java.lang.Object
net.i2p.router.JobImpl
net.i2p.router.message.SendMessageDirectJob
All Implemented Interfaces:
Job

public class SendMessageDirectJobextends JobImpl
Send a message directly to another router (not through a tunnel).

Used by HandleGarlicMessageJob to forward decrypted cloves to their target router or tunnel gateway. Also used by netdb for database store/lookup replies.

Safe to run inline via runJob(). If the RouterInfo for the Hash is not found locally, it will queue a lookup and register itself to be run again when the lookup succeeds or times out.

  • Field Details

    • _log

      private final Log _log
      Logger for the direct send job.
    • _message

      private final I2NPMessage _message
      The message to send.
    • _targetHash

      private final Hash _targetHash
      The hash of the target router.
    • _router

      private RouterInfo _router
      The target's router info, once found.
    • _expiration

      private final long _expiration
      When the message is too old to send.
    • _priority

      private final int _priority
      Send priority of the message.
    • _onSend

      private final Job _onSend
      Job run after a successful send.
    • _onSuccess

      private final ReplyJob _onSuccess
      Job run when the reply arrives.
    • _onFail

      private final Job _onFail
      Job run when the send fails.
    • _selector

      private final MessageSelector _selector
      Selector matching the expected reply.
    • _alreadySearched

      private volatile boolean _alreadySearched
      True once the floodfill search started.
    • _sent

      private volatile boolean _sent
      True once the message was sent.
    • _searchOn

      private long _searchOn
      When to start the floodfill search.
    • _msgIDBloomXor

      private final long _msgIDBloomXor
      Random mask for the message id bloom filter.
  • Constructor Details

    • SendMessageDirectJob

      public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, int timeoutMs, int priority)
      Send a message directly to a peer.
      Parameters:
      ctx - the router context
      message - the message to send
      toPeer - may be ourselves
      timeoutMs - milliseconds to wait for delivery; under 5000 is raised to 10000
      priority - the OutNetMessage priority, one of the MessageContext constants
    • SendMessageDirectJob

      public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, int timeoutMs, int priority, long msgIDBloomXor)
      Send a message directly to a peer with an XOR mask.
      Parameters:
      ctx - the router context
      message - the message to send
      toPeer - may be ourselves
      timeoutMs - milliseconds to wait for delivery; under 5000 is raised to 10000
      priority - the OutNetMessage priority, one of the MessageContext constants
      msgIDBloomXor - value to xor the messageID with before passing to the InNetMessagePool, may be 0
    • SendMessageDirectJob

      public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, ReplyJob onSuccess, Job onFail, MessageSelector selector, int timeoutMs, int priority)
      Send a message directly to a peer with reply handling.
      Parameters:
      ctx - the router context
      message - the message to send
      toPeer - may be ourselves
      onSuccess - may be null
      onFail - may be null
      selector - selects which reply triggers onSuccess, or null to accept any reply
      timeoutMs - milliseconds to wait for delivery; under 5000 is raised to 10000
      priority - the OutNetMessage priority, one of the MessageContext constants
    • SendMessageDirectJob

      public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, ReplyJob onSuccess, Job onFail, MessageSelector selector, int timeoutMs, int priority, long msgIDBloomXor)
      Send a message directly to a peer with reply handling and XOR mask.
      Parameters:
      ctx - the router context
      message - the message to send
      toPeer - may be ourselves
      onSuccess - may be null
      onFail - may be null
      selector - selects which reply triggers onSuccess, or null to accept any reply
      timeoutMs - milliseconds to wait for delivery; under 5000 is raised to 10000
      priority - the OutNetMessage priority, one of the MessageContext constants
      msgIDBloomXor - value to xor the messageID with before passing to the InNetMessagePool, may be 0
    • SendMessageDirectJob

      public SendMessageDirectJob(RouterContext ctx, I2NPMessage message, Hash toPeer, Job onSend, ReplyJob onSuccess, Job onFail, MessageSelector selector, int timeoutMs, int priority, long msgIDBloomXor)
      Send a message directly to a peer with full options.
      Parameters:
      ctx - the router context
      message - the message to send
      toPeer - may be ourselves
      onSend - may be null
      onSuccess - may be null
      onFail - may be null
      selector - selects which reply triggers onSuccess, or null to accept any reply
      timeoutMs - milliseconds to wait for delivery; under 5000 is raised to 10000
      priority - the OutNetMessage priority, one of the MessageContext constants
      msgIDBloomXor - value to xor the messageID with before passing to the InNetMessagePool, may be 0
  • Method Details

    • getName

      public String getName()
      Description copied from interface: Job
      Descriptive name of the task.
      Returns:
      the descriptive name of the task
    • messageTypeName

      private String messageTypeName()
      Simple class name of the message being sent, unwrapping a TunnelGatewayMessage to its inner message for a more informative log entry.
      Returns:
      the simple class name of the message type
    • runJob

      public void runJob()
      Description copied from interface: Job
      Actually perform the task. This call blocks until the Job is complete.
    • send

      private void send()
      Sends the message to the target's router info.