java.lang.Object
net.i2p.router.crypto.TransientSessionKeyManager.OutboundSession
Enclosing class:
TransientSessionKeyManager

private static class TransientSessionKeyManager.OutboundSessionextends Object
The state for a crypto session to a single public key.
  • Field Details

    • _context

      private final I2PAppContext _context
      The app context.
    • _log

      private final Log _log
      Logger for this session.
    • _target

      private final PublicKey _target
      The peer's public key.
    • _currentKey

      private SessionKey _currentKey
      Key for the most recently sent tag set.
    • _established

      private final long _established
      When the session was created.
    • _lastUsed

      private long _lastUsed
      When a tag was last consumed.
    • _unackedTagSets

      private final Set<TransientSessionKeyManager.TagSet> _unackedTagSets
      Before the first ack, all tagsets go here. These are never expired, we rely on the callers to call failTags() or ackTags() to remove them from this list. Actually we now do a failsafe expire. Synch on _tagSets to access this. No particular order.
    • _tagSets

      private final List<TransientSessionKeyManager.TagSet> _tagSets
      As tagsets are acked, they go here. After the first ack, new tagsets go here (i.e. presumed acked) In order, earliest first.
    • _acked

      private volatile boolean _acked
      Set to true after first tagset is acked. Upon repeated failures, we may revert back to false. This prevents us getting "stuck" forever, using tags that weren't acked to deliver the next set of tags.
    • _consecutiveFailures

      private int _consecutiveFailures
      Fail count Synch on _tagSets to access this.
    • MAX_FAILS

      private static final int MAX_FAILS
      Failed tag sets before the session is dropped.
      See Also:
  • Constructor Details

    • OutboundSession

      public OutboundSession(I2PAppContext ctx, Log log, PublicKey target, SessionKey key)
      Creates state for tracking one outbound ElGamal session to a single target.
      Parameters:
      ctx - the app context
      log - the logger for the session
      target - the peer's public key
      key - the session key in use
  • Method Details

    • getTagSets

      All tag sets currently held, for tests.
      Returns:
      list of TagSet objects This is used only by renderStatusHTML(). It includes both acked and unacked TagSets.
    • ackTags

      Got an ack for these tags For tagsets delivered after the session was acked, this is a nop because the tagset was originally placed directly on the acked list. If the set was previously failed, it will be added back in.
      Parameters:
      set - the tag set that was acknowledged
    • failTags

      Didn't get an ack for these tags.
      Parameters:
      set - the tag set that failed
    • getTarget

      public PublicKey getTarget()
      The peer this session goes to.
      Returns:
      the target's public key
    • getCurrentKey

      public SessionKey getCurrentKey()
      The session key in use now.
      Returns:
      the current key
    • setCurrentKey

      public void setCurrentKey(SessionKey key)
      Replaces the session key, dropping the old tags when it changes.
      Parameters:
      key - the new session key
    • getEstablishedDate

      public long getEstablishedDate()
      When the session was established.
      Returns:
      the time, in epoch ms
    • getLastUsedDate

      public long getLastUsedDate()
      When a tag from the session was last used.
      Returns:
      the time, in epoch ms
    • expireTags

      public int expireTags()
      Expires the old tags.
      Returns:
      the number of tag sets removed
    • consumeNext

      public SessionTag consumeNext()
      Consumes the next available tag and advances.
      Returns:
      the tag, null if none are left
    • availableTags

      public int availableTags()
      Total number of tags in acked TagSets not yet expired.
      Returns:
      the total number of tags in acked TagSets
    • getLastExpirationDate

      public long getLastExpirationDate()
      The furthest tag set expiration date, after which all of the tags will have expired.
      Returns:
      the last expiration date
    • addTags

      public void addTags(TransientSessionKeyManager.TagSet set)
      Records a tag set as sent but not yet acked.
      Parameters:
      set - the tag set to add to the unacked sets
    • getAckReceived

      public boolean getAckReceived()
      Whether the outbound tag set has been acknowledged.
      Returns:
      the ack received