Extract username and password specified in URL
This commit is contained in:
parent
6599e7d1a7
commit
9435078a8e
1 changed files with 11 additions and 0 deletions
11
cpu-miner.c
11
cpu-miner.c
|
@ -673,6 +673,7 @@ static void show_usage_and_exit(int status)
|
||||||
|
|
||||||
static void parse_arg (int key, char *arg)
|
static void parse_arg (int key, char *arg)
|
||||||
{
|
{
|
||||||
|
char *p;
|
||||||
int v, i;
|
int v, i;
|
||||||
|
|
||||||
switch(key) {
|
switch(key) {
|
||||||
|
@ -761,6 +762,16 @@ static void parse_arg (int key, char *arg)
|
||||||
|
|
||||||
free(rpc_url);
|
free(rpc_url);
|
||||||
rpc_url = strdup(arg);
|
rpc_url = strdup(arg);
|
||||||
|
p = strchr(rpc_url, '@');
|
||||||
|
if (p) {
|
||||||
|
char *ap = strstr(rpc_url, "//") + 2;
|
||||||
|
*p = '\0';
|
||||||
|
if (!strchr(ap, ':'))
|
||||||
|
show_usage_and_exit(1);
|
||||||
|
free(rpc_userpass);
|
||||||
|
rpc_userpass = strdup(ap);
|
||||||
|
strcpy(ap, p + 1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'O': /* --userpass */
|
case 'O': /* --userpass */
|
||||||
if (!strchr(arg, ':'))
|
if (!strchr(arg, ':'))
|
||||||
|
|
Loading…
Reference in a new issue