From 62f9f7b300106675d1b5fb8b65aeefa019715a36 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 17 Jun 2014 00:50:02 +1000 Subject: [PATCH] Do basic authorisation, duplicating the required 2nd UID --- src/stratifier.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index eec5c487..0e40c149 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1194,6 +1194,7 @@ static bool send_recv_auth(stratum_instance_t *client) { char *msg, *dump, *buf; char cdfield[64]; + bool ret = false; json_t *val; ts_t now; @@ -1217,12 +1218,20 @@ static bool send_recv_auth(stratum_instance_t *client) dealloc(dump); buf = send_recv_ckdb(client->ckp, msg); if (likely(buf)) { + char *secondaryuserid, *response = alloca(128); + LOGWARNING("Got auth response: %s", buf); - dealloc(buf); + sscanf(buf, "id.%*d.%s", response); + secondaryuserid = response; + strsep(&secondaryuserid, "."); + if (!strcmp(response, "added")) { + client->secondaryuserid = strdup(secondaryuserid); + ret = true; + } } else LOGWARNING("Got no auth response :("); dealloc(msg); - return true; + return ret; } static json_t *parse_authorise(stratum_instance_t *client, json_t *params_val, json_t **err_val)