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) &&