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.
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, and127-0-0-1.foobar.com
if the preresolved address is127.0.0.1
. We then manually set theHost
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.