Assume HTTP if no protocol is specified
This commit is contained in:
parent
f073f8ed58
commit
8625cf40f6
1 changed files with 15 additions and 7 deletions
16
cpu-miner.c
16
cpu-miner.c
|
@ -769,20 +769,28 @@ static void parse_arg (int key, char *arg)
|
|||
rpc_user = strdup(arg);
|
||||
break;
|
||||
case 'o': /* --url */
|
||||
if (strncmp(arg, "http://", 7) &&
|
||||
strncmp(arg, "https://", 8))
|
||||
p = strstr(arg, "://");
|
||||
if (p) {
|
||||
if (strncmp(arg, "http://", 7) && strncmp(arg, "https://", 8))
|
||||
show_usage_and_exit(1);
|
||||
free(rpc_url);
|
||||
rpc_url = strdup(arg);
|
||||
} else {
|
||||
if (!strlen(arg) || *arg == '/')
|
||||
show_usage_and_exit(1);
|
||||
free(rpc_url);
|
||||
rpc_url = malloc((strlen(arg) + 8) * sizeof(char));
|
||||
sprintf(rpc_url, "http://%s", arg);
|
||||
}
|
||||
p = strchr(rpc_url, '@');
|
||||
if (p) {
|
||||
char *ap = strstr(rpc_url, "//") + 2;
|
||||
char *ap = strstr(rpc_url, "://") + 3;
|
||||
*p = '\0';
|
||||
if (!strchr(ap, ':'))
|
||||
show_usage_and_exit(1);
|
||||
free(rpc_userpass);
|
||||
rpc_userpass = strdup(ap);
|
||||
strcpy(ap, p + 1);
|
||||
memmove(ap, p + 1, (strlen(p + 1) + 1) * sizeof(char));
|
||||
}
|
||||
break;
|
||||
case 'O': /* --userpass */
|
||||
|
|
Loading…
Reference in a new issue