Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dns_server option. #6739

Open
mhils opened this issue Mar 15, 2024 · 3 comments
Open

Add dns_server option. #6739

mhils opened this issue Mar 15, 2024 · 3 comments

Comments

@mhils
Copy link
Member

mhils commented Mar 15, 2024

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

  1. Implement an async getaddrinfo method 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.
  2. Write an addon that defines a dns_server option and monkeypatches/replaces the current event loop's getaddrinfo to use our custom implementation if dns_server is set.

Ideally we start with a PR that does just the first part + tests before getting to part two.

@oge1ata
Copy link

oge1ata commented Mar 25, 2024

Hi @mhils Could I have a bit of explanation on this?

@smenon02
Copy link

smenon02 commented Apr 2, 2024

I can help with this! If anyone is currently working on this

@smenon02
Copy link

anyone have any advice for creating test cases or testing the getaddrinfo method?

smenon02 added a commit to smenon02/mitmproxy that referenced this issue Apr 21, 2024
…er that opens UDP socket to send DNS queries for hostname resolution. Running into troubles getting UDP socket and DNS server to communicate, leading to timeout issues. Some help with this would be greatly appreciated :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants