From: Peter van Dijk Date: Tue, 15 Mar 2016 19:50:55 +0000 (+0100) Subject: only do backend ALIAS query for ANY/A/AAAA; X-Git-Tag: rec-4.0.0-alpha3~1^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65d2032b9adcde86989e7a5028bc91c0649529cb;p=thirdparty%2Fpdns.git only do backend ALIAS query for ANY/A/AAAA; 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 --- diff --git a/pdns/dnsproxy.cc b/pdns/dnsproxy.cc index fe77c57077..41288038bf 100644 --- a/pdns/dnsproxy.cc +++ b/pdns/dnsproxy.cc @@ -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; diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index 16b6a56069..5202c21d11 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -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<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; } diff --git a/regression-tests/tests/alias-mx/expected_result b/regression-tests/tests/alias-mx/expected_result index 8f5a0e13b7..e20f297941 100644 --- a/regression-tests/tests/alias-mx/expected_result +++ b/regression-tests/tests/alias-mx/expected_result @@ -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