Browse Source

don't request banned router

pull/2035/head
orignal 9 months ago
parent
commit
f1058410fb
  1. 4
      libi2pd/NetDb.cpp
  2. 11
      libi2pd/Profiling.cpp
  3. 1
      libi2pd/Profiling.h

4
libi2pd/NetDb.cpp

@ -957,8 +957,10 @@ namespace data
LogPrint (eLogDebug, "NetDb: Found new/outdated router. Requesting RouterInfo..."); LogPrint (eLogDebug, "NetDb: Found new/outdated router. Requesting RouterInfo...");
if(m_FloodfillBootstrap) if(m_FloodfillBootstrap)
RequestDestinationFrom(router, m_FloodfillBootstrap->GetIdentHash(), true); RequestDestinationFrom(router, m_FloodfillBootstrap->GetIdentHash(), true);
else else if (!IsRouterBanned (router))
RequestDestination (router); RequestDestination (router);
else
LogPrint (eLogDebug, "NetDb: Router ", peerHash, " is banned. Skipped");
} }
else else
LogPrint (eLogDebug, "NetDb: [:|||:]"); LogPrint (eLogDebug, "NetDb: [:|||:]");

11
libi2pd/Profiling.cpp

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2023, The PurpleI2P Project * Copyright (c) 2013-2024, The PurpleI2P Project
* *
* This file is part of Purple i2pd project and licensed under BSD3 * This file is part of Purple i2pd project and licensed under BSD3
* *
@ -245,6 +245,15 @@ namespace data
return profile; return profile;
} }
bool IsRouterBanned (const IdentHash& identHash)
{
std::unique_lock<std::mutex> l(g_ProfilesMutex);
auto it = g_Profiles.find (identHash);
if (it != g_Profiles.end ())
return it->second->IsUnreachable ();
return false;
}
void InitProfilesStorage () void InitProfilesStorage ()
{ {
g_ProfilesStorage.SetPlace(i2p::fs::GetDataDir()); g_ProfilesStorage.SetPlace(i2p::fs::GetDataDir());

1
libi2pd/Profiling.h

@ -87,6 +87,7 @@ namespace data
}; };
std::shared_ptr<RouterProfile> GetRouterProfile (const IdentHash& identHash); std::shared_ptr<RouterProfile> GetRouterProfile (const IdentHash& identHash);
bool IsRouterBanned (const IdentHash& identHash); // check only existing profiles
void InitProfilesStorage (); void InitProfilesStorage ();
void DeleteObsoleteProfiles (); void DeleteObsoleteProfiles ();
void SaveProfiles (); void SaveProfiles ();

Loading…
Cancel
Save