java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.HostLookupMessage
All Implemented Interfaces:
I2CPMessage

public class HostLookupMessageextends I2CPMessageImpl
Request the router look up the dest for a hash or a host. Replaces DestLookupMessage. Do not send to routers older than 0.9.11.
  • Field Details

    • MESSAGE_TYPE

      public static final int MESSAGE_TYPE
      I2CP message type number of a host or hash lookup request.
      See Also:
    • _reqID

      private long _reqID
      Id matching the reply to the request.
    • _timeout

      private long _timeout
      How long the router may take, in ms.
    • _lookupType

      private int _lookupType
      What kind of lookup to perform.
    • _hash

      private Hash _hash
      The hash to look up, for hash lookups.
    • _host

      private String _host
      The host name to look up, for name lookups.
    • _sessionId

      private SessionId _sessionId
      The session that asked for the lookup.
    • LOOKUP_HASH

      public static final int LOOKUP_HASH
      Lookup type value asking for the Destination behind a hash.
      See Also:
    • LOOKUP_HOST

      public static final int LOOKUP_HOST
      Lookup type value asking for the HostName behind a Destination.
      See Also:
    • MAX_INT

      private static final long MAX_INT
      Largest id that fits on the wire.
      See Also:
  • Constructor Details

    • HostLookupMessage

      public HostLookupMessage()
      Creates a lookup request with no target, type or session set.
    • HostLookupMessage

      public HostLookupMessage(SessionId id, Hash h, long reqID, long timeout)
      Session id.
      Parameters:
      id - the session id
      h - the hash to look up
      reqID - 0 to 2**32 - 1
      timeout - ms 1 to 2**32 - 1
    • HostLookupMessage

      public HostLookupMessage(SessionId id, String host, long reqID, long timeout)
      Session id.
      Parameters:
      id - the session id
      host - the hostname to look up
      reqID - 0 to 2**32 - 1
      timeout - ms 1 to 2**32 - 1
  • Method Details

    • getSessionId

      public SessionId getSessionId()
      Session making the lookup request.
      Returns:
      the session id, null until set or read
    • sessionId

      public SessionId sessionId()
      Return the SessionId for this message.
      Specified by:
      sessionId in interface I2CPMessage
      Overrides:
      sessionId in class I2CPMessageImpl
      Returns:
      null always. Extending classes with a SessionId must override.
    • getReqID

      public long getReqID()
      Gets the request ID.
      Returns:
      0 to 2**32 - 1
    • getTimeout

      public long getTimeout()
      Gets the lookup timeout.
      Returns:
      ms 1 to 2**32 - 1
    • getLookupType

      public int getLookupType()
      The lookup type selector.
      Returns:
      0 (hash) or 1 (host)
    • getHash

      public Hash getHash()
      Gets the hash for hash-type lookups.
      Returns:
      only valid if lookup type == 0
    • getHostname

      public String getHostname()
      Gets the hostname for host-type lookups.
      Returns:
      only valid if lookup type == 1
    • doReadMessage

      protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException
      Read the message body from the input stream.
      Specified by:
      doReadMessage in class I2CPMessageImpl
      Parameters:
      in - positioned just past the 4 byte size and 1 byte type header
      size - how many payload bytes remain to be read
      Throws:
      I2CPMessageException - if the message format is invalid
      IOException - if there's an error reading from the stream
    • doWriteMessage

      protected byte[] doWriteMessage() throws I2CPMessageException, IOException
      Write the message body to the output stream.
      Specified by:
      doWriteMessage in class I2CPMessageImpl
      Returns:
      byte array
      Throws:
      I2CPMessageException - if the message cannot be written
      IOException - if there's an error writing to the stream
    • getType

      public int getType()
      Reports this message as a host lookup request.
      Returns:
      MESSAGE_TYPE, 38
    • toString

      public String toString()
      Returns a string representation of this message.
      Overrides:
      toString in class Object