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
22
cpu-miner.c
22
cpu-miner.c
|
@ -769,20 +769,28 @@ static void parse_arg (int key, char *arg)
|
||||||
rpc_user = strdup(arg);
|
rpc_user = strdup(arg);
|
||||||
break;
|
break;
|
||||||
case 'o': /* --url */
|
case 'o': /* --url */
|
||||||
if (strncmp(arg, "http://", 7) &&
|
p = strstr(arg, "://");
|
||||||
strncmp(arg, "https://", 8))
|
if (p) {
|
||||||
show_usage_and_exit(1);
|
if (strncmp(arg, "http://", 7) && strncmp(arg, "https://", 8))
|
||||||
free(rpc_url);
|
show_usage_and_exit(1);
|
||||||
rpc_url = strdup(arg);
|
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, '@');
|
p = strchr(rpc_url, '@');
|
||||||
if (p) {
|
if (p) {
|
||||||
char *ap = strstr(rpc_url, "//") + 2;
|
char *ap = strstr(rpc_url, "://") + 3;
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
if (!strchr(ap, ':'))
|
if (!strchr(ap, ':'))
|
||||||
show_usage_and_exit(1);
|
show_usage_and_exit(1);
|
||||||
free(rpc_userpass);
|
free(rpc_userpass);
|
||||||
rpc_userpass = strdup(ap);
|
rpc_userpass = strdup(ap);
|
||||||
strcpy(ap, p + 1);
|
memmove(ap, p + 1, (strlen(p + 1) + 1) * sizeof(char));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'O': /* --userpass */
|
case 'O': /* --userpass */
|
||||||
|
|
Loading…
Reference in a new issue