forked from I2P_Developers/i2p.i2p
NetDB: Fix NPE validating expired blinded LS2
This commit is contained in:
@@ -118,6 +118,11 @@ public class LeaseSet extends DatabaseEntry {
|
|||||||
return KEY_TYPE_LEASESET;
|
return KEY_TYPE_LEASESET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warning - will be null for LS2 EncryptedLeaseSets if not decrypted
|
||||||
|
*
|
||||||
|
* @return Destination or null
|
||||||
|
*/
|
||||||
public Destination getDestination() {
|
public Destination getDestination() {
|
||||||
return _destination;
|
return _destination;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -913,13 +913,15 @@ public abstract class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacad
|
|||||||
// lookupLeaseSetLocally()
|
// lookupLeaseSetLocally()
|
||||||
latest <= now - Router.CLOCK_FUDGE_FACTOR) {
|
latest <= now - Router.CLOCK_FUDGE_FACTOR) {
|
||||||
long age = now - earliest;
|
long age = now - earliest;
|
||||||
|
Destination dest = leaseSet.getDestination();
|
||||||
|
String id = dest != null ? dest.toBase32() : leaseSet.getHash().toBase32();
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Old leaseSet! not storing it: "
|
_log.warn("Old leaseSet! not storing it: "
|
||||||
+ leaseSet.getDestination().toBase32()
|
+ id
|
||||||
+ " first exp. " + new Date(earliest)
|
+ " first exp. " + new Date(earliest)
|
||||||
+ " last exp. " + new Date(latest),
|
+ " last exp. " + new Date(latest),
|
||||||
new Exception("Rejecting store"));
|
new Exception("Rejecting store"));
|
||||||
return "Expired leaseSet for " + leaseSet.getDestination().toBase32()
|
return "Expired leaseSet for " + id
|
||||||
+ " expired " + DataHelper.formatDuration(age) + " ago";
|
+ " expired " + DataHelper.formatDuration(age) + " ago";
|
||||||
}
|
}
|
||||||
if (latest > now + (Router.CLOCK_FUDGE_FACTOR + MAX_LEASE_FUTURE) &&
|
if (latest > now + (Router.CLOCK_FUDGE_FACTOR + MAX_LEASE_FUTURE) &&
|
||||||
@@ -927,11 +929,13 @@ public abstract class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacad
|
|||||||
latest > now + (Router.CLOCK_FUDGE_FACTOR + MAX_META_LEASE_FUTURE))) {
|
latest > now + (Router.CLOCK_FUDGE_FACTOR + MAX_META_LEASE_FUTURE))) {
|
||||||
long age = latest - now;
|
long age = latest - now;
|
||||||
// let's not make this an error, it happens when peers have bad clocks
|
// let's not make this an error, it happens when peers have bad clocks
|
||||||
|
Destination dest = leaseSet.getDestination();
|
||||||
|
String id = dest != null ? dest.toBase32() : leaseSet.getHash().toBase32();
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("LeaseSet expires too far in the future: "
|
_log.warn("LeaseSet expires too far in the future: "
|
||||||
+ leaseSet.getDestination().toBase32()
|
+ id
|
||||||
+ " expires " + DataHelper.formatDuration(age) + " from now");
|
+ " expires " + DataHelper.formatDuration(age) + " from now");
|
||||||
return "Future expiring leaseSet for " + leaseSet.getDestination().toBase32()
|
return "Future expiring leaseSet for " + id
|
||||||
+ " expiring in " + DataHelper.formatDuration(age);
|
+ " expiring in " + DataHelper.formatDuration(age);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user