Changeset 22609bb


Ignore:
Timestamp:
May 29, 2009 1:57:50 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
1838ad4
Parents:
0a8cbcb
Message:
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/crypto/TransientSessionKeyManager.java

    r0a8cbcb r22609bb  
    4141    private Map<SessionTag, TagSet> _inboundTagSets;
    4242    protected I2PAppContext _context;
     43    private volatile boolean _alive;
    4344
    4445    /**
     
    7677        context.statManager().createRateStat("crypto.sessionTagsExpired", "How many tags/sessions are expired?", "Encryption", new long[] { 10*60*1000, 60*60*1000, 3*60*60*1000 });
    7778        context.statManager().createRateStat("crypto.sessionTagsRemaining", "How many tags/sessions are remaining after a cleanup?", "Encryption", new long[] { 10*60*1000, 60*60*1000, 3*60*60*1000 });
    78         SimpleScheduler.getInstance().addPeriodicEvent(new CleanupEvent(), 60*1000);
     79         _alive = true;
     80        SimpleScheduler.getInstance().addEvent(new CleanupEvent(), 60*1000);
    7981    }
    8082    private TransientSessionKeyManager() { this(null); }
    8183   
     84    public void shutdown() {
     85         _alive = false;
     86        synchronized (_inboundTagSets) {
     87            _inboundTagSets.clear();
     88        }
     89        synchronized (_outboundSessions) {
     90            _outboundSessions.clear();
     91        }
     92    }
     93
    8294    private class CleanupEvent implements SimpleTimer.TimedEvent {
    8395        public void timeReached() {
     96            if (!_alive)
     97                return;
    8498            long beforeExpire = _context.clock().now();
    8599            int expired = aggressiveExpire();
    86100            long expireTime = _context.clock().now() - beforeExpire;
    87101            _context.statManager().addRateData("crypto.sessionTagsExpired", expired, expireTime);
    88         }
    89     }
     102            SimpleScheduler.getInstance().addEvent(this, 60*1000);
     103        }
     104    }
     105
    90106
    91107    /** TagSet */
  • router/java/src/net/i2p/router/ClientManagerFacade.java

    r0a8cbcb r22609bb  
    1414import java.util.Set;
    1515
     16import net.i2p.crypto.SessionKeyManager;
    1617import net.i2p.data.Destination;
    1718import net.i2p.data.Hash;
     
    9293     */
    9394    public abstract SessionConfig getClientSessionConfig(Destination dest);
     95    public abstract SessionKeyManager getClientSessionKeyManager(Destination dest);
    9496    public void renderStatusHTML(Writer out) throws IOException { }
    9597}
  • router/java/src/net/i2p/router/DummyClientManagerFacade.java

    r0a8cbcb r22609bb  
    99 */
    1010
     11import net.i2p.crypto.SessionKeyManager;
    1112import net.i2p.data.Destination;
    1213import net.i2p.data.Hash;
     
    4142   
    4243    public SessionConfig getClientSessionConfig(Destination _dest) { return null; }
     44    public SessionKeyManager getClientSessionKeyManager(Destination _dest) { return null; }
    4345   
    4446    public void requestLeaseSet(Hash dest, LeaseSet set) {}
  • router/java/src/net/i2p/router/client/ClientConnectionRunner.java

    r0a8cbcb r22609bb  
    1818import java.util.Set;
    1919
     20import net.i2p.crypto.SessionKeyManager;
     21import net.i2p.crypto.TransientSessionKeyManager;
    2022import net.i2p.data.Destination;
    2123import net.i2p.data.Hash;
     
    6971    /** thingy that does stuff */
    7072    private I2CPMessageReader _reader;
     73    /** just for this destination */
     74    private SessionKeyManager _sessionKeyManager;
    7175    /**
    7276     * This contains the last 10 MessageIds that have had their (non-ack) status
     
    130134        if (_socket != null) try { _socket.close(); } catch (IOException ioe) { }
    131135        _messages.clear();
     136        if (_sessionKeyManager != null)
     137            _sessionKeyManager.shutdown();
    132138        if (_manager != null)
    133139            _manager.unregisterConnection(this);
     
    144150    /** current client's config */
    145151    public SessionConfig getConfig() { return _config; }
     152    /** current client's sessionkeymanager */
     153    public SessionKeyManager getSessionKeyManager() { return _sessionKeyManager; }
    146154    /** currently allocated leaseSet */
    147155    public LeaseSet getLeaseSet() { return _currentLeaseSet; }
     
    182190            _log.debug("SessionEstablished called for destination " + _destHashCache.toBase64());
    183191        _config = config;
     192        // per-dest unimplemented
     193        //if (_sessionKeyManager == null)
     194        //    _sessionKeyManager = new TransientSessionKeyManager(_context);
     195        //else
     196        //    _log.error("SessionEstablished called for twice for destination " + _destHashCache.toBase64().substring(0,4));
    184197        _manager.destinationEstablished(this);
    185198    }
  • router/java/src/net/i2p/router/client/ClientManager.java

    r0a8cbcb r22609bb  
    1717import java.util.Set;
    1818
     19import net.i2p.crypto.SessionKeyManager;
    1920import net.i2p.data.DataHelper;
    2021import net.i2p.data.Destination;
     
    311312        if (runner != null)
    312313            return runner.getConfig();
     314        else
     315            return null;
     316    }
     317   
     318    /**
     319     * Return the client's SessionKeyManager
     320     *
     321     */
     322    public SessionKeyManager getClientSessionKeyManager(Destination dest) {
     323        ClientConnectionRunner runner = getRunner(dest);
     324        if (runner != null)
     325            return runner.getSessionKeyManager();
    313326        else
    314327            return null;
  • router/java/src/net/i2p/router/client/ClientManagerFacadeImpl.java

    r0a8cbcb r22609bb  
    1515import java.util.Set;
    1616
     17import net.i2p.crypto.SessionKeyManager;
    1718import net.i2p.data.DataHelper;
    1819import net.i2p.data.Destination;
     
    200201    }
    201202   
     203    /**
     204     * Return the client's current manager or null if not connected
     205     *
     206     */
     207    public SessionKeyManager getClientSessionKeyManager(Destination dest) {
     208        if (_manager != null)
     209            return _manager.getClientSessionKeyManager(dest);
     210        else {
     211            _log.error("Null manager on getClientSessionKeyManager!");
     212            return null;
     213        }
     214    }
     215   
    202216    @Override
    203217    public void renderStatusHTML(Writer out) throws IOException {
  • router/java/src/net/i2p/router/message/GarlicMessageBuilder.java

    r0a8cbcb r22609bb  
    1515import java.util.Set;
    1616
     17import net.i2p.crypto.SessionKeyManager;
    1718import net.i2p.data.DataFormatException;
    1819import net.i2p.data.DataHelper;
     20import net.i2p.data.Destination;
    1921import net.i2p.data.PublicKey;
    2022import net.i2p.data.SessionKey;
     
    6264    private static final int LOW_THRESHOLD = 20;
    6365
    64     public static int estimateAvailableTags(RouterContext ctx, PublicKey key) {
    65         SessionKey curKey = ctx.sessionKeyManager().getCurrentKey(key);
     66    public static int estimateAvailableTags(RouterContext ctx, PublicKey key, Destination local) {
     67        // per-dest Unimplemented
     68        //SessionKeyManager skm = ctx.clientManager().getClientSessionKeyManager(local);
     69        SessionKeyManager skm = ctx.sessionKeyManager();
     70        if (skm == null)
     71            return 0;
     72        SessionKey curKey = skm.getCurrentKey(key);
    6673        if (curKey == null)
    6774            return 0;
    68         return ctx.sessionKeyManager().getAvailableTags(key, curKey);
     75        return skm.getAvailableTags(key, curKey);
    6976    }
    7077   
     
    7279        return buildMessage(ctx, config, new SessionKey(), new HashSet());
    7380    }
     81
    7482    public static GarlicMessage buildMessage(RouterContext ctx, GarlicConfig config, SessionKey wrappedKey, Set wrappedTags) {
    7583        return buildMessage(ctx, config, wrappedKey, wrappedTags, DEFAULT_TAGS);
    7684    }
     85
    7786    public static GarlicMessage buildMessage(RouterContext ctx, GarlicConfig config, SessionKey wrappedKey, Set wrappedTags, int numTagsToDeliver) {
    7887        return buildMessage(ctx, config, wrappedKey, wrappedTags, numTagsToDeliver, false);
    7988    }
     89
    8090    public static GarlicMessage buildMessage(RouterContext ctx, GarlicConfig config, SessionKey wrappedKey, Set wrappedTags, int numTagsToDeliver, boolean forceElGamal) {
    8191        Log log = ctx.logManager().getLog(GarlicMessageBuilder.class);
  • router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java

    r0a8cbcb r22609bb  
    472472        }
    473473
    474         int existingTags = GarlicMessageBuilder.estimateAvailableTags(getContext(), _leaseSet.getEncryptionKey());
     474        int existingTags = GarlicMessageBuilder.estimateAvailableTags(getContext(), _leaseSet.getEncryptionKey(), _from);
    475475        _outTunnel = selectOutboundTunnel(_to);
    476476        // boolean wantACK = _wantACK || existingTags <= 30 || getContext().random().nextInt(100) < 5;
Note: See TracChangeset for help on using the changeset viewer.