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

[Stacked] Handle DNS preresolution at the raw client level #204

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

sfackler
Copy link
Member

@sfackler sfackler commented Apr 8, 2024

The first step of #199. A new ResolvedAddr extension can be added to request extensions. If set, it will cause the raw client to connect to the specified IP instead of DNS-resolving the URI's host. This isn't currently set anywhere, but will be used in a follow-up PR.

The Hyper client's APIs don't expose extensions to the socket connection logic, so we need to smuggle the resolved address in by encoding it in the URI's host. This is done by prepending to the host. For example, if the host is foobar.com, it will be encoded as .foobar.com if there is no preresolved address, and 127-0-0-1.foobar.com if the preresolved address is 127.0.0.1. We then manually set the Host header so Hyper doesn't try to set it to our mangled hostname, and define a custom DNS resolver and TLS server name resolver which propagate the appropriate information.

if let Some(endpoint) = parts.extensions.get::<Endpoint>() {
new_req.extensions_mut().insert(endpoint.clone());
}
*new_req.extensions_mut() = parts.extensions.clone();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extensions is now Clone in hyper 1 so we can just do this directly.

Base automatically changed from upgrades to develop May 24, 2024 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant