From: Christian Hofstaedtler Date: Wed, 28 Aug 2013 14:21:28 +0000 (+0200) Subject: recursor json: put command into command var X-Git-Tag: rec-3.6.0-rc1~462^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2897a7d2d0b35072bf7cb894e342c7aa3cad83c;p=pdns recursor json: put command into command var Just like in the Auth. --- diff --git a/pdns/json_ws.cc b/pdns/json_ws.cc index b491b430f..b4daaa0a7 100644 --- a/pdns/json_ws.cc +++ b/pdns/json_ws.cc @@ -110,7 +110,16 @@ void JWebserver::readRequest(int fd) string JWebserver::handleRequest(const string &method, const string &uri, const map &rovarmap, string &headers) { map varmap = rovarmap; - string callback = varmap["callback"]; + string callback; + if (varmap.count("callback")) { + callback = varmap["callback"]; + varmap.erase("callback"); + } + string command; + if (varmap.count("command")) { + command = varmap["command"]; + varmap.erase("command"); + } headers += "Access-Control-Allow-Origin: *\r\n"; headers += "Content-Type: application/json\r\n"; @@ -120,7 +129,7 @@ string JWebserver::handleRequest(const string &method, const string &uri, const content=callback+"("; map stats; - if(varmap["command"] =="domains") { + if(command == "domains") { content += "["; bool first=1; BOOST_FOREACH(const SyncRes::domainmap_t::value_type& val, *t_sstorage->domainmap) { @@ -139,7 +148,7 @@ string JWebserver::handleRequest(const string &method, const string &uri, const } content += "]"; } - else if(varmap["command"] =="get-zone") { + else if(command == "get-zone") { SyncRes::domainmap_t::const_iterator ret = t_sstorage->domainmap->find(varmap["zone"]); content += "["; @@ -159,25 +168,25 @@ string JWebserver::handleRequest(const string &method, const string &uri, const } } content += "]"; - } - else if(varmap["command"]=="flush-cache") { + } + else if(command == "flush-cache") { string canon=toCanonic("", varmap["domain"]); int count = broadcastAccFunction(boost::bind(pleaseWipeCache, canon)); count+=broadcastAccFunction(boost::bind(pleaseWipeAndCountNegCache, canon)); stats["number"]=lexical_cast(count); content += returnJSONObject(stats); } - else if(varmap["command"] == "config") { + else if(command == "config") { vector items = ::arg().list(); BOOST_FOREACH(const string& var, items) { stats[var] = ::arg()[var]; } content += returnJSONObject(stats); } - else if(varmap["command"]=="log-grep") { + else if(command == "log-grep") { content += makeLogGrepJSON(varmap, ::arg()["experimental-logfile"], " pdns_recursor["); } - else { // if(varmap["command"] == "stats") { + else { // if(command == "stats") { stats = getAllStatsMap(); content += returnJSONObject(stats); }