public class DefaultHttpProxyServer extends Object implements HttpProxyServer
Primary implementation of an HttpProxyServer.
DefaultHttpProxyServer is bootstrapped by calling
bootstrap() or bootstrapFromFile(String), and then calling
DefaultHttpProxyServer.DefaultHttpProxyServerBootstrap.start(). For example:
DefaultHttpProxyServer server =
DefaultHttpProxyServer
.bootstrap()
.withPort(8090)
.start();
| Modifier and Type | Class and Description |
|---|---|
private static class |
DefaultHttpProxyServer.DefaultHttpProxyServerBootstrap |
private static class |
DefaultHttpProxyServer.ServerGroup
Represents a group of servers that share thread pools.
|
| Modifier | Constructor and Description |
|---|---|
private |
DefaultHttpProxyServer(DefaultHttpProxyServer.ServerGroup serverGroup,
TransportProtocol transportProtocol,
InetSocketAddress requestedAddress,
SslEngineSource sslEngineSource,
boolean authenticateSslClients,
ProxyAuthenticator proxyAuthenticator,
ChainedProxyManager chainProxyManager,
MitmManager mitmManager,
HttpFiltersSource filtersSource,
boolean transparent,
int idleConnectionTimeout,
Collection<ActivityTracker> activityTrackers,
int connectTimeout,
HostResolver serverResolver,
long readThrottleBytesPerSecond,
long writeThrottleBytesPerSecond,
InetSocketAddress localAddress)
Creates a new proxy server.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Stops the server and all related clones immediately, without waiting for traffic to stop.
|
static HttpProxyServerBootstrap |
bootstrap()
Bootstrap a new
DefaultHttpProxyServer starting from scratch. |
static HttpProxyServerBootstrap |
bootstrapFromFile(String path)
Bootstrap a new
DefaultHttpProxyServer using defaults from the
given file. |
HttpProxyServerBootstrap |
clone()
Clone the existing server, with a port 1 higher and everything else the
same.
|
private GlobalTrafficShapingHandler |
createGlobalTrafficShapingHandler(TransportProtocol transportProtocol,
long readThrottleBytesPerSecond,
long writeThrottleBytesPerSecond)
Creates a new GlobalTrafficShapingHandler for this HttpProxyServer, using this proxy's proxyToServerEventLoop.
|
private void |
doStart() |
protected Collection<ActivityTracker> |
getActivityTrackers() |
protected ChainedProxyManager |
getChainProxyManager() |
int |
getConnectTimeout() |
HttpFiltersSource |
getFiltersSource() |
int |
getIdleConnectionTimeout() |
InetSocketAddress |
getListenAddress()
Return the address on which this proxy is listening.
|
InetSocketAddress |
getLocalAddress() |
protected MitmManager |
getMitmManager() |
protected ProxyAuthenticator |
getProxyAuthenticator() |
protected EventLoopGroup |
getProxyToServerWorkerFor(TransportProtocol transportProtocol) |
long |
getReadThrottle() |
HostResolver |
getServerResolver() |
protected SslEngineSource |
getSslEngineSource() |
long |
getWriteThrottle() |
(package private) boolean |
isTransparent() |
protected void |
registerChannel(Channel channel)
Register a new
Channel with this server, for later closing. |
void |
setIdleConnectionTimeout(int idleConnectionTimeout) |
void |
setThrottle(long readThrottleBytesPerSecond,
long writeThrottleBytesPerSecond)
Set the read/write throttle bandwidths (in bytes/second) for this proxy.
|
private HttpProxyServer |
start() |
void |
stop()
Stops the server and all related clones.
|
private static final long TRAFFIC_SHAPING_CHECK_INTERVAL_MS
private static final org.slf4j.Logger LOG
private final DefaultHttpProxyServer.ServerGroup serverGroup
DefaultHttpProxyServer.ServerGroup. Multiple proxy servers can share the same
ServerGroup in order to reuse threads and other such resources.private final TransportProtocol transportProtocol
private final InetSocketAddress requestedAddress
private volatile InetSocketAddress localAddress
private volatile InetSocketAddress boundAddress
private final SslEngineSource sslEngineSource
private final boolean authenticateSslClients
private final ProxyAuthenticator proxyAuthenticator
private final ChainedProxyManager chainProxyManager
private final MitmManager mitmManager
private final HttpFiltersSource filtersSource
private final boolean transparent
private final int connectTimeout
private volatile int idleConnectionTimeout
private final HostResolver serverResolver
private volatile GlobalTrafficShapingHandler globalTrafficShapingHandler
private final Collection<ActivityTracker> activityTrackers
private DefaultHttpProxyServer(DefaultHttpProxyServer.ServerGroup serverGroup, TransportProtocol transportProtocol, InetSocketAddress requestedAddress, SslEngineSource sslEngineSource, boolean authenticateSslClients, ProxyAuthenticator proxyAuthenticator, ChainedProxyManager chainProxyManager, MitmManager mitmManager, HttpFiltersSource filtersSource, boolean transparent, int idleConnectionTimeout, Collection<ActivityTracker> activityTrackers, int connectTimeout, HostResolver serverResolver, long readThrottleBytesPerSecond, long writeThrottleBytesPerSecond, InetSocketAddress localAddress)
serverGroup - our ServerGroup for shared thread pools and suchtransportProtocol - The protocol to use for data transportrequestedAddress - The address on which this server will listensslEngineSource - (optional) if specified, this Proxy will encrypt inbound
connections from clients using an SSLEngine obtained
from this SslEngineSource.authenticateSslClients - Indicate whether or not to authenticate clients when using SSLproxyAuthenticator - (optional) If specified, requests to the proxy will be
authenticated using HTTP BASIC authentication per the provided
ProxyAuthenticatorchainProxyManager - The proxy to send requests to if chaining proxies. Typically
null.mitmManager - The MitmManager to use for man in the middle'ing
CONNECT requestsfiltersSource - Source for HttpFilterstransparent - If true, this proxy will run as a transparent proxy (not
touching requests and responses).idleConnectionTimeout - The timeout (in seconds) for auto-closing idle connections.activityTrackers - for tracking activity on this proxyconnectTimeout - number of milliseconds to wait to connect to the upstream
serverserverResolver - the HostResolver to use for resolving server addressesreadThrottleBytesPerSecond - read throttle bandwidthwriteThrottleBytesPerSecond - write throttle bandwidthpublic static HttpProxyServerBootstrap bootstrap()
DefaultHttpProxyServer starting from scratch.public static HttpProxyServerBootstrap bootstrapFromFile(String path)
DefaultHttpProxyServer using defaults from the
given file.path - private GlobalTrafficShapingHandler createGlobalTrafficShapingHandler(TransportProtocol transportProtocol, long readThrottleBytesPerSecond, long writeThrottleBytesPerSecond)
transportProtocol - readThrottleBytesPerSecond - writeThrottleBytesPerSecond - boolean isTransparent()
public int getIdleConnectionTimeout()
getIdleConnectionTimeout in interface HttpProxyServerpublic void setIdleConnectionTimeout(int idleConnectionTimeout)
setIdleConnectionTimeout in interface HttpProxyServerpublic int getConnectTimeout()
public HostResolver getServerResolver()
public InetSocketAddress getLocalAddress()
public InetSocketAddress getListenAddress()
HttpProxyServergetListenAddress in interface HttpProxyServerpublic void setThrottle(long readThrottleBytesPerSecond,
long writeThrottleBytesPerSecond)
HttpProxyServerSet the read/write throttle bandwidths (in bytes/second) for this proxy.
setThrottle in interface HttpProxyServerpublic long getReadThrottle()
public long getWriteThrottle()
public HttpProxyServerBootstrap clone()
HttpProxyServerClone the existing server, with a port 1 higher and everything else the same.
The new server will share event loops with the original server. The event loops will use whatever name was given to the first server in the clone group.
clone in interface HttpProxyServerclone in class Objectpublic void stop()
HttpProxyServerstop in interface HttpProxyServerpublic void abort()
HttpProxyServerabort in interface HttpProxyServerprivate HttpProxyServer start()
private void doStart()
protected void registerChannel(Channel channel)
Channel with this server, for later closing.channel - protected ChainedProxyManager getChainProxyManager()
protected MitmManager getMitmManager()
protected SslEngineSource getSslEngineSource()
protected ProxyAuthenticator getProxyAuthenticator()
public HttpFiltersSource getFiltersSource()
protected Collection<ActivityTracker> getActivityTrackers()
protected EventLoopGroup getProxyToServerWorkerFor(TransportProtocol transportProtocol)
Copyright © 2009–2015 LittleShoot. All rights reserved.