I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Verified Commit 9b361ce7 authored by zzz's avatar zzz
Browse files

NetDB: Negative cache LS received with zero leases

Ratchet: Don't schedule a reply to a LS with zero leases
parent 562b8663
No related branches found
No related tags found
No related merge requests found
...@@ -1479,6 +1479,9 @@ public final class ECIESAEADEngine { ...@@ -1479,6 +1479,9 @@ public final class ECIESAEADEngine {
if (entry.getType() != DatabaseEntry.KEY_TYPE_LS2) if (entry.getType() != DatabaseEntry.KEY_TYPE_LS2)
continue; continue;
LeaseSet2 ls2 = (LeaseSet2) entry; LeaseSet2 ls2 = (LeaseSet2) entry;
// i2pd bug?
if (ls2.getLeaseCount() == 0)
return;
if (!ls2.isCurrent(Router.CLOCK_FUDGE_FACTOR)) if (!ls2.isCurrent(Router.CLOCK_FUDGE_FACTOR))
continue; continue;
PublicKey pk = ls2.getEncryptionKey(LeaseSetKeys.SET_EC); PublicKey pk = ls2.getEncryptionKey(LeaseSetKeys.SET_EC);
......
...@@ -929,12 +929,19 @@ public abstract class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacad ...@@ -929,12 +929,19 @@ public abstract class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacad
long age = now - earliest; long age = now - earliest;
Destination dest = leaseSet.getDestination(); Destination dest = leaseSet.getDestination();
String id = dest != null ? dest.toBase32() : leaseSet.getHash().toBase32(); String id = dest != null ? dest.toBase32() : leaseSet.getHash().toBase32();
if (_log.shouldLog(Log.WARN)) if (_log.shouldWarn())
_log.warn("Old leaseSet! not storing it: " _log.warn("Old leaseSet! not storing it: "
+ id + id
+ " first exp. " + new Date(earliest) + " first exp. " + new Date(earliest)
+ " last exp. " + new Date(latest), + " last exp. " + new Date(latest) + '\n' + leaseSet,
new Exception("Rejecting store")); new Exception("Rejecting store"));
// i2pd bug?
// So we don't immediately go try to fetch it for a reply
if (leaseSet.getLeaseCount() == 0) {
for (int i = 0; i < NegativeLookupCache.MAX_FAILS; i++) {
lookupFailed(key);
}
}
return "Expired leaseSet for " + id return "Expired leaseSet for " + id
+ " expired " + DataHelper.formatDuration(age) + " ago"; + " expired " + DataHelper.formatDuration(age) + " ago";
} }
......
...@@ -20,7 +20,7 @@ class NegativeLookupCache { ...@@ -20,7 +20,7 @@ class NegativeLookupCache {
private final Map<Hash, Destination> badDests; private final Map<Hash, Destination> badDests;
private final int _maxFails; private final int _maxFails;
private static final int MAX_FAILS = 3; static final int MAX_FAILS = 3;
private static final int MAX_BAD_DESTS = 128; private static final int MAX_BAD_DESTS = 128;
private static final long CLEAN_TIME = 2*60*1000; private static final long CLEAN_TIME = 2*60*1000;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment