Home / Class/ DefaultSocks5CommandRequest Class — netty Architecture

DefaultSocks5CommandRequest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  2b361ef3_2470_46a0_14c7_5152a29224a6["DefaultSocks5CommandRequest"]
  5b9cd888_bd6d_f2b4_b759_c93871ccb256["DefaultSocks5CommandRequest.java"]
  2b361ef3_2470_46a0_14c7_5152a29224a6 -->|defined in| 5b9cd888_bd6d_f2b4_b759_c93871ccb256
  185f967c_c2cc_1c0e_a312_00f501bd236e["DefaultSocks5CommandRequest()"]
  2b361ef3_2470_46a0_14c7_5152a29224a6 -->|method| 185f967c_c2cc_1c0e_a312_00f501bd236e
  3462161a_febd_89de_82f7_080011dcb1ee["Socks5CommandType()"]
  2b361ef3_2470_46a0_14c7_5152a29224a6 -->|method| 3462161a_febd_89de_82f7_080011dcb1ee
  3459d74f_7db4_fe21_9cfa_0a5ebde8f626["Socks5AddressType()"]
  2b361ef3_2470_46a0_14c7_5152a29224a6 -->|method| 3459d74f_7db4_fe21_9cfa_0a5ebde8f626
  6bcbb37e_a4bc_fb23_ad4e_aaa91543ee36["String()"]
  2b361ef3_2470_46a0_14c7_5152a29224a6 -->|method| 6bcbb37e_a4bc_fb23_ad4e_aaa91543ee36
  ee79faff_0d3d_eb37_6e44_ebc0ab604cbe["dstPort()"]
  2b361ef3_2470_46a0_14c7_5152a29224a6 -->|method| ee79faff_0d3d_eb37_6e44_ebc0ab604cbe

Relationship Graph

Source Code

codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/DefaultSocks5CommandRequest.java lines 28–110

public final class DefaultSocks5CommandRequest extends AbstractSocks5Message implements Socks5CommandRequest {

    private final Socks5CommandType type;
    private final Socks5AddressType dstAddrType;
    private final String dstAddr;
    private final int dstPort;

    public DefaultSocks5CommandRequest(
            Socks5CommandType type, Socks5AddressType dstAddrType, String dstAddr, int dstPort) {

        this.type = ObjectUtil.checkNotNull(type, "type");
        ObjectUtil.checkNotNull(dstAddrType, "dstAddrType");
        ObjectUtil.checkNotNull(dstAddr, "dstAddr");

        if (dstAddrType == Socks5AddressType.IPv4) {
            if (!NetUtil.isValidIpV4Address(dstAddr)) {
                throw new IllegalArgumentException("dstAddr: " + dstAddr + " (expected: a valid IPv4 address)");
            }
        } else if (dstAddrType == Socks5AddressType.DOMAIN) {
            dstAddr = IDN.toASCII(dstAddr);
            if (dstAddr.length() > 255) {
                throw new IllegalArgumentException("dstAddr: " + dstAddr + " (expected: less than 256 chars)");
            }
        } else if (dstAddrType == Socks5AddressType.IPv6) {
            if (!NetUtil.isValidIpV6Address(dstAddr)) {
                throw new IllegalArgumentException("dstAddr: " + dstAddr + " (expected: a valid IPv6 address");
            }
        }

        if (dstPort < 0 || dstPort > 65535) {
            throw new IllegalArgumentException("dstPort: " + dstPort + " (expected: 0~65535)");
        }

        this.dstAddrType = dstAddrType;
        this.dstAddr = dstAddr;
        this.dstPort = dstPort;
    }

    @Override
    public Socks5CommandType type() {
        return type;
    }

    @Override
    public Socks5AddressType dstAddrType() {
        return dstAddrType;
    }

    @Override
    public String dstAddr() {
        return dstAddr;
    }

    @Override
    public int dstPort() {
        return dstPort;
    }

    @Override
    public String toString() {
        StringBuilder buf = new StringBuilder(128);
        buf.append(StringUtil.simpleClassName(this));

        DecoderResult decoderResult = decoderResult();
        if (!decoderResult.isSuccess()) {
            buf.append("(decoderResult: ");
            buf.append(decoderResult);
            buf.append(", type: ");
        } else {
            buf.append("(type: ");
        }
        buf.append(type());
        buf.append(", dstAddrType: ");
        buf.append(dstAddrType());
        buf.append(", dstAddr: ");
        buf.append(dstAddr());
        buf.append(", dstPort: ");
        buf.append(dstPort());
        buf.append(')');

        return buf.toString();

Frequently Asked Questions

What is the DefaultSocks5CommandRequest class?
DefaultSocks5CommandRequest is a class in the netty codebase, defined in codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/DefaultSocks5CommandRequest.java.
Where is DefaultSocks5CommandRequest defined?
DefaultSocks5CommandRequest is defined in codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/DefaultSocks5CommandRequest.java at line 28.

Analyze Your Own Codebase

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

Try Supermodel Free