bypass medium congestion(D) routers for client tunnels

debian
orignal 1 year ago
parent 572694b141
commit 4ebc7c970a

@ -1172,7 +1172,7 @@ namespace data
return !router->IsHidden () && router != compatibleWith &&
(reverse ? compatibleWith->IsReachableFrom (*router) :
router->IsReachableFrom (*compatibleWith)) &&
router->IsECIES ();
router->IsECIES () && !router->IsHighCongestion (false);
});
}
@ -1206,7 +1206,7 @@ namespace data
router->IsReachableFrom (*compatibleWith)) &&
(router->GetCaps () & RouterInfo::eHighBandwidth) &&
router->GetVersion () >= NETDB_MIN_HIGHBANDWIDTH_VERSION &&
router->IsECIES () && !router->IsHighCongestion ();
router->IsECIES () && !router->IsHighCongestion (true);
});
}

@ -1113,13 +1113,25 @@ namespace data
m_Timestamp = i2p::util::GetMillisecondsSinceEpoch ();
}
bool RouterInfo::IsHighCongestion () const
bool RouterInfo::IsHighCongestion (bool highBandwidth) const
{
if (m_Congestion == eLowCongestion || m_Congestion == eMediumCongestion) return false;
if (m_Congestion == eRejectAll) return true;
if (m_Congestion == eHighCongestion)
return (i2p::util::GetMillisecondsSinceEpoch () < m_Timestamp + HIGH_CONGESTION_INTERVAL*1000LL) ? true : false;
return false;
switch (m_Congestion)
{
case eLowCongestion:
return false;
break;
case eMediumCongestion:
return highBandwidth;
break;
case eHighCongestion:
return i2p::util::GetMillisecondsSinceEpoch () < m_Timestamp + HIGH_CONGESTION_INTERVAL*1000LL;
break;
case eRejectAll:
return true;
break;
default:
return false;
}
}
void LocalRouterInfo::CreateBuffer (const PrivateKeys& privateKeys)

@ -250,7 +250,7 @@ namespace data
bool IsPublished (bool v4) const;
bool IsSSU2PeerTesting (bool v4) const;
bool IsSSU2Introducer (bool v4) const;
bool IsHighCongestion () const;
bool IsHighCongestion (bool highBandwidth) const;
uint8_t GetCaps () const { return m_Caps; };
void SetCaps (uint8_t caps) { m_Caps = caps; };

@ -753,14 +753,15 @@ namespace tunnel
return m_CustomPeerSelector != nullptr;
}
bool TunnelPool::ValidatePeers (std::vector<std::shared_ptr<const i2p::data::IdentityEx> >& peers)
bool TunnelPool::ValidatePeers (std::vector<std::shared_ptr<const i2p::data::IdentityEx> >& peers) const
{
bool highBandwidth = !IsExploratory ();
for (auto it: peers)
{
auto r = i2p::data::netdb.FindRouter (it->GetIdentHash ());
if (r)
{
if (r->IsHighCongestion ()) return false;
if (r->IsHighCongestion (highBandwidth)) return false;
it = r->GetIdentity (); // use identity from updated RouterInfo
}
}

@ -126,7 +126,7 @@ namespace tunnel
typename TTunnels::value_type excluded, i2p::data::RouterInfo::CompatibleTransports compatible) const;
bool SelectPeers (Path& path, bool isInbound);
bool SelectExplicitPeers (Path& path, bool isInbound);
static bool ValidatePeers (std::vector<std::shared_ptr<const i2p::data::IdentityEx> >& peers);
bool ValidatePeers (std::vector<std::shared_ptr<const i2p::data::IdentityEx> >& peers) const;
private:

Loading…
Cancel
Save