try to pick non-slow tunnel

This commit is contained in:
orignal 2021-06-04 12:16:50 -04:00
parent 8e3e35a36d
commit e740d5fc4f

View File

@ -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
}
if (i > ind && tunnel) break;
}
if(HasLatencyRequirement() && !tunnel) {
if (!tunnel && skipped)
{
ind = rand () % (tunnels.size ()/2 + 1), i = 0;
for (const auto& it: tunnels)
{