From: Otto Moerbeek Date: Fri, 7 Jun 2019 11:03:03 +0000 (+0200) Subject: Simple blacklist handler for StatBag. Not configurable but that X-Git-Tag: auth-4.2.0-rc2^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28c3cc112b64e36801c06f2d81c393e90a881130;p=thirdparty%2Fpdns.git Simple blacklist handler for StatBag. Not configurable but that could easily be added if necessary. --- diff --git a/pdns/dynhandler.cc b/pdns/dynhandler.cc index e1ea81f82a..7f4449cefd 100644 --- a/pdns/dynhandler.cc +++ b/pdns/dynhandler.cc @@ -83,23 +83,24 @@ string DLPingHandler(const vector&parts, Utility::pid_t ppid) return "PONG"; } -string DLShowHandler(const vector&parts, Utility::pid_t ppid) -try -{ - extern StatBag S; - string ret("Wrong number of parameters"); - if(parts.size()==2) { - if(parts[1]=="*") - ret=S.directory(); - else - ret=S.getValueStr(parts[1]); - } +string DLShowHandler(const vector&parts, Utility::pid_t ppid) { + std::set blacklist; + blacklist.insert("special-memory-usage"); + try { + extern StatBag S; + string ret("Wrong number of parameters"); + if (parts.size() == 2) { + if (parts[1] == "*") + ret = S.directory(blacklist); + else + ret = S.getValueStr(parts[1]); + } - return ret; -} -catch(...) -{ - return "Unknown"; + return ret; + } + catch (...) { + return "Unknown"; + } } void setStatus(const string &str) diff --git a/pdns/statbag.cc b/pdns/statbag.cc index c4f46a5b1f..697226e92b 100644 --- a/pdns/statbag.cc +++ b/pdns/statbag.cc @@ -48,17 +48,21 @@ void StatBag::exists(const string &key) } } -string StatBag::directory() +string StatBag::directory(const std::set& skip) { string dir; ostringstream o; for(const auto& i: d_stats) { + if (skip.find(i.first) != skip.end()) + continue; o<& skip); //!< Returns a list of all data stored vector getEntries(); //!< returns a vector with datums (items) string getDescrip(const string &item); //!< Returns the description of this datum/item void exists(const string &key); //!< call this function to throw an exception in case a key does not exist