From 0961427b507871df7fa262af9c9011faecda95bf Mon Sep 17 00:00:00 2001 From: arvidn Date: Thu, 9 Jan 2020 00:32:43 +0100 Subject: [PATCH] expand unspecified to loopback as well --- src/session_impl.cpp | 2 -- test/test_listen_socket.cpp | 9 +++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index b349d80e0..6a900a5a2 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -260,8 +260,6 @@ namespace aux { continue; if (ipface.interface_address.is_v4()) continue; - if (ipface.interface_address.is_loopback()) - continue; if (!uep.device.empty() && uep.device != ipface.name) continue; if (std::any_of(eps.begin(), eps.end(), [&](listen_endpoint_t const& e) diff --git a/test/test_listen_socket.cpp b/test/test_listen_socket.cpp index d10246fb8..747291105 100644 --- a/test/test_listen_socket.cpp +++ b/test/test_listen_socket.cpp @@ -312,6 +312,8 @@ TORRENT_TEST(expand_unspecified) auto v6_ll_ssl = ep("fe80::d250:99ff:fe0c:9b74", 6884, tp::ssl); auto v6_g_nossl = ep("2601:646:c600:a3:d250:99ff:fe0c:9b74", 6883); auto v6_g_ssl = ep("2601:646:c600:a3:d250:99ff:fe0c:9b74", 6884, tp::ssl); + auto v6_loopb_ssl = ep("::1", 6884, tp::ssl); + auto v6_loopb_nossl= ep("::1", 6883); std::vector eps = { v4_nossl, v4_ssl, v6_unsp_nossl, v6_unsp_ssl @@ -319,13 +321,15 @@ TORRENT_TEST(expand_unspecified) aux::expand_unspecified_address(ifs, eps); - TEST_EQUAL(eps.size(), 6); + TEST_EQUAL(eps.size(), 8); TEST_CHECK(std::count(eps.begin(), eps.end(), v4_nossl) == 1); TEST_CHECK(std::count(eps.begin(), eps.end(), v4_ssl) == 1); TEST_CHECK(std::count(eps.begin(), eps.end(), v6_ll_nossl) == 1); TEST_CHECK(std::count(eps.begin(), eps.end(), v6_ll_ssl) == 1); TEST_CHECK(std::count(eps.begin(), eps.end(), v6_g_nossl) == 1); TEST_CHECK(std::count(eps.begin(), eps.end(), v6_g_ssl) == 1); + TEST_CHECK(std::count(eps.begin(), eps.end(), v6_loopb_ssl) == 1); + TEST_CHECK(std::count(eps.begin(), eps.end(), v6_loopb_nossl) == 1); TEST_CHECK(std::count(eps.begin(), eps.end(), v6_unsp_nossl) == 0); TEST_CHECK(std::count(eps.begin(), eps.end(), v6_unsp_ssl) == 0); @@ -338,9 +342,10 @@ TORRENT_TEST(expand_unspecified) aux::expand_unspecified_address(ifs, eps); - TEST_EQUAL(eps.size(), 2); + TEST_EQUAL(eps.size(), 3); TEST_CHECK(std::count(eps.begin(), eps.end(), v6_ll_nossl) == 1); TEST_CHECK(std::count(eps.begin(), eps.end(), v6_g_nossl) == 0); + TEST_CHECK(std::count(eps.begin(), eps.end(), v6_loopb_nossl) == 1); TEST_CHECK(std::count(eps.begin(), eps.end(), v6_g_nossl_dev) == 1); }