From: Michał Kępień Date: Thu, 21 May 2026 09:52:56 +0000 (+0200) Subject: Make static response handlers more specific X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=c0f01b60fdf7c01de84ed28d8942bab28650e27c;p=thirdparty%2Fbind9.git Make static response handlers more specific The RootNSHandler and ExampleNSHandler classes are only equipped to respond to specific QNAME/QTYPE tuples, not all queries for a specific QNAME. Turn them into subclasses of QnameQtypeHandler and make them only respond to QTYPE=NS queries to prevent sending NS responses for non-NS queries. --- diff --git a/bin/tests/system/resend_loop/ans3/ans.py b/bin/tests/system/resend_loop/ans3/ans.py index d0cb6d2935f..b5a1e754637 100644 --- a/bin/tests/system/resend_loop/ans3/ans.py +++ b/bin/tests/system/resend_loop/ans3/ans.py @@ -21,7 +21,7 @@ import dns.rrset from isctest.asyncserver import ( AsyncDnsServer, DnsResponseSend, - QnameHandler, + QnameQtypeHandler, QueryContext, ResponseHandler, StaticResponseHandler, @@ -53,24 +53,18 @@ def rrset( return dns.rrset.from_text(qname, ttl, dns.rdataclass.IN, rtype, rdata) -class RootNSHandler(QnameHandler, StaticResponseHandler): +class RootNSHandler(QnameQtypeHandler, StaticResponseHandler): qnames = ["."] - answer = [ - rrset(".", dns.rdatatype.NS, "a.root-servers.nil."), - ] - additional = [ - rrset("a.root-servers.nil.", dns.rdatatype.A, "10.53.0.3"), - ] + qtypes = [dns.rdatatype.NS] + answer = [rrset(".", dns.rdatatype.NS, "a.root-servers.nil.")] + additional = [rrset("a.root-servers.nil.", dns.rdatatype.A, "10.53.0.3")] -class ExampleNSHandler(QnameHandler, StaticResponseHandler): +class ExampleNSHandler(QnameQtypeHandler, StaticResponseHandler): qnames = ["example."] - answer = [ - rrset("example.", dns.rdatatype.NS, "ns.example."), - ] - additional = [ - rrset("ns.example.", dns.rdatatype.A, "10.53.0.3"), - ] + qtypes = [dns.rdatatype.NS] + answer = [rrset("example.", dns.rdatatype.NS, "ns.example.")] + additional = [rrset("ns.example.", dns.rdatatype.A, "10.53.0.3")] class CookieHandler(ResponseHandler):