Package org.bluezoo.gumdrop.socks
Class SOCKSRequest
java.lang.Object
org.bluezoo.gumdrop.socks.SOCKSRequest
A parsed SOCKS connection request from a client.
Holds the protocol version, command, destination address (as an
InetAddress and/or hostname), destination port, and for
SOCKS4/4a the userid field.
For SOCKS4a and SOCKS5 domain-name requests, getHost()
returns the unresolved hostname and getAddress() returns
null until the server resolves the name.
Relevant specifications:
- SOCKS4 protocol: Request format (VER, CD, DSTPORT, DSTIP, USERID)
- SOCKS4a: Hostname appended after USERID when DSTIP=0.0.0.x (x≠0)
- RFC 1928: SOCKS Protocol Version 5
- RFC 1929: Username/Password Authentication for SOCKS V5
- RFC 1961: GSS-API Authentication for SOCKS V5
- Author:
- Chris Burdess
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSOCKSRequest(byte version, byte command, InetAddress address, String host, int port, String userid, String authenticatedUser) Creates a SOCKS request. -
Method Summary
Modifier and TypeMethodDescriptionReturns the resolved destination address, ornullif the request specified a hostname that has not yet been resolved.Returns the username authenticated during SOCKS5 authentication, ornullif no authentication was performed or for SOCKS4 requests.byteReturns the command byte.getHost()Returns the destination hostname from a SOCKS4a or SOCKS5 domain-name request, ornullif the request specified a numeric address.intgetPort()Returns the destination port.Returns the SOCKS4/4a userid field, ornullfor SOCKS5 requests.byteReturns the SOCKS protocol version (0x04 or 0x05).booleanReturns whether this is a SOCKS4a request (SOCKS4 with server-side DNS resolution).toString()
-
Constructor Details
-
SOCKSRequest
public SOCKSRequest(byte version, byte command, InetAddress address, String host, int port, String userid, String authenticatedUser) Creates a SOCKS request.- Parameters:
version- the SOCKS version (0x04 or 0x05); SOCKS4 §Request VER / RFC 1928 §4 VERcommand- the command byte; SOCKS4 §Request CD / RFC 1928 §4 CMDaddress- the resolved destination address, or null if only a hostname was provided; SOCKS4 §Request DSTIP / RFC 1928 §4+§5 DST.ADDRhost- the destination hostname, or null if only an address was provided; SOCKS4a (DSTIP=0.0.0.x) / RFC 1928 §4+§5 DST.ADDR (ATYP 0x03)port- the destination port; SOCKS4 §Request DSTPORT / RFC 1928 §4 DST.PORTuserid- the SOCKS4 userid field, or null for SOCKS5; SOCKS4 §Request USERIDauthenticatedUser- the authenticated username from SOCKS5 auth, or null if no authentication; RFC 1929 §2 / RFC 1961 §4
-
-
Method Details
-
getVersion
public byte getVersion()Returns the SOCKS protocol version (0x04 or 0x05). SOCKS4 §Request VER field; RFC 1928 §4 VER field.- Returns:
- the version byte
-
getCommand
public byte getCommand()Returns the command byte. SOCKS4 §Request CD field; RFC 1928 §4 CMD field.- Returns:
- the command (CONNECT, BIND, or UDP ASSOCIATE)
-
getAddress
Returns the resolved destination address, ornullif the request specified a hostname that has not yet been resolved. SOCKS4 §Request DSTIP; RFC 1928 §4+§5 DST.ADDR (ATYP 0x01 IPv4, 0x04 IPv6).- Returns:
- the destination address, or null
-
getHost
Returns the destination hostname from a SOCKS4a or SOCKS5 domain-name request, ornullif the request specified a numeric address. SOCKS4a: hostname appended after USERID when DSTIP=0.0.0.x (x≠0); RFC 1928 §4+§5 DST.ADDR (ATYP 0x03 domain name).- Returns:
- the destination hostname, or null
-
getPort
public int getPort()Returns the destination port. SOCKS4 §Request DSTPORT; RFC 1928 §4 DST.PORT.- Returns:
- the port number
-
getUserid
Returns the SOCKS4/4a userid field, ornullfor SOCKS5 requests. SOCKS4 §Request USERID (null-terminated string).- Returns:
- the userid, or null
-
getAuthenticatedUser
Returns the username authenticated during SOCKS5 authentication, ornullif no authentication was performed or for SOCKS4 requests. RFC 1929 §2 (username/password auth); RFC 1961 §4 (GSS-API principal).- Returns:
- the authenticated username, or null
-
isSOCKS4a
public boolean isSOCKS4a()Returns whether this is a SOCKS4a request (SOCKS4 with server-side DNS resolution). SOCKS4a: DSTIP=0.0.0.x with x≠0 signals that the hostname is appended after USERID for server-side DNS resolution.- Returns:
- true if SOCKS4a
-
toString
-