Changeset 5b1b4ac for router


Ignore:
Timestamp:
Mar 6, 2019 3:28:47 PM (16 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
95366c0
Parents:
10bae6a
Message:

NetDB: Fix flood version check, add version check for RedDSA

Location:
router/java/src/net/i2p/router/networkdb/kademlia
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java

    r10bae6a r5b1b4ac  
    77import java.util.Set;
    88
     9import net.i2p.crypto.SigType;
    910import net.i2p.data.DatabaseEntry;
    1011import net.i2p.data.Destination;
     
    213214        FloodfillPeerSelector sel = (FloodfillPeerSelector)getPeerSelector();
    214215        final int type = ds.getType();
    215         final boolean isls2 = ds.isLeaseSet() && type != DatabaseEntry.KEY_TYPE_LEASESET;
     216        final boolean isls = ds.isLeaseSet();
     217        final boolean isls2 = isls && type != DatabaseEntry.KEY_TYPE_LEASESET;
     218        final SigType lsSigType = (isls && type != DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2) ?
     219                                  ds.getKeysAndCert().getSigningPublicKey().getType() :
     220                                  null;
    216221        int max = MAX_TO_FLOOD;
    217222        // increase candidates because we will be skipping some
     
    255260            Hash peer = peers.get(i);
    256261            RouterInfo target = lookupRouterInfoLocally(peer);
    257             if (!shouldFloodTo(key, type, peer, target))
     262            if (!shouldFloodTo(key, type, lsSigType, peer, target)) {
     263                if (_log.shouldDebug())
     264                    _log.debug("Too old, not flooding " + key.toBase64() + " to " + peer.toBase64());
    258265                continue;
     266            }
    259267            DatabaseStoreMessage msg = new DatabaseStoreMessage(_context);
    260268            msg.setEntry(ds);
     
    278286    }
    279287
    280     /** @since 0.9.39 */
    281     private boolean shouldFloodTo(Hash key, int type, Hash peer, RouterInfo target) {
     288    /**
     289     *  @param type database store type
     290     *  @param lsSigType may be null
     291     *  @since 0.9.39
     292     */
     293    private boolean shouldFloodTo(Hash key, int type, SigType lsSigType, Hash peer, RouterInfo target) {
    282294       if ( (target == null) || (_context.banlist().isBanlisted(peer)) )
    283295           return false;
     
    290302           return false;
    291303       // min version checks
    292        if (type != DatabaseEntry.KEY_TYPE_ROUTERINFO && type != DatabaseEntry.KEY_TYPE_LS2 &&
     304       if (type != DatabaseEntry.KEY_TYPE_ROUTERINFO && type != DatabaseEntry.KEY_TYPE_LEASESET &&
    293305           !StoreJob.shouldStoreLS2To(target))
    294306           return false;
    295        if (type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2 &&
     307       if ((type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2 ||
     308            lsSigType == SigType.RedDSA_SHA512_Ed25519) &&
    296309           !StoreJob.shouldStoreEncLS2To(target))
    297310           return false;
  • router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java

    r10bae6a r5b1b4ac  
    185185            int skipped = 0;
    186186            int type = _state.getData().getType();
    187             boolean isls2 = DatabaseEntry.isLeaseSet(type) && type != DatabaseEntry.KEY_TYPE_LEASESET;
     187            final boolean isls = DatabaseEntry.isLeaseSet(type);
     188            final boolean isls2 = isls && type != DatabaseEntry.KEY_TYPE_LEASESET;
     189            final SigType lsSigType = (isls && type != DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2) ?
     190                                      _state.getData().getKeysAndCert().getSigningPublicKey().getType() :
     191                                      null;
    188192            for (Hash peer : closestHashes) {
    189193                DatabaseEntry ds = _facade.getDataStore().get(peer);
     
    198202                    _state.addSkipped(peer);
    199203                    skipped++;
    200                 } else if (type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2 &&
     204                } else if ((type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2 ||
     205                            lsSigType == SigType.RedDSA_SHA512_Ed25519) &&
    201206                           !shouldStoreEncLS2To((RouterInfo)ds)) {
    202207                    if (_log.shouldInfo())
    203                         _log.info(getJobId() + ": Skipping router that doesn't support Enc LS2 " + peer);
     208                        _log.info(getJobId() + ": Skipping router that doesn't support EncLS2/RedDSA " + peer);
    204209                    _state.addSkipped(peer);
    205210                    skipped++;
Note: See TracChangeset for help on using the changeset viewer.