Added token support

This commit is contained in:
qorg11 2021-04-04 14:50:24 +02:00
parent 89ad06ce23
commit c81acdd4fd
No known key found for this signature in database
GPG Key ID: 343FC20A4ACA62B9
2 changed files with 15 additions and 4 deletions

View File

@ -20,7 +20,7 @@ main(int argc, char **argv)
tor_flag = i2p_flag = false;
bool ipv6_flag, ipv4_flag;
ipv6_flag = ipv4_flag = false;
char *token = NULL;
long silent_flag = 0L;
char *buffer = (char *)calloc(1024,sizeof(char));
if(buffer == NULL) {
@ -44,6 +44,7 @@ main(int argc, char **argv)
{"server",required_argument,0,'s'},
{"help" ,no_argument ,0,'h'},
{"tor" ,no_argument ,0,'t'},
{"token" ,required_argument,0,'T'},
{"i2p" ,no_argument ,0,'i'},
{"silent",no_argument ,0,'S'},
{"ipv4" ,no_argument ,0,'4'},
@ -53,7 +54,7 @@ main(int argc, char **argv)
};
int c = 0;
while((c = getopt_long(argc,argv, "46htiSs:",
while((c = getopt_long(argc,argv, "46hT:tiSs:",
long_options,&option_index)) != -1) {
switch(c) {
case 's':
@ -72,6 +73,9 @@ main(int argc, char **argv)
case 'S':
silent_flag = true;
break;
case 'T':
token = optarg;
break;
case '4':
ipv4_flag = true;
break;
@ -144,6 +148,11 @@ main(int argc, char **argv)
CURLFORM_COPYNAME,"file",
CURLFORM_COPYCONTENTS,argv[i],
CURLFORM_END);
if(token)
curl_formadd(&post,&last,
CURLFORM_COPYNAME,"token",
CURLFORM_COPYCONTENTS,token,
CURLFORM_END);
curl_easy_setopt(easy_handle,CURLOPT_NOPROGRESS,silent_flag);
curl_easy_setopt(easy_handle,CURLOPT_PROGRESSFUNCTION,progress);

View File

@ -35,7 +35,8 @@ store_link(const char *path, const char *buf)
void
print_help()
{
printf("--server <server>: specifies the lainsafe server\n%s\n%s\n%s\n%s\n%s\n%s",
printf("--server <server>: specifies the lainsafe server\n%s\n%s\n%s\n%s\n%s\n%s\n%s",
"-t|--token: Authentication token (https://u.kalli.st)",
"--tor: uses tor.",
"--i2p: uses i2p.",
"-6|--ipv6: uses IPv6 only.",
@ -55,8 +56,9 @@ progress(void *clientp,
/* So I don't get a warning */
dltotal += 1;
dlnow += 1;
printf("\r%0.f uploaded of %0.f (%0.f%%)",ulnow,ultotal,
printf("\r%0.f uploaded of %0.f (\E[32;1m%0.f%%\E[30;0m)",ulnow,ultotal,
ulnow*100/ultotal);
fflush(stdout);
}