]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Restore StatNode's children (optionnally) for dnsscope
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 15 Mar 2018 11:09:48 +0000 (12:09 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 15 Mar 2018 11:09:48 +0000 (12:09 +0100)
pdns/dnsdist-lua-inspection.cc
pdns/statnode.cc
pdns/statnode.hh

index c75d0bad4dbc05aa21dc56a93d5acf2f013947f7..d5d32a195b9d4f4a8d1e514c227051f53111c4f8 100644 (file)
@@ -114,7 +114,7 @@ static void statNodeRespRing(statvisitor_t visitor, unsigned int seconds)
       if (seconds && c.when < cutoff)
         continue;
 
-      root.submit(c.name, c.dh.rcode, c.requestor);
+      root.submit(c.name, c.dh.rcode, boost::none);
     }
   }
 
index 7e8578d8b195602c395157d82602f1f616a3ece9..0a9873291c0e39a0fa76073bddbee43369eb77b7 100644 (file)
@@ -39,10 +39,10 @@ void  StatNode::visit(visitor_t visitor, Stat &newstat, unsigned int depth) cons
   childstat.nxdomains += s.nxdomains;
   childstat.servfails += s.servfails;
   childstat.drops += s.drops;
-//  childstat.remotes = s.remotes;
+  childstat.remotes = s.remotes;
   
 
-  Stat selfstat(childstat);
+  Stat selfstat;
 
   for(const children_t::value_type& child :  children) {
     child.second.visit(visitor, childstat, depth+8);
@@ -54,7 +54,7 @@ void  StatNode::visit(visitor_t visitor, Stat &newstat, unsigned int depth) cons
 }
 
 
-void StatNode::submit(const DNSName& domain, int rcode, const ComboAddress& remote)
+void StatNode::submit(const DNSName& domain, int rcode, boost::optional<const ComboAddress&> remote)
 {
   //  cerr<<"FIRST submit called on '"<<domain<<"'"<<endl;
   std::vector<string> tmp = domain.getRawLabels();
@@ -72,7 +72,7 @@ void StatNode::submit(const DNSName& domain, int rcode, const ComboAddress& remo
    www.powerdns.com. 
 */
 
-void StatNode::submit(std::vector<string>::const_iterator end, std::vector<string>::const_iterator begin, const std::string& domain, int rcode, const ComboAddress& remote, unsigned int count)
+void StatNode::submit(std::vector<string>::const_iterator end, std::vector<string>::const_iterator begin, const std::string& domain, int rcode, boost::optional<const ComboAddress&> remote, unsigned int count)
 {
   //  cerr<<"Submit called for domain='"<<domain<<"': ";
   //  for(const std::string& n :  labels) 
@@ -102,7 +102,10 @@ void StatNode::submit(std::vector<string>::const_iterator end, std::vector<strin
       s.servfails++;
     else if(rcode==3)
       s.nxdomains++;
-//    s.remotes[remote]++;
+
+    if (remote) {
+      s.remotes[*remote]++;
+    }
   }
   else {
     if (fullname.empty()) {
index b541d8843be1fd973ce871f3c370bf583ad19eaf..560b8ac979f4853ec180ad398a7c5dc07faf4841 100644 (file)
@@ -41,13 +41,13 @@ public:
       servfails+=rhs.servfails;
       drops+=rhs.drops;
 
-      //for(const remotes_t::value_type& rem :  rhs.remotes) {
-      //  remotes[rem.first]+=rem.second;
-      //}
+      for(const remotes_t::value_type& rem : rhs.remotes) {
+        remotes[rem.first]+=rem.second;
+      }
       return *this;
     }
-    //typedef std::map<ComboAddress,int,ComboAddress::addressOnlyLessThan> remotes_t;
-    //remotes_t remotes;
+    typedef std::map<ComboAddress,int,ComboAddress::addressOnlyLessThan> remotes_t;
+    remotes_t remotes;
   };
 
   Stat s;
@@ -55,7 +55,7 @@ public:
   std::string fullname;
   unsigned int labelsCount{0};
 
-  void submit(const DNSName& domain, int rcode, const ComboAddress& remote);
+  void submit(const DNSName& domain, int rcode, boost::optional<const ComboAddress&> remote);
 
   Stat print(unsigned int depth=0, Stat newstat=Stat(), bool silent=false) const;
   typedef boost::function<void(const StatNode*, const Stat& selfstat, const Stat& childstat)> visitor_t;
@@ -64,5 +64,5 @@ public:
   children_t children;
 
 private:
-  void submit(std::vector<string>::const_iterator end, std::vector<string>::const_iterator begin, const std::string& domain, int rcode, const ComboAddress& remote, unsigned int count);
+  void submit(std::vector<string>::const_iterator end, std::vector<string>::const_iterator begin, const std::string& domain, int rcode, boost::optional<const ComboAddress&> remote, unsigned int count);
 };