]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Allow users of AsyncDnsServer to set AA bit for all responses
authorŠtěpán Balážik <stepan@isc.org>
Wed, 29 Oct 2025 17:59:31 +0000 (18:59 +0100)
committerŠtěpán Balážik <stepan@isc.org>
Thu, 18 Dec 2025 12:03:14 +0000 (13:03 +0100)
Previously, all responses had to be set as authoritative explicitly
using DnsResponseSend(..., authoritative=True). After using this,
it became obvious that this is obnoxious.

Add an optional keyword-only parameter to AsyncDnsServer that sets the
default value of the AA bit on outgoing responses.

Make all the other parameters keyword-only as well.

bin/tests/system/isctest/asyncserver.py

index 27a981446b9c55606a96a6b13f01d52e1ffda177..244815540370f3daeceacc8a86bfadbf60ad4d5b 100644 (file)
@@ -773,7 +773,9 @@ class AsyncDnsServer(AsyncServer):
 
     def __init__(
         self,
+        /,
         default_rcode: dns.rcode.Rcode = dns.rcode.REFUSED,
+        default_aa: bool = True,
         acknowledge_manual_dname_handling: bool = False,
         acknowledge_tsig_dnspython_hacks: bool = False,
     ) -> None:
@@ -783,6 +785,7 @@ class AsyncDnsServer(AsyncServer):
         self._connection_handler: Optional[ConnectionHandler] = None
         self._response_handlers: List[ResponseHandler] = []
         self._default_rcode = default_rcode
+        self._default_aa = default_aa
         self._acknowledge_manual_dname_handling = acknowledge_manual_dname_handling
         self._acknowledge_tsig_dnspython_hacks = acknowledge_tsig_dnspython_hacks
 
@@ -1101,6 +1104,8 @@ class AsyncDnsServer(AsyncServer):
         Yield response(s) either from response handlers or zone data.
         """
         qctx.response.set_rcode(self._default_rcode)
+        if self._default_aa:
+            qctx.response.flags |= dns.flags.AA
 
         self._prepare_response_from_zone_data(qctx)