Removed tor and I2P flags, repleaced by --socks-proxy and --httproxy

which both take them a full address (127.0.0.1:9050 for example)
This commit is contained in:
qorg11 2021-05-20 13:56:23 +02:00
parent 807e1302fe
commit 50a2682cab
No known key found for this signature in database
GPG Key ID: 343FC20A4ACA62B9
3 changed files with 32 additions and 26 deletions

View File

@ -16,13 +16,17 @@ main(int argc, char **argv)
struct curl_httppost *post = NULL; struct curl_httppost *post = NULL;
struct curl_httppost *last = NULL; struct curl_httppost *last = NULL;
bool tor_flag, i2p_flag; bool socks_proxy_flag, http_proxy_flag;
tor_flag = i2p_flag = false; socks_proxy_flag = http_proxy_flag = false;
bool ipv6_flag, ipv4_flag; bool ipv6_flag, ipv4_flag;
ipv6_flag = ipv4_flag = false; ipv6_flag = ipv4_flag = false;
char *token = NULL; char *token = NULL;
long silent_flag = 0L; long silent_flag = 0L;
char *buffer = (char *)calloc(1024,sizeof(char)); char *buffer = (char *)calloc(1024,sizeof(char));
char *socks_proxy_url, *http_proxy_url;
if(buffer == NULL) { if(buffer == NULL) {
fprintf(stderr,"Error allocating memory!\n"); fprintf(stderr,"Error allocating memory!\n");
return -1; return -1;
@ -41,20 +45,20 @@ main(int argc, char **argv)
int option_index = 0; int option_index = 0;
static struct option long_options[] = { static struct option long_options[] = {
{"server",required_argument,0,'s'}, {"server", required_argument,0,'s'},
{"help" ,no_argument ,0,'h'}, {"help" , no_argument ,0,'h'},
{"tor" ,no_argument ,0,'t'}, {"socks-proxy", required_argument,0,'p'},
{"token" ,required_argument,0,'T'}, {"token" , required_argument,0,'T'},
{"i2p" ,no_argument ,0,'i'}, {"http-proxy", no_argument ,0,'P'},
{"silent",no_argument ,0,'S'}, {"silent", no_argument ,0,'S'},
{"ipv4" ,no_argument ,0,'4'}, {"ipv4" , no_argument ,0,'4'},
{"ipv6" ,no_argument ,0,'6'}, {"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, "46hT:tiSs:", while((c = getopt_long(argc,argv, "46hT:p:P:Ss:",
long_options,&option_index)) != -1) { long_options,&option_index)) != -1) {
switch(c) { switch(c) {
case 's': case 's':
@ -64,11 +68,13 @@ main(int argc, char **argv)
print_help(); print_help();
return 0; return 0;
break; break;
case 't': case 'p':
tor_flag = true; socks_proxy_url = optarg;
socks_proxy_flag = true;
break; break;
case 'i': case 'P':
i2p_flag = true; http_proxy_url = optarg;
http_proxy_flag = true;
break; break;
case 'S': case 'S':
silent_flag = true; silent_flag = true;
@ -106,15 +112,15 @@ main(int argc, char **argv)
/* Proxy options */ /* Proxy options */
if(tor_flag && i2p_flag) { if(socks_proxy_flag && http_proxy_flag) {
fprintf(stderr,"Tor and I2P can't be used at once\n"); fprintf(stderr,"Socks_Proxy and HTTP_PROXY can't be used at once\n");
return -1; return -1;
} else if(tor_flag) { } else if(socks_proxy_flag) {
curl_easy_setopt(easy_handle,CURLOPT_PROXY,tor_proxy_url); curl_easy_setopt(easy_handle,CURLOPT_PROXY,socks_proxy_url);
curl_easy_setopt(easy_handle,CURLOPT_PROXYTYPE, curl_easy_setopt(easy_handle,CURLOPT_PROXYTYPE,
CURLPROXY_SOCKS5_HOSTNAME); CURLPROXY_SOCKS5_HOSTNAME);
} else if(i2p_flag) { } else if(http_proxy_flag) {
curl_easy_setopt(easy_handle,CURLOPT_PROXY,i2p_proxy_url); curl_easy_setopt(easy_handle,CURLOPT_PROXY,http_proxy_url);
curl_easy_setopt(easy_handle,CURLOPT_PROXYTYPE, curl_easy_setopt(easy_handle,CURLOPT_PROXYTYPE,
CURLPROXY_HTTP); CURLPROXY_HTTP);
} }

View File

@ -14,7 +14,7 @@ write_data(void *buffer, size_t size, size_t nmemb,
void void
print_usage() print_usage()
{ {
printf("USAGE: clainsafecli [--tor|--i2p] [-6|-4] [--server] file\n"); printf("USAGE: clainsafecli [--socks-proxy=socks_address|--http_proxy=proxy_address] [-6|-4] [--server] file\n");
return; return;
} }

View File

@ -5,11 +5,11 @@ char *server = "https://lainsafe.kalli.st";
/* proxy urls, socks and http. in that order, by default they're /* proxy urls, socks and http. in that order, by default they're
* configured to be used for tor and i2p, but if you have another * configured to be used for tor and i2p, but if you have another
*socks/http proxy, you can set it here. * socks/http proxy, you can set it here.
*/ */
const char tor_proxy_url[256] = "127.0.0.1:9050"; /* socks proxy */ int socks_proxy_port = 9050; /* Tor */
const char i2p_proxy_url[256] = "127.0.0.1:4444"; /* http proxy */ int http_proxy_port = 4444; /* I2P */
/* Enable "history" files and where to store that file */ /* Enable "history" files and where to store that file */