From 3f9d8727dcfc316e81fd1cabc56652562272fd9b Mon Sep 17 00:00:00 2001 From: pooler Date: Sat, 18 Jan 2014 22:56:48 +0100 Subject: [PATCH] Make the --url option mandatory --- cpu-miner.c | 25 ++++++++++++++----------- minerd.1 | 11 ++++------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cpu-miner.c b/cpu-miner.c index aed0214..c7b4aa8 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -39,7 +39,6 @@ #include "miner.h" #define PROGRAM_NAME "minerd" -#define DEF_RPC_URL "http://127.0.0.1:9332/" #define LP_SCANTIME 60 #ifdef __linux /* Linux specific policy and affinity management */ @@ -168,7 +167,7 @@ Options:\n\ -a, --algo=ALGO specify the algorithm to use\n\ scrypt scrypt(1024, 1, 1) (default)\n\ sha256d SHA-256d\n\ - -o, --url=URL URL of mining server (default: " DEF_RPC_URL ")\n\ + -o, --url=URL URL of mining server\n\ -O, --userpass=U:P username:password pair for mining server\n\ -u, --user=USERNAME username for mining server\n\ -p, --pass=PASSWORD password for mining server\n\ @@ -1267,20 +1266,31 @@ int main(int argc, char *argv[]) long flags; int i; - rpc_url = strdup(DEF_RPC_URL); rpc_user = strdup(""); rpc_pass = strdup(""); /* parse command line */ parse_cmdline(argc, argv); + if (!opt_benchmark && !rpc_url) { + fprintf(stderr, "%s: no URL supplied\n", argv[0]); + show_usage_and_exit(1); + } + + if (!rpc_userpass) { + rpc_userpass = malloc(strlen(rpc_user) + strlen(rpc_pass) + 2); + if (!rpc_userpass) + return 1; + sprintf(rpc_userpass, "%s:%s", rpc_user, rpc_pass); + } + pthread_mutex_init(&applog_lock, NULL); pthread_mutex_init(&stats_lock, NULL); pthread_mutex_init(&g_work_lock, NULL); pthread_mutex_init(&stratum.sock_lock, NULL); pthread_mutex_init(&stratum.work_lock, NULL); - flags = strncmp(rpc_url, "https:", 6) + flags = !opt_benchmark && strncmp(rpc_url, "https:", 6) ? (CURL_GLOBAL_ALL & ~CURL_GLOBAL_SSL) : CURL_GLOBAL_ALL; if (curl_global_init(flags)) { @@ -1323,13 +1333,6 @@ int main(int argc, char *argv[]) if (!opt_n_threads) opt_n_threads = num_processors; - if (!rpc_userpass) { - rpc_userpass = malloc(strlen(rpc_user) + strlen(rpc_pass) + 2); - if (!rpc_userpass) - return 1; - sprintf(rpc_userpass, "%s:%s", rpc_user, rpc_pass); - } - #ifdef HAVE_SYSLOG_H if (use_syslog) openlog("cpuminer", LOG_PID, LOG_USER); diff --git a/minerd.1 b/minerd.1 index 6747122..dff8954 100644 --- a/minerd.1 +++ b/minerd.1 @@ -1,4 +1,4 @@ -.TH MINERD 1 "November 2013" "cpuminer 2.3.2" +.TH MINERD 1 "January 2014" "cpuminer 2.3.2" .SH NAME minerd \- CPU miner for Bitcoin and Litecoin .SH SYNOPSIS @@ -81,7 +81,7 @@ Run in offline benchmark mode. Run in the background as a daemon. .TP \fB\-\-cert\fR=\fIFILE\fR -Set a SSL certificate to use with the mining server. +Set an SSL certificate to use with the mining server. Only supported when using the HTTPS protocol. .TP \fB\-c\fR, \fB\-\-config\fR=\fIFILE\fR @@ -115,12 +115,9 @@ Do not switch to Stratum, even if the server advertises support for it. \fB\-o\fR, \fB\-\-url\fR=[\fISCHEME\fR://][\fIUSERNAME\fR[:\fIPASSWORD\fR]@]\fIHOST\fR:\fIPORT\fR[/\fIPATH\fR] Set the URL of the mining server to connect to. Supported schemes are \fBhttp\fR, \fBhttps\fR and \fBstratum+tcp\fR. -If no scheme is specified, http is used. +If no scheme is specified, http is assumed. Specifying a \fIPATH\fR is only supported for HTTP and HTTPS. Specifying credentials has the same effect as using the \fB\-O\fR option. -If no mining server is provided, -the miner will try to connect to http://127.0.0.1:9332/, -corresponding to the default settings for a local Litecoin daemon. .TP \fB\-O\fR, \fB\-\-userpass\fR=\fIUSERNAME\fR:\fIPASSWORD\fR Set the credentials to use for connecting to the mining server. @@ -166,7 +163,7 @@ Any username previously set with \fB\-O\fR is discarded. \fB\-V\fR, \fB\-\-version\fR Display version information and quit. .TP -\fB\-x\fR, \fB\-\-proxy\fR=[\fISCHEME\fR://]\fIHOST\fR:\fIPORT\fR +\fB\-x\fR, \fB\-\-proxy\fR=[\fISCHEME\fR://][\fIUSERNAME\fR:\fIPASSWORD\fR@]\fIHOST\fR:\fIPORT\fR Connect to the mining server through a proxy. Supported schemes are: \fBhttp\fR, \fBsocks4\fR, \fBsocks5\fR. Since libcurl 7.18.0, the following are also supported: