MCPcopy Create free account
hub / github.com/rthalley/dnspython / handle

Method handle

tests/test_resolver.py:1032–1053  ·  view source on GitHub ↗
(self, request)

Source from the content-addressed store, hash-verified

1030
1031class NaptrNanoNameserver(Server):
1032 def handle(self, request):
1033 response = dns.message.make_response(request.message)
1034 response.set_rcode(dns.rcode.REFUSED)
1035 response.flags |= dns.flags.RA
1036 try:
1037 zero_subdomain = dns.e164.from_e164("0")
1038 if request.qname.is_subdomain(zero_subdomain):
1039 response.set_rcode(dns.rcode.NXDOMAIN)
1040 response.flags |= dns.flags.AA
1041 elif (
1042 request.qtype == dns.rdatatype.NAPTR
1043 and request.qclass == dns.rdataclass.IN
1044 ):
1045 rrs = dns.rrset.from_text(
1046 request.qname, 300, "IN", "NAPTR", '0 0 "" "" "" .'
1047 )
1048 response.answer.append(rrs)
1049 response.set_rcode(dns.rcode.NOERROR)
1050 response.flags |= dns.flags.AA
1051 except Exception:
1052 pass
1053 return response
1054
1055
1056@unittest.skipIf(

Callers

nothing calls this directly

Calls 3

set_rcodeMethod · 0.80
is_subdomainMethod · 0.80
from_textMethod · 0.45

Tested by

no test coverage detected