From 3bacdccff961b406af825c04f289e799b27ace20 Mon Sep 17 00:00:00 2001 From: Mason Garten Date: Wed, 7 Aug 2024 22:35:55 -0500 Subject: [PATCH 1/5] Enabling listening on tcp port when proxy is used for peer connections --- src/session_impl.cpp | 142 +++++++++++++++---------------------------- 1 file changed, 49 insertions(+), 93 deletions(-) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index b1efa6d1e3e..e20991f3986 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2055,85 +2055,70 @@ namespace { // if we don't proxy peer connections, don't apply the special logic for // proxies - if (m_settings.get_int(settings_pack::proxy_type) != settings_pack::none - && m_settings.get_bool(settings_pack::proxy_peer_connections)) - { - // we will be able to accept incoming connections over UDP. so use - // one of the ports the user specified to use a consistent port - // across sessions. If the user did not specify any ports, pick one - // at random - int const port = m_listen_interfaces.empty() - ? int(random(63000) + 2000) - : m_listen_interfaces.front().port; - listen_endpoint_t ep(address_v4::any(), port, {} - , transport::plaintext, listen_socket_t::proxy); - eps.emplace_back(ep); + + + std::vector const ifs = enum_net_interfaces(m_io_context, ec); + if (ec && m_alerts.should_post()) + { + m_alerts.emplace_alert("" + , operation_t::enum_if, ec, socket_type_t::tcp); } - else + auto const routes = enum_routes(m_io_context, ec); + if (ec && m_alerts.should_post()) { - std::vector const ifs = enum_net_interfaces(m_io_context, ec); - if (ec && m_alerts.should_post()) - { - m_alerts.emplace_alert("" - , operation_t::enum_if, ec, socket_type_t::tcp); - } - auto const routes = enum_routes(m_io_context, ec); - if (ec && m_alerts.should_post()) - { - m_alerts.emplace_alert("" - , operation_t::enum_route, ec, socket_type_t::tcp); - } + m_alerts.emplace_alert("" + , operation_t::enum_route, ec, socket_type_t::tcp); + } - // expand device names and populate eps - for (auto const& iface : m_listen_interfaces) - { + // expand device names and populate eps + for (auto const& iface : m_listen_interfaces) + { #if !TORRENT_USE_SSL - if (iface.ssl) - { + if (iface.ssl) + { #ifndef TORRENT_DISABLE_LOGGING - session_log("attempted to listen ssl with no library support on device: \"%s\"" - , iface.device.c_str()); + session_log("attempted to listen ssl with no library support on device: \"%s\"" + , iface.device.c_str()); #endif - if (m_alerts.should_post()) - { - m_alerts.emplace_alert(iface.device - , operation_t::sock_open - , boost::asio::error::operation_not_supported - , socket_type_t::tcp_ssl); - } - continue; + if (m_alerts.should_post()) + { + m_alerts.emplace_alert(iface.device + , operation_t::sock_open + , boost::asio::error::operation_not_supported + , socket_type_t::tcp_ssl); } + continue; + } #endif - // now we have a device to bind to. This device may actually just be an - // 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, listen_socket_t::accept_incoming, ifs, eps); - } + // now we have a device to bind to. This device may actually just be an + // 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, listen_socket_t::accept_incoming, ifs, eps); + } - if (eps.empty()) - { + if (eps.empty()) + { #ifndef TORRENT_DISABLE_LOGGING - session_log("no listen sockets"); + session_log("no listen sockets"); #endif - } + } #if defined TORRENT_ANDROID && __ANDROID_API__ >= 24 - // For Android API >= 24, enum_routes with the current NETLINK based - // implementation is unsupported (maybe in the future the operation - // will be restore using another implementation). If routes is empty, - // allow using unspecified address is a best effort approach that - // seems to work. The issue with this approach is with the DHTs, - // because for IPv6 this is not following BEP 32 and BEP 45. See: - // https://www.bittorrent.org/beps/bep_0032.html - // https://www.bittorrent.org/beps/bep_0045.html - if (!routes.empty()) expand_unspecified_address(ifs, routes, eps); + // For Android API >= 24, enum_routes with the current NETLINK based + // implementation is unsupported (maybe in the future the operation + // will be restore using another implementation). If routes is empty, + // allow using unspecified address is a best effort approach that + // seems to work. The issue with this approach is with the DHTs, + // because for IPv6 this is not following BEP 32 and BEP 45. See: + // https://www.bittorrent.org/beps/bep_0032.html + // https://www.bittorrent.org/beps/bep_0045.html + if (!routes.empty()) expand_unspecified_address(ifs, routes, eps); #else - expand_unspecified_address(ifs, routes, eps); + expand_unspecified_address(ifs, routes, eps); #endif - expand_devices(ifs, eps); - } + expand_devices(ifs, eps); auto remove_iter = partition_listen_sockets(eps, m_listen_sockets); @@ -2819,14 +2804,8 @@ namespace { } async_accept(listener, ssl); - // don't accept any connections from our local listen sockets if we're - // using a proxy. We should only accept peers via the proxy, never - // directly. // This path is only for accepting incoming TCP sockets. The udp_socket // class also restricts incoming packets based on proxy settings. - if (m_settings.get_int(settings_pack::proxy_type) != settings_pack::none - && m_settings.get_bool(settings_pack::proxy_peer_connections)) - return; auto listen = std::find_if(m_listen_sockets.begin(), m_listen_sockets.end() , [&listener](std::shared_ptr const& l) @@ -5522,12 +5501,8 @@ namespace { if (m_listen_sockets.empty()) return 0; if (sock) { - // if we're using a proxy, we won't be able to accept any TCP - // connections. Not even uTP connections via the port we know about. // The DHT may use the implied port to make it work, but the port we // announce here has no relevance for that. - if (sock->flags & listen_socket_t::proxy) - return 0; if (!(sock->flags & listen_socket_t::accept_incoming)) return 0; @@ -5566,9 +5541,6 @@ namespace { return std::uint16_t(sock->tcp_external_port()); } - if (m_settings.get_int(settings_pack::proxy_type) != settings_pack::none - && m_settings.get_bool(settings_pack::proxy_peer_connections)) - return 0; for (auto const& s : m_listen_sockets) { @@ -5661,21 +5633,6 @@ namespace { // they can't be reached from outside of the local network anyways if (is_v6(s->local_endpoint) && is_local(s->local_endpoint.address())) return; - - if (!s->natpmp_mapper - && !(s->flags & listen_socket_t::local_network) - && !(s->flags & listen_socket_t::proxy)) - { - // the natpmp constructor may fail and call the callbacks - // into the session_impl. - s->natpmp_mapper = std::make_shared(m_io_context, *this, listen_socket_handle(s)); - ip_interface ip; - ip.interface_address = s->local_endpoint.address(); - ip.netmask = s->netmask; - std::strncpy(ip.name, s->device.c_str(), sizeof(ip.name) - 1); - ip.name[sizeof(ip.name) - 1] = '\0'; - s->natpmp_mapper->start(ip); - } } void session_impl::on_port_mapping(port_mapping_t const mapping @@ -6890,8 +6847,7 @@ namespace { // there's no point in starting the UPnP mapper for a network that isn't // connected to the internet. The whole point is to forward ports through // the gateway - if ((s->flags & listen_socket_t::local_network) - || (s->flags & listen_socket_t::proxy)) + if ((s->flags & listen_socket_t::local_network)) return; if (!s->upnp_mapper) From 4bf0c2110ddaaf55adf3d631027e523b4080957e Mon Sep 17 00:00:00 2001 From: Masong19hippows Date: Wed, 2 Oct 2024 15:27:18 -0500 Subject: [PATCH 2/5] Correct natpmp --- src/session_impl.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index e20991f3986..8f8235d9259 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -5633,6 +5633,20 @@ namespace { // they can't be reached from outside of the local network anyways if (is_v6(s->local_endpoint) && is_local(s->local_endpoint.address())) return; + + if (!s->natpmp_mapper + && !(s->flags & listen_socket_t::local_network)) + { + // the natpmp constructor may fail and call the callbacks + // into the session_impl. + s->natpmp_mapper = std::make_shared(m_io_context, *this, listen_socket_handle(s)); + ip_interface ip; + ip.interface_address = s->local_endpoint.address(); + ip.netmask = s->netmask; + std::strncpy(ip.name, s->device.c_str(), sizeof(ip.name) - 1); + ip.name[sizeof(ip.name) - 1] = '\0'; + s->natpmp_mapper->start(ip); + } } void session_impl::on_port_mapping(port_mapping_t const mapping From 2db609bc649b736dd51eaf3641efbe11dd9be623 Mon Sep 17 00:00:00 2001 From: Masong19hippows Date: Wed, 16 Oct 2024 15:07:30 -0500 Subject: [PATCH 3/5] Adding listen proxy setting --- include/libtorrent/aux_/proxy_settings.hpp | 4 + src/proxy_settings.cpp | 1 + src/session_impl.cpp | 133 +++++++++++++-------- 3 files changed, 88 insertions(+), 50 deletions(-) diff --git a/include/libtorrent/aux_/proxy_settings.hpp b/include/libtorrent/aux_/proxy_settings.hpp index 57cf0b64f92..88e2e057d25 100644 --- a/include/libtorrent/aux_/proxy_settings.hpp +++ b/include/libtorrent/aux_/proxy_settings.hpp @@ -79,6 +79,10 @@ namespace aux { // This is only supported by SOCKS5 and HTTP. bool proxy_hostnames = true; + // defaults to false for integration compatibility. It means that the + // torrent port is listening with tcp and udp while there is a proxy configured. + bool listen_on_proxy = false; + // determines whether or not to exempt peer and web seed connections // from using the proxy. This defaults to true, i.e. peer connections are // proxied by default. diff --git a/src/proxy_settings.cpp b/src/proxy_settings.cpp index 01fa002555f..3288546445f 100644 --- a/src/proxy_settings.cpp +++ b/src/proxy_settings.cpp @@ -47,6 +47,7 @@ void init(proxy_settings& p, Settings const& sett) p.type = settings_pack::proxy_type_t(sett.get_int(settings_pack::proxy_type)); p.port = std::uint16_t(sett.get_int(settings_pack::proxy_port)); p.proxy_hostnames = sett.get_bool(settings_pack::proxy_hostnames); + p.listen_on_proxy = sett.get_bool(settings_pack::listen_on_proxy); p.proxy_peer_connections = sett.get_bool( settings_pack::proxy_peer_connections); p.proxy_tracker_connections = sett.get_bool( diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 8f8235d9259..c0f9d49eedb 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2055,70 +2055,86 @@ namespace { // if we don't proxy peer connections, don't apply the special logic for // proxies - - - std::vector const ifs = enum_net_interfaces(m_io_context, ec); - if (ec && m_alerts.should_post()) - { - m_alerts.emplace_alert("" - , operation_t::enum_if, ec, socket_type_t::tcp); + if (m_settings.get_int(settings_pack::proxy_type) != settings_pack::none + && m_settings.get_bool(settings_pack::proxy_peer_connections) + && !m_settings.get_bool(settings_pack::listen_on_proxy)) + { + // we will be able to accept incoming connections over UDP. so use + // one of the ports the user specified to use a consistent port + // across sessions. If the user did not specify any ports, pick one + // at random + int const port = m_listen_interfaces.empty() + ? int(random(63000) + 2000) + : m_listen_interfaces.front().port; + listen_endpoint_t ep(address_v4::any(), port, {} + , transport::plaintext, listen_socket_t::proxy); + eps.emplace_back(ep); } - auto const routes = enum_routes(m_io_context, ec); - if (ec && m_alerts.should_post()) + else { - m_alerts.emplace_alert("" - , operation_t::enum_route, ec, socket_type_t::tcp); - } + std::vector const ifs = enum_net_interfaces(m_io_context, ec); + if (ec && m_alerts.should_post()) + { + m_alerts.emplace_alert("" + , operation_t::enum_if, ec, socket_type_t::tcp); + } + auto const routes = enum_routes(m_io_context, ec); + if (ec && m_alerts.should_post()) + { + m_alerts.emplace_alert("" + , operation_t::enum_route, ec, socket_type_t::tcp); + } - // expand device names and populate eps - for (auto const& iface : m_listen_interfaces) - { -#if !TORRENT_USE_SSL - if (iface.ssl) + // expand device names and populate eps + for (auto const& iface : m_listen_interfaces) { +#if !TORRENT_USE_SSL + if (iface.ssl) + { #ifndef TORRENT_DISABLE_LOGGING - session_log("attempted to listen ssl with no library support on device: \"%s\"" - , iface.device.c_str()); + session_log("attempted to listen ssl with no library support on device: \"%s\"" + , iface.device.c_str()); #endif - if (m_alerts.should_post()) - { - m_alerts.emplace_alert(iface.device - , operation_t::sock_open - , boost::asio::error::operation_not_supported - , socket_type_t::tcp_ssl); + if (m_alerts.should_post()) + { + m_alerts.emplace_alert(iface.device + , operation_t::sock_open + , boost::asio::error::operation_not_supported + , socket_type_t::tcp_ssl); + } + continue; } - continue; - } #endif - // now we have a device to bind to. This device may actually just be an - // 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, listen_socket_t::accept_incoming, ifs, eps); - } + // now we have a device to bind to. This device may actually just be an + // 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, listen_socket_t::accept_incoming, ifs, eps); + } - if (eps.empty()) - { + if (eps.empty()) + { #ifndef TORRENT_DISABLE_LOGGING - session_log("no listen sockets"); + session_log("no listen sockets"); #endif - } + } #if defined TORRENT_ANDROID && __ANDROID_API__ >= 24 - // For Android API >= 24, enum_routes with the current NETLINK based - // implementation is unsupported (maybe in the future the operation - // will be restore using another implementation). If routes is empty, - // allow using unspecified address is a best effort approach that - // seems to work. The issue with this approach is with the DHTs, - // because for IPv6 this is not following BEP 32 and BEP 45. See: - // https://www.bittorrent.org/beps/bep_0032.html - // https://www.bittorrent.org/beps/bep_0045.html - if (!routes.empty()) expand_unspecified_address(ifs, routes, eps); + // For Android API >= 24, enum_routes with the current NETLINK based + // implementation is unsupported (maybe in the future the operation + // will be restore using another implementation). If routes is empty, + // allow using unspecified address is a best effort approach that + // seems to work. The issue with this approach is with the DHTs, + // because for IPv6 this is not following BEP 32 and BEP 45. See: + // https://www.bittorrent.org/beps/bep_0032.html + // https://www.bittorrent.org/beps/bep_0045.html + if (!routes.empty()) expand_unspecified_address(ifs, routes, eps); #else - expand_unspecified_address(ifs, routes, eps); + expand_unspecified_address(ifs, routes, eps); #endif - expand_devices(ifs, eps); + expand_devices(ifs, eps); + } auto remove_iter = partition_listen_sockets(eps, m_listen_sockets); @@ -2804,8 +2820,14 @@ namespace { } async_accept(listener, ssl); + // don't accept any connections from our local listen sockets if we're + // using a proxy and the correct setting isn't set. // This path is only for accepting incoming TCP sockets. The udp_socket // class also restricts incoming packets based on proxy settings. + if (m_settings.get_int(settings_pack::proxy_type) != settings_pack::none + && m_settings.get_bool(settings_pack::proxy_peer_connections) + && !m_settings.get_bool(settings_pack::listen_on_proxy)) + return; auto listen = std::find_if(m_listen_sockets.begin(), m_listen_sockets.end() , [&listener](std::shared_ptr const& l) @@ -5504,12 +5526,21 @@ namespace { // The DHT may use the implied port to make it work, but the port we // announce here has no relevance for that. + if (sock->flags & listen_socket_t::proxy + && !m_settings.get_bool(settings_pack::listen_on_proxy)) + return 0; + if (!(sock->flags & listen_socket_t::accept_incoming)) return 0; return std::uint16_t(sock->tcp_external_port()); } + if (m_settings.get_int(settings_pack::proxy_type) != settings_pack::none + && m_settings.get_bool(settings_pack::proxy_peer_connections) + && !m_settings.get_bool(settings_pack::listen_on_proxy)) + return 0; + #ifdef TORRENT_SSL_PEERS for (auto const& s : m_listen_sockets) { @@ -5635,7 +5666,8 @@ namespace { return; if (!s->natpmp_mapper - && !(s->flags & listen_socket_t::local_network)) + && !(s->flags & listen_socket_t::local_network) + && m_settings.get_bool(settings_pack::listen_on_proxy)) { // the natpmp constructor may fail and call the callbacks // into the session_impl. @@ -6861,7 +6893,8 @@ namespace { // there's no point in starting the UPnP mapper for a network that isn't // connected to the internet. The whole point is to forward ports through // the gateway - if ((s->flags & listen_socket_t::local_network)) + if ((s->flags & listen_socket_t::local_network) + || (s->flags & !m_settings.get_bool(settings_pack::listen_on_proxy))) return; if (!s->upnp_mapper) From eb2a910223f04b666a774337265f7fe6bd8b99b2 Mon Sep 17 00:00:00 2001 From: Masong19hippows Date: Wed, 16 Oct 2024 19:25:47 -0500 Subject: [PATCH 4/5] Fixed always on listening --- bindings/python/src/session_settings.cpp | 1 + include/libtorrent/settings_pack.hpp | 3 +++ simulation/make_proxy_settings.hpp | 1 + simulation/utils.cpp | 1 + src/session_handle.cpp | 1 + src/session_impl.cpp | 2 ++ src/settings_pack.cpp | 1 + 7 files changed, 10 insertions(+) diff --git a/bindings/python/src/session_settings.cpp b/bindings/python/src/session_settings.cpp index db93700b89a..1373c36ee6f 100644 --- a/bindings/python/src/session_settings.cpp +++ b/bindings/python/src/session_settings.cpp @@ -97,6 +97,7 @@ void bind_session_settings() .def_readwrite("type", &proxy_settings::type) .def_readwrite("proxy_peer_connections", &proxy_settings::proxy_peer_connections) .def_readwrite("proxy_hostnames", &proxy_settings::proxy_hostnames) + .def_readwrite("listen_on_proxy", &proxy_settings::listen_on_proxy) ; #endif } diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index 0446f2b60d6..907c935bace 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -876,6 +876,9 @@ namespace aux { // any). This is only supported by SOCKS5 and HTTP. proxy_hostnames, + // if true, listening on the defined port will be enabled while using proxy + listen_on_proxy, + // if true, peer connections are made (and accepted) over the // configured proxy, if any. Web seeds as well as regular bittorrent // peer connections are considered "peer connections". Anything diff --git a/simulation/make_proxy_settings.hpp b/simulation/make_proxy_settings.hpp index f073dabad99..806ca444bf9 100644 --- a/simulation/make_proxy_settings.hpp +++ b/simulation/make_proxy_settings.hpp @@ -43,6 +43,7 @@ inline lt::aux::proxy_settings make_proxy_settings( aux::proxy_settings ps; ps.type = proxy_type; ps.proxy_hostnames = false; + ps.listen_on_proxy = false; // this IP and ports are specific to test_http_connection.cpp if (proxy_type != settings_pack::none) { diff --git a/simulation/utils.cpp b/simulation/utils.cpp index e6496b0d052..1e4c2dc57e3 100644 --- a/simulation/utils.cpp +++ b/simulation/utils.cpp @@ -191,6 +191,7 @@ void set_proxy(lt::session& ses, int proxy_type, test_transfer_flags_t const fla else p.set_str(settings_pack::proxy_hostname, "50.50.50.50"); p.set_bool(settings_pack::proxy_hostnames, true); + p.set_bool(settings_pack::listen_on_proxy, false); p.set_bool(settings_pack::proxy_peer_connections, bool(flags & tx::proxy_peers)); p.set_bool(settings_pack::proxy_tracker_connections, proxy_peers); p.set_bool(settings_pack::socks5_udp_send_local_ep, true); diff --git a/src/session_handle.cpp b/src/session_handle.cpp index e4bb290eeb8..86bedb35e00 100644 --- a/src/session_handle.cpp +++ b/src/session_handle.cpp @@ -1040,6 +1040,7 @@ namespace { p.set_int(settings_pack::proxy_type, s.type); p.set_int(settings_pack::proxy_port, s.port); p.set_bool(settings_pack::proxy_hostnames,s.proxy_hostnames); + p.set_bool(settings_pack::listen_on_proxy,s.listen_on_proxy); p.set_bool(settings_pack::proxy_peer_connections, s.proxy_peer_connections); apply_settings(std::move(p)); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index c0f9d49eedb..5ffb52ebf49 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -830,6 +830,8 @@ bool ssl_server_name_callback(ssl::stream_handle_type stream_handle, std::string if (val) s.set_int(settings_pack::proxy_type, int(val.int_value())); val = settings.dict_find_int("proxy_hostnames"); if (val) s.set_bool(settings_pack::proxy_hostnames, val.int_value() != 0); + val = settings.dict_find_int("listen_on_proxy"); + if (val) s.set_bool(settings_pack::listen_on_proxy, val.int_value() != 0); val = settings.dict_find_int("proxy_peer_connections"); if (val) s.set_bool(settings_pack::proxy_peer_connections, val.int_value() != 0); val = settings.dict_find_string("hostname"); diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index 5a2c20f7405..232b8584507 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -220,6 +220,7 @@ constexpr int DISK_WRITE_MODE = settings_pack::enable_os_cache; SET(enable_dht, true, &session_impl::update_dht), SET(prefer_rc4, false, nullptr), SET(proxy_hostnames, true, nullptr), + SET(listen_on_proxy, false, nullptr), SET(proxy_peer_connections, true, nullptr), SET(auto_sequential, true, &session_impl::update_auto_sequential), SET(proxy_tracker_connections, true, nullptr), From 91081ce7eb5eff128df3f8fe1f8294f95c1675aa Mon Sep 17 00:00:00 2001 From: Masong19hippows Date: Sun, 27 Oct 2024 14:49:22 -0500 Subject: [PATCH 5/5] Changing listen_on_proxy to proxy_accept_incoming --- bindings/python/src/session_settings.cpp | 2 +- include/libtorrent/aux_/proxy_settings.hpp | 2 +- include/libtorrent/settings_pack.hpp | 2 +- simulation/make_proxy_settings.hpp | 2 +- simulation/utils.cpp | 2 +- src/proxy_settings.cpp | 2 +- src/session_handle.cpp | 2 +- src/session_impl.cpp | 16 ++++++++-------- src/settings_pack.cpp | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bindings/python/src/session_settings.cpp b/bindings/python/src/session_settings.cpp index 1373c36ee6f..33a97c087ca 100644 --- a/bindings/python/src/session_settings.cpp +++ b/bindings/python/src/session_settings.cpp @@ -97,7 +97,7 @@ void bind_session_settings() .def_readwrite("type", &proxy_settings::type) .def_readwrite("proxy_peer_connections", &proxy_settings::proxy_peer_connections) .def_readwrite("proxy_hostnames", &proxy_settings::proxy_hostnames) - .def_readwrite("listen_on_proxy", &proxy_settings::listen_on_proxy) + .def_readwrite("proxy_accept_incoming", &proxy_settings::proxy_accept_incoming) ; #endif } diff --git a/include/libtorrent/aux_/proxy_settings.hpp b/include/libtorrent/aux_/proxy_settings.hpp index 88e2e057d25..f9906536e8c 100644 --- a/include/libtorrent/aux_/proxy_settings.hpp +++ b/include/libtorrent/aux_/proxy_settings.hpp @@ -81,7 +81,7 @@ namespace aux { // defaults to false for integration compatibility. It means that the // torrent port is listening with tcp and udp while there is a proxy configured. - bool listen_on_proxy = false; + bool proxy_accept_incoming = false; // determines whether or not to exempt peer and web seed connections // from using the proxy. This defaults to true, i.e. peer connections are diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index 907c935bace..81edb54d53d 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -877,7 +877,7 @@ namespace aux { proxy_hostnames, // if true, listening on the defined port will be enabled while using proxy - listen_on_proxy, + proxy_accept_incoming, // if true, peer connections are made (and accepted) over the // configured proxy, if any. Web seeds as well as regular bittorrent diff --git a/simulation/make_proxy_settings.hpp b/simulation/make_proxy_settings.hpp index 806ca444bf9..a08c81c5d53 100644 --- a/simulation/make_proxy_settings.hpp +++ b/simulation/make_proxy_settings.hpp @@ -43,7 +43,7 @@ inline lt::aux::proxy_settings make_proxy_settings( aux::proxy_settings ps; ps.type = proxy_type; ps.proxy_hostnames = false; - ps.listen_on_proxy = false; + ps.proxy_accept_incoming = false; // this IP and ports are specific to test_http_connection.cpp if (proxy_type != settings_pack::none) { diff --git a/simulation/utils.cpp b/simulation/utils.cpp index 1e4c2dc57e3..644107aa356 100644 --- a/simulation/utils.cpp +++ b/simulation/utils.cpp @@ -191,7 +191,7 @@ void set_proxy(lt::session& ses, int proxy_type, test_transfer_flags_t const fla else p.set_str(settings_pack::proxy_hostname, "50.50.50.50"); p.set_bool(settings_pack::proxy_hostnames, true); - p.set_bool(settings_pack::listen_on_proxy, false); + p.set_bool(settings_pack::proxy_accept_incoming, false); p.set_bool(settings_pack::proxy_peer_connections, bool(flags & tx::proxy_peers)); p.set_bool(settings_pack::proxy_tracker_connections, proxy_peers); p.set_bool(settings_pack::socks5_udp_send_local_ep, true); diff --git a/src/proxy_settings.cpp b/src/proxy_settings.cpp index 3288546445f..587cb8757f6 100644 --- a/src/proxy_settings.cpp +++ b/src/proxy_settings.cpp @@ -47,7 +47,7 @@ void init(proxy_settings& p, Settings const& sett) p.type = settings_pack::proxy_type_t(sett.get_int(settings_pack::proxy_type)); p.port = std::uint16_t(sett.get_int(settings_pack::proxy_port)); p.proxy_hostnames = sett.get_bool(settings_pack::proxy_hostnames); - p.listen_on_proxy = sett.get_bool(settings_pack::listen_on_proxy); + p.proxy_accept_incoming = sett.get_bool(settings_pack::proxy_accept_incoming); p.proxy_peer_connections = sett.get_bool( settings_pack::proxy_peer_connections); p.proxy_tracker_connections = sett.get_bool( diff --git a/src/session_handle.cpp b/src/session_handle.cpp index 86bedb35e00..00268c5842c 100644 --- a/src/session_handle.cpp +++ b/src/session_handle.cpp @@ -1040,7 +1040,7 @@ namespace { p.set_int(settings_pack::proxy_type, s.type); p.set_int(settings_pack::proxy_port, s.port); p.set_bool(settings_pack::proxy_hostnames,s.proxy_hostnames); - p.set_bool(settings_pack::listen_on_proxy,s.listen_on_proxy); + p.set_bool(settings_pack::proxy_accept_incoming,s.proxy_accept_incoming); p.set_bool(settings_pack::proxy_peer_connections, s.proxy_peer_connections); apply_settings(std::move(p)); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 5ffb52ebf49..471c8ff9d4b 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -830,8 +830,8 @@ bool ssl_server_name_callback(ssl::stream_handle_type stream_handle, std::string if (val) s.set_int(settings_pack::proxy_type, int(val.int_value())); val = settings.dict_find_int("proxy_hostnames"); if (val) s.set_bool(settings_pack::proxy_hostnames, val.int_value() != 0); - val = settings.dict_find_int("listen_on_proxy"); - if (val) s.set_bool(settings_pack::listen_on_proxy, val.int_value() != 0); + val = settings.dict_find_int("proxy_accept_incoming"); + if (val) s.set_bool(settings_pack::proxy_accept_incoming, val.int_value() != 0); val = settings.dict_find_int("proxy_peer_connections"); if (val) s.set_bool(settings_pack::proxy_peer_connections, val.int_value() != 0); val = settings.dict_find_string("hostname"); @@ -2059,7 +2059,7 @@ namespace { // proxies if (m_settings.get_int(settings_pack::proxy_type) != settings_pack::none && m_settings.get_bool(settings_pack::proxy_peer_connections) - && !m_settings.get_bool(settings_pack::listen_on_proxy)) + && !m_settings.get_bool(settings_pack::proxy_accept_incoming)) { // we will be able to accept incoming connections over UDP. so use // one of the ports the user specified to use a consistent port @@ -2828,7 +2828,7 @@ namespace { // class also restricts incoming packets based on proxy settings. if (m_settings.get_int(settings_pack::proxy_type) != settings_pack::none && m_settings.get_bool(settings_pack::proxy_peer_connections) - && !m_settings.get_bool(settings_pack::listen_on_proxy)) + && !m_settings.get_bool(settings_pack::proxy_accept_incoming)) return; auto listen = std::find_if(m_listen_sockets.begin(), m_listen_sockets.end() @@ -5529,7 +5529,7 @@ namespace { // announce here has no relevance for that. if (sock->flags & listen_socket_t::proxy - && !m_settings.get_bool(settings_pack::listen_on_proxy)) + && !m_settings.get_bool(settings_pack::proxy_accept_incoming)) return 0; if (!(sock->flags & listen_socket_t::accept_incoming)) @@ -5540,7 +5540,7 @@ namespace { if (m_settings.get_int(settings_pack::proxy_type) != settings_pack::none && m_settings.get_bool(settings_pack::proxy_peer_connections) - && !m_settings.get_bool(settings_pack::listen_on_proxy)) + && !m_settings.get_bool(settings_pack::proxy_accept_incoming)) return 0; #ifdef TORRENT_SSL_PEERS @@ -5669,7 +5669,7 @@ namespace { if (!s->natpmp_mapper && !(s->flags & listen_socket_t::local_network) - && m_settings.get_bool(settings_pack::listen_on_proxy)) + && m_settings.get_bool(settings_pack::proxy_accept_incoming)) { // the natpmp constructor may fail and call the callbacks // into the session_impl. @@ -6896,7 +6896,7 @@ namespace { // connected to the internet. The whole point is to forward ports through // the gateway if ((s->flags & listen_socket_t::local_network) - || (s->flags & !m_settings.get_bool(settings_pack::listen_on_proxy))) + || (s->flags & !m_settings.get_bool(settings_pack::proxy_accept_incoming))) return; if (!s->upnp_mapper) diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index 232b8584507..42caa308145 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -220,7 +220,7 @@ constexpr int DISK_WRITE_MODE = settings_pack::enable_os_cache; SET(enable_dht, true, &session_impl::update_dht), SET(prefer_rc4, false, nullptr), SET(proxy_hostnames, true, nullptr), - SET(listen_on_proxy, false, nullptr), + SET(proxy_accept_incoming, false, nullptr), SET(proxy_peer_connections, true, nullptr), SET(auto_sequential, true, &session_impl::update_auto_sequential), SET(proxy_tracker_connections, true, nullptr),