From: Bert Hubert Date: Thu, 15 Nov 2012 21:24:36 +0000 (+0000) Subject: don't relay passwords over JSON, plus hook up hosted domains to JSON in pdns_recursor X-Git-Tag: auth-3.2-rc2~101 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8465487d67a15d99a23173df9ebbdeb063f3c0ac;p=pdns don't relay passwords over JSON, plus hook up hosted domains to JSON in pdns_recursor git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2900 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/json_ws.cc b/pdns/json_ws.cc index ff98460d4..772b9e22e 100644 --- a/pdns/json_ws.cc +++ b/pdns/json_ws.cc @@ -25,6 +25,7 @@ #include "rec_channel.hh" #include "arguments.hh" #include "misc.hh" +#include "syncres.hh" JWebserver::JWebserver(FDMultiplexer* fdm) : d_fdm(fdm) { @@ -75,15 +76,31 @@ void JWebserver::readRequest(int fd) content=callback+"("; map stats; - if(sbuffer.find("stats") != string::npos) + if(sbuffer.find("stats") != string::npos) { stats = getAllStatsMap(); + content += returnJSONObject(stats); + } else if(sbuffer.find("domains") != string::npos) { + content += "["; + bool first=1; + BOOST_FOREACH(const SyncRes::domainmap_t::value_type& val, *t_sstorage->domainmap) { + if(!first) content+= ", "; + first=false; + stats.clear(); + stats["name"] = val.first; + stats["type"] = val.second.d_servers.empty() ? "Native" : "Forwarded"; + // fill out forwarders too one day, and rdrequired + content += returnJSONObject(stats); + } + content += "]"; + } else { vector items = ::arg().list(); BOOST_FOREACH(const string& var, items) { stats[var] = ::arg()[var]; } + content += returnJSONObject(stats); } - content += returnJSONObject(stats); + if(!callback.empty()) content += ");"; diff --git a/pdns/ws.cc b/pdns/ws.cc index 142232310..22768c733 100644 --- a/pdns/ws.cc +++ b/pdns/ws.cc @@ -296,11 +296,15 @@ string StatWebServer::jsonstat(const map &varmap, void *ptr, bool ret += "["; bool first=1; BOOST_FOREACH(const string& var, items) { + if(!first) ret+=","; first=false; ret += "["; ret += "\""+var+"\", \""; - ret += ::arg()[var] + "\""; + if(var.find("password") != string::npos) + ret += "*****\""; + else + ret += ::arg()[var] + "\""; ret += "]"; } ret += "]";