Browse Source

Change config format to take url auth and pass for both btcd and proxy and choose which to use in the generator based on proxy bool

master
Con Kolivas 11 years ago
parent
commit
8af64746bf
  1. 12
      src/ckpool.c
  2. 20
      src/generator.c

12
src/ckpool.c

@ -292,9 +292,9 @@ static void parse_btcds(ckpool_t *ckp, json_t *arr_val, int arr_size)
ckp->btcdpass = ckzalloc(sizeof(char *) * arr_size);
for (i = 0; i < arr_size; i++) {
val = json_array_get(arr_val, i);
json_get_string(&ckp->btcdurl[i], val, "btcdurl");
json_get_string(&ckp->btcdauth[i], val, "btcdauth");
json_get_string(&ckp->btcdpass[i], val, "btcdpass");
json_get_string(&ckp->btcdurl[i], val, "url");
json_get_string(&ckp->btcdauth[i], val, "auth");
json_get_string(&ckp->btcdpass[i], val, "pass");
}
}
@ -309,9 +309,9 @@ static void parse_proxies(ckpool_t *ckp, json_t *arr_val, int arr_size)
ckp->proxypass = ckzalloc(sizeof(char *) * arr_size);
for (i = 0; i < arr_size; i++) {
val = json_array_get(arr_val, i);
json_get_string(&ckp->proxyurl[i], val, "proxyurl");
json_get_string(&ckp->proxyauth[i], val, "proxyauth");
json_get_string(&ckp->proxypass[i], val, "proxypass");
json_get_string(&ckp->proxyurl[i], val, "url");
json_get_string(&ckp->proxyauth[i], val, "auth");
json_get_string(&ckp->proxypass[i], val, "pass");
}
}

20
src/generator.c

@ -101,10 +101,11 @@ out:
return ret;
}
/* FIXME: Hard wired to just use config 0 for now */
int generator(proc_instance_t *pi)
{
char *url, *auth, *pass, *userpass = NULL;
ckpool_t *ckp = pi->ckp;
char *userpass = NULL;
gbtbase_t gbt;
connsock_t cs;
int ret = 1;
@ -112,13 +113,22 @@ int generator(proc_instance_t *pi)
memset(&cs, 0, sizeof(cs));
memset(&gbt, 0, sizeof(gbt));
if (!extract_sockaddr(ckp->btcdurl[0], &cs.url, &cs.port)) {
LOGWARNING("Failed to extract address from %s", ckp->btcdurl[0]);
if (!ckp->proxy) {
url = ckp->btcdurl[0];
auth = ckp->btcdauth[0];
pass = ckp->btcdpass[0];
} else {
url = ckp->proxyurl[0];
auth = ckp->proxyauth[0];
pass = ckp->proxypass[0];
}
if (!extract_sockaddr(url, &cs.url, &cs.port)) {
LOGWARNING("Failed to extract address from %s", url);
goto out;
}
userpass = strdup(ckp->btcdauth[0]);
userpass = strdup(auth);
realloc_strcat(&userpass, ":");
realloc_strcat(&userpass, ckp->btcdpass[0]);
realloc_strcat(&userpass, pass);
cs.auth = http_base64(userpass);
if (!cs.auth) {
LOGWARNING("Failed to create base64 auth from %s", userpass);

Loading…
Cancel
Save