java.lang.Object
net.i2p.i2ptunnel.socks.SOCKSHeader

public class SOCKSHeaderextends Object
Save the SOCKS header from a datagram Ref: RFC 1928.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final byte[]
    Fixed bytes a SOCKS UDP associate request starts with
    private byte[]
    The SOCKS UDP request header.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SOCKSHeader(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 Methods
    Modifier and Type
    Method
    Description
    byte[]
    Return the header bytes as parsed, for writing back to a datagram.
    Resolve the header's hostname through the naming service.
    The requested address, as a hostname or an IP address string.
    int
    Extract the I2CP port that follows the address field.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • beg

      private static final byte[] beg
      Fixed 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

      public SOCKSHeader(Destination dest, int port)
      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 field
      port - I2CP port 0-65535
  • Method Details

    • getHost

      public String 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

      public Destination 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