Home / Function/ decode() — netty Function Reference

decode() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  ab7dfc3f_38ae_2242_0527_ac688ded9e73["decode()"]
  1eb0d1c8_4306_0987_abef_474fe9a99790["Socks5PrivateAuthResponseDecoder"]
  ab7dfc3f_38ae_2242_0527_ac688ded9e73 -->|defined in| 1eb0d1c8_4306_0987_abef_474fe9a99790
  a75059f8_bc15_8624_6822_b4c350cb3525["fail()"]
  ab7dfc3f_38ae_2242_0527_ac688ded9e73 -->|calls| a75059f8_bc15_8624_6822_b4c350cb3525
  style ab7dfc3f_38ae_2242_0527_ac688ded9e73 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/Socks5PrivateAuthResponseDecoder.java lines 71–106

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in,
                          List<Object> out) throws Exception {
        try {
            switch (state) {
                case INIT:
                    if (in.readableBytes() < 2) {
                        return;
                    }

                    final byte version = in.readByte();
                    if (version != 1) {
                        throw new DecoderException(
                            "unsupported subnegotiation version: " + version + " (expected: 1)");
                    }

                    out.add(new DefaultSocks5PrivateAuthResponse(
                        Socks5PrivateAuthStatus.valueOf(in.readByte())));
                    state = State.SUCCESS;
                    break;
                case SUCCESS:
                    int readableBytes = in.readableBytes();
                    if (readableBytes > 0) {
                        out.add(in.readRetainedSlice(readableBytes));
                    }
                    break;
                case FAILURE:
                    in.skipBytes(in.readableBytes());
                    break;
                default:
                    throw new Error("Unexpected response decoder state: " + state);
            }
        } 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/Socks5PrivateAuthResponseDecoder.java.
Where is decode() defined?
decode() is defined in codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/Socks5PrivateAuthResponseDecoder.java at line 71.
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