java.lang.Object
net.i2p.router.transport.udp.RemoteHostId

final class RemoteHostIdextends Object
Unique ID for a peer - its IP + port, all bundled into a tidy obj. If the remote peer is not reachable through an IP+port, this contains the hash of their identity.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    Precomputed hash of the id.
    private final byte[]
    The peer's address bytes.
    private final Hash
    The peer's hash, if known.
    private final int
    The peer's SSU port.
  • Constructor Summary

    Modifier
    Constructor
    Description
    RemoteHostId(byte[] ip, int port)
    Direct (IP + port).
    private
    RemoteHostId(byte[] ip, int port, Hash peerHash)
    Combines an address, port and hash into one key.
    RemoteHostId(Hash peerHash)
    Indirect (hash only).
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    boolean
     
    byte[]
    The IP address, or null if indirect.
    The peer hash, or null if direct.
    int
    The port, or 0 if indirect.
    int
     
     

    Methods inherited from class Object

    clone, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • _ip

      private final byte[] _ip
      The peer's address bytes.
    • _port

      private final int _port
      The peer's SSU port.
    • _peerHash

      private final Hash _peerHash
      The peer's hash, if known.
    • _hashCode

      private final int _hashCode
      Precomputed hash of the id.
  • Constructor Details

    • RemoteHostId

      public RemoteHostId(byte[] ip, int port)
      Direct (IP + port).
      Parameters:
      ip - the peer's address bytes, 4 or 16 long
      port - the UDP port the peer is reachable on
    • RemoteHostId

      public RemoteHostId(Hash peerHash)
      Indirect (hash only).
      Parameters:
      peerHash - the hash of the peer's RouterIdentity
    • RemoteHostId

      private RemoteHostId(byte[] ip, int port, Hash peerHash)
      Combines an address, port and hash into one key.
      Parameters:
      ip - the address bytes
      port - the SSU port
      peerHash - the peer's hash, may be null
  • Method Details

    • getIP

      public byte[] getIP()
      The IP address, or null if indirect.
      Returns:
      the raw address bytes, or null for a hash-only id
    • getPort

      public int getPort()
      The port, or 0 if indirect.
      Returns:
      the peer's UDP port, or 0 for a hash-only id
    • getPeerHash

      public Hash getPeerHash()
      The peer hash, or null if direct.
      Returns:
      the hash of the peer's RouterIdentity, or null for a direct id
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object