]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Record full data from map
authorphonedph1 <phoned@gmail.com>
Tue, 28 Aug 2018 13:51:01 +0000 (13:51 +0000)
committerphonedph1 <phoned@gmail.com>
Tue, 28 Aug 2018 13:51:01 +0000 (13:51 +0000)
pdns/syncres.cc
pdns/syncres.hh

index c473ff03d3b6c2f62fc745fb73d2d429ae185924..94ea138904b6479a212587be80b5a1df903ea8aa 100644 (file)
@@ -394,15 +394,15 @@ uint64_t SyncRes::doDumpThrottleMap(int fd)
   if(!fp)
     return 0;
   fprintf(fp, "; throttle map dump follows\n");
-  fprintf(fp, "; remote IP, DNSName, QType\n");
+  fprintf(fp, "; remote IP\tqname\tqtype\tcount\tttd\n");
   uint64_t count=0;
 
-  for(const auto& i : t_sstorage.throttle.getThrottleTuples())
+  const auto& throttleMap = t_sstorage.throttle.getThrottleMap();
+  for(const auto& i : throttleMap)
   {
     count++;
-    // remote IP, dns name, qtype
-    fprintf(fp, "%s %s %d", i.get<0>().toLogString().c_str(), i.get<1>().toString().c_str(), i.get<2>());
-    fprintf(fp, "\n");
+    // remote IP, dns name, qtype, count, ttd
+    fprintf(fp, "%s\t%s\t%d\t%d\t%s", i.first.get<0>().toString().c_str(), i.first.get<1>().toString().c_str(), i.first.get<2>(), i.second.count, ctime(&i.second.ttd));
   }
   fclose(fp);
   return count;
index 94859b6007bbdabd1abc8e3f1366837b49484fd4..6fa5a1425fa656190a7e60b7501f02b380300cb7 100644 (file)
@@ -78,6 +78,14 @@ public:
     d_ttl=60;
     d_last_clean=time(0);
   }
+
+  struct entry
+  {
+    time_t ttd;
+    unsigned int count;
+  };
+  typedef map<Thing,entry> cont_t;
+
   bool shouldThrottle(time_t now, const Thing& t)
   {
     if(now > d_last_clean + 300 ) {
@@ -120,16 +128,9 @@ public:
     return (unsigned int)d_cont.size();
   }
 
-  typedef std::vector<boost::tuple<ComboAddress,DNSName,uint16_t> > throttles_t;
-  throttles_t getThrottleTuples() {
-    throttles_t ret;
-    ret.reserve(d_cont.size());
-
-    for(const auto& i : d_cont) {
-      ret.push_back(i.first);
-    }
-
-    return ret;
+  const cont_t& getThrottleMap() const
+  {
+    return d_cont;
   }
 
   void clear()
@@ -141,12 +142,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;
 };