merged RC_1_1 into master

This commit is contained in:
arvidn 2016-11-03 01:19:38 -04:00
commit d91f6f8c05
8 changed files with 47 additions and 50 deletions

View File

@ -55,7 +55,7 @@ namespace
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)
{
ct.add_file(fe);
@ -112,7 +112,7 @@ void bind_create_torrent()
{
void (file_storage::*add_file0)(std::string const&, std::int64_t
, int, std::time_t, string_view) = &file_storage::add_file;
#if !defined TORRENT_NO_DEPRECATE
#ifndef TORRENT_NO_DEPRECATE
#if TORRENT_USE_WSTRING
void (file_storage::*add_file1)(std::wstring const&, std::int64_t
, 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;
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;
#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") = ""))
#endif
.def("num_files", &file_storage::num_files)
#if !defined TORRENT_NO_DEPRECATE
#ifndef TORRENT_NO_DEPRECATE
.def("at", at)
.def("add_file", add_file, arg("entry"))
.def("__iter__", boost::python::range(&begin_files, &end_files))

View File

@ -63,7 +63,6 @@ namespace
if (ec) throw system_error(ec);
#endif
}
#endif
void outgoing_ports(lt::session& s, int _min, int _max)
{
@ -74,6 +73,8 @@ namespace
s.apply_settings(p);
return;
}
#endif // TORRENT_NO_DEPRECATE
#ifndef TORRENT_DISABLE_DHT
void add_dht_node(lt::session& s, tuple n)
{
@ -83,11 +84,13 @@ namespace
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_)
{
allow_threading_guard guard;
return s.add_dht_router(std::make_pair(router_, port_));
}
#endif
#endif // TORRENT_DISABLE_DHT
@ -116,7 +119,11 @@ namespace
std::string const key = extract<std::string>(iterkeys[i]);
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
{
@ -689,18 +696,20 @@ void bind_session()
, arg("flags")=lt::session::start_default_features | lt::session::add_default_plugins
, arg("alert_mask")=int(alert::error_notification)))
)
.def("outgoing_ports", &outgoing_ports)
#endif
.def("post_torrent_updates", allow_threads(&lt::session::post_torrent_updates), arg("flags") = 0xffffffff)
.def("post_session_stats", allow_threads(&lt::session::post_session_stats))
.def("outgoing_ports", &outgoing_ports)
.def("is_listening", allow_threads(&lt::session::is_listening))
.def("listen_port", allow_threads(&lt::session::listen_port))
#ifndef TORRENT_DISABLE_DHT
.def("add_dht_node", &add_dht_node)
#ifndef TORRENT_NO_DEPRECATE
.def(
"add_dht_router", &add_dht_router
, (arg("router"), "port")
)
#endif // TORRENT_NO_DEPRECATE
.def("is_dht_running", allow_threads(&lt::session::is_dht_running))
.def("set_dht_settings", allow_threads(&lt::session::set_dht_settings))
.def("get_dht_settings", allow_threads(&lt::session::get_dht_settings))

View File

@ -120,7 +120,7 @@ namespace
bool get_start_sent(announce_entry const& ae) { return ae.start_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; }
std::int64_t get_size(file_entry const& fe) { return fe.size; }
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("files", &torrent_info::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_offset", &torrent_info::file_at_offset)
#if TORRENT_USE_WSTRING
@ -265,7 +265,7 @@ void bind_torrent_info()
.def("map_file", &torrent_info::map_file)
;
#if !defined TORRENT_NO_DEPRECATE
#ifndef TORRENT_NO_DEPRECATE
class_<file_entry>("file_entry")
.def_readwrite("path", &file_entry::path)
.def_readwrite("symlink_path", &file_entry::symlink_path)

View File

@ -191,6 +191,24 @@ class test_session(unittest.TestCase):
self.assertTrue(isinstance(a.values, dict))
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):
s = lt.session({'enable_dht': False})

View File

@ -1386,16 +1386,6 @@ int main(int argc, char* argv[])
dht.privacy_lookups = true;
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;
if (load_file(".ses_state", in, ec) == 0)
{

View File

@ -352,6 +352,10 @@ namespace libtorrent
// ``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
// 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
// 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
// ``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);
#endif
// query the DHT for an immutable item at the ``target`` hash.
// 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
// bind to.
//
// ``listen_port()`` returns the port we ended up listening on. If the
// 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.
// ``listen_port()`` returns the port we ended up listening on.
unsigned short listen_port() const;
unsigned short ssl_listen_port() const;
bool is_listening() const;

View File

@ -1404,7 +1404,7 @@ namespace libtorrent
// 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
// 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,
// ``torrent_connect_boost`` is the number of peers to try to connect

View File

@ -524,6 +524,7 @@ namespace libtorrent
#endif
}
#ifndef TORRENT_NO_DEPRECATE
void session_handle::add_dht_router(std::pair<std::string, int> const& node)
{
#ifndef TORRENT_DISABLE_DHT
@ -532,6 +533,7 @@ namespace libtorrent
TORRENT_UNUSED(node);
#endif
}
#endif // TORRENT_NO_DEPRECATE
void session_handle::dht_get_item(sha1_hash const& target)
{