Home / Class/ DefaultSocks5CommandResponse Class — netty Architecture

DefaultSocks5CommandResponse Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  3ff113a6_09bb_17b9_4ca8_ad5a7f34f109["DefaultSocks5CommandResponse"]
  6a0fc935_4fe9_3c88_6497_47d0aafa01c6["DefaultSocks5CommandResponse.java"]
  3ff113a6_09bb_17b9_4ca8_ad5a7f34f109 -->|defined in| 6a0fc935_4fe9_3c88_6497_47d0aafa01c6
  e78bcd7a_915b_e557_5662_e78cb76cdc3f["DefaultSocks5CommandResponse()"]
  3ff113a6_09bb_17b9_4ca8_ad5a7f34f109 -->|method| e78bcd7a_915b_e557_5662_e78cb76cdc3f
  cff5beb4_cf6e_2746_316b_f0638dab6279["Socks5CommandStatus()"]
  3ff113a6_09bb_17b9_4ca8_ad5a7f34f109 -->|method| cff5beb4_cf6e_2746_316b_f0638dab6279
  20fed8e6_0eb9_3583_fc15_8b3976de7008["Socks5AddressType()"]
  3ff113a6_09bb_17b9_4ca8_ad5a7f34f109 -->|method| 20fed8e6_0eb9_3583_fc15_8b3976de7008
  e9b10d16_c6b6_7c38_1172_dd47fb6416d3["String()"]
  3ff113a6_09bb_17b9_4ca8_ad5a7f34f109 -->|method| e9b10d16_c6b6_7c38_1172_dd47fb6416d3
  ac4a7e30_4ed7_ba71_d7f5_c458e603c9ef["bndPort()"]
  3ff113a6_09bb_17b9_4ca8_ad5a7f34f109 -->|method| ac4a7e30_4ed7_ba71_d7f5_c458e603c9ef

Relationship Graph

Source Code

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

public final class DefaultSocks5CommandResponse extends AbstractSocks5Message implements Socks5CommandResponse {

    private final Socks5CommandStatus status;
    private final Socks5AddressType bndAddrType;
    private final String bndAddr;
    private final int bndPort;

    public DefaultSocks5CommandResponse(Socks5CommandStatus status, Socks5AddressType bndAddrType) {
        this(status, bndAddrType, null, 0);
    }

    public DefaultSocks5CommandResponse(
            Socks5CommandStatus status, Socks5AddressType bndAddrType, String bndAddr, int bndPort) {

        ObjectUtil.checkNotNull(status, "status");
        ObjectUtil.checkNotNull(bndAddrType, "bndAddrType");

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

        if (bndPort < 0 || bndPort > 65535) {
            throw new IllegalArgumentException("bndPort: " + bndPort + " (expected: 0~65535)");
        }
        this.status = status;
        this.bndAddrType = bndAddrType;
        this.bndAddr = bndAddr;
        this.bndPort = bndPort;
    }

    @Override
    public Socks5CommandStatus status() {
        return status;
    }

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

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

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

    @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(", status: ");
        } else {
            buf.append("(status: ");
        }
        buf.append(status());
        buf.append(", bndAddrType: ");
        buf.append(bndAddrType());
        buf.append(", bndAddr: ");
        buf.append(bndAddr());

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free