Add proxy support
This commit is contained in:
parent
0ce674668c
commit
1f15a1f672
4 changed files with 35 additions and 3 deletions
10
README
10
README
|
@ -1,13 +1,12 @@
|
||||||
This is a multi-threaded CPU miner for Litecoin, fork of Jeff Garzik's
|
This is a multi-threaded CPU miner for Litecoin, fork of Jeff Garzik's
|
||||||
reference cpuminer.
|
reference cpuminer.
|
||||||
|
|
||||||
|
|
||||||
License: GPLv2. See COPYING for details.
|
License: GPLv2. See COPYING for details.
|
||||||
|
|
||||||
Dependencies:
|
Dependencies:
|
||||||
libcurl http://curl.haxx.se/libcurl/
|
libcurl http://curl.haxx.se/libcurl/
|
||||||
jansson http://www.digip.org/jansson/
|
jansson http://www.digip.org/jansson/
|
||||||
(jansson is optional, and is included in-tree)
|
(jansson is included in-tree)
|
||||||
|
|
||||||
Basic *nix build instructions:
|
Basic *nix build instructions:
|
||||||
./autogen.sh # only needed if building from git repo
|
./autogen.sh # only needed if building from git repo
|
||||||
|
@ -23,6 +22,13 @@ Basic WIN32 build instructions (on Fedora 13; requires mingw32):
|
||||||
|
|
||||||
Usage instructions: Run "minerd --help" to see options.
|
Usage instructions: Run "minerd --help" to see options.
|
||||||
|
|
||||||
|
Connecting through a proxy: Use the --proxy option.
|
||||||
|
To use a SOCKS proxy, add a socks4:// or socks5:// prefix to the proxy string.
|
||||||
|
If no protocol is specified, the proxy is assumed to be a HTTP proxy.
|
||||||
|
When the --proxy option is not used, the program honors the http_proxy
|
||||||
|
environment variable. In this case, however, libcurl 7.21.7 or newer is
|
||||||
|
needed to handle protocol prefixes.
|
||||||
|
|
||||||
Also many issues and FAQs are covered in the forum thread
|
Also many issues and FAQs are covered in the forum thread
|
||||||
dedicated to this program,
|
dedicated to this program,
|
||||||
https://bitcointalk.org/index.php?topic=55038.0
|
https://bitcointalk.org/index.php?topic=55038.0
|
||||||
|
|
22
cpu-miner.c
22
cpu-miner.c
|
@ -108,6 +108,8 @@ static int num_processors;
|
||||||
static char *rpc_url;
|
static char *rpc_url;
|
||||||
static char *rpc_userpass;
|
static char *rpc_userpass;
|
||||||
static char *rpc_user, *rpc_pass;
|
static char *rpc_user, *rpc_pass;
|
||||||
|
char *opt_proxy;
|
||||||
|
long opt_proxy_type;
|
||||||
struct thr_info *thr_info;
|
struct thr_info *thr_info;
|
||||||
static int work_thr_id;
|
static int work_thr_id;
|
||||||
int longpoll_thr_id;
|
int longpoll_thr_id;
|
||||||
|
@ -126,6 +128,7 @@ Options:\n\
|
||||||
-O, --userpass=U:P username:password pair for mining server\n\
|
-O, --userpass=U:P username:password pair for mining server\n\
|
||||||
-u, --user=USERNAME username for mining server\n\
|
-u, --user=USERNAME username for mining server\n\
|
||||||
-p, --pass=PASSWORD password for mining server\n\
|
-p, --pass=PASSWORD password for mining server\n\
|
||||||
|
-x, --proxy=[PROTOCOL://]HOST[:PORT] connect through a proxy\n\
|
||||||
-t, --threads=N number of miner threads (default: number of processors)\n\
|
-t, --threads=N number of miner threads (default: number of processors)\n\
|
||||||
-r, --retries=N number of times to retry if a network call fails\n\
|
-r, --retries=N number of times to retry if a network call fails\n\
|
||||||
(default: retry indefinitely)\n\
|
(default: retry indefinitely)\n\
|
||||||
|
@ -147,7 +150,7 @@ Options:\n\
|
||||||
-h, --help display this help text and exit\n\
|
-h, --help display this help text and exit\n\
|
||||||
";
|
";
|
||||||
|
|
||||||
static char const short_options[] = "a:c:Dhp:Pqr:R:s:t:T:o:u:O:V";
|
static char const short_options[] = "a:c:Dhp:Px:qr:R:s:t:T:o:u:O:V";
|
||||||
|
|
||||||
static struct option const options[] = {
|
static struct option const options[] = {
|
||||||
{ "algo", 1, NULL, 'a' },
|
{ "algo", 1, NULL, 'a' },
|
||||||
|
@ -157,6 +160,7 @@ static struct option const options[] = {
|
||||||
{ "no-longpoll", 0, NULL, 1003 },
|
{ "no-longpoll", 0, NULL, 1003 },
|
||||||
{ "pass", 1, NULL, 'p' },
|
{ "pass", 1, NULL, 'p' },
|
||||||
{ "protocol-dump", 0, NULL, 'P' },
|
{ "protocol-dump", 0, NULL, 'P' },
|
||||||
|
{ "proxy", 1, NULL, 'x' },
|
||||||
{ "quiet", 0, NULL, 'q' },
|
{ "quiet", 0, NULL, 'q' },
|
||||||
{ "retries", 1, NULL, 'r' },
|
{ "retries", 1, NULL, 'r' },
|
||||||
{ "retry-pause", 1, NULL, 'R' },
|
{ "retry-pause", 1, NULL, 'R' },
|
||||||
|
@ -786,6 +790,22 @@ static void parse_arg (int key, char *arg)
|
||||||
free(rpc_userpass);
|
free(rpc_userpass);
|
||||||
rpc_userpass = strdup(arg);
|
rpc_userpass = strdup(arg);
|
||||||
break;
|
break;
|
||||||
|
case 'x': /* --proxy */
|
||||||
|
if (!strncmp(arg, "socks4://", 9))
|
||||||
|
opt_proxy_type = CURLPROXY_SOCKS4;
|
||||||
|
else if (!strncmp(arg, "socks5://", 9))
|
||||||
|
opt_proxy_type = CURLPROXY_SOCKS5;
|
||||||
|
#if LIBCURL_VERSION_NUM >= 0x071200
|
||||||
|
else if (!strncmp(arg, "socks4a://", 10))
|
||||||
|
opt_proxy_type = CURLPROXY_SOCKS4A;
|
||||||
|
else if (!strncmp(arg, "socks5h://", 10))
|
||||||
|
opt_proxy_type = CURLPROXY_SOCKS5_HOSTNAME;
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
opt_proxy_type = CURLPROXY_HTTP;
|
||||||
|
free(opt_proxy);
|
||||||
|
opt_proxy = strdup(arg);
|
||||||
|
break;
|
||||||
case 1003:
|
case 1003:
|
||||||
want_longpoll = false;
|
want_longpoll = false;
|
||||||
break;
|
break;
|
||||||
|
|
2
miner.h
2
miner.h
|
@ -140,6 +140,8 @@ extern bool fulltest(const unsigned char *hash, const unsigned char *target);
|
||||||
extern int opt_timeout;
|
extern int opt_timeout;
|
||||||
extern bool want_longpoll;
|
extern bool want_longpoll;
|
||||||
extern bool have_longpoll;
|
extern bool have_longpoll;
|
||||||
|
extern char *opt_proxy;
|
||||||
|
extern long opt_proxy_type;
|
||||||
struct thread_q;
|
struct thread_q;
|
||||||
|
|
||||||
struct work_restart {
|
struct work_restart {
|
||||||
|
|
4
util.c
4
util.c
|
@ -291,6 +291,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_HEADERFUNCTION, resp_hdr_cb);
|
||||||
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &hi);
|
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &hi);
|
||||||
}
|
}
|
||||||
|
if (opt_proxy) {
|
||||||
|
curl_easy_setopt(curl, CURLOPT_PROXY, opt_proxy);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, opt_proxy_type);
|
||||||
|
}
|
||||||
if (userpass) {
|
if (userpass) {
|
||||||
curl_easy_setopt(curl, CURLOPT_USERPWD, userpass);
|
curl_easy_setopt(curl, CURLOPT_USERPWD, userpass);
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||||
|
|
Loading…
Reference in a new issue