select OBEP/IBGW based on peer ordering key for low bandwidth tunnels

This commit is contained in:
orignal
2026-05-27 20:14:07 -04:00
parent a00a70c448
commit 8350ebb308
3 changed files with 11 additions and 4 deletions
+8 -2
View File
@@ -1151,13 +1151,19 @@ namespace data
}
std::shared_ptr<const RouterInfo> NetDb::GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith,
bool reverse, bool endpoint, bool clientTunnel) const
bool reverse, bool endpoint, bool clientTunnel, PeerOrdering * peerOrdering) const
{
bool checkIsReal = clientTunnel && i2p::tunnel::tunnels.GetPreciseTunnelCreationSuccessRate () < NETDB_TUNNEL_CREATION_RATE_THRESHOLD && // too low rate
context.GetUptime () > NETDB_CHECK_FOR_EXPIRATION_UPTIME; // after 10 minutes uptime
return GetRandomRouter (
[compatibleWith, reverse, endpoint, clientTunnel, checkIsReal](std::shared_ptr<const RouterInfo> router)->bool
[compatibleWith, reverse, endpoint, clientTunnel, checkIsReal, peerOrdering](std::shared_ptr<const RouterInfo> router)->bool
{
if (peerOrdering)
{
bool lastHop = peerOrdering->IsLastHop (router->GetIdentHash ());
if (endpoint && !lastHop) return false;
if (lastHop && !endpoint && router->IsV4 ()) return false; // if router is eligible for endpoint but it's not
}
return !router->IsHidden () && router != compatibleWith &&
(reverse ? (compatibleWith->IsReachableFrom (*router) && router->GetCompatibleTransports (true)):
router->IsReachableFrom (*compatibleWith)) && !router->IsNAT2NATOnly (*compatibleWith) &&
+2 -1
View File
@@ -94,7 +94,8 @@ namespace data
void RequestDestination (const IdentHash& destination, RequestedDestination::RequestComplete requestComplete = nullptr, bool direct = true);
std::shared_ptr<const RouterInfo> GetRandomRouter () const;
std::shared_ptr<const RouterInfo> GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse, bool endpoint, bool clientTunnel) const;
std::shared_ptr<const RouterInfo> GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith,
bool reverse, bool endpoint, bool clientTunnel, PeerOrdering * peerOrdering = nullptr) const;
std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith,
bool reverse, bool endpoint, PeerOrdering * peerOrdering = nullptr) const;
std::shared_ptr<const RouterInfo> GetRandomSSU2PeerTestRouter (bool v4, const std::unordered_set<IdentHash>& excluded) const;
+1 -1
View File
@@ -578,7 +578,7 @@ namespace tunnel
hop = tryClient ?
(m_IsHighBandwidth ?
i2p::data::netdb.GetHighBandwidthRandomRouter (prevHop, reverse, endpoint, &m_PeerOrdering) :
i2p::data::netdb.GetRandomRouter (prevHop, reverse, endpoint, true)):
i2p::data::netdb.GetRandomRouter (prevHop, reverse, endpoint, true, &m_PeerOrdering)):
i2p::data::netdb.GetRandomRouter (prevHop, reverse, endpoint, false);
if (hop)
{