java.lang.Object
net.i2p.data.DataStructureImpl
net.i2p.data.DatabaseEntry
net.i2p.data.LeaseSet
net.i2p.data.LeaseSet2
net.i2p.data.MetaLeaseSet
- All Implemented Interfaces:
Serializable, DataStructure
Implementation of MetaLeaseSet as specified in Proposal 123: New NetDb Entries.
MetaLeaseSet is a specialized LeaseSet2 that contains references to other LeaseSets rather than direct tunnel endpoints. This enables advanced routing and load balancing strategies.
Key characteristics of MetaLeaseSet:
- Contains
MetaLeaseobjects instead of regularLeaseobjects - Does not support encryption keys (throws
UnsupportedOperationException) - References other LeaseSets by hash rather than containing tunnel endpoints directly
- Supports offline signatures for reduced router load
- Includes options and statistics support
Usage: MetaLeaseSets are used for:
- Load balancing across multiple LeaseSets
- Geographic or performance-based routing decisions
- Fallback and redundancy strategies
- Service discovery and aggregation
Implementation Status: PRELIMINARY - Subject to change as the proposal evolves.
- See Also:
Field Summary
Fields inherited from class LeaseSet2
_expires, _flags, _offlineSignature, _options, _published, _transientExpires, _transientSigningPublicKeyModifier and TypeFieldDescriptionprotected longExpiration timestamp in ms (1-second resolution).protected intFlags for options, offline, unpublished, blinded.protected SignatureOffline signature.protected PropertiesOptions and statistics properties, may be null.protected longPublished timestamp in ms (1-second resolution).protected longTransient key expiration in ms.protected SigningPublicKeyTransient signing public key for offline signing.Fields inherited from class LeaseSet
_byteified, _checked, _destination, _encryptionKey, _lastExpiration, _leases, _signingKey, MAX_LEASESModifier and TypeFieldDescriptionprotected byte[]Cached serialized byte array for performance.protected booleanWhether decryption has been attempted.protected DestinationDestination this LeaseSet is for.protected PublicKeyEncryption public key for the destination.protected longLatest expiration time among all leases.Leases must stay in the order received, or signature verification will fail.protected SigningPublicKeyRevocation or blinded signing key.static final intUnlimited before 0.6.3; 6 as of 0.6.3; Increased in version 0.9.Fields inherited from class DatabaseEntry
_signature, KEY_TYPE_ENCRYPTED_LS2, KEY_TYPE_LEASESET, KEY_TYPE_LS2, KEY_TYPE_META_LS2, KEY_TYPE_ROUTERINFO, KEY_TYPE_SERVICE_LIST, KEY_TYPE_SERVICE_RECORDModifier and TypeFieldDescriptionprotected SignatureCryptographic signature.static final intEncrypted LeaseSet 2 type.static final intLeaseSet (v1) type.static final intLeaseSet 2 type.static final intMeta LeaseSet 2 type.static final intRouter info type.static final intService list type.static final intService record type.Constructor Summary
ConstructorsMethod Summary
Public MethodsModifier and TypeMethodDescriptionvoidUnsupportedOperationException always.voidMust be a MetaLease.booleanCompares this MetaLeaseSet with another object for equality.intgetType()Entry type for the network database.inthashCode()The destination has enough randomness in it to use it by itself for speed.voidreadBytes(InputStream in) This does NOT validate the signature.voidUnsupportedOperationException always.intsize()Number of bytes, NOT including signature.toString()Returns a string representation of this MetaLeaseSet.protected voidWithout sig.Methods inherited from class LeaseSet2
encrypt, getBlindedHash, getBytes, getEncryptionKey, getEncryptionKey, getEncryptionKeys, getExpires, getOption, getOptions, getPublished, getReceivedAsPublished, getTransientExpiration, getTransientSigningKey, isBlindedWhenPublished, isCurrent, isOffline, isUnpublished, offlineSign, readHeader, readOfflineBytes, setBlindedHash, setBlindedWhenPublished, setOfflineSignature, setOptions, setPublished, setSigningKey, setUnpublished, sign, verifyOfflineSignature, verifyOfflineSignature, verifySignature, writeBody, writeBytes, writeHeader, writeOfflineBytesModifier and TypeMethodDescriptionvoidencrypt(SessionKey key) Encrypt the gateway and tunnel ID of each lease, leaving the expire dates unchanged.The original blinded hash, where this came from.protected byte[]getBytes()Without the signature!If more than one key, return the first supported one.getEncryptionKey(Set<EncType> supported) If more than one key, return the first supported one.This returns all the keys.longPublished expiration, as received.Option value for the given key.Leaseset options.longPublished timestamp, as received.booleanIf true, we received this LeaseSet by a remote peer publishing it to us, AND the unpublished flag is not set.longAbsolute time, not time from now.Transient public key for offline signing.booleanWhether the unencrypted LS, when published, will be blinded/encrypted.booleanisCurrent(long fudge) Determine whether the leaseset is currently valid, at least within a given fudge factor.booleanChecks if this leaseset uses offline keys.booleanTrue if unpublished.static SignatureofflineSign(long expires, SigningPublicKey transientSPK, SigningPrivateKey priv) Generate a Signature to pass toLeaseSet2.setOfflineSignature(long, SigningPublicKey, Signature).protected voidRead the LeaseSet2 header from a stream.protected voidRead the offline signing section from a stream.voidsetBlindedHash(Hash bh) Blinded hash, if known at creation.voidMark the unencrypted LS to be blinded/encrypted when published.booleansetOfflineSignature(long expires, SigningPublicKey transientSPK, Signature offlineSig) Destination must be previously set.voidsetOptions(Properties options) Configure a set of options or statistics that the router can expose.voidsetPublished(long now) Published timestamp.voidThe revocation key.voidMarks this leaseset as unpublished.voidsign(SigningPrivateKey key) Sign the structure using the supplied signing key.booleanVerify the offline signature.protected booleanVerify the offline signature with the given key.booleanVerify with the SPK in the dest for online sigs.protected voidwriteBody(OutputStream out) Without sig.voidwriteBytes(OutputStream out) Including sig.protected voidwriteHeader(OutputStream out) Write the LeaseSet2 header to a stream.protected voidWrite the offline signing section to a stream.Methods inherited from class LeaseSet
getDate, getDestination, getEarliestLeaseDate, getKeysAndCert, getLatestLeaseDate, getLease, getLeaseCount, getSigningKey, setDestination, setReceivedByModifier and TypeMethodDescriptionlonggetDate()Same asLeaseSet.getEarliestLeaseDate().Warning - will be null for LS2 EncryptedLeaseSets if not decrypted.longRetrieve the end date of the earliest lease included in this leaseSet.Keys and certificate for this lease set.longRetrieve the end date of the latest lease included in this leaseSet.getLease(int index) Lease at the given index.intNumber of leases in this leaseset.The revocation key.voidsetDestination(Destination dest) Destination for this leaseset.voidsetReceivedBy(Hash localClient) Record the local client that received this leaseset.Methods inherited from class DatabaseEntry
getHash, getReceivedAsReply, getReceivedBy, getRoutingKey, getSignature, getSigningPublicKey, isLeaseSet, isLeaseSet, isRouterInfo, setReceivedAsPublished, setReceivedAsReply, setSignature, validateRoutingKeyModifier and TypeMethodDescriptiongetHash()A common interface to the Hash of the two subclasses.booleanIf true, we received this LeaseSet by searching for it Default false.The Hash of the local client that received this LS, null if the router or unknown.Routing key for the structure using the current modifier in the RoutingKeyGenerator.Retrieve the proof that the identity stands behind the info here.protected SigningPublicKeyIdentical to getDestination().DatabaseEntry.getSigningPublicKey()in LeaseSet, and getIdentity().getSigningPublicKey() in RouterInfo.booleanConvenience method, is the type any variant of leaseset?static booleanisLeaseSet(int type) Convenience method, is the type any variant of leaseset?booleanConvenience method, is the type any variant of router info?voidMarks this entry as received via published mode.voidMarks this entry as received via reply.voidsetSignature(Signature signature) Configure the proof that the entity stands behind the info here.booleanValidates the routing key for this entry.Methods inherited from class DataStructureImpl
calculateHash, fromBase64, fromByteArray, read, toBase64, toByteArrayModifier and TypeMethodDescriptionCalculate the SHA256 value of this object (useful for a few scenarios).voidfromBase64(String data) Load the structure from the provided base64 string.voidfromByteArray(byte[] data) Loads structure from the data providedprotected intread(InputStream in, byte[] target) Repeated reads until buffer is full or IOException is thrown.toBase64()Render the structure into modified base 64 notation.byte[]Convert the structure to a byte array.
Constructor Details
MetaLeaseSet
public MetaLeaseSet()Creates a new MetaLeaseSet with default values.
Method Details
getType
setEncryptionKey
UnsupportedOperationException always.- Overrides:
setEncryptionKeyin classLeaseSet- Parameters:
key- the ElGamal or ECIES key tunnel build requests are encrypted to, matched to the receiver by the key type- Throws:
UnsupportedOperationException- always, as a MetaLeaseSet carries no encryption keys
addEncryptionKey
UnsupportedOperationException always.- Overrides:
addEncryptionKeyin classLeaseSet2- Parameters:
key- the key to append; the first one added becomes the key returned byLeaseSet2.getEncryptionKey()- Throws:
UnsupportedOperationException- always, as a MetaLeaseSet carries no encryption keys
readBytes
This does NOT validate the signature.- Specified by:
readBytesin interfaceDataStructure- Overrides:
readBytesin classLeaseSet2- Parameters:
in- stream to read from- Throws:
IllegalStateException- if called more than once or Destination already setDataFormatException- if the data is improperly formattedIOException- if there was a problem reading the stream
writeBytesWithoutSig
Without sig. This does NOT validate the signature.- Overrides:
writeBytesWithoutSigin classLeaseSet2- Parameters:
out- the stream to write the header and body to- Throws:
DataFormatException- if the destination or encryption key is unsetIOException- if the stream cannot be written
size
addLease
Must be a MetaLease.- Overrides:
addLeasein classLeaseSet2- Parameters:
lease- must be a MetaLease- Throws:
IllegalArgumentException- if not a MetaLease
equals
hashCode
toString