Skip to content

Commit b8e19bf

Browse files
committed
reduced peer test interval and added peer test interval variance
1 parent c7efd46 commit b8e19bf

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

libi2pd/SSU2.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,8 @@ namespace transport
10781078
{
10791079
if (m_IsPublished)
10801080
{
1081-
m_IntroducersUpdateTimer.expires_from_now (boost::posix_time::seconds(SSU2_KEEP_ALIVE_INTERVAL));
1081+
m_IntroducersUpdateTimer.expires_from_now (boost::posix_time::seconds(
1082+
SSU2_KEEP_ALIVE_INTERVAL + rand () % SSU2_KEEP_ALIVE_INTERVAL_VARIANCE));
10821083
m_IntroducersUpdateTimer.async_wait (std::bind (&SSU2Server::HandleIntroducersUpdateTimer,
10831084
this, std::placeholders::_1, true));
10841085
}
@@ -1091,7 +1092,8 @@ namespace transport
10911092
m_IntroducersUpdateTimer.cancel ();
10921093
i2p::context.ClearSSU2Introducers (true);
10931094
m_Introducers.clear ();
1094-
m_IntroducersUpdateTimer.expires_from_now (boost::posix_time::seconds(SSU2_KEEP_ALIVE_INTERVAL/2));
1095+
m_IntroducersUpdateTimer.expires_from_now (boost::posix_time::seconds(
1096+
(SSU2_KEEP_ALIVE_INTERVAL + rand () % SSU2_KEEP_ALIVE_INTERVAL_VARIANCE)/2));
10951097
m_IntroducersUpdateTimer.async_wait (std::bind (&SSU2Server::HandleIntroducersUpdateTimer,
10961098
this, std::placeholders::_1, true));
10971099
}
@@ -1101,7 +1103,8 @@ namespace transport
11011103
{
11021104
if (m_IsPublished)
11031105
{
1104-
m_IntroducersUpdateTimerV6.expires_from_now (boost::posix_time::seconds(SSU2_KEEP_ALIVE_INTERVAL));
1106+
m_IntroducersUpdateTimerV6.expires_from_now (boost::posix_time::seconds(
1107+
SSU2_KEEP_ALIVE_INTERVAL + rand () % SSU2_KEEP_ALIVE_INTERVAL_VARIANCE));
11051108
m_IntroducersUpdateTimerV6.async_wait (std::bind (&SSU2Server::HandleIntroducersUpdateTimer,
11061109
this, std::placeholders::_1, false));
11071110
}
@@ -1114,7 +1117,8 @@ namespace transport
11141117
m_IntroducersUpdateTimerV6.cancel ();
11151118
i2p::context.ClearSSU2Introducers (false);
11161119
m_IntroducersV6.clear ();
1117-
m_IntroducersUpdateTimerV6.expires_from_now (boost::posix_time::seconds(SSU2_KEEP_ALIVE_INTERVAL/2));
1120+
m_IntroducersUpdateTimerV6.expires_from_now (boost::posix_time::seconds(
1121+
(SSU2_KEEP_ALIVE_INTERVAL + rand () % SSU2_KEEP_ALIVE_INTERVAL_VARIANCE)/2));
11181122
m_IntroducersUpdateTimerV6.async_wait (std::bind (&SSU2Server::HandleIntroducersUpdateTimer,
11191123
this, std::placeholders::_1, false));
11201124
}

libi2pd/SSU2.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ namespace transport
2929
const size_t SSU2_MAX_NUM_INTRODUCERS = 3;
3030
const int SSU2_TO_INTRODUCER_SESSION_DURATION = 3600; // 1 hour
3131
const int SSU2_TO_INTRODUCER_SESSION_EXPIRATION = 4800; // 80 minutes
32-
const int SSU2_KEEP_ALIVE_INTERVAL = 30; // in seconds
32+
const int SSU2_KEEP_ALIVE_INTERVAL = 15; // in seconds
33+
const int SSU2_KEEP_ALIVE_INTERVAL_VARIANCE = 4; // in seconds
3334
const int SSU2_PROXY_CONNECT_RETRY_TIMEOUT = 30; // in seconds
3435

3536
class SSU2Server: private i2p::util::RunnableServiceWithWork

0 commit comments

Comments
 (0)