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()
Rerutns
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, read
channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
protected 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.ChannelHandler
handlerAdded
in class io.netty.channel.ChannelHandlerAdapter
Exception
protected abstract void addCodec(io.netty.channel.ChannelHandlerContext ctx) throws Exception
Exception
protected abstract void removeEncoder(io.netty.channel.ChannelHandlerContext ctx) throws Exception
addCodec(ChannelHandlerContext)
.Exception
protected abstract void removeDecoder(io.netty.channel.ChannelHandlerContext ctx) throws Exception
addCodec(ChannelHandlerContext)
.Exception
public 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.ChannelOutboundHandler
connect
in class io.netty.channel.ChannelDuplexHandler
Exception
public final void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
channelActive
in interface io.netty.channel.ChannelInboundHandler
channelActive
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
protected abstract Object newInitialMessage(io.netty.channel.ChannelHandlerContext ctx) throws Exception
null
if the proxy server is expected to send the first message insteadException
protected 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.ChannelInboundHandler
channelInactive
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
public final void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception
exceptionCaught
in interface io.netty.channel.ChannelHandler
exceptionCaught
in interface io.netty.channel.ChannelInboundHandler
exceptionCaught
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
public final void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) throws Exception
channelRead
in interface io.netty.channel.ChannelInboundHandler
channelRead
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
protected 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 serverException
protected final String exceptionMessage(String msg)
public final void channelReadComplete(io.netty.channel.ChannelHandlerContext ctx) throws Exception
channelReadComplete
in interface io.netty.channel.ChannelInboundHandler
channelReadComplete
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
public final void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) throws Exception
write
in interface io.netty.channel.ChannelOutboundHandler
write
in class io.netty.channel.ChannelDuplexHandler
Exception
Copyright © 2008–2017 The Netty Project. All rights reserved.