forked from premiere/premiere-libtorrent
merged RC_1_1 into master
This commit is contained in:
commit
86786770b7
|
@ -62,6 +62,10 @@
|
|||
* resume data no longer has timestamps of files
|
||||
* require C++11 to build libtorrent
|
||||
|
||||
* deprecate torrent_added_alert (in favor of add_torrent_alert)
|
||||
* fix python binding for parse_magnet_uri
|
||||
* fix minor robustness issue in DHT bootstrap logic
|
||||
* fix issue where torrent_status::num_seeds could be negative
|
||||
* document deprecation of dynamic loading/unloading of torrents
|
||||
* include user-agent in tracker announces in anonymous_mode for private torrents
|
||||
* add support for IPv6 peers from udp trackers
|
||||
|
|
|
@ -302,9 +302,11 @@ void bind_alert()
|
|||
.def("tracker_url", &tracker_alert::tracker_url)
|
||||
;
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
class_<torrent_added_alert, bases<torrent_alert>, noncopyable>(
|
||||
"torrent_added_alert", no_init)
|
||||
;
|
||||
#endif
|
||||
|
||||
class_<torrent_removed_alert, bases<torrent_alert>, noncopyable>(
|
||||
"torrent_removed_alert", no_init)
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace {
|
|||
|
||||
dict ret;
|
||||
|
||||
ret["ti"] = p.ti;
|
||||
if (p.ti) ret["ti"] = p.ti;
|
||||
list tracker_list;
|
||||
for (std::vector<std::string>::const_iterator i = p.trackers.begin()
|
||||
, end(p.trackers.end()); i != end; ++i)
|
||||
|
@ -57,7 +57,7 @@ namespace {
|
|||
for (auto const& i : p.dht_nodes)
|
||||
tracker_list.append(boost::python::make_tuple(i.first, i.second));
|
||||
ret["dht_nodes"] = nodes_list;
|
||||
ret["info_hash"] = p.info_hash;
|
||||
ret["info_hash"] = p.info_hash.to_string();
|
||||
ret["name"] = p.name;
|
||||
ret["save_path"] = p.save_path;
|
||||
ret["storage_mode"] = p.storage_mode;
|
||||
|
|
|
@ -365,6 +365,15 @@ class test_sha1hash(unittest.TestCase):
|
|||
s = lt.sha1_hash(binascii.unhexlify(h))
|
||||
self.assertEqual(h, str(s))
|
||||
|
||||
class test_magnet_link(unittest.TestCase):
|
||||
|
||||
def test_parse_magnet_uri(self):
|
||||
ses = lt.session({})
|
||||
magnet = 'magnet:?xt=urn:btih:C6EIF4CCYDBTIJVG3APAGM7M4NDONCTI'
|
||||
p = lt.parse_magnet_uri(magnet)
|
||||
p['save_path'] = '.'
|
||||
h = ses.add_torrent(p)
|
||||
self.assertEqual(str(h.info_hash()), '178882f042c0c33426a6d81e0333ece346e68a68')
|
||||
|
||||
class test_session(unittest.TestCase):
|
||||
|
||||
|
|
|
@ -161,11 +161,14 @@ namespace libtorrent
|
|||
#define TORRENT_DEFINE_ALERT_PRIO(name, seq) \
|
||||
TORRENT_DEFINE_ALERT_IMPL(name, seq, 1)
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
// The ``torrent_added_alert`` is posted once every time a torrent is successfully
|
||||
// added. It doesn't contain any members of its own, but inherits the torrent handle
|
||||
// from its base class.
|
||||
// It's posted when the ``status_notification`` bit is set in the alert_mask.
|
||||
struct TORRENT_EXPORT torrent_added_alert final : torrent_alert
|
||||
// deprecated in 1.1.3
|
||||
// use add_torrent_alert instead
|
||||
struct TORRENT_DEPRECATED_EXPORT torrent_added_alert final : torrent_alert
|
||||
{
|
||||
// internal
|
||||
torrent_added_alert(aux::stack_allocator& alloc, torrent_handle const& h);
|
||||
|
@ -174,6 +177,7 @@ namespace libtorrent
|
|||
static const int static_category = alert::status_notification;
|
||||
virtual std::string message() const override;
|
||||
};
|
||||
#endif
|
||||
|
||||
// The ``torrent_removed_alert`` is posted whenever a torrent is removed. Since
|
||||
// the torrent handle in its base class will always be invalid (since the torrent
|
||||
|
|
|
@ -51,8 +51,6 @@ public:
|
|||
observer_ptr new_observer(udp::endpoint const& ep
|
||||
, node_id const& id);
|
||||
|
||||
void trim_seed_nodes();
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool invoke(observer_ptr o);
|
||||
|
|
|
@ -84,7 +84,7 @@ void run_test(Setup const& setup, Torrent const& torrent
|
|||
|
||||
lt::torrent_handle h;
|
||||
print_alerts(*ses, [&](lt::session& ses, lt::alert const* a) {
|
||||
auto at = lt::alert_cast<torrent_added_alert>(a);
|
||||
auto at = lt::alert_cast<add_torrent_alert>(a);
|
||||
if (at == nullptr) return;
|
||||
h = at->handle;
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ void test_stop_start_download(swarm_test type, bool graceful)
|
|||
// on alert
|
||||
, [&](lt::alert const* a, lt::session& ses) {
|
||||
|
||||
if (lt::alert_cast<lt::torrent_added_alert>(a))
|
||||
if (lt::alert_cast<lt::add_torrent_alert>(a))
|
||||
add_extra_peers(ses);
|
||||
|
||||
if (auto tp = lt::alert_cast<lt::torrent_paused_alert>(a))
|
||||
|
|
|
@ -65,7 +65,7 @@ TORRENT_TEST(status_timers)
|
|||
, [](lt::add_torrent_params&) {}
|
||||
// on alert
|
||||
, [&](lt::alert const* a, lt::session&) {
|
||||
if (auto ta = alert_cast<torrent_added_alert>(a))
|
||||
if (auto ta = alert_cast<add_torrent_alert>(a))
|
||||
{
|
||||
TEST_CHECK(!handle.is_valid());
|
||||
start_time = time_now();
|
||||
|
@ -121,7 +121,7 @@ TORRENT_TEST(status_timers_last_upload)
|
|||
, [](lt::add_torrent_params&) {}
|
||||
// on alert
|
||||
, [&](lt::alert const* a, lt::session&) {
|
||||
if (auto ta = alert_cast<torrent_added_alert>(a))
|
||||
if (auto ta = alert_cast<add_torrent_alert>(a))
|
||||
{
|
||||
TEST_CHECK(!handle.is_valid());
|
||||
start_time = time_now();
|
||||
|
@ -169,7 +169,7 @@ TORRENT_TEST(status_timers_time_shift_with_active_torrent)
|
|||
, [](lt::add_torrent_params&) {}
|
||||
// on alert
|
||||
, [&](lt::alert const* a, lt::session&) {
|
||||
if (auto ta = alert_cast<torrent_added_alert>(a))
|
||||
if (auto ta = alert_cast<add_torrent_alert>(a))
|
||||
{
|
||||
TEST_CHECK(!handle.is_valid());
|
||||
start_time = time_now();
|
||||
|
@ -250,7 +250,7 @@ TORRENT_TEST(finish_time_shift_active)
|
|||
, [](lt::add_torrent_params&) {}
|
||||
// on alert
|
||||
, [&](lt::alert const* a, lt::session&) {
|
||||
if (auto ta = alert_cast<torrent_added_alert>(a))
|
||||
if (auto ta = alert_cast<add_torrent_alert>(a))
|
||||
{
|
||||
TEST_CHECK(!handle.is_valid());
|
||||
start_time = time_now();
|
||||
|
@ -324,7 +324,7 @@ TORRENT_TEST(finish_time_shift_paused)
|
|||
, [](lt::add_torrent_params&) {}
|
||||
// on alert
|
||||
, [&](lt::alert const* a, lt::session&) {
|
||||
if (auto ta = alert_cast<torrent_added_alert>(a))
|
||||
if (auto ta = alert_cast<add_torrent_alert>(a))
|
||||
{
|
||||
TEST_CHECK(!handle.is_valid());
|
||||
start_time = time_now();
|
||||
|
|
|
@ -123,7 +123,7 @@ void run_test(
|
|||
|
||||
// only monitor alerts for session 0 (the downloader)
|
||||
print_alerts(*ses[0], [=](lt::session& ses, lt::alert const* a) {
|
||||
if (auto ta = alert_cast<lt::torrent_added_alert>(a))
|
||||
if (auto ta = alert_cast<lt::add_torrent_alert>(a))
|
||||
{
|
||||
ta->handle.connect_peer(lt::tcp::endpoint(
|
||||
(flags & connect_socks) ? proxy : peer1, 6881));
|
||||
|
|
|
@ -1273,6 +1273,7 @@ namespace libtorrent
|
|||
return m_alloc.get().ptr(m_file_idx);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
torrent_added_alert::torrent_added_alert(aux::stack_allocator& alloc
|
||||
, torrent_handle const& h)
|
||||
: torrent_alert(alloc, h)
|
||||
|
@ -1282,6 +1283,7 @@ namespace libtorrent
|
|||
{
|
||||
return torrent_alert::message() + " added";
|
||||
}
|
||||
#endif
|
||||
|
||||
torrent_removed_alert::torrent_removed_alert(aux::stack_allocator& alloc
|
||||
, torrent_handle const& h, sha1_hash const& ih)
|
||||
|
|
|
@ -230,9 +230,6 @@ void node::bootstrap(std::vector<udp::endpoint> const& nodes
|
|||
r->add_entry(node_id(), n, observer::flag_initial);
|
||||
}
|
||||
|
||||
// make us start as far away from our node ID as possible
|
||||
r->trim_seed_nodes();
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
if (m_observer != nullptr)
|
||||
m_observer->log(dht_logger::node, "bootstrapping with %d nodes", count);
|
||||
|
|
|
@ -89,15 +89,6 @@ bootstrap::bootstrap(
|
|||
|
||||
char const* bootstrap::name() const { return "bootstrap"; }
|
||||
|
||||
void bootstrap::trim_seed_nodes()
|
||||
{
|
||||
// when we're bootstrapping, we want to start as far away from our ID as
|
||||
// possible, to cover as much as possible of the ID space. So, remove all
|
||||
// nodes except for the 32 that are farthest away from us
|
||||
if (m_results.size() > 32)
|
||||
m_results.erase(m_results.begin(), m_results.end() - 32);
|
||||
}
|
||||
|
||||
void bootstrap::done()
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
|
|
|
@ -4684,8 +4684,10 @@ namespace aux {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
if (m_alerts.should_post<torrent_added_alert>())
|
||||
m_alerts.emplace_alert<torrent_added_alert>(handle);
|
||||
#endif
|
||||
|
||||
// if this was an existing torrent, we can't start it again, or add
|
||||
// another set of plugins etc. we're done
|
||||
|
|
|
@ -10553,7 +10553,7 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
st->num_pieces = num_have();
|
||||
st->num_seeds = num_seeds() - int(m_num_connecting_seeds);
|
||||
st->num_seeds = num_seeds();
|
||||
if ((flags & torrent_handle::query_distributed_copies) && m_picker.get())
|
||||
{
|
||||
std::tie(st->distributed_full_copies, st->distributed_fraction) =
|
||||
|
|
|
@ -53,7 +53,7 @@ TORRENT_TEST(limit)
|
|||
// try add 600 torrent_add_alert to make sure we honor the limit of 500
|
||||
// alerts.
|
||||
for (int i = 0; i < 600; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<torrent_finished_alert>(torrent_handle());
|
||||
|
||||
TEST_EQUAL(mgr.pending(), true);
|
||||
|
||||
|
@ -69,7 +69,7 @@ TORRENT_TEST(limit)
|
|||
mgr.set_alert_queue_size_limit(200);
|
||||
|
||||
for (int i = 0; i < 600; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<torrent_finished_alert>(torrent_handle());
|
||||
|
||||
TEST_EQUAL(mgr.pending(), true);
|
||||
|
||||
|
@ -87,7 +87,7 @@ TORRENT_TEST(priority_limit)
|
|||
|
||||
// this should only add 100 because of the limit
|
||||
for (int i = 0; i < 200; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
// the limit is twice as high for priority alerts
|
||||
for (file_index_t i(0); i < file_index_t(200); ++i)
|
||||
|
@ -115,7 +115,7 @@ TORRENT_TEST(notify_function)
|
|||
TEST_EQUAL(mgr.pending(), false);
|
||||
|
||||
for (int i = 0; i < 20; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
TEST_EQUAL(mgr.pending(), true);
|
||||
|
||||
|
@ -129,7 +129,7 @@ TORRENT_TEST(notify_function)
|
|||
// subsequent posted alerts will not cause an edge (because there are
|
||||
// already alerts queued)
|
||||
for (int i = 0; i < 20; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
TEST_EQUAL(mgr.pending(), true);
|
||||
TEST_EQUAL(cnt, 1);
|
||||
|
@ -142,7 +142,7 @@ TORRENT_TEST(notify_function)
|
|||
TEST_EQUAL(mgr.pending(), false);
|
||||
|
||||
for (int i = 0; i < 20; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
TEST_EQUAL(mgr.pending(), true);
|
||||
TEST_EQUAL(cnt, 2);
|
||||
|
@ -174,14 +174,14 @@ TORRENT_TEST(extensions)
|
|||
mgr.add_extension(std::make_shared<test_plugin>(2));
|
||||
|
||||
for (int i = 0; i < 53; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
TEST_EQUAL(plugin_alerts[0], 53);
|
||||
TEST_EQUAL(plugin_alerts[1], 53);
|
||||
TEST_EQUAL(plugin_alerts[2], 53);
|
||||
|
||||
for (int i = 0; i < 17; ++i)
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
TEST_EQUAL(plugin_alerts[0], 70);
|
||||
TEST_EQUAL(plugin_alerts[1], 70);
|
||||
|
@ -192,7 +192,7 @@ TORRENT_TEST(extensions)
|
|||
void post_torrent_added(alert_manager* mgr)
|
||||
{
|
||||
std::this_thread::sleep_for(lt::milliseconds(10));
|
||||
mgr->emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr->emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
}
|
||||
|
||||
TORRENT_TEST(wait_for_alert)
|
||||
|
@ -210,7 +210,7 @@ TORRENT_TEST(wait_for_alert)
|
|||
TEST_CHECK(end - start > milliseconds(900));
|
||||
TEST_CHECK(end - start < milliseconds(1100));
|
||||
|
||||
mgr.emplace_alert<torrent_added_alert>(torrent_handle());
|
||||
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
||||
|
||||
start = clock_type::now();
|
||||
a = mgr.wait_for_alert(seconds(1));
|
||||
|
@ -218,7 +218,7 @@ TORRENT_TEST(wait_for_alert)
|
|||
|
||||
std::printf("delay: %d ms\n", int(total_milliseconds(end - start)));
|
||||
TEST_CHECK(end - start < milliseconds(1));
|
||||
TEST_CHECK(a->type() == torrent_added_alert::alert_type);
|
||||
TEST_CHECK(a->type() == add_torrent_alert::alert_type);
|
||||
|
||||
std::vector<alert*> alerts;
|
||||
mgr.get_all(alerts);
|
||||
|
@ -231,7 +231,7 @@ TORRENT_TEST(wait_for_alert)
|
|||
|
||||
std::printf("delay: %d ms\n", int(total_milliseconds(end - start)));
|
||||
TEST_CHECK(end - start < milliseconds(500));
|
||||
TEST_CHECK(a->type() == torrent_added_alert::alert_type);
|
||||
TEST_CHECK(a->type() == add_torrent_alert::alert_type);
|
||||
|
||||
posting_thread.join();
|
||||
}
|
||||
|
@ -240,12 +240,12 @@ TORRENT_TEST(alert_mask)
|
|||
{
|
||||
alert_manager mgr(100, 0xffffffff);
|
||||
|
||||
TEST_CHECK(mgr.should_post<torrent_added_alert>());
|
||||
TEST_CHECK(mgr.should_post<add_torrent_alert>());
|
||||
TEST_CHECK(mgr.should_post<torrent_paused_alert>());
|
||||
|
||||
mgr.set_alert_mask(0);
|
||||
|
||||
TEST_CHECK(!mgr.should_post<torrent_added_alert>());
|
||||
TEST_CHECK(!mgr.should_post<add_torrent_alert>());
|
||||
TEST_CHECK(!mgr.should_post<torrent_paused_alert>());
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,11 @@ TORRENT_TEST(alerts_types)
|
|||
TEST_EQUAL(count_alert_types, seq); \
|
||||
count_alert_types++;
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
TEST_ALERT_TYPE(torrent_added_alert, 3, 0, alert::status_notification);
|
||||
#else
|
||||
++count_alert_types;
|
||||
#endif
|
||||
TEST_ALERT_TYPE(torrent_removed_alert, 4, 1, alert::status_notification);
|
||||
TEST_ALERT_TYPE(read_piece_alert, 5, 1, alert::storage_notification);
|
||||
TEST_ALERT_TYPE(file_completed_alert, 6, 0, alert::progress_notification);
|
||||
|
|
Loading…
Reference in New Issue