SocksCmdResponse Class — netty Architecture
Architecture documentation for the SocksCmdResponse class in SocksCmdResponse.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD dacdee2c_8b75_89f2_e924_597e9dde5cd3["SocksCmdResponse"] a7e6dc1b_12ff_f786_af3a_b734486a2b92["SocksCmdResponse.java"] dacdee2c_8b75_89f2_e924_597e9dde5cd3 -->|defined in| a7e6dc1b_12ff_f786_af3a_b734486a2b92 528cefb5_d2ea_c551_1161_ee05ad9a0e7b["SocksCmdResponse()"] dacdee2c_8b75_89f2_e924_597e9dde5cd3 -->|method| 528cefb5_d2ea_c551_1161_ee05ad9a0e7b 83be68de_2c9f_a351_6737_ad0a7c1a99ae["SocksCmdStatus()"] dacdee2c_8b75_89f2_e924_597e9dde5cd3 -->|method| 83be68de_2c9f_a351_6737_ad0a7c1a99ae 8e58f8f9_db67_d3dd_1bc4_945cd60e7b13["SocksAddressType()"] dacdee2c_8b75_89f2_e924_597e9dde5cd3 -->|method| 8e58f8f9_db67_d3dd_1bc4_945cd60e7b13 e367d412_de69_ab33_5f05_e77da2b5292c["String()"] dacdee2c_8b75_89f2_e924_597e9dde5cd3 -->|method| e367d412_de69_ab33_5f05_e77da2b5292c 3d2f94c7_fd9c_d25a_98fe_07e062169b17["port()"] dacdee2c_8b75_89f2_e924_597e9dde5cd3 -->|method| 3d2f94c7_fd9c_d25a_98fe_07e062169b17 d126541f_b730_97bb_0850_1946cb3b4553["encodeAsByteBuf()"] dacdee2c_8b75_89f2_e924_597e9dde5cd3 -->|method| d126541f_b730_97bb_0850_1946cb3b4553
Relationship Graph
Source Code
codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdResponse.java lines 32–174
public final class SocksCmdResponse extends SocksResponse {
private final SocksCmdStatus cmdStatus;
private final SocksAddressType addressType;
private final String host;
private final int port;
// All arrays are initialized on construction time to 0/false/null remove array Initialization
private static final byte[] DOMAIN_ZEROED = {0x00};
private static final byte[] IPv4_HOSTNAME_ZEROED = {0x00, 0x00, 0x00, 0x00};
private static final byte[] IPv6_HOSTNAME_ZEROED = {0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00};
public SocksCmdResponse(SocksCmdStatus cmdStatus, SocksAddressType addressType) {
this(cmdStatus, addressType, null, 0);
}
/**
* Constructs new response and includes provided host and port as part of it.
*
* @param cmdStatus status of the response
* @param addressType type of host parameter
* @param host host (BND.ADDR field) is address that server used when connecting to the target host.
* When null a value of 4/8 0x00 octets will be used for IPv4/IPv6 and a single 0x00 byte will be
* used for domain addressType. Value is converted to ASCII using {@link IDN#toASCII(String)}.
* @param port port (BND.PORT field) that the server assigned to connect to the target host
* @throws NullPointerException in case cmdStatus or addressType are missing
* @throws IllegalArgumentException in case host or port cannot be validated
* @see IDN#toASCII(String)
*/
public SocksCmdResponse(SocksCmdStatus cmdStatus, SocksAddressType addressType, String host, int port) {
super(SocksResponseType.CMD);
ObjectUtil.checkNotNull(cmdStatus, "cmdStatus");
ObjectUtil.checkNotNull(addressType, "addressType");
if (host != null) {
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 > 65535) {
throw new IllegalArgumentException(port + " is not in bounds 0 <= x <= 65535");
}
this.cmdStatus = cmdStatus;
this.addressType = addressType;
this.host = host;
this.port = port;
}
/**
* Returns the {@link SocksCmdStatus} of this {@link SocksCmdResponse}
*
* @return The {@link SocksCmdStatus} of this {@link SocksCmdResponse}
*/
public SocksCmdStatus cmdStatus() {
return cmdStatus;
}
/**
* Returns the {@link SocksAddressType} of this {@link SocksCmdResponse}
*
* @return The {@link SocksAddressType} of this {@link SocksCmdResponse}
Source
Frequently Asked Questions
What is the SocksCmdResponse class?
SocksCmdResponse is a class in the netty codebase, defined in codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdResponse.java.
Where is SocksCmdResponse defined?
SocksCmdResponse is defined in codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdResponse.java at line 32.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free