Skip to content

Add a resolve option to override DNS for specific hosts#163

Open
marcospassos wants to merge 1 commit into
sqdshguy:masterfrom
marcospassos:feat/transport-resolve-dns-override
Open

Add a resolve option to override DNS for specific hosts#163
marcospassos wants to merge 1 commit into
sqdshguy:masterfrom
marcospassos:feat/transport-resolve-dns-override

Conversation

@marcospassos

Copy link
Copy Markdown

This PR adds a resolve option to createTransport so you can force a hostname to use a specific address instead of relying on system DNS. You can map a host to an ip or ip:port, or even provide a list of addresses as fallbacks. Under the hood it just uses wreq’s ClientBuilder::resolve_to_addrs.

The main reason I needed this is SSRF protection. I want to resolve the hostname myself, make sure the IP isn’t internal or private, and only then connect. If the client resolves it again on its own, there’s a window where it could end up hitting a different address due to DNS rebinding. With resolve, I can pass in the exact IP I already checked, so the client only connects there and doesn’t try to look it up again.

It’s also useful for things like split horizon DNS or testing against a local server while still using a real hostname.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant