From f712caa80d7f9cf0a27cb1490d8b460574a22009 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 21 Sep 2016 16:54:49 -0700 Subject: [PATCH] deprecate send_stats property on trackers (since lt_tracker extension has been removed) (#1125) --- ChangeLog | 2 ++ bindings/python/src/torrent_handle.cpp | 4 ++++ bindings/python/src/torrent_info.cpp | 4 +++- include/libtorrent/announce_entry.hpp | 6 ++++++ include/libtorrent/tracker_manager.hpp | 3 --- src/announce_entry.cpp | 2 -- src/http_tracker_connection.cpp | 13 ++++++------- src/torrent.cpp | 4 ---- src/udp_tracker_connection.cpp | 7 +++---- 9 files changed, 24 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9bc10537e..afad7ced3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ + * deprecate "send_stats" property on trackers (since lt_tracker extension has + been removed) * remove deprecate session_settings API (use settings_pack instead) * improve file layout optimization when creating torrents with padfiles * remove remote_dl_rate feature diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index 52784d49d..3818acc97 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -200,8 +200,10 @@ void dict_to_announce_entry(dict d, announce_entry& ae) ae.source = extract(d["source"]); if (d.has_key("verified")) ae.verified = extract(d["verified"]); +#ifndef TORRENT_NO_DEPRECATE if (d.has_key("send_stats")) ae.send_stats = extract(d["send_stats"]); +#endif } void replace_trackers(torrent_handle& h, object trackers) @@ -258,7 +260,9 @@ list trackers(torrent_handle& h) d["updating"] = i->updating; d["start_sent"] = i->start_sent; d["complete_sent"] = i->complete_sent; +#ifndef TORRENT_NO_DEPRECATE d["send_stats"] = i->send_stats; +#endif ret.append(d); } return ret; diff --git a/bindings/python/src/torrent_info.cpp b/bindings/python/src/torrent_info.cpp index cddadc6ce..4ac14c9bd 100644 --- a/bindings/python/src/torrent_info.cpp +++ b/bindings/python/src/torrent_info.cpp @@ -123,9 +123,9 @@ namespace bool get_updating(announce_entry const& ae) { return ae.updating; } 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_send_stats(announce_entry const& ae) { return ae.send_stats; } #if !defined 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; } std::int64_t get_file_base(file_entry const& fe) { return fe.file_base; } @@ -295,7 +295,9 @@ void bind_torrent_info() .add_property("updating", &get_updating) .add_property("start_sent", &get_start_sent) .add_property("complete_sent", &get_complete_sent) +#if !defined TORRENT_NO_DEPRECATE .add_property("send_stats", &get_send_stats) +#endif .def("reset", &announce_entry::reset) .def("can_announce", &announce_entry::can_announce) diff --git a/include/libtorrent/announce_entry.hpp b/include/libtorrent/announce_entry.hpp index f8d1caf4e..8ac5a91d4 100644 --- a/include/libtorrent/announce_entry.hpp +++ b/include/libtorrent/announce_entry.hpp @@ -144,8 +144,14 @@ namespace libtorrent // set to true when we send a event=completed. bool complete_sent:1; +#ifndef TORRENT_NO_DEPRECATE + // deprecated in 1.2 // this is false the stats sent to this tracker will be 0 bool send_stats:1; +#else + // hidden + bool deprecated_send_stats:1; +#endif // internal bool triggered_manually:1; diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index 0c671f570..390cbb68c 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -96,7 +96,6 @@ namespace libtorrent , kind(announce_request) , key(0) , num_want(0) - , send_stats(true) , triggered_manually(false) #ifdef TORRENT_USE_OPENSSL , ssl_ctx(0) @@ -155,8 +154,6 @@ namespace libtorrent peer_id pid; address bind_ip; - bool send_stats; - // this is set to true if this request was triggered by a "manual" call to // scrape_tracker() or force_reannounce() bool triggered_manually; diff --git a/src/announce_entry.cpp b/src/announce_entry.cpp index 3f3d7e8d5..fe75d5c62 100644 --- a/src/announce_entry.cpp +++ b/src/announce_entry.cpp @@ -62,7 +62,6 @@ namespace libtorrent , verified(false) , start_sent(false) , complete_sent(false) - , send_stats(true) , triggered_manually(false) {} @@ -80,7 +79,6 @@ namespace libtorrent , verified(false) , start_sent(false) , complete_sent(false) - , send_stats(true) , triggered_manually(false) {} diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index c2ddf42b5..db5d992f7 100644 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -116,7 +116,6 @@ namespace libtorrent const char* event_string[] = {"completed", "started", "stopped", "paused"}; char str[1024]; - const bool stats = tracker_req().send_stats; std::snprintf(str, sizeof(str) , "&peer_id=%s" "&port=%d" @@ -133,10 +132,10 @@ namespace libtorrent // the i2p tracker seems to verify that the port is not 0, // even though it ignores it otherwise , i2p ? 1 : tracker_req().listen_port - , stats ? tracker_req().uploaded : 0 - , stats ? tracker_req().downloaded : 0 - , stats ? tracker_req().left : 0 - , stats ? tracker_req().corrupt : 0 + , tracker_req().uploaded + , tracker_req().downloaded + , tracker_req().left + , tracker_req().corrupt , tracker_req().key , (tracker_req().event != tracker_request::none) ? "&event=" : "" , (tracker_req().event != tracker_request::none) ? event_string[tracker_req().event - 1] : "" @@ -147,7 +146,7 @@ namespace libtorrent && settings.get_bool(settings_pack::announce_crypto_support)) url += "&supportcrypto=1"; #endif - if (stats && settings.get_bool(settings_pack::report_redundant_bytes)) + if (settings.get_bool(settings_pack::report_redundant_bytes)) { url += "&redundant="; url += to_string(tracker_req().redundant).data(); @@ -168,7 +167,7 @@ namespace libtorrent } else { - url += "&ip=" + tracker_req ().i2pconn->local_endpoint () + ".i2p"; + url += "&ip=" + tracker_req().i2pconn->local_endpoint () + ".i2p"; } } else diff --git a/src/torrent.cpp b/src/torrent.cpp index 80fd8ecd4..8bb929d46 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -6429,10 +6429,6 @@ namespace libtorrent int tier = 0; for (announce_entry const& tr : m_trackers) { - // don't save trackers we can't trust - // TODO: 1 save the send_stats state instead of throwing them away - // it may pose an issue when downgrading though - if (tr.send_stats == false) continue; if (tr.tier == tier) { tr_list.back().list().push_back(tr.url); diff --git a/src/udp_tracker_connection.cpp b/src/udp_tracker_connection.cpp index bb45266d1..68bae77cc 100644 --- a/src/udp_tracker_connection.cpp +++ b/src/udp_tracker_connection.cpp @@ -719,7 +719,6 @@ namespace libtorrent span out = buf; tracker_request const& req = tracker_req(); - bool const stats = req.send_stats; aux::session_settings const& settings = m_man.settings(); std::map::iterator i @@ -735,9 +734,9 @@ namespace libtorrent out.subspan(20); std::copy(req.pid.begin(), req.pid.end(), out.data()); // peer_id out.subspan(20); - aux::write_int64(stats ? req.downloaded : 0, out); // downloaded - aux::write_int64(stats ? req.left : 0, out); // left - aux::write_int64(stats ? req.uploaded : 0, out); // uploaded + aux::write_int64(req.downloaded, out); // downloaded + aux::write_int64(req.left, out); // left + aux::write_int64(req.uploaded, out); // uploaded aux::write_int32(req.event, out); // event // ip address address_v4 announce_ip;