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

public class RequestLeaseSetMessageextends I2CPMessageImpl
Defines the message a router sends to a client to request that a leaseset be created and signed. The reply is a CreateLeaseSetMessage.
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      The serialization version of the message.
      See Also:
    • MESSAGE_TYPE

      public static final int MESSAGE_TYPE
      I2CP message type of a lease set request.
      See Also:
    • _sessionId

      private SessionId _sessionId
      The session asking for the lease set.
    • _endpoints

      The requested tunnel endpoints, an array list because list is not serializable.
    • _end

      private Date _end
      When the lease set expires.
  • Constructor Details

    • RequestLeaseSetMessage

      public RequestLeaseSetMessage()
      Creates a request with an empty endpoint list.
  • Method Details

    • getSessionId

      public SessionId getSessionId()
      Session requesting the lease set.
      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.
    • setSessionId

      public void setSessionId(SessionId id)
      Session ID for this message.
      Parameters:
      id - the session identifier to attach to this message
    • getEndpoints

      public int getEndpoints()
      Returns the number of tunnels in the request.
      Returns:
      the count of router/tunnel pairs requested
    • getRouter

      public Hash getRouter(int endpoint)
      Returns the router identity of one of the requested tunnels.
      Parameters:
      endpoint - index into the endpoint list; out of range returns null
      Returns:
      the identity hash of the tunnel's gateway, or null if the index is out of range
    • getTunnelId

      public TunnelId getTunnelId(int endpoint)
      Tunnel of one of the requested endpoints.
      Parameters:
      endpoint - index into the endpoint list; out of range returns null
      Returns:
      the endpoint's tunnel id, or null if the index is out of range
    • addEndpoint

      public void addEndpoint(Hash router, TunnelId tunnel)
      Add a router and tunnel endpoint.
      Parameters:
      router - the router hash to add, must not be null
      tunnel - the tunnel used to reach that router, must not be null
    • getEndDate

      public Date getEndDate()
      When the lease set should expire.
      Returns:
      the end date, null until set or read
    • setEndDate

      public void setEndDate(Date end)
      End date of the lease set.
      Parameters:
      end - the expiry date requested for the lease set
    • 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()
      Returns the I2CP message type of this message.
      Returns:
      MESSAGE_TYPE, 21
    • toString

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