Home / Function/ decode() — netty Function Reference

decode() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  8981ae6c_c758_e5be_9bd7_dcf9c6ceab28["decode()"]
  21c2e1f6_8657_6435_51ab_f4e11ef47496["Socks5PasswordAuthRequestDecoder"]
  8981ae6c_c758_e5be_9bd7_dcf9c6ceab28 -->|defined in| 21c2e1f6_8657_6435_51ab_f4e11ef47496
  f3fe86a1_f0ab_270a_0b10_e07d0e101b14["fail()"]
  8981ae6c_c758_e5be_9bd7_dcf9c6ceab28 -->|calls| f3fe86a1_f0ab_270a_0b10_e07d0e101b14
  style 8981ae6c_c758_e5be_9bd7_dcf9c6ceab28 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

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

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        try {
            switch (state()) {
            case INIT: {
                final int startOffset = in.readerIndex();
                final byte version = in.getByte(startOffset);
                if (version != 1) {
                    throw new DecoderException("unsupported subnegotiation version: " + version + " (expected: 1)");
                }

                final int usernameLength = in.getUnsignedByte(startOffset + 1);
                final int passwordLength = in.getUnsignedByte(startOffset + 2 + usernameLength);
                final int totalLength = usernameLength + passwordLength + 3;

                in.skipBytes(totalLength);
                out.add(new DefaultSocks5PasswordAuthRequest(
                        in.toString(startOffset + 2, usernameLength, CharsetUtil.US_ASCII),
                        in.toString(startOffset + 3 + usernameLength, passwordLength, CharsetUtil.US_ASCII)));

                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/Socks5PasswordAuthRequestDecoder.java.
Where is decode() defined?
decode() is defined in codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/Socks5PasswordAuthRequestDecoder.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