merge RC_1_1 into master
This commit is contained in:
commit
22f8bdfebc
|
@ -78,6 +78,7 @@
|
|||
* resume data no longer has timestamps of files
|
||||
* require C++11 to build libtorrent
|
||||
|
||||
* 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"
|
||||
|
@ -112,3 +113,58 @@ TORRENT_TEST(ip_notifier_setting)
|
|||
|
||||
TEST_EQUAL(working_count, 2);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
// on session construction, we won't listen to TCP since we're in force-proxy
|
||||
// mode. We will open up the UDP sockets though, since they are used for
|
||||
// outgoing connections too.
|
||||
// when we disable force-proxy, we'll re-open the sockets and listen on TCP
|
||||
// connections this time, so we'll get a tcp_listen and a udp_listen.
|
||||
TEST_EQUAL(num_listen_tcp, 1);
|
||||
TEST_EQUAL(num_listen_udp, 2);
|
||||
}
|
||||
|
||||
|
|
|
@ -6400,7 +6400,17 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
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.
|
||||
|
|
|
@ -60,9 +60,9 @@ using namespace std::placeholders;
|
|||
using namespace lt;
|
||||
using std::ignore;
|
||||
|
||||
int const alert_mask = alert::all_categories
|
||||
& ~alert::progress_notification
|
||||
& ~alert::stats_notification;
|
||||
auto const alert_mask = alert::all_categories
|
||||
& ~alert::progress_notification
|
||||
& ~alert::stats_notification;
|
||||
|
||||
struct test_config_t
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue