Socks5PasswordAuthRequestDecoder Class — netty Architecture
Architecture documentation for the Socks5PasswordAuthRequestDecoder class in Socks5PasswordAuthRequestDecoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 21c2e1f6_8657_6435_51ab_f4e11ef47496["Socks5PasswordAuthRequestDecoder"] 91963337_0478_4427_c592_73f8ffe14510["Socks5PasswordAuthRequestDecoder.java"] 21c2e1f6_8657_6435_51ab_f4e11ef47496 -->|defined in| 91963337_0478_4427_c592_73f8ffe14510 1f8e5484_f42e_3313_b2c0_4c5c0c1f93d3["Socks5PasswordAuthRequestDecoder()"] 21c2e1f6_8657_6435_51ab_f4e11ef47496 -->|method| 1f8e5484_f42e_3313_b2c0_4c5c0c1f93d3 8981ae6c_c758_e5be_9bd7_dcf9c6ceab28["decode()"] 21c2e1f6_8657_6435_51ab_f4e11ef47496 -->|method| 8981ae6c_c758_e5be_9bd7_dcf9c6ceab28 f3fe86a1_f0ab_270a_0b10_e07d0e101b14["fail()"] 21c2e1f6_8657_6435_51ab_f4e11ef47496 -->|method| f3fe86a1_f0ab_270a_0b10_e07d0e101b14
Relationship Graph
Source Code
codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/Socks5PasswordAuthRequestDecoder.java lines 36–99
public class Socks5PasswordAuthRequestDecoder extends ReplayingDecoder<State> {
@UnstableApi
public enum State {
INIT,
SUCCESS,
FAILURE
}
public Socks5PasswordAuthRequestDecoder() {
super(State.INIT);
}
@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);
}
}
private void fail(List<Object> out, Exception cause) {
if (!(cause instanceof DecoderException)) {
cause = new DecoderException(cause);
}
checkpoint(State.FAILURE);
Socks5Message m = new DefaultSocks5PasswordAuthRequest("", "");
m.setDecoderResult(DecoderResult.failure(cause));
out.add(m);
}
}
Defined In
Source
Frequently Asked Questions
What is the Socks5PasswordAuthRequestDecoder class?
Socks5PasswordAuthRequestDecoder is a class in the netty codebase, defined in codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/Socks5PasswordAuthRequestDecoder.java.
Where is Socks5PasswordAuthRequestDecoder defined?
Socks5PasswordAuthRequestDecoder is defined in codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/Socks5PasswordAuthRequestDecoder.java at line 36.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free