palantir / conjure-rust-runtime

Rust implementation of the Conjure runtime
10 stars 7 forks source link

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

Open sfackler opened 7 months ago

sfackler commented 7 months ago

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.