Class ChainedProxyAdapter

java.lang.Object
org.littleshoot.proxy.ChainedProxyAdapter
All Implemented Interfaces:
ChainedProxy, SslEngineSource

public class ChainedProxyAdapter extends Object implements ChainedProxy
Convenience base class for implementations of ChainedProxy.
  • Field Details

    • FALLBACK_TO_DIRECT_CONNECTION

      public static ChainedProxy FALLBACK_TO_DIRECT_CONNECTION
      ChainedProxy that simply has the downstream proxy make a direct connection to the upstream server.
  • Constructor Details

    • ChainedProxyAdapter

      public ChainedProxyAdapter()
  • Method Details

    • getChainedProxyAddress

      public InetSocketAddress getChainedProxyAddress()
      Description copied from interface: ChainedProxy
      Return the InetSocketAddress for connecting to the chained proxy. Returning null indicates that we won't chain.
      Specified by:
      getChainedProxyAddress in interface ChainedProxy
      Returns:
      The Chain Proxy with Host and Port.
    • getLocalAddress

      public InetSocketAddress getLocalAddress()
      Description copied from interface: ChainedProxy
      (Optional) ensure that the connection is opened from a specific local address (useful when doing NAT traversal).
      Specified by:
      getLocalAddress in interface ChainedProxy
    • getTransportProtocol

      public TransportProtocol getTransportProtocol()
      Description copied from interface: ChainedProxy
      Tell LittleProxy what kind of TransportProtocol to use to communicate with the chained proxy.
      Specified by:
      getTransportProtocol in interface ChainedProxy
    • getChainedProxyType

      public ChainedProxyType getChainedProxyType()
      Description copied from interface: ChainedProxy
      Tell LittleProxy the type of chained proxy that it will be connecting to. This setting determines what type of requests LittleProxy will use to communicate with the chained proxy.
      Specified by:
      getChainedProxyType in interface ChainedProxy
      Returns:
      the chained proxy type.
    • getUsername

      public String getUsername()
      Description copied from interface: ChainedProxy
      (Optional) implement this method if the chained proxy requires a username.
      Specified by:
      getUsername in interface ChainedProxy
      Returns:
      the username to send to the chained proxy.
    • getPassword

      public String getPassword()
      Description copied from interface: ChainedProxy
      (Optional) implement this method if the chained proxy requires a password.
      Specified by:
      getPassword in interface ChainedProxy
      Returns:
      the password to send to the chained proxy.
    • requiresEncryption

      public boolean requiresEncryption()
      Description copied from interface: ChainedProxy
      Implement this method to tell LittleProxy whether to encrypt connections to the chained proxy for the given request. If true, LittleProxy will call SslEngineSource.newSslEngine() to obtain an SSLContext used by the downstream proxy.
      Specified by:
      requiresEncryption in interface ChainedProxy
      Returns:
      true of the connection to the chained proxy should be encrypted
    • newSslEngine

      public SSLEngine newSslEngine()
      Description copied from interface: SslEngineSource
      Returns an SSLEngine to use for a server connection from LittleProxy to the client.
      Specified by:
      newSslEngine in interface SslEngineSource
    • filterRequest

      public void filterRequest(HttpObject httpObject)
      Description copied from interface: ChainedProxy
      Filters requests on their way to the chained proxy.
      Specified by:
      filterRequest in interface ChainedProxy
    • connectionSucceeded

      public void connectionSucceeded()
      Description copied from interface: ChainedProxy
      Called to let us know that connecting to this proxy succeeded.
      Specified by:
      connectionSucceeded in interface ChainedProxy
    • connectionFailed

      public void connectionFailed(Throwable cause)
      Description copied from interface: ChainedProxy
      Called to let us know that connecting to this proxy failed.
      Specified by:
      connectionFailed in interface ChainedProxy
      Parameters:
      cause - exception that caused this failure (maybe null)
    • disconnected

      public void disconnected()
      Description copied from interface: ChainedProxy
      Called to let us know that we were disconnected.
      Specified by:
      disconnected in interface ChainedProxy
    • newSslEngine

      public SSLEngine newSslEngine(String peerHost, int peerPort)
      Description copied from interface: SslEngineSource
      Returns an SSLEngine to use for a client connection from LittleProxy to the upstream server. * Note: Peer information is needed to send the server_name extension in handshake with Server Name Indication (SNI).
      Specified by:
      newSslEngine in interface SslEngineSource
      Parameters:
      peerHost - to start a client connection to the server.
      peerPort - to start a client connection to the server.