Home / Function/ decode() — netty Function Reference

decode() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  231f97ec_4a82_58a7_d4d8_581c91154ac2["decode()"]
  5a68ac37_7c65_a197_e5fc_ea06651de05e["Socks4ClientDecoder"]
  231f97ec_4a82_58a7_d4d8_581c91154ac2 -->|defined in| 5a68ac37_7c65_a197_e5fc_ea06651de05e
  5f51e102_8380_acc7_1864_73c607712375["fail()"]
  231f97ec_4a82_58a7_d4d8_581c91154ac2 -->|calls| 5f51e102_8380_acc7_1864_73c607712375
  style 231f97ec_4a82_58a7_d4d8_581c91154ac2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-socks/src/main/java/io/netty/handler/codec/socksx/v4/Socks4ClientDecoder.java lines 50–82

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        try {
            switch (state()) {
            case START: {
                final int version = in.readUnsignedByte();
                if (version != 0) {
                    throw new DecoderException("unsupported reply version: " + version + " (expected: 0)");
                }

                final Socks4CommandStatus status = Socks4CommandStatus.valueOf(in.readByte());
                final int dstPort = ByteBufUtil.readUnsignedShortBE(in);
                final String dstAddr = NetUtil.intToIpAddress(ByteBufUtil.readIntBE(in));

                out.add(new DefaultSocks4CommandResponse(status, dstAddr, dstPort));
                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/v4/Socks4ClientDecoder.java.
Where is decode() defined?
decode() is defined in codec-socks/src/main/java/io/netty/handler/codec/socksx/v4/Socks4ClientDecoder.java at line 50.
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