From 91ecbb4b239e41af5702860d7c6705b4b096de16 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 22 Dec 2007 18:20:23 +0000 Subject: [PATCH] prioritizes local peers over non-local ones when finding connect candidates --- src/policy.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/policy.cpp b/src/policy.cpp index f203eaa56..29f135ab0 100755 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -540,6 +540,14 @@ namespace libtorrent TORRENT_ASSERT(i->second.connected <= now); + // don't replace a candidate that is on the local + // network with one that isn't. Local peers should + // always be tried first + if (candidate != m_peers.end() + && is_local(candidate->second.ip.address()) + && !is_local(i->second.ip.address())) + continue; + if (i->second.connected <= min_connect_time) { min_connect_time = i->second.connected;