Browse Source

Add userid parsing to proxy.add command

master
Con Kolivas 10 years ago
parent
commit
9f3a1bfb4d
  1. 12
      src/generator.c

12
src/generator.c

@ -2182,7 +2182,8 @@ static void parse_addproxy(ckpool_t *ckp, gdata_t *gdata, const int sockd, const
proxy_instance_t *proxy; proxy_instance_t *proxy;
json_error_t err_val; json_error_t err_val;
json_t *val = NULL; json_t *val = NULL;
int id; int id, userid;
bool global;
val = json_loads(buf, 0, &err_val); val = json_loads(buf, 0, &err_val);
if (unlikely(!val)) { if (unlikely(!val)) {
@ -2197,6 +2198,10 @@ static void parse_addproxy(ckpool_t *ckp, gdata_t *gdata, const int sockd, const
val = json_errormsg("Failed to decode url/auth/pass in addproxy %s", buf); val = json_errormsg("Failed to decode url/auth/pass in addproxy %s", buf);
goto out; goto out;
} }
if (json_get_int(&userid, val, "userid"))
global = false;
else
global = true;
mutex_lock(&gdata->lock); mutex_lock(&gdata->lock);
id = ckp->proxies++; id = ckp->proxies++;
@ -2209,7 +2214,10 @@ static void parse_addproxy(ckpool_t *ckp, gdata_t *gdata, const int sockd, const
proxy = __add_proxy(ckp, gdata, id); proxy = __add_proxy(ckp, gdata, id);
mutex_unlock(&gdata->lock); mutex_unlock(&gdata->lock);
LOGNOTICE("Adding proxy %d:%s", id, proxy->url); if (global)
LOGNOTICE("Adding global proxy %d:%s", id, proxy->url);
else
LOGNOTICE("Adding user %d proxy %d:%s", userid, id, proxy->url);
prepare_proxy(proxy); prepare_proxy(proxy);
JSON_CPACK(val, "{si,ss,ss,ss}", JSON_CPACK(val, "{si,ss,ss,ss}",
"id", proxy->id, "url", url, "auth", auth, "pass", pass); "id", proxy->id, "url", url, "auth", auth, "pass", pass);

Loading…
Cancel
Save