Add --i2p flag
This commit is contained in:
parent
693be32ee3
commit
509c6e9c68
1 changed files with 28 additions and 9 deletions
|
@ -1,11 +1,13 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <curl/curl.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
size_t static write_data(void *buffer, size_t size, size_t nmemb, void *userp)
|
|
||||||
|
size_t static write_data(void *buffer, size_t size, size_t nmemb,
|
||||||
|
void *userp)
|
||||||
{
|
{
|
||||||
memcpy(userp, buffer, nmemb*size);
|
memcpy(userp, buffer, nmemb*size);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -33,7 +35,8 @@ 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;
|
||||||
|
|
||||||
int tor_flag = 0;
|
int tor_flag, i2p_flag;
|
||||||
|
tor_flag = i2p_flag = 0;
|
||||||
|
|
||||||
char *buffer = (char *)calloc(1024,sizeof(char));
|
char *buffer = (char *)calloc(1024,sizeof(char));
|
||||||
char server[256] = "https://lainsafe.kalli.st";
|
char server[256] = "https://lainsafe.kalli.st";
|
||||||
|
@ -53,11 +56,13 @@ main(int argc, char **argv)
|
||||||
{"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'},
|
{"tor" ,no_argument ,0,'t'},
|
||||||
|
{"i2p" ,no_argument ,0,'i'},
|
||||||
{0 ,0 ,0, 0 }
|
{0 ,0 ,0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
int c = 0;
|
int c = 0;
|
||||||
while((c = getopt_long(argc,argv, "hts:",long_options,&option_index)) != -1) {
|
while((c = getopt_long(argc,argv, "htis:",
|
||||||
|
long_options,&option_index)) != -1) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 's':
|
case 's':
|
||||||
strncpy(server,optarg,256);
|
strncpy(server,optarg,256);
|
||||||
|
@ -66,7 +71,12 @@ main(int argc, char **argv)
|
||||||
print_help();
|
print_help();
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case 't': tor_flag = 1; break;
|
case 't':
|
||||||
|
tor_flag = 1;
|
||||||
|
break;
|
||||||
|
case 'i':
|
||||||
|
i2p_flag = 1;
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
print_usage();
|
print_usage();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -79,17 +89,26 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* curl options */
|
/* curl options */
|
||||||
curl_easy_setopt(easy_handle, CURLOPT_WRITEFUNCTION, write_data);
|
curl_easy_setopt(easy_handle, CURLOPT_WRITEFUNCTION, write_data);
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_WRITEDATA,buffer);
|
curl_easy_setopt(easy_handle,CURLOPT_WRITEDATA,buffer);
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_URL,server);
|
curl_easy_setopt(easy_handle,CURLOPT_URL,server);
|
||||||
|
|
||||||
if(tor_flag) {
|
/* Proxy options */
|
||||||
|
|
||||||
|
if(tor_flag && i2p_flag) {
|
||||||
|
fprintf(stderr,"Tor and I2P can't be used at once\n");
|
||||||
|
return -1;
|
||||||
|
} else if(tor_flag) {
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_PROXY,"127.0.0.1:9050");
|
curl_easy_setopt(easy_handle,CURLOPT_PROXY,"127.0.0.1:9050");
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_PROXYTYPE,
|
curl_easy_setopt(easy_handle,CURLOPT_PROXYTYPE,
|
||||||
CURLPROXY_SOCKS5_HOSTNAME);
|
CURLPROXY_SOCKS5_HOSTNAME);
|
||||||
|
} else if(i2p_flag) {
|
||||||
|
curl_easy_setopt(easy_handle,CURLOPT_PROXY,"127.0.0.1:4444");
|
||||||
|
curl_easy_setopt(easy_handle,CURLOPT_PROXYTYPE,
|
||||||
|
CURLPROXY_HTTP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Form parameters */
|
/* Form parameters */
|
||||||
|
|
||||||
/* File name */
|
/* File name */
|
||||||
|
@ -111,6 +130,6 @@ main(int argc, char **argv)
|
||||||
free(buffer);
|
free(buffer);
|
||||||
curl_formfree(post);
|
curl_formfree(post);
|
||||||
curl_easy_cleanup(easy_handle);
|
curl_easy_cleanup(easy_handle);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue