From 5ad4c2a65ec3d8338e03c67ed57aee8b2708cec0 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 4 May 2021 14:59:25 -0400 Subject: [PATCH] run ipv6 peer test again if still testing --- libi2pd/Transports.cpp | 15 +++++++++------ libi2pd/Transports.h | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/libi2pd/Transports.cpp b/libi2pd/Transports.cpp index 4ad13518..8413c859 100644 --- a/libi2pd/Transports.cpp +++ b/libi2pd/Transports.cpp @@ -581,10 +581,10 @@ namespace transport LogPrint (eLogError, "Transports: Can't detect external IP. SSU is not available"); } - void Transports::PeerTest () + void Transports::PeerTest (bool ipv4, bool ipv6) { if (RoutesRestricted() || !m_SSUServer) return; - if (i2p::context.SupportsV4 ()) + if (ipv4 && i2p::context.SupportsV4 ()) { LogPrint (eLogInfo, "Transports: Started peer test ipv4"); std::set excluded; @@ -610,7 +610,7 @@ namespace transport if (!statusChanged) LogPrint (eLogWarning, "Transports: Can't find routers for peer test ipv4"); } - if (i2p::context.SupportsV6 ()) + if (ipv6 && i2p::context.SupportsV6 ()) { LogPrint (eLogInfo, "Transports: Started peer test ipv6"); std::set excluded; @@ -750,9 +750,12 @@ namespace transport ++it; } UpdateBandwidth (); // TODO: use separate timer(s) for it - if (i2p::context.GetStatus () == eRouterStatusTesting) // if still testing, repeat peer test - DetectExternalIP (); - m_PeerCleanupTimer->expires_from_now (boost::posix_time::seconds(5*SESSION_CREATION_TIMEOUT)); + bool ipv4Testing = i2p::context.GetStatus () == eRouterStatusTesting; + bool ipv6Testing = i2p::context.GetStatusV6 () == eRouterStatusTesting; + // if still testing, repeat peer test + if (ipv4Testing || ipv6Testing) + PeerTest (ipv4Testing, ipv6Testing); + m_PeerCleanupTimer->expires_from_now (boost::posix_time::seconds(3*SESSION_CREATION_TIMEOUT)); m_PeerCleanupTimer->async_wait (std::bind (&Transports::HandlePeerCleanupTimer, this, std::placeholders::_1)); } } diff --git a/libi2pd/Transports.h b/libi2pd/Transports.h index d480840a..9377286c 100644 --- a/libi2pd/Transports.h +++ b/libi2pd/Transports.h @@ -76,9 +76,9 @@ namespace transport } }; - const size_t SESSION_CREATION_TIMEOUT = 10; // in seconds + const size_t SESSION_CREATION_TIMEOUT = 15; // in seconds const int PEER_TEST_INTERVAL = 71; // in minutes - const int MAX_NUM_DELAYED_MESSAGES = 50; + const int MAX_NUM_DELAYED_MESSAGES = 150; class Transports { public: @@ -131,7 +131,7 @@ namespace transport bool IsRestrictedPeer(const i2p::data::IdentHash & ident) const; - void PeerTest (); + void PeerTest (bool ipv4 = true, bool ipv6 = true); void SetCheckReserved (bool check) { m_CheckReserved = check; }; bool IsCheckReserved () { return m_CheckReserved; };