Home / Class/ Socks4TerminalHandler Class — netty Architecture

Socks4TerminalHandler Class — netty Architecture

Architecture documentation for the Socks4TerminalHandler class in Socks4ProxyServer.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  d0b975d2_7f64_c584_7cb3_d21e4c48f4c0["Socks4TerminalHandler"]
  35a44061_021b_aedc_780f_0592677af7d8["Socks4ProxyServer.java"]
  d0b975d2_7f64_c584_7cb3_d21e4c48f4c0 -->|defined in| 35a44061_021b_aedc_780f_0592677af7d8
  75bc00ad_fcbe_9a76_c277_9f5f07f68782["handleProxyProtocol()"]
  d0b975d2_7f64_c584_7cb3_d21e4c48f4c0 -->|method| 75bc00ad_fcbe_9a76_c277_9f5f07f68782

Relationship Graph

Source Code

handler-proxy/src/test/java/io/netty/handler/proxy/Socks4ProxyServer.java lines 115–144

    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);

            Socks4CommandResponse res;
            boolean sendGreeting = false;
            if (!authzSuccess) {
                res = new DefaultSocks4CommandResponse(Socks4CommandStatus.IDENTD_AUTH_FAILURE);
            } else if (!req.dstAddr().equals(destination.getHostString()) ||
                       req.dstPort() != destination.getPort()) {
                res = new DefaultSocks4CommandResponse(Socks4CommandStatus.REJECTED_OR_FAILED);
            } else {
                res = new DefaultSocks4CommandResponse(Socks4CommandStatus.SUCCESS);
                sendGreeting = true;
            }

            ctx.write(res);

            ctx.pipeline().remove(Socks4ServerDecoder.class);
            ctx.pipeline().remove(Socks4ServerEncoder.class);

            if (sendGreeting) {
                ctx.write(Unpooled.copiedBuffer("0\n", CharsetUtil.US_ASCII));
            }

            return true;
        }
    }

Frequently Asked Questions

What is the Socks4TerminalHandler class?
Socks4TerminalHandler is a class in the netty codebase, defined in handler-proxy/src/test/java/io/netty/handler/proxy/Socks4ProxyServer.java.
Where is Socks4TerminalHandler defined?
Socks4TerminalHandler is defined in handler-proxy/src/test/java/io/netty/handler/proxy/Socks4ProxyServer.java at line 115.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free