Socks4ProxyServer Class — netty Architecture
Architecture documentation for the Socks4ProxyServer class in Socks4ProxyServer.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 243d5be0_3bd5_5155_e16b_6cdcbf7860fa["Socks4ProxyServer"] 35a44061_021b_aedc_780f_0592677af7d8["Socks4ProxyServer.java"] 243d5be0_3bd5_5155_e16b_6cdcbf7860fa -->|defined in| 35a44061_021b_aedc_780f_0592677af7d8 fdaa51bd_d1d7_ff36_09b3_1490d74cd2f5["Socks4ProxyServer()"] 243d5be0_3bd5_5155_e16b_6cdcbf7860fa -->|method| fdaa51bd_d1d7_ff36_09b3_1490d74cd2f5 0b27ab8c_fb72_e437_82ec_6fd6f7d91a06["configure()"] 243d5be0_3bd5_5155_e16b_6cdcbf7860fa -->|method| 0b27ab8c_fb72_e437_82ec_6fd6f7d91a06 90dc76b7_3a78_6df5_59e1_b00ba7bca997["authenticate()"] 243d5be0_3bd5_5155_e16b_6cdcbf7860fa -->|method| 90dc76b7_3a78_6df5_59e1_b00ba7bca997
Relationship Graph
Source Code
handler-proxy/src/test/java/io/netty/handler/proxy/Socks4ProxyServer.java lines 39–145
final class Socks4ProxyServer extends ProxyServer {
Socks4ProxyServer(boolean useSsl, TestMode testMode, InetSocketAddress destination) {
super(useSsl, testMode, destination);
}
Socks4ProxyServer(boolean useSsl, TestMode testMode, InetSocketAddress destination, String username) {
super(useSsl, testMode, destination, username, null);
}
@Override
protected void configure(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
switch (testMode) {
case INTERMEDIARY:
p.addLast(new Socks4ServerDecoder());
p.addLast(Socks4ServerEncoder.INSTANCE);
p.addLast(new Socks4IntermediaryHandler());
break;
case TERMINAL:
p.addLast(new Socks4ServerDecoder());
p.addLast(Socks4ServerEncoder.INSTANCE);
p.addLast(new Socks4TerminalHandler());
break;
case UNRESPONSIVE:
p.addLast(UnresponsiveHandler.INSTANCE);
break;
}
}
private boolean authenticate(ChannelHandlerContext ctx, Socks4CommandRequest req) {
assertEquals(Socks4CommandType.CONNECT, req.type());
if (testMode != TestMode.INTERMEDIARY) {
ctx.pipeline().addBefore(ctx.name(), "lineDecoder", new LineBasedFrameDecoder(64, false, true));
}
boolean authzSuccess;
if (username != null) {
authzSuccess = username.equals(req.userId());
} else {
authzSuccess = true;
}
return authzSuccess;
}
private final class Socks4IntermediaryHandler extends IntermediaryHandler {
private SocketAddress intermediaryDestination;
@Override
protected boolean handleProxyProtocol(ChannelHandlerContext ctx, Object msg) throws Exception {
Socks4CommandRequest req = (Socks4CommandRequest) msg;
Socks4CommandResponse res;
if (!authenticate(ctx, req)) {
res = new DefaultSocks4CommandResponse(Socks4CommandStatus.IDENTD_AUTH_FAILURE);
} else {
res = new DefaultSocks4CommandResponse(Socks4CommandStatus.SUCCESS);
intermediaryDestination = SocketUtils.socketAddress(req.dstAddr(), req.dstPort());
}
ctx.write(res);
ctx.pipeline().remove(Socks4ServerDecoder.class);
ctx.pipeline().remove(Socks4ServerEncoder.class);
return true;
}
@Override
protected SocketAddress intermediaryDestination() {
return intermediaryDestination;
}
}
private final class Socks4TerminalHandler extends TerminalHandler {
@Override
protected boolean handleProxyProtocol(ChannelHandlerContext ctx, Object msg) throws Exception {
Socks4CommandRequest req = (Socks4CommandRequest) msg;
boolean authzSuccess = authenticate(ctx, req);
Source
Frequently Asked Questions
What is the Socks4ProxyServer class?
Socks4ProxyServer is a class in the netty codebase, defined in handler-proxy/src/test/java/io/netty/handler/proxy/Socks4ProxyServer.java.
Where is Socks4ProxyServer defined?
Socks4ProxyServer is defined in handler-proxy/src/test/java/io/netty/handler/proxy/Socks4ProxyServer.java at line 39.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free