f"ns1.{target_ns_number}.example.net.",
)
)
-
- # XXX: Perl version truncates the responses at 512 bytes to force NS explosion on non-IPv6 builds.
- # Mimic this to have packet-for-packet compatibility, but remove before merge as non-IPv6 builds
- # are no longer a thing, I think.
- for offset in range(1, 16):
- target_ns_number = next_ns_block_start + offset
qctx.response.additional.append(
a(f"ns1.{target_ns_number}.example.net.", 7)
)
- # You would think that this was incorrect and end up with one A record over the 512 byte limit,
- # but thats's not the case, because Perl's DNS library has more agressive name compression than dnspython,
- # so this ends up working out.
- if len(qctx.response.to_wire()) > 512:
- break
-
yield DnsResponseSend(qctx.response, authoritative=False)
if qctx.qtype == dns.rdatatype.A:
qctx.response.answer.append(a(qctx.qname, 4))
- # XXX: The original Perl implementation doesn't set AA on empty responses,
- # let's do the same for packet-for-packet compatibility and drop it later.
- elif qctx.qtype == dns.rdatatype.AAAA:
- qctx.response.flags &= ~dns.flags.AA
-
if qctx.qname in self._waiting_responses_locks:
# Second query arrived, release the first response.
self._waiting_responses_locks[qctx.qname].release()