java.lang.Object
net.i2p.i2ptunnel.socks.SOCKSHeader
Save the SOCKS header from a datagram Ref: RFC 1928.
Field Summary
Constructor Summary
ConstructorsConstructorDescriptionSOCKSHeader(byte[] data) Parse a SOCKS I2P datagram header, copying the header portion out of the datagram.SOCKSHeader(Destination dest, int port) Make a dummy header from a dest, for those cases where we want to receive unsolicited datagrams.Method Summary
All MethodsModifier and TypeMethodDescriptionbyte[]getBytes()Return the header bytes as parsed, for writing back to a datagram.Resolve the header's hostname through the naming service.getHost()The requested address, as a hostname or an IP address string.intgetPort()Extract the I2CP port that follows the address field.
Field Details
header
private byte[] headerThe SOCKS UDP request header.beg
private static final byte[] begFixed bytes a SOCKS UDP associate request starts with
Constructor Details
SOCKSHeader
public SOCKSHeader(byte[] data) Parse a SOCKS I2P datagram header, copying the header portion out of the datagram. The remaining payload is ignored.- Parameters:
data- the whole packet- Throws:
IllegalArgumentException- on bad socks format
SOCKSHeader
Make a dummy header from a dest, for those cases where we want to receive unsolicited datagrams. Unused for now.- Parameters:
dest- the destination whose base32 hash fills the reply address fieldport- I2CP port 0-65535
Method Details
getHost
The requested address, as a hostname or an IP address string. As of 0.9.53 the IP address types 1 and 4 are returned as a string.- Returns:
- hostname or null for unknown address type
getPort
public int getPort()Extract the I2CP port that follows the address field.- Returns:
- 0 - 65535
getDestination
Resolve the header's hostname through the naming service.- Returns:
- destination or null
getBytes
public byte[] getBytes()Return the header bytes as parsed, for writing back to a datagram.- Returns:
- the header bytes as parsed, not a copy