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

public class DestReplyMessageextends I2CPMessageImpl
Response to DestLookupMessage. As of 0.8.3, the response may include the hash from the request, indicating a failure for a specific request. Payload may be empty (failure), a Hash (failure), or a Destination.
  • Field Details

    • MESSAGE_TYPE

      public static final int MESSAGE_TYPE
      I2CP message type number of a destination lookup reply.
      See Also:
    • _dest

      private Destination _dest
      The destination found for the name.
    • _hash

      private Hash _hash
      Hash of the destination being reported.
  • Constructor Details

    • DestReplyMessage

      public DestReplyMessage()
      Creates a reply carrying no destination, for a failed lookup.
    • DestReplyMessage

      public DestReplyMessage(Destination d)
      Creates a reply naming the destination the lookup resolved to.
      Parameters:
      d - the destination the lookup resolved to, or null if this reply reports a failure
    • DestReplyMessage

      public DestReplyMessage(Hash h)
      Non-null with non-null data.
      Parameters:
      h - non-null with non-null data
  • Method Details

    • getDestination

      public Destination getDestination()
      Gets the destination this reply resolved to.
      Returns:
      the full destination the lookup resolved to, or null if this reply carries only a hash or reports a failure with an empty payload
    • getHash

      public Hash getHash()
      Gets the hash of the destination.
      Returns:
      the hash copied from the request, identifying which lookup failed, or null if this reply carries a full destination or an empty payload
    • 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 destination lookup reply.
      Returns:
      MESSAGE_TYPE, the I2CP message type number of a lookup reply
    • toString

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