2007-04-07 05:37:23 +02:00
|
|
|
// Copyright Daniel Wallin, Arvid Norberg 2006. Use, modification and distribution is
|
2007-01-10 17:11:43 +01:00
|
|
|
// subject to the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
2017-08-14 00:49:49 +02:00
|
|
|
#include "boost_python.hpp"
|
2011-11-08 06:53:13 +01:00
|
|
|
#include <list>
|
|
|
|
#include <string>
|
2007-01-10 17:11:43 +01:00
|
|
|
#include <libtorrent/session.hpp>
|
2007-04-07 05:37:23 +02:00
|
|
|
#include <libtorrent/storage.hpp>
|
2014-08-27 09:47:39 +02:00
|
|
|
#include <libtorrent/error_code.hpp>
|
2008-02-17 21:55:03 +01:00
|
|
|
#include <libtorrent/ip_filter.hpp>
|
2009-06-26 01:05:12 +02:00
|
|
|
#include <libtorrent/disk_io_thread.hpp>
|
2012-09-19 08:13:04 +02:00
|
|
|
#include <libtorrent/extensions.hpp>
|
2015-03-12 06:20:12 +01:00
|
|
|
#include <libtorrent/bdecode.hpp>
|
2013-10-10 07:53:44 +02:00
|
|
|
#include <libtorrent/bencode.hpp>
|
2016-02-16 20:20:04 +01:00
|
|
|
#include <libtorrent/read_resume_data.hpp>
|
2017-09-12 00:22:55 +02:00
|
|
|
#include <libtorrent/write_resume_data.hpp>
|
2015-09-18 06:23:45 +02:00
|
|
|
#include <libtorrent/torrent_info.hpp>
|
2015-11-08 19:08:03 +01:00
|
|
|
#include <libtorrent/kademlia/item.hpp> // for sign_mutable_item
|
2016-07-04 05:30:52 +02:00
|
|
|
#include <libtorrent/alert.hpp>
|
2016-11-23 00:38:45 +01:00
|
|
|
#include <libtorrent/time.hpp>
|
2016-12-23 03:43:05 +01:00
|
|
|
#include <libtorrent/session_stats.hpp>
|
2017-04-12 23:34:17 +02:00
|
|
|
#include <libtorrent/session_status.hpp>
|
2017-09-24 21:59:42 +02:00
|
|
|
#include <libtorrent/peer_class_type_filter.hpp>
|
2012-10-13 04:08:34 +02:00
|
|
|
|
|
|
|
#include <libtorrent/extensions/smart_ban.hpp>
|
|
|
|
#include <libtorrent/extensions/ut_metadata.hpp>
|
|
|
|
#include <libtorrent/extensions/ut_pex.hpp>
|
|
|
|
|
2016-07-04 05:30:52 +02:00
|
|
|
namespace boost
|
|
|
|
{
|
|
|
|
// this fixes mysterious link error on msvc
|
2017-08-14 00:49:49 +02:00
|
|
|
template <>
|
|
|
|
inline lt::alert const volatile*
|
|
|
|
get_pointer(class lt::alert const volatile* p)
|
2016-07-04 05:30:52 +02:00
|
|
|
{
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-10 17:11:43 +01:00
|
|
|
#include "gil.hpp"
|
2014-09-13 00:38:07 +02:00
|
|
|
#include "bytes.hpp"
|
2015-09-02 07:30:40 +02:00
|
|
|
|
2016-06-19 01:24:27 +02:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(push)
|
|
|
|
// warning C4996: X: was declared deprecated
|
|
|
|
#pragma warning( disable : 4996 )
|
|
|
|
#endif
|
|
|
|
|
2007-01-10 17:11:43 +01:00
|
|
|
using namespace boost::python;
|
2017-04-12 20:05:53 +02:00
|
|
|
using namespace lt;
|
2007-01-10 17:11:43 +01:00
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2017-08-30 20:47:49 +02:00
|
|
|
struct dummy {};
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
void listen_on(lt::session& s, int min_, int max_, char const* interface, int flags)
|
2009-05-31 22:46:40 +02:00
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
2012-09-11 19:20:31 +02:00
|
|
|
error_code ec;
|
2011-08-14 01:30:11 +02:00
|
|
|
s.listen_on(std::make_pair(min_, max_), ec, interface, flags);
|
2014-08-31 23:17:32 +02:00
|
|
|
#ifndef BOOST_NO_EXCEPTIONS
|
2016-05-15 06:33:06 +02:00
|
|
|
if (ec) throw system_error(ec);
|
2014-08-31 23:17:32 +02:00
|
|
|
#endif
|
2009-05-31 22:46:40 +02:00
|
|
|
}
|
2007-01-10 17:11:43 +01:00
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
void outgoing_ports(lt::session& s, int _min, int _max)
|
2009-05-31 22:46:40 +02:00
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
2015-06-07 06:23:30 +02:00
|
|
|
settings_pack p;
|
|
|
|
p.set_int(settings_pack::outgoing_port, _min);
|
|
|
|
p.set_int(settings_pack::num_outgoing_ports, _max - _min);
|
2014-07-06 21:18:00 +02:00
|
|
|
s.apply_settings(p);
|
2009-05-31 22:46:40 +02:00
|
|
|
return;
|
|
|
|
}
|
2018-04-26 09:01:14 +02:00
|
|
|
#endif // TORRENT_ABI_VERSION
|
2016-10-30 03:56:46 +01:00
|
|
|
|
2008-03-10 04:19:57 +01:00
|
|
|
#ifndef TORRENT_DISABLE_DHT
|
2014-07-06 21:18:00 +02:00
|
|
|
void add_dht_node(lt::session& s, tuple n)
|
2013-05-03 10:24:26 +02:00
|
|
|
{
|
|
|
|
std::string ip = extract<std::string>(n[0]);
|
|
|
|
int port = extract<int>(n[1]);
|
2015-07-12 17:05:06 +02:00
|
|
|
allow_threading_guard guard;
|
2013-05-03 10:24:26 +02:00
|
|
|
s.add_dht_node(std::make_pair(ip, port));
|
|
|
|
}
|
|
|
|
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2014-07-06 21:18:00 +02:00
|
|
|
void add_dht_router(lt::session& s, std::string router_, int port_)
|
2009-05-31 22:46:40 +02:00
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
|
|
|
return s.add_dht_router(std::make_pair(router_, port_));
|
|
|
|
}
|
2016-11-03 04:40:48 +01:00
|
|
|
#endif
|
2015-07-06 19:14:28 +02:00
|
|
|
|
|
|
|
#endif // TORRENT_DISABLE_DHT
|
2008-02-17 22:12:06 +01:00
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
void add_extension(lt::session& s, object const& e)
|
2012-10-13 04:08:34 +02:00
|
|
|
{
|
2013-12-21 07:20:16 +01:00
|
|
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
2012-10-13 04:08:34 +02:00
|
|
|
if (!extract<std::string>(e).check()) return;
|
|
|
|
|
|
|
|
std::string name = extract<std::string>(e);
|
|
|
|
if (name == "ut_metadata")
|
|
|
|
s.add_extension(create_ut_metadata_plugin);
|
|
|
|
else if (name == "ut_pex")
|
|
|
|
s.add_extension(create_ut_pex_plugin);
|
|
|
|
else if (name == "smart_ban")
|
|
|
|
s.add_extension(create_smart_ban_plugin);
|
2014-03-17 04:41:35 +01:00
|
|
|
|
2013-12-21 07:20:16 +01:00
|
|
|
#endif // TORRENT_DISABLE_EXTENSIONS
|
2012-10-13 04:08:34 +02:00
|
|
|
}
|
|
|
|
|
2016-01-05 07:32:04 +01:00
|
|
|
void make_settings_pack(lt::settings_pack& p, dict const& sett_dict)
|
2010-12-26 09:03:02 +01:00
|
|
|
{
|
2017-05-21 14:25:33 +02:00
|
|
|
stl_input_iterator<std::string> i(sett_dict.keys()), end;
|
|
|
|
for (; i != end; ++i)
|
2010-12-26 09:03:02 +01:00
|
|
|
{
|
2017-05-21 14:25:33 +02:00
|
|
|
std::string const key = *i;
|
2010-12-26 09:03:02 +01:00
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
int sett = setting_by_name(key);
|
2016-11-03 06:01:48 +01:00
|
|
|
if (sett < 0)
|
|
|
|
{
|
2016-11-03 22:06:53 +01:00
|
|
|
PyErr_SetString(PyExc_KeyError, ("unknown name in settings_pack: " + key).c_str());
|
2016-11-03 06:01:48 +01:00
|
|
|
throw_error_already_set();
|
|
|
|
}
|
2014-07-06 21:18:00 +02:00
|
|
|
|
|
|
|
TORRENT_TRY
|
2010-12-26 09:03:02 +01:00
|
|
|
{
|
2016-04-27 18:28:22 +02:00
|
|
|
object const value = sett_dict[key];
|
2014-07-06 21:18:00 +02:00
|
|
|
switch (sett & settings_pack::type_mask)
|
|
|
|
{
|
|
|
|
case settings_pack::string_type_base:
|
|
|
|
p.set_str(sett, extract<std::string>(value));
|
|
|
|
break;
|
|
|
|
case settings_pack::int_type_base:
|
|
|
|
p.set_int(sett, extract<int>(value));
|
|
|
|
break;
|
|
|
|
case settings_pack::bool_type_base:
|
|
|
|
p.set_bool(sett, extract<bool>(value));
|
|
|
|
break;
|
|
|
|
}
|
2010-12-26 09:03:02 +01:00
|
|
|
}
|
2014-07-06 21:18:00 +02:00
|
|
|
TORRENT_CATCH(...) {}
|
2010-12-26 09:03:02 +01:00
|
|
|
}
|
2016-01-05 07:32:04 +01:00
|
|
|
}
|
2010-12-26 09:03:02 +01:00
|
|
|
|
2017-01-24 02:33:52 +01:00
|
|
|
dict make_dict(lt::settings_pack const& sett)
|
|
|
|
{
|
|
|
|
dict ret;
|
|
|
|
for (int i = settings_pack::string_type_base;
|
|
|
|
i < settings_pack::max_string_setting_internal; ++i)
|
|
|
|
{
|
|
|
|
ret[name_for_setting(i)] = sett.get_str(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = settings_pack::int_type_base;
|
|
|
|
i < settings_pack::max_int_setting_internal; ++i)
|
|
|
|
{
|
|
|
|
ret[name_for_setting(i)] = sett.get_int(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = settings_pack::bool_type_base;
|
|
|
|
i < settings_pack::max_bool_setting_internal; ++i)
|
|
|
|
{
|
|
|
|
ret[name_for_setting(i)] = sett.get_bool(i);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-07-27 22:26:12 +02:00
|
|
|
std::shared_ptr<lt::session> make_session(boost::python::dict sett, session_flags_t flags)
|
2016-01-05 07:32:04 +01:00
|
|
|
{
|
|
|
|
settings_pack p;
|
|
|
|
make_settings_pack(p, sett);
|
2016-09-01 03:42:18 +02:00
|
|
|
return std::make_shared<lt::session>(p, flags);
|
2016-01-05 07:32:04 +01:00
|
|
|
}
|
2012-12-14 05:38:44 +01:00
|
|
|
|
2016-04-04 06:52:21 +02:00
|
|
|
void session_apply_settings(lt::session& ses, dict const& sett_dict)
|
2016-01-05 07:32:04 +01:00
|
|
|
{
|
|
|
|
settings_pack p;
|
|
|
|
make_settings_pack(p, sett_dict);
|
|
|
|
allow_threading_guard guard;
|
2014-07-06 21:18:00 +02:00
|
|
|
ses.apply_settings(p);
|
2010-12-26 09:03:02 +01:00
|
|
|
}
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
dict session_get_settings(lt::session const& ses)
|
2010-12-26 09:03:02 +01:00
|
|
|
{
|
2015-06-07 06:23:30 +02:00
|
|
|
settings_pack sett;
|
2012-09-11 19:20:31 +02:00
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
2014-07-06 21:18:00 +02:00
|
|
|
sett = ses.get_settings();
|
2012-09-11 19:20:31 +02:00
|
|
|
}
|
2017-01-24 02:33:52 +01:00
|
|
|
return make_dict(sett);
|
|
|
|
}
|
2014-07-06 21:18:00 +02:00
|
|
|
|
2017-01-24 02:33:52 +01:00
|
|
|
dict min_memory_usage_wrapper()
|
|
|
|
{
|
2017-01-29 02:21:39 +01:00
|
|
|
settings_pack ret = min_memory_usage();
|
2017-01-24 02:33:52 +01:00
|
|
|
return make_dict(ret);
|
|
|
|
}
|
2014-07-06 21:18:00 +02:00
|
|
|
|
2017-02-05 09:13:26 +01:00
|
|
|
dict default_settings_wrapper()
|
|
|
|
{
|
|
|
|
return make_dict(default_settings());
|
|
|
|
}
|
|
|
|
|
2017-01-24 02:33:52 +01:00
|
|
|
dict high_performance_seed_wrapper()
|
|
|
|
{
|
2017-01-29 02:21:39 +01:00
|
|
|
settings_pack ret = high_performance_seed();
|
2017-01-24 02:33:52 +01:00
|
|
|
return make_dict(ret);
|
2010-12-26 09:03:02 +01:00
|
|
|
}
|
|
|
|
|
2010-08-22 18:45:12 +02:00
|
|
|
#ifndef BOOST_NO_EXCEPTIONS
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2014-07-06 21:18:00 +02:00
|
|
|
torrent_handle add_torrent_depr(lt::session& s, torrent_info const& ti
|
2009-10-26 02:29:39 +01:00
|
|
|
, std::string const& save, entry const& resume
|
2009-05-31 22:46:40 +02:00
|
|
|
, storage_mode_t storage_mode, bool paused)
|
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
|
|
|
return s.add_torrent(ti, save, resume, storage_mode, paused, default_storage_constructor);
|
|
|
|
}
|
2010-08-22 18:45:12 +02:00
|
|
|
#endif
|
2008-10-28 03:34:14 +01:00
|
|
|
#endif
|
2011-11-08 06:36:22 +01:00
|
|
|
}
|
2008-10-28 03:34:14 +01:00
|
|
|
|
2013-08-27 18:04:19 +02:00
|
|
|
void dict_to_add_torrent_params(dict params, add_torrent_params& p)
|
2009-05-31 22:46:40 +02:00
|
|
|
{
|
2017-01-24 15:26:11 +01:00
|
|
|
list items = params.items();
|
|
|
|
int const len = int(boost::python::len(items));
|
|
|
|
for (int i = 0; i < len; i++)
|
2016-04-04 05:50:06 +02:00
|
|
|
{
|
2017-01-24 15:26:11 +01:00
|
|
|
boost::python::api::object_item item = items[i];
|
|
|
|
std::string const key = extract<std::string>(item[0]);
|
|
|
|
object const value = item[1];
|
|
|
|
// torrent_info objects are always held by a shared_ptr in the
|
|
|
|
// python binding, skip it if it is a object
|
2017-07-09 16:32:01 +02:00
|
|
|
if (key == "ti" && value != boost::python::object())
|
2017-01-24 15:26:11 +01:00
|
|
|
{
|
|
|
|
// make a copy here. We don't want to end up holding a python-owned
|
|
|
|
// object inside libtorrent. If the last reference goes out of scope
|
|
|
|
// on the C++ side, it will end up freeing the python object
|
|
|
|
// without holding the GIL and likely crash.
|
|
|
|
// https://mail.python.org/pipermail/cplusplus-sig/2007-June/012130.html
|
|
|
|
p.ti = std::make_shared<torrent_info>(
|
|
|
|
extract<torrent_info const&>(value));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(key == "info_hash")
|
|
|
|
{
|
|
|
|
p.info_hash = sha1_hash(
|
|
|
|
bytes(extract<bytes>(value)).arr.data());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(key == "name")
|
|
|
|
{
|
|
|
|
p.name = extract<std::string>(value);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(key == "save_path")
|
|
|
|
{
|
|
|
|
p.save_path = extract<std::string>(value);
|
|
|
|
continue;
|
|
|
|
}
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2017-01-24 15:26:11 +01:00
|
|
|
else if(key == "resume_data")
|
|
|
|
{
|
|
|
|
std::string resume = extract<std::string>(value);
|
|
|
|
p.resume_data.assign(resume.begin(), resume.end());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(key == "uuid")
|
|
|
|
{
|
|
|
|
p.uuid = extract<std::string>(value);
|
|
|
|
continue;
|
|
|
|
}
|
2016-02-20 21:49:49 +01:00
|
|
|
#endif
|
2017-01-24 15:26:11 +01:00
|
|
|
else if(key == "storage_mode")
|
|
|
|
{
|
|
|
|
p.storage_mode = extract<storage_mode_t>(value);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(key == "trackers")
|
|
|
|
{
|
|
|
|
p.trackers = extract<std::vector<std::string>>(value);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(key == "url_seeds")
|
|
|
|
{
|
|
|
|
p.url_seeds = extract<std::vector<std::string>>(value);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(key == "http_seeds")
|
|
|
|
{
|
|
|
|
p.http_seeds =
|
|
|
|
extract<decltype(add_torrent_params::http_seeds)>(value);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(key == "dht_nodes")
|
|
|
|
{
|
|
|
|
p.dht_nodes =
|
|
|
|
extract<std::vector<std::pair<std::string, int>>>(value);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(key == "banned_peers")
|
|
|
|
{
|
|
|
|
p.banned_peers = extract<std::vector<lt::tcp::endpoint>>(value);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(key == "peers")
|
|
|
|
{
|
|
|
|
p.peers = extract<std::vector<lt::tcp::endpoint>>(value);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(key == "flags")
|
|
|
|
{
|
2017-07-09 16:32:01 +02:00
|
|
|
p.flags = extract<lt::torrent_flags_t>(value);
|
2017-01-24 15:26:11 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(key == "trackerid")
|
|
|
|
{
|
|
|
|
p.trackerid = extract<std::string>(value);
|
|
|
|
continue;
|
|
|
|
}
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2017-01-24 15:26:11 +01:00
|
|
|
else if(key == "url")
|
|
|
|
{
|
|
|
|
p.url = extract<std::string>(value);
|
|
|
|
continue;
|
|
|
|
}
|
2017-03-29 08:16:07 +02:00
|
|
|
#endif
|
2017-01-24 15:26:11 +01:00
|
|
|
else if(key == "renamed_files")
|
|
|
|
{
|
|
|
|
p.renamed_files =
|
|
|
|
extract<std::map<lt::file_index_t, std::string>>(value);
|
|
|
|
}
|
|
|
|
else if(key == "file_priorities")
|
|
|
|
{
|
2017-10-29 00:44:40 +02:00
|
|
|
p.file_priorities = extract<std::vector<download_priority_t>>(value);
|
2017-01-24 15:26:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_KeyError,
|
|
|
|
("unknown name in torrent params: " + key).c_str());
|
|
|
|
throw_error_already_set();
|
|
|
|
}
|
|
|
|
}
|
2011-01-18 04:41:54 +01:00
|
|
|
}
|
|
|
|
|
2011-11-08 06:36:22 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
torrent_handle add_torrent(lt::session& s, dict params)
|
2011-01-18 04:41:54 +01:00
|
|
|
{
|
|
|
|
add_torrent_params p;
|
2013-08-27 18:04:19 +02:00
|
|
|
dict_to_add_torrent_params(params, p);
|
2009-06-26 01:05:12 +02:00
|
|
|
|
2011-03-07 09:24:02 +01:00
|
|
|
allow_threading_guard guard;
|
|
|
|
|
2010-08-22 18:45:12 +02:00
|
|
|
#ifndef BOOST_NO_EXCEPTIONS
|
2009-05-31 22:46:40 +02:00
|
|
|
return s.add_torrent(p);
|
2010-08-22 18:45:12 +02:00
|
|
|
#else
|
|
|
|
error_code ec;
|
|
|
|
return s.add_torrent(p, ec);
|
|
|
|
#endif
|
2009-05-31 22:46:40 +02:00
|
|
|
}
|
2008-07-01 18:02:17 +02:00
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
void async_add_torrent(lt::session& s, dict params)
|
2012-10-19 07:18:48 +02:00
|
|
|
{
|
|
|
|
add_torrent_params p;
|
2013-08-27 18:04:19 +02:00
|
|
|
dict_to_add_torrent_params(params, p);
|
2012-10-19 07:18:48 +02:00
|
|
|
|
|
|
|
allow_threading_guard guard;
|
|
|
|
|
|
|
|
s.async_add_torrent(p);
|
|
|
|
}
|
|
|
|
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2014-07-06 21:18:00 +02:00
|
|
|
void start_natpmp(lt::session& s)
|
2008-05-01 07:37:04 +02:00
|
|
|
{
|
2009-05-31 22:46:40 +02:00
|
|
|
allow_threading_guard guard;
|
|
|
|
s.start_natpmp();
|
2008-05-01 07:37:04 +02:00
|
|
|
}
|
2009-05-31 22:46:40 +02:00
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
void start_upnp(lt::session& s)
|
2008-05-01 07:37:04 +02:00
|
|
|
{
|
2009-05-31 22:46:40 +02:00
|
|
|
allow_threading_guard guard;
|
|
|
|
s.start_upnp();
|
2008-05-01 07:37:04 +02:00
|
|
|
}
|
2018-04-26 09:01:14 +02:00
|
|
|
#endif // TORRENT_ABI_VERSION
|
2008-07-01 18:02:17 +02:00
|
|
|
|
2018-07-23 06:43:21 +02:00
|
|
|
void alert_notify(object cb) try
|
2018-05-29 22:30:59 +02:00
|
|
|
{
|
|
|
|
lock_gil lock;
|
|
|
|
if (cb)
|
|
|
|
{
|
|
|
|
cb();
|
|
|
|
}
|
|
|
|
}
|
2018-07-23 06:43:21 +02:00
|
|
|
catch (boost::python::error_already_set const&)
|
|
|
|
{
|
|
|
|
// this callback isn't supposed to throw an error.
|
|
|
|
// just swallow and ignore the exception
|
|
|
|
TORRENT_ASSERT_FAIL_VAL("python notify callback threw exception");
|
|
|
|
}
|
2018-05-29 22:30:59 +02:00
|
|
|
|
|
|
|
void set_alert_notify(lt::session& s, object cb)
|
|
|
|
{
|
|
|
|
s.set_alert_notify(std::bind(&alert_notify, cb));
|
|
|
|
}
|
|
|
|
|
2016-01-05 07:32:04 +01:00
|
|
|
alert const*
|
|
|
|
wait_for_alert(lt::session& s, int ms)
|
2009-09-25 16:35:28 +02:00
|
|
|
{
|
2016-07-04 05:30:52 +02:00
|
|
|
alert const* a;
|
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
|
|
|
a = s.wait_for_alert(milliseconds(ms));
|
|
|
|
}
|
2016-01-05 07:32:04 +01:00
|
|
|
return a;
|
2009-09-25 16:35:28 +02:00
|
|
|
}
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
list get_torrents(lt::session& s)
|
2008-07-01 18:02:17 +02:00
|
|
|
{
|
2009-05-31 22:46:40 +02:00
|
|
|
list ret;
|
2012-09-11 19:20:31 +02:00
|
|
|
std::vector<torrent_handle> torrents;
|
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
|
|
|
torrents = s.get_torrents();
|
|
|
|
}
|
2009-05-31 22:46:40 +02:00
|
|
|
|
|
|
|
for (std::vector<torrent_handle>::iterator i = torrents.begin(); i != torrents.end(); ++i)
|
|
|
|
{
|
|
|
|
ret.append(*i);
|
|
|
|
}
|
|
|
|
return ret;
|
2008-07-01 18:02:17 +02:00
|
|
|
}
|
2008-10-28 07:29:30 +01:00
|
|
|
|
2016-04-04 05:50:06 +02:00
|
|
|
cache_status get_cache_info1(lt::session& s, torrent_handle h, int flags)
|
|
|
|
{
|
|
|
|
cache_status ret;
|
|
|
|
s.get_cache_info(&ret, h, flags);
|
|
|
|
return ret;
|
|
|
|
}
|
2014-07-06 21:18:00 +02:00
|
|
|
|
2016-11-23 00:38:45 +01:00
|
|
|
list cached_piece_info_list(std::vector<cached_piece_info> const& v)
|
|
|
|
{
|
|
|
|
list pieces;
|
2016-11-24 13:40:32 +01:00
|
|
|
time_point now = clock_type::now();
|
2016-11-23 00:38:45 +01:00
|
|
|
for (std::vector<cached_piece_info>::const_iterator i = v.begin()
|
|
|
|
, end(v.end()); i != end; ++i)
|
|
|
|
{
|
|
|
|
dict d;
|
|
|
|
d["piece"] = i->piece;
|
|
|
|
d["last_use"] = total_milliseconds(now - i->last_use) / 1000.f;
|
|
|
|
d["next_to_hash"] = i->next_to_hash;
|
2016-11-26 04:39:17 +01:00
|
|
|
d["kind"] = static_cast<int>(i->kind);
|
2016-11-23 00:38:45 +01:00
|
|
|
pieces.append(d);
|
|
|
|
}
|
|
|
|
return pieces;
|
|
|
|
}
|
|
|
|
|
|
|
|
list cache_status_pieces(cache_status const& cs)
|
|
|
|
{
|
|
|
|
return cached_piece_info_list(cs.pieces);
|
|
|
|
}
|
|
|
|
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2016-04-04 05:50:06 +02:00
|
|
|
cache_status get_cache_status(lt::session& s)
|
|
|
|
{
|
|
|
|
cache_status ret;
|
|
|
|
s.get_cache_info(&ret);
|
|
|
|
return ret;
|
|
|
|
}
|
2014-07-06 21:18:00 +02:00
|
|
|
|
2013-05-03 10:24:26 +02:00
|
|
|
dict get_utp_stats(session_status const& st)
|
|
|
|
{
|
|
|
|
dict ret;
|
|
|
|
ret["num_idle"] = st.utp_stats.num_idle;
|
|
|
|
ret["num_syn_sent"] = st.utp_stats.num_syn_sent;
|
|
|
|
ret["num_connected"] = st.utp_stats.num_connected;
|
|
|
|
ret["num_fin_sent"] = st.utp_stats.num_fin_sent;
|
|
|
|
ret["num_close_wait"] = st.utp_stats.num_close_wait;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
list get_cache_info2(lt::session& ses, sha1_hash ih)
|
2013-05-05 20:08:03 +02:00
|
|
|
{
|
2014-07-06 21:18:00 +02:00
|
|
|
std::vector<cached_piece_info> ret;
|
|
|
|
|
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
|
|
|
ses.get_cache_info(ih, ret);
|
|
|
|
}
|
|
|
|
|
2016-11-23 00:38:45 +01:00
|
|
|
return cached_piece_info_list(ret);
|
2013-05-05 20:08:03 +02:00
|
|
|
}
|
2008-04-20 22:12:33 +02:00
|
|
|
#endif
|
2009-12-05 08:24:22 +01:00
|
|
|
|
2017-07-27 22:26:12 +02:00
|
|
|
entry save_state(lt::session const& s, std::uint32_t const flags)
|
2009-12-05 08:24:22 +01:00
|
|
|
{
|
2011-03-07 09:24:02 +01:00
|
|
|
allow_threading_guard guard;
|
2009-12-05 08:24:22 +01:00
|
|
|
entry e;
|
2017-07-27 22:26:12 +02:00
|
|
|
s.save_state(e, save_state_flags_t(flags));
|
2009-12-05 08:24:22 +01:00
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
2016-01-05 07:32:04 +01:00
|
|
|
list pop_alerts(lt::session& ses)
|
|
|
|
{
|
|
|
|
std::vector<alert*> alerts;
|
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
|
|
|
ses.pop_alerts(&alerts);
|
|
|
|
}
|
|
|
|
|
|
|
|
list ret;
|
2016-07-04 05:30:52 +02:00
|
|
|
for (alert* a : alerts)
|
2016-01-05 07:32:04 +01:00
|
|
|
{
|
2016-07-04 05:30:52 +02:00
|
|
|
ret.append(boost::python::ptr(a));
|
2013-01-04 18:52:35 +01:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-07-27 22:26:12 +02:00
|
|
|
void load_state(lt::session& ses, entry const& st, std::uint32_t const flags)
|
2016-03-05 21:15:22 +01:00
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
|
|
|
|
|
|
|
std::vector<char> buf;
|
|
|
|
bencode(std::back_inserter(buf), st);
|
|
|
|
bdecode_node e;
|
|
|
|
error_code ec;
|
|
|
|
bdecode(&buf[0], &buf[0] + buf.size(), e, ec);
|
|
|
|
TORRENT_ASSERT(!ec);
|
2017-07-27 22:26:12 +02:00
|
|
|
ses.load_state(e, save_state_flags_t(flags));
|
2016-03-05 21:15:22 +01:00
|
|
|
}
|
2015-11-08 19:08:03 +01:00
|
|
|
|
2017-10-04 11:43:01 +02:00
|
|
|
dict get_peer_class(lt::session& ses, lt::peer_class_t const pc)
|
2017-09-24 21:59:42 +02:00
|
|
|
{
|
|
|
|
lt::peer_class_info pci;
|
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
|
|
|
pci = ses.get_peer_class(pc);
|
|
|
|
}
|
|
|
|
dict ret;
|
|
|
|
ret["ignore_unchoke_slots"] = pci.ignore_unchoke_slots;
|
|
|
|
ret["connection_limit_factor"] = pci.connection_limit_factor;
|
|
|
|
ret["label"] = pci.label;
|
|
|
|
ret["upload_limit"] = pci.upload_limit;
|
|
|
|
ret["download_limit"] = pci.download_limit;
|
|
|
|
ret["upload_priority"] = pci.upload_priority;
|
|
|
|
ret["download_priority"] = pci.download_priority;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-10-04 11:43:01 +02:00
|
|
|
void set_peer_class(lt::session& ses, peer_class_t const pc, dict info)
|
2017-09-24 21:59:42 +02:00
|
|
|
{
|
|
|
|
lt::peer_class_info pci;
|
|
|
|
stl_input_iterator<std::string> i(info.keys()), end;
|
|
|
|
for (; i != end; ++i)
|
|
|
|
{
|
|
|
|
std::string const key = *i;
|
|
|
|
|
|
|
|
object const value = info[key];
|
|
|
|
if (key == "ignore_unchoke_slots")
|
|
|
|
{
|
|
|
|
pci.ignore_unchoke_slots = extract<bool>(value);
|
|
|
|
}
|
|
|
|
else if (key == "connection_limit_factor")
|
|
|
|
{
|
|
|
|
pci.connection_limit_factor = extract<int>(value);
|
|
|
|
}
|
|
|
|
else if (key == "label")
|
|
|
|
{
|
|
|
|
pci.label = extract<std::string>(value);
|
|
|
|
}
|
|
|
|
else if (key == "upload_limit")
|
|
|
|
{
|
|
|
|
pci.upload_limit = extract<int>(value);
|
|
|
|
}
|
|
|
|
else if (key == "download_limit")
|
|
|
|
{
|
|
|
|
pci.download_limit = extract<int>(value);
|
|
|
|
}
|
|
|
|
else if (key == "upload_priority")
|
|
|
|
{
|
|
|
|
pci.upload_priority = extract<int>(value);
|
|
|
|
}
|
|
|
|
else if (key == "download_priority")
|
|
|
|
{
|
|
|
|
pci.download_priority = extract<int>(value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_KeyError, ("unknown name in peer_class_info: " + key).c_str());
|
|
|
|
throw_error_already_set();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
allow_threading_guard guard;
|
|
|
|
ses.set_peer_class(pc, pci);
|
|
|
|
}
|
|
|
|
|
2015-11-08 19:08:03 +01:00
|
|
|
#ifndef TORRENT_DISABLE_DHT
|
|
|
|
void dht_get_mutable_item(lt::session& ses, std::string key, std::string salt)
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(key.size() == 32);
|
2016-05-01 05:10:47 +02:00
|
|
|
std::array<char, 32> public_key;
|
2015-11-08 19:08:03 +01:00
|
|
|
std::copy(key.begin(), key.end(), public_key.begin());
|
|
|
|
ses.dht_get_item(public_key, salt);
|
|
|
|
}
|
|
|
|
|
2016-11-27 14:46:53 +01:00
|
|
|
void put_string(entry& e, std::array<char, 64>& sig, std::int64_t& seq
|
2016-07-24 00:57:04 +02:00
|
|
|
, std::string const& salt, std::string pk, std::string sk
|
|
|
|
, std::string data)
|
2015-11-08 19:08:03 +01:00
|
|
|
{
|
2017-04-12 20:05:53 +02:00
|
|
|
using lt::dht::sign_mutable_item;
|
2015-11-08 19:08:03 +01:00
|
|
|
|
|
|
|
e = data;
|
|
|
|
std::vector<char> buf;
|
|
|
|
bencode(std::back_inserter(buf), e);
|
|
|
|
++seq;
|
2016-08-30 08:37:51 +02:00
|
|
|
dht::signature sign = sign_mutable_item(buf, salt
|
2016-07-24 00:57:04 +02:00
|
|
|
, dht::sequence_number(seq)
|
|
|
|
, dht::public_key(pk.data())
|
2016-08-30 08:37:51 +02:00
|
|
|
, dht::secret_key(sk.data()));
|
2016-07-24 00:57:04 +02:00
|
|
|
sig = sign.bytes;
|
2015-11-08 19:08:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void dht_put_mutable_item(lt::session& ses, std::string private_key, std::string public_key,
|
2016-07-24 00:57:04 +02:00
|
|
|
std::string data, std::string salt)
|
2015-11-08 19:08:03 +01:00
|
|
|
{
|
|
|
|
TORRENT_ASSERT(private_key.size() == 64);
|
|
|
|
TORRENT_ASSERT(public_key.size() == 32);
|
2016-05-01 05:10:47 +02:00
|
|
|
std::array<char, 32> key;
|
2015-11-08 19:08:03 +01:00
|
|
|
std::copy(public_key.begin(), public_key.end(), key.begin());
|
2016-11-27 14:46:53 +01:00
|
|
|
ses.dht_put_item(key, [&](entry& e, std::array<char, 64>& sig, std::int64_t& seq
|
2016-09-01 15:43:53 +02:00
|
|
|
, std::string const& salt) { put_string(e, sig, seq, salt
|
|
|
|
, public_key, private_key, data); }
|
2016-07-24 00:57:04 +02:00
|
|
|
, salt);
|
2015-11-08 19:08:03 +01:00
|
|
|
}
|
|
|
|
#endif
|
2016-02-16 20:20:04 +01:00
|
|
|
|
|
|
|
add_torrent_params read_resume_data_wrapper(bytes const& b)
|
|
|
|
{
|
|
|
|
error_code ec;
|
2017-03-29 22:10:32 +02:00
|
|
|
add_torrent_params p = read_resume_data(b.arr, ec);
|
2016-02-16 20:20:04 +01:00
|
|
|
#ifndef BOOST_NO_EXCEPTIONS
|
2016-05-15 06:33:06 +02:00
|
|
|
if (ec) throw system_error(ec);
|
2016-02-16 20:20:04 +01:00
|
|
|
#endif
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2017-09-03 16:24:16 +02:00
|
|
|
int find_metric_idx_wrap(char const* name)
|
|
|
|
{
|
|
|
|
return lt::find_metric_idx(name);
|
|
|
|
}
|
|
|
|
|
2018-04-14 16:47:49 +02:00
|
|
|
bytes write_resume_data_buf_(add_torrent_params const& atp)
|
|
|
|
{
|
|
|
|
bytes ret;
|
|
|
|
auto buf = write_resume_data_buf(atp);
|
|
|
|
ret.arr.resize(buf.size());
|
|
|
|
std::copy(buf.begin(), buf.end(), ret.arr.begin());
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-09-24 21:59:42 +02:00
|
|
|
} // anonymous namespace
|
2007-01-10 17:11:43 +01:00
|
|
|
|
2017-07-09 16:32:01 +02:00
|
|
|
struct dummy1 {};
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2017-07-09 16:32:01 +02:00
|
|
|
struct dummy2 {};
|
|
|
|
#endif
|
2017-07-27 22:26:12 +02:00
|
|
|
struct dummy9 {};
|
|
|
|
struct dummy10 {};
|
|
|
|
struct dummy11 {};
|
2009-05-31 22:46:40 +02:00
|
|
|
|
2007-01-10 17:11:43 +01:00
|
|
|
void bind_session()
|
|
|
|
{
|
2015-07-07 01:20:04 +02:00
|
|
|
#ifndef TORRENT_DISABLE_DHT
|
|
|
|
void (lt::session::*dht_get_immutable_item)(sha1_hash const&) = <::session::dht_get_item;
|
|
|
|
sha1_hash (lt::session::*dht_put_immutable_item)(entry data) = <::session::dht_put_item;
|
|
|
|
#endif // TORRENT_DISABLE_DHT
|
|
|
|
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2014-07-06 21:18:00 +02:00
|
|
|
#ifndef TORRENT_DISABLE_DHT
|
|
|
|
void (lt::session::*start_dht0)() = <::session::start_dht;
|
|
|
|
void (lt::session::*start_dht1)(entry const&) = <::session::start_dht;
|
2010-03-06 18:50:19 +01:00
|
|
|
#endif
|
|
|
|
|
2009-05-14 19:24:17 +02:00
|
|
|
class_<session_status>("session_status")
|
|
|
|
.def_readonly("has_incoming_connections", &session_status::has_incoming_connections)
|
2009-05-31 22:46:40 +02:00
|
|
|
|
2009-05-14 19:24:17 +02:00
|
|
|
.def_readonly("upload_rate", &session_status::upload_rate)
|
|
|
|
.def_readonly("download_rate", &session_status::download_rate)
|
|
|
|
.def_readonly("total_download", &session_status::total_download)
|
|
|
|
.def_readonly("total_upload", &session_status::total_upload)
|
2009-05-31 22:46:40 +02:00
|
|
|
|
|
|
|
.def_readonly("payload_upload_rate", &session_status::payload_upload_rate)
|
|
|
|
.def_readonly("payload_download_rate", &session_status::payload_download_rate)
|
2009-05-14 19:24:17 +02:00
|
|
|
.def_readonly("total_payload_download", &session_status::total_payload_download)
|
|
|
|
.def_readonly("total_payload_upload", &session_status::total_payload_upload)
|
2009-05-31 22:46:40 +02:00
|
|
|
|
|
|
|
.def_readonly("ip_overhead_upload_rate", &session_status::ip_overhead_upload_rate)
|
|
|
|
.def_readonly("ip_overhead_download_rate", &session_status::ip_overhead_download_rate)
|
|
|
|
.def_readonly("total_ip_overhead_download", &session_status::total_ip_overhead_download)
|
|
|
|
.def_readonly("total_ip_overhead_upload", &session_status::total_ip_overhead_upload)
|
2009-06-26 01:05:12 +02:00
|
|
|
|
2009-05-31 22:46:40 +02:00
|
|
|
.def_readonly("dht_upload_rate", &session_status::dht_upload_rate)
|
|
|
|
.def_readonly("dht_download_rate", &session_status::dht_download_rate)
|
|
|
|
.def_readonly("total_dht_download", &session_status::total_dht_download)
|
|
|
|
.def_readonly("total_dht_upload", &session_status::total_dht_upload)
|
2009-06-26 01:05:12 +02:00
|
|
|
|
2009-05-31 22:46:40 +02:00
|
|
|
.def_readonly("tracker_upload_rate", &session_status::tracker_upload_rate)
|
|
|
|
.def_readonly("tracker_download_rate", &session_status::tracker_download_rate)
|
|
|
|
.def_readonly("total_tracker_download", &session_status::total_tracker_download)
|
|
|
|
.def_readonly("total_tracker_upload", &session_status::total_tracker_upload)
|
2009-06-26 01:05:12 +02:00
|
|
|
|
2009-05-31 22:46:40 +02:00
|
|
|
.def_readonly("total_redundant_bytes", &session_status::total_redundant_bytes)
|
|
|
|
.def_readonly("total_failed_bytes", &session_status::total_failed_bytes)
|
2009-06-26 01:05:12 +02:00
|
|
|
|
2009-05-14 19:24:17 +02:00
|
|
|
.def_readonly("num_peers", &session_status::num_peers)
|
2009-05-31 22:46:40 +02:00
|
|
|
.def_readonly("num_unchoked", &session_status::num_unchoked)
|
|
|
|
.def_readonly("allowed_upload_slots", &session_status::allowed_upload_slots)
|
2009-06-26 01:05:12 +02:00
|
|
|
|
2009-05-31 22:46:40 +02:00
|
|
|
.def_readonly("up_bandwidth_queue", &session_status::up_bandwidth_queue)
|
|
|
|
.def_readonly("down_bandwidth_queue", &session_status::down_bandwidth_queue)
|
2009-06-26 01:05:12 +02:00
|
|
|
|
2009-05-31 22:46:40 +02:00
|
|
|
.def_readonly("up_bandwidth_bytes_queue", &session_status::up_bandwidth_bytes_queue)
|
|
|
|
.def_readonly("down_bandwidth_bytes_queue", &session_status::down_bandwidth_bytes_queue)
|
2009-06-26 01:05:12 +02:00
|
|
|
|
2009-05-31 22:46:40 +02:00
|
|
|
.def_readonly("optimistic_unchoke_counter", &session_status::optimistic_unchoke_counter)
|
|
|
|
.def_readonly("unchoke_counter", &session_status::unchoke_counter)
|
2009-06-26 01:05:12 +02:00
|
|
|
|
2007-01-10 17:11:43 +01:00
|
|
|
#ifndef TORRENT_DISABLE_DHT
|
2009-05-14 19:24:17 +02:00
|
|
|
.def_readonly("dht_nodes", &session_status::dht_nodes)
|
2009-11-11 06:28:28 +01:00
|
|
|
.def_readonly("dht_node_cache", &session_status::dht_node_cache)
|
2009-05-14 19:24:17 +02:00
|
|
|
.def_readonly("dht_torrents", &session_status::dht_torrents)
|
2009-05-31 22:46:40 +02:00
|
|
|
.def_readonly("dht_global_nodes", &session_status::dht_global_nodes)
|
|
|
|
.def_readonly("active_requests", &session_status::active_requests)
|
2013-05-03 10:24:26 +02:00
|
|
|
.def_readonly("dht_total_allocations", &session_status::dht_total_allocations)
|
2015-01-18 22:36:24 +01:00
|
|
|
#endif // TORRENT_DISABLE_DHT
|
2013-05-03 10:24:26 +02:00
|
|
|
.add_property("utp_stats", &get_utp_stats)
|
2007-01-10 17:11:43 +01:00
|
|
|
;
|
|
|
|
|
2011-04-28 11:24:42 +02:00
|
|
|
#ifndef TORRENT_DISABLE_DHT
|
2009-05-31 22:46:40 +02:00
|
|
|
class_<dht_lookup>("dht_lookup")
|
|
|
|
.def_readonly("type", &dht_lookup::type)
|
|
|
|
.def_readonly("outstanding_requests", &dht_lookup::outstanding_requests)
|
|
|
|
.def_readonly("timeouts", &dht_lookup::timeouts)
|
|
|
|
.def_readonly("response", &dht_lookup::responses)
|
|
|
|
.def_readonly("branch_factor", &dht_lookup::branch_factor)
|
|
|
|
;
|
2015-01-18 22:36:24 +01:00
|
|
|
#endif // TORRENT_DISABLE_DHT
|
2018-04-26 09:01:14 +02:00
|
|
|
#endif // TORRENT_ABI_VERSION
|
2009-06-26 01:05:12 +02:00
|
|
|
|
2016-04-13 02:10:09 +02:00
|
|
|
#define PROP(val) \
|
|
|
|
make_getter(val, return_value_policy<return_by_value>()), \
|
|
|
|
make_setter(val, return_value_policy<return_by_value>())
|
|
|
|
|
2016-04-12 07:33:01 +02:00
|
|
|
class_<add_torrent_params>("add_torrent_params")
|
|
|
|
.def_readwrite("version", &add_torrent_params::version)
|
|
|
|
.def_readwrite("ti", &add_torrent_params::ti)
|
2016-04-13 02:10:09 +02:00
|
|
|
.add_property("trackers", PROP(&add_torrent_params::trackers))
|
|
|
|
.add_property("tracker_tiers", PROP(&add_torrent_params::tracker_tiers))
|
|
|
|
.add_property("dht_nodes", PROP(&add_torrent_params::dht_nodes))
|
2016-04-12 07:33:01 +02:00
|
|
|
.def_readwrite("name", &add_torrent_params::name)
|
|
|
|
.def_readwrite("save_path", &add_torrent_params::save_path)
|
|
|
|
.def_readwrite("storage_mode", &add_torrent_params::storage_mode)
|
2016-04-13 02:10:09 +02:00
|
|
|
// .def_readwrite("storage", &add_torrent_params::storage)
|
|
|
|
.add_property("file_priorities", PROP(&add_torrent_params::file_priorities))
|
2016-04-12 07:33:01 +02:00
|
|
|
.def_readwrite("trackerid", &add_torrent_params::trackerid)
|
2017-09-12 00:22:55 +02:00
|
|
|
.add_property("flags", PROP(&add_torrent_params::flags))
|
2016-04-12 07:33:01 +02:00
|
|
|
.def_readwrite("info_hash", &add_torrent_params::info_hash)
|
|
|
|
.def_readwrite("max_uploads", &add_torrent_params::max_uploads)
|
|
|
|
.def_readwrite("max_connections", &add_torrent_params::max_connections)
|
|
|
|
.def_readwrite("upload_limit", &add_torrent_params::upload_limit)
|
|
|
|
.def_readwrite("download_limit", &add_torrent_params::download_limit)
|
|
|
|
.def_readwrite("total_uploaded", &add_torrent_params::total_uploaded)
|
|
|
|
.def_readwrite("total_downloaded", &add_torrent_params::total_downloaded)
|
|
|
|
.def_readwrite("active_time", &add_torrent_params::active_time)
|
|
|
|
.def_readwrite("finished_time", &add_torrent_params::finished_time)
|
|
|
|
.def_readwrite("seeding_time", &add_torrent_params::seeding_time)
|
|
|
|
.def_readwrite("added_time", &add_torrent_params::added_time)
|
|
|
|
.def_readwrite("completed_time", &add_torrent_params::completed_time)
|
|
|
|
.def_readwrite("last_seen_complete", &add_torrent_params::last_seen_complete)
|
2018-04-28 03:25:36 +02:00
|
|
|
.def_readwrite("last_download", &add_torrent_params::last_download)
|
|
|
|
.def_readwrite("last_upload", &add_torrent_params::last_upload)
|
2016-04-12 07:33:01 +02:00
|
|
|
.def_readwrite("num_complete", &add_torrent_params::num_complete)
|
|
|
|
.def_readwrite("num_incomplete", &add_torrent_params::num_incomplete)
|
|
|
|
.def_readwrite("num_downloaded", &add_torrent_params::num_downloaded)
|
2016-04-13 02:10:09 +02:00
|
|
|
.add_property("http_seeds", PROP(&add_torrent_params::http_seeds))
|
|
|
|
.add_property("url_seeds", PROP(&add_torrent_params::url_seeds))
|
|
|
|
.add_property("peers", PROP(&add_torrent_params::peers))
|
|
|
|
.add_property("banned_peers", PROP(&add_torrent_params::banned_peers))
|
|
|
|
.add_property("unfinished_pieces", PROP(&add_torrent_params::unfinished_pieces))
|
|
|
|
.add_property("have_pieces", PROP(&add_torrent_params::have_pieces))
|
|
|
|
.add_property("verified_pieces", PROP(&add_torrent_params::verified_pieces))
|
|
|
|
.add_property("piece_priorities", PROP(&add_torrent_params::piece_priorities))
|
|
|
|
.add_property("merkle_tree", PROP(&add_torrent_params::merkle_tree))
|
|
|
|
.add_property("renamed_files", PROP(&add_torrent_params::renamed_files))
|
2016-04-12 07:33:01 +02:00
|
|
|
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2017-03-29 08:16:07 +02:00
|
|
|
.def_readwrite("url", &add_torrent_params::url)
|
2016-04-12 07:33:01 +02:00
|
|
|
.def_readwrite("uuid", &add_torrent_params::uuid)
|
2018-01-21 00:48:45 +01:00
|
|
|
.add_property("resume_data", PROP(&add_torrent_params::resume_data))
|
2016-04-12 07:33:01 +02:00
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
2007-10-15 07:37:35 +02:00
|
|
|
enum_<storage_mode_t>("storage_mode_t")
|
|
|
|
.value("storage_mode_allocate", storage_mode_allocate)
|
|
|
|
.value("storage_mode_sparse", storage_mode_sparse)
|
|
|
|
;
|
|
|
|
|
2017-07-27 22:26:12 +02:00
|
|
|
{
|
|
|
|
scope s = class_<dummy11>("options_t");
|
|
|
|
s.attr("delete_files") = lt::session::delete_files;
|
|
|
|
}
|
2008-10-28 07:29:30 +01:00
|
|
|
|
2017-07-27 22:26:12 +02:00
|
|
|
{
|
|
|
|
scope s = class_<dummy10>("session_flags_t");
|
|
|
|
s.attr("add_default_plugins") = lt::session::add_default_plugins;
|
|
|
|
s.attr("start_default_features") = lt::session::start_default_features;
|
|
|
|
}
|
2017-07-09 16:32:01 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
scope s = class_<dummy1>("torrent_flags");
|
|
|
|
s.attr("seed_mode") = torrent_flags::seed_mode;
|
|
|
|
s.attr("upload_mode") = torrent_flags::upload_mode;
|
|
|
|
s.attr("share_mode") = torrent_flags::share_mode;
|
|
|
|
s.attr("apply_ip_filter") = torrent_flags::apply_ip_filter;
|
|
|
|
s.attr("paused") = torrent_flags::paused;
|
|
|
|
s.attr("auto_managed") = torrent_flags::auto_managed;
|
|
|
|
s.attr("duplicate_is_error") = torrent_flags::duplicate_is_error;
|
|
|
|
s.attr("update_subscribe") = torrent_flags::update_subscribe;
|
|
|
|
s.attr("super_seeding") = torrent_flags::super_seeding;
|
|
|
|
s.attr("sequential_download") = torrent_flags::sequential_download;
|
|
|
|
s.attr("stop_when_ready") = torrent_flags::stop_when_ready;
|
|
|
|
s.attr("override_trackers") = torrent_flags::override_trackers;
|
|
|
|
s.attr("override_web_seeds") = torrent_flags::override_web_seeds;
|
2018-09-25 06:15:12 +02:00
|
|
|
s.attr("default_flags") = torrent_flags::default_flags;
|
2017-07-09 16:32:01 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2017-07-09 16:32:01 +02:00
|
|
|
{
|
|
|
|
scope s = class_<dummy2>("add_torrent_params_flags_t");
|
|
|
|
s.attr("flag_seed_mode") = add_torrent_params::flag_seed_mode;
|
|
|
|
s.attr("flag_upload_mode") = add_torrent_params::flag_upload_mode;
|
|
|
|
s.attr("flag_share_mode") = add_torrent_params::flag_share_mode;
|
|
|
|
s.attr("flag_apply_ip_filter") = add_torrent_params::flag_apply_ip_filter;
|
|
|
|
s.attr("flag_paused") = add_torrent_params::flag_paused;
|
|
|
|
s.attr("flag_auto_managed") = add_torrent_params::flag_auto_managed;
|
|
|
|
s.attr("flag_duplicate_is_error") = add_torrent_params::flag_duplicate_is_error;
|
|
|
|
s.attr("flag_update_subscribe") = add_torrent_params::flag_update_subscribe;
|
|
|
|
s.attr("flag_super_seeding") = add_torrent_params::flag_super_seeding;
|
|
|
|
s.attr("flag_sequential_download") = add_torrent_params::flag_sequential_download;
|
|
|
|
s.attr("flag_stop_when_ready") = add_torrent_params::flag_stop_when_ready;
|
|
|
|
s.attr("flag_override_trackers") = add_torrent_params::flag_override_trackers;
|
|
|
|
s.attr("flag_override_web_seeds") = add_torrent_params::flag_override_web_seeds;
|
|
|
|
s.attr("flag_pinned") = add_torrent_params::flag_pinned;
|
|
|
|
s.attr("flag_override_resume_data") = add_torrent_params::flag_override_resume_data;
|
|
|
|
s.attr("flag_merge_resume_trackers") = add_torrent_params::flag_merge_resume_trackers;
|
|
|
|
s.attr("flag_use_resume_save_path") = add_torrent_params::flag_use_resume_save_path;
|
|
|
|
s.attr("flag_merge_resume_http_seeds") = add_torrent_params::flag_merge_resume_http_seeds;
|
2018-09-25 06:15:12 +02:00
|
|
|
s.attr("default_flags") = add_torrent_params::flag_default_flags;
|
2017-07-09 16:32:01 +02:00
|
|
|
}
|
2016-02-16 20:20:04 +01:00
|
|
|
#endif
|
2017-07-09 16:32:01 +02:00
|
|
|
|
2009-06-26 01:05:12 +02:00
|
|
|
class_<cache_status>("cache_status")
|
2016-11-23 00:38:45 +01:00
|
|
|
.add_property("pieces", cache_status_pieces)
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2009-06-26 01:05:12 +02:00
|
|
|
.def_readonly("blocks_written", &cache_status::blocks_written)
|
|
|
|
.def_readonly("writes", &cache_status::writes)
|
|
|
|
.def_readonly("blocks_read", &cache_status::blocks_read)
|
|
|
|
.def_readonly("blocks_read_hit", &cache_status::blocks_read_hit)
|
|
|
|
.def_readonly("reads", &cache_status::reads)
|
2013-05-05 20:08:03 +02:00
|
|
|
.def_readonly("queued_bytes", &cache_status::queued_bytes)
|
2009-06-26 01:05:12 +02:00
|
|
|
.def_readonly("cache_size", &cache_status::cache_size)
|
2014-07-06 21:18:00 +02:00
|
|
|
.def_readonly("write_cache_size", &cache_status::write_cache_size)
|
2009-06-26 01:05:12 +02:00
|
|
|
.def_readonly("read_cache_size", &cache_status::read_cache_size)
|
2014-07-06 21:18:00 +02:00
|
|
|
.def_readonly("pinned_blocks", &cache_status::pinned_blocks)
|
2009-06-26 01:05:12 +02:00
|
|
|
.def_readonly("total_used_buffers", &cache_status::total_used_buffers)
|
2013-05-05 20:08:03 +02:00
|
|
|
.def_readonly("average_read_time", &cache_status::average_read_time)
|
|
|
|
.def_readonly("average_write_time", &cache_status::average_write_time)
|
|
|
|
.def_readonly("average_hash_time", &cache_status::average_hash_time)
|
|
|
|
.def_readonly("average_job_time", &cache_status::average_job_time)
|
|
|
|
.def_readonly("cumulative_job_time", &cache_status::cumulative_job_time)
|
|
|
|
.def_readonly("cumulative_read_time", &cache_status::cumulative_read_time)
|
|
|
|
.def_readonly("cumulative_write_time", &cache_status::cumulative_write_time)
|
|
|
|
.def_readonly("cumulative_hash_time", &cache_status::cumulative_hash_time)
|
|
|
|
.def_readonly("total_read_back", &cache_status::total_read_back)
|
|
|
|
.def_readonly("read_queue_size", &cache_status::read_queue_size)
|
2014-07-06 21:18:00 +02:00
|
|
|
.def_readonly("blocked_jobs", &cache_status::blocked_jobs)
|
|
|
|
.def_readonly("queued_jobs", &cache_status::queued_jobs)
|
|
|
|
.def_readonly("peak_queued", &cache_status::peak_queued)
|
|
|
|
.def_readonly("pending_jobs", &cache_status::pending_jobs)
|
|
|
|
.def_readonly("num_jobs", &cache_status::num_jobs)
|
|
|
|
.def_readonly("num_read_jobs", &cache_status::num_read_jobs)
|
|
|
|
.def_readonly("num_write_jobs", &cache_status::num_write_jobs)
|
|
|
|
.def_readonly("arc_mru_size", &cache_status::arc_mru_size)
|
|
|
|
.def_readonly("arc_mru_ghost_size", &cache_status::arc_mru_ghost_size)
|
|
|
|
.def_readonly("arc_mfu_size", &cache_status::arc_mfu_size)
|
|
|
|
.def_readonly("arc_mfu_ghost_size", &cache_status::arc_mfu_ghost_size)
|
2015-01-02 12:48:04 +01:00
|
|
|
#endif
|
2009-06-26 01:05:12 +02:00
|
|
|
;
|
|
|
|
|
2017-08-30 20:47:49 +02:00
|
|
|
enum_<lt::portmap_protocol>("portmap_protocol")
|
|
|
|
.value("none", lt::portmap_protocol::none)
|
|
|
|
.value("udp", lt::portmap_protocol::udp)
|
|
|
|
.value("tcp", lt::portmap_protocol::tcp)
|
|
|
|
;
|
|
|
|
|
|
|
|
enum_<lt::portmap_transport>("portmap_transport")
|
|
|
|
.value("natpmp", lt::portmap_transport::natpmp)
|
|
|
|
.value("upnp", lt::portmap_transport::upnp)
|
|
|
|
;
|
|
|
|
|
2017-10-04 13:45:11 +02:00
|
|
|
enum_<lt::peer_class_type_filter::socket_type_t>("peer_class_type_filter_socket_type_t")
|
|
|
|
.value("tcp_socket", peer_class_type_filter::tcp_socket)
|
|
|
|
.value("utp_socket", peer_class_type_filter::utp_socket)
|
|
|
|
.value("ssl_tcp_socket", peer_class_type_filter::ssl_tcp_socket)
|
|
|
|
.value("ssl_utp_socket", peer_class_type_filter::ssl_utp_socket)
|
|
|
|
.value("i2p_socket", peer_class_type_filter::i2p_socket)
|
|
|
|
;
|
|
|
|
|
|
|
|
{
|
|
|
|
scope s = class_<lt::peer_class_type_filter>("peer_class_type_filter")
|
2017-09-24 21:59:42 +02:00
|
|
|
.def(init<>())
|
|
|
|
.def("add", <::peer_class_type_filter::add)
|
|
|
|
.def("remove", <::peer_class_type_filter::remove)
|
|
|
|
.def("disallow", <::peer_class_type_filter::disallow)
|
|
|
|
.def("allow", <::peer_class_type_filter::allow)
|
|
|
|
.def("apply", <::peer_class_type_filter::apply)
|
|
|
|
;
|
2017-10-04 13:45:11 +02:00
|
|
|
s.attr("tcp_socket") = peer_class_type_filter::tcp_socket;
|
|
|
|
s.attr("utp_socket") = peer_class_type_filter::utp_socket;
|
|
|
|
s.attr("ssl_tcp_socket") = peer_class_type_filter::ssl_tcp_socket;
|
|
|
|
s.attr("ssl_utp_socket") = peer_class_type_filter::ssl_utp_socket;
|
|
|
|
s.attr("i2p_socket") = peer_class_type_filter::i2p_socket;
|
|
|
|
}
|
2017-09-24 21:59:42 +02:00
|
|
|
|
2017-08-30 20:47:49 +02:00
|
|
|
{
|
|
|
|
scope s = class_<lt::session, boost::noncopyable>("session", no_init)
|
2016-01-05 07:32:04 +01:00
|
|
|
.def("__init__", boost::python::make_constructor(&make_session
|
|
|
|
, default_call_policies()
|
|
|
|
, (arg("settings")
|
|
|
|
, arg("flags")=lt::session::start_default_features
|
|
|
|
| lt::session::add_default_plugins))
|
2014-07-06 21:18:00 +02:00
|
|
|
)
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2007-01-10 17:11:43 +01:00
|
|
|
.def(
|
2017-07-27 22:26:12 +02:00
|
|
|
init<fingerprint, session_flags_t, alert_category_t>((
|
2008-10-01 04:07:55 +02:00
|
|
|
arg("fingerprint")=fingerprint("LT",0,1,0,0)
|
2014-07-06 21:18:00 +02:00
|
|
|
, arg("flags")=lt::session::start_default_features | lt::session::add_default_plugins
|
2017-07-27 22:26:12 +02:00
|
|
|
, arg("alert_mask")=alert::error_notification))
|
2007-01-10 17:11:43 +01:00
|
|
|
)
|
2016-10-30 03:56:46 +01:00
|
|
|
.def("outgoing_ports", &outgoing_ports)
|
2015-06-08 23:56:18 +02:00
|
|
|
#endif
|
2016-07-17 04:23:23 +02:00
|
|
|
.def("post_torrent_updates", allow_threads(<::session::post_torrent_updates), arg("flags") = 0xffffffff)
|
2018-03-17 12:35:36 +01:00
|
|
|
.def("post_dht_stats", allow_threads(<::session::post_dht_stats))
|
2016-01-12 07:52:10 +01:00
|
|
|
.def("post_session_stats", allow_threads(<::session::post_session_stats))
|
2014-07-06 21:18:00 +02:00
|
|
|
.def("is_listening", allow_threads(<::session::is_listening))
|
|
|
|
.def("listen_port", allow_threads(<::session::listen_port))
|
2008-03-10 04:19:57 +01:00
|
|
|
#ifndef TORRENT_DISABLE_DHT
|
2015-07-06 19:14:28 +02:00
|
|
|
.def("add_dht_node", &add_dht_node)
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2008-02-17 22:12:06 +01:00
|
|
|
.def(
|
|
|
|
"add_dht_router", &add_dht_router
|
|
|
|
, (arg("router"), "port")
|
|
|
|
)
|
2018-04-26 09:01:14 +02:00
|
|
|
#endif // TORRENT_ABI_VERSION
|
2014-07-06 21:18:00 +02:00
|
|
|
.def("is_dht_running", allow_threads(<::session::is_dht_running))
|
|
|
|
.def("set_dht_settings", allow_threads(<::session::set_dht_settings))
|
2015-05-30 19:41:38 +02:00
|
|
|
.def("get_dht_settings", allow_threads(<::session::get_dht_settings))
|
2015-07-07 01:20:04 +02:00
|
|
|
.def("dht_get_immutable_item", allow_threads(dht_get_immutable_item))
|
2015-11-08 19:08:03 +01:00
|
|
|
.def("dht_get_mutable_item", &dht_get_mutable_item)
|
2015-07-07 01:20:04 +02:00
|
|
|
.def("dht_put_immutable_item", allow_threads(dht_put_immutable_item))
|
2015-11-08 19:08:03 +01:00
|
|
|
.def("dht_put_mutable_item", &dht_put_mutable_item)
|
2015-07-06 19:14:28 +02:00
|
|
|
.def("dht_get_peers", allow_threads(<::session::dht_get_peers))
|
|
|
|
.def("dht_announce", allow_threads(<::session::dht_announce))
|
|
|
|
#endif // TORRENT_DISABLE_DHT
|
2009-05-14 19:24:17 +02:00
|
|
|
.def("add_torrent", &add_torrent)
|
2012-10-19 07:18:48 +02:00
|
|
|
.def("async_add_torrent", &async_add_torrent)
|
2016-04-12 07:33:01 +02:00
|
|
|
.def("async_add_torrent", <::session::async_add_torrent)
|
|
|
|
.def("add_torrent", allow_threads((lt::torrent_handle (session_handle::*)(add_torrent_params const&))<::session::add_torrent))
|
2010-08-22 18:45:12 +02:00
|
|
|
#ifndef BOOST_NO_EXCEPTIONS
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2008-10-28 03:34:14 +01:00
|
|
|
.def(
|
|
|
|
"add_torrent", &add_torrent_depr
|
2008-10-28 07:29:30 +01:00
|
|
|
, (
|
2009-05-14 19:24:17 +02:00
|
|
|
arg("resume_data") = entry(),
|
2010-03-06 18:50:19 +01:00
|
|
|
arg("storage_mode") = storage_mode_sparse,
|
2008-10-28 07:29:30 +01:00
|
|
|
arg("paused") = false
|
|
|
|
)
|
2008-10-28 03:34:14 +01:00
|
|
|
)
|
2018-04-26 09:01:14 +02:00
|
|
|
#endif // TORRENT_ABI_VERSION
|
2015-01-04 22:31:02 +01:00
|
|
|
#endif // BOOST_NO_EXCEPTIONS
|
2014-07-06 21:18:00 +02:00
|
|
|
.def("remove_torrent", allow_threads(<::session::remove_torrent), arg("option") = 0)
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2015-01-04 22:31:02 +01:00
|
|
|
.def("status", allow_threads(<::session::status))
|
2010-12-26 09:03:02 +01:00
|
|
|
#endif
|
2016-04-04 06:52:21 +02:00
|
|
|
.def("get_settings", &session_get_settings)
|
|
|
|
.def("apply_settings", &session_apply_settings)
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2008-03-10 04:19:57 +01:00
|
|
|
#ifndef TORRENT_DISABLE_ENCRYPTION
|
2014-07-06 21:18:00 +02:00
|
|
|
.def("set_pe_settings", allow_threads(<::session::set_pe_settings))
|
|
|
|
.def("get_pe_settings", allow_threads(<::session::get_pe_settings))
|
2008-03-10 04:19:57 +01:00
|
|
|
#endif
|
2008-04-05 06:53:22 +02:00
|
|
|
#endif
|
2016-03-05 21:15:22 +01:00
|
|
|
.def("load_state", &load_state, (arg("entry"), arg("flags") = 0xffffffff))
|
2010-03-06 18:50:19 +01:00
|
|
|
.def("save_state", &save_state, (arg("entry"), arg("flags") = 0xffffffff))
|
2013-01-04 18:52:35 +01:00
|
|
|
.def("pop_alerts", &pop_alerts)
|
2016-07-04 05:30:52 +02:00
|
|
|
.def("wait_for_alert", &wait_for_alert, return_internal_reference<>())
|
2018-05-29 22:30:59 +02:00
|
|
|
.def("set_alert_notify", &set_alert_notify)
|
2012-09-19 08:13:04 +02:00
|
|
|
.def("add_extension", &add_extension)
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2013-05-03 10:24:26 +02:00
|
|
|
#if TORRENT_USE_I2P
|
2014-07-06 21:18:00 +02:00
|
|
|
.def("set_i2p_proxy", allow_threads(<::session::set_i2p_proxy))
|
|
|
|
.def("i2p_proxy", allow_threads(<::session::i2p_proxy))
|
2010-09-05 18:49:03 +02:00
|
|
|
#endif
|
2014-10-05 21:32:29 +02:00
|
|
|
#endif
|
2014-07-06 21:18:00 +02:00
|
|
|
.def("set_ip_filter", allow_threads(<::session::set_ip_filter))
|
|
|
|
.def("get_ip_filter", allow_threads(<::session::get_ip_filter))
|
|
|
|
.def("find_torrent", allow_threads(<::session::find_torrent))
|
|
|
|
.def("get_torrents", &get_torrents)
|
|
|
|
.def("pause", allow_threads(<::session::pause))
|
|
|
|
.def("resume", allow_threads(<::session::resume))
|
|
|
|
.def("is_paused", allow_threads(<::session::is_paused))
|
|
|
|
.def("get_cache_info", &get_cache_info1, (arg("handle") = torrent_handle(), arg("flags") = 0))
|
2015-09-02 07:30:40 +02:00
|
|
|
.def("add_port_mapping", allow_threads(<::session::add_port_mapping))
|
|
|
|
.def("delete_port_mapping", allow_threads(<::session::delete_port_mapping))
|
2017-10-28 12:15:35 +02:00
|
|
|
.def("reopen_network_sockets", allow_threads(<::session::reopen_network_sockets))
|
2017-09-24 21:59:42 +02:00
|
|
|
.def("set_peer_class_filter", <::session::set_peer_class_filter)
|
|
|
|
.def("set_peer_class_type_filter", <::session::set_peer_class_type_filter)
|
|
|
|
.def("create_peer_class", <::session::create_peer_class)
|
|
|
|
.def("delete_peer_class", <::session::delete_peer_class)
|
|
|
|
.def("get_peer_class", &get_peer_class)
|
|
|
|
.def("set_peer_class", &set_peer_class)
|
2014-10-05 21:32:29 +02:00
|
|
|
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2018-01-21 20:59:08 +01:00
|
|
|
.def("id", allow_threads(<::session::id))
|
2014-10-05 21:32:29 +02:00
|
|
|
.def(
|
|
|
|
"listen_on", &listen_on
|
2016-07-10 04:36:14 +02:00
|
|
|
, (arg("min"), "max", arg("interface") = (char const*)nullptr, arg("flags") = 0)
|
2014-10-05 21:32:29 +02:00
|
|
|
)
|
|
|
|
#ifndef TORRENT_DISABLE_DHT
|
|
|
|
.def("start_dht", allow_threads(start_dht0))
|
|
|
|
.def("stop_dht", allow_threads(<::session::stop_dht))
|
|
|
|
.def("start_dht", allow_threads(start_dht1))
|
|
|
|
.def("dht_state", allow_threads(<::session::dht_state))
|
|
|
|
.def("set_dht_proxy", allow_threads(<::session::set_dht_proxy))
|
|
|
|
.def("dht_proxy", allow_threads(<::session::dht_proxy))
|
|
|
|
#endif
|
|
|
|
.def("set_local_download_rate_limit", allow_threads(<::session::set_local_download_rate_limit))
|
|
|
|
.def("local_download_rate_limit", allow_threads(<::session::local_download_rate_limit))
|
|
|
|
.def("set_local_upload_rate_limit", allow_threads(<::session::set_local_upload_rate_limit))
|
|
|
|
.def("local_upload_rate_limit", allow_threads(<::session::local_upload_rate_limit))
|
|
|
|
.def("set_download_rate_limit", allow_threads(<::session::set_download_rate_limit))
|
|
|
|
.def("download_rate_limit", allow_threads(<::session::download_rate_limit))
|
|
|
|
.def("set_upload_rate_limit", allow_threads(<::session::set_upload_rate_limit))
|
|
|
|
.def("upload_rate_limit", allow_threads(<::session::upload_rate_limit))
|
|
|
|
.def("set_max_uploads", allow_threads(<::session::set_max_uploads))
|
|
|
|
.def("set_max_connections", allow_threads(<::session::set_max_connections))
|
|
|
|
.def("max_connections", allow_threads(<::session::max_connections))
|
|
|
|
.def("num_connections", allow_threads(<::session::num_connections))
|
|
|
|
.def("set_max_half_open_connections", allow_threads(<::session::set_max_half_open_connections))
|
|
|
|
.def("set_severity_level", allow_threads(<::session::set_severity_level))
|
|
|
|
.def("set_alert_queue_size_limit", allow_threads(<::session::set_alert_queue_size_limit))
|
|
|
|
.def("set_alert_mask", allow_threads(<::session::set_alert_mask))
|
|
|
|
.def("set_peer_proxy", allow_threads(<::session::set_peer_proxy))
|
|
|
|
.def("set_tracker_proxy", allow_threads(<::session::set_tracker_proxy))
|
|
|
|
.def("set_web_seed_proxy", allow_threads(<::session::set_web_seed_proxy))
|
|
|
|
.def("peer_proxy", allow_threads(<::session::peer_proxy))
|
|
|
|
.def("tracker_proxy", allow_threads(<::session::tracker_proxy))
|
|
|
|
.def("web_seed_proxy", allow_threads(<::session::web_seed_proxy))
|
|
|
|
.def("set_proxy", allow_threads(<::session::set_proxy))
|
|
|
|
.def("proxy", allow_threads(<::session::proxy))
|
2009-05-14 19:24:17 +02:00
|
|
|
.def("start_upnp", &start_upnp)
|
2014-07-06 21:18:00 +02:00
|
|
|
.def("stop_upnp", allow_threads(<::session::stop_upnp))
|
|
|
|
.def("start_lsd", allow_threads(<::session::start_lsd))
|
|
|
|
.def("stop_lsd", allow_threads(<::session::stop_lsd))
|
2009-05-14 19:24:17 +02:00
|
|
|
.def("start_natpmp", &start_natpmp)
|
2014-07-06 21:18:00 +02:00
|
|
|
.def("stop_natpmp", allow_threads(<::session::stop_natpmp))
|
|
|
|
.def("get_cache_status", &get_cache_status)
|
|
|
|
.def("get_cache_info", &get_cache_info2)
|
|
|
|
.def("set_peer_id", allow_threads(<::session::set_peer_id))
|
2018-04-26 09:01:14 +02:00
|
|
|
#endif // TORRENT_ABI_VERSION
|
2007-01-10 17:11:43 +01:00
|
|
|
;
|
|
|
|
|
2017-08-30 20:47:49 +02:00
|
|
|
s.attr("tcp") = lt::portmap_protocol::tcp;
|
|
|
|
s.attr("udp") = lt::portmap_protocol::udp;
|
2017-10-04 11:43:01 +02:00
|
|
|
|
|
|
|
s.attr("global_peer_class_id") = session::global_peer_class_id;
|
|
|
|
s.attr("tcp_peer_class_id") = session::tcp_peer_class_id;
|
|
|
|
s.attr("local_peer_class_id") = session::local_peer_class_id;
|
2017-10-28 12:15:35 +02:00
|
|
|
|
|
|
|
s.attr("reopen_map_ports") = lt::session::reopen_map_ports;
|
2017-08-30 20:47:49 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2017-08-30 20:47:49 +02:00
|
|
|
{
|
|
|
|
scope s = class_<dummy>("protocol_type");
|
|
|
|
s.attr("udp") = lt::portmap_protocol::udp;
|
|
|
|
s.attr("tcp") = lt::portmap_protocol::tcp;
|
|
|
|
}
|
|
|
|
#endif
|
2015-06-17 23:40:38 +02:00
|
|
|
|
2017-07-27 22:26:12 +02:00
|
|
|
{
|
|
|
|
scope s = class_<dummy9>("save_state_flags_t");
|
|
|
|
s.attr("save_settings") = lt::session::save_settings;
|
|
|
|
s.attr("save_dht_settings") = lt::session::save_dht_settings;
|
|
|
|
s.attr("save_dht_state") = lt::session::save_dht_state;
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2017-12-27 22:16:14 +01:00
|
|
|
s.attr("save_encryption_settings") = lt::session:: save_encryption_settings;
|
2017-07-27 22:26:12 +02:00
|
|
|
s.attr("save_as_map") = lt::session::save_as_map;
|
|
|
|
s.attr("save_i2p_proxy") = lt::session::save_i2p_proxy;
|
|
|
|
s.attr("save_proxy") = lt::session::save_proxy;
|
|
|
|
s.attr("save_dht_proxy") = lt::session::save_dht_proxy;
|
|
|
|
s.attr("save_peer_proxy") = lt::session::save_peer_proxy;
|
|
|
|
s.attr("save_web_proxy") = lt::session::save_web_proxy;
|
|
|
|
s.attr("save_tracker_proxy") = lt::session::save_tracker_proxy;
|
2011-01-23 19:41:15 +01:00
|
|
|
#endif
|
2017-07-27 22:26:12 +02:00
|
|
|
}
|
2010-03-06 18:50:19 +01:00
|
|
|
|
2018-04-26 09:01:14 +02:00
|
|
|
#if TORRENT_ABI_VERSION == 1
|
2014-07-06 21:18:00 +02:00
|
|
|
enum_<lt::session::listen_on_flags_t>("listen_on_flags_t")
|
|
|
|
.value("listen_reuse_address", lt::session::listen_reuse_address)
|
|
|
|
.value("listen_no_system_port", lt::session::listen_no_system_port)
|
2011-08-14 01:30:11 +02:00
|
|
|
;
|
2015-04-03 22:15:48 +02:00
|
|
|
#endif
|
2011-01-18 04:41:54 +01:00
|
|
|
|
2017-01-24 02:33:52 +01:00
|
|
|
def("high_performance_seed", high_performance_seed_wrapper);
|
|
|
|
def("min_memory_usage", min_memory_usage_wrapper);
|
2017-02-05 09:13:26 +01:00
|
|
|
def("default_settings", default_settings_wrapper);
|
2016-02-16 20:20:04 +01:00
|
|
|
def("read_resume_data", read_resume_data_wrapper);
|
2017-09-12 00:22:55 +02:00
|
|
|
def("write_resume_data", write_resume_data);
|
2018-04-14 16:47:49 +02:00
|
|
|
def("write_resume_data_buf", write_resume_data_buf_);
|
2014-07-06 21:18:00 +02:00
|
|
|
|
2016-12-23 03:43:05 +01:00
|
|
|
class_<stats_metric>("stats_metric")
|
|
|
|
.def_readonly("name", &stats_metric::name)
|
|
|
|
.def_readonly("value_index", &stats_metric::value_index)
|
|
|
|
.def_readonly("type", &stats_metric::type)
|
|
|
|
;
|
|
|
|
|
2018-07-30 01:10:52 +02:00
|
|
|
enum_<metric_type_t>("metric_type_t")
|
|
|
|
.value("counter", metric_type_t::counter)
|
|
|
|
.value("gauge", metric_type_t::gauge)
|
2018-07-28 20:32:11 +02:00
|
|
|
;
|
|
|
|
|
2016-12-23 03:43:05 +01:00
|
|
|
def("session_stats_metrics", session_stats_metrics);
|
2017-09-03 16:24:16 +02:00
|
|
|
def("find_metric_idx", find_metric_idx_wrap);
|
2016-12-23 03:43:05 +01:00
|
|
|
|
2013-08-27 18:04:19 +02:00
|
|
|
scope().attr("create_ut_metadata_plugin") = "ut_metadata";
|
|
|
|
scope().attr("create_ut_pex_plugin") = "ut_pex";
|
|
|
|
scope().attr("create_smart_ban_plugin") = "smart_ban";
|
2007-01-10 17:11:43 +01:00
|
|
|
}
|
2014-07-06 21:18:00 +02:00
|
|
|
|
2016-06-19 01:24:27 +02:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|