| 568 | } |
| 569 | |
| 570 | std::shared_ptr<const i2p::data::RouterInfo> TunnelPool::SelectNextHop (std::shared_ptr<const i2p::data::RouterInfo> prevHop, |
| 571 | bool reverse, bool endpoint) const |
| 572 | { |
| 573 | bool tryClient = !IsExploratory () && !i2p::context.IsLimitedConnectivity (); |
| 574 | std::shared_ptr<const i2p::data::RouterInfo> hop; |
| 575 | for (int i = 0; i < TUNNEL_POOL_MAX_HOP_SELECTION_ATTEMPTS; i++) |
| 576 | { |
| 577 | hop = tryClient ? |
| 578 | (m_IsHighBandwidth ? |
| 579 | i2p::data::netdb.GetHighBandwidthRandomRouter (prevHop, reverse, endpoint) : |
| 580 | i2p::data::netdb.GetRandomRouter (prevHop, reverse, endpoint, true)): |
| 581 | i2p::data::netdb.GetRandomRouter (prevHop, reverse, endpoint, false); |
| 582 | if (hop) |
| 583 | { |
| 584 | if ((!hop->HasProfile () || !hop->GetProfile ()->IsBad ()) && |
| 585 | (prevHop != i2p::context.GetSharedRouterInfo () || !i2p::transport::transports.IsTooManyConnectionsFromSubnet (hop))) |
| 586 | break; |
| 587 | } |
| 588 | else if (tryClient) |
| 589 | tryClient = false; |
| 590 | else |
| 591 | return nullptr; |
| 592 | } |
| 593 | return hop; |
| 594 | } |
| 595 | |
| 596 | bool TunnelPool::StandardSelectPeers(Path & path, int numHops, bool inbound, SelectHopFunc nextHop) |
| 597 | { |
nothing calls this directly
no test coverage detected