mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-06-02 09:04:02 +00:00
select OBEP/IBGW based on peer ordering key for low bandwidth tunnels
This commit is contained in:
+8
-2
@@ -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
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user