java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.RequestVariableLeaseSetMessage
- All Implemented Interfaces:
I2CPMessage
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 Summary
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty LeaseSet request with no endpoints.Method Summary
Modifier and TypeMethodDescriptionvoidaddEndpoint(Lease lease) Add a lease endpoint.protected voiddoReadMessage(InputStream in, int size) Read the message body from the input stream.protected byte[]Write the message body to the output stream.getEndpoint(int endpoint) Gets the tunnel at a position in this LeaseSet.intCounts the tunnels in this LeaseSet.Session requesting the lease set.intgetType()Reports this message as a variable LeaseSet request.static booleanisSupported(String clientVersion) Does the client support this message?Return the SessionId for this message.voidSession ID for this message.toString()Returns a string representation of this message.Methods inherited from class I2CPMessageImpl
readBytes, readMessage, readMessage, writeBytes, writeMessageModifier and TypeMethodDescriptionvoidreadBytes(InputStream in) Read the message from the stream, wrapping I2CPMessageException inDataFormatException.voidValidate the type and size of the message, and then read the message into the data structures.voidreadMessage(InputStream in, int length, int type) Read the body into the data structures.voidwriteBytes(OutputStream out) Write the message to the stream, wrapping I2CPMessageException in DataFormatException.voidwriteMessage(OutputStream out) Write out the full message to the stream, including the 4 byte size and 1 byte type header.
Field Details
MESSAGE_TYPE
public static final int MESSAGE_TYPEI2CP message type number of a variable LeaseSet request.- See Also:
_sessionId
The session asking for the lease set._endpoints
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
Does the client support this message?- Parameters:
clientVersion- may be null- Returns:
- version != null and version >= 0.9.7
getSessionId
Session requesting the lease set.- Returns:
- the session id, null until set or read
sessionId
Return the SessionId for this message.- Specified by:
sessionIdin interfaceI2CPMessage- Overrides:
sessionIdin classI2CPMessageImpl- Returns:
- null always. Extending classes with a SessionId must override.
setSessionId
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
Gets the tunnel at a position in this LeaseSet.- Parameters:
endpoint- the zero-based position in the list, 0 togetEndpoints()- 1- Returns:
- the tunnel at that position, or null if out of range
addEndpoint
Add a lease endpoint.- Parameters:
lease- the endpoint to append, which must not be null
doReadMessage
Read the message body from the input stream.- Specified by:
doReadMessagein classI2CPMessageImpl- Parameters:
in- positioned just past the 4 byte size and 1 byte type headersize- how many payload bytes remain to be read- Throws:
I2CPMessageException- if the message format is invalidIOException- if there's an error reading from the stream
doWriteMessage
Write the message body to the output stream.- Specified by:
doWriteMessagein classI2CPMessageImpl- Returns:
- byte array
- Throws:
I2CPMessageException- if the message cannot be writtenIOException- 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