decode() — netty Function Reference
Architecture documentation for the decode() function in SocksCmdResponseDecoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 7f156ba5_0a17_3c8d_259d_a318222f13f3["decode()"] fc217319_ea26_738e_cb17_c96d845bfede["SocksCmdResponseDecoder"] 7f156ba5_0a17_3c8d_259d_a318222f13f3 -->|defined in| fc217319_ea26_738e_cb17_c96d845bfede style 7f156ba5_0a17_3c8d_259d_a318222f13f3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdResponseDecoder.java lines 42–96
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out) throws Exception {
switch (state()) {
case CHECK_PROTOCOL_VERSION: {
if (byteBuf.readByte() != SocksProtocolVersion.SOCKS5.byteValue()) {
out.add(SocksCommonUtils.UNKNOWN_SOCKS_RESPONSE);
break;
}
checkpoint(State.READ_CMD_HEADER);
}
case READ_CMD_HEADER: {
cmdStatus = SocksCmdStatus.valueOf(byteBuf.readByte());
byteBuf.skipBytes(1); // reserved
addressType = SocksAddressType.valueOf(byteBuf.readByte());
checkpoint(State.READ_CMD_ADDRESS);
}
case READ_CMD_ADDRESS: {
switch (addressType) {
case IPv4: {
String host = NetUtil.intToIpAddress(ByteBufUtil.readIntBE(byteBuf));
int port = ByteBufUtil.readUnsignedShortBE(byteBuf);
out.add(new SocksCmdResponse(cmdStatus, addressType, host, port));
break;
}
case DOMAIN: {
int fieldLength = byteBuf.readByte();
String host = byteBuf.readString(fieldLength, CharsetUtil.US_ASCII);
int port = ByteBufUtil.readUnsignedShortBE(byteBuf);
out.add(new SocksCmdResponse(cmdStatus, addressType, host, port));
break;
}
case IPv6: {
byte[] bytes = new byte[16];
byteBuf.readBytes(bytes);
String host = SocksCommonUtils.ipv6toStr(bytes);
int port = ByteBufUtil.readUnsignedShortBE(byteBuf);
out.add(new SocksCmdResponse(cmdStatus, addressType, host, port));
break;
}
case UNKNOWN: {
out.add(SocksCommonUtils.UNKNOWN_SOCKS_RESPONSE);
break;
}
default: {
throw new Error("Unexpected address type: " + addressType);
}
}
break;
}
default: {
throw new Error("Unexpected response decoder type: " + state());
}
}
ctx.pipeline().remove(this);
}
Domain
Subdomains
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/socks/SocksCmdResponseDecoder.java.
Where is decode() defined?
decode() is defined in codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdResponseDecoder.java at line 42.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free