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

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

This message has an expiration time for each lease, unlike RequestLeaseSetMessage, which has a single expiration time for all leases.

  • Field Details

    • MESSAGE_TYPE

      public static final int MESSAGE_TYPE
      I2CP message type number of a variable LeaseSet request.
      See Also:
    • _sessionId

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

      private final List<Lease> _endpoints
      The leases to include in the reply.
    • MIN_VERSION

      private static final String MIN_VERSION
      Oldest router that understands this message.
      See Also:
  • Constructor Details

    • RequestVariableLeaseSetMessage

      public RequestVariableLeaseSetMessage()
      Creates an empty LeaseSet request with no endpoints.
  • Method Details

    • isSupported

      public static boolean isSupported(String clientVersion)
      Does the client support this message?
      Parameters:
      clientVersion - may be null
      Returns:
      version != null and version >= 0.9.7
    • 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 the client and its destination share
    • getEndpoints

      public int getEndpoints()
      Counts the tunnels in this LeaseSet.
      Returns:
      the number of tunnels in the LeaseSet
    • getEndpoint

      public Lease getEndpoint(int endpoint)
      Gets the tunnel at a position in this LeaseSet.
      Parameters:
      endpoint - the zero-based position in the list, 0 to getEndpoints() - 1
      Returns:
      the tunnel at that position, or null if out of range
    • addEndpoint

      public void addEndpoint(Lease lease)
      Add a lease endpoint.
      Parameters:
      lease - the endpoint to append, which must not be null
    • 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 variable LeaseSet request.
      Returns:
      RequestVariableLeaseSetMessage's I2CP type number, for dispatch
    • toString

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