From e8b23f3beb3cba4bbff420d680ee3ec758c75896 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Mon, 8 Jun 2015 21:11:13 +0200 Subject: [PATCH] recursor snap --- pdns/reczones.cc | 2 +- pdns/speedtest.cc | 2 +- pdns/syncres.cc | 57 +++++++++++++++++++-------------------------- pdns/syncres.hh | 2 +- pdns/ws-recursor.cc | 2 +- 5 files changed, 28 insertions(+), 37 deletions(-) diff --git a/pdns/reczones.cc b/pdns/reczones.cc index 6552e80865..03f6c4842c 100644 --- a/pdns/reczones.cc +++ b/pdns/reczones.cc @@ -445,7 +445,7 @@ SyncRes::domainmap_t* parseAuthAndForwards() if(searchSuffix.empty() || parts[n].find('.') != string::npos) makeNameToIPZone(newMap, parts[n], parts[0]); else { - string canonic=toCanonic(searchSuffix, parts[n]); + DNSName canonic=toCanonic(DNSName(searchSuffix), parts[n]); if(canonic != parts[n]) { makeNameToIPZone(newMap, canonic, parts[0]); } diff --git a/pdns/speedtest.cc b/pdns/speedtest.cc index 960e6346f7..4c0bc9c9fe 100644 --- a/pdns/speedtest.cc +++ b/pdns/speedtest.cc @@ -534,7 +534,7 @@ struct ParsePacketTest void operator()() const { MOADNSParser mdp((const char*)&*d_packet.begin(), d_packet.size()); - typedef map, set, TCacheComp > tcache_t; + typedef map, set, TCacheComp > tcache_t; tcache_t tcache; struct { diff --git a/pdns/syncres.cc b/pdns/syncres.cc index da03bacd5c..704f2b11f6 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -730,11 +730,11 @@ bool SyncRes::doCacheCheck(const DNSName &qname, const QType &qtype, vectord_ttd) { sttl=ni->d_ttd - d_now.tv_sec; if(ni->d_qtype.getCode()) { - LOG(prefix<d_qname<<"' for another "<d_qname.toString()<<"' for another "<d_qname<<"' for another "<d_qname.toString()<<"' for another "<countb; + return a.countLabels() > b.countLabels(); } struct speedOrder @@ -812,16 +803,16 @@ struct speedOrder map& d_speeds; }; -inline vector SyncRes::shuffleInSpeedOrder(set &tnameservers, const string &prefix) +inline vector SyncRes::shuffleInSpeedOrder(set &tnameservers, const string &prefix) { - vector rnameservers; + vector rnameservers; rnameservers.reserve(tnameservers.size()); - BOOST_FOREACH(const string& str, tnameservers) { - rnameservers.push_back(str); + for(const auto& tns:tnameservers) { + rnameservers.push_back(tns); } - map speeds; + map speeds; - BOOST_FOREACH(const string& val, rnameservers) { + for(const auto& val: rnameservers) { double speed; speed=t_sstorage->nsSpeeds[val].get(&d_now); speeds[val]=speed; @@ -832,7 +823,7 @@ inline vector SyncRes::shuffleInSpeedOrder(set &tnameservers, c if(doLog()) { LOG(prefix<<"Nameservers: "); - for(vector::const_iterator i=rnameservers.begin();i!=rnameservers.end();++i) { + for(const auto & i: rnameservers) { if(i!=rnameservers.begin()) { LOG(", "); if(!((i-rnameservers.begin())%3)) { @@ -880,11 +871,11 @@ int SyncRes::doResolveAt(set nameservers, DNSName auth, bool flawedNSSe LOG(prefix< rnameservers = shuffleInSpeedOrder(nameservers, doLog() ? (prefix+qname+": ") : string() ); + vector rnameservers = shuffleInSpeedOrder(nameservers, doLog() ? (prefix+qname.toString()+": ") : string() ); - for(vector::const_iterator tns=rnameservers.begin();;++tns) { + for(const auto &tns: rnameservers) { if(tns==rnameservers.end()) { - LOG(prefix<doAgeCache(d_now.tv_sec, auth, QType::NS, 10)) @@ -940,7 +931,7 @@ int SyncRes::doResolveAt(set nameservers, DNSName auth, bool flawedNSSe } else { - LOG(prefix<toString()<<" to: "); for(remoteIP = remoteIPs.begin(); remoteIP != remoteIPs.end(); ++remoteIP) { if(remoteIP != remoteIPs.begin()) { LOG(", "); @@ -1012,7 +1003,7 @@ int SyncRes::doResolveAt(set nameservers, DNSName auth, bool flawedNSSe t_sstorage->nsSpeeds[*tns].submit(*remoteIP, 1000000, &d_now); // 1 sec // code below makes sure we don't filter COM or the root - if (s_serverdownmaxfails > 0 && (auth.find('.')+1 != auth.size()) && t_sstorage->fails.incr(*remoteIP) >= s_serverdownmaxfails) { + if (s_serverdownmaxfails > 0 && (auth != DNSName(".")) && t_sstorage->fails.incr(*remoteIP) >= s_serverdownmaxfails) { LOG(prefix<toString() <<". Going full throttle for 1 minute" <throttle.throttle(d_now.tv_sec, boost::make_tuple(*remoteIP, "", 0), s_serverdownthrottletime, 10000); // mark server as down } else if(resolveret==-1) @@ -1071,7 +1062,7 @@ int SyncRes::doResolveAt(set nameservers, DNSName auth, bool flawedNSSe } } - typedef map, set, TCacheComp > tcache_t; + typedef map, set, TCacheComp > tcache_t; tcache_t tcache; // reap all answers from this packet that are acceptable @@ -1129,12 +1120,12 @@ int SyncRes::doResolveAt(set nameservers, DNSName auth, bool flawedNSSe LOG(prefix<d_place==DNSResourceRecord::AUTHORITY && i->qtype.getCode()==QType::SOA && lwr.d_rcode==RCode::NXDomain && dottedEndsOn(qname,i->qname) && dottedEndsOn(i->qname, auth)) { - LOG(prefix<ttl = min(i->ttl, s_maxnegttl); if(!newtarget.length()) // only add a SOA if we're not going anywhere after this @@ -1177,19 +1168,19 @@ int SyncRes::doResolveAt(set nameservers, DNSName auth, bool flawedNSSe else if(i->d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::NS) { if(moreSpecificThan(i->qname,auth)) { newauth=i->qname; - LOG(prefix<qname<<"' -> '"<content<<"'"<qname.toString()<<"' -> '"<content<<"'"<qname<<"' -> '"<content<<"', had '"<qname.toString()<<"' -> '"<content<<"', had '"<content); } else if(!done && i->d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::SOA && lwr.d_rcode==RCode::NoError) { - LOG(prefix< ttl = min(s_maxnegttl, i->ttl); @@ -1220,7 +1211,7 @@ int SyncRes::doResolveAt(set nameservers, DNSName auth, bool flawedNSSe LOG(prefix< beenthere2; return doResolve(newtarget, qtype, ret, depth + 1, beenthere2); diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 909a95342c..d561b22aaf 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -449,7 +449,7 @@ private: DNSName getBestNSNamesFromCache(const DNSName &qname, const QType &qtype, set& nsset, bool* flawedNSSet, int depth, set&beenthere); inline vector shuffleInSpeedOrder(set &nameservers, const string &prefix); - bool moreSpecificThan(const string& a, const string &b); + bool moreSpecificThan(const DNSName& a, const DNSName &b); vector getAddrs(const DNSName &qname, int depth, set& beenthere); private: ostringstream d_trace; diff --git a/pdns/ws-recursor.cc b/pdns/ws-recursor.cc index 15dbac9a4b..8f582bfe92 100644 --- a/pdns/ws-recursor.cc +++ b/pdns/ws-recursor.cc @@ -143,7 +143,7 @@ static void fillZone(const string& zonename, HttpResponse* resp) const SyncRes::AuthDomain& zone = iter->second; // id is the canonical lookup key, which doesn't actually match the name (in some cases) - string zoneId = apiZoneNameToId(iter->first); + string zoneId = apiZoneNameToId(iter->first.toString()); Value jzoneid(zoneId.c_str(), doc.GetAllocator()); // copy doc.AddMember("id", jzoneid, doc.GetAllocator()); string url = "/servers/localhost/zones/" + zoneId; -- 2.47.2