mark and check unreachable ident hashes

This commit is contained in:
orignal 2023-04-15 22:16:31 -04:00
parent e20acb93cf
commit cd5bfaabb5
2 changed files with 16 additions and 6 deletions

View file

@ -458,8 +458,20 @@ namespace transport
it->second.sessions.front ()->SendI2NPMessages (msgs);
else
{
if (it->second.delayedMessages.size () < MAX_NUM_DELAYED_MESSAGES)
auto sz = it->second.delayedMessages.size ();
if (sz < MAX_NUM_DELAYED_MESSAGES)
{
if (sz > CHECK_PROFILE_NUM_DELAYED_MESSAGES)
{
auto profile = i2p::data::GetRouterProfile (ident);
if (profile && profile->IsUnreachable ())
{
LogPrint (eLogWarning, "Transports: Peer profile for ", ident.ToBase64 (), "reports unreachable. Dropped");
std::unique_lock<std::mutex> l(m_PeersMutex);
m_Peers.erase (it);
return;
}
}
for (auto& it1: msgs)
it->second.delayedMessages.push_back (it1);
}
@ -776,10 +788,7 @@ namespace transport
{
LogPrint (eLogWarning, "Transports: Session to peer ", it->first.ToBase64 (), " has not been created in ", SESSION_CREATION_TIMEOUT, " seconds");
auto profile = i2p::data::GetRouterProfile (it->first);
if (profile)
{
profile->TunnelNonReplied();
}
if (profile) profile->Unreachable ();
std::unique_lock<std::mutex> l(m_PeersMutex);
it = m_Peers.erase (it);
}

View file

@ -106,6 +106,7 @@ namespace transport
const uint64_t SESSION_CREATION_TIMEOUT = 15; // in seconds
const int PEER_TEST_INTERVAL = 71; // in minutes
const int MAX_NUM_DELAYED_MESSAGES = 150;
const int CHECK_PROFILE_NUM_DELAYED_MESSAGES = 15; // check profile after
class Transports
{
public: