|
|
|
@ -172,13 +172,16 @@ namespace tunnel
@@ -172,13 +172,16 @@ namespace tunnel
|
|
|
|
|
{ |
|
|
|
|
if (tunnels.empty ()) return nullptr; |
|
|
|
|
uint32_t ind = rand () % (tunnels.size ()/2 + 1), i = 0; |
|
|
|
|
bool skipped = false; |
|
|
|
|
typename TTunnels::value_type tunnel = nullptr; |
|
|
|
|
for (const auto& it: tunnels) |
|
|
|
|
{ |
|
|
|
|
if (it->IsEstablished () && it != excluded) |
|
|
|
|
{ |
|
|
|
|
if(HasLatencyRequirement() && it->LatencyIsKnown() && !it->LatencyFitsRange(m_MinLatency, m_MaxLatency)) { |
|
|
|
|
i ++; |
|
|
|
|
if (it->IsSlow () || (HasLatencyRequirement() && it->LatencyIsKnown() && |
|
|
|
|
!it->LatencyFitsRange(m_MinLatency, m_MaxLatency))) |
|
|
|
|
{ |
|
|
|
|
i++; skipped = true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
tunnel = it; |
|
|
|
@ -186,7 +189,8 @@ namespace tunnel
@@ -186,7 +189,8 @@ namespace tunnel
|
|
|
|
|
} |
|
|
|
|
if (i > ind && tunnel) break; |
|
|
|
|
} |
|
|
|
|
if(HasLatencyRequirement() && !tunnel) { |
|
|
|
|
if (!tunnel && skipped) |
|
|
|
|
{ |
|
|
|
|
ind = rand () % (tunnels.size ()/2 + 1), i = 0; |
|
|
|
|
for (const auto& it: tunnels) |
|
|
|
|
{ |
|
|
|
|