|
|
|
@ -247,7 +247,7 @@ namespace data
@@ -247,7 +247,7 @@ namespace data
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
LocalLeaseSet::LocalLeaseSet (std::shared_ptr<const IdentityEx> identity, const uint8_t * encryptionPublicKey, std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels): |
|
|
|
|
m_Identity (identity) |
|
|
|
|
m_ExpirationTime (0), m_Identity (identity) |
|
|
|
|
{ |
|
|
|
|
int num = tunnels.size (); |
|
|
|
|
if (num > MAX_NUM_LEASES) num = MAX_NUM_LEASES; |
|
|
|
@ -273,6 +273,7 @@ namespace data
@@ -273,6 +273,7 @@ namespace data
|
|
|
|
|
offset += 4; // tunnel id
|
|
|
|
|
uint64_t ts = tunnels[i]->GetCreationTime () + i2p::tunnel::TUNNEL_EXPIRATION_TIMEOUT - i2p::tunnel::TUNNEL_EXPIRATION_THRESHOLD; // 1 minute before expiration
|
|
|
|
|
ts *= 1000; // in milliseconds
|
|
|
|
|
if (ts > m_ExpirationTime) m_ExpirationTime = ts; |
|
|
|
|
// make sure leaseset is newer than previous, but adding some time to expiration date
|
|
|
|
|
ts += (currentTime - tunnels[i]->GetCreationTime ()*1000LL)*2/i2p::tunnel::TUNNEL_EXPIRATION_TIMEOUT; // up to 2 secs
|
|
|
|
|
htobe64buf (m_Buffer + offset, ts); |
|
|
|
@ -281,10 +282,10 @@ namespace data
@@ -281,10 +282,10 @@ namespace data
|
|
|
|
|
// we don't sign it yet. must be signed later on
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void LocalLeaseSet::SetSignature (const uint8_t * signature) |
|
|
|
|
bool LocalLeaseSet::IsExpired () const |
|
|
|
|
{ |
|
|
|
|
auto signatureLen = GetSignatureLen (); |
|
|
|
|
memcpy (m_Buffer + m_BufferLen - signatureLen, signature, signatureLen); |
|
|
|
|
auto ts = i2p::util::GetMillisecondsSinceEpoch (); |
|
|
|
|
return ts > m_ExpirationTime; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|