Class Socks4ServerDecoder

All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler

public class Socks4ServerDecoder extends ReplayingDecoder<Socks4ServerDecoder.State>
Decodes a single Socks4CommandRequest from the inbound ByteBufs. On successful decode, this decoder will forward the received data to the next handler, so that other handler can remove this decoder later. On failed decode, this decoder will discard the received data, so that other handler closes the connection later.
  • Field Details

    • MAX_FIELD_LENGTH

      private static final int MAX_FIELD_LENGTH
      See Also:
    • type

      private Socks4CommandType type
    • dstAddr

      private java.lang.String dstAddr
    • dstPort

      private int dstPort
    • userId

      private java.lang.String userId
  • Constructor Details

    • Socks4ServerDecoder

      public Socks4ServerDecoder()
  • Method Details

    • decode

      protected void decode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
      Description copied from class: ByteToMessageDecoder
      Decode the from one ByteBuf to an other. This method will be called till either the input ByteBuf has nothing to read when return from this method or till nothing was read from the input ByteBuf.
      Specified by:
      decode in class ByteToMessageDecoder
      Parameters:
      ctx - the ChannelHandlerContext which this ByteToMessageDecoder belongs to
      in - the ByteBuf from which to read data
      out - the List to which decoded messages should be added
      Throws:
      java.lang.Exception - is thrown if an error occurs
    • fail

      private void fail(java.util.List<java.lang.Object> out, java.lang.Exception cause)
    • readString

      private static java.lang.String readString(java.lang.String fieldName, ByteBuf in)
      Reads a variable-length NUL-terminated string as defined in SOCKS4.