From: Bert Hubert Date: Sat, 4 Mar 2006 11:42:37 +0000 (+0000) Subject: The PowerDNS recursor did not use to try all IP addresses of a nameserver! X-Git-Tag: pdns-2.9.20~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfea0d0b4d7d50d442be9084ef0779051fd3f808;p=thirdparty%2Fpdns.git The PowerDNS recursor did not use to try all IP addresses of a nameserver! It does so now, as explained in http://mailman.powerdns.com/pipermail/pdns-users/2006-March/003101.html and http://mailman.powerdns.com/pipermail/pdns-users/2006-March/003106.html Thanks to Mark Martin for noticing this. git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@570 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index c29d5d4f94..edb50935fb 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -100,14 +100,20 @@ int SyncRes::doResolve(const string &qname, const QType &qtype, vector& beenthere) +vector SyncRes::getAs(const string &qname, int depth, set& beenthere) { - vector res; - string ret; + typedef vector res_t; + res_t res; - if(!doResolve(qname,QType(QType::A), res,depth+1,beenthere) && !res.empty()) - ret=res[res.size()-1].content; // last entry, in case of CNAME in between + vector ret; + if(!doResolve(qname,QType(QType::A), res,depth+1,beenthere) && !res.empty()) { + for(res_t::const_iterator i=res.begin(); i!= res.end(); ++i) + if(i->qtype.getCode()==QType::A) + ret.push_back(i->content); + } + if(ret.size() > 1) + random_shuffle(ret.begin(), ret.end()); return ret; } @@ -375,48 +381,55 @@ int SyncRes::doResolveAt(set nameservers, string auth, const string &qna continue; } LOG< remoteIPs_t; + remoteIPs_t remoteIPs=getAs(*tns, depth+1, beenthere); + if(remoteIPs.empty()) { LOG< nameservers, string auth, const string &qna if(d_lwr.d_rcode==RCode::ServFail) { LOG< > tcache; @@ -565,7 +578,7 @@ int SyncRes::doResolveAt(set nameservers, string auth, const string &qna } else { LOG< shuffle(set &nameservers, const string &prefix); bool moreSpecificThan(const string& a, const string &b); - string getA(const string &qname, int depth, set& beenthere); + vector getAs(const string &qname, int depth, set& beenthere); SyncRes(const SyncRes&); SyncRes& operator=(const SyncRes&);