Class Socks4ProxyHandler

All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler

public final class Socks4ProxyHandler extends ProxyHandler
Handler that establishes a blind forwarding proxy tunnel using SOCKS4 protocol.
  • Field Details

    • PROTOCOL

      private static final java.lang.String PROTOCOL
      See Also:
    • AUTH_USERNAME

      private static final java.lang.String AUTH_USERNAME
      See Also:
    • username

      private final java.lang.String username
    • decoderName

      private java.lang.String decoderName
    • encoderName

      private java.lang.String encoderName
  • Constructor Details

    • Socks4ProxyHandler

      public Socks4ProxyHandler(java.net.SocketAddress proxyAddress)
    • Socks4ProxyHandler

      public Socks4ProxyHandler(java.net.SocketAddress proxyAddress, java.lang.String username)
  • Method Details

    • protocol

      public java.lang.String protocol()
      Description copied from class: ProxyHandler
      Returns the name of the proxy protocol in use.
      Specified by:
      protocol in class ProxyHandler
    • authScheme

      public java.lang.String authScheme()
      Description copied from class: ProxyHandler
      Returns the name of the authentication scheme in use.
      Specified by:
      authScheme in class ProxyHandler
    • username

      public java.lang.String username()
    • addCodec

      protected void addCodec(ChannelHandlerContext ctx) throws java.lang.Exception
      Description copied from class: ProxyHandler
      Adds the codec handlers required to communicate with the proxy server.
      Specified by:
      addCodec in class ProxyHandler
      Throws:
      java.lang.Exception
    • removeEncoder

      protected void removeEncoder(ChannelHandlerContext ctx) throws java.lang.Exception
      Description copied from class: ProxyHandler
      Removes the encoders added in ProxyHandler.addCodec(ChannelHandlerContext).
      Specified by:
      removeEncoder in class ProxyHandler
      Throws:
      java.lang.Exception
    • removeDecoder

      protected void removeDecoder(ChannelHandlerContext ctx) throws java.lang.Exception
      Description copied from class: ProxyHandler
      Removes the decoders added in ProxyHandler.addCodec(ChannelHandlerContext).
      Specified by:
      removeDecoder in class ProxyHandler
      Throws:
      java.lang.Exception
    • newInitialMessage

      protected java.lang.Object newInitialMessage(ChannelHandlerContext ctx) throws java.lang.Exception
      Description copied from class: ProxyHandler
      Returns a new message that is sent at first time when the connection to the proxy server has been established.
      Specified by:
      newInitialMessage in class ProxyHandler
      Returns:
      the initial message, or null if the proxy server is expected to send the first message instead
      Throws:
      java.lang.Exception
    • handleResponse

      protected boolean handleResponse(ChannelHandlerContext ctx, java.lang.Object response) throws java.lang.Exception
      Description copied from class: ProxyHandler
      Handles the message received from the proxy server.
      Specified by:
      handleResponse in class ProxyHandler
      Returns:
      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 server
      Throws:
      java.lang.Exception