Class Socks5ProxyHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.handler.proxy.ProxyHandler
io.netty.handler.proxy.Socks5ProxyHandler
- All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler
Handler that establishes a blind forwarding proxy tunnel using
SOCKS Protocol Version 5.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.SharableModifier and TypeInterfaceDescriptionstatic @interfaceIndicates that the same instance of the annotatedChannelHandlercan be added to one or moreChannelPipelines multiple times without a race condition. -
Constructor Summary
ConstructorsConstructorDescriptionSocks5ProxyHandler(SocketAddress proxyAddress) Socks5ProxyHandler(SocketAddress proxyAddress, String username, String password) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds the codec handlers required to communicate with the proxy server.Returns the name of the authentication scheme in use.protected booleanhandleResponse(ChannelHandlerContext ctx, Object response) Handles the message received from the proxy server.protected ObjectReturns a new message that is sent at first time when the connection to the proxy server has been established.password()protocol()Returns the name of the proxy protocol in use.protected voidRemoves the decoders added inProxyHandler.addCodec(ChannelHandlerContext).protected voidRemoves the encoders added inProxyHandler.addCodec(ChannelHandlerContext).username()Methods inherited from class ProxyHandler
channelActive, channelInactive, channelRead, channelReadComplete, connect, connectFuture, connectTimeoutMillis, destinationAddress, exceptionCaught, exceptionMessage, flush, handlerAdded, isConnected, proxyAddress, sendToProxyServer, setConnectTimeoutMillis, writeModifier and TypeMethodDescriptionfinal voidCallsChannelHandlerContext.fireChannelActive()to forward to the nextChannelInboundHandlerin theChannelPipeline.final voidCallsChannelHandlerContext.fireChannelInactive()to forward to the nextChannelInboundHandlerin theChannelPipeline.final voidchannelRead(ChannelHandlerContext ctx, Object msg) CallsChannelHandlerContext.fireChannelRead(Object)to forward to the nextChannelInboundHandlerin theChannelPipeline.final voidCallsChannelHandlerContext.fireChannelReadComplete()to forward to the nextChannelInboundHandlerin theChannelPipeline.final voidconnect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) CallsChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline.Returns aFuturethat is notified when the connection to the destination has been established or the connection attempt has failed.final longReturns the connect timeout in millis.final <T extends SocketAddress>
TReturns the address of the destination to connect to via the proxy server.final voidexceptionCaught(ChannelHandlerContext ctx, Throwable cause) CallsChannelHandlerContext.fireExceptionCaught(Throwable)to forward to the nextChannelHandlerin theChannelPipeline.protected final StringexceptionMessage(String msg) Decorates the specified exception message with the common information such as the current protocol, authentication scheme, proxy address, and destination address.final voidCallsChannelHandlerContext.flush()to forward to the nextChannelOutboundHandlerin theChannelPipeline.final voidDo nothing by default, sub-classes may override this method.final booleanReturnstrueif and only if the connection to the destination has been established successfully.final <T extends SocketAddress>
TReturns the address of the proxy server.protected final voidsendToProxyServer(Object msg) Sends the specified message to the proxy server.final voidsetConnectTimeoutMillis(long connectTimeoutMillis) Sets the connect timeout in millis.final voidwrite(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) CallsChannelOutboundInvoker.write(Object, ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline.Methods inherited from class ChannelDuplexHandler
bind, close, deregister, disconnect, readModifier and TypeMethodDescriptionvoidbind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) CallsChannelOutboundInvoker.bind(SocketAddress, ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline.voidclose(ChannelHandlerContext ctx, ChannelPromise promise) CallsChannelOutboundInvoker.close(ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline.voidderegister(ChannelHandlerContext ctx, ChannelPromise promise) CallsChannelOutboundInvoker.deregister(ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline.voiddisconnect(ChannelHandlerContext ctx, ChannelPromise promise) CallsChannelOutboundInvoker.disconnect(ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.read()to forward to the nextChannelOutboundHandlerin theChannelPipeline.Methods inherited from class ChannelInboundHandlerAdapter
channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredModifier and TypeMethodDescriptionvoidCallsChannelHandlerContext.fireChannelRegistered()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelUnregistered()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelWritabilityChanged()to forward to the nextChannelInboundHandlerin theChannelPipeline.voiduserEventTriggered(ChannelHandlerContext ctx, Object evt) CallsChannelHandlerContext.fireUserEventTriggered(Object)to forward to the nextChannelInboundHandlerin theChannelPipeline.Methods inherited from class ChannelHandlerAdapter
ensureNotSharable, handlerRemoved, isSharableModifier and TypeMethodDescriptionprotected voidvoidDo nothing by default, sub-classes may override this method.booleanReturntrueif the implementation isChannelHandler.Sharableand so can be added to differentChannelPipelines.
-
Constructor Details
-
Socks5ProxyHandler
-
Socks5ProxyHandler
-
-
Method Details
-
protocol
Description copied from class:ProxyHandlerReturns the name of the proxy protocol in use.- Specified by:
protocolin classProxyHandler
-
authScheme
Description copied from class:ProxyHandlerReturns the name of the authentication scheme in use.- Specified by:
authSchemein classProxyHandler
-
username
-
password
-
addCodec
Description copied from class:ProxyHandlerAdds the codec handlers required to communicate with the proxy server.- Specified by:
addCodecin classProxyHandler- Throws:
Exception
-
removeEncoder
Description copied from class:ProxyHandlerRemoves the encoders added inProxyHandler.addCodec(ChannelHandlerContext).- Specified by:
removeEncoderin classProxyHandler- Throws:
Exception
-
removeDecoder
Description copied from class:ProxyHandlerRemoves the decoders added inProxyHandler.addCodec(ChannelHandlerContext).- Specified by:
removeDecoderin classProxyHandler- Throws:
Exception
-
newInitialMessage
Description copied from class:ProxyHandlerReturns a new message that is sent at first time when the connection to the proxy server has been established.- Specified by:
newInitialMessagein classProxyHandler- Returns:
- the initial message, or
nullif the proxy server is expected to send the first message instead - Throws:
Exception
-
handleResponse
Description copied from class:ProxyHandlerHandles the message received from the proxy server.- Specified by:
handleResponsein classProxyHandler- Returns:
trueif the connection to the destination has been established,falseif the connection to the destination has not been established and more messages are expected from the proxy server- Throws:
Exception
-