From fd7d62df15aa07e7f89849432102886b2bff50b9 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 20 Mar 2015 10:36:29 +1100 Subject: [PATCH] Send the proxy details from the generator to the stratifier --- src/generator.c | 9 ++++----- src/stratifier.c | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/generator.c b/src/generator.c index d0f52643..1d1e4cc9 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1303,11 +1303,10 @@ static void send_subscribe(ckpool_t *ckp, proxy_instance_t *proxi) json_t *json_msg; char *msg, *buf; - JSON_CPACK(json_msg, "{sIsisssi}", - "proxy", proxi->id, - "subproxy", proxi->subid, - "enonce1", proxi->enonce1, - "nonce2len", proxi->nonce2len); + JSON_CPACK(json_msg, "{ss,ss,ss,sI,si,ss,si}", + "url", proxi->url, "auth", proxi->auth, "pass", proxi->pass, + "proxy", proxi->id, "subproxy", proxi->subid, + "enonce1", proxi->enonce1, "nonce2len", proxi->nonce2len); msg = json_dumps(json_msg, JSON_NO_UTF8); json_decref(json_msg); ASPRINTF(&buf, "subscribe=%s", msg); diff --git a/src/stratifier.c b/src/stratifier.c index ec2f97e5..422e3203 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -302,6 +302,9 @@ struct proxy_base { double diff; + char url[128]; + char auth[128]; + char pass[128]; char enonce1[32]; uchar enonce1bin[16]; int enonce1constlen; @@ -1378,6 +1381,12 @@ static void update_subscribe(ckpool_t *ckp, const char *cmd) ck_wlock(&dsdata->workbase_lock); proxy->subscribed = true; proxy->diff = ckp->startdiff; + memset(proxy->url, 0, 128); + memset(proxy->auth, 0, 128); + memset(proxy->pass, 0, 128); + strncpy(proxy->url, json_string_value(json_object_get(val, "url")), 127); + strncpy(proxy->auth, json_string_value(json_object_get(val, "auth")), 127); + strncpy(proxy->pass, json_string_value(json_object_get(val, "pass")), 127); /* Length is checked by generator */ strcpy(proxy->enonce1, json_string_value(json_object_get(val, "enonce1"))); proxy->enonce1constlen = strlen(proxy->enonce1) / 2; @@ -1397,11 +1406,11 @@ static void update_subscribe(ckpool_t *ckp, const char *cmd) ck_wunlock(&dsdata->workbase_lock); if (subid) { - LOGINFO("Upstream pool %d:%d extranonce2 length %d, max proxy clients %"PRId64, - id, subid, proxy->nonce2len, proxy->max_clients); + LOGINFO("Upstream pool %s %d:%d extranonce2 length %d, max proxy clients %"PRId64, + proxy->url, id, subid, proxy->nonce2len, proxy->max_clients); } else { - LOGNOTICE("Upstream pool %d extranonce2 length %d, max proxy clients %"PRId64, - id, proxy->nonce2len, proxy->max_clients); + LOGNOTICE("Upstream pool %s %d extranonce2 length %d, max proxy clients %"PRId64, + proxy->url, id, proxy->nonce2len, proxy->max_clients); } json_decref(val); }