don't open any listen sockets if listen_interfaces is empty or misconfigured

This commit is contained in:
arvidn 2020-04-04 12:57:40 +02:00 committed by Arvid Norberg
parent 983b1d6422
commit c4a3937ac9
3 changed files with 8 additions and 14 deletions

View File

@ -1,3 +1,4 @@
* don't open any listen sockets if listen_interfaces is empty or misconfigured
* fix bug in auto disk cache size logic
* fix issue with outgoing_interfaces setting, where bind() would be called twice
* add build option to disable share-mode

View File

@ -547,16 +547,14 @@ TORRENT_TEST(ipv6_support)
TORRENT_TEST(announce_no_listen)
{
// if we don't listen on any sockets at all (but only make outgoing peer
// connections) we still need to make sure we announce to trackers
test_ipv6_support("", num_interfaces * 2, num_interfaces * 2);
// if we don't listen on any sockets at all we should not announce to trackers
test_ipv6_support("", 0, 0);
}
TORRENT_TEST(announce_udp_no_listen)
{
// since there's no actual udp tracker in this test, we will only try to
// announce once, and fail. We won't announce the event=stopped
test_udpv6_support("", num_interfaces * 1, num_interfaces * 1);
// if we don't listen on any sockets at all we should not announce to trackers
test_udpv6_support("", 0, 0);
}
TORRENT_TEST(ipv6_support_bind_v4_v6_any)

View File

@ -1866,14 +1866,11 @@ namespace {
interface_to_endpoints(iface, flags, ifs, eps);
}
// if no listen interfaces are specified, create sockets to use
// any interface
if (eps.empty())
{
eps.emplace_back(address_v4(), 0, "", transport::plaintext
, listen_socket_flags_t{});
eps.emplace_back(address_v6(), 0, "", transport::plaintext
, listen_socket_flags_t{});
#ifndef TORRENT_DISABLE_LOGGING
session_log("no listen sockets");
#endif
}
expand_unspecified_address(ifs, routes, eps);
@ -5004,8 +5001,6 @@ namespace {
if (m_interface_index >= m_outgoing_interfaces.size()) m_interface_index = 0;
std::string const& ifname = m_outgoing_interfaces[m_interface_index++];
if (ec) return bind_ep;
bind_ep.address(bind_socket_to_device(m_io_service, s
, remote_address.is_v4() ? tcp::v4() : tcp::v6()
, ifname.c_str(), bind_ep.port(), ec));