]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Fix merge errors 8554/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 19 Nov 2019 10:49:49 +0000 (10:49 +0000)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 19 Nov 2019 10:49:49 +0000 (10:49 +0000)
pdns/rec_channel_rec.cc
pdns/syncres.cc
pdns/syncres.hh

index 2e1e7aa14e2f8c7d256733f2252ad1473340754c..ca6180f14e48ecd804586298f105ecd2e4ec932d 100644 (file)
@@ -1433,6 +1433,9 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
   if(cmd=="dump-failedservers")
     return doDumpFailedServers(begin, end);
 
+  if(cmd=="dump-throttlemap")
+    return doDumpThrottleMap(begin, end);
+
   if(cmd=="dump-rpz") {
     return doDumpRPZ(begin, end);
   }
index 402b9db8123f3406513bd7257adc6f90abef363c..c62099ba45ce3b35c0fa6c8ef10570d5a3daa78a 100644 (file)
@@ -397,6 +397,27 @@ uint64_t SyncRes::doDumpNSSpeeds(int fd)
   return count;
 }
 
+uint64_t SyncRes::doDumpThrottleMap(int fd)
+{
+  auto fp = std::unique_ptr<FILE, int(*)(FILE*)>(fdopen(dup(fd), "w"), fclose);
+  if(!fp)
+    return 0;
+  fprintf(fp.get(), "; throttle map dump follows\n");
+  fprintf(fp.get(), "; remote IP\tqname\tqtype\tcount\tttd\n");
+  uint64_t count=0;
+
+  const auto& throttleMap = t_sstorage.throttle.getThrottleMap();
+  for(const auto& i : throttleMap)
+  {
+    count++;
+    char tmp[26];
+    // remote IP, dns name, qtype, count, ttd
+    fprintf(fp.get(), "%s\t%s\t%d\t%u\t%s", i.first.get<0>().toString().c_str(), i.first.get<1>().toLogString().c_str(), i.first.get<2>(), i.second.count, ctime_r(&i.second.ttd, tmp));
+  }
+
+  return count;
+}
+
 uint64_t SyncRes::doDumpFailedServers(int fd)
 {
   auto fp = std::unique_ptr<FILE, int(*)(FILE*)>(fdopen(dup(fd), "w"), fclose);
index 6fd3d67da0b7058cef57d588c271f34e4c0813cd..29eed2191327ed3a9b733581d55171f20f6c9473 100644 (file)
@@ -73,6 +73,12 @@ typedef map<
 template<class Thing> class Throttle : public boost::noncopyable
 {
 public:
+  struct entry
+  {
+    time_t ttd;
+    unsigned int count;
+  };
+  typedef map<Thing,entry> cont_t;
   Throttle()
   {
     d_limit=3;
@@ -121,6 +127,11 @@ public:
     return (unsigned int)d_cont.size();
   }
 
+  const cont_t& getThrottleMap() const
+  {
+    return d_cont;
+  }
+
   void clear()
   {
     d_cont.clear();
@@ -129,12 +140,6 @@ private:
   unsigned int d_limit;
   time_t d_ttl;
   time_t d_last_clean;
-  struct entry
-  {
-    time_t ttd;
-    unsigned int count;
-  };
-  typedef map<Thing,entry> cont_t;
   cont_t d_cont;
 };