feat(grpc): Add resolver wrapper to handle HTTP CONNECT proxy configuration#2679
feat(grpc): Add resolver wrapper to handle HTTP CONNECT proxy configuration#2679arjan-bal wants to merge 20 commits into
Conversation
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the gRPC client to support arbitrary byte-based addresses (via ByteStr) instead of requiring valid UTF-8 strings, enabling support for non-UTF-8 unix socket paths. It also introduces an HTTP CONNECT proxy resolver that intercepts DNS resolution and applies proxy configurations based on environment variables. The review feedback suggests bypassing proxy resolution entirely for non-DNS schemes (like unix or inmemory), safely handling empty NO_PROXY environment variables, and updating tests to verify that unix paths correctly bypass the proxy.
| options: ResolverOptions, | ||
| matcher: Option<&Matcher>, | ||
| ) -> Result<Box<dyn Resolver>, (String, ResolverOptions)> { | ||
| // Skip proxy lookup for known non-TCP schemes. |
There was a problem hiding this comment.
I'd expect to skip it for anything that isn't dns. I think there had been a little discussion around that, but I don't know where it ended.
The host will be passed to the proxy and the proxy then has to do the resolution, but we've discarded the scheme. It seems we are assuming dns formatting of the target string as well. We shouldn't be parsing the target string without knowledge of the specific scheme in use. Things would be better if we delegated to the name resolver to parse the target string into an authority.
This PR implements a resolver wrapper that determines proxy routing by checking the
HTTPS_PROXYandNO_PROXYenvironment variables. By default,hyper-utilmatches cURL's behavior by falling back toALL_PROXYwhenHTTPS_PROXYis unset. However, because Go'sFromEnvironmentand gRPC C++ ignoreALL_PROXY, gRPC Rust manually configures theMatcherto bypass it, ensuring cross-language consistency.Resolution Flow
When
HttpsProxyResolver::Builderbuilds a resolver for a target URI, it useshyper_util::client::proxy::Matcherto evaluate the environment variables:HttpsProxyResolver, which uses the child DNS resolver to resolve the proxy server's hostname instead of the target.HttpsProxyResolverintercepts resolution updates from the child resolver. It attaches the necessary proxy configuration (the original target authority and basic auth credentials) as attributes to each resolved proxy address.In follow-up PRs, the subchannel will read these address attributes to wrap the channel credentials and carry out the HTTP
CONNECThandshake prior to the standard credential handshake.Internal design doc: go/grpc-rust-http-connect