java.lang.Object
net.i2p.router.message.GarlicConfig
Direct Known Subclasses:
PayloadGarlicConfig

class GarlicConfigextends Object
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 Details

    • GarlicConfig

      public GarlicConfig(Certificate cert, long id, long expiration, DeliveryInstructions di)
      Creates a new GarlicConfig.
      Parameters:
      cert - the certificate, as carried into getCertificate()
      id - the unique ID
      expiration - the expiration time
      di - 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 configs
      cert - the certificate, as carried into getCertificate()
      id - the unique ID
      expiration - the expiration time
      di - the delivery instructions
  • Method Details

    • setRecipient

      public void setRecipient(RouterInfo info)
      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

      public RouterInfo getRecipient()
      The router that should receive and process this clove.
      Returns:
      the recipient or null
    • setRecipientPublicKey

      public void setRecipientPublicKey(PublicKey recipientPublicKey)
      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

      public PublicKey getRecipientPublicKey()
      The public key of the router that should receive and process this clove.
      Returns:
      the public key or null
    • getCertificate

      public Certificate getCertificate()
      Certificate for the getRecipient() 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

      public DeliveryInstructions getDeliveryInstructions()
      Specify how the I2NPMessage in the clove should be handled.
      Returns:
      the delivery instructions
    • addClove

      public void addClove(GarlicConfig config)
      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

      public GarlicConfig getClove(int index)
      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

      protected String getSubData()
      The sub-data included in the toString() output.
      Returns:
      sub-data string
    • toString

      public String toString()
      Overrides:
      toString in class Object