Class ProxyDetectorImpl

  • All Implemented Interfaces:
    ProxyDetector

    class ProxyDetectorImpl
    extends java.lang.Object
    implements ProxyDetector
    A utility class that detects proxies using ProxySelector and detects authentication credentials using Authenticator.
    • Field Detail

      • log

        private static final java.util.logging.Logger log
      • DEFAULT_PROXY_SELECTOR

        private static final com.google.common.base.Supplier<java.net.ProxySelector> DEFAULT_PROXY_SELECTOR
      • GRPC_PROXY_ENV_VAR

        @Deprecated
        private static final java.lang.String GRPC_PROXY_ENV_VAR
        Deprecated.
        Use the standard Java proxy configuration instead with flags such as: -Dhttps.proxyHost=HOST -Dhttps.proxyPort=PORT
        Experimental environment variable name for enabling proxy support.
        See Also:
        Constant Field Values
      • proxySelector

        private final com.google.common.base.Supplier<java.net.ProxySelector> proxySelector
      • overrideProxyAddress

        private final java.net.InetSocketAddress overrideProxyAddress
    • Constructor Detail

      • ProxyDetectorImpl

        ProxyDetectorImpl​(com.google.common.base.Supplier<java.net.ProxySelector> proxySelector,
                          ProxyDetectorImpl.AuthenticationProvider authenticationProvider,
                          @Nullable
                          java.lang.String proxyEnvString)
    • Method Detail

      • proxyFor

        @Nullable
        public ProxiedSocketAddress proxyFor​(java.net.SocketAddress targetServerAddress)
                                      throws java.io.IOException
        Description copied from interface: ProxyDetector
        Given a target address, returns a proxied address if a proxy should be used. If no proxy should be used, then return value will be null.

        If the returned ProxiedSocketAddress contains 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.

        Specified by:
        proxyFor in interface ProxyDetector
        Parameters:
        targetServerAddress - the target address, which is generally unresolved, because the proxy will resolve it.
        Throws:
        java.io.IOException
      • detectProxy

        private ProxiedSocketAddress detectProxy​(java.net.InetSocketAddress targetAddr)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • overrideProxy

        private static java.net.InetSocketAddress overrideProxy​(java.lang.String proxyHostPort)
        GRPC_PROXY_EXP is deprecated but let's maintain compatibility for now.