I2CP: Don't include lease about to expire in LS request

Better error message on attempt to sign expired LS
This commit is contained in:
zzz
2024-08-23 09:24:47 -04:00
parent b4a0f83c00
commit 8ff4797628
2 changed files with 8 additions and 2 deletions

View File

@ -544,7 +544,12 @@ public class LeaseSet2 extends LeaseSet {
long pub1k = _published / 1000;
DataHelper.writeLong(out, 4, pub1k);
// Divide separately to prevent rounding errors
DataHelper.writeLong(out, 2, ((_expires / 1000) - pub1k));
long exp = (_expires / 1000) - pub1k;
// writeLong() will throw if we try to write a negative, so preempt it with a better message
// This will only happen on the client side for leasesets we create.
if (exp < 0)
throw new DataFormatException("Leaseset expired " + (0 - exp) + " seconds ago");
DataHelper.writeLong(out, 2, exp);
DataHelper.writeLong(out, 2, _flags);
if (isOffline())
writeOfflineBytes(out);

View File

@ -770,7 +770,8 @@ public class TunnelPool {
return null;
}
long expireAfter = _context.clock().now(); // + _settings.getRebuildPeriod();
// we don't want it to expire before the client signs it or the ff gets it
long expireAfter = _context.clock().now() - 10*1000;
TunnelInfo zeroHopTunnel = null;
Lease zeroHopLease = null;