From d13109426a92765681ba688aed71fbb2e0807a1c Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 18 Jan 2020 01:34:01 +0100 Subject: [PATCH] fix test_lsd to pass reliably --- include/libtorrent/settings_pack.hpp | 7 ++++--- src/torrent.cpp | 4 ++-- test/test_lsd.cpp | 8 ++++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index 20e09da26..8704c8772 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -273,9 +273,10 @@ namespace aux { // determines if connections from the same IP address as existing // connections should be rejected or not. Rejecting multiple connections // from the same IP address will prevent abusive - // behavior by peers. It may be useful to allow such connections in - // cases where simulations are run on the same machine, and all peers - // in a swarm has the same IP address. + // behavior by peers. The logic for determining whether connections are + // to the same peer is more complicated with this enabled, and more + // likely to fail in some edge cases. It is not recommended to enable + // this feature. allow_multiple_connections_per_ip = bool_type_base, #if TORRENT_ABI_VERSION == 1 diff --git a/src/torrent.cpp b/src/torrent.cpp index af687498a..74254d493 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -3345,13 +3345,13 @@ bool is_downloading_state(int const st) bool need_update = false; for (auto const& i : resp.peers4) { - tcp::endpoint a(address_v4(i.ip), i.port); + tcp::endpoint const a(address_v4(i.ip), i.port); need_update |= bool(add_peer(a, peer_info::tracker) != nullptr); } for (auto const& i : resp.peers6) { - tcp::endpoint a(address_v6(i.ip), i.port); + tcp::endpoint const a(address_v6(i.ip), i.port); need_update |= bool(add_peer(a, peer_info::tracker) != nullptr); } diff --git a/test/test_lsd.cpp b/test/test_lsd.cpp index f7d535655..8bd96b2bc 100644 --- a/test/test_lsd.cpp +++ b/test/test_lsd.cpp @@ -53,8 +53,12 @@ void test_lsd() session_proxy p2; settings_pack pack; - pack.set_bool(settings_pack::allow_multiple_connections_per_ip, true); - pack.set_int(settings_pack::alert_mask, alert::error_notification | alert::session_log_notification | alert::status_notification); + pack.set_int(settings_pack::alert_mask, alert::error_notification + | alert::session_log_notification + | alert::torrent_log_notification + | alert::peer_log_notification + | alert::ip_block_notification + | alert::status_notification); pack.set_bool(settings_pack::enable_dht, false); pack.set_bool(settings_pack::enable_lsd, true); pack.set_bool(settings_pack::enable_upnp, false);