From 9f3a1bfb4d41f24c84227b23a5738c2ebcec97da Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 20 Mar 2015 12:40:20 +1100 Subject: [PATCH] Add userid parsing to proxy.add command --- src/generator.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/generator.c b/src/generator.c index 1d1e4cc9..fbb67e4d 100644 --- a/src/generator.c +++ b/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; json_error_t err_val; json_t *val = NULL; - int id; + int id, userid; + bool global; val = json_loads(buf, 0, &err_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); goto out; } + if (json_get_int(&userid, val, "userid")) + global = false; + else + global = true; mutex_lock(&gdata->lock); 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); 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); JSON_CPACK(val, "{si,ss,ss,ss}", "id", proxy->id, "url", url, "auth", auth, "pass", pass);