java.lang.Object
net.i2p.router.crypto.TransientSessionKeyManager.OutboundSession
- Enclosing class:
TransientSessionKeyManager
The state for a crypto session to a single public key.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanSet to true after first tagset is acked.private intFail count Synch on _tagSets to access this.private final I2PAppContextThe app context.private SessionKeyKey for the most recently sent tag set.private final longWhen the session was created.private longWhen a tag was last consumed.private final LogLogger for this session.private final List<TransientSessionKeyManager.TagSet> As tagsets are acked, they go here.private final PublicKeyThe peer's public key.private final Set<TransientSessionKeyManager.TagSet> Before the first ack, all tagsets go here.private static final intFailed tag sets before the session is dropped.Constructor Summary
ConstructorsConstructorDescriptionOutboundSession(I2PAppContext ctx, Log log, PublicKey target, SessionKey key) Creates state for tracking one outbound ElGamal session to a single target.Method Summary
Public MethodsModifier and TypeMethodDescription(package private) voidGot 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.voidRecords a tag set as sent but not yet acked.intTotal number of tags in acked TagSets not yet expired.Consumes the next available tag and advances.intExpires the old tags.(package private) voidDidn't get an ack for these tags.booleanWhether the outbound tag set has been acknowledged.The session key in use now.longWhen the session was established.longThe furthest tag set expiration date, after which all of the tags will have expired.longWhen a tag from the session was last used.(package private) List<TransientSessionKeyManager.TagSet> All tag sets currently held, for tests.The peer this session goes to.voidsetCurrentKey(SessionKey key) Replaces the session key, dropping the old tags when it changes.
Field Details
_context
The app context._log
Logger for this session._target
The peer's public key._currentKey
Key for the most recently sent tag set._established
private final long _establishedWhen the session was created._lastUsed
private long _lastUsedWhen a tag was last consumed._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
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 _ackedSet 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 _consecutiveFailuresFail count Synch on _tagSets to access this.MAX_FAILS
private static final int MAX_FAILSFailed tag sets before the session is dropped.- See Also:
Constructor Details
OutboundSession
Creates state for tracking one outbound ElGamal session to a single target.- Parameters:
ctx- the app contextlog- the logger for the sessiontarget- the peer's public keykey- the session key in use
Method Details
getTagSets
List<TransientSessionKeyManager.TagSet> 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
getCurrentKey
setCurrentKey
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
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
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