-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Closed
Labels
Description
Problem Description
This has come up a few times now: mitmproxy currently just opens asyncio sockets with the unresolved hostnames. Python's stdlib will then use libc's getaddrinfo, which always includes /etc/hosts. This can be very annoying, see e.g. #6737. We want a way to teach mitmproxy to use a custom DNS server.
Proposal
- Implement an async
getaddrinfomethod that resolves a hostname using a custom DNS server. This could be done in either Python or Rust in mitmproxy-rs. My first best guess would be to go with https://docs.rs/hickory-resolver/latest/hickory_resolver/ in Rust. - Write an addon that defines a
dns_serveroption and monkeypatches/replaces the current event loop'sgetaddrinfoto use our custom implementation ifdns_serveris set.
Ideally we start with a PR that does just the first part + tests before getting to part two.