java.lang.Object
net.i2p.router.message.GarlicConfig
- Direct Known Subclasses:
PayloadGarlicConfig
Configuration and content for a garlic message containing one or more cloves.
This is the top-level container for a GarlicMessage's cloves, their delivery instructions, and the recipient's encryption key. Individual clove payloads are represented by PayloadGarlicConfig.
Despite the name, instances of this class hold the actual clove references, not just configuration metadata.
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedGarlicConfig(List<GarlicConfig> cloveConfigs, Certificate cert, long id, long expiration, DeliveryInstructions di) Creates a new GarlicConfig with existing clove configs.GarlicConfig(Certificate cert, long id, long expiration, DeliveryInstructions di) Creates a new GarlicConfig.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidaddClove(GarlicConfig config) Add a clove to the current message - if any cloves are added, an I2NP message cannot be specified via setPayload.voidClears all clove configs.Certificate for thegetRecipient()to pay for their processing.getClove(int index) The nested clove config at the given position.intThe number of nested clove configs in this config.Specify how the I2NPMessage in the clove should be handled.longExpiration of the clove, after which it should be dropped.longgetId()Unique ID of the clove.The router that should receive and process this clove.The public key of the router that should receive and process this clove.protected StringThe sub-data included in thetoString()output.voidsetRecipient(RouterInfo info) Router to receive and process this clove.voidsetRecipientPublicKey(PublicKey recipientPublicKey) Public key of the router to receive and process this clove.toString()
Constructor Details
GarlicConfig
Creates a new GarlicConfig.- Parameters:
cert- the certificate, as carried intogetCertificate()id- the unique IDexpiration- the expiration timedi- the delivery instructions
GarlicConfig
protected GarlicConfig(List<GarlicConfig> cloveConfigs, Certificate cert, long id, long expiration, DeliveryInstructions di) Creates a new GarlicConfig with existing clove configs.- Parameters:
cloveConfigs- the list of clove configscert- the certificate, as carried into getCertificate()id- the unique IDexpiration- the expiration timedi- the delivery instructions
Method Details
setRecipient
Router to receive and process this clove. It opens the delivery instructions and decides what to do: process it locally as an I2NPMessage, or forward that I2NPMessage to a router, a Destination, or a tunnel.Used only if recipient public key is not set.
- Parameters:
info- the recipient router info
getRecipient
The router that should receive and process this clove.- Returns:
- the recipient or null
setRecipientPublicKey
Public key of the router to receive and process this clove. This is useful for garlic routed messages encrypted to the router at the end of a tunnel, as their RouterIdentity is not known, but a PublicKey they handle is exposed via the LeaseSet.- Parameters:
recipientPublicKey- the recipient's public key
getRecipientPublicKey
The public key of the router that should receive and process this clove.- Returns:
- the public key or null
getCertificate
Certificate for thegetRecipient()to pay for their processing.- Returns:
- the certificate passed to the constructor, possibly null
getId
public long getId()Unique ID of the clove.- Returns:
- the unique ID
getExpiration
public long getExpiration()Expiration of the clove, after which it should be dropped.- Returns:
- the expiration time
getDeliveryInstructions
Specify how the I2NPMessage in the clove should be handled.- Returns:
- the delivery instructions
addClove
Add a clove to the current message - if any cloves are added, an I2NP message cannot be specified via setPayload. This means that the resulting GarlicClove represented by this GarlicConfig must be a GarlicMessage itself.- Parameters:
config- the clove config to add
getCloveCount
public int getCloveCount()The number of nested clove configs in this config.- Returns:
- the clove count
getClove
The nested clove config at the given position.- Parameters:
index- the 0-based position in the clove list- Returns:
- the clove config
clearCloves
public void clearCloves()Clears all clove configs.getSubData
toString