Package io.netty.handler.proxy
Class Socks4ProxyHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.ChannelDuplexHandler
-
- io.netty.handler.proxy.ProxyHandler
-
- io.netty.handler.proxy.Socks4ProxyHandler
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,io.netty.channel.ChannelOutboundHandler
public final class Socks4ProxyHandler extends ProxyHandler
Handler that establishes a blind forwarding proxy tunnel using SOCKS4 protocol.
-
-
Constructor Summary
Constructors Constructor Description Socks4ProxyHandler(SocketAddress proxyAddress)Socks4ProxyHandler(SocketAddress proxyAddress, String username)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddCodec(io.netty.channel.ChannelHandlerContext ctx)Adds the codec handlers required to communicate with the proxy server.StringauthScheme()Returns the name of the authentication scheme in use.protected booleanhandleResponse(io.netty.channel.ChannelHandlerContext ctx, Object response)Handles the message received from the proxy server.protected ObjectnewInitialMessage(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.Stringprotocol()Returns the name of the proxy protocol in use.protected voidremoveDecoder(io.netty.channel.ChannelHandlerContext ctx)Removes the decoders added inProxyHandler.addCodec(ChannelHandlerContext).protected voidremoveEncoder(io.netty.channel.ChannelHandlerContext ctx)Removes the encoders added inProxyHandler.addCodec(ChannelHandlerContext).Stringusername()-
Methods inherited from class io.netty.handler.proxy.ProxyHandler
channelActive, channelInactive, channelRead, channelReadComplete, connect, connectFuture, connectTimeoutMillis, destinationAddress, exceptionCaught, exceptionMessage, flush, handlerAdded, isConnected, proxyAddress, sendToProxyServer, setConnectTimeoutMillis, write
-
Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, deregister, disconnect, read
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerRemoved, isSharable
-
-
-
-
Constructor Detail
-
Socks4ProxyHandler
public Socks4ProxyHandler(SocketAddress proxyAddress)
-
Socks4ProxyHandler
public Socks4ProxyHandler(SocketAddress proxyAddress, String username)
-
-
Method Detail
-
protocol
public String protocol()
Description copied from class:ProxyHandlerReturns the name of the proxy protocol in use.- Specified by:
protocolin classProxyHandler
-
authScheme
public String authScheme()
Description copied from class:ProxyHandlerReturns the name of the authentication scheme in use.- Specified by:
authSchemein classProxyHandler
-
username
public String username()
-
addCodec
protected void addCodec(io.netty.channel.ChannelHandlerContext ctx) throws ExceptionDescription copied from class:ProxyHandlerAdds the codec handlers required to communicate with the proxy server.- Specified by:
addCodecin classProxyHandler- Throws:
Exception
-
removeEncoder
protected void removeEncoder(io.netty.channel.ChannelHandlerContext ctx) throws ExceptionDescription copied from class:ProxyHandlerRemoves the encoders added inProxyHandler.addCodec(ChannelHandlerContext).- Specified by:
removeEncoderin classProxyHandler- Throws:
Exception
-
removeDecoder
protected void removeDecoder(io.netty.channel.ChannelHandlerContext ctx) throws ExceptionDescription copied from class:ProxyHandlerRemoves the decoders added inProxyHandler.addCodec(ChannelHandlerContext).- Specified by:
removeDecoderin classProxyHandler- Throws:
Exception
-
newInitialMessage
protected Object newInitialMessage(io.netty.channel.ChannelHandlerContext ctx) throws Exception
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
protected boolean handleResponse(io.netty.channel.ChannelHandlerContext ctx, Object response) throws ExceptionDescription 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
-
-