Package org.littleshoot.proxy
Class ChainedProxyAdapter
java.lang.Object
org.littleshoot.proxy.ChainedProxyAdapter
- All Implemented Interfaces:
ChainedProxy,SslEngineSource
Convenience base class for implementations of
ChainedProxy.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic ChainedProxyChainedProxythat simply has the downstream proxy make a direct connection to the upstream server. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconnectionFailed(Throwable cause) Called to let us know that connecting to this proxy failed.voidCalled to let us know that connecting to this proxy succeeded.voidCalled to let us know that we were disconnected.voidfilterRequest(HttpObject httpObject) Filters requests on their way to the chained proxy.Return theInetSocketAddressfor connecting to the chained proxy.Tell LittleProxy the type of chained proxy that it will be connecting to.(Optional) ensure that the connection is opened from a specific local address (useful when doing NAT traversal).(Optional) implement this method if the chained proxy requires a password.Tell LittleProxy what kind of TransportProtocol to use to communicate with the chained proxy.(Optional) implement this method if the chained proxy requires a username.Returns anSSLEngineto use for a server connection from LittleProxy to the client.newSslEngine(String peerHost, int peerPort) Returns anSSLEngineto use for a client connection from LittleProxy to the upstream server.booleanImplement this method to tell LittleProxy whether to encrypt connections to the chained proxy for the given request.
-
Field Details
-
FALLBACK_TO_DIRECT_CONNECTION
ChainedProxythat simply has the downstream proxy make a direct connection to the upstream server.
-
-
Constructor Details
-
ChainedProxyAdapter
public ChainedProxyAdapter()
-
-
Method Details
-
getChainedProxyAddress
Description copied from interface:ChainedProxyReturn theInetSocketAddressfor connecting to the chained proxy. Returning null indicates that we won't chain.- Specified by:
getChainedProxyAddressin interfaceChainedProxy- Returns:
- The Chain Proxy with Host and Port.
-
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:
getLocalAddressin interfaceChainedProxy
-
getTransportProtocol
Description copied from interface:ChainedProxyTell LittleProxy what kind of TransportProtocol to use to communicate with the chained proxy.- Specified by:
getTransportProtocolin interfaceChainedProxy
-
getChainedProxyType
Description copied from interface:ChainedProxyTell 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:
getChainedProxyTypein interfaceChainedProxy- Returns:
- the chained proxy type.
-
getUsername
Description copied from interface:ChainedProxy(Optional) implement this method if the chained proxy requires a username.- Specified by:
getUsernamein interfaceChainedProxy- Returns:
- the username to send to the chained proxy.
-
getPassword
Description copied from interface:ChainedProxy(Optional) implement this method if the chained proxy requires a password.- Specified by:
getPasswordin interfaceChainedProxy- Returns:
- the password to send to the chained proxy.
-
requiresEncryption
public boolean requiresEncryption()Description copied from interface:ChainedProxyImplement this method to tell LittleProxy whether to encrypt connections to the chained proxy for the given request. If true, LittleProxy will callSslEngineSource.newSslEngine()to obtain an SSLContext used by the downstream proxy.- Specified by:
requiresEncryptionin interfaceChainedProxy- Returns:
- true of the connection to the chained proxy should be encrypted
-
newSslEngine
Description copied from interface:SslEngineSourceReturns anSSLEngineto use for a server connection from LittleProxy to the client.- Specified by:
newSslEnginein interfaceSslEngineSource
-
filterRequest
Description copied from interface:ChainedProxyFilters requests on their way to the chained proxy.- Specified by:
filterRequestin interfaceChainedProxy
-
connectionSucceeded
public void connectionSucceeded()Description copied from interface:ChainedProxyCalled to let us know that connecting to this proxy succeeded.- Specified by:
connectionSucceededin interfaceChainedProxy
-
connectionFailed
Description copied from interface:ChainedProxyCalled to let us know that connecting to this proxy failed.- Specified by:
connectionFailedin interfaceChainedProxy- Parameters:
cause- exception that caused this failure (maybe null)
-
disconnected
public void disconnected()Description copied from interface:ChainedProxyCalled to let us know that we were disconnected.- Specified by:
disconnectedin interfaceChainedProxy
-
newSslEngine
Description copied from interface:SslEngineSourceReturns anSSLEngineto 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:
newSslEnginein interfaceSslEngineSource- Parameters:
peerHost- to start a client connection to the server.peerPort- to start a client connection to the server.
-