forked from premiere/premiere-libtorrent
merge RC_1_1 into master
This commit is contained in:
commit
5971818969
|
@ -26,6 +26,7 @@
|
||||||
*.exe
|
*.exe
|
||||||
*.out
|
*.out
|
||||||
*.app
|
*.app
|
||||||
|
libtool
|
||||||
|
|
||||||
*.m4
|
*.m4
|
||||||
*.in
|
*.in
|
||||||
|
@ -60,3 +61,8 @@ bindings/python/*flags
|
||||||
# Logs
|
# Logs
|
||||||
libtorrent_logs*
|
libtorrent_logs*
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
|
# Python related files and dirs
|
||||||
|
*.pyc
|
||||||
|
dist
|
||||||
|
*.egg-info
|
||||||
|
|
|
@ -55,6 +55,8 @@
|
||||||
* resume data no longer has timestamps of files
|
* resume data no longer has timestamps of files
|
||||||
* require C++11 to build libtorrent
|
* require C++11 to build libtorrent
|
||||||
|
|
||||||
|
* add web_seed_name_lookup_retry to session_settings
|
||||||
|
* slightly improve proxy settings backwards compatibility
|
||||||
* add function to get default settings
|
* add function to get default settings
|
||||||
* updating super seeding would include the torrent in state_update_alert
|
* updating super seeding would include the torrent in state_update_alert
|
||||||
* fix issue where num_seeds could be greater than num_peers in torrent_status
|
* fix issue where num_seeds could be greater than num_peers in torrent_status
|
||||||
|
|
|
@ -58,17 +58,29 @@ struct time_duration_to_python
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename Tag> struct tag {};
|
||||||
|
|
||||||
|
lt::time_point now(tag<lt::time_point>)
|
||||||
|
{ return lt::clock_type::now(); }
|
||||||
|
|
||||||
|
lt::time_point32 now(tag<lt::time_point32>)
|
||||||
|
{ return lt::time_point_cast<lt::seconds32>(lt::clock_type::now()); }
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
struct time_point_to_python
|
struct time_point_to_python
|
||||||
{
|
{
|
||||||
static PyObject* convert(lt::time_point const pt)
|
static PyObject* convert(T const pt)
|
||||||
{
|
{
|
||||||
using std::chrono::system_clock;
|
using std::chrono::system_clock;
|
||||||
using std::chrono::duration_cast;
|
using std::chrono::duration_cast;
|
||||||
|
object result;
|
||||||
|
if (pt > T())
|
||||||
|
{
|
||||||
time_t const tm = system_clock::to_time_t(system_clock::now()
|
time_t const tm = system_clock::to_time_t(system_clock::now()
|
||||||
+ duration_cast<system_clock::duration>(pt - lt::clock_type::now()));
|
+ duration_cast<system_clock::duration>(pt - now(tag<T>())));
|
||||||
|
|
||||||
std::tm* date = std::localtime(&tm);
|
std::tm* date = std::localtime(&tm);
|
||||||
object result = datetime_datetime(
|
result = datetime_datetime(
|
||||||
(int)1900 + date->tm_year
|
(int)1900 + date->tm_year
|
||||||
// tm use 0-11 and we need 1-12
|
// tm use 0-11 and we need 1-12
|
||||||
, (int)date->tm_mon + 1
|
, (int)date->tm_mon + 1
|
||||||
|
@ -77,6 +89,11 @@ struct time_point_to_python
|
||||||
, date->tm_min
|
, date->tm_min
|
||||||
, date->tm_sec
|
, date->tm_sec
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = object();
|
||||||
|
}
|
||||||
return incref(result.ptr());
|
return incref(result.ptr());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -115,11 +132,17 @@ void bind_datetime()
|
||||||
, ptime_to_python>();
|
, ptime_to_python>();
|
||||||
|
|
||||||
to_python_converter<lt::time_point
|
to_python_converter<lt::time_point
|
||||||
, time_point_to_python>();
|
, time_point_to_python<lt::time_point>>();
|
||||||
|
|
||||||
|
to_python_converter<lt::time_point32
|
||||||
|
, time_point_to_python<lt::time_point32>>();
|
||||||
|
|
||||||
to_python_converter<lt::time_duration
|
to_python_converter<lt::time_duration
|
||||||
, chrono_duration_to_python<lt::time_duration>>();
|
, chrono_duration_to_python<lt::time_duration>>();
|
||||||
|
|
||||||
|
to_python_converter<lt::seconds32
|
||||||
|
, chrono_duration_to_python<lt::seconds32>>();
|
||||||
|
|
||||||
to_python_converter<std::chrono::seconds
|
to_python_converter<std::chrono::seconds
|
||||||
, chrono_duration_to_python<std::chrono::seconds>>();
|
, chrono_duration_to_python<std::chrono::seconds>>();
|
||||||
|
|
||||||
|
|
|
@ -197,14 +197,6 @@ void dict_to_announce_entry(dict d, announce_entry& ae)
|
||||||
ae.tier = extract<int>(d["tier"]);
|
ae.tier = extract<int>(d["tier"]);
|
||||||
if (d.has_key("fail_limit"))
|
if (d.has_key("fail_limit"))
|
||||||
ae.fail_limit = extract<int>(d["fail_limit"]);
|
ae.fail_limit = extract<int>(d["fail_limit"]);
|
||||||
if (d.has_key("source"))
|
|
||||||
ae.source = extract<int>(d["source"]);
|
|
||||||
if (d.has_key("verified"))
|
|
||||||
ae.verified = extract<bool>(d["verified"]);
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
if (d.has_key("send_stats"))
|
|
||||||
ae.send_stats = extract<bool>(d["send_stats"]);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void replace_trackers(torrent_handle& h, object trackers)
|
void replace_trackers(torrent_handle& h, object trackers)
|
||||||
|
@ -253,6 +245,14 @@ list trackers(torrent_handle& h)
|
||||||
{
|
{
|
||||||
dict d;
|
dict d;
|
||||||
d["url"] = i->url;
|
d["url"] = i->url;
|
||||||
|
d["trackerid"] = i->trackerid;
|
||||||
|
d["message"] = i->message;
|
||||||
|
d["last_error"] = i->last_error;
|
||||||
|
d["next_announce"] = i->next_announce;
|
||||||
|
d["min_announce"] = i->min_announce;
|
||||||
|
d["scrape_incomplete"] = i->scrape_incomplete;
|
||||||
|
d["scrape_complete"] = i->scrape_complete;
|
||||||
|
d["scrape_downloaded"] = i->scrape_downloaded;
|
||||||
d["tier"] = i->tier;
|
d["tier"] = i->tier;
|
||||||
d["fail_limit"] = i->fail_limit;
|
d["fail_limit"] = i->fail_limit;
|
||||||
d["fails"] = i->fails;
|
d["fails"] = i->fails;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
namespace lt = libtorrent;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -124,16 +125,21 @@ namespace
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_tier(announce_entry const& ae) { return ae.tier; }
|
// Create getters for announce_entry data members with non-trivial types which need converting.
|
||||||
void set_tier(announce_entry& ae, int v) { ae.tier = v; }
|
lt::time_point get_next_announce(announce_entry const& ae) { return ae.next_announce; }
|
||||||
int get_fail_limit(announce_entry const& ae) { return ae.fail_limit; }
|
lt::time_point get_min_announce(announce_entry const& ae) { return ae.min_announce; }
|
||||||
void set_fail_limit(announce_entry& ae, int l) { ae.fail_limit = l; }
|
// announce_entry data member bit-fields.
|
||||||
int get_fails(announce_entry const& ae) { return ae.fails; }
|
int get_fails(announce_entry const& ae) { return ae.fails; }
|
||||||
int get_source(announce_entry const& ae) { return ae.source; }
|
int get_source(announce_entry const& ae) { return ae.source; }
|
||||||
bool get_verified(announce_entry const& ae) { return ae.verified; }
|
bool get_verified(announce_entry const& ae) { return ae.verified; }
|
||||||
bool get_updating(announce_entry const& ae) { return ae.updating; }
|
bool get_updating(announce_entry const& ae) { return ae.updating; }
|
||||||
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; }
|
||||||
|
// announce_entry method requires lt::time_point.
|
||||||
|
bool can_announce(announce_entry const& ae, bool is_seed) {
|
||||||
|
lt::time_point now = lt::clock_type::now();
|
||||||
|
return ae.can_announce(now, is_seed);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef 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; }
|
||||||
|
@ -306,8 +312,16 @@ void bind_torrent_info()
|
||||||
|
|
||||||
class_<announce_entry>("announce_entry", init<std::string const&>())
|
class_<announce_entry>("announce_entry", init<std::string const&>())
|
||||||
.def_readwrite("url", &announce_entry::url)
|
.def_readwrite("url", &announce_entry::url)
|
||||||
.add_property("tier", &get_tier, &set_tier)
|
.def_readonly("trackerid", &announce_entry::trackerid)
|
||||||
.add_property("fail_limit", &get_fail_limit, &set_fail_limit)
|
.def_readonly("message", &announce_entry::message)
|
||||||
|
.def_readonly("last_error", &announce_entry::last_error)
|
||||||
|
.add_property("next_announce", &get_next_announce)
|
||||||
|
.add_property("min_announce", &get_min_announce)
|
||||||
|
.def_readonly("scrape_incomplete", &announce_entry::scrape_incomplete)
|
||||||
|
.def_readonly("scrape_complete", &announce_entry::scrape_complete)
|
||||||
|
.def_readonly("scrape_downloaded", &announce_entry::scrape_downloaded)
|
||||||
|
.def_readwrite("tier", &announce_entry::tier)
|
||||||
|
.def_readwrite("fail_limit", &announce_entry::fail_limit)
|
||||||
.add_property("fails", &get_fails)
|
.add_property("fails", &get_fails)
|
||||||
.add_property("source", &get_source)
|
.add_property("source", &get_source)
|
||||||
.add_property("verified", &get_verified)
|
.add_property("verified", &get_verified)
|
||||||
|
@ -318,8 +332,10 @@ void bind_torrent_info()
|
||||||
.add_property("send_stats", &get_send_stats)
|
.add_property("send_stats", &get_send_stats)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
.def("next_announce_in", &announce_entry::next_announce_in)
|
||||||
|
.def("min_announce_in", &announce_entry::min_announce_in)
|
||||||
.def("reset", &announce_entry::reset)
|
.def("reset", &announce_entry::reset)
|
||||||
.def("can_announce", &announce_entry::can_announce)
|
.def("can_announce", can_announce)
|
||||||
.def("is_working", &announce_entry::is_working)
|
.def("is_working", &announce_entry::is_working)
|
||||||
.def("trim", &announce_entry::trim)
|
.def("trim", &announce_entry::trim)
|
||||||
;
|
;
|
||||||
|
|
|
@ -74,6 +74,20 @@ class test_torrent_handle(unittest.TestCase):
|
||||||
self.h.prioritize_pieces([(0, 1)])
|
self.h.prioritize_pieces([(0, 1)])
|
||||||
self.assertEqual(self.h.piece_priorities(), [1])
|
self.assertEqual(self.h.piece_priorities(), [1])
|
||||||
|
|
||||||
|
def test_replace_trackers(self):
|
||||||
|
self.setup()
|
||||||
|
trackers = []
|
||||||
|
for idx, tracker_url in enumerate(('udp://tracker1.com', 'udp://tracker2.com')):
|
||||||
|
tracker = lt.announce_entry(tracker_url)
|
||||||
|
tracker.tier = idx
|
||||||
|
tracker.fail_limit = 2
|
||||||
|
trackers.append(tracker)
|
||||||
|
self.h.replace_trackers(trackers)
|
||||||
|
new_trackers = self.h.trackers()
|
||||||
|
self.assertEqual(new_trackers[0]['url'], 'udp://tracker1.com')
|
||||||
|
self.assertEqual(new_trackers[1]['tier'], 1)
|
||||||
|
self.assertEqual(new_trackers[1]['fail_limit'], 2)
|
||||||
|
|
||||||
def test_file_status(self):
|
def test_file_status(self):
|
||||||
self.setup()
|
self.setup()
|
||||||
l = self.h.file_status()
|
l = self.h.file_status()
|
||||||
|
@ -238,6 +252,12 @@ class test_torrent_info(unittest.TestCase):
|
||||||
idx += 1
|
idx += 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_announce_entry(self):
|
||||||
|
ae = lt.announce_entry('test')
|
||||||
|
self.assertEquals(ae.can_announce(False), True)
|
||||||
|
self.assertEquals(ae.scrape_incomplete, -1)
|
||||||
|
self.assertEquals(ae.next_announce, None)
|
||||||
|
|
||||||
class test_alerts(unittest.TestCase):
|
class test_alerts(unittest.TestCase):
|
||||||
|
|
||||||
def test_alert(self):
|
def test_alert(self):
|
||||||
|
|
|
@ -811,6 +811,9 @@ namespace libtorrent
|
||||||
// time to wait until a new retry of a web seed takes place
|
// time to wait until a new retry of a web seed takes place
|
||||||
urlseed_wait_retry,
|
urlseed_wait_retry,
|
||||||
|
|
||||||
|
// time to wait until a new retry of a web seed name lookup
|
||||||
|
web_seed_name_lookup_retry,
|
||||||
|
|
||||||
// sets the upper limit on the total number of files this session will
|
// sets the upper limit on the total number of files this session will
|
||||||
// keep open. The reason why files are left open at all is that some
|
// keep open. The reason why files are left open at all is that some
|
||||||
// anti virus software hooks on every file close, and scans the file
|
// anti virus software hooks on every file close, and scans the file
|
||||||
|
|
|
@ -614,16 +614,14 @@ namespace libtorrent
|
||||||
strncpy(r.name, adapter->AdapterName, sizeof(r.name));
|
strncpy(r.name, adapter->AdapterName, sizeof(r.name));
|
||||||
r.name[sizeof(r.name)-1] = 0;
|
r.name[sizeof(r.name)-1] = 0;
|
||||||
r.mtu = adapter->Mtu;
|
r.mtu = adapter->Mtu;
|
||||||
IP_ADAPTER_UNICAST_ADDRESS* unicast = adapter->FirstUnicastAddress;
|
for (IP_ADAPTER_UNICAST_ADDRESS* unicast = adapter->FirstUnicastAddress;
|
||||||
while (unicast)
|
unicast; unicast = unicast->Next)
|
||||||
{
|
|
||||||
if (valid_addr_family(unicast->Address.lpSockaddr->sa_family))
|
|
||||||
{
|
{
|
||||||
|
if (!valid_addr_family(unicast->Address.lpSockaddr->sa_family))
|
||||||
|
continue;
|
||||||
r.interface_address = sockaddr_to_address(unicast->Address.lpSockaddr);
|
r.interface_address = sockaddr_to_address(unicast->Address.lpSockaddr);
|
||||||
ret.push_back(r);
|
ret.push_back(r);
|
||||||
}
|
}
|
||||||
unicast = unicast->Next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -930,14 +930,19 @@ namespace libtorrent
|
||||||
set_proxy(s);
|
set_proxy(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_handle::set_web_seed_proxy(proxy_settings const& s)
|
void session_handle::set_web_seed_proxy(proxy_settings const&)
|
||||||
{
|
{
|
||||||
set_proxy(s);
|
// NO-OP
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_handle::set_tracker_proxy(proxy_settings const& s)
|
void session_handle::set_tracker_proxy(proxy_settings const& s)
|
||||||
{
|
{
|
||||||
set_proxy(s);
|
// if the tracker proxy is enabled, set the "proxy_tracker_connections"
|
||||||
|
// setting
|
||||||
|
settings_pack pack;
|
||||||
|
pack.set_bool(settings_pack::proxy_tracker_connections
|
||||||
|
, s.type != aux::proxy_settings::none);
|
||||||
|
apply_settings(pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy_settings session_handle::peer_proxy() const
|
proxy_settings session_handle::peer_proxy() const
|
||||||
|
@ -952,12 +957,14 @@ namespace libtorrent
|
||||||
|
|
||||||
proxy_settings session_handle::tracker_proxy() const
|
proxy_settings session_handle::tracker_proxy() const
|
||||||
{
|
{
|
||||||
return proxy();
|
settings_pack const sett = get_settings();
|
||||||
|
return sett.get_bool(settings_pack::proxy_tracker_connections)
|
||||||
|
? proxy_settings(sett) : proxy_settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_handle::set_dht_proxy(proxy_settings const& s)
|
void session_handle::set_dht_proxy(proxy_settings const&)
|
||||||
{
|
{
|
||||||
set_proxy(s);
|
// NO-OP
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy_settings session_handle::dht_proxy() const
|
proxy_settings session_handle::dht_proxy() const
|
||||||
|
|
|
@ -213,6 +213,7 @@ namespace libtorrent
|
||||||
SET(urlseed_pipeline_size, 5, nullptr),
|
SET(urlseed_pipeline_size, 5, nullptr),
|
||||||
SET(urlseed_max_request_bytes, 16 * 1024 * 1024, 0),
|
SET(urlseed_max_request_bytes, 16 * 1024 * 1024, 0),
|
||||||
SET(urlseed_wait_retry, 30, nullptr),
|
SET(urlseed_wait_retry, 30, nullptr),
|
||||||
|
SET(web_seed_name_lookup_retry, 1800, nullptr),
|
||||||
SET(file_pool_size, 40, nullptr),
|
SET(file_pool_size, 40, nullptr),
|
||||||
SET(max_failcount, 3, &session_impl::update_max_failcount),
|
SET(max_failcount, 3, &session_impl::update_max_failcount),
|
||||||
SET(min_reconnect_time, 60, nullptr),
|
SET(min_reconnect_time, 60, nullptr),
|
||||||
|
|
|
@ -5727,8 +5727,9 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// unavailable, retry in 30 minutes
|
// unavailable, retry in `settings_pack::web_seed_name_lookup_retry` seconds
|
||||||
web->retry = aux::time_now32() + minutes32(30);
|
web->retry = aux::time_now32()
|
||||||
|
+ seconds32(settings().get_int(settings_pack::web_seed_name_lookup_retry));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue