Home / Class/ SocksAuthRequestDecoder Class — netty Architecture

SocksAuthRequestDecoder Class — netty Architecture

Architecture documentation for the SocksAuthRequestDecoder class in SocksAuthRequestDecoder.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  10830add_a048_4d89_ea74_df19b3a40e95["SocksAuthRequestDecoder"]
  f5f99f22_090f_b405_052d_0e25fbf88217["SocksAuthRequestDecoder.java"]
  10830add_a048_4d89_ea74_df19b3a40e95 -->|defined in| f5f99f22_090f_b405_052d_0e25fbf88217
  d3a08311_fb56_f34b_36a2_7d5ca0e2f80e["SocksAuthRequestDecoder()"]
  10830add_a048_4d89_ea74_df19b3a40e95 -->|method| d3a08311_fb56_f34b_36a2_7d5ca0e2f80e
  f8c54faf_fc3a_e71a_60d8_bdb8a1847e93["decode()"]
  10830add_a048_4d89_ea74_df19b3a40e95 -->|method| f8c54faf_fc3a_e71a_60d8_bdb8a1847e93

Relationship Graph

Source Code

codec-socks/src/main/java/io/netty/handler/codec/socks/SocksAuthRequestDecoder.java lines 31–73

public class SocksAuthRequestDecoder extends ReplayingDecoder<State> {

    private String username;

    public SocksAuthRequestDecoder() {
        super(State.CHECK_PROTOCOL_VERSION);
    }

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out) throws Exception {
        switch (state()) {
            case CHECK_PROTOCOL_VERSION: {
                if (byteBuf.readByte() != SocksSubnegotiationVersion.AUTH_PASSWORD.byteValue()) {
                    out.add(SocksCommonUtils.UNKNOWN_SOCKS_REQUEST);
                    break;
                }
                checkpoint(State.READ_USERNAME);
            }
            case READ_USERNAME: {
                int fieldLength = byteBuf.readByte();
                username = byteBuf.readString(fieldLength, CharsetUtil.US_ASCII);
                checkpoint(State.READ_PASSWORD);
            }
            case READ_PASSWORD: {
                int fieldLength = byteBuf.readByte();
                String password = byteBuf.readString(fieldLength, CharsetUtil.US_ASCII);
                out.add(new SocksAuthRequest(username, password));
                break;
            }
            default: {
                throw new Error("Unexpected request decoder state: " + state());
            }
        }
        ctx.pipeline().remove(this);
    }

    @UnstableApi
    public enum State {
        CHECK_PROTOCOL_VERSION,
        READ_USERNAME,
        READ_PASSWORD
    }
}

Frequently Asked Questions

What is the SocksAuthRequestDecoder class?
SocksAuthRequestDecoder is a class in the netty codebase, defined in codec-socks/src/main/java/io/netty/handler/codec/socks/SocksAuthRequestDecoder.java.
Where is SocksAuthRequestDecoder defined?
SocksAuthRequestDecoder is defined in codec-socks/src/main/java/io/netty/handler/codec/socks/SocksAuthRequestDecoder.java at line 31.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free