From: phonedph1 Date: Tue, 28 Aug 2018 13:51:01 +0000 (+0000) Subject: Record full data from map X-Git-Tag: dnsdist-1.3.3~126^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=96e2f64f54b5bfa4ca6dae4dc72446387457eb8d;p=thirdparty%2Fpdns.git Record full data from map --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index c473ff03d3..94ea138904 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -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; diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 94859b6007..6fa5a1425f 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -78,6 +78,14 @@ public: d_ttl=60; d_last_clean=time(0); } + + struct entry + { + time_t ttd; + unsigned int count; + }; + typedef map 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 > 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 cont_t; cont_t d_cont; };