Changeset 54d9a29 for router


Ignore:
Timestamp:
Mar 2, 2019 9:52:12 PM (16 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
cd97718
Parents:
7cbb43a
Message:

I2CP, NetDB, Console: Encrypted LS2 handling fixes (WIP)
log tweaks

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

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/client/ClientMessageEventListener.java

    r7cbb43a r54d9a29  
    1818import net.i2p.data.DataHelper;
    1919import net.i2p.data.Destination;
     20import net.i2p.data.EncryptedLeaseSet;
    2021import net.i2p.data.Hash;
    2122import net.i2p.data.LeaseSet;
     
    632633        }
    633634        try {
     635            if (_log.shouldDebug())
     636                _log.debug("Publishing: " + ls);
    634637            _context.netDb().publish(ls);
     638            if (type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2) {
     639                // store the decrypted ls also
     640                EncryptedLeaseSet encls = (EncryptedLeaseSet) ls;
     641                if (_log.shouldDebug())
     642                    _log.debug("Storing decrypted: " + encls.getDecryptedLeaseSet());
     643                _context.netDb().store(dest.getHash(), encls.getDecryptedLeaseSet());
     644            }
    635645        } catch (IllegalArgumentException iae) {
    636646            if (_log.shouldLog(Log.ERROR))
     
    643653
    644654        // leaseSetCreated takes care of all the LeaseRequestState stuff (including firing any jobs)
    645         _runner.leaseSetCreated(ls);
     655        if (type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2) {
     656            EncryptedLeaseSet encls = (EncryptedLeaseSet) ls;
     657            _runner.leaseSetCreated(encls.getDecryptedLeaseSet());
     658        } else {
     659            _runner.leaseSetCreated(ls);
     660        }
    646661    }
    647662
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    r7cbb43a r54d9a29  
    3030import net.i2p.data.KeyCertificate;
    3131import net.i2p.data.LeaseSet;
     32import net.i2p.data.LeaseSet2;
    3233import net.i2p.data.i2np.DatabaseLookupMessage;
    3334import net.i2p.data.i2np.DatabaseStoreMessage;
     
    684685            return;
    685686        }
    686         Hash h = localLeaseSet.getDestination().calculateHash();
     687        Hash h = localLeaseSet.getHash();
    687688        try {
    688689            store(h, localLeaseSet);
     
    799800     */
    800801    private String validate(Hash key, LeaseSet leaseSet) throws UnsupportedCryptoException {
    801         if (!key.equals(leaseSet.getDestination().calculateHash())) {
     802        if (!key.equals(leaseSet.getHash())) {
    802803            if (_log.shouldLog(Log.WARN))
    803804                _log.warn("Invalid store attempt! key does not match leaseSet.destination!  key = "
    804                           + key + ", leaseSet = " + leaseSet);
     805                          + key.toBase32() + ", leaseSet = " + leaseSet);
    805806            return "Key does not match leaseSet.destination - " + key.toBase64();
    806807        }
     
    813814            return "Invalid leaseSet signature on " + key;
    814815        }
    815         long earliest = leaseSet.getEarliestLeaseDate();
    816         long latest = leaseSet.getLatestLeaseDate();
     816        long earliest;
     817        long latest;
     818        int type = leaseSet.getType();
     819        if (type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2) {
     820            LeaseSet2 ls2 = (LeaseSet2) leaseSet;
     821            // we'll assume it's not an encrypted meta, for now
     822            earliest = ls2.getPublished();
     823            latest = ls2.getExpires();
     824        } else if (type == DatabaseEntry.KEY_TYPE_META_LS2) {
     825            LeaseSet2 ls2 = (LeaseSet2) leaseSet;
     826            // TODO this isn't right, and must adjust limits below also
     827            earliest = Math.min(ls2.getEarliestLeaseDate(), ls2.getPublished());
     828            latest = Math.min(ls2.getLatestLeaseDate(), ls2.getExpires());
     829        } else {
     830            earliest = leaseSet.getEarliestLeaseDate();
     831            latest = leaseSet.getLatestLeaseDate();
     832        }
    817833        long now = _context.clock().now();
    818834        if (earliest <= now - 10*60*1000L ||
Note: See TracChangeset for help on using the changeset viewer.