|
|
@ -119,6 +119,7 @@ namespace data |
|
|
|
|
|
|
|
|
|
|
|
// process leases
|
|
|
|
// process leases
|
|
|
|
m_ExpirationTime = 0; |
|
|
|
m_ExpirationTime = 0; |
|
|
|
|
|
|
|
auto ts = i2p::util::GetMillisecondsSinceEpoch (); |
|
|
|
const uint8_t * leases = m_Buffer + size; |
|
|
|
const uint8_t * leases = m_Buffer + size; |
|
|
|
for (int i = 0; i < num; i++) |
|
|
|
for (int i = 0; i < num; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -129,6 +130,8 @@ namespace data |
|
|
|
leases += 4; // tunnel ID
|
|
|
|
leases += 4; // tunnel ID
|
|
|
|
lease.endDate = bufbe64toh (leases); |
|
|
|
lease.endDate = bufbe64toh (leases); |
|
|
|
leases += 8; // end date
|
|
|
|
leases += 8; // end date
|
|
|
|
|
|
|
|
if (ts < lease.endDate) |
|
|
|
|
|
|
|
{ |
|
|
|
if (lease.endDate > m_ExpirationTime) |
|
|
|
if (lease.endDate > m_ExpirationTime) |
|
|
|
m_ExpirationTime = lease.endDate; |
|
|
|
m_ExpirationTime = lease.endDate; |
|
|
|
if (m_StoreLeases) |
|
|
|
if (m_StoreLeases) |
|
|
@ -145,6 +148,15 @@ namespace data |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
LogPrint (eLogWarning, "LeaseSet: Lease is expired already "); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!m_ExpirationTime) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint (eLogWarning, "LeaseSet: all leases are expired. Dropped"); |
|
|
|
|
|
|
|
m_IsValid = false; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
// delete old leases
|
|
|
|
// delete old leases
|
|
|
|
if (m_StoreLeases) |
|
|
|
if (m_StoreLeases) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -193,6 +205,7 @@ namespace data |
|
|
|
|
|
|
|
|
|
|
|
bool LeaseSet::IsExpired () const |
|
|
|
bool LeaseSet::IsExpired () const |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (IsEmpty ()) return true; |
|
|
|
auto ts = i2p::util::GetMillisecondsSinceEpoch (); |
|
|
|
auto ts = i2p::util::GetMillisecondsSinceEpoch (); |
|
|
|
return ts > m_ExpirationTime; |
|
|
|
return ts > m_ExpirationTime; |
|
|
|
} |
|
|
|
} |
|
|
|