java.lang.Object
net.i2p.router.message.OutboundClientMessageJobHelper

class OutboundClientMessageJobHelperextends Object
Static methods to create a Garlic Message with one or more cloves.

GarlicMessage
    Ack Clove (optional)
        Tunnel delivery instructions
        Garlic Message
            Delivery Status Clove
                Local delivery instructions
                Delivery Status Message
    LeaseSet Clove (optional)
        Local delivery instructions
        Database Store Message
    Data Clove (required)
        Destination delivery instructions
        Data Message

The low-level construction is in GarlicMessageBuilder.

  • Field Details

    • ACK_EXTRA_EXPIRATION

      private static final long ACK_EXTRA_EXPIRATION
      Extra ms an ack lives beyond its payload's expiry
      See Also:
  • Constructor Details

    • OutboundClientMessageJobHelper

      private OutboundClientMessageJobHelper()
      Utility class, not intended for instantiation.
  • Method Details

    • createGarlicMessage

      static GarlicMessage createGarlicMessage(RouterContext ctx, long replyToken, long expiration, PublicKey recipientPK, PayloadGarlicConfig dataClove, Hash from, Destination dest, TunnelInfo replyTunnel, int tagsToSendOverride, int lowTagsOverride, SessionKey wrappedKey, Set<SessionTag> wrappedTags, boolean requireAck, LeaseSet bundledReplyLeaseSet, ReplyCallback callback)
      Build a garlic message that will be delivered to the router on which the target is located. Inside the message are two cloves: one containing the payload with instructions for delivery to the (now local) destination, and the other containing a DeliveryStatusMessage with instructions for delivery to an inbound tunnel of this router.

      How the DeliveryStatusMessage is wrapped can vary - it can be simply sent to a tunnel (as above), wrapped in a GarlicMessage and source routed a few hops before being tunneled, source routed the entire way back, or not wrapped at all - in which case the payload clove contains a SourceRouteBlock and a request for a reply.

      For now, its just a tunneled DeliveryStatusMessage

      Allow the app to specify the data clove directly, which enables OutboundClientMessage to resend the same payload (including expiration and unique id) in different garlics (down different tunnels). This is called from OCMOSJ.

      Parameters:
      ctx - the router context
      replyToken - the reply token
      expiration - the message expiration
      recipientPK - the recipient public key
      dataClove - may be null for ECIES-layer ack
      from - the sender hash
      dest - the remote destination the message is addressed to
      replyTunnel - non-null if requireAck is true or bundledReplyLeaseSet is non-null
      tagsToSendOverride - if > 0, use this instead of skm's default
      lowTagsOverride - if > 0, use this instead of skm's default
      wrappedKey - for ElGamal, non-null with null data, output parameter that will be filled with the SessionKey used, may be null for ECIES
      wrappedTags - for ElGamal, output parameter that will be filled with the sessionTags used, may be null for ECIES
      requireAck - if true, bundle replyToken in an ack clove
      bundledReplyLeaseSet - may be null; if non-null, put it in a clove
      callback - only for ECIES, may be null
      Returns:
      garlic, or null if no tunnels were found (or other errors)
    • createGarlicConfig

      private static GarlicConfig createGarlicConfig(RouterContext ctx, long replyToken, long expiration, PublicKey recipientPK, PayloadGarlicConfig dataClove, Hash from, Destination dest, TunnelInfo replyTunnel, boolean requireAck, LeaseSet bundledReplyLeaseSet, SessionKeyManager skm)
      Make the top-level config, with a data clove, an optional ack clove, and an optional leaseset clove.

      The returned GarlicConfig will have the recipientPublicKey set.

      Parameters:
      ctx - the router context, source of the log and the random clove set IDs
      replyToken - the token the receiver echoes back in the ack, negative when no reply is expected
      expiration - the expiration time in milliseconds, also used for the ack clove 60 seconds later
      recipientPK - the key the whole message is encrypted to, set on the returned config
      dataClove - may be null for ECIES-layer ack
      from - our own hash, named in the log when the ack clove cannot be built
      dest - the remote destination we are sending to, named in the INFO log
      replyTunnel - non-null if requireAck is true or bundledReplyLeaseSet is non-null
      requireAck - if true, bundle replyToken in an ack clove
      bundledReplyLeaseSet - may be null; if non-null, put it in a clove
      skm - encrypt dsm with this skm non-null
      Returns:
      null on error
    • buildAckClove

      private static PayloadGarlicConfig buildAckClove(RouterContext ctx, Hash from, TunnelInfo replyToTunnel, long replyToken, long expiration, SessionKeyManager skm)
      Build a clove that sends a DeliveryStatusMessage to us. As of 0.9.12, the DSM is wrapped in a GarlicMessage.
      Parameters:
      ctx - the router context, source of the log, our keys and the random clove set IDs
      from - our own hash, whose keys are looked up and named when no inbound tunnel is available
      replyToTunnel - the inbound tunnel the ack travels back on, null means no ack is possible
      replyToken - the token the DSM carries so the receiver can match it to the data message
      expiration - the clove's expiration time in milliseconds
      skm - encrypt dsm with this skm non-null
      Returns:
      null on error
    • buildDSM

      private static DeliveryStatusMessage buildDSM(RouterContext ctx, long replyToken)
      Make a basic DSM.
      Parameters:
      ctx - the context the message is created for
      replyToken - the message id the receiver matches the ack against
      Returns:
      a DSM stamped with the current time and the given reply token
    • wrapDSM

      private static GarlicMessage wrapDSM(RouterContext ctx, SessionKeyManager skm, DeliveryStatusMessage dsm, long expiration)
      Wrap a DSM in a GarlicMessage, add the fake session to the SKM. Since 0.9.12 it is encrypted, to hide it from the target and the return path OBEP and IBGW.
      Parameters:
      ctx - the router context, source of the random session key and tags
      skm - encrypt dsm with this skm non-null
      dsm - the delivery status message to wrap
      expiration - the message's expiration time in milliseconds, from which the fake session's lifetime is taken
      Returns:
      null on error
    • buildLeaseSetClove

      private static PayloadGarlicConfig buildLeaseSetClove(RouterContext ctx, long expiration, LeaseSet replyLeaseSet)
      Build a clove that stores the leaseSet locally.
      Parameters:
      ctx - the router context, source of the random clove set ID
      expiration - the clove's expiration time in milliseconds
      replyLeaseSet - the lease set the target is asked to store for us
      Returns:
      a clove with local delivery instructions, carrying the database store message