Changeset 9cd90b0 for router


Ignore:
Timestamp:
Feb 23, 2019 5:03:04 PM (14 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
e1385a7
Parents:
5440a34
Message:

NetDB: Use published date, not earliest lease expiration, for LS2 comparisons
Fix earliest LS expiration adjustment when publishing for LS2,
so .38 routers won't reject as not newer
Don't start new store after verify fail if we've already done so
Increase flood candidates for LS2
Version checks for encrypted LS2
FVSJ cleanups
log tweaks, javadocs

Location:
router/java/src/net/i2p/router
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/RouterVersion.java

    r5440a34 r9cd90b0  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 8;
     21    public final static long BUILD = 9;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/client/ClientConnectionRunner.java

    r5440a34 r9cd90b0  
    608608                state.setIsSuccessful(true);
    609609                if (_log.shouldLog(Log.DEBUG))
    610                     _log.debug("LeaseSet created fully: " + state + " / " + ls);
     610                    _log.debug("LeaseSet created fully: " + state + '\n' + ls);
    611611                sp.leaseRequest = null;
    612612                _consecutiveLeaseRequestFails = 0;
     
    814814        int leases = set.getLeaseCount();
    815815        // synch so _currentLeaseSet isn't changed out from under us
    816         LeaseSet current = null;
     816        LeaseSet current;
    817817        Destination dest = sp.dest;
    818818        LeaseRequestState state;
     
    876876                    // so the timer won't fire off with an older LS request
    877877                    sp.rerequestTimer = null;
    878                     sp.leaseRequest = state = new LeaseRequestState(onCreateJob, onFailedJob,
     878                    long earliest = (current != null) ? current.getEarliestLeaseDate() : 0;
     879                    sp.leaseRequest = state = new LeaseRequestState(onCreateJob, onFailedJob, earliest,
    879880                                                                _context.clock().now() + expirationTime, set);
    880881                    if (_log.shouldLog(Log.DEBUG))
  • router/java/src/net/i2p/router/client/LeaseRequestState.java

    r5440a34 r9cd90b0  
    2626    private final Job _onFailed;
    2727    private final long _expiration;
     28    private final long _currentEarliestLeastDate;
    2829    private boolean _successful;
    2930
    3031    /**
     32     *  @param currentEarliestLeastDate absolute time, the earliest expiration in
     33     *         the current LS (NOT the requested one), or 0 if none
    3134     *  @param expiration absolute time, when the request expires (not when the LS expires)
    3235     *  @param requested LeaseSet with requested leases - this object must be updated to contain the
     
    3437     *             The LeaseSet contains Leases and destination only, it is unsigned.
    3538     */
    36     public LeaseRequestState(Job onGranted, Job onFailed, long expiration, LeaseSet requested) {
     39    public LeaseRequestState(Job onGranted, Job onFailed, long currentEarliestLeastDate,
     40                             long expiration, LeaseSet requested) {
    3741        _onGranted = onGranted;
    3842        _onFailed = onFailed;
     43        _currentEarliestLeastDate = currentEarliestLeastDate;
    3944        _expiration = expiration;
    4045        _requestedLeaseSet = requested;
     
    7075    public long getExpiration() { return _expiration; }
    7176
     77    /**
     78     * The earliest lease expiration time in the current LS (NOT the requested one),
     79     * or 0 if none.
     80     *
     81     * @since 0.9.39
     82     */
     83    public long getCurrentEarliestLeaseDate() { return _currentEarliestLeastDate; }
     84
    7285    /** whether the request was successful in the time allotted */
    7386    public boolean getIsSuccessful() { return _successful; }
  • router/java/src/net/i2p/router/client/RequestLeaseSetJob.java

    r5440a34 r9cd90b0  
    1010
    1111import java.util.Date;
     12import java.util.Properties;
    1213
    1314import net.i2p.data.Lease;
     
    1718import net.i2p.data.i2cp.RequestLeaseSetMessage;
    1819import net.i2p.data.i2cp.RequestVariableLeaseSetMessage;
     20import net.i2p.data.i2cp.SessionConfig;
    1921import net.i2p.data.i2cp.SessionId;
    2022import net.i2p.router.JobImpl;
     
    5456        if (_runner.isDead()) return;
    5557       
     58        boolean isLS2 = false;
     59        SessionConfig cfg = _runner.getPrimaryConfig();
     60        if (cfg != null) {
     61            Properties props = cfg.getOptions();
     62            if (props != null) {
     63                String lsType = props.getProperty("i2cp.leaseSetType");
     64                if (lsType != null && !lsType.equals("1"))
     65                    isLS2 = true;
     66            }
     67        }
     68       
    5669        LeaseSet requested = _requestState.getRequested();
    5770        long endTime = requested.getEarliestLeaseDate();
     
    6073        // this will force the floodfill to flood each new version;
    6174        // otherwise it won't if the earliest time hasn't changed.
    62         long fudge = MAX_FUDGE - ((endTime - getContext().clock().now()) / (10*60*1000 / MAX_FUDGE));
     75
     76        if (isLS2) {
     77            // fix for 0.9.38 floodfills,
     78            // adding some ms doesn't work since the dates are truncated,
     79            // and 0.9.38 did not use LeaseSet2.getPublished()
     80            long earliest = 1000 + _requestState.getCurrentEarliestLeaseDate();
     81            if (endTime < earliest)
     82                endTime = earliest;
     83        } else {
     84            long diff = endTime - getContext().clock().now();
     85            long fudge = MAX_FUDGE - (diff / (10*60*1000 / MAX_FUDGE));
     86            endTime += fudge;
     87        }
    6388        //if (_log.shouldLog(Log.DEBUG))
    6489        //    _log.debug("Adding fudge " + fudge);
    65         endTime += fudge;
    6690
    6791        SessionId id = _runner.getSessionId(requested.getDestination().calculateHash());
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java

    r5440a34 r9cd90b0  
    209209        Hash rkey = gen.getRoutingKey(key);
    210210        FloodfillPeerSelector sel = (FloodfillPeerSelector)getPeerSelector();
    211         List<Hash> peers = sel.selectFloodfillParticipants(rkey, MAX_TO_FLOOD, getKBuckets());
     211        final int type = ds.getType();
     212        final boolean isls2 = ds.isLeaseSet() && type != DatabaseEntry.KEY_TYPE_LEASESET;
     213        int max = MAX_TO_FLOOD;
     214        // increase candidates because we will be skipping some
     215        if (type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2)
     216            max *= 4;
     217        else if (isls2)
     218            max *= 2;
     219        List<Hash> peers = sel.selectFloodfillParticipants(rkey, max, getKBuckets());
     220
    212221        // todo key cert skip?
    213222        long until = gen.getTimeTillMidnight();
    214223        if (until < NEXT_RKEY_LS_ADVANCE_TIME ||
    215             (ds.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO && until < NEXT_RKEY_RI_ADVANCE_TIME)) {
     224            (type == DatabaseEntry.KEY_TYPE_ROUTERINFO && until < NEXT_RKEY_RI_ADVANCE_TIME)) {
    216225            // to avoid lookup faulures after midnight, also flood to some closest to the
    217226            // next routing key for a period of time before midnight.
     
    230239                    i++;
    231240                }
    232             }
    233             if (i > 0 && _log.shouldLog(Log.INFO))
    234                 _log.info("Flooding the entry for " + key + " to " + i + " more, just before midnight");
     241                if (i >= MAX_TO_FLOOD)
     242                    break;
     243            }
     244            if (i > 0) {
     245                max += i;
     246                if (_log.shouldInfo())
     247                    _log.info("Flooding the entry for " + key + " to " + i + " more, just before midnight");
     248            }
    235249        }
    236250        int flooded = 0;
    237         boolean isls2 = ds.isLeaseSet() && ds.getType() != DatabaseEntry.KEY_TYPE_LEASESET;
    238251        for (int i = 0; i < peers.size(); i++) {
    239252            Hash peer = peers.get(i);
    240253            RouterInfo target = lookupRouterInfoLocally(peer);
    241             if ( (target == null) || (_context.banlist().isBanlisted(peer)) )
    242                 continue;
    243             // Don't flood an RI back to itself
    244             // Not necessary, a ff will do its own flooding (reply token == 0)
    245             // But other implementations may not...
    246             if (ds.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO && peer.equals(key))
    247                 continue;
    248             if (peer.equals(_context.routerHash()))
    249                 continue;
    250             // min version checks
    251             if (isls2 && !StoreJob.shouldStoreLS2To(target))
    252                 continue;
    253             if (!StoreJob.shouldStoreTo(target))
     254            if (!shouldFloodTo(key, type, peer, target))
    254255                continue;
    255256            DatabaseStoreMessage msg = new DatabaseStoreMessage(_context);
     
    266267            if (_log.shouldLog(Log.INFO))
    267268                _log.info("Flooding the entry for " + key.toBase64() + " to " + peer.toBase64());
     269            if (flooded >= MAX_TO_FLOOD)
     270                break;
    268271        }
    269272       
    270273        if (_log.shouldLog(Log.INFO))
    271274            _log.info("Flooded the data to " + flooded + " of " + peers.size() + " peers");
     275    }
     276
     277    /** @since 0.9.39 */
     278    private boolean shouldFloodTo(Hash key, int type, Hash peer, RouterInfo target) {
     279       if ( (target == null) || (_context.banlist().isBanlisted(peer)) )
     280           return false;
     281       // Don't flood an RI back to itself
     282       // Not necessary, a ff will do its own flooding (reply token == 0)
     283       // But other implementations may not...
     284       if (type == DatabaseEntry.KEY_TYPE_ROUTERINFO && peer.equals(key))
     285           return false;
     286       if (peer.equals(_context.routerHash()))
     287           return false;
     288       // min version checks
     289       if (type != DatabaseEntry.KEY_TYPE_ROUTERINFO && type != DatabaseEntry.KEY_TYPE_LS2 &&
     290           !StoreJob.shouldStoreLS2To(target))
     291           return false;
     292       if (type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2 &&
     293           !StoreJob.shouldStoreEncLS2To(target))
     294           return false;
     295       if (!StoreJob.shouldStoreTo(target))
     296           return false;
     297        return true;
    272298    }
    273299
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillStoreJob.java

    r5440a34 r9cd90b0  
    1414import net.i2p.data.DatabaseEntry;
    1515import net.i2p.data.Hash;
     16import net.i2p.data.LeaseSet2;
    1617import net.i2p.router.Job;
    1718import net.i2p.router.RouterContext;
     
    5960        super.succeed();
    6061
     62        final boolean shouldLog = _log.shouldInfo();
     63
    6164            if (_facade.isVerifyInProgress(_state.getTarget())) {
    62                 if (_log.shouldLog(Log.INFO))
     65                if (shouldLog)
    6366                    _log.info("Skipping verify, one already in progress for: " + _state.getTarget());
    6467                return;
    6568            }
    6669            if (getContext().router().gracefulShutdownInProgress()) {
    67                 if (_log.shouldLog(Log.INFO))
     70                if (shouldLog)
    6871                    _log.info("Skipping verify, shutdown in progress for: " + _state.getTarget());
    6972                return;
     
    7275            // it finds something stamped with that time or newer.
    7376            DatabaseEntry data = _state.getData();
    74             boolean isRouterInfo = data.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO;
     77            final int type = data.getType();
     78            final boolean isRouterInfo = type == DatabaseEntry.KEY_TYPE_ROUTERINFO;
    7579            // default false since 0.9.7.1
    7680            if (isRouterInfo && !getContext().getBooleanProperty(PROP_RI_VERIFY)) {
     
    7983            }
    8084
    81             long published = data.getDate();
    82             boolean isls2 = data.isLeaseSet() && data.getType() != DatabaseEntry.KEY_TYPE_LEASESET;
    83 
     85            final boolean isls2 = data.isLeaseSet() && type != DatabaseEntry.KEY_TYPE_LEASESET;
     86            long published;
     87            if (isls2) {
     88                LeaseSet2 ls2 = (LeaseSet2) data;
     89                published = ls2.getPublished();
     90            } else {
     91                published = data.getDate();
     92            }
    8493            // we should always have exactly one successful entry
    8594            Hash sentTo = null;
     
    8796                sentTo = _state.getSuccessful().iterator().next();
    8897            } catch (NoSuchElementException nsee) {}
    89             getContext().jobQueue().addJob(new FloodfillVerifyStoreJob(getContext(), _state.getTarget(),
    90                                                                        published, isRouterInfo, isls2,
    91                                                                        sentTo, _facade));
     98            Job fvsj = new FloodfillVerifyStoreJob(getContext(), _state.getTarget(),
     99                                                   published, type,
     100                                                   sentTo, _facade);
     101            if (shouldLog)
     102                _log.info(getJobId() + ": Succeeded sending key " + _state.getTarget() +
     103                          ", queueing verify job " + fvsj.getJobId());
     104            getContext().jobQueue().addJob(fvsj);
    92105    }
    93106   
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillVerifyStoreJob.java

    r5440a34 r9cd90b0  
    1010import net.i2p.data.Hash;
    1111import net.i2p.data.LeaseSet;
     12import net.i2p.data.LeaseSet2;
    1213import net.i2p.data.router.RouterInfo;
    1314import net.i2p.data.i2np.DatabaseLookupMessage;
     
    1718import net.i2p.router.JobImpl;
    1819import net.i2p.router.MessageSelector;
     20import net.i2p.router.ProfileManager;
    1921import net.i2p.router.ReplyJob;
    2022import net.i2p.router.RouterContext;
     
    3840    private long _sendTime;
    3941    private final long _published;
     42    private final int _type;
    4043    private final boolean _isRouterInfo;
    4144    private final boolean _isLS2;
     
    5255    /**
    5356     *  Delay a few seconds, then start the verify
     57     *  @param published getDate() for RI or LS1, getPublished() for LS2
    5458     *  @param sentTo who to give the credit or blame to, can be null
    5559     */
    56     public FloodfillVerifyStoreJob(RouterContext ctx, Hash key, long published, boolean isRouterInfo,
    57                                    boolean isLS2, Hash sentTo, FloodfillNetworkDatabaseFacade facade) {
     60    public FloodfillVerifyStoreJob(RouterContext ctx, Hash key, long published, int type,
     61                                   Hash sentTo, FloodfillNetworkDatabaseFacade facade) {
    5862        super(ctx);
    5963        facade.verifyStarted(key);
    6064        _key = key;
    6165        _published = published;
    62         _isRouterInfo = isRouterInfo;
    63         _isLS2 = isLS2;
     66        _isRouterInfo = type == DatabaseEntry.KEY_TYPE_ROUTERINFO;
     67        _isLS2 = !_isRouterInfo && type != DatabaseEntry.KEY_TYPE_LEASESET;
     68        _type = type;
    6469        _log = ctx.logManager().getLog(getClass());
    6570        _sentTo = sentTo;
     
    149154            }
    150155            if (_log.shouldLog(Log.INFO))
    151                 _log.info("Requesting encrypted reply from " + _target + ' ' + sess.key + ' ' + sess.tag);
     156                _log.info(getJobId() + ": Requesting encrypted reply from " + _target + ' ' + sess.key + ' ' + sess.tag);
    152157            lookup.setReplySession(sess.key, sess.tag);
    153158        }
     
    167172
    168173        if (_log.shouldLog(Log.INFO))
    169             _log.info("Starting verify (stored " + _key + " to " + _sentTo + "), asking " + _target);
     174            _log.info(getJobId() + ": Starting verify (stored " + _key + " to " + _sentTo + "), asking " + _target);
    170175        _sendTime = getContext().clock().now();
    171176        _expiration = _sendTime + VERIFY_TIMEOUT;
     
    200205                //if (ri != null && StoreJob.supportsCert(ri, keyCert)) {
    201206                if (ri != null && StoreJob.shouldStoreTo(ri) &&
    202                     (!_isLS2 || StoreJob.shouldStoreLS2To(ri))) {
     207                    (!_isLS2 || (StoreJob.shouldStoreLS2To(ri) &&
     208                                 (_type != DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2 || StoreJob.shouldStoreEncLS2To(ri))))) {
    203209                    Set<String> peerIPs = new MaskedIPSet(getContext(), ri, IP_CLOSE_BYTES);
    204210                    if (!_ipSet.containsAny(peerIPs)) {
     
    222228       
    223229        if (_log.shouldLog(Log.WARN))
    224             _log.warn("No other peers to verify floodfill with, using the one we sent to");
     230            _log.warn(getJobId() + ": No other peers to verify floodfill with, using the one we sent to");
    225231        return _sentTo;
    226232    }
     
    260266    private class VerifyReplyJob extends JobImpl implements ReplyJob {
    261267        private I2NPMessage _message;
     268
    262269        public VerifyReplyJob(RouterContext ctx) {
    263270            super(ctx);
    264271        }
     272
    265273        public String getName() { return "Handle floodfill verification reply"; }
     274
    266275        public void runJob() {
    267             long delay = getContext().clock().now() - _sendTime;
     276            final RouterContext ctx = getContext();
     277            long delay = ctx.clock().now() - _sendTime;
    268278            if (_wrappedMessage != null)
    269279                _wrappedMessage.acked();
    270280            _facade.verifyFinished(_key);
    271             if (_message instanceof DatabaseStoreMessage) {
     281            final ProfileManager pm = ctx.profileManager();
     282            final int type = _message.getType();
     283            if (type == DatabaseStoreMessage.MESSAGE_TYPE) {
    272284                // Verify it's as recent as the one we sent
    273285                DatabaseStoreMessage dsm = (DatabaseStoreMessage)_message;
    274                 boolean success = dsm.getEntry().getDate() >= _published;
     286                DatabaseEntry entry = dsm.getEntry();
     287                long newDate;
     288                boolean success;
     289                if (_isLS2 &&
     290                    entry.getType() != DatabaseEntry.KEY_TYPE_ROUTERINFO &&
     291                    entry.getType() != DatabaseEntry.KEY_TYPE_LEASESET) {
     292                    LeaseSet2 ls2 = (LeaseSet2) entry;
     293                    success = ls2.getPublished() >= _published;
     294                } else {
     295                    success = entry.getDate() >= _published;
     296                }
    275297                if (success) {
    276298                    // store ok, w00t!
    277                     getContext().profileManager().dbLookupSuccessful(_target, delay);
     299                    pm.dbLookupSuccessful(_target, delay);
    278300                    if (_sentTo != null)
    279                         getContext().profileManager().dbStoreSuccessful(_sentTo);
    280                     getContext().statManager().addRateData("netDb.floodfillVerifyOK", delay);
     301                        pm.dbStoreSuccessful(_sentTo);
     302                    ctx.statManager().addRateData("netDb.floodfillVerifyOK", delay);
    281303                    if (_log.shouldLog(Log.INFO))
    282                         _log.info("Verify success for " + _key);
     304                        _log.info(getJobId() + ": Verify success for " + _key);
    283305                    if (_isRouterInfo)
    284306                        _facade.routerInfoPublishSuccessful();
    285307                    return;
    286308                }
    287                 if (_log.shouldLog(Log.WARN))
    288                     _log.warn("Verify failed (older) for " + _key);
    289                 if (_log.shouldLog(Log.INFO))
    290                     _log.info("Rcvd older data: " + dsm.getEntry());
    291             } else if (_message instanceof DatabaseSearchReplyMessage) {
     309                if (_log.shouldWarn()) {
     310                    _log.warn(getJobId() + ": Verify failed (older) for " + _key);
     311                    if (_log.shouldInfo())
     312                        _log.info(getJobId() + ": Rcvd older data: " + dsm.getEntry());
     313                }
     314            } else if (type == DatabaseSearchReplyMessage.MESSAGE_TYPE) {
    292315                DatabaseSearchReplyMessage dsrm = (DatabaseSearchReplyMessage) _message;
    293316                // assume 0 old, all new, 0 invalid, 0 dup
    294                 getContext().profileManager().dbLookupReply(_target,  0,
     317                pm.dbLookupReply(_target,  0,
    295318                                dsrm.getNumReplies(), 0, 0, delay);
    296319                if (_log.shouldLog(Log.WARN))
    297                     _log.warn("Verify failed (DSRM) for " + _key);
     320                    _log.warn(getJobId() + ": Verify failed (DSRM) for " + _key);
    298321                // only for RI... LS too dangerous?
    299322                if (_isRouterInfo)
    300                     getContext().jobQueue().addJob(new SingleLookupJob(getContext(), dsrm));
     323                    ctx.jobQueue().addJob(new SingleLookupJob(ctx, dsrm));
    301324            }
    302325            // store failed, boo, hiss!
    303326            // blame the sent-to peer, but not the verify peer
    304327            if (_sentTo != null)
    305                 getContext().profileManager().dbStoreFailed(_sentTo);
     328                pm.dbStoreFailed(_sentTo);
    306329            // Blame the verify peer also.
    307330            // We must use dbLookupFailed() or dbStoreFailed(), neither of which is exactly correct,
     
    310333            // though it is the real problem.
    311334            if (_target != null && !_target.equals(_sentTo))
    312                 getContext().profileManager().dbLookupFailed(_target);
    313             getContext().statManager().addRateData("netDb.floodfillVerifyFail", delay);
     335                pm.dbLookupFailed(_target);
     336            ctx.statManager().addRateData("netDb.floodfillVerifyFail", delay);
    314337            resend();
    315338        }       
     339
    316340        public void setMessage(I2NPMessage message) { _message = message; }
    317341    }
     
    328352        DatabaseEntry ds = _facade.lookupLocally(_key);
    329353        if (ds != null) {
     354            // By the time we get here, a minute or more after the store started,
     355            // we may have already started a new store
     356            // (probably, for LS, and we don't verify by default for RI)
     357            long newDate;
     358            if (_isLS2 &&
     359                ds.getType() != DatabaseEntry.KEY_TYPE_ROUTERINFO &&
     360                ds.getType() != DatabaseEntry.KEY_TYPE_LEASESET) {
     361                LeaseSet2 ls2 = (LeaseSet2) ds;
     362                newDate = ls2.getPublished();
     363            } else {
     364                newDate = ds.getDate();
     365            }
     366            if (newDate > _published) {
     367                if (_log.shouldInfo())
     368                    _log.info(getJobId() + ": Verify failed, but new store already happened for: " + _key);
     369                return;
     370            }
    330371            Set<Hash> toSkip = new HashSet<Hash>(2);
    331372            if (_sentTo != null)
     
    333374            if (_target != null)
    334375                toSkip.add(_target);
     376            if (_log.shouldWarn())
     377                _log.warn(getJobId() + ": Verify failed, starting new store for: " + _key);
    335378            _facade.sendStore(_key, ds, null, null, FloodfillNetworkDatabaseFacade.PUBLISH_TIMEOUT, toSkip);
    336379        }
     
    351394            getContext().statManager().addRateData("netDb.floodfillVerifyTimeout", getContext().clock().now() - _sendTime);
    352395            if (_log.shouldLog(Log.WARN))
    353                 _log.warn("Verify timed out for: " + _key);
     396                _log.warn(getJobId() + ": Verify timed out for: " + _key);
    354397            if (_ignore.size() < MAX_PEERS_TO_TRY) {
    355398                // Don't resend, simply rerun FVSJ.this inline and
  • router/java/src/net/i2p/router/networkdb/kademlia/HandleFloodfillDatabaseStoreMessageJob.java

    r5440a34 r9cd90b0  
    1515import net.i2p.data.Hash;
    1616import net.i2p.data.LeaseSet;
     17import net.i2p.data.LeaseSet2;
    1718import net.i2p.data.TunnelId;
    1819import net.i2p.data.router.RouterAddress;
     
    114115                    wasNew = true;
    115116                    // If it is in our keyspace and we are talking to it
    116 
    117 
    118117                    if (match.getReceivedAsPublished())
    119118                        ls.setReceivedAsPublished(true);
     119                } else if (type != DatabaseEntry.KEY_TYPE_LEASESET &&
     120                           match.getType() != DatabaseEntry.KEY_TYPE_LEASESET) {
     121                    LeaseSet2 ls2 = (LeaseSet2) ls;
     122                    LeaseSet2 match2 = (LeaseSet2) match;
     123                    if (match2.getPublished() < ls2.getPublished()) {
     124                        wasNew = true;
     125                        if (match.getReceivedAsPublished())
     126                            ls.setReceivedAsPublished(true);
     127                    } else {
     128                        wasNew = false;
     129                    }
    120130                } else {
    121131                    wasNew = false;
     
    229239                }
    230240                long floodBegin = System.currentTimeMillis();
    231                 _facade.flood(_message.getEntry());
     241                _facade.flood(entry);
    232242                // ERR: see comment in HandleDatabaseLookupMessageJob regarding hidden mode
    233243                //else if (!_message.getRouterInfo().isHidden())
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    r5440a34 r9cd90b0  
    936936            boolean validFamily = fkc.verify(routerInfo);
    937937            if (!validFamily) {
    938                 if (_log.shouldWarn())
    939                     _log.warn("Bad family sig: " + routerInfo.getHash());
     938                if (_log.shouldInfo())
     939                    _log.info("Bad family sig: " + routerInfo.getHash());
    940940            }
    941941            // todo store in RI
  • router/java/src/net/i2p/router/networkdb/kademlia/RepublishLeaseSetJob.java

    r5440a34 r9cd90b0  
    8888    }
    8989
     90    /**
     91     * @return last attempted publish time, or 0 if never
     92     */
    9093    public long lastPublished() {
    9194        return _lastPublished;
  • router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java

    r5440a34 r9cd90b0  
    5454    private final static int REDUNDANCY = 4; // we want the data sent to 6 peers
    5555    private final static int STORE_PRIORITY = OutNetMessage.PRIORITY_MY_NETDB_STORE;
    56    
     56
    5757    /**
    5858     * Send a data structure to the floodfills
     
    9090                _connectMask = ConnectChecker.ANY_V4;
    9191        }
     92        if (_log.shouldLog(Log.DEBUG))
     93            _log.debug(getJobId() + ": New store job for " + data, new Exception("I did it"));
    9294    }
    9395
    9496    public String getName() { return "Kademlia NetDb Store";}
     97
    9598    public void runJob() {
    9699        sendNext();
     
    195198                    _state.addSkipped(peer);
    196199                    skipped++;
     200                } else if (type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2 &&
     201                           !shouldStoreEncLS2To((RouterInfo)ds)) {
     202                    if (_log.shouldInfo())
     203                        _log.info(getJobId() + ": Skipping router that doesn't support LS2 " + peer);
     204                    _state.addSkipped(peer);
     205                    skipped++;
    197206                } else if (isls2 &&
    198207                           !shouldStoreLS2To((RouterInfo)ds)) {
     
    411420   
    412421            if (_log.shouldLog(Log.DEBUG))
    413                 _log.debug("sending store to " + peer.getIdentity().getHash() + " through " + outTunnel + ": " + msg);
     422                _log.debug(getJobId() + ": sending store to " + peer.getIdentity().getHash() + " through " + outTunnel + ": " + msg);
    414423            getContext().messageRegistry().registerPending(selector, onReply, onFail);
    415424            getContext().tunnelDispatcher().dispatchOutbound(msg, outTunnel.getSendTunnelId(0), null, to);
     
    477486   
    478487            if (_log.shouldLog(Log.DEBUG)) {
    479                 _log.debug("sending encrypted store to " + peer.getIdentity().getHash() + " through " + outTunnel + ": " + sent);
     488                _log.debug(getJobId() + ": sending encrypted store to " + peer.getIdentity().getHash() + " through " + outTunnel + ": " + sent);
    480489            }
    481490            getContext().messageRegistry().registerPending(selector, onReply, onFail);
     
    513522
    514523    /**
    515      * Is it too old?
     524     * Is it new enough?
    516525     * @since 0.9.33
    517526     */
     
    525534
    526535    /**
    527      * Is it too old?
     536     * Is it new enough?
    528537     * @since 0.9.38
    529538     */
     
    531540        String v = ri.getVersion();
    532541        return VersionComparator.comp(v, MIN_STORE_LS2_VERSION) >= 0;
     542    }
     543
     544    /**
     545     * Was supported in 38, but they're now sigtype 11 which wasn't added until 39
     546     * @since 0.9.39
     547     */
     548    public static final String MIN_STORE_ENCLS2_VERSION = "0.9.39";
     549
     550    /**
     551     * Is it new enough?
     552     * @since 0.9.38
     553     */
     554    static boolean shouldStoreEncLS2To(RouterInfo ri) {
     555        String v = ri.getVersion();
     556        return VersionComparator.comp(v, MIN_STORE_ENCLS2_VERSION) >= 0;
    533557    }
    534558
     
    576600            if ( (_sendThrough != null) && (_msgSize > 0) ) {
    577601                if (_log.shouldDebug())
    578                     _log.debug("sent a " + _msgSize + " byte netDb message through tunnel " + _sendThrough + " after " + howLong);
     602                    _log.debug(StoreJob.this.getJobId() + ": sent a " + _msgSize + " byte netDb message through tunnel " + _sendThrough + " after " + howLong);
    579603                for (int i = 0; i < _sendThrough.getLength(); i++)
    580604                    getContext().profileManager().tunnelDataPushed(_sendThrough.getPeer(i), howLong, _msgSize);
     
    635659     */
    636660    protected void succeed() {
    637         if (_log.shouldLog(Log.INFO))
     661        if (_log.shouldInfo()) {
    638662            _log.info(getJobId() + ": Succeeded sending key " + _state.getTarget());
    639         if (_log.shouldLog(Log.DEBUG))
    640             _log.debug(getJobId() + ": State of successful send: " + _state);
     663            if (_log.shouldDebug())
     664                _log.debug(getJobId() + ": State of successful send: " + _state);
     665        }
    641666        if (_onSuccess != null)
    642667            getContext().jobQueue().addJob(_onSuccess);
     
    649674     */
    650675    protected void fail() {
    651         if (_log.shouldLog(Log.INFO))
     676        if (_log.shouldInfo()) {
    652677            _log.info(getJobId() + ": Failed sending key " + _state.getTarget());
    653         if (_log.shouldLog(Log.DEBUG))
    654             _log.debug(getJobId() + ": State of failed send: " + _state, new Exception("Who failed me?"));
     678            if (_log.shouldDebug())
     679                _log.debug(getJobId() + ": State of failed send: " + _state, new Exception("Who failed me?"));
     680        }
    655681        if (_onFailure != null)
    656682            getContext().jobQueue().addJob(_onFailure);
  • router/java/src/net/i2p/router/networkdb/kademlia/TransientDataStore.java

    r5440a34 r9cd90b0  
    1919import net.i2p.data.Hash;
    2020import net.i2p.data.LeaseSet;
     21import net.i2p.data.LeaseSet2;
    2122import net.i2p.data.router.RouterInfo;
    2223import net.i2p.router.RouterContext;
     
    154155            if (old != null) {
    155156                LeaseSet ols = (LeaseSet)old;
    156                 if (ls.getEarliestLeaseDate() < ols.getEarliestLeaseDate()) {
    157                     if (_log.shouldLog(Log.INFO))
    158                         _log.info("Almost clobbered an old leaseSet! " + key + ": [old expires " + new Date(ols.getEarliestLeaseDate()) +
    159                                   " new on " + new Date(ls.getEarliestLeaseDate()) + ']');
    160                 } else if (ls.getEarliestLeaseDate() == ols.getEarliestLeaseDate()) {
     157                long oldDate, newDate;
     158                if (type != DatabaseEntry.KEY_TYPE_LEASESET &&
     159                    ols.getType() != DatabaseEntry.KEY_TYPE_LEASESET) {
     160                    LeaseSet2 ls2 = (LeaseSet2) ls;
     161                    LeaseSet2 ols2 = (LeaseSet2) ols;
     162                    oldDate = ols2.getPublished();
     163                    newDate = ls2.getPublished();
     164                } else {
     165                    oldDate = ols.getEarliestLeaseDate();
     166                    newDate = ls.getEarliestLeaseDate();
     167                }
     168
     169                if (newDate < oldDate) {
     170                    if (_log.shouldLog(Log.INFO))
     171                        _log.info("Almost clobbered an old leaseSet! " + key + ": [old " + new Date(oldDate) +
     172                                  " new " + new Date(newDate) + ']');
     173                } else if (newDate == oldDate) {
    161174                    if (_log.shouldLog(Log.INFO))
    162175                        _log.info("Duplicate " + key);
    163176                } else {
    164177                    if (_log.shouldLog(Log.INFO)) {
    165                         _log.info("Updated old leaseSet " + key + ": [old expires " + new Date(ols.getEarliestLeaseDate()) +
    166                                   " new on " + new Date(ls.getEarliestLeaseDate()) + ']');
     178                        _log.info("Updated old leaseSet " + key + ": [old " + new Date(oldDate) +
     179                                  " new " + new Date(newDate) + ']');
    167180                        if (_log.shouldLog(Log.DEBUG))
    168181                            _log.debug("RAP? " + ls.getReceivedAsPublished() + " RAR? " + ls.getReceivedAsReply());
Note: See TracChangeset for help on using the changeset viewer.