decode() — netty Function Reference
Architecture documentation for the decode() function in Socks4ServerDecoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 1df22ec8_3801_784f_704d_e3f44d44002d["decode()"] f3549c11_8ef1_fde3_7585_cf97abbfa145["Socks4ServerDecoder"] 1df22ec8_3801_784f_704d_e3f44d44002d -->|defined in| f3549c11_8ef1_fde3_7585_cf97abbfa145 08d49857_8bf5_9ac9_75e1_2f034739ebb2["fail()"] 1df22ec8_3801_784f_704d_e3f44d44002d -->|calls| 08d49857_8bf5_9ac9_75e1_2f034739ebb2 style 1df22ec8_3801_784f_704d_e3f44d44002d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-socks/src/main/java/io/netty/handler/codec/socksx/v4/Socks4ServerDecoder.java lines 61–103
@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 != SocksVersion.SOCKS4a.byteValue()) {
throw new DecoderException("unsupported protocol version: " + version);
}
type = Socks4CommandType.valueOf(in.readByte());
dstPort = ByteBufUtil.readUnsignedShortBE(in);
dstAddr = NetUtil.intToIpAddress(ByteBufUtil.readIntBE(in));
checkpoint(State.READ_USERID);
}
case READ_USERID: {
userId = readString("userid", in);
checkpoint(State.READ_DOMAIN);
}
case READ_DOMAIN: {
// Check for Socks4a protocol marker 0.0.0.x
if (!"0.0.0.0".equals(dstAddr) && dstAddr.startsWith("0.0.0.")) {
dstAddr = readString("dstAddr", in);
}
out.add(new DefaultSocks4CommandRequest(type, dstAddr, dstPort, userId));
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
Source
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/Socks4ServerDecoder.java.
Where is decode() defined?
decode() is defined in codec-socks/src/main/java/io/netty/handler/codec/socksx/v4/Socks4ServerDecoder.java at line 61.
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