forked from premiere/premiere-libtorrent
merged RC_1_1 into master
This commit is contained in:
commit
d91f6f8c05
|
@ -55,7 +55,7 @@ namespace
|
||||||
ct.add_node(std::make_pair(addr, port));
|
ct.add_node(std::make_pair(addr, port));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
void add_file(file_storage& ct, file_entry const& fe)
|
void add_file(file_storage& ct, file_entry const& fe)
|
||||||
{
|
{
|
||||||
ct.add_file(fe);
|
ct.add_file(fe);
|
||||||
|
@ -112,7 +112,7 @@ void bind_create_torrent()
|
||||||
{
|
{
|
||||||
void (file_storage::*add_file0)(std::string const&, std::int64_t
|
void (file_storage::*add_file0)(std::string const&, std::int64_t
|
||||||
, int, std::time_t, string_view) = &file_storage::add_file;
|
, int, std::time_t, string_view) = &file_storage::add_file;
|
||||||
#if !defined TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
#if TORRENT_USE_WSTRING
|
#if TORRENT_USE_WSTRING
|
||||||
void (file_storage::*add_file1)(std::wstring const&, std::int64_t
|
void (file_storage::*add_file1)(std::wstring const&, std::int64_t
|
||||||
, int, std::time_t, string_view) = &file_storage::add_file;
|
, int, std::time_t, string_view) = &file_storage::add_file;
|
||||||
|
@ -138,7 +138,7 @@ void bind_create_torrent()
|
||||||
std::int64_t (file_storage::*file_storage_file_offset)(int) const = &file_storage::file_offset;
|
std::int64_t (file_storage::*file_storage_file_offset)(int) const = &file_storage::file_offset;
|
||||||
int (file_storage::*file_storage_file_flags)(int) const = &file_storage::file_flags;
|
int (file_storage::*file_storage_file_flags)(int) const = &file_storage::file_flags;
|
||||||
|
|
||||||
#if !defined TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
file_entry (file_storage::*at)(int) const = &file_storage::at;
|
file_entry (file_storage::*at)(int) const = &file_storage::at;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ void bind_create_torrent()
|
||||||
.def("add_file", add_file1, (arg("path"), arg("size"), arg("flags") = 0, arg("mtime") = 0, arg("linkpath") = ""))
|
.def("add_file", add_file1, (arg("path"), arg("size"), arg("flags") = 0, arg("mtime") = 0, arg("linkpath") = ""))
|
||||||
#endif
|
#endif
|
||||||
.def("num_files", &file_storage::num_files)
|
.def("num_files", &file_storage::num_files)
|
||||||
#if !defined TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
.def("at", at)
|
.def("at", at)
|
||||||
.def("add_file", add_file, arg("entry"))
|
.def("add_file", add_file, arg("entry"))
|
||||||
.def("__iter__", boost::python::range(&begin_files, &end_files))
|
.def("__iter__", boost::python::range(&begin_files, &end_files))
|
||||||
|
|
|
@ -63,7 +63,6 @@ namespace
|
||||||
if (ec) throw system_error(ec);
|
if (ec) throw system_error(ec);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void outgoing_ports(lt::session& s, int _min, int _max)
|
void outgoing_ports(lt::session& s, int _min, int _max)
|
||||||
{
|
{
|
||||||
|
@ -74,6 +73,8 @@ namespace
|
||||||
s.apply_settings(p);
|
s.apply_settings(p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif // TORRENT_NO_DEPRECATE
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
void add_dht_node(lt::session& s, tuple n)
|
void add_dht_node(lt::session& s, tuple n)
|
||||||
{
|
{
|
||||||
|
@ -83,11 +84,13 @@ namespace
|
||||||
s.add_dht_node(std::make_pair(ip, port));
|
s.add_dht_node(std::make_pair(ip, port));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
void add_dht_router(lt::session& s, std::string router_, int port_)
|
void add_dht_router(lt::session& s, std::string router_, int port_)
|
||||||
{
|
{
|
||||||
allow_threading_guard guard;
|
allow_threading_guard guard;
|
||||||
return s.add_dht_router(std::make_pair(router_, port_));
|
return s.add_dht_router(std::make_pair(router_, port_));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // TORRENT_DISABLE_DHT
|
#endif // TORRENT_DISABLE_DHT
|
||||||
|
|
||||||
|
@ -116,7 +119,11 @@ namespace
|
||||||
std::string const key = extract<std::string>(iterkeys[i]);
|
std::string const key = extract<std::string>(iterkeys[i]);
|
||||||
|
|
||||||
int sett = setting_by_name(key);
|
int sett = setting_by_name(key);
|
||||||
if (sett < 0) continue;
|
if (sett < 0)
|
||||||
|
{
|
||||||
|
PyErr_SetString(PyExc_ValueError, ("unknown name in settings_pack: " + key).c_str());
|
||||||
|
throw_error_already_set();
|
||||||
|
}
|
||||||
|
|
||||||
TORRENT_TRY
|
TORRENT_TRY
|
||||||
{
|
{
|
||||||
|
@ -689,18 +696,20 @@ void bind_session()
|
||||||
, arg("flags")=lt::session::start_default_features | lt::session::add_default_plugins
|
, arg("flags")=lt::session::start_default_features | lt::session::add_default_plugins
|
||||||
, arg("alert_mask")=int(alert::error_notification)))
|
, arg("alert_mask")=int(alert::error_notification)))
|
||||||
)
|
)
|
||||||
|
.def("outgoing_ports", &outgoing_ports)
|
||||||
#endif
|
#endif
|
||||||
.def("post_torrent_updates", allow_threads(<::session::post_torrent_updates), arg("flags") = 0xffffffff)
|
.def("post_torrent_updates", allow_threads(<::session::post_torrent_updates), arg("flags") = 0xffffffff)
|
||||||
.def("post_session_stats", allow_threads(<::session::post_session_stats))
|
.def("post_session_stats", allow_threads(<::session::post_session_stats))
|
||||||
.def("outgoing_ports", &outgoing_ports)
|
|
||||||
.def("is_listening", allow_threads(<::session::is_listening))
|
.def("is_listening", allow_threads(<::session::is_listening))
|
||||||
.def("listen_port", allow_threads(<::session::listen_port))
|
.def("listen_port", allow_threads(<::session::listen_port))
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
.def("add_dht_node", &add_dht_node)
|
.def("add_dht_node", &add_dht_node)
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
.def(
|
.def(
|
||||||
"add_dht_router", &add_dht_router
|
"add_dht_router", &add_dht_router
|
||||||
, (arg("router"), "port")
|
, (arg("router"), "port")
|
||||||
)
|
)
|
||||||
|
#endif // TORRENT_NO_DEPRECATE
|
||||||
.def("is_dht_running", allow_threads(<::session::is_dht_running))
|
.def("is_dht_running", allow_threads(<::session::is_dht_running))
|
||||||
.def("set_dht_settings", allow_threads(<::session::set_dht_settings))
|
.def("set_dht_settings", allow_threads(<::session::set_dht_settings))
|
||||||
.def("get_dht_settings", allow_threads(<::session::get_dht_settings))
|
.def("get_dht_settings", allow_threads(<::session::get_dht_settings))
|
||||||
|
|
|
@ -120,7 +120,7 @@ namespace
|
||||||
bool get_start_sent(announce_entry const& ae) { return ae.start_sent; }
|
bool get_start_sent(announce_entry const& ae) { return ae.start_sent; }
|
||||||
bool get_complete_sent(announce_entry const& ae) { return ae.complete_sent; }
|
bool get_complete_sent(announce_entry const& ae) { return ae.complete_sent; }
|
||||||
|
|
||||||
#if !defined TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
bool get_send_stats(announce_entry const& ae) { return ae.send_stats; }
|
bool get_send_stats(announce_entry const& ae) { return ae.send_stats; }
|
||||||
std::int64_t get_size(file_entry const& fe) { return fe.size; }
|
std::int64_t get_size(file_entry const& fe) { return fe.size; }
|
||||||
std::int64_t get_offset(file_entry const& fe) { return fe.offset; }
|
std::int64_t get_offset(file_entry const& fe) { return fe.offset; }
|
||||||
|
@ -244,7 +244,7 @@ void bind_torrent_info()
|
||||||
.def("remap_files", &torrent_info::remap_files)
|
.def("remap_files", &torrent_info::remap_files)
|
||||||
.def("files", &torrent_info::files, return_internal_reference<>())
|
.def("files", &torrent_info::files, return_internal_reference<>())
|
||||||
.def("orig_files", &torrent_info::orig_files, return_internal_reference<>())
|
.def("orig_files", &torrent_info::orig_files, return_internal_reference<>())
|
||||||
#if !defined TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
.def("file_at", &torrent_info::file_at)
|
.def("file_at", &torrent_info::file_at)
|
||||||
.def("file_at_offset", &torrent_info::file_at_offset)
|
.def("file_at_offset", &torrent_info::file_at_offset)
|
||||||
#if TORRENT_USE_WSTRING
|
#if TORRENT_USE_WSTRING
|
||||||
|
@ -265,7 +265,7 @@ void bind_torrent_info()
|
||||||
.def("map_file", &torrent_info::map_file)
|
.def("map_file", &torrent_info::map_file)
|
||||||
;
|
;
|
||||||
|
|
||||||
#if !defined TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
class_<file_entry>("file_entry")
|
class_<file_entry>("file_entry")
|
||||||
.def_readwrite("path", &file_entry::path)
|
.def_readwrite("path", &file_entry::path)
|
||||||
.def_readwrite("symlink_path", &file_entry::symlink_path)
|
.def_readwrite("symlink_path", &file_entry::symlink_path)
|
||||||
|
|
|
@ -191,6 +191,24 @@ class test_session(unittest.TestCase):
|
||||||
self.assertTrue(isinstance(a.values, dict))
|
self.assertTrue(isinstance(a.values, dict))
|
||||||
self.assertTrue(len(a.values) > 0)
|
self.assertTrue(len(a.values) > 0)
|
||||||
|
|
||||||
|
def test_unknown_settings(self):
|
||||||
|
try:
|
||||||
|
s = lt.session({'unexpected-key-name': 42})
|
||||||
|
self.assertFalse('should have thrown an exception')
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
def test_deprecated_settings(self):
|
||||||
|
|
||||||
|
# this detects whether libtorrent was built with deprecated APIs
|
||||||
|
if hasattr(lt, 'version'):
|
||||||
|
s = lt.session({'enable_dht': False})
|
||||||
|
sett = lt.session_settings()
|
||||||
|
sett.num_want = 10;
|
||||||
|
s.set_settings(sett)
|
||||||
|
s.set_settings({'num_want': 33})
|
||||||
|
self.assertEqual(s.get_settings()['num_want'], 33)
|
||||||
|
|
||||||
def test_apply_settings(self):
|
def test_apply_settings(self):
|
||||||
|
|
||||||
s = lt.session({'enable_dht': False})
|
s = lt.session({'enable_dht': False})
|
||||||
|
|
|
@ -1386,16 +1386,6 @@ int main(int argc, char* argv[])
|
||||||
dht.privacy_lookups = true;
|
dht.privacy_lookups = true;
|
||||||
ses.set_dht_settings(dht);
|
ses.set_dht_settings(dht);
|
||||||
|
|
||||||
if (settings.get_bool(settings_pack::enable_dht))
|
|
||||||
{
|
|
||||||
ses.add_dht_router(std::make_pair(
|
|
||||||
std::string("router.bittorrent.com"), 6881));
|
|
||||||
ses.add_dht_router(std::make_pair(
|
|
||||||
std::string("router.utorrent.com"), 6881));
|
|
||||||
ses.add_dht_router(std::make_pair(
|
|
||||||
std::string("router.bitcomet.com"), 6881));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<char> in;
|
std::vector<char> in;
|
||||||
if (load_file(".ses_state", in, ec) == 0)
|
if (load_file(".ses_state", in, ec) == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -352,6 +352,10 @@ namespace libtorrent
|
||||||
// ``add_dht_node`` takes a host name and port pair. That endpoint will be
|
// ``add_dht_node`` takes a host name and port pair. That endpoint will be
|
||||||
// pinged, and if a valid DHT reply is received, the node will be added to
|
// pinged, and if a valid DHT reply is received, the node will be added to
|
||||||
// the routing table.
|
// the routing table.
|
||||||
|
void add_dht_node(std::pair<std::string, int> const& node);
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
|
// deprecated, use settings_pack::dht_bootstrap_nodes instead
|
||||||
//
|
//
|
||||||
// ``add_dht_router`` adds the given endpoint to a list of DHT router
|
// ``add_dht_router`` adds the given endpoint to a list of DHT router
|
||||||
// nodes. If a search is ever made while the routing table is empty,
|
// nodes. If a search is ever made while the routing table is empty,
|
||||||
|
@ -362,8 +366,9 @@ namespace libtorrent
|
||||||
//
|
//
|
||||||
// An example routing node that you could typically add is
|
// An example routing node that you could typically add is
|
||||||
// ``router.bittorrent.com``.
|
// ``router.bittorrent.com``.
|
||||||
void add_dht_node(std::pair<std::string, int> const& node);
|
TORRENT_DEPRECATED
|
||||||
void add_dht_router(std::pair<std::string, int> const& node);
|
void add_dht_router(std::pair<std::string, int> const& node);
|
||||||
|
#endif
|
||||||
|
|
||||||
// query the DHT for an immutable item at the ``target`` hash.
|
// query the DHT for an immutable item at the ``target`` hash.
|
||||||
// the result is posted as a dht_immutable_item_alert.
|
// the result is posted as a dht_immutable_item_alert.
|
||||||
|
@ -577,34 +582,7 @@ namespace libtorrent
|
||||||
// settings_pack::listen_interfaces to try another interface and port to
|
// settings_pack::listen_interfaces to try another interface and port to
|
||||||
// bind to.
|
// bind to.
|
||||||
//
|
//
|
||||||
// ``listen_port()`` returns the port we ended up listening on. If the
|
// ``listen_port()`` returns the port we ended up listening on.
|
||||||
// port specified in settings_pack::listen_interfaces failed, libtorrent
|
|
||||||
// will try to bind to the next port, and so on. If it fails
|
|
||||||
// settings_pack::max_retry_port_bind times, it will bind to port 0
|
|
||||||
// (meaning the OS picks the port). The only way to know which port it
|
|
||||||
// ended up binding to is to ask for it by calling ``listen_port()``.
|
|
||||||
//
|
|
||||||
// If all ports in the specified range fails to be opened for listening,
|
|
||||||
// libtorrent will try to use port 0 (which tells the operating system to
|
|
||||||
// pick a port that's free). If that still fails you may see a
|
|
||||||
// listen_failed_alert with port 0 even if you didn't ask to listen on
|
|
||||||
// it.
|
|
||||||
//
|
|
||||||
// It is possible to prevent libtorrent from binding to port 0 by passing
|
|
||||||
// in the flag ``session::no_system_port`` in the ``flags`` argument.
|
|
||||||
//
|
|
||||||
// The interface parameter can also be a hostname that will resolve to
|
|
||||||
// the device you want to listen on. If you don't specify an interface,
|
|
||||||
// libtorrent may attempt to listen on multiple interfaces (typically
|
|
||||||
// 0.0.0.0 and ::). This means that if your IPv6 interface doesn't work,
|
|
||||||
// you may still see a listen_failed_alert, even though the IPv4 port
|
|
||||||
// succeeded.
|
|
||||||
//
|
|
||||||
// The ``flags`` parameter can either be 0 or
|
|
||||||
// ``session::listen_reuse_address``, which will set the reuse address
|
|
||||||
// socket option on the listen socket(s). By default, the listen socket
|
|
||||||
// does not use reuse address. If you're running a service that needs to
|
|
||||||
// run on a specific port no matter if it's in use, set this flag.
|
|
||||||
unsigned short listen_port() const;
|
unsigned short listen_port() const;
|
||||||
unsigned short ssl_listen_port() const;
|
unsigned short ssl_listen_port() const;
|
||||||
bool is_listening() const;
|
bool is_listening() const;
|
||||||
|
|
|
@ -1404,7 +1404,7 @@ namespace libtorrent
|
||||||
// normal client. If this is a high performance server which expects
|
// normal client. If this is a high performance server which expects
|
||||||
// to receive a lot of connections, or used in a simulator or test, it
|
// to receive a lot of connections, or used in a simulator or test, it
|
||||||
// might make sense to raise this number. It will not take affect
|
// might make sense to raise this number. It will not take affect
|
||||||
// until listen_on() is called again (or for the first time).
|
// until the ``listen_interfaces`` settings is updated.
|
||||||
listen_queue_size,
|
listen_queue_size,
|
||||||
|
|
||||||
// ``torrent_connect_boost`` is the number of peers to try to connect
|
// ``torrent_connect_boost`` is the number of peers to try to connect
|
||||||
|
|
|
@ -524,6 +524,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
void session_handle::add_dht_router(std::pair<std::string, int> const& node)
|
void session_handle::add_dht_router(std::pair<std::string, int> const& node)
|
||||||
{
|
{
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
|
@ -532,6 +533,7 @@ namespace libtorrent
|
||||||
TORRENT_UNUSED(node);
|
TORRENT_UNUSED(node);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif // TORRENT_NO_DEPRECATE
|
||||||
|
|
||||||
void session_handle::dht_get_item(sha1_hash const& target)
|
void session_handle::dht_get_item(sha1_hash const& target)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue