public abstract class ProxyHandler extends ChannelDuplexHandler
ChannelHandler.Sharable| Modifier | Constructor and Description |
|---|---|
protected |
ProxyHandler(SocketAddress proxyAddress) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
addCodec(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(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.fireChannelActive() to forward
to the next ChannelInboundHandler in the ChannelPipeline. |
void |
channelInactive(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.fireChannelInactive() to forward
to the next ChannelInboundHandler in the ChannelPipeline. |
void |
channelRead(ChannelHandlerContext ctx,
Object msg)
Calls
ChannelHandlerContext.fireChannelRead(Object) to forward
to the next ChannelInboundHandler in the ChannelPipeline. |
void |
channelReadComplete(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.fireChannelReadComplete() to forward
to the next ChannelInboundHandler in the ChannelPipeline. |
void |
connect(ChannelHandlerContext ctx,
SocketAddress remoteAddress,
SocketAddress localAddress,
ChannelPromise promise)
Calls
ChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise) to forward
to the next ChannelOutboundHandler in the ChannelPipeline. |
Future<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(ChannelHandlerContext ctx,
Throwable cause)
Calls
ChannelHandlerContext.fireExceptionCaught(Throwable) to forward
to the next ChannelHandler in the ChannelPipeline. |
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(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.flush() to forward
to the next ChannelOutboundHandler in the ChannelPipeline. |
void |
handlerAdded(ChannelHandlerContext ctx)
Do nothing by default, sub-classes may override this method.
|
protected abstract boolean |
handleResponse(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(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(ChannelHandlerContext ctx)
Removes the decoders added in
addCodec(ChannelHandlerContext). |
protected abstract void |
removeEncoder(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(ChannelHandlerContext ctx,
Object msg,
ChannelPromise promise)
Calls
ChannelOutboundInvoker.write(Object, ChannelPromise) to forward
to the next ChannelOutboundHandler in the ChannelPipeline. |
bind, close, deregister, disconnect, readchannelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredensureNotSharable, handlerRemoved, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerRemovedprotected 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 Future<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(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapterhandlerAdded in interface ChannelHandlerhandlerAdded in class ChannelHandlerAdapterExceptionprotected abstract void addCodec(ChannelHandlerContext ctx) throws Exception
Exceptionprotected abstract void removeEncoder(ChannelHandlerContext ctx) throws Exception
addCodec(ChannelHandlerContext).Exceptionprotected abstract void removeDecoder(ChannelHandlerContext ctx) throws Exception
addCodec(ChannelHandlerContext).Exceptionpublic final void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception
ChannelDuplexHandlerChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise) to forward
to the next ChannelOutboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.connect in interface ChannelOutboundHandlerconnect in class ChannelDuplexHandlerctx - the ChannelHandlerContext for which the connect operation is maderemoteAddress - the SocketAddress to which it should connectlocalAddress - the SocketAddress which is used as source on connectpromise - the ChannelPromise to notify once the operation completesException - thrown if an error occurspublic final void channelActive(ChannelHandlerContext ctx) throws Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelActive() to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelActive in interface ChannelInboundHandlerchannelActive in class ChannelInboundHandlerAdapterExceptionprotected abstract Object newInitialMessage(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(ChannelHandlerContext ctx) throws Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelInactive() to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelInactive in interface ChannelInboundHandlerchannelInactive in class ChannelInboundHandlerAdapterExceptionpublic final void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireExceptionCaught(Throwable) to forward
to the next ChannelHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.exceptionCaught in interface ChannelHandlerexceptionCaught in interface ChannelInboundHandlerexceptionCaught in class ChannelInboundHandlerAdapterExceptionpublic final void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelRead(Object) to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelRead in interface ChannelInboundHandlerchannelRead in class ChannelInboundHandlerAdapterExceptionprotected abstract boolean handleResponse(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(ChannelHandlerContext ctx) throws Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelReadComplete() to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelReadComplete in interface ChannelInboundHandlerchannelReadComplete in class ChannelInboundHandlerAdapterExceptionpublic final void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
ChannelDuplexHandlerChannelOutboundInvoker.write(Object, ChannelPromise) to forward
to the next ChannelOutboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.write in interface ChannelOutboundHandlerwrite in class ChannelDuplexHandlerctx - the ChannelHandlerContext for which the write operation is mademsg - the message to writepromise - the ChannelPromise to notify once the operation completesException - thrown if an error occurspublic final void flush(ChannelHandlerContext ctx) throws Exception
ChannelDuplexHandlerChannelHandlerContext.flush() to forward
to the next ChannelOutboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.flush in interface ChannelOutboundHandlerflush in class ChannelDuplexHandlerctx - the ChannelHandlerContext for which the flush operation is madeException - thrown if an error occursCopyright © 2008–2025 The Netty Project. All rights reserved.