| 1189 | } |
| 1190 | |
| 1191 | std::shared_ptr<const RouterInfo> NetDb::GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, |
| 1192 | bool reverse, bool endpoint) const |
| 1193 | { |
| 1194 | bool checkIsReal = i2p::tunnel::tunnels.GetPreciseTunnelCreationSuccessRate () < NETDB_TUNNEL_CREATION_RATE_THRESHOLD && // too low rate |
| 1195 | context.GetUptime () > NETDB_CHECK_FOR_EXPIRATION_UPTIME; // after 10 minutes uptime |
| 1196 | return GetRandomRouter ( |
| 1197 | [compatibleWith, reverse, endpoint, checkIsReal](std::shared_ptr<const RouterInfo> router)->bool |
| 1198 | { |
| 1199 | return !router->IsHidden () && router != compatibleWith && |
| 1200 | (reverse ? (compatibleWith->IsReachableFrom (*router) && router->GetCompatibleTransports (true)) : |
| 1201 | router->IsReachableFrom (*compatibleWith)) && !router->IsNAT2NATOnly (*compatibleWith) && |
| 1202 | (router->GetCaps () & RouterInfo::eHighBandwidth) && |
| 1203 | router->GetVersion () >= NETDB_MIN_HIGHBANDWIDTH_VERSION && |
| 1204 | router->IsECIES () && !router->IsHighCongestion (true) && |
| 1205 | (!i2p::transport::transports.IsCheckReserved () || (!router->IsSameFamily (*compatibleWith) && !router->IsSameSubnet (*compatibleWith))) && |
| 1206 | (!checkIsReal || router->GetProfile ()->IsReal ()) && |
| 1207 | (!endpoint || (router->IsV4 () && (!reverse || router->IsPublished (true)))); // endpoint must be ipv4 and published if inbound(reverse) |
| 1208 | |
| 1209 | }); |
| 1210 | } |
| 1211 | |
| 1212 | template<typename Filter> |
| 1213 | std::shared_ptr<const RouterInfo> NetDb::GetRandomRouter (Filter filter) const |
no test coverage detected