Package io.netty.handler.codec.socks
Class SocksCmdResponse
- java.lang.Object
-
- io.netty.handler.codec.socks.SocksMessage
-
- io.netty.handler.codec.socks.SocksResponse
-
- io.netty.handler.codec.socks.SocksCmdResponse
-
public final class SocksCmdResponse extends SocksResponse
A socks cmd response.- See Also:
SocksCmdRequest
,SocksCmdResponseDecoder
-
-
Constructor Summary
Constructors Constructor Description SocksCmdResponse(SocksCmdStatus cmdStatus, SocksAddressType addressType)
SocksCmdResponse(SocksCmdStatus cmdStatus, SocksAddressType addressType, java.lang.String host, int port)
Constructs new response and includes provided host and port as part of it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SocksAddressType
addressType()
Returns theSocksAddressType
of thisSocksCmdResponse
SocksCmdStatus
cmdStatus()
Returns theSocksCmdStatus
of thisSocksCmdResponse
void
encodeAsByteBuf(ByteBuf byteBuf)
java.lang.String
host()
Returns host that is used as a parameter inSocksCmdType
.int
port()
Returns port that is used as a parameter inSocksCmdType
.-
Methods inherited from class io.netty.handler.codec.socks.SocksResponse
responseType
-
Methods inherited from class io.netty.handler.codec.socks.SocksMessage
protocolVersion, type
-
-
-
-
Constructor Detail
-
SocksCmdResponse
public SocksCmdResponse(SocksCmdStatus cmdStatus, SocksAddressType addressType)
-
SocksCmdResponse
public SocksCmdResponse(SocksCmdStatus cmdStatus, SocksAddressType addressType, java.lang.String host, int port)
Constructs new response and includes provided host and port as part of it.- Parameters:
cmdStatus
- status of the responseaddressType
- type of host parameterhost
- 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 usingIDN.toASCII(String)
.port
- port (BND.PORT field) that the server assigned to connect to the target host- Throws:
java.lang.NullPointerException
- in case cmdStatus or addressType are missingjava.lang.IllegalArgumentException
- in case host or port cannot be validated- See Also:
IDN.toASCII(String)
-
-
Method Detail
-
cmdStatus
public SocksCmdStatus cmdStatus()
Returns theSocksCmdStatus
of thisSocksCmdResponse
- Returns:
- The
SocksCmdStatus
of thisSocksCmdResponse
-
addressType
public SocksAddressType addressType()
Returns theSocksAddressType
of thisSocksCmdResponse
- Returns:
- The
SocksAddressType
of thisSocksCmdResponse
-
host
public java.lang.String host()
Returns host that is used as a parameter inSocksCmdType
. Host (BND.ADDR field in response) is address that server used when connecting to the target host. This is typically different from address which client uses to connect to the SOCKS server.- Returns:
- host that is used as a parameter in
SocksCmdType
or null when there was no host specified during response construction
-
port
public int port()
Returns port that is used as a parameter inSocksCmdType
. Port (BND.PORT field in response) is port that the server assigned to connect to the target host.- Returns:
- port that is used as a parameter in
SocksCmdType
-
encodeAsByteBuf
public void encodeAsByteBuf(ByteBuf byteBuf)
- Specified by:
encodeAsByteBuf
in classSocksMessage
-
-