expanding a device does not look for a default route
This commit is contained in:
parent
1e4083b3fb
commit
14d5c99a18
|
@ -776,7 +776,10 @@ unless the following conditions are met:
|
|||
* the IP address is not in a known loopback range
|
||||
* the item the IP address was expanded from was not marked local (``l``)
|
||||
* the IP address is in a globally reachable IP address range OR the routing
|
||||
table contains a default route with a gateway for the corresponding network
|
||||
table contains a default route with a gateway for the corresponding network.
|
||||
This bullet only applies when expanding from an unspecified IP address. When
|
||||
explicitly specifying a device, we don't need to find a route to treat it as
|
||||
external.
|
||||
|
||||
The NAT-PMP/PCP and UPnP port mapper objects are only created for networks that
|
||||
are expected to be externally available (i.e. not "local network"). If there are
|
||||
|
|
|
@ -292,7 +292,6 @@ namespace aux {
|
|||
listen_interface_t const& iface
|
||||
, listen_socket_flags_t flags
|
||||
, span<ip_interface const> const ifs
|
||||
, span<ip_route const> const routes
|
||||
, std::vector<listen_endpoint_t>& eps);
|
||||
|
||||
// expand [::] to all IPv6 interfaces for BEP 45 compliance
|
||||
|
|
|
@ -1747,7 +1747,6 @@ namespace aux {
|
|||
void interface_to_endpoints(listen_interface_t const& iface
|
||||
, listen_socket_flags_t flags
|
||||
, span<ip_interface const> const ifs
|
||||
, span<ip_route const> const routes
|
||||
, std::vector<listen_endpoint_t>& eps)
|
||||
{
|
||||
flags |= iface.local ? listen_socket_t::local_network : listen_socket_flags_t{};
|
||||
|
@ -1779,9 +1778,7 @@ namespace aux {
|
|||
// bother looking for the gateway
|
||||
bool const local = iface.local
|
||||
|| ipface.interface_address.is_loopback()
|
||||
|| is_link_local(ipface.interface_address)
|
||||
|| (!is_global(ipface.interface_address)
|
||||
&& !has_default_route(ipface.name, family(ipface.interface_address), routes));
|
||||
|| is_link_local(ipface.interface_address);
|
||||
|
||||
eps.emplace_back(ipface.interface_address, iface.port, iface.device
|
||||
, ssl, flags | (local ? listen_socket_t::local_network : listen_socket_flags_t{}));
|
||||
|
@ -1851,7 +1848,7 @@ namespace aux {
|
|||
// IP address or a device name. In case it's a device name, we want to
|
||||
// (potentially) end up binding a socket for each IP address associated
|
||||
// with that device.
|
||||
interface_to_endpoints(iface, flags, ifs, routes, eps);
|
||||
interface_to_endpoints(iface, flags, ifs, eps);
|
||||
}
|
||||
|
||||
// if no listen interfaces are specified, create sockets to use
|
||||
|
|
|
@ -391,11 +391,10 @@ TORRENT_TEST(expand_unspecified)
|
|||
|
||||
namespace {
|
||||
std::vector<aux::listen_endpoint_t> to_endpoint(listen_interface_t const& iface
|
||||
, span<ip_interface const> const ifs
|
||||
, span<ip_route const> const routes)
|
||||
, span<ip_interface const> const ifs)
|
||||
{
|
||||
std::vector<aux::listen_endpoint_t> ret;
|
||||
interface_to_endpoints(iface, aux::listen_socket_t::accept_incoming, ifs, routes, ret);
|
||||
interface_to_endpoints(iface, aux::listen_socket_t::accept_incoming, ifs, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -411,7 +410,7 @@ using ls = aux::listen_socket_t;
|
|||
|
||||
TORRENT_TEST(interface_to_endpoint)
|
||||
{
|
||||
TEST_CHECK(to_endpoint(ift("10.0.1.1", 6881), {}, {}) == eps{ep("10.0.1.1", 6881)});
|
||||
TEST_CHECK(to_endpoint(ift("10.0.1.1", 6881), {}) == eps{ep("10.0.1.1", 6881)});
|
||||
|
||||
|
||||
std::vector<ip_interface> const ifs = {
|
||||
|
@ -423,25 +422,19 @@ TORRENT_TEST(interface_to_endpoint)
|
|||
, ifc("2601:646:c600:a3:d250:99ff:fe0c:9b74", "eth1")
|
||||
};
|
||||
|
||||
TEST_CHECK((to_endpoint(ift("eth0", 1234), ifs, {})
|
||||
TEST_CHECK((to_endpoint(ift("eth0", 1234), ifs)
|
||||
== eps{ep("185.0.1.2", 1234, "eth0", ls::was_expanded | ls::accept_incoming)
|
||||
, ep("fe80::d250:99ff:fe0c:9b74", 1234, "eth0", ls::was_expanded | ls::accept_incoming | ls::local_network)}));
|
||||
|
||||
TEST_CHECK((to_endpoint(ift("eth1", 1234), ifs, {})
|
||||
== eps{ep("192.168.2.2", 1234, "eth1", ls::was_expanded | ls::accept_incoming | ls::local_network)
|
||||
TEST_CHECK((to_endpoint(ift("eth1", 1234), ifs)
|
||||
== eps{ep("192.168.2.2", 1234, "eth1", ls::was_expanded | ls::accept_incoming)
|
||||
, ep("2601:646:c600:a3:d250:99ff:fe0c:9b74", 1234, "eth1", ls::was_expanded | ls::accept_incoming)}));
|
||||
|
||||
std::vector<ip_route> const routes = {
|
||||
rt("0.0.0.0", "eth1", "3.4.5.6"),
|
||||
rt("0.0.0.0", "eth0", "1.2.3.4"),
|
||||
rt("::", "eth0", "1234:5678::1"),
|
||||
};
|
||||
|
||||
std::vector<ip_interface> const ifs2 = {
|
||||
ifc("10.0.1.1", "eth0")
|
||||
};
|
||||
|
||||
TEST_CHECK((to_endpoint(ift("eth0", 1234), ifs2, routes)
|
||||
TEST_CHECK((to_endpoint(ift("eth0", 1234), ifs2)
|
||||
== eps{ep("10.0.1.1", 1234, "eth0", ls::was_expanded | ls::accept_incoming)}));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue