net.i2p.router.transport.tcp
Class ConnectionTagManager

java.lang.Object
  extended by net.i2p.router.transport.tcp.ConnectionTagManager
Direct Known Subclasses:
PersistentConnectionTagManager

public class ConnectionTagManager
extends java.lang.Object

Organize the tags used to connect with peers.


Field Summary
protected  Log _log
           
static int MAX_CONNECTION_TAGS
          Only keep the keys and tags for up to *cough* 10,000 peers (everyone else will need to use a full DH rekey).
 
Constructor Summary
ConnectionTagManager(RouterContext context)
           
 
Method Summary
protected  RouterContext getContext()
           
 SessionKey getKey(ByteArray tag)
           
 SessionKey getKey(Hash peer)
           
 ByteArray getTag(Hash peer)
          Retrieve the associated tag (but do not consume it)
protected  void initialize()
           
protected  void initializeData(java.util.Map keyByPeer, java.util.Map tagByPeer, java.util.Map peerByTag)
           
 void replaceTag(Hash peer, ByteArray newTag, SessionKey key)
          Update the tag associated with a peer, dropping the old one
protected  void saveTags(java.util.Map keyByPeer, java.util.Map tagByPeer)
          Save the tags/keys associated with the peer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_log

protected Log _log

MAX_CONNECTION_TAGS

public static final int MAX_CONNECTION_TAGS
Only keep the keys and tags for up to *cough* 10,000 peers (everyone else will need to use a full DH rekey). Ok, yeah, 10,000 is absurd for the TCP transport anyway, but we need a limit, and this eats up at most 1MB (96 bytes per peer). Later we may add another mapping to drop the oldest ones first, but who cares for now.

See Also:
Constant Field Values
Constructor Detail

ConnectionTagManager

public ConnectionTagManager(RouterContext context)
Method Detail

initialize

protected void initialize()

initializeData

protected void initializeData(java.util.Map keyByPeer,
                              java.util.Map tagByPeer,
                              java.util.Map peerByTag)

getTag

public ByteArray getTag(Hash peer)
Retrieve the associated tag (but do not consume it)


getKey

public SessionKey getKey(Hash peer)

getKey

public SessionKey getKey(ByteArray tag)

replaceTag

public void replaceTag(Hash peer,
                       ByteArray newTag,
                       SessionKey key)
Update the tag associated with a peer, dropping the old one


saveTags

protected void saveTags(java.util.Map keyByPeer,
                        java.util.Map tagByPeer)
Save the tags/keys associated with the peer.

Parameters:
keyByPeer - H(routerIdentity) to SessionKey
tagByPeer - H(routerIdentity) to ByteArray

getContext

protected RouterContext getContext()