Home / Class/ SocksCmdRequest Class — netty Architecture

SocksCmdRequest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  4c77f215_7f5b_19c4_455f_987dda36774c["SocksCmdRequest"]
  b9ac29f4_eede_abea_a320_4bc68d76d681["SocksCmdRequest.java"]
  4c77f215_7f5b_19c4_455f_987dda36774c -->|defined in| b9ac29f4_eede_abea_a320_4bc68d76d681
  2330fb6f_df29_2258_5359_27aebc146558["SocksCmdRequest()"]
  4c77f215_7f5b_19c4_455f_987dda36774c -->|method| 2330fb6f_df29_2258_5359_27aebc146558
  63308a72_f40d_56dd_4c69_663d83d51837["SocksCmdType()"]
  4c77f215_7f5b_19c4_455f_987dda36774c -->|method| 63308a72_f40d_56dd_4c69_663d83d51837
  3089487d_9049_9051_95e9_6c5125d91b58["SocksAddressType()"]
  4c77f215_7f5b_19c4_455f_987dda36774c -->|method| 3089487d_9049_9051_95e9_6c5125d91b58
  5cc4c524_8cce_346c_201a_4cda63216d75["String()"]
  4c77f215_7f5b_19c4_455f_987dda36774c -->|method| 5cc4c524_8cce_346c_201a_4cda63216d75
  4fa97a40_dc28_bd7c_9b0a_9c38319bd9fd["port()"]
  4c77f215_7f5b_19c4_455f_987dda36774c -->|method| 4fa97a40_dc28_bd7c_9b0a_9c38319bd9fd
  1866831d_58ce_9d5c_e5ba_2ef98136037c["encodeAsByteBuf()"]
  4c77f215_7f5b_19c4_455f_987dda36774c -->|method| 1866831d_58ce_9d5c_e5ba_2ef98136037c

Relationship Graph

Source Code

codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdRequest.java lines 32–137

public final class SocksCmdRequest extends SocksRequest {
    private final SocksCmdType cmdType;
    private final SocksAddressType addressType;
    private final String host;
    private final int port;

    public SocksCmdRequest(SocksCmdType cmdType, SocksAddressType addressType, String host, int port) {
        super(SocksRequestType.CMD);
        ObjectUtil.checkNotNull(cmdType, "cmdType");
        ObjectUtil.checkNotNull(addressType, "addressType");
        ObjectUtil.checkNotNull(host, "host");

        switch (addressType) {
            case IPv4:
                if (!NetUtil.isValidIpV4Address(host)) {
                    throw new IllegalArgumentException(host + " is not a valid IPv4 address");
                }
                break;
            case DOMAIN:
                String asciiHost = IDN.toASCII(host);
                if (asciiHost.length() > 255) {
                    throw new IllegalArgumentException(host + " IDN: " + asciiHost + " exceeds 255 char limit");
                }
                host = asciiHost;
                break;
            case IPv6:
                if (!NetUtil.isValidIpV6Address(host)) {
                    throw new IllegalArgumentException(host + " is not a valid IPv6 address");
                }
                break;
            case UNKNOWN:
                break;
        }
        if (port <= 0 || port >= 65536) {
            throw new IllegalArgumentException(port + " is not in bounds 0 < x < 65536");
        }
        this.cmdType = cmdType;
        this.addressType = addressType;
        this.host = host;
        this.port = port;
    }

    /**
     * Returns the {@link SocksCmdType} of this {@link SocksCmdRequest}
     *
     * @return The {@link SocksCmdType} of this {@link SocksCmdRequest}
     */
    public SocksCmdType cmdType() {
        return cmdType;
    }

    /**
     * Returns the {@link SocksAddressType} of this {@link SocksCmdRequest}
     *
     * @return The {@link SocksAddressType} of this {@link SocksCmdRequest}
     */
    public SocksAddressType addressType() {
        return addressType;
    }

    /**
     * Returns host that is used as a parameter in {@link SocksCmdType}
     *
     * @return host that is used as a parameter in {@link SocksCmdType}
     */
    public String host() {
        return addressType == SocksAddressType.DOMAIN ? IDN.toUnicode(host) : host;
    }

    /**
     * Returns port that is used as a parameter in {@link SocksCmdType}
     *
     * @return port that is used as a parameter in {@link SocksCmdType}
     */
    public int port() {
        return port;
    }

    @Override
    public void encodeAsByteBuf(ByteBuf byteBuf) {
        byteBuf.writeByte(protocolVersion().byteValue());

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free