Browse Source

Do basic authorisation, duplicating the required 2nd UID

master
Con Kolivas 11 years ago
parent
commit
62f9f7b300
  1. 13
      src/stratifier.c

13
src/stratifier.c

@ -1194,6 +1194,7 @@ static bool send_recv_auth(stratum_instance_t *client)
{ {
char *msg, *dump, *buf; char *msg, *dump, *buf;
char cdfield[64]; char cdfield[64];
bool ret = false;
json_t *val; json_t *val;
ts_t now; ts_t now;
@ -1217,12 +1218,20 @@ static bool send_recv_auth(stratum_instance_t *client)
dealloc(dump); dealloc(dump);
buf = send_recv_ckdb(client->ckp, msg); buf = send_recv_ckdb(client->ckp, msg);
if (likely(buf)) { if (likely(buf)) {
char *secondaryuserid, *response = alloca(128);
LOGWARNING("Got auth response: %s", buf); 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 } else
LOGWARNING("Got no auth response :("); LOGWARNING("Got no auth response :(");
dealloc(msg); dealloc(msg);
return true; return ret;
} }
static json_t *parse_authorise(stratum_instance_t *client, json_t *params_val, json_t **err_val) static json_t *parse_authorise(stratum_instance_t *client, json_t *params_val, json_t **err_val)

Loading…
Cancel
Save