Home / Class/ Socks5ProxyHandler Class — netty Architecture

Socks5ProxyHandler Class — netty Architecture

Architecture documentation for the Socks5ProxyHandler class in Socks5ProxyHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  926eac21_d91e_6616_387b_ad05731b49a5["Socks5ProxyHandler"]
  c77cd70c_53ea_5933_4b03_917f4c1b90fc["Socks5ProxyHandler.java"]
  926eac21_d91e_6616_387b_ad05731b49a5 -->|defined in| c77cd70c_53ea_5933_4b03_917f4c1b90fc
  09714cc4_c141_5510_0390_f1dfbf1b811c["Socks5ProxyHandler()"]
  926eac21_d91e_6616_387b_ad05731b49a5 -->|method| 09714cc4_c141_5510_0390_f1dfbf1b811c
  c883360d_2cff_cc0c_f7cf_47ef6e5cc995["String()"]
  926eac21_d91e_6616_387b_ad05731b49a5 -->|method| c883360d_2cff_cc0c_f7cf_47ef6e5cc995
  4b63375a_30ff_ccca_30c4_6c7cbc3b9934["addCodec()"]
  926eac21_d91e_6616_387b_ad05731b49a5 -->|method| 4b63375a_30ff_ccca_30c4_6c7cbc3b9934
  ca5cf25b_e30e_62c8_b663_94265f37e88f["removeEncoder()"]
  926eac21_d91e_6616_387b_ad05731b49a5 -->|method| ca5cf25b_e30e_62c8_b663_94265f37e88f
  cb7ea250_bd9f_1e29_de85_b84d0a68738f["removeDecoder()"]
  926eac21_d91e_6616_387b_ad05731b49a5 -->|method| cb7ea250_bd9f_1e29_de85_b84d0a68738f
  baa14519_c32b_e086_335e_efbd66c594fa["Object()"]
  926eac21_d91e_6616_387b_ad05731b49a5 -->|method| baa14519_c32b_e086_335e_efbd66c594fa
  c0259981_07c5_5878_5f82_f3d8674742ec["handleResponse()"]
  926eac21_d91e_6616_387b_ad05731b49a5 -->|method| c0259981_07c5_5878_5f82_f3d8674742ec
  ad1c0198_a0f0_cc86_a6cc_95e83904bcd6["Socks5AuthMethod()"]
  926eac21_d91e_6616_387b_ad05731b49a5 -->|method| ad1c0198_a0f0_cc86_a6cc_95e83904bcd6
  ab6a5019_0df9_7148_fbe1_714574730408["sendConnectCommand()"]
  926eac21_d91e_6616_387b_ad05731b49a5 -->|method| ab6a5019_0df9_7148_fbe1_714574730408

Relationship Graph

Source Code

handler-proxy/src/main/java/io/netty/handler/proxy/Socks5ProxyHandler.java lines 53–278

public final class Socks5ProxyHandler extends ProxyHandler {

    private static final String PROTOCOL = "socks5";
    private static final String AUTH_PASSWORD = "password";
    private static final String AUTH_PRIVATE = "private";

    private static final byte NO_PRIVATE_AUTH_METHOD =
        Socks5AuthMethod.NO_AUTH.byteValue();

    private static final Socks5InitialRequest INIT_REQUEST_NO_AUTH =
            new DefaultSocks5InitialRequest(Collections.singletonList(Socks5AuthMethod.NO_AUTH));

    private static final Socks5InitialRequest INIT_REQUEST_PASSWORD =
            new DefaultSocks5InitialRequest(Arrays.asList(Socks5AuthMethod.NO_AUTH, Socks5AuthMethod.PASSWORD));

    private final String username;
    private final String password;
    private final byte privateAuthMethod;
    private final byte[] privateToken;
    private final Socks5ClientEncoder clientEncoder;

    private String decoderName;
    private String encoderName;

    public Socks5ProxyHandler(SocketAddress proxyAddress) {
        this(proxyAddress, null, null);
    }

    public Socks5ProxyHandler(SocketAddress proxyAddress, String username, String password) {
        super(proxyAddress);
        if (username != null && username.isEmpty()) {
            username = null;
        }
        if (password != null && password.isEmpty()) {
            password = null;
        }
        this.username = username;
        this.password = password;
        this.privateToken = null;
        this.privateAuthMethod = NO_PRIVATE_AUTH_METHOD; // No private authentication method specified
        this.clientEncoder = Socks5ClientEncoder.DEFAULT;
    }

    /**
     * Creates a new SOCKS5 proxy handler with a custom private authentication method.
     *
     * @param proxyAddress     The address of the SOCKS5 proxy server
     * @param privateAuthMethod The private authentication method code (must be in range 0x80-0xFE)
     * @param privateToken     The token to use for private authentication
     * @param customEncoder    The custom encoder to use for encoding SOCKS5 messages, if {@code null} the
     *                         {@link Socks5ClientEncoder#DEFAULT} will be used
     * @throws IllegalArgumentException If privateAuthMethod is not in the valid range
     */
    public Socks5ProxyHandler(SocketAddress proxyAddress, byte privateAuthMethod, byte[] privateToken,
                              Socks5ClientEncoder customEncoder) {
        super(proxyAddress);
        if (!Socks5AuthMethod.isPrivateMethod(privateAuthMethod)) {
            throw new IllegalArgumentException(
                    "privateAuthMethod: " + (privateAuthMethod & 0xFF) + " (expected: 0x80-0xFE)");
        }
        this.username = this.password = null;
        this.privateToken = privateToken;
        this.privateAuthMethod = privateAuthMethod;
        this.clientEncoder = customEncoder != null ? customEncoder : Socks5ClientEncoder.DEFAULT;
    }

    @Override
    public String protocol() {
        return PROTOCOL;
    }

    @Override
    public String authScheme() {
        Socks5AuthMethod authMethod = socksAuthMethod();
        if (Socks5AuthMethod.isPrivateMethod(authMethod.byteValue())) {
            return AUTH_PRIVATE;
        }
        if (authMethod == Socks5AuthMethod.PASSWORD) {
            return AUTH_PASSWORD;
        }
        return AUTH_NONE;

Frequently Asked Questions

What is the Socks5ProxyHandler class?
Socks5ProxyHandler is a class in the netty codebase, defined in handler-proxy/src/main/java/io/netty/handler/proxy/Socks5ProxyHandler.java.
Where is Socks5ProxyHandler defined?
Socks5ProxyHandler is defined in handler-proxy/src/main/java/io/netty/handler/proxy/Socks5ProxyHandler.java at line 53.

Analyze Your Own Codebase

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

Try Supermodel Free