Simplify match criteria for CookieHandler

The CookieHandler class handles all traffic for the "example." domain.
Make it a subclass of DomainHandler to simplify its definition.
This commit is contained in:
Michał Kępień 2026-05-21 11:52:56 +02:00
parent c0f01b60fd
commit ba6eee2b80
No known key found for this signature in database

View file

@ -21,6 +21,7 @@ import dns.rrset
from isctest.asyncserver import (
AsyncDnsServer,
DnsResponseSend,
DomainHandler,
QnameQtypeHandler,
QueryContext,
ResponseHandler,
@ -67,10 +68,8 @@ class ExampleNSHandler(QnameQtypeHandler, StaticResponseHandler):
additional = [rrset("ns.example.", dns.rdatatype.A, "10.53.0.3")]
class CookieHandler(ResponseHandler):
def match(self, qctx: QueryContext) -> bool:
example = dns.name.from_text("example")
return qctx.qname.is_subdomain(example)
class CookieHandler(DomainHandler):
domains = ["example."]
async def get_responses(
self, qctx: QueryContext