]> granicus.if.org Git - pdns/commitdiff
improve selection criterion for accepting returned data, ANY and ADDR record types...
authorBert Hubert <bert.hubert@netherlabs.nl>
Tue, 10 Jun 2008 19:49:33 +0000 (19:49 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Tue, 10 Jun 2008 19:49:33 +0000 (19:49 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1189 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/syncres.cc

index 3d3d24f4be8e12a77ce315d66ff02cea9b7bc8ab..71415c78b511820921e90d69bc97bde506cc551f 100644 (file)
@@ -581,7 +581,12 @@ struct TCacheComp
   }
 };
 
-
+static bool magicAddrMatch(const QType& query, const QType& answer)
+{
+  if(query.getCode() != QType::ADDR)
+    return false;
+  return answer.getCode() == QType::A || answer.getCode() == QType::AAAA;
+}
 
 /** returns -1 in case of no results, rcode otherwise */
 int SyncRes::doResolveAt(set<string, CIStringCompare> nameservers, string auth, bool flawedNSSet, const string &qname, const QType &qtype, 
@@ -673,6 +678,7 @@ int SyncRes::doResolveAt(set<string, CIStringCompare> nameservers, string auth,
            s_outqueries++; d_outqueries++;
          TryTCP:
            if(doTCP) {
+             LOG<<prefix<<qname<<": using TCP with "<< remoteIP->toStringWithPort() <<endl;
              s_tcpoutqueries++; d_tcpoutqueries++;
            }
            
@@ -819,14 +825,12 @@ int SyncRes::doResolveAt(set<string, CIStringCompare> nameservers, string auth,
        }
        // for ANY answers we *must* have an authoritive answer
        else if(i->d_place==DNSResourceRecord::ANSWER && !Utility::strcasecmp(i->qname.c_str(),qname.c_str()) && 
-               (i->qtype==qtype || 
-                (
-                 lwr.d_aabit && 
-                    ( qtype == QType(QType::ADDR) && (i->qtype.getCode()==QType::A || i->qtype.getCode()==QType::AAAA) ) || qtype==QType(QType::ANY) 
-                 )   
-                ) 
-               )   {
-       
+               (
+                i->qtype==qtype || (lwr.d_aabit && (qtype==QType(QType::ANY) || magicAddrMatch(qtype, i->qtype) ) )
+               ) 
+              )   
+         {
+         
          LOG<<prefix<<qname<<": answer is in: resolved to '"<< i->content<<"|"<<i->qtype.getName()<<"'"<<endl;
 
          done=true;