Added -4 and -6 options to force ipv4 or ipv6.
This commit is contained in:
parent
3c03246af4
commit
fbc96d4b47
1 changed files with 26 additions and 3 deletions
|
@ -18,6 +18,9 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
int tor_flag, i2p_flag;
|
int tor_flag, i2p_flag;
|
||||||
tor_flag = i2p_flag = 0;
|
tor_flag = i2p_flag = 0;
|
||||||
|
int ipv6_flag, ipv4_flag;
|
||||||
|
ipv6_flag = ipv4_flag = 0;
|
||||||
|
|
||||||
long silent_flag = 0L;
|
long silent_flag = 0L;
|
||||||
char *buffer = (char *)calloc(1024,sizeof(char));
|
char *buffer = (char *)calloc(1024,sizeof(char));
|
||||||
if(buffer == NULL) {
|
if(buffer == NULL) {
|
||||||
|
@ -42,12 +45,14 @@ main(int argc, char **argv)
|
||||||
{"tor" ,no_argument ,0,'t'},
|
{"tor" ,no_argument ,0,'t'},
|
||||||
{"i2p" ,no_argument ,0,'i'},
|
{"i2p" ,no_argument ,0,'i'},
|
||||||
{"silent",no_argument ,0,'S'},
|
{"silent",no_argument ,0,'S'},
|
||||||
|
{"ipv4" ,no_argument ,0,'4'},
|
||||||
|
{"ipv6" ,no_argument ,0,'6'},
|
||||||
{0 ,0 ,0, 0 }
|
{0 ,0 ,0, 0 }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int c = 0;
|
int c = 0;
|
||||||
while((c = getopt_long(argc,argv, "htiSs:",
|
while((c = getopt_long(argc,argv, "46htiSs:",
|
||||||
long_options,&option_index)) != -1) {
|
long_options,&option_index)) != -1) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 's':
|
case 's':
|
||||||
|
@ -66,6 +71,12 @@ main(int argc, char **argv)
|
||||||
case 'S':
|
case 'S':
|
||||||
silent_flag = 1L;
|
silent_flag = 1L;
|
||||||
break;
|
break;
|
||||||
|
case '4':
|
||||||
|
ipv4_flag = 1;
|
||||||
|
break;
|
||||||
|
case '6':
|
||||||
|
ipv6_flag = 1;
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
print_usage();
|
print_usage();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -103,16 +114,28 @@ main(int argc, char **argv)
|
||||||
CURLPROXY_HTTP);
|
CURLPROXY_HTTP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Which address to use */
|
||||||
|
|
||||||
|
if(ipv6_flag)
|
||||||
|
curl_easy_setopt(easy_handle,CURLOPT_IPRESOLVE,
|
||||||
|
CURL_IPRESOLVE_V6);
|
||||||
|
else if(ipv4_flag)
|
||||||
|
curl_easy_setopt(easy_handle,CURLOPT_IPRESOLVE,
|
||||||
|
CURL_IPRESOLVE_V4);
|
||||||
|
else
|
||||||
|
curl_easy_setopt(easy_handle,CURLOPT_IPRESOLVE,
|
||||||
|
CURL_IPRESOLVE_WHATEVER);
|
||||||
|
|
||||||
/* Form parameters */
|
/* Form parameters */
|
||||||
|
|
||||||
/* File name */
|
/* File name */
|
||||||
curl_formadd(&post,&last,
|
curl_formadd(&post,&last,
|
||||||
CURLFORM_COPYNAME, "file",
|
CURLFORM_COPYNAME,"file",
|
||||||
CURLFORM_FILE,argv[optind],
|
CURLFORM_FILE,argv[optind],
|
||||||
CURLFORM_END);
|
CURLFORM_END);
|
||||||
/* Actual file content */
|
/* Actual file content */
|
||||||
curl_formadd(&post,&last,
|
curl_formadd(&post,&last,
|
||||||
CURLFORM_COPYNAME, "file",
|
CURLFORM_COPYNAME,"file",
|
||||||
CURLFORM_COPYCONTENTS,argv[optind],
|
CURLFORM_COPYCONTENTS,argv[optind],
|
||||||
CURLFORM_END);
|
CURLFORM_END);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue