From 1ebc5f9ef2aee68017d4eb3641a579c587876a12 Mon Sep 17 00:00:00 2001 From: arvidn Date: Fri, 13 Jul 2018 17:48:33 +0200 Subject: [PATCH] remove special handling of uTP peers --- ChangeLog | 1 + docs/manual.rst | 20 +++++++------------- include/libtorrent/add_torrent_params.hpp | 4 ++-- include/libtorrent/session_handle.hpp | 15 +++++++-------- include/libtorrent/settings_pack.hpp | 2 +- src/session_impl.cpp | 11 ++++------- src/settings_pack.cpp | 2 +- 7 files changed, 23 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ea39b283..03ba193e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * uTP connections are no longer exempt from rate limits by default * fix exporting files from partfile while seeding * fix potential deadlock on Windows, caused by performing restricted tasks from within DllMain diff --git a/docs/manual.rst b/docs/manual.rst index a946765dd..5292afd61 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -891,13 +891,11 @@ based peer class assignment: ip_filter f; // for every IPv4 address, assign the global peer class - f.add_rule(address_v4::from_string("0.0.0.0") - , address_v4::from_string("255.255.255.255") - , mask); + f.add_rule(make_address("0.0.0.0"), make_address("255.255.255.255"), mask); // for every IPv6 address, assign the global peer class - f.add_rule(address_v6::from_string("::") - , address_v6::from_string("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") + f.add_rule(make_address("::") + , make_address("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") , mask); ses.set_peer_class_filter(f); @@ -905,7 +903,7 @@ To make uTP sockets exempt from rate limiting: .. code:: c++ - peer_class_type_filter flt; + peer_class_type_filter flt = ses.get_peer_class_type_filter(); // filter out the global and local peer class for uTP sockets, if these // classes are set by the IP filter flt.disallow(peer_class_type_filter::utp_socket, session::global_peer_class_id); @@ -925,14 +923,10 @@ To make all peers on the internal network unthrottled: ip_filter f; // for every IPv4 address, assign the global peer class - f.add_rule(address_v4::from_string("0.0.0.0") - , address_v4::from_string("255.255.255.255") - , mask); + f.add_rule(make_address("0.0.0.0"), make_address("255.255.255.255"), mask); - // for every address on the local metwork, set the mastk to 0 - f.add_rule(address_v4::from_string("10.0.0.0") - , address_v4::from_string("10.255.255.255") - , 0); + // for every address on the local metwork, set the mask to 0 + f.add_rule(make_address("10.0.0.0"), make_address("10.255.255.255"), 0); ses.set_peer_class_filter(f); SSL torrents diff --git a/include/libtorrent/add_torrent_params.hpp b/include/libtorrent/add_torrent_params.hpp index 69e0c29d0..540409d6e 100644 --- a/include/libtorrent/add_torrent_params.hpp +++ b/include/libtorrent/add_torrent_params.hpp @@ -408,8 +408,8 @@ namespace libtorrent // -1 means unlimited on these settings just like their counterpart // functions on torrent_handle // - // For fine grained control over rate limits, including making them apply - // to local peers, see peer-classes_. + // For fine grained control over rate limits depending on various + // properties of the peer connection, see peer-classes_. int max_uploads; int max_connections; int upload_limit; diff --git a/include/libtorrent/session_handle.hpp b/include/libtorrent/session_handle.hpp index 2155206fa..8bd2f2f03 100644 --- a/include/libtorrent/session_handle.hpp +++ b/include/libtorrent/session_handle.hpp @@ -632,10 +632,9 @@ namespace libtorrent // // .. code:: c++ // - // ip_filter f; - // peer_class_t my_class = ses.create_peer_class("200.1.x.x IP range"); - // f.add_rule(address_v4::from_string("200.1.1.0") - // , address_v4::from_string("200.1.255.255") + // ip_filter f = ses.get_peer_class_filter(); + // peer_class_t const my_class = ses.create_peer_class("200.1.x.x IP range"); + // f.add_rule(make_address("200.1.1.0"), make_address("200.1.255.255") // , 1 << my_class); // ses.set_peer_class_filter(f); // @@ -682,7 +681,7 @@ namespace libtorrent // make sure to create those early on, to get low identifiers. // // For more information on peer classes, see peer-classes_. - int create_peer_class(char const* name); + peer_class_t create_peer_class(char const* name); // This call dereferences the reference count of the specified peer // class. When creating a peer class it's automatically referenced by 1. @@ -701,7 +700,7 @@ namespace libtorrent // destructs. // // For more information on peer classes, see peer-classes_. - void delete_peer_class(int cid); + void delete_peer_class(peer_class_t cid); // These functions queries information from a peer class and updates the // configuration of a peer class, respectively. @@ -718,8 +717,8 @@ namespace libtorrent // account. // // For more information, see peer-classes_. - peer_class_info get_peer_class(int cid); - void set_peer_class(int cid, peer_class_info const& pci); + peer_class_info get_peer_class(peer_class_t cid); + void set_peer_class(peer_class_t cid, peer_class_info const& pci); #ifndef TORRENT_NO_DEPRECATE // if the listen port failed in some way you can retry to listen on diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index b33c8925d..d2eac1bf6 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -522,9 +522,9 @@ namespace libtorrent // libtorrent API. report_web_seed_downloads, +#ifndef TORRENT_NO_DEPRECATE // set to true if uTP connections should be rate limited This option // is *DEPRECATED*, please use set_peer_class_filter() instead. -#ifndef TORRENT_NO_DEPRECATE rate_limit_utp TORRENT_DEPRECATED_ENUM, #else deprecated2, diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 5ce9c9b5b..b993ff19a 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -511,9 +511,6 @@ namespace aux { m_peer_class_type_filter.add(peer_class_type_filter::ssl_tcp_socket, m_tcp_peer_class); m_peer_class_type_filter.add(peer_class_type_filter::i2p_socket, m_tcp_peer_class); - // TODO: there's no rule here to make uTP connections not have the global or - // local rate limits apply to it. This used to be the default. - #ifndef TORRENT_DISABLE_LOGGING session_log("config: %s version: %s revision: %s" @@ -1279,7 +1276,7 @@ namespace aux { return m_classes.new_peer_class(name); } - void session_impl::delete_peer_class(int cid) + void session_impl::delete_peer_class(peer_class_t const cid) { TORRENT_ASSERT(is_single_thread()); // if you hit this assert, you're deleting a non-existent peer class @@ -1288,7 +1285,7 @@ namespace aux { m_classes.decref(cid); } - peer_class_info session_impl::get_peer_class(int cid) + peer_class_info session_impl::get_peer_class(peer_class_t const cid) { peer_class_info ret; peer_class* pc = m_classes.at(cid); @@ -1340,7 +1337,7 @@ namespace aux { m_tracker_manager.queue_request(get_io_service(), req, c); } - void session_impl::set_peer_class(int cid, peer_class_info const& pci) + void session_impl::set_peer_class(peer_class_t const cid, peer_class_info const& pci) { peer_class* pc = m_classes.at(cid); // if you hit this assert, you're passing in an invalid cid @@ -6238,7 +6235,7 @@ retry: { return download_rate_limit(m_global_class); } -#endif +#endif // DEPRECATE // TODO: 2 this should be factored into the udp socket, so we only have the // code once diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index e2a1d6624..e4de7bc63 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -204,7 +204,7 @@ namespace libtorrent SET(no_recheck_incomplete_resume, false, 0), SET(anonymous_mode, false, &session_impl::update_anonymous_mode), SET(report_web_seed_downloads, true, &session_impl::update_report_web_seed_downloads), - DEPRECATED_SET(rate_limit_utp, false, &session_impl::update_rate_limit_utp), + DEPRECATED_SET(rate_limit_utp, true, &session_impl::update_rate_limit_utp), SET(announce_double_nat, false, 0), SET(seeding_outgoing_connections, true, 0), SET(no_connect_privileged_ports, false, &session_impl::update_privileged_ports),