Browse Source

introducer expiration time variance

gha
orignal 2 months ago
parent
commit
514be6d048
  1. 7
      libi2pd/SSU2.cpp
  2. 4
      libi2pd/SSU2.h

7
libi2pd/SSU2.cpp

@ -1267,9 +1267,7 @@ namespace transport
ts < session->GetCreationTime () + SSU2_TO_INTRODUCER_SESSION_EXPIRATION) ts < session->GetCreationTime () + SSU2_TO_INTRODUCER_SESSION_EXPIRATION)
{ {
session->SendKeepAlive (); session->SendKeepAlive ();
if (ts < session->GetCreationTime () + SSU2_TO_INTRODUCER_SESSION_DURATION || if (ts < session->GetCreationTime () + SSU2_TO_INTRODUCER_SESSION_DURATION)
ts < session->GetCreationTime () + SSU2_TO_INTRODUCER_SESSION_DURATION +
m_Rng () % SSU2_TO_INTRODUCER_SESSION_DURATION_VARIANCE)
{ {
newList.push_back ({ident, session->GetRelayTag ()}); newList.push_back ({ident, session->GetRelayTag ()});
if (tag != session->GetRelayTag ()) if (tag != session->GetRelayTag ())
@ -1316,6 +1314,9 @@ namespace transport
for (const auto& it : sessions) for (const auto& it : sessions)
{ {
uint32_t tag = it->GetRelayTag (); uint32_t tag = it->GetRelayTag ();
auto extraTime = std::min ((int)(ts - it->GetCreationTime ()), SSU2_TO_INTRODUCER_SESSION_EXPIRATION_VARIANCE);
if( extraTime > 1)
it->SetCreationTime (it->GetCreationTime () + m_Rng () % extraTime);
uint32_t exp = it->GetCreationTime () + SSU2_TO_INTRODUCER_SESSION_EXPIRATION; uint32_t exp = it->GetCreationTime () + SSU2_TO_INTRODUCER_SESSION_EXPIRATION;
if (!tag || ts + SSU2_TO_INTRODUCER_SESSION_DURATION/2 > exp) if (!tag || ts + SSU2_TO_INTRODUCER_SESSION_DURATION/2 > exp)
continue; // don't pick too old session for introducer continue; // don't pick too old session for introducer

4
libi2pd/SSU2.h

@ -35,9 +35,9 @@ namespace transport
const uint64_t SSU2_SOCKET_MAX_BUFFER_SIZE = 4 * 1024 * 1024; const uint64_t SSU2_SOCKET_MAX_BUFFER_SIZE = 4 * 1024 * 1024;
const size_t SSU2_MAX_NUM_INTRODUCERS = 3; const size_t SSU2_MAX_NUM_INTRODUCERS = 3;
const size_t SSU2_MIN_RECEIVED_PACKET_SIZE = 40; // 16 byte short header + 8 byte minimum payload + 16 byte MAC const size_t SSU2_MIN_RECEIVED_PACKET_SIZE = 40; // 16 byte short header + 8 byte minimum payload + 16 byte MAC
const int SSU2_TO_INTRODUCER_SESSION_DURATION = 3480; // 58 minutes const int SSU2_TO_INTRODUCER_SESSION_DURATION = 3680; // 1 hour
const int SSU2_TO_INTRODUCER_SESSION_DURATION_VARIANCE = 330; // 5 minutes
const int SSU2_TO_INTRODUCER_SESSION_EXPIRATION = 4800; // 80 minutes const int SSU2_TO_INTRODUCER_SESSION_EXPIRATION = 4800; // 80 minutes
const int SSU2_TO_INTRODUCER_SESSION_EXPIRATION_VARIANCE = 120; // 2 minutes
const int SSU2_KEEP_ALIVE_INTERVAL = 15; // in seconds const int SSU2_KEEP_ALIVE_INTERVAL = 15; // in seconds
const int SSU2_KEEP_ALIVE_INTERVAL_VARIANCE = 4; // in seconds const int SSU2_KEEP_ALIVE_INTERVAL_VARIANCE = 4; // in seconds
const int SSU2_PROXY_CONNECT_RETRY_TIMEOUT = 30; // in seconds const int SSU2_PROXY_CONNECT_RETRY_TIMEOUT = 30; // in seconds

Loading…
Cancel
Save