Implement socks4 proxy support.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
diff --git a/README b/README
index d8e0285..e6083a9 100644
--- a/README
+++ b/README
@@ -148,6 +148,7 @@ Options for both config file and command line:
--sched-start <arg> Set a time of day in HH:MM to start mining (a once off without a stop time)
--sched-stop <arg> Set a time of day in HH:MM to stop mining (will quit without a start time)
--shares <arg> Quit after mining N shares (default: unlimited)
+--socks-proxy <arg> Set socks4 proxy (host:port)
--submit-stale Submit shares even if they would normally be considered stale
--syslog Use system log for output messages (default: standard error)
--text-only|-T Disable ncurses formatted screen output
diff --git a/main.c b/main.c
index 554993c..423a01e 100644
--- a/main.c
+++ b/main.c
@@ -307,6 +307,7 @@ struct block {
static struct block *blocks = NULL;
static char *opt_kernel = NULL;
+char *opt_socks_proxy = NULL;
static const char def_conf[] = "cgminer.conf";
static bool config_loaded = false;
@@ -1700,6 +1701,9 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--shares",
opt_set_intval, NULL, &opt_shares,
"Quit after mining N shares (default: unlimited)"),
+ OPT_WITH_ARG("--socks-proxy",
+ opt_set_charp, NULL, &opt_socks_proxy,
+ "Set socks4 proxy (host:port)"),
OPT_WITHOUT_ARG("--submit-stale",
opt_set_bool, &opt_submit_stale,
"Submit shares even if they would normally be considered stale"),
@@ -3241,6 +3245,8 @@ static void write_config(FILE *fcfg)
fprintf(fcfg, ",\n\"sched-time\" : \"%d:%d\"", schedstart.tm.tm_hour, schedstart.tm.tm_min);
if (schedstop.enable)
fprintf(fcfg, ",\n\"stop-time\" : \"%d:%d\"", schedstop.tm.tm_hour, schedstop.tm.tm_min);
+ if (opt_socks_proxy && *opt_socks_proxy)
+ fprintf(fcfg, ",\n\"socks-proxy\" : \"%s\"", opt_socks_proxy);
for(i = 0; i < nDevs; i++)
if (!gpus[i].enabled)
break;
diff --git a/miner.h b/miner.h
index 6092b9c..da60ce5 100644
--- a/miner.h
+++ b/miner.h
@@ -412,6 +412,7 @@ extern bool opt_debug;
extern bool opt_protocol;
extern bool opt_log_output;
extern char *opt_kernel_path;
+extern char *opt_socks_proxy;
extern char *cgminer_path;
extern bool opt_autofan;
extern bool opt_autoengine;
diff --git a/util.c b/util.c
index 2314339..86fa2df 100644
--- a/util.c
+++ b/util.c
@@ -345,6 +345,10 @@ json_t *json_rpc_call(CURL *curl, const char *url,
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, resp_hdr_cb);
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &hi);
curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_TRY);
+ if (opt_socks_proxy) {
+ curl_easy_setopt(curl, CURLOPT_PROXY, opt_socks_proxy);
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+ }
if (userpass) {
curl_easy_setopt(curl, CURLOPT_USERPWD, userpass);
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);