mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
exclude previously non-reachable transports
This commit is contained in:
parent
527ee3b3c5
commit
b77ae08388
|
@ -409,19 +409,29 @@ namespace data
|
|||
|
||||
void NetDb::SetUnreachable (const IdentHash& ident, bool unreachable)
|
||||
{
|
||||
auto it = m_RouterInfos.find (ident);
|
||||
if (it != m_RouterInfos.end ())
|
||||
auto r = FindRouter (ident);
|
||||
if (r)
|
||||
{
|
||||
it->second->SetUnreachable (unreachable);
|
||||
r->SetUnreachable (unreachable);
|
||||
if (unreachable)
|
||||
{
|
||||
auto profile = it->second->GetProfile ();
|
||||
auto profile = r->GetProfile ();
|
||||
if (profile)
|
||||
profile->Unreachable ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NetDb::ExcludeReachableTransports (const IdentHash& ident, RouterInfo::CompatibleTransports transports)
|
||||
{
|
||||
auto r = FindRouter (ident);
|
||||
if (r)
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_RouterInfosMutex);
|
||||
r->ExcludeReachableTransports (transports);
|
||||
}
|
||||
}
|
||||
|
||||
void NetDb::Reseed ()
|
||||
{
|
||||
if (!m_Reseeder)
|
||||
|
|
|
@ -94,6 +94,7 @@ namespace data
|
|||
std::shared_ptr<const RouterInfo> GetClosestNonFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded) const;
|
||||
std::shared_ptr<const RouterInfo> GetRandomRouterInFamily (FamilyID fam) const;
|
||||
void SetUnreachable (const IdentHash& ident, bool unreachable);
|
||||
void ExcludeReachableTransports (const IdentHash& ident, RouterInfo::CompatibleTransports transports);
|
||||
|
||||
void PostI2NPMsg (std::shared_ptr<const I2NPMessage> msg);
|
||||
|
||||
|
|
|
@ -259,6 +259,7 @@ namespace data
|
|||
|
||||
void SetUnreachable (bool unreachable) { m_IsUnreachable = unreachable; };
|
||||
bool IsUnreachable () const { return m_IsUnreachable; };
|
||||
void ExcludeReachableTransports (CompatibleTransports transports) { m_ReachableTransports &= ~transports; };
|
||||
|
||||
const uint8_t * GetBuffer () const { return m_Buffer ? m_Buffer->data () : nullptr; };
|
||||
const uint8_t * LoadBuffer (const std::string& fullPath); // load if necessary
|
||||
|
|
|
@ -700,6 +700,17 @@ namespace transport
|
|||
auto it = m_Peers.find (ident);
|
||||
if (it != m_Peers.end ())
|
||||
{
|
||||
if (it->second.numAttempts > 1)
|
||||
{
|
||||
// exclude failed transports
|
||||
i2p::data::RouterInfo::CompatibleTransports transports = 0;
|
||||
int numExcluded = it->second.numAttempts - 1;
|
||||
if (numExcluded > (int)it->second.priority.size ()) numExcluded = it->second.priority.size ();
|
||||
for (int i = 0; i < numExcluded; i++)
|
||||
transports |= it->second.priority[i];
|
||||
i2p::data::netdb.ExcludeReachableTransports (ident, transports);
|
||||
}
|
||||
it->second.numAttempts = 0;
|
||||
it->second.router = nullptr; // we don't need RouterInfo after successive connect
|
||||
bool sendDatabaseStore = true;
|
||||
if (it->second.delayedMessages.size () > 0)
|
||||
|
|
Loading…
Reference in a new issue