Browse Source

run ipv6 peer test again if still testing

pull/1656/head
orignal 4 years ago
parent
commit
5ad4c2a65e
  1. 15
      libi2pd/Transports.cpp
  2. 6
      libi2pd/Transports.h

15
libi2pd/Transports.cpp

@ -581,10 +581,10 @@ namespace transport
LogPrint (eLogError, "Transports: Can't detect external IP. SSU is not available"); 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 (RoutesRestricted() || !m_SSUServer) return;
if (i2p::context.SupportsV4 ()) if (ipv4 && i2p::context.SupportsV4 ())
{ {
LogPrint (eLogInfo, "Transports: Started peer test ipv4"); LogPrint (eLogInfo, "Transports: Started peer test ipv4");
std::set<i2p::data::IdentHash> excluded; std::set<i2p::data::IdentHash> excluded;
@ -610,7 +610,7 @@ namespace transport
if (!statusChanged) if (!statusChanged)
LogPrint (eLogWarning, "Transports: Can't find routers for peer test ipv4"); 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"); LogPrint (eLogInfo, "Transports: Started peer test ipv6");
std::set<i2p::data::IdentHash> excluded; std::set<i2p::data::IdentHash> excluded;
@ -750,9 +750,12 @@ namespace transport
++it; ++it;
} }
UpdateBandwidth (); // TODO: use separate timer(s) for it UpdateBandwidth (); // TODO: use separate timer(s) for it
if (i2p::context.GetStatus () == eRouterStatusTesting) // if still testing, repeat peer test bool ipv4Testing = i2p::context.GetStatus () == eRouterStatusTesting;
DetectExternalIP (); bool ipv6Testing = i2p::context.GetStatusV6 () == eRouterStatusTesting;
m_PeerCleanupTimer->expires_from_now (boost::posix_time::seconds(5*SESSION_CREATION_TIMEOUT)); // 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)); m_PeerCleanupTimer->async_wait (std::bind (&Transports::HandlePeerCleanupTimer, this, std::placeholders::_1));
} }
} }

6
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 PEER_TEST_INTERVAL = 71; // in minutes
const int MAX_NUM_DELAYED_MESSAGES = 50; const int MAX_NUM_DELAYED_MESSAGES = 150;
class Transports class Transports
{ {
public: public:
@ -131,7 +131,7 @@ namespace transport
bool IsRestrictedPeer(const i2p::data::IdentHash & ident) const; 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; }; void SetCheckReserved (bool check) { m_CheckReserved = check; };
bool IsCheckReserved () { return m_CheckReserved; }; bool IsCheckReserved () { return m_CheckReserved; };

Loading…
Cancel
Save