|
|
@ -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): |
|
|
|
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 (); |
|
|
|
int num = tunnels.size (); |
|
|
|
if (num > MAX_NUM_LEASES) num = MAX_NUM_LEASES; |
|
|
|
if (num > MAX_NUM_LEASES) num = MAX_NUM_LEASES; |
|
|
@ -273,18 +273,19 @@ namespace data |
|
|
|
offset += 4; // tunnel id
|
|
|
|
offset += 4; // tunnel id
|
|
|
|
uint64_t ts = tunnels[i]->GetCreationTime () + i2p::tunnel::TUNNEL_EXPIRATION_TIMEOUT - i2p::tunnel::TUNNEL_EXPIRATION_THRESHOLD; // 1 minute before expiration
|
|
|
|
uint64_t ts = tunnels[i]->GetCreationTime () + i2p::tunnel::TUNNEL_EXPIRATION_TIMEOUT - i2p::tunnel::TUNNEL_EXPIRATION_THRESHOLD; // 1 minute before expiration
|
|
|
|
ts *= 1000; // in milliseconds
|
|
|
|
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
|
|
|
|
// 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
|
|
|
|
ts += (currentTime - tunnels[i]->GetCreationTime ()*1000LL)*2/i2p::tunnel::TUNNEL_EXPIRATION_TIMEOUT; // up to 2 secs
|
|
|
|
htobe64buf (m_Buffer + offset, ts); |
|
|
|
htobe64buf (m_Buffer + offset, ts); |
|
|
|
offset += 8; // end date
|
|
|
|
offset += 8; // end date
|
|
|
|
} |
|
|
|
} |
|
|
|
// we don't sign it yet. must be signed later on
|
|
|
|
// 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 (); |
|
|
|
auto ts = i2p::util::GetMillisecondsSinceEpoch (); |
|
|
|
memcpy (m_Buffer + m_BufferLen - signatureLen, signature, signatureLen); |
|
|
|
return ts > m_ExpirationTime; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|