]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
only do backend ALIAS query for ANY/A/AAAA;
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 15 Mar 2016 19:50:55 +0000 (20:50 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Mon, 9 May 2016 12:43:42 +0000 (14:43 +0200)
don't return useless backend SOA (but now we sometimes return no SOA at all);
don't return ALIAS itself even when asked for directly

pdns/dnsproxy.cc
pdns/packethandler.cc
regression-tests/tests/alias-mx/expected_result

index fe77c57077216d5df5c17d3b5d642861c98c9dc6..41288038bf7ef5d4e9b5ab51f27ac6bd3bc6b3dc 100644 (file)
@@ -251,7 +251,7 @@ void DNSProxy::mainloop(void)
            
              DNSResourceRecord rr;
 
-             if(j->first.d_type == i->second.qtype || j->first.d_type==QType::SOA) {
+             if(j->first.d_type == i->second.qtype || (i->second.qtype == QType::ANY && (j->first.d_type == QType::A || j->first.d_type == QType::AAAA))) {
                rr.qname=i->second.aname;
                rr.qtype = j->first.d_type;
                rr.ttl=j->first.d_ttl;
index 16b6a56069e20e97efa2e0ebae6e62768257fb09..5202c21d114b2a4000784e045cad0f758b49b56f 100644 (file)
@@ -1340,7 +1340,7 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
       if(rr.qtype.getCode() == QType::CNAME && p->qtype.getCode() != QType::CNAME) 
         weRedirected=1;
 
-      if(DP && rr.qtype.getCode() == QType::ALIAS) {
+      if(DP && rr.qtype.getCode() == QType::ALIAS && (p->qtype.getCode() == QType::A || p->qtype.getCode() == QType::AAAA || p->qtype.getCode() == QType::ANY)) {
         haveAlias=DNSName(rr.content);
       }
 
@@ -1370,7 +1370,7 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
       goto sendit;
     }
 
-    if(!haveAlias.empty() && !weDone) {
+    if(!haveAlias.empty() && (!weDone || p->qtype.getCode() == QType::ANY)) {
       DLOG(L<<Logger::Warning<<"Found nothing that matched for '"<<target<<"', but did get alias to '"<<haveAlias<<"', referring"<<endl);
       DP->completePacket(r, haveAlias, target);
       return 0;
@@ -1429,7 +1429,7 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
     else if(weDone) {
       bool haveRecords = false;
       for(const auto& rr: rrset) {
-        if((p->qtype.getCode() == QType::ANY || rr.qtype == p->qtype) && rr.qtype.getCode() && rr.auth) {
+        if((p->qtype.getCode() == QType::ANY || rr.qtype == p->qtype) && rr.qtype.getCode() && rr.qtype != QType::ALIAS && rr.auth) {
           r->addRecord(rr);
           haveRecords = true;
         }
index 8f5a0e13b7398ae1127879a63905ea46ea95b912..e20f2979410944de6141389970d96c5216d85e91 100644 (file)
@@ -1,3 +1,3 @@
-1      example.com.    IN      SOA     86400   ns1.example.com. ahu.example.com. 2847484160 28800 7200 604800 86400
+1      example.com.    IN      SOA     86400   ns1.example.com. ahu.example.com. 2847484148 28800 7200 604800 86400
 Rcode: 0 (No Error), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
 Reply to question for qname='google-alias.example.com.', qtype=MX