mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-27 20:25:55 -04:00
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.
This commit is contained in:
parent
ebab903a93
commit
c0f01b60fd
1 changed files with 9 additions and 15 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue