MCPcopy
hub / github.com/mitmproxy/mitmproxy / dns_request

Function dns_request

examples/addons/dns-simple.py:19–38  ·  view source on GitHub ↗
(flow: dns.DNSFlow)

Source from the content-addressed store, hash-verified

17
18
19def dns_request(flow: dns.DNSFlow) -> None:
20 q = flow.request.question
21 if q and q.type == dns.types.AAAA:
22 logging.info(f"Spoofing IPv6 records for {q.name}...")
23 if q.name == "example.com":
24 flow.response = flow.request.succeed(
25 [
26 dns.ResourceRecord(
27 name="example.com",
28 type=dns.types.AAAA,
29 class_=dns.classes.IN,
30 ttl=dns.ResourceRecord.DEFAULT_TTL,
31 data=ipaddress.ip_address("::1").packed,
32 )
33 ]
34 )
35 elif q.name == "example.org":
36 flow.response = flow.request.fail(dns.response_codes.NXDOMAIN)
37 else:
38 flow.response = flow.request.succeed([])

Callers

nothing calls this directly

Calls 4

infoMethod · 0.80
succeedMethod · 0.80
ip_addressMethod · 0.80
failMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…