fix issue where new listen sockets would not be opened when leaving force_proxy mode
This commit is contained in:
parent
d9de6767a7
commit
096ce54fae
|
@ -1,4 +1,5 @@
|
|||
|
||||
* fix listen socket issue when disabling "force_proxy" mode
|
||||
* fix full allocation failure on APFS
|
||||
|
||||
1.1.5 release
|
||||
|
|
|
@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "utils.hpp"
|
||||
#include "libtorrent/session.hpp"
|
||||
#include "libtorrent/socket.hpp"
|
||||
#include "libtorrent/alert_types.hpp"
|
||||
#include "simulator/simulator.hpp"
|
||||
#include "simulator/utils.hpp" // for timer
|
||||
#include "settings.hpp"
|
||||
|
@ -64,3 +65,52 @@ TORRENT_TEST(seed_mode)
|
|||
});
|
||||
}
|
||||
|
||||
TORRENT_TEST(force_proxy)
|
||||
{
|
||||
// setup the simulation
|
||||
sim::default_config network_cfg;
|
||||
sim::simulation sim{network_cfg};
|
||||
std::unique_ptr<sim::asio::io_service> ios{new sim::asio::io_service(sim
|
||||
, address_v4::from_string("50.0.0.1"))};
|
||||
lt::session_proxy zombie;
|
||||
|
||||
lt::settings_pack pack = settings();
|
||||
pack.set_bool(settings_pack::force_proxy, true);
|
||||
// create session
|
||||
std::shared_ptr<lt::session> ses = std::make_shared<lt::session>(pack, *ios);
|
||||
|
||||
// disable force proxy in 3 seconds (this should make us open up listen
|
||||
// sockets)
|
||||
sim::timer t1(sim, lt::seconds(3), [&](boost::system::error_code const& ec)
|
||||
{
|
||||
lt::settings_pack p;
|
||||
p.set_bool(settings_pack::force_proxy, false);
|
||||
ses->apply_settings(p);
|
||||
});
|
||||
|
||||
int num_listen_tcp = 0;
|
||||
int num_listen_udp = 0;
|
||||
print_alerts(*ses, [&](lt::session& ses, lt::alert const* a) {
|
||||
if (auto la = alert_cast<listen_succeeded_alert>(a))
|
||||
{
|
||||
if (la->sock_type == listen_succeeded_alert::tcp)
|
||||
++num_listen_tcp;
|
||||
else if (la->sock_type == listen_succeeded_alert::udp)
|
||||
++num_listen_udp;
|
||||
}
|
||||
});
|
||||
|
||||
// run for 10 seconds.
|
||||
sim::timer t2(sim, lt::seconds(10), [&](boost::system::error_code const& ec)
|
||||
{
|
||||
fprintf(stderr, "shutting down\n");
|
||||
// shut down
|
||||
zombie = ses->abort();
|
||||
ses.reset();
|
||||
});
|
||||
sim.run();
|
||||
|
||||
TEST_EQUAL(num_listen_tcp, 1);
|
||||
TEST_EQUAL(num_listen_udp, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -1673,6 +1673,9 @@ namespace aux {
|
|||
(pack.has_val(settings_pack::ssl_listen)
|
||||
&& pack.get_int(settings_pack::ssl_listen)
|
||||
!= m_settings.get_int(settings_pack::ssl_listen))
|
||||
|| (pack.has_val(settings_pack::force_proxy)
|
||||
&& !pack.get_bool(settings_pack::force_proxy)
|
||||
&& m_settings.get_bool(settings_pack::force_proxy))
|
||||
|| (pack.has_val(settings_pack::listen_interfaces)
|
||||
&& pack.get_str(settings_pack::listen_interfaces)
|
||||
!= m_settings.get_str(settings_pack::listen_interfaces));
|
||||
|
@ -1882,6 +1885,12 @@ retry:
|
|||
m_stats_counters.set_value(counters::has_incoming_connections, 0);
|
||||
ec.clear();
|
||||
|
||||
if (m_settings.get_bool(settings_pack::force_proxy))
|
||||
{
|
||||
// in force-proxy mode, we don't open any listen sockets
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_abort) return;
|
||||
|
||||
m_ipv6_interface = tcp::endpoint();
|
||||
|
@ -6493,7 +6502,17 @@ retry:
|
|||
m_ssl_udp_socket.set_force_proxy(m_settings.get_bool(settings_pack::force_proxy));
|
||||
#endif
|
||||
|
||||
if (!m_settings.get_bool(settings_pack::force_proxy)) return;
|
||||
if (!m_settings.get_bool(settings_pack::force_proxy))
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
session_log("force-proxy disabled");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
session_log("force-proxy enabled");
|
||||
#endif
|
||||
|
||||
// enable force_proxy mode. We don't want to accept any incoming
|
||||
// connections, except through a proxy.
|
||||
|
|
Loading…
Reference in New Issue