public interface ProxyDetectorA utility class to detect which proxy, if any, should be used for a given
SocketAddress. This class performs network requests to resolve address names, and should only be used in places that are expected to do IO such as the
How Proxies work in gRPC
NameResolvershould invoke the
ProxyDetectorretrieved from the
NameResolver.Args.getProxyDetector(), and pass the returned
NameResolver.Listener.onAddresses(java.util.List<io.grpc.EquivalentAddressGroup>, io.grpc.Attributes). The DNS name resolver shipped with gRPC is already doing so.
ProxyDetectoruses Java's standard
Authenticatorto detect proxies and authentication credentials and produce
HttpConnectProxiedSocketAddress, which is for using an HTTP CONNECT proxy. A custom
ProxyDetectorcan be passed to
ProxiedSocketAddressis then handled by the transport. The transport needs to support whatever type of
ProxyDetector. The Netty transport and the OkHttp transport currently only support
HttpConnectProxiedSocketAddresswhich is returned by the default
@Nullable ProxiedSocketAddress proxyFor(java.net.SocketAddress targetServerAddress) throws java.io.IOExceptionGiven a target address, returns a proxied address if a proxy should be used. If no proxy should be used, then return value will be
If the returned
ProxiedSocketAddresscontains any address that needs to be resolved locally, it should be resolved before it's returned, and this method throws if unable to resolve it.
targetServerAddress- the target address, which is generally unresolved, because the proxy will resolve it.