expand unspecified to loopback as well

This commit is contained in:
arvidn 2020-01-09 00:32:43 +01:00 committed by Arvid Norberg
parent 8be7ab559a
commit 0961427b50
2 changed files with 7 additions and 4 deletions

View File

@ -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)

View File

@ -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<aux::listen_endpoint_t> 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);
}