mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2024-11-17 21:26:04 +00:00
try to pick non-slow tunnel
This commit is contained in:
parent
8e3e35a36d
commit
e740d5fc4f
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user