From ed3dbaa78e224700c2b3dc76408bf107563a391f Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 21 Nov 2015 09:30:02 -0500 Subject: [PATCH] also make sure trackers are subject to the IP filter --- simulation/test_ip_filter.cpp | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/simulation/test_ip_filter.cpp b/simulation/test_ip_filter.cpp index 55dabce14..072bcb9f9 100644 --- a/simulation/test_ip_filter.cpp +++ b/simulation/test_ip_filter.cpp @@ -289,3 +289,42 @@ TORRENT_TEST(apply_ip_filter_to_torrent) ); } +// make sure IP filters apply to trackers +TORRENT_TEST(ip_filter_trackers) +{ + lt::time_point start_time = lt::clock_type::now(); + + run_test( + [](lt::session& ses) + { + add_ip_filter(ses); + + lt::add_torrent_params params = create_torrent(0, false); + params.flags &= ~lt::add_torrent_params::flag_auto_managed; + params.flags &= ~lt::add_torrent_params::flag_paused; + params.trackers = { + "http://60.0.0.0:6881/announce" + , "http://60.0.0.1:6881/announce" + , "http://60.0.0.2:6881/announce" + , "http://60.0.0.3:6881/announce" + , "http://60.0.0.4:6881/announce" + }; + ses.async_add_torrent(params); + }, + + [&](lt::session& ses, std::vector const& alerts) + { + for (lt::alert const* a : alerts) + { + printf("%-3d %s\n", int(lt::duration_cast(a->timestamp() + - start_time).count()), a->message().c_str()); + } + }, + + [](lt::session& ses, std::array& test_peers) + { + check_tripped(test_peers, {{false, false, false, true, true}} ); + } + ); +} +