Skip to content

Commit

Permalink
limit expiration by next midnight for encrypted LS2
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Apr 12, 2019
1 parent d248343 commit 5d5cd71
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions libi2pd/LeaseSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,10 +872,11 @@ namespace data
memcpy (m_Buffer + offset, blindedPub, 32); offset += 32; // Blinded Public Key
auto timestamp = i2p::util::GetSecondsSinceEpoch ();
htobe32buf (m_Buffer + offset, timestamp); offset += 4; // published timestamp (seconds)
auto expirationTime = ls->GetExpirationTime ();
SetExpirationTime (expirationTime);
auto expires = expirationTime/1000LL - timestamp;
htobe16buf (m_Buffer + offset, expires > 0 ? expires : 0); offset += 2; // expires
auto nextMidnight = (timestamp/86400LL + 1)*86400LL; // 86400 = 24*3600 seconds
auto expirationTime = ls->GetExpirationTime ()/1000LL;
if (expirationTime > nextMidnight) expirationTime = nextMidnight;
SetExpirationTime (expirationTime*1000LL);
htobe16buf (m_Buffer + offset, expirationTime > timestamp ? expirationTime - timestamp : 0); offset += 2; // expires
uint16_t flags = 0;
htobe16buf (m_Buffer + offset, flags); offset += 2; // flags
htobe16buf (m_Buffer + offset, lenOuterCiphertext); offset += 2; // lenOuterCiphertext
Expand Down

0 comments on commit 5d5cd71

Please sign in to comment.