diff --git a/ChangeLog b/ChangeLog index a976bde9e..0c14be8c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -81,6 +81,7 @@ * resume data no longer has timestamps of files * require C++11 to build libtorrent + * fix issue with receiving interested before metadata * fix IPv6 tracker announce issue * restore path sanitization behavior of ":" * fix listen socket issue when disabling "force_proxy" mode diff --git a/bindings/python/simple_client.py b/bindings/python/simple_client.py index 5c2ae4a98..9b0854d19 100755 --- a/bindings/python/simple_client.py +++ b/bindings/python/simple_client.py @@ -18,13 +18,9 @@ print('starting', s.name) while (not s.is_seeding): s = h.status() - state_str = [ - 'queued', 'checking', 'downloading metadata', - 'downloading', 'finished', 'seeding', 'allocating', - 'checking fastresume'] print('\r%.2f%% complete (down: %.1f kB/s up: %.1f kB/s peers: %d) %s' % ( s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, - s.num_peers, state_str[s.state]), end=' ') + s.num_peers, s.state), end=' ') alerts = ses.pop_alerts() for a in alerts: diff --git a/docs/manual.rst b/docs/manual.rst index 139117999..290cfecc9 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -775,6 +775,12 @@ The default peer class IDs are defined as enums in the ``session`` class: local_peer_class_id }; +The default peer classes are automatically created on session startup, and +configured to apply to each respective type of connection. There's nothing +preventing a client from reconfiguring the peer class ip- and type filters +to disable or customize which peers they apply to. See set_peer_class_filter() +and set_peer_class_type_filter(). + A peer class can be considered a more general form of *lables* that some clients have. Peer classes however are not just applied to torrents, but ultimately the peers. @@ -784,9 +790,9 @@ object), and deleted with the delete_peer_class() call. Peer classes are configured with the set_peer_class() get_peer_class() calls. -Custom peer classes can be assigned to torrents, with the ??? call, in which -case all its peers will belong to the class. They can also be assigned based on -the peer's IP address. See set_peer_class_filter() for more information. +Custom peer classes can be assigned based on the peer's IP address or the type +of transport protocol used. See set_peer_class_filter() and +set_peer_class_type_filter() for more information. peer class examples ------------------- diff --git a/docs/python_binding.rst b/docs/python_binding.rst index 5e7ab9d6e..d8bad5e4c 100644 --- a/docs/python_binding.rst +++ b/docs/python_binding.rst @@ -114,31 +114,10 @@ In order to interpret the statistics array, in C++ it is required to call ``sess For an example python program, see ``client.py`` in the ``bindings/python`` directory. -A very simple example usage of the module would be something like this:: +A very simple example usage of the module would be something like this: - import libtorrent as lt - import time - - ses = lt.session() - ses.listen_on(6881, 6891) - - e = lt.bdecode(open("test.torrent", 'rb').read()) - info = lt.torrent_info(e) - - params = { 'save_path': '.', \ - 'storage_mode': lt.storage_mode_t.storage_mode_sparse, \ - 'ti': info } - h = ses.add_torrent(params) - - s = h.status() - while (not s.is_seeding): - s = h.status() - - state_str = ['queued', 'checking', 'downloading metadata', \ - 'downloading', 'finished', 'seeding', 'allocating'] - print '%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s' % \ - (s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, \ - s.num_peers, state_str[s.state]) - - time.sleep(1) +.. include:: ../bindings/python/simple_client.py + :code: python + :tab-width: 2 + :start-after: from __future__ import print_function diff --git a/include/libtorrent/assert.hpp b/include/libtorrent/assert.hpp index da597f3e1..92efb0d4a 100644 --- a/include/libtorrent/assert.hpp +++ b/include/libtorrent/assert.hpp @@ -71,7 +71,7 @@ TORRENT_EXPORT void assert_fail(const char* expr, int line #if TORRENT_USE_ASSERTS #ifdef TORRENT_PRODUCTION_ASSERTS -extern char const* libtorrent_assert_log; +extern TORRENT_EXPORT char const* libtorrent_assert_log; #endif #if TORRENT_USE_IOSTREAM diff --git a/include/libtorrent/io_service_fwd.hpp b/include/libtorrent/io_service_fwd.hpp index 64c458ff0..615970be5 100644 --- a/include/libtorrent/io_service_fwd.hpp +++ b/include/libtorrent/io_service_fwd.hpp @@ -42,8 +42,12 @@ namespace sim { namespace asio { }} #else namespace boost { namespace asio { - +#if BOOST_VERSION < 106600 class io_service; +#else + class io_context; + typedef io_context io_service; +#endif }} #endif diff --git a/include/libtorrent/peer_class.hpp b/include/libtorrent/peer_class.hpp index 8eee1bd8d..21aec777c 100644 --- a/include/libtorrent/peer_class.hpp +++ b/include/libtorrent/peer_class.hpp @@ -53,7 +53,9 @@ namespace libtorrent { using peer_class_t = aux::strong_typedef; - struct peer_class_info + // holds settings for a peer class. Used in set_peer_class() and + // get_peer_class() calls. + struct TORRENT_EXPORT peer_class_info { // ``ignore_unchoke_slots`` determines whether peers should always // unchoke a peer, regardless of the choking algorithm, or if it should diff --git a/include/libtorrent/peer_class_type_filter.hpp b/include/libtorrent/peer_class_type_filter.hpp index 6a5d92501..5a996f0c0 100644 --- a/include/libtorrent/peer_class_type_filter.hpp +++ b/include/libtorrent/peer_class_type_filter.hpp @@ -41,7 +41,7 @@ namespace libtorrent { // ``peer_class_type_filter`` is a simple container for rules for adding and subtracting // peer-classes from peers. It is applied *after* the peer class filter is applied (which // is based on the peer's IP address). - struct peer_class_type_filter + struct TORRENT_EXPORT peer_class_type_filter { peer_class_type_filter() { diff --git a/include/libtorrent/session_handle.hpp b/include/libtorrent/session_handle.hpp index 231b66c3e..d3d7c0b6d 100644 --- a/include/libtorrent/session_handle.hpp +++ b/include/libtorrent/session_handle.hpp @@ -700,7 +700,7 @@ namespace libtorrent { // return value of ``get_peer_class()`` is undefined. // // ``set_peer_class()`` sets all the information in the - // ``peer_class_info`` object in the specified peer class. There is no + // peer_class_info object in the specified peer class. There is no // option to only update a single property. // // A peer or torrent belonging to more than one class, the highest diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index c89466b4a..c0285f6e7 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -542,6 +542,14 @@ namespace libtorrent { std::shared_ptr t = m_torrent.lock(); TORRENT_ASSERT(t); + if (!t->valid_metadata()) + { +#ifndef TORRENT_DISABLE_LOGGING + peer_log(peer_log_alert::info, "ALLOWED", "skipping allowed set because we don't have metadata"); +#endif + return; + } + if (t->super_seeding()) { #ifndef TORRENT_DISABLE_LOGGING