forked from premiere/premiere-libtorrent
add a default DHT bootstrap node when it's enabled on session startup (#1008)
make the dht bootstrap nodes part of settings_pack instead, to make it possible to set them on startup. and add default
This commit is contained in:
parent
bfe9934d57
commit
80e5ce9b32
|
@ -1,5 +1,6 @@
|
|||
1.1.1 release
|
||||
|
||||
* add dht_bootstrap_node a setting in settings_pack (and add default)
|
||||
* make pad-file and symlink support conform to BEP47
|
||||
* fix piece picker bug that could result in division by zero
|
||||
* fix value of current_tracker when all tracker failed
|
||||
|
|
|
@ -26,7 +26,7 @@ class test_create_torrent(unittest.TestCase):
|
|||
class test_torrent_handle(unittest.TestCase):
|
||||
|
||||
def test_torrent_handle(self):
|
||||
ses = lt.session({'alert_mask': lt.alert.category_t.all_categories})
|
||||
ses = lt.session({'alert_mask': lt.alert.category_t.all_categories, 'enable_dht': False})
|
||||
ti = lt.torrent_info('url_seed_multi.torrent');
|
||||
h = ses.add_torrent({'ti': ti, 'save_path': os.getcwd()})
|
||||
|
||||
|
@ -66,7 +66,7 @@ class test_torrent_info(unittest.TestCase):
|
|||
# the file_strage object is only iterable for backwards compatibility
|
||||
if not hasattr(lt, 'version'): return
|
||||
|
||||
ses = lt.session({'alert_mask': lt.alert.category_t.all_categories})
|
||||
ses = lt.session({'alert_mask': lt.alert.category_t.all_categories, 'enable_dht': False})
|
||||
ti = lt.torrent_info('url_seed_multi.torrent');
|
||||
files = ti.files()
|
||||
|
||||
|
@ -83,7 +83,7 @@ class test_alerts(unittest.TestCase):
|
|||
|
||||
def test_alert(self):
|
||||
|
||||
ses = lt.session({'alert_mask': lt.alert.category_t.all_categories})
|
||||
ses = lt.session({'alert_mask': lt.alert.category_t.all_categories, 'enable_dht': False})
|
||||
ti = lt.torrent_info('base.torrent');
|
||||
h = ses.add_torrent({'ti': ti, 'save_path': os.getcwd()})
|
||||
st = h.status()
|
||||
|
@ -108,7 +108,7 @@ class test_alerts(unittest.TestCase):
|
|||
self.assertEqual(st.save_path, os.getcwd())
|
||||
|
||||
def test_pop_alerts(self):
|
||||
ses = lt.session({'alert_mask': lt.alert.category_t.all_categories})
|
||||
ses = lt.session({'alert_mask': lt.alert.category_t.all_categories, 'enable_dht': False})
|
||||
|
||||
ses.async_add_torrent({"ti": lt.torrent_info("base.torrent"), "save_path": "."})
|
||||
# this will cause an error (because of duplicate torrents) and the
|
||||
|
@ -150,7 +150,7 @@ class test_sha1hash(unittest.TestCase):
|
|||
class test_session(unittest.TestCase):
|
||||
|
||||
def test_post_session_stats(self):
|
||||
s = lt.session({'alert_mask': lt.alert.category_t.stats_notification})
|
||||
s = lt.session({'alert_mask': lt.alert.category_t.stats_notification, 'enable_dht': False})
|
||||
s.post_session_stats()
|
||||
a = s.wait_for_alert(1000)
|
||||
self.assertTrue(isinstance(a, lt.session_stats_alert))
|
||||
|
@ -161,7 +161,7 @@ class test_session(unittest.TestCase):
|
|||
|
||||
# this detects whether libtorrent was built with deprecated APIs
|
||||
if hasattr(lt, 'version'):
|
||||
s = lt.session({})
|
||||
s = lt.session({'enable_dht': False})
|
||||
sett = lt.session_settings()
|
||||
sett.num_want = 10;
|
||||
s.set_settings(sett)
|
||||
|
@ -170,7 +170,7 @@ class test_session(unittest.TestCase):
|
|||
|
||||
def test_apply_settings(self):
|
||||
|
||||
s = lt.session({})
|
||||
s = lt.session({'enable_dht': False})
|
||||
s.apply_settings({'num_want': 66, 'user_agent': 'test123'})
|
||||
self.assertEqual(s.get_settings()['num_want'], 66)
|
||||
self.assertEqual(s.get_settings()['user_agent'], 'test123')
|
||||
|
|
|
@ -656,6 +656,7 @@ namespace libtorrent
|
|||
void update_dht();
|
||||
void update_count_slow();
|
||||
void update_peer_fingerprint();
|
||||
void update_dht_bootstrap_nodes();
|
||||
|
||||
void update_socket_buffer_size();
|
||||
void update_dht_announce_interval();
|
||||
|
|
|
@ -204,6 +204,15 @@ namespace libtorrent
|
|||
// used as the peer-id
|
||||
peer_fingerprint,
|
||||
|
||||
// This is a comma-separated list of IP port-pairs. They will be added
|
||||
// to the DHT node (if it's enabled) as back-up nodes in case we don't
|
||||
// know of any. This setting will contain one or more bootstrap nodes
|
||||
// by default.
|
||||
//
|
||||
// Changing these after the DHT has been started may not have any
|
||||
// effect until the DHT is restarted.
|
||||
dht_bootstrap_nodes,
|
||||
|
||||
max_string_setting_internal
|
||||
};
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ alias libtorrent-sims :
|
|||
[ run test_super_seeding.cpp ]
|
||||
[ run test_utp.cpp ]
|
||||
[ run test_dht.cpp ]
|
||||
[ run test_dht_bootstrap.cpp ]
|
||||
[ run test_dht_storage.cpp ]
|
||||
[ run test_pe_crypto.cpp ]
|
||||
[ run test_metadata_extension.cpp ]
|
||||
|
|
|
@ -43,6 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/sha1_hash.hpp"
|
||||
#include "libtorrent/torrent_info.hpp"
|
||||
#include "libtorrent/io.hpp"
|
||||
#include "libtorrent/bdecode.hpp"
|
||||
|
||||
using namespace sim;
|
||||
|
||||
|
@ -184,6 +185,56 @@ private:
|
|||
std::vector<char> m_send_buffer;
|
||||
};
|
||||
|
||||
struct fake_node
|
||||
{
|
||||
fake_node(simulation& sim, char const* ip, int port = 6881)
|
||||
: m_ios(sim, asio::ip::address::from_string(ip))
|
||||
, m_socket(m_ios)
|
||||
, m_tripped(false)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
m_socket.open(asio::ip::udp::v4(), ec);
|
||||
TEST_CHECK(!ec);
|
||||
m_socket.bind(asio::ip::udp::endpoint(asio::ip::address_v4::any(), port), ec);
|
||||
TEST_CHECK(!ec);
|
||||
|
||||
fprintf(stderr, "fake_node::async_read_some\n");
|
||||
m_socket.async_receive(boost::asio::buffer(m_in_buffer)
|
||||
, [&] (boost::system::error_code const& ec, size_t bytes_transferred)
|
||||
{
|
||||
fprintf(stderr, "fake_node::async_read_some callback. ec: %s transferred: %d\n"
|
||||
, ec.message().c_str(), int(bytes_transferred));
|
||||
if (ec) return;
|
||||
|
||||
lt::bdecode_node n;
|
||||
boost::system::error_code err;
|
||||
int const ret = bdecode(m_in_buffer, m_in_buffer + bytes_transferred
|
||||
, n, err, nullptr, 10, 200);
|
||||
TEST_EQUAL(ret, 0);
|
||||
|
||||
// TODO: ideally we would validate the DHT message
|
||||
m_tripped = true;
|
||||
});
|
||||
}
|
||||
|
||||
void close()
|
||||
{
|
||||
m_socket.close();
|
||||
}
|
||||
|
||||
bool tripped() const { return m_tripped; }
|
||||
|
||||
private:
|
||||
|
||||
char m_in_buffer[300];
|
||||
|
||||
asio::io_service m_ios;
|
||||
asio::ip::udp::socket m_socket;
|
||||
bool m_tripped;
|
||||
|
||||
std::vector<char> m_send_buffer;
|
||||
};
|
||||
|
||||
inline void add_fake_peers(lt::torrent_handle h)
|
||||
{
|
||||
// add the fake peers
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
|
||||
Copyright (c) 2016, Arvid Norberg
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "test.hpp"
|
||||
#include "simulator/simulator.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "fake_peer.hpp" // for fake_node
|
||||
#include "libtorrent/time.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "libtorrent/deadline_timer.hpp"
|
||||
|
||||
namespace lt = libtorrent;
|
||||
using namespace sim;
|
||||
|
||||
struct sim_config : sim::default_config
|
||||
{
|
||||
chrono::high_resolution_clock::duration hostname_lookup(
|
||||
asio::ip::address const& requestor
|
||||
, std::string hostname
|
||||
, std::vector<asio::ip::address>& result
|
||||
, boost::system::error_code& ec)
|
||||
{
|
||||
if (hostname == "dht.libtorrent.org")
|
||||
{
|
||||
result.push_back(addr("10.0.0.10"));
|
||||
return lt::duration_cast<chrono::high_resolution_clock::duration>(chrono::milliseconds(100));
|
||||
}
|
||||
return default_config::hostname_lookup(requestor, hostname, result, ec);
|
||||
}
|
||||
};
|
||||
|
||||
TORRENT_TEST(dht_bootstrap)
|
||||
{
|
||||
using sim::asio::ip::address_v4;
|
||||
sim_config network_cfg;
|
||||
sim::simulation sim{network_cfg};
|
||||
|
||||
std::vector<lt::session_proxy> zombies;
|
||||
|
||||
fake_node node(sim, "10.0.0.10", 25401);
|
||||
|
||||
lt::settings_pack pack;
|
||||
// we use 0 threads (disk I/O operations will be performed in the network
|
||||
// thread) to be simulator friendly.
|
||||
pack.set_int(lt::settings_pack::aio_threads, 0);
|
||||
pack.set_bool(lt::settings_pack::enable_lsd, false);
|
||||
pack.set_bool(lt::settings_pack::enable_upnp, false);
|
||||
pack.set_bool(lt::settings_pack::enable_natpmp, false);
|
||||
pack.set_bool(lt::settings_pack::enable_dht, true);
|
||||
sim::asio::io_service ios(sim, addr("10.0.0.1"));
|
||||
boost::shared_ptr<lt::session> ses = boost::make_shared<lt::session>(pack, ios);
|
||||
|
||||
lt::deadline_timer timer(ios);
|
||||
timer.expires_from_now(lt::seconds(10));
|
||||
timer.async_wait([&](lt::error_code const& ec) {
|
||||
zombies.push_back(ses->abort());
|
||||
node.close();
|
||||
ses.reset();
|
||||
});
|
||||
|
||||
print_alerts(*ses);
|
||||
|
||||
sim.run();
|
||||
|
||||
TEST_EQUAL(node.tripped(), true);
|
||||
}
|
||||
|
|
@ -633,6 +633,7 @@ namespace aux {
|
|||
update_lsd();
|
||||
update_dht();
|
||||
update_peer_fingerprint();
|
||||
update_dht_bootstrap_nodes();
|
||||
|
||||
if (m_listen_sockets.empty())
|
||||
{
|
||||
|
@ -5482,6 +5483,20 @@ retry:
|
|||
}
|
||||
}
|
||||
|
||||
void session_impl::update_dht_bootstrap_nodes()
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
std::string const& node_list = m_settings.get_str(settings_pack::dht_bootstrap_nodes);
|
||||
std::vector<std::pair<std::string, int> > nodes;
|
||||
parse_comma_separated_string_port(node_list, nodes);
|
||||
|
||||
for (int i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
add_dht_router(nodes[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void session_impl::update_count_slow()
|
||||
{
|
||||
error_code ec;
|
||||
|
|
|
@ -137,7 +137,8 @@ namespace libtorrent
|
|||
SET_NOPREV(proxy_username, "", &session_impl::update_proxy),
|
||||
SET_NOPREV(proxy_password, "", &session_impl::update_proxy),
|
||||
SET_NOPREV(i2p_hostname, "", &session_impl::update_i2p_bridge),
|
||||
SET_NOPREV(peer_fingerprint, "-LT1110-", &session_impl::update_peer_fingerprint)
|
||||
SET_NOPREV(peer_fingerprint, "-LT1110-", &session_impl::update_peer_fingerprint),
|
||||
SET_NOPREV(dht_bootstrap_nodes, "dht.libtorrent.org:25401", &session_impl::update_dht_bootstrap_nodes)
|
||||
};
|
||||
|
||||
bool_setting_entry_t bool_settings[settings_pack::num_bool_settings] =
|
||||
|
|
|
@ -168,7 +168,7 @@ namespace libtorrent
|
|||
return static_cast<char*>(p) + (8 - offset);
|
||||
}
|
||||
|
||||
// this parses the string that's used as the liste_interfaces setting.
|
||||
// this parses the string that's used as the listen_interfaces setting.
|
||||
// it is a comma-separated list of IP or device names with ports. For
|
||||
// example: "eth0:6881,eth1:6881" or "127.0.0.1:6881"
|
||||
void parse_comma_separated_string_port(std::string const& in
|
||||
|
|
|
@ -49,6 +49,7 @@ libtorrent::settings_pack settings()
|
|||
pack.set_bool(settings_pack::enable_natpmp, false);
|
||||
pack.set_bool(settings_pack::enable_upnp, false);
|
||||
pack.set_bool(settings_pack::enable_dht, false);
|
||||
pack.set_str(settings_pack::dht_bootstrap_nodes, "");
|
||||
|
||||
pack.set_bool(settings_pack::prefer_rc4, false);
|
||||
pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_disabled);
|
||||
|
|
|
@ -199,6 +199,7 @@ TORRENT_TEST(set_custom)
|
|||
g_storage_constructor_invoked = false;
|
||||
settings_pack p;
|
||||
p.set_bool(settings_pack::enable_dht, false);
|
||||
p.set_str(settings_pack::dht_bootstrap_nodes, "");
|
||||
lt::session ses(p);
|
||||
|
||||
TEST_EQUAL(g_storage_constructor_invoked, false);
|
||||
|
@ -208,6 +209,7 @@ TORRENT_TEST(set_custom)
|
|||
ses.set_dht_storage(dht_custom_storage_constructor);
|
||||
|
||||
p.set_bool(settings_pack::enable_dht, true);
|
||||
p.set_str(settings_pack::dht_bootstrap_nodes, "");
|
||||
ses.apply_settings(p); // async with dispatch
|
||||
r = ses.is_dht_running();
|
||||
TEST_CHECK(r);
|
||||
|
@ -219,6 +221,7 @@ TORRENT_TEST(default_set_custom)
|
|||
g_storage_constructor_invoked = false;
|
||||
settings_pack p;
|
||||
p.set_bool(settings_pack::enable_dht, true);
|
||||
p.set_str(settings_pack::dht_bootstrap_nodes, "");
|
||||
lt::session ses(p);
|
||||
|
||||
bool r = ses.is_dht_running();
|
||||
|
|
|
@ -94,6 +94,7 @@ TORRENT_TEST(direct_dht_request)
|
|||
sp.set_bool(settings_pack::enable_lsd, false);
|
||||
sp.set_bool(settings_pack::enable_natpmp, false);
|
||||
sp.set_bool(settings_pack::enable_upnp, false);
|
||||
sp.set_str(settings_pack::dht_bootstrap_nodes, "");
|
||||
sp.set_int(settings_pack::max_retry_port_bind, 800);
|
||||
sp.set_str(settings_pack::listen_interfaces, "127.0.0.1:42434");
|
||||
lt::session responder(sp, 0);
|
||||
|
@ -116,6 +117,7 @@ TORRENT_TEST(direct_dht_request)
|
|||
bdecode_node response = ra->response();
|
||||
TEST_EQUAL(ra->addr.address(), address::from_string("127.0.0.1"));
|
||||
TEST_EQUAL(ra->addr.port(), responder.listen_port());
|
||||
TEST_EQUAL(response.type(), bdecode_node::dict_t);
|
||||
TEST_EQUAL(response.dict_find_dict("r").dict_find_int_value("good"), 1);
|
||||
TEST_EQUAL(ra->userdata, (void*)12345);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/utility.hpp>
|
||||
|
||||
#include "test.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "libtorrent/socket_io.hpp"
|
||||
#include "libtorrent/session.hpp"
|
||||
|
||||
|
@ -93,7 +94,7 @@ void test_rules_invariant(std::vector<ip_range<T> > const& r, ip_filter const& f
|
|||
TORRENT_TEST(session_get_ip_filter)
|
||||
{
|
||||
using namespace libtorrent;
|
||||
session ses;
|
||||
session ses(settings());
|
||||
ip_filter const& ipf = ses.get_ip_filter();
|
||||
#if TORRENT_USE_IPV6
|
||||
TEST_EQUAL(boost::get<0>(ipf.export_filter()).size(), 1);
|
||||
|
|
|
@ -38,13 +38,14 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/bencode.hpp"
|
||||
#include "libtorrent/torrent_info.hpp" // for announce_entry
|
||||
#include "libtorrent/announce_entry.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
using namespace libtorrent;
|
||||
namespace lt = libtorrent;
|
||||
|
||||
void test_remove_url(std::string url)
|
||||
{
|
||||
lt::session s;
|
||||
lt::session s(settings());
|
||||
add_torrent_params p;
|
||||
p.flags &= ~add_torrent_params::flag_paused;
|
||||
p.flags &= ~add_torrent_params::flag_auto_managed;
|
||||
|
@ -76,7 +77,7 @@ TORRENT_TEST(magnet)
|
|||
session_proxy p2;
|
||||
|
||||
// test session state load/restore
|
||||
settings_pack pack;
|
||||
settings_pack pack = settings();
|
||||
pack.set_str(settings_pack::user_agent, "test");
|
||||
pack.set_int(settings_pack::tracker_receive_timeout, 1234);
|
||||
pack.set_int(settings_pack::file_pool_size, 543);
|
||||
|
@ -177,7 +178,7 @@ TORRENT_TEST(magnet)
|
|||
TEST_EQUAL(to_hex(t.info_hash().to_string()), "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd");
|
||||
|
||||
p1 = s->abort();
|
||||
s.reset(new lt::session());
|
||||
s.reset(new lt::session(settings()));
|
||||
|
||||
std::vector<char> buf;
|
||||
bencode(std::back_inserter(buf), session_state);
|
||||
|
|
|
@ -44,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "test.hpp"
|
||||
#include "setup_transfer.hpp"
|
||||
#include "settings.hpp"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
|
@ -374,7 +375,7 @@ done:
|
|||
TORRENT_TEST(priority)
|
||||
{
|
||||
using namespace libtorrent;
|
||||
settings_pack p;
|
||||
settings_pack p = settings();
|
||||
test_transfer(p);
|
||||
cleanup();
|
||||
}
|
||||
|
@ -383,7 +384,7 @@ TORRENT_TEST(priority)
|
|||
// yet
|
||||
TORRENT_TEST(no_metadata_file_prio)
|
||||
{
|
||||
settings_pack pack;
|
||||
settings_pack pack = settings();
|
||||
lt::session ses(pack);
|
||||
|
||||
add_torrent_params addp;
|
||||
|
@ -403,7 +404,7 @@ TORRENT_TEST(no_metadata_file_prio)
|
|||
|
||||
TORRENT_TEST(no_metadata_piece_prio)
|
||||
{
|
||||
settings_pack pack;
|
||||
settings_pack pack = settings();
|
||||
lt::session ses(pack);
|
||||
|
||||
add_torrent_params addp;
|
||||
|
|
|
@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "peer_server.hpp"
|
||||
#include "udp_tracker.hpp"
|
||||
#include "test_utils.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
#include "libtorrent/alert.hpp"
|
||||
#include "libtorrent/random.hpp"
|
||||
|
@ -101,7 +102,7 @@ session_proxy test_proxy(settings_pack::proxy_type_t proxy_type, int flags)
|
|||
& ~alert::progress_notification
|
||||
& ~alert::stats_notification;
|
||||
|
||||
settings_pack sett;
|
||||
settings_pack sett = settings();
|
||||
sett.set_int(settings_pack::stop_tracker_timeout, 2);
|
||||
sett.set_int(settings_pack::tracker_completion_timeout, 2);
|
||||
sett.set_int(settings_pack::tracker_receive_timeout, 2);
|
||||
|
|
|
@ -43,6 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "test.hpp"
|
||||
#include "setup_transfer.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
using namespace libtorrent;
|
||||
namespace lt = libtorrent;
|
||||
|
@ -193,7 +194,7 @@ void default_tests(torrent_status const& s)
|
|||
|
||||
TORRENT_TEST(piece_priorities)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
boost::shared_ptr<torrent_info> ti = generate_torrent();
|
||||
add_torrent_params p;
|
||||
p.ti = ti;
|
||||
|
@ -239,7 +240,7 @@ TORRENT_TEST(piece_priorities)
|
|||
|
||||
TORRENT_TEST(file_priorities_default)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
std::vector<int> file_priorities = test_resume_flags(ses, 0, "", "").file_priorities();
|
||||
|
||||
TEST_EQUAL(file_priorities.size(), 3);
|
||||
|
@ -251,7 +252,7 @@ TORRENT_TEST(file_priorities_default)
|
|||
TORRENT_TEST(file_priorities_resume_seed_mode)
|
||||
{
|
||||
// in share mode file priorities should always be 0
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
std::vector<int> file_priorities = test_resume_flags(ses,
|
||||
add_torrent_params::flag_share_mode, "", "123").file_priorities();
|
||||
|
||||
|
@ -264,7 +265,7 @@ TORRENT_TEST(file_priorities_resume_seed_mode)
|
|||
TORRENT_TEST(file_priorities_seed_mode)
|
||||
{
|
||||
// in share mode file priorities should always be 0
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
std::vector<int> file_priorities = test_resume_flags(ses,
|
||||
add_torrent_params::flag_share_mode, "123", "").file_priorities();
|
||||
|
||||
|
@ -278,7 +279,7 @@ TORRENT_TEST(zero_file_prio)
|
|||
{
|
||||
fprintf(stderr, "test_file_prio\n");
|
||||
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
boost::shared_ptr<torrent_info> ti = generate_torrent();
|
||||
add_torrent_params p;
|
||||
p.ti = ti;
|
||||
|
@ -317,7 +318,7 @@ void test_seed_mode(bool file_prio, bool pieces_have, bool piece_prio
|
|||
fprintf(stderr, "test_seed_mode file_prio: %d pieces_have: %d piece_prio: %d\n"
|
||||
, file_prio, pieces_have, piece_prio);
|
||||
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
boost::shared_ptr<torrent_info> ti = generate_torrent();
|
||||
add_torrent_params p;
|
||||
p.ti = ti;
|
||||
|
@ -397,7 +398,7 @@ TORRENT_TEST(seed_mode_preserve)
|
|||
|
||||
TORRENT_TEST(resume_save_load)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
torrent_handle h = test_resume_flags(ses, 0, "123", "");
|
||||
|
||||
h.save_resume_data();
|
||||
|
@ -423,7 +424,7 @@ TORRENT_TEST(resume_save_load)
|
|||
|
||||
TORRENT_TEST(resume_save_load_resume)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
torrent_handle h = test_resume_flags(ses, 0, "", "123");
|
||||
|
||||
h.save_resume_data();
|
||||
|
@ -452,7 +453,7 @@ TORRENT_TEST(file_priorities_resume_override)
|
|||
// make sure that an empty file_priorities vector in add_torrent_params won't
|
||||
// override the resume data file priorities, even when override resume data
|
||||
// flag is set.
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
std::vector<int> file_priorities = test_resume_flags(ses,
|
||||
add_torrent_params::flag_override_resume_data, "", "123").file_priorities();
|
||||
|
||||
|
@ -464,7 +465,7 @@ TORRENT_TEST(file_priorities_resume_override)
|
|||
|
||||
TORRENT_TEST(file_priorities_resume)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
std::vector<int> file_priorities = test_resume_flags(ses, 0, "", "123").file_priorities();
|
||||
|
||||
TEST_EQUAL(file_priorities.size(), 3);
|
||||
|
@ -475,7 +476,7 @@ TORRENT_TEST(file_priorities_resume)
|
|||
|
||||
TORRENT_TEST(file_priorities1)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
std::vector<int> file_priorities = test_resume_flags(ses, 0, "010").file_priorities();
|
||||
|
||||
TEST_EQUAL(file_priorities.size(), 3);
|
||||
|
@ -488,7 +489,7 @@ TORRENT_TEST(file_priorities1)
|
|||
|
||||
TORRENT_TEST(file_priorities2)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
std::vector<int> file_priorities = test_resume_flags(ses, 0, "123").file_priorities();
|
||||
|
||||
TEST_EQUAL(file_priorities.size(), 3);
|
||||
|
@ -499,7 +500,7 @@ TORRENT_TEST(file_priorities2)
|
|||
|
||||
TORRENT_TEST(file_priorities3)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
std::vector<int> file_priorities = test_resume_flags(ses, 0, "4321").file_priorities();
|
||||
|
||||
TEST_EQUAL(file_priorities.size(), 3);
|
||||
|
@ -510,7 +511,7 @@ TORRENT_TEST(file_priorities3)
|
|||
|
||||
TORRENT_TEST(plain)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
|
||||
torrent_status s = test_resume_flags(ses, 0).status();
|
||||
default_tests(s);
|
||||
|
@ -533,7 +534,7 @@ TORRENT_TEST(plain)
|
|||
|
||||
TORRENT_TEST(use_resume_save_path)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
torrent_status s = test_resume_flags(ses, add_torrent_params::flag_use_resume_save_path).status();
|
||||
default_tests(s);
|
||||
#ifdef TORRENT_WINDOWS
|
||||
|
@ -555,7 +556,7 @@ TORRENT_TEST(use_resume_save_path)
|
|||
|
||||
TORRENT_TEST(override_resume_data)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
torrent_status s = test_resume_flags(ses
|
||||
, add_torrent_params::flag_override_resume_data
|
||||
| add_torrent_params::flag_paused).status();
|
||||
|
@ -580,7 +581,7 @@ TORRENT_TEST(override_resume_data)
|
|||
|
||||
TORRENT_TEST(seed_mode)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
torrent_status s = test_resume_flags(ses, add_torrent_params::flag_override_resume_data
|
||||
| add_torrent_params::flag_seed_mode).status();
|
||||
default_tests(s);
|
||||
|
@ -603,7 +604,7 @@ TORRENT_TEST(seed_mode)
|
|||
|
||||
TORRENT_TEST(upload_mode)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
torrent_status s = test_resume_flags(ses, add_torrent_params::flag_upload_mode).status();
|
||||
default_tests(s);
|
||||
#ifdef TORRENT_WINDOWS
|
||||
|
@ -625,7 +626,7 @@ TORRENT_TEST(upload_mode)
|
|||
|
||||
TORRENT_TEST(share_mode)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
torrent_status s = test_resume_flags(ses
|
||||
, add_torrent_params::flag_override_resume_data
|
||||
| add_torrent_params::flag_share_mode).status();
|
||||
|
@ -649,7 +650,7 @@ TORRENT_TEST(share_mode)
|
|||
|
||||
TORRENT_TEST(auto_managed)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
// resume data overrides the auto-managed flag
|
||||
torrent_status s = test_resume_flags(ses, add_torrent_params::flag_auto_managed).status();
|
||||
default_tests(s);
|
||||
|
@ -672,7 +673,7 @@ TORRENT_TEST(auto_managed)
|
|||
|
||||
TORRENT_TEST(paused)
|
||||
{
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
// resume data overrides the paused flag
|
||||
torrent_status s = test_resume_flags(ses, add_torrent_params::flag_paused).status();
|
||||
default_tests(s);
|
||||
|
@ -701,7 +702,7 @@ TORRENT_TEST(url_seed_resume_data)
|
|||
{
|
||||
// merge url seeds with resume data
|
||||
fprintf(stderr, "flags: merge_resume_http_seeds\n");
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
torrent_handle h = test_resume_flags(ses,
|
||||
add_torrent_params::flag_merge_resume_http_seeds);
|
||||
std::set<std::string> us = h.url_seeds();
|
||||
|
@ -724,7 +725,7 @@ TORRENT_TEST(resume_override_torrent)
|
|||
{
|
||||
// resume data overrides the .torrent_file
|
||||
fprintf(stderr, "flags: no merge_resume_http_seed\n");
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
torrent_handle h = test_resume_flags(ses,
|
||||
add_torrent_params::flag_merge_resume_trackers);
|
||||
std::set<std::string> us = h.url_seeds();
|
||||
|
|
|
@ -47,6 +47,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/bdecode.hpp"
|
||||
#include "libtorrent/bencode.hpp"
|
||||
#include "libtorrent/torrent_info.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
|
@ -55,11 +56,11 @@ namespace lt = libtorrent;
|
|||
|
||||
TORRENT_TEST(session)
|
||||
{
|
||||
settings_pack p;
|
||||
settings_pack p = settings();
|
||||
p.set_int(settings_pack::alert_mask, ~0);
|
||||
lt::session ses(p);
|
||||
|
||||
settings_pack sett;
|
||||
settings_pack sett = settings();
|
||||
sett.set_int(settings_pack::cache_size, 100);
|
||||
sett.set_int(settings_pack::max_queued_disk_bytes, 1000 * 16 * 1024);
|
||||
|
||||
|
@ -103,7 +104,7 @@ TORRENT_TEST(session)
|
|||
|
||||
TORRENT_TEST(load_empty_file)
|
||||
{
|
||||
settings_pack p;
|
||||
settings_pack p = settings();
|
||||
p.set_int(settings_pack::alert_mask, ~0);
|
||||
lt::session ses(p);
|
||||
|
||||
|
@ -135,7 +136,7 @@ TORRENT_TEST(session_stats)
|
|||
|
||||
TORRENT_TEST(paused_session)
|
||||
{
|
||||
lt::session s;
|
||||
lt::session s(settings());
|
||||
s.pause();
|
||||
|
||||
lt::add_torrent_params ps;
|
||||
|
@ -160,14 +161,14 @@ void test_save_restore(Set setup, Save s, Default d, Load l)
|
|||
{
|
||||
entry st;
|
||||
{
|
||||
settings_pack p;
|
||||
settings_pack p = settings();
|
||||
setup(p);
|
||||
lt::session ses(p);
|
||||
s(ses, st);
|
||||
}
|
||||
|
||||
{
|
||||
settings_pack p;
|
||||
settings_pack p = settings();
|
||||
d(p);
|
||||
lt::session ses(p);
|
||||
// the loading function takes a bdecode_node, so we have to transform the
|
||||
|
|
|
@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/torrent.hpp"
|
||||
#include "libtorrent/peer_info.hpp"
|
||||
#include "libtorrent/extensions.hpp"
|
||||
#include "settings.hpp"
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <iostream>
|
||||
|
@ -52,7 +53,7 @@ namespace lt = libtorrent;
|
|||
|
||||
void test_running_torrent(boost::shared_ptr<torrent_info> info, boost::int64_t file_size)
|
||||
{
|
||||
settings_pack pack;
|
||||
settings_pack pack = settings();
|
||||
pack.set_int(settings_pack::alert_mask, alert::storage_notification);
|
||||
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48130");
|
||||
pack.set_int(settings_pack::max_retry_port_bind, 10);
|
||||
|
@ -189,7 +190,7 @@ TORRENT_TEST(total_wanted)
|
|||
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(
|
||||
&tmp[0], tmp.size(), boost::ref(ec)));
|
||||
|
||||
settings_pack pack;
|
||||
settings_pack pack = settings();
|
||||
pack.set_int(settings_pack::alert_mask, alert::storage_notification);
|
||||
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48130");
|
||||
pack.set_int(settings_pack::max_retry_port_bind, 10);
|
||||
|
@ -227,7 +228,7 @@ TORRENT_TEST(added_peers)
|
|||
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(
|
||||
&tmp[0], tmp.size(), boost::ref(ec)));
|
||||
|
||||
settings_pack pack;
|
||||
settings_pack pack = settings();
|
||||
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48130");
|
||||
pack.set_int(settings_pack::max_retry_port_bind, 10);
|
||||
lt::session ses(pack);
|
||||
|
@ -356,7 +357,7 @@ TORRENT_TEST(duplicate_is_not_error)
|
|||
p.save_path = ".";
|
||||
p.extensions.push_back(creator);
|
||||
|
||||
lt::session ses;
|
||||
lt::session ses(settings());
|
||||
ses.async_add_torrent(p);
|
||||
ses.async_add_torrent(p);
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "test.hpp"
|
||||
#include "setup_transfer.hpp"
|
||||
#include "web_seed_suite.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "libtorrent/create_torrent.hpp"
|
||||
#include "libtorrent/torrent_info.hpp"
|
||||
|
||||
|
@ -88,10 +89,10 @@ TORRENT_TEST(web_seed_redirect)
|
|||
, buf.size(), ec));
|
||||
|
||||
{
|
||||
settings_pack settings;
|
||||
settings.set_int(settings_pack::max_queued_disk_bytes, 256 * 1024);
|
||||
settings.set_int(settings_pack::alert_mask, ~(alert::progress_notification | alert::stats_notification));
|
||||
libtorrent::session ses(settings);
|
||||
settings_pack p = settings();
|
||||
p.set_int(settings_pack::max_queued_disk_bytes, 256 * 1024);
|
||||
p.set_int(settings_pack::alert_mask, ~(alert::progress_notification | alert::stats_notification));
|
||||
libtorrent::session ses(p);
|
||||
|
||||
// disable keep-alive because otherwise the test will choke on seeing
|
||||
// the disconnect (from the redirect)
|
||||
|
|
Loading…
Reference in New Issue