public abstract class ProxyHandler
extends io.netty.channel.ChannelDuplexHandler
| Modifier | Constructor and Description |
|---|---|
protected |
ProxyHandler(SocketAddress proxyAddress) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
addCodec(io.netty.channel.ChannelHandlerContext ctx)
Adds the codec handlers required to communicate with the proxy server.
|
abstract String |
authScheme()
Returns the name of the authentication scheme in use.
|
void |
channelActive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelInactive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg) |
void |
channelReadComplete(io.netty.channel.ChannelHandlerContext ctx) |
void |
connect(io.netty.channel.ChannelHandlerContext ctx,
SocketAddress remoteAddress,
SocketAddress localAddress,
io.netty.channel.ChannelPromise promise) |
io.netty.util.concurrent.Future<io.netty.channel.Channel> |
connectFuture()
Returns a
Future that is notified when the connection to the destination has been established
or the connection attempt has failed. |
long |
connectTimeoutMillis()
Returns the connect timeout in millis.
|
<T extends SocketAddress> |
destinationAddress()
Returns the address of the destination to connect to via the proxy server.
|
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
protected String |
exceptionMessage(String msg)
Decorates the specified exception message with the common information such as the current protocol,
authentication scheme, proxy address, and destination address.
|
void |
flush(io.netty.channel.ChannelHandlerContext ctx) |
void |
handlerAdded(io.netty.channel.ChannelHandlerContext ctx) |
protected abstract boolean |
handleResponse(io.netty.channel.ChannelHandlerContext ctx,
Object response)
Handles the message received from the proxy server.
|
boolean |
isConnected()
Returns
true if and only if the connection to the destination has been established successfully. |
protected abstract Object |
newInitialMessage(io.netty.channel.ChannelHandlerContext ctx)
Returns a new message that is sent at first time when the connection to the proxy server has been established.
|
abstract String |
protocol()
Returns the name of the proxy protocol in use.
|
<T extends SocketAddress> |
proxyAddress()
Returns the address of the proxy server.
|
protected abstract void |
removeDecoder(io.netty.channel.ChannelHandlerContext ctx)
Removes the decoders added in
addCodec(ChannelHandlerContext). |
protected abstract void |
removeEncoder(io.netty.channel.ChannelHandlerContext ctx)
Removes the encoders added in
addCodec(ChannelHandlerContext). |
protected void |
sendToProxyServer(Object msg)
Sends the specified message to the proxy server.
|
void |
setConnectTimeoutMillis(long connectTimeoutMillis)
Sets the connect timeout in millis.
|
void |
write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise) |
bind, close, deregister, disconnect, readchannelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredensureNotSharable, handlerRemoved, isSharableprotected ProxyHandler(SocketAddress proxyAddress)
public abstract String protocol()
public abstract String authScheme()
public final <T extends SocketAddress> T proxyAddress()
public final <T extends SocketAddress> T destinationAddress()
public final boolean isConnected()
true if and only if the connection to the destination has been established successfully.public final io.netty.util.concurrent.Future<io.netty.channel.Channel> connectFuture()
Future that is notified when the connection to the destination has been established
or the connection attempt has failed.public final long connectTimeoutMillis()
public final void setConnectTimeoutMillis(long connectTimeoutMillis)
public final void handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
handlerAdded in interface io.netty.channel.ChannelHandlerhandlerAdded in class io.netty.channel.ChannelHandlerAdapterExceptionprotected abstract void addCodec(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
Exceptionprotected abstract void removeEncoder(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
addCodec(ChannelHandlerContext).Exceptionprotected abstract void removeDecoder(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
addCodec(ChannelHandlerContext).Exceptionpublic final void connect(io.netty.channel.ChannelHandlerContext ctx,
SocketAddress remoteAddress,
SocketAddress localAddress,
io.netty.channel.ChannelPromise promise)
throws Exception
connect in interface io.netty.channel.ChannelOutboundHandlerconnect in class io.netty.channel.ChannelDuplexHandlerExceptionpublic final void channelActive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelActive in interface io.netty.channel.ChannelInboundHandlerchannelActive in class io.netty.channel.ChannelInboundHandlerAdapterExceptionprotected abstract Object newInitialMessage(io.netty.channel.ChannelHandlerContext ctx) throws Exception
null if the proxy server is expected to send the first message insteadExceptionprotected final void sendToProxyServer(Object msg)
handleResponse(ChannelHandlerContext, Object).public final void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelInactive in interface io.netty.channel.ChannelInboundHandlerchannelInactive in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic final void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause)
throws Exception
exceptionCaught in interface io.netty.channel.ChannelHandlerexceptionCaught in interface io.netty.channel.ChannelInboundHandlerexceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic final void channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg)
throws Exception
channelRead in interface io.netty.channel.ChannelInboundHandlerchannelRead in class io.netty.channel.ChannelInboundHandlerAdapterExceptionprotected abstract boolean handleResponse(io.netty.channel.ChannelHandlerContext ctx,
Object response)
throws Exception
true if the connection to the destination has been established,
false if the connection to the destination has not been established and more messages are
expected from the proxy serverExceptionprotected final String exceptionMessage(String msg)
public final void channelReadComplete(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelReadComplete in interface io.netty.channel.ChannelInboundHandlerchannelReadComplete in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic final void write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise)
throws Exception
write in interface io.netty.channel.ChannelOutboundHandlerwrite in class io.netty.channel.ChannelDuplexHandlerExceptionCopyright © 2008–2019 The Netty Project. All rights reserved.