Home / Function/ decode() — netty Function Reference

decode() — netty Function Reference

Architecture documentation for the decode() function in Socks5InitialRequestDecoder.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  98cb6c51_918c_ac5e_eeb6_81db52959586["decode()"]
  c8dbff5d_17e9_7cbf_4232_15f060dc4a1a["Socks5InitialRequestDecoder"]
  98cb6c51_918c_ac5e_eeb6_81db52959586 -->|defined in| c8dbff5d_17e9_7cbf_4232_15f060dc4a1a
  22fe9ae3_fe20_7231_af0c_834285a859b9["fail()"]
  98cb6c51_918c_ac5e_eeb6_81db52959586 -->|calls| 22fe9ae3_fe20_7231_af0c_834285a859b9
  style 98cb6c51_918c_ac5e_eeb6_81db52959586 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/Socks5InitialRequestDecoder.java lines 49–85

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        try {
            switch (state()) {
            case INIT: {
                final byte version = in.readByte();
                if (version != SocksVersion.SOCKS5.byteValue()) {
                    throw new DecoderException(
                            "unsupported version: " + version + " (expected: " + SocksVersion.SOCKS5.byteValue() + ')');
                }

                final int authMethodCnt = in.readUnsignedByte();

                final Socks5AuthMethod[] authMethods = new Socks5AuthMethod[authMethodCnt];
                for (int i = 0; i < authMethodCnt; i++) {
                    authMethods[i] = Socks5AuthMethod.valueOf(in.readByte());
                }

                out.add(new DefaultSocks5InitialRequest(authMethods));
                checkpoint(State.SUCCESS);
            }
            case SUCCESS: {
                int readableBytes = actualReadableBytes();
                if (readableBytes > 0) {
                    out.add(in.readRetainedSlice(readableBytes));
                }
                break;
            }
            case FAILURE: {
                in.skipBytes(actualReadableBytes());
                break;
            }
            }
        } catch (Exception e) {
            fail(out, e);
        }
    }

Domain

Subdomains

Calls

Frequently Asked Questions

What does decode() do?
decode() is a function in the netty codebase, defined in codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/Socks5InitialRequestDecoder.java.
Where is decode() defined?
decode() is defined in codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/Socks5InitialRequestDecoder.java at line 49.
What does decode() call?
decode() calls 1 function(s): fail.

Analyze Your Own Codebase

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

Try Supermodel Free