Skip to content

Add dns_server option. #6739

@mhils

Description

@mhils

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions