--- /srv/rebuilderd/tmp/rebuilderdPeHkwI/inputs/libtorrent-rasterbar-doc_2.0.14-2_all.deb +++ /srv/rebuilderd/tmp/rebuilderdPeHkwI/out/libtorrent-rasterbar-doc_2.0.14-2_all.deb ├── file list │ @@ -1,3 +1,3 @@ │ -rw-r--r-- 0 0 0 4 2026-08-10 18:36:30.000000 debian-binary │ --rw-r--r-- 0 0 0 3632 2026-08-10 18:36:30.000000 control.tar.xz │ --rw-r--r-- 0 0 0 1685468 2026-08-10 18:36:30.000000 data.tar.xz │ +-rw-r--r-- 0 0 0 3636 2026-08-10 18:36:30.000000 control.tar.xz │ +-rw-r--r-- 0 0 0 1685192 2026-08-10 18:36:30.000000 data.tar.xz ├── control.tar.xz │ ├── control.tar │ │ ├── ./md5sums │ │ │ ├── ./md5sums │ │ │ │┄ Files differ ├── data.tar.xz │ ├── data.tar │ │ ├── file list │ │ │ @@ -73,43 +73,43 @@ │ │ │ -rw-r--r-- 0 root (0) root (0) 448094 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/img/troubleshooting.png │ │ │ -rw-r--r-- 0 root (0) root (0) 48654 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/img/troubleshooting_thumb.png │ │ │ -rw-r--r-- 0 root (0) root (0) 243 2026-08-08 09:45:20.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/img/utp_stack.diagram │ │ │ -rw-r--r-- 0 root (0) root (0) 2007 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/img/utp_stack.png │ │ │ -rw-r--r-- 0 root (0) root (0) 1156 2026-08-08 09:45:20.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/img/write_disk_buffers.diagram │ │ │ -rw-r--r-- 0 root (0) root (0) 9631 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/img/write_disk_buffers.png │ │ │ -rw-r--r-- 0 root (0) root (0) 9768 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/index.html │ │ │ --rw-r--r-- 0 root (0) root (0) 146693 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/manual-ref.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 146686 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/manual-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 9650 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/projects.html │ │ │ -rw-r--r-- 0 root (0) root (0) 22974 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/python_binding.html │ │ │ -rw-r--r-- 0 root (0) root (0) 35575 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Add_Torrent.html │ │ │ -rw-r--r-- 0 root (0) root (0) 256838 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Alerts.html │ │ │ --rw-r--r-- 0 root (0) root (0) 27434 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Bdecoding.html │ │ │ --rw-r--r-- 0 root (0) root (0) 25771 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Bencoding.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 27437 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Bdecoding.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 25769 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Bencoding.html │ │ │ -rw-r--r-- 0 root (0) root (0) 88058 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Core.html │ │ │ -rw-r--r-- 0 root (0) root (0) 43859 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Create_Torrents.html │ │ │ -rw-r--r-- 0 root (0) root (0) 137041 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Custom_Storage.html │ │ │ -rw-r--r-- 0 root (0) root (0) 24960 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-DHT.html │ │ │ --rw-r--r-- 0 root (0) root (0) 48765 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Error_Codes.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 48763 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Error_Codes.html │ │ │ -rw-r--r-- 0 root (0) root (0) 13261 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Filter.html │ │ │ -rw-r--r-- 0 root (0) root (0) 12804 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-PeerClass.html │ │ │ -rw-r--r-- 0 root (0) root (0) 69760 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Plugins.html │ │ │ -rw-r--r-- 0 root (0) root (0) 11011 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Resume_Data.html │ │ │ --rw-r--r-- 0 root (0) root (0) 102831 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Session.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 102810 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Session.html │ │ │ -rw-r--r-- 0 root (0) root (0) 174381 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Settings.html │ │ │ -rw-r--r-- 0 root (0) root (0) 9742 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Stats.html │ │ │ --rw-r--r-- 0 root (0) root (0) 56856 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Storage.html │ │ │ --rw-r--r-- 0 root (0) root (0) 131689 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Handle.html │ │ │ --rw-r--r-- 0 root (0) root (0) 58150 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Info.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 56848 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Storage.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 131672 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Handle.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 58142 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Info.html │ │ │ -rw-r--r-- 0 root (0) root (0) 48237 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Status.html │ │ │ -rw-r--r-- 0 root (0) root (0) 16462 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Trackers.html │ │ │ -rw-r--r-- 0 root (0) root (0) 25530 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Utility.html │ │ │ -rw-r--r-- 0 root (0) root (0) 9129 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-ed25519.html │ │ │ --rw-r--r-- 0 root (0) root (0) 34357 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 34353 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference.html │ │ │ -rw-r--r-- 0 root (0) root (0) 29242 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/security-audit.html │ │ │ --rw-r--r-- 0 root (0) root (0) 1374275 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/single-page-ref.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 1374220 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/single-page-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 10121 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/streaming.html │ │ │ -rw-r--r-- 0 root (0) root (0) 8807 2026-08-08 09:45:20.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/style.css │ │ │ -rw-r--r-- 0 root (0) root (0) 521273 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/todo.html │ │ │ -rw-r--r-- 0 root (0) root (0) 3023 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/troubleshooting.html │ │ │ -rw-r--r-- 0 root (0) root (0) 25162 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/tuning-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 132630 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/tutorial-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 16383 2026-08-10 18:36:30.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/udp_tracker_protocol.html │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/manual-ref.html │ │ │ @@ -115,15 +115,15 @@ │ │ │
  • main loop (see session)

    │ │ │
    │ │ │ │ │ │
    │ │ │
  • │ │ │
  • save resume data for all torrent_handles (optional, see │ │ │ save_resume_data())

    │ │ │
  • │ │ │
  • save session state (see session_state() and write_session_params())

    │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Add_Torrent.html │ │ │ @@ -28,91 +28,26 @@ │ │ │ 2.0.14 │ │ │ │ │ │ │ │ │

    home

    │ │ │
    │ │ │

    Table of contents

    │ │ │
    │ │ │ -[report issue]
    │ │ │ -

    client_data_t

    │ │ │ -

    Declared in "libtorrent/client_data.hpp"

    │ │ │ -

    A thin wrapper around a void pointer used as "user data". i.e. an opaque │ │ │ -cookie passed in to libtorrent and returned on demand. It adds type-safety by │ │ │ -requiring the same type be requested out of it as was assigned to it.

    │ │ │ -
    │ │ │ -struct client_data_t
    │ │ │ -{
    │ │ │ -   client_data_t () = default;
    │ │ │ -   explicit client_data_t (T* v);
    │ │ │ -   client_data_t& operator= (T* v);
    │ │ │ -   T* get () const;
    │ │ │ -   explicit operator T () const;
    │ │ │ -   client_data_t& operator= (void*) = delete;
    │ │ │ -   operator void const* () const = delete;
    │ │ │ -   client_data_t& operator= (void const*) = delete;
    │ │ │ -   operator void* () const = delete;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    client_data_t()

    │ │ │ -
    │ │ │ -client_data_t () = default;
    │ │ │ -
    │ │ │ -

    construct a nullptr client data

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    client_data_t()

    │ │ │ -
    │ │ │ -explicit client_data_t (T* v);
    │ │ │ -
    │ │ │ -

    initialize the client data with the specified pointer

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    operator=()

    │ │ │ -
    │ │ │ -client_data_t& operator= (T* v);
    │ │ │ -
    │ │ │ -

    assigns a new pointer to the client data

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    get() T()

    │ │ │ -
    │ │ │ -T* get () const;
    │ │ │ -explicit operator T () const;
    │ │ │ -
    │ │ │ -

    request to retrieve the pointer back again. The type T must be │ │ │ -identical to the type of the pointer assigned earlier, including │ │ │ -const & volatile qualifiers.

    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    operator=() const*() void*()

    │ │ │ -
    │ │ │ -client_data_t& operator= (void*) = delete;
    │ │ │ -operator void const* () const = delete;
    │ │ │ -client_data_t& operator= (void const*) = delete;
    │ │ │ -operator void* () const = delete;
    │ │ │ -
    │ │ │ -

    we don't allow type-unsafe operations

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ +[report issue]
    │ │ │

    add_torrent_params

    │ │ │

    Declared in "libtorrent/add_torrent_params.hpp"

    │ │ │

    The add_torrent_params contains all the information in a .torrent file │ │ │ along with all information necessary to add that torrent to a session. │ │ │ The key fields when adding a torrent are:

    │ │ │
      │ │ │
    • ti - the immutable info-dict part of the torrent
    • │ │ │ @@ -425,14 +360,79 @@ │ │ │ [report issue]
      │ │ │
      last_download last_upload
      │ │ │
      the posix time of the last time payload was received or sent for this │ │ │ torrent, respectively. A value of 0 means we don't know when we last │ │ │ uploaded or downloaded, or we have never uploaded or downloaded any │ │ │ payload for this torrent.
      │ │ │
      │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    client_data_t

    │ │ │ +

    Declared in "libtorrent/client_data.hpp"

    │ │ │ +

    A thin wrapper around a void pointer used as "user data". i.e. an opaque │ │ │ +cookie passed in to libtorrent and returned on demand. It adds type-safety by │ │ │ +requiring the same type be requested out of it as was assigned to it.

    │ │ │ +
    │ │ │ +struct client_data_t
    │ │ │ +{
    │ │ │ +   client_data_t () = default;
    │ │ │ +   explicit client_data_t (T* v);
    │ │ │ +   client_data_t& operator= (T* v);
    │ │ │ +   T* get () const;
    │ │ │ +   explicit operator T () const;
    │ │ │ +   operator void* () const = delete;
    │ │ │ +   client_data_t& operator= (void*) = delete;
    │ │ │ +   client_data_t& operator= (void const*) = delete;
    │ │ │ +   operator void const* () const = delete;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    client_data_t()

    │ │ │ +
    │ │ │ +client_data_t () = default;
    │ │ │ +
    │ │ │ +

    construct a nullptr client data

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    client_data_t()

    │ │ │ +
    │ │ │ +explicit client_data_t (T* v);
    │ │ │ +
    │ │ │ +

    initialize the client data with the specified pointer

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    operator=()

    │ │ │ +
    │ │ │ +client_data_t& operator= (T* v);
    │ │ │ +
    │ │ │ +

    assigns a new pointer to the client data

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    get() T()

    │ │ │ +
    │ │ │ +T* get () const;
    │ │ │ +explicit operator T () const;
    │ │ │ +
    │ │ │ +

    request to retrieve the pointer back again. The type T must be │ │ │ +identical to the type of the pointer assigned earlier, including │ │ │ +const & volatile qualifiers.

    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    operator=() void*() const*()

    │ │ │ +
    │ │ │ +operator void* () const = delete;
    │ │ │ +client_data_t& operator= (void*) = delete;
    │ │ │ +client_data_t& operator= (void const*) = delete;
    │ │ │ +operator void const* () const = delete;
    │ │ │ +
    │ │ │ +

    we don't allow type-unsafe operations

    │ │ │ +
    │ │ │
    │ │ │ │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │
  • session_error_alert
  • │ │ │
  • dht_live_nodes_alert │ │ │
  • │ │ │
  • session_stats_header_alert
  • │ │ │
  • dht_sample_infohashes_alert │ │ │
  • │ │ │
  • block_uploaded_alert
  • │ │ │
  • alerts_dropped_alert
  • │ │ │
  • socks5_alert
  • │ │ │ @@ -435,27 +435,27 @@ │ │ │

    Declared in "libtorrent/alert_types.hpp"

    │ │ │

    This is posted as a response to a torrent_handle::rename_file() call, if the rename │ │ │ operation succeeds.

    │ │ │
    │ │ │  struct file_renamed_alert final : torrent_alert
    │ │ │  {
    │ │ │     std::string message () const override;
    │ │ │ -   char const* old_name () const;
    │ │ │     char const* new_name () const;
    │ │ │ +   char const* old_name () const;
    │ │ │  
    │ │ │     static constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │     file_index_t const index;
    │ │ │  };
    │ │ │  
    │ │ │ │ │ │ [report issue]
    │ │ │

    new_name() old_name()

    │ │ │
    │ │ │ -char const* old_name () const;
    │ │ │  char const* new_name () const;
    │ │ │ +char const* old_name () const;
    │ │ │  
    │ │ │

    returns the new and previous file name, respectively.

    │ │ │ [report issue]
    │ │ │
    index
    │ │ │
    refers to the index of the file that was renamed,
    │ │ │
    │ │ │ [report issue]
    │ │ │ @@ -1178,26 +1178,26 @@ │ │ │ torrent_handle::move_storage. This is useful to synchronize with the │ │ │ actual disk. The storage_path() member return the new path of the │ │ │ storage.

    │ │ │
    │ │ │  struct storage_moved_alert final : torrent_alert
    │ │ │  {
    │ │ │     std::string message () const override;
    │ │ │ -   char const* storage_path () const;
    │ │ │     char const* old_path () const;
    │ │ │ +   char const* storage_path () const;
    │ │ │  
    │ │ │     static constexpr alert_category_t static_category  = alert_category::storage;
    │ │ │  };
    │ │ │  
    │ │ │ │ │ │ [report issue]
    │ │ │

    old_path() storage_path()

    │ │ │
    │ │ │ -char const* storage_path () const;
    │ │ │  char const* old_path () const;
    │ │ │ +char const* storage_path () const;
    │ │ │  
    │ │ │

    the path the torrent was moved to and from, respectively.

    │ │ │ [report issue]
    │ │ │ │ │ │
    │ │ │

    storage_moved_failed_alert

    │ │ │

    Declared in "libtorrent/alert_types.hpp"

    │ │ │ @@ -2835,27 +2835,27 @@ │ │ │

    posted in response to a call to session::dht_live_nodes(). It contains the │ │ │ live nodes from the DHT routing table of one of the DHT nodes running │ │ │ locally.

    │ │ │
    │ │ │  struct dht_live_nodes_alert final : alert
    │ │ │  {
    │ │ │     std::string message () const override;
    │ │ │ -   int num_nodes () const;
    │ │ │     std::vector<std::pair<sha1_hash, udp::endpoint>> nodes () const;
    │ │ │ +   int num_nodes () const;
    │ │ │  
    │ │ │     static constexpr alert_category_t static_category  = alert_category::dht;
    │ │ │     sha1_hash node_id;
    │ │ │  };
    │ │ │  
    │ │ │ │ │ │ [report issue]
    │ │ │

    nodes() num_nodes()

    │ │ │
    │ │ │ -int num_nodes () const;
    │ │ │  std::vector<std::pair<sha1_hash, udp::endpoint>> nodes () const;
    │ │ │ +int num_nodes () const;
    │ │ │  
    │ │ │

    the number of nodes in the routing table and the actual nodes.

    │ │ │ [report issue]
    │ │ │
    node_id
    │ │ │
    the local DHT node's node-ID this routing table belongs to
    │ │ │
    │ │ │ [report issue]
    │ │ │ @@ -2884,32 +2884,32 @@ │ │ │

    Declared in "libtorrent/alert_types.hpp"

    │ │ │

    posted as a response to a call to session::dht_sample_infohashes() with │ │ │ the information from the DHT response message.

    │ │ │
    │ │ │  struct dht_sample_infohashes_alert final : alert
    │ │ │  {
    │ │ │     std::string message () const override;
    │ │ │ -   std::vector<sha1_hash> samples () const;
    │ │ │     int num_samples () const;
    │ │ │ +   std::vector<sha1_hash> samples () const;
    │ │ │     int num_nodes () const;
    │ │ │     std::vector<std::pair<sha1_hash, udp::endpoint>> nodes () const;
    │ │ │  
    │ │ │     static constexpr alert_category_t static_category  = alert_category::dht_operation;
    │ │ │     sha1_hash node_id;
    │ │ │     aux::noexcept_movable<udp::endpoint> endpoint;
    │ │ │     time_duration const interval;
    │ │ │     int const num_infohashes;
    │ │ │  };
    │ │ │  
    │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    samples() num_samples()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    num_samples() samples()

    │ │ │
    │ │ │ -std::vector<sha1_hash> samples () const;
    │ │ │  int num_samples () const;
    │ │ │ +std::vector<sha1_hash> samples () const;
    │ │ │  
    │ │ │

    returns the number of info-hashes returned by the node, as well as the │ │ │ actual info-hashes. num_samples() is more efficient than │ │ │ samples().size().

    │ │ │ [report issue]
    │ │ │
    │ │ │

    num_nodes()

    │ │ │ @@ -2970,16 +2970,16 @@ │ │ │

    this alert is posted to indicate to the client that some alerts were │ │ │ dropped. Dropped meaning that the alert failed to be delivered to the │ │ │ client. The most common cause of such failure is that the internal alert │ │ │ queue grew too big (controlled by alert_queue_size).

    │ │ │
    │ │ │  struct alerts_dropped_alert final : alert
    │ │ │  {
    │ │ │ -   std::string message () const override;
    │ │ │     static_assert (num_alert_types <= abi_alert_count, "need to increase bitset. This is an ABI break");
    │ │ │ +   std::string message () const override;
    │ │ │  
    │ │ │     static constexpr alert_category_t static_category  = alert_category::error;
    │ │ │     std::bitset<abi_alert_count> dropped_alerts;
    │ │ │  };
    │ │ │  
    │ │ │ [report issue]
    │ │ │
    dropped_alerts
    │ │ │ ├── html2text {} │ │ │ │ @@ -117,15 +117,15 @@ │ │ │ │ * _d_h_t___d_i_r_e_c_t___r_e_s_p_o_n_s_e___a_l_e_r_t │ │ │ │ * _p_i_c_k_e_r___l_o_g___a_l_e_r_t │ │ │ │ * _s_e_s_s_i_o_n___e_r_r_o_r___a_l_e_r_t │ │ │ │ * _d_h_t___l_i_v_e___n_o_d_e_s___a_l_e_r_t │ │ │ │ o _n_o_d_e_s_(_)_ _n_u_m___n_o_d_e_s_(_) │ │ │ │ * _s_e_s_s_i_o_n___s_t_a_t_s___h_e_a_d_e_r___a_l_e_r_t │ │ │ │ * _d_h_t___s_a_m_p_l_e___i_n_f_o_h_a_s_h_e_s___a_l_e_r_t │ │ │ │ - o _s_a_m_p_l_e_s_(_)_ _n_u_m___s_a_m_p_l_e_s_(_) │ │ │ │ + o _n_u_m___s_a_m_p_l_e_s_(_)_ _s_a_m_p_l_e_s_(_) │ │ │ │ o _n_u_m___n_o_d_e_s_(_) │ │ │ │ o _n_o_d_e_s_(_) │ │ │ │ * _b_l_o_c_k___u_p_l_o_a_d_e_d___a_l_e_r_t │ │ │ │ * _a_l_e_r_t_s___d_r_o_p_p_e_d___a_l_e_r_t │ │ │ │ * _s_o_c_k_s_5___a_l_e_r_t │ │ │ │ * _f_i_l_e___p_r_i_o___a_l_e_r_t │ │ │ │ * _o_v_e_r_s_i_z_e_d___f_i_l_e___a_l_e_r_t │ │ │ │ @@ -311,25 +311,25 @@ │ │ │ │ ************ ffiillee__rreennaammeedd__aalleerrtt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ This is posted as a response to a _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_r_e_n_a_m_e___f_i_l_e_(_) call, if the │ │ │ │ rename operation succeeds. │ │ │ │ struct file_renamed_alert final : torrent_alert │ │ │ │ { │ │ │ │ std::string mmeessssaaggee () const override; │ │ │ │ - char const* oolldd__nnaammee () const; │ │ │ │ char const* nneeww__nnaammee () const; │ │ │ │ + char const* oolldd__nnaammee () const; │ │ │ │ │ │ │ │ static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ storage; │ │ │ │ file_index_t const index; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** nneeww__nnaammee(()) oolldd__nnaammee(()) ********** │ │ │ │ -char const* oolldd__nnaammee () const; │ │ │ │ char const* nneeww__nnaammee () const; │ │ │ │ +char const* oolldd__nnaammee () const; │ │ │ │ returns the new and previous file name, respectively. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ index │ │ │ │ refers to the index of the file that was renamed, │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ffiillee__rreennaammee__ffaaiilleedd__aalleerrtt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ @@ -946,24 +946,24 @@ │ │ │ │ The storage_moved_alert is generated when all the disk IO has completed and the │ │ │ │ files have been moved, as an effect of a call to torrent_handle::move_storage. │ │ │ │ This is useful to synchronize with the actual disk. The storage_path() member │ │ │ │ return the new path of the storage. │ │ │ │ struct storage_moved_alert final : torrent_alert │ │ │ │ { │ │ │ │ std::string mmeessssaaggee () const override; │ │ │ │ - char const* ssttoorraaggee__ppaatthh () const; │ │ │ │ char const* oolldd__ppaatthh () const; │ │ │ │ + char const* ssttoorraaggee__ppaatthh () const; │ │ │ │ │ │ │ │ static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ storage; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** oolldd__ppaatthh(()) ssttoorraaggee__ppaatthh(()) ********** │ │ │ │ -char const* ssttoorraaggee__ppaatthh () const; │ │ │ │ char const* oolldd__ppaatthh () const; │ │ │ │ +char const* ssttoorraaggee__ppaatthh () const; │ │ │ │ the path the torrent was moved to and from, respectively. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ssttoorraaggee__mmoovveedd__ffaaiilleedd__aalleerrtt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ The storage_moved_failed_alert is generated when an attempt to move the │ │ │ │ storage, via _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_m_o_v_e___s_t_o_r_a_g_e_(_), fails. │ │ │ │ struct storage_moved_failed_alert final : torrent_alert │ │ │ │ @@ -2199,24 +2199,24 @@ │ │ │ │ ************ ddhhtt__lliivvee__nnooddeess__aalleerrtt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ posted in response to a call to session::dht_live_nodes(). It contains the live │ │ │ │ nodes from the DHT routing table of one of the DHT nodes running locally. │ │ │ │ struct dht_live_nodes_alert final : alert │ │ │ │ { │ │ │ │ std::string mmeessssaaggee () const override; │ │ │ │ - int nnuumm__nnooddeess () const; │ │ │ │ std::vector> nnooddeess () const; │ │ │ │ + int nnuumm__nnooddeess () const; │ │ │ │ │ │ │ │ static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category::dht; │ │ │ │ sha1_hash node_id; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** nnooddeess(()) nnuumm__nnooddeess(()) ********** │ │ │ │ -int nnuumm__nnooddeess () const; │ │ │ │ std::vector> nnooddeess () const; │ │ │ │ +int nnuumm__nnooddeess () const; │ │ │ │ the number of nodes in the routing table and the actual nodes. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ node_id │ │ │ │ the local DHT node's node-ID this routing table belongs to │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ sseessssiioonn__ssttaattss__hheeaaddeerr__aalleerrtt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ @@ -2237,30 +2237,30 @@ │ │ │ │ ************ ddhhtt__ssaammppllee__iinnffoohhaasshheess__aalleerrtt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ posted as a response to a call to session::dht_sample_infohashes() with the │ │ │ │ information from the DHT response message. │ │ │ │ struct dht_sample_infohashes_alert final : alert │ │ │ │ { │ │ │ │ std::string mmeessssaaggee () const override; │ │ │ │ - std::vector ssaammpplleess () const; │ │ │ │ int nnuumm__ssaammpplleess () const; │ │ │ │ + std::vector ssaammpplleess () const; │ │ │ │ int nnuumm__nnooddeess () const; │ │ │ │ std::vector> nnooddeess () const; │ │ │ │ │ │ │ │ static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category:: │ │ │ │ dht_operation; │ │ │ │ sha1_hash node_id; │ │ │ │ aux::noexcept_movable endpoint; │ │ │ │ time_duration const interval; │ │ │ │ int const num_infohashes; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ssaammpplleess(()) nnuumm__ssaammpplleess(()) ********** │ │ │ │ -std::vector ssaammpplleess () const; │ │ │ │ +********** nnuumm__ssaammpplleess(()) ssaammpplleess(()) ********** │ │ │ │ int nnuumm__ssaammpplleess () const; │ │ │ │ +std::vector ssaammpplleess () const; │ │ │ │ returns the number of info-hashes returned by the node, as well as the actual │ │ │ │ info-hashes. num_samples() is more efficient than samples().size(). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** nnuumm__nnooddeess(()) ********** │ │ │ │ int nnuumm__nnooddeess () const; │ │ │ │ The total number of nodes returned by nodes(). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ @@ -2305,17 +2305,17 @@ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_l_e_r_t___t_y_p_e_s_._h_p_p" │ │ │ │ this _a_l_e_r_t is posted to indicate to the client that some alerts were dropped. │ │ │ │ Dropped meaning that the _a_l_e_r_t failed to be delivered to the client. The most │ │ │ │ common cause of such failure is that the internal _a_l_e_r_t queue grew too big │ │ │ │ (controlled by alert_queue_size). │ │ │ │ struct alerts_dropped_alert final : alert │ │ │ │ { │ │ │ │ - std::string mmeessssaaggee () const override; │ │ │ │ ssttaattiicc__aasssseerrtt (num_alert_types <= abi_alert_count, "need to increase bitset. │ │ │ │ This is an ABI break"); │ │ │ │ + std::string mmeessssaaggee () const override; │ │ │ │ │ │ │ │ static constexpr alert_category_t ssttaattiicc__ccaatteeggoorryy = alert_category::error; │ │ │ │ std::bitset dropped_alerts; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ dropped_alerts │ │ │ │ a bitmask indicating which alerts were dropped. Each bit represents the │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Bdecoding.html │ │ │ @@ -30,21 +30,21 @@ │ │ │ │ │ │

    home

    │ │ │
    │ │ │

    Table of contents

    │ │ │
      │ │ │
    • bdecode_node
        │ │ │
      • bdecode_node()
      • │ │ │ -
      • operator=() bdecode_node()
      • │ │ │ +
      • bdecode_node() operator=()
      • │ │ │
      • type()
      • │ │ │
      • bool()
      • │ │ │
      • non_owning()
      • │ │ │
      • data_offset() data_section()
      • │ │ │ -
      • list_at() list_size() list_int_value_at() list_string_value_at()
      • │ │ │ -
      • dict_at_node() dict_find_int_value() dict_at() dict_find() dict_find_string() dict_find_dict() dict_find_list() dict_find_string_value() dict_find_int() dict_size()
      • │ │ │ +
      • list_int_value_at() list_at() list_size() list_string_value_at()
      • │ │ │ +
      • dict_find_int() dict_at() dict_find() dict_at_node() dict_find_dict() dict_find_list() dict_find_string() dict_find_int_value() dict_size() dict_find_string_value()
      • │ │ │
      • int_value()
      • │ │ │
      • string_value() string_length() string_ptr() string_offset()
      • │ │ │
      • clear()
      • │ │ │
      • swap()
      • │ │ │
      • reserve()
      • │ │ │
      • switch_underlying_buffer()
      • │ │ │
      • has_soft_error()
      • │ │ │ @@ -62,46 +62,46 @@ │ │ │ to be able to copy it as a reference for instance). For that, use the │ │ │ non_owning() member function.

        │ │ │

        There are 5 different types of nodes, see type_t.

        │ │ │
        │ │ │  struct bdecode_node
        │ │ │  {
        │ │ │     bdecode_node () = default;
        │ │ │ -   bdecode_node& operator= (bdecode_node&&) & = default;
        │ │ │ +   bdecode_node (bdecode_node&&) noexcept;
        │ │ │     bdecode_node& operator= (bdecode_node const&) &;
        │ │ │ +   bdecode_node& operator= (bdecode_node&&) & = default;
        │ │ │     bdecode_node (bdecode_node const&);
        │ │ │ -   bdecode_node (bdecode_node&&) noexcept;
        │ │ │     type_t type () const noexcept;
        │ │ │     explicit operator bool () const noexcept;
        │ │ │     bdecode_node non_owning () const;
        │ │ │ -   span<char const> data_section () const noexcept;
        │ │ │     std::ptrdiff_t data_offset () const noexcept;
        │ │ │ +   span<char const> data_section () const noexcept;
        │ │ │ +   bdecode_node list_at (int i) const;
        │ │ │     string_view list_string_value_at (int i
        │ │ │        , string_view default_val = string_view()) const;
        │ │ │ +   int list_size () const;
        │ │ │     std::int64_t list_int_value_at (int i
        │ │ │        , std::int64_t default_val = 0) const;
        │ │ │ -   bdecode_node list_at (int i) const;
        │ │ │ -   int list_size () const;
        │ │ │     string_view dict_find_string_value (string_view key
        │ │ │        , string_view default_value = string_view()) const;
        │ │ │ -   bdecode_node dict_find_int (string_view key) const;
        │ │ │ +   std::pair<string_view, bdecode_node> dict_at (int i) const;
        │ │ │ +   int dict_size () const;
        │ │ │     bdecode_node dict_find (string_view key) const;
        │ │ │ +   bdecode_node dict_find_string (string_view key) const;
        │ │ │     bdecode_node dict_find_dict (string_view key) const;
        │ │ │     std::pair<bdecode_node, bdecode_node> dict_at_node (int i) const;
        │ │ │ -   bdecode_node dict_find_string (string_view key) const;
        │ │ │ +   bdecode_node dict_find_int (string_view key) const;
        │ │ │     std::int64_t dict_find_int_value (string_view key
        │ │ │        , std::int64_t default_val = 0) const;
        │ │ │ -   std::pair<string_view, bdecode_node> dict_at (int i) const;
        │ │ │     bdecode_node dict_find_list (string_view key) const;
        │ │ │ -   int dict_size () const;
        │ │ │     std::int64_t int_value () const;
        │ │ │ +   string_view string_value () const;
        │ │ │ +   char const* string_ptr () const;
        │ │ │     int string_length () const;
        │ │ │     std::ptrdiff_t string_offset () const;
        │ │ │ -   char const* string_ptr () const;
        │ │ │ -   string_view string_value () const;
        │ │ │     void clear ();
        │ │ │     void swap (bdecode_node& n);
        │ │ │     void reserve (int tokens);
        │ │ │     void switch_underlying_buffer (char const* buf) noexcept;
        │ │ │     bool has_soft_error (span<char> error) const;
        │ │ │  
        │ │ │     enum type_t
        │ │ │ @@ -116,23 +116,23 @@
        │ │ │  
        │ │ │ [report issue]
        │ │ │

        bdecode_node()

        │ │ │
        │ │ │  bdecode_node () = default;
        │ │ │  
        │ │ │

        creates a default constructed node, it will have the type none_t.

        │ │ │ - │ │ │ -[report issue]
        │ │ │ -
        │ │ │ -

        operator=() bdecode_node()

        │ │ │ + │ │ │ +[report issue]
        │ │ │ +
        │ │ │ +

        bdecode_node() operator=()

        │ │ │
        │ │ │ -bdecode_node& operator= (bdecode_node&&) & = default;
        │ │ │ +bdecode_node (bdecode_node&&) noexcept;
        │ │ │  bdecode_node& operator= (bdecode_node const&) &;
        │ │ │ +bdecode_node& operator= (bdecode_node&&) & = default;
        │ │ │  bdecode_node (bdecode_node const&);
        │ │ │ -bdecode_node (bdecode_node&&) noexcept;
        │ │ │  
        │ │ │

        For owning nodes, the copy will create a copy of the tree, but the │ │ │ underlying buffer remains the same.

        │ │ │ [report issue]
        │ │ │
        │ │ │

        type()

        │ │ │
        │ │ │ @@ -141,80 +141,80 @@
        │ │ │  

        the type of this node. See type_t.

        │ │ │ [report issue]
        │ │ │
        │ │ │

        bool()

        │ │ │
        │ │ │  explicit operator bool () const noexcept;
        │ │ │  
        │ │ │ -

        returns true if type() != none_t.

        │ │ │ +

        returns true if type() != none_t.

        │ │ │ [report issue]
        │ │ │
        │ │ │

        non_owning()

        │ │ │
        │ │ │  bdecode_node non_owning () const;
        │ │ │  
        │ │ │

        return a non-owning reference to this node. This is useful to refer to │ │ │ the root node without copying it in assignments.

        │ │ │ │ │ │ [report issue]
        │ │ │
        │ │ │

        data_offset() data_section()

        │ │ │
        │ │ │ -span<char const> data_section () const noexcept;
        │ │ │  std::ptrdiff_t data_offset () const noexcept;
        │ │ │ +span<char const> data_section () const noexcept;
        │ │ │  
        │ │ │

        returns the buffer and length of the section in the original bencoded │ │ │ buffer where this node is defined. For a dictionary for instance, this │ │ │ starts with d and ends with e, and has all the content of the │ │ │ dictionary in between. │ │ │ the data_offset() function returns the byte-offset to this node in, │ │ │ starting from the beginning of the buffer that was parsed.

        │ │ │ + │ │ │ │ │ │ │ │ │ - │ │ │ -[report issue]
        │ │ │ -
        │ │ │ -

        list_at() list_size() list_int_value_at() list_string_value_at()

        │ │ │ +[report issue]
        │ │ │ +
        │ │ │ +

        list_int_value_at() list_at() list_size() list_string_value_at()

        │ │ │
        │ │ │ +bdecode_node list_at (int i) const;
        │ │ │  string_view list_string_value_at (int i
        │ │ │        , string_view default_val = string_view()) const;
        │ │ │ +int list_size () const;
        │ │ │  std::int64_t list_int_value_at (int i
        │ │ │        , std::int64_t default_val = 0) const;
        │ │ │ -bdecode_node list_at (int i) const;
        │ │ │ -int list_size () const;
        │ │ │  
        │ │ │

        functions with the list_ prefix operate on lists. These functions are │ │ │ only valid if type() == list_t. list_at() returns the item │ │ │ in the list at index i. i may not be greater than or equal to the │ │ │ size of the list. size() returns the size of the list.

        │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ -[report issue]
        │ │ │ -
        │ │ │ -

        dict_at_node() dict_find_int_value() dict_at() dict_find() dict_find_string() dict_find_dict() dict_find_list() dict_find_string_value() dict_find_int() dict_size()

        │ │ │ + │ │ │ + │ │ │ + │ │ │ +[report issue]
        │ │ │ +
        │ │ │ +

        dict_find_int() dict_at() dict_find() dict_at_node() dict_find_dict() dict_find_list() dict_find_string() dict_find_int_value() dict_size() dict_find_string_value()

        │ │ │
        │ │ │  string_view dict_find_string_value (string_view key
        │ │ │        , string_view default_value = string_view()) const;
        │ │ │ -bdecode_node dict_find_int (string_view key) const;
        │ │ │ +std::pair<string_view, bdecode_node> dict_at (int i) const;
        │ │ │ +int dict_size () const;
        │ │ │  bdecode_node dict_find (string_view key) const;
        │ │ │ +bdecode_node dict_find_string (string_view key) const;
        │ │ │  bdecode_node dict_find_dict (string_view key) const;
        │ │ │  std::pair<bdecode_node, bdecode_node> dict_at_node (int i) const;
        │ │ │ -bdecode_node dict_find_string (string_view key) const;
        │ │ │ +bdecode_node dict_find_int (string_view key) const;
        │ │ │  std::int64_t dict_find_int_value (string_view key
        │ │ │        , std::int64_t default_val = 0) const;
        │ │ │ -std::pair<string_view, bdecode_node> dict_at (int i) const;
        │ │ │  bdecode_node dict_find_list (string_view key) const;
        │ │ │ -int dict_size () const;
        │ │ │  
        │ │ │

        Functions with the dict_ prefix operates on dictionaries. They are │ │ │ only valid if type() == dict_t. In case a key you're looking up │ │ │ contains a 0 byte, you cannot use the 0-terminated string overloads, │ │ │ but have to use string_view instead. dict_find_list will return a │ │ │ valid bdecode_node if the key is found _and_ it is a list. Otherwise │ │ │ it will return a default-constructed bdecode_node.

        │ │ │ @@ -236,18 +236,18 @@ │ │ │ │ │ │ │ │ │ │ │ │ [report issue]
        │ │ │
        │ │ │

        string_value() string_length() string_ptr() string_offset()

        │ │ │
        │ │ │ +string_view string_value () const;
        │ │ │ +char const* string_ptr () const;
        │ │ │  int string_length () const;
        │ │ │  std::ptrdiff_t string_offset () const;
        │ │ │ -char const* string_ptr () const;
        │ │ │ -string_view string_value () const;
        │ │ │  
        │ │ │

        these functions are only valid if type() == string_t. They return │ │ │ the string values. Note that string_ptr() is not 0-terminated. │ │ │ string_length() returns the number of bytes in the string. │ │ │ string_offset() returns the byte offset from the start of the parsed │ │ │ bencoded buffer this string can be found.

        │ │ │ [report issue]
        │ │ │ @@ -345,20 +345,20 @@ │ │ │

        print the bencoded structure in a human-readable format to a string │ │ │ that's returned.

        │ │ │ [report issue]
    │ │ │
    │ │ │

    bdecode()

    │ │ │

    Declared in "libtorrent/bdecode.hpp"

    │ │ │
    │ │ │ -bdecode_node bdecode (span<char const> buffer
    │ │ │ +int bdecode (char const* start, char const* end, bdecode_node& ret
    │ │ │     , error_code& ec, int* error_pos = nullptr, int depth_limit = 100
    │ │ │     , int token_limit = 2000000);
    │ │ │  bdecode_node bdecode (span<char const> buffer
    │ │ │     , int depth_limit = 100, int token_limit = 2000000);
    │ │ │ -int bdecode (char const* start, char const* end, bdecode_node& ret
    │ │ │ +bdecode_node bdecode (span<char const> buffer
    │ │ │     , error_code& ec, int* error_pos = nullptr, int depth_limit = 100
    │ │ │     , int token_limit = 2000000);
    │ │ │  
    │ │ │

    This function decodes/parses bdecoded data (for example a .torrent file). │ │ │ The data structure is returned in the ret argument. the buffer to parse │ │ │ is specified by the start of the buffer as well as the end, i.e. one │ │ │ byte past the end. If the buffer fails to parse, the function returns a │ │ │ ├── html2text {} │ │ │ │ @@ -1,23 +1,23 @@ │ │ │ │ > │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.0.14 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ * _b_d_e_c_o_d_e___n_o_d_e │ │ │ │ o _b_d_e_c_o_d_e___n_o_d_e_(_) │ │ │ │ - o _o_p_e_r_a_t_o_r_=_(_)_ _b_d_e_c_o_d_e___n_o_d_e_(_) │ │ │ │ + o _b_d_e_c_o_d_e___n_o_d_e_(_)_ _o_p_e_r_a_t_o_r_=_(_) │ │ │ │ o _t_y_p_e_(_) │ │ │ │ o _b_o_o_l_(_) │ │ │ │ o _n_o_n___o_w_n_i_n_g_(_) │ │ │ │ o _d_a_t_a___o_f_f_s_e_t_(_)_ _d_a_t_a___s_e_c_t_i_o_n_(_) │ │ │ │ - o _l_i_s_t___a_t_(_)_ _l_i_s_t___s_i_z_e_(_)_ _l_i_s_t___i_n_t___v_a_l_u_e___a_t_(_)_ _l_i_s_t___s_t_r_i_n_g___v_a_l_u_e___a_t_(_) │ │ │ │ - o _d_i_c_t___a_t___n_o_d_e_(_)_ _d_i_c_t___f_i_n_d___i_n_t___v_a_l_u_e_(_)_ _d_i_c_t___a_t_(_)_ _d_i_c_t___f_i_n_d_(_) │ │ │ │ - _d_i_c_t___f_i_n_d___s_t_r_i_n_g_(_)_ _d_i_c_t___f_i_n_d___d_i_c_t_(_)_ _d_i_c_t___f_i_n_d___l_i_s_t_(_) │ │ │ │ - _d_i_c_t___f_i_n_d___s_t_r_i_n_g___v_a_l_u_e_(_)_ _d_i_c_t___f_i_n_d___i_n_t_(_)_ _d_i_c_t___s_i_z_e_(_) │ │ │ │ + o _l_i_s_t___i_n_t___v_a_l_u_e___a_t_(_)_ _l_i_s_t___a_t_(_)_ _l_i_s_t___s_i_z_e_(_)_ _l_i_s_t___s_t_r_i_n_g___v_a_l_u_e___a_t_(_) │ │ │ │ + o _d_i_c_t___f_i_n_d___i_n_t_(_)_ _d_i_c_t___a_t_(_)_ _d_i_c_t___f_i_n_d_(_)_ _d_i_c_t___a_t___n_o_d_e_(_)_ _d_i_c_t___f_i_n_d___d_i_c_t │ │ │ │ + _(_)_ _d_i_c_t___f_i_n_d___l_i_s_t_(_)_ _d_i_c_t___f_i_n_d___s_t_r_i_n_g_(_)_ _d_i_c_t___f_i_n_d___i_n_t___v_a_l_u_e_(_) │ │ │ │ + _d_i_c_t___s_i_z_e_(_)_ _d_i_c_t___f_i_n_d___s_t_r_i_n_g___v_a_l_u_e_(_) │ │ │ │ o _i_n_t___v_a_l_u_e_(_) │ │ │ │ o _s_t_r_i_n_g___v_a_l_u_e_(_)_ _s_t_r_i_n_g___l_e_n_g_t_h_(_)_ _s_t_r_i_n_g___p_t_r_(_)_ _s_t_r_i_n_g___o_f_f_s_e_t_(_) │ │ │ │ o _c_l_e_a_r_(_) │ │ │ │ o _s_w_a_p_(_) │ │ │ │ o _r_e_s_e_r_v_e_(_) │ │ │ │ o _s_w_i_t_c_h___u_n_d_e_r_l_y_i_n_g___b_u_f_f_e_r_(_) │ │ │ │ o _h_a_s___s_o_f_t___e_r_r_o_r_(_) │ │ │ │ @@ -30,46 +30,46 @@ │ │ │ │ Sometimes it's important to get a non-owning reference to the root node ( to be │ │ │ │ able to copy it as a reference for instance). For that, use the _n_o_n___o_w_n_i_n_g_(_) │ │ │ │ member function. │ │ │ │ There are 5 different types of nodes, see _t_y_p_e___t. │ │ │ │ struct bdecode_node │ │ │ │ { │ │ │ │ bbddeeccooddee__nnooddee () = default; │ │ │ │ - bdecode_node& ooppeerraattoorr== (bdecode_node&&) & = default; │ │ │ │ + bbddeeccooddee__nnooddee (bdecode_node&&) noexcept; │ │ │ │ bdecode_node& ooppeerraattoorr== (bdecode_node const&) &; │ │ │ │ + bdecode_node& ooppeerraattoorr== (bdecode_node&&) & = default; │ │ │ │ bbddeeccooddee__nnooddee (bdecode_node const&); │ │ │ │ - bbddeeccooddee__nnooddee (bdecode_node&&) noexcept; │ │ │ │ type_t ttyyppee () const noexcept; │ │ │ │ explicit operator bbooooll () const noexcept; │ │ │ │ bdecode_node nnoonn__oowwnniinngg () const; │ │ │ │ - span ddaattaa__sseeccttiioonn () const noexcept; │ │ │ │ std::ptrdiff_t ddaattaa__ooffffsseett () const noexcept; │ │ │ │ + span ddaattaa__sseeccttiioonn () const noexcept; │ │ │ │ + bdecode_node lliisstt__aatt (int i) const; │ │ │ │ string_view lliisstt__ssttrriinngg__vvaalluuee__aatt (int i │ │ │ │ , string_view default_val = string_view()) const; │ │ │ │ + int lliisstt__ssiizzee () const; │ │ │ │ std::int64_t lliisstt__iinntt__vvaalluuee__aatt (int i │ │ │ │ , std::int64_t default_val = 0) const; │ │ │ │ - bdecode_node lliisstt__aatt (int i) const; │ │ │ │ - int lliisstt__ssiizzee () const; │ │ │ │ string_view ddiicctt__ffiinndd__ssttrriinngg__vvaalluuee (string_view key │ │ │ │ , string_view default_value = string_view()) const; │ │ │ │ - bdecode_node ddiicctt__ffiinndd__iinntt (string_view key) const; │ │ │ │ + std::pair ddiicctt__aatt (int i) const; │ │ │ │ + int ddiicctt__ssiizzee () const; │ │ │ │ bdecode_node ddiicctt__ffiinndd (string_view key) const; │ │ │ │ + bdecode_node ddiicctt__ffiinndd__ssttrriinngg (string_view key) const; │ │ │ │ bdecode_node ddiicctt__ffiinndd__ddiicctt (string_view key) const; │ │ │ │ std::pair ddiicctt__aatt__nnooddee (int i) const; │ │ │ │ - bdecode_node ddiicctt__ffiinndd__ssttrriinngg (string_view key) const; │ │ │ │ + bdecode_node ddiicctt__ffiinndd__iinntt (string_view key) const; │ │ │ │ std::int64_t ddiicctt__ffiinndd__iinntt__vvaalluuee (string_view key │ │ │ │ , std::int64_t default_val = 0) const; │ │ │ │ - std::pair ddiicctt__aatt (int i) const; │ │ │ │ bdecode_node ddiicctt__ffiinndd__lliisstt (string_view key) const; │ │ │ │ - int ddiicctt__ssiizzee () const; │ │ │ │ std::int64_t iinntt__vvaalluuee () const; │ │ │ │ + string_view ssttrriinngg__vvaalluuee () const; │ │ │ │ + char const* ssttrriinngg__ppttrr () const; │ │ │ │ int ssttrriinngg__lleennggtthh () const; │ │ │ │ std::ptrdiff_t ssttrriinngg__ooffffsseett () const; │ │ │ │ - char const* ssttrriinngg__ppttrr () const; │ │ │ │ - string_view ssttrriinngg__vvaalluuee () const; │ │ │ │ void cclleeaarr (); │ │ │ │ void sswwaapp (bdecode_node& n); │ │ │ │ void rreesseerrvvee (int tokens); │ │ │ │ void sswwiittcchh__uunnddeerrllyyiinngg__bbuuffffeerr (char const* buf) noexcept; │ │ │ │ bool hhaass__ssoofftt__eerrrroorr (span error) const; │ │ │ │ │ │ │ │ enum type_t │ │ │ │ @@ -82,19 +82,19 @@ │ │ │ │ }; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** bbddeeccooddee__nnooddee(()) ********** │ │ │ │ bbddeeccooddee__nnooddee () = default; │ │ │ │ creates a default constructed node, it will have the type none_t. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr==(()) bbddeeccooddee__nnooddee(()) ********** │ │ │ │ -bdecode_node& ooppeerraattoorr== (bdecode_node&&) & = default; │ │ │ │ +********** bbddeeccooddee__nnooddee(()) ooppeerraattoorr==(()) ********** │ │ │ │ +bbddeeccooddee__nnooddee (bdecode_node&&) noexcept; │ │ │ │ bdecode_node& ooppeerraattoorr== (bdecode_node const&) &; │ │ │ │ +bdecode_node& ooppeerraattoorr== (bdecode_node&&) & = default; │ │ │ │ bbddeeccooddee__nnooddee (bdecode_node const&); │ │ │ │ -bbddeeccooddee__nnooddee (bdecode_node&&) noexcept; │ │ │ │ For owning nodes, the copy will create a copy of the tree, but the underlying │ │ │ │ buffer remains the same. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ttyyppee(()) ********** │ │ │ │ type_t ttyyppee () const noexcept; │ │ │ │ the type of this node. See _t_y_p_e___t. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ @@ -104,49 +104,49 @@ │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** nnoonn__oowwnniinngg(()) ********** │ │ │ │ bdecode_node nnoonn__oowwnniinngg () const; │ │ │ │ return a non-owning reference to this node. This is useful to refer to the root │ │ │ │ node without copying it in assignments. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ddaattaa__ooffffsseett(()) ddaattaa__sseeccttiioonn(()) ********** │ │ │ │ -span ddaattaa__sseeccttiioonn () const noexcept; │ │ │ │ std::ptrdiff_t ddaattaa__ooffffsseett () const noexcept; │ │ │ │ +span ddaattaa__sseeccttiioonn () const noexcept; │ │ │ │ returns the buffer and length of the section in the original bencoded buffer │ │ │ │ where this node is defined. For a dictionary for instance, this starts with d │ │ │ │ and ends with e, and has all the content of the dictionary in between. the │ │ │ │ data_offset() function returns the byte-offset to this node in, starting from │ │ │ │ the beginning of the buffer that was parsed. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** lliisstt__aatt(()) lliisstt__ssiizzee(()) lliisstt__iinntt__vvaalluuee__aatt(()) lliisstt__ssttrriinngg__vvaalluuee__aatt(()) ********** │ │ │ │ +********** lliisstt__iinntt__vvaalluuee__aatt(()) lliisstt__aatt(()) lliisstt__ssiizzee(()) lliisstt__ssttrriinngg__vvaalluuee__aatt(()) ********** │ │ │ │ +bdecode_node lliisstt__aatt (int i) const; │ │ │ │ string_view lliisstt__ssttrriinngg__vvaalluuee__aatt (int i │ │ │ │ , string_view default_val = string_view()) const; │ │ │ │ +int lliisstt__ssiizzee () const; │ │ │ │ std::int64_t lliisstt__iinntt__vvaalluuee__aatt (int i │ │ │ │ , std::int64_t default_val = 0) const; │ │ │ │ -bdecode_node lliisstt__aatt (int i) const; │ │ │ │ -int lliisstt__ssiizzee () const; │ │ │ │ functions with the list_ prefix operate on lists. These functions are only │ │ │ │ valid if type() == list_t. list_at() returns the item in the list at index i. i │ │ │ │ may not be greater than or equal to the size of the list. size() returns the │ │ │ │ size of the list. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddiicctt__aatt__nnooddee(()) ddiicctt__ffiinndd__iinntt__vvaalluuee(()) ddiicctt__aatt(()) ddiicctt__ffiinndd(()) │ │ │ │ -ddiicctt__ffiinndd__ssttrriinngg(()) ddiicctt__ffiinndd__ddiicctt(()) ddiicctt__ffiinndd__lliisstt(()) ddiicctt__ffiinndd__ssttrriinngg__vvaalluuee(()) │ │ │ │ -ddiicctt__ffiinndd__iinntt(()) ddiicctt__ssiizzee(()) ********** │ │ │ │ +********** ddiicctt__ffiinndd__iinntt(()) ddiicctt__aatt(()) ddiicctt__ffiinndd(()) ddiicctt__aatt__nnooddee(()) ddiicctt__ffiinndd__ddiicctt(()) │ │ │ │ +ddiicctt__ffiinndd__lliisstt(()) ddiicctt__ffiinndd__ssttrriinngg(()) ddiicctt__ffiinndd__iinntt__vvaalluuee(()) ddiicctt__ssiizzee(()) │ │ │ │ +ddiicctt__ffiinndd__ssttrriinngg__vvaalluuee(()) ********** │ │ │ │ string_view ddiicctt__ffiinndd__ssttrriinngg__vvaalluuee (string_view key │ │ │ │ , string_view default_value = string_view()) const; │ │ │ │ -bdecode_node ddiicctt__ffiinndd__iinntt (string_view key) const; │ │ │ │ +std::pair ddiicctt__aatt (int i) const; │ │ │ │ +int ddiicctt__ssiizzee () const; │ │ │ │ bdecode_node ddiicctt__ffiinndd (string_view key) const; │ │ │ │ +bdecode_node ddiicctt__ffiinndd__ssttrriinngg (string_view key) const; │ │ │ │ bdecode_node ddiicctt__ffiinndd__ddiicctt (string_view key) const; │ │ │ │ std::pair ddiicctt__aatt__nnooddee (int i) const; │ │ │ │ -bdecode_node ddiicctt__ffiinndd__ssttrriinngg (string_view key) const; │ │ │ │ +bdecode_node ddiicctt__ffiinndd__iinntt (string_view key) const; │ │ │ │ std::int64_t ddiicctt__ffiinndd__iinntt__vvaalluuee (string_view key │ │ │ │ , std::int64_t default_val = 0) const; │ │ │ │ -std::pair ddiicctt__aatt (int i) const; │ │ │ │ bdecode_node ddiicctt__ffiinndd__lliisstt (string_view key) const; │ │ │ │ -int ddiicctt__ssiizzee () const; │ │ │ │ Functions with the dict_ prefix operates on dictionaries. They are only valid │ │ │ │ if type() == dict_t. In case a key you're looking up contains a 0 byte, you │ │ │ │ cannot use the 0-terminated string overloads, but have to use string_view │ │ │ │ instead. dict_find_list will return a valid bdecode_node if the key is found │ │ │ │ _and_ it is a list. Otherwise it will return a default-constructed │ │ │ │ _b_d_e_c_o_d_e___n_o_d_e. │ │ │ │ Functions with the _value suffix return the value of the node directly, rather │ │ │ │ @@ -159,18 +159,18 @@ │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** iinntt__vvaalluuee(()) ********** │ │ │ │ std::int64_t iinntt__vvaalluuee () const; │ │ │ │ this function is only valid if type() == int_t. It returns the value of the │ │ │ │ integer. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ssttrriinngg__vvaalluuee(()) ssttrriinngg__lleennggtthh(()) ssttrriinngg__ppttrr(()) ssttrriinngg__ooffffsseett(()) ********** │ │ │ │ +string_view ssttrriinngg__vvaalluuee () const; │ │ │ │ +char const* ssttrriinngg__ppttrr () const; │ │ │ │ int ssttrriinngg__lleennggtthh () const; │ │ │ │ std::ptrdiff_t ssttrriinngg__ooffffsseett () const; │ │ │ │ -char const* ssttrriinngg__ppttrr () const; │ │ │ │ -string_view ssttrriinngg__vvaalluuee () const; │ │ │ │ these functions are only valid if type() == string_t. They return the string │ │ │ │ values. Note that string_ptr() is nnoott 0-terminated. string_length() returns the │ │ │ │ number of bytes in the string. string_offset() returns the byte offset from the │ │ │ │ start of the parsed bencoded buffer this string can be found. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** cclleeaarr(()) ********** │ │ │ │ void cclleeaarr (); │ │ │ │ @@ -214,20 +214,20 @@ │ │ │ │ std::string pprriinntt__eennttrryy (bdecode_node const& e │ │ │ │ , bool single_line = false, int indent = 0); │ │ │ │ print the bencoded structure in a human-readable format to a string that's │ │ │ │ returned. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ bbddeeccooddee(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_b_d_e_c_o_d_e_._h_p_p" │ │ │ │ -bdecode_node bbddeeccooddee (span buffer │ │ │ │ +int bbddeeccooddee (char const* start, char const* end, bdecode_node& ret │ │ │ │ , error_code& ec, int* error_pos = nullptr, int depth_limit = 100 │ │ │ │ , int token_limit = 2000000); │ │ │ │ bdecode_node bbddeeccooddee (span buffer │ │ │ │ , int depth_limit = 100, int token_limit = 2000000); │ │ │ │ -int bbddeeccooddee (char const* start, char const* end, bdecode_node& ret │ │ │ │ +bdecode_node bbddeeccooddee (span buffer │ │ │ │ , error_code& ec, int* error_pos = nullptr, int depth_limit = 100 │ │ │ │ , int token_limit = 2000000); │ │ │ │ This function decodes/parses bdecoded data (for example a .torrent file). The │ │ │ │ data structure is returned in the ret argument. the buffer to parse is │ │ │ │ specified by the start of the buffer as well as the end, i.e. one byte past the │ │ │ │ end. If the buffer fails to parse, the function returns a non-zero value and │ │ │ │ fills in ec with the error code. The optional argument error_pos, if set to │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Bencoding.html │ │ │ @@ -34,28 +34,28 @@ │ │ │

    │ │ │
    │ │ │

    Bencoding is a common representation in bittorrent used for dictionary, │ │ │ -list, int and string hierarchies. It's used to encode .torrent files and │ │ │ +list, int and string hierarchies. It's used to encode .torrent files and │ │ │ some messages in the network protocol. libtorrent also uses it to store │ │ │ settings, resume data and other session state.

    │ │ │

    Strings in bencoded structures do not necessarily represent text. │ │ │ Strings are raw byte buffers of a certain length. If a string is meant to be │ │ │ interpreted as text, it is required to be UTF-8 encoded. See BEP 3.

    │ │ │

    The function for decoding bencoded data bdecode(), returning a bdecode_node. │ │ │ This function builds a tree that points back into the original buffer. The │ │ │ @@ -69,44 +69,44 @@ │ │ │

    The entry class represents one node in a bencoded hierarchy. It works as a │ │ │ variant type, it can be either a list, a dictionary (std::map), an integer │ │ │ or a string.

    │ │ │
    │ │ │  class entry
    │ │ │  {
    │ │ │     data_type type () const;
    │ │ │ -   entry (list_type);
    │ │ │ -   entry (dictionary_type);
    │ │ │     entry (integer_type);
    │ │ │ -   entry (span<char const>);
    │ │ │     entry (preformatted_type);
    │ │ │ +   entry (span<char const>);
    │ │ │ +   entry (list_type);
    │ │ │ +   entry (dictionary_type);
    │ │ │     entry (data_type t);
    │ │ │     entry (bdecode_node const& n);
    │ │ │ +   entry& operator= (entry const&) &;
    │ │ │ +   entry& operator= (bdecode_node const&) &;
    │ │ │     entry& operator= (entry&&) & noexcept;
    │ │ │ -   entry& operator= (preformatted_type) &;
    │ │ │     entry& operator= (list_type) &;
    │ │ │     entry& operator= (integer_type) &;
    │ │ │ -   entry& operator= (span<char const>) &;
    │ │ │     entry& operator= (dictionary_type) &;
    │ │ │ -   entry& operator= (entry const&) &;
    │ │ │ -   entry& operator= (bdecode_node const&) &;
    │ │ │ -   preformatted_type const& preformatted () const;
    │ │ │ -   integer_type const& integer () const;
    │ │ │ -   dictionary_type const& dict () const;
    │ │ │ -   integer_type& integer ();
    │ │ │ -   string_type& string ();
    │ │ │ +   entry& operator= (span<char const>) &;
    │ │ │ +   entry& operator= (preformatted_type) &;
    │ │ │     dictionary_type& dict ();
    │ │ │ +   integer_type& integer ();
    │ │ │ +   list_type const& list () const;
    │ │ │     string_type const& string () const;
    │ │ │     preformatted_type& preformatted ();
    │ │ │ +   preformatted_type const& preformatted () const;
    │ │ │     list_type& list ();
    │ │ │ -   list_type const& list () const;
    │ │ │ +   dictionary_type const& dict () const;
    │ │ │ +   integer_type const& integer () const;
    │ │ │ +   string_type& string ();
    │ │ │     void swap (entry& e);
    │ │ │     entry& operator[] (string_view key);
    │ │ │     entry const& operator[] (string_view key) const;
    │ │ │ -   entry const* find_key (string_view key) const;
    │ │ │     entry* find_key (string_view key);
    │ │ │ +   entry const* find_key (string_view key) const;
    │ │ │     std::string to_string (bool single_line = false) const;
    │ │ │  
    │ │ │     enum data_type
    │ │ │     {
    │ │ │        int_t,
    │ │ │        string_t,
    │ │ │        list_t,
    │ │ │ @@ -122,19 +122,19 @@
    │ │ │  data_type type () const;
    │ │ │  
    │ │ │

    returns the concrete type of the entry

    │ │ │ [report issue]
    │ │ │
    │ │ │

    entry()

    │ │ │
    │ │ │ -entry (list_type);
    │ │ │ -entry (dictionary_type);
    │ │ │  entry (integer_type);
    │ │ │ -entry (span<char const>);
    │ │ │  entry (preformatted_type);
    │ │ │ +entry (span<char const>);
    │ │ │ +entry (list_type);
    │ │ │ +entry (dictionary_type);
    │ │ │  
    │ │ │

    constructors directly from a specific type. │ │ │ The content of the argument is copied into the │ │ │ newly constructed entry

    │ │ │ [report issue]
    │ │ │
    │ │ │

    entry()

    │ │ │ @@ -150,43 +150,43 @@ │ │ │ entry (bdecode_node const& n); │ │ │ │ │ │

    construct from bdecode_node parsed form (see bdecode())

    │ │ │ [report issue]
    │ │ │
    │ │ │

    operator=()

    │ │ │
    │ │ │ +entry& operator= (entry const&) &;
    │ │ │ +entry& operator= (bdecode_node const&) &;
    │ │ │  entry& operator= (entry&&) & noexcept;
    │ │ │ -entry& operator= (preformatted_type) &;
    │ │ │  entry& operator= (list_type) &;
    │ │ │  entry& operator= (integer_type) &;
    │ │ │ -entry& operator= (span<char const>) &;
    │ │ │  entry& operator= (dictionary_type) &;
    │ │ │ -entry& operator= (entry const&) &;
    │ │ │ -entry& operator= (bdecode_node const&) &;
    │ │ │ +entry& operator= (span<char const>) &;
    │ │ │ +entry& operator= (preformatted_type) &;
    │ │ │  
    │ │ │

    copies the structure of the right hand side into this │ │ │ entry.

    │ │ │ + │ │ │ │ │ │ │ │ │ - │ │ │ │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    list() preformatted() integer() string() dict()

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    integer() list() preformatted() string() dict()

    │ │ │
    │ │ │ -preformatted_type const& preformatted () const;
    │ │ │ -integer_type const& integer () const;
    │ │ │ -dictionary_type const& dict () const;
    │ │ │ -integer_type& integer ();
    │ │ │ -string_type& string ();
    │ │ │  dictionary_type& dict ();
    │ │ │ +integer_type& integer ();
    │ │ │ +list_type const& list () const;
    │ │ │  string_type const& string () const;
    │ │ │  preformatted_type& preformatted ();
    │ │ │ +preformatted_type const& preformatted () const;
    │ │ │  list_type& list ();
    │ │ │ -list_type const& list () const;
    │ │ │ +dictionary_type const& dict () const;
    │ │ │ +integer_type const& integer () const;
    │ │ │ +string_type& string ();
    │ │ │  
    │ │ │

    The integer(), string(), list() and dict() functions │ │ │ are accessors that return the respective type. If the entry object │ │ │ isn't of the type you request, the accessor will throw │ │ │ system_error. You can ask an entry for its type through the │ │ │ type() function.

    │ │ │

    If you want to create an entry you give it the type you want it to │ │ │ @@ -246,16 +246,16 @@ │ │ │

    The const version of operator[] will only return a reference to an │ │ │ existing element at the given key. If the key is not found, it will │ │ │ throw system_error.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    find_key()

    │ │ │
    │ │ │ -entry const* find_key (string_view key) const;
    │ │ │  entry* find_key (string_view key);
    │ │ │ +entry const* find_key (string_view key) const;
    │ │ │  
    │ │ │

    These functions requires the entry to be a dictionary, if it isn't │ │ │ they will throw system_error.

    │ │ │

    They will look for an element at the given key in the dictionary, if │ │ │ the element cannot be found, they will return nullptr. If an element │ │ │ with the given key is found, the return a pointer to it.

    │ │ │ [report issue]
    │ │ │ @@ -305,24 +305,16 @@ │ │ │ │ │ │ preformatted_t │ │ │ 5 │ │ │   │ │ │ │ │ │ │ │ │ │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    operator<<()

    │ │ │ -

    Declared in "libtorrent/entry.hpp"

    │ │ │ -
    │ │ │ -inline std::ostream& operator<< (std::ostream& os, const entry& e);
    │ │ │ -
    │ │ │ -

    prints the bencoded structure to the ostream as a JSON-style structure.

    │ │ │ [report issue]
    │ │ │ + │ │ │
    │ │ │

    bencode()

    │ │ │

    Declared in "libtorrent/bencode.hpp"

    │ │ │
    │ │ │  template<class OutIt> int bencode (OutIt out, const entry& e);
    │ │ │  
    │ │ │

    This function will encode data to bencoded form.

    │ │ │ @@ -334,14 +326,22 @@ │ │ │ instantiated as ostream_iterator or back_insert_iterator. This │ │ │ function assumes the value_type of the iterator is a char. │ │ │ In order to encode entry e into a buffer, do:

    │ │ │
    │ │ │  std::vector<char> buf;
    │ │ │  bencode(std::back_inserter(buf), e);
    │ │ │  
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    operator<<()

    │ │ │ +

    Declared in "libtorrent/entry.hpp"

    │ │ │ +
    │ │ │ +inline std::ostream& operator<< (std::ostream& os, const entry& e);
    │ │ │ +
    │ │ │ +

    prints the bencoded structure to the ostream as a JSON-style structure.

    │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │
    │ │ │ │ │ │ -
    │ │ │ -

    info_hash_t

    │ │ │ -

    Declared in "libtorrent/info_hash.hpp"

    │ │ │ -

    class holding the info-hash of a torrent. It can hold a v1 info-hash │ │ │ -(SHA-1) or a v2 info-hash (SHA-256) or both.

    │ │ │ -
    │ │ │ -

    Note

    │ │ │ -

    If has_v2() is false then the v1 hash might actually be a truncated │ │ │ -v2 hash

    │ │ │ -
    │ │ │ -
    │ │ │ -struct info_hash_t
    │ │ │ -{
    │ │ │ -   info_hash_t () noexcept = default;
    │ │ │ -   info_hash_t (sha1_hash h1, sha256_hash h2) noexcept;
    │ │ │ -   explicit info_hash_t (sha1_hash h1) noexcept;
    │ │ │ -   explicit info_hash_t (sha256_hash h2) noexcept;
    │ │ │ -   bool has (protocol_version v) const;
    │ │ │ -   bool has_v1 () const;
    │ │ │ -   bool has_v2 () const;
    │ │ │ -   sha1_hash get (protocol_version v) const;
    │ │ │ -   sha1_hash get_best () const;
    │ │ │ -   friend bool operator!= (info_hash_t const& lhs, info_hash_t const& rhs);
    │ │ │ -   friend bool operator== (info_hash_t const& lhs, info_hash_t const& rhs) noexcept;
    │ │ │ -   bool operator< (info_hash_t const& o) const;
    │ │ │ -   friend std::ostream& operator<< (std::ostream& os, info_hash_t const& ih);
    │ │ │ -
    │ │ │ -   sha1_hash v1;
    │ │ │ -   sha256_hash v2;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    info_hash_t()

    │ │ │ -
    │ │ │ -info_hash_t () noexcept = default;
    │ │ │ -info_hash_t (sha1_hash h1, sha256_hash h2) noexcept;
    │ │ │ -explicit info_hash_t (sha1_hash h1) noexcept;
    │ │ │ -explicit info_hash_t (sha256_hash h2) noexcept;
    │ │ │ -
    │ │ │ -

    The default constructor creates an object that has neither a v1 or v2 │ │ │ -hash.

    │ │ │ -

    For backwards compatibility, make it possible to construct directly │ │ │ -from a v1 hash. This constructor allows implicit conversion from a │ │ │ -v1 hash, but the implicitness is deprecated.

    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    has_v2() has() has_v1()

    │ │ │ -
    │ │ │ -bool has (protocol_version v) const;
    │ │ │ -bool has_v1 () const;
    │ │ │ -bool has_v2 () const;
    │ │ │ -
    │ │ │ -

    returns true if the corresponding info hash is present in this │ │ │ -object.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    get()

    │ │ │ -
    │ │ │ -sha1_hash get (protocol_version v) const;
    │ │ │ -
    │ │ │ -

    returns the has for the specified protocol version

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    get_best()

    │ │ │ -
    │ │ │ -sha1_hash get_best () const;
    │ │ │ -
    │ │ │ -

    returns the v2 (truncated) info-hash, if there is one, otherwise │ │ │ -returns the v1 info-hash

    │ │ │ -[report issue]
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │
    │ │ │ -
    │ │ │ -

    version()

    │ │ │ -

    Declared in "libtorrent/version.hpp"

    │ │ │ +
    │ │ │ +

    load_torrent_parsed() load_torrent_file() load_torrent_buffer()

    │ │ │ +

    Declared in "libtorrent/load_torrent.hpp"

    │ │ │
    │ │ │ -char const* version ();
    │ │ │ +add_torrent_params load_torrent_parsed (
    │ │ │ +   bdecode_node const& torrent_file);
    │ │ │ +add_torrent_params load_torrent_parsed (
    │ │ │ +   bdecode_node const& torrent_file, load_torrent_limits const& cfg);
    │ │ │ +add_torrent_params load_torrent_file (
    │ │ │ +   std::string const& filename, load_torrent_limits const& cfg);
    │ │ │ +add_torrent_params load_torrent_buffer (
    │ │ │ +   span<char const> buffer, load_torrent_limits const& cfg);
    │ │ │ +add_torrent_params load_torrent_file (
    │ │ │ +   std::string const& filename);
    │ │ │ +add_torrent_params load_torrent_buffer (
    │ │ │ +   span<char const> buffer);
    │ │ │  
    │ │ │ -

    returns the libtorrent version as string form in this format: │ │ │ -"<major>.<minor>.<tiny>.<tag>"

    │ │ │ +

    These functions load the content of a .torrent file into an │ │ │ +add_torrent_params object. │ │ │ +The immutable part of a torrent file (the info-dictionary) is stored in │ │ │ +the ti field in the add_torrent_params object (as a torrent_info │ │ │ +object). │ │ │ +The returned object is suitable to be:

    │ │ │ +
    │ │ │ + │ │ │ +
    │ │ │ [report issue]
    │ │ │
    │ │ │

    truncate_files()

    │ │ │

    Declared in "libtorrent/truncate.hpp"

    │ │ │
    │ │ │  void truncate_files (file_storage const& fs, std::string const& save_path, storage_error& ec);
    │ │ │  
    │ │ │

    Truncates files larger than specified in the file_storage, saved under │ │ │ the specified save_path.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    torrent_peer_equal()

    │ │ │ -

    Declared in "libtorrent/torrent_peer.hpp"

    │ │ │ -
    │ │ │ -inline bool torrent_peer_equal (torrent_peer const* lhs, torrent_peer const* rhs);
    │ │ │ -
    │ │ │ [report issue]
    │ │ │
    │ │ │

    make_magnet_uri()

    │ │ │

    Declared in "libtorrent/magnet_uri.hpp"

    │ │ │
    │ │ │  std::string make_magnet_uri (add_torrent_params const& atp);
    │ │ │ -std::string make_magnet_uri (torrent_info const& info);
    │ │ │  std::string make_magnet_uri (torrent_handle const& handle);
    │ │ │ +std::string make_magnet_uri (torrent_info const& info);
    │ │ │  
    │ │ │

    Generates a magnet URI from the specified torrent.

    │ │ │

    Several fields from the add_torrent_params objects are recorded in the │ │ │ magnet link. In order to not include them, they have to be cleared before │ │ │ calling make_magnet_uri(). These fields are used:

    │ │ │
    │ │ │ ti, info_hashes, url_seeds, dht_nodes, │ │ │ @@ -746,47 +763,61 @@ │ │ │ add_torrent_params parse_magnet_uri (string_view uri); │ │ │ │ │ │

    This function parses out information from the magnet link and populates the │ │ │ add_torrent_params object. The overload that does not take an │ │ │ error_code reference will throw a system_error on error │ │ │ The overload taking an add_torrent_params reference will fill in the │ │ │ fields specified in the magnet URI.

    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    load_torrent_buffer() load_torrent_file() load_torrent_parsed()

    │ │ │ -

    Declared in "libtorrent/load_torrent.hpp"

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    torrent_peer_equal()

    │ │ │ +

    Declared in "libtorrent/torrent_peer.hpp"

    │ │ │
    │ │ │ -add_torrent_params load_torrent_buffer (
    │ │ │ -   span<char const> buffer);
    │ │ │ -add_torrent_params load_torrent_file (
    │ │ │ -   std::string const& filename, load_torrent_limits const& cfg);
    │ │ │ -add_torrent_params load_torrent_parsed (
    │ │ │ -   bdecode_node const& torrent_file);
    │ │ │ -add_torrent_params load_torrent_file (
    │ │ │ -   std::string const& filename);
    │ │ │ -add_torrent_params load_torrent_buffer (
    │ │ │ -   span<char const> buffer, load_torrent_limits const& cfg);
    │ │ │ -add_torrent_params load_torrent_parsed (
    │ │ │ -   bdecode_node const& torrent_file, load_torrent_limits const& cfg);
    │ │ │ +inline bool torrent_peer_equal (torrent_peer const* lhs, torrent_peer const* rhs);
    │ │ │  
    │ │ │ -

    These functions load the content of a .torrent file into an │ │ │ -add_torrent_params object. │ │ │ -The immutable part of a torrent file (the info-dictionary) is stored in │ │ │ -the ti field in the add_torrent_params object (as a torrent_info │ │ │ -object). │ │ │ -The returned object is suitable to be:

    │ │ │ -
    │ │ │ - │ │ │ -
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    version()

    │ │ │ +

    Declared in "libtorrent/version.hpp"

    │ │ │ +
    │ │ │ +char const* version ();
    │ │ │ +
    │ │ │ +

    returns the libtorrent version as string form in this format: │ │ │ +"<major>.<minor>.<tiny>.<tag>"

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum protocol_version

    │ │ │ +

    Declared in "libtorrent/info_hash.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    V10The original BitTorrent version, using SHA-1 hashes
    V21Version 2 of the BitTorrent protocol, using SHA-256 hashes
    NUM2 
    │ │ │ [report issue]
    │ │ │
    │ │ │

    enum event_t

    │ │ │

    Declared in "libtorrent/tracker_manager.hpp"

    │ │ │ │ │ │ │ │ │ │ │ │ @@ -818,67 +849,43 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    paused4 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum socket_type_t

    │ │ │ -

    Declared in "libtorrent/socket_type.hpp"

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum connection_type

    │ │ │ +

    Declared in "libtorrent/peer_connection.hpp"

    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ │ │ │
    namevaluedescription
    tcp
    bittorrent0 
    socks5
    url_seed1 
    http
    http_seed2 
    utp3 
    i2p4 
    tcp_ssl5 
    socks5_ssl6 
    http_ssl7 
    utp_ssl8 
    │ │ │ [report issue]
    │ │ │
    │ │ │

    enum portmap_transport

    │ │ │

    Declared in "libtorrent/portmap.hpp"

    │ │ │ │ │ │ @@ -931,72 +938,65 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    udp2 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum connection_type

    │ │ │ -

    Declared in "libtorrent/peer_connection.hpp"

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum socket_type_t

    │ │ │ +

    Declared in "libtorrent/socket_type.hpp"

    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ -
    namevaluedescription
    bittorrent
    tcp0 
    url_seed
    socks51 
    http_seed
    http2 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum protocol_version

    │ │ │ -

    Declared in "libtorrent/info_hash.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │
    namevaluedescription
    utp3 
    V10The original BitTorrent version, using SHA-1 hashes
    i2p4 
    V21Version 2 of the BitTorrent protocol, using SHA-256 hashes
    tcp_ssl5 
    NUM2
    socks5_ssl6 
    http_ssl7 
    utp_ssl8 
    │ │ │ [report issue]
    │ │ │
    │ │ │

    int

    │ │ │ @@ -1009,14 +1009,62 @@ │ │ │
    version_minor
    │ │ │
    the major, minor and tiny versions of libtorrent
    │ │ │ │ │ │
    │ │ │
    version_tiny
    │ │ │
    the major, minor and tiny versions of libtorrent
    │ │ │
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    download_priority_t

    │ │ │ +

    Declared in "libtorrent/download_priority.hpp"

    │ │ │ +
    │ │ │ +
    dont_download
    │ │ │ +
    Don't download the file or piece. Partial pieces may still be downloaded when │ │ │ +setting file priorities.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    default_priority
    │ │ │ +
    The default priority for files and pieces.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    low_priority
    │ │ │ +
    The lowest priority for files and pieces.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    top_priority
    │ │ │ +
    The highest priority for files and pieces.
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    pex_flags_t

    │ │ │ +

    Declared in "libtorrent/pex_flags.hpp"

    │ │ │ +
    │ │ │ +
    pex_encryption
    │ │ │ +
    the peer supports protocol encryption
    │ │ │ +
    │ │ │ +
    │ │ │ +
    pex_seed
    │ │ │ +
    the peer is a seed
    │ │ │ +
    │ │ │ +
    │ │ │ +
    pex_utp
    │ │ │ +
    the peer supports the uTP, transport protocol over UDP.
    │ │ │ +
    │ │ │ +
    │ │ │ +
    pex_holepunch
    │ │ │ +
    the peer supports the holepunch extension If this flag is received from a │ │ │ +peer, it can be used as a rendezvous point in case direct connections to │ │ │ +the peer fail
    │ │ │ +
    │ │ │ +
    │ │ │ +
    pex_lt_v2
    │ │ │ +
    protocol v2 │ │ │ +this is not a standard flag, it is only used internally
    │ │ │ +
    │ │ │ [report issue]
    │ │ │
    │ │ │

    char const*

    │ │ │

    Declared in "libtorrent/version.hpp"

    │ │ │
    │ │ │
    version_str
    │ │ │
    the libtorrent version in string form
    │ │ │ @@ -1259,62 +1307,14 @@ │ │ │ URL. │ │ │
    │ │ │
    │ │ │
    all
    │ │ │
    all torrent flags combined. Can conveniently be used when creating masks │ │ │ for flags
    │ │ │
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    pex_flags_t

    │ │ │ -

    Declared in "libtorrent/pex_flags.hpp"

    │ │ │ -
    │ │ │ -
    pex_encryption
    │ │ │ -
    the peer supports protocol encryption
    │ │ │ -
    │ │ │ -
    │ │ │ -
    pex_seed
    │ │ │ -
    the peer is a seed
    │ │ │ -
    │ │ │ -
    │ │ │ -
    pex_utp
    │ │ │ -
    the peer supports the uTP, transport protocol over UDP.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    pex_holepunch
    │ │ │ -
    the peer supports the holepunch extension If this flag is received from a │ │ │ -peer, it can be used as a rendezvous point in case direct connections to │ │ │ -the peer fail
    │ │ │ -
    │ │ │ -
    │ │ │ -
    pex_lt_v2
    │ │ │ -
    protocol v2 │ │ │ -this is not a standard flag, it is only used internally
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    download_priority_t

    │ │ │ -

    Declared in "libtorrent/download_priority.hpp"

    │ │ │ -
    │ │ │ -
    dont_download
    │ │ │ -
    Don't download the file or piece. Partial pieces may still be downloaded when │ │ │ -setting file priorities.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    default_priority
    │ │ │ -
    The default priority for files and pieces.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    low_priority
    │ │ │ -
    The lowest priority for files and pieces.
    │ │ │ -
    │ │ │ -
    │ │ │ -
    top_priority
    │ │ │ -
    The highest priority for files and pieces.
    │ │ │ -
    │ │ │
    │ │ │ │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ │ │ │
    │ │ │

    add_files()

    │ │ │

    Declared in "libtorrent/create_torrent.hpp"

    │ │ │
    │ │ │  void add_files (file_storage& fs, std::string const& file
    │ │ │ -   , create_flags_t flags = {});
    │ │ │ -void add_files (file_storage& fs, std::string const& file
    │ │ │     , std::function<bool(std::string)> p, create_flags_t flags = {});
    │ │ │ +void add_files (file_storage& fs, std::string const& file
    │ │ │ +   , create_flags_t flags = {});
    │ │ │  
    │ │ │

    Adds the file specified by path to the file_storage object. In case path │ │ │ refers to a directory, files will be added recursively from the directory.

    │ │ │

    If specified, the predicate p is called once for every file and directory that │ │ │ is encountered. Files for which p returns true are added, and directories for │ │ │ which p returns true are traversed. p must have the following signature:

    │ │ │
    │ │ │ @@ -482,29 +482,29 @@
    │ │ │  

    The flags argument should be the same as the flags passed to the create_torrent │ │ │ constructor.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    set_piece_hashes()

    │ │ │

    Declared in "libtorrent/create_torrent.hpp"

    │ │ │
    │ │ │ -inline void set_piece_hashes (create_torrent& t, std::string const& p, error_code& ec);
    │ │ │ -inline void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │ -   , settings_interface const& settings
    │ │ │ -   , std::function<void(piece_index_t)> const& f);
    │ │ │ -inline void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │ -   , std::function<void(piece_index_t)> const& f);
    │ │ │ -void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │ -   , std::function<void(piece_index_t)> const& f, error_code& ec);
    │ │ │  void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │ -   , settings_interface const& settings
    │ │ │     , std::function<void(piece_index_t)> const& f, error_code& ec);
    │ │ │ +inline void set_piece_hashes (create_torrent& t, std::string const& p, error_code& ec);
    │ │ │  void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │     , settings_interface const& settings, disk_io_constructor_type disk_io
    │ │ │     , std::function<void(piece_index_t)> const& f, error_code& ec);
    │ │ │  inline void set_piece_hashes (create_torrent& t, std::string const& p);
    │ │ │ +void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │ +   , settings_interface const& settings
    │ │ │ +   , std::function<void(piece_index_t)> const& f, error_code& ec);
    │ │ │ +inline void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │ +   , std::function<void(piece_index_t)> const& f);
    │ │ │ +inline void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │ +   , settings_interface const& settings
    │ │ │ +   , std::function<void(piece_index_t)> const& f);
    │ │ │  
    │ │ │

    This function will assume that the files added to the torrent file exists at path │ │ │ p, read those files and hash the content and set the hashes in the create_torrent │ │ │ object. The optional function f is called in between every hash that is set. f │ │ │ must have the following signature:

    │ │ │
    │ │ │  void Fun(piece_index_t);
    │ │ │ ├── html2text {}
    │ │ │ │ @@ -1,33 +1,33 @@
    │ │ │ │  >
    │ │ │ │  _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_]
    │ │ │ │  VVeerrssiioonn:: 2.0.14
    │ │ │ │  _h_o_m_e
    │ │ │ │  Table of contents
    │ │ │ │      * _c_r_e_a_t_e___t_o_r_r_e_n_t
    │ │ │ │            o _c_r_e_a_t_e___t_o_r_r_e_n_t_(_)
    │ │ │ │ -          o _g_e_n_e_r_a_t_e_(_)_ _g_e_n_e_r_a_t_e___b_u_f_(_)
    │ │ │ │ +          o _g_e_n_e_r_a_t_e___b_u_f_(_)_ _g_e_n_e_r_a_t_e_(_)
    │ │ │ │            o _f_i_l_e_s_(_)
    │ │ │ │            o _s_e_t___c_o_m_m_e_n_t_(_)
    │ │ │ │            o _s_e_t___c_r_e_a_t_o_r_(_)
    │ │ │ │            o _s_e_t___c_r_e_a_t_i_o_n___d_a_t_e_(_)
    │ │ │ │            o _s_e_t___h_a_s_h_(_)
    │ │ │ │            o _s_e_t___h_a_s_h_2_(_)
    │ │ │ │ -          o _a_d_d___h_t_t_p___s_e_e_d_(_)_ _a_d_d___u_r_l___s_e_e_d_(_)
    │ │ │ │ +          o _a_d_d___u_r_l___s_e_e_d_(_)_ _a_d_d___h_t_t_p___s_e_e_d_(_)
    │ │ │ │            o _a_d_d___n_o_d_e_(_)
    │ │ │ │            o _a_d_d___t_r_a_c_k_e_r_(_)
    │ │ │ │            o _s_e_t___r_o_o_t___c_e_r_t_(_)
    │ │ │ │            o _p_r_i_v_(_)_ _s_e_t___p_r_i_v_(_)
    │ │ │ │            o _n_u_m___p_i_e_c_e_s_(_)
    │ │ │ │            o _p_i_e_c_e___r_a_n_g_e_(_)
    │ │ │ │            o _f_i_l_e___r_a_n_g_e_(_)
    │ │ │ │            o _f_i_l_e___p_i_e_c_e___r_a_n_g_e_(_)
    │ │ │ │            o _t_o_t_a_l___s_i_z_e_(_)
    │ │ │ │ -          o _p_i_e_c_e___l_e_n_g_t_h_(_)_ _p_i_e_c_e___s_i_z_e_(_)
    │ │ │ │ -          o _a_d_d___s_i_m_i_l_a_r___t_o_r_r_e_n_t_(_)_ _a_d_d___c_o_l_l_e_c_t_i_o_n_(_)
    │ │ │ │ +          o _p_i_e_c_e___s_i_z_e_(_)_ _p_i_e_c_e___l_e_n_g_t_h_(_)
    │ │ │ │ +          o _a_d_d___c_o_l_l_e_c_t_i_o_n_(_)_ _a_d_d___s_i_m_i_l_a_r___t_o_r_r_e_n_t_(_)
    │ │ │ │      * _a_d_d___f_i_l_e_s_(_)
    │ │ │ │      * _s_e_t___p_i_e_c_e___h_a_s_h_e_s_(_)
    │ │ │ │  This section describes the functions and classes that are used to create
    │ │ │ │  torrent files. It is a layered API with low level classes and higher level
    │ │ │ │  convenience functions. A torrent is created in 4 steps:
    │ │ │ │     1. first the files that will be part of the torrent are determined.
    │ │ │ │     2. the torrent properties are set, such as tracker url, web seeds, DHT nodes
    │ │ │ │ @@ -66,60 +66,60 @@
    │ │ │ │  Declared in "_l_i_b_t_o_r_r_e_n_t_/_c_r_e_a_t_e___t_o_r_r_e_n_t_._h_p_p"
    │ │ │ │  This class holds state for creating a torrent. After having added all
    │ │ │ │  information to it, call _c_r_e_a_t_e___t_o_r_r_e_n_t_:_:_g_e_n_e_r_a_t_e_(_) to generate the torrent. The
    │ │ │ │  _e_n_t_r_y that's returned can then be bencoded into a .torrent file using _b_e_n_c_o_d_e
    │ │ │ │  _(_).
    │ │ │ │  struct create_torrent
    │ │ │ │  {
    │ │ │ │ +   explicit ccrreeaattee__ttoorrrreenntt (torrent_info const& ti);
    │ │ │ │     explicit ccrreeaattee__ttoorrrreenntt (file_storage& fs, int piece_size = 0
    │ │ │ │        , create_flags_t flags = {});
    │ │ │ │ -   explicit ccrreeaattee__ttoorrrreenntt (torrent_info const& ti);
    │ │ │ │ -   std::vector ggeenneerraattee__bbuuff () const;
    │ │ │ │     entry ggeenneerraattee () const;
    │ │ │ │ +   std::vector ggeenneerraattee__bbuuff () const;
    │ │ │ │     file_storage const& ffiilleess () const;
    │ │ │ │     void sseett__ccoommmmeenntt (char const* str);
    │ │ │ │     void sseett__ccrreeaattoorr (char const* str);
    │ │ │ │     void sseett__ccrreeaattiioonn__ddaattee (std::time_t timestamp);
    │ │ │ │     void sseett__hhaasshh (piece_index_t index, sha1_hash const& h);
    │ │ │ │     void sseett__hhaasshh22 (file_index_t file, piece_index_t::diff_type piece,
    │ │ │ │  sha256_hash const& h);
    │ │ │ │     void aadddd__hhttttpp__sseeeedd (string_view url);
    │ │ │ │     void aadddd__uurrll__sseeeedd (string_view url);
    │ │ │ │     void aadddd__nnooddee (std::pair node);
    │ │ │ │     void aadddd__ttrraacckkeerr (string_view url, int tier = 0);
    │ │ │ │     void sseett__rroooott__cceerrtt (string_view cert);
    │ │ │ │     void sseett__pprriivv (bool p);
    │ │ │ │     bool pprriivv () const;
    │ │ │ │ -   bool iiss__vv11__oonnllyy () const;
    │ │ │ │     bool iiss__vv22__oonnllyy () const;
    │ │ │ │ +   bool iiss__vv11__oonnllyy () const;
    │ │ │ │     int nnuumm__ppiieecceess () const;
    │ │ │ │     piece_index_t eenndd__ppiieeccee () const;
    │ │ │ │     index_range ppiieeccee__rraannggee () const noexcept;
    │ │ │ │     file_index_t eenndd__ffiillee () const;
    │ │ │ │     index_range ffiillee__rraannggee () const noexcept;
    │ │ │ │     index_range ffiillee__ppiieeccee__rraannggee (file_index_t f);
    │ │ │ │     std::int64_t ttoottaall__ssiizzee () const;
    │ │ │ │ -   int ppiieeccee__ssiizzee (piece_index_t i) const;
    │ │ │ │     int ppiieeccee__lleennggtthh () const;
    │ │ │ │ +   int ppiieeccee__ssiizzee (piece_index_t i) const;
    │ │ │ │     void aadddd__ssiimmiillaarr__ttoorrrreenntt (sha1_hash ih);
    │ │ │ │     void aadddd__ccoolllleeccttiioonn (string_view c);
    │ │ │ │  
    │ │ │ │     static constexpr create_flags_t mmooddiiffiiccaattiioonn__ttiimmee  = 2_bit;
    │ │ │ │     static constexpr create_flags_t ssyymmlliinnkkss  = 3_bit;
    │ │ │ │     static constexpr create_flags_t vv22__oonnllyy  = 5_bit;
    │ │ │ │     static constexpr create_flags_t vv11__oonnllyy  = 6_bit;
    │ │ │ │     static constexpr create_flags_t ccaannoonniiccaall__ffiilleess  = 7_bit;
    │ │ │ │     static constexpr create_flags_t nnoo__aattttrriibbuutteess  = 8_bit;
    │ │ │ │     static constexpr create_flags_t ccaannoonniiccaall__ffiilleess__nnoo__ttaaiill__ppaaddddiinngg  = 9_bit;
    │ │ │ │  };
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ccrreeaattee__ttoorrrreenntt(()) **********
    │ │ │ │ +explicit ccrreeaattee__ttoorrrreenntt (torrent_info const& ti);
    │ │ │ │  explicit ccrreeaattee__ttoorrrreenntt (file_storage& fs, int piece_size = 0
    │ │ │ │        , create_flags_t flags = {});
    │ │ │ │ -explicit ccrreeaattee__ttoorrrreenntt (torrent_info const& ti);
    │ │ │ │  The piece_size is the size of each piece in bytes. It must be a power of 2 and
    │ │ │ │  a minimum of 16 kiB. If a piece size of 0 is specified, a piece_size will be
    │ │ │ │  set automatically. Piece sizes greater than 128 MiB are considered unreasonable
    │ │ │ │  and will be rejected (with an lt::system_error exception).
    │ │ │ │  The flags arguments specifies options for the torrent creation. It can be any
    │ │ │ │  combination of the flags defined by create_flags_t.
    │ │ │ │  The _f_i_l_e___s_t_o_r_a_g_e (fs) parameter defines the files, sizes and their properties
    │ │ │ │ @@ -131,17 +131,17 @@
    │ │ │ │  functions of _c_r_e_a_t_e___t_o_r_r_e_n_t that affects the content of the info dictionary
    │ │ │ │  (such as _s_e_t___h_a_s_h_(_)), will have any affect. Instead of using this overload,
    │ │ │ │  consider using _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_) instead.
    │ │ │ │  Warning
    │ │ │ │  The _f_i_l_e___s_t_o_r_a_g_e and _t_o_r_r_e_n_t___i_n_f_o objects must stay alive for the entire
    │ │ │ │  duration of the _c_r_e_a_t_e___t_o_r_r_e_n_t object.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ggeenneerraattee(()) ggeenneerraattee__bbuuff(()) **********
    │ │ │ │ -std::vector ggeenneerraattee__bbuuff () const;
    │ │ │ │ +********** ggeenneerraattee__bbuuff(()) ggeenneerraattee(()) **********
    │ │ │ │  entry ggeenneerraattee () const;
    │ │ │ │ +std::vector ggeenneerraattee__bbuuff () const;
    │ │ │ │  This function will generate the .torrent file as a bencode tree, or a bencoded
    │ │ │ │  into a buffer. In order to encode the _e_n_t_r_y into a flat file, use the _b_e_n_c_o_d_e_(_)
    │ │ │ │  function.
    │ │ │ │  The function returning an _e_n_t_r_y may be useful to add custom entries to the
    │ │ │ │  torrent file before bencoding it and saving it to disk.
    │ │ │ │  Whether the resulting torrent object is v1, v2 or hybrid depends on whether any
    │ │ │ │  of the v1_only or v2_only flags were set on the constructor. If neither were
    │ │ │ │ @@ -198,15 +198,15 @@
    │ │ │ │  the merkle tree formed by the piece's 16 kiB blocks. Note that piece sizes must
    │ │ │ │  be powers-of-2, so all per-piece merkle trees are complete. A SHA-256 hash of
    │ │ │ │  all zeros is internally used to indicate a hash that has not been set. Setting
    │ │ │ │  such hash will not be considered set when calling _g_e_n_e_r_a_t_e_(_). This function
    │ │ │ │  will throw std::system_error if it is called on an object constructed with the
    │ │ │ │  v1_only flag.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** aadddd__hhttttpp__sseeeedd(()) aadddd__uurrll__sseeeedd(()) **********
    │ │ │ │ +********** aadddd__uurrll__sseeeedd(()) aadddd__hhttttpp__sseeeedd(()) **********
    │ │ │ │  void aadddd__hhttttpp__sseeeedd (string_view url);
    │ │ │ │  void aadddd__uurrll__sseeeedd (string_view url);
    │ │ │ │  This adds a url seed to the torrent. You can have any number of url seeds. For
    │ │ │ │  a single file torrent, this should be an HTTP url, pointing to a file with
    │ │ │ │  identical content as the file of the torrent. For a multi-file torrent, it
    │ │ │ │  should point to a directory containing a directory with the same name as this
    │ │ │ │  torrent, and all the files of the torrent in it.
    │ │ │ │ @@ -263,22 +263,22 @@
    │ │ │ │  for v2 and hybrid torrents only, the pieces in the specified file, specified as
    │ │ │ │  delta from the first piece in the file. i.e. the first index is 0.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ttoottaall__ssiizzee(()) **********
    │ │ │ │  std::int64_t ttoottaall__ssiizzee () const;
    │ │ │ │  the total number of bytes of all files and pad files
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ppiieeccee__lleennggtthh(()) ppiieeccee__ssiizzee(()) **********
    │ │ │ │ -int ppiieeccee__ssiizzee (piece_index_t i) const;
    │ │ │ │ +********** ppiieeccee__ssiizzee(()) ppiieeccee__lleennggtthh(()) **********
    │ │ │ │  int ppiieeccee__lleennggtthh () const;
    │ │ │ │ +int ppiieeccee__ssiizzee (piece_index_t i) const;
    │ │ │ │  piece_length() returns the piece size of all pieces but the last one.
    │ │ │ │  piece_size() returns the size of the specified piece. these functions are just
    │ │ │ │  forwarding to the associated _f_i_l_e___s_t_o_r_a_g_e.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** aadddd__ssiimmiillaarr__ttoorrrreenntt(()) aadddd__ccoolllleeccttiioonn(()) **********
    │ │ │ │ +********** aadddd__ccoolllleeccttiioonn(()) aadddd__ssiimmiillaarr__ttoorrrreenntt(()) **********
    │ │ │ │  void aadddd__ssiimmiillaarr__ttoorrrreenntt (sha1_hash ih);
    │ │ │ │  void aadddd__ccoolllleeccttiioonn (string_view c);
    │ │ │ │  Add similar torrents (by info-hash) or collections of similar torrents. Similar
    │ │ │ │  torrents are expected to share some files with this torrent. Torrents sharing a
    │ │ │ │  collection name with this torrent are also expected to share files with this
    │ │ │ │  torrent. A torrent may have more than one collection and more than one similar
    │ │ │ │  torrents. For more information, see _B_E_P_ _3_8.
    │ │ │ │ @@ -330,17 +330,17 @@
    │ │ │ │        behavior deviates from the specification but was the way libtorrent
    │ │ │ │        created torrents in version up to and including 2.0.7. This flag is here
    │ │ │ │        for backwards compatibility.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ************ aadddd__ffiilleess(()) ************
    │ │ │ │  Declared in "_l_i_b_t_o_r_r_e_n_t_/_c_r_e_a_t_e___t_o_r_r_e_n_t_._h_p_p"
    │ │ │ │  void aadddd__ffiilleess (file_storage& fs, std::string const& file
    │ │ │ │ -   , create_flags_t flags = {});
    │ │ │ │ -void aadddd__ffiilleess (file_storage& fs, std::string const& file
    │ │ │ │     , std::function p, create_flags_t flags = {});
    │ │ │ │ +void aadddd__ffiilleess (file_storage& fs, std::string const& file
    │ │ │ │ +   , create_flags_t flags = {});
    │ │ │ │  Adds the file specified by path to the _f_i_l_e___s_t_o_r_a_g_e object. In case path refers
    │ │ │ │  to a directory, files will be added recursively from the directory.
    │ │ │ │  If specified, the predicate p is called once for every file and directory that
    │ │ │ │  is encountered. Files for which p returns true are added, and directories for
    │ │ │ │  which p returns true are traversed. p must have the following signature:
    │ │ │ │  bool Pred(std::string const& p);
    │ │ │ │  The path that is passed in to the predicate is the full path of the file or
    │ │ │ │ @@ -348,30 +348,30 @@
    │ │ │ │  directories are traversed.
    │ │ │ │  The ".." directory is never traversed.
    │ │ │ │  The flags argument should be the same as the flags passed to the _c_r_e_a_t_e___t_o_r_r_e_n_t
    │ │ │ │  constructor.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ************ sseett__ppiieeccee__hhaasshheess(()) ************
    │ │ │ │  Declared in "_l_i_b_t_o_r_r_e_n_t_/_c_r_e_a_t_e___t_o_r_r_e_n_t_._h_p_p"
    │ │ │ │ +void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │ +   , std::function const& f, error_code& ec);
    │ │ │ │  inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p,
    │ │ │ │  error_code& ec);
    │ │ │ │ -inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │ -   , settings_interface const& settings
    │ │ │ │ -   , std::function const& f);
    │ │ │ │ -inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │ -   , std::function const& f);
    │ │ │ │  void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │ +   , settings_interface const& settings, disk_io_constructor_type disk_io
    │ │ │ │     , std::function const& f, error_code& ec);
    │ │ │ │ +inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p);
    │ │ │ │  void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │     , settings_interface const& settings
    │ │ │ │     , std::function const& f, error_code& ec);
    │ │ │ │ -void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │ -   , settings_interface const& settings, disk_io_constructor_type disk_io
    │ │ │ │ -   , std::function const& f, error_code& ec);
    │ │ │ │ -inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p);
    │ │ │ │ +inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │ +   , std::function const& f);
    │ │ │ │ +inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │ +   , settings_interface const& settings
    │ │ │ │ +   , std::function const& f);
    │ │ │ │  This function will assume that the files added to the torrent file exists at
    │ │ │ │  path p, read those files and hash the content and set the hashes in the
    │ │ │ │  create_torrent object. The optional function f is called in between every hash
    │ │ │ │  that is set. f must have the following signature:
    │ │ │ │  void Fun(piece_index_t);
    │ │ │ │  The overloads taking a _s_e_t_t_i_n_g_s___p_a_c_k may be used to configure the underlying
    │ │ │ │  disk access. Such as settings_pack::aio_threads.
    │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Custom_Storage.html
    │ │ │ @@ -29,41 +29,41 @@
    │ │ │  
    │ │ │  
    │ │ │  

    home

    │ │ │
    │ │ │

    Table of contents

    │ │ │
    │ │ │ -
    │ │ │ -

    disk_observer

    │ │ │ -

    Declared in "libtorrent/disk_observer.hpp"

    │ │ │ -
    │ │ │ -struct disk_observer
    │ │ │ -{
    │ │ │ -   virtual void on_disk () = 0;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    on_disk()

    │ │ │ -
    │ │ │ -virtual void on_disk () = 0;
    │ │ │ -
    │ │ │ -

    called when the disk cache size has dropped │ │ │ -below the low watermark again and we can │ │ │ -resume downloading from peers

    │ │ │ [report issue]
    │ │ │ -
    │ │ │
    │ │ │

    open_file_state

    │ │ │

    Declared in "libtorrent/disk_interface.hpp"

    │ │ │

    this contains information about a file that's currently open by the │ │ │ libtorrent disk I/O subsystem. It's associated with a single torrent.

    │ │ │
    │ │ │  struct open_file_state
    │ │ │ @@ -428,21 +409,21 @@
    │ │ │  the constructor. The callbacks will be run in the network thread.

    │ │ │
    │ │ │  struct disk_interface
    │ │ │  {
    │ │ │     virtual storage_holder new_torrent (storage_params const& p
    │ │ │        , std::shared_ptr<void> const& torrent) = 0;
    │ │ │     virtual void remove_torrent (storage_index_t) = 0;
    │ │ │ -   virtual void async_read (storage_index_t storage, peer_request const& r
    │ │ │ -      , std::function<void(disk_buffer_holder, storage_error const&)> handler
    │ │ │ -      , disk_job_flags_t flags = {}) = 0;
    │ │ │     virtual bool async_write (storage_index_t storage, peer_request const& r
    │ │ │        , char const* buf, std::shared_ptr<disk_observer> o
    │ │ │        , std::function<void(storage_error const&)> handler
    │ │ │        , disk_job_flags_t flags = {}) = 0;
    │ │ │ +   virtual void async_read (storage_index_t storage, peer_request const& r
    │ │ │ +      , std::function<void(disk_buffer_holder, storage_error const&)> handler
    │ │ │ +      , disk_job_flags_t flags = {}) = 0;
    │ │ │     virtual void async_hash (storage_index_t storage, piece_index_t piece, span<sha256_hash> v2
    │ │ │        , disk_job_flags_t flags
    │ │ │        , std::function<void(piece_index_t, sha1_hash const&, storage_error const&)> handler) = 0;
    │ │ │     virtual void async_hash2 (storage_index_t storage, piece_index_t piece, int offset, disk_job_flags_t flags
    │ │ │        , std::function<void(piece_index_t, sha256_hash const&, storage_error const&)> handler) = 0;
    │ │ │     virtual void async_move_storage (storage_index_t storage, std::string p, move_flags_t flags
    │ │ │        , std::function<void(status_t, std::string const&, storage_error const&)> handler) = 0;
    │ │ │ @@ -499,21 +480,21 @@
    │ │ │  delete any files from disk, just to clean up any resources associated
    │ │ │  with the specified storage.

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    async_read() async_write()

    │ │ │
    │ │ │ -virtual void async_read (storage_index_t storage, peer_request const& r
    │ │ │ -      , std::function<void(disk_buffer_holder, storage_error const&)> handler
    │ │ │ -      , disk_job_flags_t flags = {}) = 0;
    │ │ │  virtual bool async_write (storage_index_t storage, peer_request const& r
    │ │ │        , char const* buf, std::shared_ptr<disk_observer> o
    │ │ │        , std::function<void(storage_error const&)> handler
    │ │ │        , disk_job_flags_t flags = {}) = 0;
    │ │ │ +virtual void async_read (storage_index_t storage, peer_request const& r
    │ │ │ +      , std::function<void(disk_buffer_holder, storage_error const&)> handler
    │ │ │ +      , disk_job_flags_t flags = {}) = 0;
    │ │ │  
    │ │ │

    perform a read or write operation from/to the specified storage │ │ │ index and the specified request. When the operation completes, call │ │ │ handler possibly with a disk_buffer_holder, holding the buffer with │ │ │ the result. Flags may be set to affect the read operation. See │ │ │ disk_job_flags_t.

    │ │ │

    The disk_observer is a callback to indicate that │ │ │ @@ -764,27 +745,46 @@ │ │ │ internal libtorrent torrent object to tie the storage object allocated │ │ │ for a torrent to the lifetime of the internal torrent object. When a │ │ │ torrent is removed from the session, this holder is destructed and will │ │ │ inform the disk object.

    │ │ │
    │ │ │  struct storage_holder
    │ │ │  {
    │ │ │ -   ~storage_holder ();
    │ │ │     storage_holder (storage_index_t idx, disk_interface& disk_io);
    │ │ │     storage_holder () = default;
    │ │ │ +   ~storage_holder ();
    │ │ │     explicit operator bool () const;
    │ │ │     operator storage_index_t () const;
    │ │ │     void reset ();
    │ │ │ -   storage_holder (storage_holder const&) = delete;
    │ │ │     storage_holder& operator= (storage_holder const&) = delete;
    │ │ │ +   storage_holder (storage_holder const&) = delete;
    │ │ │     storage_holder (storage_holder&& rhs) noexcept;
    │ │ │     storage_holder& operator= (storage_holder&& rhs) noexcept;
    │ │ │  };
    │ │ │  
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    disk_observer

    │ │ │ +

    Declared in "libtorrent/disk_observer.hpp"

    │ │ │ +
    │ │ │ +struct disk_observer
    │ │ │ +{
    │ │ │ +   virtual void on_disk () = 0;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    on_disk()

    │ │ │ +
    │ │ │ +virtual void on_disk () = 0;
    │ │ │ +
    │ │ │ +

    called when the disk cache size has dropped │ │ │ +below the low watermark again and we can │ │ │ +resume downloading from peers

    │ │ │ [report issue]
    │ │ │ +
    │ │ │
    │ │ │

    buffer_allocator_interface

    │ │ │

    Declared in "libtorrent/disk_buffer_holder.hpp"

    │ │ │

    the interface for freeing disk buffers, used by the disk_buffer_holder. │ │ │ when implementing disk_interface, this must also be implemented in order │ │ │ to return disk buffers back to libtorrent

    │ │ │
    │ │ │ @@ -800,18 +800,18 @@
    │ │ │  

    The disk buffer holder acts like a unique_ptr that frees a disk buffer │ │ │ when it's destructed

    │ │ │

    If this buffer holder is moved-from, default constructed or reset, │ │ │ data() will return nullptr.

    │ │ │
    │ │ │  struct disk_buffer_holder
    │ │ │  {
    │ │ │ -   disk_buffer_holder (disk_buffer_holder&&) noexcept;
    │ │ │     disk_buffer_holder& operator= (disk_buffer_holder&&) & noexcept;
    │ │ │ -   disk_buffer_holder (disk_buffer_holder const&) = delete;
    │ │ │ +   disk_buffer_holder (disk_buffer_holder&&) noexcept;
    │ │ │     disk_buffer_holder& operator= (disk_buffer_holder const&) = delete;
    │ │ │ +   disk_buffer_holder (disk_buffer_holder const&) = delete;
    │ │ │     disk_buffer_holder (buffer_allocator_interface& alloc
    │ │ │        , char* buf, int sz) noexcept;
    │ │ │     disk_buffer_holder () noexcept = default;
    │ │ │     ~disk_buffer_holder ();
    │ │ │     char* data () const noexcept;
    │ │ │     void reset ();
    │ │ │     void swap (disk_buffer_holder& h) noexcept;
    │ │ │ ├── html2text {}
    │ │ │ │ @@ -1,15 +1,13 @@
    │ │ │ │  >
    │ │ │ │  _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_]
    │ │ │ │  VVeerrssiioonn:: 2.0.14
    │ │ │ │  _h_o_m_e
    │ │ │ │  Table of contents
    │ │ │ │      * _s_e_t_t_i_n_g_s___i_n_t_e_r_f_a_c_e
    │ │ │ │ -    * _d_i_s_k___o_b_s_e_r_v_e_r
    │ │ │ │ -          o _o_n___d_i_s_k_(_)
    │ │ │ │      * _o_p_e_n___f_i_l_e___s_t_a_t_e
    │ │ │ │      * _d_i_s_k___i_n_t_e_r_f_a_c_e
    │ │ │ │            o _n_e_w___t_o_r_r_e_n_t_(_)
    │ │ │ │            o _r_e_m_o_v_e___t_o_r_r_e_n_t_(_)
    │ │ │ │            o _a_s_y_n_c___r_e_a_d_(_)_ _a_s_y_n_c___w_r_i_t_e_(_)
    │ │ │ │            o _a_s_y_n_c___h_a_s_h_(_)
    │ │ │ │            o _a_s_y_n_c___h_a_s_h_2_(_)
    │ │ │ │ @@ -23,14 +21,16 @@
    │ │ │ │            o _a_s_y_n_c___c_l_e_a_r___p_i_e_c_e_(_)
    │ │ │ │            o _u_p_d_a_t_e___s_t_a_t_s___c_o_u_n_t_e_r_s_(_)
    │ │ │ │            o _g_e_t___s_t_a_t_u_s_(_)
    │ │ │ │            o _a_b_o_r_t_(_)
    │ │ │ │            o _s_u_b_m_i_t___j_o_b_s_(_)
    │ │ │ │            o _s_e_t_t_i_n_g_s___u_p_d_a_t_e_d_(_)
    │ │ │ │      * _s_t_o_r_a_g_e___h_o_l_d_e_r
    │ │ │ │ +    * _d_i_s_k___o_b_s_e_r_v_e_r
    │ │ │ │ +          o _o_n___d_i_s_k_(_)
    │ │ │ │      * _b_u_f_f_e_r___a_l_l_o_c_a_t_o_r___i_n_t_e_r_f_a_c_e
    │ │ │ │      * _d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r
    │ │ │ │            o _d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r_(_)
    │ │ │ │            o _d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r_(_)
    │ │ │ │            o _~_d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r_(_)
    │ │ │ │            o _d_a_t_a_(_)
    │ │ │ │            o _r_e_s_e_t_(_)
    │ │ │ │ @@ -333,35 +333,23 @@
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ************ sseettttiinnggss__iinntteerrffaaccee ************
    │ │ │ │  Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_t_t_i_n_g_s___p_a_c_k_._h_p_p"
    │ │ │ │  the common interface to _s_e_t_t_i_n_g_s___p_a_c_k and the internal representation of
    │ │ │ │  settings.
    │ │ │ │  struct settings_interface
    │ │ │ │  {
    │ │ │ │ -   virtual void sseett__ssttrr (int name, std::string val) = 0;
    │ │ │ │ -   virtual void sseett__iinntt (int name, int val) = 0;
    │ │ │ │ -   virtual bool hhaass__vvaall (int name) const = 0;
    │ │ │ │     virtual void sseett__bbooooll (int name, bool val) = 0;
    │ │ │ │ +   virtual bool hhaass__vvaall (int name) const = 0;
    │ │ │ │ +   virtual void sseett__iinntt (int name, int val) = 0;
    │ │ │ │ +   virtual void sseett__ssttrr (int name, std::string val) = 0;
    │ │ │ │ +   virtual int ggeett__iinntt (int name) const = 0;
    │ │ │ │     virtual std::string const& ggeett__ssttrr (int name) const = 0;
    │ │ │ │     virtual bool ggeett__bbooooll (int name) const = 0;
    │ │ │ │ -   virtual int ggeett__iinntt (int name) const = 0;
    │ │ │ │ -};
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -************ ddiisskk__oobbsseerrvveerr ************
    │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___o_b_s_e_r_v_e_r_._h_p_p"
    │ │ │ │ -struct disk_observer
    │ │ │ │ -{
    │ │ │ │ -   virtual void oonn__ddiisskk () = 0;
    │ │ │ │  };
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** oonn__ddiisskk(()) **********
    │ │ │ │ -virtual void oonn__ddiisskk () = 0;
    │ │ │ │ -called when the disk cache size has dropped below the low watermark again and
    │ │ │ │ -we can resume downloading from peers
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ************ ooppeenn__ffiillee__ssttaattee ************
    │ │ │ │  Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___i_n_t_e_r_f_a_c_e_._h_p_p"
    │ │ │ │  this contains information about a file that's currently open by the libtorrent
    │ │ │ │  disk I/O subsystem. It's associated with a single torrent.
    │ │ │ │  struct open_file_state
    │ │ │ │  {
    │ │ │ │     file_index_t file_index;
    │ │ │ │ @@ -397,21 +385,21 @@
    │ │ │ │  thread via the io_context object passed into the constructor. The callbacks
    │ │ │ │  will be run in the network thread.
    │ │ │ │  struct disk_interface
    │ │ │ │  {
    │ │ │ │     virtual storage_holder nneeww__ttoorrrreenntt (storage_params const& p
    │ │ │ │        , std::shared_ptr const& torrent) = 0;
    │ │ │ │     virtual void rreemmoovvee__ttoorrrreenntt (storage_index_t) = 0;
    │ │ │ │ -   virtual void aassyynncc__rreeaadd (storage_index_t storage, peer_request const& r
    │ │ │ │ -      , std::function handler
    │ │ │ │ -      , disk_job_flags_t flags = {}) = 0;
    │ │ │ │     virtual bool aassyynncc__wwrriittee (storage_index_t storage, peer_request const& r
    │ │ │ │        , char const* buf, std::shared_ptr o
    │ │ │ │        , std::function handler
    │ │ │ │        , disk_job_flags_t flags = {}) = 0;
    │ │ │ │ +   virtual void aassyynncc__rreeaadd (storage_index_t storage, peer_request const& r
    │ │ │ │ +      , std::function handler
    │ │ │ │ +      , disk_job_flags_t flags = {}) = 0;
    │ │ │ │     virtual void aassyynncc__hhaasshh (storage_index_t storage, piece_index_t piece,
    │ │ │ │  span v2
    │ │ │ │        , disk_job_flags_t flags
    │ │ │ │        , std::function handler) = 0;
    │ │ │ │     virtual void aassyynncc__hhaasshh22 (storage_index_t storage, piece_index_t piece, int
    │ │ │ │  offset, disk_job_flags_t flags
    │ │ │ │ @@ -467,21 +455,21 @@
    │ │ │ │  ********** rreemmoovvee__ttoorrrreenntt(()) **********
    │ │ │ │  virtual void rreemmoovvee__ttoorrrreenntt (storage_index_t) = 0;
    │ │ │ │  remove the storage with the specified index. This is not expected to delete any
    │ │ │ │  files from disk, just to clean up any resources associated with the specified
    │ │ │ │  storage.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** aassyynncc__rreeaadd(()) aassyynncc__wwrriittee(()) **********
    │ │ │ │ -virtual void aassyynncc__rreeaadd (storage_index_t storage, peer_request const& r
    │ │ │ │ -      , std::function handler
    │ │ │ │ -      , disk_job_flags_t flags = {}) = 0;
    │ │ │ │  virtual bool aassyynncc__wwrriittee (storage_index_t storage, peer_request const& r
    │ │ │ │        , char const* buf, std::shared_ptr o
    │ │ │ │        , std::function handler
    │ │ │ │        , disk_job_flags_t flags = {}) = 0;
    │ │ │ │ +virtual void aassyynncc__rreeaadd (storage_index_t storage, peer_request const& r
    │ │ │ │ +      , std::function handler
    │ │ │ │ +      , disk_job_flags_t flags = {}) = 0;
    │ │ │ │  perform a read or write operation from/to the specified storage index and the
    │ │ │ │  specified request. When the operation completes, call handler possibly with a
    │ │ │ │  _d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r, holding the buffer with the result. Flags may be set to
    │ │ │ │  affect the read operation. See disk_job_flags_t.
    │ │ │ │  The _d_i_s_k___o_b_s_e_r_v_e_r is a callback to indicate that the store buffer/disk write
    │ │ │ │  queue is below the watermark to let peers start writing buffers to disk again.
    │ │ │ │  When async_write() returns true, indicating the write queue is full, the peer
    │ │ │ │ @@ -668,26 +656,38 @@
    │ │ │ │  a unique, owning, reference to the storage of a torrent in a disk io subsystem
    │ │ │ │  (class that implements _d_i_s_k___i_n_t_e_r_f_a_c_e). This is held by the internal libtorrent
    │ │ │ │  torrent object to tie the storage object allocated for a torrent to the
    │ │ │ │  lifetime of the internal torrent object. When a torrent is removed from the
    │ │ │ │  _s_e_s_s_i_o_n, this holder is destructed and will inform the disk object.
    │ │ │ │  struct storage_holder
    │ │ │ │  {
    │ │ │ │ -   ~~ssttoorraaggee__hhoollddeerr ();
    │ │ │ │     ssttoorraaggee__hhoollddeerr (storage_index_t idx, disk_interface& disk_io);
    │ │ │ │     ssttoorraaggee__hhoollddeerr () = default;
    │ │ │ │ +   ~~ssttoorraaggee__hhoollddeerr ();
    │ │ │ │     explicit operator bbooooll () const;
    │ │ │ │     operator ssttoorraaggee__iinnddeexx__tt () const;
    │ │ │ │     void rreesseett ();
    │ │ │ │ -   ssttoorraaggee__hhoollddeerr (storage_holder const&) = delete;
    │ │ │ │     storage_holder& ooppeerraattoorr== (storage_holder const&) = delete;
    │ │ │ │ +   ssttoorraaggee__hhoollddeerr (storage_holder const&) = delete;
    │ │ │ │     ssttoorraaggee__hhoollddeerr (storage_holder&& rhs) noexcept;
    │ │ │ │     storage_holder& ooppeerraattoorr== (storage_holder&& rhs) noexcept;
    │ │ │ │  };
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +************ ddiisskk__oobbsseerrvveerr ************
    │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___o_b_s_e_r_v_e_r_._h_p_p"
    │ │ │ │ +struct disk_observer
    │ │ │ │ +{
    │ │ │ │ +   virtual void oonn__ddiisskk () = 0;
    │ │ │ │ +};
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** oonn__ddiisskk(()) **********
    │ │ │ │ +virtual void oonn__ddiisskk () = 0;
    │ │ │ │ +called when the disk cache size has dropped below the low watermark again and
    │ │ │ │ +we can resume downloading from peers
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ************ bbuuffffeerr__aallllooccaattoorr__iinntteerrffaaccee ************
    │ │ │ │  Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r_._h_p_p"
    │ │ │ │  the interface for freeing disk buffers, used by the _d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r. when
    │ │ │ │  implementing _d_i_s_k___i_n_t_e_r_f_a_c_e, this must also be implemented in order to return
    │ │ │ │  disk buffers back to libtorrent
    │ │ │ │  struct buffer_allocator_interface
    │ │ │ │  {
    │ │ │ │ @@ -698,18 +698,18 @@
    │ │ │ │  Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_k___b_u_f_f_e_r___h_o_l_d_e_r_._h_p_p"
    │ │ │ │  The disk buffer holder acts like a unique_ptr that frees a disk buffer when
    │ │ │ │  it's destructed
    │ │ │ │  If this buffer holder is moved-from, default constructed or reset, data() will
    │ │ │ │  return nullptr.
    │ │ │ │  struct disk_buffer_holder
    │ │ │ │  {
    │ │ │ │ -   ddiisskk__bbuuffffeerr__hhoollddeerr (disk_buffer_holder&&) noexcept;
    │ │ │ │     disk_buffer_holder& ooppeerraattoorr== (disk_buffer_holder&&) & noexcept;
    │ │ │ │ -   ddiisskk__bbuuffffeerr__hhoollddeerr (disk_buffer_holder const&) = delete;
    │ │ │ │ +   ddiisskk__bbuuffffeerr__hhoollddeerr (disk_buffer_holder&&) noexcept;
    │ │ │ │     disk_buffer_holder& ooppeerraattoorr== (disk_buffer_holder const&) = delete;
    │ │ │ │ +   ddiisskk__bbuuffffeerr__hhoollddeerr (disk_buffer_holder const&) = delete;
    │ │ │ │     ddiisskk__bbuuffffeerr__hhoollddeerr (buffer_allocator_interface& alloc
    │ │ │ │        , char* buf, int sz) noexcept;
    │ │ │ │     ddiisskk__bbuuffffeerr__hhoollddeerr () noexcept = default;
    │ │ │ │     ~~ddiisskk__bbuuffffeerr__hhoollddeerr ();
    │ │ │ │     char* ddaattaa () const noexcept;
    │ │ │ │     void rreesseett ();
    │ │ │ │     void sswwaapp (disk_buffer_holder& h) noexcept;
    │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-DHT.html
    │ │ │ @@ -28,39 +28,65 @@
    │ │ │  2.0.14
    │ │ │  
    │ │ │  
    │ │ │  

    home

    │ │ │
    │ │ │

    Table of contents

    │ │ │
    │ │ │ -[report issue]
    │ │ │ +[report issue]
    │ │ │ +

    dht_state

    │ │ │ +

    Declared in "libtorrent/kademlia/dht_state.hpp"

    │ │ │ +

    This structure helps to store and load the state │ │ │ +of the dht_tracker. │ │ │ +At this moment the library is only a dual stack │ │ │ +implementation of the DHT. See BEP 32

    │ │ │ +
    │ │ │ +struct dht_state
    │ │ │ +{
    │ │ │ +   void clear ();
    │ │ │ +
    │ │ │ +   node_ids_t nids;
    │ │ │ +   std::vector<udp::endpoint> nodes;
    │ │ │ +   std::vector<udp::endpoint> nodes6;
    │ │ │ +};
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    nodes
    │ │ │ +
    the bootstrap nodes saved from the buckets node
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    nodes6
    │ │ │ +
    the bootstrap nodes saved from the IPv6 buckets node
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │

    dht_storage_counters

    │ │ │

    Declared in "libtorrent/kademlia/dht_storage.hpp"

    │ │ │

    This structure hold the relevant counters for the storage

    │ │ │
    │ │ │  struct dht_storage_counters
    │ │ │  {
    │ │ │     void reset ();
    │ │ │ @@ -282,41 +308,26 @@
    │ │ │  [report issue]
    │ │ │
    │ │ │

    counters()

    │ │ │
    │ │ │  virtual dht_storage_counters counters () const = 0;
    │ │ │  
    │ │ │

    return stats counters for the store

    │ │ │ -[report issue]
    │ │ │ +[report issue]
    │ │ │
    │ │ │ -
    │ │ │ -

    dht_state

    │ │ │ -

    Declared in "libtorrent/kademlia/dht_state.hpp"

    │ │ │ -

    This structure helps to store and load the state │ │ │ -of the dht_tracker. │ │ │ -At this moment the library is only a dual stack │ │ │ -implementation of the DHT. See BEP 32

    │ │ │ +
    │ │ │ +

    dht_default_storage_constructor()

    │ │ │ +

    Declared in "libtorrent/kademlia/dht_storage.hpp"

    │ │ │
    │ │ │ -struct dht_state
    │ │ │ -{
    │ │ │ -   void clear ();
    │ │ │ -
    │ │ │ -   node_ids_t nids;
    │ │ │ -   std::vector<udp::endpoint> nodes;
    │ │ │ -   std::vector<udp::endpoint> nodes6;
    │ │ │ -};
    │ │ │ +std::unique_ptr<dht_storage_interface> dht_default_storage_constructor (
    │ │ │ +   settings_interface const& settings);
    │ │ │  
    │ │ │ -[report issue]
    │ │ │ -
    nodes
    │ │ │ -
    the bootstrap nodes saved from the buckets node
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    nodes6
    │ │ │ -
    the bootstrap nodes saved from the IPv6 buckets node
    │ │ │ -
    │ │ │ +

    constructor for the default DHT storage. The DHT storage is responsible │ │ │ +for maintaining peers and mutable and immutable items announced and │ │ │ +stored/put to the DHT node.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    sign_mutable_item()

    │ │ │

    Declared in "libtorrent/kademlia/item.hpp"

    │ │ │
    │ │ │  signature sign_mutable_item (
    │ │ │     span<char const> v
    │ │ │ @@ -327,25 +338,14 @@
    │ │ │  
    │ │ │

    given a byte range v and an optional byte range salt, a │ │ │ sequence number, public key pk (must be 32 bytes) and a secret key │ │ │ sk (must be 64 bytes), this function produces a signature which │ │ │ is written into a 64 byte buffer pointed to by sig. The caller │ │ │ is responsible for allocating the destination buffer that's passed in │ │ │ as the sig argument. Typically it would be allocated on the stack.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    dht_default_storage_constructor()

    │ │ │ -

    Declared in "libtorrent/kademlia/dht_storage.hpp"

    │ │ │ -
    │ │ │ -std::unique_ptr<dht_storage_interface> dht_default_storage_constructor (
    │ │ │ -   settings_interface const& settings);
    │ │ │ -
    │ │ │ -

    constructor for the default DHT storage. The DHT storage is responsible │ │ │ -for maintaining peers and mutable and immutable items announced and │ │ │ -stored/put to the DHT node.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    announce_flags_t

    │ │ │

    Declared in "libtorrent/kademlia/announce_flags.hpp"

    │ │ │
    │ │ │
    seed
    │ │ │
    announce to DHT as a seed
    │ │ │ ├── html2text {} │ │ │ │ @@ -1,31 +1,50 @@ │ │ │ │ > │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.0.14 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ + * _d_h_t___s_t_a_t_e │ │ │ │ * _d_h_t___s_t_o_r_a_g_e___c_o_u_n_t_e_r_s │ │ │ │ o _r_e_s_e_t_(_) │ │ │ │ * _d_h_t___s_t_o_r_a_g_e___i_n_t_e_r_f_a_c_e │ │ │ │ o _u_p_d_a_t_e___n_o_d_e___i_d_s_(_) │ │ │ │ o _g_e_t___p_e_e_r_s_(_) │ │ │ │ o _a_n_n_o_u_n_c_e___p_e_e_r_(_) │ │ │ │ o _g_e_t___i_m_m_u_t_a_b_l_e___i_t_e_m_(_) │ │ │ │ o _p_u_t___i_m_m_u_t_a_b_l_e___i_t_e_m_(_) │ │ │ │ o _g_e_t___m_u_t_a_b_l_e___i_t_e_m___s_e_q_(_) │ │ │ │ o _g_e_t___m_u_t_a_b_l_e___i_t_e_m_(_) │ │ │ │ o _p_u_t___m_u_t_a_b_l_e___i_t_e_m_(_) │ │ │ │ o _g_e_t___i_n_f_o_h_a_s_h_e_s___s_a_m_p_l_e_(_) │ │ │ │ o _t_i_c_k_(_) │ │ │ │ o _c_o_u_n_t_e_r_s_(_) │ │ │ │ - * _d_h_t___s_t_a_t_e │ │ │ │ - * _s_i_g_n___m_u_t_a_b_l_e___i_t_e_m_(_) │ │ │ │ * _d_h_t___d_e_f_a_u_l_t___s_t_o_r_a_g_e___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ + * _s_i_g_n___m_u_t_a_b_l_e___i_t_e_m_(_) │ │ │ │ * _a_n_n_o_u_n_c_e___f_l_a_g_s___t │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddhhtt__ssttaattee ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_k_a_d_e_m_l_i_a_/_d_h_t___s_t_a_t_e_._h_p_p" │ │ │ │ +This structure helps to store and load the state of the dht_tracker. At this │ │ │ │ +moment the library is only a dual stack implementation of the DHT. See _B_E_P_ _3_2 │ │ │ │ +struct dht_state │ │ │ │ +{ │ │ │ │ + void cclleeaarr (); │ │ │ │ + │ │ │ │ + node_ids_t nids; │ │ │ │ + std::vector nodes; │ │ │ │ + std::vector nodes6; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + nodes │ │ │ │ + the bootstrap nodes saved from the buckets node │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + nodes6 │ │ │ │ + the bootstrap nodes saved from the IPv6 buckets node │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ddhhtt__ssttoorraaggee__ccoouunntteerrss ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_k_a_d_e_m_l_i_a_/_d_h_t___s_t_o_r_a_g_e_._h_p_p" │ │ │ │ This structure hold the relevant _c_o_u_n_t_e_r_s for the storage │ │ │ │ struct dht_storage_counters │ │ │ │ { │ │ │ │ void rreesseett (); │ │ │ │ │ │ │ │ @@ -191,32 +210,21 @@ │ │ │ │ For implementers: Use this functions for expire peers or items or any other │ │ │ │ storage cleanup. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ccoouunntteerrss(()) ********** │ │ │ │ virtual dht_storage_counters ccoouunntteerrss () const = 0; │ │ │ │ return stats _c_o_u_n_t_e_r_s for the store │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddhhtt__ssttaattee ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_k_a_d_e_m_l_i_a_/_d_h_t___s_t_a_t_e_._h_p_p" │ │ │ │ -This structure helps to store and load the state of the dht_tracker. At this │ │ │ │ -moment the library is only a dual stack implementation of the DHT. See _B_E_P_ _3_2 │ │ │ │ -struct dht_state │ │ │ │ -{ │ │ │ │ - void cclleeaarr (); │ │ │ │ - │ │ │ │ - node_ids_t nids; │ │ │ │ - std::vector nodes; │ │ │ │ - std::vector nodes6; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - nodes │ │ │ │ - the bootstrap nodes saved from the buckets node │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - nodes6 │ │ │ │ - the bootstrap nodes saved from the IPv6 buckets node │ │ │ │ +************ ddhhtt__ddeeffaauulltt__ssttoorraaggee__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_k_a_d_e_m_l_i_a_/_d_h_t___s_t_o_r_a_g_e_._h_p_p" │ │ │ │ +std::unique_ptr ddhhtt__ddeeffaauulltt__ssttoorraaggee__ccoonnssttrruuccttoorr ( │ │ │ │ + settings_interface const& settings); │ │ │ │ +constructor for the default DHT storage. The DHT storage is responsible for │ │ │ │ +maintaining peers and mutable and immutable items announced and stored/put to │ │ │ │ +the DHT node. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ssiiggnn__mmuuttaabbllee__iitteemm(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_k_a_d_e_m_l_i_a_/_i_t_e_m_._h_p_p" │ │ │ │ signature ssiiggnn__mmuuttaabbllee__iitteemm ( │ │ │ │ span v │ │ │ │ , span salt │ │ │ │ , sequence_number seq │ │ │ │ @@ -224,22 +232,14 @@ │ │ │ │ , secret_key const& sk); │ │ │ │ given a byte range v and an optional byte range salt, a sequence number, public │ │ │ │ key pk (must be 32 bytes) and a secret key sk (must be 64 bytes), this function │ │ │ │ produces a signature which is written into a 64 byte buffer pointed to by sig. │ │ │ │ The caller is responsible for allocating the destination buffer that's passed │ │ │ │ in as the sig argument. Typically it would be allocated on the stack. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddhhtt__ddeeffaauulltt__ssttoorraaggee__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_k_a_d_e_m_l_i_a_/_d_h_t___s_t_o_r_a_g_e_._h_p_p" │ │ │ │ -std::unique_ptr ddhhtt__ddeeffaauulltt__ssttoorraaggee__ccoonnssttrruuccttoorr ( │ │ │ │ - settings_interface const& settings); │ │ │ │ -constructor for the default DHT storage. The DHT storage is responsible for │ │ │ │ -maintaining peers and mutable and immutable items announced and stored/put to │ │ │ │ -the DHT node. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ aannnnoouunnccee__ffllaaggss__tt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_k_a_d_e_m_l_i_a_/_a_n_n_o_u_n_c_e___f_l_a_g_s_._h_p_p" │ │ │ │ seed │ │ │ │ announce to DHT as a seed │ │ │ │ implied_port │ │ │ │ announce to DHT with the implied-port flag set. This tells the network to │ │ │ │ use your source UDP port as your listen port, rather than the one │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Error_Codes.html │ │ │ @@ -33,44 +33,44 @@ │ │ │

    Table of contents

    │ │ │ │ │ │
    │ │ │ [report issue]
    │ │ │

    storage_error

    │ │ │

    Declared in "libtorrent/error_code.hpp"

    │ │ │

    used by storage to return errors │ │ │ also includes which underlying file the │ │ │ error happened on

    │ │ │
    │ │ │  struct storage_error
    │ │ │  {
    │ │ │     explicit operator bool () const;
    │ │ │ -   void file (file_index_t f);
    │ │ │     file_index_t file () const;
    │ │ │ +   void file (file_index_t f);
    │ │ │  
    │ │ │     error_code ec;
    │ │ │     operation_t operation;
    │ │ │  };
    │ │ │  
    │ │ │ [report issue]
    │ │ │

    bool()

    │ │ │ @@ -79,31 +79,38 @@ │ │ │
    │ │ │

    explicitly converts to true if this object represents an error, and │ │ │ false if it does not.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    file()

    │ │ │
    │ │ │ -void file (file_index_t f);
    │ │ │  file_index_t file () const;
    │ │ │ +void file (file_index_t f);
    │ │ │  
    │ │ │

    set and query the index (in the torrent) of the file this error │ │ │ occurred on. This may also have special values defined in │ │ │ torrent_status.

    │ │ │ [report issue]
    │ │ │
    ec
    │ │ │
    the error that occurred
    │ │ │
    │ │ │ [report issue]
    │ │ │
    operation
    │ │ │
    A code from operation_t enum, indicating what │ │ │ kind of operation failed.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ +[report issue]
    │ │ │ │ │ │ +
    │ │ │ +

    pcp_category()

    │ │ │ +

    Declared in "libtorrent/natpmp.hpp"

    │ │ │ +
    │ │ │ +boost::system::error_category& pcp_category ();
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │
    │ │ │

    upnp_category()

    │ │ │

    Declared in "libtorrent/upnp.hpp"

    │ │ │
    │ │ │  boost::system::error_category& upnp_category ();
    │ │ │  
    │ │ │

    the boost.system error category for UPnP errors

    │ │ │ @@ -111,37 +118,37 @@ │ │ │
    │ │ │

    socks_category()

    │ │ │

    Declared in "libtorrent/socks5_stream.hpp"

    │ │ │
    │ │ │  boost::system::error_category& socks_category ();
    │ │ │  
    │ │ │

    returns the error_category for SOCKS5 errors

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    pcp_category()

    │ │ │ -

    Declared in "libtorrent/natpmp.hpp"

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    gzip_category()

    │ │ │ +

    Declared in "libtorrent/gzip.hpp"

    │ │ │
    │ │ │ -boost::system::error_category& pcp_category ();
    │ │ │ +boost::system::error_category& gzip_category ();
    │ │ │  
    │ │ │ +

    get the error_category for zip errors

    │ │ │ [report issue]
    │ │ │
    │ │ │

    i2p_category()

    │ │ │

    Declared in "libtorrent/i2p_stream.hpp"

    │ │ │
    │ │ │  boost::system::error_category& i2p_category ();
    │ │ │  
    │ │ │

    returns the error category for I2P errors

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    gzip_category()

    │ │ │ -

    Declared in "libtorrent/gzip.hpp"

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    bdecode_category()

    │ │ │ +

    Declared in "libtorrent/bdecode.hpp"

    │ │ │
    │ │ │ -boost::system::error_category& gzip_category ();
    │ │ │ +boost::system::error_category& bdecode_category ();
    │ │ │  
    │ │ │ -

    get the error_category for zip errors

    │ │ │ [report issue]
    │ │ │
    │ │ │

    libtorrent_category()

    │ │ │

    Declared in "libtorrent/error_code.hpp"

    │ │ │
    │ │ │  boost::system::error_category& libtorrent_category ();
    │ │ │  
    │ │ │ @@ -151,21 +158,89 @@ │ │ │
    │ │ │

    http_category()

    │ │ │

    Declared in "libtorrent/error_code.hpp"

    │ │ │
    │ │ │  boost::system::error_category& http_category ();
    │ │ │  
    │ │ │

    returns the error_category for HTTP errors

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    bdecode_category()

    │ │ │ -

    Declared in "libtorrent/bdecode.hpp"

    │ │ │ -
    │ │ │ -boost::system::error_category& bdecode_category ();
    │ │ │ -
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum pcp_errors

    │ │ │ +

    Declared in "libtorrent/natpmp.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    pcp_success0 
    pcp_unsupp_version1 
    pcp_not_authorized2 
    pcp_malformed_request3 
    pcp_unsupp_opcode4 
    pcp_unsupp_option5 
    pcp_malformed_option6 
    pcp_network_failure7 
    pcp_no_resources8 
    pcp_unsupp_protocol9 
    pcp_user_ex_quota10 
    pcp_cannot_provide_external11 
    pcp_address_mismatch12 
    pcp_excessive_remote_peers13 
    │ │ │ [report issue]
    │ │ │
    │ │ │

    enum error_code_enum

    │ │ │

    Declared in "libtorrent/upnp.hpp"

    │ │ │ │ │ │ │ │ │ │ │ │ @@ -290,86 +365,99 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    num_errors10 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum pcp_errors

    │ │ │ -

    Declared in "libtorrent/natpmp.hpp"

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum error_code_enum

    │ │ │ +

    Declared in "libtorrent/gzip.hpp"

    │ │ │ │ │ │ │ │ │ -│ │ │ -│ │ │ -│ │ │ +│ │ │ +│ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ │ │ │ │ │ │
    namevaluedescription
    pcp_success
    no_error0 Not an error
    pcp_unsupp_version
    invalid_gzip_header1 the supplied gzip buffer has invalid header
    pcp_not_authorized
    inflated_data_too_large2 the gzip buffer would inflate to more bytes than the specified │ │ │ +maximum size, and was rejected.
    pcp_malformed_request
    data_did_not_terminate3 available inflate data did not terminate
    pcp_unsupp_opcode
    space_exhausted4 output space exhausted before completing inflate
    pcp_unsupp_option
    invalid_block_type5 invalid block type (type == 3)
    pcp_malformed_option
    invalid_stored_block_length6 stored block length did not match one's complement
    pcp_network_failure
    too_many_length_or_distance_codes7 dynamic block code description: too many length or distance codes
    pcp_no_resources
    code_lengths_codes_incomplete8 dynamic block code description: code lengths codes incomplete
    pcp_unsupp_protocol
    repeat_lengths_with_no_first_length9 dynamic block code description: repeat lengths with no first length
    pcp_user_ex_quota
    repeat_more_than_specified_lengths10 dynamic block code description: repeat more than specified lengths
    pcp_cannot_provide_external
    invalid_literal_length_code_lengths11 dynamic block code description: invalid literal/length code lengths
    pcp_address_mismatch
    invalid_distance_code_lengths12 dynamic block code description: invalid distance code lengths
    pcp_excessive_remote_peers
    invalid_literal_code_in_block13 invalid literal/length or distance code in fixed or dynamic block
    distance_too_far_back_in_block14distance is too far back in fixed or dynamic block
    unknown_gzip_error15an unknown error occurred during gzip inflation
    error_code_max16the number of error codes
    │ │ │ [report issue]
    │ │ │
    │ │ │

    enum i2p_error_code

    │ │ │

    Declared in "libtorrent/i2p_stream.hpp"

    │ │ │ @@ -425,103 +513,70 @@ │ │ │ num_errors │ │ │ 9 │ │ │   │ │ │ │ │ │ │ │ │ │ │ │ [report issue]
    │ │ │ -
    │ │ │ +
    │ │ │

    enum error_code_enum

    │ │ │ -

    Declared in "libtorrent/gzip.hpp"

    │ │ │ +

    Declared in "libtorrent/bdecode.hpp"

    │ │ │ │ │ │ │ │ │ -│ │ │ -│ │ │ -│ │ │ +│ │ │ +│ │ │ +│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │
    namevaluedescription
    no_error0Not an error
    invalid_gzip_header
    expected_digit1the supplied gzip buffer has invalid headerexpected digit in bencoded string
    inflated_data_too_large
    expected_colon2the gzip buffer would inflate to more bytes than the specified │ │ │ -maximum size, and was rejected.expected colon in bencoded string
    data_did_not_terminate
    unexpected_eof3available inflate data did not terminateunexpected end of file in bencoded string
    space_exhausted
    expected_value4output space exhausted before completing inflateexpected value (list, dict, int or string) in bencoded string
    invalid_block_type
    depth_exceeded5invalid block type (type == 3)bencoded recursion depth limit exceeded
    invalid_stored_block_length
    limit_exceeded6stored block length did not match one's complementbencoded item count limit exceeded
    too_many_length_or_distance_codes
    overflow7dynamic block code description: too many length or distance codes
    code_lengths_codes_incomplete8dynamic block code description: code lengths codes incomplete
    repeat_lengths_with_no_first_length9dynamic block code description: repeat lengths with no first length
    repeat_more_than_specified_lengths10dynamic block code description: repeat more than specified lengths
    invalid_literal_length_code_lengths11dynamic block code description: invalid literal/length code lengths
    invalid_distance_code_lengths12dynamic block code description: invalid distance code lengths
    invalid_literal_code_in_block13invalid literal/length or distance code in fixed or dynamic block
    distance_too_far_back_in_block14distance is too far back in fixed or dynamic block
    unknown_gzip_error15an unknown error occurred during gzip inflationinteger overflow
    error_code_max168the number of error codes
    │ │ │ [report issue]
    │ │ │ -
    │ │ │ +
    │ │ │

    enum error_code_enum

    │ │ │

    Declared in "libtorrent/error_code.hpp"

    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -1345,69 +1400,14 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    service_unavailable503 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum error_code_enum

    │ │ │ -

    Declared in "libtorrent/bdecode.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    no_error0Not an error
    expected_digit1expected digit in bencoded string
    expected_colon2expected colon in bencoded string
    unexpected_eof3unexpected end of file in bencoded string
    expected_value4expected value (list, dict, int or string) in bencoded string
    depth_exceeded5bencoded recursion depth limit exceeded
    limit_exceeded6bencoded item count limit exceeded
    overflow7integer overflow
    error_code_max8the number of error codes
    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │
    │ │ │
    │ │ │ │ │ │
    │ │ │

    bt_peer_connection_handle

    │ │ │

    Declared in "libtorrent/peer_connection_handle.hpp"

    │ │ │ @@ -244,16 +244,16 @@ │ │ │
    │ │ │  struct bt_peer_connection_handle : peer_connection_handle
    │ │ │  {
    │ │ │     explicit bt_peer_connection_handle (peer_connection_handle pc);
    │ │ │     bool packet_finished () const;
    │ │ │     bool support_extensions () const;
    │ │ │     bool supports_encryption () const;
    │ │ │ -   void switch_recv_crypto (std::shared_ptr<crypto_plugin> crypto);
    │ │ │     void switch_send_crypto (std::shared_ptr<crypto_plugin> crypto);
    │ │ │ +   void switch_recv_crypto (std::shared_ptr<crypto_plugin> crypto);
    │ │ │     std::shared_ptr<bt_peer_connection> native_handle () const;
    │ │ │  };
    │ │ │  
    │ │ │ [report issue]
    │ │ │
    │ │ │

    plugin

    │ │ │

    Declared in "libtorrent/extensions.hpp"

    │ │ │ @@ -416,19 +416,19 @@ │ │ │

    Torrent plugins are associated with a single torrent and have a number │ │ │ of functions called at certain events. Many of its functions have the │ │ │ ability to change or override the default libtorrent behavior.

    │ │ │
    │ │ │  struct torrent_plugin
    │ │ │  {
    │ │ │     virtual std::shared_ptr<peer_plugin> new_connection (peer_connection_handle const&);
    │ │ │ -   virtual void on_piece_failed (piece_index_t);
    │ │ │     virtual void on_piece_pass (piece_index_t);
    │ │ │ +   virtual void on_piece_failed (piece_index_t);
    │ │ │     virtual void tick ();
    │ │ │ -   virtual bool on_resume ();
    │ │ │     virtual bool on_pause ();
    │ │ │ +   virtual bool on_resume ();
    │ │ │     virtual void on_files_checked ();
    │ │ │     virtual void on_state (torrent_status::state_t);
    │ │ │     virtual void on_add_peer (tcp::endpoint const&,
    │ │ │        peer_source_flags_t, add_peer_flags_t);
    │ │ │  
    │ │ │     static constexpr add_peer_flags_t first_time  = 1_bit;
    │ │ │     static constexpr add_peer_flags_t filtered  = 2_bit;
    │ │ │ @@ -452,16 +452,16 @@
    │ │ │  to it, use weak_ptr.

    │ │ │

    If this function throws an exception, the connection will be closed.

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    on_piece_pass() on_piece_failed()

    │ │ │
    │ │ │ -virtual void on_piece_failed (piece_index_t);
    │ │ │  virtual void on_piece_pass (piece_index_t);
    │ │ │ +virtual void on_piece_failed (piece_index_t);
    │ │ │  
    │ │ │

    These hooks are called when a piece passes the hash check or fails the hash │ │ │ check, respectively. The index is the piece index that was downloaded. │ │ │ It is possible to access the list of peers that participated in sending the │ │ │ piece through the torrent and the piece_picker.

    │ │ │ [report issue]
    │ │ │
    │ │ │ @@ -472,16 +472,16 @@ │ │ │

    This hook is called approximately once per second. It is a way of making it │ │ │ easy for plugins to do timed events, for sending messages or whatever.

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    on_resume() on_pause()

    │ │ │
    │ │ │ -virtual bool on_resume ();
    │ │ │  virtual bool on_pause ();
    │ │ │ +virtual bool on_resume ();
    │ │ │  
    │ │ │

    These hooks are called when the torrent is paused and resumed respectively. │ │ │ The return value indicates if the event was handled. A return value of │ │ │ true indicates that it was handled, and no other plugin after this one │ │ │ will have this hook function called, and the standard handler will also not be │ │ │ invoked. So, returning true effectively overrides the standard behavior of │ │ │ pause or resume.

    │ │ │ @@ -546,51 +546,51 @@ │ │ │ { │ │ │ virtual string_view type () const; │ │ │ virtual void add_handshake (entry&); │ │ │ virtual void on_disconnect (error_code const&); │ │ │ virtual void on_connected (); │ │ │ virtual bool on_handshake (span<char const>); │ │ │ virtual bool on_extension_handshake (bdecode_node const&); │ │ │ - virtual bool on_have_none (); │ │ │ - virtual bool on_have (piece_index_t); │ │ │ + virtual bool on_choke (); │ │ │ + virtual bool on_interested (); │ │ │ + virtual bool on_dont_have (piece_index_t); │ │ │ + virtual bool on_not_interested (); │ │ │ + virtual bool on_allowed_fast (piece_index_t); │ │ │ virtual bool on_unchoke (); │ │ │ virtual bool on_bitfield (bitfield const& /*bitfield*/); │ │ │ + virtual bool on_have (piece_index_t); │ │ │ + virtual bool on_have_none (); │ │ │ virtual bool on_request (peer_request const&); │ │ │ - virtual bool on_not_interested (); │ │ │ - virtual bool on_choke (); │ │ │ virtual bool on_have_all (); │ │ │ - virtual bool on_allowed_fast (piece_index_t); │ │ │ - virtual bool on_dont_have (piece_index_t); │ │ │ - virtual bool on_interested (); │ │ │ virtual bool on_piece (peer_request const& /*piece*/ │ │ │ , span<char const> /*buf*/); │ │ │ - virtual bool on_suggest (piece_index_t); │ │ │ - virtual bool on_cancel (peer_request const&); │ │ │ virtual bool on_reject (peer_request const&); │ │ │ + virtual bool on_cancel (peer_request const&); │ │ │ + virtual bool on_suggest (piece_index_t); │ │ │ + virtual void sent_suggest (piece_index_t); │ │ │ virtual void sent_cancel (peer_request const&); │ │ │ virtual void sent_have_all (); │ │ │ + virtual void sent_choke (); │ │ │ + virtual void sent_have_none (); │ │ │ virtual void sent_allow_fast (piece_index_t); │ │ │ virtual void sent_reject_request (peer_request const&); │ │ │ - virtual void sent_have_none (); │ │ │ - virtual void sent_suggest (piece_index_t); │ │ │ virtual void sent_request (peer_request const&); │ │ │ - virtual void sent_choke (); │ │ │ - virtual void sent_not_interested (); │ │ │ virtual void sent_piece (peer_request const&); │ │ │ virtual void sent_interested (); │ │ │ + virtual void sent_not_interested (); │ │ │ virtual void sent_have (piece_index_t); │ │ │ virtual void sent_unchoke (); │ │ │ virtual void sent_payload (int /* bytes */); │ │ │ virtual bool can_disconnect (error_code const& /*ec*/); │ │ │ virtual bool on_extended (int /*length*/, int /*msg*/, │ │ │ span<char const> /*body*/); │ │ │ virtual bool on_unknown_message (int /*length*/, int /*msg*/, │ │ │ span<char const> /*body*/); │ │ │ - virtual void on_piece_failed (piece_index_t); │ │ │ virtual void on_piece_pass (piece_index_t); │ │ │ + virtual void on_piece_failed (piece_index_t); │ │ │ virtual void tick (); │ │ │ virtual bool write_request (peer_request const&); │ │ │ }; │ │ │ │ │ │ [report issue]
    │ │ │

    type()

    │ │ │
    │ │ │ @@ -640,39 +640,39 @@
    │ │ │  virtual bool on_extension_handshake (bdecode_node const&);
    │ │ │  
    │ │ │

    called when the extension handshake from the other end is received │ │ │ if this returns false, it means that this extension isn't │ │ │ supported by this peer. It will result in this peer_plugin │ │ │ being removed from the peer_connection and destructed. │ │ │ this is not called for web seeds

    │ │ │ - │ │ │ - │ │ │ │ │ │ │ │ │ - │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ + │ │ │ + │ │ │ │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    on_have_none() on_not_interested() on_request() on_interested() on_bitfield() on_unchoke() on_dont_have() on_allowed_fast() on_choke() on_have() on_have_all()

    │ │ │ + │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    on_request() on_interested() on_not_interested() on_allowed_fast() on_dont_have() on_have_all() on_choke() on_unchoke() on_bitfield() on_have_none() on_have()

    │ │ │
    │ │ │ -virtual bool on_have_none ();
    │ │ │ -virtual bool on_have (piece_index_t);
    │ │ │ +virtual bool on_choke ();
    │ │ │ +virtual bool on_interested ();
    │ │ │ +virtual bool on_dont_have (piece_index_t);
    │ │ │ +virtual bool on_not_interested ();
    │ │ │ +virtual bool on_allowed_fast (piece_index_t);
    │ │ │  virtual bool on_unchoke ();
    │ │ │  virtual bool on_bitfield (bitfield const& /*bitfield*/);
    │ │ │ +virtual bool on_have (piece_index_t);
    │ │ │ +virtual bool on_have_none ();
    │ │ │  virtual bool on_request (peer_request const&);
    │ │ │ -virtual bool on_not_interested ();
    │ │ │ -virtual bool on_choke ();
    │ │ │  virtual bool on_have_all ();
    │ │ │ -virtual bool on_allowed_fast (piece_index_t);
    │ │ │ -virtual bool on_dont_have (piece_index_t);
    │ │ │ -virtual bool on_interested ();
    │ │ │  
    │ │ │

    returning true from any of the message handlers │ │ │ indicates that the plugin has handled the message. │ │ │ it will break the plugin chain traversing and not let │ │ │ anyone else handle the message, including the default │ │ │ handler.

    │ │ │ [report issue]
    │ │ │ @@ -684,25 +684,25 @@ │ │ │ │ │ │

    This function is called when the peer connection is receiving │ │ │ a piece. buf points (non-owning pointer) to the data in an │ │ │ internal immutable disk buffer. The length of the data is specified │ │ │ in the length member of the piece parameter. │ │ │ returns true to indicate that the piece is handled and the │ │ │ rest of the logic should be ignored.

    │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    sent_have() sent_not_interested() sent_unchoke() sent_interested() sent_piece()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    sent_piece() sent_unchoke() sent_interested() sent_have() sent_not_interested()

    │ │ │
    │ │ │ -virtual void sent_not_interested ();
    │ │ │  virtual void sent_piece (peer_request const&);
    │ │ │  virtual void sent_interested ();
    │ │ │ +virtual void sent_not_interested ();
    │ │ │  virtual void sent_have (piece_index_t);
    │ │ │  virtual void sent_unchoke ();
    │ │ │  
    │ │ │

    called after a choke message has been sent to the peer

    │ │ │ [report issue]
    │ │ │
    │ │ │

    sent_payload()

    │ │ │ @@ -745,16 +745,16 @@ │ │ │ │ │ │

    this is not called for web seeds

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    on_piece_pass() on_piece_failed()

    │ │ │
    │ │ │ -virtual void on_piece_failed (piece_index_t);
    │ │ │  virtual void on_piece_pass (piece_index_t);
    │ │ │ +virtual void on_piece_failed (piece_index_t);
    │ │ │  
    │ │ │

    called when a piece that this peer participated in either │ │ │ fails or passes the hash_check

    │ │ │ [report issue]
    │ │ │
    │ │ │

    tick()

    │ │ │
    │ │ │ @@ -824,14 +824,27 @@
    │ │ │  

    constructor function for the ut_pex extension. The ut_pex │ │ │ extension allows peers to gossip about their connections, allowing │ │ │ the swarm stay well connected and peers aware of more peers in the │ │ │ swarm. This extension is enabled by default unless explicitly disabled in │ │ │ the session constructor.

    │ │ │

    This can either be passed in the add_torrent_params::extensions field, or │ │ │ via torrent_handle::add_extension().

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    create_smart_ban_plugin()

    │ │ │ +

    Declared in "libtorrent/extensions/smart_ban.hpp"

    │ │ │ +
    │ │ │ +std::shared_ptr<torrent_plugin> create_smart_ban_plugin (torrent_handle const&, client_data_t);
    │ │ │ +
    │ │ │ +

    constructor function for the smart ban extension. The extension keeps │ │ │ +track of the data peers have sent us for failing pieces and once the │ │ │ +piece completes and passes the hash check bans the peers that turned │ │ │ +out to have sent corrupt data. │ │ │ +This function can either be passed in the add_torrent_params::extensions │ │ │ +field, or via torrent_handle::add_extension().

    │ │ │ [report issue]
    │ │ │
    │ │ │

    create_ut_metadata_plugin()

    │ │ │

    Declared in "libtorrent/extensions/ut_metadata.hpp"

    │ │ │
    │ │ │  std::shared_ptr<torrent_plugin> create_ut_metadata_plugin (torrent_handle const&, client_data_t);
    │ │ │  
    │ │ │ @@ -839,27 +852,14 @@ │ │ │ extension allows peers to request the .torrent file (or more │ │ │ specifically the info-dictionary of the .torrent file) from each │ │ │ other. This is the main building block in making magnet links work. │ │ │ This extension is enabled by default unless explicitly disabled in │ │ │ the session constructor.

    │ │ │

    This can either be passed in the add_torrent_params::extensions field, or │ │ │ via torrent_handle::add_extension().

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    create_smart_ban_plugin()

    │ │ │ -

    Declared in "libtorrent/extensions/smart_ban.hpp"

    │ │ │ -
    │ │ │ -std::shared_ptr<torrent_plugin> create_smart_ban_plugin (torrent_handle const&, client_data_t);
    │ │ │ -
    │ │ │ -

    constructor function for the smart ban extension. The extension keeps │ │ │ -track of the data peers have sent us for failing pieces and once the │ │ │ -piece completes and passes the hash check bans the peers that turned │ │ │ -out to have sent corrupt data. │ │ │ -This function can either be passed in the add_torrent_params::extensions │ │ │ -field, or via torrent_handle::add_extension().

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │
    │ │ │
    │ │ │ │ │ │ -
    │ │ │ -
    │ │ │ -

    session_proxy

    │ │ │ -

    Declared in "libtorrent/session.hpp"

    │ │ │ -

    this is a holder for the internal session implementation object. Once the │ │ │ -session destruction is explicitly initiated, this holder is used to │ │ │ -synchronize the completion of the shutdown. The lifetime of this object │ │ │ -may outlive session, causing the session destructor to not block. The │ │ │ -session_proxy destructor will block however, until the underlying session │ │ │ -is done shutting down.

    │ │ │ -
    │ │ │ -struct session_proxy
    │ │ │ -{
    │ │ │ -   session_proxy ();
    │ │ │ -   ~session_proxy ();
    │ │ │ -   session_proxy (session_proxy&&) noexcept;
    │ │ │ -   session_proxy (session_proxy const&);
    │ │ │ -   session_proxy& operator= (session_proxy const&) &;
    │ │ │ -   session_proxy& operator= (session_proxy&&) & noexcept;
    │ │ │ -};
    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    operator=() session_proxy() ~session_proxy()

    │ │ │ -
    │ │ │ -session_proxy ();
    │ │ │ -~session_proxy ();
    │ │ │ -session_proxy (session_proxy&&) noexcept;
    │ │ │ -session_proxy (session_proxy const&);
    │ │ │ -session_proxy& operator= (session_proxy const&) &;
    │ │ │ -session_proxy& operator= (session_proxy&&) & noexcept;
    │ │ │ -
    │ │ │ -

    default constructor, does not refer to any session │ │ │ -implementation object.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -
    │ │ │ -

    session

    │ │ │ -

    Declared in "libtorrent/session.hpp"

    │ │ │ -

    The session holds all state that spans multiple torrents. Among other │ │ │ -things it runs the network loop and manages all torrents. Once it's │ │ │ -created, the session object will spawn the main thread that will do all │ │ │ -the work. The main thread will be idle as long it doesn't have any │ │ │ -torrents to participate in.

    │ │ │ -

    You have some control over session configuration through the │ │ │ -session_handle::apply_settings() member function. To change one or more │ │ │ -configuration options, create a settings_pack. object and fill it with │ │ │ -the settings to be set and pass it in to session::apply_settings().

    │ │ │ -

    see apply_settings().

    │ │ │ -
    │ │ │ -struct session : session_handle
    │ │ │ -{
    │ │ │ -   session (session_params&& params, session_flags_t flags);
    │ │ │ -   session ();
    │ │ │ -   explicit session (session_params&& params);
    │ │ │ -   session (session_params const& params, session_flags_t flags);
    │ │ │ -   explicit session (session_params const& params);
    │ │ │ -   session (session_params const& params, io_context& ios, session_flags_t);
    │ │ │ -   session (session_params&& params, io_context& ios, session_flags_t);
    │ │ │ -   session (session_params&& params, io_context& ios);
    │ │ │ -   session (session_params const& params, io_context& ios);
    │ │ │ -   ~session ();
    │ │ │ -   session_proxy abort ();
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    session()

    │ │ │ -
    │ │ │ -session (session_params&& params, session_flags_t flags);
    │ │ │ -session ();
    │ │ │ -explicit session (session_params&& params);
    │ │ │ -session (session_params const& params, session_flags_t flags);
    │ │ │ -explicit session (session_params const& params);
    │ │ │ -
    │ │ │ -

    Constructs the session objects which acts as the container of torrents. │ │ │ -In order to avoid a race condition between starting the session and │ │ │ -configuring it, you can pass in a session_params object. Its settings │ │ │ -will take effect before the session starts up.

    │ │ │ -

    The overloads taking flags can be used to start a session in │ │ │ -paused mode (by passing in session::paused). Note that │ │ │ -add_default_plugins do not have an affect on constructors that │ │ │ -take a session_params object. It already contains the plugins to use.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    session()

    │ │ │ -
    │ │ │ -session (session_params const& params, io_context& ios, session_flags_t);
    │ │ │ -session (session_params&& params, io_context& ios, session_flags_t);
    │ │ │ -session (session_params&& params, io_context& ios);
    │ │ │ -session (session_params const& params, io_context& ios);
    │ │ │ -
    │ │ │ -

    Overload of the constructor that takes an external io_context to run │ │ │ -the session object on. This is primarily useful for tests that may want │ │ │ -to run multiple sessions on a single io_context, or low resource │ │ │ -systems where additional threads are expensive and sharing an │ │ │ -io_context with other events is fine.

    │ │ │ -
    │ │ │ -

    Warning

    │ │ │ -

    The session object does not cleanly terminate with an external │ │ │ -io_context. The io_context::run() call must have returned │ │ │ -before it's safe to destruct the session. Which means you MUST │ │ │ -call session::abort() and save the session_proxy first, then │ │ │ -destruct the session object, then sync with the io_context, then │ │ │ -destruct the session_proxy object.

    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    ~session()

    │ │ │ -
    │ │ │ -~session ();
    │ │ │ -
    │ │ │ -

    The destructor of session will notify all trackers that our torrents │ │ │ -have been shut down. If some trackers are down, they will time out. │ │ │ -All this before the destructor of session returns. So, it's advised │ │ │ -that any kind of interface (such as windows) are closed before │ │ │ -destructing the session object. Because it can take a few second for │ │ │ -it to finish. The timeout can be set with apply_settings().

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    abort()

    │ │ │ -
    │ │ │ -session_proxy abort ();
    │ │ │ -
    │ │ │ -

    In case you want to destruct the session asynchronously, you can │ │ │ -request a session destruction proxy. If you don't do this, the │ │ │ -destructor of the session object will block while the trackers are │ │ │ -contacted. If you keep one session_proxy to the session when │ │ │ -destructing it, the destructor will not block, but start to close down │ │ │ -the session, the destructor of the proxy will then synchronize the │ │ │ -threads. So, the destruction of the session is performed from the │ │ │ -session destructor call until the session_proxy destructor │ │ │ -call. The session_proxy does not have any operations on it (since │ │ │ -the session is being closed down, no operations are allowed on it). │ │ │ -The only valid operation is calling the destructor:

    │ │ │ -
    │ │ │ -struct session_proxy {};
    │ │ │ -
    │ │ │ │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │
    │ │ │

    read_session_params() write_session_params_buf() write_session_params()

    │ │ │

    Declared in "libtorrent/session_params.hpp"

    │ │ │
    │ │ │ -std::vector<char> write_session_params_buf (session_params const& sp
    │ │ │ +session_params read_session_params (bdecode_node const& e
    │ │ │     , save_state_flags_t flags = save_state_flags_t::all());
    │ │ │  entry write_session_params (session_params const& sp
    │ │ │     , save_state_flags_t flags = save_state_flags_t::all());
    │ │ │ -session_params read_session_params (span<char const> buf
    │ │ │ +std::vector<char> write_session_params_buf (session_params const& sp
    │ │ │     , save_state_flags_t flags = save_state_flags_t::all());
    │ │ │ -session_params read_session_params (bdecode_node const& e
    │ │ │ +session_params read_session_params (span<char const> buf
    │ │ │     , save_state_flags_t flags = save_state_flags_t::all());
    │ │ │  
    │ │ │

    These functions serialize and de-serialize a session_params object to and │ │ │ from bencoded form. The session_params object is used to initialize a new │ │ │ session using the state from a previous one (or by programmatically configure │ │ │ the session up-front). │ │ │ The flags parameter can be used to only save and load certain aspects of the │ │ │ ├── html2text {} │ │ │ │ @@ -2,96 +2,96 @@ │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.0.14 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ * _s_e_s_s_i_o_n___p_a_r_a_m_s │ │ │ │ o _s_e_s_s_i_o_n___p_a_r_a_m_s_(_) │ │ │ │ o _s_e_s_s_i_o_n___p_a_r_a_m_s_(_) │ │ │ │ + * _s_e_s_s_i_o_n___p_r_o_x_y │ │ │ │ + o _o_p_e_r_a_t_o_r_=_(_)_ _~_s_e_s_s_i_o_n___p_r_o_x_y_(_)_ _s_e_s_s_i_o_n___p_r_o_x_y_(_) │ │ │ │ + * _s_e_s_s_i_o_n │ │ │ │ + o _s_e_s_s_i_o_n_(_) │ │ │ │ + o _s_e_s_s_i_o_n_(_) │ │ │ │ + o _~_s_e_s_s_i_o_n_(_) │ │ │ │ + o _a_b_o_r_t_(_) │ │ │ │ * _s_e_s_s_i_o_n___h_a_n_d_l_e │ │ │ │ o _i_s___v_a_l_i_d_(_) │ │ │ │ o _s_e_s_s_i_o_n___s_t_a_t_e_(_) │ │ │ │ o _r_e_f_r_e_s_h___t_o_r_r_e_n_t___s_t_a_t_u_s_(_)_ _g_e_t___t_o_r_r_e_n_t___s_t_a_t_u_s_(_) │ │ │ │ o _p_o_s_t___t_o_r_r_e_n_t___u_p_d_a_t_e_s_(_) │ │ │ │ o _p_o_s_t___s_e_s_s_i_o_n___s_t_a_t_s_(_) │ │ │ │ o _p_o_s_t___d_h_t___s_t_a_t_s_(_) │ │ │ │ o _s_e_t___d_h_t___s_t_a_t_e_(_) │ │ │ │ - o _f_i_n_d___t_o_r_r_e_n_t_(_)_ _g_e_t___t_o_r_r_e_n_t_s_(_) │ │ │ │ - o _a_s_y_n_c___a_d_d___t_o_r_r_e_n_t_(_)_ _a_d_d___t_o_r_r_e_n_t_(_) │ │ │ │ - o _r_e_s_u_m_e_(_)_ _p_a_u_s_e_(_)_ _i_s___p_a_u_s_e_d_(_) │ │ │ │ + o _g_e_t___t_o_r_r_e_n_t_s_(_)_ _f_i_n_d___t_o_r_r_e_n_t_(_) │ │ │ │ + o _a_d_d___t_o_r_r_e_n_t_(_)_ _a_s_y_n_c___a_d_d___t_o_r_r_e_n_t_(_) │ │ │ │ + o _r_e_s_u_m_e_(_)_ _i_s___p_a_u_s_e_d_(_)_ _p_a_u_s_e_(_) │ │ │ │ o _i_s___d_h_t___r_u_n_n_i_n_g_(_) │ │ │ │ o _s_e_t___d_h_t___s_t_o_r_a_g_e_(_) │ │ │ │ o _a_d_d___d_h_t___n_o_d_e_(_) │ │ │ │ o _d_h_t___g_e_t___i_t_e_m_(_) │ │ │ │ o _d_h_t___g_e_t___i_t_e_m_(_) │ │ │ │ o _d_h_t___p_u_t___i_t_e_m_(_) │ │ │ │ o _d_h_t___p_u_t___i_t_e_m_(_) │ │ │ │ o _d_h_t___a_n_n_o_u_n_c_e_(_)_ _d_h_t___g_e_t___p_e_e_r_s_(_) │ │ │ │ o _d_h_t___l_i_v_e___n_o_d_e_s_(_) │ │ │ │ o _d_h_t___s_a_m_p_l_e___i_n_f_o_h_a_s_h_e_s_(_) │ │ │ │ o _d_h_t___d_i_r_e_c_t___r_e_q_u_e_s_t_(_) │ │ │ │ o _a_d_d___e_x_t_e_n_s_i_o_n_(_) │ │ │ │ - o _g_e_t___i_p___f_i_l_t_e_r_(_)_ _s_e_t___i_p___f_i_l_t_e_r_(_) │ │ │ │ + o _s_e_t___i_p___f_i_l_t_e_r_(_)_ _g_e_t___i_p___f_i_l_t_e_r_(_) │ │ │ │ o _s_e_t___p_o_r_t___f_i_l_t_e_r_(_) │ │ │ │ o _l_i_s_t_e_n___p_o_r_t_(_)_ _i_s___l_i_s_t_e_n_i_n_g_(_)_ _s_s_l___l_i_s_t_e_n___p_o_r_t_(_) │ │ │ │ o _g_e_t___p_e_e_r___c_l_a_s_s___f_i_l_t_e_r_(_)_ _s_e_t___p_e_e_r___c_l_a_s_s___f_i_l_t_e_r_(_) │ │ │ │ o _s_e_t___p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r_(_)_ _g_e_t___p_e_e_r___c_l_a_s_s___t_y_p_e___f_i_l_t_e_r_(_) │ │ │ │ o _c_r_e_a_t_e___p_e_e_r___c_l_a_s_s_(_) │ │ │ │ o _d_e_l_e_t_e___p_e_e_r___c_l_a_s_s_(_) │ │ │ │ - o _g_e_t___p_e_e_r___c_l_a_s_s_(_)_ _s_e_t___p_e_e_r___c_l_a_s_s_(_) │ │ │ │ + o _s_e_t___p_e_e_r___c_l_a_s_s_(_)_ _g_e_t___p_e_e_r___c_l_a_s_s_(_) │ │ │ │ o _r_e_m_o_v_e___t_o_r_r_e_n_t_(_) │ │ │ │ - o _g_e_t___s_e_t_t_i_n_g_s_(_)_ _a_p_p_l_y___s_e_t_t_i_n_g_s_(_) │ │ │ │ - o _p_o_p___a_l_e_r_t_s_(_)_ _s_e_t___a_l_e_r_t___n_o_t_i_f_y_(_)_ _w_a_i_t___f_o_r___a_l_e_r_t_(_) │ │ │ │ + o _a_p_p_l_y___s_e_t_t_i_n_g_s_(_)_ _g_e_t___s_e_t_t_i_n_g_s_(_) │ │ │ │ + o _w_a_i_t___f_o_r___a_l_e_r_t_(_)_ _p_o_p___a_l_e_r_t_s_(_)_ _s_e_t___a_l_e_r_t___n_o_t_i_f_y_(_) │ │ │ │ o _a_d_d___p_o_r_t___m_a_p_p_i_n_g_(_)_ _d_e_l_e_t_e___p_o_r_t___m_a_p_p_i_n_g_(_) │ │ │ │ o _r_e_o_p_e_n___n_e_t_w_o_r_k___s_o_c_k_e_t_s_(_) │ │ │ │ o _n_a_t_i_v_e___h_a_n_d_l_e_(_) │ │ │ │ - * _s_e_s_s_i_o_n___p_r_o_x_y │ │ │ │ - o _o_p_e_r_a_t_o_r_=_(_)_ _s_e_s_s_i_o_n___p_r_o_x_y_(_)_ _~_s_e_s_s_i_o_n___p_r_o_x_y_(_) │ │ │ │ - * _s_e_s_s_i_o_n │ │ │ │ - o _s_e_s_s_i_o_n_(_) │ │ │ │ - o _s_e_s_s_i_o_n_(_) │ │ │ │ - o _~_s_e_s_s_i_o_n_(_) │ │ │ │ - o _a_b_o_r_t_(_) │ │ │ │ * _r_e_a_d___s_e_s_s_i_o_n___p_a_r_a_m_s_(_)_ _w_r_i_t_e___s_e_s_s_i_o_n___p_a_r_a_m_s___b_u_f_(_)_ _w_r_i_t_e___s_e_s_s_i_o_n___p_a_r_a_m_s_(_) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ sseessssiioonn__ppaarraammss ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___p_a_r_a_m_s_._h_p_p" │ │ │ │ The _s_e_s_s_i_o_n___p_a_r_a_m_s is a parameters pack for configuring the _s_e_s_s_i_o_n before it's │ │ │ │ started. │ │ │ │ struct session_params │ │ │ │ { │ │ │ │ - sseessssiioonn__ppaarraammss (settings_pack const& sp); │ │ │ │ sseessssiioonn__ppaarraammss (); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack&& sp); │ │ │ │ - sseessssiioonn__ppaarraammss (settings_pack const& sp │ │ │ │ - , std::vector> exts); │ │ │ │ + sseessssiioonn__ppaarraammss (settings_pack const& sp); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack&& sp │ │ │ │ , std::vector> exts); │ │ │ │ + sseessssiioonn__ppaarraammss (settings_pack const& sp │ │ │ │ + , std::vector> exts); │ │ │ │ │ │ │ │ settings_pack settings; │ │ │ │ std::vector> extensions; │ │ │ │ dht::dht_state dht_state; │ │ │ │ dht::dht_storage_constructor_type dht_storage_constructor; │ │ │ │ disk_io_constructor_type disk_io_constructor; │ │ │ │ std::map ext_state; │ │ │ │ libtorrent::ip_filter ip_filter; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** sseessssiioonn__ppaarraammss(()) ********** │ │ │ │ -sseessssiioonn__ppaarraammss (settings_pack const& sp); │ │ │ │ sseessssiioonn__ppaarraammss (); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack&& sp); │ │ │ │ +sseessssiioonn__ppaarraammss (settings_pack const& sp); │ │ │ │ This constructor can be used to start with the default plugins (ut_metadata, │ │ │ │ ut_pex and smart_ban). Pass a _s_e_t_t_i_n_g_s___p_a_c_k to set the initial settings when │ │ │ │ the _s_e_s_s_i_o_n starts. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** sseessssiioonn__ppaarraammss(()) ********** │ │ │ │ -sseessssiioonn__ppaarraammss (settings_pack const& sp │ │ │ │ - , std::vector> exts); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack&& sp │ │ │ │ , std::vector> exts); │ │ │ │ +sseessssiioonn__ppaarraammss (settings_pack const& sp │ │ │ │ + , std::vector> exts); │ │ │ │ This constructor helps to configure the set of initial plugins to be added to │ │ │ │ the _s_e_s_s_i_o_n before it's started. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ settings │ │ │ │ The settings to configure the _s_e_s_s_i_o_n with │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ extensions │ │ │ │ @@ -112,49 +112,157 @@ │ │ │ │ primarily here to make it convenient to save and restore state across │ │ │ │ sessions, using _r_e_a_d___s_e_s_s_i_o_n___p_a_r_a_m_s_(_) and _w_r_i_t_e___s_e_s_s_i_o_n___p_a_r_a_m_s_(_). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ip_filter │ │ │ │ the IP filter to use for the _s_e_s_s_i_o_n. This restricts which peers are │ │ │ │ allowed to connect. As if passed to _s_e_t___i_p___f_i_l_t_e_r_(_). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ sseessssiioonn__pprrooxxyy ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ +this is a holder for the internal _s_e_s_s_i_o_n implementation object. Once the │ │ │ │ +_s_e_s_s_i_o_n destruction is explicitly initiated, this holder is used to synchronize │ │ │ │ +the completion of the shutdown. The lifetime of this object may outlive │ │ │ │ +_s_e_s_s_i_o_n, causing the _s_e_s_s_i_o_n destructor to not block. The _s_e_s_s_i_o_n___p_r_o_x_y │ │ │ │ +destructor will block however, until the underlying _s_e_s_s_i_o_n is done shutting │ │ │ │ +down. │ │ │ │ +struct session_proxy │ │ │ │ +{ │ │ │ │ + sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ + ~~sseessssiioonn__pprrooxxyy (); │ │ │ │ + sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ + sseessssiioonn__pprrooxxyy (); │ │ │ │ + session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ + session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ooppeerraattoorr==(()) ~~sseessssiioonn__pprrooxxyy(()) sseessssiioonn__pprrooxxyy(()) ********** │ │ │ │ +sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ +~~sseessssiioonn__pprrooxxyy (); │ │ │ │ +sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ +sseessssiioonn__pprrooxxyy (); │ │ │ │ +session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ +session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ +default constructor, does not refer to any _s_e_s_s_i_o_n implementation object. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ sseessssiioonn ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ +The _s_e_s_s_i_o_n holds all state that spans multiple torrents. Among other things it │ │ │ │ +runs the network loop and manages all torrents. Once it's created, the _s_e_s_s_i_o_n │ │ │ │ +object will spawn the main thread that will do all the work. The main thread │ │ │ │ +will be idle as long it doesn't have any torrents to participate in. │ │ │ │ +You have some control over _s_e_s_s_i_o_n configuration through the session_handle:: │ │ │ │ +apply_settings() member function. To change one or more configuration options, │ │ │ │ +create a _s_e_t_t_i_n_g_s___p_a_c_k. object and fill it with the settings to be set and pass │ │ │ │ +it in to session::apply_settings(). │ │ │ │ +see _a_p_p_l_y___s_e_t_t_i_n_g_s_(_). │ │ │ │ +struct session : session_handle │ │ │ │ +{ │ │ │ │ + sseessssiioonn (session_params const& params, session_flags_t flags); │ │ │ │ + sseessssiioonn (session_params&& params, session_flags_t flags); │ │ │ │ + explicit sseessssiioonn (session_params const& params); │ │ │ │ + sseessssiioonn (); │ │ │ │ + explicit sseessssiioonn (session_params&& params); │ │ │ │ + sseessssiioonn (session_params&& params, io_context& ios, session_flags_t); │ │ │ │ + sseessssiioonn (session_params&& params, io_context& ios); │ │ │ │ + sseessssiioonn (session_params const& params, io_context& ios); │ │ │ │ + sseessssiioonn (session_params const& params, io_context& ios, session_flags_t); │ │ │ │ + ~~sseessssiioonn (); │ │ │ │ + session_proxy aabboorrtt (); │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** sseessssiioonn(()) ********** │ │ │ │ +sseessssiioonn (session_params const& params, session_flags_t flags); │ │ │ │ +sseessssiioonn (session_params&& params, session_flags_t flags); │ │ │ │ +explicit sseessssiioonn (session_params const& params); │ │ │ │ +sseessssiioonn (); │ │ │ │ +explicit sseessssiioonn (session_params&& params); │ │ │ │ +Constructs the _s_e_s_s_i_o_n objects which acts as the container of torrents. In │ │ │ │ +order to avoid a race condition between starting the _s_e_s_s_i_o_n and configuring │ │ │ │ +it, you can pass in a _s_e_s_s_i_o_n___p_a_r_a_m_s object. Its settings will take effect │ │ │ │ +before the _s_e_s_s_i_o_n starts up. │ │ │ │ +The overloads taking flags can be used to start a _s_e_s_s_i_o_n in paused mode (by │ │ │ │ +passing in session::paused). Note that add_default_plugins do not have an │ │ │ │ +affect on constructors that take a _s_e_s_s_i_o_n___p_a_r_a_m_s object. It already contains │ │ │ │ +the plugins to use. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** sseessssiioonn(()) ********** │ │ │ │ +sseessssiioonn (session_params&& params, io_context& ios, session_flags_t); │ │ │ │ +sseessssiioonn (session_params&& params, io_context& ios); │ │ │ │ +sseessssiioonn (session_params const& params, io_context& ios); │ │ │ │ +sseessssiioonn (session_params const& params, io_context& ios, session_flags_t); │ │ │ │ +Overload of the constructor that takes an external io_context to run the │ │ │ │ +_s_e_s_s_i_o_n object on. This is primarily useful for tests that may want to run │ │ │ │ +multiple sessions on a single io_context, or low resource systems where │ │ │ │ +additional threads are expensive and sharing an io_context with other events is │ │ │ │ +fine. │ │ │ │ +Warning │ │ │ │ +The _s_e_s_s_i_o_n object does not cleanly terminate with an external io_context. The │ │ │ │ +io_context::run() call mmuusstt have returned before it's safe to destruct the │ │ │ │ +_s_e_s_s_i_o_n. Which means you MMUUSSTT call _s_e_s_s_i_o_n_:_:_a_b_o_r_t_(_) and save the _s_e_s_s_i_o_n___p_r_o_x_y │ │ │ │ +first, then destruct the _s_e_s_s_i_o_n object, then sync with the io_context, then │ │ │ │ +destruct the _s_e_s_s_i_o_n___p_r_o_x_y object. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ~~sseessssiioonn(()) ********** │ │ │ │ +~~sseessssiioonn (); │ │ │ │ +The destructor of _s_e_s_s_i_o_n will notify all trackers that our torrents have been │ │ │ │ +shut down. If some trackers are down, they will time out. All this before the │ │ │ │ +destructor of _s_e_s_s_i_o_n returns. So, it's advised that any kind of interface │ │ │ │ +(such as windows) are closed before destructing the _s_e_s_s_i_o_n object. Because it │ │ │ │ +can take a few second for it to finish. The timeout can be set with │ │ │ │ +_a_p_p_l_y___s_e_t_t_i_n_g_s_(_). │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** aabboorrtt(()) ********** │ │ │ │ +session_proxy aabboorrtt (); │ │ │ │ +In case you want to destruct the _s_e_s_s_i_o_n asynchronously, you can request a │ │ │ │ +_s_e_s_s_i_o_n destruction proxy. If you don't do this, the destructor of the _s_e_s_s_i_o_n │ │ │ │ +object will block while the trackers are contacted. If you keep one │ │ │ │ +session_proxy to the _s_e_s_s_i_o_n when destructing it, the destructor will not │ │ │ │ +block, but start to close down the _s_e_s_s_i_o_n, the destructor of the proxy will │ │ │ │ +then synchronize the threads. So, the destruction of the _s_e_s_s_i_o_n is performed │ │ │ │ +from the session destructor call until the session_proxy destructor call. The │ │ │ │ +session_proxy does not have any operations on it (since the _s_e_s_s_i_o_n is being │ │ │ │ +closed down, no operations are allowed on it). The only valid operation is │ │ │ │ +calling the destructor: │ │ │ │ +struct session_proxy {}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ sseessssiioonn__hhaannddllee ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___h_a_n_d_l_e_._h_p_p" │ │ │ │ this class provides a non-owning handle to a _s_e_s_s_i_o_n and a subset of the │ │ │ │ interface of the _s_e_s_s_i_o_n class. If the underlying _s_e_s_s_i_o_n is destructed any │ │ │ │ handle to it will no longer be valid. _i_s___v_a_l_i_d_(_) will return false and any │ │ │ │ operation on it will throw a system_error exception, with error code │ │ │ │ invalid_session_handle. │ │ │ │ struct session_handle │ │ │ │ { │ │ │ │ bool iiss__vvaalliidd () const; │ │ │ │ session_params sseessssiioonn__ssttaattee (save_state_flags_t flags = │ │ │ │ save_state_flags_t::all()) const; │ │ │ │ + void rreeffrreesshh__ttoorrrreenntt__ssttaattuuss (std::vector* ret │ │ │ │ + , status_flags_t flags = {}) const; │ │ │ │ std::vector ggeett__ttoorrrreenntt__ssttaattuuss ( │ │ │ │ std::function const& pred │ │ │ │ , status_flags_t flags = {}) const; │ │ │ │ - void rreeffrreesshh__ttoorrrreenntt__ssttaattuuss (std::vector* ret │ │ │ │ - , status_flags_t flags = {}) const; │ │ │ │ void ppoosstt__ttoorrrreenntt__uuppddaatteess (status_flags_t flags = status_flags_t::all()); │ │ │ │ void ppoosstt__sseessssiioonn__ssttaattss (); │ │ │ │ void ppoosstt__ddhhtt__ssttaattss (); │ │ │ │ void sseett__ddhhtt__ssttaattee (dht::dht_state&& st); │ │ │ │ void sseett__ddhhtt__ssttaattee (dht::dht_state const& st); │ │ │ │ std::vector ggeett__ttoorrrreennttss () const; │ │ │ │ - torrent_handle ffiinndd__ttoorrrreenntt (sha1_hash const& info_hash) const; │ │ │ │ torrent_handle ffiinndd__ttoorrrreenntt (sha256_hash const& info_hash) const; │ │ │ │ - torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ - torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ + torrent_handle ffiinndd__ttoorrrreenntt (sha1_hash const& info_hash) const; │ │ │ │ + void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params, error_code& │ │ │ │ ec); │ │ │ │ - void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ + torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ + torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params, error_code& ec); │ │ │ │ - bool iiss__ppaauusseedd () const; │ │ │ │ void ppaauussee (); │ │ │ │ void rreessuummee (); │ │ │ │ + bool iiss__ppaauusseedd () const; │ │ │ │ bool iiss__ddhhtt__rruunnnniinngg () const; │ │ │ │ void sseett__ddhhtt__ssttoorraaggee (dht::dht_storage_constructor_type sc); │ │ │ │ void aadddd__ddhhtt__nnooddee (std::pair const& node); │ │ │ │ void ddhhtt__ggeett__iitteemm (sha1_hash const& target); │ │ │ │ void ddhhtt__ggeett__iitteemm (std::array key │ │ │ │ , std::string salt = std::string()); │ │ │ │ sha1_hash ddhhtt__ppuutt__iitteemm (entry data); │ │ │ │ @@ -169,38 +277,38 @@ │ │ │ │ void ddhhtt__ssaammppllee__iinnffoohhaasshheess (udp::endpoint const& ep, sha1_hash const& │ │ │ │ target); │ │ │ │ void ddhhtt__ddiirreecctt__rreeqquueesstt (udp::endpoint const& ep, entry const& e, │ │ │ │ client_data_t userdata = {}); │ │ │ │ void aadddd__eexxtteennssiioonn (std::shared_ptr ext); │ │ │ │ void aadddd__eexxtteennssiioonn (std::function( │ │ │ │ torrent_handle const&, client_data_t)> ext); │ │ │ │ - void sseett__iipp__ffiilltteerr (ip_filter f); │ │ │ │ ip_filter ggeett__iipp__ffiilltteerr () const; │ │ │ │ + void sseett__iipp__ffiilltteerr (ip_filter f); │ │ │ │ void sseett__ppoorrtt__ffiilltteerr (port_filter const& f); │ │ │ │ - unsigned short lliisstteenn__ppoorrtt () const; │ │ │ │ bool iiss__lliisstteenniinngg () const; │ │ │ │ + unsigned short lliisstteenn__ppoorrtt () const; │ │ │ │ unsigned short ssssll__lliisstteenn__ppoorrtt () const; │ │ │ │ - ip_filter ggeett__ppeeeerr__ccllaassss__ffiilltteerr () const; │ │ │ │ void sseett__ppeeeerr__ccllaassss__ffiilltteerr (ip_filter const& f); │ │ │ │ - void sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr (peer_class_type_filter const& f); │ │ │ │ + ip_filter ggeett__ppeeeerr__ccllaassss__ffiilltteerr () const; │ │ │ │ peer_class_type_filter ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr () const; │ │ │ │ + void sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr (peer_class_type_filter const& f); │ │ │ │ peer_class_t ccrreeaattee__ppeeeerr__ccllaassss (char const* name); │ │ │ │ void ddeelleettee__ppeeeerr__ccllaassss (peer_class_t cid); │ │ │ │ - void sseett__ppeeeerr__ccllaassss (peer_class_t cid, peer_class_info const& pci); │ │ │ │ peer_class_info ggeett__ppeeeerr__ccllaassss (peer_class_t cid) const; │ │ │ │ + void sseett__ppeeeerr__ccllaassss (peer_class_t cid, peer_class_info const& pci); │ │ │ │ void rreemmoovvee__ttoorrrreenntt (const torrent_handle&, remove_flags_t = {}); │ │ │ │ - void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ void aappppllyy__sseettttiinnggss (settings_pack&&); │ │ │ │ settings_pack ggeett__sseettttiinnggss () const; │ │ │ │ - void ppoopp__aalleerrttss (std::vector* alerts); │ │ │ │ + void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ void sseett__aalleerrtt__nnoottiiffyy (std::function const& fun); │ │ │ │ alert* wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ - void ddeelleettee__ppoorrtt__mmaappppiinngg (port_mapping_t handle); │ │ │ │ + void ppoopp__aalleerrttss (std::vector* alerts); │ │ │ │ std::vector aadddd__ppoorrtt__mmaappppiinngg (portmap_protocol t, int │ │ │ │ external_port, int local_port); │ │ │ │ + void ddeelleettee__ppoorrtt__mmaappppiinngg (port_mapping_t handle); │ │ │ │ void rreeooppeenn__nneettwwoorrkk__ssoocckkeettss (reopen_network_flags_t options = │ │ │ │ reopen_map_ports); │ │ │ │ std::shared_ptr nnaattiivvee__hhaannddllee () const; │ │ │ │ │ │ │ │ static constexpr save_state_flags_t ssaavvee__sseettttiinnggss = 0_bit; │ │ │ │ static constexpr save_state_flags_t ssaavvee__ddhhtt__ssttaattee = 2_bit; │ │ │ │ static constexpr save_state_flags_t ssaavvee__eexxtteennssiioonn__ssttaattee = 11_bit; │ │ │ │ @@ -227,19 +335,19 @@ │ │ │ │ returns the current _s_e_s_s_i_o_n state. This can be passed to _w_r_i_t_e___s_e_s_s_i_o_n___p_a_r_a_m_s_(_) │ │ │ │ to save the state to disk and restored using _r_e_a_d___s_e_s_s_i_o_n___p_a_r_a_m_s_(_) when │ │ │ │ constructing a new _s_e_s_s_i_o_n. The kind of state that's included is all settings, │ │ │ │ the DHT routing table, possibly plugin-specific state. the flags parameter can │ │ │ │ be used to only save certain parts of the _s_e_s_s_i_o_n state │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** rreeffrreesshh__ttoorrrreenntt__ssttaattuuss(()) ggeett__ttoorrrreenntt__ssttaattuuss(()) ********** │ │ │ │ +void rreeffrreesshh__ttoorrrreenntt__ssttaattuuss (std::vector* ret │ │ │ │ + , status_flags_t flags = {}) const; │ │ │ │ std::vector ggeett__ttoorrrreenntt__ssttaattuuss ( │ │ │ │ std::function const& pred │ │ │ │ , status_flags_t flags = {}) const; │ │ │ │ -void rreeffrreesshh__ttoorrrreenntt__ssttaattuuss (std::vector* ret │ │ │ │ - , status_flags_t flags = {}) const; │ │ │ │ Note │ │ │ │ these calls are potentially expensive and won't scale well with lots of │ │ │ │ torrents. If you're concerned about performance, consider using │ │ │ │ post_torrent_updates() instead. │ │ │ │ get_torrent_status returns a vector of the _t_o_r_r_e_n_t___s_t_a_t_u_s for every torrent │ │ │ │ which satisfies pred, which is a predicate function which determines if a │ │ │ │ torrent should be included in the returned set or not. Returning true means it │ │ │ │ @@ -290,31 +398,31 @@ │ │ │ │ ********** sseett__ddhhtt__ssttaattee(()) ********** │ │ │ │ void sseett__ddhhtt__ssttaattee (dht::dht_state&& st); │ │ │ │ void sseett__ddhhtt__ssttaattee (dht::dht_state const& st); │ │ │ │ set the DHT state for the _s_e_s_s_i_o_n. This will be taken into account the next │ │ │ │ time the DHT is started, as if it had been passed in via the _s_e_s_s_i_o_n___p_a_r_a_m_s on │ │ │ │ startup. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ffiinndd__ttoorrrreenntt(()) ggeett__ttoorrrreennttss(()) ********** │ │ │ │ +********** ggeett__ttoorrrreennttss(()) ffiinndd__ttoorrrreenntt(()) ********** │ │ │ │ std::vector ggeett__ttoorrrreennttss () const; │ │ │ │ -torrent_handle ffiinndd__ttoorrrreenntt (sha1_hash const& info_hash) const; │ │ │ │ torrent_handle ffiinndd__ttoorrrreenntt (sha256_hash const& info_hash) const; │ │ │ │ +torrent_handle ffiinndd__ttoorrrreenntt (sha1_hash const& info_hash) const; │ │ │ │ find_torrent() looks for a torrent with the given info-hash. In case there is │ │ │ │ such a torrent in the _s_e_s_s_i_o_n, a _t_o_r_r_e_n_t___h_a_n_d_l_e to that torrent is returned. In │ │ │ │ case the torrent cannot be found, an invalid _t_o_r_r_e_n_t___h_a_n_d_l_e is returned. │ │ │ │ See torrent_handle::is_valid() to know if the torrent was found or not. │ │ │ │ get_torrents() returns a vector of torrent_handles to all the torrents │ │ │ │ currently in the _s_e_s_s_i_o_n. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aassyynncc__aadddd__ttoorrrreenntt(()) aadddd__ttoorrrreenntt(()) ********** │ │ │ │ -torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ -torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ -torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params, error_code& ec); │ │ │ │ +********** aadddd__ttoorrrreenntt(()) aassyynncc__aadddd__ttoorrrreenntt(()) ********** │ │ │ │ void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ +torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params, error_code& ec); │ │ │ │ void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ +torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ +torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params); │ │ │ │ torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params, error_code& ec); │ │ │ │ You add torrents through the _a_d_d___t_o_r_r_e_n_t_(_) function where you give an object │ │ │ │ with all the parameters. The _a_d_d___t_o_r_r_e_n_t_(_) overloads will block until the │ │ │ │ torrent has been added (or failed to be added) and returns an error code and a │ │ │ │ _t_o_r_r_e_n_t___h_a_n_d_l_e. In order to add torrents more efficiently, consider using │ │ │ │ _a_s_y_n_c___a_d_d___t_o_r_r_e_n_t_(_) which returns immediately, without waiting for the torrent │ │ │ │ to add. Notification of the torrent being added is sent as _a_d_d___t_o_r_r_e_n_t___a_l_e_r_t. │ │ │ │ @@ -336,18 +444,18 @@ │ │ │ │ torrent_flags::paused and torrent_flags::auto_managed. In order to add a magnet │ │ │ │ link that will just download the metadata, but no payload, set the │ │ │ │ torrent_flags::upload_mode flag. │ │ │ │ Special consideration has to be taken when adding hybrid torrents (i.e. │ │ │ │ torrents that are BitTorrent v2 torrents that are backwards compatible with │ │ │ │ v1). For more details, see _B_i_t_T_o_r_r_e_n_t_ _v_2_ _t_o_r_r_e_n_t_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** rreessuummee(()) ppaauussee(()) iiss__ppaauusseedd(()) ********** │ │ │ │ -bool iiss__ppaauusseedd () const; │ │ │ │ +********** rreessuummee(()) iiss__ppaauusseedd(()) ppaauussee(()) ********** │ │ │ │ void ppaauussee (); │ │ │ │ void rreessuummee (); │ │ │ │ +bool iiss__ppaauusseedd () const; │ │ │ │ Pausing the _s_e_s_s_i_o_n has the same effect as pausing every torrent in it, except │ │ │ │ that torrents will not be resumed by the auto-manage mechanism. Resuming will │ │ │ │ restore the torrents to their previous paused state. i.e. the _s_e_s_s_i_o_n pause │ │ │ │ state is separate from the torrent pause state. A torrent is inactive if it is │ │ │ │ paused or if the _s_e_s_s_i_o_n is paused. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** iiss__ddhhtt__rruunnnniinngg(()) ********** │ │ │ │ @@ -491,17 +599,17 @@ │ │ │ │ smart ban _p_l_u_g_i_n │ │ │ │ A _p_l_u_g_i_n that, with a small overhead, can ban peers that sends bad data │ │ │ │ with very high accuracy. Should eliminate most problems on poisoned │ │ │ │ torrents. │ │ │ │ #include │ │ │ │ ses.add_extension(<::create_smart_ban_plugin); │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__iipp__ffiilltteerr(()) sseett__iipp__ffiilltteerr(()) ********** │ │ │ │ -void sseett__iipp__ffiilltteerr (ip_filter f); │ │ │ │ +********** sseett__iipp__ffiilltteerr(()) ggeett__iipp__ffiilltteerr(()) ********** │ │ │ │ ip_filter ggeett__iipp__ffiilltteerr () const; │ │ │ │ +void sseett__iipp__ffiilltteerr (ip_filter f); │ │ │ │ Sets a filter that will be used to reject and accept incoming as well as │ │ │ │ outgoing connections based on their originating ip address. The default filter │ │ │ │ will allow connections to any ip address. To build a set of rules for which │ │ │ │ addresses are accepted and not, see _i_p___f_i_l_t_e_r. │ │ │ │ Each time a peer is blocked because of the IP filter, a _p_e_e_r___b_l_o_c_k_e_d___a_l_e_r_t is │ │ │ │ generated. get_ip_filter() Returns the _i_p___f_i_l_t_e_r currently in the _s_e_s_s_i_o_n. See │ │ │ │ _i_p___f_i_l_t_e_r. │ │ │ │ @@ -510,26 +618,26 @@ │ │ │ │ void sseett__ppoorrtt__ffiilltteerr (port_filter const& f); │ │ │ │ apply _p_o_r_t___f_i_l_t_e_r f to incoming and outgoing peers. a port filter will reject │ │ │ │ making outgoing peer connections to certain remote ports. The main intention is │ │ │ │ to be able to avoid triggering certain anti-virus software by connecting to │ │ │ │ SMTP, FTP ports. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** lliisstteenn__ppoorrtt(()) iiss__lliisstteenniinngg(()) ssssll__lliisstteenn__ppoorrtt(()) ********** │ │ │ │ -unsigned short lliisstteenn__ppoorrtt () const; │ │ │ │ bool iiss__lliisstteenniinngg () const; │ │ │ │ +unsigned short lliisstteenn__ppoorrtt () const; │ │ │ │ unsigned short ssssll__lliisstteenn__ppoorrtt () const; │ │ │ │ is_listening() will tell you whether or not the _s_e_s_s_i_o_n has successfully opened │ │ │ │ a listening port. If it hasn't, this function will return false, and then you │ │ │ │ can set a new _s_e_t_t_i_n_g_s___p_a_c_k_:_:_l_i_s_t_e_n___i_n_t_e_r_f_a_c_e_s to try another interface and │ │ │ │ port to bind to. │ │ │ │ listen_port() returns the port we ended up listening on. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ggeett__ppeeeerr__ccllaassss__ffiilltteerr(()) sseett__ppeeeerr__ccllaassss__ffiilltteerr(()) ********** │ │ │ │ -ip_filter ggeett__ppeeeerr__ccllaassss__ffiilltteerr () const; │ │ │ │ void sseett__ppeeeerr__ccllaassss__ffiilltteerr (ip_filter const& f); │ │ │ │ +ip_filter ggeett__ppeeeerr__ccllaassss__ffiilltteerr () const; │ │ │ │ Sets the peer class filter for this _s_e_s_s_i_o_n. All new peer connections will take │ │ │ │ this into account and be added to the peer classes specified by this filter, │ │ │ │ based on the peer's IP address. │ │ │ │ The ip-filter essentially maps an IP -> uint32. Each bit in that 32 bit integer │ │ │ │ represents a peer class. The least significant bit represents class 0, the next │ │ │ │ bit class 1 and so on. │ │ │ │ For more info, see _i_p___f_i_l_t_e_r. │ │ │ │ @@ -547,16 +655,16 @@ │ │ │ │ removed from a peer as a result of this call, peer classes are only added. │ │ │ │ The peer_class argument cannot be greater than 31. The bitmasks representing │ │ │ │ peer classes in the peer_class_filter are 32 bits. │ │ │ │ The get_peer_class_filter() function returns the current filter. │ │ │ │ For more information, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr(()) ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr(()) ********** │ │ │ │ -void sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr (peer_class_type_filter const& f); │ │ │ │ peer_class_type_filter ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr () const; │ │ │ │ +void sseett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr (peer_class_type_filter const& f); │ │ │ │ Sets and gets the ppeeeerr ccllaassss ttyyppee ffiilltteerr. This is controls automatic peer class │ │ │ │ assignments to peers based on what kind of socket it is. │ │ │ │ It does not only support assigning peer classes, it also supports removing peer │ │ │ │ classes based on socket type. │ │ │ │ The order of these rules being applied are: │ │ │ │ 1. peer-class IP filter │ │ │ │ 2. peer-class type filter, removing classes │ │ │ │ @@ -584,17 +692,17 @@ │ │ │ │ Since peer classes are reference counted, this function will not remove the │ │ │ │ peer class if it's still assigned to torrents or peers. It will however remove │ │ │ │ it once the last peer and torrent drops their references to it. │ │ │ │ There is no need to call this function for custom peer classes. All peer │ │ │ │ classes will be properly destructed when the _s_e_s_s_i_o_n object destructs. │ │ │ │ For more information on peer classes, see _p_e_e_r_ _c_l_a_s_s_e_s. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__ppeeeerr__ccllaassss(()) sseett__ppeeeerr__ccllaassss(()) ********** │ │ │ │ -void sseett__ppeeeerr__ccllaassss (peer_class_t cid, peer_class_info const& pci); │ │ │ │ +********** sseett__ppeeeerr__ccllaassss(()) ggeett__ppeeeerr__ccllaassss(()) ********** │ │ │ │ peer_class_info ggeett__ppeeeerr__ccllaassss (peer_class_t cid) const; │ │ │ │ +void sseett__ppeeeerr__ccllaassss (peer_class_t cid, peer_class_info const& pci); │ │ │ │ These functions queries information from a peer class and updates the │ │ │ │ configuration of a peer class, respectively. │ │ │ │ cid must refer to an existing peer class. If it does not, the return value of │ │ │ │ get_peer_class() is undefined. │ │ │ │ set_peer_class() sets all the information in the _p_e_e_r___c_l_a_s_s___i_n_f_o 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 priority among │ │ │ │ @@ -624,26 +732,26 @@ │ │ │ │ session.remove_handle(handle); handle.save_resume_data(); │ │ │ │ Note that when a queued or downloading torrent is removed, its position in the │ │ │ │ download queue is vacated and every subsequent torrent in the queue has their │ │ │ │ queue positions updated. This can potentially cause a large state_update to be │ │ │ │ posted. When removing all torrents, it is advised to remove them from the back │ │ │ │ of the queue, to minimize the shifting. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__sseettttiinnggss(()) aappppllyy__sseettttiinnggss(()) ********** │ │ │ │ -void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ +********** aappppllyy__sseettttiinnggss(()) ggeett__sseettttiinnggss(()) ********** │ │ │ │ void aappppllyy__sseettttiinnggss (settings_pack&&); │ │ │ │ settings_pack ggeett__sseettttiinnggss () const; │ │ │ │ +void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ Applies the settings specified by the _s_e_t_t_i_n_g_s___p_a_c_k s. This is an asynchronous │ │ │ │ operation that will return immediately and actually apply the settings to the │ │ │ │ main thread of libtorrent some time later. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppoopp__aalleerrttss(()) sseett__aalleerrtt__nnoottiiffyy(()) wwaaiitt__ffoorr__aalleerrtt(()) ********** │ │ │ │ -void ppoopp__aalleerrttss (std::vector* alerts); │ │ │ │ +********** wwaaiitt__ffoorr__aalleerrtt(()) ppoopp__aalleerrttss(()) sseett__aalleerrtt__nnoottiiffyy(()) ********** │ │ │ │ void sseett__aalleerrtt__nnoottiiffyy (std::function const& fun); │ │ │ │ alert* wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ +void ppoopp__aalleerrttss (std::vector* alerts); │ │ │ │ Alerts is the main mechanism for libtorrent to report errors and events. │ │ │ │ pop_alerts fills in the vector passed to it with pointers to new alerts. The │ │ │ │ _s_e_s_s_i_o_n still owns these alerts and they will stay valid until the next time │ │ │ │ pop_alerts is called. You may not delete the _a_l_e_r_t objects. │ │ │ │ It is safe to call pop_alerts from multiple different threads, as long as the │ │ │ │ alerts themselves are not accessed once another thread calls pop_alerts. Doing │ │ │ │ this requires manual synchronization between the popping threads. │ │ │ │ @@ -684,17 +792,17 @@ │ │ │ │ block. It should not perform any expensive work. It really should just notify │ │ │ │ the main application thread. │ │ │ │ The type of an _a_l_e_r_t is returned by the polymorphic function alert::type() but │ │ │ │ can also be queries from a concrete type via T::alert_type, as a static │ │ │ │ constant. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** aadddd__ppoorrtt__mmaappppiinngg(()) ddeelleettee__ppoorrtt__mmaappppiinngg(()) ********** │ │ │ │ -void ddeelleettee__ppoorrtt__mmaappppiinngg (port_mapping_t handle); │ │ │ │ std::vector aadddd__ppoorrtt__mmaappppiinngg (portmap_protocol t, int │ │ │ │ external_port, int local_port); │ │ │ │ +void ddeelleettee__ppoorrtt__mmaappppiinngg (port_mapping_t handle); │ │ │ │ add_port_mapping adds one or more port forwards on UPnP and/or NAT-PMP, │ │ │ │ whichever is enabled. A mapping is created for each listen socket in the │ │ │ │ _s_e_s_s_i_o_n. The return values are all handles referring to the port mappings that │ │ │ │ were just created. Pass them to _d_e_l_e_t_e___p_o_r_t___m_a_p_p_i_n_g_(_) to remove them. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** rreeooppeenn__nneettwwoorrkk__ssoocckkeettss(()) ********** │ │ │ │ void rreeooppeenn__nneettwwoorrkk__ssoocckkeettss (reopen_network_flags_t options = │ │ │ │ @@ -740,132 +848,24 @@ │ │ │ │ protocols used by _a_d_d___p_o_r_t___m_a_p_p_i_n_g_(_) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ reopen_map_ports │ │ │ │ This option indicates if the ports are mapped using natpmp and upnp. If │ │ │ │ mapping was already made, they are deleted and added again. This only │ │ │ │ works if natpmp and/or upnp are configured to be enable. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ sseessssiioonn__pprrooxxyy ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ -this is a holder for the internal _s_e_s_s_i_o_n implementation object. Once the │ │ │ │ -_s_e_s_s_i_o_n destruction is explicitly initiated, this holder is used to synchronize │ │ │ │ -the completion of the shutdown. The lifetime of this object may outlive │ │ │ │ -_s_e_s_s_i_o_n, causing the _s_e_s_s_i_o_n destructor to not block. The _s_e_s_s_i_o_n___p_r_o_x_y │ │ │ │ -destructor will block however, until the underlying _s_e_s_s_i_o_n is done shutting │ │ │ │ -down. │ │ │ │ -struct session_proxy │ │ │ │ -{ │ │ │ │ - sseessssiioonn__pprrooxxyy (); │ │ │ │ - ~~sseessssiioonn__pprrooxxyy (); │ │ │ │ - sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ - sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ - session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ - session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr==(()) sseessssiioonn__pprrooxxyy(()) ~~sseessssiioonn__pprrooxxyy(()) ********** │ │ │ │ -sseessssiioonn__pprrooxxyy (); │ │ │ │ -~~sseessssiioonn__pprrooxxyy (); │ │ │ │ -sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ -sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ -session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ -session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ -default constructor, does not refer to any _s_e_s_s_i_o_n implementation object. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ sseessssiioonn ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ -The _s_e_s_s_i_o_n holds all state that spans multiple torrents. Among other things it │ │ │ │ -runs the network loop and manages all torrents. Once it's created, the _s_e_s_s_i_o_n │ │ │ │ -object will spawn the main thread that will do all the work. The main thread │ │ │ │ -will be idle as long it doesn't have any torrents to participate in. │ │ │ │ -You have some control over _s_e_s_s_i_o_n configuration through the session_handle:: │ │ │ │ -apply_settings() member function. To change one or more configuration options, │ │ │ │ -create a _s_e_t_t_i_n_g_s___p_a_c_k. object and fill it with the settings to be set and pass │ │ │ │ -it in to session::apply_settings(). │ │ │ │ -see _a_p_p_l_y___s_e_t_t_i_n_g_s_(_). │ │ │ │ -struct session : session_handle │ │ │ │ -{ │ │ │ │ - sseessssiioonn (session_params&& params, session_flags_t flags); │ │ │ │ - sseessssiioonn (); │ │ │ │ - explicit sseessssiioonn (session_params&& params); │ │ │ │ - sseessssiioonn (session_params const& params, session_flags_t flags); │ │ │ │ - explicit sseessssiioonn (session_params const& params); │ │ │ │ - sseessssiioonn (session_params const& params, io_context& ios, session_flags_t); │ │ │ │ - sseessssiioonn (session_params&& params, io_context& ios, session_flags_t); │ │ │ │ - sseessssiioonn (session_params&& params, io_context& ios); │ │ │ │ - sseessssiioonn (session_params const& params, io_context& ios); │ │ │ │ - ~~sseessssiioonn (); │ │ │ │ - session_proxy aabboorrtt (); │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseessssiioonn(()) ********** │ │ │ │ -sseessssiioonn (session_params&& params, session_flags_t flags); │ │ │ │ -sseessssiioonn (); │ │ │ │ -explicit sseessssiioonn (session_params&& params); │ │ │ │ -sseessssiioonn (session_params const& params, session_flags_t flags); │ │ │ │ -explicit sseessssiioonn (session_params const& params); │ │ │ │ -Constructs the _s_e_s_s_i_o_n objects which acts as the container of torrents. In │ │ │ │ -order to avoid a race condition between starting the _s_e_s_s_i_o_n and configuring │ │ │ │ -it, you can pass in a _s_e_s_s_i_o_n___p_a_r_a_m_s object. Its settings will take effect │ │ │ │ -before the _s_e_s_s_i_o_n starts up. │ │ │ │ -The overloads taking flags can be used to start a _s_e_s_s_i_o_n in paused mode (by │ │ │ │ -passing in session::paused). Note that add_default_plugins do not have an │ │ │ │ -affect on constructors that take a _s_e_s_s_i_o_n___p_a_r_a_m_s object. It already contains │ │ │ │ -the plugins to use. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseessssiioonn(()) ********** │ │ │ │ -sseessssiioonn (session_params const& params, io_context& ios, session_flags_t); │ │ │ │ -sseessssiioonn (session_params&& params, io_context& ios, session_flags_t); │ │ │ │ -sseessssiioonn (session_params&& params, io_context& ios); │ │ │ │ -sseessssiioonn (session_params const& params, io_context& ios); │ │ │ │ -Overload of the constructor that takes an external io_context to run the │ │ │ │ -_s_e_s_s_i_o_n object on. This is primarily useful for tests that may want to run │ │ │ │ -multiple sessions on a single io_context, or low resource systems where │ │ │ │ -additional threads are expensive and sharing an io_context with other events is │ │ │ │ -fine. │ │ │ │ -Warning │ │ │ │ -The _s_e_s_s_i_o_n object does not cleanly terminate with an external io_context. The │ │ │ │ -io_context::run() call mmuusstt have returned before it's safe to destruct the │ │ │ │ -_s_e_s_s_i_o_n. Which means you MMUUSSTT call _s_e_s_s_i_o_n_:_:_a_b_o_r_t_(_) and save the _s_e_s_s_i_o_n___p_r_o_x_y │ │ │ │ -first, then destruct the _s_e_s_s_i_o_n object, then sync with the io_context, then │ │ │ │ -destruct the _s_e_s_s_i_o_n___p_r_o_x_y object. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ~~sseessssiioonn(()) ********** │ │ │ │ -~~sseessssiioonn (); │ │ │ │ -The destructor of _s_e_s_s_i_o_n will notify all trackers that our torrents have been │ │ │ │ -shut down. If some trackers are down, they will time out. All this before the │ │ │ │ -destructor of _s_e_s_s_i_o_n returns. So, it's advised that any kind of interface │ │ │ │ -(such as windows) are closed before destructing the _s_e_s_s_i_o_n object. Because it │ │ │ │ -can take a few second for it to finish. The timeout can be set with │ │ │ │ -_a_p_p_l_y___s_e_t_t_i_n_g_s_(_). │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aabboorrtt(()) ********** │ │ │ │ -session_proxy aabboorrtt (); │ │ │ │ -In case you want to destruct the _s_e_s_s_i_o_n asynchronously, you can request a │ │ │ │ -_s_e_s_s_i_o_n destruction proxy. If you don't do this, the destructor of the _s_e_s_s_i_o_n │ │ │ │ -object will block while the trackers are contacted. If you keep one │ │ │ │ -session_proxy to the _s_e_s_s_i_o_n when destructing it, the destructor will not │ │ │ │ -block, but start to close down the _s_e_s_s_i_o_n, the destructor of the proxy will │ │ │ │ -then synchronize the threads. So, the destruction of the _s_e_s_s_i_o_n is performed │ │ │ │ -from the session destructor call until the session_proxy destructor call. The │ │ │ │ -session_proxy does not have any operations on it (since the _s_e_s_s_i_o_n is being │ │ │ │ -closed down, no operations are allowed on it). The only valid operation is │ │ │ │ -calling the destructor: │ │ │ │ -struct session_proxy {}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ rreeaadd__sseessssiioonn__ppaarraammss(()) wwrriittee__sseessssiioonn__ppaarraammss__bbuuff(()) wwrriittee__sseessssiioonn__ppaarraammss(()) │ │ │ │ ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___p_a_r_a_m_s_._h_p_p" │ │ │ │ -std::vector wwrriittee__sseessssiioonn__ppaarraammss__bbuuff (session_params const& sp │ │ │ │ +session_params rreeaadd__sseessssiioonn__ppaarraammss (bdecode_node const& e │ │ │ │ , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ entry wwrriittee__sseessssiioonn__ppaarraammss (session_params const& sp │ │ │ │ , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ -session_params rreeaadd__sseessssiioonn__ppaarraammss (span buf │ │ │ │ +std::vector wwrriittee__sseessssiioonn__ppaarraammss__bbuuff (session_params const& sp │ │ │ │ , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ -session_params rreeaadd__sseessssiioonn__ppaarraammss (bdecode_node const& e │ │ │ │ +session_params rreeaadd__sseessssiioonn__ppaarraammss (span buf │ │ │ │ , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ These functions serialize and de-serialize a session_params object to and from │ │ │ │ bencoded form. The _s_e_s_s_i_o_n___p_a_r_a_m_s object is used to initialize a new _s_e_s_s_i_o_n │ │ │ │ using the state from a previous one (or by programmatically configure the │ │ │ │ _s_e_s_s_i_o_n up-front). The flags parameter can be used to only save and load │ │ │ │ certain aspects of the session's state. The _buf suffix indicates the function │ │ │ │ operates on buffer rather than the bencoded structure. The torrents in a │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Settings.html │ │ │ @@ -29,34 +29,34 @@ │ │ │ │ │ │ │ │ │

    home

    │ │ │
    │ │ │

    Table of contents

    │ │ │ │ │ │
    │ │ │

    You have some control over session configuration through the session::apply_settings() │ │ │ member function. To change one or more configuration options, create a settings_pack │ │ │ object and fill it with the settings to be set and pass it in to session::apply_settings().

    │ │ │

    The settings_pack object is a collection of settings updates that are applied │ │ │ @@ -4760,24 +4760,24 @@ │ │ │ seconds.

    │ │ │
    │ │ │  struct settings_pack final : settings_interface
    │ │ │  {
    │ │ │     friend  void apply_pack_impl (settings_pack const*
    │ │ │        , aux::session_settings_single_thread&
    │ │ │        , std::vector<void(aux::session_impl::*)()>*);
    │ │ │ -   void set_int (int name, flags::bitfield_flag<Type, Tag> const val);
    │ │ │     void set_bool (int name, bool val) override;
    │ │ │ +   void set_int (int name, flags::bitfield_flag<Type, Tag> const val);
    │ │ │     void set_str (int name, std::string val) override;
    │ │ │     void set_int (int name, int val) override;
    │ │ │     bool has_val (int name) const override;
    │ │ │     void clear ();
    │ │ │     void clear (int name);
    │ │ │ +   int get_int (int name) const override;
    │ │ │     bool get_bool (int name) const override;
    │ │ │     std::string const& get_str (int name) const override;
    │ │ │ -   int get_int (int name) const override;
    │ │ │  
    │ │ │     enum type_bases
    │ │ │     {
    │ │ │        string_type_base,
    │ │ │        int_type_base,
    │ │ │        bool_type_base,
    │ │ │        type_mask,
    │ │ │ @@ -4846,21 +4846,21 @@
    │ │ │        socks5,
    │ │ │        socks5_pw,
    │ │ │        http,
    │ │ │        http_pw,
    │ │ │     };
    │ │ │  };
    │ │ │  
    │ │ │ + │ │ │ │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    set_int() set_bool() set_str()

    │ │ │ +[report issue]
    │ │ │ +

    set_str() set_int() set_bool()

    │ │ │
    │ │ │ -void set_int (int name, flags::bitfield_flag<Type, Tag> const val);
    │ │ │  void set_bool (int name, bool val) override;
    │ │ │ +void set_int (int name, flags::bitfield_flag<Type, Tag> const val);
    │ │ │  void set_str (int name, std::string val) override;
    │ │ │  void set_int (int name, int val) override;
    │ │ │  
    │ │ │

    set a configuration option in the settings_pack. name is one of │ │ │ the enum values from string_types, int_types or bool_types. They must │ │ │ match the respective type of the set_* function.

    │ │ │ [report issue]
    │ │ │ @@ -4882,23 +4882,23 @@ │ │ │ [report issue]
    │ │ │
    │ │ │

    clear()

    │ │ │
    │ │ │  void clear (int name);
    │ │ │  
    │ │ │

    clear a specific setting from the pack

    │ │ │ - │ │ │ │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    get_int() get_str() get_bool()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    get_str() get_int() get_bool()

    │ │ │
    │ │ │ +int get_int (int name) const override;
    │ │ │  bool get_bool (int name) const override;
    │ │ │  std::string const& get_str (int name) const override;
    │ │ │ -int get_int (int name) const override;
    │ │ │  
    │ │ │

    queries the current configuration option from the settings_pack. │ │ │ name is one of the enumeration values from string_types, int_types │ │ │ or bool_types. The enum value must match the type of the get_* │ │ │ function. If the specified setting field has not been set, the default │ │ │ value is returned.

    │ │ │ [report issue]
    │ │ │ @@ -5257,42 +5257,42 @@ │ │ │ http_pw │ │ │ 5 │ │ │ The server is assumed to be an HTTP proxy that requires user │ │ │ authorization. The username and password will be sent to the proxy. │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ -[report issue]
    │ │ │ + │ │ │ +[report issue]
    │ │ │ │ │ │ -
    │ │ │ -

    setting_by_name() name_for_setting()

    │ │ │ +
    │ │ │ +

    name_for_setting() setting_by_name()

    │ │ │

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │
    │ │ │ -char const* name_for_setting (int s);
    │ │ │  int setting_by_name (string_view name);
    │ │ │ +char const* name_for_setting (int s);
    │ │ │  
    │ │ │

    converts a setting integer (from the enums string_types, int_types or │ │ │ bool_types) to a string, and vice versa.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    default_settings()

    │ │ │

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │
    │ │ │  settings_pack default_settings ();
    │ │ │  
    │ │ │

    returns a settings_pack with every setting set to its default value

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    high_performance_seed() min_memory_usage()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    min_memory_usage() high_performance_seed()

    │ │ │

    Declared in "libtorrent/session.hpp"

    │ │ │
    │ │ │ -settings_pack min_memory_usage ();
    │ │ │  settings_pack high_performance_seed ();
    │ │ │ +settings_pack min_memory_usage ();
    │ │ │  
    │ │ │

    The default values of the session settings are set for a regular │ │ │ bittorrent client running on a desktop system. There are functions that │ │ │ can set the session settings to pre set settings for other environments. │ │ │ These can be used for the basis, and should be tweaked to fit your needs │ │ │ better.

    │ │ │

    min_memory_usage returns settings that will use the minimal amount of │ │ │ ├── html2text {} │ │ │ │ @@ -1,31 +1,31 @@ │ │ │ │ > │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.0.14 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ * _s_e_t_t_i_n_g_s___p_a_c_k │ │ │ │ - o _s_e_t___i_n_t_(_)_ _s_e_t___b_o_o_l_(_)_ _s_e_t___s_t_r_(_) │ │ │ │ + o _s_e_t___s_t_r_(_)_ _s_e_t___i_n_t_(_)_ _s_e_t___b_o_o_l_(_) │ │ │ │ o _h_a_s___v_a_l_(_) │ │ │ │ o _c_l_e_a_r_(_) │ │ │ │ o _c_l_e_a_r_(_) │ │ │ │ - o _g_e_t___i_n_t_(_)_ _g_e_t___s_t_r_(_)_ _g_e_t___b_o_o_l_(_) │ │ │ │ + o _g_e_t___s_t_r_(_)_ _g_e_t___i_n_t_(_)_ _g_e_t___b_o_o_l_(_) │ │ │ │ o _e_n_u_m_ _t_y_p_e___b_a_s_e_s │ │ │ │ o _e_n_u_m_ _m_m_a_p___w_r_i_t_e___m_o_d_e___t │ │ │ │ o _e_n_u_m_ _s_u_g_g_e_s_t___m_o_d_e___t │ │ │ │ o _e_n_u_m_ _c_h_o_k_i_n_g___a_l_g_o_r_i_t_h_m___t │ │ │ │ o _e_n_u_m_ _s_e_e_d___c_h_o_k_i_n_g___a_l_g_o_r_i_t_h_m___t │ │ │ │ o _e_n_u_m_ _i_o___b_u_f_f_e_r___m_o_d_e___t │ │ │ │ o _e_n_u_m_ _b_a_n_d_w_i_d_t_h___m_i_x_e_d___a_l_g_o___t │ │ │ │ o _e_n_u_m_ _e_n_c___p_o_l_i_c_y │ │ │ │ o _e_n_u_m_ _e_n_c___l_e_v_e_l │ │ │ │ o _e_n_u_m_ _p_r_o_x_y___t_y_p_e___t │ │ │ │ - * _s_e_t_t_i_n_g___b_y___n_a_m_e_(_)_ _n_a_m_e___f_o_r___s_e_t_t_i_n_g_(_) │ │ │ │ + * _n_a_m_e___f_o_r___s_e_t_t_i_n_g_(_)_ _s_e_t_t_i_n_g___b_y___n_a_m_e_(_) │ │ │ │ * _d_e_f_a_u_l_t___s_e_t_t_i_n_g_s_(_) │ │ │ │ - * _h_i_g_h___p_e_r_f_o_r_m_a_n_c_e___s_e_e_d_(_)_ _m_i_n___m_e_m_o_r_y___u_s_a_g_e_(_) │ │ │ │ + * _m_i_n___m_e_m_o_r_y___u_s_a_g_e_(_)_ _h_i_g_h___p_e_r_f_o_r_m_a_n_c_e___s_e_e_d_(_) │ │ │ │ * _g_e_n_e_r_a_t_e___f_i_n_g_e_r_p_r_i_n_t_(_) │ │ │ │ You have some control over _s_e_s_s_i_o_n configuration through the session:: │ │ │ │ apply_settings() member function. To change one or more configuration options, │ │ │ │ create a _s_e_t_t_i_n_g_s___p_a_c_k object and fill it with the settings to be set and pass │ │ │ │ it in to session::apply_settings(). │ │ │ │ The _s_e_t_t_i_n_g_s___p_a_c_k object is a collection of settings updates that are applied │ │ │ │ to the _s_e_s_s_i_o_n when passed to session::apply_settings(). It's empty when │ │ │ │ @@ -1490,24 +1490,24 @@ │ │ │ │ |_n_a_t_p_m_p___l_e_a_s_e___d_u_r_a_t_i_o_n_|_i_n_t_ _|_3_6_0_0_ _ _ | │ │ │ │ The life time of NAT-PMP and PCP port-mappings, specified in seconds. │ │ │ │ struct settings_pack final : settings_interface │ │ │ │ { │ │ │ │ friend void aappppllyy__ppaacckk__iimmppll (settings_pack const* │ │ │ │ , aux::session_settings_single_thread& │ │ │ │ , std::vector*); │ │ │ │ - void sseett__iinntt (int name, flags::bitfield_flag const val); │ │ │ │ void sseett__bbooooll (int name, bool val) override; │ │ │ │ + void sseett__iinntt (int name, flags::bitfield_flag const val); │ │ │ │ void sseett__ssttrr (int name, std::string val) override; │ │ │ │ void sseett__iinntt (int name, int val) override; │ │ │ │ bool hhaass__vvaall (int name) const override; │ │ │ │ void cclleeaarr (); │ │ │ │ void cclleeaarr (int name); │ │ │ │ + int ggeett__iinntt (int name) const override; │ │ │ │ bool ggeett__bbooooll (int name) const override; │ │ │ │ std::string const& ggeett__ssttrr (int name) const override; │ │ │ │ - int ggeett__iinntt (int name) const override; │ │ │ │ │ │ │ │ enum type_bases │ │ │ │ { │ │ │ │ string_type_base, │ │ │ │ int_type_base, │ │ │ │ bool_type_base, │ │ │ │ type_mask, │ │ │ │ @@ -1576,17 +1576,17 @@ │ │ │ │ socks5, │ │ │ │ socks5_pw, │ │ │ │ http, │ │ │ │ http_pw, │ │ │ │ }; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__iinntt(()) sseett__bbooooll(()) sseett__ssttrr(()) ********** │ │ │ │ -void sseett__iinntt (int name, flags::bitfield_flag const val); │ │ │ │ +********** sseett__ssttrr(()) sseett__iinntt(()) sseett__bbooooll(()) ********** │ │ │ │ void sseett__bbooooll (int name, bool val) override; │ │ │ │ +void sseett__iinntt (int name, flags::bitfield_flag const val); │ │ │ │ void sseett__ssttrr (int name, std::string val) override; │ │ │ │ void sseett__iinntt (int name, int val) override; │ │ │ │ set a configuration option in the _s_e_t_t_i_n_g_s___p_a_c_k. name is one of the enum values │ │ │ │ from string_types, int_types or bool_types. They must match the respective type │ │ │ │ of the set_* function. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** hhaass__vvaall(()) ********** │ │ │ │ @@ -1599,18 +1599,18 @@ │ │ │ │ void cclleeaarr (); │ │ │ │ clear the settings pack from all settings │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** cclleeaarr(()) ********** │ │ │ │ void cclleeaarr (int name); │ │ │ │ clear a specific setting from the pack │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__iinntt(()) ggeett__ssttrr(()) ggeett__bbooooll(()) ********** │ │ │ │ +********** ggeett__ssttrr(()) ggeett__iinntt(()) ggeett__bbooooll(()) ********** │ │ │ │ +int ggeett__iinntt (int name) const override; │ │ │ │ bool ggeett__bbooooll (int name) const override; │ │ │ │ std::string const& ggeett__ssttrr (int name) const override; │ │ │ │ -int ggeett__iinntt (int name) const override; │ │ │ │ queries the current configuration option from the _s_e_t_t_i_n_g_s___p_a_c_k. name is one of │ │ │ │ the enumeration values from string_types, int_types or bool_types. The enum │ │ │ │ value must match the type of the get_* function. If the specified setting field │ │ │ │ has not been set, the default value is returned. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** eennuumm ttyyppee__bbaasseess ********** │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_t_t_i_n_g_s___p_a_c_k_._h_p_p" │ │ │ │ @@ -1737,30 +1737,30 @@ │ │ │ │ | | |trackers, a plain proxy will suffice. The proxy is assumed to| │ │ │ │ | | |not require authorization. The username and password will not| │ │ │ │ |_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_b_e_ _u_s_e_d_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ | | |The server is assumed to be an HTTP proxy that requires user | │ │ │ │ |http_pw |5 |authorization. The username and password will be sent to the | │ │ │ │ |_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_p_r_o_x_y_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ sseettttiinngg__bbyy__nnaammee(()) nnaammee__ffoorr__sseettttiinngg(()) ************ │ │ │ │ +************ nnaammee__ffoorr__sseettttiinngg(()) sseettttiinngg__bbyy__nnaammee(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_t_t_i_n_g_s___p_a_c_k_._h_p_p" │ │ │ │ -char const* nnaammee__ffoorr__sseettttiinngg (int s); │ │ │ │ int sseettttiinngg__bbyy__nnaammee (string_view name); │ │ │ │ +char const* nnaammee__ffoorr__sseettttiinngg (int s); │ │ │ │ converts a setting integer (from the enums string_types, int_types or │ │ │ │ bool_types) to a string, and vice versa. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ddeeffaauulltt__sseettttiinnggss(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_t_t_i_n_g_s___p_a_c_k_._h_p_p" │ │ │ │ settings_pack ddeeffaauulltt__sseettttiinnggss (); │ │ │ │ returns a _s_e_t_t_i_n_g_s___p_a_c_k with every setting set to its default value │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ hhiigghh__ppeerrffoorrmmaannccee__sseeeedd(()) mmiinn__mmeemmoorryy__uussaaggee(()) ************ │ │ │ │ +************ mmiinn__mmeemmoorryy__uussaaggee(()) hhiigghh__ppeerrffoorrmmaannccee__sseeeedd(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ -settings_pack mmiinn__mmeemmoorryy__uussaaggee (); │ │ │ │ settings_pack hhiigghh__ppeerrffoorrmmaannccee__sseeeedd (); │ │ │ │ +settings_pack mmiinn__mmeemmoorryy__uussaaggee (); │ │ │ │ The default values of the _s_e_s_s_i_o_n settings are set for a regular bittorrent │ │ │ │ client running on a desktop system. There are functions that can set the │ │ │ │ _s_e_s_s_i_o_n settings to pre set settings for other environments. These can be used │ │ │ │ for the basis, and should be tweaked to fit your needs better. │ │ │ │ min_memory_usage returns settings that will use the minimal amount of RAM, at │ │ │ │ the potential expense of upload and download performance. It adjusts the socket │ │ │ │ buffer sizes, disables the disk cache, lowers the send buffer watermarks so │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Stats.html │ │ │┄ Ordering differences only │ │ │ @@ -72,26 +72,26 @@ │ │ │

    Declared in "libtorrent/performance_counters.hpp"

    │ │ │
    │ │ │  struct counters
    │ │ │  {
    │ │ │     counters () ;
    │ │ │     counters (counters const&) ;
    │ │ │     counters& operator= (counters const&) & ;
    │ │ │ -   std::int64_t inc_stats_counter (int c, std::int64_t value = 1) ;
    │ │ │     std::int64_t operator[] (int i) const ;
    │ │ │ +   std::int64_t inc_stats_counter (int c, std::int64_t value = 1) ;
    │ │ │     void set_value (int c, std::int64_t value) ;
    │ │ │     void blend_stats_counter (int c, std::int64_t value, int ratio) ;
    │ │ │  };
    │ │ │  
    │ │ │ │ │ │ [report issue]
    │ │ │

    operator[]() inc_stats_counter()

    │ │ │
    │ │ │ -std::int64_t inc_stats_counter (int c, std::int64_t value = 1) ;
    │ │ │  std::int64_t operator[] (int i) const ;
    │ │ │ +std::int64_t inc_stats_counter (int c, std::int64_t value = 1) ;
    │ │ │  
    │ │ │

    returns the new value

    │ │ │ [report issue]
    │ │ │
    │ │ │
    │ │ │

    session_stats_metrics()

    │ │ │

    Declared in "libtorrent/session_stats.hpp"

    │ │ │ ├── html2text {} │ │ │ │ @@ -32,23 +32,23 @@ │ │ │ │ ************ ccoouunntteerrss ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_r_f_o_r_m_a_n_c_e___c_o_u_n_t_e_r_s_._h_p_p" │ │ │ │ struct counters │ │ │ │ { │ │ │ │ ccoouunntteerrss () ; │ │ │ │ ccoouunntteerrss (counters const&) ; │ │ │ │ counters& ooppeerraattoorr== (counters const&) & ; │ │ │ │ - std::int64_t iinncc__ssttaattss__ccoouunntteerr (int c, std::int64_t value = 1) ; │ │ │ │ std::int64_t ooppeerraattoorr[[]] (int i) const ; │ │ │ │ + std::int64_t iinncc__ssttaattss__ccoouunntteerr (int c, std::int64_t value = 1) ; │ │ │ │ void sseett__vvaalluuee (int c, std::int64_t value) ; │ │ │ │ void bblleenndd__ssttaattss__ccoouunntteerr (int c, std::int64_t value, int ratio) ; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ooppeerraattoorr[[]](()) iinncc__ssttaattss__ccoouunntteerr(()) ********** │ │ │ │ -std::int64_t iinncc__ssttaattss__ccoouunntteerr (int c, std::int64_t value = 1) ; │ │ │ │ std::int64_t ooppeerraattoorr[[]] (int i) const ; │ │ │ │ +std::int64_t iinncc__ssttaattss__ccoouunntteerr (int c, std::int64_t value = 1) ; │ │ │ │ returns the new value │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ sseessssiioonn__ssttaattss__mmeettrriiccss(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n___s_t_a_t_s_._h_p_p" │ │ │ │ std::vector sseessssiioonn__ssttaattss__mmeettrriiccss (); │ │ │ │ This free function returns the list of available metrics exposed by │ │ │ │ libtorrent's statistics API. Each metric has a name and a vvaalluuee iinnddeexx. The │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Storage.html │ │ │ @@ -33,52 +33,52 @@ │ │ │

    Table of contents

    │ │ │ │ │ │
    │ │ │ [report issue]
    │ │ │

    storage_params

    │ │ │ @@ -139,70 +139,70 @@ │ │ │ size. Everything necessary to interpret a regular bittorrent storage │ │ │ file structure.

    │ │ │
    │ │ │  class file_storage
    │ │ │  {
    │ │ │     bool is_valid () const;
    │ │ │     void reserve (int num_files);
    │ │ │ -   void add_file (error_code& ec, std::string const& path, std::int64_t file_size
    │ │ │ -      , file_flags_t file_flags = {}
    │ │ │ -      , std::time_t mtime = 0, string_view symlink_path = string_view()
    │ │ │ -      , char const* root_hash = nullptr);
    │ │ │ -   void add_file (std::string const& path, std::int64_t file_size
    │ │ │ -      , file_flags_t file_flags = {}
    │ │ │ -      , std::time_t mtime = 0, string_view symlink_path = string_view()
    │ │ │ -      , char const* root_hash = nullptr);
    │ │ │     void add_file_borrow (string_view filename
    │ │ │        , std::string const& path, std::int64_t file_size
    │ │ │        , file_flags_t file_flags = {}, char const* filehash = nullptr
    │ │ │        , std::int64_t mtime = 0, string_view symlink_path = string_view()
    │ │ │        , char const* root_hash = nullptr);
    │ │ │     void add_file_borrow (error_code& ec, string_view filename
    │ │ │        , std::string const& path, std::int64_t file_size
    │ │ │        , file_flags_t file_flags = {}, char const* filehash = nullptr
    │ │ │        , std::int64_t mtime = 0, string_view symlink_path = string_view()
    │ │ │        , char const* root_hash = nullptr);
    │ │ │ +   void add_file (std::string const& path, std::int64_t file_size
    │ │ │ +      , file_flags_t file_flags = {}
    │ │ │ +      , std::time_t mtime = 0, string_view symlink_path = string_view()
    │ │ │ +      , char const* root_hash = nullptr);
    │ │ │ +   void add_file (error_code& ec, std::string const& path, std::int64_t file_size
    │ │ │ +      , file_flags_t file_flags = {}
    │ │ │ +      , std::time_t mtime = 0, string_view symlink_path = string_view()
    │ │ │ +      , char const* root_hash = nullptr);
    │ │ │     void rename_file (file_index_t index, std::string const& new_filename);
    │ │ │     std::vector<file_slice> map_block (piece_index_t piece, std::int64_t offset
    │ │ │        , std::int64_t size) const;
    │ │ │     peer_request map_file (file_index_t file, std::int64_t offset, int size) const;
    │ │ │     int num_files () const noexcept;
    │ │ │     file_index_t end_file () const noexcept;
    │ │ │     index_range<file_index_t> file_range () const noexcept;
    │ │ │     std::int64_t total_size () const;
    │ │ │ -   void set_num_pieces (int n);
    │ │ │     int num_pieces () const;
    │ │ │ +   void set_num_pieces (int n);
    │ │ │     piece_index_t end_piece () const;
    │ │ │     piece_index_t last_piece () const;
    │ │ │     index_range<piece_index_t> piece_range () const noexcept;
    │ │ │     int piece_length () const;
    │ │ │     void set_piece_length (int l);
    │ │ │     int piece_size (piece_index_t index) const;
    │ │ │     int piece_size2 (piece_index_t index) const;
    │ │ │     int blocks_in_piece2 (piece_index_t index) const;
    │ │ │     int blocks_per_piece () const;
    │ │ │     void set_name (std::string const& n);
    │ │ │     std::string const& name () const;
    │ │ │     void swap (file_storage& ti) noexcept;
    │ │ │     void canonicalize ();
    │ │ │ -   sha1_hash hash (file_index_t index) const;
    │ │ │ -   char const* root_ptr (file_index_t const index) const;
    │ │ │     std::int64_t file_offset (file_index_t index) const;
    │ │ │ -   string_view file_name (file_index_t index) const;
    │ │ │ -   bool pad_file_at (file_index_t index) const;
    │ │ │ -   std::string file_path (file_index_t index, std::string const& save_path = "") const;
    │ │ │     std::int64_t file_size (file_index_t index) const;
    │ │ │ +   bool pad_file_at (file_index_t index) const;
    │ │ │ +   std::string symlink (file_index_t index) const;
    │ │ │ +   char const* root_ptr (file_index_t const index) const;
    │ │ │     sha256_hash root (file_index_t index) const;
    │ │ │ +   std::string file_path (file_index_t index, std::string const& save_path = "") const;
    │ │ │ +   string_view file_name (file_index_t index) const;
    │ │ │     std::time_t mtime (file_index_t index) const;
    │ │ │ -   std::string symlink (file_index_t index) const;
    │ │ │ -   int file_num_pieces (file_index_t index) const;
    │ │ │ -   int file_num_blocks (file_index_t index) const;
    │ │ │ +   sha1_hash hash (file_index_t index) const;
    │ │ │     index_range<piece_index_t::diff_type> file_piece_range (file_index_t) const;
    │ │ │ -   int file_first_piece_node (file_index_t index) const;
    │ │ │ +   int file_num_blocks (file_index_t index) const;
    │ │ │ +   int file_num_pieces (file_index_t index) const;
    │ │ │     int file_first_block_node (file_index_t index) const;
    │ │ │ +   int file_first_piece_node (file_index_t index) const;
    │ │ │     std::uint32_t file_path_hash (file_index_t index, std::string const& save_path) const;
    │ │ │     void all_path_hashes (std::unordered_set<std::uint32_t>& table) const;
    │ │ │     file_flags_t file_flags (file_index_t index) const;
    │ │ │     bool file_absolute_path (file_index_t index) const;
    │ │ │     file_index_t file_index_at_piece (piece_index_t piece) const;
    │ │ │     file_index_t file_index_at_offset (std::int64_t offset) const;
    │ │ │     file_index_t file_index_for_root (sha256_hash const& root_hash) const;
    │ │ │ @@ -230,37 +230,37 @@
    │ │ │  

    reserve()

    │ │ │
    │ │ │  void reserve (int num_files);
    │ │ │  
    │ │ │

    allocates space for num_files in the internal file list. This can │ │ │ be used to avoid reallocating the internal file list when the number │ │ │ of files to be added is known up-front.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    add_file() add_file_borrow()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_file_borrow() add_file()

    │ │ │
    │ │ │ -void add_file (error_code& ec, std::string const& path, std::int64_t file_size
    │ │ │ -      , file_flags_t file_flags = {}
    │ │ │ -      , std::time_t mtime = 0, string_view symlink_path = string_view()
    │ │ │ -      , char const* root_hash = nullptr);
    │ │ │ -void add_file (std::string const& path, std::int64_t file_size
    │ │ │ -      , file_flags_t file_flags = {}
    │ │ │ -      , std::time_t mtime = 0, string_view symlink_path = string_view()
    │ │ │ -      , char const* root_hash = nullptr);
    │ │ │  void add_file_borrow (string_view filename
    │ │ │        , std::string const& path, std::int64_t file_size
    │ │ │        , file_flags_t file_flags = {}, char const* filehash = nullptr
    │ │ │        , std::int64_t mtime = 0, string_view symlink_path = string_view()
    │ │ │        , char const* root_hash = nullptr);
    │ │ │  void add_file_borrow (error_code& ec, string_view filename
    │ │ │        , std::string const& path, std::int64_t file_size
    │ │ │        , file_flags_t file_flags = {}, char const* filehash = nullptr
    │ │ │        , std::int64_t mtime = 0, string_view symlink_path = string_view()
    │ │ │        , char const* root_hash = nullptr);
    │ │ │ +void add_file (std::string const& path, std::int64_t file_size
    │ │ │ +      , file_flags_t file_flags = {}
    │ │ │ +      , std::time_t mtime = 0, string_view symlink_path = string_view()
    │ │ │ +      , char const* root_hash = nullptr);
    │ │ │ +void add_file (error_code& ec, std::string const& path, std::int64_t file_size
    │ │ │ +      , file_flags_t file_flags = {}
    │ │ │ +      , std::time_t mtime = 0, string_view symlink_path = string_view()
    │ │ │ +      , char const* root_hash = nullptr);
    │ │ │  
    │ │ │

    Adds a file to the file storage. The add_file_borrow version │ │ │ expects that filename is the file name (without a path) of │ │ │ the file that's being added. │ │ │ This memory is borrowed, i.e. it is the caller's │ │ │ responsibility to make sure it stays valid throughout the lifetime │ │ │ of this file_storage object or any copy of it. The same thing applies │ │ │ @@ -358,21 +358,21 @@ │ │ │ [report issue]

    │ │ │
    │ │ │

    total_size()

    │ │ │
    │ │ │  std::int64_t total_size () const;
    │ │ │  
    │ │ │

    returns the total number of bytes all the files in this torrent spans

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    num_pieces() set_num_pieces()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_num_pieces() num_pieces()

    │ │ │
    │ │ │ -void set_num_pieces (int n);
    │ │ │  int num_pieces () const;
    │ │ │ +void set_num_pieces (int n);
    │ │ │  
    │ │ │

    set and get the number of pieces in the torrent

    │ │ │ [report issue]
    │ │ │
    │ │ │

    end_piece()

    │ │ │
    │ │ │  piece_index_t end_piece () const;
    │ │ │ @@ -408,15 +408,15 @@
    │ │ │  and at least 16 kiB.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    piece_size()

    │ │ │
    │ │ │  int piece_size (piece_index_t index) const;
    │ │ │  
    │ │ │ -

    returns the piece size of index. This will be the same as piece_length(), except │ │ │ +

    returns the piece size of index. This will be the same as piece_length(), except │ │ │ for the last piece, which may be shorter.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    piece_size2()

    │ │ │
    │ │ │  int piece_size2 (piece_index_t index) const;
    │ │ │  
    │ │ │ @@ -460,37 +460,37 @@ │ │ │
    │ │ │

    canonicalize()

    │ │ │
    │ │ │  void canonicalize ();
    │ │ │  
    │ │ │

    arrange files and padding to match the canonical form required │ │ │ by BEP 52

    │ │ │ - │ │ │ │ │ │ - │ │ │ │ │ │ - │ │ │ - │ │ │ │ │ │ │ │ │ │ │ │ -[report issue]
    │ │ │ - │ │ │ + │ │ │
    │ │ │

    file_piece_range() file_num_pieces() file_num_blocks()

    │ │ │
    │ │ │ -int file_num_pieces (file_index_t index) const;
    │ │ │ -int file_num_blocks (file_index_t index) const;
    │ │ │  index_range<piece_index_t::diff_type> file_piece_range (file_index_t) const;
    │ │ │ +int file_num_blocks (file_index_t index) const;
    │ │ │ +int file_num_pieces (file_index_t index) const;
    │ │ │  
    │ │ │

    Returns the number of pieces or blocks the file at index spans, │ │ │ under the assumption that the file is aligned to the start of a piece. │ │ │ This is only meaningful for v2 torrents, where files are guaranteed │ │ │ such alignment. │ │ │ These numbers are used to size and navigate the merkle hash tree for │ │ │ each file.

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    file_first_piece_node() file_first_block_node()

    │ │ │
    │ │ │ -int file_first_piece_node (file_index_t index) const;
    │ │ │  int file_first_block_node (file_index_t index) const;
    │ │ │ +int file_first_piece_node (file_index_t index) const;
    │ │ │  
    │ │ │

    index of first piece node in the merkle tree

    │ │ │ [report issue]
    │ │ │
    │ │ │

    file_path_hash()

    │ │ │
    │ │ │  std::uint32_t file_path_hash (file_index_t index, std::string const& save_path) const;
    │ │ │ @@ -629,57 +629,57 @@
    │ │ │  
    this file has the executable attribute set.
    │ │ │ │ │ │ [report issue]
    │ │ │
    flag_symlink
    │ │ │
    this file is a symbolic link. It should have a link │ │ │ target string associated with it.
    │ │ │
    │ │ │ -[report issue]
    │ │ │ +[report issue]
    │ │ │
    │ │ │ +
    │ │ │ +

    mmap_disk_io_constructor()

    │ │ │ +

    Declared in "libtorrent/mmap_disk_io.hpp"

    │ │ │ +
    │ │ │ +std::unique_ptr<disk_interface> mmap_disk_io_constructor (
    │ │ │ +   io_context& ios, settings_interface const&, counters& cnt);
    │ │ │ +
    │ │ │ +

    constructs a memory mapped file disk I/O object.

    │ │ │ +[report issue]
    │ │ │
    │ │ │

    default_disk_io_constructor()

    │ │ │

    Declared in "libtorrent/session.hpp"

    │ │ │
    │ │ │  std::unique_ptr<disk_interface> default_disk_io_constructor (
    │ │ │     io_context& ios, settings_interface const&, counters& cnt);
    │ │ │  
    │ │ │

    the constructor function for the default storage. On systems that support │ │ │ memory mapped files (and a 64 bit address space) the memory mapped storage │ │ │ will be constructed, otherwise the portable posix storage.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    posix_disk_io_constructor()

    │ │ │ -

    Declared in "libtorrent/posix_disk_io.hpp"

    │ │ │ -
    │ │ │ -std::unique_ptr<disk_interface> posix_disk_io_constructor (
    │ │ │ -   io_context& ios, settings_interface const&, counters& cnt);
    │ │ │ -
    │ │ │ -

    this is a simple posix disk I/O back-end, used for systems that don't │ │ │ -have a 64 bit virtual address space or don't support memory mapped files. │ │ │ -It's implemented using portable C file functions and is single-threaded.

    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    mmap_disk_io_constructor()

    │ │ │ -

    Declared in "libtorrent/mmap_disk_io.hpp"

    │ │ │ -
    │ │ │ -std::unique_ptr<disk_interface> mmap_disk_io_constructor (
    │ │ │ -   io_context& ios, settings_interface const&, counters& cnt);
    │ │ │ -
    │ │ │ -

    constructs a memory mapped file disk I/O object.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    disabled_disk_io_constructor()

    │ │ │

    Declared in "libtorrent/disabled_disk_io.hpp"

    │ │ │
    │ │ │  std::unique_ptr<disk_interface> disabled_disk_io_constructor (
    │ │ │     io_context& ios, settings_interface const&, counters& cnt);
    │ │ │  
    │ │ │

    creates a disk io object that discards all data written to it, and only │ │ │ returns zero-buffers when read from. May be useful for testing and │ │ │ benchmarking.

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    posix_disk_io_constructor()

    │ │ │ +

    Declared in "libtorrent/posix_disk_io.hpp"

    │ │ │ +
    │ │ │ +std::unique_ptr<disk_interface> posix_disk_io_constructor (
    │ │ │ +   io_context& ios, settings_interface const&, counters& cnt);
    │ │ │ +
    │ │ │ +

    this is a simple posix disk I/O back-end, used for systems that don't │ │ │ +have a 64 bit virtual address space or don't support memory mapped files. │ │ │ +It's implemented using portable C file functions and is single-threaded.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    enum storage_mode_t

    │ │ │

    Declared in "libtorrent/storage_defs.hpp"

    │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ @@ -4,51 +4,51 @@ │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ * _s_t_o_r_a_g_e___p_a_r_a_m_s │ │ │ │ * _f_i_l_e___s_l_i_c_e │ │ │ │ * _f_i_l_e___s_t_o_r_a_g_e │ │ │ │ o _i_s___v_a_l_i_d_(_) │ │ │ │ o _r_e_s_e_r_v_e_(_) │ │ │ │ - o _a_d_d___f_i_l_e_(_)_ _a_d_d___f_i_l_e___b_o_r_r_o_w_(_) │ │ │ │ + o _a_d_d___f_i_l_e___b_o_r_r_o_w_(_)_ _a_d_d___f_i_l_e_(_) │ │ │ │ o _r_e_n_a_m_e___f_i_l_e_(_) │ │ │ │ o _m_a_p___b_l_o_c_k_(_) │ │ │ │ o _m_a_p___f_i_l_e_(_) │ │ │ │ o _n_u_m___f_i_l_e_s_(_) │ │ │ │ o _e_n_d___f_i_l_e_(_) │ │ │ │ o _f_i_l_e___r_a_n_g_e_(_) │ │ │ │ o _t_o_t_a_l___s_i_z_e_(_) │ │ │ │ - o _n_u_m___p_i_e_c_e_s_(_)_ _s_e_t___n_u_m___p_i_e_c_e_s_(_) │ │ │ │ + o _s_e_t___n_u_m___p_i_e_c_e_s_(_)_ _n_u_m___p_i_e_c_e_s_(_) │ │ │ │ o _e_n_d___p_i_e_c_e_(_) │ │ │ │ o _l_a_s_t___p_i_e_c_e_(_) │ │ │ │ o _p_i_e_c_e___r_a_n_g_e_(_) │ │ │ │ o _s_e_t___p_i_e_c_e___l_e_n_g_t_h_(_)_ _p_i_e_c_e___l_e_n_g_t_h_(_) │ │ │ │ o _p_i_e_c_e___s_i_z_e_(_) │ │ │ │ o _p_i_e_c_e___s_i_z_e_2_(_) │ │ │ │ o _b_l_o_c_k_s___i_n___p_i_e_c_e_2_(_) │ │ │ │ o _b_l_o_c_k_s___p_e_r___p_i_e_c_e_(_) │ │ │ │ o _s_e_t___n_a_m_e_(_)_ _n_a_m_e_(_) │ │ │ │ o _s_w_a_p_(_) │ │ │ │ o _c_a_n_o_n_i_c_a_l_i_z_e_(_) │ │ │ │ - o _m_t_i_m_e_(_)_ _s_y_m_l_i_n_k_(_)_ _f_i_l_e___p_a_t_h_(_)_ _f_i_l_e___s_i_z_e_(_)_ _f_i_l_e___o_f_f_s_e_t_(_)_ _r_o_o_t_(_)_ _h_a_s_h │ │ │ │ - _(_)_ _r_o_o_t___p_t_r_(_)_ _p_a_d___f_i_l_e___a_t_(_)_ _f_i_l_e___n_a_m_e_(_) │ │ │ │ + o _s_y_m_l_i_n_k_(_)_ _f_i_l_e___s_i_z_e_(_)_ _h_a_s_h_(_)_ _r_o_o_t___p_t_r_(_)_ _p_a_d___f_i_l_e___a_t_(_)_ _m_t_i_m_e_(_)_ _r_o_o_t │ │ │ │ + _(_)_ _f_i_l_e___o_f_f_s_e_t_(_)_ _f_i_l_e___n_a_m_e_(_)_ _f_i_l_e___p_a_t_h_(_) │ │ │ │ o _f_i_l_e___p_i_e_c_e___r_a_n_g_e_(_)_ _f_i_l_e___n_u_m___p_i_e_c_e_s_(_)_ _f_i_l_e___n_u_m___b_l_o_c_k_s_(_) │ │ │ │ o _f_i_l_e___f_i_r_s_t___p_i_e_c_e___n_o_d_e_(_)_ _f_i_l_e___f_i_r_s_t___b_l_o_c_k___n_o_d_e_(_) │ │ │ │ o _f_i_l_e___p_a_t_h___h_a_s_h_(_) │ │ │ │ o _a_l_l___p_a_t_h___h_a_s_h_e_s_(_) │ │ │ │ o _f_i_l_e___f_l_a_g_s_(_) │ │ │ │ o _f_i_l_e___a_b_s_o_l_u_t_e___p_a_t_h_(_) │ │ │ │ o _f_i_l_e___i_n_d_e_x___a_t___o_f_f_s_e_t_(_)_ _f_i_l_e___i_n_d_e_x___a_t___p_i_e_c_e_(_) │ │ │ │ o _f_i_l_e___i_n_d_e_x___f_o_r___r_o_o_t_(_) │ │ │ │ o _p_i_e_c_e___i_n_d_e_x___a_t___f_i_l_e_(_) │ │ │ │ o _s_a_n_i_t_i_z_e___s_y_m_l_i_n_k_s_(_) │ │ │ │ o _v_2_(_) │ │ │ │ - * _d_e_f_a_u_l_t___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ - * _p_o_s_i_x___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ * _m_m_a_p___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ + * _d_e_f_a_u_l_t___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ * _d_i_s_a_b_l_e_d___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ + * _p_o_s_i_x___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ * _e_n_u_m_ _s_t_o_r_a_g_e___m_o_d_e___t │ │ │ │ * _e_n_u_m_ _s_t_a_t_u_s___t │ │ │ │ * _e_n_u_m_ _m_o_v_e___f_l_a_g_s___t │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ssttoorraaggee__ppaarraammss ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_t_o_r_a_g_e___d_e_f_s_._h_p_p" │ │ │ │ a parameter pack used to construct the storage for a torrent, used in │ │ │ │ @@ -96,73 +96,73 @@ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_f_i_l_e___s_t_o_r_a_g_e_._h_p_p" │ │ │ │ The file_storage class represents a file list and the piece size. Everything │ │ │ │ necessary to interpret a regular bittorrent storage file structure. │ │ │ │ class file_storage │ │ │ │ { │ │ │ │ bool iiss__vvaalliidd () const; │ │ │ │ void rreesseerrvvee (int num_files); │ │ │ │ - void aadddd__ffiillee (error_code& ec, std::string const& path, std::int64_t │ │ │ │ -file_size │ │ │ │ - , file_flags_t file_flags = {} │ │ │ │ - , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ - , char const* root_hash = nullptr); │ │ │ │ - void aadddd__ffiillee (std::string const& path, std::int64_t file_size │ │ │ │ - , file_flags_t file_flags = {} │ │ │ │ - , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ - , char const* root_hash = nullptr); │ │ │ │ void aadddd__ffiillee__bboorrrrooww (string_view filename │ │ │ │ , std::string const& path, std::int64_t file_size │ │ │ │ , file_flags_t file_flags = {}, char const* filehash = nullptr │ │ │ │ , std::int64_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ , char const* root_hash = nullptr); │ │ │ │ void aadddd__ffiillee__bboorrrrooww (error_code& ec, string_view filename │ │ │ │ , std::string const& path, std::int64_t file_size │ │ │ │ , file_flags_t file_flags = {}, char const* filehash = nullptr │ │ │ │ , std::int64_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ , char const* root_hash = nullptr); │ │ │ │ + void aadddd__ffiillee (std::string const& path, std::int64_t file_size │ │ │ │ + , file_flags_t file_flags = {} │ │ │ │ + , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ + , char const* root_hash = nullptr); │ │ │ │ + void aadddd__ffiillee (error_code& ec, std::string const& path, std::int64_t │ │ │ │ +file_size │ │ │ │ + , file_flags_t file_flags = {} │ │ │ │ + , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ + , char const* root_hash = nullptr); │ │ │ │ void rreennaammee__ffiillee (file_index_t index, std::string const& new_filename); │ │ │ │ std::vector mmaapp__bblloocckk (piece_index_t piece, std::int64_t offset │ │ │ │ , std::int64_t size) const; │ │ │ │ peer_request mmaapp__ffiillee (file_index_t file, std::int64_t offset, int size) │ │ │ │ const; │ │ │ │ int nnuumm__ffiilleess () const noexcept; │ │ │ │ file_index_t eenndd__ffiillee () const noexcept; │ │ │ │ index_range ffiillee__rraannggee () const noexcept; │ │ │ │ std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ - void sseett__nnuumm__ppiieecceess (int n); │ │ │ │ int nnuumm__ppiieecceess () const; │ │ │ │ + void sseett__nnuumm__ppiieecceess (int n); │ │ │ │ piece_index_t eenndd__ppiieeccee () const; │ │ │ │ piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ index_range ppiieeccee__rraannggee () const noexcept; │ │ │ │ int ppiieeccee__lleennggtthh () const; │ │ │ │ void sseett__ppiieeccee__lleennggtthh (int l); │ │ │ │ int ppiieeccee__ssiizzee (piece_index_t index) const; │ │ │ │ int ppiieeccee__ssiizzee22 (piece_index_t index) const; │ │ │ │ int bblloocckkss__iinn__ppiieeccee22 (piece_index_t index) const; │ │ │ │ int bblloocckkss__ppeerr__ppiieeccee () const; │ │ │ │ void sseett__nnaammee (std::string const& n); │ │ │ │ std::string const& nnaammee () const; │ │ │ │ void sswwaapp (file_storage& ti) noexcept; │ │ │ │ void ccaannoonniiccaalliizzee (); │ │ │ │ - sha1_hash hhaasshh (file_index_t index) const; │ │ │ │ - char const* rroooott__ppttrr (file_index_t const index) const; │ │ │ │ std::int64_t ffiillee__ooffffsseett (file_index_t index) const; │ │ │ │ - string_view ffiillee__nnaammee (file_index_t index) const; │ │ │ │ + std::int64_t ffiillee__ssiizzee (file_index_t index) const; │ │ │ │ bool ppaadd__ffiillee__aatt (file_index_t index) const; │ │ │ │ + std::string ssyymmlliinnkk (file_index_t index) const; │ │ │ │ + char const* rroooott__ppttrr (file_index_t const index) const; │ │ │ │ + sha256_hash rroooott (file_index_t index) const; │ │ │ │ std::string ffiillee__ppaatthh (file_index_t index, std::string const& save_path = │ │ │ │ "") const; │ │ │ │ - std::int64_t ffiillee__ssiizzee (file_index_t index) const; │ │ │ │ - sha256_hash rroooott (file_index_t index) const; │ │ │ │ + string_view ffiillee__nnaammee (file_index_t index) const; │ │ │ │ std::time_t mmttiimmee (file_index_t index) const; │ │ │ │ - std::string ssyymmlliinnkk (file_index_t index) const; │ │ │ │ - int ffiillee__nnuumm__ppiieecceess (file_index_t index) const; │ │ │ │ - int ffiillee__nnuumm__bblloocckkss (file_index_t index) const; │ │ │ │ + sha1_hash hhaasshh (file_index_t index) const; │ │ │ │ index_range ffiillee__ppiieeccee__rraannggee (file_index_t) const; │ │ │ │ - int ffiillee__ffiirrsstt__ppiieeccee__nnooddee (file_index_t index) const; │ │ │ │ + int ffiillee__nnuumm__bblloocckkss (file_index_t index) const; │ │ │ │ + int ffiillee__nnuumm__ppiieecceess (file_index_t index) const; │ │ │ │ int ffiillee__ffiirrsstt__bblloocckk__nnooddee (file_index_t index) const; │ │ │ │ + int ffiillee__ffiirrsstt__ppiieeccee__nnooddee (file_index_t index) const; │ │ │ │ std::uint32_t ffiillee__ppaatthh__hhaasshh (file_index_t index, std::string const& │ │ │ │ save_path) const; │ │ │ │ void aallll__ppaatthh__hhaasshheess (std::unordered_set& table) const; │ │ │ │ file_flags_t ffiillee__ffllaaggss (file_index_t index) const; │ │ │ │ bool ffiillee__aabbssoolluuttee__ppaatthh (file_index_t index) const; │ │ │ │ file_index_t ffiillee__iinnddeexx__aatt__ppiieeccee (piece_index_t piece) const; │ │ │ │ file_index_t ffiillee__iinnddeexx__aatt__ooffffsseett (std::int64_t offset) const; │ │ │ │ @@ -185,33 +185,33 @@ │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** rreesseerrvvee(()) ********** │ │ │ │ void rreesseerrvvee (int num_files); │ │ │ │ allocates space for num_files in the internal file list. This can be used to │ │ │ │ avoid reallocating the internal file list when the number of files to be added │ │ │ │ is known up-front. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__ffiillee(()) aadddd__ffiillee__bboorrrrooww(()) ********** │ │ │ │ -void aadddd__ffiillee (error_code& ec, std::string const& path, std::int64_t file_size │ │ │ │ - , file_flags_t file_flags = {} │ │ │ │ - , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ - , char const* root_hash = nullptr); │ │ │ │ -void aadddd__ffiillee (std::string const& path, std::int64_t file_size │ │ │ │ - , file_flags_t file_flags = {} │ │ │ │ - , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ - , char const* root_hash = nullptr); │ │ │ │ +********** aadddd__ffiillee__bboorrrrooww(()) aadddd__ffiillee(()) ********** │ │ │ │ void aadddd__ffiillee__bboorrrrooww (string_view filename │ │ │ │ , std::string const& path, std::int64_t file_size │ │ │ │ , file_flags_t file_flags = {}, char const* filehash = nullptr │ │ │ │ , std::int64_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ , char const* root_hash = nullptr); │ │ │ │ void aadddd__ffiillee__bboorrrrooww (error_code& ec, string_view filename │ │ │ │ , std::string const& path, std::int64_t file_size │ │ │ │ , file_flags_t file_flags = {}, char const* filehash = nullptr │ │ │ │ , std::int64_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ , char const* root_hash = nullptr); │ │ │ │ +void aadddd__ffiillee (std::string const& path, std::int64_t file_size │ │ │ │ + , file_flags_t file_flags = {} │ │ │ │ + , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ + , char const* root_hash = nullptr); │ │ │ │ +void aadddd__ffiillee (error_code& ec, std::string const& path, std::int64_t file_size │ │ │ │ + , file_flags_t file_flags = {} │ │ │ │ + , std::time_t mtime = 0, string_view symlink_path = string_view() │ │ │ │ + , char const* root_hash = nullptr); │ │ │ │ Adds a file to the file storage. The add_file_borrow version expects that │ │ │ │ filename is the file name (without a path) of the file that's being added. This │ │ │ │ memory is bboorrrroowweedd, i.e. it is the caller's responsibility to make sure it │ │ │ │ stays valid throughout the lifetime of this _f_i_l_e___s_t_o_r_a_g_e object or any copy of │ │ │ │ it. The same thing applies to filehash, which is an optional pointer to a 20 │ │ │ │ byte binary SHA-1 hash of the file. │ │ │ │ if filename is empty, the filename from path is used and not borrowed. │ │ │ │ @@ -280,17 +280,17 @@ │ │ │ │ range-for loop. Where the values are the indices of all files in the │ │ │ │ _f_i_l_e___s_t_o_r_a_g_e. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ttoottaall__ssiizzee(()) ********** │ │ │ │ std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ returns the total number of bytes all the files in this torrent spans │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** nnuumm__ppiieecceess(()) sseett__nnuumm__ppiieecceess(()) ********** │ │ │ │ -void sseett__nnuumm__ppiieecceess (int n); │ │ │ │ +********** sseett__nnuumm__ppiieecceess(()) nnuumm__ppiieecceess(()) ********** │ │ │ │ int nnuumm__ppiieecceess () const; │ │ │ │ +void sseett__nnuumm__ppiieecceess (int n); │ │ │ │ set and get the number of pieces in the torrent │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** eenndd__ppiieeccee(()) ********** │ │ │ │ piece_index_t eenndd__ppiieeccee () const; │ │ │ │ returns the index of the one-past-end piece in the file storage │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** llaasstt__ppiieeccee(()) ********** │ │ │ │ @@ -342,27 +342,27 @@ │ │ │ │ void sswwaapp (file_storage& ti) noexcept; │ │ │ │ swap all content of tthhiiss with ttii. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ccaannoonniiccaalliizzee(()) ********** │ │ │ │ void ccaannoonniiccaalliizzee (); │ │ │ │ arrange files and padding to match the canonical form required by BEP 52 │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** mmttiimmee(()) ssyymmlliinnkk(()) ffiillee__ppaatthh(()) ffiillee__ssiizzee(()) ffiillee__ooffffsseett(()) rroooott(()) hhaasshh(()) │ │ │ │ -rroooott__ppttrr(()) ppaadd__ffiillee__aatt(()) ffiillee__nnaammee(()) ********** │ │ │ │ -sha1_hash hhaasshh (file_index_t index) const; │ │ │ │ -char const* rroooott__ppttrr (file_index_t const index) const; │ │ │ │ +********** ssyymmlliinnkk(()) ffiillee__ssiizzee(()) hhaasshh(()) rroooott__ppttrr(()) ppaadd__ffiillee__aatt(()) mmttiimmee(()) rroooott(()) │ │ │ │ +ffiillee__ooffffsseett(()) ffiillee__nnaammee(()) ffiillee__ppaatthh(()) ********** │ │ │ │ std::int64_t ffiillee__ooffffsseett (file_index_t index) const; │ │ │ │ -string_view ffiillee__nnaammee (file_index_t index) const; │ │ │ │ +std::int64_t ffiillee__ssiizzee (file_index_t index) const; │ │ │ │ bool ppaadd__ffiillee__aatt (file_index_t index) const; │ │ │ │ +std::string ssyymmlliinnkk (file_index_t index) const; │ │ │ │ +char const* rroooott__ppttrr (file_index_t const index) const; │ │ │ │ +sha256_hash rroooott (file_index_t index) const; │ │ │ │ std::string ffiillee__ppaatthh (file_index_t index, std::string const& save_path = "") │ │ │ │ const; │ │ │ │ -std::int64_t ffiillee__ssiizzee (file_index_t index) const; │ │ │ │ -sha256_hash rroooott (file_index_t index) const; │ │ │ │ +string_view ffiillee__nnaammee (file_index_t index) const; │ │ │ │ std::time_t mmttiimmee (file_index_t index) const; │ │ │ │ -std::string ssyymmlliinnkk (file_index_t index) const; │ │ │ │ +sha1_hash hhaasshh (file_index_t index) const; │ │ │ │ These functions are used to query attributes of files at a given index. │ │ │ │ The hash() is a SHA-1 hash of the file, or 0 if none was provided in the │ │ │ │ torrent file. This can potentially be used to join a bittorrent network with │ │ │ │ other file sharing networks. │ │ │ │ root() returns the SHA-256 merkle tree root of the specified file, in case this │ │ │ │ is a v2 torrent. Otherwise returns zeros. root_ptr() returns a pointer to the │ │ │ │ SHA-256 merkle tree root hash for the specified file. The pointer points into │ │ │ │ @@ -376,25 +376,25 @@ │ │ │ │ pad_file_at() returns true if the file at the given index is a pad-file. │ │ │ │ file_name() returns jjuusstt the name of the file, whereas file_path() returns the │ │ │ │ path (inside the torrent file) with the filename appended. │ │ │ │ file_offset() returns the byte offset within the torrent file where this file │ │ │ │ starts. It can be used to map the file to a piece index (given the piece size). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ffiillee__ppiieeccee__rraannggee(()) ffiillee__nnuumm__ppiieecceess(()) ffiillee__nnuumm__bblloocckkss(()) ********** │ │ │ │ -int ffiillee__nnuumm__ppiieecceess (file_index_t index) const; │ │ │ │ -int ffiillee__nnuumm__bblloocckkss (file_index_t index) const; │ │ │ │ index_range ffiillee__ppiieeccee__rraannggee (file_index_t) const; │ │ │ │ +int ffiillee__nnuumm__bblloocckkss (file_index_t index) const; │ │ │ │ +int ffiillee__nnuumm__ppiieecceess (file_index_t index) const; │ │ │ │ Returns the number of pieces or blocks the file atindexspans, under the │ │ │ │ assumption that the file is aligned to the start of a piece. This is only │ │ │ │ meaningful for v2 torrents, where files are guaranteed such alignment. These │ │ │ │ numbers are used to size and navigate the merkle hash tree for each file. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ffiillee__ffiirrsstt__ppiieeccee__nnooddee(()) ffiillee__ffiirrsstt__bblloocckk__nnooddee(()) ********** │ │ │ │ -int ffiillee__ffiirrsstt__ppiieeccee__nnooddee (file_index_t index) const; │ │ │ │ int ffiillee__ffiirrsstt__bblloocckk__nnooddee (file_index_t index) const; │ │ │ │ +int ffiillee__ffiirrsstt__ppiieeccee__nnooddee (file_index_t index) const; │ │ │ │ index of first piece node in the merkle tree │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ffiillee__ppaatthh__hhaasshh(()) ********** │ │ │ │ std::uint32_t ffiillee__ppaatthh__hhaasshh (file_index_t index, std::string const& save_path) │ │ │ │ const; │ │ │ │ returns the crc32 hash of file_path(index) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ @@ -450,43 +450,43 @@ │ │ │ │ flag_executable │ │ │ │ this file has the executable attribute set. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ flag_symlink │ │ │ │ this file is a symbolic link. It should have a link target string │ │ │ │ associated with it. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ mmmmaapp__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_m_m_a_p___d_i_s_k___i_o_._h_p_p" │ │ │ │ +std::unique_ptr mmmmaapp__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ + io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ +constructs a memory mapped file disk I/O object. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ddeeffaauulltt__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_e_s_s_i_o_n_._h_p_p" │ │ │ │ std::unique_ptr ddeeffaauulltt__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ the constructor function for the default storage. On systems that support │ │ │ │ memory mapped files (and a 64 bit address space) the memory mapped storage will │ │ │ │ be constructed, otherwise the portable posix storage. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ddiissaabblleedd__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_a_b_l_e_d___d_i_s_k___i_o_._h_p_p" │ │ │ │ +std::unique_ptr ddiissaabblleedd__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ + io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ +creates a disk io object that discards all data written to it, and only returns │ │ │ │ +zero-buffers when read from. May be useful for testing and benchmarking. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ppoossiixx__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_o_s_i_x___d_i_s_k___i_o_._h_p_p" │ │ │ │ std::unique_ptr ppoossiixx__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ this is a simple posix disk I/O back-end, used for systems that don't have a 64 │ │ │ │ bit virtual address space or don't support memory mapped files. It's │ │ │ │ implemented using portable C file functions and is single-threaded. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ mmmmaapp__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_m_m_a_p___d_i_s_k___i_o_._h_p_p" │ │ │ │ -std::unique_ptr mmmmaapp__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ - io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ -constructs a memory mapped file disk I/O object. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ddiissaabblleedd__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_i_s_a_b_l_e_d___d_i_s_k___i_o_._h_p_p" │ │ │ │ -std::unique_ptr ddiissaabblleedd__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ - io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ -creates a disk io object that discards all data written to it, and only returns │ │ │ │ -zero-buffers when read from. May be useful for testing and benchmarking. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ eennuumm ssttoorraaggee__mmooddee__tt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_t_o_r_a_g_e___d_e_f_s_._h_p_p" │ │ │ │ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ |_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ | | |All pieces will be written to their final | │ │ │ │ | | |position, all files will be allocated in full | │ │ │ │ |storage_mode_allocate|0 |when the torrent is first started. This mode | │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Handle.html │ │ │ @@ -39,52 +39,52 @@ │ │ │ │ │ │
  • partial_piece_info
  • │ │ │
  • torrent_handle │ │ │
  • │ │ │
  • hash_value()
  • │ │ │ @@ -263,111 +263,111 @@ │ │ │ handle will remain valid between two calls.

    │ │ │ │ │ │
    │ │ │  struct torrent_handle
    │ │ │  {
    │ │ │     friend std::size_t hash_value (torrent_handle const& th);
    │ │ │     torrent_handle () noexcept = default;
    │ │ │ -   void add_piece (piece_index_t piece, std::vector<char> data, add_piece_flags_t flags = {}) const;
    │ │ │     void add_piece (piece_index_t piece, char const* data, add_piece_flags_t flags = {}) const;
    │ │ │ +   void add_piece (piece_index_t piece, std::vector<char> data, add_piece_flags_t flags = {}) const;
    │ │ │     void read_piece (piece_index_t piece) const;
    │ │ │     bool have_piece (piece_index_t piece) const;
    │ │ │     void post_peer_info () const;
    │ │ │     void get_peer_info (std::vector<peer_info>& v) const;
    │ │ │ -   torrent_status status (status_flags_t flags = status_flags_t::all()) const;
    │ │ │     void post_status (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ -   std::vector<partial_piece_info> get_download_queue () const;
    │ │ │ -   void post_download_queue () const;
    │ │ │ +   torrent_status status (status_flags_t flags = status_flags_t::all()) const;
    │ │ │     void get_download_queue (std::vector<partial_piece_info>& queue) const;
    │ │ │ -   void clear_piece_deadlines () const;
    │ │ │ +   void post_download_queue () const;
    │ │ │ +   std::vector<partial_piece_info> get_download_queue () const;
    │ │ │     void set_piece_deadline (piece_index_t index, int deadline, deadline_flags_t flags = {}) const;
    │ │ │ +   void clear_piece_deadlines () const;
    │ │ │     void reset_piece_deadline (piece_index_t index) const;
    │ │ │ -   std::vector<std::int64_t> file_progress (file_progress_flags_t flags = {}) const;
    │ │ │     void post_file_progress (file_progress_flags_t flags) const;
    │ │ │     void file_progress (std::vector<std::int64_t>& progress, file_progress_flags_t flags = {}) const;
    │ │ │ +   std::vector<std::int64_t> file_progress (file_progress_flags_t flags = {}) const;
    │ │ │     std::vector<open_file_state> file_status () const;
    │ │ │     void clear_error () const;
    │ │ │ -   void replace_trackers (std::vector<announce_entry> const&) const;
    │ │ │     void add_tracker (announce_entry const&) const;
    │ │ │     void post_trackers () const;
    │ │ │     std::vector<announce_entry> trackers () const;
    │ │ │ -   void remove_url_seed (std::string const& url) const;
    │ │ │ +   void replace_trackers (std::vector<announce_entry> const&) const;
    │ │ │     void add_url_seed (std::string const& url) const;
    │ │ │ +   void remove_url_seed (std::string const& url) const;
    │ │ │     std::set<std::string> url_seeds () const;
    │ │ │ -   void add_http_seed (std::string const& url) const;
    │ │ │     std::set<std::string> http_seeds () const;
    │ │ │     void remove_http_seed (std::string const& url) const;
    │ │ │ +   void add_http_seed (std::string const& url) const;
    │ │ │     void add_extension (
    │ │ │        std::function<std::shared_ptr<torrent_plugin>(torrent_handle const&, client_data_t)> const& ext
    │ │ │        , client_data_t userdata = client_data_t{});
    │ │ │     bool set_metadata (span<char const> metadata) const;
    │ │ │     bool is_valid () const;
    │ │ │     void resume () const;
    │ │ │     void pause (pause_flags_t flags = {}) const;
    │ │ │ +   void set_flags (torrent_flags_t flags) const;
    │ │ │     void set_flags (torrent_flags_t flags, torrent_flags_t mask) const;
    │ │ │     void unset_flags (torrent_flags_t flags) const;
    │ │ │     torrent_flags_t flags () const;
    │ │ │ -   void set_flags (torrent_flags_t flags) const;
    │ │ │     void flush_cache () const;
    │ │ │     void force_recheck () const;
    │ │ │ -   add_torrent_params get_resume_data (resume_data_flags_t flags = {}) const;
    │ │ │     void save_resume_data (resume_data_flags_t flags = {}) const;
    │ │ │ -   bool need_save_resume_data () const;
    │ │ │ +   add_torrent_params get_resume_data (resume_data_flags_t flags = {}) const;
    │ │ │     bool need_save_resume_data (resume_data_flags_t flags) const;
    │ │ │ -   void queue_position_down () const;
    │ │ │ -   void queue_position_up () const;
    │ │ │ -   void queue_position_top () const;
    │ │ │ +   bool need_save_resume_data () const;
    │ │ │     queue_position_t queue_position () const;
    │ │ │ +   void queue_position_top () const;
    │ │ │     void queue_position_bottom () const;
    │ │ │ +   void queue_position_up () const;
    │ │ │ +   void queue_position_down () const;
    │ │ │     void queue_position_set (queue_position_t p) const;
    │ │ │     void set_ssl_certificate (std::string const& certificate
    │ │ │        , std::string const& private_key
    │ │ │        , std::string const& dh_params
    │ │ │        , std::string const& passphrase = "");
    │ │ │     void set_ssl_certificate_buffer (std::string const& certificate
    │ │ │        , std::string const& private_key
    │ │ │        , std::string const& dh_params);
    │ │ │     std::shared_ptr<torrent_info> torrent_file_with_hashes () const;
    │ │ │     std::shared_ptr<const torrent_info> torrent_file () const;
    │ │ │     std::vector<std::vector<sha256_hash>> piece_layers () const;
    │ │ │ -   void post_piece_availability () const;
    │ │ │     void piece_availability (std::vector<int>& avail) const;
    │ │ │ +   void post_piece_availability () const;
    │ │ │ +   void prioritize_pieces (std::vector<download_priority_t> const& pieces) const;
    │ │ │     download_priority_t piece_priority (piece_index_t index) const;
    │ │ │ -   std::vector<download_priority_t> get_piece_priorities () const;
    │ │ │     void piece_priority (piece_index_t index, download_priority_t priority) const;
    │ │ │ -   void prioritize_pieces (std::vector<download_priority_t> const& pieces) const;
    │ │ │ +   std::vector<download_priority_t> get_piece_priorities () const;
    │ │ │     void prioritize_pieces (std::vector<std::pair<piece_index_t, download_priority_t>> const& pieces) const;
    │ │ │ -   std::vector<download_priority_t> get_file_priorities () const;
    │ │ │ -   download_priority_t file_priority (file_index_t index) const;
    │ │ │     void prioritize_files (std::vector<download_priority_t> const& files) const;
    │ │ │     void file_priority (file_index_t index, download_priority_t priority) const;
    │ │ │ -   void force_lsd_announce () const;
    │ │ │ +   std::vector<download_priority_t> get_file_priorities () const;
    │ │ │ +   download_priority_t file_priority (file_index_t index) const;
    │ │ │     void force_dht_announce () const;
    │ │ │ +   void force_lsd_announce () const;
    │ │ │     void force_reannounce (int seconds = 0, int idx = -1, reannounce_flags_t = {}) const;
    │ │ │     void scrape_tracker (int idx = -1) const;
    │ │ │ -   void set_download_limit (int limit) const;
    │ │ │ -   void set_upload_limit (int limit) const;
    │ │ │     int upload_limit () const;
    │ │ │ +   void set_download_limit (int limit) const;
    │ │ │     int download_limit () const;
    │ │ │ +   void set_upload_limit (int limit) const;
    │ │ │     void connect_peer (tcp::endpoint const& adr, peer_source_flags_t source = {}
    │ │ │        , pex_flags_t flags = pex_encryption | pex_utp | pex_holepunch) const;
    │ │ │     void clear_peers ();
    │ │ │ -   int max_uploads () const;
    │ │ │     void set_max_uploads (int max_uploads) const;
    │ │ │ +   int max_uploads () const;
    │ │ │     void set_max_connections (int max_connections) const;
    │ │ │     int max_connections () const;
    │ │ │     void move_storage (std::string const& save_path
    │ │ │        , move_flags_t flags = move_flags_t::always_replace_files
    │ │ │        ) const;
    │ │ │     void rename_file (file_index_t index, std::string const& new_name) const;
    │ │ │ -   info_hash_t info_hashes () const;
    │ │ │     sha1_hash info_hash () const;
    │ │ │ +   info_hash_t info_hashes () const;
    │ │ │     bool operator== (const torrent_handle& h) const;
    │ │ │ -   bool operator!= (const torrent_handle& h) const;
    │ │ │     bool operator< (const torrent_handle& h) const;
    │ │ │ +   bool operator!= (const torrent_handle& h) const;
    │ │ │     std::uint32_t id () const;
    │ │ │     std::shared_ptr<torrent> native_handle () const;
    │ │ │     client_data_t userdata () const;
    │ │ │     bool in_session () const;
    │ │ │  
    │ │ │     static constexpr add_piece_flags_t overwrite_existing  = 0_bit;
    │ │ │     static constexpr status_flags_t query_distributed_copies  = 0_bit;
    │ │ │ @@ -400,16 +400,16 @@
    │ │ │  
    │ │ │

    constructs a torrent handle that does not refer to a torrent. │ │ │ i.e. is_valid() will return false.

    │ │ │ [report issue] │ │ │
    │ │ │

    add_piece()

    │ │ │
    │ │ │ -void add_piece (piece_index_t piece, std::vector<char> data, add_piece_flags_t flags = {}) const;
    │ │ │  void add_piece (piece_index_t piece, char const* data, add_piece_flags_t flags = {}) const;
    │ │ │ +void add_piece (piece_index_t piece, std::vector<char> data, add_piece_flags_t flags = {}) const;
    │ │ │  
    │ │ │

    This function will write data to the storage as piece piece, │ │ │ as if it had been downloaded from a peer.

    │ │ │

    By default, data that's already been downloaded is not overwritten by │ │ │ this buffer. If you trust this data to be correct (and pass the piece │ │ │ hash check) you may pass the overwrite_existing flag. This will │ │ │ instruct libtorrent to overwrite any data that may already have been │ │ │ @@ -444,50 +444,50 @@ │ │ │

    Note

    │ │ │

    that if you read multiple pieces, the read operations are not │ │ │ guaranteed to finish in the same order as you initiated them.

    │ │ │
    │ │ │
    │ │ │

    Note

    │ │ │

    the size of the buffer passed back in the alert is not │ │ │ -necessarily piece_length() long. The last piece or pieces at the end │ │ │ +necessarily piece_length() long. The last piece or pieces at the end │ │ │ of files (in v2 and hybrid torrents) are not full size.

    │ │ │
    │ │ │ [report issue] │ │ │
    │ │ │

    have_piece()

    │ │ │
    │ │ │  bool have_piece (piece_index_t piece) const;
    │ │ │  
    │ │ │

    Returns true if this piece has been completely downloaded and written │ │ │ to disk, and false otherwise.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    get_peer_info() post_peer_info()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    post_peer_info() get_peer_info()

    │ │ │
    │ │ │  void post_peer_info () const;
    │ │ │  void get_peer_info (std::vector<peer_info>& v) const;
    │ │ │  
    │ │ │

    Query information about connected peers for this torrent. If the │ │ │ torrent_handle is invalid, it will throw a system_error exception.

    │ │ │

    post_peer_info() is asynchronous and will trigger the posting of │ │ │ a peer_info_alert. The alert contain a list of peer_info objects, one │ │ │ for each connected peer.

    │ │ │

    get_peer_info() is synchronous and takes a reference to a vector │ │ │ that will be cleared and filled with one entry for each peer │ │ │ connected to this torrent, given the handle is valid. Each entry in │ │ │ the vector contains information about that particular peer. See │ │ │ peer_info.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    status() post_status()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    post_status() status()

    │ │ │
    │ │ │ -torrent_status status (status_flags_t flags = status_flags_t::all()) const;
    │ │ │  void post_status (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ +torrent_status status (status_flags_t flags = status_flags_t::all()) const;
    │ │ │  
    │ │ │

    status() will return a structure with information about the status │ │ │ of this torrent. If the torrent_handle is invalid, it will throw │ │ │ system_error exception. See torrent_status. The flags │ │ │ argument filters what information is returned in the torrent_status. │ │ │ Some information in there is relatively expensive to calculate, and if │ │ │ you're not interested in it (and see performance issues), you can │ │ │ @@ -497,22 +497,22 @@ │ │ │ instead call post_status(). It will trigger posting of a │ │ │ state_update_alert with a single torrent_status object for this │ │ │ torrent.

    │ │ │

    In order to get regular updates for torrents whose status changes, │ │ │ consider calling session::post_torrent_updates()`` instead.

    │ │ │

    By default everything is included. The flags you can use to decide │ │ │ what to include are defined in this class.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    post_download_queue() get_download_queue()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    get_download_queue() post_download_queue()

    │ │ │
    │ │ │ -std::vector<partial_piece_info> get_download_queue () const;
    │ │ │ -void post_download_queue () const;
    │ │ │  void get_download_queue (std::vector<partial_piece_info>& queue) const;
    │ │ │ +void post_download_queue () const;
    │ │ │ +std::vector<partial_piece_info> get_download_queue () const;
    │ │ │  
    │ │ │

    post_download_queue() triggers a download_queue_alert to be │ │ │ posted. │ │ │ get_download_queue() is a synchronous call and returns a vector │ │ │ with information about pieces that are partially downloaded or not │ │ │ downloaded but partially requested. See partial_piece_info for the │ │ │ fields in the returned vector.

    │ │ │ @@ -521,22 +521,22 @@ │ │ │

    get_download_queue() is prone to threading errors. The │ │ │ block_info pointers its return value points to are owned by the │ │ │ session and will be cleared the next time get_download_queue() │ │ │ is called. Therefore it's not safe to call this function from │ │ │ multiple threads. Using post_download_queue() is a safe │ │ │ alternative.

    │ │ │
    │ │ │ - │ │ │ │ │ │ -[report issue] │ │ │ -
    │ │ │ -

    set_piece_deadline() reset_piece_deadline() clear_piece_deadlines()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    reset_piece_deadline() set_piece_deadline() clear_piece_deadlines()

    │ │ │
    │ │ │ -void clear_piece_deadlines () const;
    │ │ │  void set_piece_deadline (piece_index_t index, int deadline, deadline_flags_t flags = {}) const;
    │ │ │ +void clear_piece_deadlines () const;
    │ │ │  void reset_piece_deadline (piece_index_t index) const;
    │ │ │  
    │ │ │

    This function sets or resets the deadline associated with a specific │ │ │ piece index (index). libtorrent will attempt to download this │ │ │ entire piece before the deadline expires. This is not necessarily │ │ │ possible, but pieces with a more recent deadline will always be │ │ │ prioritized over pieces with a deadline further ahead in time. The │ │ │ @@ -548,22 +548,22 @@ │ │ │

    deadline is the number of milliseconds until this piece should be │ │ │ completed.

    │ │ │

    reset_piece_deadline removes the deadline from the piece. If it │ │ │ hasn't already been downloaded, it will no longer be considered a │ │ │ priority.

    │ │ │

    clear_piece_deadlines() removes deadlines on all pieces in │ │ │ the torrent. As if reset_piece_deadline() was called on all pieces.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    post_file_progress() file_progress()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    file_progress() post_file_progress()

    │ │ │
    │ │ │ -std::vector<std::int64_t> file_progress (file_progress_flags_t flags = {}) const;
    │ │ │  void post_file_progress (file_progress_flags_t flags) const;
    │ │ │  void file_progress (std::vector<std::int64_t>& progress, file_progress_flags_t flags = {}) const;
    │ │ │ +std::vector<std::int64_t> file_progress (file_progress_flags_t flags = {}) const;
    │ │ │  
    │ │ │

    This function fills in the supplied vector, or returns a vector, with │ │ │ the number of bytes downloaded of each file in this torrent. The │ │ │ progress values are ordered the same as the files in the │ │ │ torrent_info.

    │ │ │

    This operation is not very cheap. Its complexity is O(n + mj). │ │ │ Where n is the number of files, m is the number of currently │ │ │ @@ -592,29 +592,29 @@ │ │ │

    │ │ │

    clear_error()

    │ │ │
    │ │ │  void clear_error () const;
    │ │ │  
    │ │ │

    If the torrent is in an error state (i.e. torrent_status::error is │ │ │ non-empty), this will clear the error and start the torrent again.

    │ │ │ - │ │ │ - │ │ │ + │ │ │ │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    add_tracker() replace_trackers() trackers() post_trackers()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    post_trackers() trackers() replace_trackers() add_tracker()

    │ │ │
    │ │ │ -void replace_trackers (std::vector<announce_entry> const&) const;
    │ │ │  void add_tracker (announce_entry const&) const;
    │ │ │  void post_trackers () const;
    │ │ │  std::vector<announce_entry> trackers () const;
    │ │ │ +void replace_trackers (std::vector<announce_entry> const&) const;
    │ │ │  
    │ │ │

    trackers() returns the list of trackers for this torrent. The │ │ │ announce entry contains both a string url which specify the │ │ │ -announce url for the tracker as well as an int tier, which is │ │ │ +announce url for the tracker as well as an int tier, which is │ │ │ specifies the order in which this tracker is tried. If you want │ │ │ libtorrent to use another list of trackers for this torrent, you can │ │ │ use replace_trackers() which takes a list of the same form as the │ │ │ one returned from trackers() and will replace it. If you want an │ │ │ immediate effect, you have to call force_reannounce(). See │ │ │ announce_entry.

    │ │ │

    post_trackers() is the asynchronous version of trackers(). It │ │ │ @@ -622,42 +622,42 @@ │ │ │

    add_tracker() will look if the specified tracker is already in the │ │ │ set. If it is, it doesn't do anything. If it's not in the current set │ │ │ of trackers, it will insert it in the tier specified in the │ │ │ announce_entry.

    │ │ │

    The updated set of trackers will be saved in the resume data, and when │ │ │ a torrent is started with resume data, the trackers from the resume │ │ │ data will replace the original ones.

    │ │ │ - │ │ │ + │ │ │ │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    remove_url_seed() url_seeds() add_url_seed()

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_url_seed() url_seeds() remove_url_seed()

    │ │ │
    │ │ │ -void remove_url_seed (std::string const& url) const;
    │ │ │  void add_url_seed (std::string const& url) const;
    │ │ │ +void remove_url_seed (std::string const& url) const;
    │ │ │  std::set<std::string> url_seeds () const;
    │ │ │  
    │ │ │

    add_url_seed() adds another url to the torrent's list of url │ │ │ seeds. If the given url already exists in that list, the call has no │ │ │ effect. The torrent will connect to the server and try to download │ │ │ pieces from it, unless it's paused, queued, checking or seeding. │ │ │ remove_url_seed() removes the given url if it exists already. │ │ │ url_seeds() return a set of the url seeds currently in this │ │ │ torrent. Note that URLs that fails may be removed automatically from │ │ │ the list.

    │ │ │

    See http seeding for more information.

    │ │ │ - │ │ │ │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    add_http_seed() remove_http_seed() http_seeds()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    remove_http_seed() add_http_seed() http_seeds()

    │ │ │
    │ │ │ -void add_http_seed (std::string const& url) const;
    │ │ │  std::set<std::string> http_seeds () const;
    │ │ │  void remove_http_seed (std::string const& url) const;
    │ │ │ +void add_http_seed (std::string const& url) const;
    │ │ │  
    │ │ │

    These functions are identical as the *_url_seed() variants, but │ │ │ they operate on BEP 17 web seeds instead of BEP 19.

    │ │ │

    See http seeding for more information.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    add_extension()

    │ │ │ @@ -730,18 +730,18 @@ │ │ │
    │ │ │ │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    unset_flags() set_flags() flags()

    │ │ │
    │ │ │ +void set_flags (torrent_flags_t flags) const;
    │ │ │  void set_flags (torrent_flags_t flags, torrent_flags_t mask) const;
    │ │ │  void unset_flags (torrent_flags_t flags) const;
    │ │ │  torrent_flags_t flags () const;
    │ │ │ -void set_flags (torrent_flags_t flags) const;
    │ │ │  
    │ │ │

    sets and gets the torrent state flags. See torrent_flags_t. │ │ │ The set_flags overload that take a mask will affect all │ │ │ flags part of the mask, and set their values to what the │ │ │ flags argument is set to. This allows clearing and │ │ │ setting flags in a single function call. │ │ │ The set_flags overload that just takes flags, sets all │ │ │ @@ -779,16 +779,16 @@ │ │ │ The torrent will be placed last in queue, i.e. its queue position │ │ │ will be the highest of all torrents in the session.

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    get_resume_data() save_resume_data()

    │ │ │
    │ │ │ -add_torrent_params get_resume_data (resume_data_flags_t flags = {}) const;
    │ │ │  void save_resume_data (resume_data_flags_t flags = {}) const;
    │ │ │ +add_torrent_params get_resume_data (resume_data_flags_t flags = {}) const;
    │ │ │  
    │ │ │

    save_resume_data() and get_resume_data() asks libtorrent to │ │ │ generate fast-resume data for this torrent. The fast resume data │ │ │ (stored in an add_torrent_params object) can be used to resume a │ │ │ torrent in the next session without having to check all files for │ │ │ which pieces have been downloaded. It can also be used to save a │ │ │ .torrent file for a torrent_handle.

    │ │ │ @@ -807,15 +807,15 @@ │ │ │
  • No torrent state has changed since the last saving of resume │ │ │ data, and the only_if_modified flag is set. │ │ │ metadata (see libtorrent's metadata from peers extension)
  • │ │ │ │ │ │ │ │ │

    Note that some counters may be outdated by the time you receive the fast resume data

    │ │ │

    When saving resume data because of shutting down, make sure not to │ │ │ -remove_torrent() before you receive the save_resume_data_alert. │ │ │ +remove_torrent() before you receive the save_resume_data_alert. │ │ │ There's no need to pause the session or torrent when saving resume │ │ │ data.

    │ │ │

    The paused state of a torrent is saved in the resume data, so pausing │ │ │ all torrents before saving resume data will all torrents be restored │ │ │ in a paused state.

    │ │ │
    │ │ │

    Note

    │ │ │ @@ -883,16 +883,16 @@ │ │ │ report that they don't need to save resume data again, and skipped by │ │ │ the initial loop, and thwart the counter otherwise.

    │ │ │
    │ │ │ [report issue]
    │ │ │
    │ │ │

    need_save_resume_data()

    │ │ │
    │ │ │ -bool need_save_resume_data () const;
    │ │ │  bool need_save_resume_data (resume_data_flags_t flags) const;
    │ │ │ +bool need_save_resume_data () const;
    │ │ │  
    │ │ │

    This function returns true if anything that is stored in the resume │ │ │ data has changed since the last time resume data was saved. │ │ │ The overload that takes flags let you ask if specific categories │ │ │ of properties have changed. These flags have the same behavior as in │ │ │ the save_resume_data() call.

    │ │ │

    This is a blocking call. It will wait for a response from │ │ │ @@ -902,27 +902,27 @@ │ │ │

    │ │ │

    Note

    │ │ │

    A torrent's resume data is considered saved as soon as the │ │ │ save_resume_data_alert is posted. It is important to make sure this │ │ │ alert is received and handled in order for this function to be │ │ │ meaningful.

    │ │ │
    │ │ │ - │ │ │ │ │ │ - │ │ │ + │ │ │ │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    queue_position() queue_position_bottom() queue_position_top() queue_position_down() queue_position_up()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    queue_position_bottom() queue_position() queue_position_down() queue_position_top() queue_position_up()

    │ │ │
    │ │ │ -void queue_position_down () const;
    │ │ │ -void queue_position_up () const;
    │ │ │ -void queue_position_top () const;
    │ │ │  queue_position_t queue_position () const;
    │ │ │ +void queue_position_top () const;
    │ │ │  void queue_position_bottom () const;
    │ │ │ +void queue_position_up () const;
    │ │ │ +void queue_position_down () const;
    │ │ │  
    │ │ │

    Every torrent that is added is assigned a queue position exactly one │ │ │ greater than the greatest queue position of all existing torrents. │ │ │ Torrents that are being seeded have -1 as their queue position, since │ │ │ they're no longer in line to be downloaded.

    │ │ │

    When a torrent is removed or turns into a seed, all torrents with │ │ │ greater queue positions have their positions decreased to fill in the │ │ │ @@ -976,18 +976,18 @@ │ │ │

    Note that when a torrent first starts up, and it needs a certificate, │ │ │ it will suspend connecting to any peers until it has one. It's │ │ │ typically desirable to resume the torrent after setting the SSL │ │ │ certificate.

    │ │ │

    If you receive a torrent_need_cert_alert, you need to call this to │ │ │ provide a valid cert. If you don't have a cert you won't be allowed to │ │ │ connect to any peers.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    torrent_file() torrent_file_with_hashes()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    torrent_file_with_hashes() torrent_file()

    │ │ │
    │ │ │  std::shared_ptr<torrent_info> torrent_file_with_hashes () const;
    │ │ │  std::shared_ptr<const torrent_info> torrent_file () const;
    │ │ │  
    │ │ │

    torrent_file() returns a pointer to the torrent_info object │ │ │ associated with this torrent. The torrent_info object may be a copy │ │ │ of the internal object. If the torrent doesn't have metadata, the │ │ │ @@ -1022,41 +1022,41 @@ │ │ │

    │ │ │  std::vector<std::vector<sha256_hash>> piece_layers () const;
    │ │ │  
    │ │ │

    returns the piece layers for all files in the torrent. If this is a │ │ │ v1 torrent (and doesn't have any piece layers) it returns an empty │ │ │ vector. This is a blocking call that will synchronize with the │ │ │ libtorrent network thread.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    piece_availability() post_piece_availability()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    post_piece_availability() piece_availability()

    │ │ │
    │ │ │ -void post_piece_availability () const;
    │ │ │  void piece_availability (std::vector<int>& avail) const;
    │ │ │ +void post_piece_availability () const;
    │ │ │  
    │ │ │

    The piece availability is the number of peers that we are connected │ │ │ that has advertised having a particular piece. This is the information │ │ │ that libtorrent uses in order to prefer picking rare pieces.

    │ │ │

    post_piece_availability() will trigger a piece_availability_alert │ │ │ to be posted.

    │ │ │

    piece_availability() fills the specified std::vector<int> │ │ │ with the availability for each piece in this torrent. libtorrent does │ │ │ not keep track of availability for seeds, so if the torrent is │ │ │ seeding the availability for all pieces is reported as 0.

    │ │ │ + │ │ │ │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    get_piece_priorities() piece_priority() prioritize_pieces()

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    prioritize_pieces() get_piece_priorities() piece_priority()

    │ │ │
    │ │ │ +void prioritize_pieces (std::vector<download_priority_t> const& pieces) const;
    │ │ │  download_priority_t piece_priority (piece_index_t index) const;
    │ │ │ -std::vector<download_priority_t> get_piece_priorities () const;
    │ │ │  void piece_priority (piece_index_t index, download_priority_t priority) const;
    │ │ │ -void prioritize_pieces (std::vector<download_priority_t> const& pieces) const;
    │ │ │ +std::vector<download_priority_t> get_piece_priorities () const;
    │ │ │  void prioritize_pieces (std::vector<std::pair<piece_index_t, download_priority_t>> const& pieces) const;
    │ │ │  
    │ │ │

    These functions are used to set and get the priority of individual │ │ │ pieces. By default all pieces have priority 4. That means that the │ │ │ random rarest first algorithm is effectively active for all pieces. │ │ │ You may however change the priority of individual pieces. There are 8 │ │ │ priority levels. 0 means not to download the piece at all. Otherwise, │ │ │ @@ -1085,18 +1085,18 @@ │ │ │ usage of file- and piece priorities.

    │ │ │ │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    get_file_priorities() file_priority() prioritize_files()

    │ │ │
    │ │ │ -std::vector<download_priority_t> get_file_priorities () const;
    │ │ │ -download_priority_t file_priority (file_index_t index) const;
    │ │ │  void prioritize_files (std::vector<download_priority_t> const& files) const;
    │ │ │  void file_priority (file_index_t index, download_priority_t priority) const;
    │ │ │ +std::vector<download_priority_t> get_file_priorities () const;
    │ │ │ +download_priority_t file_priority (file_index_t index) const;
    │ │ │  
    │ │ │

    index must be in the range [0, number_of_files).

    │ │ │

    file_priority() queries or sets the priority of file index.

    │ │ │

    prioritize_files() takes a vector that has at as many elements as │ │ │ there are files in the torrent. Each entry is the priority of that │ │ │ file. The function sets the priorities of all the pieces in the │ │ │ torrent based on the vector.

    │ │ │ @@ -1119,22 +1119,22 @@ │ │ │ file_prio_alert.

    │ │ │

    When combining file- and piece priorities, the resume file will record │ │ │ both. When loading the resume data, the file priorities will be applied │ │ │ first, then the piece priorities.

    │ │ │

    Moving data from a file into the part file is currently not │ │ │ supported. If a file has its priority set to 0 after it has already │ │ │ been created, it will not be moved into the partfile.

    │ │ │ - │ │ │ │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    force_reannounce() force_dht_announce() force_lsd_announce()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    force_dht_announce() force_reannounce() force_lsd_announce()

    │ │ │
    │ │ │ -void force_lsd_announce () const;
    │ │ │  void force_dht_announce () const;
    │ │ │ +void force_lsd_announce () const;
    │ │ │  void force_reannounce (int seconds = 0, int idx = -1, reannounce_flags_t = {}) const;
    │ │ │  
    │ │ │

    force_reannounce() will force this torrent to do another tracker │ │ │ request, to receive new peers. The seconds argument specifies how │ │ │ many seconds from now to issue the tracker announces.

    │ │ │

    If the tracker's min_interval has not passed since the last │ │ │ announce, the forced announce will be scheduled to happen immediately │ │ │ @@ -1161,23 +1161,23 @@ │ │ │ number of incomplete peers, complete peers, number of downloads etc.

    │ │ │

    This request will specifically update the num_complete and │ │ │ num_incomplete fields in the torrent_status struct once it │ │ │ completes. When it completes, it will generate a scrape_reply_alert. │ │ │ If it fails, it will generate a scrape_failed_alert.

    │ │ │ │ │ │ │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    set_upload_limit() set_download_limit() download_limit() upload_limit()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    set_upload_limit() set_download_limit() upload_limit() download_limit()

    │ │ │
    │ │ │ -void set_download_limit (int limit) const;
    │ │ │ -void set_upload_limit (int limit) const;
    │ │ │  int upload_limit () const;
    │ │ │ +void set_download_limit (int limit) const;
    │ │ │  int download_limit () const;
    │ │ │ +void set_upload_limit (int limit) const;
    │ │ │  
    │ │ │

    set_upload_limit will limit the upload bandwidth used by this │ │ │ particular torrent to the limit you set. It is given as the number of │ │ │ bytes per second the torrent is allowed to upload. │ │ │ set_download_limit works the same way but for download bandwidth │ │ │ instead of upload bandwidth. Note that setting a higher limit on a │ │ │ torrent then the global limit │ │ │ @@ -1214,16 +1214,16 @@ │ │ │ torrent. New peers will have to be acquired before resuming, from │ │ │ trackers, DHT or local service discovery, for example.

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    max_uploads() set_max_uploads()

    │ │ │
    │ │ │ -int max_uploads () const;
    │ │ │  void set_max_uploads (int max_uploads) const;
    │ │ │ +int max_uploads () const;
    │ │ │  
    │ │ │

    set_max_uploads() sets the maximum number of peers that's unchoked │ │ │ at the same time on this torrent. If you set this to -1, there will be │ │ │ no limit. This defaults to infinite. The primary setting controlling │ │ │ this is the global unchoke slots limit, set by unchoke_slots_limit in │ │ │ settings_pack.

    │ │ │

    max_uploads() returns the current settings.

    │ │ │ @@ -1300,37 +1300,37 @@ │ │ │

    rename_file()

    │ │ │
    │ │ │  void rename_file (file_index_t index, std::string const& new_name) const;
    │ │ │  
    │ │ │

    Renames the file with the given index asynchronously. The rename │ │ │ operation is complete when either a file_renamed_alert or │ │ │ file_rename_failed_alert is posted.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    info_hash() info_hashes()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    info_hashes() info_hash()

    │ │ │
    │ │ │ -info_hash_t info_hashes () const;
    │ │ │  sha1_hash info_hash () const;
    │ │ │ +info_hash_t info_hashes () const;
    │ │ │  
    │ │ │

    returns the info-hash(es) of the torrent. If this handle is to a │ │ │ torrent that hasn't loaded yet (for instance by being added) by a │ │ │ URL, the returned value is undefined. │ │ │ The info_hash() returns the SHA-1 info-hash for v1 torrents and a │ │ │ truncated hash for v2 torrents. For the full v2 info-hash, use │ │ │ info_hashes() instead.

    │ │ │ - │ │ │ │ │ │ -[report issue]
    │ │ │ + │ │ │ +[report issue] │ │ │
    │ │ │ -

    operator<() operator==() operator!=()

    │ │ │ +

    operator==() operator!=() operator<()

    │ │ │
    │ │ │  bool operator== (const torrent_handle& h) const;
    │ │ │ -bool operator!= (const torrent_handle& h) const;
    │ │ │  bool operator< (const torrent_handle& h) const;
    │ │ │ +bool operator!= (const torrent_handle& h) const;
    │ │ │  
    │ │ │

    comparison operators. The order of the torrents is unspecified │ │ │ but stable.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    id()

    │ │ │
    │ │ │ ├── html2text {}
    │ │ │ │ @@ -8,54 +8,54 @@
    │ │ │ │            o _e_n_u_m_ _b_l_o_c_k___s_t_a_t_e___t
    │ │ │ │      * _p_a_r_t_i_a_l___p_i_e_c_e___i_n_f_o
    │ │ │ │      * _t_o_r_r_e_n_t___h_a_n_d_l_e
    │ │ │ │            o _t_o_r_r_e_n_t___h_a_n_d_l_e_(_)
    │ │ │ │            o _a_d_d___p_i_e_c_e_(_)
    │ │ │ │            o _r_e_a_d___p_i_e_c_e_(_)
    │ │ │ │            o _h_a_v_e___p_i_e_c_e_(_)
    │ │ │ │ -          o _g_e_t___p_e_e_r___i_n_f_o_(_)_ _p_o_s_t___p_e_e_r___i_n_f_o_(_)
    │ │ │ │ -          o _s_t_a_t_u_s_(_)_ _p_o_s_t___s_t_a_t_u_s_(_)
    │ │ │ │ -          o _p_o_s_t___d_o_w_n_l_o_a_d___q_u_e_u_e_(_)_ _g_e_t___d_o_w_n_l_o_a_d___q_u_e_u_e_(_)
    │ │ │ │ -          o _s_e_t___p_i_e_c_e___d_e_a_d_l_i_n_e_(_)_ _r_e_s_e_t___p_i_e_c_e___d_e_a_d_l_i_n_e_(_)_ _c_l_e_a_r___p_i_e_c_e___d_e_a_d_l_i_n_e_s_(_)
    │ │ │ │ -          o _p_o_s_t___f_i_l_e___p_r_o_g_r_e_s_s_(_)_ _f_i_l_e___p_r_o_g_r_e_s_s_(_)
    │ │ │ │ +          o _p_o_s_t___p_e_e_r___i_n_f_o_(_)_ _g_e_t___p_e_e_r___i_n_f_o_(_)
    │ │ │ │ +          o _p_o_s_t___s_t_a_t_u_s_(_)_ _s_t_a_t_u_s_(_)
    │ │ │ │ +          o _g_e_t___d_o_w_n_l_o_a_d___q_u_e_u_e_(_)_ _p_o_s_t___d_o_w_n_l_o_a_d___q_u_e_u_e_(_)
    │ │ │ │ +          o _r_e_s_e_t___p_i_e_c_e___d_e_a_d_l_i_n_e_(_)_ _s_e_t___p_i_e_c_e___d_e_a_d_l_i_n_e_(_)_ _c_l_e_a_r___p_i_e_c_e___d_e_a_d_l_i_n_e_s_(_)
    │ │ │ │ +          o _f_i_l_e___p_r_o_g_r_e_s_s_(_)_ _p_o_s_t___f_i_l_e___p_r_o_g_r_e_s_s_(_)
    │ │ │ │            o _f_i_l_e___s_t_a_t_u_s_(_)
    │ │ │ │            o _c_l_e_a_r___e_r_r_o_r_(_)
    │ │ │ │ -          o _a_d_d___t_r_a_c_k_e_r_(_)_ _r_e_p_l_a_c_e___t_r_a_c_k_e_r_s_(_)_ _t_r_a_c_k_e_r_s_(_)_ _p_o_s_t___t_r_a_c_k_e_r_s_(_)
    │ │ │ │ -          o _r_e_m_o_v_e___u_r_l___s_e_e_d_(_)_ _u_r_l___s_e_e_d_s_(_)_ _a_d_d___u_r_l___s_e_e_d_(_)
    │ │ │ │ -          o _a_d_d___h_t_t_p___s_e_e_d_(_)_ _r_e_m_o_v_e___h_t_t_p___s_e_e_d_(_)_ _h_t_t_p___s_e_e_d_s_(_)
    │ │ │ │ +          o _p_o_s_t___t_r_a_c_k_e_r_s_(_)_ _t_r_a_c_k_e_r_s_(_)_ _r_e_p_l_a_c_e___t_r_a_c_k_e_r_s_(_)_ _a_d_d___t_r_a_c_k_e_r_(_)
    │ │ │ │ +          o _a_d_d___u_r_l___s_e_e_d_(_)_ _u_r_l___s_e_e_d_s_(_)_ _r_e_m_o_v_e___u_r_l___s_e_e_d_(_)
    │ │ │ │ +          o _r_e_m_o_v_e___h_t_t_p___s_e_e_d_(_)_ _a_d_d___h_t_t_p___s_e_e_d_(_)_ _h_t_t_p___s_e_e_d_s_(_)
    │ │ │ │            o _a_d_d___e_x_t_e_n_s_i_o_n_(_)
    │ │ │ │            o _s_e_t___m_e_t_a_d_a_t_a_(_)
    │ │ │ │            o _i_s___v_a_l_i_d_(_)
    │ │ │ │            o _r_e_s_u_m_e_(_)_ _p_a_u_s_e_(_)
    │ │ │ │            o _u_n_s_e_t___f_l_a_g_s_(_)_ _s_e_t___f_l_a_g_s_(_)_ _f_l_a_g_s_(_)
    │ │ │ │            o _f_l_u_s_h___c_a_c_h_e_(_)
    │ │ │ │            o _f_o_r_c_e___r_e_c_h_e_c_k_(_)
    │ │ │ │            o _g_e_t___r_e_s_u_m_e___d_a_t_a_(_)_ _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_)
    │ │ │ │            o _n_e_e_d___s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_)
    │ │ │ │ -          o _q_u_e_u_e___p_o_s_i_t_i_o_n_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n___b_o_t_t_o_m_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n___t_o_p_(_)
    │ │ │ │ -            _q_u_e_u_e___p_o_s_i_t_i_o_n___d_o_w_n_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n___u_p_(_)
    │ │ │ │ +          o _q_u_e_u_e___p_o_s_i_t_i_o_n___b_o_t_t_o_m_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n___d_o_w_n_(_)
    │ │ │ │ +            _q_u_e_u_e___p_o_s_i_t_i_o_n___t_o_p_(_)_ _q_u_e_u_e___p_o_s_i_t_i_o_n___u_p_(_)
    │ │ │ │            o _q_u_e_u_e___p_o_s_i_t_i_o_n___s_e_t_(_)
    │ │ │ │            o _s_e_t___s_s_l___c_e_r_t_i_f_i_c_a_t_e___b_u_f_f_e_r_(_)_ _s_e_t___s_s_l___c_e_r_t_i_f_i_c_a_t_e_(_)
    │ │ │ │ -          o _t_o_r_r_e_n_t___f_i_l_e_(_)_ _t_o_r_r_e_n_t___f_i_l_e___w_i_t_h___h_a_s_h_e_s_(_)
    │ │ │ │ +          o _t_o_r_r_e_n_t___f_i_l_e___w_i_t_h___h_a_s_h_e_s_(_)_ _t_o_r_r_e_n_t___f_i_l_e_(_)
    │ │ │ │            o _p_i_e_c_e___l_a_y_e_r_s_(_)
    │ │ │ │ -          o _p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y_(_)_ _p_o_s_t___p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y_(_)
    │ │ │ │ -          o _g_e_t___p_i_e_c_e___p_r_i_o_r_i_t_i_e_s_(_)_ _p_i_e_c_e___p_r_i_o_r_i_t_y_(_)_ _p_r_i_o_r_i_t_i_z_e___p_i_e_c_e_s_(_)
    │ │ │ │ +          o _p_o_s_t___p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y_(_)_ _p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y_(_)
    │ │ │ │ +          o _p_r_i_o_r_i_t_i_z_e___p_i_e_c_e_s_(_)_ _g_e_t___p_i_e_c_e___p_r_i_o_r_i_t_i_e_s_(_)_ _p_i_e_c_e___p_r_i_o_r_i_t_y_(_)
    │ │ │ │            o _g_e_t___f_i_l_e___p_r_i_o_r_i_t_i_e_s_(_)_ _f_i_l_e___p_r_i_o_r_i_t_y_(_)_ _p_r_i_o_r_i_t_i_z_e___f_i_l_e_s_(_)
    │ │ │ │ -          o _f_o_r_c_e___r_e_a_n_n_o_u_n_c_e_(_)_ _f_o_r_c_e___d_h_t___a_n_n_o_u_n_c_e_(_)_ _f_o_r_c_e___l_s_d___a_n_n_o_u_n_c_e_(_)
    │ │ │ │ +          o _f_o_r_c_e___d_h_t___a_n_n_o_u_n_c_e_(_)_ _f_o_r_c_e___r_e_a_n_n_o_u_n_c_e_(_)_ _f_o_r_c_e___l_s_d___a_n_n_o_u_n_c_e_(_)
    │ │ │ │            o _s_c_r_a_p_e___t_r_a_c_k_e_r_(_)
    │ │ │ │ -          o _s_e_t___u_p_l_o_a_d___l_i_m_i_t_(_)_ _s_e_t___d_o_w_n_l_o_a_d___l_i_m_i_t_(_)_ _d_o_w_n_l_o_a_d___l_i_m_i_t_(_)
    │ │ │ │ -            _u_p_l_o_a_d___l_i_m_i_t_(_)
    │ │ │ │ +          o _s_e_t___u_p_l_o_a_d___l_i_m_i_t_(_)_ _s_e_t___d_o_w_n_l_o_a_d___l_i_m_i_t_(_)_ _u_p_l_o_a_d___l_i_m_i_t_(_)
    │ │ │ │ +            _d_o_w_n_l_o_a_d___l_i_m_i_t_(_)
    │ │ │ │            o _c_o_n_n_e_c_t___p_e_e_r_(_)
    │ │ │ │            o _c_l_e_a_r___p_e_e_r_s_(_)
    │ │ │ │            o _m_a_x___u_p_l_o_a_d_s_(_)_ _s_e_t___m_a_x___u_p_l_o_a_d_s_(_)
    │ │ │ │            o _s_e_t___m_a_x___c_o_n_n_e_c_t_i_o_n_s_(_)_ _m_a_x___c_o_n_n_e_c_t_i_o_n_s_(_)
    │ │ │ │            o _m_o_v_e___s_t_o_r_a_g_e_(_)
    │ │ │ │            o _r_e_n_a_m_e___f_i_l_e_(_)
    │ │ │ │ -          o _i_n_f_o___h_a_s_h_(_)_ _i_n_f_o___h_a_s_h_e_s_(_)
    │ │ │ │ -          o _o_p_e_r_a_t_o_r_<_(_)_ _o_p_e_r_a_t_o_r_=_=_(_)_ _o_p_e_r_a_t_o_r_!_=_(_)
    │ │ │ │ +          o _i_n_f_o___h_a_s_h_e_s_(_)_ _i_n_f_o___h_a_s_h_(_)
    │ │ │ │ +          o _o_p_e_r_a_t_o_r_=_=_(_)_ _o_p_e_r_a_t_o_r_!_=_(_)_ _o_p_e_r_a_t_o_r_<_(_)
    │ │ │ │            o _i_d_(_)
    │ │ │ │            o _n_a_t_i_v_e___h_a_n_d_l_e_(_)
    │ │ │ │            o _u_s_e_r_d_a_t_a_(_)
    │ │ │ │            o _i_n___s_e_s_s_i_o_n_(_)
    │ │ │ │      * _h_a_s_h___v_a_l_u_e_(_)
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ************ bblloocckk__iinnffoo ************
    │ │ │ │ @@ -175,121 +175,121 @@
    │ │ │ │  the handle is no longer referring to a torrent. There is one exception _i_s___v_a_l_i_d
    │ │ │ │  _(_) will never throw. Since the torrents are processed by a background thread,
    │ │ │ │  there is no guarantee that a handle will remain valid between two calls.
    │ │ │ │  struct torrent_handle
    │ │ │ │  {
    │ │ │ │     friend std::size_t hhaasshh__vvaalluuee (torrent_handle const& th);
    │ │ │ │     ttoorrrreenntt__hhaannddllee () noexcept = default;
    │ │ │ │ -   void aadddd__ppiieeccee (piece_index_t piece, std::vector data,
    │ │ │ │ -add_piece_flags_t flags = {}) const;
    │ │ │ │     void aadddd__ppiieeccee (piece_index_t piece, char const* data, add_piece_flags_t
    │ │ │ │  flags = {}) const;
    │ │ │ │ +   void aadddd__ppiieeccee (piece_index_t piece, std::vector data,
    │ │ │ │ +add_piece_flags_t flags = {}) const;
    │ │ │ │     void rreeaadd__ppiieeccee (piece_index_t piece) const;
    │ │ │ │     bool hhaavvee__ppiieeccee (piece_index_t piece) const;
    │ │ │ │     void ppoosstt__ppeeeerr__iinnffoo () const;
    │ │ │ │     void ggeett__ppeeeerr__iinnffoo (std::vector& v) const;
    │ │ │ │ -   torrent_status ssttaattuuss (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ │     void ppoosstt__ssttaattuuss (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ │ -   std::vector ggeett__ddoowwnnllooaadd__qquueeuuee () const;
    │ │ │ │ -   void ppoosstt__ddoowwnnllooaadd__qquueeuuee () const;
    │ │ │ │ +   torrent_status ssttaattuuss (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ │     void ggeett__ddoowwnnllooaadd__qquueeuuee (std::vector& queue) const;
    │ │ │ │ -   void cclleeaarr__ppiieeccee__ddeeaaddlliinneess () const;
    │ │ │ │ +   void ppoosstt__ddoowwnnllooaadd__qquueeuuee () const;
    │ │ │ │ +   std::vector ggeett__ddoowwnnllooaadd__qquueeuuee () const;
    │ │ │ │     void sseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index, int deadline, deadline_flags_t
    │ │ │ │  flags = {}) const;
    │ │ │ │ +   void cclleeaarr__ppiieeccee__ddeeaaddlliinneess () const;
    │ │ │ │     void rreesseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index) const;
    │ │ │ │ -   std::vector ffiillee__pprrooggrreessss (file_progress_flags_t flags = {})
    │ │ │ │ -const;
    │ │ │ │     void ppoosstt__ffiillee__pprrooggrreessss (file_progress_flags_t flags) const;
    │ │ │ │     void ffiillee__pprrooggrreessss (std::vector& progress,
    │ │ │ │  file_progress_flags_t flags = {}) const;
    │ │ │ │ +   std::vector ffiillee__pprrooggrreessss (file_progress_flags_t flags = {})
    │ │ │ │ +const;
    │ │ │ │     std::vector ffiillee__ssttaattuuss () const;
    │ │ │ │     void cclleeaarr__eerrrroorr () const;
    │ │ │ │ -   void rreeppllaaccee__ttrraacckkeerrss (std::vector const&) const;
    │ │ │ │     void aadddd__ttrraacckkeerr (announce_entry const&) const;
    │ │ │ │     void ppoosstt__ttrraacckkeerrss () const;
    │ │ │ │     std::vector ttrraacckkeerrss () const;
    │ │ │ │ -   void rreemmoovvee__uurrll__sseeeedd (std::string const& url) const;
    │ │ │ │ +   void rreeppllaaccee__ttrraacckkeerrss (std::vector const&) const;
    │ │ │ │     void aadddd__uurrll__sseeeedd (std::string const& url) const;
    │ │ │ │ +   void rreemmoovvee__uurrll__sseeeedd (std::string const& url) const;
    │ │ │ │     std::set uurrll__sseeeeddss () const;
    │ │ │ │ -   void aadddd__hhttttpp__sseeeedd (std::string const& url) const;
    │ │ │ │     std::set hhttttpp__sseeeeddss () const;
    │ │ │ │     void rreemmoovvee__hhttttpp__sseeeedd (std::string const& url) const;
    │ │ │ │ +   void aadddd__hhttttpp__sseeeedd (std::string const& url) const;
    │ │ │ │     void aadddd__eexxtteennssiioonn (
    │ │ │ │        std::function(torrent_handle const&,
    │ │ │ │  client_data_t)> const& ext
    │ │ │ │        , client_data_t userdata = client_data_t{});
    │ │ │ │     bool sseett__mmeettaaddaattaa (span metadata) const;
    │ │ │ │     bool iiss__vvaalliidd () const;
    │ │ │ │     void rreessuummee () const;
    │ │ │ │     void ppaauussee (pause_flags_t flags = {}) const;
    │ │ │ │ +   void sseett__ffllaaggss (torrent_flags_t flags) const;
    │ │ │ │     void sseett__ffllaaggss (torrent_flags_t flags, torrent_flags_t mask) const;
    │ │ │ │     void uunnsseett__ffllaaggss (torrent_flags_t flags) const;
    │ │ │ │     torrent_flags_t ffllaaggss () const;
    │ │ │ │ -   void sseett__ffllaaggss (torrent_flags_t flags) const;
    │ │ │ │     void fflluusshh__ccaacchhee () const;
    │ │ │ │     void ffoorrccee__rreecchheecckk () const;
    │ │ │ │ -   add_torrent_params ggeett__rreessuummee__ddaattaa (resume_data_flags_t flags = {}) const;
    │ │ │ │     void ssaavvee__rreessuummee__ddaattaa (resume_data_flags_t flags = {}) const;
    │ │ │ │ -   bool nneeeedd__ssaavvee__rreessuummee__ddaattaa () const;
    │ │ │ │ +   add_torrent_params ggeett__rreessuummee__ddaattaa (resume_data_flags_t flags = {}) const;
    │ │ │ │     bool nneeeedd__ssaavvee__rreessuummee__ddaattaa (resume_data_flags_t flags) const;
    │ │ │ │ -   void qquueeuuee__ppoossiittiioonn__ddoowwnn () const;
    │ │ │ │ -   void qquueeuuee__ppoossiittiioonn__uupp () const;
    │ │ │ │ -   void qquueeuuee__ppoossiittiioonn__ttoopp () const;
    │ │ │ │ +   bool nneeeedd__ssaavvee__rreessuummee__ddaattaa () const;
    │ │ │ │     queue_position_t qquueeuuee__ppoossiittiioonn () const;
    │ │ │ │ +   void qquueeuuee__ppoossiittiioonn__ttoopp () const;
    │ │ │ │     void qquueeuuee__ppoossiittiioonn__bboottttoomm () const;
    │ │ │ │ +   void qquueeuuee__ppoossiittiioonn__uupp () const;
    │ │ │ │ +   void qquueeuuee__ppoossiittiioonn__ddoowwnn () const;
    │ │ │ │     void qquueeuuee__ppoossiittiioonn__sseett (queue_position_t p) const;
    │ │ │ │     void sseett__ssssll__cceerrttiiffiiccaattee (std::string const& certificate
    │ │ │ │        , std::string const& private_key
    │ │ │ │        , std::string const& dh_params
    │ │ │ │        , std::string const& passphrase = "");
    │ │ │ │     void sseett__ssssll__cceerrttiiffiiccaattee__bbuuffffeerr (std::string const& certificate
    │ │ │ │        , std::string const& private_key
    │ │ │ │        , std::string const& dh_params);
    │ │ │ │     std::shared_ptr ttoorrrreenntt__ffiillee__wwiitthh__hhaasshheess () const;
    │ │ │ │     std::shared_ptr ttoorrrreenntt__ffiillee () const;
    │ │ │ │     std::vector> ppiieeccee__llaayyeerrss () const;
    │ │ │ │ -   void ppoosstt__ppiieeccee__aavvaaiillaabbiilliittyy () const;
    │ │ │ │     void ppiieeccee__aavvaaiillaabbiilliittyy (std::vector& avail) const;
    │ │ │ │ +   void ppoosstt__ppiieeccee__aavvaaiillaabbiilliittyy () const;
    │ │ │ │ +   void pprriioorriittiizzee__ppiieecceess (std::vector const& pieces)
    │ │ │ │ +const;
    │ │ │ │     download_priority_t ppiieeccee__pprriioorriittyy (piece_index_t index) const;
    │ │ │ │ -   std::vector ggeett__ppiieeccee__pprriioorriittiieess () const;
    │ │ │ │     void ppiieeccee__pprriioorriittyy (piece_index_t index, download_priority_t priority)
    │ │ │ │  const;
    │ │ │ │ -   void pprriioorriittiizzee__ppiieecceess (std::vector const& pieces)
    │ │ │ │ -const;
    │ │ │ │ +   std::vector ggeett__ppiieeccee__pprriioorriittiieess () const;
    │ │ │ │     void pprriioorriittiizzee__ppiieecceess (std::vector> const& pieces) const;
    │ │ │ │ -   std::vector ggeett__ffiillee__pprriioorriittiieess () const;
    │ │ │ │ -   download_priority_t ffiillee__pprriioorriittyy (file_index_t index) const;
    │ │ │ │     void pprriioorriittiizzee__ffiilleess (std::vector const& files) const;
    │ │ │ │     void ffiillee__pprriioorriittyy (file_index_t index, download_priority_t priority) const;
    │ │ │ │ -   void ffoorrccee__llssdd__aannnnoouunnccee () const;
    │ │ │ │ +   std::vector ggeett__ffiillee__pprriioorriittiieess () const;
    │ │ │ │ +   download_priority_t ffiillee__pprriioorriittyy (file_index_t index) const;
    │ │ │ │     void ffoorrccee__ddhhtt__aannnnoouunnccee () const;
    │ │ │ │ +   void ffoorrccee__llssdd__aannnnoouunnccee () const;
    │ │ │ │     void ffoorrccee__rreeaannnnoouunnccee (int seconds = 0, int idx = -1, reannounce_flags_t =
    │ │ │ │  {}) const;
    │ │ │ │     void ssccrraappee__ttrraacckkeerr (int idx = -1) const;
    │ │ │ │ -   void sseett__ddoowwnnllooaadd__lliimmiitt (int limit) const;
    │ │ │ │ -   void sseett__uuppllooaadd__lliimmiitt (int limit) const;
    │ │ │ │     int uuppllooaadd__lliimmiitt () const;
    │ │ │ │ +   void sseett__ddoowwnnllooaadd__lliimmiitt (int limit) const;
    │ │ │ │     int ddoowwnnllooaadd__lliimmiitt () const;
    │ │ │ │ +   void sseett__uuppllooaadd__lliimmiitt (int limit) const;
    │ │ │ │     void ccoonnnneecctt__ppeeeerr (tcp::endpoint const& adr, peer_source_flags_t source = {}
    │ │ │ │        , pex_flags_t flags = pex_encryption | pex_utp | pex_holepunch) const;
    │ │ │ │     void cclleeaarr__ppeeeerrss ();
    │ │ │ │ -   int mmaaxx__uuppllooaaddss () const;
    │ │ │ │     void sseett__mmaaxx__uuppllooaaddss (int max_uploads) const;
    │ │ │ │ +   int mmaaxx__uuppllooaaddss () const;
    │ │ │ │     void sseett__mmaaxx__ccoonnnneeccttiioonnss (int max_connections) const;
    │ │ │ │     int mmaaxx__ccoonnnneeccttiioonnss () const;
    │ │ │ │     void mmoovvee__ssttoorraaggee (std::string const& save_path
    │ │ │ │        , move_flags_t flags = move_flags_t::always_replace_files
    │ │ │ │        ) const;
    │ │ │ │     void rreennaammee__ffiillee (file_index_t index, std::string const& new_name) const;
    │ │ │ │ -   info_hash_t iinnffoo__hhaasshheess () const;
    │ │ │ │     sha1_hash iinnffoo__hhaasshh () const;
    │ │ │ │ +   info_hash_t iinnffoo__hhaasshheess () const;
    │ │ │ │     bool ooppeerraattoorr==== (const torrent_handle& h) const;
    │ │ │ │ -   bool ooppeerraattoorr!!== (const torrent_handle& h) const;
    │ │ │ │     bool ooppeerraattoorr<< (const torrent_handle& h) const;
    │ │ │ │ +   bool ooppeerraattoorr!!== (const torrent_handle& h) const;
    │ │ │ │     std::uint32_t iidd () const;
    │ │ │ │     std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │     client_data_t uusseerrddaattaa () const;
    │ │ │ │     bool iinn__sseessssiioonn () const;
    │ │ │ │  
    │ │ │ │     static constexpr add_piece_flags_t oovveerrwwrriittee__eexxiissttiinngg  = 0_bit;
    │ │ │ │     static constexpr status_flags_t qquueerryy__ddiissttrriibbuutteedd__ccooppiieess  = 0_bit;
    │ │ │ │ @@ -317,18 +317,18 @@
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ttoorrrreenntt__hhaannddllee(()) **********
    │ │ │ │  ttoorrrreenntt__hhaannddllee () noexcept = default;
    │ │ │ │  constructs a torrent handle that does not refer to a torrent. i.e. _i_s___v_a_l_i_d_(_)
    │ │ │ │  will return false.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** aadddd__ppiieeccee(()) **********
    │ │ │ │ -void aadddd__ppiieeccee (piece_index_t piece, std::vector data, add_piece_flags_t
    │ │ │ │ -flags = {}) const;
    │ │ │ │  void aadddd__ppiieeccee (piece_index_t piece, char const* data, add_piece_flags_t flags
    │ │ │ │  = {}) const;
    │ │ │ │ +void aadddd__ppiieeccee (piece_index_t piece, std::vector data, add_piece_flags_t
    │ │ │ │ +flags = {}) const;
    │ │ │ │  This function will write data to the storage as piece piece, as if it had been
    │ │ │ │  downloaded from a peer.
    │ │ │ │  By default, data that's already been downloaded is not overwritten by this
    │ │ │ │  buffer. If you trust this data to be correct (and pass the piece hash check)
    │ │ │ │  you may pass the overwrite_existing flag. This will instruct libtorrent to
    │ │ │ │  overwrite any data that may already have been downloaded with this data.
    │ │ │ │  Since the data is written asynchronously, you may know that is passed or failed
    │ │ │ │ @@ -362,30 +362,30 @@
    │ │ │ │  torrents) are not full size.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** hhaavvee__ppiieeccee(()) **********
    │ │ │ │  bool hhaavvee__ppiieeccee (piece_index_t piece) const;
    │ │ │ │  Returns true if this piece has been completely downloaded and written to disk,
    │ │ │ │  and false otherwise.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ggeett__ppeeeerr__iinnffoo(()) ppoosstt__ppeeeerr__iinnffoo(()) **********
    │ │ │ │ +********** ppoosstt__ppeeeerr__iinnffoo(()) ggeett__ppeeeerr__iinnffoo(()) **********
    │ │ │ │  void ppoosstt__ppeeeerr__iinnffoo () const;
    │ │ │ │  void ggeett__ppeeeerr__iinnffoo (std::vector& v) const;
    │ │ │ │  Query information about connected peers for this torrent. If the _t_o_r_r_e_n_t___h_a_n_d_l_e
    │ │ │ │  is invalid, it will throw a system_error exception.
    │ │ │ │  post_peer_info() is asynchronous and will trigger the posting of a
    │ │ │ │  _p_e_e_r___i_n_f_o___a_l_e_r_t. The _a_l_e_r_t contain a list of _p_e_e_r___i_n_f_o objects, one for each
    │ │ │ │  connected peer.
    │ │ │ │  get_peer_info() is synchronous and takes a reference to a vector that will be
    │ │ │ │  cleared and filled with one _e_n_t_r_y for each peer connected to this torrent,
    │ │ │ │  given the handle is valid. Each _e_n_t_r_y in the vector contains information about
    │ │ │ │  that particular peer. See _p_e_e_r___i_n_f_o.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ssttaattuuss(()) ppoosstt__ssttaattuuss(()) **********
    │ │ │ │ -torrent_status ssttaattuuss (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ │ +********** ppoosstt__ssttaattuuss(()) ssttaattuuss(()) **********
    │ │ │ │  void ppoosstt__ssttaattuuss (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ │ +torrent_status ssttaattuuss (status_flags_t flags = status_flags_t::all()) const;
    │ │ │ │  status() will return a structure with information about the status of this
    │ │ │ │  torrent. If the _t_o_r_r_e_n_t___h_a_n_d_l_e is invalid, it will throw system_error
    │ │ │ │  exception. See _t_o_r_r_e_n_t___s_t_a_t_u_s. The flags argument filters what information is
    │ │ │ │  returned in the _t_o_r_r_e_n_t___s_t_a_t_u_s. Some information in there is relatively
    │ │ │ │  expensive to calculate, and if you're not interested in it (and see performance
    │ │ │ │  issues), you can filter them out.
    │ │ │ │  The status() function will block until the internal libtorrent thread responds
    │ │ │ │ @@ -393,34 +393,34 @@
    │ │ │ │  It will trigger posting of a _s_t_a_t_e___u_p_d_a_t_e___a_l_e_r_t with a single _t_o_r_r_e_n_t___s_t_a_t_u_s
    │ │ │ │  object for this torrent.
    │ │ │ │  In order to get regular updates for torrents whose status changes, consider
    │ │ │ │  calling session::post_torrent_updates()`` instead.
    │ │ │ │  By default everything is included. The flags you can use to decide what to
    │ │ │ │  iinncclluuddee are defined in this class.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ppoosstt__ddoowwnnllooaadd__qquueeuuee(()) ggeett__ddoowwnnllooaadd__qquueeuuee(()) **********
    │ │ │ │ -std::vector ggeett__ddoowwnnllooaadd__qquueeuuee () const;
    │ │ │ │ -void ppoosstt__ddoowwnnllooaadd__qquueeuuee () const;
    │ │ │ │ +********** ggeett__ddoowwnnllooaadd__qquueeuuee(()) ppoosstt__ddoowwnnllooaadd__qquueeuuee(()) **********
    │ │ │ │  void ggeett__ddoowwnnllooaadd__qquueeuuee (std::vector& queue) const;
    │ │ │ │ +void ppoosstt__ddoowwnnllooaadd__qquueeuuee () const;
    │ │ │ │ +std::vector ggeett__ddoowwnnllooaadd__qquueeuuee () const;
    │ │ │ │  post_download_queue() triggers a download_queue_alert to be posted.
    │ │ │ │  get_download_queue() is a synchronous call and returns a vector with
    │ │ │ │  information about pieces that are partially downloaded or not downloaded but
    │ │ │ │  partially requested. See _p_a_r_t_i_a_l___p_i_e_c_e___i_n_f_o for the fields in the returned
    │ │ │ │  vector.
    │ │ │ │  Warning
    │ │ │ │  get_download_queue() is prone to threading errors. The _b_l_o_c_k___i_n_f_o pointers its
    │ │ │ │  return value points to are owned by the _s_e_s_s_i_o_n and will be cleared the next
    │ │ │ │  time get_download_queue() is called. Therefore it's not safe to call this
    │ │ │ │  function from multiple threads. Using post_download_queue() is a safe
    │ │ │ │  alternative.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** sseett__ppiieeccee__ddeeaaddlliinnee(()) rreesseett__ppiieeccee__ddeeaaddlliinnee(()) cclleeaarr__ppiieeccee__ddeeaaddlliinneess(()) **********
    │ │ │ │ -void cclleeaarr__ppiieeccee__ddeeaaddlliinneess () const;
    │ │ │ │ +********** rreesseett__ppiieeccee__ddeeaaddlliinnee(()) sseett__ppiieeccee__ddeeaaddlliinnee(()) cclleeaarr__ppiieeccee__ddeeaaddlliinneess(()) **********
    │ │ │ │  void sseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index, int deadline, deadline_flags_t
    │ │ │ │  flags = {}) const;
    │ │ │ │ +void cclleeaarr__ppiieeccee__ddeeaaddlliinneess () const;
    │ │ │ │  void rreesseett__ppiieeccee__ddeeaaddlliinnee (piece_index_t index) const;
    │ │ │ │  This function sets or resets the deadline associated with a specific piece
    │ │ │ │  index (index). libtorrent will attempt to download this entire piece before the
    │ │ │ │  deadline expires. This is not necessarily possible, but pieces with a more
    │ │ │ │  recent deadline will always be prioritized over pieces with a deadline further
    │ │ │ │  ahead in time. The deadline (and flags) of a piece can be changed by calling
    │ │ │ │  this function again.
    │ │ │ │ @@ -429,20 +429,20 @@
    │ │ │ │  same effect as calling _r_e_a_d___p_i_e_c_e_(_) for index.
    │ │ │ │  deadline is the number of milliseconds until this piece should be completed.
    │ │ │ │  reset_piece_deadline removes the deadline from the piece. If it hasn't already
    │ │ │ │  been downloaded, it will no longer be considered a priority.
    │ │ │ │  clear_piece_deadlines() removes deadlines on all pieces in the torrent. As if
    │ │ │ │  _r_e_s_e_t___p_i_e_c_e___d_e_a_d_l_i_n_e_(_) was called on all pieces.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ppoosstt__ffiillee__pprrooggrreessss(()) ffiillee__pprrooggrreessss(()) **********
    │ │ │ │ -std::vector ffiillee__pprrooggrreessss (file_progress_flags_t flags = {})
    │ │ │ │ -const;
    │ │ │ │ +********** ffiillee__pprrooggrreessss(()) ppoosstt__ffiillee__pprrooggrreessss(()) **********
    │ │ │ │  void ppoosstt__ffiillee__pprrooggrreessss (file_progress_flags_t flags) const;
    │ │ │ │  void ffiillee__pprrooggrreessss (std::vector& progress, file_progress_flags_t
    │ │ │ │  flags = {}) const;
    │ │ │ │ +std::vector ffiillee__pprrooggrreessss (file_progress_flags_t flags = {})
    │ │ │ │ +const;
    │ │ │ │  This function fills in the supplied vector, or returns a vector, with the
    │ │ │ │  number of bytes downloaded of each file in this torrent. The progress values
    │ │ │ │  are ordered the same as the files in the _t_o_r_r_e_n_t___i_n_f_o.
    │ │ │ │  This operation is not very cheap. Its complexity is OO((nn ++ mmjj)). Where nn is the
    │ │ │ │  number of files, mm is the number of currently downloading pieces and jj is the
    │ │ │ │  number of blocks in a piece.
    │ │ │ │  The flags parameter can be used to specify the granularity of the file
    │ │ │ │ @@ -463,19 +463,19 @@
    │ │ │ │  See _o_p_e_n___f_i_l_e___s_t_a_t_e
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** cclleeaarr__eerrrroorr(()) **********
    │ │ │ │  void cclleeaarr__eerrrroorr () const;
    │ │ │ │  If the torrent is in an error state (i.e. torrent_status::error is non-empty),
    │ │ │ │  this will clear the error and start the torrent again.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** aadddd__ttrraacckkeerr(()) rreeppllaaccee__ttrraacckkeerrss(()) ttrraacckkeerrss(()) ppoosstt__ttrraacckkeerrss(()) **********
    │ │ │ │ -void rreeppllaaccee__ttrraacckkeerrss (std::vector const&) const;
    │ │ │ │ +********** ppoosstt__ttrraacckkeerrss(()) ttrraacckkeerrss(()) rreeppllaaccee__ttrraacckkeerrss(()) aadddd__ttrraacckkeerr(()) **********
    │ │ │ │  void aadddd__ttrraacckkeerr (announce_entry const&) const;
    │ │ │ │  void ppoosstt__ttrraacckkeerrss () const;
    │ │ │ │  std::vector ttrraacckkeerrss () const;
    │ │ │ │ +void rreeppllaaccee__ttrraacckkeerrss (std::vector const&) const;
    │ │ │ │  trackers() returns the list of trackers for this torrent. The announce _e_n_t_r_y
    │ │ │ │  contains both a string url which specify the announce url for the tracker as
    │ │ │ │  well as an _i_n_t tier, which is specifies the order in which this tracker is
    │ │ │ │  tried. If you want libtorrent to use another list of trackers for this torrent,
    │ │ │ │  you can use replace_trackers() which takes a list of the same form as the one
    │ │ │ │  returned from trackers() and will replace it. If you want an immediate effect,
    │ │ │ │  you have to call _f_o_r_c_e___r_e_a_n_n_o_u_n_c_e_(_). See _a_n_n_o_u_n_c_e___e_n_t_r_y.
    │ │ │ │ @@ -484,30 +484,30 @@
    │ │ │ │  add_tracker() will look if the specified tracker is already in the set. If it
    │ │ │ │  is, it doesn't do anything. If it's not in the current set of trackers, it will
    │ │ │ │  insert it in the tier specified in the _a_n_n_o_u_n_c_e___e_n_t_r_y.
    │ │ │ │  The updated set of trackers will be saved in the resume data, and when a
    │ │ │ │  torrent is started with resume data, the trackers from the resume data will
    │ │ │ │  replace the original ones.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** rreemmoovvee__uurrll__sseeeedd(()) uurrll__sseeeeddss(()) aadddd__uurrll__sseeeedd(()) **********
    │ │ │ │ -void rreemmoovvee__uurrll__sseeeedd (std::string const& url) const;
    │ │ │ │ +********** aadddd__uurrll__sseeeedd(()) uurrll__sseeeeddss(()) rreemmoovvee__uurrll__sseeeedd(()) **********
    │ │ │ │  void aadddd__uurrll__sseeeedd (std::string const& url) const;
    │ │ │ │ +void rreemmoovvee__uurrll__sseeeedd (std::string const& url) const;
    │ │ │ │  std::set uurrll__sseeeeddss () const;
    │ │ │ │  add_url_seed() adds another url to the torrent's list of url seeds. If the
    │ │ │ │  given url already exists in that list, the call has no effect. The torrent will
    │ │ │ │  connect to the server and try to download pieces from it, unless it's paused,
    │ │ │ │  queued, checking or seeding. remove_url_seed() removes the given url if it
    │ │ │ │  exists already. url_seeds() return a set of the url seeds currently in this
    │ │ │ │  torrent. Note that URLs that fails may be removed automatically from the list.
    │ │ │ │  See _h_t_t_p_ _s_e_e_d_i_n_g for more information.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** aadddd__hhttttpp__sseeeedd(()) rreemmoovvee__hhttttpp__sseeeedd(()) hhttttpp__sseeeeddss(()) **********
    │ │ │ │ -void aadddd__hhttttpp__sseeeedd (std::string const& url) const;
    │ │ │ │ +********** rreemmoovvee__hhttttpp__sseeeedd(()) aadddd__hhttttpp__sseeeedd(()) hhttttpp__sseeeeddss(()) **********
    │ │ │ │  std::set hhttttpp__sseeeeddss () const;
    │ │ │ │  void rreemmoovvee__hhttttpp__sseeeedd (std::string const& url) const;
    │ │ │ │ +void aadddd__hhttttpp__sseeeedd (std::string const& url) const;
    │ │ │ │  These functions are identical as the *_url_seed() variants, but they operate on
    │ │ │ │  _B_E_P_ _1_7 web seeds instead of _B_E_P_ _1_9.
    │ │ │ │  See _h_t_t_p_ _s_e_e_d_i_n_g for more information.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** aadddd__eexxtteennssiioonn(()) **********
    │ │ │ │  void aadddd__eexxtteennssiioonn (
    │ │ │ │        std::function(torrent_handle const&,
    │ │ │ │ @@ -556,18 +556,18 @@
    │ │ │ │  Note
    │ │ │ │  Torrents that are auto-managed may be automatically resumed again. It does not
    │ │ │ │  make sense to pause an auto-managed torrent without making it not auto-managed
    │ │ │ │  first. Torrents are auto-managed by default when added to the _s_e_s_s_i_o_n. For more
    │ │ │ │  information, see _q_u_e_u_i_n_g.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** uunnsseett__ffllaaggss(()) sseett__ffllaaggss(()) ffllaaggss(()) **********
    │ │ │ │ +void sseett__ffllaaggss (torrent_flags_t flags) const;
    │ │ │ │  void sseett__ffllaaggss (torrent_flags_t flags, torrent_flags_t mask) const;
    │ │ │ │  void uunnsseett__ffllaaggss (torrent_flags_t flags) const;
    │ │ │ │  torrent_flags_t ffllaaggss () const;
    │ │ │ │ -void sseett__ffllaaggss (torrent_flags_t flags) const;
    │ │ │ │  sets and gets the torrent state flags. See _t_o_r_r_e_n_t___f_l_a_g_s___t. The set_flags
    │ │ │ │  overload that take a mask will affect all flags part of the mask, and set their
    │ │ │ │  values to what the flags argument is set to. This allows clearing and setting
    │ │ │ │  flags in a single function call. The set_flags overload that just takes flags,
    │ │ │ │  sets all the specified flags and leave any other flags unchanged. unset_flags
    │ │ │ │  clears the specified flags, while leaving any other flags unchanged.
    │ │ │ │  Theseed_modeflag is special, it can only be cleared once the torrent has been
    │ │ │ │ @@ -591,16 +591,16 @@
    │ │ │ │  announcing to the tracker. The torrent will be added to the checking queue, and
    │ │ │ │  will be checked (all the files will be read and compared to the piece hashes).
    │ │ │ │  Once the check is complete, the torrent will start connecting to peers again,
    │ │ │ │  as normal. The torrent will be placed last in queue, i.e. its queue position
    │ │ │ │  will be the highest of all torrents in the _s_e_s_s_i_o_n.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ggeett__rreessuummee__ddaattaa(()) ssaavvee__rreessuummee__ddaattaa(()) **********
    │ │ │ │ -add_torrent_params ggeett__rreessuummee__ddaattaa (resume_data_flags_t flags = {}) const;
    │ │ │ │  void ssaavvee__rreessuummee__ddaattaa (resume_data_flags_t flags = {}) const;
    │ │ │ │ +add_torrent_params ggeett__rreessuummee__ddaattaa (resume_data_flags_t flags = {}) const;
    │ │ │ │  save_resume_data() and get_resume_data() asks libtorrent to generate fast-
    │ │ │ │  resume data for this torrent. The fast resume data (stored in an
    │ │ │ │  _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object) can be used to resume a torrent in the next _s_e_s_s_i_o_n
    │ │ │ │  without having to check all files for which pieces have been downloaded. It can
    │ │ │ │  also be used to save a .torrent file for a _t_o_r_r_e_n_t___h_a_n_d_l_e.
    │ │ │ │  `get_resume_data() is synchronous and will block the calling thread until the
    │ │ │ │  resume data is ready and returned from the libtorrent main thread. /
    │ │ │ │ @@ -678,35 +678,35 @@
    │ │ │ │  Note how outstanding_resume_data is a global counter in this example. This is
    │ │ │ │  deliberate, otherwise there is a race condition for torrents that was just
    │ │ │ │  asked to save their resume data, they posted the _a_l_e_r_t, but it has not been
    │ │ │ │  received yet. Those torrents would report that they don't need to save resume
    │ │ │ │  data again, and skipped by the initial loop, and thwart the counter otherwise.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** nneeeedd__ssaavvee__rreessuummee__ddaattaa(()) **********
    │ │ │ │ -bool nneeeedd__ssaavvee__rreessuummee__ddaattaa () const;
    │ │ │ │  bool nneeeedd__ssaavvee__rreessuummee__ddaattaa (resume_data_flags_t flags) const;
    │ │ │ │ +bool nneeeedd__ssaavvee__rreessuummee__ddaattaa () const;
    │ │ │ │  This function returns true if anything that is stored in the resume data has
    │ │ │ │  changed since the last time resume data was saved. The overload that takes
    │ │ │ │  flags let you ask if specific categories of properties have changed. These
    │ │ │ │  flags have the same behavior as in the _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) call.
    │ │ │ │  This is a bblloocckkiinngg call. It will wait for a response from libtorrent's main
    │ │ │ │  thread. A way to avoid blocking is to instead call _s_a_v_e___r_e_s_u_m_e___d_a_t_a_(_) directly,
    │ │ │ │  specifying the conditions under which resume data should be saved.
    │ │ │ │  Note
    │ │ │ │  A torrent's resume data is considered saved as soon as the
    │ │ │ │  _s_a_v_e___r_e_s_u_m_e___d_a_t_a___a_l_e_r_t is posted. It is important to make sure this _a_l_e_r_t is
    │ │ │ │  received and handled in order for this function to be meaningful.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** qquueeuuee__ppoossiittiioonn(()) qquueeuuee__ppoossiittiioonn__bboottttoomm(()) qquueeuuee__ppoossiittiioonn__ttoopp(())
    │ │ │ │ -qquueeuuee__ppoossiittiioonn__ddoowwnn(()) qquueeuuee__ppoossiittiioonn__uupp(()) **********
    │ │ │ │ -void qquueeuuee__ppoossiittiioonn__ddoowwnn () const;
    │ │ │ │ -void qquueeuuee__ppoossiittiioonn__uupp () const;
    │ │ │ │ -void qquueeuuee__ppoossiittiioonn__ttoopp () const;
    │ │ │ │ +********** qquueeuuee__ppoossiittiioonn__bboottttoomm(()) qquueeuuee__ppoossiittiioonn(()) qquueeuuee__ppoossiittiioonn__ddoowwnn(())
    │ │ │ │ +qquueeuuee__ppoossiittiioonn__ttoopp(()) qquueeuuee__ppoossiittiioonn__uupp(()) **********
    │ │ │ │  queue_position_t qquueeuuee__ppoossiittiioonn () const;
    │ │ │ │ +void qquueeuuee__ppoossiittiioonn__ttoopp () const;
    │ │ │ │  void qquueeuuee__ppoossiittiioonn__bboottttoomm () const;
    │ │ │ │ +void qquueeuuee__ppoossiittiioonn__uupp () const;
    │ │ │ │ +void qquueeuuee__ppoossiittiioonn__ddoowwnn () const;
    │ │ │ │  Every torrent that is added is assigned a queue position exactly one greater
    │ │ │ │  than the greatest queue position of all existing torrents. Torrents that are
    │ │ │ │  being seeded have -1 as their queue position, since they're no longer in line
    │ │ │ │  to be downloaded.
    │ │ │ │  When a torrent is removed or turns into a seed, all torrents with greater queue
    │ │ │ │  positions have their positions decreased to fill in the space in the sequence.
    │ │ │ │  queue_position() returns the torrent's position in the download queue. The
    │ │ │ │ @@ -749,15 +749,15 @@
    │ │ │ │  Note that when a torrent first starts up, and it needs a certificate, it will
    │ │ │ │  suspend connecting to any peers until it has one. It's typically desirable to
    │ │ │ │  resume the torrent after setting the SSL certificate.
    │ │ │ │  If you receive a _t_o_r_r_e_n_t___n_e_e_d___c_e_r_t___a_l_e_r_t, you need to call this to provide a
    │ │ │ │  valid cert. If you don't have a cert you won't be allowed to connect to any
    │ │ │ │  peers.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ttoorrrreenntt__ffiillee(()) ttoorrrreenntt__ffiillee__wwiitthh__hhaasshheess(()) **********
    │ │ │ │ +********** ttoorrrreenntt__ffiillee__wwiitthh__hhaasshheess(()) ttoorrrreenntt__ffiillee(()) **********
    │ │ │ │  std::shared_ptr ttoorrrreenntt__ffiillee__wwiitthh__hhaasshheess () const;
    │ │ │ │  std::shared_ptr ttoorrrreenntt__ffiillee () const;
    │ │ │ │  _t_o_r_r_e_n_t___f_i_l_e_(_) returns a pointer to the _t_o_r_r_e_n_t___i_n_f_o object associated with
    │ │ │ │  this torrent. The _t_o_r_r_e_n_t___i_n_f_o object may be a copy of the internal object. If
    │ │ │ │  the torrent doesn't have metadata, the pointer will not be initialized (i.e. a
    │ │ │ │  nullptr). The torrent may be in a state without metadata only if it was started
    │ │ │ │  without a .torrent file, e.g. by being added by magnet link.
    │ │ │ │ @@ -785,31 +785,31 @@
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ppiieeccee__llaayyeerrss(()) **********
    │ │ │ │  std::vector> ppiieeccee__llaayyeerrss () const;
    │ │ │ │  returns the piece layers for all files in the torrent. If this is a v1 torrent
    │ │ │ │  (and doesn't have any piece layers) it returns an empty vector. This is a
    │ │ │ │  blocking call that will synchronize with the libtorrent network thread.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ppiieeccee__aavvaaiillaabbiilliittyy(()) ppoosstt__ppiieeccee__aavvaaiillaabbiilliittyy(()) **********
    │ │ │ │ -void ppoosstt__ppiieeccee__aavvaaiillaabbiilliittyy () const;
    │ │ │ │ +********** ppoosstt__ppiieeccee__aavvaaiillaabbiilliittyy(()) ppiieeccee__aavvaaiillaabbiilliittyy(()) **********
    │ │ │ │  void ppiieeccee__aavvaaiillaabbiilliittyy (std::vector& avail) const;
    │ │ │ │ +void ppoosstt__ppiieeccee__aavvaaiillaabbiilliittyy () const;
    │ │ │ │  The piece availability is the number of peers that we are connected that has
    │ │ │ │  advertised having a particular piece. This is the information that libtorrent
    │ │ │ │  uses in order to prefer picking rare pieces.
    │ │ │ │  post_piece_availability() will trigger a _p_i_e_c_e___a_v_a_i_l_a_b_i_l_i_t_y___a_l_e_r_t to be posted.
    │ │ │ │  piece_availability() fills the specified std::vector with the availability
    │ │ │ │  for each piece in this torrent. libtorrent does not keep track of availability
    │ │ │ │  for seeds, so if the torrent is seeding the availability for all pieces is
    │ │ │ │  reported as 0.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ggeett__ppiieeccee__pprriioorriittiieess(()) ppiieeccee__pprriioorriittyy(()) pprriioorriittiizzee__ppiieecceess(()) **********
    │ │ │ │ +********** pprriioorriittiizzee__ppiieecceess(()) ggeett__ppiieeccee__pprriioorriittiieess(()) ppiieeccee__pprriioorriittyy(()) **********
    │ │ │ │ +void pprriioorriittiizzee__ppiieecceess (std::vector const& pieces) const;
    │ │ │ │  download_priority_t ppiieeccee__pprriioorriittyy (piece_index_t index) const;
    │ │ │ │ -std::vector ggeett__ppiieeccee__pprriioorriittiieess () const;
    │ │ │ │  void ppiieeccee__pprriioorriittyy (piece_index_t index, download_priority_t priority) const;
    │ │ │ │ -void pprriioorriittiizzee__ppiieecceess (std::vector const& pieces) const;
    │ │ │ │ +std::vector ggeett__ppiieeccee__pprriioorriittiieess () const;
    │ │ │ │  void pprriioorriittiizzee__ppiieecceess (std::vector> const& pieces) const;
    │ │ │ │  These functions are used to set and get the priority of individual pieces. By
    │ │ │ │  default all pieces have priority 4. That means that the random rarest first
    │ │ │ │  algorithm is effectively active for all pieces. You may however change the
    │ │ │ │  priority of individual pieces. There are 8 priority levels. 0 means not to
    │ │ │ │  download the piece at all. Otherwise, lower priority values means less likely
    │ │ │ │ @@ -832,18 +832,18 @@
    │ │ │ │  get_piece_priorities returns a vector with one element for each piece in the
    │ │ │ │  torrent. Each element is the current priority of that piece.
    │ │ │ │  It's possible to cancel the effect of ffiillee priorities by setting the priorities
    │ │ │ │  for the affected pieces. Care has to be taken when mixing usage of file- and
    │ │ │ │  piece priorities.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ggeett__ffiillee__pprriioorriittiieess(()) ffiillee__pprriioorriittyy(()) pprriioorriittiizzee__ffiilleess(()) **********
    │ │ │ │ -std::vector ggeett__ffiillee__pprriioorriittiieess () const;
    │ │ │ │ -download_priority_t ffiillee__pprriioorriittyy (file_index_t index) const;
    │ │ │ │  void pprriioorriittiizzee__ffiilleess (std::vector const& files) const;
    │ │ │ │  void ffiillee__pprriioorriittyy (file_index_t index, download_priority_t priority) const;
    │ │ │ │ +std::vector ggeett__ffiillee__pprriioorriittiieess () const;
    │ │ │ │ +download_priority_t ffiillee__pprriioorriittyy (file_index_t index) const;
    │ │ │ │  index must be in the range [0, number_of_files).
    │ │ │ │  file_priority() queries or sets the priority of file index.
    │ │ │ │  prioritize_files() takes a vector that has at as many elements as there are
    │ │ │ │  files in the torrent. Each _e_n_t_r_y is the priority of that file. The function
    │ │ │ │  sets the priorities of all the pieces in the torrent based on the vector.
    │ │ │ │  get_file_priorities() returns a vector with the priorities of all files.
    │ │ │ │  The priority values are the same as for _p_i_e_c_e___p_r_i_o_r_i_t_y_(_). See
    │ │ │ │ @@ -862,17 +862,17 @@
    │ │ │ │  When combining file- and piece priorities, the resume file will record both.
    │ │ │ │  When loading the resume data, the file priorities will be applied first, then
    │ │ │ │  the piece priorities.
    │ │ │ │  Moving data from a file into the part file is currently not supported. If a
    │ │ │ │  file has its priority set to 0 aafftteerr it has already been created, it will not
    │ │ │ │  be moved into the partfile.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ffoorrccee__rreeaannnnoouunnccee(()) ffoorrccee__ddhhtt__aannnnoouunnccee(()) ffoorrccee__llssdd__aannnnoouunnccee(()) **********
    │ │ │ │ -void ffoorrccee__llssdd__aannnnoouunnccee () const;
    │ │ │ │ +********** ffoorrccee__ddhhtt__aannnnoouunnccee(()) ffoorrccee__rreeaannnnoouunnccee(()) ffoorrccee__llssdd__aannnnoouunnccee(()) **********
    │ │ │ │  void ffoorrccee__ddhhtt__aannnnoouunnccee () const;
    │ │ │ │ +void ffoorrccee__llssdd__aannnnoouunnccee () const;
    │ │ │ │  void ffoorrccee__rreeaannnnoouunnccee (int seconds = 0, int idx = -1, reannounce_flags_t = {})
    │ │ │ │  const;
    │ │ │ │  force_reannounce() will force this torrent to do another tracker request, to
    │ │ │ │  receive new peers. The seconds argument specifies how many seconds from now to
    │ │ │ │  issue the tracker announces.
    │ │ │ │  If the tracker's min_interval has not passed since the last announce, the
    │ │ │ │  forced announce will be scheduled to happen immediately as the min_interval
    │ │ │ │ @@ -892,20 +892,20 @@
    │ │ │ │  A scrape request queries the tracker for statistics such as total number of
    │ │ │ │  incomplete peers, complete peers, number of downloads etc.
    │ │ │ │  This request will specifically update the num_complete and num_incomplete
    │ │ │ │  fields in the _t_o_r_r_e_n_t___s_t_a_t_u_s struct once it completes. When it completes, it
    │ │ │ │  will generate a _s_c_r_a_p_e___r_e_p_l_y___a_l_e_r_t. If it fails, it will generate a
    │ │ │ │  _s_c_r_a_p_e___f_a_i_l_e_d___a_l_e_r_t.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** sseett__uuppllooaadd__lliimmiitt(()) sseett__ddoowwnnllooaadd__lliimmiitt(()) ddoowwnnllooaadd__lliimmiitt(()) uuppllooaadd__lliimmiitt(())
    │ │ │ │ +********** sseett__uuppllooaadd__lliimmiitt(()) sseett__ddoowwnnllooaadd__lliimmiitt(()) uuppllooaadd__lliimmiitt(()) ddoowwnnllooaadd__lliimmiitt(())
    │ │ │ │  **********
    │ │ │ │ -void sseett__ddoowwnnllooaadd__lliimmiitt (int limit) const;
    │ │ │ │ -void sseett__uuppllooaadd__lliimmiitt (int limit) const;
    │ │ │ │  int uuppllooaadd__lliimmiitt () const;
    │ │ │ │ +void sseett__ddoowwnnllooaadd__lliimmiitt (int limit) const;
    │ │ │ │  int ddoowwnnllooaadd__lliimmiitt () const;
    │ │ │ │ +void sseett__uuppllooaadd__lliimmiitt (int limit) const;
    │ │ │ │  set_upload_limit will limit the upload bandwidth used by this particular
    │ │ │ │  torrent to the limit you set. It is given as the number of bytes per second the
    │ │ │ │  torrent is allowed to upload. set_download_limit works the same way but for
    │ │ │ │  download bandwidth instead of upload bandwidth. Note that setting a higher
    │ │ │ │  limit on a torrent then the global limit (settings_pack::upload_rate_limit)
    │ │ │ │  will not override the global rate limit. The torrent can never upload more than
    │ │ │ │  the global rate limit.
    │ │ │ │ @@ -929,16 +929,16 @@
    │ │ │ │  ********** cclleeaarr__ppeeeerrss(()) **********
    │ │ │ │  void cclleeaarr__ppeeeerrss ();
    │ │ │ │  This will disconnect all peers and clear the peer list for this torrent. New
    │ │ │ │  peers will have to be acquired before resuming, from trackers, DHT or local
    │ │ │ │  service discovery, for example.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** mmaaxx__uuppllooaaddss(()) sseett__mmaaxx__uuppllooaaddss(()) **********
    │ │ │ │ -int mmaaxx__uuppllooaaddss () const;
    │ │ │ │  void sseett__mmaaxx__uuppllooaaddss (int max_uploads) const;
    │ │ │ │ +int mmaaxx__uuppllooaaddss () const;
    │ │ │ │  set_max_uploads() sets the maximum number of peers that's unchoked at the same
    │ │ │ │  time on this torrent. If you set this to -1, there will be no limit. This
    │ │ │ │  defaults to infinite. The primary setting controlling this is the global
    │ │ │ │  unchoke slots limit, set by unchoke_slots_limit in _s_e_t_t_i_n_g_s___p_a_c_k.
    │ │ │ │  max_uploads() returns the current settings.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** sseett__mmaaxx__ccoonnnneeccttiioonnss(()) mmaaxx__ccoonnnneeccttiioonnss(()) **********
    │ │ │ │ @@ -997,27 +997,27 @@
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** rreennaammee__ffiillee(()) **********
    │ │ │ │  void rreennaammee__ffiillee (file_index_t index, std::string const& new_name) const;
    │ │ │ │  Renames the file with the given index asynchronously. The rename operation is
    │ │ │ │  complete when either a _f_i_l_e___r_e_n_a_m_e_d___a_l_e_r_t or _f_i_l_e___r_e_n_a_m_e___f_a_i_l_e_d___a_l_e_r_t is
    │ │ │ │  posted.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** iinnffoo__hhaasshh(()) iinnffoo__hhaasshheess(()) **********
    │ │ │ │ -info_hash_t iinnffoo__hhaasshheess () const;
    │ │ │ │ +********** iinnffoo__hhaasshheess(()) iinnffoo__hhaasshh(()) **********
    │ │ │ │  sha1_hash iinnffoo__hhaasshh () const;
    │ │ │ │ +info_hash_t iinnffoo__hhaasshheess () const;
    │ │ │ │  returns the info-hash(es) of the torrent. If this handle is to a torrent that
    │ │ │ │  hasn't loaded yet (for instance by being added) by a URL, the returned value is
    │ │ │ │  undefined. The info_hash() returns the SHA-1 info-hash for v1 torrents and a
    │ │ │ │  truncated hash for v2 torrents. For the full v2 info-hash, use info_hashes()
    │ │ │ │  instead.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ooppeerraattoorr<<(()) ooppeerraattoorr====(()) ooppeerraattoorr!!==(()) **********
    │ │ │ │ +********** ooppeerraattoorr====(()) ooppeerraattoorr!!==(()) ooppeerraattoorr<<(()) **********
    │ │ │ │  bool ooppeerraattoorr==== (const torrent_handle& h) const;
    │ │ │ │ -bool ooppeerraattoorr!!== (const torrent_handle& h) const;
    │ │ │ │  bool ooppeerraattoorr<< (const torrent_handle& h) const;
    │ │ │ │ +bool ooppeerraattoorr!!== (const torrent_handle& h) const;
    │ │ │ │  comparison operators. The order of the torrents is unspecified but stable.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** iidd(()) **********
    │ │ │ │  std::uint32_t iidd () const;
    │ │ │ │  returns a unique identifier for this torrent. It's not a dense index. It's not
    │ │ │ │  preserved across sessions.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Info.html
    │ │ │ @@ -41,23 +41,23 @@
    │ │ │  
  • load_torrent_limits
  • │ │ │
  • torrent_info
      │ │ │
    • torrent_info()
    • │ │ │
    • ~torrent_info()
    • │ │ │
    • files() orig_files()
    • │ │ │
    • rename_file()
    • │ │ │
    • remap_files()
    • │ │ │ -
    • add_tracker() clear_trackers() trackers()
    • │ │ │ -
    • collections() similar_torrents()
    • │ │ │ -
    • add_http_seed() set_web_seeds() web_seeds() add_url_seed()
    • │ │ │ +
    • trackers() clear_trackers() add_tracker()
    • │ │ │ +
    • similar_torrents() collections()
    • │ │ │ +
    • add_url_seed() add_http_seed() set_web_seeds() web_seeds()
    • │ │ │
    • total_size()
    • │ │ │
    • num_pieces() piece_length()
    • │ │ │
    • blocks_per_piece()
    • │ │ │ -
    • piece_range() end_piece() last_piece()
    • │ │ │ -
    • info_hash() info_hashes()
    • │ │ │ -
    • v2() v1()
    • │ │ │ +
    • end_piece() piece_range() last_piece()
    • │ │ │ +
    • info_hashes() info_hash()
    • │ │ │ +
    • v1() v2()
    • │ │ │
    • num_files()
    • │ │ │
    • map_block()
    • │ │ │
    • map_file()
    • │ │ │
    • ssl_cert()
    • │ │ │
    • is_valid()
    • │ │ │
    • priv()
    • │ │ │
    • is_i2p()
    • │ │ │ @@ -212,57 +212,57 @@ │ │ │

      torrent_info

      │ │ │

      Declared in "libtorrent/torrent_info.hpp"

      │ │ │

      the torrent_info class holds the information found in a .torrent file.

      │ │ │
      │ │ │  class torrent_info
      │ │ │  {
      │ │ │     explicit torrent_info (bdecode_node const& torrent_file);
      │ │ │ -   torrent_info (std::string const& filename, load_torrent_limits const& cfg);
      │ │ │ +   explicit torrent_info (std::string const& filename);
      │ │ │     torrent_info (bdecode_node const& torrent_file, load_torrent_limits const& cfg);
      │ │ │ -   torrent_info (torrent_info const& t);
      │ │ │ -   torrent_info (char const* buffer, int size, error_code& ec);
      │ │ │ -   torrent_info (span<char const> buffer, load_torrent_limits const& cfg, from_span_t);
      │ │ │ -   torrent_info (std::string const& filename, error_code& ec);
      │ │ │ -   torrent_info (char const* buffer, int size);
      │ │ │     torrent_info (bdecode_node const& torrent_file, error_code& ec);
      │ │ │ -   torrent_info (span<char const> buffer, error_code& ec, from_span_t);
      │ │ │ -   explicit torrent_info (info_hash_t const& info_hash);
      │ │ │ -   explicit torrent_info (std::string const& filename);
      │ │ │ +   torrent_info (std::string const& filename, load_torrent_limits const& cfg);
      │ │ │ +   torrent_info (std::string const& filename, error_code& ec);
      │ │ │     explicit torrent_info (span<char const> buffer, from_span_t);
      │ │ │ +   explicit torrent_info (info_hash_t const& info_hash);
      │ │ │ +   torrent_info (span<char const> buffer, load_torrent_limits const& cfg, from_span_t);
      │ │ │ +   torrent_info (span<char const> buffer, error_code& ec, from_span_t);
      │ │ │ +   torrent_info (char const* buffer, int size);
      │ │ │ +   torrent_info (torrent_info const& t);
      │ │ │ +   torrent_info (char const* buffer, int size, error_code& ec);
      │ │ │     ~torrent_info ();
      │ │ │ -   file_storage const& files () const;
      │ │ │     file_storage const& orig_files () const;
      │ │ │ +   file_storage const& files () const;
      │ │ │     void rename_file (file_index_t index, std::string const& new_filename);
      │ │ │     void remap_files (file_storage const& f);
      │ │ │ +   void add_tracker (std::string const& url, int tier = 0);
      │ │ │     void clear_trackers ();
      │ │ │     std::vector<announce_entry> const& trackers () const;
      │ │ │ -   void add_tracker (std::string const& url, int tier = 0);
      │ │ │     void add_tracker (std::string const& url, int tier
      │ │ │        , announce_entry::tracker_source source);
      │ │ │     std::vector<std::string> collections () const;
      │ │ │     std::vector<sha1_hash> similar_torrents () const;
      │ │ │ -   void add_http_seed (std::string const& url
      │ │ │ -      , std::string const& extern_auth = std::string()
      │ │ │ -      , web_seed_entry::headers_t const& extra_headers = web_seed_entry::headers_t());
      │ │ │ -   void set_web_seeds (std::vector<web_seed_entry> seeds);
      │ │ │     std::vector<web_seed_entry> const& web_seeds () const;
      │ │ │ +   void set_web_seeds (std::vector<web_seed_entry> seeds);
      │ │ │     void add_url_seed (std::string const& url
      │ │ │        , std::string const& extern_auth = std::string()
      │ │ │        , web_seed_entry::headers_t const& ext_headers = web_seed_entry::headers_t());
      │ │ │ +   void add_http_seed (std::string const& url
      │ │ │ +      , std::string const& extern_auth = std::string()
      │ │ │ +      , web_seed_entry::headers_t const& extra_headers = web_seed_entry::headers_t());
      │ │ │     std::int64_t total_size () const;
      │ │ │     int num_pieces () const;
      │ │ │     int piece_length () const;
      │ │ │     int blocks_per_piece () const;
      │ │ │ +   index_range<piece_index_t> piece_range () const;
      │ │ │     piece_index_t last_piece () const;
      │ │ │     piece_index_t end_piece () const;
      │ │ │ -   index_range<piece_index_t> piece_range () const;
      │ │ │     sha1_hash info_hash () const noexcept;
      │ │ │     info_hash_t const& info_hashes () const;
      │ │ │ -   bool v1 () const;
      │ │ │     bool v2 () const;
      │ │ │ +   bool v1 () const;
      │ │ │     int num_files () const;
      │ │ │     std::vector<file_slice> map_block (piece_index_t const piece
      │ │ │        , std::int64_t offset, int size) const;
      │ │ │     peer_request map_file (file_index_t const file, std::int64_t offset, int size) const;
      │ │ │     string_view ssl_cert () const;
      │ │ │     bool is_valid () const;
      │ │ │     bool priv () const;
      │ │ │ @@ -285,26 +285,26 @@
      │ │ │     void free_piece_layers ();
      │ │ │  };
      │ │ │  
      │ │ │ [report issue]
      │ │ │

      torrent_info()

      │ │ │
      │ │ │  explicit torrent_info (bdecode_node const& torrent_file);
      │ │ │ -torrent_info (std::string const& filename, load_torrent_limits const& cfg);
      │ │ │ +explicit torrent_info (std::string const& filename);
      │ │ │  torrent_info (bdecode_node const& torrent_file, load_torrent_limits const& cfg);
      │ │ │ -torrent_info (torrent_info const& t);
      │ │ │ -torrent_info (char const* buffer, int size, error_code& ec);
      │ │ │ -torrent_info (span<char const> buffer, load_torrent_limits const& cfg, from_span_t);
      │ │ │ -torrent_info (std::string const& filename, error_code& ec);
      │ │ │ -torrent_info (char const* buffer, int size);
      │ │ │  torrent_info (bdecode_node const& torrent_file, error_code& ec);
      │ │ │ -torrent_info (span<char const> buffer, error_code& ec, from_span_t);
      │ │ │ -explicit torrent_info (info_hash_t const& info_hash);
      │ │ │ -explicit torrent_info (std::string const& filename);
      │ │ │ +torrent_info (std::string const& filename, load_torrent_limits const& cfg);
      │ │ │ +torrent_info (std::string const& filename, error_code& ec);
      │ │ │  explicit torrent_info (span<char const> buffer, from_span_t);
      │ │ │ +explicit torrent_info (info_hash_t const& info_hash);
      │ │ │ +torrent_info (span<char const> buffer, load_torrent_limits const& cfg, from_span_t);
      │ │ │ +torrent_info (span<char const> buffer, error_code& ec, from_span_t);
      │ │ │ +torrent_info (char const* buffer, int size);
      │ │ │ +torrent_info (torrent_info const& t);
      │ │ │ +torrent_info (char const* buffer, int size, error_code& ec);
      │ │ │  
      │ │ │

      The constructor that takes an info-hash will initialize the info-hash │ │ │ to the given value, but leave all other fields empty. This is used │ │ │ internally when downloading torrents without the metadata. The │ │ │ metadata will be created by libtorrent as soon as it has been │ │ │ downloaded from the swarm.

      │ │ │

      The constructor that takes a bdecode_node will create a torrent_info │ │ │ @@ -338,16 +338,16 @@ │ │ │

  • │ │ │

    frees all storage associated with this torrent_info object

    │ │ │ │ │ │ [report issue]
    │ │ │
    │ │ │

    files() orig_files()

    │ │ │
    │ │ │ -file_storage const& files () const;
    │ │ │  file_storage const& orig_files () const;
    │ │ │ +file_storage const& files () const;
    │ │ │  
    │ │ │

    The file_storage object contains the information on how to map the │ │ │ pieces to files. It is separated from the torrent_info object because │ │ │ when creating torrents a storage object needs to be created without │ │ │ having a torrent file. When renaming files in a storage, the storage │ │ │ needs to make its own copy of the file_storage in order to make its │ │ │ mapping differ from the one in the torrent file.

    │ │ │ @@ -391,64 +391,64 @@ │ │ │
    │ │ │

    Remaps the file storage to a new file layout. This can be used to, for │ │ │ instance, download all data in a torrent to a single file, or to a │ │ │ number of fixed size sector aligned files, regardless of the number │ │ │ and sizes of the files in the torrent.

    │ │ │

    The new specified file_storage must have the exact same size as │ │ │ the current one.

    │ │ │ - │ │ │ + │ │ │ │ │ │ -[report issue] │ │ │ -
    │ │ │ -

    add_tracker() clear_trackers() trackers()

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    trackers() clear_trackers() add_tracker()

    │ │ │
    │ │ │ +void add_tracker (std::string const& url, int tier = 0);
    │ │ │  void clear_trackers ();
    │ │ │  std::vector<announce_entry> const& trackers () const;
    │ │ │ -void add_tracker (std::string const& url, int tier = 0);
    │ │ │  void add_tracker (std::string const& url, int tier
    │ │ │        , announce_entry::tracker_source source);
    │ │ │  
    │ │ │

    add_tracker() adds a tracker to the announce-list. The tier │ │ │ determines the order in which the trackers are to be tried. │ │ │ The trackers() function will return a sorted vector of │ │ │ announce_entry. Each announce entry contains a string, which is │ │ │ the tracker url, and a tier index. The tier index is the high-level │ │ │ priority. No matter which trackers that works or not, the ones with │ │ │ lower tier will always be tried before the one with higher tier │ │ │ number. For more information, see announce_entry.

    │ │ │

    trackers() returns all entries from announce-list.

    │ │ │

    clear_trackers() removes all trackers from announce-list.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    collections() similar_torrents()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    similar_torrents() collections()

    │ │ │
    │ │ │  std::vector<std::string> collections () const;
    │ │ │  std::vector<sha1_hash> similar_torrents () const;
    │ │ │  
    │ │ │

    These two functions are related to BEP 38 (mutable torrents). The │ │ │ vectors returned from these correspond to the "similar" and │ │ │ "collections" keys in the .torrent file. Both info-hashes and │ │ │ collections from within the info-dict and from outside of it are │ │ │ included.

    │ │ │ + │ │ │ │ │ │ │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    add_http_seed() set_web_seeds() web_seeds() add_url_seed()

    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    add_url_seed() add_http_seed() set_web_seeds() web_seeds()

    │ │ │
    │ │ │ -void add_http_seed (std::string const& url
    │ │ │ -      , std::string const& extern_auth = std::string()
    │ │ │ -      , web_seed_entry::headers_t const& extra_headers = web_seed_entry::headers_t());
    │ │ │ -void set_web_seeds (std::vector<web_seed_entry> seeds);
    │ │ │  std::vector<web_seed_entry> const& web_seeds () const;
    │ │ │ +void set_web_seeds (std::vector<web_seed_entry> seeds);
    │ │ │  void add_url_seed (std::string const& url
    │ │ │        , std::string const& extern_auth = std::string()
    │ │ │        , web_seed_entry::headers_t const& ext_headers = web_seed_entry::headers_t());
    │ │ │ +void add_http_seed (std::string const& url
    │ │ │ +      , std::string const& extern_auth = std::string()
    │ │ │ +      , web_seed_entry::headers_t const& extra_headers = web_seed_entry::headers_t());
    │ │ │  
    │ │ │

    web_seeds() returns all url seeds and http seeds in the torrent. │ │ │ Each entry is a web_seed_entry and may refer to either a url seed │ │ │ or http seed.

    │ │ │

    add_url_seed() and add_http_seed() adds one url to the list of │ │ │ url/http seeds.

    │ │ │

    set_web_seeds() replaces all web seeds with the ones specified in │ │ │ @@ -494,48 +494,48 @@ │ │ │

    │ │ │

    blocks_per_piece()

    │ │ │
    │ │ │  int blocks_per_piece () const;
    │ │ │  
    │ │ │

    returns the number of blocks there are in the typical piece. There │ │ │ may be fewer in the last piece)

    │ │ │ - │ │ │ │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    piece_range() end_piece() last_piece()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    end_piece() piece_range() last_piece()

    │ │ │
    │ │ │ +index_range<piece_index_t> piece_range () const;
    │ │ │  piece_index_t last_piece () const;
    │ │ │  piece_index_t end_piece () const;
    │ │ │ -index_range<piece_index_t> piece_range () const;
    │ │ │  
    │ │ │

    last_piece() returns the index to the last piece in the torrent and │ │ │ end_piece() returns the index to the one-past-end piece in the │ │ │ torrent │ │ │ piece_range() returns an implementation-defined type that can be │ │ │ used as the container in a range-for loop. Where the values are the │ │ │ indices of all pieces in the file_storage.

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    info_hash() info_hashes()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    info_hashes() info_hash()

    │ │ │
    │ │ │  sha1_hash info_hash () const noexcept;
    │ │ │  info_hash_t const& info_hashes () const;
    │ │ │  
    │ │ │

    returns the info-hash of the torrent. For BitTorrent v2 support, use │ │ │ info_hashes() to get an object that may hold both a v1 and v2 │ │ │ info-hash

    │ │ │ - │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    v2() v1()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    v1() v2()

    │ │ │
    │ │ │ -bool v1 () const;
    │ │ │  bool v2 () const;
    │ │ │ +bool v1 () const;
    │ │ │  
    │ │ │

    returns whether this torrent has v1 and/or v2 metadata, respectively. │ │ │ Hybrid torrents have both. These are shortcuts for │ │ │ info_hashes().has_v1() and info_hashes().has_v2() calls.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    num_files()

    │ │ │ @@ -606,15 +606,15 @@ │ │ │ to peers over anything other than the i2p network.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    piece_size()

    │ │ │
    │ │ │  int piece_size (piece_index_t index) const;
    │ │ │  
    │ │ │ -

    returns the piece size of file with index. This will be the same as piece_length(), │ │ │ +

    returns the piece size of file with index. This will be the same as piece_length(), │ │ │ except for the last piece, which may be shorter.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    piece_size_for_req()

    │ │ │
    │ │ │  int piece_size_for_req (piece_index_t index) const;
    │ │ │  
    │ │ │ ├── html2text {} │ │ │ │ @@ -10,23 +10,23 @@ │ │ │ │ * _l_o_a_d___t_o_r_r_e_n_t___l_i_m_i_t_s │ │ │ │ * _t_o_r_r_e_n_t___i_n_f_o │ │ │ │ o _t_o_r_r_e_n_t___i_n_f_o_(_) │ │ │ │ o _~_t_o_r_r_e_n_t___i_n_f_o_(_) │ │ │ │ o _f_i_l_e_s_(_)_ _o_r_i_g___f_i_l_e_s_(_) │ │ │ │ o _r_e_n_a_m_e___f_i_l_e_(_) │ │ │ │ o _r_e_m_a_p___f_i_l_e_s_(_) │ │ │ │ - o _a_d_d___t_r_a_c_k_e_r_(_)_ _c_l_e_a_r___t_r_a_c_k_e_r_s_(_)_ _t_r_a_c_k_e_r_s_(_) │ │ │ │ - o _c_o_l_l_e_c_t_i_o_n_s_(_)_ _s_i_m_i_l_a_r___t_o_r_r_e_n_t_s_(_) │ │ │ │ - o _a_d_d___h_t_t_p___s_e_e_d_(_)_ _s_e_t___w_e_b___s_e_e_d_s_(_)_ _w_e_b___s_e_e_d_s_(_)_ _a_d_d___u_r_l___s_e_e_d_(_) │ │ │ │ + o _t_r_a_c_k_e_r_s_(_)_ _c_l_e_a_r___t_r_a_c_k_e_r_s_(_)_ _a_d_d___t_r_a_c_k_e_r_(_) │ │ │ │ + o _s_i_m_i_l_a_r___t_o_r_r_e_n_t_s_(_)_ _c_o_l_l_e_c_t_i_o_n_s_(_) │ │ │ │ + o _a_d_d___u_r_l___s_e_e_d_(_)_ _a_d_d___h_t_t_p___s_e_e_d_(_)_ _s_e_t___w_e_b___s_e_e_d_s_(_)_ _w_e_b___s_e_e_d_s_(_) │ │ │ │ o _t_o_t_a_l___s_i_z_e_(_) │ │ │ │ o _n_u_m___p_i_e_c_e_s_(_)_ _p_i_e_c_e___l_e_n_g_t_h_(_) │ │ │ │ o _b_l_o_c_k_s___p_e_r___p_i_e_c_e_(_) │ │ │ │ - o _p_i_e_c_e___r_a_n_g_e_(_)_ _e_n_d___p_i_e_c_e_(_)_ _l_a_s_t___p_i_e_c_e_(_) │ │ │ │ - o _i_n_f_o___h_a_s_h_(_)_ _i_n_f_o___h_a_s_h_e_s_(_) │ │ │ │ - o _v_2_(_)_ _v_1_(_) │ │ │ │ + o _e_n_d___p_i_e_c_e_(_)_ _p_i_e_c_e___r_a_n_g_e_(_)_ _l_a_s_t___p_i_e_c_e_(_) │ │ │ │ + o _i_n_f_o___h_a_s_h_e_s_(_)_ _i_n_f_o___h_a_s_h_(_) │ │ │ │ + o _v_1_(_)_ _v_2_(_) │ │ │ │ o _n_u_m___f_i_l_e_s_(_) │ │ │ │ o _m_a_p___b_l_o_c_k_(_) │ │ │ │ o _m_a_p___f_i_l_e_(_) │ │ │ │ o _s_s_l___c_e_r_t_(_) │ │ │ │ o _i_s___v_a_l_i_d_(_) │ │ │ │ o _p_r_i_v_(_) │ │ │ │ o _i_s___i_2_p_(_) │ │ │ │ @@ -133,61 +133,61 @@ │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ttoorrrreenntt__iinnffoo ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_o_r_r_e_n_t___i_n_f_o_._h_p_p" │ │ │ │ the _t_o_r_r_e_n_t___i_n_f_o class holds the information found in a .torrent file. │ │ │ │ class torrent_info │ │ │ │ { │ │ │ │ explicit ttoorrrreenntt__iinnffoo (bdecode_node const& torrent_file); │ │ │ │ - ttoorrrreenntt__iinnffoo (std::string const& filename, load_torrent_limits const& cfg); │ │ │ │ + explicit ttoorrrreenntt__iinnffoo (std::string const& filename); │ │ │ │ ttoorrrreenntt__iinnffoo (bdecode_node const& torrent_file, load_torrent_limits const& │ │ │ │ cfg); │ │ │ │ - ttoorrrreenntt__iinnffoo (torrent_info const& t); │ │ │ │ - ttoorrrreenntt__iinnffoo (char const* buffer, int size, error_code& ec); │ │ │ │ + ttoorrrreenntt__iinnffoo (bdecode_node const& torrent_file, error_code& ec); │ │ │ │ + ttoorrrreenntt__iinnffoo (std::string const& filename, load_torrent_limits const& cfg); │ │ │ │ + ttoorrrreenntt__iinnffoo (std::string const& filename, error_code& ec); │ │ │ │ + explicit ttoorrrreenntt__iinnffoo (span buffer, from_span_t); │ │ │ │ + explicit ttoorrrreenntt__iinnffoo (info_hash_t const& info_hash); │ │ │ │ ttoorrrreenntt__iinnffoo (span buffer, load_torrent_limits const& cfg, │ │ │ │ from_span_t); │ │ │ │ - ttoorrrreenntt__iinnffoo (std::string const& filename, error_code& ec); │ │ │ │ - ttoorrrreenntt__iinnffoo (char const* buffer, int size); │ │ │ │ - ttoorrrreenntt__iinnffoo (bdecode_node const& torrent_file, error_code& ec); │ │ │ │ ttoorrrreenntt__iinnffoo (span buffer, error_code& ec, from_span_t); │ │ │ │ - explicit ttoorrrreenntt__iinnffoo (info_hash_t const& info_hash); │ │ │ │ - explicit ttoorrrreenntt__iinnffoo (std::string const& filename); │ │ │ │ - explicit ttoorrrreenntt__iinnffoo (span buffer, from_span_t); │ │ │ │ + ttoorrrreenntt__iinnffoo (char const* buffer, int size); │ │ │ │ + ttoorrrreenntt__iinnffoo (torrent_info const& t); │ │ │ │ + ttoorrrreenntt__iinnffoo (char const* buffer, int size, error_code& ec); │ │ │ │ ~~ttoorrrreenntt__iinnffoo (); │ │ │ │ - file_storage const& ffiilleess () const; │ │ │ │ file_storage const& oorriigg__ffiilleess () const; │ │ │ │ + file_storage const& ffiilleess () const; │ │ │ │ void rreennaammee__ffiillee (file_index_t index, std::string const& new_filename); │ │ │ │ void rreemmaapp__ffiilleess (file_storage const& f); │ │ │ │ + void aadddd__ttrraacckkeerr (std::string const& url, int tier = 0); │ │ │ │ void cclleeaarr__ttrraacckkeerrss (); │ │ │ │ std::vector const& ttrraacckkeerrss () const; │ │ │ │ - void aadddd__ttrraacckkeerr (std::string const& url, int tier = 0); │ │ │ │ void aadddd__ttrraacckkeerr (std::string const& url, int tier │ │ │ │ , announce_entry::tracker_source source); │ │ │ │ std::vector ccoolllleeccttiioonnss () const; │ │ │ │ std::vector ssiimmiillaarr__ttoorrrreennttss () const; │ │ │ │ - void aadddd__hhttttpp__sseeeedd (std::string const& url │ │ │ │ - , std::string const& extern_auth = std::string() │ │ │ │ - , web_seed_entry::headers_t const& extra_headers = web_seed_entry:: │ │ │ │ -headers_t()); │ │ │ │ - void sseett__wweebb__sseeeeddss (std::vector seeds); │ │ │ │ std::vector const& wweebb__sseeeeddss () const; │ │ │ │ + void sseett__wweebb__sseeeeddss (std::vector seeds); │ │ │ │ void aadddd__uurrll__sseeeedd (std::string const& url │ │ │ │ , std::string const& extern_auth = std::string() │ │ │ │ , web_seed_entry::headers_t const& ext_headers = web_seed_entry:: │ │ │ │ headers_t()); │ │ │ │ + void aadddd__hhttttpp__sseeeedd (std::string const& url │ │ │ │ + , std::string const& extern_auth = std::string() │ │ │ │ + , web_seed_entry::headers_t const& extra_headers = web_seed_entry:: │ │ │ │ +headers_t()); │ │ │ │ std::int64_t ttoottaall__ssiizzee () const; │ │ │ │ int nnuumm__ppiieecceess () const; │ │ │ │ int ppiieeccee__lleennggtthh () const; │ │ │ │ int bblloocckkss__ppeerr__ppiieeccee () const; │ │ │ │ + index_range ppiieeccee__rraannggee () const; │ │ │ │ piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ piece_index_t eenndd__ppiieeccee () const; │ │ │ │ - index_range ppiieeccee__rraannggee () const; │ │ │ │ sha1_hash iinnffoo__hhaasshh () const noexcept; │ │ │ │ info_hash_t const& iinnffoo__hhaasshheess () const; │ │ │ │ - bool vv11 () const; │ │ │ │ bool vv22 () const; │ │ │ │ + bool vv11 () const; │ │ │ │ int nnuumm__ffiilleess () const; │ │ │ │ std::vector mmaapp__bblloocckk (piece_index_t const piece │ │ │ │ , std::int64_t offset, int size) const; │ │ │ │ peer_request mmaapp__ffiillee (file_index_t const file, std::int64_t offset, int │ │ │ │ size) const; │ │ │ │ string_view ssssll__cceerrtt () const; │ │ │ │ bool iiss__vvaalliidd () const; │ │ │ │ @@ -210,28 +210,28 @@ │ │ │ │ span iinnffoo__sseeccttiioonn () const; │ │ │ │ span ppiieeccee__llaayyeerr (file_index_t) const; │ │ │ │ void ffrreeee__ppiieeccee__llaayyeerrss (); │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ttoorrrreenntt__iinnffoo(()) ********** │ │ │ │ explicit ttoorrrreenntt__iinnffoo (bdecode_node const& torrent_file); │ │ │ │ -ttoorrrreenntt__iinnffoo (std::string const& filename, load_torrent_limits const& cfg); │ │ │ │ +explicit ttoorrrreenntt__iinnffoo (std::string const& filename); │ │ │ │ ttoorrrreenntt__iinnffoo (bdecode_node const& torrent_file, load_torrent_limits const& │ │ │ │ cfg); │ │ │ │ -ttoorrrreenntt__iinnffoo (torrent_info const& t); │ │ │ │ -ttoorrrreenntt__iinnffoo (char const* buffer, int size, error_code& ec); │ │ │ │ +ttoorrrreenntt__iinnffoo (bdecode_node const& torrent_file, error_code& ec); │ │ │ │ +ttoorrrreenntt__iinnffoo (std::string const& filename, load_torrent_limits const& cfg); │ │ │ │ +ttoorrrreenntt__iinnffoo (std::string const& filename, error_code& ec); │ │ │ │ +explicit ttoorrrreenntt__iinnffoo (span buffer, from_span_t); │ │ │ │ +explicit ttoorrrreenntt__iinnffoo (info_hash_t const& info_hash); │ │ │ │ ttoorrrreenntt__iinnffoo (span buffer, load_torrent_limits const& cfg, │ │ │ │ from_span_t); │ │ │ │ -ttoorrrreenntt__iinnffoo (std::string const& filename, error_code& ec); │ │ │ │ -ttoorrrreenntt__iinnffoo (char const* buffer, int size); │ │ │ │ -ttoorrrreenntt__iinnffoo (bdecode_node const& torrent_file, error_code& ec); │ │ │ │ ttoorrrreenntt__iinnffoo (span buffer, error_code& ec, from_span_t); │ │ │ │ -explicit ttoorrrreenntt__iinnffoo (info_hash_t const& info_hash); │ │ │ │ -explicit ttoorrrreenntt__iinnffoo (std::string const& filename); │ │ │ │ -explicit ttoorrrreenntt__iinnffoo (span buffer, from_span_t); │ │ │ │ +ttoorrrreenntt__iinnffoo (char const* buffer, int size); │ │ │ │ +ttoorrrreenntt__iinnffoo (torrent_info const& t); │ │ │ │ +ttoorrrreenntt__iinnffoo (char const* buffer, int size, error_code& ec); │ │ │ │ The constructor that takes an info-hash will initialize the info-hash to the │ │ │ │ given value, but leave all other fields empty. This is used internally when │ │ │ │ downloading torrents without the metadata. The metadata will be created by │ │ │ │ libtorrent as soon as it has been downloaded from the swarm. │ │ │ │ The constructor that takes a _b_d_e_c_o_d_e___n_o_d_e will create a _t_o_r_r_e_n_t___i_n_f_o object │ │ │ │ from the information found in the given torrent_file. The _b_d_e_c_o_d_e___n_o_d_e │ │ │ │ represents a tree node in an bencoded file. To load an ordinary .torrent file │ │ │ │ @@ -255,16 +255,16 @@ │ │ │ │ is an object in the libtorrent namespace of this type called from_span. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ~~ttoorrrreenntt__iinnffoo(()) ********** │ │ │ │ ~~ttoorrrreenntt__iinnffoo (); │ │ │ │ frees all storage associated with this _t_o_r_r_e_n_t___i_n_f_o object │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ffiilleess(()) oorriigg__ffiilleess(()) ********** │ │ │ │ -file_storage const& ffiilleess () const; │ │ │ │ file_storage const& oorriigg__ffiilleess () const; │ │ │ │ +file_storage const& ffiilleess () const; │ │ │ │ The _f_i_l_e___s_t_o_r_a_g_e object contains the information on how to map the pieces to │ │ │ │ files. It is separated from the _t_o_r_r_e_n_t___i_n_f_o object because when creating │ │ │ │ torrents a storage object needs to be created without having a torrent file. │ │ │ │ When renaming files in a storage, the storage needs to make its own copy of the │ │ │ │ _f_i_l_e___s_t_o_r_a_g_e in order to make its mapping differ from the one in the torrent │ │ │ │ file. │ │ │ │ orig_files() returns the original (unmodified) file storage for this torrent. │ │ │ │ @@ -297,49 +297,49 @@ │ │ │ │ Remaps the file storage to a new file layout. This can be used to, for │ │ │ │ instance, download all data in a torrent to a single file, or to a number of │ │ │ │ fixed size sector aligned files, regardless of the number and sizes of the │ │ │ │ files in the torrent. │ │ │ │ The new specified file_storage must have the exact same size as the current │ │ │ │ one. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__ttrraacckkeerr(()) cclleeaarr__ttrraacckkeerrss(()) ttrraacckkeerrss(()) ********** │ │ │ │ +********** ttrraacckkeerrss(()) cclleeaarr__ttrraacckkeerrss(()) aadddd__ttrraacckkeerr(()) ********** │ │ │ │ +void aadddd__ttrraacckkeerr (std::string const& url, int tier = 0); │ │ │ │ void cclleeaarr__ttrraacckkeerrss (); │ │ │ │ std::vector const& ttrraacckkeerrss () const; │ │ │ │ -void aadddd__ttrraacckkeerr (std::string const& url, int tier = 0); │ │ │ │ void aadddd__ttrraacckkeerr (std::string const& url, int tier │ │ │ │ , announce_entry::tracker_source source); │ │ │ │ add_tracker() adds a tracker to the announce-list. The tier determines the │ │ │ │ order in which the trackers are to be tried. The trackers() function will │ │ │ │ return a sorted vector of _a_n_n_o_u_n_c_e___e_n_t_r_y. Each announce _e_n_t_r_y contains a │ │ │ │ string, which is the tracker url, and a tier index. The tier index is the high- │ │ │ │ level priority. No matter which trackers that works or not, the ones with lower │ │ │ │ tier will always be tried before the one with higher tier number. For more │ │ │ │ information, see _a_n_n_o_u_n_c_e___e_n_t_r_y. │ │ │ │ trackers() returns all entries from announce-list. │ │ │ │ clear_trackers() removes all trackers from announce-list. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ccoolllleeccttiioonnss(()) ssiimmiillaarr__ttoorrrreennttss(()) ********** │ │ │ │ +********** ssiimmiillaarr__ttoorrrreennttss(()) ccoolllleeccttiioonnss(()) ********** │ │ │ │ std::vector ccoolllleeccttiioonnss () const; │ │ │ │ std::vector ssiimmiillaarr__ttoorrrreennttss () const; │ │ │ │ These two functions are related to _B_E_P_ _3_8 (mutable torrents). The vectors │ │ │ │ returned from these correspond to the "similar" and "collections" keys in the │ │ │ │ .torrent file. Both info-hashes and collections from within the info-dict and │ │ │ │ from outside of it are included. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** aadddd__hhttttpp__sseeeedd(()) sseett__wweebb__sseeeeddss(()) wweebb__sseeeeddss(()) aadddd__uurrll__sseeeedd(()) ********** │ │ │ │ -void aadddd__hhttttpp__sseeeedd (std::string const& url │ │ │ │ - , std::string const& extern_auth = std::string() │ │ │ │ - , web_seed_entry::headers_t const& extra_headers = web_seed_entry:: │ │ │ │ -headers_t()); │ │ │ │ -void sseett__wweebb__sseeeeddss (std::vector seeds); │ │ │ │ +********** aadddd__uurrll__sseeeedd(()) aadddd__hhttttpp__sseeeedd(()) sseett__wweebb__sseeeeddss(()) wweebb__sseeeeddss(()) ********** │ │ │ │ std::vector const& wweebb__sseeeeddss () const; │ │ │ │ +void sseett__wweebb__sseeeeddss (std::vector seeds); │ │ │ │ void aadddd__uurrll__sseeeedd (std::string const& url │ │ │ │ , std::string const& extern_auth = std::string() │ │ │ │ , web_seed_entry::headers_t const& ext_headers = web_seed_entry:: │ │ │ │ headers_t()); │ │ │ │ +void aadddd__hhttttpp__sseeeedd (std::string const& url │ │ │ │ + , std::string const& extern_auth = std::string() │ │ │ │ + , web_seed_entry::headers_t const& extra_headers = web_seed_entry:: │ │ │ │ +headers_t()); │ │ │ │ web_seeds() returns all url seeds and http seeds in the torrent. Each _e_n_t_r_y is │ │ │ │ a web_seed_entry and may refer to either a url seed or http seed. │ │ │ │ add_url_seed() and add_http_seed() adds one url to the list of url/http seeds. │ │ │ │ set_web_seeds() replaces all web seeds with the ones specified in the seeds │ │ │ │ vector. │ │ │ │ The extern_auth argument sets the auth field of the _w_e_b___s_e_e_d___e_n_t_r_y. If set, it │ │ │ │ overrides any username and password found in the URL itself, and it is sent │ │ │ │ @@ -368,33 +368,33 @@ │ │ │ │ piece_length() except in the case of the last piece, which may be smaller. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** bblloocckkss__ppeerr__ppiieeccee(()) ********** │ │ │ │ int bblloocckkss__ppeerr__ppiieeccee () const; │ │ │ │ returns the number of blocks there are in the typical piece. There may be fewer │ │ │ │ in the last piece) │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ppiieeccee__rraannggee(()) eenndd__ppiieeccee(()) llaasstt__ppiieeccee(()) ********** │ │ │ │ +********** eenndd__ppiieeccee(()) ppiieeccee__rraannggee(()) llaasstt__ppiieeccee(()) ********** │ │ │ │ +index_range ppiieeccee__rraannggee () const; │ │ │ │ piece_index_t llaasstt__ppiieeccee () const; │ │ │ │ piece_index_t eenndd__ppiieeccee () const; │ │ │ │ -index_range ppiieeccee__rraannggee () const; │ │ │ │ last_piece() returns the index to the last piece in the torrent and end_piece() │ │ │ │ returns the index to the one-past-end piece in the torrent piece_range() │ │ │ │ returns an implementation-defined type that can be used as the container in a │ │ │ │ range-for loop. Where the values are the indices of all pieces in the │ │ │ │ _f_i_l_e___s_t_o_r_a_g_e. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iinnffoo__hhaasshh(()) iinnffoo__hhaasshheess(()) ********** │ │ │ │ +********** iinnffoo__hhaasshheess(()) iinnffoo__hhaasshh(()) ********** │ │ │ │ sha1_hash iinnffoo__hhaasshh () const noexcept; │ │ │ │ info_hash_t const& iinnffoo__hhaasshheess () const; │ │ │ │ returns the info-hash of the torrent. For BitTorrent v2 support, use │ │ │ │ info_hashes() to get an object that may hold both a v1 and v2 info-hash │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** vv22(()) vv11(()) ********** │ │ │ │ -bool vv11 () const; │ │ │ │ +********** vv11(()) vv22(()) ********** │ │ │ │ bool vv22 () const; │ │ │ │ +bool vv11 () const; │ │ │ │ returns whether this torrent has v1 and/or v2 metadata, respectively. Hybrid │ │ │ │ torrents have both. These are shortcuts for info_hashes().has_v1() and │ │ │ │ info_hashes().has_v2() calls. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** nnuumm__ffiilleess(()) ********** │ │ │ │ int nnuumm__ffiilleess () const; │ │ │ │ If you need index-access to files you can use the num_files() along with the │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Trackers.html │ │ │ @@ -31,15 +31,15 @@ │ │ │

    home

    │ │ │
    │ │ │

    Table of contents

    │ │ │ │ │ │
    │ │ │ [report issue]
    │ │ │

    announce_infohash

    │ │ │ @@ -131,19 +131,19 @@ │ │ │

    announce_entry

    │ │ │

    Declared in "libtorrent/announce_entry.hpp"

    │ │ │

    this class holds information about one bittorrent tracker, as it │ │ │ relates to a specific torrent.

    │ │ │
    │ │ │  struct announce_entry
    │ │ │  {
    │ │ │ +   announce_entry ();
    │ │ │ +   announce_entry (announce_entry const&);
    │ │ │     ~announce_entry ();
    │ │ │     announce_entry& operator= (announce_entry const&) &;
    │ │ │ -   announce_entry (announce_entry const&);
    │ │ │     explicit announce_entry (string_view u);
    │ │ │ -   announce_entry ();
    │ │ │  
    │ │ │     enum tracker_source
    │ │ │     {
    │ │ │        source_torrent,
    │ │ │        source_client,
    │ │ │        source_magnet_link,
    │ │ │        source_tex,
    │ │ │ @@ -154,24 +154,24 @@
    │ │ │     std::vector<announce_endpoint> endpoints;
    │ │ │     std::uint8_t tier  = 0;
    │ │ │     std::uint8_t fail_limit  = 0;
    │ │ │     std::uint8_t source:4;
    │ │ │     bool verified:1;
    │ │ │  };
    │ │ │  
    │ │ │ - │ │ │ │ │ │ -[report issue]
    │ │ │ -

    ~announce_entry() announce_entry() operator=()

    │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    announce_entry() operator=() ~announce_entry()

    │ │ │
    │ │ │ +announce_entry ();
    │ │ │ +announce_entry (announce_entry const&);
    │ │ │  ~announce_entry ();
    │ │ │  announce_entry& operator= (announce_entry const&) &;
    │ │ │ -announce_entry (announce_entry const&);
    │ │ │  explicit announce_entry (string_view u);
    │ │ │ -announce_entry ();
    │ │ │  
    │ │ │

    constructs a tracker announce entry with u as the URL.

    │ │ │ [report issue]
    │ │ │
    │ │ │

    enum tracker_source

    │ │ │

    Declared in "libtorrent/announce_entry.hpp"

    │ │ │
    │ │ │ ├── html2text {} │ │ │ │ @@ -2,15 +2,15 @@ │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.0.14 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ * _a_n_n_o_u_n_c_e___i_n_f_o_h_a_s_h │ │ │ │ * _a_n_n_o_u_n_c_e___e_n_d_p_o_i_n_t │ │ │ │ * _a_n_n_o_u_n_c_e___e_n_t_r_y │ │ │ │ - o _~_a_n_n_o_u_n_c_e___e_n_t_r_y_(_)_ _a_n_n_o_u_n_c_e___e_n_t_r_y_(_)_ _o_p_e_r_a_t_o_r_=_(_) │ │ │ │ + o _a_n_n_o_u_n_c_e___e_n_t_r_y_(_)_ _o_p_e_r_a_t_o_r_=_(_)_ _~_a_n_n_o_u_n_c_e___e_n_t_r_y_(_) │ │ │ │ o _e_n_u_m_ _t_r_a_c_k_e_r___s_o_u_r_c_e │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ aannnnoouunnccee__iinnffoohhaasshh ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_n_n_o_u_n_c_e___e_n_t_r_y_._h_p_p" │ │ │ │ struct announce_infohash │ │ │ │ { │ │ │ │ std::string message; │ │ │ │ @@ -78,19 +78,19 @@ │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ aannnnoouunnccee__eennttrryy ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_n_n_o_u_n_c_e___e_n_t_r_y_._h_p_p" │ │ │ │ this class holds information about one bittorrent tracker, as it relates to a │ │ │ │ specific torrent. │ │ │ │ struct announce_entry │ │ │ │ { │ │ │ │ + aannnnoouunnccee__eennttrryy (); │ │ │ │ + aannnnoouunnccee__eennttrryy (announce_entry const&); │ │ │ │ ~~aannnnoouunnccee__eennttrryy (); │ │ │ │ announce_entry& ooppeerraattoorr== (announce_entry const&) &; │ │ │ │ - aannnnoouunnccee__eennttrryy (announce_entry const&); │ │ │ │ explicit aannnnoouunnccee__eennttrryy (string_view u); │ │ │ │ - aannnnoouunnccee__eennttrryy (); │ │ │ │ │ │ │ │ enum tracker_source │ │ │ │ { │ │ │ │ source_torrent, │ │ │ │ source_client, │ │ │ │ source_magnet_link, │ │ │ │ source_tex, │ │ │ │ @@ -101,20 +101,20 @@ │ │ │ │ std::vector endpoints; │ │ │ │ std::uint8_t ttiieerr = 0; │ │ │ │ std::uint8_t ffaaiill__lliimmiitt = 0; │ │ │ │ std::uint8_t source:4; │ │ │ │ bool verified:1; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ~~aannnnoouunnccee__eennttrryy(()) aannnnoouunnccee__eennttrryy(()) ooppeerraattoorr==(()) ********** │ │ │ │ +********** aannnnoouunnccee__eennttrryy(()) ooppeerraattoorr==(()) ~~aannnnoouunnccee__eennttrryy(()) ********** │ │ │ │ +aannnnoouunnccee__eennttrryy (); │ │ │ │ +aannnnoouunnccee__eennttrryy (announce_entry const&); │ │ │ │ ~~aannnnoouunnccee__eennttrryy (); │ │ │ │ announce_entry& ooppeerraattoorr== (announce_entry const&) &; │ │ │ │ -aannnnoouunnccee__eennttrryy (announce_entry const&); │ │ │ │ explicit aannnnoouunnccee__eennttrryy (string_view u); │ │ │ │ -aannnnoouunnccee__eennttrryy (); │ │ │ │ constructs a tracker announce _e_n_t_r_y with u as the URL. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** eennuumm ttrraacckkeerr__ssoouurrccee ********** │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_a_n_n_o_u_n_c_e___e_n_t_r_y_._h_p_p" │ │ │ │ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ |_nn_aa_mm_ee_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |_s_o_u_r_c_e___t_o_r_r_e_n_t_ _ _ _ _|_1_ _ _ _ _|_t_h_e_ _t_r_a_c_k_e_r_ _w_a_s_ _p_a_r_t_ _o_f_ _t_h_e_ _._t_o_r_r_e_n_t_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ | │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Utility.html │ │ │ @@ -29,32 +29,32 @@ │ │ │ │ │ │
    │ │ │

    home

    │ │ │
    │ │ │

    Table of contents

    │ │ │
    .{...in │ │ │ +0001a6a0: 7420 636f 6e73 7420 7661 6c75 6520 3d20 t const value = │ │ │ +0001a6b0: 6d5f 7365 7474 696e 6773 2e67 6574 5f69 m_settings.get_i │ │ │ +0001a6c0: 6e74 2873 6574 7469 6e67 735f 7061 636b nt(settings_pack │ │ │ +0001a6d0: 3a3a 7065 6572 5f64 7363 7029 3b0a 0909 ::peer_dscp);... │ │ │ +0001a6e0: 666f 7220 2861 7574 6f20 636f 6e73 7426 for (auto const& │ │ │ +0001a6f0: 616d 703b 206c 203a 206d 5f6c 6973 7465 amp; l : m_liste │ │ │ +0001a700: 6e5f 736f 636b 6574 7329 0a09 097b 0a09 n_sockets)...{.. │ │ │ +0001a710: 0909 6966 2028 6c2d 2667 743b 736f 636b ..if (l->sock │ │ │ +0001a720: 290a 0909 097b 0a09 0909 0965 7272 6f72 )....{.....error │ │ │ +0001a730: 5f63 6f64 6520 6563 3b0a 0909 0909 7365 _code ec;.....se │ │ │ +0001a740: 745f 7472 6166 6669 635f 636c 6173 7328 t_traffic_class( │ │ │ +0001a750: 2a6c 2d26 6774 3b73 6f63 6b2c 2076 616c *l->sock, val │ │ │ +0001a760: 7565 2c20 6563 293b 0a0a 2369 666e 6465 ue, ec);..#ifnde │ │ │ +0001a770: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ +0001a780: 455f 4c4f 4747 494e 470a 0909 0909 6966 E_LOGGING.....if │ │ │ +0001a790: 2028 7368 6f75 6c64 5f6c 6f67 2829 290a (should_log()). │ │ │ +0001a7a0: 0909 0909 7b0a 0909 0909 0973 6573 7369 ....{......sessi │ │ │ +0001a7b0: 6f6e 5f6c 6f67 2822 2667 743b 2667 743b on_log(">> │ │ │ +0001a7c0: 2667 743b 2053 4554 5f44 5343 5020 5b20 > SET_DSCP [ │ │ │ +0001a7d0: 7463 7020 2825 7320 2564 2920 7661 6c75 tcp (%s %d) valu │ │ │ +0001a7e0: 653a 2025 7820 653a 2025 7320 5d22 0a09 e: %x e: %s ]".. │ │ │ +0001a7f0: 0909 0909 092c 206c 2d26 6774 3b73 6f63 ....., l->soc │ │ │ +0001a800: 6b2d 2667 743b 6c6f 6361 6c5f 656e 6470 k->local_endp │ │ │ +0001a810: 6f69 6e74 2829 2e61 6464 7265 7373 2829 oint().address() │ │ │ +0001a820: 2e74 6f5f 7374 7269 6e67 2829 2e63 5f73 .to_string().c_s │ │ │ +0001a830: 7472 2829 0a09 0909 0909 092c 206c 2d26 tr()......., l-& │ │ │ +0001a840: 6774 3b73 6f63 6b2d 2667 743b 6c6f 6361 gt;sock->loca │ │ │ +0001a850: 6c5f 656e 6470 6f69 6e74 2829 2e70 6f72 l_endpoint().por │ │ │ +0001a860: 7428 292c 2073 7464 3a3a 7569 6e74 3332 t(), std::uint32 │ │ │ +0001a870: 5f74 2876 616c 7565 292c 2065 632e 6d65 _t(value), ec.me │ │ │ +0001a880: 7373 6167 6528 292e 635f 7374 7228 2929 ssage().c_str()) │ │ │ +0001a890: 3b0a 0909 0909 7d0a 2365 6e64 6966 0a09 ;.....}.#endif.. │ │ │ +0001a8a0: 0909 7d0a 0a09 0909 6966 2028 6c2d 2667 ..}.....if (l-&g │ │ │ +0001a8b0: 743b 7564 705f 736f 636b 290a 0909 097b t;udp_sock)....{ │ │ │ +0001a8c0: 0a09 0909 0965 7272 6f72 5f63 6f64 6520 .....error_code │ │ │ +0001a8d0: 6563 3b0a 0909 0909 7365 745f 7472 6166 ec;.....set_traf │ │ │ +0001a8e0: 6669 635f 636c 6173 7328 6c2d 2667 743b fic_class(l-> │ │ │ +0001a8f0: 7564 705f 736f 636b 2d26 6774 3b73 6f63 udp_sock->soc │ │ │ +0001a900: 6b2c 2076 616c 7565 2c20 6563 293b 0a0a k, value, ec);.. │ │ │ +0001a910: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ +0001a920: 4449 5341 424c 455f 4c4f 4747 494e 470a DISABLE_LOGGING. │ │ │ +0001a930: 0909 0909 6966 2028 7368 6f75 6c64 5f6c ....if (should_l │ │ │ +0001a940: 6f67 2829 290a 0909 0909 7b0a 0909 0909 og()).....{..... │ │ │ +0001a950: 0973 6573 7369 6f6e 5f6c 6f67 2822 2667 .session_log("&g │ │ │ +0001a960: 743b 2667 743b 2667 743b 2053 4554 5f44 t;>> SET_D │ │ │ +0001a970: 5343 5020 5b20 7564 7020 2825 7320 2564 SCP [ udp (%s %d │ │ │ +0001a980: 2920 7661 6c75 653a 2025 7820 653a 2025 ) value: %x e: % │ │ │ +0001a990: 7320 5d22 0a09 0909 0909 092c 206c 2d26 s ]"......., l-& │ │ │ +0001a9a0: 6774 3b75 6470 5f73 6f63 6b2d 2667 743b gt;udp_sock-> │ │ │ +0001a9b0: 736f 636b 2e6c 6f63 616c 5f65 6e64 706f sock.local_endpo │ │ │ +0001a9c0: 696e 7428 292e 6164 6472 6573 7328 292e int().address(). │ │ │ +0001a9d0: 746f 5f73 7472 696e 6728 292e 635f 7374 to_string().c_st │ │ │ +0001a9e0: 7228 290a 0909 0909 0909 2c20 6c2d 2667 r()......., l-&g │ │ │ +0001a9f0: 743b 7564 705f 736f 636b 2d26 6774 3b73 t;udp_sock->s │ │ │ +0001aa00: 6f63 6b2e 6c6f 6361 6c5f 706f 7274 2829 ock.local_port() │ │ │ +0001aa10: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .relevance  │ │ │ +0001aa50: 3b32 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;2../sr │ │ │ +0001aa80: 632f 7765 625f 7065 6572 5f63 6f6e 6e65 c/web_peer_conne │ │ │ +0001aa90: 6374 696f 6e2e 6370 703a 3633 363c 2f61 ction.cpp:636just m │ │ │ +0001aab0: 616b 6520 7468 6973 2070 6565 7220 6e6f ake this peer no │ │ │ +0001aac0: 7420 6861 7665 2074 6865 2070 6965 6365 t have the piece │ │ │ +0001aad0: 7320 6173 736f 6369 6174 6564 2077 6974 s associated wit │ │ │ +0001aae0: 6820 7468 6520 6669 6c65 2077 6520 6a75 h the file we ju │ │ │ +0001aaf0: 7374 2072 6571 7565 7374 6564 2e20 4f6e st requested. On │ │ │ +0001ab00: 6c79 2077 6865 6e20 6974 2064 6f65 736e ly when it doesn │ │ │ +0001ab10: 2774 2068 6176 6520 616e 7920 6f66 2074 't have any of t │ │ │ +0001ab20: 6865 2066 696c 6520 646f 2074 6865 2066 he file do the f │ │ │ +0001ab30: 6f6c 6c6f 7769 6e67 2070 6164 2066 696c ollowing pad fil │ │ │ +0001ab40: 6573 2077 696c 6c20 6d61 6b65 2069 7420 es will make it │ │ │ +0001ab50: 636f 6d70 6c69 6361 7465 643c 2f74 643e complicated │ │ │ +0001ab60: 3c2f 7472 3e3c 7472 2069 643d 2235 3322

    just mak │ │ │ +0001abb0: 6520 7468 6973 2070 6565 7220 6e6f 7420 e this peer not │ │ │ +0001abc0: 6861 7665 2074 6865 2070 6965 6365 730a have the pieces. │ │ │ +0001abd0: 6173 736f 6369 6174 6564 2077 6974 6820 associated with │ │ │ +0001abe0: 7468 6520 6669 6c65 2077 6520 6a75 7374 the file we just │ │ │ +0001abf0: 2072 6571 7565 7374 6564 2e20 4f6e 6c79 requested. Only │ │ │ +0001ac00: 0a77 6865 6e20 6974 2064 6f65 736e 2774 .when it doesn't │ │ │ +0001ac10: 2068 6176 6520 616e 7920 6f66 2074 6865 have any of the │ │ │ +0001ac20: 2066 696c 6520 646f 2074 6865 2066 6f6c file do the fol │ │ │ +0001ac30: 6c6f 7769 6e67 0a70 6164 2066 696c 6573 lowing.pad files │ │ │ +0001ac40: 2077 696c 6c20 6d61 6b65 2069 7420 636f will make it co │ │ │ +0001ac50: 6d70 6c69 6361 7465 643c 2f68 323e 3c68 mplicated

    ../src/web_pee │ │ │ +0001ac70: 725f 636f 6e6e 6563 7469 6f6e 2e63 7070 r_connection.cpp │ │ │ +0001ac80: 3a36 3336 3c2f 6834 3e3c 7072 6520 7374 :636
    ..peer_connec
    │ │ │ +0001acd0: 7469 6f6e 3a3a 7265 6365 6976 6564 5f69  tion::received_i
    │ │ │ +0001ace0: 6e76 616c 6964 5f64 6174 6128 696e 6465  nvalid_data(inde
    │ │ │ +0001acf0: 782c 2073 696e 676c 655f 7065 6572 293b  x, single_peer);
    │ │ │ +0001ad00: 0a0a 092f 2f20 6966 2077 6520 646f 6e27  ...// if we don'
    │ │ │ +0001ad10: 7420 7468 696e 6b20 7765 2068 6176 6520  t think we have 
    │ │ │ +0001ad20: 616e 7920 6f66 2074 6865 2066 696c 6573  any of the files
    │ │ │ +0001ad30: 2c20 616c 6c6f 7720 6261 6e6e 696e 6720  , allow banning 
    │ │ │ +0001ad40: 7468 6520 7765 6220 7365 6564 0a09 6966  the web seed..if
    │ │ │ +0001ad50: 2028 6e75 6d5f 6861 7665 5f70 6965 6365   (num_have_piece
    │ │ │ +0001ad60: 7328 2920 3d3d 2030 2920 7265 7475 726e  s() == 0) return
    │ │ │ +0001ad70: 2074 7275 653b 0a0a 092f 2f20 646f 6e27   true;...// don'
    │ │ │ +0001ad80: 7420 6469 7363 6f6e 6e65 6374 2c20 7765  t disconnect, we
    │ │ │ +0001ad90: 2077 6f6e 2774 2072 6571 7565 7374 2061   won't request a
    │ │ │ +0001ada0: 6e79 7468 696e 6720 6672 6f6d 2074 6869  nything from thi
    │ │ │ +0001adb0: 7320 6669 6c65 2061 6761 696e 0a09 7265  s file again..re
    │ │ │ +0001adc0: 7475 726e 2066 616c 7365 3b0a 7d0a 0a76  turn false;.}..v
    │ │ │ +0001add0: 6f69 6420 7765 625f 7065 6572 5f63 6f6e  oid web_peer_con
    │ │ │ +0001ade0: 6e65 6374 696f 6e3a 3a6f 6e5f 7265 6365  nection::on_rece
    │ │ │ +0001adf0: 6976 655f 7061 6466 696c 6528 290a 7b0a  ive_padfile().{.
    │ │ │ +0001ae00: 0968 616e 646c 655f 7061 6466 696c 6528  .handle_padfile(
    │ │ │ +0001ae10: 293b 0a7d 0a0a 766f 6964 2077 6562 5f70  );.}..void web_p
    │ │ │ +0001ae20: 6565 725f 636f 6e6e 6563 7469 6f6e 3a3a  eer_connection::
    │ │ │ +0001ae30: 6861 6e64 6c65 5f65 7272 6f72 2869 6e74  handle_error(int
    │ │ │ +0001ae40: 2063 6f6e 7374 2062 7974 6573 5f6c 6566   const bytes_lef
    │ │ │ +0001ae50: 7429 0a7b 0a09 7374 643a 3a73 6861 7265  t).{..std::share
    │ │ │ +0001ae60: 645f 7074 7226 6c74 3b74 6f72 7265 6e74  d_ptr<torrent
    │ │ │ +0001ae70: 2667 743b 2074 203d 2061 7373 6f63 6961  > t = associa
    │ │ │ +0001ae80: 7465 645f 746f 7272 656e 7428 292e 6c6f  ted_torrent().lo
    │ │ │ +0001ae90: 636b 2829 3b0a 0954 4f52 5245 4e54 5f41  ck();..TORRENT_A
    │ │ │ +0001aea0: 5353 4552 5428 7429 3b0a 0a3c 6469 7620  SSERT(t);..
    .
    │ │ │ +0001aee0: 092f 2f20 7465 6d70 6f72 6172 696c 7920 .// temporarily │ │ │ +0001aef0: 756e 6176 6169 6c61 626c 652c 2072 6574 unavailable, ret │ │ │ +0001af00: 7279 206c 6174 6572 0a09 742d 2667 743b ry later..t-> │ │ │ +0001af10: 7265 7472 795f 7765 625f 7365 6564 2874 retry_web_seed(t │ │ │ +0001af20: 6869 732c 206d 5f70 6172 7365 722e 6865 his, m_parser.he │ │ │ +0001af30: 6164 6572 5f64 7572 6174 696f 6e28 2272 ader_duration("r │ │ │ +0001af40: 6574 7279 2d61 6674 6572 2229 293b 0a09 etry-after"));.. │ │ │ +0001af50: 6966 2028 742d 2667 743b 616c 6572 7473 if (t->alerts │ │ │ +0001af60: 2829 2e73 686f 756c 645f 706f 7374 266c ().should_post&l │ │ │ +0001af70: 743b 7572 6c5f 7365 6564 5f61 6c65 7274 t;url_seed_alert │ │ │ +0001af80: 2667 743b 2829 290a 097b 0a09 0973 7464 >())..{...std │ │ │ +0001af90: 3a3a 7374 7269 6e67 2063 6f6e 7374 2065 ::string const e │ │ │ +0001afa0: 7272 6f72 5f6d 7367 203d 2074 6f5f 7374 rror_msg = to_st │ │ │ +0001afb0: 7269 6e67 286d 5f70 6172 7365 722e 7374 ring(m_parser.st │ │ │ +0001afc0: 6174 7573 5f63 6f64 6528 2929 2e64 6174 atus_code()).dat │ │ │ +0001afd0: 6128 290a 0909 092b 2028 2220 2220 2b20 a()....+ (" " + │ │ │ +0001afe0: 6d5f 7061 7273 6572 2e6d 6573 7361 6765 m_parser.message │ │ │ +0001aff0: 2829 293b 0a09 0974 2d26 6774 3b61 6c65 ());...t->ale │ │ │ +0001b000: 7274 7328 292e 656d 706c 6163 655f 616c rts().emplace_al │ │ │ +0001b010: 6572 7426 6c74 3b75 726c 5f73 6565 645f ert<url_seed_ │ │ │ +0001b020: 616c 6572 7426 6774 3b28 742d 2667 743b alert>(t-> │ │ │ +0001b030: 6765 745f 6861 6e64 6c65 2829 2c20 6d5f get_handle(), m_ │ │ │ +0001b040: 7572 6c0a 0909 092c 2065 7272 6f72 5f6d url...., error_m │ │ │ +0001b050: 7367 293b 0a09 7d0a 0972 6563 6569 7665 sg);..}..receive │ │ │ +0001b060: 645f 6279 7465 7328 302c 2062 7974 6573 d_bytes(0, bytes │ │ │ +0001b070: 5f6c 6566 7429 3b0a 0964 6973 636f 6e6e _left);..disconn │ │ │ +0001b080: 6563 7428 6572 726f 725f 636f 6465 286d ect(error_code(m │ │ │ +0001b090: 5f70 6172 7365 722e 7374 6174 7573 5f63 _parser.status_c │ │ │ +0001b0a0: 6f64 6528 292c 2068 7474 705f 6361 7465 ode(), http_cate │ │ │ +0001b0b0: 676f 7279 2829 292c 206f 7065 7261 7469 gory()), operati │ │ │ +0001b0c0: 6f6e 5f74 3a3a 6269 7474 6f72 7265 6e74 on_t::bittorrent │ │ │ +0001b0d0: 2c20 6661 696c 7572 6529 3b0a 7d0a 0a76 , failure);.}..v │ │ │ +0001b0e0: 6f69 6420 7765 625f 7065 6572 5f63 6f6e oid web_peer_con │ │ │ +0001b0f0: 6e65 6374 696f 6e3a 3a64 6973 6162 6c65 nection::disable │ │ │ +0001b100: 2865 7272 6f72 5f63 6f64 6520 636f 6e73 (error_code cons │ │ │ +0001b110: 7426 616d 703b 2065 6329 0a7b 0a09 2f2f t& ec).{..// │ │ │ +0001b120: 2077 6520 7368 6f75 6c64 206e 6f74 2074 we should not t │ │ │ +0001b130: 7279 2074 6869 7320 7365 7276 6572 2061 ry this server a │ │ │ +0001b140: 6761 696e 2e0a 096d 5f77 6562 2d26 6774 gain...m_web-> │ │ │ +0001b150: 3b64 6973 6162 6c65 6420 3d20 7472 7565 ;disabled = true │ │ │ +0001b160: 3b0a 0964 6973 636f 6e6e 6563 7428 6563 ;..disconnect(ec │ │ │ +0001b170: 2c20 6f70 6572 6174 696f 6e5f 743a 3a62 , operation_t::b │ │ │ +0001b180: 6974 746f 7272 656e 742c 2070 6565 725f ittorrent, peer_ │ │ │ +0001b190: 6572 726f 7229 3b0a 0969 6620 286d 5f77 error);..if (m_w │ │ │ +0001b1a0: 6562 2d26 6774 3b65 7068 656d 6572 616c eb->ephemeral │ │ │ +0001b1b0: 290a 097b 0a09 0973 7464 3a3a 7368 6172 )..{...std::shar │ │ │ +0001b1c0: 6564 5f70 7472 266c 743b 746f 7272 656e ed_ptr<torren │ │ │ +0001b1d0: 7426 6774 3b20 7420 3d20 6173 736f 6369 t> t = associ │ │ │ +0001b1e0: 6174 6564 5f74 6f72 7265 6e74 2829 2e6c ated_torrent().l │ │ │ +0001b1f0: 6f63 6b28 293b 0a09 0954 4f52 5245 4e54 ock();...TORRENT │ │ │ +0001b200: 5f41 5353 4552 5428 7429 3b0a 0909 742d _ASSERT(t);...t- │ │ │ +0001b210: 2667 743b 7265 6d6f 7665 5f77 6562 5f73 >remove_web_s │ │ │ +0001b220: 6565 645f 636f 6e6e 2874 6869 7329 3b0a eed_conn(this);. │ │ │ +0001b230: 097d 0a09 6d5f 7765 6220 3d20 6e75 6c6c .}..m_web = null │ │ │ +0001b240: 7074 723b 0a09 544f 5252 454e 545f 4153 ptr;..TORRENT_AS │ │ │ +0001b250: 5345 5254 2869 735f 6469 7363 6f6e 6e65 SERT(is_disconne │ │ │ +0001b260: 6374 696e 6728 2929 3b0a 7d0a 0a76 6f69 cting());.}..voi │ │ │ +0001b270: 6420 7765 625f 7065 6572 5f63 6f6e 6e65 d web_peer_conne │ │ │ +0001b280: 6374 696f 6e3a 3a68 616e 646c 655f 7265 ction::handle_re │ │ │ +0001b290: 6469 7265 6374 2869 6e74 2063 6f6e 7374 direct(int const │ │ │ +0001b2a0: 2062 7974 6573 5f6c 6566 7429 0a7b 0a3c bytes_left).{.< │ │ │ +0001b2b0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +0001b2c0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +0001b2d0: 6f75 6e64 3a20 2363 6663 223e 3c74 643e ound: #cfc"> │ │ │ +0001b2e0: 7265 6c65 7661 6e63 6526 6e62 7370 3b32 relevance 2 │ │ │ +0001b2f0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src/ │ │ │ +0001b320: 7065 6572 5f63 6f6e 6e65 6374 696f 6e2e peer_connection. │ │ │ +0001b330: 6370 703a 3235 3731 3c2f 613e 3c2f 7464 cpp:2571this should │ │ │ +0001b350: 2070 726f 6261 626c 7920 6265 2062 6173 probably be bas │ │ │ +0001b360: 6564 206f 6e20 7469 6d65 2069 6e73 7465 ed on time inste │ │ │ +0001b370: 6164 206f 6620 6e75 6d62 6572 206f 6620 ad of number of │ │ │ +0001b380: 7265 7175 6573 7420 6d65 7373 6167 6573 request messages │ │ │ +0001b390: 2e20 466f 7220 6120 7665 7279 2068 6967 . For a very hig │ │ │ +0001b3a0: 6820 7468 726f 7567 6870 7574 2063 6f6e h throughput con │ │ │ +0001b3b0: 6e65 6374 696f 6e2c 2033 3030 206d 6179 nection, 300 may │ │ │ +0001b3c0: 2062 6520 6120 6c65 6769 7469 6d61 7465 be a legitimate │ │ │ +0001b3d0: 206e 756d 6265 7220 6f66 2072 6571 7565 number of reque │ │ │ +0001b3e0: 7374 7320 746f 2068 6176 6520 696e 2066 sts to have in f │ │ │ +0001b3f0: 6c69 6768 7420 7768 656e 2067 6574 7469 light when getti │ │ │ +0001b400: 6e67 2063 686f 6b65 643c 2f74 643e 3c2f ng choked

    this shoul │ │ │ +0001b460: 6420 7072 6f62 6162 6c79 2062 6520 6261 d probably be ba │ │ │ +0001b470: 7365 6420 6f6e 2074 696d 6520 696e 7374 sed on time inst │ │ │ +0001b480: 6561 6420 6f66 206e 756d 6265 720a 6f66 ead of number.of │ │ │ +0001b490: 2072 6571 7565 7374 206d 6573 7361 6765 request message │ │ │ +0001b4a0: 732e 2046 6f72 2061 2076 6572 7920 6869 s. For a very hi │ │ │ +0001b4b0: 6768 2074 6872 6f75 6768 7075 7420 636f gh throughput co │ │ │ +0001b4c0: 6e6e 6563 7469 6f6e 2c20 3330 300a 6d61 nnection, 300.ma │ │ │ +0001b4d0: 7920 6265 2061 206c 6567 6974 696d 6174 y be a legitimat │ │ │ +0001b4e0: 6520 6e75 6d62 6572 206f 6620 7265 7175 e number of requ │ │ │ +0001b4f0: 6573 7473 2074 6f20 6861 7665 2069 6e20 ests to have in │ │ │ +0001b500: 666c 6967 6874 2077 6865 6e0a 6765 7474 flight when.gett │ │ │ +0001b510: 696e 6720 6368 6f6b 6564 3c2f 6832 3e3c ing choked

    < │ │ │ +0001b520: 6834 3e2e 2e2f 7372 632f 7065 6572 5f63 h4>../src/peer_c │ │ │ +0001b530: 6f6e 6e65 6374 696f 6e2e 6370 703a 3235 onnection.cpp:25 │ │ │ +0001b540: 3731 3c2f 6834 3e3c 7072 6520 7374 796c 71
    ...}.#endif....
    │ │ │ +0001b590: 0977 7269 7465 5f72 656a 6563 745f 7265  .write_reject_re
    │ │ │ +0001b5a0: 7175 6573 7428 7229 3b0a 0909 0969 6620  quest(r);....if 
    │ │ │ +0001b5b0: 286d 5f6e 756d 5f69 6e76 616c 6964 5f72  (m_num_invalid_r
    │ │ │ +0001b5c0: 6571 7565 7374 7320 266c 743b 2073 7464  equests < std
    │ │ │ +0001b5d0: 3a3a 6e75 6d65 7269 635f 6c69 6d69 7473  ::numeric_limits
    │ │ │ +0001b5e0: 266c 743b 6465 636c 7479 7065 286d 5f6e  <decltype(m_n
    │ │ │ +0001b5f0: 756d 5f69 6e76 616c 6964 5f72 6571 7565  um_invalid_reque
    │ │ │ +0001b600: 7374 7329 2667 743b 3a3a 6d61 7828 2929  sts)>::max())
    │ │ │ +0001b610: 0a09 0909 092b 2b6d 5f6e 756d 5f69 6e76  .....++m_num_inv
    │ │ │ +0001b620: 616c 6964 5f72 6571 7565 7374 733b 0a0a  alid_requests;..
    │ │ │ +0001b630: 0909 0969 6620 2874 2d26 6774 3b61 6c65  ...if (t->ale
    │ │ │ +0001b640: 7274 7328 292e 7368 6f75 6c64 5f70 6f73  rts().should_pos
    │ │ │ +0001b650: 7426 6c74 3b69 6e76 616c 6964 5f72 6571  t<invalid_req
    │ │ │ +0001b660: 7565 7374 5f61 6c65 7274 2667 743b 2829  uest_alert>()
    │ │ │ +0001b670: 290a 0909 097b 0a09 0909 092f 2f20 6d73  )....{.....// ms
    │ │ │ +0001b680: 7663 2031 3220 6170 7065 6172 7320 746f  vc 12 appears to
    │ │ │ +0001b690: 2064 6564 7563 6520 7468 6520 7276 616c   deduce the rval
    │ │ │ +0001b6a0: 7565 2072 6566 6572 656e 6365 2074 656d  ue reference tem
    │ │ │ +0001b6b0: 706c 6174 650a 0909 0909 2f2f 2069 6e63  plate.....// inc
    │ │ │ +0001b6c0: 6f72 7265 6374 6c79 2066 6f72 2062 6f6f  orrectly for boo
    │ │ │ +0001b6d0: 6c20 7465 6d70 6f72 6172 6965 732e 2053  l temporaries. S
    │ │ │ +0001b6e0: 6f2c 2063 7265 6174 6520 6120 6475 6d6d  o, create a dumm
    │ │ │ +0001b6f0: 7920 696e 7374 616e 6365 0a09 0909 0962  y instance.....b
    │ │ │ +0001b700: 6f6f 6c20 636f 6e73 7420 7065 6572 5f69  ool const peer_i
    │ │ │ +0001b710: 6e74 6572 6573 7465 6420 3d20 626f 6f6c  nterested = bool
    │ │ │ +0001b720: 286d 5f70 6565 725f 696e 7465 7265 7374  (m_peer_interest
    │ │ │ +0001b730: 6564 293b 0a09 0909 0974 2d26 6774 3b61  ed);.....t->a
    │ │ │ +0001b740: 6c65 7274 7328 292e 656d 706c 6163 655f  lerts().emplace_
    │ │ │ +0001b750: 616c 6572 7426 6c74 3b69 6e76 616c 6964  alert<invalid
    │ │ │ +0001b760: 5f72 6571 7565 7374 5f61 6c65 7274 2667  _request_alert&g
    │ │ │ +0001b770: 743b 280a 0909 0909 0974 2d26 6774 3b67  t;(......t->g
    │ │ │ +0001b780: 6574 5f68 616e 646c 6528 292c 206d 5f72  et_handle(), m_r
    │ │ │ +0001b790: 656d 6f74 652c 206d 5f70 6565 725f 6964  emote, m_peer_id
    │ │ │ +0001b7a0: 2c20 720a 0909 0909 092c 2074 2d26 6774  , r......, t->
    │ │ │ +0001b7b0: 3b75 7365 725f 6861 7665 5f70 6965 6365  ;user_have_piece
    │ │ │ +0001b7c0: 2872 2e70 6965 6365 292c 2070 6565 725f  (r.piece), peer_
    │ │ │ +0001b7d0: 696e 7465 7265 7374 6564 2c20 6661 6c73  interested, fals
    │ │ │ +0001b7e0: 6529 3b0a 0909 097d 0a0a 0909 092f 2f20  e);....}.....// 
    │ │ │ +0001b7f0: 6576 6572 7920 7465 6e20 696e 7661 6c69  every ten invali
    │ │ │ +0001b800: 6420 7265 7175 6573 742c 2072 656d 696e  d request, remin
    │ │ │ +0001b810: 6420 7468 6520 7065 6572 2074 6861 7420  d the peer that 
    │ │ │ +0001b820: 6974 2773 2063 686f 6b65 640a 0909 0969  it's choked....i
    │ │ │ +0001b830: 6620 2821 6d5f 7065 6572 5f69 6e74 6572  f (!m_peer_inter
    │ │ │ +0001b840: 6573 7465 6420 2661 6d70 3b26 616d 703b  ested &&
    │ │ │ +0001b850: 206d 5f6e 756d 5f69 6e76 616c 6964 5f72   m_num_invalid_r
    │ │ │ +0001b860: 6571 7565 7374 7320 2520 3130 203d 3d20  equests % 10 == 
    │ │ │ +0001b870: 3020 2661 6d70 3b26 616d 703b 206d 5f63  0 && m_c
    │ │ │ +0001b880: 686f 6b65 6429 0a09 0909 7b0a 3c64 6976  hoked)....{.
    ....if │ │ │ +0001b8c0: 2028 6d5f 6e75 6d5f 696e 7661 6c69 645f (m_num_invalid_ │ │ │ +0001b8d0: 7265 7175 6573 7473 2026 6774 3b20 3330 requests > 30 │ │ │ +0001b8e0: 3020 2661 6d70 3b26 616d 703b 2021 6d5f 0 && !m_ │ │ │ +0001b8f0: 7065 6572 5f63 686f 6b65 640a 3c2f 6469 peer_choked......&& │ │ │ +0001b910: 3b20 6361 6e5f 6469 7363 6f6e 6e65 6374 ; can_disconnect │ │ │ +0001b920: 2865 7272 6f72 733a 3a74 6f6f 5f6d 616e (errors::too_man │ │ │ +0001b930: 795f 7265 7175 6573 7473 5f77 6865 6e5f y_requests_when_ │ │ │ +0001b940: 6368 6f6b 6564 2929 0a09 0909 097b 0a09 choked)).....{.. │ │ │ +0001b950: 0909 0909 6469 7363 6f6e 6e65 6374 2865 ....disconnect(e │ │ │ +0001b960: 7272 6f72 733a 3a74 6f6f 5f6d 616e 795f rrors::too_many_ │ │ │ +0001b970: 7265 7175 6573 7473 5f77 6865 6e5f 6368 requests_when_ch │ │ │ +0001b980: 6f6b 6564 2c20 6f70 6572 6174 696f 6e5f oked, operation_ │ │ │ +0001b990: 743a 3a62 6974 746f 7272 656e 742c 2070 t::bittorrent, p │ │ │ +0001b9a0: 6565 725f 6572 726f 7229 3b0a 0909 0909 eer_error);..... │ │ │ +0001b9b0: 0972 6574 7572 6e3b 0a09 0909 097d 0a23 .return;.....}.# │ │ │ +0001b9c0: 6966 6e64 6566 2054 4f52 5245 4e54 5f44 ifndef TORRENT_D │ │ │ +0001b9d0: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09 ISABLE_LOGGING.. │ │ │ +0001b9e0: 0909 0970 6565 725f 6c6f 6728 7065 6572 ...peer_log(peer │ │ │ +0001b9f0: 5f6c 6f67 5f61 6c65 7274 3a3a 6f75 7467 _log_alert::outg │ │ │ +0001ba00: 6f69 6e67 5f6d 6573 7361 6765 2c20 2243 oing_message, "C │ │ │ +0001ba10: 484f 4b45 2229 3b0a 2365 6e64 6966 0a09 HOKE");.#endif.. │ │ │ +0001ba20: 0909 0977 7269 7465 5f63 686f 6b65 2829 ...write_choke() │ │ │ +0001ba30: 3b0a 0909 097d 0a0a 0909 0972 6574 7572 ;....}.....retur │ │ │ +0001ba40: 6e3b 0a09 097d 0a0a 0909 2f2f 2069 6620 n;...}....// if │ │ │ +0001ba50: 7765 2068 6176 6520 6368 6f6b 6564 2074 we have choked t │ │ │ +0001ba60: 6865 2063 6c69 656e 740a 0909 2f2f 2069 he client...// i │ │ │ +0001ba70: 676e 6f72 6520 7468 6520 7265 7175 6573 gnore the reques │ │ │ +0001ba80: 740a 0909 696e 7420 636f 6e73 7420 626c t...int const bl │ │ │ +0001ba90: 6f63 6b73 5f70 6572 5f70 6965 6365 203d ocks_per_piece = │ │ │ +0001baa0: 0a09 0909 2874 692e 7069 6563 655f 6c65 ....(ti.piece_le │ │ │ +0001bab0: 6e67 7468 2829 202b 2074 2d26 6774 3b62 ngth() + t->b │ │ │ +0001bac0: 6c6f 636b 5f73 697a 6528 2920 2d20 3129 lock_size() - 1) │ │ │ +0001bad0: 202f 2074 2d26 6774 3b62 6c6f 636b 5f73 / t->block_s │ │ │ +0001bae0: 697a 6528 293b 0a0a 0909 2f2f 2064 6973 ize();....// dis │ │ │ +0001baf0: 636f 6e6e 6563 7420 7065 6572 7320 7468 connect peers th │ │ │ +0001bb00: 6174 2064 6f77 6e6c 6f61 6473 206d 6f72 at downloads mor │ │ │ +0001bb10: 6520 7468 616e 2066 6f6f 2074 696d 6573 e than foo times │ │ │ +0001bb20: 2061 6e20 616c 6c6f 7765 640a 0909 2f2f an allowed...// │ │ │ +0001bb30: 2066 6173 7420 7069 6563 650a 0909 6966 fast piece...if │ │ │ +0001bb40: 2028 6d5f 6368 6f6b 6564 2026 616d 703b (m_choked & │ │ │ +0001bb50: 2661 6d70 3b20 6661 7374 5f69 6478 2021 & fast_idx ! │ │ │ +0001bb60: 3d20 2d31 2026 616d 703b 2661 6d70 3b20 = -1 && │ │ │ +0001bb70: 6d5f 6163 6365 7074 5f66 6173 745f 7069 m_accept_fast_pi │ │ │ +0001bb80: 6563 655f 636e 745b 6661 7374 5f69 6478 ece_cnt[fast_idx │ │ │ +0001bb90: 5d20 2667 743b 3d20 3320 2a20 626c 6f63 ] >= 3 * bloc │ │ │ +0001bba0: 6b73 5f70 6572 5f70 6965 6365 0a09 0909 ks_per_piece.... │ │ │ +0001bbb0: 2661 6d70 3b26 616d 703b 2063 616e 5f64 && can_d │ │ │ +0001bbc0: 6973 636f 6e6e 6563 7428 6572 726f 7273 isconnect(errors │ │ │ +0001bbd0: 3a3a 746f 6f5f 6d61 6e79 5f72 6571 7565 ::too_many_reque │ │ │ +0001bbe0: 7374 735f 7768 656e 5f63 686f 6b65 6429 sts_when_choked) │ │ │ +0001bbf0: 290a 0909 7b0a 0909 0964 6973 636f 6e6e )...{....disconn │ │ │ +0001bc00: 6563 7428 6572 726f 7273 3a3a 746f 6f5f ect(errors::too_ │ │ │ +0001bc10: 6d61 6e79 5f72 6571 7565 7374 735f 7768 many_requests_wh │ │ │ +0001bc20: 656e 5f63 686f 6b65 642c 206f 7065 7261 en_choked, opera │ │ │ +0001bc30: 7469 6f6e 5f74 3a3a 6269 7474 6f72 7265 tion_t::bittorre │ │ │ +0001bc40: 6e74 2c20 7065 6572 5f65 7272 6f72 293b nt, peer_error); │ │ │ +0001bc50: 0a09 0909 7265 7475 726e 3b0a 0909 7d0a ....return;...}. │ │ │ +0001bc60: 0a09 0969 6620 286d 5f63 686f 6b65 6420 ...if (m_choked │ │ │ +0001bc70: 2661 6d70 3b26 616d 703b 2066 6173 745f && fast_ │ │ │ +0001bc80: 6964 7820 3d3d 202d 3129 0a09 097b 0a3c idx == -1)...{.< │ │ │ +0001bc90: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +0001bca0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +0001bcb0: 6f75 6e64 3a20 2363 6663 223e 3c74 643e ound: #cfc"> │ │ │ +0001bcc0: 7265 6c65 7661 6e63 6526 6e62 7370 3b32 relevance 2 │ │ │ +0001bcd0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src/ │ │ │ +0001bd00: 7065 6572 5f63 6f6e 6e65 6374 696f 6e2e peer_connection. │ │ │ +0001bd10: 6370 703a 3333 3233 3c2f 613e 3c2f 7464 cpp:3323since we th │ │ │ +0001bd30: 726f 7720 6177 6179 2074 6865 2071 7565 row away the que │ │ │ +0001bd40: 7565 2065 6e74 7279 206f 6e63 6520 7765 ue entry once we │ │ │ +0001bd50: 2069 7373 7565 2074 6865 2064 6973 6b20 issue the disk │ │ │ +0001bd60: 6a6f 622c 2074 6869 7320 6d61 7920 6861 job, this may ha │ │ │ +0001bd70: 7070 656e 2e20 496e 7374 6561 642c 2077 ppen. Instead, w │ │ │ +0001bd80: 6520 7368 6f75 6c64 206b 6565 7020 7468 e should keep th │ │ │ +0001bd90: 6520 7175 6575 6520 656e 7472 7920 6172 e queue entry ar │ │ │ +0001bda0: 6f75 6e64 2c20 6d61 726b 2069 7420 6173 ound, mark it as │ │ │ +0001bdb0: 2068 6176 696e 6720 6265 656e 2072 6571 having been req │ │ │ +0001bdc0: 7565 7374 6564 2066 726f 6d20 6469 736b uested from disk │ │ │ +0001bdd0: 2061 6e64 206f 6e63 6520 7468 6520 6469 and once the di │ │ │ +0001bde0: 736b 206a 6f62 2063 6f6d 6573 2062 6163 sk job comes bac │ │ │ +0001bdf0: 6b2c 2064 6973 6361 7264 2069 7420 6966 k, discard it if │ │ │ +0001be00: 2069 7420 6861 7320 6265 656e 2063 616e it has been can │ │ │ +0001be10: 6365 6c6c 6564 2e20 4d61 7962 6520 6576 celled. Maybe ev │ │ │ +0001be20: 656e 2062 6520 6162 6c65 2074 6f20 6361 en be able to ca │ │ │ +0001be30: 6e63 656c 2064 6973 6b20 6a6f 6273 3f3c ncel disk jobs?< │ │ │ +0001be40: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    sinc │ │ │ +0001be90: 6520 7765 2074 6872 6f77 2061 7761 7920 e we throw away │ │ │ +0001bea0: 7468 6520 7175 6575 6520 656e 7472 7920 the queue entry │ │ │ +0001beb0: 6f6e 6365 2077 6520 6973 7375 650a 7468 once we issue.th │ │ │ +0001bec0: 6520 6469 736b 206a 6f62 2c20 7468 6973 e disk job, this │ │ │ +0001bed0: 206d 6179 2068 6170 7065 6e2e 2049 6e73 may happen. Ins │ │ │ +0001bee0: 7465 6164 2c20 7765 2073 686f 756c 6420 tead, we should │ │ │ +0001bef0: 6b65 6570 2074 6865 0a71 7565 7565 2065 keep the.queue e │ │ │ +0001bf00: 6e74 7279 2061 726f 756e 642c 206d 6172 ntry around, mar │ │ │ +0001bf10: 6b20 6974 2061 7320 6861 7669 6e67 2062 k it as having b │ │ │ +0001bf20: 6565 6e20 7265 7175 6573 7465 6420 6672 een requested fr │ │ │ +0001bf30: 6f6d 0a64 6973 6b20 616e 6420 6f6e 6365 om.disk and once │ │ │ +0001bf40: 2074 6865 2064 6973 6b20 6a6f 6220 636f the disk job co │ │ │ +0001bf50: 6d65 7320 6261 636b 2c20 6469 7363 6172 mes back, discar │ │ │ +0001bf60: 6420 6974 2069 6620 6974 2068 6173 0a62 d it if it has.b │ │ │ +0001bf70: 6565 6e20 6361 6e63 656c 6c65 642e 204d een cancelled. M │ │ │ +0001bf80: 6179 6265 2065 7665 6e20 6265 2061 626c aybe even be abl │ │ │ +0001bf90: 6520 746f 2063 616e 6365 6c20 6469 736b e to cancel disk │ │ │ +0001bfa0: 206a 6f62 733f 3c2f 6832 3e3c 6834 3e2e jobs?

    . │ │ │ +0001bfb0: 2e2f 7372 632f 7065 6572 5f63 6f6e 6e65 ./src/peer_conne │ │ │ +0001bfc0: 6374 696f 6e2e 6370 703a 3333 3233 3c2f ction.cpp:3323
    .#i
    │ │ │ +0001c010: 666e 6465 6620 544f 5252 454e 545f 4449  fndef TORRENT_DI
    │ │ │ +0001c020: 5341 424c 455f 4c4f 4747 494e 470a 0909  SABLE_LOGGING...
    │ │ │ +0001c030: 7065 6572 5f6c 6f67 2870 6565 725f 6c6f  peer_log(peer_lo
    │ │ │ +0001c040: 675f 616c 6572 743a 3a69 6e63 6f6d 696e  g_alert::incomin
    │ │ │ +0001c050: 675f 6d65 7373 6167 652c 2022 4341 4e43  g_message, "CANC
    │ │ │ +0001c060: 454c 220a 0909 092c 2022 7069 6563 653a  EL"...., "piece:
    │ │ │ +0001c070: 2025 6420 733a 2025 7820 6c3a 2025 7822   %d s: %x l: %x"
    │ │ │ +0001c080: 2c20 7374 6174 6963 5f63 6173 7426 6c74  , static_cast<
    │ │ │ +0001c090: 3b69 6e74 2667 743b 2872 2e70 6965 6365  ;int>(r.piece
    │ │ │ +0001c0a0: 292c 2073 7464 3a3a 7569 6e74 3332 5f74  ), std::uint32_t
    │ │ │ +0001c0b0: 2872 2e73 7461 7274 292c 2073 7464 3a3a  (r.start), std::
    │ │ │ +0001c0c0: 7569 6e74 3332 5f74 2872 2e6c 656e 6774  uint32_t(r.lengt
    │ │ │ +0001c0d0: 6829 293b 0a23 656e 6469 660a 0a09 0961  h));.#endif....a
    │ │ │ +0001c0e0: 7574 6f20 636f 6e73 7420 6920 3d20 7374  uto const i = st
    │ │ │ +0001c0f0: 643a 3a66 696e 6428 6d5f 7265 7175 6573  d::find(m_reques
    │ │ │ +0001c100: 7473 2e62 6567 696e 2829 2c20 6d5f 7265  ts.begin(), m_re
    │ │ │ +0001c110: 7175 6573 7473 2e65 6e64 2829 2c20 7229  quests.end(), r)
    │ │ │ +0001c120: 3b0a 0a09 0969 6620 2869 2021 3d20 6d5f  ;....if (i != m_
    │ │ │ +0001c130: 7265 7175 6573 7473 2e65 6e64 2829 290a  requests.end()).
    │ │ │ +0001c140: 0909 7b0a 0909 096d 5f63 6f75 6e74 6572  ..{....m_counter
    │ │ │ +0001c150: 732e 696e 635f 7374 6174 735f 636f 756e  s.inc_stats_coun
    │ │ │ +0001c160: 7465 7228 636f 756e 7465 7273 3a3a 6361  ter(counters::ca
    │ │ │ +0001c170: 6e63 656c 6c65 645f 7069 6563 655f 7265  ncelled_piece_re
    │ │ │ +0001c180: 7175 6573 7473 293b 0a09 0909 6d5f 7265  quests);....m_re
    │ │ │ +0001c190: 7175 6573 7473 2e65 7261 7365 2869 293b  quests.erase(i);
    │ │ │ +0001c1a0: 0a0a 0909 0969 6620 286d 5f72 6571 7565  .....if (m_reque
    │ │ │ +0001c1b0: 7374 732e 656d 7074 7928 2929 0a09 0909  sts.empty())....
    │ │ │ +0001c1c0: 096d 5f63 6f75 6e74 6572 732e 696e 635f  .m_counters.inc_
    │ │ │ +0001c1d0: 7374 6174 735f 636f 756e 7465 7228 636f  stats_counter(co
    │ │ │ +0001c1e0: 756e 7465 7273 3a3a 6e75 6d5f 7065 6572  unters::num_peer
    │ │ │ +0001c1f0: 735f 7570 5f72 6571 7565 7374 732c 202d  s_up_requests, -
    │ │ │ +0001c200: 3129 3b0a 0a09 0909 7772 6974 655f 7265  1);.....write_re
    │ │ │ +0001c210: 6a65 6374 5f72 6571 7565 7374 2872 293b  ject_request(r);
    │ │ │ +0001c220: 0a09 097d 0a09 0965 6c73 650a 0909 7b0a  ...}...else...{.
    │ │ │ +0001c230: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    #i │ │ │ +0001c260: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ +0001c270: 5341 424c 455f 4c4f 4747 494e 470a 3c2f SABLE_LOGGING....peer_log( │ │ │ +0001c290: 7065 6572 5f6c 6f67 5f61 6c65 7274 3a3a peer_log_alert:: │ │ │ +0001c2a0: 696e 666f 2c20 2249 4e56 414c 4944 5f43 info, "INVALID_C │ │ │ +0001c2b0: 414e 4345 4c22 2c20 2267 6f74 2063 616e ANCEL", "got can │ │ │ +0001c2c0: 6365 6c20 6e6f 7420 696e 2074 6865 2071 cel not in the q │ │ │ +0001c2d0: 7565 7565 2229 3b0a 2365 6e64 6966 0a09 ueue");.#endif.. │ │ │ +0001c2e0: 097d 0a09 7d0a 0a09 2f2f 202d 2d2d 2d2d .}..}...// ----- │ │ │ +0001c2f0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +0001c300: 2d2d 2d2d 2d2d 2d2d 0a09 2f2f 202d 2d2d --------..// --- │ │ │ +0001c310: 2d2d 2d2d 2d2d 2044 4854 2050 4f52 5420 ------ DHT PORT │ │ │ +0001c320: 2d2d 2d2d 2d2d 2d2d 2d2d 0a09 2f2f 202d ----------..// - │ │ │ +0001c330: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +0001c340: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 0a0a 0976 ------------...v │ │ │ +0001c350: 6f69 6420 7065 6572 5f63 6f6e 6e65 6374 oid peer_connect │ │ │ +0001c360: 696f 6e3a 3a69 6e63 6f6d 696e 675f 6468 ion::incoming_dh │ │ │ +0001c370: 745f 706f 7274 2869 6e74 2063 6f6e 7374 t_port(int const │ │ │ +0001c380: 206c 6973 7465 6e5f 706f 7274 290a 097b listen_port)..{ │ │ │ +0001c390: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0001c3a0: 5428 6973 5f73 696e 676c 655f 7468 7265 T(is_single_thre │ │ │ +0001c3b0: 6164 2829 293b 0a09 0949 4e56 4152 4941 ad());...INVARIA │ │ │ +0001c3c0: 4e54 5f43 4845 434b 3b0a 0a23 6966 6e64 NT_CHECK;..#ifnd │ │ │ +0001c3d0: 6566 2054 4f52 5245 4e54 5f44 4953 4142 ef TORRENT_DISAB │ │ │ +0001c3e0: 4c45 5f4c 4f47 4749 4e47 0a09 0970 6565 LE_LOGGING...pee │ │ │ +0001c3f0: 725f 6c6f 6728 7065 6572 5f6c 6f67 5f61 r_log(peer_log_a │ │ │ +0001c400: 6c65 7274 3a3a 696e 636f 6d69 6e67 5f6d lert::incoming_m │ │ │ +0001c410: 6573 7361 6765 2c20 2244 4854 5f50 4f52 essage, "DHT_POR │ │ │ +0001c420: 5422 2c20 2270 3a20 2564 222c 206c 6973 T", "p: %d", lis │ │ │ +0001c430: 7465 6e5f 706f 7274 293b 0a23 656e 6469 ten_port);.#endi │ │ │ +0001c440: 660a 2369 666e 6465 6620 544f 5252 454e f.#ifndef TORREN │ │ │ +0001c450: 545f 4449 5341 424c 455f 4448 540a 0909 T_DISABLE_DHT... │ │ │ +0001c460: 6d5f 7365 732e 6164 645f 6468 745f 6e6f m_ses.add_dht_no │ │ │ +0001c470: 6465 287b 6d5f 7265 6d6f 7465 2e61 6464 de({m_remote.add │ │ │ +0001c480: 7265 7373 2829 2c20 7374 643a 3a75 696e ress(), std::uin │ │ │ +0001c490: 7431 365f 7428 6c69 7374 656e 5f70 6f72 t16_t(listen_por │ │ │ +0001c4a0: 7429 7d29 3b0a 2365 6c73 650a 0909 544f t)});.#else...TO │ │ │ +0001c4b0: 5252 454e 545f 554e 5553 4544 286c 6973 RRENT_UNUSED(lis │ │ │ +0001c4c0: 7465 6e5f 706f 7274 293b 0a23 656e 6469 ten_port);.#endi │ │ │ +0001c4d0: 660a 097d 0a0a 092f 2f20 2d2d 2d2d 2d2d f..}...// ------ │ │ │ +0001c4e0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +0001c4f0: 2d2d 2d2d 2d2d 2d0a 092f 2f20 2d2d 2d2d -------..// ---- │ │ │ +0001c500: 2d2d 2d2d 2d20 4841 5645 2041 4c4c 202d ----- HAVE ALL - │ │ │ +0001c510: 2d2d 2d2d 2d2d 2d2d 2d0a 092f 2f20 2d2d ---------..// -- │ │ │ +0001c520: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +0001c530: 2d2d 2d2d 2d2d 2d2d 2d2d 2d0a 0a09 766f -----------...vo │ │ │ +0001c540: 6964 2070 6565 725f 636f 6e6e 6563 7469 id peer_connecti │ │ │ +0001c550: 6f6e 3a3a 696e 636f 6d69 6e67 5f68 6176 on::incoming_hav │ │ │ +0001c560: 655f 616c 6c28 290a 097b 0a3c 2f70 7265 e_all()..{.
    rele │ │ │ +0001c5a0: 7661 6e63 6526 6e62 7370 3b32 3c2f 7464 vance 2../src/peer │ │ │ +0001c5e0: 5f63 6f6e 6e65 6374 696f 6e2e 6370 703a _connection.cpp: │ │ │ +0001c5f0: 3439 3631 3c2f 613e 3c2f 7464 3e3c 7464 4961use a deadline_ │ │ │ +0001c610: 7469 6d65 7220 666f 7220 7469 6d65 6f75 timer for timeou │ │ │ +0001c620: 7473 2e20 446f 6e27 7420 7265 6c79 206f ts. Don't rely o │ │ │ +0001c630: 6e20 7365 636f 6e64 5f74 6963 6b28 2921 n second_tick()! │ │ │ +0001c640: 2048 6f6f 6b20 7468 6973 2075 7020 746f Hook this up to │ │ │ +0001c650: 2063 6f6e 6e65 6374 2074 696d 656f 7574 connect timeout │ │ │ +0001c660: 2061 7320 7765 6c6c 2e20 5468 6973 2077 as well. This w │ │ │ +0001c670: 6f75 6c64 2069 6d70 726f 7665 2070 6572 ould improve per │ │ │ +0001c680: 666f 726d 616e 6365 2062 6563 6175 7365 formance because │ │ │ +0001c690: 206f 6620 6c65 7373 2077 6f72 6b20 696e of less work in │ │ │ +0001c6a0: 2073 6563 6f6e 645f 7469 636b 2829 2c20 second_tick(), │ │ │ +0001c6b0: 616e 6420 6d69 6768 7420 6c65 7420 7573 and might let us │ │ │ +0001c6c0: 6520 7265 6d6f 7665 2074 6963 6b69 6e67 e remove ticking │ │ │ +0001c6d0: 2065 6e74 6972 656c 7920 6576 656e 7475 entirely eventu │ │ │ +0001c6e0: 616c 6c79 3c2f 7464 3e3c 2f74 723e 3c74 ally

    use a deadline_ │ │ │ +0001c740: 7469 6d65 7220 666f 7220 7469 6d65 6f75 timer for timeou │ │ │ +0001c750: 7473 2e20 446f 6e27 7420 7265 6c79 206f ts. Don't rely o │ │ │ +0001c760: 6e20 7365 636f 6e64 5f74 6963 6b28 2921 n second_tick()! │ │ │ +0001c770: 0a48 6f6f 6b20 7468 6973 2075 7020 746f .Hook this up to │ │ │ +0001c780: 2063 6f6e 6e65 6374 2074 696d 656f 7574 connect timeout │ │ │ +0001c790: 2061 7320 7765 6c6c 2e20 5468 6973 2077 as well. This w │ │ │ +0001c7a0: 6f75 6c64 2069 6d70 726f 7665 2070 6572 ould improve per │ │ │ +0001c7b0: 666f 726d 616e 6365 0a62 6563 6175 7365 formance.because │ │ │ +0001c7c0: 206f 6620 6c65 7373 2077 6f72 6b20 696e of less work in │ │ │ +0001c7d0: 2073 6563 6f6e 645f 7469 636b 2829 2c20 second_tick(), │ │ │ +0001c7e0: 616e 6420 6d69 6768 7420 6c65 7420 7573 and might let us │ │ │ +0001c7f0: 6520 7265 6d6f 7665 2074 6963 6b69 6e67 e remove ticking │ │ │ +0001c800: 0a65 6e74 6972 656c 7920 6576 656e 7475 .entirely eventu │ │ │ +0001c810: 616c 6c79 3c2f 6832 3e3c 6834 3e2e 2e2f ally

    ../ │ │ │ +0001c820: 7372 632f 7065 6572 5f63 6f6e 6e65 6374 src/peer_connect │ │ │ +0001c830: 696f 6e2e 6370 703a 3439 3631 3c2f 6834 ion.cpp:4961

    ...if
    │ │ │ +0001c880: 2028 6420 2667 743b 2073 6563 6f6e 6473   (d > seconds
    │ │ │ +0001c890: 2863 6f6e 6e65 6374 5f74 696d 656f 7574  (connect_timeout
    │ │ │ +0001c8a0: 290a 0909 0909 2661 6d70 3b26 616d 703b  ).....&&
    │ │ │ +0001c8b0: 2063 616e 5f64 6973 636f 6e6e 6563 7428   can_disconnect(
    │ │ │ +0001c8c0: 6572 726f 7273 3a3a 7469 6d65 645f 6f75  errors::timed_ou
    │ │ │ +0001c8d0: 7429 290a 0909 097b 0a23 6966 6e64 6566  t))....{.#ifndef
    │ │ │ +0001c8e0: 2054 4f52 5245 4e54 5f44 4953 4142 4c45   TORRENT_DISABLE
    │ │ │ +0001c8f0: 5f4c 4f47 4749 4e47 0a09 0909 0970 6565  _LOGGING.....pee
    │ │ │ +0001c900: 725f 6c6f 6728 7065 6572 5f6c 6f67 5f61  r_log(peer_log_a
    │ │ │ +0001c910: 6c65 7274 3a3a 696e 666f 2c20 2243 4f4e  lert::info, "CON
    │ │ │ +0001c920: 4e45 4354 5f46 4149 4c45 4422 2c20 2277  NECT_FAILED", "w
    │ │ │ +0001c930: 6169 7465 6420 2564 2073 6563 6f6e 6473  aited %d seconds
    │ │ │ +0001c940: 220a 0909 0909 092c 2069 6e74 2874 6f74  "......, int(tot
    │ │ │ +0001c950: 616c 5f73 6563 6f6e 6473 2864 2929 293b  al_seconds(d)));
    │ │ │ +0001c960: 0a23 656e 6469 660a 0909 0909 636f 6e6e  .#endif.....conn
    │ │ │ +0001c970: 6563 745f 6661 696c 6564 2865 7272 6f72  ect_failed(error
    │ │ │ +0001c980: 733a 3a74 696d 6564 5f6f 7574 293b 0a09  s::timed_out);..
    │ │ │ +0001c990: 0909 0972 6574 7572 6e3b 0a09 0909 7d0a  ...return;....}.
    │ │ │ +0001c9a0: 0909 7d0a 0a09 092f 2f20 6966 2074 6865  ..}....// if the
    │ │ │ +0001c9b0: 2062 775f 6e65 7477 6f72 6b20 666c 6167   bw_network flag
    │ │ │ +0001c9c0: 2069 736e 2774 2073 6574 2c20 6974 206d   isn't set, it m
    │ │ │ +0001c9d0: 6561 6e73 2077 6520 6172 6520 6e6f 7420  eans we are not 
    │ │ │ +0001c9e0: 6576 656e 2074 7279 696e 6720 746f 0a09  even trying to..
    │ │ │ +0001c9f0: 092f 2f20 7265 6164 2066 726f 6d20 7468  .// read from th
    │ │ │ +0001ca00: 6973 2070 6565 7227 7320 736f 636b 6574  is peer's socket
    │ │ │ +0001ca10: 2e20 4d6f 7374 206c 696b 656c 7920 6265  . Most likely be
    │ │ │ +0001ca20: 6361 7573 6520 7765 2772 6520 6170 706c  cause we're appl
    │ │ │ +0001ca30: 7969 6e67 2061 0a09 092f 2f20 7261 7465  ying a...// rate
    │ │ │ +0001ca40: 206c 696d 6974 2e20 4966 2074 6865 2070   limit. If the p
    │ │ │ +0001ca50: 6565 7220 6973 2022 736c 6f77 2220 6265  eer is "slow" be
    │ │ │ +0001ca60: 6361 7573 6520 7765 2061 7265 2072 6174  cause we are rat
    │ │ │ +0001ca70: 6520 6c69 6d69 7469 6e67 2069 742c 0a09  e limiting it,..
    │ │ │ +0001ca80: 092f 2f20 646f 6e27 7420 656e 666f 7263  .// don't enforc
    │ │ │ +0001ca90: 6520 7469 6d65 6f75 7473 2e20 486f 7765  e timeouts. Howe
    │ │ │ +0001caa0: 7665 722c 2061 7320 736f 6f6e 2061 7320  ver, as soon as 
    │ │ │ +0001cab0: 7765 202a 646f 2a20 7265 6164 2066 726f  we *do* read fro
    │ │ │ +0001cac0: 6d20 7468 650a 0909 2f2f 2073 6f63 6b65  m the...// socke
    │ │ │ +0001cad0: 742c 2077 6520 6578 7065 6374 2074 6f20  t, we expect to 
    │ │ │ +0001cae0: 7265 6365 6976 6520 6461 7461 2c20 616e  receive data, an
    │ │ │ +0001caf0: 6420 6e6f 7420 6861 7665 2074 696d 6564  d not have timed
    │ │ │ +0001cb00: 206f 7574 2e20 5468 656e 2077 650a 0909   out. Then we...
    │ │ │ +0001cb10: 2f2f 2063 616e 2065 6e66 6f72 6365 2074  // can enforce t
    │ │ │ +0001cb20: 6865 2074 696d 656f 7574 732e 0a09 0962  he timeouts....b
    │ │ │ +0001cb30: 6f6f 6c20 636f 6e73 7420 7265 6164 696e  ool const readin
    │ │ │ +0001cb40: 675f 736f 636b 6574 203d 2062 6f6f 6c28  g_socket = bool(
    │ │ │ +0001cb50: 6d5f 6368 616e 6e65 6c5f 7374 6174 655b  m_channel_state[
    │ │ │ +0001cb60: 646f 776e 6c6f 6164 5f63 6861 6e6e 656c  download_channel
    │ │ │ +0001cb70: 5d20 2661 6d70 3b20 7065 6572 5f69 6e66  ] & peer_inf
    │ │ │ +0001cb80: 6f3a 3a62 775f 6e65 7477 6f72 6b29 3b0a  o::bw_network);.
    │ │ │ +0001cb90: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +0001cbc0: 0969 6620 2872 6561 6469 6e67 5f73 6f63 .if (reading_soc │ │ │ +0001cbd0: 6b65 7420 2661 6d70 3b26 616d 703b 2064 ket && d │ │ │ +0001cbe0: 2026 6774 3b20 7365 636f 6e64 7328 7469 > seconds(ti │ │ │ +0001cbf0: 6d65 6f75 7428 2929 2026 616d 703b 2661 meout()) &&a │ │ │ +0001cc00: 6d70 3b20 216d 5f63 6f6e 6e65 6374 696e mp; !m_connectin │ │ │ +0001cc10: 6720 2661 6d70 3b26 616d 703b 206d 5f72 g && m_r │ │ │ +0001cc20: 6561 6469 6e67 5f62 7974 6573 203d 3d20 eading_bytes == │ │ │ +0001cc30: 300a 3c2f 6469 763e 0909 0926 616d 703b 0.
    ...& │ │ │ +0001cc40: 2661 6d70 3b20 6361 6e5f 6469 7363 6f6e & can_discon │ │ │ +0001cc50: 6e65 6374 2865 7272 6f72 733a 3a74 696d nect(errors::tim │ │ │ +0001cc60: 6564 5f6f 7574 5f69 6e61 6374 6976 6974 ed_out_inactivit │ │ │ +0001cc70: 7929 290a 0909 7b0a 2369 666e 6465 6620 y))...{.#ifndef │ │ │ +0001cc80: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ +0001cc90: 4c4f 4747 494e 470a 0909 0970 6565 725f LOGGING....peer_ │ │ │ +0001cca0: 6c6f 6728 7065 6572 5f6c 6f67 5f61 6c65 log(peer_log_ale │ │ │ +0001ccb0: 7274 3a3a 696e 666f 2c20 224c 4153 545f rt::info, "LAST_ │ │ │ +0001ccc0: 4143 5449 5649 5459 222c 2022 2564 2073 ACTIVITY", "%d s │ │ │ +0001ccd0: 6563 6f6e 6473 2061 676f 220a 0909 0909 econds ago"..... │ │ │ +0001cce0: 2c20 696e 7428 746f 7461 6c5f 7365 636f , int(total_seco │ │ │ +0001ccf0: 6e64 7328 6429 2929 3b0a 2365 6e64 6966 nds(d)));.#endif │ │ │ +0001cd00: 0a09 0909 6469 7363 6f6e 6e65 6374 2865 ....disconnect(e │ │ │ +0001cd10: 7272 6f72 733a 3a74 696d 6564 5f6f 7574 rrors::timed_out │ │ │ +0001cd20: 5f69 6e61 6374 6976 6974 792c 206f 7065 _inactivity, ope │ │ │ +0001cd30: 7261 7469 6f6e 5f74 3a3a 6269 7474 6f72 ration_t::bittor │ │ │ +0001cd40: 7265 6e74 293b 0a09 0909 7265 7475 726e rent);....return │ │ │ +0001cd50: 3b0a 0909 7d0a 0a09 092f 2f20 646f 206e ;...}....// do n │ │ │ +0001cd60: 6f74 2073 7461 6c6c 2077 6169 7469 6e67 ot stall waiting │ │ │ +0001cd70: 2066 6f72 2061 2068 616e 6473 6861 6b65 for a handshake │ │ │ +0001cd80: 0a09 0969 6e74 2074 696d 656f 7574 203d ...int timeout = │ │ │ +0001cd90: 206d 5f73 6574 7469 6e67 732e 6765 745f m_settings.get_ │ │ │ +0001cda0: 696e 7420 2873 6574 7469 6e67 735f 7061 int (settings_pa │ │ │ +0001cdb0: 636b 3a3a 6861 6e64 7368 616b 655f 7469 ck::handshake_ti │ │ │ +0001cdc0: 6d65 6f75 7429 3b0a 2369 6620 544f 5252 meout);.#if TORR │ │ │ +0001cdd0: 454e 545f 5553 455f 4932 500a 0909 7469 ENT_USE_I2P...ti │ │ │ +0001cde0: 6d65 6f75 7420 2a3d 2069 735f 6932 7028 meout *= is_i2p( │ │ │ +0001cdf0: 6d5f 736f 636b 6574 2920 3f20 3420 3a20 m_socket) ? 4 : │ │ │ +0001ce00: 313b 0a23 656e 6469 660a 0909 6966 2028 1;.#endif...if ( │ │ │ +0001ce10: 7265 6164 696e 675f 736f 636b 6574 0a09 reading_socket.. │ │ │ +0001ce20: 0909 2661 6d70 3b26 616d 703b 2021 6d5f ..&& !m_ │ │ │ +0001ce30: 636f 6e6e 6563 7469 6e67 0a09 0909 2661 connecting....&a │ │ │ +0001ce40: 6d70 3b26 616d 703b 2069 6e5f 6861 6e64 mp;& in_hand │ │ │ +0001ce50: 7368 616b 6528 290a 0909 0926 616d 703b shake()....& │ │ │ +0001ce60: 2661 6d70 3b20 6420 2667 743b 2073 6563 & d > sec │ │ │ +0001ce70: 6f6e 6473 2874 696d 656f 7574 2929 0a09 onds(timeout)).. │ │ │ +0001ce80: 097b 0a23 6966 6e64 6566 2054 4f52 5245 .{.#ifndef TORRE │ │ │ +0001ce90: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749 NT_DISABLE_LOGGI │ │ │ +0001cea0: 4e47 0a09 0909 7065 6572 5f6c 6f67 2870 NG....peer_log(p │ │ │ +0001ceb0: 6565 725f 6c6f 675f 616c 6572 743a 3a69 eer_log_alert::i │ │ │ +0001cec0: 6e66 6f2c 2022 4e4f 5f48 414e 4453 4841 nfo, "NO_HANDSHA │ │ │ +0001ced0: 4b45 222c 2022 7761 6974 6564 2025 6420 KE", "waited %d │ │ │ +0001cee0: 7365 636f 6e64 7322 0a09 0909 092c 2069 seconds"....., i │ │ │ +0001cef0: 6e74 2874 6f74 616c 5f73 6563 6f6e 6473 nt(total_seconds │ │ │ +0001cf00: 2864 2929 293b 0a23 656e 6469 660a 0909 (d)));.#endif... │ │ │ +0001cf10: 0964 6973 636f 6e6e 6563 7428 6572 726f .disconnect(erro │ │ │ +0001cf20: 7273 3a3a 7469 6d65 645f 6f75 745f 6e6f rs::timed_out_no │ │ │ +0001cf30: 5f68 616e 6473 6861 6b65 2c20 6f70 6572 _handshake, oper │ │ │ +0001cf40: 6174 696f 6e5f 743a 3a62 6974 746f 7272 ation_t::bittorr │ │ │ +0001cf50: 656e 7429 3b0a 0909 0972 6574 7572 6e3b ent);....return; │ │ │ +0001cf60: 0a09 097d 0a0a 0909 2f2f 2064 6973 636f ...}....// disco │ │ │ +0001cf70: 6e6e 6563 7420 7065 6572 7320 7468 6174 nnect peers that │ │ │ +0001cf80: 2077 6520 756e 6368 6f6b 6564 2c20 6275 we unchoked, bu │ │ │ +0001cf90: 7420 7468 6579 2064 6964 6e27 7420 7365 t they didn't se │ │ │ +0001cfa0: 6e64 2061 2072 6571 7565 7374 2069 6e0a nd a request in. │ │ │ +0001cfb0: 0909 2f2f 2074 6865 206c 6173 7420 3630 ..// the last 60 │ │ │ +0001cfc0: 2073 6563 6f6e 6473 2c20 616e 6420 7765 seconds, and we │ │ │ +0001cfd0: 2068 6176 656e 2774 2062 6565 6e20 776f haven't been wo │ │ │ +0001cfe0: 726b 696e 6720 6f6e 2073 6572 7669 6369 rking on servici │ │ │ +0001cff0: 6e67 2061 2072 6571 7565 7374 0a3c 2f70 ng a request.

    re │ │ │ +0001d030: 6c65 7661 6e63 6526 6e62 7370 3b32 3c2f levance 2../src/to │ │ │ +0001d070: 7272 656e 742e 6370 703a 3535 313c 2f61 rrent.cpp:551post a │ │ │ +0001d090: 6c65 7274 3c2f 7464 3e3c 2f74 723e 3c74 lert

    post alert

    │ │ │ +0001d0f0: 3c68 343e 2e2e 2f73 7263 2f74 6f72 7265

    ../src/torre │ │ │ +0001d100: 6e74 2e63 7070 3a35 3531 3c2f 6834 3e3c nt.cpp:551

    < │ │ │ +0001d110: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +0001d120: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +0001d130: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +0001d140: 7820 2364 6464 3b22 3e09 0969 6620 286d x #ddd;">..if (m │ │ │ +0001d150: 5f63 7572 7265 6e74 5f67 6175 6765 5f73 _current_gauge_s │ │ │ +0001d160: 7461 7465 2021 3d20 6e6f 5f67 6175 6765 tate != no_gauge │ │ │ +0001d170: 5f73 7461 7465 290a 0909 0969 6e63 5f73 _state)....inc_s │ │ │ +0001d180: 7461 7473 5f63 6f75 6e74 6572 286d 5f63 tats_counter(m_c │ │ │ +0001d190: 7572 7265 6e74 5f67 6175 6765 5f73 7461 urrent_gauge_sta │ │ │ +0001d1a0: 7465 202b 2063 6f75 6e74 6572 733a 3a6e te + counters::n │ │ │ +0001d1b0: 756d 5f63 6865 636b 696e 675f 746f 7272 um_checking_torr │ │ │ +0001d1c0: 656e 7473 2c20 2d31 293b 0a09 0969 6620 ents, -1);...if │ │ │ +0001d1d0: 286e 6577 5f67 6175 6765 5f73 7461 7465 (new_gauge_state │ │ │ +0001d1e0: 2021 3d20 6e6f 5f67 6175 6765 5f73 7461 != no_gauge_sta │ │ │ +0001d1f0: 7465 290a 0909 0969 6e63 5f73 7461 7473 te)....inc_stats │ │ │ +0001d200: 5f63 6f75 6e74 6572 286e 6577 5f67 6175 _counter(new_gau │ │ │ +0001d210: 6765 5f73 7461 7465 202b 2063 6f75 6e74 ge_state + count │ │ │ +0001d220: 6572 733a 3a6e 756d 5f63 6865 636b 696e ers::num_checkin │ │ │ +0001d230: 675f 746f 7272 656e 7473 2c20 3129 3b0a g_torrents, 1);. │ │ │ +0001d240: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0001d250: 5428 6e65 775f 6761 7567 655f 7374 6174 T(new_gauge_stat │ │ │ +0001d260: 6520 2667 743b 3d20 3029 3b0a 0909 544f e >= 0);...TO │ │ │ +0001d270: 5252 454e 545f 4153 5345 5254 286e 6577 RRENT_ASSERT(new │ │ │ +0001d280: 5f67 6175 6765 5f73 7461 7465 2026 6c74 _gauge_state < │ │ │ +0001d290: 3b3d 206e 6f5f 6761 7567 655f 7374 6174 ;= no_gauge_stat │ │ │ +0001d2a0: 6529 3b0a 0909 6d5f 6375 7272 656e 745f e);...m_current_ │ │ │ +0001d2b0: 6761 7567 655f 7374 6174 6520 3d20 7374 gauge_state = st │ │ │ +0001d2c0: 6174 6963 5f63 6173 7426 6c74 3b73 7464 atic_cast<std │ │ │ +0001d2d0: 3a3a 7569 6e74 3332 5f74 2667 743b 286e ::uint32_t>(n │ │ │ +0001d2e0: 6577 5f67 6175 6765 5f73 7461 7465 293b ew_gauge_state); │ │ │ +0001d2f0: 0a09 7d0a 0a09 766f 6964 2074 6f72 7265 ..}...void torre │ │ │ +0001d300: 6e74 3a3a 6c65 6176 655f 7365 6564 5f6d nt::leave_seed_m │ │ │ +0001d310: 6f64 6528 7365 6564 5f6d 6f64 655f 7420 ode(seed_mode_t │ │ │ +0001d320: 636f 6e73 7420 6368 6563 6b69 6e67 290a const checking). │ │ │ +0001d330: 097b 0a09 0969 6620 2821 6d5f 7365 6564 .{...if (!m_seed │ │ │ +0001d340: 5f6d 6f64 6529 2072 6574 7572 6e3b 0a0a _mode) return;.. │ │ │ +0001d350: 0909 6966 2028 6368 6563 6b69 6e67 203d ..if (checking = │ │ │ +0001d360: 3d20 7365 6564 5f6d 6f64 655f 743a 3a63 = seed_mode_t::c │ │ │ +0001d370: 6865 636b 5f66 696c 6573 290a 0909 7b0a heck_files)...{. │ │ │ +0001d380: 0909 092f 2f20 7468 6973 206d 6561 6e73 ...// this means │ │ │ +0001d390: 2074 6865 2075 7365 7220 7072 6f6d 6973 the user promis │ │ │ +0001d3a0: 6564 2077 6520 6861 6420 616c 6c20 7468 ed we had all th │ │ │ +0001d3b0: 650a 0909 092f 2f20 6669 6c65 732c 2062 e....// files, b │ │ │ +0001d3c0: 7574 2069 7420 7475 726e 6564 206f 7574 ut it turned out │ │ │ +0001d3d0: 2077 6520 6469 646e 2774 2e20 5468 6973 we didn't. This │ │ │ +0001d3e0: 2069 730a 0909 092f 2f20 616e 2065 7272 is....// an err │ │ │ +0001d3f0: 6f72 2e0a 0a3c 6469 7620 7374 796c 653d or...
    .
    #ifnde │ │ │ +0001d430: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ +0001d440: 455f 4c4f 4747 494e 470a 0909 0964 6562 E_LOGGING....deb │ │ │ +0001d450: 7567 5f6c 6f67 2822 2a2a 2a20 4641 494c ug_log("*** FAIL │ │ │ +0001d460: 4544 2053 4545 4420 4d4f 4445 2c20 7265 ED SEED MODE, re │ │ │ +0001d470: 6368 6563 6b69 6e67 2229 3b0a 2365 6e64 checking");.#end │ │ │ +0001d480: 6966 0a09 097d 0a0a 2369 666e 6465 6620 if...}..#ifndef │ │ │ +0001d490: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ +0001d4a0: 4c4f 4747 494e 470a 0909 6465 6275 675f LOGGING...debug_ │ │ │ +0001d4b0: 6c6f 6728 222a 2a2a 204c 4541 5649 4e47 log("*** LEAVING │ │ │ +0001d4c0: 2053 4545 4420 4d4f 4445 2028 2573 2922 SEED MODE (%s)" │ │ │ +0001d4d0: 0a09 0909 2c20 6368 6563 6b69 6e67 203d ...., checking = │ │ │ +0001d4e0: 3d20 7365 6564 5f6d 6f64 655f 743a 3a73 = seed_mode_t::s │ │ │ +0001d4f0: 6b69 705f 6368 6563 6b69 6e67 203f 2022 kip_checking ? " │ │ │ +0001d500: 6173 2073 6565 6422 203a 2022 6173 206e as seed" : "as n │ │ │ +0001d510: 6f6e 2d73 6565 6422 293b 0a23 656e 6469 on-seed");.#endi │ │ │ +0001d520: 660a 0909 6d5f 7365 6564 5f6d 6f64 6520 f...m_seed_mode │ │ │ +0001d530: 3d20 6661 6c73 653b 0a09 092f 2f20 6d5f = false;...// m_ │ │ │ +0001d540: 7365 6564 5f6d 6f64 6520 6973 206f 6e65 seed_mode is one │ │ │ +0001d550: 206f 6620 6973 5f73 6565 6428 2927 7320 of is_seed()'s │ │ │ +0001d560: 696e 7075 7473 2c20 616e 6420 7365 745f inputs, and set_ │ │ │ +0001d570: 6861 7665 5f61 6c6c 2829 2062 656c 6f77 have_all() below │ │ │ +0001d580: 0a09 092f 2f20 6f6e 6c79 2072 6561 6374 ...// only react │ │ │ +0001d590: 7320 746f 206d 5f68 6176 655f 616c 6c20 s to m_have_all │ │ │ +0001d5a0: 6368 616e 6769 6e67 2c20 736f 2066 6c75 changing, so flu │ │ │ +0001d5b0: 7368 2f72 652d 616e 6368 6f72 2074 6865 sh/re-anchor the │ │ │ +0001d5c0: 2074 696d 6572 730a 0909 2f2f 2068 6572 timers...// her │ │ │ +0001d5d0: 6520 6578 706c 6963 6974 6c79 0a09 0975 e explicitly...u │ │ │ +0001d5e0: 7064 6174 655f 7374 6174 655f 7469 6d65 pdate_state_time │ │ │ +0001d5f0: 7273 2829 3b0a 0909 2f2f 2073 6565 6420 rs();...// seed │ │ │ +0001d600: 6973 2066 616c 7365 2069 6620 7765 2074 is false if we t │ │ │ +0001d610: 7572 6e65 6420 6f75 7420 6e6f 740a 0909 urned out not... │ │ │ +0001d620: 2f2f 2074 6f20 6265 2061 2073 6565 6420 // to be a seed │ │ │ +0001d630: 6166 7465 7220 616c 6c0a 0909 6966 2028 after all...if ( │ │ │ +0001d640: 6368 6563 6b69 6e67 203d 3d20 7365 6564 checking == seed │ │ │ +0001d650: 5f6d 6f64 655f 743a 3a63 6865 636b 5f66 _mode_t::check_f │ │ │ +0001d660: 696c 6573 0a09 0909 2661 6d70 3b26 616d iles....&&am │ │ │ +0001d670: 703b 2073 7461 7465 2829 2021 3d20 746f p; state() != to │ │ │ +0001d680: 7272 656e 745f 7374 6174 7573 3a3a 6368 rrent_status::ch │ │ │ +0001d690: 6563 6b69 6e67 5f72 6573 756d 655f 6461 ecking_resume_da │ │ │ +0001d6a0: 7461 290a 0909 7b0a 0909 0973 6574 5f68 ta)...{....set_h │ │ │ +0001d6b0: 6176 655f 616c 6c28 6661 6c73 6529 3b0a ave_all(false);. │ │ │ +0001d6c0: 0909 0973 6574 5f73 7461 7465 2874 6f72 ...set_state(tor │ │ │ +0001d6d0: 7265 6e74 5f73 7461 7475 733a 3a64 6f77 rent_status::dow │ │ │ +0001d6e0: 6e6c 6f61 6469 6e67 293b 0a09 0909 666f nloading);....fo │ │ │ +0001d6f0: 7263 655f 7265 6368 6563 6b28 293b 0a09 rce_recheck();.. │ │ │ +0001d700: 097d 0a09 096d 5f6e 756d 5f76 6572 6966 .}...m_num_verif │ │ │ +0001d710: 6965 6420 3d20 303b 0a09 096d 5f76 6572 ied = 0;...m_ver │ │ │ +0001d720: 6966 6965 642e 636c 6561 7228 293b 0a09 ified.clear();.. │ │ │ +0001d730: 096d 5f76 6572 6966 7969 6e67 2e63 6c65 .m_verifying.cle │ │ │ +0001d740: 6172 2829 3b0a 0a09 0973 6574 5f6e 6565 ar();....set_nee │ │ │ +0001d750: 645f 7361 7665 5f72 6573 756d 6528 746f d_save_resume(to │ │ │ +0001d760: 7272 656e 745f 6861 6e64 6c65 3a3a 6966 rrent_handle::if │ │ │ +0001d770: 5f73 7461 7465 5f63 6861 6e67 6564 293b _state_changed); │ │ │ +0001d780: 0a09 7d0a 0a3c 2f70 7265 3e3c 2f74 643e ..}..
    │ │ │ +0001d790: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +0001d7c0: 6e62 7370 3b32 3c2f 7464 3e3c 7464 3e3c nbsp;2< │ │ │ +0001d7d0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +0001d7e0: 7074 3a65 7870 616e 6428 3538 2922 3e2e pt:expand(58)">. │ │ │ +0001d7f0: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ +0001d800: 703a 3139 3338 3c2f 613e 3c2f 7464 3e3c p:1938< │ │ │ +0001d810: 7464 3e61 6464 2061 2075 6e69 7420 7465 td>add a unit te │ │ │ +0001d820: 7374 2077 6865 7265 2077 6520 646f 6e27 st where we don' │ │ │ +0001d830: 7420 6861 7665 206d 6574 6164 6174 612c t have metadata, │ │ │ +0001d840: 2063 6f6e 6e65 6374 2074 6f20 6120 7065 connect to a pe │ │ │ +0001d850: 6572 2074 6861 7420 7365 6e64 7320 6120 er that sends a │ │ │ +0001d860: 6269 7466 6965 6c64 2074 6861 7427 7320 bitfield that's │ │ │ +0001d870: 746f 6f20 6c61 7267 652c 2074 6865 6e20 too large, then │ │ │ +0001d880: 7765 2067 6574 2074 6865 206d 6574 6164 we get the metad │ │ │ +0001d890: 6174 613c 2f74 643e 3c2f 7472 3e3c 7472 ata

    │ │ │ +0001d8e0: 6164 6420 6120 756e 6974 2074 6573 7420 add a unit test │ │ │ +0001d8f0: 7768 6572 6520 7765 2064 6f6e 2774 2068 where we don't h │ │ │ +0001d900: 6176 6520 6d65 7461 6461 7461 2c20 636f ave metadata, co │ │ │ +0001d910: 6e6e 6563 7420 746f 2061 2070 6565 720a nnect to a peer. │ │ │ +0001d920: 7468 6174 2073 656e 6473 2061 2062 6974 that sends a bit │ │ │ +0001d930: 6669 656c 6420 7468 6174 2773 2074 6f6f field that's too │ │ │ +0001d940: 206c 6172 6765 2c20 7468 656e 2077 6520 large, then we │ │ │ +0001d950: 6765 7420 7468 6520 6d65 7461 6461 7461 get the metadata │ │ │ +0001d960: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +0001d970: 746f 7272 656e 742e 6370 703a 3139 3338 torrent.cpp:1938 │ │ │ +0001d980: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +0001d9c0: 0909 666f 7220 2861 7574 6f20 636f 6e73  ..for (auto cons
    │ │ │ +0001d9d0: 7426 616d 703b 2066 203a 206d 5f61 6464  t& f : m_add
    │ │ │ +0001d9e0: 5f74 6f72 7265 6e74 5f70 6172 616d 732d  _torrent_params-
    │ │ │ +0001d9f0: 2667 743b 7265 6e61 6d65 645f 6669 6c65  >renamed_file
    │ │ │ +0001da00: 7329 0a09 0909 7b0a 0909 0909 6966 2028  s)....{.....if (
    │ │ │ +0001da10: 662e 6669 7273 7420 266c 743b 2066 696c  f.first < fil
    │ │ │ +0001da20: 655f 696e 6465 785f 7428 3029 207c 7c20  e_index_t(0) || 
    │ │ │ +0001da30: 662e 6669 7273 7420 2667 743b 3d20 6673  f.first >= fs
    │ │ │ +0001da40: 2e65 6e64 5f66 696c 6528 2929 2063 6f6e  .end_file()) con
    │ │ │ +0001da50: 7469 6e75 653b 0a09 0909 096d 5f74 6f72  tinue;.....m_tor
    │ │ │ +0001da60: 7265 6e74 5f66 696c 652d 2667 743b 7265  rent_file->re
    │ │ │ +0001da70: 6e61 6d65 5f66 696c 6528 6669 6c65 5f69  name_file(file_i
    │ │ │ +0001da80: 6e64 6578 5f74 2866 2e66 6972 7374 292c  ndex_t(f.first),
    │ │ │ +0001da90: 2066 2e73 6563 6f6e 6429 3b0a 0909 097d   f.second);....}
    │ │ │ +0001daa0: 0a09 097d 0a0a 0909 636f 6e73 7472 7563  ...}....construc
    │ │ │ +0001dab0: 745f 7374 6f72 6167 6528 293b 0a0a 2369  t_storage();..#i
    │ │ │ +0001dac0: 666e 6465 6620 544f 5252 454e 545f 4449  fndef TORRENT_DI
    │ │ │ +0001dad0: 5341 424c 455f 5348 4152 455f 4d4f 4445  SABLE_SHARE_MODE
    │ │ │ +0001dae0: 0a09 0969 6620 286d 5f73 6861 7265 5f6d  ...if (m_share_m
    │ │ │ +0001daf0: 6f64 6520 2661 6d70 3b26 616d 703b 2076  ode && v
    │ │ │ +0001db00: 616c 6964 5f6d 6574 6164 6174 6128 2929  alid_metadata())
    │ │ │ +0001db10: 0a09 097b 0a09 0909 2f2f 2069 6e20 7368  ...{....// in sh
    │ │ │ +0001db20: 6172 6520 6d6f 6465 2c20 616c 6c20 7069  are mode, all pi
    │ │ │ +0001db30: 6563 6573 2068 6176 6520 7468 6569 7220  eces have their 
    │ │ │ +0001db40: 7072 696f 7269 7469 6573 2069 6e69 7469  priorities initi
    │ │ │ +0001db50: 616c 697a 6564 2074 6f20 300a 0909 096d  alized to 0....m
    │ │ │ +0001db60: 5f66 696c 655f 7072 696f 7269 7479 2e63  _file_priority.c
    │ │ │ +0001db70: 6c65 6172 2829 3b0a 0909 096d 5f66 696c  lear();....m_fil
    │ │ │ +0001db80: 655f 7072 696f 7269 7479 2e72 6573 697a  e_priority.resiz
    │ │ │ +0001db90: 6528 6d5f 746f 7272 656e 745f 6669 6c65  e(m_torrent_file
    │ │ │ +0001dba0: 2d26 6774 3b6e 756d 5f66 696c 6573 2829  ->num_files()
    │ │ │ +0001dbb0: 2c20 646f 6e74 5f64 6f77 6e6c 6f61 6429  , dont_download)
    │ │ │ +0001dbc0: 3b0a 0909 7d0a 2365 6e64 6966 0a0a 0909  ;...}.#endif....
    │ │ │ +0001dbd0: 2f2f 2069 7427 7320 696d 706f 7274 616e  // it's importan
    │ │ │ +0001dbe0: 7420 746f 2069 6e69 7469 616c 697a 6520  t to initialize 
    │ │ │ +0001dbf0: 7468 6520 7065 6572 7320 6561 726c 792c  the peers early,
    │ │ │ +0001dc00: 2062 6563 6175 7365 2074 6869 7320 6973   because this is
    │ │ │ +0001dc10: 2077 6861 7420 7769 6c6c 0a09 092f 2f20   what will...// 
    │ │ │ +0001dc20: 6669 7820 7570 2074 6865 6972 2068 6176  fix up their hav
    │ │ │ +0001dc30: 652d 6269 746d 6173 6b73 2074 6f20 6861  e-bitmasks to ha
    │ │ │ +0001dc40: 7665 2074 6865 2063 6f72 7265 6374 2073  ve the correct s
    │ │ │ +0001dc50: 697a 650a 3c64 6976 2073 7479 6c65 3d22  ize.
    ..if (!m_conne │ │ │ +0001dc90: 6374 696f 6e73 5f69 6e69 7469 616c 697a ctions_initializ │ │ │ +0001dca0: 6564 290a 3c2f 6469 763e 0909 7b0a 0909 ed).
    ..{... │ │ │ +0001dcb0: 096d 5f63 6f6e 6e65 6374 696f 6e73 5f69 .m_connections_i │ │ │ +0001dcc0: 6e69 7469 616c 697a 6564 203d 2074 7275 nitialized = tru │ │ │ +0001dcd0: 653b 0a09 0909 2f2f 2061 6c6c 2070 6565 e;....// all pee │ │ │ +0001dce0: 7220 636f 6e6e 6563 7469 6f6e 7320 6861 r connections ha │ │ │ +0001dcf0: 7665 2074 6f20 696e 6974 6961 6c69 7a65 ve to initialize │ │ │ +0001dd00: 2074 6865 6d73 656c 7665 7320 6e6f 7720 themselves now │ │ │ +0001dd10: 7468 6174 2074 6865 206d 6574 6164 6174 that the metadat │ │ │ +0001dd20: 610a 0909 092f 2f20 6973 2061 7661 696c a....// is avail │ │ │ +0001dd30: 6162 6c65 0a09 0909 2f2f 2063 6f70 7920 able....// copy │ │ │ +0001dd40: 7468 6520 7065 6572 206c 6973 7420 7369 the peer list si │ │ │ +0001dd50: 6e63 6520 7065 6572 7320 6d61 7920 6469 nce peers may di │ │ │ +0001dd60: 7363 6f6e 6e65 6374 2061 6e64 2069 6e76 sconnect and inv │ │ │ +0001dd70: 616c 6964 6174 650a 0909 092f 2f20 6d5f alidate....// m_ │ │ │ +0001dd80: 636f 6e6e 6563 7469 6f6e 7320 6173 2077 connections as w │ │ │ +0001dd90: 6520 696e 6974 6961 6c69 7a65 2074 6865 e initialize the │ │ │ +0001dda0: 6d0a 0909 0966 6f72 2028 6175 746f 2063 m....for (auto c │ │ │ +0001ddb0: 203a 206d 5f63 6f6e 6e65 6374 696f 6e73 : m_connections │ │ │ +0001ddc0: 290a 0909 097b 0a09 0909 0961 7574 6f20 )....{.....auto │ │ │ +0001ddd0: 7063 203d 2063 2d26 6774 3b73 656c 6628 pc = c->self( │ │ │ +0001dde0: 293b 0a09 0909 0969 6620 2870 632d 2667 );.....if (pc-&g │ │ │ +0001ddf0: 743b 6973 5f64 6973 636f 6e6e 6563 7469 t;is_disconnecti │ │ │ +0001de00: 6e67 2829 2920 636f 6e74 696e 7565 3b0a ng()) continue;. │ │ │ +0001de10: 0909 0909 7063 2d26 6774 3b6f 6e5f 6d65 ....pc->on_me │ │ │ +0001de20: 7461 6461 7461 5f69 6d70 6c28 293b 0a09 tadata_impl();.. │ │ │ +0001de30: 0909 0969 6620 2870 632d 2667 743b 6973 ...if (pc->is │ │ │ +0001de40: 5f64 6973 636f 6e6e 6563 7469 6e67 2829 _disconnecting() │ │ │ +0001de50: 2920 636f 6e74 696e 7565 3b0a 0909 0909 ) continue;..... │ │ │ +0001de60: 7063 2d26 6774 3b69 6e69 7428 293b 0a09 pc->init();.. │ │ │ +0001de70: 0909 7d0a 0909 7d0a 0a09 092f 2f20 696e ..}...}....// in │ │ │ +0001de80: 2063 6173 6520 6669 6c65 2070 7269 6f72 case file prior │ │ │ +0001de90: 6974 6965 7320 7765 7265 2070 6173 7365 ities were passe │ │ │ +0001dea0: 6420 696e 2076 6961 2074 6865 2061 6464 d in via the add │ │ │ +0001deb0: 5f74 6f72 7265 6e74 5f70 6172 616d 730a _torrent_params. │ │ │ +0001dec0: 0909 2f2f 2061 6e64 2061 6c73 6f20 696e ..// and also in │ │ │ +0001ded0: 2074 6865 2063 6173 6520 6f66 2073 6861 the case of sha │ │ │ +0001dee0: 7265 206d 6f64 652c 2077 6520 6e65 6564 re mode, we need │ │ │ +0001def0: 2074 6f20 7570 6461 7465 2074 6865 2070 to update the p │ │ │ +0001df00: 7269 6f72 6974 6965 730a 0909 2f2f 2074 riorities...// t │ │ │ +0001df10: 6869 7320 6861 7320 746f 2062 6520 6170 his has to be ap │ │ │ +0001df20: 706c 6965 6420 6265 666f 7265 2070 6965 plied before pie │ │ │ +0001df30: 6365 2070 7269 6f72 6974 790a 0909 6966 ce priority...if │ │ │ +0001df40: 2028 216d 5f66 696c 655f 7072 696f 7269 (!m_file_priori │ │ │ +0001df50: 7479 2e65 6d70 7479 2829 290a 0909 7b0a ty.empty())...{. │ │ │ +0001df60: 0909 092f 2f20 6d5f 6669 6c65 5f70 7269 ...// m_file_pri │ │ │ +0001df70: 6f72 6974 7920 7761 7320 6c6f 6164 6564 ority was loaded │ │ │ +0001df80: 2066 726f 6d20 7468 6520 7265 7375 6d65 from the resume │ │ │ +0001df90: 2064 6174 612c 2074 6869 7320 646f 6573 data, this does │ │ │ +0001dfa0: 6e27 740a 0909 092f 2f20 616c 7465 7220 n't....// alter │ │ │ +0001dfb0: 616e 7920 7374 6174 6520 7468 6174 206e any state that n │ │ │ +0001dfc0: 6565 6473 2074 6f20 6265 2073 6176 6564 eeds to be saved │ │ │ +0001dfd0: 2069 6e20 7468 6520 7265 7375 6d65 2064 in the resume d │ │ │ +0001dfe0: 6174 610a 0909 0961 7574 6f20 636f 6e73 ata....auto cons │ │ │ +0001dff0: 7420 6e73 203d 206d 5f6e 6565 645f 7361 t ns = m_need_sa │ │ │ +0001e000: 7665 5f72 6573 756d 655f 6461 7461 3b0a ve_resume_data;. │ │ │ +0001e010: 0909 0975 7064 6174 655f 7069 6563 655f ...update_piece_ │ │ │ +0001e020: 7072 696f 7269 7469 6573 286d 5f66 696c priorities(m_fil │ │ │ +0001e030: 655f 7072 696f 7269 7479 293b 0a09 0909 e_priority);.... │ │ │ +0001e040: 6d5f 6e65 6564 5f73 6176 655f 7265 7375 m_need_save_resu │ │ │ +0001e050: 6d65 5f64 6174 6120 3d20 6e73 3b0a 0909 me_data = ns;... │ │ │ +0001e060: 7d0a 0a09 0969 6620 286d 5f61 6464 5f74 }....if (m_add_t │ │ │ +0001e070: 6f72 7265 6e74 5f70 6172 616d 7329 0a09 orrent_params).. │ │ │ +0001e080: 097b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f .{.
    │ │ │ +0001e0b0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +0001e0c0: 7370 3b32 3c2f 7464 3e3c 7464 3e3c 6120 sp;2../ │ │ │ +0001e0f0: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ +0001e100: 3436 3230 3c2f 613e 3c2f 7464 3e3c 7464 4620use chrono type │ │ │ +0001e120: 2066 6f72 2074 696d 6520 6475 7261 7469 for time durati │ │ │ +0001e130: 6f6e 3c2f 7464 3e3c 2f74 723e 3c74 7220 on

    u │ │ │ +0001e180: 7365 2063 6872 6f6e 6f20 7479 7065 2066 se chrono type f │ │ │ +0001e190: 6f72 2074 696d 6520 6475 7261 7469 6f6e or time duration │ │ │ +0001e1a0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +0001e1b0: 746f 7272 656e 742e 6370 703a 3436 3230 torrent.cpp:4620 │ │ │ +0001e1c0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +0001e200: 097d 0a0a 0909 6d5f 7069 636b 6572 2d26  .}....m_picker-&
    │ │ │ +0001e210: 6774 3b70 6965 6365 5f70 6173 7365 6428  gt;piece_passed(
    │ │ │ +0001e220: 696e 6465 7829 3b0a 0909 7570 6461 7465  index);...update
    │ │ │ +0001e230: 5f67 6175 6765 2829 3b0a 0909 7765 5f68  _gauge();...we_h
    │ │ │ +0001e240: 6176 6528 696e 6465 7829 3b0a 0a23 6966  ave(index);..#if
    │ │ │ +0001e250: 6e64 6566 2054 4f52 5245 4e54 5f44 4953  ndef TORRENT_DIS
    │ │ │ +0001e260: 4142 4c45 5f4c 4f47 4749 4e47 0a09 0969  ABLE_LOGGING...i
    │ │ │ +0001e270: 6620 2873 686f 756c 645f 6c6f 6728 2929  f (should_log())
    │ │ │ +0001e280: 0a09 0909 6465 6275 675f 6c6f 6728 2277  ....debug_log("w
    │ │ │ +0001e290: 655f 6861 7665 2825 6429 2028 6e75 6d5f  e_have(%d) (num_
    │ │ │ +0001e2a0: 6861 7665 3a20 2564 2922 2c20 696e 7428  have: %d)", int(
    │ │ │ +0001e2b0: 696e 6465 7829 2c20 6e75 6d5f 6861 7665  index), num_have
    │ │ │ +0001e2c0: 2829 293b 0a23 656e 6469 660a 2369 666e  ());.#endif.#ifn
    │ │ │ +0001e2d0: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ +0001e2e0: 424c 455f 5354 5245 414d 494e 470a 0909  BLE_STREAMING...
    │ │ │ +0001e2f0: 7265 6d6f 7665 5f74 696d 655f 6372 6974  remove_time_crit
    │ │ │ +0001e300: 6963 616c 5f70 6965 6365 2869 6e64 6578  ical_piece(index
    │ │ │ +0001e310: 2c20 7472 7565 293b 0a23 656e 6469 660a  , true);.#endif.
    │ │ │ +0001e320: 097d 0a0a 2369 666e 6465 6620 544f 5252  .}..#ifndef TORR
    │ │ │ +0001e330: 454e 545f 4449 5341 424c 455f 5052 4544  ENT_DISABLE_PRED
    │ │ │ +0001e340: 4943 5449 5645 5f50 4945 4345 530a 092f  ICTIVE_PIECES../
    │ │ │ +0001e350: 2f20 7765 2062 656c 6965 7665 2077 6520  / we believe we 
    │ │ │ +0001e360: 7769 6c6c 2063 6f6d 706c 6574 6520 7468  will complete th
    │ │ │ +0001e370: 6973 2070 6965 6365 2076 6572 7920 736f  is piece very so
    │ │ │ +0001e380: 6f6e 0a09 2f2f 2061 6e6e 6f75 6e63 6520  on..// announce 
    │ │ │ +0001e390: 6974 2074 6f20 7065 6572 7320 6168 6561  it to peers ahea
    │ │ │ +0001e3a0: 6420 6f66 2074 696d 6520 746f 2065 6c69  d of time to eli
    │ │ │ +0001e3b0: 6d69 6e61 7465 2074 6865 0a09 2f2f 2072  minate the..// r
    │ │ │ +0001e3c0: 6f75 6e64 2d74 7269 7020 7469 6d65 7320  ound-trip times 
    │ │ │ +0001e3d0: 696e 766f 6c76 6564 2069 6e20 616e 6e6f  involved in anno
    │ │ │ +0001e3e0: 756e 6369 6e67 2069 742c 2072 6571 7565  uncing it, reque
    │ │ │ +0001e3f0: 7374 696e 6720 6974 0a09 2f2f 2061 6e64  sting it..// and
    │ │ │ +0001e400: 2073 656e 6469 6e67 2069 740a 3c64 6976   sending it.
    .void │ │ │ +0001e440: 746f 7272 656e 743a 3a70 7265 6469 6374 torrent::predict │ │ │ +0001e450: 6564 5f68 6176 655f 7069 6563 6528 7069 ed_have_piece(pi │ │ │ +0001e460: 6563 655f 696e 6465 785f 7420 636f 6e73 ece_index_t cons │ │ │ +0001e470: 7420 696e 6465 782c 2069 6e74 2063 6f6e t index, int con │ │ │ +0001e480: 7374 206d 696c 6c69 7365 636f 6e64 7329 st milliseconds) │ │ │ +0001e490: 0a3c 2f64 6976 3e09 7b0a 0909 6175 746f .
    .{...auto │ │ │ +0001e4a0: 2063 6f6e 7374 2069 203d 2073 7464 3a3a const i = std:: │ │ │ +0001e4b0: 6c6f 7765 725f 626f 756e 6428 6d5f 7072 lower_bound(m_pr │ │ │ +0001e4c0: 6564 6963 7469 7665 5f70 6965 6365 732e edictive_pieces. │ │ │ +0001e4d0: 6265 6769 6e28 290a 0909 092c 206d 5f70 begin()...., m_p │ │ │ +0001e4e0: 7265 6469 6374 6976 655f 7069 6563 6573 redictive_pieces │ │ │ +0001e4f0: 2e65 6e64 2829 2c20 696e 6465 7829 3b0a .end(), index);. │ │ │ +0001e500: 0909 6966 2028 6920 213d 206d 5f70 7265 ..if (i != m_pre │ │ │ +0001e510: 6469 6374 6976 655f 7069 6563 6573 2e65 dictive_pieces.e │ │ │ +0001e520: 6e64 2829 2026 616d 703b 2661 6d70 3b20 nd() && │ │ │ +0001e530: 2a69 203d 3d20 696e 6465 7829 2072 6574 *i == index) ret │ │ │ +0001e540: 7572 6e3b 0a0a 0909 666f 7220 2861 7574 urn;....for (aut │ │ │ +0001e550: 6f20 7020 3a20 6d5f 636f 6e6e 6563 7469 o p : m_connecti │ │ │ +0001e560: 6f6e 7329 0a09 097b 0a09 0909 544f 5252 ons)...{....TORR │ │ │ +0001e570: 454e 545f 494e 4352 454d 454e 5428 6d5f ENT_INCREMENT(m_ │ │ │ +0001e580: 6974 6572 6174 696e 675f 636f 6e6e 6563 iterating_connec │ │ │ +0001e590: 7469 6f6e 7329 3b0a 2369 666e 6465 6620 tions);.#ifndef │ │ │ +0001e5a0: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ +0001e5b0: 4c4f 4747 494e 470a 0909 0970 2d26 6774 LOGGING....p-> │ │ │ +0001e5c0: 3b70 6565 725f 6c6f 6728 7065 6572 5f6c ;peer_log(peer_l │ │ │ +0001e5d0: 6f67 5f61 6c65 7274 3a3a 6f75 7467 6f69 og_alert::outgoi │ │ │ +0001e5e0: 6e67 2c20 2250 5245 4449 4354 4956 455f ng, "PREDICTIVE_ │ │ │ +0001e5f0: 4841 5645 222c 2022 7069 6563 653a 2025 HAVE", "piece: % │ │ │ +0001e600: 6420 6578 7065 6374 6564 2069 6e20 2564 d expected in %d │ │ │ +0001e610: 206d 7322 0a09 0909 092c 2073 7461 7469 ms"....., stati │ │ │ +0001e620: 635f 6361 7374 266c 743b 696e 7426 6774 c_cast<int> │ │ │ +0001e630: 3b28 696e 6465 7829 2c20 6d69 6c6c 6973 ;(index), millis │ │ │ +0001e640: 6563 6f6e 6473 293b 0a23 656c 7365 0a09 econds);.#else.. │ │ │ +0001e650: 0909 544f 5252 454e 545f 554e 5553 4544 ..TORRENT_UNUSED │ │ │ +0001e660: 286d 696c 6c69 7365 636f 6e64 7329 3b0a (milliseconds);. │ │ │ +0001e670: 2365 6e64 6966 0a09 0909 702d 2667 743b #endif....p-> │ │ │ +0001e680: 616e 6e6f 756e 6365 5f70 6965 6365 2869 announce_piece(i │ │ │ +0001e690: 6e64 6578 293b 0a09 097d 0a0a 0909 6d5f ndex);...}....m_ │ │ │ +0001e6a0: 7072 6564 6963 7469 7665 5f70 6965 6365 predictive_piece │ │ │ +0001e6b0: 732e 696e 7365 7274 2869 2c20 696e 6465 s.insert(i, inde │ │ │ +0001e6c0: 7829 3b0a 097d 0a23 656e 6469 660a 0a09 x);..}.#endif... │ │ │ +0001e6d0: 2f2f 2062 6c6f 636b 7320 6d61 7920 636f // blocks may co │ │ │ +0001e6e0: 6e74 6169 6e20 7468 6520 626c 6f63 6b20 ntain the block │ │ │ +0001e6f0: 696e 6469 6365 7320 6f66 2074 6865 2062 indices of the b │ │ │ +0001e700: 6c6f 636b 7320 7468 6174 2066 6169 6c65 locks that faile │ │ │ +0001e710: 6420 2869 6620 7468 6973 2069 730a 092f d (if this is../ │ │ │ +0001e720: 2f20 6120 7632 2074 6f72 7265 6e74 292e / a v2 torrent). │ │ │ +0001e730: 0a09 766f 6964 2074 6f72 7265 6e74 3a3a ..void torrent:: │ │ │ +0001e740: 7069 6563 655f 6661 696c 6564 2870 6965 piece_failed(pie │ │ │ +0001e750: 6365 5f69 6e64 6578 5f74 2063 6f6e 7374 ce_index_t const │ │ │ +0001e760: 2069 6e64 6578 2c20 7374 643a 3a76 6563 index, std::vec │ │ │ +0001e770: 746f 7226 6c74 3b69 6e74 2667 743b 2062 tor<int> b │ │ │ +0001e780: 6c6f 636b 7329 0a09 7b0a 0909 2f2f 2069 locks)..{...// i │ │ │ +0001e790: 6620 7468 6520 6c61 7374 2070 6965 6365 f the last piece │ │ │ +0001e7a0: 2066 6169 6c73 2074 6865 2070 6565 7220 fails the peer │ │ │ +0001e7b0: 636f 6e6e 6563 7469 6f6e 2077 696c 6c20 connection will │ │ │ +0001e7c0: 7374 696c 6c0a 0909 2f2f 2074 6869 6e6b still...// think │ │ │ +0001e7d0: 2074 6861 7420 6974 2068 6173 2072 6563 that it has rec │ │ │ +0001e7e0: 6569 7665 6420 616c 6c20 6f66 2069 7420 eived all of it │ │ │ +0001e7f0: 756e 7469 6c20 7468 6973 2066 756e 6374 until this funct │ │ │ +0001e800: 696f 6e0a 0909 2f2f 2072 6573 6574 7320 ion...// resets │ │ │ +0001e810: 7468 6520 646f 776e 6c6f 6164 2071 7565 the download que │ │ │ +0001e820: 7565 2e20 536f 2c20 7765 2063 616e 6e6f ue. So, we canno │ │ │ +0001e830: 7420 646f 2074 6865 0a09 092f 2f20 696e t do the...// in │ │ │ +0001e840: 7661 7269 616e 7420 6368 6563 6b20 6865 variant check he │ │ │ +0001e850: 7265 2073 696e 6365 2069 7420 6173 7375 re since it assu │ │ │ +0001e860: 6d65 733a 0a09 092f 2f20 2874 6f74 616c mes:...// (total │ │ │ +0001e870: 5f64 6f6e 6520 3d3d 206d 5f74 6f72 7265 _done == m_torre │ │ │ +0001e880: 6e74 5f66 696c 652d 2667 743b 746f 7461 nt_file->tota │ │ │ +0001e890: 6c5f 7369 7a65 2829 2920 3d26 6774 3b20 l_size()) => │ │ │ +0001e8a0: 6973 5f73 6565 6428 290a 3c2f 7072 653e is_seed().
    │ │ │ +0001e8b0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +0001e8e0: 616e 6365 266e 6273 703b 323c 2f74 643e ance 2 │ │ │ +0001e8f0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/torre │ │ │ +0001e920: 6e74 2e63 7070 3a35 3036 353c 2f61 3e3c nt.cpp:5065< │ │ │ +0001e930: 2f74 643e 3c74 643e 6162 6f72 7420 6c6f /td>abort lo │ │ │ +0001e940: 6f6b 7570 7320 7468 6973 2074 6f72 7265 okups this torre │ │ │ +0001e950: 6e74 2068 6173 206d 6164 6520 7669 6120 nt has made via │ │ │ +0001e960: 7468 6520 7365 7373 696f 6e20 686f 7374 the session host │ │ │ +0001e970: 2072 6573 6f6c 7665 7220 696e 7465 7266 resolver interf │ │ │ +0001e980: 6163 653c 2f74 643e 3c2f 7472 3e3c 7472 ace

    │ │ │ +0001e9d0: 6162 6f72 7420 6c6f 6f6b 7570 7320 7468 abort lookups th │ │ │ +0001e9e0: 6973 2074 6f72 7265 6e74 2068 6173 206d is torrent has m │ │ │ +0001e9f0: 6164 6520 7669 6120 7468 650a 7365 7373 ade via the.sess │ │ │ +0001ea00: 696f 6e20 686f 7374 2072 6573 6f6c 7665 ion host resolve │ │ │ +0001ea10: 7220 696e 7465 7266 6163 653c 2f68 323e r interface

    │ │ │ +0001ea20: 3c68 343e 2e2e 2f73 7263 2f74 6f72 7265

    ../src/torre │ │ │ +0001ea30: 6e74 2e63 7070 3a35 3036 353c 2f68 343e nt.cpp:5065

    │ │ │ +0001ea40: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ....TO
    │ │ │ +0001ea80: 5252 454e 545f 554e 5553 4544 2865 293b  RRENT_UNUSED(e);
    │ │ │ +0001ea90: 0a09 0909 096d 5f73 746f 7261 6765 2e72  .....m_storage.r
    │ │ │ +0001eaa0: 6573 6574 2829 3b0a 2369 666e 6465 6620  eset();.#ifndef 
    │ │ │ +0001eab0: 544f 5252 454e 545f 4449 5341 424c 455f  TORRENT_DISABLE_
    │ │ │ +0001eac0: 4c4f 4747 494e 470a 0909 0909 6465 6275  LOGGING.....debu
    │ │ │ +0001ead0: 675f 6c6f 6728 2246 6169 6c65 6420 746f  g_log("Failed to
    │ │ │ +0001eae0: 2066 6c75 7368 2064 6973 6b20 6361 6368   flush disk cach
    │ │ │ +0001eaf0: 653a 2025 7322 2c20 652e 7768 6174 2829  e: %s", e.what()
    │ │ │ +0001eb00: 293b 0a23 656e 6469 660a 0909 0909 2f2f  );.#endif.....//
    │ │ │ +0001eb10: 2063 6c69 656e 7473 206d 6179 2072 656c   clients may rel
    │ │ │ +0001eb20: 7920 6f6e 2074 6869 7320 616c 6572 7420  y on this alert 
    │ │ │ +0001eb30: 746f 2062 6520 706f 7374 6564 2c20 736f  to be posted, so
    │ │ │ +0001eb40: 2069 7427 7320 7072 6f62 6162 6c79 2061   it's probably a
    │ │ │ +0001eb50: 0a09 0909 092f 2f20 676f 6f64 2069 6465  .....// good ide
    │ │ │ +0001eb60: 6120 746f 2070 6f73 7420 6974 2068 6572  a to post it her
    │ │ │ +0001eb70: 652c 2065 7665 6e20 7468 6f75 6768 2077  e, even though w
    │ │ │ +0001eb80: 6520 6661 696c 6564 0a09 0909 0969 6620  e failed.....if 
    │ │ │ +0001eb90: 2861 6c65 7274 7328 292e 7368 6f75 6c64  (alerts().should
    │ │ │ +0001eba0: 5f70 6f73 7426 6c74 3b63 6163 6865 5f66  _post<cache_f
    │ │ │ +0001ebb0: 6c75 7368 6564 5f61 6c65 7274 2667 743b  lushed_alert>
    │ │ │ +0001ebc0: 2829 290a 0909 0909 0961 6c65 7274 7328  ())......alerts(
    │ │ │ +0001ebd0: 292e 656d 706c 6163 655f 616c 6572 7426  ).emplace_alert&
    │ │ │ +0001ebe0: 6c74 3b63 6163 6865 5f66 6c75 7368 6564  lt;cache_flushed
    │ │ │ +0001ebf0: 5f61 6c65 7274 2667 743b 2867 6574 5f68  _alert>(get_h
    │ │ │ +0001ec00: 616e 646c 6528 2929 3b0a 0909 097d 0a09  andle());....}..
    │ │ │ +0001ec10: 0909 6d5f 7365 732e 6465 6665 7272 6564  ..m_ses.deferred
    │ │ │ +0001ec20: 5f73 7562 6d69 745f 6a6f 6273 2829 3b0a  _submit_jobs();.
    │ │ │ +0001ec30: 0909 7d0a 0909 656c 7365 0a09 097b 0a09  ..}...else...{..
    │ │ │ +0001ec40: 0909 6966 2028 616c 6572 7473 2829 2e73  ..if (alerts().s
    │ │ │ +0001ec50: 686f 756c 645f 706f 7374 266c 743b 6361  hould_post<ca
    │ │ │ +0001ec60: 6368 655f 666c 7573 6865 645f 616c 6572  che_flushed_aler
    │ │ │ +0001ec70: 7426 6774 3b28 2929 0a09 0909 0961 6c65  t>()).....ale
    │ │ │ +0001ec80: 7274 7328 292e 656d 706c 6163 655f 616c  rts().emplace_al
    │ │ │ +0001ec90: 6572 7426 6c74 3b63 6163 6865 5f66 6c75  ert<cache_flu
    │ │ │ +0001eca0: 7368 6564 5f61 6c65 7274 2667 743b 2867  shed_alert>(g
    │ │ │ +0001ecb0: 6574 5f68 616e 646c 6528 2929 3b0a 0909  et_handle());...
    │ │ │ +0001ecc0: 0961 6c65 7274 7328 292e 656d 706c 6163  .alerts().emplac
    │ │ │ +0001ecd0: 655f 616c 6572 7426 6c74 3b74 6f72 7265  e_alert<torre
    │ │ │ +0001ece0: 6e74 5f72 656d 6f76 6564 5f61 6c65 7274  nt_removed_alert
    │ │ │ +0001ecf0: 2667 743b 2867 6574 5f68 616e 646c 6528  >(get_handle(
    │ │ │ +0001ed00: 290a 0909 0909 2c20 696e 666f 5f68 6173  )....., info_has
    │ │ │ +0001ed10: 6828 292c 2067 6574 5f75 7365 7264 6174  h(), get_userdat
    │ │ │ +0001ed20: 6128 2929 3b0a 0909 7d0a 0a3c 6469 7620  a());...}..
    .
    │ │ │ +0001ed60: 0909 6966 2028 216d 5f61 7070 6c79 5f69 ..if (!m_apply_i │ │ │ +0001ed70: 705f 6669 6c74 6572 290a 0909 7b0a 0909 p_filter)...{... │ │ │ +0001ed80: 0969 6e63 5f73 7461 7473 5f63 6f75 6e74 .inc_stats_count │ │ │ +0001ed90: 6572 2863 6f75 6e74 6572 733a 3a6e 6f6e er(counters::non │ │ │ +0001eda0: 5f66 696c 7465 725f 746f 7272 656e 7473 _filter_torrents │ │ │ +0001edb0: 2c20 2d31 293b 0a09 0909 6d5f 6170 706c , -1);....m_appl │ │ │ +0001edc0: 795f 6970 5f66 696c 7465 7220 3d20 7472 y_ip_filter = tr │ │ │ +0001edd0: 7565 3b0a 0909 7d0a 097d 0a0a 092f 2f20 ue;...}..}...// │ │ │ +0001ede0: 7468 6973 2069 7320 6361 6c6c 6564 2077 this is called w │ │ │ +0001edf0: 6865 6e20 7765 2772 6520 6465 7374 7275 hen we're destru │ │ │ +0001ee00: 6374 696e 6720 6e6f 6e2d 6772 6163 6566 cting non-gracef │ │ │ +0001ee10: 756c 6c79 2e20 692e 652e 2077 6527 7265 ully. i.e. we're │ │ │ +0001ee20: 205f 6a75 7374 5f0a 092f 2f20 6465 7374 _just_..// dest │ │ │ +0001ee30: 7275 6374 696e 6720 6576 6572 7974 6869 ructing everythi │ │ │ +0001ee40: 6e67 2e0a 0976 6f69 6420 746f 7272 656e ng...void torren │ │ │ +0001ee50: 743a 3a70 616e 6963 2829 0a09 7b0a 0909 t::panic()..{... │ │ │ +0001ee60: 6d5f 7374 6f72 6167 652e 7265 7365 7428 m_storage.reset( │ │ │ +0001ee70: 293b 0a09 092f 2f20 6966 2074 6865 7265 );...// if there │ │ │ +0001ee80: 2061 7265 2061 6e79 206f 7468 6572 2070 are any other p │ │ │ +0001ee90: 6565 7273 2061 6c6c 6f63 6174 6564 2073 eers allocated s │ │ │ +0001eea0: 7469 6c6c 2c20 7765 206e 6565 6420 746f till, we need to │ │ │ +0001eeb0: 2063 6c65 6172 2074 6865 6d0a 0909 2f2f clear them...// │ │ │ +0001eec0: 206e 6f77 2e20 5468 6579 2063 616e 2774 now. They can't │ │ │ +0001eed0: 2062 6520 636c 6561 7265 6420 6c61 7465 be cleared late │ │ │ +0001eee0: 7220 6265 6361 7573 6520 7468 6520 616c r because the al │ │ │ +0001eef0: 6c6f 6361 746f 7220 7769 6c6c 2061 6c72 locator will alr │ │ │ +0001ef00: 6561 6479 0a09 092f 2f20 6861 7665 2062 eady...// have b │ │ │ +0001ef10: 6565 6e20 6465 7374 7275 6374 6564 0a09 een destructed.. │ │ │ +0001ef20: 0969 6620 286d 5f70 6565 725f 6c69 7374 .if (m_peer_list │ │ │ +0001ef30: 2920 6d5f 7065 6572 5f6c 6973 742d 2667 ) m_peer_list-&g │ │ │ +0001ef40: 743b 636c 6561 7228 293b 0a09 096d 5f63 t;clear();...m_c │ │ │ +0001ef50: 6f6e 6e65 6374 696f 6e73 2e63 6c65 6172 onnections.clear │ │ │ +0001ef60: 2829 3b0a 0909 6d5f 6f75 7467 6f69 6e67 ();...m_outgoing │ │ │ +0001ef70: 5f70 6964 732e 636c 6561 7228 293b 0a09 _pids.clear();.. │ │ │ +0001ef80: 096d 5f70 6565 7273 5f74 6f5f 6469 7363 .m_peers_to_disc │ │ │ +0001ef90: 6f6e 6e65 6374 2e63 6c65 6172 2829 3b0a onnect.clear();. │ │ │ +0001efa0: 0909 6d5f 6e75 6d5f 7570 6c6f 6164 7320 ..m_num_uploads │ │ │ +0001efb0: 3d20 303b 0a09 096d 5f6e 756d 5f63 6f6e = 0;...m_num_con │ │ │ +0001efc0: 6e65 6374 696e 6720 3d20 303b 0a09 096d necting = 0;...m │ │ │ +0001efd0: 5f6e 756d 5f63 6f6e 6e65 6374 696e 675f _num_connecting_ │ │ │ +0001efe0: 7365 6564 7320 3d20 303b 0a09 7d0a 0a23 seeds = 0;..}..# │ │ │ +0001eff0: 6966 6e64 6566 2054 4f52 5245 4e54 5f44 ifndef TORRENT_D │ │ │ +0001f000: 4953 4142 4c45 5f53 5550 4552 5345 4544 ISABLE_SUPERSEED │ │ │ +0001f010: 494e 470a 0976 6f69 6420 746f 7272 656e ING..void torren │ │ │ +0001f020: 743a 3a73 6574 5f73 7570 6572 5f73 6565 t::set_super_see │ │ │ +0001f030: 6469 6e67 2862 6f6f 6c20 636f 6e73 7420 ding(bool const │ │ │ +0001f040: 6f6e 290a 097b 0a09 0969 6620 286f 6e20 on)..{...if (on │ │ │ +0001f050: 3d3d 206d 5f73 7570 6572 5f73 6565 6469 == m_super_seedi │ │ │ +0001f060: 6e67 2920 7265 7475 726e 3b0a 0a09 096d ng) return;....m │ │ │ +0001f070: 5f73 7570 6572 5f73 6565 6469 6e67 203d _super_seeding = │ │ │ +0001f080: 206f 6e3b 0a3c 2f70 7265 3e3c 2f74 643e on;.
    │ │ │ +0001f090: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +0001f0c0: 6e62 7370 3b32 3c2f 7464 3e3c 7464 3e3c nbsp;2< │ │ │ +0001f0d0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +0001f0e0: 7074 3a65 7870 616e 6428 3631 2922 3e2e pt:expand(61)">. │ │ │ +0001f0f0: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ +0001f100: 703a 3831 3930 3c2f 613e 3c2f 7464 3e3c p:8190< │ │ │ +0001f110: 7464 3e69 6620 7065 6572 2069 7320 6120 td>if peer is a │ │ │ +0001f120: 7265 616c 6c79 2067 6f6f 6420 7065 6572 really good peer │ │ │ +0001f130: 2c20 6d61 7962 6520 7765 2073 686f 756c , maybe we shoul │ │ │ +0001f140: 646e 2774 2064 6973 636f 6e6e 6563 7420 dn't disconnect │ │ │ +0001f150: 6974 2070 6572 6861 7073 2074 6869 7320 it perhaps this │ │ │ +0001f160: 6c6f 6769 6320 7368 6f75 6c64 2062 6520 logic should be │ │ │ +0001f170: 6469 7361 626c 6564 2069 6620 7765 2068 disabled if we h │ │ │ +0001f180: 6176 6520 746f 6f20 6d61 6e79 2069 646c ave too many idl │ │ │ +0001f190: 6520 7065 6572 7320 2877 6974 6820 736f e peers (with so │ │ │ +0001f1a0: 6d65 2064 6566 696e 6974 696f 6e20 6f66 me definition of │ │ │ +0001f1b0: 2069 646c 6529 3c2f 7464 3e3c 2f74 723e idle) │ │ │ +0001f1c0: 3c74 7220 6964 3d22 3631 2220 7374 796c < │ │ │ +0001f1f0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +0001f200: 6832 3e69 6620 7065 6572 2069 7320 6120 h2>if peer is a │ │ │ +0001f210: 7265 616c 6c79 2067 6f6f 6420 7065 6572 really good peer │ │ │ +0001f220: 2c20 6d61 7962 6520 7765 2073 686f 756c , maybe we shoul │ │ │ +0001f230: 646e 2774 2064 6973 636f 6e6e 6563 7420 dn't disconnect │ │ │ +0001f240: 6974 0a70 6572 6861 7073 2074 6869 7320 it.perhaps this │ │ │ +0001f250: 6c6f 6769 6320 7368 6f75 6c64 2062 6520 logic should be │ │ │ +0001f260: 6469 7361 626c 6564 2069 6620 7765 2068 disabled if we h │ │ │ +0001f270: 6176 6520 746f 6f20 6d61 6e79 2069 646c ave too many idl │ │ │ +0001f280: 6520 7065 6572 730a 2877 6974 6820 736f e peers.(with so │ │ │ +0001f290: 6d65 2064 6566 696e 6974 696f 6e20 6f66 me definition of │ │ │ +0001f2a0: 2069 646c 6529 3c2f 6832 3e3c 6834 3e2e idle)

    . │ │ │ +0001f2b0: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ +0001f2c0: 703a 3831 3930 3c2f 6834 3e3c 7072 6520 p:8190

    ...m_peers_
    │ │ │ +0001f310: 746f 5f64 6973 636f 6e6e 6563 742e 7265  to_disconnect.re
    │ │ │ +0001f320: 7365 7276 6528 6d5f 636f 6e6e 6563 7469  serve(m_connecti
    │ │ │ +0001f330: 6f6e 732e 7369 7a65 2829 202b 2031 293b  ons.size() + 1);
    │ │ │ +0001f340: 0a09 096d 5f63 6f6e 6e65 6374 696f 6e73  ...m_connections
    │ │ │ +0001f350: 2e72 6573 6572 7665 286d 5f63 6f6e 6e65  .reserve(m_conne
    │ │ │ +0001f360: 6374 696f 6e73 2e73 697a 6528 2920 2b20  ctions.size() + 
    │ │ │ +0001f370: 3129 3b0a 0a23 6966 2054 4f52 5245 4e54  1);..#if TORRENT
    │ │ │ +0001f380: 5f55 5345 5f41 5353 4552 5453 0a09 0965  _USE_ASSERTS...e
    │ │ │ +0001f390: 7272 6f72 5f63 6f64 6520 6563 3b0a 0909  rror_code ec;...
    │ │ │ +0001f3a0: 544f 5252 454e 545f 4153 5345 5254 2870  TORRENT_ASSERT(p
    │ │ │ +0001f3b0: 2d26 6774 3b72 656d 6f74 6528 2920 3d3d  ->remote() ==
    │ │ │ +0001f3c0: 2070 2d26 6774 3b67 6574 5f73 6f63 6b65   p->get_socke
    │ │ │ +0001f3d0: 7428 292e 7265 6d6f 7465 5f65 6e64 706f  t().remote_endpo
    │ │ │ +0001f3e0: 696e 7428 6563 2920 7c7c 2065 6329 3b0a  int(ec) || ec);.
    │ │ │ +0001f3f0: 2365 6e64 6966 0a0a 0909 544f 5252 454e  #endif....TORREN
    │ │ │ +0001f400: 545f 4153 5345 5254 2870 2d26 6774 3b70  T_ASSERT(p->p
    │ │ │ +0001f410: 6565 725f 696e 666f 5f73 7472 7563 7428  eer_info_struct(
    │ │ │ +0001f420: 2920 213d 206e 756c 6c70 7472 293b 0a0a  ) != nullptr);..
    │ │ │ +0001f430: 0909 2f2f 2077 6520 6e65 6564 2074 6f20  ..// we need to 
    │ │ │ +0001f440: 646f 2074 6869 7320 6166 7465 7220 7765  do this after we
    │ │ │ +0001f450: 2776 6520 6164 6465 6420 7468 6520 7065  've added the pe
    │ │ │ +0001f460: 6572 2074 6f20 7468 6520 7065 6572 5f6c  er to the peer_l
    │ │ │ +0001f470: 6973 740a 0909 2f2f 2073 696e 6365 2074  ist...// since t
    │ │ │ +0001f480: 6861 7427 7320 7768 656e 2074 6865 2070  hat's when the p
    │ │ │ +0001f490: 6565 7220 6973 2061 7373 6967 6e65 6420  eer is assigned 
    │ │ │ +0001f4a0: 6974 7320 7065 6572 5f69 6e66 6f20 6f62  its peer_info ob
    │ │ │ +0001f4b0: 6a65 6374 2c0a 0909 2f2f 2077 6869 6368  ject,...// which
    │ │ │ +0001f4c0: 2068 6f6c 6473 2074 6865 2072 616e 6b0a   holds the rank.
    │ │ │ +0001f4d0: 0909 6966 2028 6d61 7962 655f 7265 706c  ..if (maybe_repl
    │ │ │ +0001f4e0: 6163 655f 7065 6572 290a 0909 7b0a 0909  ace_peer)...{...
    │ │ │ +0001f4f0: 092f 2f20 6e6f 772c 2066 696e 6420 7468  .// now, find th
    │ │ │ +0001f500: 6520 6c6f 7765 7374 2072 616e 6b20 7065  e lowest rank pe
    │ │ │ +0001f510: 6572 2061 6e64 2064 6973 636f 6e6e 6563  er and disconnec
    │ │ │ +0001f520: 7420 7468 6174 0a09 0909 2f2f 2069 6620  t that....// if 
    │ │ │ +0001f530: 6974 2773 206c 6f77 6572 2072 616e 6b20  it's lower rank 
    │ │ │ +0001f540: 7468 616e 2074 6865 2069 6e63 6f6d 696e  than the incomin
    │ │ │ +0001f550: 6720 636f 6e6e 6563 7469 6f6e 0a09 0909  g connection....
    │ │ │ +0001f560: 7065 6572 5f63 6f6e 6e65 6374 696f 6e2a  peer_connection*
    │ │ │ +0001f570: 2070 6565 7220 3d20 6669 6e64 5f6c 6f77   peer = find_low
    │ │ │ +0001f580: 6573 745f 7261 6e6b 696e 675f 7065 6572  est_ranking_peer
    │ │ │ +0001f590: 2829 3b0a 0a3c 6469 7620 7374 796c 653d  ();..
    ...if (peer ! │ │ │ +0001f5d0: 3d20 6e75 6c6c 7074 7220 2661 6d70 3b26 = nullptr && │ │ │ +0001f5e0: 616d 703b 2070 6565 722d 2667 743b 7065 amp; peer->pe │ │ │ +0001f5f0: 6572 5f72 616e 6b28 2920 266c 743b 2070 er_rank() < p │ │ │ +0001f600: 2d26 6774 3b70 6565 725f 7261 6e6b 2829 ->peer_rank() │ │ │ +0001f610: 290a 3c2f 6469 763e 0909 097b 0a23 6966 ).
    ...{.#if │ │ │ +0001f620: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ +0001f630: 4142 4c45 5f4c 4f47 4749 4e47 0a09 0909 ABLE_LOGGING.... │ │ │ +0001f640: 0969 6620 2873 686f 756c 645f 6c6f 6728 .if (should_log( │ │ │ +0001f650: 2929 0a09 0909 097b 0a09 0909 0909 6465 )).....{......de │ │ │ +0001f660: 6275 675f 6c6f 6728 2243 4c4f 5349 4e47 bug_log("CLOSING │ │ │ +0001f670: 2043 4f4e 4e45 4354 494f 4e20 5c22 2573 CONNECTION \"%s │ │ │ +0001f680: 5c22 2070 6565 7220 6c69 7374 2066 756c \" peer list ful │ │ │ +0001f690: 6c20 286c 6f77 2070 6565 7220 7261 6e6b l (low peer rank │ │ │ +0001f6a0: 2920 220a 0909 0909 0909 2263 6f6e 6e65 ) "......."conne │ │ │ +0001f6b0: 6374 696f 6e73 3a20 2564 206c 696d 6974 ctions: %d limit │ │ │ +0001f6c0: 3a20 2564 220a 0909 0909 0909 2c20 7072 : %d"......., pr │ │ │ +0001f6d0: 696e 745f 656e 6470 6f69 6e74 2870 6565 int_endpoint(pee │ │ │ +0001f6e0: 722d 2667 743b 7265 6d6f 7465 2829 292e r->remote()). │ │ │ +0001f6f0: 635f 7374 7228 290a 0909 0909 0909 2c20 c_str()......., │ │ │ +0001f700: 6e75 6d5f 7065 6572 7328 290a 0909 0909 num_peers()..... │ │ │ +0001f710: 0909 2c20 6d5f 6d61 785f 636f 6e6e 6563 .., m_max_connec │ │ │ +0001f720: 7469 6f6e 7329 3b0a 0909 0909 7d0a 2365 tions);.....}.#e │ │ │ +0001f730: 6e64 6966 0a09 0909 0970 6565 722d 2667 ndif.....peer-&g │ │ │ +0001f740: 743b 6469 7363 6f6e 6e65 6374 2865 7272 t;disconnect(err │ │ │ +0001f750: 6f72 733a 3a74 6f6f 5f6d 616e 795f 636f ors::too_many_co │ │ │ +0001f760: 6e6e 6563 7469 6f6e 732c 206f 7065 7261 nnections, opera │ │ │ +0001f770: 7469 6f6e 5f74 3a3a 6269 7474 6f72 7265 tion_t::bittorre │ │ │ +0001f780: 6e74 293b 0a09 0909 0970 2d26 6774 3b70 nt);.....p->p │ │ │ +0001f790: 6565 725f 6469 7363 6f6e 6e65 6374 6564 eer_disconnected │ │ │ +0001f7a0: 5f6f 7468 6572 2829 3b0a 0909 097d 0a09 _other();....}.. │ │ │ +0001f7b0: 0909 656c 7365 0a09 0909 7b0a 2369 666e ..else....{.#ifn │ │ │ +0001f7c0: 6465 6620 544f 5252 454e 545f 4449 5341 def TORRENT_DISA │ │ │ +0001f7d0: 424c 455f 4c4f 4747 494e 470a 0909 0909 BLE_LOGGING..... │ │ │ +0001f7e0: 6966 2028 7368 6f75 6c64 5f6c 6f67 2829 if (should_log() │ │ │ +0001f7f0: 290a 0909 0909 7b0a 0909 0909 0964 6562 ).....{......deb │ │ │ +0001f800: 7567 5f6c 6f67 2822 434c 4f53 494e 4720 ug_log("CLOSING │ │ │ +0001f810: 434f 4e4e 4543 5449 4f4e 205c 2225 735c CONNECTION \"%s\ │ │ │ +0001f820: 2220 7065 6572 206c 6973 7420 6675 6c6c " peer list full │ │ │ +0001f830: 2028 6c6f 7720 7065 6572 2072 616e 6b29 (low peer rank) │ │ │ +0001f840: 2022 0a09 0909 0909 0922 636f 6e6e 6563 "......."connec │ │ │ +0001f850: 7469 6f6e 733a 2025 6420 6c69 6d69 743a tions: %d limit: │ │ │ +0001f860: 2025 6422 0a09 0909 0909 092c 2070 7269 %d"......., pri │ │ │ +0001f870: 6e74 5f65 6e64 706f 696e 7428 702d 2667 nt_endpoint(p-&g │ │ │ +0001f880: 743b 7265 6d6f 7465 2829 292e 635f 7374 t;remote()).c_st │ │ │ +0001f890: 7228 290a 0909 0909 0909 2c20 6e75 6d5f r()......., num_ │ │ │ +0001f8a0: 7065 6572 7328 290a 0909 0909 0909 2c20 peers()......., │ │ │ +0001f8b0: 6d5f 6d61 785f 636f 6e6e 6563 7469 6f6e m_max_connection │ │ │ +0001f8c0: 7329 3b0a 0909 0909 7d0a 2365 6e64 6966 s);.....}.#endif │ │ │ +0001f8d0: 0a09 0909 0970 2d26 6774 3b64 6973 636f .....p->disco │ │ │ +0001f8e0: 6e6e 6563 7428 6572 726f 7273 3a3a 746f nnect(errors::to │ │ │ +0001f8f0: 6f5f 6d61 6e79 5f63 6f6e 6e65 6374 696f o_many_connectio │ │ │ +0001f900: 6e73 2c20 6f70 6572 6174 696f 6e5f 743a ns, operation_t: │ │ │ +0001f910: 3a62 6974 746f 7272 656e 7429 3b0a 0909 :bittorrent);... │ │ │ +0001f920: 0909 2f2f 2077 6520 6861 7665 2074 6f20 ..// we have to │ │ │ +0001f930: 646f 2074 6869 7320 6865 7265 2062 6563 do this here bec │ │ │ +0001f940: 6175 7365 2066 726f 6d20 7468 6520 7065 ause from the pe │ │ │ +0001f950: 6572 2773 2070 6f69 6e74 206f 6620 7669 er's point of vi │ │ │ +0001f960: 6577 0a09 0909 092f 2f20 6974 2077 6173 ew.....// it was │ │ │ +0001f970: 6e27 7420 7265 616c 6c79 2061 7474 6163 n't really attac │ │ │ +0001f980: 6865 6420 746f 2074 6865 2074 6f72 7265 hed to the torre │ │ │ +0001f990: 6e74 2c20 6275 7420 7765 2064 6f20 6e65 nt, but we do ne │ │ │ +0001f9a0: 6564 0a09 0909 092f 2f20 746f 206c 6574 ed.....// to let │ │ │ +0001f9b0: 2070 6565 725f 6c69 7374 206b 6e6f 7720 peer_list know │ │ │ +0001f9c0: 7765 2772 6520 7265 6d6f 7669 6e67 2069 we're removing i │ │ │ +0001f9d0: 740a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 t.
    < │ │ │ +0001fa00: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +0001fa10: 703b 323c 2f74 643e 3c74 643e 3c61 2068 p;2../s │ │ │ +0001fa40: 7263 2f73 746f 7261 6765 5f75 7469 6c73 rc/storage_utils │ │ │ +0001fa50: 2e63 7070 3a32 3935 3c2f 613e 3c2f 7464 .cpp:295technically │ │ │ +0001fa70: 2c20 7468 6973 2069 7320 7768 6572 6520 , this is where │ │ │ +0001fa80: 7468 6520 7472 616e 7361 6374 696f 6e20 the transaction │ │ │ +0001fa90: 6f66 206d 6f76 696e 6720 7468 6520 6669 of moving the fi │ │ │ +0001faa0: 6c65 7320 6973 2063 6f6d 706c 6574 6564 les is completed │ │ │ +0001fab0: 2e20 5468 6973 2069 7320 7768 6572 6520 . This is where │ │ │ +0001fac0: 7468 6520 6e65 7720 7361 7665 5f70 6174 the new save_pat │ │ │ +0001fad0: 6820 7368 6f75 6c64 2062 6520 636f 6d6d h should be comm │ │ │ +0001fae0: 6974 7465 642e 2049 6620 7468 6572 6520 itted. If there │ │ │ +0001faf0: 6973 2061 6e20 6572 726f 7220 696e 2074 is an error in t │ │ │ +0001fb00: 6865 2063 6f64 6520 6265 6c6f 772c 2074 he code below, t │ │ │ +0001fb10: 6861 7420 7368 6f75 6c64 206e 6f74 2070 hat should not p │ │ │ +0001fb20: 7265 7665 6e74 2074 6865 206e 6577 2073 revent the new s │ │ │ +0001fb30: 6176 6520 7061 7468 2074 6f20 6265 2073 ave path to be s │ │ │ +0001fb40: 6574 2e20 4d61 7962 6520 6974 2077 6f75 et. Maybe it wou │ │ │ +0001fb50: 6c64 206d 616b 6520 7365 6e73 6520 746f ld make sense to │ │ │ +0001fb60: 206d 616b 6520 7468 6520 7361 7665 5f70 make the save_p │ │ │ +0001fb70: 6174 6820 616e 2069 6e2d 6f75 7420 7061 ath an in-out pa │ │ │ +0001fb80: 7261 6d65 7465 723c 2f74 643e 3c2f 7472 rameter │ │ │ +0001fbc0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0001fbd0: 3c68 323e 7465 6368 6e69 6361 6c6c 792c

    technically, │ │ │ +0001fbe0: 2074 6869 7320 6973 2077 6865 7265 2074 this is where t │ │ │ +0001fbf0: 6865 2074 7261 6e73 6163 7469 6f6e 206f he transaction o │ │ │ +0001fc00: 6620 6d6f 7669 6e67 2074 6865 2066 696c f moving the fil │ │ │ +0001fc10: 6573 0a69 7320 636f 6d70 6c65 7465 642e es.is completed. │ │ │ +0001fc20: 2054 6869 7320 6973 2077 6865 7265 2074 This is where t │ │ │ +0001fc30: 6865 206e 6577 2073 6176 655f 7061 7468 he new save_path │ │ │ +0001fc40: 2073 686f 756c 6420 6265 2063 6f6d 6d69 should be commi │ │ │ +0001fc50: 7474 6564 2e20 4966 0a74 6865 7265 2069 tted. If.there i │ │ │ +0001fc60: 7320 616e 2065 7272 6f72 2069 6e20 7468 s an error in th │ │ │ +0001fc70: 6520 636f 6465 2062 656c 6f77 2c20 7468 e code below, th │ │ │ +0001fc80: 6174 2073 686f 756c 6420 6e6f 7420 7072 at should not pr │ │ │ +0001fc90: 6576 656e 7420 7468 6520 6e65 770a 7361 event the new.sa │ │ │ +0001fca0: 7665 2070 6174 6820 746f 2062 6520 7365 ve path to be se │ │ │ +0001fcb0: 742e 204d 6179 6265 2069 7420 776f 756c t. Maybe it woul │ │ │ +0001fcc0: 6420 6d61 6b65 2073 656e 7365 2074 6f20 d make sense to │ │ │ +0001fcd0: 6d61 6b65 2074 6865 2073 6176 655f 7061 make the save_pa │ │ │ +0001fce0: 7468 0a61 6e20 696e 2d6f 7574 2070 6172 th.an in-out par │ │ │ +0001fcf0: 616d 6574 6572 3c2f 6832 3e3c 6834 3e2e ameter

    . │ │ │ +0001fd00: 2e2f 7372 632f 7374 6f72 6167 655f 7574 ./src/storage_ut │ │ │ +0001fd10: 696c 732e 6370 703a 3239 353c 2f68 343e ils.cpp:295

    │ │ │ +0001fd20: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ...whi
    │ │ │ +0001fd60: 6c65 2028 2d2d 6669 6c65 5f69 6e64 6578  le (--file_index
    │ │ │ +0001fd70: 2026 6774 3b3d 2066 696c 655f 696e 6465   >= file_inde
    │ │ │ +0001fd80: 785f 7428 3029 290a 0909 097b 0a09 0909  x_t(0))....{....
    │ │ │ +0001fd90: 092f 2f20 6669 6c65 7320 6d6f 7665 6420  .// files moved 
    │ │ │ +0001fda0: 6f75 7420 746f 2061 6273 6f6c 7574 6520  out to absolute 
    │ │ │ +0001fdb0: 7061 7468 7320 6172 6520 6e6f 7420 6d6f  paths are not mo
    │ │ │ +0001fdc0: 7665 640a 0909 0909 6966 2028 662e 6669  ved.....if (f.fi
    │ │ │ +0001fdd0: 6c65 5f61 6273 6f6c 7574 655f 7061 7468  le_absolute_path
    │ │ │ +0001fde0: 2866 696c 655f 696e 6465 7829 2920 636f  (file_index)) co
    │ │ │ +0001fdf0: 6e74 696e 7565 3b0a 0a09 0909 092f 2f20  ntinue;......// 
    │ │ │ +0001fe00: 6966 2077 6520 656e 6465 6420 7570 2063  if we ended up c
    │ │ │ +0001fe10: 6f70 7969 6e67 2074 6865 2066 696c 652c  opying the file,
    │ │ │ +0001fe20: 2064 6f6e 2774 2064 6f20 616e 7974 6869   don't do anythi
    │ │ │ +0001fe30: 6e67 2064 7572 696e 670a 0909 0909 2f2f  ng during.....//
    │ │ │ +0001fe40: 2072 6f6c 6c2d 6261 636b 0a09 0909 0969   roll-back.....i
    │ │ │ +0001fe50: 6620 2863 6f70 6965 645f 6669 6c65 735b  f (copied_files[
    │ │ │ +0001fe60: 6669 6c65 5f69 6e64 6578 5d29 2063 6f6e  file_index]) con
    │ │ │ +0001fe70: 7469 6e75 653b 0a0a 0909 0909 7374 643a  tinue;......std:
    │ │ │ +0001fe80: 3a73 7472 696e 6720 636f 6e73 7420 6f6c  :string const ol
    │ │ │ +0001fe90: 645f 7061 7468 203d 2063 6f6d 6269 6e65  d_path = combine
    │ │ │ +0001fea0: 5f70 6174 6828 7361 7665 5f70 6174 682c  _path(save_path,
    │ │ │ +0001feb0: 2066 2e66 696c 655f 7061 7468 2866 696c   f.file_path(fil
    │ │ │ +0001fec0: 655f 696e 6465 7829 293b 0a09 0909 0973  e_index));.....s
    │ │ │ +0001fed0: 7464 3a3a 7374 7269 6e67 2063 6f6e 7374  td::string const
    │ │ │ +0001fee0: 206e 6577 5f70 6174 6820 3d20 636f 6d62   new_path = comb
    │ │ │ +0001fef0: 696e 655f 7061 7468 286e 6577 5f73 6176  ine_path(new_sav
    │ │ │ +0001ff00: 655f 7061 7468 2c20 662e 6669 6c65 5f70  e_path, f.file_p
    │ │ │ +0001ff10: 6174 6828 6669 6c65 5f69 6e64 6578 2929  ath(file_index))
    │ │ │ +0001ff20: 3b0a 0a09 0909 092f 2f20 6967 6e6f 7265  ;......// ignore
    │ │ │ +0001ff30: 2065 7272 6f72 7320 7768 656e 2072 6f6c   errors when rol
    │ │ │ +0001ff40: 6c69 6e67 2062 6163 6b0a 0909 0909 7374  ling back.....st
    │ │ │ +0001ff50: 6f72 6167 655f 6572 726f 7220 6967 6e6f  orage_error igno
    │ │ │ +0001ff60: 7265 3b0a 0909 0909 6d6f 7665 5f66 696c  re;.....move_fil
    │ │ │ +0001ff70: 6528 6e65 775f 7061 7468 2c20 6f6c 645f  e(new_path, old_
    │ │ │ +0001ff80: 7061 7468 2c20 6967 6e6f 7265 293b 0a09  path, ignore);..
    │ │ │ +0001ff90: 0909 7d0a 0a09 0909 7265 7475 726e 207b  ..}.....return {
    │ │ │ +0001ffa0: 2073 7461 7475 735f 743a 3a66 6174 616c   status_t::fatal
    │ │ │ +0001ffb0: 5f64 6973 6b5f 6572 726f 722c 2073 6176  _disk_error, sav
    │ │ │ +0001ffc0: 655f 7061 7468 207d 3b0a 0909 7d0a 0a3c  e_path };...}..<
    │ │ │ +0001ffd0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +0001ffe0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +0001fff0: 7769 6474 683d 2231 3030 2522 3e0a 3c2f  width="100%">...std::set&l
    │ │ │ +00020010: 743b 7374 643a 3a73 7472 696e 6726 6774  t;std::string>
    │ │ │ +00020020: 3b20 7375 6264 6972 733b 0a09 0966 6f72  ; subdirs;...for
    │ │ │ +00020030: 2028 6175 746f 2063 6f6e 7374 2069 203a   (auto const i :
    │ │ │ +00020040: 2066 2e66 696c 655f 7261 6e67 6528 2929   f.file_range())
    │ │ │ +00020050: 0a09 097b 0a09 0909 2f2f 2066 696c 6573  ...{....// files
    │ │ │ +00020060: 206d 6f76 6564 206f 7574 2074 6f20 6162   moved out to ab
    │ │ │ +00020070: 736f 6c75 7465 2070 6174 6873 2061 7265  solute paths are
    │ │ │ +00020080: 206e 6f74 206d 6f76 6564 0a09 0909 6966   not moved....if
    │ │ │ +00020090: 2028 662e 6669 6c65 5f61 6273 6f6c 7574   (f.file_absolut
    │ │ │ +000200a0: 655f 7061 7468 2869 2929 2063 6f6e 7469  e_path(i)) conti
    │ │ │ +000200b0: 6e75 653b 0a0a 0909 0969 6620 2868 6173  nue;.....if (has
    │ │ │ +000200c0: 5f70 6172 656e 745f 7061 7468 2866 2e66  _parent_path(f.f
    │ │ │ +000200d0: 696c 655f 7061 7468 2869 2929 290a 0909  ile_path(i)))...
    │ │ │ +000200e0: 0909 7375 6264 6972 732e 696e 7365 7274  ..subdirs.insert
    │ │ │ +000200f0: 2870 6172 656e 745f 7061 7468 2866 2e66  (parent_path(f.f
    │ │ │ +00020100: 696c 655f 7061 7468 2869 2929 293b 0a0a  ile_path(i)));..
    │ │ │ +00020110: 0909 092f 2f20 6966 2077 6520 656e 6465  ...// if we ende
    │ │ │ +00020120: 6420 7570 2072 656e 616d 696e 6720 7468  d up renaming th
    │ │ │ +00020130: 6520 6669 6c65 2069 6e73 7465 6164 206f  e file instead o
    │ │ │ +00020140: 6620 6d6f 7669 6e67 2069 742c 2074 6865  f moving it, the
    │ │ │ +00020150: 7265 2773 206e 6f0a 0909 092f 2f20 6e65  re's no....// ne
    │ │ │ +00020160: 6564 2074 6f20 6465 6c65 7465 2074 6865  ed to delete the
    │ │ │ +00020170: 2073 6f75 7263 652e 0a09 0909 6966 2028   source.....if (
    │ │ │ +00020180: 636f 7069 6564 5f66 696c 6573 5b69 5d20  copied_files[i] 
    │ │ │ +00020190: 3d3d 2066 616c 7365 2920 636f 6e74 696e  == false) contin
    │ │ │ +000201a0: 7565 3b0a 0a09 0909 7374 643a 3a73 7472  ue;.....std::str
    │ │ │ +000201b0: 696e 6720 636f 6e73 7420 6f6c 645f 7061  ing const old_pa
    │ │ │ +000201c0: 7468 203d 2063 6f6d 6269 6e65 5f70 6174  th = combine_pat
    │ │ │ +000201d0: 6828 7361 7665 5f70 6174 682c 2066 2e66  h(save_path, f.f
    │ │ │ +000201e0: 696c 655f 7061 7468 2869 2929 3b0a 0a09  ile_path(i));...
    │ │ │ +000201f0: 0909 2f2f 2077 6520 6d61 7920 7374 696c  ..// we may stil
    │ │ │ +00020200: 6c20 6861 7665 2073 6f6d 6520 6669 6c65  l have some file
    │ │ │ +00020210: 7320 696e 206f 6c64 2073 6176 655f 7061  s in old save_pa
    │ │ │ +00020220: 7468 0a09 0909 2f2f 2065 672e 2069 6620  th....// eg. if 
    │ │ │ +00020230: 2866 6c61 6773 203d 3d20 646f 6e74 5f72  (flags == dont_r
    │ │ │ +00020240: 6570 6c61 6365 2026 616d 703b 2661 6d70  eplace &&
    │ │ │ +00020250: 3b20 6578 6973 7473 286e 6577 5f70 6174  ; exists(new_pat
    │ │ │ +00020260: 6829 290a 0909 092f 2f20 6967 6e6f 7265  h))....// ignore
    │ │ │ +00020270: 2065 7272 6f72 7320 7768 656e 2072 656d   errors when rem
    │ │ │ +00020280: 6f76 696e 670a 0909 0965 7272 6f72 5f63  oving....error_c
    │ │ │ +00020290: 6f64 6520 6967 6e6f 7265 3b0a 0909 0972  ode ignore;....r
    │ │ │ +000202a0: 656d 6f76 6528 6f6c 645f 7061 7468 2c20  emove(old_path, 
    │ │ │ +000202b0: 6967 6e6f 7265 293b 0a09 097d 0a0a 0909  ignore);...}....
    │ │ │ +000202c0: 666f 7220 2873 7464 3a3a 7374 7269 6e67  for (std::string
    │ │ │ +000202d0: 2063 6f6e 7374 2661 6d70 3b20 7320 3a20   const& s : 
    │ │ │ +000202e0: 7375 6264 6972 7329 0a09 097b 0a09 0909  subdirs)...{....
    │ │ │ +000202f0: 6572 726f 725f 636f 6465 2065 7272 3b0a  error_code err;.
    │ │ │ +00020300: 0909 0973 7464 3a3a 7374 7269 6e67 2073  ...std::string s
    │ │ │ +00020310: 7562 6469 7220 3d20 636f 6d62 696e 655f  ubdir = combine_
    │ │ │ +00020320: 7061 7468 2873 6176 655f 7061 7468 2c20  path(save_path, 
    │ │ │ +00020330: 7329 3b0a 0a09 0909 7768 696c 6520 2821  s);.....while (!
    │ │ │ +00020340: 7061 7468 5f65 7175 616c 2873 7562 6469  path_equal(subdi
    │ │ │ +00020350: 722c 2073 6176 655f 7061 7468 2920 2661  r, save_path) &a
    │ │ │ +00020360: 6d70 3b26 616d 703b 2021 6572 7229 0a09  mp;& !err)..
    │ │ │ +00020370: 0909 7b0a 0909 0909 7265 6d6f 7665 2873  ..{.....remove(s
    │ │ │ +00020380: 7562 6469 722c 2065 7272 293b 0a3c 2f70  ubdir, err);.

    re │ │ │ +000203c0: 6c65 7661 6e63 6526 6e62 7370 3b32 3c2f levance 2../src/st │ │ │ +00020400: 6f72 6167 655f 7574 696c 732e 6370 703a orage_utils.cpp: │ │ │ +00020410: 3438 373c 2f61 3e3c 2f74 643e 3c74 643e 487 │ │ │ +00020420: 6973 2074 6869 7320 7269 736b 793f 2054 is this risky? T │ │ │ +00020430: 6865 2075 7070 6572 206c 6179 6572 2077 he upper layer w │ │ │ +00020440: 696c 6c20 6173 7375 6d65 2077 6520 6861 ill assume we ha │ │ │ +00020450: 7665 2074 6865 2077 686f 6c65 2066 696c ve the whole fil │ │ │ +00020460: 652e 2050 6572 6861 7073 2077 6520 7368 e. Perhaps we sh │ │ │ +00020470: 6f75 6c64 2076 6572 6966 7920 7468 6174 ould verify that │ │ │ +00020480: 2061 7420 6c65 6173 7420 7468 6520 7369 at least the si │ │ │ +00020490: 7a65 206f 6620 7468 6520 6669 6c65 2069 ze of the file i │ │ │ +000204a0: 7320 636f 7272 6563 743c 2f74 643e 3c2f s correct

    is this ri │ │ │ +00020500: 736b 793f 2054 6865 2075 7070 6572 206c sky? The upper l │ │ │ +00020510: 6179 6572 2077 696c 6c20 6173 7375 6d65 ayer will assume │ │ │ +00020520: 2077 6520 6861 7665 2074 6865 0a77 686f we have the.who │ │ │ +00020530: 6c65 2066 696c 652e 2050 6572 6861 7073 le file. Perhaps │ │ │ +00020540: 2077 6520 7368 6f75 6c64 2076 6572 6966 we should verif │ │ │ +00020550: 7920 7468 6174 2061 7420 6c65 6173 7420 y that at least │ │ │ +00020560: 7468 6520 7369 7a65 0a6f 6620 7468 6520 the size.of the │ │ │ +00020570: 6669 6c65 2069 7320 636f 7272 6563 743c file is correct< │ │ │ +00020580: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f73 /h2>

    ../src/s │ │ │ +00020590: 746f 7261 6765 5f75 7469 6c73 2e63 7070 torage_utils.cpp │ │ │ +000205a0: 3a34 3837 3c2f 6834 3e3c 7072 6520 7374 :487

    ....{......//
    │ │ │ +000205f0: 2077 6520 6372 6561 7465 2064 6972 6563   we create direc
    │ │ │ +00020600: 746f 7269 6573 206c 617a 696c 792c 2073  tories lazily, s
    │ │ │ +00020610: 6f20 6974 2773 2070 6f73 7369 626c 6520  o it's possible 
    │ │ │ +00020620: 6974 2068 6173 6e27 740a 0909 0909 092f  it hasn't....../
    │ │ │ +00020630: 2f20 6265 656e 2063 7265 6174 6564 2079  / been created y
    │ │ │ +00020640: 6574 2e20 4372 6561 7465 2074 6865 2064  et. Create the d
    │ │ │ +00020650: 6972 6563 746f 7269 6573 206e 6f77 2061  irectories now a
    │ │ │ +00020660: 6e64 2074 7279 0a09 0909 0909 2f2f 2061  nd try......// a
    │ │ │ +00020670: 6761 696e 0a09 0909 0909 6372 6561 7465  gain......create
    │ │ │ +00020680: 5f64 6972 6563 746f 7269 6573 2870 6172  _directories(par
    │ │ │ +00020690: 656e 745f 7061 7468 2866 696c 655f 7061  ent_path(file_pa
    │ │ │ +000206a0: 7468 292c 2065 7272 293b 0a0a 0909 0909  th), err);......
    │ │ │ +000206b0: 0969 6620 2865 7272 290a 0909 0909 097b  .if (err)......{
    │ │ │ +000206c0: 0a09 0909 0909 0965 632e 6669 6c65 2869  .......ec.file(i
    │ │ │ +000206d0: 6478 293b 0a09 0909 0909 0965 632e 6f70  dx);.......ec.op
    │ │ │ +000206e0: 6572 6174 696f 6e20 3d20 6f70 6572 6174  eration = operat
    │ │ │ +000206f0: 696f 6e5f 743a 3a6d 6b64 6972 3b0a 0909  ion_t::mkdir;...
    │ │ │ +00020700: 0909 0909 7265 7475 726e 2066 616c 7365  ....return false
    │ │ │ +00020710: 3b0a 0909 0909 097d 0a0a 0909 0909 0968  ;......}.......h
    │ │ │ +00020720: 6172 645f 6c69 6e6b 2873 2c20 6669 6c65  ard_link(s, file
    │ │ │ +00020730: 5f70 6174 682c 2065 7272 293b 0a09 0909  _path, err);....
    │ │ │ +00020740: 097d 0a0a 0909 0909 2f2f 2069 6620 7468  .}......// if th
    │ │ │ +00020750: 6520 6669 6c65 2061 6c72 6561 6479 2065  e file already e
    │ │ │ +00020760: 7869 7374 732c 2074 6861 7427 7320 6e6f  xists, that's no
    │ │ │ +00020770: 7420 616e 2065 7272 6f72 0a09 0909 0969  t an error.....i
    │ │ │ +00020780: 6620 2865 7272 203d 3d20 626f 6f73 743a  f (err == boost:
    │ │ │ +00020790: 3a73 7973 7465 6d3a 3a65 7272 633a 3a66  :system::errc::f
    │ │ │ +000207a0: 696c 655f 6578 6973 7473 290a 0909 0909  ile_exists).....
    │ │ │ +000207b0: 0963 6f6e 7469 6e75 653b 0a0a 3c64 6976  .continue;..
    ....if │ │ │ +000207f0: 2028 6572 7229 0a3c 2f64 6976 3e09 0909 (err).
    ... │ │ │ +00020800: 097b 0a09 0909 0909 6563 2e65 6320 3d20 .{......ec.ec = │ │ │ +00020810: 6572 723b 0a09 0909 0909 6563 2e66 696c err;......ec.fil │ │ │ +00020820: 6528 6964 7829 3b0a 0909 0909 0965 632e e(idx);......ec. │ │ │ +00020830: 6f70 6572 6174 696f 6e20 3d20 6f70 6572 operation = oper │ │ │ +00020840: 6174 696f 6e5f 743a 3a66 696c 655f 6861 ation_t::file_ha │ │ │ +00020850: 7264 5f6c 696e 6b3b 0a09 0909 0909 7265 rd_link;......re │ │ │ +00020860: 7475 726e 2066 616c 7365 3b0a 0909 0909 turn false;..... │ │ │ +00020870: 7d0a 0909 0909 6164 6465 645f 6669 6c65 }.....added_file │ │ │ +00020880: 7320 3d20 7472 7565 3b0a 0909 0909 7374 s = true;.....st │ │ │ +00020890: 6174 2e73 6574 5f64 6972 7479 2869 6478 at.set_dirty(idx │ │ │ +000208a0: 293b 0a09 0909 7d0a 0909 7d0a 2365 6e64 );....}...}.#end │ │ │ +000208b0: 6966 202f 2f20 544f 5252 454e 545f 4449 if // TORRENT_DI │ │ │ +000208c0: 5341 424c 455f 4d55 5441 424c 455f 544f SABLE_MUTABLE_TO │ │ │ +000208d0: 5252 454e 5453 0a0a 0909 626f 6f6c 2063 RRENTS....bool c │ │ │ +000208e0: 6f6e 7374 2073 6565 6420 3d20 2872 642e onst seed = (rd. │ │ │ +000208f0: 6861 7665 5f70 6965 6365 732e 7369 7a65 have_pieces.size │ │ │ +00020900: 2829 2026 6774 3b3d 2066 732e 6e75 6d5f () >= fs.num_ │ │ │ +00020910: 7069 6563 6573 2829 0a09 0909 2661 6d70 pieces()....& │ │ │ +00020920: 3b26 616d 703b 2072 642e 6861 7665 5f70 ;& rd.have_p │ │ │ +00020930: 6965 6365 732e 616c 6c5f 7365 7428 2929 ieces.all_set()) │ │ │ +00020940: 0a09 0909 7c7c 2028 7264 2e66 6c61 6773 ....|| (rd.flags │ │ │ +00020950: 2026 616d 703b 2074 6f72 7265 6e74 5f66 & torrent_f │ │ │ +00020960: 6c61 6773 3a3a 7365 6564 5f6d 6f64 6529 lags::seed_mode) │ │ │ +00020970: 3b0a 0a09 0969 6620 2873 6565 6429 0a09 ;....if (seed).. │ │ │ +00020980: 097b 0a09 0909 666f 7220 2866 696c 655f .{....for (file_ │ │ │ +00020990: 696e 6465 785f 7420 636f 6e73 7420 6669 index_t const fi │ │ │ +000209a0: 6c65 5f69 6e64 6578 203a 2066 732e 6669 le_index : fs.fi │ │ │ +000209b0: 6c65 5f72 616e 6765 2829 290a 0909 097b le_range())....{ │ │ │ +000209c0: 0a09 0909 0969 6620 2866 732e 7061 645f .....if (fs.pad_ │ │ │ +000209d0: 6669 6c65 5f61 7428 6669 6c65 5f69 6e64 file_at(file_ind │ │ │ +000209e0: 6578 2929 2063 6f6e 7469 6e75 653b 0a0a ex)) continue;.. │ │ │ +000209f0: 0909 0909 2f2f 2066 696c 6573 2077 6974 ....// files wit │ │ │ +00020a00: 6820 7072 696f 7269 7479 207a 6572 6f20 h priority zero │ │ │ +00020a10: 6d61 7920 6e6f 7420 6861 7665 2062 6565 may not have bee │ │ │ +00020a20: 6e20 7361 7665 6420 746f 2064 6973 6b20 n saved to disk │ │ │ +00020a30: 6174 2074 6865 6972 0a09 0909 092f 2f20 at their.....// │ │ │ +00020a40: 6578 7065 6374 6564 206c 6f63 6174 696f expected locatio │ │ │ +00020a50: 6e2c 2062 7574 2069 7320 6c69 6b65 6c79 n, but is likely │ │ │ +00020a60: 2074 6f20 6265 2069 6e20 6120 7061 7274 to be in a part │ │ │ +00020a70: 6669 6c65 2e20 4a75 7374 2065 7865 6d70 file. Just exemp │ │ │ +00020a80: 7420 6974 0a09 0909 092f 2f20 6672 6f6d t it.....// from │ │ │ +00020a90: 2063 6865 636b 696e 670a 0909 0909 6966 checking.....if │ │ │ +00020aa0: 2028 6669 6c65 5f69 6e64 6578 2026 6c74 (file_index < │ │ │ +00020ab0: 3b20 6669 6c65 5f70 7269 6f72 6974 792e ; file_priority. │ │ │ +00020ac0: 656e 645f 696e 6465 7828 290a 0909 0909 end_index()..... │ │ │ +00020ad0: 0926 616d 703b 2661 6d70 3b20 6669 6c65 .&& file │ │ │ +00020ae0: 5f70 7269 6f72 6974 795b 6669 6c65 5f69 _priority[file_i │ │ │ +00020af0: 6e64 6578 5d20 3d3d 2064 6f6e 745f 646f ndex] == dont_do │ │ │ +00020b00: 776e 6c6f 6164 0a09 0909 0909 2661 6d70 wnload......& │ │ │ +00020b10: 3b26 616d 703b 2021 2872 642e 666c 6167 ;& !(rd.flag │ │ │ +00020b20: 7320 2661 6d70 3b20 746f 7272 656e 745f s & torrent_ │ │ │ +00020b30: 666c 6167 733a 3a73 6565 645f 6d6f 6465 flags::seed_mode │ │ │ +00020b40: 2929 0a09 0909 0909 636f 6e74 696e 7565 ))......continue │ │ │ +00020b50: 3b0a 0a3c 2f70 7265 3e3c 2f74 643e 3c2f ;..
    │ │ │ +00020b80: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00020b90: 7370 3b32 3c2f 7464 3e3c 7464 3e3c 6120 sp;2../ │ │ │ +00020bc0: 7372 632f 7061 7468 2e63 7070 3a34 3336 src/path.cpp:436 │ │ │ +00020bd0: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6573 tes │ │ │ +00020be0: 7420 7468 6973 206f 6e20 6120 4641 5420 t this on a FAT │ │ │ +00020bf0: 766f 6c75 6d65 2074 6f20 7365 6520 7768 volume to see wh │ │ │ +00020c00: 6174 2065 7272 6f72 2077 6520 6765 7421 at error we get! │ │ │ +00020c10: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    tes │ │ │ +00020c60: 7420 7468 6973 206f 6e20 6120 4641 5420 t this on a FAT │ │ │ +00020c70: 766f 6c75 6d65 2074 6f20 7365 6520 7768 volume to see wh │ │ │ +00020c80: 6174 2065 7272 6f72 2077 6520 6765 7421 at error we get! │ │ │ +00020c90: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +00020ca0: 7061 7468 2e63 7070 3a34 3336 3c2f 6834 path.cpp:436

    ...//
    │ │ │ +00020cf0: 2069 7427 7320 706f 7373 6962 6c65 2043   it's possible C
    │ │ │ +00020d00: 7265 6174 6548 6172 644c 696e 6b20 7769  reateHardLink wi
    │ │ │ +00020d10: 6c6c 2063 6f70 7920 7468 6520 6669 6c65  ll copy the file
    │ │ │ +00020d20: 2069 6e74 6572 6e61 6c6c 7920 746f 6f2c   internally too,
    │ │ │ +00020d30: 0a09 0909 2f2f 2069 6620 7468 6520 6669  ....// if the fi
    │ │ │ +00020d40: 6c65 7379 7374 656d 2064 6f65 7320 6e6f  lesystem does no
    │ │ │ +00020d50: 7420 7375 7070 6f72 7420 6974 2e0a 0909  t support it....
    │ │ │ +00020d60: 0965 632e 6173 7369 676e 2847 6574 4c61  .ec.assign(GetLa
    │ │ │ +00020d70: 7374 4572 726f 7228 292c 2073 7973 7465  stError(), syste
    │ │ │ +00020d80: 6d5f 6361 7465 676f 7279 2829 293b 0a09  m_category());..
    │ │ │ +00020d90: 0909 7265 7475 726e 3b0a 0909 7d0a 0a09  ..return;...}...
    │ │ │ +00020da0: 092f 2f20 6661 6c6c 2062 6163 6b20 746f  .// fall back to
    │ │ │ +00020db0: 206d 616b 696e 6720 6120 636f 7079 0a23   making a copy.#
    │ │ │ +00020dc0: 656e 6469 660a 2365 6c73 650a 0909 2f2f  endif.#else...//
    │ │ │ +00020dd0: 2061 7373 756d 6520 706f 7369 7827 7320   assume posix's 
    │ │ │ +00020de0: 6c69 6e6b 2829 2066 756e 6374 696f 6e20  link() function 
    │ │ │ +00020df0: 6578 6973 7473 0a09 0969 6e74 2072 6574  exists...int ret
    │ │ │ +00020e00: 203d 203a 3a6c 696e 6b28 6e5f 6578 6973   = ::link(n_exis
    │ │ │ +00020e10: 742e 635f 7374 7228 292c 206e 5f6c 696e  t.c_str(), n_lin
    │ │ │ +00020e20: 6b2e 635f 7374 7228 2929 3b0a 0a09 0969  k.c_str());....i
    │ │ │ +00020e30: 6620 2872 6574 203d 3d20 3029 0a09 097b  f (ret == 0)...{
    │ │ │ +00020e40: 0a09 0909 6563 2e63 6c65 6172 2829 3b0a  ....ec.clear();.
    │ │ │ +00020e50: 0909 0972 6574 7572 6e3b 0a09 097d 0a0a  ...return;...}..
    │ │ │ +00020e60: 0909 2f2f 206d 6f73 7420 6572 726f 7273  ..// most errors
    │ │ │ +00020e70: 2061 7265 2070 6173 7365 6420 7468 726f   are passed thro
    │ │ │ +00020e80: 7567 682c 2065 7863 6570 7420 666f 7220  ugh, except for 
    │ │ │ +00020e90: 7468 6520 6f6e 6573 2074 6861 7420 696e  the ones that in
    │ │ │ +00020ea0: 6469 6361 7465 2074 6861 740a 0909 2f2f  dicate that...//
    │ │ │ +00020eb0: 2068 6172 6420 6c69 6e6b 7320 6172 6520   hard links are 
    │ │ │ +00020ec0: 6e6f 7420 7375 7070 6f72 7465 6420 616e  not supported an
    │ │ │ +00020ed0: 6420 7265 7175 6972 6520 6120 636f 7079  d require a copy
    │ │ │ +00020ee0: 2e0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +00020f10: 0909 6966 2028 6572 726e 6f20 213d 2045 ..if (errno != E │ │ │ +00020f20: 4d4c 494e 4b0a 3c2f 6469 763e 0909 0926 MLINK.
    ...& │ │ │ +00020f30: 616d 703b 2661 6d70 3b20 6572 726e 6f20 amp;& errno │ │ │ +00020f40: 213d 2045 5844 4556 0a23 6966 6465 6620 != EXDEV.#ifdef │ │ │ +00020f50: 544f 5252 454e 545f 4245 4f53 0a09 0909 TORRENT_BEOS.... │ │ │ +00020f60: 2f2f 2068 6169 6b75 2072 6574 7572 6e73 // haiku returns │ │ │ +00020f70: 2045 5045 524d 2077 6865 6e20 7468 6520 EPERM when the │ │ │ +00020f80: 6669 6c65 7379 7374 656d 2064 6f65 736e filesystem doesn │ │ │ +00020f90: 2774 2073 7570 706f 7274 2068 6172 6420 't support hard │ │ │ +00020fa0: 6c69 6e6b 0a09 0909 2661 6d70 3b26 616d link....&&am │ │ │ +00020fb0: 703b 2065 7272 6e6f 2021 3d20 4550 4552 p; errno != EPER │ │ │ +00020fc0: 4d0a 2365 6e64 6966 0a09 0909 290a 0909 M.#endif....)... │ │ │ +00020fd0: 7b0a 0909 092f 2f20 736f 6d65 2065 7272 {....// some err │ │ │ +00020fe0: 6f72 2068 6170 7065 6e65 642c 2072 6570 or happened, rep │ │ │ +00020ff0: 6f72 7420 7570 2074 6f20 7468 6520 6361 ort up to the ca │ │ │ +00021000: 6c6c 6572 0a09 0909 6563 2e61 7373 6967 ller....ec.assig │ │ │ +00021010: 6e28 6572 726e 6f2c 2073 7973 7465 6d5f n(errno, system_ │ │ │ +00021020: 6361 7465 676f 7279 2829 293b 0a09 0909 category());.... │ │ │ +00021030: 7265 7475 726e 3b0a 0909 7d0a 0a09 092f return;...}..../ │ │ │ +00021040: 2f20 6661 6c6c 2062 6163 6b20 746f 206d / fall back to m │ │ │ +00021050: 616b 696e 6720 6120 636f 7079 0a0a 2365 aking a copy..#e │ │ │ +00021060: 6e64 6966 0a0a 0909 2f2f 2069 6620 7765 ndif....// if we │ │ │ +00021070: 2067 6574 2068 6572 652c 2077 6520 7368 get here, we sh │ │ │ +00021080: 6f75 6c64 2063 6f70 7920 7468 6520 6669 ould copy the fi │ │ │ +00021090: 6c65 0a09 0973 746f 7261 6765 5f65 7272 le...storage_err │ │ │ +000210a0: 6f72 2073 653b 0a09 0961 7578 3a3a 636f or se;...aux::co │ │ │ +000210b0: 7079 5f66 696c 6528 6669 6c65 2c20 6c69 py_file(file, li │ │ │ +000210c0: 6e6b 2c20 7365 293b 0a09 0965 6320 3d20 nk, se);...ec = │ │ │ +000210d0: 7365 2e65 633b 0a09 7d0a 0a09 626f 6f6c se.ec;..}...bool │ │ │ +000210e0: 2069 735f 6469 7265 6374 6f72 7928 7374 is_directory(st │ │ │ +000210f0: 643a 3a73 7472 696e 6720 636f 6e73 7426 d::string const& │ │ │ +00021100: 616d 703b 2066 2c20 6572 726f 725f 636f amp; f, error_co │ │ │ +00021110: 6465 2661 6d70 3b20 6563 290a 097b 0a09 de& ec)..{.. │ │ │ +00021120: 0965 632e 636c 6561 7228 293b 0a09 0965 .ec.clear();...e │ │ │ +00021130: 7272 6f72 5f63 6f64 6520 653b 0a09 0966 rror_code e;...f │ │ │ +00021140: 696c 655f 7374 6174 7573 2073 3b0a 0909 ile_status s;... │ │ │ +00021150: 7374 6174 5f66 696c 6528 662c 2026 616d stat_file(f, &am │ │ │ +00021160: 703b 732c 2065 293b 0a09 0969 6620 2821 p;s, e);...if (! │ │ │ +00021170: 6520 2661 6d70 3b26 616d 703b 2073 2e6d e && s.m │ │ │ +00021180: 6f64 6520 2661 6d70 3b20 6669 6c65 5f73 ode & file_s │ │ │ +00021190: 7461 7475 733a 3a64 6972 6563 746f 7279 tatus::directory │ │ │ +000211a0: 2920 7265 7475 726e 2074 7275 653b 0a09 ) return true;.. │ │ │ +000211b0: 0965 6320 3d20 653b 0a3c 2f70 7265 3e3c .ec = e;.
    < │ │ │ +000211c0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +000211f0: 6e63 6526 6e62 7370 3b32 3c2f 7464 3e3c nce 2< │ │ │ +00021200: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/http_t │ │ │ +00021230: 7261 636b 6572 5f63 6f6e 6e65 6374 696f racker_connectio │ │ │ +00021240: 6e2e 6370 703a 3438 363c 2f61 3e3c 2f74 n.cpp:486returning │ │ │ +00021260: 6120 626f 6f6c 2068 6572 6520 6973 2072 a bool here is r │ │ │ +00021270: 6564 756e 6461 6e74 2e20 496e 7374 6561 edundant. Instea │ │ │ +00021280: 6420 7468 6973 2066 756e 6374 696f 6e20 d this function │ │ │ +00021290: 7368 6f75 6c64 2072 6574 7572 6e20 7468 should return th │ │ │ +000212a0: 6520 7065 6572 5f65 6e74 7279 3c2f 7464 e peer_entry

    returni │ │ │ +00021300: 6e67 2061 2062 6f6f 6c20 6865 7265 2069 ng a bool here i │ │ │ +00021310: 7320 7265 6475 6e64 616e 742e 2049 6e73 s redundant. Ins │ │ │ +00021320: 7465 6164 2074 6869 7320 6675 6e63 7469 tead this functi │ │ │ +00021330: 6f6e 2073 686f 756c 640a 7265 7475 726e on should.return │ │ │ +00021340: 2074 6865 2070 6565 725f 656e 7472 793c the peer_entry< │ │ │ +00021350: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f68 /h2>

    ../src/h │ │ │ +00021360: 7474 705f 7472 6163 6b65 725f 636f 6e6e ttp_tracker_conn │ │ │ +00021370: 6563 7469 6f6e 2e63 7070 3a34 3836 3c2f ection.cpp:486
    ..{
    │ │ │ +000213c0: 0a09 0909 6362 2d26 6774 3b74 7261 636b  ....cb->track
    │ │ │ +000213d0: 6572 5f73 6372 6170 655f 7265 7370 6f6e  er_scrape_respon
    │ │ │ +000213e0: 7365 2874 7261 636b 6572 5f72 6571 2829  se(tracker_req()
    │ │ │ +000213f0: 2c20 7265 7370 2e63 6f6d 706c 6574 650a  , resp.complete.
    │ │ │ +00021400: 0909 0909 2c20 7265 7370 2e69 6e63 6f6d  ...., resp.incom
    │ │ │ +00021410: 706c 6574 652c 2072 6573 702e 646f 776e  plete, resp.down
    │ │ │ +00021420: 6c6f 6164 6564 2c20 7265 7370 2e64 6f77  loaded, resp.dow
    │ │ │ +00021430: 6e6c 6f61 6465 7273 293b 0a09 097d 0a09  nloaders);...}..
    │ │ │ +00021440: 0965 6c73 650a 0909 7b0a 0909 0973 7464  .else...{....std
    │ │ │ +00021450: 3a3a 6c69 7374 266c 743b 6164 6472 6573  ::list<addres
    │ │ │ +00021460: 7326 6774 3b20 6970 5f6c 6973 743b 0a09  s> ip_list;..
    │ │ │ +00021470: 0909 6966 2028 6d5f 7472 6163 6b65 725f  ..if (m_tracker_
    │ │ │ +00021480: 636f 6e6e 6563 7469 6f6e 290a 0909 097b  connection)....{
    │ │ │ +00021490: 0a09 0909 0966 6f72 2028 6175 746f 2063  .....for (auto c
    │ │ │ +000214a0: 6f6e 7374 2661 6d70 3b20 656e 6470 203a  onst& endp :
    │ │ │ +000214b0: 206d 5f74 7261 636b 6572 5f63 6f6e 6e65   m_tracker_conne
    │ │ │ +000214c0: 6374 696f 6e2d 2667 743b 656e 6470 6f69  ction->endpoi
    │ │ │ +000214d0: 6e74 7328 2929 0a09 0909 097b 0a09 0909  nts()).....{....
    │ │ │ +000214e0: 0909 6970 5f6c 6973 742e 7075 7368 5f62  ..ip_list.push_b
    │ │ │ +000214f0: 6163 6b28 656e 6470 2e61 6464 7265 7373  ack(endp.address
    │ │ │ +00021500: 2829 293b 0a09 0909 097d 0a09 0909 7d0a  ());.....}....}.
    │ │ │ +00021510: 0a09 0909 6362 2d26 6774 3b74 7261 636b  ....cb->track
    │ │ │ +00021520: 6572 5f72 6573 706f 6e73 6528 7472 6163  er_response(trac
    │ │ │ +00021530: 6b65 725f 7265 7128 292c 206d 5f74 7261  ker_req(), m_tra
    │ │ │ +00021540: 636b 6572 5f69 702c 2069 705f 6c69 7374  cker_ip, ip_list
    │ │ │ +00021550: 2c20 7265 7370 293b 0a09 097d 0a09 0963  , resp);...}...c
    │ │ │ +00021560: 6c6f 7365 2829 3b0a 097d 0a0a 3c64 6976  lose();..}..
    .bool │ │ │ +000215a0: 6578 7472 6163 745f 7065 6572 5f69 6e66 extract_peer_inf │ │ │ +000215b0: 6f28 6264 6563 6f64 655f 6e6f 6465 2063 o(bdecode_node c │ │ │ +000215c0: 6f6e 7374 2661 6d70 3b20 696e 666f 2c20 onst& info, │ │ │ +000215d0: 7065 6572 5f65 6e74 7279 2661 6d70 3b20 peer_entry& │ │ │ +000215e0: 7265 742c 2065 7272 6f72 5f63 6f64 6526 ret, error_code& │ │ │ +000215f0: 616d 703b 2065 6329 0a3c 2f64 6976 3e09 amp; ec).
    . │ │ │ +00021600: 7b0a 0909 2f2f 2065 7874 7261 6374 2070 {...// extract p │ │ │ +00021610: 6565 7220 6964 2028 6966 2061 6e79 290a eer id (if any). │ │ │ +00021620: 0909 6966 2028 696e 666f 2e74 7970 6528 ..if (info.type( │ │ │ +00021630: 2920 213d 2062 6465 636f 6465 5f6e 6f64 ) != bdecode_nod │ │ │ +00021640: 653a 3a64 6963 745f 7429 0a09 097b 0a09 e::dict_t)...{.. │ │ │ +00021650: 0909 6563 203d 2065 7272 6f72 733a 3a69 ..ec = errors::i │ │ │ +00021660: 6e76 616c 6964 5f70 6565 725f 6469 6374 nvalid_peer_dict │ │ │ +00021670: 3b0a 0909 0972 6574 7572 6e20 6661 6c73 ;....return fals │ │ │ +00021680: 653b 0a09 097d 0a09 0962 6465 636f 6465 e;...}...bdecode │ │ │ +00021690: 5f6e 6f64 6520 6920 3d20 696e 666f 2e64 _node i = info.d │ │ │ +000216a0: 6963 745f 6669 6e64 5f73 7472 696e 6728 ict_find_string( │ │ │ +000216b0: 2270 6565 7220 6964 2229 3b0a 0909 6966 "peer id");...if │ │ │ +000216c0: 2028 6920 2661 6d70 3b26 616d 703b 2069 (i && i │ │ │ +000216d0: 2e73 7472 696e 675f 6c65 6e67 7468 2829 .string_length() │ │ │ +000216e0: 203d 3d20 3230 290a 0909 7b0a 0909 0973 == 20)...{....s │ │ │ +000216f0: 7464 3a3a 636f 7079 2869 2e73 7472 696e td::copy(i.strin │ │ │ +00021700: 675f 7074 7228 292c 2069 2e73 7472 696e g_ptr(), i.strin │ │ │ +00021710: 675f 7074 7228 2920 2b20 3230 2c20 7265 g_ptr() + 20, re │ │ │ +00021720: 742e 7069 642e 6265 6769 6e28 2929 3b0a t.pid.begin());. │ │ │ +00021730: 0909 7d0a 0909 656c 7365 0a09 097b 0a09 ..}...else...{.. │ │ │ +00021740: 0909 2f2f 2069 6620 7468 6572 6527 7320 ..// if there's │ │ │ +00021750: 6e6f 2070 6565 725f 6964 2c20 6a75 7374 no peer_id, just │ │ │ +00021760: 2069 6e69 7469 616c 697a 6520 6974 2074 initialize it t │ │ │ +00021770: 6f20 6120 6275 6e63 6820 6f66 207a 6572 o a bunch of zer │ │ │ +00021780: 6f65 730a 0909 0972 6574 2e70 6964 2e63 oes....ret.pid.c │ │ │ +00021790: 6c65 6172 2829 3b0a 0909 7d0a 0a09 092f lear();...}..../ │ │ │ +000217a0: 2f20 6578 7472 6163 7420 6970 0a09 0969 / extract ip...i │ │ │ +000217b0: 203d 2069 6e66 6f2e 6469 6374 5f66 696e = info.dict_fin │ │ │ +000217c0: 645f 7374 7269 6e67 2822 6970 2229 3b0a d_string("ip");. │ │ │ +000217d0: 0909 6966 2028 2169 290a 0909 7b0a 0909 ..if (!i)...{... │ │ │ +000217e0: 0965 6320 3d20 6572 726f 7273 3a3a 696e .ec = errors::in │ │ │ +000217f0: 7661 6c69 645f 7472 6163 6b65 725f 7265 valid_tracker_re │ │ │ +00021800: 7370 6f6e 7365 3b0a 0909 0972 6574 7572 sponse;....retur │ │ │ +00021810: 6e20 6661 6c73 653b 0a09 097d 0a09 0972 n false;...}...r │ │ │ +00021820: 6574 2e68 6f73 746e 616d 6520 3d20 692e et.hostname = i. │ │ │ +00021830: 7374 7269 6e67 5f76 616c 7565 2829 2e74 string_value().t │ │ │ +00021840: 6f5f 7374 7269 6e67 2829 3b0a 0a09 092f o_string();..../ │ │ │ +00021850: 2f20 6578 7472 6163 7420 706f 7274 0a09 / extract port.. │ │ │ +00021860: 0969 203d 2069 6e66 6f2e 6469 6374 5f66 .i = info.dict_f │ │ │ +00021870: 696e 645f 696e 7428 2270 6f72 7422 293b ind_int("port"); │ │ │ +00021880: 0a09 0969 6620 2821 6929 0a3c 2f70 7265 ...if (!i).
    rele │ │ │ +000218c0: 7661 6e63 6526 6e62 7370 3b32 3c2f 7464 vance 2../src/inst │ │ │ +00021900: 616e 7469 6174 655f 636f 6e6e 6563 7469 antiate_connecti │ │ │ +00021910: 6f6e 2e63 7070 3a34 343c 2f61 3e3c 2f74 on.cpp:44peer_conne │ │ │ +00021930: 6374 696f 6e20 616e 6420 7472 6163 6b65 ction and tracke │ │ │ +00021940: 725f 636f 6e6e 6563 7469 6f6e 2073 686f r_connection sho │ │ │ +00021950: 756c 6420 7072 6f62 6162 6c79 2062 6520 uld probably be │ │ │ +00021960: 666c 6167 733c 2f74 643e 3c2f 7472 3e3c flags< │ │ │ +00021970: 7472 2069 643d 2236 3622 2073 7479 6c65 tr id="66" style │ │ │ +00021980: 3d22 6469 7370 6c61 793a 206e 6f6e 653b ="display: none; │ │ │ +00021990: 2220 636f 6c73 7061 6e3d 2233 223e 3c74 " colspan="3">peer_connectio │ │ │ +000219c0: 6e20 616e 6420 7472 6163 6b65 725f 636f n and tracker_co │ │ │ +000219d0: 6e6e 6563 7469 6f6e 2073 686f 756c 6420 nnection should │ │ │ +000219e0: 7072 6f62 6162 6c79 2062 6520 666c 6167 probably be flag │ │ │ +000219f0: 733c 2f68 323e 3c68 343e 2e2e 2f73 7263 s

    ../src │ │ │ +00021a00: 2f69 6e73 7461 6e74 6961 7465 5f63 6f6e /instantiate_con │ │ │ +00021a10: 6e65 6374 696f 6e2e 6370 703a 3434 3c2f nection.cpp:44
    ARE
    │ │ │ +00021a60: 2044 4953 434c 4149 4d45 442e 2049 4e20   DISCLAIMED. IN 
    │ │ │ +00021a70: 4e4f 2045 5645 4e54 2053 4841 4c4c 2054  NO EVENT SHALL T
    │ │ │ +00021a80: 4845 2043 4f50 5952 4947 4854 204f 574e  HE COPYRIGHT OWN
    │ │ │ +00021a90: 4552 204f 5220 434f 4e54 5249 4255 544f  ER OR CONTRIBUTO
    │ │ │ +00021aa0: 5253 2042 450a 4c49 4142 4c45 2046 4f52  RS BE.LIABLE FOR
    │ │ │ +00021ab0: 2041 4e59 2044 4952 4543 542c 2049 4e44   ANY DIRECT, IND
    │ │ │ +00021ac0: 4952 4543 542c 2049 4e43 4944 454e 5441  IRECT, INCIDENTA
    │ │ │ +00021ad0: 4c2c 2053 5045 4349 414c 2c20 4558 454d  L, SPECIAL, EXEM
    │ │ │ +00021ae0: 504c 4152 592c 204f 520a 434f 4e53 4551  PLARY, OR.CONSEQ
    │ │ │ +00021af0: 5545 4e54 4941 4c20 4441 4d41 4745 5320  UENTIAL DAMAGES 
    │ │ │ +00021b00: 2849 4e43 4c55 4449 4e47 2c20 4255 5420  (INCLUDING, BUT 
    │ │ │ +00021b10: 4e4f 5420 4c49 4d49 5445 4420 544f 2c20  NOT LIMITED TO, 
    │ │ │ +00021b20: 5052 4f43 5552 454d 454e 5420 4f46 0a53  PROCUREMENT OF.S
    │ │ │ +00021b30: 5542 5354 4954 5554 4520 474f 4f44 5320  UBSTITUTE GOODS 
    │ │ │ +00021b40: 4f52 2053 4552 5649 4345 533b 204c 4f53  OR SERVICES; LOS
    │ │ │ +00021b50: 5320 4f46 2055 5345 2c20 4441 5441 2c20  S OF USE, DATA, 
    │ │ │ +00021b60: 4f52 2050 524f 4649 5453 3b20 4f52 2042  OR PROFITS; OR B
    │ │ │ +00021b70: 5553 494e 4553 530a 494e 5445 5252 5550  USINESS.INTERRUP
    │ │ │ +00021b80: 5449 4f4e 2920 484f 5745 5645 5220 4341  TION) HOWEVER CA
    │ │ │ +00021b90: 5553 4544 2041 4e44 204f 4e20 414e 5920  USED AND ON ANY 
    │ │ │ +00021ba0: 5448 454f 5259 204f 4620 4c49 4142 494c  THEORY OF LIABIL
    │ │ │ +00021bb0: 4954 592c 2057 4845 5448 4552 2049 4e0a  ITY, WHETHER IN.
    │ │ │ +00021bc0: 434f 4e54 5241 4354 2c20 5354 5249 4354  CONTRACT, STRICT
    │ │ │ +00021bd0: 204c 4941 4249 4c49 5459 2c20 4f52 2054   LIABILITY, OR T
    │ │ │ +00021be0: 4f52 5420 2849 4e43 4c55 4449 4e47 204e  ORT (INCLUDING N
    │ │ │ +00021bf0: 4547 4c49 4745 4e43 4520 4f52 204f 5448  EGLIGENCE OR OTH
    │ │ │ +00021c00: 4552 5749 5345 290a 4152 4953 494e 4720  ERWISE).ARISING 
    │ │ │ +00021c10: 494e 2041 4e59 2057 4159 204f 5554 204f  IN ANY WAY OUT O
    │ │ │ +00021c20: 4620 5448 4520 5553 4520 4f46 2054 4849  F THE USE OF THI
    │ │ │ +00021c30: 5320 534f 4654 5741 5245 2c20 4556 454e  S SOFTWARE, EVEN
    │ │ │ +00021c40: 2049 4620 4144 5649 5345 4420 4f46 2054   IF ADVISED OF T
    │ │ │ +00021c50: 4845 0a50 4f53 5349 4249 4c49 5459 204f  HE.POSSIBILITY O
    │ │ │ +00021c60: 4620 5355 4348 2044 414d 4147 452e 0a0a  F SUCH DAMAGE...
    │ │ │ +00021c70: 2a2f 0a0a 2369 6e63 6c75 6465 2022 6c69  */..#include "li
    │ │ │ +00021c80: 6274 6f72 7265 6e74 2f73 6f63 6b65 742e  btorrent/socket.
    │ │ │ +00021c90: 6870 7022 0a23 696e 636c 7564 6520 226c  hpp".#include "l
    │ │ │ +00021ca0: 6962 746f 7272 656e 742f 6175 785f 2f73  ibtorrent/aux_/s
    │ │ │ +00021cb0: 6f63 6b65 745f 7479 7065 2e68 7070 220a  ocket_type.hpp".
    │ │ │ +00021cc0: 2369 6e63 6c75 6465 2022 6c69 6274 6f72  #include "libtor
    │ │ │ +00021cd0: 7265 6e74 2f61 7578 5f2f 7574 705f 736f  rent/aux_/utp_so
    │ │ │ +00021ce0: 636b 6574 5f6d 616e 6167 6572 2e68 7070  cket_manager.hpp
    │ │ │ +00021cf0: 220a 2369 6e63 6c75 6465 2022 6c69 6274  ".#include "libt
    │ │ │ +00021d00: 6f72 7265 6e74 2f61 7578 5f2f 696e 7374  orrent/aux_/inst
    │ │ │ +00021d10: 616e 7469 6174 655f 636f 6e6e 6563 7469  antiate_connecti
    │ │ │ +00021d20: 6f6e 2e68 7070 220a 2369 6e63 6c75 6465  on.hpp".#include
    │ │ │ +00021d30: 2022 6c69 6274 6f72 7265 6e74 2f61 7578   "libtorrent/aux
    │ │ │ +00021d40: 5f2f 7574 705f 7374 7265 616d 2e68 7070  _/utp_stream.hpp
    │ │ │ +00021d50: 220a 2369 6e63 6c75 6465 2022 6c69 6274  ".#include "libt
    │ │ │ +00021d60: 6f72 7265 6e74 2f73 736c 5f73 7472 6561  orrent/ssl_strea
    │ │ │ +00021d70: 6d2e 6870 7022 0a0a 6e61 6d65 7370 6163  m.hpp"..namespac
    │ │ │ +00021d80: 6520 6c69 6274 6f72 7265 6e74 207b 206e  e libtorrent { n
    │ │ │ +00021d90: 616d 6573 7061 6365 2061 7578 207b 0a0a  amespace aux {..
    │ │ │ +00021da0: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .a │ │ │ +00021dd0: 7578 3a3a 736f 636b 6574 5f74 7970 6520 ux::socket_type │ │ │ +00021de0: 696e 7374 616e 7469 6174 655f 636f 6e6e instantiate_conn │ │ │ +00021df0: 6563 7469 6f6e 2869 6f5f 636f 6e74 6578 ection(io_contex │ │ │ +00021e00: 7426 616d 703b 2069 6f73 0a3c 2f64 6976 t& ios.
    .., aux::proxy_ │ │ │ +00021e20: 7365 7474 696e 6773 2063 6f6e 7374 2661 settings const&a │ │ │ +00021e30: 6d70 3b20 7073 0a09 092c 2076 6f69 642a mp; ps..., void* │ │ │ +00021e40: 2073 736c 5f63 6f6e 7465 7874 0a09 092c ssl_context..., │ │ │ +00021e50: 2075 7470 5f73 6f63 6b65 745f 6d61 6e61 utp_socket_mana │ │ │ +00021e60: 6765 722a 2073 6d0a 0909 2c20 626f 6f6c ger* sm..., bool │ │ │ +00021e70: 2070 6565 725f 636f 6e6e 6563 7469 6f6e peer_connection │ │ │ +00021e80: 0a09 092c 2062 6f6f 6c20 7472 6163 6b65 ..., bool tracke │ │ │ +00021e90: 725f 636f 6e6e 6563 7469 6f6e 290a 097b r_connection)..{ │ │ │ +00021ea0: 0a23 6966 2021 544f 5252 454e 545f 5553 .#if !TORRENT_US │ │ │ +00021eb0: 455f 5353 4c0a 0909 544f 5252 454e 545f E_SSL...TORRENT_ │ │ │ +00021ec0: 554e 5553 4544 2873 736c 5f63 6f6e 7465 UNUSED(ssl_conte │ │ │ +00021ed0: 7874 293b 0a23 656e 6469 660a 0a09 0969 xt);.#endif....i │ │ │ +00021ee0: 6620 2873 6d29 0a09 097b 0a23 6966 2054 f (sm)...{.#if T │ │ │ +00021ef0: 4f52 5245 4e54 5f55 5345 5f53 534c 0a09 ORRENT_USE_SSL.. │ │ │ +00021f00: 0909 6966 2028 7373 6c5f 636f 6e74 6578 ..if (ssl_contex │ │ │ +00021f10: 7429 0a09 0909 7b0a 0909 0909 7373 6c5f t)....{.....ssl_ │ │ │ +00021f20: 7374 7265 616d 266c 743b 7574 705f 7374 stream<utp_st │ │ │ +00021f30: 7265 616d 2667 743b 2073 2869 6f73 2c20 ream> s(ios, │ │ │ +00021f40: 2a73 7461 7469 635f 6361 7374 266c 743b *static_cast< │ │ │ +00021f50: 7373 6c3a 3a63 6f6e 7465 7874 2a26 6774 ssl::context*> │ │ │ +00021f60: 3b28 7373 6c5f 636f 6e74 6578 7429 293b ;(ssl_context)); │ │ │ +00021f70: 0a09 0909 0973 2e6e 6578 745f 6c61 7965 .....s.next_laye │ │ │ +00021f80: 7228 292e 7365 745f 696d 706c 2873 6d2d r().set_impl(sm- │ │ │ +00021f90: 2667 743b 6e65 775f 7574 705f 736f 636b >new_utp_sock │ │ │ +00021fa0: 6574 2826 616d 703b 732e 6e65 7874 5f6c et(&s.next_l │ │ │ +00021fb0: 6179 6572 2829 2929 3b0a 0909 0909 7265 ayer()));.....re │ │ │ +00021fc0: 7475 726e 2073 6f63 6b65 745f 7479 7065 turn socket_type │ │ │ +00021fd0: 2873 7464 3a3a 6d6f 7665 2873 2929 3b0a (std::move(s));. │ │ │ +00021fe0: 0909 097d 0a09 0909 656c 7365 0a23 656e ...}....else.#en │ │ │ +00021ff0: 6469 660a 0909 097b 0a09 0909 0975 7470 dif....{.....utp │ │ │ +00022000: 5f73 7472 6561 6d20 7328 696f 7329 3b0a _stream s(ios);. │ │ │ +00022010: 0909 0909 732e 7365 745f 696d 706c 2873 ....s.set_impl(s │ │ │ +00022020: 6d2d 2667 743b 6e65 775f 7574 705f 736f m->new_utp_so │ │ │ +00022030: 636b 6574 2826 616d 703b 7329 293b 0a09 cket(&s));.. │ │ │ +00022040: 0909 0972 6574 7572 6e20 736f 636b 6574 ...return socket │ │ │ +00022050: 5f74 7970 6528 7374 643a 3a6d 6f76 6528 _type(std::move( │ │ │ +00022060: 7329 293b 0a09 0909 7d0a 0909 7d0a 2369 s));....}...}.#i │ │ │ +00022070: 6620 544f 5252 454e 545f 5553 455f 4932 f TORRENT_USE_I2 │ │ │ +00022080: 500a 0909 656c 7365 2069 6620 2870 732e P...else if (ps. │ │ │ +00022090: 7479 7065 203d 3d20 7365 7474 696e 6773 type == settings │ │ │ +000220a0: 5f70 6163 6b3a 3a69 3270 5f70 726f 7879 _pack::i2p_proxy │ │ │ +000220b0: 290a 0909 7b0a 3c2f 7072 653e 3c2f 7464 )...{.
    relevance │ │ │ +000220f0: 266e 6273 703b 323c 2f74 643e 3c74 643e  2 │ │ │ +00022100: 3c61 2068 7265 663d 226a 6176 6173 6372 │ │ │ +00022120: 2e2e 2f73 7263 2f61 6c65 7274 5f6d 616e ../src/alert_man │ │ │ +00022130: 6167 6572 2e63 7070 3a37 363c 2f61 3e3c ager.cpp:76< │ │ │ +00022140: 2f74 643e 3c74 643e 6b65 6570 2061 2063 /td>keep a c │ │ │ +00022150: 6f75 6e74 206f 6620 7468 6520 6e75 6d62 ount of the numb │ │ │ +00022160: 6572 206f 6620 7468 7265 6164 7320 7761 er of threads wa │ │ │ +00022170: 6974 696e 672e 204f 6e6c 7920 6966 2069 iting. Only if i │ │ │ +00022180: 7427 7320 3e20 3020 6e6f 7469 6679 2074 t's > 0 notify t │ │ │ +00022190: 6865 6d3c 2f74 643e 3c2f 7472 3e3c 7472 hem

    │ │ │ +000221e0: 6b65 6570 2061 2063 6f75 6e74 206f 6620 keep a count of │ │ │ +000221f0: 7468 6520 6e75 6d62 6572 206f 6620 7468 the number of th │ │ │ +00022200: 7265 6164 7320 7761 6974 696e 672e 204f reads waiting. O │ │ │ +00022210: 6e6c 7920 6966 2069 7427 730a 3e20 3020 nly if it's.> 0 │ │ │ +00022220: 6e6f 7469 6679 2074 6865 6d3c 2f68 323e notify them

    │ │ │ +00022230: 3c68 343e 2e2e 2f73 7263 2f61 6c65 7274

    ../src/alert │ │ │ +00022240: 5f6d 616e 6167 6572 2e63 7070 3a37 363c _manager.cpp:76< │ │ │ +00022250: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    .{
    │ │ │ +00022290: 0a09 0973 7464 3a3a 756e 6971 7565 5f6c  ...std::unique_l
    │ │ │ +000222a0: 6f63 6b26 6c74 3b73 7464 3a3a 7265 6375  ock<std::recu
    │ │ │ +000222b0: 7273 6976 655f 6d75 7465 7826 6774 3b20  rsive_mutex> 
    │ │ │ +000222c0: 6c6f 636b 286d 5f6d 7574 6578 293b 0a0a  lock(m_mutex);..
    │ │ │ +000222d0: 0909 6966 2028 216d 5f61 6c65 7274 735b  ..if (!m_alerts[
    │ │ │ +000222e0: 6d5f 6765 6e65 7261 7469 6f6e 2026 616d  m_generation &am
    │ │ │ +000222f0: 703b 2031 5d2e 656d 7074 7928 2929 2072  p; 1].empty()) r
    │ │ │ +00022300: 6574 7572 6e20 7472 7565 3b0a 0a09 092f  eturn true;..../
    │ │ │ +00022310: 2f20 7468 6973 2063 616c 6c20 6361 6e20  / this call can 
    │ │ │ +00022320: 6265 2069 6e74 6572 7275 7074 6564 2070  be interrupted p
    │ │ │ +00022330: 7265 6d61 7475 7265 6c79 2062 7920 6f74  rematurely by ot
    │ │ │ +00022340: 6865 7220 7369 676e 616c 730a 0909 6d5f  her signals...m_
    │ │ │ +00022350: 636f 6e64 6974 696f 6e2e 7761 6974 5f66  condition.wait_f
    │ │ │ +00022360: 6f72 286c 6f63 6b2c 206d 6178 5f77 6169  or(lock, max_wai
    │ │ │ +00022370: 7429 3b0a 0909 7265 7475 726e 2021 6d5f  t);...return !m_
    │ │ │ +00022380: 616c 6572 7473 5b6d 5f67 656e 6572 6174  alerts[m_generat
    │ │ │ +00022390: 696f 6e20 2661 6d70 3b20 315d 2e65 6d70  ion & 1].emp
    │ │ │ +000223a0: 7479 2829 3b0a 097d 0a0a 0976 6f69 6420  ty();..}...void 
    │ │ │ +000223b0: 616c 6572 745f 6d61 6e61 6765 723a 3a6d  alert_manager::m
    │ │ │ +000223c0: 6179 6265 5f6e 6f74 6966 7928 616c 6572  aybe_notify(aler
    │ │ │ +000223d0: 742a 2061 290a 097b 0a09 0969 6620 286d  t* a)..{...if (m
    │ │ │ +000223e0: 5f61 6c65 7274 735b 6d5f 6765 6e65 7261  _alerts[m_genera
    │ │ │ +000223f0: 7469 6f6e 2026 616d 703b 2031 5d2e 7369  tion & 1].si
    │ │ │ +00022400: 7a65 2829 203d 3d20 3129 0a09 097b 0a09  ze() == 1)...{..
    │ │ │ +00022410: 0909 2f2f 2077 6520 6a75 7374 2070 6f73  ..// we just pos
    │ │ │ +00022420: 7465 6420 746f 2061 6e20 656d 7074 7920  ted to an empty 
    │ │ │ +00022430: 7175 6575 652e 2049 6620 616e 796f 6e65  queue. If anyone
    │ │ │ +00022440: 2069 7320 7761 6974 696e 6720 666f 720a   is waiting for.
    │ │ │ +00022450: 0909 092f 2f20 616c 6572 7473 2c20 7765  ...// alerts, we
    │ │ │ +00022460: 206e 6565 6420 746f 206e 6f74 6966 7920   need to notify 
    │ │ │ +00022470: 7468 656d 2e20 416c 736f 2028 706f 7465  them. Also (pote
    │ │ │ +00022480: 6e74 6961 6c6c 7929 2063 616c 6c20 7468  ntially) call th
    │ │ │ +00022490: 650a 0909 092f 2f20 7573 6572 2073 7570  e....// user sup
    │ │ │ +000224a0: 706c 6965 6420 6d5f 6e6f 7469 6679 2063  plied m_notify c
    │ │ │ +000224b0: 616c 6c62 6163 6b20 746f 206c 6574 2074  allback to let t
    │ │ │ +000224c0: 6865 2063 6c69 656e 7420 7761 6b65 2075  he client wake u
    │ │ │ +000224d0: 7020 6974 730a 0909 092f 2f20 6d65 7373  p its....// mess
    │ │ │ +000224e0: 6167 6520 6c6f 6f70 2074 6f20 706f 6c6c  age loop to poll
    │ │ │ +000224f0: 2066 6f72 2061 6c65 7274 732e 0a09 0909   for alerts.....
    │ │ │ +00022500: 6966 2028 6d5f 6e6f 7469 6679 2920 6d5f  if (m_notify) m_
    │ │ │ +00022510: 6e6f 7469 6679 2829 3b0a 0a3c 6469 7620  notify();..
    ...m_co │ │ │ +00022550: 6e64 6974 696f 6e2e 6e6f 7469 6679 5f61 ndition.notify_a │ │ │ +00022560: 6c6c 2829 3b0a 3c2f 6469 763e 0909 7d0a ll();.
    ..}. │ │ │ +00022570: 0a23 6966 6e64 6566 2054 4f52 5245 4e54 .#ifndef TORRENT │ │ │ +00022580: 5f44 4953 4142 4c45 5f45 5854 454e 5349 _DISABLE_EXTENSI │ │ │ +00022590: 4f4e 530a 0909 666f 7220 2861 7574 6f26 ONS...for (auto& │ │ │ +000225a0: 616d 703b 2065 203a 206d 5f73 6573 5f65 amp; e : m_ses_e │ │ │ +000225b0: 7874 656e 7369 6f6e 7329 0a09 0909 652d xtensions)....e- │ │ │ +000225c0: 2667 743b 6f6e 5f61 6c65 7274 2861 293b >on_alert(a); │ │ │ +000225d0: 0a23 656c 7365 0a09 0954 4f52 5245 4e54 .#else...TORRENT │ │ │ +000225e0: 5f55 4e55 5345 4428 6129 3b0a 2365 6e64 _UNUSED(a);.#end │ │ │ +000225f0: 6966 0a09 7d0a 0a09 766f 6964 2061 6c65 if..}...void ale │ │ │ +00022600: 7274 5f6d 616e 6167 6572 3a3a 7365 745f rt_manager::set_ │ │ │ +00022610: 6e6f 7469 6679 5f66 756e 6374 696f 6e28 notify_function( │ │ │ +00022620: 7374 643a 3a66 756e 6374 696f 6e26 6c74 std::function< │ │ │ +00022630: 3b76 6f69 6428 2926 6774 3b20 636f 6e73 ;void()> cons │ │ │ +00022640: 7426 616d 703b 2066 756e 290a 097b 0a09 t& fun)..{.. │ │ │ +00022650: 0973 7464 3a3a 756e 6971 7565 5f6c 6f63 .std::unique_loc │ │ │ +00022660: 6b26 6c74 3b73 7464 3a3a 7265 6375 7273 k<std::recurs │ │ │ +00022670: 6976 655f 6d75 7465 7826 6774 3b20 6c6f ive_mutex> lo │ │ │ +00022680: 636b 286d 5f6d 7574 6578 293b 0a09 096d ck(m_mutex);...m │ │ │ +00022690: 5f6e 6f74 6966 7920 3d20 6675 6e3b 0a09 _notify = fun;.. │ │ │ +000226a0: 0969 6620 2821 6d5f 616c 6572 7473 5b6d .if (!m_alerts[m │ │ │ +000226b0: 5f67 656e 6572 6174 696f 6e20 2661 6d70 _generation & │ │ │ +000226c0: 3b20 315d 2e65 6d70 7479 2829 290a 0909 ; 1].empty())... │ │ │ +000226d0: 7b0a 0909 0969 6620 286d 5f6e 6f74 6966 {....if (m_notif │ │ │ +000226e0: 7929 206d 5f6e 6f74 6966 7928 293b 0a09 y) m_notify();.. │ │ │ +000226f0: 097d 0a09 7d0a 0a23 6966 6e64 6566 2054 .}..}..#ifndef T │ │ │ +00022700: 4f52 5245 4e54 5f44 4953 4142 4c45 5f45 ORRENT_DISABLE_E │ │ │ +00022710: 5854 454e 5349 4f4e 530a 0976 6f69 6420 XTENSIONS..void │ │ │ +00022720: 616c 6572 745f 6d61 6e61 6765 723a 3a61 alert_manager::a │ │ │ +00022730: 6464 5f65 7874 656e 7369 6f6e 2873 7464 dd_extension(std │ │ │ +00022740: 3a3a 7368 6172 6564 5f70 7472 266c 743b ::shared_ptr< │ │ │ +00022750: 706c 7567 696e 2667 743b 2065 7874 290a plugin> ext). │ │ │ +00022760: 097b 0a09 096d 5f73 6573 5f65 7874 656e .{...m_ses_exten │ │ │ +00022770: 7369 6f6e 732e 7075 7368 5f62 6163 6b28 sions.push_back( │ │ │ +00022780: 7374 643a 3a6d 6f76 6528 6578 7429 293b std::move(ext)); │ │ │ +00022790: 0a09 7d0a 2365 6e64 6966 0a0a 0976 6f69 ..}.#endif...voi │ │ │ +000227a0: 6420 616c 6572 745f 6d61 6e61 6765 723a d alert_manager: │ │ │ +000227b0: 3a67 6574 5f61 6c6c 2873 7464 3a3a 7665 :get_all(std::ve │ │ │ +000227c0: 6374 6f72 266c 743b 616c 6572 742a 2667 ctor<alert*&g │ │ │ +000227d0: 743b 2661 6d70 3b20 616c 6572 7473 290a t;& alerts). │ │ │ +000227e0: 097b 0a09 0973 7464 3a3a 6c6f 636b 5f67 .{...std::lock_g │ │ │ +000227f0: 7561 7264 266c 743b 7374 643a 3a72 6563 uard<std::rec │ │ │ +00022800: 7572 7369 7665 5f6d 7574 6578 2667 743b ursive_mutex> │ │ │ +00022810: 206c 6f63 6b28 6d5f 6d75 7465 7829 3b0a lock(m_mutex);. │ │ │ +00022820: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +00022830: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00022860: 323c 2f74 643e 3c74 643e 3c61 2068 7265 2../src │ │ │ +00022890: 2f70 6565 725f 6c69 7374 2e63 7070 3a35 /peer_list.cpp:5 │ │ │ +000228a0: 3335 3c2f 613e 3c2f 7464 3e3c 7464 3e69 35i │ │ │ +000228b0: 7420 776f 756c 6420 6265 206e 6963 6520 t would be nice │ │ │ +000228c0: 6966 2074 6865 7265 2077 6173 2061 2077 if there was a w │ │ │ +000228d0: 6179 2074 6f20 6974 6572 6174 6520 6f76 ay to iterate ov │ │ │ +000228e0: 6572 2074 6865 7365 2074 6f72 7265 6e74 er these torrent │ │ │ +000228f0: 5f70 6565 7220 6f62 6a65 6374 7320 696e _peer objects in │ │ │ +00022900: 2074 6865 206f 7264 6572 2074 6865 7920 the order they │ │ │ +00022910: 6172 6520 616c 6c6f 6361 7465 6420 696e are allocated in │ │ │ +00022920: 2074 6865 2070 6f6f 6c20 696e 7374 6561 the pool instea │ │ │ +00022930: 642e 2049 7420 776f 756c 6420 7072 6f62 d. It would prob │ │ │ +00022940: 6162 6c79 2062 6520 6d6f 7265 2065 6666 ably be more eff │ │ │ +00022950: 6963 6965 6e74 3c2f 7464 3e3c 2f74 723e icient │ │ │ +00022960: 3c74 7220 6964 3d22 3638 2220 7374 796c < │ │ │ +00022990: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +000229a0: 6832 3e69 7420 776f 756c 6420 6265 206e h2>it would be n │ │ │ +000229b0: 6963 6520 6966 2074 6865 7265 2077 6173 ice if there was │ │ │ +000229c0: 2061 2077 6179 2074 6f20 6974 6572 6174 a way to iterat │ │ │ +000229d0: 6520 6f76 6572 2074 6865 7365 0a74 6f72 e over these.tor │ │ │ +000229e0: 7265 6e74 5f70 6565 7220 6f62 6a65 6374 rent_peer object │ │ │ +000229f0: 7320 696e 2074 6865 206f 7264 6572 2074 s in the order t │ │ │ +00022a00: 6865 7920 6172 6520 616c 6c6f 6361 7465 hey are allocate │ │ │ +00022a10: 6420 696e 2074 6865 2070 6f6f 6c0a 696e d in the pool.in │ │ │ +00022a20: 7374 6561 642e 2049 7420 776f 756c 6420 stead. It would │ │ │ +00022a30: 7072 6f62 6162 6c79 2062 6520 6d6f 7265 probably be more │ │ │ +00022a40: 2065 6666 6963 6965 6e74 3c2f 6832 3e3c efficient

    < │ │ │ +00022a50: 6834 3e2e 2e2f 7372 632f 7065 6572 5f6c h4>../src/peer_l │ │ │ +00022a60: 6973 742e 6370 703a 3533 353c 2f68 343e ist.cpp:535 │ │ │ +00022a70: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .., in
    │ │ │ +00022ab0: 7420 7365 7373 696f 6e5f 7469 6d65 2c20  t session_time, 
    │ │ │ +00022ac0: 746f 7272 656e 745f 7374 6174 652a 2073  torrent_state* s
    │ │ │ +00022ad0: 7461 7465 290a 097b 0a09 0954 4f52 5245  tate)..{...TORRE
    │ │ │ +00022ae0: 4e54 5f41 5353 4552 5428 6973 5f73 696e  NT_ASSERT(is_sin
    │ │ │ +00022af0: 676c 655f 7468 7265 6164 2829 293b 0a09  gle_thread());..
    │ │ │ +00022b00: 0949 4e56 4152 4941 4e54 5f43 4845 434b  .INVARIANT_CHECK
    │ │ │ +00022b10: 3b0a 0a09 0963 6f6e 7374 2069 6e74 2063  ;....const int c
    │ │ │ +00022b20: 616e 6469 6461 7465 5f63 6f75 6e74 203d  andidate_count =
    │ │ │ +00022b30: 2031 303b 0a09 0970 6565 7273 2e72 6573   10;...peers.res
    │ │ │ +00022b40: 6572 7665 2863 616e 6469 6461 7465 5f63  erve(candidate_c
    │ │ │ +00022b50: 6f75 6e74 293b 0a0a 0909 696e 7420 6572  ount);....int er
    │ │ │ +00022b60: 6173 655f 6361 6e64 6964 6174 6520 3d20  ase_candidate = 
    │ │ │ +00022b70: 2d31 3b0a 0a09 0969 6620 2862 6f6f 6c28  -1;....if (bool(
    │ │ │ +00022b80: 6d5f 6669 6e69 7368 6564 2920 213d 2073  m_finished) != s
    │ │ │ +00022b90: 7461 7465 2d26 6774 3b69 735f 6669 6e69  tate->is_fini
    │ │ │ +00022ba0: 7368 6564 290a 0909 0972 6563 616c 6375  shed)....recalcu
    │ │ │ +00022bb0: 6c61 7465 5f63 6f6e 6e65 6374 5f63 616e  late_connect_can
    │ │ │ +00022bc0: 6469 6461 7465 7328 7374 6174 6529 3b0a  didates(state);.
    │ │ │ +00022bd0: 0a09 0965 7874 6572 6e61 6c5f 6970 2063  ...external_ip c
    │ │ │ +00022be0: 6f6e 7374 2661 6d70 3b20 6578 7465 726e  onst& extern
    │ │ │ +00022bf0: 616c 203d 2073 7461 7465 2d26 6774 3b69  al = state->i
    │ │ │ +00022c00: 703b 0a09 0969 6e74 2065 7874 6572 6e61  p;...int externa
    │ │ │ +00022c10: 6c5f 706f 7274 203d 2073 7461 7465 2d26  l_port = state-&
    │ │ │ +00022c20: 6774 3b70 6f72 743b 0a0a 0909 6966 2028  gt;port;....if (
    │ │ │ +00022c30: 6d5f 726f 756e 645f 726f 6269 6e20 2667  m_round_robin &g
    │ │ │ +00022c40: 743b 3d20 696e 7428 6d5f 7065 6572 732e  t;= int(m_peers.
    │ │ │ +00022c50: 7369 7a65 2829 2929 206d 5f72 6f75 6e64  size())) m_round
    │ │ │ +00022c60: 5f72 6f62 696e 203d 2030 3b0a 0a09 0969  _robin = 0;....i
    │ │ │ +00022c70: 6e74 206d 6178 5f70 6565 726c 6973 745f  nt max_peerlist_
    │ │ │ +00022c80: 7369 7a65 203d 2073 7461 7465 2d26 6774  size = state->
    │ │ │ +00022c90: 3b6d 6178 5f70 6565 726c 6973 745f 7369  ;max_peerlist_si
    │ │ │ +00022ca0: 7a65 3b0a 0a3c 6469 7620 7374 796c 653d  ze;..
    ..for (int it │ │ │ +00022ce0: 6572 6174 696f 6e73 203d 2073 7464 3a3a erations = std:: │ │ │ +00022cf0: 6d69 6e28 696e 7428 6d5f 7065 6572 732e min(int(m_peers. │ │ │ +00022d00: 7369 7a65 2829 292c 2033 3030 293b 0a3c size()), 300);.< │ │ │ +00022d10: 2f64 6976 3e09 0909 6974 6572 6174 696f /div>...iteratio │ │ │ +00022d20: 6e73 2026 6774 3b20 303b 202d 2d69 7465 ns > 0; --ite │ │ │ +00022d30: 7261 7469 6f6e 7329 0a09 097b 0a09 0909 rations)...{.... │ │ │ +00022d40: 2b2b 7374 6174 652d 2667 743b 6c6f 6f70 ++state->loop │ │ │ +00022d50: 5f63 6f75 6e74 6572 3b0a 0a09 0909 6966 _counter;.....if │ │ │ +00022d60: 2028 6d5f 726f 756e 645f 726f 6269 6e20 (m_round_robin │ │ │ +00022d70: 2667 743b 3d20 696e 7428 6d5f 7065 6572 >= int(m_peer │ │ │ +00022d80: 732e 7369 7a65 2829 2929 206d 5f72 6f75 s.size())) m_rou │ │ │ +00022d90: 6e64 5f72 6f62 696e 203d 2030 3b0a 0a09 nd_robin = 0;... │ │ │ +00022da0: 0909 746f 7272 656e 745f 7065 6572 2661 ..torrent_peer&a │ │ │ +00022db0: 6d70 3b20 7065 203d 202a 6d5f 7065 6572 mp; pe = *m_peer │ │ │ +00022dc0: 735b 6d5f 726f 756e 645f 726f 6269 6e5d s[m_round_robin] │ │ │ +00022dd0: 3b0a 0909 0954 4f52 5245 4e54 5f41 5353 ;....TORRENT_ASS │ │ │ +00022de0: 4552 5428 7065 2e69 6e5f 7573 6529 3b0a ERT(pe.in_use);. │ │ │ +00022df0: 0909 0969 6e74 2063 7572 7265 6e74 203d ...int current = │ │ │ +00022e00: 206d 5f72 6f75 6e64 5f72 6f62 696e 3b0a m_round_robin;. │ │ │ +00022e10: 0a09 0909 2f2f 2069 6620 7468 6520 6e75 ....// if the nu │ │ │ +00022e20: 6d62 6572 206f 6620 7065 6572 7320 6973 mber of peers is │ │ │ +00022e30: 2067 726f 7769 6e67 206c 6172 6765 0a09 growing large.. │ │ │ +00022e40: 0909 2f2f 2077 6520 6e65 6564 2074 6f20 ..// we need to │ │ │ +00022e50: 7374 6172 7420 7765 6564 696e 672e 0a0a start weeding... │ │ │ +00022e60: 0909 0969 6620 2869 6e74 286d 5f70 6565 ...if (int(m_pee │ │ │ +00022e70: 7273 2e73 697a 6528 2929 2026 6774 3b3d rs.size()) >= │ │ │ +00022e80: 206d 6178 5f70 6565 726c 6973 745f 7369 max_peerlist_si │ │ │ +00022e90: 7a65 202a 2030 2e39 350a 0909 0909 2661 ze * 0.95.....&a │ │ │ +00022ea0: 6d70 3b26 616d 703b 206d 6178 5f70 6565 mp;& max_pee │ │ │ +00022eb0: 726c 6973 745f 7369 7a65 2026 6774 3b20 rlist_size > │ │ │ +00022ec0: 3029 0a09 0909 7b0a 0909 0909 6966 2028 0)....{.....if ( │ │ │ +00022ed0: 6973 5f65 7261 7365 5f63 616e 6469 6461 is_erase_candida │ │ │ +00022ee0: 7465 2870 6529 0a09 0909 0909 2661 6d70 te(pe)......& │ │ │ +00022ef0: 3b26 616d 703b 2028 6572 6173 655f 6361 ;& (erase_ca │ │ │ +00022f00: 6e64 6964 6174 6520 3d3d 202d 310a 0909 ndidate == -1... │ │ │ +00022f10: 0909 0909 7c7c 2021 636f 6d70 6172 655f ....|| !compare_ │ │ │ +00022f20: 7065 6572 5f65 7261 7365 282a 6d5f 7065 peer_erase(*m_pe │ │ │ +00022f30: 6572 735b 6572 6173 655f 6361 6e64 6964 ers[erase_candid │ │ │ +00022f40: 6174 655d 2c20 7065 2929 290a 0909 0909 ate], pe)))..... │ │ │ +00022f50: 7b0a 0909 0909 0969 6620 2873 686f 756c {......if (shoul │ │ │ +00022f60: 645f 6572 6173 655f 696d 6d65 6469 6174 d_erase_immediat │ │ │ +00022f70: 656c 7928 7065 2929 0a09 0909 0909 7b0a ely(pe))......{. │ │ │ +00022f80: 0909 0909 0909 6966 2028 6572 6173 655f ......if (erase_ │ │ │ +00022f90: 6361 6e64 6964 6174 6520 2667 743b 2063 candidate > c │ │ │ +00022fa0: 7572 7265 6e74 2920 2d2d 6572 6173 655f urrent) --erase_ │ │ │ +00022fb0: 6361 6e64 6964 6174 653b 0a09 0909 0909 candidate;...... │ │ │ +00022fc0: 0965 7261 7365 5f70 6565 7228 6d5f 7065 .erase_peer(m_pe │ │ │ +00022fd0: 6572 732e 6265 6769 6e28 2920 2b20 6375 ers.begin() + cu │ │ │ +00022fe0: 7272 656e 742c 2073 7461 7465 293b 0a09 rrent, state);.. │ │ │ +00022ff0: 0909 0909 0963 6f6e 7469 6e75 653b 0a09 .....continue;.. │ │ │ +00023000: 0909 0909 7d0a 0909 0909 0965 6c73 650a ....}......else. │ │ │ +00023010: 0909 0909 097b 0a09 0909 0909 0965 7261 .....{.......era │ │ │ +00023020: 7365 5f63 616e 6469 6461 7465 203d 2063 se_candidate = c │ │ │ +00023030: 7572 7265 6e74 3b0a 0909 0909 097d 0a3c urrent;......}.< │ │ │ +00023040: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00023050: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +00023060: 6f75 6e64 3a20 2363 6663 223e 3c74 643e ound: #cfc"> │ │ │ +00023070: 7265 6c65 7661 6e63 6526 6e62 7370 3b32 relevance 2 │ │ │ +00023080: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src/ │ │ │ +000230b0: 7472 6163 6b65 725f 6d61 6e61 6765 722e tracker_manager. │ │ │ +000230c0: 6370 703a 3338 393c 2f61 3e3c 2f74 643e cpp:389 │ │ │ +000230d0: 3c74 643e 696d 706c 656d 656e 743c 2f74 implement

    implem │ │ │ +00023130: 656e 743c 2f68 323e 3c68 343e 2e2e 2f73 ent

    ../s │ │ │ +00023140: 7263 2f74 7261 636b 6572 5f6d 616e 6167 rc/tracker_manag │ │ │ +00023150: 6572 2e63 7070 3a33 3839 3c2f 6834 3e3c er.cpp:389

    < │ │ │ +00023160: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00023170: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00023180: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00023190: 7820 2364 6464 3b22 3e23 6966 6e64 6566 x #ddd;">#ifndef │ │ │ +000231a0: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ +000231b0: 5f4c 4f47 4749 4e47 0a09 0909 6966 2028 _LOGGING....if ( │ │ │ +000231c0: 6d5f 7365 732e 7368 6f75 6c64 5f6c 6f67 m_ses.should_log │ │ │ +000231d0: 2829 290a 0909 097b 0a09 0909 096d 5f73 ())....{.....m_s │ │ │ +000231e0: 6573 2e73 6573 7369 6f6e 5f6c 6f67 2822 es.session_log(" │ │ │ +000231f0: 696e 636f 6d69 6e67 2055 4450 2074 7261 incoming UDP tra │ │ │ +00023200: 636b 6572 2070 6163 6b65 7420 6672 6f6d cker packet from │ │ │ +00023210: 2025 7320 6861 7320 696e 7661 6c69 6420 %s has invalid │ │ │ +00023220: 220a 0909 0909 0922 7472 616e 7361 6374 "......"transact │ │ │ +00023230: 696f 6e20 4944 2028 2578 2922 2c20 7072 ion ID (%x)", pr │ │ │ +00023240: 696e 745f 656e 6470 6f69 6e74 2865 7029 int_endpoint(ep) │ │ │ +00023250: 2e63 5f73 7472 2829 0a09 0909 0909 2c20 .c_str()......, │ │ │ +00023260: 7472 616e 7361 6374 696f 6e29 3b0a 0909 transaction);... │ │ │ +00023270: 097d 0a23 656e 6469 660a 0909 0972 6574 .}.#endif....ret │ │ │ +00023280: 7572 6e20 6661 6c73 653b 0a09 097d 0a0a urn false;...}.. │ │ │ +00023290: 0909 7374 643a 3a73 6861 7265 645f 7074 ..std::shared_pt │ │ │ +000232a0: 7226 6c74 3b75 6470 5f74 7261 636b 6572 r<udp_tracker │ │ │ +000232b0: 5f63 6f6e 6e65 6374 696f 6e26 6774 3b20 _connection> │ │ │ +000232c0: 636f 6e73 7420 7020 3d20 692d 2667 743b const p = i-> │ │ │ +000232d0: 7365 636f 6e64 3b0a 0909 2f2f 206f 6e5f second;...// on_ │ │ │ +000232e0: 7265 6365 6976 6528 2920 6d61 7920 7265 receive() may re │ │ │ +000232f0: 6d6f 7665 2074 6865 2074 7261 636b 6572 move the tracker │ │ │ +00023300: 2063 6f6e 6e65 6374 696f 6e20 6672 6f6d connection from │ │ │ +00023310: 2074 6865 206c 6973 740a 0909 7265 7475 the list...retu │ │ │ +00023320: 726e 2070 2d26 6774 3b6f 6e5f 7265 6365 rn p->on_rece │ │ │ +00023330: 6976 6528 6570 2c20 6275 6629 3b0a 097d ive(ep, buf);..} │ │ │ +00023340: 0a0a 0976 6f69 6420 7472 6163 6b65 725f ...void tracker_ │ │ │ +00023350: 6d61 6e61 6765 723a 3a69 6e63 6f6d 696e manager::incomin │ │ │ +00023360: 675f 6572 726f 7228 6572 726f 725f 636f g_error(error_co │ │ │ +00023370: 6465 2063 6f6e 7374 2661 6d70 3b0a 0909 de const&... │ │ │ +00023380: 2c20 7564 703a 3a65 6e64 706f 696e 7420 , udp::endpoint │ │ │ +00023390: 636f 6e73 7426 616d 703b 290a 097b 0a09 const&)..{.. │ │ │ +000233a0: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ +000233b0: 6973 5f73 696e 676c 655f 7468 7265 6164 is_single_thread │ │ │ +000233c0: 2829 293b 0a3c 6469 7620 7374 796c 653d ());.
    .}.
    ..bo │ │ │ +00023400: 6f6c 2074 7261 636b 6572 5f6d 616e 6167 ol tracker_manag │ │ │ +00023410: 6572 3a3a 696e 636f 6d69 6e67 5f70 6163 er::incoming_pac │ │ │ +00023420: 6b65 7428 7374 7269 6e67 5f76 6965 7720 ket(string_view │ │ │ +00023430: 636f 6e73 7420 686f 7374 6e61 6d65 0a09 const hostname.. │ │ │ +00023440: 092c 2073 7061 6e26 6c74 3b63 6861 7220 ., span<char │ │ │ +00023450: 636f 6e73 7426 6774 3b20 636f 6e73 7420 const> const │ │ │ +00023460: 6275 6629 0a09 7b0a 0909 544f 5252 454e buf)..{...TORREN │ │ │ +00023470: 545f 4153 5345 5254 2869 735f 7369 6e67 T_ASSERT(is_sing │ │ │ +00023480: 6c65 5f74 6872 6561 6428 2929 3b0a 0909 le_thread());... │ │ │ +00023490: 2f2f 2069 676e 6f72 6520 7061 636b 6574 // ignore packet │ │ │ +000234a0: 7320 736d 616c 6c65 7220 7468 616e 2038 s smaller than 8 │ │ │ +000234b0: 2062 7974 6573 0a09 0969 6620 2862 7566 bytes...if (buf │ │ │ +000234c0: 2e73 697a 6528 2920 266c 743b 2031 3629 .size() < 16) │ │ │ +000234d0: 2072 6574 7572 6e20 6661 6c73 653b 0a0a return false;.. │ │ │ +000234e0: 0909 2f2f 2074 6865 2066 6972 7374 2077 ..// the first w │ │ │ +000234f0: 6f72 6420 6973 2074 6865 2061 6374 696f ord is the actio │ │ │ +00023500: 6e2c 2069 6620 6974 2773 206e 6f74 205b n, if it's not [ │ │ │ +00023510: 302c 2033 5d0a 0909 2f2f 2069 7427 7320 0, 3]...// it's │ │ │ +00023520: 6e6f 7420 6120 7661 6c69 6420 7564 7020 not a valid udp │ │ │ +00023530: 7472 6163 6b65 7220 7265 7370 6f6e 7365 tracker response │ │ │ +00023540: 0a09 0973 7061 6e26 6c74 3b63 6f6e 7374 ...span<const │ │ │ +00023550: 2063 6861 7226 6774 3b20 7074 7220 3d20 char> ptr = │ │ │ +00023560: 6275 663b 0a09 0973 7464 3a3a 7569 6e74 buf;...std::uint │ │ │ +00023570: 3332 5f74 2063 6f6e 7374 2061 6374 696f 32_t const actio │ │ │ +00023580: 6e20 3d20 6175 783a 3a72 6561 645f 7569 n = aux::read_ui │ │ │ +00023590: 6e74 3332 2870 7472 293b 0a09 0969 6620 nt32(ptr);...if │ │ │ +000235a0: 2861 6374 696f 6e20 2667 743b 2033 2920 (action > 3) │ │ │ +000235b0: 7265 7475 726e 2066 616c 7365 3b0a 0a09 return false;... │ │ │ +000235c0: 0973 7464 3a3a 7569 6e74 3332 5f74 2063 .std::uint32_t c │ │ │ +000235d0: 6f6e 7374 2074 7261 6e73 6163 7469 6f6e onst transaction │ │ │ +000235e0: 203d 2061 7578 3a3a 7265 6164 5f75 696e = aux::read_uin │ │ │ +000235f0: 7433 3228 7074 7229 3b0a 0909 6175 746f t32(ptr);...auto │ │ │ +00023600: 2063 6f6e 7374 2069 203d 206d 5f75 6470 const i = m_udp │ │ │ +00023610: 5f63 6f6e 6e73 2e66 696e 6428 7472 616e _conns.find(tran │ │ │ +00023620: 7361 6374 696f 6e29 3b0a 0a09 0969 6620 saction);....if │ │ │ +00023630: 2869 203d 3d20 6d5f 7564 705f 636f 6e6e (i == m_udp_conn │ │ │ +00023640: 732e 656e 6428 2929 0a09 097b 0a23 6966 s.end())...{.#if │ │ │ +00023650: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ +00023660: 4142 4c45 5f4c 4f47 4749 4e47 0a09 0909 ABLE_LOGGING.... │ │ │ +00023670: 2f2f 206e 6f77 2c20 7468 6973 206d 6179 // now, this may │ │ │ +00023680: 206e 6f74 2068 6176 6520 6265 656e 206d not have been m │ │ │ +00023690: 6561 6e74 2074 6f20 6265 2061 2074 7261 eant to be a tra │ │ │ +000236a0: 636b 6572 2072 6573 706f 6e73 652c 0a09 cker response,.. │ │ │ +000236b0: 0909 2f2f 2062 7574 2063 6861 6e63 6573 ..// but chances │ │ │ +000236c0: 2061 7265 2070 7265 7474 7920 676f 6f64 are pretty good │ │ │ +000236d0: 2c20 736f 2069 7427 7320 7072 6f62 6162 , so it's probab │ │ │ +000236e0: 6c79 2077 6f72 7468 206c 6f67 6769 6e67 ly worth logging │ │ │ +000236f0: 0a09 0909 6d5f 7365 732e 7365 7373 696f ....m_ses.sessio │ │ │ +00023700: 6e5f 6c6f 6728 2269 6e63 6f6d 696e 6720 n_log("incoming │ │ │ +00023710: 5544 5020 7472 6163 6b65 7220 7061 636b UDP tracker pack │ │ │ +00023720: 6574 2066 726f 6d20 2573 2068 6173 2069 et from %s has i │ │ │ +00023730: 6e76 616c 6964 2022 0a09 0909 0922 7472 nvalid "....."tr │ │ │ +00023740: 616e 7361 6374 696f 6e20 4944 2028 2578 ansaction ID (%x │ │ │ +00023750: 2922 2c20 7374 643a 3a73 7472 696e 6728 )", std::string( │ │ │ +00023760: 686f 7374 6e61 6d65 292e 635f 7374 7228 hostname).c_str( │ │ │ +00023770: 292c 2074 7261 6e73 6163 7469 6f6e 293b ), transaction); │ │ │ +00023780: 0a23 656e 6469 660a 0909 0972 6574 7572 .#endif....retur │ │ │ +00023790: 6e20 6661 6c73 653b 0a09 097d 0a0a 0909 n false;...}.... │ │ │ +000237a0: 7374 643a 3a73 6861 7265 645f 7074 7226 std::shared_ptr& │ │ │ +000237b0: 6c74 3b75 6470 5f74 7261 636b 6572 5f63 lt;udp_tracker_c │ │ │ +000237c0: 6f6e 6e65 6374 696f 6e26 6774 3b20 636f onnection> co │ │ │ +000237d0: 6e73 7420 7020 3d20 692d 2667 743b 7365 nst p = i->se │ │ │ +000237e0: 636f 6e64 3b0a 0909 2f2f 206f 6e5f 7265 cond;...// on_re │ │ │ +000237f0: 6365 6976 6528 2920 6d61 7920 7265 6d6f ceive() may remo │ │ │ +00023800: 7665 2074 6865 2074 7261 636b 6572 2063 ve the tracker c │ │ │ +00023810: 6f6e 6e65 6374 696f 6e20 6672 6f6d 2074 onnection from t │ │ │ +00023820: 6865 206c 6973 740a 3c2f 7072 653e 3c2f he list.
    relevan │ │ │ +00023860: 6365 266e 6273 703b 323c 2f74 643e 3c74 ce 2../src/piece_p │ │ │ +000238a0: 6963 6b65 722e 6370 703a 3230 3133 3c2f icker.cpp:2013make │ │ │ +000238c0: 7468 6520 3230 3438 206c 696d 6974 2063 the 2048 limit c │ │ │ +000238d0: 6f6e 6669 6775 7261 626c 653c 2f74 643e onfigurable │ │ │ +000238e0: 3c2f 7472 3e3c 7472 2069 643d 2237 3022

    make the │ │ │ +00023930: 2032 3034 3820 6c69 6d69 7420 636f 6e66 2048 limit conf │ │ │ +00023940: 6967 7572 6162 6c65 3c2f 6832 3e3c 6834 igurable

    ../src/piece_pi │ │ │ +00023960: 636b 6572 2e63 7070 3a32 3031 333c 2f68 cker.cpp:2013
    .// 
    │ │ │ +000239b0: 696e 6469 6361 7469 6e67 2077 6869 6368  indicating which
    │ │ │ +000239c0: 2070 6174 6820 7468 6f75 6768 7420 7468   path thought th
    │ │ │ +000239d0: 6520 7069 636b 6572 2077 6520 746f 6f6b  e picker we took
    │ │ │ +000239e0: 2074 6f20 6172 7269 7665 2061 7420 7468   to arrive at th
    │ │ │ +000239f0: 650a 092f 2f20 7265 7475 726e 6564 2062  e..// returned b
    │ │ │ +00023a00: 6c6f 636b 2070 6963 6b73 2e0a 0970 6963  lock picks...pic
    │ │ │ +00023a10: 6b65 725f 666c 6167 735f 7420 7069 6563  ker_flags_t piec
    │ │ │ +00023a20: 655f 7069 636b 6572 3a3a 7069 636b 5f70  e_picker::pick_p
    │ │ │ +00023a30: 6965 6365 7328 7479 7065 645f 6269 7466  ieces(typed_bitf
    │ │ │ +00023a40: 6965 6c64 266c 743b 7069 6563 655f 696e  ield<piece_in
    │ │ │ +00023a50: 6465 785f 7426 6774 3b20 636f 6e73 7426  dex_t> const&
    │ │ │ +00023a60: 616d 703b 2070 6965 6365 730a 0909 2c20  amp; pieces..., 
    │ │ │ +00023a70: 7374 643a 3a76 6563 746f 7226 6c74 3b70  std::vector<p
    │ │ │ +00023a80: 6965 6365 5f62 6c6f 636b 2667 743b 2661  iece_block>&a
    │ │ │ +00023a90: 6d70 3b20 696e 7465 7265 7374 696e 675f  mp; interesting_
    │ │ │ +00023aa0: 626c 6f63 6b73 2c20 696e 7420 6e75 6d5f  blocks, int num_
    │ │ │ +00023ab0: 626c 6f63 6b73 0a09 092c 2069 6e74 2070  blocks..., int p
    │ │ │ +00023ac0: 7265 6665 725f 636f 6e74 6967 756f 7573  refer_contiguous
    │ │ │ +00023ad0: 5f62 6c6f 636b 732c 2074 6f72 7265 6e74  _blocks, torrent
    │ │ │ +00023ae0: 5f70 6565 722a 2070 6565 720a 0909 2c20  _peer* peer..., 
    │ │ │ +00023af0: 7069 636b 6572 5f6f 7074 696f 6e73 5f74  picker_options_t
    │ │ │ +00023b00: 206f 7074 696f 6e73 2c20 7374 643a 3a76   options, std::v
    │ │ │ +00023b10: 6563 746f 7226 6c74 3b70 6965 6365 5f69  ector<piece_i
    │ │ │ +00023b20: 6e64 6578 5f74 2667 743b 2063 6f6e 7374  ndex_t> const
    │ │ │ +00023b30: 2661 6d70 3b20 7375 6767 6573 7465 645f  & suggested_
    │ │ │ +00023b40: 7069 6563 6573 0a09 092c 2069 6e74 206e  pieces..., int n
    │ │ │ +00023b50: 756d 5f70 6565 7273 0a09 092c 2063 6f75  um_peers..., cou
    │ │ │ +00023b60: 6e74 6572 7326 616d 703b 2070 630a 0909  nters& pc...
    │ │ │ +00023b70: 2920 636f 6e73 740a 097b 0a09 0954 4f52  ) const..{...TOR
    │ │ │ +00023b80: 5245 4e54 5f41 5353 4552 5428 7065 6572  RENT_ASSERT(peer
    │ │ │ +00023b90: 203d 3d20 6e75 6c6c 7074 7220 7c7c 2070   == nullptr || p
    │ │ │ +00023ba0: 6565 722d 2667 743b 696e 5f75 7365 293b  eer->in_use);
    │ │ │ +00023bb0: 0a09 0970 6963 6b65 725f 666c 6167 735f  ...picker_flags_
    │ │ │ +00023bc0: 7420 7265 743b 0a0a 0909 2f2f 2070 7265  t ret;....// pre
    │ │ │ +00023bd0: 7665 6e74 2074 6865 206e 756d 6265 7220  vent the number 
    │ │ │ +00023be0: 6f66 2070 6172 7469 616c 2070 6965 6365  of partial piece
    │ │ │ +00023bf0: 7320 746f 2067 726f 7720 696e 6465 6669  s to grow indefi
    │ │ │ +00023c00: 6e69 7465 6c79 0a09 092f 2f20 6d61 6b65  nitely...// make
    │ │ │ +00023c10: 2074 6869 7320 7363 616c 6520 6279 2074   this scale by t
    │ │ │ +00023c20: 6865 206e 756d 6265 7220 6f66 2070 6565  he number of pee
    │ │ │ +00023c30: 7273 2077 6520 6861 7665 2e20 466f 7220  rs we have. For 
    │ │ │ +00023c40: 6c61 7267 650a 0909 2f2f 2073 6361 6c65  large...// scale
    │ │ │ +00023c50: 2063 6c69 656e 7473 2c20 7765 2077 6f75   clients, we wou
    │ │ │ +00023c60: 6c64 2068 6176 6520 6d6f 7265 2070 6565  ld have more pee
    │ │ │ +00023c70: 7273 2c20 616e 6420 616c 6c6f 7720 6120  rs, and allow a 
    │ │ │ +00023c80: 6869 6768 6572 0a09 092f 2f20 7468 7265  higher...// thre
    │ │ │ +00023c90: 7368 6f6c 6420 666f 7220 7468 6520 6e75  shold for the nu
    │ │ │ +00023ca0: 6d62 6572 206f 6620 7061 7274 6961 6c73  mber of partials
    │ │ │ +00023cb0: 0a09 092f 2f20 7468 6520 7365 636f 6e64  ...// the second
    │ │ │ +00023cc0: 2063 6f6e 6469 7469 6f6e 2069 7320 746f   condition is to
    │ │ │ +00023cd0: 206d 616b 6520 7375 7265 2077 6520 6361   make sure we ca
    │ │ │ +00023ce0: 7020 7468 6520 6e75 6d62 6572 206f 6620  p the number of 
    │ │ │ +00023cf0: 7061 7274 6961 6c0a 0909 2f2f 205f 6279  partial...// _by
    │ │ │ +00023d00: 7465 735f 2e20 5468 6520 6c61 7267 6572  tes_. The larger
    │ │ │ +00023d10: 2074 6865 2070 6965 6365 7320 6172 652c   the pieces are,
    │ │ │ +00023d20: 2074 6865 2066 6577 6572 2070 6172 7469   the fewer parti
    │ │ │ +00023d30: 616c 2070 6965 6365 7320 7765 2077 616e  al pieces we wan
    │ │ │ +00023d40: 742e 0a09 092f 2f20 3230 3438 2063 6f72  t....// 2048 cor
    │ │ │ +00023d50: 7265 7370 6f6e 6473 2074 6f20 3332 204d  responds to 32 M
    │ │ │ +00023d60: 6942 0a3c 6469 7620 7374 796c 653d 2262  iB.
    ..const int num │ │ │ +00023da0: 5f70 6172 7469 616c 7320 3d20 696e 7428 _partials = int( │ │ │ +00023db0: 6d5f 646f 776e 6c6f 6164 735b 7069 6563 m_downloads[piec │ │ │ +00023dc0: 655f 706f 733a 3a70 6965 6365 5f64 6f77 e_pos::piece_dow │ │ │ +00023dd0: 6e6c 6f61 6469 6e67 5d2e 7369 7a65 2829 nloading].size() │ │ │ +00023de0: 293b 0a3c 2f64 6976 3e09 0969 6620 286e );.
    ..if (n │ │ │ +00023df0: 756d 5f70 6172 7469 616c 7320 2667 743b um_partials > │ │ │ +00023e00: 206e 756d 5f70 6565 7273 202a 2033 202f num_peers * 3 / │ │ │ +00023e10: 2032 0a09 0909 7c7c 206e 756d 5f70 6172 2....|| num_par │ │ │ +00023e20: 7469 616c 7320 2a20 626c 6f63 6b73 5f70 tials * blocks_p │ │ │ +00023e30: 6572 5f70 6965 6365 2829 2026 6774 3b20 er_piece() > │ │ │ +00023e40: 3230 3438 290a 0909 7b0a 0909 092f 2f20 2048)...{....// │ │ │ +00023e50: 6966 2077 6520 6861 7665 2074 6f6f 206d if we have too m │ │ │ +00023e60: 616e 7920 7061 7274 6961 6c20 7069 6563 any partial piec │ │ │ +00023e70: 6573 2c20 7072 696f 7269 7469 7a65 2063 es, prioritize c │ │ │ +00023e80: 6f6d 706c 6574 696e 670a 0909 092f 2f20 ompleting....// │ │ │ +00023e90: 7468 656d 2e20 496e 206f 7264 6572 2066 them. In order f │ │ │ +00023ea0: 6f72 2074 6869 7320 746f 2068 6176 6520 or this to have │ │ │ +00023eb0: 616e 2061 6666 6563 742c 2061 6c73 6f20 an affect, also │ │ │ +00023ec0: 6469 7361 626c 650a 0909 092f 2f20 7072 disable....// pr │ │ │ +00023ed0: 6566 6572 2077 686f 6c65 2070 6965 6365 efer whole piece │ │ │ +00023ee0: 7320 286f 7468 6572 7769 7365 2070 6172 s (otherwise par │ │ │ +00023ef0: 7469 616c 2070 6965 6365 7320 776f 756c tial pieces woul │ │ │ +00023f00: 6420 6265 2064 652d 7072 696f 7269 7469 d be de-prioriti │ │ │ +00023f10: 7a65 6429 0a09 0909 6f70 7469 6f6e 7320 zed)....options │ │ │ +00023f20: 7c3d 2070 7269 6f72 6974 697a 655f 7061 |= prioritize_pa │ │ │ +00023f30: 7274 6961 6c73 3b0a 0909 0970 7265 6665 rtials;....prefe │ │ │ +00023f40: 725f 636f 6e74 6967 756f 7573 5f62 6c6f r_contiguous_blo │ │ │ +00023f50: 636b 7320 3d20 303b 0a0a 0909 0972 6574 cks = 0;.....ret │ │ │ +00023f60: 207c 3d20 7069 636b 6572 5f6c 6f67 5f61 |= picker_log_a │ │ │ +00023f70: 6c65 7274 3a3a 7061 7274 6961 6c5f 7261 lert::partial_ra │ │ │ +00023f80: 7469 6f3b 0a09 097d 0a0a 0909 6966 2028 tio;...}....if ( │ │ │ +00023f90: 7072 6566 6572 5f63 6f6e 7469 6775 6f75 prefer_contiguou │ │ │ +00023fa0: 735f 626c 6f63 6b73 2920 7265 7420 7c3d s_blocks) ret |= │ │ │ +00023fb0: 2070 6963 6b65 725f 6c6f 675f 616c 6572 picker_log_aler │ │ │ +00023fc0: 743a 3a70 7265 6665 725f 636f 6e74 6967 t::prefer_contig │ │ │ +00023fd0: 756f 7573 3b0a 0a09 092f 2f20 6f6e 6c79 uous;....// only │ │ │ +00023fe0: 206f 6e65 206f 6620 7261 7265 7374 5f66 one of rarest_f │ │ │ +00023ff0: 6972 7374 2061 6e64 2073 6571 7565 6e74 irst and sequent │ │ │ +00024000: 6961 6c20 6361 6e20 6265 2073 6574 2e0a ial can be set.. │ │ │ +00024010: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +00024020: 2828 286f 7074 696f 6e73 2026 616d 703b (((options & │ │ │ +00024030: 2072 6172 6573 745f 6669 7273 7429 203f rarest_first) ? │ │ │ +00024040: 2031 203a 2030 290a 0909 092b 2028 286f 1 : 0)....+ ((o │ │ │ +00024050: 7074 696f 6e73 2026 616d 703b 2073 6571 ptions & seq │ │ │ +00024060: 7565 6e74 6961 6c29 203f 2031 203a 2030 uential) ? 1 : 0 │ │ │ +00024070: 2920 266c 743b 3d20 3129 3b0a 2369 6664 ) <= 1);.#ifd │ │ │ +00024080: 6566 2054 4f52 5245 4e54 5f45 5850 454e ef TORRENT_EXPEN │ │ │ +00024090: 5349 5645 5f49 4e56 4152 4941 4e54 5f43 SIVE_INVARIANT_C │ │ │ +000240a0: 4845 434b 530a 0909 494e 5641 5249 414e HECKS...INVARIAN │ │ │ +000240b0: 545f 4348 4543 4b3b 0a23 656e 6469 660a T_CHECK;.#endif. │ │ │ +000240c0: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +000240d0: 286e 756d 5f62 6c6f 636b 7320 2667 743b (num_blocks > │ │ │ +000240e0: 2030 293b 0a09 0954 4f52 5245 4e54 5f41 0);...TORRENT_A │ │ │ +000240f0: 5353 4552 5428 7069 6563 6573 2e73 697a SSERT(pieces.siz │ │ │ +00024100: 6528 2920 3d3d 2069 6e74 286d 5f70 6965 e() == int(m_pie │ │ │ +00024110: 6365 5f6d 6170 2e73 697a 6528 2929 293b ce_map.size())); │ │ │ +00024120: 0a0a 0909 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ +00024130: 5254 2821 6d5f 7072 696f 7269 7479 5f62 RT(!m_priority_b │ │ │ +00024140: 6f75 6e64 6172 6965 732e 656d 7074 7928 oundaries.empty( │ │ │ +00024150: 2920 7c7c 206d 5f64 6972 7479 293b 0a0a ) || m_dirty);.. │ │ │ +00024160: 0909 2f2f 2074 6869 7320 7769 6c6c 2062 ..// this will b │ │ │ +00024170: 6520 6669 6c6c 6564 2077 6974 6820 626c e filled with bl │ │ │ +00024180: 6f63 6b73 2074 6861 7420 7765 2073 686f ocks that we sho │ │ │ +00024190: 756c 6420 6e6f 7420 7265 7175 6573 740a uld not request. │ │ │ +000241a0: 0909 2f2f 2075 6e6c 6573 7320 7765 2063 ..// unless we c │ │ │ +000241b0: 616e 2774 2066 696e 6420 6e75 6d5f 626c an't find num_bl │ │ │ +000241c0: 6f63 6b73 2061 6d6f 6e67 2074 6865 206f ocks among the o │ │ │ +000241d0: 7468 6572 206f 6e65 732e 0a09 0973 7464 ther ones....std │ │ │ +000241e0: 3a3a 7665 6374 6f72 266c 743b 7069 6563 ::vector<piec │ │ │ +000241f0: 655f 626c 6f63 6b26 6774 3b20 6261 636b e_block> back │ │ │ +00024200: 7570 5f62 6c6f 636b 733b 0a09 0973 7464 up_blocks;...std │ │ │ +00024210: 3a3a 7665 6374 6f72 266c 743b 7069 6563 ::vector<piec │ │ │ +00024220: 655f 626c 6f63 6b26 6774 3b20 6261 636b e_block> back │ │ │ +00024230: 7570 5f62 6c6f 636b 7332 3b0a 0909 7374 up_blocks2;...st │ │ │ +00024240: 643a 3a76 6563 746f 7226 6c74 3b70 6965 d::vector<pie │ │ │ +00024250: 6365 5f69 6e64 6578 5f74 2667 743b 2069 ce_index_t> i │ │ │ +00024260: 676e 6f72 6564 5f70 6965 6365 733b 0a3c gnored_pieces;.< │ │ │ +00024270: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00024280: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +00024290: 6f75 6e64 3a20 2363 6663 223e 3c74 643e ound: #cfc"> │ │ │ +000242a0: 7265 6c65 7661 6e63 6526 6e62 7370 3b32 relevance 2 │ │ │ +000242b0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566
    ../src/ │ │ │ +000242e0: 7069 6563 655f 7069 636b 6572 2e63 7070 piece_picker.cpp │ │ │ +000242f0: 3a32 3631 313c 2f61 3e3c 2f74 643e 3c74 :2611the first_bloc │ │ │ +00024310: 6b20 7265 7475 726e 6564 2068 6572 6520 k returned here │ │ │ +00024320: 6973 2074 6865 206c 6172 6765 7374 2066 is the largest f │ │ │ +00024330: 7265 6520 7261 6e67 652c 206e 6f74 2074 ree range, not t │ │ │ +00024340: 6865 2066 6972 7374 2d66 6974 2072 616e he first-fit ran │ │ │ +00024350: 6765 2c20 7768 6963 6820 776f 756c 6420 ge, which would │ │ │ +00024360: 6265 2062 6574 7465 723c 2f74 643e 3c2f be better

    the first_ │ │ │ +000243c0: 626c 6f63 6b20 7265 7475 726e 6564 2068 block returned h │ │ │ +000243d0: 6572 6520 6973 2074 6865 206c 6172 6765 ere is the large │ │ │ +000243e0: 7374 2066 7265 6520 7261 6e67 652c 206e st free range, n │ │ │ +000243f0: 6f74 0a74 6865 2066 6972 7374 2d66 6974 ot.the first-fit │ │ │ +00024400: 2072 616e 6765 2c20 7768 6963 6820 776f range, which wo │ │ │ +00024410: 756c 6420 6265 2062 6574 7465 723c 2f68 uld be better

    ../src/pie │ │ │ +00024430: 6365 5f70 6963 6b65 722e 6370 703a 3236 ce_picker.cpp:26 │ │ │ +00024440: 3131 3c2f 6834 3e3c 7072 6520 7374 796c 11

    .{...for (auto 
    │ │ │ +00024490: 636f 6e73 7426 616d 703b 2062 203a 206d  const& b : m
    │ │ │ +000244a0: 5f62 6c6f 636b 5f69 6e66 6f29 0a09 097b  _block_info)...{
    │ │ │ +000244b0: 0a09 0909 544f 5252 454e 545f 4153 5345  ....TORRENT_ASSE
    │ │ │ +000244c0: 5254 2862 2e70 6565 7220 3d3d 206e 756c  RT(b.peer == nul
    │ │ │ +000244d0: 6c70 7472 207c 7c20 7374 6174 6963 5f63  lptr || static_c
    │ │ │ +000244e0: 6173 7426 6c74 3b74 6f72 7265 6e74 5f70  ast<torrent_p
    │ │ │ +000244f0: 6565 722a 2667 743b 2862 2e70 6565 7229  eer*>(b.peer)
    │ │ │ +00024500: 2d26 6774 3b69 6e5f 7573 6529 3b0a 0909  ->in_use);...
    │ │ │ +00024510: 7d0a 097d 0a23 656e 6469 660a 0a09 766f  }..}.#endif...vo
    │ │ │ +00024520: 6964 2070 6965 6365 5f70 6963 6b65 723a  id piece_picker:
    │ │ │ +00024530: 3a63 6c65 6172 5f70 6565 7228 746f 7272  :clear_peer(torr
    │ │ │ +00024540: 656e 745f 7065 6572 2a20 7065 6572 290a  ent_peer* peer).
    │ │ │ +00024550: 097b 0a09 0966 6f72 2028 6175 746f 2661  .{...for (auto&a
    │ │ │ +00024560: 6d70 3b20 6220 3a20 6d5f 626c 6f63 6b5f  mp; b : m_block_
    │ │ │ +00024570: 696e 666f 290a 0909 7b0a 0909 0969 6620  info)...{....if 
    │ │ │ +00024580: 2862 2e70 6565 7220 3d3d 2070 6565 7229  (b.peer == peer)
    │ │ │ +00024590: 2062 2e70 6565 7220 3d20 6e75 6c6c 7074   b.peer = nullpt
    │ │ │ +000245a0: 723b 0a09 097d 0a09 7d0a 0a09 2f2f 2074  r;...}..}...// t
    │ │ │ +000245b0: 6865 2066 6972 7374 2062 6f6f 6c20 6973  he first bool is
    │ │ │ +000245c0: 2074 7275 6520 6966 2074 6869 7320 6973   true if this is
    │ │ │ +000245d0: 2074 6865 206f 6e6c 7920 7065 6572 2074   the only peer t
    │ │ │ +000245e0: 6861 7420 6861 7320 7265 7175 6573 7465  hat has requeste
    │ │ │ +000245f0: 6420 616e 6420 646f 776e 6c6f 6164 6564  d and downloaded
    │ │ │ +00024600: 0a09 2f2f 2062 6c6f 636b 7320 6672 6f6d  ..// blocks from
    │ │ │ +00024610: 2074 6869 7320 7069 6563 652e 0a09 2f2f   this piece...//
    │ │ │ +00024620: 2074 6865 2073 6563 6f6e 6420 626f 6f6c   the second bool
    │ │ │ +00024630: 2069 7320 7472 7565 2069 6620 7468 6973   is true if this
    │ │ │ +00024640: 2069 7320 7468 6520 6f6e 6c79 2061 6374   is the only act
    │ │ │ +00024650: 6976 6520 7065 6572 2074 6861 7420 6973  ive peer that is
    │ │ │ +00024660: 2072 6571 7565 7374 696e 670a 092f 2f20   requesting..// 
    │ │ │ +00024670: 616e 6420 646f 776e 6c6f 6164 696e 6720  and downloading 
    │ │ │ +00024680: 626c 6f63 6b73 2066 726f 6d20 7468 6973  blocks from this
    │ │ │ +00024690: 2070 6965 6365 2e20 4163 7469 7665 206d   piece. Active m
    │ │ │ +000246a0: 6561 6e73 2068 6176 696e 6720 6120 636f  eans having a co
    │ │ │ +000246b0: 6e6e 6563 7469 6f6e 2e0a 3c64 6976 2073  nnection..
    .std::tu │ │ │ +000246f0: 706c 6526 6c74 3b62 6f6f 6c2c 2062 6f6f ple<bool, boo │ │ │ +00024700: 6c2c 2069 6e74 2c20 696e 7426 6774 3b20 l, int, int> │ │ │ +00024710: 7069 6563 655f 7069 636b 6572 3a3a 7265 piece_picker::re │ │ │ +00024720: 7175 6573 7465 645f 6672 6f6d 280a 3c2f quested_from(...piece_pick │ │ │ +00024740: 6572 3a3a 646f 776e 6c6f 6164 696e 675f er::downloading_ │ │ │ +00024750: 7069 6563 6520 636f 6e73 7426 616d 703b piece const& │ │ │ +00024760: 2070 0a09 092c 2069 6e74 2063 6f6e 7374 p..., int const │ │ │ +00024770: 206e 756d 5f62 6c6f 636b 735f 696e 5f70 num_blocks_in_p │ │ │ +00024780: 6965 6365 2c20 746f 7272 656e 745f 7065 iece, torrent_pe │ │ │ +00024790: 6572 2a20 7065 6572 2920 636f 6e73 740a er* peer) const. │ │ │ +000247a0: 097b 0a09 0962 6f6f 6c20 6578 636c 7573 .{...bool exclus │ │ │ +000247b0: 6976 6520 3d20 7472 7565 3b0a 0909 626f ive = true;...bo │ │ │ +000247c0: 6f6c 2065 7863 6c75 7369 7665 5f61 6374 ol exclusive_act │ │ │ +000247d0: 6976 6520 3d20 7472 7565 3b0a 0909 696e ive = true;...in │ │ │ +000247e0: 7420 636f 6e74 6967 756f 7573 5f62 6c6f t contiguous_blo │ │ │ +000247f0: 636b 7320 3d20 303b 0a09 0969 6e74 206d cks = 0;...int m │ │ │ +00024800: 6178 5f63 6f6e 7469 6775 6f75 7320 3d20 ax_contiguous = │ │ │ +00024810: 303b 0a09 0969 6e74 2066 6972 7374 5f62 0;...int first_b │ │ │ +00024820: 6c6f 636b 203d 2030 3b0a 0909 696e 7420 lock = 0;...int │ │ │ +00024830: 6964 7820 3d20 2d31 3b0a 0909 666f 7220 idx = -1;...for │ │ │ +00024840: 2861 7574 6f20 636f 6e73 7426 616d 703b (auto const& │ │ │ +00024850: 2069 6e66 6f20 3a20 626c 6f63 6b73 5f66 info : blocks_f │ │ │ +00024860: 6f72 5f70 6965 6365 2870 2929 0a09 097b or_piece(p))...{ │ │ │ +00024870: 0a09 0909 2b2b 6964 783b 0a09 0909 544f ....++idx;....TO │ │ │ +00024880: 5252 454e 545f 4153 5345 5254 2869 6e66 RRENT_ASSERT(inf │ │ │ +00024890: 6f2e 7065 6572 203d 3d20 6e75 6c6c 7074 o.peer == nullpt │ │ │ +000248a0: 7220 7c7c 2069 6e66 6f2e 7065 6572 2d26 r || info.peer-& │ │ │ +000248b0: 6774 3b69 6e5f 7573 6529 3b0a 0909 0954 gt;in_use);....T │ │ │ +000248c0: 4f52 5245 4e54 5f41 5353 4552 5428 696e ORRENT_ASSERT(in │ │ │ +000248d0: 666f 2e70 6965 6365 5f69 6e64 6578 203d fo.piece_index = │ │ │ +000248e0: 3d20 702e 696e 6465 7829 3b0a 0909 0969 = p.index);....i │ │ │ +000248f0: 6620 2869 6e66 6f2e 7374 6174 6520 3d3d f (info.state == │ │ │ +00024900: 2070 6965 6365 5f70 6963 6b65 723a 3a62 piece_picker::b │ │ │ +00024910: 6c6f 636b 5f69 6e66 6f3a 3a73 7461 7465 lock_info::state │ │ │ +00024920: 5f6e 6f6e 6529 0a09 0909 7b0a 0909 0909 _none)....{..... │ │ │ +00024930: 2b2b 636f 6e74 6967 756f 7573 5f62 6c6f ++contiguous_blo │ │ │ +00024940: 636b 733b 0a09 0909 0963 6f6e 7469 6e75 cks;.....continu │ │ │ +00024950: 653b 0a09 0909 7d0a 0909 0969 6620 2863 e;....}....if (c │ │ │ +00024960: 6f6e 7469 6775 6f75 735f 626c 6f63 6b73 ontiguous_blocks │ │ │ +00024970: 2026 6774 3b20 6d61 785f 636f 6e74 6967 > max_contig │ │ │ +00024980: 756f 7573 290a 0909 097b 0a09 0909 096d uous)....{.....m │ │ │ +00024990: 6178 5f63 6f6e 7469 6775 6f75 7320 3d20 ax_contiguous = │ │ │ +000249a0: 636f 6e74 6967 756f 7573 5f62 6c6f 636b contiguous_block │ │ │ +000249b0: 733b 0a09 0909 0966 6972 7374 5f62 6c6f s;.....first_blo │ │ │ +000249c0: 636b 203d 2069 6478 202d 2063 6f6e 7469 ck = idx - conti │ │ │ +000249d0: 6775 6f75 735f 626c 6f63 6b73 3b0a 0909 guous_blocks;... │ │ │ +000249e0: 097d 0a09 0909 636f 6e74 6967 756f 7573 .}....contiguous │ │ │ +000249f0: 5f62 6c6f 636b 7320 3d20 303b 0a09 0909 _blocks = 0;.... │ │ │ +00024a00: 6966 2028 696e 666f 2e70 6565 7220 213d if (info.peer != │ │ │ +00024a10: 2070 6565 7229 0a09 0909 7b0a 0909 0909 peer)....{..... │ │ │ +00024a20: 6578 636c 7573 6976 6520 3d20 6661 6c73 exclusive = fals │ │ │ +00024a30: 653b 0a09 0909 0969 6620 2869 6e66 6f2e e;.....if (info. │ │ │ +00024a40: 7374 6174 6520 3d3d 2070 6965 6365 5f70 state == piece_p │ │ │ +00024a50: 6963 6b65 723a 3a62 6c6f 636b 5f69 6e66 icker::block_inf │ │ │ +00024a60: 6f3a 3a73 7461 7465 5f72 6571 7565 7374 o::state_request │ │ │ +00024a70: 6564 0a09 0909 0909 2661 6d70 3b26 616d ed......&&am │ │ │ +00024a80: 703b 2069 6e66 6f2e 7065 6572 2021 3d20 p; info.peer != │ │ │ +00024a90: 6e75 6c6c 7074 7229 0a3c 2f70 7265 3e3c nullptr).
    < │ │ │ +00024aa0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00024ad0: 6e63 6526 6e62 7370 3b32 3c2f 7464 3e3c nce 2< │ │ │ +00024ae0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/piece_ │ │ │ +00024b10: 7069 636b 6572 2e63 7070 3a33 3439 353c picker.cpp:3495< │ │ │ +00024b20: 2f61 3e3c 2f74 643e 3c74 643e 6974 2077 /a>it w │ │ │ +00024b30: 6f75 6c64 2062 6520 6e69 6365 2069 6620 ould be nice if │ │ │ +00024b40: 7468 6973 2063 6f75 6c64 2062 6520 666f this could be fo │ │ │ +00024b50: 6c64 6564 2069 6e74 6f20 6c6f 636b 5f70 lded into lock_p │ │ │ +00024b60: 6965 6365 2829 2074 6865 206d 6169 6e20 iece() the main │ │ │ +00024b70: 6469 7374 696e 6374 696f 6e20 6973 2074 distinction is t │ │ │ +00024b80: 6861 7420 7468 6973 2061 6c73 6f20 6d61 hat this also ma │ │ │ +00024b90: 696e 7461 696e 7320 7468 6520 6d5f 6e75 intains the m_nu │ │ │ +00024ba0: 6d5f 6861 7665 2063 6f75 6e74 6572 2061 m_have counter a │ │ │ +00024bb0: 6e64 2074 6865 2070 6173 7365 645f 6861 nd the passed_ha │ │ │ +00024bc0: 7368 5f63 6865 636b 206d 656d 6265 7220 sh_check member │ │ │ +00024bd0: 4973 2074 6865 7265 2065 7665 7220 6120 Is there ever a │ │ │ +00024be0: 6361 7365 2077 6865 7265 2077 6520 6361 case where we ca │ │ │ +00024bf0: 6c6c 2077 7269 7465 2066 6169 6c65 6420 ll write failed │ │ │ +00024c00: 7769 7468 6f75 7420 616c 736f 206c 6f63 without also loc │ │ │ +00024c10: 6b69 6e67 2074 6865 2070 6965 6365 3f20 king the piece? │ │ │ +00024c20: 5065 7268 6170 7320 7772 6974 655f 6661 Perhaps write_fa │ │ │ +00024c30: 696c 6564 2829 2073 686f 756c 6420 696d iled() should im │ │ │ +00024c40: 706c 7920 6c6f 636b 696e 6720 6974 2e3c ply locking it.< │ │ │ +00024c50: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    it w │ │ │ +00024ca0: 6f75 6c64 2062 6520 6e69 6365 2069 6620 ould be nice if │ │ │ +00024cb0: 7468 6973 2063 6f75 6c64 2062 6520 666f this could be fo │ │ │ +00024cc0: 6c64 6564 2069 6e74 6f20 6c6f 636b 5f70 lded into lock_p │ │ │ +00024cd0: 6965 6365 2829 0a74 6865 206d 6169 6e20 iece().the main │ │ │ +00024ce0: 6469 7374 696e 6374 696f 6e20 6973 2074 distinction is t │ │ │ +00024cf0: 6861 7420 7468 6973 2061 6c73 6f20 6d61 hat this also ma │ │ │ +00024d00: 696e 7461 696e 7320 7468 6520 6d5f 6e75 intains the m_nu │ │ │ +00024d10: 6d5f 6861 7665 0a63 6f75 6e74 6572 2061 m_have.counter a │ │ │ +00024d20: 6e64 2074 6865 2070 6173 7365 645f 6861 nd the passed_ha │ │ │ +00024d30: 7368 5f63 6865 636b 206d 656d 6265 720a sh_check member. │ │ │ +00024d40: 4973 2074 6865 7265 2065 7665 7220 6120 Is there ever a │ │ │ +00024d50: 6361 7365 2077 6865 7265 2077 6520 6361 case where we ca │ │ │ +00024d60: 6c6c 2077 7269 7465 2066 6169 6c65 6420 ll write failed │ │ │ +00024d70: 7769 7468 6f75 7420 616c 736f 206c 6f63 without also loc │ │ │ +00024d80: 6b69 6e67 0a74 6865 2070 6965 6365 3f20 king.the piece? │ │ │ +00024d90: 5065 7268 6170 7320 7772 6974 655f 6661 Perhaps write_fa │ │ │ +00024da0: 696c 6564 2829 2073 686f 756c 6420 696d iled() should im │ │ │ +00024db0: 706c 7920 6c6f 636b 696e 6720 6974 2e3c ply locking it.< │ │ │ +00024dc0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ +00024dd0: 6965 6365 5f70 6963 6b65 722e 6370 703a iece_picker.cpp: │ │ │ +00024de0: 3334 3935 3c2f 6834 3e3c 7072 6520 7374 3495

    ...auto const
    │ │ │ +00024e30: 2073 7461 7465 203d 206d 5f70 6965 6365   state = m_piece
    │ │ │ +00024e40: 5f6d 6170 5b70 6965 6365 5d2e 646f 776e  _map[piece].down
    │ │ │ +00024e50: 6c6f 6164 5f71 7565 7565 2829 3b0a 0909  load_queue();...
    │ │ │ +00024e60: 6966 2028 7374 6174 6520 3d3d 2070 6965  if (state == pie
    │ │ │ +00024e70: 6365 5f70 6f73 3a3a 7069 6563 655f 6f70  ce_pos::piece_op
    │ │ │ +00024e80: 656e 2920 7265 7475 726e 3b0a 0909 6175  en) return;...au
    │ │ │ +00024e90: 746f 2063 6f6e 7374 2069 203d 2066 696e  to const i = fin
    │ │ │ +00024ea0: 645f 646c 5f70 6965 6365 2873 7461 7465  d_dl_piece(state
    │ │ │ +00024eb0: 2c20 7069 6563 6529 3b0a 0909 6966 2028  , piece);...if (
    │ │ │ +00024ec0: 6920 3d3d 206d 5f64 6f77 6e6c 6f61 6473  i == m_downloads
    │ │ │ +00024ed0: 5b73 7461 7465 5d2e 656e 6428 2929 2072  [state].end()) r
    │ │ │ +00024ee0: 6574 7572 6e3b 0a0a 0909 544f 5252 454e  eturn;....TORREN
    │ │ │ +00024ef0: 545f 4153 5345 5254 2869 2d26 6774 3b70  T_ASSERT(i->p
    │ │ │ +00024f00: 6173 7365 645f 6861 7368 5f63 6865 636b  assed_hash_check
    │ │ │ +00024f10: 203d 3d20 6661 6c73 6529 3b0a 0909 6966   == false);...if
    │ │ │ +00024f20: 2028 692d 2667 743b 7061 7373 6564 5f68   (i->passed_h
    │ │ │ +00024f30: 6173 685f 6368 6563 6b29 0a09 097b 0a09  ash_check)...{..
    │ │ │ +00024f40: 0909 2f2f 2069 7427 7320 6e6f 7420 636c  ..// it's not cl
    │ │ │ +00024f50: 6561 7220 7768 7920 7468 6973 2077 6f75  ear why this wou
    │ │ │ +00024f60: 6c64 2068 6170 7065 6e2c 0a09 0909 2f2f  ld happen,....//
    │ │ │ +00024f70: 2062 7574 2069 7420 7365 656d 7320 7265   but it seems re
    │ │ │ +00024f80: 6173 6f6e 6162 6c65 2074 6f20 6e6f 7420  asonable to not 
    │ │ │ +00024f90: 6272 6561 6b20 7468 650a 0909 092f 2f20  break the....// 
    │ │ │ +00024fa0: 6163 636f 756e 7469 6e67 206f 7665 7220  accounting over 
    │ │ │ +00024fb0: 6974 2e0a 0909 0969 2d26 6774 3b70 6173  it.....i->pas
    │ │ │ +00024fc0: 7365 645f 6861 7368 5f63 6865 636b 203d  sed_hash_check =
    │ │ │ +00024fd0: 2066 616c 7365 3b0a 0909 0961 6363 6f75   false;....accou
    │ │ │ +00024fe0: 6e74 5f6c 6f73 7428 7069 6563 6529 3b0a  nt_lost(piece);.
    │ │ │ +00024ff0: 0909 7d0a 0a09 092f 2f20 7072 6576 656e  ..}....// preven
    │ │ │ +00025000: 7420 7468 6973 2070 6965 6365 2066 726f  t this piece fro
    │ │ │ +00025010: 6d20 6265 696e 6720 7069 636b 6564 2075  m being picked u
    │ │ │ +00025020: 6e74 696c 2069 7427 7320 7265 7374 6f72  ntil it's restor
    │ │ │ +00025030: 6564 0a09 0969 2d26 6774 3b6c 6f63 6b65  ed...i->locke
    │ │ │ +00025040: 6420 3d20 7472 7565 3b0a 097d 0a0a 3c64  d = true;..}...voi
    │ │ │ +00025080: 6420 7069 6563 655f 7069 636b 6572 3a3a  d piece_picker::
    │ │ │ +00025090: 7772 6974 655f 6661 696c 6564 2870 6965  write_failed(pie
    │ │ │ +000250a0: 6365 5f62 6c6f 636b 2063 6f6e 7374 2062  ce_block const b
    │ │ │ +000250b0: 6c6f 636b 290a 3c2f 6469 763e 097b 0a09  lock).

    .{.. │ │ │ +000250c0: 0949 4e56 4152 4941 4e54 5f43 4845 434b .INVARIANT_CHECK │ │ │ +000250d0: 3b0a 0a23 6966 2054 4f52 5245 4e54 5f55 ;..#if TORRENT_U │ │ │ +000250e0: 5345 5f49 4e56 4152 4941 4e54 5f43 4845 SE_INVARIANT_CHE │ │ │ +000250f0: 434b 530a 0909 6368 6563 6b5f 7069 6563 CKS...check_piec │ │ │ +00025100: 655f 7374 6174 6528 293b 0a23 656e 6469 e_state();.#endi │ │ │ +00025110: 660a 0a23 6966 6465 6620 544f 5252 454e f..#ifdef TORREN │ │ │ +00025120: 545f 5049 434b 4552 5f4c 4f47 0a09 0973 T_PICKER_LOG...s │ │ │ +00025130: 7464 3a3a 6365 7272 2026 6c74 3b26 6c74 td::cerr << │ │ │ +00025140: 3b20 225b 2220 266c 743b 266c 743b 2074 ; "[" << t │ │ │ +00025150: 6869 7320 266c 743b 266c 743b 2022 5d20 his << "] │ │ │ +00025160: 2220 266c 743b 266c 743b 2022 7772 6974 " << "writ │ │ │ +00025170: 655f 6661 696c 6564 2820 7b22 2026 6c74 e_failed( {" < │ │ │ +00025180: 3b26 6c74 3b20 626c 6f63 6b2e 7069 6563 ;< block.piec │ │ │ +00025190: 655f 696e 6465 7820 266c 743b 266c 743b e_index << │ │ │ +000251a0: 2022 2c20 2220 266c 743b 266c 743b 2062 ", " << b │ │ │ +000251b0: 6c6f 636b 2e62 6c6f 636b 5f69 6e64 6578 lock.block_index │ │ │ +000251c0: 2026 6c74 3b26 6c74 3b20 227d 2029 2220 << "} )" │ │ │ +000251d0: 266c 743b 266c 743b 2073 7464 3a3a 656e << std::en │ │ │ +000251e0: 646c 3b0a 2365 6e64 6966 0a0a 0909 6175 dl;.#endif....au │ │ │ +000251f0: 746f 2063 6f6e 7374 2073 7461 7465 203d to const state = │ │ │ +00025200: 206d 5f70 6965 6365 5f6d 6170 5b62 6c6f m_piece_map[blo │ │ │ +00025210: 636b 2e70 6965 6365 5f69 6e64 6578 5d2e ck.piece_index]. │ │ │ +00025220: 646f 776e 6c6f 6164 5f71 7565 7565 2829 download_queue() │ │ │ +00025230: 3b0a 0909 6966 2028 7374 6174 6520 3d3d ;...if (state == │ │ │ +00025240: 2070 6965 6365 5f70 6f73 3a3a 7069 6563 piece_pos::piec │ │ │ +00025250: 655f 6f70 656e 2920 7265 7475 726e 3b0a e_open) return;. │ │ │ +00025260: 0909 6175 746f 2069 203d 2066 696e 645f ..auto i = find_ │ │ │ +00025270: 646c 5f70 6965 6365 2873 7461 7465 2c20 dl_piece(state, │ │ │ +00025280: 626c 6f63 6b2e 7069 6563 655f 696e 6465 block.piece_inde │ │ │ +00025290: 7829 3b0a 0909 6966 2028 6920 3d3d 206d x);...if (i == m │ │ │ +000252a0: 5f64 6f77 6e6c 6f61 6473 5b73 7461 7465 _downloads[state │ │ │ +000252b0: 5d2e 656e 6428 2929 2072 6574 7572 6e3b ].end()) return; │ │ │ +000252c0: 0a0a 0909 6175 746f 2063 6f6e 7374 2062 ....auto const b │ │ │ +000252d0: 696e 666f 203d 206d 7574 6162 6c65 5f62 info = mutable_b │ │ │ +000252e0: 6c6f 636b 735f 666f 725f 7069 6563 6528 locks_for_piece( │ │ │ +000252f0: 2a69 293b 0a09 0962 6c6f 636b 5f69 6e66 *i);...block_inf │ │ │ +00025300: 6f26 616d 703b 2069 6e66 6f20 3d20 6269 o& info = bi │ │ │ +00025310: 6e66 6f5b 626c 6f63 6b2e 626c 6f63 6b5f nfo[block.block_ │ │ │ +00025320: 696e 6465 785d 3b0a 0909 544f 5252 454e index];...TORREN │ │ │ +00025330: 545f 4153 5345 5254 2826 616d 703b 696e T_ASSERT(&in │ │ │ +00025340: 666f 2026 6774 3b3d 2026 616d 703b 6d5f fo >= &m_ │ │ │ +00025350: 626c 6f63 6b5f 696e 666f 5b30 5d29 3b0a block_info[0]);. │ │ │ +00025360: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +00025370: 2826 616d 703b 696e 666f 2026 6c74 3b20 (&info < │ │ │ +00025380: 2661 6d70 3b6d 5f62 6c6f 636b 5f69 6e66 &m_block_inf │ │ │ +00025390: 6f5b 305d 202b 206d 5f62 6c6f 636b 5f69 o[0] + m_block_i │ │ │ +000253a0: 6e66 6f2e 7369 7a65 2829 293b 0a09 0954 nfo.size());...T │ │ │ +000253b0: 4f52 5245 4e54 5f41 5353 4552 5428 696e ORRENT_ASSERT(in │ │ │ +000253c0: 666f 2e70 6965 6365 5f69 6e64 6578 203d fo.piece_index = │ │ │ +000253d0: 3d20 626c 6f63 6b2e 7069 6563 655f 696e = block.piece_in │ │ │ +000253e0: 6465 7829 3b0a 0909 544f 5252 454e 545f dex);...TORRENT_ │ │ │ +000253f0: 4153 5345 5254 2869 6e66 6f2e 7374 6174 ASSERT(info.stat │ │ │ +00025400: 6520 3d3d 2062 6c6f 636b 5f69 6e66 6f3a e == block_info: │ │ │ +00025410: 3a73 7461 7465 5f77 7269 7469 6e67 293b :state_writing); │ │ │ +00025420: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00025430: 5428 696e 666f 2e6e 756d 5f70 6565 7273 T(info.num_peers │ │ │ +00025440: 203d 3d20 3029 3b0a 0a09 0954 4f52 5245 == 0);....TORRE │ │ │ +00025450: 4e54 5f41 5353 4552 5428 692d 2667 743b NT_ASSERT(i-> │ │ │ +00025460: 7772 6974 696e 6720 2667 743b 2030 293b writing > 0); │ │ │ +00025470: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00025480: 5428 696e 666f 2e73 7461 7465 203d 3d20 T(info.state == │ │ │ +00025490: 626c 6f63 6b5f 696e 666f 3a3a 7374 6174 block_info::stat │ │ │ +000254a0: 655f 7772 6974 696e 6729 3b0a 0a09 0969 e_writing);....i │ │ │ +000254b0: 6620 2869 6e66 6f2e 7374 6174 6520 3d3d f (info.state == │ │ │ +000254c0: 2062 6c6f 636b 5f69 6e66 6f3a 3a73 7461 block_info::sta │ │ │ +000254d0: 7465 5f66 696e 6973 6865 6429 2072 6574 te_finished) ret │ │ │ +000254e0: 7572 6e3b 0a09 0969 6620 2869 6e66 6f2e urn;...if (info. │ │ │ +000254f0: 7374 6174 6520 3d3d 2062 6c6f 636b 5f69 state == block_i │ │ │ +00025500: 6e66 6f3a 3a73 7461 7465 5f77 7269 7469 nfo::state_writi │ │ │ +00025510: 6e67 2920 2d2d 692d 2667 743b 7772 6974 ng) --i->writ │ │ │ +00025520: 696e 673b 0a0a 3c2f 7072 653e 3c2f 7464 ing;..
    relevance │ │ │ +00025560: 266e 6273 703b 323c 2f74 643e 3c74 643e  2 │ │ │ +00025570: 3c61 2068 7265 663d 226a 6176 6173 6372 │ │ │ +00025590: 2e2e 2f73 7263 2f75 706e 702e 6370 703a ../src/upnp.cpp: │ │ │ +000255a0: 3131 363c 2f61 3e3c 2f74 643e 3c74 643e 116 │ │ │ +000255b0: 7573 6520 626f 6f73 743a 3a61 7369 6f3a use boost::asio: │ │ │ +000255c0: 3a69 703a 3a6e 6574 776f 726b 2069 6e73 :ip::network ins │ │ │ +000255d0: 7465 6164 206f 6620 6e65 746d 6173 6b3c tead of netmask< │ │ │ +000255e0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    use │ │ │ +00025630: 626f 6f73 743a 3a61 7369 6f3a 3a69 703a boost::asio::ip: │ │ │ +00025640: 3a6e 6574 776f 726b 2069 6e73 7465 6164 :network instead │ │ │ +00025650: 206f 6620 6e65 746d 6173 6b3c 2f68 323e of netmask

    │ │ │ +00025660: 3c68 343e 2e2e 2f73 7263 2f75 706e 702e

    ../src/upnp. │ │ │ +00025670: 6370 703a 3131 363c 2f68 343e 3c70 7265 cpp:116

    ..|| strin
    │ │ │ +000256c0: 675f 6571 7561 6c5f 6e6f 5f63 6173 6528  g_equal_no_case(
    │ │ │ +000256d0: 636f 6e74 656e 745f 7479 7065 2c20 2261  content_type, "a
    │ │ │ +000256e0: 7070 6c69 6361 7469 6f6e 2f73 6f61 702b  pplication/soap+
    │ │ │ +000256f0: 786d 6c22 5f73 7629 3b0a 7d0a 0a75 706e  xml"_sv);.}..upn
    │ │ │ +00025700: 703a 3a72 6f6f 7464 6576 6963 653a 3a72  p::rootdevice::r
    │ │ │ +00025710: 6f6f 7464 6576 6963 6528 2920 3d20 6465  ootdevice() = de
    │ │ │ +00025720: 6661 756c 743b 0a0a 2369 6620 544f 5252  fault;..#if TORR
    │ │ │ +00025730: 454e 545f 5553 455f 4153 5345 5254 530a  ENT_USE_ASSERTS.
    │ │ │ +00025740: 7570 6e70 3a3a 726f 6f74 6465 7669 6365  upnp::rootdevice
    │ │ │ +00025750: 3a3a 7e72 6f6f 7464 6576 6963 6528 290a  ::~rootdevice().
    │ │ │ +00025760: 7b0a 0954 4f52 5245 4e54 5f41 5353 4552  {..TORRENT_ASSER
    │ │ │ +00025770: 5428 6d61 6769 6320 3d3d 2031 3333 3729  T(magic == 1337)
    │ │ │ +00025780: 3b0a 096d 6167 6963 203d 2030 3b0a 7d0a  ;..magic = 0;.}.
    │ │ │ +00025790: 2365 6c73 650a 7570 6e70 3a3a 726f 6f74  #else.upnp::root
    │ │ │ +000257a0: 6465 7669 6365 3a3a 7e72 6f6f 7464 6576  device::~rootdev
    │ │ │ +000257b0: 6963 6528 2920 3d20 6465 6661 756c 743b  ice() = default;
    │ │ │ +000257c0: 0a23 656e 6469 660a 0a75 706e 703a 3a72  .#endif..upnp::r
    │ │ │ +000257d0: 6f6f 7464 6576 6963 653a 3a72 6f6f 7464  ootdevice::rootd
    │ │ │ +000257e0: 6576 6963 6528 726f 6f74 6465 7669 6365  evice(rootdevice
    │ │ │ +000257f0: 2063 6f6e 7374 2661 6d70 3b29 203d 2064   const&) = d
    │ │ │ +00025800: 6566 6175 6c74 3b0a 7570 6e70 3a3a 726f  efault;.upnp::ro
    │ │ │ +00025810: 6f74 6465 7669 6365 2661 6d70 3b20 7570  otdevice& up
    │ │ │ +00025820: 6e70 3a3a 726f 6f74 6465 7669 6365 3a3a  np::rootdevice::
    │ │ │ +00025830: 6f70 6572 6174 6f72 3d28 726f 6f74 6465  operator=(rootde
    │ │ │ +00025840: 7669 6365 2063 6f6e 7374 2661 6d70 3b29  vice const&)
    │ │ │ +00025850: 2026 616d 703b 203d 2064 6566 6175 6c74   & = default
    │ │ │ +00025860: 3b0a 7570 6e70 3a3a 726f 6f74 6465 7669  ;.upnp::rootdevi
    │ │ │ +00025870: 6365 3a3a 726f 6f74 6465 7669 6365 2872  ce::rootdevice(r
    │ │ │ +00025880: 6f6f 7464 6576 6963 6526 616d 703b 2661  ootdevice&&a
    │ │ │ +00025890: 6d70 3b29 206e 6f65 7863 6570 7420 3d20  mp;) noexcept = 
    │ │ │ +000258a0: 6465 6661 756c 743b 0a75 706e 703a 3a72  default;.upnp::r
    │ │ │ +000258b0: 6f6f 7464 6576 6963 6526 616d 703b 2075  ootdevice& u
    │ │ │ +000258c0: 706e 703a 3a72 6f6f 7464 6576 6963 653a  pnp::rootdevice:
    │ │ │ +000258d0: 3a6f 7065 7261 746f 723d 2872 6f6f 7464  :operator=(rootd
    │ │ │ +000258e0: 6576 6963 6526 616d 703b 2661 6d70 3b29  evice&&)
    │ │ │ +000258f0: 2026 616d 703b 203d 2064 6566 6175 6c74   & = default
    │ │ │ +00025900: 3b0a 0a3c 6469 7620 7374 796c 653d 2262  ;..
    upnp::upnp(io_c │ │ │ +00025940: 6f6e 7465 7874 2661 6d70 3b20 696f 730a ontext& ios. │ │ │ +00025950: 3c2f 6469 763e 092c 2061 7578 3a3a 7365
    ., aux::se │ │ │ +00025960: 7373 696f 6e5f 7365 7474 696e 6773 2063 ssion_settings c │ │ │ +00025970: 6f6e 7374 2661 6d70 3b20 7365 7474 696e onst& settin │ │ │ +00025980: 6773 0a09 2c20 6175 783a 3a70 6f72 746d gs.., aux::portm │ │ │ +00025990: 6170 5f63 616c 6c62 6163 6b26 616d 703b ap_callback& │ │ │ +000259a0: 2063 620a 092c 2061 6464 7265 7373 5f76 cb.., address_v │ │ │ +000259b0: 3420 636f 6e73 7420 6c69 7374 656e 5f61 4 const listen_a │ │ │ +000259c0: 6464 7265 7373 0a09 2c20 6164 6472 6573 ddress.., addres │ │ │ +000259d0: 735f 7634 2063 6f6e 7374 206e 6574 6d61 s_v4 const netma │ │ │ +000259e0: 736b 0a09 2c20 7374 643a 3a73 7472 696e sk.., std::strin │ │ │ +000259f0: 6720 6c69 7374 656e 5f64 6576 6963 650a g listen_device. │ │ │ +00025a00: 092c 206c 6973 7465 6e5f 736f 636b 6574 ., listen_socket │ │ │ +00025a10: 5f68 616e 646c 6520 6c73 290a 093a 206d _handle ls)..: m │ │ │ +00025a20: 5f73 6574 7469 6e67 7328 7365 7474 696e _settings(settin │ │ │ +00025a30: 6773 290a 092c 206d 5f63 616c 6c62 6163 gs).., m_callbac │ │ │ +00025a40: 6b28 6362 290a 092c 206d 5f69 6f5f 7365 k(cb).., m_io_se │ │ │ +00025a50: 7276 6963 6528 696f 7329 0a09 2c20 6d5f rvice(ios).., m_ │ │ │ +00025a60: 7265 736f 6c76 6572 2869 6f73 290a 092c resolver(ios).., │ │ │ +00025a70: 206d 5f6d 756c 7469 6361 7374 2869 6f73 m_multicast(ios │ │ │ +00025a80: 290a 092c 206d 5f75 6e69 6361 7374 2869 ).., m_unicast(i │ │ │ +00025a90: 6f73 290a 092c 206d 5f62 726f 6164 6361 os).., m_broadca │ │ │ +00025aa0: 7374 5f74 696d 6572 2869 6f73 290a 092c st_timer(ios).., │ │ │ +00025ab0: 206d 5f72 6566 7265 7368 5f74 696d 6572 m_refresh_timer │ │ │ +00025ac0: 2869 6f73 290a 092c 206d 5f6d 6170 5f74 (ios).., m_map_t │ │ │ +00025ad0: 696d 6572 2869 6f73 290a 092c 206d 5f6c imer(ios).., m_l │ │ │ +00025ae0: 6973 7465 6e5f 6164 6472 6573 7328 6c69 isten_address(li │ │ │ +00025af0: 7374 656e 5f61 6464 7265 7373 290a 092c sten_address).., │ │ │ +00025b00: 206d 5f6e 6574 6d61 736b 286e 6574 6d61 m_netmask(netma │ │ │ +00025b10: 736b 290a 092c 206d 5f64 6576 6963 6528 sk).., m_device( │ │ │ +00025b20: 7374 643a 3a6d 6f76 6528 6c69 7374 656e std::move(listen │ │ │ +00025b30: 5f64 6576 6963 6529 290a 2369 6620 544f _device)).#if TO │ │ │ +00025b40: 5252 454e 545f 5553 455f 5353 4c0a 092c RRENT_USE_SSL.., │ │ │ +00025b50: 206d 5f73 736c 5f63 7478 2873 736c 3a3a m_ssl_ctx(ssl:: │ │ │ +00025b60: 636f 6e74 6578 743a 3a73 736c 7632 335f context::sslv23_ │ │ │ +00025b70: 636c 6965 6e74 290a 2365 6e64 6966 0a09 client).#endif.. │ │ │ +00025b80: 2c20 6d5f 6c69 7374 656e 5f68 616e 646c , m_listen_handl │ │ │ +00025b90: 6528 7374 643a 3a6d 6f76 6528 6c73 2929 e(std::move(ls)) │ │ │ +00025ba0: 0a7b 0a23 6966 2054 4f52 5245 4e54 5f55 .{.#if TORRENT_U │ │ │ +00025bb0: 5345 5f53 534c 0a09 6d5f 7373 6c5f 6374 SE_SSL..m_ssl_ct │ │ │ +00025bc0: 782e 7365 745f 7665 7269 6679 5f6d 6f64 x.set_verify_mod │ │ │ +00025bd0: 6528 7373 6c3a 3a63 6f6e 7465 7874 3a3a e(ssl::context:: │ │ │ +00025be0: 7665 7269 6679 5f6e 6f6e 6529 3b0a 2365 verify_none);.#e │ │ │ +00025bf0: 6e64 6966 0a7d 0a0a 766f 6964 2075 706e ndif.}..void upn │ │ │ +00025c00: 703a 3a73 7461 7274 2829 0a7b 0a3c 2f70 p::start().{.

    re │ │ │ +00025c40: 6c65 7661 6e63 6526 6e62 7370 3b32 3c2f levance 2../src/bd │ │ │ +00025c80: 6563 6f64 652e 6370 703a 3832 373c 2f61 ecode.cpp:827attemp │ │ │ +00025ca0: 7420 746f 2073 696d 706c 6966 7920 7468 t to simplify th │ │ │ +00025cb0: 6973 2069 6d70 6c65 6d65 6e74 6174 696f is implementatio │ │ │ +00025cc0: 6e20 6279 2065 6d62 7261 6369 6e67 2074 n by embracing t │ │ │ +00025cd0: 6865 2073 7061 6e3c 2f74 643e 3c2f 7472 he span │ │ │ +00025d10: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00025d20: 3c68 323e 6174 7465 6d70 7420 746f 2073

    attempt to s │ │ │ +00025d30: 696d 706c 6966 7920 7468 6973 2069 6d70 implify this imp │ │ │ +00025d40: 6c65 6d65 6e74 6174 696f 6e20 6279 2065 lementation by e │ │ │ +00025d50: 6d62 7261 6369 6e67 2074 6865 2073 7061 mbracing the spa │ │ │ +00025d60: 6e3c 2f68 323e 3c68 343e 2e2e 2f73 7263 n

    ../src │ │ │ +00025d70: 2f62 6465 636f 6465 2e63 7070 3a38 3237 /bdecode.cpp:827 │ │ │ +00025d80: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +00025dc0: 7d0a 0a09 6264 6563 6f64 655f 6e6f 6465  }...bdecode_node
    │ │ │ +00025dd0: 2062 6465 636f 6465 2873 7061 6e26 6c74   bdecode(span<
    │ │ │ +00025de0: 3b63 6861 7220 636f 6e73 7426 6774 3b20  ;char const> 
    │ │ │ +00025df0: 6275 6666 6572 0a09 092c 2065 7272 6f72  buffer..., error
    │ │ │ +00025e00: 5f63 6f64 6526 616d 703b 2065 632c 2069  _code& ec, i
    │ │ │ +00025e10: 6e74 2a20 6572 726f 725f 706f 732c 2069  nt* error_pos, i
    │ │ │ +00025e20: 6e74 2064 6570 7468 5f6c 696d 6974 2c20  nt depth_limit, 
    │ │ │ +00025e30: 696e 7420 746f 6b65 6e5f 6c69 6d69 7429  int token_limit)
    │ │ │ +00025e40: 0a09 7b0a 0909 6264 6563 6f64 655f 6e6f  ..{...bdecode_no
    │ │ │ +00025e50: 6465 2072 6574 3b0a 0909 6563 2e63 6c65  de ret;...ec.cle
    │ │ │ +00025e60: 6172 2829 3b0a 0a09 0969 6620 2862 7566  ar();....if (buf
    │ │ │ +00025e70: 6665 722e 7369 7a65 2829 2026 6774 3b20  fer.size() > 
    │ │ │ +00025e80: 6264 6563 6f64 655f 746f 6b65 6e3a 3a6d  bdecode_token::m
    │ │ │ +00025e90: 6178 5f6f 6666 7365 7429 0a09 097b 0a09  ax_offset)...{..
    │ │ │ +00025ea0: 0909 6966 2028 6572 726f 725f 706f 7329  ..if (error_pos)
    │ │ │ +00025eb0: 202a 6572 726f 725f 706f 7320 3d20 303b   *error_pos = 0;
    │ │ │ +00025ec0: 0a09 0909 6563 203d 2062 6465 636f 6465  ....ec = bdecode
    │ │ │ +00025ed0: 5f65 7272 6f72 733a 3a6c 696d 6974 5f65  _errors::limit_e
    │ │ │ +00025ee0: 7863 6565 6465 643b 0a09 0909 7265 7475  xceeded;....retu
    │ │ │ +00025ef0: 726e 2072 6574 3b0a 0909 7d0a 0a09 092f  rn ret;...}..../
    │ │ │ +00025f00: 2f20 7468 6973 2069 7320 7468 6520 7374  / this is the st
    │ │ │ +00025f10: 6163 6b20 6f66 2062 6465 636f 6465 5f74  ack of bdecode_t
    │ │ │ +00025f20: 6f6b 656e 2069 6e64 6963 6573 2c20 696e  oken indices, in
    │ │ │ +00025f30: 746f 206d 5f74 6f6b 656e 732e 0a09 092f  to m_tokens..../
    │ │ │ +00025f40: 2f20 7370 2069 7320 7468 6520 7374 6163  / sp is the stac
    │ │ │ +00025f50: 6b20 706f 696e 7465 722c 2061 7320 696e  k pointer, as in
    │ │ │ +00025f60: 6465 7820 696e 746f 2074 6865 2061 7272  dex into the arr
    │ │ │ +00025f70: 6179 2c20 7374 6163 6b0a 0909 696e 7420  ay, stack...int 
    │ │ │ +00025f80: 7370 203d 2030 3b0a 0909 544f 5252 454e  sp = 0;...TORREN
    │ │ │ +00025f90: 545f 414c 4c4f 4341 2873 7461 636b 2c20  T_ALLOCA(stack, 
    │ │ │ +00025fa0: 7374 6163 6b5f 6672 616d 652c 2064 6570  stack_frame, dep
    │ │ │ +00025fb0: 7468 5f6c 696d 6974 293b 0a0a 3c64 6976  th_limit);..
    ..char │ │ │ +00025ff0: 2063 6f6e 7374 2a20 7374 6172 7420 3d20 const* start = │ │ │ +00026000: 6275 6666 6572 2e64 6174 6128 293b 0a3c buffer.data();.< │ │ │ +00026010: 2f64 6976 3e09 0963 6861 7220 636f 6e73 /div>..char cons │ │ │ +00026020: 742a 2065 6e64 203d 2073 7461 7274 202b t* end = start + │ │ │ +00026030: 2062 7566 6665 722e 7369 7a65 2829 3b0a buffer.size();. │ │ │ +00026040: 0909 6368 6172 2063 6f6e 7374 2a20 636f ..char const* co │ │ │ +00026050: 6e73 7420 6f72 6967 5f73 7461 7274 203d nst orig_start = │ │ │ +00026060: 2073 7461 7274 3b0a 0a09 0969 6620 2873 start;....if (s │ │ │ +00026070: 7461 7274 203d 3d20 656e 6429 0a09 0909 tart == end).... │ │ │ +00026080: 544f 5252 454e 545f 4641 494c 5f42 4445 TORRENT_FAIL_BDE │ │ │ +00026090: 434f 4445 2862 6465 636f 6465 5f65 7272 CODE(bdecode_err │ │ │ +000260a0: 6f72 733a 3a75 6e65 7870 6563 7465 645f ors::unexpected_ │ │ │ +000260b0: 656f 6629 3b0a 0a09 0977 6869 6c65 2028 eof);....while ( │ │ │ +000260c0: 7374 6172 7420 266c 743b 3d20 656e 6429 start <= end) │ │ │ +000260d0: 0a09 097b 0a09 0909 6966 2028 7374 6172 ...{....if (star │ │ │ +000260e0: 7420 2667 743b 3d20 656e 6429 2054 4f52 t >= end) TOR │ │ │ +000260f0: 5245 4e54 5f46 4149 4c5f 4244 4543 4f44 RENT_FAIL_BDECOD │ │ │ +00026100: 4528 6264 6563 6f64 655f 6572 726f 7273 E(bdecode_errors │ │ │ +00026110: 3a3a 756e 6578 7065 6374 6564 5f65 6f66 ::unexpected_eof │ │ │ +00026120: 293b 0a0a 0909 0969 6620 2873 7020 2667 );.....if (sp &g │ │ │ +00026130: 743b 3d20 6465 7074 685f 6c69 6d69 7429 t;= depth_limit) │ │ │ +00026140: 0a09 0909 0954 4f52 5245 4e54 5f46 4149 .....TORRENT_FAI │ │ │ +00026150: 4c5f 4244 4543 4f44 4528 6264 6563 6f64 L_BDECODE(bdecod │ │ │ +00026160: 655f 6572 726f 7273 3a3a 6465 7074 685f e_errors::depth_ │ │ │ +00026170: 6578 6365 6564 6564 293b 0a0a 0909 092d exceeded);.....- │ │ │ +00026180: 2d74 6f6b 656e 5f6c 696d 6974 3b0a 0909 -token_limit;... │ │ │ +00026190: 0969 6620 2874 6f6b 656e 5f6c 696d 6974 .if (token_limit │ │ │ +000261a0: 2026 6c74 3b20 3029 0a09 0909 0954 4f52 < 0).....TOR │ │ │ +000261b0: 5245 4e54 5f46 4149 4c5f 4244 4543 4f44 RENT_FAIL_BDECOD │ │ │ +000261c0: 4528 6264 6563 6f64 655f 6572 726f 7273 E(bdecode_errors │ │ │ +000261d0: 3a3a 6c69 6d69 745f 6578 6365 6564 6564 ::limit_exceeded │ │ │ +000261e0: 293b 0a0a 0909 092f 2f20 6c6f 6f6b 2066 );.....// look f │ │ │ +000261f0: 6f72 2061 206e 6577 2074 6f6b 656e 0a09 or a new token.. │ │ │ +00026200: 0909 6368 6172 2063 6f6e 7374 2074 203d ..char const t = │ │ │ +00026210: 202a 7374 6172 743b 0a0a 0909 0969 6e74 *start;.....int │ │ │ +00026220: 2063 6f6e 7374 2063 7572 7265 6e74 5f66 const current_f │ │ │ +00026230: 7261 6d65 203d 2073 703b 0a0a 0909 092f rame = sp;...../ │ │ │ +00026240: 2f20 6966 2077 6527 7265 2063 7572 7265 / if we're curre │ │ │ +00026250: 6e74 6c79 2070 6172 7369 6e67 2061 2064 ntly parsing a d │ │ │ +00026260: 6963 7469 6f6e 6172 792c 2061 7373 6572 ictionary, asser │ │ │ +00026270: 7420 7468 6174 0a09 0909 2f2f 2065 7665 t that....// eve │ │ │ +00026280: 7279 206f 7468 6572 206e 6f64 6520 6973 ry other node is │ │ │ +00026290: 2061 2073 7472 696e 672e 0a09 0909 6966 a string.....if │ │ │ +000262a0: 2028 6375 7272 656e 745f 6672 616d 6520 (current_frame │ │ │ +000262b0: 2667 743b 2030 0a09 0909 0926 616d 703b > 0.....& │ │ │ +000262c0: 2661 6d70 3b20 7265 742e 6d5f 746f 6b65 & ret.m_toke │ │ │ +000262d0: 6e73 5b73 7461 636b 5b63 7572 7265 6e74 ns[stack[current │ │ │ +000262e0: 5f66 7261 6d65 202d 2031 5d2e 746f 6b65 _frame - 1].toke │ │ │ +000262f0: 6e5d 2e74 7970 6520 3d3d 2062 6465 636f n].type == bdeco │ │ │ +00026300: 6465 5f74 6f6b 656e 3a3a 6469 6374 290a de_token::dict). │ │ │ +00026310: 0909 097b 0a09 0909 0969 6620 2873 7461 ...{.....if (sta │ │ │ +00026320: 636b 5b63 7572 7265 6e74 5f66 7261 6d65 ck[current_frame │ │ │ +00026330: 202d 2031 5d2e 7374 6174 6520 3d3d 2030 - 1].state == 0 │ │ │ +00026340: 290a 0909 0909 7b0a 0909 0909 092f 2f20 ).....{......// │ │ │ +00026350: 7468 6520 6375 7272 656e 7420 7061 7265 the current pare │ │ │ +00026360: 6e74 2069 7320 6120 6469 6374 2061 6e64 nt is a dict and │ │ │ +00026370: 2077 6520 6172 6520 7061 7273 696e 6720 we are parsing │ │ │ +00026380: 6120 6b65 792e 0a3c 2f70 7265 3e3c 2f74 a key..
    relevanc │ │ │ +000263c0: 6526 6e62 7370 3b32 3c2f 7464 3e3c 7464 e 2../src/udp_trac │ │ │ +00026400: 6b65 725f 636f 6e6e 6563 7469 6f6e 2e63 ker_connection.c │ │ │ +00026410: 7070 3a38 313c 2f61 3e3c 2f74 643e 3c74 pp:81support authen │ │ │ +00026430: 7469 6361 7469 6f6e 2068 6572 652e 2074 tication here. t │ │ │ +00026440: 7261 636b 6572 5f72 6571 2829 2e61 7574 racker_req().aut │ │ │ +00026450: 683c 2f74 643e 3c2f 7472 3e3c 7472 2069 h

    su │ │ │ +000264a0: 7070 6f72 7420 6175 7468 656e 7469 6361 pport authentica │ │ │ +000264b0: 7469 6f6e 2068 6572 652e 2074 7261 636b tion here. track │ │ │ +000264c0: 6572 5f72 6571 2829 2e61 7574 683c 2f68 er_req().auth

    ../src/udp │ │ │ +000264e0: 5f74 7261 636b 6572 5f63 6f6e 6e65 6374 _tracker_connect │ │ │ +000264f0: 696f 6e2e 6370 703a 3831 3c2f 6834 3e3c ion.cpp:81

    < │ │ │ +00026500: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00026510: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00026520: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00026530: 7820 2364 6464 3b22 3e09 0975 6470 5f74 x #ddd;">..udp_t │ │ │ +00026540: 7261 636b 6572 5f63 6f6e 6e65 6374 696f racker_connectio │ │ │ +00026550: 6e3a 3a6d 5f63 6f6e 6e65 6374 696f 6e5f n::m_connection_ │ │ │ +00026560: 6361 6368 653b 0a0a 0973 7464 3a3a 6d75 cache;...std::mu │ │ │ +00026570: 7465 7820 7564 705f 7472 6163 6b65 725f tex udp_tracker_ │ │ │ +00026580: 636f 6e6e 6563 7469 6f6e 3a3a 6d5f 6361 connection::m_ca │ │ │ +00026590: 6368 655f 6d75 7465 783b 0a0a 0975 6470 che_mutex;...udp │ │ │ +000265a0: 5f74 7261 636b 6572 5f63 6f6e 6e65 6374 _tracker_connect │ │ │ +000265b0: 696f 6e3a 3a75 6470 5f74 7261 636b 6572 ion::udp_tracker │ │ │ +000265c0: 5f63 6f6e 6e65 6374 696f 6e28 0a09 0969 _connection(...i │ │ │ +000265d0: 6f5f 636f 6e74 6578 7426 616d 703b 2069 o_context& i │ │ │ +000265e0: 6f73 0a09 092c 2074 7261 636b 6572 5f6d os..., tracker_m │ │ │ +000265f0: 616e 6167 6572 2661 6d70 3b20 6d61 6e0a anager& man. │ │ │ +00026600: 0909 2c20 7472 6163 6b65 725f 7265 7175 .., tracker_requ │ │ │ +00026610: 6573 7420 636f 6e73 7426 616d 703b 2072 est const& r │ │ │ +00026620: 6571 0a09 092c 2073 7464 3a3a 7765 616b eq..., std::weak │ │ │ +00026630: 5f70 7472 266c 743b 7265 7175 6573 745f _ptr<request_ │ │ │ +00026640: 6361 6c6c 6261 636b 2667 743b 2063 290a callback> c). │ │ │ +00026650: 0909 3a20 7472 6163 6b65 725f 636f 6e6e ..: tracker_conn │ │ │ +00026660: 6563 7469 6f6e 286d 616e 2c20 7265 712c ection(man, req, │ │ │ +00026670: 2069 6f73 2c20 7374 643a 3a6d 6f76 6528 ios, std::move( │ │ │ +00026680: 6329 290a 0909 2c20 6d5f 7472 616e 7361 c))..., m_transa │ │ │ +00026690: 6374 696f 6e5f 6964 2830 290a 0909 2c20 ction_id(0)..., │ │ │ +000266a0: 6d5f 6174 7465 6d70 7473 2830 290a 0909 m_attempts(0)... │ │ │ +000266b0: 2c20 6d5f 7374 6174 6528 6163 7469 6f6e , m_state(action │ │ │ +000266c0: 5f74 3a3a 6572 726f 7229 0a09 092c 206d _t::error)..., m │ │ │ +000266d0: 5f61 626f 7274 2866 616c 7365 290a 097b _abort(false)..{ │ │ │ +000266e0: 0a09 0975 7064 6174 655f 7472 616e 7361 ...update_transa │ │ │ +000266f0: 6374 696f 6e5f 6964 2829 3b0a 097d 0a0a ction_id();..}.. │ │ │ +00026700: 0976 6f69 6420 7564 705f 7472 6163 6b65 .void udp_tracke │ │ │ +00026710: 725f 636f 6e6e 6563 7469 6f6e 3a3a 7374 r_connection::st │ │ │ +00026720: 6172 7428 290a 097b 0a3c 6469 7620 7374 art()..{.
    ..std::st │ │ │ +00026760: 7269 6e67 2068 6f73 746e 616d 653b 0a3c ring hostname;.< │ │ │ +00026770: 2f64 6976 3e09 0973 7464 3a3a 7374 7269 /div>..std::stri │ │ │ +00026780: 6e67 2070 726f 746f 636f 6c3b 0a09 0969 ng protocol;...i │ │ │ +00026790: 6e74 2070 6f72 743b 0a09 0965 7272 6f72 nt port;...error │ │ │ +000267a0: 5f63 6f64 6520 6563 3b0a 0a09 0973 7464 _code ec;....std │ │ │ +000267b0: 3a3a 7469 6528 7072 6f74 6f63 6f6c 2c20 ::tie(protocol, │ │ │ +000267c0: 7374 643a 3a69 676e 6f72 652c 2068 6f73 std::ignore, hos │ │ │ +000267d0: 746e 616d 652c 2070 6f72 742c 2073 7464 tname, port, std │ │ │ +000267e0: 3a3a 6967 6e6f 7265 290a 0909 093d 2070 ::ignore)....= p │ │ │ +000267f0: 6172 7365 5f75 726c 5f63 6f6d 706f 6e65 arse_url_compone │ │ │ +00026800: 6e74 7328 7472 6163 6b65 725f 7265 7128 nts(tracker_req( │ │ │ +00026810: 292e 7572 6c2c 2065 6329 3b0a 0909 6966 ).url, ec);...if │ │ │ +00026820: 2028 706f 7274 203d 3d20 2d31 2920 706f (port == -1) po │ │ │ +00026830: 7274 203d 2070 726f 746f 636f 6c20 3d3d rt = protocol == │ │ │ +00026840: 2022 6874 7470 2220 3f20 3830 203a 2034 "http" ? 80 : 4 │ │ │ +00026850: 3433 3b0a 0a09 0969 6620 2865 6329 0a09 43;....if (ec).. │ │ │ +00026860: 097b 0a09 0909 7472 6163 6b65 725f 636f .{....tracker_co │ │ │ +00026870: 6e6e 6563 7469 6f6e 3a3a 6661 696c 2865 nnection::fail(e │ │ │ +00026880: 632c 206f 7065 7261 7469 6f6e 5f74 3a3a c, operation_t:: │ │ │ +00026890: 7061 7273 655f 6164 6472 6573 7329 3b0a parse_address);. │ │ │ +000268a0: 0909 0972 6574 7572 6e3b 0a09 097d 0a0a ...return;...}.. │ │ │ +000268b0: 0909 6175 783a 3a73 6573 7369 6f6e 5f73 ..aux::session_s │ │ │ +000268c0: 6574 7469 6e67 7320 636f 6e73 7426 616d ettings const&am │ │ │ +000268d0: 703b 2073 6574 7469 6e67 7320 3d20 6d5f p; settings = m_ │ │ │ +000268e0: 6d61 6e2e 7365 7474 696e 6773 2829 3b0a man.settings();. │ │ │ +000268f0: 0a09 0969 6e74 2063 6f6e 7374 2070 726f ...int const pro │ │ │ +00026900: 7879 5f74 7970 6520 3d20 7365 7474 696e xy_type = settin │ │ │ +00026910: 6773 2e67 6574 5f69 6e74 2873 6574 7469 gs.get_int(setti │ │ │ +00026920: 6e67 735f 7061 636b 3a3a 7072 6f78 795f ngs_pack::proxy_ │ │ │ +00026930: 7479 7065 293b 0a0a 0909 6966 2028 7365 type);....if (se │ │ │ +00026940: 7474 696e 6773 2e67 6574 5f62 6f6f 6c28 ttings.get_bool( │ │ │ +00026950: 7365 7474 696e 6773 5f70 6163 6b3a 3a70 settings_pack::p │ │ │ +00026960: 726f 7879 5f68 6f73 746e 616d 6573 290a roxy_hostnames). │ │ │ +00026970: 0909 0926 616d 703b 2661 6d70 3b20 2870 ...&& (p │ │ │ +00026980: 726f 7879 5f74 7970 6520 3d3d 2073 6574 roxy_type == set │ │ │ +00026990: 7469 6e67 735f 7061 636b 3a3a 736f 636b tings_pack::sock │ │ │ +000269a0: 7335 0a09 0909 097c 7c20 7072 6f78 795f s5.....|| proxy_ │ │ │ +000269b0: 7479 7065 203d 3d20 7365 7474 696e 6773 type == settings │ │ │ +000269c0: 5f70 6163 6b3a 3a73 6f63 6b73 355f 7077 _pack::socks5_pw │ │ │ +000269d0: 2929 0a09 097b 0a09 0909 6d5f 686f 7374 ))...{....m_host │ │ │ +000269e0: 6e61 6d65 203d 2068 6f73 746e 616d 653b name = hostname; │ │ │ +000269f0: 0a09 0909 6d5f 7461 7267 6574 2e70 6f72 ....m_target.por │ │ │ +00026a00: 7428 7374 643a 3a75 696e 7431 365f 7428 t(std::uint16_t( │ │ │ +00026a10: 706f 7274 2929 3b0a 0909 0973 7461 7274 port));....start │ │ │ +00026a20: 5f61 6e6e 6f75 6e63 6528 293b 0a09 097d _announce();...} │ │ │ +00026a30: 0a09 0965 6c73 650a 0909 7b0a 0909 0975 ...else...{....u │ │ │ +00026a40: 7369 6e67 206e 616d 6573 7061 6365 2073 sing namespace s │ │ │ +00026a50: 7464 3a3a 706c 6163 6568 6f6c 6465 7273 td::placeholders │ │ │ +00026a60: 3b0a 0909 0941 4444 5f4f 5554 5354 414e ;....ADD_OUTSTAN │ │ │ +00026a70: 4449 4e47 5f41 5359 4e43 2822 7564 705f DING_ASYNC("udp_ │ │ │ +00026a80: 7472 6163 6b65 725f 636f 6e6e 6563 7469 tracker_connecti │ │ │ +00026a90: 6f6e 3a3a 6e61 6d65 5f6c 6f6f 6b75 7022 on::name_lookup" │ │ │ 00026aa0: 293b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f );.
    │ │ │ 00026ad0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ 00026ae0: 7370 3b32 3c2f 7464 3e3c 7464 3e3c 6120 sp;2../ │ │ │ @@ -10014,1245 +10014,1245 @@ │ │ │ 000271d0: 7265 3e3c 2f74 643e 3c2f 7472 3e3c 7472 re>re │ │ │ 00027200: 6c65 7661 6e63 6526 6e62 7370 3b32 3c2f levance 2../src/ka │ │ │ -00027240: 6465 6d6c 6961 2f72 6f75 7469 6e67 5f74 demlia/routing_t │ │ │ -00027250: 6162 6c65 2e63 7070 3a33 3035 3c2f 613e able.cpp:305 │ │ │ -00027260: 3c2f 7464 3e3c 7464 3e75 7365 2074 6865 use the │ │ │ -00027270: 206e 6f6e 2064 6570 7265 6361 7465 6420 non deprecated │ │ │ -00027280: 6675 6e63 7469 6f6e 2069 6e73 7465 6164 function instead │ │ │ -00027290: 206f 6620 7468 6973 206f 6e65 3c2f 7464 of this one

    use the │ │ │ -000272f0: 206e 6f6e 2064 6570 7265 6361 7465 6420 non deprecated │ │ │ -00027300: 6675 6e63 7469 6f6e 2069 6e73 7465 6164 function instead │ │ │ -00027310: 206f 6620 7468 6973 206f 6e65 3c2f 6832 of this one

    ../src/kade │ │ │ -00027330: 6d6c 6961 2f72 6f75 7469 6e67 5f74 6162 mlia/routing_tab │ │ │ -00027340: 6c65 2e63 7070 3a33 3035 3c2f 6834 3e3c le.cpp:305

    < │ │ │ -00027350: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00027360: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00027370: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00027380: 7820 2364 6464 3b22 3e09 7374 6174 6963 x #ddd;">.static │ │ │ -00027390: 2063 6f6e 7374 2061 7578 3a3a 6172 7261 const aux::arra │ │ │ -000273a0: 7926 6c74 3b69 6e74 2c20 3426 6774 3b20 y<int, 4> │ │ │ -000273b0: 7369 7a65 5f65 7863 6570 7469 6f6e 737b size_exceptions{ │ │ │ -000273c0: 7b7b 3136 2c20 382c 2034 2c20 327d 7d7d {{16, 8, 4, 2}}} │ │ │ -000273d0: 3b0a 0969 6620 2862 7563 6b65 7420 266c ;..if (bucket &l │ │ │ -000273e0: 743b 2073 697a 655f 6578 6365 7074 696f t; size_exceptio │ │ │ -000273f0: 6e73 2e65 6e64 5f69 6e64 6578 2829 290a ns.end_index()). │ │ │ -00027400: 0909 7265 7475 726e 206d 5f62 7563 6b65 ..return m_bucke │ │ │ -00027410: 745f 7369 7a65 202a 2073 697a 655f 6578 t_size * size_ex │ │ │ -00027420: 6365 7074 696f 6e73 5b62 7563 6b65 745d ceptions[bucket] │ │ │ -00027430: 3b0a 0972 6574 7572 6e20 6d5f 6275 636b ;..return m_buck │ │ │ -00027440: 6574 5f73 697a 653b 0a7d 0a0a 766f 6964 et_size;.}..void │ │ │ -00027450: 2072 6f75 7469 6e67 5f74 6162 6c65 3a3a routing_table:: │ │ │ -00027460: 7374 6174 7573 2873 7464 3a3a 7665 6374 status(std::vect │ │ │ -00027470: 6f72 266c 743b 6468 745f 726f 7574 696e or<dht_routin │ │ │ -00027480: 675f 6275 636b 6574 2667 743b 2661 6d70 g_bucket>& │ │ │ -00027490: 3b20 7329 2063 6f6e 7374 0a7b 0a09 6966 ; s) const.{..if │ │ │ -000274a0: 2028 732e 7369 7a65 2829 2026 6774 3b20 (s.size() > │ │ │ -000274b0: 6d5f 6275 636b 6574 732e 7369 7a65 2829 m_buckets.size() │ │ │ -000274c0: 2920 7265 7475 726e 3b0a 0973 2e63 6c65 ) return;..s.cle │ │ │ -000274d0: 6172 2829 3b0a 0966 6f72 2028 6175 746f ar();..for (auto │ │ │ -000274e0: 2063 6f6e 7374 2661 6d70 3b20 6920 3a20 const& i : │ │ │ -000274f0: 6d5f 6275 636b 6574 7329 0a09 7b0a 0909 m_buckets)..{... │ │ │ -00027500: 6468 745f 726f 7574 696e 675f 6275 636b dht_routing_buck │ │ │ -00027510: 6574 2062 3b0a 0909 622e 6e75 6d5f 6e6f et b;...b.num_no │ │ │ -00027520: 6465 7320 3d20 696e 7428 692e 6c69 7665 des = int(i.live │ │ │ -00027530: 5f6e 6f64 6573 2e73 697a 6528 2929 3b0a _nodes.size());. │ │ │ -00027540: 0909 622e 6e75 6d5f 7265 706c 6163 656d ..b.num_replacem │ │ │ -00027550: 656e 7473 203d 2069 6e74 2869 2e72 6570 ents = int(i.rep │ │ │ -00027560: 6c61 6365 6d65 6e74 732e 7369 7a65 2829 lacements.size() │ │ │ -00027570: 293b 0a09 0973 2e70 7573 685f 6261 636b );...s.push_back │ │ │ -00027580: 2862 293b 0a09 7d0a 7d0a 0a23 6966 2054 (b);..}.}..#if T │ │ │ -00027590: 4f52 5245 4e54 5f41 4249 5f56 4552 5349 ORRENT_ABI_VERSI │ │ │ -000275a0: 4f4e 203d 3d20 310a 3c64 6976 2073 7479 ON == 1.
    void routi │ │ │ -000275e0: 6e67 5f74 6162 6c65 3a3a 7374 6174 7573 ng_table::status │ │ │ -000275f0: 2873 6573 7369 6f6e 5f73 7461 7475 7326 (session_status& │ │ │ -00027600: 616d 703b 2073 2920 636f 6e73 740a 3c2f amp; s) const.{..int dht_n │ │ │ -00027620: 6f64 6573 3b0a 0969 6e74 2064 6874 5f6e odes;..int dht_n │ │ │ -00027630: 6f64 655f 6361 6368 653b 0a09 696e 7420 ode_cache;..int │ │ │ -00027640: 6967 6e6f 7265 3b0a 0973 7464 3a3a 7469 ignore;..std::ti │ │ │ -00027650: 6528 6468 745f 6e6f 6465 732c 2064 6874 e(dht_nodes, dht │ │ │ -00027660: 5f6e 6f64 655f 6361 6368 652c 2069 676e _node_cache, ign │ │ │ -00027670: 6f72 6529 203d 2073 697a 6528 293b 0a09 ore) = size();.. │ │ │ -00027680: 732e 6468 745f 6e6f 6465 7320 2b3d 2064 s.dht_nodes += d │ │ │ -00027690: 6874 5f6e 6f64 6573 3b0a 0973 2e64 6874 ht_nodes;..s.dht │ │ │ -000276a0: 5f6e 6f64 655f 6361 6368 6520 2b3d 2064 _node_cache += d │ │ │ -000276b0: 6874 5f6e 6f64 655f 6361 6368 653b 0a3c ht_node_cache;.< │ │ │ -000276c0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -000276d0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -000276e0: 6f75 6e64 3a20 2363 6663 223e 3c74 643e ound: #cfc"> │ │ │ -000276f0: 7265 6c65 7661 6e63 6526 6e62 7370 3b32 relevance 2 │ │ │ -00027700: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src/ │ │ │ -00027730: 6b61 6465 6d6c 6961 2f72 6f75 7469 6e67 kademlia/routing │ │ │ -00027740: 5f74 6162 6c65 2e63 7070 3a39 3430 3c2f _table.cpp:940move │ │ │ -00027760: 7468 6520 6c6f 7765 7374 2070 7269 6f72 the lowest prior │ │ │ -00027770: 6974 7920 6e6f 6465 7320 746f 2074 6865 ity nodes to the │ │ │ -00027780: 2072 6570 6c61 6365 6d65 6e74 2062 7563 replacement buc │ │ │ -00027790: 6b65 743c 2f74 643e 3c2f 7472 3e3c 7472 ket

    │ │ │ -000277e0: 6d6f 7665 2074 6865 206c 6f77 6573 7420 move the lowest │ │ │ -000277f0: 7072 696f 7269 7479 206e 6f64 6573 2074 priority nodes t │ │ │ -00027800: 6f20 7468 6520 7265 706c 6163 656d 656e o the replacemen │ │ │ -00027810: 7420 6275 636b 6574 3c2f 6832 3e3c 6834 t bucket

    ../src/kademlia │ │ │ -00027830: 2f72 6f75 7469 6e67 5f74 6162 6c65 2e63 /routing_table.c │ │ │ -00027840: 7070 3a39 3430 3c2f 6834 3e3c 7072 6520 pp:940

    .bucket_t&a
    │ │ │ -00027890: 6d70 3b20 7262 203d 206d 5f62 7563 6b65  mp; rb = m_bucke
    │ │ │ -000278a0: 7473 5b62 7563 6b65 745f 696e 6465 785d  ts[bucket_index]
    │ │ │ -000278b0: 2e72 6570 6c61 6365 6d65 6e74 733b 0a0a  .replacements;..
    │ │ │ -000278c0: 092f 2f20 6d6f 7665 2061 6e79 206e 6f64  .// move any nod
    │ │ │ -000278d0: 6520 7768 6f73 6520 2831 3630 202d 2064  e whose (160 - d
    │ │ │ -000278e0: 6973 7461 6e63 655f 6578 7028 6d5f 6964  istance_exp(m_id
    │ │ │ -000278f0: 2c20 6964 2929 2026 6774 3b3d 2028 6920  , id)) >= (i 
    │ │ │ -00027900: 2d20 6d5f 6275 636b 6574 732e 6265 6769  - m_buckets.begi
    │ │ │ -00027910: 6e28 2929 0a09 2f2f 2074 6f20 7468 6520  n())..// to the 
    │ │ │ -00027920: 6e65 7720 6275 636b 6574 0a09 696e 7420  new bucket..int 
    │ │ │ -00027930: 636f 6e73 7420 6e65 775f 6275 636b 6574  const new_bucket
    │ │ │ -00027940: 5f73 697a 6520 3d20 6275 636b 6574 5f6c  _size = bucket_l
    │ │ │ -00027950: 696d 6974 2862 7563 6b65 745f 696e 6465  imit(bucket_inde
    │ │ │ -00027960: 7820 2b20 3129 3b0a 0966 6f72 2028 6175  x + 1);..for (au
    │ │ │ -00027970: 746f 206a 203d 2062 2e62 6567 696e 2829  to j = b.begin()
    │ │ │ -00027980: 3b20 6a20 213d 2062 2e65 6e64 2829 3b29  ; j != b.end();)
    │ │ │ -00027990: 0a09 7b0a 0909 696e 7420 636f 6e73 7420  ..{...int const 
    │ │ │ -000279a0: 6420 3d20 6469 7374 616e 6365 5f65 7870  d = distance_exp
    │ │ │ -000279b0: 286d 5f69 642c 206a 2d26 6774 3b69 6429  (m_id, j->id)
    │ │ │ -000279c0: 3b0a 0909 6966 2028 6420 2667 743b 3d20  ;...if (d >= 
    │ │ │ -000279d0: 3135 3920 2d20 6275 636b 6574 5f69 6e64  159 - bucket_ind
    │ │ │ -000279e0: 6578 290a 0909 7b0a 0909 092b 2b6a 3b0a  ex)...{....++j;.
    │ │ │ -000279f0: 0909 0963 6f6e 7469 6e75 653b 0a09 097d  ...continue;...}
    │ │ │ -00027a00: 0a09 092f 2f20 7468 6973 2065 6e74 7279  ...// this entry
    │ │ │ -00027a10: 2062 656c 6f6e 6773 2069 6e20 7468 6520   belongs in the 
    │ │ │ -00027a20: 6e65 7720 6275 636b 6574 0a09 096e 6577  new bucket...new
    │ │ │ -00027a30: 5f62 7563 6b65 742e 7075 7368 5f62 6163  _bucket.push_bac
    │ │ │ -00027a40: 6b28 2a6a 293b 0a09 096a 203d 2062 2e65  k(*j);...j = b.e
    │ │ │ -00027a50: 7261 7365 286a 293b 0a09 7d0a 0a09 6966  rase(j);..}...if
    │ │ │ -00027a60: 2028 696e 7428 622e 7369 7a65 2829 2920   (int(b.size()) 
    │ │ │ -00027a70: 2667 743b 2062 7563 6b65 745f 7369 7a65  > bucket_size
    │ │ │ -00027a80: 5f6c 696d 6974 290a 097b 0a3c 6469 7620  _limit)..{.
    ..for ( │ │ │ -00027ac0: 6175 746f 2069 203d 2062 2e62 6567 696e auto i = b.begin │ │ │ -00027ad0: 2829 202b 2062 7563 6b65 745f 7369 7a65 () + bucket_size │ │ │ -00027ae0: 5f6c 696d 6974 0a3c 2f64 6976 3e09 0909 _limit.
    ... │ │ │ -00027af0: 2c20 656e 6428 622e 656e 6428 2929 3b20 , end(b.end()); │ │ │ -00027b00: 6920 213d 2065 6e64 3b20 2b2b 6929 0a09 i != end; ++i).. │ │ │ -00027b10: 097b 0a09 0909 7262 2e70 7573 685f 6261 .{....rb.push_ba │ │ │ -00027b20: 636b 282a 6929 3b0a 0909 7d0a 0a09 0962 ck(*i);...}....b │ │ │ -00027b30: 2e72 6573 697a 6528 6275 636b 6574 5f73 .resize(bucket_s │ │ │ -00027b40: 697a 655f 6c69 6d69 7429 3b0a 097d 0a0a ize_limit);..}.. │ │ │ -00027b50: 092f 2f20 7370 6c69 7420 7468 6520 7265 .// split the re │ │ │ -00027b60: 706c 6163 656d 656e 7420 6275 636b 6574 placement bucket │ │ │ -00027b70: 2061 7320 7765 6c6c 2e20 4966 2074 6865 as well. If the │ │ │ -00027b80: 206c 6976 6520 6275 636b 6574 0a09 2f2f live bucket..// │ │ │ -00027b90: 2069 7320 6e6f 7420 6675 6c6c 2061 6e79 is not full any │ │ │ -00027ba0: 6d6f 7265 2c20 616c 736f 206d 6f76 6520 more, also move │ │ │ -00027bb0: 7468 6520 7265 706c 6163 656d 656e 7420 the replacement │ │ │ -00027bc0: 656e 7472 6965 730a 092f 2f20 696e 746f entries..// into │ │ │ -00027bd0: 2074 6865 206d 6169 6e20 6275 636b 6574 the main bucket │ │ │ -00027be0: 0a09 666f 7220 2861 7574 6f20 6a20 3d20 ..for (auto j = │ │ │ -00027bf0: 7262 2e62 6567 696e 2829 3b20 6a20 213d rb.begin(); j != │ │ │ -00027c00: 2072 622e 656e 6428 293b 290a 097b 0a09 rb.end();)..{.. │ │ │ -00027c10: 0969 6620 2864 6973 7461 6e63 655f 6578 .if (distance_ex │ │ │ -00027c20: 7028 6d5f 6964 2c20 6a2d 2667 743b 6964 p(m_id, j->id │ │ │ -00027c30: 2920 2667 743b 3d20 3135 3920 2d20 6275 ) >= 159 - bu │ │ │ -00027c40: 636b 6574 5f69 6e64 6578 290a 0909 7b0a cket_index)...{. │ │ │ -00027c50: 0909 0969 6620 2821 6a2d 2667 743b 7069 ...if (!j->pi │ │ │ -00027c60: 6e67 6564 2829 207c 7c20 696e 7428 622e nged() || int(b. │ │ │ -00027c70: 7369 7a65 2829 2920 2667 743b 3d20 6275 size()) >= bu │ │ │ -00027c80: 636b 6574 5f73 697a 655f 6c69 6d69 7429 cket_size_limit) │ │ │ -00027c90: 0a09 0909 7b0a 0909 0909 2b2b 6a3b 0a09 ....{.....++j;.. │ │ │ -00027ca0: 0909 0963 6f6e 7469 6e75 653b 0a09 0909 ...continue;.... │ │ │ -00027cb0: 7d0a 0909 0962 2e70 7573 685f 6261 636b }....b.push_back │ │ │ -00027cc0: 282a 6a29 3b0a 0909 7d0a 0909 656c 7365 (*j);...}...else │ │ │ -00027cd0: 0a09 097b 0a09 0909 2f2f 2074 6869 7320 ...{....// this │ │ │ -00027ce0: 656e 7472 7920 6265 6c6f 6e67 7320 696e entry belongs in │ │ │ -00027cf0: 2074 6865 206e 6577 2062 7563 6b65 740a the new bucket. │ │ │ -00027d00: 0909 0969 6620 286a 2d26 6774 3b70 696e ...if (j->pin │ │ │ -00027d10: 6765 6428 2920 2661 6d70 3b26 616d 703b ged() && │ │ │ -00027d20: 2069 6e74 286e 6577 5f62 7563 6b65 742e int(new_bucket. │ │ │ -00027d30: 7369 7a65 2829 2920 266c 743b 206e 6577 size()) < new │ │ │ -00027d40: 5f62 7563 6b65 745f 7369 7a65 290a 0909 _bucket_size)... │ │ │ -00027d50: 0909 6e65 775f 6275 636b 6574 2e70 7573 ..new_bucket.pus │ │ │ -00027d60: 685f 6261 636b 282a 6a29 3b0a 0909 0965 h_back(*j);....e │ │ │ -00027d70: 6c73 650a 0909 0909 6e65 775f 7265 706c lse.....new_repl │ │ │ -00027d80: 6163 656d 656e 745f 6275 636b 6574 2e70 acement_bucket.p │ │ │ -00027d90: 7573 685f 6261 636b 282a 6a29 3b0a 0909 ush_back(*j);... │ │ │ -00027da0: 7d0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 }.
    < │ │ │ -00027dd0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00027de0: 703b 323c 2f74 643e 3c74 643e 3c61 2068 p;2
    ../s │ │ │ -00027e10: 7263 2f6b 6164 656d 6c69 612f 6e6f 6465 rc/kademlia/node │ │ │ -00027e20: 2e63 7070 3a36 3834 3c2f 613e 3c2f 7464 .cpp:684it would be │ │ │ -00027e40: 206e 6963 6520 746f 2068 6176 6520 6120 nice to have a │ │ │ -00027e50: 6269 6173 2074 6f77 6172 6473 206e 6f64 bias towards nod │ │ │ -00027e60: 652d 6964 2070 7265 6669 7865 7320 7468 e-id prefixes th │ │ │ -00027e70: 6174 2061 7265 206d 6973 7369 6e67 2069 at are missing i │ │ │ -00027e80: 6e20 7468 6520 6275 636b 6574 3c2f 7464 n the bucket

    it woul │ │ │ -00027ee0: 6420 6265 206e 6963 6520 746f 2068 6176 d be nice to hav │ │ │ -00027ef0: 6520 6120 6269 6173 2074 6f77 6172 6473 e a bias towards │ │ │ -00027f00: 206e 6f64 652d 6964 2070 7265 6669 7865 node-id prefixe │ │ │ -00027f10: 7320 7468 6174 0a61 7265 206d 6973 7369 s that.are missi │ │ │ -00027f20: 6e67 2069 6e20 7468 6520 6275 636b 6574 ng in the bucket │ │ │ -00027f30: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -00027f40: 6b61 6465 6d6c 6961 2f6e 6f64 652e 6370 kademlia/node.cp │ │ │ -00027f50: 703a 3638 343c 2f68 343e 3c70 7265 2073 p:684

    .node_entry 
    │ │ │ -00027fa0: 636f 6e73 742a 206e 6520 3d20 6d5f 7461  const* ne = m_ta
    │ │ │ -00027fb0: 626c 652e 6e65 7874 5f72 6566 7265 7368  ble.next_refresh
    │ │ │ -00027fc0: 2829 3b0a 0969 6620 286e 6520 3d3d 206e  ();..if (ne == n
    │ │ │ -00027fd0: 756c 6c70 7472 2920 7265 7475 726e 3b0a  ullptr) return;.
    │ │ │ -00027fe0: 0a09 2f2f 2074 6869 7320 7368 6f75 6c64  ..// this should
    │ │ │ -00027ff0: 6e27 7420 6861 7070 656e 0a09 544f 5252  n't happen..TORR
    │ │ │ -00028000: 454e 545f 4153 5345 5254 286d 5f69 6420  ENT_ASSERT(m_id 
    │ │ │ -00028010: 213d 206e 652d 2667 743b 6964 293b 0a09  != ne->id);..
    │ │ │ -00028020: 6966 2028 6e65 2d26 6774 3b69 6420 3d3d  if (ne->id ==
    │ │ │ -00028030: 206d 5f69 6429 2072 6574 7572 6e3b 0a0a   m_id) return;..
    │ │ │ -00028040: 0969 6e74 2063 6f6e 7374 2062 7563 6b65  .int const bucke
    │ │ │ -00028050: 7420 3d20 3135 3920 2d20 6469 7374 616e  t = 159 - distan
    │ │ │ -00028060: 6365 5f65 7870 286d 5f69 642c 206e 652d  ce_exp(m_id, ne-
    │ │ │ -00028070: 2667 743b 6964 293b 0a09 544f 5252 454e  >id);..TORREN
    │ │ │ -00028080: 545f 4153 5345 5254 2862 7563 6b65 7420  T_ASSERT(bucket 
    │ │ │ -00028090: 266c 743b 2031 3630 293b 0a09 7365 6e64  < 160);..send
    │ │ │ -000280a0: 5f73 696e 676c 655f 7265 6672 6573 6828  _single_refresh(
    │ │ │ -000280b0: 6e65 2d26 6774 3b65 7028 292c 2062 7563  ne->ep(), buc
    │ │ │ -000280c0: 6b65 742c 206e 652d 2667 743b 6964 293b  ket, ne->id);
    │ │ │ -000280d0: 0a7d 0a0a 766f 6964 206e 6f64 653a 3a73  .}..void node::s
    │ │ │ -000280e0: 656e 645f 7369 6e67 6c65 5f72 6566 7265  end_single_refre
    │ │ │ -000280f0: 7368 2875 6470 3a3a 656e 6470 6f69 6e74  sh(udp::endpoint
    │ │ │ -00028100: 2063 6f6e 7374 2661 6d70 3b20 6570 2c20   const& ep, 
    │ │ │ -00028110: 696e 7420 636f 6e73 7420 6275 636b 6574  int const bucket
    │ │ │ -00028120: 0a09 2c20 6e6f 6465 5f69 6420 636f 6e73  .., node_id cons
    │ │ │ -00028130: 7426 616d 703b 2069 6429 0a7b 0a09 544f  t& id).{..TO
    │ │ │ -00028140: 5252 454e 545f 4153 5345 5254 2869 6420  RRENT_ASSERT(id 
    │ │ │ -00028150: 213d 206d 5f69 6429 3b0a 0954 4f52 5245  != m_id);..TORRE
    │ │ │ -00028160: 4e54 5f41 5353 4552 5428 6275 636b 6574  NT_ASSERT(bucket
    │ │ │ -00028170: 2026 6774 3b3d 2030 293b 0a09 544f 5252   >= 0);..TORR
    │ │ │ -00028180: 454e 545f 4153 5345 5254 2862 7563 6b65  ENT_ASSERT(bucke
    │ │ │ -00028190: 7420 266c 743b 3d20 3135 3929 3b0a 0a09  t <= 159);...
    │ │ │ -000281a0: 2f2f 2067 656e 6572 6174 6520 6120 7261  // generate a ra
    │ │ │ -000281b0: 6e64 6f6d 206e 6f64 655f 6964 2077 6974  ndom node_id wit
    │ │ │ -000281c0: 6869 6e20 7468 6520 6769 7665 6e20 6275  hin the given bu
    │ │ │ -000281d0: 636b 6574 0a3c 6469 7620 7374 796c 653d  cket.
    .node_id mask │ │ │ -00028210: 203d 2067 656e 6572 6174 655f 7072 6566 = generate_pref │ │ │ -00028220: 6978 5f6d 6173 6b28 6275 636b 6574 202b ix_mask(bucket + │ │ │ -00028230: 2031 293b 0a3c 2f64 6976 3e09 6e6f 6465 1);.
    .node │ │ │ -00028240: 5f69 6420 7461 7267 6574 203d 2067 656e _id target = gen │ │ │ -00028250: 6572 6174 655f 7365 6372 6574 5f69 6428 erate_secret_id( │ │ │ -00028260: 2920 2661 6d70 3b20 7e6d 6173 6b3b 0a09 ) & ~mask;.. │ │ │ -00028270: 7461 7267 6574 207c 3d20 6d5f 6964 2026 target |= m_id & │ │ │ -00028280: 616d 703b 206d 6173 6b3b 0a0a 092f 2f20 amp; mask;...// │ │ │ -00028290: 6372 6561 7465 2061 2064 756d 6d79 2074 create a dummy t │ │ │ -000282a0: 7261 7665 7273 616c 5f61 6c67 6f72 6974 raversal_algorit │ │ │ -000282b0: 686d 0a09 6175 746f 2061 6c67 6f20 3d20 hm..auto algo = │ │ │ -000282c0: 7374 643a 3a6d 616b 655f 7368 6172 6564 std::make_shared │ │ │ -000282d0: 266c 743b 7472 6176 6572 7361 6c5f 616c <traversal_al │ │ │ -000282e0: 676f 7269 7468 6d26 6774 3b28 2a74 6869 gorithm>(*thi │ │ │ -000282f0: 732c 206e 6f64 655f 6964 2829 293b 0a09 s, node_id());.. │ │ │ -00028300: 6175 746f 206f 203d 206d 5f72 7063 2e61 auto o = m_rpc.a │ │ │ -00028310: 6c6c 6f63 6174 655f 6f62 7365 7276 6572 llocate_observer │ │ │ -00028320: 266c 743b 7069 6e67 5f6f 6273 6572 7665 <ping_observe │ │ │ -00028330: 7226 6774 3b28 7374 643a 3a6d 6f76 6528 r>(std::move( │ │ │ -00028340: 616c 676f 292c 2065 702c 2069 6429 3b0a algo), ep, id);. │ │ │ -00028350: 0969 6620 2821 6f29 2072 6574 7572 6e3b .if (!o) return; │ │ │ -00028360: 0a23 6966 2054 4f52 5245 4e54 5f55 5345 .#if TORRENT_USE │ │ │ -00028370: 5f41 5353 4552 5453 0a09 6f2d 2667 743b _ASSERTS..o-> │ │ │ -00028380: 6d5f 696e 5f63 6f6e 7374 7275 6374 6f72 m_in_constructor │ │ │ -00028390: 203d 2066 616c 7365 3b0a 2365 6e64 6966 = false;.#endif │ │ │ -000283a0: 0a09 656e 7472 7920 653b 0a09 655b 2279 ..entry e;..e["y │ │ │ -000283b0: 225d 203d 2022 7122 3b0a 0a09 6966 2028 "] = "q";...if ( │ │ │ -000283c0: 6d5f 7461 626c 652e 6973 5f66 756c 6c28 m_table.is_full( │ │ │ -000283d0: 6275 636b 6574 2929 0a09 7b0a 0909 2f2f bucket))..{...// │ │ │ -000283e0: 2063 7572 7265 6e74 2062 7563 6b65 7420 current bucket │ │ │ -000283f0: 6973 2066 756c 6c2c 206a 7573 7420 7069 is full, just pi │ │ │ -00028400: 6e67 2069 742e 0a09 0965 5b22 7122 5d20 ng it....e["q"] │ │ │ -00028410: 3d20 2270 696e 6722 3b0a 0909 6d5f 636f = "ping";...m_co │ │ │ -00028420: 756e 7465 7273 2e69 6e63 5f73 7461 7473 unters.inc_stats │ │ │ -00028430: 5f63 6f75 6e74 6572 2863 6f75 6e74 6572 _counter(counter │ │ │ -00028440: 733a 3a64 6874 5f70 696e 675f 6f75 7429 s::dht_ping_out) │ │ │ -00028450: 3b0a 097d 0a09 656c 7365 0a09 7b0a 0909 ;..}..else..{... │ │ │ -00028460: 2f2f 2075 7365 2067 6574 5f70 6565 7273 // use get_peers │ │ │ -00028470: 2069 6e73 7465 6164 206f 6620 6669 6e64 instead of find │ │ │ -00028480: 5f6e 6f64 652e 2057 6527 6c6c 2067 6574 _node. We'll get │ │ │ -00028490: 206e 6f64 6573 2069 6e20 7468 6520 7265 nodes in the re │ │ │ -000284a0: 7370 6f6e 7365 0a09 092f 2f20 6569 7468 sponse...// eith │ │ │ -000284b0: 6572 2077 6179 2e0a 0909 655b 2271 225d er way....e["q"] │ │ │ -000284c0: 203d 2022 6765 745f 7065 6572 7322 3b0a = "get_peers";. │ │ │ -000284d0: 0909 655b 2261 225d 5b22 696e 666f 5f68 ..e["a"]["info_h │ │ │ -000284e0: 6173 6822 5d20 3d20 7461 7267 6574 2e74 ash"] = target.t │ │ │ -000284f0: 6f5f 7374 7269 6e67 2829 3b0a 0909 6d5f o_string();...m_ │ │ │ -00028500: 636f 756e 7465 7273 2e69 6e63 5f73 7461 counters.inc_sta │ │ │ -00028510: 7473 5f63 6f75 6e74 6572 2863 6f75 6e74 ts_counter(count │ │ │ -00028520: 6572 733a 3a64 6874 5f67 6574 5f70 6565 ers::dht_get_pee │ │ │ -00028530: 7273 5f6f 7574 293b 0a09 7d0a 0a09 6f2d rs_out);..}...o- │ │ │ -00028540: 2667 743b 666c 6167 7320 7c3d 206f 6273 >flags |= obs │ │ │ -00028550: 6572 7665 723a 3a66 6c61 675f 7175 6572 erver::flag_quer │ │ │ -00028560: 6965 643b 0a09 6d5f 7270 632e 696e 766f ied;..m_rpc.invo │ │ │ -00028570: 6b65 2865 2c20 6570 2c20 6f29 3b0a 3c2f ke(e, ep, o);.r │ │ │ -000285b0: 656c 6576 616e 6365 266e 6273 703b 323c elevance 2< │ │ │ -000285c0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/k │ │ │ -000285f0: 6164 656d 6c69 612f 6e6f 6465 2e63 7070 ademlia/node.cpp │ │ │ -00028600: 3a37 3537 3c2f 613e 3c2f 7464 3e3c 7464 :757use the non dep │ │ │ -00028620: 7265 6361 7465 6420 6675 6e63 7469 6f6e recated function │ │ │ -00028630: 2069 6e73 7465 6164 206f 6620 7468 6973 instead of this │ │ │ -00028640: 206f 6e65 3c2f 7464 3e3c 2f74 723e 3c74 one

    use the non dep │ │ │ -000286a0: 7265 6361 7465 6420 6675 6e63 7469 6f6e recated function │ │ │ -000286b0: 2069 6e73 7465 6164 206f 6620 7468 6973 instead of this │ │ │ -000286c0: 206f 6e65 3c2f 6832 3e3c 6834 3e2e 2e2f one

    ../ │ │ │ -000286d0: 7372 632f 6b61 6465 6d6c 6961 2f6e 6f64 src/kademlia/nod │ │ │ -000286e0: 652e 6370 703a 3735 373c 2f68 343e 3c70 e.cpp:757

    .ret.loc │ │ │ -00028730: 616c 5f65 6e64 706f 696e 7420 3d20 6d61 al_endpoint = ma │ │ │ -00028740: 6b65 5f75 6470 286d 5f73 6f63 6b2e 6765 ke_udp(m_sock.ge │ │ │ -00028750: 745f 6c6f 6361 6c5f 656e 6470 6f69 6e74 t_local_endpoint │ │ │ -00028760: 2829 293b 0a09 6d5f 7461 626c 652e 7374 ());..m_table.st │ │ │ -00028770: 6174 7573 2872 6574 2e74 6162 6c65 293b atus(ret.table); │ │ │ -00028780: 0a0a 0966 6f72 2028 6175 746f 2063 6f6e ...for (auto con │ │ │ -00028790: 7374 2661 6d70 3b20 7220 3a20 6d5f 7275 st& r : m_ru │ │ │ -000287a0: 6e6e 696e 675f 7265 7175 6573 7473 290a nning_requests). │ │ │ -000287b0: 097b 0a09 0972 6574 2e72 6571 7565 7374 .{...ret.request │ │ │ -000287c0: 732e 656d 706c 6163 655f 6261 636b 2829 s.emplace_back() │ │ │ -000287d0: 3b0a 0909 6468 745f 6c6f 6f6b 7570 2661 ;...dht_lookup&a │ │ │ -000287e0: 6d70 3b20 6c6f 6f6b 7570 203d 2072 6574 mp; lookup = ret │ │ │ -000287f0: 2e72 6571 7565 7374 732e 6261 636b 2829 .requests.back() │ │ │ -00028800: 3b0a 0909 722d 2667 743b 7374 6174 7573 ;...r->status │ │ │ -00028810: 286c 6f6f 6b75 7029 3b0a 097d 0a09 7265 (lookup);..}..re │ │ │ -00028820: 7475 726e 2072 6574 3b0a 7d0a 0a73 7464 turn ret;.}..std │ │ │ -00028830: 3a3a 7475 706c 6526 6c74 3b69 6e74 2c20 ::tuple<int, │ │ │ -00028840: 696e 742c 2069 6e74 2667 743b 206e 6f64 int, int> nod │ │ │ -00028850: 653a 3a67 6574 5f73 7461 7473 5f63 6f75 e::get_stats_cou │ │ │ -00028860: 6e74 6572 7328 2920 636f 6e73 740a 7b0a nters() const.{. │ │ │ -00028870: 0969 6e74 206e 6f64 6573 2c20 7265 706c .int nodes, repl │ │ │ -00028880: 6163 656d 656e 7473 3b0a 0973 7464 3a3a acements;..std:: │ │ │ -00028890: 7469 6528 6e6f 6465 732c 2072 6570 6c61 tie(nodes, repla │ │ │ -000288a0: 6365 6d65 6e74 732c 2073 7464 3a3a 6967 cements, std::ig │ │ │ -000288b0: 6e6f 7265 2920 3d20 7369 7a65 2829 3b0a nore) = size();. │ │ │ -000288c0: 0972 6574 7572 6e20 7374 643a 3a6d 616b .return std::mak │ │ │ -000288d0: 655f 7475 706c 6528 6e6f 6465 732c 2072 e_tuple(nodes, r │ │ │ -000288e0: 6570 6c61 6365 6d65 6e74 732c 206d 5f72 eplacements, m_r │ │ │ -000288f0: 7063 2e6e 756d 5f61 6c6c 6f63 6174 6564 pc.num_allocated │ │ │ -00028900: 5f6f 6273 6572 7665 7273 2829 293b 0a7d _observers());.} │ │ │ -00028910: 0a0a 2369 6620 544f 5252 454e 545f 4142 ..#if TORRENT_AB │ │ │ -00028920: 495f 5645 5253 494f 4e20 3d3d 2031 0a3c I_VERSION == 1.< │ │ │ -00028930: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ -00028940: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ -00028950: 7769 6474 683d 2231 3030 2522 3e76 6f69 width="100%">voi │ │ │ -00028960: 6420 6e6f 6465 3a3a 7374 6174 7573 2873 d node::status(s │ │ │ -00028970: 6573 7369 6f6e 5f73 7461 7475 7326 616d ession_status&am │ │ │ -00028980: 703b 2073 290a 3c2f 6469 763e 7b0a 0973 p; s).

    {..s │ │ │ -00028990: 7464 3a3a 6c6f 636b 5f67 7561 7264 266c td::lock_guard&l │ │ │ -000289a0: 743b 7374 643a 3a6d 7574 6578 2667 743b t;std::mutex> │ │ │ -000289b0: 206c 286d 5f6d 7574 6578 293b 0a0a 096d l(m_mutex);...m │ │ │ -000289c0: 5f74 6162 6c65 2e73 7461 7475 7328 7329 _table.status(s) │ │ │ -000289d0: 3b0a 0973 2e64 6874 5f74 6f74 616c 5f61 ;..s.dht_total_a │ │ │ -000289e0: 6c6c 6f63 6174 696f 6e73 202b 3d20 6d5f llocations += m_ │ │ │ -000289f0: 7270 632e 6e75 6d5f 616c 6c6f 6361 7465 rpc.num_allocate │ │ │ -00028a00: 645f 6f62 7365 7276 6572 7328 293b 0a09 d_observers();.. │ │ │ -00028a10: 666f 7220 2861 7574 6f26 616d 703b 2072 for (auto& r │ │ │ -00028a20: 203a 206d 5f72 756e 6e69 6e67 5f72 6571 : m_running_req │ │ │ -00028a30: 7565 7374 7329 0a09 7b0a 0909 732e 6163 uests)..{...s.ac │ │ │ -00028a40: 7469 7665 5f72 6571 7565 7374 732e 656d tive_requests.em │ │ │ -00028a50: 706c 6163 655f 6261 636b 2829 3b0a 0909 place_back();... │ │ │ -00028a60: 6468 745f 6c6f 6f6b 7570 2661 6d70 3b20 dht_lookup& │ │ │ -00028a70: 6c6f 6f6b 7570 203d 2073 2e61 6374 6976 lookup = s.activ │ │ │ -00028a80: 655f 7265 7175 6573 7473 2e62 6163 6b28 e_requests.back( │ │ │ -00028a90: 293b 0a09 0972 2d26 6774 3b73 7461 7475 );...r->statu │ │ │ -00028aa0: 7328 6c6f 6f6b 7570 293b 0a09 7d0a 7d0a s(lookup);..}.}. │ │ │ -00028ab0: 2365 6e64 6966 0a0a 626f 6f6c 206e 6f64 #endif..bool nod │ │ │ -00028ac0: 653a 3a6c 6f6f 6b75 705f 7065 6572 7328 e::lookup_peers( │ │ │ -00028ad0: 7368 6131 5f68 6173 6820 636f 6e73 7426 sha1_hash const& │ │ │ -00028ae0: 616d 703b 2069 6e66 6f5f 6861 7368 2c20 amp; info_hash, │ │ │ -00028af0: 656e 7472 7926 616d 703b 2072 6570 6c79 entry& reply │ │ │ -00028b00: 0a09 2c20 626f 6f6c 206e 6f73 6565 642c .., bool noseed, │ │ │ -00028b10: 2062 6f6f 6c20 7363 7261 7065 2c20 6164 bool scrape, ad │ │ │ -00028b20: 6472 6573 7320 636f 6e73 7426 616d 703b dress const& │ │ │ -00028b30: 2072 6571 7565 7374 6572 2920 636f 6e73 requester) cons │ │ │ -00028b40: 740a 7b0a 0969 6620 286d 5f6f 6273 6572 t.{..if (m_obser │ │ │ -00028b50: 7665 7229 0a09 096d 5f6f 6273 6572 7665 ver)...m_observe │ │ │ -00028b60: 722d 2667 743b 6765 745f 7065 6572 7328 r->get_peers( │ │ │ -00028b70: 696e 666f 5f68 6173 6829 3b0a 0a09 7265 info_hash);...re │ │ │ -00028b80: 7475 726e 206d 5f73 746f 7261 6765 2e67 turn m_storage.g │ │ │ -00028b90: 6574 5f70 6565 7273 2869 6e66 6f5f 6861 et_peers(info_ha │ │ │ -00028ba0: 7368 2c20 6e6f 7365 6564 2c20 7363 7261 sh, noseed, scra │ │ │ -00028bb0: 7065 2c20 7265 7175 6573 7465 722c 2072 pe, requester, r │ │ │ -00028bc0: 6570 6c79 293b 0a7d 0a0a 656e 7472 7920 eply);.}..entry │ │ │ -00028bd0: 7772 6974 655f 6e6f 6465 735f 656e 7472 write_nodes_entr │ │ │ -00028be0: 7928 7374 643a 3a76 6563 746f 7226 6c74 y(std::vector< │ │ │ -00028bf0: 3b6e 6f64 655f 656e 7472 7926 6774 3b20 ;node_entry> │ │ │ -00028c00: 636f 6e73 7426 616d 703b 206e 6f64 6573 const& nodes │ │ │ -00028c10: 290a 7b0a 0965 6e74 7279 2072 3b0a 0973 ).{..entry r;..s │ │ │ -00028c20: 7464 3a3a 6261 636b 5f69 6e73 6572 745f td::back_insert_ │ │ │ -00028c30: 6974 6572 6174 6f72 266c 743b 7374 643a iterator<std: │ │ │ -00028c40: 3a73 7472 696e 6726 6774 3b20 6f75 7428 :string> out( │ │ │ -00028c50: 722e 7374 7269 6e67 2829 293b 0a09 666f r.string());..fo │ │ │ -00028c60: 7220 2861 7574 6f20 636f 6e73 7426 616d r (auto const&am │ │ │ -00028c70: 703b 206e 203a 206e 6f64 6573 290a 097b p; n : nodes)..{ │ │ │ -00028c80: 0a09 0973 7464 3a3a 636f 7079 286e 2e69 ...std::copy(n.i │ │ │ -00028c90: 642e 6265 6769 6e28 292c 206e 2e69 642e d.begin(), n.id. │ │ │ -00028ca0: 656e 6428 292c 206f 7574 293b 0a3c 2f70 end(), out);.

    re │ │ │ -00028ce0: 6c65 7661 6e63 6526 6e62 7370 3b32 3c2f levance 2../src/ka │ │ │ -00028d20: 6465 6d6c 6961 2f64 6874 5f73 746f 7261 demlia/dht_stora │ │ │ -00028d30: 6765 2e63 7070 3a38 373c 2f61 3e3c 2f74 ge.cpp:87make this │ │ │ -00028d50: 636f 6e66 6967 7572 6162 6c65 2069 6e20 configurable in │ │ │ -00028d60: 6468 745f 7365 7474 696e 6773 3c2f 7464 dht_settings

    make th │ │ │ -00028dc0: 6973 2063 6f6e 6669 6775 7261 626c 6520 is configurable │ │ │ -00028dd0: 696e 2064 6874 5f73 6574 7469 6e67 733c in dht_settings< │ │ │ -00028de0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f6b /h2>

    ../src/k │ │ │ -00028df0: 6164 656d 6c69 612f 6468 745f 7374 6f72 ademlia/dht_stor │ │ │ -00028e00: 6167 652e 6370 703a 3837 3c2f 6834 3e3c age.cpp:87

    < │ │ │ -00028e10: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00028e20: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00028e30: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00028e40: 7820 2364 6464 3b22 3e09 0974 6370 3a3a x #ddd;">..tcp:: │ │ │ -00028e50: 656e 6470 6f69 6e74 2061 6464 723b 0a09 endpoint addr;.. │ │ │ -00028e60: 0962 6f6f 6c20 7365 6564 203d 2030 3b0a .bool seed = 0;. │ │ │ -00028e70: 097d 3b0a 0a09 2f2f 2069 6e74 6572 6e61 .};...// interna │ │ │ -00028e80: 6c0a 0962 6f6f 6c20 6f70 6572 6174 6f72 l..bool operator │ │ │ -00028e90: 266c 743b 2870 6565 725f 656e 7472 7920 <(peer_entry │ │ │ -00028ea0: 636f 6e73 7426 616d 703b 206c 6873 2c20 const& lhs, │ │ │ -00028eb0: 7065 6572 5f65 6e74 7279 2063 6f6e 7374 peer_entry const │ │ │ -00028ec0: 2661 6d70 3b20 7268 7329 0a09 7b0a 0909 & rhs)..{... │ │ │ -00028ed0: 7265 7475 726e 206c 6873 2e61 6464 722e return lhs.addr. │ │ │ -00028ee0: 6164 6472 6573 7328 2920 3d3d 2072 6873 address() == rhs │ │ │ -00028ef0: 2e61 6464 722e 6164 6472 6573 7328 290a .addr.address(). │ │ │ -00028f00: 0909 093f 206c 6873 2e61 6464 722e 706f ...? lhs.addr.po │ │ │ -00028f10: 7274 2829 2026 6c74 3b20 7268 732e 6164 rt() < rhs.ad │ │ │ -00028f20: 6472 2e70 6f72 7428 290a 0909 093a 206c dr.port()....: l │ │ │ -00028f30: 6873 2e61 6464 722e 6164 6472 6573 7328 hs.addr.address( │ │ │ -00028f40: 2920 266c 743b 2072 6873 2e61 6464 722e ) < rhs.addr. │ │ │ -00028f50: 6164 6472 6573 7328 293b 0a09 7d0a 0a09 address();..}... │ │ │ -00028f60: 2f2f 2074 6869 7320 6973 2061 2067 726f // this is a gro │ │ │ -00028f70: 7570 2e20 4974 2063 6f6e 7461 696e 7320 up. It contains │ │ │ -00028f80: 6120 7365 7420 6f66 2067 726f 7570 206d a set of group m │ │ │ -00028f90: 656d 6265 7273 0a09 7374 7275 6374 2074 embers..struct t │ │ │ -00028fa0: 6f72 7265 6e74 5f65 6e74 7279 0a09 7b0a orrent_entry..{. │ │ │ -00028fb0: 0909 7374 643a 3a73 7472 696e 6720 6e61 ..std::string na │ │ │ -00028fc0: 6d65 3b0a 0909 7374 643a 3a76 6563 746f me;...std::vecto │ │ │ -00028fd0: 7226 6c74 3b70 6565 725f 656e 7472 7926 r<peer_entry& │ │ │ -00028fe0: 6774 3b20 7065 6572 7334 3b0a 0909 7374 gt; peers4;...st │ │ │ -00028ff0: 643a 3a76 6563 746f 7226 6c74 3b70 6565 d::vector<pee │ │ │ -00029000: 725f 656e 7472 7926 6774 3b20 7065 6572 r_entry> peer │ │ │ -00029010: 7336 3b0a 097d 3b0a 0a3c 6469 7620 7374 s6;..};..
    .constexp │ │ │ -00029050: 7220 7469 6d65 5f64 7572 6174 696f 6e20 r time_duration │ │ │ -00029060: 616e 6e6f 756e 6365 5f69 6e74 6572 7661 announce_interva │ │ │ -00029070: 6c20 3d20 6d69 6e75 7465 7328 3330 293b l = minutes(30); │ │ │ -00029080: 0a3c 2f64 6976 3e0a 0973 7472 7563 7420 .
    ..struct │ │ │ -00029090: 6468 745f 696d 6d75 7461 626c 655f 6974 dht_immutable_it │ │ │ -000290a0: 656d 0a09 7b0a 0909 2f2f 2074 6865 2061 em..{...// the a │ │ │ -000290b0: 6374 7561 6c20 7661 6c75 650a 0909 7374 ctual value...st │ │ │ -000290c0: 643a 3a75 6e69 7175 655f 7074 7226 6c74 d::unique_ptr< │ │ │ -000290d0: 3b63 6861 725b 5d26 6774 3b20 7661 6c75 ;char[]> valu │ │ │ -000290e0: 653b 0a09 092f 2f20 7468 6973 2063 6f75 e;...// this cou │ │ │ -000290f0: 6e74 7320 7468 6520 6e75 6d62 6572 206f nts the number o │ │ │ -00029100: 6620 4950 7320 7765 2068 6176 6520 7365 f IPs we have se │ │ │ -00029110: 656e 0a09 092f 2f20 616e 6e6f 756e 6369 en...// announci │ │ │ -00029120: 6e67 2074 6869 7320 6974 656d 2c20 7468 ng this item, th │ │ │ -00029130: 6973 2069 7320 7573 6564 2074 6f20 6465 is is used to de │ │ │ -00029140: 7465 726d 696e 650a 0909 2f2f 2070 6f70 termine...// pop │ │ │ -00029150: 756c 6172 6974 7920 6966 2077 6520 7265 ularity if we re │ │ │ -00029160: 6163 6820 7468 6520 6c69 6d69 7420 6f66 ach the limit of │ │ │ -00029170: 2069 7465 6d73 2074 6f20 7374 6f72 650a items to store. │ │ │ -00029180: 0909 626c 6f6f 6d5f 6669 6c74 6572 266c ..bloom_filter&l │ │ │ -00029190: 743b 3132 3826 6774 3b20 6970 733b 0a09 t;128> ips;.. │ │ │ -000291a0: 092f 2f20 7468 6520 6c61 7374 2074 696d .// the last tim │ │ │ -000291b0: 6520 7765 2068 6561 7264 2061 626f 7574 e we heard about │ │ │ -000291c0: 2074 6869 7320 6974 656d 0a09 092f 2f20 this item...// │ │ │ -000291d0: 7468 6520 636f 7272 6563 7420 696e 7465 the correct inte │ │ │ -000291e0: 7270 7265 7461 7469 6f6e 206f 6620 7468 rpretation of th │ │ │ -000291f0: 6973 2066 6965 6c64 0a09 092f 2f20 7265 is field...// re │ │ │ -00029200: 7175 6972 6573 2061 2074 696d 6520 7265 quires a time re │ │ │ -00029210: 6665 7265 6e63 650a 0909 7469 6d65 5f70 ference...time_p │ │ │ -00029220: 6f69 6e74 206c 6173 745f 7365 656e 3b0a oint last_seen;. │ │ │ -00029230: 0909 2f2f 206e 756d 6265 7220 6f66 2049 ..// number of I │ │ │ -00029240: 5073 2069 6e20 7468 6520 626c 6f6f 6d20 Ps in the bloom │ │ │ -00029250: 6669 6c74 6572 0a09 0969 6e74 206e 756d filter...int num │ │ │ -00029260: 5f61 6e6e 6f75 6e63 6572 7320 3d20 303b _announcers = 0; │ │ │ -00029270: 0a09 092f 2f20 7369 7a65 206f 6620 6d61 ...// size of ma │ │ │ -00029280: 6c6c 6f63 6564 2073 7061 6365 2070 6f69 lloced space poi │ │ │ -00029290: 6e74 6564 2074 6f20 6279 2076 616c 7565 nted to by value │ │ │ -000292a0: 0a09 0969 6e74 2073 697a 6520 3d20 303b ...int size = 0; │ │ │ -000292b0: 0a09 7d3b 0a0a 0973 7472 7563 7420 6468 ..};...struct dh │ │ │ -000292c0: 745f 6d75 7461 626c 655f 6974 656d 203a t_mutable_item : │ │ │ -000292d0: 2064 6874 5f69 6d6d 7574 6162 6c65 5f69 dht_immutable_i │ │ │ -000292e0: 7465 6d0a 097b 0a09 0973 6967 6e61 7475 tem..{...signatu │ │ │ -000292f0: 7265 2073 6967 7b7d 3b0a 0909 7365 7175 re sig{};...sequ │ │ │ -00029300: 656e 6365 5f6e 756d 6265 7220 7365 717b ence_number seq{ │ │ │ -00029310: 7d3b 0a09 0970 7562 6c69 635f 6b65 7920 };...public_key │ │ │ -00029320: 6b65 797b 7d3b 0a09 0973 7464 3a3a 7374 key{};...std::st │ │ │ -00029330: 7269 6e67 2073 616c 743b 0a09 7d3b 0a0a ring salt;..};.. │ │ │ -00029340: 0976 6f69 6420 7365 745f 7661 6c75 6528 .void set_value( │ │ │ -00029350: 6468 745f 696d 6d75 7461 626c 655f 6974 dht_immutable_it │ │ │ -00029360: 656d 2661 6d70 3b20 6974 656d 2c20 7370 em& item, sp │ │ │ -00029370: 616e 266c 743b 6368 6172 2063 6f6e 7374 an<char const │ │ │ -00029380: 2667 743b 2062 7566 290a 097b 0a09 0969 > buf)..{...i │ │ │ -00029390: 6e74 2063 6f6e 7374 2073 697a 6520 3d20 nt const size = │ │ │ -000293a0: 696e 7428 6275 662e 7369 7a65 2829 293b int(buf.size()); │ │ │ +00027240: 6465 6d6c 6961 2f64 6874 5f73 746f 7261 demlia/dht_stora │ │ │ +00027250: 6765 2e63 7070 3a38 373c 2f61 3e3c 2f74 ge.cpp:87make this │ │ │ +00027270: 636f 6e66 6967 7572 6162 6c65 2069 6e20 configurable in │ │ │ +00027280: 6468 745f 7365 7474 696e 6773 3c2f 7464 dht_settings

    make th │ │ │ +000272e0: 6973 2063 6f6e 6669 6775 7261 626c 6520 is configurable │ │ │ +000272f0: 696e 2064 6874 5f73 6574 7469 6e67 733c in dht_settings< │ │ │ +00027300: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f6b /h2>

    ../src/k │ │ │ +00027310: 6164 656d 6c69 612f 6468 745f 7374 6f72 ademlia/dht_stor │ │ │ +00027320: 6167 652e 6370 703a 3837 3c2f 6834 3e3c age.cpp:87

    < │ │ │ +00027330: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00027340: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00027350: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00027360: 7820 2364 6464 3b22 3e09 0974 6370 3a3a x #ddd;">..tcp:: │ │ │ +00027370: 656e 6470 6f69 6e74 2061 6464 723b 0a09 endpoint addr;.. │ │ │ +00027380: 0962 6f6f 6c20 7365 6564 203d 2030 3b0a .bool seed = 0;. │ │ │ +00027390: 097d 3b0a 0a09 2f2f 2069 6e74 6572 6e61 .};...// interna │ │ │ +000273a0: 6c0a 0962 6f6f 6c20 6f70 6572 6174 6f72 l..bool operator │ │ │ +000273b0: 266c 743b 2870 6565 725f 656e 7472 7920 <(peer_entry │ │ │ +000273c0: 636f 6e73 7426 616d 703b 206c 6873 2c20 const& lhs, │ │ │ +000273d0: 7065 6572 5f65 6e74 7279 2063 6f6e 7374 peer_entry const │ │ │ +000273e0: 2661 6d70 3b20 7268 7329 0a09 7b0a 0909 & rhs)..{... │ │ │ +000273f0: 7265 7475 726e 206c 6873 2e61 6464 722e return lhs.addr. │ │ │ +00027400: 6164 6472 6573 7328 2920 3d3d 2072 6873 address() == rhs │ │ │ +00027410: 2e61 6464 722e 6164 6472 6573 7328 290a .addr.address(). │ │ │ +00027420: 0909 093f 206c 6873 2e61 6464 722e 706f ...? lhs.addr.po │ │ │ +00027430: 7274 2829 2026 6c74 3b20 7268 732e 6164 rt() < rhs.ad │ │ │ +00027440: 6472 2e70 6f72 7428 290a 0909 093a 206c dr.port()....: l │ │ │ +00027450: 6873 2e61 6464 722e 6164 6472 6573 7328 hs.addr.address( │ │ │ +00027460: 2920 266c 743b 2072 6873 2e61 6464 722e ) < rhs.addr. │ │ │ +00027470: 6164 6472 6573 7328 293b 0a09 7d0a 0a09 address();..}... │ │ │ +00027480: 2f2f 2074 6869 7320 6973 2061 2067 726f // this is a gro │ │ │ +00027490: 7570 2e20 4974 2063 6f6e 7461 696e 7320 up. It contains │ │ │ +000274a0: 6120 7365 7420 6f66 2067 726f 7570 206d a set of group m │ │ │ +000274b0: 656d 6265 7273 0a09 7374 7275 6374 2074 embers..struct t │ │ │ +000274c0: 6f72 7265 6e74 5f65 6e74 7279 0a09 7b0a orrent_entry..{. │ │ │ +000274d0: 0909 7374 643a 3a73 7472 696e 6720 6e61 ..std::string na │ │ │ +000274e0: 6d65 3b0a 0909 7374 643a 3a76 6563 746f me;...std::vecto │ │ │ +000274f0: 7226 6c74 3b70 6565 725f 656e 7472 7926 r<peer_entry& │ │ │ +00027500: 6774 3b20 7065 6572 7334 3b0a 0909 7374 gt; peers4;...st │ │ │ +00027510: 643a 3a76 6563 746f 7226 6c74 3b70 6565 d::vector<pee │ │ │ +00027520: 725f 656e 7472 7926 6774 3b20 7065 6572 r_entry> peer │ │ │ +00027530: 7336 3b0a 097d 3b0a 0a3c 6469 7620 7374 s6;..};..
    .constexp │ │ │ +00027570: 7220 7469 6d65 5f64 7572 6174 696f 6e20 r time_duration │ │ │ +00027580: 616e 6e6f 756e 6365 5f69 6e74 6572 7661 announce_interva │ │ │ +00027590: 6c20 3d20 6d69 6e75 7465 7328 3330 293b l = minutes(30); │ │ │ +000275a0: 0a3c 2f64 6976 3e0a 0973 7472 7563 7420 .
    ..struct │ │ │ +000275b0: 6468 745f 696d 6d75 7461 626c 655f 6974 dht_immutable_it │ │ │ +000275c0: 656d 0a09 7b0a 0909 2f2f 2074 6865 2061 em..{...// the a │ │ │ +000275d0: 6374 7561 6c20 7661 6c75 650a 0909 7374 ctual value...st │ │ │ +000275e0: 643a 3a75 6e69 7175 655f 7074 7226 6c74 d::unique_ptr< │ │ │ +000275f0: 3b63 6861 725b 5d26 6774 3b20 7661 6c75 ;char[]> valu │ │ │ +00027600: 653b 0a09 092f 2f20 7468 6973 2063 6f75 e;...// this cou │ │ │ +00027610: 6e74 7320 7468 6520 6e75 6d62 6572 206f nts the number o │ │ │ +00027620: 6620 4950 7320 7765 2068 6176 6520 7365 f IPs we have se │ │ │ +00027630: 656e 0a09 092f 2f20 616e 6e6f 756e 6369 en...// announci │ │ │ +00027640: 6e67 2074 6869 7320 6974 656d 2c20 7468 ng this item, th │ │ │ +00027650: 6973 2069 7320 7573 6564 2074 6f20 6465 is is used to de │ │ │ +00027660: 7465 726d 696e 650a 0909 2f2f 2070 6f70 termine...// pop │ │ │ +00027670: 756c 6172 6974 7920 6966 2077 6520 7265 ularity if we re │ │ │ +00027680: 6163 6820 7468 6520 6c69 6d69 7420 6f66 ach the limit of │ │ │ +00027690: 2069 7465 6d73 2074 6f20 7374 6f72 650a items to store. │ │ │ +000276a0: 0909 626c 6f6f 6d5f 6669 6c74 6572 266c ..bloom_filter&l │ │ │ +000276b0: 743b 3132 3826 6774 3b20 6970 733b 0a09 t;128> ips;.. │ │ │ +000276c0: 092f 2f20 7468 6520 6c61 7374 2074 696d .// the last tim │ │ │ +000276d0: 6520 7765 2068 6561 7264 2061 626f 7574 e we heard about │ │ │ +000276e0: 2074 6869 7320 6974 656d 0a09 092f 2f20 this item...// │ │ │ +000276f0: 7468 6520 636f 7272 6563 7420 696e 7465 the correct inte │ │ │ +00027700: 7270 7265 7461 7469 6f6e 206f 6620 7468 rpretation of th │ │ │ +00027710: 6973 2066 6965 6c64 0a09 092f 2f20 7265 is field...// re │ │ │ +00027720: 7175 6972 6573 2061 2074 696d 6520 7265 quires a time re │ │ │ +00027730: 6665 7265 6e63 650a 0909 7469 6d65 5f70 ference...time_p │ │ │ +00027740: 6f69 6e74 206c 6173 745f 7365 656e 3b0a oint last_seen;. │ │ │ +00027750: 0909 2f2f 206e 756d 6265 7220 6f66 2049 ..// number of I │ │ │ +00027760: 5073 2069 6e20 7468 6520 626c 6f6f 6d20 Ps in the bloom │ │ │ +00027770: 6669 6c74 6572 0a09 0969 6e74 206e 756d filter...int num │ │ │ +00027780: 5f61 6e6e 6f75 6e63 6572 7320 3d20 303b _announcers = 0; │ │ │ +00027790: 0a09 092f 2f20 7369 7a65 206f 6620 6d61 ...// size of ma │ │ │ +000277a0: 6c6c 6f63 6564 2073 7061 6365 2070 6f69 lloced space poi │ │ │ +000277b0: 6e74 6564 2074 6f20 6279 2076 616c 7565 nted to by value │ │ │ +000277c0: 0a09 0969 6e74 2073 697a 6520 3d20 303b ...int size = 0; │ │ │ +000277d0: 0a09 7d3b 0a0a 0973 7472 7563 7420 6468 ..};...struct dh │ │ │ +000277e0: 745f 6d75 7461 626c 655f 6974 656d 203a t_mutable_item : │ │ │ +000277f0: 2064 6874 5f69 6d6d 7574 6162 6c65 5f69 dht_immutable_i │ │ │ +00027800: 7465 6d0a 097b 0a09 0973 6967 6e61 7475 tem..{...signatu │ │ │ +00027810: 7265 2073 6967 7b7d 3b0a 0909 7365 7175 re sig{};...sequ │ │ │ +00027820: 656e 6365 5f6e 756d 6265 7220 7365 717b ence_number seq{ │ │ │ +00027830: 7d3b 0a09 0970 7562 6c69 635f 6b65 7920 };...public_key │ │ │ +00027840: 6b65 797b 7d3b 0a09 0973 7464 3a3a 7374 key{};...std::st │ │ │ +00027850: 7269 6e67 2073 616c 743b 0a09 7d3b 0a0a ring salt;..};.. │ │ │ +00027860: 0976 6f69 6420 7365 745f 7661 6c75 6528 .void set_value( │ │ │ +00027870: 6468 745f 696d 6d75 7461 626c 655f 6974 dht_immutable_it │ │ │ +00027880: 656d 2661 6d70 3b20 6974 656d 2c20 7370 em& item, sp │ │ │ +00027890: 616e 266c 743b 6368 6172 2063 6f6e 7374 an<char const │ │ │ +000278a0: 2667 743b 2062 7566 290a 097b 0a09 0969 > buf)..{...i │ │ │ +000278b0: 6e74 2063 6f6e 7374 2073 697a 6520 3d20 nt const size = │ │ │ +000278c0: 696e 7428 6275 662e 7369 7a65 2829 293b int(buf.size()); │ │ │ +000278d0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +00027910: 3b32 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;2../sr │ │ │ +00027940: 632f 6b61 6465 6d6c 6961 2f72 6f75 7469 c/kademlia/routi │ │ │ +00027950: 6e67 5f74 6162 6c65 2e63 7070 3a33 3035 ng_table.cpp:305 │ │ │ +00027960: 3c2f 613e 3c2f 7464 3e3c 7464 3e75 7365 use │ │ │ +00027970: 2074 6865 206e 6f6e 2064 6570 7265 6361 the non depreca │ │ │ +00027980: 7465 6420 6675 6e63 7469 6f6e 2069 6e73 ted function ins │ │ │ +00027990: 7465 6164 206f 6620 7468 6973 206f 6e65 tead of this one │ │ │ +000279a0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    use │ │ │ +000279f0: 2074 6865 206e 6f6e 2064 6570 7265 6361 the non depreca │ │ │ +00027a00: 7465 6420 6675 6e63 7469 6f6e 2069 6e73 ted function ins │ │ │ +00027a10: 7465 6164 206f 6620 7468 6973 206f 6e65 tead of this one │ │ │ +00027a20: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +00027a30: 6b61 6465 6d6c 6961 2f72 6f75 7469 6e67 kademlia/routing │ │ │ +00027a40: 5f74 6162 6c65 2e63 7070 3a33 3035 3c2f _table.cpp:305
    .st
    │ │ │ +00027a90: 6174 6963 2063 6f6e 7374 2061 7578 3a3a  atic const aux::
    │ │ │ +00027aa0: 6172 7261 7926 6c74 3b69 6e74 2c20 3426  array<int, 4&
    │ │ │ +00027ab0: 6774 3b20 7369 7a65 5f65 7863 6570 7469  gt; size_excepti
    │ │ │ +00027ac0: 6f6e 737b 7b7b 3136 2c20 382c 2034 2c20  ons{{{16, 8, 4, 
    │ │ │ +00027ad0: 327d 7d7d 3b0a 0969 6620 2862 7563 6b65  2}}};..if (bucke
    │ │ │ +00027ae0: 7420 266c 743b 2073 697a 655f 6578 6365  t < size_exce
    │ │ │ +00027af0: 7074 696f 6e73 2e65 6e64 5f69 6e64 6578  ptions.end_index
    │ │ │ +00027b00: 2829 290a 0909 7265 7475 726e 206d 5f62  ())...return m_b
    │ │ │ +00027b10: 7563 6b65 745f 7369 7a65 202a 2073 697a  ucket_size * siz
    │ │ │ +00027b20: 655f 6578 6365 7074 696f 6e73 5b62 7563  e_exceptions[buc
    │ │ │ +00027b30: 6b65 745d 3b0a 0972 6574 7572 6e20 6d5f  ket];..return m_
    │ │ │ +00027b40: 6275 636b 6574 5f73 697a 653b 0a7d 0a0a  bucket_size;.}..
    │ │ │ +00027b50: 766f 6964 2072 6f75 7469 6e67 5f74 6162  void routing_tab
    │ │ │ +00027b60: 6c65 3a3a 7374 6174 7573 2873 7464 3a3a  le::status(std::
    │ │ │ +00027b70: 7665 6374 6f72 266c 743b 6468 745f 726f  vector<dht_ro
    │ │ │ +00027b80: 7574 696e 675f 6275 636b 6574 2667 743b  uting_bucket>
    │ │ │ +00027b90: 2661 6d70 3b20 7329 2063 6f6e 7374 0a7b  & s) const.{
    │ │ │ +00027ba0: 0a09 6966 2028 732e 7369 7a65 2829 2026  ..if (s.size() &
    │ │ │ +00027bb0: 6774 3b20 6d5f 6275 636b 6574 732e 7369  gt; m_buckets.si
    │ │ │ +00027bc0: 7a65 2829 2920 7265 7475 726e 3b0a 0973  ze()) return;..s
    │ │ │ +00027bd0: 2e63 6c65 6172 2829 3b0a 0966 6f72 2028  .clear();..for (
    │ │ │ +00027be0: 6175 746f 2063 6f6e 7374 2661 6d70 3b20  auto const& 
    │ │ │ +00027bf0: 6920 3a20 6d5f 6275 636b 6574 7329 0a09  i : m_buckets)..
    │ │ │ +00027c00: 7b0a 0909 6468 745f 726f 7574 696e 675f  {...dht_routing_
    │ │ │ +00027c10: 6275 636b 6574 2062 3b0a 0909 622e 6e75  bucket b;...b.nu
    │ │ │ +00027c20: 6d5f 6e6f 6465 7320 3d20 696e 7428 692e  m_nodes = int(i.
    │ │ │ +00027c30: 6c69 7665 5f6e 6f64 6573 2e73 697a 6528  live_nodes.size(
    │ │ │ +00027c40: 2929 3b0a 0909 622e 6e75 6d5f 7265 706c  ));...b.num_repl
    │ │ │ +00027c50: 6163 656d 656e 7473 203d 2069 6e74 2869  acements = int(i
    │ │ │ +00027c60: 2e72 6570 6c61 6365 6d65 6e74 732e 7369  .replacements.si
    │ │ │ +00027c70: 7a65 2829 293b 0a09 0973 2e70 7573 685f  ze());...s.push_
    │ │ │ +00027c80: 6261 636b 2862 293b 0a09 7d0a 7d0a 0a23  back(b);..}.}..#
    │ │ │ +00027c90: 6966 2054 4f52 5245 4e54 5f41 4249 5f56  if TORRENT_ABI_V
    │ │ │ +00027ca0: 4552 5349 4f4e 203d 3d20 310a 3c64 6976  ERSION == 1.
    void r │ │ │ +00027ce0: 6f75 7469 6e67 5f74 6162 6c65 3a3a 7374 outing_table::st │ │ │ +00027cf0: 6174 7573 2873 6573 7369 6f6e 5f73 7461 atus(session_sta │ │ │ +00027d00: 7475 7326 616d 703b 2073 2920 636f 6e73 tus& s) cons │ │ │ +00027d10: 740a 3c2f 6469 763e 7b0a 0969 6e74 2064 t.
    {..int d │ │ │ +00027d20: 6874 5f6e 6f64 6573 3b0a 0969 6e74 2064 ht_nodes;..int d │ │ │ +00027d30: 6874 5f6e 6f64 655f 6361 6368 653b 0a09 ht_node_cache;.. │ │ │ +00027d40: 696e 7420 6967 6e6f 7265 3b0a 0973 7464 int ignore;..std │ │ │ +00027d50: 3a3a 7469 6528 6468 745f 6e6f 6465 732c ::tie(dht_nodes, │ │ │ +00027d60: 2064 6874 5f6e 6f64 655f 6361 6368 652c dht_node_cache, │ │ │ +00027d70: 2069 676e 6f72 6529 203d 2073 697a 6528 ignore) = size( │ │ │ +00027d80: 293b 0a09 732e 6468 745f 6e6f 6465 7320 );..s.dht_nodes │ │ │ +00027d90: 2b3d 2064 6874 5f6e 6f64 6573 3b0a 0973 += dht_nodes;..s │ │ │ +00027da0: 2e64 6874 5f6e 6f64 655f 6361 6368 6520 .dht_node_cache │ │ │ +00027db0: 2b3d 2064 6874 5f6e 6f64 655f 6361 6368 += dht_node_cach │ │ │ +00027dc0: 653b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f e;.
    │ │ │ +00027df0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00027e00: 7370 3b32 3c2f 7464 3e3c 7464 3e3c 6120 sp;2../ │ │ │ +00027e30: 7372 632f 6b61 6465 6d6c 6961 2f72 6f75 src/kademlia/rou │ │ │ +00027e40: 7469 6e67 5f74 6162 6c65 2e63 7070 3a39 ting_table.cpp:9 │ │ │ +00027e50: 3430 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 40m │ │ │ +00027e60: 6f76 6520 7468 6520 6c6f 7765 7374 2070 ove the lowest p │ │ │ +00027e70: 7269 6f72 6974 7920 6e6f 6465 7320 746f riority nodes to │ │ │ +00027e80: 2074 6865 2072 6570 6c61 6365 6d65 6e74 the replacement │ │ │ +00027e90: 2062 7563 6b65 743c 2f74 643e 3c2f 7472 bucket │ │ │ +00027ed0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00027ee0: 3c68 323e 6d6f 7665 2074 6865 206c 6f77

    move the low │ │ │ +00027ef0: 6573 7420 7072 696f 7269 7479 206e 6f64 est priority nod │ │ │ +00027f00: 6573 2074 6f20 7468 6520 7265 706c 6163 es to the replac │ │ │ +00027f10: 656d 656e 7420 6275 636b 6574 3c2f 6832 ement bucket

    ../src/kade │ │ │ +00027f30: 6d6c 6961 2f72 6f75 7469 6e67 5f74 6162 mlia/routing_tab │ │ │ +00027f40: 6c65 2e63 7070 3a39 3430 3c2f 6834 3e3c le.cpp:940

    < │ │ │ +00027f50: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00027f60: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00027f70: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00027f80: 7820 2364 6464 3b22 3e09 6275 636b 6574 x #ddd;">.bucket │ │ │ +00027f90: 5f74 2661 6d70 3b20 7262 203d 206d 5f62 _t& rb = m_b │ │ │ +00027fa0: 7563 6b65 7473 5b62 7563 6b65 745f 696e uckets[bucket_in │ │ │ +00027fb0: 6465 785d 2e72 6570 6c61 6365 6d65 6e74 dex].replacement │ │ │ +00027fc0: 733b 0a0a 092f 2f20 6d6f 7665 2061 6e79 s;...// move any │ │ │ +00027fd0: 206e 6f64 6520 7768 6f73 6520 2831 3630 node whose (160 │ │ │ +00027fe0: 202d 2064 6973 7461 6e63 655f 6578 7028 - distance_exp( │ │ │ +00027ff0: 6d5f 6964 2c20 6964 2929 2026 6774 3b3d m_id, id)) >= │ │ │ +00028000: 2028 6920 2d20 6d5f 6275 636b 6574 732e (i - m_buckets. │ │ │ +00028010: 6265 6769 6e28 2929 0a09 2f2f 2074 6f20 begin())..// to │ │ │ +00028020: 7468 6520 6e65 7720 6275 636b 6574 0a09 the new bucket.. │ │ │ +00028030: 696e 7420 636f 6e73 7420 6e65 775f 6275 int const new_bu │ │ │ +00028040: 636b 6574 5f73 697a 6520 3d20 6275 636b cket_size = buck │ │ │ +00028050: 6574 5f6c 696d 6974 2862 7563 6b65 745f et_limit(bucket_ │ │ │ +00028060: 696e 6465 7820 2b20 3129 3b0a 0966 6f72 index + 1);..for │ │ │ +00028070: 2028 6175 746f 206a 203d 2062 2e62 6567 (auto j = b.beg │ │ │ +00028080: 696e 2829 3b20 6a20 213d 2062 2e65 6e64 in(); j != b.end │ │ │ +00028090: 2829 3b29 0a09 7b0a 0909 696e 7420 636f ();)..{...int co │ │ │ +000280a0: 6e73 7420 6420 3d20 6469 7374 616e 6365 nst d = distance │ │ │ +000280b0: 5f65 7870 286d 5f69 642c 206a 2d26 6774 _exp(m_id, j-> │ │ │ +000280c0: 3b69 6429 3b0a 0909 6966 2028 6420 2667 ;id);...if (d &g │ │ │ +000280d0: 743b 3d20 3135 3920 2d20 6275 636b 6574 t;= 159 - bucket │ │ │ +000280e0: 5f69 6e64 6578 290a 0909 7b0a 0909 092b _index)...{....+ │ │ │ +000280f0: 2b6a 3b0a 0909 0963 6f6e 7469 6e75 653b +j;....continue; │ │ │ +00028100: 0a09 097d 0a09 092f 2f20 7468 6973 2065 ...}...// this e │ │ │ +00028110: 6e74 7279 2062 656c 6f6e 6773 2069 6e20 ntry belongs in │ │ │ +00028120: 7468 6520 6e65 7720 6275 636b 6574 0a09 the new bucket.. │ │ │ +00028130: 096e 6577 5f62 7563 6b65 742e 7075 7368 .new_bucket.push │ │ │ +00028140: 5f62 6163 6b28 2a6a 293b 0a09 096a 203d _back(*j);...j = │ │ │ +00028150: 2062 2e65 7261 7365 286a 293b 0a09 7d0a b.erase(j);..}. │ │ │ +00028160: 0a09 6966 2028 696e 7428 622e 7369 7a65 ..if (int(b.size │ │ │ +00028170: 2829 2920 2667 743b 2062 7563 6b65 745f ()) > bucket_ │ │ │ +00028180: 7369 7a65 5f6c 696d 6974 290a 097b 0a3c size_limit)..{.< │ │ │ +00028190: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ +000281a0: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ +000281b0: 7769 6474 683d 2231 3030 2522 3e09 0966 width="100%">..f │ │ │ +000281c0: 6f72 2028 6175 746f 2069 203d 2062 2e62 or (auto i = b.b │ │ │ +000281d0: 6567 696e 2829 202b 2062 7563 6b65 745f egin() + bucket_ │ │ │ +000281e0: 7369 7a65 5f6c 696d 6974 0a3c 2f64 6976 size_limit.
    ..., end(b.end( │ │ │ +00028200: 2929 3b20 6920 213d 2065 6e64 3b20 2b2b )); i != end; ++ │ │ │ +00028210: 6929 0a09 097b 0a09 0909 7262 2e70 7573 i)...{....rb.pus │ │ │ +00028220: 685f 6261 636b 282a 6929 3b0a 0909 7d0a h_back(*i);...}. │ │ │ +00028230: 0a09 0962 2e72 6573 697a 6528 6275 636b ...b.resize(buck │ │ │ +00028240: 6574 5f73 697a 655f 6c69 6d69 7429 3b0a et_size_limit);. │ │ │ +00028250: 097d 0a0a 092f 2f20 7370 6c69 7420 7468 .}...// split th │ │ │ +00028260: 6520 7265 706c 6163 656d 656e 7420 6275 e replacement bu │ │ │ +00028270: 636b 6574 2061 7320 7765 6c6c 2e20 4966 cket as well. If │ │ │ +00028280: 2074 6865 206c 6976 6520 6275 636b 6574 the live bucket │ │ │ +00028290: 0a09 2f2f 2069 7320 6e6f 7420 6675 6c6c ..// is not full │ │ │ +000282a0: 2061 6e79 6d6f 7265 2c20 616c 736f 206d anymore, also m │ │ │ +000282b0: 6f76 6520 7468 6520 7265 706c 6163 656d ove the replacem │ │ │ +000282c0: 656e 7420 656e 7472 6965 730a 092f 2f20 ent entries..// │ │ │ +000282d0: 696e 746f 2074 6865 206d 6169 6e20 6275 into the main bu │ │ │ +000282e0: 636b 6574 0a09 666f 7220 2861 7574 6f20 cket..for (auto │ │ │ +000282f0: 6a20 3d20 7262 2e62 6567 696e 2829 3b20 j = rb.begin(); │ │ │ +00028300: 6a20 213d 2072 622e 656e 6428 293b 290a j != rb.end();). │ │ │ +00028310: 097b 0a09 0969 6620 2864 6973 7461 6e63 .{...if (distanc │ │ │ +00028320: 655f 6578 7028 6d5f 6964 2c20 6a2d 2667 e_exp(m_id, j-&g │ │ │ +00028330: 743b 6964 2920 2667 743b 3d20 3135 3920 t;id) >= 159 │ │ │ +00028340: 2d20 6275 636b 6574 5f69 6e64 6578 290a - bucket_index). │ │ │ +00028350: 0909 7b0a 0909 0969 6620 2821 6a2d 2667 ..{....if (!j-&g │ │ │ +00028360: 743b 7069 6e67 6564 2829 207c 7c20 696e t;pinged() || in │ │ │ +00028370: 7428 622e 7369 7a65 2829 2920 2667 743b t(b.size()) > │ │ │ +00028380: 3d20 6275 636b 6574 5f73 697a 655f 6c69 = bucket_size_li │ │ │ +00028390: 6d69 7429 0a09 0909 7b0a 0909 0909 2b2b mit)....{.....++ │ │ │ +000283a0: 6a3b 0a09 0909 0963 6f6e 7469 6e75 653b j;.....continue; │ │ │ +000283b0: 0a09 0909 7d0a 0909 0962 2e70 7573 685f ....}....b.push_ │ │ │ +000283c0: 6261 636b 282a 6a29 3b0a 0909 7d0a 0909 back(*j);...}... │ │ │ +000283d0: 656c 7365 0a09 097b 0a09 0909 2f2f 2074 else...{....// t │ │ │ +000283e0: 6869 7320 656e 7472 7920 6265 6c6f 6e67 his entry belong │ │ │ +000283f0: 7320 696e 2074 6865 206e 6577 2062 7563 s in the new buc │ │ │ +00028400: 6b65 740a 0909 0969 6620 286a 2d26 6774 ket....if (j-> │ │ │ +00028410: 3b70 696e 6765 6428 2920 2661 6d70 3b26 ;pinged() && │ │ │ +00028420: 616d 703b 2069 6e74 286e 6577 5f62 7563 amp; int(new_buc │ │ │ +00028430: 6b65 742e 7369 7a65 2829 2920 266c 743b ket.size()) < │ │ │ +00028440: 206e 6577 5f62 7563 6b65 745f 7369 7a65 new_bucket_size │ │ │ +00028450: 290a 0909 0909 6e65 775f 6275 636b 6574 ).....new_bucket │ │ │ +00028460: 2e70 7573 685f 6261 636b 282a 6a29 3b0a .push_back(*j);. │ │ │ +00028470: 0909 0965 6c73 650a 0909 0909 6e65 775f ...else.....new_ │ │ │ +00028480: 7265 706c 6163 656d 656e 745f 6275 636b replacement_buck │ │ │ +00028490: 6574 2e70 7573 685f 6261 636b 282a 6a29 et.push_back(*j) │ │ │ +000284a0: 3b0a 0909 7d0a 3c2f 7072 653e 3c2f 7464 ;...}.relevance │ │ │ +000284e0: 266e 6273 703b 323c 2f74 643e 3c74 643e  2 │ │ │ +000284f0: 3c61 2068 7265 663d 226a 6176 6173 6372 │ │ │ +00028510: 2e2e 2f73 7263 2f6b 6164 656d 6c69 612f ../src/kademlia/ │ │ │ +00028520: 6e6f 6465 2e63 7070 3a36 3834 3c2f 613e node.cpp:684 │ │ │ +00028530: 3c2f 7464 3e3c 7464 3e69 7420 776f 756c it woul │ │ │ +00028540: 6420 6265 206e 6963 6520 746f 2068 6176 d be nice to hav │ │ │ +00028550: 6520 6120 6269 6173 2074 6f77 6172 6473 e a bias towards │ │ │ +00028560: 206e 6f64 652d 6964 2070 7265 6669 7865 node-id prefixe │ │ │ +00028570: 7320 7468 6174 2061 7265 206d 6973 7369 s that are missi │ │ │ +00028580: 6e67 2069 6e20 7468 6520 6275 636b 6574 ng in the bucket │ │ │ +00028590: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    it │ │ │ +000285e0: 776f 756c 6420 6265 206e 6963 6520 746f would be nice to │ │ │ +000285f0: 2068 6176 6520 6120 6269 6173 2074 6f77 have a bias tow │ │ │ +00028600: 6172 6473 206e 6f64 652d 6964 2070 7265 ards node-id pre │ │ │ +00028610: 6669 7865 7320 7468 6174 0a61 7265 206d fixes that.are m │ │ │ +00028620: 6973 7369 6e67 2069 6e20 7468 6520 6275 issing in the bu │ │ │ +00028630: 636b 6574 3c2f 6832 3e3c 6834 3e2e 2e2f cket

    ../ │ │ │ +00028640: 7372 632f 6b61 6465 6d6c 6961 2f6e 6f64 src/kademlia/nod │ │ │ +00028650: 652e 6370 703a 3638 343c 2f68 343e 3c70 e.cpp:684

    .node_en │ │ │ +000286a0: 7472 7920 636f 6e73 742a 206e 6520 3d20 try const* ne = │ │ │ +000286b0: 6d5f 7461 626c 652e 6e65 7874 5f72 6566 m_table.next_ref │ │ │ +000286c0: 7265 7368 2829 3b0a 0969 6620 286e 6520 resh();..if (ne │ │ │ +000286d0: 3d3d 206e 756c 6c70 7472 2920 7265 7475 == nullptr) retu │ │ │ +000286e0: 726e 3b0a 0a09 2f2f 2074 6869 7320 7368 rn;...// this sh │ │ │ +000286f0: 6f75 6c64 6e27 7420 6861 7070 656e 0a09 ouldn't happen.. │ │ │ +00028700: 544f 5252 454e 545f 4153 5345 5254 286d TORRENT_ASSERT(m │ │ │ +00028710: 5f69 6420 213d 206e 652d 2667 743b 6964 _id != ne->id │ │ │ +00028720: 293b 0a09 6966 2028 6e65 2d26 6774 3b69 );..if (ne->i │ │ │ +00028730: 6420 3d3d 206d 5f69 6429 2072 6574 7572 d == m_id) retur │ │ │ +00028740: 6e3b 0a0a 0969 6e74 2063 6f6e 7374 2062 n;...int const b │ │ │ +00028750: 7563 6b65 7420 3d20 3135 3920 2d20 6469 ucket = 159 - di │ │ │ +00028760: 7374 616e 6365 5f65 7870 286d 5f69 642c stance_exp(m_id, │ │ │ +00028770: 206e 652d 2667 743b 6964 293b 0a09 544f ne->id);..TO │ │ │ +00028780: 5252 454e 545f 4153 5345 5254 2862 7563 RRENT_ASSERT(buc │ │ │ +00028790: 6b65 7420 266c 743b 2031 3630 293b 0a09 ket < 160);.. │ │ │ +000287a0: 7365 6e64 5f73 696e 676c 655f 7265 6672 send_single_refr │ │ │ +000287b0: 6573 6828 6e65 2d26 6774 3b65 7028 292c esh(ne->ep(), │ │ │ +000287c0: 2062 7563 6b65 742c 206e 652d 2667 743b bucket, ne-> │ │ │ +000287d0: 6964 293b 0a7d 0a0a 766f 6964 206e 6f64 id);.}..void nod │ │ │ +000287e0: 653a 3a73 656e 645f 7369 6e67 6c65 5f72 e::send_single_r │ │ │ +000287f0: 6566 7265 7368 2875 6470 3a3a 656e 6470 efresh(udp::endp │ │ │ +00028800: 6f69 6e74 2063 6f6e 7374 2661 6d70 3b20 oint const& │ │ │ +00028810: 6570 2c20 696e 7420 636f 6e73 7420 6275 ep, int const bu │ │ │ +00028820: 636b 6574 0a09 2c20 6e6f 6465 5f69 6420 cket.., node_id │ │ │ +00028830: 636f 6e73 7426 616d 703b 2069 6429 0a7b const& id).{ │ │ │ +00028840: 0a09 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +00028850: 2869 6420 213d 206d 5f69 6429 3b0a 0954 (id != m_id);..T │ │ │ +00028860: 4f52 5245 4e54 5f41 5353 4552 5428 6275 ORRENT_ASSERT(bu │ │ │ +00028870: 636b 6574 2026 6774 3b3d 2030 293b 0a09 cket >= 0);.. │ │ │ +00028880: 544f 5252 454e 545f 4153 5345 5254 2862 TORRENT_ASSERT(b │ │ │ +00028890: 7563 6b65 7420 266c 743b 3d20 3135 3929 ucket <= 159) │ │ │ +000288a0: 3b0a 0a09 2f2f 2067 656e 6572 6174 6520 ;...// generate │ │ │ +000288b0: 6120 7261 6e64 6f6d 206e 6f64 655f 6964 a random node_id │ │ │ +000288c0: 2077 6974 6869 6e20 7468 6520 6769 7665 within the give │ │ │ +000288d0: 6e20 6275 636b 6574 0a3c 6469 7620 7374 n bucket.

    .node_id │ │ │ +00028910: 6d61 736b 203d 2067 656e 6572 6174 655f mask = generate_ │ │ │ +00028920: 7072 6566 6978 5f6d 6173 6b28 6275 636b prefix_mask(buck │ │ │ +00028930: 6574 202b 2031 293b 0a3c 2f64 6976 3e09 et + 1);.
    . │ │ │ +00028940: 6e6f 6465 5f69 6420 7461 7267 6574 203d node_id target = │ │ │ +00028950: 2067 656e 6572 6174 655f 7365 6372 6574 generate_secret │ │ │ +00028960: 5f69 6428 2920 2661 6d70 3b20 7e6d 6173 _id() & ~mas │ │ │ +00028970: 6b3b 0a09 7461 7267 6574 207c 3d20 6d5f k;..target |= m_ │ │ │ +00028980: 6964 2026 616d 703b 206d 6173 6b3b 0a0a id & mask;.. │ │ │ +00028990: 092f 2f20 6372 6561 7465 2061 2064 756d .// create a dum │ │ │ +000289a0: 6d79 2074 7261 7665 7273 616c 5f61 6c67 my traversal_alg │ │ │ +000289b0: 6f72 6974 686d 0a09 6175 746f 2061 6c67 orithm..auto alg │ │ │ +000289c0: 6f20 3d20 7374 643a 3a6d 616b 655f 7368 o = std::make_sh │ │ │ +000289d0: 6172 6564 266c 743b 7472 6176 6572 7361 ared<traversa │ │ │ +000289e0: 6c5f 616c 676f 7269 7468 6d26 6774 3b28 l_algorithm>( │ │ │ +000289f0: 2a74 6869 732c 206e 6f64 655f 6964 2829 *this, node_id() │ │ │ +00028a00: 293b 0a09 6175 746f 206f 203d 206d 5f72 );..auto o = m_r │ │ │ +00028a10: 7063 2e61 6c6c 6f63 6174 655f 6f62 7365 pc.allocate_obse │ │ │ +00028a20: 7276 6572 266c 743b 7069 6e67 5f6f 6273 rver<ping_obs │ │ │ +00028a30: 6572 7665 7226 6774 3b28 7374 643a 3a6d erver>(std::m │ │ │ +00028a40: 6f76 6528 616c 676f 292c 2065 702c 2069 ove(algo), ep, i │ │ │ +00028a50: 6429 3b0a 0969 6620 2821 6f29 2072 6574 d);..if (!o) ret │ │ │ +00028a60: 7572 6e3b 0a23 6966 2054 4f52 5245 4e54 urn;.#if TORRENT │ │ │ +00028a70: 5f55 5345 5f41 5353 4552 5453 0a09 6f2d _USE_ASSERTS..o- │ │ │ +00028a80: 2667 743b 6d5f 696e 5f63 6f6e 7374 7275 >m_in_constru │ │ │ +00028a90: 6374 6f72 203d 2066 616c 7365 3b0a 2365 ctor = false;.#e │ │ │ +00028aa0: 6e64 6966 0a09 656e 7472 7920 653b 0a09 ndif..entry e;.. │ │ │ +00028ab0: 655b 2279 225d 203d 2022 7122 3b0a 0a09 e["y"] = "q";... │ │ │ +00028ac0: 6966 2028 6d5f 7461 626c 652e 6973 5f66 if (m_table.is_f │ │ │ +00028ad0: 756c 6c28 6275 636b 6574 2929 0a09 7b0a ull(bucket))..{. │ │ │ +00028ae0: 0909 2f2f 2063 7572 7265 6e74 2062 7563 ..// current buc │ │ │ +00028af0: 6b65 7420 6973 2066 756c 6c2c 206a 7573 ket is full, jus │ │ │ +00028b00: 7420 7069 6e67 2069 742e 0a09 0965 5b22 t ping it....e[" │ │ │ +00028b10: 7122 5d20 3d20 2270 696e 6722 3b0a 0909 q"] = "ping";... │ │ │ +00028b20: 6d5f 636f 756e 7465 7273 2e69 6e63 5f73 m_counters.inc_s │ │ │ +00028b30: 7461 7473 5f63 6f75 6e74 6572 2863 6f75 tats_counter(cou │ │ │ +00028b40: 6e74 6572 733a 3a64 6874 5f70 696e 675f nters::dht_ping_ │ │ │ +00028b50: 6f75 7429 3b0a 097d 0a09 656c 7365 0a09 out);..}..else.. │ │ │ +00028b60: 7b0a 0909 2f2f 2075 7365 2067 6574 5f70 {...// use get_p │ │ │ +00028b70: 6565 7273 2069 6e73 7465 6164 206f 6620 eers instead of │ │ │ +00028b80: 6669 6e64 5f6e 6f64 652e 2057 6527 6c6c find_node. We'll │ │ │ +00028b90: 2067 6574 206e 6f64 6573 2069 6e20 7468 get nodes in th │ │ │ +00028ba0: 6520 7265 7370 6f6e 7365 0a09 092f 2f20 e response...// │ │ │ +00028bb0: 6569 7468 6572 2077 6179 2e0a 0909 655b either way....e[ │ │ │ +00028bc0: 2271 225d 203d 2022 6765 745f 7065 6572 "q"] = "get_peer │ │ │ +00028bd0: 7322 3b0a 0909 655b 2261 225d 5b22 696e s";...e["a"]["in │ │ │ +00028be0: 666f 5f68 6173 6822 5d20 3d20 7461 7267 fo_hash"] = targ │ │ │ +00028bf0: 6574 2e74 6f5f 7374 7269 6e67 2829 3b0a et.to_string();. │ │ │ +00028c00: 0909 6d5f 636f 756e 7465 7273 2e69 6e63 ..m_counters.inc │ │ │ +00028c10: 5f73 7461 7473 5f63 6f75 6e74 6572 2863 _stats_counter(c │ │ │ +00028c20: 6f75 6e74 6572 733a 3a64 6874 5f67 6574 ounters::dht_get │ │ │ +00028c30: 5f70 6565 7273 5f6f 7574 293b 0a09 7d0a _peers_out);..}. │ │ │ +00028c40: 0a09 6f2d 2667 743b 666c 6167 7320 7c3d ..o->flags |= │ │ │ +00028c50: 206f 6273 6572 7665 723a 3a66 6c61 675f observer::flag_ │ │ │ +00028c60: 7175 6572 6965 643b 0a09 6d5f 7270 632e queried;..m_rpc. │ │ │ +00028c70: 696e 766f 6b65 2865 2c20 6570 2c20 6f29 invoke(e, ep, o) │ │ │ +00028c80: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.< │ │ │ +00028cb0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00028cc0: 703b 323c 2f74 643e 3c74 643e 3c61 2068 p;2../s │ │ │ +00028cf0: 7263 2f6b 6164 656d 6c69 612f 6e6f 6465 rc/kademlia/node │ │ │ +00028d00: 2e63 7070 3a37 3537 3c2f 613e 3c2f 7464 .cpp:757use the non │ │ │ +00028d20: 2064 6570 7265 6361 7465 6420 6675 6e63 deprecated func │ │ │ +00028d30: 7469 6f6e 2069 6e73 7465 6164 206f 6620 tion instead of │ │ │ +00028d40: 7468 6973 206f 6e65 3c2f 7464 3e3c 2f74 this one

    use the non │ │ │ +00028da0: 2064 6570 7265 6361 7465 6420 6675 6e63 deprecated func │ │ │ +00028db0: 7469 6f6e 2069 6e73 7465 6164 206f 6620 tion instead of │ │ │ +00028dc0: 7468 6973 206f 6e65 3c2f 6832 3e3c 6834 this one

    ../src/kademlia │ │ │ +00028de0: 2f6e 6f64 652e 6370 703a 3735 373c 2f68 /node.cpp:757
    .ret
    │ │ │ +00028e30: 2e6c 6f63 616c 5f65 6e64 706f 696e 7420  .local_endpoint 
    │ │ │ +00028e40: 3d20 6d61 6b65 5f75 6470 286d 5f73 6f63  = make_udp(m_soc
    │ │ │ +00028e50: 6b2e 6765 745f 6c6f 6361 6c5f 656e 6470  k.get_local_endp
    │ │ │ +00028e60: 6f69 6e74 2829 293b 0a09 6d5f 7461 626c  oint());..m_tabl
    │ │ │ +00028e70: 652e 7374 6174 7573 2872 6574 2e74 6162  e.status(ret.tab
    │ │ │ +00028e80: 6c65 293b 0a0a 0966 6f72 2028 6175 746f  le);...for (auto
    │ │ │ +00028e90: 2063 6f6e 7374 2661 6d70 3b20 7220 3a20   const& r : 
    │ │ │ +00028ea0: 6d5f 7275 6e6e 696e 675f 7265 7175 6573  m_running_reques
    │ │ │ +00028eb0: 7473 290a 097b 0a09 0972 6574 2e72 6571  ts)..{...ret.req
    │ │ │ +00028ec0: 7565 7374 732e 656d 706c 6163 655f 6261  uests.emplace_ba
    │ │ │ +00028ed0: 636b 2829 3b0a 0909 6468 745f 6c6f 6f6b  ck();...dht_look
    │ │ │ +00028ee0: 7570 2661 6d70 3b20 6c6f 6f6b 7570 203d  up& lookup =
    │ │ │ +00028ef0: 2072 6574 2e72 6571 7565 7374 732e 6261   ret.requests.ba
    │ │ │ +00028f00: 636b 2829 3b0a 0909 722d 2667 743b 7374  ck();...r->st
    │ │ │ +00028f10: 6174 7573 286c 6f6f 6b75 7029 3b0a 097d  atus(lookup);..}
    │ │ │ +00028f20: 0a09 7265 7475 726e 2072 6574 3b0a 7d0a  ..return ret;.}.
    │ │ │ +00028f30: 0a73 7464 3a3a 7475 706c 6526 6c74 3b69  .std::tuple<i
    │ │ │ +00028f40: 6e74 2c20 696e 742c 2069 6e74 2667 743b  nt, int, int>
    │ │ │ +00028f50: 206e 6f64 653a 3a67 6574 5f73 7461 7473   node::get_stats
    │ │ │ +00028f60: 5f63 6f75 6e74 6572 7328 2920 636f 6e73  _counters() cons
    │ │ │ +00028f70: 740a 7b0a 0969 6e74 206e 6f64 6573 2c20  t.{..int nodes, 
    │ │ │ +00028f80: 7265 706c 6163 656d 656e 7473 3b0a 0973  replacements;..s
    │ │ │ +00028f90: 7464 3a3a 7469 6528 6e6f 6465 732c 2072  td::tie(nodes, r
    │ │ │ +00028fa0: 6570 6c61 6365 6d65 6e74 732c 2073 7464  eplacements, std
    │ │ │ +00028fb0: 3a3a 6967 6e6f 7265 2920 3d20 7369 7a65  ::ignore) = size
    │ │ │ +00028fc0: 2829 3b0a 0972 6574 7572 6e20 7374 643a  ();..return std:
    │ │ │ +00028fd0: 3a6d 616b 655f 7475 706c 6528 6e6f 6465  :make_tuple(node
    │ │ │ +00028fe0: 732c 2072 6570 6c61 6365 6d65 6e74 732c  s, replacements,
    │ │ │ +00028ff0: 206d 5f72 7063 2e6e 756d 5f61 6c6c 6f63   m_rpc.num_alloc
    │ │ │ +00029000: 6174 6564 5f6f 6273 6572 7665 7273 2829  ated_observers()
    │ │ │ +00029010: 293b 0a7d 0a0a 2369 6620 544f 5252 454e  );.}..#if TORREN
    │ │ │ +00029020: 545f 4142 495f 5645 5253 494f 4e20 3d3d  T_ABI_VERSION ==
    │ │ │ +00029030: 2031 0a3c 6469 7620 7374 796c 653d 2262   1.
    void node::stat │ │ │ +00029070: 7573 2873 6573 7369 6f6e 5f73 7461 7475 us(session_statu │ │ │ +00029080: 7326 616d 703b 2073 290a 3c2f 6469 763e s& s).
    │ │ │ +00029090: 7b0a 0973 7464 3a3a 6c6f 636b 5f67 7561 {..std::lock_gua │ │ │ +000290a0: 7264 266c 743b 7374 643a 3a6d 7574 6578 rd<std::mutex │ │ │ +000290b0: 2667 743b 206c 286d 5f6d 7574 6578 293b > l(m_mutex); │ │ │ +000290c0: 0a0a 096d 5f74 6162 6c65 2e73 7461 7475 ...m_table.statu │ │ │ +000290d0: 7328 7329 3b0a 0973 2e64 6874 5f74 6f74 s(s);..s.dht_tot │ │ │ +000290e0: 616c 5f61 6c6c 6f63 6174 696f 6e73 202b al_allocations + │ │ │ +000290f0: 3d20 6d5f 7270 632e 6e75 6d5f 616c 6c6f = m_rpc.num_allo │ │ │ +00029100: 6361 7465 645f 6f62 7365 7276 6572 7328 cated_observers( │ │ │ +00029110: 293b 0a09 666f 7220 2861 7574 6f26 616d );..for (auto&am │ │ │ +00029120: 703b 2072 203a 206d 5f72 756e 6e69 6e67 p; r : m_running │ │ │ +00029130: 5f72 6571 7565 7374 7329 0a09 7b0a 0909 _requests)..{... │ │ │ +00029140: 732e 6163 7469 7665 5f72 6571 7565 7374 s.active_request │ │ │ +00029150: 732e 656d 706c 6163 655f 6261 636b 2829 s.emplace_back() │ │ │ +00029160: 3b0a 0909 6468 745f 6c6f 6f6b 7570 2661 ;...dht_lookup&a │ │ │ +00029170: 6d70 3b20 6c6f 6f6b 7570 203d 2073 2e61 mp; lookup = s.a │ │ │ +00029180: 6374 6976 655f 7265 7175 6573 7473 2e62 ctive_requests.b │ │ │ +00029190: 6163 6b28 293b 0a09 0972 2d26 6774 3b73 ack();...r->s │ │ │ +000291a0: 7461 7475 7328 6c6f 6f6b 7570 293b 0a09 tatus(lookup);.. │ │ │ +000291b0: 7d0a 7d0a 2365 6e64 6966 0a0a 626f 6f6c }.}.#endif..bool │ │ │ +000291c0: 206e 6f64 653a 3a6c 6f6f 6b75 705f 7065 node::lookup_pe │ │ │ +000291d0: 6572 7328 7368 6131 5f68 6173 6820 636f ers(sha1_hash co │ │ │ +000291e0: 6e73 7426 616d 703b 2069 6e66 6f5f 6861 nst& info_ha │ │ │ +000291f0: 7368 2c20 656e 7472 7926 616d 703b 2072 sh, entry& r │ │ │ +00029200: 6570 6c79 0a09 2c20 626f 6f6c 206e 6f73 eply.., bool nos │ │ │ +00029210: 6565 642c 2062 6f6f 6c20 7363 7261 7065 eed, bool scrape │ │ │ +00029220: 2c20 6164 6472 6573 7320 636f 6e73 7426 , address const& │ │ │ +00029230: 616d 703b 2072 6571 7565 7374 6572 2920 amp; requester) │ │ │ +00029240: 636f 6e73 740a 7b0a 0969 6620 286d 5f6f const.{..if (m_o │ │ │ +00029250: 6273 6572 7665 7229 0a09 096d 5f6f 6273 bserver)...m_obs │ │ │ +00029260: 6572 7665 722d 2667 743b 6765 745f 7065 erver->get_pe │ │ │ +00029270: 6572 7328 696e 666f 5f68 6173 6829 3b0a ers(info_hash);. │ │ │ +00029280: 0a09 7265 7475 726e 206d 5f73 746f 7261 ..return m_stora │ │ │ +00029290: 6765 2e67 6574 5f70 6565 7273 2869 6e66 ge.get_peers(inf │ │ │ +000292a0: 6f5f 6861 7368 2c20 6e6f 7365 6564 2c20 o_hash, noseed, │ │ │ +000292b0: 7363 7261 7065 2c20 7265 7175 6573 7465 scrape, requeste │ │ │ +000292c0: 722c 2072 6570 6c79 293b 0a7d 0a0a 656e r, reply);.}..en │ │ │ +000292d0: 7472 7920 7772 6974 655f 6e6f 6465 735f try write_nodes_ │ │ │ +000292e0: 656e 7472 7928 7374 643a 3a76 6563 746f entry(std::vecto │ │ │ +000292f0: 7226 6c74 3b6e 6f64 655f 656e 7472 7926 r<node_entry& │ │ │ +00029300: 6774 3b20 636f 6e73 7426 616d 703b 206e gt; const& n │ │ │ +00029310: 6f64 6573 290a 7b0a 0965 6e74 7279 2072 odes).{..entry r │ │ │ +00029320: 3b0a 0973 7464 3a3a 6261 636b 5f69 6e73 ;..std::back_ins │ │ │ +00029330: 6572 745f 6974 6572 6174 6f72 266c 743b ert_iterator< │ │ │ +00029340: 7374 643a 3a73 7472 696e 6726 6774 3b20 std::string> │ │ │ +00029350: 6f75 7428 722e 7374 7269 6e67 2829 293b out(r.string()); │ │ │ +00029360: 0a09 666f 7220 2861 7574 6f20 636f 6e73 ..for (auto cons │ │ │ +00029370: 7426 616d 703b 206e 203a 206e 6f64 6573 t& n : nodes │ │ │ +00029380: 290a 097b 0a09 0973 7464 3a3a 636f 7079 )..{...std::copy │ │ │ +00029390: 286e 2e69 642e 6265 6769 6e28 292c 206e (n.id.begin(), n │ │ │ +000293a0: 2e69 642e 656e 6428 292c 206f 7574 293b .id.end(), out); │ │ │ 000293b0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ 000293f0: 3b32 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;2../in │ │ │ 00029420: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -00029430: 2f73 6f63 6b73 355f 7374 7265 616d 2e68 /socks5_stream.h │ │ │ -00029440: 7070 3a31 3535 3c2f 613e 3c2f 7464 3e3c pp:155< │ │ │ -00029450: 7464 3e61 6464 2061 7379 6e63 5f63 6f6e td>add async_con │ │ │ -00029460: 6e65 6374 2829 2074 6861 7420 7461 6b65 nect() that take │ │ │ -00029470: 7320 6120 686f 7374 6e61 6d65 2061 6e64 s a hostname and │ │ │ -00029480: 2070 6f72 7420 6173 2077 656c 6c3c 2f74 port as well

    add as │ │ │ -000294e0: 796e 635f 636f 6e6e 6563 7428 2920 7468 ync_connect() th │ │ │ -000294f0: 6174 2074 616b 6573 2061 2068 6f73 746e at takes a hostn │ │ │ -00029500: 616d 6520 616e 6420 706f 7274 2061 7320 ame and port as │ │ │ -00029510: 7765 6c6c 3c2f 6832 3e3c 6834 3e2e 2e2f well

    ../ │ │ │ -00029520: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -00029530: 6e74 2f73 6f63 6b73 355f 7374 7265 616d nt/socks5_stream │ │ │ -00029540: 2e68 7070 3a31 3535 3c2f 6834 3e3c 7072 .hpp:155

    ..TORRENT │ │ │ -00029590: 5f41 5353 4552 5428 2161 7578 3a3a 6973 _ASSERT(!aux::is │ │ │ -000295a0: 5f69 705f 6164 6472 6573 7328 686f 7374 _ip_address(host │ │ │ -000295b0: 2929 3b0a 0909 6d5f 6473 745f 6e61 6d65 ));...m_dst_name │ │ │ -000295c0: 203d 2068 6f73 743b 0a09 0969 6620 286d = host;...if (m │ │ │ -000295d0: 5f64 7374 5f6e 616d 652e 7369 7a65 2829 _dst_name.size() │ │ │ -000295e0: 2026 6774 3b20 3235 3529 0a09 0909 6d5f > 255)....m_ │ │ │ -000295f0: 6473 745f 6e61 6d65 2e72 6573 697a 6528 dst_name.resize( │ │ │ -00029600: 3235 3529 3b0a 097d 0a0a 0976 6f69 6420 255);..}...void │ │ │ -00029610: 636c 6f73 6528 6572 726f 725f 636f 6465 close(error_code │ │ │ -00029620: 2661 6d70 3b20 6563 290a 097b 0a09 096d & ec)..{...m │ │ │ -00029630: 5f64 7374 5f6e 616d 652e 636c 6561 7228 _dst_name.clear( │ │ │ -00029640: 293b 0a09 0970 726f 7879 5f62 6173 653a );...proxy_base: │ │ │ -00029650: 3a63 6c6f 7365 2865 6329 3b0a 097d 0a0a :close(ec);..}.. │ │ │ -00029660: 2369 666e 6465 6620 424f 4f53 545f 4e4f #ifndef BOOST_NO │ │ │ -00029670: 5f45 5843 4550 5449 4f4e 530a 0976 6f69 _EXCEPTIONS..voi │ │ │ -00029680: 6420 636c 6f73 6528 290a 097b 0a09 096d d close()..{...m │ │ │ -00029690: 5f64 7374 5f6e 616d 652e 636c 6561 7228 _dst_name.clear( │ │ │ -000296a0: 293b 0a09 0970 726f 7879 5f62 6173 653a );...proxy_base: │ │ │ -000296b0: 3a63 6c6f 7365 2829 3b0a 097d 0a23 656e :close();..}.#en │ │ │ -000296c0: 6469 660a 0a3c 6469 7620 7374 796c 653d dif..
    .template < │ │ │ -00029700: 3b63 6c61 7373 2048 616e 646c 6572 2667 ;class Handler&g │ │ │ -00029710: 743b 0a3c 2f64 6976 3e09 766f 6964 2061 t;.
    .void a │ │ │ -00029720: 7379 6e63 5f63 6f6e 6e65 6374 2865 6e64 sync_connect(end │ │ │ -00029730: 706f 696e 745f 7479 7065 2063 6f6e 7374 point_type const │ │ │ -00029740: 2661 6d70 3b20 656e 6470 6f69 6e74 2c20 & endpoint, │ │ │ -00029750: 4861 6e64 6c65 7220 6861 6e64 6c65 7229 Handler handler) │ │ │ -00029760: 0a09 7b0a 0909 2f2f 206d 616b 6520 7375 ..{...// make su │ │ │ -00029770: 7265 2077 6520 646f 6e27 7420 7472 7920 re we don't try │ │ │ -00029780: 746f 2063 6f6e 6e65 6374 2074 6f20 494e to connect to IN │ │ │ -00029790: 4144 4452 5f41 4e59 2e20 6269 6e64 696e ADDR_ANY. bindin │ │ │ -000297a0: 6720 6973 2066 696e 652c 0a09 092f 2f20 g is fine,...// │ │ │ -000297b0: 616e 6420 7573 696e 6720 6120 686f 7374 and using a host │ │ │ -000297c0: 6e61 6d65 2069 7320 6669 6e65 206f 6e20 name is fine on │ │ │ -000297d0: 534f 434b 5320 7665 7273 696f 6e20 352e SOCKS version 5. │ │ │ -000297e0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -000297f0: 5428 656e 6470 6f69 6e74 2e61 6464 7265 T(endpoint.addre │ │ │ -00029800: 7373 2829 2021 3d20 6164 6472 6573 7328 ss() != address( │ │ │ -00029810: 290a 0909 097c 7c20 2821 6d5f 6473 745f )....|| (!m_dst_ │ │ │ -00029820: 6e61 6d65 2e65 6d70 7479 2829 2026 616d name.empty() &am │ │ │ -00029830: 703b 2661 6d70 3b20 6d5f 7665 7273 696f p;& m_versio │ │ │ -00029840: 6e20 3d3d 2035 2929 3b0a 0a09 096d 5f72 n == 5));....m_r │ │ │ -00029850: 656d 6f74 655f 656e 6470 6f69 6e74 203d emote_endpoint = │ │ │ -00029860: 2065 6e64 706f 696e 743b 0a0a 0909 2f2f endpoint;....// │ │ │ -00029870: 2074 6865 2063 6f6e 6e65 6374 2069 7320 the connect is │ │ │ -00029880: 7370 6c69 7420 7570 2069 6e20 7468 6520 split up in the │ │ │ -00029890: 666f 6c6c 6f77 696e 6720 7374 6570 733a following steps: │ │ │ -000298a0: 0a09 092f 2f20 312e 2072 6573 6f6c 7665 ...// 1. resolve │ │ │ -000298b0: 206e 616d 6520 6f66 2070 726f 7879 2073 name of proxy s │ │ │ -000298c0: 6572 7665 720a 0909 2f2f 2032 2e20 636f erver...// 2. co │ │ │ -000298d0: 6e6e 6563 7420 746f 2070 726f 7879 2073 nnect to proxy s │ │ │ -000298e0: 6572 7665 720a 0909 2f2f 2033 2e20 6966 erver...// 3. if │ │ │ -000298f0: 2076 6572 7369 6f6e 203d 3d20 353a 0a09 version == 5:.. │ │ │ -00029900: 092f 2f20 2020 332e 3120 7365 6e64 2053 .// 3.1 send S │ │ │ -00029910: 4f43 4b53 3520 6175 7468 656e 7469 6361 OCKS5 authentica │ │ │ -00029920: 7469 6f6e 206d 6574 686f 6420 6d65 7373 tion method mess │ │ │ -00029930: 6167 650a 0909 2f2f 2020 2033 2e32 2072 age...// 3.2 r │ │ │ -00029940: 6561 6420 534f 434b 5335 2061 7574 6865 ead SOCKS5 authe │ │ │ -00029950: 6e74 6963 6174 696f 6e20 7265 7370 6f6e ntication respon │ │ │ -00029960: 7365 0a09 092f 2f20 2020 332e 3320 7365 se...// 3.3 se │ │ │ -00029970: 6e64 2075 7365 726e 616d 652b 7061 7373 nd username+pass │ │ │ -00029980: 776f 7264 0a09 092f 2f20 342e 2073 656e word...// 4. sen │ │ │ -00029990: 6420 534f 434b 5320 636f 6d6d 616e 6420 d SOCKS command │ │ │ -000299a0: 6d65 7373 6167 650a 0a09 0941 4444 5f4f message....ADD_O │ │ │ -000299b0: 5554 5354 414e 4449 4e47 5f41 5359 4e43 UTSTANDING_ASYNC │ │ │ -000299c0: 2822 736f 636b 7335 5f73 7472 6561 6d3a ("socks5_stream: │ │ │ -000299d0: 3a6e 616d 655f 6c6f 6f6b 7570 2229 3b0a :name_lookup");. │ │ │ -000299e0: 0909 6d5f 7265 736f 6c76 6572 2e61 7379 ..m_resolver.asy │ │ │ -000299f0: 6e63 5f72 6573 6f6c 7665 286d 5f68 6f73 nc_resolve(m_hos │ │ │ -00029a00: 746e 616d 652c 2074 6f5f 7374 7269 6e67 tname, to_string │ │ │ -00029a10: 286d 5f70 6f72 7429 2e64 6174 6128 292c (m_port).data(), │ │ │ -00029a20: 2077 7261 705f 616c 6c6f 6361 746f 7228 wrap_allocator( │ │ │ -00029a30: 0a09 0909 5b74 6869 735d 2865 7272 6f72 ....[this](error │ │ │ -00029a40: 5f63 6f64 6520 636f 6e73 7426 616d 703b _code const& │ │ │ -00029a50: 2065 632c 2074 6370 3a3a 7265 736f 6c76 ec, tcp::resolv │ │ │ -00029a60: 6572 3a3a 7265 7375 6c74 735f 7479 7065 er::results_type │ │ │ -00029a70: 2069 7073 2c20 4861 6e64 6c65 7220 686e ips, Handler hn │ │ │ -00029a80: 2920 7b0a 0909 0909 6e61 6d65 5f6c 6f6f ) {.....name_loo │ │ │ -00029a90: 6b75 7028 6563 2c20 7374 643a 3a6d 6f76 kup(ec, std::mov │ │ │ -00029aa0: 6528 6970 7329 2c20 7374 643a 3a6d 6f76 e(ips), std::mov │ │ │ -00029ab0: 6528 686e 2929 3b0a 0909 097d 2c20 7374 e(hn));....}, st │ │ │ -00029ac0: 643a 3a6d 6f76 6528 6861 6e64 6c65 7229 d::move(handler) │ │ │ -00029ad0: 2929 3b0a 097d 0a0a 7072 6976 6174 653a ));..}..private: │ │ │ -00029ae0: 0a0a 0974 656d 706c 6174 6520 266c 743b ...template < │ │ │ -00029af0: 7479 7065 6e61 6d65 2048 616e 646c 6572 typename Handler │ │ │ -00029b00: 2667 743b 0a09 766f 6964 206e 616d 655f >..void name_ │ │ │ -00029b10: 6c6f 6f6b 7570 2865 7272 6f72 5f63 6f64 lookup(error_cod │ │ │ -00029b20: 6520 636f 6e73 7426 616d 703b 2065 2c20 e const& e, │ │ │ -00029b30: 7463 703a 3a72 6573 6f6c 7665 723a 3a72 tcp::resolver::r │ │ │ -00029b40: 6573 756c 7473 5f74 7970 6520 6970 730a esults_type ips. │ │ │ -00029b50: 0909 2c20 4861 6e64 6c65 7220 6829 0a3c .., Handler h).< │ │ │ -00029b60: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00029b70: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00029b80: 6f75 6e64 3a20 2363 6663 223e 3c74 643e ound: #cfc"> │ │ │ -00029b90: 7265 6c65 7661 6e63 6526 6e62 7370 3b32 relevance 2 │ │ │ -00029ba0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../incl │ │ │ -00029bd0: 7564 652f 6c69 6274 6f72 7265 6e74 2f70 ude/libtorrent/p │ │ │ -00029be0: 726f 7879 5f62 6173 652e 6870 703a 3332 roxy_base.hpp:32 │ │ │ -00029bf0: 383c 2f61 3e3c 2f74 643e 3c74 643e 7573 8us │ │ │ -00029c00: 6520 7468 6520 7265 736f 6c76 6572 2069 e the resolver i │ │ │ -00029c10: 6e74 6572 6661 6365 2074 6861 7420 6861 nterface that ha │ │ │ -00029c20: 7320 6120 6275 696c 742d 696e 2063 6163 s a built-in cac │ │ │ -00029c30: 6865 3c2f 7464 3e3c 2f74 723e 3c74 7220 he

    u │ │ │ -00029c80: 7365 2074 6865 2072 6573 6f6c 7665 7220 se the resolver │ │ │ -00029c90: 696e 7465 7266 6163 6520 7468 6174 2068 interface that h │ │ │ -00029ca0: 6173 2061 2062 7569 6c74 2d69 6e20 6361 as a built-in ca │ │ │ -00029cb0: 6368 653c 2f68 323e 3c68 343e 2e2e 2f69 che

    ../i │ │ │ -00029cc0: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -00029cd0: 742f 7072 6f78 795f 6261 7365 2e68 7070 t/proxy_base.hpp │ │ │ -00029ce0: 3a33 3238 3c2f 6834 3e3c 7072 6520 7374 :328

    .// The handl
    │ │ │ -00029d30: 6572 206d 7573 7420 6265 2074 616b 656e  er must be taken
    │ │ │ -00029d40: 2061 7320 6c76 616c 7565 2072 6566 6572   as lvalue refer
    │ │ │ -00029d50: 656e 6365 2068 6572 6520 7369 6e63 6520  ence here since 
    │ │ │ -00029d60: 7765 206d 6179 206e 6f74 2063 616c 6c0a  we may not call.
    │ │ │ -00029d70: 092f 2f20 6974 2e20 4275 7420 6966 2077  .// it. But if w
    │ │ │ -00029d80: 6520 646f 2c20 7765 2077 616e 7420 7468  e do, we want th
    │ │ │ -00029d90: 6520 6361 6c6c 206f 7065 7261 746f 7220  e call operator 
    │ │ │ -00029da0: 746f 206f 776e 2074 6865 2066 756e 6374  to own the funct
    │ │ │ -00029db0: 696f 6e20 6f62 6a65 6374 2e0a 0974 656d  ion object...tem
    │ │ │ -00029dc0: 706c 6174 6520 266c 743b 7479 7065 6e61  plate <typena
    │ │ │ -00029dd0: 6d65 2048 616e 646c 6572 2667 743b 0a09  me Handler>..
    │ │ │ -00029de0: 626f 6f6c 2068 616e 646c 655f 6572 726f  bool handle_erro
    │ │ │ -00029df0: 7228 6572 726f 725f 636f 6465 2065 2c20  r(error_code e, 
    │ │ │ -00029e00: 4861 6e64 6c65 7226 616d 703b 2661 6d70  Handler&&
    │ │ │ -00029e10: 3b20 6829 0a09 7b0a 0909 544f 5252 454e  ; h)..{...TORREN
    │ │ │ -00029e20: 545f 4153 5345 5254 286d 5f6d 6167 6963  T_ASSERT(m_magic
    │ │ │ -00029e30: 203d 3d20 3078 3133 3337 293b 0a09 0969   == 0x1337);...i
    │ │ │ -00029e40: 6620 2821 6529 2072 6574 7572 6e20 6661  f (!e) return fa
    │ │ │ -00029e50: 6c73 653b 0a09 0965 7272 6f72 5f63 6f64  lse;...error_cod
    │ │ │ -00029e60: 6520 6563 3b0a 0909 2f2f 2070 7265 7665  e ec;...// preve
    │ │ │ -00029e70: 6e74 206c 6966 6574 696d 6520 6d61 6e61  nt lifetime mana
    │ │ │ -00029e80: 6765 6d65 6e74 2075 7365 2d61 6674 6572  gement use-after
    │ │ │ -00029e90: 2d66 7265 650a 0909 636c 6f73 6528 6563  -free...close(ec
    │ │ │ -00029ea0: 293b 202f 2f20 636c 6f73 6520 6669 7273  ); // close firs
    │ │ │ -00029eb0: 740a 0909 7374 643a 3a6d 6f76 6528 6829  t...std::move(h)
    │ │ │ -00029ec0: 2865 293b 202f 2f20 636f 6e73 756d 650a  (e); // consume.
    │ │ │ -00029ed0: 0909 7265 7475 726e 2074 7275 653b 0a09  ..return true;..
    │ │ │ -00029ee0: 7d0a 0a09 6175 783a 3a6e 6f65 7863 6570  }...aux::noexcep
    │ │ │ -00029ef0: 745f 6d6f 7661 626c 6526 6c74 3b74 6370  t_movable<tcp
    │ │ │ -00029f00: 3a3a 736f 636b 6574 2667 743b 206d 5f73  ::socket> m_s
    │ │ │ -00029f10: 6f63 6b3b 0a09 7374 643a 3a73 7472 696e  ock;..std::strin
    │ │ │ -00029f20: 6720 6d5f 686f 7374 6e61 6d65 3b20 2f2f  g m_hostname; //
    │ │ │ -00029f30: 2070 726f 7879 2068 6f73 740a 0969 6e74   proxy host..int
    │ │ │ -00029f40: 206d 5f70 6f72 7420 3d20 303b 2020 2020   m_port = 0;    
    │ │ │ -00029f50: 2020 2020 202f 2f20 7072 6f78 7920 706f       // proxy po
    │ │ │ -00029f60: 7274 0a0a 0961 7578 3a3a 6e6f 6578 6365  rt...aux::noexce
    │ │ │ -00029f70: 7074 5f6d 6f76 6162 6c65 266c 743b 656e  pt_movable<en
    │ │ │ -00029f80: 6470 6f69 6e74 5f74 7970 6526 6774 3b20  dpoint_type> 
    │ │ │ -00029f90: 6d5f 7265 6d6f 7465 5f65 6e64 706f 696e  m_remote_endpoin
    │ │ │ -00029fa0: 743b 0a0a 3c64 6976 2073 7479 6c65 3d22  t;..
    .aux::noexcept │ │ │ -00029fe0: 5f6d 6f76 655f 6f6e 6c79 266c 743b 7463 _move_only<tc │ │ │ -00029ff0: 703a 3a72 6573 6f6c 7665 7226 6774 3b20 p::resolver> │ │ │ -0002a000: 6d5f 7265 736f 6c76 6572 3b0a 3c2f 6469 m_resolver;..#if TORRENT_U │ │ │ -0002a020: 5345 5f41 5353 4552 5453 0a09 696e 7420 SE_ASSERTS..int │ │ │ -0002a030: 6d5f 6d61 6769 6320 3d20 3078 3133 3337 m_magic = 0x1337 │ │ │ -0002a040: 3b0a 2365 6e64 6966 0a7d 3b0a 0a74 656d ;.#endif.};..tem │ │ │ -0002a050: 706c 6174 6520 266c 743b 7479 7065 6e61 plate <typena │ │ │ -0002a060: 6d65 2048 616e 646c 6572 2c20 7479 7065 me Handler, type │ │ │ -0002a070: 6e61 6d65 2055 6e64 6572 6c79 696e 6748 name UnderlyingH │ │ │ -0002a080: 616e 646c 6572 2667 743b 0a73 7472 7563 andler>.struc │ │ │ -0002a090: 7420 7772 6170 5f61 6c6c 6f63 6174 6f72 t wrap_allocator │ │ │ -0002a0a0: 5f74 0a7b 0a09 7772 6170 5f61 6c6c 6f63 _t.{..wrap_alloc │ │ │ -0002a0b0: 6174 6f72 5f74 2848 616e 646c 6572 2068 ator_t(Handler h │ │ │ -0002a0c0: 2c20 556e 6465 726c 7969 6e67 4861 6e64 , UnderlyingHand │ │ │ -0002a0d0: 6c65 7220 7568 290a 0909 3a20 6d5f 6861 ler uh)...: m_ha │ │ │ -0002a0e0: 6e64 6c65 7228 7374 643a 3a6d 6f76 6528 ndler(std::move( │ │ │ -0002a0f0: 6829 290a 0909 2c20 6d5f 756e 6465 726c h))..., m_underl │ │ │ -0002a100: 7969 6e67 5f68 616e 646c 6572 2873 7464 ying_handler(std │ │ │ -0002a110: 3a3a 6d6f 7665 2875 6829 290a 097b 7d0a ::move(uh))..{}. │ │ │ -0002a120: 0a09 7772 6170 5f61 6c6c 6f63 6174 6f72 ..wrap_allocator │ │ │ -0002a130: 5f74 2877 7261 705f 616c 6c6f 6361 746f _t(wrap_allocato │ │ │ -0002a140: 725f 7420 636f 6e73 7426 616d 703b 2920 r_t const&) │ │ │ -0002a150: 3d20 6465 6661 756c 743b 0a09 7772 6170 = default;..wrap │ │ │ -0002a160: 5f61 6c6c 6f63 6174 6f72 5f74 2877 7261 _allocator_t(wra │ │ │ -0002a170: 705f 616c 6c6f 6361 746f 725f 7426 616d p_allocator_t&am │ │ │ -0002a180: 703b 2661 6d70 3b29 203d 2064 6566 6175 p;&) = defau │ │ │ -0002a190: 6c74 3b0a 0a09 7465 6d70 6c61 7465 2026 lt;...template & │ │ │ -0002a1a0: 6c74 3b63 6c61 7373 2e2e 2e20 4126 6774 lt;class... A> │ │ │ -0002a1b0: 3b0a 0976 6f69 6420 6f70 6572 6174 6f72 ;..void operator │ │ │ -0002a1c0: 2829 2841 2661 6d70 3b26 616d 703b 2e2e ()(A&&.. │ │ │ -0002a1d0: 2e20 6129 0a09 7b0a 0909 6d5f 6861 6e64 . a)..{...m_hand │ │ │ -0002a1e0: 6c65 7228 7374 643a 3a66 6f72 7761 7264 ler(std::forward │ │ │ -0002a1f0: 266c 743b 4126 6774 3b28 6129 2e2e 2e2c <A>(a)..., │ │ │ -0002a200: 2073 7464 3a3a 6d6f 7665 286d 5f75 6e64 std::move(m_und │ │ │ -0002a210: 6572 6c79 696e 675f 6861 6e64 6c65 7229 erlying_handler) │ │ │ -0002a220: 293b 0a09 7d0a 0a09 7573 696e 6720 616c );..}...using al │ │ │ -0002a230: 6c6f 6361 746f 725f 7479 7065 203d 2074 locator_type = t │ │ │ -0002a240: 7970 656e 616d 6520 626f 6f73 743a 3a61 ypename boost::a │ │ │ -0002a250: 7369 6f3a 3a61 7373 6f63 6961 7465 645f sio::associated_ │ │ │ -0002a260: 616c 6c6f 6361 746f 7226 6c74 3b55 6e64 allocator<Und │ │ │ -0002a270: 6572 6c79 696e 6748 616e 646c 6572 2667 erlyingHandler&g │ │ │ -0002a280: 743b 3a3a 7479 7065 3b0a 0975 7369 6e67 t;::type;..using │ │ │ -0002a290: 2065 7865 6375 746f 725f 7479 7065 203d executor_type = │ │ │ -0002a2a0: 2074 7970 656e 616d 6520 626f 6f73 743a typename boost: │ │ │ -0002a2b0: 3a61 7369 6f3a 3a61 7373 6f63 6961 7465 :asio::associate │ │ │ -0002a2c0: 645f 6578 6563 7574 6f72 266c 743b 556e d_executor<Un │ │ │ -0002a2d0: 6465 726c 7969 6e67 4861 6e64 6c65 7226 derlyingHandler& │ │ │ -0002a2e0: 6774 3b3a 3a74 7970 653b 0a0a 0961 6c6c gt;::type;...all │ │ │ -0002a2f0: 6f63 6174 6f72 5f74 7970 6520 6765 745f ocator_type get_ │ │ │ -0002a300: 616c 6c6f 6361 746f 7228 2920 636f 6e73 allocator() cons │ │ │ -0002a310: 7420 6e6f 6578 6365 7074 0a09 7b20 7265 t noexcept..{ re │ │ │ -0002a320: 7475 726e 2062 6f6f 7374 3a3a 6173 696f turn boost::asio │ │ │ -0002a330: 3a3a 6765 745f 6173 736f 6369 6174 6564 ::get_associated │ │ │ -0002a340: 5f61 6c6c 6f63 6174 6f72 286d 5f75 6e64 _allocator(m_und │ │ │ -0002a350: 6572 6c79 696e 675f 6861 6e64 6c65 7229 erlying_handler) │ │ │ -0002a360: 3b20 7d0a 0a09 6578 6563 7574 6f72 5f74 ; }...executor_t │ │ │ -0002a370: 7970 6520 6765 745f 6578 6563 7574 6f72 ype get_executor │ │ │ -0002a380: 2829 2063 6f6e 7374 206e 6f65 7863 6570 () const noexcep │ │ │ -0002a390: 740a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 t.
    < │ │ │ -0002a3c0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0002a3d0: 703b 323c 2f74 643e 3c74 643e 3c61 2068 p;2../i │ │ │ -0002a400: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -0002a410: 742f 7069 6563 655f 7069 636b 6572 2e68 t/piece_picker.h │ │ │ -0002a420: 7070 3a36 3638 3c2f 613e 3c2f 7464 3e3c pp:668< │ │ │ -0002a430: 7464 3e68 6176 696e 6720 3820 7072 696f td>having 8 prio │ │ │ -0002a440: 7269 7479 206c 6576 656c 7320 6973 2070 rity levels is p │ │ │ -0002a450: 726f 6261 626c 7920 6578 6365 7373 6976 robably excessiv │ │ │ -0002a460: 652e 2049 7420 7368 6f75 6c64 2070 726f e. It should pro │ │ │ -0002a470: 6261 626c 7920 6265 2063 6861 6e67 6564 bably be changed │ │ │ -0002a480: 2074 6f20 3320 6c65 7665 6c73 202b 2064 to 3 levels + d │ │ │ -0002a490: 6f6e 742d 646f 776e 6c6f 6164 3c2f 7464 ont-download

    having │ │ │ -0002a4f0: 3820 7072 696f 7269 7479 206c 6576 656c 8 priority level │ │ │ -0002a500: 7320 6973 2070 726f 6261 626c 7920 6578 s is probably ex │ │ │ -0002a510: 6365 7373 6976 652e 2049 7420 7368 6f75 cessive. It shou │ │ │ -0002a520: 6c64 0a70 726f 6261 626c 7920 6265 2063 ld.probably be c │ │ │ -0002a530: 6861 6e67 6564 2074 6f20 3320 6c65 7665 hanged to 3 leve │ │ │ -0002a540: 6c73 202b 2064 6f6e 742d 646f 776e 6c6f ls + dont-downlo │ │ │ -0002a550: 6164 3c2f 6832 3e3c 6834 3e2e 2e2f 696e ad

    ../in │ │ │ -0002a560: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -0002a570: 2f70 6965 6365 5f70 6963 6b65 722e 6870 /piece_picker.hp │ │ │ -0002a580: 703a 3636 383c 2f68 343e 3c70 7265 2073 p:668

    ....else if 
    │ │ │ -0002a5d0: 2873 7461 7465 2829 203d 3d20 7069 6563  (state() == piec
    │ │ │ -0002a5e0: 655f 6675 6c6c 290a 0909 0909 0909 7374  e_full).......st
    │ │ │ -0002a5f0: 6174 6528 7069 6563 655f 6675 6c6c 5f72  ate(piece_full_r
    │ │ │ -0002a600: 6576 6572 7365 293b 0a09 0909 7d0a 0a09  everse);....}...
    │ │ │ -0002a610: 0909 2f2f 2074 6865 206e 756d 6265 7220  ..// the number 
    │ │ │ -0002a620: 6f66 2070 6565 7273 2074 6861 7420 6861  of peers that ha
    │ │ │ -0002a630: 7320 7468 6973 2070 6965 6365 0a09 0909  s this piece....
    │ │ │ -0002a640: 2f2f 2028 6176 6169 6c61 6269 6c69 7479  // (availability
    │ │ │ -0002a650: 290a 0909 0973 7464 3a3a 7569 6e74 3332  )....std::uint32
    │ │ │ -0002a660: 5f74 2070 6565 725f 636f 756e 7420 3a20  _t peer_count : 
    │ │ │ -0002a670: 3236 3b0a 0a09 0909 2f2f 206f 6e65 206f  26;.....// one o
    │ │ │ -0002a680: 6620 7468 6520 646f 776e 6c6f 6164 5f71  f the download_q
    │ │ │ -0002a690: 7565 7565 5f74 2076 616c 7565 732e 2054  ueue_t values. T
    │ │ │ -0002a6a0: 6869 7320 696e 6469 6361 7465 7320 7768  his indicates wh
    │ │ │ -0002a6b0: 6574 6865 7220 7468 6973 2070 6965 6365  ether this piece
    │ │ │ -0002a6c0: 0a09 0909 2f2f 2069 7320 6375 7272 656e  ....// is curren
    │ │ │ -0002a6d0: 746c 7920 6265 696e 6720 646f 776e 6c6f  tly being downlo
    │ │ │ -0002a6e0: 6164 6564 206f 7220 6e6f 742c 2061 6e64  aded or not, and
    │ │ │ -0002a6f0: 2077 6861 7420 7374 6174 6520 6974 2773   what state it's
    │ │ │ -0002a700: 2069 6e20 6966 0a09 0909 2f2f 2069 7420   in if....// it 
    │ │ │ -0002a710: 6973 2e20 5370 6563 6966 6963 616c 6c79  is. Specifically
    │ │ │ -0002a720: 2c20 6173 2061 6e20 6f70 7469 6d69 7a61  , as an optimiza
    │ │ │ -0002a730: 7469 6f6e 2c20 7069 6563 6573 2074 6861  tion, pieces tha
    │ │ │ -0002a740: 7420 6861 7665 2061 6c6c 2062 6c6f 636b  t have all block
    │ │ │ -0002a750: 730a 0909 092f 2f20 7265 7175 6573 7465  s....// requeste
    │ │ │ -0002a760: 6420 6672 6f6d 2074 6865 6d20 6172 6520  d from them are 
    │ │ │ -0002a770: 7365 7061 7261 7465 6420 6f75 7420 696e  separated out in
    │ │ │ -0002a780: 746f 2073 6570 6172 6174 6520 6c69 7374  to separate list
    │ │ │ -0002a790: 7320 746f 206d 616b 650a 0909 092f 2f20  s to make....// 
    │ │ │ -0002a7a0: 6c6f 6f6b 7570 7320 7175 6963 6b65 722e  lookups quicker.
    │ │ │ -0002a7b0: 2054 6865 206d 6169 6e20 6f64 6469 7479   The main oddity
    │ │ │ -0002a7c0: 2069 7320 7468 6174 2077 6865 7468 6572   is that whether
    │ │ │ -0002a7d0: 2061 2064 6f77 6e6c 6f61 6469 6e67 2070   a downloading p
    │ │ │ -0002a7e0: 6965 6365 0a09 0909 2f2f 2068 6173 206f  iece....// has o
    │ │ │ -0002a7f0: 6e6c 7920 6265 656e 2072 6571 7565 7374  nly been request
    │ │ │ -0002a800: 6564 2066 726f 6d20 7065 6572 7320 7468  ed from peers th
    │ │ │ -0002a810: 6174 2061 7265 2072 6576 6572 7365 2c20  at are reverse, 
    │ │ │ -0002a820: 7468 6174 2773 0a09 0909 2f2f 2072 6563  that's....// rec
    │ │ │ -0002a830: 6f72 6465 6420 6173 2070 6965 6365 5f64  orded as piece_d
    │ │ │ -0002a840: 6f77 6e6c 6f61 6469 6e67 5f72 6576 6572  ownloading_rever
    │ │ │ -0002a850: 7365 2c20 7768 6963 6820 7265 616c 6c79  se, which really
    │ │ │ -0002a860: 206d 6561 6e73 2074 6865 2073 616d 650a   means the same.
    │ │ │ -0002a870: 0909 092f 2f20 6173 2070 6965 6365 5f64  ...// as piece_d
    │ │ │ -0002a880: 6f77 6e6c 6f61 6469 6e67 2c20 6974 206a  ownloading, it j
    │ │ │ -0002a890: 7573 7420 7361 7665 7320 7370 6163 6520  ust saves space 
    │ │ │ -0002a8a0: 746f 2061 6c73 6f20 696e 6469 6361 7465  to also indicate
    │ │ │ -0002a8b0: 2074 6861 7420 6974 0a09 0909 2f2f 2068   that it....// h
    │ │ │ -0002a8c0: 6173 2061 2062 6974 206c 6f77 6572 2070  as a bit lower p
    │ │ │ -0002a8d0: 7269 6f72 6974 792e 2054 6865 2072 6576  riority. The rev
    │ │ │ -0002a8e0: 6572 7365 2062 6974 2069 7320 6f6e 6c79  erse bit is only
    │ │ │ -0002a8f0: 2072 656c 6576 616e 7420 6966 2074 6865   relevant if the
    │ │ │ -0002a900: 0a09 0909 2f2f 2073 7461 7465 2069 7320  ....// state is 
    │ │ │ -0002a910: 7069 6563 655f 646f 776e 6c6f 6164 696e  piece_downloadin
    │ │ │ -0002a920: 672e 0a09 0909 7374 643a 3a75 696e 7433  g.....std::uint3
    │ │ │ -0002a930: 325f 7420 646f 776e 6c6f 6164 5f73 7461  2_t download_sta
    │ │ │ -0002a940: 7465 203a 2033 3b0a 0a3c 6469 7620 7374  te : 3;..
    .
    .. │ │ │ -0002a980: 092f 2f20 6973 2030 2069 6620 7468 6520 .// is 0 if the │ │ │ -0002a990: 7069 6563 6520 6973 2066 696c 7465 7265 piece is filtere │ │ │ -0002a9a0: 6420 286e 6f74 2074 6f20 6265 2064 6f77 d (not to be dow │ │ │ -0002a9b0: 6e6c 6f61 6465 6429 0a09 0909 2f2f 2031 nloaded)....// 1 │ │ │ -0002a9c0: 2069 7320 6c6f 7720 7072 696f 7269 7479 is low priority │ │ │ -0002a9d0: 0a09 0909 2f2f 2032 2069 7320 6c6f 7720 ....// 2 is low │ │ │ -0002a9e0: 7072 696f 7269 7479 0a09 0909 2f2f 2033 priority....// 3 │ │ │ -0002a9f0: 2069 7320 6d69 6420 7072 696f 7269 7479 is mid priority │ │ │ -0002aa00: 0a09 0909 2f2f 2034 2069 7320 6465 6661 ....// 4 is defa │ │ │ -0002aa10: 756c 7420 7072 696f 7269 7479 0a09 0909 ult priority.... │ │ │ -0002aa20: 2f2f 2035 2069 7320 6d69 6420 7072 696f // 5 is mid prio │ │ │ -0002aa30: 7269 7479 0a09 0909 2f2f 2036 2069 7320 rity....// 6 is │ │ │ -0002aa40: 6869 6768 2070 7269 6f72 6974 790a 0909 high priority... │ │ │ -0002aa50: 092f 2f20 3720 6973 2068 6967 6820 7072 .// 7 is high pr │ │ │ -0002aa60: 696f 7269 7479 0a09 0909 7374 643a 3a75 iority....std::u │ │ │ -0002aa70: 696e 7433 325f 7420 7069 6563 655f 7072 int32_t piece_pr │ │ │ -0002aa80: 696f 7269 7479 203a 2033 3b0a 0a09 0909 iority : 3;..... │ │ │ -0002aa90: 2f2f 2069 6e64 6578 2069 6e20 746f 2074 // index in to t │ │ │ -0002aaa0: 6865 2070 6965 6365 5f69 6e66 6f20 7665 he piece_info ve │ │ │ -0002aab0: 6374 6f72 0a09 0909 7072 696f 5f69 6e64 ctor....prio_ind │ │ │ -0002aac0: 6578 5f74 2069 6e64 6578 3b0a 0a23 6966 ex_t index;..#if │ │ │ -0002aad0: 6465 6620 544f 5252 454e 545f 4445 4255 def TORRENT_DEBU │ │ │ -0002aae0: 475f 5245 4643 4f55 4e54 530a 0909 092f G_REFCOUNTS..../ │ │ │ -0002aaf0: 2f20 616c 6c20 7468 6520 7065 6572 7320 / all the peers │ │ │ -0002ab00: 7468 6174 2068 6176 6520 7468 6973 2070 that have this p │ │ │ -0002ab10: 6965 6365 0a09 0909 7374 643a 3a73 6574 iece....std::set │ │ │ -0002ab20: 266c 743b 636f 6e73 7420 746f 7272 656e <const torren │ │ │ -0002ab30: 745f 7065 6572 2a26 6774 3b20 6861 7665 t_peer*> have │ │ │ -0002ab40: 5f70 6565 7273 3b0a 2365 6e64 6966 0a0a _peers;.#endif.. │ │ │ -0002ab50: 0909 092f 2f20 696e 6465 7820 6973 2073 ...// index is s │ │ │ -0002ab60: 6574 2074 6f20 7468 6973 2074 6f20 696e et to this to in │ │ │ -0002ab70: 6469 6361 7465 2074 6861 7420 7765 2068 dicate that we h │ │ │ -0002ab80: 6176 6520 7468 650a 0909 092f 2f20 7069 ave the....// pi │ │ │ -0002ab90: 6563 652e 2054 6865 7265 2069 7320 6e6f ece. There is no │ │ │ -0002aba0: 2065 6e74 7279 2066 6f72 2074 6865 2070 entry for the p │ │ │ -0002abb0: 6965 6365 2069 6e20 7468 650a 0909 092f iece in the..../ │ │ │ -0002abc0: 2f20 6275 636b 6574 7320 6966 2074 6869 / buckets if thi │ │ │ -0002abd0: 7320 6973 2074 6865 2063 6173 652e 0a09 s is the case... │ │ │ -0002abe0: 0909 7374 6174 6963 2063 6f6e 7374 6578 ..static constex │ │ │ -0002abf0: 7072 2070 7269 6f5f 696e 6465 785f 7420 pr prio_index_t │ │ │ -0002ac00: 7765 5f68 6176 655f 696e 6465 787b 2d31 we_have_index{-1 │ │ │ -0002ac10: 7d3b 0a0a 0909 092f 2f20 7468 6520 7072 };.....// the pr │ │ │ -0002ac20: 696f 7269 7479 2076 616c 7565 2074 6861 iority value tha │ │ │ -0002ac30: 7420 6d65 616e 7320 7468 6520 7069 6563 t means the piec │ │ │ -0002ac40: 6520 6973 2066 696c 7465 7265 640a 0909 e is filtered... │ │ │ -0002ac50: 0973 7461 7469 6320 636f 6e73 7465 7870 .static constexp │ │ │ -0002ac60: 7220 7374 643a 3a75 696e 7433 325f 7420 r std::uint32_t │ │ │ -0002ac70: 6669 6c74 6572 5f70 7269 6f72 6974 7920 filter_priority │ │ │ -0002ac80: 3d20 303b 0a0a 0909 092f 2f20 7468 6520 = 0;.....// the │ │ │ -0002ac90: 6d61 7820 6e75 6d62 6572 2074 6865 2070 max number the p │ │ │ -0002aca0: 6565 7220 636f 756e 7420 6361 6e20 686f eer count can ho │ │ │ -0002acb0: 6c64 0a09 0909 7374 6174 6963 2063 6f6e ld....static con │ │ │ -0002acc0: 7374 6578 7072 2073 7464 3a3a 7569 6e74 stexpr std::uint │ │ │ -0002acd0: 3332 5f74 206d 6178 5f70 6565 725f 636f 32_t max_peer_co │ │ │ -0002ace0: 756e 7420 3d20 3078 6666 6666 3b0a 0a09 unt = 0xffff;... │ │ │ -0002acf0: 0909 626f 6f6c 2068 6176 6528 2920 636f ..bool have() co │ │ │ -0002ad00: 6e73 7420 7b20 7265 7475 726e 2069 6e64 nst { return ind │ │ │ -0002ad10: 6578 203d 3d20 7765 5f68 6176 655f 696e ex == we_have_in │ │ │ -0002ad20: 6465 783b 207d 0a3c 2f70 7265 3e3c 2f74 dex; }.
    relevanc │ │ │ -0002ad60: 6526 6e62 7370 3b32 3c2f 7464 3e3c 7464 e 2../include/libt │ │ │ -0002ada0: 6f72 7265 6e74 2f70 6565 725f 636f 6e6e orrent/peer_conn │ │ │ -0002adb0: 6563 7469 6f6e 2e68 7070 3a39 3936 3c2f ection.hpp:996this │ │ │ -0002add0: 7368 6f75 6c64 2072 6561 6c6c 7920 6265 should really be │ │ │ -0002ade0: 2061 2063 6972 6375 6c61 7220 6275 6666 a circular buff │ │ │ -0002adf0: 6572 3c2f 7464 3e3c 2f74 723e 3c74 7220 er

    t │ │ │ -0002ae40: 6869 7320 7368 6f75 6c64 2072 6561 6c6c his should reall │ │ │ -0002ae50: 7920 6265 2061 2063 6972 6375 6c61 7220 y be a circular │ │ │ -0002ae60: 6275 6666 6572 3c2f 6832 3e3c 6834 3e2e buffer

    . │ │ │ -0002ae70: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -0002ae80: 7265 6e74 2f70 6565 725f 636f 6e6e 6563 rent/peer_connec │ │ │ -0002ae90: 7469 6f6e 2e68 7070 3a39 3936 3c2f 6834 tion.hpp:996

    ..// 
    │ │ │ -0002aee0: 6974 206a 7573 7420 7365 7276 6573 2061  it just serves a
    │ │ │ -0002aef0: 7320 6120 7175 6575 6520 746f 2072 656d  s a queue to rem
    │ │ │ -0002af00: 656d 6265 7220 7768 6174 2077 6527 7665  ember what we've
    │ │ │ -0002af10: 2073 656e 742c 2074 6f20 6176 6f69 640a   sent, to avoid.
    │ │ │ -0002af20: 0909 2f2f 2072 652d 7365 6e64 696e 6720  ..// re-sending 
    │ │ │ -0002af30: 7375 6767 6573 7473 2066 6f72 2074 6865  suggests for the
    │ │ │ -0002af40: 2073 616d 6520 7069 6563 650a 0909 2f2f   same piece...//
    │ │ │ -0002af50: 2069 2e65 2e20 6f75 7467 6f69 6e67 2073   i.e. outgoing s
    │ │ │ -0002af60: 7567 6765 7374 2070 6965 6365 730a 0909  uggest pieces...
    │ │ │ -0002af70: 6175 783a 3a76 6563 746f 7226 6c74 3b70  aux::vector<p
    │ │ │ -0002af80: 6965 6365 5f69 6e64 6578 5f74 2667 743b  iece_index_t>
    │ │ │ -0002af90: 206d 5f73 7567 6765 7374 5f70 6965 6365   m_suggest_piece
    │ │ │ -0002afa0: 733b 0a0a 0909 2f2f 2074 6865 2070 6965  s;....// the pie
    │ │ │ -0002afb0: 6365 7320 7765 2077 696c 6c20 7365 6e64  ces we will send
    │ │ │ -0002afc0: 2074 6f20 7468 6520 7065 6572 0a09 092f   to the peer.../
    │ │ │ -0002afd0: 2f20 6966 2072 6571 7565 7374 6564 2028  / if requested (
    │ │ │ -0002afe0: 7265 6761 7264 6c65 7373 206f 6620 6368  regardless of ch
    │ │ │ -0002aff0: 6f6b 6520 7374 6174 6529 0a09 0973 7464  oke state)...std
    │ │ │ -0002b000: 3a3a 7665 6374 6f72 266c 743b 7069 6563  ::vector<piec
    │ │ │ -0002b010: 655f 696e 6465 785f 7426 6774 3b20 6d5f  e_index_t> m_
    │ │ │ -0002b020: 6163 6365 7074 5f66 6173 743b 0a0a 0909  accept_fast;....
    │ │ │ -0002b030: 2f2f 2061 2073 656e 742d 7069 6563 6520  // a sent-piece 
    │ │ │ -0002b040: 636f 756e 7465 7220 666f 7220 7468 6520  counter for the 
    │ │ │ -0002b050: 616c 6c6f 7765 6420 6661 7374 2073 6574  allowed fast set
    │ │ │ -0002b060: 0a09 092f 2f20 746f 2061 766f 6964 2065  ...// to avoid e
    │ │ │ -0002b070: 7870 6c6f 6974 6174 696f 6e2e 2045 6163  xploitation. Eac
    │ │ │ -0002b080: 6820 736c 6f74 2069 7320 6120 636f 756e  h slot is a coun
    │ │ │ -0002b090: 7465 720a 0909 2f2f 2066 6f72 206f 6e65  ter...// for one
    │ │ │ -0002b0a0: 206f 6620 7468 6520 7069 6563 6573 2066   of the pieces f
    │ │ │ -0002b0b0: 726f 6d20 7468 6520 616c 6c6f 7765 642d  rom the allowed-
    │ │ │ -0002b0c0: 6661 7374 2073 6574 0a09 0961 7578 3a3a  fast set...aux::
    │ │ │ -0002b0d0: 7665 6374 6f72 266c 743b 7374 643a 3a75  vector<std::u
    │ │ │ -0002b0e0: 696e 7431 365f 7426 6774 3b20 6d5f 6163  int16_t> m_ac
    │ │ │ -0002b0f0: 6365 7074 5f66 6173 745f 7069 6563 655f  cept_fast_piece_
    │ │ │ -0002b100: 636e 743b 0a0a 0909 2f2f 2074 6865 2070  cnt;....// the p
    │ │ │ -0002b110: 6965 6365 7320 7468 6520 7065 6572 2077  ieces the peer w
    │ │ │ -0002b120: 696c 6c20 7365 6e64 2075 7320 6966 0a09  ill send us if..
    │ │ │ -0002b130: 092f 2f20 7265 7175 6573 7465 6420 2872  .// requested (r
    │ │ │ -0002b140: 6567 6172 646c 6573 7320 6f66 2063 686f  egardless of cho
    │ │ │ -0002b150: 6b65 2073 7461 7465 290a 0909 7374 643a  ke state)...std:
    │ │ │ -0002b160: 3a76 6563 746f 7226 6c74 3b70 6965 6365  :vector<piece
    │ │ │ -0002b170: 5f69 6e64 6578 5f74 2667 743b 206d 5f61  _index_t> m_a
    │ │ │ -0002b180: 6c6c 6f77 6564 5f66 6173 743b 0a0a 0909  llowed_fast;....
    │ │ │ -0002b190: 2f2f 2070 6965 6365 7320 7468 6174 2068  // pieces that h
    │ │ │ -0002b1a0: 6173 2062 6565 6e20 7375 6767 6573 7465  as been suggeste
    │ │ │ -0002b1b0: 6420 746f 2062 6520 646f 776e 6c6f 6164  d to be download
    │ │ │ -0002b1c0: 6564 2066 726f 6d20 7468 6973 2070 6565  ed from this pee
    │ │ │ -0002b1d0: 720a 0909 2f2f 2069 2e65 2e20 696e 636f  r...// i.e. inco
    │ │ │ -0002b1e0: 6d69 6e67 2073 7567 6765 7374 696f 6e73  ming suggestions
    │ │ │ -0002b1f0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -0002b220: 0961 7578 3a3a 7665 6374 6f72 266c 743b .aux::vector< │ │ │ -0002b230: 7069 6563 655f 696e 6465 785f 7426 6774 piece_index_t> │ │ │ -0002b240: 3b20 6d5f 7375 6767 6573 7465 645f 7069 ; m_suggested_pi │ │ │ -0002b250: 6563 6573 3b0a 3c2f 6469 763e 0a09 092f eces;.
    .../ │ │ │ -0002b260: 2f20 7468 6520 7469 6d65 2077 6865 6e20 / the time when │ │ │ -0002b270: 7468 6973 2070 6565 7220 6c61 7374 2073 this peer last s │ │ │ -0002b280: 6177 2061 2063 6f6d 706c 6574 6520 636f aw a complete co │ │ │ -0002b290: 7079 0a09 092f 2f20 6f66 2074 6869 7320 py...// of this │ │ │ -0002b2a0: 746f 7272 656e 740a 0909 7469 6d65 5f74 torrent...time_t │ │ │ -0002b2b0: 206d 5f6c 6173 745f 7365 656e 5f63 6f6d m_last_seen_com │ │ │ -0002b2c0: 706c 6574 6520 3d20 303b 0a0a 0909 2f2f plete = 0;....// │ │ │ -0002b2d0: 2074 6865 2062 6c6f 636b 2077 6527 7265 the block we're │ │ │ -0002b2e0: 2063 7572 7265 6e74 6c79 2072 6563 6569 currently recei │ │ │ -0002b2f0: 7669 6e67 2e20 4f72 0a09 092f 2f20 282d ving. Or...// (- │ │ │ -0002b300: 312c 202d 3129 2069 6620 7765 2772 6520 1, -1) if we're │ │ │ -0002b310: 6e6f 7420 7265 6365 6976 696e 6720 6f6e not receiving on │ │ │ -0002b320: 650a 0909 7069 6563 655f 626c 6f63 6b20 e...piece_block │ │ │ -0002b330: 6d5f 7265 6365 6976 696e 675f 626c 6f63 m_receiving_bloc │ │ │ -0002b340: 6b20 3d20 7069 6563 655f 626c 6f63 6b3a k = piece_block: │ │ │ -0002b350: 3a69 6e76 616c 6964 3b0a 0a09 092f 2f20 :invalid;....// │ │ │ -0002b360: 7468 6520 6c6f 6361 6c20 656e 6470 6f69 the local endpoi │ │ │ -0002b370: 6e74 2066 6f72 2074 6869 7320 7065 6572 nt for this peer │ │ │ -0002b380: 2c20 692e 652e 206f 7572 2061 6464 7265 , i.e. our addre │ │ │ -0002b390: 7373 0a09 092f 2f20 616e 6420 6f75 7220 ss...// and our │ │ │ -0002b3a0: 706f 7274 2e20 4966 2074 6869 7320 6973 port. If this is │ │ │ -0002b3b0: 2073 6574 2066 6f72 206f 7574 676f 696e set for outgoin │ │ │ -0002b3c0: 6720 636f 6e6e 6563 7469 6f6e 730a 0909 g connections... │ │ │ -0002b3d0: 2f2f 2062 6566 6f72 6520 7468 6520 636f // before the co │ │ │ -0002b3e0: 6e6e 6563 7469 6f6e 2063 6f6d 706c 6574 nnection complet │ │ │ -0002b3f0: 6573 2c20 6974 206d 6561 6e73 2077 6520 es, it means we │ │ │ -0002b400: 7761 6e74 2074 6f0a 0909 2f2f 2066 6f72 want to...// for │ │ │ -0002b410: 6365 2074 6865 2063 6f6e 6e65 6374 696f ce the connectio │ │ │ -0002b420: 6e20 746f 2062 6520 626f 756e 6420 746f n to be bound to │ │ │ -0002b430: 2074 6865 2073 7065 6369 6669 6564 2069 the specified i │ │ │ -0002b440: 6e74 6572 6661 6365 2e0a 0909 2f2f 2069 nterface....// i │ │ │ -0002b450: 6620 6974 2065 6e64 7320 7570 2062 6569 f it ends up bei │ │ │ -0002b460: 6e67 2062 6f75 6e64 2074 6f20 6120 6469 ng bound to a di │ │ │ -0002b470: 6666 6572 656e 7420 6c6f 6361 6c20 4950 fferent local IP │ │ │ -0002b480: 2c20 7468 6520 636f 6e6e 6563 7469 6f6e , the connection │ │ │ -0002b490: 0a09 092f 2f20 6973 2063 6c6f 7365 642e ...// is closed. │ │ │ -0002b4a0: 0a09 0974 6370 3a3a 656e 6470 6f69 6e74 ...tcp::endpoint │ │ │ -0002b4b0: 206d 5f6c 6f63 616c 3b0a 0a09 092f 2f20 m_local;....// │ │ │ -0002b4c0: 7265 6d6f 7465 2070 6565 7227 7320 6964 remote peer's id │ │ │ -0002b4d0: 0a09 0970 6565 725f 6964 206d 5f70 6565 ...peer_id m_pee │ │ │ -0002b4e0: 725f 6964 3b0a 0a09 7072 6f74 6563 7465 r_id;...protecte │ │ │ -0002b4f0: 643a 0a0a 0909 7465 6d70 6c61 7465 2026 d:....template & │ │ │ -0002b500: 6c74 3b74 7970 656e 616d 6520 4675 6e2c lt;typename Fun, │ │ │ -0002b510: 2074 7970 656e 616d 652e 2e2e 2041 7267 typename... Arg │ │ │ -0002b520: 7326 6774 3b0a 0909 766f 6964 2077 7261 s>...void wra │ │ │ -0002b530: 7028 4675 6e20 662c 2041 7267 7326 616d p(Fun f, Args&am │ │ │ -0002b540: 703b 2661 6d70 3b2e 2e2e 2061 293b 0a0a p;&... a);.. │ │ │ -0002b550: 0909 2f2f 2073 7461 7469 7374 6963 7320 ..// statistics │ │ │ -0002b560: 6162 6f75 7420 7570 6c6f 6164 2061 6e64 about upload and │ │ │ -0002b570: 2064 6f77 6e6c 6f61 6420 7370 6565 6473 download speeds │ │ │ -0002b580: 0a09 092f 2f20 616e 6420 746f 7461 6c20 ...// and total │ │ │ -0002b590: 616d 6f75 6e74 206f 6620 7570 6c6f 6164 amount of upload │ │ │ -0002b5a0: 7320 616e 6420 646f 776e 6c6f 6164 7320 s and downloads │ │ │ -0002b5b0: 666f 720a 0909 2f2f 2074 6869 7320 7065 for...// this pe │ │ │ -0002b5c0: 6572 0a3c 2f70 7265 3e3c 2f74 643e 3c2f er.
    │ │ │ -0002b5f0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -0002b600: 7370 3b32 3c2f 7464 3e3c 7464 3e3c 6120 sp;2
    ../ │ │ │ -0002b630: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -0002b640: 6e74 2f70 6565 725f 636f 6e6e 6563 7469 nt/peer_connecti │ │ │ -0002b650: 6f6e 2e68 7070 3a31 3038 363c 2f61 3e3c on.hpp:1086< │ │ │ -0002b660: 2f74 643e 3c74 643e 7265 6e61 6d65 2074 /td>rename t │ │ │ -0002b670: 6869 7320 7461 7267 6574 2071 7565 7565 his target queue │ │ │ -0002b680: 2073 697a 653c 2f74 643e 3c2f 7472 3e3c size< │ │ │ -0002b690: 7472 2069 643d 2238 3622 2073 7479 6c65 tr id="86" style │ │ │ -0002b6a0: 3d22 6469 7370 6c61 793a 206e 6f6e 653b ="display: none; │ │ │ -0002b6b0: 2220 636f 6c73 7061 6e3d 2233 223e 3c74 " colspan="3">rename this ta │ │ │ -0002b6e0: 7267 6574 2071 7565 7565 2073 697a 653c rget queue size< │ │ │ -0002b6f0: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ -0002b700: 6465 2f6c 6962 746f 7272 656e 742f 7065 de/libtorrent/pe │ │ │ -0002b710: 6572 5f63 6f6e 6e65 6374 696f 6e2e 6870 er_connection.hp │ │ │ -0002b720: 703a 3130 3836 3c2f 6834 3e3c 7072 6520 p:1086

    ..// this i
    │ │ │ -0002b770: 7320 7468 6520 7069 6563 6520 7468 6174  s the piece that
    │ │ │ -0002b780: 2069 7320 6176 6169 6c61 626c 6520 746f   is available to
    │ │ │ -0002b790: 2074 6869 7320 7065 6572 2e20 4f6e 6c79   this peer. Only
    │ │ │ -0002b7a0: 0a09 092f 2f20 7468 6573 6520 7477 6f20  ...// these two 
    │ │ │ -0002b7b0: 7069 6563 6573 2063 616e 2062 6520 646f  pieces can be do
    │ │ │ -0002b7c0: 776e 6c6f 6164 6564 2066 726f 6d20 7573  wnloaded from us
    │ │ │ -0002b7d0: 2062 7920 7468 6973 2070 6565 722e 0a09   by this peer...
    │ │ │ -0002b7e0: 092f 2f20 5468 6973 2077 696c 6c20 7265  .// This will re
    │ │ │ -0002b7f0: 6d61 696e 2074 6865 2063 7572 7265 6e74  main the current
    │ │ │ -0002b800: 2070 6965 6365 2066 6f72 2074 6869 7320   piece for this 
    │ │ │ -0002b810: 7065 6572 2075 6e74 696c 0a09 092f 2f20  peer until...// 
    │ │ │ -0002b820: 616e 6f74 6865 7220 7065 6572 2073 656e  another peer sen
    │ │ │ -0002b830: 6473 2075 7320 6120 6861 7665 206d 6573  ds us a have mes
    │ │ │ -0002b840: 7361 6765 2066 6f72 2074 6869 7320 7069  sage for this pi
    │ │ │ -0002b850: 6563 650a 0909 7374 643a 3a61 7272 6179  ece...std::array
    │ │ │ -0002b860: 266c 743b 7069 6563 655f 696e 6465 785f  <piece_index_
    │ │ │ -0002b870: 742c 2032 2667 743b 206d 5f73 7570 6572  t, 2> m_super
    │ │ │ -0002b880: 7365 6564 5f70 6965 6365 203d 207b 7b70  seed_piece = {{p
    │ │ │ -0002b890: 6965 6365 5f69 6e64 6578 5f74 282d 3129  iece_index_t(-1)
    │ │ │ -0002b8a0: 2c20 7069 6563 655f 696e 6465 785f 7428  , piece_index_t(
    │ │ │ -0002b8b0: 2d31 297d 7d3b 0a23 656e 6469 660a 0a09  -1)}};.#endif...
    │ │ │ -0002b8c0: 092f 2f20 7468 6520 6e75 6d62 6572 206f  .// the number o
    │ │ │ -0002b8d0: 6620 6279 7465 7320 7365 6e64 2074 6f20  f bytes send to 
    │ │ │ -0002b8e0: 7468 6520 6469 736b 2d69 6f0a 0909 2f2f  the disk-io...//
    │ │ │ -0002b8f0: 2074 6872 6561 6420 7468 6174 2068 6173   thread that has
    │ │ │ -0002b900: 6e27 7420 7965 7420 6265 656e 2063 6f6d  n't yet been com
    │ │ │ -0002b910: 706c 6574 656c 7920 7772 6974 7465 6e2e  pletely written.
    │ │ │ -0002b920: 0a09 0969 6e74 206d 5f6f 7574 7374 616e  ...int m_outstan
    │ │ │ -0002b930: 6469 6e67 5f77 7269 7469 6e67 5f62 7974  ding_writing_byt
    │ │ │ -0002b940: 6573 203d 2030 3b0a 0a09 092f 2f20 6d61  es = 0;....// ma
    │ │ │ -0002b950: 7820 7472 616e 7366 6572 2072 6174 6573  x transfer rates
    │ │ │ -0002b960: 2073 6565 6e20 6f6e 2074 6869 7320 7065   seen on this pe
    │ │ │ -0002b970: 6572 0a09 0969 6e74 206d 5f64 6f77 6e6c  er...int m_downl
    │ │ │ -0002b980: 6f61 645f 7261 7465 5f70 6561 6b20 3d20  oad_rate_peak = 
    │ │ │ -0002b990: 303b 0a09 0969 6e74 206d 5f75 706c 6f61  0;...int m_uploa
    │ │ │ -0002b9a0: 645f 7261 7465 5f70 6561 6b20 3d20 303b  d_rate_peak = 0;
    │ │ │ -0002b9b0: 0a0a 0909 2f2f 2073 746f 7020 7365 6e64  ....// stop send
    │ │ │ -0002b9c0: 696e 6720 6461 7461 2061 6674 6572 2074  ing data after t
    │ │ │ -0002b9d0: 6869 7320 6d61 6e79 2062 7974 6573 2c20  his many bytes, 
    │ │ │ -0002b9e0: 494e 545f 4d41 5820 3d20 696e 660a 0909  INT_MAX = inf...
    │ │ │ -0002b9f0: 696e 7420 6d5f 7365 6e64 5f62 6172 7269  int m_send_barri
    │ │ │ -0002ba00: 6572 203d 2049 4e54 5f4d 4158 3b0a 0a09  er = INT_MAX;...
    │ │ │ -0002ba10: 092f 2f20 7468 6520 6e75 6d62 6572 206f  .// the number o
    │ │ │ -0002ba20: 6620 7265 7175 6573 7420 7765 2073 686f  f request we sho
    │ │ │ -0002ba30: 756c 6420 7175 6575 6520 7570 0a09 092f  uld queue up.../
    │ │ │ -0002ba40: 2f20 6174 2074 6865 2072 656d 6f74 6520  / at the remote 
    │ │ │ -0002ba50: 656e 642e 0a3c 6469 7620 7374 796c 653d  end..
    ..std::uint16 │ │ │ -0002ba90: 5f74 206d 5f64 6573 6972 6564 5f71 7565 _t m_desired_que │ │ │ -0002baa0: 7565 5f73 697a 6520 3d20 343b 0a3c 2f64 ue_size = 4;....// if set │ │ │ -0002bac0: 746f 206e 6f6e 2d7a 6572 6f2c 2074 6869 to non-zero, thi │ │ │ -0002bad0: 7320 7065 6572 2077 696c 6c20 616c 7761 s peer will alwa │ │ │ -0002bae0: 7973 2070 7265 6665 720a 0909 2f2f 2074 ys prefer...// t │ │ │ -0002baf0: 6f20 7265 7175 6573 7420 656e 7469 7265 o request entire │ │ │ -0002bb00: 206e 2070 6965 6365 732c 2072 6174 6865 n pieces, rathe │ │ │ -0002bb10: 7220 7468 616e 2062 6c6f 636b 732e 0a09 r than blocks... │ │ │ -0002bb20: 092f 2f20 7768 6572 6520 6e20 6973 2074 .// where n is t │ │ │ -0002bb30: 6865 2076 616c 7565 206f 6620 7468 6973 he value of this │ │ │ -0002bb40: 2076 6172 6961 626c 652e 0a09 092f 2f20 variable....// │ │ │ -0002bb50: 6966 2069 7420 6973 2030 2c20 7468 6520 if it is 0, the │ │ │ -0002bb60: 646f 776e 6c6f 6164 2072 6174 6520 6c69 download rate li │ │ │ -0002bb70: 6d69 7420 7365 7474 696e 670a 0909 2f2f mit setting...// │ │ │ -0002bb80: 2077 696c 6c20 6265 2075 7365 6420 746f will be used to │ │ │ -0002bb90: 2064 6574 6572 6d69 6e65 2069 6620 7768 determine if wh │ │ │ -0002bba0: 6f6c 6520 7069 6563 6573 0a09 092f 2f20 ole pieces...// │ │ │ -0002bbb0: 6172 6520 7072 6566 6572 7265 642e 0a09 are preferred... │ │ │ -0002bbc0: 0973 7464 3a3a 7569 6e74 3136 5f74 206d .std::uint16_t m │ │ │ -0002bbd0: 5f70 7265 6665 725f 636f 6e74 6967 756f _prefer_contiguo │ │ │ -0002bbe0: 7573 5f62 6c6f 636b 7320 3d20 303b 0a0a us_blocks = 0;.. │ │ │ -0002bbf0: 0909 2f2f 2074 6869 7320 6973 2074 6865 ..// this is the │ │ │ -0002bc00: 206e 756d 6265 7220 6f66 2074 696d 6573 number of times │ │ │ -0002bc10: 2074 6869 7320 7065 6572 2068 6173 2068 this peer has h │ │ │ -0002bc20: 6164 0a09 092f 2f20 6120 7265 7175 6573 ad...// a reques │ │ │ -0002bc30: 7420 7265 6a65 6374 6564 2062 6563 6175 t rejected becau │ │ │ -0002bc40: 7365 206f 6620 6120 6469 736b 2049 2f4f se of a disk I/O │ │ │ -0002bc50: 2066 6169 6c75 7265 2e0a 0909 2f2f 206f failure....// o │ │ │ -0002bc60: 6e63 6520 7468 6973 2072 6561 6368 6573 nce this reaches │ │ │ -0002bc70: 2061 2063 6572 7461 696e 2074 6872 6573 a certain thres │ │ │ -0002bc80: 686f 6c64 2c20 7468 650a 0909 2f2f 2070 hold, the...// p │ │ │ -0002bc90: 6565 7220 6973 2064 6973 636f 6e6e 6563 eer is disconnec │ │ │ -0002bca0: 7465 6420 696e 206f 7264 6572 2074 6f20 ted in order to │ │ │ -0002bcb0: 6176 6f69 6420 696e 6669 6e69 7465 0a09 avoid infinite.. │ │ │ -0002bcc0: 092f 2f20 6c6f 6f70 7320 6f66 2063 6f6e .// loops of con │ │ │ -0002bcd0: 7369 7374 656e 7420 6661 696c 7572 6573 sistent failures │ │ │ -0002bce0: 0a09 0973 7464 3a3a 7569 6e74 385f 7420 ...std::uint8_t │ │ │ -0002bcf0: 6d5f 6469 736b 5f72 6561 645f 6661 696c m_disk_read_fail │ │ │ -0002bd00: 7572 6573 203d 2030 3b0a 0a09 092f 2f20 ures = 0;....// │ │ │ -0002bd10: 7468 6973 2069 7320 7573 6564 2069 6e20 this is used in │ │ │ -0002bd20: 7365 6564 206d 6f64 6520 7768 656e 6576 seed mode whenev │ │ │ -0002bd30: 6572 2077 6520 7472 6967 6765 7220 6120 er we trigger a │ │ │ -0002bd40: 6861 7368 2063 6865 636b 0a09 092f 2f20 hash check...// │ │ │ -0002bd50: 666f 7220 6120 7069 6563 652c 2062 6566 for a piece, bef │ │ │ -0002bd60: 6f72 6520 7765 2072 6561 6420 6974 2e20 ore we read it. │ │ │ -0002bd70: 4974 2773 2075 7365 6420 746f 2074 6872 It's used to thr │ │ │ -0002bd80: 6f74 746c 650a 0909 2f2f 2074 6865 2068 ottle...// the h │ │ │ -0002bd90: 6173 6820 6368 6563 6b73 2074 6f20 6a75 ash checks to ju │ │ │ -0002bda0: 7374 2061 2066 6577 2070 6572 2070 6565 st a few per pee │ │ │ -0002bdb0: 7220 6174 2061 2074 696d 652e 0a09 0973 r at a time....s │ │ │ -0002bdc0: 7464 3a3a 7569 6e74 385f 7420 6d5f 6f75 td::uint8_t m_ou │ │ │ -0002bdd0: 7473 7461 6e64 696e 675f 7069 6563 655f tstanding_piece_ │ │ │ -0002bde0: 7665 7269 6669 6361 7469 6f6e 3a33 3b0a verification:3;. │ │ │ -0002bdf0: 0a09 092f 2f20 6973 2074 7275 6520 6966 ...// is true if │ │ │ -0002be00: 2069 7420 7761 7320 7765 2074 6861 7420 it was we that │ │ │ -0002be10: 636f 6e6e 6563 7465 6420 746f 2074 6865 connected to the │ │ │ -0002be20: 2070 6565 720a 0909 2f2f 2061 6e64 2066 peer...// and f │ │ │ -0002be30: 616c 7365 2069 6620 7765 2067 6f74 2061 alse if we got a │ │ │ -0002be40: 6e20 696e 636f 6d69 6e67 2063 6f6e 6e65 n incoming conne │ │ │ -0002be50: 6374 696f 6e0a 0909 2f2f 2063 6f75 6c64 ction...// could │ │ │ -0002be60: 2062 6520 636f 6e73 6964 6572 6564 3a20 be considered: │ │ │ -0002be70: 7472 7565 203d 206c 6f63 616c 2c20 6661 true = local, fa │ │ │ -0002be80: 6c73 6520 3d20 7265 6d6f 7465 0a09 0962 lse = remote...b │ │ │ -0002be90: 6f6f 6c20 6d5f 6f75 7467 6f69 6e67 3a31 ool m_outgoing:1 │ │ │ -0002bea0: 3b0a 0a09 092f 2f20 6973 2074 7275 6520 ;....// is true │ │ │ -0002beb0: 6966 2077 6520 6c65 6172 6e20 7468 6520 if we learn the │ │ │ -0002bec0: 696e 636f 6d69 6e67 2063 6f6e 6e65 6374 incoming connect │ │ │ -0002bed0: 696f 6e73 206c 6973 7465 6e69 6e67 0a09 ions listening.. │ │ │ -0002bee0: 092f 2f20 6475 7269 6e67 2074 6865 2065 .// during the e │ │ │ -0002bef0: 7874 656e 6465 6420 6861 6e64 7368 616b xtended handshak │ │ │ -0002bf00: 650a 0909 626f 6f6c 206d 5f72 6563 6569 e...bool m_recei │ │ │ -0002bf10: 7665 645f 6c69 7374 656e 5f70 6f72 743a ved_listen_port: │ │ │ -0002bf20: 313b 0a0a 3c2f 7072 653e 3c2f 7464 3e3c 1;..
    < │ │ │ +00029430: 2f70 726f 7879 5f62 6173 652e 6870 703a /proxy_base.hpp: │ │ │ +00029440: 3332 383c 2f61 3e3c 2f74 643e 3c74 643e 328 │ │ │ +00029450: 7573 6520 7468 6520 7265 736f 6c76 6572 use the resolver │ │ │ +00029460: 2069 6e74 6572 6661 6365 2074 6861 7420 interface that │ │ │ +00029470: 6861 7320 6120 6275 696c 742d 696e 2063 has a built-in c │ │ │ +00029480: 6163 6865 3c2f 7464 3e3c 2f74 723e 3c74 ache

    use the resolve │ │ │ +000294e0: 7220 696e 7465 7266 6163 6520 7468 6174 r interface that │ │ │ +000294f0: 2068 6173 2061 2062 7569 6c74 2d69 6e20 has a built-in │ │ │ +00029500: 6361 6368 653c 2f68 323e 3c68 343e 2e2e cache

    .. │ │ │ +00029510: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ +00029520: 656e 742f 7072 6f78 795f 6261 7365 2e68 ent/proxy_base.h │ │ │ +00029530: 7070 3a33 3238 3c2f 6834 3e3c 7072 6520 pp:328

    .// The han
    │ │ │ +00029580: 646c 6572 206d 7573 7420 6265 2074 616b  dler must be tak
    │ │ │ +00029590: 656e 2061 7320 6c76 616c 7565 2072 6566  en as lvalue ref
    │ │ │ +000295a0: 6572 656e 6365 2068 6572 6520 7369 6e63  erence here sinc
    │ │ │ +000295b0: 6520 7765 206d 6179 206e 6f74 2063 616c  e we may not cal
    │ │ │ +000295c0: 6c0a 092f 2f20 6974 2e20 4275 7420 6966  l..// it. But if
    │ │ │ +000295d0: 2077 6520 646f 2c20 7765 2077 616e 7420   we do, we want 
    │ │ │ +000295e0: 7468 6520 6361 6c6c 206f 7065 7261 746f  the call operato
    │ │ │ +000295f0: 7220 746f 206f 776e 2074 6865 2066 756e  r to own the fun
    │ │ │ +00029600: 6374 696f 6e20 6f62 6a65 6374 2e0a 0974  ction object...t
    │ │ │ +00029610: 656d 706c 6174 6520 266c 743b 7479 7065  emplate <type
    │ │ │ +00029620: 6e61 6d65 2048 616e 646c 6572 2667 743b  name Handler>
    │ │ │ +00029630: 0a09 626f 6f6c 2068 616e 646c 655f 6572  ..bool handle_er
    │ │ │ +00029640: 726f 7228 6572 726f 725f 636f 6465 2065  ror(error_code e
    │ │ │ +00029650: 2c20 4861 6e64 6c65 7226 616d 703b 2661  , Handler&&a
    │ │ │ +00029660: 6d70 3b20 6829 0a09 7b0a 0909 544f 5252  mp; h)..{...TORR
    │ │ │ +00029670: 454e 545f 4153 5345 5254 286d 5f6d 6167  ENT_ASSERT(m_mag
    │ │ │ +00029680: 6963 203d 3d20 3078 3133 3337 293b 0a09  ic == 0x1337);..
    │ │ │ +00029690: 0969 6620 2821 6529 2072 6574 7572 6e20  .if (!e) return 
    │ │ │ +000296a0: 6661 6c73 653b 0a09 0965 7272 6f72 5f63  false;...error_c
    │ │ │ +000296b0: 6f64 6520 6563 3b0a 0909 2f2f 2070 7265  ode ec;...// pre
    │ │ │ +000296c0: 7665 6e74 206c 6966 6574 696d 6520 6d61  vent lifetime ma
    │ │ │ +000296d0: 6e61 6765 6d65 6e74 2075 7365 2d61 6674  nagement use-aft
    │ │ │ +000296e0: 6572 2d66 7265 650a 0909 636c 6f73 6528  er-free...close(
    │ │ │ +000296f0: 6563 293b 202f 2f20 636c 6f73 6520 6669  ec); // close fi
    │ │ │ +00029700: 7273 740a 0909 7374 643a 3a6d 6f76 6528  rst...std::move(
    │ │ │ +00029710: 6829 2865 293b 202f 2f20 636f 6e73 756d  h)(e); // consum
    │ │ │ +00029720: 650a 0909 7265 7475 726e 2074 7275 653b  e...return true;
    │ │ │ +00029730: 0a09 7d0a 0a09 6175 783a 3a6e 6f65 7863  ..}...aux::noexc
    │ │ │ +00029740: 6570 745f 6d6f 7661 626c 6526 6c74 3b74  ept_movable<t
    │ │ │ +00029750: 6370 3a3a 736f 636b 6574 2667 743b 206d  cp::socket> m
    │ │ │ +00029760: 5f73 6f63 6b3b 0a09 7374 643a 3a73 7472  _sock;..std::str
    │ │ │ +00029770: 696e 6720 6d5f 686f 7374 6e61 6d65 3b20  ing m_hostname; 
    │ │ │ +00029780: 2f2f 2070 726f 7879 2068 6f73 740a 0969  // proxy host..i
    │ │ │ +00029790: 6e74 206d 5f70 6f72 7420 3d20 303b 2020  nt m_port = 0;  
    │ │ │ +000297a0: 2020 2020 2020 202f 2f20 7072 6f78 7920         // proxy 
    │ │ │ +000297b0: 706f 7274 0a0a 0961 7578 3a3a 6e6f 6578  port...aux::noex
    │ │ │ +000297c0: 6365 7074 5f6d 6f76 6162 6c65 266c 743b  cept_movable<
    │ │ │ +000297d0: 656e 6470 6f69 6e74 5f74 7970 6526 6774  endpoint_type>
    │ │ │ +000297e0: 3b20 6d5f 7265 6d6f 7465 5f65 6e64 706f  ; m_remote_endpo
    │ │ │ +000297f0: 696e 743b 0a0a 3c64 6976 2073 7479 6c65  int;..
    .aux::noexce │ │ │ +00029830: 7074 5f6d 6f76 655f 6f6e 6c79 266c 743b pt_move_only< │ │ │ +00029840: 7463 703a 3a72 6573 6f6c 7665 7226 6774 tcp::resolver> │ │ │ +00029850: 3b20 6d5f 7265 736f 6c76 6572 3b0a 3c2f ; m_resolver;..#if TORRENT │ │ │ +00029870: 5f55 5345 5f41 5353 4552 5453 0a09 696e _USE_ASSERTS..in │ │ │ +00029880: 7420 6d5f 6d61 6769 6320 3d20 3078 3133 t m_magic = 0x13 │ │ │ +00029890: 3337 3b0a 2365 6e64 6966 0a7d 3b0a 0a74 37;.#endif.};..t │ │ │ +000298a0: 656d 706c 6174 6520 266c 743b 7479 7065 emplate <type │ │ │ +000298b0: 6e61 6d65 2048 616e 646c 6572 2c20 7479 name Handler, ty │ │ │ +000298c0: 7065 6e61 6d65 2055 6e64 6572 6c79 696e pename Underlyin │ │ │ +000298d0: 6748 616e 646c 6572 2667 743b 0a73 7472 gHandler>.str │ │ │ +000298e0: 7563 7420 7772 6170 5f61 6c6c 6f63 6174 uct wrap_allocat │ │ │ +000298f0: 6f72 5f74 0a7b 0a09 7772 6170 5f61 6c6c or_t.{..wrap_all │ │ │ +00029900: 6f63 6174 6f72 5f74 2848 616e 646c 6572 ocator_t(Handler │ │ │ +00029910: 2068 2c20 556e 6465 726c 7969 6e67 4861 h, UnderlyingHa │ │ │ +00029920: 6e64 6c65 7220 7568 290a 0909 3a20 6d5f ndler uh)...: m_ │ │ │ +00029930: 6861 6e64 6c65 7228 7374 643a 3a6d 6f76 handler(std::mov │ │ │ +00029940: 6528 6829 290a 0909 2c20 6d5f 756e 6465 e(h))..., m_unde │ │ │ +00029950: 726c 7969 6e67 5f68 616e 646c 6572 2873 rlying_handler(s │ │ │ +00029960: 7464 3a3a 6d6f 7665 2875 6829 290a 097b td::move(uh))..{ │ │ │ +00029970: 7d0a 0a09 7772 6170 5f61 6c6c 6f63 6174 }...wrap_allocat │ │ │ +00029980: 6f72 5f74 2877 7261 705f 616c 6c6f 6361 or_t(wrap_alloca │ │ │ +00029990: 746f 725f 7420 636f 6e73 7426 616d 703b tor_t const& │ │ │ +000299a0: 2920 3d20 6465 6661 756c 743b 0a09 7772 ) = default;..wr │ │ │ +000299b0: 6170 5f61 6c6c 6f63 6174 6f72 5f74 2877 ap_allocator_t(w │ │ │ +000299c0: 7261 705f 616c 6c6f 6361 746f 725f 7426 rap_allocator_t& │ │ │ +000299d0: 616d 703b 2661 6d70 3b29 203d 2064 6566 amp;&) = def │ │ │ +000299e0: 6175 6c74 3b0a 0a09 7465 6d70 6c61 7465 ault;...template │ │ │ +000299f0: 2026 6c74 3b63 6c61 7373 2e2e 2e20 4126 <class... A& │ │ │ +00029a00: 6774 3b0a 0976 6f69 6420 6f70 6572 6174 gt;..void operat │ │ │ +00029a10: 6f72 2829 2841 2661 6d70 3b26 616d 703b or()(A&& │ │ │ +00029a20: 2e2e 2e20 6129 0a09 7b0a 0909 6d5f 6861 ... a)..{...m_ha │ │ │ +00029a30: 6e64 6c65 7228 7374 643a 3a66 6f72 7761 ndler(std::forwa │ │ │ +00029a40: 7264 266c 743b 4126 6774 3b28 6129 2e2e rd<A>(a).. │ │ │ +00029a50: 2e2c 2073 7464 3a3a 6d6f 7665 286d 5f75 ., std::move(m_u │ │ │ +00029a60: 6e64 6572 6c79 696e 675f 6861 6e64 6c65 nderlying_handle │ │ │ +00029a70: 7229 293b 0a09 7d0a 0a09 7573 696e 6720 r));..}...using │ │ │ +00029a80: 616c 6c6f 6361 746f 725f 7479 7065 203d allocator_type = │ │ │ +00029a90: 2074 7970 656e 616d 6520 626f 6f73 743a typename boost: │ │ │ +00029aa0: 3a61 7369 6f3a 3a61 7373 6f63 6961 7465 :asio::associate │ │ │ +00029ab0: 645f 616c 6c6f 6361 746f 7226 6c74 3b55 d_allocator<U │ │ │ +00029ac0: 6e64 6572 6c79 696e 6748 616e 646c 6572 nderlyingHandler │ │ │ +00029ad0: 2667 743b 3a3a 7479 7065 3b0a 0975 7369 >::type;..usi │ │ │ +00029ae0: 6e67 2065 7865 6375 746f 725f 7479 7065 ng executor_type │ │ │ +00029af0: 203d 2074 7970 656e 616d 6520 626f 6f73 = typename boos │ │ │ +00029b00: 743a 3a61 7369 6f3a 3a61 7373 6f63 6961 t::asio::associa │ │ │ +00029b10: 7465 645f 6578 6563 7574 6f72 266c 743b ted_executor< │ │ │ +00029b20: 556e 6465 726c 7969 6e67 4861 6e64 6c65 UnderlyingHandle │ │ │ +00029b30: 7226 6774 3b3a 3a74 7970 653b 0a0a 0961 r>::type;...a │ │ │ +00029b40: 6c6c 6f63 6174 6f72 5f74 7970 6520 6765 llocator_type ge │ │ │ +00029b50: 745f 616c 6c6f 6361 746f 7228 2920 636f t_allocator() co │ │ │ +00029b60: 6e73 7420 6e6f 6578 6365 7074 0a09 7b20 nst noexcept..{ │ │ │ +00029b70: 7265 7475 726e 2062 6f6f 7374 3a3a 6173 return boost::as │ │ │ +00029b80: 696f 3a3a 6765 745f 6173 736f 6369 6174 io::get_associat │ │ │ +00029b90: 6564 5f61 6c6c 6f63 6174 6f72 286d 5f75 ed_allocator(m_u │ │ │ +00029ba0: 6e64 6572 6c79 696e 675f 6861 6e64 6c65 nderlying_handle │ │ │ +00029bb0: 7229 3b20 7d0a 0a09 6578 6563 7574 6f72 r); }...executor │ │ │ +00029bc0: 5f74 7970 6520 6765 745f 6578 6563 7574 _type get_execut │ │ │ +00029bd0: 6f72 2829 2063 6f6e 7374 206e 6f65 7863 or() const noexc │ │ │ +00029be0: 6570 740a 3c2f 7072 653e 3c2f 7464 3e3c ept.
    < │ │ │ +00029bf0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +00029c20: 6273 703b 323c 2f74 643e 3c74 643e 3c61 bsp;2.. │ │ │ +00029c50: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ +00029c60: 656e 742f 7065 6572 5f63 6f6e 6e65 6374 ent/peer_connect │ │ │ +00029c70: 696f 6e2e 6870 703a 3939 363c 2f61 3e3c ion.hpp:996< │ │ │ +00029c80: 2f74 643e 3c74 643e 7468 6973 2073 686f /td>this sho │ │ │ +00029c90: 756c 6420 7265 616c 6c79 2062 6520 6120 uld really be a │ │ │ +00029ca0: 6369 7263 756c 6172 2062 7566 6665 723c circular buffer< │ │ │ +00029cb0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    this │ │ │ +00029d00: 2073 686f 756c 6420 7265 616c 6c79 2062 should really b │ │ │ +00029d10: 6520 6120 6369 7263 756c 6172 2062 7566 e a circular buf │ │ │ +00029d20: 6665 723c 2f68 323e 3c68 343e 2e2e 2f69 fer

    ../i │ │ │ +00029d30: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ +00029d40: 742f 7065 6572 5f63 6f6e 6e65 6374 696f t/peer_connectio │ │ │ +00029d50: 6e2e 6870 703a 3939 363c 2f68 343e 3c70 n.hpp:996

    ..// it │ │ │ +00029da0: 6a75 7374 2073 6572 7665 7320 6173 2061 just serves as a │ │ │ +00029db0: 2071 7565 7565 2074 6f20 7265 6d65 6d62 queue to rememb │ │ │ +00029dc0: 6572 2077 6861 7420 7765 2776 6520 7365 er what we've se │ │ │ +00029dd0: 6e74 2c20 746f 2061 766f 6964 0a09 092f nt, to avoid.../ │ │ │ +00029de0: 2f20 7265 2d73 656e 6469 6e67 2073 7567 / re-sending sug │ │ │ +00029df0: 6765 7374 7320 666f 7220 7468 6520 7361 gests for the sa │ │ │ +00029e00: 6d65 2070 6965 6365 0a09 092f 2f20 692e me piece...// i. │ │ │ +00029e10: 652e 206f 7574 676f 696e 6720 7375 6767 e. outgoing sugg │ │ │ +00029e20: 6573 7420 7069 6563 6573 0a09 0961 7578 est pieces...aux │ │ │ +00029e30: 3a3a 7665 6374 6f72 266c 743b 7069 6563 ::vector<piec │ │ │ +00029e40: 655f 696e 6465 785f 7426 6774 3b20 6d5f e_index_t> m_ │ │ │ +00029e50: 7375 6767 6573 745f 7069 6563 6573 3b0a suggest_pieces;. │ │ │ +00029e60: 0a09 092f 2f20 7468 6520 7069 6563 6573 ...// the pieces │ │ │ +00029e70: 2077 6520 7769 6c6c 2073 656e 6420 746f we will send to │ │ │ +00029e80: 2074 6865 2070 6565 720a 0909 2f2f 2069 the peer...// i │ │ │ +00029e90: 6620 7265 7175 6573 7465 6420 2872 6567 f requested (reg │ │ │ +00029ea0: 6172 646c 6573 7320 6f66 2063 686f 6b65 ardless of choke │ │ │ +00029eb0: 2073 7461 7465 290a 0909 7374 643a 3a76 state)...std::v │ │ │ +00029ec0: 6563 746f 7226 6c74 3b70 6965 6365 5f69 ector<piece_i │ │ │ +00029ed0: 6e64 6578 5f74 2667 743b 206d 5f61 6363 ndex_t> m_acc │ │ │ +00029ee0: 6570 745f 6661 7374 3b0a 0a09 092f 2f20 ept_fast;....// │ │ │ +00029ef0: 6120 7365 6e74 2d70 6965 6365 2063 6f75 a sent-piece cou │ │ │ +00029f00: 6e74 6572 2066 6f72 2074 6865 2061 6c6c nter for the all │ │ │ +00029f10: 6f77 6564 2066 6173 7420 7365 740a 0909 owed fast set... │ │ │ +00029f20: 2f2f 2074 6f20 6176 6f69 6420 6578 706c // to avoid expl │ │ │ +00029f30: 6f69 7461 7469 6f6e 2e20 4561 6368 2073 oitation. Each s │ │ │ +00029f40: 6c6f 7420 6973 2061 2063 6f75 6e74 6572 lot is a counter │ │ │ +00029f50: 0a09 092f 2f20 666f 7220 6f6e 6520 6f66 ...// for one of │ │ │ +00029f60: 2074 6865 2070 6965 6365 7320 6672 6f6d the pieces from │ │ │ +00029f70: 2074 6865 2061 6c6c 6f77 6564 2d66 6173 the allowed-fas │ │ │ +00029f80: 7420 7365 740a 0909 6175 783a 3a76 6563 t set...aux::vec │ │ │ +00029f90: 746f 7226 6c74 3b73 7464 3a3a 7569 6e74 tor<std::uint │ │ │ +00029fa0: 3136 5f74 2667 743b 206d 5f61 6363 6570 16_t> m_accep │ │ │ +00029fb0: 745f 6661 7374 5f70 6965 6365 5f63 6e74 t_fast_piece_cnt │ │ │ +00029fc0: 3b0a 0a09 092f 2f20 7468 6520 7069 6563 ;....// the piec │ │ │ +00029fd0: 6573 2074 6865 2070 6565 7220 7769 6c6c es the peer will │ │ │ +00029fe0: 2073 656e 6420 7573 2069 660a 0909 2f2f send us if...// │ │ │ +00029ff0: 2072 6571 7565 7374 6564 2028 7265 6761 requested (rega │ │ │ +0002a000: 7264 6c65 7373 206f 6620 6368 6f6b 6520 rdless of choke │ │ │ +0002a010: 7374 6174 6529 0a09 0973 7464 3a3a 7665 state)...std::ve │ │ │ +0002a020: 6374 6f72 266c 743b 7069 6563 655f 696e ctor<piece_in │ │ │ +0002a030: 6465 785f 7426 6774 3b20 6d5f 616c 6c6f dex_t> m_allo │ │ │ +0002a040: 7765 645f 6661 7374 3b0a 0a09 092f 2f20 wed_fast;....// │ │ │ +0002a050: 7069 6563 6573 2074 6861 7420 6861 7320 pieces that has │ │ │ +0002a060: 6265 656e 2073 7567 6765 7374 6564 2074 been suggested t │ │ │ +0002a070: 6f20 6265 2064 6f77 6e6c 6f61 6465 6420 o be downloaded │ │ │ +0002a080: 6672 6f6d 2074 6869 7320 7065 6572 0a09 from this peer.. │ │ │ +0002a090: 092f 2f20 692e 652e 2069 6e63 6f6d 696e .// i.e. incomin │ │ │ +0002a0a0: 6720 7375 6767 6573 7469 6f6e 730a 3c64 g suggestions...au │ │ │ +0002a0e0: 783a 3a76 6563 746f 7226 6c74 3b70 6965 x::vector<pie │ │ │ +0002a0f0: 6365 5f69 6e64 6578 5f74 2667 743b 206d ce_index_t> m │ │ │ +0002a100: 5f73 7567 6765 7374 6564 5f70 6965 6365 _suggested_piece │ │ │ +0002a110: 733b 0a3c 2f64 6976 3e0a 0909 2f2f 2074 s;....// t │ │ │ +0002a120: 6865 2074 696d 6520 7768 656e 2074 6869 he time when thi │ │ │ +0002a130: 7320 7065 6572 206c 6173 7420 7361 7720 s peer last saw │ │ │ +0002a140: 6120 636f 6d70 6c65 7465 2063 6f70 790a a complete copy. │ │ │ +0002a150: 0909 2f2f 206f 6620 7468 6973 2074 6f72 ..// of this tor │ │ │ +0002a160: 7265 6e74 0a09 0974 696d 655f 7420 6d5f rent...time_t m_ │ │ │ +0002a170: 6c61 7374 5f73 6565 6e5f 636f 6d70 6c65 last_seen_comple │ │ │ +0002a180: 7465 203d 2030 3b0a 0a09 092f 2f20 7468 te = 0;....// th │ │ │ +0002a190: 6520 626c 6f63 6b20 7765 2772 6520 6375 e block we're cu │ │ │ +0002a1a0: 7272 656e 746c 7920 7265 6365 6976 696e rrently receivin │ │ │ +0002a1b0: 672e 204f 720a 0909 2f2f 2028 2d31 2c20 g. Or...// (-1, │ │ │ +0002a1c0: 2d31 2920 6966 2077 6527 7265 206e 6f74 -1) if we're not │ │ │ +0002a1d0: 2072 6563 6569 7669 6e67 206f 6e65 0a09 receiving one.. │ │ │ +0002a1e0: 0970 6965 6365 5f62 6c6f 636b 206d 5f72 .piece_block m_r │ │ │ +0002a1f0: 6563 6569 7669 6e67 5f62 6c6f 636b 203d eceiving_block = │ │ │ +0002a200: 2070 6965 6365 5f62 6c6f 636b 3a3a 696e piece_block::in │ │ │ +0002a210: 7661 6c69 643b 0a0a 0909 2f2f 2074 6865 valid;....// the │ │ │ +0002a220: 206c 6f63 616c 2065 6e64 706f 696e 7420 local endpoint │ │ │ +0002a230: 666f 7220 7468 6973 2070 6565 722c 2069 for this peer, i │ │ │ +0002a240: 2e65 2e20 6f75 7220 6164 6472 6573 730a .e. our address. │ │ │ +0002a250: 0909 2f2f 2061 6e64 206f 7572 2070 6f72 ..// and our por │ │ │ +0002a260: 742e 2049 6620 7468 6973 2069 7320 7365 t. If this is se │ │ │ +0002a270: 7420 666f 7220 6f75 7467 6f69 6e67 2063 t for outgoing c │ │ │ +0002a280: 6f6e 6e65 6374 696f 6e73 0a09 092f 2f20 onnections...// │ │ │ +0002a290: 6265 666f 7265 2074 6865 2063 6f6e 6e65 before the conne │ │ │ +0002a2a0: 6374 696f 6e20 636f 6d70 6c65 7465 732c ction completes, │ │ │ +0002a2b0: 2069 7420 6d65 616e 7320 7765 2077 616e it means we wan │ │ │ +0002a2c0: 7420 746f 0a09 092f 2f20 666f 7263 6520 t to...// force │ │ │ +0002a2d0: 7468 6520 636f 6e6e 6563 7469 6f6e 2074 the connection t │ │ │ +0002a2e0: 6f20 6265 2062 6f75 6e64 2074 6f20 7468 o be bound to th │ │ │ +0002a2f0: 6520 7370 6563 6966 6965 6420 696e 7465 e specified inte │ │ │ +0002a300: 7266 6163 652e 0a09 092f 2f20 6966 2069 rface....// if i │ │ │ +0002a310: 7420 656e 6473 2075 7020 6265 696e 6720 t ends up being │ │ │ +0002a320: 626f 756e 6420 746f 2061 2064 6966 6665 bound to a diffe │ │ │ +0002a330: 7265 6e74 206c 6f63 616c 2049 502c 2074 rent local IP, t │ │ │ +0002a340: 6865 2063 6f6e 6e65 6374 696f 6e0a 0909 he connection... │ │ │ +0002a350: 2f2f 2069 7320 636c 6f73 6564 2e0a 0909 // is closed.... │ │ │ +0002a360: 7463 703a 3a65 6e64 706f 696e 7420 6d5f tcp::endpoint m_ │ │ │ +0002a370: 6c6f 6361 6c3b 0a0a 0909 2f2f 2072 656d local;....// rem │ │ │ +0002a380: 6f74 6520 7065 6572 2773 2069 640a 0909 ote peer's id... │ │ │ +0002a390: 7065 6572 5f69 6420 6d5f 7065 6572 5f69 peer_id m_peer_i │ │ │ +0002a3a0: 643b 0a0a 0970 726f 7465 6374 6564 3a0a d;...protected:. │ │ │ +0002a3b0: 0a09 0974 656d 706c 6174 6520 266c 743b ...template < │ │ │ +0002a3c0: 7479 7065 6e61 6d65 2046 756e 2c20 7479 typename Fun, ty │ │ │ +0002a3d0: 7065 6e61 6d65 2e2e 2e20 4172 6773 2667 pename... Args&g │ │ │ +0002a3e0: 743b 0a09 0976 6f69 6420 7772 6170 2846 t;...void wrap(F │ │ │ +0002a3f0: 756e 2066 2c20 4172 6773 2661 6d70 3b26 un f, Args&& │ │ │ +0002a400: 616d 703b 2e2e 2e20 6129 3b0a 0a09 092f amp;... a);..../ │ │ │ +0002a410: 2f20 7374 6174 6973 7469 6373 2061 626f / statistics abo │ │ │ +0002a420: 7574 2075 706c 6f61 6420 616e 6420 646f ut upload and do │ │ │ +0002a430: 776e 6c6f 6164 2073 7065 6564 730a 0909 wnload speeds... │ │ │ +0002a440: 2f2f 2061 6e64 2074 6f74 616c 2061 6d6f // and total amo │ │ │ +0002a450: 756e 7420 6f66 2075 706c 6f61 6473 2061 unt of uploads a │ │ │ +0002a460: 6e64 2064 6f77 6e6c 6f61 6473 2066 6f72 nd downloads for │ │ │ +0002a470: 0a09 092f 2f20 7468 6973 2070 6565 720a ...// this peer. │ │ │ +0002a480: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e │ │ │ +0002a490: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +0002a4c0: 323c 2f74 643e 3c74 643e 3c61 2068 7265 2../inc │ │ │ +0002a4f0: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ +0002a500: 7065 6572 5f63 6f6e 6e65 6374 696f 6e2e peer_connection. │ │ │ +0002a510: 6870 703a 3130 3836 3c2f 613e 3c2f 7464 hpp:1086rename this │ │ │ +0002a530: 2074 6172 6765 7420 7175 6575 6520 7369 target queue si │ │ │ +0002a540: 7a65 3c2f 7464 3e3c 2f74 723e 3c74 7220 ze

    r │ │ │ +0002a590: 656e 616d 6520 7468 6973 2074 6172 6765 ename this targe │ │ │ +0002a5a0: 7420 7175 6575 6520 7369 7a65 3c2f 6832 t queue size

    ../include/ │ │ │ +0002a5c0: 6c69 6274 6f72 7265 6e74 2f70 6565 725f libtorrent/peer_ │ │ │ +0002a5d0: 636f 6e6e 6563 7469 6f6e 2e68 7070 3a31 connection.hpp:1 │ │ │ +0002a5e0: 3038 363c 2f68 343e 3c70 7265 2073 7479 086

    ..// this is t
    │ │ │ +0002a630: 6865 2070 6965 6365 2074 6861 7420 6973  he piece that is
    │ │ │ +0002a640: 2061 7661 696c 6162 6c65 2074 6f20 7468   available to th
    │ │ │ +0002a650: 6973 2070 6565 722e 204f 6e6c 790a 0909  is peer. Only...
    │ │ │ +0002a660: 2f2f 2074 6865 7365 2074 776f 2070 6965  // these two pie
    │ │ │ +0002a670: 6365 7320 6361 6e20 6265 2064 6f77 6e6c  ces can be downl
    │ │ │ +0002a680: 6f61 6465 6420 6672 6f6d 2075 7320 6279  oaded from us by
    │ │ │ +0002a690: 2074 6869 7320 7065 6572 2e0a 0909 2f2f   this peer....//
    │ │ │ +0002a6a0: 2054 6869 7320 7769 6c6c 2072 656d 6169   This will remai
    │ │ │ +0002a6b0: 6e20 7468 6520 6375 7272 656e 7420 7069  n the current pi
    │ │ │ +0002a6c0: 6563 6520 666f 7220 7468 6973 2070 6565  ece for this pee
    │ │ │ +0002a6d0: 7220 756e 7469 6c0a 0909 2f2f 2061 6e6f  r until...// ano
    │ │ │ +0002a6e0: 7468 6572 2070 6565 7220 7365 6e64 7320  ther peer sends 
    │ │ │ +0002a6f0: 7573 2061 2068 6176 6520 6d65 7373 6167  us a have messag
    │ │ │ +0002a700: 6520 666f 7220 7468 6973 2070 6965 6365  e for this piece
    │ │ │ +0002a710: 0a09 0973 7464 3a3a 6172 7261 7926 6c74  ...std::array<
    │ │ │ +0002a720: 3b70 6965 6365 5f69 6e64 6578 5f74 2c20  ;piece_index_t, 
    │ │ │ +0002a730: 3226 6774 3b20 6d5f 7375 7065 7273 6565  2> m_supersee
    │ │ │ +0002a740: 645f 7069 6563 6520 3d20 7b7b 7069 6563  d_piece = {{piec
    │ │ │ +0002a750: 655f 696e 6465 785f 7428 2d31 292c 2070  e_index_t(-1), p
    │ │ │ +0002a760: 6965 6365 5f69 6e64 6578 5f74 282d 3129  iece_index_t(-1)
    │ │ │ +0002a770: 7d7d 3b0a 2365 6e64 6966 0a0a 0909 2f2f  }};.#endif....//
    │ │ │ +0002a780: 2074 6865 206e 756d 6265 7220 6f66 2062   the number of b
    │ │ │ +0002a790: 7974 6573 2073 656e 6420 746f 2074 6865  ytes send to the
    │ │ │ +0002a7a0: 2064 6973 6b2d 696f 0a09 092f 2f20 7468   disk-io...// th
    │ │ │ +0002a7b0: 7265 6164 2074 6861 7420 6861 736e 2774  read that hasn't
    │ │ │ +0002a7c0: 2079 6574 2062 6565 6e20 636f 6d70 6c65   yet been comple
    │ │ │ +0002a7d0: 7465 6c79 2077 7269 7474 656e 2e0a 0909  tely written....
    │ │ │ +0002a7e0: 696e 7420 6d5f 6f75 7473 7461 6e64 696e  int m_outstandin
    │ │ │ +0002a7f0: 675f 7772 6974 696e 675f 6279 7465 7320  g_writing_bytes 
    │ │ │ +0002a800: 3d20 303b 0a0a 0909 2f2f 206d 6178 2074  = 0;....// max t
    │ │ │ +0002a810: 7261 6e73 6665 7220 7261 7465 7320 7365  ransfer rates se
    │ │ │ +0002a820: 656e 206f 6e20 7468 6973 2070 6565 720a  en on this peer.
    │ │ │ +0002a830: 0909 696e 7420 6d5f 646f 776e 6c6f 6164  ..int m_download
    │ │ │ +0002a840: 5f72 6174 655f 7065 616b 203d 2030 3b0a  _rate_peak = 0;.
    │ │ │ +0002a850: 0909 696e 7420 6d5f 7570 6c6f 6164 5f72  ..int m_upload_r
    │ │ │ +0002a860: 6174 655f 7065 616b 203d 2030 3b0a 0a09  ate_peak = 0;...
    │ │ │ +0002a870: 092f 2f20 7374 6f70 2073 656e 6469 6e67  .// stop sending
    │ │ │ +0002a880: 2064 6174 6120 6166 7465 7220 7468 6973   data after this
    │ │ │ +0002a890: 206d 616e 7920 6279 7465 732c 2049 4e54   many bytes, INT
    │ │ │ +0002a8a0: 5f4d 4158 203d 2069 6e66 0a09 0969 6e74  _MAX = inf...int
    │ │ │ +0002a8b0: 206d 5f73 656e 645f 6261 7272 6965 7220   m_send_barrier 
    │ │ │ +0002a8c0: 3d20 494e 545f 4d41 583b 0a0a 0909 2f2f  = INT_MAX;....//
    │ │ │ +0002a8d0: 2074 6865 206e 756d 6265 7220 6f66 2072   the number of r
    │ │ │ +0002a8e0: 6571 7565 7374 2077 6520 7368 6f75 6c64  equest we should
    │ │ │ +0002a8f0: 2071 7565 7565 2075 700a 0909 2f2f 2061   queue up...// a
    │ │ │ +0002a900: 7420 7468 6520 7265 6d6f 7465 2065 6e64  t the remote end
    │ │ │ +0002a910: 2e0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +0002a940: 0909 7374 643a 3a75 696e 7431 365f 7420 ..std::uint16_t │ │ │ +0002a950: 6d5f 6465 7369 7265 645f 7175 6575 655f m_desired_queue_ │ │ │ +0002a960: 7369 7a65 203d 2034 3b0a 3c2f 6469 763e size = 4;.
    │ │ │ +0002a970: 0a09 092f 2f20 6966 2073 6574 2074 6f20 ...// if set to │ │ │ +0002a980: 6e6f 6e2d 7a65 726f 2c20 7468 6973 2070 non-zero, this p │ │ │ +0002a990: 6565 7220 7769 6c6c 2061 6c77 6179 7320 eer will always │ │ │ +0002a9a0: 7072 6566 6572 0a09 092f 2f20 746f 2072 prefer...// to r │ │ │ +0002a9b0: 6571 7565 7374 2065 6e74 6972 6520 6e20 equest entire n │ │ │ +0002a9c0: 7069 6563 6573 2c20 7261 7468 6572 2074 pieces, rather t │ │ │ +0002a9d0: 6861 6e20 626c 6f63 6b73 2e0a 0909 2f2f han blocks....// │ │ │ +0002a9e0: 2077 6865 7265 206e 2069 7320 7468 6520 where n is the │ │ │ +0002a9f0: 7661 6c75 6520 6f66 2074 6869 7320 7661 value of this va │ │ │ +0002aa00: 7269 6162 6c65 2e0a 0909 2f2f 2069 6620 riable....// if │ │ │ +0002aa10: 6974 2069 7320 302c 2074 6865 2064 6f77 it is 0, the dow │ │ │ +0002aa20: 6e6c 6f61 6420 7261 7465 206c 696d 6974 nload rate limit │ │ │ +0002aa30: 2073 6574 7469 6e67 0a09 092f 2f20 7769 setting...// wi │ │ │ +0002aa40: 6c6c 2062 6520 7573 6564 2074 6f20 6465 ll be used to de │ │ │ +0002aa50: 7465 726d 696e 6520 6966 2077 686f 6c65 termine if whole │ │ │ +0002aa60: 2070 6965 6365 730a 0909 2f2f 2061 7265 pieces...// are │ │ │ +0002aa70: 2070 7265 6665 7272 6564 2e0a 0909 7374 preferred....st │ │ │ +0002aa80: 643a 3a75 696e 7431 365f 7420 6d5f 7072 d::uint16_t m_pr │ │ │ +0002aa90: 6566 6572 5f63 6f6e 7469 6775 6f75 735f efer_contiguous_ │ │ │ +0002aaa0: 626c 6f63 6b73 203d 2030 3b0a 0a09 092f blocks = 0;..../ │ │ │ +0002aab0: 2f20 7468 6973 2069 7320 7468 6520 6e75 / this is the nu │ │ │ +0002aac0: 6d62 6572 206f 6620 7469 6d65 7320 7468 mber of times th │ │ │ +0002aad0: 6973 2070 6565 7220 6861 7320 6861 640a is peer has had. │ │ │ +0002aae0: 0909 2f2f 2061 2072 6571 7565 7374 2072 ..// a request r │ │ │ +0002aaf0: 656a 6563 7465 6420 6265 6361 7573 6520 ejected because │ │ │ +0002ab00: 6f66 2061 2064 6973 6b20 492f 4f20 6661 of a disk I/O fa │ │ │ +0002ab10: 696c 7572 652e 0a09 092f 2f20 6f6e 6365 ilure....// once │ │ │ +0002ab20: 2074 6869 7320 7265 6163 6865 7320 6120 this reaches a │ │ │ +0002ab30: 6365 7274 6169 6e20 7468 7265 7368 6f6c certain threshol │ │ │ +0002ab40: 642c 2074 6865 0a09 092f 2f20 7065 6572 d, the...// peer │ │ │ +0002ab50: 2069 7320 6469 7363 6f6e 6e65 6374 6564 is disconnected │ │ │ +0002ab60: 2069 6e20 6f72 6465 7220 746f 2061 766f in order to avo │ │ │ +0002ab70: 6964 2069 6e66 696e 6974 650a 0909 2f2f id infinite...// │ │ │ +0002ab80: 206c 6f6f 7073 206f 6620 636f 6e73 6973 loops of consis │ │ │ +0002ab90: 7465 6e74 2066 6169 6c75 7265 730a 0909 tent failures... │ │ │ +0002aba0: 7374 643a 3a75 696e 7438 5f74 206d 5f64 std::uint8_t m_d │ │ │ +0002abb0: 6973 6b5f 7265 6164 5f66 6169 6c75 7265 isk_read_failure │ │ │ +0002abc0: 7320 3d20 303b 0a0a 0909 2f2f 2074 6869 s = 0;....// thi │ │ │ +0002abd0: 7320 6973 2075 7365 6420 696e 2073 6565 s is used in see │ │ │ +0002abe0: 6420 6d6f 6465 2077 6865 6e65 7665 7220 d mode whenever │ │ │ +0002abf0: 7765 2074 7269 6767 6572 2061 2068 6173 we trigger a has │ │ │ +0002ac00: 6820 6368 6563 6b0a 0909 2f2f 2066 6f72 h check...// for │ │ │ +0002ac10: 2061 2070 6965 6365 2c20 6265 666f 7265 a piece, before │ │ │ +0002ac20: 2077 6520 7265 6164 2069 742e 2049 7427 we read it. It' │ │ │ +0002ac30: 7320 7573 6564 2074 6f20 7468 726f 7474 s used to thrott │ │ │ +0002ac40: 6c65 0a09 092f 2f20 7468 6520 6861 7368 le...// the hash │ │ │ +0002ac50: 2063 6865 636b 7320 746f 206a 7573 7420 checks to just │ │ │ +0002ac60: 6120 6665 7720 7065 7220 7065 6572 2061 a few per peer a │ │ │ +0002ac70: 7420 6120 7469 6d65 2e0a 0909 7374 643a t a time....std: │ │ │ +0002ac80: 3a75 696e 7438 5f74 206d 5f6f 7574 7374 :uint8_t m_outst │ │ │ +0002ac90: 616e 6469 6e67 5f70 6965 6365 5f76 6572 anding_piece_ver │ │ │ +0002aca0: 6966 6963 6174 696f 6e3a 333b 0a0a 0909 ification:3;.... │ │ │ +0002acb0: 2f2f 2069 7320 7472 7565 2069 6620 6974 // is true if it │ │ │ +0002acc0: 2077 6173 2077 6520 7468 6174 2063 6f6e was we that con │ │ │ +0002acd0: 6e65 6374 6564 2074 6f20 7468 6520 7065 nected to the pe │ │ │ +0002ace0: 6572 0a09 092f 2f20 616e 6420 6661 6c73 er...// and fals │ │ │ +0002acf0: 6520 6966 2077 6520 676f 7420 616e 2069 e if we got an i │ │ │ +0002ad00: 6e63 6f6d 696e 6720 636f 6e6e 6563 7469 ncoming connecti │ │ │ +0002ad10: 6f6e 0a09 092f 2f20 636f 756c 6420 6265 on...// could be │ │ │ +0002ad20: 2063 6f6e 7369 6465 7265 643a 2074 7275 considered: tru │ │ │ +0002ad30: 6520 3d20 6c6f 6361 6c2c 2066 616c 7365 e = local, false │ │ │ +0002ad40: 203d 2072 656d 6f74 650a 0909 626f 6f6c = remote...bool │ │ │ +0002ad50: 206d 5f6f 7574 676f 696e 673a 313b 0a0a m_outgoing:1;.. │ │ │ +0002ad60: 0909 2f2f 2069 7320 7472 7565 2069 6620 ..// is true if │ │ │ +0002ad70: 7765 206c 6561 726e 2074 6865 2069 6e63 we learn the inc │ │ │ +0002ad80: 6f6d 696e 6720 636f 6e6e 6563 7469 6f6e oming connection │ │ │ +0002ad90: 7320 6c69 7374 656e 696e 670a 0909 2f2f s listening...// │ │ │ +0002ada0: 2064 7572 696e 6720 7468 6520 6578 7465 during the exte │ │ │ +0002adb0: 6e64 6564 2068 616e 6473 6861 6b65 0a09 nded handshake.. │ │ │ +0002adc0: 0962 6f6f 6c20 6d5f 7265 6365 6976 6564 .bool m_received │ │ │ +0002add0: 5f6c 6973 7465 6e5f 706f 7274 3a31 3b0a _listen_port:1;. │ │ │ +0002ade0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +0002ae20: 3b32 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;2../in │ │ │ +0002ae50: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ +0002ae60: 2f73 6f63 6b73 355f 7374 7265 616d 2e68 /socks5_stream.h │ │ │ +0002ae70: 7070 3a31 3535 3c2f 613e 3c2f 7464 3e3c pp:155< │ │ │ +0002ae80: 7464 3e61 6464 2061 7379 6e63 5f63 6f6e td>add async_con │ │ │ +0002ae90: 6e65 6374 2829 2074 6861 7420 7461 6b65 nect() that take │ │ │ +0002aea0: 7320 6120 686f 7374 6e61 6d65 2061 6e64 s a hostname and │ │ │ +0002aeb0: 2070 6f72 7420 6173 2077 656c 6c3c 2f74 port as well

    add as │ │ │ +0002af10: 796e 635f 636f 6e6e 6563 7428 2920 7468 ync_connect() th │ │ │ +0002af20: 6174 2074 616b 6573 2061 2068 6f73 746e at takes a hostn │ │ │ +0002af30: 616d 6520 616e 6420 706f 7274 2061 7320 ame and port as │ │ │ +0002af40: 7765 6c6c 3c2f 6832 3e3c 6834 3e2e 2e2f well

    ../ │ │ │ +0002af50: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ +0002af60: 6e74 2f73 6f63 6b73 355f 7374 7265 616d nt/socks5_stream │ │ │ +0002af70: 2e68 7070 3a31 3535 3c2f 6834 3e3c 7072 .hpp:155

    ..TORRENT │ │ │ +0002afc0: 5f41 5353 4552 5428 2161 7578 3a3a 6973 _ASSERT(!aux::is │ │ │ +0002afd0: 5f69 705f 6164 6472 6573 7328 686f 7374 _ip_address(host │ │ │ +0002afe0: 2929 3b0a 0909 6d5f 6473 745f 6e61 6d65 ));...m_dst_name │ │ │ +0002aff0: 203d 2068 6f73 743b 0a09 0969 6620 286d = host;...if (m │ │ │ +0002b000: 5f64 7374 5f6e 616d 652e 7369 7a65 2829 _dst_name.size() │ │ │ +0002b010: 2026 6774 3b20 3235 3529 0a09 0909 6d5f > 255)....m_ │ │ │ +0002b020: 6473 745f 6e61 6d65 2e72 6573 697a 6528 dst_name.resize( │ │ │ +0002b030: 3235 3529 3b0a 097d 0a0a 0976 6f69 6420 255);..}...void │ │ │ +0002b040: 636c 6f73 6528 6572 726f 725f 636f 6465 close(error_code │ │ │ +0002b050: 2661 6d70 3b20 6563 290a 097b 0a09 096d & ec)..{...m │ │ │ +0002b060: 5f64 7374 5f6e 616d 652e 636c 6561 7228 _dst_name.clear( │ │ │ +0002b070: 293b 0a09 0970 726f 7879 5f62 6173 653a );...proxy_base: │ │ │ +0002b080: 3a63 6c6f 7365 2865 6329 3b0a 097d 0a0a :close(ec);..}.. │ │ │ +0002b090: 2369 666e 6465 6620 424f 4f53 545f 4e4f #ifndef BOOST_NO │ │ │ +0002b0a0: 5f45 5843 4550 5449 4f4e 530a 0976 6f69 _EXCEPTIONS..voi │ │ │ +0002b0b0: 6420 636c 6f73 6528 290a 097b 0a09 096d d close()..{...m │ │ │ +0002b0c0: 5f64 7374 5f6e 616d 652e 636c 6561 7228 _dst_name.clear( │ │ │ +0002b0d0: 293b 0a09 0970 726f 7879 5f62 6173 653a );...proxy_base: │ │ │ +0002b0e0: 3a63 6c6f 7365 2829 3b0a 097d 0a23 656e :close();..}.#en │ │ │ +0002b0f0: 6469 660a 0a3c 6469 7620 7374 796c 653d dif..
    .template < │ │ │ +0002b130: 3b63 6c61 7373 2048 616e 646c 6572 2667 ;class Handler&g │ │ │ +0002b140: 743b 0a3c 2f64 6976 3e09 766f 6964 2061 t;.
    .void a │ │ │ +0002b150: 7379 6e63 5f63 6f6e 6e65 6374 2865 6e64 sync_connect(end │ │ │ +0002b160: 706f 696e 745f 7479 7065 2063 6f6e 7374 point_type const │ │ │ +0002b170: 2661 6d70 3b20 656e 6470 6f69 6e74 2c20 & endpoint, │ │ │ +0002b180: 4861 6e64 6c65 7220 6861 6e64 6c65 7229 Handler handler) │ │ │ +0002b190: 0a09 7b0a 0909 2f2f 206d 616b 6520 7375 ..{...// make su │ │ │ +0002b1a0: 7265 2077 6520 646f 6e27 7420 7472 7920 re we don't try │ │ │ +0002b1b0: 746f 2063 6f6e 6e65 6374 2074 6f20 494e to connect to IN │ │ │ +0002b1c0: 4144 4452 5f41 4e59 2e20 6269 6e64 696e ADDR_ANY. bindin │ │ │ +0002b1d0: 6720 6973 2066 696e 652c 0a09 092f 2f20 g is fine,...// │ │ │ +0002b1e0: 616e 6420 7573 696e 6720 6120 686f 7374 and using a host │ │ │ +0002b1f0: 6e61 6d65 2069 7320 6669 6e65 206f 6e20 name is fine on │ │ │ +0002b200: 534f 434b 5320 7665 7273 696f 6e20 352e SOCKS version 5. │ │ │ +0002b210: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0002b220: 5428 656e 6470 6f69 6e74 2e61 6464 7265 T(endpoint.addre │ │ │ +0002b230: 7373 2829 2021 3d20 6164 6472 6573 7328 ss() != address( │ │ │ +0002b240: 290a 0909 097c 7c20 2821 6d5f 6473 745f )....|| (!m_dst_ │ │ │ +0002b250: 6e61 6d65 2e65 6d70 7479 2829 2026 616d name.empty() &am │ │ │ +0002b260: 703b 2661 6d70 3b20 6d5f 7665 7273 696f p;& m_versio │ │ │ +0002b270: 6e20 3d3d 2035 2929 3b0a 0a09 096d 5f72 n == 5));....m_r │ │ │ +0002b280: 656d 6f74 655f 656e 6470 6f69 6e74 203d emote_endpoint = │ │ │ +0002b290: 2065 6e64 706f 696e 743b 0a0a 0909 2f2f endpoint;....// │ │ │ +0002b2a0: 2074 6865 2063 6f6e 6e65 6374 2069 7320 the connect is │ │ │ +0002b2b0: 7370 6c69 7420 7570 2069 6e20 7468 6520 split up in the │ │ │ +0002b2c0: 666f 6c6c 6f77 696e 6720 7374 6570 733a following steps: │ │ │ +0002b2d0: 0a09 092f 2f20 312e 2072 6573 6f6c 7665 ...// 1. resolve │ │ │ +0002b2e0: 206e 616d 6520 6f66 2070 726f 7879 2073 name of proxy s │ │ │ +0002b2f0: 6572 7665 720a 0909 2f2f 2032 2e20 636f erver...// 2. co │ │ │ +0002b300: 6e6e 6563 7420 746f 2070 726f 7879 2073 nnect to proxy s │ │ │ +0002b310: 6572 7665 720a 0909 2f2f 2033 2e20 6966 erver...// 3. if │ │ │ +0002b320: 2076 6572 7369 6f6e 203d 3d20 353a 0a09 version == 5:.. │ │ │ +0002b330: 092f 2f20 2020 332e 3120 7365 6e64 2053 .// 3.1 send S │ │ │ +0002b340: 4f43 4b53 3520 6175 7468 656e 7469 6361 OCKS5 authentica │ │ │ +0002b350: 7469 6f6e 206d 6574 686f 6420 6d65 7373 tion method mess │ │ │ +0002b360: 6167 650a 0909 2f2f 2020 2033 2e32 2072 age...// 3.2 r │ │ │ +0002b370: 6561 6420 534f 434b 5335 2061 7574 6865 ead SOCKS5 authe │ │ │ +0002b380: 6e74 6963 6174 696f 6e20 7265 7370 6f6e ntication respon │ │ │ +0002b390: 7365 0a09 092f 2f20 2020 332e 3320 7365 se...// 3.3 se │ │ │ +0002b3a0: 6e64 2075 7365 726e 616d 652b 7061 7373 nd username+pass │ │ │ +0002b3b0: 776f 7264 0a09 092f 2f20 342e 2073 656e word...// 4. sen │ │ │ +0002b3c0: 6420 534f 434b 5320 636f 6d6d 616e 6420 d SOCKS command │ │ │ +0002b3d0: 6d65 7373 6167 650a 0a09 0941 4444 5f4f message....ADD_O │ │ │ +0002b3e0: 5554 5354 414e 4449 4e47 5f41 5359 4e43 UTSTANDING_ASYNC │ │ │ +0002b3f0: 2822 736f 636b 7335 5f73 7472 6561 6d3a ("socks5_stream: │ │ │ +0002b400: 3a6e 616d 655f 6c6f 6f6b 7570 2229 3b0a :name_lookup");. │ │ │ +0002b410: 0909 6d5f 7265 736f 6c76 6572 2e61 7379 ..m_resolver.asy │ │ │ +0002b420: 6e63 5f72 6573 6f6c 7665 286d 5f68 6f73 nc_resolve(m_hos │ │ │ +0002b430: 746e 616d 652c 2074 6f5f 7374 7269 6e67 tname, to_string │ │ │ +0002b440: 286d 5f70 6f72 7429 2e64 6174 6128 292c (m_port).data(), │ │ │ +0002b450: 2077 7261 705f 616c 6c6f 6361 746f 7228 wrap_allocator( │ │ │ +0002b460: 0a09 0909 5b74 6869 735d 2865 7272 6f72 ....[this](error │ │ │ +0002b470: 5f63 6f64 6520 636f 6e73 7426 616d 703b _code const& │ │ │ +0002b480: 2065 632c 2074 6370 3a3a 7265 736f 6c76 ec, tcp::resolv │ │ │ +0002b490: 6572 3a3a 7265 7375 6c74 735f 7479 7065 er::results_type │ │ │ +0002b4a0: 2069 7073 2c20 4861 6e64 6c65 7220 686e ips, Handler hn │ │ │ +0002b4b0: 2920 7b0a 0909 0909 6e61 6d65 5f6c 6f6f ) {.....name_loo │ │ │ +0002b4c0: 6b75 7028 6563 2c20 7374 643a 3a6d 6f76 kup(ec, std::mov │ │ │ +0002b4d0: 6528 6970 7329 2c20 7374 643a 3a6d 6f76 e(ips), std::mov │ │ │ +0002b4e0: 6528 686e 2929 3b0a 0909 097d 2c20 7374 e(hn));....}, st │ │ │ +0002b4f0: 643a 3a6d 6f76 6528 6861 6e64 6c65 7229 d::move(handler) │ │ │ +0002b500: 2929 3b0a 097d 0a0a 7072 6976 6174 653a ));..}..private: │ │ │ +0002b510: 0a0a 0974 656d 706c 6174 6520 266c 743b ...template < │ │ │ +0002b520: 7479 7065 6e61 6d65 2048 616e 646c 6572 typename Handler │ │ │ +0002b530: 2667 743b 0a09 766f 6964 206e 616d 655f >..void name_ │ │ │ +0002b540: 6c6f 6f6b 7570 2865 7272 6f72 5f63 6f64 lookup(error_cod │ │ │ +0002b550: 6520 636f 6e73 7426 616d 703b 2065 2c20 e const& e, │ │ │ +0002b560: 7463 703a 3a72 6573 6f6c 7665 723a 3a72 tcp::resolver::r │ │ │ +0002b570: 6573 756c 7473 5f74 7970 6520 6970 730a esults_type ips. │ │ │ +0002b580: 0909 2c20 4861 6e64 6c65 7220 6829 0a3c .., Handler h).< │ │ │ +0002b590: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +0002b5a0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +0002b5b0: 6f75 6e64 3a20 2363 6663 223e 3c74 643e ound: #cfc"> │ │ │ +0002b5c0: 7265 6c65 7661 6e63 6526 6e62 7370 3b32 relevance 2 │ │ │ +0002b5d0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../incl │ │ │ +0002b600: 7564 652f 6c69 6274 6f72 7265 6e74 2f70 ude/libtorrent/p │ │ │ +0002b610: 6965 6365 5f70 6963 6b65 722e 6870 703a iece_picker.hpp: │ │ │ +0002b620: 3636 383c 2f61 3e3c 2f74 643e 3c74 643e 668 │ │ │ +0002b630: 6861 7669 6e67 2038 2070 7269 6f72 6974 having 8 priorit │ │ │ +0002b640: 7920 6c65 7665 6c73 2069 7320 7072 6f62 y levels is prob │ │ │ +0002b650: 6162 6c79 2065 7863 6573 7369 7665 2e20 ably excessive. │ │ │ +0002b660: 4974 2073 686f 756c 6420 7072 6f62 6162 It should probab │ │ │ +0002b670: 6c79 2062 6520 6368 616e 6765 6420 746f ly be changed to │ │ │ +0002b680: 2033 206c 6576 656c 7320 2b20 646f 6e74 3 levels + dont │ │ │ +0002b690: 2d64 6f77 6e6c 6f61 643c 2f74 643e 3c2f -download

    having 8 p │ │ │ +0002b6f0: 7269 6f72 6974 7920 6c65 7665 6c73 2069 riority levels i │ │ │ +0002b700: 7320 7072 6f62 6162 6c79 2065 7863 6573 s probably exces │ │ │ +0002b710: 7369 7665 2e20 4974 2073 686f 756c 640a sive. It should. │ │ │ +0002b720: 7072 6f62 6162 6c79 2062 6520 6368 616e probably be chan │ │ │ +0002b730: 6765 6420 746f 2033 206c 6576 656c 7320 ged to 3 levels │ │ │ +0002b740: 2b20 646f 6e74 2d64 6f77 6e6c 6f61 643c + dont-download< │ │ │ +0002b750: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ +0002b760: 6465 2f6c 6962 746f 7272 656e 742f 7069 de/libtorrent/pi │ │ │ +0002b770: 6563 655f 7069 636b 6572 2e68 7070 3a36 ece_picker.hpp:6 │ │ │ +0002b780: 3638 3c2f 6834 3e3c 7072 6520 7374 796c 68

    ....else if (st
    │ │ │ +0002b7d0: 6174 6528 2920 3d3d 2070 6965 6365 5f66  ate() == piece_f
    │ │ │ +0002b7e0: 756c 6c29 0a09 0909 0909 0973 7461 7465  ull).......state
    │ │ │ +0002b7f0: 2870 6965 6365 5f66 756c 6c5f 7265 7665  (piece_full_reve
    │ │ │ +0002b800: 7273 6529 3b0a 0909 097d 0a0a 0909 092f  rse);....}...../
    │ │ │ +0002b810: 2f20 7468 6520 6e75 6d62 6572 206f 6620  / the number of 
    │ │ │ +0002b820: 7065 6572 7320 7468 6174 2068 6173 2074  peers that has t
    │ │ │ +0002b830: 6869 7320 7069 6563 650a 0909 092f 2f20  his piece....// 
    │ │ │ +0002b840: 2861 7661 696c 6162 696c 6974 7929 0a09  (availability)..
    │ │ │ +0002b850: 0909 7374 643a 3a75 696e 7433 325f 7420  ..std::uint32_t 
    │ │ │ +0002b860: 7065 6572 5f63 6f75 6e74 203a 2032 363b  peer_count : 26;
    │ │ │ +0002b870: 0a0a 0909 092f 2f20 6f6e 6520 6f66 2074  .....// one of t
    │ │ │ +0002b880: 6865 2064 6f77 6e6c 6f61 645f 7175 6575  he download_queu
    │ │ │ +0002b890: 655f 7420 7661 6c75 6573 2e20 5468 6973  e_t values. This
    │ │ │ +0002b8a0: 2069 6e64 6963 6174 6573 2077 6865 7468   indicates wheth
    │ │ │ +0002b8b0: 6572 2074 6869 7320 7069 6563 650a 0909  er this piece...
    │ │ │ +0002b8c0: 092f 2f20 6973 2063 7572 7265 6e74 6c79  .// is currently
    │ │ │ +0002b8d0: 2062 6569 6e67 2064 6f77 6e6c 6f61 6465   being downloade
    │ │ │ +0002b8e0: 6420 6f72 206e 6f74 2c20 616e 6420 7768  d or not, and wh
    │ │ │ +0002b8f0: 6174 2073 7461 7465 2069 7427 7320 696e  at state it's in
    │ │ │ +0002b900: 2069 660a 0909 092f 2f20 6974 2069 732e   if....// it is.
    │ │ │ +0002b910: 2053 7065 6369 6669 6361 6c6c 792c 2061   Specifically, a
    │ │ │ +0002b920: 7320 616e 206f 7074 696d 697a 6174 696f  s an optimizatio
    │ │ │ +0002b930: 6e2c 2070 6965 6365 7320 7468 6174 2068  n, pieces that h
    │ │ │ +0002b940: 6176 6520 616c 6c20 626c 6f63 6b73 0a09  ave all blocks..
    │ │ │ +0002b950: 0909 2f2f 2072 6571 7565 7374 6564 2066  ..// requested f
    │ │ │ +0002b960: 726f 6d20 7468 656d 2061 7265 2073 6570  rom them are sep
    │ │ │ +0002b970: 6172 6174 6564 206f 7574 2069 6e74 6f20  arated out into 
    │ │ │ +0002b980: 7365 7061 7261 7465 206c 6973 7473 2074  separate lists t
    │ │ │ +0002b990: 6f20 6d61 6b65 0a09 0909 2f2f 206c 6f6f  o make....// loo
    │ │ │ +0002b9a0: 6b75 7073 2071 7569 636b 6572 2e20 5468  kups quicker. Th
    │ │ │ +0002b9b0: 6520 6d61 696e 206f 6464 6974 7920 6973  e main oddity is
    │ │ │ +0002b9c0: 2074 6861 7420 7768 6574 6865 7220 6120   that whether a 
    │ │ │ +0002b9d0: 646f 776e 6c6f 6164 696e 6720 7069 6563  downloading piec
    │ │ │ +0002b9e0: 650a 0909 092f 2f20 6861 7320 6f6e 6c79  e....// has only
    │ │ │ +0002b9f0: 2062 6565 6e20 7265 7175 6573 7465 6420   been requested 
    │ │ │ +0002ba00: 6672 6f6d 2070 6565 7273 2074 6861 7420  from peers that 
    │ │ │ +0002ba10: 6172 6520 7265 7665 7273 652c 2074 6861  are reverse, tha
    │ │ │ +0002ba20: 7427 730a 0909 092f 2f20 7265 636f 7264  t's....// record
    │ │ │ +0002ba30: 6564 2061 7320 7069 6563 655f 646f 776e  ed as piece_down
    │ │ │ +0002ba40: 6c6f 6164 696e 675f 7265 7665 7273 652c  loading_reverse,
    │ │ │ +0002ba50: 2077 6869 6368 2072 6561 6c6c 7920 6d65   which really me
    │ │ │ +0002ba60: 616e 7320 7468 6520 7361 6d65 0a09 0909  ans the same....
    │ │ │ +0002ba70: 2f2f 2061 7320 7069 6563 655f 646f 776e  // as piece_down
    │ │ │ +0002ba80: 6c6f 6164 696e 672c 2069 7420 6a75 7374  loading, it just
    │ │ │ +0002ba90: 2073 6176 6573 2073 7061 6365 2074 6f20   saves space to 
    │ │ │ +0002baa0: 616c 736f 2069 6e64 6963 6174 6520 7468  also indicate th
    │ │ │ +0002bab0: 6174 2069 740a 0909 092f 2f20 6861 7320  at it....// has 
    │ │ │ +0002bac0: 6120 6269 7420 6c6f 7765 7220 7072 696f  a bit lower prio
    │ │ │ +0002bad0: 7269 7479 2e20 5468 6520 7265 7665 7273  rity. The revers
    │ │ │ +0002bae0: 6520 6269 7420 6973 206f 6e6c 7920 7265  e bit is only re
    │ │ │ +0002baf0: 6c65 7661 6e74 2069 6620 7468 650a 0909  levant if the...
    │ │ │ +0002bb00: 092f 2f20 7374 6174 6520 6973 2070 6965  .// state is pie
    │ │ │ +0002bb10: 6365 5f64 6f77 6e6c 6f61 6469 6e67 2e0a  ce_downloading..
    │ │ │ +0002bb20: 0909 0973 7464 3a3a 7569 6e74 3332 5f74  ...std::uint32_t
    │ │ │ +0002bb30: 2064 6f77 6e6c 6f61 645f 7374 6174 6520   download_state 
    │ │ │ +0002bb40: 3a20 333b 0a0a 3c64 6976 2073 7479 6c65  : 3;..
    .
    ...// │ │ │ +0002bb80: 2069 7320 3020 6966 2074 6865 2070 6965 is 0 if the pie │ │ │ +0002bb90: 6365 2069 7320 6669 6c74 6572 6564 2028 ce is filtered ( │ │ │ +0002bba0: 6e6f 7420 746f 2062 6520 646f 776e 6c6f not to be downlo │ │ │ +0002bbb0: 6164 6564 290a 0909 092f 2f20 3120 6973 aded)....// 1 is │ │ │ +0002bbc0: 206c 6f77 2070 7269 6f72 6974 790a 0909 low priority... │ │ │ +0002bbd0: 092f 2f20 3220 6973 206c 6f77 2070 7269 .// 2 is low pri │ │ │ +0002bbe0: 6f72 6974 790a 0909 092f 2f20 3320 6973 ority....// 3 is │ │ │ +0002bbf0: 206d 6964 2070 7269 6f72 6974 790a 0909 mid priority... │ │ │ +0002bc00: 092f 2f20 3420 6973 2064 6566 6175 6c74 .// 4 is default │ │ │ +0002bc10: 2070 7269 6f72 6974 790a 0909 092f 2f20 priority....// │ │ │ +0002bc20: 3520 6973 206d 6964 2070 7269 6f72 6974 5 is mid priorit │ │ │ +0002bc30: 790a 0909 092f 2f20 3620 6973 2068 6967 y....// 6 is hig │ │ │ +0002bc40: 6820 7072 696f 7269 7479 0a09 0909 2f2f h priority....// │ │ │ +0002bc50: 2037 2069 7320 6869 6768 2070 7269 6f72 7 is high prior │ │ │ +0002bc60: 6974 790a 0909 0973 7464 3a3a 7569 6e74 ity....std::uint │ │ │ +0002bc70: 3332 5f74 2070 6965 6365 5f70 7269 6f72 32_t piece_prior │ │ │ +0002bc80: 6974 7920 3a20 333b 0a0a 0909 092f 2f20 ity : 3;.....// │ │ │ +0002bc90: 696e 6465 7820 696e 2074 6f20 7468 6520 index in to the │ │ │ +0002bca0: 7069 6563 655f 696e 666f 2076 6563 746f piece_info vecto │ │ │ +0002bcb0: 720a 0909 0970 7269 6f5f 696e 6465 785f r....prio_index_ │ │ │ +0002bcc0: 7420 696e 6465 783b 0a0a 2369 6664 6566 t index;..#ifdef │ │ │ +0002bcd0: 2054 4f52 5245 4e54 5f44 4542 5547 5f52 TORRENT_DEBUG_R │ │ │ +0002bce0: 4546 434f 554e 5453 0a09 0909 2f2f 2061 EFCOUNTS....// a │ │ │ +0002bcf0: 6c6c 2074 6865 2070 6565 7273 2074 6861 ll the peers tha │ │ │ +0002bd00: 7420 6861 7665 2074 6869 7320 7069 6563 t have this piec │ │ │ +0002bd10: 650a 0909 0973 7464 3a3a 7365 7426 6c74 e....std::set< │ │ │ +0002bd20: 3b63 6f6e 7374 2074 6f72 7265 6e74 5f70 ;const torrent_p │ │ │ +0002bd30: 6565 722a 2667 743b 2068 6176 655f 7065 eer*> have_pe │ │ │ +0002bd40: 6572 733b 0a23 656e 6469 660a 0a09 0909 ers;.#endif..... │ │ │ +0002bd50: 2f2f 2069 6e64 6578 2069 7320 7365 7420 // index is set │ │ │ +0002bd60: 746f 2074 6869 7320 746f 2069 6e64 6963 to this to indic │ │ │ +0002bd70: 6174 6520 7468 6174 2077 6520 6861 7665 ate that we have │ │ │ +0002bd80: 2074 6865 0a09 0909 2f2f 2070 6965 6365 the....// piece │ │ │ +0002bd90: 2e20 5468 6572 6520 6973 206e 6f20 656e . There is no en │ │ │ +0002bda0: 7472 7920 666f 7220 7468 6520 7069 6563 try for the piec │ │ │ +0002bdb0: 6520 696e 2074 6865 0a09 0909 2f2f 2062 e in the....// b │ │ │ +0002bdc0: 7563 6b65 7473 2069 6620 7468 6973 2069 uckets if this i │ │ │ +0002bdd0: 7320 7468 6520 6361 7365 2e0a 0909 0973 s the case.....s │ │ │ +0002bde0: 7461 7469 6320 636f 6e73 7465 7870 7220 tatic constexpr │ │ │ +0002bdf0: 7072 696f 5f69 6e64 6578 5f74 2077 655f prio_index_t we_ │ │ │ +0002be00: 6861 7665 5f69 6e64 6578 7b2d 317d 3b0a have_index{-1};. │ │ │ +0002be10: 0a09 0909 2f2f 2074 6865 2070 7269 6f72 ....// the prior │ │ │ +0002be20: 6974 7920 7661 6c75 6520 7468 6174 206d ity value that m │ │ │ +0002be30: 6561 6e73 2074 6865 2070 6965 6365 2069 eans the piece i │ │ │ +0002be40: 7320 6669 6c74 6572 6564 0a09 0909 7374 s filtered....st │ │ │ +0002be50: 6174 6963 2063 6f6e 7374 6578 7072 2073 atic constexpr s │ │ │ +0002be60: 7464 3a3a 7569 6e74 3332 5f74 2066 696c td::uint32_t fil │ │ │ +0002be70: 7465 725f 7072 696f 7269 7479 203d 2030 ter_priority = 0 │ │ │ +0002be80: 3b0a 0a09 0909 2f2f 2074 6865 206d 6178 ;.....// the max │ │ │ +0002be90: 206e 756d 6265 7220 7468 6520 7065 6572 number the peer │ │ │ +0002bea0: 2063 6f75 6e74 2063 616e 2068 6f6c 640a count can hold. │ │ │ +0002beb0: 0909 0973 7461 7469 6320 636f 6e73 7465 ...static conste │ │ │ +0002bec0: 7870 7220 7374 643a 3a75 696e 7433 325f xpr std::uint32_ │ │ │ +0002bed0: 7420 6d61 785f 7065 6572 5f63 6f75 6e74 t max_peer_count │ │ │ +0002bee0: 203d 2030 7866 6666 663b 0a0a 0909 0962 = 0xffff;.....b │ │ │ +0002bef0: 6f6f 6c20 6861 7665 2829 2063 6f6e 7374 ool have() const │ │ │ +0002bf00: 207b 2072 6574 7572 6e20 696e 6465 7820 { return index │ │ │ +0002bf10: 3d3d 2077 655f 6861 7665 5f69 6e64 6578 == we_have_index │ │ │ +0002bf20: 3b20 7d0a 3c2f 7072 653e 3c2f 7464 3e3c ; }.
    < │ │ │ 0002bf30: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ 0002bf60: 6273 703b 323c 2f74 643e 3c74 643e 3c61 bsp;2.. │ │ │ 0002bf90: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ @@ -11750,473 +11750,473 @@ │ │ │ 0002de50: 7863 6570 740a 0909 097b 0a3c 2f70 7265 xcept....{.rele │ │ │ 0002de90: 7661 6e63 6526 6e62 7370 3b31 3c2f 7464 vance 1../src/torr │ │ │ -0002ded0: 656e 742e 6370 703a 3131 3739 3c2f 613e ent.cpp:1179 │ │ │ -0002dee0: 3c2f 7464 3e3c 7464 3e6d 616b 6520 7468 make th │ │ │ -0002def0: 6973 2064 6570 656e 6420 6f6e 2074 6865 is depend on the │ │ │ -0002df00: 2065 7272 6f72 2061 6e64 206f 6e20 7468 error and on th │ │ │ -0002df10: 6520 6669 6c65 7379 7374 656d 2074 6865 e filesystem the │ │ │ -0002df20: 2066 696c 6573 2061 7265 2062 6569 6e67 files are being │ │ │ -0002df30: 2064 6f77 6e6c 6f61 6465 6420 746f 2e20 downloaded to. │ │ │ -0002df40: 4966 2074 6865 2065 7272 6f72 2069 7320 If the error is │ │ │ -0002df50: 6e6f 5f73 7061 6365 5f6c 6566 745f 6f6e no_space_left_on │ │ │ -0002df60: 5f64 6576 6963 6520 616e 6420 7468 6520 _device and the │ │ │ -0002df70: 6669 6c65 7379 7374 656d 2064 6f65 736e filesystem doesn │ │ │ -0002df80: 2774 2073 7570 706f 7274 2073 7061 7273 't support spars │ │ │ -0002df90: 6520 6669 6c65 732c 206f 6e6c 7920 7a65 e files, only ze │ │ │ -0002dfa0: 726f 2074 6865 2070 7269 6f72 6974 6965 ro the prioritie │ │ │ -0002dfb0: 7320 6f66 2074 6865 2070 6965 6365 7320 s of the pieces │ │ │ -0002dfc0: 7468 6174 2061 7265 2061 7420 7468 6520 that are at the │ │ │ -0002dfd0: 7461 696c 7320 6f66 2061 6c6c 2066 696c tails of all fil │ │ │ -0002dfe0: 6573 2c20 6c65 6176 696e 6720 6576 6572 es, leaving ever │ │ │ -0002dff0: 7974 6869 6e67 2075 7020 746f 2074 6865 ything up to the │ │ │ -0002e000: 2068 6967 6865 7374 2077 7269 7474 656e highest written │ │ │ -0002e010: 2070 6965 6365 2069 6e20 6561 6368 2066 piece in each f │ │ │ -0002e020: 696c 653c 2f74 643e 3c2f 7472 3e3c 7472 ile

    │ │ │ -0002e070: 6d61 6b65 2074 6869 7320 6465 7065 6e64 make this depend │ │ │ -0002e080: 206f 6e20 7468 6520 6572 726f 7220 616e on the error an │ │ │ -0002e090: 6420 6f6e 2074 6865 2066 696c 6573 7973 d on the filesys │ │ │ -0002e0a0: 7465 6d20 7468 650a 6669 6c65 7320 6172 tem the.files ar │ │ │ -0002e0b0: 6520 6265 696e 6720 646f 776e 6c6f 6164 e being download │ │ │ -0002e0c0: 6564 2074 6f2e 2049 6620 7468 6520 6572 ed to. If the er │ │ │ -0002e0d0: 726f 7220 6973 206e 6f5f 7370 6163 655f ror is no_space_ │ │ │ -0002e0e0: 6c65 6674 5f6f 6e5f 6465 7669 6365 0a61 left_on_device.a │ │ │ -0002e0f0: 6e64 2074 6865 2066 696c 6573 7973 7465 nd the filesyste │ │ │ -0002e100: 6d20 646f 6573 6e27 7420 7375 7070 6f72 m doesn't suppor │ │ │ -0002e110: 7420 7370 6172 7365 2066 696c 6573 2c20 t sparse files, │ │ │ -0002e120: 6f6e 6c79 207a 6572 6f20 7468 6520 7072 only zero the pr │ │ │ -0002e130: 696f 7269 7469 6573 0a6f 6620 7468 6520 iorities.of the │ │ │ -0002e140: 7069 6563 6573 2074 6861 7420 6172 6520 pieces that are │ │ │ -0002e150: 6174 2074 6865 2074 6169 6c73 206f 6620 at the tails of │ │ │ -0002e160: 616c 6c20 6669 6c65 732c 206c 6561 7669 all files, leavi │ │ │ -0002e170: 6e67 2065 7665 7279 7468 696e 670a 7570 ng everything.up │ │ │ -0002e180: 2074 6f20 7468 6520 6869 6768 6573 7420 to the highest │ │ │ -0002e190: 7772 6974 7465 6e20 7069 6563 6520 696e written piece in │ │ │ -0002e1a0: 2065 6163 6820 6669 6c65 3c2f 6832 3e3c each file

    < │ │ │ -0002e1b0: 6834 3e2e 2e2f 7372 632f 746f 7272 656e h4>../src/torren │ │ │ -0002e1c0: 742e 6370 703a 3131 3739 3c2f 6834 3e3c t.cpp:1179< │ │ │ -0002e1d0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -0002e1e0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -0002e1f0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -0002e200: 7820 2364 6464 3b22 3e0a 0909 2f2f 206e x #ddd;">...// n │ │ │ -0002e210: 6f74 6966 7920 7468 6520 7573 6572 206f otify the user o │ │ │ -0002e220: 6620 7468 6520 6572 726f 720a 0909 6966 f the error...if │ │ │ -0002e230: 2028 616c 6572 7473 2829 2e73 686f 756c (alerts().shoul │ │ │ -0002e240: 645f 706f 7374 266c 743b 6669 6c65 5f65 d_post<file_e │ │ │ -0002e250: 7272 6f72 5f61 6c65 7274 2667 743b 2829 rror_alert>() │ │ │ -0002e260: 290a 0909 0961 6c65 7274 7328 292e 656d )....alerts().em │ │ │ -0002e270: 706c 6163 655f 616c 6572 7426 6c74 3b66 place_alert<f │ │ │ -0002e280: 696c 655f 6572 726f 725f 616c 6572 7426 ile_error_alert& │ │ │ -0002e290: 6774 3b28 6572 726f 722e 6563 0a09 0909 gt;(error.ec.... │ │ │ -0002e2a0: 092c 2072 6573 6f6c 7665 5f66 696c 656e ., resolve_filen │ │ │ -0002e2b0: 616d 6528 6572 726f 722e 6669 6c65 2829 ame(error.file() │ │ │ -0002e2c0: 292c 2065 7272 6f72 2e6f 7065 7261 7469 ), error.operati │ │ │ -0002e2d0: 6f6e 2c20 6765 745f 6861 6e64 6c65 2829 on, get_handle() │ │ │ -0002e2e0: 293b 0a0a 0909 2f2f 2069 6620 6120 7772 );....// if a wr │ │ │ -0002e2f0: 6974 6520 6f70 6572 6174 696f 6e20 6661 ite operation fa │ │ │ -0002e300: 696c 6564 2c20 616e 6420 6675 7475 7265 iled, and future │ │ │ -0002e310: 2077 7269 7465 7320 6172 6520 6c69 6b65 writes are like │ │ │ -0002e320: 6c79 2074 6f0a 0909 2f2f 2066 6169 6c2c ly to...// fail, │ │ │ -0002e330: 2077 6869 6c65 2072 6561 6473 206d 6179 while reads may │ │ │ -0002e340: 2073 7563 6365 6564 2c20 6a75 7374 2073 succeed, just s │ │ │ -0002e350: 6574 2074 6865 2074 6f72 7265 6e74 2074 et the torrent t │ │ │ -0002e360: 6f20 7570 6c6f 6164 206d 6f64 650a 0909 o upload mode... │ │ │ -0002e370: 2f2f 2069 6620 7765 206d 616b 6520 616e // if we make an │ │ │ -0002e380: 2069 6e63 6f72 7265 6374 2061 7373 756d incorrect assum │ │ │ -0002e390: 7074 696f 6e20 6865 7265 2c20 6974 2773 ption here, it's │ │ │ -0002e3a0: 206e 6f74 2074 6865 2065 6e64 206f 6620 not the end of │ │ │ -0002e3b0: 7468 650a 0909 2f2f 2077 6f72 6c64 2c20 the...// world, │ │ │ -0002e3c0: 6966 2077 6520 6576 6572 2069 7373 7565 if we ever issue │ │ │ -0002e3d0: 2061 2072 6561 6420 7265 7175 6573 7420 a read request │ │ │ -0002e3e0: 616e 6420 6974 2066 6169 6c73 2061 7320 and it fails as │ │ │ -0002e3f0: 7765 6c6c 2c20 7765 0a09 092f 2f20 776f well, we...// wo │ │ │ -0002e400: 6e27 7420 6765 7420 696e 2068 6572 6520 n't get in here │ │ │ -0002e410: 616e 6420 7765 276c 6c20 6163 7475 616c and we'll actual │ │ │ -0002e420: 6c79 2065 6e64 2075 7020 7061 7573 696e ly end up pausin │ │ │ -0002e430: 6720 7468 6520 746f 7272 656e 740a 0909 g the torrent... │ │ │ -0002e440: 6966 2028 7277 203d 3d20 6469 736b 5f63 if (rw == disk_c │ │ │ -0002e450: 6c61 7373 3a3a 7772 6974 650a 0909 0926 lass::write....& │ │ │ -0002e460: 616d 703b 2661 6d70 3b20 2865 7272 6f72 amp;& (error │ │ │ -0002e470: 2e65 6320 3d3d 2062 6f6f 7374 3a3a 7379 .ec == boost::sy │ │ │ -0002e480: 7374 656d 3a3a 6572 7263 3a3a 7265 6164 stem::errc::read │ │ │ -0002e490: 5f6f 6e6c 795f 6669 6c65 5f73 7973 7465 _only_file_syste │ │ │ -0002e4a0: 6d0a 0909 097c 7c20 6572 726f 722e 6563 m....|| error.ec │ │ │ -0002e4b0: 203d 3d20 626f 6f73 743a 3a73 7973 7465 == boost::syste │ │ │ -0002e4c0: 6d3a 3a65 7272 633a 3a70 6572 6d69 7373 m::errc::permiss │ │ │ -0002e4d0: 696f 6e5f 6465 6e69 6564 0a09 0909 7c7c ion_denied....|| │ │ │ -0002e4e0: 2065 7272 6f72 2e65 6320 3d3d 2062 6f6f error.ec == boo │ │ │ -0002e4f0: 7374 3a3a 7379 7374 656d 3a3a 6572 7263 st::system::errc │ │ │ -0002e500: 3a3a 6f70 6572 6174 696f 6e5f 6e6f 745f ::operation_not_ │ │ │ -0002e510: 7065 726d 6974 7465 640a 0909 097c 7c20 permitted....|| │ │ │ -0002e520: 6572 726f 722e 6563 203d 3d20 626f 6f73 error.ec == boos │ │ │ -0002e530: 743a 3a73 7973 7465 6d3a 3a65 7272 633a t::system::errc: │ │ │ -0002e540: 3a6e 6f5f 7370 6163 655f 6f6e 5f64 6576 :no_space_on_dev │ │ │ -0002e550: 6963 650a 0909 097c 7c20 6572 726f 722e ice....|| error. │ │ │ -0002e560: 6563 203d 3d20 626f 6f73 743a 3a73 7973 ec == boost::sys │ │ │ -0002e570: 7465 6d3a 3a65 7272 633a 3a66 696c 655f tem::errc::file_ │ │ │ -0002e580: 746f 6f5f 6c61 7267 6529 290a 0909 7b0a too_large))...{. │ │ │ -0002e590: 0909 092f 2f20 6966 2077 6520 6661 696c ...// if we fail │ │ │ -0002e5a0: 6564 2074 6f20 7772 6974 652c 2073 746f ed to write, sto │ │ │ -0002e5b0: 7020 646f 776e 6c6f 6164 696e 6720 616e p downloading an │ │ │ -0002e5c0: 6420 6a75 7374 0a09 0909 2f2f 206b 6565 d just....// kee │ │ │ -0002e5d0: 7020 7365 6564 696e 672e 0a3c 6469 7620 p seeding..
    ...set_ │ │ │ -0002e610: 7570 6c6f 6164 5f6d 6f64 6528 7472 7565 upload_mode(true │ │ │ -0002e620: 293b 0a3c 2f64 6976 3e09 0909 7265 7475 );.
    ...retu │ │ │ -0002e630: 726e 3b0a 0909 7d0a 0a09 092f 2f20 7075 rn;...}....// pu │ │ │ -0002e640: 7420 7468 6520 746f 7272 656e 7420 696e t the torrent in │ │ │ -0002e650: 2061 6e20 6572 726f 722d 7374 6174 650a an error-state. │ │ │ -0002e660: 0909 7365 745f 6572 726f 7228 6572 726f ..set_error(erro │ │ │ -0002e670: 722e 6563 2c20 6572 726f 722e 6669 6c65 r.ec, error.file │ │ │ -0002e680: 2829 293b 0a0a 0909 2f2f 2069 6620 7468 ());....// if th │ │ │ -0002e690: 6520 6572 726f 7220 6170 7065 6172 7320 e error appears │ │ │ -0002e6a0: 746f 2062 6520 6d6f 7265 2073 6572 696f to be more serio │ │ │ -0002e6b0: 7573 2074 6861 6e20 6120 6675 6c6c 2064 us than a full d │ │ │ -0002e6c0: 6973 6b2c 206a 7573 7420 7061 7573 6520 isk, just pause │ │ │ -0002e6d0: 7468 6520 746f 7272 656e 740a 0909 7061 the torrent...pa │ │ │ -0002e6e0: 7573 6528 293b 0a09 7d0a 0a09 766f 6964 use();..}...void │ │ │ -0002e6f0: 2074 6f72 7265 6e74 3a3a 6861 6e64 6c65 torrent::handle │ │ │ -0002e700: 5f69 6e63 6f6e 7369 7374 656e 745f 6861 _inconsistent_ha │ │ │ -0002e710: 7368 6573 2870 6965 6365 5f69 6e64 6578 shes(piece_index │ │ │ -0002e720: 5f74 2063 6f6e 7374 2070 6965 6365 290a _t const piece). │ │ │ -0002e730: 097b 0a09 0961 7574 6f20 636f 6e73 7420 .{...auto const │ │ │ -0002e740: 6669 6c65 5f73 6c69 6365 7320 3d20 746f file_slices = to │ │ │ -0002e750: 7272 656e 745f 6669 6c65 2829 2e6d 6170 rrent_file().map │ │ │ -0002e760: 5f62 6c6f 636b 2870 6965 6365 2c20 302c _block(piece, 0, │ │ │ -0002e770: 2030 293b 0a09 0966 696c 655f 696e 6465 0);...file_inde │ │ │ -0002e780: 785f 7420 636f 6e73 7420 6669 6c65 203d x_t const file = │ │ │ -0002e790: 2066 696c 655f 736c 6963 6573 2e65 6d70 file_slices.emp │ │ │ -0002e7a0: 7479 2829 203f 2074 6f72 7265 6e74 5f73 ty() ? torrent_s │ │ │ -0002e7b0: 7461 7475 733a 3a65 7272 6f72 5f66 696c tatus::error_fil │ │ │ -0002e7c0: 655f 6e6f 6e65 203a 2066 696c 655f 736c e_none : file_sl │ │ │ -0002e7d0: 6963 6573 5b30 5d2e 6669 6c65 5f69 6e64 ices[0].file_ind │ │ │ -0002e7e0: 6578 3b0a 0909 7365 745f 6572 726f 7228 ex;...set_error( │ │ │ -0002e7f0: 6572 726f 7273 3a3a 746f 7272 656e 745f errors::torrent_ │ │ │ -0002e800: 696e 636f 6e73 6973 7465 6e74 5f68 6173 inconsistent_has │ │ │ -0002e810: 6865 732c 2066 696c 6529 3b0a 0909 2f2f hes, file);...// │ │ │ -0002e820: 2069 6620 7468 6973 2069 7320 6120 6879 if this is a hy │ │ │ -0002e830: 6272 6964 2074 6f72 7265 6e74 2c20 7765 brid torrent, we │ │ │ -0002e840: 206d 6179 2068 6176 6520 6d61 726b 6564 may have marked │ │ │ -0002e850: 2073 6f6d 6520 6d6f 7265 2070 6965 6365 some more piece │ │ │ -0002e860: 730a 0909 2f2f 2061 7320 2268 6176 6522 s...// as "have" │ │ │ -0002e870: 2062 7574 206e 6f74 2079 6574 2076 616c but not yet val │ │ │ -0002e880: 6964 6174 6564 2074 6865 6d20 6167 6169 idated them agai │ │ │ -0002e890: 6e73 7420 7468 6520 7632 2068 6173 6865 nst the v2 hashe │ │ │ -0002e8a0: 732e 2041 740a 0909 2f2f 2074 6869 7320 s. At...// this │ │ │ -0002e8b0: 706f 696e 742c 206a 7573 7420 6173 7375 point, just assu │ │ │ -0002e8c0: 6d65 2077 6520 6861 7665 206e 6f20 7069 me we have no pi │ │ │ -0002e8d0: 6563 6573 0a09 096d 5f70 6963 6b65 722e eces...m_picker. │ │ │ -0002e8e0: 7265 7365 7428 293b 0a09 096d 5f68 6173 reset();...m_has │ │ │ -0002e8f0: 685f 7069 636b 6572 2e72 6573 6574 2829 h_picker.reset() │ │ │ -0002e900: 3b0a 0909 6d5f 6669 6c65 5f70 726f 6772 ;...m_file_progr │ │ │ -0002e910: 6573 732e 636c 6561 7228 293b 0a09 0973 ess.clear();...s │ │ │ -0002e920: 6574 5f68 6176 655f 616c 6c28 6661 6c73 et_have_all(fals │ │ │ -0002e930: 6529 3b0a 0909 7570 6461 7465 5f67 6175 e);...update_gau │ │ │ -0002e940: 6765 2829 3b0a 0909 7061 7573 6528 293b ge();...pause(); │ │ │ -0002e950: 0a09 7d0a 0a09 766f 6964 2074 6f72 7265 ..}...void torre │ │ │ -0002e960: 6e74 3a3a 6f6e 5f70 6965 6365 5f66 6169 nt::on_piece_fai │ │ │ -0002e970: 6c5f 7379 6e63 2870 6965 6365 5f69 6e64 l_sync(piece_ind │ │ │ -0002e980: 6578 5f74 2063 6f6e 7374 2070 6965 6365 ex_t const piece │ │ │ -0002e990: 2c20 7069 6563 655f 626c 6f63 6b29 2074 , piece_block) t │ │ │ -0002e9a0: 7279 0a09 7b0a 0909 6966 2028 6d5f 6162 ry..{...if (m_ab │ │ │ -0002e9b0: 6f72 7429 2072 6574 7572 6e3b 0a0a 3c2f ort) return;..r │ │ │ -0002e9f0: 656c 6576 616e 6365 266e 6273 703b 313c elevance 1< │ │ │ -0002ea00: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/t │ │ │ -0002ea30: 6f72 7265 6e74 2e63 7070 3a38 3536 323c orrent.cpp:8562< │ │ │ -0002ea40: 2f61 3e3c 2f74 643e 3c74 643e 7368 6f75 /a>shou │ │ │ -0002ea50: 6c64 2064 6973 636f 6e6e 6563 7420 616c ld disconnect al │ │ │ -0002ea60: 6c20 7065 6572 7320 7468 6174 2068 6176 l peers that hav │ │ │ -0002ea70: 6520 7468 6520 7069 6563 6573 2077 6520 e the pieces we │ │ │ -0002ea80: 6861 7665 206e 6f74 206a 7573 7420 7365 have not just se │ │ │ -0002ea90: 6564 732e 2049 7420 776f 756c 6420 6265 eds. It would be │ │ │ -0002eaa0: 2070 7265 7474 7920 6578 7065 6e73 6976 pretty expensiv │ │ │ -0002eab0: 6520 746f 2063 6865 636b 2061 6c6c 2070 e to check all p │ │ │ -0002eac0: 6965 6365 7320 666f 7220 616c 6c20 7065 ieces for all pe │ │ │ -0002ead0: 6572 7320 7468 6f75 6768 3c2f 7464 3e3c ers though< │ │ │ -0002eae0: 2f74 723e 3c74 7220 6964 3d22 3932 2220 /tr>

    should di │ │ │ -0002eb30: 7363 6f6e 6e65 6374 2061 6c6c 2070 6565 sconnect all pee │ │ │ -0002eb40: 7273 2074 6861 7420 6861 7665 2074 6865 rs that have the │ │ │ -0002eb50: 2070 6965 6365 7320 7765 2068 6176 650a pieces we have. │ │ │ -0002eb60: 6e6f 7420 6a75 7374 2073 6565 6473 2e20 not just seeds. │ │ │ -0002eb70: 4974 2077 6f75 6c64 2062 6520 7072 6574 It would be pret │ │ │ -0002eb80: 7479 2065 7870 656e 7369 7665 2074 6f20 ty expensive to │ │ │ -0002eb90: 6368 6563 6b20 616c 6c20 7069 6563 6573 check all pieces │ │ │ -0002eba0: 0a66 6f72 2061 6c6c 2070 6565 7273 2074 .for all peers t │ │ │ -0002ebb0: 686f 7567 683c 2f68 323e 3c68 343e 2e2e hough

    .. │ │ │ -0002ebc0: 2f73 7263 2f74 6f72 7265 6e74 2e63 7070 /src/torrent.cpp │ │ │ -0002ebd0: 3a38 3536 323c 2f68 343e 3c70 7265 2073 :8562

    ...set_state
    │ │ │ -0002ec20: 2874 6f72 7265 6e74 5f73 7461 7475 733a  (torrent_status:
    │ │ │ -0002ec30: 3a66 696e 6973 6865 6429 3b0a 0909 7365  :finished);...se
    │ │ │ -0002ec40: 745f 7175 6575 655f 706f 7369 7469 6f6e  t_queue_position
    │ │ │ -0002ec50: 286e 6f5f 706f 7329 3b0a 0a09 0975 7064  (no_pos);....upd
    │ │ │ -0002ec60: 6174 655f 7374 6174 655f 7469 6d65 7273  ate_state_timers
    │ │ │ -0002ec70: 2829 3b0a 0a09 092f 2f20 7765 2068 6176  ();....// we hav
    │ │ │ -0002ec80: 6520 746f 2063 616c 6c20 636f 6d70 6c65  e to call comple
    │ │ │ -0002ec90: 7465 6428 2920 6265 666f 7265 2077 6520  ted() before we 
    │ │ │ -0002eca0: 7374 6172 740a 0909 2f2f 2064 6973 636f  start...// disco
    │ │ │ -0002ecb0: 6e6e 6563 7469 6e67 2070 6565 7273 2c20  nnecting peers, 
    │ │ │ -0002ecc0: 7369 6e63 6520 7468 6572 6527 7320 616e  since there's an
    │ │ │ -0002ecd0: 2061 7373 6572 740a 0909 2f2f 2074 6f20   assert...// to 
    │ │ │ -0002ece0: 6d61 6b65 2073 7572 6520 7765 2772 6520  make sure we're 
    │ │ │ -0002ecf0: 636c 6561 7265 6420 7468 6520 7069 6563  cleared the piec
    │ │ │ -0002ed00: 6520 7069 636b 6572 0a09 0969 6620 2869  e picker...if (i
    │ │ │ -0002ed10: 735f 7365 6564 2829 2920 636f 6d70 6c65  s_seed()) comple
    │ │ │ -0002ed20: 7465 6428 293b 0a0a 0909 7365 6e64 5f75  ted();....send_u
    │ │ │ -0002ed30: 706c 6f61 645f 6f6e 6c79 2829 3b0a 0909  pload_only();...
    │ │ │ -0002ed40: 7374 6174 655f 7570 6461 7465 6428 293b  state_updated();
    │ │ │ -0002ed50: 0a0a 0909 6966 2028 6d5f 636f 6d70 6c65  ....if (m_comple
    │ │ │ -0002ed60: 7465 645f 7469 6d65 203d 3d20 3029 0a09  ted_time == 0)..
    │ │ │ -0002ed70: 0909 6d5f 636f 6d70 6c65 7465 645f 7469  ..m_completed_ti
    │ │ │ -0002ed80: 6d65 203d 2074 696d 6528 6e75 6c6c 7074  me = time(nullpt
    │ │ │ -0002ed90: 7229 3b0a 0a09 092f 2f20 6469 7363 6f6e  r);....// discon
    │ │ │ -0002eda0: 6e65 6374 2061 6c6c 2073 6565 6473 0a09  nect all seeds..
    │ │ │ -0002edb0: 0969 6620 2873 6574 7469 6e67 7328 292e  .if (settings().
    │ │ │ -0002edc0: 6765 745f 626f 6f6c 2873 6574 7469 6e67  get_bool(setting
    │ │ │ -0002edd0: 735f 7061 636b 3a3a 636c 6f73 655f 7265  s_pack::close_re
    │ │ │ -0002ede0: 6475 6e64 616e 745f 636f 6e6e 6563 7469  dundant_connecti
    │ │ │ -0002edf0: 6f6e 7329 290a 0909 7b0a 3c64 6976 2073  ons))...{.
    ...std:: │ │ │ -0002ee30: 7665 6374 6f72 266c 743b 7065 6572 5f63 vector<peer_c │ │ │ -0002ee40: 6f6e 6e65 6374 696f 6e2a 2667 743b 2073 onnection*> s │ │ │ -0002ee50: 6565 6473 3b0a 3c2f 6469 763e 0909 0966 eeds;.
    ...f │ │ │ -0002ee60: 6f72 2028 6175 746f 2063 6f6e 7374 2070 or (auto const p │ │ │ -0002ee70: 203a 206d 5f63 6f6e 6e65 6374 696f 6e73 : m_connections │ │ │ -0002ee80: 290a 0909 097b 0a09 0909 0954 4f52 5245 )....{.....TORRE │ │ │ -0002ee90: 4e54 5f49 4e43 5245 4d45 4e54 286d 5f69 NT_INCREMENT(m_i │ │ │ -0002eea0: 7465 7261 7469 6e67 5f63 6f6e 6e65 6374 terating_connect │ │ │ -0002eeb0: 696f 6e73 293b 0a09 0909 0954 4f52 5245 ions);.....TORRE │ │ │ -0002eec0: 4e54 5f41 5353 4552 5428 702d 2667 743b NT_ASSERT(p-> │ │ │ -0002eed0: 6173 736f 6369 6174 6564 5f74 6f72 7265 associated_torre │ │ │ -0002eee0: 6e74 2829 2e6c 6f63 6b28 292e 6765 7428 nt().lock().get( │ │ │ -0002eef0: 2920 3d3d 2074 6869 7329 3b0a 0909 0909 ) == this);..... │ │ │ -0002ef00: 6966 2028 702d 2667 743b 7570 6c6f 6164 if (p->upload │ │ │ -0002ef10: 5f6f 6e6c 7928 2920 2661 6d70 3b26 616d _only() &&am │ │ │ -0002ef20: 703b 2070 2d26 6774 3b63 616e 5f64 6973 p; p->can_dis │ │ │ -0002ef30: 636f 6e6e 6563 7428 6572 726f 7273 3a3a connect(errors:: │ │ │ -0002ef40: 746f 7272 656e 745f 6669 6e69 7368 6564 torrent_finished │ │ │ -0002ef50: 2929 0a09 0909 097b 0a23 6966 6e64 6566 )).....{.#ifndef │ │ │ -0002ef60: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ -0002ef70: 5f4c 4f47 4749 4e47 0a09 0909 0909 702d _LOGGING......p- │ │ │ -0002ef80: 2667 743b 7065 6572 5f6c 6f67 2870 6565 >peer_log(pee │ │ │ -0002ef90: 725f 6c6f 675f 616c 6572 743a 3a69 6e66 r_log_alert::inf │ │ │ -0002efa0: 6f2c 2022 5345 4544 222c 2022 434c 4f53 o, "SEED", "CLOS │ │ │ -0002efb0: 494e 4720 434f 4e4e 4543 5449 4f4e 2229 ING CONNECTION") │ │ │ -0002efc0: 3b0a 2365 6e64 6966 0a09 0909 0909 7365 ;.#endif......se │ │ │ -0002efd0: 6564 732e 7075 7368 5f62 6163 6b28 7029 eds.push_back(p) │ │ │ -0002efe0: 3b0a 0909 0909 7d0a 0909 097d 0a09 0909 ;.....}....}.... │ │ │ -0002eff0: 666f 7220 2861 7574 6f26 616d 703b 2070 for (auto& p │ │ │ -0002f000: 203a 2073 6565 6473 290a 0909 0909 702d : seeds).....p- │ │ │ -0002f010: 2667 743b 6469 7363 6f6e 6e65 6374 2865 >disconnect(e │ │ │ -0002f020: 7272 6f72 733a 3a74 6f72 7265 6e74 5f66 rrors::torrent_f │ │ │ -0002f030: 696e 6973 6865 642c 206f 7065 7261 7469 inished, operati │ │ │ -0002f040: 6f6e 5f74 3a3a 6269 7474 6f72 7265 6e74 on_t::bittorrent │ │ │ -0002f050: 0a09 0909 0909 2c20 7065 6572 5f63 6f6e ......, peer_con │ │ │ -0002f060: 6e65 6374 696f 6e5f 696e 7465 7266 6163 nection_interfac │ │ │ -0002f070: 653a 3a6e 6f72 6d61 6c29 3b0a 0909 7d0a e::normal);...}. │ │ │ -0002f080: 0a09 0969 6620 286d 5f61 626f 7274 2920 ...if (m_abort) │ │ │ -0002f090: 7265 7475 726e 3b0a 0a09 0975 7064 6174 return;....updat │ │ │ -0002f0a0: 655f 7761 6e74 5f70 6565 7273 2829 3b0a e_want_peers();. │ │ │ -0002f0b0: 0a09 0969 6620 286d 5f73 746f 7261 6765 ...if (m_storage │ │ │ -0002f0c0: 290a 0909 7b0a 0909 092f 2f20 7765 206e )...{....// we n │ │ │ -0002f0d0: 6565 6420 746f 206b 6565 7020 7468 6520 eed to keep the │ │ │ -0002f0e0: 6f62 6a65 6374 2061 6c69 7665 2064 7572 object alive dur │ │ │ -0002f0f0: 696e 6720 7468 6973 206f 7065 7261 7469 ing this operati │ │ │ -0002f100: 6f6e 0a09 0909 6d5f 7365 732e 6469 736b on....m_ses.disk │ │ │ -0002f110: 5f74 6872 6561 6428 292e 6173 796e 635f _thread().async_ │ │ │ -0002f120: 7265 6c65 6173 655f 6669 6c65 7328 6d5f release_files(m_ │ │ │ -0002f130: 7374 6f72 6167 650a 0909 0909 2c20 7374 storage....., st │ │ │ -0002f140: 643a 3a62 696e 6428 2661 6d70 3b74 6f72 d::bind(&tor │ │ │ -0002f150: 7265 6e74 3a3a 6f6e 5f63 6163 6865 5f66 rent::on_cache_f │ │ │ -0002f160: 6c75 7368 6564 2c20 7368 6172 6564 5f66 lushed, shared_f │ │ │ -0002f170: 726f 6d5f 7468 6973 2829 2c20 6661 6c73 rom_this(), fals │ │ │ -0002f180: 6529 293b 0a09 0909 6d5f 7365 732e 6465 e));....m_ses.de │ │ │ -0002f190: 6665 7272 6564 5f73 7562 6d69 745f 6a6f ferred_submit_jo │ │ │ -0002f1a0: 6273 2829 3b0a 0909 7d0a 0a09 092f 2f20 bs();...}....// │ │ │ -0002f1b0: 7468 6973 2074 6f72 7265 6e74 206a 7573 this torrent jus │ │ │ -0002f1c0: 7420 636f 6d70 6c65 7465 6420 646f 776e t completed down │ │ │ -0002f1d0: 6c6f 6164 732c 2077 6869 6368 206d 6561 loads, which mea │ │ │ -0002f1e0: 6e73 2069 7420 7769 6c6c 2066 616c 6c0a ns it will fall. │ │ │ -0002f1f0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0002f200: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0002f230: 313c 2f74 643e 3c74 643e 3c61 2068 7265 1
    ../src │ │ │ -0002f260: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ -0002f270: 703a 3537 3431 3c2f 613e 3c2f 7464 3e3c p:5741< │ │ │ -0002f280: 7464 3e72 6570 6f72 7420 7468 6520 7072 td>report the pr │ │ │ -0002f290: 6f70 6572 2061 6464 7265 7373 206f 6620 oper address of │ │ │ -0002f2a0: 7468 6520 726f 7574 6572 2061 7320 7468 the router as th │ │ │ -0002f2b0: 6520 736f 7572 6365 2049 5020 6f66 2074 e source IP of t │ │ │ -0002f2c0: 6869 7320 766f 7465 206f 6620 6f75 7220 his vote of our │ │ │ -0002f2d0: 6578 7465 726e 616c 2061 6464 7265 7373 external address │ │ │ -0002f2e0: 2c20 696e 7374 6561 6420 6f66 2074 6865 , instead of the │ │ │ -0002f2f0: 2065 6d70 7479 2061 6464 7265 7373 3c2f empty address

    repor │ │ │ -0002f350: 7420 7468 6520 7072 6f70 6572 2061 6464 t the proper add │ │ │ -0002f360: 7265 7373 206f 6620 7468 6520 726f 7574 ress of the rout │ │ │ -0002f370: 6572 2061 7320 7468 6520 736f 7572 6365 er as the source │ │ │ -0002f380: 2049 5020 6f66 0a74 6869 7320 766f 7465 IP of.this vote │ │ │ -0002f390: 206f 6620 6f75 7220 6578 7465 726e 616c of our external │ │ │ -0002f3a0: 2061 6464 7265 7373 2c20 696e 7374 6561 address, instea │ │ │ -0002f3b0: 6420 6f66 2074 6865 2065 6d70 7479 2061 d of the empty a │ │ │ -0002f3c0: 6464 7265 7373 3c2f 6832 3e3c 6834 3e2e ddress

    . │ │ │ -0002f3d0: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ -0002f3e0: 706c 2e63 7070 3a35 3734 313c 2f68 343e pl.cpp:5741

    │ │ │ -0002f3f0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .., li
    │ │ │ -0002f430: 7374 656e 5f73 6f63 6b65 745f 6861 6e64  sten_socket_hand
    │ │ │ -0002f440: 6c65 2063 6f6e 7374 2661 6d70 3b20 6c73  le const& ls
    │ │ │ -0002f450: 290a 097b 0a09 0954 4f52 5245 4e54 5f41  )..{...TORRENT_A
    │ │ │ -0002f460: 5353 4552 5428 6973 5f73 696e 676c 655f  SSERT(is_single_
    │ │ │ -0002f470: 7468 7265 6164 2829 293b 0a0a 0909 6c69  thread());....li
    │ │ │ -0002f480: 7374 656e 5f73 6f63 6b65 745f 742a 206c  sten_socket_t* l
    │ │ │ -0002f490: 6973 7465 6e5f 736f 636b 6574 203d 206c  isten_socket = l
    │ │ │ -0002f4a0: 732e 6765 7428 293b 0a0a 0909 2f2f 204e  s.get();....// N
    │ │ │ -0002f4b0: 4f54 453a 2064 6f6e 2774 2061 7373 756d  OTE: don't assum
    │ │ │ -0002f4c0: 6520 7468 6174 2069 6620 6563 2021 3d20  e that if ec != 
    │ │ │ -0002f4d0: 302c 2074 6865 2072 6573 7420 6f66 2074  0, the rest of t
    │ │ │ -0002f4e0: 6865 206c 6f67 6963 0a09 092f 2f20 6973  he logic...// is
    │ │ │ -0002f4f0: 206e 6f74 206e 6563 6573 7361 7279 2c20   not necessary, 
    │ │ │ -0002f500: 7468 6520 706f 7274 7320 7374 696c 6c20  the ports still 
    │ │ │ -0002f510: 6e65 6564 2074 6f20 6265 2073 6574 2c20  need to be set, 
    │ │ │ -0002f520: 696e 206f 7468 6572 0a09 092f 2f20 776f  in other...// wo
    │ │ │ -0002f530: 7264 732c 2064 6f6e 2774 2065 6172 6c79  rds, don't early
    │ │ │ -0002f540: 2072 6574 7572 6e20 7769 7468 6f75 7420   return without 
    │ │ │ -0002f550: 6361 7265 6675 6c20 7265 7669 6577 206f  careful review o
    │ │ │ -0002f560: 6620 7468 650a 0909 2f2f 2072 656d 6169  f the...// remai
    │ │ │ -0002f570: 6e69 6e67 206c 6f67 6963 0a09 0969 6620  ning logic...if 
    │ │ │ -0002f580: 2865 6320 2661 6d70 3b26 616d 703b 206d  (ec && m
    │ │ │ -0002f590: 5f61 6c65 7274 732e 7368 6f75 6c64 5f70  _alerts.should_p
    │ │ │ -0002f5a0: 6f73 7426 6c74 3b70 6f72 746d 6170 5f65  ost<portmap_e
    │ │ │ -0002f5b0: 7272 6f72 5f61 6c65 7274 2667 743b 2829  rror_alert>()
    │ │ │ -0002f5c0: 290a 0909 7b0a 0909 096d 5f61 6c65 7274  )...{....m_alert
    │ │ │ -0002f5d0: 732e 656d 706c 6163 655f 616c 6572 7426  s.emplace_alert&
    │ │ │ -0002f5e0: 6c74 3b70 6f72 746d 6170 5f65 7272 6f72  lt;portmap_error
    │ │ │ -0002f5f0: 5f61 6c65 7274 2667 743b 286d 6170 7069  _alert>(mappi
    │ │ │ -0002f600: 6e67 0a09 0909 092c 2074 7261 6e73 706f  ng....., transpo
    │ │ │ -0002f610: 7274 2c20 6563 2c20 6c69 7374 656e 5f73  rt, ec, listen_s
    │ │ │ -0002f620: 6f63 6b65 7420 3f20 6c69 7374 656e 5f73  ocket ? listen_s
    │ │ │ -0002f630: 6f63 6b65 742d 2667 743b 6c6f 6361 6c5f  ocket->local_
    │ │ │ -0002f640: 656e 6470 6f69 6e74 2e61 6464 7265 7373  endpoint.address
    │ │ │ -0002f650: 2829 203a 2061 6464 7265 7373 2829 293b  () : address());
    │ │ │ -0002f660: 0a09 097d 0a0a 0909 6966 2028 216c 6973  ...}....if (!lis
    │ │ │ -0002f670: 7465 6e5f 736f 636b 6574 2920 7265 7475  ten_socket) retu
    │ │ │ -0002f680: 726e 3b0a 0a09 0969 6620 2821 6563 2026  rn;....if (!ec &
    │ │ │ -0002f690: 616d 703b 2661 6d70 3b20 2165 7874 6572  amp;& !exter
    │ │ │ -0002f6a0: 6e61 6c5f 6970 2e69 735f 756e 7370 6563  nal_ip.is_unspec
    │ │ │ -0002f6b0: 6966 6965 6428 2929 0a09 097b 0a3c 6469  ified())...{....au
    │ │ │ -0002f6f0: 746f 2073 6f63 6b20 3d20 6c73 2e6d 5f73  to sock = ls.m_s
    │ │ │ -0002f700: 6f63 6b2e 6c6f 636b 2829 3b0a 3c2f 6469  ock.lock();....TORRENT_ASS
    │ │ │ -0002f720: 4552 5428 736f 636b 293b 0a09 0909 6966  ERT(sock);....if
    │ │ │ -0002f730: 2028 736f 636b 290a 0909 0909 7365 745f   (sock).....set_
    │ │ │ -0002f740: 6578 7465 726e 616c 5f61 6464 7265 7373  external_address
    │ │ │ -0002f750: 2873 6f63 6b2c 2065 7874 6572 6e61 6c5f  (sock, external_
    │ │ │ -0002f760: 6970 2c20 736f 7572 6365 5f72 6f75 7465  ip, source_route
    │ │ │ -0002f770: 722c 2061 6464 7265 7373 2829 293b 0a09  r, address());..
    │ │ │ -0002f780: 097d 0a0a 0909 2f2f 206e 6565 6420 746f  .}....// need to
    │ │ │ -0002f790: 2063 6865 636b 2077 6865 7468 6572 2074   check whether t
    │ │ │ -0002f7a0: 6869 7320 6d61 7070 696e 6720 6973 2066  his mapping is f
    │ │ │ -0002f7b0: 6f72 206f 6e65 206f 6620 7365 7373 696f  or one of sessio
    │ │ │ -0002f7c0: 6e20 706f 7274 7320 2869 7420 636f 756c  n ports (it coul
    │ │ │ -0002f7d0: 6420 616c 736f 2062 6520 6120 7573 6572  d also be a user
    │ │ │ -0002f7e0: 206d 6170 7069 6e67 290a 0909 6966 2028   mapping)...if (
    │ │ │ -0002f7f0: 2870 726f 746f 203d 3d20 706f 7274 6d61  (proto == portma
    │ │ │ -0002f800: 705f 7072 6f74 6f63 6f6c 3a3a 7463 7029  p_protocol::tcp)
    │ │ │ -0002f810: 2026 616d 703b 2661 6d70 3b20 286c 6973   && (lis
    │ │ │ -0002f820: 7465 6e5f 736f 636b 6574 2d26 6774 3b74  ten_socket->t
    │ │ │ -0002f830: 6370 5f70 6f72 745f 6d61 7070 696e 675b  cp_port_mapping[
    │ │ │ -0002f840: 7472 616e 7370 6f72 745d 2e6d 6170 7069  transport].mappi
    │ │ │ -0002f850: 6e67 203d 3d20 6d61 7070 696e 6729 290a  ng == mapping)).
    │ │ │ -0002f860: 0909 096c 6973 7465 6e5f 736f 636b 6574  ...listen_socket
    │ │ │ -0002f870: 2d26 6774 3b74 6370 5f70 6f72 745f 6d61  ->tcp_port_ma
    │ │ │ -0002f880: 7070 696e 675b 7472 616e 7370 6f72 745d  pping[transport]
    │ │ │ -0002f890: 2e70 6f72 7420 3d20 706f 7274 3b0a 0909  .port = port;...
    │ │ │ -0002f8a0: 656c 7365 2069 6620 2828 7072 6f74 6f20  else if ((proto 
    │ │ │ -0002f8b0: 3d3d 2070 6f72 746d 6170 5f70 726f 746f  == portmap_proto
    │ │ │ -0002f8c0: 636f 6c3a 3a75 6470 2920 2661 6d70 3b26  col::udp) &&
    │ │ │ -0002f8d0: 616d 703b 2028 6c69 7374 656e 5f73 6f63  amp; (listen_soc
    │ │ │ -0002f8e0: 6b65 742d 2667 743b 7564 705f 706f 7274  ket->udp_port
    │ │ │ -0002f8f0: 5f6d 6170 7069 6e67 5b74 7261 6e73 706f  _mapping[transpo
    │ │ │ -0002f900: 7274 5d2e 6d61 7070 696e 6720 3d3d 206d  rt].mapping == m
    │ │ │ -0002f910: 6170 7069 6e67 2929 0a09 0909 6c69 7374  apping))....list
    │ │ │ -0002f920: 656e 5f73 6f63 6b65 742d 2667 743b 7564  en_socket->ud
    │ │ │ -0002f930: 705f 706f 7274 5f6d 6170 7069 6e67 5b74  p_port_mapping[t
    │ │ │ -0002f940: 7261 6e73 706f 7274 5d2e 706f 7274 203d  ransport].port =
    │ │ │ -0002f950: 2070 6f72 743b 0a0a 0909 6966 2028 2165   port;....if (!e
    │ │ │ -0002f960: 6320 2661 6d70 3b26 616d 703b 206d 5f61  c && m_a
    │ │ │ -0002f970: 6c65 7274 732e 7368 6f75 6c64 5f70 6f73  lerts.should_pos
    │ │ │ -0002f980: 7426 6c74 3b70 6f72 746d 6170 5f61 6c65  t<portmap_ale
    │ │ │ -0002f990: 7274 2667 743b 2829 290a 0909 7b0a 0909  rt>())...{...
    │ │ │ -0002f9a0: 096d 5f61 6c65 7274 732e 656d 706c 6163  .m_alerts.emplac
    │ │ │ -0002f9b0: 655f 616c 6572 7426 6c74 3b70 6f72 746d  e_alert<portm
    │ │ │ -0002f9c0: 6170 5f61 6c65 7274 2667 743b 286d 6170  ap_alert>(map
    │ │ │ -0002f9d0: 7069 6e67 2c20 706f 7274 0a09 0909 092c  ping, port.....,
    │ │ │ -0002f9e0: 2074 7261 6e73 706f 7274 2c20 7072 6f74   transport, prot
    │ │ │ -0002f9f0: 6f2c 206c 6973 7465 6e5f 736f 636b 6574  o, listen_socket
    │ │ │ -0002fa00: 2d26 6774 3b6c 6f63 616c 5f65 6e64 706f  ->local_endpo
    │ │ │ -0002fa10: 696e 742e 6164 6472 6573 7328 2929 3b0a  int.address());.
    │ │ │ -0002fa20: 0909 7d0a 097d 0a0a 2369 6620 544f 5252  ..}..}..#if TORR
    │ │ │ -0002fa30: 454e 545f 4142 495f 5645 5253 494f 4e20  ENT_ABI_VERSION 
    │ │ │ -0002fa40: 3d3d 2031 0a09 7365 7373 696f 6e5f 7374  == 1..session_st
    │ │ │ -0002fa50: 6174 7573 2073 6573 7369 6f6e 5f69 6d70  atus session_imp
    │ │ │ -0002fa60: 6c3a 3a73 7461 7475 7328 2920 636f 6e73  l::status() cons
    │ │ │ -0002fa70: 740a 097b 0a2f 2f09 0949 4e56 4152 4941  t..{.//..INVARIA
    │ │ │ -0002fa80: 4e54 5f43 4845 434b 3b0a 0909 544f 5252  NT_CHECK;...TORR
    │ │ │ -0002fa90: 454e 545f 4153 5345 5254 2869 735f 7369  ENT_ASSERT(is_si
    │ │ │ -0002faa0: 6e67 6c65 5f74 6872 6561 6428 2929 3b0a  ngle_thread());.
    │ │ │ -0002fab0: 0a09 0973 6573 7369 6f6e 5f73 7461 7475  ...session_statu
    │ │ │ -0002fac0: 7320 733b 0a0a 0909 732e 6f70 7469 6d69  s s;....s.optimi
    │ │ │ -0002fad0: 7374 6963 5f75 6e63 686f 6b65 5f63 6f75  stic_unchoke_cou
    │ │ │ -0002fae0: 6e74 6572 203d 206d 5f6f 7074 696d 6973  nter = m_optimis
    │ │ │ -0002faf0: 7469 635f 756e 6368 6f6b 655f 7469 6d65  tic_unchoke_time
    │ │ │ -0002fb00: 5f73 6361 6c65 723b 0a09 0973 2e75 6e63  _scaler;...s.unc
    │ │ │ -0002fb10: 686f 6b65 5f63 6f75 6e74 6572 203d 206d  hoke_counter = m
    │ │ │ -0002fb20: 5f75 6e63 686f 6b65 5f74 696d 655f 7363  _unchoke_time_sc
    │ │ │ -0002fb30: 616c 6572 3b0a 0909 732e 6e75 6d5f 6465  aler;...s.num_de
    │ │ │ -0002fb40: 6164 5f70 6565 7273 203d 2069 6e74 286d  ad_peers = int(m
    │ │ │ -0002fb50: 5f75 6e64 6561 645f 7065 6572 732e 7369  _undead_peers.si
    │ │ │ -0002fb60: 7a65 2829 293b 0a0a 3c2f 7072 653e 3c2f  ze());..
    ../src/sess │ │ │ +0002ded0: 696f 6e5f 696d 706c 2e63 7070 3a35 3734 ion_impl.cpp:574 │ │ │ +0002dee0: 313c 2f61 3e3c 2f74 643e 3c74 643e 7265 1re │ │ │ +0002def0: 706f 7274 2074 6865 2070 726f 7065 7220 port the proper │ │ │ +0002df00: 6164 6472 6573 7320 6f66 2074 6865 2072 address of the r │ │ │ +0002df10: 6f75 7465 7220 6173 2074 6865 2073 6f75 outer as the sou │ │ │ +0002df20: 7263 6520 4950 206f 6620 7468 6973 2076 rce IP of this v │ │ │ +0002df30: 6f74 6520 6f66 206f 7572 2065 7874 6572 ote of our exter │ │ │ +0002df40: 6e61 6c20 6164 6472 6573 732c 2069 6e73 nal address, ins │ │ │ +0002df50: 7465 6164 206f 6620 7468 6520 656d 7074 tead of the empt │ │ │ +0002df60: 7920 6164 6472 6573 733c 2f74 643e 3c2f y address

    report the │ │ │ +0002dfc0: 2070 726f 7065 7220 6164 6472 6573 7320 proper address │ │ │ +0002dfd0: 6f66 2074 6865 2072 6f75 7465 7220 6173 of the router as │ │ │ +0002dfe0: 2074 6865 2073 6f75 7263 6520 4950 206f the source IP o │ │ │ +0002dff0: 660a 7468 6973 2076 6f74 6520 6f66 206f f.this vote of o │ │ │ +0002e000: 7572 2065 7874 6572 6e61 6c20 6164 6472 ur external addr │ │ │ +0002e010: 6573 732c 2069 6e73 7465 6164 206f 6620 ess, instead of │ │ │ +0002e020: 7468 6520 656d 7074 7920 6164 6472 6573 the empty addres │ │ │ +0002e030: 733c 2f68 323e 3c68 343e 2e2e 2f73 7263 s

    ../src │ │ │ +0002e040: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ +0002e050: 703a 3537 3431 3c2f 6834 3e3c 7072 6520 p:5741

    .., listen_
    │ │ │ +0002e0a0: 736f 636b 6574 5f68 616e 646c 6520 636f  socket_handle co
    │ │ │ +0002e0b0: 6e73 7426 616d 703b 206c 7329 0a09 7b0a  nst& ls)..{.
    │ │ │ +0002e0c0: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ +0002e0d0: 2869 735f 7369 6e67 6c65 5f74 6872 6561  (is_single_threa
    │ │ │ +0002e0e0: 6428 2929 3b0a 0a09 096c 6973 7465 6e5f  d());....listen_
    │ │ │ +0002e0f0: 736f 636b 6574 5f74 2a20 6c69 7374 656e  socket_t* listen
    │ │ │ +0002e100: 5f73 6f63 6b65 7420 3d20 6c73 2e67 6574  _socket = ls.get
    │ │ │ +0002e110: 2829 3b0a 0a09 092f 2f20 4e4f 5445 3a20  ();....// NOTE: 
    │ │ │ +0002e120: 646f 6e27 7420 6173 7375 6d65 2074 6861  don't assume tha
    │ │ │ +0002e130: 7420 6966 2065 6320 213d 2030 2c20 7468  t if ec != 0, th
    │ │ │ +0002e140: 6520 7265 7374 206f 6620 7468 6520 6c6f  e rest of the lo
    │ │ │ +0002e150: 6769 630a 0909 2f2f 2069 7320 6e6f 7420  gic...// is not 
    │ │ │ +0002e160: 6e65 6365 7373 6172 792c 2074 6865 2070  necessary, the p
    │ │ │ +0002e170: 6f72 7473 2073 7469 6c6c 206e 6565 6420  orts still need 
    │ │ │ +0002e180: 746f 2062 6520 7365 742c 2069 6e20 6f74  to be set, in ot
    │ │ │ +0002e190: 6865 720a 0909 2f2f 2077 6f72 6473 2c20  her...// words, 
    │ │ │ +0002e1a0: 646f 6e27 7420 6561 726c 7920 7265 7475  don't early retu
    │ │ │ +0002e1b0: 726e 2077 6974 686f 7574 2063 6172 6566  rn without caref
    │ │ │ +0002e1c0: 756c 2072 6576 6965 7720 6f66 2074 6865  ul review of the
    │ │ │ +0002e1d0: 0a09 092f 2f20 7265 6d61 696e 696e 6720  ...// remaining 
    │ │ │ +0002e1e0: 6c6f 6769 630a 0909 6966 2028 6563 2026  logic...if (ec &
    │ │ │ +0002e1f0: 616d 703b 2661 6d70 3b20 6d5f 616c 6572  amp;& m_aler
    │ │ │ +0002e200: 7473 2e73 686f 756c 645f 706f 7374 266c  ts.should_post&l
    │ │ │ +0002e210: 743b 706f 7274 6d61 705f 6572 726f 725f  t;portmap_error_
    │ │ │ +0002e220: 616c 6572 7426 6774 3b28 2929 0a09 097b  alert>())...{
    │ │ │ +0002e230: 0a09 0909 6d5f 616c 6572 7473 2e65 6d70  ....m_alerts.emp
    │ │ │ +0002e240: 6c61 6365 5f61 6c65 7274 266c 743b 706f  lace_alert<po
    │ │ │ +0002e250: 7274 6d61 705f 6572 726f 725f 616c 6572  rtmap_error_aler
    │ │ │ +0002e260: 7426 6774 3b28 6d61 7070 696e 670a 0909  t>(mapping...
    │ │ │ +0002e270: 0909 2c20 7472 616e 7370 6f72 742c 2065  .., transport, e
    │ │ │ +0002e280: 632c 206c 6973 7465 6e5f 736f 636b 6574  c, listen_socket
    │ │ │ +0002e290: 203f 206c 6973 7465 6e5f 736f 636b 6574   ? listen_socket
    │ │ │ +0002e2a0: 2d26 6774 3b6c 6f63 616c 5f65 6e64 706f  ->local_endpo
    │ │ │ +0002e2b0: 696e 742e 6164 6472 6573 7328 2920 3a20  int.address() : 
    │ │ │ +0002e2c0: 6164 6472 6573 7328 2929 3b0a 0909 7d0a  address());...}.
    │ │ │ +0002e2d0: 0a09 0969 6620 2821 6c69 7374 656e 5f73  ...if (!listen_s
    │ │ │ +0002e2e0: 6f63 6b65 7429 2072 6574 7572 6e3b 0a0a  ocket) return;..
    │ │ │ +0002e2f0: 0909 6966 2028 2165 6320 2661 6d70 3b26  ..if (!ec &&
    │ │ │ +0002e300: 616d 703b 2021 6578 7465 726e 616c 5f69  amp; !external_i
    │ │ │ +0002e310: 702e 6973 5f75 6e73 7065 6369 6669 6564  p.is_unspecified
    │ │ │ +0002e320: 2829 290a 0909 7b0a 3c64 6976 2073 7479  ())...{.
    ...auto so │ │ │ +0002e360: 636b 203d 206c 732e 6d5f 736f 636b 2e6c ck = ls.m_sock.l │ │ │ +0002e370: 6f63 6b28 293b 0a3c 2f64 6976 3e09 0909 ock();.
    ... │ │ │ +0002e380: 544f 5252 454e 545f 4153 5345 5254 2873 TORRENT_ASSERT(s │ │ │ +0002e390: 6f63 6b29 3b0a 0909 0969 6620 2873 6f63 ock);....if (soc │ │ │ +0002e3a0: 6b29 0a09 0909 0973 6574 5f65 7874 6572 k).....set_exter │ │ │ +0002e3b0: 6e61 6c5f 6164 6472 6573 7328 736f 636b nal_address(sock │ │ │ +0002e3c0: 2c20 6578 7465 726e 616c 5f69 702c 2073 , external_ip, s │ │ │ +0002e3d0: 6f75 7263 655f 726f 7574 6572 2c20 6164 ource_router, ad │ │ │ +0002e3e0: 6472 6573 7328 2929 3b0a 0909 7d0a 0a09 dress());...}... │ │ │ +0002e3f0: 092f 2f20 6e65 6564 2074 6f20 6368 6563 .// need to chec │ │ │ +0002e400: 6b20 7768 6574 6865 7220 7468 6973 206d k whether this m │ │ │ +0002e410: 6170 7069 6e67 2069 7320 666f 7220 6f6e apping is for on │ │ │ +0002e420: 6520 6f66 2073 6573 7369 6f6e 2070 6f72 e of session por │ │ │ +0002e430: 7473 2028 6974 2063 6f75 6c64 2061 6c73 ts (it could als │ │ │ +0002e440: 6f20 6265 2061 2075 7365 7220 6d61 7070 o be a user mapp │ │ │ +0002e450: 696e 6729 0a09 0969 6620 2828 7072 6f74 ing)...if ((prot │ │ │ +0002e460: 6f20 3d3d 2070 6f72 746d 6170 5f70 726f o == portmap_pro │ │ │ +0002e470: 746f 636f 6c3a 3a74 6370 2920 2661 6d70 tocol::tcp) & │ │ │ +0002e480: 3b26 616d 703b 2028 6c69 7374 656e 5f73 ;& (listen_s │ │ │ +0002e490: 6f63 6b65 742d 2667 743b 7463 705f 706f ocket->tcp_po │ │ │ +0002e4a0: 7274 5f6d 6170 7069 6e67 5b74 7261 6e73 rt_mapping[trans │ │ │ +0002e4b0: 706f 7274 5d2e 6d61 7070 696e 6720 3d3d port].mapping == │ │ │ +0002e4c0: 206d 6170 7069 6e67 2929 0a09 0909 6c69 mapping))....li │ │ │ +0002e4d0: 7374 656e 5f73 6f63 6b65 742d 2667 743b sten_socket-> │ │ │ +0002e4e0: 7463 705f 706f 7274 5f6d 6170 7069 6e67 tcp_port_mapping │ │ │ +0002e4f0: 5b74 7261 6e73 706f 7274 5d2e 706f 7274 [transport].port │ │ │ +0002e500: 203d 2070 6f72 743b 0a09 0965 6c73 6520 = port;...else │ │ │ +0002e510: 6966 2028 2870 726f 746f 203d 3d20 706f if ((proto == po │ │ │ +0002e520: 7274 6d61 705f 7072 6f74 6f63 6f6c 3a3a rtmap_protocol:: │ │ │ +0002e530: 7564 7029 2026 616d 703b 2661 6d70 3b20 udp) && │ │ │ +0002e540: 286c 6973 7465 6e5f 736f 636b 6574 2d26 (listen_socket-& │ │ │ +0002e550: 6774 3b75 6470 5f70 6f72 745f 6d61 7070 gt;udp_port_mapp │ │ │ +0002e560: 696e 675b 7472 616e 7370 6f72 745d 2e6d ing[transport].m │ │ │ +0002e570: 6170 7069 6e67 203d 3d20 6d61 7070 696e apping == mappin │ │ │ +0002e580: 6729 290a 0909 096c 6973 7465 6e5f 736f g))....listen_so │ │ │ +0002e590: 636b 6574 2d26 6774 3b75 6470 5f70 6f72 cket->udp_por │ │ │ +0002e5a0: 745f 6d61 7070 696e 675b 7472 616e 7370 t_mapping[transp │ │ │ +0002e5b0: 6f72 745d 2e70 6f72 7420 3d20 706f 7274 ort].port = port │ │ │ +0002e5c0: 3b0a 0a09 0969 6620 2821 6563 2026 616d ;....if (!ec &am │ │ │ +0002e5d0: 703b 2661 6d70 3b20 6d5f 616c 6572 7473 p;& m_alerts │ │ │ +0002e5e0: 2e73 686f 756c 645f 706f 7374 266c 743b .should_post< │ │ │ +0002e5f0: 706f 7274 6d61 705f 616c 6572 7426 6774 portmap_alert> │ │ │ +0002e600: 3b28 2929 0a09 097b 0a09 0909 6d5f 616c ;())...{....m_al │ │ │ +0002e610: 6572 7473 2e65 6d70 6c61 6365 5f61 6c65 erts.emplace_ale │ │ │ +0002e620: 7274 266c 743b 706f 7274 6d61 705f 616c rt<portmap_al │ │ │ +0002e630: 6572 7426 6774 3b28 6d61 7070 696e 672c ert>(mapping, │ │ │ +0002e640: 2070 6f72 740a 0909 0909 2c20 7472 616e port....., tran │ │ │ +0002e650: 7370 6f72 742c 2070 726f 746f 2c20 6c69 sport, proto, li │ │ │ +0002e660: 7374 656e 5f73 6f63 6b65 742d 2667 743b sten_socket-> │ │ │ +0002e670: 6c6f 6361 6c5f 656e 6470 6f69 6e74 2e61 local_endpoint.a │ │ │ +0002e680: 6464 7265 7373 2829 293b 0a09 097d 0a09 ddress());...}.. │ │ │ +0002e690: 7d0a 0a23 6966 2054 4f52 5245 4e54 5f41 }..#if TORRENT_A │ │ │ +0002e6a0: 4249 5f56 4552 5349 4f4e 203d 3d20 310a BI_VERSION == 1. │ │ │ +0002e6b0: 0973 6573 7369 6f6e 5f73 7461 7475 7320 .session_status │ │ │ +0002e6c0: 7365 7373 696f 6e5f 696d 706c 3a3a 7374 session_impl::st │ │ │ +0002e6d0: 6174 7573 2829 2063 6f6e 7374 0a09 7b0a atus() const..{. │ │ │ +0002e6e0: 2f2f 0909 494e 5641 5249 414e 545f 4348 //..INVARIANT_CH │ │ │ +0002e6f0: 4543 4b3b 0a09 0954 4f52 5245 4e54 5f41 ECK;...TORRENT_A │ │ │ +0002e700: 5353 4552 5428 6973 5f73 696e 676c 655f SSERT(is_single_ │ │ │ +0002e710: 7468 7265 6164 2829 293b 0a0a 0909 7365 thread());....se │ │ │ +0002e720: 7373 696f 6e5f 7374 6174 7573 2073 3b0a ssion_status s;. │ │ │ +0002e730: 0a09 0973 2e6f 7074 696d 6973 7469 635f ...s.optimistic_ │ │ │ +0002e740: 756e 6368 6f6b 655f 636f 756e 7465 7220 unchoke_counter │ │ │ +0002e750: 3d20 6d5f 6f70 7469 6d69 7374 6963 5f75 = m_optimistic_u │ │ │ +0002e760: 6e63 686f 6b65 5f74 696d 655f 7363 616c nchoke_time_scal │ │ │ +0002e770: 6572 3b0a 0909 732e 756e 6368 6f6b 655f er;...s.unchoke_ │ │ │ +0002e780: 636f 756e 7465 7220 3d20 6d5f 756e 6368 counter = m_unch │ │ │ +0002e790: 6f6b 655f 7469 6d65 5f73 6361 6c65 723b oke_time_scaler; │ │ │ +0002e7a0: 0a09 0973 2e6e 756d 5f64 6561 645f 7065 ...s.num_dead_pe │ │ │ +0002e7b0: 6572 7320 3d20 696e 7428 6d5f 756e 6465 ers = int(m_unde │ │ │ +0002e7c0: 6164 5f70 6565 7273 2e73 697a 6528 2929 ad_peers.size()) │ │ │ +0002e7d0: 3b0a 0a3c 2f70 7265 3e3c 2f74 643e 3c2f ;..
    │ │ │ +0002e800: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +0002e810: 7370 3b31 3c2f 7464 3e3c 7464 3e3c 6120 sp;1../ │ │ │ +0002e840: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ +0002e850: 3131 3739 3c2f 613e 3c2f 7464 3e3c 7464 1179make this depen │ │ │ +0002e870: 6420 6f6e 2074 6865 2065 7272 6f72 2061 d on the error a │ │ │ +0002e880: 6e64 206f 6e20 7468 6520 6669 6c65 7379 nd on the filesy │ │ │ +0002e890: 7374 656d 2074 6865 2066 696c 6573 2061 stem the files a │ │ │ +0002e8a0: 7265 2062 6569 6e67 2064 6f77 6e6c 6f61 re being downloa │ │ │ +0002e8b0: 6465 6420 746f 2e20 4966 2074 6865 2065 ded to. If the e │ │ │ +0002e8c0: 7272 6f72 2069 7320 6e6f 5f73 7061 6365 rror is no_space │ │ │ +0002e8d0: 5f6c 6566 745f 6f6e 5f64 6576 6963 6520 _left_on_device │ │ │ +0002e8e0: 616e 6420 7468 6520 6669 6c65 7379 7374 and the filesyst │ │ │ +0002e8f0: 656d 2064 6f65 736e 2774 2073 7570 706f em doesn't suppo │ │ │ +0002e900: 7274 2073 7061 7273 6520 6669 6c65 732c rt sparse files, │ │ │ +0002e910: 206f 6e6c 7920 7a65 726f 2074 6865 2070 only zero the p │ │ │ +0002e920: 7269 6f72 6974 6965 7320 6f66 2074 6865 riorities of the │ │ │ +0002e930: 2070 6965 6365 7320 7468 6174 2061 7265 pieces that are │ │ │ +0002e940: 2061 7420 7468 6520 7461 696c 7320 6f66 at the tails of │ │ │ +0002e950: 2061 6c6c 2066 696c 6573 2c20 6c65 6176 all files, leav │ │ │ +0002e960: 696e 6720 6576 6572 7974 6869 6e67 2075 ing everything u │ │ │ +0002e970: 7020 746f 2074 6865 2068 6967 6865 7374 p to the highest │ │ │ +0002e980: 2077 7269 7474 656e 2070 6965 6365 2069 written piece i │ │ │ +0002e990: 6e20 6561 6368 2066 696c 653c 2f74 643e n each file │ │ │ +0002e9a0: 3c2f 7472 3e3c 7472 2069 643d 2239 3222

    make thi │ │ │ +0002e9f0: 7320 6465 7065 6e64 206f 6e20 7468 6520 s depend on the │ │ │ +0002ea00: 6572 726f 7220 616e 6420 6f6e 2074 6865 error and on the │ │ │ +0002ea10: 2066 696c 6573 7973 7465 6d20 7468 650a filesystem the. │ │ │ +0002ea20: 6669 6c65 7320 6172 6520 6265 696e 6720 files are being │ │ │ +0002ea30: 646f 776e 6c6f 6164 6564 2074 6f2e 2049 downloaded to. I │ │ │ +0002ea40: 6620 7468 6520 6572 726f 7220 6973 206e f the error is n │ │ │ +0002ea50: 6f5f 7370 6163 655f 6c65 6674 5f6f 6e5f o_space_left_on_ │ │ │ +0002ea60: 6465 7669 6365 0a61 6e64 2074 6865 2066 device.and the f │ │ │ +0002ea70: 696c 6573 7973 7465 6d20 646f 6573 6e27 ilesystem doesn' │ │ │ +0002ea80: 7420 7375 7070 6f72 7420 7370 6172 7365 t support sparse │ │ │ +0002ea90: 2066 696c 6573 2c20 6f6e 6c79 207a 6572 files, only zer │ │ │ +0002eaa0: 6f20 7468 6520 7072 696f 7269 7469 6573 o the priorities │ │ │ +0002eab0: 0a6f 6620 7468 6520 7069 6563 6573 2074 .of the pieces t │ │ │ +0002eac0: 6861 7420 6172 6520 6174 2074 6865 2074 hat are at the t │ │ │ +0002ead0: 6169 6c73 206f 6620 616c 6c20 6669 6c65 ails of all file │ │ │ +0002eae0: 732c 206c 6561 7669 6e67 2065 7665 7279 s, leaving every │ │ │ +0002eaf0: 7468 696e 670a 7570 2074 6f20 7468 6520 thing.up to the │ │ │ +0002eb00: 6869 6768 6573 7420 7772 6974 7465 6e20 highest written │ │ │ +0002eb10: 7069 6563 6520 696e 2065 6163 6820 6669 piece in each fi │ │ │ +0002eb20: 6c65 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 le

    ../sr │ │ │ +0002eb30: 632f 746f 7272 656e 742e 6370 703a 3131 c/torrent.cpp:11 │ │ │ +0002eb40: 3739 3c2f 6834 3e3c 7072 6520 7374 796c 79

    ...// notify th
    │ │ │ +0002eb90: 6520 7573 6572 206f 6620 7468 6520 6572  e user of the er
    │ │ │ +0002eba0: 726f 720a 0909 6966 2028 616c 6572 7473  ror...if (alerts
    │ │ │ +0002ebb0: 2829 2e73 686f 756c 645f 706f 7374 266c  ().should_post&l
    │ │ │ +0002ebc0: 743b 6669 6c65 5f65 7272 6f72 5f61 6c65  t;file_error_ale
    │ │ │ +0002ebd0: 7274 2667 743b 2829 290a 0909 0961 6c65  rt>())....ale
    │ │ │ +0002ebe0: 7274 7328 292e 656d 706c 6163 655f 616c  rts().emplace_al
    │ │ │ +0002ebf0: 6572 7426 6c74 3b66 696c 655f 6572 726f  ert<file_erro
    │ │ │ +0002ec00: 725f 616c 6572 7426 6774 3b28 6572 726f  r_alert>(erro
    │ │ │ +0002ec10: 722e 6563 0a09 0909 092c 2072 6573 6f6c  r.ec....., resol
    │ │ │ +0002ec20: 7665 5f66 696c 656e 616d 6528 6572 726f  ve_filename(erro
    │ │ │ +0002ec30: 722e 6669 6c65 2829 292c 2065 7272 6f72  r.file()), error
    │ │ │ +0002ec40: 2e6f 7065 7261 7469 6f6e 2c20 6765 745f  .operation, get_
    │ │ │ +0002ec50: 6861 6e64 6c65 2829 293b 0a0a 0909 2f2f  handle());....//
    │ │ │ +0002ec60: 2069 6620 6120 7772 6974 6520 6f70 6572   if a write oper
    │ │ │ +0002ec70: 6174 696f 6e20 6661 696c 6564 2c20 616e  ation failed, an
    │ │ │ +0002ec80: 6420 6675 7475 7265 2077 7269 7465 7320  d future writes 
    │ │ │ +0002ec90: 6172 6520 6c69 6b65 6c79 2074 6f0a 0909  are likely to...
    │ │ │ +0002eca0: 2f2f 2066 6169 6c2c 2077 6869 6c65 2072  // fail, while r
    │ │ │ +0002ecb0: 6561 6473 206d 6179 2073 7563 6365 6564  eads may succeed
    │ │ │ +0002ecc0: 2c20 6a75 7374 2073 6574 2074 6865 2074  , just set the t
    │ │ │ +0002ecd0: 6f72 7265 6e74 2074 6f20 7570 6c6f 6164  orrent to upload
    │ │ │ +0002ece0: 206d 6f64 650a 0909 2f2f 2069 6620 7765   mode...// if we
    │ │ │ +0002ecf0: 206d 616b 6520 616e 2069 6e63 6f72 7265   make an incorre
    │ │ │ +0002ed00: 6374 2061 7373 756d 7074 696f 6e20 6865  ct assumption he
    │ │ │ +0002ed10: 7265 2c20 6974 2773 206e 6f74 2074 6865  re, it's not the
    │ │ │ +0002ed20: 2065 6e64 206f 6620 7468 650a 0909 2f2f   end of the...//
    │ │ │ +0002ed30: 2077 6f72 6c64 2c20 6966 2077 6520 6576   world, if we ev
    │ │ │ +0002ed40: 6572 2069 7373 7565 2061 2072 6561 6420  er issue a read 
    │ │ │ +0002ed50: 7265 7175 6573 7420 616e 6420 6974 2066  request and it f
    │ │ │ +0002ed60: 6169 6c73 2061 7320 7765 6c6c 2c20 7765  ails as well, we
    │ │ │ +0002ed70: 0a09 092f 2f20 776f 6e27 7420 6765 7420  ...// won't get 
    │ │ │ +0002ed80: 696e 2068 6572 6520 616e 6420 7765 276c  in here and we'l
    │ │ │ +0002ed90: 6c20 6163 7475 616c 6c79 2065 6e64 2075  l actually end u
    │ │ │ +0002eda0: 7020 7061 7573 696e 6720 7468 6520 746f  p pausing the to
    │ │ │ +0002edb0: 7272 656e 740a 0909 6966 2028 7277 203d  rrent...if (rw =
    │ │ │ +0002edc0: 3d20 6469 736b 5f63 6c61 7373 3a3a 7772  = disk_class::wr
    │ │ │ +0002edd0: 6974 650a 0909 0926 616d 703b 2661 6d70  ite....&&
    │ │ │ +0002ede0: 3b20 2865 7272 6f72 2e65 6320 3d3d 2062  ; (error.ec == b
    │ │ │ +0002edf0: 6f6f 7374 3a3a 7379 7374 656d 3a3a 6572  oost::system::er
    │ │ │ +0002ee00: 7263 3a3a 7265 6164 5f6f 6e6c 795f 6669  rc::read_only_fi
    │ │ │ +0002ee10: 6c65 5f73 7973 7465 6d0a 0909 097c 7c20  le_system....|| 
    │ │ │ +0002ee20: 6572 726f 722e 6563 203d 3d20 626f 6f73  error.ec == boos
    │ │ │ +0002ee30: 743a 3a73 7973 7465 6d3a 3a65 7272 633a  t::system::errc:
    │ │ │ +0002ee40: 3a70 6572 6d69 7373 696f 6e5f 6465 6e69  :permission_deni
    │ │ │ +0002ee50: 6564 0a09 0909 7c7c 2065 7272 6f72 2e65  ed....|| error.e
    │ │ │ +0002ee60: 6320 3d3d 2062 6f6f 7374 3a3a 7379 7374  c == boost::syst
    │ │ │ +0002ee70: 656d 3a3a 6572 7263 3a3a 6f70 6572 6174  em::errc::operat
    │ │ │ +0002ee80: 696f 6e5f 6e6f 745f 7065 726d 6974 7465  ion_not_permitte
    │ │ │ +0002ee90: 640a 0909 097c 7c20 6572 726f 722e 6563  d....|| error.ec
    │ │ │ +0002eea0: 203d 3d20 626f 6f73 743a 3a73 7973 7465   == boost::syste
    │ │ │ +0002eeb0: 6d3a 3a65 7272 633a 3a6e 6f5f 7370 6163  m::errc::no_spac
    │ │ │ +0002eec0: 655f 6f6e 5f64 6576 6963 650a 0909 097c  e_on_device....|
    │ │ │ +0002eed0: 7c20 6572 726f 722e 6563 203d 3d20 626f  | error.ec == bo
    │ │ │ +0002eee0: 6f73 743a 3a73 7973 7465 6d3a 3a65 7272  ost::system::err
    │ │ │ +0002eef0: 633a 3a66 696c 655f 746f 6f5f 6c61 7267  c::file_too_larg
    │ │ │ +0002ef00: 6529 290a 0909 7b0a 0909 092f 2f20 6966  e))...{....// if
    │ │ │ +0002ef10: 2077 6520 6661 696c 6564 2074 6f20 7772   we failed to wr
    │ │ │ +0002ef20: 6974 652c 2073 746f 7020 646f 776e 6c6f  ite, stop downlo
    │ │ │ +0002ef30: 6164 696e 6720 616e 6420 6a75 7374 0a09  ading and just..
    │ │ │ +0002ef40: 0909 2f2f 206b 6565 7020 7365 6564 696e  ..// keep seedin
    │ │ │ +0002ef50: 672e 0a3c 6469 7620 7374 796c 653d 2262  g..
    ...set_upload_m │ │ │ +0002ef90: 6f64 6528 7472 7565 293b 0a3c 2f64 6976 ode(true);.
    ...return;...}. │ │ │ +0002efb0: 0a09 092f 2f20 7075 7420 7468 6520 746f ...// put the to │ │ │ +0002efc0: 7272 656e 7420 696e 2061 6e20 6572 726f rrent in an erro │ │ │ +0002efd0: 722d 7374 6174 650a 0909 7365 745f 6572 r-state...set_er │ │ │ +0002efe0: 726f 7228 6572 726f 722e 6563 2c20 6572 ror(error.ec, er │ │ │ +0002eff0: 726f 722e 6669 6c65 2829 293b 0a0a 0909 ror.file());.... │ │ │ +0002f000: 2f2f 2069 6620 7468 6520 6572 726f 7220 // if the error │ │ │ +0002f010: 6170 7065 6172 7320 746f 2062 6520 6d6f appears to be mo │ │ │ +0002f020: 7265 2073 6572 696f 7573 2074 6861 6e20 re serious than │ │ │ +0002f030: 6120 6675 6c6c 2064 6973 6b2c 206a 7573 a full disk, jus │ │ │ +0002f040: 7420 7061 7573 6520 7468 6520 746f 7272 t pause the torr │ │ │ +0002f050: 656e 740a 0909 7061 7573 6528 293b 0a09 ent...pause();.. │ │ │ +0002f060: 7d0a 0a09 766f 6964 2074 6f72 7265 6e74 }...void torrent │ │ │ +0002f070: 3a3a 6861 6e64 6c65 5f69 6e63 6f6e 7369 ::handle_inconsi │ │ │ +0002f080: 7374 656e 745f 6861 7368 6573 2870 6965 stent_hashes(pie │ │ │ +0002f090: 6365 5f69 6e64 6578 5f74 2063 6f6e 7374 ce_index_t const │ │ │ +0002f0a0: 2070 6965 6365 290a 097b 0a09 0961 7574 piece)..{...aut │ │ │ +0002f0b0: 6f20 636f 6e73 7420 6669 6c65 5f73 6c69 o const file_sli │ │ │ +0002f0c0: 6365 7320 3d20 746f 7272 656e 745f 6669 ces = torrent_fi │ │ │ +0002f0d0: 6c65 2829 2e6d 6170 5f62 6c6f 636b 2870 le().map_block(p │ │ │ +0002f0e0: 6965 6365 2c20 302c 2030 293b 0a09 0966 iece, 0, 0);...f │ │ │ +0002f0f0: 696c 655f 696e 6465 785f 7420 636f 6e73 ile_index_t cons │ │ │ +0002f100: 7420 6669 6c65 203d 2066 696c 655f 736c t file = file_sl │ │ │ +0002f110: 6963 6573 2e65 6d70 7479 2829 203f 2074 ices.empty() ? t │ │ │ +0002f120: 6f72 7265 6e74 5f73 7461 7475 733a 3a65 orrent_status::e │ │ │ +0002f130: 7272 6f72 5f66 696c 655f 6e6f 6e65 203a rror_file_none : │ │ │ +0002f140: 2066 696c 655f 736c 6963 6573 5b30 5d2e file_slices[0]. │ │ │ +0002f150: 6669 6c65 5f69 6e64 6578 3b0a 0909 7365 file_index;...se │ │ │ +0002f160: 745f 6572 726f 7228 6572 726f 7273 3a3a t_error(errors:: │ │ │ +0002f170: 746f 7272 656e 745f 696e 636f 6e73 6973 torrent_inconsis │ │ │ +0002f180: 7465 6e74 5f68 6173 6865 732c 2066 696c tent_hashes, fil │ │ │ +0002f190: 6529 3b0a 0909 2f2f 2069 6620 7468 6973 e);...// if this │ │ │ +0002f1a0: 2069 7320 6120 6879 6272 6964 2074 6f72 is a hybrid tor │ │ │ +0002f1b0: 7265 6e74 2c20 7765 206d 6179 2068 6176 rent, we may hav │ │ │ +0002f1c0: 6520 6d61 726b 6564 2073 6f6d 6520 6d6f e marked some mo │ │ │ +0002f1d0: 7265 2070 6965 6365 730a 0909 2f2f 2061 re pieces...// a │ │ │ +0002f1e0: 7320 2268 6176 6522 2062 7574 206e 6f74 s "have" but not │ │ │ +0002f1f0: 2079 6574 2076 616c 6964 6174 6564 2074 yet validated t │ │ │ +0002f200: 6865 6d20 6167 6169 6e73 7420 7468 6520 hem against the │ │ │ +0002f210: 7632 2068 6173 6865 732e 2041 740a 0909 v2 hashes. At... │ │ │ +0002f220: 2f2f 2074 6869 7320 706f 696e 742c 206a // this point, j │ │ │ +0002f230: 7573 7420 6173 7375 6d65 2077 6520 6861 ust assume we ha │ │ │ +0002f240: 7665 206e 6f20 7069 6563 6573 0a09 096d ve no pieces...m │ │ │ +0002f250: 5f70 6963 6b65 722e 7265 7365 7428 293b _picker.reset(); │ │ │ +0002f260: 0a09 096d 5f68 6173 685f 7069 636b 6572 ...m_hash_picker │ │ │ +0002f270: 2e72 6573 6574 2829 3b0a 0909 6d5f 6669 .reset();...m_fi │ │ │ +0002f280: 6c65 5f70 726f 6772 6573 732e 636c 6561 le_progress.clea │ │ │ +0002f290: 7228 293b 0a09 0973 6574 5f68 6176 655f r();...set_have_ │ │ │ +0002f2a0: 616c 6c28 6661 6c73 6529 3b0a 0909 7570 all(false);...up │ │ │ +0002f2b0: 6461 7465 5f67 6175 6765 2829 3b0a 0909 date_gauge();... │ │ │ +0002f2c0: 7061 7573 6528 293b 0a09 7d0a 0a09 766f pause();..}...vo │ │ │ +0002f2d0: 6964 2074 6f72 7265 6e74 3a3a 6f6e 5f70 id torrent::on_p │ │ │ +0002f2e0: 6965 6365 5f66 6169 6c5f 7379 6e63 2870 iece_fail_sync(p │ │ │ +0002f2f0: 6965 6365 5f69 6e64 6578 5f74 2063 6f6e iece_index_t con │ │ │ +0002f300: 7374 2070 6965 6365 2c20 7069 6563 655f st piece, piece_ │ │ │ +0002f310: 626c 6f63 6b29 2074 7279 0a09 7b0a 0909 block) try..{... │ │ │ +0002f320: 6966 2028 6d5f 6162 6f72 7429 2072 6574 if (m_abort) ret │ │ │ +0002f330: 7572 6e3b 0a0a 3c2f 7072 653e 3c2f 7464 urn;..
    relevance │ │ │ +0002f370: 266e 6273 703b 313c 2f74 643e 3c74 643e  1 │ │ │ +0002f380: 3c61 2068 7265 663d 226a 6176 6173 6372 │ │ │ +0002f3a0: 2e2e 2f73 7263 2f74 6f72 7265 6e74 2e63 ../src/torrent.c │ │ │ +0002f3b0: 7070 3a38 3536 323c 2f61 3e3c 2f74 643e pp:8562 │ │ │ +0002f3c0: 3c74 643e 7368 6f75 6c64 2064 6973 636f should disco │ │ │ +0002f3d0: 6e6e 6563 7420 616c 6c20 7065 6572 7320 nnect all peers │ │ │ +0002f3e0: 7468 6174 2068 6176 6520 7468 6520 7069 that have the pi │ │ │ +0002f3f0: 6563 6573 2077 6520 6861 7665 206e 6f74 eces we have not │ │ │ +0002f400: 206a 7573 7420 7365 6564 732e 2049 7420 just seeds. It │ │ │ +0002f410: 776f 756c 6420 6265 2070 7265 7474 7920 would be pretty │ │ │ +0002f420: 6578 7065 6e73 6976 6520 746f 2063 6865 expensive to che │ │ │ +0002f430: 636b 2061 6c6c 2070 6965 6365 7320 666f ck all pieces fo │ │ │ +0002f440: 7220 616c 6c20 7065 6572 7320 7468 6f75 r all peers thou │ │ │ +0002f450: 6768 3c2f 7464 3e3c 2f74 723e 3c74 7220 gh

    s │ │ │ +0002f4a0: 686f 756c 6420 6469 7363 6f6e 6e65 6374 hould disconnect │ │ │ +0002f4b0: 2061 6c6c 2070 6565 7273 2074 6861 7420 all peers that │ │ │ +0002f4c0: 6861 7665 2074 6865 2070 6965 6365 7320 have the pieces │ │ │ +0002f4d0: 7765 2068 6176 650a 6e6f 7420 6a75 7374 we have.not just │ │ │ +0002f4e0: 2073 6565 6473 2e20 4974 2077 6f75 6c64 seeds. It would │ │ │ +0002f4f0: 2062 6520 7072 6574 7479 2065 7870 656e be pretty expen │ │ │ +0002f500: 7369 7665 2074 6f20 6368 6563 6b20 616c sive to check al │ │ │ +0002f510: 6c20 7069 6563 6573 0a66 6f72 2061 6c6c l pieces.for all │ │ │ +0002f520: 2070 6565 7273 2074 686f 7567 683c 2f68 peers though

    ../src/tor │ │ │ +0002f540: 7265 6e74 2e63 7070 3a38 3536 323c 2f68 rent.cpp:8562
    ...s
    │ │ │ +0002f590: 6574 5f73 7461 7465 2874 6f72 7265 6e74  et_state(torrent
    │ │ │ +0002f5a0: 5f73 7461 7475 733a 3a66 696e 6973 6865  _status::finishe
    │ │ │ +0002f5b0: 6429 3b0a 0909 7365 745f 7175 6575 655f  d);...set_queue_
    │ │ │ +0002f5c0: 706f 7369 7469 6f6e 286e 6f5f 706f 7329  position(no_pos)
    │ │ │ +0002f5d0: 3b0a 0a09 0975 7064 6174 655f 7374 6174  ;....update_stat
    │ │ │ +0002f5e0: 655f 7469 6d65 7273 2829 3b0a 0a09 092f  e_timers();..../
    │ │ │ +0002f5f0: 2f20 7765 2068 6176 6520 746f 2063 616c  / we have to cal
    │ │ │ +0002f600: 6c20 636f 6d70 6c65 7465 6428 2920 6265  l completed() be
    │ │ │ +0002f610: 666f 7265 2077 6520 7374 6172 740a 0909  fore we start...
    │ │ │ +0002f620: 2f2f 2064 6973 636f 6e6e 6563 7469 6e67  // disconnecting
    │ │ │ +0002f630: 2070 6565 7273 2c20 7369 6e63 6520 7468   peers, since th
    │ │ │ +0002f640: 6572 6527 7320 616e 2061 7373 6572 740a  ere's an assert.
    │ │ │ +0002f650: 0909 2f2f 2074 6f20 6d61 6b65 2073 7572  ..// to make sur
    │ │ │ +0002f660: 6520 7765 2772 6520 636c 6561 7265 6420  e we're cleared 
    │ │ │ +0002f670: 7468 6520 7069 6563 6520 7069 636b 6572  the piece picker
    │ │ │ +0002f680: 0a09 0969 6620 2869 735f 7365 6564 2829  ...if (is_seed()
    │ │ │ +0002f690: 2920 636f 6d70 6c65 7465 6428 293b 0a0a  ) completed();..
    │ │ │ +0002f6a0: 0909 7365 6e64 5f75 706c 6f61 645f 6f6e  ..send_upload_on
    │ │ │ +0002f6b0: 6c79 2829 3b0a 0909 7374 6174 655f 7570  ly();...state_up
    │ │ │ +0002f6c0: 6461 7465 6428 293b 0a0a 0909 6966 2028  dated();....if (
    │ │ │ +0002f6d0: 6d5f 636f 6d70 6c65 7465 645f 7469 6d65  m_completed_time
    │ │ │ +0002f6e0: 203d 3d20 3029 0a09 0909 6d5f 636f 6d70   == 0)....m_comp
    │ │ │ +0002f6f0: 6c65 7465 645f 7469 6d65 203d 2074 696d  leted_time = tim
    │ │ │ +0002f700: 6528 6e75 6c6c 7074 7229 3b0a 0a09 092f  e(nullptr);..../
    │ │ │ +0002f710: 2f20 6469 7363 6f6e 6e65 6374 2061 6c6c  / disconnect all
    │ │ │ +0002f720: 2073 6565 6473 0a09 0969 6620 2873 6574   seeds...if (set
    │ │ │ +0002f730: 7469 6e67 7328 292e 6765 745f 626f 6f6c  tings().get_bool
    │ │ │ +0002f740: 2873 6574 7469 6e67 735f 7061 636b 3a3a  (settings_pack::
    │ │ │ +0002f750: 636c 6f73 655f 7265 6475 6e64 616e 745f  close_redundant_
    │ │ │ +0002f760: 636f 6e6e 6563 7469 6f6e 7329 290a 0909  connections))...
    │ │ │ +0002f770: 7b0a 3c64 6976 2073 7479 6c65 3d22 6261  {.
    │ │ │ +0002f7a0: 0909 0973 7464 3a3a 7665 6374 6f72 266c ...std::vector&l │ │ │ +0002f7b0: 743b 7065 6572 5f63 6f6e 6e65 6374 696f t;peer_connectio │ │ │ +0002f7c0: 6e2a 2667 743b 2073 6565 6473 3b0a 3c2f n*> seeds;....for (auto │ │ │ +0002f7e0: 2063 6f6e 7374 2070 203a 206d 5f63 6f6e const p : m_con │ │ │ +0002f7f0: 6e65 6374 696f 6e73 290a 0909 097b 0a09 nections)....{.. │ │ │ +0002f800: 0909 0954 4f52 5245 4e54 5f49 4e43 5245 ...TORRENT_INCRE │ │ │ +0002f810: 4d45 4e54 286d 5f69 7465 7261 7469 6e67 MENT(m_iterating │ │ │ +0002f820: 5f63 6f6e 6e65 6374 696f 6e73 293b 0a09 _connections);.. │ │ │ +0002f830: 0909 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0002f840: 5428 702d 2667 743b 6173 736f 6369 6174 T(p->associat │ │ │ +0002f850: 6564 5f74 6f72 7265 6e74 2829 2e6c 6f63 ed_torrent().loc │ │ │ +0002f860: 6b28 292e 6765 7428 2920 3d3d 2074 6869 k().get() == thi │ │ │ +0002f870: 7329 3b0a 0909 0909 6966 2028 702d 2667 s);.....if (p-&g │ │ │ +0002f880: 743b 7570 6c6f 6164 5f6f 6e6c 7928 2920 t;upload_only() │ │ │ +0002f890: 2661 6d70 3b26 616d 703b 2070 2d26 6774 && p-> │ │ │ +0002f8a0: 3b63 616e 5f64 6973 636f 6e6e 6563 7428 ;can_disconnect( │ │ │ +0002f8b0: 6572 726f 7273 3a3a 746f 7272 656e 745f errors::torrent_ │ │ │ +0002f8c0: 6669 6e69 7368 6564 2929 0a09 0909 097b finished)).....{ │ │ │ +0002f8d0: 0a23 6966 6e64 6566 2054 4f52 5245 4e54 .#ifndef TORRENT │ │ │ +0002f8e0: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47 _DISABLE_LOGGING │ │ │ +0002f8f0: 0a09 0909 0909 702d 2667 743b 7065 6572 ......p->peer │ │ │ +0002f900: 5f6c 6f67 2870 6565 725f 6c6f 675f 616c _log(peer_log_al │ │ │ +0002f910: 6572 743a 3a69 6e66 6f2c 2022 5345 4544 ert::info, "SEED │ │ │ +0002f920: 222c 2022 434c 4f53 494e 4720 434f 4e4e ", "CLOSING CONN │ │ │ +0002f930: 4543 5449 4f4e 2229 3b0a 2365 6e64 6966 ECTION");.#endif │ │ │ +0002f940: 0a09 0909 0909 7365 6564 732e 7075 7368 ......seeds.push │ │ │ +0002f950: 5f62 6163 6b28 7029 3b0a 0909 0909 7d0a _back(p);.....}. │ │ │ +0002f960: 0909 097d 0a09 0909 666f 7220 2861 7574 ...}....for (aut │ │ │ +0002f970: 6f26 616d 703b 2070 203a 2073 6565 6473 o& p : seeds │ │ │ +0002f980: 290a 0909 0909 702d 2667 743b 6469 7363 ).....p->disc │ │ │ +0002f990: 6f6e 6e65 6374 2865 7272 6f72 733a 3a74 onnect(errors::t │ │ │ +0002f9a0: 6f72 7265 6e74 5f66 696e 6973 6865 642c orrent_finished, │ │ │ +0002f9b0: 206f 7065 7261 7469 6f6e 5f74 3a3a 6269 operation_t::bi │ │ │ +0002f9c0: 7474 6f72 7265 6e74 0a09 0909 0909 2c20 ttorrent......, │ │ │ +0002f9d0: 7065 6572 5f63 6f6e 6e65 6374 696f 6e5f peer_connection_ │ │ │ +0002f9e0: 696e 7465 7266 6163 653a 3a6e 6f72 6d61 interface::norma │ │ │ +0002f9f0: 6c29 3b0a 0909 7d0a 0a09 0969 6620 286d l);...}....if (m │ │ │ +0002fa00: 5f61 626f 7274 2920 7265 7475 726e 3b0a _abort) return;. │ │ │ +0002fa10: 0a09 0975 7064 6174 655f 7761 6e74 5f70 ...update_want_p │ │ │ +0002fa20: 6565 7273 2829 3b0a 0a09 0969 6620 286d eers();....if (m │ │ │ +0002fa30: 5f73 746f 7261 6765 290a 0909 7b0a 0909 _storage)...{... │ │ │ +0002fa40: 092f 2f20 7765 206e 6565 6420 746f 206b .// we need to k │ │ │ +0002fa50: 6565 7020 7468 6520 6f62 6a65 6374 2061 eep the object a │ │ │ +0002fa60: 6c69 7665 2064 7572 696e 6720 7468 6973 live during this │ │ │ +0002fa70: 206f 7065 7261 7469 6f6e 0a09 0909 6d5f operation....m_ │ │ │ +0002fa80: 7365 732e 6469 736b 5f74 6872 6561 6428 ses.disk_thread( │ │ │ +0002fa90: 292e 6173 796e 635f 7265 6c65 6173 655f ).async_release_ │ │ │ +0002faa0: 6669 6c65 7328 6d5f 7374 6f72 6167 650a files(m_storage. │ │ │ +0002fab0: 0909 0909 2c20 7374 643a 3a62 696e 6428 ...., std::bind( │ │ │ +0002fac0: 2661 6d70 3b74 6f72 7265 6e74 3a3a 6f6e &torrent::on │ │ │ +0002fad0: 5f63 6163 6865 5f66 6c75 7368 6564 2c20 _cache_flushed, │ │ │ +0002fae0: 7368 6172 6564 5f66 726f 6d5f 7468 6973 shared_from_this │ │ │ +0002faf0: 2829 2c20 6661 6c73 6529 293b 0a09 0909 (), false));.... │ │ │ +0002fb00: 6d5f 7365 732e 6465 6665 7272 6564 5f73 m_ses.deferred_s │ │ │ +0002fb10: 7562 6d69 745f 6a6f 6273 2829 3b0a 0909 ubmit_jobs();... │ │ │ +0002fb20: 7d0a 0a09 092f 2f20 7468 6973 2074 6f72 }....// this tor │ │ │ +0002fb30: 7265 6e74 206a 7573 7420 636f 6d70 6c65 rent just comple │ │ │ +0002fb40: 7465 6420 646f 776e 6c6f 6164 732c 2077 ted downloads, w │ │ │ +0002fb50: 6869 6368 206d 6561 6e73 2069 7420 7769 hich means it wi │ │ │ +0002fb60: 6c6c 2066 616c 6c0a 3c2f 7072 653e 3c2f ll fall.
    relevan │ │ │ 0002fba0: 6365 266e 6273 703b 313c 2f74 643e 3c74 ce 1../include/lib │ │ │ @@ -12296,18496 +12296,18496 @@ │ │ │ 00030070: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .relevance  │ │ │ 000300b0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../te │ │ │ -000300e0: 7374 2f74 6573 745f 7570 6e70 2e63 7070 st/test_upnp.cpp │ │ │ -000300f0: 3a31 3536 3c2f 613e 3c2f 7464 3e3c 7464 :156store the log a │ │ │ -00030110: 6e64 2076 6572 6966 7920 7468 6174 2073 nd verify that s │ │ │ -00030120: 6f6d 6520 6b65 7920 6d65 7373 6167 6573 ome key messages │ │ │ -00030130: 2061 7265 2074 6865 7265 3c2f 7464 3e3c are there< │ │ │ -00030140: 2f74 723e 3c74 7220 6964 3d22 3935 2220 /tr>

    store the │ │ │ -00030190: 206c 6f67 2061 6e64 2076 6572 6966 7920 log and verify │ │ │ -000301a0: 7468 6174 2073 6f6d 6520 6b65 7920 6d65 that some key me │ │ │ -000301b0: 7373 6167 6573 2061 7265 2074 6865 7265 ssages are there │ │ │ -000301c0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 7374

    ../test │ │ │ -000301d0: 2f74 6573 745f 7570 6e70 2e63 7070 3a31 /test_upnp.cpp:1 │ │ │ -000301e0: 3536 3c2f 6834 3e3c 7072 6520 7374 796c 56

    ..., portmap_pr
    │ │ │ -00030230: 6f74 6f63 6f6c 2063 6f6e 7374 2070 726f  otocol const pro
    │ │ │ -00030240: 746f 636f 6c2c 2065 7272 6f72 5f63 6f64  tocol, error_cod
    │ │ │ -00030250: 6520 636f 6e73 7426 616d 703b 2065 7272  e const& err
    │ │ │ -00030260: 0a09 0909 2c20 706f 7274 6d61 705f 7472  ...., portmap_tr
    │ │ │ -00030270: 616e 7370 6f72 742c 2061 7578 3a3a 6c69  ansport, aux::li
    │ │ │ -00030280: 7374 656e 5f73 6f63 6b65 745f 6861 6e64  sten_socket_hand
    │ │ │ -00030290: 6c65 2063 6f6e 7374 2661 6d70 3b29 206f  le const&) o
    │ │ │ -000302a0: 7665 7272 6964 650a 0909 7b0a 0909 0963  verride...{....c
    │ │ │ -000302b0: 616c 6c62 6163 6b5f 696e 666f 2069 6e66  allback_info inf
    │ │ │ -000302c0: 6f20 3d20 7b6d 6170 7069 6e67 2c20 706f  o = {mapping, po
    │ │ │ -000302d0: 7274 2c20 6572 727d 3b0a 0909 0963 616c  rt, err};....cal
    │ │ │ -000302e0: 6c62 6163 6b73 2e70 7573 685f 6261 636b  lbacks.push_back
    │ │ │ -000302f0: 2869 6e66 6f29 3b0a 0909 0973 7464 3a3a  (info);....std::
    │ │ │ -00030300: 636f 7574 2026 6c74 3b26 6c74 3b20 226d  cout << "m
    │ │ │ -00030310: 6170 7069 6e67 3a20 2220 266c 743b 266c  apping: " <&l
    │ │ │ -00030320: 743b 2073 7461 7469 635f 6361 7374 266c  t; static_cast&l
    │ │ │ -00030330: 743b 696e 7426 6774 3b28 6d61 7070 696e  t;int>(mappin
    │ │ │ -00030340: 6729 0a09 0909 0926 6c74 3b26 6c74 3b20  g).....<< 
    │ │ │ -00030350: 222c 2070 6f72 743a 2022 2026 6c74 3b26  ", port: " <&
    │ │ │ -00030360: 6c74 3b20 706f 7274 2026 6c74 3b26 6c74  lt; port <<
    │ │ │ -00030370: 3b20 222c 2049 503a 2022 2026 6c74 3b26  ; ", IP: " <&
    │ │ │ -00030380: 6c74 3b20 6970 0a09 0909 0926 6c74 3b26  lt; ip.....<&
    │ │ │ -00030390: 6c74 3b20 222c 2070 726f 746f 3a20 2220  lt; ", proto: " 
    │ │ │ -000303a0: 266c 743b 266c 743b 2073 7461 7469 635f  << static_
    │ │ │ -000303b0: 6361 7374 266c 743b 696e 7426 6774 3b28  cast<int>(
    │ │ │ -000303c0: 7072 6f74 6f63 6f6c 290a 0909 0909 266c  protocol).....&l
    │ │ │ -000303d0: 743b 266c 743b 2022 2c20 6572 726f 723a  t;< ", error:
    │ │ │ -000303e0: 205c 2222 2026 6c74 3b26 6c74 3b20 6572   \"" << er
    │ │ │ -000303f0: 722e 6d65 7373 6167 6528 2920 266c 743b  r.message() <
    │ │ │ -00030400: 266c 743b 2022 5c22 5c6e 223b 0a09 097d  < "\"\n";...}
    │ │ │ -00030410: 0a09 2369 666e 6465 6620 544f 5252 454e  ..#ifndef TORREN
    │ │ │ -00030420: 545f 4449 5341 424c 455f 4c4f 4747 494e  T_DISABLE_LOGGIN
    │ │ │ -00030430: 470a 0909 626f 6f6c 2073 686f 756c 645f  G...bool should_
    │ │ │ -00030440: 6c6f 675f 706f 7274 6d61 7028 706f 7274  log_portmap(port
    │ │ │ -00030450: 6d61 705f 7472 616e 7370 6f72 7429 2063  map_transport) c
    │ │ │ -00030460: 6f6e 7374 206f 7665 7272 6964 650a 0909  onst override...
    │ │ │ -00030470: 7b0a 0909 0972 6574 7572 6e20 7472 7565  {....return true
    │ │ │ -00030480: 3b0a 0909 7d0a 0a09 0976 6f69 6420 6c6f  ;...}....void lo
    │ │ │ -00030490: 675f 706f 7274 6d61 7028 706f 7274 6d61  g_portmap(portma
    │ │ │ -000304a0: 705f 7472 616e 7370 6f72 742c 2063 6861  p_transport, cha
    │ │ │ -000304b0: 7220 636f 6e73 742a 206d 7367 0a09 0909  r const* msg....
    │ │ │ -000304c0: 2c20 6175 783a 3a6c 6973 7465 6e5f 736f  , aux::listen_so
    │ │ │ -000304d0: 636b 6574 5f68 616e 646c 6520 636f 6e73  cket_handle cons
    │ │ │ -000304e0: 7426 616d 703b 2920 636f 6e73 7420 6f76  t&) const ov
    │ │ │ -000304f0: 6572 7269 6465 0a09 097b 0a09 0909 7374  erride...{....st
    │ │ │ -00030500: 643a 3a63 6f75 7420 266c 743b 266c 743b  d::cout <<
    │ │ │ -00030510: 2022 5550 6e50 3a20 2220 266c 743b 266c   "UPnP: " <&l
    │ │ │ -00030520: 743b 206d 7367 2026 6c74 3b26 6c74 3b20  t; msg << 
    │ │ │ -00030530: 7374 643a 3a65 6e64 6c3b 0a3c 6469 7620  std::endl;.
    ..}..#endif..};.. │ │ │ -00030580: 6970 5f69 6e74 6572 6661 6365 2070 6963 ip_interface pic │ │ │ -00030590: 6b5f 7570 6e70 5f69 6e74 6572 6661 6365 k_upnp_interface │ │ │ -000305a0: 2829 0a7b 0a09 6c74 3a3a 696f 5f63 6f6e ().{..lt::io_con │ │ │ -000305b0: 7465 7874 2069 6f73 3b0a 0965 7272 6f72 text ios;..error │ │ │ -000305c0: 5f63 6f64 6520 6563 3b0a 0973 7464 3a3a _code ec;..std:: │ │ │ -000305d0: 7665 6374 6f72 266c 743b 6970 5f72 6f75 vector<ip_rou │ │ │ -000305e0: 7465 2667 743b 2063 6f6e 7374 2072 6f75 te> const rou │ │ │ -000305f0: 7465 7320 3d20 656e 756d 5f72 6f75 7465 tes = enum_route │ │ │ -00030600: 7328 696f 732c 2065 6329 3b0a 0969 6620 s(ios, ec);..if │ │ │ -00030610: 2865 6329 0a09 7b0a 0909 7374 643a 3a63 (ec)..{...std::c │ │ │ -00030620: 6572 7220 266c 743b 266c 743b 2022 6661 err << "fa │ │ │ -00030630: 696c 6564 2074 6f20 656e 756d 6572 6174 iled to enumerat │ │ │ -00030640: 6520 726f 7574 6573 3a20 2220 266c 743b e routes: " < │ │ │ -00030650: 266c 743b 2065 632e 6d65 7373 6167 6528 < ec.message( │ │ │ -00030660: 2920 266c 743b 266c 743b 2027 5c6e 273b ) << '\n'; │ │ │ -00030670: 0a09 0954 4553 545f 4348 4543 4b28 6661 ...TEST_CHECK(fa │ │ │ -00030680: 6c73 6529 3b0a 0909 7265 7475 726e 207b lse);...return { │ │ │ -00030690: 7d3b 0a09 7d0a 0973 7464 3a3a 7665 6374 };..}..std::vect │ │ │ -000306a0: 6f72 266c 743b 6970 5f69 6e74 6572 6661 or<ip_interfa │ │ │ -000306b0: 6365 2667 743b 2063 6f6e 7374 2069 6673 ce> const ifs │ │ │ -000306c0: 203d 2065 6e75 6d5f 6e65 745f 696e 7465 = enum_net_inte │ │ │ -000306d0: 7266 6163 6573 2869 6f73 2c20 6563 293b rfaces(ios, ec); │ │ │ -000306e0: 0a09 6966 2028 6563 290a 097b 0a09 0973 ..if (ec)..{...s │ │ │ -000306f0: 7464 3a3a 6365 7272 2026 6c74 3b26 6c74 td::cerr << │ │ │ -00030700: 3b20 2266 6169 6c65 6420 746f 2065 6e75 ; "failed to enu │ │ │ -00030710: 6d65 7261 7465 206e 6574 776f 726b 2069 merate network i │ │ │ -00030720: 6e74 6572 6661 6365 733a 2022 2026 6c74 nterfaces: " < │ │ │ -00030730: 3b26 6c74 3b20 6563 2e6d 6573 7361 6765 ;< ec.message │ │ │ -00030740: 2829 2026 6c74 3b26 6c74 3b20 275c 6e27 () << '\n' │ │ │ -00030750: 3b0a 0909 5445 5354 5f43 4845 434b 2866 ;...TEST_CHECK(f │ │ │ -00030760: 616c 7365 293b 0a09 0972 6574 7572 6e20 alse);...return │ │ │ -00030770: 7b7d 3b0a 097d 0a09 696e 7420 6964 7820 {};..}..int idx │ │ │ -00030780: 3d20 303b 0a09 666f 7220 2861 7574 6f20 = 0;..for (auto │ │ │ -00030790: 636f 6e73 7426 616d 703b 2066 6163 6520 const& face │ │ │ -000307a0: 3a20 6966 7329 0a09 7b0a 0909 6966 2028 : ifs)..{...if ( │ │ │ -000307b0: 2166 6163 652e 696e 7465 7266 6163 655f !face.interface_ │ │ │ -000307c0: 6164 6472 6573 732e 6973 5f76 3428 2929 address.is_v4()) │ │ │ -000307d0: 2063 6f6e 7469 6e75 653b 0a09 0973 7464 continue;...std │ │ │ -000307e0: 3a3a 636f 7574 2026 6c74 3b26 6c74 3b20 ::cout << │ │ │ -000307f0: 2220 2d20 2220 266c 743b 266c 743b 2069 " - " << i │ │ │ -00030800: 6478 0a09 0909 266c 743b 266c 743b 2027 dx....<< ' │ │ │ -00030810: 2027 2026 6c74 3b26 6c74 3b20 6661 6365 ' << face │ │ │ -00030820: 2e69 6e74 6572 6661 6365 5f61 6464 7265 .interface_addre │ │ │ -00030830: 7373 2e74 6f5f 7374 7269 6e67 2829 0a09 ss.to_string().. │ │ │ -00030840: 0909 266c 743b 266c 743b 2027 2027 2026 ..<< ' ' & │ │ │ -00030850: 6c74 3b26 6c74 3b20 696e 7428 7374 6174 lt;< int(stat │ │ │ -00030860: 6963 5f63 6173 7426 6c74 3b73 7464 3a3a ic_cast<std:: │ │ │ -00030870: 7569 6e74 385f 7426 6774 3b28 6661 6365 uint8_t>(face │ │ │ -00030880: 2e73 7461 7465 2929 0a09 0909 266c 743b .state))....< │ │ │ -00030890: 266c 743b 2027 2027 2026 6c74 3b26 6c74 < ' ' << │ │ │ -000308a0: 3b20 7374 6174 6963 5f63 6173 7426 6c74 ; static_cast< │ │ │ -000308b0: 3b73 7464 3a3a 7569 6e74 3332 5f74 2667 ;std::uint32_t&g │ │ │ -000308c0: 743b 2866 6163 652e 666c 6167 7329 0a09 t;(face.flags).. │ │ │ -000308d0: 0909 266c 743b 266c 743b 2027 2027 2026 ..<< ' ' & │ │ │ -000308e0: 6c74 3b26 6c74 3b20 6661 6365 2e6e 616d lt;< face.nam │ │ │ -000308f0: 6520 266c 743b 266c 743b 2027 5c6e 273b e << '\n'; │ │ │ -00030900: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -00030940: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../te │ │ │ -00030970: 7374 2f74 6573 745f 7472 616e 7366 6572 st/test_transfer │ │ │ -00030980: 2e63 7070 3a31 3733 3c2f 613e 3c2f 7464 .cpp:173these setti │ │ │ -000309a0: 6e67 735f 7061 636b 2074 6573 7473 2062 ngs_pack tests b │ │ │ -000309b0: 656c 6f6e 6720 696e 2074 6865 6972 206f elong in their o │ │ │ -000309c0: 776e 2074 6573 743c 2f74 643e 3c2f 7472 wn test │ │ │ -00030a00: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00030a10: 3c68 323e 7468 6573 6520 7365 7474 696e

    these settin │ │ │ -00030a20: 6773 5f70 6163 6b20 7465 7374 7320 6265 gs_pack tests be │ │ │ -00030a30: 6c6f 6e67 2069 6e20 7468 6569 7220 6f77 long in their ow │ │ │ -00030a40: 6e20 7465 7374 3c2f 6832 3e3c 6834 3e2e n test

    . │ │ │ -00030a50: 2e2f 7465 7374 2f74 6573 745f 7472 616e ./test/test_tran │ │ │ -00030a60: 7366 6572 2e63 7070 3a31 3733 3c2f 6834 sfer.cpp:173

    .// t
    │ │ │ -00030ab0: 6f20 7468 6520 7469 6d65 2069 7420 7769  o the time it wi
    │ │ │ -00030ac0: 6c6c 2074 616b 6520 746f 2063 6f6d 706c  ll take to compl
    │ │ │ -00030ad0: 6574 6520 7468 6520 7465 7374 0a09 7061  ete the test..pa
    │ │ │ -00030ae0: 636b 2e73 6574 5f69 6e74 2873 6574 7469  ck.set_int(setti
    │ │ │ -00030af0: 6e67 735f 7061 636b 3a3a 6d69 6e5f 7265  ngs_pack::min_re
    │ │ │ -00030b00: 636f 6e6e 6563 745f 7469 6d65 2c20 3029  connect_time, 0)
    │ │ │ -00030b10: 3b0a 0970 6163 6b2e 7365 745f 696e 7428  ;..pack.set_int(
    │ │ │ -00030b20: 7365 7474 696e 6773 5f70 6163 6b3a 3a73  settings_pack::s
    │ │ │ -00030b30: 746f 705f 7472 6163 6b65 725f 7469 6d65  top_tracker_time
    │ │ │ -00030b40: 6f75 742c 2031 293b 0a09 7061 636b 2e73  out, 1);..pack.s
    │ │ │ -00030b50: 6574 5f62 6f6f 6c28 7365 7474 696e 6773  et_bool(settings
    │ │ │ -00030b60: 5f70 6163 6b3a 3a61 6e6e 6f75 6e63 655f  _pack::announce_
    │ │ │ -00030b70: 746f 5f61 6c6c 5f74 7261 636b 6572 732c  to_all_trackers,
    │ │ │ -00030b80: 2074 7275 6529 3b0a 0970 6163 6b2e 7365   true);..pack.se
    │ │ │ -00030b90: 745f 626f 6f6c 2873 6574 7469 6e67 735f  t_bool(settings_
    │ │ │ -00030ba0: 7061 636b 3a3a 616e 6e6f 756e 6365 5f74  pack::announce_t
    │ │ │ -00030bb0: 6f5f 616c 6c5f 7469 6572 732c 2074 7275  o_all_tiers, tru
    │ │ │ -00030bc0: 6529 3b0a 0a09 2f2f 206d 616b 6520 7375  e);...// make su
    │ │ │ -00030bd0: 7265 2077 6520 616e 6e6f 756e 6365 2074  re we announce t
    │ │ │ -00030be0: 6f20 626f 7468 2068 7474 7020 616e 6420  o both http and 
    │ │ │ -00030bf0: 7564 7020 7472 6163 6b65 7273 0a09 7061  udp trackers..pa
    │ │ │ -00030c00: 636b 2e73 6574 5f62 6f6f 6c28 7365 7474  ck.set_bool(sett
    │ │ │ -00030c10: 696e 6773 5f70 6163 6b3a 3a70 7265 6665  ings_pack::prefe
    │ │ │ -00030c20: 725f 7564 705f 7472 6163 6b65 7273 2c20  r_udp_trackers, 
    │ │ │ -00030c30: 6661 6c73 6529 3b0a 0970 6163 6b2e 7365  false);..pack.se
    │ │ │ -00030c40: 745f 626f 6f6c 2873 6574 7469 6e67 735f  t_bool(settings_
    │ │ │ -00030c50: 7061 636b 3a3a 656e 6162 6c65 5f6f 7574  pack::enable_out
    │ │ │ -00030c60: 676f 696e 675f 7574 702c 2066 616c 7365  going_utp, false
    │ │ │ -00030c70: 293b 0a09 7061 636b 2e73 6574 5f62 6f6f  );..pack.set_boo
    │ │ │ -00030c80: 6c28 7365 7474 696e 6773 5f70 6163 6b3a  l(settings_pack:
    │ │ │ -00030c90: 3a65 6e61 626c 655f 696e 636f 6d69 6e67  :enable_incoming
    │ │ │ -00030ca0: 5f75 7470 2c20 6661 6c73 6529 3b0a 0970  _utp, false);..p
    │ │ │ -00030cb0: 6163 6b2e 7365 745f 626f 6f6c 2873 6574  ack.set_bool(set
    │ │ │ -00030cc0: 7469 6e67 735f 7061 636b 3a3a 656e 6162  tings_pack::enab
    │ │ │ -00030cd0: 6c65 5f6c 7364 2c20 6661 6c73 6529 3b0a  le_lsd, false);.
    │ │ │ -00030ce0: 0970 6163 6b2e 7365 745f 626f 6f6c 2873  .pack.set_bool(s
    │ │ │ -00030cf0: 6574 7469 6e67 735f 7061 636b 3a3a 656e  ettings_pack::en
    │ │ │ -00030d00: 6162 6c65 5f6e 6174 706d 702c 2066 616c  able_natpmp, fal
    │ │ │ -00030d10: 7365 293b 0a09 7061 636b 2e73 6574 5f62  se);..pack.set_b
    │ │ │ -00030d20: 6f6f 6c28 7365 7474 696e 6773 5f70 6163  ool(settings_pac
    │ │ │ -00030d30: 6b3a 3a65 6e61 626c 655f 7570 6e70 2c20  k::enable_upnp, 
    │ │ │ -00030d40: 6661 6c73 6529 3b0a 0970 6163 6b2e 7365  false);..pack.se
    │ │ │ -00030d50: 745f 626f 6f6c 2873 6574 7469 6e67 735f  t_bool(settings_
    │ │ │ -00030d60: 7061 636b 3a3a 656e 6162 6c65 5f64 6874  pack::enable_dht
    │ │ │ -00030d70: 2c20 6661 6c73 6529 3b0a 0a09 7061 636b  , false);...pack
    │ │ │ -00030d80: 2e73 6574 5f69 6e74 2873 6574 7469 6e67  .set_int(setting
    │ │ │ -00030d90: 735f 7061 636b 3a3a 6f75 745f 656e 635f  s_pack::out_enc_
    │ │ │ -00030da0: 706f 6c69 6379 2c20 7365 7474 696e 6773  policy, settings
    │ │ │ -00030db0: 5f70 6163 6b3a 3a70 655f 6469 7361 626c  _pack::pe_disabl
    │ │ │ -00030dc0: 6564 293b 0a09 7061 636b 2e73 6574 5f69  ed);..pack.set_i
    │ │ │ -00030dd0: 6e74 2873 6574 7469 6e67 735f 7061 636b  nt(settings_pack
    │ │ │ -00030de0: 3a3a 696e 5f65 6e63 5f70 6f6c 6963 792c  ::in_enc_policy,
    │ │ │ -00030df0: 2073 6574 7469 6e67 735f 7061 636b 3a3a   settings_pack::
    │ │ │ -00030e00: 7065 5f64 6973 6162 6c65 6429 3b0a 0a09  pe_disabled);...
    │ │ │ -00030e10: 7061 636b 2e73 6574 5f62 6f6f 6c28 7365  pack.set_bool(se
    │ │ │ -00030e20: 7474 696e 6773 5f70 6163 6b3a 3a61 6c6c  ttings_pack::all
    │ │ │ -00030e30: 6f77 5f6d 756c 7469 706c 655f 636f 6e6e  ow_multiple_conn
    │ │ │ -00030e40: 6563 7469 6f6e 735f 7065 725f 6970 2c20  ections_per_ip, 
    │ │ │ -00030e50: 6661 6c73 6529 3b0a 0a3c 6469 7620 7374  false);..
    .pack.set │ │ │ -00030e90: 5f69 6e74 2873 6574 7469 6e67 735f 7061 _int(settings_pa │ │ │ -00030ea0: 636b 3a3a 756e 6368 6f6b 655f 736c 6f74 ck::unchoke_slot │ │ │ -00030eb0: 735f 6c69 6d69 742c 2030 293b 0a3c 2f64 s_limit, 0);..ses1.apply_s │ │ │ -00030ed0: 6574 7469 6e67 7328 7061 636b 293b 0a09 ettings(pack);.. │ │ │ -00030ee0: 5445 5354 5f43 4845 434b 2873 6573 312e TEST_CHECK(ses1. │ │ │ -00030ef0: 6765 745f 7365 7474 696e 6773 2829 2e67 get_settings().g │ │ │ -00030f00: 6574 5f69 6e74 2873 6574 7469 6e67 735f et_int(settings_ │ │ │ -00030f10: 7061 636b 3a3a 756e 6368 6f6b 655f 736c pack::unchoke_sl │ │ │ -00030f20: 6f74 735f 6c69 6d69 7429 203d 3d20 3029 ots_limit) == 0) │ │ │ -00030f30: 3b0a 0a09 7061 636b 2e73 6574 5f69 6e74 ;...pack.set_int │ │ │ -00030f40: 2873 6574 7469 6e67 735f 7061 636b 3a3a (settings_pack:: │ │ │ -00030f50: 756e 6368 6f6b 655f 736c 6f74 735f 6c69 unchoke_slots_li │ │ │ -00030f60: 6d69 742c 202d 3129 3b0a 0973 6573 312e mit, -1);..ses1. │ │ │ -00030f70: 6170 706c 795f 7365 7474 696e 6773 2870 apply_settings(p │ │ │ -00030f80: 6163 6b29 3b0a 0954 4553 545f 4348 4543 ack);..TEST_CHEC │ │ │ -00030f90: 4b28 7365 7331 2e67 6574 5f73 6574 7469 K(ses1.get_setti │ │ │ -00030fa0: 6e67 7328 292e 6765 745f 696e 7428 7365 ngs().get_int(se │ │ │ -00030fb0: 7474 696e 6773 5f70 6163 6b3a 3a75 6e63 ttings_pack::unc │ │ │ -00030fc0: 686f 6b65 5f73 6c6f 7473 5f6c 696d 6974 hoke_slots_limit │ │ │ -00030fd0: 2920 3d3d 202d 3129 3b0a 0a09 7061 636b ) == -1);...pack │ │ │ -00030fe0: 2e73 6574 5f69 6e74 2873 6574 7469 6e67 .set_int(setting │ │ │ -00030ff0: 735f 7061 636b 3a3a 756e 6368 6f6b 655f s_pack::unchoke_ │ │ │ -00031000: 736c 6f74 735f 6c69 6d69 742c 2038 293b slots_limit, 8); │ │ │ -00031010: 0a09 7365 7331 2e61 7070 6c79 5f73 6574 ..ses1.apply_set │ │ │ -00031020: 7469 6e67 7328 7061 636b 293b 0a09 5445 tings(pack);..TE │ │ │ -00031030: 5354 5f43 4845 434b 2873 6573 312e 6765 ST_CHECK(ses1.ge │ │ │ -00031040: 745f 7365 7474 696e 6773 2829 2e67 6574 t_settings().get │ │ │ -00031050: 5f69 6e74 2873 6574 7469 6e67 735f 7061 _int(settings_pa │ │ │ -00031060: 636b 3a3a 756e 6368 6f6b 655f 736c 6f74 ck::unchoke_slot │ │ │ -00031070: 735f 6c69 6d69 7429 203d 3d20 3829 3b0a s_limit) == 8);. │ │ │ -00031080: 0a09 7365 7332 2e61 7070 6c79 5f73 6574 ..ses2.apply_set │ │ │ -00031090: 7469 6e67 7328 7061 636b 293b 0a0a 0974 tings(pack);...t │ │ │ -000310a0: 6f72 7265 6e74 5f68 616e 646c 6520 746f orrent_handle to │ │ │ -000310b0: 7231 3b0a 0974 6f72 7265 6e74 5f68 616e r1;..torrent_han │ │ │ -000310c0: 646c 6520 746f 7232 3b0a 0a09 6372 6561 dle tor2;...crea │ │ │ -000310d0: 7465 5f64 6972 6563 746f 7279 2822 746d te_directory("tm │ │ │ -000310e0: 7031 5f74 7261 6e73 6665 7222 2c20 6563 p1_transfer", ec │ │ │ -000310f0: 293b 0a09 7374 643a 3a6f 6673 7472 6561 );..std::ofstrea │ │ │ -00031100: 6d20 6669 6c65 2822 746d 7031 5f74 7261 m file("tmp1_tra │ │ │ -00031110: 6e73 6665 722f 7465 6d70 6f72 6172 7922 nsfer/temporary" │ │ │ -00031120: 293b 0a09 7374 643a 3a73 6861 7265 645f );..std::shared_ │ │ │ -00031130: 7074 7226 6c74 3b74 6f72 7265 6e74 5f69 ptr<torrent_i │ │ │ -00031140: 6e66 6f26 6774 3b20 7420 3d20 3a3a 6372 nfo> t = ::cr │ │ │ -00031150: 6561 7465 5f74 6f72 7265 6e74 2826 616d eate_torrent(&am │ │ │ -00031160: 703b 6669 6c65 2c20 2274 656d 706f 7261 p;file, "tempora │ │ │ -00031170: 7279 222c 2033 3220 2a20 3130 3234 2c20 ry", 32 * 1024, │ │ │ -00031180: 3133 2c20 6661 6c73 6529 3b0a 0966 696c 13, false);..fil │ │ │ -00031190: 652e 636c 6f73 6528 293b 0a0a 0954 4553 e.close();...TES │ │ │ -000311a0: 545f 4348 4543 4b28 6578 6973 7473 2863 T_CHECK(exists(c │ │ │ -000311b0: 6f6d 6269 6e65 5f70 6174 6828 2274 6d70 ombine_path("tmp │ │ │ -000311c0: 315f 7472 616e 7366 6572 222c 2022 7465 1_transfer", "te │ │ │ -000311d0: 6d70 6f72 6172 7922 2929 293b 0a0a 0961 mporary")));...a │ │ │ -000311e0: 6464 5f74 6f72 7265 6e74 5f70 6172 616d dd_torrent_param │ │ │ -000311f0: 7320 7061 7261 6d73 3b0a 0970 6172 616d s params;..param │ │ │ -00031200: 732e 7374 6f72 6167 655f 6d6f 6465 203d s.storage_mode = │ │ │ -00031210: 2073 746f 7261 6765 5f6d 6f64 653b 0a09 storage_mode;.. │ │ │ -00031220: 7061 7261 6d73 2e66 6c61 6773 2026 616d params.flags &am │ │ │ -00031230: 703b 3d20 7e74 6f72 7265 6e74 5f66 6c61 p;= ~torrent_fla │ │ │ -00031240: 6773 3a3a 7061 7573 6564 3b0a 0970 6172 gs::paused;..par │ │ │ -00031250: 616d 732e 666c 6167 7320 2661 6d70 3b3d ams.flags &= │ │ │ -00031260: 207e 746f 7272 656e 745f 666c 6167 733a ~torrent_flags: │ │ │ -00031270: 3a61 7574 6f5f 6d61 6e61 6765 643b 0a0a :auto_managed;.. │ │ │ -00031280: 0977 6169 745f 666f 725f 6c69 7374 656e .wait_for_listen │ │ │ -00031290: 2873 6573 312c 2022 7365 7331 2229 3b0a (ses1, "ses1");. │ │ │ -000312a0: 0977 6169 745f 666f 725f 6c69 7374 656e .wait_for_listen │ │ │ -000312b0: 2873 6573 322c 2022 7365 7332 2229 3b0a (ses2, "ses2");. │ │ │ -000312c0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -000312d0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00031300: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../tes │ │ │ -00031330: 742f 7465 7374 5f74 7261 636b 6572 2e63 t/test_tracker.c │ │ │ -00031340: 7070 3a36 303c 2f61 3e3c 2f74 643e 3c74 pp:60test scrape re │ │ │ -00031360: 7175 6573 7473 3c2f 7464 3e3c 2f74 723e quests │ │ │ -00031370: 3c74 7220 6964 3d22 3937 2220 7374 796c < │ │ │ -000313a0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -000313b0: 6832 3e74 6573 7420 7363 7261 7065 2072 h2>test scrape r │ │ │ -000313c0: 6571 7565 7374 733c 2f68 323e 3c68 343e equests

    │ │ │ -000313d0: 2e2e 2f74 6573 742f 7465 7374 5f74 7261 ../test/test_tra │ │ │ -000313e0: 636b 6572 2e63 7070 3a36 303c 2f68 343e cker.cpp:60

    │ │ │ -000313f0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    
    │ │ │ -00031430: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374  relev
    │ │ │ -00031460: 616e 6365 266e 6273 703b 303c 2f74 643e  ance 0
    │ │ │ -00031470: 3c74 643e 3c61 2068 7265 663d 226a 6176  ../test/test
    │ │ │ -000314a0: 5f74 7261 636b 6572 2e63 7070 3a36 313c  _tracker.cpp:61<
    │ │ │ -000314b0: 2f61 3e3c 2f74 643e 3c74 643e 7465 7374  /a>test
    │ │ │ -000314c0: 2070 6172 7365 2070 6565 7273 363c 2f74   parse peers6

    test p │ │ │ -00031520: 6172 7365 2070 6565 7273 363c 2f68 323e arse peers6

    │ │ │ -00031530: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ -00031540: 5f74 7261 636b 6572 2e63 7070 3a36 313c _tracker.cpp:61< │ │ │ -00031550: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    r
    │ │ │ -000315c0: 656c 6576 616e 6365 266e 6273 703b 303c  elevance 0<
    │ │ │ -000315d0: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../test/
    │ │ │ -00031600: 7465 7374 5f74 7261 636b 6572 2e63 7070  test_tracker.cpp
    │ │ │ -00031610: 3a36 323c 2f61 3e3c 2f74 643e 3c74 643e  :62
    │ │ │ -00031620: 7465 7374 2070 6172 7365 2074 7261 636b  test parse track
    │ │ │ -00031630: 6572 2d69 643c 2f74 643e 3c2f 7472 3e3c  er-id<
    │ │ │ -00031640: 7472 2069 643d 2239 3922 2073 7479 6c65  tr id="99" style
    │ │ │ -00031650: 3d22 6469 7370 6c61 793a 206e 6f6e 653b  ="display: none;
    │ │ │ -00031660: 2220 636f 6c73 7061 6e3d 2233 223e 3c74  " colspan="3">test parse tra
    │ │ │ -00031690: 636b 6572 2d69 643c 2f68 323e 3c68 343e  cker-id

    │ │ │ -000316a0: 2e2e 2f74 6573 742f 7465 7374 5f74 7261 ../test/test_tra │ │ │ -000316b0: 636b 6572 2e63 7070 3a36 323c 2f68 343e cker.cpp:62

    │ │ │ -000316c0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    
    │ │ │ -00031700: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374  relev
    │ │ │ -00031730: 616e 6365 266e 6273 703b 303c 2f74 643e  ance 0
    │ │ │ -00031740: 3c74 643e 3c61 2068 7265 663d 226a 6176  ../test/tes
    │ │ │ -00031770: 745f 7472 6163 6b65 722e 6370 703a 3633  t_tracker.cpp:63
    │ │ │ -00031780: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6573  tes
    │ │ │ -00031790: 7420 7061 7273 6520 6661 696c 7572 652d  t parse failure-
    │ │ │ -000317a0: 7265 6173 6f6e 3c2f 7464 3e3c 2f74 723e  reason
    │ │ │ -000317b0: 3c74 7220 6964 3d22 3130 3022 2073 7479  
    │ │ │ -000317e0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e  
    │ │ │ -000317f0: 3c68 323e 7465 7374 2070 6172 7365 2066  

    test parse f │ │ │ -00031800: 6169 6c75 7265 2d72 6561 736f 6e3c 2f68 ailure-reason

    ../test/te │ │ │ -00031820: 7374 5f74 7261 636b 6572 2e63 7070 3a36 st_tracker.cpp:6 │ │ │ -00031830: 333c 2f68 343e 3c70 7265 2073 7479 6c65 3

    │ │ │ -00031870: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e  
    │ │ │ -00031880: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -000318b0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../te │ │ │ -000318e0: 7374 2f74 6573 745f 7472 6163 6b65 722e st/test_tracker. │ │ │ -000318f0: 6370 703a 3634 3c2f 613e 3c2f 7464 3e3c cpp:64< │ │ │ -00031900: 7464 3e74 6573 7420 616c 6c20 6661 696c td>test all fail │ │ │ -00031910: 7572 6520 7061 7468 732c 2069 6e63 6c75 ure paths, inclu │ │ │ -00031920: 6469 6e67 2069 6e76 616c 6964 2062 656e ding invalid ben │ │ │ -00031930: 636f 6469 6e67 206e 6f74 2061 2064 6963 coding not a dic │ │ │ -00031940: 7469 6f6e 6172 7920 6e6f 2066 696c 6573 tionary no files │ │ │ -00031950: 2065 6e74 7279 2069 6e20 7363 7261 7065 entry in scrape │ │ │ -00031960: 2072 6573 706f 6e73 6520 6e6f 2069 6e66 response no inf │ │ │ -00031970: 6f2d 6861 7368 2065 6e74 7279 2069 6e20 o-hash entry in │ │ │ -00031980: 7363 7261 7065 2072 6573 706f 6e73 6520 scrape response │ │ │ -00031990: 6d61 6c66 6f72 6d65 6420 7065 6572 7320 malformed peers │ │ │ -000319a0: 696e 2070 6565 7220 6c69 7374 206f 6620 in peer list of │ │ │ -000319b0: 6469 6374 696f 6e61 7269 6573 2075 6e65 dictionaries une │ │ │ -000319c0: 7665 6e20 6e75 6d62 6572 206f 6620 6279 ven number of by │ │ │ -000319d0: 7465 7320 696e 2070 6565 7273 2061 6e64 tes in peers and │ │ │ -000319e0: 2070 6565 7273 3620 7374 7269 6e67 2072 peers6 string r │ │ │ -000319f0: 6573 706f 6e73 6573 3c2f 7464 3e3c 2f74 esponses

    test all f │ │ │ -00031a50: 6169 6c75 7265 2070 6174 6873 2c20 696e ailure paths, in │ │ │ -00031a60: 636c 7564 696e 670a 696e 7661 6c69 6420 cluding.invalid │ │ │ -00031a70: 6265 6e63 6f64 696e 670a 6e6f 7420 6120 bencoding.not a │ │ │ -00031a80: 6469 6374 696f 6e61 7279 0a6e 6f20 6669 dictionary.no fi │ │ │ -00031a90: 6c65 7320 656e 7472 7920 696e 2073 6372 les entry in scr │ │ │ -00031aa0: 6170 6520 7265 7370 6f6e 7365 0a6e 6f20 ape response.no │ │ │ -00031ab0: 696e 666f 2d68 6173 6820 656e 7472 7920 info-hash entry │ │ │ -00031ac0: 696e 2073 6372 6170 6520 7265 7370 6f6e in scrape respon │ │ │ -00031ad0: 7365 0a6d 616c 666f 726d 6564 2070 6565 se.malformed pee │ │ │ -00031ae0: 7273 2069 6e20 7065 6572 206c 6973 7420 rs in peer list │ │ │ -00031af0: 6f66 2064 6963 7469 6f6e 6172 6965 730a of dictionaries. │ │ │ -00031b00: 756e 6576 656e 206e 756d 6265 7220 6f66 uneven number of │ │ │ -00031b10: 2062 7974 6573 2069 6e20 7065 6572 7320 bytes in peers │ │ │ -00031b20: 616e 6420 7065 6572 7336 2073 7472 696e and peers6 strin │ │ │ -00031b30: 6720 7265 7370 6f6e 7365 733c 2f68 323e g responses

    │ │ │ -00031b40: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ -00031b50: 5f74 7261 636b 6572 2e63 7070 3a36 343c _tracker.cpp:64< │ │ │ -00031b60: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    #i
    │ │ │ -00031ba0: 6e63 6c75 6465 2022 7465 7374 5f75 7469  nclude "test_uti
    │ │ │ -00031bb0: 6c73 2e68 7070 220a 2369 6e63 6c75 6465  ls.hpp".#include
    │ │ │ -00031bc0: 2022 7564 705f 7472 6163 6b65 722e 6870   "udp_tracker.hp
    │ │ │ -00031bd0: 7022 0a23 696e 636c 7564 6520 2273 6574  p".#include "set
    │ │ │ -00031be0: 7469 6e67 732e 6870 7022 0a23 696e 636c  tings.hpp".#incl
    │ │ │ -00031bf0: 7564 6520 2274 6573 745f 7574 696c 732e  ude "test_utils.
    │ │ │ -00031c00: 6870 7022 0a23 696e 636c 7564 6520 226c  hpp".#include "l
    │ │ │ -00031c10: 6962 746f 7272 656e 742f 616c 6572 742e  ibtorrent/alert.
    │ │ │ -00031c20: 6870 7022 0a23 696e 636c 7564 6520 226c  hpp".#include "l
    │ │ │ -00031c30: 6962 746f 7272 656e 742f 7065 6572 5f69  ibtorrent/peer_i
    │ │ │ -00031c40: 6e66 6f2e 6870 7022 202f 2f20 666f 7220  nfo.hpp" // for 
    │ │ │ -00031c50: 7065 6572 5f6c 6973 745f 656e 7472 790a  peer_list_entry.
    │ │ │ -00031c60: 2369 6e63 6c75 6465 2022 6c69 6274 6f72  #include "libtor
    │ │ │ -00031c70: 7265 6e74 2f61 6c65 7274 5f74 7970 6573  rent/alert_types
    │ │ │ -00031c80: 2e68 7070 220a 2369 6e63 6c75 6465 2022  .hpp".#include "
    │ │ │ -00031c90: 6c69 6274 6f72 7265 6e74 2f73 6573 7369  libtorrent/sessi
    │ │ │ -00031ca0: 6f6e 2e68 7070 220a 2369 6e63 6c75 6465  on.hpp".#include
    │ │ │ -00031cb0: 2022 6c69 6274 6f72 7265 6e74 2f73 6573   "libtorrent/ses
    │ │ │ -00031cc0: 7369 6f6e 5f70 6172 616d 732e 6870 7022  sion_params.hpp"
    │ │ │ -00031cd0: 0a23 696e 636c 7564 6520 226c 6962 746f  .#include "libto
    │ │ │ -00031ce0: 7272 656e 742f 6572 726f 725f 636f 6465  rrent/error_code
    │ │ │ -00031cf0: 2e68 7070 220a 2369 6e63 6c75 6465 2022  .hpp".#include "
    │ │ │ -00031d00: 6c69 6274 6f72 7265 6e74 2f74 7261 636b  libtorrent/track
    │ │ │ -00031d10: 6572 5f6d 616e 6167 6572 2e68 7070 220a  er_manager.hpp".
    │ │ │ -00031d20: 2369 6e63 6c75 6465 2022 6c69 6274 6f72  #include "libtor
    │ │ │ -00031d30: 7265 6e74 2f68 7474 705f 7472 6163 6b65  rent/http_tracke
    │ │ │ -00031d40: 725f 636f 6e6e 6563 7469 6f6e 2e68 7070  r_connection.hpp
    │ │ │ -00031d50: 2220 2f2f 2066 6f72 2070 6172 7365 5f74  " // for parse_t
    │ │ │ -00031d60: 7261 636b 6572 5f72 6573 706f 6e73 650a  racker_response.
    │ │ │ -00031d70: 2369 6e63 6c75 6465 2022 6c69 6274 6f72  #include "libtor
    │ │ │ -00031d80: 7265 6e74 2f74 6f72 7265 6e74 5f69 6e66  rent/torrent_inf
    │ │ │ -00031d90: 6f2e 6870 7022 0a23 696e 636c 7564 6520  o.hpp".#include 
    │ │ │ -00031da0: 226c 6962 746f 7272 656e 742f 616e 6e6f  "libtorrent/anno
    │ │ │ -00031db0: 756e 6365 5f65 6e74 7279 2e68 7070 220a  unce_entry.hpp".
    │ │ │ -00031dc0: 2369 6e63 6c75 6465 2022 6c69 6274 6f72  #include "libtor
    │ │ │ -00031dd0: 7265 6e74 2f74 6f72 7265 6e74 2e68 7070  rent/torrent.hpp
    │ │ │ -00031de0: 220a 2369 6e63 6c75 6465 2022 6c69 6274  ".#include "libt
    │ │ │ -00031df0: 6f72 7265 6e74 2f61 7578 5f2f 7061 7468  orrent/aux_/path
    │ │ │ -00031e00: 2e68 7070 220a 2369 6e63 6c75 6465 2022  .hpp".#include "
    │ │ │ -00031e10: 6c69 6274 6f72 7265 6e74 2f73 6f63 6b65  libtorrent/socke
    │ │ │ -00031e20: 745f 696f 2e68 7070 220a 0a75 7369 6e67  t_io.hpp"..using
    │ │ │ -00031e30: 206e 616d 6573 7061 6365 206c 743b 0a0a   namespace lt;..
    │ │ │ -00031e40: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .< │ │ │ -00031e70: 2f64 6976 3e54 4f52 5245 4e54 5f54 4553 /div>TORRENT_TES │ │ │ -00031e80: 5428 7061 7273 655f 686f 7374 6e61 6d65 T(parse_hostname │ │ │ -00031e90: 5f70 6565 7273 290a 7b0a 0963 6861 7220 _peers).{..char │ │ │ -00031ea0: 636f 6e73 7420 7265 7370 6f6e 7365 5b5d const response[] │ │ │ -00031eb0: 203d 2022 6435 3a70 6565 7273 6c64 373a = "d5:peersld7: │ │ │ -00031ec0: 7065 6572 2069 6432 303a 6161 6161 6161 peer id20:aaaaaa │ │ │ -00031ed0: 6161 6161 6161 6161 6161 6161 6161 220a aaaaaaaaaaaaaa". │ │ │ -00031ee0: 0909 2232 3a69 7031 333a 7465 7374 5f68 .."2:ip13:test_h │ │ │ -00031ef0: 6f73 746e 616d 6534 3a70 6f72 7469 3130 ostname4:porti10 │ │ │ -00031f00: 3030 6565 6422 0a09 0922 373a 7065 6572 00eed"..."7:peer │ │ │ -00031f10: 2069 6432 303a 6262 6262 6162 6161 6261 id20:bbbbabaaba │ │ │ -00031f20: 6261 6261 6261 6261 6261 323a 6970 3132 bababababa2:ip12 │ │ │ -00031f30: 3a61 6e6f 7468 6572 5f68 6f73 7434 3a70 :another_host4:p │ │ │ -00031f40: 6f72 7469 3130 3031 6565 6565 223b 0a09 orti1001eeee";.. │ │ │ -00031f50: 6572 726f 725f 636f 6465 2065 633b 0a09 error_code ec;.. │ │ │ -00031f60: 7472 6163 6b65 725f 7265 7370 6f6e 7365 tracker_response │ │ │ -00031f70: 2072 6573 7020 3d20 7061 7273 655f 7472 resp = parse_tr │ │ │ -00031f80: 6163 6b65 725f 7265 7370 6f6e 7365 2872 acker_response(r │ │ │ -00031f90: 6573 706f 6e73 650a 0909 2c20 6563 2c20 esponse..., ec, │ │ │ -00031fa0: 7b7d 2c20 7368 6131 5f68 6173 6828 2929 {}, sha1_hash()) │ │ │ -00031fb0: 3b0a 0a09 5445 5354 5f45 5155 414c 2865 ;...TEST_EQUAL(e │ │ │ -00031fc0: 632c 2065 7272 6f72 5f63 6f64 6528 2929 c, error_code()) │ │ │ -00031fd0: 3b0a 0954 4553 545f 4551 5541 4c28 7265 ;..TEST_EQUAL(re │ │ │ -00031fe0: 7370 2e70 6565 7273 2e73 697a 6528 292c sp.peers.size(), │ │ │ -00031ff0: 2032 293b 0a09 6966 2028 7265 7370 2e70 2);..if (resp.p │ │ │ -00032000: 6565 7273 2e73 697a 6528 2920 3d3d 2032 eers.size() == 2 │ │ │ -00032010: 290a 097b 0a09 0970 6565 725f 656e 7472 )..{...peer_entr │ │ │ -00032020: 7920 636f 6e73 7426 616d 703b 2065 3020 y const& e0 │ │ │ -00032030: 3d20 7265 7370 2e70 6565 7273 5b30 5d3b = resp.peers[0]; │ │ │ -00032040: 0a09 0970 6565 725f 656e 7472 7920 636f ...peer_entry co │ │ │ -00032050: 6e73 7426 616d 703b 2065 3120 3d20 7265 nst& e1 = re │ │ │ -00032060: 7370 2e70 6565 7273 5b31 5d3b 0a09 0954 sp.peers[1];...T │ │ │ -00032070: 4553 545f 4551 5541 4c28 6530 2e68 6f73 EST_EQUAL(e0.hos │ │ │ -00032080: 746e 616d 652c 2022 7465 7374 5f68 6f73 tname, "test_hos │ │ │ -00032090: 746e 616d 6522 293b 0a09 0954 4553 545f tname");...TEST_ │ │ │ -000320a0: 4551 5541 4c28 6530 2e70 6f72 742c 2031 EQUAL(e0.port, 1 │ │ │ -000320b0: 3030 3029 3b0a 0909 5445 5354 5f45 5155 000);...TEST_EQU │ │ │ -000320c0: 414c 2865 302e 7069 642c 2070 6565 725f AL(e0.pid, peer_ │ │ │ -000320d0: 6964 2822 6161 6161 6161 6161 6161 6161 id("aaaaaaaaaaaa │ │ │ -000320e0: 6161 6161 6161 6161 2229 293b 0a0a 0909 aaaaaaaa"));.... │ │ │ -000320f0: 5445 5354 5f45 5155 414c 2865 312e 686f TEST_EQUAL(e1.ho │ │ │ -00032100: 7374 6e61 6d65 2c20 2261 6e6f 7468 6572 stname, "another │ │ │ -00032110: 5f68 6f73 7422 293b 0a09 0954 4553 545f _host");...TEST_ │ │ │ -00032120: 4551 5541 4c28 6531 2e70 6f72 742c 2031 EQUAL(e1.port, 1 │ │ │ -00032130: 3030 3129 3b0a 0909 5445 5354 5f45 5155 001);...TEST_EQU │ │ │ -00032140: 414c 2865 312e 7069 642c 2070 6565 725f AL(e1.pid, peer_ │ │ │ -00032150: 6964 2822 6262 6262 6162 6161 6261 6261 id("bbbbabaababa │ │ │ -00032160: 6261 6261 6261 6261 2229 293b 0a09 7d0a babababa"));..}. │ │ │ -00032170: 7d0a 0a54 4f52 5245 4e54 5f54 4553 5428 }..TORRENT_TEST( │ │ │ -00032180: 7061 7273 655f 7065 6572 7334 290a 7b0a parse_peers4).{. │ │ │ -00032190: 0963 6861 7220 636f 6e73 7420 7265 7370 .char const resp │ │ │ -000321a0: 6f6e 7365 5b5d 203d 2022 6435 3a70 6565 onse[] = "d5:pee │ │ │ -000321b0: 7273 3132 3a5c 7830 315c 7830 325c 7830 rs12:\x01\x02\x0 │ │ │ -000321c0: 335c 7830 345c 7833 305c 7831 3022 0a09 3\x04\x30\x10".. │ │ │ -000321d0: 0922 5c78 3039 5c78 3038 5c78 3037 5c78 ."\x09\x08\x07\x │ │ │ -000321e0: 3036 5c78 3230 5c78 3130 2220 2265 223b 06\x20\x10" "e"; │ │ │ -000321f0: 0a09 6572 726f 725f 636f 6465 2065 633b ..error_code ec; │ │ │ -00032200: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -00032240: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../t │ │ │ -00032270: 6573 742f 7465 7374 5f74 6f72 7265 6e74 est/test_torrent │ │ │ -00032280: 5f69 6e66 6f2e 6370 703a 3437 353c 2f61 _info.cpp:475test r │ │ │ -000322a0: 656d 6170 5f66 696c 6573 3c2f 7464 3e3c emap_files< │ │ │ -000322b0: 2f74 723e 3c74 7220 6964 3d22 3130 3222 /tr>

    test rem │ │ │ -00032300: 6170 5f66 696c 6573 3c2f 6832 3e3c 6834 ap_files

    ../test/test_to │ │ │ -00032320: 7272 656e 745f 696e 666f 2e63 7070 3a34 rrent_info.cpp:4 │ │ │ -00032330: 3735 3c2f 6834 3e3c 7072 6520 7374 796c 75

    relevance 
    │ │ │ -000323b0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872  ;0../t
    │ │ │ -000323e0: 6573 742f 7465 7374 5f74 6f72 7265 6e74  est/test_torrent
    │ │ │ -000323f0: 5f69 6e66 6f2e 6370 703a 3437 363c 2f61  _info.cpp:476torren
    │ │ │ -00032410: 7420 7769 7468 2027 7027 2028 7061 6466  t with 'p' (padf
    │ │ │ -00032420: 696c 6529 2061 7474 7269 6275 7465 3c2f  ile) attribute

    torr │ │ │ -00032480: 656e 7420 7769 7468 2027 7027 2028 7061 ent with 'p' (pa │ │ │ -00032490: 6466 696c 6529 2061 7474 7269 6275 7465 dfile) attribute │ │ │ -000324a0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 7374

    ../test │ │ │ -000324b0: 2f74 6573 745f 746f 7272 656e 745f 696e /test_torrent_in │ │ │ -000324c0: 666f 2e63 7070 3a34 3736 3c2f 6834 3e3c fo.cpp:476

    < │ │ │ -000324d0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -000324e0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -000324f0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00032500: 7820 2364 6464 3b22 3e3c 2f70 7265 3e3c x #ddd;">< │ │ │ -00032510: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00032540: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00032550: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test │ │ │ -00032580: 5f74 6f72 7265 6e74 5f69 6e66 6f2e 6370 _torrent_info.cp │ │ │ -00032590: 703a 3437 373c 2f61 3e3c 2f74 643e 3c74 p:477torrent with ' │ │ │ -000325b0: 6827 2028 6869 6464 656e 2920 6174 7472 h' (hidden) attr │ │ │ -000325c0: 6962 7574 653c 2f74 643e 3c2f 7472 3e3c ibute< │ │ │ -000325d0: 7472 2069 643d 2231 3034 2220 7374 796c tr id="104" styl │ │ │ -000325e0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -000325f0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00032600: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00032610: 6832 3e74 6f72 7265 6e74 2077 6974 6820 h2>torrent with │ │ │ -00032620: 2768 2720 2868 6964 6465 6e29 2061 7474 'h' (hidden) att │ │ │ -00032630: 7269 6275 7465 3c2f 6832 3e3c 6834 3e2e ribute

    . │ │ │ -00032640: 2e2f 7465 7374 2f74 6573 745f 746f 7272 ./test/test_torr │ │ │ -00032650: 656e 745f 696e 666f 2e63 7070 3a34 3737 ent_info.cpp:477 │ │ │ -00032660: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ -000326a0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ -000326b0: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ -000326c0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ -000326d0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ -000326e0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../tes
    │ │ │ -00032710: 742f 7465 7374 5f74 6f72 7265 6e74 5f69  t/test_torrent_i
    │ │ │ -00032720: 6e66 6f2e 6370 703a 3437 383c 2f61 3e3c  nfo.cpp:478<
    │ │ │ -00032730: 2f74 643e 3c74 643e 746f 7272 656e 7420  /td>torrent 
    │ │ │ -00032740: 7769 7468 2027 7827 2028 6578 6563 7574  with 'x' (execut
    │ │ │ -00032750: 6162 6c65 2920 6174 7472 6962 7574 653c  able) attribute<
    │ │ │ -00032760: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d  /td>

    tor │ │ │ -000327b0: 7265 6e74 2077 6974 6820 2778 2720 2865 rent with 'x' (e │ │ │ -000327c0: 7865 6375 7461 626c 6529 2061 7474 7269 xecutable) attri │ │ │ -000327d0: 6275 7465 3c2f 6832 3e3c 6834 3e2e 2e2f bute

    ../ │ │ │ -000327e0: 7465 7374 2f74 6573 745f 746f 7272 656e test/test_torren │ │ │ -000327f0: 745f 696e 666f 2e63 7070 3a34 3738 3c2f t_info.cpp:478

    re │ │ │ -00032870: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../test/ │ │ │ -000328b0: 7465 7374 5f74 6f72 7265 6e74 5f69 6e66 test_torrent_inf │ │ │ -000328c0: 6f2e 6370 703a 3437 393c 2f61 3e3c 2f74 o.cpp:479torrent wi │ │ │ -000328e0: 7468 2027 6c27 2028 7379 6d6c 696e 6b29 th 'l' (symlink) │ │ │ -000328f0: 2061 7474 7269 6275 7465 3c2f 7464 3e3c attribute< │ │ │ -00032900: 2f74 723e 3c74 7220 6964 3d22 3130 3622 /tr>

    torrent │ │ │ -00032950: 7769 7468 2027 6c27 2028 7379 6d6c 696e with 'l' (symlin │ │ │ -00032960: 6b29 2061 7474 7269 6275 7465 3c2f 6832 k) attribute

    ../test/tes │ │ │ -00032980: 745f 746f 7272 656e 745f 696e 666f 2e63 t_torrent_info.c │ │ │ -00032990: 7070 3a34 3739 3c2f 6834 3e3c 7072 6520 pp:479

    
    │ │ │ -000329e0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22  relevance&
    │ │ │ -00032a10: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c  nbsp;0<
    │ │ │ -00032a20: 6120 6872 6566 3d22 6a61 7661 7363 7269  a href="javascri
    │ │ │ -00032a30: 7074 3a65 7870 616e 6428 3130 3729 223e  pt:expand(107)">
    │ │ │ -00032a40: 2e2e 2f74 6573 742f 7465 7374 5f74 6f72  ../test/test_tor
    │ │ │ -00032a50: 7265 6e74 5f69 6e66 6f2e 6370 703a 3438  rent_info.cpp:48
    │ │ │ -00032a60: 303c 2f61 3e3c 2f74 643e 3c74 643e 746f  0to
    │ │ │ -00032a70: 7272 656e 7420 7769 7468 206d 756c 7469  rrent with multi
    │ │ │ -00032a80: 706c 6520 7472 6163 6b65 7273 2069 6e20  ple trackers in 
    │ │ │ -00032a90: 6d75 6c74 6970 6c65 2074 6965 7273 2c20  multiple tiers, 
    │ │ │ -00032aa0: 6d61 6b69 6e67 2073 7572 6520 7765 2073  making sure we s
    │ │ │ -00032ab0: 6875 6666 6c65 2074 6865 6d20 2868 6f77  huffle them (how
    │ │ │ -00032ac0: 2064 6f20 796f 7520 7465 7374 2073 6875   do you test shu
    │ │ │ -00032ad0: 6666 6c69 6e67 3f2c 206c 6f61 6420 6974  ffling?, load it
    │ │ │ -00032ae0: 206d 756c 7469 706c 6520 7469 6d65 7320   multiple times 
    │ │ │ -00032af0: 616e 6420 6d61 6b65 2073 7572 6520 6974  and make sure it
    │ │ │ -00032b00: 2773 2069 6e20 6469 6666 6572 656e 7420  's in different 
    │ │ │ -00032b10: 6f72 6465 7220 6174 206c 6561 7374 206f  order at least o
    │ │ │ -00032b20: 6e63 6529 3c2f 7464 3e3c 2f74 723e 3c74  nce)torrent with m
    │ │ │ -00032b80: 756c 7469 706c 6520 7472 6163 6b65 7273  ultiple trackers
    │ │ │ -00032b90: 2069 6e20 6d75 6c74 6970 6c65 2074 6965   in multiple tie
    │ │ │ -00032ba0: 7273 2c20 6d61 6b69 6e67 2073 7572 6520  rs, making sure 
    │ │ │ -00032bb0: 7765 0a73 6875 6666 6c65 2074 6865 6d20  we.shuffle them 
    │ │ │ -00032bc0: 2868 6f77 2064 6f20 796f 7520 7465 7374  (how do you test
    │ │ │ -00032bd0: 2073 6875 6666 6c69 6e67 3f2c 206c 6f61   shuffling?, loa
    │ │ │ -00032be0: 6420 6974 206d 756c 7469 706c 6520 7469  d it multiple ti
    │ │ │ -00032bf0: 6d65 7320 616e 6420 6d61 6b65 0a73 7572  mes and make.sur
    │ │ │ -00032c00: 6520 6974 2773 2069 6e20 6469 6666 6572  e it's in differ
    │ │ │ -00032c10: 656e 7420 6f72 6465 7220 6174 206c 6561  ent order at lea
    │ │ │ -00032c20: 7374 206f 6e63 6529 3c2f 6832 3e3c 6834  st once)

    ../test/test_to │ │ │ -00032c40: 7272 656e 745f 696e 666f 2e63 7070 3a34 rrent_info.cpp:4 │ │ │ -00032c50: 3830 3c2f 6834 3e3c 7072 6520 7374 796c 80

    relevance 
    │ │ │ -00032cd0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872  ;0../t
    │ │ │ -00032d00: 6573 742f 7465 7374 5f74 6f72 7265 6e74  est/test_torrent
    │ │ │ -00032d10: 5f69 6e66 6f2e 6370 703a 3438 333c 2f61  _info.cpp:483torren
    │ │ │ -00032d30: 7473 2077 6974 6820 6120 7a65 726f 2d6c  ts with a zero-l
    │ │ │ -00032d40: 656e 6774 6820 6e61 6d65 3c2f 7464 3e3c  ength name<
    │ │ │ -00032d50: 2f74 723e 3c74 7220 6964 3d22 3130 3822  /tr>

    torrents │ │ │ -00032da0: 2077 6974 6820 6120 7a65 726f 2d6c 656e with a zero-len │ │ │ -00032db0: 6774 6820 6e61 6d65 3c2f 6832 3e3c 6834 gth name

    ../test/test_to │ │ │ -00032dd0: 7272 656e 745f 696e 666f 2e63 7070 3a34 rrent_info.cpp:4 │ │ │ -00032de0: 3833 3c2f 6834 3e3c 7072 6520 7374 796c 83

    relevance 
    │ │ │ -00032e60: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872  ;0../t
    │ │ │ -00032e90: 6573 742f 7465 7374 5f74 6f72 7265 6e74  est/test_torrent
    │ │ │ -00032ea0: 5f69 6e66 6f2e 6370 703a 3438 343c 2f61  _info.cpp:484torren
    │ │ │ -00032ec0: 7420 7769 7468 2061 206e 6f6e 2d64 6963  t with a non-dic
    │ │ │ -00032ed0: 7469 6f6e 6172 7920 696e 666f 2d73 6563  tionary info-sec
    │ │ │ -00032ee0: 7469 6f6e 3c2f 7464 3e3c 2f74 723e 3c74  tiontorrent with a
    │ │ │ -00032f40: 206e 6f6e 2d64 6963 7469 6f6e 6172 7920   non-dictionary 
    │ │ │ -00032f50: 696e 666f 2d73 6563 7469 6f6e 3c2f 6832  info-section

    ../test/tes │ │ │ -00032f70: 745f 746f 7272 656e 745f 696e 666f 2e63 t_torrent_info.c │ │ │ -00032f80: 7070 3a34 3834 3c2f 6834 3e3c 7072 6520 pp:484

    
    │ │ │ -00032fd0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22  relevance&
    │ │ │ -00033000: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c  nbsp;0<
    │ │ │ -00033010: 6120 6872 6566 3d22 6a61 7661 7363 7269  a href="javascri
    │ │ │ -00033020: 7074 3a65 7870 616e 6428 3131 3029 223e  pt:expand(110)">
    │ │ │ -00033030: 2e2e 2f74 6573 742f 7465 7374 5f74 6f72  ../test/test_tor
    │ │ │ -00033040: 7265 6e74 5f69 6e66 6f2e 6370 703a 3438  rent_info.cpp:48
    │ │ │ -00033050: 353c 2f61 3e3c 2f74 643e 3c74 643e 746f  5to
    │ │ │ -00033060: 7272 656e 7473 2077 6974 6820 4448 5420  rrents with DHT 
    │ │ │ -00033070: 6e6f 6465 733c 2f74 643e 3c2f 7472 3e3c  nodes<
    │ │ │ -00033080: 7472 2069 643d 2231 3130 2220 7374 796c  tr id="110" styl
    │ │ │ -00033090: 653d 2264 6973 706c 6179 3a20 6e6f 6e65  e="display: none
    │ │ │ -000330a0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c  ;" colspan="3"><
    │ │ │ -000330b0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c  td colspan="3"><
    │ │ │ -000330c0: 6832 3e74 6f72 7265 6e74 7320 7769 7468  h2>torrents with
    │ │ │ -000330d0: 2044 4854 206e 6f64 6573 3c2f 6832 3e3c   DHT nodes<
    │ │ │ -000330e0: 6834 3e2e 2e2f 7465 7374 2f74 6573 745f  h4>../test/test_
    │ │ │ -000330f0: 746f 7272 656e 745f 696e 666f 2e63 7070  torrent_info.cpp
    │ │ │ -00033100: 3a34 3835 3c2f 6834 3e3c 7072 6520 7374  :485
    
    │ │ │ -00033170: 3c74 643e 7265 6c65 7661 6e63 6526 6e62  relevance&nb
    │ │ │ -00033180: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120  sp;0..
    │ │ │ -000331b0: 2f74 6573 742f 7465 7374 5f74 6f72 7265  /test/test_torre
    │ │ │ -000331c0: 6e74 5f69 6e66 6f2e 6370 703a 3438 363c  nt_info.cpp:486<
    │ │ │ -000331d0: 2f61 3e3c 2f74 643e 3c74 643e 746f 7272  /a>torr
    │ │ │ -000331e0: 656e 7420 7769 7468 2075 726c 2d6c 6973  ent with url-lis
    │ │ │ -000331f0: 7420 6173 2061 2073 696e 676c 6520 7374  t as a single st
    │ │ │ -00033200: 7269 6e67 3c2f 7464 3e3c 2f74 723e 3c74  ringtorrent with u
    │ │ │ -00033260: 726c 2d6c 6973 7420 6173 2061 2073 696e  rl-list as a sin
    │ │ │ -00033270: 676c 6520 7374 7269 6e67 3c2f 6832 3e3c  gle string<
    │ │ │ -00033280: 6834 3e2e 2e2f 7465 7374 2f74 6573 745f  h4>../test/test_
    │ │ │ -00033290: 746f 7272 656e 745f 696e 666f 2e63 7070  torrent_info.cpp
    │ │ │ -000332a0: 3a34 3836 3c2f 6834 3e3c 7072 6520 7374  :486
    
    │ │ │ -00033310: 3c74 643e 7265 6c65 7661 6e63 6526 6e62  relevance&nb
    │ │ │ -00033320: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120  sp;0
    .. │ │ │ -00033350: 2f74 6573 742f 7465 7374 5f74 6f72 7265 /test/test_torre │ │ │ -00033360: 6e74 5f69 6e66 6f2e 6370 703a 3438 373c nt_info.cpp:487< │ │ │ -00033370: 2f61 3e3c 2f74 643e 3c74 643e 746f 7272 /a>torr │ │ │ -00033380: 656e 7420 7769 7468 2068 7474 7020 7365 ent with http se │ │ │ -00033390: 6564 2061 7320 6120 7369 6e67 6c65 2073 ed as a single s │ │ │ -000333a0: 7472 696e 673c 2f74 643e 3c2f 7472 3e3c tring< │ │ │ -000333b0: 7472 2069 643d 2231 3132 2220 7374 796c tr id="112" styl │ │ │ -000333c0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -000333d0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -000333e0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -000333f0: 6832 3e74 6f72 7265 6e74 2077 6974 6820 h2>torrent with │ │ │ -00033400: 6874 7470 2073 6565 6420 6173 2061 2073 http seed as a s │ │ │ -00033410: 696e 676c 6520 7374 7269 6e67 3c2f 6832 ingle string

    ../test/tes │ │ │ -00033430: 745f 746f 7272 656e 745f 696e 666f 2e63 t_torrent_info.c │ │ │ -00033440: 7070 3a34 3837 3c2f 6834 3e3c 7072 6520 pp:487

    
    │ │ │ -00033490: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22  relevance&
    │ │ │ -000334c0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c  nbsp;0<
    │ │ │ -000334d0: 6120 6872 6566 3d22 6a61 7661 7363 7269  a href="javascri
    │ │ │ -000334e0: 7074 3a65 7870 616e 6428 3131 3329 223e  pt:expand(113)">
    │ │ │ -000334f0: 2e2e 2f74 6573 742f 7465 7374 5f74 6f72  ../test/test_tor
    │ │ │ -00033500: 7265 6e74 5f69 6e66 6f2e 6370 703a 3438  rent_info.cpp:48
    │ │ │ -00033510: 383c 2f61 3e3c 2f74 643e 3c74 643e 746f  8
    to │ │ │ -00033520: 7272 656e 7420 7769 7468 2061 2063 6f6d rrent with a com │ │ │ -00033530: 6d65 6e74 3c2f 7464 3e3c 2f74 723e 3c74 menttorrent with a │ │ │ -00033590: 2063 6f6d 6d65 6e74 3c2f 6832 3e3c 6834 comment

    ../test/test_to │ │ │ -000335b0: 7272 656e 745f 696e 666f 2e63 7070 3a34 rrent_info.cpp:4 │ │ │ -000335c0: 3838 3c2f 6834 3e3c 7072 6520 7374 796c 88

    relevance 
    │ │ │ -00033640: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872  ;0../t
    │ │ │ -00033670: 6573 742f 7465 7374 5f74 6f72 7265 6e74  est/test_torrent
    │ │ │ -00033680: 5f69 6e66 6f2e 6370 703a 3438 393c 2f61  _info.cpp:489torren
    │ │ │ -000336a0: 7420 7769 7468 2061 6e20 5353 4c20 6365  t with an SSL ce
    │ │ │ -000336b0: 7274 3c2f 7464 3e3c 2f74 723e 3c74 7220  rt

    │ │ │ -00033700: 746f 7272 656e 7420 7769 7468 2061 6e20 torrent with an │ │ │ -00033710: 5353 4c20 6365 7274 3c2f 6832 3e3c 6834 SSL cert

    ../test/test_to │ │ │ -00033730: 7272 656e 745f 696e 666f 2e63 7070 3a34 rrent_info.cpp:4 │ │ │ -00033740: 3839 3c2f 6834 3e3c 7072 6520 7374 796c 89

    relevance 
    │ │ │ -000337c0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872  ;0../t
    │ │ │ -000337f0: 6573 742f 7465 7374 5f74 6f72 7265 6e74  est/test_torrent
    │ │ │ -00033800: 5f69 6e66 6f2e 6370 703a 3439 303c 2f61  _info.cpp:490torren
    │ │ │ -00033820: 7420 7769 7468 2061 7474 7269 6275 7465  t with attribute
    │ │ │ -00033830: 7320 2865 7865 6375 7461 626c 6520 616e  s (executable an
    │ │ │ -00033840: 6420 6869 6464 656e 293c 2f74 643e 3c2f  d hidden)

    torrent w │ │ │ -000338a0: 6974 6820 6174 7472 6962 7574 6573 2028 ith attributes ( │ │ │ -000338b0: 6578 6563 7574 6162 6c65 2061 6e64 2068 executable and h │ │ │ -000338c0: 6964 6465 6e29 3c2f 6832 3e3c 6834 3e2e idden)

    . │ │ │ -000338d0: 2e2f 7465 7374 2f74 6573 745f 746f 7272 ./test/test_torr │ │ │ -000338e0: 656e 745f 696e 666f 2e63 7070 3a34 3930 ent_info.cpp:490 │ │ │ -000338f0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ -00033930: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ -00033940: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ -00033950: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ -00033960: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ -00033970: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../tes
    │ │ │ -000339a0: 742f 7465 7374 5f74 6f72 7265 6e74 5f69  t/test_torrent_i
    │ │ │ -000339b0: 6e66 6f2e 6370 703a 3439 313c 2f61 3e3c  nfo.cpp:491<
    │ │ │ -000339c0: 2f74 643e 3c74 643e 746f 7272 656e 745f  /td>torrent_
    │ │ │ -000339d0: 696e 666f 2063 6f6e 7374 7275 6374 6f72  info constructor
    │ │ │ -000339e0: 2074 6861 7420 7461 6b65 7320 616e 2069   that takes an i
    │ │ │ -000339f0: 6e76 616c 6964 2062 656e 636f 6465 6420  nvalid bencoded 
    │ │ │ -00033a00: 6275 6666 6572 3c2f 7464 3e3c 2f74 723e  buffer
    │ │ │ -00033a10: 3c74 7220 6964 3d22 3131 3622 2073 7479  
    │ │ │ -00033a40: 3c74 6420 636f 6c73 7061 6e3d 2233 223e  
    │ │ │ -00033a50: 3c68 323e 746f 7272 656e 745f 696e 666f  

    torrent_info │ │ │ -00033a60: 2063 6f6e 7374 7275 6374 6f72 2074 6861 constructor tha │ │ │ -00033a70: 7420 7461 6b65 7320 616e 2069 6e76 616c t takes an inval │ │ │ -00033a80: 6964 2062 656e 636f 6465 6420 6275 6666 id bencoded buff │ │ │ -00033a90: 6572 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 er

    ../te │ │ │ -00033aa0: 7374 2f74 6573 745f 746f 7272 656e 745f st/test_torrent_ │ │ │ -00033ab0: 696e 666f 2e63 7070 3a34 3931 3c2f 6834 info.cpp:491

    rele
    │ │ │ -00033b30: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../test/te
    │ │ │ -00033b70: 7374 5f74 6f72 7265 6e74 5f69 6e66 6f2e  st_torrent_info.
    │ │ │ -00033b80: 6370 703a 3439 323c 2f61 3e3c 2f74 643e  cpp:492
    │ │ │ -00033b90: 3c74 643e 7665 7269 6679 5f65 6e63 6f64  verify_encod
    │ │ │ -00033ba0: 696e 6720 7769 7468 2061 2073 7472 696e  ing with a strin
    │ │ │ -00033bb0: 6720 7468 6174 2074 7269 6767 6572 7320  g that triggers 
    │ │ │ -00033bc0: 6368 6172 6163 7465 7220 7265 706c 6163  character replac
    │ │ │ -00033bd0: 656d 656e 743c 2f74 643e 3c2f 7472 3e3c  ement<
    │ │ │ -00033be0: 7472 2069 643d 2231 3137 2220 7374 796c  tr id="117" styl
    │ │ │ -00033bf0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65  e="display: none
    │ │ │ -00033c00: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c  ;" colspan="3"><
    │ │ │ -00033c10: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c  td colspan="3"><
    │ │ │ -00033c20: 6832 3e76 6572 6966 795f 656e 636f 6469  h2>verify_encodi
    │ │ │ -00033c30: 6e67 2077 6974 6820 6120 7374 7269 6e67  ng with a string
    │ │ │ -00033c40: 2074 6861 7420 7472 6967 6765 7273 2063   that triggers c
    │ │ │ -00033c50: 6861 7261 6374 6572 2072 6570 6c61 6365  haracter replace
    │ │ │ -00033c60: 6d65 6e74 3c2f 6832 3e3c 6834 3e2e 2e2f  ment

    ../ │ │ │ -00033c70: 7465 7374 2f74 6573 745f 746f 7272 656e test/test_torren │ │ │ -00033c80: 745f 696e 666f 2e63 7070 3a34 3932 3c2f t_info.cpp:492
    .{ 
    │ │ │ -00033cd0: 2276 325f 7069 6563 655f 6c61 7965 725f  "v2_piece_layer_
    │ │ │ -00033ce0: 696e 7661 6c69 645f 6669 6c65 5f68 6173  invalid_file_has
    │ │ │ -00033cf0: 682e 746f 7272 656e 7422 2c20 6572 726f  h.torrent", erro
    │ │ │ -00033d00: 7273 3a3a 746f 7272 656e 745f 696e 7661  rs::torrent_inva
    │ │ │ -00033d10: 6c69 645f 7069 6563 655f 6c61 7965 727d  lid_piece_layer}
    │ │ │ -00033d20: 2c0a 097b 2022 7632 5f69 6e76 616c 6964  ,..{ "v2_invalid
    │ │ │ -00033d30: 5f70 6965 6365 5f6c 6179 6572 2e74 6f72  _piece_layer.tor
    │ │ │ -00033d40: 7265 6e74 222c 2065 7272 6f72 733a 3a74  rent", errors::t
    │ │ │ -00033d50: 6f72 7265 6e74 5f69 6e76 616c 6964 5f70  orrent_invalid_p
    │ │ │ -00033d60: 6965 6365 5f6c 6179 6572 7d2c 0a09 7b20  iece_layer},..{ 
    │ │ │ -00033d70: 2276 325f 696e 7661 6c69 645f 7069 6563  "v2_invalid_piec
    │ │ │ -00033d80: 655f 6c61 7965 725f 726f 6f74 2e74 6f72  e_layer_root.tor
    │ │ │ -00033d90: 7265 6e74 222c 2065 7272 6f72 733a 3a74  rent", errors::t
    │ │ │ -00033da0: 6f72 7265 6e74 5f69 6e76 616c 6964 5f70  orrent_invalid_p
    │ │ │ -00033db0: 6965 6365 5f6c 6179 6572 7d2c 0a09 7b20  iece_layer},..{ 
    │ │ │ -00033dc0: 2276 325f 756e 6b6e 6f77 6e5f 7069 6563  "v2_unknown_piec
    │ │ │ -00033dd0: 655f 6c61 7965 725f 656e 7472 792e 746f  e_layer_entry.to
    │ │ │ -00033de0: 7272 656e 7422 2c20 6572 726f 7273 3a3a  rrent", errors::
    │ │ │ -00033df0: 746f 7272 656e 745f 696e 7661 6c69 645f  torrent_invalid_
    │ │ │ -00033e00: 7069 6563 655f 6c61 7965 727d 2c0a 097b  piece_layer},..{
    │ │ │ -00033e10: 2022 7632 5f69 6e76 616c 6964 5f70 6965   "v2_invalid_pie
    │ │ │ -00033e20: 6365 5f6c 6179 6572 5f73 697a 652e 746f  ce_layer_size.to
    │ │ │ -00033e30: 7272 656e 7422 2c20 6572 726f 7273 3a3a  rrent", errors::
    │ │ │ -00033e40: 746f 7272 656e 745f 696e 7661 6c69 645f  torrent_invalid_
    │ │ │ -00033e50: 7069 6563 655f 6c61 7965 727d 2c0a 097b  piece_layer},..{
    │ │ │ -00033e60: 2022 7632 5f62 6164 5f66 696c 655f 616c   "v2_bad_file_al
    │ │ │ -00033e70: 6967 6e6d 656e 742e 746f 7272 656e 7422  ignment.torrent"
    │ │ │ -00033e80: 2c20 6572 726f 7273 3a3a 746f 7272 656e  , errors::torren
    │ │ │ -00033e90: 745f 696e 636f 6e73 6973 7465 6e74 5f66  t_inconsistent_f
    │ │ │ -00033ea0: 696c 6573 7d2c 0a09 7b20 2276 325f 756e  iles},..{ "v2_un
    │ │ │ -00033eb0: 6f72 6465 7265 645f 6669 6c65 732e 746f  ordered_files.to
    │ │ │ -00033ec0: 7272 656e 7422 2c20 6572 726f 7273 3a3a  rrent", errors::
    │ │ │ -00033ed0: 696e 7661 6c69 645f 6265 6e63 6f64 696e  invalid_bencodin
    │ │ │ -00033ee0: 677d 2c0a 097b 2022 7632 5f6f 7665 726c  g},..{ "v2_overl
    │ │ │ -00033ef0: 6f6e 675f 696e 7465 6765 722e 746f 7272  ong_integer.torr
    │ │ │ -00033f00: 656e 7422 2c20 6572 726f 7273 3a3a 696e  ent", errors::in
    │ │ │ -00033f10: 7661 6c69 645f 6265 6e63 6f64 696e 677d  valid_bencoding}
    │ │ │ -00033f20: 2c0a 097b 2022 7632 5f6d 6973 7369 6e67  ,..{ "v2_missing
    │ │ │ -00033f30: 5f66 696c 655f 726f 6f74 5f69 6e76 616c  _file_root_inval
    │ │ │ -00033f40: 6964 5f73 796d 6c69 6e6b 2e74 6f72 7265  id_symlink.torre
    │ │ │ -00033f50: 6e74 222c 2065 7272 6f72 733a 3a74 6f72  nt", errors::tor
    │ │ │ -00033f60: 7265 6e74 5f6d 6973 7369 6e67 5f70 6965  rent_missing_pie
    │ │ │ -00033f70: 6365 735f 726f 6f74 7d2c 0a09 7b20 2276  ces_root},..{ "v
    │ │ │ -00033f80: 325f 6c61 7267 655f 6669 6c65 2e74 6f72  2_large_file.tor
    │ │ │ -00033f90: 7265 6e74 222c 2065 7272 6f72 733a 3a74  rent", errors::t
    │ │ │ -00033fa0: 6f72 7265 6e74 5f69 6e76 616c 6964 5f6c  orrent_invalid_l
    │ │ │ -00033fb0: 656e 6774 687d 2c0a 097b 2022 7632 5f6c  ength},..{ "v2_l
    │ │ │ -00033fc0: 6172 6765 5f6f 6666 7365 742e 746f 7272  arge_offset.torr
    │ │ │ -00033fd0: 656e 7422 2c20 6572 726f 7273 3a3a 746f  ent", errors::to
    │ │ │ -00033fe0: 6f5f 6d61 6e79 5f70 6965 6365 735f 696e  o_many_pieces_in
    │ │ │ -00033ff0: 5f74 6f72 7265 6e74 7d2c 0a09 7b20 2276  _torrent},..{ "v
    │ │ │ -00034000: 325f 7069 6563 655f 7369 7a65 2e74 6f72  2_piece_size.tor
    │ │ │ -00034010: 7265 6e74 222c 2065 7272 6f72 733a 3a74  rent", errors::t
    │ │ │ -00034020: 6f72 7265 6e74 5f6d 6973 7369 6e67 5f70  orrent_missing_p
    │ │ │ -00034030: 6965 6365 5f6c 656e 6774 687d 2c0a 097b  iece_length},..{
    │ │ │ -00034040: 2022 7632 5f69 6e76 616c 6964 5f70 6164   "v2_invalid_pad
    │ │ │ -00034050: 5f66 696c 652e 746f 7272 656e 7422 2c20  _file.torrent", 
    │ │ │ -00034060: 6572 726f 7273 3a3a 746f 7272 656e 745f  errors::torrent_
    │ │ │ -00034070: 696e 7661 6c69 645f 7061 645f 6669 6c65  invalid_pad_file
    │ │ │ -00034080: 7d2c 0a09 7b20 2276 325f 7a65 726f 5f72  },..{ "v2_zero_r
    │ │ │ -00034090: 6f6f 742e 746f 7272 656e 7422 2c20 6572  oot.torrent", er
    │ │ │ -000340a0: 726f 7273 3a3a 746f 7272 656e 745f 6d69  rors::torrent_mi
    │ │ │ -000340b0: 7373 696e 675f 7069 6563 6573 5f72 6f6f  ssing_pieces_roo
    │ │ │ -000340c0: 747d 2c0a 097b 2022 7632 5f7a 6572 6f5f  t},..{ "v2_zero_
    │ │ │ -000340d0: 726f 6f74 5f73 6d61 6c6c 2e74 6f72 7265  root_small.torre
    │ │ │ -000340e0: 6e74 222c 2065 7272 6f72 733a 3a74 6f72  nt", errors::tor
    │ │ │ -000340f0: 7265 6e74 5f6d 6973 7369 6e67 5f70 6965  rent_missing_pie
    │ │ │ -00034100: 6365 735f 726f 6f74 7d2c 0a09 7b20 2276  ces_root},..{ "v
    │ │ │ -00034110: 325f 656d 7074 795f 6669 6c65 6e61 6d65  2_empty_filename
    │ │ │ -00034120: 2e74 6f72 7265 6e74 222c 2065 7272 6f72  .torrent", error
    │ │ │ -00034130: 733a 3a74 6f72 7265 6e74 5f66 696c 655f  s::torrent_file_
    │ │ │ -00034140: 7061 7273 655f 6661 696c 6564 7d2c 0a7d  parse_failed},.}
    │ │ │ -00034150: 3b0a 0a7d 202f 2f20 616e 6f6e 796d 6f75  ;..} // anonymou
    │ │ │ -00034160: 7320 6e61 6d65 7370 6163 650a 0a3c 6469  s namespace...TORRENT_TEST(a
    │ │ │ -000341b0: 6464 5f74 7261 636b 6572 290a 7b0a 0974  dd_tracker).{..t
    │ │ │ -000341c0: 6f72 7265 6e74 5f69 6e66 6f20 7469 2869  orrent_info ti(i
    │ │ │ -000341d0: 6e66 6f5f 6861 7368 5f74 2873 6861 315f  nfo_hash_t(sha1_
    │ │ │ -000341e0: 6861 7368 2822 2020 2020 2020 2020 2020  hash("          
    │ │ │ -000341f0: 2020 2020 2020 2020 2022 2929 293b 0a09           ")));..
    │ │ │ -00034200: 5445 5354 5f45 5155 414c 2874 692e 7472  TEST_EQUAL(ti.tr
    │ │ │ -00034210: 6163 6b65 7273 2829 2e73 697a 6528 292c  ackers().size(),
    │ │ │ -00034220: 2030 293b 0a0a 0974 692e 6164 645f 7472   0);...ti.add_tr
    │ │ │ -00034230: 6163 6b65 7228 2268 7474 703a 2f2f 7465  acker("http://te
    │ │ │ -00034240: 7374 2e63 6f6d 2f61 6e6e 6f75 6e63 6522  st.com/announce"
    │ │ │ -00034250: 293b 0a09 5445 5354 5f45 5155 414c 2874  );..TEST_EQUAL(t
    │ │ │ -00034260: 692e 7472 6163 6b65 7273 2829 2e73 697a  i.trackers().siz
    │ │ │ -00034270: 6528 292c 2031 293b 0a0a 0961 6e6e 6f75  e(), 1);...annou
    │ │ │ -00034280: 6e63 655f 656e 7472 7920 6165 203d 2074  nce_entry ae = t
    │ │ │ -00034290: 692e 7472 6163 6b65 7273 2829 5b30 5d3b  i.trackers()[0];
    │ │ │ -000342a0: 0a09 5445 5354 5f45 5155 414c 2861 652e  ..TEST_EQUAL(ae.
    │ │ │ -000342b0: 7572 6c2c 2022 6874 7470 3a2f 2f74 6573  url, "http://tes
    │ │ │ -000342c0: 742e 636f 6d2f 616e 6e6f 756e 6365 2229  t.com/announce")
    │ │ │ -000342d0: 3b0a 0a09 7469 2e63 6c65 6172 5f74 7261  ;...ti.clear_tra
    │ │ │ -000342e0: 636b 6572 7328 293b 0a09 5445 5354 5f45  ckers();..TEST_E
    │ │ │ -000342f0: 5155 414c 2874 692e 7472 6163 6b65 7273  QUAL(ti.trackers
    │ │ │ -00034300: 2829 2e73 697a 6528 292c 2030 293b 0a7d  ().size(), 0);.}
    │ │ │ -00034310: 0a0a 544f 5252 454e 545f 5445 5354 2875  ..TORRENT_TEST(u
    │ │ │ -00034320: 726c 5f6c 6973 745f 616e 645f 6874 7470  rl_list_and_http
    │ │ │ -00034330: 7365 6564 7329 0a7b 0a09 656e 7472 7920  seeds).{..entry 
    │ │ │ -00034340: 696e 666f 3b0a 0969 6e66 6f5b 2270 6965  info;..info["pie
    │ │ │ -00034350: 6365 7322 5d20 3d20 2261 6161 6161 6161  ces"] = "aaaaaaa
    │ │ │ -00034360: 6161 6161 6161 6161 6161 6161 6122 3b0a  aaaaaaaaaaaaa";.
    │ │ │ -00034370: 0969 6e66 6f5b 226e 616d 652e 7574 662d  .info["name.utf-
    │ │ │ -00034380: 3822 5d20 3d20 2274 6573 7431 223b 0a09  8"] = "test1";..
    │ │ │ -00034390: 696e 666f 5b22 6e61 6d65 225d 203d 2022  info["name"] = "
    │ │ │ -000343a0: 7465 7374 5f5f 223b 0a09 696e 666f 5b22  test__";..info["
    │ │ │ -000343b0: 7069 6563 6520 6c65 6e67 7468 225d 203d  piece length"] =
    │ │ │ -000343c0: 2031 3620 2a20 3130 3234 3b0a 0969 6e66   16 * 1024;..inf
    │ │ │ -000343d0: 6f5b 226c 656e 6774 6822 5d20 3d20 3332  o["length"] = 32
    │ │ │ -000343e0: 3435 3b0a 0965 6e74 7279 3a3a 6c69 7374  45;..entry::list
    │ │ │ -000343f0: 5f74 7970 6520 6c3b 0a09 6c2e 7075 7368  _type l;..l.push
    │ │ │ -00034400: 5f62 6163 6b28 656e 7472 7928 2268 7474  _back(entry("htt
    │ │ │ -00034410: 703a 2f2f 666f 6f2e 636f 6d2f 6261 7231  p://foo.com/bar1
    │ │ │ -00034420: 2229 293b 0a09 6c2e 7075 7368 5f62 6163  "));..l.push_bac
    │ │ │ -00034430: 6b28 656e 7472 7928 2268 7474 703a 2f2f  k(entry("http://
    │ │ │ -00034440: 666f 6f2e 636f 6d2f 6261 7231 2229 293b  foo.com/bar1"));
    │ │ │ -00034450: 0a09 6c2e 7075 7368 5f62 6163 6b28 656e  ..l.push_back(en
    │ │ │ -00034460: 7472 7928 2268 7474 703a 2f2f 666f 6f2e  try("http://foo.
    │ │ │ -00034470: 636f 6d2f 6261 7232 2229 293b 0a09 656e  com/bar2"));..en
    │ │ │ -00034480: 7472 7920 636f 6e73 7420 6528 6c29 3b0a  try const e(l);.
    │ │ │ -00034490: 0965 6e74 7279 2074 6f72 7265 6e74 3b0a  .entry torrent;.
    │ │ │ -000344a0: 0974 6f72 7265 6e74 5b22 7572 6c2d 6c69  .torrent["url-li
    │ │ │ -000344b0: 7374 225d 203d 2065 3b0a 3c2f 7072 653e  st"] = e;.
    │ │ │ -000344c0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -000344f0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00034500: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../test/tes │ │ │ -00034530: 745f 7469 6d65 7374 616d 705f 6869 7374 t_timestamp_hist │ │ │ -00034540: 6f72 792e 6370 703a 3534 3c2f 613e 3c2f ory.cpp:54test the │ │ │ -00034560: 6361 7365 2077 6865 7265 2077 6520 6861 case where we ha │ │ │ -00034570: 7665 203e 2031 3230 2073 616d 706c 6573 ve > 120 samples │ │ │ -00034580: 2028 616e 6420 6861 7665 2074 6865 2062 (and have the b │ │ │ -00034590: 6173 6520 6465 6c61 7920 6163 7475 616c ase delay actual │ │ │ -000345a0: 6c79 2062 6520 7570 6461 7465 6429 3c2f ly be updated)

    test │ │ │ -00034600: 2074 6865 2063 6173 6520 7768 6572 6520 the case where │ │ │ -00034610: 7765 2068 6176 6520 3e20 3132 3020 7361 we have > 120 sa │ │ │ -00034620: 6d70 6c65 7320 2861 6e64 2068 6176 6520 mples (and have │ │ │ -00034630: 7468 6520 6261 7365 2064 656c 6179 2061 the base delay a │ │ │ -00034640: 6374 7561 6c6c 7920 6265 2075 7064 6174 ctually be updat │ │ │ -00034650: 6564 293c 2f68 323e 3c68 343e 2e2e 2f74 ed)

    ../t │ │ │ -00034660: 6573 742f 7465 7374 5f74 696d 6573 7461 est/test_timesta │ │ │ -00034670: 6d70 5f68 6973 746f 7279 2e63 7070 3a35 mp_history.cpp:5 │ │ │ -00034680: 343c 2f68 343e 3c70 7265 2073 7479 6c65 4

    │ │ │ -000346c0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e  
    │ │ │ -000346d0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00034700: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../te │ │ │ -00034730: 7374 2f74 6573 745f 7469 6d65 7374 616d st/test_timestam │ │ │ -00034740: 705f 6869 7374 6f72 792e 6370 703a 3535 p_history.cpp:55 │ │ │ -00034750: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6573 tes │ │ │ -00034760: 7420 7468 6520 6361 7365 2077 6865 7265 t the case where │ │ │ -00034770: 2061 2073 616d 706c 6520 6973 206c 6f77 a sample is low │ │ │ -00034780: 6572 2074 6861 6e20 7468 6520 6869 7374 er than the hist │ │ │ -00034790: 6f72 7920 656e 7472 7920 6275 7420 6e6f ory entry but no │ │ │ -000347a0: 7420 6c6f 7765 7220 7468 616e 2074 6865 t lower than the │ │ │ -000347b0: 2062 6173 653c 2f74 643e 3c2f 7472 3e3c base< │ │ │ -000347c0: 7472 2069 643d 2231 3139 2220 7374 796c tr id="119" styl │ │ │ -000347d0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -000347e0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -000347f0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00034800: 6832 3e74 6573 7420 7468 6520 6361 7365 h2>test the case │ │ │ -00034810: 2077 6865 7265 2061 2073 616d 706c 6520 where a sample │ │ │ -00034820: 6973 206c 6f77 6572 2074 6861 6e20 7468 is lower than th │ │ │ -00034830: 6520 6869 7374 6f72 7920 656e 7472 7920 e history entry │ │ │ -00034840: 6275 7420 6e6f 7420 6c6f 7765 7220 7468 but not lower th │ │ │ -00034850: 616e 2074 6865 2062 6173 653c 2f68 323e an the base │ │ │ -00034860: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ -00034870: 5f74 696d 6573 7461 6d70 5f68 6973 746f _timestamp_histo │ │ │ -00034880: 7279 2e63 7070 3a35 353c 2f68 343e 3c70 ry.cpp:55

    #include │ │ │ -000348d0: 2022 6c69 6274 6f72 7265 6e74 2f61 7578 "libtorrent/aux │ │ │ -000348e0: 5f2f 7469 6d65 7374 616d 705f 6869 7374 _/timestamp_hist │ │ │ -000348f0: 6f72 792e 6870 7022 0a0a 544f 5252 454e ory.hpp"..TORREN │ │ │ -00034900: 545f 5445 5354 2874 696d 6573 7461 6d70 T_TEST(timestamp │ │ │ -00034910: 5f68 6973 746f 7279 290a 7b0a 0975 7369 _history).{..usi │ │ │ -00034920: 6e67 206e 616d 6573 7061 6365 206c 743b ng namespace lt; │ │ │ -00034930: 0a0a 0961 7578 3a3a 7469 6d65 7374 616d ...aux::timestam │ │ │ -00034940: 705f 6869 7374 6f72 7920 683b 0a09 5445 p_history h;..TE │ │ │ -00034950: 5354 5f45 5155 414c 2868 2e61 6464 5f73 ST_EQUAL(h.add_s │ │ │ -00034960: 616d 706c 6528 3078 3332 2c20 6661 6c73 ample(0x32, fals │ │ │ -00034970: 6529 2c20 3029 3b0a 0954 4553 545f 4551 e), 0);..TEST_EQ │ │ │ -00034980: 5541 4c28 682e 6261 7365 2829 2c20 3078 UAL(h.base(), 0x │ │ │ -00034990: 3332 293b 0a09 5445 5354 5f45 5155 414c 32);..TEST_EQUAL │ │ │ -000349a0: 2868 2e61 6464 5f73 616d 706c 6528 3078 (h.add_sample(0x │ │ │ -000349b0: 3333 2c20 6661 6c73 6529 2c20 3078 3129 33, false), 0x1) │ │ │ -000349c0: 3b0a 0954 4553 545f 4551 5541 4c28 682e ;..TEST_EQUAL(h. │ │ │ -000349d0: 6261 7365 2829 2c20 3078 3332 293b 0a09 base(), 0x32);.. │ │ │ -000349e0: 5445 5354 5f45 5155 414c 2868 2e61 6464 TEST_EQUAL(h.add │ │ │ -000349f0: 5f73 616d 706c 6528 3078 3334 3333 2c20 _sample(0x3433, │ │ │ -00034a00: 6661 6c73 6529 2c20 3078 3334 3031 293b false), 0x3401); │ │ │ -00034a10: 0a09 5445 5354 5f45 5155 414c 2868 2e62 ..TEST_EQUAL(h.b │ │ │ -00034a20: 6173 6528 292c 2030 7833 3229 3b0a 0954 ase(), 0x32);..T │ │ │ -00034a30: 4553 545f 4551 5541 4c28 682e 6164 645f EST_EQUAL(h.add_ │ │ │ -00034a40: 7361 6d70 6c65 2830 7833 302c 2066 616c sample(0x30, fal │ │ │ -00034a50: 7365 292c 2030 293b 0a09 5445 5354 5f45 se), 0);..TEST_E │ │ │ -00034a60: 5155 414c 2868 2e62 6173 6528 292c 2030 QUAL(h.base(), 0 │ │ │ -00034a70: 7833 3029 3b0a 0a09 2f2f 2074 6573 7420 x30);...// test │ │ │ -00034a80: 7468 6174 2077 7261 7070 696e 6720 6f66 that wrapping of │ │ │ -00034a90: 2074 6865 2074 696d 6573 7461 6d70 2069 the timestamp i │ │ │ -00034aa0: 7320 7072 6f70 6572 6c79 2068 616e 646c s properly handl │ │ │ -00034ab0: 6564 0a09 682e 6164 645f 7361 6d70 6c65 ed..h.add_sample │ │ │ -00034ac0: 2830 7866 6666 6666 6666 332c 2066 616c (0xfffffff3, fal │ │ │ -00034ad0: 7365 293b 0a09 5445 5354 5f45 5155 414c se);..TEST_EQUAL │ │ │ -00034ae0: 2868 2e62 6173 6528 292c 2030 7866 6666 (h.base(), 0xfff │ │ │ -00034af0: 6666 6666 3329 3b0a 0a3c 6469 7620 7374 ffff3);..

    }.
    . │ │ │ -00034b30: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00034b40: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00034b70: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../te │ │ │ -00034ba0: 7374 2f74 6573 745f 7373 6c2e 6370 703a st/test_ssl.cpp: │ │ │ -00034bb0: 3430 373c 2f61 3e3c 2f74 643e 3c74 643e 407 │ │ │ -00034bc0: 7465 7374 2075 7369 6e67 2061 2073 6967 test using a sig │ │ │ -00034bd0: 6e65 6420 6365 7274 6966 6963 6174 6520 ned certificate │ │ │ -00034be0: 7769 7468 2074 6865 2077 726f 6e67 2069 with the wrong i │ │ │ -00034bf0: 6e66 6f2d 6861 7368 2069 6e20 444e 3c2f nfo-hash in DN

    test │ │ │ -00034c50: 2075 7369 6e67 2061 2073 6967 6e65 6420 using a signed │ │ │ -00034c60: 6365 7274 6966 6963 6174 6520 7769 7468 certificate with │ │ │ -00034c70: 2074 6865 2077 726f 6e67 2069 6e66 6f2d the wrong info- │ │ │ -00034c80: 6861 7368 2069 6e20 444e 3c2f 6832 3e3c hash in DN

    < │ │ │ -00034c90: 6834 3e2e 2e2f 7465 7374 2f74 6573 745f h4>../test/test_ │ │ │ -00034ca0: 7373 6c2e 6370 703a 3430 373c 2f68 343e ssl.cpp:407 │ │ │ -00034cb0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .// in
    │ │ │ -00034cf0: 2076 6572 6966 7969 6e67 2070 6565 7273   verifying peers
    │ │ │ -00034d00: 0a09 6374 782e 7365 745f 7665 7269 6679  ..ctx.set_verify
    │ │ │ -00034d10: 5f6d 6f64 6528 636f 6e74 6578 743a 3a76  _mode(context::v
    │ │ │ -00034d20: 6572 6966 795f 6e6f 6e65 2c20 6563 293b  erify_none, ec);
    │ │ │ -00034d30: 0a09 6966 2028 6563 290a 097b 0a09 0973  ..if (ec)..{...s
    │ │ │ -00034d40: 7464 3a3a 7072 696e 7466 2822 4661 696c  td::printf("Fail
    │ │ │ -00034d50: 6564 2074 6f20 7365 7420 5353 4c20 7665  ed to set SSL ve
    │ │ │ -00034d60: 7269 6679 206d 6f64 653a 2025 735c 6e22  rify mode: %s\n"
    │ │ │ -00034d70: 0a09 0909 2c20 6563 2e6d 6573 7361 6765  ...., ec.message
    │ │ │ -00034d80: 2829 2e63 5f73 7472 2829 293b 0a09 0954  ().c_str());...T
    │ │ │ -00034d90: 4553 545f 4348 4543 4b28 2165 6329 3b0a  EST_CHECK(!ec);.
    │ │ │ -00034da0: 0909 7265 7475 726e 2066 616c 7365 3b0a  ..return false;.
    │ │ │ -00034db0: 097d 0a0a 0973 7464 3a3a 7374 7269 6e67  .}...std::string
    │ │ │ -00034dc0: 2063 6572 7469 6669 6361 7465 203d 2063   certificate = c
    │ │ │ -00034dd0: 6f6d 6269 6e65 5f70 6174 6828 222e 2e22  ombine_path(".."
    │ │ │ -00034de0: 2c20 636f 6d62 696e 655f 7061 7468 2822  , combine_path("
    │ │ │ -00034df0: 7373 6c22 2c20 2270 6565 725f 6365 7274  ssl", "peer_cert
    │ │ │ -00034e00: 6966 6963 6174 652e 7065 6d22 2929 3b0a  ificate.pem"));.
    │ │ │ -00034e10: 0973 7464 3a3a 7374 7269 6e67 2070 7269  .std::string pri
    │ │ │ -00034e20: 7661 7465 5f6b 6579 203d 2063 6f6d 6269  vate_key = combi
    │ │ │ -00034e30: 6e65 5f70 6174 6828 222e 2e22 2c20 636f  ne_path("..", co
    │ │ │ -00034e40: 6d62 696e 655f 7061 7468 2822 7373 6c22  mbine_path("ssl"
    │ │ │ -00034e50: 2c20 2270 6565 725f 7072 6976 6174 655f  , "peer_private_
    │ │ │ -00034e60: 6b65 792e 7065 6d22 2929 3b0a 0973 7464  key.pem"));..std
    │ │ │ -00034e70: 3a3a 7374 7269 6e67 2064 685f 7061 7261  ::string dh_para
    │ │ │ -00034e80: 6d73 203d 2063 6f6d 6269 6e65 5f70 6174  ms = combine_pat
    │ │ │ -00034e90: 6828 222e 2e22 2c20 636f 6d62 696e 655f  h("..", combine_
    │ │ │ -00034ea0: 7061 7468 2822 7373 6c22 2c20 2264 6870  path("ssl", "dhp
    │ │ │ -00034eb0: 6172 616d 732e 7065 6d22 2929 3b0a 0a09  arams.pem"));...
    │ │ │ -00034ec0: 6966 2028 666c 6167 7320 2661 6d70 3b20  if (flags & 
    │ │ │ -00034ed0: 696e 7661 6c69 645f 6365 7274 6966 6963  invalid_certific
    │ │ │ -00034ee0: 6174 6529 0a09 7b0a 0909 6365 7274 6966  ate)..{...certif
    │ │ │ -00034ef0: 6963 6174 6520 3d20 636f 6d62 696e 655f  icate = combine_
    │ │ │ -00034f00: 7061 7468 2822 2e2e 222c 2063 6f6d 6269  path("..", combi
    │ │ │ -00034f10: 6e65 5f70 6174 6828 2273 736c 222c 2022  ne_path("ssl", "
    │ │ │ -00034f20: 696e 7661 6c69 645f 7065 6572 5f63 6572  invalid_peer_cer
    │ │ │ -00034f30: 7469 6669 6361 7465 2e70 656d 2229 293b  tificate.pem"));
    │ │ │ -00034f40: 0a09 0970 7269 7661 7465 5f6b 6579 203d  ...private_key =
    │ │ │ -00034f50: 2063 6f6d 6269 6e65 5f70 6174 6828 222e   combine_path(".
    │ │ │ -00034f60: 2e22 2c20 636f 6d62 696e 655f 7061 7468  .", combine_path
    │ │ │ -00034f70: 2822 7373 6c22 2c20 2269 6e76 616c 6964  ("ssl", "invalid
    │ │ │ -00034f80: 5f70 6565 725f 7072 6976 6174 655f 6b65  _peer_private_ke
    │ │ │ -00034f90: 792e 7065 6d22 2929 3b0a 097d 0a0a 3c64  y.pem"));..}....if (flags &a
    │ │ │ -00034fe0: 6d70 3b20 2876 616c 6964 5f63 6572 7469  mp; (valid_certi
    │ │ │ -00034ff0: 6669 6361 7465 207c 2069 6e76 616c 6964  ficate | invalid
    │ │ │ -00035000: 5f63 6572 7469 6669 6361 7465 2929 0a09  _certificate))..
    │ │ │ -00035010: 7b0a 0909 7374 643a 3a70 7269 6e74 6628  {...std::printf(
    │ │ │ -00035020: 2273 6574 5f70 6173 7377 6f72 645f 6361  "set_password_ca
    │ │ │ -00035030: 6c6c 6261 636b 5c6e 2229 3b0a 0909 6374  llback\n");...ct
    │ │ │ -00035040: 782e 7365 745f 7061 7373 776f 7264 5f63  x.set_password_c
    │ │ │ -00035050: 616c 6c62 6163 6b28 0a09 0909 5b5d 2873  allback(....[](s
    │ │ │ -00035060: 7464 3a3a 7369 7a65 5f74 2c20 636f 6e74  td::size_t, cont
    │ │ │ -00035070: 6578 743a 3a70 6173 7377 6f72 645f 7075  ext::password_pu
    │ │ │ -00035080: 7270 6f73 6529 207b 2072 6574 7572 6e20  rpose) { return 
    │ │ │ -00035090: 2274 6573 7422 3b20 7d0a 0909 092c 2065  "test"; }...., e
    │ │ │ -000350a0: 6329 3b0a 0909 6966 2028 6563 290a 0909  c);...if (ec)...
    │ │ │ -000350b0: 7b0a 0909 0973 7464 3a3a 7072 696e 7466  {....std::printf
    │ │ │ -000350c0: 2822 4661 696c 6564 2074 6f20 7365 7420  ("Failed to set 
    │ │ │ -000350d0: 6365 7274 6966 6963 6174 6520 7061 7373  certificate pass
    │ │ │ -000350e0: 7068 7261 7365 3a20 2573 5c6e 220a 0909  phrase: %s\n"...
    │ │ │ -000350f0: 0909 2c20 6563 2e6d 6573 7361 6765 2829  .., ec.message()
    │ │ │ -00035100: 2e63 5f73 7472 2829 293b 0a09 0909 5445  .c_str());....TE
    │ │ │ -00035110: 5354 5f43 4845 434b 2821 6563 293b 0a09  ST_CHECK(!ec);..
    │ │ │ -00035120: 0909 7265 7475 726e 2066 616c 7365 3b0a  ..return false;.
    │ │ │ -00035130: 0909 7d0a 0909 7374 643a 3a70 7269 6e74  ..}...std::print
    │ │ │ -00035140: 6628 2275 7365 5f63 6572 7469 6669 6361  f("use_certifica
    │ │ │ -00035150: 7465 5f66 696c 6520 5c22 2573 5c22 5c6e  te_file \"%s\"\n
    │ │ │ -00035160: 222c 2063 6572 7469 6669 6361 7465 2e63  ", certificate.c
    │ │ │ -00035170: 5f73 7472 2829 293b 0a09 0963 7478 2e75  _str());...ctx.u
    │ │ │ -00035180: 7365 5f63 6572 7469 6669 6361 7465 5f66  se_certificate_f
    │ │ │ -00035190: 696c 6528 6365 7274 6966 6963 6174 652c  ile(certificate,
    │ │ │ -000351a0: 2063 6f6e 7465 7874 3a3a 7065 6d2c 2065   context::pem, e
    │ │ │ -000351b0: 6329 3b0a 0909 6966 2028 6563 290a 0909  c);...if (ec)...
    │ │ │ -000351c0: 7b0a 0909 0973 7464 3a3a 7072 696e 7466  {....std::printf
    │ │ │ -000351d0: 2822 4661 696c 6564 2074 6f20 7365 7420  ("Failed to set 
    │ │ │ -000351e0: 6365 7274 6966 6963 6174 6520 6669 6c65  certificate file
    │ │ │ -000351f0: 3a20 2573 5c6e 220a 0909 0909 2c20 6563  : %s\n"....., ec
    │ │ │ -00035200: 2e6d 6573 7361 6765 2829 2e63 5f73 7472  .message().c_str
    │ │ │ -00035210: 2829 293b 0a09 0909 5445 5354 5f43 4845  ());....TEST_CHE
    │ │ │ -00035220: 434b 2821 6563 293b 0a09 0909 7265 7475  CK(!ec);....retu
    │ │ │ -00035230: 726e 2066 616c 7365 3b0a 0909 7d0a 0909  rn false;...}...
    │ │ │ -00035240: 7374 643a 3a70 7269 6e74 6628 2275 7365  std::printf("use
    │ │ │ -00035250: 5f70 7269 7661 7465 5f6b 6579 5f66 696c  _private_key_fil
    │ │ │ -00035260: 6520 5c22 2573 5c22 5c6e 222c 2070 7269  e \"%s\"\n", pri
    │ │ │ -00035270: 7661 7465 5f6b 6579 2e63 5f73 7472 2829  vate_key.c_str()
    │ │ │ -00035280: 293b 0a09 0963 7478 2e75 7365 5f70 7269  );...ctx.use_pri
    │ │ │ -00035290: 7661 7465 5f6b 6579 5f66 696c 6528 7072  vate_key_file(pr
    │ │ │ -000352a0: 6976 6174 655f 6b65 792c 2063 6f6e 7465  ivate_key, conte
    │ │ │ -000352b0: 7874 3a3a 7065 6d2c 2065 6329 3b0a 0909  xt::pem, ec);...
    │ │ │ -000352c0: 6966 2028 6563 290a 0909 7b0a 0909 0973  if (ec)...{....s
    │ │ │ -000352d0: 7464 3a3a 7072 696e 7466 2822 4661 696c  td::printf("Fail
    │ │ │ -000352e0: 6564 2074 6f20 7365 7420 7072 6976 6174  ed to set privat
    │ │ │ -000352f0: 6520 6b65 793a 2025 735c 6e22 0a09 0909  e key: %s\n"....
    │ │ │ -00035300: 092c 2065 632e 6d65 7373 6167 6528 292e  ., ec.message().
    │ │ │ -00035310: 635f 7374 7228 2929 3b0a 0909 0954 4553  c_str());....TES
    │ │ │ -00035320: 545f 4348 4543 4b28 2165 6329 3b0a 0909  T_CHECK(!ec);...
    │ │ │ -00035330: 0972 6574 7572 6e20 6661 6c73 653b 0a3c  .return false;.<
    │ │ │ -00035340: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ -00035350: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ -00035360: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ -00035370: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ -00035380: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../tes
    │ │ │ -000353b0: 742f 7465 7374 5f73 736c 2e63 7070 3a35  t/test_ssl.cpp:5
    │ │ │ -000353c0: 3039 3c2f 613e 3c2f 7464 3e3c 7464 3e61  09a
    │ │ │ -000353d0: 6c73 6f20 7465 7374 2075 7369 6e67 2061  lso test using a
    │ │ │ -000353e0: 2068 6173 6820 7468 6174 2072 6566 6572   hash that refer
    │ │ │ -000353f0: 7320 746f 2061 2076 616c 6964 2074 6f72  s to a valid tor
    │ │ │ -00035400: 7265 6e74 2062 7574 2074 6861 7420 6469  rent but that di
    │ │ │ -00035410: 6666 6572 7320 6672 6f6d 2074 6865 2053  ffers from the S
    │ │ │ -00035420: 4e49 2068 6173 683c 2f74 643e 3c2f 7472  NI hash

    also test u │ │ │ -00035480: 7369 6e67 2061 2068 6173 6820 7468 6174 sing a hash that │ │ │ -00035490: 2072 6566 6572 7320 746f 2061 2076 616c refers to a val │ │ │ -000354a0: 6964 2074 6f72 7265 6e74 0a62 7574 2074 id torrent.but t │ │ │ -000354b0: 6861 7420 6469 6666 6572 7320 6672 6f6d hat differs from │ │ │ -000354c0: 2074 6865 2053 4e49 2068 6173 683c 2f68 the SNI hash

    ../test/te │ │ │ -000354e0: 7374 5f73 736c 2e63 7070 3a35 3039 3c2f st_ssl.cpp:509
    .pr
    │ │ │ -00035530: 696e 745f 616c 6572 7473 2873 6573 312c  int_alerts(ses1,
    │ │ │ -00035540: 2022 7365 7331 222c 2074 7275 652c 2074   "ses1", true, t
    │ │ │ -00035550: 7275 652c 2026 616d 703b 6f6e 5f61 6c65  rue, &on_ale
    │ │ │ -00035560: 7274 293b 0a09 6966 2028 6563 290a 097b  rt);..if (ec)..{
    │ │ │ -00035570: 0a09 0973 7464 3a3a 7072 696e 7466 2822  ...std::printf("
    │ │ │ -00035580: 4661 696c 6564 2053 534c 2068 616e 6473  Failed SSL hands
    │ │ │ -00035590: 6861 6b65 3a20 2573 5c6e 220a 0909 092c  hake: %s\n"....,
    │ │ │ -000355a0: 2065 632e 6d65 7373 6167 6528 292e 635f   ec.message().c_
    │ │ │ -000355b0: 7374 7228 2929 3b0a 0909 7265 7475 726e  str());...return
    │ │ │ -000355c0: 2066 616c 7365 3b0a 097d 0a0a 0963 6861   false;..}...cha
    │ │ │ -000355d0: 7220 6861 6e64 7368 616b 655b 5d20 3d20  r handshake[] = 
    │ │ │ -000355e0: 225c 7831 3322 2022 4269 7454 6f72 7265  "\x13" "BitTorre
    │ │ │ -000355f0: 6e74 2070 726f 746f 636f 6c5c 305c 305c  nt protocol\0\0\
    │ │ │ -00035600: 305c 305c 305c 305c 305c 7830 3422 0a09  0\0\0\0\0\x04"..
    │ │ │ -00035610: 0922 2020 2020 2020 2020 2020 2020 2020  ."              
    │ │ │ -00035620: 2020 2020 2020 2220 2f2f 2073 7061 6365        " // space
    │ │ │ -00035630: 2066 6f72 2069 6e66 6f2d 6861 7368 0a09   for info-hash..
    │ │ │ -00035640: 0922 6161 6161 6161 6161 6161 6161 6161  ."aaaaaaaaaaaaaa
    │ │ │ -00035650: 6161 6161 6161 2220 2f2f 2070 6565 722d  aaaaaa" // peer-
    │ │ │ -00035660: 6964 0a09 0922 5c30 5c30 5c30 5c78 3031  id..."\0\0\0\x01
    │ │ │ -00035670: 5c78 3032 223b 202f 2f20 696e 7465 7265  \x02"; // intere
    │ │ │ -00035680: 7374 6564 0a0a 092f 2f20 6669 6c6c 2069  sted...// fill i
    │ │ │ -00035690: 6e20 7468 6520 696e 666f 2d68 6173 680a  n the info-hash.
    │ │ │ -000356a0: 0969 6620 2866 6c61 6773 2026 616d 703b  .if (flags &
    │ │ │ -000356b0: 2076 616c 6964 5f62 6974 746f 7272 656e   valid_bittorren
    │ │ │ -000356c0: 745f 6861 7368 290a 097b 0a09 0973 7464  t_hash)..{...std
    │ │ │ -000356d0: 3a3a 6d65 6d63 7079 2868 616e 6473 6861  ::memcpy(handsha
    │ │ │ -000356e0: 6b65 202b 2032 382c 2026 616d 703b 742d  ke + 28, &t-
    │ │ │ -000356f0: 2667 743b 696e 666f 5f68 6173 6865 7328  >info_hashes(
    │ │ │ -00035700: 292e 7631 5b30 5d2c 2032 3029 3b0a 097d  ).v1[0], 20);..}
    │ │ │ -00035710: 0a09 656c 7365 0a09 7b0a 3c64 6976 2073  ..else..{.
    ..std::g │ │ │ -00035750: 656e 6572 6174 6528 6861 6e64 7368 616b enerate(handshak │ │ │ -00035760: 6520 2b20 3238 2c20 6861 6e64 7368 616b e + 28, handshak │ │ │ -00035770: 6520 2b20 3438 2c20 2661 6d70 3b72 616e e + 48, &ran │ │ │ -00035780: 6429 3b0a 3c2f 6469 763e 097d 0a0a 092f d);.
    .}.../ │ │ │ -00035790: 2f20 6669 6c6c 2069 6e20 7468 6520 7065 / fill in the pe │ │ │ -000357a0: 6572 2d69 640a 0973 7464 3a3a 6765 6e65 er-id..std::gene │ │ │ -000357b0: 7261 7465 2868 616e 6473 6861 6b65 202b rate(handshake + │ │ │ -000357c0: 2034 382c 2068 616e 6473 6861 6b65 202b 48, handshake + │ │ │ -000357d0: 2036 382c 2026 616d 703b 7261 6e64 293b 68, &rand); │ │ │ -000357e0: 0a0a 0973 7464 3a3a 7072 696e 7466 2822 ...std::printf(" │ │ │ -000357f0: 6269 7474 6f72 7265 6e74 2068 616e 6473 bittorrent hands │ │ │ -00035800: 6861 6b65 5c6e 2229 3b0a 0962 6f6f 7374 hake\n");..boost │ │ │ -00035810: 3a3a 6173 696f 3a3a 7772 6974 6528 7373 ::asio::write(ss │ │ │ -00035820: 6c5f 736f 636b 2c20 626f 6f73 743a 3a61 l_sock, boost::a │ │ │ -00035830: 7369 6f3a 3a62 7566 6665 7228 6861 6e64 sio::buffer(hand │ │ │ -00035840: 7368 616b 652c 2028 7369 7a65 6f66 2868 shake, (sizeof(h │ │ │ -00035850: 616e 6473 6861 6b65 2920 2d20 3129 292c andshake) - 1)), │ │ │ -00035860: 2065 6329 3b0a 0970 7269 6e74 5f61 6c65 ec);..print_ale │ │ │ -00035870: 7274 7328 7365 7331 2c20 2273 6573 3122 rts(ses1, "ses1" │ │ │ -00035880: 2c20 7472 7565 2c20 7472 7565 2c20 2661 , true, true, &a │ │ │ -00035890: 6d70 3b6f 6e5f 616c 6572 7429 3b0a 0969 mp;on_alert);..i │ │ │ -000358a0: 6620 2865 6329 0a09 7b0a 0909 7374 643a f (ec)..{...std: │ │ │ -000358b0: 3a70 7269 6e74 6628 2266 6169 6c65 6420 :printf("failed │ │ │ -000358c0: 746f 2077 7269 7465 2062 6974 746f 7272 to write bittorr │ │ │ -000358d0: 656e 7420 6861 6e64 7368 616b 653a 2025 ent handshake: % │ │ │ -000358e0: 735c 6e22 0a09 0909 2c20 6563 2e6d 6573 s\n"...., ec.mes │ │ │ -000358f0: 7361 6765 2829 2e63 5f73 7472 2829 293b sage().c_str()); │ │ │ -00035900: 0a09 0972 6574 7572 6e20 6661 6c73 653b ...return false; │ │ │ -00035910: 0a09 7d0a 0a09 6368 6172 2062 7566 5b36 ..}...char buf[6 │ │ │ -00035920: 385d 3b0a 0973 7464 3a3a 7072 696e 7466 8];..std::printf │ │ │ -00035930: 2822 7265 6164 2062 6974 746f 7272 656e ("read bittorren │ │ │ -00035940: 7420 6861 6e64 7368 616b 655c 6e22 293b t handshake\n"); │ │ │ -00035950: 0a09 626f 6f73 743a 3a61 7369 6f3a 3a72 ..boost::asio::r │ │ │ -00035960: 6561 6428 7373 6c5f 736f 636b 2c20 626f ead(ssl_sock, bo │ │ │ -00035970: 6f73 743a 3a61 7369 6f3a 3a62 7566 6665 ost::asio::buffe │ │ │ -00035980: 7228 6275 662c 2073 697a 656f 6628 6275 r(buf, sizeof(bu │ │ │ -00035990: 6629 292c 2065 6329 3b0a 0970 7269 6e74 f)), ec);..print │ │ │ -000359a0: 5f61 6c65 7274 7328 7365 7331 2c20 2273 _alerts(ses1, "s │ │ │ -000359b0: 6573 3122 2c20 7472 7565 2c20 7472 7565 es1", true, true │ │ │ -000359c0: 2c20 2661 6d70 3b6f 6e5f 616c 6572 7429 , &on_alert) │ │ │ -000359d0: 3b0a 0969 6620 2865 6329 0a09 7b0a 0909 ;..if (ec)..{... │ │ │ -000359e0: 7374 643a 3a70 7269 6e74 6628 2266 6169 std::printf("fai │ │ │ -000359f0: 6c65 6420 746f 2072 6561 6420 6269 7474 led to read bitt │ │ │ -00035a00: 6f72 7265 6e74 2068 616e 6473 6861 6b65 orrent handshake │ │ │ -00035a10: 3a20 2573 5c6e 220a 0909 092c 2065 632e : %s\n"...., ec. │ │ │ -00035a20: 6d65 7373 6167 6528 292e 635f 7374 7228 message().c_str( │ │ │ -00035a30: 2929 3b0a 0909 7265 7475 726e 2066 616c ));...return fal │ │ │ -00035a40: 7365 3b0a 097d 0a0a 0969 6620 286d 656d se;..}...if (mem │ │ │ -00035a50: 636d 7028 6275 662c 2022 5c78 3133 2220 cmp(buf, "\x13" │ │ │ -00035a60: 2242 6974 546f 7272 656e 7420 7072 6f74 "BitTorrent prot │ │ │ -00035a70: 6f63 6f6c 222c 2032 3029 2021 3d20 3029 ocol", 20) != 0) │ │ │ -00035a80: 0a09 7b0a 0909 7374 643a 3a70 7269 6e74 ..{...std::print │ │ │ -00035a90: 6628 2269 6e76 616c 6964 2062 6974 746f f("invalid bitto │ │ │ -00035aa0: 7272 656e 7420 6861 6e64 7368 616b 655c rrent handshake\ │ │ │ -00035ab0: 6e22 293b 0a09 0972 6574 7572 6e20 6661 n");...return fa │ │ │ -00035ac0: 6c73 653b 0a3c 2f70 7265 3e3c 2f74 643e lse;.
    │ │ │ -00035ad0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00035b00: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00035b10: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00035b20: 7074 3a65 7870 616e 6428 3132 3229 223e pt:expand(122)"> │ │ │ -00035b30: 2e2e 2f74 6573 742f 7465 7374 5f72 6573 ../test/test_res │ │ │ -00035b40: 756d 652e 6370 703a 3631 343c 2f61 3e3c ume.cpp:614< │ │ │ -00035b50: 2f74 643e 3c74 643e 7465 7374 2077 6861 /td>test wha │ │ │ -00035b60: 7420 6861 7070 656e 7320 7768 656e 206c t happens when l │ │ │ -00035b70: 6f61 6469 6e67 2061 2072 6573 756d 6520 oading a resume │ │ │ -00035b80: 6669 6c65 2077 6974 6820 626f 7468 2070 file with both p │ │ │ -00035b90: 6965 6365 2070 7269 6f72 6974 6965 7320 iece priorities │ │ │ -00035ba0: 616e 6420 6669 6c65 2070 7269 6f72 6974 and file priorit │ │ │ -00035bb0: 6965 7320 2866 696c 6520 7072 696f 2073 ies (file prio s │ │ │ -00035bc0: 686f 756c 6420 7461 6b65 2070 7265 6365 hould take prece │ │ │ -00035bd0: 6465 6e63 6529 3c2f 7464 3e3c 2f74 723e dence) │ │ │ -00035be0: 3c74 7220 6964 3d22 3132 3222 2073 7479 │ │ │ -00035c10: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00035c20: 3c68 323e 7465 7374 2077 6861 7420 6861

    test what ha │ │ │ -00035c30: 7070 656e 7320 7768 656e 206c 6f61 6469 ppens when loadi │ │ │ -00035c40: 6e67 2061 2072 6573 756d 6520 6669 6c65 ng a resume file │ │ │ -00035c50: 2077 6974 6820 626f 7468 2070 6965 6365 with both piece │ │ │ -00035c60: 2070 7269 6f72 6974 6965 730a 616e 6420 priorities.and │ │ │ -00035c70: 6669 6c65 2070 7269 6f72 6974 6965 7320 file priorities │ │ │ -00035c80: 2866 696c 6520 7072 696f 2073 686f 756c (file prio shoul │ │ │ -00035c90: 6420 7461 6b65 2070 7265 6365 6465 6e63 d take precedenc │ │ │ -00035ca0: 6529 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 e)

    ../te │ │ │ -00035cb0: 7374 2f74 6573 745f 7265 7375 6d65 2e63 st/test_resume.c │ │ │ -00035cc0: 7070 3a36 3134 3c2f 6834 3e3c 7072 6520 pp:614

    ..{....TEST
    │ │ │ -00035d10: 5f45 5155 414c 2870 6965 6365 735b 695d  _EQUAL(pieces[i]
    │ │ │ -00035d20: 2c20 7472 7565 293b 0a09 097d 0a09 7d0a  , true);...}..}.
    │ │ │ -00035d30: 7d0a 0a7d 202f 2f20 616e 6f6e 796d 6f75  }..} // anonymou
    │ │ │ -00035d40: 7320 6e61 6d65 7370 6163 650a 0a54 4f52  s namespace..TOR
    │ │ │ -00035d50: 5245 4e54 5f54 4553 5428 7069 6563 655f  RENT_TEST(piece_
    │ │ │ -00035d60: 736c 6f74 735f 7365 6564 290a 7b0a 0974  slots_seed).{..t
    │ │ │ -00035d70: 6573 745f 7069 6563 655f 736c 6f74 735f  est_piece_slots_
    │ │ │ -00035d80: 7365 6564 2873 6574 7469 6e67 7328 2929  seed(settings())
    │ │ │ -00035d90: 3b0a 7d0a 0a54 4f52 5245 4e54 5f54 4553  ;.}..TORRENT_TES
    │ │ │ -00035da0: 5428 7069 6563 655f 736c 6f74 735f 7365  T(piece_slots_se
    │ │ │ -00035db0: 6564 5f73 7567 6765 7374 5f63 6163 6865  ed_suggest_cache
    │ │ │ -00035dc0: 290a 7b0a 0973 6574 7469 6e67 735f 7061  ).{..settings_pa
    │ │ │ -00035dd0: 636b 2073 6574 7420 3d20 7365 7474 696e  ck sett = settin
    │ │ │ -00035de0: 6773 2829 3b0a 0973 6574 742e 7365 745f  gs();..sett.set_
    │ │ │ -00035df0: 696e 7428 7365 7474 696e 6773 5f70 6163  int(settings_pac
    │ │ │ -00035e00: 6b3a 3a73 7567 6765 7374 5f6d 6f64 652c  k::suggest_mode,
    │ │ │ -00035e10: 2073 6574 7469 6e67 735f 7061 636b 3a3a   settings_pack::
    │ │ │ -00035e20: 7375 6767 6573 745f 7265 6164 5f63 6163  suggest_read_cac
    │ │ │ -00035e30: 6865 293b 0a09 7465 7374 5f70 6965 6365  he);..test_piece
    │ │ │ -00035e40: 5f73 6c6f 7473 5f73 6565 6428 7365 7474  _slots_seed(sett
    │ │ │ -00035e50: 293b 0a7d 0a0a 3c64 6976 2073 7479 6c65  );.}..
    .
    rele │ │ │ -00035ec0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../test/te │ │ │ -00035f00: 7374 5f72 6573 756d 652e 6370 703a 3631 st_resume.cpp:61 │ │ │ -00035f10: 373c 2f61 3e3c 2f74 643e 3c74 643e 6d61 7ma │ │ │ -00035f20: 6b65 2073 7572 6520 6120 7265 7375 6d65 ke sure a resume │ │ │ -00035f30: 2066 696c 6520 6f6e 6c79 2065 7665 7220 file only ever │ │ │ -00035f40: 636f 6e74 6169 6e20 6669 6c65 2070 7269 contain file pri │ │ │ -00035f50: 6f72 6974 6965 7320 4f52 2070 6965 6365 orities OR piece │ │ │ -00035f60: 2070 7269 6f72 6974 6965 732e 204e 6576 priorities. Nev │ │ │ -00035f70: 6572 2062 6f74 682e 3c2f 7464 3e3c 2f74 er both.

    make sure │ │ │ -00035fd0: 6120 7265 7375 6d65 2066 696c 6520 6f6e a resume file on │ │ │ -00035fe0: 6c79 2065 7665 7220 636f 6e74 6169 6e20 ly ever contain │ │ │ -00035ff0: 6669 6c65 2070 7269 6f72 6974 6965 7320 file priorities │ │ │ -00036000: 4f52 2070 6965 6365 0a70 7269 6f72 6974 OR piece.priorit │ │ │ -00036010: 6965 732e 204e 6576 6572 2062 6f74 682e ies. Never both. │ │ │ -00036020: 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 7374

    ../test │ │ │ -00036030: 2f74 6573 745f 7265 7375 6d65 2e63 7070 /test_resume.cpp │ │ │ -00036040: 3a36 3137 3c2f 6834 3e3c 7072 6520 7374 :617

    ...TEST_EQUAL
    │ │ │ -00036090: 2870 6965 6365 735b 695d 2c20 7472 7565  (pieces[i], true
    │ │ │ -000360a0: 293b 0a09 097d 0a09 7d0a 7d0a 0a7d 202f  );...}..}.}..} /
    │ │ │ -000360b0: 2f20 616e 6f6e 796d 6f75 7320 6e61 6d65  / anonymous name
    │ │ │ -000360c0: 7370 6163 650a 0a54 4f52 5245 4e54 5f54  space..TORRENT_T
    │ │ │ -000360d0: 4553 5428 7069 6563 655f 736c 6f74 735f  EST(piece_slots_
    │ │ │ -000360e0: 7365 6564 290a 7b0a 0974 6573 745f 7069  seed).{..test_pi
    │ │ │ -000360f0: 6563 655f 736c 6f74 735f 7365 6564 2873  ece_slots_seed(s
    │ │ │ -00036100: 6574 7469 6e67 7328 2929 3b0a 7d0a 0a54  ettings());.}..T
    │ │ │ -00036110: 4f52 5245 4e54 5f54 4553 5428 7069 6563  ORRENT_TEST(piec
    │ │ │ -00036120: 655f 736c 6f74 735f 7365 6564 5f73 7567  e_slots_seed_sug
    │ │ │ -00036130: 6765 7374 5f63 6163 6865 290a 7b0a 0973  gest_cache).{..s
    │ │ │ -00036140: 6574 7469 6e67 735f 7061 636b 2073 6574  ettings_pack set
    │ │ │ -00036150: 7420 3d20 7365 7474 696e 6773 2829 3b0a  t = settings();.
    │ │ │ -00036160: 0973 6574 742e 7365 745f 696e 7428 7365  .sett.set_int(se
    │ │ │ -00036170: 7474 696e 6773 5f70 6163 6b3a 3a73 7567  ttings_pack::sug
    │ │ │ -00036180: 6765 7374 5f6d 6f64 652c 2073 6574 7469  gest_mode, setti
    │ │ │ -00036190: 6e67 735f 7061 636b 3a3a 7375 6767 6573  ngs_pack::sugges
    │ │ │ -000361a0: 745f 7265 6164 5f63 6163 6865 293b 0a09  t_read_cache);..
    │ │ │ -000361b0: 7465 7374 5f70 6965 6365 5f73 6c6f 7473  test_piece_slots
    │ │ │ -000361c0: 5f73 6565 6428 7365 7474 293b 0a7d 0a0a  _seed(sett);.}..
    │ │ │ -000361d0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -00036200: 3c2f 6469 763e 3c2f 7072 653e 3c2f 7464
    relevance │ │ │ -00036240: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -00036250: 3c61 2068 7265 663d 226a 6176 6173 6372 ../test/test_re │ │ │ -00036280: 7375 6d65 2e63 7070 3a36 3230 3c2f 613e sume.cpp:620 │ │ │ -00036290: 3c2f 7464 3e3c 7464 3e67 656e 6572 616c general │ │ │ -000362a0: 6c79 2073 6176 653c 2f74 643e 3c2f 7472 ly save

    generally s │ │ │ -00036300: 6176 653c 2f68 323e 3c68 343e 2e2e 2f74 ave

    ../t │ │ │ -00036310: 6573 742f 7465 7374 5f72 6573 756d 652e est/test_resume. │ │ │ -00036320: 6370 703a 3632 303c 2f68 343e 3c70 7265 cpp:620

    ..}..}.}..
    │ │ │ -00036370: 7d20 2f2f 2061 6e6f 6e79 6d6f 7573 206e  } // anonymous n
    │ │ │ -00036380: 616d 6573 7061 6365 0a0a 544f 5252 454e  amespace..TORREN
    │ │ │ -00036390: 545f 5445 5354 2870 6965 6365 5f73 6c6f  T_TEST(piece_slo
    │ │ │ -000363a0: 7473 5f73 6565 6429 0a7b 0a09 7465 7374  ts_seed).{..test
    │ │ │ -000363b0: 5f70 6965 6365 5f73 6c6f 7473 5f73 6565  _piece_slots_see
    │ │ │ -000363c0: 6428 7365 7474 696e 6773 2829 293b 0a7d  d(settings());.}
    │ │ │ -000363d0: 0a0a 544f 5252 454e 545f 5445 5354 2870  ..TORRENT_TEST(p
    │ │ │ -000363e0: 6965 6365 5f73 6c6f 7473 5f73 6565 645f  iece_slots_seed_
    │ │ │ -000363f0: 7375 6767 6573 745f 6361 6368 6529 0a7b  suggest_cache).{
    │ │ │ -00036400: 0a09 7365 7474 696e 6773 5f70 6163 6b20  ..settings_pack 
    │ │ │ -00036410: 7365 7474 203d 2073 6574 7469 6e67 7328  sett = settings(
    │ │ │ -00036420: 293b 0a09 7365 7474 2e73 6574 5f69 6e74  );..sett.set_int
    │ │ │ -00036430: 2873 6574 7469 6e67 735f 7061 636b 3a3a  (settings_pack::
    │ │ │ -00036440: 7375 6767 6573 745f 6d6f 6465 2c20 7365  suggest_mode, se
    │ │ │ -00036450: 7474 696e 6773 5f70 6163 6b3a 3a73 7567  ttings_pack::sug
    │ │ │ -00036460: 6765 7374 5f72 6561 645f 6361 6368 6529  gest_read_cache)
    │ │ │ -00036470: 3b0a 0974 6573 745f 7069 6563 655f 736c  ;..test_piece_sl
    │ │ │ -00036480: 6f74 735f 7365 6564 2873 6574 7429 3b0a  ots_seed(sett);.
    │ │ │ -00036490: 7d0a 0a0a 0a3c 6469 7620 7374 796c 653d  }....
    .
    #if TO │ │ │ -000364d0: 5252 454e 545f 4142 495f 5645 5253 494f RRENT_ABI_VERSIO │ │ │ -000364e0: 4e20 3d3d 2031 0a54 4f52 5245 4e54 5f54 N == 1.TORRENT_T │ │ │ -000364f0: 4553 5428 6669 6c65 5f70 7269 6f72 6974 EST(file_priorit │ │ │ -00036500: 6965 735f 6465 6661 756c 745f 6465 7072 ies_default_depr │ │ │ -00036510: 6563 6174 6564 290a 7b0a 096c 743a 3a73 ecated).{..lt::s │ │ │ -00036520: 6573 7369 6f6e 2073 6573 2873 6574 7469 ession ses(setti │ │ │ -00036530: 6e67 7328 2929 3b0a 0973 7464 3a3a 7665 ngs());..std::ve │ │ │ -00036540: 6374 6f72 266c 743b 646f 776e 6c6f 6164 ctor<download │ │ │ -00036550: 5f70 7269 6f72 6974 795f 7426 6774 3b20 _priority_t> │ │ │ -00036560: 6669 6c65 5f70 7269 6f72 6974 6965 7320 file_priorities │ │ │ -00036570: 3d20 7465 7374 5f72 6573 756d 655f 666c = test_resume_fl │ │ │ -00036580: 6167 7328 7365 730a 0909 2c20 7b7d 2c20 ags(ses..., {}, │ │ │ -00036590: 2222 2c20 2222 2c20 7472 7565 292e 6765 "", "", true).ge │ │ │ -000365a0: 745f 6669 6c65 5f70 7269 6f72 6974 6965 t_file_prioritie │ │ │ -000365b0: 7328 293b 0a0a 0954 4553 545f 4551 5541 s();...TEST_EQUA │ │ │ -000365c0: 4c28 6669 6c65 5f70 7269 6f72 6974 6965 L(file_prioritie │ │ │ -000365d0: 732e 7369 7a65 2829 2c20 3329 3b0a 0954 s.size(), 3);..T │ │ │ -000365e0: 4553 545f 4551 5541 4c28 6669 6c65 5f70 EST_EQUAL(file_p │ │ │ -000365f0: 7269 6f72 6974 6965 735b 305d 2c20 3429 riorities[0], 4) │ │ │ -00036600: 3b0a 0954 4553 545f 4551 5541 4c28 6669 ;..TEST_EQUAL(fi │ │ │ -00036610: 6c65 5f70 7269 6f72 6974 6965 735b 315d le_priorities[1] │ │ │ -00036620: 2c20 3429 3b0a 0954 4553 545f 4551 5541 , 4);..TEST_EQUA │ │ │ -00036630: 4c28 6669 6c65 5f70 7269 6f72 6974 6965 L(file_prioritie │ │ │ -00036640: 735b 325d 2c20 3429 3b0a 7d0a 0a2f 2f20 s[2], 4);.}..// │ │ │ -00036650: 4173 206c 6f6e 6720 6173 2074 6865 2061 As long as the a │ │ │ -00036660: 6464 5f74 6f72 7265 6e74 5f70 6172 616d dd_torrent_param │ │ │ -00036670: 7320 7072 696f 7269 7469 6573 2061 7265 s priorities are │ │ │ -00036680: 2065 6d70 7479 2c20 7468 6520 6669 6c65 empty, the file │ │ │ -00036690: 5f70 7269 6f72 6974 6965 730a 2f2f 2066 _priorities.// f │ │ │ -000366a0: 726f 6d20 7468 6520 7265 7375 6d65 2064 rom the resume d │ │ │ -000366b0: 6174 6120 7368 6f75 6c64 2074 616b 6520 ata should take │ │ │ -000366c0: 6566 6665 6374 0a54 4f52 5245 4e54 5f54 effect.TORRENT_T │ │ │ -000366d0: 4553 5428 6669 6c65 5f70 7269 6f72 6974 EST(file_priorit │ │ │ -000366e0: 6965 735f 696e 5f72 6573 756d 655f 6465 ies_in_resume_de │ │ │ -000366f0: 7072 6563 6174 6564 290a 7b0a 096c 743a precated).{..lt: │ │ │ -00036700: 3a73 6573 7369 6f6e 2073 6573 2873 6574 :session ses(set │ │ │ -00036710: 7469 6e67 7328 2929 3b0a 0973 7464 3a3a tings());..std:: │ │ │ -00036720: 7665 6374 6f72 266c 743b 646f 776e 6c6f vector<downlo │ │ │ -00036730: 6164 5f70 7269 6f72 6974 795f 7426 6774 ad_priority_t> │ │ │ -00036740: 3b20 6669 6c65 5f70 7269 6f72 6974 6965 ; file_prioritie │ │ │ -00036750: 7320 3d20 7465 7374 5f72 6573 756d 655f s = test_resume_ │ │ │ -00036760: 666c 6167 7328 7365 732c 207b 7d2c 2022 flags(ses, {}, " │ │ │ -00036770: 222c 2022 3132 3322 292e 6765 745f 6669 ", "123").get_fi │ │ │ -00036780: 6c65 5f70 7269 6f72 6974 6965 7328 293b le_priorities(); │ │ │ -00036790: 0a0a 0954 4553 545f 4551 5541 4c28 6669 ...TEST_EQUAL(fi │ │ │ -000367a0: 6c65 5f70 7269 6f72 6974 6965 732e 7369 le_priorities.si │ │ │ -000367b0: 7a65 2829 2c20 3329 3b0a 0954 4553 545f ze(), 3);..TEST_ │ │ │ -000367c0: 4551 5541 4c28 6669 6c65 5f70 7269 6f72 EQUAL(file_prior │ │ │ -000367d0: 6974 6965 735b 305d 2c20 3129 3b0a 0954 ities[0], 1);..T │ │ │ -000367e0: 4553 545f 4551 5541 4c28 6669 6c65 5f70 EST_EQUAL(file_p │ │ │ -000367f0: 7269 6f72 6974 6965 735b 315d 2c20 3229 riorities[1], 2) │ │ │ -00036800: 3b0a 0954 4553 545f 4551 5541 4c28 6669 ;..TEST_EQUAL(fi │ │ │ -00036810: 6c65 5f70 7269 6f72 6974 6965 735b 325d le_priorities[2] │ │ │ -00036820: 2c20 3329 3b0a 7d0a 0a2f 2f20 6966 2062 , 3);.}..// if b │ │ │ -00036830: 6f74 6820 7265 7375 6d65 2064 6174 6120 oth resume data │ │ │ -00036840: 616e 6420 6164 645f 746f 7272 656e 745f and add_torrent_ │ │ │ -00036850: 7061 7261 6d73 2068 6173 2066 696c 655f params has file_ │ │ │ -00036860: 7072 696f 7269 7469 6573 2c20 7468 650a priorities, the. │ │ │ -00036870: 2f2f 2061 6464 5f74 6f72 7265 6e74 5f70 // add_torrent_p │ │ │ -00036880: 6172 616d 7320 6f6e 6520 7461 6b65 2070 arams one take p │ │ │ -00036890: 7265 6365 6465 6e63 650a 544f 5252 454e recedence.TORREN │ │ │ -000368a0: 545f 5445 5354 2866 696c 655f 7072 696f T_TEST(file_prio │ │ │ -000368b0: 7269 7469 6573 5f69 6e5f 7265 7375 6d65 rities_in_resume │ │ │ -000368c0: 5f61 6e64 5f70 6172 616d 735f 6465 7072 _and_params_depr │ │ │ -000368d0: 6563 6174 6564 290a 7b0a 3c2f 7072 653e ecated).{.
    │ │ │ -000368e0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -00036910: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00036920: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../test/tes │ │ │ -00036950: 745f 7265 7375 6d65 2e63 7070 3a39 3433 t_resume.cpp:943 │ │ │ -00036960: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6573 tes │ │ │ -00036970: 7420 616c 6c20 6f74 6865 7220 7265 7375 t all other resu │ │ │ -00036980: 6d65 2066 6c61 6773 2068 6572 6520 746f me flags here to │ │ │ -00036990: 6f2e 2054 6869 7320 776f 756c 6420 7265 o. This would re │ │ │ -000369a0: 7175 6972 6520 7265 7475 726e 696e 6720 quire returning │ │ │ -000369b0: 6d6f 7265 2074 6861 6e20 6a75 7374 2074 more than just t │ │ │ -000369c0: 6865 2074 6f72 7265 6e74 5f73 7461 7475 he torrent_statu │ │ │ -000369d0: 7320 6672 6f6d 2074 6573 745f 7265 7375 s from test_resu │ │ │ -000369e0: 6d65 5f66 6c61 6773 2e20 416c 736f 2068 me_flags. Also h │ │ │ -000369f0: 7474 7020 7365 6564 7320 616e 6420 7472 ttp seeds and tr │ │ │ -00036a00: 6163 6b65 7273 2066 6f72 2069 6e73 7461 ackers for insta │ │ │ -00036a10: 6e63 653c 2f74 643e 3c2f 7472 3e3c 7472 nce

    test all other │ │ │ -00036a70: 7265 7375 6d65 2066 6c61 6773 2068 6572 resume flags her │ │ │ -00036a80: 6520 746f 6f2e 2054 6869 7320 776f 756c e too. This woul │ │ │ -00036a90: 6420 7265 7175 6972 6520 7265 7475 726e d require return │ │ │ -00036aa0: 696e 670a 6d6f 7265 2074 6861 6e20 6a75 ing.more than ju │ │ │ -00036ab0: 7374 2074 6865 2074 6f72 7265 6e74 5f73 st the torrent_s │ │ │ -00036ac0: 7461 7475 7320 6672 6f6d 2074 6573 745f tatus from test_ │ │ │ -00036ad0: 7265 7375 6d65 5f66 6c61 6773 2e20 416c resume_flags. Al │ │ │ -00036ae0: 736f 2068 7474 7020 7365 6564 730a 616e so http seeds.an │ │ │ -00036af0: 6420 7472 6163 6b65 7273 2066 6f72 2069 d trackers for i │ │ │ -00036b00: 6e73 7461 6e63 653c 2f68 323e 3c68 343e nstance

    │ │ │ -00036b10: 2e2e 2f74 6573 742f 7465 7374 5f72 6573 ../test/test_res │ │ │ -00036b20: 756d 652e 6370 703a 3934 333c 2f68 343e ume.cpp:943

    │ │ │ -00036b30: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .TEST_
    │ │ │ -00036b70: 4551 5541 4c28 732e 636f 6e6e 6563 7469  EQUAL(s.connecti
    │ │ │ -00036b80: 6f6e 735f 6c69 6d69 742c 2031 3334 3529  ons_limit, 1345)
    │ │ │ -00036b90: 3b0a 0954 4553 545f 4551 5541 4c28 732e  ;..TEST_EQUAL(s.
    │ │ │ -00036ba0: 7570 6c6f 6164 735f 6c69 6d69 742c 2031  uploads_limit, 1
    │ │ │ -00036bb0: 3334 3629 3b0a 7d0a 0a54 4f52 5245 4e54  346);.}..TORRENT
    │ │ │ -00036bc0: 5f54 4553 5428 7061 7573 6564 5f64 6570  _TEST(paused_dep
    │ │ │ -00036bd0: 7265 6361 7465 6429 0a7b 0a09 6c74 3a3a  recated).{..lt::
    │ │ │ -00036be0: 7365 7373 696f 6e20 7365 7328 7365 7474  session ses(sett
    │ │ │ -00036bf0: 696e 6773 2829 293b 0a09 2f2f 2072 6573  ings());..// res
    │ │ │ -00036c00: 756d 6520 6461 7461 206f 7665 7272 6964  ume data overrid
    │ │ │ -00036c10: 6573 2074 6865 2070 6175 7365 6420 666c  es the paused fl
    │ │ │ -00036c20: 6167 0a09 6175 746f 2063 6f6e 7374 206e  ag..auto const n
    │ │ │ -00036c30: 6f77 203d 206c 743a 3a63 6c6f 636b 5f74  ow = lt::clock_t
    │ │ │ -00036c40: 7970 653a 3a6e 6f77 2829 3b0a 0974 6f72  ype::now();..tor
    │ │ │ -00036c50: 7265 6e74 5f73 7461 7475 7320 7320 3d20  rent_status s = 
    │ │ │ -00036c60: 7465 7374 5f72 6573 756d 655f 666c 6167  test_resume_flag
    │ │ │ -00036c70: 7328 7365 732c 2074 6f72 7265 6e74 5f66  s(ses, torrent_f
    │ │ │ -00036c80: 6c61 6773 3a3a 7061 7573 6564 2c20 2222  lags::paused, ""
    │ │ │ -00036c90: 2c20 2222 2c20 7472 7565 292e 7374 6174  , "", true).stat
    │ │ │ -00036ca0: 7573 2829 3b0a 0964 6566 6175 6c74 5f74  us();..default_t
    │ │ │ -00036cb0: 6573 7473 2873 2c20 6e6f 7729 3b0a 2369  ests(s, now);.#i
    │ │ │ -00036cc0: 6664 6566 2054 4f52 5245 4e54 5f57 494e  fdef TORRENT_WIN
    │ │ │ -00036cd0: 444f 5753 0a09 5445 5354 5f45 5155 414c  DOWS..TEST_EQUAL
    │ │ │ -00036ce0: 2873 2e73 6176 655f 7061 7468 2c20 2263  (s.save_path, "c
    │ │ │ -00036cf0: 3a5c 5c61 6464 5f74 6f72 7265 6e74 5f70  :\\add_torrent_p
    │ │ │ -00036d00: 6172 616d 7320 7361 7665 5f70 6174 6822  arams save_path"
    │ │ │ -00036d10: 293b 0a23 656c 7365 0a09 5445 5354 5f45  );.#else..TEST_E
    │ │ │ -00036d20: 5155 414c 2873 2e73 6176 655f 7061 7468  QUAL(s.save_path
    │ │ │ -00036d30: 2c20 222f 6164 645f 746f 7272 656e 745f  , "/add_torrent_
    │ │ │ -00036d40: 7061 7261 6d73 2073 6176 655f 7061 7468  params save_path
    │ │ │ -00036d50: 2229 3b0a 2365 6e64 6966 0a09 5445 5354  ");.#endif..TEST
    │ │ │ -00036d60: 5f45 5155 414c 2873 2e66 6c61 6773 2026  _EQUAL(s.flags &
    │ │ │ -00036d70: 616d 703b 2066 6c61 6773 5f6d 6173 6b2c  amp; flags_mask,
    │ │ │ -00036d80: 2074 6f72 7265 6e74 5f66 6c61 6773 5f74   torrent_flags_t
    │ │ │ -00036d90: 7b7d 293b 0a09 5445 5354 5f45 5155 414c  {});..TEST_EQUAL
    │ │ │ -00036da0: 2873 2e63 6f6e 6e65 6374 696f 6e73 5f6c  (s.connections_l
    │ │ │ -00036db0: 696d 6974 2c20 3133 3435 293b 0a09 5445  imit, 1345);..TE
    │ │ │ -00036dc0: 5354 5f45 5155 414c 2873 2e75 706c 6f61  ST_EQUAL(s.uploa
    │ │ │ -00036dd0: 6473 5f6c 696d 6974 2c20 3133 3436 293b  ds_limit, 1346);
    │ │ │ -00036de0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -00036e10: 7d0a 3c2f 6469 763e 0a54 4f52 5245 4e54 }.
    .TORRENT │ │ │ -00036e20: 5f54 4553 5428 7572 6c5f 7365 6564 5f72 _TEST(url_seed_r │ │ │ -00036e30: 6573 756d 655f 6461 7461 5f64 6570 7265 esume_data_depre │ │ │ -00036e40: 6361 7465 6429 0a7b 0a09 2f2f 206d 6572 cated).{..// mer │ │ │ -00036e50: 6765 2075 726c 2073 6565 6473 2077 6974 ge url seeds wit │ │ │ -00036e60: 6820 7265 7375 6d65 2064 6174 610a 0973 h resume data..s │ │ │ -00036e70: 7464 3a3a 7072 696e 7466 2822 666c 6167 td::printf("flag │ │ │ -00036e80: 733a 206d 6572 6765 5f72 6573 756d 655f s: merge_resume_ │ │ │ -00036e90: 6874 7470 5f73 6565 6473 5c6e 2229 3b0a http_seeds\n");. │ │ │ -00036ea0: 096c 743a 3a73 6573 7369 6f6e 2073 6573 .lt::session ses │ │ │ -00036eb0: 2873 6574 7469 6e67 7328 2929 3b0a 0974 (settings());..t │ │ │ -00036ec0: 6f72 7265 6e74 5f68 616e 646c 6520 6820 orrent_handle h │ │ │ -00036ed0: 3d20 7465 7374 5f72 6573 756d 655f 666c = test_resume_fl │ │ │ -00036ee0: 6167 7328 7365 732c 0a09 0974 6f72 7265 ags(ses,...torre │ │ │ -00036ef0: 6e74 5f66 6c61 6773 3a3a 6d65 7267 655f nt_flags::merge_ │ │ │ -00036f00: 7265 7375 6d65 5f68 7474 705f 7365 6564 resume_http_seed │ │ │ -00036f10: 732c 2022 222c 2022 222c 2074 7275 6529 s, "", "", true) │ │ │ -00036f20: 3b0a 0973 7464 3a3a 7365 7426 6c74 3b73 ;..std::set<s │ │ │ -00036f30: 7464 3a3a 7374 7269 6e67 2667 743b 2075 td::string> u │ │ │ -00036f40: 7320 3d20 682e 7572 6c5f 7365 6564 7328 s = h.url_seeds( │ │ │ -00036f50: 293b 0a09 7374 643a 3a73 6574 266c 743b );..std::set< │ │ │ -00036f60: 7374 643a 3a73 7472 696e 6726 6774 3b20 std::string> │ │ │ -00036f70: 7773 203d 2068 2e68 7474 705f 7365 6564 ws = h.http_seed │ │ │ -00036f80: 7328 293b 0a0a 0954 4553 545f 4551 5541 s();...TEST_EQUA │ │ │ -00036f90: 4c28 7573 2e73 697a 6528 292c 2033 293b L(us.size(), 3); │ │ │ -00036fa0: 0a09 5445 5354 5f45 5155 414c 2873 7464 ..TEST_EQUAL(std │ │ │ -00036fb0: 3a3a 636f 756e 7428 7573 2e62 6567 696e ::count(us.begin │ │ │ -00036fc0: 2829 2c20 7573 2e65 6e64 2829 0a09 092c (), us.end()..., │ │ │ -00036fd0: 2022 6874 7470 3a2f 2f61 6464 2d74 6f72 "http://add-tor │ │ │ -00036fe0: 7265 6e74 2d70 6172 616d 732d 7572 6c2d rent-params-url- │ │ │ -00036ff0: 7365 6564 2e63 6f6d 2f22 292c 2031 293b seed.com/"), 1); │ │ │ -00037000: 0a09 5445 5354 5f45 5155 414c 2873 7464 ..TEST_EQUAL(std │ │ │ -00037010: 3a3a 636f 756e 7428 7573 2e62 6567 696e ::count(us.begin │ │ │ -00037020: 2829 2c20 7573 2e65 6e64 2829 0a09 092c (), us.end()..., │ │ │ -00037030: 2022 6874 7470 3a2f 2f74 6f72 7265 6e74 "http://torrent │ │ │ -00037040: 2d66 696c 652d 7572 6c2d 7365 6564 2e63 -file-url-seed.c │ │ │ -00037050: 6f6d 2f22 292c 2031 293b 0a09 5445 5354 om/"), 1);..TEST │ │ │ -00037060: 5f45 5155 414c 2873 7464 3a3a 636f 756e _EQUAL(std::coun │ │ │ -00037070: 7428 7573 2e62 6567 696e 2829 2c20 7573 t(us.begin(), us │ │ │ -00037080: 2e65 6e64 2829 0a09 092c 2022 6874 7470 .end()..., "http │ │ │ -00037090: 3a2f 2f72 6573 756d 652d 6461 7461 2d75 ://resume-data-u │ │ │ -000370a0: 726c 2d73 6565 642e 636f 6d2f 2229 2c20 rl-seed.com/"), │ │ │ -000370b0: 3129 3b0a 0a09 5445 5354 5f45 5155 414c 1);...TEST_EQUAL │ │ │ -000370c0: 2877 732e 7369 7a65 2829 2c20 3129 3b0a (ws.size(), 1);. │ │ │ -000370d0: 0954 4553 545f 4551 5541 4c28 7374 643a .TEST_EQUAL(std: │ │ │ -000370e0: 3a63 6f75 6e74 2877 732e 6265 6769 6e28 :count(ws.begin( │ │ │ -000370f0: 292c 2077 732e 656e 6428 290a 0909 2c20 ), ws.end()..., │ │ │ -00037100: 2268 7474 703a 2f2f 7265 7375 6d65 2d64 "http://resume-d │ │ │ -00037110: 6174 612d 6874 7470 2d73 6565 642e 636f ata-http-seed.co │ │ │ -00037120: 6d22 292c 2031 293b 0a7d 0a0a 544f 5252 m"), 1);.}..TORR │ │ │ -00037130: 454e 545f 5445 5354 2872 6573 756d 655f ENT_TEST(resume_ │ │ │ -00037140: 6f76 6572 7269 6465 5f74 6f72 7265 6e74 override_torrent │ │ │ -00037150: 5f64 6570 7265 6361 7465 6429 0a7b 0a09 _deprecated).{.. │ │ │ -00037160: 2f2f 2072 6573 756d 6520 6461 7461 206f // resume data o │ │ │ -00037170: 7665 7272 6964 6573 2074 6865 202e 746f verrides the .to │ │ │ -00037180: 7272 656e 745f 6669 6c65 0a09 7374 643a rrent_file..std: │ │ │ -00037190: 3a70 7269 6e74 6628 2266 6c61 6773 3a20 :printf("flags: │ │ │ -000371a0: 6e6f 206d 6572 6765 5f72 6573 756d 655f no merge_resume_ │ │ │ -000371b0: 6874 7470 5f73 6565 645c 6e22 293b 0a09 http_seed\n");.. │ │ │ -000371c0: 6c74 3a3a 7365 7373 696f 6e20 7365 7328 lt::session ses( │ │ │ -000371d0: 7365 7474 696e 6773 2829 293b 0a09 746f settings());..to │ │ │ -000371e0: 7272 656e 745f 6861 6e64 6c65 2068 203d rrent_handle h = │ │ │ -000371f0: 2074 6573 745f 7265 7375 6d65 5f66 6c61 test_resume_fla │ │ │ -00037200: 6773 2873 6573 2c0a 3c2f 7072 653e 3c2f gs(ses,.
    relevan │ │ │ -00037240: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../test/test_ │ │ │ -00037280: 7265 7375 6d65 2e63 7070 3a31 3731 353c resume.cpp:1715< │ │ │ -00037290: 2f61 3e3c 2f74 643e 3c74 643e 7465 7374 /a>test │ │ │ -000372a0: 2061 6c6c 206f 7468 6572 2072 6573 756d all other resum │ │ │ -000372b0: 6520 666c 6167 7320 6865 7265 2074 6f6f e flags here too │ │ │ -000372c0: 2e20 5468 6973 2077 6f75 6c64 2072 6571 . This would req │ │ │ -000372d0: 7569 7265 2072 6574 7572 6e69 6e67 206d uire returning m │ │ │ -000372e0: 6f72 6520 7468 616e 206a 7573 7420 7468 ore than just th │ │ │ -000372f0: 6520 746f 7272 656e 745f 7374 6174 7573 e torrent_status │ │ │ -00037300: 2066 726f 6d20 7465 7374 5f72 6573 756d from test_resum │ │ │ -00037310: 655f 666c 6167 732e 2041 6c73 6f20 6874 e_flags. Also ht │ │ │ -00037320: 7470 2073 6565 6473 2061 6e64 2074 7261 tp seeds and tra │ │ │ -00037330: 636b 6572 7320 666f 7220 696e 7374 616e ckers for instan │ │ │ -00037340: 6365 3c2f 7464 3e3c 2f74 723e 3c74 7220 ce

    │ │ │ -00037390: 7465 7374 2061 6c6c 206f 7468 6572 2072 test all other r │ │ │ -000373a0: 6573 756d 6520 666c 6167 7320 6865 7265 esume flags here │ │ │ -000373b0: 2074 6f6f 2e20 5468 6973 2077 6f75 6c64 too. This would │ │ │ -000373c0: 2072 6571 7569 7265 2072 6574 7572 6e69 require returni │ │ │ -000373d0: 6e67 0a6d 6f72 6520 7468 616e 206a 7573 ng.more than jus │ │ │ -000373e0: 7420 7468 6520 746f 7272 656e 745f 7374 t the torrent_st │ │ │ -000373f0: 6174 7573 2066 726f 6d20 7465 7374 5f72 atus from test_r │ │ │ -00037400: 6573 756d 655f 666c 6167 732e 2041 6c73 esume_flags. Als │ │ │ -00037410: 6f20 6874 7470 2073 6565 6473 0a61 6e64 o http seeds.and │ │ │ -00037420: 2074 7261 636b 6572 7320 666f 7220 696e trackers for in │ │ │ -00037430: 7374 616e 6365 3c2f 6832 3e3c 6834 3e2e stance

    . │ │ │ -00037440: 2e2f 7465 7374 2f74 6573 745f 7265 7375 ./test/test_resu │ │ │ -00037450: 6d65 2e63 7070 3a31 3731 353c 2f68 343e me.cpp:1715

    │ │ │ -00037460: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .TEST_
    │ │ │ -000374a0: 4551 5541 4c28 732e 636f 6e6e 6563 7469  EQUAL(s.connecti
    │ │ │ -000374b0: 6f6e 735f 6c69 6d69 742c 2031 3334 3529  ons_limit, 1345)
    │ │ │ -000374c0: 3b0a 0954 4553 545f 4551 5541 4c28 732e  ;..TEST_EQUAL(s.
    │ │ │ -000374d0: 7570 6c6f 6164 735f 6c69 6d69 742c 2031  uploads_limit, 1
    │ │ │ -000374e0: 3334 3629 3b0a 7d0a 0a54 4f52 5245 4e54  346);.}..TORRENT
    │ │ │ -000374f0: 5f54 4553 5428 7061 7573 6564 290a 7b0a  _TEST(paused).{.
    │ │ │ -00037500: 096c 743a 3a73 6573 7369 6f6e 2073 6573  .lt::session ses
    │ │ │ -00037510: 2873 6574 7469 6e67 7328 2929 3b0a 092f  (settings());../
    │ │ │ -00037520: 2f20 7265 7375 6d65 2064 6174 6120 6f76  / resume data ov
    │ │ │ -00037530: 6572 7269 6465 7320 7468 6520 7061 7573  errides the paus
    │ │ │ -00037540: 6564 2066 6c61 670a 0961 7574 6f20 636f  ed flag..auto co
    │ │ │ -00037550: 6e73 7420 6e6f 7720 3d20 6c74 3a3a 636c  nst now = lt::cl
    │ │ │ -00037560: 6f63 6b5f 7479 7065 3a3a 6e6f 7728 293b  ock_type::now();
    │ │ │ -00037570: 0a09 746f 7272 656e 745f 7374 6174 7573  ..torrent_status
    │ │ │ -00037580: 2073 203d 2074 6573 745f 7265 7375 6d65   s = test_resume
    │ │ │ -00037590: 5f66 6c61 6773 2873 6573 2c20 746f 7272  _flags(ses, torr
    │ │ │ -000375a0: 656e 745f 666c 6167 733a 3a70 6175 7365  ent_flags::pause
    │ │ │ -000375b0: 6429 2e73 7461 7475 7328 293b 0a09 6465  d).status();..de
    │ │ │ -000375c0: 6661 756c 745f 7465 7374 7328 732c 206e  fault_tests(s, n
    │ │ │ -000375d0: 6f77 293b 0a23 6966 6465 6620 544f 5252  ow);.#ifdef TORR
    │ │ │ -000375e0: 454e 545f 5749 4e44 4f57 530a 0954 4553  ENT_WINDOWS..TES
    │ │ │ -000375f0: 545f 4551 5541 4c28 732e 7361 7665 5f70  T_EQUAL(s.save_p
    │ │ │ -00037600: 6174 682c 2022 633a 5c5c 6164 645f 746f  ath, "c:\\add_to
    │ │ │ -00037610: 7272 656e 745f 7061 7261 6d73 2073 6176  rrent_params sav
    │ │ │ -00037620: 655f 7061 7468 2229 3b0a 2365 6c73 650a  e_path");.#else.
    │ │ │ -00037630: 0954 4553 545f 4551 5541 4c28 732e 7361  .TEST_EQUAL(s.sa
    │ │ │ -00037640: 7665 5f70 6174 682c 2022 2f61 6464 5f74  ve_path, "/add_t
    │ │ │ -00037650: 6f72 7265 6e74 5f70 6172 616d 7320 7361  orrent_params sa
    │ │ │ -00037660: 7665 5f70 6174 6822 293b 0a23 656e 6469  ve_path");.#endi
    │ │ │ -00037670: 660a 0954 4553 545f 4551 5541 4c28 732e  f..TEST_EQUAL(s.
    │ │ │ -00037680: 666c 6167 7320 2661 6d70 3b20 666c 6167  flags & flag
    │ │ │ -00037690: 735f 6d61 736b 2c20 746f 7272 656e 745f  s_mask, torrent_
    │ │ │ -000376a0: 666c 6167 733a 3a70 6175 7365 6429 3b0a  flags::paused);.
    │ │ │ -000376b0: 0954 4553 545f 4551 5541 4c28 732e 636f  .TEST_EQUAL(s.co
    │ │ │ -000376c0: 6e6e 6563 7469 6f6e 735f 6c69 6d69 742c  nnections_limit,
    │ │ │ -000376d0: 2031 3334 3529 3b0a 0954 4553 545f 4551   1345);..TEST_EQ
    │ │ │ -000376e0: 5541 4c28 732e 7570 6c6f 6164 735f 6c69  UAL(s.uploads_li
    │ │ │ -000376f0: 6d69 742c 2031 3334 3629 3b0a 0a3c 6469  mit, 1346);..}..TORRENT_TEST
    │ │ │ -00037740: 286e 6f5f 6d65 7461 6461 7461 290a 7b0a  (no_metadata).{.
    │ │ │ -00037750: 096c 743a 3a73 6573 7369 6f6e 2073 6573  .lt::session ses
    │ │ │ -00037760: 2873 6574 7469 6e67 7328 2929 3b0a 0a09  (settings());...
    │ │ │ -00037770: 6164 645f 746f 7272 656e 745f 7061 7261  add_torrent_para
    │ │ │ -00037780: 6d73 2070 3b0a 0970 2e69 6e66 6f5f 6861  ms p;..p.info_ha
    │ │ │ -00037790: 7368 6573 2e76 3120 3d20 7368 6131 5f68  shes.v1 = sha1_h
    │ │ │ -000377a0: 6173 6828 2261 6261 6261 6261 6261 6261  ash("abababababa
    │ │ │ -000377b0: 6261 6261 6261 6261 6222 293b 0a09 702e  babababab");..p.
    │ │ │ -000377c0: 7361 7665 5f70 6174 6820 3d20 222e 223b  save_path = ".";
    │ │ │ -000377d0: 0a09 702e 6e61 6d65 203d 2022 666f 6f62  ..p.name = "foob
    │ │ │ -000377e0: 6172 223b 0a09 746f 7272 656e 745f 6861  ar";..torrent_ha
    │ │ │ -000377f0: 6e64 6c65 2068 203d 2073 6573 2e61 6464  ndle h = ses.add
    │ │ │ -00037800: 5f74 6f72 7265 6e74 2870 293b 0a09 682e  _torrent(p);..h.
    │ │ │ -00037810: 7361 7665 5f72 6573 756d 655f 6461 7461  save_resume_data
    │ │ │ -00037820: 2874 6f72 7265 6e74 5f68 616e 646c 653a  (torrent_handle:
    │ │ │ -00037830: 3a73 6176 655f 696e 666f 5f64 6963 7429  :save_info_dict)
    │ │ │ -00037840: 3b0a 0961 6c65 7274 2063 6f6e 7374 2a20  ;..alert const* 
    │ │ │ -00037850: 6120 3d20 7761 6974 5f66 6f72 5f61 6c65  a = wait_for_ale
    │ │ │ -00037860: 7274 2873 6573 2c20 7361 7665 5f72 6573  rt(ses, save_res
    │ │ │ -00037870: 756d 655f 6461 7461 5f61 6c65 7274 3a3a  ume_data_alert::
    │ │ │ -00037880: 616c 6572 745f 7479 7065 293b 0a09 5445  alert_type);..TE
    │ │ │ -00037890: 5354 5f43 4845 434b 2861 293b 0a09 7361  ST_CHECK(a);..sa
    │ │ │ -000378a0: 7665 5f72 6573 756d 655f 6461 7461 5f61  ve_resume_data_a
    │ │ │ -000378b0: 6c65 7274 2063 6f6e 7374 2a20 7261 203d  lert const* ra =
    │ │ │ -000378c0: 2061 6c65 7274 5f63 6173 7426 6c74 3b73   alert_cast<s
    │ │ │ -000378d0: 6176 655f 7265 7375 6d65 5f64 6174 615f  ave_resume_data_
    │ │ │ -000378e0: 616c 6572 7426 6774 3b28 6129 3b0a 0954  alert>(a);..T
    │ │ │ -000378f0: 4553 545f 4348 4543 4b28 7261 293b 0a09  EST_CHECK(ra);..
    │ │ │ -00037900: 6966 2028 7261 290a 097b 0a09 0961 7574  if (ra)..{...aut
    │ │ │ -00037910: 6f20 636f 6e73 7426 616d 703b 2061 7470  o const& atp
    │ │ │ -00037920: 203d 2072 612d 2667 743b 7061 7261 6d73   = ra->params
    │ │ │ -00037930: 3b0a 0909 5445 5354 5f45 5155 414c 2861  ;...TEST_EQUAL(a
    │ │ │ -00037940: 7470 2e69 6e66 6f5f 6861 7368 6573 2c20  tp.info_hashes, 
    │ │ │ -00037950: 702e 696e 666f 5f68 6173 6865 7329 3b0a  p.info_hashes);.
    │ │ │ -00037960: 0909 5445 5354 5f45 5155 414c 2861 7470  ..TEST_EQUAL(atp
    │ │ │ -00037970: 2e6e 616d 652c 2022 666f 6f62 6172 2229  .name, "foobar")
    │ │ │ -00037980: 3b0a 097d 0a7d 0a0a 7465 6d70 6c61 7465  ;..}.}..template
    │ │ │ -00037990: 2026 6c74 3b74 7970 656e 616d 6520 4675   <typename Fu
    │ │ │ -000379a0: 6e26 6774 3b0a 766f 6964 2074 6573 745f  n>.void test_
    │ │ │ -000379b0: 756e 6669 6e69 7368 6564 5f70 6965 6365  unfinished_piece
    │ │ │ -000379c0: 7328 4675 6e20 6629 0a7b 0a09 2f2f 2063  s(Fun f).{..// c
    │ │ │ -000379d0: 7265 6174 6520 6120 746f 7272 656e 7420  reate a torrent 
    │ │ │ -000379e0: 616e 6420 636f 6d70 6c65 7465 2066 696c  and complete fil
    │ │ │ -000379f0: 6573 0a09 7374 643a 3a73 6861 7265 645f  es..std::shared_
    │ │ │ -00037a00: 7074 7226 6c74 3b74 6f72 7265 6e74 5f69  ptr<torrent_i
    │ │ │ -00037a10: 6e66 6f26 6774 3b20 7469 203d 2067 656e  nfo> ti = gen
    │ │ │ -00037a20: 6572 6174 655f 746f 7272 656e 7428 7472  erate_torrent(tr
    │ │ │ -00037a30: 7565 2c20 7472 7565 293b 0a0a 0961 6464  ue, true);...add
    │ │ │ -00037a40: 5f74 6f72 7265 6e74 5f70 6172 616d 7320  _torrent_params 
    │ │ │ -00037a50: 703b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f  p;.
    │ │ │ -00037a80: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -00037a90: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0
    .. │ │ │ -00037ac0: 2f74 6573 742f 7465 7374 5f72 6573 6f6c /test/test_resol │ │ │ -00037ad0: 7665 5f6c 696e 6b73 2e63 7070 3a39 353c ve_links.cpp:95< │ │ │ -00037ae0: 2f61 3e3c 2f74 643e 3c74 643e 7465 7374 /a>test │ │ │ -00037af0: 2066 696c 6573 2077 6974 6820 6469 6666 files with diff │ │ │ -00037b00: 6572 656e 7420 7069 6563 6520 7369 7a65 erent piece size │ │ │ -00037b10: 2028 6e65 6761 7469 7665 2074 6573 7429 (negative test) │ │ │ -00037b20: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    te │ │ │ -00037b70: 7374 2066 696c 6573 2077 6974 6820 6469 st files with di │ │ │ -00037b80: 6666 6572 656e 7420 7069 6563 6520 7369 fferent piece si │ │ │ -00037b90: 7a65 2028 6e65 6761 7469 7665 2074 6573 ze (negative tes │ │ │ -00037ba0: 7429 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 t)

    ../te │ │ │ -00037bb0: 7374 2f74 6573 745f 7265 736f 6c76 655f st/test_resolve_ │ │ │ -00037bc0: 6c69 6e6b 732e 6370 703a 3935 3c2f 6834 links.cpp:95

    .{ "t
    │ │ │ -00037c10: 6573 7432 222c 2022 7465 7374 315f 7061  est2", "test1_pa
    │ │ │ -00037c20: 645f 6669 6c65 7322 2c20 307d 2c0a 097b  d_files", 0},..{
    │ │ │ -00037c30: 2022 7465 7374 3322 2c20 2274 6573 7431   "test3", "test1
    │ │ │ -00037c40: 5f70 6164 5f66 696c 6573 222c 2030 7d2c  _pad_files", 0},
    │ │ │ -00037c50: 0a09 7b20 2274 6573 7432 222c 2022 7465  ..{ "test2", "te
    │ │ │ -00037c60: 7374 315f 7369 6e67 6c65 222c 2030 7d2c  st1_single", 0},
    │ │ │ -00037c70: 0a0a 092f 2f20 7468 6573 6520 6172 6520  ...// these are 
    │ │ │ -00037c80: 616c 6c20 7061 6464 6564 2e20 5468 6520  all padded. The 
    │ │ │ -00037c90: 6669 7273 7420 736d 616c 6c20 6669 6c65  first small file
    │ │ │ -00037ca0: 2077 696c 6c20 6163 6369 6465 6e74 616c   will accidental
    │ │ │ -00037cb0: 6c79 2061 6c73 6f0a 092f 2f20 6d61 7463  ly also..// matc
    │ │ │ -00037cc0: 682c 2065 7665 6e20 7468 6f75 6768 2069  h, even though i
    │ │ │ -00037cd0: 7427 7320 6e6f 7420 7461 696c 2070 6164  t's not tail pad
    │ │ │ -00037ce0: 6465 642c 2074 6865 2066 6f6c 6c6f 7769  ded, the followi
    │ │ │ -00037cf0: 6e67 2066 696c 6520 6973 2069 6465 6e74  ng file is ident
    │ │ │ -00037d00: 6963 616c 0a09 7b20 2274 6573 7432 5f70  ical..{ "test2_p
    │ │ │ -00037d10: 6164 5f66 696c 6573 222c 2022 7465 7374  ad_files", "test
    │ │ │ -00037d20: 315f 7061 645f 6669 6c65 7322 2c20 327d  1_pad_files", 2}
    │ │ │ -00037d30: 2c0a 097b 2022 7465 7374 335f 7061 645f  ,..{ "test3_pad_
    │ │ │ -00037d40: 6669 6c65 7322 2c20 2274 6573 7431 5f70  files", "test1_p
    │ │ │ -00037d50: 6164 5f66 696c 6573 222c 2032 7d2c 0a09  ad_files", 2},..
    │ │ │ -00037d60: 7b20 2274 6573 7433 5f70 6164 5f66 696c  { "test3_pad_fil
    │ │ │ -00037d70: 6573 222c 2022 7465 7374 325f 7061 645f  es", "test2_pad_
    │ │ │ -00037d80: 6669 6c65 7322 2c20 327d 2c0a 097b 2022  files", 2},..{ "
    │ │ │ -00037d90: 7465 7374 315f 7061 645f 6669 6c65 7322  test1_pad_files"
    │ │ │ -00037da0: 2c20 2274 6573 7432 5f70 6164 5f66 696c  , "test2_pad_fil
    │ │ │ -00037db0: 6573 222c 2032 7d2c 0a09 7b20 2274 6573  es", 2},..{ "tes
    │ │ │ -00037dc0: 7431 5f70 6164 5f66 696c 6573 222c 2022  t1_pad_files", "
    │ │ │ -00037dd0: 7465 7374 335f 7061 645f 6669 6c65 7322  test3_pad_files"
    │ │ │ -00037de0: 2c20 327d 2c0a 097b 2022 7465 7374 325f  , 2},..{ "test2_
    │ │ │ -00037df0: 7061 645f 6669 6c65 7322 2c20 2274 6573  pad_files", "tes
    │ │ │ -00037e00: 7433 5f70 6164 5f66 696c 6573 222c 2032  t3_pad_files", 2
    │ │ │ -00037e10: 7d2c 0a0a 092f 2f20 6f6e 6520 6d69 6768  },...// one migh
    │ │ │ -00037e20: 7420 6578 7065 6374 2074 6869 7320 746f  t expect this to
    │ │ │ -00037e30: 2077 6f72 6b2c 2062 7574 2073 696e 6365   work, but since
    │ │ │ -00037e40: 2074 6865 2074 6169 6c20 6f66 2074 6865   the tail of the
    │ │ │ -00037e50: 2073 696e 676c 6520 6669 6c65 0a09 2f2f   single file..//
    │ │ │ -00037e60: 2074 6f72 7265 6e74 2069 7320 6e6f 7420   torrent is not 
    │ │ │ -00037e70: 7061 6464 6564 2c20 7468 6520 6c61 7374  padded, the last
    │ │ │ -00037e80: 2070 6965 6365 2068 6173 6820 776f 6e27   piece hash won'
    │ │ │ -00037e90: 7420 6d61 7463 680a 097b 2022 7465 7374  t match..{ "test
    │ │ │ -00037ea0: 315f 7061 645f 6669 6c65 7322 2c20 2274  1_pad_files", "t
    │ │ │ -00037eb0: 6573 7431 5f73 696e 676c 6522 2c20 307d  est1_single", 0}
    │ │ │ -00037ec0: 2c0a 0a09 2f2f 2069 6620 6974 2773 2070  ,...// if it's p
    │ │ │ -00037ed0: 6164 6465 6420 6f6e 2074 6865 206f 7468  added on the oth
    │ │ │ -00037ee0: 6572 2068 616e 642c 2069 7420 7769 6c6c  er hand, it will
    │ │ │ -00037ef0: 2077 6f72 6b0a 097b 2022 7465 7374 315f   work..{ "test1_
    │ │ │ -00037f00: 7061 645f 6669 6c65 7322 2c20 2274 6573  pad_files", "tes
    │ │ │ -00037f10: 7431 5f73 696e 676c 655f 7061 6464 6564  t1_single_padded
    │ │ │ -00037f20: 222c 2031 7d2c 0a0a 3c64 6976 2073 7479  ", 1},..
    };.
    . │ │ │ -00037f60: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00037f70: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00037fa0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0
    ../te │ │ │ -00037fd0: 7374 2f74 6573 745f 7265 736f 6c76 655f st/test_resolve_ │ │ │ -00037fe0: 6c69 6e6b 732e 6370 703a 3938 3c2f 613e links.cpp:98 │ │ │ -00037ff0: 3c2f 7464 3e3c 7464 3e69 7420 776f 756c it woul │ │ │ -00038000: 6420 6265 206e 6963 6520 746f 2074 6573 d be nice to tes │ │ │ -00038010: 7420 7265 736f 6c76 696e 6720 6f66 206d t resolving of m │ │ │ -00038020: 6f72 6520 7468 616e 206a 7573 7420 3220 ore than just 2 │ │ │ -00038030: 6669 6c65 7320 6173 2077 656c 6c2e 206c files as well. l │ │ │ -00038040: 696b 6520 3320 7369 6e67 6c65 2066 696c ike 3 single fil │ │ │ -00038050: 6520 746f 7272 656e 7473 206d 6572 6765 e torrents merge │ │ │ -00038060: 6420 696e 746f 206f 6e65 2c20 7265 736f d into one, reso │ │ │ -00038070: 6c76 696e 6720 616c 6c20 3320 6669 6c65 lving all 3 file │ │ │ -00038080: 732e 3c2f 7464 3e3c 2f74 723e 3c74 7220 s.

    │ │ │ -000380d0: 6974 2077 6f75 6c64 2062 6520 6e69 6365 it would be nice │ │ │ -000380e0: 2074 6f20 7465 7374 2072 6573 6f6c 7669 to test resolvi │ │ │ -000380f0: 6e67 206f 6620 6d6f 7265 2074 6861 6e20 ng of more than │ │ │ -00038100: 6a75 7374 2032 2066 696c 6573 2061 7320 just 2 files as │ │ │ -00038110: 7765 6c6c 2e0a 6c69 6b65 2033 2073 696e well..like 3 sin │ │ │ -00038120: 676c 6520 6669 6c65 2074 6f72 7265 6e74 gle file torrent │ │ │ -00038130: 7320 6d65 7267 6564 2069 6e74 6f20 6f6e s merged into on │ │ │ -00038140: 652c 2072 6573 6f6c 7669 6e67 2061 6c6c e, resolving all │ │ │ -00038150: 2033 2066 696c 6573 2e3c 2f68 323e 3c68 3 files.

    ../test/test_r │ │ │ -00038170: 6573 6f6c 7665 5f6c 696e 6b73 2e63 7070 esolve_links.cpp │ │ │ -00038180: 3a39 383c 2f68 343e 3c70 7265 2073 7479 :98
    .{ "test2", "t
    │ │ │ -000381d0: 6573 7431 5f73 696e 676c 6522 2c20 307d  est1_single", 0}
    │ │ │ -000381e0: 2c0a 0a09 2f2f 2074 6865 7365 2061 7265  ,...// these are
    │ │ │ -000381f0: 2061 6c6c 2070 6164 6465 642e 2054 6865   all padded. The
    │ │ │ -00038200: 2066 6972 7374 2073 6d61 6c6c 2066 696c   first small fil
    │ │ │ -00038210: 6520 7769 6c6c 2061 6363 6964 656e 7461  e will accidenta
    │ │ │ -00038220: 6c6c 7920 616c 736f 0a09 2f2f 206d 6174  lly also..// mat
    │ │ │ -00038230: 6368 2c20 6576 656e 2074 686f 7567 6820  ch, even though 
    │ │ │ -00038240: 6974 2773 206e 6f74 2074 6169 6c20 7061  it's not tail pa
    │ │ │ -00038250: 6464 6564 2c20 7468 6520 666f 6c6c 6f77  dded, the follow
    │ │ │ -00038260: 696e 6720 6669 6c65 2069 7320 6964 656e  ing file is iden
    │ │ │ -00038270: 7469 6361 6c0a 097b 2022 7465 7374 325f  tical..{ "test2_
    │ │ │ -00038280: 7061 645f 6669 6c65 7322 2c20 2274 6573  pad_files", "tes
    │ │ │ -00038290: 7431 5f70 6164 5f66 696c 6573 222c 2032  t1_pad_files", 2
    │ │ │ -000382a0: 7d2c 0a09 7b20 2274 6573 7433 5f70 6164  },..{ "test3_pad
    │ │ │ -000382b0: 5f66 696c 6573 222c 2022 7465 7374 315f  _files", "test1_
    │ │ │ -000382c0: 7061 645f 6669 6c65 7322 2c20 327d 2c0a  pad_files", 2},.
    │ │ │ -000382d0: 097b 2022 7465 7374 335f 7061 645f 6669  .{ "test3_pad_fi
    │ │ │ -000382e0: 6c65 7322 2c20 2274 6573 7432 5f70 6164  les", "test2_pad
    │ │ │ -000382f0: 5f66 696c 6573 222c 2032 7d2c 0a09 7b20  _files", 2},..{ 
    │ │ │ -00038300: 2274 6573 7431 5f70 6164 5f66 696c 6573  "test1_pad_files
    │ │ │ -00038310: 222c 2022 7465 7374 325f 7061 645f 6669  ", "test2_pad_fi
    │ │ │ -00038320: 6c65 7322 2c20 327d 2c0a 097b 2022 7465  les", 2},..{ "te
    │ │ │ -00038330: 7374 315f 7061 645f 6669 6c65 7322 2c20  st1_pad_files", 
    │ │ │ -00038340: 2274 6573 7433 5f70 6164 5f66 696c 6573  "test3_pad_files
    │ │ │ -00038350: 222c 2032 7d2c 0a09 7b20 2274 6573 7432  ", 2},..{ "test2
    │ │ │ -00038360: 5f70 6164 5f66 696c 6573 222c 2022 7465  _pad_files", "te
    │ │ │ -00038370: 7374 335f 7061 645f 6669 6c65 7322 2c20  st3_pad_files", 
    │ │ │ -00038380: 327d 2c0a 0a09 2f2f 206f 6e65 206d 6967  2},...// one mig
    │ │ │ -00038390: 6874 2065 7870 6563 7420 7468 6973 2074  ht expect this t
    │ │ │ -000383a0: 6f20 776f 726b 2c20 6275 7420 7369 6e63  o work, but sinc
    │ │ │ -000383b0: 6520 7468 6520 7461 696c 206f 6620 7468  e the tail of th
    │ │ │ -000383c0: 6520 7369 6e67 6c65 2066 696c 650a 092f  e single file../
    │ │ │ -000383d0: 2f20 746f 7272 656e 7420 6973 206e 6f74  / torrent is not
    │ │ │ -000383e0: 2070 6164 6465 642c 2074 6865 206c 6173   padded, the las
    │ │ │ -000383f0: 7420 7069 6563 6520 6861 7368 2077 6f6e  t piece hash won
    │ │ │ -00038400: 2774 206d 6174 6368 0a09 7b20 2274 6573  't match..{ "tes
    │ │ │ -00038410: 7431 5f70 6164 5f66 696c 6573 222c 2022  t1_pad_files", "
    │ │ │ -00038420: 7465 7374 315f 7369 6e67 6c65 222c 2030  test1_single", 0
    │ │ │ -00038430: 7d2c 0a0a 092f 2f20 6966 2069 7427 7320  },...// if it's 
    │ │ │ -00038440: 7061 6464 6564 206f 6e20 7468 6520 6f74  padded on the ot
    │ │ │ -00038450: 6865 7220 6861 6e64 2c20 6974 2077 696c  her hand, it wil
    │ │ │ -00038460: 6c20 776f 726b 0a09 7b20 2274 6573 7431  l work..{ "test1
    │ │ │ -00038470: 5f70 6164 5f66 696c 6573 222c 2022 7465  _pad_files", "te
    │ │ │ -00038480: 7374 315f 7369 6e67 6c65 5f70 6164 6465  st1_single_padde
    │ │ │ -00038490: 6422 2c20 317d 2c0a 0a7d 3b0a 0a3c 6469  d", 1},..};...TORRENT_TEST(r
    │ │ │ -000384e0: 6573 6f6c 7665 5f6c 696e 6b73 290a 7b0a  esolve_links).{.
    │ │ │ -000384f0: 0973 7464 3a3a 7374 7269 6e67 2070 6174  .std::string pat
    │ │ │ -00038500: 6820 3d20 636f 6d62 696e 655f 7061 7468  h = combine_path
    │ │ │ -00038510: 2870 6172 656e 745f 7061 7468 2863 7572  (parent_path(cur
    │ │ │ -00038520: 7265 6e74 5f77 6f72 6b69 6e67 5f64 6972  rent_working_dir
    │ │ │ -00038530: 6563 746f 7279 2829 290a 0909 2c20 226d  ectory())..., "m
    │ │ │ -00038540: 7574 6162 6c65 5f74 6573 745f 746f 7272  utable_test_torr
    │ │ │ -00038550: 656e 7473 2229 3b0a 0a09 666f 7220 2869  ents");...for (i
    │ │ │ -00038560: 6e74 2069 203d 2030 3b20 6920 266c 743b  nt i = 0; i <
    │ │ │ -00038570: 2069 6e74 2873 697a 656f 6628 7465 7374   int(sizeof(test
    │ │ │ -00038580: 5f74 6f72 7265 6e74 7329 2f73 697a 656f  _torrents)/sizeo
    │ │ │ -00038590: 6628 7465 7374 5f74 6f72 7265 6e74 735b  f(test_torrents[
    │ │ │ -000385a0: 305d 2929 3b20 2b2b 6929 0a09 7b0a 0909  0])); ++i)..{...
    │ │ │ -000385b0: 7465 7374 5f74 6f72 7265 6e74 5f74 2063  test_torrent_t c
    │ │ │ -000385c0: 6f6e 7374 2661 6d70 3b20 6520 3d20 7465  onst& e = te
    │ │ │ -000385d0: 7374 5f74 6f72 7265 6e74 735b 695d 3b0a  st_torrents[i];.
    │ │ │ -000385e0: 0a09 0973 7464 3a3a 7374 7269 6e67 2070  ...std::string p
    │ │ │ -000385f0: 203d 2063 6f6d 6269 6e65 5f70 6174 6828   = combine_path(
    │ │ │ -00038600: 7061 7468 2c20 652e 6669 6c65 6e61 6d65  path, e.filename
    │ │ │ -00038610: 3129 202b 2022 2e74 6f72 7265 6e74 223b  1) + ".torrent";
    │ │ │ -00038620: 0a09 0973 7464 3a3a 7072 696e 7466 2822  ...std::printf("
    │ │ │ -00038630: 6c6f 6164 696e 6720 2573 5c6e 222c 2070  loading %s\n", p
    │ │ │ -00038640: 2e63 5f73 7472 2829 293b 0a09 0973 7464  .c_str());...std
    │ │ │ -00038650: 3a3a 7368 6172 6564 5f70 7472 266c 743b  ::shared_ptr<
    │ │ │ -00038660: 746f 7272 656e 745f 696e 666f 2667 743b  torrent_info>
    │ │ │ -00038670: 2074 6931 203d 2073 7464 3a3a 6d61 6b65   ti1 = std::make
    │ │ │ -00038680: 5f73 6861 7265 6426 6c74 3b74 6f72 7265  _shared<torre
    │ │ │ -00038690: 6e74 5f69 6e66 6f26 6774 3b28 7029 3b0a  nt_info>(p);.
    │ │ │ -000386a0: 0a09 0970 203d 2063 6f6d 6269 6e65 5f70  ...p = combine_p
    │ │ │ -000386b0: 6174 6828 7061 7468 2c20 652e 6669 6c65  ath(path, e.file
    │ │ │ -000386c0: 6e61 6d65 3229 202b 2022 2e74 6f72 7265  name2) + ".torre
    │ │ │ -000386d0: 6e74 223b 0a09 0973 7464 3a3a 7072 696e  nt";...std::prin
    │ │ │ -000386e0: 7466 2822 6c6f 6164 696e 6720 2573 5c6e  tf("loading %s\n
    │ │ │ -000386f0: 222c 2070 2e63 5f73 7472 2829 293b 0a09  ", p.c_str());..
    │ │ │ -00038700: 0973 7464 3a3a 7368 6172 6564 5f70 7472  .std::shared_ptr
    │ │ │ -00038710: 266c 743b 746f 7272 656e 745f 696e 666f  <torrent_info
    │ │ │ -00038720: 2667 743b 2074 6932 203d 2073 7464 3a3a  > ti2 = std::
    │ │ │ -00038730: 6d61 6b65 5f73 6861 7265 6426 6c74 3b74  make_shared<t
    │ │ │ -00038740: 6f72 7265 6e74 5f69 6e66 6f26 6774 3b28  orrent_info>(
    │ │ │ -00038750: 7029 3b0a 0a09 0973 7464 3a3a 7072 696e  p);....std::prin
    │ │ │ -00038760: 7466 2822 7265 736f 6c76 696e 675c 6e22  tf("resolving\n"
    │ │ │ -00038770: 293b 0a09 0972 6573 6f6c 7665 5f6c 696e  );...resolve_lin
    │ │ │ -00038780: 6b73 206c 2874 6931 293b 0a09 096c 2e6d  ks l(ti1);...l.m
    │ │ │ -00038790: 6174 6368 2874 6932 2c20 222e 2229 3b0a  atch(ti2, ".");.
    │ │ │ -000387a0: 0a09 0961 7578 3a3a 7665 6374 6f72 266c  ...aux::vector&l
    │ │ │ -000387b0: 743b 7265 736f 6c76 655f 6c69 6e6b 733a  t;resolve_links:
    │ │ │ -000387c0: 3a6c 696e 6b5f 742c 2066 696c 655f 696e  :link_t, file_in
    │ │ │ -000387d0: 6465 785f 7426 6774 3b20 636f 6e73 7426  dex_t> const&
    │ │ │ -000387e0: 616d 703b 206c 696e 6b73 203d 206c 2e67  amp; links = l.g
    │ │ │ -000387f0: 6574 5f6c 696e 6b73 2829 3b0a 0a09 0961  et_links();....a
    │ │ │ -00038800: 7574 6f20 636f 6e73 7420 6e75 6d5f 6d61  uto const num_ma
    │ │ │ -00038810: 7463 6865 7320 3d20 7374 643a 3a73 697a  tches = std::siz
    │ │ │ -00038820: 655f 7428 7374 643a 3a63 6f75 6e74 5f69  e_t(std::count_i
    │ │ │ -00038830: 6628 6c69 6e6b 732e 6265 6769 6e28 292c  f(links.begin(),
    │ │ │ -00038840: 206c 696e 6b73 2e65 6e64 2829 0a09 0909   links.end()....
    │ │ │ -00038850: 2c20 7374 643a 3a62 696e 6428 2661 6d70  , std::bind(&
    │ │ │ -00038860: 3b72 6573 6f6c 7665 5f6c 696e 6b73 3a3a  ;resolve_links::
    │ │ │ -00038870: 6c69 6e6b 5f74 3a3a 7469 2c20 5f31 2929  link_t::ti, _1))
    │ │ │ -00038880: 293b 0a0a 0909 2f2f 2073 6f6d 6520 6465  );....// some de
    │ │ │ -00038890: 6275 6720 6f75 7470 7574 2069 6e20 6361  bug output in ca
    │ │ │ -000388a0: 7365 2074 6865 2074 6573 7420 6661 696c  se the test fail
    │ │ │ -000388b0: 730a 0909 6966 2028 6e75 6d5f 6d61 7463  s...if (num_matc
    │ │ │ -000388c0: 6865 7320 2667 743b 2065 2e65 7870 6563  hes > e.expec
    │ │ │ -000388d0: 7465 645f 6d61 7463 6865 7329 0a09 097b  ted_matches)...{
    │ │ │ -000388e0: 0a09 0909 6669 6c65 5f73 746f 7261 6765  ....file_storage
    │ │ │ -000388f0: 2063 6f6e 7374 2661 6d70 3b20 6673 203d   const& fs =
    │ │ │ -00038900: 2074 6931 2d26 6774 3b66 696c 6573 2829   ti1->files()
    │ │ │ -00038910: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74  ;.
    < │ │ │ -00038940: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00038950: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00038980: 7465 7374 2f74 6573 745f 7065 6572 5f6c test/test_peer_l │ │ │ -00038990: 6973 742e 6370 703a 3132 3931 3c2f 613e ist.cpp:1291 │ │ │ -000389a0: 3c2f 7464 3e3c 7464 3e74 6573 7420 6572 test er │ │ │ -000389b0: 6173 696e 6720 7065 6572 733c 2f74 643e asing peers │ │ │ -000389c0: 3c2f 7472 3e3c 7472 2069 643d 2231 3239

    test er │ │ │ -00038a10: 6173 696e 6720 7065 6572 733c 2f68 323e asing peers

    │ │ │ -00038a20: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ -00038a30: 5f70 6565 725f 6c69 7374 2e63 7070 3a31 _peer_list.cpp:1 │ │ │ -00038a40: 3239 313c 2f68 343e 3c70 7265 2073 7479 291

    <
    │ │ │ -00038ab0: 7464 3e72 656c 6576 616e 6365 266e 6273  td>relevance&nbs
    │ │ │ -00038ac0: 703b 303c 2f74 643e 3c74 643e 3c61 2068  p;0../
    │ │ │ -00038af0: 7465 7374 2f74 6573 745f 7065 6572 5f6c  test/test_peer_l
    │ │ │ -00038b00: 6973 742e 6370 703a 3132 3932 3c2f 613e  ist.cpp:1292
    │ │ │ -00038b10: 3c2f 7464 3e3c 7464 3e74 6573 7420 7570  test up
    │ │ │ -00038b20: 6461 7465 5f70 6565 725f 706f 7274 2077  date_peer_port w
    │ │ │ -00038b30: 6974 6820 616c 6c6f 775f 6d75 6c74 6970  ith allow_multip
    │ │ │ -00038b40: 6c65 5f63 6f6e 6e65 6374 696f 6e73 5f70  le_connections_p
    │ │ │ -00038b50: 6572 5f69 7020 616e 6420 7769 7468 6f75  er_ip and withou
    │ │ │ -00038b60: 743c 2f74 643e 3c2f 7472 3e3c 7472 2069  t

    t │ │ │ -00038bb0: 6573 7420 7570 6461 7465 5f70 6565 725f est update_peer_ │ │ │ -00038bc0: 706f 7274 2077 6974 6820 616c 6c6f 775f port with allow_ │ │ │ -00038bd0: 6d75 6c74 6970 6c65 5f63 6f6e 6e65 6374 multiple_connect │ │ │ -00038be0: 696f 6e73 5f70 6572 5f69 7020 616e 6420 ions_per_ip and │ │ │ -00038bf0: 7769 7468 6f75 743c 2f68 323e 3c68 343e without

    │ │ │ -00038c00: 2e2e 2f74 6573 742f 7465 7374 5f70 6565 ../test/test_pee │ │ │ -00038c10: 725f 6c69 7374 2e63 7070 3a31 3239 323c r_list.cpp:1292< │ │ │ -00038c20: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    r
    │ │ │ -00038c90: 656c 6576 616e 6365 266e 6273 703b 303c  elevance 0<
    │ │ │ -00038ca0: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../test
    │ │ │ -00038cd0: 2f74 6573 745f 7065 6572 5f6c 6973 742e  /test_peer_list.
    │ │ │ -00038ce0: 6370 703a 3132 3933 3c2f 613e 3c2f 7464  cpp:1293test add i2
    │ │ │ -00038d00: 7020 7065 6572 733c 2f74 643e 3c2f 7472  p peers

    test add i2 │ │ │ -00038d60: 7020 7065 6572 733c 2f68 323e 3c68 343e p peers

    │ │ │ -00038d70: 2e2e 2f74 6573 742f 7465 7374 5f70 6565 ../test/test_pee │ │ │ -00038d80: 725f 6c69 7374 2e63 7070 3a31 3239 333c r_list.cpp:1293< │ │ │ -00038d90: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    r
    │ │ │ -00038e00: 656c 6576 616e 6365 266e 6273 703b 303c  elevance 0<
    │ │ │ -00038e10: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../test
    │ │ │ -00038e40: 2f74 6573 745f 7065 6572 5f6c 6973 742e  /test_peer_list.
    │ │ │ -00038e50: 6370 703a 3132 3934 3c2f 613e 3c2f 7464  cpp:1294test allow_
    │ │ │ -00038e70: 6932 705f 6d69 7865 643c 2f74 643e 3c2f  i2p_mixed

    test allo │ │ │ -00038ed0: 775f 6932 705f 6d69 7865 643c 2f68 323e w_i2p_mixed

    │ │ │ -00038ee0: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ -00038ef0: 5f70 6565 725f 6c69 7374 2e63 7070 3a31 _peer_list.cpp:1 │ │ │ -00038f00: 3239 343c 2f68 343e 3c70 7265 2073 7479 294

    < │ │ │ -00038f70: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00038f80: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00038fb0: 7465 7374 2f74 6573 745f 7065 6572 5f6c test/test_peer_l │ │ │ -00038fc0: 6973 742e 6370 703a 3132 3935 3c2f 613e ist.cpp:1295 │ │ │ -00038fd0: 3c2f 7464 3e3c 7464 3e74 6573 7420 696e test in │ │ │ -00038fe0: 7365 7274 5f70 6565 7220 6661 696c 696e sert_peer failin │ │ │ -00038ff0: 6720 7769 7468 2061 6c6c 2065 7272 6f72 g with all error │ │ │ -00039000: 2063 6f6e 6469 7469 6f6e 733c 2f74 643e conditions │ │ │ -00039010: 3c2f 7472 3e3c 7472 2069 643d 2231 3333

    test in │ │ │ -00039060: 7365 7274 5f70 6565 7220 6661 696c 696e sert_peer failin │ │ │ -00039070: 6720 7769 7468 2061 6c6c 2065 7272 6f72 g with all error │ │ │ -00039080: 2063 6f6e 6469 7469 6f6e 733c 2f68 323e conditions

    │ │ │ -00039090: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ -000390a0: 5f70 6565 725f 6c69 7374 2e63 7070 3a31 _peer_list.cpp:1 │ │ │ -000390b0: 3239 353c 2f68 343e 3c70 7265 2073 7479 295

    <
    │ │ │ -00039120: 7464 3e72 656c 6576 616e 6365 266e 6273  td>relevance&nbs
    │ │ │ -00039130: 703b 303c 2f74 643e 3c74 643e 3c61 2068  p;0../
    │ │ │ -00039160: 7465 7374 2f74 6573 745f 7065 6572 5f6c  test/test_peer_l
    │ │ │ -00039170: 6973 742e 6370 703a 3132 3936 3c2f 613e  ist.cpp:1296
    │ │ │ -00039180: 3c2f 7464 3e3c 7464 3e74 6573 7420 4950  test IP
    │ │ │ -00039190: 7636 3c2f 7464 3e3c 2f74 723e 3c74 7220  v6

    │ │ │ -000391e0: 7465 7374 2049 5076 363c 2f68 323e 3c68 test IPv6

    ../test/test_p │ │ │ -00039200: 6565 725f 6c69 7374 2e63 7070 3a31 3239 eer_list.cpp:129 │ │ │ -00039210: 363c 2f68 343e 3c70 7265 2073 7479 6c65 6

    │ │ │ -00039250: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e  
    │ │ │ -00039260: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00039290: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../te │ │ │ -000392c0: 7374 2f74 6573 745f 7065 6572 5f6c 6973 st/test_peer_lis │ │ │ -000392d0: 742e 6370 703a 3132 3937 3c2f 613e 3c2f t.cpp:1297test conn │ │ │ -000392f0: 6563 745f 746f 5f70 6565 7228 2920 6661 ect_to_peer() fa │ │ │ -00039300: 696c 696e 673c 2f74 643e 3c2f 7472 3e3c iling< │ │ │ -00039310: 7472 2069 643d 2231 3335 2220 7374 796c tr id="135" styl │ │ │ -00039320: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00039330: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00039340: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00039350: 6832 3e74 6573 7420 636f 6e6e 6563 745f h2>test connect_ │ │ │ -00039360: 746f 5f70 6565 7228 2920 6661 696c 696e to_peer() failin │ │ │ -00039370: 673c 2f68 323e 3c68 343e 2e2e 2f74 6573 g

    ../tes │ │ │ -00039380: 742f 7465 7374 5f70 6565 725f 6c69 7374 t/test_peer_list │ │ │ -00039390: 2e63 7070 3a31 3239 373c 2f68 343e 3c70 .cpp:1297

    relevan │ │ │ -00039410: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../test/test_ │ │ │ -00039450: 7065 6572 5f6c 6973 742e 6370 703a 3132 peer_list.cpp:12 │ │ │ -00039460: 3938 3c2f 613e 3c2f 7464 3e3c 7464 3e74 98t │ │ │ -00039470: 6573 7420 636f 6e6e 6563 7469 6f6e 5f63 est connection_c │ │ │ -00039480: 6c6f 7365 643c 2f74 643e 3c2f 7472 3e3c losed< │ │ │ -00039490: 7472 2069 643d 2231 3336 2220 7374 796c tr id="136" styl │ │ │ -000394a0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -000394b0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -000394c0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -000394d0: 6832 3e74 6573 7420 636f 6e6e 6563 7469 h2>test connecti │ │ │ -000394e0: 6f6e 5f63 6c6f 7365 643c 2f68 323e 3c68 on_closed../test/test_p │ │ │ -00039500: 6565 725f 6c69 7374 2e63 7070 3a31 3239 eer_list.cpp:129 │ │ │ -00039510: 383c 2f68 343e 3c70 7265 2073 7479 6c65 8
    │ │ │ -00039550: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e  
    │ │ │ -00039560: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00039590: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../te │ │ │ -000395c0: 7374 2f74 6573 745f 7065 6572 5f6c 6973 st/test_peer_lis │ │ │ -000395d0: 742e 6370 703a 3132 3939 3c2f 613e 3c2f t.cpp:1299connect c │ │ │ -000395f0: 616e 6469 6461 7465 7320 7265 6361 6c63 andidates recalc │ │ │ -00039600: 756c 6174 696f 6e20 7768 656e 2069 6e63 ulation when inc │ │ │ -00039610: 7265 6d65 6e74 696e 6720 6661 696c 636f rementing failco │ │ │ -00039620: 756e 743c 2f74 643e 3c2f 7472 3e3c 7472 unt

    connect candida │ │ │ -00039680: 7465 7320 7265 6361 6c63 756c 6174 696f tes recalculatio │ │ │ -00039690: 6e20 7768 656e 2069 6e63 7265 6d65 6e74 n when increment │ │ │ -000396a0: 696e 6720 6661 696c 636f 756e 743c 2f68 ing failcount

    ../test/te │ │ │ -000396c0: 7374 5f70 6565 725f 6c69 7374 2e63 7070 st_peer_list.cpp │ │ │ -000396d0: 3a31 3239 393c 2f68 343e 3c70 7265 2073 :1299

    <
    │ │ │ -00039720: 2f74 723e 3c74 7220 7374 796c 653d 2262  /tr>relevance&n
    │ │ │ -00039750: 6273 703b 303c 2f74 643e 3c74 643e 3c61  bsp;0.
    │ │ │ -00039780: 2e2f 7465 7374 2f74 6573 745f 6d65 726b  ./test/test_merk
    │ │ │ -00039790: 6c65 5f74 7265 652e 6370 703a 3233 333c  le_tree.cpp:233<
    │ │ │ -000397a0: 2f61 3e3c 2f74 643e 3c74 643e 7573 6520  /a>use 
    │ │ │ -000397b0: 7374 7275 6374 7572 6564 2062 696e 6469  structured bindi
    │ │ │ -000397c0: 6e67 7320 696e 2043 2b2b 3137 3c2f 7464  ngs in C++17

    use st │ │ │ -00039820: 7275 6374 7572 6564 2062 696e 6469 6e67 ructured binding │ │ │ -00039830: 7320 696e 2043 2b2b 3137 3c2f 6832 3e3c s in C++17

    < │ │ │ -00039840: 6834 3e2e 2e2f 7465 7374 2f74 6573 745f h4>../test/test_ │ │ │ -00039850: 6d65 726b 6c65 5f74 7265 652e 6370 703a merkle_tree.cpp: │ │ │ -00039860: 3233 333c 2f68 343e 3c70 7265 2073 7479 233
    ...mask[std::s
    │ │ │ -000398b0: 697a 655f 7428 6929 5d20 3d20 7472 7565  ize_t(i)] = true
    │ │ │ -000398c0: 3b0a 0909 742e 6c6f 6164 5f73 7061 7273  ;...t.load_spars
    │ │ │ -000398d0: 655f 7472 6565 2873 7061 6e26 6c74 3b73  e_tree(span<s
    │ │ │ -000398e0: 6861 3235 365f 6861 7368 2063 6f6e 7374  ha256_hash const
    │ │ │ -000398f0: 2667 743b 2866 292e 7375 6273 7061 6e28  >(f).subspan(
    │ │ │ -00039900: 6669 7273 745f 7069 6563 652c 206e 756d  first_piece, num
    │ │ │ -00039910: 5f70 6965 6365 7329 2c20 6d61 736b 2c20  _pieces), mask, 
    │ │ │ -00039920: 656d 7074 795f 7665 7269 6669 6564 293b  empty_verified);
    │ │ │ -00039930: 0a09 0969 6e74 2063 6f6e 7374 2065 6e64  ...int const end
    │ │ │ -00039940: 5f70 6965 6365 5f6c 6179 6572 203d 2066  _piece_layer = f
    │ │ │ -00039950: 6972 7374 5f70 6965 6365 202b 206d 6572  irst_piece + mer
    │ │ │ -00039960: 6b6c 655f 6e75 6d5f 6c65 6166 7328 6e75  kle_num_leafs(nu
    │ │ │ -00039970: 6d5f 7069 6563 6573 293b 0a09 0966 6f72  m_pieces);...for
    │ │ │ -00039980: 2028 696e 7420 6920 3d20 303b 2069 2026   (int i = 0; i &
    │ │ │ -00039990: 6c74 3b20 656e 645f 7069 6563 655f 6c61  lt; end_piece_la
    │ │ │ -000399a0: 7965 723b 202b 2b69 290a 0909 7b0a 0909  yer; ++i)...{...
    │ │ │ -000399b0: 0954 4553 545f 4348 4543 4b28 742e 6861  .TEST_CHECK(t.ha
    │ │ │ -000399c0: 735f 6e6f 6465 2869 2929 3b0a 0909 0954  s_node(i));....T
    │ │ │ -000399d0: 4553 545f 4348 4543 4b28 742e 636f 6d70  EST_CHECK(t.comp
    │ │ │ -000399e0: 6172 655f 6e6f 6465 2869 2c20 665b 695d  are_node(i, f[i]
    │ │ │ -000399f0: 2929 3b0a 0909 7d0a 0909 666f 7220 2869  ));...}...for (i
    │ │ │ -00039a00: 6e74 2069 203d 2065 6e64 5f70 6965 6365  nt i = end_piece
    │ │ │ -00039a10: 5f6c 6179 6572 3b20 6920 266c 743b 206e  _layer; i < n
    │ │ │ -00039a20: 756d 5f6e 6f64 6573 3b20 2b2b 6929 0a09  um_nodes; ++i)..
    │ │ │ -00039a30: 097b 0a09 0909 5445 5354 5f43 4845 434b  .{....TEST_CHECK
    │ │ │ -00039a40: 2821 742e 6861 735f 6e6f 6465 2869 2929  (!t.has_node(i))
    │ │ │ -00039a50: 3b0a 0909 7d0a 097d 0a7d 0a0a 6e61 6d65  ;...}..}.}..name
    │ │ │ -00039a60: 7370 6163 6520 7b0a 766f 6964 2074 6573  space {.void tes
    │ │ │ -00039a70: 745f 726f 756e 6474 7269 7028 6175 783a  t_roundtrip(aux:
    │ │ │ -00039a80: 3a6d 6572 6b6c 655f 7472 6565 2063 6f6e  :merkle_tree con
    │ │ │ -00039a90: 7374 2661 6d70 3b20 740a 092c 2069 6e74  st& t.., int
    │ │ │ -00039aa0: 2063 6f6e 7374 2062 6c6f 636b 5f63 6f75   const block_cou
    │ │ │ -00039ab0: 6e74 0a09 2c20 696e 7420 636f 6e73 7420  nt.., int const 
    │ │ │ -00039ac0: 626c 6f63 6b73 5f70 6572 5f70 6965 6365  blocks_per_piece
    │ │ │ -00039ad0: 290a 7b0a 3c64 6976 2073 7479 6c65 3d22  ).{.
    .aux::vector&l │ │ │ -00039b10: 743b 626f 6f6c 2667 743b 206d 6173 6b3b t;bool> mask; │ │ │ -00039b20: 0a3c 2f64 6976 3e09 7374 643a 3a76 6563 .
    .std::vec │ │ │ -00039b30: 746f 7226 6c74 3b73 6861 3235 365f 6861 tor<sha256_ha │ │ │ -00039b40: 7368 2667 743b 2074 7265 653b 0a09 7374 sh> tree;..st │ │ │ -00039b50: 643a 3a74 6965 2874 7265 652c 206d 6173 d::tie(tree, mas │ │ │ -00039b60: 6b29 203d 2074 2e62 7569 6c64 5f73 7061 k) = t.build_spa │ │ │ -00039b70: 7273 655f 7665 6374 6f72 2829 3b0a 0a09 rse_vector();... │ │ │ -00039b80: 6175 783a 3a6d 6572 6b6c 655f 7472 6565 aux::merkle_tree │ │ │ -00039b90: 2074 3228 626c 6f63 6b5f 636f 756e 742c t2(block_count, │ │ │ -00039ba0: 2062 6c6f 636b 735f 7065 725f 7069 6563 blocks_per_piec │ │ │ -00039bb0: 652c 2066 5b30 5d2e 6461 7461 2829 293b e, f[0].data()); │ │ │ -00039bc0: 0a09 7432 2e6c 6f61 645f 7370 6172 7365 ..t2.load_sparse │ │ │ -00039bd0: 5f74 7265 6528 7472 6565 2c20 6d61 736b _tree(tree, mask │ │ │ -00039be0: 2c20 656d 7074 795f 7665 7269 6669 6564 , empty_verified │ │ │ -00039bf0: 293b 0a0a 0954 4553 545f 4348 4543 4b28 );...TEST_CHECK( │ │ │ -00039c00: 742e 6275 696c 645f 7665 6374 6f72 2829 t.build_vector() │ │ │ -00039c10: 203d 3d20 7432 2e62 7569 6c64 5f76 6563 == t2.build_vec │ │ │ -00039c20: 746f 7228 2929 3b0a 0966 6f72 2028 696e tor());..for (in │ │ │ -00039c30: 7420 6920 3d20 303b 2069 2026 6c74 3b20 t i = 0; i < │ │ │ -00039c40: 696e 7428 742e 7369 7a65 2829 293b 202b int(t.size()); + │ │ │ -00039c50: 2b69 290a 097b 0a09 0954 4553 545f 4551 +i)..{...TEST_EQ │ │ │ -00039c60: 5541 4c28 745b 695d 2c20 7432 5b69 5d29 UAL(t[i], t2[i]) │ │ │ -00039c70: 3b0a 0909 5445 5354 5f45 5155 414c 2874 ;...TEST_EQUAL(t │ │ │ -00039c80: 2e68 6173 5f6e 6f64 6528 6929 2c20 7432 .has_node(i), t2 │ │ │ -00039c90: 2e68 6173 5f6e 6f64 6528 6929 293b 0a0a .has_node(i));.. │ │ │ -00039ca0: 0909 6966 2028 2174 2e68 6173 5f6e 6f64 ..if (!t.has_nod │ │ │ -00039cb0: 6528 6929 290a 0909 0954 4553 545f 4348 e(i))....TEST_CH │ │ │ -00039cc0: 4543 4b28 745b 695d 2e69 735f 616c 6c5f ECK(t[i].is_all_ │ │ │ -00039cd0: 7a65 726f 7328 2929 3b0a 0909 6966 2028 zeros());...if ( │ │ │ -00039ce0: 2174 322e 6861 735f 6e6f 6465 2869 2929 !t2.has_node(i)) │ │ │ -00039cf0: 0a09 0909 5445 5354 5f43 4845 434b 2874 ....TEST_CHECK(t │ │ │ -00039d00: 325b 695d 2e69 735f 616c 6c5f 7a65 726f 2[i].is_all_zero │ │ │ -00039d10: 7328 2929 3b0a 0a09 0954 4553 545f 4348 s());....TEST_CH │ │ │ -00039d20: 4543 4b28 742e 636f 6d70 6172 655f 6e6f ECK(t.compare_no │ │ │ -00039d30: 6465 2869 2c20 7432 5b69 5d29 293b 0a09 de(i, t2[i]));.. │ │ │ -00039d40: 0954 4553 545f 4348 4543 4b28 7432 2e63 .TEST_CHECK(t2.c │ │ │ -00039d50: 6f6d 7061 7265 5f6e 6f64 6528 692c 2074 ompare_node(i, t │ │ │ -00039d60: 5b69 5d29 293b 0a09 7d0a 7d0a 7d0a 0a54 [i]));..}.}.}..T │ │ │ -00039d70: 4f52 5245 4e54 5f54 4553 5428 726f 756e ORRENT_TEST(roun │ │ │ -00039d80: 6474 7269 705f 656d 7074 795f 7472 6565 dtrip_empty_tree │ │ │ -00039d90: 290a 7b0a 0961 7578 3a3a 6d65 726b 6c65 ).{..aux::merkle │ │ │ -00039da0: 5f74 7265 6520 7428 6e75 6d5f 626c 6f63 _tree t(num_bloc │ │ │ -00039db0: 6b73 2c20 312c 2066 5b30 5d2e 6461 7461 ks, 1, f[0].data │ │ │ -00039dc0: 2829 293b 0a09 7465 7374 5f72 6f75 6e64 ());..test_round │ │ │ -00039dd0: 7472 6970 2874 2c20 6e75 6d5f 626c 6f63 trip(t, num_bloc │ │ │ -00039de0: 6b73 2c20 3129 3b0a 7d0a 0a54 4f52 5245 ks, 1);.}..TORRE │ │ │ -00039df0: 4e54 5f54 4553 5428 726f 756e 6474 7269 NT_TEST(roundtri │ │ │ -00039e00: 705f 6675 6c6c 5f74 7265 6529 0a3c 2f70 p_full_tree).

    re │ │ │ -00039e40: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0
    ../test/ │ │ │ -00039e80: 7465 7374 5f6d 6572 6b6c 655f 7472 6565 test_merkle_tree │ │ │ -00039e90: 2e63 7070 3a39 3935 3c2f 613e 3c2f 7464 .cpp:995add test fo │ │ │ -00039eb0: 7220 6c6f 6164 5f70 6965 6365 5f6c 6179 r load_piece_lay │ │ │ -00039ec0: 6572 2829 3c2f 7464 3e3c 2f74 723e 3c74 er()add test for l │ │ │ -00039f20: 6f61 645f 7069 6563 655f 6c61 7965 7228 oad_piece_layer( │ │ │ -00039f30: 293c 2f68 323e 3c68 343e 2e2e 2f74 6573 )

    ../tes │ │ │ -00039f40: 742f 7465 7374 5f6d 6572 6b6c 655f 7472 t/test_merkle_tr │ │ │ -00039f50: 6565 2e63 7070 3a39 3935 3c2f 6834 3e3c ee.cpp:995

    < │ │ │ -00039f60: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00039f70: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00039f80: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00039f90: 7820 2364 6464 3b22 3e3c 2f70 7265 3e3c x #ddd;">
    < │ │ │ -00039fa0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00039fd0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00039fe0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test │ │ │ -0003a010: 5f6d 6572 6b6c 655f 7472 6565 2e63 7070 _merkle_tree.cpp │ │ │ -0003a020: 3a39 3936 3c2f 613e 3c2f 7464 3e3c 7464 :996add test for ad │ │ │ -0003a040: 645f 6861 7368 6573 2829 2077 6974 6820 d_hashes() with │ │ │ -0003a050: 616e 206f 6464 206e 756d 6265 7220 6f66 an odd number of │ │ │ -0003a060: 2062 6c6f 636b 733c 2f74 643e 3c2f 7472 blocks

    add test fo │ │ │ -0003a0c0: 7220 6164 645f 6861 7368 6573 2829 2077 r add_hashes() w │ │ │ -0003a0d0: 6974 6820 616e 206f 6464 206e 756d 6265 ith an odd numbe │ │ │ -0003a0e0: 7220 6f66 2062 6c6f 636b 733c 2f68 323e r of blocks

    │ │ │ -0003a0f0: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ -0003a100: 5f6d 6572 6b6c 655f 7472 6565 2e63 7070 _merkle_tree.cpp │ │ │ -0003a110: 3a39 3936 3c2f 6834 3e3c 7072 6520 7374 :996

    
    │ │ │ -0003a180: 3c74 643e 7265 6c65 7661 6e63 6526 6e62  relevance&nb
    │ │ │ -0003a190: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120  sp;0..
    │ │ │ -0003a1c0: 2f74 6573 742f 7465 7374 5f6d 6572 6b6c  /test/test_merkl
    │ │ │ -0003a1d0: 655f 7472 6565 2e63 7070 3a39 3937 3c2f  e_tree.cpp:997add t
    │ │ │ -0003a1f0: 6573 7420 666f 7220 7365 745f 626c 6f63  est for set_bloc
    │ │ │ -0003a200: 6b28 2920 2873 6574 7469 6e67 2074 6865  k() (setting the
    │ │ │ -0003a210: 206c 6173 7420 626c 6f63 6b29 2077 6974   last block) wit
    │ │ │ -0003a220: 6820 616e 206f 6464 206e 756d 6265 7220  h an odd number 
    │ │ │ -0003a230: 6f66 2062 6c6f 636b 733c 2f74 643e 3c2f  of blocks

    add test │ │ │ -0003a290: 666f 7220 7365 745f 626c 6f63 6b28 2920 for set_block() │ │ │ -0003a2a0: 2873 6574 7469 6e67 2074 6865 206c 6173 (setting the las │ │ │ -0003a2b0: 7420 626c 6f63 6b29 2077 6974 6820 616e t block) with an │ │ │ -0003a2c0: 206f 6464 206e 756d 6265 7220 6f66 2062 odd number of b │ │ │ -0003a2d0: 6c6f 636b 733c 2f68 323e 3c68 343e 2e2e locks

    .. │ │ │ -0003a2e0: 2f74 6573 742f 7465 7374 5f6d 6572 6b6c /test/test_merkl │ │ │ -0003a2f0: 655f 7472 6565 2e63 7070 3a39 3937 3c2f e_tree.cpp:997
    .TE
    │ │ │ -0003a340: 5354 5f43 4845 434b 2874 2e6c 6f61 645f  ST_CHECK(t.load_
    │ │ │ -0003a350: 7069 6563 655f 6c61 7965 7228 7069 6563  piece_layer(piec
    │ │ │ -0003a360: 655f 6c61 7965 725f 6279 7465 7329 293b  e_layer_bytes));
    │ │ │ -0003a370: 0a0a 092f 2f20 696e 2070 6965 6365 5f6c  ...// in piece_l
    │ │ │ -0003a380: 6179 6572 206d 6f64 6520 7769 7468 2062  ayer mode with b
    │ │ │ -0003a390: 7070 2026 6774 3b20 312c 206e 6f20 626c  pp > 1, no bl
    │ │ │ -0003a3a0: 6f63 6b73 2073 686f 756c 6420 7265 706f  ocks should repo
    │ │ │ -0003a3b0: 7274 2061 7320 7665 7269 6669 6564 0a09  rt as verified..
    │ │ │ -0003a3c0: 5445 5354 5f43 4845 434b 2874 2e76 6572  TEST_CHECK(t.ver
    │ │ │ -0003a3d0: 6966 6965 645f 6c65 6166 7328 2920 3d3d  ified_leafs() ==
    │ │ │ -0003a3e0: 206e 6f6e 655f 7365 7428 6e75 6d5f 626c   none_set(num_bl
    │ │ │ -0003a3f0: 6f63 6b73 2929 3b0a 0a09 2f2f 2061 6674  ocks));...// aft
    │ │ │ -0003a400: 6572 206c 6f61 645f 7069 6563 655f 6c61  er load_piece_la
    │ │ │ -0003a410: 7965 7220 7468 6520 7472 6565 2069 7320  yer the tree is 
    │ │ │ -0003a420: 6261 636b 2069 6e20 7468 6520 7069 6563  back in the piec
    │ │ │ -0003a430: 655f 6c61 7965 722d 6f6e 6c79 0a09 2f2f  e_layer-only..//
    │ │ │ -0003a440: 2073 7461 7465 2c20 736f 2061 2073 696e   state, so a sin
    │ │ │ -0003a450: 676c 6520 7365 745f 626c 6f63 6b20 6361  gle set_block ca
    │ │ │ -0003a460: 6e27 7420 7965 7420 7665 7269 6679 2061  n't yet verify a
    │ │ │ -0003a470: 6761 696e 7374 2074 6865 2073 6962 6c69  gainst the sibli
    │ │ │ -0003a480: 6e67 2e0a 0961 7574 6f20 636f 6e73 7420  ng...auto const 
    │ │ │ -0003a490: 7265 7375 6c74 203d 2074 2e73 6574 5f62  result = t.set_b
    │ │ │ -0003a4a0: 6c6f 636b 2830 2c20 665b 3531 315d 293b  lock(0, f[511]);
    │ │ │ -0003a4b0: 0a09 5445 5354 5f43 4845 434b 2873 7464  ..TEST_CHECK(std
    │ │ │ -0003a4c0: 3a3a 6765 7426 6c74 3b30 2667 743b 2872  ::get<0>(r
    │ │ │ -0003a4d0: 6573 756c 7429 203d 3d20 6175 783a 3a6d  esult) == aux::m
    │ │ │ -0003a4e0: 6572 6b6c 655f 7472 6565 3a3a 7365 745f  erkle_tree::set_
    │ │ │ -0003a4f0: 626c 6f63 6b5f 7265 7375 6c74 3a3a 756e  block_result::un
    │ │ │ -0003a500: 6b6e 6f77 6e29 3b0a 0a09 2f2f 2074 6865  known);...// the
    │ │ │ -0003a510: 2073 6574 5f62 6c6f 636b 2061 626f 7665   set_block above
    │ │ │ -0003a520: 2072 616e 2061 6c6c 6f63 6174 655f 6675   ran allocate_fu
    │ │ │ -0003a530: 6c6c 2829 2c20 6272 696e 6769 6e67 2075  ll(), bringing u
    │ │ │ -0003a540: 7320 6261 636b 2074 6f20 6675 6c6c 5f74  s back to full_t
    │ │ │ -0003a550: 7265 650a 092f 2f20 6d6f 6465 2077 6865  ree..// mode whe
    │ │ │ -0003a560: 7265 2076 6572 6966 6965 645f 6c65 6166  re verified_leaf
    │ │ │ -0003a570: 7328 292f 626c 6f63 6b73 5f76 6572 6966  s()/blocks_verif
    │ │ │ -0003a580: 6965 6428 2920 636f 6e73 756c 7420 6d5f  ied() consult m_
    │ │ │ -0003a590: 626c 6f63 6b5f 7665 7269 6669 6564 0a09  block_verified..
    │ │ │ -0003a5a0: 2f2f 2064 6972 6563 746c 7920 2869 6e20  // directly (in 
    │ │ │ -0003a5b0: 7069 6563 655f 6c61 7965 7220 6d6f 6465  piece_layer mode
    │ │ │ -0003a5c0: 2074 6865 7920 6967 6e6f 7265 2069 7429   they ignore it)
    │ │ │ -0003a5d0: 2e20 616c 6c6f 6361 7465 5f66 756c 6c27  . allocate_full'
    │ │ │ -0003a5e0: 7320 7265 7369 7a65 0a09 2f2f 2070 7265  s resize..// pre
    │ │ │ -0003a5f0: 7365 7276 6573 2061 6e79 2070 7265 2d65  serves any pre-e
    │ │ │ -0003a600: 7869 7374 696e 6720 6269 7473 2c20 736f  xisting bits, so
    │ │ │ -0003a610: 2068 6164 206c 6f61 645f 7069 6563 655f   had load_piece_
    │ │ │ -0003a620: 6c61 7965 7220 6661 696c 6564 2074 6f0a  layer failed to.
    │ │ │ -0003a630: 092f 2f20 636c 6561 7220 7468 656d 2074  .// clear them t
    │ │ │ -0003a640: 6865 2073 7461 6c65 2070 6965 6365 2d30  he stale piece-0
    │ │ │ -0003a650: 2062 6974 7320 776f 756c 6420 7265 7375   bits would resu
    │ │ │ -0003a660: 7266 6163 6520 6173 2022 7665 7269 6669  rface as "verifi
    │ │ │ -0003a670: 6564 2220 6865 7265 202d 2d0a 092f 2f20  ed" here --..// 
    │ │ │ -0003a680: 6361 7463 6869 6e67 2074 6865 2062 7567  catching the bug
    │ │ │ -0003a690: 2065 7665 6e20 696e 2062 7569 6c64 7320   even in builds 
    │ │ │ -0003a6a0: 636f 6d70 696c 6564 2077 6974 686f 7574  compiled without
    │ │ │ -0003a6b0: 2069 6e76 6172 6961 6e74 2063 6865 636b   invariant check
    │ │ │ -0003a6c0: 732e 0a09 5445 5354 5f43 4845 434b 2821  s...TEST_CHECK(!
    │ │ │ -0003a6d0: 742e 626c 6f63 6b73 5f76 6572 6966 6965  t.blocks_verifie
    │ │ │ -0003a6e0: 6428 302c 2062 6c6f 636b 735f 7065 725f  d(0, blocks_per_
    │ │ │ -0003a6f0: 7069 6563 6529 293b 0a09 5445 5354 5f43  piece));..TEST_C
    │ │ │ -0003a700: 4845 434b 2874 2e76 6572 6966 6965 645f  HECK(t.verified_
    │ │ │ -0003a710: 6c65 6166 7328 2920 3d3d 206e 6f6e 655f  leafs() == none_
    │ │ │ -0003a720: 7365 7428 6e75 6d5f 626c 6f63 6b73 2929  set(num_blocks))
    │ │ │ -0003a730: 3b0a 7d0a 0a3c 6469 7620 7374 796c 653d  ;.}..
    .
    TORREN │ │ │ -0003a770: 545f 5445 5354 2861 6464 5f68 6173 6865 T_TEST(add_hashe │ │ │ -0003a780: 735f 7a65 726f 5f62 6c6f 636b 5f68 6173 s_zero_block_has │ │ │ -0003a790: 6829 0a7b 0a09 2f2f 2061 2070 6565 7220 h).{..// a peer │ │ │ -0003a7a0: 6361 6e20 6173 6b20 7573 2074 6f20 696e can ask us to in │ │ │ -0003a7b0: 7365 7274 2061 2073 696e 676c 6520 626c sert a single bl │ │ │ -0003a7c0: 6f63 6b20 6861 7368 206f 6620 616c 6c20 ock hash of all │ │ │ -0003a7d0: 7a65 726f 732e 2074 6861 7427 7320 7468 zeros. that's th │ │ │ -0003a7e0: 650a 092f 2f20 7361 6d65 2076 616c 7565 e..// same value │ │ │ -0003a7f0: 2061 6e20 756e 6b6e 6f77 6e20 6e6f 6465 an unknown node │ │ │ -0003a800: 2068 6173 2c20 736f 2074 6865 2069 6e73 has, so the ins │ │ │ -0003a810: 6572 7420 6d75 7374 2062 6520 7265 6a65 ert must be reje │ │ │ -0003a820: 6374 6564 2072 6174 6865 720a 092f 2f20 cted rather..// │ │ │ -0003a830: 7468 616e 2073 696c 656e 746c 7920 6d61 than silently ma │ │ │ -0003a840: 726b 696e 6720 7468 6520 626c 6f63 6b20 rking the block │ │ │ -0003a850: 6173 2076 6572 6966 6965 640a 0961 7578 as verified..aux │ │ │ -0003a860: 3a3a 6d65 726b 6c65 5f74 7265 6520 7428 ::merkle_tree t( │ │ │ -0003a870: 6e75 6d5f 626c 6f63 6b73 2c20 342c 2066 num_blocks, 4, f │ │ │ -0003a880: 5b30 5d2e 6461 7461 2829 293b 0a0a 0973 [0].data());...s │ │ │ -0003a890: 7464 3a3a 7665 6374 6f72 266c 743b 7368 td::vector<sh │ │ │ -0003a8a0: 6132 3536 5f68 6173 6826 6774 3b20 636f a256_hash> co │ │ │ -0003a8b0: 6e73 7420 6861 7368 6573 7b73 6861 3235 nst hashes{sha25 │ │ │ -0003a8c0: 365f 6861 7368 7b7d 7d3b 0a09 7374 643a 6_hash{}};..std: │ │ │ -0003a8d0: 3a76 6563 746f 7226 6c74 3b73 6861 3235 :vector<sha25 │ │ │ -0003a8e0: 365f 6861 7368 2667 743b 2063 6f6e 7374 6_hash> const │ │ │ -0003a8f0: 2070 726f 6f66 737b 7261 6e64 5f73 6861 proofs{rand_sha │ │ │ -0003a900: 3235 3628 297d 3b0a 0a09 6175 746f 2063 256()};...auto c │ │ │ -0003a910: 6f6e 7374 2072 6573 756c 7420 3d20 742e onst result = t. │ │ │ -0003a920: 6164 645f 6861 7368 6573 286d 6572 6b6c add_hashes(merkl │ │ │ -0003a930: 655f 6669 7273 745f 6c65 6166 286e 756d e_first_leaf(num │ │ │ -0003a940: 5f6c 6561 6673 2920 2b20 312c 2070 6469 _leafs) + 1, pdi │ │ │ -0003a950: 6666 2830 292c 2068 6173 6865 732c 2070 ff(0), hashes, p │ │ │ -0003a960: 726f 6f66 7329 3b0a 0a09 5445 5354 5f43 roofs);...TEST_C │ │ │ -0003a970: 4845 434b 2821 7265 7375 6c74 293b 0a09 HECK(!result);.. │ │ │ -0003a980: 5445 5354 5f43 4845 434b 2874 2e76 6572 TEST_CHECK(t.ver │ │ │ -0003a990: 6966 6965 645f 6c65 6166 7328 2920 3d3d ified_leafs() == │ │ │ -0003a9a0: 206e 6f6e 655f 7365 7428 6e75 6d5f 626c none_set(num_bl │ │ │ -0003a9b0: 6f63 6b73 2929 3b0a 7d0a 3c2f 7072 653e ocks));.}.
    │ │ │ -0003a9c0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0003a9f0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0003aa00: 3c74 643e 3c61 2068 7265 663d 226a 6176
    ../test/tes │ │ │ -0003aa30: 745f 666c 6167 732e 6370 703a 3136 333c t_flags.cpp:163< │ │ │ -0003aa40: 2f61 3e3c 2f74 643e 3c74 643e 6368 616e /a>chan │ │ │ -0003aa50: 6765 2074 6f20 6120 6469 6666 6572 656e ge to a differen │ │ │ -0003aa60: 7420 7465 7374 2073 6574 7570 2e20 6375 t test setup. cu │ │ │ -0003aa70: 7272 656e 746c 7920 616c 7761 7973 2070 rrently always p │ │ │ -0003aa80: 6175 7365 642e 2074 6573 745f 7365 745f aused. test_set_ │ │ │ -0003aa90: 6166 7465 725f 6164 6428 746f 7272 656e after_add(torren │ │ │ -0003aaa0: 745f 666c 6167 733a 3a70 6175 7365 6429 t_flags::paused) │ │ │ -0003aab0: 3b20 7465 7374 5f75 6e73 6574 5f61 6674 ; test_unset_aft │ │ │ -0003aac0: 6572 5f61 6464 2874 6f72 7265 6e74 5f66 er_add(torrent_f │ │ │ -0003aad0: 6c61 6773 3a3a 7061 7573 6564 293b 3c2f lags::paused);

    chan │ │ │ -0003ab30: 6765 2074 6f20 6120 6469 6666 6572 656e ge to a differen │ │ │ -0003ab40: 7420 7465 7374 2073 6574 7570 2e20 6375 t test setup. cu │ │ │ -0003ab50: 7272 656e 746c 7920 616c 7761 7973 2070 rrently always p │ │ │ -0003ab60: 6175 7365 642e 0a74 6573 745f 7365 745f aused..test_set_ │ │ │ -0003ab70: 6166 7465 725f 6164 6428 746f 7272 656e after_add(torren │ │ │ -0003ab80: 745f 666c 6167 733a 3a70 6175 7365 6429 t_flags::paused) │ │ │ -0003ab90: 3b0a 7465 7374 5f75 6e73 6574 5f61 6674 ;.test_unset_aft │ │ │ -0003aba0: 6572 5f61 6464 2874 6f72 7265 6e74 5f66 er_add(torrent_f │ │ │ -0003abb0: 6c61 6773 3a3a 7061 7573 6564 293b 3c2f lags::paused);

    ../test/t │ │ │ -0003abd0: 6573 745f 666c 6167 732e 6370 703a 3136 est_flags.cpp:16 │ │ │ -0003abe0: 333c 2f68 343e 3c70 7265 2073 7479 6c65 3

    │ │ │ -0003ac20: 7b0a 092f 2f20 7368 6172 652d 6d6f 6465  {..// share-mode
    │ │ │ -0003ac30: 0a09 7465 7374 5f61 6464 5f61 6e64 5f67  ..test_add_and_g
    │ │ │ -0003ac40: 6574 5f66 6c61 6773 2874 6f72 7265 6e74  et_flags(torrent
    │ │ │ -0003ac50: 5f66 6c61 6773 3a3a 7368 6172 655f 6d6f  _flags::share_mo
    │ │ │ -0003ac60: 6465 293b 0a09 7465 7374 5f73 6574 5f61  de);..test_set_a
    │ │ │ -0003ac70: 6674 6572 5f61 6464 2874 6f72 7265 6e74  fter_add(torrent
    │ │ │ -0003ac80: 5f66 6c61 6773 3a3a 7368 6172 655f 6d6f  _flags::share_mo
    │ │ │ -0003ac90: 6465 293b 0a09 7465 7374 5f75 6e73 6574  de);..test_unset
    │ │ │ -0003aca0: 5f61 6674 6572 5f61 6464 2874 6f72 7265  _after_add(torre
    │ │ │ -0003acb0: 6e74 5f66 6c61 6773 3a3a 7368 6172 655f  nt_flags::share_
    │ │ │ -0003acc0: 6d6f 6465 293b 0a7d 0a23 656e 6469 660a  mode);.}.#endif.
    │ │ │ -0003acd0: 0a54 4f52 5245 4e54 5f54 4553 5428 666c  .TORRENT_TEST(fl
    │ │ │ -0003ace0: 6167 5f61 7070 6c79 5f69 705f 6669 6c74  ag_apply_ip_filt
    │ │ │ -0003acf0: 6572 290a 7b0a 092f 2f20 6170 706c 792d  er).{..// apply-
    │ │ │ -0003ad00: 6970 2d66 696c 7465 720a 0974 6573 745f  ip-filter..test_
    │ │ │ -0003ad10: 6164 645f 616e 645f 6765 745f 666c 6167  add_and_get_flag
    │ │ │ -0003ad20: 7328 746f 7272 656e 745f 666c 6167 733a  s(torrent_flags:
    │ │ │ -0003ad30: 3a61 7070 6c79 5f69 705f 6669 6c74 6572  :apply_ip_filter
    │ │ │ -0003ad40: 293b 0a09 7465 7374 5f73 6574 5f61 6674  );..test_set_aft
    │ │ │ -0003ad50: 6572 5f61 6464 2874 6f72 7265 6e74 5f66  er_add(torrent_f
    │ │ │ -0003ad60: 6c61 6773 3a3a 6170 706c 795f 6970 5f66  lags::apply_ip_f
    │ │ │ -0003ad70: 696c 7465 7229 3b0a 0974 6573 745f 756e  ilter);..test_un
    │ │ │ -0003ad80: 7365 745f 6166 7465 725f 6164 6428 746f  set_after_add(to
    │ │ │ -0003ad90: 7272 656e 745f 666c 6167 733a 3a61 7070  rrent_flags::app
    │ │ │ -0003ada0: 6c79 5f69 705f 6669 6c74 6572 293b 0a7d  ly_ip_filter);.}
    │ │ │ -0003adb0: 0a0a 544f 5252 454e 545f 5445 5354 2866  ..TORRENT_TEST(f
    │ │ │ -0003adc0: 6c61 675f 7061 7573 6564 290a 7b0a 092f  lag_paused).{../
    │ │ │ -0003add0: 2f20 7061 7573 6564 0a09 7465 7374 5f61  / paused..test_a
    │ │ │ -0003ade0: 6464 5f61 6e64 5f67 6574 5f66 6c61 6773  dd_and_get_flags
    │ │ │ -0003adf0: 2874 6f72 7265 6e74 5f66 6c61 6773 3a3a  (torrent_flags::
    │ │ │ -0003ae00: 7061 7573 6564 293b 0a3c 6469 7620 7374  paused);.
    }.
    . │ │ │ -0003ae40: 544f 5252 454e 545f 5445 5354 2866 6c61 TORRENT_TEST(fla │ │ │ -0003ae50: 675f 6175 746f 5f6d 616e 6167 6564 290a g_auto_managed). │ │ │ -0003ae60: 7b0a 092f 2f20 6175 746f 2d6d 616e 6167 {..// auto-manag │ │ │ -0003ae70: 6564 0a09 7465 7374 5f61 6464 5f61 6e64 ed..test_add_and │ │ │ -0003ae80: 5f67 6574 5f66 6c61 6773 2874 6f72 7265 _get_flags(torre │ │ │ -0003ae90: 6e74 5f66 6c61 6773 3a3a 6175 746f 5f6d nt_flags::auto_m │ │ │ -0003aea0: 616e 6167 6564 293b 0a09 7465 7374 5f73 anaged);..test_s │ │ │ -0003aeb0: 6574 5f61 6674 6572 5f61 6464 2874 6f72 et_after_add(tor │ │ │ -0003aec0: 7265 6e74 5f66 6c61 6773 3a3a 6175 746f rent_flags::auto │ │ │ -0003aed0: 5f6d 616e 6167 6564 293b 0a09 7465 7374 _managed);..test │ │ │ -0003aee0: 5f75 6e73 6574 5f61 6674 6572 5f61 6464 _unset_after_add │ │ │ -0003aef0: 2874 6f72 7265 6e74 5f66 6c61 6773 3a3a (torrent_flags:: │ │ │ -0003af00: 6175 746f 5f6d 616e 6167 6564 293b 0a7d auto_managed);.} │ │ │ -0003af10: 0a0a 2f2f 2073 7570 6572 2073 6565 6469 ..// super seedi │ │ │ -0003af20: 6e67 206d 6f64 6520 6973 2061 7574 6f6d ng mode is autom │ │ │ -0003af30: 6174 6963 616c 6c79 2074 7572 6e65 6420 atically turned │ │ │ -0003af40: 6f66 6620 6966 2077 6527 7265 206e 6f74 off if we're not │ │ │ -0003af50: 2061 2073 6565 640a 2f2f 2073 696e 6365 a seed.// since │ │ │ -0003af60: 2074 6865 2070 6f73 6978 5f64 6973 6b5f the posix_disk_ │ │ │ -0003af70: 696f 2069 7320 6e6f 7420 7468 7265 6164 io is not thread │ │ │ -0003af80: 6564 2c20 7468 6973 2077 696c 6c20 6861 ed, this will ha │ │ │ -0003af90: 7070 656e 2069 6d6d 6564 6961 7465 6c79 ppen immediately │ │ │ -0003afa0: 0a23 6966 2054 4f52 5245 4e54 5f48 4156 .#if TORRENT_HAV │ │ │ -0003afb0: 455f 4d4d 4150 0a23 6966 6e64 6566 2054 E_MMAP.#ifndef T │ │ │ -0003afc0: 4f52 5245 4e54 5f44 4953 4142 4c45 5f53 ORRENT_DISABLE_S │ │ │ -0003afd0: 5550 4552 5345 4544 494e 470a 544f 5252 UPERSEEDING.TORR │ │ │ -0003afe0: 454e 545f 5445 5354 2866 6c61 675f 7375 ENT_TEST(flag_su │ │ │ -0003aff0: 7065 725f 7365 6564 696e 6729 0a7b 0a09 per_seeding).{.. │ │ │ -0003b000: 2f2f 2073 7570 6572 2d73 6565 6469 6e67 // super-seeding │ │ │ -0003b010: 0a09 7465 7374 5f61 6464 5f61 6e64 5f67 ..test_add_and_g │ │ │ -0003b020: 6574 5f66 6c61 6773 2874 6f72 7265 6e74 et_flags(torrent │ │ │ -0003b030: 5f66 6c61 6773 3a3a 7375 7065 725f 7365 _flags::super_se │ │ │ -0003b040: 6564 696e 6729 3b0a 0974 6573 745f 756e eding);..test_un │ │ │ -0003b050: 7365 745f 6166 7465 725f 6164 6428 746f set_after_add(to │ │ │ -0003b060: 7272 656e 745f 666c 6167 733a 3a73 7570 rrent_flags::sup │ │ │ -0003b070: 6572 5f73 6565 6469 6e67 293b 0a09 7465 er_seeding);..te │ │ │ -0003b080: 7374 5f73 6574 5f61 6674 6572 5f61 6464 st_set_after_add │ │ │ -0003b090: 2874 6f72 7265 6e74 5f66 6c61 6773 3a3a (torrent_flags:: │ │ │ -0003b0a0: 7375 7065 725f 7365 6564 696e 6729 3b0a super_seeding);. │ │ │ -0003b0b0: 7d0a 2365 6e64 6966 0a23 656e 6469 660a }.#endif.#endif. │ │ │ -0003b0c0: 0a54 4f52 5245 4e54 5f54 4553 5428 666c .TORRENT_TEST(fl │ │ │ -0003b0d0: 6167 5f73 6571 7565 6e74 6961 6c5f 646f ag_sequential_do │ │ │ -0003b0e0: 776e 6c6f 6164 290a 7b0a 092f 2f20 7365 wnload).{..// se │ │ │ -0003b0f0: 7175 656e 7469 616c 2d64 6f77 6e6c 6f61 quential-downloa │ │ │ -0003b100: 640a 0974 6573 745f 6164 645f 616e 645f d..test_add_and_ │ │ │ -0003b110: 6765 745f 666c 6167 7328 746f 7272 656e get_flags(torren │ │ │ -0003b120: 745f 666c 6167 733a 3a73 6571 7565 6e74 t_flags::sequent │ │ │ -0003b130: 6961 6c5f 646f 776e 6c6f 6164 293b 0a09 ial_download);.. │ │ │ -0003b140: 7465 7374 5f73 6574 5f61 6674 6572 5f61 test_set_after_a │ │ │ -0003b150: 6464 2874 6f72 7265 6e74 5f66 6c61 6773 dd(torrent_flags │ │ │ -0003b160: 3a3a 7365 7175 656e 7469 616c 5f64 6f77 ::sequential_dow │ │ │ -0003b170: 6e6c 6f61 6429 3b0a 0974 6573 745f 756e nload);..test_un │ │ │ -0003b180: 7365 745f 6166 7465 725f 6164 6428 746f set_after_add(to │ │ │ -0003b190: 7272 656e 745f 666c 6167 733a 3a73 6571 rrent_flags::seq │ │ │ -0003b1a0: 7565 6e74 6961 6c5f 646f 776e 6c6f 6164 uential_download │ │ │ -0003b1b0: 293b 0a7d 0a3c 2f70 7265 3e3c 2f74 643e );.}.
    │ │ │ -0003b1c0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -0003b1f0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -0003b200: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -0003b210: 7074 3a65 7870 616e 6428 3134 3329 223e pt:expand(143)"> │ │ │ -0003b220: 2e2e 2f74 6573 742f 7465 7374 5f66 6c61 ../test/test_fla │ │ │ -0003b230: 6773 2e63 7070 3a32 3035 3c2f 613e 3c2f gs.cpp:205
    this test │ │ │ -0003b250: 2069 7320 666c 616b 792c 2073 696e 6365 is flaky, since │ │ │ -0003b260: 2074 6865 2074 6f72 7265 6e74 2077 696c the torrent wil │ │ │ -0003b270: 6c20 6265 636f 6d65 2072 6561 6479 2062 l become ready b │ │ │ -0003b280: 6566 6f72 6520 6173 6b69 6e67 2066 6f72 efore asking for │ │ │ -0003b290: 2074 6865 2066 6c61 6773 2c20 616e 6420 the flags, and │ │ │ -0003b2a0: 6279 2074 6865 6e20 7374 6f70 5f77 6865 by then stop_whe │ │ │ -0003b2b0: 6e5f 7265 6164 7920 7769 6c6c 2068 6176 n_ready will hav │ │ │ -0003b2c0: 6520 6265 656e 2063 6c65 6172 6564 2074 e been cleared t │ │ │ -0003b2d0: 6573 745f 6164 645f 616e 645f 6765 745f est_add_and_get_ │ │ │ -0003b2e0: 666c 6167 7328 746f 7272 656e 745f 666c flags(torrent_fl │ │ │ -0003b2f0: 6167 733a 3a73 746f 705f 7768 656e 5f72 ags::stop_when_r │ │ │ -0003b300: 6561 6479 293b 2073 6574 7469 6e67 2073 eady); setting s │ │ │ -0003b310: 746f 702d 7768 656e 2d72 6561 6479 2077 top-when-ready w │ │ │ -0003b320: 6865 6e20 616c 7265 6164 7920 7374 6f70 hen already stop │ │ │ -0003b330: 7065 6420 6861 7320 6e6f 2065 6666 6563 ped has no effec │ │ │ -0003b340: 742e 3c2f 7464 3e3c 2f74 723e 3c74 7220 t.

    │ │ │ -0003b390: 7468 6973 2074 6573 7420 6973 2066 6c61 this test is fla │ │ │ -0003b3a0: 6b79 2c20 7369 6e63 6520 7468 6520 746f ky, since the to │ │ │ -0003b3b0: 7272 656e 7420 7769 6c6c 2062 6563 6f6d rrent will becom │ │ │ -0003b3c0: 6520 7265 6164 7920 6265 666f 7265 0a61 e ready before.a │ │ │ -0003b3d0: 736b 696e 6720 666f 7220 7468 6520 666c sking for the fl │ │ │ -0003b3e0: 6167 732c 2061 6e64 2062 7920 7468 656e ags, and by then │ │ │ -0003b3f0: 2073 746f 705f 7768 656e 5f72 6561 6479 stop_when_ready │ │ │ -0003b400: 2077 696c 6c20 6861 7665 2062 6565 6e20 will have been │ │ │ -0003b410: 636c 6561 7265 640a 7465 7374 5f61 6464 cleared.test_add │ │ │ -0003b420: 5f61 6e64 5f67 6574 5f66 6c61 6773 2874 _and_get_flags(t │ │ │ -0003b430: 6f72 7265 6e74 5f66 6c61 6773 3a3a 7374 orrent_flags::st │ │ │ -0003b440: 6f70 5f77 6865 6e5f 7265 6164 7929 3b0a op_when_ready);. │ │ │ -0003b450: 7365 7474 696e 6720 7374 6f70 2d77 6865 setting stop-whe │ │ │ -0003b460: 6e2d 7265 6164 7920 7768 656e 2061 6c72 n-ready when alr │ │ │ -0003b470: 6561 6479 2073 746f 7070 6564 2068 6173 eady stopped has │ │ │ -0003b480: 206e 6f20 6566 6665 6374 2e3c 2f68 323e no effect.

    │ │ │ -0003b490: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ -0003b4a0: 5f66 6c61 6773 2e63 7070 3a32 3035 3c2f _flags.cpp:205

    re │ │ │ -0003b520: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../test/ │ │ │ -0003b560: 7465 7374 5f66 6c61 6773 2e63 7070 3a32 test_flags.cpp:2 │ │ │ -0003b570: 3039 3c2f 613e 3c2f 7464 3e3c 7464 3e63 09c │ │ │ -0003b580: 6861 6e67 6520 746f 2061 2064 6966 6665 hange to a diffe │ │ │ -0003b590: 7265 6e74 2074 6573 7420 7365 7475 702e rent test setup. │ │ │ -0003b5a0: 2063 7572 7265 6e74 6c79 2061 6c77 6179 currently alway │ │ │ -0003b5b0: 7320 7061 7573 6564 2e20 7465 7374 5f73 s paused. test_s │ │ │ -0003b5c0: 6574 5f61 6674 6572 5f61 6464 2874 6f72 et_after_add(tor │ │ │ -0003b5d0: 7265 6e74 5f66 6c61 6773 3a3a 7374 6f70 rent_flags::stop │ │ │ -0003b5e0: 5f77 6865 6e5f 7265 6164 7929 3b3c 2f74 _when_ready);

    chang │ │ │ -0003b640: 6520 746f 2061 2064 6966 6665 7265 6e74 e to a different │ │ │ -0003b650: 2074 6573 7420 7365 7475 702e 2063 7572 test setup. cur │ │ │ -0003b660: 7265 6e74 6c79 2061 6c77 6179 7320 7061 rently always pa │ │ │ -0003b670: 7573 6564 2e0a 7465 7374 5f73 6574 5f61 used..test_set_a │ │ │ -0003b680: 6674 6572 5f61 6464 2874 6f72 7265 6e74 fter_add(torrent │ │ │ -0003b690: 5f66 6c61 6773 3a3a 7374 6f70 5f77 6865 _flags::stop_whe │ │ │ -0003b6a0: 6e5f 7265 6164 7929 3b3c 2f68 323e 3c68 n_ready);

    ../test/test_f │ │ │ -0003b6c0: 6c61 6773 2e63 7070 3a32 3039 3c2f 6834 lags.cpp:209

    .test
    │ │ │ -0003b710: 5f73 6574 5f61 6674 6572 5f61 6464 2874  _set_after_add(t
    │ │ │ -0003b720: 6f72 7265 6e74 5f66 6c61 6773 3a3a 7375  orrent_flags::su
    │ │ │ -0003b730: 7065 725f 7365 6564 696e 6729 3b0a 7d0a  per_seeding);.}.
    │ │ │ -0003b740: 2365 6e64 6966 0a23 656e 6469 660a 0a54  #endif.#endif..T
    │ │ │ -0003b750: 4f52 5245 4e54 5f54 4553 5428 666c 6167  ORRENT_TEST(flag
    │ │ │ -0003b760: 5f73 6571 7565 6e74 6961 6c5f 646f 776e  _sequential_down
    │ │ │ -0003b770: 6c6f 6164 290a 7b0a 092f 2f20 7365 7175  load).{..// sequ
    │ │ │ -0003b780: 656e 7469 616c 2d64 6f77 6e6c 6f61 640a  ential-download.
    │ │ │ -0003b790: 0974 6573 745f 6164 645f 616e 645f 6765  .test_add_and_ge
    │ │ │ -0003b7a0: 745f 666c 6167 7328 746f 7272 656e 745f  t_flags(torrent_
    │ │ │ -0003b7b0: 666c 6167 733a 3a73 6571 7565 6e74 6961  flags::sequentia
    │ │ │ -0003b7c0: 6c5f 646f 776e 6c6f 6164 293b 0a09 7465  l_download);..te
    │ │ │ -0003b7d0: 7374 5f73 6574 5f61 6674 6572 5f61 6464  st_set_after_add
    │ │ │ -0003b7e0: 2874 6f72 7265 6e74 5f66 6c61 6773 3a3a  (torrent_flags::
    │ │ │ -0003b7f0: 7365 7175 656e 7469 616c 5f64 6f77 6e6c  sequential_downl
    │ │ │ -0003b800: 6f61 6429 3b0a 0974 6573 745f 756e 7365  oad);..test_unse
    │ │ │ -0003b810: 745f 6166 7465 725f 6164 6428 746f 7272  t_after_add(torr
    │ │ │ -0003b820: 656e 745f 666c 6167 733a 3a73 6571 7565  ent_flags::seque
    │ │ │ -0003b830: 6e74 6961 6c5f 646f 776e 6c6f 6164 293b  ntial_download);
    │ │ │ -0003b840: 0a7d 0a0a 2f2f 2074 6865 2073 746f 7020  .}..// the stop 
    │ │ │ -0003b850: 7768 656e 2072 6561 6479 2066 6c61 6720  when ready flag 
    │ │ │ -0003b860: 7769 6c6c 2062 6520 636c 6561 7265 6420  will be cleared 
    │ │ │ -0003b870: 7768 656e 2074 6865 2074 6f72 7265 6e74  when the torrent
    │ │ │ -0003b880: 2069 7320 7265 6164 7920 746f 2073 7461   is ready to sta
    │ │ │ -0003b890: 7274 0a2f 2f20 646f 776e 6c6f 6164 696e  rt.// downloadin
    │ │ │ -0003b8a0: 672e 0a2f 2f20 7369 6e63 6520 7468 6520  g..// since the 
    │ │ │ -0003b8b0: 706f 7369 785f 6469 736b 5f69 6f20 6973  posix_disk_io is
    │ │ │ -0003b8c0: 206e 6f74 2074 6872 6561 6465 642c 2074   not threaded, t
    │ │ │ -0003b8d0: 6869 7320 7769 6c6c 2068 6170 7065 6e20  his will happen 
    │ │ │ -0003b8e0: 696d 6d65 6469 6174 656c 790a 2369 6620  immediately.#if 
    │ │ │ -0003b8f0: 544f 5252 454e 545f 4841 5645 5f4d 4d41  TORRENT_HAVE_MMA
    │ │ │ -0003b900: 500a 544f 5252 454e 545f 5445 5354 2866  P.TORRENT_TEST(f
    │ │ │ -0003b910: 6c61 675f 7374 6f70 5f77 6865 6e5f 7265  lag_stop_when_re
    │ │ │ -0003b920: 6164 7929 0a7b 0a09 2f2f 2073 746f 702d  ady).{..// stop-
    │ │ │ -0003b930: 7768 656e 2d72 6561 6479 0a3c 6469 7620  when-ready.
    .test_u │ │ │ -0003b970: 6e73 6574 5f61 6674 6572 5f61 6464 2874 nset_after_add(t │ │ │ -0003b980: 6f72 7265 6e74 5f66 6c61 6773 3a3a 7374 orrent_flags::st │ │ │ -0003b990: 6f70 5f77 6865 6e5f 7265 6164 7929 3b0a op_when_ready);. │ │ │ -0003b9a0: 3c2f 6469 763e 7d0a 2365 6e64 6966 0a0a
    }.#endif.. │ │ │ -0003b9b0: 544f 5252 454e 545f 5445 5354 2866 6c61 TORRENT_TEST(fla │ │ │ -0003b9c0: 675f 6469 7361 626c 655f 6468 7429 0a7b g_disable_dht).{ │ │ │ -0003b9d0: 0a09 7465 7374 5f61 6464 5f61 6e64 5f67 ..test_add_and_g │ │ │ -0003b9e0: 6574 5f66 6c61 6773 2874 6f72 7265 6e74 et_flags(torrent │ │ │ -0003b9f0: 5f66 6c61 6773 3a3a 6469 7361 626c 655f _flags::disable_ │ │ │ -0003ba00: 6468 7429 3b0a 0974 6573 745f 7365 745f dht);..test_set_ │ │ │ -0003ba10: 6166 7465 725f 6164 6428 746f 7272 656e after_add(torren │ │ │ -0003ba20: 745f 666c 6167 733a 3a64 6973 6162 6c65 t_flags::disable │ │ │ -0003ba30: 5f64 6874 293b 0a09 7465 7374 5f75 6e73 _dht);..test_uns │ │ │ -0003ba40: 6574 5f61 6674 6572 5f61 6464 2874 6f72 et_after_add(tor │ │ │ -0003ba50: 7265 6e74 5f66 6c61 6773 3a3a 6469 7361 rent_flags::disa │ │ │ -0003ba60: 626c 655f 6468 7429 3b0a 7d0a 0a0a 544f ble_dht);.}...TO │ │ │ -0003ba70: 5252 454e 545f 5445 5354 2866 6c61 675f RRENT_TEST(flag_ │ │ │ -0003ba80: 6469 7361 626c 655f 6c73 6429 0a7b 0a09 disable_lsd).{.. │ │ │ -0003ba90: 7465 7374 5f61 6464 5f61 6e64 5f67 6574 test_add_and_get │ │ │ -0003baa0: 5f66 6c61 6773 2874 6f72 7265 6e74 5f66 _flags(torrent_f │ │ │ -0003bab0: 6c61 6773 3a3a 6469 7361 626c 655f 6c73 lags::disable_ls │ │ │ -0003bac0: 6429 3b0a 0974 6573 745f 7365 745f 6166 d);..test_set_af │ │ │ -0003bad0: 7465 725f 6164 6428 746f 7272 656e 745f ter_add(torrent_ │ │ │ -0003bae0: 666c 6167 733a 3a64 6973 6162 6c65 5f6c flags::disable_l │ │ │ -0003baf0: 7364 293b 0a09 7465 7374 5f75 6e73 6574 sd);..test_unset │ │ │ -0003bb00: 5f61 6674 6572 5f61 6464 2874 6f72 7265 _after_add(torre │ │ │ -0003bb10: 6e74 5f66 6c61 6773 3a3a 6469 7361 626c nt_flags::disabl │ │ │ -0003bb20: 655f 6c73 6429 3b0a 7d0a 0a54 4f52 5245 e_lsd);.}..TORRE │ │ │ -0003bb30: 4e54 5f54 4553 5428 666c 6167 5f64 6973 NT_TEST(flag_dis │ │ │ -0003bb40: 6162 6c65 5f70 6578 290a 7b0a 0974 6573 able_pex).{..tes │ │ │ -0003bb50: 745f 6164 645f 616e 645f 6765 745f 666c t_add_and_get_fl │ │ │ -0003bb60: 6167 7328 746f 7272 656e 745f 666c 6167 ags(torrent_flag │ │ │ -0003bb70: 733a 3a64 6973 6162 6c65 5f70 6578 293b s::disable_pex); │ │ │ -0003bb80: 0a09 7465 7374 5f73 6574 5f61 6674 6572 ..test_set_after │ │ │ -0003bb90: 5f61 6464 2874 6f72 7265 6e74 5f66 6c61 _add(torrent_fla │ │ │ -0003bba0: 6773 3a3a 6469 7361 626c 655f 7065 7829 gs::disable_pex) │ │ │ -0003bbb0: 3b0a 0974 6573 745f 756e 7365 745f 6166 ;..test_unset_af │ │ │ -0003bbc0: 7465 725f 6164 6428 746f 7272 656e 745f ter_add(torrent_ │ │ │ -0003bbd0: 666c 6167 733a 3a64 6973 6162 6c65 5f70 flags::disable_p │ │ │ -0003bbe0: 6578 293b 0a7d 0a3c 2f70 7265 3e3c 2f74 ex);.}.
    relevanc │ │ │ -0003bc20: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../test/test_f │ │ │ -0003bc60: 696c 655f 7374 6f72 6167 652e 6370 703a ile_storage.cpp: │ │ │ -0003bc70: 3132 3335 3c2f 613e 3c2f 7464 3e3c 7464 1235test file attri │ │ │ -0003bc90: 6275 7465 733c 2f74 643e 3c2f 7472 3e3c butes< │ │ │ -0003bca0: 7472 2069 643d 2231 3435 2220 7374 796c tr id="145" styl │ │ │ -0003bcb0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -0003bcc0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -0003bcd0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -0003bce0: 6832 3e74 6573 7420 6669 6c65 2061 7474 h2>test file att │ │ │ -0003bcf0: 7269 6275 7465 733c 2f68 323e 3c68 343e ributes

    │ │ │ -0003bd00: 2e2e 2f74 6573 742f 7465 7374 5f66 696c ../test/test_fil │ │ │ -0003bd10: 655f 7374 6f72 6167 652e 6370 703a 3132 e_storage.cpp:12 │ │ │ -0003bd20: 3335 3c2f 6834 3e3c 7072 6520 7374 796c 35

    relevance 
    │ │ │ -0003bda0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872  ;0../t
    │ │ │ -0003bdd0: 6573 742f 7465 7374 5f66 696c 655f 7374  est/test_file_st
    │ │ │ -0003bde0: 6f72 6167 652e 6370 703a 3132 3336 3c2f  orage.cpp:1236test 
    │ │ │ -0003be00: 7379 6d6c 696e 6b73 3c2f 7464 3e3c 2f74  symlinks

    test symli │ │ │ -0003be60: 6e6b 733c 2f68 323e 3c68 343e 2e2e 2f74 nks

    ../t │ │ │ -0003be70: 6573 742f 7465 7374 5f66 696c 655f 7374 est/test_file_st │ │ │ -0003be80: 6f72 6167 652e 6370 703a 3132 3336 3c2f orage.cpp:1236

    re │ │ │ -0003bf00: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0
    ../test/ │ │ │ -0003bf40: 7465 7374 5f66 6173 745f 6578 7465 6e73 test_fast_extens │ │ │ -0003bf50: 696f 6e2e 6370 703a 3132 3238 3c2f 613e ion.cpp:1228 │ │ │ -0003bf60: 3c2f 7464 3e3c 7464 3e74 6573 7420 7365 test se │ │ │ -0003bf70: 6e64 696e 6720 696e 7661 6c69 6420 7265 nding invalid re │ │ │ -0003bf80: 7175 6573 7473 2028 6f75 7420 6f66 2062 quests (out of b │ │ │ -0003bf90: 6f75 6e64 2070 6965 6365 2069 6e64 6578 ound piece index │ │ │ -0003bfa0: 2c20 6f66 6673 6574 7320 616e 6420 7369 , offsets and si │ │ │ -0003bfb0: 7a65 7329 3c2f 7464 3e3c 2f74 723e 3c74 zes)test sending i │ │ │ -0003c010: 6e76 616c 6964 2072 6571 7565 7374 7320 nvalid requests │ │ │ -0003c020: 286f 7574 206f 6620 626f 756e 6420 7069 (out of bound pi │ │ │ -0003c030: 6563 6520 696e 6465 782c 206f 6666 7365 ece index, offse │ │ │ -0003c040: 7473 2061 6e64 0a73 697a 6573 293c 2f68 ts and.sizes)

    ../test/te │ │ │ -0003c060: 7374 5f66 6173 745f 6578 7465 6e73 696f st_fast_extensio │ │ │ -0003c070: 6e2e 6370 703a 3132 3238 3c2f 6834 3e3c n.cpp:1228

    < │ │ │ -0003c080: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -0003c090: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -0003c0a0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -0003c0b0: 7820 2364 6464 3b22 3e3c 2f70 7265 3e3c x #ddd;">
    < │ │ │ -0003c0c0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -0003c0f0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -0003c100: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test │ │ │ -0003c130: 5f64 6874 2e63 7070 3a34 3838 3c2f 613e _dht.cpp:488 │ │ │ -0003c140: 3c2f 7464 3e3c 7464 3e63 6865 636b 2074 check t │ │ │ -0003c150: 6f20 6d61 6b65 2073 7572 6520 7468 6520 o make sure the │ │ │ -0003c160: 2262 6573 7422 2069 7465 6d73 2061 7265 "best" items are │ │ │ -0003c170: 2073 746f 7265 643c 2f74 643e 3c2f 7472 stored

    check to ma │ │ │ -0003c1d0: 6b65 2073 7572 6520 7468 6520 2262 6573 ke sure the "bes │ │ │ -0003c1e0: 7422 2069 7465 6d73 2061 7265 2073 746f t" items are sto │ │ │ -0003c1f0: 7265 643c 2f68 323e 3c68 343e 2e2e 2f74 red

    ../t │ │ │ -0003c200: 6573 742f 7465 7374 5f64 6874 2e63 7070 est/test_dht.cpp │ │ │ -0003c210: 3a34 3838 3c2f 6834 3e3c 7072 6520 7374 :488

    ..., msg_args
    │ │ │ -0003c260: 2829 2e74 6172 6765 7428 6974 656d 735b  ().target(items[
    │ │ │ -0003c270: 6a5d 2e74 6172 6765 7429 293b 0a0a 0909  j].target));....
    │ │ │ -0003c280: 6b65 795f 6465 7363 5f74 2063 6f6e 7374  key_desc_t const
    │ │ │ -0003c290: 2064 6573 635b 5d20 3d0a 0909 7b0a 0909   desc[] =...{...
    │ │ │ -0003c2a0: 097b 2022 7222 2c20 6264 6563 6f64 655f  .{ "r", bdecode_
    │ │ │ -0003c2b0: 6e6f 6465 3a3a 6469 6374 5f74 2c20 302c  node::dict_t, 0,
    │ │ │ -0003c2c0: 206b 6579 5f64 6573 635f 743a 3a70 6172   key_desc_t::par
    │ │ │ -0003c2d0: 7365 5f63 6869 6c64 7265 6e20 7d2c 0a09  se_children },..
    │ │ │ -0003c2e0: 0909 097b 2022 7622 2c20 6264 6563 6f64  ...{ "v", bdecod
    │ │ │ -0003c2f0: 655f 6e6f 6465 3a3a 6469 6374 5f74 2c20  e_node::dict_t, 
    │ │ │ -0003c300: 302c 2030 7d2c 0a09 0909 097b 2022 6964  0, 0},.....{ "id
    │ │ │ -0003c310: 222c 2062 6465 636f 6465 5f6e 6f64 653a  ", bdecode_node:
    │ │ │ -0003c320: 3a73 7472 696e 675f 742c 2032 302c 206b  :string_t, 20, k
    │ │ │ -0003c330: 6579 5f64 6573 635f 743a 3a6c 6173 745f  ey_desc_t::last_
    │ │ │ -0003c340: 6368 696c 647d 2c0a 0909 097b 2022 7922  child},....{ "y"
    │ │ │ -0003c350: 2c20 6264 6563 6f64 655f 6e6f 6465 3a3a  , bdecode_node::
    │ │ │ -0003c360: 7374 7269 6e67 5f74 2c20 312c 2030 7d2c  string_t, 1, 0},
    │ │ │ -0003c370: 0a09 097d 3b0a 0a09 0962 6465 636f 6465  ...};....bdecode
    │ │ │ -0003c380: 5f6e 6f64 6520 7061 7273 6564 5b34 5d3b  _node parsed[4];
    │ │ │ -0003c390: 0a09 0963 6861 7220 6572 726f 725f 7374  ...char error_st
    │ │ │ -0003c3a0: 7269 6e67 5b32 3030 5d3b 0a0a 0909 696e  ring[200];....in
    │ │ │ -0003c3b0: 7420 7265 7420 3d20 7665 7269 6679 5f6d  t ret = verify_m
    │ │ │ -0003c3c0: 6573 7361 6765 2872 6573 706f 6e73 652c  essage(response,
    │ │ │ -0003c3d0: 2064 6573 632c 2070 6172 7365 642c 2065   desc, parsed, e
    │ │ │ -0003c3e0: 7272 6f72 5f73 7472 696e 6729 3b0a 0909  rror_string);...
    │ │ │ -0003c3f0: 6966 2028 7265 7429 0a09 097b 0a09 0909  if (ret)...{....
    │ │ │ -0003c400: 6974 656d 735f 6e75 6d2e 696e 7365 7274  items_num.insert
    │ │ │ -0003c410: 2869 7465 6d73 5f6e 756d 2e62 6567 696e  (items_num.begin
    │ │ │ -0003c420: 2829 2c20 6a29 3b0a 0909 7d0a 097d 0a0a  (), j);...}..}..
    │ │ │ -0003c430: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .T │ │ │ -0003c460: 4553 545f 4551 5541 4c28 6974 656d 735f EST_EQUAL(items_ │ │ │ -0003c470: 6e75 6d2e 7369 7a65 2829 2c20 3429 3b0a num.size(), 4);. │ │ │ -0003c480: 3c2f 6469 763e 7d0a 0a69 6e74 2073 756d
    }..int sum │ │ │ -0003c490: 5f64 6973 7461 6e63 655f 6578 7028 696e _distance_exp(in │ │ │ -0003c4a0: 7420 732c 206e 6f64 655f 656e 7472 7920 t s, node_entry │ │ │ -0003c4b0: 636f 6e73 7426 616d 703b 2065 2c20 6e6f const& e, no │ │ │ -0003c4c0: 6465 5f69 6420 636f 6e73 7426 616d 703b de_id const& │ │ │ -0003c4d0: 2072 6566 290a 7b0a 0972 6574 7572 6e20 ref).{..return │ │ │ -0003c4e0: 7320 2b20 6469 7374 616e 6365 5f65 7870 s + distance_exp │ │ │ -0003c4f0: 2865 2e69 642c 2072 6566 293b 0a7d 0a0a (e.id, ref);.}.. │ │ │ -0003c500: 7374 643a 3a76 6563 746f 7226 6c74 3b74 std::vector<t │ │ │ -0003c510: 6370 3a3a 656e 6470 6f69 6e74 2667 743b cp::endpoint> │ │ │ -0003c520: 2067 5f67 6f74 5f70 6565 7273 3b0a 0a76 g_got_peers;..v │ │ │ -0003c530: 6f69 6420 6765 745f 7065 6572 735f 6362 oid get_peers_cb │ │ │ -0003c540: 2873 7464 3a3a 7665 6374 6f72 266c 743b (std::vector< │ │ │ -0003c550: 7463 703a 3a65 6e64 706f 696e 7426 6774 tcp::endpoint> │ │ │ -0003c560: 3b20 636f 6e73 7426 616d 703b 2070 6565 ; const& pee │ │ │ -0003c570: 7273 290a 7b0a 0967 5f67 6f74 5f70 6565 rs).{..g_got_pee │ │ │ -0003c580: 7273 2e69 6e73 6572 7428 675f 676f 745f rs.insert(g_got_ │ │ │ -0003c590: 7065 6572 732e 656e 6428 292c 2070 6565 peers.end(), pee │ │ │ -0003c5a0: 7273 2e62 6567 696e 2829 2c20 7065 6572 rs.begin(), peer │ │ │ -0003c5b0: 732e 656e 6428 2929 3b0a 7d0a 0a73 7464 s.end());.}..std │ │ │ -0003c5c0: 3a3a 7665 6374 6f72 266c 743b 6468 743a ::vector<dht: │ │ │ -0003c5d0: 3a69 7465 6d26 6774 3b20 675f 676f 745f :item> g_got_ │ │ │ -0003c5e0: 6974 656d 733b 0a64 6874 3a3a 6974 656d items;.dht::item │ │ │ -0003c5f0: 2067 5f70 7574 5f69 7465 6d3b 0a69 6e74 g_put_item;.int │ │ │ -0003c600: 2067 5f70 7574 5f63 6f75 6e74 3b0a 0a76 g_put_count;..v │ │ │ -0003c610: 6f69 6420 6765 745f 6d75 7461 626c 655f oid get_mutable_ │ │ │ -0003c620: 6974 656d 5f63 6228 6468 743a 3a69 7465 item_cb(dht::ite │ │ │ -0003c630: 6d20 636f 6e73 7426 616d 703b 2069 2c20 m const& i, │ │ │ -0003c640: 626f 6f6c 2061 290a 7b0a 0969 6620 2821 bool a).{..if (! │ │ │ -0003c650: 6129 2072 6574 7572 6e3b 0a09 6966 2028 a) return;..if ( │ │ │ -0003c660: 2169 2e65 6d70 7479 2829 290a 0909 675f !i.empty())...g_ │ │ │ -0003c670: 676f 745f 6974 656d 732e 7075 7368 5f62 got_items.push_b │ │ │ -0003c680: 6163 6b28 6929 3b0a 7d0a 0a76 6f69 6420 ack(i);.}..void │ │ │ -0003c690: 7075 745f 6d75 7461 626c 655f 6974 656d put_mutable_item │ │ │ -0003c6a0: 5f64 6174 615f 6362 2864 6874 3a3a 6974 _data_cb(dht::it │ │ │ -0003c6b0: 656d 2661 6d70 3b20 6929 0a7b 0a09 6966 em& i).{..if │ │ │ -0003c6c0: 2028 2169 2e65 6d70 7479 2829 290a 0909 (!i.empty())... │ │ │ -0003c6d0: 675f 676f 745f 6974 656d 732e 7075 7368 g_got_items.push │ │ │ -0003c6e0: 5f62 6163 6b28 6929 3b0a 0a3c 2f70 7265 _back(i);..
    rele │ │ │ -0003c720: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../test/te │ │ │ -0003c760: 7374 5f64 6874 2e63 7070 3a33 3233 393c st_dht.cpp:3239< │ │ │ -0003c770: 2f61 3e3c 2f74 643e 3c74 643e 7468 6973 /a>this │ │ │ -0003c780: 2077 6f6e 2774 2077 6f72 6b20 6265 6361 won't work beca │ │ │ -0003c790: 7573 6520 7468 6520 7365 636f 6e64 206e use the second n │ │ │ -0003c7a0: 6f64 6520 6973 6e27 7420 7069 6e67 6564 ode isn't pinged │ │ │ -0003c7b0: 2073 6f20 6974 2077 6f6e 7420 6265 2061 so it wont be a │ │ │ -0003c7c0: 6464 6564 2074 6f20 7468 6520 726f 7574 dded to the rout │ │ │ -0003c7d0: 696e 6720 7461 626c 653c 2f74 643e 3c2f ing table

    this won' │ │ │ -0003c830: 7420 776f 726b 2062 6563 6175 7365 2074 t work because t │ │ │ -0003c840: 6865 2073 6563 6f6e 6420 6e6f 6465 2069 he second node i │ │ │ -0003c850: 736e 2774 2070 696e 6765 6420 736f 2069 sn't pinged so i │ │ │ -0003c860: 7420 776f 6e74 0a62 6520 6164 6465 6420 t wont.be added │ │ │ -0003c870: 746f 2074 6865 2072 6f75 7469 6e67 2074 to the routing t │ │ │ -0003c880: 6162 6c65 3c2f 6832 3e3c 6834 3e2e 2e2f able

    ../ │ │ │ -0003c890: 7465 7374 2f74 6573 745f 6468 742e 6370 test/test_dht.cp │ │ │ -0003c8a0: 703a 3332 3339 3c2f 6834 3e3c 7072 6520 p:3239

    .bool ret =
    │ │ │ -0003c8f0: 2076 6572 6966 795f 6d65 7373 6167 6528   verify_message(
    │ │ │ -0003c900: 7265 7175 6573 742c 2067 6574 5f69 7465  request, get_ite
    │ │ │ -0003c910: 6d5f 6465 7363 5f72 6f2c 2070 6172 7365  m_desc_ro, parse
    │ │ │ -0003c920: 642c 2065 7272 6f72 5f73 7472 696e 6729  d, error_string)
    │ │ │ -0003c930: 3b0a 0a09 5445 5354 5f43 4845 434b 2872  ;...TEST_CHECK(r
    │ │ │ -0003c940: 6574 293b 0a09 5445 5354 5f45 5155 414c  et);..TEST_EQUAL
    │ │ │ -0003c950: 2870 6172 7365 645b 335d 2e69 6e74 5f76  (parsed[3].int_v
    │ │ │ -0003c960: 616c 7565 2829 2c20 3129 3b0a 0a09 2f2f  alue(), 1);...//
    │ │ │ -0003c970: 2073 686f 756c 6420 6861 7665 206f 6e65   should have one
    │ │ │ -0003c980: 206e 6f64 6520 6e6f 772c 2077 6869 6368   node now, which
    │ │ │ -0003c990: 2069 7320 342e 342e 342e 343a 3132 3334   is 4.4.4.4:1234
    │ │ │ -0003c9a0: 0a09 5445 5354 5f45 5155 414c 2873 7464  ..TEST_EQUAL(std
    │ │ │ -0003c9b0: 3a3a 6765 7426 6c74 3b30 2667 743b 286e  ::get<0>(n
    │ │ │ -0003c9c0: 6f64 652e 7369 7a65 2829 292c 2031 293b  ode.size()), 1);
    │ │ │ -0003c9d0: 0a09 2f2f 2061 6e64 206e 6f20 7265 706c  ..// and no repl
    │ │ │ -0003c9e0: 6163 656d 656e 7420 6e6f 6465 730a 0954  acement nodes..T
    │ │ │ -0003c9f0: 4553 545f 4551 5541 4c28 7374 643a 3a67  EST_EQUAL(std::g
    │ │ │ -0003ca00: 6574 266c 743b 3126 6774 3b28 6e6f 6465  et<1>(node
    │ │ │ -0003ca10: 2e73 697a 6528 2929 2c20 3029 3b0a 0a09  .size()), 0);...
    │ │ │ -0003ca20: 2f2f 206e 6f77 2c20 6469 7361 626c 6520  // now, disable 
    │ │ │ -0003ca30: 7265 6164 5f6f 6e6c 792c 2074 7279 2061  read_only, try a
    │ │ │ -0003ca40: 6761 696e 2e0a 0967 5f73 656e 745f 7061  gain...g_sent_pa
    │ │ │ -0003ca50: 636b 6574 732e 636c 6561 7228 293b 0a09  ckets.clear();..
    │ │ │ -0003ca60: 7365 7474 2e73 6574 5f62 6f6f 6c28 7365  sett.set_bool(se
    │ │ │ -0003ca70: 7474 696e 6773 5f70 6163 6b3a 3a64 6874  ttings_pack::dht
    │ │ │ -0003ca80: 5f72 6561 645f 6f6e 6c79 2c20 6661 6c73  _read_only, fals
    │ │ │ -0003ca90: 6529 3b0a 0a09 7365 6e64 5f64 6874 5f72  e);...send_dht_r
    │ │ │ -0003caa0: 6571 7565 7374 286e 6f64 652c 2022 6765  equest(node, "ge
    │ │ │ -0003cab0: 7422 2c20 736f 7572 6365 2c20 2661 6d70  t", source, &
    │ │ │ -0003cac0: 3b72 6573 706f 6e73 6529 3b0a 092f 2f20  ;response);..// 
    │ │ │ -0003cad0: 7365 6e64 6572 2073 686f 756c 6420 6265  sender should be
    │ │ │ -0003cae0: 2061 6464 6564 2074 6f20 7265 706c 6163   added to replac
    │ │ │ -0003caf0: 656d 656e 7420 6275 636b 6574 0a09 5445  ement bucket..TE
    │ │ │ -0003cb00: 5354 5f45 5155 414c 2873 7464 3a3a 6765  ST_EQUAL(std::ge
    │ │ │ -0003cb10: 7426 6c74 3b31 2667 743b 286e 6f64 652e  t<1>(node.
    │ │ │ -0003cb20: 7369 7a65 2829 292c 2031 293b 0a0a 0967  size()), 1);...g
    │ │ │ -0003cb30: 5f73 656e 745f 7061 636b 6574 732e 636c  _sent_packets.cl
    │ │ │ -0003cb40: 6561 7228 293b 0a23 6966 2030 0a3c 6469  ear();.#if 0..targ
    │ │ │ -0003cb80: 6574 203d 2067 656e 6572 6174 655f 6e65  et = generate_ne
    │ │ │ -0003cb90: 7874 2829 3b0a 3c2f 6469 763e 096e 6f64  xt();..nod
    │ │ │ -0003cba0: 652e 6765 745f 6974 656d 2874 6172 6765  e.get_item(targe
    │ │ │ -0003cbb0: 742c 2067 6574 5f69 6d6d 7574 6162 6c65  t, get_immutable
    │ │ │ -0003cbc0: 5f69 7465 6d5f 6362 293b 0a0a 092f 2f20  _item_cb);...// 
    │ │ │ -0003cbd0: 7369 6e63 6520 7765 2068 6176 6520 3220  since we have 2 
    │ │ │ -0003cbe0: 6e6f 6465 732c 2077 6520 7368 6f75 6c64  nodes, we should
    │ │ │ -0003cbf0: 2068 6176 6520 7477 6f20 7061 636b 6574   have two packet
    │ │ │ -0003cc00: 732e 0a09 5445 5354 5f45 5155 414c 2867  s...TEST_EQUAL(g
    │ │ │ -0003cc10: 5f73 656e 745f 7061 636b 6574 732e 7369  _sent_packets.si
    │ │ │ -0003cc20: 7a65 2829 2c20 3229 3b0a 0a09 2f2f 2062  ze(), 2);...// b
    │ │ │ -0003cc30: 6f74 6820 6f66 2074 6865 6d20 7368 6f75  oth of them shou
    │ │ │ -0003cc40: 6c64 6e27 7420 6861 7665 2061 2027 726f  ldn't have a 'ro
    │ │ │ -0003cc50: 2720 6b65 792e 0a09 6e6f 6465 5f66 726f  ' key...node_fro
    │ │ │ -0003cc60: 6d5f 656e 7472 7928 675f 7365 6e74 5f70  m_entry(g_sent_p
    │ │ │ -0003cc70: 6163 6b65 7473 2e66 726f 6e74 2829 2e73  ackets.front().s
    │ │ │ -0003cc80: 6563 6f6e 642c 2072 6571 7565 7374 293b  econd, request);
    │ │ │ -0003cc90: 0a09 7265 7420 3d20 7665 7269 6679 5f6d  ..ret = verify_m
    │ │ │ -0003cca0: 6573 7361 6765 2872 6571 7565 7374 2c20  essage(request, 
    │ │ │ -0003ccb0: 6765 745f 6974 656d 5f64 6573 635f 726f  get_item_desc_ro
    │ │ │ -0003ccc0: 2c20 7061 7273 6564 2c20 6572 726f 725f  , parsed, error_
    │ │ │ -0003ccd0: 7374 7269 6e67 293b 0a0a 0954 4553 545f  string);...TEST_
    │ │ │ -0003cce0: 4348 4543 4b28 7265 7429 3b0a 0954 4553  CHECK(ret);..TES
    │ │ │ -0003ccf0: 545f 4348 4543 4b28 2170 6172 7365 645b  T_CHECK(!parsed[
    │ │ │ -0003cd00: 335d 293b 0a0a 096e 6f64 655f 6672 6f6d  3]);...node_from
    │ │ │ -0003cd10: 5f65 6e74 7279 2867 5f73 656e 745f 7061  _entry(g_sent_pa
    │ │ │ -0003cd20: 636b 6574 732e 6261 636b 2829 2e73 6563  ckets.back().sec
    │ │ │ -0003cd30: 6f6e 642c 2072 6571 7565 7374 293b 0a09  ond, request);..
    │ │ │ -0003cd40: 7265 7420 3d20 7665 7269 6679 5f6d 6573  ret = verify_mes
    │ │ │ -0003cd50: 7361 6765 2872 6571 7565 7374 2c20 6765  sage(request, ge
    │ │ │ -0003cd60: 745f 6974 656d 5f64 6573 635f 726f 2c20  t_item_desc_ro, 
    │ │ │ -0003cd70: 7061 7273 6564 2c20 6572 726f 725f 7374  parsed, error_st
    │ │ │ -0003cd80: 7269 6e67 293b 0a0a 0954 4553 545f 4348  ring);...TEST_CH
    │ │ │ -0003cd90: 4543 4b28 7265 7429 3b0a 0954 4553 545f  ECK(ret);..TEST_
    │ │ │ -0003cda0: 4348 4543 4b28 2170 6172 7365 645b 335d  CHECK(!parsed[3]
    │ │ │ -0003cdb0: 293b 0a23 656e 6469 660a 7d0a 0a54 4f52  );.#endif.}..TOR
    │ │ │ -0003cdc0: 5245 4e54 5f54 4553 5428 7270 635f 7265  RENT_TEST(rpc_re
    │ │ │ -0003cdd0: 706c 795f 6967 6e6f 7265 735f 7772 6f6e  ply_ignores_wron
    │ │ │ -0003cde0: 675f 706f 7274 290a 7b0a 0961 7574 6f20  g_port).{..auto 
    │ │ │ -0003cdf0: 7365 7474 203d 2074 6573 745f 7365 7474  sett = test_sett
    │ │ │ -0003ce00: 696e 6773 2829 3b0a 096d 6f63 6b5f 736f  ings();..mock_so
    │ │ │ -0003ce10: 636b 6574 2073 3b0a 0961 7574 6f20 6c73  cket s;..auto ls
    │ │ │ -0003ce20: 203d 2064 756d 6d79 5f6c 6973 7465 6e5f   = dummy_listen_
    │ │ │ -0003ce30: 736f 636b 6574 3428 293b 0a09 6f62 7320  socket4();..obs 
    │ │ │ -0003ce40: 6f62 7365 7276 6572 3b0a 0963 6f75 6e74  observer;..count
    │ │ │ -0003ce50: 6572 7320 636e 743b 0a0a 0964 6874 3a3a  ers cnt;...dht::
    │ │ │ -0003ce60: 726f 7574 696e 675f 7461 626c 6520 7461  routing_table ta
    │ │ │ -0003ce70: 626c 6528 6e6f 6465 5f69 6428 292c 2075  ble(node_id(), u
    │ │ │ -0003ce80: 6470 3a3a 7634 2829 2c20 382c 2073 6574  dp::v4(), 8, set
    │ │ │ -0003ce90: 742c 2026 616d 703b 6f62 7365 7276 6572  t, &observer
    │ │ │ -0003cea0: 293b 0a09 6468 743a 3a72 7063 5f6d 616e  );..dht::rpc_man
    │ │ │ -0003ceb0: 6167 6572 2072 7063 286e 6f64 655f 6964  ager rpc(node_id
    │ │ │ -0003cec0: 2829 2c20 7365 7474 2c20 7461 626c 652c  (), sett, table,
    │ │ │ -0003ced0: 206c 732c 2026 616d 703b 732c 2026 616d   ls, &s, &am
    │ │ │ -0003cee0: 703b 6f62 7365 7276 6572 293b 0a3c 2f70  p;observer);.

    re │ │ │ -0003cf20: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0
    ../test/ │ │ │ -0003cf60: 7465 7374 5f64 6874 2e63 7070 3a34 3135 test_dht.cpp:415 │ │ │ -0003cf70: 303c 2f61 3e3c 2f74 643e 3c74 643e 7465 0te │ │ │ -0003cf80: 7374 206f 6266 7573 6361 7465 645f 6765 st obfuscated_ge │ │ │ -0003cf90: 745f 7065 6572 733c 2f74 643e 3c2f 7472 t_peers

    test obfusc │ │ │ -0003cff0: 6174 6564 5f67 6574 5f70 6565 7273 3c2f ated_get_peers

    ../test/t │ │ │ -0003d010: 6573 745f 6468 742e 6370 703a 3431 3530 est_dht.cpp:4150 │ │ │ -0003d020: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -0003d060: 0954 4553 545f 4348 4543 4b28 736d 2e68  .TEST_CHECK(sm.h
    │ │ │ -0003d070: 6173 5f71 756f 7461 2829 293b 0a09 7d29  as_quota());..})
    │ │ │ -0003d080: 3b0a 7d0a 0a54 4f52 5245 4e54 5f54 4553  ;.}..TORRENT_TES
    │ │ │ -0003d090: 5428 7261 7465 5f6c 696d 6974 5f61 6363  T(rate_limit_acc
    │ │ │ -0003d0a0: 7275 655f 6c69 6d69 7429 0a7b 0a09 6175  rue_limit).{..au
    │ │ │ -0003d0b0: 783a 3a73 6573 7369 6f6e 5f73 6574 7469  x::session_setti
    │ │ │ -0003d0c0: 6e67 7320 7365 7474 3b0a 0973 6574 742e  ngs sett;..sett.
    │ │ │ -0003d0d0: 7365 745f 696e 7428 7365 7474 696e 6773  set_int(settings
    │ │ │ -0003d0e0: 5f70 6163 6b3a 3a64 6874 5f75 706c 6f61  _pack::dht_uploa
    │ │ │ -0003d0f0: 645f 7261 7465 5f6c 696d 6974 2c20 7374  d_rate_limit, st
    │ │ │ -0003d100: 643a 3a6e 756d 6572 6963 5f6c 696d 6974  d::numeric_limit
    │ │ │ -0003d110: 7326 6c74 3b69 6e74 2667 743b 3a3a 6d61  s<int>::ma
    │ │ │ -0003d120: 7828 2929 3b0a 0a09 7465 7374 5f72 6174  x());...test_rat
    │ │ │ -0003d130: 655f 6c69 6d69 7428 7365 7474 2c20 5b5d  e_limit(sett, []
    │ │ │ -0003d140: 286c 743a 3a64 6874 3a3a 736f 636b 6574  (lt::dht::socket
    │ │ │ -0003d150: 5f6d 616e 6167 6572 2661 6d70 3b20 736d  _manager& sm
    │ │ │ -0003d160: 2920 7b0a 0909 5445 5354 5f43 4845 434b  ) {...TEST_CHECK
    │ │ │ -0003d170: 2873 6d2e 6861 735f 7175 6f74 6128 2929  (sm.has_quota())
    │ │ │ -0003d180: 3b0a 0909 666f 7220 2869 6e74 2069 203d  ;...for (int i =
    │ │ │ -0003d190: 2030 3b20 6920 266c 743b 2031 303b 202b   0; i < 10; +
    │ │ │ -0003d1a0: 2b69 290a 0909 7b0a 0909 0973 7464 3a3a  +i)...{....std::
    │ │ │ -0003d1b0: 7468 6973 5f74 6872 6561 643a 3a73 6c65  this_thread::sle
    │ │ │ -0003d1c0: 6570 5f66 6f72 286d 696c 6c69 7365 636f  ep_for(milliseco
    │ │ │ -0003d1d0: 6e64 7328 3530 3029 293b 0a09 0909 5445  nds(500));....TE
    │ │ │ -0003d1e0: 5354 5f43 4845 434b 2873 6d2e 6861 735f  ST_CHECK(sm.has_
    │ │ │ -0003d1f0: 7175 6f74 6128 2929 3b0a 0909 7d0a 097d  quota());...}..}
    │ │ │ -0003d200: 293b 0a7d 0a0a 0a3c 6469 7620 7374 796c  );.}...
    .
    #els │ │ │ -0003d240: 650a 544f 5252 454e 545f 5445 5354 2864 e.TORRENT_TEST(d │ │ │ -0003d250: 6874 290a 7b0a 092f 2f20 6475 6d6d 7920 ht).{..// dummy │ │ │ -0003d260: 6468 7420 7465 7374 0a09 5445 5354 5f43 dht test..TEST_C │ │ │ -0003d270: 4845 434b 2874 7275 6529 3b0a 7d0a 0a23 HECK(true);.}..# │ │ │ -0003d280: 656e 6469 660a 3c2f 7072 653e 3c2f 7464 endif.
    relevance │ │ │ -0003d2c0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -0003d2d0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../test/test_bl │ │ │ -0003d300: 6f6f 6d5f 6669 6c74 6572 2e63 7070 3a31 oom_filter.cpp:1 │ │ │ -0003d310: 3335 3c2f 613e 3c2f 7464 3e3c 7464 3e74 35t │ │ │ -0003d320: 6573 7420 7369 7a65 2829 3c2f 7464 3e3c est size()< │ │ │ -0003d330: 2f74 723e 3c74 7220 6964 3d22 3135 3122 /tr>

    test siz │ │ │ -0003d380: 6528 293c 2f68 323e 3c68 343e 2e2e 2f74 e()

    ../t │ │ │ -0003d390: 6573 742f 7465 7374 5f62 6c6f 6f6d 5f66 est/test_bloom_f │ │ │ -0003d3a0: 696c 7465 722e 6370 703a 3133 353c 2f68 ilter.cpp:135
    rel
    │ │ │ -0003d420: 6576 616e 6365 266e 6273 703b 303c 2f74  evance 0../test/t
    │ │ │ -0003d460: 6573 745f 626c 6f6f 6d5f 6669 6c74 6572  est_bloom_filter
    │ │ │ -0003d470: 2e63 7070 3a31 3336 3c2f 613e 3c2f 7464  .cpp:136test clear(
    │ │ │ -0003d490: 293c 2f74 643e 3c2f 7472 3e3c 7472 2069  )

    t │ │ │ -0003d4e0: 6573 7420 636c 6561 7228 293c 2f68 323e est clear()

    │ │ │ -0003d4f0: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ -0003d500: 5f62 6c6f 6f6d 5f66 696c 7465 722e 6370 _bloom_filter.cp │ │ │ -0003d510: 703a 3133 363c 2f68 343e 3c70 7265 2073 p:136

    .sha1_hash k
    │ │ │ -0003d560: 2822 5c78 3031 5c78 3030 5c78 3032 5c78  ("\x01\x00\x02\x
    │ │ │ -0003d570: 3030 2020 2020 2020 2020 2020 2020 2020  00              
    │ │ │ -0003d580: 2020 2229 3b0a 0954 4553 545f 4348 4543    ");..TEST_CHEC
    │ │ │ -0003d590: 4b28 2166 696c 7465 722e 6669 6e64 286b  K(!filter.find(k
    │ │ │ -0003d5a0: 2929 3b0a 0966 696c 7465 722e 7365 7428  ));..filter.set(
    │ │ │ -0003d5b0: 6b29 3b0a 0954 4553 545f 4348 4543 4b28  k);..TEST_CHECK(
    │ │ │ -0003d5c0: 6669 6c74 6572 2e66 696e 6428 6b29 293b  filter.find(k));
    │ │ │ -0003d5d0: 0a0a 0973 7464 3a3a 7569 6e74 385f 7420  ...std::uint8_t 
    │ │ │ -0003d5e0: 636f 6d70 6172 655b 345d 203d 207b 2030  compare[4] = { 0
    │ │ │ -0003d5f0: 7831 362c 2030 7866 662c 2030 7835 352c  x16, 0xff, 0x55,
    │ │ │ -0003d600: 2030 7861 617d 3b0a 0a09 6269 7473 5f6f   0xaa};...bits_o
    │ │ │ -0003d610: 7574 203d 2066 696c 7465 722e 746f 5f73  ut = filter.to_s
    │ │ │ -0003d620: 7472 696e 6728 293b 0a09 5445 5354 5f45  tring();..TEST_E
    │ │ │ -0003d630: 5155 414c 286d 656d 636d 7028 636f 6d70  QUAL(memcmp(comp
    │ │ │ -0003d640: 6172 652c 2062 6974 735f 6f75 742e 635f  are, bits_out.c_
    │ │ │ -0003d650: 7374 7228 292c 2034 292c 2030 293b 0a7d  str(), 4), 0);.}
    │ │ │ -0003d660: 0a0a 7d20 2f2f 2061 6e6f 6e79 6d6f 7573  ..} // anonymous
    │ │ │ -0003d670: 206e 616d 6573 7061 6365 0a0a 544f 5252   namespace..TORR
    │ │ │ -0003d680: 454e 545f 5445 5354 2862 6c6f 6f6d 5f66  ENT_TEST(bloom_f
    │ │ │ -0003d690: 696c 7465 7229 0a7b 0a09 7465 7374 5f73  ilter).{..test_s
    │ │ │ -0003d6a0: 6574 5f61 6e64 5f67 6574 2829 3b0a 0974  et_and_get();..t
    │ │ │ -0003d6b0: 6573 745f 7365 745f 6269 7473 2829 3b0a  est_set_bits();.
    │ │ │ -0003d6c0: 0974 6573 745f 636f 756e 745f 7a65 726f  .test_count_zero
    │ │ │ -0003d6d0: 6573 2829 3b0a 0974 6573 745f 746f 5f66  es();..test_to_f
    │ │ │ -0003d6e0: 726f 6d5f 7374 7269 6e67 2829 3b0a 0a3c  rom_string();..<
    │ │ │ -0003d6f0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -0003d700: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -0003d710: 7769 6474 683d 2231 3030 2522 3e7d 0a3c  width="100%">}.<
    │ │ │ -0003d720: 2f64 6976 3e3c 2f70 7265 3e3c 2f74 643e  /div>
    │ │ │ +000300e0: 7374 2f74 6573 745f 6669 6c65 5f73 746f st/test_file_sto │ │ │ +000300f0: 7261 6765 2e63 7070 3a31 3233 353c 2f61 rage.cpp:1235test f │ │ │ +00030110: 696c 6520 6174 7472 6962 7574 6573 3c2f ile attributes

    test │ │ │ +00030170: 6669 6c65 2061 7474 7269 6275 7465 733c file attributes< │ │ │ +00030180: 2f68 323e 3c68 343e 2e2e 2f74 6573 742f /h2>

    ../test/ │ │ │ +00030190: 7465 7374 5f66 696c 655f 7374 6f72 6167 test_file_storag │ │ │ +000301a0: 652e 6370 703a 3132 3335 3c2f 6834 3e3c e.cpp:1235

    < │ │ │ +000301b0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +000301c0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +000301d0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +000301e0: 7820 2364 6464 3b22 3e3c 2f70 7265 3e3c x #ddd;">
    < │ │ │ +000301f0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00030220: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +00030230: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test_ │ │ │ +00030260: 6669 6c65 5f73 746f 7261 6765 2e63 7070 file_storage.cpp │ │ │ +00030270: 3a31 3233 363c 2f61 3e3c 2f74 643e 3c74 :1236test symlinks< │ │ │ +00030290: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    test │ │ │ +000302e0: 2073 796d 6c69 6e6b 733c 2f68 323e 3c68 symlinks

    ../test/test_f │ │ │ +00030300: 696c 655f 7374 6f72 6167 652e 6370 703a ile_storage.cpp: │ │ │ +00030310: 3132 3336 3c2f 6834 3e3c 7072 6520 7374 1236

    
    │ │ │ +00030380: 3c74 643e 7265 6c65 7661 6e63 6526 6e62  relevance&nb
    │ │ │ +00030390: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120  sp;0../
    │ │ │ +000303c0: 7465 7374 2f74 6573 745f 7373 6c2e 6370  test/test_ssl.cp
    │ │ │ +000303d0: 703a 3430 373c 2f61 3e3c 2f74 643e 3c74  p:407test using a s
    │ │ │ +000303f0: 6967 6e65 6420 6365 7274 6966 6963 6174  igned certificat
    │ │ │ +00030400: 6520 7769 7468 2074 6865 2077 726f 6e67  e with the wrong
    │ │ │ +00030410: 2069 6e66 6f2d 6861 7368 2069 6e20 444e   info-hash in DN
    │ │ │ +00030420: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964  

    tes │ │ │ +00030470: 7420 7573 696e 6720 6120 7369 676e 6564 t using a signed │ │ │ +00030480: 2063 6572 7469 6669 6361 7465 2077 6974 certificate wit │ │ │ +00030490: 6820 7468 6520 7772 6f6e 6720 696e 666f h the wrong info │ │ │ +000304a0: 2d68 6173 6820 696e 2044 4e3c 2f68 323e -hash in DN

    │ │ │ +000304b0: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ +000304c0: 5f73 736c 2e63 7070 3a34 3037 3c2f 6834 _ssl.cpp:407

    .// i
    │ │ │ +00030510: 6e20 7665 7269 6679 696e 6720 7065 6572  n verifying peer
    │ │ │ +00030520: 730a 0963 7478 2e73 6574 5f76 6572 6966  s..ctx.set_verif
    │ │ │ +00030530: 795f 6d6f 6465 2863 6f6e 7465 7874 3a3a  y_mode(context::
    │ │ │ +00030540: 7665 7269 6679 5f6e 6f6e 652c 2065 6329  verify_none, ec)
    │ │ │ +00030550: 3b0a 0969 6620 2865 6329 0a09 7b0a 0909  ;..if (ec)..{...
    │ │ │ +00030560: 7374 643a 3a70 7269 6e74 6628 2246 6169  std::printf("Fai
    │ │ │ +00030570: 6c65 6420 746f 2073 6574 2053 534c 2076  led to set SSL v
    │ │ │ +00030580: 6572 6966 7920 6d6f 6465 3a20 2573 5c6e  erify mode: %s\n
    │ │ │ +00030590: 220a 0909 092c 2065 632e 6d65 7373 6167  "...., ec.messag
    │ │ │ +000305a0: 6528 292e 635f 7374 7228 2929 3b0a 0909  e().c_str());...
    │ │ │ +000305b0: 5445 5354 5f43 4845 434b 2821 6563 293b  TEST_CHECK(!ec);
    │ │ │ +000305c0: 0a09 0972 6574 7572 6e20 6661 6c73 653b  ...return false;
    │ │ │ +000305d0: 0a09 7d0a 0a09 7374 643a 3a73 7472 696e  ..}...std::strin
    │ │ │ +000305e0: 6720 6365 7274 6966 6963 6174 6520 3d20  g certificate = 
    │ │ │ +000305f0: 636f 6d62 696e 655f 7061 7468 2822 2e2e  combine_path("..
    │ │ │ +00030600: 222c 2063 6f6d 6269 6e65 5f70 6174 6828  ", combine_path(
    │ │ │ +00030610: 2273 736c 222c 2022 7065 6572 5f63 6572  "ssl", "peer_cer
    │ │ │ +00030620: 7469 6669 6361 7465 2e70 656d 2229 293b  tificate.pem"));
    │ │ │ +00030630: 0a09 7374 643a 3a73 7472 696e 6720 7072  ..std::string pr
    │ │ │ +00030640: 6976 6174 655f 6b65 7920 3d20 636f 6d62  ivate_key = comb
    │ │ │ +00030650: 696e 655f 7061 7468 2822 2e2e 222c 2063  ine_path("..", c
    │ │ │ +00030660: 6f6d 6269 6e65 5f70 6174 6828 2273 736c  ombine_path("ssl
    │ │ │ +00030670: 222c 2022 7065 6572 5f70 7269 7661 7465  ", "peer_private
    │ │ │ +00030680: 5f6b 6579 2e70 656d 2229 293b 0a09 7374  _key.pem"));..st
    │ │ │ +00030690: 643a 3a73 7472 696e 6720 6468 5f70 6172  d::string dh_par
    │ │ │ +000306a0: 616d 7320 3d20 636f 6d62 696e 655f 7061  ams = combine_pa
    │ │ │ +000306b0: 7468 2822 2e2e 222c 2063 6f6d 6269 6e65  th("..", combine
    │ │ │ +000306c0: 5f70 6174 6828 2273 736c 222c 2022 6468  _path("ssl", "dh
    │ │ │ +000306d0: 7061 7261 6d73 2e70 656d 2229 293b 0a0a  params.pem"));..
    │ │ │ +000306e0: 0969 6620 2866 6c61 6773 2026 616d 703b  .if (flags &
    │ │ │ +000306f0: 2069 6e76 616c 6964 5f63 6572 7469 6669   invalid_certifi
    │ │ │ +00030700: 6361 7465 290a 097b 0a09 0963 6572 7469  cate)..{...certi
    │ │ │ +00030710: 6669 6361 7465 203d 2063 6f6d 6269 6e65  ficate = combine
    │ │ │ +00030720: 5f70 6174 6828 222e 2e22 2c20 636f 6d62  _path("..", comb
    │ │ │ +00030730: 696e 655f 7061 7468 2822 7373 6c22 2c20  ine_path("ssl", 
    │ │ │ +00030740: 2269 6e76 616c 6964 5f70 6565 725f 6365  "invalid_peer_ce
    │ │ │ +00030750: 7274 6966 6963 6174 652e 7065 6d22 2929  rtificate.pem"))
    │ │ │ +00030760: 3b0a 0909 7072 6976 6174 655f 6b65 7920  ;...private_key 
    │ │ │ +00030770: 3d20 636f 6d62 696e 655f 7061 7468 2822  = combine_path("
    │ │ │ +00030780: 2e2e 222c 2063 6f6d 6269 6e65 5f70 6174  ..", combine_pat
    │ │ │ +00030790: 6828 2273 736c 222c 2022 696e 7661 6c69  h("ssl", "invali
    │ │ │ +000307a0: 645f 7065 6572 5f70 7269 7661 7465 5f6b  d_peer_private_k
    │ │ │ +000307b0: 6579 2e70 656d 2229 293b 0a09 7d0a 0a3c  ey.pem"));..}..<
    │ │ │ +000307c0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +000307d0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +000307e0: 7769 6474 683d 2231 3030 2522 3e0a 3c2f  width="100%">..if (flags &
    │ │ │ +00030800: 616d 703b 2028 7661 6c69 645f 6365 7274  amp; (valid_cert
    │ │ │ +00030810: 6966 6963 6174 6520 7c20 696e 7661 6c69  ificate | invali
    │ │ │ +00030820: 645f 6365 7274 6966 6963 6174 6529 290a  d_certificate)).
    │ │ │ +00030830: 097b 0a09 0973 7464 3a3a 7072 696e 7466  .{...std::printf
    │ │ │ +00030840: 2822 7365 745f 7061 7373 776f 7264 5f63  ("set_password_c
    │ │ │ +00030850: 616c 6c62 6163 6b5c 6e22 293b 0a09 0963  allback\n");...c
    │ │ │ +00030860: 7478 2e73 6574 5f70 6173 7377 6f72 645f  tx.set_password_
    │ │ │ +00030870: 6361 6c6c 6261 636b 280a 0909 095b 5d28  callback(....[](
    │ │ │ +00030880: 7374 643a 3a73 697a 655f 742c 2063 6f6e  std::size_t, con
    │ │ │ +00030890: 7465 7874 3a3a 7061 7373 776f 7264 5f70  text::password_p
    │ │ │ +000308a0: 7572 706f 7365 2920 7b20 7265 7475 726e  urpose) { return
    │ │ │ +000308b0: 2022 7465 7374 223b 207d 0a09 0909 2c20   "test"; }...., 
    │ │ │ +000308c0: 6563 293b 0a09 0969 6620 2865 6329 0a09  ec);...if (ec)..
    │ │ │ +000308d0: 097b 0a09 0909 7374 643a 3a70 7269 6e74  .{....std::print
    │ │ │ +000308e0: 6628 2246 6169 6c65 6420 746f 2073 6574  f("Failed to set
    │ │ │ +000308f0: 2063 6572 7469 6669 6361 7465 2070 6173   certificate pas
    │ │ │ +00030900: 7370 6872 6173 653a 2025 735c 6e22 0a09  sphrase: %s\n"..
    │ │ │ +00030910: 0909 092c 2065 632e 6d65 7373 6167 6528  ..., ec.message(
    │ │ │ +00030920: 292e 635f 7374 7228 2929 3b0a 0909 0954  ).c_str());....T
    │ │ │ +00030930: 4553 545f 4348 4543 4b28 2165 6329 3b0a  EST_CHECK(!ec);.
    │ │ │ +00030940: 0909 0972 6574 7572 6e20 6661 6c73 653b  ...return false;
    │ │ │ +00030950: 0a09 097d 0a09 0973 7464 3a3a 7072 696e  ...}...std::prin
    │ │ │ +00030960: 7466 2822 7573 655f 6365 7274 6966 6963  tf("use_certific
    │ │ │ +00030970: 6174 655f 6669 6c65 205c 2225 735c 225c  ate_file \"%s\"\
    │ │ │ +00030980: 6e22 2c20 6365 7274 6966 6963 6174 652e  n", certificate.
    │ │ │ +00030990: 635f 7374 7228 2929 3b0a 0909 6374 782e  c_str());...ctx.
    │ │ │ +000309a0: 7573 655f 6365 7274 6966 6963 6174 655f  use_certificate_
    │ │ │ +000309b0: 6669 6c65 2863 6572 7469 6669 6361 7465  file(certificate
    │ │ │ +000309c0: 2c20 636f 6e74 6578 743a 3a70 656d 2c20  , context::pem, 
    │ │ │ +000309d0: 6563 293b 0a09 0969 6620 2865 6329 0a09  ec);...if (ec)..
    │ │ │ +000309e0: 097b 0a09 0909 7374 643a 3a70 7269 6e74  .{....std::print
    │ │ │ +000309f0: 6628 2246 6169 6c65 6420 746f 2073 6574  f("Failed to set
    │ │ │ +00030a00: 2063 6572 7469 6669 6361 7465 2066 696c   certificate fil
    │ │ │ +00030a10: 653a 2025 735c 6e22 0a09 0909 092c 2065  e: %s\n"....., e
    │ │ │ +00030a20: 632e 6d65 7373 6167 6528 292e 635f 7374  c.message().c_st
    │ │ │ +00030a30: 7228 2929 3b0a 0909 0954 4553 545f 4348  r());....TEST_CH
    │ │ │ +00030a40: 4543 4b28 2165 6329 3b0a 0909 0972 6574  ECK(!ec);....ret
    │ │ │ +00030a50: 7572 6e20 6661 6c73 653b 0a09 097d 0a09  urn false;...}..
    │ │ │ +00030a60: 0973 7464 3a3a 7072 696e 7466 2822 7573  .std::printf("us
    │ │ │ +00030a70: 655f 7072 6976 6174 655f 6b65 795f 6669  e_private_key_fi
    │ │ │ +00030a80: 6c65 205c 2225 735c 225c 6e22 2c20 7072  le \"%s\"\n", pr
    │ │ │ +00030a90: 6976 6174 655f 6b65 792e 635f 7374 7228  ivate_key.c_str(
    │ │ │ +00030aa0: 2929 3b0a 0909 6374 782e 7573 655f 7072  ));...ctx.use_pr
    │ │ │ +00030ab0: 6976 6174 655f 6b65 795f 6669 6c65 2870  ivate_key_file(p
    │ │ │ +00030ac0: 7269 7661 7465 5f6b 6579 2c20 636f 6e74  rivate_key, cont
    │ │ │ +00030ad0: 6578 743a 3a70 656d 2c20 6563 293b 0a09  ext::pem, ec);..
    │ │ │ +00030ae0: 0969 6620 2865 6329 0a09 097b 0a09 0909  .if (ec)...{....
    │ │ │ +00030af0: 7374 643a 3a70 7269 6e74 6628 2246 6169  std::printf("Fai
    │ │ │ +00030b00: 6c65 6420 746f 2073 6574 2070 7269 7661  led to set priva
    │ │ │ +00030b10: 7465 206b 6579 3a20 2573 5c6e 220a 0909  te key: %s\n"...
    │ │ │ +00030b20: 0909 2c20 6563 2e6d 6573 7361 6765 2829  .., ec.message()
    │ │ │ +00030b30: 2e63 5f73 7472 2829 293b 0a09 0909 5445  .c_str());....TE
    │ │ │ +00030b40: 5354 5f43 4845 434b 2821 6563 293b 0a09  ST_CHECK(!ec);..
    │ │ │ +00030b50: 0909 7265 7475 726e 2066 616c 7365 3b0a  ..return false;.
    │ │ │ +00030b60: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e  
    │ │ │ +00030b70: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00030ba0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../tes │ │ │ +00030bd0: 742f 7465 7374 5f73 736c 2e63 7070 3a35 t/test_ssl.cpp:5 │ │ │ +00030be0: 3039 3c2f 613e 3c2f 7464 3e3c 7464 3e61 09a │ │ │ +00030bf0: 6c73 6f20 7465 7374 2075 7369 6e67 2061 lso test using a │ │ │ +00030c00: 2068 6173 6820 7468 6174 2072 6566 6572 hash that refer │ │ │ +00030c10: 7320 746f 2061 2076 616c 6964 2074 6f72 s to a valid tor │ │ │ +00030c20: 7265 6e74 2062 7574 2074 6861 7420 6469 rent but that di │ │ │ +00030c30: 6666 6572 7320 6672 6f6d 2074 6865 2053 ffers from the S │ │ │ +00030c40: 4e49 2068 6173 683c 2f74 643e 3c2f 7472 NI hash │ │ │ +00030c80: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00030c90: 3c68 323e 616c 736f 2074 6573 7420 7573

    also test us │ │ │ +00030ca0: 696e 6720 6120 6861 7368 2074 6861 7420 ing a hash that │ │ │ +00030cb0: 7265 6665 7273 2074 6f20 6120 7661 6c69 refers to a vali │ │ │ +00030cc0: 6420 746f 7272 656e 740a 6275 7420 7468 d torrent.but th │ │ │ +00030cd0: 6174 2064 6966 6665 7273 2066 726f 6d20 at differs from │ │ │ +00030ce0: 7468 6520 534e 4920 6861 7368 3c2f 6832 the SNI hash

    ../test/tes │ │ │ +00030d00: 745f 7373 6c2e 6370 703a 3530 393c 2f68 t_ssl.cpp:509
    .pri
    │ │ │ +00030d50: 6e74 5f61 6c65 7274 7328 7365 7331 2c20  nt_alerts(ses1, 
    │ │ │ +00030d60: 2273 6573 3122 2c20 7472 7565 2c20 7472  "ses1", true, tr
    │ │ │ +00030d70: 7565 2c20 2661 6d70 3b6f 6e5f 616c 6572  ue, &on_aler
    │ │ │ +00030d80: 7429 3b0a 0969 6620 2865 6329 0a09 7b0a  t);..if (ec)..{.
    │ │ │ +00030d90: 0909 7374 643a 3a70 7269 6e74 6628 2246  ..std::printf("F
    │ │ │ +00030da0: 6169 6c65 6420 5353 4c20 6861 6e64 7368  ailed SSL handsh
    │ │ │ +00030db0: 616b 653a 2025 735c 6e22 0a09 0909 2c20  ake: %s\n"...., 
    │ │ │ +00030dc0: 6563 2e6d 6573 7361 6765 2829 2e63 5f73  ec.message().c_s
    │ │ │ +00030dd0: 7472 2829 293b 0a09 0972 6574 7572 6e20  tr());...return 
    │ │ │ +00030de0: 6661 6c73 653b 0a09 7d0a 0a09 6368 6172  false;..}...char
    │ │ │ +00030df0: 2068 616e 6473 6861 6b65 5b5d 203d 2022   handshake[] = "
    │ │ │ +00030e00: 5c78 3133 2220 2242 6974 546f 7272 656e  \x13" "BitTorren
    │ │ │ +00030e10: 7420 7072 6f74 6f63 6f6c 5c30 5c30 5c30  t protocol\0\0\0
    │ │ │ +00030e20: 5c30 5c30 5c30 5c30 5c78 3034 220a 0909  \0\0\0\0\x04"...
    │ │ │ +00030e30: 2220 2020 2020 2020 2020 2020 2020 2020  "               
    │ │ │ +00030e40: 2020 2020 2022 202f 2f20 7370 6163 6520       " // space 
    │ │ │ +00030e50: 666f 7220 696e 666f 2d68 6173 680a 0909  for info-hash...
    │ │ │ +00030e60: 2261 6161 6161 6161 6161 6161 6161 6161  "aaaaaaaaaaaaaaa
    │ │ │ +00030e70: 6161 6161 6122 202f 2f20 7065 6572 2d69  aaaaa" // peer-i
    │ │ │ +00030e80: 640a 0909 225c 305c 305c 305c 7830 315c  d..."\0\0\0\x01\
    │ │ │ +00030e90: 7830 3222 3b20 2f2f 2069 6e74 6572 6573  x02"; // interes
    │ │ │ +00030ea0: 7465 640a 0a09 2f2f 2066 696c 6c20 696e  ted...// fill in
    │ │ │ +00030eb0: 2074 6865 2069 6e66 6f2d 6861 7368 0a09   the info-hash..
    │ │ │ +00030ec0: 6966 2028 666c 6167 7320 2661 6d70 3b20  if (flags & 
    │ │ │ +00030ed0: 7661 6c69 645f 6269 7474 6f72 7265 6e74  valid_bittorrent
    │ │ │ +00030ee0: 5f68 6173 6829 0a09 7b0a 0909 7374 643a  _hash)..{...std:
    │ │ │ +00030ef0: 3a6d 656d 6370 7928 6861 6e64 7368 616b  :memcpy(handshak
    │ │ │ +00030f00: 6520 2b20 3238 2c20 2661 6d70 3b74 2d26  e + 28, &t-&
    │ │ │ +00030f10: 6774 3b69 6e66 6f5f 6861 7368 6573 2829  gt;info_hashes()
    │ │ │ +00030f20: 2e76 315b 305d 2c20 3230 293b 0a09 7d0a  .v1[0], 20);..}.
    │ │ │ +00030f30: 0965 6c73 650a 097b 0a3c 6469 7620 7374  .else..{.
    ..std::ge │ │ │ +00030f70: 6e65 7261 7465 2868 616e 6473 6861 6b65 nerate(handshake │ │ │ +00030f80: 202b 2032 382c 2068 616e 6473 6861 6b65 + 28, handshake │ │ │ +00030f90: 202b 2034 382c 2026 616d 703b 7261 6e64 + 48, &rand │ │ │ +00030fa0: 293b 0a3c 2f64 6976 3e09 7d0a 0a09 2f2f );.
    .}...// │ │ │ +00030fb0: 2066 696c 6c20 696e 2074 6865 2070 6565 fill in the pee │ │ │ +00030fc0: 722d 6964 0a09 7374 643a 3a67 656e 6572 r-id..std::gener │ │ │ +00030fd0: 6174 6528 6861 6e64 7368 616b 6520 2b20 ate(handshake + │ │ │ +00030fe0: 3438 2c20 6861 6e64 7368 616b 6520 2b20 48, handshake + │ │ │ +00030ff0: 3638 2c20 2661 6d70 3b72 616e 6429 3b0a 68, &rand);. │ │ │ +00031000: 0a09 7374 643a 3a70 7269 6e74 6628 2262 ..std::printf("b │ │ │ +00031010: 6974 746f 7272 656e 7420 6861 6e64 7368 ittorrent handsh │ │ │ +00031020: 616b 655c 6e22 293b 0a09 626f 6f73 743a ake\n");..boost: │ │ │ +00031030: 3a61 7369 6f3a 3a77 7269 7465 2873 736c :asio::write(ssl │ │ │ +00031040: 5f73 6f63 6b2c 2062 6f6f 7374 3a3a 6173 _sock, boost::as │ │ │ +00031050: 696f 3a3a 6275 6666 6572 2868 616e 6473 io::buffer(hands │ │ │ +00031060: 6861 6b65 2c20 2873 697a 656f 6628 6861 hake, (sizeof(ha │ │ │ +00031070: 6e64 7368 616b 6529 202d 2031 2929 2c20 ndshake) - 1)), │ │ │ +00031080: 6563 293b 0a09 7072 696e 745f 616c 6572 ec);..print_aler │ │ │ +00031090: 7473 2873 6573 312c 2022 7365 7331 222c ts(ses1, "ses1", │ │ │ +000310a0: 2074 7275 652c 2074 7275 652c 2026 616d true, true, &am │ │ │ +000310b0: 703b 6f6e 5f61 6c65 7274 293b 0a09 6966 p;on_alert);..if │ │ │ +000310c0: 2028 6563 290a 097b 0a09 0973 7464 3a3a (ec)..{...std:: │ │ │ +000310d0: 7072 696e 7466 2822 6661 696c 6564 2074 printf("failed t │ │ │ +000310e0: 6f20 7772 6974 6520 6269 7474 6f72 7265 o write bittorre │ │ │ +000310f0: 6e74 2068 616e 6473 6861 6b65 3a20 2573 nt handshake: %s │ │ │ +00031100: 5c6e 220a 0909 092c 2065 632e 6d65 7373 \n"...., ec.mess │ │ │ +00031110: 6167 6528 292e 635f 7374 7228 2929 3b0a age().c_str());. │ │ │ +00031120: 0909 7265 7475 726e 2066 616c 7365 3b0a ..return false;. │ │ │ +00031130: 097d 0a0a 0963 6861 7220 6275 665b 3638 .}...char buf[68 │ │ │ +00031140: 5d3b 0a09 7374 643a 3a70 7269 6e74 6628 ];..std::printf( │ │ │ +00031150: 2272 6561 6420 6269 7474 6f72 7265 6e74 "read bittorrent │ │ │ +00031160: 2068 616e 6473 6861 6b65 5c6e 2229 3b0a handshake\n");. │ │ │ +00031170: 0962 6f6f 7374 3a3a 6173 696f 3a3a 7265 .boost::asio::re │ │ │ +00031180: 6164 2873 736c 5f73 6f63 6b2c 2062 6f6f ad(ssl_sock, boo │ │ │ +00031190: 7374 3a3a 6173 696f 3a3a 6275 6666 6572 st::asio::buffer │ │ │ +000311a0: 2862 7566 2c20 7369 7a65 6f66 2862 7566 (buf, sizeof(buf │ │ │ +000311b0: 2929 2c20 6563 293b 0a09 7072 696e 745f )), ec);..print_ │ │ │ +000311c0: 616c 6572 7473 2873 6573 312c 2022 7365 alerts(ses1, "se │ │ │ +000311d0: 7331 222c 2074 7275 652c 2074 7275 652c s1", true, true, │ │ │ +000311e0: 2026 616d 703b 6f6e 5f61 6c65 7274 293b &on_alert); │ │ │ +000311f0: 0a09 6966 2028 6563 290a 097b 0a09 0973 ..if (ec)..{...s │ │ │ +00031200: 7464 3a3a 7072 696e 7466 2822 6661 696c td::printf("fail │ │ │ +00031210: 6564 2074 6f20 7265 6164 2062 6974 746f ed to read bitto │ │ │ +00031220: 7272 656e 7420 6861 6e64 7368 616b 653a rrent handshake: │ │ │ +00031230: 2025 735c 6e22 0a09 0909 2c20 6563 2e6d %s\n"...., ec.m │ │ │ +00031240: 6573 7361 6765 2829 2e63 5f73 7472 2829 essage().c_str() │ │ │ +00031250: 293b 0a09 0972 6574 7572 6e20 6661 6c73 );...return fals │ │ │ +00031260: 653b 0a09 7d0a 0a09 6966 2028 6d65 6d63 e;..}...if (memc │ │ │ +00031270: 6d70 2862 7566 2c20 225c 7831 3322 2022 mp(buf, "\x13" " │ │ │ +00031280: 4269 7454 6f72 7265 6e74 2070 726f 746f BitTorrent proto │ │ │ +00031290: 636f 6c22 2c20 3230 2920 213d 2030 290a col", 20) != 0). │ │ │ +000312a0: 097b 0a09 0973 7464 3a3a 7072 696e 7466 .{...std::printf │ │ │ +000312b0: 2822 696e 7661 6c69 6420 6269 7474 6f72 ("invalid bittor │ │ │ +000312c0: 7265 6e74 2068 616e 6473 6861 6b65 5c6e rent handshake\n │ │ │ +000312d0: 2229 3b0a 0909 7265 7475 726e 2066 616c ");...return fal │ │ │ +000312e0: 7365 3b0a 3c2f 7072 653e 3c2f 7464 3e3c se;.
    < │ │ │ +000312f0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +00031320: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0.. │ │ │ +00031350: 2f74 6573 742f 7465 7374 5f66 6173 745f /test/test_fast_ │ │ │ +00031360: 6578 7465 6e73 696f 6e2e 6370 703a 3132 extension.cpp:12 │ │ │ +00031370: 3238 3c2f 613e 3c2f 7464 3e3c 7464 3e74 28t │ │ │ +00031380: 6573 7420 7365 6e64 696e 6720 696e 7661 est sending inva │ │ │ +00031390: 6c69 6420 7265 7175 6573 7473 2028 6f75 lid requests (ou │ │ │ +000313a0: 7420 6f66 2062 6f75 6e64 2070 6965 6365 t of bound piece │ │ │ +000313b0: 2069 6e64 6578 2c20 6f66 6673 6574 7320 index, offsets │ │ │ +000313c0: 616e 6420 7369 7a65 7329 3c2f 7464 3e3c and sizes)< │ │ │ +000313d0: 2f74 723e 3c74 7220 6964 3d22 3939 2220 /tr>

    test send │ │ │ +00031420: 696e 6720 696e 7661 6c69 6420 7265 7175 ing invalid requ │ │ │ +00031430: 6573 7473 2028 6f75 7420 6f66 2062 6f75 ests (out of bou │ │ │ +00031440: 6e64 2070 6965 6365 2069 6e64 6578 2c20 nd piece index, │ │ │ +00031450: 6f66 6673 6574 7320 616e 640a 7369 7a65 offsets and.size │ │ │ +00031460: 7329 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 s)

    ../te │ │ │ +00031470: 7374 2f74 6573 745f 6661 7374 5f65 7874 st/test_fast_ext │ │ │ +00031480: 656e 7369 6f6e 2e63 7070 3a31 3232 383c ension.cpp:1228< │ │ │ +00031490: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    r
    │ │ │ +00031500: 656c 6576 616e 6365 266e 6273 703b 303c  elevance 0<
    │ │ │ +00031510: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../test
    │ │ │ +00031540: 2f74 6573 745f 7265 736f 6c76 655f 6c69  /test_resolve_li
    │ │ │ +00031550: 6e6b 732e 6370 703a 3935 3c2f 613e 3c2f  nks.cpp:95test file
    │ │ │ +00031570: 7320 7769 7468 2064 6966 6665 7265 6e74  s with different
    │ │ │ +00031580: 2070 6965 6365 2073 697a 6520 286e 6567   piece size (neg
    │ │ │ +00031590: 6174 6976 6520 7465 7374 293c 2f74 643e  ative test)
    │ │ │ +000315a0: 3c2f 7472 3e3c 7472 2069 643d 2231 3030  

    test fi │ │ │ +000315f0: 6c65 7320 7769 7468 2064 6966 6665 7265 les with differe │ │ │ +00031600: 6e74 2070 6965 6365 2073 697a 6520 286e nt piece size (n │ │ │ +00031610: 6567 6174 6976 6520 7465 7374 293c 2f68 egative test)

    ../test/te │ │ │ +00031630: 7374 5f72 6573 6f6c 7665 5f6c 696e 6b73 st_resolve_links │ │ │ +00031640: 2e63 7070 3a39 353c 2f68 343e 3c70 7265 .cpp:95

    .{ "test2"
    │ │ │ +00031690: 2c20 2274 6573 7431 5f70 6164 5f66 696c  , "test1_pad_fil
    │ │ │ +000316a0: 6573 222c 2030 7d2c 0a09 7b20 2274 6573  es", 0},..{ "tes
    │ │ │ +000316b0: 7433 222c 2022 7465 7374 315f 7061 645f  t3", "test1_pad_
    │ │ │ +000316c0: 6669 6c65 7322 2c20 307d 2c0a 097b 2022  files", 0},..{ "
    │ │ │ +000316d0: 7465 7374 3222 2c20 2274 6573 7431 5f73  test2", "test1_s
    │ │ │ +000316e0: 696e 676c 6522 2c20 307d 2c0a 0a09 2f2f  ingle", 0},...//
    │ │ │ +000316f0: 2074 6865 7365 2061 7265 2061 6c6c 2070   these are all p
    │ │ │ +00031700: 6164 6465 642e 2054 6865 2066 6972 7374  added. The first
    │ │ │ +00031710: 2073 6d61 6c6c 2066 696c 6520 7769 6c6c   small file will
    │ │ │ +00031720: 2061 6363 6964 656e 7461 6c6c 7920 616c   accidentally al
    │ │ │ +00031730: 736f 0a09 2f2f 206d 6174 6368 2c20 6576  so..// match, ev
    │ │ │ +00031740: 656e 2074 686f 7567 6820 6974 2773 206e  en though it's n
    │ │ │ +00031750: 6f74 2074 6169 6c20 7061 6464 6564 2c20  ot tail padded, 
    │ │ │ +00031760: 7468 6520 666f 6c6c 6f77 696e 6720 6669  the following fi
    │ │ │ +00031770: 6c65 2069 7320 6964 656e 7469 6361 6c0a  le is identical.
    │ │ │ +00031780: 097b 2022 7465 7374 325f 7061 645f 6669  .{ "test2_pad_fi
    │ │ │ +00031790: 6c65 7322 2c20 2274 6573 7431 5f70 6164  les", "test1_pad
    │ │ │ +000317a0: 5f66 696c 6573 222c 2032 7d2c 0a09 7b20  _files", 2},..{ 
    │ │ │ +000317b0: 2274 6573 7433 5f70 6164 5f66 696c 6573  "test3_pad_files
    │ │ │ +000317c0: 222c 2022 7465 7374 315f 7061 645f 6669  ", "test1_pad_fi
    │ │ │ +000317d0: 6c65 7322 2c20 327d 2c0a 097b 2022 7465  les", 2},..{ "te
    │ │ │ +000317e0: 7374 335f 7061 645f 6669 6c65 7322 2c20  st3_pad_files", 
    │ │ │ +000317f0: 2274 6573 7432 5f70 6164 5f66 696c 6573  "test2_pad_files
    │ │ │ +00031800: 222c 2032 7d2c 0a09 7b20 2274 6573 7431  ", 2},..{ "test1
    │ │ │ +00031810: 5f70 6164 5f66 696c 6573 222c 2022 7465  _pad_files", "te
    │ │ │ +00031820: 7374 325f 7061 645f 6669 6c65 7322 2c20  st2_pad_files", 
    │ │ │ +00031830: 327d 2c0a 097b 2022 7465 7374 315f 7061  2},..{ "test1_pa
    │ │ │ +00031840: 645f 6669 6c65 7322 2c20 2274 6573 7433  d_files", "test3
    │ │ │ +00031850: 5f70 6164 5f66 696c 6573 222c 2032 7d2c  _pad_files", 2},
    │ │ │ +00031860: 0a09 7b20 2274 6573 7432 5f70 6164 5f66  ..{ "test2_pad_f
    │ │ │ +00031870: 696c 6573 222c 2022 7465 7374 335f 7061  iles", "test3_pa
    │ │ │ +00031880: 645f 6669 6c65 7322 2c20 327d 2c0a 0a09  d_files", 2},...
    │ │ │ +00031890: 2f2f 206f 6e65 206d 6967 6874 2065 7870  // one might exp
    │ │ │ +000318a0: 6563 7420 7468 6973 2074 6f20 776f 726b  ect this to work
    │ │ │ +000318b0: 2c20 6275 7420 7369 6e63 6520 7468 6520  , but since the 
    │ │ │ +000318c0: 7461 696c 206f 6620 7468 6520 7369 6e67  tail of the sing
    │ │ │ +000318d0: 6c65 2066 696c 650a 092f 2f20 746f 7272  le file..// torr
    │ │ │ +000318e0: 656e 7420 6973 206e 6f74 2070 6164 6465  ent is not padde
    │ │ │ +000318f0: 642c 2074 6865 206c 6173 7420 7069 6563  d, the last piec
    │ │ │ +00031900: 6520 6861 7368 2077 6f6e 2774 206d 6174  e hash won't mat
    │ │ │ +00031910: 6368 0a09 7b20 2274 6573 7431 5f70 6164  ch..{ "test1_pad
    │ │ │ +00031920: 5f66 696c 6573 222c 2022 7465 7374 315f  _files", "test1_
    │ │ │ +00031930: 7369 6e67 6c65 222c 2030 7d2c 0a0a 092f  single", 0},.../
    │ │ │ +00031940: 2f20 6966 2069 7427 7320 7061 6464 6564  / if it's padded
    │ │ │ +00031950: 206f 6e20 7468 6520 6f74 6865 7220 6861   on the other ha
    │ │ │ +00031960: 6e64 2c20 6974 2077 696c 6c20 776f 726b  nd, it will work
    │ │ │ +00031970: 0a09 7b20 2274 6573 7431 5f70 6164 5f66  ..{ "test1_pad_f
    │ │ │ +00031980: 696c 6573 222c 2022 7465 7374 315f 7369  iles", "test1_si
    │ │ │ +00031990: 6e67 6c65 5f70 6164 6465 6422 2c20 317d  ngle_padded", 1}
    │ │ │ +000319a0: 2c0a 0a3c 6469 7620 7374 796c 653d 2262  ,..
    };.
    .
    rele │ │ │ +00031a10: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../test/te │ │ │ +00031a50: 7374 5f72 6573 6f6c 7665 5f6c 696e 6b73 st_resolve_links │ │ │ +00031a60: 2e63 7070 3a39 383c 2f61 3e3c 2f74 643e .cpp:98 │ │ │ +00031a70: 3c74 643e 6974 2077 6f75 6c64 2062 6520 it would be │ │ │ +00031a80: 6e69 6365 2074 6f20 7465 7374 2072 6573 nice to test res │ │ │ +00031a90: 6f6c 7669 6e67 206f 6620 6d6f 7265 2074 olving of more t │ │ │ +00031aa0: 6861 6e20 6a75 7374 2032 2066 696c 6573 han just 2 files │ │ │ +00031ab0: 2061 7320 7765 6c6c 2e20 6c69 6b65 2033 as well. like 3 │ │ │ +00031ac0: 2073 696e 676c 6520 6669 6c65 2074 6f72 single file tor │ │ │ +00031ad0: 7265 6e74 7320 6d65 7267 6564 2069 6e74 rents merged int │ │ │ +00031ae0: 6f20 6f6e 652c 2072 6573 6f6c 7669 6e67 o one, resolving │ │ │ +00031af0: 2061 6c6c 2033 2066 696c 6573 2e3c 2f74 all 3 files.

    it wo │ │ │ +00031b50: 756c 6420 6265 206e 6963 6520 746f 2074 uld be nice to t │ │ │ +00031b60: 6573 7420 7265 736f 6c76 696e 6720 6f66 est resolving of │ │ │ +00031b70: 206d 6f72 6520 7468 616e 206a 7573 7420 more than just │ │ │ +00031b80: 3220 6669 6c65 7320 6173 2077 656c 6c2e 2 files as well. │ │ │ +00031b90: 0a6c 696b 6520 3320 7369 6e67 6c65 2066 .like 3 single f │ │ │ +00031ba0: 696c 6520 746f 7272 656e 7473 206d 6572 ile torrents mer │ │ │ +00031bb0: 6765 6420 696e 746f 206f 6e65 2c20 7265 ged into one, re │ │ │ +00031bc0: 736f 6c76 696e 6720 616c 6c20 3320 6669 solving all 3 fi │ │ │ +00031bd0: 6c65 732e 3c2f 6832 3e3c 6834 3e2e 2e2f les.

    ../ │ │ │ +00031be0: 7465 7374 2f74 6573 745f 7265 736f 6c76 test/test_resolv │ │ │ +00031bf0: 655f 6c69 6e6b 732e 6370 703a 3938 3c2f e_links.cpp:98
    .{ 
    │ │ │ +00031c40: 2274 6573 7432 222c 2022 7465 7374 315f  "test2", "test1_
    │ │ │ +00031c50: 7369 6e67 6c65 222c 2030 7d2c 0a0a 092f  single", 0},.../
    │ │ │ +00031c60: 2f20 7468 6573 6520 6172 6520 616c 6c20  / these are all 
    │ │ │ +00031c70: 7061 6464 6564 2e20 5468 6520 6669 7273  padded. The firs
    │ │ │ +00031c80: 7420 736d 616c 6c20 6669 6c65 2077 696c  t small file wil
    │ │ │ +00031c90: 6c20 6163 6369 6465 6e74 616c 6c79 2061  l accidentally a
    │ │ │ +00031ca0: 6c73 6f0a 092f 2f20 6d61 7463 682c 2065  lso..// match, e
    │ │ │ +00031cb0: 7665 6e20 7468 6f75 6768 2069 7427 7320  ven though it's 
    │ │ │ +00031cc0: 6e6f 7420 7461 696c 2070 6164 6465 642c  not tail padded,
    │ │ │ +00031cd0: 2074 6865 2066 6f6c 6c6f 7769 6e67 2066   the following f
    │ │ │ +00031ce0: 696c 6520 6973 2069 6465 6e74 6963 616c  ile is identical
    │ │ │ +00031cf0: 0a09 7b20 2274 6573 7432 5f70 6164 5f66  ..{ "test2_pad_f
    │ │ │ +00031d00: 696c 6573 222c 2022 7465 7374 315f 7061  iles", "test1_pa
    │ │ │ +00031d10: 645f 6669 6c65 7322 2c20 327d 2c0a 097b  d_files", 2},..{
    │ │ │ +00031d20: 2022 7465 7374 335f 7061 645f 6669 6c65   "test3_pad_file
    │ │ │ +00031d30: 7322 2c20 2274 6573 7431 5f70 6164 5f66  s", "test1_pad_f
    │ │ │ +00031d40: 696c 6573 222c 2032 7d2c 0a09 7b20 2274  iles", 2},..{ "t
    │ │ │ +00031d50: 6573 7433 5f70 6164 5f66 696c 6573 222c  est3_pad_files",
    │ │ │ +00031d60: 2022 7465 7374 325f 7061 645f 6669 6c65   "test2_pad_file
    │ │ │ +00031d70: 7322 2c20 327d 2c0a 097b 2022 7465 7374  s", 2},..{ "test
    │ │ │ +00031d80: 315f 7061 645f 6669 6c65 7322 2c20 2274  1_pad_files", "t
    │ │ │ +00031d90: 6573 7432 5f70 6164 5f66 696c 6573 222c  est2_pad_files",
    │ │ │ +00031da0: 2032 7d2c 0a09 7b20 2274 6573 7431 5f70   2},..{ "test1_p
    │ │ │ +00031db0: 6164 5f66 696c 6573 222c 2022 7465 7374  ad_files", "test
    │ │ │ +00031dc0: 335f 7061 645f 6669 6c65 7322 2c20 327d  3_pad_files", 2}
    │ │ │ +00031dd0: 2c0a 097b 2022 7465 7374 325f 7061 645f  ,..{ "test2_pad_
    │ │ │ +00031de0: 6669 6c65 7322 2c20 2274 6573 7433 5f70  files", "test3_p
    │ │ │ +00031df0: 6164 5f66 696c 6573 222c 2032 7d2c 0a0a  ad_files", 2},..
    │ │ │ +00031e00: 092f 2f20 6f6e 6520 6d69 6768 7420 6578  .// one might ex
    │ │ │ +00031e10: 7065 6374 2074 6869 7320 746f 2077 6f72  pect this to wor
    │ │ │ +00031e20: 6b2c 2062 7574 2073 696e 6365 2074 6865  k, but since the
    │ │ │ +00031e30: 2074 6169 6c20 6f66 2074 6865 2073 696e   tail of the sin
    │ │ │ +00031e40: 676c 6520 6669 6c65 0a09 2f2f 2074 6f72  gle file..// tor
    │ │ │ +00031e50: 7265 6e74 2069 7320 6e6f 7420 7061 6464  rent is not padd
    │ │ │ +00031e60: 6564 2c20 7468 6520 6c61 7374 2070 6965  ed, the last pie
    │ │ │ +00031e70: 6365 2068 6173 6820 776f 6e27 7420 6d61  ce hash won't ma
    │ │ │ +00031e80: 7463 680a 097b 2022 7465 7374 315f 7061  tch..{ "test1_pa
    │ │ │ +00031e90: 645f 6669 6c65 7322 2c20 2274 6573 7431  d_files", "test1
    │ │ │ +00031ea0: 5f73 696e 676c 6522 2c20 307d 2c0a 0a09  _single", 0},...
    │ │ │ +00031eb0: 2f2f 2069 6620 6974 2773 2070 6164 6465  // if it's padde
    │ │ │ +00031ec0: 6420 6f6e 2074 6865 206f 7468 6572 2068  d on the other h
    │ │ │ +00031ed0: 616e 642c 2069 7420 7769 6c6c 2077 6f72  and, it will wor
    │ │ │ +00031ee0: 6b0a 097b 2022 7465 7374 315f 7061 645f  k..{ "test1_pad_
    │ │ │ +00031ef0: 6669 6c65 7322 2c20 2274 6573 7431 5f73  files", "test1_s
    │ │ │ +00031f00: 696e 676c 655f 7061 6464 6564 222c 2031  ingle_padded", 1
    │ │ │ +00031f10: 7d2c 0a0a 7d3b 0a0a 3c64 6976 2073 7479  },..};..
    .
    TOR │ │ │ +00031f50: 5245 4e54 5f54 4553 5428 7265 736f 6c76 RENT_TEST(resolv │ │ │ +00031f60: 655f 6c69 6e6b 7329 0a7b 0a09 7374 643a e_links).{..std: │ │ │ +00031f70: 3a73 7472 696e 6720 7061 7468 203d 2063 :string path = c │ │ │ +00031f80: 6f6d 6269 6e65 5f70 6174 6828 7061 7265 ombine_path(pare │ │ │ +00031f90: 6e74 5f70 6174 6828 6375 7272 656e 745f nt_path(current_ │ │ │ +00031fa0: 776f 726b 696e 675f 6469 7265 6374 6f72 working_director │ │ │ +00031fb0: 7928 2929 0a09 092c 2022 6d75 7461 626c y())..., "mutabl │ │ │ +00031fc0: 655f 7465 7374 5f74 6f72 7265 6e74 7322 e_test_torrents" │ │ │ +00031fd0: 293b 0a0a 0966 6f72 2028 696e 7420 6920 );...for (int i │ │ │ +00031fe0: 3d20 303b 2069 2026 6c74 3b20 696e 7428 = 0; i < int( │ │ │ +00031ff0: 7369 7a65 6f66 2874 6573 745f 746f 7272 sizeof(test_torr │ │ │ +00032000: 656e 7473 292f 7369 7a65 6f66 2874 6573 ents)/sizeof(tes │ │ │ +00032010: 745f 746f 7272 656e 7473 5b30 5d29 293b t_torrents[0])); │ │ │ +00032020: 202b 2b69 290a 097b 0a09 0974 6573 745f ++i)..{...test_ │ │ │ +00032030: 746f 7272 656e 745f 7420 636f 6e73 7426 torrent_t const& │ │ │ +00032040: 616d 703b 2065 203d 2074 6573 745f 746f amp; e = test_to │ │ │ +00032050: 7272 656e 7473 5b69 5d3b 0a0a 0909 7374 rrents[i];....st │ │ │ +00032060: 643a 3a73 7472 696e 6720 7020 3d20 636f d::string p = co │ │ │ +00032070: 6d62 696e 655f 7061 7468 2870 6174 682c mbine_path(path, │ │ │ +00032080: 2065 2e66 696c 656e 616d 6531 2920 2b20 e.filename1) + │ │ │ +00032090: 222e 746f 7272 656e 7422 3b0a 0909 7374 ".torrent";...st │ │ │ +000320a0: 643a 3a70 7269 6e74 6628 226c 6f61 6469 d::printf("loadi │ │ │ +000320b0: 6e67 2025 735c 6e22 2c20 702e 635f 7374 ng %s\n", p.c_st │ │ │ +000320c0: 7228 2929 3b0a 0909 7374 643a 3a73 6861 r());...std::sha │ │ │ +000320d0: 7265 645f 7074 7226 6c74 3b74 6f72 7265 red_ptr<torre │ │ │ +000320e0: 6e74 5f69 6e66 6f26 6774 3b20 7469 3120 nt_info> ti1 │ │ │ +000320f0: 3d20 7374 643a 3a6d 616b 655f 7368 6172 = std::make_shar │ │ │ +00032100: 6564 266c 743b 746f 7272 656e 745f 696e ed<torrent_in │ │ │ +00032110: 666f 2667 743b 2870 293b 0a0a 0909 7020 fo>(p);....p │ │ │ +00032120: 3d20 636f 6d62 696e 655f 7061 7468 2870 = combine_path(p │ │ │ +00032130: 6174 682c 2065 2e66 696c 656e 616d 6532 ath, e.filename2 │ │ │ +00032140: 2920 2b20 222e 746f 7272 656e 7422 3b0a ) + ".torrent";. │ │ │ +00032150: 0909 7374 643a 3a70 7269 6e74 6628 226c ..std::printf("l │ │ │ +00032160: 6f61 6469 6e67 2025 735c 6e22 2c20 702e oading %s\n", p. │ │ │ +00032170: 635f 7374 7228 2929 3b0a 0909 7374 643a c_str());...std: │ │ │ +00032180: 3a73 6861 7265 645f 7074 7226 6c74 3b74 :shared_ptr<t │ │ │ +00032190: 6f72 7265 6e74 5f69 6e66 6f26 6774 3b20 orrent_info> │ │ │ +000321a0: 7469 3220 3d20 7374 643a 3a6d 616b 655f ti2 = std::make_ │ │ │ +000321b0: 7368 6172 6564 266c 743b 746f 7272 656e shared<torren │ │ │ +000321c0: 745f 696e 666f 2667 743b 2870 293b 0a0a t_info>(p);.. │ │ │ +000321d0: 0909 7374 643a 3a70 7269 6e74 6628 2272 ..std::printf("r │ │ │ +000321e0: 6573 6f6c 7669 6e67 5c6e 2229 3b0a 0909 esolving\n");... │ │ │ +000321f0: 7265 736f 6c76 655f 6c69 6e6b 7320 6c28 resolve_links l( │ │ │ +00032200: 7469 3129 3b0a 0909 6c2e 6d61 7463 6828 ti1);...l.match( │ │ │ +00032210: 7469 322c 2022 2e22 293b 0a0a 0909 6175 ti2, ".");....au │ │ │ +00032220: 783a 3a76 6563 746f 7226 6c74 3b72 6573 x::vector<res │ │ │ +00032230: 6f6c 7665 5f6c 696e 6b73 3a3a 6c69 6e6b olve_links::link │ │ │ +00032240: 5f74 2c20 6669 6c65 5f69 6e64 6578 5f74 _t, file_index_t │ │ │ +00032250: 2667 743b 2063 6f6e 7374 2661 6d70 3b20 > const& │ │ │ +00032260: 6c69 6e6b 7320 3d20 6c2e 6765 745f 6c69 links = l.get_li │ │ │ +00032270: 6e6b 7328 293b 0a0a 0909 6175 746f 2063 nks();....auto c │ │ │ +00032280: 6f6e 7374 206e 756d 5f6d 6174 6368 6573 onst num_matches │ │ │ +00032290: 203d 2073 7464 3a3a 7369 7a65 5f74 2873 = std::size_t(s │ │ │ +000322a0: 7464 3a3a 636f 756e 745f 6966 286c 696e td::count_if(lin │ │ │ +000322b0: 6b73 2e62 6567 696e 2829 2c20 6c69 6e6b ks.begin(), link │ │ │ +000322c0: 732e 656e 6428 290a 0909 092c 2073 7464 s.end()...., std │ │ │ +000322d0: 3a3a 6269 6e64 2826 616d 703b 7265 736f ::bind(&reso │ │ │ +000322e0: 6c76 655f 6c69 6e6b 733a 3a6c 696e 6b5f lve_links::link_ │ │ │ +000322f0: 743a 3a74 692c 205f 3129 2929 3b0a 0a09 t::ti, _1)));... │ │ │ +00032300: 092f 2f20 736f 6d65 2064 6562 7567 206f .// some debug o │ │ │ +00032310: 7574 7075 7420 696e 2063 6173 6520 7468 utput in case th │ │ │ +00032320: 6520 7465 7374 2066 6169 6c73 0a09 0969 e test fails...i │ │ │ +00032330: 6620 286e 756d 5f6d 6174 6368 6573 2026 f (num_matches & │ │ │ +00032340: 6774 3b20 652e 6578 7065 6374 6564 5f6d gt; e.expected_m │ │ │ +00032350: 6174 6368 6573 290a 0909 7b0a 0909 0966 atches)...{....f │ │ │ +00032360: 696c 655f 7374 6f72 6167 6520 636f 6e73 ile_storage cons │ │ │ +00032370: 7426 616d 703b 2066 7320 3d20 7469 312d t& fs = ti1- │ │ │ +00032380: 2667 743b 6669 6c65 7328 293b 0a3c 2f70 >files();.

    re │ │ │ +000323c0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../test/ │ │ │ +00032400: 7465 7374 5f62 6c6f 6f6d 5f66 696c 7465 test_bloom_filte │ │ │ +00032410: 722e 6370 703a 3133 353c 2f61 3e3c 2f74 r.cpp:135test size( │ │ │ +00032430: 293c 2f74 643e 3c2f 7472 3e3c 7472 2069 )

    t │ │ │ +00032480: 6573 7420 7369 7a65 2829 3c2f 6832 3e3c est size()

    < │ │ │ +00032490: 6834 3e2e 2e2f 7465 7374 2f74 6573 745f h4>../test/test_ │ │ │ +000324a0: 626c 6f6f 6d5f 6669 6c74 6572 2e63 7070 bloom_filter.cpp │ │ │ +000324b0: 3a31 3335 3c2f 6834 3e3c 7072 6520 7374 :135

    
    │ │ │ +00032520: 3c74 643e 7265 6c65 7661 6e63 6526 6e62  relevance&nb
    │ │ │ +00032530: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120  sp;0..
    │ │ │ +00032560: 2f74 6573 742f 7465 7374 5f62 6c6f 6f6d  /test/test_bloom
    │ │ │ +00032570: 5f66 696c 7465 722e 6370 703a 3133 363c  _filter.cpp:136<
    │ │ │ +00032580: 2f61 3e3c 2f74 643e 3c74 643e 7465 7374  /a>test
    │ │ │ +00032590: 2063 6c65 6172 2829 3c2f 7464 3e3c 2f74   clear()

    test clear │ │ │ +000325f0: 2829 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 ()

    ../te │ │ │ +00032600: 7374 2f74 6573 745f 626c 6f6f 6d5f 6669 st/test_bloom_fi │ │ │ +00032610: 6c74 6572 2e63 7070 3a31 3336 3c2f 6834 lter.cpp:136

    .sha1
    │ │ │ +00032660: 5f68 6173 6820 6b28 225c 7830 315c 7830  _hash k("\x01\x0
    │ │ │ +00032670: 305c 7830 325c 7830 3020 2020 2020 2020  0\x02\x00       
    │ │ │ +00032680: 2020 2020 2020 2020 2022 293b 0a09 5445           ");..TE
    │ │ │ +00032690: 5354 5f43 4845 434b 2821 6669 6c74 6572  ST_CHECK(!filter
    │ │ │ +000326a0: 2e66 696e 6428 6b29 293b 0a09 6669 6c74  .find(k));..filt
    │ │ │ +000326b0: 6572 2e73 6574 286b 293b 0a09 5445 5354  er.set(k);..TEST
    │ │ │ +000326c0: 5f43 4845 434b 2866 696c 7465 722e 6669  _CHECK(filter.fi
    │ │ │ +000326d0: 6e64 286b 2929 3b0a 0a09 7374 643a 3a75  nd(k));...std::u
    │ │ │ +000326e0: 696e 7438 5f74 2063 6f6d 7061 7265 5b34  int8_t compare[4
    │ │ │ +000326f0: 5d20 3d20 7b20 3078 3136 2c20 3078 6666  ] = { 0x16, 0xff
    │ │ │ +00032700: 2c20 3078 3535 2c20 3078 6161 7d3b 0a0a  , 0x55, 0xaa};..
    │ │ │ +00032710: 0962 6974 735f 6f75 7420 3d20 6669 6c74  .bits_out = filt
    │ │ │ +00032720: 6572 2e74 6f5f 7374 7269 6e67 2829 3b0a  er.to_string();.
    │ │ │ +00032730: 0954 4553 545f 4551 5541 4c28 6d65 6d63  .TEST_EQUAL(memc
    │ │ │ +00032740: 6d70 2863 6f6d 7061 7265 2c20 6269 7473  mp(compare, bits
    │ │ │ +00032750: 5f6f 7574 2e63 5f73 7472 2829 2c20 3429  _out.c_str(), 4)
    │ │ │ +00032760: 2c20 3029 3b0a 7d0a 0a7d 202f 2f20 616e  , 0);.}..} // an
    │ │ │ +00032770: 6f6e 796d 6f75 7320 6e61 6d65 7370 6163  onymous namespac
    │ │ │ +00032780: 650a 0a54 4f52 5245 4e54 5f54 4553 5428  e..TORRENT_TEST(
    │ │ │ +00032790: 626c 6f6f 6d5f 6669 6c74 6572 290a 7b0a  bloom_filter).{.
    │ │ │ +000327a0: 0974 6573 745f 7365 745f 616e 645f 6765  .test_set_and_ge
    │ │ │ +000327b0: 7428 293b 0a09 7465 7374 5f73 6574 5f62  t();..test_set_b
    │ │ │ +000327c0: 6974 7328 293b 0a09 7465 7374 5f63 6f75  its();..test_cou
    │ │ │ +000327d0: 6e74 5f7a 6572 6f65 7328 293b 0a09 7465  nt_zeroes();..te
    │ │ │ +000327e0: 7374 5f74 6f5f 6672 6f6d 5f73 7472 696e  st_to_from_strin
    │ │ │ +000327f0: 6728 293b 0a0a 3c64 6976 2073 7479 6c65  g();..
    }.
    rel │ │ │ +00032860: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0
    ../test/t │ │ │ +000328a0: 6573 745f 6468 742e 6370 703a 3438 383c est_dht.cpp:488< │ │ │ +000328b0: 2f61 3e3c 2f74 643e 3c74 643e 6368 6563 /a>chec │ │ │ +000328c0: 6b20 746f 206d 616b 6520 7375 7265 2074 k to make sure t │ │ │ +000328d0: 6865 2022 6265 7374 2220 6974 656d 7320 he "best" items │ │ │ +000328e0: 6172 6520 7374 6f72 6564 3c2f 7464 3e3c are stored< │ │ │ +000328f0: 2f74 723e 3c74 7220 6964 3d22 3130 3422 /tr>

    check to │ │ │ +00032940: 206d 616b 6520 7375 7265 2074 6865 2022 make sure the " │ │ │ +00032950: 6265 7374 2220 6974 656d 7320 6172 6520 best" items are │ │ │ +00032960: 7374 6f72 6564 3c2f 6832 3e3c 6834 3e2e stored

    . │ │ │ +00032970: 2e2f 7465 7374 2f74 6573 745f 6468 742e ./test/test_dht. │ │ │ +00032980: 6370 703a 3438 383c 2f68 343e 3c70 7265 cpp:488

    ..., msg_a
    │ │ │ +000329d0: 7267 7328 292e 7461 7267 6574 2869 7465  rgs().target(ite
    │ │ │ +000329e0: 6d73 5b6a 5d2e 7461 7267 6574 2929 3b0a  ms[j].target));.
    │ │ │ +000329f0: 0a09 096b 6579 5f64 6573 635f 7420 636f  ...key_desc_t co
    │ │ │ +00032a00: 6e73 7420 6465 7363 5b5d 203d 0a09 097b  nst desc[] =...{
    │ │ │ +00032a10: 0a09 0909 7b20 2272 222c 2062 6465 636f  ....{ "r", bdeco
    │ │ │ +00032a20: 6465 5f6e 6f64 653a 3a64 6963 745f 742c  de_node::dict_t,
    │ │ │ +00032a30: 2030 2c20 6b65 795f 6465 7363 5f74 3a3a   0, key_desc_t::
    │ │ │ +00032a40: 7061 7273 655f 6368 696c 6472 656e 207d  parse_children }
    │ │ │ +00032a50: 2c0a 0909 0909 7b20 2276 222c 2062 6465  ,.....{ "v", bde
    │ │ │ +00032a60: 636f 6465 5f6e 6f64 653a 3a64 6963 745f  code_node::dict_
    │ │ │ +00032a70: 742c 2030 2c20 307d 2c0a 0909 0909 7b20  t, 0, 0},.....{ 
    │ │ │ +00032a80: 2269 6422 2c20 6264 6563 6f64 655f 6e6f  "id", bdecode_no
    │ │ │ +00032a90: 6465 3a3a 7374 7269 6e67 5f74 2c20 3230  de::string_t, 20
    │ │ │ +00032aa0: 2c20 6b65 795f 6465 7363 5f74 3a3a 6c61  , key_desc_t::la
    │ │ │ +00032ab0: 7374 5f63 6869 6c64 7d2c 0a09 0909 7b20  st_child},....{ 
    │ │ │ +00032ac0: 2279 222c 2062 6465 636f 6465 5f6e 6f64  "y", bdecode_nod
    │ │ │ +00032ad0: 653a 3a73 7472 696e 675f 742c 2031 2c20  e::string_t, 1, 
    │ │ │ +00032ae0: 307d 2c0a 0909 7d3b 0a0a 0909 6264 6563  0},...};....bdec
    │ │ │ +00032af0: 6f64 655f 6e6f 6465 2070 6172 7365 645b  ode_node parsed[
    │ │ │ +00032b00: 345d 3b0a 0909 6368 6172 2065 7272 6f72  4];...char error
    │ │ │ +00032b10: 5f73 7472 696e 675b 3230 305d 3b0a 0a09  _string[200];...
    │ │ │ +00032b20: 0969 6e74 2072 6574 203d 2076 6572 6966  .int ret = verif
    │ │ │ +00032b30: 795f 6d65 7373 6167 6528 7265 7370 6f6e  y_message(respon
    │ │ │ +00032b40: 7365 2c20 6465 7363 2c20 7061 7273 6564  se, desc, parsed
    │ │ │ +00032b50: 2c20 6572 726f 725f 7374 7269 6e67 293b  , error_string);
    │ │ │ +00032b60: 0a09 0969 6620 2872 6574 290a 0909 7b0a  ...if (ret)...{.
    │ │ │ +00032b70: 0909 0969 7465 6d73 5f6e 756d 2e69 6e73  ...items_num.ins
    │ │ │ +00032b80: 6572 7428 6974 656d 735f 6e75 6d2e 6265  ert(items_num.be
    │ │ │ +00032b90: 6769 6e28 292c 206a 293b 0a09 097d 0a09  gin(), j);...}..
    │ │ │ +00032ba0: 7d0a 0a3c 6469 7620 7374 796c 653d 2262  }..
    .TEST_EQUAL(ite │ │ │ +00032be0: 6d73 5f6e 756d 2e73 697a 6528 292c 2034 ms_num.size(), 4 │ │ │ +00032bf0: 293b 0a3c 2f64 6976 3e7d 0a0a 696e 7420 );.
    }..int │ │ │ +00032c00: 7375 6d5f 6469 7374 616e 6365 5f65 7870 sum_distance_exp │ │ │ +00032c10: 2869 6e74 2073 2c20 6e6f 6465 5f65 6e74 (int s, node_ent │ │ │ +00032c20: 7279 2063 6f6e 7374 2661 6d70 3b20 652c ry const& e, │ │ │ +00032c30: 206e 6f64 655f 6964 2063 6f6e 7374 2661 node_id const&a │ │ │ +00032c40: 6d70 3b20 7265 6629 0a7b 0a09 7265 7475 mp; ref).{..retu │ │ │ +00032c50: 726e 2073 202b 2064 6973 7461 6e63 655f rn s + distance_ │ │ │ +00032c60: 6578 7028 652e 6964 2c20 7265 6629 3b0a exp(e.id, ref);. │ │ │ +00032c70: 7d0a 0a73 7464 3a3a 7665 6374 6f72 266c }..std::vector&l │ │ │ +00032c80: 743b 7463 703a 3a65 6e64 706f 696e 7426 t;tcp::endpoint& │ │ │ +00032c90: 6774 3b20 675f 676f 745f 7065 6572 733b gt; g_got_peers; │ │ │ +00032ca0: 0a0a 766f 6964 2067 6574 5f70 6565 7273 ..void get_peers │ │ │ +00032cb0: 5f63 6228 7374 643a 3a76 6563 746f 7226 _cb(std::vector& │ │ │ +00032cc0: 6c74 3b74 6370 3a3a 656e 6470 6f69 6e74 lt;tcp::endpoint │ │ │ +00032cd0: 2667 743b 2063 6f6e 7374 2661 6d70 3b20 > const& │ │ │ +00032ce0: 7065 6572 7329 0a7b 0a09 675f 676f 745f peers).{..g_got_ │ │ │ +00032cf0: 7065 6572 732e 696e 7365 7274 2867 5f67 peers.insert(g_g │ │ │ +00032d00: 6f74 5f70 6565 7273 2e65 6e64 2829 2c20 ot_peers.end(), │ │ │ +00032d10: 7065 6572 732e 6265 6769 6e28 292c 2070 peers.begin(), p │ │ │ +00032d20: 6565 7273 2e65 6e64 2829 293b 0a7d 0a0a eers.end());.}.. │ │ │ +00032d30: 7374 643a 3a76 6563 746f 7226 6c74 3b64 std::vector<d │ │ │ +00032d40: 6874 3a3a 6974 656d 2667 743b 2067 5f67 ht::item> g_g │ │ │ +00032d50: 6f74 5f69 7465 6d73 3b0a 6468 743a 3a69 ot_items;.dht::i │ │ │ +00032d60: 7465 6d20 675f 7075 745f 6974 656d 3b0a tem g_put_item;. │ │ │ +00032d70: 696e 7420 675f 7075 745f 636f 756e 743b int g_put_count; │ │ │ +00032d80: 0a0a 766f 6964 2067 6574 5f6d 7574 6162 ..void get_mutab │ │ │ +00032d90: 6c65 5f69 7465 6d5f 6362 2864 6874 3a3a le_item_cb(dht:: │ │ │ +00032da0: 6974 656d 2063 6f6e 7374 2661 6d70 3b20 item const& │ │ │ +00032db0: 692c 2062 6f6f 6c20 6129 0a7b 0a09 6966 i, bool a).{..if │ │ │ +00032dc0: 2028 2161 2920 7265 7475 726e 3b0a 0969 (!a) return;..i │ │ │ +00032dd0: 6620 2821 692e 656d 7074 7928 2929 0a09 f (!i.empty()).. │ │ │ +00032de0: 0967 5f67 6f74 5f69 7465 6d73 2e70 7573 .g_got_items.pus │ │ │ +00032df0: 685f 6261 636b 2869 293b 0a7d 0a0a 766f h_back(i);.}..vo │ │ │ +00032e00: 6964 2070 7574 5f6d 7574 6162 6c65 5f69 id put_mutable_i │ │ │ +00032e10: 7465 6d5f 6461 7461 5f63 6228 6468 743a tem_data_cb(dht: │ │ │ +00032e20: 3a69 7465 6d26 616d 703b 2069 290a 7b0a :item& i).{. │ │ │ +00032e30: 0969 6620 2821 692e 656d 7074 7928 2929 .if (!i.empty()) │ │ │ +00032e40: 0a09 0967 5f67 6f74 5f69 7465 6d73 2e70 ...g_got_items.p │ │ │ +00032e50: 7573 685f 6261 636b 2869 293b 0a0a 3c2f ush_back(i);..r │ │ │ +00032e90: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +00032ea0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>
    ../test │ │ │ +00032ed0: 2f74 6573 745f 6468 742e 6370 703a 3332 /test_dht.cpp:32 │ │ │ +00032ee0: 3339 3c2f 613e 3c2f 7464 3e3c 7464 3e74 39t │ │ │ +00032ef0: 6869 7320 776f 6e27 7420 776f 726b 2062 his won't work b │ │ │ +00032f00: 6563 6175 7365 2074 6865 2073 6563 6f6e ecause the secon │ │ │ +00032f10: 6420 6e6f 6465 2069 736e 2774 2070 696e d node isn't pin │ │ │ +00032f20: 6765 6420 736f 2069 7420 776f 6e74 2062 ged so it wont b │ │ │ +00032f30: 6520 6164 6465 6420 746f 2074 6865 2072 e added to the r │ │ │ +00032f40: 6f75 7469 6e67 2074 6162 6c65 3c2f 7464 outing table

    this w │ │ │ +00032fa0: 6f6e 2774 2077 6f72 6b20 6265 6361 7573 on't work becaus │ │ │ +00032fb0: 6520 7468 6520 7365 636f 6e64 206e 6f64 e the second nod │ │ │ +00032fc0: 6520 6973 6e27 7420 7069 6e67 6564 2073 e isn't pinged s │ │ │ +00032fd0: 6f20 6974 2077 6f6e 740a 6265 2061 6464 o it wont.be add │ │ │ +00032fe0: 6564 2074 6f20 7468 6520 726f 7574 696e ed to the routin │ │ │ +00032ff0: 6720 7461 626c 653c 2f68 323e 3c68 343e g table

    │ │ │ +00033000: 2e2e 2f74 6573 742f 7465 7374 5f64 6874 ../test/test_dht │ │ │ +00033010: 2e63 7070 3a33 3233 393c 2f68 343e 3c70 .cpp:3239

    .bool re │ │ │ +00033060: 7420 3d20 7665 7269 6679 5f6d 6573 7361 t = verify_messa │ │ │ +00033070: 6765 2872 6571 7565 7374 2c20 6765 745f ge(request, get_ │ │ │ +00033080: 6974 656d 5f64 6573 635f 726f 2c20 7061 item_desc_ro, pa │ │ │ +00033090: 7273 6564 2c20 6572 726f 725f 7374 7269 rsed, error_stri │ │ │ +000330a0: 6e67 293b 0a0a 0954 4553 545f 4348 4543 ng);...TEST_CHEC │ │ │ +000330b0: 4b28 7265 7429 3b0a 0954 4553 545f 4551 K(ret);..TEST_EQ │ │ │ +000330c0: 5541 4c28 7061 7273 6564 5b33 5d2e 696e UAL(parsed[3].in │ │ │ +000330d0: 745f 7661 6c75 6528 292c 2031 293b 0a0a t_value(), 1);.. │ │ │ +000330e0: 092f 2f20 7368 6f75 6c64 2068 6176 6520 .// should have │ │ │ +000330f0: 6f6e 6520 6e6f 6465 206e 6f77 2c20 7768 one node now, wh │ │ │ +00033100: 6963 6820 6973 2034 2e34 2e34 2e34 3a31 ich is 4.4.4.4:1 │ │ │ +00033110: 3233 340a 0954 4553 545f 4551 5541 4c28 234..TEST_EQUAL( │ │ │ +00033120: 7374 643a 3a67 6574 266c 743b 3026 6774 std::get<0> │ │ │ +00033130: 3b28 6e6f 6465 2e73 697a 6528 2929 2c20 ;(node.size()), │ │ │ +00033140: 3129 3b0a 092f 2f20 616e 6420 6e6f 2072 1);..// and no r │ │ │ +00033150: 6570 6c61 6365 6d65 6e74 206e 6f64 6573 eplacement nodes │ │ │ +00033160: 0a09 5445 5354 5f45 5155 414c 2873 7464 ..TEST_EQUAL(std │ │ │ +00033170: 3a3a 6765 7426 6c74 3b31 2667 743b 286e ::get<1>(n │ │ │ +00033180: 6f64 652e 7369 7a65 2829 292c 2030 293b ode.size()), 0); │ │ │ +00033190: 0a0a 092f 2f20 6e6f 772c 2064 6973 6162 ...// now, disab │ │ │ +000331a0: 6c65 2072 6561 645f 6f6e 6c79 2c20 7472 le read_only, tr │ │ │ +000331b0: 7920 6167 6169 6e2e 0a09 675f 7365 6e74 y again...g_sent │ │ │ +000331c0: 5f70 6163 6b65 7473 2e63 6c65 6172 2829 _packets.clear() │ │ │ +000331d0: 3b0a 0973 6574 742e 7365 745f 626f 6f6c ;..sett.set_bool │ │ │ +000331e0: 2873 6574 7469 6e67 735f 7061 636b 3a3a (settings_pack:: │ │ │ +000331f0: 6468 745f 7265 6164 5f6f 6e6c 792c 2066 dht_read_only, f │ │ │ +00033200: 616c 7365 293b 0a0a 0973 656e 645f 6468 alse);...send_dh │ │ │ +00033210: 745f 7265 7175 6573 7428 6e6f 6465 2c20 t_request(node, │ │ │ +00033220: 2267 6574 222c 2073 6f75 7263 652c 2026 "get", source, & │ │ │ +00033230: 616d 703b 7265 7370 6f6e 7365 293b 0a09 amp;response);.. │ │ │ +00033240: 2f2f 2073 656e 6465 7220 7368 6f75 6c64 // sender should │ │ │ +00033250: 2062 6520 6164 6465 6420 746f 2072 6570 be added to rep │ │ │ +00033260: 6c61 6365 6d65 6e74 2062 7563 6b65 740a lacement bucket. │ │ │ +00033270: 0954 4553 545f 4551 5541 4c28 7374 643a .TEST_EQUAL(std: │ │ │ +00033280: 3a67 6574 266c 743b 3126 6774 3b28 6e6f :get<1>(no │ │ │ +00033290: 6465 2e73 697a 6528 2929 2c20 3129 3b0a de.size()), 1);. │ │ │ +000332a0: 0a09 675f 7365 6e74 5f70 6163 6b65 7473 ..g_sent_packets │ │ │ +000332b0: 2e63 6c65 6172 2829 3b0a 2369 6620 300a .clear();.#if 0. │ │ │ +000332c0: 3c64 6976 2073 7479 6c65 3d22 6261 636b

    .t │ │ │ +000332f0: 6172 6765 7420 3d20 6765 6e65 7261 7465 arget = generate │ │ │ +00033300: 5f6e 6578 7428 293b 0a3c 2f64 6976 3e09 _next();.
    . │ │ │ +00033310: 6e6f 6465 2e67 6574 5f69 7465 6d28 7461 node.get_item(ta │ │ │ +00033320: 7267 6574 2c20 6765 745f 696d 6d75 7461 rget, get_immuta │ │ │ +00033330: 626c 655f 6974 656d 5f63 6229 3b0a 0a09 ble_item_cb);... │ │ │ +00033340: 2f2f 2073 696e 6365 2077 6520 6861 7665 // since we have │ │ │ +00033350: 2032 206e 6f64 6573 2c20 7765 2073 686f 2 nodes, we sho │ │ │ +00033360: 756c 6420 6861 7665 2074 776f 2070 6163 uld have two pac │ │ │ +00033370: 6b65 7473 2e0a 0954 4553 545f 4551 5541 kets...TEST_EQUA │ │ │ +00033380: 4c28 675f 7365 6e74 5f70 6163 6b65 7473 L(g_sent_packets │ │ │ +00033390: 2e73 697a 6528 292c 2032 293b 0a0a 092f .size(), 2);.../ │ │ │ +000333a0: 2f20 626f 7468 206f 6620 7468 656d 2073 / both of them s │ │ │ +000333b0: 686f 756c 646e 2774 2068 6176 6520 6120 houldn't have a │ │ │ +000333c0: 2772 6f27 206b 6579 2e0a 096e 6f64 655f 'ro' key...node_ │ │ │ +000333d0: 6672 6f6d 5f65 6e74 7279 2867 5f73 656e from_entry(g_sen │ │ │ +000333e0: 745f 7061 636b 6574 732e 6672 6f6e 7428 t_packets.front( │ │ │ +000333f0: 292e 7365 636f 6e64 2c20 7265 7175 6573 ).second, reques │ │ │ +00033400: 7429 3b0a 0972 6574 203d 2076 6572 6966 t);..ret = verif │ │ │ +00033410: 795f 6d65 7373 6167 6528 7265 7175 6573 y_message(reques │ │ │ +00033420: 742c 2067 6574 5f69 7465 6d5f 6465 7363 t, get_item_desc │ │ │ +00033430: 5f72 6f2c 2070 6172 7365 642c 2065 7272 _ro, parsed, err │ │ │ +00033440: 6f72 5f73 7472 696e 6729 3b0a 0a09 5445 or_string);...TE │ │ │ +00033450: 5354 5f43 4845 434b 2872 6574 293b 0a09 ST_CHECK(ret);.. │ │ │ +00033460: 5445 5354 5f43 4845 434b 2821 7061 7273 TEST_CHECK(!pars │ │ │ +00033470: 6564 5b33 5d29 3b0a 0a09 6e6f 6465 5f66 ed[3]);...node_f │ │ │ +00033480: 726f 6d5f 656e 7472 7928 675f 7365 6e74 rom_entry(g_sent │ │ │ +00033490: 5f70 6163 6b65 7473 2e62 6163 6b28 292e _packets.back(). │ │ │ +000334a0: 7365 636f 6e64 2c20 7265 7175 6573 7429 second, request) │ │ │ +000334b0: 3b0a 0972 6574 203d 2076 6572 6966 795f ;..ret = verify_ │ │ │ +000334c0: 6d65 7373 6167 6528 7265 7175 6573 742c message(request, │ │ │ +000334d0: 2067 6574 5f69 7465 6d5f 6465 7363 5f72 get_item_desc_r │ │ │ +000334e0: 6f2c 2070 6172 7365 642c 2065 7272 6f72 o, parsed, error │ │ │ +000334f0: 5f73 7472 696e 6729 3b0a 0a09 5445 5354 _string);...TEST │ │ │ +00033500: 5f43 4845 434b 2872 6574 293b 0a09 5445 _CHECK(ret);..TE │ │ │ +00033510: 5354 5f43 4845 434b 2821 7061 7273 6564 ST_CHECK(!parsed │ │ │ +00033520: 5b33 5d29 3b0a 2365 6e64 6966 0a7d 0a0a [3]);.#endif.}.. │ │ │ +00033530: 544f 5252 454e 545f 5445 5354 2872 7063 TORRENT_TEST(rpc │ │ │ +00033540: 5f72 6570 6c79 5f69 676e 6f72 6573 5f77 _reply_ignores_w │ │ │ +00033550: 726f 6e67 5f70 6f72 7429 0a7b 0a09 6175 rong_port).{..au │ │ │ +00033560: 746f 2073 6574 7420 3d20 7465 7374 5f73 to sett = test_s │ │ │ +00033570: 6574 7469 6e67 7328 293b 0a09 6d6f 636b ettings();..mock │ │ │ +00033580: 5f73 6f63 6b65 7420 733b 0a09 6175 746f _socket s;..auto │ │ │ +00033590: 206c 7320 3d20 6475 6d6d 795f 6c69 7374 ls = dummy_list │ │ │ +000335a0: 656e 5f73 6f63 6b65 7434 2829 3b0a 096f en_socket4();..o │ │ │ +000335b0: 6273 206f 6273 6572 7665 723b 0a09 636f bs observer;..co │ │ │ +000335c0: 756e 7465 7273 2063 6e74 3b0a 0a09 6468 unters cnt;...dh │ │ │ +000335d0: 743a 3a72 6f75 7469 6e67 5f74 6162 6c65 t::routing_table │ │ │ +000335e0: 2074 6162 6c65 286e 6f64 655f 6964 2829 table(node_id() │ │ │ +000335f0: 2c20 7564 703a 3a76 3428 292c 2038 2c20 , udp::v4(), 8, │ │ │ +00033600: 7365 7474 2c20 2661 6d70 3b6f 6273 6572 sett, &obser │ │ │ +00033610: 7665 7229 3b0a 0964 6874 3a3a 7270 635f ver);..dht::rpc_ │ │ │ +00033620: 6d61 6e61 6765 7220 7270 6328 6e6f 6465 manager rpc(node │ │ │ +00033630: 5f69 6428 292c 2073 6574 742c 2074 6162 _id(), sett, tab │ │ │ +00033640: 6c65 2c20 6c73 2c20 2661 6d70 3b73 2c20 le, ls, &s, │ │ │ +00033650: 2661 6d70 3b6f 6273 6572 7665 7229 3b0a &observer);. │ │ │ +00033660: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +00033670: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +000336a0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../te │ │ │ +000336d0: 7374 2f74 6573 745f 6468 742e 6370 703a st/test_dht.cpp: │ │ │ +000336e0: 3431 3530 3c2f 613e 3c2f 7464 3e3c 7464 4150test obfuscated │ │ │ +00033700: 5f67 6574 5f70 6565 7273 3c2f 7464 3e3c _get_peers< │ │ │ +00033710: 2f74 723e 3c74 7220 6964 3d22 3130 3622 /tr>

    test obf │ │ │ +00033760: 7573 6361 7465 645f 6765 745f 7065 6572 uscated_get_peer │ │ │ +00033770: 733c 2f68 323e 3c68 343e 2e2e 2f74 6573 s

    ../tes │ │ │ +00033780: 742f 7465 7374 5f64 6874 2e63 7070 3a34 t/test_dht.cpp:4 │ │ │ +00033790: 3135 303c 2f68 343e 3c70 7265 2073 7479 150

    ..TEST_CHECK(s
    │ │ │ +000337e0: 6d2e 6861 735f 7175 6f74 6128 2929 3b0a  m.has_quota());.
    │ │ │ +000337f0: 097d 293b 0a7d 0a0a 544f 5252 454e 545f  .});.}..TORRENT_
    │ │ │ +00033800: 5445 5354 2872 6174 655f 6c69 6d69 745f  TEST(rate_limit_
    │ │ │ +00033810: 6163 6372 7565 5f6c 696d 6974 290a 7b0a  accrue_limit).{.
    │ │ │ +00033820: 0961 7578 3a3a 7365 7373 696f 6e5f 7365  .aux::session_se
    │ │ │ +00033830: 7474 696e 6773 2073 6574 743b 0a09 7365  ttings sett;..se
    │ │ │ +00033840: 7474 2e73 6574 5f69 6e74 2873 6574 7469  tt.set_int(setti
    │ │ │ +00033850: 6e67 735f 7061 636b 3a3a 6468 745f 7570  ngs_pack::dht_up
    │ │ │ +00033860: 6c6f 6164 5f72 6174 655f 6c69 6d69 742c  load_rate_limit,
    │ │ │ +00033870: 2073 7464 3a3a 6e75 6d65 7269 635f 6c69   std::numeric_li
    │ │ │ +00033880: 6d69 7473 266c 743b 696e 7426 6774 3b3a  mits<int>:
    │ │ │ +00033890: 3a6d 6178 2829 293b 0a0a 0974 6573 745f  :max());...test_
    │ │ │ +000338a0: 7261 7465 5f6c 696d 6974 2873 6574 742c  rate_limit(sett,
    │ │ │ +000338b0: 205b 5d28 6c74 3a3a 6468 743a 3a73 6f63   [](lt::dht::soc
    │ │ │ +000338c0: 6b65 745f 6d61 6e61 6765 7226 616d 703b  ket_manager&
    │ │ │ +000338d0: 2073 6d29 207b 0a09 0954 4553 545f 4348   sm) {...TEST_CH
    │ │ │ +000338e0: 4543 4b28 736d 2e68 6173 5f71 756f 7461  ECK(sm.has_quota
    │ │ │ +000338f0: 2829 293b 0a09 0966 6f72 2028 696e 7420  ());...for (int 
    │ │ │ +00033900: 6920 3d20 303b 2069 2026 6c74 3b20 3130  i = 0; i < 10
    │ │ │ +00033910: 3b20 2b2b 6929 0a09 097b 0a09 0909 7374  ; ++i)...{....st
    │ │ │ +00033920: 643a 3a74 6869 735f 7468 7265 6164 3a3a  d::this_thread::
    │ │ │ +00033930: 736c 6565 705f 666f 7228 6d69 6c6c 6973  sleep_for(millis
    │ │ │ +00033940: 6563 6f6e 6473 2835 3030 2929 3b0a 0909  econds(500));...
    │ │ │ +00033950: 0954 4553 545f 4348 4543 4b28 736d 2e68  .TEST_CHECK(sm.h
    │ │ │ +00033960: 6173 5f71 756f 7461 2829 293b 0a09 097d  as_quota());...}
    │ │ │ +00033970: 0a09 7d29 3b0a 7d0a 0a0a 3c64 6976 2073  ..});.}...
    .
    # │ │ │ +000339b0: 656c 7365 0a54 4f52 5245 4e54 5f54 4553 else.TORRENT_TES │ │ │ +000339c0: 5428 6468 7429 0a7b 0a09 2f2f 2064 756d T(dht).{..// dum │ │ │ +000339d0: 6d79 2064 6874 2074 6573 740a 0954 4553 my dht test..TES │ │ │ +000339e0: 545f 4348 4543 4b28 7472 7565 293b 0a7d T_CHECK(true);.} │ │ │ +000339f0: 0a0a 2365 6e64 6966 0a3c 2f70 7265 3e3c ..#endif.
    < │ │ │ +00033a00: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00033a30: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +00033a40: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test │ │ │ +00033a70: 5f74 7261 636b 6572 2e63 7070 3a36 303c _tracker.cpp:60< │ │ │ +00033a80: 2f61 3e3c 2f74 643e 3c74 643e 7465 7374 /a>test │ │ │ +00033a90: 2073 6372 6170 6520 7265 7175 6573 7473 scrape requests │ │ │ +00033aa0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    te │ │ │ +00033af0: 7374 2073 6372 6170 6520 7265 7175 6573 st scrape reques │ │ │ +00033b00: 7473 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 ts

    ../te │ │ │ +00033b10: 7374 2f74 6573 745f 7472 6163 6b65 722e st/test_tracker. │ │ │ +00033b20: 6370 703a 3630 3c2f 6834 3e3c 7072 6520 cpp:60

    
    │ │ │ +00033b70: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22  relevance&
    │ │ │ +00033ba0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c  nbsp;0<
    │ │ │ +00033bb0: 6120 6872 6566 3d22 6a61 7661 7363 7269  a href="javascri
    │ │ │ +00033bc0: 7074 3a65 7870 616e 6428 3130 3829 223e  pt:expand(108)">
    │ │ │ +00033bd0: 2e2e 2f74 6573 742f 7465 7374 5f74 7261  ../test/test_tra
    │ │ │ +00033be0: 636b 6572 2e63 7070 3a36 313c 2f61 3e3c  cker.cpp:61
    < │ │ │ +00033bf0: 2f74 643e 3c74 643e 7465 7374 2070 6172 /td>test par │ │ │ +00033c00: 7365 2070 6565 7273 363c 2f74 643e 3c2f se peers6

    test pars │ │ │ +00033c60: 6520 7065 6572 7336 3c2f 6832 3e3c 6834 e peers6

    ../test/test_tr │ │ │ +00033c80: 6163 6b65 722e 6370 703a 3631 3c2f 6834 acker.cpp:61

    rele
    │ │ │ +00033d00: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../test/te
    │ │ │ +00033d40: 7374 5f74 7261 636b 6572 2e63 7070 3a36  st_tracker.cpp:6
    │ │ │ +00033d50: 323c 2f61 3e3c 2f74 643e 3c74 643e 7465  2te
    │ │ │ +00033d60: 7374 2070 6172 7365 2074 7261 636b 6572  st parse tracker
    │ │ │ +00033d70: 2d69 643c 2f74 643e 3c2f 7472 3e3c 7472  -id

    test parse trac │ │ │ +00033dd0: 6b65 722d 6964 3c2f 6832 3e3c 6834 3e2e ker-id

    . │ │ │ +00033de0: 2e2f 7465 7374 2f74 6573 745f 7472 6163 ./test/test_trac │ │ │ +00033df0: 6b65 722e 6370 703a 3632 3c2f 6834 3e3c ker.cpp:62

    < │ │ │ +00033e00: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00033e10: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00033e20: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00033e30: 7820 2364 6464 3b22 3e3c 2f70 7265 3e3c x #ddd;">
    < │ │ │ +00033e40: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00033e70: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +00033e80: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../test/test │ │ │ +00033eb0: 5f74 7261 636b 6572 2e63 7070 3a36 333c _tracker.cpp:63< │ │ │ +00033ec0: 2f61 3e3c 2f74 643e 3c74 643e 7465 7374 /a>test │ │ │ +00033ed0: 2070 6172 7365 2066 6169 6c75 7265 2d72 parse failure-r │ │ │ +00033ee0: 6561 736f 6e3c 2f74 643e 3c2f 7472 3e3c eason< │ │ │ +00033ef0: 7472 2069 643d 2231 3130 2220 7374 796c tr id="110" styl │ │ │ +00033f00: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00033f10: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00033f20: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00033f30: 6832 3e74 6573 7420 7061 7273 6520 6661 h2>test parse fa │ │ │ +00033f40: 696c 7572 652d 7265 6173 6f6e 3c2f 6832 ilure-reason

    ../test/tes │ │ │ +00033f60: 745f 7472 6163 6b65 722e 6370 703a 3633 t_tracker.cpp:63 │ │ │ +00033f70: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ +00033fb0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ +00033fc0: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ +00033fd0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ +00033fe0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ +00033ff0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../tes
    │ │ │ +00034020: 742f 7465 7374 5f74 7261 636b 6572 2e63  t/test_tracker.c
    │ │ │ +00034030: 7070 3a36 343c 2f61 3e3c 2f74 643e 3c74  pp:64test all failu
    │ │ │ +00034050: 7265 2070 6174 6873 2c20 696e 636c 7564  re paths, includ
    │ │ │ +00034060: 696e 6720 696e 7661 6c69 6420 6265 6e63  ing invalid benc
    │ │ │ +00034070: 6f64 696e 6720 6e6f 7420 6120 6469 6374  oding not a dict
    │ │ │ +00034080: 696f 6e61 7279 206e 6f20 6669 6c65 7320  ionary no files 
    │ │ │ +00034090: 656e 7472 7920 696e 2073 6372 6170 6520  entry in scrape 
    │ │ │ +000340a0: 7265 7370 6f6e 7365 206e 6f20 696e 666f  response no info
    │ │ │ +000340b0: 2d68 6173 6820 656e 7472 7920 696e 2073  -hash entry in s
    │ │ │ +000340c0: 6372 6170 6520 7265 7370 6f6e 7365 206d  crape response m
    │ │ │ +000340d0: 616c 666f 726d 6564 2070 6565 7273 2069  alformed peers i
    │ │ │ +000340e0: 6e20 7065 6572 206c 6973 7420 6f66 2064  n peer list of d
    │ │ │ +000340f0: 6963 7469 6f6e 6172 6965 7320 756e 6576  ictionaries unev
    │ │ │ +00034100: 656e 206e 756d 6265 7220 6f66 2062 7974  en number of byt
    │ │ │ +00034110: 6573 2069 6e20 7065 6572 7320 616e 6420  es in peers and 
    │ │ │ +00034120: 7065 6572 7336 2073 7472 696e 6720 7265  peers6 string re
    │ │ │ +00034130: 7370 6f6e 7365 733c 2f74 643e 3c2f 7472  sponses

    test all fa │ │ │ +00034190: 696c 7572 6520 7061 7468 732c 2069 6e63 ilure paths, inc │ │ │ +000341a0: 6c75 6469 6e67 0a69 6e76 616c 6964 2062 luding.invalid b │ │ │ +000341b0: 656e 636f 6469 6e67 0a6e 6f74 2061 2064 encoding.not a d │ │ │ +000341c0: 6963 7469 6f6e 6172 790a 6e6f 2066 696c ictionary.no fil │ │ │ +000341d0: 6573 2065 6e74 7279 2069 6e20 7363 7261 es entry in scra │ │ │ +000341e0: 7065 2072 6573 706f 6e73 650a 6e6f 2069 pe response.no i │ │ │ +000341f0: 6e66 6f2d 6861 7368 2065 6e74 7279 2069 nfo-hash entry i │ │ │ +00034200: 6e20 7363 7261 7065 2072 6573 706f 6e73 n scrape respons │ │ │ +00034210: 650a 6d61 6c66 6f72 6d65 6420 7065 6572 e.malformed peer │ │ │ +00034220: 7320 696e 2070 6565 7220 6c69 7374 206f s in peer list o │ │ │ +00034230: 6620 6469 6374 696f 6e61 7269 6573 0a75 f dictionaries.u │ │ │ +00034240: 6e65 7665 6e20 6e75 6d62 6572 206f 6620 neven number of │ │ │ +00034250: 6279 7465 7320 696e 2070 6565 7273 2061 bytes in peers a │ │ │ +00034260: 6e64 2070 6565 7273 3620 7374 7269 6e67 nd peers6 string │ │ │ +00034270: 2072 6573 706f 6e73 6573 3c2f 6832 3e3c responses

    < │ │ │ +00034280: 6834 3e2e 2e2f 7465 7374 2f74 6573 745f h4>../test/test_ │ │ │ +00034290: 7472 6163 6b65 722e 6370 703a 3634 3c2f tracker.cpp:64
    #in
    │ │ │ +000342e0: 636c 7564 6520 2274 6573 745f 7574 696c  clude "test_util
    │ │ │ +000342f0: 732e 6870 7022 0a23 696e 636c 7564 6520  s.hpp".#include 
    │ │ │ +00034300: 2275 6470 5f74 7261 636b 6572 2e68 7070  "udp_tracker.hpp
    │ │ │ +00034310: 220a 2369 6e63 6c75 6465 2022 7365 7474  ".#include "sett
    │ │ │ +00034320: 696e 6773 2e68 7070 220a 2369 6e63 6c75  ings.hpp".#inclu
    │ │ │ +00034330: 6465 2022 7465 7374 5f75 7469 6c73 2e68  de "test_utils.h
    │ │ │ +00034340: 7070 220a 2369 6e63 6c75 6465 2022 6c69  pp".#include "li
    │ │ │ +00034350: 6274 6f72 7265 6e74 2f61 6c65 7274 2e68  btorrent/alert.h
    │ │ │ +00034360: 7070 220a 2369 6e63 6c75 6465 2022 6c69  pp".#include "li
    │ │ │ +00034370: 6274 6f72 7265 6e74 2f70 6565 725f 696e  btorrent/peer_in
    │ │ │ +00034380: 666f 2e68 7070 2220 2f2f 2066 6f72 2070  fo.hpp" // for p
    │ │ │ +00034390: 6565 725f 6c69 7374 5f65 6e74 7279 0a23  eer_list_entry.#
    │ │ │ +000343a0: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ +000343b0: 656e 742f 616c 6572 745f 7479 7065 732e  ent/alert_types.
    │ │ │ +000343c0: 6870 7022 0a23 696e 636c 7564 6520 226c  hpp".#include "l
    │ │ │ +000343d0: 6962 746f 7272 656e 742f 7365 7373 696f  ibtorrent/sessio
    │ │ │ +000343e0: 6e2e 6870 7022 0a23 696e 636c 7564 6520  n.hpp".#include 
    │ │ │ +000343f0: 226c 6962 746f 7272 656e 742f 7365 7373  "libtorrent/sess
    │ │ │ +00034400: 696f 6e5f 7061 7261 6d73 2e68 7070 220a  ion_params.hpp".
    │ │ │ +00034410: 2369 6e63 6c75 6465 2022 6c69 6274 6f72  #include "libtor
    │ │ │ +00034420: 7265 6e74 2f65 7272 6f72 5f63 6f64 652e  rent/error_code.
    │ │ │ +00034430: 6870 7022 0a23 696e 636c 7564 6520 226c  hpp".#include "l
    │ │ │ +00034440: 6962 746f 7272 656e 742f 7472 6163 6b65  ibtorrent/tracke
    │ │ │ +00034450: 725f 6d61 6e61 6765 722e 6870 7022 0a23  r_manager.hpp".#
    │ │ │ +00034460: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ +00034470: 656e 742f 6874 7470 5f74 7261 636b 6572  ent/http_tracker
    │ │ │ +00034480: 5f63 6f6e 6e65 6374 696f 6e2e 6870 7022  _connection.hpp"
    │ │ │ +00034490: 202f 2f20 666f 7220 7061 7273 655f 7472   // for parse_tr
    │ │ │ +000344a0: 6163 6b65 725f 7265 7370 6f6e 7365 0a23  acker_response.#
    │ │ │ +000344b0: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ +000344c0: 656e 742f 746f 7272 656e 745f 696e 666f  ent/torrent_info
    │ │ │ +000344d0: 2e68 7070 220a 2369 6e63 6c75 6465 2022  .hpp".#include "
    │ │ │ +000344e0: 6c69 6274 6f72 7265 6e74 2f61 6e6e 6f75  libtorrent/annou
    │ │ │ +000344f0: 6e63 655f 656e 7472 792e 6870 7022 0a23  nce_entry.hpp".#
    │ │ │ +00034500: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ +00034510: 656e 742f 746f 7272 656e 742e 6870 7022  ent/torrent.hpp"
    │ │ │ +00034520: 0a23 696e 636c 7564 6520 226c 6962 746f  .#include "libto
    │ │ │ +00034530: 7272 656e 742f 6175 785f 2f70 6174 682e  rrent/aux_/path.
    │ │ │ +00034540: 6870 7022 0a23 696e 636c 7564 6520 226c  hpp".#include "l
    │ │ │ +00034550: 6962 746f 7272 656e 742f 736f 636b 6574  ibtorrent/socket
    │ │ │ +00034560: 5f69 6f2e 6870 7022 0a0a 7573 696e 6720  _io.hpp"..using 
    │ │ │ +00034570: 6e61 6d65 7370 6163 6520 6c74 3b0a 0a3c  namespace lt;..<
    │ │ │ +00034580: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +00034590: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +000345a0: 7769 6474 683d 2231 3030 2522 3e0a 3c2f  width="100%">.TORRENT_TEST
    │ │ │ +000345c0: 2870 6172 7365 5f68 6f73 746e 616d 655f  (parse_hostname_
    │ │ │ +000345d0: 7065 6572 7329 0a7b 0a09 6368 6172 2063  peers).{..char c
    │ │ │ +000345e0: 6f6e 7374 2072 6573 706f 6e73 655b 5d20  onst response[] 
    │ │ │ +000345f0: 3d20 2264 353a 7065 6572 736c 6437 3a70  = "d5:peersld7:p
    │ │ │ +00034600: 6565 7220 6964 3230 3a61 6161 6161 6161  eer id20:aaaaaaa
    │ │ │ +00034610: 6161 6161 6161 6161 6161 6161 6122 0a09  aaaaaaaaaaaaa"..
    │ │ │ +00034620: 0922 323a 6970 3133 3a74 6573 745f 686f  ."2:ip13:test_ho
    │ │ │ +00034630: 7374 6e61 6d65 343a 706f 7274 6931 3030  stname4:porti100
    │ │ │ +00034640: 3065 6564 220a 0909 2237 3a70 6565 7220  0eed"..."7:peer 
    │ │ │ +00034650: 6964 3230 3a62 6262 6261 6261 6162 6162  id20:bbbbabaabab
    │ │ │ +00034660: 6162 6162 6162 6162 6132 3a69 7031 323a  ababababa2:ip12:
    │ │ │ +00034670: 616e 6f74 6865 725f 686f 7374 343a 706f  another_host4:po
    │ │ │ +00034680: 7274 6931 3030 3165 6565 6522 3b0a 0965  rti1001eeee";..e
    │ │ │ +00034690: 7272 6f72 5f63 6f64 6520 6563 3b0a 0974  rror_code ec;..t
    │ │ │ +000346a0: 7261 636b 6572 5f72 6573 706f 6e73 6520  racker_response 
    │ │ │ +000346b0: 7265 7370 203d 2070 6172 7365 5f74 7261  resp = parse_tra
    │ │ │ +000346c0: 636b 6572 5f72 6573 706f 6e73 6528 7265  cker_response(re
    │ │ │ +000346d0: 7370 6f6e 7365 0a09 092c 2065 632c 207b  sponse..., ec, {
    │ │ │ +000346e0: 7d2c 2073 6861 315f 6861 7368 2829 293b  }, sha1_hash());
    │ │ │ +000346f0: 0a0a 0954 4553 545f 4551 5541 4c28 6563  ...TEST_EQUAL(ec
    │ │ │ +00034700: 2c20 6572 726f 725f 636f 6465 2829 293b  , error_code());
    │ │ │ +00034710: 0a09 5445 5354 5f45 5155 414c 2872 6573  ..TEST_EQUAL(res
    │ │ │ +00034720: 702e 7065 6572 732e 7369 7a65 2829 2c20  p.peers.size(), 
    │ │ │ +00034730: 3229 3b0a 0969 6620 2872 6573 702e 7065  2);..if (resp.pe
    │ │ │ +00034740: 6572 732e 7369 7a65 2829 203d 3d20 3229  ers.size() == 2)
    │ │ │ +00034750: 0a09 7b0a 0909 7065 6572 5f65 6e74 7279  ..{...peer_entry
    │ │ │ +00034760: 2063 6f6e 7374 2661 6d70 3b20 6530 203d   const& e0 =
    │ │ │ +00034770: 2072 6573 702e 7065 6572 735b 305d 3b0a   resp.peers[0];.
    │ │ │ +00034780: 0909 7065 6572 5f65 6e74 7279 2063 6f6e  ..peer_entry con
    │ │ │ +00034790: 7374 2661 6d70 3b20 6531 203d 2072 6573  st& e1 = res
    │ │ │ +000347a0: 702e 7065 6572 735b 315d 3b0a 0909 5445  p.peers[1];...TE
    │ │ │ +000347b0: 5354 5f45 5155 414c 2865 302e 686f 7374  ST_EQUAL(e0.host
    │ │ │ +000347c0: 6e61 6d65 2c20 2274 6573 745f 686f 7374  name, "test_host
    │ │ │ +000347d0: 6e61 6d65 2229 3b0a 0909 5445 5354 5f45  name");...TEST_E
    │ │ │ +000347e0: 5155 414c 2865 302e 706f 7274 2c20 3130  QUAL(e0.port, 10
    │ │ │ +000347f0: 3030 293b 0a09 0954 4553 545f 4551 5541  00);...TEST_EQUA
    │ │ │ +00034800: 4c28 6530 2e70 6964 2c20 7065 6572 5f69  L(e0.pid, peer_i
    │ │ │ +00034810: 6428 2261 6161 6161 6161 6161 6161 6161  d("aaaaaaaaaaaaa
    │ │ │ +00034820: 6161 6161 6161 6122 2929 3b0a 0a09 0954  aaaaaaa"));....T
    │ │ │ +00034830: 4553 545f 4551 5541 4c28 6531 2e68 6f73  EST_EQUAL(e1.hos
    │ │ │ +00034840: 746e 616d 652c 2022 616e 6f74 6865 725f  tname, "another_
    │ │ │ +00034850: 686f 7374 2229 3b0a 0909 5445 5354 5f45  host");...TEST_E
    │ │ │ +00034860: 5155 414c 2865 312e 706f 7274 2c20 3130  QUAL(e1.port, 10
    │ │ │ +00034870: 3031 293b 0a09 0954 4553 545f 4551 5541  01);...TEST_EQUA
    │ │ │ +00034880: 4c28 6531 2e70 6964 2c20 7065 6572 5f69  L(e1.pid, peer_i
    │ │ │ +00034890: 6428 2262 6262 6261 6261 6162 6162 6162  d("bbbbabaababab
    │ │ │ +000348a0: 6162 6162 6162 6122 2929 3b0a 097d 0a7d  abababa"));..}.}
    │ │ │ +000348b0: 0a0a 544f 5252 454e 545f 5445 5354 2870  ..TORRENT_TEST(p
    │ │ │ +000348c0: 6172 7365 5f70 6565 7273 3429 0a7b 0a09  arse_peers4).{..
    │ │ │ +000348d0: 6368 6172 2063 6f6e 7374 2072 6573 706f  char const respo
    │ │ │ +000348e0: 6e73 655b 5d20 3d20 2264 353a 7065 6572  nse[] = "d5:peer
    │ │ │ +000348f0: 7331 323a 5c78 3031 5c78 3032 5c78 3033  s12:\x01\x02\x03
    │ │ │ +00034900: 5c78 3034 5c78 3330 5c78 3130 220a 0909  \x04\x30\x10"...
    │ │ │ +00034910: 225c 7830 395c 7830 385c 7830 375c 7830  "\x09\x08\x07\x0
    │ │ │ +00034920: 365c 7832 305c 7831 3022 2022 6522 3b0a  6\x20\x10" "e";.
    │ │ │ +00034930: 0965 7272 6f72 5f63 6f64 6520 6563 3b0a  .error_code ec;.
    │ │ │ +00034940: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e  
    │ │ │ +00034950: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00034980: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../te │ │ │ +000349b0: 7374 2f74 6573 745f 7472 616e 7366 6572 st/test_transfer │ │ │ +000349c0: 2e63 7070 3a31 3733 3c2f 613e 3c2f 7464 .cpp:173these setti │ │ │ +000349e0: 6e67 735f 7061 636b 2074 6573 7473 2062 ngs_pack tests b │ │ │ +000349f0: 656c 6f6e 6720 696e 2074 6865 6972 206f elong in their o │ │ │ +00034a00: 776e 2074 6573 743c 2f74 643e 3c2f 7472 wn test

    these setti │ │ │ +00034a60: 6e67 735f 7061 636b 2074 6573 7473 2062 ngs_pack tests b │ │ │ +00034a70: 656c 6f6e 6720 696e 2074 6865 6972 206f elong in their o │ │ │ +00034a80: 776e 2074 6573 743c 2f68 323e 3c68 343e wn test

    │ │ │ +00034a90: 2e2e 2f74 6573 742f 7465 7374 5f74 7261 ../test/test_tra │ │ │ +00034aa0: 6e73 6665 722e 6370 703a 3137 333c 2f68 nsfer.cpp:173
    .// 
    │ │ │ +00034af0: 746f 2074 6865 2074 696d 6520 6974 2077  to the time it w
    │ │ │ +00034b00: 696c 6c20 7461 6b65 2074 6f20 636f 6d70  ill take to comp
    │ │ │ +00034b10: 6c65 7465 2074 6865 2074 6573 740a 0970  lete the test..p
    │ │ │ +00034b20: 6163 6b2e 7365 745f 696e 7428 7365 7474  ack.set_int(sett
    │ │ │ +00034b30: 696e 6773 5f70 6163 6b3a 3a6d 696e 5f72  ings_pack::min_r
    │ │ │ +00034b40: 6563 6f6e 6e65 6374 5f74 696d 652c 2030  econnect_time, 0
    │ │ │ +00034b50: 293b 0a09 7061 636b 2e73 6574 5f69 6e74  );..pack.set_int
    │ │ │ +00034b60: 2873 6574 7469 6e67 735f 7061 636b 3a3a  (settings_pack::
    │ │ │ +00034b70: 7374 6f70 5f74 7261 636b 6572 5f74 696d  stop_tracker_tim
    │ │ │ +00034b80: 656f 7574 2c20 3129 3b0a 0970 6163 6b2e  eout, 1);..pack.
    │ │ │ +00034b90: 7365 745f 626f 6f6c 2873 6574 7469 6e67  set_bool(setting
    │ │ │ +00034ba0: 735f 7061 636b 3a3a 616e 6e6f 756e 6365  s_pack::announce
    │ │ │ +00034bb0: 5f74 6f5f 616c 6c5f 7472 6163 6b65 7273  _to_all_trackers
    │ │ │ +00034bc0: 2c20 7472 7565 293b 0a09 7061 636b 2e73  , true);..pack.s
    │ │ │ +00034bd0: 6574 5f62 6f6f 6c28 7365 7474 696e 6773  et_bool(settings
    │ │ │ +00034be0: 5f70 6163 6b3a 3a61 6e6e 6f75 6e63 655f  _pack::announce_
    │ │ │ +00034bf0: 746f 5f61 6c6c 5f74 6965 7273 2c20 7472  to_all_tiers, tr
    │ │ │ +00034c00: 7565 293b 0a0a 092f 2f20 6d61 6b65 2073  ue);...// make s
    │ │ │ +00034c10: 7572 6520 7765 2061 6e6e 6f75 6e63 6520  ure we announce 
    │ │ │ +00034c20: 746f 2062 6f74 6820 6874 7470 2061 6e64  to both http and
    │ │ │ +00034c30: 2075 6470 2074 7261 636b 6572 730a 0970   udp trackers..p
    │ │ │ +00034c40: 6163 6b2e 7365 745f 626f 6f6c 2873 6574  ack.set_bool(set
    │ │ │ +00034c50: 7469 6e67 735f 7061 636b 3a3a 7072 6566  tings_pack::pref
    │ │ │ +00034c60: 6572 5f75 6470 5f74 7261 636b 6572 732c  er_udp_trackers,
    │ │ │ +00034c70: 2066 616c 7365 293b 0a09 7061 636b 2e73   false);..pack.s
    │ │ │ +00034c80: 6574 5f62 6f6f 6c28 7365 7474 696e 6773  et_bool(settings
    │ │ │ +00034c90: 5f70 6163 6b3a 3a65 6e61 626c 655f 6f75  _pack::enable_ou
    │ │ │ +00034ca0: 7467 6f69 6e67 5f75 7470 2c20 6661 6c73  tgoing_utp, fals
    │ │ │ +00034cb0: 6529 3b0a 0970 6163 6b2e 7365 745f 626f  e);..pack.set_bo
    │ │ │ +00034cc0: 6f6c 2873 6574 7469 6e67 735f 7061 636b  ol(settings_pack
    │ │ │ +00034cd0: 3a3a 656e 6162 6c65 5f69 6e63 6f6d 696e  ::enable_incomin
    │ │ │ +00034ce0: 675f 7574 702c 2066 616c 7365 293b 0a09  g_utp, false);..
    │ │ │ +00034cf0: 7061 636b 2e73 6574 5f62 6f6f 6c28 7365  pack.set_bool(se
    │ │ │ +00034d00: 7474 696e 6773 5f70 6163 6b3a 3a65 6e61  ttings_pack::ena
    │ │ │ +00034d10: 626c 655f 6c73 642c 2066 616c 7365 293b  ble_lsd, false);
    │ │ │ +00034d20: 0a09 7061 636b 2e73 6574 5f62 6f6f 6c28  ..pack.set_bool(
    │ │ │ +00034d30: 7365 7474 696e 6773 5f70 6163 6b3a 3a65  settings_pack::e
    │ │ │ +00034d40: 6e61 626c 655f 6e61 7470 6d70 2c20 6661  nable_natpmp, fa
    │ │ │ +00034d50: 6c73 6529 3b0a 0970 6163 6b2e 7365 745f  lse);..pack.set_
    │ │ │ +00034d60: 626f 6f6c 2873 6574 7469 6e67 735f 7061  bool(settings_pa
    │ │ │ +00034d70: 636b 3a3a 656e 6162 6c65 5f75 706e 702c  ck::enable_upnp,
    │ │ │ +00034d80: 2066 616c 7365 293b 0a09 7061 636b 2e73   false);..pack.s
    │ │ │ +00034d90: 6574 5f62 6f6f 6c28 7365 7474 696e 6773  et_bool(settings
    │ │ │ +00034da0: 5f70 6163 6b3a 3a65 6e61 626c 655f 6468  _pack::enable_dh
    │ │ │ +00034db0: 742c 2066 616c 7365 293b 0a0a 0970 6163  t, false);...pac
    │ │ │ +00034dc0: 6b2e 7365 745f 696e 7428 7365 7474 696e  k.set_int(settin
    │ │ │ +00034dd0: 6773 5f70 6163 6b3a 3a6f 7574 5f65 6e63  gs_pack::out_enc
    │ │ │ +00034de0: 5f70 6f6c 6963 792c 2073 6574 7469 6e67  _policy, setting
    │ │ │ +00034df0: 735f 7061 636b 3a3a 7065 5f64 6973 6162  s_pack::pe_disab
    │ │ │ +00034e00: 6c65 6429 3b0a 0970 6163 6b2e 7365 745f  led);..pack.set_
    │ │ │ +00034e10: 696e 7428 7365 7474 696e 6773 5f70 6163  int(settings_pac
    │ │ │ +00034e20: 6b3a 3a69 6e5f 656e 635f 706f 6c69 6379  k::in_enc_policy
    │ │ │ +00034e30: 2c20 7365 7474 696e 6773 5f70 6163 6b3a  , settings_pack:
    │ │ │ +00034e40: 3a70 655f 6469 7361 626c 6564 293b 0a0a  :pe_disabled);..
    │ │ │ +00034e50: 0970 6163 6b2e 7365 745f 626f 6f6c 2873  .pack.set_bool(s
    │ │ │ +00034e60: 6574 7469 6e67 735f 7061 636b 3a3a 616c  ettings_pack::al
    │ │ │ +00034e70: 6c6f 775f 6d75 6c74 6970 6c65 5f63 6f6e  low_multiple_con
    │ │ │ +00034e80: 6e65 6374 696f 6e73 5f70 6572 5f69 702c  nections_per_ip,
    │ │ │ +00034e90: 2066 616c 7365 293b 0a0a 3c64 6976 2073   false);..
    .pack.se │ │ │ +00034ed0: 745f 696e 7428 7365 7474 696e 6773 5f70 t_int(settings_p │ │ │ +00034ee0: 6163 6b3a 3a75 6e63 686f 6b65 5f73 6c6f ack::unchoke_slo │ │ │ +00034ef0: 7473 5f6c 696d 6974 2c20 3029 3b0a 3c2f ts_limit, 0);..ses1.apply_ │ │ │ +00034f10: 7365 7474 696e 6773 2870 6163 6b29 3b0a settings(pack);. │ │ │ +00034f20: 0954 4553 545f 4348 4543 4b28 7365 7331 .TEST_CHECK(ses1 │ │ │ +00034f30: 2e67 6574 5f73 6574 7469 6e67 7328 292e .get_settings(). │ │ │ +00034f40: 6765 745f 696e 7428 7365 7474 696e 6773 get_int(settings │ │ │ +00034f50: 5f70 6163 6b3a 3a75 6e63 686f 6b65 5f73 _pack::unchoke_s │ │ │ +00034f60: 6c6f 7473 5f6c 696d 6974 2920 3d3d 2030 lots_limit) == 0 │ │ │ +00034f70: 293b 0a0a 0970 6163 6b2e 7365 745f 696e );...pack.set_in │ │ │ +00034f80: 7428 7365 7474 696e 6773 5f70 6163 6b3a t(settings_pack: │ │ │ +00034f90: 3a75 6e63 686f 6b65 5f73 6c6f 7473 5f6c :unchoke_slots_l │ │ │ +00034fa0: 696d 6974 2c20 2d31 293b 0a09 7365 7331 imit, -1);..ses1 │ │ │ +00034fb0: 2e61 7070 6c79 5f73 6574 7469 6e67 7328 .apply_settings( │ │ │ +00034fc0: 7061 636b 293b 0a09 5445 5354 5f43 4845 pack);..TEST_CHE │ │ │ +00034fd0: 434b 2873 6573 312e 6765 745f 7365 7474 CK(ses1.get_sett │ │ │ +00034fe0: 696e 6773 2829 2e67 6574 5f69 6e74 2873 ings().get_int(s │ │ │ +00034ff0: 6574 7469 6e67 735f 7061 636b 3a3a 756e ettings_pack::un │ │ │ +00035000: 6368 6f6b 655f 736c 6f74 735f 6c69 6d69 choke_slots_limi │ │ │ +00035010: 7429 203d 3d20 2d31 293b 0a0a 0970 6163 t) == -1);...pac │ │ │ +00035020: 6b2e 7365 745f 696e 7428 7365 7474 696e k.set_int(settin │ │ │ +00035030: 6773 5f70 6163 6b3a 3a75 6e63 686f 6b65 gs_pack::unchoke │ │ │ +00035040: 5f73 6c6f 7473 5f6c 696d 6974 2c20 3829 _slots_limit, 8) │ │ │ +00035050: 3b0a 0973 6573 312e 6170 706c 795f 7365 ;..ses1.apply_se │ │ │ +00035060: 7474 696e 6773 2870 6163 6b29 3b0a 0954 ttings(pack);..T │ │ │ +00035070: 4553 545f 4348 4543 4b28 7365 7331 2e67 EST_CHECK(ses1.g │ │ │ +00035080: 6574 5f73 6574 7469 6e67 7328 292e 6765 et_settings().ge │ │ │ +00035090: 745f 696e 7428 7365 7474 696e 6773 5f70 t_int(settings_p │ │ │ +000350a0: 6163 6b3a 3a75 6e63 686f 6b65 5f73 6c6f ack::unchoke_slo │ │ │ +000350b0: 7473 5f6c 696d 6974 2920 3d3d 2038 293b ts_limit) == 8); │ │ │ +000350c0: 0a0a 0973 6573 322e 6170 706c 795f 7365 ...ses2.apply_se │ │ │ +000350d0: 7474 696e 6773 2870 6163 6b29 3b0a 0a09 ttings(pack);... │ │ │ +000350e0: 746f 7272 656e 745f 6861 6e64 6c65 2074 torrent_handle t │ │ │ +000350f0: 6f72 313b 0a09 746f 7272 656e 745f 6861 or1;..torrent_ha │ │ │ +00035100: 6e64 6c65 2074 6f72 323b 0a0a 0963 7265 ndle tor2;...cre │ │ │ +00035110: 6174 655f 6469 7265 6374 6f72 7928 2274 ate_directory("t │ │ │ +00035120: 6d70 315f 7472 616e 7366 6572 222c 2065 mp1_transfer", e │ │ │ +00035130: 6329 3b0a 0973 7464 3a3a 6f66 7374 7265 c);..std::ofstre │ │ │ +00035140: 616d 2066 696c 6528 2274 6d70 315f 7472 am file("tmp1_tr │ │ │ +00035150: 616e 7366 6572 2f74 656d 706f 7261 7279 ansfer/temporary │ │ │ +00035160: 2229 3b0a 0973 7464 3a3a 7368 6172 6564 ");..std::shared │ │ │ +00035170: 5f70 7472 266c 743b 746f 7272 656e 745f _ptr<torrent_ │ │ │ +00035180: 696e 666f 2667 743b 2074 203d 203a 3a63 info> t = ::c │ │ │ +00035190: 7265 6174 655f 746f 7272 656e 7428 2661 reate_torrent(&a │ │ │ +000351a0: 6d70 3b66 696c 652c 2022 7465 6d70 6f72 mp;file, "tempor │ │ │ +000351b0: 6172 7922 2c20 3332 202a 2031 3032 342c ary", 32 * 1024, │ │ │ +000351c0: 2031 332c 2066 616c 7365 293b 0a09 6669 13, false);..fi │ │ │ +000351d0: 6c65 2e63 6c6f 7365 2829 3b0a 0a09 5445 le.close();...TE │ │ │ +000351e0: 5354 5f43 4845 434b 2865 7869 7374 7328 ST_CHECK(exists( │ │ │ +000351f0: 636f 6d62 696e 655f 7061 7468 2822 746d combine_path("tm │ │ │ +00035200: 7031 5f74 7261 6e73 6665 7222 2c20 2274 p1_transfer", "t │ │ │ +00035210: 656d 706f 7261 7279 2229 2929 3b0a 0a09 emporary")));... │ │ │ +00035220: 6164 645f 746f 7272 656e 745f 7061 7261 add_torrent_para │ │ │ +00035230: 6d73 2070 6172 616d 733b 0a09 7061 7261 ms params;..para │ │ │ +00035240: 6d73 2e73 746f 7261 6765 5f6d 6f64 6520 ms.storage_mode │ │ │ +00035250: 3d20 7374 6f72 6167 655f 6d6f 6465 3b0a = storage_mode;. │ │ │ +00035260: 0970 6172 616d 732e 666c 6167 7320 2661 .params.flags &a │ │ │ +00035270: 6d70 3b3d 207e 746f 7272 656e 745f 666c mp;= ~torrent_fl │ │ │ +00035280: 6167 733a 3a70 6175 7365 643b 0a09 7061 ags::paused;..pa │ │ │ +00035290: 7261 6d73 2e66 6c61 6773 2026 616d 703b rams.flags & │ │ │ +000352a0: 3d20 7e74 6f72 7265 6e74 5f66 6c61 6773 = ~torrent_flags │ │ │ +000352b0: 3a3a 6175 746f 5f6d 616e 6167 6564 3b0a ::auto_managed;. │ │ │ +000352c0: 0a09 7761 6974 5f66 6f72 5f6c 6973 7465 ..wait_for_liste │ │ │ +000352d0: 6e28 7365 7331 2c20 2273 6573 3122 293b n(ses1, "ses1"); │ │ │ +000352e0: 0a09 7761 6974 5f66 6f72 5f6c 6973 7465 ..wait_for_liste │ │ │ +000352f0: 6e28 7365 7332 2c20 2273 6573 3222 293b n(ses2, "ses2"); │ │ │ +00035300: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +00035340: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../t │ │ │ +00035370: 6573 742f 7465 7374 5f70 6565 725f 6c69 est/test_peer_li │ │ │ +00035380: 7374 2e63 7070 3a31 3239 313c 2f61 3e3c st.cpp:1291< │ │ │ +00035390: 2f74 643e 3c74 643e 7465 7374 2065 7261 /td>test era │ │ │ +000353a0: 7369 6e67 2070 6565 7273 3c2f 7464 3e3c sing peers< │ │ │ +000353b0: 2f74 723e 3c74 7220 6964 3d22 3131 3322 /tr>

    test era │ │ │ +00035400: 7369 6e67 2070 6565 7273 3c2f 6832 3e3c sing peers

    < │ │ │ +00035410: 6834 3e2e 2e2f 7465 7374 2f74 6573 745f h4>../test/test_ │ │ │ +00035420: 7065 6572 5f6c 6973 742e 6370 703a 3132 peer_list.cpp:12 │ │ │ +00035430: 3931 3c2f 6834 3e3c 7072 6520 7374 796c 91

    relevance 
    │ │ │ +000354b0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872  ;0../t
    │ │ │ +000354e0: 6573 742f 7465 7374 5f70 6565 725f 6c69  est/test_peer_li
    │ │ │ +000354f0: 7374 2e63 7070 3a31 3239 323c 2f61 3e3c  st.cpp:1292<
    │ │ │ +00035500: 2f74 643e 3c74 643e 7465 7374 2075 7064  /td>test upd
    │ │ │ +00035510: 6174 655f 7065 6572 5f70 6f72 7420 7769  ate_peer_port wi
    │ │ │ +00035520: 7468 2061 6c6c 6f77 5f6d 756c 7469 706c  th allow_multipl
    │ │ │ +00035530: 655f 636f 6e6e 6563 7469 6f6e 735f 7065  e_connections_pe
    │ │ │ +00035540: 725f 6970 2061 6e64 2077 6974 686f 7574  r_ip and without
    │ │ │ +00035550: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964  

    te │ │ │ +000355a0: 7374 2075 7064 6174 655f 7065 6572 5f70 st update_peer_p │ │ │ +000355b0: 6f72 7420 7769 7468 2061 6c6c 6f77 5f6d ort with allow_m │ │ │ +000355c0: 756c 7469 706c 655f 636f 6e6e 6563 7469 ultiple_connecti │ │ │ +000355d0: 6f6e 735f 7065 725f 6970 2061 6e64 2077 ons_per_ip and w │ │ │ +000355e0: 6974 686f 7574 3c2f 6832 3e3c 6834 3e2e ithout

    . │ │ │ +000355f0: 2e2f 7465 7374 2f74 6573 745f 7065 6572 ./test/test_peer │ │ │ +00035600: 5f6c 6973 742e 6370 703a 3132 3932 3c2f _list.cpp:1292

    re │ │ │ +00035680: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../test/ │ │ │ +000356c0: 7465 7374 5f70 6565 725f 6c69 7374 2e63 test_peer_list.c │ │ │ +000356d0: 7070 3a31 3239 333c 2f61 3e3c 2f74 643e pp:1293 │ │ │ +000356e0: 3c74 643e 7465 7374 2061 6464 2069 3270 test add i2p │ │ │ +000356f0: 2070 6565 7273 3c2f 7464 3e3c 2f74 723e peers │ │ │ +00035700: 3c74 7220 6964 3d22 3131 3522 2073 7479 │ │ │ +00035730: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00035740: 3c68 323e 7465 7374 2061 6464 2069 3270

    test add i2p │ │ │ +00035750: 2070 6565 7273 3c2f 6832 3e3c 6834 3e2e peers

    . │ │ │ +00035760: 2e2f 7465 7374 2f74 6573 745f 7065 6572 ./test/test_peer │ │ │ +00035770: 5f6c 6973 742e 6370 703a 3132 3933 3c2f _list.cpp:1293

    re │ │ │ +000357f0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../test/ │ │ │ +00035830: 7465 7374 5f70 6565 725f 6c69 7374 2e63 test_peer_list.c │ │ │ +00035840: 7070 3a31 3239 343c 2f61 3e3c 2f74 643e pp:1294 │ │ │ +00035850: 3c74 643e 7465 7374 2061 6c6c 6f77 5f69 test allow_i │ │ │ +00035860: 3270 5f6d 6978 6564 3c2f 7464 3e3c 2f74 2p_mixed

    test allow │ │ │ +000358c0: 5f69 3270 5f6d 6978 6564 3c2f 6832 3e3c _i2p_mixed

    < │ │ │ +000358d0: 6834 3e2e 2e2f 7465 7374 2f74 6573 745f h4>../test/test_ │ │ │ +000358e0: 7065 6572 5f6c 6973 742e 6370 703a 3132 peer_list.cpp:12 │ │ │ +000358f0: 3934 3c2f 6834 3e3c 7072 6520 7374 796c 94

    relevance 
    │ │ │ +00035970: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872  ;0../t
    │ │ │ +000359a0: 6573 742f 7465 7374 5f70 6565 725f 6c69  est/test_peer_li
    │ │ │ +000359b0: 7374 2e63 7070 3a31 3239 353c 2f61 3e3c  st.cpp:1295<
    │ │ │ +000359c0: 2f74 643e 3c74 643e 7465 7374 2069 6e73  /td>test ins
    │ │ │ +000359d0: 6572 745f 7065 6572 2066 6169 6c69 6e67  ert_peer failing
    │ │ │ +000359e0: 2077 6974 6820 616c 6c20 6572 726f 7220   with all error 
    │ │ │ +000359f0: 636f 6e64 6974 696f 6e73 3c2f 7464 3e3c  conditions<
    │ │ │ +00035a00: 2f74 723e 3c74 7220 6964 3d22 3131 3722  /tr>

    test ins │ │ │ +00035a50: 6572 745f 7065 6572 2066 6169 6c69 6e67 ert_peer failing │ │ │ +00035a60: 2077 6974 6820 616c 6c20 6572 726f 7220 with all error │ │ │ +00035a70: 636f 6e64 6974 696f 6e73 3c2f 6832 3e3c conditions

    < │ │ │ +00035a80: 6834 3e2e 2e2f 7465 7374 2f74 6573 745f h4>../test/test_ │ │ │ +00035a90: 7065 6572 5f6c 6973 742e 6370 703a 3132 peer_list.cpp:12 │ │ │ +00035aa0: 3935 3c2f 6834 3e3c 7072 6520 7374 796c 95

    relevance 
    │ │ │ +00035b20: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872  ;0../t
    │ │ │ +00035b50: 6573 742f 7465 7374 5f70 6565 725f 6c69  est/test_peer_li
    │ │ │ +00035b60: 7374 2e63 7070 3a31 3239 363c 2f61 3e3c  st.cpp:1296<
    │ │ │ +00035b70: 2f74 643e 3c74 643e 7465 7374 2049 5076  /td>test IPv
    │ │ │ +00035b80: 363c 2f74 643e 3c2f 7472 3e3c 7472 2069  6

    t │ │ │ +00035bd0: 6573 7420 4950 7636 3c2f 6832 3e3c 6834 est IPv6

    ../test/test_pe │ │ │ +00035bf0: 6572 5f6c 6973 742e 6370 703a 3132 3936 er_list.cpp:1296 │ │ │ +00035c00: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ +00035c40: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ +00035c50: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ +00035c60: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ +00035c70: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ +00035c80: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../tes
    │ │ │ +00035cb0: 742f 7465 7374 5f70 6565 725f 6c69 7374  t/test_peer_list
    │ │ │ +00035cc0: 2e63 7070 3a31 3239 373c 2f61 3e3c 2f74  .cpp:1297test conne
    │ │ │ +00035ce0: 6374 5f74 6f5f 7065 6572 2829 2066 6169  ct_to_peer() fai
    │ │ │ +00035cf0: 6c69 6e67 3c2f 7464 3e3c 2f74 723e 3c74  lingtest connect_t
    │ │ │ +00035d50: 6f5f 7065 6572 2829 2066 6169 6c69 6e67  o_peer() failing
    │ │ │ +00035d60: 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 7374  

    ../test │ │ │ +00035d70: 2f74 6573 745f 7065 6572 5f6c 6973 742e /test_peer_list. │ │ │ +00035d80: 6370 703a 3132 3937 3c2f 6834 3e3c 7072 cpp:1297

    relevanc │ │ │ +00035e00: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../test/test_p │ │ │ +00035e40: 6565 725f 6c69 7374 2e63 7070 3a31 3239 eer_list.cpp:129 │ │ │ +00035e50: 383c 2f61 3e3c 2f74 643e 3c74 643e 7465 8te │ │ │ +00035e60: 7374 2063 6f6e 6e65 6374 696f 6e5f 636c st connection_cl │ │ │ +00035e70: 6f73 6564 3c2f 7464 3e3c 2f74 723e 3c74 osedtest connectio │ │ │ +00035ed0: 6e5f 636c 6f73 6564 3c2f 6832 3e3c 6834 n_closed

    ../test/test_pe │ │ │ +00035ef0: 6572 5f6c 6973 742e 6370 703a 3132 3938 er_list.cpp:1298 │ │ │ +00035f00: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ +00035f40: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ +00035f50: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ +00035f60: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ +00035f70: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ +00035f80: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../tes
    │ │ │ +00035fb0: 742f 7465 7374 5f70 6565 725f 6c69 7374  t/test_peer_list
    │ │ │ +00035fc0: 2e63 7070 3a31 3239 393c 2f61 3e3c 2f74  .cpp:1299connect ca
    │ │ │ +00035fe0: 6e64 6964 6174 6573 2072 6563 616c 6375  ndidates recalcu
    │ │ │ +00035ff0: 6c61 7469 6f6e 2077 6865 6e20 696e 6372  lation when incr
    │ │ │ +00036000: 656d 656e 7469 6e67 2066 6169 6c63 6f75  ementing failcou
    │ │ │ +00036010: 6e74 3c2f 7464 3e3c 2f74 723e 3c74 7220  nt

    │ │ │ +00036060: 636f 6e6e 6563 7420 6361 6e64 6964 6174 connect candidat │ │ │ +00036070: 6573 2072 6563 616c 6375 6c61 7469 6f6e es recalculation │ │ │ +00036080: 2077 6865 6e20 696e 6372 656d 656e 7469 when incrementi │ │ │ +00036090: 6e67 2066 6169 6c63 6f75 6e74 3c2f 6832 ng failcount

    ../test/tes │ │ │ +000360b0: 745f 7065 6572 5f6c 6973 742e 6370 703a t_peer_list.cpp: │ │ │ +000360c0: 3132 3939 3c2f 6834 3e3c 7072 6520 7374 1299

    
    │ │ │ +00036130: 3c74 643e 7265 6c65 7661 6e63 6526 6e62  relevance&nb
    │ │ │ +00036140: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120  sp;0..
    │ │ │ +00036170: 2f74 6573 742f 7465 7374 5f66 6c61 6773  /test/test_flags
    │ │ │ +00036180: 2e63 7070 3a31 3633 3c2f 613e 3c2f 7464  .cpp:163change to a
    │ │ │ +000361a0: 2064 6966 6665 7265 6e74 2074 6573 7420   different test 
    │ │ │ +000361b0: 7365 7475 702e 2063 7572 7265 6e74 6c79  setup. currently
    │ │ │ +000361c0: 2061 6c77 6179 7320 7061 7573 6564 2e20   always paused. 
    │ │ │ +000361d0: 7465 7374 5f73 6574 5f61 6674 6572 5f61  test_set_after_a
    │ │ │ +000361e0: 6464 2874 6f72 7265 6e74 5f66 6c61 6773  dd(torrent_flags
    │ │ │ +000361f0: 3a3a 7061 7573 6564 293b 2074 6573 745f  ::paused); test_
    │ │ │ +00036200: 756e 7365 745f 6166 7465 725f 6164 6428  unset_after_add(
    │ │ │ +00036210: 746f 7272 656e 745f 666c 6167 733a 3a70  torrent_flags::p
    │ │ │ +00036220: 6175 7365 6429 3b3c 2f74 643e 3c2f 7472  aused);

    change to a │ │ │ +00036280: 2064 6966 6665 7265 6e74 2074 6573 7420 different test │ │ │ +00036290: 7365 7475 702e 2063 7572 7265 6e74 6c79 setup. currently │ │ │ +000362a0: 2061 6c77 6179 7320 7061 7573 6564 2e0a always paused.. │ │ │ +000362b0: 7465 7374 5f73 6574 5f61 6674 6572 5f61 test_set_after_a │ │ │ +000362c0: 6464 2874 6f72 7265 6e74 5f66 6c61 6773 dd(torrent_flags │ │ │ +000362d0: 3a3a 7061 7573 6564 293b 0a74 6573 745f ::paused);.test_ │ │ │ +000362e0: 756e 7365 745f 6166 7465 725f 6164 6428 unset_after_add( │ │ │ +000362f0: 746f 7272 656e 745f 666c 6167 733a 3a70 torrent_flags::p │ │ │ +00036300: 6175 7365 6429 3b3c 2f68 323e 3c68 343e aused);

    │ │ │ +00036310: 2e2e 2f74 6573 742f 7465 7374 5f66 6c61 ../test/test_fla │ │ │ +00036320: 6773 2e63 7070 3a31 3633 3c2f 6834 3e3c gs.cpp:163

    < │ │ │ +00036330: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00036340: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00036350: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00036360: 7820 2364 6464 3b22 3e7b 0a09 2f2f 2073 x #ddd;">{..// s │ │ │ +00036370: 6861 7265 2d6d 6f64 650a 0974 6573 745f hare-mode..test_ │ │ │ +00036380: 6164 645f 616e 645f 6765 745f 666c 6167 add_and_get_flag │ │ │ +00036390: 7328 746f 7272 656e 745f 666c 6167 733a s(torrent_flags: │ │ │ +000363a0: 3a73 6861 7265 5f6d 6f64 6529 3b0a 0974 :share_mode);..t │ │ │ +000363b0: 6573 745f 7365 745f 6166 7465 725f 6164 est_set_after_ad │ │ │ +000363c0: 6428 746f 7272 656e 745f 666c 6167 733a d(torrent_flags: │ │ │ +000363d0: 3a73 6861 7265 5f6d 6f64 6529 3b0a 0974 :share_mode);..t │ │ │ +000363e0: 6573 745f 756e 7365 745f 6166 7465 725f est_unset_after_ │ │ │ +000363f0: 6164 6428 746f 7272 656e 745f 666c 6167 add(torrent_flag │ │ │ +00036400: 733a 3a73 6861 7265 5f6d 6f64 6529 3b0a s::share_mode);. │ │ │ +00036410: 7d0a 2365 6e64 6966 0a0a 544f 5252 454e }.#endif..TORREN │ │ │ +00036420: 545f 5445 5354 2866 6c61 675f 6170 706c T_TEST(flag_appl │ │ │ +00036430: 795f 6970 5f66 696c 7465 7229 0a7b 0a09 y_ip_filter).{.. │ │ │ +00036440: 2f2f 2061 7070 6c79 2d69 702d 6669 6c74 // apply-ip-filt │ │ │ +00036450: 6572 0a09 7465 7374 5f61 6464 5f61 6e64 er..test_add_and │ │ │ +00036460: 5f67 6574 5f66 6c61 6773 2874 6f72 7265 _get_flags(torre │ │ │ +00036470: 6e74 5f66 6c61 6773 3a3a 6170 706c 795f nt_flags::apply_ │ │ │ +00036480: 6970 5f66 696c 7465 7229 3b0a 0974 6573 ip_filter);..tes │ │ │ +00036490: 745f 7365 745f 6166 7465 725f 6164 6428 t_set_after_add( │ │ │ +000364a0: 746f 7272 656e 745f 666c 6167 733a 3a61 torrent_flags::a │ │ │ +000364b0: 7070 6c79 5f69 705f 6669 6c74 6572 293b pply_ip_filter); │ │ │ +000364c0: 0a09 7465 7374 5f75 6e73 6574 5f61 6674 ..test_unset_aft │ │ │ +000364d0: 6572 5f61 6464 2874 6f72 7265 6e74 5f66 er_add(torrent_f │ │ │ +000364e0: 6c61 6773 3a3a 6170 706c 795f 6970 5f66 lags::apply_ip_f │ │ │ +000364f0: 696c 7465 7229 3b0a 7d0a 0a54 4f52 5245 ilter);.}..TORRE │ │ │ +00036500: 4e54 5f54 4553 5428 666c 6167 5f70 6175 NT_TEST(flag_pau │ │ │ +00036510: 7365 6429 0a7b 0a09 2f2f 2070 6175 7365 sed).{..// pause │ │ │ +00036520: 640a 0974 6573 745f 6164 645f 616e 645f d..test_add_and_ │ │ │ +00036530: 6765 745f 666c 6167 7328 746f 7272 656e get_flags(torren │ │ │ +00036540: 745f 666c 6167 733a 3a70 6175 7365 6429 t_flags::paused) │ │ │ +00036550: 3b0a 3c64 6976 2073 7479 6c65 3d22 6261 ;.
    │ │ │ +00036580: 7d0a 3c2f 6469 763e 0a54 4f52 5245 4e54 }.
    .TORRENT │ │ │ +00036590: 5f54 4553 5428 666c 6167 5f61 7574 6f5f _TEST(flag_auto_ │ │ │ +000365a0: 6d61 6e61 6765 6429 0a7b 0a09 2f2f 2061 managed).{..// a │ │ │ +000365b0: 7574 6f2d 6d61 6e61 6765 640a 0974 6573 uto-managed..tes │ │ │ +000365c0: 745f 6164 645f 616e 645f 6765 745f 666c t_add_and_get_fl │ │ │ +000365d0: 6167 7328 746f 7272 656e 745f 666c 6167 ags(torrent_flag │ │ │ +000365e0: 733a 3a61 7574 6f5f 6d61 6e61 6765 6429 s::auto_managed) │ │ │ +000365f0: 3b0a 0974 6573 745f 7365 745f 6166 7465 ;..test_set_afte │ │ │ +00036600: 725f 6164 6428 746f 7272 656e 745f 666c r_add(torrent_fl │ │ │ +00036610: 6167 733a 3a61 7574 6f5f 6d61 6e61 6765 ags::auto_manage │ │ │ +00036620: 6429 3b0a 0974 6573 745f 756e 7365 745f d);..test_unset_ │ │ │ +00036630: 6166 7465 725f 6164 6428 746f 7272 656e after_add(torren │ │ │ +00036640: 745f 666c 6167 733a 3a61 7574 6f5f 6d61 t_flags::auto_ma │ │ │ +00036650: 6e61 6765 6429 3b0a 7d0a 0a2f 2f20 7375 naged);.}..// su │ │ │ +00036660: 7065 7220 7365 6564 696e 6720 6d6f 6465 per seeding mode │ │ │ +00036670: 2069 7320 6175 746f 6d61 7469 6361 6c6c is automaticall │ │ │ +00036680: 7920 7475 726e 6564 206f 6666 2069 6620 y turned off if │ │ │ +00036690: 7765 2772 6520 6e6f 7420 6120 7365 6564 we're not a seed │ │ │ +000366a0: 0a2f 2f20 7369 6e63 6520 7468 6520 706f .// since the po │ │ │ +000366b0: 7369 785f 6469 736b 5f69 6f20 6973 206e six_disk_io is n │ │ │ +000366c0: 6f74 2074 6872 6561 6465 642c 2074 6869 ot threaded, thi │ │ │ +000366d0: 7320 7769 6c6c 2068 6170 7065 6e20 696d s will happen im │ │ │ +000366e0: 6d65 6469 6174 656c 790a 2369 6620 544f mediately.#if TO │ │ │ +000366f0: 5252 454e 545f 4841 5645 5f4d 4d41 500a RRENT_HAVE_MMAP. │ │ │ +00036700: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ +00036710: 4449 5341 424c 455f 5355 5045 5253 4545 DISABLE_SUPERSEE │ │ │ +00036720: 4449 4e47 0a54 4f52 5245 4e54 5f54 4553 DING.TORRENT_TES │ │ │ +00036730: 5428 666c 6167 5f73 7570 6572 5f73 6565 T(flag_super_see │ │ │ +00036740: 6469 6e67 290a 7b0a 092f 2f20 7375 7065 ding).{..// supe │ │ │ +00036750: 722d 7365 6564 696e 670a 0974 6573 745f r-seeding..test_ │ │ │ +00036760: 6164 645f 616e 645f 6765 745f 666c 6167 add_and_get_flag │ │ │ +00036770: 7328 746f 7272 656e 745f 666c 6167 733a s(torrent_flags: │ │ │ +00036780: 3a73 7570 6572 5f73 6565 6469 6e67 293b :super_seeding); │ │ │ +00036790: 0a09 7465 7374 5f75 6e73 6574 5f61 6674 ..test_unset_aft │ │ │ +000367a0: 6572 5f61 6464 2874 6f72 7265 6e74 5f66 er_add(torrent_f │ │ │ +000367b0: 6c61 6773 3a3a 7375 7065 725f 7365 6564 lags::super_seed │ │ │ +000367c0: 696e 6729 3b0a 0974 6573 745f 7365 745f ing);..test_set_ │ │ │ +000367d0: 6166 7465 725f 6164 6428 746f 7272 656e after_add(torren │ │ │ +000367e0: 745f 666c 6167 733a 3a73 7570 6572 5f73 t_flags::super_s │ │ │ +000367f0: 6565 6469 6e67 293b 0a7d 0a23 656e 6469 eeding);.}.#endi │ │ │ +00036800: 660a 2365 6e64 6966 0a0a 544f 5252 454e f.#endif..TORREN │ │ │ +00036810: 545f 5445 5354 2866 6c61 675f 7365 7175 T_TEST(flag_sequ │ │ │ +00036820: 656e 7469 616c 5f64 6f77 6e6c 6f61 6429 ential_download) │ │ │ +00036830: 0a7b 0a09 2f2f 2073 6571 7565 6e74 6961 .{..// sequentia │ │ │ +00036840: 6c2d 646f 776e 6c6f 6164 0a09 7465 7374 l-download..test │ │ │ +00036850: 5f61 6464 5f61 6e64 5f67 6574 5f66 6c61 _add_and_get_fla │ │ │ +00036860: 6773 2874 6f72 7265 6e74 5f66 6c61 6773 gs(torrent_flags │ │ │ +00036870: 3a3a 7365 7175 656e 7469 616c 5f64 6f77 ::sequential_dow │ │ │ +00036880: 6e6c 6f61 6429 3b0a 0974 6573 745f 7365 nload);..test_se │ │ │ +00036890: 745f 6166 7465 725f 6164 6428 746f 7272 t_after_add(torr │ │ │ +000368a0: 656e 745f 666c 6167 733a 3a73 6571 7565 ent_flags::seque │ │ │ +000368b0: 6e74 6961 6c5f 646f 776e 6c6f 6164 293b ntial_download); │ │ │ +000368c0: 0a09 7465 7374 5f75 6e73 6574 5f61 6674 ..test_unset_aft │ │ │ +000368d0: 6572 5f61 6464 2874 6f72 7265 6e74 5f66 er_add(torrent_f │ │ │ +000368e0: 6c61 6773 3a3a 7365 7175 656e 7469 616c lags::sequential │ │ │ +000368f0: 5f64 6f77 6e6c 6f61 6429 3b0a 7d0a 3c2f _download);.}.r │ │ │ +00036930: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +00036940: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../test │ │ │ +00036970: 2f74 6573 745f 666c 6167 732e 6370 703a /test_flags.cpp: │ │ │ +00036980: 3230 353c 2f61 3e3c 2f74 643e 3c74 643e 205 │ │ │ +00036990: 7468 6973 2074 6573 7420 6973 2066 6c61 this test is fla │ │ │ +000369a0: 6b79 2c20 7369 6e63 6520 7468 6520 746f ky, since the to │ │ │ +000369b0: 7272 656e 7420 7769 6c6c 2062 6563 6f6d rrent will becom │ │ │ +000369c0: 6520 7265 6164 7920 6265 666f 7265 2061 e ready before a │ │ │ +000369d0: 736b 696e 6720 666f 7220 7468 6520 666c sking for the fl │ │ │ +000369e0: 6167 732c 2061 6e64 2062 7920 7468 656e ags, and by then │ │ │ +000369f0: 2073 746f 705f 7768 656e 5f72 6561 6479 stop_when_ready │ │ │ +00036a00: 2077 696c 6c20 6861 7665 2062 6565 6e20 will have been │ │ │ +00036a10: 636c 6561 7265 6420 7465 7374 5f61 6464 cleared test_add │ │ │ +00036a20: 5f61 6e64 5f67 6574 5f66 6c61 6773 2874 _and_get_flags(t │ │ │ +00036a30: 6f72 7265 6e74 5f66 6c61 6773 3a3a 7374 orrent_flags::st │ │ │ +00036a40: 6f70 5f77 6865 6e5f 7265 6164 7929 3b20 op_when_ready); │ │ │ +00036a50: 7365 7474 696e 6720 7374 6f70 2d77 6865 setting stop-whe │ │ │ +00036a60: 6e2d 7265 6164 7920 7768 656e 2061 6c72 n-ready when alr │ │ │ +00036a70: 6561 6479 2073 746f 7070 6564 2068 6173 eady stopped has │ │ │ +00036a80: 206e 6f20 6566 6665 6374 2e3c 2f74 643e no effect. │ │ │ +00036a90: 3c2f 7472 3e3c 7472 2069 643d 2231 3233

    this te │ │ │ +00036ae0: 7374 2069 7320 666c 616b 792c 2073 696e st is flaky, sin │ │ │ +00036af0: 6365 2074 6865 2074 6f72 7265 6e74 2077 ce the torrent w │ │ │ +00036b00: 696c 6c20 6265 636f 6d65 2072 6561 6479 ill become ready │ │ │ +00036b10: 2062 6566 6f72 650a 6173 6b69 6e67 2066 before.asking f │ │ │ +00036b20: 6f72 2074 6865 2066 6c61 6773 2c20 616e or the flags, an │ │ │ +00036b30: 6420 6279 2074 6865 6e20 7374 6f70 5f77 d by then stop_w │ │ │ +00036b40: 6865 6e5f 7265 6164 7920 7769 6c6c 2068 hen_ready will h │ │ │ +00036b50: 6176 6520 6265 656e 2063 6c65 6172 6564 ave been cleared │ │ │ +00036b60: 0a74 6573 745f 6164 645f 616e 645f 6765 .test_add_and_ge │ │ │ +00036b70: 745f 666c 6167 7328 746f 7272 656e 745f t_flags(torrent_ │ │ │ +00036b80: 666c 6167 733a 3a73 746f 705f 7768 656e flags::stop_when │ │ │ +00036b90: 5f72 6561 6479 293b 0a73 6574 7469 6e67 _ready);.setting │ │ │ +00036ba0: 2073 746f 702d 7768 656e 2d72 6561 6479 stop-when-ready │ │ │ +00036bb0: 2077 6865 6e20 616c 7265 6164 7920 7374 when already st │ │ │ +00036bc0: 6f70 7065 6420 6861 7320 6e6f 2065 6666 opped has no eff │ │ │ +00036bd0: 6563 742e 3c2f 6832 3e3c 6834 3e2e 2e2f ect.

    ../ │ │ │ +00036be0: 7465 7374 2f74 6573 745f 666c 6167 732e test/test_flags. │ │ │ +00036bf0: 6370 703a 3230 353c 2f68 343e 3c70 7265 cpp:205

    relevance
    │ │ │ +00036c70: 266e 6273 703b 303c 2f74 643e 3c74 643e   0
    │ │ │ +00036c80: 3c61 2068 7265 663d 226a 6176 6173 6372  ../test/test_fl
    │ │ │ +00036cb0: 6167 732e 6370 703a 3230 393c 2f61 3e3c  ags.cpp:209<
    │ │ │ +00036cc0: 2f74 643e 3c74 643e 6368 616e 6765 2074  /td>change t
    │ │ │ +00036cd0: 6f20 6120 6469 6666 6572 656e 7420 7465  o a different te
    │ │ │ +00036ce0: 7374 2073 6574 7570 2e20 6375 7272 656e  st setup. curren
    │ │ │ +00036cf0: 746c 7920 616c 7761 7973 2070 6175 7365  tly always pause
    │ │ │ +00036d00: 642e 2074 6573 745f 7365 745f 6166 7465  d. test_set_afte
    │ │ │ +00036d10: 725f 6164 6428 746f 7272 656e 745f 666c  r_add(torrent_fl
    │ │ │ +00036d20: 6167 733a 3a73 746f 705f 7768 656e 5f72  ags::stop_when_r
    │ │ │ +00036d30: 6561 6479 293b 3c2f 7464 3e3c 2f74 723e  eady);
    │ │ │ +00036d40: 3c74 7220 6964 3d22 3132 3422 2073 7479  
    │ │ │ +00036d70: 3c74 6420 636f 6c73 7061 6e3d 2233 223e  
    │ │ │ +00036d80: 3c68 323e 6368 616e 6765 2074 6f20 6120  

    change to a │ │ │ +00036d90: 6469 6666 6572 656e 7420 7465 7374 2073 different test s │ │ │ +00036da0: 6574 7570 2e20 6375 7272 656e 746c 7920 etup. currently │ │ │ +00036db0: 616c 7761 7973 2070 6175 7365 642e 0a74 always paused..t │ │ │ +00036dc0: 6573 745f 7365 745f 6166 7465 725f 6164 est_set_after_ad │ │ │ +00036dd0: 6428 746f 7272 656e 745f 666c 6167 733a d(torrent_flags: │ │ │ +00036de0: 3a73 746f 705f 7768 656e 5f72 6561 6479 :stop_when_ready │ │ │ +00036df0: 293b 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 );

    ../te │ │ │ +00036e00: 7374 2f74 6573 745f 666c 6167 732e 6370 st/test_flags.cp │ │ │ +00036e10: 703a 3230 393c 2f68 343e 3c70 7265 2073 p:209

    .test_set_af
    │ │ │ +00036e60: 7465 725f 6164 6428 746f 7272 656e 745f  ter_add(torrent_
    │ │ │ +00036e70: 666c 6167 733a 3a73 7570 6572 5f73 6565  flags::super_see
    │ │ │ +00036e80: 6469 6e67 293b 0a7d 0a23 656e 6469 660a  ding);.}.#endif.
    │ │ │ +00036e90: 2365 6e64 6966 0a0a 544f 5252 454e 545f  #endif..TORRENT_
    │ │ │ +00036ea0: 5445 5354 2866 6c61 675f 7365 7175 656e  TEST(flag_sequen
    │ │ │ +00036eb0: 7469 616c 5f64 6f77 6e6c 6f61 6429 0a7b  tial_download).{
    │ │ │ +00036ec0: 0a09 2f2f 2073 6571 7565 6e74 6961 6c2d  ..// sequential-
    │ │ │ +00036ed0: 646f 776e 6c6f 6164 0a09 7465 7374 5f61  download..test_a
    │ │ │ +00036ee0: 6464 5f61 6e64 5f67 6574 5f66 6c61 6773  dd_and_get_flags
    │ │ │ +00036ef0: 2874 6f72 7265 6e74 5f66 6c61 6773 3a3a  (torrent_flags::
    │ │ │ +00036f00: 7365 7175 656e 7469 616c 5f64 6f77 6e6c  sequential_downl
    │ │ │ +00036f10: 6f61 6429 3b0a 0974 6573 745f 7365 745f  oad);..test_set_
    │ │ │ +00036f20: 6166 7465 725f 6164 6428 746f 7272 656e  after_add(torren
    │ │ │ +00036f30: 745f 666c 6167 733a 3a73 6571 7565 6e74  t_flags::sequent
    │ │ │ +00036f40: 6961 6c5f 646f 776e 6c6f 6164 293b 0a09  ial_download);..
    │ │ │ +00036f50: 7465 7374 5f75 6e73 6574 5f61 6674 6572  test_unset_after
    │ │ │ +00036f60: 5f61 6464 2874 6f72 7265 6e74 5f66 6c61  _add(torrent_fla
    │ │ │ +00036f70: 6773 3a3a 7365 7175 656e 7469 616c 5f64  gs::sequential_d
    │ │ │ +00036f80: 6f77 6e6c 6f61 6429 3b0a 7d0a 0a2f 2f20  ownload);.}..// 
    │ │ │ +00036f90: 7468 6520 7374 6f70 2077 6865 6e20 7265  the stop when re
    │ │ │ +00036fa0: 6164 7920 666c 6167 2077 696c 6c20 6265  ady flag will be
    │ │ │ +00036fb0: 2063 6c65 6172 6564 2077 6865 6e20 7468   cleared when th
    │ │ │ +00036fc0: 6520 746f 7272 656e 7420 6973 2072 6561  e torrent is rea
    │ │ │ +00036fd0: 6479 2074 6f20 7374 6172 740a 2f2f 2064  dy to start.// d
    │ │ │ +00036fe0: 6f77 6e6c 6f61 6469 6e67 2e0a 2f2f 2073  ownloading..// s
    │ │ │ +00036ff0: 696e 6365 2074 6865 2070 6f73 6978 5f64  ince the posix_d
    │ │ │ +00037000: 6973 6b5f 696f 2069 7320 6e6f 7420 7468  isk_io is not th
    │ │ │ +00037010: 7265 6164 6564 2c20 7468 6973 2077 696c  readed, this wil
    │ │ │ +00037020: 6c20 6861 7070 656e 2069 6d6d 6564 6961  l happen immedia
    │ │ │ +00037030: 7465 6c79 0a23 6966 2054 4f52 5245 4e54  tely.#if TORRENT
    │ │ │ +00037040: 5f48 4156 455f 4d4d 4150 0a54 4f52 5245  _HAVE_MMAP.TORRE
    │ │ │ +00037050: 4e54 5f54 4553 5428 666c 6167 5f73 746f  NT_TEST(flag_sto
    │ │ │ +00037060: 705f 7768 656e 5f72 6561 6479 290a 7b0a  p_when_ready).{.
    │ │ │ +00037070: 092f 2f20 7374 6f70 2d77 6865 6e2d 7265  .// stop-when-re
    │ │ │ +00037080: 6164 790a 3c64 6976 2073 7479 6c65 3d22  ady.
    .test_unset_af │ │ │ +000370c0: 7465 725f 6164 6428 746f 7272 656e 745f ter_add(torrent_ │ │ │ +000370d0: 666c 6167 733a 3a73 746f 705f 7768 656e flags::stop_when │ │ │ +000370e0: 5f72 6561 6479 293b 0a3c 2f64 6976 3e7d _ready);.
    } │ │ │ +000370f0: 0a23 656e 6469 660a 0a54 4f52 5245 4e54 .#endif..TORRENT │ │ │ +00037100: 5f54 4553 5428 666c 6167 5f64 6973 6162 _TEST(flag_disab │ │ │ +00037110: 6c65 5f64 6874 290a 7b0a 0974 6573 745f le_dht).{..test_ │ │ │ +00037120: 6164 645f 616e 645f 6765 745f 666c 6167 add_and_get_flag │ │ │ +00037130: 7328 746f 7272 656e 745f 666c 6167 733a s(torrent_flags: │ │ │ +00037140: 3a64 6973 6162 6c65 5f64 6874 293b 0a09 :disable_dht);.. │ │ │ +00037150: 7465 7374 5f73 6574 5f61 6674 6572 5f61 test_set_after_a │ │ │ +00037160: 6464 2874 6f72 7265 6e74 5f66 6c61 6773 dd(torrent_flags │ │ │ +00037170: 3a3a 6469 7361 626c 655f 6468 7429 3b0a ::disable_dht);. │ │ │ +00037180: 0974 6573 745f 756e 7365 745f 6166 7465 .test_unset_afte │ │ │ +00037190: 725f 6164 6428 746f 7272 656e 745f 666c r_add(torrent_fl │ │ │ +000371a0: 6167 733a 3a64 6973 6162 6c65 5f64 6874 ags::disable_dht │ │ │ +000371b0: 293b 0a7d 0a0a 0a54 4f52 5245 4e54 5f54 );.}...TORRENT_T │ │ │ +000371c0: 4553 5428 666c 6167 5f64 6973 6162 6c65 EST(flag_disable │ │ │ +000371d0: 5f6c 7364 290a 7b0a 0974 6573 745f 6164 _lsd).{..test_ad │ │ │ +000371e0: 645f 616e 645f 6765 745f 666c 6167 7328 d_and_get_flags( │ │ │ +000371f0: 746f 7272 656e 745f 666c 6167 733a 3a64 torrent_flags::d │ │ │ +00037200: 6973 6162 6c65 5f6c 7364 293b 0a09 7465 isable_lsd);..te │ │ │ +00037210: 7374 5f73 6574 5f61 6674 6572 5f61 6464 st_set_after_add │ │ │ +00037220: 2874 6f72 7265 6e74 5f66 6c61 6773 3a3a (torrent_flags:: │ │ │ +00037230: 6469 7361 626c 655f 6c73 6429 3b0a 0974 disable_lsd);..t │ │ │ +00037240: 6573 745f 756e 7365 745f 6166 7465 725f est_unset_after_ │ │ │ +00037250: 6164 6428 746f 7272 656e 745f 666c 6167 add(torrent_flag │ │ │ +00037260: 733a 3a64 6973 6162 6c65 5f6c 7364 293b s::disable_lsd); │ │ │ +00037270: 0a7d 0a0a 544f 5252 454e 545f 5445 5354 .}..TORRENT_TEST │ │ │ +00037280: 2866 6c61 675f 6469 7361 626c 655f 7065 (flag_disable_pe │ │ │ +00037290: 7829 0a7b 0a09 7465 7374 5f61 6464 5f61 x).{..test_add_a │ │ │ +000372a0: 6e64 5f67 6574 5f66 6c61 6773 2874 6f72 nd_get_flags(tor │ │ │ +000372b0: 7265 6e74 5f66 6c61 6773 3a3a 6469 7361 rent_flags::disa │ │ │ +000372c0: 626c 655f 7065 7829 3b0a 0974 6573 745f ble_pex);..test_ │ │ │ +000372d0: 7365 745f 6166 7465 725f 6164 6428 746f set_after_add(to │ │ │ +000372e0: 7272 656e 745f 666c 6167 733a 3a64 6973 rrent_flags::dis │ │ │ +000372f0: 6162 6c65 5f70 6578 293b 0a09 7465 7374 able_pex);..test │ │ │ +00037300: 5f75 6e73 6574 5f61 6674 6572 5f61 6464 _unset_after_add │ │ │ +00037310: 2874 6f72 7265 6e74 5f66 6c61 6773 3a3a (torrent_flags:: │ │ │ +00037320: 6469 7361 626c 655f 7065 7829 3b0a 7d0a disable_pex);.}. │ │ │ +00037330: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +00037340: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00037370: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../te │ │ │ +000373a0: 7374 2f74 6573 745f 7265 7375 6d65 2e63 st/test_resume.c │ │ │ +000373b0: 7070 3a36 3134 3c2f 613e 3c2f 7464 3e3c pp:614< │ │ │ +000373c0: 7464 3e74 6573 7420 7768 6174 2068 6170 td>test what hap │ │ │ +000373d0: 7065 6e73 2077 6865 6e20 6c6f 6164 696e pens when loadin │ │ │ +000373e0: 6720 6120 7265 7375 6d65 2066 696c 6520 g a resume file │ │ │ +000373f0: 7769 7468 2062 6f74 6820 7069 6563 6520 with both piece │ │ │ +00037400: 7072 696f 7269 7469 6573 2061 6e64 2066 priorities and f │ │ │ +00037410: 696c 6520 7072 696f 7269 7469 6573 2028 ile priorities ( │ │ │ +00037420: 6669 6c65 2070 7269 6f20 7368 6f75 6c64 file prio should │ │ │ +00037430: 2074 616b 6520 7072 6563 6564 656e 6365 take precedence │ │ │ +00037440: 293c 2f74 643e 3c2f 7472 3e3c 7472 2069 )

    t │ │ │ +00037490: 6573 7420 7768 6174 2068 6170 7065 6e73 est what happens │ │ │ +000374a0: 2077 6865 6e20 6c6f 6164 696e 6720 6120 when loading a │ │ │ +000374b0: 7265 7375 6d65 2066 696c 6520 7769 7468 resume file with │ │ │ +000374c0: 2062 6f74 6820 7069 6563 6520 7072 696f both piece prio │ │ │ +000374d0: 7269 7469 6573 0a61 6e64 2066 696c 6520 rities.and file │ │ │ +000374e0: 7072 696f 7269 7469 6573 2028 6669 6c65 priorities (file │ │ │ +000374f0: 2070 7269 6f20 7368 6f75 6c64 2074 616b prio should tak │ │ │ +00037500: 6520 7072 6563 6564 656e 6365 293c 2f68 e precedence)

    ../test/te │ │ │ +00037520: 7374 5f72 6573 756d 652e 6370 703a 3631 st_resume.cpp:61 │ │ │ +00037530: 343c 2f68 343e 3c70 7265 2073 7479 6c65 4

    │ │ │ +00037570: 0909 7b0a 0909 0954 4553 545f 4551 5541  ..{....TEST_EQUA
    │ │ │ +00037580: 4c28 7069 6563 6573 5b69 5d2c 2074 7275  L(pieces[i], tru
    │ │ │ +00037590: 6529 3b0a 0909 7d0a 097d 0a7d 0a0a 7d20  e);...}..}.}..} 
    │ │ │ +000375a0: 2f2f 2061 6e6f 6e79 6d6f 7573 206e 616d  // anonymous nam
    │ │ │ +000375b0: 6573 7061 6365 0a0a 544f 5252 454e 545f  espace..TORRENT_
    │ │ │ +000375c0: 5445 5354 2870 6965 6365 5f73 6c6f 7473  TEST(piece_slots
    │ │ │ +000375d0: 5f73 6565 6429 0a7b 0a09 7465 7374 5f70  _seed).{..test_p
    │ │ │ +000375e0: 6965 6365 5f73 6c6f 7473 5f73 6565 6428  iece_slots_seed(
    │ │ │ +000375f0: 7365 7474 696e 6773 2829 293b 0a7d 0a0a  settings());.}..
    │ │ │ +00037600: 544f 5252 454e 545f 5445 5354 2870 6965  TORRENT_TEST(pie
    │ │ │ +00037610: 6365 5f73 6c6f 7473 5f73 6565 645f 7375  ce_slots_seed_su
    │ │ │ +00037620: 6767 6573 745f 6361 6368 6529 0a7b 0a09  ggest_cache).{..
    │ │ │ +00037630: 7365 7474 696e 6773 5f70 6163 6b20 7365  settings_pack se
    │ │ │ +00037640: 7474 203d 2073 6574 7469 6e67 7328 293b  tt = settings();
    │ │ │ +00037650: 0a09 7365 7474 2e73 6574 5f69 6e74 2873  ..sett.set_int(s
    │ │ │ +00037660: 6574 7469 6e67 735f 7061 636b 3a3a 7375  ettings_pack::su
    │ │ │ +00037670: 6767 6573 745f 6d6f 6465 2c20 7365 7474  ggest_mode, sett
    │ │ │ +00037680: 696e 6773 5f70 6163 6b3a 3a73 7567 6765  ings_pack::sugge
    │ │ │ +00037690: 7374 5f72 6561 645f 6361 6368 6529 3b0a  st_read_cache);.
    │ │ │ +000376a0: 0974 6573 745f 7069 6563 655f 736c 6f74  .test_piece_slot
    │ │ │ +000376b0: 735f 7365 6564 2873 6574 7429 3b0a 7d0a  s_seed(sett);.}.
    │ │ │ +000376c0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +000376f0: 3c2f 6469 763e 3c2f 7072 653e 3c2f 7464
    relevance │ │ │ +00037730: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +00037740: 3c61 2068 7265 663d 226a 6176 6173 6372 ../test/test_re │ │ │ +00037770: 7375 6d65 2e63 7070 3a36 3137 3c2f 613e sume.cpp:617 │ │ │ +00037780: 3c2f 7464 3e3c 7464 3e6d 616b 6520 7375 make su │ │ │ +00037790: 7265 2061 2072 6573 756d 6520 6669 6c65 re a resume file │ │ │ +000377a0: 206f 6e6c 7920 6576 6572 2063 6f6e 7461 only ever conta │ │ │ +000377b0: 696e 2066 696c 6520 7072 696f 7269 7469 in file prioriti │ │ │ +000377c0: 6573 204f 5220 7069 6563 6520 7072 696f es OR piece prio │ │ │ +000377d0: 7269 7469 6573 2e20 4e65 7665 7220 626f rities. Never bo │ │ │ +000377e0: 7468 2e3c 2f74 643e 3c2f 7472 3e3c 7472 th.

    make sure a res │ │ │ +00037840: 756d 6520 6669 6c65 206f 6e6c 7920 6576 ume file only ev │ │ │ +00037850: 6572 2063 6f6e 7461 696e 2066 696c 6520 er contain file │ │ │ +00037860: 7072 696f 7269 7469 6573 204f 5220 7069 priorities OR pi │ │ │ +00037870: 6563 650a 7072 696f 7269 7469 6573 2e20 ece.priorities. │ │ │ +00037880: 4e65 7665 7220 626f 7468 2e3c 2f68 323e Never both.

    │ │ │ +00037890: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ +000378a0: 5f72 6573 756d 652e 6370 703a 3631 373c _resume.cpp:617< │ │ │ +000378b0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +000378f0: 0954 4553 545f 4551 5541 4c28 7069 6563  .TEST_EQUAL(piec
    │ │ │ +00037900: 6573 5b69 5d2c 2074 7275 6529 3b0a 0909  es[i], true);...
    │ │ │ +00037910: 7d0a 097d 0a7d 0a0a 7d20 2f2f 2061 6e6f  }..}.}..} // ano
    │ │ │ +00037920: 6e79 6d6f 7573 206e 616d 6573 7061 6365  nymous namespace
    │ │ │ +00037930: 0a0a 544f 5252 454e 545f 5445 5354 2870  ..TORRENT_TEST(p
    │ │ │ +00037940: 6965 6365 5f73 6c6f 7473 5f73 6565 6429  iece_slots_seed)
    │ │ │ +00037950: 0a7b 0a09 7465 7374 5f70 6965 6365 5f73  .{..test_piece_s
    │ │ │ +00037960: 6c6f 7473 5f73 6565 6428 7365 7474 696e  lots_seed(settin
    │ │ │ +00037970: 6773 2829 293b 0a7d 0a0a 544f 5252 454e  gs());.}..TORREN
    │ │ │ +00037980: 545f 5445 5354 2870 6965 6365 5f73 6c6f  T_TEST(piece_slo
    │ │ │ +00037990: 7473 5f73 6565 645f 7375 6767 6573 745f  ts_seed_suggest_
    │ │ │ +000379a0: 6361 6368 6529 0a7b 0a09 7365 7474 696e  cache).{..settin
    │ │ │ +000379b0: 6773 5f70 6163 6b20 7365 7474 203d 2073  gs_pack sett = s
    │ │ │ +000379c0: 6574 7469 6e67 7328 293b 0a09 7365 7474  ettings();..sett
    │ │ │ +000379d0: 2e73 6574 5f69 6e74 2873 6574 7469 6e67  .set_int(setting
    │ │ │ +000379e0: 735f 7061 636b 3a3a 7375 6767 6573 745f  s_pack::suggest_
    │ │ │ +000379f0: 6d6f 6465 2c20 7365 7474 696e 6773 5f70  mode, settings_p
    │ │ │ +00037a00: 6163 6b3a 3a73 7567 6765 7374 5f72 6561  ack::suggest_rea
    │ │ │ +00037a10: 645f 6361 6368 6529 3b0a 0974 6573 745f  d_cache);..test_
    │ │ │ +00037a20: 7069 6563 655f 736c 6f74 735f 7365 6564  piece_slots_seed
    │ │ │ +00037a30: 2873 6574 7429 3b0a 7d0a 0a0a 3c64 6976  (sett);.}...
    .
    relevance  │ │ │ +00037ab0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../t │ │ │ +00037ae0: 6573 742f 7465 7374 5f72 6573 756d 652e est/test_resume. │ │ │ +00037af0: 6370 703a 3632 303c 2f61 3e3c 2f74 643e cpp:620 │ │ │ +00037b00: 3c74 643e 6765 6e65 7261 6c6c 7920 7361 generally sa │ │ │ +00037b10: 7665 3c2f 7464 3e3c 2f74 723e 3c74 7220 ve

    │ │ │ +00037b60: 6765 6e65 7261 6c6c 7920 7361 7665 3c2f generally save

    ../test/t │ │ │ +00037b80: 6573 745f 7265 7375 6d65 2e63 7070 3a36 est_resume.cpp:6 │ │ │ +00037b90: 3230 3c2f 6834 3e3c 7072 6520 7374 796c 20

    ..}..}.}..} // 
    │ │ │ +00037be0: 616e 6f6e 796d 6f75 7320 6e61 6d65 7370  anonymous namesp
    │ │ │ +00037bf0: 6163 650a 0a54 4f52 5245 4e54 5f54 4553  ace..TORRENT_TES
    │ │ │ +00037c00: 5428 7069 6563 655f 736c 6f74 735f 7365  T(piece_slots_se
    │ │ │ +00037c10: 6564 290a 7b0a 0974 6573 745f 7069 6563  ed).{..test_piec
    │ │ │ +00037c20: 655f 736c 6f74 735f 7365 6564 2873 6574  e_slots_seed(set
    │ │ │ +00037c30: 7469 6e67 7328 2929 3b0a 7d0a 0a54 4f52  tings());.}..TOR
    │ │ │ +00037c40: 5245 4e54 5f54 4553 5428 7069 6563 655f  RENT_TEST(piece_
    │ │ │ +00037c50: 736c 6f74 735f 7365 6564 5f73 7567 6765  slots_seed_sugge
    │ │ │ +00037c60: 7374 5f63 6163 6865 290a 7b0a 0973 6574  st_cache).{..set
    │ │ │ +00037c70: 7469 6e67 735f 7061 636b 2073 6574 7420  tings_pack sett 
    │ │ │ +00037c80: 3d20 7365 7474 696e 6773 2829 3b0a 0973  = settings();..s
    │ │ │ +00037c90: 6574 742e 7365 745f 696e 7428 7365 7474  ett.set_int(sett
    │ │ │ +00037ca0: 696e 6773 5f70 6163 6b3a 3a73 7567 6765  ings_pack::sugge
    │ │ │ +00037cb0: 7374 5f6d 6f64 652c 2073 6574 7469 6e67  st_mode, setting
    │ │ │ +00037cc0: 735f 7061 636b 3a3a 7375 6767 6573 745f  s_pack::suggest_
    │ │ │ +00037cd0: 7265 6164 5f63 6163 6865 293b 0a09 7465  read_cache);..te
    │ │ │ +00037ce0: 7374 5f70 6965 6365 5f73 6c6f 7473 5f73  st_piece_slots_s
    │ │ │ +00037cf0: 6565 6428 7365 7474 293b 0a7d 0a0a 0a0a  eed(sett);.}....
    │ │ │ +00037d00: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .< │ │ │ +00037d30: 2f64 6976 3e23 6966 2054 4f52 5245 4e54 /div>#if TORRENT │ │ │ +00037d40: 5f41 4249 5f56 4552 5349 4f4e 203d 3d20 _ABI_VERSION == │ │ │ +00037d50: 310a 544f 5252 454e 545f 5445 5354 2866 1.TORRENT_TEST(f │ │ │ +00037d60: 696c 655f 7072 696f 7269 7469 6573 5f64 ile_priorities_d │ │ │ +00037d70: 6566 6175 6c74 5f64 6570 7265 6361 7465 efault_deprecate │ │ │ +00037d80: 6429 0a7b 0a09 6c74 3a3a 7365 7373 696f d).{..lt::sessio │ │ │ +00037d90: 6e20 7365 7328 7365 7474 696e 6773 2829 n ses(settings() │ │ │ +00037da0: 293b 0a09 7374 643a 3a76 6563 746f 7226 );..std::vector& │ │ │ +00037db0: 6c74 3b64 6f77 6e6c 6f61 645f 7072 696f lt;download_prio │ │ │ +00037dc0: 7269 7479 5f74 2667 743b 2066 696c 655f rity_t> file_ │ │ │ +00037dd0: 7072 696f 7269 7469 6573 203d 2074 6573 priorities = tes │ │ │ +00037de0: 745f 7265 7375 6d65 5f66 6c61 6773 2873 t_resume_flags(s │ │ │ +00037df0: 6573 0a09 092c 207b 7d2c 2022 222c 2022 es..., {}, "", " │ │ │ +00037e00: 222c 2074 7275 6529 2e67 6574 5f66 696c ", true).get_fil │ │ │ +00037e10: 655f 7072 696f 7269 7469 6573 2829 3b0a e_priorities();. │ │ │ +00037e20: 0a09 5445 5354 5f45 5155 414c 2866 696c ..TEST_EQUAL(fil │ │ │ +00037e30: 655f 7072 696f 7269 7469 6573 2e73 697a e_priorities.siz │ │ │ +00037e40: 6528 292c 2033 293b 0a09 5445 5354 5f45 e(), 3);..TEST_E │ │ │ +00037e50: 5155 414c 2866 696c 655f 7072 696f 7269 QUAL(file_priori │ │ │ +00037e60: 7469 6573 5b30 5d2c 2034 293b 0a09 5445 ties[0], 4);..TE │ │ │ +00037e70: 5354 5f45 5155 414c 2866 696c 655f 7072 ST_EQUAL(file_pr │ │ │ +00037e80: 696f 7269 7469 6573 5b31 5d2c 2034 293b iorities[1], 4); │ │ │ +00037e90: 0a09 5445 5354 5f45 5155 414c 2866 696c ..TEST_EQUAL(fil │ │ │ +00037ea0: 655f 7072 696f 7269 7469 6573 5b32 5d2c e_priorities[2], │ │ │ +00037eb0: 2034 293b 0a7d 0a0a 2f2f 2041 7320 6c6f 4);.}..// As lo │ │ │ +00037ec0: 6e67 2061 7320 7468 6520 6164 645f 746f ng as the add_to │ │ │ +00037ed0: 7272 656e 745f 7061 7261 6d73 2070 7269 rrent_params pri │ │ │ +00037ee0: 6f72 6974 6965 7320 6172 6520 656d 7074 orities are empt │ │ │ +00037ef0: 792c 2074 6865 2066 696c 655f 7072 696f y, the file_prio │ │ │ +00037f00: 7269 7469 6573 0a2f 2f20 6672 6f6d 2074 rities.// from t │ │ │ +00037f10: 6865 2072 6573 756d 6520 6461 7461 2073 he resume data s │ │ │ +00037f20: 686f 756c 6420 7461 6b65 2065 6666 6563 hould take effec │ │ │ +00037f30: 740a 544f 5252 454e 545f 5445 5354 2866 t.TORRENT_TEST(f │ │ │ +00037f40: 696c 655f 7072 696f 7269 7469 6573 5f69 ile_priorities_i │ │ │ +00037f50: 6e5f 7265 7375 6d65 5f64 6570 7265 6361 n_resume_depreca │ │ │ +00037f60: 7465 6429 0a7b 0a09 6c74 3a3a 7365 7373 ted).{..lt::sess │ │ │ +00037f70: 696f 6e20 7365 7328 7365 7474 696e 6773 ion ses(settings │ │ │ +00037f80: 2829 293b 0a09 7374 643a 3a76 6563 746f ());..std::vecto │ │ │ +00037f90: 7226 6c74 3b64 6f77 6e6c 6f61 645f 7072 r<download_pr │ │ │ +00037fa0: 696f 7269 7479 5f74 2667 743b 2066 696c iority_t> fil │ │ │ +00037fb0: 655f 7072 696f 7269 7469 6573 203d 2074 e_priorities = t │ │ │ +00037fc0: 6573 745f 7265 7375 6d65 5f66 6c61 6773 est_resume_flags │ │ │ +00037fd0: 2873 6573 2c20 7b7d 2c20 2222 2c20 2231 (ses, {}, "", "1 │ │ │ +00037fe0: 3233 2229 2e67 6574 5f66 696c 655f 7072 23").get_file_pr │ │ │ +00037ff0: 696f 7269 7469 6573 2829 3b0a 0a09 5445 iorities();...TE │ │ │ +00038000: 5354 5f45 5155 414c 2866 696c 655f 7072 ST_EQUAL(file_pr │ │ │ +00038010: 696f 7269 7469 6573 2e73 697a 6528 292c iorities.size(), │ │ │ +00038020: 2033 293b 0a09 5445 5354 5f45 5155 414c 3);..TEST_EQUAL │ │ │ +00038030: 2866 696c 655f 7072 696f 7269 7469 6573 (file_priorities │ │ │ +00038040: 5b30 5d2c 2031 293b 0a09 5445 5354 5f45 [0], 1);..TEST_E │ │ │ +00038050: 5155 414c 2866 696c 655f 7072 696f 7269 QUAL(file_priori │ │ │ +00038060: 7469 6573 5b31 5d2c 2032 293b 0a09 5445 ties[1], 2);..TE │ │ │ +00038070: 5354 5f45 5155 414c 2866 696c 655f 7072 ST_EQUAL(file_pr │ │ │ +00038080: 696f 7269 7469 6573 5b32 5d2c 2033 293b iorities[2], 3); │ │ │ +00038090: 0a7d 0a0a 2f2f 2069 6620 626f 7468 2072 .}..// if both r │ │ │ +000380a0: 6573 756d 6520 6461 7461 2061 6e64 2061 esume data and a │ │ │ +000380b0: 6464 5f74 6f72 7265 6e74 5f70 6172 616d dd_torrent_param │ │ │ +000380c0: 7320 6861 7320 6669 6c65 5f70 7269 6f72 s has file_prior │ │ │ +000380d0: 6974 6965 732c 2074 6865 0a2f 2f20 6164 ities, the.// ad │ │ │ +000380e0: 645f 746f 7272 656e 745f 7061 7261 6d73 d_torrent_params │ │ │ +000380f0: 206f 6e65 2074 616b 6520 7072 6563 6564 one take preced │ │ │ +00038100: 656e 6365 0a54 4f52 5245 4e54 5f54 4553 ence.TORRENT_TES │ │ │ +00038110: 5428 6669 6c65 5f70 7269 6f72 6974 6965 T(file_prioritie │ │ │ +00038120: 735f 696e 5f72 6573 756d 655f 616e 645f s_in_resume_and_ │ │ │ +00038130: 7061 7261 6d73 5f64 6570 7265 6361 7465 params_deprecate │ │ │ +00038140: 6429 0a7b 0a3c 2f70 7265 3e3c 2f74 643e d).{.
    │ │ │ +00038150: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +00038180: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +00038190: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +000381a0: 7074 3a65 7870 616e 6428 3132 3829 223e pt:expand(128)"> │ │ │ +000381b0: 2e2e 2f74 6573 742f 7465 7374 5f72 6573 ../test/test_res │ │ │ +000381c0: 756d 652e 6370 703a 3934 333c 2f61 3e3c ume.cpp:943< │ │ │ +000381d0: 2f74 643e 3c74 643e 7465 7374 2061 6c6c /td>test all │ │ │ +000381e0: 206f 7468 6572 2072 6573 756d 6520 666c other resume fl │ │ │ +000381f0: 6167 7320 6865 7265 2074 6f6f 2e20 5468 ags here too. Th │ │ │ +00038200: 6973 2077 6f75 6c64 2072 6571 7569 7265 is would require │ │ │ +00038210: 2072 6574 7572 6e69 6e67 206d 6f72 6520 returning more │ │ │ +00038220: 7468 616e 206a 7573 7420 7468 6520 746f than just the to │ │ │ +00038230: 7272 656e 745f 7374 6174 7573 2066 726f rrent_status fro │ │ │ +00038240: 6d20 7465 7374 5f72 6573 756d 655f 666c m test_resume_fl │ │ │ +00038250: 6167 732e 2041 6c73 6f20 6874 7470 2073 ags. Also http s │ │ │ +00038260: 6565 6473 2061 6e64 2074 7261 636b 6572 eeds and tracker │ │ │ +00038270: 7320 666f 7220 696e 7374 616e 6365 3c2f s for instance

    test │ │ │ +000382d0: 2061 6c6c 206f 7468 6572 2072 6573 756d all other resum │ │ │ +000382e0: 6520 666c 6167 7320 6865 7265 2074 6f6f e flags here too │ │ │ +000382f0: 2e20 5468 6973 2077 6f75 6c64 2072 6571 . This would req │ │ │ +00038300: 7569 7265 2072 6574 7572 6e69 6e67 0a6d uire returning.m │ │ │ +00038310: 6f72 6520 7468 616e 206a 7573 7420 7468 ore than just th │ │ │ +00038320: 6520 746f 7272 656e 745f 7374 6174 7573 e torrent_status │ │ │ +00038330: 2066 726f 6d20 7465 7374 5f72 6573 756d from test_resum │ │ │ +00038340: 655f 666c 6167 732e 2041 6c73 6f20 6874 e_flags. Also ht │ │ │ +00038350: 7470 2073 6565 6473 0a61 6e64 2074 7261 tp seeds.and tra │ │ │ +00038360: 636b 6572 7320 666f 7220 696e 7374 616e ckers for instan │ │ │ +00038370: 6365 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 ce

    ../te │ │ │ +00038380: 7374 2f74 6573 745f 7265 7375 6d65 2e63 st/test_resume.c │ │ │ +00038390: 7070 3a39 3433 3c2f 6834 3e3c 7072 6520 pp:943

    .TEST_EQUAL
    │ │ │ +000383e0: 2873 2e63 6f6e 6e65 6374 696f 6e73 5f6c  (s.connections_l
    │ │ │ +000383f0: 696d 6974 2c20 3133 3435 293b 0a09 5445  imit, 1345);..TE
    │ │ │ +00038400: 5354 5f45 5155 414c 2873 2e75 706c 6f61  ST_EQUAL(s.uploa
    │ │ │ +00038410: 6473 5f6c 696d 6974 2c20 3133 3436 293b  ds_limit, 1346);
    │ │ │ +00038420: 0a7d 0a0a 544f 5252 454e 545f 5445 5354  .}..TORRENT_TEST
    │ │ │ +00038430: 2870 6175 7365 645f 6465 7072 6563 6174  (paused_deprecat
    │ │ │ +00038440: 6564 290a 7b0a 096c 743a 3a73 6573 7369  ed).{..lt::sessi
    │ │ │ +00038450: 6f6e 2073 6573 2873 6574 7469 6e67 7328  on ses(settings(
    │ │ │ +00038460: 2929 3b0a 092f 2f20 7265 7375 6d65 2064  ));..// resume d
    │ │ │ +00038470: 6174 6120 6f76 6572 7269 6465 7320 7468  ata overrides th
    │ │ │ +00038480: 6520 7061 7573 6564 2066 6c61 670a 0961  e paused flag..a
    │ │ │ +00038490: 7574 6f20 636f 6e73 7420 6e6f 7720 3d20  uto const now = 
    │ │ │ +000384a0: 6c74 3a3a 636c 6f63 6b5f 7479 7065 3a3a  lt::clock_type::
    │ │ │ +000384b0: 6e6f 7728 293b 0a09 746f 7272 656e 745f  now();..torrent_
    │ │ │ +000384c0: 7374 6174 7573 2073 203d 2074 6573 745f  status s = test_
    │ │ │ +000384d0: 7265 7375 6d65 5f66 6c61 6773 2873 6573  resume_flags(ses
    │ │ │ +000384e0: 2c20 746f 7272 656e 745f 666c 6167 733a  , torrent_flags:
    │ │ │ +000384f0: 3a70 6175 7365 642c 2022 222c 2022 222c  :paused, "", "",
    │ │ │ +00038500: 2074 7275 6529 2e73 7461 7475 7328 293b   true).status();
    │ │ │ +00038510: 0a09 6465 6661 756c 745f 7465 7374 7328  ..default_tests(
    │ │ │ +00038520: 732c 206e 6f77 293b 0a23 6966 6465 6620  s, now);.#ifdef 
    │ │ │ +00038530: 544f 5252 454e 545f 5749 4e44 4f57 530a  TORRENT_WINDOWS.
    │ │ │ +00038540: 0954 4553 545f 4551 5541 4c28 732e 7361  .TEST_EQUAL(s.sa
    │ │ │ +00038550: 7665 5f70 6174 682c 2022 633a 5c5c 6164  ve_path, "c:\\ad
    │ │ │ +00038560: 645f 746f 7272 656e 745f 7061 7261 6d73  d_torrent_params
    │ │ │ +00038570: 2073 6176 655f 7061 7468 2229 3b0a 2365   save_path");.#e
    │ │ │ +00038580: 6c73 650a 0954 4553 545f 4551 5541 4c28  lse..TEST_EQUAL(
    │ │ │ +00038590: 732e 7361 7665 5f70 6174 682c 2022 2f61  s.save_path, "/a
    │ │ │ +000385a0: 6464 5f74 6f72 7265 6e74 5f70 6172 616d  dd_torrent_param
    │ │ │ +000385b0: 7320 7361 7665 5f70 6174 6822 293b 0a23  s save_path");.#
    │ │ │ +000385c0: 656e 6469 660a 0954 4553 545f 4551 5541  endif..TEST_EQUA
    │ │ │ +000385d0: 4c28 732e 666c 6167 7320 2661 6d70 3b20  L(s.flags & 
    │ │ │ +000385e0: 666c 6167 735f 6d61 736b 2c20 746f 7272  flags_mask, torr
    │ │ │ +000385f0: 656e 745f 666c 6167 735f 747b 7d29 3b0a  ent_flags_t{});.
    │ │ │ +00038600: 0954 4553 545f 4551 5541 4c28 732e 636f  .TEST_EQUAL(s.co
    │ │ │ +00038610: 6e6e 6563 7469 6f6e 735f 6c69 6d69 742c  nnections_limit,
    │ │ │ +00038620: 2031 3334 3529 3b0a 0954 4553 545f 4551   1345);..TEST_EQ
    │ │ │ +00038630: 5541 4c28 732e 7570 6c6f 6164 735f 6c69  UAL(s.uploads_li
    │ │ │ +00038640: 6d69 742c 2031 3334 3629 3b0a 0a3c 6469  mit, 1346);..}..TORRENT_TEST
    │ │ │ +00038690: 2875 726c 5f73 6565 645f 7265 7375 6d65  (url_seed_resume
    │ │ │ +000386a0: 5f64 6174 615f 6465 7072 6563 6174 6564  _data_deprecated
    │ │ │ +000386b0: 290a 7b0a 092f 2f20 6d65 7267 6520 7572  ).{..// merge ur
    │ │ │ +000386c0: 6c20 7365 6564 7320 7769 7468 2072 6573  l seeds with res
    │ │ │ +000386d0: 756d 6520 6461 7461 0a09 7374 643a 3a70  ume data..std::p
    │ │ │ +000386e0: 7269 6e74 6628 2266 6c61 6773 3a20 6d65  rintf("flags: me
    │ │ │ +000386f0: 7267 655f 7265 7375 6d65 5f68 7474 705f  rge_resume_http_
    │ │ │ +00038700: 7365 6564 735c 6e22 293b 0a09 6c74 3a3a  seeds\n");..lt::
    │ │ │ +00038710: 7365 7373 696f 6e20 7365 7328 7365 7474  session ses(sett
    │ │ │ +00038720: 696e 6773 2829 293b 0a09 746f 7272 656e  ings());..torren
    │ │ │ +00038730: 745f 6861 6e64 6c65 2068 203d 2074 6573  t_handle h = tes
    │ │ │ +00038740: 745f 7265 7375 6d65 5f66 6c61 6773 2873  t_resume_flags(s
    │ │ │ +00038750: 6573 2c0a 0909 746f 7272 656e 745f 666c  es,...torrent_fl
    │ │ │ +00038760: 6167 733a 3a6d 6572 6765 5f72 6573 756d  ags::merge_resum
    │ │ │ +00038770: 655f 6874 7470 5f73 6565 6473 2c20 2222  e_http_seeds, ""
    │ │ │ +00038780: 2c20 2222 2c20 7472 7565 293b 0a09 7374  , "", true);..st
    │ │ │ +00038790: 643a 3a73 6574 266c 743b 7374 643a 3a73  d::set<std::s
    │ │ │ +000387a0: 7472 696e 6726 6774 3b20 7573 203d 2068  tring> us = h
    │ │ │ +000387b0: 2e75 726c 5f73 6565 6473 2829 3b0a 0973  .url_seeds();..s
    │ │ │ +000387c0: 7464 3a3a 7365 7426 6c74 3b73 7464 3a3a  td::set<std::
    │ │ │ +000387d0: 7374 7269 6e67 2667 743b 2077 7320 3d20  string> ws = 
    │ │ │ +000387e0: 682e 6874 7470 5f73 6565 6473 2829 3b0a  h.http_seeds();.
    │ │ │ +000387f0: 0a09 5445 5354 5f45 5155 414c 2875 732e  ..TEST_EQUAL(us.
    │ │ │ +00038800: 7369 7a65 2829 2c20 3329 3b0a 0954 4553  size(), 3);..TES
    │ │ │ +00038810: 545f 4551 5541 4c28 7374 643a 3a63 6f75  T_EQUAL(std::cou
    │ │ │ +00038820: 6e74 2875 732e 6265 6769 6e28 292c 2075  nt(us.begin(), u
    │ │ │ +00038830: 732e 656e 6428 290a 0909 2c20 2268 7474  s.end()..., "htt
    │ │ │ +00038840: 703a 2f2f 6164 642d 746f 7272 656e 742d  p://add-torrent-
    │ │ │ +00038850: 7061 7261 6d73 2d75 726c 2d73 6565 642e  params-url-seed.
    │ │ │ +00038860: 636f 6d2f 2229 2c20 3129 3b0a 0954 4553  com/"), 1);..TES
    │ │ │ +00038870: 545f 4551 5541 4c28 7374 643a 3a63 6f75  T_EQUAL(std::cou
    │ │ │ +00038880: 6e74 2875 732e 6265 6769 6e28 292c 2075  nt(us.begin(), u
    │ │ │ +00038890: 732e 656e 6428 290a 0909 2c20 2268 7474  s.end()..., "htt
    │ │ │ +000388a0: 703a 2f2f 746f 7272 656e 742d 6669 6c65  p://torrent-file
    │ │ │ +000388b0: 2d75 726c 2d73 6565 642e 636f 6d2f 2229  -url-seed.com/")
    │ │ │ +000388c0: 2c20 3129 3b0a 0954 4553 545f 4551 5541  , 1);..TEST_EQUA
    │ │ │ +000388d0: 4c28 7374 643a 3a63 6f75 6e74 2875 732e  L(std::count(us.
    │ │ │ +000388e0: 6265 6769 6e28 292c 2075 732e 656e 6428  begin(), us.end(
    │ │ │ +000388f0: 290a 0909 2c20 2268 7474 703a 2f2f 7265  )..., "http://re
    │ │ │ +00038900: 7375 6d65 2d64 6174 612d 7572 6c2d 7365  sume-data-url-se
    │ │ │ +00038910: 6564 2e63 6f6d 2f22 292c 2031 293b 0a0a  ed.com/"), 1);..
    │ │ │ +00038920: 0954 4553 545f 4551 5541 4c28 7773 2e73  .TEST_EQUAL(ws.s
    │ │ │ +00038930: 697a 6528 292c 2031 293b 0a09 5445 5354  ize(), 1);..TEST
    │ │ │ +00038940: 5f45 5155 414c 2873 7464 3a3a 636f 756e  _EQUAL(std::coun
    │ │ │ +00038950: 7428 7773 2e62 6567 696e 2829 2c20 7773  t(ws.begin(), ws
    │ │ │ +00038960: 2e65 6e64 2829 0a09 092c 2022 6874 7470  .end()..., "http
    │ │ │ +00038970: 3a2f 2f72 6573 756d 652d 6461 7461 2d68  ://resume-data-h
    │ │ │ +00038980: 7474 702d 7365 6564 2e63 6f6d 2229 2c20  ttp-seed.com"), 
    │ │ │ +00038990: 3129 3b0a 7d0a 0a54 4f52 5245 4e54 5f54  1);.}..TORRENT_T
    │ │ │ +000389a0: 4553 5428 7265 7375 6d65 5f6f 7665 7272  EST(resume_overr
    │ │ │ +000389b0: 6964 655f 746f 7272 656e 745f 6465 7072  ide_torrent_depr
    │ │ │ +000389c0: 6563 6174 6564 290a 7b0a 092f 2f20 7265  ecated).{..// re
    │ │ │ +000389d0: 7375 6d65 2064 6174 6120 6f76 6572 7269  sume data overri
    │ │ │ +000389e0: 6465 7320 7468 6520 2e74 6f72 7265 6e74  des the .torrent
    │ │ │ +000389f0: 5f66 696c 650a 0973 7464 3a3a 7072 696e  _file..std::prin
    │ │ │ +00038a00: 7466 2822 666c 6167 733a 206e 6f20 6d65  tf("flags: no me
    │ │ │ +00038a10: 7267 655f 7265 7375 6d65 5f68 7474 705f  rge_resume_http_
    │ │ │ +00038a20: 7365 6564 5c6e 2229 3b0a 096c 743a 3a73  seed\n");..lt::s
    │ │ │ +00038a30: 6573 7369 6f6e 2073 6573 2873 6574 7469  ession ses(setti
    │ │ │ +00038a40: 6e67 7328 2929 3b0a 0974 6f72 7265 6e74  ngs());..torrent
    │ │ │ +00038a50: 5f68 616e 646c 6520 6820 3d20 7465 7374  _handle h = test
    │ │ │ +00038a60: 5f72 6573 756d 655f 666c 6167 7328 7365  _resume_flags(se
    │ │ │ +00038a70: 732c 0a3c 2f70 7265 3e3c 2f74 643e 3c2f  s,.
    │ │ │ +00038aa0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00038ab0: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +00038ae0: 2f74 6573 742f 7465 7374 5f72 6573 756d /test/test_resum │ │ │ +00038af0: 652e 6370 703a 3137 3135 3c2f 613e 3c2f e.cpp:1715test all │ │ │ +00038b10: 6f74 6865 7220 7265 7375 6d65 2066 6c61 other resume fla │ │ │ +00038b20: 6773 2068 6572 6520 746f 6f2e 2054 6869 gs here too. Thi │ │ │ +00038b30: 7320 776f 756c 6420 7265 7175 6972 6520 s would require │ │ │ +00038b40: 7265 7475 726e 696e 6720 6d6f 7265 2074 returning more t │ │ │ +00038b50: 6861 6e20 6a75 7374 2074 6865 2074 6f72 han just the tor │ │ │ +00038b60: 7265 6e74 5f73 7461 7475 7320 6672 6f6d rent_status from │ │ │ +00038b70: 2074 6573 745f 7265 7375 6d65 5f66 6c61 test_resume_fla │ │ │ +00038b80: 6773 2e20 416c 736f 2068 7474 7020 7365 gs. Also http se │ │ │ +00038b90: 6564 7320 616e 6420 7472 6163 6b65 7273 eds and trackers │ │ │ +00038ba0: 2066 6f72 2069 6e73 7461 6e63 653c 2f74 for instance

    test │ │ │ +00038c00: 616c 6c20 6f74 6865 7220 7265 7375 6d65 all other resume │ │ │ +00038c10: 2066 6c61 6773 2068 6572 6520 746f 6f2e flags here too. │ │ │ +00038c20: 2054 6869 7320 776f 756c 6420 7265 7175 This would requ │ │ │ +00038c30: 6972 6520 7265 7475 726e 696e 670a 6d6f ire returning.mo │ │ │ +00038c40: 7265 2074 6861 6e20 6a75 7374 2074 6865 re than just the │ │ │ +00038c50: 2074 6f72 7265 6e74 5f73 7461 7475 7320 torrent_status │ │ │ +00038c60: 6672 6f6d 2074 6573 745f 7265 7375 6d65 from test_resume │ │ │ +00038c70: 5f66 6c61 6773 2e20 416c 736f 2068 7474 _flags. Also htt │ │ │ +00038c80: 7020 7365 6564 730a 616e 6420 7472 6163 p seeds.and trac │ │ │ +00038c90: 6b65 7273 2066 6f72 2069 6e73 7461 6e63 kers for instanc │ │ │ +00038ca0: 653c 2f68 323e 3c68 343e 2e2e 2f74 6573 e

    ../tes │ │ │ +00038cb0: 742f 7465 7374 5f72 6573 756d 652e 6370 t/test_resume.cp │ │ │ +00038cc0: 703a 3137 3135 3c2f 6834 3e3c 7072 6520 p:1715

    .TEST_EQUAL
    │ │ │ +00038d10: 2873 2e63 6f6e 6e65 6374 696f 6e73 5f6c  (s.connections_l
    │ │ │ +00038d20: 696d 6974 2c20 3133 3435 293b 0a09 5445  imit, 1345);..TE
    │ │ │ +00038d30: 5354 5f45 5155 414c 2873 2e75 706c 6f61  ST_EQUAL(s.uploa
    │ │ │ +00038d40: 6473 5f6c 696d 6974 2c20 3133 3436 293b  ds_limit, 1346);
    │ │ │ +00038d50: 0a7d 0a0a 544f 5252 454e 545f 5445 5354  .}..TORRENT_TEST
    │ │ │ +00038d60: 2870 6175 7365 6429 0a7b 0a09 6c74 3a3a  (paused).{..lt::
    │ │ │ +00038d70: 7365 7373 696f 6e20 7365 7328 7365 7474  session ses(sett
    │ │ │ +00038d80: 696e 6773 2829 293b 0a09 2f2f 2072 6573  ings());..// res
    │ │ │ +00038d90: 756d 6520 6461 7461 206f 7665 7272 6964  ume data overrid
    │ │ │ +00038da0: 6573 2074 6865 2070 6175 7365 6420 666c  es the paused fl
    │ │ │ +00038db0: 6167 0a09 6175 746f 2063 6f6e 7374 206e  ag..auto const n
    │ │ │ +00038dc0: 6f77 203d 206c 743a 3a63 6c6f 636b 5f74  ow = lt::clock_t
    │ │ │ +00038dd0: 7970 653a 3a6e 6f77 2829 3b0a 0974 6f72  ype::now();..tor
    │ │ │ +00038de0: 7265 6e74 5f73 7461 7475 7320 7320 3d20  rent_status s = 
    │ │ │ +00038df0: 7465 7374 5f72 6573 756d 655f 666c 6167  test_resume_flag
    │ │ │ +00038e00: 7328 7365 732c 2074 6f72 7265 6e74 5f66  s(ses, torrent_f
    │ │ │ +00038e10: 6c61 6773 3a3a 7061 7573 6564 292e 7374  lags::paused).st
    │ │ │ +00038e20: 6174 7573 2829 3b0a 0964 6566 6175 6c74  atus();..default
    │ │ │ +00038e30: 5f74 6573 7473 2873 2c20 6e6f 7729 3b0a  _tests(s, now);.
    │ │ │ +00038e40: 2369 6664 6566 2054 4f52 5245 4e54 5f57  #ifdef TORRENT_W
    │ │ │ +00038e50: 494e 444f 5753 0a09 5445 5354 5f45 5155  INDOWS..TEST_EQU
    │ │ │ +00038e60: 414c 2873 2e73 6176 655f 7061 7468 2c20  AL(s.save_path, 
    │ │ │ +00038e70: 2263 3a5c 5c61 6464 5f74 6f72 7265 6e74  "c:\\add_torrent
    │ │ │ +00038e80: 5f70 6172 616d 7320 7361 7665 5f70 6174  _params save_pat
    │ │ │ +00038e90: 6822 293b 0a23 656c 7365 0a09 5445 5354  h");.#else..TEST
    │ │ │ +00038ea0: 5f45 5155 414c 2873 2e73 6176 655f 7061  _EQUAL(s.save_pa
    │ │ │ +00038eb0: 7468 2c20 222f 6164 645f 746f 7272 656e  th, "/add_torren
    │ │ │ +00038ec0: 745f 7061 7261 6d73 2073 6176 655f 7061  t_params save_pa
    │ │ │ +00038ed0: 7468 2229 3b0a 2365 6e64 6966 0a09 5445  th");.#endif..TE
    │ │ │ +00038ee0: 5354 5f45 5155 414c 2873 2e66 6c61 6773  ST_EQUAL(s.flags
    │ │ │ +00038ef0: 2026 616d 703b 2066 6c61 6773 5f6d 6173   & flags_mas
    │ │ │ +00038f00: 6b2c 2074 6f72 7265 6e74 5f66 6c61 6773  k, torrent_flags
    │ │ │ +00038f10: 3a3a 7061 7573 6564 293b 0a09 5445 5354  ::paused);..TEST
    │ │ │ +00038f20: 5f45 5155 414c 2873 2e63 6f6e 6e65 6374  _EQUAL(s.connect
    │ │ │ +00038f30: 696f 6e73 5f6c 696d 6974 2c20 3133 3435  ions_limit, 1345
    │ │ │ +00038f40: 293b 0a09 5445 5354 5f45 5155 414c 2873  );..TEST_EQUAL(s
    │ │ │ +00038f50: 2e75 706c 6f61 6473 5f6c 696d 6974 2c20  .uploads_limit, 
    │ │ │ +00038f60: 3133 3436 293b 0a0a 3c64 6976 2073 7479  1346);..
    }.
    .T │ │ │ +00038fa0: 4f52 5245 4e54 5f54 4553 5428 6e6f 5f6d ORRENT_TEST(no_m │ │ │ +00038fb0: 6574 6164 6174 6129 0a7b 0a09 6c74 3a3a etadata).{..lt:: │ │ │ +00038fc0: 7365 7373 696f 6e20 7365 7328 7365 7474 session ses(sett │ │ │ +00038fd0: 696e 6773 2829 293b 0a0a 0961 6464 5f74 ings());...add_t │ │ │ +00038fe0: 6f72 7265 6e74 5f70 6172 616d 7320 703b orrent_params p; │ │ │ +00038ff0: 0a09 702e 696e 666f 5f68 6173 6865 732e ..p.info_hashes. │ │ │ +00039000: 7631 203d 2073 6861 315f 6861 7368 2822 v1 = sha1_hash(" │ │ │ +00039010: 6162 6162 6162 6162 6162 6162 6162 6162 abababababababab │ │ │ +00039020: 6162 6162 2229 3b0a 0970 2e73 6176 655f abab");..p.save_ │ │ │ +00039030: 7061 7468 203d 2022 2e22 3b0a 0970 2e6e path = ".";..p.n │ │ │ +00039040: 616d 6520 3d20 2266 6f6f 6261 7222 3b0a ame = "foobar";. │ │ │ +00039050: 0974 6f72 7265 6e74 5f68 616e 646c 6520 .torrent_handle │ │ │ +00039060: 6820 3d20 7365 732e 6164 645f 746f 7272 h = ses.add_torr │ │ │ +00039070: 656e 7428 7029 3b0a 0968 2e73 6176 655f ent(p);..h.save_ │ │ │ +00039080: 7265 7375 6d65 5f64 6174 6128 746f 7272 resume_data(torr │ │ │ +00039090: 656e 745f 6861 6e64 6c65 3a3a 7361 7665 ent_handle::save │ │ │ +000390a0: 5f69 6e66 6f5f 6469 6374 293b 0a09 616c _info_dict);..al │ │ │ +000390b0: 6572 7420 636f 6e73 742a 2061 203d 2077 ert const* a = w │ │ │ +000390c0: 6169 745f 666f 725f 616c 6572 7428 7365 ait_for_alert(se │ │ │ +000390d0: 732c 2073 6176 655f 7265 7375 6d65 5f64 s, save_resume_d │ │ │ +000390e0: 6174 615f 616c 6572 743a 3a61 6c65 7274 ata_alert::alert │ │ │ +000390f0: 5f74 7970 6529 3b0a 0954 4553 545f 4348 _type);..TEST_CH │ │ │ +00039100: 4543 4b28 6129 3b0a 0973 6176 655f 7265 ECK(a);..save_re │ │ │ +00039110: 7375 6d65 5f64 6174 615f 616c 6572 7420 sume_data_alert │ │ │ +00039120: 636f 6e73 742a 2072 6120 3d20 616c 6572 const* ra = aler │ │ │ +00039130: 745f 6361 7374 266c 743b 7361 7665 5f72 t_cast<save_r │ │ │ +00039140: 6573 756d 655f 6461 7461 5f61 6c65 7274 esume_data_alert │ │ │ +00039150: 2667 743b 2861 293b 0a09 5445 5354 5f43 >(a);..TEST_C │ │ │ +00039160: 4845 434b 2872 6129 3b0a 0969 6620 2872 HECK(ra);..if (r │ │ │ +00039170: 6129 0a09 7b0a 0909 6175 746f 2063 6f6e a)..{...auto con │ │ │ +00039180: 7374 2661 6d70 3b20 6174 7020 3d20 7261 st& atp = ra │ │ │ +00039190: 2d26 6774 3b70 6172 616d 733b 0a09 0954 ->params;...T │ │ │ +000391a0: 4553 545f 4551 5541 4c28 6174 702e 696e EST_EQUAL(atp.in │ │ │ +000391b0: 666f 5f68 6173 6865 732c 2070 2e69 6e66 fo_hashes, p.inf │ │ │ +000391c0: 6f5f 6861 7368 6573 293b 0a09 0954 4553 o_hashes);...TES │ │ │ +000391d0: 545f 4551 5541 4c28 6174 702e 6e61 6d65 T_EQUAL(atp.name │ │ │ +000391e0: 2c20 2266 6f6f 6261 7222 293b 0a09 7d0a , "foobar");..}. │ │ │ +000391f0: 7d0a 0a74 656d 706c 6174 6520 266c 743b }..template < │ │ │ +00039200: 7479 7065 6e61 6d65 2046 756e 2667 743b typename Fun> │ │ │ +00039210: 0a76 6f69 6420 7465 7374 5f75 6e66 696e .void test_unfin │ │ │ +00039220: 6973 6865 645f 7069 6563 6573 2846 756e ished_pieces(Fun │ │ │ +00039230: 2066 290a 7b0a 092f 2f20 6372 6561 7465 f).{..// create │ │ │ +00039240: 2061 2074 6f72 7265 6e74 2061 6e64 2063 a torrent and c │ │ │ +00039250: 6f6d 706c 6574 6520 6669 6c65 730a 0973 omplete files..s │ │ │ +00039260: 7464 3a3a 7368 6172 6564 5f70 7472 266c td::shared_ptr&l │ │ │ +00039270: 743b 746f 7272 656e 745f 696e 666f 2667 t;torrent_info&g │ │ │ +00039280: 743b 2074 6920 3d20 6765 6e65 7261 7465 t; ti = generate │ │ │ +00039290: 5f74 6f72 7265 6e74 2874 7275 652c 2074 _torrent(true, t │ │ │ +000392a0: 7275 6529 3b0a 0a09 6164 645f 746f 7272 rue);...add_torr │ │ │ +000392b0: 656e 745f 7061 7261 6d73 2070 3b0a 3c2f ent_params p;.r │ │ │ +000392f0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +00039300: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../test │ │ │ +00039330: 2f74 6573 745f 6d65 726b 6c65 5f74 7265 /test_merkle_tre │ │ │ +00039340: 652e 6370 703a 3233 333c 2f61 3e3c 2f74 e.cpp:233use struct │ │ │ +00039360: 7572 6564 2062 696e 6469 6e67 7320 696e ured bindings in │ │ │ +00039370: 2043 2b2b 3137 3c2f 7464 3e3c 2f74 723e C++17 │ │ │ +00039380: 3c74 7220 6964 3d22 3133 3022 2073 7479 │ │ │ +000393b0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +000393c0: 3c68 323e 7573 6520 7374 7275 6374 7572

    use structur │ │ │ +000393d0: 6564 2062 696e 6469 6e67 7320 696e 2043 ed bindings in C │ │ │ +000393e0: 2b2b 3137 3c2f 6832 3e3c 6834 3e2e 2e2f ++17

    ../ │ │ │ +000393f0: 7465 7374 2f74 6573 745f 6d65 726b 6c65 test/test_merkle │ │ │ +00039400: 5f74 7265 652e 6370 703a 3233 333c 2f68 _tree.cpp:233
    ...m
    │ │ │ +00039450: 6173 6b5b 7374 643a 3a73 697a 655f 7428  ask[std::size_t(
    │ │ │ +00039460: 6929 5d20 3d20 7472 7565 3b0a 0909 742e  i)] = true;...t.
    │ │ │ +00039470: 6c6f 6164 5f73 7061 7273 655f 7472 6565  load_sparse_tree
    │ │ │ +00039480: 2873 7061 6e26 6c74 3b73 6861 3235 365f  (span<sha256_
    │ │ │ +00039490: 6861 7368 2063 6f6e 7374 2667 743b 2866  hash const>(f
    │ │ │ +000394a0: 292e 7375 6273 7061 6e28 6669 7273 745f  ).subspan(first_
    │ │ │ +000394b0: 7069 6563 652c 206e 756d 5f70 6965 6365  piece, num_piece
    │ │ │ +000394c0: 7329 2c20 6d61 736b 2c20 656d 7074 795f  s), mask, empty_
    │ │ │ +000394d0: 7665 7269 6669 6564 293b 0a09 0969 6e74  verified);...int
    │ │ │ +000394e0: 2063 6f6e 7374 2065 6e64 5f70 6965 6365   const end_piece
    │ │ │ +000394f0: 5f6c 6179 6572 203d 2066 6972 7374 5f70  _layer = first_p
    │ │ │ +00039500: 6965 6365 202b 206d 6572 6b6c 655f 6e75  iece + merkle_nu
    │ │ │ +00039510: 6d5f 6c65 6166 7328 6e75 6d5f 7069 6563  m_leafs(num_piec
    │ │ │ +00039520: 6573 293b 0a09 0966 6f72 2028 696e 7420  es);...for (int 
    │ │ │ +00039530: 6920 3d20 303b 2069 2026 6c74 3b20 656e  i = 0; i < en
    │ │ │ +00039540: 645f 7069 6563 655f 6c61 7965 723b 202b  d_piece_layer; +
    │ │ │ +00039550: 2b69 290a 0909 7b0a 0909 0954 4553 545f  +i)...{....TEST_
    │ │ │ +00039560: 4348 4543 4b28 742e 6861 735f 6e6f 6465  CHECK(t.has_node
    │ │ │ +00039570: 2869 2929 3b0a 0909 0954 4553 545f 4348  (i));....TEST_CH
    │ │ │ +00039580: 4543 4b28 742e 636f 6d70 6172 655f 6e6f  ECK(t.compare_no
    │ │ │ +00039590: 6465 2869 2c20 665b 695d 2929 3b0a 0909  de(i, f[i]));...
    │ │ │ +000395a0: 7d0a 0909 666f 7220 2869 6e74 2069 203d  }...for (int i =
    │ │ │ +000395b0: 2065 6e64 5f70 6965 6365 5f6c 6179 6572   end_piece_layer
    │ │ │ +000395c0: 3b20 6920 266c 743b 206e 756d 5f6e 6f64  ; i < num_nod
    │ │ │ +000395d0: 6573 3b20 2b2b 6929 0a09 097b 0a09 0909  es; ++i)...{....
    │ │ │ +000395e0: 5445 5354 5f43 4845 434b 2821 742e 6861  TEST_CHECK(!t.ha
    │ │ │ +000395f0: 735f 6e6f 6465 2869 2929 3b0a 0909 7d0a  s_node(i));...}.
    │ │ │ +00039600: 097d 0a7d 0a0a 6e61 6d65 7370 6163 6520  .}.}..namespace 
    │ │ │ +00039610: 7b0a 766f 6964 2074 6573 745f 726f 756e  {.void test_roun
    │ │ │ +00039620: 6474 7269 7028 6175 783a 3a6d 6572 6b6c  dtrip(aux::merkl
    │ │ │ +00039630: 655f 7472 6565 2063 6f6e 7374 2661 6d70  e_tree const&
    │ │ │ +00039640: 3b20 740a 092c 2069 6e74 2063 6f6e 7374  ; t.., int const
    │ │ │ +00039650: 2062 6c6f 636b 5f63 6f75 6e74 0a09 2c20   block_count.., 
    │ │ │ +00039660: 696e 7420 636f 6e73 7420 626c 6f63 6b73  int const blocks
    │ │ │ +00039670: 5f70 6572 5f70 6965 6365 290a 7b0a 3c64  _per_piece).{..aux
    │ │ │ +000396b0: 3a3a 7665 6374 6f72 266c 743b 626f 6f6c  ::vector<bool
    │ │ │ +000396c0: 2667 743b 206d 6173 6b3b 0a3c 2f64 6976  > mask;..std::vector<
    │ │ │ +000396e0: 3b73 6861 3235 365f 6861 7368 2667 743b  ;sha256_hash>
    │ │ │ +000396f0: 2074 7265 653b 0a09 7374 643a 3a74 6965   tree;..std::tie
    │ │ │ +00039700: 2874 7265 652c 206d 6173 6b29 203d 2074  (tree, mask) = t
    │ │ │ +00039710: 2e62 7569 6c64 5f73 7061 7273 655f 7665  .build_sparse_ve
    │ │ │ +00039720: 6374 6f72 2829 3b0a 0a09 6175 783a 3a6d  ctor();...aux::m
    │ │ │ +00039730: 6572 6b6c 655f 7472 6565 2074 3228 626c  erkle_tree t2(bl
    │ │ │ +00039740: 6f63 6b5f 636f 756e 742c 2062 6c6f 636b  ock_count, block
    │ │ │ +00039750: 735f 7065 725f 7069 6563 652c 2066 5b30  s_per_piece, f[0
    │ │ │ +00039760: 5d2e 6461 7461 2829 293b 0a09 7432 2e6c  ].data());..t2.l
    │ │ │ +00039770: 6f61 645f 7370 6172 7365 5f74 7265 6528  oad_sparse_tree(
    │ │ │ +00039780: 7472 6565 2c20 6d61 736b 2c20 656d 7074  tree, mask, empt
    │ │ │ +00039790: 795f 7665 7269 6669 6564 293b 0a0a 0954  y_verified);...T
    │ │ │ +000397a0: 4553 545f 4348 4543 4b28 742e 6275 696c  EST_CHECK(t.buil
    │ │ │ +000397b0: 645f 7665 6374 6f72 2829 203d 3d20 7432  d_vector() == t2
    │ │ │ +000397c0: 2e62 7569 6c64 5f76 6563 746f 7228 2929  .build_vector())
    │ │ │ +000397d0: 3b0a 0966 6f72 2028 696e 7420 6920 3d20  ;..for (int i = 
    │ │ │ +000397e0: 303b 2069 2026 6c74 3b20 696e 7428 742e  0; i < int(t.
    │ │ │ +000397f0: 7369 7a65 2829 293b 202b 2b69 290a 097b  size()); ++i)..{
    │ │ │ +00039800: 0a09 0954 4553 545f 4551 5541 4c28 745b  ...TEST_EQUAL(t[
    │ │ │ +00039810: 695d 2c20 7432 5b69 5d29 3b0a 0909 5445  i], t2[i]);...TE
    │ │ │ +00039820: 5354 5f45 5155 414c 2874 2e68 6173 5f6e  ST_EQUAL(t.has_n
    │ │ │ +00039830: 6f64 6528 6929 2c20 7432 2e68 6173 5f6e  ode(i), t2.has_n
    │ │ │ +00039840: 6f64 6528 6929 293b 0a0a 0909 6966 2028  ode(i));....if (
    │ │ │ +00039850: 2174 2e68 6173 5f6e 6f64 6528 6929 290a  !t.has_node(i)).
    │ │ │ +00039860: 0909 0954 4553 545f 4348 4543 4b28 745b  ...TEST_CHECK(t[
    │ │ │ +00039870: 695d 2e69 735f 616c 6c5f 7a65 726f 7328  i].is_all_zeros(
    │ │ │ +00039880: 2929 3b0a 0909 6966 2028 2174 322e 6861  ));...if (!t2.ha
    │ │ │ +00039890: 735f 6e6f 6465 2869 2929 0a09 0909 5445  s_node(i))....TE
    │ │ │ +000398a0: 5354 5f43 4845 434b 2874 325b 695d 2e69  ST_CHECK(t2[i].i
    │ │ │ +000398b0: 735f 616c 6c5f 7a65 726f 7328 2929 3b0a  s_all_zeros());.
    │ │ │ +000398c0: 0a09 0954 4553 545f 4348 4543 4b28 742e  ...TEST_CHECK(t.
    │ │ │ +000398d0: 636f 6d70 6172 655f 6e6f 6465 2869 2c20  compare_node(i, 
    │ │ │ +000398e0: 7432 5b69 5d29 293b 0a09 0954 4553 545f  t2[i]));...TEST_
    │ │ │ +000398f0: 4348 4543 4b28 7432 2e63 6f6d 7061 7265  CHECK(t2.compare
    │ │ │ +00039900: 5f6e 6f64 6528 692c 2074 5b69 5d29 293b  _node(i, t[i]));
    │ │ │ +00039910: 0a09 7d0a 7d0a 7d0a 0a54 4f52 5245 4e54  ..}.}.}..TORRENT
    │ │ │ +00039920: 5f54 4553 5428 726f 756e 6474 7269 705f  _TEST(roundtrip_
    │ │ │ +00039930: 656d 7074 795f 7472 6565 290a 7b0a 0961  empty_tree).{..a
    │ │ │ +00039940: 7578 3a3a 6d65 726b 6c65 5f74 7265 6520  ux::merkle_tree 
    │ │ │ +00039950: 7428 6e75 6d5f 626c 6f63 6b73 2c20 312c  t(num_blocks, 1,
    │ │ │ +00039960: 2066 5b30 5d2e 6461 7461 2829 293b 0a09   f[0].data());..
    │ │ │ +00039970: 7465 7374 5f72 6f75 6e64 7472 6970 2874  test_roundtrip(t
    │ │ │ +00039980: 2c20 6e75 6d5f 626c 6f63 6b73 2c20 3129  , num_blocks, 1)
    │ │ │ +00039990: 3b0a 7d0a 0a54 4f52 5245 4e54 5f54 4553  ;.}..TORRENT_TES
    │ │ │ +000399a0: 5428 726f 756e 6474 7269 705f 6675 6c6c  T(roundtrip_full
    │ │ │ +000399b0: 5f74 7265 6529 0a3c 2f70 7265 3e3c 2f74  _tree).
    relevanc │ │ │ +000399f0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../test/test_m │ │ │ +00039a30: 6572 6b6c 655f 7472 6565 2e63 7070 3a39 erkle_tree.cpp:9 │ │ │ +00039a40: 3935 3c2f 613e 3c2f 7464 3e3c 7464 3e61 95a │ │ │ +00039a50: 6464 2074 6573 7420 666f 7220 6c6f 6164 dd test for load │ │ │ +00039a60: 5f70 6965 6365 5f6c 6179 6572 2829 3c2f _piece_layer()

    add │ │ │ +00039ac0: 7465 7374 2066 6f72 206c 6f61 645f 7069 test for load_pi │ │ │ +00039ad0: 6563 655f 6c61 7965 7228 293c 2f68 323e ece_layer()

    │ │ │ +00039ae0: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ +00039af0: 5f6d 6572 6b6c 655f 7472 6565 2e63 7070 _merkle_tree.cpp │ │ │ +00039b00: 3a39 3935 3c2f 6834 3e3c 7072 6520 7374 :995

    
    │ │ │ +00039b70: 3c74 643e 7265 6c65 7661 6e63 6526 6e62  relevance&nb
    │ │ │ +00039b80: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120  sp;0..
    │ │ │ +00039bb0: 2f74 6573 742f 7465 7374 5f6d 6572 6b6c  /test/test_merkl
    │ │ │ +00039bc0: 655f 7472 6565 2e63 7070 3a39 3936 3c2f  e_tree.cpp:996add t
    │ │ │ +00039be0: 6573 7420 666f 7220 6164 645f 6861 7368  est for add_hash
    │ │ │ +00039bf0: 6573 2829 2077 6974 6820 616e 206f 6464  es() with an odd
    │ │ │ +00039c00: 206e 756d 6265 7220 6f66 2062 6c6f 636b   number of block
    │ │ │ +00039c10: 733c 2f74 643e 3c2f 7472 3e3c 7472 2069  s

    a │ │ │ +00039c60: 6464 2074 6573 7420 666f 7220 6164 645f dd test for add_ │ │ │ +00039c70: 6861 7368 6573 2829 2077 6974 6820 616e hashes() with an │ │ │ +00039c80: 206f 6464 206e 756d 6265 7220 6f66 2062 odd number of b │ │ │ +00039c90: 6c6f 636b 733c 2f68 323e 3c68 343e 2e2e locks

    .. │ │ │ +00039ca0: 2f74 6573 742f 7465 7374 5f6d 6572 6b6c /test/test_merkl │ │ │ +00039cb0: 655f 7472 6565 2e63 7070 3a39 3936 3c2f e_tree.cpp:996

    re │ │ │ +00039d30: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0
    ../test/ │ │ │ +00039d70: 7465 7374 5f6d 6572 6b6c 655f 7472 6565 test_merkle_tree │ │ │ +00039d80: 2e63 7070 3a39 3937 3c2f 613e 3c2f 7464 .cpp:997add test fo │ │ │ +00039da0: 7220 7365 745f 626c 6f63 6b28 2920 2873 r set_block() (s │ │ │ +00039db0: 6574 7469 6e67 2074 6865 206c 6173 7420 etting the last │ │ │ +00039dc0: 626c 6f63 6b29 2077 6974 6820 616e 206f block) with an o │ │ │ +00039dd0: 6464 206e 756d 6265 7220 6f66 2062 6c6f dd number of blo │ │ │ +00039de0: 636b 733c 2f74 643e 3c2f 7472 3e3c 7472 cks

    add test for se │ │ │ +00039e40: 745f 626c 6f63 6b28 2920 2873 6574 7469 t_block() (setti │ │ │ +00039e50: 6e67 2074 6865 206c 6173 7420 626c 6f63 ng the last bloc │ │ │ +00039e60: 6b29 2077 6974 6820 616e 206f 6464 206e k) with an odd n │ │ │ +00039e70: 756d 6265 7220 6f66 2062 6c6f 636b 733c umber of blocks< │ │ │ +00039e80: 2f68 323e 3c68 343e 2e2e 2f74 6573 742f /h2>

    ../test/ │ │ │ +00039e90: 7465 7374 5f6d 6572 6b6c 655f 7472 6565 test_merkle_tree │ │ │ +00039ea0: 2e63 7070 3a39 3937 3c2f 6834 3e3c 7072 .cpp:997

    .TEST_CHE │ │ │ +00039ef0: 434b 2874 2e6c 6f61 645f 7069 6563 655f CK(t.load_piece_ │ │ │ +00039f00: 6c61 7965 7228 7069 6563 655f 6c61 7965 layer(piece_laye │ │ │ +00039f10: 725f 6279 7465 7329 293b 0a0a 092f 2f20 r_bytes));...// │ │ │ +00039f20: 696e 2070 6965 6365 5f6c 6179 6572 206d in piece_layer m │ │ │ +00039f30: 6f64 6520 7769 7468 2062 7070 2026 6774 ode with bpp > │ │ │ +00039f40: 3b20 312c 206e 6f20 626c 6f63 6b73 2073 ; 1, no blocks s │ │ │ +00039f50: 686f 756c 6420 7265 706f 7274 2061 7320 hould report as │ │ │ +00039f60: 7665 7269 6669 6564 0a09 5445 5354 5f43 verified..TEST_C │ │ │ +00039f70: 4845 434b 2874 2e76 6572 6966 6965 645f HECK(t.verified_ │ │ │ +00039f80: 6c65 6166 7328 2920 3d3d 206e 6f6e 655f leafs() == none_ │ │ │ +00039f90: 7365 7428 6e75 6d5f 626c 6f63 6b73 2929 set(num_blocks)) │ │ │ +00039fa0: 3b0a 0a09 2f2f 2061 6674 6572 206c 6f61 ;...// after loa │ │ │ +00039fb0: 645f 7069 6563 655f 6c61 7965 7220 7468 d_piece_layer th │ │ │ +00039fc0: 6520 7472 6565 2069 7320 6261 636b 2069 e tree is back i │ │ │ +00039fd0: 6e20 7468 6520 7069 6563 655f 6c61 7965 n the piece_laye │ │ │ +00039fe0: 722d 6f6e 6c79 0a09 2f2f 2073 7461 7465 r-only..// state │ │ │ +00039ff0: 2c20 736f 2061 2073 696e 676c 6520 7365 , so a single se │ │ │ +0003a000: 745f 626c 6f63 6b20 6361 6e27 7420 7965 t_block can't ye │ │ │ +0003a010: 7420 7665 7269 6679 2061 6761 696e 7374 t verify against │ │ │ +0003a020: 2074 6865 2073 6962 6c69 6e67 2e0a 0961 the sibling...a │ │ │ +0003a030: 7574 6f20 636f 6e73 7420 7265 7375 6c74 uto const result │ │ │ +0003a040: 203d 2074 2e73 6574 5f62 6c6f 636b 2830 = t.set_block(0 │ │ │ +0003a050: 2c20 665b 3531 315d 293b 0a09 5445 5354 , f[511]);..TEST │ │ │ +0003a060: 5f43 4845 434b 2873 7464 3a3a 6765 7426 _CHECK(std::get& │ │ │ +0003a070: 6c74 3b30 2667 743b 2872 6573 756c 7429 lt;0>(result) │ │ │ +0003a080: 203d 3d20 6175 783a 3a6d 6572 6b6c 655f == aux::merkle_ │ │ │ +0003a090: 7472 6565 3a3a 7365 745f 626c 6f63 6b5f tree::set_block_ │ │ │ +0003a0a0: 7265 7375 6c74 3a3a 756e 6b6e 6f77 6e29 result::unknown) │ │ │ +0003a0b0: 3b0a 0a09 2f2f 2074 6865 2073 6574 5f62 ;...// the set_b │ │ │ +0003a0c0: 6c6f 636b 2061 626f 7665 2072 616e 2061 lock above ran a │ │ │ +0003a0d0: 6c6c 6f63 6174 655f 6675 6c6c 2829 2c20 llocate_full(), │ │ │ +0003a0e0: 6272 696e 6769 6e67 2075 7320 6261 636b bringing us back │ │ │ +0003a0f0: 2074 6f20 6675 6c6c 5f74 7265 650a 092f to full_tree../ │ │ │ +0003a100: 2f20 6d6f 6465 2077 6865 7265 2076 6572 / mode where ver │ │ │ +0003a110: 6966 6965 645f 6c65 6166 7328 292f 626c ified_leafs()/bl │ │ │ +0003a120: 6f63 6b73 5f76 6572 6966 6965 6428 2920 ocks_verified() │ │ │ +0003a130: 636f 6e73 756c 7420 6d5f 626c 6f63 6b5f consult m_block_ │ │ │ +0003a140: 7665 7269 6669 6564 0a09 2f2f 2064 6972 verified..// dir │ │ │ +0003a150: 6563 746c 7920 2869 6e20 7069 6563 655f ectly (in piece_ │ │ │ +0003a160: 6c61 7965 7220 6d6f 6465 2074 6865 7920 layer mode they │ │ │ +0003a170: 6967 6e6f 7265 2069 7429 2e20 616c 6c6f ignore it). allo │ │ │ +0003a180: 6361 7465 5f66 756c 6c27 7320 7265 7369 cate_full's resi │ │ │ +0003a190: 7a65 0a09 2f2f 2070 7265 7365 7276 6573 ze..// preserves │ │ │ +0003a1a0: 2061 6e79 2070 7265 2d65 7869 7374 696e any pre-existin │ │ │ +0003a1b0: 6720 6269 7473 2c20 736f 2068 6164 206c g bits, so had l │ │ │ +0003a1c0: 6f61 645f 7069 6563 655f 6c61 7965 7220 oad_piece_layer │ │ │ +0003a1d0: 6661 696c 6564 2074 6f0a 092f 2f20 636c failed to..// cl │ │ │ +0003a1e0: 6561 7220 7468 656d 2074 6865 2073 7461 ear them the sta │ │ │ +0003a1f0: 6c65 2070 6965 6365 2d30 2062 6974 7320 le piece-0 bits │ │ │ +0003a200: 776f 756c 6420 7265 7375 7266 6163 6520 would resurface │ │ │ +0003a210: 6173 2022 7665 7269 6669 6564 2220 6865 as "verified" he │ │ │ +0003a220: 7265 202d 2d0a 092f 2f20 6361 7463 6869 re --..// catchi │ │ │ +0003a230: 6e67 2074 6865 2062 7567 2065 7665 6e20 ng the bug even │ │ │ +0003a240: 696e 2062 7569 6c64 7320 636f 6d70 696c in builds compil │ │ │ +0003a250: 6564 2077 6974 686f 7574 2069 6e76 6172 ed without invar │ │ │ +0003a260: 6961 6e74 2063 6865 636b 732e 0a09 5445 iant checks...TE │ │ │ +0003a270: 5354 5f43 4845 434b 2821 742e 626c 6f63 ST_CHECK(!t.bloc │ │ │ +0003a280: 6b73 5f76 6572 6966 6965 6428 302c 2062 ks_verified(0, b │ │ │ +0003a290: 6c6f 636b 735f 7065 725f 7069 6563 6529 locks_per_piece) │ │ │ +0003a2a0: 293b 0a09 5445 5354 5f43 4845 434b 2874 );..TEST_CHECK(t │ │ │ +0003a2b0: 2e76 6572 6966 6965 645f 6c65 6166 7328 .verified_leafs( │ │ │ +0003a2c0: 2920 3d3d 206e 6f6e 655f 7365 7428 6e75 ) == none_set(nu │ │ │ +0003a2d0: 6d5f 626c 6f63 6b73 2929 3b0a 7d0a 0a3c m_blocks));.}..< │ │ │ +0003a2e0: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ +0003a2f0: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ +0003a300: 7769 6474 683d 2231 3030 2522 3e0a 3c2f width="100%">.TORRENT_TEST │ │ │ +0003a320: 2861 6464 5f68 6173 6865 735f 7a65 726f (add_hashes_zero │ │ │ +0003a330: 5f62 6c6f 636b 5f68 6173 6829 0a7b 0a09 _block_hash).{.. │ │ │ +0003a340: 2f2f 2061 2070 6565 7220 6361 6e20 6173 // a peer can as │ │ │ +0003a350: 6b20 7573 2074 6f20 696e 7365 7274 2061 k us to insert a │ │ │ +0003a360: 2073 696e 676c 6520 626c 6f63 6b20 6861 single block ha │ │ │ +0003a370: 7368 206f 6620 616c 6c20 7a65 726f 732e sh of all zeros. │ │ │ +0003a380: 2074 6861 7427 7320 7468 650a 092f 2f20 that's the..// │ │ │ +0003a390: 7361 6d65 2076 616c 7565 2061 6e20 756e same value an un │ │ │ +0003a3a0: 6b6e 6f77 6e20 6e6f 6465 2068 6173 2c20 known node has, │ │ │ +0003a3b0: 736f 2074 6865 2069 6e73 6572 7420 6d75 so the insert mu │ │ │ +0003a3c0: 7374 2062 6520 7265 6a65 6374 6564 2072 st be rejected r │ │ │ +0003a3d0: 6174 6865 720a 092f 2f20 7468 616e 2073 ather..// than s │ │ │ +0003a3e0: 696c 656e 746c 7920 6d61 726b 696e 6720 ilently marking │ │ │ +0003a3f0: 7468 6520 626c 6f63 6b20 6173 2076 6572 the block as ver │ │ │ +0003a400: 6966 6965 640a 0961 7578 3a3a 6d65 726b ified..aux::merk │ │ │ +0003a410: 6c65 5f74 7265 6520 7428 6e75 6d5f 626c le_tree t(num_bl │ │ │ +0003a420: 6f63 6b73 2c20 342c 2066 5b30 5d2e 6461 ocks, 4, f[0].da │ │ │ +0003a430: 7461 2829 293b 0a0a 0973 7464 3a3a 7665 ta());...std::ve │ │ │ +0003a440: 6374 6f72 266c 743b 7368 6132 3536 5f68 ctor<sha256_h │ │ │ +0003a450: 6173 6826 6774 3b20 636f 6e73 7420 6861 ash> const ha │ │ │ +0003a460: 7368 6573 7b73 6861 3235 365f 6861 7368 shes{sha256_hash │ │ │ +0003a470: 7b7d 7d3b 0a09 7374 643a 3a76 6563 746f {}};..std::vecto │ │ │ +0003a480: 7226 6c74 3b73 6861 3235 365f 6861 7368 r<sha256_hash │ │ │ +0003a490: 2667 743b 2063 6f6e 7374 2070 726f 6f66 > const proof │ │ │ +0003a4a0: 737b 7261 6e64 5f73 6861 3235 3628 297d s{rand_sha256()} │ │ │ +0003a4b0: 3b0a 0a09 6175 746f 2063 6f6e 7374 2072 ;...auto const r │ │ │ +0003a4c0: 6573 756c 7420 3d20 742e 6164 645f 6861 esult = t.add_ha │ │ │ +0003a4d0: 7368 6573 286d 6572 6b6c 655f 6669 7273 shes(merkle_firs │ │ │ +0003a4e0: 745f 6c65 6166 286e 756d 5f6c 6561 6673 t_leaf(num_leafs │ │ │ +0003a4f0: 2920 2b20 312c 2070 6469 6666 2830 292c ) + 1, pdiff(0), │ │ │ +0003a500: 2068 6173 6865 732c 2070 726f 6f66 7329 hashes, proofs) │ │ │ +0003a510: 3b0a 0a09 5445 5354 5f43 4845 434b 2821 ;...TEST_CHECK(! │ │ │ +0003a520: 7265 7375 6c74 293b 0a09 5445 5354 5f43 result);..TEST_C │ │ │ +0003a530: 4845 434b 2874 2e76 6572 6966 6965 645f HECK(t.verified_ │ │ │ +0003a540: 6c65 6166 7328 2920 3d3d 206e 6f6e 655f leafs() == none_ │ │ │ +0003a550: 7365 7428 6e75 6d5f 626c 6f63 6b73 2929 set(num_blocks)) │ │ │ +0003a560: 3b0a 7d0a 3c2f 7072 653e 3c2f 7464 3e3c ;.}.
    < │ │ │ +0003a570: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +0003a5a0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +0003a5d0: 2e2f 7465 7374 2f74 6573 745f 746f 7272 ./test/test_torr │ │ │ +0003a5e0: 656e 745f 696e 666f 2e63 7070 3a34 3735 ent_info.cpp:475 │ │ │ +0003a5f0: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6573 tes │ │ │ +0003a600: 7420 7265 6d61 705f 6669 6c65 733c 2f74 t remap_files

    test │ │ │ +0003a660: 7265 6d61 705f 6669 6c65 733c 2f68 323e remap_files

    │ │ │ +0003a670: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ +0003a680: 5f74 6f72 7265 6e74 5f69 6e66 6f2e 6370 _torrent_info.cp │ │ │ +0003a690: 703a 3437 353c 2f68 343e 3c70 7265 2073 p:475

    <
    │ │ │ +0003a6e0: 2f74 723e 3c74 7220 7374 796c 653d 2262  /tr>relevance&n
    │ │ │ +0003a710: 6273 703b 303c 2f74 643e 3c74 643e 3c61  bsp;0.
    │ │ │ +0003a740: 2e2f 7465 7374 2f74 6573 745f 746f 7272  ./test/test_torr
    │ │ │ +0003a750: 656e 745f 696e 666f 2e63 7070 3a34 3736  ent_info.cpp:476
    │ │ │ +0003a760: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6f72  tor
    │ │ │ +0003a770: 7265 6e74 2077 6974 6820 2770 2720 2870  rent with 'p' (p
    │ │ │ +0003a780: 6164 6669 6c65 2920 6174 7472 6962 7574  adfile) attribut
    │ │ │ +0003a790: 653c 2f74 643e 3c2f 7472 3e3c 7472 2069  e

    t │ │ │ +0003a7e0: 6f72 7265 6e74 2077 6974 6820 2770 2720 orrent with 'p' │ │ │ +0003a7f0: 2870 6164 6669 6c65 2920 6174 7472 6962 (padfile) attrib │ │ │ +0003a800: 7574 653c 2f68 323e 3c68 343e 2e2e 2f74 ute

    ../t │ │ │ +0003a810: 6573 742f 7465 7374 5f74 6f72 7265 6e74 est/test_torrent │ │ │ +0003a820: 5f69 6e66 6f2e 6370 703a 3437 363c 2f68 _info.cpp:476
    rel
    │ │ │ +0003a8a0: 6576 616e 6365 266e 6273 703b 303c 2f74  evance 0../test/t
    │ │ │ +0003a8e0: 6573 745f 746f 7272 656e 745f 696e 666f  est_torrent_info
    │ │ │ +0003a8f0: 2e63 7070 3a34 3737 3c2f 613e 3c2f 7464  .cpp:477torrent wit
    │ │ │ +0003a910: 6820 2768 2720 2868 6964 6465 6e29 2061  h 'h' (hidden) a
    │ │ │ +0003a920: 7474 7269 6275 7465 3c2f 7464 3e3c 2f74  ttribute

    torrent wi │ │ │ +0003a980: 7468 2027 6827 2028 6869 6464 656e 2920 th 'h' (hidden) │ │ │ +0003a990: 6174 7472 6962 7574 653c 2f68 323e 3c68 attribute

    ../test/test_t │ │ │ +0003a9b0: 6f72 7265 6e74 5f69 6e66 6f2e 6370 703a orrent_info.cpp: │ │ │ +0003a9c0: 3437 373c 2f68 343e 3c70 7265 2073 7479 477

    <
    │ │ │ +0003aa30: 7464 3e72 656c 6576 616e 6365 266e 6273  td>relevance&nbs
    │ │ │ +0003aa40: 703b 303c 2f74 643e 3c74 643e 3c61 2068  p;0../
    │ │ │ +0003aa70: 7465 7374 2f74 6573 745f 746f 7272 656e  test/test_torren
    │ │ │ +0003aa80: 745f 696e 666f 2e63 7070 3a34 3738 3c2f  t_info.cpp:478torre
    │ │ │ +0003aaa0: 6e74 2077 6974 6820 2778 2720 2865 7865  nt with 'x' (exe
    │ │ │ +0003aab0: 6375 7461 626c 6529 2061 7474 7269 6275  cutable) attribu
    │ │ │ +0003aac0: 7465 3c2f 7464 3e3c 2f74 723e 3c74 7220  te

    │ │ │ +0003ab10: 746f 7272 656e 7420 7769 7468 2027 7827 torrent with 'x' │ │ │ +0003ab20: 2028 6578 6563 7574 6162 6c65 2920 6174 (executable) at │ │ │ +0003ab30: 7472 6962 7574 653c 2f68 323e 3c68 343e tribute

    │ │ │ +0003ab40: 2e2e 2f74 6573 742f 7465 7374 5f74 6f72 ../test/test_tor │ │ │ +0003ab50: 7265 6e74 5f69 6e66 6f2e 6370 703a 3437 rent_info.cpp:47 │ │ │ +0003ab60: 383c 2f68 343e 3c70 7265 2073 7479 6c65 8

    │ │ │ +0003aba0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e  
    │ │ │ +0003abb0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +0003abe0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0
    ../te │ │ │ +0003ac10: 7374 2f74 6573 745f 746f 7272 656e 745f st/test_torrent_ │ │ │ +0003ac20: 696e 666f 2e63 7070 3a34 3739 3c2f 613e info.cpp:479 │ │ │ +0003ac30: 3c2f 7464 3e3c 7464 3e74 6f72 7265 6e74 torrent │ │ │ +0003ac40: 2077 6974 6820 276c 2720 2873 796d 6c69 with 'l' (symli │ │ │ +0003ac50: 6e6b 2920 6174 7472 6962 7574 653c 2f74 nk) attribute

    torre │ │ │ +0003acb0: 6e74 2077 6974 6820 276c 2720 2873 796d nt with 'l' (sym │ │ │ +0003acc0: 6c69 6e6b 2920 6174 7472 6962 7574 653c link) attribute< │ │ │ +0003acd0: 2f68 323e 3c68 343e 2e2e 2f74 6573 742f /h2>

    ../test/ │ │ │ +0003ace0: 7465 7374 5f74 6f72 7265 6e74 5f69 6e66 test_torrent_inf │ │ │ +0003acf0: 6f2e 6370 703a 3437 393c 2f68 343e 3c70 o.cpp:479

    relevan │ │ │ +0003ad70: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../test/test_ │ │ │ +0003adb0: 746f 7272 656e 745f 696e 666f 2e63 7070 torrent_info.cpp │ │ │ +0003adc0: 3a34 3830 3c2f 613e 3c2f 7464 3e3c 7464 :480torrent with mu │ │ │ +0003ade0: 6c74 6970 6c65 2074 7261 636b 6572 7320 ltiple trackers │ │ │ +0003adf0: 696e 206d 756c 7469 706c 6520 7469 6572 in multiple tier │ │ │ +0003ae00: 732c 206d 616b 696e 6720 7375 7265 2077 s, making sure w │ │ │ +0003ae10: 6520 7368 7566 666c 6520 7468 656d 2028 e shuffle them ( │ │ │ +0003ae20: 686f 7720 646f 2079 6f75 2074 6573 7420 how do you test │ │ │ +0003ae30: 7368 7566 666c 696e 673f 2c20 6c6f 6164 shuffling?, load │ │ │ +0003ae40: 2069 7420 6d75 6c74 6970 6c65 2074 696d it multiple tim │ │ │ +0003ae50: 6573 2061 6e64 206d 616b 6520 7375 7265 es and make sure │ │ │ +0003ae60: 2069 7427 7320 696e 2064 6966 6665 7265 it's in differe │ │ │ +0003ae70: 6e74 206f 7264 6572 2061 7420 6c65 6173 nt order at leas │ │ │ +0003ae80: 7420 6f6e 6365 293c 2f74 643e 3c2f 7472 t once)

    torrent wit │ │ │ +0003aee0: 6820 6d75 6c74 6970 6c65 2074 7261 636b h multiple track │ │ │ +0003aef0: 6572 7320 696e 206d 756c 7469 706c 6520 ers in multiple │ │ │ +0003af00: 7469 6572 732c 206d 616b 696e 6720 7375 tiers, making su │ │ │ +0003af10: 7265 2077 650a 7368 7566 666c 6520 7468 re we.shuffle th │ │ │ +0003af20: 656d 2028 686f 7720 646f 2079 6f75 2074 em (how do you t │ │ │ +0003af30: 6573 7420 7368 7566 666c 696e 673f 2c20 est shuffling?, │ │ │ +0003af40: 6c6f 6164 2069 7420 6d75 6c74 6970 6c65 load it multiple │ │ │ +0003af50: 2074 696d 6573 2061 6e64 206d 616b 650a times and make. │ │ │ +0003af60: 7375 7265 2069 7427 7320 696e 2064 6966 sure it's in dif │ │ │ +0003af70: 6665 7265 6e74 206f 7264 6572 2061 7420 ferent order at │ │ │ +0003af80: 6c65 6173 7420 6f6e 6365 293c 2f68 323e least once)

    │ │ │ +0003af90: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ +0003afa0: 5f74 6f72 7265 6e74 5f69 6e66 6f2e 6370 _torrent_info.cp │ │ │ +0003afb0: 703a 3438 303c 2f68 343e 3c70 7265 2073 p:480

    <
    │ │ │ +0003b000: 2f74 723e 3c74 7220 7374 796c 653d 2262  /tr>relevance&n
    │ │ │ +0003b030: 6273 703b 303c 2f74 643e 3c74 643e 3c61  bsp;0.
    │ │ │ +0003b060: 2e2f 7465 7374 2f74 6573 745f 746f 7272  ./test/test_torr
    │ │ │ +0003b070: 656e 745f 696e 666f 2e63 7070 3a34 3833  ent_info.cpp:483
    │ │ │ +0003b080: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6f72  tor
    │ │ │ +0003b090: 7265 6e74 7320 7769 7468 2061 207a 6572  rents with a zer
    │ │ │ +0003b0a0: 6f2d 6c65 6e67 7468 206e 616d 653c 2f74  o-length name

    torre │ │ │ +0003b100: 6e74 7320 7769 7468 2061 207a 6572 6f2d nts with a zero- │ │ │ +0003b110: 6c65 6e67 7468 206e 616d 653c 2f68 323e length name

    │ │ │ +0003b120: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ +0003b130: 5f74 6f72 7265 6e74 5f69 6e66 6f2e 6370 _torrent_info.cp │ │ │ +0003b140: 703a 3438 333c 2f68 343e 3c70 7265 2073 p:483

    <
    │ │ │ +0003b190: 2f74 723e 3c74 7220 7374 796c 653d 2262  /tr>relevance&n
    │ │ │ +0003b1c0: 6273 703b 303c 2f74 643e 3c74 643e 3c61  bsp;0.
    │ │ │ +0003b1f0: 2e2f 7465 7374 2f74 6573 745f 746f 7272  ./test/test_torr
    │ │ │ +0003b200: 656e 745f 696e 666f 2e63 7070 3a34 3834  ent_info.cpp:484
    │ │ │ +0003b210: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6f72  tor
    │ │ │ +0003b220: 7265 6e74 2077 6974 6820 6120 6e6f 6e2d  rent with a non-
    │ │ │ +0003b230: 6469 6374 696f 6e61 7279 2069 6e66 6f2d  dictionary info-
    │ │ │ +0003b240: 7365 6374 696f 6e3c 2f74 643e 3c2f 7472  section

    torrent wit │ │ │ +0003b2a0: 6820 6120 6e6f 6e2d 6469 6374 696f 6e61 h a non-dictiona │ │ │ +0003b2b0: 7279 2069 6e66 6f2d 7365 6374 696f 6e3c ry info-section< │ │ │ +0003b2c0: 2f68 323e 3c68 343e 2e2e 2f74 6573 742f /h2>

    ../test/ │ │ │ +0003b2d0: 7465 7374 5f74 6f72 7265 6e74 5f69 6e66 test_torrent_inf │ │ │ +0003b2e0: 6f2e 6370 703a 3438 343c 2f68 343e 3c70 o.cpp:484

    relevan │ │ │ +0003b360: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../test/test_ │ │ │ +0003b3a0: 746f 7272 656e 745f 696e 666f 2e63 7070 torrent_info.cpp │ │ │ +0003b3b0: 3a34 3835 3c2f 613e 3c2f 7464 3e3c 7464 :485torrents with D │ │ │ +0003b3d0: 4854 206e 6f64 6573 3c2f 7464 3e3c 2f74 HT nodes

    torrents w │ │ │ +0003b430: 6974 6820 4448 5420 6e6f 6465 733c 2f68 ith DHT nodes

    ../test/te │ │ │ +0003b450: 7374 5f74 6f72 7265 6e74 5f69 6e66 6f2e st_torrent_info. │ │ │ +0003b460: 6370 703a 3438 353c 2f68 343e 3c70 7265 cpp:485

    relevance
    │ │ │ +0003b4e0: 266e 6273 703b 303c 2f74 643e 3c74 643e   0
    │ │ │ +0003b4f0: 3c61 2068 7265 663d 226a 6176 6173 6372  ../test/test_to
    │ │ │ +0003b520: 7272 656e 745f 696e 666f 2e63 7070 3a34  rrent_info.cpp:4
    │ │ │ +0003b530: 3836 3c2f 613e 3c2f 7464 3e3c 7464 3e74  86t
    │ │ │ +0003b540: 6f72 7265 6e74 2077 6974 6820 7572 6c2d  orrent with url-
    │ │ │ +0003b550: 6c69 7374 2061 7320 6120 7369 6e67 6c65  list as a single
    │ │ │ +0003b560: 2073 7472 696e 673c 2f74 643e 3c2f 7472   string

    torrent wit │ │ │ +0003b5c0: 6820 7572 6c2d 6c69 7374 2061 7320 6120 h url-list as a │ │ │ +0003b5d0: 7369 6e67 6c65 2073 7472 696e 673c 2f68 single string

    ../test/te │ │ │ +0003b5f0: 7374 5f74 6f72 7265 6e74 5f69 6e66 6f2e st_torrent_info. │ │ │ +0003b600: 6370 703a 3438 363c 2f68 343e 3c70 7265 cpp:486

    relevance
    │ │ │ +0003b680: 266e 6273 703b 303c 2f74 643e 3c74 643e   0
    │ │ │ +0003b690: 3c61 2068 7265 663d 226a 6176 6173 6372  ../test/test_to
    │ │ │ +0003b6c0: 7272 656e 745f 696e 666f 2e63 7070 3a34  rrent_info.cpp:4
    │ │ │ +0003b6d0: 3837 3c2f 613e 3c2f 7464 3e3c 7464 3e74  87t
    │ │ │ +0003b6e0: 6f72 7265 6e74 2077 6974 6820 6874 7470  orrent with http
    │ │ │ +0003b6f0: 2073 6565 6420 6173 2061 2073 696e 676c   seed as a singl
    │ │ │ +0003b700: 6520 7374 7269 6e67 3c2f 7464 3e3c 2f74  e string

    torrent wi │ │ │ +0003b760: 7468 2068 7474 7020 7365 6564 2061 7320 th http seed as │ │ │ +0003b770: 6120 7369 6e67 6c65 2073 7472 696e 673c a single string< │ │ │ +0003b780: 2f68 323e 3c68 343e 2e2e 2f74 6573 742f /h2>

    ../test/ │ │ │ +0003b790: 7465 7374 5f74 6f72 7265 6e74 5f69 6e66 test_torrent_inf │ │ │ +0003b7a0: 6f2e 6370 703a 3438 373c 2f68 343e 3c70 o.cpp:487

    relevan │ │ │ +0003b820: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../test/test_ │ │ │ +0003b860: 746f 7272 656e 745f 696e 666f 2e63 7070 torrent_info.cpp │ │ │ +0003b870: 3a34 3838 3c2f 613e 3c2f 7464 3e3c 7464 :488torrent with a │ │ │ +0003b890: 636f 6d6d 656e 743c 2f74 643e 3c2f 7472 comment

    torrent wit │ │ │ +0003b8f0: 6820 6120 636f 6d6d 656e 743c 2f68 323e h a comment

    │ │ │ +0003b900: 3c68 343e 2e2e 2f74 6573 742f 7465 7374

    ../test/test │ │ │ +0003b910: 5f74 6f72 7265 6e74 5f69 6e66 6f2e 6370 _torrent_info.cp │ │ │ +0003b920: 703a 3438 383c 2f68 343e 3c70 7265 2073 p:488

    <
    │ │ │ +0003b970: 2f74 723e 3c74 7220 7374 796c 653d 2262  /tr>relevance&n
    │ │ │ +0003b9a0: 6273 703b 303c 2f74 643e 3c74 643e 3c61  bsp;0.
    │ │ │ +0003b9d0: 2e2f 7465 7374 2f74 6573 745f 746f 7272  ./test/test_torr
    │ │ │ +0003b9e0: 656e 745f 696e 666f 2e63 7070 3a34 3839  ent_info.cpp:489
    │ │ │ +0003b9f0: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6f72  tor
    │ │ │ +0003ba00: 7265 6e74 2077 6974 6820 616e 2053 534c  rent with an SSL
    │ │ │ +0003ba10: 2063 6572 743c 2f74 643e 3c2f 7472 3e3c   cert<
    │ │ │ +0003ba20: 7472 2069 643d 2231 3436 2220 7374 796c  tr id="146" styl
    │ │ │ +0003ba30: 653d 2264 6973 706c 6179 3a20 6e6f 6e65  e="display: none
    │ │ │ +0003ba40: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c  ;" colspan="3"><
    │ │ │ +0003ba50: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c  td colspan="3"><
    │ │ │ +0003ba60: 6832 3e74 6f72 7265 6e74 2077 6974 6820  h2>torrent with 
    │ │ │ +0003ba70: 616e 2053 534c 2063 6572 743c 2f68 323e  an SSL cert
    │ │ │ +0003ba80: 3c68 343e 2e2e 2f74 6573 742f 7465 7374  

    ../test/test │ │ │ +0003ba90: 5f74 6f72 7265 6e74 5f69 6e66 6f2e 6370 _torrent_info.cp │ │ │ +0003baa0: 703a 3438 393c 2f68 343e 3c70 7265 2073 p:489

    <
    │ │ │ +0003baf0: 2f74 723e 3c74 7220 7374 796c 653d 2262  /tr>relevance&n
    │ │ │ +0003bb20: 6273 703b 303c 2f74 643e 3c74 643e 3c61  bsp;0.
    │ │ │ +0003bb50: 2e2f 7465 7374 2f74 6573 745f 746f 7272  ./test/test_torr
    │ │ │ +0003bb60: 656e 745f 696e 666f 2e63 7070 3a34 3930  ent_info.cpp:490
    │ │ │ +0003bb70: 3c2f 613e 3c2f 7464 3e3c 7464 3e74 6f72  tor
    │ │ │ +0003bb80: 7265 6e74 2077 6974 6820 6174 7472 6962  rent with attrib
    │ │ │ +0003bb90: 7574 6573 2028 6578 6563 7574 6162 6c65  utes (executable
    │ │ │ +0003bba0: 2061 6e64 2068 6964 6465 6e29 3c2f 7464   and hidden)

    torren │ │ │ +0003bc00: 7420 7769 7468 2061 7474 7269 6275 7465 t with attribute │ │ │ +0003bc10: 7320 2865 7865 6375 7461 626c 6520 616e s (executable an │ │ │ +0003bc20: 6420 6869 6464 656e 293c 2f68 323e 3c68 d hidden)

    ../test/test_t │ │ │ +0003bc40: 6f72 7265 6e74 5f69 6e66 6f2e 6370 703a orrent_info.cpp: │ │ │ +0003bc50: 3439 303c 2f68 343e 3c70 7265 2073 7479 490
    < │ │ │ +0003bcc0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +0003bcd0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +0003bd00: 7465 7374 2f74 6573 745f 746f 7272 656e test/test_torren │ │ │ +0003bd10: 745f 696e 666f 2e63 7070 3a34 3931 3c2f t_info.cpp:491torre │ │ │ +0003bd30: 6e74 5f69 6e66 6f20 636f 6e73 7472 7563 nt_info construc │ │ │ +0003bd40: 746f 7220 7468 6174 2074 616b 6573 2061 tor that takes a │ │ │ +0003bd50: 6e20 696e 7661 6c69 6420 6265 6e63 6f64 n invalid bencod │ │ │ +0003bd60: 6564 2062 7566 6665 723c 2f74 643e 3c2f ed buffer

    torrent_i │ │ │ +0003bdc0: 6e66 6f20 636f 6e73 7472 7563 746f 7220 nfo constructor │ │ │ +0003bdd0: 7468 6174 2074 616b 6573 2061 6e20 696e that takes an in │ │ │ +0003bde0: 7661 6c69 6420 6265 6e63 6f64 6564 2062 valid bencoded b │ │ │ +0003bdf0: 7566 6665 723c 2f68 323e 3c68 343e 2e2e uffer

    .. │ │ │ +0003be00: 2f74 6573 742f 7465 7374 5f74 6f72 7265 /test/test_torre │ │ │ +0003be10: 6e74 5f69 6e66 6f2e 6370 703a 3439 313c nt_info.cpp:491< │ │ │ +0003be20: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    r
    │ │ │ +0003be90: 656c 6576 616e 6365 266e 6273 703b 303c  elevance 0<
    │ │ │ +0003bea0: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../test
    │ │ │ +0003bed0: 2f74 6573 745f 746f 7272 656e 745f 696e  /test_torrent_in
    │ │ │ +0003bee0: 666f 2e63 7070 3a34 3932 3c2f 613e 3c2f  fo.cpp:492verify_en
    │ │ │ +0003bf00: 636f 6469 6e67 2077 6974 6820 6120 7374  coding with a st
    │ │ │ +0003bf10: 7269 6e67 2074 6861 7420 7472 6967 6765  ring that trigge
    │ │ │ +0003bf20: 7273 2063 6861 7261 6374 6572 2072 6570  rs character rep
    │ │ │ +0003bf30: 6c61 6365 6d65 6e74 3c2f 7464 3e3c 2f74  lacement

    verify_enc │ │ │ +0003bf90: 6f64 696e 6720 7769 7468 2061 2073 7472 oding with a str │ │ │ +0003bfa0: 696e 6720 7468 6174 2074 7269 6767 6572 ing that trigger │ │ │ +0003bfb0: 7320 6368 6172 6163 7465 7220 7265 706c s character repl │ │ │ +0003bfc0: 6163 656d 656e 743c 2f68 323e 3c68 343e acement

    │ │ │ +0003bfd0: 2e2e 2f74 6573 742f 7465 7374 5f74 6f72 ../test/test_tor │ │ │ +0003bfe0: 7265 6e74 5f69 6e66 6f2e 6370 703a 3439 rent_info.cpp:49 │ │ │ +0003bff0: 323c 2f68 343e 3c70 7265 2073 7479 6c65 2

    │ │ │ +0003c030: 097b 2022 7632 5f70 6965 6365 5f6c 6179  .{ "v2_piece_lay
    │ │ │ +0003c040: 6572 5f69 6e76 616c 6964 5f66 696c 655f  er_invalid_file_
    │ │ │ +0003c050: 6861 7368 2e74 6f72 7265 6e74 222c 2065  hash.torrent", e
    │ │ │ +0003c060: 7272 6f72 733a 3a74 6f72 7265 6e74 5f69  rrors::torrent_i
    │ │ │ +0003c070: 6e76 616c 6964 5f70 6965 6365 5f6c 6179  nvalid_piece_lay
    │ │ │ +0003c080: 6572 7d2c 0a09 7b20 2276 325f 696e 7661  er},..{ "v2_inva
    │ │ │ +0003c090: 6c69 645f 7069 6563 655f 6c61 7965 722e  lid_piece_layer.
    │ │ │ +0003c0a0: 746f 7272 656e 7422 2c20 6572 726f 7273  torrent", errors
    │ │ │ +0003c0b0: 3a3a 746f 7272 656e 745f 696e 7661 6c69  ::torrent_invali
    │ │ │ +0003c0c0: 645f 7069 6563 655f 6c61 7965 727d 2c0a  d_piece_layer},.
    │ │ │ +0003c0d0: 097b 2022 7632 5f69 6e76 616c 6964 5f70  .{ "v2_invalid_p
    │ │ │ +0003c0e0: 6965 6365 5f6c 6179 6572 5f72 6f6f 742e  iece_layer_root.
    │ │ │ +0003c0f0: 746f 7272 656e 7422 2c20 6572 726f 7273  torrent", errors
    │ │ │ +0003c100: 3a3a 746f 7272 656e 745f 696e 7661 6c69  ::torrent_invali
    │ │ │ +0003c110: 645f 7069 6563 655f 6c61 7965 727d 2c0a  d_piece_layer},.
    │ │ │ +0003c120: 097b 2022 7632 5f75 6e6b 6e6f 776e 5f70  .{ "v2_unknown_p
    │ │ │ +0003c130: 6965 6365 5f6c 6179 6572 5f65 6e74 7279  iece_layer_entry
    │ │ │ +0003c140: 2e74 6f72 7265 6e74 222c 2065 7272 6f72  .torrent", error
    │ │ │ +0003c150: 733a 3a74 6f72 7265 6e74 5f69 6e76 616c  s::torrent_inval
    │ │ │ +0003c160: 6964 5f70 6965 6365 5f6c 6179 6572 7d2c  id_piece_layer},
    │ │ │ +0003c170: 0a09 7b20 2276 325f 696e 7661 6c69 645f  ..{ "v2_invalid_
    │ │ │ +0003c180: 7069 6563 655f 6c61 7965 725f 7369 7a65  piece_layer_size
    │ │ │ +0003c190: 2e74 6f72 7265 6e74 222c 2065 7272 6f72  .torrent", error
    │ │ │ +0003c1a0: 733a 3a74 6f72 7265 6e74 5f69 6e76 616c  s::torrent_inval
    │ │ │ +0003c1b0: 6964 5f70 6965 6365 5f6c 6179 6572 7d2c  id_piece_layer},
    │ │ │ +0003c1c0: 0a09 7b20 2276 325f 6261 645f 6669 6c65  ..{ "v2_bad_file
    │ │ │ +0003c1d0: 5f61 6c69 676e 6d65 6e74 2e74 6f72 7265  _alignment.torre
    │ │ │ +0003c1e0: 6e74 222c 2065 7272 6f72 733a 3a74 6f72  nt", errors::tor
    │ │ │ +0003c1f0: 7265 6e74 5f69 6e63 6f6e 7369 7374 656e  rent_inconsisten
    │ │ │ +0003c200: 745f 6669 6c65 737d 2c0a 097b 2022 7632  t_files},..{ "v2
    │ │ │ +0003c210: 5f75 6e6f 7264 6572 6564 5f66 696c 6573  _unordered_files
    │ │ │ +0003c220: 2e74 6f72 7265 6e74 222c 2065 7272 6f72  .torrent", error
    │ │ │ +0003c230: 733a 3a69 6e76 616c 6964 5f62 656e 636f  s::invalid_benco
    │ │ │ +0003c240: 6469 6e67 7d2c 0a09 7b20 2276 325f 6f76  ding},..{ "v2_ov
    │ │ │ +0003c250: 6572 6c6f 6e67 5f69 6e74 6567 6572 2e74  erlong_integer.t
    │ │ │ +0003c260: 6f72 7265 6e74 222c 2065 7272 6f72 733a  orrent", errors:
    │ │ │ +0003c270: 3a69 6e76 616c 6964 5f62 656e 636f 6469  :invalid_bencodi
    │ │ │ +0003c280: 6e67 7d2c 0a09 7b20 2276 325f 6d69 7373  ng},..{ "v2_miss
    │ │ │ +0003c290: 696e 675f 6669 6c65 5f72 6f6f 745f 696e  ing_file_root_in
    │ │ │ +0003c2a0: 7661 6c69 645f 7379 6d6c 696e 6b2e 746f  valid_symlink.to
    │ │ │ +0003c2b0: 7272 656e 7422 2c20 6572 726f 7273 3a3a  rrent", errors::
    │ │ │ +0003c2c0: 746f 7272 656e 745f 6d69 7373 696e 675f  torrent_missing_
    │ │ │ +0003c2d0: 7069 6563 6573 5f72 6f6f 747d 2c0a 097b  pieces_root},..{
    │ │ │ +0003c2e0: 2022 7632 5f6c 6172 6765 5f66 696c 652e   "v2_large_file.
    │ │ │ +0003c2f0: 746f 7272 656e 7422 2c20 6572 726f 7273  torrent", errors
    │ │ │ +0003c300: 3a3a 746f 7272 656e 745f 696e 7661 6c69  ::torrent_invali
    │ │ │ +0003c310: 645f 6c65 6e67 7468 7d2c 0a09 7b20 2276  d_length},..{ "v
    │ │ │ +0003c320: 325f 6c61 7267 655f 6f66 6673 6574 2e74  2_large_offset.t
    │ │ │ +0003c330: 6f72 7265 6e74 222c 2065 7272 6f72 733a  orrent", errors:
    │ │ │ +0003c340: 3a74 6f6f 5f6d 616e 795f 7069 6563 6573  :too_many_pieces
    │ │ │ +0003c350: 5f69 6e5f 746f 7272 656e 747d 2c0a 097b  _in_torrent},..{
    │ │ │ +0003c360: 2022 7632 5f70 6965 6365 5f73 697a 652e   "v2_piece_size.
    │ │ │ +0003c370: 746f 7272 656e 7422 2c20 6572 726f 7273  torrent", errors
    │ │ │ +0003c380: 3a3a 746f 7272 656e 745f 6d69 7373 696e  ::torrent_missin
    │ │ │ +0003c390: 675f 7069 6563 655f 6c65 6e67 7468 7d2c  g_piece_length},
    │ │ │ +0003c3a0: 0a09 7b20 2276 325f 696e 7661 6c69 645f  ..{ "v2_invalid_
    │ │ │ +0003c3b0: 7061 645f 6669 6c65 2e74 6f72 7265 6e74  pad_file.torrent
    │ │ │ +0003c3c0: 222c 2065 7272 6f72 733a 3a74 6f72 7265  ", errors::torre
    │ │ │ +0003c3d0: 6e74 5f69 6e76 616c 6964 5f70 6164 5f66  nt_invalid_pad_f
    │ │ │ +0003c3e0: 696c 657d 2c0a 097b 2022 7632 5f7a 6572  ile},..{ "v2_zer
    │ │ │ +0003c3f0: 6f5f 726f 6f74 2e74 6f72 7265 6e74 222c  o_root.torrent",
    │ │ │ +0003c400: 2065 7272 6f72 733a 3a74 6f72 7265 6e74   errors::torrent
    │ │ │ +0003c410: 5f6d 6973 7369 6e67 5f70 6965 6365 735f  _missing_pieces_
    │ │ │ +0003c420: 726f 6f74 7d2c 0a09 7b20 2276 325f 7a65  root},..{ "v2_ze
    │ │ │ +0003c430: 726f 5f72 6f6f 745f 736d 616c 6c2e 746f  ro_root_small.to
    │ │ │ +0003c440: 7272 656e 7422 2c20 6572 726f 7273 3a3a  rrent", errors::
    │ │ │ +0003c450: 746f 7272 656e 745f 6d69 7373 696e 675f  torrent_missing_
    │ │ │ +0003c460: 7069 6563 6573 5f72 6f6f 747d 2c0a 097b  pieces_root},..{
    │ │ │ +0003c470: 2022 7632 5f65 6d70 7479 5f66 696c 656e   "v2_empty_filen
    │ │ │ +0003c480: 616d 652e 746f 7272 656e 7422 2c20 6572  ame.torrent", er
    │ │ │ +0003c490: 726f 7273 3a3a 746f 7272 656e 745f 6669  rors::torrent_fi
    │ │ │ +0003c4a0: 6c65 5f70 6172 7365 5f66 6169 6c65 647d  le_parse_failed}
    │ │ │ +0003c4b0: 2c0a 7d3b 0a0a 7d20 2f2f 2061 6e6f 6e79  ,.};..} // anony
    │ │ │ +0003c4c0: 6d6f 7573 206e 616d 6573 7061 6365 0a0a  mous namespace..
    │ │ │ +0003c4d0: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .< │ │ │ +0003c500: 2f64 6976 3e54 4f52 5245 4e54 5f54 4553 /div>TORRENT_TES │ │ │ +0003c510: 5428 6164 645f 7472 6163 6b65 7229 0a7b T(add_tracker).{ │ │ │ +0003c520: 0a09 746f 7272 656e 745f 696e 666f 2074 ..torrent_info t │ │ │ +0003c530: 6928 696e 666f 5f68 6173 685f 7428 7368 i(info_hash_t(sh │ │ │ +0003c540: 6131 5f68 6173 6828 2220 2020 2020 2020 a1_hash(" │ │ │ +0003c550: 2020 2020 2020 2020 2020 2020 2229 2929 "))) │ │ │ +0003c560: 3b0a 0954 4553 545f 4551 5541 4c28 7469 ;..TEST_EQUAL(ti │ │ │ +0003c570: 2e74 7261 636b 6572 7328 292e 7369 7a65 .trackers().size │ │ │ +0003c580: 2829 2c20 3029 3b0a 0a09 7469 2e61 6464 (), 0);...ti.add │ │ │ +0003c590: 5f74 7261 636b 6572 2822 6874 7470 3a2f _tracker("http:/ │ │ │ +0003c5a0: 2f74 6573 742e 636f 6d2f 616e 6e6f 756e /test.com/announ │ │ │ +0003c5b0: 6365 2229 3b0a 0954 4553 545f 4551 5541 ce");..TEST_EQUA │ │ │ +0003c5c0: 4c28 7469 2e74 7261 636b 6572 7328 292e L(ti.trackers(). │ │ │ +0003c5d0: 7369 7a65 2829 2c20 3129 3b0a 0a09 616e size(), 1);...an │ │ │ +0003c5e0: 6e6f 756e 6365 5f65 6e74 7279 2061 6520 nounce_entry ae │ │ │ +0003c5f0: 3d20 7469 2e74 7261 636b 6572 7328 295b = ti.trackers()[ │ │ │ +0003c600: 305d 3b0a 0954 4553 545f 4551 5541 4c28 0];..TEST_EQUAL( │ │ │ +0003c610: 6165 2e75 726c 2c20 2268 7474 703a 2f2f ae.url, "http:// │ │ │ +0003c620: 7465 7374 2e63 6f6d 2f61 6e6e 6f75 6e63 test.com/announc │ │ │ +0003c630: 6522 293b 0a0a 0974 692e 636c 6561 725f e");...ti.clear_ │ │ │ +0003c640: 7472 6163 6b65 7273 2829 3b0a 0954 4553 trackers();..TES │ │ │ +0003c650: 545f 4551 5541 4c28 7469 2e74 7261 636b T_EQUAL(ti.track │ │ │ +0003c660: 6572 7328 292e 7369 7a65 2829 2c20 3029 ers().size(), 0) │ │ │ +0003c670: 3b0a 7d0a 0a54 4f52 5245 4e54 5f54 4553 ;.}..TORRENT_TES │ │ │ +0003c680: 5428 7572 6c5f 6c69 7374 5f61 6e64 5f68 T(url_list_and_h │ │ │ +0003c690: 7474 7073 6565 6473 290a 7b0a 0965 6e74 ttpseeds).{..ent │ │ │ +0003c6a0: 7279 2069 6e66 6f3b 0a09 696e 666f 5b22 ry info;..info[" │ │ │ +0003c6b0: 7069 6563 6573 225d 203d 2022 6161 6161 pieces"] = "aaaa │ │ │ +0003c6c0: 6161 6161 6161 6161 6161 6161 6161 6161 aaaaaaaaaaaaaaaa │ │ │ +0003c6d0: 223b 0a09 696e 666f 5b22 6e61 6d65 2e75 ";..info["name.u │ │ │ +0003c6e0: 7466 2d38 225d 203d 2022 7465 7374 3122 tf-8"] = "test1" │ │ │ +0003c6f0: 3b0a 0969 6e66 6f5b 226e 616d 6522 5d20 ;..info["name"] │ │ │ +0003c700: 3d20 2274 6573 745f 5f22 3b0a 0969 6e66 = "test__";..inf │ │ │ +0003c710: 6f5b 2270 6965 6365 206c 656e 6774 6822 o["piece length" │ │ │ +0003c720: 5d20 3d20 3136 202a 2031 3032 343b 0a09 ] = 16 * 1024;.. │ │ │ +0003c730: 696e 666f 5b22 6c65 6e67 7468 225d 203d info["length"] = │ │ │ +0003c740: 2033 3234 353b 0a09 656e 7472 793a 3a6c 3245;..entry::l │ │ │ +0003c750: 6973 745f 7479 7065 206c 3b0a 096c 2e70 ist_type l;..l.p │ │ │ +0003c760: 7573 685f 6261 636b 2865 6e74 7279 2822 ush_back(entry(" │ │ │ +0003c770: 6874 7470 3a2f 2f66 6f6f 2e63 6f6d 2f62 http://foo.com/b │ │ │ +0003c780: 6172 3122 2929 3b0a 096c 2e70 7573 685f ar1"));..l.push_ │ │ │ +0003c790: 6261 636b 2865 6e74 7279 2822 6874 7470 back(entry("http │ │ │ +0003c7a0: 3a2f 2f66 6f6f 2e63 6f6d 2f62 6172 3122 ://foo.com/bar1" │ │ │ +0003c7b0: 2929 3b0a 096c 2e70 7573 685f 6261 636b ));..l.push_back │ │ │ +0003c7c0: 2865 6e74 7279 2822 6874 7470 3a2f 2f66 (entry("http://f │ │ │ +0003c7d0: 6f6f 2e63 6f6d 2f62 6172 3222 2929 3b0a oo.com/bar2"));. │ │ │ +0003c7e0: 0965 6e74 7279 2063 6f6e 7374 2065 286c .entry const e(l │ │ │ +0003c7f0: 293b 0a09 656e 7472 7920 746f 7272 656e );..entry torren │ │ │ +0003c800: 743b 0a09 746f 7272 656e 745b 2275 726c t;..torrent["url │ │ │ +0003c810: 2d6c 6973 7422 5d20 3d20 653b 0a3c 2f70 -list"] = e;.

    re │ │ │ +0003c850: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../test/ │ │ │ +0003c890: 7465 7374 5f75 706e 702e 6370 703a 3135 test_upnp.cpp:15 │ │ │ +0003c8a0: 363c 2f61 3e3c 2f74 643e 3c74 643e 7374 6st │ │ │ +0003c8b0: 6f72 6520 7468 6520 6c6f 6720 616e 6420 ore the log and │ │ │ +0003c8c0: 7665 7269 6679 2074 6861 7420 736f 6d65 verify that some │ │ │ +0003c8d0: 206b 6579 206d 6573 7361 6765 7320 6172 key messages ar │ │ │ +0003c8e0: 6520 7468 6572 653c 2f74 643e 3c2f 7472 e there

    store the l │ │ │ +0003c940: 6f67 2061 6e64 2076 6572 6966 7920 7468 og and verify th │ │ │ +0003c950: 6174 2073 6f6d 6520 6b65 7920 6d65 7373 at some key mess │ │ │ +0003c960: 6167 6573 2061 7265 2074 6865 7265 3c2f ages are there

    ../test/t │ │ │ +0003c980: 6573 745f 7570 6e70 2e63 7070 3a31 3536 est_upnp.cpp:156 │ │ │ +0003c990: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +0003c9d0: 0909 2c20 706f 7274 6d61 705f 7072 6f74  .., portmap_prot
    │ │ │ +0003c9e0: 6f63 6f6c 2063 6f6e 7374 2070 726f 746f  ocol const proto
    │ │ │ +0003c9f0: 636f 6c2c 2065 7272 6f72 5f63 6f64 6520  col, error_code 
    │ │ │ +0003ca00: 636f 6e73 7426 616d 703b 2065 7272 0a09  const& err..
    │ │ │ +0003ca10: 0909 2c20 706f 7274 6d61 705f 7472 616e  .., portmap_tran
    │ │ │ +0003ca20: 7370 6f72 742c 2061 7578 3a3a 6c69 7374  sport, aux::list
    │ │ │ +0003ca30: 656e 5f73 6f63 6b65 745f 6861 6e64 6c65  en_socket_handle
    │ │ │ +0003ca40: 2063 6f6e 7374 2661 6d70 3b29 206f 7665   const&) ove
    │ │ │ +0003ca50: 7272 6964 650a 0909 7b0a 0909 0963 616c  rride...{....cal
    │ │ │ +0003ca60: 6c62 6163 6b5f 696e 666f 2069 6e66 6f20  lback_info info 
    │ │ │ +0003ca70: 3d20 7b6d 6170 7069 6e67 2c20 706f 7274  = {mapping, port
    │ │ │ +0003ca80: 2c20 6572 727d 3b0a 0909 0963 616c 6c62  , err};....callb
    │ │ │ +0003ca90: 6163 6b73 2e70 7573 685f 6261 636b 2869  acks.push_back(i
    │ │ │ +0003caa0: 6e66 6f29 3b0a 0909 0973 7464 3a3a 636f  nfo);....std::co
    │ │ │ +0003cab0: 7574 2026 6c74 3b26 6c74 3b20 226d 6170  ut << "map
    │ │ │ +0003cac0: 7069 6e67 3a20 2220 266c 743b 266c 743b  ping: " <<
    │ │ │ +0003cad0: 2073 7461 7469 635f 6361 7374 266c 743b   static_cast<
    │ │ │ +0003cae0: 696e 7426 6774 3b28 6d61 7070 696e 6729  int>(mapping)
    │ │ │ +0003caf0: 0a09 0909 0926 6c74 3b26 6c74 3b20 222c  .....<< ",
    │ │ │ +0003cb00: 2070 6f72 743a 2022 2026 6c74 3b26 6c74   port: " <<
    │ │ │ +0003cb10: 3b20 706f 7274 2026 6c74 3b26 6c74 3b20  ; port << 
    │ │ │ +0003cb20: 222c 2049 503a 2022 2026 6c74 3b26 6c74  ", IP: " <<
    │ │ │ +0003cb30: 3b20 6970 0a09 0909 0926 6c74 3b26 6c74  ; ip.....<<
    │ │ │ +0003cb40: 3b20 222c 2070 726f 746f 3a20 2220 266c  ; ", proto: " &l
    │ │ │ +0003cb50: 743b 266c 743b 2073 7461 7469 635f 6361  t;< static_ca
    │ │ │ +0003cb60: 7374 266c 743b 696e 7426 6774 3b28 7072  st<int>(pr
    │ │ │ +0003cb70: 6f74 6f63 6f6c 290a 0909 0909 266c 743b  otocol).....<
    │ │ │ +0003cb80: 266c 743b 2022 2c20 6572 726f 723a 205c  < ", error: \
    │ │ │ +0003cb90: 2222 2026 6c74 3b26 6c74 3b20 6572 722e  "" << err.
    │ │ │ +0003cba0: 6d65 7373 6167 6528 2920 266c 743b 266c  message() <&l
    │ │ │ +0003cbb0: 743b 2022 5c22 5c6e 223b 0a09 097d 0a09  t; "\"\n";...}..
    │ │ │ +0003cbc0: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ +0003cbd0: 4449 5341 424c 455f 4c4f 4747 494e 470a  DISABLE_LOGGING.
    │ │ │ +0003cbe0: 0909 626f 6f6c 2073 686f 756c 645f 6c6f  ..bool should_lo
    │ │ │ +0003cbf0: 675f 706f 7274 6d61 7028 706f 7274 6d61  g_portmap(portma
    │ │ │ +0003cc00: 705f 7472 616e 7370 6f72 7429 2063 6f6e  p_transport) con
    │ │ │ +0003cc10: 7374 206f 7665 7272 6964 650a 0909 7b0a  st override...{.
    │ │ │ +0003cc20: 0909 0972 6574 7572 6e20 7472 7565 3b0a  ...return true;.
    │ │ │ +0003cc30: 0909 7d0a 0a09 0976 6f69 6420 6c6f 675f  ..}....void log_
    │ │ │ +0003cc40: 706f 7274 6d61 7028 706f 7274 6d61 705f  portmap(portmap_
    │ │ │ +0003cc50: 7472 616e 7370 6f72 742c 2063 6861 7220  transport, char 
    │ │ │ +0003cc60: 636f 6e73 742a 206d 7367 0a09 0909 2c20  const* msg...., 
    │ │ │ +0003cc70: 6175 783a 3a6c 6973 7465 6e5f 736f 636b  aux::listen_sock
    │ │ │ +0003cc80: 6574 5f68 616e 646c 6520 636f 6e73 7426  et_handle const&
    │ │ │ +0003cc90: 616d 703b 2920 636f 6e73 7420 6f76 6572  amp;) const over
    │ │ │ +0003cca0: 7269 6465 0a09 097b 0a09 0909 7374 643a  ride...{....std:
    │ │ │ +0003ccb0: 3a63 6f75 7420 266c 743b 266c 743b 2022  :cout << "
    │ │ │ +0003ccc0: 5550 6e50 3a20 2220 266c 743b 266c 743b  UPnP: " <<
    │ │ │ +0003ccd0: 206d 7367 2026 6c74 3b26 6c74 3b20 7374   msg << st
    │ │ │ +0003cce0: 643a 3a65 6e64 6c3b 0a3c 6469 7620 7374  d::endl;.
    ..}.
    .#endif..};..ip │ │ │ +0003cd30: 5f69 6e74 6572 6661 6365 2070 6963 6b5f _interface pick_ │ │ │ +0003cd40: 7570 6e70 5f69 6e74 6572 6661 6365 2829 upnp_interface() │ │ │ +0003cd50: 0a7b 0a09 6c74 3a3a 696f 5f63 6f6e 7465 .{..lt::io_conte │ │ │ +0003cd60: 7874 2069 6f73 3b0a 0965 7272 6f72 5f63 xt ios;..error_c │ │ │ +0003cd70: 6f64 6520 6563 3b0a 0973 7464 3a3a 7665 ode ec;..std::ve │ │ │ +0003cd80: 6374 6f72 266c 743b 6970 5f72 6f75 7465 ctor<ip_route │ │ │ +0003cd90: 2667 743b 2063 6f6e 7374 2072 6f75 7465 > const route │ │ │ +0003cda0: 7320 3d20 656e 756d 5f72 6f75 7465 7328 s = enum_routes( │ │ │ +0003cdb0: 696f 732c 2065 6329 3b0a 0969 6620 2865 ios, ec);..if (e │ │ │ +0003cdc0: 6329 0a09 7b0a 0909 7374 643a 3a63 6572 c)..{...std::cer │ │ │ +0003cdd0: 7220 266c 743b 266c 743b 2022 6661 696c r << "fail │ │ │ +0003cde0: 6564 2074 6f20 656e 756d 6572 6174 6520 ed to enumerate │ │ │ +0003cdf0: 726f 7574 6573 3a20 2220 266c 743b 266c routes: " <&l │ │ │ +0003ce00: 743b 2065 632e 6d65 7373 6167 6528 2920 t; ec.message() │ │ │ +0003ce10: 266c 743b 266c 743b 2027 5c6e 273b 0a09 << '\n';.. │ │ │ +0003ce20: 0954 4553 545f 4348 4543 4b28 6661 6c73 .TEST_CHECK(fals │ │ │ +0003ce30: 6529 3b0a 0909 7265 7475 726e 207b 7d3b e);...return {}; │ │ │ +0003ce40: 0a09 7d0a 0973 7464 3a3a 7665 6374 6f72 ..}..std::vector │ │ │ +0003ce50: 266c 743b 6970 5f69 6e74 6572 6661 6365 <ip_interface │ │ │ +0003ce60: 2667 743b 2063 6f6e 7374 2069 6673 203d > const ifs = │ │ │ +0003ce70: 2065 6e75 6d5f 6e65 745f 696e 7465 7266 enum_net_interf │ │ │ +0003ce80: 6163 6573 2869 6f73 2c20 6563 293b 0a09 aces(ios, ec);.. │ │ │ +0003ce90: 6966 2028 6563 290a 097b 0a09 0973 7464 if (ec)..{...std │ │ │ +0003cea0: 3a3a 6365 7272 2026 6c74 3b26 6c74 3b20 ::cerr << │ │ │ +0003ceb0: 2266 6169 6c65 6420 746f 2065 6e75 6d65 "failed to enume │ │ │ +0003cec0: 7261 7465 206e 6574 776f 726b 2069 6e74 rate network int │ │ │ +0003ced0: 6572 6661 6365 733a 2022 2026 6c74 3b26 erfaces: " <& │ │ │ +0003cee0: 6c74 3b20 6563 2e6d 6573 7361 6765 2829 lt; ec.message() │ │ │ +0003cef0: 2026 6c74 3b26 6c74 3b20 275c 6e27 3b0a << '\n';. │ │ │ +0003cf00: 0909 5445 5354 5f43 4845 434b 2866 616c ..TEST_CHECK(fal │ │ │ +0003cf10: 7365 293b 0a09 0972 6574 7572 6e20 7b7d se);...return {} │ │ │ +0003cf20: 3b0a 097d 0a09 696e 7420 6964 7820 3d20 ;..}..int idx = │ │ │ +0003cf30: 303b 0a09 666f 7220 2861 7574 6f20 636f 0;..for (auto co │ │ │ +0003cf40: 6e73 7426 616d 703b 2066 6163 6520 3a20 nst& face : │ │ │ +0003cf50: 6966 7329 0a09 7b0a 0909 6966 2028 2166 ifs)..{...if (!f │ │ │ +0003cf60: 6163 652e 696e 7465 7266 6163 655f 6164 ace.interface_ad │ │ │ +0003cf70: 6472 6573 732e 6973 5f76 3428 2929 2063 dress.is_v4()) c │ │ │ +0003cf80: 6f6e 7469 6e75 653b 0a09 0973 7464 3a3a ontinue;...std:: │ │ │ +0003cf90: 636f 7574 2026 6c74 3b26 6c74 3b20 2220 cout << " │ │ │ +0003cfa0: 2d20 2220 266c 743b 266c 743b 2069 6478 - " << idx │ │ │ +0003cfb0: 0a09 0909 266c 743b 266c 743b 2027 2027 ....<< ' ' │ │ │ +0003cfc0: 2026 6c74 3b26 6c74 3b20 6661 6365 2e69 << face.i │ │ │ +0003cfd0: 6e74 6572 6661 6365 5f61 6464 7265 7373 nterface_address │ │ │ +0003cfe0: 2e74 6f5f 7374 7269 6e67 2829 0a09 0909 .to_string().... │ │ │ +0003cff0: 266c 743b 266c 743b 2027 2027 2026 6c74 << ' ' < │ │ │ +0003d000: 3b26 6c74 3b20 696e 7428 7374 6174 6963 ;< int(static │ │ │ +0003d010: 5f63 6173 7426 6c74 3b73 7464 3a3a 7569 _cast<std::ui │ │ │ +0003d020: 6e74 385f 7426 6774 3b28 6661 6365 2e73 nt8_t>(face.s │ │ │ +0003d030: 7461 7465 2929 0a09 0909 266c 743b 266c tate))....<&l │ │ │ +0003d040: 743b 2027 2027 2026 6c74 3b26 6c74 3b20 t; ' ' << │ │ │ +0003d050: 7374 6174 6963 5f63 6173 7426 6c74 3b73 static_cast<s │ │ │ +0003d060: 7464 3a3a 7569 6e74 3332 5f74 2667 743b td::uint32_t> │ │ │ +0003d070: 2866 6163 652e 666c 6167 7329 0a09 0909 (face.flags).... │ │ │ +0003d080: 266c 743b 266c 743b 2027 2027 2026 6c74 << ' ' < │ │ │ +0003d090: 3b26 6c74 3b20 6661 6365 2e6e 616d 6520 ;< face.name │ │ │ +0003d0a0: 266c 743b 266c 743b 2027 5c6e 273b 0a3c << '\n';.< │ │ │ +0003d0b0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +0003d0c0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +0003d0d0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +0003d0e0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +0003d0f0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../tes │ │ │ +0003d120: 742f 7465 7374 5f74 696d 6573 7461 6d70 t/test_timestamp │ │ │ +0003d130: 5f68 6973 746f 7279 2e63 7070 3a35 343c _history.cpp:54< │ │ │ +0003d140: 2f61 3e3c 2f74 643e 3c74 643e 7465 7374 /a>test │ │ │ +0003d150: 2074 6865 2063 6173 6520 7768 6572 6520 the case where │ │ │ +0003d160: 7765 2068 6176 6520 3e20 3132 3020 7361 we have > 120 sa │ │ │ +0003d170: 6d70 6c65 7320 2861 6e64 2068 6176 6520 mples (and have │ │ │ +0003d180: 7468 6520 6261 7365 2064 656c 6179 2061 the base delay a │ │ │ +0003d190: 6374 7561 6c6c 7920 6265 2075 7064 6174 ctually be updat │ │ │ +0003d1a0: 6564 293c 2f74 643e 3c2f 7472 3e3c 7472 ed)

    test the case w │ │ │ +0003d200: 6865 7265 2077 6520 6861 7665 203e 2031 here we have > 1 │ │ │ +0003d210: 3230 2073 616d 706c 6573 2028 616e 6420 20 samples (and │ │ │ +0003d220: 6861 7665 2074 6865 2062 6173 6520 6465 have the base de │ │ │ +0003d230: 6c61 7920 6163 7475 616c 6c79 2062 6520 lay actually be │ │ │ +0003d240: 7570 6461 7465 6429 3c2f 6832 3e3c 6834 updated)

    ../test/test_ti │ │ │ +0003d260: 6d65 7374 616d 705f 6869 7374 6f72 792e mestamp_history. │ │ │ +0003d270: 6370 703a 3534 3c2f 6834 3e3c 7072 6520 cpp:54

    
    │ │ │ +0003d2c0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22  relevance&
    │ │ │ +0003d2f0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c  nbsp;0<
    │ │ │ +0003d300: 6120 6872 6566 3d22 6a61 7661 7363 7269  a href="javascri
    │ │ │ +0003d310: 7074 3a65 7870 616e 6428 3135 3229 223e  pt:expand(152)">
    │ │ │ +0003d320: 2e2e 2f74 6573 742f 7465 7374 5f74 696d  ../test/test_tim
    │ │ │ +0003d330: 6573 7461 6d70 5f68 6973 746f 7279 2e63  estamp_history.c
    │ │ │ +0003d340: 7070 3a35 353c 2f61 3e3c 2f74 643e 3c74  pp:55
    test the case │ │ │ +0003d360: 7768 6572 6520 6120 7361 6d70 6c65 2069 where a sample i │ │ │ +0003d370: 7320 6c6f 7765 7220 7468 616e 2074 6865 s lower than the │ │ │ +0003d380: 2068 6973 746f 7279 2065 6e74 7279 2062 history entry b │ │ │ +0003d390: 7574 206e 6f74 206c 6f77 6572 2074 6861 ut not lower tha │ │ │ +0003d3a0: 6e20 7468 6520 6261 7365 3c2f 7464 3e3c n the base< │ │ │ +0003d3b0: 2f74 723e 3c74 7220 6964 3d22 3135 3222 /tr>

    test the │ │ │ +0003d400: 2063 6173 6520 7768 6572 6520 6120 7361 case where a sa │ │ │ +0003d410: 6d70 6c65 2069 7320 6c6f 7765 7220 7468 mple is lower th │ │ │ +0003d420: 616e 2074 6865 2068 6973 746f 7279 2065 an the history e │ │ │ +0003d430: 6e74 7279 2062 7574 206e 6f74 206c 6f77 ntry but not low │ │ │ +0003d440: 6572 2074 6861 6e20 7468 6520 6261 7365 er than the base │ │ │ +0003d450: 3c2f 6832 3e3c 6834 3e2e 2e2f 7465 7374

    ../test │ │ │ +0003d460: 2f74 6573 745f 7469 6d65 7374 616d 705f /test_timestamp_ │ │ │ +0003d470: 6869 7374 6f72 792e 6370 703a 3535 3c2f history.cpp:55
    #in
    │ │ │ +0003d4c0: 636c 7564 6520 226c 6962 746f 7272 656e  clude "libtorren
    │ │ │ +0003d4d0: 742f 6175 785f 2f74 696d 6573 7461 6d70  t/aux_/timestamp
    │ │ │ +0003d4e0: 5f68 6973 746f 7279 2e68 7070 220a 0a54  _history.hpp"..T
    │ │ │ +0003d4f0: 4f52 5245 4e54 5f54 4553 5428 7469 6d65  ORRENT_TEST(time
    │ │ │ +0003d500: 7374 616d 705f 6869 7374 6f72 7929 0a7b  stamp_history).{
    │ │ │ +0003d510: 0a09 7573 696e 6720 6e61 6d65 7370 6163  ..using namespac
    │ │ │ +0003d520: 6520 6c74 3b0a 0a09 6175 783a 3a74 696d  e lt;...aux::tim
    │ │ │ +0003d530: 6573 7461 6d70 5f68 6973 746f 7279 2068  estamp_history h
    │ │ │ +0003d540: 3b0a 0954 4553 545f 4551 5541 4c28 682e  ;..TEST_EQUAL(h.
    │ │ │ +0003d550: 6164 645f 7361 6d70 6c65 2830 7833 322c  add_sample(0x32,
    │ │ │ +0003d560: 2066 616c 7365 292c 2030 293b 0a09 5445   false), 0);..TE
    │ │ │ +0003d570: 5354 5f45 5155 414c 2868 2e62 6173 6528  ST_EQUAL(h.base(
    │ │ │ +0003d580: 292c 2030 7833 3229 3b0a 0954 4553 545f  ), 0x32);..TEST_
    │ │ │ +0003d590: 4551 5541 4c28 682e 6164 645f 7361 6d70  EQUAL(h.add_samp
    │ │ │ +0003d5a0: 6c65 2830 7833 332c 2066 616c 7365 292c  le(0x33, false),
    │ │ │ +0003d5b0: 2030 7831 293b 0a09 5445 5354 5f45 5155   0x1);..TEST_EQU
    │ │ │ +0003d5c0: 414c 2868 2e62 6173 6528 292c 2030 7833  AL(h.base(), 0x3
    │ │ │ +0003d5d0: 3229 3b0a 0954 4553 545f 4551 5541 4c28  2);..TEST_EQUAL(
    │ │ │ +0003d5e0: 682e 6164 645f 7361 6d70 6c65 2830 7833  h.add_sample(0x3
    │ │ │ +0003d5f0: 3433 332c 2066 616c 7365 292c 2030 7833  433, false), 0x3
    │ │ │ +0003d600: 3430 3129 3b0a 0954 4553 545f 4551 5541  401);..TEST_EQUA
    │ │ │ +0003d610: 4c28 682e 6261 7365 2829 2c20 3078 3332  L(h.base(), 0x32
    │ │ │ +0003d620: 293b 0a09 5445 5354 5f45 5155 414c 2868  );..TEST_EQUAL(h
    │ │ │ +0003d630: 2e61 6464 5f73 616d 706c 6528 3078 3330  .add_sample(0x30
    │ │ │ +0003d640: 2c20 6661 6c73 6529 2c20 3029 3b0a 0954  , false), 0);..T
    │ │ │ +0003d650: 4553 545f 4551 5541 4c28 682e 6261 7365  EST_EQUAL(h.base
    │ │ │ +0003d660: 2829 2c20 3078 3330 293b 0a0a 092f 2f20  (), 0x30);...// 
    │ │ │ +0003d670: 7465 7374 2074 6861 7420 7772 6170 7069  test that wrappi
    │ │ │ +0003d680: 6e67 206f 6620 7468 6520 7469 6d65 7374  ng of the timest
    │ │ │ +0003d690: 616d 7020 6973 2070 726f 7065 726c 7920  amp is properly 
    │ │ │ +0003d6a0: 6861 6e64 6c65 640a 0968 2e61 6464 5f73  handled..h.add_s
    │ │ │ +0003d6b0: 616d 706c 6528 3078 6666 6666 6666 6633  ample(0xfffffff3
    │ │ │ +0003d6c0: 2c20 6661 6c73 6529 3b0a 0954 4553 545f  , false);..TEST_
    │ │ │ +0003d6d0: 4551 5541 4c28 682e 6261 7365 2829 2c20  EQUAL(h.base(), 
    │ │ │ +0003d6e0: 3078 6666 6666 6666 6633 293b 0a0a 3c64  0xfffffff3);..}..
    │ │ │ 0003d730: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ 0003d760: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ 0003d770: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ 0003d780: 7074 3a65 7870 616e 6428 3135 3329 223e pt:expand(153)"> │ │ │ -0003d790: 2e2e 2f73 7263 2f77 6562 5f63 6f6e 6e65 ../src/web_conne │ │ │ -0003d7a0: 6374 696f 6e5f 6261 7365 2e63 7070 3a37 ction_base.cpp:7 │ │ │ -0003d7b0: 333c 2f61 3e3c 2f74 643e 3c74 643e 696e 3in │ │ │ -0003d7c0: 7472 6f64 7563 6520 6120 7765 622d 7365 troduce a web-se │ │ │ -0003d7d0: 6564 2064 6566 6175 6c74 2063 6c61 7373 ed default class │ │ │ -0003d7e0: 2077 6869 6368 2068 6173 2061 206c 6f77 which has a low │ │ │ -0003d7f0: 2064 6f77 6e6c 6f61 6420 7072 696f 7269 download priori │ │ │ -0003d800: 7479 3c2f 7464 3e3c 2f74 723e 3c74 7220 ty

    │ │ │ -0003d850: 696e 7472 6f64 7563 6520 6120 7765 622d introduce a web- │ │ │ -0003d860: 7365 6564 2064 6566 6175 6c74 2063 6c61 seed default cla │ │ │ -0003d870: 7373 2077 6869 6368 2068 6173 2061 206c ss which has a l │ │ │ -0003d880: 6f77 2064 6f77 6e6c 6f61 6420 7072 696f ow download prio │ │ │ -0003d890: 7269 7479 3c2f 6832 3e3c 6834 3e2e 2e2f rity

    ../ │ │ │ -0003d8a0: 7372 632f 7765 625f 636f 6e6e 6563 7469 src/web_connecti │ │ │ -0003d8b0: 6f6e 5f62 6173 652e 6370 703a 3733 3c2f on_base.cpp:73
    ..:
    │ │ │ -0003d900: 2070 6565 725f 636f 6e6e 6563 7469 6f6e   peer_connection
    │ │ │ -0003d910: 2870 6163 6b29 0a09 092c 206d 5f66 6972  (pack)..., m_fir
    │ │ │ -0003d920: 7374 5f72 6571 7565 7374 2874 7275 6529  st_request(true)
    │ │ │ -0003d930: 0a09 092c 206d 5f73 736c 2866 616c 7365  ..., m_ssl(false
    │ │ │ -0003d940: 290a 0909 2c20 6d5f 6578 7465 726e 616c  )..., m_external
    │ │ │ -0003d950: 5f61 7574 6828 7765 622e 6175 7468 290a  _auth(web.auth).
    │ │ │ -0003d960: 0909 2c20 6d5f 6578 7472 615f 6865 6164  .., m_extra_head
    │ │ │ -0003d970: 6572 7328 7765 622e 6578 7472 615f 6865  ers(web.extra_he
    │ │ │ -0003d980: 6164 6572 7329 0a09 092c 206d 5f70 6172  aders)..., m_par
    │ │ │ -0003d990: 7365 7228 6874 7470 5f70 6172 7365 723a  ser(http_parser:
    │ │ │ -0003d9a0: 3a64 6f6e 745f 7061 7273 655f 6368 756e  :dont_parse_chun
    │ │ │ -0003d9b0: 6b73 290a 0909 2c20 6d5f 626f 6479 5f73  ks)..., m_body_s
    │ │ │ -0003d9c0: 7461 7274 2830 290a 097b 0a09 0954 4f52  tart(0)..{...TOR
    │ │ │ -0003d9d0: 5245 4e54 5f41 5353 4552 5428 2661 6d70  RENT_ASSERT(&
    │ │ │ -0003d9e0: 3b77 6562 2e70 6565 725f 696e 666f 203d  ;web.peer_info =
    │ │ │ -0003d9f0: 3d20 7061 636b 2e70 6565 7269 6e66 6f29  = pack.peerinfo)
    │ │ │ -0003da00: 3b0a 0909 2f2f 2077 6865 6e20 676f 696e  ;...// when goin
    │ │ │ -0003da10: 6720 7468 726f 7567 6820 6120 7072 6f78  g through a prox
    │ │ │ -0003da20: 792c 2077 6520 646f 6e27 7420 6e65 6365  y, we don't nece
    │ │ │ -0003da30: 7373 6172 696c 7920 6861 7665 2061 6e20  ssarily have an 
    │ │ │ -0003da40: 656e 6470 6f69 6e74 2068 6572 652c 0a09  endpoint here,..
    │ │ │ -0003da50: 092f 2f20 7369 6e63 6520 7468 6520 7072  .// since the pr
    │ │ │ -0003da60: 6f78 7920 6d69 6768 7420 6265 2072 6573  oxy might be res
    │ │ │ -0003da70: 6f6c 7669 6e67 2074 6865 2068 6f73 746e  olving the hostn
    │ │ │ -0003da80: 616d 652c 206e 6f74 2075 730a 0909 544f  ame, not us...TO
    │ │ │ -0003da90: 5252 454e 545f 4153 5345 5254 2877 6562  RRENT_ASSERT(web
    │ │ │ -0003daa0: 2e65 6e64 706f 696e 7473 2e65 6d70 7479  .endpoints.empty
    │ │ │ -0003dab0: 2829 207c 7c20 7765 622e 656e 6470 6f69  () || web.endpoi
    │ │ │ -0003dac0: 6e74 732e 6672 6f6e 7428 2920 3d3d 2070  nts.front() == p
    │ │ │ -0003dad0: 6163 6b2e 656e 6470 293b 0a0a 0909 494e  ack.endp);....IN
    │ │ │ -0003dae0: 5641 5249 414e 545f 4348 4543 4b3b 0a0a  VARIANT_CHECK;..
    │ │ │ -0003daf0: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ -0003db00: 2869 735f 6f75 7467 6f69 6e67 2829 293b  (is_outgoing());
    │ │ │ -0003db10: 0a0a 0909 544f 5252 454e 545f 4153 5345  ....TORRENT_ASSE
    │ │ │ -0003db20: 5254 2821 6d5f 746f 7272 656e 742e 6c6f  RT(!m_torrent.lo
    │ │ │ -0003db30: 636b 2829 2d26 6774 3b69 735f 7570 6c6f  ck()->is_uplo
    │ │ │ -0003db40: 6164 5f6f 6e6c 7928 2929 3b0a 0a09 092f  ad_only());..../
    │ │ │ -0003db50: 2f20 7765 206f 6e6c 7920 7761 6e74 206c  / we only want l
    │ │ │ -0003db60: 6566 742d 6f76 6572 2062 616e 6477 6964  eft-over bandwid
    │ │ │ -0003db70: 7468 0a3c 6469 7620 7374 796c 653d 2262  th.
    .
    ..std::s │ │ │ -0003dbb0: 7472 696e 6720 7072 6f74 6f63 6f6c 3b0a tring protocol;. │ │ │ -0003dbc0: 0909 6572 726f 725f 636f 6465 2065 633b ..error_code ec; │ │ │ -0003dbd0: 0a09 0973 7464 3a3a 7469 6528 7072 6f74 ...std::tie(prot │ │ │ -0003dbe0: 6f63 6f6c 2c20 6d5f 6261 7369 635f 6175 ocol, m_basic_au │ │ │ -0003dbf0: 7468 2c20 6d5f 686f 7374 2c20 6d5f 706f th, m_host, m_po │ │ │ -0003dc00: 7274 2c20 6d5f 7061 7468 290a 0909 093d rt, m_path)....= │ │ │ -0003dc10: 2070 6172 7365 5f75 726c 5f63 6f6d 706f parse_url_compo │ │ │ -0003dc20: 6e65 6e74 7328 7765 622e 7572 6c2c 2065 nents(web.url, e │ │ │ -0003dc30: 6329 3b0a 0909 544f 5252 454e 545f 4153 c);...TORRENT_AS │ │ │ -0003dc40: 5345 5254 2821 6563 293b 0a0a 0909 6966 SERT(!ec);....if │ │ │ -0003dc50: 2028 6d5f 706f 7274 203d 3d20 2d31 2026 (m_port == -1 & │ │ │ -0003dc60: 616d 703b 2661 6d70 3b20 7072 6f74 6f63 amp;& protoc │ │ │ -0003dc70: 6f6c 203d 3d20 2268 7474 7022 290a 0909 ol == "http")... │ │ │ -0003dc80: 096d 5f70 6f72 7420 3d20 3830 3b0a 0a23 .m_port = 80;..# │ │ │ -0003dc90: 6966 2054 4f52 5245 4e54 5f55 5345 5f53 if TORRENT_USE_S │ │ │ -0003dca0: 534c 0a09 0969 6620 2870 726f 746f 636f SL...if (protoco │ │ │ -0003dcb0: 6c20 3d3d 2022 6874 7470 7322 290a 0909 l == "https")... │ │ │ -0003dcc0: 7b0a 0909 096d 5f73 736c 203d 2074 7275 {....m_ssl = tru │ │ │ -0003dcd0: 653b 0a09 0909 6966 2028 6d5f 706f 7274 e;....if (m_port │ │ │ -0003dce0: 203d 3d20 2d31 2920 6d5f 706f 7274 203d == -1) m_port = │ │ │ -0003dcf0: 2034 3433 3b0a 0909 7d0a 2365 6e64 6966 443;...}.#endif │ │ │ -0003dd00: 0a0a 0909 6966 2028 216d 5f62 6173 6963 ....if (!m_basic │ │ │ -0003dd10: 5f61 7574 682e 656d 7074 7928 2929 0a09 _auth.empty()).. │ │ │ -0003dd20: 0909 6d5f 6261 7369 635f 6175 7468 203d ..m_basic_auth = │ │ │ -0003dd30: 2062 6173 6536 3465 6e63 6f64 6528 6d5f base64encode(m_ │ │ │ -0003dd40: 6261 7369 635f 6175 7468 293b 0a0a 0909 basic_auth);.... │ │ │ -0003dd50: 6d5f 7365 7276 6572 5f73 7472 696e 6720 m_server_string │ │ │ -0003dd60: 3d20 6d5f 686f 7374 3b0a 0909 6175 783a = m_host;...aux: │ │ │ -0003dd70: 3a76 6572 6966 795f 656e 636f 6469 6e67 :verify_encoding │ │ │ -0003dd80: 286d 5f73 6572 7665 725f 7374 7269 6e67 (m_server_string │ │ │ -0003dd90: 293b 0a09 7d0a 0a09 696e 7420 7765 625f );..}...int web_ │ │ │ -0003dda0: 636f 6e6e 6563 7469 6f6e 5f62 6173 653a connection_base: │ │ │ -0003ddb0: 3a74 696d 656f 7574 2829 2063 6f6e 7374 :timeout() const │ │ │ -0003ddc0: 0a09 7b0a 0909 2f2f 2073 696e 6365 2074 ..{...// since t │ │ │ -0003ddd0: 6869 7320 6973 2061 2077 6562 2073 6565 his is a web see │ │ │ -0003dde0: 642c 2063 6861 6e67 6520 7468 6520 7469 d, change the ti │ │ │ -0003ddf0: 6d65 6f75 740a 0909 2f2f 2061 6363 6f72 meout...// accor │ │ │ -0003de00: 6469 6e67 2074 6f20 7468 6520 7365 7474 ding to the sett │ │ │ -0003de10: 696e 6773 2e0a 0909 7265 7475 726e 206d ings....return m │ │ │ -0003de20: 5f73 6574 7469 6e67 732e 6765 745f 696e _settings.get_in │ │ │ -0003de30: 7428 7365 7474 696e 6773 5f70 6163 6b3a t(settings_pack: │ │ │ -0003de40: 3a75 726c 7365 6564 5f74 696d 656f 7574 :urlseed_timeout │ │ │ -0003de50: 293b 0a09 7d0a 3c2f 7072 653e 3c2f 7464 );..}.
    relevance │ │ │ -0003de90: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -0003dea0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/utp_sock │ │ │ -0003ded0: 6574 5f6d 616e 6167 6572 2e63 7070 3a32 et_manager.cpp:2 │ │ │ -0003dee0: 3034 3c2f 613e 3c2f 7464 3e3c 7464 3e74 04t │ │ │ -0003def0: 6869 7320 7368 6f75 6c64 206e 6f74 2062 his should not b │ │ │ -0003df00: 6520 6865 6170 2061 6c6c 6f63 6174 6564 e heap allocated │ │ │ -0003df10: 2c20 736f 636b 6574 7320 7368 6f75 6c64 , sockets should │ │ │ -0003df20: 2062 6520 6d6f 7661 626c 653c 2f74 643e be movable │ │ │ -0003df30: 3c2f 7472 3e3c 7472 2069 643d 2231 3534

    this sh │ │ │ -0003df80: 6f75 6c64 206e 6f74 2062 6520 6865 6170 ould not be heap │ │ │ -0003df90: 2061 6c6c 6f63 6174 6564 2c20 736f 636b allocated, sock │ │ │ -0003dfa0: 6574 7320 7368 6f75 6c64 2062 6520 6d6f ets should be mo │ │ │ -0003dfb0: 7661 626c 653c 2f68 323e 3c68 343e 2e2e vable

    .. │ │ │ -0003dfc0: 2f73 7263 2f75 7470 5f73 6f63 6b65 745f /src/utp_socket_ │ │ │ -0003dfd0: 6d61 6e61 6765 722e 6370 703a 3230 343c manager.cpp:204< │ │ │ -0003dfe0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ./
    │ │ │ -0003e020: 2f09 0955 5450 5f4c 4f47 5628 2269 6e63  /..UTP_LOGV("inc
    │ │ │ -0003e030: 6f6d 696e 6720 7061 636b 6574 2069 643a  oming packet id:
    │ │ │ -0003e040: 2564 2073 6f75 7263 653a 2573 5c6e 222c  %d source:%s\n",
    │ │ │ -0003e050: 2069 642c 2070 7269 6e74 5f65 6e64 706f   id, print_endpo
    │ │ │ -0003e060: 696e 7428 6570 292e 635f 7374 7228 2929  int(ep).c_str())
    │ │ │ -0003e070: 3b0a 0a09 0969 6620 2821 6d5f 7365 7474  ;....if (!m_sett
    │ │ │ -0003e080: 2e67 6574 5f62 6f6f 6c28 7365 7474 696e  .get_bool(settin
    │ │ │ -0003e090: 6773 5f70 6163 6b3a 3a65 6e61 626c 655f  gs_pack::enable_
    │ │ │ -0003e0a0: 696e 636f 6d69 6e67 5f75 7470 2929 0a09  incoming_utp))..
    │ │ │ -0003e0b0: 0909 7265 7475 726e 2066 616c 7365 3b0a  ..return false;.
    │ │ │ -0003e0c0: 0a09 092f 2f20 6966 206e 6f74 2066 6f75  ...// if not fou
    │ │ │ -0003e0d0: 6e64 2c20 7365 6520 6966 2069 7427 7320  nd, see if it's 
    │ │ │ -0003e0e0: 6120 5359 4e20 7061 636b 6574 2c20 6966  a SYN packet, if
    │ │ │ -0003e0f0: 2069 7420 6973 2c0a 0909 2f2f 2063 7265   it is,...// cre
    │ │ │ -0003e100: 6174 6520 6120 6e65 7720 7574 705f 7374  ate a new utp_st
    │ │ │ -0003e110: 7265 616d 0a09 0969 6620 2870 682d 2667  ream...if (ph-&g
    │ │ │ -0003e120: 743b 6765 745f 7479 7065 2829 203d 3d20  t;get_type() == 
    │ │ │ -0003e130: 5354 5f53 594e 290a 0909 7b0a 0909 092f  ST_SYN)...{..../
    │ │ │ -0003e140: 2f20 706f 7373 6962 6c65 2053 594e 2066  / possible SYN f
    │ │ │ -0003e150: 6c6f 6f64 2e20 4a75 7374 2069 676e 6f72  lood. Just ignor
    │ │ │ -0003e160: 650a 0909 0969 6620 2869 6e74 286d 5f75  e....if (int(m_u
    │ │ │ -0003e170: 7470 5f73 6f63 6b65 7473 2e73 697a 6528  tp_sockets.size(
    │ │ │ -0003e180: 2929 2026 6774 3b20 6d5f 7365 7474 2e67  )) > m_sett.g
    │ │ │ -0003e190: 6574 5f69 6e74 2873 6574 7469 6e67 735f  et_int(settings_
    │ │ │ -0003e1a0: 7061 636b 3a3a 636f 6e6e 6563 7469 6f6e  pack::connection
    │ │ │ -0003e1b0: 735f 6c69 6d69 7429 202a 2032 290a 0909  s_limit) * 2)...
    │ │ │ -0003e1c0: 0909 7265 7475 726e 2066 616c 7365 3b0a  ..return false;.
    │ │ │ -0003e1d0: 0a09 0909 544f 5252 454e 545f 4153 5345  ....TORRENT_ASSE
    │ │ │ -0003e1e0: 5254 286d 5f6e 6577 5f63 6f6e 6e65 6374  RT(m_new_connect
    │ │ │ -0003e1f0: 696f 6e20 3d3d 202d 3129 3b0a 0909 092f  ion == -1);..../
    │ │ │ -0003e200: 2f20 6372 6561 7465 2074 6865 206e 6577  / create the new
    │ │ │ -0003e210: 2073 6f63 6b65 7420 7769 7468 2074 6869   socket with thi
    │ │ │ -0003e220: 7320 4944 0a09 0909 6d5f 6e65 775f 636f  s ID....m_new_co
    │ │ │ -0003e230: 6e6e 6563 7469 6f6e 203d 2069 643b 0a0a  nnection = id;..
    │ │ │ -0003e240: 2f2f 0909 0955 5450 5f4c 4f47 5628 226e  //...UTP_LOGV("n
    │ │ │ -0003e250: 6f74 2066 6f75 6e64 2c20 6e65 7720 636f  ot found, new co
    │ │ │ -0003e260: 6e6e 6563 7469 6f6e 2069 643a 2564 5c6e  nnection id:%d\n
    │ │ │ -0003e270: 222c 206d 5f6e 6577 5f63 6f6e 6e65 6374  ", m_new_connect
    │ │ │ -0003e280: 696f 6e29 3b0a 0a3c 6469 7620 7374 796c  ion);..
    ...aux::soc │ │ │ -0003e2c0: 6b65 745f 7479 7065 2063 2861 7578 3a3a ket_type c(aux:: │ │ │ -0003e2d0: 696e 7374 616e 7469 6174 655f 636f 6e6e instantiate_conn │ │ │ -0003e2e0: 6563 7469 6f6e 286d 5f69 6f73 2c20 6175 ection(m_ios, au │ │ │ -0003e2f0: 783a 3a70 726f 7879 5f73 6574 7469 6e67 x::proxy_setting │ │ │ -0003e300: 7328 292c 206d 5f73 736c 5f63 6f6e 7465 s(), m_ssl_conte │ │ │ -0003e310: 7874 2c20 7468 6973 2c20 7472 7565 2c20 xt, this, true, │ │ │ -0003e320: 6661 6c73 6529 293b 0a3c 2f64 6976 3e0a false));.
    . │ │ │ -0003e330: 0909 0975 7470 5f73 7472 6561 6d2a 2073 ...utp_stream* s │ │ │ -0003e340: 7472 203d 206e 756c 6c70 7472 3b0a 2369 tr = nullptr;.#i │ │ │ -0003e350: 6664 6566 2054 4f52 5245 4e54 5f53 534c fdef TORRENT_SSL │ │ │ -0003e360: 5f50 4545 5253 0a09 0909 6966 2028 6973 _PEERS....if (is │ │ │ -0003e370: 5f73 736c 2863 2929 0a09 0909 0973 7472 _ssl(c)).....str │ │ │ -0003e380: 203d 2026 616d 703b 626f 6f73 743a 3a67 = &boost::g │ │ │ -0003e390: 6574 266c 743b 7373 6c5f 7374 7265 616d et<ssl_stream │ │ │ -0003e3a0: 266c 743b 7574 705f 7374 7265 616d 2667 <utp_stream&g │ │ │ -0003e3b0: 743b 2667 743b 2863 292e 6e65 7874 5f6c t;>(c).next_l │ │ │ -0003e3c0: 6179 6572 2829 3b0a 0909 0965 6c73 650a ayer();....else. │ │ │ -0003e3d0: 2365 6e64 6966 0a09 0909 0973 7472 203d #endif.....str = │ │ │ -0003e3e0: 2062 6f6f 7374 3a3a 6765 7426 6c74 3b75 boost::get<u │ │ │ -0003e3f0: 7470 5f73 7472 6561 6d26 6774 3b28 2661 tp_stream>(&a │ │ │ -0003e400: 6d70 3b63 293b 0a0a 0909 0954 4f52 5245 mp;c);.....TORRE │ │ │ -0003e410: 4e54 5f41 5353 4552 5428 7374 7229 3b0a NT_ASSERT(str);. │ │ │ -0003e420: 0909 0969 6e74 2063 6f6e 7374 206d 7475 ...int const mtu │ │ │ -0003e430: 203d 206d 7475 5f66 6f72 5f64 6573 7428 = mtu_for_dest( │ │ │ -0003e440: 6570 2e61 6464 7265 7373 2829 293b 0a09 ep.address());.. │ │ │ -0003e450: 0909 7374 722d 2667 743b 6765 745f 696d ..str->get_im │ │ │ -0003e460: 706c 2829 2d26 6774 3b69 6e69 745f 6d74 pl()->init_mt │ │ │ -0003e470: 7528 6d74 7529 3b0a 0909 0973 7472 2d26 u(mtu);....str-& │ │ │ -0003e480: 6774 3b67 6574 5f69 6d70 6c28 292d 2667 gt;get_impl()-&g │ │ │ -0003e490: 743b 6d5f 736f 636b 203d 2073 7464 3a3a t;m_sock = std:: │ │ │ -0003e4a0: 6d6f 7665 2873 6f63 6b65 7429 3b0a 0909 move(socket);... │ │ │ -0003e4b0: 0962 6f6f 6c20 636f 6e73 7420 7265 7420 .bool const ret │ │ │ -0003e4c0: 3d20 7374 722d 2667 743b 6765 745f 696d = str->get_im │ │ │ -0003e4d0: 706c 2829 2d26 6774 3b69 6e63 6f6d 696e pl()->incomin │ │ │ -0003e4e0: 675f 7061 636b 6574 2870 2c20 6570 2c20 g_packet(p, ep, │ │ │ -0003e4f0: 7265 6365 6976 655f 7469 6d65 293b 0a09 receive_time);.. │ │ │ -0003e500: 0909 6966 2028 2172 6574 2920 7265 7475 ..if (!ret) retu │ │ │ -0003e510: 726e 2066 616c 7365 3b0a 0909 096d 5f6c rn false;....m_l │ │ │ -0003e520: 6173 745f 736f 636b 6574 203d 2073 7472 ast_socket = str │ │ │ -0003e530: 2d26 6774 3b67 6574 5f69 6d70 6c28 293b ->get_impl(); │ │ │ -0003e540: 0a09 0909 6d5f 6362 2873 7464 3a3a 6d6f ....m_cb(std::mo │ │ │ -0003e550: 7665 2863 2929 3b0a 0909 092f 2f20 7468 ve(c));....// th │ │ │ -0003e560: 6520 636f 6e6e 6563 7469 6f6e 206d 6f73 e connection mos │ │ │ -0003e570: 7420 6c69 6b65 6c79 2063 6861 6e67 6564 t likely changed │ │ │ -0003e580: 2069 7473 2063 6f6e 6e65 6374 696f 6e20 its connection │ │ │ -0003e590: 4944 2068 6572 650a 0909 092f 2f20 7765 ID here....// we │ │ │ -0003e5a0: 206e 6565 6420 746f 206d 6f76 6520 6974 need to move it │ │ │ -0003e5b0: 2074 6f20 7468 6520 636f 7272 6563 7420 to the correct │ │ │ -0003e5c0: 4944 0a09 0909 7265 7475 726e 2074 7275 ID....return tru │ │ │ -0003e5d0: 653b 0a09 097d 0a0a 0909 6966 2028 7068 e;...}....if (ph │ │ │ -0003e5e0: 2d26 6774 3b67 6574 5f74 7970 6528 2920 ->get_type() │ │ │ -0003e5f0: 3d3d 2053 545f 5245 5345 5429 2072 6574 == ST_RESET) ret │ │ │ -0003e600: 7572 6e20 6661 6c73 653b 0a0a 0909 2f2f urn false;....// │ │ │ -0003e610: 2023 6572 726f 7220 7365 6e64 2072 6573 #error send res │ │ │ -0003e620: 6574 0a0a 0909 7265 7475 726e 2066 616c et....return fal │ │ │ -0003e630: 7365 3b0a 097d 0a0a 0976 6f69 6420 7574 se;..}...void ut │ │ │ -0003e640: 705f 736f 636b 6574 5f6d 616e 6167 6572 p_socket_manager │ │ │ -0003e650: 3a3a 7375 6273 6372 6962 655f 7772 6974 ::subscribe_writ │ │ │ -0003e660: 6162 6c65 2875 7470 5f73 6f63 6b65 745f able(utp_socket_ │ │ │ -0003e670: 696d 706c 2a20 7329 0a3c 2f70 7265 3e3c impl* s).
    < │ │ │ -0003e680: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -0003e6b0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -0003e6c0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/ut_me │ │ │ -0003e6f0: 7461 6461 7461 2e63 7070 3a32 3831 3c2f tadata.cpp:281we re │ │ │ -0003e710: 616c 6c79 206e 6565 6420 746f 2069 6e63 ally need to inc │ │ │ -0003e720: 7265 6d65 6e74 2074 6865 2072 6566 636f rement the refco │ │ │ -0003e730: 756e 7465 7220 6f6e 2074 6865 2074 6f72 unter on the tor │ │ │ -0003e740: 7265 6e74 2077 6869 6c65 2074 6869 7320 rent while this │ │ │ -0003e750: 6275 6666 6572 2069 7320 7374 696c 6c20 buffer is still │ │ │ -0003e760: 696e 2074 6865 2070 6565 7227 7320 7365 in the peer's se │ │ │ -0003e770: 6e64 2062 7566 6665 723c 2f74 643e 3c2f nd buffer

    we really │ │ │ -0003e7d0: 206e 6565 6420 746f 2069 6e63 7265 6d65 need to increme │ │ │ -0003e7e0: 6e74 2074 6865 2072 6566 636f 756e 7465 nt the refcounte │ │ │ -0003e7f0: 7220 6f6e 2074 6865 2074 6f72 7265 6e74 r on the torrent │ │ │ -0003e800: 0a77 6869 6c65 2074 6869 7320 6275 6666 .while this buff │ │ │ -0003e810: 6572 2069 7320 7374 696c 6c20 696e 2074 er is still in t │ │ │ -0003e820: 6865 2070 6565 7227 7320 7365 6e64 2062 he peer's send b │ │ │ -0003e830: 7566 6665 723c 2f68 323e 3c68 343e 2e2e uffer

    .. │ │ │ -0003e840: 2f73 7263 2f75 745f 6d65 7461 6461 7461 /src/ut_metadata │ │ │ -0003e850: 2e63 7070 3a32 3831 3c2f 6834 3e3c 7072 .cpp:281

    ....int c │ │ │ -0003e8a0: 6f6e 7374 206f 6666 7365 7420 3d20 7069 onst offset = pi │ │ │ -0003e8b0: 6563 6520 2a20 3136 202a 2031 3032 343b ece * 16 * 1024; │ │ │ -0003e8c0: 0a09 0909 096d 6574 6164 6174 6120 3d20 .....metadata = │ │ │ -0003e8d0: 6d5f 7470 2e6d 6574 6164 6174 6128 292e m_tp.metadata(). │ │ │ -0003e8e0: 6461 7461 2829 202b 206f 6666 7365 743b data() + offset; │ │ │ -0003e8f0: 0a09 0909 096d 6574 6164 6174 615f 7069 .....metadata_pi │ │ │ -0003e900: 6563 655f 7369 7a65 203d 2073 7464 3a3a ece_size = std:: │ │ │ -0003e910: 6d69 6e28 0a09 0909 0909 696e 7428 6d5f min(......int(m_ │ │ │ -0003e920: 7470 2e6d 6574 6164 6174 6128 292e 7369 tp.metadata().si │ │ │ -0003e930: 7a65 2829 2920 2d20 6f66 6673 6574 2c20 ze()) - offset, │ │ │ -0003e940: 3136 202a 2031 3032 3429 3b0a 0909 0909 16 * 1024);..... │ │ │ -0003e950: 544f 5252 454e 545f 4153 5345 5254 286d TORRENT_ASSERT(m │ │ │ -0003e960: 6574 6164 6174 615f 7069 6563 655f 7369 etadata_piece_si │ │ │ -0003e970: 7a65 2026 6774 3b20 3029 3b0a 0909 0909 ze > 0);..... │ │ │ -0003e980: 544f 5252 454e 545f 4153 5345 5254 286f TORRENT_ASSERT(o │ │ │ -0003e990: 6666 7365 7420 2667 743b 3d20 3029 3b0a ffset >= 0);. │ │ │ -0003e9a0: 0909 0909 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ -0003e9b0: 5254 286f 6666 7365 7420 2b20 6d65 7461 RT(offset + meta │ │ │ -0003e9c0: 6461 7461 5f70 6965 6365 5f73 697a 6520 data_piece_size │ │ │ -0003e9d0: 266c 743b 3d20 6d5f 7470 2e6d 6574 6164 <= m_tp.metad │ │ │ -0003e9e0: 6174 6128 292e 7369 7a65 2829 293b 0a09 ata().size());.. │ │ │ -0003e9f0: 0909 7d0a 0a09 0909 6368 6172 206d 7367 ..}.....char msg │ │ │ -0003ea00: 5b32 3030 5d3b 0a09 0909 6368 6172 2a20 [200];....char* │ │ │ -0003ea10: 6865 6164 6572 203d 206d 7367 3b0a 0909 header = msg;... │ │ │ -0003ea20: 0963 6861 722a 2070 203d 2026 616d 703b .char* p = & │ │ │ -0003ea30: 6d73 675b 365d 3b0a 0909 0969 6e74 2063 msg[6];....int c │ │ │ -0003ea40: 6f6e 7374 206c 656e 203d 2062 656e 636f onst len = benco │ │ │ -0003ea50: 6465 2870 2c20 6529 3b0a 0909 0969 6e74 de(p, e);....int │ │ │ -0003ea60: 2063 6f6e 7374 2074 6f74 616c 5f73 697a const total_siz │ │ │ -0003ea70: 6520 3d20 3220 2b20 6c65 6e20 2b20 6d65 e = 2 + len + me │ │ │ -0003ea80: 7461 6461 7461 5f70 6965 6365 5f73 697a tadata_piece_siz │ │ │ -0003ea90: 653b 0a09 0909 6e61 6d65 7370 6163 6520 e;....namespace │ │ │ -0003eaa0: 696f 203d 2061 7578 3b0a 0909 0969 6f3a io = aux;....io: │ │ │ -0003eab0: 3a77 7269 7465 5f75 696e 7433 3228 746f :write_uint32(to │ │ │ -0003eac0: 7461 6c5f 7369 7a65 2c20 6865 6164 6572 tal_size, header │ │ │ -0003ead0: 293b 0a09 0909 696f 3a3a 7772 6974 655f );....io::write_ │ │ │ -0003eae0: 7569 6e74 3828 6274 5f70 6565 725f 636f uint8(bt_peer_co │ │ │ -0003eaf0: 6e6e 6563 7469 6f6e 3a3a 6d73 675f 6578 nnection::msg_ex │ │ │ -0003eb00: 7465 6e64 6564 2c20 6865 6164 6572 293b tended, header); │ │ │ -0003eb10: 0a09 0909 696f 3a3a 7772 6974 655f 7569 ....io::write_ui │ │ │ -0003eb20: 6e74 3828 6d5f 6d65 7373 6167 655f 696e nt8(m_message_in │ │ │ -0003eb30: 6465 782c 2068 6561 6465 7229 3b0a 0a09 dex, header);... │ │ │ -0003eb40: 0909 6d5f 7063 2e73 656e 645f 6275 6666 ..m_pc.send_buff │ │ │ -0003eb50: 6572 287b 6d73 672c 206c 656e 202b 2036 er({msg, len + 6 │ │ │ -0003eb60: 7d29 3b0a 3c64 6976 2073 7479 6c65 3d22 });.
    ...if (metadat │ │ │ -0003eba0: 615f 7069 6563 655f 7369 7a65 290a 3c2f a_piece_size)....{.....m_p │ │ │ -0003ebc0: 632e 6170 7065 6e64 5f63 6f6e 7374 5f73 c.append_const_s │ │ │ -0003ebd0: 656e 645f 6275 6666 6572 280a 0909 0909 end_buffer(..... │ │ │ -0003ebe0: 0973 7061 6e26 6c74 3b63 6861 7226 6774 .span<char> │ │ │ -0003ebf0: 3b28 636f 6e73 745f 6361 7374 266c 743b ;(const_cast< │ │ │ -0003ec00: 6368 6172 2a26 6774 3b28 6d65 7461 6461 char*>(metada │ │ │ -0003ec10: 7461 292c 206d 6574 6164 6174 615f 7069 ta), metadata_pi │ │ │ -0003ec20: 6563 655f 7369 7a65 292c 206d 6574 6164 ece_size), metad │ │ │ -0003ec30: 6174 615f 7069 6563 655f 7369 7a65 293b ata_piece_size); │ │ │ -0003ec40: 0a09 0909 7d0a 0a09 0909 6d5f 7063 2e73 ....}.....m_pc.s │ │ │ -0003ec50: 7461 7473 5f63 6f75 6e74 6572 7328 292e tats_counters(). │ │ │ -0003ec60: 696e 635f 7374 6174 735f 636f 756e 7465 inc_stats_counte │ │ │ -0003ec70: 7228 636f 756e 7465 7273 3a3a 6e75 6d5f r(counters::num_ │ │ │ -0003ec80: 6f75 7467 6f69 6e67 5f65 7874 656e 6465 outgoing_extende │ │ │ -0003ec90: 6429 3b0a 0909 096d 5f70 632e 7374 6174 d);....m_pc.stat │ │ │ -0003eca0: 735f 636f 756e 7465 7273 2829 2e69 6e63 s_counters().inc │ │ │ -0003ecb0: 5f73 7461 7473 5f63 6f75 6e74 6572 2863 _stats_counter(c │ │ │ -0003ecc0: 6f75 6e74 6572 733a 3a6e 756d 5f6f 7574 ounters::num_out │ │ │ -0003ecd0: 676f 696e 675f 6d65 7461 6461 7461 293b going_metadata); │ │ │ -0003ece0: 0a09 097d 0a0a 0909 626f 6f6c 206f 6e5f ...}....bool on_ │ │ │ -0003ecf0: 6578 7465 6e64 6564 2869 6e74 2063 6f6e extended(int con │ │ │ -0003ed00: 7374 206c 656e 6774 680a 0909 092c 2069 st length...., i │ │ │ -0003ed10: 6e74 2063 6f6e 7374 2065 7874 656e 6465 nt const extende │ │ │ -0003ed20: 645f 6d73 672c 2073 7061 6e26 6c74 3b63 d_msg, span<c │ │ │ -0003ed30: 6861 7220 636f 6e73 7426 6774 3b20 626f har const> bo │ │ │ -0003ed40: 6479 2920 6f76 6572 7269 6465 0a09 097b dy) override...{ │ │ │ -0003ed50: 0a09 0909 6966 2028 6578 7465 6e64 6564 ....if (extended │ │ │ -0003ed60: 5f6d 7367 2021 3d20 3229 2072 6574 7572 _msg != 2) retur │ │ │ -0003ed70: 6e20 6661 6c73 653b 0a09 0909 6966 2028 n false;....if ( │ │ │ -0003ed80: 6d5f 6d65 7373 6167 655f 696e 6465 7820 m_message_index │ │ │ -0003ed90: 3d3d 2030 2920 7265 7475 726e 2066 616c == 0) return fal │ │ │ -0003eda0: 7365 3b0a 0a09 0909 6966 2028 6c65 6e67 se;.....if (leng │ │ │ -0003edb0: 7468 2026 6774 3b20 3137 202a 2031 3032 th > 17 * 102 │ │ │ -0003edc0: 3429 0a09 0909 7b0a 2369 666e 6465 6620 4)....{.#ifndef │ │ │ -0003edd0: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -0003ede0: 4c4f 4747 494e 470a 0909 0909 6d5f 7063 LOGGING.....m_pc │ │ │ -0003edf0: 2e70 6565 725f 6c6f 6728 7065 6572 5f6c .peer_log(peer_l │ │ │ -0003ee00: 6f67 5f61 6c65 7274 3a3a 696e 636f 6d69 og_alert::incomi │ │ │ -0003ee10: 6e67 5f6d 6573 7361 6765 2c20 2255 545f ng_message, "UT_ │ │ │ -0003ee20: 4d45 5441 4441 5441 220a 0909 0909 092c METADATA"......, │ │ │ -0003ee30: 2022 7061 636b 6574 2074 6f6f 2062 6967 "packet too big │ │ │ -0003ee40: 2025 6422 2c20 6c65 6e67 7468 293b 0a23 %d", length);.# │ │ │ -0003ee50: 656e 6469 660a 0909 0909 6d5f 7063 2e64 endif.....m_pc.d │ │ │ -0003ee60: 6973 636f 6e6e 6563 7428 6572 726f 7273 isconnect(errors │ │ │ -0003ee70: 3a3a 696e 7661 6c69 645f 6d65 7461 6461 ::invalid_metada │ │ │ -0003ee80: 7461 5f6d 6573 7361 6765 2c20 6f70 6572 ta_message, oper │ │ │ -0003ee90: 6174 696f 6e5f 743a 3a62 6974 746f 7272 ation_t::bittorr │ │ │ -0003eea0: 656e 742c 2070 6565 725f 636f 6e6e 6563 ent, peer_connec │ │ │ -0003eeb0: 7469 6f6e 5f69 6e74 6572 6661 6365 3a3a tion_interface:: │ │ │ -0003eec0: 7065 6572 5f65 7272 6f72 293b 0a09 0909 peer_error);.... │ │ │ -0003eed0: 0972 6574 7572 6e20 7472 7565 3b0a 0909 .return true;... │ │ │ -0003eee0: 097d 0a0a 0909 0969 6620 2821 6d5f 7063 .}.....if (!m_pc │ │ │ -0003eef0: 2e70 6163 6b65 745f 6669 6e69 7368 6564 .packet_finished │ │ │ -0003ef00: 2829 2920 7265 7475 726e 2074 7275 653b ()) return true; │ │ │ -0003ef10: 0a0a 0909 0965 7272 6f72 5f63 6f64 6520 .....error_code │ │ │ -0003ef20: 6563 3b0a 0909 0962 6465 636f 6465 5f6e ec;....bdecode_n │ │ │ -0003ef30: 6f64 6520 6d73 6720 3d20 6264 6563 6f64 ode msg = bdecod │ │ │ -0003ef40: 6528 626f 6479 2c20 6563 293b 0a09 0909 e(body, ec);.... │ │ │ -0003ef50: 6966 2028 6d73 672e 7479 7065 2829 2021 if (msg.type() ! │ │ │ -0003ef60: 3d20 6264 6563 6f64 655f 6e6f 6465 3a3a = bdecode_node:: │ │ │ -0003ef70: 6469 6374 5f74 290a 3c2f 7072 653e 3c2f dict_t).

    relevan │ │ │ -0003efb0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/udp_tr │ │ │ -0003eff0: 6163 6b65 725f 636f 6e6e 6563 7469 6f6e acker_connection │ │ │ -0003f000: 2e63 7070 3a36 3333 3c2f 613e 3c2f 7464 .cpp:633why is this │ │ │ -0003f020: 2061 206c 696e 6b65 6420 6c69 7374 3f3c a linked list?< │ │ │ -0003f030: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    why │ │ │ -0003f080: 2069 7320 7468 6973 2061 206c 696e 6b65 is this a linke │ │ │ -0003f090: 6420 6c69 7374 3f3c 2f68 323e 3c68 343e d list?

    │ │ │ -0003f0a0: 2e2e 2f73 7263 2f75 6470 5f74 7261 636b ../src/udp_track │ │ │ -0003f0b0: 6572 5f63 6f6e 6e65 6374 696f 6e2e 6370 er_connection.cp │ │ │ -0003f0c0: 703a 3633 333c 2f68 343e 3c70 7265 2073 p:633

    ....ipv6_pee
    │ │ │ -0003f110: 725f 656e 7472 7920 657b 7d3b 0a09 0909  r_entry e{};....
    │ │ │ -0003f120: 0973 7464 3a3a 6d65 6d63 7079 2865 2e69  .std::memcpy(e.i
    │ │ │ -0003f130: 702e 6461 7461 2829 2c20 6275 662e 6461  p.data(), buf.da
    │ │ │ -0003f140: 7461 2829 2c20 3136 293b 0a09 0909 0962  ta(), 16);.....b
    │ │ │ -0003f150: 7566 203d 2062 7566 2e73 7562 7370 616e  uf = buf.subspan
    │ │ │ -0003f160: 2831 3629 3b0a 0909 0909 652e 706f 7274  (16);.....e.port
    │ │ │ -0003f170: 203d 2061 7578 3a3a 7265 6164 5f75 696e   = aux::read_uin
    │ │ │ -0003f180: 7431 3628 6275 6629 3b0a 0909 0909 7265  t16(buf);.....re
    │ │ │ -0003f190: 7370 2e70 6565 7273 362e 7075 7368 5f62  sp.peers6.push_b
    │ │ │ -0003f1a0: 6163 6b28 6529 3b0a 0909 097d 0a09 097d  ack(e);....}...}
    │ │ │ -0003f1b0: 0a09 0965 6c73 650a 0909 7b0a 0909 0972  ...else...{....r
    │ │ │ -0003f1c0: 6573 702e 7065 6572 7334 2e72 6573 6572  esp.peers4.reser
    │ │ │ -0003f1d0: 7665 2873 7461 7469 635f 6361 7374 266c  ve(static_cast&l
    │ │ │ -0003f1e0: 743b 7374 643a 3a73 697a 655f 7426 6774  t;std::size_t>
    │ │ │ -0003f1f0: 3b28 6e75 6d5f 7065 6572 7329 293b 0a09  ;(num_peers));..
    │ │ │ -0003f200: 0909 666f 7220 2869 6e74 2069 203d 2030  ..for (int i = 0
    │ │ │ -0003f210: 3b20 6920 266c 743b 206e 756d 5f70 6565  ; i < num_pee
    │ │ │ -0003f220: 7273 3b20 2b2b 6929 0a09 0909 7b0a 0909  rs; ++i)....{...
    │ │ │ -0003f230: 0909 6970 7634 5f70 6565 725f 656e 7472  ..ipv4_peer_entr
    │ │ │ -0003f240: 7920 657b 7d3b 0a09 0909 0973 7464 3a3a  y e{};.....std::
    │ │ │ -0003f250: 6d65 6d63 7079 2865 2e69 702e 6461 7461  memcpy(e.ip.data
    │ │ │ -0003f260: 2829 2c20 6275 662e 6461 7461 2829 2c20  (), buf.data(), 
    │ │ │ -0003f270: 3429 3b0a 0909 0909 6275 6620 3d20 6275  4);.....buf = bu
    │ │ │ -0003f280: 662e 7375 6273 7061 6e28 3429 3b0a 0909  f.subspan(4);...
    │ │ │ -0003f290: 0909 652e 706f 7274 203d 2061 7578 3a3a  ..e.port = aux::
    │ │ │ -0003f2a0: 7265 6164 5f75 696e 7431 3628 6275 6629  read_uint16(buf)
    │ │ │ -0003f2b0: 3b0a 0909 0909 7265 7370 2e70 6565 7273  ;.....resp.peers
    │ │ │ -0003f2c0: 342e 7075 7368 5f62 6163 6b28 6529 3b0a  4.push_back(e);.
    │ │ │ -0003f2d0: 0909 097d 0a09 097d 0a0a 3c64 6976 2073  ...}...}..
    ..std::l │ │ │ -0003f310: 6973 7426 6c74 3b61 6464 7265 7373 2667 ist<address&g │ │ │ -0003f320: 743b 2069 705f 6c69 7374 3b0a 3c2f 6469 t; ip_list;...std::transfo │ │ │ -0003f340: 726d 286d 5f65 6e64 706f 696e 7473 2e62 rm(m_endpoints.b │ │ │ -0003f350: 6567 696e 2829 2c20 6d5f 656e 6470 6f69 egin(), m_endpoi │ │ │ -0003f360: 6e74 732e 656e 6428 292c 2073 7464 3a3a nts.end(), std:: │ │ │ -0003f370: 6261 636b 5f69 6e73 6572 7465 7228 6970 back_inserter(ip │ │ │ -0003f380: 5f6c 6973 7429 0a09 0909 2c20 5b5d 2874 _list)...., [](t │ │ │ -0003f390: 6370 3a3a 656e 6470 6f69 6e74 2063 6f6e cp::endpoint con │ │ │ -0003f3a0: 7374 2661 6d70 3b20 6570 2920 7b20 7265 st& ep) { re │ │ │ -0003f3b0: 7475 726e 2065 702e 6164 6472 6573 7328 turn ep.address( │ │ │ -0003f3c0: 293b 207d 2029 3b0a 0a09 092f 2f20 6162 ); } );....// ab │ │ │ -0003f3d0: 6f75 7420 746f 2072 6570 6f72 7420 7468 out to report th │ │ │ -0003f3e0: 6520 7265 7370 6f6e 7365 2062 656c 6f77 e response below │ │ │ -0003f3f0: 3b20 6d61 726b 2069 7420 6173 206e 6f20 ; mark it as no │ │ │ -0003f400: 6c6f 6e67 6572 2070 656e 6469 6e67 0a09 longer pending.. │ │ │ -0003f410: 092f 2f20 6669 7273 742c 2073 6f20 6120 .// first, so a │ │ │ -0003f420: 6661 696c 2829 2061 6c72 6561 6479 2070 fail() already p │ │ │ -0003f430: 6f73 7465 6420 2865 2e67 2e20 6279 0a09 osted (e.g. by.. │ │ │ -0003f440: 092f 2f20 7472 6163 6b65 725f 6d61 6e61 .// tracker_mana │ │ │ -0003f450: 6765 723a 3a61 626f 7274 5f61 6c6c 5f72 ger::abort_all_r │ │ │ -0003f460: 6571 7565 7374 7328 2920 7261 6369 6e67 equests() racing │ │ │ -0003f470: 2074 6869 7320 7265 7370 6f6e 7365 2920 this response) │ │ │ -0003f480: 6669 6e64 730a 0909 2f2f 206e 6f74 6869 finds...// nothi │ │ │ -0003f490: 6e67 206c 6566 7420 746f 2072 6570 6f72 ng left to repor │ │ │ -0003f4a0: 7420 7768 656e 2069 7420 7275 6e73 2e0a t when it runs.. │ │ │ -0003f4b0: 0909 6d5f 7265 715f 7065 6e64 696e 6720 ..m_req_pending │ │ │ -0003f4c0: 3d20 6661 6c73 653b 0a09 0963 622d 2667 = false;...cb-&g │ │ │ -0003f4d0: 743b 7472 6163 6b65 725f 7265 7370 6f6e t;tracker_respon │ │ │ -0003f4e0: 7365 2874 7261 636b 6572 5f72 6571 2829 se(tracker_req() │ │ │ -0003f4f0: 2c20 6d5f 7461 7267 6574 2e61 6464 7265 , m_target.addre │ │ │ -0003f500: 7373 2829 2c20 6970 5f6c 6973 742c 2072 ss(), ip_list, r │ │ │ -0003f510: 6573 7029 3b0a 0a09 0963 6c6f 7365 2829 esp);....close() │ │ │ -0003f520: 3b0a 0909 7265 7475 726e 2074 7275 653b ;...return true; │ │ │ -0003f530: 0a09 7d0a 0a09 626f 6f6c 2075 6470 5f74 ..}...bool udp_t │ │ │ -0003f540: 7261 636b 6572 5f63 6f6e 6e65 6374 696f racker_connectio │ │ │ -0003f550: 6e3a 3a6f 6e5f 7363 7261 7065 5f72 6573 n::on_scrape_res │ │ │ -0003f560: 706f 6e73 6528 7370 616e 266c 743b 6368 ponse(span<ch │ │ │ -0003f570: 6172 2063 6f6e 7374 2667 743b 2062 7566 ar const> buf │ │ │ -0003f580: 290a 097b 0a09 0972 6573 7461 7274 5f72 )..{...restart_r │ │ │ -0003f590: 6561 645f 7469 6d65 6f75 7428 293b 0a09 ead_timeout();.. │ │ │ -0003f5a0: 0961 7574 6f20 636f 6e73 7420 6163 7469 .auto const acti │ │ │ -0003f5b0: 6f6e 203d 2073 7461 7469 635f 6361 7374 on = static_cast │ │ │ -0003f5c0: 266c 743b 6163 7469 6f6e 5f74 2667 743b <action_t> │ │ │ -0003f5d0: 2861 7578 3a3a 7265 6164 5f69 6e74 3332 (aux::read_int32 │ │ │ -0003f5e0: 2862 7566 2929 3b0a 0909 7374 643a 3a75 (buf));...std::u │ │ │ -0003f5f0: 696e 7433 325f 7420 636f 6e73 7420 7472 int32_t const tr │ │ │ -0003f600: 616e 7361 6374 696f 6e20 3d20 6175 783a ansaction = aux: │ │ │ -0003f610: 3a72 6561 645f 7569 6e74 3332 2862 7566 :read_uint32(buf │ │ │ -0003f620: 293b 0a0a 0909 6966 2028 7472 616e 7361 );....if (transa │ │ │ -0003f630: 6374 696f 6e20 213d 206d 5f74 7261 6e73 ction != m_trans │ │ │ -0003f640: 6163 7469 6f6e 5f69 6429 0a09 097b 0a09 action_id)...{.. │ │ │ -0003f650: 0909 6661 696c 2865 7272 6f72 5f63 6f64 ..fail(error_cod │ │ │ -0003f660: 6528 6572 726f 7273 3a3a 696e 7661 6c69 e(errors::invali │ │ │ -0003f670: 645f 7472 6163 6b65 725f 7472 616e 7361 d_tracker_transa │ │ │ -0003f680: 6374 696f 6e5f 6964 292c 206f 7065 7261 ction_id), opera │ │ │ -0003f690: 7469 6f6e 5f74 3a3a 6269 7474 6f72 7265 tion_t::bittorre │ │ │ -0003f6a0: 6e74 293b 0a09 0909 7265 7475 726e 2066 nt);....return f │ │ │ -0003f6b0: 616c 7365 3b0a 0909 7d0a 0a09 0969 6620 alse;...}....if │ │ │ -0003f6c0: 2861 6374 696f 6e20 3d3d 2061 6374 696f (action == actio │ │ │ -0003f6d0: 6e5f 743a 3a65 7272 6f72 290a 0909 7b0a n_t::error)...{. │ │ │ -0003f6e0: 0909 0966 6169 6c28 6572 726f 725f 636f ...fail(error_co │ │ │ -0003f6f0: 6465 2865 7272 6f72 733a 3a74 7261 636b de(errors::track │ │ │ -0003f700: 6572 5f66 6169 6c75 7265 292c 206f 7065 er_failure), ope │ │ │ -0003f710: 7261 7469 6f6e 5f74 3a3a 6269 7474 6f72 ration_t::bittor │ │ │ -0003f720: 7265 6e74 0a09 0909 092c 2073 7464 3a3a rent....., std:: │ │ │ -0003f730: 7374 7269 6e67 2862 7566 2e64 6174 6128 string(buf.data( │ │ │ -0003f740: 292c 2073 7461 7469 635f 6361 7374 266c ), static_cast&l │ │ │ -0003f750: 743b 7374 643a 3a73 697a 655f 7426 6774 t;std::size_t> │ │ │ -0003f760: 3b28 6275 662e 7369 7a65 2829 2929 2e63 ;(buf.size())).c │ │ │ -0003f770: 5f73 7472 2829 293b 0a3c 2f70 7265 3e3c _str());.
    < │ │ │ -0003f780: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -0003f7b0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -0003f7c0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/udp_s │ │ │ -0003f7f0: 6f63 6b65 742e 6370 703a 3637 303c 2f61 ocket.cpp:670perhap │ │ │ -0003f810: 7320 616e 2061 7474 656d 7074 2073 686f s an attempt sho │ │ │ -0003f820: 756c 6420 6265 206d 6164 6520 746f 2062 uld be made to b │ │ │ -0003f830: 696e 6420 6d5f 736f 636b 7335 5f73 6f63 ind m_socks5_soc │ │ │ -0003f840: 6b20 746f 2074 6865 2064 6576 6963 6520 k to the device │ │ │ -0003f850: 6f66 206d 5f6c 6973 7465 6e5f 736f 636b of m_listen_sock │ │ │ -0003f860: 6574 3c2f 7464 3e3c 2f74 723e 3c74 7220 et

    │ │ │ -0003f8b0: 7065 7268 6170 7320 616e 2061 7474 656d perhaps an attem │ │ │ -0003f8c0: 7074 2073 686f 756c 6420 6265 206d 6164 pt should be mad │ │ │ -0003f8d0: 6520 746f 2062 696e 6420 6d5f 736f 636b e to bind m_sock │ │ │ -0003f8e0: 7335 5f73 6f63 6b20 746f 2074 6865 0a64 s5_sock to the.d │ │ │ -0003f8f0: 6576 6963 6520 6f66 206d 5f6c 6973 7465 evice of m_liste │ │ │ -0003f900: 6e5f 736f 636b 6574 3c2f 6832 3e3c 6834 n_socket

    ../src/udp_sock │ │ │ -0003f920: 6574 2e63 7070 3a36 3730 3c2f 6834 3e3c et.cpp:670

    < │ │ │ -0003f930: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -0003f940: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -0003f950: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -0003f960: 7820 2364 6464 3b22 3e09 6966 2028 6563 x #ddd;">.if (ec │ │ │ -0003f970: 290a 097b 0a09 0969 6620 286d 5f61 6c65 )..{...if (m_ale │ │ │ -0003f980: 7274 732e 7368 6f75 6c64 5f70 6f73 7426 rts.should_post& │ │ │ -0003f990: 6c74 3b73 6f63 6b73 355f 616c 6572 7426 lt;socks5_alert& │ │ │ -0003f9a0: 6774 3b28 2929 0a09 0909 6d5f 616c 6572 gt;())....m_aler │ │ │ -0003f9b0: 7473 2e65 6d70 6c61 6365 5f61 6c65 7274 ts.emplace_alert │ │ │ -0003f9c0: 266c 743b 736f 636b 7335 5f61 6c65 7274 <socks5_alert │ │ │ -0003f9d0: 2667 743b 286d 5f70 726f 7879 5f61 6464 >(m_proxy_add │ │ │ -0003f9e0: 722c 206f 7065 7261 7469 6f6e 5f74 3a3a r, operation_t:: │ │ │ -0003f9f0: 736f 636b 5f6f 7074 696f 6e2c 2065 6329 sock_option, ec) │ │ │ -0003fa00: 3b0a 0909 6563 2e63 6c65 6172 2829 3b0a ;...ec.clear();. │ │ │ -0003fa10: 097d 0a23 656e 6469 660a 2365 6e64 6966 .}.#endif.#endif │ │ │ -0003fa20: 0a0a 0974 6370 3a3a 656e 6470 6f69 6e74 ...tcp::endpoint │ │ │ -0003fa30: 2063 6f6e 7374 2062 696e 645f 6570 286d const bind_ep(m │ │ │ -0003fa40: 5f6c 6973 7465 6e5f 736f 636b 6574 2e67 _listen_socket.g │ │ │ -0003fa50: 6574 5f6c 6f63 616c 5f65 6e64 706f 696e et_local_endpoin │ │ │ -0003fa60: 7428 292e 6164 6472 6573 7328 292c 2030 t().address(), 0 │ │ │ -0003fa70: 293b 0a09 6d5f 736f 636b 7335 5f73 6f63 );..m_socks5_soc │ │ │ -0003fa80: 6b2e 6269 6e64 2862 696e 645f 6570 2c20 k.bind(bind_ep, │ │ │ -0003fa90: 6563 293b 0a09 6966 2028 6563 290a 097b ec);..if (ec)..{ │ │ │ -0003faa0: 0a09 0969 6620 286d 5f61 6c65 7274 732e ...if (m_alerts. │ │ │ -0003fab0: 7368 6f75 6c64 5f70 6f73 7426 6c74 3b73 should_post<s │ │ │ -0003fac0: 6f63 6b73 355f 616c 6572 7426 6774 3b28 ocks5_alert>( │ │ │ -0003fad0: 2929 0a09 0909 6d5f 616c 6572 7473 2e65 ))....m_alerts.e │ │ │ -0003fae0: 6d70 6c61 6365 5f61 6c65 7274 266c 743b mplace_alert< │ │ │ -0003faf0: 736f 636b 7335 5f61 6c65 7274 2667 743b socks5_alert> │ │ │ -0003fb00: 286d 5f70 726f 7879 5f61 6464 722c 206f (m_proxy_addr, o │ │ │ -0003fb10: 7065 7261 7469 6f6e 5f74 3a3a 736f 636b peration_t::sock │ │ │ -0003fb20: 5f62 696e 642c 2065 6329 3b0a 0909 2b2b _bind, ec);...++ │ │ │ -0003fb30: 6d5f 6661 696c 7572 6573 3b0a 0909 7265 m_failures;...re │ │ │ -0003fb40: 7472 795f 636f 6e6e 6563 7469 6f6e 2829 try_connection() │ │ │ -0003fb50: 3b0a 0909 7265 7475 726e 3b0a 097d 0a0a ;...return;..}.. │ │ │ -0003fb60: 3c64 6976 2073 7479 6c65 3d22 6261 636b
    .< │ │ │ -0003fb90: 2f64 6976 3e09 4144 445f 4f55 5453 5441 /div>.ADD_OUTSTA │ │ │ -0003fba0: 4e44 494e 475f 4153 594e 4328 2273 6f63 NDING_ASYNC("soc │ │ │ -0003fbb0: 6b73 353a 3a6f 6e5f 636f 6e6e 6563 7465 ks5::on_connecte │ │ │ -0003fbc0: 6422 293b 0a09 6d5f 736f 636b 7335 5f73 d");..m_socks5_s │ │ │ -0003fbd0: 6f63 6b2e 6173 796e 635f 636f 6e6e 6563 ock.async_connec │ │ │ -0003fbe0: 7428 6d5f 7072 6f78 795f 6164 6472 0a09 t(m_proxy_addr.. │ │ │ -0003fbf0: 092c 2073 7464 3a3a 6269 6e64 2826 616d ., std::bind(&am │ │ │ -0003fc00: 703b 736f 636b 7335 3a3a 6f6e 5f63 6f6e p;socks5::on_con │ │ │ -0003fc10: 6e65 6374 6564 2c20 7365 6c66 2829 2c20 nected, self(), │ │ │ -0003fc20: 5f31 2929 3b0a 0a09 4144 445f 4f55 5453 _1));...ADD_OUTS │ │ │ -0003fc30: 5441 4e44 494e 475f 4153 594e 4328 2273 TANDING_ASYNC("s │ │ │ -0003fc40: 6f63 6b73 353a 3a6f 6e5f 636f 6e6e 6563 ocks5::on_connec │ │ │ -0003fc50: 745f 7469 6d65 6f75 7422 293b 0a09 6d5f t_timeout");..m_ │ │ │ -0003fc60: 7469 6d65 722e 6578 7069 7265 735f 6166 timer.expires_af │ │ │ -0003fc70: 7465 7228 7365 636f 6e64 7328 3130 2929 ter(seconds(10)) │ │ │ -0003fc80: 3b0a 096d 5f74 696d 6572 2e61 7379 6e63 ;..m_timer.async │ │ │ -0003fc90: 5f77 6169 7428 7374 643a 3a62 696e 6428 _wait(std::bind( │ │ │ -0003fca0: 2661 6d70 3b73 6f63 6b73 353a 3a6f 6e5f &socks5::on_ │ │ │ -0003fcb0: 636f 6e6e 6563 745f 7469 6d65 6f75 740a connect_timeout. │ │ │ -0003fcc0: 0909 2c20 7365 6c66 2829 2c20 5f31 2929 .., self(), _1)) │ │ │ -0003fcd0: 3b0a 7d0a 0a76 6f69 6420 736f 636b 7335 ;.}..void socks5 │ │ │ -0003fce0: 3a3a 6f6e 5f63 6f6e 6e65 6374 5f74 696d ::on_connect_tim │ │ │ -0003fcf0: 656f 7574 2865 7272 6f72 5f63 6f64 6520 eout(error_code │ │ │ -0003fd00: 636f 6e73 7426 616d 703b 2065 290a 7b0a const& e).{. │ │ │ -0003fd10: 0943 4f4d 504c 4554 455f 4153 594e 4328 .COMPLETE_ASYNC( │ │ │ -0003fd20: 2273 6f63 6b73 353a 3a6f 6e5f 636f 6e6e "socks5::on_conn │ │ │ -0003fd30: 6563 745f 7469 6d65 6f75 7422 293b 0a0a ect_timeout");.. │ │ │ -0003fd40: 0969 6620 2865 203d 3d20 626f 6f73 743a .if (e == boost: │ │ │ -0003fd50: 3a61 7369 6f3a 3a65 7272 6f72 3a3a 6f70 :asio::error::op │ │ │ -0003fd60: 6572 6174 696f 6e5f 6162 6f72 7465 6429 eration_aborted) │ │ │ -0003fd70: 2072 6574 7572 6e3b 0a0a 0969 6620 286d return;...if (m │ │ │ -0003fd80: 5f61 626f 7274 2920 7265 7475 726e 3b0a _abort) return;. │ │ │ -0003fd90: 0a09 6966 2028 6d5f 616c 6572 7473 2e73 ..if (m_alerts.s │ │ │ -0003fda0: 686f 756c 645f 706f 7374 266c 743b 736f hould_post<so │ │ │ -0003fdb0: 636b 7335 5f61 6c65 7274 2667 743b 2829 cks5_alert>() │ │ │ -0003fdc0: 290a 0909 6d5f 616c 6572 7473 2e65 6d70 )...m_alerts.emp │ │ │ -0003fdd0: 6c61 6365 5f61 6c65 7274 266c 743b 736f lace_alert<so │ │ │ -0003fde0: 636b 7335 5f61 6c65 7274 2667 743b 286d cks5_alert>(m │ │ │ -0003fdf0: 5f70 726f 7879 5f61 6464 722c 206f 7065 _proxy_addr, ope │ │ │ -0003fe00: 7261 7469 6f6e 5f74 3a3a 636f 6e6e 6563 ration_t::connec │ │ │ -0003fe10: 742c 2065 7272 6f72 733a 3a74 696d 6564 t, errors::timed │ │ │ -0003fe20: 5f6f 7574 293b 0a0a 0965 7272 6f72 5f63 _out);...error_c │ │ │ -0003fe30: 6f64 6520 6967 6e6f 7265 3b0a 096d 5f73 ode ignore;..m_s │ │ │ -0003fe40: 6f63 6b73 355f 736f 636b 2e63 6c6f 7365 ocks5_sock.close │ │ │ -0003fe50: 2869 676e 6f72 6529 3b0a 0a09 2b2b 6d5f (ignore);...++m_ │ │ │ -0003fe60: 6661 696c 7572 6573 3b0a 0972 6574 7279 failures;..retry │ │ │ -0003fe70: 5f63 6f6e 6e65 6374 696f 6e28 293b 0a7d _connection();.} │ │ │ -0003fe80: 0a0a 766f 6964 2073 6f63 6b73 353a 3a6f ..void socks5::o │ │ │ -0003fe90: 6e5f 636f 6e6e 6563 7465 6428 6572 726f n_connected(erro │ │ │ -0003fea0: 725f 636f 6465 2063 6f6e 7374 2661 6d70 r_code const& │ │ │ -0003feb0: 3b20 6529 0a7b 0a3c 2f70 7265 3e3c 2f74 ; e).{.
    relevanc │ │ │ -0003fef0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/torrent │ │ │ -0003ff30: 5f70 6565 722e 6370 703a 3139 333c 2f61 _peer.cpp:193how do │ │ │ -0003ff50: 2077 6520 6465 616c 2077 6974 6820 6f75 we deal with ou │ │ │ -0003ff60: 7220 6578 7465 726e 616c 2061 6464 7265 r external addre │ │ │ -0003ff70: 7373 2063 6861 6e67 696e 673f 3c2f 7464 ss changing?

    how do │ │ │ -0003ffd0: 2077 6520 6465 616c 2077 6974 6820 6f75 we deal with ou │ │ │ -0003ffe0: 7220 6578 7465 726e 616c 2061 6464 7265 r external addre │ │ │ -0003fff0: 7373 2063 6861 6e67 696e 673f 3c2f 6832 ss changing?

    ../src/torr │ │ │ -00040010: 656e 745f 7065 6572 2e63 7070 3a31 3933 ent_peer.cpp:193 │ │ │ -00040020: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00040060: 092f 2f20 636f 6e6e 6563 7469 6f6e 732e  .// connections.
    │ │ │ -00040070: 2049 6620 6974 2066 6169 6c73 2c20 7765   If it fails, we
    │ │ │ -00040080: 276c 6c0a 0909 2f2f 2072 6574 7279 2077  'll...// retry w
    │ │ │ -00040090: 6974 6820 656e 6372 7970 7469 6f6e 0a09  ith encryption..
    │ │ │ -000400a0: 092c 2070 655f 7375 7070 6f72 7428 6661  ., pe_support(fa
    │ │ │ -000400b0: 6c73 6529 0a23 656e 6469 660a 0909 2c20  lse).#endif..., 
    │ │ │ -000400c0: 6973 5f76 365f 6164 6472 2866 616c 7365  is_v6_addr(false
    │ │ │ -000400d0: 290a 2369 6620 544f 5252 454e 545f 5553  ).#if TORRENT_US
    │ │ │ -000400e0: 455f 4932 500a 0909 2c20 6973 5f69 3270  E_I2P..., is_i2p
    │ │ │ -000400f0: 5f61 6464 7228 6661 6c73 6529 0a23 656e  _addr(false).#en
    │ │ │ -00040100: 6469 660a 0909 2c20 6f6e 5f70 6172 6f6c  dif..., on_parol
    │ │ │ -00040110: 6528 6661 6c73 6529 0a09 092c 2062 616e  e(false)..., ban
    │ │ │ -00040120: 6e65 6428 6661 6c73 6529 0a09 092c 2073  ned(false)..., s
    │ │ │ -00040130: 7570 706f 7274 735f 7574 7028 7472 7565  upports_utp(true
    │ │ │ -00040140: 2920 2f2f 2061 7373 756d 6520 7065 6572  ) // assume peer
    │ │ │ -00040150: 7320 7375 7070 6f72 7420 7574 700a 0909  s support utp...
    │ │ │ -00040160: 2c20 636f 6e66 6972 6d65 645f 7375 7070  , confirmed_supp
    │ │ │ -00040170: 6f72 7473 5f75 7470 2866 616c 7365 290a  orts_utp(false).
    │ │ │ -00040180: 0909 2c20 7375 7070 6f72 7473 5f68 6f6c  .., supports_hol
    │ │ │ -00040190: 6570 756e 6368 2866 616c 7365 290a 0909  epunch(false)...
    │ │ │ -000401a0: 2c20 7765 625f 7365 6564 2866 616c 7365  , web_seed(false
    │ │ │ -000401b0: 290a 0909 2c20 7072 6f74 6f63 6f6c 5f76  )..., protocol_v
    │ │ │ -000401c0: 3228 6661 6c73 6529 0a09 7b7d 0a0a 0973  2(false)..{}...s
    │ │ │ -000401d0: 7464 3a3a 7569 6e74 3332 5f74 2074 6f72  td::uint32_t tor
    │ │ │ -000401e0: 7265 6e74 5f70 6565 723a 3a72 616e 6b28  rent_peer::rank(
    │ │ │ -000401f0: 6578 7465 726e 616c 5f69 7020 636f 6e73  external_ip cons
    │ │ │ -00040200: 7426 616d 703b 2065 7874 6572 6e61 6c2c  t& external,
    │ │ │ -00040210: 2069 6e74 2065 7874 6572 6e61 6c5f 706f   int external_po
    │ │ │ -00040220: 7274 2920 636f 6e73 740a 097b 0a09 0954  rt) const..{...T
    │ │ │ -00040230: 4f52 5245 4e54 5f41 5353 4552 5428 696e  ORRENT_ASSERT(in
    │ │ │ -00040240: 5f75 7365 293b 0a3c 6469 7620 7374 796c  _use);.
    ..if (peer_ │ │ │ -00040280: 7261 6e6b 203d 3d20 3029 0a3c 2f64 6976 rank == 0).
    ...peer_rank = │ │ │ -000402a0: 7065 6572 5f70 7269 6f72 6974 7928 0a09 peer_priority(.. │ │ │ -000402b0: 0909 0974 6370 3a3a 656e 6470 6f69 6e74 ...tcp::endpoint │ │ │ -000402c0: 2865 7874 6572 6e61 6c2e 6578 7465 726e (external.extern │ │ │ -000402d0: 616c 5f61 6464 7265 7373 2874 6869 732d al_address(this- │ │ │ -000402e0: 2667 743b 6164 6472 6573 7328 2929 2c20 >address()), │ │ │ -000402f0: 7374 643a 3a75 696e 7431 365f 7428 6578 std::uint16_t(ex │ │ │ -00040300: 7465 726e 616c 5f70 6f72 7429 290a 0909 ternal_port))... │ │ │ -00040310: 0909 2c20 7463 703a 3a65 6e64 706f 696e .., tcp::endpoin │ │ │ -00040320: 7428 7468 6973 2d26 6774 3b61 6464 7265 t(this->addre │ │ │ -00040330: 7373 2829 2c20 7468 6973 2d26 6774 3b70 ss(), this->p │ │ │ -00040340: 6f72 7429 293b 0a09 0972 6574 7572 6e20 ort));...return │ │ │ -00040350: 7065 6572 5f72 616e 6b3b 0a09 7d0a 0a23 peer_rank;..}..# │ │ │ -00040360: 6966 6e64 6566 2054 4f52 5245 4e54 5f44 ifndef TORRENT_D │ │ │ -00040370: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09 ISABLE_LOGGING.. │ │ │ -00040380: 7374 643a 3a73 7472 696e 6720 746f 7272 std::string torr │ │ │ -00040390: 656e 745f 7065 6572 3a3a 746f 5f73 7472 ent_peer::to_str │ │ │ -000403a0: 696e 6728 2920 636f 6e73 740a 097b 0a09 ing() const..{.. │ │ │ -000403b0: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -000403c0: 696e 5f75 7365 293b 0a23 6966 2054 4f52 in_use);.#if TOR │ │ │ -000403d0: 5245 4e54 5f55 5345 5f49 3250 0a09 0969 RENT_USE_I2P...i │ │ │ -000403e0: 6620 2869 735f 6932 705f 6164 6472 2920 f (is_i2p_addr) │ │ │ -000403f0: 7265 7475 726e 2064 6573 7428 292e 746f return dest().to │ │ │ -00040400: 5f73 7472 696e 6728 293b 0a23 656e 6469 _string();.#endi │ │ │ -00040410: 6620 2f2f 2054 4f52 5245 4e54 5f55 5345 f // TORRENT_USE │ │ │ -00040420: 5f49 3250 0a09 0972 6574 7572 6e20 6164 _I2P...return ad │ │ │ -00040430: 6472 6573 7328 292e 746f 5f73 7472 696e dress().to_strin │ │ │ -00040440: 6728 293b 0a09 7d0a 2365 6e64 6966 0a0a g();..}.#endif.. │ │ │ -00040450: 0973 7464 3a3a 696e 7436 345f 7420 746f .std::int64_t to │ │ │ -00040460: 7272 656e 745f 7065 6572 3a3a 746f 7461 rrent_peer::tota │ │ │ -00040470: 6c5f 646f 776e 6c6f 6164 2829 2063 6f6e l_download() con │ │ │ -00040480: 7374 0a09 7b0a 0909 544f 5252 454e 545f st..{...TORRENT_ │ │ │ -00040490: 4153 5345 5254 2869 6e5f 7573 6529 3b0a ASSERT(in_use);. │ │ │ -000404a0: 0909 6966 2028 636f 6e6e 6563 7469 6f6e ..if (connection │ │ │ -000404b0: 2021 3d20 6e75 6c6c 7074 7229 0a09 097b != nullptr)...{ │ │ │ -000404c0: 0a09 0909 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ -000404d0: 5254 2870 7265 765f 616d 6f75 6e74 5f64 RT(prev_amount_d │ │ │ -000404e0: 6f77 6e6c 6f61 6420 3d3d 2030 293b 0a09 ownload == 0);.. │ │ │ -000404f0: 0909 7265 7475 726e 2063 6f6e 6e65 6374 ..return connect │ │ │ -00040500: 696f 6e2d 2667 743b 7374 6174 6973 7469 ion->statisti │ │ │ -00040510: 6373 2829 2e74 6f74 616c 5f70 6179 6c6f cs().total_paylo │ │ │ -00040520: 6164 5f64 6f77 6e6c 6f61 6428 293b 0a09 ad_download();.. │ │ │ -00040530: 097d 0a09 0965 6c73 650a 0909 7b0a 0909 .}...else...{... │ │ │ -00040540: 0972 6574 7572 6e20 7374 643a 3a69 6e74 .return std::int │ │ │ -00040550: 3634 5f74 2870 7265 765f 616d 6f75 6e74 64_t(prev_amount │ │ │ -00040560: 5f64 6f77 6e6c 6f61 6429 2026 6c74 3b26 _download) <& │ │ │ -00040570: 6c74 3b20 3130 3b0a 0909 7d0a 097d 0a3c lt; 10;...}..}.< │ │ │ -00040580: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00040590: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -000405a0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -000405b0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -000405c0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -000405f0: 2f74 6f72 7265 6e74 5f69 6e66 6f2e 6370 /torrent_info.cp │ │ │ -00040600: 703a 3930 313c 2f61 3e3c 2f74 643e 3c74 p:901this should be │ │ │ -00040620: 2063 6f6e 7369 6465 7265 6420 6120 6661 considered a fa │ │ │ -00040630: 696c 7572 652c 2061 6e64 2074 6865 202e ilure, and the . │ │ │ -00040640: 746f 7272 656e 7420 6669 6c65 2072 656a torrent file rej │ │ │ -00040650: 6563 7465 643c 2f74 643e 3c2f 7472 3e3c ected< │ │ │ -00040660: 7472 2069 643d 2231 3539 2220 7374 796c tr id="159" styl │ │ │ -00040670: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00040680: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00040690: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -000406a0: 6832 3e74 6869 7320 7368 6f75 6c64 2062 h2>this should b │ │ │ -000406b0: 6520 636f 6e73 6964 6572 6564 2061 2066 e considered a f │ │ │ -000406c0: 6169 6c75 7265 2c20 616e 6420 7468 6520 ailure, and the │ │ │ -000406d0: 2e74 6f72 7265 6e74 2066 696c 650a 7265 .torrent file.re │ │ │ -000406e0: 6a65 6374 6564 3c2f 6832 3e3c 6834 3e2e jected

    . │ │ │ -000406f0: 2e2f 7372 632f 746f 7272 656e 745f 696e ./src/torrent_in │ │ │ -00040700: 666f 2e63 7070 3a39 3031 3c2f 6834 3e3c fo.cpp:901

    < │ │ │ -00040710: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00040720: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00040730: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00040740: 7820 2364 6464 3b22 3e09 0909 7374 643a x #ddd;">...std: │ │ │ -00040750: 3a73 7472 696e 6720 6578 7420 3d20 6578 :string ext = ex │ │ │ -00040760: 7465 6e73 696f 6e28 6669 6c65 6e61 6d65 tension(filename │ │ │ -00040770: 293b 0a09 0909 696e 7420 636e 7420 3d20 );....int cnt = │ │ │ -00040780: 303b 0a09 0909 666f 7220 283b 3b29 0a09 0;....for (;;).. │ │ │ -00040790: 0909 7b0a 0909 0909 2b2b 636e 743b 0a09 ..{.....++cnt;.. │ │ │ -000407a0: 0909 0963 6861 7220 6e65 775f 6578 745b ...char new_ext[ │ │ │ -000407b0: 3530 5d3b 0a09 0909 0973 7464 3a3a 736e 50];.....std::sn │ │ │ -000407c0: 7072 696e 7466 286e 6577 5f65 7874 2c20 printf(new_ext, │ │ │ -000407d0: 7369 7a65 6f66 286e 6577 5f65 7874 292c sizeof(new_ext), │ │ │ -000407e0: 2022 2e25 6425 7322 2c20 636e 742c 2065 ".%d%s", cnt, e │ │ │ -000407f0: 7874 2e63 5f73 7472 2829 293b 0a09 0909 xt.c_str());.... │ │ │ -00040800: 0966 696c 656e 616d 6520 3d20 6261 7365 .filename = base │ │ │ -00040810: 202b 206e 6577 5f65 7874 3b0a 0a09 0909 + new_ext;..... │ │ │ -00040820: 0962 6f6f 7374 3a3a 6372 635f 6f70 7469 .boost::crc_opti │ │ │ -00040830: 6d61 6c26 6c74 3b33 322c 2030 7831 4544 mal<32, 0x1ED │ │ │ -00040840: 4336 4634 312c 2030 7846 4646 4646 4646 C6F41, 0xFFFFFFF │ │ │ -00040850: 462c 2030 7846 4646 4646 4646 462c 2074 F, 0xFFFFFFFF, t │ │ │ -00040860: 7275 652c 2074 7275 6526 6774 3b20 6372 rue, true> cr │ │ │ -00040870: 633b 0a09 0909 0970 726f 6365 7373 5f73 c;.....process_s │ │ │ -00040880: 7472 696e 675f 6c6f 7765 7263 6173 6528 tring_lowercase( │ │ │ -00040890: 6372 632c 2066 696c 656e 616d 6529 3b0a crc, filename);. │ │ │ -000408a0: 0909 0909 7374 643a 3a75 696e 7433 325f ....std::uint32_ │ │ │ -000408b0: 7420 636f 6e73 7420 6e65 775f 6861 7368 t const new_hash │ │ │ -000408c0: 203d 2063 7263 2e63 6865 636b 7375 6d28 = crc.checksum( │ │ │ -000408d0: 293b 0a09 0909 0969 6620 2866 696c 6573 );.....if (files │ │ │ -000408e0: 2e66 696e 6428 6e65 775f 6861 7368 2920 .find(new_hash) │ │ │ -000408f0: 3d3d 2066 696c 6573 2e65 6e64 2829 290a == files.end()). │ │ │ -00040900: 0909 0909 7b0a 0909 0909 0966 696c 6573 ....{......files │ │ │ -00040910: 2e69 6e73 6572 7428 7b6e 6577 5f68 6173 .insert({new_has │ │ │ -00040920: 682c 207b 692c 2030 7d7d 293b 0a09 0909 h, {i, 0}});.... │ │ │ -00040930: 0909 6272 6561 6b3b 0a09 0909 097d 0a09 ..break;.....}.. │ │ │ -00040940: 0909 092b 2b6e 756d 5f63 6f6c 6c69 7369 ...++num_collisi │ │ │ -00040950: 6f6e 733b 0a09 0909 0969 6620 286e 756d ons;.....if (num │ │ │ -00040960: 5f63 6f6c 6c69 7369 6f6e 7320 2667 743b _collisions > │ │ │ -00040970: 2031 3030 290a 0909 0909 7b0a 3c64 6976 100).....{.
    ....}. │ │ │ -000409b0: 3c2f 6469 763e 0909 097d 0a0a 0909 0963
    ...}.....c │ │ │ -000409c0: 6f70 795f 6f6e 5f77 7269 7465 2829 3b0a opy_on_write();. │ │ │ -000409d0: 0909 096d 5f66 696c 6573 2e72 656e 616d ...m_files.renam │ │ │ -000409e0: 655f 6669 6c65 2869 2c20 6669 6c65 6e61 e_file(i, filena │ │ │ -000409f0: 6d65 293b 0a09 097d 0a09 7d0a 0a09 766f me);...}..}...vo │ │ │ -00040a00: 6964 2074 6f72 7265 6e74 5f69 6e66 6f3a id torrent_info: │ │ │ -00040a10: 3a72 656d 6170 5f66 696c 6573 2866 696c :remap_files(fil │ │ │ -00040a20: 655f 7374 6f72 6167 6520 636f 6e73 7426 e_storage const& │ │ │ -00040a30: 616d 703b 2066 290a 097b 0a09 0949 4e56 amp; f)..{...INV │ │ │ -00040a40: 4152 4941 4e54 5f43 4845 434b 3b0a 0a09 ARIANT_CHECK;... │ │ │ -00040a50: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -00040a60: 6973 5f6c 6f61 6465 6428 2929 3b0a 0909 is_loaded());... │ │ │ -00040a70: 2f2f 2074 6865 206e 6577 2073 7065 6369 // the new speci │ │ │ -00040a80: 6669 6564 2066 696c 6520 7374 6f72 6167 fied file storag │ │ │ -00040a90: 6520 6d75 7374 2068 6176 6520 7468 6520 e must have the │ │ │ -00040aa0: 6578 6163 740a 0909 2f2f 2073 616d 6520 exact...// same │ │ │ -00040ab0: 7369 7a65 2061 7320 7468 6520 6375 7272 size as the curr │ │ │ -00040ac0: 656e 7420 6669 6c65 2073 746f 7261 6765 ent file storage │ │ │ -00040ad0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -00040ae0: 5428 6d5f 6669 6c65 732e 746f 7461 6c5f T(m_files.total_ │ │ │ -00040af0: 7369 7a65 2829 203d 3d20 662e 746f 7461 size() == f.tota │ │ │ -00040b00: 6c5f 7369 7a65 2829 293b 0a0a 0909 6966 l_size());....if │ │ │ -00040b10: 2028 6d5f 6669 6c65 732e 746f 7461 6c5f (m_files.total_ │ │ │ -00040b20: 7369 7a65 2829 2021 3d20 662e 746f 7461 size() != f.tota │ │ │ -00040b30: 6c5f 7369 7a65 2829 2920 7265 7475 726e l_size()) return │ │ │ -00040b40: 3b0a 0909 636f 7079 5f6f 6e5f 7772 6974 ;...copy_on_writ │ │ │ -00040b50: 6528 293b 0a09 096d 5f66 696c 6573 203d e();...m_files = │ │ │ -00040b60: 2066 3b0a 0909 6d5f 6669 6c65 732e 7365 f;...m_files.se │ │ │ -00040b70: 745f 6e75 6d5f 7069 6563 6573 286d 5f6f t_num_pieces(m_o │ │ │ -00040b80: 7269 675f 6669 6c65 732d 2667 743b 6e75 rig_files->nu │ │ │ -00040b90: 6d5f 7069 6563 6573 2829 293b 0a09 096d m_pieces());...m │ │ │ -00040ba0: 5f66 696c 6573 2e73 6574 5f70 6965 6365 _files.set_piece │ │ │ -00040bb0: 5f6c 656e 6774 6828 6d5f 6f72 6967 5f66 _length(m_orig_f │ │ │ -00040bc0: 696c 6573 2d26 6774 3b70 6965 6365 5f6c iles->piece_l │ │ │ -00040bd0: 656e 6774 6828 2929 3b0a 097d 0a0a 2369 ength());..}..#i │ │ │ -00040be0: 6620 544f 5252 454e 545f 4142 495f 5645 f TORRENT_ABI_VE │ │ │ -00040bf0: 5253 494f 4e20 3d3d 2031 0a09 2f2f 2073 RSION == 1..// s │ │ │ -00040c00: 7461 6e64 6172 6420 636f 6e73 7472 7563 tandard construc │ │ │ -00040c10: 746f 7220 7468 6174 2070 6172 7365 7320 tor that parses │ │ │ -00040c20: 6120 746f 7272 656e 7420 6669 6c65 0a09 a torrent file.. │ │ │ -00040c30: 746f 7272 656e 745f 696e 666f 3a3a 746f torrent_info::to │ │ │ -00040c40: 7272 656e 745f 696e 666f 2865 6e74 7279 rrent_info(entry │ │ │ -00040c50: 2063 6f6e 7374 2661 6d70 3b20 746f 7272 const& torr │ │ │ -00040c60: 656e 745f 6669 6c65 290a 097b 0a09 0973 ent_file)..{...s │ │ │ -00040c70: 7464 3a3a 7665 6374 6f72 266c 743b 6368 td::vector<ch │ │ │ -00040c80: 6172 2667 743b 2074 6d70 3b0a 0909 7374 ar> tmp;...st │ │ │ -00040c90: 643a 3a62 6163 6b5f 696e 7365 7274 5f69 d::back_insert_i │ │ │ -00040ca0: 7465 7261 746f 7226 6c74 3b73 7464 3a3a terator<std:: │ │ │ -00040cb0: 7665 6374 6f72 266c 743b 6368 6172 2667 vector<char&g │ │ │ -00040cc0: 743b 2667 743b 206f 7574 2874 6d70 293b t;> out(tmp); │ │ │ -00040cd0: 0a09 0962 656e 636f 6465 286f 7574 2c20 ...bencode(out, │ │ │ -00040ce0: 746f 7272 656e 745f 6669 6c65 293b 0a3c torrent_file);.< │ │ │ -00040cf0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00040d00: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00040d10: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -00040d20: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -00040d30: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -00040d60: 2f74 6f72 7265 6e74 5f68 616e 646c 652e /torrent_handle. │ │ │ -00040d70: 6370 703a 3630 343c 2f61 3e3c 2f74 643e cpp:604 │ │ │ -00040d80: 3c74 643e 7375 7070 6f72 7420 6d6f 7669 support movi │ │ │ -00040d90: 6e67 2066 696c 6573 2069 6e74 6f20 7468 ng files into th │ │ │ -00040da0: 6973 2063 616c 6c3c 2f74 643e 3c2f 7472 is call

    support mov │ │ │ -00040e00: 696e 6720 6669 6c65 7320 696e 746f 2074 ing files into t │ │ │ -00040e10: 6869 7320 6361 6c6c 3c2f 6832 3e3c 6834 his call

    ../src/torrent_ │ │ │ -00040e30: 6861 6e64 6c65 2e63 7070 3a36 3034 3c2f handle.cpp:604
    ..a
    │ │ │ -00040e80: 7574 6f20 7265 7470 203d 2026 616d 703b  uto retp = &
    │ │ │ -00040e90: 7072 696f 3b0a 0909 7379 6e63 5f63 616c  prio;...sync_cal
    │ │ │ -00040ea0: 6c28 2661 6d70 3b74 6f72 7265 6e74 3a3a  l(&torrent::
    │ │ │ -00040eb0: 7069 6563 655f 7072 696f 7269 7469 6573  piece_priorities
    │ │ │ -00040ec0: 2c20 7265 7470 293b 0a09 0973 7464 3a3a  , retp);...std::
    │ │ │ -00040ed0: 7665 6374 6f72 266c 743b 696e 7426 6774  vector<int>
    │ │ │ -00040ee0: 3b20 7265 743b 0a09 0972 6574 2e72 6573  ; ret;...ret.res
    │ │ │ -00040ef0: 6572 7665 2870 7269 6f2e 7369 7a65 2829  erve(prio.size()
    │ │ │ -00040f00: 293b 0a09 0966 6f72 2028 6175 746f 2070  );...for (auto p
    │ │ │ -00040f10: 203a 2070 7269 6f29 0a09 0909 7265 742e   : prio)....ret.
    │ │ │ -00040f20: 7075 7368 5f62 6163 6b28 696e 7428 7374  push_back(int(st
    │ │ │ -00040f30: 6174 6963 5f63 6173 7426 6c74 3b73 7464  atic_cast<std
    │ │ │ -00040f40: 3a3a 7569 6e74 385f 7426 6774 3b28 7029  ::uint8_t>(p)
    │ │ │ -00040f50: 2929 3b0a 0909 7265 7475 726e 2072 6574  ));...return ret
    │ │ │ -00040f60: 3b0a 097d 0a23 656e 6469 660a 0a09 766f  ;..}.#endif...vo
    │ │ │ -00040f70: 6964 2074 6f72 7265 6e74 5f68 616e 646c  id torrent_handl
    │ │ │ -00040f80: 653a 3a66 696c 655f 7072 696f 7269 7479  e::file_priority
    │ │ │ -00040f90: 2866 696c 655f 696e 6465 785f 7420 696e  (file_index_t in
    │ │ │ -00040fa0: 6465 782c 2064 6f77 6e6c 6f61 645f 7072  dex, download_pr
    │ │ │ -00040fb0: 696f 7269 7479 5f74 2070 7269 6f72 6974  iority_t priorit
    │ │ │ -00040fc0: 7929 2063 6f6e 7374 0a09 7b0a 0909 6173  y) const..{...as
    │ │ │ -00040fd0: 796e 635f 6361 6c6c 2826 616d 703b 746f  ync_call(&to
    │ │ │ -00040fe0: 7272 656e 743a 3a73 6574 5f66 696c 655f  rrent::set_file_
    │ │ │ -00040ff0: 7072 696f 7269 7479 2c20 696e 6465 782c  priority, index,
    │ │ │ -00041000: 2070 7269 6f72 6974 7929 3b0a 097d 0a0a   priority);..}..
    │ │ │ -00041010: 0964 6f77 6e6c 6f61 645f 7072 696f 7269  .download_priori
    │ │ │ -00041020: 7479 5f74 2074 6f72 7265 6e74 5f68 616e  ty_t torrent_han
    │ │ │ -00041030: 646c 653a 3a66 696c 655f 7072 696f 7269  dle::file_priori
    │ │ │ -00041040: 7479 2866 696c 655f 696e 6465 785f 7420  ty(file_index_t 
    │ │ │ -00041050: 696e 6465 7829 2063 6f6e 7374 0a09 7b0a  index) const..{.
    │ │ │ -00041060: 0909 7265 7475 726e 2073 796e 635f 6361  ..return sync_ca
    │ │ │ -00041070: 6c6c 5f72 6574 266c 743b 646f 776e 6c6f  ll_ret<downlo
    │ │ │ -00041080: 6164 5f70 7269 6f72 6974 795f 7426 6774  ad_priority_t>
    │ │ │ -00041090: 3b28 646f 6e74 5f64 6f77 6e6c 6f61 642c  ;(dont_download,
    │ │ │ -000410a0: 2026 616d 703b 746f 7272 656e 743a 3a66   &torrent::f
    │ │ │ -000410b0: 696c 655f 7072 696f 7269 7479 2c20 696e  ile_priority, in
    │ │ │ -000410c0: 6465 7829 3b0a 097d 0a0a 3c64 6976 2073  dex);..}..
    .void to │ │ │ -00041100: 7272 656e 745f 6861 6e64 6c65 3a3a 7072 rrent_handle::pr │ │ │ -00041110: 696f 7269 7469 7a65 5f66 696c 6573 2873 ioritize_files(s │ │ │ -00041120: 7464 3a3a 7665 6374 6f72 266c 743b 646f td::vector<do │ │ │ -00041130: 776e 6c6f 6164 5f70 7269 6f72 6974 795f wnload_priority_ │ │ │ -00041140: 7426 6774 3b20 636f 6e73 7426 616d 703b t> const& │ │ │ -00041150: 2066 696c 6573 2920 636f 6e73 740a 3c2f files) const..{...async_c │ │ │ -00041170: 616c 6c28 2661 6d70 3b74 6f72 7265 6e74 all(&torrent │ │ │ -00041180: 3a3a 7072 696f 7269 7469 7a65 5f66 696c ::prioritize_fil │ │ │ -00041190: 6573 0a09 0909 2c20 7374 6174 6963 5f63 es...., static_c │ │ │ -000411a0: 6173 7426 6c74 3b61 7578 3a3a 7665 6374 ast<aux::vect │ │ │ -000411b0: 6f72 266c 743b 646f 776e 6c6f 6164 5f70 or<download_p │ │ │ -000411c0: 7269 6f72 6974 795f 742c 2066 696c 655f riority_t, file_ │ │ │ -000411d0: 696e 6465 785f 7426 6774 3b20 636f 6e73 index_t> cons │ │ │ -000411e0: 7426 616d 703b 2667 743b 2866 696c 6573 t&>(files │ │ │ -000411f0: 2929 3b0a 097d 0a0a 0973 7464 3a3a 7665 ));..}...std::ve │ │ │ -00041200: 6374 6f72 266c 743b 646f 776e 6c6f 6164 ctor<download │ │ │ -00041210: 5f70 7269 6f72 6974 795f 7426 6774 3b20 _priority_t> │ │ │ -00041220: 746f 7272 656e 745f 6861 6e64 6c65 3a3a torrent_handle:: │ │ │ -00041230: 6765 745f 6669 6c65 5f70 7269 6f72 6974 get_file_priorit │ │ │ -00041240: 6965 7328 2920 636f 6e73 740a 097b 0a09 ies() const..{.. │ │ │ -00041250: 0961 7578 3a3a 7665 6374 6f72 266c 743b .aux::vector< │ │ │ -00041260: 646f 776e 6c6f 6164 5f70 7269 6f72 6974 download_priorit │ │ │ -00041270: 795f 742c 2066 696c 655f 696e 6465 785f y_t, file_index_ │ │ │ -00041280: 7426 6774 3b20 7265 743b 0a09 0961 7574 t> ret;...aut │ │ │ -00041290: 6f20 7265 7470 203d 2026 616d 703b 7265 o retp = &re │ │ │ -000412a0: 743b 0a09 0973 796e 635f 6361 6c6c 2826 t;...sync_call(& │ │ │ -000412b0: 616d 703b 746f 7272 656e 743a 3a66 696c amp;torrent::fil │ │ │ -000412c0: 655f 7072 696f 7269 7469 6573 2c20 7265 e_priorities, re │ │ │ -000412d0: 7470 293b 0a09 0972 6574 7572 6e20 544f tp);...return TO │ │ │ -000412e0: 5252 454e 545f 5256 4f28 7265 7429 3b0a RRENT_RVO(ret);. │ │ │ -000412f0: 097d 0a0a 2369 6620 544f 5252 454e 545f .}..#if TORRENT_ │ │ │ -00041300: 4142 495f 5645 5253 494f 4e20 3d3d 2031 ABI_VERSION == 1 │ │ │ -00041310: 0a0a 2f2f 203d 3d3d 3d3d 3d3d 3d3d 3d3d ..// =========== │ │ │ -00041320: 3d20 7374 6172 7420 6465 7072 6563 6174 = start deprecat │ │ │ -00041330: 696f 6e20 3d3d 3d3d 3d3d 3d3d 3d3d 3d3d ion ============ │ │ │ -00041340: 3d3d 3d0a 0a09 766f 6964 2074 6f72 7265 ===...void torre │ │ │ -00041350: 6e74 5f68 616e 646c 653a 3a70 7269 6f72 nt_handle::prior │ │ │ -00041360: 6974 697a 655f 6669 6c65 7328 7374 643a itize_files(std: │ │ │ -00041370: 3a76 6563 746f 7226 6c74 3b69 6e74 2667 :vector<int&g │ │ │ -00041380: 743b 2063 6f6e 7374 2661 6d70 3b20 6669 t; const& fi │ │ │ -00041390: 6c65 7329 2063 6f6e 7374 0a09 7b0a 0909 les) const..{... │ │ │ -000413a0: 6175 783a 3a76 6563 746f 7226 6c74 3b64 aux::vector<d │ │ │ -000413b0: 6f77 6e6c 6f61 645f 7072 696f 7269 7479 ownload_priority │ │ │ -000413c0: 5f74 2c20 6669 6c65 5f69 6e64 6578 5f74 _t, file_index_t │ │ │ -000413d0: 2667 743b 2066 696c 655f 7072 696f 3b0a > file_prio;. │ │ │ -000413e0: 0909 6669 6c65 5f70 7269 6f2e 7265 7365 ..file_prio.rese │ │ │ -000413f0: 7276 6528 6669 6c65 732e 7369 7a65 2829 rve(files.size() │ │ │ -00041400: 293b 0a09 0966 6f72 2028 6175 746f 2063 );...for (auto c │ │ │ -00041410: 6f6e 7374 2070 203a 2066 696c 6573 2920 onst p : files) │ │ │ -00041420: 7b0a 0909 0966 696c 655f 7072 696f 2e70 {....file_prio.p │ │ │ -00041430: 7573 685f 6261 636b 2864 6f77 6e6c 6f61 ush_back(downloa │ │ │ -00041440: 645f 7072 696f 7269 7479 5f74 2873 7461 d_priority_t(sta │ │ │ -00041450: 7469 635f 6361 7374 266c 743b 7374 643a tic_cast<std: │ │ │ -00041460: 3a75 696e 7438 5f74 2667 743b 2870 2929 :uint8_t>(p)) │ │ │ -00041470: 293b 0a09 097d 0a09 0961 7379 6e63 5f63 );...}...async_c │ │ │ -00041480: 616c 6c28 2661 6d70 3b74 6f72 7265 6e74 all(&torrent │ │ │ -00041490: 3a3a 7072 696f 7269 7469 7a65 5f66 696c ::prioritize_fil │ │ │ -000414a0: 6573 2c20 6669 6c65 5f70 7269 6f29 3b0a es, file_prio);. │ │ │ -000414b0: 097d 0a0a 0973 7464 3a3a 7665 6374 6f72 .}...std::vector │ │ │ -000414c0: 266c 743b 696e 7426 6774 3b20 746f 7272 <int> torr │ │ │ -000414d0: 656e 745f 6861 6e64 6c65 3a3a 6669 6c65 ent_handle::file │ │ │ -000414e0: 5f70 7269 6f72 6974 6965 7328 2920 636f _priorities() co │ │ │ -000414f0: 6e73 740a 097b 0a09 0961 7578 3a3a 7665 nst..{...aux::ve │ │ │ -00041500: 6374 6f72 266c 743b 646f 776e 6c6f 6164 ctor<download │ │ │ -00041510: 5f70 7269 6f72 6974 795f 742c 2066 696c _priority_t, fil │ │ │ -00041520: 655f 696e 6465 785f 7426 6774 3b20 7072 e_index_t> pr │ │ │ -00041530: 696f 3b0a 3c2f 7072 653e 3c2f 7464 3e3c io;.
    < │ │ │ -00041540: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00041570: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -000415a0: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ -000415b0: 703a 3230 3337 3c2f 613e 3c2f 7464 3e3c p:2037< │ │ │ -000415c0: 7464 3e74 6869 7320 636f 756c 6420 6265 td>this could be │ │ │ -000415d0: 206f 7074 696d 697a 6564 2062 7920 6c6f optimized by lo │ │ │ -000415e0: 6f6b 696e 6720 7570 2077 6869 6368 2066 oking up which f │ │ │ -000415f0: 696c 6573 2061 7265 2063 6f6d 706c 6574 iles are complet │ │ │ -00041600: 6520 616e 6420 6a75 7374 206c 6f6f 6b20 e and just look │ │ │ -00041610: 6174 2074 686f 7365 3c2f 7464 3e3c 2f74 at those

    this could │ │ │ -00041670: 2062 6520 6f70 7469 6d69 7a65 6420 6279 be optimized by │ │ │ -00041680: 206c 6f6f 6b69 6e67 2075 7020 7768 6963 looking up whic │ │ │ -00041690: 6820 6669 6c65 7320 6172 650a 636f 6d70 h files are.comp │ │ │ -000416a0: 6c65 7465 2061 6e64 206a 7573 7420 6c6f lete and just lo │ │ │ -000416b0: 6f6b 2061 7420 7468 6f73 653c 2f68 323e ok at those

    │ │ │ -000416c0: 3c68 343e 2e2e 2f73 7263 2f74 6f72 7265

    ../src/torre │ │ │ -000416d0: 6e74 2e63 7070 3a32 3033 373c 2f68 343e nt.cpp:2037

    │ │ │ -000416e0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    //....
    │ │ │ -00041720: 544f 5252 454e 545f 4153 5345 5254 2870  TORRENT_ASSERT(p
    │ │ │ -00041730: 6963 6b65 7228 292e 6861 7665 5f70 6965  icker().have_pie
    │ │ │ -00041740: 6365 2869 2929 3b0a 0909 0909 7765 5f68  ce(i));.....we_h
    │ │ │ -00041750: 6176 6528 6929 3b0a 0909 097d 0a09 097d  ave(i);....}...}
    │ │ │ -00041760: 0a0a 0909 7365 745f 7374 6174 6528 746f  ....set_state(to
    │ │ │ -00041770: 7272 656e 745f 7374 6174 7573 3a3a 6368  rrent_status::ch
    │ │ │ -00041780: 6563 6b69 6e67 5f72 6573 756d 655f 6461  ecking_resume_da
    │ │ │ -00041790: 7461 293b 0a0a 0909 6175 783a 3a76 6563  ta);....aux::vec
    │ │ │ -000417a0: 746f 7226 6c74 3b73 7464 3a3a 7374 7269  tor<std::stri
    │ │ │ -000417b0: 6e67 2c20 6669 6c65 5f69 6e64 6578 5f74  ng, file_index_t
    │ │ │ -000417c0: 2667 743b 206c 696e 6b73 3b0a 2369 666e  > links;.#ifn
    │ │ │ -000417d0: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ -000417e0: 424c 455f 4d55 5441 424c 455f 544f 5252  BLE_MUTABLE_TORR
    │ │ │ -000417f0: 454e 5453 0a09 0969 6620 2821 6d5f 746f  ENTS...if (!m_to
    │ │ │ -00041800: 7272 656e 745f 6669 6c65 2d26 6774 3b73  rrent_file->s
    │ │ │ -00041810: 696d 696c 6172 5f74 6f72 7265 6e74 7328  imilar_torrents(
    │ │ │ -00041820: 292e 656d 7074 7928 290a 0909 097c 7c20  ).empty()....|| 
    │ │ │ -00041830: 216d 5f74 6f72 7265 6e74 5f66 696c 652d  !m_torrent_file-
    │ │ │ -00041840: 2667 743b 636f 6c6c 6563 7469 6f6e 7328  >collections(
    │ │ │ -00041850: 292e 656d 7074 7928 2929 0a09 097b 0a09  ).empty())...{..
    │ │ │ -00041860: 0909 7265 736f 6c76 655f 6c69 6e6b 7320  ..resolve_links 
    │ │ │ -00041870: 7265 7328 6d5f 746f 7272 656e 745f 6669  res(m_torrent_fi
    │ │ │ -00041880: 6c65 293b 0a0a 0909 0966 6f72 2028 6175  le);.....for (au
    │ │ │ -00041890: 746f 2063 6f6e 7374 2661 6d70 3b20 6968  to const& ih
    │ │ │ -000418a0: 203a 206d 5f74 6f72 7265 6e74 5f66 696c   : m_torrent_fil
    │ │ │ -000418b0: 652d 2667 743b 7369 6d69 6c61 725f 746f  e->similar_to
    │ │ │ -000418c0: 7272 656e 7473 2829 290a 0909 097b 0a09  rrents())....{..
    │ │ │ -000418d0: 0909 0973 7464 3a3a 7368 6172 6564 5f70  ...std::shared_p
    │ │ │ -000418e0: 7472 266c 743b 746f 7272 656e 7426 6774  tr<torrent>
    │ │ │ -000418f0: 3b20 7420 3d20 6d5f 7365 732e 6669 6e64  ; t = m_ses.find
    │ │ │ -00041900: 5f74 6f72 7265 6e74 2869 6e66 6f5f 6861  _torrent(info_ha
    │ │ │ -00041910: 7368 5f74 2869 6829 292e 6c6f 636b 2829  sh_t(ih)).lock()
    │ │ │ -00041920: 3b0a 0909 0909 6966 2028 2174 2920 636f  ;.....if (!t) co
    │ │ │ -00041930: 6e74 696e 7565 3b0a 0a09 0909 092f 2f20  ntinue;......// 
    │ │ │ -00041940: 4f6e 6c79 2061 7474 656d 7074 2074 6f20  Only attempt to 
    │ │ │ -00041950: 7265 7573 6520 6669 6c65 7320 6672 6f6d  reuse files from
    │ │ │ -00041960: 2074 6f72 7265 6e74 7320 7468 6174 2061   torrents that a
    │ │ │ -00041970: 7265 2073 6565 6469 6e67 2e0a 3c64 6976  re seeding..
    ....if │ │ │ -000419b0: 2028 2174 2d26 6774 3b69 735f 7365 6564 (!t->is_seed │ │ │ -000419c0: 2829 2920 636f 6e74 696e 7565 3b0a 3c2f ()) continue;......res.mat │ │ │ -000419e0: 6368 2874 2d26 6774 3b67 6574 5f74 6f72 ch(t->get_tor │ │ │ -000419f0: 7265 6e74 5f66 696c 6528 292c 2074 2d26 rent_file(), t-& │ │ │ -00041a00: 6774 3b73 6176 655f 7061 7468 2829 293b gt;save_path()); │ │ │ -00041a10: 0a09 0909 7d0a 0909 0966 6f72 2028 6175 ....}....for (au │ │ │ -00041a20: 746f 2063 6f6e 7374 2661 6d70 3b20 6320 to const& c │ │ │ -00041a30: 3a20 6d5f 746f 7272 656e 745f 6669 6c65 : m_torrent_file │ │ │ -00041a40: 2d26 6774 3b63 6f6c 6c65 6374 696f 6e73 ->collections │ │ │ -00041a50: 2829 290a 0909 097b 0a09 0909 0973 7464 ())....{.....std │ │ │ -00041a60: 3a3a 7665 6374 6f72 266c 743b 7374 643a ::vector<std: │ │ │ -00041a70: 3a73 6861 7265 645f 7074 7226 6c74 3b74 :shared_ptr<t │ │ │ -00041a80: 6f72 7265 6e74 2667 743b 2667 743b 2074 orrent>> t │ │ │ -00041a90: 7320 3d20 6d5f 7365 732e 6669 6e64 5f63 s = m_ses.find_c │ │ │ -00041aa0: 6f6c 6c65 6374 696f 6e28 6329 3b0a 0a09 ollection(c);... │ │ │ -00041ab0: 0909 0966 6f72 2028 6175 746f 2063 6f6e ...for (auto con │ │ │ -00041ac0: 7374 2661 6d70 3b20 7420 3a20 7473 290a st& t : ts). │ │ │ -00041ad0: 0909 0909 7b0a 0909 0909 092f 2f20 4f6e ....{......// On │ │ │ -00041ae0: 6c79 2061 7474 656d 7074 2074 6f20 7265 ly attempt to re │ │ │ -00041af0: 7573 6520 6669 6c65 7320 6672 6f6d 2074 use files from t │ │ │ -00041b00: 6f72 7265 6e74 7320 7468 6174 2061 7265 orrents that are │ │ │ -00041b10: 2073 6565 6469 6e67 2e0a 3c2f 7072 653e seeding..
    │ │ │ -00041b20: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -00041b50: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00041b60: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/torr │ │ │ -00041b90: 656e 742e 6370 703a 3230 3530 3c2f 613e ent.cpp:2050 │ │ │ -00041ba0: 3c2f 7464 3e3c 7464 3e74 6869 7320 636f this co │ │ │ -00041bb0: 756c 6420 6265 206f 7074 696d 697a 6564 uld be optimized │ │ │ -00041bc0: 2062 7920 6c6f 6f6b 696e 6720 7570 2077 by looking up w │ │ │ -00041bd0: 6869 6368 2066 696c 6573 2061 7265 2063 hich files are c │ │ │ -00041be0: 6f6d 706c 6574 6520 616e 6420 6a75 7374 omplete and just │ │ │ -00041bf0: 206c 6f6f 6b20 6174 2074 686f 7365 3c2f look at those

    this │ │ │ -00041c50: 2063 6f75 6c64 2062 6520 6f70 7469 6d69 could be optimi │ │ │ -00041c60: 7a65 6420 6279 206c 6f6f 6b69 6e67 2075 zed by looking u │ │ │ -00041c70: 7020 7768 6963 6820 6669 6c65 7320 6172 p which files ar │ │ │ -00041c80: 650a 636f 6d70 6c65 7465 2061 6e64 206a e.complete and j │ │ │ -00041c90: 7573 7420 6c6f 6f6b 2061 7420 7468 6f73 ust look at thos │ │ │ -00041ca0: 653c 2f68 323e 3c68 343e 2e2e 2f73 7263 e

    ../src │ │ │ -00041cb0: 2f74 6f72 7265 6e74 2e63 7070 3a32 3035 /torrent.cpp:205 │ │ │ -00041cc0: 303c 2f68 343e 3c70 7265 2073 7479 6c65 0

    │ │ │ -00041d00: 0909 7b0a 0909 0972 6573 6f6c 7665 5f6c  ..{....resolve_l
    │ │ │ -00041d10: 696e 6b73 2072 6573 286d 5f74 6f72 7265  inks res(m_torre
    │ │ │ -00041d20: 6e74 5f66 696c 6529 3b0a 0a09 0909 666f  nt_file);.....fo
    │ │ │ -00041d30: 7220 2861 7574 6f20 636f 6e73 7426 616d  r (auto const&am
    │ │ │ -00041d40: 703b 2069 6820 3a20 6d5f 746f 7272 656e  p; ih : m_torren
    │ │ │ -00041d50: 745f 6669 6c65 2d26 6774 3b73 696d 696c  t_file->simil
    │ │ │ -00041d60: 6172 5f74 6f72 7265 6e74 7328 2929 0a09  ar_torrents())..
    │ │ │ -00041d70: 0909 7b0a 0909 0909 7374 643a 3a73 6861  ..{.....std::sha
    │ │ │ -00041d80: 7265 645f 7074 7226 6c74 3b74 6f72 7265  red_ptr<torre
    │ │ │ -00041d90: 6e74 2667 743b 2074 203d 206d 5f73 6573  nt> t = m_ses
    │ │ │ -00041da0: 2e66 696e 645f 746f 7272 656e 7428 696e  .find_torrent(in
    │ │ │ -00041db0: 666f 5f68 6173 685f 7428 6968 2929 2e6c  fo_hash_t(ih)).l
    │ │ │ -00041dc0: 6f63 6b28 293b 0a09 0909 0969 6620 2821  ock();.....if (!
    │ │ │ -00041dd0: 7429 2063 6f6e 7469 6e75 653b 0a0a 0909  t) continue;....
    │ │ │ -00041de0: 0909 2f2f 204f 6e6c 7920 6174 7465 6d70  ..// Only attemp
    │ │ │ -00041df0: 7420 746f 2072 6575 7365 2066 696c 6573  t to reuse files
    │ │ │ -00041e00: 2066 726f 6d20 746f 7272 656e 7473 2074   from torrents t
    │ │ │ -00041e10: 6861 7420 6172 6520 7365 6564 696e 672e  hat are seeding.
    │ │ │ -00041e20: 0a09 0909 0969 6620 2821 742d 2667 743b  .....if (!t->
    │ │ │ -00041e30: 6973 5f73 6565 6428 2929 2063 6f6e 7469  is_seed()) conti
    │ │ │ -00041e40: 6e75 653b 0a0a 0909 0909 7265 732e 6d61  nue;......res.ma
    │ │ │ -00041e50: 7463 6828 742d 2667 743b 6765 745f 746f  tch(t->get_to
    │ │ │ -00041e60: 7272 656e 745f 6669 6c65 2829 2c20 742d  rrent_file(), t-
    │ │ │ -00041e70: 2667 743b 7361 7665 5f70 6174 6828 2929  >save_path())
    │ │ │ -00041e80: 3b0a 0909 097d 0a09 0909 666f 7220 2861  ;....}....for (a
    │ │ │ -00041e90: 7574 6f20 636f 6e73 7426 616d 703b 2063  uto const& c
    │ │ │ -00041ea0: 203a 206d 5f74 6f72 7265 6e74 5f66 696c   : m_torrent_fil
    │ │ │ -00041eb0: 652d 2667 743b 636f 6c6c 6563 7469 6f6e  e->collection
    │ │ │ -00041ec0: 7328 2929 0a09 0909 7b0a 0909 0909 7374  s())....{.....st
    │ │ │ -00041ed0: 643a 3a76 6563 746f 7226 6c74 3b73 7464  d::vector<std
    │ │ │ -00041ee0: 3a3a 7368 6172 6564 5f70 7472 266c 743b  ::shared_ptr<
    │ │ │ -00041ef0: 746f 7272 656e 7426 6774 3b26 6774 3b20  torrent>> 
    │ │ │ -00041f00: 7473 203d 206d 5f73 6573 2e66 696e 645f  ts = m_ses.find_
    │ │ │ -00041f10: 636f 6c6c 6563 7469 6f6e 2863 293b 0a0a  collection(c);..
    │ │ │ -00041f20: 0909 0909 666f 7220 2861 7574 6f20 636f  ....for (auto co
    │ │ │ -00041f30: 6e73 7426 616d 703b 2074 203a 2074 7329  nst& t : ts)
    │ │ │ -00041f40: 0a09 0909 097b 0a09 0909 0909 2f2f 204f  .....{......// O
    │ │ │ -00041f50: 6e6c 7920 6174 7465 6d70 7420 746f 2072  nly attempt to r
    │ │ │ -00041f60: 6575 7365 2066 696c 6573 2066 726f 6d20  euse files from 
    │ │ │ -00041f70: 746f 7272 656e 7473 2074 6861 7420 6172  torrents that ar
    │ │ │ -00041f80: 6520 7365 6564 696e 672e 0a3c 6469 7620  e seeding..
    .....if │ │ │ -00041fc0: 2028 2174 2d26 6774 3b69 735f 7365 6564 (!t->is_seed │ │ │ -00041fd0: 2829 2920 636f 6e74 696e 7565 3b0a 3c2f ()) continue;.......res.ma │ │ │ -00041ff0: 7463 6828 742d 2667 743b 6765 745f 746f tch(t->get_to │ │ │ -00042000: 7272 656e 745f 6669 6c65 2829 2c20 742d rrent_file(), t- │ │ │ -00042010: 2667 743b 7361 7665 5f70 6174 6828 2929 >save_path()) │ │ │ -00042020: 3b0a 0909 0909 7d0a 0909 097d 0a0a 0909 ;.....}....}.... │ │ │ -00042030: 0973 7464 3a3a 7665 6374 6f72 266c 743b .std::vector< │ │ │ -00042040: 7265 736f 6c76 655f 6c69 6e6b 733a 3a6c resolve_links::l │ │ │ -00042050: 696e 6b5f 7426 6774 3b20 636f 6e73 7426 ink_t> const& │ │ │ -00042060: 616d 703b 206c 203d 2072 6573 2e67 6574 amp; l = res.get │ │ │ -00042070: 5f6c 696e 6b73 2829 3b0a 0909 0969 6620 _links();....if │ │ │ -00042080: 2821 6c2e 656d 7074 7928 2929 0a09 0909 (!l.empty()).... │ │ │ -00042090: 7b0a 0909 0909 6c69 6e6b 732e 7265 7369 {.....links.resi │ │ │ -000420a0: 7a65 286d 5f74 6f72 7265 6e74 5f66 696c ze(m_torrent_fil │ │ │ -000420b0: 652d 2667 743b 6669 6c65 7328 292e 6e75 e->files().nu │ │ │ -000420c0: 6d5f 6669 6c65 7328 2929 3b0a 0909 0909 m_files());..... │ │ │ -000420d0: 666f 7220 2861 7574 6f20 636f 6e73 7426 for (auto const& │ │ │ -000420e0: 616d 703b 2069 203a 206c 290a 0909 0909 amp; i : l)..... │ │ │ -000420f0: 7b0a 0909 0909 0969 6620 2821 692e 7469 {......if (!i.ti │ │ │ -00042100: 2920 636f 6e74 696e 7565 3b0a 0909 0909 ) continue;..... │ │ │ -00042110: 096c 696e 6b73 5b69 2e66 696c 655f 6964 .links[i.file_id │ │ │ -00042120: 785d 203d 2063 6f6d 6269 6e65 5f70 6174 x] = combine_pat │ │ │ -00042130: 6828 692e 7361 7665 5f70 6174 680a 0909 h(i.save_path... │ │ │ -00042140: 0909 0909 2c20 692e 7469 2d26 6774 3b66 ...., i.ti->f │ │ │ -00042150: 696c 6573 2829 2e66 696c 655f 7061 7468 iles().file_path │ │ │ -00042160: 2869 2e66 696c 655f 6964 7829 293b 0a09 (i.file_idx));.. │ │ │ -00042170: 0909 097d 0a09 0909 7d0a 0909 7d0a 2365 ...}....}...}.#e │ │ │ -00042180: 6e64 6966 202f 2f20 544f 5252 454e 545f ndif // TORRENT_ │ │ │ -00042190: 4449 5341 424c 455f 4d55 5441 424c 455f DISABLE_MUTABLE_ │ │ │ -000421a0: 544f 5252 454e 5453 0a0a 2369 6620 544f TORRENTS..#if TO │ │ │ -000421b0: 5252 454e 545f 5553 455f 4153 5345 5254 RRENT_USE_ASSERT │ │ │ -000421c0: 530a 0909 544f 5252 454e 545f 4153 5345 S...TORRENT_ASSE │ │ │ -000421d0: 5254 286d 5f6f 7574 7374 616e 6469 6e67 RT(m_outstanding │ │ │ -000421e0: 5f63 6865 636b 5f66 696c 6573 203d 3d20 _check_files == │ │ │ -000421f0: 6661 6c73 6529 3b0a 0909 6d5f 6f75 7473 false);...m_outs │ │ │ -00042200: 7461 6e64 696e 675f 6368 6563 6b5f 6669 tanding_check_fi │ │ │ -00042210: 6c65 7320 3d20 7472 7565 3b0a 2365 6e64 les = true;.#end │ │ │ -00042220: 6966 0a0a 0909 6966 2028 216d 5f61 6464 if....if (!m_add │ │ │ -00042230: 5f74 6f72 7265 6e74 5f70 6172 616d 7320 _torrent_params │ │ │ -00042240: 7c7c 2021 286d 5f61 6464 5f74 6f72 7265 || !(m_add_torre │ │ │ -00042250: 6e74 5f70 6172 616d 732d 2667 743b 666c nt_params->fl │ │ │ -00042260: 6167 7320 2661 6d70 3b20 746f 7272 656e ags & torren │ │ │ -00042270: 745f 666c 6167 733a 3a6e 6f5f 7665 7269 t_flags::no_veri │ │ │ -00042280: 6679 5f66 696c 6573 2929 0a09 097b 0a09 fy_files))...{.. │ │ │ -00042290: 0909 6d5f 7365 732e 6469 736b 5f74 6872 ..m_ses.disk_thr │ │ │ -000422a0: 6561 6428 292e 6173 796e 635f 6368 6563 ead().async_chec │ │ │ -000422b0: 6b5f 6669 6c65 7328 0a09 0909 096d 5f73 k_files(.....m_s │ │ │ -000422c0: 746f 7261 6765 2c20 6d5f 6164 645f 746f torage, m_add_to │ │ │ -000422d0: 7272 656e 745f 7061 7261 6d73 203f 206d rrent_params ? m │ │ │ -000422e0: 5f61 6464 5f74 6f72 7265 6e74 5f70 6172 _add_torrent_par │ │ │ -000422f0: 616d 732e 6765 7428 2920 3a20 6e75 6c6c ams.get() : null │ │ │ -00042300: 7074 720a 0909 0909 2c20 7374 643a 3a6d ptr....., std::m │ │ │ -00042310: 6f76 6528 6c69 6e6b 7329 2c20 5b73 656c ove(links), [sel │ │ │ -00042320: 6620 3d20 7368 6172 6564 5f66 726f 6d5f f = shared_from_ │ │ │ -00042330: 7468 6973 2829 5d28 7374 6174 7573 5f74 this()](status_t │ │ │ -00042340: 2073 742c 2073 746f 7261 6765 5f65 7272 st, storage_err │ │ │ -00042350: 6f72 2063 6f6e 7374 2661 6d70 3b20 6572 or const& er │ │ │ -00042360: 726f 7229 0a09 0909 097b 2073 656c 662d ror).....{ self- │ │ │ -00042370: 2667 743b 6f6e 5f72 6573 756d 655f 6461 >on_resume_da │ │ │ -00042380: 7461 5f63 6865 636b 6564 2873 742c 2065 ta_checked(st, e │ │ │ -00042390: 7272 6f72 293b 207d 293b 0a3c 2f70 7265 rror); });.
    rele │ │ │ -000423d0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/tor │ │ │ -00042410: 7265 6e74 2e63 7070 3a32 3831 383c 2f61 rent.cpp:2818this p │ │ │ -00042430: 6174 7465 726e 2069 7320 7265 7065 6174 attern is repeat │ │ │ -00042440: 6564 2069 6e20 6120 6665 7720 706c 6163 ed in a few plac │ │ │ -00042450: 6573 2e20 4661 6374 6f72 2074 6869 7320 es. Factor this │ │ │ -00042460: 696e 746f 2061 2066 756e 6374 696f 6e20 into a function │ │ │ -00042470: 616e 6420 6765 6e65 7261 6c69 7a65 2074 and generalize t │ │ │ -00042480: 6865 2063 6f6e 6365 7074 206f 6620 6120 he concept of a │ │ │ -00042490: 746f 7272 656e 7420 6861 7669 6e67 2061 torrent having a │ │ │ -000424a0: 2064 6564 6963 6174 6564 206c 6973 7465 dedicated liste │ │ │ -000424b0: 6e20 706f 7274 3c2f 7464 3e3c 2f74 723e n port │ │ │ -000424c0: 3c74 7220 6964 3d22 3136 3322 2073 7479 │ │ │ -000424f0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00042500: 3c68 323e 7468 6973 2070 6174 7465 726e

    this pattern │ │ │ -00042510: 2069 7320 7265 7065 6174 6564 2069 6e20 is repeated in │ │ │ -00042520: 6120 6665 7720 706c 6163 6573 2e20 4661 a few places. Fa │ │ │ -00042530: 6374 6f72 2074 6869 7320 696e 746f 0a61 ctor this into.a │ │ │ -00042540: 2066 756e 6374 696f 6e20 616e 6420 6765 function and ge │ │ │ -00042550: 6e65 7261 6c69 7a65 2074 6865 2063 6f6e neralize the con │ │ │ -00042560: 6365 7074 206f 6620 6120 746f 7272 656e cept of a torren │ │ │ -00042570: 7420 6861 7669 6e67 2061 0a64 6564 6963 t having a.dedic │ │ │ -00042580: 6174 6564 206c 6973 7465 6e20 706f 7274 ated listen port │ │ │ -00042590: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -000425a0: 746f 7272 656e 742e 6370 703a 3238 3138 torrent.cpp:2818 │ │ │ -000425b0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -000425f0: 092f 2f20 6e6f 7420 7265 6164 7920 666f  .// not ready fo
    │ │ │ -00042600: 7220 7065 6572 732e 2045 7863 6570 742c  r peers. Except,
    │ │ │ -00042610: 2069 6620 7765 2064 6f6e 2774 2068 6176   if we don't hav
    │ │ │ -00042620: 6520 6d65 7461 6461 7461 2c0a 0909 2f2f  e metadata,...//
    │ │ │ -00042630: 2077 6520 6e65 6564 2070 6565 7273 2074   we need peers t
    │ │ │ -00042640: 6f20 646f 776e 6c6f 6164 2066 726f 6d0a  o download from.
    │ │ │ -00042650: 0909 6966 2028 216d 5f66 696c 6573 5f63  ..if (!m_files_c
    │ │ │ -00042660: 6865 636b 6564 2026 616d 703b 2661 6d70  hecked &&
    │ │ │ -00042670: 3b20 7661 6c69 645f 6d65 7461 6461 7461  ; valid_metadata
    │ │ │ -00042680: 2829 2920 7265 7475 726e 3b0a 0a09 0969  ()) return;....i
    │ │ │ -00042690: 6620 2821 6d5f 616e 6e6f 756e 6365 5f74  f (!m_announce_t
    │ │ │ -000426a0: 6f5f 6c73 6429 2072 6574 7572 6e3b 0a0a  o_lsd) return;..
    │ │ │ -000426b0: 0909 2f2f 2070 7269 7661 7465 2074 6f72  ..// private tor
    │ │ │ -000426c0: 7265 6e74 7320 6172 6520 6e65 7665 7220  rents are never 
    │ │ │ -000426d0: 616e 6e6f 756e 6365 6420 6f6e 204c 5344  announced on LSD
    │ │ │ -000426e0: 0a09 0969 6620 286d 5f74 6f72 7265 6e74  ...if (m_torrent
    │ │ │ -000426f0: 5f66 696c 652d 2667 743b 6973 5f76 616c  _file->is_val
    │ │ │ -00042700: 6964 2829 2026 616d 703b 2661 6d70 3b20  id() && 
    │ │ │ -00042710: 6d5f 746f 7272 656e 745f 6669 6c65 2d26  m_torrent_file-&
    │ │ │ -00042720: 6774 3b70 7269 7628 2929 2072 6574 7572  gt;priv()) retur
    │ │ │ -00042730: 6e3b 0a0a 2369 6620 544f 5252 454e 545f  n;..#if TORRENT_
    │ │ │ -00042740: 5553 455f 4932 500a 0909 2f2f 2069 3270  USE_I2P...// i2p
    │ │ │ -00042750: 2074 6f72 7265 6e74 7320 6172 6520 616c   torrents are al
    │ │ │ -00042760: 736f 206e 6576 6572 2061 6e6e 6f75 6e63  so never announc
    │ │ │ -00042770: 6564 206f 6e20 4c53 440a 0909 2f2f 2075  ed on LSD...// u
    │ │ │ -00042780: 6e6c 6573 7320 7765 2061 6c6c 6f77 206d  nless we allow m
    │ │ │ -00042790: 6978 6564 2073 7761 726d 730a 0909 6966  ixed swarms...if
    │ │ │ -000427a0: 2028 6973 5f69 3270 2829 2026 616d 703b   (is_i2p() &
    │ │ │ -000427b0: 2661 6d70 3b20 2173 6574 7469 6e67 7328  & !settings(
    │ │ │ -000427c0: 292e 6765 745f 626f 6f6c 2873 6574 7469  ).get_bool(setti
    │ │ │ -000427d0: 6e67 735f 7061 636b 3a3a 616c 6c6f 775f  ngs_pack::allow_
    │ │ │ -000427e0: 6932 705f 6d69 7865 6429 290a 0909 0972  i2p_mixed))....r
    │ │ │ -000427f0: 6574 7572 6e3b 0a23 656e 6469 660a 0a09  eturn;.#endif...
    │ │ │ -00042800: 0969 6620 2869 735f 7061 7573 6564 2829  .if (is_paused()
    │ │ │ -00042810: 2920 7265 7475 726e 3b0a 0a09 0969 6620  ) return;....if 
    │ │ │ -00042820: 2821 6d5f 7365 732e 6861 735f 6c73 6428  (!m_ses.has_lsd(
    │ │ │ -00042830: 2929 2072 6574 7572 6e3b 0a0a 3c64 6976  )) return;..
    #ifdef │ │ │ -00042870: 2054 4f52 5245 4e54 5f53 534c 5f50 4545 TORRENT_SSL_PEE │ │ │ -00042880: 5253 0a3c 2f64 6976 3e09 0969 6e74 2070 RS.
    ..int p │ │ │ -00042890: 6f72 7420 3d20 6973 5f73 736c 5f74 6f72 ort = is_ssl_tor │ │ │ -000428a0: 7265 6e74 2829 203f 206d 5f73 6573 2e73 rent() ? m_ses.s │ │ │ -000428b0: 736c 5f6c 6973 7465 6e5f 706f 7274 2829 sl_listen_port() │ │ │ -000428c0: 203a 206d 5f73 6573 2e6c 6973 7465 6e5f : m_ses.listen_ │ │ │ -000428d0: 706f 7274 2829 3b0a 2365 6c73 650a 0909 port();.#else... │ │ │ -000428e0: 696e 7420 706f 7274 203d 206d 5f73 6573 int port = m_ses │ │ │ -000428f0: 2e6c 6973 7465 6e5f 706f 7274 2829 3b0a .listen_port();. │ │ │ -00042900: 2365 6e64 6966 0a0a 0909 2f2f 2061 6e6e #endif....// ann │ │ │ -00042910: 6f75 6e63 6520 7769 7468 2074 6865 206c ounce with the l │ │ │ -00042920: 6f63 616c 2064 6973 636f 7665 7279 2073 ocal discovery s │ │ │ -00042930: 6572 7669 6365 0a09 096d 5f74 6f72 7265 ervice...m_torre │ │ │ -00042940: 6e74 5f66 696c 652d 2667 743b 696e 666f nt_file->info │ │ │ -00042950: 5f68 6173 6865 7328 292e 666f 725f 6561 _hashes().for_ea │ │ │ -00042960: 6368 285b 2661 6d70 3b5d 2873 6861 315f ch([&](sha1_ │ │ │ -00042970: 6861 7368 2063 6f6e 7374 2661 6d70 3b20 hash const& │ │ │ -00042980: 6968 2c20 7072 6f74 6f63 6f6c 5f76 6572 ih, protocol_ver │ │ │ -00042990: 7369 6f6e 290a 0909 7b0a 0909 096d 5f73 sion)...{....m_s │ │ │ -000429a0: 6573 2e61 6e6e 6f75 6e63 655f 6c73 6428 es.announce_lsd( │ │ │ -000429b0: 6968 2c20 706f 7274 293b 0a09 097d 293b ih, port);...}); │ │ │ -000429c0: 0a09 7d0a 0a23 6966 6e64 6566 2054 4f52 ..}..#ifndef TOR │ │ │ -000429d0: 5245 4e54 5f44 4953 4142 4c45 5f44 4854 RENT_DISABLE_DHT │ │ │ -000429e0: 0a0a 0976 6f69 6420 746f 7272 656e 743a ...void torrent: │ │ │ -000429f0: 3a64 6874 5f61 6e6e 6f75 6e63 6528 290a :dht_announce(). │ │ │ -00042a00: 097b 0a09 0954 4f52 5245 4e54 5f41 5353 .{...TORRENT_ASS │ │ │ -00042a10: 4552 5428 6973 5f73 696e 676c 655f 7468 ERT(is_single_th │ │ │ -00042a20: 7265 6164 2829 293b 0a09 0969 6620 2821 read());...if (! │ │ │ -00042a30: 6d5f 7365 732e 6468 7428 2929 0a09 097b m_ses.dht())...{ │ │ │ -00042a40: 0a23 6966 6e64 6566 2054 4f52 5245 4e54 .#ifndef TORRENT │ │ │ -00042a50: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47 _DISABLE_LOGGING │ │ │ -00042a60: 0a09 0909 6465 6275 675f 6c6f 6728 2244 ....debug_log("D │ │ │ -00042a70: 4854 3a20 6e6f 2064 6874 2069 6e69 7469 HT: no dht initi │ │ │ -00042a80: 616c 697a 6564 2229 3b0a 2365 6e64 6966 alized");.#endif │ │ │ -00042a90: 0a09 0909 7265 7475 726e 3b0a 0909 7d0a ....return;...}. │ │ │ -00042aa0: 0909 6966 2028 2173 686f 756c 645f 616e ..if (!should_an │ │ │ -00042ab0: 6e6f 756e 6365 5f64 6874 2829 290a 0909 nounce_dht())... │ │ │ -00042ac0: 7b0a 2369 666e 6465 6620 544f 5252 454e {.#ifndef TORREN │ │ │ -00042ad0: 545f 4449 5341 424c 455f 4c4f 4747 494e T_DISABLE_LOGGIN │ │ │ -00042ae0: 470a 0909 0969 6620 2873 686f 756c 645f G....if (should_ │ │ │ -00042af0: 6c6f 6728 2929 0a09 0909 7b0a 2369 6620 log())....{.#if │ │ │ -00042b00: 544f 5252 454e 545f 5553 455f 4932 500a TORRENT_USE_I2P. │ │ │ -00042b10: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00042b20: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00042b50: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -00042b80: 632f 746f 7272 656e 742e 6370 703a 3339 c/torrent.cpp:39 │ │ │ -00042b90: 3932 3c2f 613e 3c2f 7464 3e3c 7464 3e61 92a │ │ │ -00042ba0: 6464 206f 6e65 2070 6565 7220 7065 7220 dd one peer per │ │ │ -00042bb0: 4950 2074 6865 2068 6f73 746e 616d 6520 IP the hostname │ │ │ -00042bc0: 7265 736f 6c76 6573 2074 6f3c 2f74 643e resolves to │ │ │ -00042bd0: 3c2f 7472 3e3c 7472 2069 643d 2231 3634

    add one │ │ │ -00042c20: 2070 6565 7220 7065 7220 4950 2074 6865 peer per IP the │ │ │ -00042c30: 2068 6f73 746e 616d 6520 7265 736f 6c76 hostname resolv │ │ │ -00042c40: 6573 2074 6f3c 2f68 323e 3c68 343e 2e2e es to

    .. │ │ │ -00042c50: 2f73 7263 2f74 6f72 7265 6e74 2e63 7070 /src/torrent.cpp │ │ │ -00042c60: 3a33 3939 323c 2f68 343e 3c70 7265 2073 :3992

    .catch (...)
    │ │ │ -00042cb0: 207b 2068 616e 646c 655f 6578 6365 7074   { handle_except
    │ │ │ -00042cc0: 696f 6e28 293b 207d 0a23 656e 6469 660a  ion(); }.#endif.
    │ │ │ -00042cd0: 0a09 766f 6964 2074 6f72 7265 6e74 3a3a  ..void torrent::
    │ │ │ -00042ce0: 6f6e 5f70 6565 725f 6e61 6d65 5f6c 6f6f  on_peer_name_loo
    │ │ │ -00042cf0: 6b75 7028 6572 726f 725f 636f 6465 2063  kup(error_code c
    │ │ │ -00042d00: 6f6e 7374 2661 6d70 3b20 650a 0909 2c20  onst& e..., 
    │ │ │ -00042d10: 7374 643a 3a76 6563 746f 7226 6c74 3b61  std::vector<a
    │ │ │ -00042d20: 6464 7265 7373 2667 743b 2063 6f6e 7374  ddress> const
    │ │ │ -00042d30: 2661 6d70 3b20 686f 7374 5f6c 6973 742c  & host_list,
    │ │ │ -00042d40: 2069 6e74 2063 6f6e 7374 2070 6f72 740a   int const port.
    │ │ │ -00042d50: 0909 2c20 7072 6f74 6f63 6f6c 5f76 6572  .., protocol_ver
    │ │ │ -00042d60: 7369 6f6e 2063 6f6e 7374 2076 2920 7472  sion const v) tr
    │ │ │ -00042d70: 790a 097b 0a09 0954 4f52 5245 4e54 5f41  y..{...TORRENT_A
    │ │ │ -00042d80: 5353 4552 5428 6973 5f73 696e 676c 655f  SSERT(is_single_
    │ │ │ -00042d90: 7468 7265 6164 2829 293b 0a0a 0909 494e  thread());....IN
    │ │ │ -00042da0: 5641 5249 414e 545f 4348 4543 4b3b 0a0a  VARIANT_CHECK;..
    │ │ │ -00042db0: 0909 434f 4d50 4c45 5445 5f41 5359 4e43  ..COMPLETE_ASYNC
    │ │ │ -00042dc0: 2822 746f 7272 656e 743a 3a6f 6e5f 7065  ("torrent::on_pe
    │ │ │ -00042dd0: 6572 5f6e 616d 655f 6c6f 6f6b 7570 2229  er_name_lookup")
    │ │ │ -00042de0: 3b0a 0a23 6966 6e64 6566 2054 4f52 5245  ;..#ifndef TORRE
    │ │ │ -00042df0: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749  NT_DISABLE_LOGGI
    │ │ │ -00042e00: 4e47 0a09 0969 6620 2865 2026 616d 703b  NG...if (e &
    │ │ │ -00042e10: 2661 6d70 3b20 7368 6f75 6c64 5f6c 6f67  & should_log
    │ │ │ -00042e20: 2829 290a 0909 0964 6562 7567 5f6c 6f67  ())....debug_log
    │ │ │ -00042e30: 2822 7065 6572 206e 616d 6520 6c6f 6f6b  ("peer name look
    │ │ │ -00042e40: 7570 2065 7272 6f72 3a20 2573 222c 2065  up error: %s", e
    │ │ │ -00042e50: 2e6d 6573 7361 6765 2829 2e63 5f73 7472  .message().c_str
    │ │ │ -00042e60: 2829 293b 0a23 656e 6469 660a 0a09 0969  ());.#endif....i
    │ │ │ -00042e70: 6620 2865 207c 7c20 6d5f 6162 6f72 7420  f (e || m_abort 
    │ │ │ -00042e80: 7c7c 2068 6f73 745f 6c69 7374 2e65 6d70  || host_list.emp
    │ │ │ -00042e90: 7479 2829 207c 7c20 6d5f 7365 732e 6973  ty() || m_ses.is
    │ │ │ -00042ea0: 5f61 626f 7274 6564 2829 2920 7265 7475  _aborted()) retu
    │ │ │ -00042eb0: 726e 3b0a 0a3c 6469 7620 7374 796c 653d  rn;..
    ..tcp::endpoi │ │ │ -00042ef0: 6e74 2068 6f73 7428 686f 7374 5f6c 6973 nt host(host_lis │ │ │ -00042f00: 742e 6672 6f6e 7428 292c 2073 7464 3a3a t.front(), std:: │ │ │ -00042f10: 7569 6e74 3136 5f74 2870 6f72 7429 293b uint16_t(port)); │ │ │ -00042f20: 0a3c 2f64 6976 3e0a 0909 6966 2028 6d5f .
    ...if (m_ │ │ │ -00042f30: 6970 5f66 696c 7465 7220 2661 6d70 3b26 ip_filter && │ │ │ -00042f40: 616d 703b 206d 5f69 705f 6669 6c74 6572 amp; m_ip_filter │ │ │ -00042f50: 2d26 6774 3b61 6363 6573 7328 686f 7374 ->access(host │ │ │ -00042f60: 2e61 6464 7265 7373 2829 2920 2661 6d70 .address()) & │ │ │ -00042f70: 3b20 6970 5f66 696c 7465 723a 3a62 6c6f ; ip_filter::blo │ │ │ -00042f80: 636b 6564 290a 0909 7b0a 2369 666e 6465 cked)...{.#ifnde │ │ │ -00042f90: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ -00042fa0: 455f 4c4f 4747 494e 470a 0909 0969 6620 E_LOGGING....if │ │ │ -00042fb0: 2873 686f 756c 645f 6c6f 6728 2929 0a09 (should_log()).. │ │ │ -00042fc0: 0909 7b0a 0909 0909 6465 6275 675f 6c6f ..{.....debug_lo │ │ │ -00042fd0: 6728 2262 6c6f 636b 6564 2069 7020 6672 g("blocked ip fr │ │ │ -00042fe0: 6f6d 2074 7261 636b 6572 3a20 2573 222c om tracker: %s", │ │ │ -00042ff0: 2068 6f73 742e 6164 6472 6573 7328 292e host.address(). │ │ │ -00043000: 746f 5f73 7472 696e 6728 292e 635f 7374 to_string().c_st │ │ │ -00043010: 7228 2929 3b0a 0909 097d 0a23 656e 6469 r());....}.#endi │ │ │ -00043020: 660a 0909 0969 6620 286d 5f73 6573 2e61 f....if (m_ses.a │ │ │ -00043030: 6c65 7274 7328 292e 7368 6f75 6c64 5f70 lerts().should_p │ │ │ -00043040: 6f73 7426 6c74 3b70 6565 725f 626c 6f63 ost<peer_bloc │ │ │ -00043050: 6b65 645f 616c 6572 7426 6774 3b28 2929 ked_alert>()) │ │ │ -00043060: 0a09 0909 096d 5f73 6573 2e61 6c65 7274 .....m_ses.alert │ │ │ -00043070: 7328 292e 656d 706c 6163 655f 616c 6572 s().emplace_aler │ │ │ -00043080: 7426 6c74 3b70 6565 725f 626c 6f63 6b65 t<peer_blocke │ │ │ -00043090: 645f 616c 6572 7426 6774 3b28 6765 745f d_alert>(get_ │ │ │ -000430a0: 6861 6e64 6c65 2829 0a09 0909 0909 2c20 handle()......, │ │ │ -000430b0: 686f 7374 2c20 7065 6572 5f62 6c6f 636b host, peer_block │ │ │ -000430c0: 6564 5f61 6c65 7274 3a3a 6970 5f66 696c ed_alert::ip_fil │ │ │ -000430d0: 7465 7229 3b0a 0909 0972 6574 7572 6e3b ter);....return; │ │ │ -000430e0: 0a09 097d 0a0a 0909 6966 2028 6164 645f ...}....if (add_ │ │ │ -000430f0: 7065 6572 2868 6f73 742c 2070 6565 725f peer(host, peer_ │ │ │ -00043100: 696e 666f 3a3a 7472 6163 6b65 722c 2076 info::tracker, v │ │ │ -00043110: 203d 3d20 7072 6f74 6f63 6f6c 5f76 6572 == protocol_ver │ │ │ -00043120: 7369 6f6e 3a3a 5632 203f 2070 6578 5f6c sion::V2 ? pex_l │ │ │ -00043130: 745f 7632 203a 2070 6578 5f66 6c61 6773 t_v2 : pex_flags │ │ │ -00043140: 5f74 2830 2929 290a 0909 7b0a 0909 0973 _t(0)))...{....s │ │ │ -00043150: 7461 7465 5f75 7064 6174 6564 2829 3b0a tate_updated();. │ │ │ -00043160: 0a23 6966 6e64 6566 2054 4f52 5245 4e54 .#ifndef TORRENT │ │ │ -00043170: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47 _DISABLE_LOGGING │ │ │ -00043180: 0a09 0909 6966 2028 7368 6f75 6c64 5f6c ....if (should_l │ │ │ -00043190: 6f67 2829 290a 0909 097b 0a09 0909 0964 og())....{.....d │ │ │ -000431a0: 6562 7567 5f6c 6f67 2822 6e61 6d65 2d6c ebug_log("name-l │ │ │ -000431b0: 6f6f 6b75 7020 6164 645f 7065 6572 2829 ookup add_peer() │ │ │ -000431c0: 205b 2025 7320 5d20 636f 6e6e 6563 742d [ %s ] connect- │ │ │ -000431d0: 6361 6e64 6964 6174 6573 3a20 2564 220a candidates: %d". │ │ │ -000431e0: 0909 0909 092c 2068 6f73 742e 6164 6472 ....., host.addr │ │ │ -000431f0: 6573 7328 292e 746f 5f73 7472 696e 6728 ess().to_string( │ │ │ -00043200: 292e 635f 7374 7228 290a 0909 0909 092c ).c_str()......, │ │ │ -00043210: 206d 5f70 6565 725f 6c69 7374 203f 206d m_peer_list ? m │ │ │ -00043220: 5f70 6565 725f 6c69 7374 2d26 6774 3b6e _peer_list->n │ │ │ -00043230: 756d 5f63 6f6e 6e65 6374 5f63 616e 6469 um_connect_candi │ │ │ -00043240: 6461 7465 7328 2920 3a20 2d31 293b 0a09 dates() : -1);.. │ │ │ -00043250: 0909 7d0a 2365 6e64 6966 0a09 097d 0a09 ..}.#endif...}.. │ │ │ -00043260: 0975 7064 6174 655f 7761 6e74 5f70 6565 .update_want_pee │ │ │ -00043270: 7273 2829 3b0a 097d 0a3c 2f70 7265 3e3c rs();..}.
    < │ │ │ -00043280: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -000432b0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -000432c0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/torre │ │ │ -000432f0: 6e74 2e63 7070 3a34 3730 393c 2f61 3e3c nt.cpp:4709< │ │ │ -00043300: 2f74 643e 3c74 643e 6f6e 6c79 2064 6f20 /td>only do │ │ │ -00043310: 7468 6973 2069 6620 7468 6520 7069 6563 this if the piec │ │ │ -00043320: 6520 7369 7a65 203e 2031 2062 6c6f 636b e size > 1 block │ │ │ -00043330: 7320 5468 6973 2069 7320 6120 7632 2074 s This is a v2 t │ │ │ -00043340: 6f72 7265 6e74 2073 6f20 7765 2063 616e orrent so we can │ │ │ -00043350: 2072 6571 7565 7374 2067 6574 2062 6c6f request get blo │ │ │ -00043360: 636b 206c 6576 656c 2068 6173 6865 732e ck level hashes. │ │ │ -00043370: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    on │ │ │ -000433c0: 6c79 2064 6f20 7468 6973 2069 6620 7468 ly do this if th │ │ │ -000433d0: 6520 7069 6563 6520 7369 7a65 203e 2031 e piece size > 1 │ │ │ -000433e0: 2062 6c6f 636b 730a 5468 6973 2069 7320 blocks.This is │ │ │ -000433f0: 6120 7632 2074 6f72 7265 6e74 2073 6f20 a v2 torrent so │ │ │ -00043400: 7765 2063 616e 2072 6571 7565 7374 2067 we can request g │ │ │ -00043410: 6574 2062 6c6f 636b 0a6c 6576 656c 2068 et block.level h │ │ │ -00043420: 6173 6865 732e 3c2f 6832 3e3c 6834 3e2e ashes.

    . │ │ │ -00043430: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ -00043440: 703a 3437 3039 3c2f 6834 3e3c 7072 6520 p:4709

    ..{....std:
    │ │ │ -00043490: 3a73 6574 266c 743b 746f 7272 656e 745f  :set<torrent_
    │ │ │ -000434a0: 7065 6572 2a26 6774 3b20 7265 743b 0a09  peer*> ret;..
    │ │ │ -000434b0: 0909 6966 2028 2162 6c6f 636b 732e 656d  ..if (!blocks.em
    │ │ │ -000434c0: 7074 7928 2920 2661 6d70 3b26 616d 703b  pty() &&
    │ │ │ -000434d0: 2021 646f 776e 6c6f 6164 6572 732e 656d   !downloaders.em
    │ │ │ -000434e0: 7074 7928 2929 0a09 0909 7b0a 0909 0909  pty())....{.....
    │ │ │ -000434f0: 666f 7220 2861 7574 6f20 636f 6e73 7420  for (auto const 
    │ │ │ -00043500: 6220 3a20 626c 6f63 6b73 2920 7265 742e  b : blocks) ret.
    │ │ │ -00043510: 696e 7365 7274 2864 6f77 6e6c 6f61 6465  insert(downloade
    │ │ │ -00043520: 7273 5b73 7464 3a3a 7369 7a65 5f74 2862  rs[std::size_t(b
    │ │ │ -00043530: 295d 293b 0a09 0909 7d0a 0909 0965 6c73  )]);....}....els
    │ │ │ -00043540: 650a 0909 097b 0a09 0909 0973 7464 3a3a  e....{.....std::
    │ │ │ -00043550: 636f 7079 2864 6f77 6e6c 6f61 6465 7273  copy(downloaders
    │ │ │ -00043560: 2e62 6567 696e 2829 2c20 646f 776e 6c6f  .begin(), downlo
    │ │ │ -00043570: 6164 6572 732e 656e 6428 292c 2073 7464  aders.end(), std
    │ │ │ -00043580: 3a3a 696e 7365 7274 6572 2872 6574 2c20  ::inserter(ret, 
    │ │ │ -00043590: 7265 742e 6265 6769 6e28 2929 293b 0a09  ret.begin()));..
    │ │ │ -000435a0: 0909 7d0a 0909 0972 6574 7572 6e20 7265  ..}....return re
    │ │ │ -000435b0: 743b 0a09 097d 2829 3b0a 0a09 092f 2f20  t;...}();....// 
    │ │ │ -000435c0: 6966 2074 6869 7320 7069 6563 6520 7761  if this piece wa
    │ │ │ -000435d0: 736e 2774 2064 6f77 6e6c 6f61 6465 6420  sn't downloaded 
    │ │ │ -000435e0: 6672 6f6d 2070 6565 7273 2c20 7765 206a  from peers, we j
    │ │ │ -000435f0: 7573 7420 666f 756e 6420 6974 206f 6e20  ust found it on 
    │ │ │ -00043600: 6469 736b 2e0a 0909 2f2f 2049 6e20 7468  disk....// In th
    │ │ │ -00043610: 6174 2063 6173 652c 2077 6520 7368 6f75  at case, we shou
    │ │ │ -00043620: 6c64 206a 7573 7420 636f 6e73 6964 6572  ld just consider
    │ │ │ -00043630: 2069 7420 6173 2022 6e6f 742d 6861 7665   it as "not-have
    │ │ │ -00043640: 2220 616e 6420 7468 6572 6527 7320 6e6f  " and there's no
    │ │ │ -00043650: 0a09 092f 2f20 6e65 6564 2074 6f20 7472  ...// need to tr
    │ │ │ -00043660: 7920 746f 2067 6574 2068 6967 6865 7220  y to get higher 
    │ │ │ -00043670: 6669 6465 6c69 7479 2068 6173 6865 7320  fidelity hashes 
    │ │ │ -00043680: 2879 6574 290a 0909 626f 6f6c 2063 6f6e  (yet)...bool con
    │ │ │ -00043690: 7374 2066 6f75 6e64 5f6f 6e5f 6469 736b  st found_on_disk
    │ │ │ -000436a0: 203d 2070 6565 7273 2e73 697a 6528 2920   = peers.size() 
    │ │ │ -000436b0: 3d3d 2031 2026 616d 703b 2661 6d70 3b20  == 1 && 
    │ │ │ -000436c0: 7065 6572 732e 636f 756e 7428 6e75 6c6c  peers.count(null
    │ │ │ -000436d0: 7074 7229 3b0a 0a09 0969 6620 2874 6f72  ptr);....if (tor
    │ │ │ -000436e0: 7265 6e74 5f66 696c 6528 292e 696e 666f  rent_file().info
    │ │ │ -000436f0: 5f68 6173 6865 7328 292e 6861 735f 7632  _hashes().has_v2
    │ │ │ -00043700: 2829 2026 616d 703b 2661 6d70 3b20 626c  () && bl
    │ │ │ -00043710: 6f63 6b73 2e65 6d70 7479 2829 2026 616d  ocks.empty() &am
    │ │ │ -00043720: 703b 2661 6d70 3b20 2166 6f75 6e64 5f6f  p;& !found_o
    │ │ │ -00043730: 6e5f 6469 736b 290a 0909 7b0a 3c64 6976  n_disk)...{.
    ...ver │ │ │ -00043770: 6966 795f 626c 6f63 6b5f 6861 7368 6573 ify_block_hashes │ │ │ -00043780: 2869 6e64 6578 293b 0a3c 2f64 6976 3e09 (index);.
    . │ │ │ -00043790: 097d 0a0a 0909 2f2f 2074 6865 2062 656c .}....// the bel │ │ │ -000437a0: 6f77 2063 6f64 6520 6973 2070 656e 616c ow code is penal │ │ │ -000437b0: 697a 696e 6720 7065 6572 7320 7468 6174 izing peers that │ │ │ -000437c0: 2073 656e 7420 7573 6520 6261 6420 6461 sent use bad da │ │ │ -000437d0: 7461 2e0a 0909 2f2f 2069 6e63 7265 6173 ta....// increas │ │ │ -000437e0: 6520 7468 6520 746f 7461 6c20 616d 6f75 e the total amou │ │ │ -000437f0: 6e74 206f 6620 6661 696c 6564 2062 7974 nt of failed byt │ │ │ -00043800: 6573 0a09 0969 6620 2821 666f 756e 645f es...if (!found_ │ │ │ -00043810: 6f6e 5f64 6973 6b29 0a09 097b 0a09 0909 on_disk)...{.... │ │ │ -00043820: 6966 2028 626c 6f63 6b73 2e65 6d70 7479 if (blocks.empty │ │ │ -00043830: 2829 290a 0909 0909 6164 645f 6661 696c ()).....add_fail │ │ │ -00043840: 6564 5f62 7974 6573 286d 5f74 6f72 7265 ed_bytes(m_torre │ │ │ -00043850: 6e74 5f66 696c 652d 2667 743b 7069 6563 nt_file->piec │ │ │ -00043860: 655f 7369 7a65 2869 6e64 6578 2929 3b0a e_size(index));. │ │ │ -00043870: 0909 0965 6c73 650a 0909 0909 6164 645f ...else.....add_ │ │ │ -00043880: 6661 696c 6564 5f62 7974 6573 2873 7461 failed_bytes(sta │ │ │ -00043890: 7469 635f 6361 7374 266c 743b 696e 7426 tic_cast<int& │ │ │ -000438a0: 6774 3b28 626c 6f63 6b73 2e73 697a 6528 gt;(blocks.size( │ │ │ -000438b0: 2929 202a 2064 6566 6175 6c74 5f62 6c6f )) * default_blo │ │ │ -000438c0: 636b 5f73 697a 6529 3b0a 0a23 6966 6e64 ck_size);..#ifnd │ │ │ -000438d0: 6566 2054 4f52 5245 4e54 5f44 4953 4142 ef TORRENT_DISAB │ │ │ -000438e0: 4c45 5f45 5854 454e 5349 4f4e 530a 0909 LE_EXTENSIONS... │ │ │ -000438f0: 0966 6f72 2028 6175 746f 2661 6d70 3b20 .for (auto& │ │ │ -00043900: 6578 7420 3a20 6d5f 6578 7465 6e73 696f ext : m_extensio │ │ │ -00043910: 6e73 290a 0909 097b 0a09 0909 0965 7874 ns)....{.....ext │ │ │ -00043920: 2d26 6774 3b6f 6e5f 7069 6563 655f 6661 ->on_piece_fa │ │ │ -00043930: 696c 6564 2869 6e64 6578 293b 0a09 0909 iled(index);.... │ │ │ -00043940: 7d0a 2365 6e64 6966 0a0a 0909 092f 2f20 }.#endif.....// │ │ │ -00043950: 6469 6420 7765 2072 6563 6569 7665 2074 did we receive t │ │ │ -00043960: 6869 7320 7069 6563 6520 6672 6f6d 2061 his piece from a │ │ │ -00043970: 2073 696e 676c 6520 7065 6572 3f0a 0909 single peer?... │ │ │ -00043980: 092f 2f20 6966 2077 6520 6b6e 6f77 2065 .// if we know e │ │ │ -00043990: 7861 6374 6c79 2077 6869 6368 2062 6c6f xactly which blo │ │ │ -000439a0: 636b 7320 6661 696c 6564 2074 6865 2068 cks failed the h │ │ │ -000439b0: 6173 682c 2077 6520 6361 6e20 616c 736f ash, we can also │ │ │ -000439c0: 2062 6520 6365 7274 6169 6e0a 0909 092f be certain..../ │ │ │ -000439d0: 2f20 7468 6174 2061 6c6c 2070 6565 7273 / that all peers │ │ │ -000439e0: 2069 6e20 7468 6520 6c69 7374 2073 656e in the list sen │ │ │ -000439f0: 7420 7573 2062 6164 2064 6174 610a 0909 t us bad data... │ │ │ -00043a00: 0962 6f6f 6c20 636f 6e73 7420 6b6e 6f77 .bool const know │ │ │ -00043a10: 6e5f 6261 645f 7065 6572 203d 2028 2166 n_bad_peer = (!f │ │ │ -00043a20: 6f75 6e64 5f6f 6e5f 6469 736b 2026 616d ound_on_disk &am │ │ │ -00043a30: 703b 2661 6d70 3b20 7065 6572 732e 7369 p;& peers.si │ │ │ -00043a40: 7a65 2829 203d 3d20 3129 207c 7c20 2162 ze() == 1) || !b │ │ │ -00043a50: 6c6f 636b 732e 656d 7074 7928 293b 0a0a locks.empty();.. │ │ │ -00043a60: 0909 0970 656e 616c 697a 655f 7065 6572 ...penalize_peer │ │ │ -00043a70: 7328 7065 6572 732c 2069 6e64 6578 2c20 s(peers, index, │ │ │ -00043a80: 6b6e 6f77 6e5f 6261 645f 7065 6572 293b known_bad_peer); │ │ │ -00043a90: 0a09 097d 0a0a 0909 2f2f 2049 6620 6d5f ...}....// If m_ │ │ │ -00043aa0: 7374 6f72 6167 6520 6973 6e27 7420 7365 storage isn't se │ │ │ -00043ab0: 7420 6865 7265 2c20 6974 206d 6561 6e73 t here, it means │ │ │ -00043ac0: 2077 6527 7265 2073 6875 7474 696e 6720 we're shutting │ │ │ -00043ad0: 646f 776e 0a09 0969 6620 286d 5f73 746f down...if (m_sto │ │ │ -00043ae0: 7261 6765 290a 0909 7b0a 0909 092f 2f20 rage)...{....// │ │ │ -00043af0: 6974 2064 6f65 736e 2774 206d 616b 6520 it doesn't make │ │ │ -00043b00: 6d75 6368 2073 656e 7365 2074 6f20 6661 much sense to fa │ │ │ -00043b10: 696c 2074 6f20 6861 7368 2061 2070 6965 il to hash a pie │ │ │ -00043b20: 6365 0a3c 2f70 7265 3e3c 2f74 643e 3c2f ce.
    │ │ │ -00043b50: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -00043b60: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -00043b90: 2f73 7263 2f74 6f72 7265 6e74 2e63 7070 /src/torrent.cpp │ │ │ -00043ba0: 3a37 3636 353c 2f61 3e3c 2f74 643e 3c74 :7665come up with a │ │ │ -00043bc0: 2062 6574 7465 7220 7761 7920 6f66 2064 better way of d │ │ │ -00043bd0: 6f69 6e67 2074 6869 732c 2069 6e73 7465 oing this, inste │ │ │ -00043be0: 6164 206f 6620 616e 2069 6d6d 6564 6961 ad of an immedia │ │ │ -00043bf0: 7465 6c79 2069 6e76 6f6b 6564 206c 616d tely invoked lam │ │ │ -00043c00: 6264 6120 6578 7072 6573 7369 6f6e 2e3c bda expression.< │ │ │ -00043c10: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    com │ │ │ -00043c60: 6520 7570 2077 6974 6820 6120 6265 7474 e up with a bett │ │ │ -00043c70: 6572 2077 6179 206f 6620 646f 696e 6720 er way of doing │ │ │ -00043c80: 7468 6973 2c20 696e 7374 6561 6420 6f66 this, instead of │ │ │ -00043c90: 2061 6e0a 696d 6d65 6469 6174 656c 7920 an.immediately │ │ │ -00043ca0: 696e 766f 6b65 6420 6c61 6d62 6461 2065 invoked lambda e │ │ │ -00043cb0: 7870 7265 7373 696f 6e2e 3c2f 6832 3e3c xpression.

    < │ │ │ -00043cc0: 6834 3e2e 2e2f 7372 632f 746f 7272 656e h4>../src/torren │ │ │ -00043cd0: 742e 6370 703a 3736 3635 3c2f 6834 3e3c t.cpp:7665< │ │ │ -00043ce0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00043cf0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00043d00: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00043d10: 7820 2364 6464 3b22 3e09 0909 0909 7c7c x #ddd;">.....|| │ │ │ -00043d20: 2070 6565 7269 6e66 6f2d 2667 743b 636f peerinfo->co │ │ │ -00043d30: 6e66 6972 6d65 645f 7375 7070 6f72 7473 nfirmed_supports │ │ │ -00043d40: 5f75 7470 2929 0a09 0909 7b0a 0909 0909 _utp))....{..... │ │ │ -00043d50: 736d 203d 206d 5f73 6573 2e75 7470 5f73 sm = m_ses.utp_s │ │ │ -00043d60: 6f63 6b65 745f 6d61 6e61 6765 7228 293b ocket_manager(); │ │ │ -00043d70: 0a09 0909 7d0a 0a09 0909 2f2f 2064 6f6e ....}.....// don │ │ │ -00043d80: 2774 206d 616b 6520 6120 5443 5020 636f 't make a TCP co │ │ │ -00043d90: 6e6e 6563 7469 6f6e 2069 6620 6974 2773 nnection if it's │ │ │ -00043da0: 2064 6973 6162 6c65 640a 0909 0969 6620 disabled....if │ │ │ -00043db0: 2873 6d20 3d3d 206e 756c 6c70 7472 2026 (sm == nullptr & │ │ │ -00043dc0: 616d 703b 2661 6d70 3b20 2173 6574 7469 amp;& !setti │ │ │ -00043dd0: 6e67 7328 292e 6765 745f 626f 6f6c 2873 ngs().get_bool(s │ │ │ -00043de0: 6574 7469 6e67 735f 7061 636b 3a3a 656e ettings_pack::en │ │ │ -00043df0: 6162 6c65 5f6f 7574 676f 696e 675f 7463 able_outgoing_tc │ │ │ -00043e00: 7029 290a 0909 097b 0a23 6966 6e64 6566 p))....{.#ifndef │ │ │ -00043e10: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ -00043e20: 5f4c 4f47 4749 4e47 0a09 0909 0969 6620 _LOGGING.....if │ │ │ -00043e30: 2873 686f 756c 645f 6c6f 6728 2929 0a09 (should_log()).. │ │ │ -00043e40: 0909 097b 0a09 0909 0909 6465 6275 675f ...{......debug_ │ │ │ -00043e50: 6c6f 6728 2264 6973 6361 7264 696e 6720 log("discarding │ │ │ -00043e60: 7065 6572 205c 2225 735c 223a 2054 4350 peer \"%s\": TCP │ │ │ -00043e70: 2063 6f6e 6e65 6374 696f 6e73 2064 6973 connections dis │ │ │ -00043e80: 6162 6c65 6420 220a 0909 0909 0909 225b abled "......."[ │ │ │ -00043e90: 2073 7570 706f 7274 732d 7574 703a 2025 supports-utp: % │ │ │ -00043ea0: 6420 5d22 2c20 7065 6572 696e 666f 2d26 d ]", peerinfo-& │ │ │ -00043eb0: 6774 3b74 6f5f 7374 7269 6e67 2829 2e63 gt;to_string().c │ │ │ -00043ec0: 5f73 7472 2829 0a09 0909 0909 092c 2070 _str()......., p │ │ │ -00043ed0: 6565 7269 6e66 6f2d 2667 743b 7375 7070 eerinfo->supp │ │ │ -00043ee0: 6f72 7473 5f75 7470 293b 0a09 0909 097d orts_utp);.....} │ │ │ -00043ef0: 0a23 656e 6469 660a 0909 0909 7265 7475 .#endif.....retu │ │ │ -00043f00: 726e 2066 616c 7365 3b0a 0909 097d 0a09 rn false;....}.. │ │ │ -00043f10: 097d 0a0a 3c64 6976 2073 7479 6c65 3d22 .}..
    ..aux::socket_ │ │ │ -00043f50: 7479 7065 2073 203d 205b 2661 6d70 3b5d type s = [&] │ │ │ -00043f60: 207b 0a3c 2f64 6976 3e0a 2369 6620 544f {.
    .#if TO │ │ │ -00043f70: 5252 454e 545f 5553 455f 4932 500a 0909 RRENT_USE_I2P... │ │ │ -00043f80: 6966 2028 7065 6572 696e 666f 2d26 6774 if (peerinfo-> │ │ │ -00043f90: 3b69 735f 6932 705f 6164 6472 290a 0909 ;is_i2p_addr)... │ │ │ -00043fa0: 7b0a 0909 092f 2f20 4974 2773 206e 6f74 {....// It's not │ │ │ -00043fb0: 2065 6e74 6972 656c 7920 6f62 7669 6f75 entirely obviou │ │ │ -00043fc0: 7320 7768 7920 7468 6973 2070 6565 7220 s why this peer │ │ │ -00043fd0: 636f 6e6e 6563 7469 6f6e 2069 7320 6e6f connection is no │ │ │ -00043fe0: 7420 6d61 726b 6564 2061 730a 0909 092f t marked as..../ │ │ │ -00043ff0: 2f20 6f6e 652e 2054 6865 206d 6169 6e20 / one. The main │ │ │ -00044000: 6665 6174 7572 6520 6f66 2061 2070 6565 feature of a pee │ │ │ -00044010: 7220 636f 6e6e 6563 7469 6f6e 2069 7320 r connection is │ │ │ -00044020: 7468 6174 2077 6865 7468 6572 206f 7220 that whether or │ │ │ -00044030: 6e6f 7420 7765 0a09 0909 2f2f 2070 726f not we....// pro │ │ │ -00044040: 7879 2069 7420 6973 2063 6f6e 6669 6775 xy it is configu │ │ │ -00044050: 7261 626c 652e 2057 6865 6e20 7765 2075 rable. When we u │ │ │ -00044060: 7365 2069 3270 2c20 7765 2077 616e 7420 se i2p, we want │ │ │ -00044070: 746f 2061 6c77 6179 7320 7072 6f78 0a09 to always prox.. │ │ │ -00044080: 0909 2f2f 2065 7665 7279 7468 696e 6720 ..// everything │ │ │ -00044090: 7669 6120 6932 702e 0a0a 0909 0961 7578 via i2p......aux │ │ │ -000440a0: 3a3a 7072 6f78 795f 7365 7474 696e 6773 ::proxy_settings │ │ │ -000440b0: 2070 726f 7879 3b0a 0909 0970 726f 7879 proxy;....proxy │ │ │ -000440c0: 2e68 6f73 746e 616d 6520 3d20 7365 7474 .hostname = sett │ │ │ -000440d0: 696e 6773 2829 2e67 6574 5f73 7472 2873 ings().get_str(s │ │ │ -000440e0: 6574 7469 6e67 735f 7061 636b 3a3a 6932 ettings_pack::i2 │ │ │ -000440f0: 705f 686f 7374 6e61 6d65 293b 0a09 0909 p_hostname);.... │ │ │ -00044100: 7072 6f78 792e 706f 7274 203d 2073 7464 proxy.port = std │ │ │ -00044110: 3a3a 7569 6e74 3136 5f74 2873 6574 7469 ::uint16_t(setti │ │ │ -00044120: 6e67 7328 292e 6765 745f 696e 7428 7365 ngs().get_int(se │ │ │ -00044130: 7474 696e 6773 5f70 6163 6b3a 3a69 3270 ttings_pack::i2p │ │ │ -00044140: 5f70 6f72 7429 293b 0a09 0909 7072 6f78 _port));....prox │ │ │ -00044150: 792e 7479 7065 203d 2073 6574 7469 6e67 y.type = setting │ │ │ -00044160: 735f 7061 636b 3a3a 6932 705f 7072 6f78 s_pack::i2p_prox │ │ │ -00044170: 793b 0a0a 0909 0961 7578 3a3a 736f 636b y;.....aux::sock │ │ │ -00044180: 6574 5f74 7970 6520 7265 7420 3d20 696e et_type ret = in │ │ │ -00044190: 7374 616e 7469 6174 655f 636f 6e6e 6563 stantiate_connec │ │ │ -000441a0: 7469 6f6e 286d 5f73 6573 2e67 6574 5f63 tion(m_ses.get_c │ │ │ -000441b0: 6f6e 7465 7874 2829 0a09 0909 092c 2070 ontext()....., p │ │ │ -000441c0: 726f 7879 2c20 6e75 6c6c 7074 722c 206e roxy, nullptr, n │ │ │ -000441d0: 756c 6c70 7472 2c20 6661 6c73 652c 2066 ullptr, false, f │ │ │ -000441e0: 616c 7365 293b 0a09 0909 6932 705f 7374 alse);....i2p_st │ │ │ -000441f0: 7265 616d 2661 6d70 3b20 7374 7220 3d20 ream& str = │ │ │ -00044200: 626f 6f73 743a 3a67 6574 266c 743b 6932 boost::get<i2 │ │ │ -00044210: 705f 7374 7265 616d 2667 743b 2872 6574 p_stream>(ret │ │ │ -00044220: 293b 0a09 0909 7374 722e 7365 745f 6c6f );....str.set_lo │ │ │ -00044230: 6361 6c5f 6932 705f 656e 6470 6f69 6e74 cal_i2p_endpoint │ │ │ -00044240: 286d 5f73 6573 2e6c 6f63 616c 5f69 3270 (m_ses.local_i2p │ │ │ -00044250: 5f65 6e64 706f 696e 7428 2929 3b0a 0909 _endpoint());... │ │ │ -00044260: 0973 7472 2e73 6574 5f64 6573 7469 6e61 .str.set_destina │ │ │ -00044270: 7469 6f6e 2873 7461 7469 635f 6361 7374 tion(static_cast │ │ │ -00044280: 266c 743b 6932 705f 7065 6572 2a26 6774 <i2p_peer*> │ │ │ -00044290: 3b28 7065 6572 696e 666f 292d 2667 743b ;(peerinfo)-> │ │ │ -000442a0: 6465 7374 2829 293b 0a09 0909 7374 722e dest());....str. │ │ │ -000442b0: 7365 745f 636f 6d6d 616e 6428 6932 705f set_command(i2p_ │ │ │ -000442c0: 7374 7265 616d 3a3a 636d 645f 636f 6e6e stream::cmd_conn │ │ │ -000442d0: 6563 7429 3b0a 0909 0973 7472 2e73 6574 ect);....str.set │ │ │ -000442e0: 5f73 6573 7369 6f6e 5f69 6428 6d5f 7365 _session_id(m_se │ │ │ -000442f0: 732e 6932 705f 7365 7373 696f 6e28 2929 s.i2p_session()) │ │ │ -00044300: 3b0a 0909 0972 6574 7572 6e20 7265 743b ;....return ret; │ │ │ -00044310: 0a09 097d 0a09 0965 6c73 650a 2365 6e64 ...}...else.#end │ │ │ -00044320: 6966 0a09 097b 0a09 0909 766f 6964 2a20 if...{....void* │ │ │ -00044330: 7573 6572 6461 7461 203d 206e 756c 6c70 userdata = nullp │ │ │ -00044340: 7472 3b0a 2369 6664 6566 2054 4f52 5245 tr;.#ifdef TORRE │ │ │ -00044350: 4e54 5f53 534c 5f50 4545 5253 0a09 0909 NT_SSL_PEERS.... │ │ │ -00044360: 6966 2028 6973 5f73 736c 5f74 6f72 7265 if (is_ssl_torre │ │ │ -00044370: 6e74 2829 290a 0909 097b 0a3c 2f70 7265 nt())....{.
    rele │ │ │ -000443b0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/tor │ │ │ -000443f0: 7265 6e74 2e63 7070 3a39 3331 313c 2f61 rent.cpp:9311perhap │ │ │ -00044410: 7320 3020 7368 6f75 6c64 2061 6374 7561 s 0 should actua │ │ │ -00044420: 6c6c 7920 6d65 616e 2030 3c2f 7464 3e3c lly mean 0< │ │ │ -00044430: 2f74 723e 3c74 7220 6964 3d22 3136 3722 /tr>

    perhaps │ │ │ -00044480: 3020 7368 6f75 6c64 2061 6374 7561 6c6c 0 should actuall │ │ │ -00044490: 7920 6d65 616e 2030 3c2f 6832 3e3c 6834 y mean 0

    ../src/torrent. │ │ │ -000444b0: 6370 703a 3933 3131 3c2f 6834 3e3c 7072 cpp:9311

    ..// fini │ │ │ -00044500: 7368 6564 2074 6f72 7265 6e74 7320 6d61 shed torrents ma │ │ │ -00044510: 7920 6e6f 7420 6368 616e 6765 2074 6865 y not change the │ │ │ -00044520: 6972 2071 7565 7565 2070 6f73 6974 696f ir queue positio │ │ │ -00044530: 6e73 2c20 6173 2069 7427 7320 7365 7420 ns, as it's set │ │ │ -00044540: 746f 0a09 092f 2f20 2d31 0a09 0969 6620 to...// -1...if │ │ │ -00044550: 2828 6d5f 6162 6f72 7420 7c7c 2069 735f ((m_abort || is_ │ │ │ -00044560: 6669 6e69 7368 6564 2829 2920 2661 6d70 finished()) & │ │ │ -00044570: 3b26 616d 703b 2070 2021 3d20 6e6f 5f70 ;& p != no_p │ │ │ -00044580: 6f73 2920 7265 7475 726e 3b0a 0a09 0954 os) return;....T │ │ │ -00044590: 4f52 5245 4e54 5f41 5353 4552 5428 2870 ORRENT_ASSERT((p │ │ │ -000445a0: 203d 3d20 6e6f 5f70 6f73 2920 3d3d 2069 == no_pos) == i │ │ │ -000445b0: 735f 6669 6e69 7368 6564 2829 0a09 0909 s_finished().... │ │ │ -000445c0: 7c7c 2028 216d 5f61 7574 6f5f 6d61 6e61 || (!m_auto_mana │ │ │ -000445d0: 6765 6420 2661 6d70 3b26 616d 703b 2070 ged && p │ │ │ -000445e0: 203d 3d20 6e6f 5f70 6f73 290a 0909 097c == no_pos)....| │ │ │ -000445f0: 7c20 286d 5f61 626f 7274 2026 616d 703b | (m_abort & │ │ │ -00044600: 2661 6d70 3b20 7020 3d3d 206e 6f5f 706f & p == no_po │ │ │ -00044610: 7329 0a09 0909 7c7c 2028 216d 5f61 6464 s)....|| (!m_add │ │ │ -00044620: 6564 2026 616d 703b 2661 6d70 3b20 7020 ed && p │ │ │ -00044630: 3d3d 206e 6f5f 706f 7329 293b 0a09 0969 == no_pos));...i │ │ │ -00044640: 6620 2870 203d 3d20 6d5f 7365 7175 656e f (p == m_sequen │ │ │ -00044650: 6365 5f6e 756d 6265 7229 2072 6574 7572 ce_number) retur │ │ │ -00044660: 6e3b 0a0a 0909 544f 5252 454e 545f 4153 n;....TORRENT_AS │ │ │ -00044670: 5345 5254 2870 2026 6774 3b3d 206e 6f5f SERT(p >= no_ │ │ │ -00044680: 706f 7329 3b0a 0a09 0973 7461 7465 5f75 pos);....state_u │ │ │ -00044690: 7064 6174 6564 2829 3b0a 0a09 096d 5f73 pdated();....m_s │ │ │ -000446a0: 6573 2e73 6574 5f71 7565 7565 5f70 6f73 es.set_queue_pos │ │ │ -000446b0: 6974 696f 6e28 7468 6973 2c20 7029 3b0a ition(this, p);. │ │ │ -000446c0: 097d 0a0a 0976 6f69 6420 746f 7272 656e .}...void torren │ │ │ -000446d0: 743a 3a73 6574 5f6d 6178 5f75 706c 6f61 t::set_max_uploa │ │ │ -000446e0: 6473 2869 6e74 206c 696d 6974 2c20 626f ds(int limit, bo │ │ │ -000446f0: 6f6c 2063 6f6e 7374 2073 7461 7465 5f75 ol const state_u │ │ │ -00044700: 7064 6174 6529 0a09 7b0a 0909 544f 5252 pdate)..{...TORR │ │ │ -00044710: 454e 545f 4153 5345 5254 2869 735f 7369 ENT_ASSERT(is_si │ │ │ -00044720: 6e67 6c65 5f74 6872 6561 6428 2929 3b0a ngle_thread());. │ │ │ -00044730: 3c64 6976 2073 7479 6c65 3d22 6261 636b
    .. │ │ │ -00044760: 6966 2028 6c69 6d69 7420 266c 743b 3d20 if (limit <= │ │ │ -00044770: 3029 206c 696d 6974 203d 2028 3120 266c 0) limit = (1 &l │ │ │ -00044780: 743b 266c 743b 2032 3429 202d 2031 3b0a t;< 24) - 1;. │ │ │ -00044790: 3c2f 6469 763e 0909 6966 2028 696e 7428
    ..if (int( │ │ │ -000447a0: 6d5f 6d61 785f 7570 6c6f 6164 7329 203d m_max_uploads) = │ │ │ -000447b0: 3d20 6c69 6d69 7429 2072 6574 7572 6e3b = limit) return; │ │ │ -000447c0: 0a09 0969 6620 2873 7461 7465 5f75 7064 ...if (state_upd │ │ │ -000447d0: 6174 6529 2073 7461 7465 5f75 7064 6174 ate) state_updat │ │ │ -000447e0: 6564 2829 3b0a 0909 6d5f 6d61 785f 7570 ed();...m_max_up │ │ │ -000447f0: 6c6f 6164 7320 3d20 6175 783a 3a6e 756d loads = aux::num │ │ │ -00044800: 6572 6963 5f63 6173 7426 6c74 3b73 7464 eric_cast<std │ │ │ -00044810: 3a3a 7569 6e74 3332 5f74 2667 743b 286c ::uint32_t>(l │ │ │ -00044820: 696d 6974 293b 0a23 6966 6e64 6566 2054 imit);.#ifndef T │ │ │ -00044830: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c ORRENT_DISABLE_L │ │ │ -00044840: 4f47 4749 4e47 0a09 0969 6620 2873 686f OGGING...if (sho │ │ │ -00044850: 756c 645f 6c6f 6728 2920 2661 6d70 3b26 uld_log() && │ │ │ -00044860: 616d 703b 2073 7461 7465 5f75 7064 6174 amp; state_updat │ │ │ -00044870: 6529 0a09 0909 6465 6275 675f 6c6f 6728 e)....debug_log( │ │ │ -00044880: 222a 2a2a 2073 6574 2d6d 6178 2d75 706c "*** set-max-upl │ │ │ -00044890: 6f61 6473 3a20 2564 222c 206d 5f6d 6178 oads: %d", m_max │ │ │ -000448a0: 5f75 706c 6f61 6473 293b 0a23 656e 6469 _uploads);.#endi │ │ │ -000448b0: 660a 0a09 0969 6620 2873 7461 7465 5f75 f....if (state_u │ │ │ -000448c0: 7064 6174 6529 0a09 0909 7365 745f 6e65 pdate)....set_ne │ │ │ -000448d0: 6564 5f73 6176 655f 7265 7375 6d65 2874 ed_save_resume(t │ │ │ -000448e0: 6f72 7265 6e74 5f68 616e 646c 653a 3a69 orrent_handle::i │ │ │ -000448f0: 665f 636f 6e66 6967 5f63 6861 6e67 6564 f_config_changed │ │ │ -00044900: 293b 0a09 7d0a 0a09 766f 6964 2074 6f72 );..}...void tor │ │ │ -00044910: 7265 6e74 3a3a 7365 745f 6d61 785f 636f rent::set_max_co │ │ │ -00044920: 6e6e 6563 7469 6f6e 7328 696e 7420 6c69 nnections(int li │ │ │ -00044930: 6d69 742c 2062 6f6f 6c20 636f 6e73 7420 mit, bool const │ │ │ -00044940: 7374 6174 655f 7570 6461 7465 290a 097b state_update)..{ │ │ │ -00044950: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -00044960: 5428 6973 5f73 696e 676c 655f 7468 7265 T(is_single_thre │ │ │ -00044970: 6164 2829 293b 0a3c 2f70 7265 3e3c 2f74 ad());.
    relevanc │ │ │ -000449b0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/torrent │ │ │ -000449f0: 2e63 7070 3a39 3332 383c 2f61 3e3c 2f74 .cpp:9328perhaps 0 │ │ │ -00044a10: 7368 6f75 6c64 2061 6374 7561 6c6c 7920 should actually │ │ │ -00044a20: 6d65 616e 2030 3c2f 7464 3e3c 2f74 723e mean 0 │ │ │ -00044a30: 3c74 7220 6964 3d22 3136 3822 2073 7479 │ │ │ -00044a60: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00044a70: 3c68 323e 7065 7268 6170 7320 3020 7368

    perhaps 0 sh │ │ │ -00044a80: 6f75 6c64 2061 6374 7561 6c6c 7920 6d65 ould actually me │ │ │ -00044a90: 616e 2030 3c2f 6832 3e3c 6834 3e2e 2e2f an 0

    ../ │ │ │ -00044aa0: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ -00044ab0: 3933 3238 3c2f 6834 3e3c 7072 6520 7374 9328

    ..void torren
    │ │ │ -00044b00: 743a 3a73 6574 5f6d 6178 5f75 706c 6f61  t::set_max_uploa
    │ │ │ -00044b10: 6473 2869 6e74 206c 696d 6974 2c20 626f  ds(int limit, bo
    │ │ │ -00044b20: 6f6c 2063 6f6e 7374 2073 7461 7465 5f75  ol const state_u
    │ │ │ -00044b30: 7064 6174 6529 0a09 7b0a 0909 544f 5252  pdate)..{...TORR
    │ │ │ -00044b40: 454e 545f 4153 5345 5254 2869 735f 7369  ENT_ASSERT(is_si
    │ │ │ -00044b50: 6e67 6c65 5f74 6872 6561 6428 2929 3b0a  ngle_thread());.
    │ │ │ -00044b60: 0909 6966 2028 6c69 6d69 7420 266c 743b  ..if (limit <
    │ │ │ -00044b70: 3d20 3029 206c 696d 6974 203d 2028 3120  = 0) limit = (1 
    │ │ │ -00044b80: 266c 743b 266c 743b 2032 3429 202d 2031  << 24) - 1
    │ │ │ -00044b90: 3b0a 0909 6966 2028 696e 7428 6d5f 6d61  ;...if (int(m_ma
    │ │ │ -00044ba0: 785f 7570 6c6f 6164 7329 203d 3d20 6c69  x_uploads) == li
    │ │ │ -00044bb0: 6d69 7429 2072 6574 7572 6e3b 0a09 0969  mit) return;...i
    │ │ │ -00044bc0: 6620 2873 7461 7465 5f75 7064 6174 6529  f (state_update)
    │ │ │ -00044bd0: 2073 7461 7465 5f75 7064 6174 6564 2829   state_updated()
    │ │ │ -00044be0: 3b0a 0909 6d5f 6d61 785f 7570 6c6f 6164  ;...m_max_upload
    │ │ │ -00044bf0: 7320 3d20 6175 783a 3a6e 756d 6572 6963  s = aux::numeric
    │ │ │ -00044c00: 5f63 6173 7426 6c74 3b73 7464 3a3a 7569  _cast<std::ui
    │ │ │ -00044c10: 6e74 3332 5f74 2667 743b 286c 696d 6974  nt32_t>(limit
    │ │ │ -00044c20: 293b 0a23 6966 6e64 6566 2054 4f52 5245  );.#ifndef TORRE
    │ │ │ -00044c30: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749  NT_DISABLE_LOGGI
    │ │ │ -00044c40: 4e47 0a09 0969 6620 2873 686f 756c 645f  NG...if (should_
    │ │ │ -00044c50: 6c6f 6728 2920 2661 6d70 3b26 616d 703b  log() &&
    │ │ │ -00044c60: 2073 7461 7465 5f75 7064 6174 6529 0a09   state_update)..
    │ │ │ -00044c70: 0909 6465 6275 675f 6c6f 6728 222a 2a2a  ..debug_log("***
    │ │ │ -00044c80: 2073 6574 2d6d 6178 2d75 706c 6f61 6473   set-max-uploads
    │ │ │ -00044c90: 3a20 2564 222c 206d 5f6d 6178 5f75 706c  : %d", m_max_upl
    │ │ │ -00044ca0: 6f61 6473 293b 0a23 656e 6469 660a 0a09  oads);.#endif...
    │ │ │ -00044cb0: 0969 6620 2873 7461 7465 5f75 7064 6174  .if (state_updat
    │ │ │ -00044cc0: 6529 0a09 0909 7365 745f 6e65 6564 5f73  e)....set_need_s
    │ │ │ -00044cd0: 6176 655f 7265 7375 6d65 2874 6f72 7265  ave_resume(torre
    │ │ │ -00044ce0: 6e74 5f68 616e 646c 653a 3a69 665f 636f  nt_handle::if_co
    │ │ │ -00044cf0: 6e66 6967 5f63 6861 6e67 6564 293b 0a09  nfig_changed);..
    │ │ │ -00044d00: 7d0a 0a09 766f 6964 2074 6f72 7265 6e74  }...void torrent
    │ │ │ -00044d10: 3a3a 7365 745f 6d61 785f 636f 6e6e 6563  ::set_max_connec
    │ │ │ -00044d20: 7469 6f6e 7328 696e 7420 6c69 6d69 742c  tions(int limit,
    │ │ │ -00044d30: 2062 6f6f 6c20 636f 6e73 7420 7374 6174   bool const stat
    │ │ │ -00044d40: 655f 7570 6461 7465 290a 097b 0a09 0954  e_update)..{...T
    │ │ │ -00044d50: 4f52 5245 4e54 5f41 5353 4552 5428 6973  ORRENT_ASSERT(is
    │ │ │ -00044d60: 5f73 696e 676c 655f 7468 7265 6164 2829  _single_thread()
    │ │ │ -00044d70: 293b 0a3c 6469 7620 7374 796c 653d 2262  );.
    ..if (limit < │ │ │ -00044db0: 3b3d 2030 2920 6c69 6d69 7420 3d20 2831 ;= 0) limit = (1 │ │ │ -00044dc0: 2026 6c74 3b26 6c74 3b20 3234 2920 2d20 << 24) - │ │ │ -00044dd0: 313b 0a3c 2f64 6976 3e09 0969 6620 2869 1;.
    ..if (i │ │ │ -00044de0: 6e74 286d 5f6d 6178 5f63 6f6e 6e65 6374 nt(m_max_connect │ │ │ -00044df0: 696f 6e73 2920 3d3d 206c 696d 6974 2920 ions) == limit) │ │ │ -00044e00: 7265 7475 726e 3b0a 0909 6966 2028 7374 return;...if (st │ │ │ -00044e10: 6174 655f 7570 6461 7465 2920 7374 6174 ate_update) stat │ │ │ -00044e20: 655f 7570 6461 7465 6428 293b 0a09 096d e_updated();...m │ │ │ -00044e30: 5f6d 6178 5f63 6f6e 6e65 6374 696f 6e73 _max_connections │ │ │ -00044e40: 203d 2061 7578 3a3a 6e75 6d65 7269 635f = aux::numeric_ │ │ │ -00044e50: 6361 7374 266c 743b 7374 643a 3a75 696e cast<std::uin │ │ │ -00044e60: 7433 325f 7426 6774 3b28 6c69 6d69 7429 t32_t>(limit) │ │ │ -00044e70: 3b0a 0909 7570 6461 7465 5f77 616e 745f ;...update_want_ │ │ │ -00044e80: 7065 6572 7328 293b 0a0a 2369 666e 6465 peers();..#ifnde │ │ │ -00044e90: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ -00044ea0: 455f 4c4f 4747 494e 470a 0909 6966 2028 E_LOGGING...if ( │ │ │ -00044eb0: 7368 6f75 6c64 5f6c 6f67 2829 2026 616d should_log() &am │ │ │ -00044ec0: 703b 2661 6d70 3b20 7374 6174 655f 7570 p;& state_up │ │ │ -00044ed0: 6461 7465 290a 0909 0964 6562 7567 5f6c date)....debug_l │ │ │ -00044ee0: 6f67 2822 2a2a 2a20 7365 742d 6d61 782d og("*** set-max- │ │ │ -00044ef0: 636f 6e6e 6563 7469 6f6e 733a 2025 6422 connections: %d" │ │ │ -00044f00: 2c20 6d5f 6d61 785f 636f 6e6e 6563 7469 , m_max_connecti │ │ │ -00044f10: 6f6e 7329 3b0a 2365 6e64 6966 0a0a 0909 ons);.#endif.... │ │ │ -00044f20: 6966 2028 6e75 6d5f 7065 6572 7328 2920 if (num_peers() │ │ │ -00044f30: 2667 743b 2069 6e74 286d 5f6d 6178 5f63 > int(m_max_c │ │ │ -00044f40: 6f6e 6e65 6374 696f 6e73 2929 0a09 097b onnections))...{ │ │ │ -00044f50: 0a09 0909 6469 7363 6f6e 6e65 6374 5f70 ....disconnect_p │ │ │ -00044f60: 6565 7273 286e 756d 5f70 6565 7273 2829 eers(num_peers() │ │ │ -00044f70: 202d 206d 5f6d 6178 5f63 6f6e 6e65 6374 - m_max_connect │ │ │ -00044f80: 696f 6e73 0a09 0909 092c 2065 7272 6f72 ions....., error │ │ │ -00044f90: 733a 3a74 6f6f 5f6d 616e 795f 636f 6e6e s::too_many_conn │ │ │ -00044fa0: 6563 7469 6f6e 7329 3b0a 0909 7d0a 0a09 ections);...}... │ │ │ -00044fb0: 0969 6620 2873 7461 7465 5f75 7064 6174 .if (state_updat │ │ │ -00044fc0: 6529 0a09 0909 7365 745f 6e65 6564 5f73 e)....set_need_s │ │ │ -00044fd0: 6176 655f 7265 7375 6d65 2874 6f72 7265 ave_resume(torre │ │ │ -00044fe0: 6e74 5f68 616e 646c 653a 3a69 665f 636f nt_handle::if_co │ │ │ -00044ff0: 6e66 6967 5f63 6861 6e67 6564 293b 0a09 nfig_changed);.. │ │ │ -00045000: 7d0a 0a09 766f 6964 2074 6f72 7265 6e74 }...void torrent │ │ │ -00045010: 3a3a 7365 745f 7570 6c6f 6164 5f6c 696d ::set_upload_lim │ │ │ -00045020: 6974 2869 6e74 2063 6f6e 7374 206c 696d it(int const lim │ │ │ -00045030: 6974 290a 097b 0a09 0973 6574 5f6c 696d it)..{...set_lim │ │ │ -00045040: 6974 5f69 6d70 6c28 6c69 6d69 742c 2070 it_impl(limit, p │ │ │ -00045050: 6565 725f 636f 6e6e 6563 7469 6f6e 3a3a eer_connection:: │ │ │ -00045060: 7570 6c6f 6164 5f63 6861 6e6e 656c 293b upload_channel); │ │ │ -00045070: 0a23 6966 6e64 6566 2054 4f52 5245 4e54 .#ifndef TORRENT │ │ │ -00045080: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47 _DISABLE_LOGGING │ │ │ -00045090: 0a09 0964 6562 7567 5f6c 6f67 2822 2a2a ...debug_log("** │ │ │ -000450a0: 2a20 7365 742d 7570 6c6f 6164 2d6c 696d * set-upload-lim │ │ │ -000450b0: 6974 3a20 2564 222c 206c 696d 6974 293b it: %d", limit); │ │ │ -000450c0: 0a23 656e 6469 660a 097d 0a0a 0976 6f69 .#endif..}...voi │ │ │ -000450d0: 6420 746f 7272 656e 743a 3a73 6574 5f64 d torrent::set_d │ │ │ -000450e0: 6f77 6e6c 6f61 645f 6c69 6d69 7428 696e ownload_limit(in │ │ │ -000450f0: 7420 636f 6e73 7420 6c69 6d69 7429 0a09 t const limit).. │ │ │ -00045100: 7b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 {.
    < │ │ │ -00045130: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00045140: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00045170: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ -00045180: 3131 3237 303c 2f61 3e3c 2f74 643e 3c74 11270instead of res │ │ │ -000451a0: 6f72 7469 6e67 2074 6865 2077 686f 6c65 orting the whole │ │ │ -000451b0: 206c 6973 742c 2069 6e73 6572 7420 7468 list, insert th │ │ │ -000451c0: 6520 7065 6572 7320 6469 7265 6374 6c79 e peers directly │ │ │ -000451d0: 2069 6e74 6f20 7468 6520 7269 6768 7420 into the right │ │ │ -000451e0: 706c 6163 653c 2f74 643e 3c2f 7472 3e3c place< │ │ │ -000451f0: 7472 2069 643d 2231 3639 2220 7374 796c tr id="169" styl │ │ │ -00045200: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00045210: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00045220: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00045230: 6832 3e69 6e73 7465 6164 206f 6620 7265 h2>instead of re │ │ │ -00045240: 736f 7274 696e 6720 7468 6520 7768 6f6c sorting the whol │ │ │ -00045250: 6520 6c69 7374 2c20 696e 7365 7274 2074 e list, insert t │ │ │ -00045260: 6865 2070 6565 7273 0a64 6972 6563 746c he peers.directl │ │ │ -00045270: 7920 696e 746f 2074 6865 2072 6967 6874 y into the right │ │ │ -00045280: 2070 6c61 6365 3c2f 6832 3e3c 6834 3e2e place

    . │ │ │ -00045290: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ -000452a0: 703a 3131 3237 303c 2f68 343e 3c70 7265 p:11270

    ....std::p
    │ │ │ -000452f0: 7269 6e74 6628 2274 696d 6564 206f 7574  rintf("timed out
    │ │ │ -00045300: 205b 6176 6572 6167 652d 7069 6563 652d   [average-piece-
    │ │ │ -00045310: 7469 6d65 3a20 2564 206d 7320 5d5c 6e22  time: %d ms ]\n"
    │ │ │ -00045320: 0a09 0909 0909 2c20 6d5f 6176 6572 6167  ......, m_averag
    │ │ │ -00045330: 655f 7069 6563 655f 7469 6d65 293b 0a23  e_piece_time);.#
    │ │ │ -00045340: 656e 6469 660a 0909 097d 0a0a 0909 092f  endif....}...../
    │ │ │ -00045350: 2f20 7069 636b 2061 6c6c 2062 6c6f 636b  / pick all block
    │ │ │ -00045360: 7320 666f 7220 7468 6973 2070 6965 6365  s for this piece
    │ │ │ -00045370: 2e20 7468 6520 7065 6572 7320 6c69 7374  . the peers list
    │ │ │ -00045380: 2069 7320 6b65 7074 2075 7020 746f 2064   is kept up to d
    │ │ │ -00045390: 6174 650a 0909 092f 2f20 616e 6420 736f  ate....// and so
    │ │ │ -000453a0: 7274 6564 2e20 7768 656e 2077 6520 6973  rted. when we is
    │ │ │ -000453b0: 7375 6520 6120 7265 7175 6573 7420 746f  sue a request to
    │ │ │ -000453c0: 2061 2070 6565 722c 2069 7473 2064 6f77   a peer, its dow
    │ │ │ -000453d0: 6e6c 6f61 6420 7175 6575 650a 0909 092f  nload queue..../
    │ │ │ -000453e0: 2f20 7469 6d65 2077 696c 6c20 696e 6372  / time will incr
    │ │ │ -000453f0: 6561 7365 2061 6e64 2069 7420 6d61 7920  ease and it may 
    │ │ │ -00045400: 6e65 6564 2074 6f20 6265 2062 756d 7065  need to be bumpe
    │ │ │ -00045410: 6420 696e 2074 6865 2070 6565 7273 206c  d in the peers l
    │ │ │ -00045420: 6973 742c 0a09 0909 2f2f 2073 696e 6365  ist,....// since
    │ │ │ -00045430: 2069 7427 7320 6f72 6465 7265 6420 6279   it's ordered by
    │ │ │ -00045440: 2064 6f77 6e6c 6f61 6420 7175 6575 6520   download queue 
    │ │ │ -00045450: 7469 6d65 0a09 0909 7069 636b 5f74 696d  time....pick_tim
    │ │ │ -00045460: 655f 6372 6974 6963 616c 5f62 6c6f 636b  e_critical_block
    │ │ │ -00045470: 2870 6565 7273 2c20 6967 6e6f 7265 5f70  (peers, ignore_p
    │ │ │ -00045480: 6565 7273 0a09 0909 092c 2070 6565 7273  eers....., peers
    │ │ │ -00045490: 5f77 6974 685f 7265 7175 6573 7473 0a09  _with_requests..
    │ │ │ -000454a0: 0909 092c 2070 692c 2026 616d 703b 692c  ..., pi, &i,
    │ │ │ -000454b0: 206d 5f70 6963 6b65 722e 6765 7428 290a   m_picker.get().
    │ │ │ -000454c0: 0909 0909 2c20 626c 6f63 6b73 5f69 6e5f  ...., blocks_in_
    │ │ │ -000454d0: 7069 6563 652c 2074 696d 6564 5f6f 7574  piece, timed_out
    │ │ │ -000454e0: 293b 0a0a 0909 092f 2f20 7075 7420 6261  );.....// put ba
    │ │ │ -000454f0: 636b 2074 6865 2070 6565 7273 2077 6520  ck the peers we 
    │ │ │ -00045500: 6967 6e6f 7265 6420 696e 746f 2074 6865  ignored into the
    │ │ │ -00045510: 2070 6565 7220 6c69 7374 2066 6f72 2074   peer list for t
    │ │ │ -00045520: 6865 206e 6578 7420 7069 6563 650a 0909  he next piece...
    │ │ │ -00045530: 0969 6620 2821 6967 6e6f 7265 5f70 6565  .if (!ignore_pee
    │ │ │ -00045540: 7273 2e65 6d70 7479 2829 290a 0909 097b  rs.empty())....{
    │ │ │ -00045550: 0a09 0909 0970 6565 7273 2e69 6e73 6572  .....peers.inser
    │ │ │ -00045560: 7428 7065 6572 732e 6265 6769 6e28 292c  t(peers.begin(),
    │ │ │ -00045570: 2069 676e 6f72 655f 7065 6572 732e 6265   ignore_peers.be
    │ │ │ -00045580: 6769 6e28 292c 2069 676e 6f72 655f 7065  gin(), ignore_pe
    │ │ │ -00045590: 6572 732e 656e 6428 2929 3b0a 0909 0909  ers.end());.....
    │ │ │ -000455a0: 6967 6e6f 7265 5f70 6565 7273 2e63 6c65  ignore_peers.cle
    │ │ │ -000455b0: 6172 2829 3b0a 0a3c 6469 7620 7374 796c  ar();..
    ....std::so │ │ │ -000455f0: 7274 2870 6565 7273 2e62 6567 696e 2829 rt(peers.begin() │ │ │ -00045600: 2c20 7065 6572 732e 656e 6428 290a 3c2f , peers.end()......, [] (p │ │ │ -00045620: 6565 725f 636f 6e6e 6563 7469 6f6e 2063 eer_connection c │ │ │ -00045630: 6f6e 7374 2a20 6c68 732c 2070 6565 725f onst* lhs, peer_ │ │ │ -00045640: 636f 6e6e 6563 7469 6f6e 2063 6f6e 7374 connection const │ │ │ -00045650: 2a20 7268 7329 0a09 0909 0909 7b20 7265 * rhs)......{ re │ │ │ -00045660: 7475 726e 206c 6873 2d26 6774 3b64 6f77 turn lhs->dow │ │ │ -00045670: 6e6c 6f61 645f 7175 6575 655f 7469 6d65 nload_queue_time │ │ │ -00045680: 2831 362a 3130 3234 2920 266c 743b 2072 (16*1024) < r │ │ │ -00045690: 6873 2d26 6774 3b64 6f77 6e6c 6f61 645f hs->download_ │ │ │ -000456a0: 7175 6575 655f 7469 6d65 2831 362a 3130 queue_time(16*10 │ │ │ -000456b0: 3234 293b 207d 293b 0a09 0909 7d0a 0a09 24); });....}... │ │ │ -000456c0: 0909 2f2f 2069 6620 7468 6973 2070 6565 ..// if this pee │ │ │ -000456d0: 7227 7320 646f 776e 6c6f 6164 2074 696d r's download tim │ │ │ -000456e0: 6520 6578 6365 6564 7320 3220 7365 636f e exceeds 2 seco │ │ │ -000456f0: 6e64 732c 2077 6527 7265 2064 6f6e 652e nds, we're done. │ │ │ -00045700: 0a09 0909 2f2f 2057 6520 646f 6e27 7420 ....// We don't │ │ │ -00045710: 7761 6e74 2074 6f20 6275 696c 6420 756e want to build un │ │ │ -00045720: 7265 6173 6f6e 6162 6c79 206c 6f6e 6720 reasonably long │ │ │ -00045730: 7265 7175 6573 7420 7175 6575 6573 0a09 request queues.. │ │ │ -00045740: 0909 6966 2028 2170 6565 7273 2e65 6d70 ..if (!peers.emp │ │ │ -00045750: 7479 2829 2026 616d 703b 2661 6d70 3b20 ty() && │ │ │ -00045760: 7065 6572 735b 305d 2d26 6774 3b64 6f77 peers[0]->dow │ │ │ -00045770: 6e6c 6f61 645f 7175 6575 655f 7469 6d65 nload_queue_time │ │ │ -00045780: 2829 2026 6774 3b20 6d69 6c6c 6973 6563 () > millisec │ │ │ -00045790: 6f6e 6473 2832 3030 3029 290a 0909 0909 onds(2000))..... │ │ │ -000457a0: 6272 6561 6b3b 0a09 097d 0a0a 0909 2f2f break;...}....// │ │ │ -000457b0: 2063 6f6d 6d69 7420 616c 6c20 7468 6520 commit all the │ │ │ -000457c0: 7469 6d65 2063 7269 7469 6361 6c20 7265 time critical re │ │ │ -000457d0: 7175 6573 7473 0a09 0966 6f72 2028 6175 quests...for (au │ │ │ -000457e0: 746f 2070 203a 2070 6565 7273 5f77 6974 to p : peers_wit │ │ │ -000457f0: 685f 7265 7175 6573 7473 290a 0909 7b0a h_requests)...{. │ │ │ -00045800: 0909 0970 2d26 6774 3b73 656e 645f 626c ...p->send_bl │ │ │ -00045810: 6f63 6b5f 7265 7175 6573 7473 2829 3b0a ock_requests();. │ │ │ -00045820: 0909 7d0a 097d 0a23 656e 6469 6620 2f2f ..}..}.#endif // │ │ │ -00045830: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ -00045840: 5f53 5452 4541 4d49 4e47 0a0a 0973 7464 _STREAMING...std │ │ │ -00045850: 3a3a 7365 7426 6c74 3b73 7464 3a3a 7374 ::set<std::st │ │ │ -00045860: 7269 6e67 2667 743b 2074 6f72 7265 6e74 ring> torrent │ │ │ -00045870: 3a3a 7765 625f 7365 6564 7328 7765 625f ::web_seeds(web_ │ │ │ -00045880: 7365 6564 5f65 6e74 7279 3a3a 7479 7065 seed_entry::type │ │ │ -00045890: 5f74 2063 6f6e 7374 2074 7970 6529 2063 _t const type) c │ │ │ -000458a0: 6f6e 7374 0a09 7b0a 0909 544f 5252 454e onst..{...TORREN │ │ │ -000458b0: 545f 4153 5345 5254 2869 735f 7369 6e67 T_ASSERT(is_sing │ │ │ -000458c0: 6c65 5f74 6872 6561 6428 2929 3b0a 0909 le_thread());... │ │ │ -000458d0: 7374 643a 3a73 6574 266c 743b 7374 643a std::set<std: │ │ │ -000458e0: 3a73 7472 696e 6726 6774 3b20 7265 743b :string> ret; │ │ │ -000458f0: 0a09 0966 6f72 2028 6175 746f 2063 6f6e ...for (auto con │ │ │ -00045900: 7374 2661 6d70 3b20 7320 3a20 6d5f 7765 st& s : m_we │ │ │ -00045910: 625f 7365 6564 7329 0a09 097b 0a09 0909 b_seeds)...{.... │ │ │ -00045920: 6966 2028 732e 7065 6572 5f69 6e66 6f2e if (s.peer_info. │ │ │ -00045930: 6261 6e6e 6564 2920 636f 6e74 696e 7565 banned) continue │ │ │ -00045940: 3b0a 0909 0969 6620 2873 2e72 656d 6f76 ;....if (s.remov │ │ │ -00045950: 6564 2920 636f 6e74 696e 7565 3b0a 0909 ed) continue;... │ │ │ -00045960: 0969 6620 2873 2e74 7970 6520 213d 2074 .if (s.type != t │ │ │ -00045970: 7970 6529 2063 6f6e 7469 6e75 653b 0a09 ype) continue;.. │ │ │ -00045980: 0909 7265 742e 696e 7365 7274 2873 2e75 ..ret.insert(s.u │ │ │ -00045990: 726c 293b 0a09 097d 0a09 0972 6574 7572 rl);...}...retur │ │ │ -000459a0: 6e20 7265 743b 0a3c 2f70 7265 3e3c 2f74 n ret;.
    relevanc │ │ │ -000459e0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/storage │ │ │ -00045a20: 5f75 7469 6c73 2e63 7070 3a32 3331 3c2f _utils.cpp:231ideal │ │ │ -00045a40: 6c79 2c20 6966 2077 6520 656e 6420 7570 ly, if we end up │ │ │ -00045a50: 2063 6f70 7969 6e67 2066 696c 6573 2062 copying files b │ │ │ -00045a60: 6563 6175 7365 206f 6620 6120 6d6f 7665 ecause of a move │ │ │ -00045a70: 2061 6372 6f73 7320 766f 6c75 6d65 732c across volumes, │ │ │ -00045a80: 2074 6865 2073 6f75 7263 6520 7368 6f75 the source shou │ │ │ -00045a90: 6c64 206e 6f74 2062 6520 6465 6c65 7465 ld not be delete │ │ │ -00045aa0: 6420 756e 7469 6c20 7468 6579 2776 6520 d until they've │ │ │ -00045ab0: 616c 6c20 6265 656e 2063 6f70 6965 642e all been copied. │ │ │ -00045ac0: 2054 6861 7420 776f 756c 6420 6c65 7420 That would let │ │ │ -00045ad0: 7573 2072 6f6c 6c62 6163 6b20 7769 7468 us rollback with │ │ │ -00045ae0: 2068 6967 6865 7220 636f 6e66 6964 656e higher confiden │ │ │ -00045af0: 6365 2e3c 2f74 643e 3c2f 7472 3e3c 7472 ce.

    ideally, if we │ │ │ -00045b50: 656e 6420 7570 2063 6f70 7969 6e67 2066 end up copying f │ │ │ -00045b60: 696c 6573 2062 6563 6175 7365 206f 6620 iles because of │ │ │ -00045b70: 6120 6d6f 7665 2061 6372 6f73 730a 766f a move across.vo │ │ │ -00045b80: 6c75 6d65 732c 2074 6865 2073 6f75 7263 lumes, the sourc │ │ │ -00045b90: 6520 7368 6f75 6c64 206e 6f74 2062 6520 e should not be │ │ │ -00045ba0: 6465 6c65 7465 6420 756e 7469 6c20 7468 deleted until th │ │ │ -00045bb0: 6579 2776 6520 616c 6c20 6265 656e 0a63 ey've all been.c │ │ │ -00045bc0: 6f70 6965 642e 2054 6861 7420 776f 756c opied. That woul │ │ │ -00045bd0: 6420 6c65 7420 7573 2072 6f6c 6c62 6163 d let us rollbac │ │ │ -00045be0: 6b20 7769 7468 2068 6967 6865 7220 636f k with higher co │ │ │ -00045bf0: 6e66 6964 656e 6365 2e3c 2f68 323e 3c68 nfidence.

    ../src/storage │ │ │ -00045c10: 5f75 7469 6c73 2e63 7070 3a32 3331 3c2f _utils.cpp:231
    ../
    │ │ │ -00045c60: 2f20 6c61 7465 720a 0909 6175 783a 3a76  / later...aux::v
    │ │ │ -00045c70: 6563 746f 7226 6c74 3b62 6f6f 6c2c 2066  ector<bool, f
    │ │ │ -00045c80: 696c 655f 696e 6465 785f 7426 6774 3b20  ile_index_t> 
    │ │ │ -00045c90: 636f 7069 6564 5f66 696c 6573 2873 7464  copied_files(std
    │ │ │ -00045ca0: 3a3a 7369 7a65 5f74 2866 2e6e 756d 5f66  ::size_t(f.num_f
    │ │ │ -00045cb0: 696c 6573 2829 292c 2066 616c 7365 293b  iles()), false);
    │ │ │ -00045cc0: 0a0a 0909 2f2f 2074 7261 636b 2068 6f77  ....// track how
    │ │ │ -00045cd0: 2066 6172 2077 6520 676f 7420 696e 2063   far we got in c
    │ │ │ -00045ce0: 6173 6520 6f66 2061 6e20 6572 726f 720a  ase of an error.
    │ │ │ -00045cf0: 0909 6669 6c65 5f69 6e64 6578 5f74 2066  ..file_index_t f
    │ │ │ -00045d00: 696c 655f 696e 6465 787b 7d3b 0a09 0966  ile_index{};...f
    │ │ │ -00045d10: 6f72 2028 6175 746f 2063 6f6e 7374 2069  or (auto const i
    │ │ │ -00045d20: 203a 2066 2e66 696c 655f 7261 6e67 6528   : f.file_range(
    │ │ │ -00045d30: 2929 0a09 097b 0a09 0909 2f2f 2066 696c  ))...{....// fil
    │ │ │ -00045d40: 6573 206d 6f76 6564 206f 7574 2074 6f20  es moved out to 
    │ │ │ -00045d50: 6162 736f 6c75 7465 2070 6174 6873 2061  absolute paths a
    │ │ │ -00045d60: 7265 206e 6f74 206d 6f76 6564 0a09 0909  re not moved....
    │ │ │ -00045d70: 6966 2028 662e 6669 6c65 5f61 6273 6f6c  if (f.file_absol
    │ │ │ -00045d80: 7574 655f 7061 7468 2869 2929 2063 6f6e  ute_path(i)) con
    │ │ │ -00045d90: 7469 6e75 653b 0a0a 0909 0973 7464 3a3a  tinue;.....std::
    │ │ │ -00045da0: 7374 7269 6e67 2063 6f6e 7374 206f 6c64  string const old
    │ │ │ -00045db0: 5f70 6174 6820 3d20 636f 6d62 696e 655f  _path = combine_
    │ │ │ -00045dc0: 7061 7468 2873 6176 655f 7061 7468 2c20  path(save_path, 
    │ │ │ -00045dd0: 662e 6669 6c65 5f70 6174 6828 6929 293b  f.file_path(i));
    │ │ │ -00045de0: 0a09 0909 7374 643a 3a73 7472 696e 6720  ....std::string 
    │ │ │ -00045df0: 636f 6e73 7420 6e65 775f 7061 7468 203d  const new_path =
    │ │ │ -00045e00: 2063 6f6d 6269 6e65 5f70 6174 6828 6e65   combine_path(ne
    │ │ │ -00045e10: 775f 7361 7665 5f70 6174 682c 2066 2e66  w_save_path, f.f
    │ │ │ -00045e20: 696c 655f 7061 7468 2869 2929 3b0a 0a09  ile_path(i));...
    │ │ │ -00045e30: 0909 6572 726f 725f 636f 6465 2069 676e  ..error_code ign
    │ │ │ -00045e40: 6f72 653b 0a09 0909 6966 2028 666c 6167  ore;....if (flag
    │ │ │ -00045e50: 7320 3d3d 206d 6f76 655f 666c 6167 735f  s == move_flags_
    │ │ │ -00045e60: 743a 3a64 6f6e 745f 7265 706c 6163 6520  t::dont_replace 
    │ │ │ -00045e70: 2661 6d70 3b26 616d 703b 2065 7869 7374  && exist
    │ │ │ -00045e80: 7328 6e65 775f 7061 7468 2c20 6967 6e6f  s(new_path, igno
    │ │ │ -00045e90: 7265 2929 0a09 0909 7b0a 0909 0909 6966  re))....{.....if
    │ │ │ -00045ea0: 2028 7265 7420 3d3d 2073 7461 7475 735f   (ret == status_
    │ │ │ -00045eb0: 743a 3a6e 6f5f 6572 726f 7229 2072 6574  t::no_error) ret
    │ │ │ -00045ec0: 203d 2073 7461 7475 735f 743a 3a6e 6565   = status_t::nee
    │ │ │ -00045ed0: 645f 6675 6c6c 5f63 6865 636b 3b0a 0909  d_full_check;...
    │ │ │ -00045ee0: 0909 636f 6e74 696e 7565 3b0a 0909 097d  ..continue;....}
    │ │ │ -00045ef0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -00045f20: 0909 096d 6f76 655f 6669 6c65 286f 6c64 ...move_file(old │ │ │ -00045f30: 5f70 6174 682c 206e 6577 5f70 6174 682c _path, new_path, │ │ │ -00045f40: 2065 6329 3b0a 3c2f 6469 763e 0a09 0909 ec);.
    .... │ │ │ -00045f50: 2f2f 2069 6620 7468 6520 736f 7572 6365 // if the source │ │ │ -00045f60: 2066 696c 6520 646f 6573 6e27 7420 6578 file doesn't ex │ │ │ -00045f70: 6973 742e 2054 6861 7427 7320 6e6f 7420 ist. That's not │ │ │ -00045f80: 6120 7072 6f62 6c65 6d0a 0909 092f 2f20 a problem....// │ │ │ -00045f90: 7765 206a 7573 7420 6967 6e6f 7265 2074 we just ignore t │ │ │ -00045fa0: 6861 7420 6669 6c65 0a09 0909 6966 2028 hat file....if ( │ │ │ -00045fb0: 6563 2e65 6320 3d3d 2062 6f6f 7374 3a3a ec.ec == boost:: │ │ │ -00045fc0: 7379 7374 656d 3a3a 6572 7263 3a3a 6e6f system::errc::no │ │ │ -00045fd0: 5f73 7563 685f 6669 6c65 5f6f 725f 6469 _such_file_or_di │ │ │ -00045fe0: 7265 6374 6f72 7929 0a09 0909 0965 632e rectory).....ec. │ │ │ -00045ff0: 6563 2e63 6c65 6172 2829 3b0a 0909 0965 ec.clear();....e │ │ │ -00046000: 6c73 6520 6966 2028 6563 0a09 0909 0926 lse if (ec.....& │ │ │ -00046010: 616d 703b 2661 6d70 3b20 6563 2e65 6320 amp;& ec.ec │ │ │ -00046020: 213d 2062 6f6f 7374 3a3a 7379 7374 656d != boost::system │ │ │ -00046030: 3a3a 6572 7263 3a3a 696e 7661 6c69 645f ::errc::invalid_ │ │ │ -00046040: 6172 6775 6d65 6e74 0a09 0909 0926 616d argument.....&am │ │ │ -00046050: 703b 2661 6d70 3b20 6563 2e65 6320 213d p;& ec.ec != │ │ │ -00046060: 2062 6f6f 7374 3a3a 7379 7374 656d 3a3a boost::system:: │ │ │ -00046070: 6572 7263 3a3a 7065 726d 6973 7369 6f6e errc::permission │ │ │ -00046080: 5f64 656e 6965 6429 0a09 0909 7b0a 0909 _denied)....{... │ │ │ -00046090: 0909 2f2f 206d 6f76 696e 6720 7468 6520 ..// moving the │ │ │ -000460a0: 6669 6c65 2066 6169 6c65 640a 0909 0909 file failed..... │ │ │ -000460b0: 2f2f 206f 6e20 4f53 582c 2074 6865 2065 // on OSX, the e │ │ │ -000460c0: 7272 6f72 2077 6865 6e20 7472 7969 6e67 rror when trying │ │ │ -000460d0: 2074 6f20 7265 6e61 6d65 2061 2066 696c to rename a fil │ │ │ -000460e0: 6520 6163 726f 7373 2064 6966 6665 7265 e across differe │ │ │ -000460f0: 6e74 0a09 0909 092f 2f20 766f 6c75 6d65 nt.....// volume │ │ │ -00046100: 7320 6973 2045 5844 4556 2c20 7768 6963 s is EXDEV, whic │ │ │ -00046110: 6820 7769 6c6c 206d 616b 6520 6974 2066 h will make it f │ │ │ -00046120: 616c 6c20 6261 636b 2074 6f20 636f 7079 all back to copy │ │ │ -00046130: 696e 672e 0a09 0909 0965 632e 6563 2e63 ing......ec.ec.c │ │ │ -00046140: 6c65 6172 2829 3b0a 0909 0909 636f 7079 lear();.....copy │ │ │ -00046150: 5f66 696c 6528 6f6c 645f 7061 7468 2c20 _file(old_path, │ │ │ -00046160: 6e65 775f 7061 7468 2c20 6563 293b 0a09 new_path, ec);.. │ │ │ -00046170: 0909 0969 6620 2821 6563 2920 636f 7069 ...if (!ec) copi │ │ │ -00046180: 6564 5f66 696c 6573 5b69 5d20 3d20 7472 ed_files[i] = tr │ │ │ -00046190: 7565 3b0a 0909 097d 0a0a 0909 0969 6620 ue;....}.....if │ │ │ -000461a0: 2865 6329 0a09 0909 7b0a 0909 0909 6563 (ec)....{.....ec │ │ │ -000461b0: 2e66 696c 6528 6929 3b0a 0909 0909 6669 .file(i);.....fi │ │ │ -000461c0: 6c65 5f69 6e64 6578 203d 2069 3b0a 0909 le_index = i;... │ │ │ -000461d0: 0909 6272 6561 6b3b 0a09 0909 7d0a 0909 ..break;....}... │ │ │ -000461e0: 7d0a 0a09 0969 6620 2821 6563 2026 616d }....if (!ec &am │ │ │ -000461f0: 703b 2661 6d70 3b20 6d6f 7665 5f70 6172 p;& move_par │ │ │ -00046200: 7466 696c 6529 0a09 097b 0a09 0909 6572 tfile)...{....er │ │ │ -00046210: 726f 725f 636f 6465 2065 3b0a 0909 096d ror_code e;....m │ │ │ -00046220: 6f76 655f 7061 7274 6669 6c65 286e 6577 ove_partfile(new │ │ │ -00046230: 5f73 6176 655f 7061 7468 2c20 6529 3b0a _save_path, e);. │ │ │ -00046240: 0909 0969 6620 2865 290a 3c2f 7072 653e ...if (e).
    │ │ │ -00046250: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -00046280: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00046290: 3c74 643e 3c61 2068 7265 663d 226a 6176
    ../src/stor │ │ │ -000462c0: 6167 655f 7574 696c 732e 6370 703a 3533 age_utils.cpp:53 │ │ │ -000462d0: 393c 2f61 3e3c 2f74 643e 3c74 643e 6974 9it │ │ │ -000462e0: 2077 6f75 6c64 2073 6565 6d20 7265 6173 would seem reas │ │ │ -000462f0: 6f6e 6162 6c65 2074 6f2c 2069 6e73 7465 onable to, inste │ │ │ -00046300: 6164 2c20 7365 7420 7468 6520 6861 7665 ad, set the have │ │ │ -00046310: 5f70 6965 6365 7320 6269 7473 2066 6f72 _pieces bits for │ │ │ -00046320: 2074 6865 2070 6965 6365 7320 7265 7072 the pieces repr │ │ │ -00046330: 6573 656e 7469 6e67 2074 6865 7365 2066 esenting these f │ │ │ -00046340: 696c 6573 2c20 616e 6420 7265 7375 6d65 iles, and resume │ │ │ -00046350: 2077 6974 6820 7468 6520 6e6f 726d 616c with the normal │ │ │ -00046360: 206c 6f67 6963 3c2f 7464 3e3c 2f74 723e logic │ │ │ -00046370: 3c74 7220 6964 3d22 3137 3122 2073 7479 │ │ │ -000463a0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -000463b0: 3c68 323e 6974 2077 6f75 6c64 2073 6565

    it would see │ │ │ -000463c0: 6d20 7265 6173 6f6e 6162 6c65 2074 6f2c m reasonable to, │ │ │ -000463d0: 2069 6e73 7465 6164 2c20 7365 7420 7468 instead, set th │ │ │ -000463e0: 6520 6861 7665 5f70 6965 6365 7320 6269 e have_pieces bi │ │ │ -000463f0: 7473 0a66 6f72 2074 6865 2070 6965 6365 ts.for the piece │ │ │ -00046400: 7320 7265 7072 6573 656e 7469 6e67 2074 s representing t │ │ │ -00046410: 6865 7365 2066 696c 6573 2c20 616e 6420 hese files, and │ │ │ -00046420: 7265 7375 6d65 2077 6974 6820 7468 6520 resume with the │ │ │ -00046430: 6e6f 726d 616c 0a6c 6f67 6963 3c2f 6832 normal.logic

    ../src/stor │ │ │ -00046450: 6167 655f 7574 696c 732e 6370 703a 3533 age_utils.cpp:53 │ │ │ -00046460: 393c 2f68 343e 3c70 7265 2073 7479 6c65 9

    │ │ │ -000464a0: 0909 0909 0963 6f6e 7469 6e75 653b 0a0a  .....continue;..
    │ │ │ -000464b0: 0909 0909 7374 643a 3a69 6e74 3634 5f74  ....std::int64_t
    │ │ │ -000464c0: 2063 6f6e 7374 2073 697a 6520 3d20 6765   const size = ge
    │ │ │ -000464d0: 745f 6669 6c65 7369 7a65 2873 7461 742c  t_filesize(stat,
    │ │ │ -000464e0: 2066 696c 655f 696e 6465 782c 2066 730a   file_index, fs.
    │ │ │ -000464f0: 0909 0909 092c 2073 6176 655f 7061 7468  ....., save_path
    │ │ │ -00046500: 2c20 6563 293b 0a09 0909 0969 6620 2873  , ec);.....if (s
    │ │ │ -00046510: 697a 6520 266c 743b 2030 2920 7265 7475  ize < 0) retu
    │ │ │ -00046520: 726e 2066 616c 7365 3b0a 0a09 0909 0969  rn false;......i
    │ │ │ -00046530: 6620 2873 697a 6520 266c 743b 2066 732e  f (size < fs.
    │ │ │ -00046540: 6669 6c65 5f73 697a 6528 6669 6c65 5f69  file_size(file_i
    │ │ │ -00046550: 6e64 6578 2929 0a09 0909 097b 0a09 0909  ndex)).....{....
    │ │ │ -00046560: 0909 6563 2e65 6320 3d20 6572 726f 7273  ..ec.ec = errors
    │ │ │ -00046570: 3a3a 6d69 736d 6174 6368 696e 675f 6669  ::mismatching_fi
    │ │ │ -00046580: 6c65 5f73 697a 653b 0a09 0909 0909 6563  le_size;......ec
    │ │ │ -00046590: 2e66 696c 6528 6669 6c65 5f69 6e64 6578  .file(file_index
    │ │ │ -000465a0: 293b 0a09 0909 0909 6563 2e6f 7065 7261  );......ec.opera
    │ │ │ -000465b0: 7469 6f6e 203d 206f 7065 7261 7469 6f6e  tion = operation
    │ │ │ -000465c0: 5f74 3a3a 6368 6563 6b5f 7265 7375 6d65  _t::check_resume
    │ │ │ -000465d0: 3b0a 0909 0909 0972 6574 7572 6e20 6661  ;......return fa
    │ │ │ -000465e0: 6c73 653b 0a09 0909 097d 0a09 0909 7d0a  lse;.....}....}.
    │ │ │ -000465f0: 0909 0972 6574 7572 6e20 7472 7565 3b0a  ...return true;.
    │ │ │ -00046600: 0909 7d0a 0a23 6966 6e64 6566 2054 4f52  ..}..#ifndef TOR
    │ │ │ -00046610: 5245 4e54 5f44 4953 4142 4c45 5f4d 5554  RENT_DISABLE_MUT
    │ │ │ -00046620: 4142 4c45 5f54 4f52 5245 4e54 530a 0909  ABLE_TORRENTS...
    │ │ │ -00046630: 2f2f 2061 6c77 6179 7320 7472 6967 6765  // always trigge
    │ │ │ -00046640: 7220 6120 6675 6c6c 2072 6563 6865 636b  r a full recheck
    │ │ │ -00046650: 2077 6865 6e20 7765 2070 756c 6c20 696e   when we pull in
    │ │ │ -00046660: 2066 696c 6573 2066 726f 6d20 6f74 6865   files from othe
    │ │ │ -00046670: 720a 0909 2f2f 2074 6f72 7265 6e74 732c  r...// torrents,
    │ │ │ -00046680: 2076 6961 2068 6172 6420 6c69 6e6b 730a   via hard links.
    │ │ │ -00046690: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ -000466c0: 6966 2028 6164 6465 645f 6669 6c65 7329 if (added_files) │ │ │ -000466d0: 2072 6574 7572 6e20 6661 6c73 653b 0a3c return false;.< │ │ │ -000466e0: 2f64 6976 3e23 656e 6469 660a 0a09 092f /div>#endif..../ │ │ │ -000466f0: 2f20 7061 7273 6520 6861 7665 2062 6974 / parse have bit │ │ │ -00046700: 6d61 736b 2e20 5665 7269 6679 2074 6861 mask. Verify tha │ │ │ -00046710: 7420 6669 6c65 7320 746f 7563 6865 6420 t files touched │ │ │ -00046720: 6279 2063 6f6d 706c 6574 6564 2070 6965 by completed pie │ │ │ -00046730: 6365 730a 0909 2f2f 2061 6374 7561 6c6c ces...// actuall │ │ │ -00046740: 7920 6578 6973 742e 2041 2063 6f6d 706c y exist. A compl │ │ │ -00046750: 6574 6564 2070 6965 6365 206d 6179 2073 eted piece may s │ │ │ -00046760: 7061 6e20 6d75 6c74 6970 6c65 2066 696c pan multiple fil │ │ │ -00046770: 6573 2e0a 0909 666f 7220 2866 696c 655f es....for (file_ │ │ │ -00046780: 696e 6465 785f 7420 636f 6e73 7420 6669 index_t const fi │ │ │ -00046790: 6c65 5f69 6e64 6578 203a 2066 732e 6669 le_index : fs.fi │ │ │ -000467a0: 6c65 5f72 616e 6765 2829 290a 0909 7b0a le_range())...{. │ │ │ -000467b0: 0909 092f 2f20 6669 6c65 7320 7769 7468 ...// files with │ │ │ -000467c0: 2070 7269 6f72 6974 7920 7a65 726f 206d priority zero m │ │ │ -000467d0: 6179 206e 6f74 2068 6176 6520 6265 656e ay not have been │ │ │ -000467e0: 2073 6176 6564 2074 6f20 6469 736b 2061 saved to disk a │ │ │ -000467f0: 7420 7468 6569 720a 0909 092f 2f20 6578 t their....// ex │ │ │ -00046800: 7065 6374 6564 206c 6f63 6174 696f 6e2c pected location, │ │ │ -00046810: 2062 7574 2069 7320 6c69 6b65 6c79 2074 but is likely t │ │ │ -00046820: 6f20 6265 2069 6e20 6120 7061 7274 6669 o be in a partfi │ │ │ -00046830: 6c65 2e20 4a75 7374 2065 7865 6d70 7420 le. Just exempt │ │ │ -00046840: 6974 0a09 0909 2f2f 2066 726f 6d20 6368 it....// from ch │ │ │ -00046850: 6563 6b69 6e67 0a09 0909 6966 2028 6669 ecking....if (fi │ │ │ -00046860: 6c65 5f69 6e64 6578 2026 6c74 3b20 6669 le_index < fi │ │ │ -00046870: 6c65 5f70 7269 6f72 6974 792e 656e 645f le_priority.end_ │ │ │ -00046880: 696e 6465 7828 290a 0909 0909 2661 6d70 index().....& │ │ │ -00046890: 3b26 616d 703b 2066 696c 655f 7072 696f ;& file_prio │ │ │ -000468a0: 7269 7479 5b66 696c 655f 696e 6465 785d rity[file_index] │ │ │ -000468b0: 203d 3d20 646f 6e74 5f64 6f77 6e6c 6f61 == dont_downloa │ │ │ -000468c0: 6429 0a09 0909 0963 6f6e 7469 6e75 653b d).....continue; │ │ │ -000468d0: 0a0a 0909 0969 6620 2866 732e 7061 645f .....if (fs.pad_ │ │ │ -000468e0: 6669 6c65 5f61 7428 6669 6c65 5f69 6e64 file_at(file_ind │ │ │ -000468f0: 6578 2929 2063 6f6e 7469 6e75 653b 0a09 ex)) continue;.. │ │ │ -00046900: 0909 6966 2028 6673 2e66 696c 655f 7369 ..if (fs.file_si │ │ │ -00046910: 7a65 2866 696c 655f 696e 6465 7829 203d ze(file_index) = │ │ │ -00046920: 3d20 3029 2063 6f6e 7469 6e75 653b 0a0a = 0) continue;.. │ │ │ -00046930: 0909 0970 6965 6365 5f69 6e64 6578 5f74 ...piece_index_t │ │ │ -00046940: 2073 7461 7274 5f70 6965 6365 3b0a 0909 start_piece;... │ │ │ -00046950: 0970 6965 6365 5f69 6e64 6578 5f74 2066 .piece_index_t f │ │ │ -00046960: 696c 655f 656e 645f 7069 6563 653b 0a09 ile_end_piece;.. │ │ │ -00046970: 0909 7374 643a 3a74 6965 2873 7461 7274 ..std::tie(start │ │ │ -00046980: 5f70 6965 6365 2c20 6669 6c65 5f65 6e64 _piece, file_end │ │ │ -00046990: 5f70 6965 6365 290a 0909 0909 3d20 6175 _piece).....= au │ │ │ -000469a0: 783a 3a66 696c 655f 7069 6563 655f 7261 x::file_piece_ra │ │ │ -000469b0: 6e67 655f 696e 636c 7573 6976 6528 6673 nge_inclusive(fs │ │ │ -000469c0: 2c20 6669 6c65 5f69 6e64 6578 293b 0a0a , file_index);.. │ │ │ -000469d0: 0909 0970 6965 6365 5f69 6e64 6578 5f74 ...piece_index_t │ │ │ -000469e0: 2063 6f6e 7374 2065 6e64 5f70 6965 6365 const end_piece │ │ │ -000469f0: 203d 2073 7464 3a3a 6d69 6e28 6669 6c65 = std::min(file │ │ │ -00046a00: 5f65 6e64 5f70 6965 6365 0a09 0909 092c _end_piece....., │ │ │ -00046a10: 2072 642e 6861 7665 5f70 6965 6365 732e rd.have_pieces. │ │ │ -00046a20: 656e 645f 696e 6465 7828 2929 3b0a 0a09 end_index());... │ │ │ -00046a30: 0909 626f 6f6c 2068 6173 5f63 6f6d 706c ..bool has_compl │ │ │ -00046a40: 6574 6564 5f72 6573 756d 655f 7069 6563 eted_resume_piec │ │ │ -00046a50: 6520 3d20 6661 6c73 653b 0a09 0909 666f e = false;....fo │ │ │ -00046a60: 7220 2870 6965 6365 5f69 6e64 6578 5f74 r (piece_index_t │ │ │ -00046a70: 2070 6965 6365 203d 2073 7461 7274 5f70 piece = start_p │ │ │ -00046a80: 6965 6365 3b20 7069 6563 6520 266c 743b iece; piece < │ │ │ -00046a90: 2065 6e64 5f70 6965 6365 3b20 2b2b 7069 end_piece; ++pi │ │ │ -00046aa0: 6563 6529 0a09 0909 7b0a 0909 0909 6966 ece)....{.....if │ │ │ -00046ab0: 2028 2172 642e 6861 7665 5f70 6965 6365 (!rd.have_piece │ │ │ -00046ac0: 732e 6765 745f 6269 7428 7069 6563 6529 s.get_bit(piece) │ │ │ -00046ad0: 2920 636f 6e74 696e 7565 3b0a 0909 0909 ) continue;..... │ │ │ -00046ae0: 6861 735f 636f 6d70 6c65 7465 645f 7265 has_completed_re │ │ │ -00046af0: 7375 6d65 5f70 6965 6365 203d 2074 7275 sume_piece = tru │ │ │ -00046b00: 653b 0a09 0909 0962 7265 616b 3b0a 3c2f e;.....break;.r │ │ │ -00046b40: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -00046b50: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -00046b80: 736d 6172 745f 6261 6e2e 6370 703a 3137 smart_ban.cpp:17 │ │ │ -00046b90: 383c 2f61 3e3c 2f74 643e 3c74 643e 7265 8re │ │ │ -00046ba0: 706c 6163 6520 7769 7468 2073 7464 3a3a place with std:: │ │ │ -00046bb0: 6572 6173 655f 6966 2829 206f 6e63 6520 erase_if() once │ │ │ -00046bc0: 7765 2072 6571 7569 7265 2043 2b2b 3230 we require C++20 │ │ │ -00046bd0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    re │ │ │ -00046c20: 706c 6163 6520 7769 7468 2073 7464 3a3a place with std:: │ │ │ -00046c30: 6572 6173 655f 6966 2829 206f 6e63 6520 erase_if() once │ │ │ -00046c40: 7765 2072 6571 7569 7265 2043 2b2b 3230 we require C++20 │ │ │ -00046c50: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -00046c60: 736d 6172 745f 6261 6e2e 6370 703a 3137 smart_ban.cpp:17 │ │ │ -00046c70: 383c 2f68 343e 3c70 7265 2073 7479 6c65 8

    │ │ │ -00046cb0: 0909 0909 0909 2c20 6469 736b 5f69 6e74  ......, disk_int
    │ │ │ -00046cc0: 6572 6661 6365 3a3a 666f 7263 655f 636f  erface::force_co
    │ │ │ -00046cd0: 7079 293b 0a09 0909 097d 0a0a 0909 0909  py);.....}......
    │ │ │ -00046ce0: 722e 7374 6172 7420 2b3d 2031 362a 3130  r.start += 16*10
    │ │ │ -00046cf0: 3234 3b0a 0909 0909 7369 7a65 202d 3d20  24;.....size -= 
    │ │ │ -00046d00: 3136 2a31 3032 343b 0a09 0909 0972 2e6c  16*1024;.....r.l
    │ │ │ -00046d10: 656e 6774 6820 3d20 7374 643a 3a6d 696e  ength = std::min
    │ │ │ -00046d20: 2831 362a 3130 3234 2c20 7369 7a65 293b  (16*1024, size);
    │ │ │ -00046d30: 0a09 0909 092b 2b70 622e 626c 6f63 6b5f  .....++pb.block_
    │ │ │ -00046d40: 696e 6465 783b 0a09 0909 7d0a 0909 0954  index;....}....T
    │ │ │ -00046d50: 4f52 5245 4e54 5f41 5353 4552 5428 7369  ORRENT_ASSERT(si
    │ │ │ -00046d60: 7a65 2026 6c74 3b3d 2030 293b 0a09 097d  ze <= 0);...}
    │ │ │ -00046d70: 0a0a 0909 2f2f 206e 6f74 2064 6563 6c61  ....// not decla
    │ │ │ -00046d80: 7265 6420 6f6e 2074 6f72 7265 6e74 5f70  red on torrent_p
    │ │ │ -00046d90: 6c75 6769 6e20 2877 6f75 6c64 2072 6571  lugin (would req
    │ │ │ -00046da0: 7569 7265 2061 6e20 4142 492d 6272 6561  uire an ABI-brea
    │ │ │ -00046db0: 6b69 6e67 206e 6577 0a09 092f 2f20 7669  king new...// vi
    │ │ │ -00046dc0: 7274 7561 6c29 2e20 4361 6c6c 6564 2076  rtual). Called v
    │ │ │ -00046dd0: 6961 2061 2064 6f77 6e63 6173 7420 696e  ia a downcast in
    │ │ │ -00046de0: 2074 6f72 7265 6e74 3a3a 7065 6572 735f   torrent::peers_
    │ │ │ -00046df0: 6572 6173 6564 2829 20e2 8094 2073 6565  erased() ... see
    │ │ │ -00046e00: 0a09 092f 2f20 736d 6172 745f 6261 6e5f  ...// smart_ban_
    │ │ │ -00046e10: 6e6f 7469 6679 5f65 7261 7365 5f70 6565  notify_erase_pee
    │ │ │ -00046e20: 7273 2829 2062 656c 6f77 0a09 0976 6f69  rs() below...voi
    │ │ │ -00046e30: 6420 6f6e 5f65 7261 7365 5f70 6565 7273  d on_erase_peers
    │ │ │ -00046e40: 2873 7061 6e26 6c74 3b74 6f72 7265 6e74  (span<torrent
    │ │ │ -00046e50: 5f70 6565 722a 2063 6f6e 7374 2667 743b  _peer* const>
    │ │ │ -00046e60: 2070 6565 7273 290a 0909 7b0a 0909 0969   peers)...{....i
    │ │ │ -00046e70: 6620 286d 5f62 6c6f 636b 5f68 6173 6865  f (m_block_hashe
    │ │ │ -00046e80: 732e 656d 7074 7928 2920 7c7c 2070 6565  s.empty() || pee
    │ │ │ -00046e90: 7273 2e65 6d70 7479 2829 2920 7265 7475  rs.empty()) retu
    │ │ │ -00046ea0: 726e 3b0a 0a09 0909 7374 643a 3a76 6563  rn;.....std::vec
    │ │ │ -00046eb0: 746f 7226 6c74 3b74 6f72 7265 6e74 5f70  tor<torrent_p
    │ │ │ -00046ec0: 6565 722a 2667 743b 2065 7261 7365 6428  eer*> erased(
    │ │ │ -00046ed0: 7065 6572 732e 6265 6769 6e28 292c 2070  peers.begin(), p
    │ │ │ -00046ee0: 6565 7273 2e65 6e64 2829 293b 0a09 0909  eers.end());....
    │ │ │ -00046ef0: 7374 643a 3a73 6f72 7428 6572 6173 6564  std::sort(erased
    │ │ │ -00046f00: 2e62 6567 696e 2829 2c20 6572 6173 6564  .begin(), erased
    │ │ │ -00046f10: 2e65 6e64 2829 293b 0a3c 6469 7620 7374  .end());.
    ...for (a │ │ │ -00046f50: 7574 6f20 6920 3d20 6d5f 626c 6f63 6b5f uto i = m_block_ │ │ │ -00046f60: 6861 7368 6573 2e62 6567 696e 2829 3b20 hashes.begin(); │ │ │ -00046f70: 6920 213d 206d 5f62 6c6f 636b 5f68 6173 i != m_block_has │ │ │ -00046f80: 6865 732e 656e 6428 293b 290a 3c2f 6469 hes.end();)....{.....if (s │ │ │ -00046fa0: 7464 3a3a 6269 6e61 7279 5f73 6561 7263 td::binary_searc │ │ │ -00046fb0: 6828 6572 6173 6564 2e62 6567 696e 2829 h(erased.begin() │ │ │ -00046fc0: 2c20 6572 6173 6564 2e65 6e64 2829 2c20 , erased.end(), │ │ │ -00046fd0: 692d 2667 743b 7365 636f 6e64 2e70 6565 i->second.pee │ │ │ -00046fe0: 7229 290a 0909 0909 0969 203d 206d 5f62 r))......i = m_b │ │ │ -00046ff0: 6c6f 636b 5f68 6173 6865 732e 6572 6173 lock_hashes.eras │ │ │ -00047000: 6528 6929 3b0a 0909 0909 656c 7365 0a09 e(i);.....else.. │ │ │ -00047010: 0909 0909 2b2b 693b 0a09 0909 7d0a 0909 ....++i;....}... │ │ │ -00047020: 7d0a 0a09 7072 6976 6174 653a 0a0a 0909 }...private:.... │ │ │ -00047030: 2f2f 2074 6869 7320 656e 7472 7920 7469 // this entry ti │ │ │ -00047040: 6573 2061 2073 7065 6369 6669 6320 626c es a specific bl │ │ │ -00047050: 6f63 6b20 4352 4320 746f 0a09 092f 2f20 ock CRC to...// │ │ │ -00047060: 6120 7065 6572 2e0a 0909 7374 7275 6374 a peer....struct │ │ │ -00047070: 2062 6c6f 636b 5f65 6e74 7279 0a09 097b block_entry...{ │ │ │ -00047080: 0a09 0909 746f 7272 656e 745f 7065 6572 ....torrent_peer │ │ │ -00047090: 2a20 7065 6572 3b0a 0909 0973 6861 315f * peer;....sha1_ │ │ │ -000470a0: 6861 7368 2064 6967 6573 743b 0a09 097d hash digest;...} │ │ │ -000470b0: 3b0a 0a09 0976 6f69 6420 6f6e 5f72 6561 ;....void on_rea │ │ │ -000470c0: 645f 6661 696c 6564 5f62 6c6f 636b 2870 d_failed_block(p │ │ │ -000470d0: 6965 6365 5f62 6c6f 636b 2063 6f6e 7374 iece_block const │ │ │ -000470e0: 2062 2c20 6164 6472 6573 7320 636f 6e73 b, address cons │ │ │ -000470f0: 7420 610a 0909 092c 2064 6973 6b5f 6275 t a...., disk_bu │ │ │ -00047100: 6666 6572 5f68 6f6c 6465 7220 6275 6666 ffer_holder buff │ │ │ -00047110: 6572 2c20 696e 7420 636f 6e73 7420 626c er, int const bl │ │ │ -00047120: 6f63 6b5f 7369 7a65 0a09 0909 2c20 7374 ock_size...., st │ │ │ -00047130: 6f72 6167 655f 6572 726f 7220 636f 6e73 orage_error cons │ │ │ -00047140: 7426 616d 703b 2065 7272 6f72 290a 0909 t& error)... │ │ │ -00047150: 7b0a 0909 0954 4f52 5245 4e54 5f41 5353 {....TORRENT_ASS │ │ │ -00047160: 4552 5428 6d5f 746f 7272 656e 742e 7365 ERT(m_torrent.se │ │ │ -00047170: 7373 696f 6e28 292e 6973 5f73 696e 676c ssion().is_singl │ │ │ -00047180: 655f 7468 7265 6164 2829 293b 0a0a 0909 e_thread());.... │ │ │ -00047190: 092f 2f20 6967 6e6f 7265 2072 6561 6420 .// ignore read │ │ │ -000471a0: 6572 726f 7273 0a09 0909 6966 2028 6572 errors....if (er │ │ │ -000471b0: 726f 7229 2072 6574 7572 6e3b 0a0a 0909 ror) return;.... │ │ │ -000471c0: 0968 6173 6865 7220 683b 0a09 0909 682e .hasher h;....h. │ │ │ -000471d0: 7570 6461 7465 287b 6275 6666 6572 2e64 update({buffer.d │ │ │ -000471e0: 6174 6128 292c 2062 6c6f 636b 5f73 697a ata(), block_siz │ │ │ -000471f0: 657d 293b 0a0a 3c2f 7072 653e 3c2f 7464 e});..
    relevance │ │ │ -00047230: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -00047240: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/settings │ │ │ -00047270: 5f70 6163 6b2e 6370 703a 3330 393c 2f61 _pack.cpp:309deprec │ │ │ -00047290: 6174 6520 7468 6973 3c2f 7464 3e3c 2f74 ate this

    deprecate │ │ │ -000472f0: 7468 6973 3c2f 6832 3e3c 6834 3e2e 2e2f this

    ../ │ │ │ -00047300: 7372 632f 7365 7474 696e 6773 5f70 6163 src/settings_pac │ │ │ -00047310: 6b2e 6370 703a 3330 393c 2f68 343e 3c70 k.cpp:309

    ..SET(ou │ │ │ -00047360: 7467 6f69 6e67 5f70 6f72 742c 2030 2c20 tgoing_port, 0, │ │ │ -00047370: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428 nullptr),...SET( │ │ │ -00047380: 6e75 6d5f 6f75 7467 6f69 6e67 5f70 6f72 num_outgoing_por │ │ │ -00047390: 7473 2c20 302c 206e 756c 6c70 7472 292c ts, 0, nullptr), │ │ │ -000473a0: 0a09 0953 4554 2870 6565 725f 6473 6370 ...SET(peer_dscp │ │ │ -000473b0: 2c20 3078 3031 2c20 2661 6d70 3b73 6573 , 0x01, &ses │ │ │ -000473c0: 7369 6f6e 5f69 6d70 6c3a 3a75 7064 6174 sion_impl::updat │ │ │ -000473d0: 655f 7065 6572 5f64 7363 7029 2c0a 0909 e_peer_dscp),... │ │ │ -000473e0: 5345 5428 6163 7469 7665 5f64 6f77 6e6c SET(active_downl │ │ │ -000473f0: 6f61 6473 2c20 332c 2026 616d 703b 7365 oads, 3, &se │ │ │ -00047400: 7373 696f 6e5f 696d 706c 3a3a 7472 6967 ssion_impl::trig │ │ │ -00047410: 6765 725f 6175 746f 5f6d 616e 6167 6529 ger_auto_manage) │ │ │ -00047420: 2c0a 0909 5345 5428 6163 7469 7665 5f73 ,...SET(active_s │ │ │ -00047430: 6565 6473 2c20 352c 2026 616d 703b 7365 eeds, 5, &se │ │ │ -00047440: 7373 696f 6e5f 696d 706c 3a3a 7472 6967 ssion_impl::trig │ │ │ -00047450: 6765 725f 6175 746f 5f6d 616e 6167 6529 ger_auto_manage) │ │ │ -00047460: 2c0a 0909 5345 5428 6163 7469 7665 5f63 ,...SET(active_c │ │ │ -00047470: 6865 636b 696e 672c 2031 2c20 2661 6d70 hecking, 1, & │ │ │ -00047480: 3b73 6573 7369 6f6e 5f69 6d70 6c3a 3a74 ;session_impl::t │ │ │ -00047490: 7269 6767 6572 5f61 7574 6f5f 6d61 6e61 rigger_auto_mana │ │ │ -000474a0: 6765 292c 0a09 0953 4554 2861 6374 6976 ge),...SET(activ │ │ │ -000474b0: 655f 6468 745f 6c69 6d69 742c 2038 382c e_dht_limit, 88, │ │ │ -000474c0: 206e 756c 6c70 7472 292c 0a09 0953 4554 nullptr),...SET │ │ │ -000474d0: 2861 6374 6976 655f 7472 6163 6b65 725f (active_tracker_ │ │ │ -000474e0: 6c69 6d69 742c 2031 3630 302c 206e 756c limit, 1600, nul │ │ │ -000474f0: 6c70 7472 292c 0a09 0953 4554 2861 6374 lptr),...SET(act │ │ │ -00047500: 6976 655f 6c73 645f 6c69 6d69 742c 2036 ive_lsd_limit, 6 │ │ │ -00047510: 302c 206e 756c 6c70 7472 292c 0a09 0953 0, nullptr),...S │ │ │ -00047520: 4554 2861 6374 6976 655f 6c69 6d69 742c ET(active_limit, │ │ │ -00047530: 2035 3030 2c20 2661 6d70 3b73 6573 7369 500, &sessi │ │ │ -00047540: 6f6e 5f69 6d70 6c3a 3a74 7269 6767 6572 on_impl::trigger │ │ │ -00047550: 5f61 7574 6f5f 6d61 6e61 6765 292c 0a09 _auto_manage),.. │ │ │ -00047560: 0944 4550 5245 4341 5445 445f 5345 5428 .DEPRECATED_SET( │ │ │ -00047570: 6163 7469 7665 5f6c 6f61 6465 645f 6c69 active_loaded_li │ │ │ -00047580: 6d69 742c 2030 2c20 2661 6d70 3b73 6573 mit, 0, &ses │ │ │ -00047590: 7369 6f6e 5f69 6d70 6c3a 3a74 7269 6767 sion_impl::trigg │ │ │ -000475a0: 6572 5f61 7574 6f5f 6d61 6e61 6765 292c er_auto_manage), │ │ │ -000475b0: 0a09 0953 4554 2861 7574 6f5f 6d61 6e61 ...SET(auto_mana │ │ │ -000475c0: 6765 5f69 6e74 6572 7661 6c2c 2033 302c ge_interval, 30, │ │ │ -000475d0: 206e 756c 6c70 7472 292c 0a09 0953 4554 nullptr),...SET │ │ │ -000475e0: 2873 6565 645f 7469 6d65 5f6c 696d 6974 (seed_time_limit │ │ │ -000475f0: 2c20 3234 202a 2036 3020 2a20 3630 2c20 , 24 * 60 * 60, │ │ │ -00047600: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428 nullptr),...SET( │ │ │ -00047610: 6175 746f 5f73 6372 6170 655f 696e 7465 auto_scrape_inte │ │ │ -00047620: 7276 616c 2c20 3138 3030 2c20 6e75 6c6c rval, 1800, null │ │ │ -00047630: 7074 7229 2c0a 0909 5345 5428 6175 746f ptr),...SET(auto │ │ │ -00047640: 5f73 6372 6170 655f 6d69 6e5f 696e 7465 _scrape_min_inte │ │ │ -00047650: 7276 616c 2c20 3330 302c 206e 756c 6c70 rval, 300, nullp │ │ │ -00047660: 7472 292c 0a09 0953 4554 286d 6178 5f70 tr),...SET(max_p │ │ │ -00047670: 6565 726c 6973 745f 7369 7a65 2c20 3330 eerlist_size, 30 │ │ │ -00047680: 3030 2c20 6e75 6c6c 7074 7229 2c0a 0909 00, nullptr),... │ │ │ -00047690: 5345 5428 6d61 785f 7061 7573 6564 5f70 SET(max_paused_p │ │ │ -000476a0: 6565 726c 6973 745f 7369 7a65 2c20 3130 eerlist_size, 10 │ │ │ -000476b0: 3030 2c20 6e75 6c6c 7074 7229 2c0a 0909 00, nullptr),... │ │ │ -000476c0: 5345 5428 6d69 6e5f 616e 6e6f 756e 6365 SET(min_announce │ │ │ -000476d0: 5f69 6e74 6572 7661 6c2c 2035 202a 2036 _interval, 5 * 6 │ │ │ -000476e0: 302c 206e 756c 6c70 7472 292c 0a09 0953 0, nullptr),...S │ │ │ -000476f0: 4554 2861 7574 6f5f 6d61 6e61 6765 5f73 ET(auto_manage_s │ │ │ -00047700: 7461 7274 7570 2c20 3630 2c20 6e75 6c6c tartup, 60, null │ │ │ -00047710: 7074 7229 2c0a 0909 5345 5428 7365 6564 ptr),...SET(seed │ │ │ -00047720: 696e 675f 7069 6563 655f 7175 6f74 612c ing_piece_quota, │ │ │ -00047730: 2032 302c 206e 756c 6c70 7472 292c 0a3c 20, nullptr),.< │ │ │ -00047740: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ -00047750: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ -00047760: 7769 6474 683d 2231 3030 2522 3e09 0953 width="100%">..S │ │ │ -00047770: 4554 286d 6178 5f72 656a 6563 7473 2c20 ET(max_rejects, │ │ │ -00047780: 3530 2c20 6e75 6c6c 7074 7229 2c0a 3c2f 50, nullptr),...SET(recv_s │ │ │ -000477a0: 6f63 6b65 745f 6275 6666 6572 5f73 697a ocket_buffer_siz │ │ │ -000477b0: 652c 2030 2c20 2661 6d70 3b73 6573 7369 e, 0, &sessi │ │ │ -000477c0: 6f6e 5f69 6d70 6c3a 3a75 7064 6174 655f on_impl::update_ │ │ │ -000477d0: 736f 636b 6574 5f62 7566 6665 725f 7369 socket_buffer_si │ │ │ -000477e0: 7a65 292c 0a09 0953 4554 2873 656e 645f ze),...SET(send_ │ │ │ -000477f0: 736f 636b 6574 5f62 7566 6665 725f 7369 socket_buffer_si │ │ │ -00047800: 7a65 2c20 302c 2026 616d 703b 7365 7373 ze, 0, &sess │ │ │ -00047810: 696f 6e5f 696d 706c 3a3a 7570 6461 7465 ion_impl::update │ │ │ -00047820: 5f73 6f63 6b65 745f 6275 6666 6572 5f73 _socket_buffer_s │ │ │ -00047830: 697a 6529 2c0a 0909 5345 5428 6d61 785f ize),...SET(max_ │ │ │ -00047840: 7065 6572 5f72 6563 765f 6275 6666 6572 peer_recv_buffer │ │ │ -00047850: 5f73 697a 652c 2032 202a 2031 3032 3420 _size, 2 * 1024 │ │ │ -00047860: 2a20 3130 3234 2c20 6e75 6c6c 7074 7229 * 1024, nullptr) │ │ │ -00047870: 2c0a 0909 4445 5052 4543 4154 4544 5f53 ,...DEPRECATED_S │ │ │ -00047880: 4554 2866 696c 655f 6368 6563 6b73 5f64 ET(file_checks_d │ │ │ -00047890: 656c 6179 5f70 6572 5f62 6c6f 636b 2c20 elay_per_block, │ │ │ -000478a0: 302c 206e 756c 6c70 7472 292c 0a09 0944 0, nullptr),...D │ │ │ -000478b0: 4550 5245 4341 5445 4432 5f53 4554 2872 EPRECATED2_SET(r │ │ │ -000478c0: 6561 645f 6361 6368 655f 6c69 6e65 5f73 ead_cache_line_s │ │ │ -000478d0: 697a 652c 2033 322c 206e 756c 6c70 7472 ize, 32, nullptr │ │ │ -000478e0: 292c 0a09 0944 4550 5245 4341 5445 4432 ),...DEPRECATED2 │ │ │ -000478f0: 5f53 4554 2877 7269 7465 5f63 6163 6865 _SET(write_cache │ │ │ -00047900: 5f6c 696e 655f 7369 7a65 2c20 3136 2c20 _line_size, 16, │ │ │ -00047910: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428 nullptr),...SET( │ │ │ -00047920: 6f70 7469 6d69 7374 6963 5f64 6973 6b5f optimistic_disk_ │ │ │ -00047930: 7265 7472 792c 2031 3020 2a20 3630 2c20 retry, 10 * 60, │ │ │ -00047940: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428 nullptr),...SET( │ │ │ -00047950: 6d61 785f 7375 6767 6573 745f 7069 6563 max_suggest_piec │ │ │ -00047960: 6573 2c20 3136 2c20 6e75 6c6c 7074 7229 es, 16, nullptr) │ │ │ -00047970: 2c0a 0909 5345 5428 6c6f 6361 6c5f 7365 ,...SET(local_se │ │ │ -00047980: 7276 6963 655f 616e 6e6f 756e 6365 5f69 rvice_announce_i │ │ │ -00047990: 6e74 6572 7661 6c2c 2035 202a 2036 302c nterval, 5 * 60, │ │ │ -000479a0: 206e 756c 6c70 7472 292c 0a09 0953 4554 nullptr),...SET │ │ │ -000479b0: 2864 6874 5f61 6e6e 6f75 6e63 655f 696e (dht_announce_in │ │ │ -000479c0: 7465 7276 616c 2c20 3135 202a 2036 302c terval, 15 * 60, │ │ │ -000479d0: 2026 616d 703b 7365 7373 696f 6e5f 696d &session_im │ │ │ -000479e0: 706c 3a3a 7570 6461 7465 5f64 6874 5f61 pl::update_dht_a │ │ │ -000479f0: 6e6e 6f75 6e63 655f 696e 7465 7276 616c nnounce_interval │ │ │ -00047a00: 292c 0a09 0953 4554 2875 6470 5f74 7261 ),...SET(udp_tra │ │ │ -00047a10: 636b 6572 5f74 6f6b 656e 5f65 7870 6972 cker_token_expir │ │ │ -00047a20: 792c 2036 302c 206e 756c 6c70 7472 292c y, 60, nullptr), │ │ │ -00047a30: 0a09 0944 4550 5245 4341 5445 445f 5345 ...DEPRECATED_SE │ │ │ -00047a40: 5428 6465 6661 756c 745f 6361 6368 655f T(default_cache_ │ │ │ -00047a50: 6d69 6e5f 6167 652c 2031 2c20 6e75 6c6c min_age, 1, null │ │ │ -00047a60: 7074 7229 2c0a 0909 5345 5428 6e75 6d5f ptr),...SET(num_ │ │ │ -00047a70: 6f70 7469 6d69 7374 6963 5f75 6e63 686f optimistic_uncho │ │ │ -00047a80: 6b65 5f73 6c6f 7473 2c20 302c 206e 756c ke_slots, 0, nul │ │ │ -00047a90: 6c70 7472 292c 0a09 0944 4550 5245 4341 lptr),...DEPRECA │ │ │ -00047aa0: 5445 445f 5345 5428 6465 6661 756c 745f TED_SET(default_ │ │ │ -00047ab0: 6573 745f 7265 6369 7072 6f63 6174 696f est_reciprocatio │ │ │ -00047ac0: 6e5f 7261 7465 2c20 3136 3030 302c 206e n_rate, 16000, n │ │ │ -00047ad0: 756c 6c70 7472 292c 0a09 0944 4550 5245 ullptr),...DEPRE │ │ │ -00047ae0: 4341 5445 445f 5345 5428 696e 6372 6561 CATED_SET(increa │ │ │ -00047af0: 7365 5f65 7374 5f72 6563 6970 726f 6361 se_est_reciproca │ │ │ -00047b00: 7469 6f6e 5f72 6174 652c 2032 302c 206e tion_rate, 20, n │ │ │ -00047b10: 756c 6c70 7472 292c 0a09 0944 4550 5245 ullptr),...DEPRE │ │ │ -00047b20: 4341 5445 445f 5345 5428 6465 6372 6561 CATED_SET(decrea │ │ │ -00047b30: 7365 5f65 7374 5f72 6563 6970 726f 6361 se_est_reciproca │ │ │ -00047b40: 7469 6f6e 5f72 6174 652c 2033 2c20 6e75 tion_rate, 3, nu │ │ │ -00047b50: 6c6c 7074 7229 2c0a 0909 5345 5428 6d61 llptr),...SET(ma │ │ │ -00047b60: 785f 7065 785f 7065 6572 732c 2035 302c x_pex_peers, 50, │ │ │ -00047b70: 206e 756c 6c70 7472 292c 0a09 0953 4554 nullptr),...SET │ │ │ -00047b80: 2874 6963 6b5f 696e 7465 7276 616c 2c20 (tick_interval, │ │ │ -00047b90: 3530 302c 206e 756c 6c70 7472 292c 0a09 500, nullptr),.. │ │ │ -00047ba0: 0953 4554 2873 6861 7265 5f6d 6f64 655f .SET(share_mode_ │ │ │ -00047bb0: 7461 7267 6574 2c20 332c 206e 756c 6c70 target, 3, nullp │ │ │ -00047bc0: 7472 292c 0a09 0953 4554 2875 706c 6f61 tr),...SET(uploa │ │ │ -00047bd0: 645f 7261 7465 5f6c 696d 6974 2c20 302c d_rate_limit, 0, │ │ │ -00047be0: 2026 616d 703b 7365 7373 696f 6e5f 696d &session_im │ │ │ -00047bf0: 706c 3a3a 7570 6461 7465 5f75 706c 6f61 pl::update_uploa │ │ │ -00047c00: 645f 7261 7465 292c 0a09 0953 4554 2864 d_rate),...SET(d │ │ │ -00047c10: 6f77 6e6c 6f61 645f 7261 7465 5f6c 696d ownload_rate_lim │ │ │ -00047c20: 6974 2c20 302c 2026 616d 703b 7365 7373 it, 0, &sess │ │ │ -00047c30: 696f 6e5f 696d 706c 3a3a 7570 6461 7465 ion_impl::update │ │ │ -00047c40: 5f64 6f77 6e6c 6f61 645f 7261 7465 292c _download_rate), │ │ │ -00047c50: 0a09 0944 4550 5245 4341 5445 445f 5345 ...DEPRECATED_SE │ │ │ -00047c60: 5428 6c6f 6361 6c5f 7570 6c6f 6164 5f72 T(local_upload_r │ │ │ -00047c70: 6174 655f 6c69 6d69 742c 2030 2c20 2661 ate_limit, 0, &a │ │ │ -00047c80: 6d70 3b73 6573 7369 6f6e 5f69 6d70 6c3a mp;session_impl: │ │ │ -00047c90: 3a75 7064 6174 655f 6c6f 6361 6c5f 7570 :update_local_up │ │ │ -00047ca0: 6c6f 6164 5f72 6174 6529 2c0a 0909 4445 load_rate),...DE │ │ │ -00047cb0: 5052 4543 4154 4544 5f53 4554 286c 6f63 PRECATED_SET(loc │ │ │ -00047cc0: 616c 5f64 6f77 6e6c 6f61 645f 7261 7465 al_download_rate │ │ │ -00047cd0: 5f6c 696d 6974 2c20 302c 2026 616d 703b _limit, 0, & │ │ │ -00047ce0: 7365 7373 696f 6e5f 696d 706c 3a3a 7570 session_impl::up │ │ │ -00047cf0: 6461 7465 5f6c 6f63 616c 5f64 6f77 6e6c date_local_downl │ │ │ -00047d00: 6f61 645f 7261 7465 292c 0a09 0953 4554 oad_rate),...SET │ │ │ -00047d10: 2864 6874 5f75 706c 6f61 645f 7261 7465 (dht_upload_rate │ │ │ -00047d20: 5f6c 696d 6974 2c20 3830 3030 2c20 2661 _limit, 8000, &a │ │ │ -00047d30: 6d70 3b73 6573 7369 6f6e 5f69 6d70 6c3a mp;session_impl: │ │ │ -00047d40: 3a75 7064 6174 655f 6468 745f 7570 6c6f :update_dht_uplo │ │ │ -00047d50: 6164 5f72 6174 655f 6c69 6d69 7429 2c0a ad_rate_limit),. │ │ │ -00047d60: 0909 5345 5428 756e 6368 6f6b 655f 736c ..SET(unchoke_sl │ │ │ -00047d70: 6f74 735f 6c69 6d69 742c 2038 2c20 2661 ots_limit, 8, &a │ │ │ -00047d80: 6d70 3b73 6573 7369 6f6e 5f69 6d70 6c3a mp;session_impl: │ │ │ -00047d90: 3a75 7064 6174 655f 756e 6368 6f6b 655f :update_unchoke_ │ │ │ -00047da0: 6c69 6d69 7429 2c0a 0909 4445 5052 4543 limit),...DEPREC │ │ │ -00047db0: 4154 4544 5f53 4554 2868 616c 665f 6f70 ATED_SET(half_op │ │ │ -00047dc0: 656e 5f6c 696d 6974 2c20 302c 206e 756c en_limit, 0, nul │ │ │ -00047dd0: 6c70 7472 292c 0a09 0953 4554 2863 6f6e lptr),...SET(con │ │ │ -00047de0: 6e65 6374 696f 6e73 5f6c 696d 6974 2c20 nections_limit, │ │ │ -00047df0: 3230 302c 2026 616d 703b 7365 7373 696f 200, &sessio │ │ │ -00047e00: 6e5f 696d 706c 3a3a 7570 6461 7465 5f63 n_impl::update_c │ │ │ -00047e10: 6f6e 6e65 6374 696f 6e73 5f6c 696d 6974 onnections_limit │ │ │ -00047e20: 292c 0a09 0953 4554 2863 6f6e 6e65 6374 ),...SET(connect │ │ │ -00047e30: 696f 6e73 5f73 6c61 636b 2c20 3130 2c20 ions_slack, 10, │ │ │ -00047e40: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428 nullptr),...SET( │ │ │ -00047e50: 7574 705f 7461 7267 6574 5f64 656c 6179 utp_target_delay │ │ │ -00047e60: 2c20 3130 302c 206e 756c 6c70 7472 292c , 100, nullptr), │ │ │ -00047e70: 0a09 0953 4554 2875 7470 5f67 6169 6e5f ...SET(utp_gain_ │ │ │ -00047e80: 6661 6374 6f72 2c20 3330 3030 2c20 6e75 factor, 3000, nu │ │ │ -00047e90: 6c6c 7074 7229 2c0a 3c2f 7072 653e 3c2f llptr),.

    relevan │ │ │ -00047ed0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/settin │ │ │ -00047f10: 6773 5f70 6163 6b2e 6370 703a 3539 373c gs_pack.cpp:597< │ │ │ -00047f20: 2f61 3e3c 2f74 643e 3c74 643e 6974 2077 /a>it w │ │ │ -00047f30: 6f75 6c64 2062 6520 6e69 6365 2074 6f20 ould be nice to │ │ │ -00047f40: 7265 7365 7276 6528 2920 7468 6573 6520 reserve() these │ │ │ -00047f50: 7665 6374 6f72 7320 7570 2066 726f 6e74 vectors up front │ │ │ -00047f60: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    it │ │ │ -00047fb0: 2077 6f75 6c64 2062 6520 6e69 6365 2074 would be nice t │ │ │ -00047fc0: 6f20 7265 7365 7276 6528 2920 7468 6573 o reserve() thes │ │ │ -00047fd0: 6520 7665 6374 6f72 7320 7570 2066 726f e vectors up fro │ │ │ -00047fe0: 6e74 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 nt

    ../sr │ │ │ -00047ff0: 632f 7365 7474 696e 6773 5f70 6163 6b2e c/settings_pack. │ │ │ -00048000: 6370 703a 3539 373c 2f68 343e 3c70 7265 cpp:597

    ...s.set_s
    │ │ │ -00048050: 7472 2873 6574 7469 6e67 735f 7061 636b  tr(settings_pack
    │ │ │ -00048060: 3a3a 7374 7269 6e67 5f74 7970 655f 6261  ::string_type_ba
    │ │ │ -00048070: 7365 207c 2069 2c20 7374 725f 7365 7474  se | i, str_sett
    │ │ │ -00048080: 696e 6773 5b69 5d2e 6465 6661 756c 745f  ings[i].default_
    │ │ │ -00048090: 7661 6c75 6529 3b0a 0909 0954 4f52 5245  value);....TORRE
    │ │ │ -000480a0: 4e54 5f41 5353 4552 5428 732e 6765 745f  NT_ASSERT(s.get_
    │ │ │ -000480b0: 7374 7228 7365 7474 696e 6773 5f70 6163  str(settings_pac
    │ │ │ -000480c0: 6b3a 3a73 7472 696e 675f 7479 7065 5f62  k::string_type_b
    │ │ │ -000480d0: 6173 6520 2b20 6929 203d 3d20 7374 725f  ase + i) == str_
    │ │ │ -000480e0: 7365 7474 696e 6773 5b69 5d2e 6465 6661  settings[i].defa
    │ │ │ -000480f0: 756c 745f 7661 6c75 6529 3b0a 0909 7d0a  ult_value);...}.
    │ │ │ -00048100: 0a09 0966 6f72 2028 696e 7420 6920 3d20  ...for (int i = 
    │ │ │ -00048110: 303b 2069 2026 6c74 3b20 7365 7474 696e  0; i < settin
    │ │ │ -00048120: 6773 5f70 6163 6b3a 3a6e 756d 5f69 6e74  gs_pack::num_int
    │ │ │ -00048130: 5f73 6574 7469 6e67 733b 202b 2b69 290a  _settings; ++i).
    │ │ │ -00048140: 0909 7b0a 0909 0973 2e73 6574 5f69 6e74  ..{....s.set_int
    │ │ │ -00048150: 2873 6574 7469 6e67 735f 7061 636b 3a3a  (settings_pack::
    │ │ │ -00048160: 696e 745f 7479 7065 5f62 6173 6520 7c20  int_type_base | 
    │ │ │ -00048170: 692c 2069 6e74 5f73 6574 7469 6e67 735b  i, int_settings[
    │ │ │ -00048180: 695d 2e64 6566 6175 6c74 5f76 616c 7565  i].default_value
    │ │ │ -00048190: 293b 0a09 0909 544f 5252 454e 545f 4153  );....TORRENT_AS
    │ │ │ -000481a0: 5345 5254 2873 2e67 6574 5f69 6e74 2873  SERT(s.get_int(s
    │ │ │ -000481b0: 6574 7469 6e67 735f 7061 636b 3a3a 696e  ettings_pack::in
    │ │ │ -000481c0: 745f 7479 7065 5f62 6173 6520 2b20 6929  t_type_base + i)
    │ │ │ -000481d0: 203d 3d20 696e 745f 7365 7474 696e 6773   == int_settings
    │ │ │ -000481e0: 5b69 5d2e 6465 6661 756c 745f 7661 6c75  [i].default_valu
    │ │ │ -000481f0: 6529 3b0a 0909 7d0a 0a09 0966 6f72 2028  e);...}....for (
    │ │ │ -00048200: 696e 7420 6920 3d20 303b 2069 2026 6c74  int i = 0; i <
    │ │ │ -00048210: 3b20 7365 7474 696e 6773 5f70 6163 6b3a  ; settings_pack:
    │ │ │ -00048220: 3a6e 756d 5f62 6f6f 6c5f 7365 7474 696e  :num_bool_settin
    │ │ │ -00048230: 6773 3b20 2b2b 6929 0a09 097b 0a09 0909  gs; ++i)...{....
    │ │ │ -00048240: 732e 7365 745f 626f 6f6c 2873 6574 7469  s.set_bool(setti
    │ │ │ -00048250: 6e67 735f 7061 636b 3a3a 626f 6f6c 5f74  ngs_pack::bool_t
    │ │ │ -00048260: 7970 655f 6261 7365 207c 2069 2c20 626f  ype_base | i, bo
    │ │ │ -00048270: 6f6c 5f73 6574 7469 6e67 735b 695d 2e64  ol_settings[i].d
    │ │ │ -00048280: 6566 6175 6c74 5f76 616c 7565 293b 0a09  efault_value);..
    │ │ │ -00048290: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ -000482a0: 2873 2e67 6574 5f62 6f6f 6c28 7365 7474  (s.get_bool(sett
    │ │ │ -000482b0: 696e 6773 5f70 6163 6b3a 3a62 6f6f 6c5f  ings_pack::bool_
    │ │ │ -000482c0: 7479 7065 5f62 6173 6520 2b20 6929 203d  type_base + i) =
    │ │ │ -000482d0: 3d20 626f 6f6c 5f73 6574 7469 6e67 735b  = bool_settings[
    │ │ │ -000482e0: 695d 2e64 6566 6175 6c74 5f76 616c 7565  i].default_value
    │ │ │ -000482f0: 293b 0a09 097d 0a09 7d0a 0a09 7365 7474  );...}..}...sett
    │ │ │ -00048300: 696e 6773 5f70 6163 6b20 6465 6661 756c  ings_pack defaul
    │ │ │ -00048310: 745f 7365 7474 696e 6773 2829 0a09 7b0a  t_settings()..{.
    │ │ │ -00048320: 0909 7365 7474 696e 6773 5f70 6163 6b20  ..settings_pack 
    │ │ │ -00048330: 7265 743b 0a3c 6469 7620 7374 796c 653d  ret;.
    ..for (int i │ │ │ -00048370: 3d20 303b 2069 2026 6c74 3b20 7365 7474 = 0; i < sett │ │ │ -00048380: 696e 6773 5f70 6163 6b3a 3a6e 756d 5f73 ings_pack::num_s │ │ │ -00048390: 7472 696e 675f 7365 7474 696e 6773 3b20 tring_settings; │ │ │ -000483a0: 2b2b 6929 0a3c 2f64 6976 3e09 097b 0a09 ++i).
    ..{.. │ │ │ -000483b0: 0909 6966 2028 7374 725f 7365 7474 696e ..if (str_settin │ │ │ -000483c0: 6773 5b69 5d2e 6465 6661 756c 745f 7661 gs[i].default_va │ │ │ -000483d0: 6c75 6520 3d3d 206e 756c 6c70 7472 2920 lue == nullptr) │ │ │ -000483e0: 636f 6e74 696e 7565 3b0a 0909 0972 6574 continue;....ret │ │ │ -000483f0: 2e73 6574 5f73 7472 2873 6574 7469 6e67 .set_str(setting │ │ │ -00048400: 735f 7061 636b 3a3a 7374 7269 6e67 5f74 s_pack::string_t │ │ │ -00048410: 7970 655f 6261 7365 202b 2069 2c20 7374 ype_base + i, st │ │ │ -00048420: 725f 7365 7474 696e 6773 5b69 5d2e 6465 r_settings[i].de │ │ │ -00048430: 6661 756c 745f 7661 6c75 6529 3b0a 0909 fault_value);... │ │ │ -00048440: 7d0a 0a09 0966 6f72 2028 696e 7420 6920 }....for (int i │ │ │ -00048450: 3d20 303b 2069 2026 6c74 3b20 7365 7474 = 0; i < sett │ │ │ -00048460: 696e 6773 5f70 6163 6b3a 3a6e 756d 5f69 ings_pack::num_i │ │ │ -00048470: 6e74 5f73 6574 7469 6e67 733b 202b 2b69 nt_settings; ++i │ │ │ -00048480: 290a 0909 7b0a 0909 0972 6574 2e73 6574 )...{....ret.set │ │ │ -00048490: 5f69 6e74 2873 6574 7469 6e67 735f 7061 _int(settings_pa │ │ │ -000484a0: 636b 3a3a 696e 745f 7479 7065 5f62 6173 ck::int_type_bas │ │ │ -000484b0: 6520 2b20 692c 2069 6e74 5f73 6574 7469 e + i, int_setti │ │ │ -000484c0: 6e67 735b 695d 2e64 6566 6175 6c74 5f76 ngs[i].default_v │ │ │ -000484d0: 616c 7565 293b 0a09 097d 0a0a 0909 666f alue);...}....fo │ │ │ -000484e0: 7220 2869 6e74 2069 203d 2030 3b20 6920 r (int i = 0; i │ │ │ -000484f0: 266c 743b 2073 6574 7469 6e67 735f 7061 < settings_pa │ │ │ -00048500: 636b 3a3a 6e75 6d5f 626f 6f6c 5f73 6574 ck::num_bool_set │ │ │ -00048510: 7469 6e67 733b 202b 2b69 290a 0909 7b0a tings; ++i)...{. │ │ │ -00048520: 0909 0972 6574 2e73 6574 5f62 6f6f 6c28 ...ret.set_bool( │ │ │ -00048530: 7365 7474 696e 6773 5f70 6163 6b3a 3a62 settings_pack::b │ │ │ -00048540: 6f6f 6c5f 7479 7065 5f62 6173 6520 2b20 ool_type_base + │ │ │ -00048550: 692c 2062 6f6f 6c5f 7365 7474 696e 6773 i, bool_settings │ │ │ -00048560: 5b69 5d2e 6465 6661 756c 745f 7661 6c75 [i].default_valu │ │ │ -00048570: 6529 3b0a 0909 7d0a 0909 7265 7475 726e e);...}...return │ │ │ -00048580: 2072 6574 3b0a 097d 0a0a 0976 6f69 6420 ret;..}...void │ │ │ -00048590: 6170 706c 795f 7061 636b 2873 6574 7469 apply_pack(setti │ │ │ -000485a0: 6e67 735f 7061 636b 2063 6f6e 7374 2a20 ngs_pack const* │ │ │ -000485b0: 7061 636b 2c20 6175 783a 3a73 6573 7369 pack, aux::sessi │ │ │ -000485c0: 6f6e 5f73 6574 7469 6e67 7326 616d 703b on_settings& │ │ │ -000485d0: 2073 6574 740a 0909 2c20 6175 783a 3a73 sett..., aux::s │ │ │ -000485e0: 6573 7369 6f6e 5f69 6d70 6c2a 2073 6573 ession_impl* ses │ │ │ -000485f0: 290a 097b 0a09 0975 7369 6e67 2066 756e )..{...using fun │ │ │ -00048600: 5f74 203d 2076 6f69 6420 2861 7578 3a3a _t = void (aux:: │ │ │ -00048610: 7365 7373 696f 6e5f 696d 706c 3a3a 2a29 session_impl::*) │ │ │ -00048620: 2829 3b0a 0909 7374 643a 3a76 6563 746f ();...std::vecto │ │ │ -00048630: 7226 6c74 3b66 756e 5f74 2667 743b 2063 r<fun_t> c │ │ │ -00048640: 616c 6c62 6163 6b73 3b0a 0a09 0973 6574 allbacks;....set │ │ │ -00048650: 742e 6275 6c6b 5f73 6574 285b 2661 6d70 t.bulk_set([& │ │ │ -00048660: 3b5d 2861 7578 3a3a 7365 7373 696f 6e5f ;](aux::session_ │ │ │ -00048670: 7365 7474 696e 6773 5f73 696e 676c 655f settings_single_ │ │ │ -00048680: 7468 7265 6164 2661 6d70 3b20 7329 0a09 thread& s).. │ │ │ -00048690: 097b 0a09 0909 6170 706c 795f 7061 636b .{....apply_pack │ │ │ -000486a0: 5f69 6d70 6c28 7061 636b 2c20 732c 2073 _impl(pack, s, s │ │ │ -000486b0: 6573 203f 2026 616d 703b 6361 6c6c 6261 es ? &callba │ │ │ -000486c0: 636b 7320 3a20 6e75 6c6c 7074 7229 3b0a cks : nullptr);. │ │ │ -000486d0: 0909 7d29 3b0a 0a09 092f 2f20 6361 6c6c ..});....// call │ │ │ -000486e0: 2074 6865 2063 616c 6c62 6163 6b73 206f the callbacks o │ │ │ -000486f0: 6e63 6520 616c 6c20 7468 6520 7365 7474 nce all the sett │ │ │ -00048700: 696e 6773 2068 6176 6520 6265 656e 2061 ings have been a │ │ │ -00048710: 7070 6c69 6564 2c20 616e 640a 0909 2f2f pplied, and...// │ │ │ -00048720: 206f 6e6c 7920 6f6e 6365 2070 6572 2063 only once per c │ │ │ -00048730: 616c 6c62 6163 6b0a 3c2f 7072 653e 3c2f allback.
    relevan │ │ │ -00048770: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0
    ../src/sessio │ │ │ -000487b0: 6e5f 696d 706c 2e63 7070 3a36 3135 3c2f n_impl.cpp:615come │ │ │ -000487d0: 7570 2077 6974 6820 736f 6d65 2061 6273 up with some abs │ │ │ -000487e0: 7472 6163 7469 6f6e 2074 6f20 646f 2074 traction to do t │ │ │ -000487f0: 6869 7320 666f 7220 676e 7574 6c73 2061 his for gnutls a │ │ │ -00048800: 7320 7765 6c6c 206c 6f61 6420 6365 7274 s well load cert │ │ │ -00048810: 6966 6963 6174 6573 2066 726f 6d20 7468 ificates from th │ │ │ -00048820: 6520 7769 6e64 6f77 7320 7379 7374 656d e windows system │ │ │ -00048830: 2063 6572 7469 6669 6361 7465 2073 746f certificate sto │ │ │ -00048840: 7265 3c2f 7464 3e3c 2f74 723e 3c74 7220 re

    │ │ │ -00048890: 636f 6d65 2075 7020 7769 7468 2073 6f6d come up with som │ │ │ -000488a0: 6520 6162 7374 7261 6374 696f 6e20 746f e abstraction to │ │ │ -000488b0: 2064 6f20 7468 6973 2066 6f72 2067 6e75 do this for gnu │ │ │ -000488c0: 746c 7320 6173 2077 656c 6c0a 6c6f 6164 tls as well.load │ │ │ -000488d0: 2063 6572 7469 6669 6361 7465 7320 6672 certificates fr │ │ │ -000488e0: 6f6d 2074 6865 2077 696e 646f 7773 2073 om the windows s │ │ │ -000488f0: 7973 7465 6d20 6365 7274 6966 6963 6174 ystem certificat │ │ │ -00048900: 6520 7374 6f72 653c 2f68 323e 3c68 343e e store

    │ │ │ -00048910: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ -00048920: 6d70 6c2e 6370 703a 3631 353c 2f68 343e mpl.cpp:615

    │ │ │ -00048930: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..paus
    │ │ │ -00048970: 6528 293b 0a09 7d0a 2365 6e64 6966 0a0a  e();..}.#endif..
    │ │ │ -00048980: 092f 2f20 5468 6973 2066 756e 6374 696f  .// This functio
    │ │ │ -00048990: 6e20 6973 2063 616c 6c65 6420 6279 2074  n is called by t
    │ │ │ -000489a0: 6865 2063 7265 6174 696e 6720 7468 7265  he creating thre
    │ │ │ -000489b0: 6164 2c20 6e6f 7420 696e 2074 6865 206d  ad, not in the m
    │ │ │ -000489c0: 6573 7361 6765 206c 6f6f 7027 730a 092f  essage loop's../
    │ │ │ -000489d0: 2f20 696f 5f63 6f6e 7465 7874 2074 6872  / io_context thr
    │ │ │ -000489e0: 6561 642e 0a09 766f 6964 2073 6573 7369  ead...void sessi
    │ │ │ -000489f0: 6f6e 5f69 6d70 6c3a 3a73 7461 7274 5f73  on_impl::start_s
    │ │ │ -00048a00: 6573 7369 6f6e 2829 0a09 7b0a 2369 666e  ession()..{.#ifn
    │ │ │ -00048a10: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ -00048a20: 424c 455f 4c4f 4747 494e 470a 0909 7365  BLE_LOGGING...se
    │ │ │ -00048a30: 7373 696f 6e5f 6c6f 6728 2273 7461 7274  ssion_log("start
    │ │ │ -00048a40: 2073 6573 7369 6f6e 2229 3b0a 2365 6e64   session");.#end
    │ │ │ -00048a50: 6966 0a0a 2369 6620 544f 5252 454e 545f  if..#if TORRENT_
    │ │ │ -00048a60: 5553 455f 5353 4c0a 0909 6572 726f 725f  USE_SSL...error_
    │ │ │ -00048a70: 636f 6465 2065 633b 0a09 096d 5f73 736c  code ec;...m_ssl
    │ │ │ -00048a80: 5f63 7478 2e73 6574 5f64 6566 6175 6c74  _ctx.set_default
    │ │ │ -00048a90: 5f76 6572 6966 795f 7061 7468 7328 6563  _verify_paths(ec
    │ │ │ -00048aa0: 293b 0a23 6966 6e64 6566 2054 4f52 5245  );.#ifndef TORRE
    │ │ │ -00048ab0: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749  NT_DISABLE_LOGGI
    │ │ │ -00048ac0: 4e47 0a09 0969 6620 2865 6329 2073 6573  NG...if (ec) ses
    │ │ │ -00048ad0: 7369 6f6e 5f6c 6f67 2822 5353 4c20 7365  sion_log("SSL se
    │ │ │ -00048ae0: 745f 6465 6661 756c 7420 7665 7269 6679  t_default verify
    │ │ │ -00048af0: 5f70 6174 6873 2066 6169 6c65 643a 2025  _paths failed: %
    │ │ │ -00048b00: 7322 2c20 6563 2e6d 6573 7361 6765 2829  s", ec.message()
    │ │ │ -00048b10: 2e63 5f73 7472 2829 293b 0a09 0965 632e  .c_str());...ec.
    │ │ │ -00048b20: 636c 6561 7228 293b 0a23 656e 6469 660a  clear();.#endif.
    │ │ │ -00048b30: 2369 6620 6465 6669 6e65 6420 544f 5252  #if defined TORR
    │ │ │ -00048b40: 454e 545f 5749 4e44 4f57 5320 2661 6d70  ENT_WINDOWS &
    │ │ │ -00048b50: 3b26 616d 703b 2064 6566 696e 6564 2054  ;& defined T
    │ │ │ -00048b60: 4f52 5245 4e54 5f55 5345 5f4f 5045 4e53  ORRENT_USE_OPENS
    │ │ │ -00048b70: 534c 2026 616d 703b 2661 6d70 3b20 2164  SL && !d
    │ │ │ -00048b80: 6566 696e 6564 2054 4f52 5245 4e54 5f57  efined TORRENT_W
    │ │ │ -00048b90: 494e 5254 0a3c 6469 7620 7374 796c 653d  INRT.
    ..X509_STORE* │ │ │ -00048bd0: 2073 746f 7265 203d 2058 3530 395f 5354 store = X509_ST │ │ │ -00048be0: 4f52 455f 6e65 7728 293b 0a3c 2f64 6976 ORE_new();.
    ..if (store)... │ │ │ -00048c00: 7b0a 0909 0948 4345 5254 5354 4f52 4520 {....HCERTSTORE │ │ │ -00048c10: 7379 7374 656d 5f73 746f 7265 203d 2043 system_store = C │ │ │ -00048c20: 6572 744f 7065 6e53 7973 7465 6d53 746f ertOpenSystemSto │ │ │ -00048c30: 7265 4128 302c 2022 524f 4f54 2229 3b0a reA(0, "ROOT");. │ │ │ -00048c40: 0909 092f 2f20 7468 6973 2069 7320 6265 ...// this is be │ │ │ -00048c50: 7374 2065 6666 6f72 740a 0909 0969 6620 st effort....if │ │ │ -00048c60: 2873 7973 7465 6d5f 7374 6f72 6529 0a09 (system_store).. │ │ │ -00048c70: 0909 7b0a 0909 0909 4345 5254 5f43 4f4e ..{.....CERT_CON │ │ │ -00048c80: 5445 5854 2063 6f6e 7374 2a20 6374 7820 TEXT const* ctx │ │ │ -00048c90: 3d20 6e75 6c6c 7074 723b 0a09 0909 0977 = nullptr;.....w │ │ │ -00048ca0: 6869 6c65 2028 2863 7478 203d 2043 6572 hile ((ctx = Cer │ │ │ -00048cb0: 7445 6e75 6d43 6572 7469 6669 6361 7465 tEnumCertificate │ │ │ -00048cc0: 7349 6e53 746f 7265 2873 7973 7465 6d5f sInStore(system_ │ │ │ -00048cd0: 7374 6f72 652c 2063 7478 2929 2021 3d20 store, ctx)) != │ │ │ -00048ce0: 6e75 6c6c 7074 7229 0a09 0909 097b 0a09 nullptr).....{.. │ │ │ -00048cf0: 0909 0909 756e 7369 676e 6564 2063 6861 ....unsigned cha │ │ │ -00048d00: 7220 636f 6e73 742a 2063 6572 745f 7074 r const* cert_pt │ │ │ -00048d10: 7220 3d20 7265 696e 7465 7270 7265 745f r = reinterpret_ │ │ │ -00048d20: 6361 7374 266c 743b 756e 7369 676e 6564 cast<unsigned │ │ │ -00048d30: 2063 6861 7220 636f 6e73 742a 2667 743b char const*> │ │ │ -00048d40: 2863 7478 2d26 6774 3b70 6243 6572 7445 (ctx->pbCertE │ │ │ -00048d50: 6e63 6f64 6564 293b 0a09 0909 0909 5835 ncoded);......X5 │ │ │ -00048d60: 3039 2a20 7835 3039 203d 2064 3269 5f58 09* x509 = d2i_X │ │ │ -00048d70: 3530 3928 6e75 6c6c 7074 722c 2026 616d 509(nullptr, &am │ │ │ -00048d80: 703b 6365 7274 5f70 7472 2c20 6374 782d p;cert_ptr, ctx- │ │ │ -00048d90: 2667 743b 6362 4365 7274 456e 636f 6465 >cbCertEncode │ │ │ -00048da0: 6429 3b0a 0909 0909 092f 2f20 7468 6973 d);......// this │ │ │ -00048db0: 2069 7320 6265 7374 2065 6666 6f72 740a is best effort. │ │ │ -00048dc0: 0909 0909 0969 6620 2821 7835 3039 2920 .....if (!x509) │ │ │ -00048dd0: 636f 6e74 696e 7565 3b0a 0909 0909 0958 continue;......X │ │ │ -00048de0: 3530 395f 5354 4f52 455f 6164 645f 6365 509_STORE_add_ce │ │ │ -00048df0: 7274 2873 746f 7265 2c20 7835 3039 293b rt(store, x509); │ │ │ -00048e00: 0a09 0909 0909 5835 3039 5f66 7265 6528 ......X509_free( │ │ │ -00048e10: 7835 3039 293b 0a09 0909 097d 0a09 0909 x509);.....}.... │ │ │ -00048e20: 0943 6572 7446 7265 6543 6572 7469 6669 .CertFreeCertifi │ │ │ -00048e30: 6361 7465 436f 6e74 6578 7428 6374 7829 cateContext(ctx) │ │ │ -00048e40: 3b0a 0909 0909 4365 7274 436c 6f73 6553 ;.....CertCloseS │ │ │ -00048e50: 746f 7265 2873 7973 7465 6d5f 7374 6f72 tore(system_stor │ │ │ -00048e60: 652c 2030 293b 0a09 0909 7d0a 0909 7d0a e, 0);....}...}. │ │ │ -00048e70: 0a09 0953 534c 5f43 5458 2a20 7373 6c5f ...SSL_CTX* ssl_ │ │ │ -00048e80: 6374 7820 3d20 6d5f 7373 6c5f 6374 782e ctx = m_ssl_ctx. │ │ │ -00048e90: 6e61 7469 7665 5f68 616e 646c 6528 293b native_handle(); │ │ │ -00048ea0: 0a09 0953 534c 5f43 5458 5f73 6574 5f63 ...SSL_CTX_set_c │ │ │ -00048eb0: 6572 745f 7374 6f72 6528 7373 6c5f 6374 ert_store(ssl_ct │ │ │ -00048ec0: 782c 2073 746f 7265 293b 0a23 656e 6469 x, store);.#endi │ │ │ -00048ed0: 660a 2369 6664 6566 205f 5f41 5050 4c45 f.#ifdef __APPLE │ │ │ -00048ee0: 5f5f 0a09 096d 5f73 736c 5f63 7478 2e6c __...m_ssl_ctx.l │ │ │ -00048ef0: 6f61 645f 7665 7269 6679 5f66 696c 6528 oad_verify_file( │ │ │ -00048f00: 222f 6574 632f 7373 6c2f 6365 7274 2e70 "/etc/ssl/cert.p │ │ │ -00048f10: 656d 222c 2065 6329 3b0a 2369 666e 6465 em", ec);.#ifnde │ │ │ -00048f20: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ -00048f30: 455f 4c4f 4747 494e 470a 0909 6966 2028 E_LOGGING...if ( │ │ │ -00048f40: 6563 2920 7365 7373 696f 6e5f 6c6f 6728 ec) session_log( │ │ │ -00048f50: 2253 534c 206c 6f61 645f 7665 7269 6679 "SSL load_verify │ │ │ -00048f60: 5f66 696c 6520 6661 696c 6564 3a20 2573 _file failed: %s │ │ │ -00048f70: 222c 2065 632e 6d65 7373 6167 6528 292e ", ec.message(). │ │ │ -00048f80: 635f 7374 7228 2929 3b0a 2365 6e64 6966 c_str());.#endif │ │ │ -00048f90: 0a09 0965 632e 636c 6561 7228 293b 0a3c ...ec.clear();.< │ │ │ -00048fa0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00048fb0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00048fc0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -00048fd0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -00048fe0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566
    ../src │ │ │ -00049010: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ -00049020: 703a 3135 3030 3c2f 613e 3c2f 7464 3e3c p:1500< │ │ │ -00049030: 7464 3e69 7420 776f 756c 6420 6265 206e td>it would be n │ │ │ -00049040: 6963 6520 746f 2072 6573 6572 7665 2829 ice to reserve() │ │ │ -00049050: 2074 6865 7365 2076 6563 746f 7273 2075 these vectors u │ │ │ -00049060: 7020 6672 6f6e 743c 2f74 643e 3c2f 7472 p front

    it would be │ │ │ -000490c0: 206e 6963 6520 746f 2072 6573 6572 7665 nice to reserve │ │ │ -000490d0: 2829 2074 6865 7365 2076 6563 746f 7273 () these vectors │ │ │ -000490e0: 2075 7020 6672 6f6e 743c 2f68 323e 3c68 up front

    ../src/session │ │ │ -00049100: 5f69 6d70 6c2e 6370 703a 3135 3030 3c2f _impl.cpp:1500
    ...
    │ │ │ -00049150: 6261 6e64 7769 6474 685f 6368 616e 6e65  bandwidth_channe
    │ │ │ -00049160: 6c2a 2063 6820 3d20 2661 6d70 3b70 2d26  l* ch = &p-&
    │ │ │ -00049170: 6774 3b63 6861 6e6e 656c 5b70 6565 725f  gt;channel[peer_
    │ │ │ -00049180: 636f 6e6e 6563 7469 6f6e 3a3a 646f 776e  connection::down
    │ │ │ -00049190: 6c6f 6164 5f63 6861 6e6e 656c 5d3b 0a09  load_channel];..
    │ │ │ -000491a0: 0909 6966 2028 7573 655f 7175 6f74 615f  ..if (use_quota_
    │ │ │ -000491b0: 6f76 6572 6865 6164 2863 682c 2061 6d6f  overhead(ch, amo
    │ │ │ -000491c0: 756e 745f 646f 776e 2929 0a09 0909 0972  unt_down)).....r
    │ │ │ -000491d0: 6574 207c 3d20 3120 266c 743b 266c 743b  et |= 1 <<
    │ │ │ -000491e0: 2070 6565 725f 636f 6e6e 6563 7469 6f6e   peer_connection
    │ │ │ -000491f0: 3a3a 646f 776e 6c6f 6164 5f63 6861 6e6e  ::download_chann
    │ │ │ -00049200: 656c 3b0a 0909 0963 6820 3d20 2661 6d70  el;....ch = &
    │ │ │ -00049210: 3b70 2d26 6774 3b63 6861 6e6e 656c 5b70  ;p->channel[p
    │ │ │ -00049220: 6565 725f 636f 6e6e 6563 7469 6f6e 3a3a  eer_connection::
    │ │ │ -00049230: 7570 6c6f 6164 5f63 6861 6e6e 656c 5d3b  upload_channel];
    │ │ │ -00049240: 0a09 0909 6966 2028 7573 655f 7175 6f74  ....if (use_quot
    │ │ │ -00049250: 615f 6f76 6572 6865 6164 2863 682c 2061  a_overhead(ch, a
    │ │ │ -00049260: 6d6f 756e 745f 7570 2929 0a09 0909 0972  mount_up)).....r
    │ │ │ -00049270: 6574 207c 3d20 3120 266c 743b 266c 743b  et |= 1 <<
    │ │ │ -00049280: 2070 6565 725f 636f 6e6e 6563 7469 6f6e   peer_connection
    │ │ │ -00049290: 3a3a 7570 6c6f 6164 5f63 6861 6e6e 656c  ::upload_channel
    │ │ │ -000492a0: 3b0a 0909 7d0a 0909 7265 7475 726e 2072  ;...}...return r
    │ │ │ -000492b0: 6574 3b0a 097d 0a0a 092f 2f20 7365 7373  et;..}...// sess
    │ │ │ -000492c0: 696f 6e5f 696d 706c 2069 7320 7265 7370  ion_impl is resp
    │ │ │ -000492d0: 6f6e 7369 626c 6520 666f 7220 6465 6c65  onsible for dele
    │ │ │ -000492e0: 7469 6e67 2027 7061 636b 270a 0976 6f69  ting 'pack'..voi
    │ │ │ -000492f0: 6420 7365 7373 696f 6e5f 696d 706c 3a3a  d session_impl::
    │ │ │ -00049300: 6170 706c 795f 7365 7474 696e 6773 5f70  apply_settings_p
    │ │ │ -00049310: 6163 6b28 7374 643a 3a73 6861 7265 645f  ack(std::shared_
    │ │ │ -00049320: 7074 7226 6c74 3b73 6574 7469 6e67 735f  ptr<settings_
    │ │ │ -00049330: 7061 636b 2667 743b 2070 6163 6b29 0a09  pack> pack)..
    │ │ │ -00049340: 7b0a 0909 494e 5641 5249 414e 545f 4348  {...INVARIANT_CH
    │ │ │ -00049350: 4543 4b3b 0a09 0961 7070 6c79 5f73 6574  ECK;...apply_set
    │ │ │ -00049360: 7469 6e67 735f 7061 636b 5f69 6d70 6c28  tings_pack_impl(
    │ │ │ -00049370: 2a70 6163 6b29 3b0a 097d 0a0a 0973 6574  *pack);..}...set
    │ │ │ -00049380: 7469 6e67 735f 7061 636b 2073 6573 7369  tings_pack sessi
    │ │ │ -00049390: 6f6e 5f69 6d70 6c3a 3a67 6574 5f73 6574  on_impl::get_set
    │ │ │ -000493a0: 7469 6e67 7328 2920 636f 6e73 740a 097b  tings() const..{
    │ │ │ -000493b0: 0a09 0973 6574 7469 6e67 735f 7061 636b  ...settings_pack
    │ │ │ -000493c0: 2072 6574 3b0a 3c64 6976 2073 7479 6c65   ret;.
    ..for (int i │ │ │ -00049400: 203d 2073 6574 7469 6e67 735f 7061 636b = settings_pack │ │ │ -00049410: 3a3a 7374 7269 6e67 5f74 7970 655f 6261 ::string_type_ba │ │ │ -00049420: 7365 3b0a 3c2f 6469 763e 0909 0969 2026 se;.
    ...i & │ │ │ -00049430: 6c74 3b20 7365 7474 696e 6773 5f70 6163 lt; settings_pac │ │ │ -00049440: 6b3a 3a6d 6178 5f73 7472 696e 675f 7365 k::max_string_se │ │ │ -00049450: 7474 696e 675f 696e 7465 726e 616c 3b20 tting_internal; │ │ │ -00049460: 2b2b 6929 0a09 097b 0a09 0909 7265 742e ++i)...{....ret. │ │ │ -00049470: 7365 745f 7374 7228 692c 206d 5f73 6574 set_str(i, m_set │ │ │ -00049480: 7469 6e67 732e 6765 745f 7374 7228 6929 tings.get_str(i) │ │ │ -00049490: 293b 0a09 097d 0a09 0966 6f72 2028 696e );...}...for (in │ │ │ -000494a0: 7420 6920 3d20 7365 7474 696e 6773 5f70 t i = settings_p │ │ │ -000494b0: 6163 6b3a 3a69 6e74 5f74 7970 655f 6261 ack::int_type_ba │ │ │ -000494c0: 7365 3b0a 0909 0969 2026 6c74 3b20 7365 se;....i < se │ │ │ -000494d0: 7474 696e 6773 5f70 6163 6b3a 3a6d 6178 ttings_pack::max │ │ │ -000494e0: 5f69 6e74 5f73 6574 7469 6e67 5f69 6e74 _int_setting_int │ │ │ -000494f0: 6572 6e61 6c3b 202b 2b69 290a 0909 7b0a ernal; ++i)...{. │ │ │ -00049500: 0909 0972 6574 2e73 6574 5f69 6e74 2869 ...ret.set_int(i │ │ │ -00049510: 2c20 6d5f 7365 7474 696e 6773 2e67 6574 , m_settings.get │ │ │ -00049520: 5f69 6e74 2869 2929 3b0a 0909 7d0a 0909 _int(i));...}... │ │ │ -00049530: 666f 7220 2869 6e74 2069 203d 2073 6574 for (int i = set │ │ │ -00049540: 7469 6e67 735f 7061 636b 3a3a 626f 6f6c tings_pack::bool │ │ │ -00049550: 5f74 7970 655f 6261 7365 3b0a 0909 0969 _type_base;....i │ │ │ -00049560: 2026 6c74 3b20 7365 7474 696e 6773 5f70 < settings_p │ │ │ -00049570: 6163 6b3a 3a6d 6178 5f62 6f6f 6c5f 7365 ack::max_bool_se │ │ │ -00049580: 7474 696e 675f 696e 7465 726e 616c 3b20 tting_internal; │ │ │ -00049590: 2b2b 6929 0a09 097b 0a09 0909 7265 742e ++i)...{....ret. │ │ │ -000495a0: 7365 745f 626f 6f6c 2869 2c20 6d5f 7365 set_bool(i, m_se │ │ │ -000495b0: 7474 696e 6773 2e67 6574 5f62 6f6f 6c28 ttings.get_bool( │ │ │ -000495c0: 6929 293b 0a09 097d 0a09 0972 6574 7572 i));...}...retur │ │ │ -000495d0: 6e20 7265 743b 0a09 7d0a 0a6e 616d 6573 n ret;..}..names │ │ │ -000495e0: 7061 6365 207b 0a09 7465 6d70 6c61 7465 pace {..template │ │ │ -000495f0: 2026 6c74 3b74 7970 656e 616d 6520 5061 <typename Pa │ │ │ -00049600: 636b 2667 743b 0a09 696e 7420 6765 745f ck>..int get_ │ │ │ -00049610: 7365 7474 696e 675f 696d 706c 2850 6163 setting_impl(Pac │ │ │ -00049620: 6b20 636f 6e73 7426 616d 703b 2070 2c20 k const& p, │ │ │ -00049630: 696e 7420 6e61 6d65 2c20 696e 742a 290a int name, int*). │ │ │ -00049640: 097b 2072 6574 7572 6e20 702e 6765 745f .{ return p.get_ │ │ │ -00049650: 696e 7428 6e61 6d65 293b 207d 0a0a 0974 int(name); }...t │ │ │ -00049660: 656d 706c 6174 6520 266c 743b 7479 7065 emplate <type │ │ │ -00049670: 6e61 6d65 2050 6163 6b26 6774 3b0a 0962 name Pack>..b │ │ │ -00049680: 6f6f 6c20 6765 745f 7365 7474 696e 675f ool get_setting_ │ │ │ -00049690: 696d 706c 2850 6163 6b20 636f 6e73 7426 impl(Pack const& │ │ │ -000496a0: 616d 703b 2070 2c20 696e 7420 6e61 6d65 amp; p, int name │ │ │ -000496b0: 2c20 626f 6f6c 2a29 0a09 7b20 7265 7475 , bool*)..{ retu │ │ │ -000496c0: 726e 2070 2e67 6574 5f62 6f6f 6c28 6e61 rn p.get_bool(na │ │ │ -000496d0: 6d65 293b 207d 0a0a 0974 656d 706c 6174 me); }...templat │ │ │ -000496e0: 6520 266c 743b 7479 7065 6e61 6d65 2050 e <typename P │ │ │ -000496f0: 6163 6b26 6774 3b0a 0973 7464 3a3a 7374 ack>..std::st │ │ │ -00049700: 7269 6e67 2067 6574 5f73 6574 7469 6e67 ring get_setting │ │ │ -00049710: 5f69 6d70 6c28 5061 636b 2063 6f6e 7374 _impl(Pack const │ │ │ -00049720: 2661 6d70 3b20 702c 2069 6e74 206e 616d & p, int nam │ │ │ -00049730: 652c 2073 7464 3a3a 7374 7269 6e67 2a29 e, std::string*) │ │ │ -00049740: 0a09 7b20 7265 7475 726e 2070 2e67 6574 ..{ return p.get │ │ │ -00049750: 5f73 7472 286e 616d 6529 3b20 7d0a 0a3c _str(name); }..< │ │ │ -00049760: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00049770: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00049780: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -00049790: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -000497a0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -000497d0: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ -000497e0: 703a 3230 3134 3c2f 613e 3c2f 7464 3e3c p:2014< │ │ │ -000497f0: 7464 3e63 6f75 6c64 2074 6869 7320 6675 td>could this fu │ │ │ -00049800: 6e63 7469 6f6e 2062 6520 6d65 7267 6564 nction be merged │ │ │ -00049810: 2077 6974 6820 6578 7061 6e64 5f75 6e73 with expand_uns │ │ │ -00049820: 7065 6369 6669 6564 5f61 6464 7265 7373 pecified_address │ │ │ -00049830: 6573 3f20 7269 6768 7420 6e6f 7720 626f es? right now bo │ │ │ -00049840: 7468 206c 6973 7465 6e5f 656e 6470 6f69 th listen_endpoi │ │ │ -00049850: 6e74 5f74 2061 6e64 206c 6973 7465 6e5f nt_t and listen_ │ │ │ -00049860: 696e 7465 7266 6163 655f 7420 6172 6520 interface_t are │ │ │ -00049870: 616c 6d6f 7374 2069 6465 6e74 6963 616c almost identical │ │ │ -00049880: 2c20 6d61 7962 6520 7468 6520 6c61 7474 , maybe the latt │ │ │ -00049890: 6572 2063 6f75 6c64 2062 6520 7265 6d6f er could be remo │ │ │ -000498a0: 7665 6420 746f 6f3c 2f74 643e 3c2f 7472 ved too

    could this │ │ │ -00049900: 6675 6e63 7469 6f6e 2062 6520 6d65 7267 function be merg │ │ │ -00049910: 6564 2077 6974 6820 6578 7061 6e64 5f75 ed with expand_u │ │ │ -00049920: 6e73 7065 6369 6669 6564 5f61 6464 7265 nspecified_addre │ │ │ -00049930: 7373 6573 3f0a 7269 6768 7420 6e6f 7720 sses?.right now │ │ │ -00049940: 626f 7468 206c 6973 7465 6e5f 656e 6470 both listen_endp │ │ │ -00049950: 6f69 6e74 5f74 2061 6e64 206c 6973 7465 oint_t and liste │ │ │ -00049960: 6e5f 696e 7465 7266 6163 655f 7420 6172 n_interface_t ar │ │ │ -00049970: 6520 616c 6d6f 7374 0a69 6465 6e74 6963 e almost.identic │ │ │ -00049980: 616c 2c20 6d61 7962 6520 7468 6520 6c61 al, maybe the la │ │ │ -00049990: 7474 6572 2063 6f75 6c64 2062 6520 7265 tter could be re │ │ │ -000499a0: 6d6f 7665 6420 746f 6f3c 2f68 323e 3c68 moved too

    ../src/session │ │ │ -000499c0: 5f69 6d70 6c2e 6370 703a 3230 3134 3c2f _impl.cpp:2014
    ..s
    │ │ │ -00049a10: 6573 7369 6f6e 5f6c 6f67 2822 4641 5441  ession_log("FATA
    │ │ │ -00049a20: 4c20 5345 5353 494f 4e20 4552 524f 5220  L SESSION ERROR 
    │ │ │ -00049a30: 2825 7320 3a20 2564 2920 5b25 735d 220a  (%s : %d) [%s]".
    │ │ │ -00049a40: 0909 092c 2065 632e 6361 7465 676f 7279  ..., ec.category
    │ │ │ -00049a50: 2829 2e6e 616d 6528 292c 2065 632e 7661  ().name(), ec.va
    │ │ │ -00049a60: 6c75 6528 292c 2065 632e 6d65 7373 6167  lue(), ec.messag
    │ │ │ -00049a70: 6528 292e 635f 7374 7228 2929 3b0a 2365  e().c_str());.#e
    │ │ │ -00049a80: 6e64 6966 0a09 0974 6869 732d 2667 743b  ndif...this->
    │ │ │ -00049a90: 6162 6f72 7428 293b 0a09 7d0a 0a09 766f  abort();..}...vo
    │ │ │ -00049aa0: 6964 2073 6573 7369 6f6e 5f69 6d70 6c3a  id session_impl:
    │ │ │ -00049ab0: 3a6f 6e5f 6970 5f63 6861 6e67 6528 6572  :on_ip_change(er
    │ │ │ -00049ac0: 726f 725f 636f 6465 2063 6f6e 7374 2661  ror_code const&a
    │ │ │ -00049ad0: 6d70 3b20 6563 290a 097b 0a23 6966 6e64  mp; ec)..{.#ifnd
    │ │ │ -00049ae0: 6566 2054 4f52 5245 4e54 5f44 4953 4142  ef TORRENT_DISAB
    │ │ │ -00049af0: 4c45 5f4c 4f47 4749 4e47 0a09 0969 6620  LE_LOGGING...if 
    │ │ │ -00049b00: 2821 6563 290a 0909 0973 6573 7369 6f6e  (!ec)....session
    │ │ │ -00049b10: 5f6c 6f67 2822 7265 6365 6976 6564 2069  _log("received i
    │ │ │ -00049b20: 7020 6368 616e 6765 2066 726f 6d20 696e  p change from in
    │ │ │ -00049b30: 7465 726e 616c 2069 705f 6e6f 7469 6669  ternal ip_notifi
    │ │ │ -00049b40: 6572 2229 3b0a 0909 656c 7365 0a09 0909  er");...else....
    │ │ │ -00049b50: 7365 7373 696f 6e5f 6c6f 6728 2272 6563  session_log("rec
    │ │ │ -00049b60: 6569 7665 6420 6572 726f 7220 6f6e 5f69  eived error on_i
    │ │ │ -00049b70: 705f 6368 616e 6765 3a20 2564 2c20 2573  p_change: %d, %s
    │ │ │ -00049b80: 222c 2065 632e 7661 6c75 6528 292c 2065  ", ec.value(), e
    │ │ │ -00049b90: 632e 6d65 7373 6167 6528 292e 635f 7374  c.message().c_st
    │ │ │ -00049ba0: 7228 2929 3b0a 2365 6e64 6966 0a09 0969  r());.#endif...i
    │ │ │ -00049bb0: 6620 2865 6320 7c7c 206d 5f61 626f 7274  f (ec || m_abort
    │ │ │ -00049bc0: 207c 7c20 216d 5f69 705f 6e6f 7469 6669   || !m_ip_notifi
    │ │ │ -00049bd0: 6572 2920 7265 7475 726e 3b0a 0909 6d5f  er) return;...m_
    │ │ │ -00049be0: 6970 5f6e 6f74 6966 6965 722d 2667 743b  ip_notifier->
    │ │ │ -00049bf0: 6173 796e 635f 7761 6974 285b 7468 6973  async_wait([this
    │ │ │ -00049c00: 5d20 2865 7272 6f72 5f63 6f64 6520 636f  ] (error_code co
    │ │ │ -00049c10: 6e73 7426 616d 703b 2065 290a 0909 097b  nst& e)....{
    │ │ │ -00049c20: 2077 7261 7028 2661 6d70 3b73 6573 7369   wrap(&sessi
    │ │ │ -00049c30: 6f6e 5f69 6d70 6c3a 3a6f 6e5f 6970 5f63  on_impl::on_ip_c
    │ │ │ -00049c40: 6861 6e67 652c 2065 293b 207d 293b 0a09  hange, e); });..
    │ │ │ -00049c50: 0972 656f 7065 6e5f 6e65 7477 6f72 6b5f  .reopen_network_
    │ │ │ -00049c60: 736f 636b 6574 7328 7b7d 293b 0a09 7d0a  sockets({});..}.
    │ │ │ -00049c70: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -00049ca0: 766f 6964 2069 6e74 6572 6661 6365 5f74 void interface_t │ │ │ -00049cb0: 6f5f 656e 6470 6f69 6e74 7328 6c69 7374 o_endpoints(list │ │ │ -00049cc0: 656e 5f69 6e74 6572 6661 6365 5f74 2063 en_interface_t c │ │ │ -00049cd0: 6f6e 7374 2661 6d70 3b20 6966 6163 650a onst& iface. │ │ │ -00049ce0: 3c2f 6469 763e 0909 2c20 6c69 7374 656e
    .., listen │ │ │ -00049cf0: 5f73 6f63 6b65 745f 666c 6167 735f 7420 _socket_flags_t │ │ │ -00049d00: 666c 6167 730a 0909 2c20 7370 616e 266c flags..., span&l │ │ │ -00049d10: 743b 6970 5f69 6e74 6572 6661 6365 2063 t;ip_interface c │ │ │ -00049d20: 6f6e 7374 2667 743b 2063 6f6e 7374 2069 onst> const i │ │ │ -00049d30: 6673 0a09 092c 2073 7464 3a3a 7665 6374 fs..., std::vect │ │ │ -00049d40: 6f72 266c 743b 6c69 7374 656e 5f65 6e64 or<listen_end │ │ │ -00049d50: 706f 696e 745f 7426 6774 3b26 616d 703b point_t>& │ │ │ -00049d60: 2065 7073 290a 097b 0a09 0966 6c61 6773 eps)..{...flags │ │ │ -00049d70: 207c 3d20 6966 6163 652e 6c6f 6361 6c20 |= iface.local │ │ │ -00049d80: 3f20 6c69 7374 656e 5f73 6f63 6b65 745f ? listen_socket_ │ │ │ -00049d90: 743a 3a6c 6f63 616c 5f6e 6574 776f 726b t::local_network │ │ │ -00049da0: 203a 206c 6973 7465 6e5f 736f 636b 6574 : listen_socket │ │ │ -00049db0: 5f66 6c61 6773 5f74 7b7d 3b0a 0909 7472 _flags_t{};...tr │ │ │ -00049dc0: 616e 7370 6f72 7420 636f 6e73 7420 7373 ansport const ss │ │ │ -00049dd0: 6c20 3d20 6966 6163 652e 7373 6c20 3f20 l = iface.ssl ? │ │ │ -00049de0: 7472 616e 7370 6f72 743a 3a73 736c 203a transport::ssl : │ │ │ -00049df0: 2074 7261 6e73 706f 7274 3a3a 706c 6169 transport::plai │ │ │ -00049e00: 6e74 6578 743b 0a0a 0909 2f2f 2046 6972 ntext;....// Fir │ │ │ -00049e10: 7374 2c20 6368 6563 6b20 746f 2073 6565 st, check to see │ │ │ -00049e20: 2069 6620 6974 2773 2061 6e20 4950 2061 if it's an IP a │ │ │ -00049e30: 6464 7265 7373 0a09 0965 7272 6f72 5f63 ddress...error_c │ │ │ -00049e40: 6f64 6520 6572 723b 0a09 0961 6464 7265 ode err;...addre │ │ │ -00049e50: 7373 2063 6f6e 7374 2061 6472 203d 206d ss const adr = m │ │ │ -00049e60: 616b 655f 6164 6472 6573 7328 6966 6163 ake_address(ifac │ │ │ -00049e70: 652e 6465 7669 6365 2e63 5f73 7472 2829 e.device.c_str() │ │ │ -00049e80: 2c20 6572 7229 3b0a 0909 6966 2028 2165 , err);...if (!e │ │ │ -00049e90: 7272 290a 0909 7b0a 0909 0965 7073 2e65 rr)...{....eps.e │ │ │ -00049ea0: 6d70 6c61 6365 5f62 6163 6b28 6164 722c mplace_back(adr, │ │ │ -00049eb0: 2069 6661 6365 2e70 6f72 742c 2073 7464 iface.port, std │ │ │ -00049ec0: 3a3a 7374 7269 6e67 7b7d 2c20 7373 6c2c ::string{}, ssl, │ │ │ -00049ed0: 2066 6c61 6773 293b 0a09 097d 0a09 0965 flags);...}...e │ │ │ -00049ee0: 6c73 650a 0909 7b0a 0909 0966 6c61 6773 lse...{....flags │ │ │ -00049ef0: 207c 3d20 6c69 7374 656e 5f73 6f63 6b65 |= listen_socke │ │ │ -00049f00: 745f 743a 3a77 6173 5f65 7870 616e 6465 t_t::was_expande │ │ │ -00049f10: 643b 0a0a 0909 092f 2f20 7468 6973 2069 d;.....// this i │ │ │ -00049f20: 7320 7468 6520 6361 7365 2077 6865 7265 s the case where │ │ │ -00049f30: 2064 6576 6963 6520 6e61 6d65 7320 6120 device names a │ │ │ -00049f40: 6e65 7477 6f72 6b20 6465 7669 6365 2e20 network device. │ │ │ -00049f50: 5765 206e 6565 6420 746f 0a09 0909 2f2f We need to....// │ │ │ -00049f60: 2065 6e75 6d65 7261 7465 2061 6c6c 2049 enumerate all I │ │ │ -00049f70: 5073 2061 7373 6f63 6961 7465 6420 7769 Ps associated wi │ │ │ -00049f80: 7468 2074 6869 7320 6465 7669 6365 0a09 th this device.. │ │ │ -00049f90: 0909 666f 7220 2861 7574 6f20 636f 6e73 ..for (auto cons │ │ │ -00049fa0: 7426 616d 703b 2069 7066 6163 6520 3a20 t& ipface : │ │ │ -00049fb0: 6966 7329 0a09 0909 7b0a 0909 0909 2f2f ifs)....{.....// │ │ │ -00049fc0: 2077 6527 7265 206c 6f6f 6b69 6e67 2066 we're looking f │ │ │ -00049fd0: 6f72 2061 2073 7065 6369 6669 6320 696e or a specific in │ │ │ -00049fe0: 7465 7266 6163 652c 2061 6e64 2069 7473 terface, and its │ │ │ -00049ff0: 2061 6464 7265 7373 0a09 0909 092f 2f20 address.....// │ │ │ -0004a000: 2877 6869 6368 206d 7573 7420 6265 206f (which must be o │ │ │ -0004a010: 6620 7468 6520 7361 6d65 2066 616d 696c f the same famil │ │ │ -0004a020: 7920 6173 2074 6865 2061 6464 7265 7373 y as the address │ │ │ -0004a030: 2077 6527 7265 0a09 0909 092f 2f20 636f we're.....// co │ │ │ -0004a040: 6e6e 6563 7469 6e67 2074 6f29 0a09 0909 nnecting to).... │ │ │ -0004a050: 0969 6620 2869 6661 6365 2e64 6576 6963 .if (iface.devic │ │ │ -0004a060: 6520 213d 2069 7066 6163 652e 6e61 6d65 e != ipface.name │ │ │ -0004a070: 2920 636f 6e74 696e 7565 3b0a 0a09 0909 ) continue;..... │ │ │ -0004a080: 0962 6f6f 6c20 636f 6e73 7420 6c6f 6361 .bool const loca │ │ │ -0004a090: 6c20 3d20 6966 6163 652e 6c6f 6361 6c0a l = iface.local. │ │ │ -0004a0a0: 0909 0909 097c 7c20 6970 6661 6365 2e69 .....|| ipface.i │ │ │ -0004a0b0: 6e74 6572 6661 6365 5f61 6464 7265 7373 nterface_address │ │ │ -0004a0c0: 2e69 735f 6c6f 6f70 6261 636b 2829 0a09 .is_loopback().. │ │ │ -0004a0d0: 0909 0909 7c7c 2069 735f 6c69 6e6b 5f6c ....|| is_link_l │ │ │ -0004a0e0: 6f63 616c 2869 7066 6163 652e 696e 7465 ocal(ipface.inte │ │ │ -0004a0f0: 7266 6163 655f 6164 6472 6573 7329 3b0a rface_address);. │ │ │ -0004a100: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0004a110: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0004a140: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -0004a170: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ -0004a180: 7070 3a32 3332 323c 2f61 3e3c 2f74 643e pp:2322 │ │ │ -0004a190: 3c74 643e 6974 2077 6f75 6c64 2070 726f it would pro │ │ │ -0004a1a0: 6261 626c 7920 6265 2062 6574 7465 7220 bably be better │ │ │ -0004a1b0: 746f 2064 6f20 7468 6973 2062 7920 6861 to do this by ha │ │ │ -0004a1c0: 7669 6e67 2061 206c 6973 7465 6e2d 736f ving a listen-so │ │ │ -0004a1d0: 636b 6574 2022 7665 7273 696f 6e22 206e cket "version" n │ │ │ -0004a1e0: 756d 6265 7220 7468 6174 2067 6574 7320 umber that gets │ │ │ -0004a1f0: 6275 6d70 6564 2e20 416e 6420 696e 7374 bumped. And inst │ │ │ -0004a200: 6561 6420 6f66 2073 6574 7469 6e67 2061 ead of setting a │ │ │ -0004a210: 2062 6f6f 6c20 746f 2064 6973 6162 6c65 bool to disable │ │ │ -0004a220: 2061 2074 7261 636b 6572 2c20 7765 2073 a tracker, we s │ │ │ -0004a230: 6574 2074 6865 2076 6572 7369 6f6e 206e et the version n │ │ │ -0004a240: 756d 6265 7220 7468 6174 2069 7420 7761 umber that it wa │ │ │ -0004a250: 7320 6469 7361 626c 6564 2061 742e 2054 s disabled at. T │ │ │ -0004a260: 6869 7320 6368 616e 6765 2077 6f75 6c64 his change would │ │ │ -0004a270: 2061 6666 6563 7420 7468 6520 4142 4920 affect the ABI │ │ │ -0004a280: 696e 2031 2e32 2c20 736f 2073 686f 756c in 1.2, so shoul │ │ │ -0004a290: 6420 6265 2064 6f6e 6520 696e 2032 2e30 d be done in 2.0 │ │ │ -0004a2a0: 206f 7220 6c61 7465 723c 2f74 643e 3c2f or later

    it would │ │ │ -0004a300: 7072 6f62 6162 6c79 2062 6520 6265 7474 probably be bett │ │ │ -0004a310: 6572 2074 6f20 646f 2074 6869 7320 6279 er to do this by │ │ │ -0004a320: 2068 6176 696e 6720 610a 6c69 7374 656e having a.listen │ │ │ -0004a330: 2d73 6f63 6b65 7420 2276 6572 7369 6f6e -socket "version │ │ │ -0004a340: 2220 6e75 6d62 6572 2074 6861 7420 6765 " number that ge │ │ │ -0004a350: 7473 2062 756d 7065 642e 2041 6e64 2069 ts bumped. And i │ │ │ -0004a360: 6e73 7465 6164 206f 660a 7365 7474 696e nstead of.settin │ │ │ -0004a370: 6720 6120 626f 6f6c 2074 6f20 6469 7361 g a bool to disa │ │ │ -0004a380: 626c 6520 6120 7472 6163 6b65 722c 2077 ble a tracker, w │ │ │ -0004a390: 6520 7365 7420 7468 6520 7665 7273 696f e set the versio │ │ │ -0004a3a0: 6e20 6e75 6d62 6572 2074 6861 740a 6974 n number that.it │ │ │ -0004a3b0: 2077 6173 2064 6973 6162 6c65 6420 6174 was disabled at │ │ │ -0004a3c0: 2e20 5468 6973 2063 6861 6e67 6520 776f . This change wo │ │ │ -0004a3d0: 756c 6420 6166 6665 6374 2074 6865 2041 uld affect the A │ │ │ -0004a3e0: 4249 2069 6e20 312e 322c 2073 6f0a 7368 BI in 1.2, so.sh │ │ │ -0004a3f0: 6f75 6c64 2062 6520 646f 6e65 2069 6e20 ould be done in │ │ │ -0004a400: 322e 3020 6f72 206c 6174 6572 3c2f 6832 2.0 or later

    ../src/sess │ │ │ -0004a420: 696f 6e5f 696d 706c 2e63 7070 3a32 3332 ion_impl.cpp:232 │ │ │ -0004a430: 323c 2f68 343e 3c70 7265 2073 7479 6c65 2

    │ │ │ -0004a470: 0909 7b0a 0909 0966 6f72 2028 6175 746f  ..{....for (auto
    │ │ │ -0004a480: 2063 6f6e 7374 2661 6d70 3b20 7320 3a20   const& s : 
    │ │ │ -0004a490: 6d5f 6c69 7374 656e 5f73 6f63 6b65 7473  m_listen_sockets
    │ │ │ -0004a4a0: 290a 0909 0909 7265 6d61 705f 706f 7274  ).....remap_port
    │ │ │ -0004a4b0: 7328 7265 6d61 705f 6e61 7470 6d70 5f61  s(remap_natpmp_a
    │ │ │ -0004a4c0: 6e64 5f75 706e 702c 202a 7329 3b0a 0909  nd_upnp, *s);...
    │ │ │ -0004a4d0: 7d0a 0909 656c 7365 0a09 097b 0a09 0909  }...else...{....
    │ │ │ -0004a4e0: 2f2f 206e 6577 2073 6f63 6b65 7473 206e  // new sockets n
    │ │ │ -0004a4f0: 6565 6420 746f 206d 6170 2070 6f72 7473  eed to map ports
    │ │ │ -0004a500: 2065 7665 6e20 6966 2074 6865 2063 616c   even if the cal
    │ │ │ -0004a510: 6c65 7220 6469 6420 6e6f 7420 7265 7175  ler did not requ
    │ │ │ -0004a520: 6573 740a 0909 092f 2f20 7265 2d6d 6170  est....// re-map
    │ │ │ -0004a530: 7069 6e67 0a09 0909 666f 7220 2861 7574  ping....for (aut
    │ │ │ -0004a540: 6f20 636f 6e73 7426 616d 703b 2073 203a  o const& s :
    │ │ │ -0004a550: 206e 6577 5f73 6f63 6b65 7473 290a 0909   new_sockets)...
    │ │ │ -0004a560: 0909 7265 6d61 705f 706f 7274 7328 7265  ..remap_ports(re
    │ │ │ -0004a570: 6d61 705f 6e61 7470 6d70 5f61 6e64 5f75  map_natpmp_and_u
    │ │ │ -0004a580: 706e 702c 202a 7329 3b0a 0909 7d0a 0a09  pnp, *s);...}...
    │ │ │ -0004a590: 0975 7064 6174 655f 6c73 6428 293b 0a0a  .update_lsd();..
    │ │ │ -0004a5a0: 2369 6620 544f 5252 454e 545f 5553 455f  #if TORRENT_USE_
    │ │ │ -0004a5b0: 4932 500a 0909 6f70 656e 5f6e 6577 5f69  I2P...open_new_i
    │ │ │ -0004a5c0: 6e63 6f6d 696e 675f 6932 705f 636f 6e6e  ncoming_i2p_conn
    │ │ │ -0004a5d0: 6563 7469 6f6e 2829 3b0a 2365 6e64 6966  ection();.#endif
    │ │ │ -0004a5e0: 0a0a 0909 2f2f 2074 7261 636b 6572 7320  ....// trackers 
    │ │ │ -0004a5f0: 7468 6174 2077 6572 6520 6e6f 7420 7265  that were not re
    │ │ │ -0004a600: 6163 6861 626c 652c 206d 6179 2068 6176  achable, may hav
    │ │ │ -0004a610: 6520 6265 636f 6d65 2072 6561 6368 6162  e become reachab
    │ │ │ -0004a620: 6c65 206e 6f77 2e0a 0909 2f2f 2073 6f20  le now....// so 
    │ │ │ -0004a630: 636c 6561 7220 7468 6520 2264 6973 6162  clear the "disab
    │ │ │ -0004a640: 6c65 6422 2066 6c61 6773 2074 6f20 6c65  led" flags to le
    │ │ │ -0004a650: 7420 7468 656d 2062 6520 7472 6965 6420  t them be tried 
    │ │ │ -0004a660: 6f6e 6520 6d6f 7265 2074 696d 650a 3c64  one more time...fo
    │ │ │ -0004a6a0: 7220 2861 7574 6f26 616d 703b 2074 203a  r (auto& t :
    │ │ │ -0004a6b0: 206d 5f74 6f72 7265 6e74 7329 0a3c 2f64   m_torrents)....t->enab
    │ │ │ -0004a6d0: 6c65 5f61 6c6c 5f74 7261 636b 6572 7328  le_all_trackers(
    │ │ │ -0004a6e0: 293b 0a09 7d0a 0a09 766f 6964 2073 6573  );..}...void ses
    │ │ │ -0004a6f0: 7369 6f6e 5f69 6d70 6c3a 3a72 656f 7065  sion_impl::reope
    │ │ │ -0004a700: 6e5f 6e65 7477 6f72 6b5f 736f 636b 6574  n_network_socket
    │ │ │ -0004a710: 7328 7265 6f70 656e 5f6e 6574 776f 726b  s(reopen_network
    │ │ │ -0004a720: 5f66 6c61 6773 5f74 2063 6f6e 7374 206f  _flags_t const o
    │ │ │ -0004a730: 7074 696f 6e73 290a 097b 0a09 0972 656f  ptions)..{...reo
    │ │ │ -0004a740: 7065 6e5f 6c69 7374 656e 5f73 6f63 6b65  pen_listen_socke
    │ │ │ -0004a750: 7473 2862 6f6f 6c28 6f70 7469 6f6e 7320  ts(bool(options 
    │ │ │ -0004a760: 2661 6d70 3b20 7365 7373 696f 6e5f 6861  & session_ha
    │ │ │ -0004a770: 6e64 6c65 3a3a 7265 6f70 656e 5f6d 6170  ndle::reopen_map
    │ │ │ -0004a780: 5f70 6f72 7473 2929 3b0a 097d 0a0a 096e  _ports));..}...n
    │ │ │ -0004a790: 616d 6573 7061 6365 207b 0a09 0974 656d  amespace {...tem
    │ │ │ -0004a7a0: 706c 6174 6520 266c 743b 7479 7065 6e61  plate <typena
    │ │ │ -0004a7b0: 6d65 204d 6170 5072 6f74 6f63 6f6c 2c20  me MapProtocol, 
    │ │ │ -0004a7c0: 7479 7065 6e61 6d65 2050 726f 746f 5479  typename ProtoTy
    │ │ │ -0004a7d0: 7065 2c20 7479 7065 6e61 6d65 2045 6e64  pe, typename End
    │ │ │ -0004a7e0: 706f 696e 7454 7970 6526 6774 3b0a 0909  pointType>...
    │ │ │ -0004a7f0: 766f 6964 206d 6170 5f70 6f72 7428 4d61  void map_port(Ma
    │ │ │ -0004a800: 7050 726f 746f 636f 6c26 616d 703b 206d  pProtocol& m
    │ │ │ -0004a810: 2c20 5072 6f74 6f54 7970 6520 7072 6f74  , ProtoType prot
    │ │ │ -0004a820: 6f63 6f6c 2c20 456e 6470 6f69 6e74 5479  ocol, EndpointTy
    │ │ │ -0004a830: 7065 2063 6f6e 7374 2661 6d70 3b20 6570  pe const& ep
    │ │ │ -0004a840: 0a09 0909 2c20 706f 7274 5f6d 6170 7069  ...., port_mappi
    │ │ │ -0004a850: 6e67 5f74 2661 6d70 3b20 6d61 705f 6861  ng_t& map_ha
    │ │ │ -0004a860: 6e64 6c65 2c20 7374 643a 3a73 7472 696e  ndle, std::strin
    │ │ │ -0004a870: 6720 636f 6e73 7426 616d 703b 2064 6576  g const& dev
    │ │ │ -0004a880: 6963 6529 0a09 097b 0a09 0909 6966 2028  ice)...{....if (
    │ │ │ -0004a890: 6d61 705f 6861 6e64 6c65 2021 3d20 706f  map_handle != po
    │ │ │ -0004a8a0: 7274 5f6d 6170 7069 6e67 5f74 7b2d 317d  rt_mapping_t{-1}
    │ │ │ -0004a8b0: 2920 6d2e 6465 6c65 7465 5f6d 6170 7069  ) m.delete_mappi
    │ │ │ -0004a8c0: 6e67 286d 6170 5f68 616e 646c 6529 3b0a  ng(map_handle);.
    │ │ │ -0004a8d0: 0909 096d 6170 5f68 616e 646c 6520 3d20  ...map_handle = 
    │ │ │ -0004a8e0: 706f 7274 5f6d 6170 7069 6e67 5f74 7b2d  port_mapping_t{-
    │ │ │ -0004a8f0: 317d 3b0a 0a09 0909 6164 6472 6573 7320  1};.....address 
    │ │ │ -0004a900: 636f 6e73 7420 6164 6472 203d 2065 702e  const addr = ep.
    │ │ │ -0004a910: 6164 6472 6573 7328 293b 0a09 0909 2f2f  address();....//
    │ │ │ -0004a920: 2077 6974 6820 4950 7634 2074 6865 2069   with IPv4 the i
    │ │ │ -0004a930: 6e74 6572 6661 6365 206d 6967 6874 2062  nterface might b
    │ │ │ -0004a940: 6520 6265 6869 6e64 204e 4154 2073 6f20  e behind NAT so 
    │ │ │ -0004a950: 7765 2063 616e 2774 2073 6b69 7020 7468  we can't skip th
    │ │ │ -0004a960: 656d 0a09 0909 2f2f 2062 6173 6564 206f  em....// based o
    │ │ │ -0004a970: 6e20 7468 6520 7363 6f70 6520 6f66 2074  n the scope of t
    │ │ │ -0004a980: 6865 206c 6f63 616c 2061 6464 7265 7373  he local address
    │ │ │ -0004a990: 0a09 0909 6966 2028 6164 6472 2e69 735f  ....if (addr.is_
    │ │ │ -0004a9a0: 7636 2829 2026 616d 703b 2661 6d70 3b20  v6() && 
    │ │ │ -0004a9b0: 6973 5f6c 6f63 616c 2861 6464 7229 290a  is_local(addr)).
    │ │ │ -0004a9c0: 0909 0909 7265 7475 726e 3b0a 0a09 0909  ....return;.....
    │ │ │ -0004a9d0: 2f2f 206f 6e6c 7920 7570 6461 7465 2074  // only update t
    │ │ │ -0004a9e0: 6869 7320 6d61 7070 696e 6720 6966 2077  his mapping if w
    │ │ │ -0004a9f0: 6520 6163 7475 616c 6c79 2068 6176 6520  e actually have 
    │ │ │ -0004aa00: 6120 736f 636b 6574 206c 6973 7465 6e69  a socket listeni
    │ │ │ -0004aa10: 6e67 0a09 0909 6966 2028 6570 2021 3d20  ng....if (ep != 
    │ │ │ -0004aa20: 456e 6470 6f69 6e74 5479 7065 2829 290a  EndpointType()).
    │ │ │ -0004aa30: 0909 0909 6d61 705f 6861 6e64 6c65 203d  ....map_handle =
    │ │ │ -0004aa40: 206d 2e61 6464 5f6d 6170 7069 6e67 2870   m.add_mapping(p
    │ │ │ -0004aa50: 726f 746f 636f 6c2c 2065 702e 706f 7274  rotocol, ep.port
    │ │ │ -0004aa60: 2829 2c20 6570 2c20 6465 7669 6365 293b  (), ep, device);
    │ │ │ -0004aa70: 0a09 097d 0a09 7d0a 0a09 766f 6964 2073  ...}..}...void s
    │ │ │ -0004aa80: 6573 7369 6f6e 5f69 6d70 6c3a 3a72 656d  ession_impl::rem
    │ │ │ -0004aa90: 6170 5f70 6f72 7473 2872 656d 6170 5f70  ap_ports(remap_p
    │ │ │ -0004aaa0: 6f72 745f 6d61 736b 5f74 2063 6f6e 7374  ort_mask_t const
    │ │ │ -0004aab0: 206d 6173 6b0a 0909 2c20 6c69 7374 656e   mask..., listen
    │ │ │ -0004aac0: 5f73 6f63 6b65 745f 7426 616d 703b 2073  _socket_t& s
    │ │ │ -0004aad0: 290a 3c2f 7072 653e 3c2f 7464 3e3c 2f74  ).
    < │ │ │ -0004ab00: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0004ab10: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0004ab40: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ -0004ab50: 2e63 7070 3a32 3838 343c 2f61 3e3c 2f74 .cpp:2884this size │ │ │ -0004ab70: 6e65 6564 2074 6f20 6265 2063 6170 7065 need to be cappe │ │ │ -0004ab80: 643c 2f74 643e 3c2f 7472 3e3c 7472 2069 d

    t │ │ │ -0004abd0: 6869 7320 7369 7a65 206e 6565 6420 746f his size need to │ │ │ -0004abe0: 2062 6520 6361 7070 6564 3c2f 6832 3e3c be capped

    < │ │ │ -0004abf0: 6834 3e2e 2e2f 7372 632f 7365 7373 696f h4>../src/sessio │ │ │ -0004ac00: 6e5f 696d 706c 2e63 7070 3a32 3838 343c n_impl.cpp:2884< │ │ │ -0004ac10: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -0004ac50: 0909 2f2f 2068 616e 6473 6861 6b69 6e67  ..// handshaking
    │ │ │ -0004ac60: 0a09 0909 0972 6574 7572 6e20 736f 636b  .....return sock
    │ │ │ -0004ac70: 6574 5f74 7970 6528 7373 6c5f 7374 7265  et_type(ssl_stre
    │ │ │ -0004ac80: 616d 266c 743b 7463 703a 3a73 6f63 6b65  am<tcp::socke
    │ │ │ -0004ac90: 7426 6774 3b28 7463 703a 3a73 6f63 6b65  t>(tcp::socke
    │ │ │ -0004aca0: 7428 7374 643a 3a6d 6f76 6528 7329 292c  t(std::move(s)),
    │ │ │ -0004acb0: 206d 5f70 6565 725f 7373 6c5f 6374 7829   m_peer_ssl_ctx)
    │ │ │ -0004acc0: 293b 0a09 0909 7d0a 0909 0965 6c73 650a  );....}....else.
    │ │ │ -0004acd0: 2365 6e64 6966 0a09 0909 7b0a 0909 0909  #endif....{.....
    │ │ │ -0004ace0: 7265 7475 726e 2073 6f63 6b65 745f 7479  return socket_ty
    │ │ │ -0004acf0: 7065 2874 6370 3a3a 736f 636b 6574 2873  pe(tcp::socket(s
    │ │ │ -0004ad00: 7464 3a3a 6d6f 7665 2873 2929 293b 0a09  td::move(s)));..
    │ │ │ -0004ad10: 0909 7d0a 0909 7d28 293b 0a0a 2369 6664  ..}...}();..#ifd
    │ │ │ -0004ad20: 6566 2054 4f52 5245 4e54 5f53 534c 5f50  ef TORRENT_SSL_P
    │ │ │ -0004ad30: 4545 5253 0a09 0954 4f52 5245 4e54 5f41  EERS...TORRENT_A
    │ │ │ -0004ad40: 5353 4552 5428 2873 736c 203d 3d20 7472  SSERT((ssl == tr
    │ │ │ -0004ad50: 616e 7370 6f72 743a 3a73 736c 2920 3d3d  ansport::ssl) ==
    │ │ │ -0004ad60: 2069 735f 7373 6c28 6329 293b 0a23 656e   is_ssl(c));.#en
    │ │ │ -0004ad70: 6469 660a 0a23 6966 6465 6620 544f 5252  dif..#ifdef TORR
    │ │ │ -0004ad80: 454e 545f 5353 4c5f 5045 4552 530a 0909  ENT_SSL_PEERS...
    │ │ │ -0004ad90: 6966 2028 7373 6c20 3d3d 2074 7261 6e73  if (ssl == trans
    │ │ │ -0004ada0: 706f 7274 3a3a 7373 6c29 0a09 097b 0a09  port::ssl)...{..
    │ │ │ -0004adb0: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ -0004adc0: 2869 735f 7373 6c28 6329 293b 0a0a 0909  (is_ssl(c));....
    │ │ │ -0004add0: 092f 2f20 7361 7665 2074 6865 2073 6f63  .// save the soc
    │ │ │ -0004ade0: 6b65 7420 736f 2077 6520 6361 6e20 6361  ket so we can ca
    │ │ │ -0004adf0: 6e63 656c 2074 6865 2068 616e 6473 6861  ncel the handsha
    │ │ │ -0004ae00: 6b65 0a3c 6469 7620 7374 796c 653d 2262  ke.
    ...auto iter = │ │ │ -0004ae40: 6d5f 696e 636f 6d69 6e67 5f73 6f63 6b65 m_incoming_socke │ │ │ -0004ae50: 7473 2e65 6d70 6c61 6365 2873 7464 3a3a ts.emplace(std:: │ │ │ -0004ae60: 6d61 6b65 5f75 6e69 7175 6526 6c74 3b73 make_unique<s │ │ │ -0004ae70: 6f63 6b65 745f 7479 7065 2667 743b 2873 ocket_type>(s │ │ │ -0004ae80: 7464 3a3a 6d6f 7665 2863 2929 292e 6669 td::move(c))).fi │ │ │ -0004ae90: 7273 743b 0a3c 2f64 6976 3e0a 0909 0961 rst;.
    ....a │ │ │ -0004aea0: 7574 6f20 736f 636b 203d 2069 7465 722d uto sock = iter- │ │ │ -0004aeb0: 2667 743b 6765 7428 293b 0a09 0909 2f2f >get();....// │ │ │ -0004aec0: 2066 6f72 2053 534c 2063 6f6e 6e65 6374 for SSL connect │ │ │ -0004aed0: 696f 6e73 2c20 696e 636f 6d69 6e67 5f63 ions, incoming_c │ │ │ -0004aee0: 6f6e 6e65 6374 696f 6e28 2920 6973 2063 onnection() is c │ │ │ -0004aef0: 616c 6c65 640a 0909 092f 2f20 6166 7465 alled....// afte │ │ │ -0004af00: 7220 7468 6520 6861 6e64 7368 616b 6520 r the handshake │ │ │ -0004af10: 6973 2064 6f6e 650a 0909 0941 4444 5f4f is done....ADD_O │ │ │ -0004af20: 5554 5354 414e 4449 4e47 5f41 5359 4e43 UTSTANDING_ASYNC │ │ │ -0004af30: 2822 7365 7373 696f 6e5f 696d 706c 3a3a ("session_impl:: │ │ │ -0004af40: 7373 6c5f 6861 6e64 7368 616b 6522 293b ssl_handshake"); │ │ │ -0004af50: 0a09 0909 626f 6f73 743a 3a67 6574 266c ....boost::get&l │ │ │ -0004af60: 743b 7373 6c5f 7374 7265 616d 266c 743b t;ssl_stream< │ │ │ -0004af70: 7463 703a 3a73 6f63 6b65 7426 6774 3b26 tcp::socket>& │ │ │ -0004af80: 6774 3b28 2a2a 6974 6572 292e 6173 796e gt;(**iter).asyn │ │ │ -0004af90: 635f 6163 6365 7074 5f68 616e 6473 6861 c_accept_handsha │ │ │ -0004afa0: 6b65 280a 0909 0909 5b74 6869 732c 2073 ke(.....[this, s │ │ │ -0004afb0: 6f63 6b5d 2028 6572 726f 725f 636f 6465 ock] (error_code │ │ │ -0004afc0: 2063 6f6e 7374 2661 6d70 3b20 6572 7229 const& err) │ │ │ -0004afd0: 207b 2073 736c 5f68 616e 6473 6861 6b65 { ssl_handshake │ │ │ -0004afe0: 2865 7272 2c20 736f 636b 293b 207d 293b (err, sock); }); │ │ │ -0004aff0: 0a09 097d 0a09 0965 6c73 650a 2365 6e64 ...}...else.#end │ │ │ -0004b000: 6966 0a09 097b 0a09 0909 696e 636f 6d69 if...{....incomi │ │ │ -0004b010: 6e67 5f63 6f6e 6e65 6374 696f 6e28 7374 ng_connection(st │ │ │ -0004b020: 643a 3a6d 6f76 6528 6329 293b 0a09 097d d::move(c));...} │ │ │ -0004b030: 0a09 7d0a 0a23 6966 6465 6620 544f 5252 ..}..#ifdef TORR │ │ │ -0004b040: 454e 545f 5353 4c5f 5045 4552 530a 0a09 ENT_SSL_PEERS... │ │ │ -0004b050: 766f 6964 2073 6573 7369 6f6e 5f69 6d70 void session_imp │ │ │ -0004b060: 6c3a 3a6f 6e5f 696e 636f 6d69 6e67 5f75 l::on_incoming_u │ │ │ -0004b070: 7470 5f73 736c 2873 6f63 6b65 745f 7479 tp_ssl(socket_ty │ │ │ -0004b080: 7065 2073 290a 097b 0a09 0954 4f52 5245 pe s)..{...TORRE │ │ │ -0004b090: 4e54 5f41 5353 4552 5428 6973 5f73 736c NT_ASSERT(is_ssl │ │ │ -0004b0a0: 2873 2929 3b0a 0a09 092f 2f20 7361 7665 (s));....// save │ │ │ -0004b0b0: 2074 6865 2073 6f63 6b65 7420 736f 2077 the socket so w │ │ │ -0004b0c0: 6520 6361 6e20 6361 6e63 656c 2074 6865 e can cancel the │ │ │ -0004b0d0: 2068 616e 6473 6861 6b65 0a0a 3c2f 7072 handshake..rel │ │ │ -0004b110: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/se │ │ │ -0004b150: 7373 696f 6e5f 696d 706c 2e63 7070 3a32 ssion_impl.cpp:2 │ │ │ -0004b160: 3930 393c 2f61 3e3c 2f74 643e 3c74 643e 909 │ │ │ -0004b170: 7468 6973 2073 697a 6520 6e65 6564 2074 this size need t │ │ │ -0004b180: 6f20 6265 2063 6170 7065 643c 2f74 643e o be capped │ │ │ -0004b190: 3c2f 7472 3e3c 7472 2069 643d 2231 3830

    this si │ │ │ -0004b1e0: 7a65 206e 6565 6420 746f 2062 6520 6361 ze need to be ca │ │ │ -0004b1f0: 7070 6564 3c2f 6832 3e3c 6834 3e2e 2e2f pped

    ../ │ │ │ -0004b200: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ -0004b210: 2e63 7070 3a32 3930 393c 2f68 343e 3c70 .cpp:2909

    ...// af │ │ │ -0004b260: 7465 7220 7468 6520 6861 6e64 7368 616b ter the handshak │ │ │ -0004b270: 6520 6973 2064 6f6e 650a 0909 0941 4444 e is done....ADD │ │ │ -0004b280: 5f4f 5554 5354 414e 4449 4e47 5f41 5359 _OUTSTANDING_ASY │ │ │ -0004b290: 4e43 2822 7365 7373 696f 6e5f 696d 706c NC("session_impl │ │ │ -0004b2a0: 3a3a 7373 6c5f 6861 6e64 7368 616b 6522 ::ssl_handshake" │ │ │ -0004b2b0: 293b 0a09 0909 626f 6f73 743a 3a67 6574 );....boost::get │ │ │ -0004b2c0: 266c 743b 7373 6c5f 7374 7265 616d 266c <ssl_stream&l │ │ │ -0004b2d0: 743b 7463 703a 3a73 6f63 6b65 7426 6774 t;tcp::socket> │ │ │ -0004b2e0: 3b26 6774 3b28 2a2a 6974 6572 292e 6173 ;>(**iter).as │ │ │ -0004b2f0: 796e 635f 6163 6365 7074 5f68 616e 6473 ync_accept_hands │ │ │ -0004b300: 6861 6b65 280a 0909 0909 5b74 6869 732c hake(.....[this, │ │ │ -0004b310: 2073 6f63 6b5d 2028 6572 726f 725f 636f sock] (error_co │ │ │ -0004b320: 6465 2063 6f6e 7374 2661 6d70 3b20 6572 de const& er │ │ │ -0004b330: 7229 207b 2073 736c 5f68 616e 6473 6861 r) { ssl_handsha │ │ │ -0004b340: 6b65 2865 7272 2c20 736f 636b 293b 207d ke(err, sock); } │ │ │ -0004b350: 293b 0a09 097d 0a09 0965 6c73 650a 2365 );...}...else.#e │ │ │ -0004b360: 6e64 6966 0a09 097b 0a09 0909 696e 636f ndif...{....inco │ │ │ -0004b370: 6d69 6e67 5f63 6f6e 6e65 6374 696f 6e28 ming_connection( │ │ │ -0004b380: 7374 643a 3a6d 6f76 6528 6329 293b 0a09 std::move(c));.. │ │ │ -0004b390: 097d 0a09 7d0a 0a23 6966 6465 6620 544f .}..}..#ifdef TO │ │ │ -0004b3a0: 5252 454e 545f 5353 4c5f 5045 4552 530a RRENT_SSL_PEERS. │ │ │ -0004b3b0: 0a09 766f 6964 2073 6573 7369 6f6e 5f69 ..void session_i │ │ │ -0004b3c0: 6d70 6c3a 3a6f 6e5f 696e 636f 6d69 6e67 mpl::on_incoming │ │ │ -0004b3d0: 5f75 7470 5f73 736c 2873 6f63 6b65 745f _utp_ssl(socket_ │ │ │ -0004b3e0: 7479 7065 2073 290a 097b 0a09 0954 4f52 type s)..{...TOR │ │ │ -0004b3f0: 5245 4e54 5f41 5353 4552 5428 6973 5f73 RENT_ASSERT(is_s │ │ │ -0004b400: 736c 2873 2929 3b0a 0a09 092f 2f20 7361 sl(s));....// sa │ │ │ -0004b410: 7665 2074 6865 2073 6f63 6b65 7420 736f ve the socket so │ │ │ -0004b420: 2077 6520 6361 6e20 6361 6e63 656c 2074 we can cancel t │ │ │ -0004b430: 6865 2068 616e 6473 6861 6b65 0a0a 3c64 he handshake....au │ │ │ -0004b470: 746f 2069 7465 7220 3d20 6d5f 696e 636f to iter = m_inco │ │ │ -0004b480: 6d69 6e67 5f73 6f63 6b65 7473 2e65 6d70 ming_sockets.emp │ │ │ -0004b490: 6c61 6365 2873 7464 3a3a 6d61 6b65 5f75 lace(std::make_u │ │ │ -0004b4a0: 6e69 7175 6526 6c74 3b73 6f63 6b65 745f nique<socket_ │ │ │ -0004b4b0: 7479 7065 2667 743b 2873 7464 3a3a 6d6f type>(std::mo │ │ │ -0004b4c0: 7665 2873 2929 292e 6669 7273 743b 0a3c ve(s))).first;.< │ │ │ -0004b4d0: 2f64 6976 3e09 0961 7574 6f20 736f 636b /div>..auto sock │ │ │ -0004b4e0: 203d 2069 7465 722d 2667 743b 6765 7428 = iter->get( │ │ │ -0004b4f0: 293b 0a0a 0909 2f2f 2066 6f72 2053 534c );....// for SSL │ │ │ -0004b500: 2063 6f6e 6e65 6374 696f 6e73 2c20 696e connections, in │ │ │ -0004b510: 636f 6d69 6e67 5f63 6f6e 6e65 6374 696f coming_connectio │ │ │ -0004b520: 6e28 2920 6973 2063 616c 6c65 640a 0909 n() is called... │ │ │ -0004b530: 2f2f 2061 6674 6572 2074 6865 2068 616e // after the han │ │ │ -0004b540: 6473 6861 6b65 2069 7320 646f 6e65 0a09 dshake is done.. │ │ │ -0004b550: 0941 4444 5f4f 5554 5354 414e 4449 4e47 .ADD_OUTSTANDING │ │ │ -0004b560: 5f41 5359 4e43 2822 7365 7373 696f 6e5f _ASYNC("session_ │ │ │ -0004b570: 696d 706c 3a3a 7373 6c5f 6861 6e64 7368 impl::ssl_handsh │ │ │ -0004b580: 616b 6522 293b 0a09 0962 6f6f 7374 3a3a ake");...boost:: │ │ │ -0004b590: 6765 7426 6c74 3b73 736c 5f73 7472 6561 get<ssl_strea │ │ │ -0004b5a0: 6d26 6c74 3b75 7470 5f73 7472 6561 6d26 m<utp_stream& │ │ │ -0004b5b0: 6774 3b26 6774 3b28 2a2a 6974 6572 292e gt;>(**iter). │ │ │ -0004b5c0: 6173 796e 635f 6163 6365 7074 5f68 616e async_accept_han │ │ │ -0004b5d0: 6473 6861 6b65 280a 0909 095b 7468 6973 dshake(....[this │ │ │ -0004b5e0: 2c20 736f 636b 5d20 2865 7272 6f72 5f63 , sock] (error_c │ │ │ -0004b5f0: 6f64 6520 636f 6e73 7426 616d 703b 2065 ode const& e │ │ │ -0004b600: 7272 2920 7b20 7373 6c5f 6861 6e64 7368 rr) { ssl_handsh │ │ │ -0004b610: 616b 6528 6572 722c 2073 6f63 6b29 3b20 ake(err, sock); │ │ │ -0004b620: 7d29 3b0a 097d 0a0a 092f 2f20 746f 2074 });..}...// to t │ │ │ -0004b630: 6573 7420 5353 4c20 636f 6e6e 6563 7469 est SSL connecti │ │ │ -0004b640: 6f6e 732c 206f 6e65 2063 616e 2075 7365 ons, one can use │ │ │ -0004b650: 2074 6869 7320 6f70 656e 7373 6c20 636f this openssl co │ │ │ -0004b660: 6d6d 616e 6420 7465 6d70 6c61 7465 3a0a mmand template:. │ │ │ -0004b670: 092f 2f0a 092f 2f20 6f70 656e 7373 6c20 .//..// openssl │ │ │ -0004b680: 735f 636c 6965 6e74 202d 6365 7274 2026 s_client -cert & │ │ │ -0004b690: 6c74 3b63 6c69 656e 742d 6365 7274 2667 lt;client-cert&g │ │ │ -0004b6a0: 743b 2e70 656d 202d 6b65 7920 266c 743b t;.pem -key < │ │ │ -0004b6b0: 636c 6965 6e74 2d70 7269 7661 7465 2d6b client-private-k │ │ │ -0004b6c0: 6579 2667 743b 2e70 656d 0a09 2f2f 2020 ey>.pem..// │ │ │ -0004b6d0: 202d 4341 6669 6c65 2026 6c74 3b74 6f72 -CAfile <tor │ │ │ -0004b6e0: 7265 6e74 2d63 6572 7426 6774 3b2e 7065 rent-cert>.pe │ │ │ -0004b6f0: 6d20 202d 6465 6275 6720 2d63 6f6e 6e65 m -debug -conne │ │ │ -0004b700: 6374 2031 3237 2e30 2e30 2e31 3a34 3433 ct 127.0.0.1:443 │ │ │ -0004b710: 3320 2d74 6c73 310a 092f 2f20 2020 2d73 3 -tls1..// -s │ │ │ -0004b720: 6572 7665 726e 616d 6520 266c 743b 6865 ervername <he │ │ │ -0004b730: 782d 656e 636f 6465 642d 696e 666f 2d68 x-encoded-info-h │ │ │ -0004b740: 6173 6826 6774 3b0a 0a09 766f 6964 2073 ash>...void s │ │ │ -0004b750: 6573 7369 6f6e 5f69 6d70 6c3a 3a73 736c ession_impl::ssl │ │ │ -0004b760: 5f68 616e 6473 6861 6b65 2865 7272 6f72 _handshake(error │ │ │ -0004b770: 5f63 6f64 6520 636f 6e73 7426 616d 703b _code const& │ │ │ -0004b780: 2065 632c 2073 6f63 6b65 745f 7479 7065 ec, socket_type │ │ │ -0004b790: 2a20 736f 636b 290a 097b 0a09 0943 4f4d * sock)..{...COM │ │ │ -0004b7a0: 504c 4554 455f 4153 594e 4328 2273 6573 PLETE_ASYNC("ses │ │ │ -0004b7b0: 7369 6f6e 5f69 6d70 6c3a 3a73 736c 5f68 sion_impl::ssl_h │ │ │ -0004b7c0: 616e 6473 6861 6b65 2229 3b0a 0a09 0961 andshake");....a │ │ │ -0004b7d0: 7574 6f20 6974 6572 203d 206d 5f69 6e63 uto iter = m_inc │ │ │ -0004b7e0: 6f6d 696e 675f 736f 636b 6574 732e 6669 oming_sockets.fi │ │ │ -0004b7f0: 6e64 2873 6f63 6b29 3b0a 0a09 092f 2f20 nd(sock);....// │ │ │ -0004b800: 7468 6973 2068 6170 7065 6e73 2069 6620 this happens if │ │ │ -0004b810: 7468 6520 5353 4c20 636f 6e6e 6563 7469 the SSL connecti │ │ │ -0004b820: 6f6e 2069 7320 6162 6f72 7465 6420 6265 on is aborted be │ │ │ -0004b830: 6361 7573 6520 7765 2772 6520 7368 7574 cause we're shut │ │ │ -0004b840: 7469 6e67 0a09 092f 2f20 646f 776e 0a09 ting...// down.. │ │ │ -0004b850: 0969 6620 2869 7465 7220 3d3d 206d 5f69 .if (iter == m_i │ │ │ -0004b860: 6e63 6f6d 696e 675f 736f 636b 6574 732e ncoming_sockets. │ │ │ -0004b870: 656e 6428 2929 2072 6574 7572 6e3b 0a0a end()) return;.. │ │ │ -0004b880: 0909 736f 636b 6574 5f74 7970 6520 7328 ..socket_type s( │ │ │ -0004b890: 7374 643a 3a6d 6f76 6528 2a2a 6974 6572 std::move(**iter │ │ │ -0004b8a0: 2929 3b0a 0909 544f 5252 454e 545f 4153 ));...TORRENT_AS │ │ │ -0004b8b0: 5345 5254 2869 735f 7373 6c28 7329 293b SERT(is_ssl(s)); │ │ │ -0004b8c0: 0a09 096d 5f69 6e63 6f6d 696e 675f 736f ...m_incoming_so │ │ │ -0004b8d0: 636b 6574 732e 6572 6173 6528 6974 6572 ckets.erase(iter │ │ │ -0004b8e0: 293b 0a0a 0909 6572 726f 725f 636f 6465 );....error_code │ │ │ -0004b8f0: 2065 3b0a 3c2f 7072 653e 3c2f 7464 3e3c e;.

    < │ │ │ -0004b900: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -0004b930: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -0004b960: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ -0004b970: 706c 2e63 7070 3a33 3630 383c 2f61 3e3c pl.cpp:3608< │ │ │ -0004b980: 2f74 643e 3c74 643e 6861 7665 2061 2073 /td>have a s │ │ │ -0004b990: 6570 6172 6174 6520 6c69 7374 2066 6f72 eparate list for │ │ │ -0004b9a0: 2074 6865 7365 2063 6f6e 6e65 6374 696f these connectio │ │ │ -0004b9b0: 6e73 2c20 696e 7374 6561 6420 6f66 2068 ns, instead of h │ │ │ -0004b9c0: 6176 696e 6720 746f 206c 6f6f 7020 7468 aving to loop th │ │ │ -0004b9d0: 726f 7567 6820 616c 6c20 6f66 2074 6865 rough all of the │ │ │ -0004b9e0: 6d3c 2f74 643e 3c2f 7472 3e3c 7472 2069 m

    h │ │ │ -0004ba30: 6176 6520 6120 7365 7061 7261 7465 206c ave a separate l │ │ │ -0004ba40: 6973 7420 666f 7220 7468 6573 6520 636f ist for these co │ │ │ -0004ba50: 6e6e 6563 7469 6f6e 732c 2069 6e73 7465 nnections, inste │ │ │ -0004ba60: 6164 206f 6620 6861 7669 6e67 2074 6f20 ad of having to │ │ │ -0004ba70: 6c6f 6f70 2074 6872 6f75 6768 2061 6c6c loop through all │ │ │ -0004ba80: 206f 6620 7468 656d 3c2f 6832 3e3c 6834 of them

    ../src/session_ │ │ │ -0004baa0: 696d 706c 2e63 7070 3a33 3630 383c 2f68 impl.cpp:3608
    ..//
    │ │ │ -0004baf0: 202d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d   ---------------
    │ │ │ -0004bb00: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0004bb10: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0004bb20: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d0a  ---------------.
    │ │ │ -0004bb30: 0909 6966 2028 216d 5f70 6175 7365 6429  ..if (!m_paused)
    │ │ │ -0004bb40: 206d 5f61 7574 6f5f 6d61 6e61 6765 5f74   m_auto_manage_t
    │ │ │ -0004bb50: 696d 655f 7363 616c 6572 2d2d 3b0a 0909  ime_scaler--;...
    │ │ │ -0004bb60: 6966 2028 6d5f 6175 746f 5f6d 616e 6167  if (m_auto_manag
    │ │ │ -0004bb70: 655f 7469 6d65 5f73 6361 6c65 7220 266c  e_time_scaler &l
    │ │ │ -0004bb80: 743b 2030 290a 0909 7b0a 0909 096d 5f61  t; 0)...{....m_a
    │ │ │ -0004bb90: 7574 6f5f 6d61 6e61 6765 5f74 696d 655f  uto_manage_time_
    │ │ │ -0004bba0: 7363 616c 6572 203d 2073 6574 7469 6e67  scaler = setting
    │ │ │ -0004bbb0: 7328 292e 6765 745f 696e 7428 7365 7474  s().get_int(sett
    │ │ │ -0004bbc0: 696e 6773 5f70 6163 6b3a 3a61 7574 6f5f  ings_pack::auto_
    │ │ │ -0004bbd0: 6d61 6e61 6765 5f69 6e74 6572 7661 6c29  manage_interval)
    │ │ │ -0004bbe0: 3b0a 0909 0972 6563 616c 6375 6c61 7465  ;....recalculate
    │ │ │ -0004bbf0: 5f61 7574 6f5f 6d61 6e61 6765 645f 746f  _auto_managed_to
    │ │ │ -0004bc00: 7272 656e 7473 2829 3b0a 0909 7d0a 0a09  rrents();...}...
    │ │ │ -0004bc10: 092f 2f20 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  .// ------------
    │ │ │ -0004bc20: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0004bc30: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0004bc40: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0004bc50: 2d2d 0a09 092f 2f20 6368 6563 6b20 666f  --...// check fo
    │ │ │ -0004bc60: 7220 696e 636f 6d69 6e67 2063 6f6e 6e65  r incoming conne
    │ │ │ -0004bc70: 6374 696f 6e73 2074 6861 7420 6d69 6768  ctions that migh
    │ │ │ -0004bc80: 7420 6861 7665 2074 696d 6564 206f 7574  t have timed out
    │ │ │ -0004bc90: 0a09 092f 2f20 2d2d 2d2d 2d2d 2d2d 2d2d  ...// ----------
    │ │ │ -0004bca0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0004bcb0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0004bcc0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0004bcd0: 2d2d 2d2d 0a0a 0909 666f 7220 2861 7574  ----....for (aut
    │ │ │ -0004bce0: 6f20 6920 3d20 6d5f 636f 6e6e 6563 7469  o i = m_connecti
    │ │ │ -0004bcf0: 6f6e 732e 6265 6769 6e28 293b 2069 2021  ons.begin(); i !
    │ │ │ -0004bd00: 3d20 6d5f 636f 6e6e 6563 7469 6f6e 732e  = m_connections.
    │ │ │ -0004bd10: 656e 6428 293b 290a 0909 7b0a 0909 0970  end();)...{....p
    │ │ │ -0004bd20: 6565 725f 636f 6e6e 6563 7469 6f6e 2a20  eer_connection* 
    │ │ │ -0004bd30: 7020 3d20 282a 6929 2e67 6574 2829 3b0a  p = (*i).get();.
    │ │ │ -0004bd40: 0909 092b 2b69 3b0a 0909 092f 2f20 6967  ...++i;....// ig
    │ │ │ -0004bd50: 6e6f 7265 2063 6f6e 6e65 6374 696f 6e73  nore connections
    │ │ │ -0004bd60: 2074 6861 7420 616c 7265 6164 7920 6861   that already ha
    │ │ │ -0004bd70: 7665 2061 2074 6f72 7265 6e74 2c20 7369  ve a torrent, si
    │ │ │ -0004bd80: 6e63 6520 7468 6579 0a09 0909 2f2f 2061  nce they....// a
    │ │ │ -0004bd90: 7265 2074 6963 6b65 6420 7468 726f 7567  re ticked throug
    │ │ │ -0004bda0: 6820 7468 6520 746f 7272 656e 7473 2720  h the torrents' 
    │ │ │ -0004bdb0: 7365 636f 6e64 5f74 6963 6b0a 0909 0969  second_tick....i
    │ │ │ -0004bdc0: 6620 2821 702d 2667 743b 6173 736f 6369  f (!p->associ
    │ │ │ -0004bdd0: 6174 6564 5f74 6f72 7265 6e74 2829 2e65  ated_torrent().e
    │ │ │ -0004bde0: 7870 6972 6564 2829 2920 636f 6e74 696e  xpired()) contin
    │ │ │ -0004bdf0: 7565 3b0a 0a3c 6469 7620 7374 796c 653d  ue;..
    ...int timeou │ │ │ -0004be30: 7420 3d20 6d5f 7365 7474 696e 6773 2e67 t = m_settings.g │ │ │ -0004be40: 6574 5f69 6e74 2873 6574 7469 6e67 735f et_int(settings_ │ │ │ -0004be50: 7061 636b 3a3a 6861 6e64 7368 616b 655f pack::handshake_ │ │ │ -0004be60: 7469 6d65 6f75 7429 3b0a 3c2f 6469 763e timeout);.
    │ │ │ -0004be70: 2369 6620 544f 5252 454e 545f 5553 455f #if TORRENT_USE_ │ │ │ -0004be80: 4932 500a 0909 0974 696d 656f 7574 202a I2P....timeout * │ │ │ -0004be90: 3d20 6973 5f69 3270 2870 2d26 6774 3b67 = is_i2p(p->g │ │ │ -0004bea0: 6574 5f73 6f63 6b65 7428 2929 203f 2034 et_socket()) ? 4 │ │ │ -0004beb0: 203a 2031 3b0a 2365 6e64 6966 0a09 0909 : 1;.#endif.... │ │ │ -0004bec0: 6966 2028 6d5f 6c61 7374 5f74 6963 6b20 if (m_last_tick │ │ │ -0004bed0: 2d20 702d 2667 743b 636f 6e6e 6563 7465 - p->connecte │ │ │ -0004bee0: 645f 7469 6d65 2028 2920 2667 743b 2073 d_time () > s │ │ │ -0004bef0: 6563 6f6e 6473 2874 696d 656f 7574 2929 econds(timeout)) │ │ │ -0004bf00: 0a09 0909 0970 2d26 6774 3b64 6973 636f .....p->disco │ │ │ -0004bf10: 6e6e 6563 7428 6572 726f 7273 3a3a 7469 nnect(errors::ti │ │ │ -0004bf20: 6d65 645f 6f75 742c 206f 7065 7261 7469 med_out, operati │ │ │ -0004bf30: 6f6e 5f74 3a3a 6269 7474 6f72 7265 6e74 on_t::bittorrent │ │ │ -0004bf40: 293b 0a09 097d 0a0a 0909 2f2f 202d 2d2d );...}....// --- │ │ │ -0004bf50: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0004bf60: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0004bf70: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0004bf80: 2d2d 2d2d 2d2d 2d2d 2d2d 2d0a 0909 2f2f -----------...// │ │ │ -0004bf90: 2073 6563 6f6e 645f 7469 636b 2065 7665 second_tick eve │ │ │ -0004bfa0: 7279 2074 6f72 7265 6e74 2028 7468 6174 ry torrent (that │ │ │ -0004bfb0: 2077 616e 7473 2069 7429 0a09 092f 2f20 wants it)...// │ │ │ -0004bfc0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0004bfd0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0004bfe0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0004bff0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 0a0a --------------.. │ │ │ -0004c000: 2369 6620 544f 5252 454e 545f 4445 4255 #if TORRENT_DEBU │ │ │ -0004c010: 475f 5354 5245 414d 494e 4720 2667 743b G_STREAMING > │ │ │ -0004c020: 2030 0a09 0973 7464 3a3a 7072 696e 7466 0...std::printf │ │ │ -0004c030: 2822 5c30 3333 5b32 4a5c 3033 335b 303b ("\033[2J\033[0; │ │ │ -0004c040: 3048 2229 3b0a 2365 6e64 6966 0a0a 0909 0H");.#endif.... │ │ │ -0004c050: 6175 783a 3a76 6563 746f 7226 6c74 3b74 aux::vector<t │ │ │ -0004c060: 6f72 7265 6e74 2a26 6774 3b26 616d 703b orrent*>& │ │ │ -0004c070: 2077 616e 745f 7469 636b 203d 206d 5f74 want_tick = m_t │ │ │ -0004c080: 6f72 7265 6e74 5f6c 6973 7473 5b74 6f72 orrent_lists[tor │ │ │ -0004c090: 7265 6e74 5f77 616e 745f 7469 636b 5d3b rent_want_tick]; │ │ │ -0004c0a0: 0a09 0966 6f72 2028 696e 7420 6920 3d20 ...for (int i = │ │ │ -0004c0b0: 303b 2069 2026 6c74 3b20 696e 7428 7761 0; i < int(wa │ │ │ -0004c0c0: 6e74 5f74 6963 6b2e 7369 7a65 2829 293b nt_tick.size()); │ │ │ -0004c0d0: 202b 2b69 290a 0909 7b0a 0909 0974 6f72 ++i)...{....tor │ │ │ -0004c0e0: 7265 6e74 2661 6d70 3b20 7420 3d20 2a77 rent& t = *w │ │ │ -0004c0f0: 616e 745f 7469 636b 5b69 5d3b 0a09 0909 ant_tick[i];.... │ │ │ -0004c100: 544f 5252 454e 545f 4153 5345 5254 2874 TORRENT_ASSERT(t │ │ │ -0004c110: 2e77 616e 745f 7469 636b 2829 293b 0a09 .want_tick());.. │ │ │ -0004c120: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -0004c130: 2821 742e 6973 5f61 626f 7274 6564 2829 (!t.is_aborted() │ │ │ -0004c140: 293b 0a0a 0909 0974 2e73 6563 6f6e 645f );.....t.second_ │ │ │ -0004c150: 7469 636b 2874 6963 6b5f 696e 7465 7276 tick(tick_interv │ │ │ -0004c160: 616c 5f6d 7329 3b0a 0a09 0909 2f2f 2069 al_ms);.....// i │ │ │ -0004c170: 6620 7468 6520 6361 6c6c 2074 6f20 7365 f the call to se │ │ │ -0004c180: 636f 6e64 5f74 6963 6b20 6361 7573 6564 cond_tick caused │ │ │ -0004c190: 2074 6865 2074 6f72 7265 6e74 0a09 0909 the torrent.... │ │ │ -0004c1a0: 2f2f 2074 6f20 6e6f 206c 6f6e 6765 7220 // to no longer │ │ │ -0004c1b0: 7761 6e74 2074 6f20 6265 2074 6963 6b65 want to be ticke │ │ │ -0004c1c0: 6420 2869 2e65 2e20 6974 2077 6173 0a09 d (i.e. it was.. │ │ │ -0004c1d0: 0909 2f2f 2072 656d 6f76 6564 2066 726f ..// removed fro │ │ │ -0004c1e0: 6d20 7468 6520 6c69 7374 2920 7765 206e m the list) we n │ │ │ -0004c1f0: 6565 6420 746f 2062 6163 6b20 7570 2074 eed to back up t │ │ │ -0004c200: 6865 2063 6f75 6e74 6572 0a09 0909 2f2f he counter....// │ │ │ -0004c210: 2074 6f20 6e6f 7420 6d69 7373 2074 6865 to not miss the │ │ │ -0004c220: 2074 6f72 7265 6e74 2061 6674 6572 2069 torrent after i │ │ │ -0004c230: 740a 0909 0969 6620 2821 742e 7761 6e74 t....if (!t.want │ │ │ -0004c240: 5f74 6963 6b28 2929 202d 2d69 3b0a 0909 _tick()) --i;... │ │ │ -0004c250: 7d0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 }.
    < │ │ │ -0004c280: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0004c290: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0004c2c0: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ -0004c2d0: 2e63 7070 3a33 3634 313c 2f61 3e3c 2f74 .cpp:3641this shoul │ │ │ -0004c2f0: 6420 6170 706c 7920 746f 2061 6c6c 2062 d apply to all b │ │ │ -0004c300: 616e 6477 6964 7468 2063 6861 6e6e 656c andwidth channel │ │ │ -0004c310: 733c 2f74 643e 3c2f 7472 3e3c 7472 2069 s

    t │ │ │ -0004c360: 6869 7320 7368 6f75 6c64 2061 7070 6c79 his should apply │ │ │ -0004c370: 2074 6f20 616c 6c20 6261 6e64 7769 6474 to all bandwidt │ │ │ -0004c380: 6820 6368 616e 6e65 6c73 3c2f 6832 3e3c h channels

    < │ │ │ -0004c390: 6834 3e2e 2e2f 7372 632f 7365 7373 696f h4>../src/sessio │ │ │ -0004c3a0: 6e5f 696d 706c 2e63 7070 3a33 3634 313c n_impl.cpp:3641< │ │ │ -0004c3b0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    #i
    │ │ │ -0004c3f0: 6620 544f 5252 454e 545f 4445 4255 475f  f TORRENT_DEBUG_
    │ │ │ -0004c400: 5354 5245 414d 494e 4720 2667 743b 2030  STREAMING > 0
    │ │ │ -0004c410: 0a09 0973 7464 3a3a 7072 696e 7466 2822  ...std::printf("
    │ │ │ -0004c420: 5c30 3333 5b32 4a5c 3033 335b 303b 3048  \033[2J\033[0;0H
    │ │ │ -0004c430: 2229 3b0a 2365 6e64 6966 0a0a 0909 6175  ");.#endif....au
    │ │ │ -0004c440: 783a 3a76 6563 746f 7226 6c74 3b74 6f72  x::vector<tor
    │ │ │ -0004c450: 7265 6e74 2a26 6774 3b26 616d 703b 2077  rent*>& w
    │ │ │ -0004c460: 616e 745f 7469 636b 203d 206d 5f74 6f72  ant_tick = m_tor
    │ │ │ -0004c470: 7265 6e74 5f6c 6973 7473 5b74 6f72 7265  rent_lists[torre
    │ │ │ -0004c480: 6e74 5f77 616e 745f 7469 636b 5d3b 0a09  nt_want_tick];..
    │ │ │ -0004c490: 0966 6f72 2028 696e 7420 6920 3d20 303b  .for (int i = 0;
    │ │ │ -0004c4a0: 2069 2026 6c74 3b20 696e 7428 7761 6e74   i < int(want
    │ │ │ -0004c4b0: 5f74 6963 6b2e 7369 7a65 2829 293b 202b  _tick.size()); +
    │ │ │ -0004c4c0: 2b69 290a 0909 7b0a 0909 0974 6f72 7265  +i)...{....torre
    │ │ │ -0004c4d0: 6e74 2661 6d70 3b20 7420 3d20 2a77 616e  nt& t = *wan
    │ │ │ -0004c4e0: 745f 7469 636b 5b69 5d3b 0a09 0909 544f  t_tick[i];....TO
    │ │ │ -0004c4f0: 5252 454e 545f 4153 5345 5254 2874 2e77  RRENT_ASSERT(t.w
    │ │ │ -0004c500: 616e 745f 7469 636b 2829 293b 0a09 0909  ant_tick());....
    │ │ │ -0004c510: 544f 5252 454e 545f 4153 5345 5254 2821  TORRENT_ASSERT(!
    │ │ │ -0004c520: 742e 6973 5f61 626f 7274 6564 2829 293b  t.is_aborted());
    │ │ │ -0004c530: 0a0a 0909 0974 2e73 6563 6f6e 645f 7469  .....t.second_ti
    │ │ │ -0004c540: 636b 2874 6963 6b5f 696e 7465 7276 616c  ck(tick_interval
    │ │ │ -0004c550: 5f6d 7329 3b0a 0a09 0909 2f2f 2069 6620  _ms);.....// if 
    │ │ │ -0004c560: 7468 6520 6361 6c6c 2074 6f20 7365 636f  the call to seco
    │ │ │ -0004c570: 6e64 5f74 6963 6b20 6361 7573 6564 2074  nd_tick caused t
    │ │ │ -0004c580: 6865 2074 6f72 7265 6e74 0a09 0909 2f2f  he torrent....//
    │ │ │ -0004c590: 2074 6f20 6e6f 206c 6f6e 6765 7220 7761   to no longer wa
    │ │ │ -0004c5a0: 6e74 2074 6f20 6265 2074 6963 6b65 6420  nt to be ticked 
    │ │ │ -0004c5b0: 2869 2e65 2e20 6974 2077 6173 0a09 0909  (i.e. it was....
    │ │ │ -0004c5c0: 2f2f 2072 656d 6f76 6564 2066 726f 6d20  // removed from 
    │ │ │ -0004c5d0: 7468 6520 6c69 7374 2920 7765 206e 6565  the list) we nee
    │ │ │ -0004c5e0: 6420 746f 2062 6163 6b20 7570 2074 6865  d to back up the
    │ │ │ -0004c5f0: 2063 6f75 6e74 6572 0a09 0909 2f2f 2074   counter....// t
    │ │ │ -0004c600: 6f20 6e6f 7420 6d69 7373 2074 6865 2074  o not miss the t
    │ │ │ -0004c610: 6f72 7265 6e74 2061 6674 6572 2069 740a  orrent after it.
    │ │ │ -0004c620: 0909 0969 6620 2821 742e 7761 6e74 5f74  ...if (!t.want_t
    │ │ │ -0004c630: 6963 6b28 2929 202d 2d69 3b0a 0909 7d0a  ick()) --i;...}.
    │ │ │ -0004c640: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -0004c670: 0969 6620 286d 5f73 6574 7469 6e67 732e .if (m_settings. │ │ │ -0004c680: 6765 745f 626f 6f6c 2873 6574 7469 6e67 get_bool(setting │ │ │ -0004c690: 735f 7061 636b 3a3a 7261 7465 5f6c 696d s_pack::rate_lim │ │ │ -0004c6a0: 6974 5f69 705f 6f76 6572 6865 6164 2929 it_ip_overhead)) │ │ │ -0004c6b0: 0a3c 2f64 6976 3e09 097b 0a09 0909 696e .
    ..{....in │ │ │ -0004c6c0: 7420 636f 6e73 7420 7570 5f6c 696d 6974 t const up_limit │ │ │ -0004c6d0: 203d 2075 706c 6f61 645f 7261 7465 5f6c = upload_rate_l │ │ │ -0004c6e0: 696d 6974 286d 5f67 6c6f 6261 6c5f 636c imit(m_global_cl │ │ │ -0004c6f0: 6173 7329 3b0a 0909 0969 6e74 2063 6f6e ass);....int con │ │ │ -0004c700: 7374 2064 6f77 6e5f 6c69 6d69 7420 3d20 st down_limit = │ │ │ -0004c710: 646f 776e 6c6f 6164 5f72 6174 655f 6c69 download_rate_li │ │ │ -0004c720: 6d69 7428 6d5f 676c 6f62 616c 5f63 6c61 mit(m_global_cla │ │ │ -0004c730: 7373 293b 0a0a 0909 0969 6620 2864 6f77 ss);.....if (dow │ │ │ -0004c740: 6e5f 6c69 6d69 7420 2667 743b 2030 0a09 n_limit > 0.. │ │ │ -0004c750: 0909 0926 616d 703b 2661 6d70 3b20 6d5f ...&& m_ │ │ │ -0004c760: 7374 6174 2e64 6f77 6e6c 6f61 645f 6970 stat.download_ip │ │ │ -0004c770: 5f6f 7665 7268 6561 6428 2920 2667 743b _overhead() > │ │ │ -0004c780: 3d20 646f 776e 5f6c 696d 6974 0a09 0909 = down_limit.... │ │ │ -0004c790: 0926 616d 703b 2661 6d70 3b20 6d5f 616c .&& m_al │ │ │ -0004c7a0: 6572 7473 2e73 686f 756c 645f 706f 7374 erts.should_post │ │ │ -0004c7b0: 266c 743b 7065 7266 6f72 6d61 6e63 655f <performance_ │ │ │ -0004c7c0: 616c 6572 7426 6774 3b28 2929 0a09 0909 alert>()).... │ │ │ -0004c7d0: 7b0a 0909 0909 6d5f 616c 6572 7473 2e65 {.....m_alerts.e │ │ │ -0004c7e0: 6d70 6c61 6365 5f61 6c65 7274 266c 743b mplace_alert< │ │ │ -0004c7f0: 7065 7266 6f72 6d61 6e63 655f 616c 6572 performance_aler │ │ │ -0004c800: 7426 6774 3b28 746f 7272 656e 745f 6861 t>(torrent_ha │ │ │ -0004c810: 6e64 6c65 2829 0a09 0909 0909 2c20 7065 ndle()......, pe │ │ │ -0004c820: 7266 6f72 6d61 6e63 655f 616c 6572 743a rformance_alert: │ │ │ -0004c830: 3a64 6f77 6e6c 6f61 645f 6c69 6d69 745f :download_limit_ │ │ │ -0004c840: 746f 6f5f 6c6f 7729 3b0a 0909 097d 0a0a too_low);....}.. │ │ │ -0004c850: 0909 0969 6620 2875 705f 6c69 6d69 7420 ...if (up_limit │ │ │ -0004c860: 2667 743b 2030 0a09 0909 0926 616d 703b > 0.....& │ │ │ -0004c870: 2661 6d70 3b20 6d5f 7374 6174 2e75 706c & m_stat.upl │ │ │ -0004c880: 6f61 645f 6970 5f6f 7665 7268 6561 6428 oad_ip_overhead( │ │ │ -0004c890: 2920 2667 743b 3d20 7570 5f6c 696d 6974 ) >= up_limit │ │ │ -0004c8a0: 0a09 0909 0926 616d 703b 2661 6d70 3b20 .....&& │ │ │ -0004c8b0: 6d5f 616c 6572 7473 2e73 686f 756c 645f m_alerts.should_ │ │ │ -0004c8c0: 706f 7374 266c 743b 7065 7266 6f72 6d61 post<performa │ │ │ -0004c8d0: 6e63 655f 616c 6572 7426 6774 3b28 2929 nce_alert>()) │ │ │ -0004c8e0: 0a09 0909 7b0a 0909 0909 6d5f 616c 6572 ....{.....m_aler │ │ │ -0004c8f0: 7473 2e65 6d70 6c61 6365 5f61 6c65 7274 ts.emplace_alert │ │ │ -0004c900: 266c 743b 7065 7266 6f72 6d61 6e63 655f <performance_ │ │ │ -0004c910: 616c 6572 7426 6774 3b28 746f 7272 656e alert>(torren │ │ │ -0004c920: 745f 6861 6e64 6c65 2829 0a09 0909 0909 t_handle()...... │ │ │ -0004c930: 2c20 7065 7266 6f72 6d61 6e63 655f 616c , performance_al │ │ │ -0004c940: 6572 743a 3a75 706c 6f61 645f 6c69 6d69 ert::upload_limi │ │ │ -0004c950: 745f 746f 6f5f 6c6f 7729 3b0a 0909 097d t_too_low);....} │ │ │ -0004c960: 0a09 097d 0a0a 2369 6620 544f 5252 454e ...}..#if TORREN │ │ │ -0004c970: 545f 4142 495f 5645 5253 494f 4e20 3d3d T_ABI_VERSION == │ │ │ -0004c980: 2031 0a09 096d 5f70 6561 6b5f 7570 5f72 1...m_peak_up_r │ │ │ -0004c990: 6174 6520 3d20 7374 643a 3a6d 6178 286d ate = std::max(m │ │ │ -0004c9a0: 5f73 7461 742e 7570 6c6f 6164 5f72 6174 _stat.upload_rat │ │ │ -0004c9b0: 6528 292c 206d 5f70 6561 6b5f 7570 5f72 e(), m_peak_up_r │ │ │ -0004c9c0: 6174 6529 3b0a 2365 6e64 6966 0a0a 0909 ate);.#endif.... │ │ │ -0004c9d0: 6d5f 7374 6174 2e73 6563 6f6e 645f 7469 m_stat.second_ti │ │ │ -0004c9e0: 636b 2874 6963 6b5f 696e 7465 7276 616c ck(tick_interval │ │ │ -0004c9f0: 5f6d 7329 3b0a 0a09 092f 2f20 2d2d 2d2d _ms);....// ---- │ │ │ -0004ca00: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0004ca10: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0004ca20: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0004ca30: 2d2d 2d2d 2d2d 2d2d 2d2d 0a09 092f 2f20 ----------...// │ │ │ -0004ca40: 7363 7261 7065 2070 6175 7365 6420 746f scrape paused to │ │ │ -0004ca50: 7272 656e 7473 2074 6861 7420 6172 6520 rrents that are │ │ │ -0004ca60: 6175 746f 206d 616e 6167 6564 0a09 092f auto managed.../ │ │ │ -0004ca70: 2f20 2875 6e6c 6573 7320 7468 6520 7365 / (unless the se │ │ │ -0004ca80: 7373 696f 6e20 6973 2070 6175 7365 6429 ssion is paused) │ │ │ -0004ca90: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -0004cad0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ -0004cb00: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ -0004cb10: 6370 703a 3433 3332 3c2f 613e 3c2f 7464 cpp:4332use a lower │ │ │ -0004cb30: 206c 696d 6974 2074 6861 6e20 6d5f 7365 limit than m_se │ │ │ -0004cb40: 7474 696e 6773 2e63 6f6e 6e65 6374 696f ttings.connectio │ │ │ -0004cb50: 6e73 5f6c 696d 6974 2074 6f20 616c 6c6f ns_limit to allo │ │ │ -0004cb60: 6361 7465 2074 6865 2074 6f20 3130 2520 cate the to 10% │ │ │ -0004cb70: 6f72 2073 6f20 6f66 2063 6f6e 6e65 6374 or so of connect │ │ │ -0004cb80: 696f 6e20 736c 6f74 7320 666f 7220 696e ion slots for in │ │ │ -0004cb90: 636f 6d69 6e67 2063 6f6e 6e65 6374 696f coming connectio │ │ │ -0004cba0: 6e73 2063 6170 2074 6869 7320 6174 206d ns cap this at m │ │ │ -0004cbb0: 6178 202d 2031 2c20 7369 6e63 6520 7765 ax - 1, since we │ │ │ -0004cbc0: 206d 6179 2061 6464 206f 6e65 2062 656c may add one bel │ │ │ -0004cbd0: 6f77 3c2f 7464 3e3c 2f74 723e 3c74 7220 ow

    │ │ │ -0004cc20: 7573 6520 6120 6c6f 7765 7220 6c69 6d69 use a lower limi │ │ │ -0004cc30: 7420 7468 616e 206d 5f73 6574 7469 6e67 t than m_setting │ │ │ -0004cc40: 732e 636f 6e6e 6563 7469 6f6e 735f 6c69 s.connections_li │ │ │ -0004cc50: 6d69 740a 746f 2061 6c6c 6f63 6174 6520 mit.to allocate │ │ │ -0004cc60: 7468 6520 746f 2031 3025 206f 7220 736f the to 10% or so │ │ │ -0004cc70: 206f 6620 636f 6e6e 6563 7469 6f6e 2073 of connection s │ │ │ -0004cc80: 6c6f 7473 2066 6f72 2069 6e63 6f6d 696e lots for incomin │ │ │ -0004cc90: 670a 636f 6e6e 6563 7469 6f6e 730a 6361 g.connections.ca │ │ │ -0004cca0: 7020 7468 6973 2061 7420 6d61 7820 2d20 p this at max - │ │ │ -0004ccb0: 312c 2073 696e 6365 2077 6520 6d61 7920 1, since we may │ │ │ -0004ccc0: 6164 6420 6f6e 6520 6265 6c6f 773c 2f68 add one below

    ../src/ses │ │ │ -0004cce0: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3433 sion_impl.cpp:43 │ │ │ -0004ccf0: 3332 3c2f 6834 3e3c 7072 6520 7374 796c 32

    ..// boost, whi
    │ │ │ -0004cd40: 6368 2061 7265 2064 6f6e 6520 696d 6d65  ch are done imme
    │ │ │ -0004cd50: 6469 6174 656c 7920 6f6e 2061 2074 7261  diately on a tra
    │ │ │ -0004cd60: 636b 6572 2072 6573 706f 6e73 652e 2054  cker response. T
    │ │ │ -0004cd70: 6865 7365 0a09 092f 2f20 636f 6e6e 6563  hese...// connec
    │ │ │ -0004cd80: 7469 6f6e 7320 6e65 6564 7320 746f 2062  tions needs to b
    │ │ │ -0004cd90: 6520 6465 6475 6374 6564 2066 726f 6d20  e deducted from 
    │ │ │ -0004cda0: 7468 6520 7265 6775 6c61 7220 636f 6e6e  the regular conn
    │ │ │ -0004cdb0: 6563 7469 6f6e 2061 7474 656d 7074 0a09  ection attempt..
    │ │ │ -0004cdc0: 092f 2f20 7175 6f74 6120 666f 7220 7468  .// quota for th
    │ │ │ -0004cdd0: 6973 2074 6963 6b0a 0909 6966 2028 6d5f  is tick...if (m_
    │ │ │ -0004cde0: 626f 6f73 745f 636f 6e6e 6563 7469 6f6e  boost_connection
    │ │ │ -0004cdf0: 7320 2667 743b 2030 290a 0909 7b0a 0909  s > 0)...{...
    │ │ │ -0004ce00: 0969 6620 286d 5f62 6f6f 7374 5f63 6f6e  .if (m_boost_con
    │ │ │ -0004ce10: 6e65 6374 696f 6e73 2026 6774 3b20 6d61  nections > ma
    │ │ │ -0004ce20: 785f 636f 6e6e 6563 7469 6f6e 7329 0a09  x_connections)..
    │ │ │ -0004ce30: 0909 7b0a 0909 0909 6d5f 626f 6f73 745f  ..{.....m_boost_
    │ │ │ -0004ce40: 636f 6e6e 6563 7469 6f6e 7320 2d3d 206d  connections -= m
    │ │ │ -0004ce50: 6178 5f63 6f6e 6e65 6374 696f 6e73 3b0a  ax_connections;.
    │ │ │ -0004ce60: 0909 0909 6d61 785f 636f 6e6e 6563 7469  ....max_connecti
    │ │ │ -0004ce70: 6f6e 7320 3d20 303b 0a09 0909 7d0a 0909  ons = 0;....}...
    │ │ │ -0004ce80: 0965 6c73 650a 0909 097b 0a09 0909 096d  .else....{.....m
    │ │ │ -0004ce90: 6178 5f63 6f6e 6e65 6374 696f 6e73 202d  ax_connections -
    │ │ │ -0004cea0: 3d20 6d5f 626f 6f73 745f 636f 6e6e 6563  = m_boost_connec
    │ │ │ -0004ceb0: 7469 6f6e 733b 0a09 0909 096d 5f62 6f6f  tions;.....m_boo
    │ │ │ -0004cec0: 7374 5f63 6f6e 6e65 6374 696f 6e73 203d  st_connections =
    │ │ │ -0004ced0: 2030 3b0a 0909 097d 0a09 097d 0a0a 0909   0;....}...}....
    │ │ │ -0004cee0: 2f2f 207a 6572 6f20 636f 6e6e 6563 7469  // zero connecti
    │ │ │ -0004cef0: 6f6e 7320 7370 6565 6473 2061 7265 2061  ons speeds are a
    │ │ │ -0004cf00: 6c6c 6f77 6564 2c20 7765 206a 7573 7420  llowed, we just 
    │ │ │ -0004cf10: 776f 6e27 7420 6d61 6b65 2061 6e79 2063  won't make any c
    │ │ │ -0004cf20: 6f6e 6e65 6374 696f 6e73 0a09 0969 6620  onnections...if 
    │ │ │ -0004cf30: 286d 6178 5f63 6f6e 6e65 6374 696f 6e73  (max_connections
    │ │ │ -0004cf40: 2026 6c74 3b3d 2030 2920 7265 7475 726e   <= 0) return
    │ │ │ -0004cf50: 3b0a 0a3c 6469 7620 7374 796c 653d 2262  ;..
    ..int const lim │ │ │ -0004cf90: 6974 203d 2073 7464 3a3a 6d69 6e28 6d5f it = std::min(m_ │ │ │ -0004cfa0: 7365 7474 696e 6773 2e67 6574 5f69 6e74 settings.get_int │ │ │ -0004cfb0: 2873 6574 7469 6e67 735f 7061 636b 3a3a (settings_pack:: │ │ │ -0004cfc0: 636f 6e6e 6563 7469 6f6e 735f 6c69 6d69 connections_limi │ │ │ -0004cfd0: 7429 0a3c 2f64 6976 3e09 0909 2d20 6e75 t).
    ...- nu │ │ │ -0004cfe0: 6d5f 636f 6e6e 6563 7469 6f6e 7328 292c m_connections(), │ │ │ -0004cff0: 2073 7464 3a3a 6e75 6d65 7269 635f 6c69 std::numeric_li │ │ │ -0004d000: 6d69 7473 266c 743b 696e 7426 6774 3b3a mits<int>: │ │ │ -0004d010: 3a6d 6178 2829 202d 2031 293b 0a0a 0909 :max() - 1);.... │ │ │ -0004d020: 2f2f 2074 6869 7320 6c6f 6769 6320 6973 // this logic is │ │ │ -0004d030: 2068 6572 6520 746f 2073 6d6f 6f74 6820 here to smooth │ │ │ -0004d040: 6f75 7420 7468 6520 6e75 6d62 6572 206f out the number o │ │ │ -0004d050: 6620 6e65 7720 636f 6e6e 6563 7469 6f6e f new connection │ │ │ -0004d060: 0a09 092f 2f20 6174 7465 6d70 7473 206f ...// attempts o │ │ │ -0004d070: 7665 7220 7469 6d65 2c20 746f 2070 7265 ver time, to pre │ │ │ -0004d080: 7665 6e74 2063 6f6e 6e65 6374 696e 6720 vent connecting │ │ │ -0004d090: 6120 6c61 7267 6520 6e75 6d62 6572 206f a large number o │ │ │ -0004d0a0: 660a 0909 2f2f 2073 6f63 6b65 7473 2c20 f...// sockets, │ │ │ -0004d0b0: 7761 6974 2031 3020 7365 636f 6e64 732c wait 10 seconds, │ │ │ -0004d0c0: 2061 6e64 2074 6865 6e20 7472 7920 6167 and then try ag │ │ │ -0004d0d0: 6169 6e0a 0909 6966 2028 6d5f 7365 7474 ain...if (m_sett │ │ │ -0004d0e0: 696e 6773 2e67 6574 5f62 6f6f 6c28 7365 ings.get_bool(se │ │ │ -0004d0f0: 7474 696e 6773 5f70 6163 6b3a 3a73 6d6f ttings_pack::smo │ │ │ -0004d100: 6f74 685f 636f 6e6e 6563 7473 2920 2661 oth_connects) &a │ │ │ -0004d110: 6d70 3b26 616d 703b 206d 6178 5f63 6f6e mp;& max_con │ │ │ -0004d120: 6e65 6374 696f 6e73 2026 6774 3b20 286c nections > (l │ │ │ -0004d130: 696d 6974 2b31 2920 2f20 3229 0a09 0909 imit+1) / 2).... │ │ │ -0004d140: 6d61 785f 636f 6e6e 6563 7469 6f6e 7320 max_connections │ │ │ -0004d150: 3d20 286c 696d 6974 202b 2031 2920 2f20 = (limit + 1) / │ │ │ -0004d160: 323b 0a0a 0909 6175 783a 3a76 6563 746f 2;....aux::vecto │ │ │ -0004d170: 7226 6c74 3b74 6f72 7265 6e74 2a26 6774 r<torrent*> │ │ │ -0004d180: 3b26 616d 703b 2077 616e 745f 7065 6572 ;& want_peer │ │ │ -0004d190: 735f 646f 776e 6c6f 6164 203d 206d 5f74 s_download = m_t │ │ │ -0004d1a0: 6f72 7265 6e74 5f6c 6973 7473 5b74 6f72 orrent_lists[tor │ │ │ -0004d1b0: 7265 6e74 5f77 616e 745f 7065 6572 735f rent_want_peers_ │ │ │ -0004d1c0: 646f 776e 6c6f 6164 5d3b 0a09 0961 7578 download];...aux │ │ │ -0004d1d0: 3a3a 7665 6374 6f72 266c 743b 746f 7272 ::vector<torr │ │ │ -0004d1e0: 656e 742a 2667 743b 2661 6d70 3b20 7761 ent*>& wa │ │ │ -0004d1f0: 6e74 5f70 6565 7273 5f66 696e 6973 6865 nt_peers_finishe │ │ │ -0004d200: 6420 3d20 6d5f 746f 7272 656e 745f 6c69 d = m_torrent_li │ │ │ -0004d210: 7374 735b 746f 7272 656e 745f 7761 6e74 sts[torrent_want │ │ │ -0004d220: 5f70 6565 7273 5f66 696e 6973 6865 645d _peers_finished] │ │ │ -0004d230: 3b0a 0a09 092f 2f20 6966 206e 6f20 746f ;....// if no to │ │ │ -0004d240: 7272 656e 7420 7761 6e74 2061 6e79 2070 rrent want any p │ │ │ -0004d250: 6565 7273 2c20 6a75 7374 2072 6574 7572 eers, just retur │ │ │ -0004d260: 6e0a 0909 6966 2028 7761 6e74 5f70 6565 n...if (want_pee │ │ │ -0004d270: 7273 5f64 6f77 6e6c 6f61 642e 656d 7074 rs_download.empt │ │ │ -0004d280: 7928 2920 2661 6d70 3b26 616d 703b 2077 y() && w │ │ │ -0004d290: 616e 745f 7065 6572 735f 6669 6e69 7368 ant_peers_finish │ │ │ -0004d2a0: 6564 2e65 6d70 7479 2829 2920 7265 7475 ed.empty()) retu │ │ │ -0004d2b0: 726e 3b0a 0a09 092f 2f20 6966 2077 6520 rn;....// if we │ │ │ -0004d2c0: 646f 6e27 7420 6861 7665 2061 6e79 2063 don't have any c │ │ │ -0004d2d0: 6f6e 6e65 6374 696f 6e20 6174 7465 6d70 onnection attemp │ │ │ -0004d2e0: 7420 7175 6f74 612c 2072 6574 7572 6e0a t quota, return. │ │ │ -0004d2f0: 0909 6966 2028 6d61 785f 636f 6e6e 6563 ..if (max_connec │ │ │ -0004d300: 7469 6f6e 7320 266c 743b 3d20 3029 2072 tions <= 0) r │ │ │ -0004d310: 6574 7572 6e3b 0a0a 0909 696e 7420 7374 eturn;....int st │ │ │ -0004d320: 6570 735f 7369 6e63 655f 6c61 7374 5f63 eps_since_last_c │ │ │ -0004d330: 6f6e 6e65 6374 203d 2030 3b0a 0909 696e onnect = 0;...in │ │ │ -0004d340: 7420 636f 6e73 7420 6e75 6d5f 746f 7272 t const num_torr │ │ │ -0004d350: 656e 7473 203d 2069 6e74 2877 616e 745f ents = int(want_ │ │ │ -0004d360: 7065 6572 735f 6669 6e69 7368 6564 2e73 peers_finished.s │ │ │ -0004d370: 697a 6528 2920 2b20 7761 6e74 5f70 6565 ize() + want_pee │ │ │ -0004d380: 7273 5f64 6f77 6e6c 6f61 642e 7369 7a65 rs_download.size │ │ │ -0004d390: 2829 293b 0a09 0966 6f72 2028 3b3b 290a ());...for (;;). │ │ │ -0004d3a0: 0909 7b0a 0909 0969 6620 286d 5f6e 6578 ..{....if (m_nex │ │ │ -0004d3b0: 745f 646f 776e 6c6f 6164 696e 675f 636f t_downloading_co │ │ │ -0004d3c0: 6e6e 6563 745f 746f 7272 656e 7420 2667 nnect_torrent &g │ │ │ -0004d3d0: 743b 3d20 696e 7428 7761 6e74 5f70 6565 t;= int(want_pee │ │ │ -0004d3e0: 7273 5f64 6f77 6e6c 6f61 642e 7369 7a65 rs_download.size │ │ │ -0004d3f0: 2829 2929 0a09 0909 096d 5f6e 6578 745f ())).....m_next_ │ │ │ -0004d400: 646f 776e 6c6f 6164 696e 675f 636f 6e6e downloading_conn │ │ │ -0004d410: 6563 745f 746f 7272 656e 7420 3d20 303b ect_torrent = 0; │ │ │ -0004d420: 0a0a 0909 0969 6620 286d 5f6e 6578 745f .....if (m_next_ │ │ │ -0004d430: 6669 6e69 7368 6564 5f63 6f6e 6e65 6374 finished_connect │ │ │ -0004d440: 5f74 6f72 7265 6e74 2026 6774 3b3d 2069 _torrent >= i │ │ │ -0004d450: 6e74 2877 616e 745f 7065 6572 735f 6669 nt(want_peers_fi │ │ │ -0004d460: 6e69 7368 6564 2e73 697a 6528 2929 290a nished.size())). │ │ │ -0004d470: 0909 0909 6d5f 6e65 7874 5f66 696e 6973 ....m_next_finis │ │ │ -0004d480: 6865 645f 636f 6e6e 6563 745f 746f 7272 hed_connect_torr │ │ │ -0004d490: 656e 7420 3d20 303b 0a0a 0909 0974 6f72 ent = 0;.....tor │ │ │ -0004d4a0: 7265 6e74 2a20 7420 3d20 6e75 6c6c 7074 rent* t = nullpt │ │ │ -0004d4b0: 723b 0a09 0909 2f2f 2074 6865 7265 2061 r;....// there a │ │ │ -0004d4c0: 7265 2070 7269 6f72 6974 697a 6564 2074 re prioritized t │ │ │ -0004d4d0: 6f72 7265 6e74 732e 2050 6963 6b20 6f6e orrents. Pick on │ │ │ -0004d4e0: 6520 6f66 2074 686f 7365 0a09 0909 7768 e of those....wh │ │ │ -0004d4f0: 696c 6520 2821 6d5f 7072 696f 5f74 6f72 ile (!m_prio_tor │ │ │ -0004d500: 7265 6e74 732e 656d 7074 7928 2929 0a3c rents.empty()).< │ │ │ -0004d510: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -0004d520: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -0004d530: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -0004d540: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -0004d550: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -0004d580: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ -0004d590: 703a 3434 3737 3c2f 613e 3c2f 7464 3e3c p:4477< │ │ │ -0004d5a0: 7464 3e70 6f73 7420 6120 6d65 7373 6167 td>post a messag │ │ │ -0004d5b0: 6520 746f 2068 6176 6520 7468 6973 2068 e to have this h │ │ │ -0004d5c0: 6170 7065 6e20 696d 6d65 6469 6174 656c appen immediatel │ │ │ -0004d5d0: 7920 696e 7374 6561 6420 6f66 2077 6169 y instead of wai │ │ │ -0004d5e0: 7469 6e67 2066 6f72 2074 6865 206e 6578 ting for the nex │ │ │ -0004d5f0: 7420 7469 636b 3c2f 7464 3e3c 2f74 723e t tick │ │ │ -0004d600: 3c74 7220 6964 3d22 3138 3422 2073 7479 │ │ │ -0004d630: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0004d640: 3c68 323e 706f 7374 2061 206d 6573 7361

    post a messa │ │ │ -0004d650: 6765 2074 6f20 6861 7665 2074 6869 7320 ge to have this │ │ │ -0004d660: 6861 7070 656e 0a69 6d6d 6564 6961 7465 happen.immediate │ │ │ -0004d670: 6c79 2069 6e73 7465 6164 206f 6620 7761 ly instead of wa │ │ │ -0004d680: 6974 696e 6720 666f 7220 7468 6520 6e65 iting for the ne │ │ │ -0004d690: 7874 2074 6963 6b3c 2f68 323e 3c68 343e xt tick

    │ │ │ -0004d6a0: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ -0004d6b0: 6d70 6c2e 6370 703a 3434 3737 3c2f 6834 mpl.cpp:4477

    ....c
    │ │ │ -0004d700: 6f6e 7469 6e75 653b 0a09 0909 7d0a 0a09  ontinue;....}...
    │ │ │ -0004d710: 0909 6966 2028 2170 2d26 6774 3b69 735f  ..if (!p->is_
    │ │ │ -0004d720: 7065 6572 5f69 6e74 6572 6573 7465 6428  peer_interested(
    │ │ │ -0004d730: 290a 0909 0909 7c7c 2070 2d26 6774 3b69  ).....|| p->i
    │ │ │ -0004d740: 735f 6469 7363 6f6e 6e65 6374 696e 6728  s_disconnecting(
    │ │ │ -0004d750: 290a 0909 0909 7c7c 2070 2d26 6774 3b69  ).....|| p->i
    │ │ │ -0004d760: 735f 636f 6e6e 6563 7469 6e67 2829 290a  s_connecting()).
    │ │ │ -0004d770: 0909 097b 0a09 0909 092f 2f20 7468 6973  ...{.....// this
    │ │ │ -0004d780: 2070 6565 7220 6973 206e 6f74 2075 6e63   peer is not unc
    │ │ │ -0004d790: 686f 6b61 626c 652e 2053 6f2c 2069 6620  hokable. So, if 
    │ │ │ -0004d7a0: 6974 2773 2075 6e63 686f 6b65 640a 0909  it's unchoked...
    │ │ │ -0004d7b0: 0909 2f2f 2061 6c72 6561 6479 2c20 6d61  ..// already, ma
    │ │ │ -0004d7c0: 6b65 2073 7572 6520 746f 2063 686f 6b65  ke sure to choke
    │ │ │ -0004d7d0: 2069 742e 0a09 0909 0969 6620 2870 2d26   it......if (p-&
    │ │ │ -0004d7e0: 6774 3b69 735f 6368 6f6b 6564 2829 290a  gt;is_choked()).
    │ │ │ -0004d7f0: 0909 0909 7b0a 0909 0909 0970 2d26 6774  ....{......p->
    │ │ │ -0004d800: 3b72 6573 6574 5f63 686f 6b65 5f63 6f75  ;reset_choke_cou
    │ │ │ -0004d810: 6e74 6572 7328 293b 0a09 0909 0909 636f  nters();......co
    │ │ │ -0004d820: 6e74 696e 7565 3b0a 0909 0909 7d0a 0909  ntinue;.....}...
    │ │ │ -0004d830: 0909 6966 2028 7069 2026 616d 703b 2661  ..if (pi &&a
    │ │ │ -0004d840: 6d70 3b20 7069 2d26 6774 3b6f 7074 696d  mp; pi->optim
    │ │ │ -0004d850: 6973 7469 6361 6c6c 795f 756e 6368 6f6b  istically_unchok
    │ │ │ -0004d860: 6564 290a 0909 0909 7b0a 0909 0909 096d  ed).....{......m
    │ │ │ -0004d870: 5f73 7461 7473 5f63 6f75 6e74 6572 732e  _stats_counters.
    │ │ │ -0004d880: 696e 635f 7374 6174 735f 636f 756e 7465  inc_stats_counte
    │ │ │ -0004d890: 7228 636f 756e 7465 7273 3a3a 6e75 6d5f  r(counters::num_
    │ │ │ -0004d8a0: 7065 6572 735f 7570 5f75 6e63 686f 6b65  peers_up_unchoke
    │ │ │ -0004d8b0: 645f 6f70 7469 6d69 7374 6963 2c20 2d31  d_optimistic, -1
    │ │ │ -0004d8c0: 293b 0a09 0909 0909 7069 2d26 6774 3b6f  );......pi->o
    │ │ │ -0004d8d0: 7074 696d 6973 7469 6361 6c6c 795f 756e  ptimistically_un
    │ │ │ -0004d8e0: 6368 6f6b 6564 203d 2066 616c 7365 3b0a  choked = false;.
    │ │ │ -0004d8f0: 0909 0909 092f 2f20 666f 7263 6520 6120  .....// force a 
    │ │ │ -0004d900: 6e65 7720 6f70 7469 6d69 7374 6963 2075  new optimistic u
    │ │ │ -0004d910: 6e63 686f 6b65 0a09 0909 0909 6d5f 6f70  nchoke......m_op
    │ │ │ -0004d920: 7469 6d69 7374 6963 5f75 6e63 686f 6b65  timistic_unchoke
    │ │ │ -0004d930: 5f74 696d 655f 7363 616c 6572 203d 2030  _time_scaler = 0
    │ │ │ -0004d940: 3b0a 3c64 6976 2073 7479 6c65 3d22 6261  ;.
    │ │ │ -0004d970: 0909 0909 7d0a 3c2f 6469 763e 0909 0909 ....}.
    .... │ │ │ -0004d980: 742d 2667 743b 6368 6f6b 655f 7065 6572 t->choke_peer │ │ │ -0004d990: 282a 7029 3b0a 0909 0909 702d 2667 743b (*p);.....p-> │ │ │ -0004d9a0: 7265 7365 745f 6368 6f6b 655f 636f 756e reset_choke_coun │ │ │ -0004d9b0: 7465 7273 2829 3b0a 0909 0909 636f 6e74 ters();.....cont │ │ │ -0004d9c0: 696e 7565 3b0a 0909 097d 0a0a 0909 0970 inue;....}.....p │ │ │ -0004d9d0: 6565 7273 2e70 7573 685f 6261 636b 2870 eers.push_back(p │ │ │ -0004d9e0: 2e67 6574 2829 293b 0a09 097d 0a0a 0909 .get());...}.... │ │ │ -0004d9f0: 696e 7420 636f 6e73 7420 616c 6c6f 7765 int const allowe │ │ │ -0004da00: 645f 7570 6c6f 6164 5f73 6c6f 7473 203d d_upload_slots = │ │ │ -0004da10: 2075 6e63 686f 6b65 5f73 6f72 7428 7065 unchoke_sort(pe │ │ │ -0004da20: 6572 730a 0909 092c 2075 6e63 686f 6b65 ers...., unchoke │ │ │ -0004da30: 5f69 6e74 6572 7661 6c2c 206d 5f73 6574 _interval, m_set │ │ │ -0004da40: 7469 6e67 7329 3b0a 0a09 0969 6620 286d tings);....if (m │ │ │ -0004da50: 5f73 6574 7469 6e67 732e 6765 745f 696e _settings.get_in │ │ │ -0004da60: 7428 7365 7474 696e 6773 5f70 6163 6b3a t(settings_pack: │ │ │ -0004da70: 3a63 686f 6b69 6e67 5f61 6c67 6f72 6974 :choking_algorit │ │ │ -0004da80: 686d 2920 3d3d 2073 6574 7469 6e67 735f hm) == settings_ │ │ │ -0004da90: 7061 636b 3a3a 6669 7865 645f 736c 6f74 pack::fixed_slot │ │ │ -0004daa0: 735f 6368 6f6b 6572 290a 0909 7b0a 0909 s_choker)...{... │ │ │ -0004dab0: 0969 6e74 2063 6f6e 7374 2075 706c 6f61 .int const uploa │ │ │ -0004dac0: 645f 736c 6f74 7320 3d20 6765 745f 696e d_slots = get_in │ │ │ -0004dad0: 745f 7365 7474 696e 6728 7365 7474 696e t_setting(settin │ │ │ -0004dae0: 6773 5f70 6163 6b3a 3a75 6e63 686f 6b65 gs_pack::unchoke │ │ │ -0004daf0: 5f73 6c6f 7473 5f6c 696d 6974 293b 0a09 _slots_limit);.. │ │ │ -0004db00: 0909 6d5f 7374 6174 735f 636f 756e 7465 ..m_stats_counte │ │ │ -0004db10: 7273 2e73 6574 5f76 616c 7565 2863 6f75 rs.set_value(cou │ │ │ -0004db20: 6e74 6572 733a 3a6e 756d 5f75 6e63 686f nters::num_uncho │ │ │ -0004db30: 6b65 5f73 6c6f 7473 2c20 7570 6c6f 6164 ke_slots, upload │ │ │ -0004db40: 5f73 6c6f 7473 293b 0a09 097d 0a09 0965 _slots);...}...e │ │ │ -0004db50: 6c73 650a 0909 7b0a 0909 096d 5f73 7461 lse...{....m_sta │ │ │ -0004db60: 7473 5f63 6f75 6e74 6572 732e 7365 745f ts_counters.set_ │ │ │ -0004db70: 7661 6c75 6528 636f 756e 7465 7273 3a3a value(counters:: │ │ │ -0004db80: 6e75 6d5f 756e 6368 6f6b 655f 736c 6f74 num_unchoke_slot │ │ │ -0004db90: 730a 0909 0909 2c20 616c 6c6f 7765 645f s....., allowed_ │ │ │ -0004dba0: 7570 6c6f 6164 5f73 6c6f 7473 293b 0a09 upload_slots);.. │ │ │ -0004dbb0: 097d 0a0a 2369 666e 6465 6620 544f 5252 .}..#ifndef TORR │ │ │ -0004dbc0: 454e 545f 4449 5341 424c 455f 4c4f 4747 ENT_DISABLE_LOGG │ │ │ -0004dbd0: 494e 470a 0909 6966 2028 7368 6f75 6c64 ING...if (should │ │ │ -0004dbe0: 5f6c 6f67 2829 290a 0909 7b0a 0909 0973 _log())...{....s │ │ │ -0004dbf0: 6573 7369 6f6e 5f6c 6f67 2822 5245 4341 ession_log("RECA │ │ │ -0004dc00: 4c43 554c 4154 4520 554e 4348 4f4b 4520 LCULATE UNCHOKE │ │ │ -0004dc10: 534c 4f54 533a 205b 2070 6565 7273 3a20 SLOTS: [ peers: │ │ │ -0004dc20: 2564 2022 0a09 0909 0922 656c 6967 6962 %d "....."eligib │ │ │ -0004dc30: 6c65 2d70 6565 7273 3a20 2564 220a 0909 le-peers: %d"... │ │ │ -0004dc40: 0909 2220 616c 6c6f 7765 642d 736c 6f74 .." allowed-slot │ │ │ -0004dc50: 733a 2025 6420 5d22 0a09 0909 092c 2069 s: %d ]"....., i │ │ │ -0004dc60: 6e74 286d 5f63 6f6e 6e65 6374 696f 6e73 nt(m_connections │ │ │ -0004dc70: 2e73 697a 6528 2929 0a09 0909 092c 2069 .size())....., i │ │ │ -0004dc80: 6e74 2870 6565 7273 2e73 697a 6528 2929 nt(peers.size()) │ │ │ -0004dc90: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -0004dcd0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ -0004dd00: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ -0004dd10: 6370 703a 3438 3034 3c2f 613e 3c2f 7464 cpp:4804it might be │ │ │ -0004dd30: 2061 206e 6963 6520 6665 6174 7572 6520 a nice feature │ │ │ -0004dd40: 6865 7265 2074 6f20 6c69 6d69 7420 7468 here to limit th │ │ │ -0004dd50: 6520 6e75 6d62 6572 206f 6620 746f 7272 e number of torr │ │ │ -0004dd60: 656e 7473 2074 6f20 7365 6e64 2069 6e20 ents to send in │ │ │ -0004dd70: 6120 7369 6e67 6c65 2075 7064 6174 652e a single update. │ │ │ -0004dd80: 2042 7920 6a75 7374 2070 6f73 7469 6e67 By just posting │ │ │ -0004dd90: 2074 6865 2066 6972 7374 206e 2074 6f72 the first n tor │ │ │ -0004dda0: 7265 6e74 732c 2074 6865 7920 776f 756c rents, they woul │ │ │ -0004ddb0: 6420 6e69 6365 6c79 2062 6520 726f 756e d nicely be roun │ │ │ -0004ddc0: 642d 726f 6269 6e65 6420 6265 6361 7573 d-robined becaus │ │ │ -0004ddd0: 6520 7468 6520 746f 7272 656e 7420 6c69 e the torrent li │ │ │ -0004dde0: 7374 7320 6172 6520 616c 7761 7973 2070 sts are always p │ │ │ -0004ddf0: 7573 6865 6420 6261 636b 2e20 5065 7268 ushed back. Perh │ │ │ -0004de00: 6170 7320 7468 6520 7374 6174 7573 5f75 aps the status_u │ │ │ -0004de10: 7064 6174 655f 616c 6572 7420 636f 756c pdate_alert coul │ │ │ -0004de20: 6420 6576 656e 2068 6176 6520 6120 6669 d even have a fi │ │ │ -0004de30: 7865 6420 6172 7261 7920 6f66 206e 2065 xed array of n e │ │ │ -0004de40: 6e74 7269 6573 2072 6174 6865 7220 7468 ntries rather th │ │ │ -0004de50: 616e 2061 2076 6563 746f 722c 2074 6f20 an a vector, to │ │ │ -0004de60: 6675 7274 6865 7220 696d 7072 6f76 6520 further improve │ │ │ -0004de70: 6d65 6d6f 7279 206c 6f63 616c 6974 792e memory locality. │ │ │ -0004de80: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    it │ │ │ -0004ded0: 206d 6967 6874 2062 6520 6120 6e69 6365 might be a nice │ │ │ -0004dee0: 2066 6561 7475 7265 2068 6572 6520 746f feature here to │ │ │ -0004def0: 206c 696d 6974 2074 6865 206e 756d 6265 limit the numbe │ │ │ -0004df00: 7220 6f66 2074 6f72 7265 6e74 730a 746f r of torrents.to │ │ │ -0004df10: 2073 656e 6420 696e 2061 2073 696e 676c send in a singl │ │ │ -0004df20: 6520 7570 6461 7465 2e20 4279 206a 7573 e update. By jus │ │ │ -0004df30: 7420 706f 7374 696e 6720 7468 6520 6669 t posting the fi │ │ │ -0004df40: 7273 7420 6e20 746f 7272 656e 7473 2c20 rst n torrents, │ │ │ -0004df50: 7468 6579 0a77 6f75 6c64 206e 6963 656c they.would nicel │ │ │ -0004df60: 7920 6265 2072 6f75 6e64 2d72 6f62 696e y be round-robin │ │ │ -0004df70: 6564 2062 6563 6175 7365 2074 6865 2074 ed because the t │ │ │ -0004df80: 6f72 7265 6e74 206c 6973 7473 2061 7265 orrent lists are │ │ │ -0004df90: 2061 6c77 6179 730a 7075 7368 6564 2062 always.pushed b │ │ │ -0004dfa0: 6163 6b2e 2050 6572 6861 7073 2074 6865 ack. Perhaps the │ │ │ -0004dfb0: 2073 7461 7475 735f 7570 6461 7465 5f61 status_update_a │ │ │ -0004dfc0: 6c65 7274 2063 6f75 6c64 2065 7665 6e20 lert could even │ │ │ -0004dfd0: 6861 7665 2061 2066 6978 6564 0a61 7272 have a fixed.arr │ │ │ -0004dfe0: 6179 206f 6620 6e20 656e 7472 6965 7320 ay of n entries │ │ │ -0004dff0: 7261 7468 6572 2074 6861 6e20 6120 7665 rather than a ve │ │ │ -0004e000: 6374 6f72 2c20 746f 2066 7572 7468 6572 ctor, to further │ │ │ -0004e010: 2069 6d70 726f 7665 206d 656d 6f72 790a improve memory. │ │ │ -0004e020: 6c6f 6361 6c69 7479 2e3c 2f68 323e 3c68 locality.

    ../src/session │ │ │ -0004e040: 5f69 6d70 6c2e 6370 703a 3438 3034 3c2f _impl.cpp:4804
    ...
    │ │ │ -0004e090: 742d 2667 743b 7374 6174 7573 2826 616d  t->status(&am
    │ │ │ -0004e0a0: 703b 7374 2c20 666c 6167 7329 3b0a 0909  p;st, flags);...
    │ │ │ -0004e0b0: 7d0a 097d 0a0a 0976 6f69 6420 7365 7373  }..}...void sess
    │ │ │ -0004e0c0: 696f 6e5f 696d 706c 3a3a 706f 7374 5f74  ion_impl::post_t
    │ │ │ -0004e0d0: 6f72 7265 6e74 5f75 7064 6174 6573 2873  orrent_updates(s
    │ │ │ -0004e0e0: 7461 7475 735f 666c 6167 735f 7420 636f  tatus_flags_t co
    │ │ │ -0004e0f0: 6e73 7420 666c 6167 7329 0a09 7b0a 0909  nst flags)..{...
    │ │ │ -0004e100: 494e 5641 5249 414e 545f 4348 4543 4b3b  INVARIANT_CHECK;
    │ │ │ -0004e110: 0a0a 0909 544f 5252 454e 545f 4153 5345  ....TORRENT_ASSE
    │ │ │ -0004e120: 5254 2869 735f 7369 6e67 6c65 5f74 6872  RT(is_single_thr
    │ │ │ -0004e130: 6561 6428 2929 3b0a 0a09 0973 7464 3a3a  ead());....std::
    │ │ │ -0004e140: 7665 6374 6f72 266c 743b 746f 7272 656e  vector<torren
    │ │ │ -0004e150: 742a 2667 743b 2661 6d70 3b20 7374 6174  t*>& stat
    │ │ │ -0004e160: 655f 7570 6461 7465 730a 0909 093d 206d  e_updates....= m
    │ │ │ -0004e170: 5f74 6f72 7265 6e74 5f6c 6973 7473 5b61  _torrent_lists[a
    │ │ │ -0004e180: 7578 3a3a 7365 7373 696f 6e5f 696d 706c  ux::session_impl
    │ │ │ -0004e190: 3a3a 746f 7272 656e 745f 7374 6174 655f  ::torrent_state_
    │ │ │ -0004e1a0: 7570 6461 7465 735d 3b0a 0a23 6966 2054  updates];..#if T
    │ │ │ -0004e1b0: 4f52 5245 4e54 5f55 5345 5f41 5353 4552  ORRENT_USE_ASSER
    │ │ │ -0004e1c0: 5453 0a09 096d 5f70 6f73 7469 6e67 5f74  TS...m_posting_t
    │ │ │ -0004e1d0: 6f72 7265 6e74 5f75 7064 6174 6573 203d  orrent_updates =
    │ │ │ -0004e1e0: 2074 7275 653b 0a23 656e 6469 660a 0a09   true;.#endif...
    │ │ │ -0004e1f0: 0973 7464 3a3a 7665 6374 6f72 266c 743b  .std::vector<
    │ │ │ -0004e200: 746f 7272 656e 745f 7374 6174 7573 2667  torrent_status&g
    │ │ │ -0004e210: 743b 2073 7461 7475 733b 0a09 0973 7461  t; status;...sta
    │ │ │ -0004e220: 7475 732e 7265 7365 7276 6528 7374 6174  tus.reserve(stat
    │ │ │ -0004e230: 655f 7570 6461 7465 732e 7369 7a65 2829  e_updates.size()
    │ │ │ -0004e240: 293b 0a0a 3c64 6976 2073 7479 6c65 3d22  );..
    ..for (auto&am │ │ │ -0004e280: 703b 2074 203a 2073 7461 7465 5f75 7064 p; t : state_upd │ │ │ -0004e290: 6174 6573 290a 3c2f 6469 763e 0909 7b0a ates).
    ..{. │ │ │ -0004e2a0: 0909 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -0004e2b0: 5428 742d 2667 743b 6d5f 6c69 6e6b 735b T(t->m_links[ │ │ │ -0004e2c0: 6175 783a 3a73 6573 7369 6f6e 5f69 6d70 aux::session_imp │ │ │ -0004e2d0: 6c3a 3a74 6f72 7265 6e74 5f73 7461 7465 l::torrent_state │ │ │ -0004e2e0: 5f75 7064 6174 6573 5d2e 696e 5f6c 6973 _updates].in_lis │ │ │ -0004e2f0: 7428 2929 3b0a 0909 0973 7461 7475 732e t());....status. │ │ │ -0004e300: 656d 706c 6163 655f 6261 636b 2829 3b0a emplace_back();. │ │ │ -0004e310: 0909 092f 2f20 7175 6572 7969 6e67 2061 ...// querying a │ │ │ -0004e320: 6363 7572 6174 6520 646f 776e 6c6f 6164 ccurate download │ │ │ -0004e330: 2063 6f75 6e74 6572 7320 6d61 7920 7265 counters may re │ │ │ -0004e340: 7175 6972 650a 0909 092f 2f20 7468 6520 quire....// the │ │ │ -0004e350: 746f 7272 656e 7420 746f 2062 6520 6c6f torrent to be lo │ │ │ -0004e360: 6164 6564 2e20 4c6f 6164 696e 6720 6120 aded. Loading a │ │ │ -0004e370: 746f 7272 656e 742c 2061 6e64 2065 7669 torrent, and evi │ │ │ -0004e380: 6374 696e 6720 616e 6f74 6865 720a 0909 cting another... │ │ │ -0004e390: 092f 2f20 6f6e 6520 7769 6c6c 206c 6561 .// one will lea │ │ │ -0004e3a0: 6420 746f 2063 616c 6c69 6e67 2073 7461 d to calling sta │ │ │ -0004e3b0: 7465 5f75 7064 6174 6564 2829 2c20 7768 te_updated(), wh │ │ │ -0004e3c0: 6963 6820 7363 7265 7773 2077 6974 680a ich screws with. │ │ │ -0004e3d0: 0909 092f 2f20 7468 6973 206c 6973 7420 ...// this list │ │ │ -0004e3e0: 7768 696c 6520 7765 2772 6520 776f 726b while we're work │ │ │ -0004e3f0: 696e 6720 6f6e 2069 742c 2061 6e64 2062 ing on it, and b │ │ │ -0004e400: 7265 616b 2074 6869 6e67 730a 0909 0974 reak things....t │ │ │ -0004e410: 2d26 6774 3b73 7461 7475 7328 2661 6d70 ->status(& │ │ │ -0004e420: 3b73 7461 7475 732e 6261 636b 2829 2c20 ;status.back(), │ │ │ -0004e430: 666c 6167 7329 3b0a 0909 0974 2d26 6774 flags);....t-> │ │ │ -0004e440: 3b63 6c65 6172 5f69 6e5f 7374 6174 655f ;clear_in_state_ │ │ │ -0004e450: 7570 6461 7465 2829 3b0a 0909 7d0a 0909 update();...}... │ │ │ -0004e460: 7374 6174 655f 7570 6461 7465 732e 636c state_updates.cl │ │ │ -0004e470: 6561 7228 293b 0a0a 2369 6620 544f 5252 ear();..#if TORR │ │ │ -0004e480: 454e 545f 5553 455f 4153 5345 5254 530a ENT_USE_ASSERTS. │ │ │ -0004e490: 0909 6d5f 706f 7374 696e 675f 746f 7272 ..m_posting_torr │ │ │ -0004e4a0: 656e 745f 7570 6461 7465 7320 3d20 6661 ent_updates = fa │ │ │ -0004e4b0: 6c73 653b 0a23 656e 6469 660a 0a09 096d lse;.#endif....m │ │ │ -0004e4c0: 5f61 6c65 7274 732e 656d 706c 6163 655f _alerts.emplace_ │ │ │ -0004e4d0: 616c 6572 7426 6c74 3b73 7461 7465 5f75 alert<state_u │ │ │ -0004e4e0: 7064 6174 655f 616c 6572 7426 6774 3b28 pdate_alert>( │ │ │ -0004e4f0: 7374 643a 3a6d 6f76 6528 7374 6174 7573 std::move(status │ │ │ -0004e500: 2929 3b0a 097d 0a0a 0976 6f69 6420 7365 ));..}...void se │ │ │ -0004e510: 7373 696f 6e5f 696d 706c 3a3a 706f 7374 ssion_impl::post │ │ │ -0004e520: 5f73 6573 7369 6f6e 5f73 7461 7473 2829 _session_stats() │ │ │ -0004e530: 0a09 7b0a 0909 6966 2028 216d 5f70 6f73 ..{...if (!m_pos │ │ │ -0004e540: 7465 645f 7374 6174 735f 6865 6164 6572 ted_stats_header │ │ │ -0004e550: 290a 0909 7b0a 0909 096d 5f70 6f73 7465 )...{....m_poste │ │ │ -0004e560: 645f 7374 6174 735f 6865 6164 6572 203d d_stats_header = │ │ │ -0004e570: 2074 7275 653b 0a09 0909 6d5f 616c 6572 true;....m_aler │ │ │ -0004e580: 7473 2e65 6d70 6c61 6365 5f61 6c65 7274 ts.emplace_alert │ │ │ -0004e590: 266c 743b 7365 7373 696f 6e5f 7374 6174 <session_stat │ │ │ -0004e5a0: 735f 6865 6164 6572 5f61 6c65 7274 2667 s_header_alert&g │ │ │ -0004e5b0: 743b 2829 3b0a 0909 7d0a 0909 6d5f 6469 t;();...}...m_di │ │ │ -0004e5c0: 736b 5f74 6872 6561 642d 2667 743b 7570 sk_thread->up │ │ │ -0004e5d0: 6461 7465 5f73 7461 7473 5f63 6f75 6e74 date_stats_count │ │ │ -0004e5e0: 6572 7328 6d5f 7374 6174 735f 636f 756e ers(m_stats_coun │ │ │ -0004e5f0: 7465 7273 293b 0a0a 2369 666e 6465 6620 ters);..#ifndef │ │ │ -0004e600: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -0004e610: 4448 540a 0909 6966 2028 6d5f 6468 7429 DHT...if (m_dht) │ │ │ -0004e620: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -0004e660: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ -0004e690: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ -0004e6a0: 6370 703a 3531 3836 3c2f 613e 3c2f 7464 cpp:5186factor out │ │ │ -0004e6c0: 7468 6973 206c 6f67 6963 2069 6e74 6f20 this logic into │ │ │ -0004e6d0: 6120 7365 7061 7261 7465 2066 756e 6374 a separate funct │ │ │ -0004e6e0: 696f 6e20 666f 7220 756e 6974 2074 6573 ion for unit tes │ │ │ -0004e6f0: 7469 6e67 3c2f 7464 3e3c 2f74 723e 3c74 tingfactor out thi │ │ │ -0004e750: 7320 6c6f 6769 6320 696e 746f 2061 2073 s logic into a s │ │ │ -0004e760: 6570 6172 6174 6520 6675 6e63 7469 6f6e eparate function │ │ │ -0004e770: 2066 6f72 2075 6e69 740a 7465 7374 696e for unit.testin │ │ │ -0004e780: 673c 2f68 323e 3c68 343e 2e2e 2f73 7263 g

    ../src │ │ │ -0004e790: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ -0004e7a0: 703a 3531 3836 3c2f 6834 3e3c 7072 6520 p:5186

    ..if (m_set
    │ │ │ -0004e7f0: 7469 6e67 732e 6765 745f 696e 7428 7365  tings.get_int(se
    │ │ │ -0004e800: 7474 696e 6773 5f70 6163 6b3a 3a6f 7574  ttings_pack::out
    │ │ │ -0004e810: 676f 696e 675f 706f 7274 2920 2667 743b  going_port) >
    │ │ │ -0004e820: 2030 290a 0909 7b0a 2369 6664 6566 2054   0)...{.#ifdef T
    │ │ │ -0004e830: 4f52 5245 4e54 5f57 494e 444f 5753 0a09  ORRENT_WINDOWS..
    │ │ │ -0004e840: 0909 732e 7365 745f 6f70 7469 6f6e 2865  ..s.set_option(e
    │ │ │ -0004e850: 7863 6c75 7369 7665 5f61 6464 7265 7373  xclusive_address
    │ │ │ -0004e860: 5f75 7365 2874 7275 6529 2c20 6563 293b  _use(true), ec);
    │ │ │ -0004e870: 0a23 656c 7365 0a09 0909 732e 7365 745f  .#else....s.set_
    │ │ │ -0004e880: 6f70 7469 6f6e 2874 6370 3a3a 6163 6365  option(tcp::acce
    │ │ │ -0004e890: 7074 6f72 3a3a 7265 7573 655f 6164 6472  ptor::reuse_addr
    │ │ │ -0004e8a0: 6573 7328 7472 7565 292c 2065 6329 3b0a  ess(true), ec);.
    │ │ │ -0004e8b0: 2365 6e64 6966 0a09 0909 2f2f 2069 676e  #endif....// ign
    │ │ │ -0004e8c0: 6f72 6520 6572 726f 7273 2062 6563 6175  ore errors becau
    │ │ │ -0004e8d0: 7365 2074 6865 2075 6e64 6572 6c79 696e  se the underlyin
    │ │ │ -0004e8e0: 6720 736f 636b 6574 206d 6179 206e 6f74  g socket may not
    │ │ │ -0004e8f0: 0a09 0909 2f2f 2062 6520 6f70 656e 6564  ....// be opened
    │ │ │ -0004e900: 2079 6574 2e20 5468 6973 2068 6170 7065   yet. This happe
    │ │ │ -0004e910: 6e73 2077 6865 6e20 7765 2772 6520 726f  ns when we're ro
    │ │ │ -0004e920: 7574 696e 6720 7468 726f 7567 680a 0909  uting through...
    │ │ │ -0004e930: 092f 2f20 6120 7072 6f78 792e 2049 6e20  .// a proxy. In 
    │ │ │ -0004e940: 7468 6174 2063 6173 652c 2077 6520 646f  that case, we do
    │ │ │ -0004e950: 6e27 7420 7965 7420 6b6e 6f77 2074 6865  n't yet know the
    │ │ │ -0004e960: 2061 6464 7265 7373 206f 660a 0909 092f   address of..../
    │ │ │ -0004e970: 2f20 7468 6520 7072 6f78 7920 7365 7276  / the proxy serv
    │ │ │ -0004e980: 6572 2c20 616e 6420 6d6f 7265 2069 6d70  er, and more imp
    │ │ │ -0004e990: 6f72 7461 6e74 6c79 2c20 7765 2064 6f6e  ortantly, we don
    │ │ │ -0004e9a0: 2774 206b 6e6f 770a 0909 092f 2f20 7468  't know....// th
    │ │ │ -0004e9b0: 6520 6164 6472 6573 7320 6661 6d69 6c79  e address family
    │ │ │ -0004e9c0: 206f 6620 6974 7320 6164 6472 6573 732e   of its address.
    │ │ │ -0004e9d0: 2054 6869 7320 6d65 616e 7320 7765 2063   This means we c
    │ │ │ -0004e9e0: 616e 2774 0a09 0909 2f2f 206f 7065 6e20  an't....// open 
    │ │ │ -0004e9f0: 7468 6520 736f 636b 6574 2079 6574 2e20  the socket yet. 
    │ │ │ -0004ea00: 5468 6520 736f 636b 7320 6162 7374 7261  The socks abstra
    │ │ │ -0004ea10: 6374 696f 6e20 6c61 7965 7220 6465 6665  ction layer defe
    │ │ │ -0004ea20: 7273 0a09 0909 2f2f 206f 7065 6e69 6e67  rs....// opening
    │ │ │ -0004ea30: 2069 742e 0a09 0909 6563 2e63 6c65 6172   it.....ec.clear
    │ │ │ -0004ea40: 2829 3b0a 0909 0962 696e 645f 6570 2e70  ();....bind_ep.p
    │ │ │ -0004ea50: 6f72 7428 7374 643a 3a75 696e 7431 365f  ort(std::uint16_
    │ │ │ -0004ea60: 7428 6e65 7874 5f70 6f72 7428 2929 293b  t(next_port()));
    │ │ │ -0004ea70: 0a09 097d 0a0a 0909 6966 2028 6973 5f75  ...}....if (is_u
    │ │ │ -0004ea80: 7470 2873 2929 0a09 097b 0a3c 6469 7620  tp(s))...{.
    .
    │ │ │ -0004eac0: 0909 0975 7470 5f73 6f63 6b65 745f 696d ...utp_socket_im │ │ │ -0004ead0: 706c 2a20 696d 706c 203d 206e 756c 6c70 pl* impl = nullp │ │ │ -0004eae0: 7472 3b0a 0909 0974 7261 6e73 706f 7274 tr;....transport │ │ │ -0004eaf0: 2073 736c 203d 2074 7261 6e73 706f 7274 ssl = transport │ │ │ -0004eb00: 3a3a 706c 6169 6e74 6578 743b 0a23 6966 ::plaintext;.#if │ │ │ -0004eb10: 2054 4f52 5245 4e54 5f55 5345 5f53 534c TORRENT_USE_SSL │ │ │ -0004eb20: 0a09 0909 6966 2028 626f 6f73 743a 3a67 ....if (boost::g │ │ │ -0004eb30: 6574 266c 743b 7373 6c5f 7374 7265 616d et<ssl_stream │ │ │ -0004eb40: 266c 743b 7574 705f 7374 7265 616d 2667 <utp_stream&g │ │ │ -0004eb50: 743b 2667 743b 2826 616d 703b 7329 2021 t;>(&s) ! │ │ │ -0004eb60: 3d20 6e75 6c6c 7074 7229 0a09 0909 7b0a = nullptr)....{. │ │ │ -0004eb70: 0909 0909 696d 706c 203d 2062 6f6f 7374 ....impl = boost │ │ │ -0004eb80: 3a3a 6765 7426 6c74 3b73 736c 5f73 7472 ::get<ssl_str │ │ │ -0004eb90: 6561 6d26 6c74 3b75 7470 5f73 7472 6561 eam<utp_strea │ │ │ -0004eba0: 6d26 6774 3b26 6774 3b28 7329 2e6e 6578 m>>(s).nex │ │ │ -0004ebb0: 745f 6c61 7965 7228 292e 6765 745f 696d t_layer().get_im │ │ │ -0004ebc0: 706c 2829 3b0a 0909 0909 7373 6c20 3d20 pl();.....ssl = │ │ │ -0004ebd0: 7472 616e 7370 6f72 743a 3a73 736c 3b0a transport::ssl;. │ │ │ -0004ebe0: 0909 097d 0a09 0909 656c 7365 0a23 656e ...}....else.#en │ │ │ -0004ebf0: 6469 660a 0909 0909 696d 706c 203d 2062 dif.....impl = b │ │ │ -0004ec00: 6f6f 7374 3a3a 6765 7426 6c74 3b75 7470 oost::get<utp │ │ │ -0004ec10: 5f73 7472 6561 6d26 6774 3b28 7329 2e67 _stream>(s).g │ │ │ -0004ec20: 6574 5f69 6d70 6c28 293b 0a0a 0909 0973 et_impl();.....s │ │ │ -0004ec30: 7464 3a3a 7665 6374 6f72 266c 743b 7374 td::vector<st │ │ │ -0004ec40: 643a 3a73 6861 7265 645f 7074 7226 6c74 d::shared_ptr< │ │ │ -0004ec50: 3b6c 6973 7465 6e5f 736f 636b 6574 5f74 ;listen_socket_t │ │ │ -0004ec60: 2667 743b 2667 743b 2077 6974 685f 6761 >> with_ga │ │ │ -0004ec70: 7465 7761 7973 3b0a 0909 0973 7464 3a3a teways;....std:: │ │ │ -0004ec80: 7368 6172 6564 5f70 7472 266c 743b 6c69 shared_ptr<li │ │ │ -0004ec90: 7374 656e 5f73 6f63 6b65 745f 7426 6774 sten_socket_t> │ │ │ -0004eca0: 3b20 6d61 7463 683b 0a09 0909 666f 7220 ; match;....for │ │ │ -0004ecb0: 2861 7574 6f26 616d 703b 206c 7320 3a20 (auto& ls : │ │ │ -0004ecc0: 6d5f 6c69 7374 656e 5f73 6f63 6b65 7473 m_listen_sockets │ │ │ -0004ecd0: 290a 0909 097b 0a09 0909 092f 2f20 7468 )....{.....// th │ │ │ -0004ece0: 6973 2069 7320 616c 6d6f 7374 2c20 6275 is is almost, bu │ │ │ -0004ecf0: 7420 6e6f 7420 7175 6974 652c 206c 696b t not quite, lik │ │ │ -0004ed00: 6520 6361 6e5f 726f 7574 6528 290a 0909 e can_route()... │ │ │ -0004ed10: 0909 6966 2028 2128 6c73 2d26 6774 3b66 ..if (!(ls->f │ │ │ -0004ed20: 6c61 6773 2026 616d 703b 206c 6973 7465 lags & liste │ │ │ -0004ed30: 6e5f 736f 636b 6574 5f74 3a3a 7072 6f78 n_socket_t::prox │ │ │ -0004ed40: 7929 0a09 0909 0909 2661 6d70 3b26 616d y)......&&am │ │ │ -0004ed50: 703b 2069 735f 7634 286c 732d 2667 743b p; is_v4(ls-> │ │ │ -0004ed60: 6c6f 6361 6c5f 656e 6470 6f69 6e74 2920 local_endpoint) │ │ │ -0004ed70: 213d 2072 656d 6f74 655f 6164 6472 6573 != remote_addres │ │ │ -0004ed80: 732e 6973 5f76 3428 2929 0a09 0909 0909 s.is_v4())...... │ │ │ -0004ed90: 636f 6e74 696e 7565 3b0a 0909 0909 6966 continue;.....if │ │ │ -0004eda0: 2028 6c73 2d26 6774 3b73 736c 2021 3d20 (ls->ssl != │ │ │ -0004edb0: 7373 6c29 2063 6f6e 7469 6e75 653b 0a09 ssl) continue;.. │ │ │ -0004edc0: 0909 0969 6620 2821 286c 732d 2667 743b ...if (!(ls-> │ │ │ -0004edd0: 666c 6167 7320 2661 6d70 3b20 6c69 7374 flags & list │ │ │ -0004ede0: 656e 5f73 6f63 6b65 745f 743a 3a6c 6f63 en_socket_t::loc │ │ │ -0004edf0: 616c 5f6e 6574 776f 726b 2929 0a09 0909 al_network)).... │ │ │ -0004ee00: 0909 7769 7468 5f67 6174 6577 6179 732e ..with_gateways. │ │ │ -0004ee10: 7075 7368 5f62 6163 6b28 6c73 293b 0a0a push_back(ls);.. │ │ │ -0004ee20: 0909 0909 6966 2028 6c73 2d26 6774 3b66 ....if (ls->f │ │ │ -0004ee30: 6c61 6773 2026 616d 703b 206c 6973 7465 lags & liste │ │ │ -0004ee40: 6e5f 736f 636b 6574 5f74 3a3a 7072 6f78 n_socket_t::prox │ │ │ -0004ee50: 790a 0909 0909 097c 7c20 6d61 7463 685f y......|| match_ │ │ │ -0004ee60: 6164 6472 5f6d 6173 6b28 6c73 2d26 6774 addr_mask(ls-> │ │ │ -0004ee70: 3b6c 6f63 616c 5f65 6e64 706f 696e 742e ;local_endpoint. │ │ │ -0004ee80: 6164 6472 6573 7328 292c 2072 656d 6f74 address(), remot │ │ │ -0004ee90: 655f 6164 6472 6573 732c 206c 732d 2667 e_address, ls-&g │ │ │ -0004eea0: 743b 6e65 746d 6173 6b29 290a 0909 0909 t;netmask))..... │ │ │ -0004eeb0: 7b0a 0909 0909 092f 2f20 6973 2074 6869 {......// is thi │ │ │ -0004eec0: 7320 6265 7474 6572 2074 6861 6e20 7468 s better than th │ │ │ -0004eed0: 6520 7072 6576 696f 7573 206d 6174 6368 e previous match │ │ │ -0004eee0: 3f0a 0909 0909 096d 6174 6368 203d 206c ?......match = l │ │ │ -0004eef0: 733b 0a09 0909 097d 0a3c 2f70 7265 3e3c s;.....}.
    < │ │ │ -0004ef00: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -0004ef30: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -0004ef40: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/sessi │ │ │ -0004ef70: 6f6e 5f69 6d70 6c2e 6370 703a 3539 3137 on_impl.cpp:5917 │ │ │ -0004ef80: 3c2f 613e 3c2f 7464 3e3c 7464 3e72 6566 ref │ │ │ -0004ef90: 6163 746f 722c 206d 6f76 6520 7468 6520 actor, move the │ │ │ -0004efa0: 7374 6f72 6167 6520 746f 2064 6874 5f74 storage to dht_t │ │ │ -0004efb0: 7261 636b 6572 3c2f 7464 3e3c 2f74 723e racker │ │ │ -0004efc0: 3c74 7220 6964 3d22 3138 3722 2073 7479 │ │ │ -0004eff0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0004f000: 3c68 323e 7265 6661 6374 6f72 2c20 6d6f

    refactor, mo │ │ │ -0004f010: 7665 2074 6865 2073 746f 7261 6765 2074 ve the storage t │ │ │ -0004f020: 6f20 6468 745f 7472 6163 6b65 723c 2f68 o dht_tracker

    ../src/ses │ │ │ -0004f040: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3539 sion_impl.cpp:59 │ │ │ -0004f050: 3137 3c2f 6834 3e3c 7072 6520 7374 796c 17

    #ifndef TORRENT
    │ │ │ -0004f0a0: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47  _DISABLE_LOGGING
    │ │ │ -0004f0b0: 0a09 0909 7365 7373 696f 6e5f 6c6f 6728  ....session_log(
    │ │ │ -0004f0c0: 226e 6f74 2073 7461 7274 696e 6720 4448  "not starting DH
    │ │ │ -0004f0d0: 542c 206f 7574 7374 616e 6469 6e67 2072  T, outstanding r
    │ │ │ -0004f0e0: 6f75 7465 7220 6c6f 6f6b 7570 733a 2025  outer lookups: %
    │ │ │ -0004f0f0: 6422 0a09 0909 092c 206d 5f6f 7574 7374  d"....., m_outst
    │ │ │ -0004f100: 616e 6469 6e67 5f72 6f75 7465 725f 6c6f  anding_router_lo
    │ │ │ -0004f110: 6f6b 7570 7329 3b0a 2365 6e64 6966 0a09  okups);.#endif..
    │ │ │ -0004f120: 0909 7265 7475 726e 3b0a 0909 7d0a 0a09  ..return;...}...
    │ │ │ -0004f130: 0969 6620 286d 5f61 626f 7274 290a 0909  .if (m_abort)...
    │ │ │ -0004f140: 7b0a 2369 666e 6465 6620 544f 5252 454e  {.#ifndef TORREN
    │ │ │ -0004f150: 545f 4449 5341 424c 455f 4c4f 4747 494e  T_DISABLE_LOGGIN
    │ │ │ -0004f160: 470a 0909 0973 6573 7369 6f6e 5f6c 6f67  G....session_log
    │ │ │ -0004f170: 2822 6e6f 7420 7374 6172 7469 6e67 2044  ("not starting D
    │ │ │ -0004f180: 4854 2c20 6162 6f72 7469 6e67 2229 3b0a  HT, aborting");.
    │ │ │ -0004f190: 2365 6e64 6966 0a09 0909 7265 7475 726e  #endif....return
    │ │ │ -0004f1a0: 3b0a 0909 7d0a 0a23 6966 6e64 6566 2054  ;...}..#ifndef T
    │ │ │ -0004f1b0: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c  ORRENT_DISABLE_L
    │ │ │ -0004f1c0: 4f47 4749 4e47 0a09 0973 6573 7369 6f6e  OGGING...session
    │ │ │ -0004f1d0: 5f6c 6f67 2822 7374 6172 7469 6e67 2044  _log("starting D
    │ │ │ -0004f1e0: 4854 2c20 7275 6e6e 696e 673a 2025 732c  HT, running: %s,
    │ │ │ -0004f1f0: 2072 6f75 7465 7220 6c6f 6f6b 7570 733a   router lookups:
    │ │ │ -0004f200: 2025 6422 0a09 0909 2c20 6d5f 6468 7420   %d"...., m_dht 
    │ │ │ -0004f210: 3f20 2274 7275 6522 203a 2022 6661 6c73  ? "true" : "fals
    │ │ │ -0004f220: 6522 2c20 6d5f 6f75 7473 7461 6e64 696e  e", m_outstandin
    │ │ │ -0004f230: 675f 726f 7574 6572 5f6c 6f6f 6b75 7073  g_router_lookups
    │ │ │ -0004f240: 293b 0a23 656e 6469 660a 0a3c 6469 7620  );.#endif..
    ..m_dht │ │ │ -0004f280: 5f73 746f 7261 6765 203d 206d 5f64 6874 _storage = m_dht │ │ │ -0004f290: 5f73 746f 7261 6765 5f63 6f6e 7374 7275 _storage_constru │ │ │ -0004f2a0: 6374 6f72 286d 5f73 6574 7469 6e67 7329 ctor(m_settings) │ │ │ -0004f2b0: 3b0a 3c2f 6469 763e 0909 6d5f 6468 7420 ;.
    ..m_dht │ │ │ -0004f2c0: 3d20 7374 643a 3a6d 616b 655f 7368 6172 = std::make_shar │ │ │ -0004f2d0: 6564 266c 743b 6468 743a 3a64 6874 5f74 ed<dht::dht_t │ │ │ -0004f2e0: 7261 636b 6572 2667 743b 280a 0909 0973 racker>(....s │ │ │ -0004f2f0: 7461 7469 635f 6361 7374 266c 743b 6468 tatic_cast<dh │ │ │ -0004f300: 743a 3a64 6874 5f6f 6273 6572 7665 722a t::dht_observer* │ │ │ -0004f310: 2667 743b 2874 6869 7329 0a09 0909 2c20 >(this)...., │ │ │ -0004f320: 6d5f 696f 5f63 6f6e 7465 7874 0a09 0909 m_io_context.... │ │ │ -0004f330: 2c20 5b74 6869 735d 2861 7578 3a3a 6c69 , [this](aux::li │ │ │ -0004f340: 7374 656e 5f73 6f63 6b65 745f 6861 6e64 sten_socket_hand │ │ │ -0004f350: 6c65 2063 6f6e 7374 2661 6d70 3b20 736f le const& so │ │ │ -0004f360: 636b 0a09 0909 092c 2075 6470 3a3a 656e ck....., udp::en │ │ │ -0004f370: 6470 6f69 6e74 2063 6f6e 7374 2661 6d70 dpoint const& │ │ │ -0004f380: 3b20 6570 0a09 0909 092c 2073 7061 6e26 ; ep....., span& │ │ │ -0004f390: 6c74 3b63 6861 7220 636f 6e73 7426 6774 lt;char const> │ │ │ -0004f3a0: 3b20 700a 0909 0909 2c20 6572 726f 725f ; p....., error_ │ │ │ -0004f3b0: 636f 6465 2661 6d70 3b20 6563 0a09 0909 code& ec.... │ │ │ -0004f3c0: 092c 2075 6470 5f73 656e 645f 666c 6167 ., udp_send_flag │ │ │ -0004f3d0: 735f 7420 636f 6e73 7420 666c 6167 7329 s_t const flags) │ │ │ -0004f3e0: 0a09 0909 097b 2073 656e 645f 7564 705f .....{ send_udp_ │ │ │ -0004f3f0: 7061 636b 6574 5f6c 6973 7465 6e28 736f packet_listen(so │ │ │ -0004f400: 636b 2c20 6570 2c20 702c 2065 632c 2066 ck, ep, p, ec, f │ │ │ -0004f410: 6c61 6773 293b 207d 0a09 0909 2c20 6d5f lags); }...., m_ │ │ │ -0004f420: 7365 7474 696e 6773 0a09 0909 2c20 6d5f settings...., m_ │ │ │ -0004f430: 7374 6174 735f 636f 756e 7465 7273 0a09 stats_counters.. │ │ │ -0004f440: 0909 2c20 2a6d 5f64 6874 5f73 746f 7261 .., *m_dht_stora │ │ │ -0004f450: 6765 0a09 0909 2c20 7374 643a 3a6d 6f76 ge...., std::mov │ │ │ -0004f460: 6528 6d5f 6468 745f 7374 6174 6529 293b e(m_dht_state)); │ │ │ -0004f470: 0a0a 0909 666f 7220 2861 7574 6f26 616d ....for (auto&am │ │ │ -0004f480: 703b 2073 203a 206d 5f6c 6973 7465 6e5f p; s : m_listen_ │ │ │ -0004f490: 736f 636b 6574 7329 0a09 097b 0a09 0909 sockets)...{.... │ │ │ -0004f4a0: 6966 2028 732d 2667 743b 7373 6c20 213d if (s->ssl != │ │ │ -0004f4b0: 2074 7261 6e73 706f 7274 3a3a 7373 6c0a transport::ssl. │ │ │ -0004f4c0: 0909 0909 2661 6d70 3b26 616d 703b 2021 ....&& ! │ │ │ -0004f4d0: 2873 2d26 6774 3b66 6c61 6773 2026 616d (s->flags &am │ │ │ -0004f4e0: 703b 206c 6973 7465 6e5f 736f 636b 6574 p; listen_socket │ │ │ -0004f4f0: 5f74 3a3a 6c6f 6361 6c5f 6e65 7477 6f72 _t::local_networ │ │ │ -0004f500: 6b29 290a 0909 097b 0a09 0909 096d 5f64 k))....{.....m_d │ │ │ -0004f510: 6874 2d26 6774 3b6e 6577 5f73 6f63 6b65 ht->new_socke │ │ │ -0004f520: 7428 7329 3b0a 0909 097d 0a09 097d 0a0a t(s);....}...}.. │ │ │ -0004f530: 0909 666f 7220 2861 7574 6f20 636f 6e73 ..for (auto cons │ │ │ -0004f540: 7426 616d 703b 206e 203a 206d 5f64 6874 t& n : m_dht │ │ │ -0004f550: 5f72 6f75 7465 725f 6e6f 6465 7329 0a09 _router_nodes).. │ │ │ -0004f560: 097b 0a09 0909 6d5f 6468 742d 2667 743b .{....m_dht-> │ │ │ -0004f570: 6164 645f 726f 7574 6572 5f6e 6f64 6528 add_router_node( │ │ │ -0004f580: 6e29 3b0a 0909 7d0a 0a09 0966 6f72 2028 n);...}....for ( │ │ │ -0004f590: 6175 746f 2063 6f6e 7374 2661 6d70 3b20 auto const& │ │ │ -0004f5a0: 6e20 3a20 6d5f 6468 745f 6e6f 6465 7329 n : m_dht_nodes) │ │ │ -0004f5b0: 0a09 097b 0a3c 2f70 7265 3e3c 2f74 643e ...{.
    │ │ │ -0004f5c0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -0004f5f0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -0004f600: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -0004f610: 7074 3a65 7870 616e 6428 3138 3829 223e pt:expand(188)"> │ │ │ -0004f620: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ -0004f630: 6d70 6c2e 6370 703a 3633 3034 3c2f 613e mpl.cpp:6304 │ │ │ -0004f640: 3c2f 7464 3e3c 7464 3e61 7373 6572 7473 asserts │ │ │ -0004f650: 2074 6861 7420 6e6f 206f 7574 7374 616e that no outstan │ │ │ -0004f660: 6469 6e67 2061 7379 6e63 206f 7065 7261 ding async opera │ │ │ -0004f670: 7469 6f6e 7320 6172 6520 7374 696c 6c20 tions are still │ │ │ -0004f680: 696e 2066 6c69 6768 743c 2f74 643e 3c2f in flight

    asserts t │ │ │ -0004f6e0: 6861 7420 6e6f 206f 7574 7374 616e 6469 hat no outstandi │ │ │ -0004f6f0: 6e67 2061 7379 6e63 206f 7065 7261 7469 ng async operati │ │ │ -0004f700: 6f6e 7320 6172 6520 7374 696c 6c20 696e ons are still in │ │ │ -0004f710: 2066 6c69 6768 743c 2f68 323e 3c68 343e flight

    │ │ │ -0004f720: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ -0004f730: 6d70 6c2e 6370 703a 3633 3034 3c2f 6834 mpl.cpp:6304

    ..if 
    │ │ │ -0004f780: 2821 6d5f 6468 7429 2072 6574 7572 6e3b  (!m_dht) return;
    │ │ │ -0004f790: 0a09 096d 5f64 6874 2d26 6774 3b64 6972  ...m_dht->dir
    │ │ │ -0004f7a0: 6563 745f 7265 7175 6573 7428 6570 2c20  ect_request(ep, 
    │ │ │ -0004f7b0: 652c 2073 7464 3a3a 6269 6e64 2826 616d  e, std::bind(&am
    │ │ │ -0004f7c0: 703b 6f6e 5f64 6972 6563 745f 7265 7370  p;on_direct_resp
    │ │ │ -0004f7d0: 6f6e 7365 2c20 7374 643a 3a72 6566 286d  onse, std::ref(m
    │ │ │ -0004f7e0: 5f61 6c65 7274 7329 2c20 7573 6572 6461  _alerts), userda
    │ │ │ -0004f7f0: 7461 2c20 5f31 2929 3b0a 097d 0a0a 2365  ta, _1));..}..#e
    │ │ │ -0004f800: 6e64 6966 0a0a 0962 6f6f 6c20 7365 7373  ndif...bool sess
    │ │ │ -0004f810: 696f 6e5f 696d 706c 3a3a 6973 5f6c 6973  ion_impl::is_lis
    │ │ │ -0004f820: 7465 6e69 6e67 2829 2063 6f6e 7374 0a09  tening() const..
    │ │ │ -0004f830: 7b0a 0909 7265 7475 726e 2021 6d5f 6c69  {...return !m_li
    │ │ │ -0004f840: 7374 656e 5f73 6f63 6b65 7473 2e65 6d70  sten_sockets.emp
    │ │ │ -0004f850: 7479 2829 3b0a 097d 0a0a 0973 6573 7369  ty();..}...sessi
    │ │ │ -0004f860: 6f6e 5f69 6d70 6c3a 3a7e 7365 7373 696f  on_impl::~sessio
    │ │ │ -0004f870: 6e5f 696d 706c 2829 0a09 7b0a 0909 2f2f  n_impl()..{...//
    │ │ │ -0004f880: 2073 696e 6365 2077 6527 7265 2064 6573   since we're des
    │ │ │ -0004f890: 7472 7563 7469 6e67 2074 6865 2073 6573  tructing the ses
    │ │ │ -0004f8a0: 7369 6f6e 2c20 6e6f 206d 6f72 6520 616c  sion, no more al
    │ │ │ -0004f8b0: 6572 7473 2077 696c 6c20 6d61 6b65 2069  erts will make i
    │ │ │ -0004f8c0: 7420 6f75 7420 746f 0a09 092f 2f20 7468  t out to...// th
    │ │ │ -0004f8d0: 6520 7573 6572 2e20 536f 2073 746f 7020  e user. So stop 
    │ │ │ -0004f8e0: 706f 7374 696e 6720 7468 656d 206e 6f77  posting them now
    │ │ │ -0004f8f0: 0a09 096d 5f61 6c65 7274 732e 7365 745f  ...m_alerts.set_
    │ │ │ -0004f900: 616c 6572 745f 6d61 736b 287b 7d29 3b0a  alert_mask({});.
    │ │ │ -0004f910: 0909 6d5f 616c 6572 7473 2e73 6574 5f6e  ..m_alerts.set_n
    │ │ │ -0004f920: 6f74 6966 795f 6675 6e63 7469 6f6e 287b  otify_function({
    │ │ │ -0004f930: 7d29 3b0a 0a09 092f 2f20 7468 6973 2069  });....// this i
    │ │ │ -0004f940: 7320 6e6f 7420 616c 6c6f 7765 6420 746f  s not allowed to
    │ │ │ -0004f950: 2062 6520 7468 6520 6e65 7477 6f72 6b20   be the network 
    │ │ │ -0004f960: 7468 7265 6164 210a 2f2f 0909 544f 5252  thread!.//..TORR
    │ │ │ -0004f970: 454e 545f 4153 5345 5254 2869 735f 6e6f  ENT_ASSERT(is_no
    │ │ │ -0004f980: 745f 7468 7265 6164 2829 293b 0a3c 6469  t_thread());....// this can 
    │ │ │ -0004f9d0: 6861 7070 656e 2069 6620 7765 2065 6e64  happen if we end
    │ │ │ -0004f9e0: 2074 6865 2069 6f5f 636f 6e74 6578 7420   the io_context 
    │ │ │ -0004f9f0: 7275 6e20 6c6f 6f70 2077 6974 6820 616e  run loop with an
    │ │ │ -0004fa00: 2065 7863 6570 7469 6f6e 0a09 096d 5f63   exception...m_c
    │ │ │ -0004fa10: 6f6e 6e65 6374 696f 6e73 2e63 6c65 6172  onnections.clear
    │ │ │ -0004fa20: 2829 3b0a 0909 666f 7220 2861 7574 6f26  ();...for (auto&
    │ │ │ -0004fa30: 616d 703b 2074 203a 206d 5f74 6f72 7265  amp; t : m_torre
    │ │ │ -0004fa40: 6e74 7329 0a09 097b 0a09 0909 742d 2667  nts)...{....t-&g
    │ │ │ -0004fa50: 743b 7061 6e69 6328 293b 0a09 0909 742d  t;panic();....t-
    │ │ │ -0004fa60: 2667 743b 6162 6f72 7428 293b 0a09 097d  >abort();...}
    │ │ │ -0004fa70: 0a09 096d 5f74 6f72 7265 6e74 732e 636c  ...m_torrents.cl
    │ │ │ -0004fa80: 6561 7228 293b 0a0a 0909 2f2f 2074 6869  ear();....// thi
    │ │ │ -0004fa90: 7320 6861 7320 7072 6f62 6162 6c79 2062  s has probably b
    │ │ │ -0004faa0: 6565 6e20 6361 6c6c 6564 2061 6c72 6561  een called alrea
    │ │ │ -0004fab0: 6479 2c20 6275 7420 696e 2063 6173 6520  dy, but in case 
    │ │ │ -0004fac0: 6f66 2073 7564 6465 6e0a 0909 2f2f 2074  of sudden...// t
    │ │ │ -0004fad0: 6572 6d69 6e61 7469 6f6e 2074 6872 6f75  ermination throu
    │ │ │ -0004fae0: 6768 2061 6e20 6578 6365 7074 696f 6e2c  gh an exception,
    │ │ │ -0004faf0: 2069 7420 6d61 7920 6e6f 7420 6861 7665   it may not have
    │ │ │ -0004fb00: 2062 6565 6e20 646f 6e65 0a09 0961 626f   been done...abo
    │ │ │ -0004fb10: 7274 5f73 7461 6765 3228 293b 0a0a 2369  rt_stage2();..#i
    │ │ │ -0004fb20: 6620 6465 6669 6e65 6420 544f 5252 454e  f defined TORREN
    │ │ │ -0004fb30: 545f 4153 494f 5f44 4542 5547 4749 4e47  T_ASIO_DEBUGGING
    │ │ │ -0004fb40: 0a09 0946 494c 452a 2066 203d 2066 6f70  ...FILE* f = fop
    │ │ │ -0004fb50: 656e 2822 7761 6b65 7570 732e 6c6f 6722  en("wakeups.log"
    │ │ │ -0004fb60: 2c20 2277 2b22 293b 0a09 0969 6620 2866  , "w+");...if (f
    │ │ │ -0004fb70: 2021 3d20 6e75 6c6c 7074 7229 0a09 097b   != nullptr)...{
    │ │ │ -0004fb80: 0a09 0909 7469 6d65 5f70 6f69 6e74 206d  ....time_point m
    │ │ │ -0004fb90: 203d 206d 696e 5f74 696d 6528 293b 0a09   = min_time();..
    │ │ │ -0004fba0: 0909 6966 2028 215f 7761 6b65 7570 732e  ..if (!_wakeups.
    │ │ │ -0004fbb0: 656d 7074 7928 2929 206d 203d 205f 7761  empty()) m = _wa
    │ │ │ -0004fbc0: 6b65 7570 735b 305d 2e74 696d 6573 7461  keups[0].timesta
    │ │ │ -0004fbd0: 6d70 3b0a 0909 0974 696d 655f 706f 696e  mp;....time_poin
    │ │ │ -0004fbe0: 7420 7072 6576 203d 206d 3b0a 0909 0973  t prev = m;....s
    │ │ │ -0004fbf0: 7464 3a3a 7569 6e74 3634 5f74 2070 7265  td::uint64_t pre
    │ │ │ -0004fc00: 765f 6373 7720 3d20 303b 0a09 0909 6966  v_csw = 0;....if
    │ │ │ -0004fc10: 2028 215f 7761 6b65 7570 732e 656d 7074   (!_wakeups.empt
    │ │ │ -0004fc20: 7928 2929 2070 7265 765f 6373 7720 3d20  y()) prev_csw = 
    │ │ │ -0004fc30: 5f77 616b 6575 7073 5b30 5d2e 636f 6e74  _wakeups[0].cont
    │ │ │ -0004fc40: 6578 745f 7377 6974 6368 6573 3b0a 0909  ext_switches;...
    │ │ │ -0004fc50: 0973 7464 3a3a 6670 7269 6e74 6628 662c  .std::fprintf(f,
    │ │ │ -0004fc60: 2022 6162 732e 2074 696d 655c 7472 656c   "abs. time\trel
    │ │ │ -0004fc70: 2e20 7469 6d65 5c74 6374 7820 7377 6974  . time\tctx swit
    │ │ │ -0004fc80: 6368 5c74 6964 6c65 2d77 616b 6575 705c  ch\tidle-wakeup\
    │ │ │ -0004fc90: 746f 7065 7261 7469 6f6e 5c6e 2229 3b0a  toperation\n");.
    │ │ │ -0004fca0: 0909 0966 6f72 2028 7761 6b65 7570 5f74  ...for (wakeup_t
    │ │ │ -0004fcb0: 2063 6f6e 7374 2661 6d70 3b20 7720 3a20   const& w : 
    │ │ │ -0004fcc0: 5f77 616b 6575 7073 290a 0909 097b 0a09  _wakeups)....{..
    │ │ │ -0004fcd0: 0909 0962 6f6f 6c20 636f 6e73 7420 6964  ...bool const id
    │ │ │ -0004fce0: 6c65 5f77 616b 6575 7020 3d20 772e 636f  le_wakeup = w.co
    │ │ │ -0004fcf0: 6e74 6578 745f 7377 6974 6368 6573 2026  ntext_switches &
    │ │ │ -0004fd00: 6774 3b20 7072 6576 5f63 7377 3b0a 0909  gt; prev_csw;...
    │ │ │ -0004fd10: 0909 7374 643a 3a66 7072 696e 7466 2866  ..std::fprintf(f
    │ │ │ -0004fd20: 2c20 2225 2220 5052 4964 3634 2022 5c74  , "%" PRId64 "\t
    │ │ │ -0004fd30: 2522 2050 5249 6436 3420 225c 7425 2220  %" PRId64 "\t%" 
    │ │ │ -0004fd40: 5052 4964 3634 2022 5c74 2563 5c74 2573  PRId64 "\t%c\t%s
    │ │ │ -0004fd50: 5c6e 220a 0909 0909 092c 2074 6f74 616c  \n"......, total
    │ │ │ -0004fd60: 5f6d 6963 726f 7365 636f 6e64 7328 772e  _microseconds(w.
    │ │ │ -0004fd70: 7469 6d65 7374 616d 7020 2d20 6d29 0a09  timestamp - m)..
    │ │ │ -0004fd80: 0909 0909 2c20 746f 7461 6c5f 6d69 6372  ...., total_micr
    │ │ │ -0004fd90: 6f73 6563 6f6e 6473 2877 2e74 696d 6573  oseconds(w.times
    │ │ │ -0004fda0: 7461 6d70 202d 2070 7265 7629 0a09 0909  tamp - prev)....
    │ │ │ -0004fdb0: 0909 2c20 772e 636f 6e74 6578 745f 7377  .., w.context_sw
    │ │ │ -0004fdc0: 6974 6368 6573 0a3c 2f70 7265 3e3c 2f74  itches.
    relevanc │ │ │ -0004fe00: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/session │ │ │ -0004fe40: 5f68 616e 646c 652e 6370 703a 3530 333c _handle.cpp:503< │ │ │ -0004fe50: 2f61 3e3c 2f74 643e 3c74 643e 696e 2043 /a>in C │ │ │ -0004fe60: 2b2b 3134 2c20 7573 6520 756e 6971 7565 ++14, use unique │ │ │ -0004fe70: 5f70 7472 2061 6e64 206d 6f76 6520 6974 _ptr and move it │ │ │ -0004fe80: 2069 6e74 6f20 7468 6520 6c61 6d62 6461 into the lambda │ │ │ -0004fe90: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    in │ │ │ -0004fee0: 2043 2b2b 3134 2c20 7573 6520 756e 6971 C++14, use uniq │ │ │ -0004fef0: 7565 5f70 7472 2061 6e64 206d 6f76 6520 ue_ptr and move │ │ │ -0004ff00: 6974 2069 6e74 6f20 7468 6520 6c61 6d62 it into the lamb │ │ │ -0004ff10: 6461 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 da

    ../sr │ │ │ -0004ff20: 632f 7365 7373 696f 6e5f 6861 6e64 6c65 c/session_handle │ │ │ -0004ff30: 2e63 7070 3a35 3033 3c2f 6834 3e3c 7072 .cpp:503

    #ifndef B │ │ │ -0004ff80: 4f4f 5354 5f4e 4f5f 4558 4345 5054 494f OOST_NO_EXCEPTIO │ │ │ -0004ff90: 4e53 0a09 0969 6620 2870 6172 616d 732e NS...if (params. │ │ │ -0004ffa0: 7361 7665 5f70 6174 682e 656d 7074 7928 save_path.empty( │ │ │ -0004ffb0: 2929 0a09 0909 6175 783a 3a74 6872 6f77 ))....aux::throw │ │ │ -0004ffc0: 5f65 7826 6c74 3b73 7973 7465 6d5f 6572 _ex<system_er │ │ │ -0004ffd0: 726f 7226 6774 3b28 6572 726f 725f 636f ror>(error_co │ │ │ -0004ffe0: 6465 2865 7272 6f72 733a 3a69 6e76 616c de(errors::inval │ │ │ -0004fff0: 6964 5f73 6176 655f 7061 7468 2929 3b0a id_save_path));. │ │ │ -00050000: 2365 6c73 650a 0909 544f 5252 454e 545f #else...TORRENT_ │ │ │ -00050010: 4153 5345 5254 5f50 5245 434f 4e44 2821 ASSERT_PRECOND(! │ │ │ -00050020: 7061 7261 6d73 2e73 6176 655f 7061 7468 params.save_path │ │ │ -00050030: 2e65 6d70 7479 2829 293b 0a23 656e 6469 .empty());.#endi │ │ │ -00050040: 660a 0a23 6966 2054 4f52 5245 4e54 5f41 f..#if TORRENT_A │ │ │ -00050050: 4249 5f56 4552 5349 4f4e 2026 6c74 3b20 BI_VERSION < │ │ │ -00050060: 330a 0909 6966 2028 2170 6172 616d 732e 3...if (!params. │ │ │ -00050070: 696e 666f 5f68 6173 6865 732e 6861 735f info_hashes.has_ │ │ │ -00050080: 7631 2829 2026 616d 703b 2661 6d70 3b20 v1() && │ │ │ -00050090: 2170 6172 616d 732e 696e 666f 5f68 6173 !params.info_has │ │ │ -000500a0: 6865 732e 6861 735f 7632 2829 2026 616d hes.has_v2() &am │ │ │ -000500b0: 703b 2661 6d70 3b20 2170 6172 616d 732e p;& !params. │ │ │ -000500c0: 7469 290a 0909 0970 6172 616d 732e 696e ti)....params.in │ │ │ -000500d0: 666f 5f68 6173 6865 732e 7631 203d 2070 fo_hashes.v1 = p │ │ │ -000500e0: 6172 616d 732e 696e 666f 5f68 6173 683b arams.info_hash; │ │ │ -000500f0: 0a23 656e 6469 660a 0a09 092f 2f20 7468 .#endif....// th │ │ │ -00050100: 6520 696e 7465 726e 616c 2074 6f72 7265 e internal torre │ │ │ -00050110: 6e74 206f 626a 6563 7420 6b65 6570 7320 nt object keeps │ │ │ -00050120: 616e 6420 6d75 7461 7465 7320 7374 6174 and mutates stat │ │ │ -00050130: 6520 696e 2074 6865 0a09 092f 2f20 746f e in the...// to │ │ │ -00050140: 7272 656e 745f 696e 666f 206f 626a 6563 rrent_info objec │ │ │ -00050150: 742e 2057 6520 6361 6e27 7420 6c65 7420 t. We can't let │ │ │ -00050160: 7468 6174 206c 6561 6b20 6261 636b 2074 that leak back t │ │ │ -00050170: 6f20 7468 6520 636c 6965 6e74 0a09 0969 o the client...i │ │ │ -00050180: 6620 2870 6172 616d 732e 7469 290a 0909 f (params.ti)... │ │ │ -00050190: 0970 6172 616d 732e 7469 203d 2073 7464 .params.ti = std │ │ │ -000501a0: 3a3a 6d61 6b65 5f73 6861 7265 6426 6c74 ::make_shared< │ │ │ -000501b0: 3b74 6f72 7265 6e74 5f69 6e66 6f26 6774 ;torrent_info> │ │ │ -000501c0: 3b28 2a70 6172 616d 732e 7469 293b 0a0a ;(*params.ti);.. │ │ │ -000501d0: 0909 2f2f 2077 6520 6361 6e6e 6f74 2063 ..// we cannot c │ │ │ -000501e0: 6170 7475 7265 2061 2075 6e69 7175 655f apture a unique_ │ │ │ -000501f0: 7074 7220 696e 746f 2061 206c 616d 6264 ptr into a lambd │ │ │ -00050200: 6120 696e 2063 2b2b 3131 2c20 736f 2077 a in c++11, so w │ │ │ -00050210: 6520 7573 6520 6120 7261 770a 0909 2f2f e use a raw...// │ │ │ -00050220: 2070 6f69 6e74 6572 2066 6f72 206e 6f77 pointer for now │ │ │ -00050230: 2e20 6173 796e 635f 6361 6c6c 2075 7365 . async_call use │ │ │ -00050240: 7320 6120 6c61 6d62 6461 2065 7870 7265 s a lambda expre │ │ │ -00050250: 7373 696f 6e20 746f 2070 6f73 7420 7468 ssion to post th │ │ │ -00050260: 6520 6361 6c6c 0a09 092f 2f20 746f 2074 e call...// to t │ │ │ -00050270: 6865 206d 6169 6e20 7468 7265 6164 0a3c he main thread.< │ │ │ -00050280: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ -00050290: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ -000502a0: 7769 6474 683d 2231 3030 2522 3e09 0961 width="100%">..a │ │ │ -000502b0: 7574 6f2a 2070 203d 206e 6577 2061 6464 uto* p = new add │ │ │ -000502c0: 5f74 6f72 7265 6e74 5f70 6172 616d 7328 _torrent_params( │ │ │ -000502d0: 7374 643a 3a6d 6f76 6528 7061 7261 6d73 std::move(params │ │ │ -000502e0: 2929 3b0a 3c2f 6469 763e 0909 6175 746f ));...auto │ │ │ -000502f0: 2067 7561 7264 203d 2061 7578 3a3a 7363 guard = aux::sc │ │ │ -00050300: 6f70 655f 656e 6428 5b70 5d7b 2064 656c ope_end([p]{ del │ │ │ -00050310: 6574 6520 703b 207d 293b 0a09 0970 2d26 ete p; });...p-& │ │ │ -00050320: 6774 3b73 6176 655f 7061 7468 203d 2063 gt;save_path = c │ │ │ -00050330: 6f6d 706c 6574 6528 702d 2667 743b 7361 omplete(p->sa │ │ │ -00050340: 7665 5f70 6174 6829 3b0a 0a23 6966 2054 ve_path);..#if T │ │ │ -00050350: 4f52 5245 4e54 5f41 4249 5f56 4552 5349 ORRENT_ABI_VERSI │ │ │ -00050360: 4f4e 203d 3d20 310a 0909 6861 6e64 6c65 ON == 1...handle │ │ │ -00050370: 5f62 6163 6b77 6172 6473 5f63 6f6d 7061 _backwards_compa │ │ │ -00050380: 7469 626c 655f 7265 7375 6d65 5f64 6174 tible_resume_dat │ │ │ -00050390: 6128 2a70 293b 0a23 656e 6469 660a 0a09 a(*p);.#endif... │ │ │ -000503a0: 0961 7379 6e63 5f63 616c 6c28 2661 6d70 .async_call(& │ │ │ -000503b0: 3b73 6573 7369 6f6e 5f69 6d70 6c3a 3a61 ;session_impl::a │ │ │ -000503c0: 7379 6e63 5f61 6464 5f74 6f72 7265 6e74 sync_add_torrent │ │ │ -000503d0: 2c20 7029 3b0a 0909 6775 6172 642e 6469 , p);...guard.di │ │ │ -000503e0: 7361 726d 2829 3b0a 097d 0a0a 2369 666e sarm();..}..#ifn │ │ │ -000503f0: 6465 6620 424f 4f53 545f 4e4f 5f45 5843 def BOOST_NO_EXC │ │ │ -00050400: 4550 5449 4f4e 530a 2369 6620 544f 5252 EPTIONS.#if TORR │ │ │ -00050410: 454e 545f 4142 495f 5645 5253 494f 4e20 ENT_ABI_VERSION │ │ │ -00050420: 3d3d 2031 0a09 2f2f 2069 6620 7468 6520 == 1..// if the │ │ │ -00050430: 746f 7272 656e 7420 616c 7265 6164 7920 torrent already │ │ │ -00050440: 6578 6973 7473 2c20 7468 6973 2077 696c exists, this wil │ │ │ -00050450: 6c20 7468 726f 7720 6475 706c 6963 6174 l throw duplicat │ │ │ -00050460: 655f 746f 7272 656e 740a 0974 6f72 7265 e_torrent..torre │ │ │ -00050470: 6e74 5f68 616e 646c 6520 7365 7373 696f nt_handle sessio │ │ │ -00050480: 6e5f 6861 6e64 6c65 3a3a 6164 645f 746f n_handle::add_to │ │ │ -00050490: 7272 656e 7428 0a09 0974 6f72 7265 6e74 rrent(...torrent │ │ │ -000504a0: 5f69 6e66 6f20 636f 6e73 7426 616d 703b _info const& │ │ │ -000504b0: 2074 690a 0909 2c20 7374 643a 3a73 7472 ti..., std::str │ │ │ -000504c0: 696e 6720 636f 6e73 7426 616d 703b 2073 ing const& s │ │ │ -000504d0: 6176 655f 7061 7468 0a09 092c 2065 6e74 ave_path..., ent │ │ │ -000504e0: 7279 2063 6f6e 7374 2661 6d70 3b20 7265 ry const& re │ │ │ -000504f0: 7375 6d65 5f64 6174 610a 0909 2c20 7374 sume_data..., st │ │ │ -00050500: 6f72 6167 655f 6d6f 6465 5f74 2073 746f orage_mode_t sto │ │ │ -00050510: 7261 6765 5f6d 6f64 650a 0909 2c20 626f rage_mode..., bo │ │ │ -00050520: 6f6c 2063 6f6e 7374 2061 6464 5f70 6175 ol const add_pau │ │ │ -00050530: 7365 6429 0a09 7b0a 0909 6164 645f 746f sed)..{...add_to │ │ │ -00050540: 7272 656e 745f 7061 7261 6d73 2070 3b0a rrent_params p;. │ │ │ -00050550: 0909 702e 7469 203d 2073 7464 3a3a 6d61 ..p.ti = std::ma │ │ │ -00050560: 6b65 5f73 6861 7265 6426 6c74 3b74 6f72 ke_shared<tor │ │ │ -00050570: 7265 6e74 5f69 6e66 6f26 6774 3b28 7469 rent_info>(ti │ │ │ -00050580: 293b 0a09 0970 2e73 6176 655f 7061 7468 );...p.save_path │ │ │ -00050590: 203d 2073 6176 655f 7061 7468 3b0a 0909 = save_path;... │ │ │ -000505a0: 6966 2028 7265 7375 6d65 5f64 6174 612e if (resume_data. │ │ │ -000505b0: 7479 7065 2829 2021 3d20 656e 7472 793a type() != entry: │ │ │ -000505c0: 3a75 6e64 6566 696e 6564 5f74 290a 0909 :undefined_t)... │ │ │ -000505d0: 7b0a 0909 0962 656e 636f 6465 2873 7464 {....bencode(std │ │ │ -000505e0: 3a3a 6261 636b 5f69 6e73 6572 7465 7228 ::back_inserter( │ │ │ -000505f0: 702e 7265 7375 6d65 5f64 6174 6129 2c20 p.resume_data), │ │ │ -00050600: 7265 7375 6d65 5f64 6174 6129 3b0a 0909 resume_data);... │ │ │ -00050610: 7d0a 0909 702e 7374 6f72 6167 655f 6d6f }...p.storage_mo │ │ │ -00050620: 6465 203d 2073 746f 7261 6765 5f6d 6f64 de = storage_mod │ │ │ -00050630: 653b 0a09 0969 6620 2861 6464 5f70 6175 e;...if (add_pau │ │ │ -00050640: 7365 6429 2070 2e66 6c61 6773 207c 3d20 sed) p.flags |= │ │ │ -00050650: 6164 645f 746f 7272 656e 745f 7061 7261 add_torrent_para │ │ │ -00050660: 6d73 3a3a 666c 6167 5f70 6175 7365 643b ms::flag_paused; │ │ │ -00050670: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -000506b0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ -000506e0: 7263 2f73 6573 7369 6f6e 2e63 7070 3a35 rc/session.cpp:5 │ │ │ -000506f0: 3430 3c2f 613e 3c2f 7464 3e3c 7464 3e49 40I │ │ │ -00050700: 6e20 432b 2b31 372e 2075 7365 2069 6620 n C++17. use if │ │ │ -00050710: 636f 6e73 7465 7870 7220 696e 7374 6561 constexpr instea │ │ │ -00050720: 643c 2f74 643e 3c2f 7472 3e3c 7472 2069 d

    I │ │ │ -00050770: 6e20 432b 2b31 372e 2075 7365 2069 6620 n C++17. use if │ │ │ -00050780: 636f 6e73 7465 7870 7220 696e 7374 6561 constexpr instea │ │ │ -00050790: 643c 2f68 323e 3c68 343e 2e2e 2f73 7263 d

    ../src │ │ │ -000507a0: 2f73 6573 7369 6f6e 2e63 7070 3a35 3430 /session.cpp:540 │ │ │ -000507b0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -000507f0: 7b7d 0a09 7365 7373 696f 6e5f 7072 6f78  {}..session_prox
    │ │ │ -00050800: 793a 3a73 6573 7369 6f6e 5f70 726f 7879  y::session_proxy
    │ │ │ -00050810: 2873 6573 7369 6f6e 5f70 726f 7879 2063  (session_proxy c
    │ │ │ -00050820: 6f6e 7374 2661 6d70 3b29 203d 2064 6566  onst&) = def
    │ │ │ -00050830: 6175 6c74 3b0a 0973 6573 7369 6f6e 5f70  ault;..session_p
    │ │ │ -00050840: 726f 7879 2661 6d70 3b20 7365 7373 696f  roxy& sessio
    │ │ │ -00050850: 6e5f 7072 6f78 793a 3a6f 7065 7261 746f  n_proxy::operato
    │ │ │ -00050860: 723d 2873 6573 7369 6f6e 5f70 726f 7879  r=(session_proxy
    │ │ │ -00050870: 2063 6f6e 7374 2661 6d70 3b29 2026 616d   const&) &am
    │ │ │ -00050880: 703b 203d 2064 6566 6175 6c74 3b0a 0973  p; = default;..s
    │ │ │ -00050890: 6573 7369 6f6e 5f70 726f 7879 3a3a 7365  ession_proxy::se
    │ │ │ -000508a0: 7373 696f 6e5f 7072 6f78 7928 7365 7373  ssion_proxy(sess
    │ │ │ -000508b0: 696f 6e5f 7072 6f78 7926 616d 703b 2661  ion_proxy&&a
    │ │ │ -000508c0: 6d70 3b29 206e 6f65 7863 6570 7420 3d20  mp;) noexcept = 
    │ │ │ -000508d0: 6465 6661 756c 743b 0a09 7365 7373 696f  default;..sessio
    │ │ │ -000508e0: 6e5f 7072 6f78 7926 616d 703b 2073 6573  n_proxy& ses
    │ │ │ -000508f0: 7369 6f6e 5f70 726f 7879 3a3a 6f70 6572  sion_proxy::oper
    │ │ │ -00050900: 6174 6f72 3d28 7365 7373 696f 6e5f 7072  ator=(session_pr
    │ │ │ -00050910: 6f78 7926 616d 703b 2661 6d70 3b29 2026  oxy&&) &
    │ │ │ -00050920: 616d 703b 206e 6f65 7863 6570 7420 3d20  amp; noexcept = 
    │ │ │ -00050930: 6465 6661 756c 743b 0a09 7365 7373 696f  default;..sessio
    │ │ │ -00050940: 6e5f 7072 6f78 793a 3a7e 7365 7373 696f  n_proxy::~sessio
    │ │ │ -00050950: 6e5f 7072 6f78 7928 290a 097b 0a09 0969  n_proxy()..{...i
    │ │ │ -00050960: 6620 286d 5f74 6872 6561 6420 2661 6d70  f (m_thread &
    │ │ │ -00050970: 3b26 616d 703b 206d 5f74 6872 6561 642e  ;& m_thread.
    │ │ │ -00050980: 7573 655f 636f 756e 7428 2920 3d3d 2031  use_count() == 1
    │ │ │ -00050990: 290a 0909 7b0a 2369 6620 6465 6669 6e65  )...{.#if define
    │ │ │ -000509a0: 6420 544f 5252 454e 545f 4153 494f 5f44  d TORRENT_ASIO_D
    │ │ │ -000509b0: 4542 5547 4749 4e47 0a09 0909 7761 6974  EBUGGING....wait
    │ │ │ -000509c0: 5f66 6f72 5f61 7369 6f5f 6861 6e64 6c65  _for_asio_handle
    │ │ │ -000509d0: 7273 2829 3b0a 2365 6e64 6966 0a09 0909  rs();.#endif....
    │ │ │ -000509e0: 6d5f 7468 7265 6164 2d26 6774 3b6a 6f69  m_thread->joi
    │ │ │ -000509f0: 6e28 293b 0a09 097d 0a09 7d0a 0a09 544f  n();...}..}...TO
    │ │ │ -00050a00: 5252 454e 545f 4558 504f 5254 2073 7464  RRENT_EXPORT std
    │ │ │ -00050a10: 3a3a 756e 6971 7565 5f70 7472 266c 743b  ::unique_ptr<
    │ │ │ -00050a20: 6469 736b 5f69 6e74 6572 6661 6365 2667  disk_interface&g
    │ │ │ -00050a30: 743b 2064 6566 6175 6c74 5f64 6973 6b5f  t; default_disk_
    │ │ │ -00050a40: 696f 5f63 6f6e 7374 7275 6374 6f72 280a  io_constructor(.
    │ │ │ -00050a50: 0909 696f 5f63 6f6e 7465 7874 2661 6d70  ..io_context&
    │ │ │ -00050a60: 3b20 696f 732c 2073 6574 7469 6e67 735f  ; ios, settings_
    │ │ │ -00050a70: 696e 7465 7266 6163 6520 636f 6e73 7426  interface const&
    │ │ │ -00050a80: 616d 703b 2073 6574 742c 2063 6f75 6e74  amp; sett, count
    │ │ │ -00050a90: 6572 7326 616d 703b 2063 6e74 290a 097b  ers& cnt)..{
    │ │ │ -00050aa0: 0a23 6966 2054 4f52 5245 4e54 5f48 4156  .#if TORRENT_HAV
    │ │ │ -00050ab0: 455f 4d4d 4150 207c 7c20 544f 5252 454e  E_MMAP || TORREN
    │ │ │ -00050ac0: 545f 4841 5645 5f4d 4150 5f56 4945 575f  T_HAVE_MAP_VIEW_
    │ │ │ -00050ad0: 4f46 5f46 494c 450a 3c64 6976 2073 7479  OF_FILE.
    #include " │ │ │ -00050b10: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -00050b20: 6469 7361 626c 655f 6465 7072 6563 6174 disable_deprecat │ │ │ -00050b30: 696f 6e5f 7761 726e 696e 6773 5f70 7573 ion_warnings_pus │ │ │ -00050b40: 682e 6870 7022 0a3c 2f64 6976 3e09 0969 h.hpp".
    ..i │ │ │ -00050b50: 6620 2873 697a 656f 6628 766f 6964 2a29 f (sizeof(void*) │ │ │ -00050b60: 203d 3d20 3829 0a09 0909 7265 7475 726e == 8)....return │ │ │ -00050b70: 206d 6d61 705f 6469 736b 5f69 6f5f 636f mmap_disk_io_co │ │ │ -00050b80: 6e73 7472 7563 746f 7228 696f 732c 2073 nstructor(ios, s │ │ │ -00050b90: 6574 742c 2063 6e74 293b 0a09 0965 6c73 ett, cnt);...els │ │ │ -00050ba0: 650a 0909 0972 6574 7572 6e20 706f 7369 e....return posi │ │ │ -00050bb0: 785f 6469 736b 5f69 6f5f 636f 6e73 7472 x_disk_io_constr │ │ │ -00050bc0: 7563 746f 7228 696f 732c 2073 6574 742c uctor(ios, sett, │ │ │ -00050bd0: 2063 6e74 293b 0a23 696e 636c 7564 6520 cnt);.#include │ │ │ -00050be0: 226c 6962 746f 7272 656e 742f 6175 785f "libtorrent/aux_ │ │ │ -00050bf0: 2f64 6973 6162 6c65 5f77 6172 6e69 6e67 /disable_warning │ │ │ -00050c00: 735f 706f 702e 6870 7022 0a23 656c 7365 s_pop.hpp".#else │ │ │ -00050c10: 0a09 0972 6574 7572 6e20 706f 7369 785f ...return posix_ │ │ │ -00050c20: 6469 736b 5f69 6f5f 636f 6e73 7472 7563 disk_io_construc │ │ │ -00050c30: 746f 7228 696f 732c 2073 6574 742c 2063 tor(ios, sett, c │ │ │ -00050c40: 6e74 293b 0a23 656e 6469 660a 097d 0a0a nt);.#endif..}.. │ │ │ -00050c50: 7d0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 }.
    < │ │ │ -00050c80: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00050c90: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00050cc0: 7372 632f 7261 6e64 6f6d 2e63 7070 3a31 src/random.cpp:1 │ │ │ -00050cd0: 3431 3c2f 613e 3c2f 7464 3e3c 7464 3e69 41i │ │ │ -00050ce0: 6d70 726f 7665 2063 616c 6c69 6e67 2052 mprove calling R │ │ │ -00050cf0: 414e 445f 6279 7465 7320 6d75 6c74 6970 AND_bytes multip │ │ │ -00050d00: 6c65 2074 696d 6573 2c20 7573 696e 6720 le times, using │ │ │ -00050d10: 6661 6c6c 6261 636b 2066 6f72 206e 6f77 fallback for now │ │ │ -00050d20: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    im │ │ │ -00050d70: 7072 6f76 6520 6361 6c6c 696e 6720 5241 prove calling RA │ │ │ -00050d80: 4e44 5f62 7974 6573 206d 756c 7469 706c ND_bytes multipl │ │ │ -00050d90: 6520 7469 6d65 732c 2075 7369 6e67 2066 e times, using f │ │ │ -00050da0: 616c 6c62 6163 6b20 666f 7220 6e6f 773c allback for now< │ │ │ -00050db0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f72 /h2>

    ../src/r │ │ │ -00050dc0: 616e 646f 6d2e 6370 703a 3134 313c 2f68 andom.cpp:141
    #els
    │ │ │ -00050e10: 650a 0909 0973 7464 3a3a 6765 6e65 7261  e....std::genera
    │ │ │ -00050e20: 7465 2862 7566 6665 722e 6265 6769 6e28  te(buffer.begin(
    │ │ │ -00050e30: 292c 2062 7566 6665 722e 656e 6428 292c  ), buffer.end(),
    │ │ │ -00050e40: 205b 5d20 7b20 7265 7475 726e 2063 6861   [] { return cha
    │ │ │ -00050e50: 7228 7261 6e64 6f6d 2830 7866 6629 293b  r(random(0xff));
    │ │ │ -00050e60: 207d 293b 0a23 656e 6469 660a 0909 7d0a   });.#endif...}.
    │ │ │ -00050e70: 0a09 0976 6f69 6420 6372 7970 746f 5f72  ...void crypto_r
    │ │ │ -00050e80: 616e 646f 6d5f 6279 7465 7328 7370 616e  andom_bytes(span
    │ │ │ -00050e90: 266c 743b 6368 6172 2667 743b 2062 7566  <char> buf
    │ │ │ -00050ea0: 6665 7229 0a09 097b 0a23 6966 6465 6620  fer)...{.#ifdef 
    │ │ │ -00050eb0: 544f 5252 454e 545f 4255 494c 445f 5349  TORRENT_BUILD_SI
    │ │ │ -00050ec0: 4d55 4c41 544f 520a 0909 092f 2f20 496e  MULATOR....// In
    │ │ │ -00050ed0: 2074 6865 2073 696d 756c 6174 6f72 2077   the simulator w
    │ │ │ -00050ee0: 6520 7761 6e74 2064 6574 6572 6d69 6e69  e want determini
    │ │ │ -00050ef0: 7374 6963 2072 616e 646f 6d20 6e75 6d62  stic random numb
    │ │ │ -00050f00: 6572 730a 0909 0973 7464 3a3a 6765 6e65  ers....std::gene
    │ │ │ -00050f10: 7261 7465 2862 7566 6665 722e 6265 6769  rate(buffer.begi
    │ │ │ -00050f20: 6e28 292c 2062 7566 6665 722e 656e 6428  n(), buffer.end(
    │ │ │ -00050f30: 292c 205b 5d20 7b20 7265 7475 726e 2063  ), [] { return c
    │ │ │ -00050f40: 6861 7228 7261 6e64 6f6d 2830 7866 6629  har(random(0xff)
    │ │ │ -00050f50: 293b 207d 293b 0a23 656c 6966 2054 4f52  ); });.#elif TOR
    │ │ │ -00050f60: 5245 4e54 5f55 5345 5f43 4e47 0a09 0909  RENT_USE_CNG....
    │ │ │ -00050f70: 6175 783a 3a63 6e67 5f67 656e 5f72 616e  aux::cng_gen_ran
    │ │ │ -00050f80: 646f 6d28 6275 6666 6572 293b 0a23 656c  dom(buffer);.#el
    │ │ │ -00050f90: 6966 2054 4f52 5245 4e54 5f55 5345 5f43  if TORRENT_USE_C
    │ │ │ -00050fa0: 5259 5054 4f41 5049 0a09 0909 2f2f 2077  RYPTOAPI....// w
    │ │ │ -00050fb0: 696e 646f 7773 0a09 0909 6175 783a 3a63  indows....aux::c
    │ │ │ -00050fc0: 7279 7074 5f67 656e 5f72 616e 646f 6d28  rypt_gen_random(
    │ │ │ -00050fd0: 6275 6666 6572 293b 0a23 656c 6966 2064  buffer);.#elif d
    │ │ │ -00050fe0: 6566 696e 6564 2054 4f52 5245 4e54 5f55  efined TORRENT_U
    │ │ │ -00050ff0: 5345 5f4c 4942 4352 5950 544f 2026 616d  SE_LIBCRYPTO &am
    │ │ │ -00051000: 703b 2661 6d70 3b20 2164 6566 696e 6564  p;& !defined
    │ │ │ -00051010: 2054 4f52 5245 4e54 5f55 5345 5f57 4f4c   TORRENT_USE_WOL
    │ │ │ -00051020: 4653 534c 0a2f 2f20 776f 6c66 5353 4c20  FSSL.// wolfSSL 
    │ │ │ -00051030: 7573 6573 2077 635f 524e 475f 4765 6e65  uses wc_RNG_Gene
    │ │ │ -00051040: 7261 7465 426c 6f63 6b20 6173 2074 6865  rateBlock as the
    │ │ │ -00051050: 2069 6e74 6572 6e61 6c20 6675 6e63 7469   internal functi
    │ │ │ -00051060: 6f6e 2066 6f72 2074 6865 0a2f 2f20 6f70  on for the.// op
    │ │ │ -00051070: 656e 7373 6c20 636f 6d70 6174 6962 696c  enssl compatibil
    │ │ │ -00051080: 6974 7920 6c61 7965 722e 2054 6869 7320  ity layer. This 
    │ │ │ -00051090: 6675 6e63 7469 6f6e 2041 5049 2064 6f65  function API doe
    │ │ │ -000510a0: 7320 6e6f 7420 7375 7070 6f72 740a 2f2f  s not support.//
    │ │ │ -000510b0: 2061 6e20 6172 6269 7472 6172 7920 6275   an arbitrary bu
    │ │ │ -000510c0: 6666 6572 2073 697a 6520 286f 7065 6e73  ffer size (opens
    │ │ │ -000510d0: 736c 2064 6f65 7329 2c20 6974 2069 7320  sl does), it is 
    │ │ │ -000510e0: 6c69 6d69 7465 6420 6279 2074 6865 0a2f  limited by the./
    │ │ │ -000510f0: 2f20 636f 6e73 7461 6e74 2052 4e47 5f4d  / constant RNG_M
    │ │ │ -00051100: 4158 5f42 4c4f 434b 5f4c 454e 2e0a 3c64  AX_BLOCK_LEN......// openssl
    │ │ │ -00051150: 0a09 0909 696e 7420 7220 3d20 5241 4e44  ....int r = RAND
    │ │ │ -00051160: 5f62 7974 6573 2872 6569 6e74 6572 7072  _bytes(reinterpr
    │ │ │ -00051170: 6574 5f63 6173 7426 6c74 3b75 6e73 6967  et_cast<unsig
    │ │ │ -00051180: 6e65 6420 6368 6172 2a26 6774 3b28 6275  ned char*>(bu
    │ │ │ -00051190: 6666 6572 2e64 6174 6128 2929 0a09 0909  ffer.data())....
    │ │ │ -000511a0: 092c 2069 6e74 2862 7566 6665 722e 7369  ., int(buffer.si
    │ │ │ -000511b0: 7a65 2829 2929 3b0a 0909 0969 6620 2872  ze()));....if (r
    │ │ │ -000511c0: 2021 3d20 3129 2061 7578 3a3a 7468 726f   != 1) aux::thro
    │ │ │ -000511d0: 775f 6578 266c 743b 7379 7374 656d 5f65  w_ex<system_e
    │ │ │ -000511e0: 7272 6f72 2667 743b 2865 7272 6f72 733a  rror>(errors:
    │ │ │ -000511f0: 3a6e 6f5f 656e 7472 6f70 7929 3b0a 2365  :no_entropy);.#e
    │ │ │ -00051200: 6c69 6620 544f 5252 454e 545f 5553 455f  lif TORRENT_USE_
    │ │ │ -00051210: 4745 5452 414e 444f 4d0a 0909 0973 7369  GETRANDOM....ssi
    │ │ │ -00051220: 7a65 5f74 2063 6f6e 7374 2072 203d 203a  ze_t const r = :
    │ │ │ -00051230: 3a67 6574 7261 6e64 6f6d 2862 7566 6665  :getrandom(buffe
    │ │ │ -00051240: 722e 6461 7461 2829 2c20 7374 6174 6963  r.data(), static
    │ │ │ -00051250: 5f63 6173 7426 6c74 3b73 7464 3a3a 7369  _cast<std::si
    │ │ │ -00051260: 7a65 5f74 2667 743b 2862 7566 6665 722e  ze_t>(buffer.
    │ │ │ -00051270: 7369 7a65 2829 292c 2030 293b 0a09 0909  size()), 0);....
    │ │ │ -00051280: 6966 2028 7220 3d3d 2073 7369 7a65 5f74  if (r == ssize_t
    │ │ │ -00051290: 2862 7566 6665 722e 7369 7a65 2829 2929  (buffer.size()))
    │ │ │ -000512a0: 2072 6574 7572 6e3b 0a09 0909 6966 2028   return;....if (
    │ │ │ -000512b0: 7220 3d3d 202d 3120 2661 6d70 3b26 616d  r == -1 &&am
    │ │ │ -000512c0: 703b 2065 7272 6e6f 2021 3d20 454e 4f53  p; errno != ENOS
    │ │ │ -000512d0: 5953 2920 6175 783a 3a74 6872 6f77 5f65  YS) aux::throw_e
    │ │ │ -000512e0: 7826 6c74 3b73 7973 7465 6d5f 6572 726f  x<system_erro
    │ │ │ -000512f0: 7226 6774 3b28 6572 726f 725f 636f 6465  r>(error_code
    │ │ │ -00051300: 2865 7272 6e6f 2c20 6765 6e65 7269 635f  (errno, generic_
    │ │ │ -00051310: 6361 7465 676f 7279 2829 2929 3b0a 0909  category()));...
    │ │ │ -00051320: 0973 7461 7469 6320 6465 765f 7261 6e64  .static dev_rand
    │ │ │ -00051330: 6f6d 2064 6576 3b0a 0909 0964 6576 2e72  om dev;....dev.r
    │ │ │ -00051340: 6561 6428 6275 6666 6572 293b 0a23 656c  ead(buffer);.#el
    │ │ │ -00051350: 6966 2054 4f52 5245 4e54 5f55 5345 5f44  if TORRENT_USE_D
    │ │ │ -00051360: 4556 5f52 414e 444f 4d0a 0909 0973 7461  EV_RANDOM....sta
    │ │ │ -00051370: 7469 6320 6465 765f 7261 6e64 6f6d 2064  tic dev_random d
    │ │ │ -00051380: 6576 3b0a 0909 0964 6576 2e72 6561 6428  ev;....dev.read(
    │ │ │ -00051390: 6275 6666 6572 293b 0a23 656c 7365 0a0a  buffer);.#else..
    │ │ │ -000513a0: 2369 6620 544f 5252 454e 545f 4252 4f4b  #if TORRENT_BROK
    │ │ │ -000513b0: 454e 5f52 414e 444f 4d5f 4445 5649 4345  EN_RANDOM_DEVICE
    │ │ │ -000513c0: 0a09 0909 2f2f 2065 7665 6e20 7073 6575  ....// even pseu
    │ │ │ -000513d0: 646f 2072 616e 646f 6d20 6e75 6d62 6572  do random number
    │ │ │ -000513e0: 7320 7265 6c79 206f 6e20 6265 696e 6720  s rely on being 
    │ │ │ -000513f0: 6162 6c65 2074 6f20 7365 6564 2074 6865  able to seed the
    │ │ │ -00051400: 2072 616e 646f 6d0a 0909 092f 2f20 6765   random....// ge
    │ │ │ -00051410: 6e65 7261 746f 720a 2365 7272 6f72 2022  nerator.#error "
    │ │ │ -00051420: 6e6f 2065 6e74 726f 7079 2073 6f75 7263  no entropy sourc
    │ │ │ -00051430: 6520 6176 6169 6c61 626c 6522 0a23 656c  e available".#el
    │ │ │ -00051440: 7365 0a23 6966 6465 6620 544f 5252 454e  se.#ifdef TORREN
    │ │ │ -00051450: 545f 495f 5741 4e54 5f49 4e53 4543 5552  T_I_WANT_INSECUR
    │ │ │ -00051460: 455f 5241 4e44 4f4d 5f4e 554d 4245 5253  E_RANDOM_NUMBERS
    │ │ │ -00051470: 0a09 0909 7374 643a 3a67 656e 6572 6174  ....std::generat
    │ │ │ -00051480: 6528 6275 6666 6572 2e62 6567 696e 2829  e(buffer.begin()
    │ │ │ -00051490: 2c20 6275 6666 6572 2e65 6e64 2829 2c20  , buffer.end(), 
    │ │ │ -000514a0: 5b5d 207b 2072 6574 7572 6e20 6368 6172  [] { return char
    │ │ │ -000514b0: 2872 616e 646f 6d28 3078 6666 2929 3b20  (random(0xff)); 
    │ │ │ -000514c0: 7d29 3b0a 2365 6c73 650a 2365 7272 6f72  });.#else.#error
    │ │ │ -000514d0: 2022 6e6f 2073 6563 7572 6520 656e 7472   "no secure entr
    │ │ │ -000514e0: 6f70 7920 736f 7572 6365 2061 7661 696c  opy source avail
    │ │ │ -000514f0: 6162 6c65 2e20 4966 2079 6f75 2072 6561  able. If you rea
    │ │ │ -00051500: 6c6c 7920 7761 6e74 2069 6e73 6563 7572  lly want insecur
    │ │ │ -00051510: 6520 7261 6e64 6f6d 206e 756d 6265 7273  e random numbers
    │ │ │ -00051520: 2c20 6465 6669 6e65 2054 4f52 5245 4e54  , define TORRENT
    │ │ │ -00051530: 5f49 5f57 414e 545f 494e 5345 4355 5245  _I_WANT_INSECURE
    │ │ │ -00051540: 5f52 414e 444f 4d5f 4e55 4d42 4552 5322  _RANDOM_NUMBERS"
    │ │ │ -00051550: 0a23 656e 6469 660a 2365 6e64 6966 0a0a  .#endif.#endif..
    │ │ │ -00051560: 2365 6e64 6966 0a09 097d 0a7d 0a3c 2f70  #endif...}.}.

    re │ │ │ -000515a0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/p │ │ │ -000515e0: 6f73 6978 5f70 6172 745f 6669 6c65 2e63 osix_part_file.c │ │ │ -000515f0: 7070 3a33 3339 3c2f 613e 3c2f 7464 3e3c pp:339< │ │ │ -00051600: 7464 3e77 6861 7420 646f 2077 6520 646f td>what do we do │ │ │ -00051610: 2069 6620 736f 6d65 6f6e 6520 6973 2063 if someone is c │ │ │ -00051620: 7572 7265 6e74 6c79 2072 6561 6469 6e67 urrently reading │ │ │ -00051630: 2066 726f 6d20 7468 6520 6469 736b 2066 from the disk f │ │ │ -00051640: 726f 6d20 7468 6973 2070 6965 6365 3f20 rom this piece? │ │ │ -00051650: 646f 6573 2069 7420 6d61 7474 6572 3f20 does it matter? │ │ │ -00051660: 5369 6e63 6520 7765 2077 6f6e 2774 2061 Since we won't a │ │ │ -00051670: 6374 6976 656c 7920 6572 6173 6520 7468 ctively erase th │ │ │ -00051680: 6520 6461 7461 2066 726f 6d20 6469 736b e data from disk │ │ │ -00051690: 2c20 6275 7420 6974 206d 6179 2062 6520 , but it may be │ │ │ -000516a0: 6f76 6572 7772 6974 7465 6e20 736f 6f6e overwritten soon │ │ │ -000516b0: 2c20 6974 2773 2070 726f 6261 626c 7920 , it's probably │ │ │ -000516c0: 6e6f 7420 7468 6174 2062 6967 206f 6620 not that big of │ │ │ -000516d0: 6120 6465 616c 3c2f 7464 3e3c 2f74 723e a deal │ │ │ -000516e0: 3c74 7220 6964 3d22 3139 3222 2073 7479 │ │ │ -00051710: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00051720: 3c68 323e 7768 6174 2064 6f20 7765 2064

    what do we d │ │ │ -00051730: 6f20 6966 2073 6f6d 656f 6e65 2069 7320 o if someone is │ │ │ -00051740: 6375 7272 656e 746c 7920 7265 6164 696e currently readin │ │ │ -00051750: 6720 6672 6f6d 2074 6865 2064 6973 6b0a g from the disk. │ │ │ -00051760: 6672 6f6d 2074 6869 7320 7069 6563 653f from this piece? │ │ │ -00051770: 2064 6f65 7320 6974 206d 6174 7465 723f does it matter? │ │ │ -00051780: 2053 696e 6365 2077 6520 776f 6e27 7420 Since we won't │ │ │ -00051790: 6163 7469 7665 6c79 2065 7261 7365 2074 actively erase t │ │ │ -000517a0: 6865 0a64 6174 6120 6672 6f6d 2064 6973 he.data from dis │ │ │ -000517b0: 6b2c 2062 7574 2069 7420 6d61 7920 6265 k, but it may be │ │ │ -000517c0: 206f 7665 7277 7269 7474 656e 2073 6f6f overwritten soo │ │ │ -000517d0: 6e2c 2069 7427 7320 7072 6f62 6162 6c79 n, it's probably │ │ │ -000517e0: 206e 6f74 2074 6861 740a 6269 6720 6f66 not that.big of │ │ │ -000517f0: 2061 2064 6561 6c3c 2f68 323e 3c68 343e a deal

    │ │ │ -00051800: 2e2e 2f73 7263 2f70 6f73 6978 5f70 6172 ../src/posix_par │ │ │ -00051810: 745f 6669 6c65 2e63 7070 3a33 3339 3c2f t_file.cpp:339
    ...
    │ │ │ -00051860: 0969 6620 2865 6329 2072 6574 7572 6e20  .if (ec) return 
    │ │ │ -00051870: 7b7d 3b0a 0a23 6966 6465 6620 544f 5252  {};..#ifdef TORR
    │ │ │ -00051880: 454e 545f 5749 4e44 4f57 530a 0909 0972  ENT_WINDOWS....r
    │ │ │ -00051890: 6574 203d 2066 696c 655f 706f 696e 7465  et = file_pointe
    │ │ │ -000518a0: 7228 3a3a 5f77 666f 7065 6e28 636f 6e76  r(::_wfopen(conv
    │ │ │ -000518b0: 6572 745f 746f 5f6e 6174 6976 655f 7061  ert_to_native_pa
    │ │ │ -000518c0: 7468 5f73 7472 696e 6728 666e 292e 635f  th_string(fn).c_
    │ │ │ -000518d0: 7374 7228 292c 204c 2277 622b 2229 293b  str(), L"wb+"));
    │ │ │ -000518e0: 0a23 656c 7365 0a09 0909 7265 7420 3d20  .#else....ret = 
    │ │ │ -000518f0: 6669 6c65 5f70 6f69 6e74 6572 283a 3a66  file_pointer(::f
    │ │ │ -00051900: 6f70 656e 2866 6e2e 635f 7374 7228 292c  open(fn.c_str(),
    │ │ │ -00051910: 2022 7762 2b22 2929 3b0a 2365 6e64 6966   "wb+"));.#endif
    │ │ │ -00051920: 0a09 0909 6966 2028 7265 742e 6669 6c65  ....if (ret.file
    │ │ │ -00051930: 2829 203d 3d20 6e75 6c6c 7074 7229 0a09  () == nullptr)..
    │ │ │ -00051940: 0909 0965 632e 6173 7369 676e 2865 7272  ...ec.assign(err
    │ │ │ -00051950: 6e6f 2c20 6765 6e65 7269 635f 6361 7465  no, generic_cate
    │ │ │ -00051960: 676f 7279 2829 293b 0a09 097d 0a09 0969  gory());...}...i
    │ │ │ -00051970: 6620 2865 6329 2072 6574 7572 6e20 7b7d  f (ec) return {}
    │ │ │ -00051980: 3b0a 0909 7265 7475 726e 2072 6574 3b0a  ;...return ret;.
    │ │ │ -00051990: 097d 0a0a 0976 6f69 6420 706f 7369 785f  .}...void posix_
    │ │ │ -000519a0: 7061 7274 5f66 696c 653a 3a66 7265 655f  part_file::free_
    │ │ │ -000519b0: 7069 6563 6528 7069 6563 655f 696e 6465  piece(piece_inde
    │ │ │ -000519c0: 785f 7420 636f 6e73 7420 7069 6563 6529  x_t const piece)
    │ │ │ -000519d0: 0a09 7b0a 0909 6175 746f 2063 6f6e 7374  ..{...auto const
    │ │ │ -000519e0: 2069 203d 206d 5f70 6965 6365 5f6d 6170   i = m_piece_map
    │ │ │ -000519f0: 2e66 696e 6428 7069 6563 6529 3b0a 0909  .find(piece);...
    │ │ │ -00051a00: 6966 2028 6920 3d3d 206d 5f70 6965 6365  if (i == m_piece
    │ │ │ -00051a10: 5f6d 6170 2e65 6e64 2829 2920 7265 7475  _map.end()) retu
    │ │ │ -00051a20: 726e 3b0a 0a3c 6469 7620 7374 796c 653d  rn;..
    .
    ..m_fr │ │ │ -00051a60: 6565 5f73 6c6f 7473 2e70 7573 685f 6261 ee_slots.push_ba │ │ │ -00051a70: 636b 2869 2d26 6774 3b73 6563 6f6e 6429 ck(i->second) │ │ │ -00051a80: 3b0a 0909 6d5f 7069 6563 655f 6d61 702e ;...m_piece_map. │ │ │ -00051a90: 6572 6173 6528 6929 3b0a 0909 6d5f 6469 erase(i);...m_di │ │ │ -00051aa0: 7274 795f 6d65 7461 6461 7461 203d 2074 rty_metadata = t │ │ │ -00051ab0: 7275 653b 0a09 7d0a 0a09 766f 6964 2070 rue;..}...void p │ │ │ -00051ac0: 6f73 6978 5f70 6172 745f 6669 6c65 3a3a osix_part_file:: │ │ │ -00051ad0: 6d6f 7665 5f70 6172 7466 696c 6528 7374 move_partfile(st │ │ │ -00051ae0: 643a 3a73 7472 696e 6720 636f 6e73 7426 d::string const& │ │ │ -00051af0: 616d 703b 2070 6174 682c 2065 7272 6f72 amp; path, error │ │ │ -00051b00: 5f63 6f64 6526 616d 703b 2065 6329 0a09 _code& ec).. │ │ │ -00051b10: 7b0a 0909 666c 7573 685f 6d65 7461 6461 {...flush_metada │ │ │ -00051b20: 7461 5f69 6d70 6c28 6563 293b 0a09 0969 ta_impl(ec);...i │ │ │ -00051b30: 6620 2865 6329 2072 6574 7572 6e3b 0a0a f (ec) return;.. │ │ │ -00051b40: 0909 6966 2028 216d 5f70 6965 6365 5f6d ..if (!m_piece_m │ │ │ -00051b50: 6170 2e65 6d70 7479 2829 290a 0909 7b0a ap.empty())...{. │ │ │ -00051b60: 0909 0973 7464 3a3a 7374 7269 6e67 206f ...std::string o │ │ │ -00051b70: 6c64 5f70 6174 6820 3d20 636f 6d62 696e ld_path = combin │ │ │ -00051b80: 655f 7061 7468 286d 5f70 6174 682c 206d e_path(m_path, m │ │ │ -00051b90: 5f6e 616d 6529 3b0a 0909 0973 7464 3a3a _name);....std:: │ │ │ -00051ba0: 7374 7269 6e67 206e 6577 5f70 6174 6820 string new_path │ │ │ -00051bb0: 3d20 636f 6d62 696e 655f 7061 7468 2870 = combine_path(p │ │ │ -00051bc0: 6174 682c 206d 5f6e 616d 6529 3b0a 0a09 ath, m_name);... │ │ │ -00051bd0: 0909 7265 6e61 6d65 286f 6c64 5f70 6174 ..rename(old_pat │ │ │ -00051be0: 682c 206e 6577 5f70 6174 682c 2065 6329 h, new_path, ec) │ │ │ -00051bf0: 3b0a 0909 0969 6620 2865 6320 3d3d 2062 ;....if (ec == b │ │ │ -00051c00: 6f6f 7374 3a3a 7379 7374 656d 3a3a 6572 oost::system::er │ │ │ -00051c10: 7263 3a3a 6e6f 5f73 7563 685f 6669 6c65 rc::no_such_file │ │ │ -00051c20: 5f6f 725f 6469 7265 6374 6f72 7929 0a09 _or_directory).. │ │ │ -00051c30: 0909 0965 632e 636c 6561 7228 293b 0a0a ...ec.clear();.. │ │ │ -00051c40: 0909 0969 6620 2865 6329 0a09 0909 7b0a ...if (ec)....{. │ │ │ -00051c50: 0909 0909 7374 6f72 6167 655f 6572 726f ....storage_erro │ │ │ -00051c60: 7220 7365 3b0a 0909 0909 6175 783a 3a63 r se;.....aux::c │ │ │ -00051c70: 6f70 795f 6669 6c65 286f 6c64 5f70 6174 opy_file(old_pat │ │ │ -00051c80: 682c 206e 6577 5f70 6174 682c 2073 6529 h, new_path, se) │ │ │ -00051c90: 3b0a 0909 0909 6563 203d 2073 652e 6563 ;.....ec = se.ec │ │ │ -00051ca0: 3b0a 0909 0909 6966 2028 6563 2920 7265 ;.....if (ec) re │ │ │ -00051cb0: 7475 726e 3b0a 0909 0909 7265 6d6f 7665 turn;.....remove │ │ │ -00051cc0: 286f 6c64 5f70 6174 682c 2065 6329 3b0a (old_path, ec);. │ │ │ -00051cd0: 0909 097d 0a09 097d 0a09 096d 5f70 6174 ...}...}...m_pat │ │ │ -00051ce0: 6820 3d20 7061 7468 3b0a 097d 0a3c 2f70 h = path;..}.

    re │ │ │ -00051d20: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/p │ │ │ -00051d60: 6f73 6978 5f70 6172 745f 6669 6c65 2e63 osix_part_file.c │ │ │ -00051d70: 7070 3a34 3239 3c2f 613e 3c2f 7464 3e3c pp:429< │ │ │ -00051d80: 7464 3e69 6e73 7465 6164 206f 6620 7265 td>instead of re │ │ │ -00051d90: 6275 696c 6469 6e67 2074 6865 2077 686f building the who │ │ │ -00051da0: 6c65 2066 696c 6520 6865 6164 6572 2061 le file header a │ │ │ -00051db0: 6e64 2066 6c75 7368 696e 6720 6974 2c20 nd flushing it, │ │ │ -00051dc0: 7570 6461 7465 2074 6865 2073 6c6f 7420 update the slot │ │ │ -00051dd0: 656e 7472 6965 7320 6173 2077 6520 676f entries as we go │ │ │ -00051de0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    in │ │ │ -00051e30: 7374 6561 6420 6f66 2072 6562 7569 6c64 stead of rebuild │ │ │ -00051e40: 696e 6720 7468 6520 7768 6f6c 6520 6669 ing the whole fi │ │ │ -00051e50: 6c65 2068 6561 6465 720a 616e 6420 666c le header.and fl │ │ │ -00051e60: 7573 6869 6e67 2069 742c 2075 7064 6174 ushing it, updat │ │ │ -00051e70: 6520 7468 6520 736c 6f74 2065 6e74 7269 e the slot entri │ │ │ -00051e80: 6573 2061 7320 7765 2067 6f3c 2f68 323e es as we go

    │ │ │ -00051e90: 3c68 343e 2e2e 2f73 7263 2f70 6f73 6978

    ../src/posix │ │ │ -00051ea0: 5f70 6172 745f 6669 6c65 2e63 7070 3a34 _part_file.cpp:4 │ │ │ -00051eb0: 3239 3c2f 6834 3e3c 7072 6520 7374 796c 29

    ....{......if (
    │ │ │ -00051f00: 7374 643a 3a66 6572 726f 7228 6669 6c65  std::ferror(file
    │ │ │ -00051f10: 2e66 696c 6528 2929 2920 6563 2e61 7373  .file())) ec.ass
    │ │ │ -00051f20: 6967 6e28 6572 726e 6f2c 2067 656e 6572  ign(errno, gener
    │ │ │ -00051f30: 6963 5f63 6174 6567 6f72 7928 2929 3b0a  ic_category());.
    │ │ │ -00051f40: 0909 0909 0965 6c73 6520 6563 2e61 7373  .....else ec.ass
    │ │ │ -00051f50: 6967 6e28 6572 726f 7273 3a3a 6669 6c65  ign(errors::file
    │ │ │ -00051f60: 5f74 6f6f 5f73 686f 7274 2c20 6c69 6274  _too_short, libt
    │ │ │ -00051f70: 6f72 7265 6e74 5f63 6174 6567 6f72 7928  orrent_category(
    │ │ │ -00051f80: 2929 3b0a 0909 0909 7d0a 0a09 0909 0969  ));.....}......i
    │ │ │ -00051f90: 6620 2865 6329 2072 6574 7572 6e3b 0a0a  f (ec) return;..
    │ │ │ -00051fa0: 0909 0909 6628 6669 6c65 5f6f 6666 7365  ....f(file_offse
    │ │ │ -00051fb0: 742c 207b 6275 662e 6765 7428 292c 2062  t, {buf.get(), b
    │ │ │ -00051fc0: 6c6f 636b 5f74 6f5f 636f 7079 7d29 3b0a  lock_to_copy});.
    │ │ │ -00051fd0: 0909 097d 0a09 0909 6669 6c65 5f6f 6666  ...}....file_off
    │ │ │ -00051fe0: 7365 7420 2b3d 2062 6c6f 636b 5f74 6f5f  set += block_to_
    │ │ │ -00051ff0: 636f 7079 3b0a 0909 0970 6965 6365 5f6f  copy;....piece_o
    │ │ │ -00052000: 6666 7365 7420 3d20 303b 0a09 0909 7369  ffset = 0;....si
    │ │ │ -00052010: 7a65 202d 3d20 626c 6f63 6b5f 746f 5f63  ze -= block_to_c
    │ │ │ -00052020: 6f70 793b 0a09 097d 0a09 7d0a 0a09 766f  opy;...}..}...vo
    │ │ │ -00052030: 6964 2070 6f73 6978 5f70 6172 745f 6669  id posix_part_fi
    │ │ │ -00052040: 6c65 3a3a 666c 7573 685f 6d65 7461 6461  le::flush_metada
    │ │ │ -00052050: 7461 2865 7272 6f72 5f63 6f64 6526 616d  ta(error_code&am
    │ │ │ -00052060: 703b 2065 6329 0a09 7b0a 0909 666c 7573  p; ec)..{...flus
    │ │ │ -00052070: 685f 6d65 7461 6461 7461 5f69 6d70 6c28  h_metadata_impl(
    │ │ │ -00052080: 6563 293b 0a09 7d0a 0a3c 6469 7620 7374  ec);..}..
    .void pos │ │ │ -000520c0: 6978 5f70 6172 745f 6669 6c65 3a3a 666c ix_part_file::fl │ │ │ -000520d0: 7573 685f 6d65 7461 6461 7461 5f69 6d70 ush_metadata_imp │ │ │ -000520e0: 6c28 6572 726f 725f 636f 6465 2661 6d70 l(error_code& │ │ │ -000520f0: 3b20 6563 290a 3c2f 6469 763e 097b 0a09 ; ec).
    .{.. │ │ │ -00052100: 092f 2f20 646f 2077 6520 6e65 6564 2074 .// do we need t │ │ │ -00052110: 6f20 666c 7573 6820 7468 6520 6d65 7461 o flush the meta │ │ │ -00052120: 6461 7461 3f0a 0909 6966 2028 6d5f 6469 data?...if (m_di │ │ │ -00052130: 7274 795f 6d65 7461 6461 7461 203d 3d20 rty_metadata == │ │ │ -00052140: 6661 6c73 6529 2072 6574 7572 6e3b 0a0a false) return;.. │ │ │ -00052150: 0909 6966 2028 6d5f 7069 6563 655f 6d61 ..if (m_piece_ma │ │ │ -00052160: 702e 656d 7074 7928 2929 0a09 097b 0a09 p.empty())...{.. │ │ │ -00052170: 0909 2f2f 2069 6620 7765 2064 6f6e 2774 ..// if we don't │ │ │ -00052180: 2068 6176 6520 616e 7920 7069 6563 6573 have any pieces │ │ │ -00052190: 206c 6566 7420 696e 2074 6865 0a09 0909 left in the.... │ │ │ -000521a0: 2f2f 2070 6172 7420 6669 6c65 2c20 7265 // part file, re │ │ │ -000521b0: 6d6f 7665 2069 740a 0909 0973 7464 3a3a move it....std:: │ │ │ -000521c0: 7374 7269 6e67 2063 6f6e 7374 2070 203d string const p = │ │ │ -000521d0: 2063 6f6d 6269 6e65 5f70 6174 6828 6d5f combine_path(m_ │ │ │ -000521e0: 7061 7468 2c20 6d5f 6e61 6d65 293b 0a09 path, m_name);.. │ │ │ -000521f0: 0909 7265 6d6f 7665 2870 2c20 6563 293b ..remove(p, ec); │ │ │ -00052200: 0a0a 0909 0969 6620 2865 6320 3d3d 2062 .....if (ec == b │ │ │ -00052210: 6f6f 7374 3a3a 7379 7374 656d 3a3a 6572 oost::system::er │ │ │ -00052220: 7263 3a3a 6e6f 5f73 7563 685f 6669 6c65 rc::no_such_file │ │ │ -00052230: 5f6f 725f 6469 7265 6374 6f72 7929 0a09 _or_directory).. │ │ │ -00052240: 0909 0965 632e 636c 6561 7228 293b 0a09 ...ec.clear();.. │ │ │ -00052250: 0909 7265 7475 726e 3b0a 0909 7d0a 0a09 ..return;...}... │ │ │ -00052260: 0961 7574 6f20 6620 3d20 6f70 656e 5f66 .auto f = open_f │ │ │ -00052270: 696c 6528 6f70 656e 5f6d 6f64 653a 3a72 ile(open_mode::r │ │ │ -00052280: 6561 645f 7772 6974 652c 2065 6329 3b0a ead_write, ec);. │ │ │ -00052290: 0909 6966 2028 6563 2920 7265 7475 726e ..if (ec) return │ │ │ -000522a0: 3b0a 0a09 0973 7464 3a3a 7665 6374 6f72 ;....std::vector │ │ │ -000522b0: 266c 743b 6368 6172 2667 743b 2068 6561 <char> hea │ │ │ -000522c0: 6465 7228 7374 6174 6963 5f63 6173 7426 der(static_cast& │ │ │ -000522d0: 6c74 3b73 7464 3a3a 7369 7a65 5f74 2667 lt;std::size_t&g │ │ │ -000522e0: 743b 286d 5f68 6561 6465 725f 7369 7a65 t;(m_header_size │ │ │ -000522f0: 2929 3b0a 0a09 0975 7369 6e67 206e 616d ));....using nam │ │ │ -00052300: 6573 7061 6365 206c 6962 746f 7272 656e espace libtorren │ │ │ -00052310: 743a 3a61 7578 3b0a 0a09 0963 6861 722a t::aux;....char* │ │ │ -00052320: 2070 7472 203d 2068 6561 6465 722e 6461 ptr = header.da │ │ │ -00052330: 7461 2829 3b0a 0909 7772 6974 655f 7569 ta();...write_ui │ │ │ -00052340: 6e74 3332 286d 5f6d 6178 5f70 6965 6365 nt32(m_max_piece │ │ │ -00052350: 732c 2070 7472 293b 0a09 0977 7269 7465 s, ptr);...write │ │ │ -00052360: 5f75 696e 7433 3228 6d5f 7069 6563 655f _uint32(m_piece_ │ │ │ -00052370: 7369 7a65 2c20 7074 7229 3b0a 0a09 0966 size, ptr);....f │ │ │ -00052380: 6f72 2028 7069 6563 655f 696e 6465 785f or (piece_index_ │ │ │ -00052390: 7420 7069 6563 6528 3029 3b20 7069 6563 t piece(0); piec │ │ │ -000523a0: 6520 266c 743b 2070 6965 6365 5f69 6e64 e < piece_ind │ │ │ -000523b0: 6578 5f74 286d 5f6d 6178 5f70 6965 6365 ex_t(m_max_piece │ │ │ -000523c0: 7329 3b20 2b2b 7069 6563 6529 0a09 097b s); ++piece)...{ │ │ │ -000523d0: 0a09 0909 6175 746f 2063 6f6e 7374 2069 ....auto const i │ │ │ -000523e0: 203d 206d 5f70 6965 6365 5f6d 6170 2e66 = m_piece_map.f │ │ │ -000523f0: 696e 6428 7069 6563 6529 3b0a 3c2f 7072 ind(piece);.rel │ │ │ -00052430: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/pi │ │ │ -00052470: 6563 655f 7069 636b 6572 2e63 7070 3a31 ece_picker.cpp:1 │ │ │ -00052480: 3231 3c2f 613e 3c2f 7464 3e3c 7464 3e66 21f │ │ │ -00052490: 696e 6420 6120 6265 7474 6572 2070 6c61 ind a better pla │ │ │ -000524a0: 6365 2066 6f72 2074 6869 733c 2f74 643e ce for this │ │ │ -000524b0: 3c2f 7472 3e3c 7472 2069 643d 2231 3934

    find a │ │ │ -00052500: 6265 7474 6572 2070 6c61 6365 2066 6f72 better place for │ │ │ -00052510: 2074 6869 733c 2f68 323e 3c68 343e 2e2e this

    .. │ │ │ -00052520: 2f73 7263 2f70 6965 6365 5f70 6963 6b65 /src/piece_picke │ │ │ -00052530: 722e 6370 703a 3132 313c 2f68 343e 3c70 r.cpp:121

    ...if (l │ │ │ -00052580: 696d 6974 203d 3d20 3029 0a09 0909 7b0a imit == 0)....{. │ │ │ -00052590: 0909 0909 7374 643a 3a63 6572 7220 266c ....std::cerr &l │ │ │ -000525a0: 743b 266c 743b 2022 202e 2e2e 223b 0a09 t;< " ...";.. │ │ │ -000525b0: 0909 0962 7265 616b 3b0a 0909 097d 0a09 ...break;....}.. │ │ │ -000525c0: 0909 6966 2028 2a69 203d 3d20 2d31 2920 ..if (*i == -1) │ │ │ -000525d0: 6272 6561 6b3b 0a09 0909 7768 696c 6520 break;....while │ │ │ -000525e0: 286a 2021 3d20 702e 6d5f 7072 696f 7269 (j != p.m_priori │ │ │ -000525f0: 7479 5f62 6f75 6e64 6172 6965 732e 656e ty_boundaries.en │ │ │ -00052600: 6428 2920 2661 6d70 3b26 616d 703b 202a d() && * │ │ │ -00052610: 6a20 266c 743b 3d20 696e 6465 7829 0a09 j <= index).. │ │ │ -00052620: 0909 7b0a 0909 0909 7374 643a 3a63 6572 ..{.....std::cer │ │ │ -00052630: 7220 266c 743b 266c 743b 2022 7c20 223b r << "| "; │ │ │ -00052640: 0a09 0909 092b 2b6a 3b0a 0909 097d 0a09 .....++j;....}.. │ │ │ -00052650: 0909 7374 643a 3a63 6572 7220 266c 743b ..std::cerr < │ │ │ -00052660: 266c 743b 202a 6920 266c 743b 266c 743b < *i << │ │ │ -00052670: 2022 2822 2026 6c74 3b26 6c74 3b20 702e "(" << p. │ │ │ -00052680: 6d5f 7069 6563 655f 6d61 705b 2a69 5d2e m_piece_map[*i]. │ │ │ -00052690: 696e 6465 7820 266c 743b 266c 743b 2022 index << " │ │ │ -000526a0: 2920 223b 0a09 0909 2d2d 6c69 6d69 743b ) ";....--limit; │ │ │ -000526b0: 0a09 097d 0a09 0973 7464 3a3a 6365 7272 ...}...std::cerr │ │ │ -000526c0: 2026 6c74 3b26 6c74 3b20 7374 643a 3a65 << std::e │ │ │ -000526d0: 6e64 6c3b 0a09 7d0a 7d0a 2365 6e64 6966 ndl;..}.}.#endif │ │ │ -000526e0: 202f 2f20 544f 5252 454e 545f 5049 434b // TORRENT_PICK │ │ │ -000526f0: 4552 5f4c 4f47 0a6e 616d 6573 7061 6365 ER_LOG.namespace │ │ │ -00052700: 206c 6962 746f 7272 656e 7420 7b0a 0a3c libtorrent {..< │ │ │ -00052710: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ -00052720: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ -00052730: 7769 6474 683d 2231 3030 2522 3e09 636f width="100%">.co │ │ │ -00052740: 6e73 7420 7069 6563 655f 626c 6f63 6b20 nst piece_block │ │ │ -00052750: 7069 6563 655f 626c 6f63 6b3a 3a69 6e76 piece_block::inv │ │ │ -00052760: 616c 6964 280a 3c2f 6469 763e 0909 7374 alid(...st │ │ │ -00052770: 643a 3a6e 756d 6572 6963 5f6c 696d 6974 d::numeric_limit │ │ │ -00052780: 7326 6c74 3b70 6965 6365 5f69 6e64 6578 s<piece_index │ │ │ -00052790: 5f74 2667 743b 3a3a 6d61 7828 290a 0909 _t>::max()... │ │ │ -000527a0: 2c20 7374 643a 3a6e 756d 6572 6963 5f6c , std::numeric_l │ │ │ -000527b0: 696d 6974 7326 6c74 3b69 6e74 2667 743b imits<int> │ │ │ -000527c0: 3a3a 6d61 7828 2929 3b0a 0a09 636f 6e73 ::max());...cons │ │ │ -000527d0: 7465 7870 7220 7072 696f 5f69 6e64 6578 texpr prio_index │ │ │ -000527e0: 5f74 2070 6965 6365 5f70 6963 6b65 723a _t piece_picker: │ │ │ -000527f0: 3a70 6965 6365 5f70 6f73 3a3a 7765 5f68 :piece_pos::we_h │ │ │ -00052800: 6176 655f 696e 6465 783b 0a0a 0963 6f6e ave_index;...con │ │ │ -00052810: 7374 6578 7072 2070 6963 6b65 725f 6f70 stexpr picker_op │ │ │ -00052820: 7469 6f6e 735f 7420 7069 6563 655f 7069 tions_t piece_pi │ │ │ -00052830: 636b 6572 3a3a 7261 7265 7374 5f66 6972 cker::rarest_fir │ │ │ -00052840: 7374 3b0a 0963 6f6e 7374 6578 7072 2070 st;..constexpr p │ │ │ -00052850: 6963 6b65 725f 6f70 7469 6f6e 735f 7420 icker_options_t │ │ │ -00052860: 7069 6563 655f 7069 636b 6572 3a3a 7265 piece_picker::re │ │ │ -00052870: 7665 7273 653b 0a09 636f 6e73 7465 7870 verse;..constexp │ │ │ -00052880: 7220 7069 636b 6572 5f6f 7074 696f 6e73 r picker_options │ │ │ -00052890: 5f74 2070 6965 6365 5f70 6963 6b65 723a _t piece_picker: │ │ │ -000528a0: 3a6f 6e5f 7061 726f 6c65 3b0a 0963 6f6e :on_parole;..con │ │ │ -000528b0: 7374 6578 7072 2070 6963 6b65 725f 6f70 stexpr picker_op │ │ │ -000528c0: 7469 6f6e 735f 7420 7069 6563 655f 7069 tions_t piece_pi │ │ │ -000528d0: 636b 6572 3a3a 7072 696f 7269 7469 7a65 cker::prioritize │ │ │ -000528e0: 5f70 6172 7469 616c 733b 0a09 636f 6e73 _partials;..cons │ │ │ -000528f0: 7465 7870 7220 7069 636b 6572 5f6f 7074 texpr picker_opt │ │ │ -00052900: 696f 6e73 5f74 2070 6965 6365 5f70 6963 ions_t piece_pic │ │ │ -00052910: 6b65 723a 3a73 6571 7565 6e74 6961 6c3b ker::sequential; │ │ │ -00052920: 0a09 636f 6e73 7465 7870 7220 7069 636b ..constexpr pick │ │ │ -00052930: 6572 5f6f 7074 696f 6e73 5f74 2070 6965 er_options_t pie │ │ │ -00052940: 6365 5f70 6963 6b65 723a 3a61 6c69 676e ce_picker::align │ │ │ -00052950: 5f65 7870 616e 6465 645f 7069 6563 6573 _expanded_pieces │ │ │ -00052960: 3b0a 0963 6f6e 7374 6578 7072 2070 6963 ;..constexpr pic │ │ │ -00052970: 6b65 725f 6f70 7469 6f6e 735f 7420 7069 ker_options_t pi │ │ │ -00052980: 6563 655f 7069 636b 6572 3a3a 7069 6563 ece_picker::piec │ │ │ -00052990: 655f 6578 7465 6e74 5f61 6666 696e 6974 e_extent_affinit │ │ │ -000529a0: 793b 0a0a 0963 6f6e 7374 6578 7072 2064 y;...constexpr d │ │ │ -000529b0: 6f77 6e6c 6f61 645f 7175 6575 655f 7420 ownload_queue_t │ │ │ -000529c0: 7069 6563 655f 7069 636b 6572 3a3a 7069 piece_picker::pi │ │ │ -000529d0: 6563 655f 706f 733a 3a70 6965 6365 5f64 ece_pos::piece_d │ │ │ -000529e0: 6f77 6e6c 6f61 6469 6e67 3b0a 0963 6f6e ownloading;..con │ │ │ -000529f0: 7374 6578 7072 2064 6f77 6e6c 6f61 645f stexpr download_ │ │ │ -00052a00: 7175 6575 655f 7420 7069 6563 655f 7069 queue_t piece_pi │ │ │ -00052a10: 636b 6572 3a3a 7069 6563 655f 706f 733a cker::piece_pos: │ │ │ -00052a20: 3a70 6965 6365 5f66 756c 6c3b 0a09 636f :piece_full;..co │ │ │ -00052a30: 6e73 7465 7870 7220 646f 776e 6c6f 6164 nstexpr download │ │ │ -00052a40: 5f71 7565 7565 5f74 2070 6965 6365 5f70 _queue_t piece_p │ │ │ -00052a50: 6963 6b65 723a 3a70 6965 6365 5f70 6f73 icker::piece_pos │ │ │ -00052a60: 3a3a 7069 6563 655f 6669 6e69 7368 6564 ::piece_finished │ │ │ -00052a70: 3b0a 0963 6f6e 7374 6578 7072 2064 6f77 ;..constexpr dow │ │ │ -00052a80: 6e6c 6f61 645f 7175 6575 655f 7420 7069 nload_queue_t pi │ │ │ -00052a90: 6563 655f 7069 636b 6572 3a3a 7069 6563 ece_picker::piec │ │ │ -00052aa0: 655f 706f 733a 3a70 6965 6365 5f7a 6572 e_pos::piece_zer │ │ │ -00052ab0: 6f5f 7072 696f 3b0a 0963 6f6e 7374 6578 o_prio;..constex │ │ │ -00052ac0: 7072 2064 6f77 6e6c 6f61 645f 7175 6575 pr download_queu │ │ │ -00052ad0: 655f 7420 7069 6563 655f 7069 636b 6572 e_t piece_picker │ │ │ -00052ae0: 3a3a 7069 6563 655f 706f 733a 3a6e 756d ::piece_pos::num │ │ │ -00052af0: 5f64 6f77 6e6c 6f61 645f 6361 7465 676f _download_catego │ │ │ -00052b00: 7269 6573 3b0a 0963 6f6e 7374 6578 7072 ries;..constexpr │ │ │ -00052b10: 2064 6f77 6e6c 6f61 645f 7175 6575 655f download_queue_ │ │ │ -00052b20: 7420 7069 6563 655f 7069 636b 6572 3a3a t piece_picker:: │ │ │ -00052b30: 7069 6563 655f 706f 733a 3a70 6965 6365 piece_pos::piece │ │ │ -00052b40: 5f6f 7065 6e3b 0a09 636f 6e73 7465 7870 _open;..constexp │ │ │ -00052b50: 7220 646f 776e 6c6f 6164 5f71 7565 7565 r download_queue │ │ │ -00052b60: 5f74 2070 6965 6365 5f70 6963 6b65 723a _t piece_picker: │ │ │ -00052b70: 3a70 6965 6365 5f70 6f73 3a3a 7069 6563 :piece_pos::piec │ │ │ -00052b80: 655f 646f 776e 6c6f 6164 696e 675f 7265 e_downloading_re │ │ │ -00052b90: 7665 7273 653b 0a09 636f 6e73 7465 7870 verse;..constexp │ │ │ -00052ba0: 7220 646f 776e 6c6f 6164 5f71 7565 7565 r download_queue │ │ │ -00052bb0: 5f74 2070 6965 6365 5f70 6963 6b65 723a _t piece_picker: │ │ │ -00052bc0: 3a70 6965 6365 5f70 6f73 3a3a 7069 6563 :piece_pos::piec │ │ │ -00052bd0: 655f 6675 6c6c 5f72 6576 6572 7365 3b0a e_full_reverse;. │ │ │ -00052be0: 0a09 2f2f 2074 6865 206d 6178 206e 756d ..// the max num │ │ │ -00052bf0: 6265 7220 6f66 2062 6c6f 636b 7320 746f ber of blocks to │ │ │ -00052c00: 2063 7265 6174 6520 616e 2061 6666 696e create an affin │ │ │ -00052c10: 6974 7920 666f 720a 0963 6f6e 7374 6578 ity for..constex │ │ │ -00052c20: 7072 2069 6e74 206d 6178 5f70 6965 6365 pr int max_piece │ │ │ -00052c30: 5f61 6666 696e 6974 795f 6578 7465 6e74 _affinity_extent │ │ │ -00052c40: 203d 2034 202a 2031 3032 3420 2a20 3130 = 4 * 1024 * 10 │ │ │ -00052c50: 3234 202f 2064 6566 6175 6c74 5f62 6c6f 24 / default_blo │ │ │ -00052c60: 636b 5f73 697a 653b 0a0a 0970 6965 6365 ck_size;...piece │ │ │ -00052c70: 5f70 6963 6b65 723a 3a70 6965 6365 5f70 _picker::piece_p │ │ │ -00052c80: 6963 6b65 7228 7374 643a 3a69 6e74 3634 icker(std::int64 │ │ │ -00052c90: 5f74 2063 6f6e 7374 2074 6f74 616c 5f73 _t const total_s │ │ │ -00052ca0: 697a 652c 2069 6e74 2063 6f6e 7374 2070 ize, int const p │ │ │ -00052cb0: 6965 6365 5f73 697a 6529 0a09 093a 206d iece_size)...: m │ │ │ -00052cc0: 5f70 7269 6f72 6974 795f 626f 756e 6461 _priority_bounda │ │ │ -00052cd0: 7269 6573 2831 2c20 6d5f 7069 6563 6573 ries(1, m_pieces │ │ │ -00052ce0: 2e65 6e64 5f69 6e64 6578 2829 290a 097b .end_index())..{ │ │ │ -00052cf0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -00052d00: 5428 746f 7461 6c5f 7369 7a65 2026 6774 T(total_size > │ │ │ -00052d10: 3b20 3029 3b0a 0909 544f 5252 454e 545f ; 0);...TORRENT_ │ │ │ -00052d20: 4153 5345 5254 2870 6965 6365 5f73 697a ASSERT(piece_siz │ │ │ -00052d30: 6520 2667 743b 2030 293b 0a3c 2f70 7265 e > 0);.

    rele │ │ │ -00052d70: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/pie │ │ │ -00052db0: 6365 5f70 6963 6b65 722e 6370 703a 3230 ce_picker.cpp:20 │ │ │ -00052dc0: 3834 3c2f 613e 3c2f 7464 3e3c 7464 3e74 84t │ │ │ -00052dd0: 6869 7320 636f 756c 6420 7072 6f62 6162 his could probab │ │ │ -00052de0: 6c79 2062 6520 6f70 7469 6d69 7a65 6420 ly be optimized │ │ │ -00052df0: 6279 2069 6e63 7265 6d65 6e74 616c 6c79 by incrementally │ │ │ -00052e00: 2063 616c 6c69 6e67 2070 6172 7469 616c calling partial │ │ │ -00052e10: 5f73 6f72 7420 746f 2073 6f72 7420 6f6e _sort to sort on │ │ │ -00052e20: 6520 6d6f 7265 2065 6c65 6d65 6e74 2069 e more element i │ │ │ -00052e30: 6e20 7468 6520 6c69 7374 2e20 4265 6361 n the list. Beca │ │ │ -00052e40: 7573 6520 6368 616e 6365 7320 6172 6520 use chances are │ │ │ -00052e50: 7468 6174 2077 6527 6c6c 206a 7573 7420 that we'll just │ │ │ -00052e60: 6e65 6564 2061 2073 696e 676c 6520 7069 need a single pi │ │ │ -00052e70: 6563 652c 2061 6e64 206f 6e63 6520 7765 ece, and once we │ │ │ -00052e80: 2776 6520 7069 636b 6564 2066 726f 6d20 've picked from │ │ │ -00052e90: 6974 2077 6527 7265 2064 6f6e 652e 2053 it we're done. S │ │ │ -00052ea0: 6f72 7469 6e67 2074 6865 2072 6573 7420 orting the rest │ │ │ -00052eb0: 6f66 2074 6865 206c 6973 7420 696e 2074 of the list in t │ │ │ -00052ec0: 6861 7420 6361 7365 2069 7320 6120 7761 hat case is a wa │ │ │ -00052ed0: 7374 6520 6f66 2074 696d 652e 3c2f 7464 ste of time.

    this c │ │ │ -00052f30: 6f75 6c64 2070 726f 6261 626c 7920 6265 ould probably be │ │ │ -00052f40: 206f 7074 696d 697a 6564 2062 7920 696e optimized by in │ │ │ -00052f50: 6372 656d 656e 7461 6c6c 790a 6361 6c6c crementally.call │ │ │ -00052f60: 696e 6720 7061 7274 6961 6c5f 736f 7274 ing partial_sort │ │ │ -00052f70: 2074 6f20 736f 7274 206f 6e65 206d 6f72 to sort one mor │ │ │ -00052f80: 6520 656c 656d 656e 7420 696e 2074 6865 e element in the │ │ │ -00052f90: 206c 6973 742e 2042 6563 6175 7365 0a63 list. Because.c │ │ │ -00052fa0: 6861 6e63 6573 2061 7265 2074 6861 7420 hances are that │ │ │ -00052fb0: 7765 276c 6c20 6a75 7374 206e 6565 6420 we'll just need │ │ │ -00052fc0: 6120 7369 6e67 6c65 2070 6965 6365 2c20 a single piece, │ │ │ -00052fd0: 616e 6420 6f6e 6365 2077 6527 7665 0a70 and once we've.p │ │ │ -00052fe0: 6963 6b65 6420 6672 6f6d 2069 7420 7765 icked from it we │ │ │ -00052ff0: 2772 6520 646f 6e65 2e20 536f 7274 696e 're done. Sortin │ │ │ -00053000: 6720 7468 6520 7265 7374 206f 6620 7468 g the rest of th │ │ │ -00053010: 6520 6c69 7374 2069 6e20 7468 6174 0a63 e list in that.c │ │ │ -00053020: 6173 6520 6973 2061 2077 6173 7465 206f ase is a waste o │ │ │ -00053030: 6620 7469 6d65 2e3c 2f68 323e 3c68 343e f time.

    │ │ │ -00053040: 2e2e 2f73 7263 2f70 6965 6365 5f70 6963 ../src/piece_pic │ │ │ -00053050: 6b65 722e 6370 703a 3230 3834 3c2f 6834 ker.cpp:2084

    ...//
    │ │ │ -000530a0: 206e 6f77 2c20 636f 7079 206f 7665 7220   now, copy over 
    │ │ │ -000530b0: 7468 6520 706f 696e 7465 7273 2e20 5765  the pointers. We
    │ │ │ -000530c0: 2061 6c73 6f20 6170 706c 7920 6120 6669   also apply a fi
    │ │ │ -000530d0: 6c74 6572 2068 6572 6520 746f 206e 6f74  lter here to not
    │ │ │ -000530e0: 0a09 0909 2f2f 2069 6e63 6c75 6465 2069  ....// include i
    │ │ │ -000530f0: 6e65 6c69 6769 626c 6520 7069 6563 6573  neligible pieces
    │ │ │ -00053100: 2069 6e20 6365 7274 6169 6e20 6d6f 6465   in certain mode
    │ │ │ -00053110: 732e 2046 6f72 2069 6e73 7461 6e63 652c  s. For instance,
    │ │ │ -00053120: 2061 2070 6965 6365 0a09 0909 2f2f 2074   a piece....// t
    │ │ │ -00053130: 6861 7420 7468 6520 6375 7272 656e 7420  hat the current 
    │ │ │ -00053140: 7065 6572 2064 6f65 736e 2774 2068 6176  peer doesn't hav
    │ │ │ -00053150: 6520 6973 206e 6f74 2069 6e63 6c75 6465  e is not include
    │ │ │ -00053160: 642e 0a09 0909 666f 7220 2861 7574 6f26  d.....for (auto&
    │ │ │ -00053170: 616d 703b 2064 7020 3a20 6d5f 646f 776e  amp; dp : m_down
    │ │ │ -00053180: 6c6f 6164 735b 7069 6563 655f 706f 733a  loads[piece_pos:
    │ │ │ -00053190: 3a70 6965 6365 5f64 6f77 6e6c 6f61 6469  :piece_downloadi
    │ │ │ -000531a0: 6e67 5d29 0a09 0909 7b0a 0909 0909 7063  ng])....{.....pc
    │ │ │ -000531b0: 2e69 6e63 5f73 7461 7473 5f63 6f75 6e74  .inc_stats_count
    │ │ │ -000531c0: 6572 2863 6f75 6e74 6572 733a 3a70 6965  er(counters::pie
    │ │ │ -000531d0: 6365 5f70 6963 6b65 725f 7061 7274 6961  ce_picker_partia
    │ │ │ -000531e0: 6c5f 6c6f 6f70 7329 3b0a 0a09 0909 0969  l_loops);......i
    │ │ │ -000531f0: 6620 2821 6973 5f70 6965 6365 5f66 7265  f (!is_piece_fre
    │ │ │ -00053200: 6528 6470 2e69 6e64 6578 2c20 7069 6563  e(dp.index, piec
    │ │ │ -00053210: 6573 2929 2063 6f6e 7469 6e75 653b 0a0a  es)) continue;..
    │ │ │ -00053220: 0909 0909 544f 5252 454e 545f 4153 5345  ....TORRENT_ASSE
    │ │ │ -00053230: 5254 286d 5f70 6965 6365 5f6d 6170 5b64  RT(m_piece_map[d
    │ │ │ -00053240: 702e 696e 6465 785d 2e64 6f77 6e6c 6f61  p.index].downloa
    │ │ │ -00053250: 645f 7175 6575 6528 290a 0909 0909 093d  d_queue()......=
    │ │ │ -00053260: 3d20 7069 6563 655f 706f 733a 3a70 6965  = piece_pos::pie
    │ │ │ -00053270: 6365 5f64 6f77 6e6c 6f61 6469 6e67 293b  ce_downloading);
    │ │ │ -00053280: 0a0a 0909 0909 6f72 6465 7265 645f 7061  ......ordered_pa
    │ │ │ -00053290: 7274 6961 6c73 5b6e 756d 5f6f 7264 6572  rtials[num_order
    │ │ │ -000532a0: 6564 5f70 6172 7469 616c 732b 2b5d 203d  ed_partials++] =
    │ │ │ -000532b0: 2026 616d 703b 6470 3b0a 0909 097d 0a0a   &dp;....}..
    │ │ │ -000532c0: 0909 092f 2f20 6e6f 772c 2073 6f72 7420  ...// now, sort 
    │ │ │ -000532d0: 7468 6520 6c69 7374 2e0a 0909 0969 6620  the list.....if 
    │ │ │ -000532e0: 286f 7074 696f 6e73 2026 616d 703b 2072  (options & r
    │ │ │ -000532f0: 6172 6573 745f 6669 7273 7429 0a09 0909  arest_first)....
    │ │ │ -00053300: 7b0a 0909 0909 7265 7420 7c3d 2070 6963  {.....ret |= pic
    │ │ │ -00053310: 6b65 725f 6c6f 675f 616c 6572 743a 3a72  ker_log_alert::r
    │ │ │ -00053320: 6172 6573 745f 6669 7273 745f 7061 7274  arest_first_part
    │ │ │ -00053330: 6961 6c73 3b0a 0a3c 6469 7620 7374 796c  ials;..
    ....std::so │ │ │ -00053370: 7274 286f 7264 6572 6564 5f70 6172 7469 rt(ordered_parti │ │ │ -00053380: 616c 732e 6265 6769 6e28 292c 206f 7264 als.begin(), ord │ │ │ -00053390: 6572 6564 5f70 6172 7469 616c 732e 6265 ered_partials.be │ │ │ -000533a0: 6769 6e28 2920 2b20 6e75 6d5f 6f72 6465 gin() + num_orde │ │ │ -000533b0: 7265 645f 7061 7274 6961 6c73 0a3c 2f64 red_partials......, std::b │ │ │ -000533d0: 696e 6428 2661 6d70 3b70 6965 6365 5f70 ind(&piece_p │ │ │ -000533e0: 6963 6b65 723a 3a70 6172 7469 616c 5f63 icker::partial_c │ │ │ -000533f0: 6f6d 7061 7265 5f72 6172 6573 745f 6669 ompare_rarest_fi │ │ │ -00053400: 7273 742c 2074 6869 730a 0909 0909 0909 rst, this....... │ │ │ -00053410: 2c20 5f31 2c20 5f32 2929 3b0a 0909 097d , _1, _2));....} │ │ │ -00053420: 0a0a 0909 0966 6f72 2028 696e 7420 6920 .....for (int i │ │ │ -00053430: 3d20 303b 2069 2026 6c74 3b20 6e75 6d5f = 0; i < num_ │ │ │ -00053440: 6f72 6465 7265 645f 7061 7274 6961 6c73 ordered_partials │ │ │ -00053450: 3b20 2b2b 6929 0a09 0909 7b0a 0909 0909 ; ++i)....{..... │ │ │ -00053460: 7265 7420 7c3d 2070 6963 6b65 725f 6c6f ret |= picker_lo │ │ │ -00053470: 675f 616c 6572 743a 3a70 7269 6f72 6974 g_alert::priorit │ │ │ -00053480: 697a 655f 7061 7274 6961 6c73 3b0a 0a09 ize_partials;... │ │ │ -00053490: 0909 096e 756d 5f62 6c6f 636b 7320 3d20 ...num_blocks = │ │ │ -000534a0: 6164 645f 626c 6f63 6b73 5f64 6f77 6e6c add_blocks_downl │ │ │ -000534b0: 6f61 6469 6e67 282a 6f72 6465 7265 645f oading(*ordered_ │ │ │ -000534c0: 7061 7274 6961 6c73 5b69 5d2c 2070 6965 partials[i], pie │ │ │ -000534d0: 6365 730a 0909 0909 092c 2069 6e74 6572 ces......, inter │ │ │ -000534e0: 6573 7469 6e67 5f62 6c6f 636b 732c 2062 esting_blocks, b │ │ │ -000534f0: 6163 6b75 705f 626c 6f63 6b73 2c20 6261 ackup_blocks, ba │ │ │ -00053500: 636b 7570 5f62 6c6f 636b 7332 0a09 0909 ckup_blocks2.... │ │ │ -00053510: 0909 2c20 6e75 6d5f 626c 6f63 6b73 2c20 .., num_blocks, │ │ │ -00053520: 7072 6566 6572 5f63 6f6e 7469 6775 6f75 prefer_contiguou │ │ │ -00053530: 735f 626c 6f63 6b73 2c20 7065 6572 2c20 s_blocks, peer, │ │ │ -00053540: 6f70 7469 6f6e 7329 3b0a 0909 0909 6966 options);.....if │ │ │ -00053550: 2028 6e75 6d5f 626c 6f63 6b73 2026 6c74 (num_blocks < │ │ │ -00053560: 3b3d 2030 2920 7265 7475 726e 2072 6574 ;= 0) return ret │ │ │ -00053570: 3b0a 0909 0909 6966 2028 696e 7428 6261 ;.....if (int(ba │ │ │ -00053580: 636b 7570 5f62 6c6f 636b 732e 7369 7a65 ckup_blocks.size │ │ │ -00053590: 2829 2920 2667 743b 3d20 6e75 6d5f 626c ()) >= num_bl │ │ │ -000535a0: 6f63 6b73 0a09 0909 0909 2661 6d70 3b26 ocks......&& │ │ │ -000535b0: 616d 703b 2069 6e74 2862 6163 6b75 705f amp; int(backup_ │ │ │ -000535c0: 626c 6f63 6b73 322e 7369 7a65 2829 2920 blocks2.size()) │ │ │ -000535d0: 2667 743b 3d20 6e75 6d5f 626c 6f63 6b73 >= num_blocks │ │ │ -000535e0: 290a 0909 0909 0962 7265 616b 3b0a 0909 )......break;... │ │ │ -000535f0: 097d 0a0a 0909 096e 756d 5f62 6c6f 636b .}.....num_block │ │ │ -00053600: 7320 3d20 6170 7065 6e64 5f62 6c6f 636b s = append_block │ │ │ -00053610: 7328 696e 7465 7265 7374 696e 675f 626c s(interesting_bl │ │ │ -00053620: 6f63 6b73 2c20 6261 636b 7570 5f62 6c6f ocks, backup_blo │ │ │ -00053630: 636b 730a 0909 0909 2c20 6e75 6d5f 626c cks....., num_bl │ │ │ -00053640: 6f63 6b73 293b 0a09 0909 6966 2028 6e75 ocks);....if (nu │ │ │ -00053650: 6d5f 626c 6f63 6b73 2026 6c74 3b3d 2030 m_blocks <= 0 │ │ │ -00053660: 2920 7265 7475 726e 2072 6574 3b0a 0a09 ) return ret;... │ │ │ -00053670: 0909 6e75 6d5f 626c 6f63 6b73 203d 2061 ..num_blocks = a │ │ │ -00053680: 7070 656e 645f 626c 6f63 6b73 2869 6e74 ppend_blocks(int │ │ │ -00053690: 6572 6573 7469 6e67 5f62 6c6f 636b 732c eresting_blocks, │ │ │ -000536a0: 2062 6163 6b75 705f 626c 6f63 6b73 320a backup_blocks2. │ │ │ -000536b0: 0909 0909 2c20 6e75 6d5f 626c 6f63 6b73 ...., num_blocks │ │ │ -000536c0: 293b 0a09 0909 6966 2028 6e75 6d5f 626c );....if (num_bl │ │ │ -000536d0: 6f63 6b73 2026 6c74 3b3d 2030 2920 7265 ocks <= 0) re │ │ │ -000536e0: 7475 726e 2072 6574 3b0a 0909 7d0a 0a09 turn ret;...}... │ │ │ -000536f0: 0969 6620 2821 7375 6767 6573 7465 645f .if (!suggested_ │ │ │ -00053700: 7069 6563 6573 2e65 6d70 7479 2829 290a pieces.empty()). │ │ │ -00053710: 0909 7b0a 0909 0966 6f72 2028 7069 6563 ..{....for (piec │ │ │ -00053720: 655f 696e 6465 785f 7420 6920 3a20 7375 e_index_t i : su │ │ │ -00053730: 6767 6573 7465 645f 7069 6563 6573 290a ggested_pieces). │ │ │ -00053740: 0909 097b 0a3c 2f70 7265 3e3c 2f74 643e ...{.
    │ │ │ -00053750: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00053780: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00053790: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -000537a0: 7074 3a65 7870 616e 6428 3139 3629 223e pt:expand(196)"> │ │ │ -000537b0: 2e2e 2f73 7263 2f70 6965 6365 5f70 6963 ../src/piece_pic │ │ │ -000537c0: 6b65 722e 6370 703a 3232 3238 3c2f 613e ker.cpp:2228 │ │ │ -000537d0: 3c2f 7464 3e3c 7464 3e49 7320 6974 2061 Is it a │ │ │ -000537e0: 2067 6f6f 6420 6964 6561 2074 6861 7420 good idea that │ │ │ -000537f0: 7468 6973 2061 6666 696e 6974 7920 7461 this affinity ta │ │ │ -00053800: 6b65 7320 7072 6563 6564 656e 6365 206f kes precedence o │ │ │ -00053810: 7665 7220 7069 6563 6520 7072 696f 7269 ver piece priori │ │ │ -00053820: 7479 3f3c 2f74 643e 3c2f 7472 3e3c 7472 ty?

    Is it a good id │ │ │ -00053880: 6561 2074 6861 7420 7468 6973 2061 6666 ea that this aff │ │ │ -00053890: 696e 6974 7920 7461 6b65 7320 7072 6563 inity takes prec │ │ │ -000538a0: 6564 656e 6365 206f 7665 720a 7069 6563 edence over.piec │ │ │ -000538b0: 6520 7072 696f 7269 7479 3f3c 2f68 323e e priority?

    │ │ │ -000538c0: 3c68 343e 2e2e 2f73 7263 2f70 6965 6365

    ../src/piece │ │ │ -000538d0: 5f70 6963 6b65 722e 6370 703a 3232 3238 _picker.cpp:2228 │ │ │ -000538e0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00053920: 0909 0909 7072 696f 5f69 6e64 6578 5f74  ....prio_index_t
    │ │ │ -00053930: 2063 6f6e 7374 2065 6e64 203d 2070 7269   const end = pri
    │ │ │ -00053940: 6f72 6974 795f 656e 6428 6929 3b0a 0909  ority_end(i);...
    │ │ │ -00053950: 0909 0966 6f72 2028 7072 696f 5f69 6e64  ...for (prio_ind
    │ │ │ -00053960: 6578 5f74 2070 203d 2070 7265 7628 656e  ex_t p = prev(en
    │ │ │ -00053970: 6429 3b20 7020 2667 743b 3d20 7374 6172  d); p >= star
    │ │ │ -00053980: 743b 202d 2d70 290a 0909 0909 097b 0a09  t; --p)......{..
    │ │ │ -00053990: 0909 0909 0970 632e 696e 635f 7374 6174  .....pc.inc_stat
    │ │ │ -000539a0: 735f 636f 756e 7465 7228 636f 756e 7465  s_counter(counte
    │ │ │ -000539b0: 7273 3a3a 7069 6563 655f 7069 636b 6572  rs::piece_picker
    │ │ │ -000539c0: 5f72 6576 6572 7365 5f72 6172 655f 6c6f  _reverse_rare_lo
    │ │ │ -000539d0: 6f70 7329 3b0a 0a09 0909 0909 0969 6620  ops);........if 
    │ │ │ -000539e0: 2821 6973 5f70 6965 6365 5f66 7265 6528  (!is_piece_free(
    │ │ │ -000539f0: 6d5f 7069 6563 6573 5b70 5d2c 2070 6965  m_pieces[p], pie
    │ │ │ -00053a00: 6365 7329 2920 636f 6e74 696e 7565 3b0a  ces)) continue;.
    │ │ │ -00053a10: 0a09 0909 0909 0972 6574 207c 3d20 7069  .......ret |= pi
    │ │ │ -00053a20: 636b 6572 5f6c 6f67 5f61 6c65 7274 3a3a  cker_log_alert::
    │ │ │ -00053a30: 7265 7665 7273 655f 7261 7265 7374 5f66  reverse_rarest_f
    │ │ │ -00053a40: 6972 7374 3b0a 0a09 0909 0909 096e 756d  irst;........num
    │ │ │ -00053a50: 5f62 6c6f 636b 7320 3d20 6164 645f 626c  _blocks = add_bl
    │ │ │ -00053a60: 6f63 6b73 286d 5f70 6965 6365 735b 705d  ocks(m_pieces[p]
    │ │ │ -00053a70: 2c20 7069 6563 6573 0a09 0909 0909 0909  , pieces........
    │ │ │ -00053a80: 2c20 696e 7465 7265 7374 696e 675f 626c  , interesting_bl
    │ │ │ -00053a90: 6f63 6b73 2c20 6261 636b 7570 5f62 6c6f  ocks, backup_blo
    │ │ │ -00053aa0: 636b 730a 0909 0909 0909 092c 2062 6163  cks........, bac
    │ │ │ -00053ab0: 6b75 705f 626c 6f63 6b73 322c 206e 756d  kup_blocks2, num
    │ │ │ -00053ac0: 5f62 6c6f 636b 730a 0909 0909 0909 092c  _blocks........,
    │ │ │ -00053ad0: 2070 7265 6665 725f 636f 6e74 6967 756f   prefer_contiguo
    │ │ │ -00053ae0: 7573 5f62 6c6f 636b 732c 2070 6565 722c  us_blocks, peer,
    │ │ │ -00053af0: 2069 676e 6f72 6564 5f70 6965 6365 730a   ignored_pieces.
    │ │ │ -00053b00: 0909 0909 0909 092c 206f 7074 696f 6e73  ......., options
    │ │ │ -00053b10: 293b 0a09 0909 0909 0969 6620 286e 756d  );.......if (num
    │ │ │ -00053b20: 5f62 6c6f 636b 7320 266c 743b 3d20 3029  _blocks <= 0)
    │ │ │ -00053b30: 2072 6574 7572 6e20 7265 743b 0a09 0909   return ret;....
    │ │ │ -00053b40: 0909 7d0a 0909 0909 7d0a 0909 097d 0a09  ..}.....}....}..
    │ │ │ -00053b50: 0909 656c 7365 0a09 0909 7b0a 3c64 6976  ..else....{.
    ....if │ │ │ -00053b90: 2028 6f70 7469 6f6e 7320 2661 6d70 3b20 (options & │ │ │ -00053ba0: 7069 6563 655f 6578 7465 6e74 5f61 6666 piece_extent_aff │ │ │ -00053bb0: 696e 6974 7929 0a3c 2f64 6976 3e09 0909 inity).
    ... │ │ │ -00053bc0: 097b 0a09 0909 0909 696e 7420 746f 5f65 .{......int to_e │ │ │ -00053bd0: 7261 7365 203d 202d 313b 0a09 0909 0909 rase = -1;...... │ │ │ -00053be0: 696e 7420 6964 7820 3d20 2d31 3b0a 0909 int idx = -1;... │ │ │ -00053bf0: 0909 0966 6f72 2028 7069 6563 655f 6578 ...for (piece_ex │ │ │ -00053c00: 7465 6e74 5f74 2063 6f6e 7374 2065 203a tent_t const e : │ │ │ -00053c10: 206d 5f72 6563 656e 745f 6578 7465 6e74 m_recent_extent │ │ │ -00053c20: 7329 0a09 0909 0909 7b0a 0909 0909 0909 s)......{....... │ │ │ -00053c30: 2b2b 6964 783b 0a09 0909 0909 0962 6f6f ++idx;.......boo │ │ │ -00053c40: 6c20 6861 7665 5f61 6c6c 203d 2074 7275 l have_all = tru │ │ │ -00053c50: 653b 0a09 0909 0909 0966 6f72 2028 7069 e;.......for (pi │ │ │ -00053c60: 6563 655f 696e 6465 785f 7420 636f 6e73 ece_index_t cons │ │ │ -00053c70: 7420 7020 3a20 6578 7465 6e74 5f66 6f72 t p : extent_for │ │ │ -00053c80: 2865 2929 0a09 0909 0909 097b 0a09 0909 (e)).......{.... │ │ │ -00053c90: 0909 0909 6966 2028 216d 5f70 6965 6365 ....if (!m_piece │ │ │ -00053ca0: 5f6d 6170 5b70 5d2e 6861 7665 2829 2920 _map[p].have()) │ │ │ -00053cb0: 6861 7665 5f61 6c6c 203d 2066 616c 7365 have_all = false │ │ │ -00053cc0: 3b0a 0909 0909 0909 0969 6620 2821 6973 ;........if (!is │ │ │ -00053cd0: 5f70 6965 6365 5f66 7265 6528 702c 2070 _piece_free(p, p │ │ │ -00053ce0: 6965 6365 7329 2920 636f 6e74 696e 7565 ieces)) continue │ │ │ -00053cf0: 3b0a 0a09 0909 0909 0909 7265 7420 7c3d ;.........ret |= │ │ │ -00053d00: 2070 6963 6b65 725f 6c6f 675f 616c 6572 picker_log_aler │ │ │ -00053d10: 743a 3a65 7874 656e 745f 6166 6669 6e69 t::extent_affini │ │ │ -00053d20: 7479 3b0a 0a09 0909 0909 0909 6e75 6d5f ty;.........num_ │ │ │ -00053d30: 626c 6f63 6b73 203d 2061 6464 5f62 6c6f blocks = add_blo │ │ │ -00053d40: 636b 7328 702c 2070 6965 6365 730a 0909 cks(p, pieces... │ │ │ -00053d50: 0909 0909 0909 2c20 696e 7465 7265 7374 ......, interest │ │ │ -00053d60: 696e 675f 626c 6f63 6b73 2c20 6261 636b ing_blocks, back │ │ │ -00053d70: 7570 5f62 6c6f 636b 730a 0909 0909 0909 up_blocks....... │ │ │ -00053d80: 0909 2c20 6261 636b 7570 5f62 6c6f 636b .., backup_block │ │ │ -00053d90: 7332 2c20 6e75 6d5f 626c 6f63 6b73 0a09 s2, num_blocks.. │ │ │ -00053da0: 0909 0909 0909 092c 2070 7265 6665 725f ......., prefer_ │ │ │ -00053db0: 636f 6e74 6967 756f 7573 5f62 6c6f 636b contiguous_block │ │ │ -00053dc0: 732c 2070 6565 722c 2069 676e 6f72 6564 s, peer, ignored │ │ │ -00053dd0: 5f70 6965 6365 730a 0909 0909 0909 0909 _pieces......... │ │ │ -00053de0: 2c20 6f70 7469 6f6e 7329 3b0a 0909 0909 , options);..... │ │ │ -00053df0: 0909 0969 6620 286e 756d 5f62 6c6f 636b ...if (num_block │ │ │ -00053e00: 7320 266c 743b 3d20 3029 0a09 0909 0909 s <= 0)...... │ │ │ -00053e10: 0909 7b0a 0909 0909 0909 0909 2f2f 2069 ..{.........// i │ │ │ -00053e20: 6620 7765 2068 6176 6520 616c 6c20 7069 f we have all pi │ │ │ -00053e30: 6563 6573 2062 656c 6f6e 6769 6e67 2074 eces belonging t │ │ │ -00053e40: 6f20 7468 6973 2065 7874 656e 742c 2072 o this extent, r │ │ │ -00053e50: 656d 6f76 6520 6974 0a09 0909 0909 0909 emove it........ │ │ │ -00053e60: 0969 6620 2874 6f5f 6572 6173 6520 213d .if (to_erase != │ │ │ -00053e70: 202d 3129 206d 5f72 6563 656e 745f 6578 -1) m_recent_ex │ │ │ -00053e80: 7465 6e74 732e 6572 6173 6528 6d5f 7265 tents.erase(m_re │ │ │ -00053e90: 6365 6e74 5f65 7874 656e 7473 2e62 6567 cent_extents.beg │ │ │ -00053ea0: 696e 2829 202b 2074 6f5f 6572 6173 6529 in() + to_erase) │ │ │ -00053eb0: 3b0a 0909 0909 0909 0909 7265 7475 726e ;.........return │ │ │ -00053ec0: 2072 6574 3b0a 0909 0909 0909 097d 0a09 ret;........}.. │ │ │ -00053ed0: 0909 0909 097d 0a09 0909 0909 092f 2f20 .....}.......// │ │ │ -00053ee0: 6966 2077 6520 6861 7665 2061 6c6c 2070 if we have all p │ │ │ -00053ef0: 6965 6365 7320 6265 6c6f 6e67 696e 6720 ieces belonging │ │ │ -00053f00: 746f 2074 6869 7320 6578 7465 6e74 2c20 to this extent, │ │ │ -00053f10: 7265 6d6f 7665 2069 740a 0909 0909 0909 remove it....... │ │ │ -00053f20: 6966 2028 6861 7665 5f61 6c6c 2920 746f if (have_all) to │ │ │ -00053f30: 5f65 7261 7365 203d 2069 6478 3b0a 0909 _erase = idx;... │ │ │ -00053f40: 0909 097d 0a09 0909 0909 6966 2028 746f ...}......if (to │ │ │ -00053f50: 5f65 7261 7365 2021 3d20 2d31 2920 6d5f _erase != -1) m_ │ │ │ -00053f60: 7265 6365 6e74 5f65 7874 656e 7473 2e65 recent_extents.e │ │ │ -00053f70: 7261 7365 286d 5f72 6563 656e 745f 6578 rase(m_recent_ex │ │ │ -00053f80: 7465 6e74 732e 6265 6769 6e28 2920 2b20 tents.begin() + │ │ │ -00053f90: 746f 5f65 7261 7365 293b 0a3c 2f70 7265 to_erase);.
    rele │ │ │ -00053fd0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/pie │ │ │ -00054010: 6365 5f70 6963 6b65 722e 6370 703a 3235 ce_picker.cpp:25 │ │ │ -00054020: 3833 3c2f 613e 3c2f 7464 3e3c 7464 3e77 83w │ │ │ -00054030: 6865 6e20 6578 7061 6e64 696e 6720 7069 hen expanding pi │ │ │ -00054040: 6563 6573 2066 6f72 2063 6163 6865 2073 eces for cache s │ │ │ -00054050: 7472 6970 6520 7265 6173 6f6e 732c 2074 tripe reasons, t │ │ │ -00054060: 6865 2021 646f 776e 6c6f 6164 696e 6720 he !downloading │ │ │ -00054070: 636f 6e64 6974 696f 6e20 646f 6573 6e27 condition doesn' │ │ │ -00054080: 7420 6d61 6b65 206d 7563 6820 7365 6e73 t make much sens │ │ │ -00054090: 653c 2f74 643e 3c2f 7472 3e3c 7472 2069 e

    w │ │ │ -000540e0: 6865 6e20 6578 7061 6e64 696e 6720 7069 hen expanding pi │ │ │ -000540f0: 6563 6573 2066 6f72 2063 6163 6865 2073 eces for cache s │ │ │ -00054100: 7472 6970 6520 7265 6173 6f6e 732c 0a74 tripe reasons,.t │ │ │ -00054110: 6865 2021 646f 776e 6c6f 6164 696e 6720 he !downloading │ │ │ -00054120: 636f 6e64 6974 696f 6e20 646f 6573 6e27 condition doesn' │ │ │ -00054130: 7420 6d61 6b65 206d 7563 6820 7365 6e73 t make much sens │ │ │ -00054140: 653c 2f68 323e 3c68 343e 2e2e 2f73 7263 e

    ../src │ │ │ -00054150: 2f70 6965 6365 5f70 6963 6b65 722e 6370 /piece_picker.cp │ │ │ -00054160: 703a 3235 3833 3c2f 6834 3e3c 7072 6520 p:2583

    ..TORRENT_A
    │ │ │ -000541b0: 5353 4552 5428 696e 6465 7820 266c 743b  SSERT(index <
    │ │ │ -000541c0: 206d 5f70 6965 6365 5f6d 6170 2e65 6e64   m_piece_map.end
    │ │ │ -000541d0: 5f69 6e64 6578 2829 293b 0a09 0969 6620  _index());...if 
    │ │ │ -000541e0: 286e 6578 7428 696e 6465 7829 203d 3d20  (next(index) == 
    │ │ │ -000541f0: 6d5f 7069 6563 655f 6d61 702e 656e 645f  m_piece_map.end_
    │ │ │ -00054200: 696e 6465 7828 2929 0a09 0909 7265 7475  index())....retu
    │ │ │ -00054210: 726e 206d 5f62 6c6f 636b 735f 696e 5f6c  rn m_blocks_in_l
    │ │ │ -00054220: 6173 745f 7069 6563 653b 0a09 0965 6c73  ast_piece;...els
    │ │ │ -00054230: 650a 0909 0972 6574 7572 6e20 626c 6f63  e....return bloc
    │ │ │ -00054240: 6b73 5f70 6572 5f70 6965 6365 2829 3b0a  ks_per_piece();.
    │ │ │ -00054250: 097d 0a0a 0962 6f6f 6c20 7069 6563 655f  .}...bool piece_
    │ │ │ -00054260: 7069 636b 6572 3a3a 6973 5f70 6965 6365  picker::is_piece
    │ │ │ -00054270: 5f66 7265 6528 7069 6563 655f 696e 6465  _free(piece_inde
    │ │ │ -00054280: 785f 7420 636f 6e73 7420 7069 6563 650a  x_t const piece.
    │ │ │ -00054290: 0909 2c20 7479 7065 645f 6269 7466 6965  .., typed_bitfie
    │ │ │ -000542a0: 6c64 266c 743b 7069 6563 655f 696e 6465  ld<piece_inde
    │ │ │ -000542b0: 785f 7426 6774 3b20 636f 6e73 7426 616d  x_t> const&am
    │ │ │ -000542c0: 703b 2062 6974 6d61 736b 2920 636f 6e73  p; bitmask) cons
    │ │ │ -000542d0: 740a 097b 0a09 0972 6574 7572 6e20 6269  t..{...return bi
    │ │ │ -000542e0: 746d 6173 6b5b 7069 6563 655d 0a09 0909  tmask[piece]....
    │ │ │ -000542f0: 2661 6d70 3b26 616d 703b 2021 6d5f 7069  && !m_pi
    │ │ │ -00054300: 6563 655f 6d61 705b 7069 6563 655d 2e68  ece_map[piece].h
    │ │ │ -00054310: 6176 6528 290a 0909 0926 616d 703b 2661  ave()....&&a
    │ │ │ -00054320: 6d70 3b20 216d 5f70 6965 6365 5f6d 6170  mp; !m_piece_map
    │ │ │ -00054330: 5b70 6965 6365 5d2e 6669 6c74 6572 6564  [piece].filtered
    │ │ │ -00054340: 2829 3b0a 097d 0a0a 0962 6f6f 6c20 7069  ();..}...bool pi
    │ │ │ -00054350: 6563 655f 7069 636b 6572 3a3a 6361 6e5f  ece_picker::can_
    │ │ │ -00054360: 7069 636b 2870 6965 6365 5f69 6e64 6578  pick(piece_index
    │ │ │ -00054370: 5f74 2063 6f6e 7374 2070 6965 6365 0a09  _t const piece..
    │ │ │ -00054380: 092c 2074 7970 6564 5f62 6974 6669 656c  ., typed_bitfiel
    │ │ │ -00054390: 6426 6c74 3b70 6965 6365 5f69 6e64 6578  d<piece_index
    │ │ │ -000543a0: 5f74 2667 743b 2063 6f6e 7374 2661 6d70  _t> const&
    │ │ │ -000543b0: 3b20 6269 746d 6173 6b29 2063 6f6e 7374  ; bitmask) const
    │ │ │ -000543c0: 0a09 7b0a 0909 7265 7475 726e 2062 6974  ..{...return bit
    │ │ │ -000543d0: 6d61 736b 5b70 6965 6365 5d0a 0909 0926  mask[piece]....&
    │ │ │ -000543e0: 616d 703b 2661 6d70 3b20 216d 5f70 6965  amp;& !m_pie
    │ │ │ -000543f0: 6365 5f6d 6170 5b70 6965 6365 5d2e 6861  ce_map[piece].ha
    │ │ │ -00054400: 7665 2829 0a3c 6469 7620 7374 796c 653d  ve().
    ...&& │ │ │ -00054440: 2021 6d5f 7069 6563 655f 6d61 705b 7069 !m_piece_map[pi │ │ │ -00054450: 6563 655d 2e64 6f77 6e6c 6f61 6469 6e67 ece].downloading │ │ │ -00054460: 2829 0a3c 2f64 6976 3e09 0909 2661 6d70 ().
    ...& │ │ │ -00054470: 3b26 616d 703b 2021 6d5f 7069 6563 655f ;& !m_piece_ │ │ │ -00054480: 6d61 705b 7069 6563 655d 2e66 696c 7465 map[piece].filte │ │ │ -00054490: 7265 6428 293b 0a09 7d0a 0a23 6966 2054 red();..}..#if T │ │ │ -000544a0: 4f52 5245 4e54 5f55 5345 5f49 4e56 4152 ORRENT_USE_INVAR │ │ │ -000544b0: 4941 4e54 5f43 4845 434b 530a 0976 6f69 IANT_CHECKS..voi │ │ │ -000544c0: 6420 7069 6563 655f 7069 636b 6572 3a3a d piece_picker:: │ │ │ -000544d0: 6368 6563 6b5f 7065 6572 7328 290a 097b check_peers()..{ │ │ │ -000544e0: 0a09 0966 6f72 2028 6175 746f 2063 6f6e ...for (auto con │ │ │ -000544f0: 7374 2661 6d70 3b20 6220 3a20 6d5f 626c st& b : m_bl │ │ │ -00054500: 6f63 6b5f 696e 666f 290a 0909 7b0a 0909 ock_info)...{... │ │ │ -00054510: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -00054520: 622e 7065 6572 203d 3d20 6e75 6c6c 7074 b.peer == nullpt │ │ │ -00054530: 7220 7c7c 2073 7461 7469 635f 6361 7374 r || static_cast │ │ │ -00054540: 266c 743b 746f 7272 656e 745f 7065 6572 <torrent_peer │ │ │ -00054550: 2a26 6774 3b28 622e 7065 6572 292d 2667 *>(b.peer)-&g │ │ │ -00054560: 743b 696e 5f75 7365 293b 0a09 097d 0a09 t;in_use);...}.. │ │ │ -00054570: 7d0a 2365 6e64 6966 0a0a 0976 6f69 6420 }.#endif...void │ │ │ -00054580: 7069 6563 655f 7069 636b 6572 3a3a 636c piece_picker::cl │ │ │ -00054590: 6561 725f 7065 6572 2874 6f72 7265 6e74 ear_peer(torrent │ │ │ -000545a0: 5f70 6565 722a 2070 6565 7229 0a09 7b0a _peer* peer)..{. │ │ │ -000545b0: 0909 666f 7220 2861 7574 6f26 616d 703b ..for (auto& │ │ │ -000545c0: 2062 203a 206d 5f62 6c6f 636b 5f69 6e66 b : m_block_inf │ │ │ -000545d0: 6f29 0a09 097b 0a09 0909 6966 2028 622e o)...{....if (b. │ │ │ -000545e0: 7065 6572 203d 3d20 7065 6572 2920 622e peer == peer) b. │ │ │ -000545f0: 7065 6572 203d 206e 756c 6c70 7472 3b0a peer = nullptr;. │ │ │ -00054600: 0909 7d0a 097d 0a0a 092f 2f20 7468 6520 ..}..}...// the │ │ │ -00054610: 6669 7273 7420 626f 6f6c 2069 7320 7472 first bool is tr │ │ │ -00054620: 7565 2069 6620 7468 6973 2069 7320 7468 ue if this is th │ │ │ -00054630: 6520 6f6e 6c79 2070 6565 7220 7468 6174 e only peer that │ │ │ -00054640: 2068 6173 2072 6571 7565 7374 6564 2061 has requested a │ │ │ -00054650: 6e64 2064 6f77 6e6c 6f61 6465 640a 092f nd downloaded../ │ │ │ -00054660: 2f20 626c 6f63 6b73 2066 726f 6d20 7468 / blocks from th │ │ │ -00054670: 6973 2070 6965 6365 2e0a 092f 2f20 7468 is piece...// th │ │ │ -00054680: 6520 7365 636f 6e64 2062 6f6f 6c20 6973 e second bool is │ │ │ -00054690: 2074 7275 6520 6966 2074 6869 7320 6973 true if this is │ │ │ -000546a0: 2074 6865 206f 6e6c 7920 6163 7469 7665 the only active │ │ │ -000546b0: 2070 6565 7220 7468 6174 2069 7320 7265 peer that is re │ │ │ -000546c0: 7175 6573 7469 6e67 0a09 2f2f 2061 6e64 questing..// and │ │ │ -000546d0: 2064 6f77 6e6c 6f61 6469 6e67 2062 6c6f downloading blo │ │ │ -000546e0: 636b 7320 6672 6f6d 2074 6869 7320 7069 cks from this pi │ │ │ -000546f0: 6563 652e 2041 6374 6976 6520 6d65 616e ece. Active mean │ │ │ -00054700: 7320 6861 7669 6e67 2061 2063 6f6e 6e65 s having a conne │ │ │ -00054710: 6374 696f 6e2e 0a3c 2f70 7265 3e3c 2f74 ction..
    relevanc │ │ │ -00054750: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/piece_p │ │ │ -00054790: 6963 6b65 722e 6370 703a 3331 3631 3c2f icker.cpp:3161shoul │ │ │ -000547b0: 6420 3520 6265 2063 6f6e 6669 6775 7261 d 5 be configura │ │ │ -000547c0: 626c 653f 3c2f 7464 3e3c 2f74 723e 3c74 ble?should 5 be co │ │ │ -00054820: 6e66 6967 7572 6162 6c65 3f3c 2f68 323e nfigurable?

    │ │ │ -00054830: 3c68 343e 2e2e 2f73 7263 2f70 6965 6365

    ../src/piece │ │ │ -00054840: 5f70 6963 6b65 722e 6370 703a 3331 3631 _picker.cpp:3161 │ │ │ -00054850: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00054890: 0962 6f6f 6c20 6861 7665 5f61 6c6c 203d  .bool have_all =
    │ │ │ -000548a0: 2074 7275 653b 0a0a 0909 666f 7220 2861   true;....for (a
    │ │ │ -000548b0: 7574 6f20 636f 6e73 7420 7069 6563 6520  uto const piece 
    │ │ │ -000548c0: 3a20 6578 7465 6e74 5f66 6f72 2874 6869  : extent_for(thi
    │ │ │ -000548d0: 735f 6578 7465 6e74 2929 0a09 097b 0a09  s_extent))...{..
    │ │ │ -000548e0: 0909 6966 2028 7069 6563 6520 3d3d 2070  ..if (piece == p
    │ │ │ -000548f0: 2920 636f 6e74 696e 7565 3b0a 0a09 0909  ) continue;.....
    │ │ │ -00054900: 6966 2028 216d 5f70 6965 6365 5f6d 6170  if (!m_piece_map
    │ │ │ -00054910: 5b70 6965 6365 5d2e 6861 7665 2829 2920  [piece].have()) 
    │ │ │ -00054920: 6861 7665 5f61 6c6c 203d 2066 616c 7365  have_all = false
    │ │ │ -00054930: 3b0a 0a09 0909 2f2f 2069 6620 6174 206c  ;.....// if at l
    │ │ │ -00054940: 6561 7374 206f 6e65 2070 6965 6365 2069  east one piece i
    │ │ │ -00054950: 6e20 7468 6973 2065 7874 656e 7420 6861  n this extent ha
    │ │ │ -00054960: 7320 6120 6469 6666 6572 656e 7420 7072  s a different pr
    │ │ │ -00054970: 696f 7269 7479 2074 6861 6e0a 0909 092f  iority than..../
    │ │ │ -00054980: 2f20 7468 6520 6f6e 6520 7765 206a 7573  / the one we jus
    │ │ │ -00054990: 7420 7374 6172 7465 6420 646f 776e 6c6f  t started downlo
    │ │ │ -000549a0: 6164 696e 672c 2064 6f6e 2774 2063 7265  ading, don't cre
    │ │ │ -000549b0: 6174 6520 616e 2061 6666 696e 6974 7920  ate an affinity 
    │ │ │ -000549c0: 666f 720a 0909 092f 2f20 6164 6a61 6365  for....// adjace
    │ │ │ -000549d0: 6e74 2070 6965 6365 732e 2054 6869 7320  nt pieces. This 
    │ │ │ -000549e0: 7072 6f62 6162 6c79 206d 6561 6e73 2074  probably means t
    │ │ │ -000549f0: 6865 2070 6965 6365 7320 6265 6c6f 6e67  he pieces belong
    │ │ │ -00054a00: 2074 6f20 6469 6666 6572 656e 740a 0909   to different...
    │ │ │ -00054a10: 092f 2f20 6669 6c65 732c 206f 7220 7468  .// files, or th
    │ │ │ -00054a20: 6174 2073 6f6d 6520 6f74 6865 7220 6d65  at some other me
    │ │ │ -00054a30: 6368 616e 6973 6d20 6465 7465 726d 696e  chanism determin
    │ │ │ -00054a40: 696e 6720 7468 6520 7072 696f 7269 7479  ing the priority
    │ │ │ -00054a50: 2073 686f 756c 640a 0909 092f 2f20 7461   should....// ta
    │ │ │ -00054a60: 6b65 2070 7265 6365 6465 6e63 652e 0a09  ke precedence...
    │ │ │ -00054a70: 0909 6966 2028 7069 6563 655f 7072 696f  ..if (piece_prio
    │ │ │ -00054a80: 7269 7479 2870 6965 6365 2920 213d 2074  rity(piece) != t
    │ │ │ -00054a90: 6869 735f 7072 696f 2920 7265 7475 726e  his_prio) return
    │ │ │ -00054aa0: 3b0a 0909 7d0a 0a09 092f 2f20 6966 2077  ;...}....// if w
    │ │ │ -00054ab0: 6520 616c 7265 6164 7920 6861 7665 2061  e already have a
    │ │ │ -00054ac0: 6c6c 2074 6865 202a 6f74 6865 722a 2070  ll the *other* p
    │ │ │ -00054ad0: 6965 6365 7320 696e 2074 6869 7320 6578  ieces in this ex
    │ │ │ -00054ae0: 7465 6e74 2c20 7468 6572 6527 7320 6e6f  tent, there's no
    │ │ │ -00054af0: 0a09 092f 2f20 6e65 6564 2074 6f20 696e  ...// need to in
    │ │ │ -00054b00: 666c 6174 6520 7468 6569 7220 7072 696f  flate their prio
    │ │ │ -00054b10: 7269 7469 6573 0a09 0969 6620 2868 6176  rities...if (hav
    │ │ │ -00054b20: 655f 616c 6c29 2072 6574 7572 6e3b 0a0a  e_all) return;..
    │ │ │ -00054b30: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ -00054b60: 6966 2028 6d5f 7265 6365 6e74 5f65 7874 if (m_recent_ext │ │ │ -00054b70: 656e 7473 2e73 697a 6528 2920 266c 743b ents.size() < │ │ │ -00054b80: 2035 290a 3c2f 6469 763e 0909 096d 5f72 5).
    ...m_r │ │ │ -00054b90: 6563 656e 745f 6578 7465 6e74 732e 7075 ecent_extents.pu │ │ │ -00054ba0: 7368 5f62 6163 6b28 7468 6973 5f65 7874 sh_back(this_ext │ │ │ -00054bb0: 656e 7429 3b0a 0a09 092f 2f20 6c69 6d69 ent);....// limi │ │ │ -00054bc0: 7420 7468 6520 6e75 6d62 6572 206f 6620 t the number of │ │ │ -00054bd0: 6578 7465 6e74 2061 6666 696e 6974 6965 extent affinitie │ │ │ -00054be0: 7320 6163 7469 7665 2061 7420 616e 7920 s active at any │ │ │ -00054bf0: 6769 7665 6e20 7469 6d65 2074 6f20 6c69 given time to li │ │ │ -00054c00: 6d69 740a 0909 2f2f 2074 6865 2063 6f73 mit...// the cos │ │ │ -00054c10: 7420 6f66 2063 6865 636b 696e 6720 7468 t of checking th │ │ │ -00054c20: 656d 2e20 416c 736f 2c20 646f 6e27 7420 em. Also, don't │ │ │ -00054c30: 7265 706c 6163 6520 7468 656d 2c20 636f replace them, co │ │ │ -00054c40: 6d6d 6974 2074 6f0a 0909 2f2f 2066 696e mmit to...// fin │ │ │ -00054c50: 6973 6869 6e67 2074 6865 6d20 6265 666f ishing them befo │ │ │ -00054c60: 7265 2073 7461 7274 696e 6720 616e 6f74 re starting anot │ │ │ -00054c70: 6865 7220 6578 7465 6e74 2e20 5468 6973 her extent. This │ │ │ -00054c80: 2069 7320 616e 616c 6f67 6f75 7320 746f is analogous to │ │ │ -00054c90: 0a09 092f 2f20 6c69 6d69 7469 6e67 2074 ...// limiting t │ │ │ -00054ca0: 6865 206e 756d 6265 7220 6f66 2070 6172 he number of par │ │ │ -00054cb0: 7469 616c 2070 6965 6365 732e 0a09 7d0a tial pieces...}. │ │ │ -00054cc0: 0a09 2f2f 206f 7074 696f 6e73 206d 6179 ..// options may │ │ │ -00054cd0: 2062 6520 3020 6f72 2070 6965 6365 5f70 be 0 or piece_p │ │ │ -00054ce0: 6963 6b65 723a 3a72 6576 6572 7365 0a09 icker::reverse.. │ │ │ -00054cf0: 2f2f 2072 6574 7572 6e73 2066 616c 7365 // returns false │ │ │ -00054d00: 2069 6620 7468 6520 626c 6f63 6b20 636f if the block co │ │ │ -00054d10: 756c 6420 6e6f 7420 6265 206d 6172 6b65 uld not be marke │ │ │ -00054d20: 6420 6173 2064 6f77 6e6c 6f61 6469 6e67 d as downloading │ │ │ -00054d30: 0a09 626f 6f6c 2070 6965 6365 5f70 6963 ..bool piece_pic │ │ │ -00054d40: 6b65 723a 3a6d 6172 6b5f 6173 5f64 6f77 ker::mark_as_dow │ │ │ -00054d50: 6e6c 6f61 6469 6e67 2870 6965 6365 5f62 nloading(piece_b │ │ │ -00054d60: 6c6f 636b 2063 6f6e 7374 2062 6c6f 636b lock const block │ │ │ -00054d70: 0a09 092c 2074 6f72 7265 6e74 5f70 6565 ..., torrent_pee │ │ │ -00054d80: 722a 2070 6565 722c 2070 6963 6b65 725f r* peer, picker_ │ │ │ -00054d90: 6f70 7469 6f6e 735f 7420 636f 6e73 7420 options_t const │ │ │ -00054da0: 6f70 7469 6f6e 7329 0a09 7b0a 2369 6664 options)..{.#ifd │ │ │ -00054db0: 6566 2054 4f52 5245 4e54 5f50 4943 4b45 ef TORRENT_PICKE │ │ │ -00054dc0: 525f 4c4f 470a 0909 7374 643a 3a63 6572 R_LOG...std::cer │ │ │ -00054dd0: 7220 266c 743b 266c 743b 2022 5b22 2026 r << "[" & │ │ │ -00054de0: 6c74 3b26 6c74 3b20 7468 6973 2026 6c74 lt;< this < │ │ │ -00054df0: 3b26 6c74 3b20 225d 2022 2026 6c74 3b26 ;< "] " <& │ │ │ -00054e00: 6c74 3b20 226d 6172 6b5f 6173 5f64 6f77 lt; "mark_as_dow │ │ │ -00054e10: 6e6c 6f61 6469 6e67 2820 7b22 0a09 0909 nloading( {".... │ │ │ -00054e20: 266c 743b 266c 743b 2062 6c6f 636b 2e70 << block.p │ │ │ -00054e30: 6965 6365 5f69 6e64 6578 2026 6c74 3b26 iece_index <& │ │ │ -00054e40: 6c74 3b20 222c 2022 2026 6c74 3b26 6c74 lt; ", " << │ │ │ -00054e50: 3b20 626c 6f63 6b2e 626c 6f63 6b5f 696e ; block.block_in │ │ │ -00054e60: 6465 7820 266c 743b 266c 743b 2022 7d20 dex << "} │ │ │ -00054e70: 2922 2026 6c74 3b26 6c74 3b20 7374 643a )" << std: │ │ │ -00054e80: 3a65 6e64 6c3b 0a23 656e 6469 660a 0a09 :endl;.#endif... │ │ │ -00054e90: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -00054ea0: 7065 6572 203d 3d20 6e75 6c6c 7074 7220 peer == nullptr │ │ │ -00054eb0: 7c7c 2070 6565 722d 2667 743b 696e 5f75 || peer->in_u │ │ │ -00054ec0: 7365 293b 0a09 0954 4f52 5245 4e54 5f41 se);...TORRENT_A │ │ │ -00054ed0: 5353 4552 5428 626c 6f63 6b2e 626c 6f63 SSERT(block.bloc │ │ │ -00054ee0: 6b5f 696e 6465 7820 213d 2070 6965 6365 k_index != piece │ │ │ -00054ef0: 5f62 6c6f 636b 3a3a 696e 7661 6c69 642e _block::invalid. │ │ │ -00054f00: 626c 6f63 6b5f 696e 6465 7829 3b0a 0909 block_index);... │ │ │ -00054f10: 544f 5252 454e 545f 4153 5345 5254 2862 TORRENT_ASSERT(b │ │ │ -00054f20: 6c6f 636b 2e70 6965 6365 5f69 6e64 6578 lock.piece_index │ │ │ -00054f30: 2021 3d20 7069 6563 655f 626c 6f63 6b3a != piece_block: │ │ │ -00054f40: 3a69 6e76 616c 6964 2e70 6965 6365 5f69 :invalid.piece_i │ │ │ -00054f50: 6e64 6578 293b 0a09 0954 4f52 5245 4e54 ndex);...TORRENT │ │ │ -00054f60: 5f41 5353 4552 5428 626c 6f63 6b2e 7069 _ASSERT(block.pi │ │ │ -00054f70: 6563 655f 696e 6465 7820 266c 743b 206d ece_index < m │ │ │ -00054f80: 5f70 6965 6365 5f6d 6170 2e65 6e64 5f69 _piece_map.end_i │ │ │ -00054f90: 6e64 6578 2829 293b 0a09 0954 4f52 5245 ndex());...TORRE │ │ │ -00054fa0: 4e54 5f41 5353 4552 5428 626c 6f63 6b2e NT_ASSERT(block. │ │ │ -00054fb0: 626c 6f63 6b5f 696e 6465 7820 266c 743b block_index < │ │ │ -00054fc0: 2062 6c6f 636b 735f 696e 5f70 6965 6365 blocks_in_piece │ │ │ -00054fd0: 2862 6c6f 636b 2e70 6965 6365 5f69 6e64 (block.piece_ind │ │ │ -00054fe0: 6578 2929 3b0a 0909 544f 5252 454e 545f ex));...TORRENT_ │ │ │ -00054ff0: 4153 5345 5254 2821 6d5f 7069 6563 655f ASSERT(!m_piece_ │ │ │ -00055000: 6d61 705b 626c 6f63 6b2e 7069 6563 655f map[block.piece_ │ │ │ -00055010: 696e 6465 785d 2e68 6176 6528 2929 3b0a index].have());. │ │ │ -00055020: 0a09 0970 6965 6365 5f70 6f73 2661 6d70 ...piece_pos& │ │ │ -00055030: 3b20 7020 3d20 6d5f 7069 6563 655f 6d61 ; p = m_piece_ma │ │ │ -00055040: 705b 626c 6f63 6b2e 7069 6563 655f 696e p[block.piece_in │ │ │ -00055050: 6465 785d 3b0a 0909 6966 2028 702e 646f dex];...if (p.do │ │ │ -00055060: 776e 6c6f 6164 5f71 7565 7565 2829 203d wnload_queue() = │ │ │ -00055070: 3d20 7069 6563 655f 706f 733a 3a70 6965 = piece_pos::pie │ │ │ -00055080: 6365 5f6f 7065 6e29 0a09 097b 0a23 6966 ce_open)...{.#if │ │ │ -00055090: 6465 6620 544f 5252 454e 545f 4558 5045 def TORRENT_EXPE │ │ │ -000550a0: 4e53 4956 455f 494e 5641 5249 414e 545f NSIVE_INVARIANT_ │ │ │ -000550b0: 4348 4543 4b53 0a09 0909 494e 5641 5249 CHECKS....INVARI │ │ │ -000550c0: 414e 545f 4348 4543 4b3b 0a3c 2f70 7265 ANT_CHECK;.
    rele │ │ │ -00055100: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0
    ../src/per │ │ │ -00055140: 666f 726d 616e 6365 5f63 6f75 6e74 6572 formance_counter │ │ │ -00055150: 732e 6370 703a 3430 3c2f 613e 3c2f 7464 s.cpp:40move stats_ │ │ │ -00055170: 636f 756e 7465 725f 7420 6f75 7420 6f66 counter_t out of │ │ │ -00055180: 2063 6f75 6e74 6572 733c 2f74 643e 3c2f counters

    move stat │ │ │ -000551e0: 735f 636f 756e 7465 725f 7420 6f75 7420 s_counter_t out │ │ │ -000551f0: 6f66 2063 6f75 6e74 6572 733c 2f68 323e of counters

    │ │ │ -00055200: 3c68 343e 2e2e 2f73 7263 2f70 6572 666f

    ../src/perfo │ │ │ -00055210: 726d 616e 6365 5f63 6f75 6e74 6572 732e rmance_counters. │ │ │ -00055220: 6370 703a 3430 3c2f 6834 3e3c 7072 6520 cpp:40

    
    │ │ │ -00055270: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22  relevance&
    │ │ │ -000552a0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c  nbsp;0<
    │ │ │ -000552b0: 6120 6872 6566 3d22 6a61 7661 7363 7269  a href="javascri
    │ │ │ -000552c0: 7074 3a65 7870 616e 6428 3230 3029 223e  pt:expand(200)">
    │ │ │ -000552d0: 2e2e 2f73 7263 2f70 6572 666f 726d 616e  ../src/performan
    │ │ │ -000552e0: 6365 5f63 6f75 6e74 6572 732e 6370 703a  ce_counters.cpp:
    │ │ │ -000552f0: 3431 3c2f 613e 3c2f 7464 3e3c 7464 3e73  41s
    │ │ │ -00055300: 686f 756c 6420 6269 7474 6f72 7265 6e74  hould bittorrent
    │ │ │ -00055310: 206b 6565 702d 616c 6976 6520 6d65 7373   keep-alive mess
    │ │ │ -00055320: 6167 6573 2068 6176 6520 6120 636f 756e  ages have a coun
    │ │ │ -00055330: 7465 7220 746f 6f3f 3c2f 7464 3e3c 2f74  ter too?

    should bit │ │ │ -00055390: 746f 7272 656e 7420 6b65 6570 2d61 6c69 torrent keep-ali │ │ │ -000553a0: 7665 206d 6573 7361 6765 7320 6861 7665 ve messages have │ │ │ -000553b0: 2061 2063 6f75 6e74 6572 2074 6f6f 3f3c a counter too?< │ │ │ -000553c0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ -000553d0: 6572 666f 726d 616e 6365 5f63 6f75 6e74 erformance_count │ │ │ -000553e0: 6572 732e 6370 703a 3431 3c2f 6834 3e3c ers.cpp:41

    < │ │ │ -000553f0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00055400: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00055410: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00055420: 7820 2364 6464 3b22 3e3c 2f70 7265 3e3c x #ddd;">
    < │ │ │ -00055430: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00055460: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00055470: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/perfo │ │ │ -000554a0: 726d 616e 6365 5f63 6f75 6e74 6572 732e rmance_counters. │ │ │ -000554b0: 6370 703a 3432 3c2f 613e 3c2f 7464 3e3c cpp:42< │ │ │ -000554c0: 7464 3e49 7420 776f 756c 6420 6265 206e td>It would be n │ │ │ -000554d0: 6963 6520 6966 2074 6869 7320 636f 756c ice if this coul │ │ │ -000554e0: 6420 6265 2061 6e20 696e 7465 726e 616c d be an internal │ │ │ -000554f0: 2074 7970 652e 2064 6566 6175 6c74 5f64 type. default_d │ │ │ -00055500: 6973 6b5f 636f 6e73 7472 7563 746f 7220 isk_constructor │ │ │ -00055510: 6465 7065 6e64 7320 6f6e 2069 7420 6e6f depends on it no │ │ │ -00055520: 773c 2f74 643e 3c2f 7472 3e3c 7472 2069 w

    I │ │ │ -00055570: 7420 776f 756c 6420 6265 206e 6963 6520 t would be nice │ │ │ -00055580: 6966 2074 6869 7320 636f 756c 6420 6265 if this could be │ │ │ -00055590: 2061 6e20 696e 7465 726e 616c 2074 7970 an internal typ │ │ │ -000555a0: 652e 2064 6566 6175 6c74 5f64 6973 6b5f e. default_disk_ │ │ │ -000555b0: 636f 6e73 7472 7563 746f 7220 6465 7065 constructor depe │ │ │ -000555c0: 6e64 7320 6f6e 2069 7420 6e6f 773c 2f68 nds on it now

    ../src/per │ │ │ -000555e0: 666f 726d 616e 6365 5f63 6f75 6e74 6572 formance_counter │ │ │ -000555f0: 732e 6370 703a 3432 3c2f 6834 3e3c 7072 s.cpp:42

    THIS SOFT │ │ │ -00055640: 5741 5245 2049 5320 5052 4f56 4944 4544 WARE IS PROVIDED │ │ │ -00055650: 2042 5920 5448 4520 434f 5059 5249 4748 BY THE COPYRIGH │ │ │ -00055660: 5420 484f 4c44 4552 5320 414e 4420 434f T HOLDERS AND CO │ │ │ -00055670: 4e54 5249 4255 544f 5253 2022 4153 2049 NTRIBUTORS "AS I │ │ │ -00055680: 5322 0a41 4e44 2041 4e59 2045 5850 5245 S".AND ANY EXPRE │ │ │ -00055690: 5353 204f 5220 494d 504c 4945 4420 5741 SS OR IMPLIED WA │ │ │ -000556a0: 5252 414e 5449 4553 2c20 494e 434c 5544 RRANTIES, INCLUD │ │ │ -000556b0: 494e 472c 2042 5554 204e 4f54 204c 494d ING, BUT NOT LIM │ │ │ -000556c0: 4954 4544 2054 4f2c 2054 4845 0a49 4d50 ITED TO, THE.IMP │ │ │ -000556d0: 4c49 4544 2057 4152 5241 4e54 4945 5320 LIED WARRANTIES │ │ │ -000556e0: 4f46 204d 4552 4348 414e 5441 4249 4c49 OF MERCHANTABILI │ │ │ -000556f0: 5459 2041 4e44 2046 4954 4e45 5353 2046 TY AND FITNESS F │ │ │ -00055700: 4f52 2041 2050 4152 5449 4355 4c41 5220 OR A PARTICULAR │ │ │ -00055710: 5055 5250 4f53 450a 4152 4520 4449 5343 PURPOSE.ARE DISC │ │ │ -00055720: 4c41 494d 4544 2e20 494e 204e 4f20 4556 LAIMED. IN NO EV │ │ │ -00055730: 454e 5420 5348 414c 4c20 5448 4520 434f ENT SHALL THE CO │ │ │ -00055740: 5059 5249 4748 5420 4f57 4e45 5220 4f52 PYRIGHT OWNER OR │ │ │ -00055750: 2043 4f4e 5452 4942 5554 4f52 5320 4245 CONTRIBUTORS BE │ │ │ -00055760: 0a4c 4941 424c 4520 464f 5220 414e 5920 .LIABLE FOR ANY │ │ │ -00055770: 4449 5245 4354 2c20 494e 4449 5245 4354 DIRECT, INDIRECT │ │ │ -00055780: 2c20 494e 4349 4445 4e54 414c 2c20 5350 , INCIDENTAL, SP │ │ │ -00055790: 4543 4941 4c2c 2045 5845 4d50 4c41 5259 ECIAL, EXEMPLARY │ │ │ -000557a0: 2c20 4f52 0a43 4f4e 5345 5155 454e 5449 , OR.CONSEQUENTI │ │ │ -000557b0: 414c 2044 414d 4147 4553 2028 494e 434c AL DAMAGES (INCL │ │ │ -000557c0: 5544 494e 472c 2042 5554 204e 4f54 204c UDING, BUT NOT L │ │ │ -000557d0: 494d 4954 4544 2054 4f2c 2050 524f 4355 IMITED TO, PROCU │ │ │ -000557e0: 5245 4d45 4e54 204f 460a 5355 4253 5449 REMENT OF.SUBSTI │ │ │ -000557f0: 5455 5445 2047 4f4f 4453 204f 5220 5345 TUTE GOODS OR SE │ │ │ -00055800: 5256 4943 4553 3b20 4c4f 5353 204f 4620 RVICES; LOSS OF │ │ │ -00055810: 5553 452c 2044 4154 412c 204f 5220 5052 USE, DATA, OR PR │ │ │ -00055820: 4f46 4954 533b 204f 5220 4255 5349 4e45 OFITS; OR BUSINE │ │ │ -00055830: 5353 0a49 4e54 4552 5255 5054 494f 4e29 SS.INTERRUPTION) │ │ │ -00055840: 2048 4f57 4556 4552 2043 4155 5345 4420 HOWEVER CAUSED │ │ │ -00055850: 414e 4420 4f4e 2041 4e59 2054 4845 4f52 AND ON ANY THEOR │ │ │ -00055860: 5920 4f46 204c 4941 4249 4c49 5459 2c20 Y OF LIABILITY, │ │ │ -00055870: 5748 4554 4845 5220 494e 0a43 4f4e 5452 WHETHER IN.CONTR │ │ │ -00055880: 4143 542c 2053 5452 4943 5420 4c49 4142 ACT, STRICT LIAB │ │ │ -00055890: 494c 4954 592c 204f 5220 544f 5254 2028 ILITY, OR TORT ( │ │ │ -000558a0: 494e 434c 5544 494e 4720 4e45 474c 4947 INCLUDING NEGLIG │ │ │ -000558b0: 454e 4345 204f 5220 4f54 4845 5257 4953 ENCE OR OTHERWIS │ │ │ -000558c0: 4529 0a41 5249 5349 4e47 2049 4e20 414e E).ARISING IN AN │ │ │ -000558d0: 5920 5741 5920 4f55 5420 4f46 2054 4845 Y WAY OUT OF THE │ │ │ -000558e0: 2055 5345 204f 4620 5448 4953 2053 4f46 USE OF THIS SOF │ │ │ -000558f0: 5457 4152 452c 2045 5645 4e20 4946 2041 TWARE, EVEN IF A │ │ │ -00055900: 4456 4953 4544 204f 4620 5448 450a 504f DVISED OF THE.PO │ │ │ -00055910: 5353 4942 494c 4954 5920 4f46 2053 5543 SSIBILITY OF SUC │ │ │ -00055920: 4820 4441 4d41 4745 2e0a 0a2a 2f0a 0a23 H DAMAGE...*/..# │ │ │ -00055930: 696e 636c 7564 6520 226c 6962 746f 7272 include "libtorr │ │ │ -00055940: 656e 742f 7065 7266 6f72 6d61 6e63 655f ent/performance_ │ │ │ -00055950: 636f 756e 7465 7273 2e68 7070 220a 2369 counters.hpp".#i │ │ │ -00055960: 6e63 6c75 6465 2022 6c69 6274 6f72 7265 nclude "libtorre │ │ │ -00055970: 6e74 2f61 7373 6572 742e 6870 7022 0a23 nt/assert.hpp".# │ │ │ -00055980: 696e 636c 7564 6520 266c 743b 6373 7472 include <cstr │ │ │ -00055990: 696e 6726 6774 3b20 2f2f 2066 6f72 206d ing> // for m │ │ │ -000559a0: 656d 7365 740a 0a6e 616d 6573 7061 6365 emset..namespace │ │ │ -000559b0: 206c 6962 746f 7272 656e 7420 7b0a 0a3c libtorrent {..< │ │ │ -000559c0: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ -000559d0: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ -000559e0: 7769 6474 683d 2231 3030 2522 3e09 636f width="100%">.co │ │ │ -000559f0: 756e 7465 7273 3a3a 636f 756e 7465 7273 unters::counters │ │ │ -00055a00: 2829 2054 4f52 5245 4e54 5f43 4f55 4e54 () TORRENT_COUNT │ │ │ -00055a10: 4552 5f4e 4f45 5843 4550 540a 3c2f 6469 ER_NOEXCEPT..{.#ifdef ATOM │ │ │ -00055a30: 4943 5f4c 4c4f 4e47 5f4c 4f43 4b5f 4652 IC_LLONG_LOCK_FR │ │ │ -00055a40: 4545 0a09 0966 6f72 2028 6175 746f 2661 EE...for (auto&a │ │ │ -00055a50: 6d70 3b20 636f 756e 7465 7220 3a20 6d5f mp; counter : m_ │ │ │ -00055a60: 7374 6174 735f 636f 756e 7465 7229 0a09 stats_counter).. │ │ │ -00055a70: 0909 636f 756e 7465 722e 7374 6f72 6528 ..counter.store( │ │ │ -00055a80: 302c 2073 7464 3a3a 6d65 6d6f 7279 5f6f 0, std::memory_o │ │ │ -00055a90: 7264 6572 5f72 656c 6178 6564 293b 0a23 rder_relaxed);.# │ │ │ -00055aa0: 656c 7365 0a09 096d 5f73 7461 7473 5f63 else...m_stats_c │ │ │ -00055ab0: 6f75 6e74 6572 2e66 696c 6c28 3029 3b0a ounter.fill(0);. │ │ │ -00055ac0: 2365 6e64 6966 0a09 7d0a 0a09 636f 756e #endif..}...coun │ │ │ -00055ad0: 7465 7273 3a3a 636f 756e 7465 7273 2863 ters::counters(c │ │ │ -00055ae0: 6f75 6e74 6572 7320 636f 6e73 7426 616d ounters const&am │ │ │ -00055af0: 703b 2063 2920 544f 5252 454e 545f 434f p; c) TORRENT_CO │ │ │ -00055b00: 554e 5445 525f 4e4f 4558 4345 5054 0a09 UNTER_NOEXCEPT.. │ │ │ -00055b10: 7b0a 2369 6664 6566 2041 544f 4d49 435f {.#ifdef ATOMIC_ │ │ │ -00055b20: 4c4c 4f4e 475f 4c4f 434b 5f46 5245 450a LLONG_LOCK_FREE. │ │ │ -00055b30: 0909 666f 7220 2869 6e74 2069 203d 2030 ..for (int i = 0 │ │ │ -00055b40: 3b20 6920 266c 743b 206d 5f73 7461 7473 ; i < m_stats │ │ │ -00055b50: 5f63 6f75 6e74 6572 2e65 6e64 5f69 6e64 _counter.end_ind │ │ │ -00055b60: 6578 2829 3b20 2b2b 6929 0a09 0909 6d5f ex(); ++i)....m_ │ │ │ -00055b70: 7374 6174 735f 636f 756e 7465 725b 695d stats_counter[i] │ │ │ -00055b80: 2e73 746f 7265 280a 0909 0909 632e 6d5f .store(.....c.m_ │ │ │ -00055b90: 7374 6174 735f 636f 756e 7465 725b 695d stats_counter[i] │ │ │ -00055ba0: 2e6c 6f61 6428 7374 643a 3a6d 656d 6f72 .load(std::memor │ │ │ -00055bb0: 795f 6f72 6465 725f 7265 6c61 7865 6429 y_order_relaxed) │ │ │ -00055bc0: 0a09 0909 0909 2c20 7374 643a 3a6d 656d ......, std::mem │ │ │ -00055bd0: 6f72 795f 6f72 6465 725f 7265 6c61 7865 ory_order_relaxe │ │ │ -00055be0: 6429 3b0a 2365 6c73 650a 0909 7374 643a d);.#else...std: │ │ │ -00055bf0: 3a6c 6f63 6b5f 6775 6172 6426 6c74 3b73 :lock_guard<s │ │ │ -00055c00: 7464 3a3a 6d75 7465 7826 6774 3b20 6c28 td::mutex> l( │ │ │ -00055c10: 632e 6d5f 6d75 7465 7829 3b0a 0909 6d5f c.m_mutex);...m_ │ │ │ -00055c20: 7374 6174 735f 636f 756e 7465 7220 3d20 stats_counter = │ │ │ -00055c30: 632e 6d5f 7374 6174 735f 636f 756e 7465 c.m_stats_counte │ │ │ -00055c40: 723b 0a23 656e 6469 660a 097d 0a0a 0963 r;.#endif..}...c │ │ │ -00055c50: 6f75 6e74 6572 7326 616d 703b 2063 6f75 ounters& cou │ │ │ -00055c60: 6e74 6572 733a 3a6f 7065 7261 746f 723d nters::operator= │ │ │ -00055c70: 2863 6f75 6e74 6572 7320 636f 6e73 7426 (counters const& │ │ │ -00055c80: 616d 703b 2063 2920 2661 6d70 3b20 544f amp; c) & TO │ │ │ -00055c90: 5252 454e 545f 434f 554e 5445 525f 4e4f RRENT_COUNTER_NO │ │ │ -00055ca0: 4558 4345 5054 0a09 7b0a 0909 6966 2028 EXCEPT..{...if ( │ │ │ -00055cb0: 2661 6d70 3b63 203d 3d20 7468 6973 2920 &c == this) │ │ │ -00055cc0: 7265 7475 726e 202a 7468 6973 3b0a 2369 return *this;.#i │ │ │ -00055cd0: 6664 6566 2041 544f 4d49 435f 4c4c 4f4e fdef ATOMIC_LLON │ │ │ -00055ce0: 475f 4c4f 434b 5f46 5245 450a 0909 666f G_LOCK_FREE...fo │ │ │ -00055cf0: 7220 2869 6e74 2069 203d 2030 3b20 6920 r (int i = 0; i │ │ │ -00055d00: 266c 743b 206d 5f73 7461 7473 5f63 6f75 < m_stats_cou │ │ │ -00055d10: 6e74 6572 2e65 6e64 5f69 6e64 6578 2829 nter.end_index() │ │ │ -00055d20: 3b20 2b2b 6929 0a09 0909 6d5f 7374 6174 ; ++i)....m_stat │ │ │ -00055d30: 735f 636f 756e 7465 725b 695d 2e73 746f s_counter[i].sto │ │ │ -00055d40: 7265 280a 0909 0909 632e 6d5f 7374 6174 re(.....c.m_stat │ │ │ -00055d50: 735f 636f 756e 7465 725b 695d 2e6c 6f61 s_counter[i].loa │ │ │ -00055d60: 6428 7374 643a 3a6d 656d 6f72 795f 6f72 d(std::memory_or │ │ │ -00055d70: 6465 725f 7265 6c61 7865 6429 0a09 0909 der_relaxed).... │ │ │ -00055d80: 0909 2c20 7374 643a 3a6d 656d 6f72 795f .., std::memory_ │ │ │ -00055d90: 6f72 6465 725f 7265 6c61 7865 6429 3b0a order_relaxed);. │ │ │ -00055da0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00055db0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00055de0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -00055e10: 632f 7065 6572 5f63 6f6e 6e65 6374 696f c/peer_connectio │ │ │ -00055e20: 6e2e 6370 703a 3131 3038 3c2f 613e 3c2f n.cpp:1108this shou │ │ │ -00055e40: 6c64 2062 6520 7468 6520 676c 6f62 616c ld be the global │ │ │ -00055e50: 2064 6f77 6e6c 6f61 6420 7261 7465 3c2f download rate

    this │ │ │ -00055eb0: 2073 686f 756c 6420 6265 2074 6865 2067 should be the g │ │ │ -00055ec0: 6c6f 6261 6c20 646f 776e 6c6f 6164 2072 lobal download r │ │ │ -00055ed0: 6174 653c 2f68 323e 3c68 343e 2e2e 2f73 ate

    ../s │ │ │ -00055ee0: 7263 2f70 6565 725f 636f 6e6e 6563 7469 rc/peer_connecti │ │ │ -00055ef0: 6f6e 2e63 7070 3a31 3130 383c 2f68 343e on.cpp:1108

    │ │ │ -00055f00: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ...int
    │ │ │ -00055f40: 2072 6174 6520 3d20 303b 0a0a 0909 2f2f   rate = 0;....//
    │ │ │ -00055f50: 2069 6620 7765 2068 6176 656e 2774 2072   if we haven't r
    │ │ │ -00055f60: 6563 6569 7665 6420 616e 7920 6461 7461  eceived any data
    │ │ │ -00055f70: 2072 6563 656e 746c 792c 2074 6865 2063   recently, the c
    │ │ │ -00055f80: 7572 7265 6e74 2064 6f77 6e6c 6f61 6420  urrent download 
    │ │ │ -00055f90: 7261 7465 0a09 092f 2f20 6973 206e 6f74  rate...// is not
    │ │ │ -00055fa0: 2072 6570 7265 7365 6e74 6174 6976 650a   representative.
    │ │ │ -00055fb0: 0909 6966 2028 6175 783a 3a74 696d 655f  ..if (aux::time_
    │ │ │ -00055fc0: 6e6f 7728 2920 2d20 6d5f 6c61 7374 5f70  now() - m_last_p
    │ │ │ -00055fd0: 6965 6365 2e67 6574 286d 5f63 6f6e 6e65  iece.get(m_conne
    │ │ │ -00055fe0: 6374 2920 2667 743b 2073 6563 6f6e 6473  ct) > seconds
    │ │ │ -00055ff0: 2833 3029 2026 616d 703b 2661 6d70 3b20  (30) && 
    │ │ │ -00056000: 6d5f 646f 776e 6c6f 6164 5f72 6174 655f  m_download_rate_
    │ │ │ -00056010: 7065 616b 2026 6774 3b20 3029 0a09 097b  peak > 0)...{
    │ │ │ -00056020: 0a09 0909 7261 7465 203d 206d 5f64 6f77  ....rate = m_dow
    │ │ │ -00056030: 6e6c 6f61 645f 7261 7465 5f70 6561 6b3b  nload_rate_peak;
    │ │ │ -00056040: 0a09 097d 0a09 0965 6c73 6520 6966 2028  ...}...else if (
    │ │ │ -00056050: 6175 783a 3a74 696d 655f 6e6f 7728 2920  aux::time_now() 
    │ │ │ -00056060: 2d20 6d5f 6c61 7374 5f75 6e63 686f 6b65  - m_last_unchoke
    │ │ │ -00056070: 642e 6765 7428 6d5f 636f 6e6e 6563 7429  d.get(m_connect)
    │ │ │ -00056080: 2026 6c74 3b20 7365 636f 6e64 7328 3529   < seconds(5)
    │ │ │ -00056090: 0a09 0909 2661 6d70 3b26 616d 703b 206d  ....&& m
    │ │ │ -000560a0: 5f73 7461 7469 7374 6963 732e 746f 7461  _statistics.tota
    │ │ │ -000560b0: 6c5f 7061 796c 6f61 645f 7570 6c6f 6164  l_payload_upload
    │ │ │ -000560c0: 2829 2026 6c74 3b20 3220 2a20 3078 3430  () < 2 * 0x40
    │ │ │ -000560d0: 3030 290a 0909 7b0a 0909 092f 2f20 6966  00)...{....// if
    │ │ │ -000560e0: 2077 6527 7265 2068 6176 6520 6f6e 6c79   we're have only
    │ │ │ -000560f0: 2062 6565 6e20 756e 6368 6f6b 6564 2066   been unchoked f
    │ │ │ -00056100: 6f72 2061 2073 686f 7274 2070 6572 696f  or a short perio
    │ │ │ -00056110: 6420 6f66 2074 696d 652c 0a09 0909 2f2f  d of time,....//
    │ │ │ -00056120: 2077 6520 646f 6e27 7420 6b6e 6f77 2077   we don't know w
    │ │ │ -00056130: 6861 7420 7261 7465 2077 6520 6361 6e20  hat rate we can 
    │ │ │ -00056140: 6765 7420 6672 6f6d 2074 6869 7320 7065  get from this pe
    │ │ │ -00056150: 6572 2e20 496e 7374 6561 6420 6f66 2061  er. Instead of a
    │ │ │ -00056160: 7373 756d 696e 670a 0909 092f 2f20 7468  ssuming....// th
    │ │ │ -00056170: 6520 6c6f 7765 7374 2070 6f73 7369 626c  e lowest possibl
    │ │ │ -00056180: 6520 7261 7465 2c20 6173 7375 6d65 2074  e rate, assume t
    │ │ │ -00056190: 6865 2061 7665 7261 6765 2e0a 0a09 0909  he average......
    │ │ │ -000561a0: 696e 7420 7065 6572 735f 7769 7468 5f72  int peers_with_r
    │ │ │ -000561b0: 6571 7565 7374 7320 3d20 696e 7428 7374  equests = int(st
    │ │ │ -000561c0: 6174 735f 636f 756e 7465 7273 2829 5b63  ats_counters()[c
    │ │ │ -000561d0: 6f75 6e74 6572 733a 3a6e 756d 5f70 6565  ounters::num_pee
    │ │ │ -000561e0: 7273 5f64 6f77 6e5f 7265 7175 6573 7473  rs_down_requests
    │ │ │ -000561f0: 5d29 3b0a 0909 092f 2f20 6176 6f69 6420  ]);....// avoid 
    │ │ │ -00056200: 6469 7669 7369 6f6e 2062 7920 300a 0909  division by 0...
    │ │ │ -00056210: 0969 6620 2870 6565 7273 5f77 6974 685f  .if (peers_with_
    │ │ │ -00056220: 7265 7175 6573 7473 203d 3d20 3029 2070  requests == 0) p
    │ │ │ -00056230: 6565 7273 5f77 6974 685f 7265 7175 6573  eers_with_reques
    │ │ │ -00056240: 7473 203d 2031 3b0a 0a3c 6469 7620 7374  ts = 1;..
    ...rate = │ │ │ -00056280: 2074 2d26 6774 3b73 7461 7469 7374 6963 t->statistic │ │ │ -00056290: 7328 292e 7472 616e 7366 6572 5f72 6174 s().transfer_rat │ │ │ -000562a0: 6528 7374 6174 3a3a 646f 776e 6c6f 6164 e(stat::download │ │ │ -000562b0: 5f70 6179 6c6f 6164 2920 2f20 7065 6572 _payload) / peer │ │ │ -000562c0: 735f 7769 7468 5f72 6571 7565 7374 733b s_with_requests; │ │ │ -000562d0: 0a3c 2f64 6976 3e09 097d 0a09 0965 6c73 .
    ..}...els │ │ │ -000562e0: 650a 0909 7b0a 0909 092f 2f20 6375 7272 e...{....// curr │ │ │ -000562f0: 656e 7420 646f 776e 6c6f 6164 2072 6174 ent download rat │ │ │ -00056300: 6520 696e 2062 7974 6573 2070 6572 2073 e in bytes per s │ │ │ -00056310: 6563 6f6e 6473 0a09 0909 7261 7465 203d econds....rate = │ │ │ -00056320: 206d 5f73 7461 7469 7374 6963 732e 7472 m_statistics.tr │ │ │ -00056330: 616e 7366 6572 5f72 6174 6528 7374 6174 ansfer_rate(stat │ │ │ -00056340: 3a3a 646f 776e 6c6f 6164 5f70 6179 6c6f ::download_paylo │ │ │ -00056350: 6164 293b 0a09 097d 0a0a 0909 2f2f 2061 ad);...}....// a │ │ │ -00056360: 766f 6964 2064 6976 6973 696f 6e20 6279 void division by │ │ │ -00056370: 207a 6572 6f0a 0909 6966 2028 7261 7465 zero...if (rate │ │ │ -00056380: 2026 6c74 3b20 3530 2920 7261 7465 203d < 50) rate = │ │ │ -00056390: 2035 303b 0a0a 0909 2f2f 2061 7665 7261 50;....// avera │ │ │ -000563a0: 6765 206f 6620 6375 7272 656e 7420 7261 ge of current ra │ │ │ -000563b0: 7465 2061 6e64 2070 6561 6b0a 2f2f 0909 te and peak.//.. │ │ │ -000563c0: 7261 7465 203d 2028 7261 7465 202b 206d rate = (rate + m │ │ │ -000563d0: 5f64 6f77 6e6c 6f61 645f 7261 7465 5f70 _download_rate_p │ │ │ -000563e0: 6561 6b29 202f 2032 3b0a 0a09 0972 6574 eak) / 2;....ret │ │ │ -000563f0: 7572 6e20 6d69 6c6c 6973 6563 6f6e 6473 urn milliseconds │ │ │ -00056400: 2828 7374 643a 3a69 6e74 3634 5f74 286d ((std::int64_t(m │ │ │ -00056410: 5f6f 7574 7374 616e 6469 6e67 5f62 7974 _outstanding_byt │ │ │ -00056420: 6573 2920 2b20 6578 7472 615f 6279 7465 es) + extra_byte │ │ │ -00056430: 730a 0909 092b 206d 5f71 7565 7565 645f s....+ m_queued_ │ │ │ -00056440: 7469 6d65 5f63 7269 7469 6361 6c20 2a20 time_critical * │ │ │ -00056450: 742d 2667 743b 626c 6f63 6b5f 7369 7a65 t->block_size │ │ │ -00056460: 2829 202a 2031 3030 3029 202f 2072 6174 () * 1000) / rat │ │ │ -00056470: 6529 3b0a 097d 0a0a 0976 6f69 6420 7065 e);..}...void pe │ │ │ -00056480: 6572 5f63 6f6e 6e65 6374 696f 6e3a 3a61 er_connection::a │ │ │ -00056490: 6464 5f73 7461 7428 7374 643a 3a69 6e74 dd_stat(std::int │ │ │ -000564a0: 3634 5f74 2063 6f6e 7374 2064 6f77 6e6c 64_t const downl │ │ │ -000564b0: 6f61 6465 642c 2073 7464 3a3a 696e 7436 oaded, std::int6 │ │ │ -000564c0: 345f 7420 636f 6e73 7420 7570 6c6f 6164 4_t const upload │ │ │ -000564d0: 6564 290a 097b 0a09 0954 4f52 5245 4e54 ed)..{...TORRENT │ │ │ -000564e0: 5f41 5353 4552 5428 6973 5f73 696e 676c _ASSERT(is_singl │ │ │ -000564f0: 655f 7468 7265 6164 2829 293b 0a09 096d e_thread());...m │ │ │ -00056500: 5f73 7461 7469 7374 6963 732e 6164 645f _statistics.add_ │ │ │ -00056510: 7374 6174 2864 6f77 6e6c 6f61 6465 642c stat(downloaded, │ │ │ -00056520: 2075 706c 6f61 6465 6429 3b0a 097d 0a0a uploaded);..}.. │ │ │ -00056530: 0973 6861 315f 6861 7368 2070 6565 725f .sha1_hash peer_ │ │ │ -00056540: 636f 6e6e 6563 7469 6f6e 3a3a 6173 736f connection::asso │ │ │ -00056550: 6369 6174 6564 5f69 6e66 6f5f 6861 7368 ciated_info_hash │ │ │ -00056560: 2829 2063 6f6e 7374 0a09 7b0a 0909 7374 () const..{...st │ │ │ -00056570: 643a 3a73 6861 7265 645f 7074 7226 6c74 d::shared_ptr< │ │ │ -00056580: 3b74 6f72 7265 6e74 2667 743b 2074 203d ;torrent> t = │ │ │ -00056590: 2061 7373 6f63 6961 7465 645f 746f 7272 associated_torr │ │ │ -000565a0: 656e 7428 292e 6c6f 636b 2829 3b0a 0909 ent().lock();... │ │ │ -000565b0: 544f 5252 454e 545f 4153 5345 5254 2874 TORRENT_ASSERT(t │ │ │ -000565c0: 293b 0a09 0961 7574 6f20 636f 6e73 7426 );...auto const& │ │ │ -000565d0: 616d 703b 2069 6820 3d20 742d 2667 743b amp; ih = t-> │ │ │ -000565e0: 696e 666f 5f68 6173 6828 293b 0a09 092f info_hash();.../ │ │ │ -000565f0: 2f20 6120 7065 6572 2773 2070 726f 746f / a peer's proto │ │ │ -00056600: 636f 6c5f 7632 2066 6c61 6720 6d61 7920 col_v2 flag may │ │ │ -00056610: 6265 2073 6574 2073 7065 6375 6c61 7469 be set speculati │ │ │ -00056620: 7665 6c79 2077 6869 6c65 206d 6574 6164 vely while metad │ │ │ -00056630: 6174 610a 0909 2f2f 2069 7320 6e6f 7420 ata...// is not │ │ │ -00056640: 7965 7420 7661 6c69 6420 2873 6565 2074 yet valid (see t │ │ │ -00056650: 6f72 7265 6e74 3a3a 7365 745f 6d65 7461 orrent::set_meta │ │ │ -00056660: 6461 7461 2829 292c 2062 7574 206f 6e63 data()), but onc │ │ │ -00056670: 6520 6d65 7461 6461 7461 0a3c 2f70 7265 e metadata.
    rele │ │ │ -000566b0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/pee │ │ │ -000566f0: 725f 636f 6e6e 6563 7469 6f6e 2e63 7070 r_connection.cpp │ │ │ -00056700: 3a33 3535 303c 2f61 3e3c 2f74 643e 3c74 :3550sort the allow │ │ │ -00056720: 6564 2066 6173 7420 7365 7420 696e 2070 ed fast set in p │ │ │ -00056730: 7269 6f72 6974 7920 6f72 6465 723c 2f74 riority order

    sort │ │ │ -00056790: 7468 6520 616c 6c6f 7765 6420 6661 7374 the allowed fast │ │ │ -000567a0: 2073 6574 2069 6e20 7072 696f 7269 7479 set in priority │ │ │ -000567b0: 206f 7264 6572 3c2f 6832 3e3c 6834 3e2e order

    . │ │ │ -000567c0: 2e2f 7372 632f 7065 6572 5f63 6f6e 6e65 ./src/peer_conne │ │ │ -000567d0: 6374 696f 6e2e 6370 703a 3335 3530 3c2f ction.cpp:3550
    ...
    │ │ │ -00056820: 2f2f 2069 6620 7468 6520 7065 6572 2068  // if the peer h
    │ │ │ -00056830: 6173 2074 6865 2070 6965 6365 2061 6e64  as the piece and
    │ │ │ -00056840: 2077 6520 7761 6e74 0a09 092f 2f20 746f   we want...// to
    │ │ │ -00056850: 2064 6f77 6e6c 6f61 6420 6974 2c20 7265   download it, re
    │ │ │ -00056860: 7175 6573 7420 6974 0a09 0969 6620 2869  quest it...if (i
    │ │ │ -00056870: 6e64 6578 2026 6c74 3b20 6d5f 6861 7665  ndex < m_have
    │ │ │ -00056880: 5f70 6965 6365 2e65 6e64 5f69 6e64 6578  _piece.end_index
    │ │ │ -00056890: 2829 0a09 0909 2661 6d70 3b26 616d 703b  ()....&&
    │ │ │ -000568a0: 206d 5f68 6176 655f 7069 6563 655b 696e   m_have_piece[in
    │ │ │ -000568b0: 6465 785d 0a09 0909 2661 6d70 3b26 616d  dex]....&&am
    │ │ │ -000568c0: 703b 2021 742d 2667 743b 6861 7665 5f70  p; !t->have_p
    │ │ │ -000568d0: 6965 6365 2869 6e64 6578 290a 0909 0926  iece(index)....&
    │ │ │ -000568e0: 616d 703b 2661 6d70 3b20 742d 2667 743b  amp;& t->
    │ │ │ -000568f0: 7661 6c69 645f 6d65 7461 6461 7461 2829  valid_metadata()
    │ │ │ -00056900: 0a09 0909 2661 6d70 3b26 616d 703b 2074  ....&& t
    │ │ │ -00056910: 2d26 6774 3b68 6173 5f70 6963 6b65 7228  ->has_picker(
    │ │ │ -00056920: 290a 0909 0926 616d 703b 2661 6d70 3b20  )....&& 
    │ │ │ -00056930: 742d 2667 743b 7069 636b 6572 2829 2e70  t->picker().p
    │ │ │ -00056940: 6965 6365 5f70 7269 6f72 6974 7928 696e  iece_priority(in
    │ │ │ -00056950: 6465 7829 2026 6774 3b20 646f 6e74 5f64  dex) > dont_d
    │ │ │ -00056960: 6f77 6e6c 6f61 6429 0a09 097b 0a09 0909  ownload)...{....
    │ │ │ -00056970: 742d 2667 743b 7065 6572 5f69 735f 696e  t->peer_is_in
    │ │ │ -00056980: 7465 7265 7374 696e 6728 2a74 6869 7329  teresting(*this)
    │ │ │ -00056990: 3b0a 0909 7d0a 097d 0a0a 0973 7464 3a3a  ;...}..}...std::
    │ │ │ -000569a0: 7665 6374 6f72 266c 743b 7069 6563 655f  vector<piece_
    │ │ │ -000569b0: 696e 6465 785f 7426 6774 3b20 636f 6e73  index_t> cons
    │ │ │ -000569c0: 7426 616d 703b 2070 6565 725f 636f 6e6e  t& peer_conn
    │ │ │ -000569d0: 6563 7469 6f6e 3a3a 616c 6c6f 7765 645f  ection::allowed_
    │ │ │ -000569e0: 6661 7374 2829 0a09 7b0a 0909 544f 5252  fast()..{...TORR
    │ │ │ -000569f0: 454e 545f 4153 5345 5254 2869 735f 7369  ENT_ASSERT(is_si
    │ │ │ -00056a00: 6e67 6c65 5f74 6872 6561 6428 2929 3b0a  ngle_thread());.
    │ │ │ -00056a10: 0909 7374 643a 3a73 6861 7265 645f 7074  ..std::shared_pt
    │ │ │ -00056a20: 7226 6c74 3b74 6f72 7265 6e74 2667 743b  r<torrent>
    │ │ │ -00056a30: 2074 203d 206d 5f74 6f72 7265 6e74 2e6c   t = m_torrent.l
    │ │ │ -00056a40: 6f63 6b28 293b 0a09 0954 4f52 5245 4e54  ock();...TORRENT
    │ │ │ -00056a50: 5f41 5353 4552 5428 7429 3b0a 0a3c 6469  _ASSERT(t);....ret
    │ │ │ -00056a90: 7572 6e20 6d5f 616c 6c6f 7765 645f 6661  urn m_allowed_fa
    │ │ │ -00056aa0: 7374 3b0a 3c2f 6469 763e 097d 0a0a 0962  st;..}...b
    │ │ │ -00056ab0: 6f6f 6c20 7065 6572 5f63 6f6e 6e65 6374  ool peer_connect
    │ │ │ -00056ac0: 696f 6e3a 3a63 616e 5f72 6571 7565 7374  ion::can_request
    │ │ │ -00056ad0: 5f74 696d 655f 6372 6974 6963 616c 2829  _time_critical()
    │ │ │ -00056ae0: 2063 6f6e 7374 0a09 7b0a 0909 544f 5252   const..{...TORR
    │ │ │ -00056af0: 454e 545f 4153 5345 5254 2869 735f 7369  ENT_ASSERT(is_si
    │ │ │ -00056b00: 6e67 6c65 5f74 6872 6561 6428 2929 3b0a  ngle_thread());.
    │ │ │ -00056b10: 0909 6966 2028 6861 735f 7065 6572 5f63  ..if (has_peer_c
    │ │ │ -00056b20: 686f 6b65 6428 2920 7c7c 2021 6973 5f69  hoked() || !is_i
    │ │ │ -00056b30: 6e74 6572 6573 7469 6e67 2829 2920 7265  nteresting()) re
    │ │ │ -00056b40: 7475 726e 2066 616c 7365 3b0a 0909 6966  turn false;...if
    │ │ │ -00056b50: 2028 696e 7428 6d5f 646f 776e 6c6f 6164   (int(m_download
    │ │ │ -00056b60: 5f71 7565 7565 2e73 697a 6528 2929 202b  _queue.size()) +
    │ │ │ -00056b70: 2069 6e74 286d 5f72 6571 7565 7374 5f71   int(m_request_q
    │ │ │ -00056b80: 7565 7565 2e73 697a 6528 2929 0a09 0909  ueue.size())....
    │ │ │ -00056b90: 2667 743b 206d 5f64 6573 6972 6564 5f71  > m_desired_q
    │ │ │ -00056ba0: 7565 7565 5f73 697a 6520 2a20 3229 2072  ueue_size * 2) r
    │ │ │ -00056bb0: 6574 7572 6e20 6661 6c73 653b 0a09 0969  eturn false;...i
    │ │ │ -00056bc0: 6620 286f 6e5f 7061 726f 6c65 2829 2920  f (on_parole()) 
    │ │ │ -00056bd0: 7265 7475 726e 2066 616c 7365 3b0a 0909  return false;...
    │ │ │ -00056be0: 6966 2028 6d5f 6469 7363 6f6e 6e65 6374  if (m_disconnect
    │ │ │ -00056bf0: 696e 6729 2072 6574 7572 6e20 6661 6c73  ing) return fals
    │ │ │ -00056c00: 653b 0a09 0973 7464 3a3a 7368 6172 6564  e;...std::shared
    │ │ │ -00056c10: 5f70 7472 266c 743b 746f 7272 656e 7426  _ptr<torrent&
    │ │ │ -00056c20: 6774 3b20 7420 3d20 6d5f 746f 7272 656e  gt; t = m_torren
    │ │ │ -00056c30: 742e 6c6f 636b 2829 3b0a 0909 544f 5252  t.lock();...TORR
    │ │ │ -00056c40: 454e 545f 4153 5345 5254 2874 293b 0a09  ENT_ASSERT(t);..
    │ │ │ -00056c50: 0969 6620 2874 2d26 6774 3b75 706c 6f61  .if (t->uploa
    │ │ │ -00056c60: 645f 6d6f 6465 2829 2920 7265 7475 726e  d_mode()) return
    │ │ │ -00056c70: 2066 616c 7365 3b0a 0a09 092f 2f20 6967   false;....// ig
    │ │ │ -00056c80: 6e6f 7265 2073 6e75 6262 6564 2070 6565  nore snubbed pee
    │ │ │ -00056c90: 7273 2c20 7369 6e63 6520 7468 6579 2772  rs, since they'r
    │ │ │ -00056ca0: 6520 6e6f 7420 6c69 6b65 6c79 2074 6f20  e not likely to 
    │ │ │ -00056cb0: 7265 7475 726e 2070 6965 6365 7320 696e  return pieces in
    │ │ │ -00056cc0: 2061 0a09 092f 2f20 7469 6d65 6c79 206d   a...// timely m
    │ │ │ -00056cd0: 616e 6e65 7220 616e 7977 6179 0a09 0969  anner anyway...i
    │ │ │ -00056ce0: 6620 286d 5f73 6e75 6262 6564 2920 7265  f (m_snubbed) re
    │ │ │ -00056cf0: 7475 726e 2066 616c 7365 3b0a 0909 7265  turn false;...re
    │ │ │ -00056d00: 7475 726e 2074 7275 653b 0a09 7d0a 0a09  turn true;..}...
    │ │ │ -00056d10: 626f 6f6c 2070 6565 725f 636f 6e6e 6563  bool peer_connec
    │ │ │ -00056d20: 7469 6f6e 3a3a 6d61 6b65 5f74 696d 655f  tion::make_time_
    │ │ │ -00056d30: 6372 6974 6963 616c 2870 6965 6365 5f62  critical(piece_b
    │ │ │ -00056d40: 6c6f 636b 2063 6f6e 7374 2661 6d70 3b20  lock const& 
    │ │ │ -00056d50: 626c 6f63 6b29 0a09 7b0a 0909 544f 5252  block)..{...TORR
    │ │ │ -00056d60: 454e 545f 4153 5345 5254 2869 735f 7369  ENT_ASSERT(is_si
    │ │ │ -00056d70: 6e67 6c65 5f74 6872 6561 6428 2929 3b0a  ngle_thread());.
    │ │ │ -00056d80: 0909 6175 746f 2063 6f6e 7374 2072 6974  ..auto const rit
    │ │ │ -00056d90: 203d 2073 7464 3a3a 6669 6e64 5f69 6628   = std::find_if(
    │ │ │ -00056da0: 6d5f 7265 7175 6573 745f 7175 6575 652e  m_request_queue.
    │ │ │ -00056db0: 6265 6769 6e28 290a 0909 092c 206d 5f72  begin()...., m_r
    │ │ │ -00056dc0: 6571 7565 7374 5f71 7565 7565 2e65 6e64  equest_queue.end
    │ │ │ -00056dd0: 2829 2c20 6175 783a 3a68 6173 5f62 6c6f  (), aux::has_blo
    │ │ │ -00056de0: 636b 2862 6c6f 636b 2929 3b0a 0909 6966  ck(block));...if
    │ │ │ -00056df0: 2028 7269 7420 3d3d 206d 5f72 6571 7565   (rit == m_reque
    │ │ │ -00056e00: 7374 5f71 7565 7565 2e65 6e64 2829 2920  st_queue.end()) 
    │ │ │ -00056e10: 7265 7475 726e 2066 616c 7365 3b0a 2369  return false;.#i
    │ │ │ -00056e20: 6620 544f 5252 454e 545f 5553 455f 4153  f TORRENT_USE_AS
    │ │ │ -00056e30: 5345 5254 530a 0909 7374 643a 3a73 6861  SERTS...std::sha
    │ │ │ -00056e40: 7265 645f 7074 7226 6c74 3b74 6f72 7265  red_ptr<torre
    │ │ │ -00056e50: 6e74 2667 743b 2074 203d 206d 5f74 6f72  nt> t = m_tor
    │ │ │ -00056e60: 7265 6e74 2e6c 6f63 6b28 293b 0a09 0954  rent.lock();...T
    │ │ │ -00056e70: 4f52 5245 4e54 5f41 5353 4552 5428 7429  ORRENT_ASSERT(t)
    │ │ │ -00056e80: 3b0a 0909 544f 5252 454e 545f 4153 5345  ;...TORRENT_ASSE
    │ │ │ -00056e90: 5254 2874 2d26 6774 3b68 6173 5f70 6963  RT(t->has_pic
    │ │ │ -00056ea0: 6b65 7228 2929 3b0a 3c2f 7072 653e 3c2f  ker());.
    relevan │ │ │ -00056ee0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/pe_cry │ │ │ -00056f20: 7074 6f2e 6370 703a 3630 3c2f 613e 3c2f pto.cpp:60it would │ │ │ -00056f40: 6265 206e 6963 6520 746f 2067 6574 2074 be nice to get t │ │ │ -00056f50: 6865 206c 6974 6572 616c 2077 6f72 6b69 he literal worki │ │ │ -00056f60: 6e67 3c2f 7464 3e3c 2f74 723e 3c74 7220 ng

    │ │ │ -00056fb0: 6974 2077 6f75 6c64 2062 6520 6e69 6365 it would be nice │ │ │ -00056fc0: 2074 6f20 6765 7420 7468 6520 6c69 7465 to get the lite │ │ │ -00056fd0: 7261 6c20 776f 726b 696e 673c 2f68 323e ral working

    │ │ │ -00056fe0: 3c68 343e 2e2e 2f73 7263 2f70 655f 6372

    ../src/pe_cr │ │ │ -00056ff0: 7970 746f 2e63 7070 3a36 303c 2f68 343e ypto.cpp:60

    │ │ │ -00057000: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    #inclu
    │ │ │ -00057040: 6465 2026 6c74 3b61 6c67 6f72 6974 686d  de <algorithm
    │ │ │ -00057050: 2667 743b 0a23 696e 636c 7564 6520 266c  >.#include &l
    │ │ │ -00057060: 743b 7261 6e64 6f6d 2667 743b 0a0a 2369  t;random>..#i
    │ │ │ -00057070: 6e63 6c75 6465 2022 6c69 6274 6f72 7265  nclude "libtorre
    │ │ │ -00057080: 6e74 2f61 7578 5f2f 6469 7361 626c 655f  nt/aux_/disable_
    │ │ │ -00057090: 7761 726e 696e 6773 5f70 7573 682e 6870  warnings_push.hp
    │ │ │ -000570a0: 7022 0a0a 2369 6e63 6c75 6465 2026 6c74  p"..#include <
    │ │ │ -000570b0: 3b62 6f6f 7374 2f6d 756c 7469 7072 6563  ;boost/multiprec
    │ │ │ -000570c0: 6973 696f 6e2f 696e 7465 6765 722e 6870  ision/integer.hp
    │ │ │ -000570d0: 7026 6774 3b0a 2369 6e63 6c75 6465 2026  p>.#include &
    │ │ │ -000570e0: 6c74 3b62 6f6f 7374 2f6d 756c 7469 7072  lt;boost/multipr
    │ │ │ -000570f0: 6563 6973 696f 6e2f 6370 705f 696e 742e  ecision/cpp_int.
    │ │ │ -00057100: 6870 7026 6774 3b0a 0a23 696e 636c 7564  hpp>..#includ
    │ │ │ -00057110: 6520 226c 6962 746f 7272 656e 742f 6175  e "libtorrent/au
    │ │ │ -00057120: 785f 2f64 6973 6162 6c65 5f77 6172 6e69  x_/disable_warni
    │ │ │ -00057130: 6e67 735f 706f 702e 6870 7022 0a0a 2369  ngs_pop.hpp"..#i
    │ │ │ -00057140: 6e63 6c75 6465 2022 6c69 6274 6f72 7265  nclude "libtorre
    │ │ │ -00057150: 6e74 2f72 616e 646f 6d2e 6870 7022 0a23  nt/random.hpp".#
    │ │ │ -00057160: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ -00057170: 656e 742f 6175 785f 2f61 6c6c 6f63 612e  ent/aux_/alloca.
    │ │ │ -00057180: 6870 7022 0a23 696e 636c 7564 6520 226c  hpp".#include "l
    │ │ │ -00057190: 6962 746f 7272 656e 742f 7065 5f63 7279  ibtorrent/pe_cry
    │ │ │ -000571a0: 7074 6f2e 6870 7022 0a23 696e 636c 7564  pto.hpp".#includ
    │ │ │ -000571b0: 6520 226c 6962 746f 7272 656e 742f 6861  e "libtorrent/ha
    │ │ │ -000571c0: 7368 6572 2e68 7070 220a 0a6e 616d 6573  sher.hpp"..names
    │ │ │ -000571d0: 7061 6365 206c 6962 746f 7272 656e 7420  pace libtorrent 
    │ │ │ -000571e0: 7b0a 0a09 6e61 6d65 7370 6163 6520 6d70  {...namespace mp
    │ │ │ -000571f0: 203d 2062 6f6f 7374 3a3a 6d75 6c74 6970   = boost::multip
    │ │ │ -00057200: 7265 6369 7369 6f6e 3b0a 0a09 6e61 6d65  recision;...name
    │ │ │ -00057210: 7370 6163 6520 7b0a 3c64 6976 2073 7479  space {.
    ..key_t co │ │ │ -00057250: 6e73 7420 6468 5f70 7269 6d65 0a3c 2f64 nst dh_prime....("0xFFFFFF │ │ │ -00057270: 4646 4646 4646 4646 4646 4339 3046 4441 FFFFFFFFFFC90FDA │ │ │ -00057280: 4132 3231 3638 4332 3334 4334 4336 3632 A22168C234C4C662 │ │ │ -00057290: 3842 3830 4443 3143 4431 3239 3032 3445 8B80DC1CD129024E │ │ │ -000572a0: 3038 3841 3637 4343 3734 3032 3042 4245 088A67CC74020BBE │ │ │ -000572b0: 4136 3342 3133 3942 3232 3531 3441 3038 A63B139B22514A08 │ │ │ -000572c0: 3739 3845 3334 3034 4444 4546 3935 3139 798E3404DDEF9519 │ │ │ -000572d0: 4233 4344 3341 3433 3142 3330 3242 3041 B3CD3A431B302B0A │ │ │ -000572e0: 3644 4632 3546 3134 3337 3446 4531 3335 6DF25F14374FE135 │ │ │ -000572f0: 3644 3644 3531 4332 3435 4534 3835 4235 6D6D51C245E485B5 │ │ │ -00057300: 3736 3632 3545 3745 4336 4634 3443 3432 76625E7EC6F44C42 │ │ │ -00057310: 4539 4136 3341 3336 3231 3030 3030 3030 E9A63A3621000000 │ │ │ -00057320: 3030 3030 3039 3035 3633 2229 3b0a 097d 0000090563");..} │ │ │ -00057330: 0a0a 0973 7464 3a3a 6172 7261 7926 6c74 ...std::array< │ │ │ -00057340: 3b63 6861 722c 2039 3626 6774 3b20 6578 ;char, 96> ex │ │ │ -00057350: 706f 7274 5f6b 6579 286b 6579 5f74 2063 port_key(key_t c │ │ │ -00057360: 6f6e 7374 2661 6d70 3b20 6b29 0a09 7b0a onst& k)..{. │ │ │ -00057370: 0909 7374 643a 3a61 7272 6179 266c 743b ..std::array< │ │ │ -00057380: 6368 6172 2c20 3936 2667 743b 2072 6574 char, 96> ret │ │ │ -00057390: 3b0a 0909 6175 746f 2a20 6265 6769 6e20 ;...auto* begin │ │ │ -000573a0: 3d20 7265 696e 7465 7270 7265 745f 6361 = reinterpret_ca │ │ │ -000573b0: 7374 266c 743b 7374 643a 3a75 696e 7438 st<std::uint8 │ │ │ -000573c0: 5f74 2a26 6774 3b28 7265 742e 6461 7461 _t*>(ret.data │ │ │ -000573d0: 2829 293b 0a09 0973 7464 3a3a 7569 6e74 ());...std::uint │ │ │ -000573e0: 385f 742a 2065 6e64 203d 206d 703a 3a65 8_t* end = mp::e │ │ │ -000573f0: 7870 6f72 745f 6269 7473 286b 2c20 6265 xport_bits(k, be │ │ │ -00057400: 6769 6e2c 2038 293b 0a0a 3c2f 7072 653e gin, 8);..
    │ │ │ -00057410: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -00057440: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00057450: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/pe_c │ │ │ -00057480: 7279 7074 6f2e 6370 703a 3731 3c2f 613e rypto.cpp:71 │ │ │ -00057490: 3c2f 7464 3e3c 7464 3e69 7420 776f 756c it woul │ │ │ -000574a0: 6420 6265 206e 6963 6520 746f 2062 6520 d be nice to be │ │ │ -000574b0: 6162 6c65 2074 6f20 6578 706f 7274 2074 able to export t │ │ │ -000574c0: 6f20 6120 6669 7865 6420 7769 6474 6820 o a fixed width │ │ │ -000574d0: 6669 656c 642c 2073 6f20 7765 2077 6f75 field, so we wou │ │ │ -000574e0: 6c64 6e27 7420 6861 7665 2074 6f20 7368 ldn't have to sh │ │ │ -000574f0: 6966 7420 6974 206c 6174 6572 3c2f 7464 ift it later

    it wou │ │ │ -00057550: 6c64 2062 6520 6e69 6365 2074 6f20 6265 ld be nice to be │ │ │ -00057560: 2061 626c 6520 746f 2065 7870 6f72 7420 able to export │ │ │ -00057570: 746f 2061 2066 6978 6564 2077 6964 7468 to a fixed width │ │ │ -00057580: 2066 6965 6c64 2c20 736f 0a77 6520 776f field, so.we wo │ │ │ -00057590: 756c 646e 2774 2068 6176 6520 746f 2073 uldn't have to s │ │ │ -000575a0: 6869 6674 2069 7420 6c61 7465 723c 2f68 hift it later

    ../src/pe_ │ │ │ -000575c0: 6372 7970 746f 2e63 7070 3a37 313c 2f68 crypto.cpp:71
    #inc
    │ │ │ -00057610: 6c75 6465 2022 6c69 6274 6f72 7265 6e74  lude "libtorrent
    │ │ │ -00057620: 2f72 616e 646f 6d2e 6870 7022 0a23 696e  /random.hpp".#in
    │ │ │ -00057630: 636c 7564 6520 226c 6962 746f 7272 656e  clude "libtorren
    │ │ │ -00057640: 742f 6175 785f 2f61 6c6c 6f63 612e 6870  t/aux_/alloca.hp
    │ │ │ -00057650: 7022 0a23 696e 636c 7564 6520 226c 6962  p".#include "lib
    │ │ │ -00057660: 746f 7272 656e 742f 7065 5f63 7279 7074  torrent/pe_crypt
    │ │ │ -00057670: 6f2e 6870 7022 0a23 696e 636c 7564 6520  o.hpp".#include 
    │ │ │ -00057680: 226c 6962 746f 7272 656e 742f 6861 7368  "libtorrent/hash
    │ │ │ -00057690: 6572 2e68 7070 220a 0a6e 616d 6573 7061  er.hpp"..namespa
    │ │ │ -000576a0: 6365 206c 6962 746f 7272 656e 7420 7b0a  ce libtorrent {.
    │ │ │ -000576b0: 0a09 6e61 6d65 7370 6163 6520 6d70 203d  ..namespace mp =
    │ │ │ -000576c0: 2062 6f6f 7374 3a3a 6d75 6c74 6970 7265   boost::multipre
    │ │ │ -000576d0: 6369 7369 6f6e 3b0a 0a09 6e61 6d65 7370  cision;...namesp
    │ │ │ -000576e0: 6163 6520 7b0a 0909 6b65 795f 7420 636f  ace {...key_t co
    │ │ │ -000576f0: 6e73 7420 6468 5f70 7269 6d65 0a09 0909  nst dh_prime....
    │ │ │ -00057700: 2822 3078 4646 4646 4646 4646 4646 4646  ("0xFFFFFFFFFFFF
    │ │ │ -00057710: 4646 4646 4339 3046 4441 4132 3231 3638  FFFFC90FDAA22168
    │ │ │ -00057720: 4332 3334 4334 4336 3632 3842 3830 4443  C234C4C6628B80DC
    │ │ │ -00057730: 3143 4431 3239 3032 3445 3038 3841 3637  1CD129024E088A67
    │ │ │ -00057740: 4343 3734 3032 3042 4245 4136 3342 3133  CC74020BBEA63B13
    │ │ │ -00057750: 3942 3232 3531 3441 3038 3739 3845 3334  9B22514A08798E34
    │ │ │ -00057760: 3034 4444 4546 3935 3139 4233 4344 3341  04DDEF9519B3CD3A
    │ │ │ -00057770: 3433 3142 3330 3242 3041 3644 4632 3546  431B302B0A6DF25F
    │ │ │ -00057780: 3134 3337 3446 4531 3335 3644 3644 3531  14374FE1356D6D51
    │ │ │ -00057790: 4332 3435 4534 3835 4235 3736 3632 3545  C245E485B576625E
    │ │ │ -000577a0: 3745 4336 4634 3443 3432 4539 4136 3341  7EC6F44C42E9A63A
    │ │ │ -000577b0: 3336 3231 3030 3030 3030 3030 3030 3039  3621000000000009
    │ │ │ -000577c0: 3035 3633 2229 3b0a 097d 0a0a 0973 7464  0563");..}...std
    │ │ │ -000577d0: 3a3a 6172 7261 7926 6c74 3b63 6861 722c  ::array<char,
    │ │ │ -000577e0: 2039 3626 6774 3b20 6578 706f 7274 5f6b   96> export_k
    │ │ │ -000577f0: 6579 286b 6579 5f74 2063 6f6e 7374 2661  ey(key_t const&a
    │ │ │ -00057800: 6d70 3b20 6b29 0a09 7b0a 0909 7374 643a  mp; k)..{...std:
    │ │ │ -00057810: 3a61 7272 6179 266c 743b 6368 6172 2c20  :array<char, 
    │ │ │ -00057820: 3936 2667 743b 2072 6574 3b0a 0909 6175  96> ret;...au
    │ │ │ -00057830: 746f 2a20 6265 6769 6e20 3d20 7265 696e  to* begin = rein
    │ │ │ -00057840: 7465 7270 7265 745f 6361 7374 266c 743b  terpret_cast<
    │ │ │ -00057850: 7374 643a 3a75 696e 7438 5f74 2a26 6774  std::uint8_t*>
    │ │ │ -00057860: 3b28 7265 742e 6461 7461 2829 293b 0a09  ;(ret.data());..
    │ │ │ -00057870: 0973 7464 3a3a 7569 6e74 385f 742a 2065  .std::uint8_t* e
    │ │ │ -00057880: 6e64 203d 206d 703a 3a65 7870 6f72 745f  nd = mp::export_
    │ │ │ -00057890: 6269 7473 286b 2c20 6265 6769 6e2c 2038  bits(k, begin, 8
    │ │ │ -000578a0: 293b 0a0a 3c64 6976 2073 7479 6c65 3d22  );..
    ..if (end < │ │ │ -000578e0: 2062 6567 696e 202b 2039 3629 0a3c 2f64 begin + 96)...{....int co │ │ │ -00057900: 6e73 7420 6c65 6e20 3d20 696e 7428 656e nst len = int(en │ │ │ -00057910: 6420 2d20 6265 6769 6e29 3b0a 2369 6620 d - begin);.#if │ │ │ -00057920: 6465 6669 6e65 6420 5f5f 474e 5543 5f5f defined __GNUC__ │ │ │ -00057930: 2026 616d 703b 2661 6d70 3b20 5f5f 474e && __GN │ │ │ -00057940: 5543 5f5f 203d 3d20 3132 0a23 7072 6167 UC__ == 12.#prag │ │ │ -00057950: 6d61 2047 4343 2064 6961 676e 6f73 7469 ma GCC diagnosti │ │ │ -00057960: 6320 7075 7368 0a23 7072 6167 6d61 2047 c push.#pragma G │ │ │ -00057970: 4343 2064 6961 676e 6f73 7469 6320 6967 CC diagnostic ig │ │ │ -00057980: 6e6f 7265 6420 222d 5773 7472 696e 676f nored "-Wstringo │ │ │ -00057990: 702d 6f76 6572 666c 6f77 220a 2365 6e64 p-overflow".#end │ │ │ -000579a0: 6966 0a09 0909 7374 643a 3a6d 656d 6d6f if....std::memmo │ │ │ -000579b0: 7665 2862 6567 696e 202b 2039 3620 2d20 ve(begin + 96 - │ │ │ -000579c0: 6c65 6e2c 2062 6567 696e 2c20 6175 783a len, begin, aux: │ │ │ -000579d0: 3a6e 756d 6572 6963 5f63 6173 7426 6c74 :numeric_cast< │ │ │ -000579e0: 3b73 7464 3a3a 7369 7a65 5f74 2667 743b ;std::size_t> │ │ │ -000579f0: 286c 656e 2929 3b0a 2369 6620 6465 6669 (len));.#if defi │ │ │ -00057a00: 6e65 6420 5f5f 474e 5543 5f5f 2026 616d ned __GNUC__ &am │ │ │ -00057a10: 703b 2661 6d70 3b20 5f5f 474e 5543 5f5f p;& __GNUC__ │ │ │ -00057a20: 203d 3d20 3132 0a23 7072 6167 6d61 2047 == 12.#pragma G │ │ │ -00057a30: 4343 2064 6961 676e 6f73 7469 6320 706f CC diagnostic po │ │ │ -00057a40: 700a 2365 6e64 6966 0a09 0909 7374 643a p.#endif....std: │ │ │ -00057a50: 3a6d 656d 7365 7428 6265 6769 6e2c 2030 :memset(begin, 0 │ │ │ -00057a60: 2c20 6175 783a 3a6e 756d 6572 6963 5f63 , aux::numeric_c │ │ │ -00057a70: 6173 7426 6c74 3b73 7464 3a3a 7369 7a65 ast<std::size │ │ │ -00057a80: 5f74 2667 743b 2839 3620 2d20 6c65 6e29 _t>(96 - len) │ │ │ -00057a90: 293b 0a09 097d 0a09 0972 6574 7572 6e20 );...}...return │ │ │ -00057aa0: 7265 743b 0a09 7d0a 0a09 766f 6964 2072 ret;..}...void r │ │ │ -00057ab0: 6334 5f69 6e69 7428 636f 6e73 7420 756e c4_init(const un │ │ │ -00057ac0: 7369 676e 6564 2063 6861 722a 2069 6e2c signed char* in, │ │ │ -00057ad0: 2073 7464 3a3a 7369 7a65 5f74 206c 656e std::size_t len │ │ │ -00057ae0: 2c20 7263 3420 2a73 7461 7465 293b 0a09 , rc4 *state);.. │ │ │ -00057af0: 7374 643a 3a73 697a 655f 7420 7263 345f std::size_t rc4_ │ │ │ -00057b00: 656e 6372 7970 7428 756e 7369 676e 6564 encrypt(unsigned │ │ │ -00057b10: 2063 6861 7220 2a6f 7574 2c20 7374 643a char *out, std: │ │ │ -00057b20: 3a73 697a 655f 7420 6f75 746c 656e 2c20 :size_t outlen, │ │ │ -00057b30: 7263 3420 2a73 7461 7465 293b 0a0a 092f rc4 *state);.../ │ │ │ -00057b40: 2f20 5365 7420 7468 6520 7072 696d 6520 / Set the prime │ │ │ -00057b50: 5020 616e 6420 7468 6520 6765 6e65 7261 P and the genera │ │ │ -00057b60: 746f 722c 2067 656e 6572 6174 6520 6c6f tor, generate lo │ │ │ -00057b70: 6361 6c20 7075 626c 6963 206b 6579 0a09 cal public key.. │ │ │ -00057b80: 6468 5f6b 6579 5f65 7863 6861 6e67 653a dh_key_exchange: │ │ │ -00057b90: 3a64 685f 6b65 795f 6578 6368 616e 6765 :dh_key_exchange │ │ │ -00057ba0: 2829 0a09 7b0a 0909 6175 783a 3a61 7272 ()..{...aux::arr │ │ │ -00057bb0: 6179 266c 743b 7374 643a 3a75 696e 7438 ay<std::uint8 │ │ │ -00057bc0: 5f74 2c20 3230 2667 743b 2072 616e 646f _t, 20> rando │ │ │ -00057bd0: 6d5f 6b65 793b 0a09 0961 7578 3a3a 7261 m_key;...aux::ra │ │ │ -00057be0: 6e64 6f6d 5f62 7974 6573 287b 7265 696e ndom_bytes({rein │ │ │ -00057bf0: 7465 7270 7265 745f 6361 7374 266c 743b terpret_cast< │ │ │ -00057c00: 6368 6172 2a26 6774 3b28 7261 6e64 6f6d char*>(random │ │ │ -00057c10: 5f6b 6579 2e64 6174 6128 2929 0a09 0909 _key.data()).... │ │ │ -00057c20: 2c20 7374 6174 6963 5f63 6173 7426 6c74 , static_cast< │ │ │ -00057c30: 3b73 7464 3a3a 7074 7264 6966 665f 7426 ;std::ptrdiff_t& │ │ │ -00057c40: 6774 3b28 7261 6e64 6f6d 5f6b 6579 2e73 gt;(random_key.s │ │ │ -00057c50: 697a 6528 2929 7d29 3b0a 0a09 092f 2f20 ize())});....// │ │ │ -00057c60: 6372 6561 7465 206c 6f63 616c 206b 6579 create local key │ │ │ -00057c70: 2028 7261 6e64 6f6d 290a 0909 6d70 3a3a (random)...mp:: │ │ │ -00057c80: 696d 706f 7274 5f62 6974 7328 6d5f 6468 import_bits(m_dh │ │ │ -00057c90: 5f6c 6f63 616c 5f73 6563 7265 742c 2072 _local_secret, r │ │ │ -00057ca0: 616e 646f 6d5f 6b65 792e 6265 6769 6e28 andom_key.begin( │ │ │ -00057cb0: 292c 2072 616e 646f 6d5f 6b65 792e 656e ), random_key.en │ │ │ -00057cc0: 6428 2929 3b0a 0a09 092f 2f20 6b65 7920 d());....// key │ │ │ -00057cd0: 3d20 2832 205e 2073 6563 7265 7429 2025 = (2 ^ secret) % │ │ │ -00057ce0: 2070 7269 6d65 0a09 096d 5f64 685f 6c6f prime...m_dh_lo │ │ │ -00057cf0: 6361 6c5f 6b65 7920 3d20 6d70 3a3a 706f cal_key = mp::po │ │ │ -00057d00: 776d 286b 6579 5f74 2832 292c 206d 5f64 wm(key_t(2), m_d │ │ │ -00057d10: 685f 6c6f 6361 6c5f 7365 6372 6574 2c20 h_local_secret, │ │ │ -00057d20: 6468 5f70 7269 6d65 293b 0a3c 2f70 7265 dh_prime);.
    rele │ │ │ -00057d60: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/par │ │ │ -00057da0: 745f 6669 6c65 2e63 7070 3a33 3032 3c2f t_file.cpp:302what │ │ │ -00057dc0: 646f 2077 6520 646f 2069 6620 736f 6d65 do we do if some │ │ │ -00057dd0: 6f6e 6520 6973 2063 7572 7265 6e74 6c79 one is currently │ │ │ -00057de0: 2072 6561 6469 6e67 2066 726f 6d20 7468 reading from th │ │ │ -00057df0: 6520 6469 736b 2066 726f 6d20 7468 6973 e disk from this │ │ │ -00057e00: 2070 6965 6365 3f20 646f 6573 2069 7420 piece? does it │ │ │ -00057e10: 6d61 7474 6572 3f20 5369 6e63 6520 7765 matter? Since we │ │ │ -00057e20: 2077 6f6e 2774 2061 6374 6976 656c 7920 won't actively │ │ │ -00057e30: 6572 6173 6520 7468 6520 6461 7461 2066 erase the data f │ │ │ -00057e40: 726f 6d20 6469 736b 2c20 6275 7420 6974 rom disk, but it │ │ │ -00057e50: 206d 6179 2062 6520 6f76 6572 7772 6974 may be overwrit │ │ │ -00057e60: 7465 6e20 736f 6f6e 2c20 6974 2773 2070 ten soon, it's p │ │ │ -00057e70: 726f 6261 626c 7920 6e6f 7420 7468 6174 robably not that │ │ │ -00057e80: 2062 6967 206f 6620 6120 6465 616c 3c2f big of a deal

    what │ │ │ -00057ee0: 2064 6f20 7765 2064 6f20 6966 2073 6f6d do we do if som │ │ │ -00057ef0: 656f 6e65 2069 7320 6375 7272 656e 746c eone is currentl │ │ │ -00057f00: 7920 7265 6164 696e 6720 6672 6f6d 2074 y reading from t │ │ │ -00057f10: 6865 2064 6973 6b0a 6672 6f6d 2074 6869 he disk.from thi │ │ │ -00057f20: 7320 7069 6563 653f 2064 6f65 7320 6974 s piece? does it │ │ │ -00057f30: 206d 6174 7465 723f 2053 696e 6365 2077 matter? Since w │ │ │ -00057f40: 6520 776f 6e27 7420 6163 7469 7665 6c79 e won't actively │ │ │ -00057f50: 2065 7261 7365 2074 6865 0a64 6174 6120 erase the.data │ │ │ -00057f60: 6672 6f6d 2064 6973 6b2c 2062 7574 2069 from disk, but i │ │ │ -00057f70: 7420 6d61 7920 6265 206f 7665 7277 7269 t may be overwri │ │ │ -00057f80: 7474 656e 2073 6f6f 6e2c 2069 7427 7320 tten soon, it's │ │ │ -00057f90: 7072 6f62 6162 6c79 206e 6f74 2074 6861 probably not tha │ │ │ -00057fa0: 740a 6269 6720 6f66 2061 2064 6561 6c3c t.big of a deal< │ │ │ -00057fb0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ -00057fc0: 6172 745f 6669 6c65 2e63 7070 3a33 3032 art_file.cpp:302 │ │ │ -00057fd0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00058010: 0909 0963 7265 6174 655f 6469 7265 6374  ...create_direct
    │ │ │ -00058020: 6f72 6965 7328 6d5f 7061 7468 2c20 6563  ories(m_path, ec
    │ │ │ -00058030: 293b 0a09 0909 0969 6620 2865 6329 2072  );.....if (ec) r
    │ │ │ -00058040: 6574 7572 6e20 7b7d 3b0a 0909 0909 7265  eturn {};.....re
    │ │ │ -00058050: 7475 726e 2061 7578 3a3a 6669 6c65 5f68  turn aux::file_h
    │ │ │ -00058060: 616e 646c 6528 666e 2c20 302c 206d 6f64  andle(fn, 0, mod
    │ │ │ -00058070: 6529 3b0a 0909 097d 0a09 0909 7265 7475  e);....}....retu
    │ │ │ -00058080: 726e 207b 7d3b 0a09 097d 0a09 7d0a 0963  rn {};...}..}..c
    │ │ │ -00058090: 6174 6368 2028 7374 6f72 6167 655f 6572  atch (storage_er
    │ │ │ -000580a0: 726f 7220 636f 6e73 7426 616d 703b 2065  ror const& e
    │ │ │ -000580b0: 290a 097b 0a09 0965 6320 3d20 652e 6563  )..{...ec = e.ec
    │ │ │ -000580c0: 3b0a 0909 7265 7475 726e 207b 7d3b 0a09  ;...return {};..
    │ │ │ -000580d0: 7d0a 0a09 766f 6964 2070 6172 745f 6669  }...void part_fi
    │ │ │ -000580e0: 6c65 3a3a 6672 6565 5f70 6965 6365 2870  le::free_piece(p
    │ │ │ -000580f0: 6965 6365 5f69 6e64 6578 5f74 2063 6f6e  iece_index_t con
    │ │ │ -00058100: 7374 2070 6965 6365 290a 097b 0a09 0973  st piece)..{...s
    │ │ │ -00058110: 7464 3a3a 6c6f 636b 5f67 7561 7264 266c  td::lock_guard&l
    │ │ │ -00058120: 743b 7374 643a 3a6d 7574 6578 2667 743b  t;std::mutex>
    │ │ │ -00058130: 206c 286d 5f6d 7574 6578 293b 0a0a 0909   l(m_mutex);....
    │ │ │ -00058140: 6175 746f 2063 6f6e 7374 2069 203d 206d  auto const i = m
    │ │ │ -00058150: 5f70 6965 6365 5f6d 6170 2e66 696e 6428  _piece_map.find(
    │ │ │ -00058160: 7069 6563 6529 3b0a 0909 6966 2028 6920  piece);...if (i 
    │ │ │ -00058170: 3d3d 206d 5f70 6965 6365 5f6d 6170 2e65  == m_piece_map.e
    │ │ │ -00058180: 6e64 2829 2920 7265 7475 726e 3b0a 0a3c  nd()) return;..<
    │ │ │ -00058190: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -000581a0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -000581b0: 7769 6474 683d 2231 3030 2522 3e0a 3c2f  width="100%">...m_free_slo
    │ │ │ -000581d0: 7473 2e70 7573 685f 6261 636b 2869 2d26  ts.push_back(i-&
    │ │ │ -000581e0: 6774 3b73 6563 6f6e 6429 3b0a 0909 6d5f  gt;second);...m_
    │ │ │ -000581f0: 7069 6563 655f 6d61 702e 6572 6173 6528  piece_map.erase(
    │ │ │ -00058200: 6929 3b0a 0909 6d5f 6469 7274 795f 6d65  i);...m_dirty_me
    │ │ │ -00058210: 7461 6461 7461 203d 2074 7275 653b 0a09  tadata = true;..
    │ │ │ -00058220: 7d0a 0a09 766f 6964 2070 6172 745f 6669  }...void part_fi
    │ │ │ -00058230: 6c65 3a3a 6d6f 7665 5f70 6172 7466 696c  le::move_partfil
    │ │ │ -00058240: 6528 7374 643a 3a73 7472 696e 6720 636f  e(std::string co
    │ │ │ -00058250: 6e73 7426 616d 703b 2070 6174 682c 2065  nst& path, e
    │ │ │ -00058260: 7272 6f72 5f63 6f64 6526 616d 703b 2065  rror_code& e
    │ │ │ -00058270: 6329 0a09 7b0a 0909 7374 643a 3a6c 6f63  c)..{...std::loc
    │ │ │ -00058280: 6b5f 6775 6172 6426 6c74 3b73 7464 3a3a  k_guard<std::
    │ │ │ -00058290: 6d75 7465 7826 6774 3b20 6c28 6d5f 6d75  mutex> l(m_mu
    │ │ │ -000582a0: 7465 7829 3b0a 0a09 0966 6c75 7368 5f6d  tex);....flush_m
    │ │ │ -000582b0: 6574 6164 6174 615f 696d 706c 2865 6329  etadata_impl(ec)
    │ │ │ -000582c0: 3b0a 0909 6966 2028 6563 2920 7265 7475  ;...if (ec) retu
    │ │ │ -000582d0: 726e 3b0a 0a09 0969 6620 2821 6d5f 7069  rn;....if (!m_pi
    │ │ │ -000582e0: 6563 655f 6d61 702e 656d 7074 7928 2929  ece_map.empty())
    │ │ │ -000582f0: 0a09 097b 0a09 0909 7374 643a 3a73 7472  ...{....std::str
    │ │ │ -00058300: 696e 6720 6f6c 645f 7061 7468 203d 2063  ing old_path = c
    │ │ │ -00058310: 6f6d 6269 6e65 5f70 6174 6828 6d5f 7061  ombine_path(m_pa
    │ │ │ -00058320: 7468 2c20 6d5f 6e61 6d65 293b 0a09 0909  th, m_name);....
    │ │ │ -00058330: 7374 643a 3a73 7472 696e 6720 6e65 775f  std::string new_
    │ │ │ -00058340: 7061 7468 203d 2063 6f6d 6269 6e65 5f70  path = combine_p
    │ │ │ -00058350: 6174 6828 7061 7468 2c20 6d5f 6e61 6d65  ath(path, m_name
    │ │ │ -00058360: 293b 0a0a 0909 0972 656e 616d 6528 6f6c  );.....rename(ol
    │ │ │ -00058370: 645f 7061 7468 2c20 6e65 775f 7061 7468  d_path, new_path
    │ │ │ -00058380: 2c20 6563 293b 0a09 0909 6966 2028 6563  , ec);....if (ec
    │ │ │ -00058390: 203d 3d20 626f 6f73 743a 3a73 7973 7465   == boost::syste
    │ │ │ -000583a0: 6d3a 3a65 7272 633a 3a6e 6f5f 7375 6368  m::errc::no_such
    │ │ │ -000583b0: 5f66 696c 655f 6f72 5f64 6972 6563 746f  _file_or_directo
    │ │ │ -000583c0: 7279 290a 0909 0909 6563 2e63 6c65 6172  ry).....ec.clear
    │ │ │ -000583d0: 2829 3b0a 0a09 0909 6966 2028 6563 290a  ();.....if (ec).
    │ │ │ -000583e0: 0909 097b 0a09 0909 0973 746f 7261 6765  ...{.....storage
    │ │ │ -000583f0: 5f65 7272 6f72 2073 653b 0a09 0909 0961  _error se;.....a
    │ │ │ -00058400: 7578 3a3a 636f 7079 5f66 696c 6528 6f6c  ux::copy_file(ol
    │ │ │ -00058410: 645f 7061 7468 2c20 6e65 775f 7061 7468  d_path, new_path
    │ │ │ -00058420: 2c20 7365 293b 0a09 0909 0965 6320 3d20  , se);.....ec = 
    │ │ │ -00058430: 7365 2e65 633b 0a09 0909 0969 6620 2865  se.ec;.....if (e
    │ │ │ -00058440: 6329 2072 6574 7572 6e3b 0a09 0909 0972  c) return;.....r
    │ │ │ -00058450: 656d 6f76 6528 6f6c 645f 7061 7468 2c20  emove(old_path, 
    │ │ │ -00058460: 6563 293b 0a09 0909 7d0a 0909 7d0a 3c2f  ec);....}...}.r
    │ │ │ -000584a0: 656c 6576 616e 6365 266e 6273 703b 303c  elevance 0<
    │ │ │ -000584b0: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../src/
    │ │ │ -000584e0: 7061 7274 5f66 696c 652e 6370 703a 3431  part_file.cpp:41
    │ │ │ -000584f0: 323c 2f61 3e3c 2f74 643e 3c74 643e 696e  2in
    │ │ │ -00058500: 7374 6561 6420 6f66 2072 6562 7569 6c64  stead of rebuild
    │ │ │ -00058510: 696e 6720 7468 6520 7768 6f6c 6520 6669  ing the whole fi
    │ │ │ -00058520: 6c65 2068 6561 6465 7220 616e 6420 666c  le header and fl
    │ │ │ -00058530: 7573 6869 6e67 2069 742c 2075 7064 6174  ushing it, updat
    │ │ │ -00058540: 6520 7468 6520 736c 6f74 2065 6e74 7269  e the slot entri
    │ │ │ -00058550: 6573 2061 7320 7765 2067 6f3c 2f74 643e  es as we go
    │ │ │ -00058560: 3c2f 7472 3e3c 7472 2069 643d 2232 3037  

    instead │ │ │ -000585b0: 206f 6620 7265 6275 696c 6469 6e67 2074 of rebuilding t │ │ │ -000585c0: 6865 2077 686f 6c65 2066 696c 6520 6865 he whole file he │ │ │ -000585d0: 6164 6572 0a61 6e64 2066 6c75 7368 696e ader.and flushin │ │ │ -000585e0: 6720 6974 2c20 7570 6461 7465 2074 6865 g it, update the │ │ │ -000585f0: 2073 6c6f 7420 656e 7472 6965 7320 6173 slot entries as │ │ │ -00058600: 2077 6520 676f 3c2f 6832 3e3c 6834 3e2e we go

    . │ │ │ -00058610: 2e2f 7372 632f 7061 7274 5f66 696c 652e ./src/part_file. │ │ │ -00058620: 6370 703a 3431 323c 2f68 343e 3c70 7265 cpp:412

    ......TORR
    │ │ │ -00058670: 454e 545f 4153 5345 5254 286a 2d26 6774  ENT_ASSERT(j->
    │ │ │ -00058680: 3b73 6563 6f6e 6420 3d3d 2073 6c6f 7429  ;second == slot)
    │ │ │ -00058690: 3b0a 0909 0909 0909 6d5f 6672 6565 5f73  ;.......m_free_s
    │ │ │ -000586a0: 6c6f 7473 2e70 7573 685f 6261 636b 286a  lots.push_back(j
    │ │ │ -000586b0: 2d26 6774 3b73 6563 6f6e 6429 3b0a 0909  ->second);...
    │ │ │ -000586c0: 0909 0909 6d5f 7069 6563 655f 6d61 702e  ....m_piece_map.
    │ │ │ -000586d0: 6572 6173 6528 6a29 3b0a 0909 0909 0909  erase(j);.......
    │ │ │ -000586e0: 6d5f 6469 7274 795f 6d65 7461 6461 7461  m_dirty_metadata
    │ │ │ -000586f0: 203d 2074 7275 653b 0a09 0909 0909 7d0a   = true;......}.
    │ │ │ -00058700: 0909 0909 7d0a 0909 097d 0a09 0909 6669  ....}....}....fi
    │ │ │ -00058710: 6c65 5f6f 6666 7365 7420 2b3d 2062 6c6f  le_offset += blo
    │ │ │ -00058720: 636b 5f74 6f5f 636f 7079 3b0a 0909 0970  ck_to_copy;....p
    │ │ │ -00058730: 6965 6365 5f6f 6666 7365 7420 3d20 303b  iece_offset = 0;
    │ │ │ -00058740: 0a09 0909 7369 7a65 202d 3d20 626c 6f63  ....size -= bloc
    │ │ │ -00058750: 6b5f 746f 5f63 6f70 793b 0a09 097d 0a09  k_to_copy;...}..
    │ │ │ -00058760: 7d0a 0a09 766f 6964 2070 6172 745f 6669  }...void part_fi
    │ │ │ -00058770: 6c65 3a3a 666c 7573 685f 6d65 7461 6461  le::flush_metada
    │ │ │ -00058780: 7461 2865 7272 6f72 5f63 6f64 6526 616d  ta(error_code&am
    │ │ │ -00058790: 703b 2065 6329 0a09 7b0a 0909 7374 643a  p; ec)..{...std:
    │ │ │ -000587a0: 3a6c 6f63 6b5f 6775 6172 6426 6c74 3b73  :lock_guard<s
    │ │ │ -000587b0: 7464 3a3a 6d75 7465 7826 6774 3b20 6c28  td::mutex> l(
    │ │ │ -000587c0: 6d5f 6d75 7465 7829 3b0a 0a09 0966 6c75  m_mutex);....flu
    │ │ │ -000587d0: 7368 5f6d 6574 6164 6174 615f 696d 706c  sh_metadata_impl
    │ │ │ -000587e0: 2865 6329 3b0a 097d 0a0a 3c64 6976 2073  (ec);..}..
    .void pa │ │ │ -00058820: 7274 5f66 696c 653a 3a66 6c75 7368 5f6d rt_file::flush_m │ │ │ -00058830: 6574 6164 6174 615f 696d 706c 2865 7272 etadata_impl(err │ │ │ -00058840: 6f72 5f63 6f64 6526 616d 703b 2065 6329 or_code& ec) │ │ │ -00058850: 0a3c 2f64 6976 3e09 7b0a 0909 2f2f 2064 .
    .{...// d │ │ │ -00058860: 6f20 7765 206e 6565 6420 746f 2066 6c75 o we need to flu │ │ │ -00058870: 7368 2074 6865 206d 6574 6164 6174 613f sh the metadata? │ │ │ -00058880: 0a09 0969 6620 286d 5f64 6972 7479 5f6d ...if (m_dirty_m │ │ │ -00058890: 6574 6164 6174 6120 3d3d 2066 616c 7365 etadata == false │ │ │ -000588a0: 2920 7265 7475 726e 3b0a 0a09 0969 6620 ) return;....if │ │ │ -000588b0: 286d 5f70 6965 6365 5f6d 6170 2e65 6d70 (m_piece_map.emp │ │ │ -000588c0: 7479 2829 290a 0909 7b0a 0909 092f 2f20 ty())...{....// │ │ │ -000588d0: 6966 2077 6520 646f 6e27 7420 6861 7665 if we don't have │ │ │ -000588e0: 2061 6e79 2070 6965 6365 7320 6c65 6674 any pieces left │ │ │ -000588f0: 2069 6e20 7468 650a 0909 092f 2f20 7061 in the....// pa │ │ │ -00058900: 7274 2066 696c 652c 2072 656d 6f76 6520 rt file, remove │ │ │ -00058910: 6974 0a09 0909 7374 643a 3a73 7472 696e it....std::strin │ │ │ -00058920: 6720 636f 6e73 7420 7020 3d20 636f 6d62 g const p = comb │ │ │ -00058930: 696e 655f 7061 7468 286d 5f70 6174 682c ine_path(m_path, │ │ │ -00058940: 206d 5f6e 616d 6529 3b0a 0909 0972 656d m_name);....rem │ │ │ -00058950: 6f76 6528 702c 2065 6329 3b0a 0a09 0909 ove(p, ec);..... │ │ │ -00058960: 6966 2028 6563 203d 3d20 626f 6f73 743a if (ec == boost: │ │ │ -00058970: 3a73 7973 7465 6d3a 3a65 7272 633a 3a6e :system::errc::n │ │ │ -00058980: 6f5f 7375 6368 5f66 696c 655f 6f72 5f64 o_such_file_or_d │ │ │ -00058990: 6972 6563 746f 7279 290a 0909 0909 6563 irectory).....ec │ │ │ -000589a0: 2e63 6c65 6172 2829 3b0a 0909 0972 6574 .clear();....ret │ │ │ -000589b0: 7572 6e3b 0a09 097d 0a0a 0909 6175 746f urn;...}....auto │ │ │ -000589c0: 2066 203d 206f 7065 6e5f 6669 6c65 2861 f = open_file(a │ │ │ -000589d0: 7578 3a3a 6f70 656e 5f6d 6f64 653a 3a77 ux::open_mode::w │ │ │ -000589e0: 7269 7465 207c 2061 7578 3a3a 6f70 656e rite | aux::open │ │ │ -000589f0: 5f6d 6f64 653a 3a68 6964 6465 6e2c 2065 _mode::hidden, e │ │ │ -00058a00: 6329 3b0a 0909 6966 2028 6563 2920 7265 c);...if (ec) re │ │ │ -00058a10: 7475 726e 3b0a 0a09 0973 7464 3a3a 7665 turn;....std::ve │ │ │ -00058a20: 6374 6f72 266c 743b 6368 6172 2667 743b ctor<char> │ │ │ -00058a30: 2068 6561 6465 7228 7374 6174 6963 5f63 header(static_c │ │ │ -00058a40: 6173 7426 6c74 3b73 7464 3a3a 7369 7a65 ast<std::size │ │ │ -00058a50: 5f74 2667 743b 286d 5f68 6561 6465 725f _t>(m_header_ │ │ │ -00058a60: 7369 7a65 2929 3b0a 0a09 0975 7369 6e67 size));....using │ │ │ -00058a70: 206e 616d 6573 7061 6365 206c 6962 746f namespace libto │ │ │ -00058a80: 7272 656e 743a 3a61 7578 3b0a 0a09 0963 rrent::aux;....c │ │ │ -00058a90: 6861 722a 2070 7472 203d 2068 6561 6465 har* ptr = heade │ │ │ -00058aa0: 722e 6461 7461 2829 3b0a 0909 7772 6974 r.data();...writ │ │ │ -00058ab0: 655f 7569 6e74 3332 286d 5f6d 6178 5f70 e_uint32(m_max_p │ │ │ -00058ac0: 6965 6365 732c 2070 7472 293b 0a09 0977 ieces, ptr);...w │ │ │ -00058ad0: 7269 7465 5f75 696e 7433 3228 6d5f 7069 rite_uint32(m_pi │ │ │ -00058ae0: 6563 655f 7369 7a65 2c20 7074 7229 3b0a ece_size, ptr);. │ │ │ -00058af0: 0a09 0966 6f72 2028 7069 6563 655f 696e ...for (piece_in │ │ │ -00058b00: 6465 785f 7420 7069 6563 6528 3029 3b20 dex_t piece(0); │ │ │ -00058b10: 7069 6563 6520 266c 743b 2070 6965 6365 piece < piece │ │ │ -00058b20: 5f69 6e64 6578 5f74 286d 5f6d 6178 5f70 _index_t(m_max_p │ │ │ -00058b30: 6965 6365 7329 3b20 2b2b 7069 6563 6529 ieces); ++piece) │ │ │ -00058b40: 0a09 097b 0a09 0909 6175 746f 2063 6f6e ...{....auto con │ │ │ -00058b50: 7374 2069 203d 206d 5f70 6965 6365 5f6d st i = m_piece_m │ │ │ -00058b60: 6170 2e66 696e 6428 7069 6563 6529 3b0a ap.find(piece);. │ │ │ -00058b70: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00058b80: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00058bb0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -00058be0: 632f 6d6d 6170 5f64 6973 6b5f 696f 2e63 c/mmap_disk_io.c │ │ │ -00058bf0: 7070 3a35 3738 3c2f 613e 3c2f 7464 3e3c pp:578< │ │ │ -00058c00: 7464 3e69 6e20 7468 6520 6675 7475 7265 td>in the future │ │ │ -00058c10: 2c20 7072 6f70 6167 6174 6520 6578 6365 , propagate exce │ │ │ -00058c20: 7074 696f 6e73 2062 6163 6b20 746f 2074 ptions back to t │ │ │ -00058c30: 6865 2068 616e 646c 6572 733c 2f74 643e he handlers │ │ │ -00058c40: 3c2f 7472 3e3c 7472 2069 643d 2232 3038

    in the │ │ │ -00058c90: 6675 7475 7265 2c20 7072 6f70 6167 6174 future, propagat │ │ │ -00058ca0: 6520 6578 6365 7074 696f 6e73 2062 6163 e exceptions bac │ │ │ -00058cb0: 6b20 746f 2074 6865 2068 616e 646c 6572 k to the handler │ │ │ -00058cc0: 733c 2f68 323e 3c68 343e 2e2e 2f73 7263 s

    ../src │ │ │ -00058cd0: 2f6d 6d61 705f 6469 736b 5f69 6f2e 6370 /mmap_disk_io.cp │ │ │ -00058ce0: 703a 3537 383c 2f68 343e 3c70 7265 2073 p:578

    #if DEBUG_DI
    │ │ │ -00058d30: 534b 5f54 4852 4541 440a 0909 7b0a 0909  SK_THREAD...{...
    │ │ │ -00058d40: 0973 7464 3a3a 756e 6971 7565 5f6c 6f63  .std::unique_loc
    │ │ │ -00058d50: 6b26 6c74 3b73 7464 3a3a 6d75 7465 7826  k<std::mutex&
    │ │ │ -00058d60: 6774 3b20 6c28 6d5f 6a6f 625f 6d75 7465  gt; l(m_job_mute
    │ │ │ -00058d70: 7829 3b0a 0a09 0909 444c 4f47 2822 7065  x);.....DLOG("pe
    │ │ │ -00058d80: 7266 6f72 6d5f 6a6f 6220 6a6f 623a 2025  rform_job job: %
    │ │ │ -00058d90: 7320 2820 2573 2573 2920 7069 6563 653a  s ( %s%s) piece:
    │ │ │ -00058da0: 2025 6420 6f66 6673 6574 3a20 2564 206f   %d offset: %d o
    │ │ │ -00058db0: 7574 7374 616e 6469 6e67 3a20 2564 5c6e  utstanding: %d\n
    │ │ │ -00058dc0: 220a 0909 0909 2c20 6a6f 625f 6163 7469  "....., job_acti
    │ │ │ -00058dd0: 6f6e 5f6e 616d 655b 6a2d 2667 743b 6163  on_name[j->ac
    │ │ │ -00058de0: 7469 6f6e 5d0a 0909 0909 2c20 286a 2d26  tion]....., (j-&
    │ │ │ -00058df0: 6774 3b66 6c61 6773 2026 616d 703b 206d  gt;flags & m
    │ │ │ -00058e00: 6d61 705f 6469 736b 5f6a 6f62 3a3a 6665  map_disk_job::fe
    │ │ │ -00058e10: 6e63 6529 203f 2022 6665 6e63 6520 223a  nce) ? "fence ":
    │ │ │ -00058e20: 2022 220a 0909 0909 2c20 286a 2d26 6774   ""....., (j->
    │ │ │ -00058e30: 3b66 6c61 6773 2026 616d 703b 206d 6d61  ;flags & mma
    │ │ │ -00058e40: 705f 6469 736b 5f6a 6f62 3a3a 666f 7263  p_disk_job::forc
    │ │ │ -00058e50: 655f 636f 7079 2920 3f20 2266 6f72 6365  e_copy) ? "force
    │ │ │ -00058e60: 5f63 6f70 7920 223a 2022 220a 0909 0909  _copy ": "".....
    │ │ │ -00058e70: 2c20 7374 6174 6963 5f63 6173 7426 6c74  , static_cast<
    │ │ │ -00058e80: 3b69 6e74 2667 743b 286a 2d26 6774 3b70  ;int>(j->p
    │ │ │ -00058e90: 6965 6365 292c 206a 2d26 6774 3b64 2e69  iece), j->d.i
    │ │ │ -00058ea0: 6f2e 6f66 6673 6574 0a09 0909 092c 206a  o.offset....., j
    │ │ │ -00058eb0: 2d26 6774 3b73 746f 7261 6765 203f 206a  ->storage ? j
    │ │ │ -00058ec0: 2d26 6774 3b73 746f 7261 6765 2d26 6774  ->storage->
    │ │ │ -00058ed0: 3b6e 756d 5f6f 7574 7374 616e 6469 6e67  ;num_outstanding
    │ │ │ -00058ee0: 5f6a 6f62 7328 2920 3a20 2d31 293b 0a09  _jobs() : -1);..
    │ │ │ -00058ef0: 097d 0a23 656e 6469 660a 0a09 0973 7464  .}.#endif....std
    │ │ │ -00058f00: 3a3a 7368 6172 6564 5f70 7472 266c 743b  ::shared_ptr<
    │ │ │ -00058f10: 6d6d 6170 5f73 746f 7261 6765 2667 743b  mmap_storage>
    │ │ │ -00058f20: 2073 746f 7261 6765 203d 206a 2d26 6774   storage = j->
    │ │ │ -00058f30: 3b73 746f 7261 6765 3b0a 0a09 0954 4f52  ;storage;....TOR
    │ │ │ -00058f40: 5245 4e54 5f41 5353 4552 5428 7374 6174  RENT_ASSERT(stat
    │ │ │ -00058f50: 6963 5f63 6173 7426 6c74 3b69 6e74 2667  ic_cast<int&g
    │ │ │ -00058f60: 743b 286a 2d26 6774 3b61 6374 696f 6e29  t;(j->action)
    │ │ │ -00058f70: 2026 6c74 3b20 696e 7428 6a6f 625f 6675   < int(job_fu
    │ │ │ -00058f80: 6e63 7469 6f6e 732e 7369 7a65 2829 2929  nctions.size()))
    │ │ │ -00058f90: 3b0a 0a09 096d 5f73 7461 7473 5f63 6f75  ;....m_stats_cou
    │ │ │ -00058fa0: 6e74 6572 732e 696e 635f 7374 6174 735f  nters.inc_stats_
    │ │ │ -00058fb0: 636f 756e 7465 7228 636f 756e 7465 7273  counter(counters
    │ │ │ -00058fc0: 3a3a 6e75 6d5f 7275 6e6e 696e 675f 6469  ::num_running_di
    │ │ │ -00058fd0: 736b 5f6a 6f62 732c 2031 293b 0a0a 0909  sk_jobs, 1);....
    │ │ │ -00058fe0: 2f2f 2063 616c 6c20 6469 736b 2066 756e  // call disk fun
    │ │ │ -00058ff0: 6374 696f 6e0a 3c64 6976 2073 7479 6c65  ction.
    ..status_t r │ │ │ -00059030: 6574 203d 2073 7461 7475 735f 743a 3a6e et = status_t::n │ │ │ -00059040: 6f5f 6572 726f 723b 0a3c 2f64 6976 3e09 o_error;.
    . │ │ │ -00059050: 0974 7279 0a09 097b 0a09 0909 696e 7420 .try...{....int │ │ │ -00059060: 636f 6e73 7420 6964 7820 3d20 7374 6174 const idx = stat │ │ │ -00059070: 6963 5f63 6173 7426 6c74 3b69 6e74 2667 ic_cast<int&g │ │ │ -00059080: 743b 286a 2d26 6774 3b61 6374 696f 6e29 t;(j->action) │ │ │ -00059090: 3b0a 0909 0972 6574 203d 2028 7468 6973 ;....ret = (this │ │ │ -000590a0: 2d26 6774 3b2a 286a 6f62 5f66 756e 6374 ->*(job_funct │ │ │ -000590b0: 696f 6e73 5b73 7461 7469 635f 6361 7374 ions[static_cast │ │ │ -000590c0: 266c 743b 7374 643a 3a73 697a 655f 7426 <std::size_t& │ │ │ -000590d0: 6774 3b28 6964 7829 5d29 2928 6a29 3b0a gt;(idx)]))(j);. │ │ │ -000590e0: 0909 7d0a 0909 6361 7463 6820 2862 6f6f ..}...catch (boo │ │ │ -000590f0: 7374 3a3a 7379 7374 656d 3a3a 7379 7374 st::system::syst │ │ │ -00059100: 656d 5f65 7272 6f72 2063 6f6e 7374 2661 em_error const&a │ │ │ -00059110: 6d70 3b20 6572 7229 0a09 097b 0a09 0909 mp; err)...{.... │ │ │ -00059120: 7265 7420 3d20 7374 6174 7573 5f74 3a3a ret = status_t:: │ │ │ -00059130: 6661 7461 6c5f 6469 736b 5f65 7272 6f72 fatal_disk_error │ │ │ -00059140: 3b0a 0909 096a 2d26 6774 3b65 7272 6f72 ;....j->error │ │ │ -00059150: 2e65 6320 3d20 6572 722e 636f 6465 2829 .ec = err.code() │ │ │ -00059160: 3b0a 0909 096a 2d26 6774 3b65 7272 6f72 ;....j->error │ │ │ -00059170: 2e6f 7065 7261 7469 6f6e 203d 206f 7065 .operation = ope │ │ │ -00059180: 7261 7469 6f6e 5f74 3a3a 6578 6365 7074 ration_t::except │ │ │ -00059190: 696f 6e3b 0a09 097d 0a09 0963 6174 6368 ion;...}...catch │ │ │ -000591a0: 2028 7374 643a 3a62 6164 5f61 6c6c 6f63 (std::bad_alloc │ │ │ -000591b0: 2063 6f6e 7374 2661 6d70 3b29 0a09 097b const&)...{ │ │ │ -000591c0: 0a09 0909 7265 7420 3d20 7374 6174 7573 ....ret = status │ │ │ -000591d0: 5f74 3a3a 6661 7461 6c5f 6469 736b 5f65 _t::fatal_disk_e │ │ │ -000591e0: 7272 6f72 3b0a 0909 096a 2d26 6774 3b65 rror;....j->e │ │ │ -000591f0: 7272 6f72 2e65 6320 3d20 6572 726f 7273 rror.ec = errors │ │ │ -00059200: 3a3a 6e6f 5f6d 656d 6f72 793b 0a09 0909 ::no_memory;.... │ │ │ -00059210: 6a2d 2667 743b 6572 726f 722e 6f70 6572 j->error.oper │ │ │ -00059220: 6174 696f 6e20 3d20 6f70 6572 6174 696f ation = operatio │ │ │ -00059230: 6e5f 743a 3a65 7863 6570 7469 6f6e 3b0a n_t::exception;. │ │ │ -00059240: 0909 7d0a 0909 6361 7463 6820 2873 7464 ..}...catch (std │ │ │ -00059250: 3a3a 6578 6365 7074 696f 6e20 636f 6e73 ::exception cons │ │ │ -00059260: 7426 616d 703b 290a 0909 7b0a 0909 0972 t&)...{....r │ │ │ -00059270: 6574 203d 2073 7461 7475 735f 743a 3a66 et = status_t::f │ │ │ -00059280: 6174 616c 5f64 6973 6b5f 6572 726f 723b atal_disk_error; │ │ │ -00059290: 0a09 0909 6a2d 2667 743b 6572 726f 722e ....j->error. │ │ │ -000592a0: 6563 203d 2062 6f6f 7374 3a3a 6173 696f ec = boost::asio │ │ │ -000592b0: 3a3a 6572 726f 723a 3a66 6175 6c74 3b0a ::error::fault;. │ │ │ -000592c0: 0909 096a 2d26 6774 3b65 7272 6f72 2e6f ...j->error.o │ │ │ -000592d0: 7065 7261 7469 6f6e 203d 206f 7065 7261 peration = opera │ │ │ -000592e0: 7469 6f6e 5f74 3a3a 6578 6365 7074 696f tion_t::exceptio │ │ │ -000592f0: 6e3b 0a09 097d 0a0a 0909 2f2f 206e 6f74 n;...}....// not │ │ │ -00059300: 6520 7468 6174 202d 3220 6572 726f 7273 e that -2 errors │ │ │ -00059310: 2061 7265 204f 4b0a 0909 544f 5252 454e are OK...TORREN │ │ │ -00059320: 545f 4153 5345 5254 2872 6574 2021 3d20 T_ASSERT(ret != │ │ │ -00059330: 7374 6174 7573 5f74 3a3a 6661 7461 6c5f status_t::fatal_ │ │ │ -00059340: 6469 736b 5f65 7272 6f72 0a09 0909 7c7c disk_error....|| │ │ │ -00059350: 2028 6a2d 2667 743b 6572 726f 722e 6563 (j->error.ec │ │ │ -00059360: 2026 616d 703b 2661 6d70 3b20 6a2d 2667 && j-&g │ │ │ -00059370: 743b 6572 726f 722e 6f70 6572 6174 696f t;error.operatio │ │ │ -00059380: 6e20 213d 206f 7065 7261 7469 6f6e 5f74 n != operation_t │ │ │ -00059390: 3a3a 756e 6b6e 6f77 6e29 293b 0a0a 0909 ::unknown));.... │ │ │ -000593a0: 6d5f 7374 6174 735f 636f 756e 7465 7273 m_stats_counters │ │ │ -000593b0: 2e69 6e63 5f73 7461 7473 5f63 6f75 6e74 .inc_stats_count │ │ │ -000593c0: 6572 2863 6f75 6e74 6572 733a 3a6e 756d er(counters::num │ │ │ -000593d0: 5f72 756e 6e69 6e67 5f64 6973 6b5f 6a6f _running_disk_jo │ │ │ -000593e0: 6273 2c20 2d31 293b 0a0a 3c2f 7072 653e bs, -1);..
    │ │ │ -000593f0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -00059420: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00059430: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/mmap │ │ │ -00059460: 5f64 6973 6b5f 696f 2e63 7070 3a31 3031 _disk_io.cpp:101 │ │ │ -00059470: 373c 2f61 3e3c 2f74 643e 3c74 643e 7468 7th │ │ │ -00059480: 6973 2069 7320 706f 7465 6e74 6961 6c6c is is potentiall │ │ │ -00059490: 7920 7665 7279 2065 7870 656e 7369 7665 y very expensive │ │ │ -000594a0: 2e20 4f6e 6520 7761 7920 746f 2073 6f6c . One way to sol │ │ │ -000594b0: 7665 2069 7420 776f 756c 6420 6265 2074 ve it would be t │ │ │ -000594c0: 6f20 6861 7665 2061 2066 656e 6365 2066 o have a fence f │ │ │ -000594d0: 6f72 206a 7573 7420 7468 6973 206f 6e65 or just this one │ │ │ -000594e0: 2070 6965 6365 2e20 6275 7420 6974 2068 piece. but it h │ │ │ -000594f0: 6172 646c 7920 7365 656d 7320 776f 7274 ardly seems wort │ │ │ -00059500: 6820 7468 6520 636f 6d70 6c65 7869 7479 h the complexity │ │ │ -00059510: 2061 6e64 2063 6f73 7420 6a75 7374 2066 and cost just f │ │ │ -00059520: 6f72 2074 6865 2065 6467 6520 6361 7365 or the edge case │ │ │ -00059530: 206f 6620 7265 6365 6976 696e 6720 6120 of receiving a │ │ │ -00059540: 636f 7272 7570 7420 7069 6563 653c 2f74 corrupt piece

    this │ │ │ -000595a0: 6973 2070 6f74 656e 7469 616c 6c79 2076 is potentially v │ │ │ -000595b0: 6572 7920 6578 7065 6e73 6976 652e 204f ery expensive. O │ │ │ -000595c0: 6e65 2077 6179 2074 6f20 736f 6c76 650a ne way to solve. │ │ │ -000595d0: 6974 2077 6f75 6c64 2062 6520 746f 2068 it would be to h │ │ │ -000595e0: 6176 6520 6120 6665 6e63 6520 666f 7220 ave a fence for │ │ │ -000595f0: 6a75 7374 2074 6869 7320 6f6e 6520 7069 just this one pi │ │ │ -00059600: 6563 652e 0a62 7574 2069 7420 6861 7264 ece..but it hard │ │ │ -00059610: 6c79 2073 6565 6d73 2077 6f72 7468 2074 ly seems worth t │ │ │ -00059620: 6865 2063 6f6d 706c 6578 6974 7920 616e he complexity an │ │ │ -00059630: 6420 636f 7374 206a 7573 7420 666f 7220 d cost just for │ │ │ -00059640: 7468 6520 6564 6765 0a63 6173 6520 6f66 the edge.case of │ │ │ -00059650: 2072 6563 6569 7669 6e67 2061 2063 6f72 receiving a cor │ │ │ -00059660: 7275 7074 2070 6965 6365 3c2f 6832 3e3c rupt piece

    < │ │ │ -00059670: 6834 3e2e 2e2f 7372 632f 6d6d 6170 5f64 h4>../src/mmap_d │ │ │ -00059680: 6973 6b5f 696f 2e63 7070 3a31 3031 373c isk_io.cpp:1017< │ │ │ -00059690: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -000596d0: 6175 783a 3a6d 6d61 705f 6469 736b 5f6a  aux::mmap_disk_j
    │ │ │ -000596e0: 6f62 2a20 6a20 3d20 6d5f 6a6f 625f 706f  ob* j = m_job_po
    │ │ │ -000596f0: 6f6c 2e61 6c6c 6f63 6174 655f 6a6f 6228  ol.allocate_job(
    │ │ │ -00059700: 6175 783a 3a6a 6f62 5f61 6374 696f 6e5f  aux::job_action_
    │ │ │ -00059710: 743a 3a66 696c 655f 7072 696f 7269 7479  t::file_priority
    │ │ │ -00059720: 293b 0a09 096a 2d26 6774 3b73 746f 7261  );...j->stora
    │ │ │ -00059730: 6765 203d 206d 5f74 6f72 7265 6e74 735b  ge = m_torrents[
    │ │ │ -00059740: 7374 6f72 6167 655d 2d26 6774 3b73 6861  storage]->sha
    │ │ │ -00059750: 7265 645f 6672 6f6d 5f74 6869 7328 293b  red_from_this();
    │ │ │ -00059760: 0a09 096a 2d26 6774 3b61 7267 756d 656e  ...j->argumen
    │ │ │ -00059770: 7420 3d20 7374 643a 3a6d 6f76 6528 7072  t = std::move(pr
    │ │ │ -00059780: 696f 7329 3b0a 0909 6a2d 2667 743b 6361  ios);...j->ca
    │ │ │ -00059790: 6c6c 6261 636b 203d 2073 7464 3a3a 6d6f  llback = std::mo
    │ │ │ -000597a0: 7665 2868 616e 646c 6572 293b 0a0a 0909  ve(handler);....
    │ │ │ -000597b0: 6164 645f 6665 6e63 655f 6a6f 6228 6a29  add_fence_job(j)
    │ │ │ -000597c0: 3b0a 097d 0a0a 0976 6f69 6420 6d6d 6170  ;..}...void mmap
    │ │ │ -000597d0: 5f64 6973 6b5f 696f 3a3a 6173 796e 635f  _disk_io::async_
    │ │ │ -000597e0: 636c 6561 725f 7069 6563 6528 7374 6f72  clear_piece(stor
    │ │ │ -000597f0: 6167 655f 696e 6465 785f 7420 636f 6e73  age_index_t cons
    │ │ │ -00059800: 7420 7374 6f72 6167 650a 0909 2c20 7069  t storage..., pi
    │ │ │ -00059810: 6563 655f 696e 6465 785f 7420 636f 6e73  ece_index_t cons
    │ │ │ -00059820: 7420 696e 6465 782c 2073 7464 3a3a 6675  t index, std::fu
    │ │ │ -00059830: 6e63 7469 6f6e 266c 743b 766f 6964 2870  nction<void(p
    │ │ │ -00059840: 6965 6365 5f69 6e64 6578 5f74 2926 6774  iece_index_t)>
    │ │ │ -00059850: 3b20 6861 6e64 6c65 7229 0a09 7b0a 0909  ; handler)..{...
    │ │ │ -00059860: 6175 783a 3a6d 6d61 705f 6469 736b 5f6a  aux::mmap_disk_j
    │ │ │ -00059870: 6f62 2a20 6a20 3d20 6d5f 6a6f 625f 706f  ob* j = m_job_po
    │ │ │ -00059880: 6f6c 2e61 6c6c 6f63 6174 655f 6a6f 6228  ol.allocate_job(
    │ │ │ -00059890: 6175 783a 3a6a 6f62 5f61 6374 696f 6e5f  aux::job_action_
    │ │ │ -000598a0: 743a 3a63 6c65 6172 5f70 6965 6365 293b  t::clear_piece);
    │ │ │ -000598b0: 0a09 096a 2d26 6774 3b73 746f 7261 6765  ...j->storage
    │ │ │ -000598c0: 203d 206d 5f74 6f72 7265 6e74 735b 7374   = m_torrents[st
    │ │ │ -000598d0: 6f72 6167 655d 2d26 6774 3b73 6861 7265  orage]->share
    │ │ │ -000598e0: 645f 6672 6f6d 5f74 6869 7328 293b 0a09  d_from_this();..
    │ │ │ -000598f0: 096a 2d26 6774 3b70 6965 6365 203d 2069  .j->piece = i
    │ │ │ -00059900: 6e64 6578 3b0a 0909 6a2d 2667 743b 6361  ndex;...j->ca
    │ │ │ -00059910: 6c6c 6261 636b 203d 2073 7464 3a3a 6d6f  llback = std::mo
    │ │ │ -00059920: 7665 2868 616e 646c 6572 293b 0a0a 0909  ve(handler);....
    │ │ │ -00059930: 2f2f 2072 6567 756c 6172 206a 6f62 7320  // regular jobs 
    │ │ │ -00059940: 6172 6520 6e6f 7420 6775 6172 616e 7465  are not guarante
    │ │ │ -00059950: 6564 2074 6f20 6265 2065 7865 6375 7465  ed to be execute
    │ │ │ -00059960: 6420 696e 2d6f 7264 6572 0a09 092f 2f20  d in-order...// 
    │ │ │ -00059970: 7369 6e63 6520 636c 6561 7220 7069 6563  since clear piec
    │ │ │ -00059980: 6520 6d75 7374 2067 7561 7261 6e74 6565  e must guarantee
    │ │ │ -00059990: 2074 6861 7420 616c 6c20 7772 6974 6520   that all write 
    │ │ │ -000599a0: 6a6f 6273 2074 6861 740a 0909 2f2f 2068  jobs that...// h
    │ │ │ -000599b0: 6176 6520 6265 656e 2069 7373 7565 6420  ave been issued 
    │ │ │ -000599c0: 6669 6e69 7368 2062 6566 6f72 6520 7468  finish before th
    │ │ │ -000599d0: 6520 636c 6561 7220 7069 6563 6520 6a6f  e clear piece jo
    │ │ │ -000599e0: 6220 636f 6d70 6c65 7465 730a 0a3c 6469  b completes...
    < │ │ │ -00059a50: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00059a60: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00059a90: 7372 632f 6d6d 6170 5f64 6973 6b5f 696f src/mmap_disk_io │ │ │ -00059aa0: 2e63 7070 3a31 3032 323c 2f61 3e3c 2f74 .cpp:1022Perhaps th │ │ │ -00059ac0: 6520 6a6f 6220 7175 6575 6520 636f 756c e job queue coul │ │ │ -00059ad0: 6420 6265 2074 7261 7665 7273 6564 2061 d be traversed a │ │ │ -00059ae0: 6e64 2061 6c6c 206a 6f62 7320 666f 7220 nd all jobs for │ │ │ -00059af0: 7468 6973 2070 6965 6365 2063 6f75 6c64 this piece could │ │ │ -00059b00: 2062 6520 6361 6e63 656c 6c65 642e 2049 be cancelled. I │ │ │ -00059b10: 6620 7468 6572 6520 6172 6520 6e6f 2074 f there are no t │ │ │ -00059b20: 6872 6561 6473 2063 7572 7265 6e74 6c79 hreads currently │ │ │ -00059b30: 2077 7269 7469 6e67 2074 6f20 7468 6973 writing to this │ │ │ -00059b40: 2070 6965 6365 2c20 7765 2063 6f75 6c64 piece, we could │ │ │ -00059b50: 2073 6b69 7020 7468 6520 6665 6e63 6520 skip the fence │ │ │ -00059b60: 616c 746f 6765 7468 6572 3c2f 7464 3e3c altogether< │ │ │ -00059b70: 2f74 723e 3c74 7220 6964 3d22 3231 3022 /tr>

    Perhaps │ │ │ -00059bc0: 7468 6520 6a6f 6220 7175 6575 6520 636f the job queue co │ │ │ -00059bd0: 756c 6420 6265 2074 7261 7665 7273 6564 uld be traversed │ │ │ -00059be0: 2061 6e64 2061 6c6c 206a 6f62 7320 666f and all jobs fo │ │ │ -00059bf0: 7220 7468 6973 0a70 6965 6365 2063 6f75 r this.piece cou │ │ │ -00059c00: 6c64 2062 6520 6361 6e63 656c 6c65 642e ld be cancelled. │ │ │ -00059c10: 2049 6620 7468 6572 6520 6172 6520 6e6f If there are no │ │ │ -00059c20: 2074 6872 6561 6473 2063 7572 7265 6e74 threads current │ │ │ -00059c30: 6c79 2077 7269 7469 6e67 0a74 6f20 7468 ly writing.to th │ │ │ -00059c40: 6973 2070 6965 6365 2c20 7765 2063 6f75 is piece, we cou │ │ │ -00059c50: 6c64 2073 6b69 7020 7468 6520 6665 6e63 ld skip the fenc │ │ │ -00059c60: 6520 616c 746f 6765 7468 6572 3c2f 6832 e altogether

    ../src/mmap │ │ │ -00059c80: 5f64 6973 6b5f 696f 2e63 7070 3a31 3032 _disk_io.cpp:102 │ │ │ -00059c90: 323c 2f68 343e 3c70 7265 2073 7479 6c65 2

    │ │ │ -00059cd0: 0909 6a2d 2667 743b 7374 6f72 6167 6520  ..j->storage 
    │ │ │ -00059ce0: 3d20 6d5f 746f 7272 656e 7473 5b73 746f  = m_torrents[sto
    │ │ │ -00059cf0: 7261 6765 5d2d 2667 743b 7368 6172 6564  rage]->shared
    │ │ │ -00059d00: 5f66 726f 6d5f 7468 6973 2829 3b0a 0909  _from_this();...
    │ │ │ -00059d10: 6a2d 2667 743b 6172 6775 6d65 6e74 203d  j->argument =
    │ │ │ -00059d20: 2073 7464 3a3a 6d6f 7665 2870 7269 6f73   std::move(prios
    │ │ │ -00059d30: 293b 0a09 096a 2d26 6774 3b63 616c 6c62  );...j->callb
    │ │ │ -00059d40: 6163 6b20 3d20 7374 643a 3a6d 6f76 6528  ack = std::move(
    │ │ │ -00059d50: 6861 6e64 6c65 7229 3b0a 0a09 0961 6464  handler);....add
    │ │ │ -00059d60: 5f66 656e 6365 5f6a 6f62 286a 293b 0a09  _fence_job(j);..
    │ │ │ -00059d70: 7d0a 0a09 766f 6964 206d 6d61 705f 6469  }...void mmap_di
    │ │ │ -00059d80: 736b 5f69 6f3a 3a61 7379 6e63 5f63 6c65  sk_io::async_cle
    │ │ │ -00059d90: 6172 5f70 6965 6365 2873 746f 7261 6765  ar_piece(storage
    │ │ │ -00059da0: 5f69 6e64 6578 5f74 2063 6f6e 7374 2073  _index_t const s
    │ │ │ -00059db0: 746f 7261 6765 0a09 092c 2070 6965 6365  torage..., piece
    │ │ │ -00059dc0: 5f69 6e64 6578 5f74 2063 6f6e 7374 2069  _index_t const i
    │ │ │ -00059dd0: 6e64 6578 2c20 7374 643a 3a66 756e 6374  ndex, std::funct
    │ │ │ -00059de0: 696f 6e26 6c74 3b76 6f69 6428 7069 6563  ion<void(piec
    │ │ │ -00059df0: 655f 696e 6465 785f 7429 2667 743b 2068  e_index_t)> h
    │ │ │ -00059e00: 616e 646c 6572 290a 097b 0a09 0961 7578  andler)..{...aux
    │ │ │ -00059e10: 3a3a 6d6d 6170 5f64 6973 6b5f 6a6f 622a  ::mmap_disk_job*
    │ │ │ -00059e20: 206a 203d 206d 5f6a 6f62 5f70 6f6f 6c2e   j = m_job_pool.
    │ │ │ -00059e30: 616c 6c6f 6361 7465 5f6a 6f62 2861 7578  allocate_job(aux
    │ │ │ -00059e40: 3a3a 6a6f 625f 6163 7469 6f6e 5f74 3a3a  ::job_action_t::
    │ │ │ -00059e50: 636c 6561 725f 7069 6563 6529 3b0a 0909  clear_piece);...
    │ │ │ -00059e60: 6a2d 2667 743b 7374 6f72 6167 6520 3d20  j->storage = 
    │ │ │ -00059e70: 6d5f 746f 7272 656e 7473 5b73 746f 7261  m_torrents[stora
    │ │ │ -00059e80: 6765 5d2d 2667 743b 7368 6172 6564 5f66  ge]->shared_f
    │ │ │ -00059e90: 726f 6d5f 7468 6973 2829 3b0a 0909 6a2d  rom_this();...j-
    │ │ │ -00059ea0: 2667 743b 7069 6563 6520 3d20 696e 6465  >piece = inde
    │ │ │ -00059eb0: 783b 0a09 096a 2d26 6774 3b63 616c 6c62  x;...j->callb
    │ │ │ -00059ec0: 6163 6b20 3d20 7374 643a 3a6d 6f76 6528  ack = std::move(
    │ │ │ -00059ed0: 6861 6e64 6c65 7229 3b0a 0a09 092f 2f20  handler);....// 
    │ │ │ -00059ee0: 7265 6775 6c61 7220 6a6f 6273 2061 7265  regular jobs are
    │ │ │ -00059ef0: 206e 6f74 2067 7561 7261 6e74 6565 6420   not guaranteed 
    │ │ │ -00059f00: 746f 2062 6520 6578 6563 7574 6564 2069  to be executed i
    │ │ │ -00059f10: 6e2d 6f72 6465 720a 0909 2f2f 2073 696e  n-order...// sin
    │ │ │ -00059f20: 6365 2063 6c65 6172 2070 6965 6365 206d  ce clear piece m
    │ │ │ -00059f30: 7573 7420 6775 6172 616e 7465 6520 7468  ust guarantee th
    │ │ │ -00059f40: 6174 2061 6c6c 2077 7269 7465 206a 6f62  at all write job
    │ │ │ -00059f50: 7320 7468 6174 0a09 092f 2f20 6861 7665  s that...// have
    │ │ │ -00059f60: 2062 6565 6e20 6973 7375 6564 2066 696e   been issued fin
    │ │ │ -00059f70: 6973 6820 6265 666f 7265 2074 6865 2063  ish before the c
    │ │ │ -00059f80: 6c65 6172 2070 6965 6365 206a 6f62 2063  lear piece job c
    │ │ │ -00059f90: 6f6d 706c 6574 6573 0a0a 0a3c 6469 7620  ompletes...
    ..add_f │ │ │ -00059fd0: 656e 6365 5f6a 6f62 286a 293b 0a3c 2f64 ence_job(j);..}...status_t │ │ │ -00059ff0: 206d 6d61 705f 6469 736b 5f69 6f3a 3a64 mmap_disk_io::d │ │ │ -0005a000: 6f5f 6861 7368 2861 7578 3a3a 6d6d 6170 o_hash(aux::mmap │ │ │ -0005a010: 5f64 6973 6b5f 6a6f 622a 206a 290a 097b _disk_job* j)..{ │ │ │ -0005a020: 0a09 092f 2f20 7765 2772 6520 6e6f 7420 ...// we're not │ │ │ -0005a030: 7573 696e 6720 6120 6361 6368 652e 2054 using a cache. T │ │ │ -0005a040: 6869 7320 6973 2074 6865 2073 696d 706c his is the simpl │ │ │ -0005a050: 6520 7061 7468 0a09 092f 2f20 6a75 7374 e path...// just │ │ │ -0005a060: 2072 6561 6420 7374 7261 6967 6874 2066 read straight f │ │ │ -0005a070: 726f 6d20 7468 6520 6669 6c65 0a09 0954 rom the file...T │ │ │ -0005a080: 4f52 5245 4e54 5f41 5353 4552 5428 6d5f ORRENT_ASSERT(m_ │ │ │ -0005a090: 6d61 6769 6320 3d3d 2030 7831 3333 3729 magic == 0x1337) │ │ │ -0005a0a0: 3b0a 0a09 0962 6f6f 6c20 636f 6e73 7420 ;....bool const │ │ │ -0005a0b0: 7631 203d 2062 6f6f 6c28 6a2d 2667 743b v1 = bool(j-> │ │ │ -0005a0c0: 666c 6167 7320 2661 6d70 3b20 6469 736b flags & disk │ │ │ -0005a0d0: 5f69 6e74 6572 6661 6365 3a3a 7631 5f68 _interface::v1_h │ │ │ -0005a0e0: 6173 6829 3b0a 0909 626f 6f6c 2063 6f6e ash);...bool con │ │ │ -0005a0f0: 7374 2076 3220 3d20 216a 2d26 6774 3b64 st v2 = !j->d │ │ │ -0005a100: 2e68 2e62 6c6f 636b 5f68 6173 6865 732e .h.block_hashes. │ │ │ -0005a110: 656d 7074 7928 293b 0a0a 0909 696e 7420 empty();....int │ │ │ -0005a120: 636f 6e73 7420 7069 6563 655f 7369 7a65 const piece_size │ │ │ -0005a130: 203d 2076 3120 3f20 6a2d 2667 743b 7374 = v1 ? j->st │ │ │ -0005a140: 6f72 6167 652d 2667 743b 6669 6c65 7328 orage->files( │ │ │ -0005a150: 292e 7069 6563 655f 7369 7a65 286a 2d26 ).piece_size(j-& │ │ │ -0005a160: 6774 3b70 6965 6365 2920 3a20 303b 0a09 gt;piece) : 0;.. │ │ │ -0005a170: 0969 6e74 2063 6f6e 7374 2070 6965 6365 .int const piece │ │ │ -0005a180: 5f73 697a 6532 203d 2076 3220 3f20 6a2d _size2 = v2 ? j- │ │ │ -0005a190: 2667 743b 7374 6f72 6167 652d 2667 743b >storage-> │ │ │ -0005a1a0: 6669 6c65 7328 292e 7069 6563 655f 7369 files().piece_si │ │ │ -0005a1b0: 7a65 3228 6a2d 2667 743b 7069 6563 6529 ze2(j->piece) │ │ │ -0005a1c0: 203a 2030 3b0a 0909 696e 7420 636f 6e73 : 0;...int cons │ │ │ -0005a1d0: 7420 626c 6f63 6b73 5f69 6e5f 7069 6563 t blocks_in_piec │ │ │ -0005a1e0: 6520 3d20 7631 203f 2028 7069 6563 655f e = v1 ? (piece_ │ │ │ -0005a1f0: 7369 7a65 202b 2064 6566 6175 6c74 5f62 size + default_b │ │ │ -0005a200: 6c6f 636b 5f73 697a 6520 2d20 3129 202f lock_size - 1) / │ │ │ -0005a210: 2064 6566 6175 6c74 5f62 6c6f 636b 5f73 default_block_s │ │ │ -0005a220: 697a 6520 3a20 303b 0a09 0969 6e74 2063 ize : 0;...int c │ │ │ -0005a230: 6f6e 7374 2062 6c6f 636b 735f 696e 5f70 onst blocks_in_p │ │ │ -0005a240: 6965 6365 3220 3d20 7632 203f 206a 2d26 iece2 = v2 ? j-& │ │ │ -0005a250: 6774 3b73 746f 7261 6765 2d26 6774 3b66 gt;storage->f │ │ │ -0005a260: 696c 6573 2829 2e62 6c6f 636b 735f 696e iles().blocks_in │ │ │ -0005a270: 5f70 6965 6365 3228 6a2d 2667 743b 7069 _piece2(j->pi │ │ │ -0005a280: 6563 6529 203a 2030 3b0a 0909 6175 783a ece) : 0;...aux: │ │ │ -0005a290: 3a6f 7065 6e5f 6d6f 6465 5f74 2063 6f6e :open_mode_t con │ │ │ -0005a2a0: 7374 2066 696c 655f 6d6f 6465 203d 2066 st file_mode = f │ │ │ -0005a2b0: 696c 655f 6d6f 6465 5f66 6f72 5f6a 6f62 ile_mode_for_job │ │ │ -0005a2c0: 286a 293b 0a0a 0909 544f 5252 454e 545f (j);....TORRENT_ │ │ │ -0005a2d0: 4153 5345 5254 2821 7632 207c 7c20 696e ASSERT(!v2 || in │ │ │ -0005a2e0: 7428 6a2d 2667 743b 642e 682e 626c 6f63 t(j->d.h.bloc │ │ │ -0005a2f0: 6b5f 6861 7368 6573 2e73 697a 6528 2929 k_hashes.size()) │ │ │ -0005a300: 2026 6774 3b3d 2062 6c6f 636b 735f 696e >= blocks_in │ │ │ -0005a310: 5f70 6965 6365 3229 3b0a 0909 544f 5252 _piece2);...TORR │ │ │ -0005a320: 454e 545f 4153 5345 5254 2876 3120 7c7c ENT_ASSERT(v1 || │ │ │ -0005a330: 2076 3229 3b0a 0a09 0968 6173 6865 7220 v2);....hasher │ │ │ -0005a340: 683b 0a09 0969 6e74 2072 6574 203d 2030 h;...int ret = 0 │ │ │ -0005a350: 3b0a 0909 696e 7420 6f66 6673 6574 203d ;...int offset = │ │ │ -0005a360: 2030 3b0a 0909 696e 7420 636f 6e73 7420 0;...int const │ │ │ -0005a370: 626c 6f63 6b73 5f74 6f5f 7265 6164 203d blocks_to_read = │ │ │ -0005a380: 2073 7464 3a3a 6d61 7828 626c 6f63 6b73 std::max(blocks │ │ │ -0005a390: 5f69 6e5f 7069 6563 652c 2062 6c6f 636b _in_piece, block │ │ │ -0005a3a0: 735f 696e 5f70 6965 6365 3229 3b0a 0909 s_in_piece2);... │ │ │ -0005a3b0: 7469 6d65 5f70 6f69 6e74 2063 6f6e 7374 time_point const │ │ │ -0005a3c0: 2073 7461 7274 5f74 696d 6520 3d20 636c start_time = cl │ │ │ -0005a3d0: 6f63 6b5f 7479 7065 3a3a 6e6f 7728 293b ock_type::now(); │ │ │ -0005a3e0: 0a09 0966 6f72 2028 696e 7420 6920 3d20 ...for (int i = │ │ │ -0005a3f0: 303b 2069 2026 6c74 3b20 626c 6f63 6b73 0; i < blocks │ │ │ -0005a400: 5f74 6f5f 7265 6164 3b20 2b2b 6929 0a09 _to_read; ++i).. │ │ │ -0005a410: 097b 0a09 0909 626f 6f6c 2063 6f6e 7374 .{....bool const │ │ │ -0005a420: 2076 325f 626c 6f63 6b20 3d20 6920 266c v2_block = i &l │ │ │ -0005a430: 743b 2062 6c6f 636b 735f 696e 5f70 6965 t; blocks_in_pie │ │ │ -0005a440: 6365 323b 0a0a 0909 0944 4c4f 4728 2264 ce2;.....DLOG("d │ │ │ -0005a450: 6f5f 6861 7368 3a20 7265 6164 696e 6720 o_hash: reading │ │ │ -0005a460: 2870 6965 6365 3a20 2564 2062 6c6f 636b (piece: %d block │ │ │ -0005a470: 3a20 2564 295c 6e22 2c20 696e 7428 6a2d : %d)\n", int(j- │ │ │ -0005a480: 2667 743b 7069 6563 6529 2c20 6929 3b0a >piece), i);. │ │ │ -0005a490: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0005a4a0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0005a4d0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -0005a500: 632f 6d65 726b 6c65 5f74 7265 652e 6370 c/merkle_tree.cp │ │ │ -0005a510: 703a 3131 303c 2f61 3e3c 2f74 643e 3c74 p:110in C++20, use │ │ │ -0005a530: 7374 643a 3a69 6465 6e74 6974 793c 2f74 std::identity

    in C+ │ │ │ -0005a590: 2b32 302c 2075 7365 2073 7464 3a3a 6964 +20, use std::id │ │ │ -0005a5a0: 656e 7469 7479 3c2f 6832 3e3c 6834 3e2e entity

    . │ │ │ -0005a5b0: 2e2f 7372 632f 6d65 726b 6c65 5f74 7265 ./src/merkle_tre │ │ │ -0005a5c0: 652e 6370 703a 3131 303c 2f68 343e 3c70 e.cpp:110

    ..alloca │ │ │ -0005a610: 7465 5f66 756c 6c28 293b 0a0a 0909 6d65 te_full();....me │ │ │ -0005a620: 726b 6c65 5f76 616c 6964 6174 655f 636f rkle_validate_co │ │ │ -0005a630: 7079 2874 2c20 6d5f 7472 6565 2c20 726f py(t, m_tree, ro │ │ │ -0005a640: 6f74 2829 2c20 6d5f 626c 6f63 6b5f 7665 ot(), m_block_ve │ │ │ -0005a650: 7269 6669 6564 293b 0a0a 0909 6c6f 6164 rified);....load │ │ │ -0005a660: 5f76 6572 6966 6965 645f 6269 7473 2876 _verified_bits(v │ │ │ -0005a670: 6572 6966 6965 6429 3b0a 0a09 096f 7074 erified);....opt │ │ │ -0005a680: 696d 697a 655f 7374 6f72 6167 6528 293b imize_storage(); │ │ │ -0005a690: 0a09 096f 7074 696d 697a 655f 7374 6f72 ...optimize_stor │ │ │ -0005a6a0: 6167 655f 7069 6563 655f 6c61 7965 7228 age_piece_layer( │ │ │ -0005a6b0: 293b 0a09 7d0a 0a09 766f 6964 206d 6572 );..}...void mer │ │ │ -0005a6c0: 6b6c 655f 7472 6565 3a3a 636c 6561 7228 kle_tree::clear( │ │ │ -0005a6d0: 290a 097b 0a09 096d 5f74 7265 652e 636c )..{...m_tree.cl │ │ │ -0005a6e0: 6561 7228 293b 0a09 096d 5f74 7265 652e ear();...m_tree. │ │ │ -0005a6f0: 7368 7269 6e6b 5f74 6f5f 6669 7428 293b shrink_to_fit(); │ │ │ -0005a700: 0a09 096d 5f62 6c6f 636b 5f76 6572 6966 ...m_block_verif │ │ │ -0005a710: 6965 642e 636c 6561 7228 293b 0a09 096d ied.clear();...m │ │ │ -0005a720: 5f6d 6f64 6520 3d20 6d6f 6465 5f74 3a3a _mode = mode_t:: │ │ │ -0005a730: 656d 7074 795f 7472 6565 3b0a 097d 0a0a empty_tree;..}.. │ │ │ -0005a740: 6e61 6d65 7370 6163 6520 7b0a 0a3c 6469 namespace {...stru │ │ │ -0005a780: 6374 2069 6465 6e74 6974 790a 3c2f 6469 ct identity..{...bool oper │ │ │ -0005a7a0: 6174 6f72 2829 2862 6f6f 6c20 6229 2063 ator()(bool b) c │ │ │ -0005a7b0: 6f6e 7374 207b 2072 6574 7572 6e20 623b onst { return b; │ │ │ -0005a7c0: 207d 0a09 7d3b 0a7d 0a0a 0976 6f69 6420 }..};.}...void │ │ │ -0005a7d0: 6d65 726b 6c65 5f74 7265 653a 3a6c 6f61 merkle_tree::loa │ │ │ -0005a7e0: 645f 7370 6172 7365 5f74 7265 6528 7370 d_sparse_tree(sp │ │ │ -0005a7f0: 616e 266c 743b 7368 6132 3536 5f68 6173 an<sha256_has │ │ │ -0005a800: 6820 636f 6e73 7426 6774 3b20 740a 0909 h const> t... │ │ │ -0005a810: 2c20 7374 643a 3a76 6563 746f 7226 6c74 , std::vector< │ │ │ -0005a820: 3b62 6f6f 6c26 6774 3b20 636f 6e73 7426 ;bool> const& │ │ │ -0005a830: 616d 703b 206d 6173 6b0a 0909 2c20 7374 amp; mask..., st │ │ │ -0005a840: 643a 3a76 6563 746f 7226 6c74 3b62 6f6f d::vector<boo │ │ │ -0005a850: 6c26 6774 3b20 636f 6e73 7426 616d 703b l> const& │ │ │ -0005a860: 2076 6572 6966 6965 6429 0a09 7b0a 0909 verified)..{... │ │ │ -0005a870: 494e 5641 5249 414e 545f 4348 4543 4b3b INVARIANT_CHECK; │ │ │ -0005a880: 0a0a 0909 2f2f 2054 6865 2073 697a 6520 ....// The size │ │ │ -0005a890: 6f66 2074 6865 206d 6173 6b20 7368 6f75 of the mask shou │ │ │ -0005a8a0: 6c64 206e 6f74 2065 7863 6565 6420 7468 ld not exceed th │ │ │ -0005a8b0: 6520 7369 7a65 206f 6620 7468 6520 7472 e size of the tr │ │ │ -0005a8c0: 6565 2c20 6275 7420 6120 6d61 736b 206c ee, but a mask l │ │ │ -0005a8d0: 6172 6765 7220 7468 616e 0a09 092f 2f20 arger than...// │ │ │ -0005a8e0: 7468 6520 7472 6565 2063 616e 2062 6520 the tree can be │ │ │ -0005a8f0: 656e 636f 756e 7465 7265 6420 696e 2074 encountered in t │ │ │ -0005a900: 6865 2022 7265 7375 6d65 2064 6174 6122 he "resume data" │ │ │ -0005a910: 2066 6f72 2073 6f6d 6520 7265 6173 6f6e for some reason │ │ │ -0005a920: 2c20 7065 7268 6170 7320 7468 6572 6520 , perhaps there │ │ │ -0005a930: 6973 0a09 092f 2f20 6120 6275 6720 696e is...// a bug in │ │ │ -0005a940: 2074 6865 2022 7265 7375 6d65 2064 6174 the "resume dat │ │ │ -0005a950: 6122 2067 656e 6572 6174 696f 6e20 616c a" generation al │ │ │ -0005a960: 676f 7269 7468 6d2e 0a09 092f 2f20 536f gorithm....// So │ │ │ -0005a970: 2077 6520 6a75 7374 2070 726f 6365 7373 we just process │ │ │ -0005a980: 206d 6173 6b20 6974 656d 7320 636f 756e mask items coun │ │ │ -0005a990: 7420 7570 2074 6f20 7472 6565 2073 697a t up to tree siz │ │ │ -0005a9a0: 652e 0a09 0969 6e74 2063 6f6e 7374 206d e....int const m │ │ │ -0005a9b0: 6173 6b5f 7369 7a65 203d 2069 6e74 2873 ask_size = int(s │ │ │ -0005a9c0: 7464 3a3a 6d69 6e28 6d61 736b 2e73 697a td::min(mask.siz │ │ │ -0005a9d0: 6528 292c 2073 697a 6528 2929 293b 0a0a e(), size()));.. │ │ │ -0005a9e0: 0909 696e 7420 636f 6e73 7420 6669 7273 ..int const firs │ │ │ -0005a9f0: 745f 626c 6f63 6b20 3d20 626c 6f63 6b5f t_block = block_ │ │ │ -0005aa00: 6c61 7965 725f 7374 6172 7428 293b 0a09 layer_start();.. │ │ │ -0005aa10: 0969 6e74 2063 6f6e 7374 2065 6e64 5f62 .int const end_b │ │ │ -0005aa20: 6c6f 636b 203d 2066 6972 7374 5f62 6c6f lock = first_blo │ │ │ -0005aa30: 636b 202b 206d 5f6e 756d 5f62 6c6f 636b ck + m_num_block │ │ │ -0005aa40: 733b 0a0a 0909 544f 5252 454e 545f 4153 s;....TORRENT_AS │ │ │ -0005aa50: 5345 5254 2866 6972 7374 5f62 6c6f 636b SERT(first_block │ │ │ -0005aa60: 2026 6c74 3b20 696e 7428 7369 7a65 2829 < int(size() │ │ │ -0005aa70: 2929 3b0a 0909 544f 5252 454e 545f 4153 ));...TORRENT_AS │ │ │ -0005aa80: 5345 5254 2865 6e64 5f62 6c6f 636b 2026 SERT(end_block & │ │ │ -0005aa90: 6c74 3b3d 2069 6e74 2873 697a 6528 2929 lt;= int(size()) │ │ │ -0005aaa0: 293b 0a0a 0909 2f2f 2069 6620 7468 6520 );....// if the │ │ │ -0005aab0: 6d61 736b 2063 6f76 6572 7320 616c 6c20 mask covers all │ │ │ -0005aac0: 626c 6f63 6b73 2c20 676f 2073 7472 6169 blocks, go strai │ │ │ -0005aad0: 6768 7420 746f 2062 6c6f 636b 5f6c 6179 ght to block_lay │ │ │ -0005aae0: 6572 0a09 092f 2f20 6d6f 6465 2c20 616e er...// mode, an │ │ │ -0005aaf0: 6420 7661 6c69 6461 7465 0a09 0969 6620 d validate...if │ │ │ -0005ab00: 2828 6669 7273 745f 626c 6f63 6b20 266c ((first_block &l │ │ │ -0005ab10: 743b 206d 6173 6b5f 7369 7a65 2920 2661 t; mask_size) &a │ │ │ -0005ab20: 6d70 3b26 616d 703b 2028 656e 645f 626c mp;& (end_bl │ │ │ -0005ab30: 6f63 6b20 266c 743b 3d20 6d61 736b 5f73 ock <= mask_s │ │ │ -0005ab40: 697a 6529 0a09 0909 2661 6d70 3b26 616d ize)....&&am │ │ │ -0005ab50: 703b 2073 7464 3a3a 616c 6c5f 6f66 286d p; std::all_of(m │ │ │ -0005ab60: 6173 6b2e 6265 6769 6e28 2920 2b20 6669 ask.begin() + fi │ │ │ -0005ab70: 7273 745f 626c 6f63 6b2c 206d 6173 6b2e rst_block, mask. │ │ │ -0005ab80: 6265 6769 6e28 2920 2b20 656e 645f 626c begin() + end_bl │ │ │ -0005ab90: 6f63 6b2c 2069 6465 6e74 6974 7928 2929 ock, identity()) │ │ │ -0005aba0: 290a 0909 7b0a 0909 092f 2f20 7468 6520 )...{....// the │ │ │ -0005abb0: 696e 6465 7820 696e 2074 2074 6861 7420 index in t that │ │ │ -0005abc0: 706f 696e 7473 2074 6f20 6669 7273 745f points to first_ │ │ │ -0005abd0: 626c 6f63 6b0a 0909 0961 7574 6f20 636f block....auto co │ │ │ -0005abe0: 6e73 7420 626c 6f63 6b5f 696e 6465 7820 nst block_index │ │ │ -0005abf0: 3d20 7374 643a 3a63 6f75 6e74 5f69 6628 = std::count_if( │ │ │ -0005ac00: 6d61 736b 2e62 6567 696e 2829 2c20 6d61 mask.begin(), ma │ │ │ -0005ac10: 736b 2e62 6567 696e 2829 202b 2066 6972 sk.begin() + fir │ │ │ -0005ac20: 7374 5f62 6c6f 636b 2c20 6964 656e 7469 st_block, identi │ │ │ -0005ac30: 7479 2829 293b 0a3c 2f70 7265 3e3c 2f74 ty());.

    relevanc │ │ │ -0005ac70: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/merkle_ │ │ │ -0005acb0: 7472 6565 2e63 7070 3a33 3239 3c2f 613e tree.cpp:329 │ │ │ -0005acc0: 3c2f 7464 3e3c 7464 3e74 6869 7320 6361 this ca │ │ │ -0005acd0: 6e20 6265 206f 7074 696d 697a 6564 2062 n be optimized b │ │ │ -0005ace0: 7920 7573 696e 6720 6d5f 7472 6565 2061 y using m_tree a │ │ │ -0005acf0: 7320 7374 6f72 6167 6520 746f 2066 696c s storage to fil │ │ │ -0005ad00: 6c20 7468 6973 2074 7265 6520 696e 746f l this tree into │ │ │ -0005ad10: 2c20 616e 6420 7468 656e 2063 6c65 6172 , and then clear │ │ │ -0005ad20: 2069 7420 6966 2074 6865 2068 6173 6865 it if the hashe │ │ │ -0005ad30: 7320 6661 696c 3c2f 7464 3e3c 2f74 723e s fail │ │ │ -0005ad40: 3c74 7220 6964 3d22 3231 3222 2073 7479 │ │ │ -0005ad70: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0005ad80: 3c68 323e 7468 6973 2063 616e 2062 6520

    this can be │ │ │ -0005ad90: 6f70 7469 6d69 7a65 6420 6279 2075 7369 optimized by usi │ │ │ -0005ada0: 6e67 206d 5f74 7265 6520 6173 2073 746f ng m_tree as sto │ │ │ -0005adb0: 7261 6765 2074 6f20 6669 6c6c 2074 6869 rage to fill thi │ │ │ -0005adc0: 730a 7472 6565 2069 6e74 6f2c 2061 6e64 s.tree into, and │ │ │ -0005add0: 2074 6865 6e20 636c 6561 7220 6974 2069 then clear it i │ │ │ -0005ade0: 6620 7468 6520 6861 7368 6573 2066 6169 f the hashes fai │ │ │ -0005adf0: 6c3c 2f68 323e 3c68 343e 2e2e 2f73 7263 l

    ../src │ │ │ -0005ae00: 2f6d 6572 6b6c 655f 7472 6565 2e63 7070 /merkle_tree.cpp │ │ │ -0005ae10: 3a33 3239 3c2f 6834 3e3c 7072 6520 7374 :329

    .{...INVARIAN
    │ │ │ -0005ae60: 545f 4348 4543 4b3b 0a0a 0909 2f2f 2061  T_CHECK;....// a
    │ │ │ -0005ae70: 7320 7765 2073 6574 2074 6865 2068 6173  s we set the has
    │ │ │ -0005ae80: 6865 7320 6f66 2069 6e74 6572 696f 7220  hes of interior 
    │ │ │ -0005ae90: 6e6f 6465 732c 2077 6520 6d61 7920 6265  nodes, we may be
    │ │ │ -0005aea0: 2061 626c 6520 746f 2076 616c 6964 6174   able to validat
    │ │ │ -0005aeb0: 650a 0909 2f2f 2062 6c6f 636b 2068 6173  e...// block has
    │ │ │ -0005aec0: 6865 7320 7468 6174 2077 6520 6861 6420  hes that we had 
    │ │ │ -0005aed0: 7369 6e63 6520 6561 726c 6965 722e 2041  since earlier. A
    │ │ │ -0005aee0: 6e79 2062 6c6f 636b 7320 7468 6174 2063  ny blocks that c
    │ │ │ -0005aef0: 616e 2062 650a 0909 2f2f 2076 616c 6964  an be...// valid
    │ │ │ -0005af00: 6174 6564 2c20 616e 6420 6661 696c 6564  ated, and failed
    │ │ │ -0005af10: 2c20 6172 6520 6164 6465 6420 746f 2074  , are added to t
    │ │ │ -0005af20: 6869 7320 6c69 7374 0a09 0961 6464 5f68  his list...add_h
    │ │ │ -0005af30: 6173 6865 735f 7265 7375 6c74 5f74 2072  ashes_result_t r
    │ │ │ -0005af40: 6574 3b0a 0a09 092f 2f20 7765 2061 6c72  et;....// we alr
    │ │ │ -0005af50: 6561 6479 2068 6176 6520 616c 6c20 6861  eady have all ha
    │ │ │ -0005af60: 7368 6573 0a09 0969 6620 286d 5f6d 6f64  shes...if (m_mod
    │ │ │ -0005af70: 6520 3d3d 206d 6f64 655f 743a 3a62 6c6f  e == mode_t::blo
    │ │ │ -0005af80: 636b 5f6c 6179 6572 290a 0909 7b0a 0909  ck_layer)...{...
    │ │ │ -0005af90: 092f 2f20 7369 6e63 6520 7765 2772 6520  .// since we're 
    │ │ │ -0005afa0: 616c 7265 6164 7920 6f6e 2074 6865 2062  already on the b
    │ │ │ -0005afb0: 6c6f 636b 206c 6179 6572 206d 6f64 652c  lock layer mode,
    │ │ │ -0005afc0: 2077 6520 6861 7665 2074 6865 2077 686f   we have the who
    │ │ │ -0005afd0: 6c65 0a09 0909 2f2f 2074 7265 652c 2061  le....// tree, a
    │ │ │ -0005afe0: 6e64 2077 6527 7665 2061 6c72 6561 6479  nd we've already
    │ │ │ -0005aff0: 2072 6570 6f72 7465 6420 616e 7920 7069   reported any pi
    │ │ │ -0005b000: 6563 6573 2061 7320 7061 7373 696e 6720  eces as passing 
    │ │ │ -0005b010: 7468 6174 206d 6179 0a09 0909 2f2f 2068  that may....// h
    │ │ │ -0005b020: 6176 6520 6578 6973 7465 6420 696e 2074  ave existed in t
    │ │ │ -0005b030: 6865 2074 7265 6520 7768 656e 2077 6520  he tree when we 
    │ │ │ -0005b040: 636f 6d70 6c65 7465 6420 6974 2e20 4174  completed it. At
    │ │ │ -0005b050: 2074 6869 7320 706f 696e 7420 6e6f 0a09   this point no..
    │ │ │ -0005b060: 0909 2f2f 206d 6f72 6520 7069 6563 6573  ..// more pieces
    │ │ │ -0005b070: 2073 686f 756c 6420 6265 2072 6570 6f72   should be repor
    │ │ │ -0005b080: 7465 6420 6173 2070 6173 7365 640a 0909  ted as passed...
    │ │ │ -0005b090: 0972 6574 7572 6e20 7265 743b 0a09 097d  .return ret;...}
    │ │ │ -0005b0a0: 0a0a 0909 616c 6c6f 6361 7465 5f66 756c  ....allocate_ful
    │ │ │ -0005b0b0: 6c28 293b 0a0a 3c64 6976 2073 7479 6c65  l();..
    ..int const │ │ │ -0005b0f0: 6c65 6166 5f63 6f75 6e74 203d 206d 6572 leaf_count = mer │ │ │ -0005b100: 6b6c 655f 6e75 6d5f 6c65 6166 7328 696e kle_num_leafs(in │ │ │ -0005b110: 7428 6861 7368 6573 2e73 697a 6528 2929 t(hashes.size()) │ │ │ -0005b120: 293b 0a3c 2f64 6976 3e09 0961 7578 3a3a );.
    ..aux:: │ │ │ -0005b130: 7665 6374 6f72 266c 743b 7368 6132 3536 vector<sha256 │ │ │ -0005b140: 5f68 6173 6826 6774 3b20 7472 6565 286d _hash> tree(m │ │ │ -0005b150: 6572 6b6c 655f 6e75 6d5f 6e6f 6465 7328 erkle_num_nodes( │ │ │ -0005b160: 6c65 6166 5f63 6f75 6e74 2929 3b0a 0909 leaf_count));... │ │ │ -0005b170: 7374 643a 3a63 6f70 7928 6861 7368 6573 std::copy(hashes │ │ │ -0005b180: 2e62 6567 696e 2829 2c20 6861 7368 6573 .begin(), hashes │ │ │ -0005b190: 2e65 6e64 2829 2c20 7472 6565 2e65 6e64 .end(), tree.end │ │ │ -0005b1a0: 2829 202d 206c 6561 665f 636f 756e 7429 () - leaf_count) │ │ │ -0005b1b0: 3b0a 0a09 092f 2f20 7468 6520 656e 6420 ;....// the end │ │ │ -0005b1c0: 6f66 2061 2066 696c 6520 6973 2061 2073 of a file is a s │ │ │ -0005b1d0: 7065 6369 616c 2063 6173 652c 2077 6520 pecial case, we │ │ │ -0005b1e0: 6d61 7920 6e65 6564 2074 6f20 7061 6420 may need to pad │ │ │ -0005b1f0: 7468 6520 6c65 6166 206c 6179 6572 0a09 the leaf layer.. │ │ │ -0005b200: 0969 6620 286c 6561 665f 636f 756e 7420 .if (leaf_count │ │ │ -0005b210: 2667 743b 2068 6173 6865 732e 7369 7a65 > hashes.size │ │ │ -0005b220: 2829 290a 0909 7b0a 0909 0969 6e74 2063 ())...{....int c │ │ │ -0005b230: 6f6e 7374 206c 6561 665f 6c61 7965 725f onst leaf_layer_ │ │ │ -0005b240: 7369 7a65 203d 206e 756d 5f6c 6561 6673 size = num_leafs │ │ │ -0005b250: 2829 3b0a 0909 092f 2f20 6173 7375 6d69 ();....// assumi │ │ │ -0005b260: 6e67 2075 6e63 6c65 5f68 6173 6865 7320 ng uncle_hashes │ │ │ -0005b270: 6c65 6164 2061 6c6c 2074 6865 2077 6179 lead all the way │ │ │ -0005b280: 2074 6f20 7468 6520 726f 6f74 2c20 7468 to the root, th │ │ │ -0005b290: 6579 2074 656c 6c20 7573 0a09 0909 2f2f ey tell us....// │ │ │ -0005b2a0: 2068 6f77 206d 616e 7920 6c61 7965 7273 how many layers │ │ │ -0005b2b0: 2064 6f77 6e20 7765 2061 7265 0a09 0909 down we are.... │ │ │ -0005b2c0: 696e 7420 636f 6e73 7420 696e 7365 7274 int const insert │ │ │ -0005b2d0: 5f6c 6179 6572 5f73 697a 6520 3d20 6c65 _layer_size = le │ │ │ -0005b2e0: 6166 5f63 6f75 6e74 2026 6c74 3b26 6c74 af_count << │ │ │ -0005b2f0: 3b20 756e 636c 655f 6861 7368 6573 2e73 ; uncle_hashes.s │ │ │ -0005b300: 697a 6528 293b 0a09 0909 6966 2028 6c65 ize();....if (le │ │ │ -0005b310: 6166 5f6c 6179 6572 5f73 697a 6520 213d af_layer_size != │ │ │ -0005b320: 2069 6e73 6572 745f 6c61 7965 725f 7369 insert_layer_si │ │ │ -0005b330: 7a65 290a 0909 097b 0a09 0909 0973 6861 ze)....{.....sha │ │ │ -0005b340: 3235 365f 6861 7368 2063 6f6e 7374 2070 256_hash const p │ │ │ -0005b350: 6164 5f68 6173 6820 3d20 6d65 726b 6c65 ad_hash = merkle │ │ │ -0005b360: 5f70 6164 286c 6561 665f 6c61 7965 725f _pad(leaf_layer_ │ │ │ -0005b370: 7369 7a65 2c20 696e 7365 7274 5f6c 6179 size, insert_lay │ │ │ -0005b380: 6572 5f73 697a 6529 3b0a 0909 0909 666f er_size);.....fo │ │ │ -0005b390: 7220 2869 6e74 2069 203d 2069 6e74 2868 r (int i = int(h │ │ │ -0005b3a0: 6173 6865 732e 7369 7a65 2829 293b 2069 ashes.size()); i │ │ │ -0005b3b0: 2026 6c74 3b20 6c65 6166 5f63 6f75 6e74 < leaf_count │ │ │ -0005b3c0: 3b20 2b2b 6929 0a09 0909 0909 7472 6565 ; ++i)......tree │ │ │ -0005b3d0: 5b74 7265 652e 656e 645f 696e 6465 7828 [tree.end_index( │ │ │ -0005b3e0: 2920 2d20 6c65 6166 5f63 6f75 6e74 202b ) - leaf_count + │ │ │ -0005b3f0: 2069 5d20 3d20 7061 645f 6861 7368 3b0a i] = pad_hash;. │ │ │ -0005b400: 0909 097d 0a09 097d 0a0a 0909 6d65 726b ...}...}....merk │ │ │ -0005b410: 6c65 5f66 696c 6c5f 7472 6565 2874 7265 le_fill_tree(tre │ │ │ -0005b420: 652c 206c 6561 665f 636f 756e 7429 3b0a e, leaf_count);. │ │ │ -0005b430: 0a09 0969 6e74 2063 6f6e 7374 2062 6173 ...int const bas │ │ │ -0005b440: 655f 6e75 6d5f 6c61 7965 7273 203d 206d e_num_layers = m │ │ │ -0005b450: 6572 6b6c 655f 6e75 6d5f 6c61 7965 7273 erkle_num_layers │ │ │ -0005b460: 286c 6561 665f 636f 756e 7429 3b0a 0a09 (leaf_count);... │ │ │ -0005b470: 092f 2f20 7468 6973 2069 7320 7468 6520 .// this is the │ │ │ -0005b480: 696e 6465 7820 6f66 2074 6865 206e 6f64 index of the nod │ │ │ -0005b490: 6520 7768 6572 6520 7765 276c 6c20 696e e where we'll in │ │ │ -0005b4a0: 7365 7274 2074 6865 2072 6f6f 7420 6f66 sert the root of │ │ │ -0005b4b0: 2074 6865 0a09 092f 2f20 7375 6274 7265 the...// subtre │ │ │ -0005b4c0: 6520 2874 7265 6529 2e20 4974 2773 2061 e (tree). It's a │ │ │ -0005b4d0: 6c73 6f20 7468 6520 6861 7368 2074 6865 lso the hash the │ │ │ -0005b4e0: 2075 6e63 6c65 5f68 6173 6865 7320 6172 uncle_hashes ar │ │ │ -0005b4f0: 6520 6865 7265 2074 6f20 7072 6f76 650a e here to prove. │ │ │ -0005b500: 0909 2f2f 2069 7320 7661 6c69 642e 0a09 ..// is valid... │ │ │ -0005b510: 0969 6e74 2063 6f6e 7374 2069 6e73 6572 .int const inser │ │ │ -0005b520: 745f 726f 6f74 5f69 6478 203d 2064 6573 t_root_idx = des │ │ │ -0005b530: 745f 7374 6172 745f 6964 7820 2667 743b t_start_idx > │ │ │ -0005b540: 2667 743b 2062 6173 655f 6e75 6d5f 6c61 > base_num_la │ │ │ -0005b550: 7965 7273 3b0a 0a09 092f 2f20 7374 6172 yers;....// star │ │ │ -0005b560: 7420 7769 7468 2076 616c 6964 6174 696e t with validatin │ │ │ -0005b570: 6720 7468 6520 7072 6f6f 6673 2c20 616e g the proofs, an │ │ │ -0005b580: 6420 696e 7365 7274 696e 6720 7468 656d d inserting them │ │ │ -0005b590: 2061 7320 7765 2067 6f2e 0a09 0969 6620 as we go....if │ │ │ -0005b5a0: 2821 6d65 726b 6c65 5f76 616c 6964 6174 (!merkle_validat │ │ │ -0005b5b0: 655f 616e 645f 696e 7365 7274 5f70 726f e_and_insert_pro │ │ │ -0005b5c0: 6f66 7328 6d5f 7472 6565 2c20 696e 7365 ofs(m_tree, inse │ │ │ -0005b5d0: 7274 5f72 6f6f 745f 6964 782c 2074 7265 rt_root_idx, tre │ │ │ -0005b5e0: 655b 305d 2c20 756e 636c 655f 6861 7368 e[0], uncle_hash │ │ │ -0005b5f0: 6573 2929 0a09 0909 7265 7475 726e 207b es))....return { │ │ │ -0005b600: 7d3b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f };.
    │ │ │ -0005b630: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -0005b640: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -0005b670: 2f73 7263 2f6d 6572 6b6c 655f 7472 6565 /src/merkle_tree │ │ │ -0005b680: 2e63 7070 3a33 3737 3c2f 613e 3c2f 7464 .cpp:377a piece out │ │ │ -0005b6a0: 7369 6465 206f 6620 7468 6973 2072 616e side of this ran │ │ │ -0005b6b0: 6765 206d 6179 2061 6c73 6f20 6661 696c ge may also fail │ │ │ -0005b6c0: 2c20 6966 206f 6e65 206f 6620 7468 6520 , if one of the │ │ │ -0005b6d0: 756e 636c 6520 6861 7368 6573 2069 7320 uncle hashes is │ │ │ -0005b6e0: 6174 2074 6865 206c 6179 6572 2072 6967 at the layer rig │ │ │ -0005b6f0: 6874 2061 626f 7665 2074 6865 2062 6c6f ht above the blo │ │ │ -0005b700: 636b 2068 6173 6865 733c 2f74 643e 3c2f ck hashes

    a piece o │ │ │ -0005b760: 7574 7369 6465 206f 6620 7468 6973 2072 utside of this r │ │ │ -0005b770: 616e 6765 206d 6179 2061 6c73 6f20 6661 ange may also fa │ │ │ -0005b780: 696c 2c20 6966 206f 6e65 206f 6620 7468 il, if one of th │ │ │ -0005b790: 6520 756e 636c 650a 6861 7368 6573 2069 e uncle.hashes i │ │ │ -0005b7a0: 7320 6174 2074 6865 206c 6179 6572 2072 s at the layer r │ │ │ -0005b7b0: 6967 6874 2061 626f 7665 2074 6865 2062 ight above the b │ │ │ -0005b7c0: 6c6f 636b 2068 6173 6865 733c 2f68 323e lock hashes

    │ │ │ -0005b7d0: 3c68 343e 2e2e 2f73 7263 2f6d 6572 6b6c

    ../src/merkl │ │ │ -0005b7e0: 655f 7472 6565 2e63 7070 3a33 3737 3c2f e_tree.cpp:377
    ..i
    │ │ │ -0005b830: 6e74 2063 6f6e 7374 2069 6e73 6572 745f  nt const insert_
    │ │ │ -0005b840: 726f 6f74 5f69 6478 203d 2064 6573 745f  root_idx = dest_
    │ │ │ -0005b850: 7374 6172 745f 6964 7820 2667 743b 2667  start_idx >&g
    │ │ │ -0005b860: 743b 2062 6173 655f 6e75 6d5f 6c61 7965  t; base_num_laye
    │ │ │ -0005b870: 7273 3b0a 0a09 092f 2f20 7374 6172 7420  rs;....// start 
    │ │ │ -0005b880: 7769 7468 2076 616c 6964 6174 696e 6720  with validating 
    │ │ │ -0005b890: 7468 6520 7072 6f6f 6673 2c20 616e 6420  the proofs, and 
    │ │ │ -0005b8a0: 696e 7365 7274 696e 6720 7468 656d 2061  inserting them a
    │ │ │ -0005b8b0: 7320 7765 2067 6f2e 0a09 0969 6620 2821  s we go....if (!
    │ │ │ -0005b8c0: 6d65 726b 6c65 5f76 616c 6964 6174 655f  merkle_validate_
    │ │ │ -0005b8d0: 616e 645f 696e 7365 7274 5f70 726f 6f66  and_insert_proof
    │ │ │ -0005b8e0: 7328 6d5f 7472 6565 2c20 696e 7365 7274  s(m_tree, insert
    │ │ │ -0005b8f0: 5f72 6f6f 745f 6964 782c 2074 7265 655b  _root_idx, tree[
    │ │ │ -0005b900: 305d 2c20 756e 636c 655f 6861 7368 6573  0], uncle_hashes
    │ │ │ -0005b910: 2929 0a09 0909 7265 7475 726e 207b 7d3b  ))....return {};
    │ │ │ -0005b920: 0a0a 0909 2f2f 2066 6972 7374 2066 696c  ....// first fil
    │ │ │ -0005b930: 6c20 696e 2074 6865 2073 7562 7472 6565  l in the subtree
    │ │ │ -0005b940: 206f 6620 6b6e 6f77 6e20 6861 7368 6573   of known hashes
    │ │ │ -0005b950: 2066 726f 6d20 7468 6520 6261 7365 206c   from the base l
    │ │ │ -0005b960: 6179 6572 0a09 0961 7574 6f20 636f 6e73  ayer...auto cons
    │ │ │ -0005b970: 7420 6e75 6d5f 6c65 6166 7320 3d20 6d65  t num_leafs = me
    │ │ │ -0005b980: 726b 6c65 5f6e 756d 5f6c 6561 6673 286d  rkle_num_leafs(m
    │ │ │ -0005b990: 5f6e 756d 5f62 6c6f 636b 7329 3b0a 0909  _num_blocks);...
    │ │ │ -0005b9a0: 6175 746f 2063 6f6e 7374 2066 6972 7374  auto const first
    │ │ │ -0005b9b0: 5f6c 6561 6620 3d20 6d65 726b 6c65 5f66  _leaf = merkle_f
    │ │ │ -0005b9c0: 6972 7374 5f6c 6561 6628 6e75 6d5f 6c65  irst_leaf(num_le
    │ │ │ -0005b9d0: 6166 7329 3b0a 0a09 092f 2f20 7468 6973  afs);....// this
    │ │ │ -0005b9e0: 2069 7320 7468 6520 7374 6172 7420 6f66   is the start of
    │ │ │ -0005b9f0: 2074 6865 206c 6561 6620 6c61 7965 7220   the leaf layer 
    │ │ │ -0005ba00: 6f66 2022 7472 6565 222e 2057 6527 6c6c  of "tree". We'll
    │ │ │ -0005ba10: 2075 7365 2074 6869 730a 0909 2f2f 2076   use this...// v
    │ │ │ -0005ba20: 6172 6961 626c 6520 746f 2073 7465 7020  ariable to step 
    │ │ │ -0005ba30: 7570 7761 7264 7320 746f 7761 7264 7320  upwards towards 
    │ │ │ -0005ba40: 7468 6520 726f 6f74 0a09 0969 6e74 2073  the root...int s
    │ │ │ -0005ba50: 6f75 7263 655f 6375 7273 6f72 203d 2069  ource_cursor = i
    │ │ │ -0005ba60: 6e74 2874 7265 652e 7369 7a65 2829 2920  nt(tree.size()) 
    │ │ │ -0005ba70: 2d20 6c65 6166 5f63 6f75 6e74 3b0a 0909  - leaf_count;...
    │ │ │ -0005ba80: 2f2f 2074 6865 2072 756e 6e69 6e67 2069  // the running i
    │ │ │ -0005ba90: 6e64 6578 2069 6e20 7468 6520 6c6f 6f70  ndex in the loop
    │ │ │ -0005baa0: 0a09 0969 6e74 2064 6573 745f 6375 7273  ...int dest_curs
    │ │ │ -0005bab0: 6f72 203d 2064 6573 745f 7374 6172 745f  or = dest_start_
    │ │ │ -0005bac0: 6964 783b 0a0a 0909 2f2f 2074 6865 206e  idx;....// the n
    │ │ │ -0005bad0: 756d 6265 7220 6f66 2074 7265 6520 6c65  umber of tree le
    │ │ │ -0005bae0: 7665 6c73 2069 6e20 6120 7069 6563 6520  vels in a piece 
    │ │ │ -0005baf0: 6861 7368 2e20 3020 6d65 616e 7320 7468  hash. 0 means th
    │ │ │ -0005bb00: 6520 626c 6f63 6b20 6c61 7965 7220 6973  e block layer is
    │ │ │ -0005bb10: 0a09 092f 2f20 7468 6520 7361 6d65 2061  ...// the same a
    │ │ │ -0005bb20: 7320 7468 6520 7069 6563 6520 6c61 7965  s the piece laye
    │ │ │ -0005bb30: 720a 0909 696e 7420 636f 6e73 7420 6261  r...int const ba
    │ │ │ -0005bb40: 7365 203d 2070 6965 6365 5f6c 6576 656c  se = piece_level
    │ │ │ -0005bb50: 7328 293b 0a0a 3c64 6976 2073 7479 6c65  s();..
    ..for (int l │ │ │ -0005bb90: 6179 6572 5f73 697a 6520 3d20 6c65 6166 ayer_size = leaf │ │ │ -0005bba0: 5f63 6f75 6e74 3b20 6c61 7965 725f 7369 _count; layer_si │ │ │ -0005bbb0: 7a65 2021 3d20 303b 206c 6179 6572 5f73 ze != 0; layer_s │ │ │ -0005bbc0: 697a 6520 2f3d 2032 290a 3c2f 6469 763e ize /= 2).
    │ │ │ -0005bbd0: 0909 7b0a 0909 0966 6f72 2028 696e 7420 ..{....for (int │ │ │ -0005bbe0: 6920 3d20 303b 2069 2026 6c74 3b20 6c61 i = 0; i < la │ │ │ -0005bbf0: 7965 725f 7369 7a65 3b20 2b2b 6929 0a09 yer_size; ++i).. │ │ │ -0005bc00: 0909 7b0a 0909 0909 696e 7420 636f 6e73 ..{.....int cons │ │ │ -0005bc10: 7420 6473 745f 6964 7820 3d20 6465 7374 t dst_idx = dest │ │ │ -0005bc20: 5f63 7572 736f 7220 2b20 693b 0a09 0909 _cursor + i;.... │ │ │ -0005bc30: 0969 6e74 2063 6f6e 7374 2073 7263 5f69 .int const src_i │ │ │ -0005bc40: 6478 203d 2073 6f75 7263 655f 6375 7273 dx = source_curs │ │ │ -0005bc50: 6f72 202b 2069 3b0a 0909 0909 6966 2028 or + i;.....if ( │ │ │ -0005bc60: 6861 735f 6e6f 6465 2864 7374 5f69 6478 has_node(dst_idx │ │ │ -0005bc70: 2929 0a09 0909 097b 0a09 0909 0909 6966 )).....{......if │ │ │ -0005bc80: 2028 6d5f 7472 6565 5b64 7374 5f69 6478 (m_tree[dst_idx │ │ │ -0005bc90: 5d20 213d 2074 7265 655b 7372 635f 6964 ] != tree[src_id │ │ │ -0005bca0: 785d 290a 0909 0909 097b 0a09 0909 0909 x])......{...... │ │ │ -0005bcb0: 092f 2f20 7468 6973 206d 7573 7420 6265 .// this must be │ │ │ -0005bcc0: 2061 2062 6c6f 636b 2068 6173 6820 6265 a block hash be │ │ │ -0005bcd0: 6361 7573 6520 696e 6e65 7220 6e6f 6465 cause inner node │ │ │ -0005bce0: 7320 6172 6520 6e6f 7420 6669 6c6c 6564 s are not filled │ │ │ -0005bcf0: 2069 6e20 756e 7469 6c0a 0909 0909 0909 in until....... │ │ │ -0005bd00: 2f2f 2074 6865 7920 6361 6e20 6265 2076 // they can be v │ │ │ -0005bd10: 6572 6966 6965 642e 2054 6869 7320 6173 erified. This as │ │ │ -0005bd20: 7365 7274 2065 6e73 7572 6573 2077 6527 sert ensures we' │ │ │ -0005bd30: 7265 2061 7420 7468 650a 0909 0909 0909 re at the....... │ │ │ -0005bd40: 2f2f 206c 6561 6620 6c61 7965 7220 6f66 // leaf layer of │ │ │ -0005bd50: 2074 6865 2066 696c 6520 7472 6565 0a09 the file tree.. │ │ │ -0005bd60: 0909 0909 0954 4f52 5245 4e54 5f41 5353 .....TORRENT_ASS │ │ │ -0005bd70: 4552 5428 6473 745f 6964 7820 2667 743b ERT(dst_idx > │ │ │ -0005bd80: 3d20 6669 7273 745f 6c65 6166 293b 0a0a = first_leaf);.. │ │ │ -0005bd90: 0909 0909 0909 696e 7420 636f 6e73 7420 ......int const │ │ │ -0005bda0: 706f 7320 3d20 6473 745f 6964 7820 2d20 pos = dst_idx - │ │ │ -0005bdb0: 6669 7273 745f 6c65 6166 3b0a 0909 0909 first_leaf;..... │ │ │ -0005bdc0: 0909 6175 746f 2063 6f6e 7374 2070 6965 ..auto const pie │ │ │ -0005bdd0: 6365 203d 2070 6965 6365 5f69 6e64 6578 ce = piece_index │ │ │ -0005bde0: 5f74 7b70 6f73 2026 6774 3b26 6774 3b20 _t{pos >> │ │ │ -0005bdf0: 6d5f 626c 6f63 6b73 5f70 6572 5f70 6965 m_blocks_per_pie │ │ │ -0005be00: 6365 5f6c 6f67 7d20 2b20 6669 6c65 5f70 ce_log} + file_p │ │ │ -0005be10: 6965 6365 5f6f 6666 7365 743b 0a09 0909 iece_offset;.... │ │ │ -0005be20: 0909 0969 6e74 2063 6f6e 7374 2062 6c6f ...int const blo │ │ │ -0005be30: 636b 203d 2070 6f73 2026 616d 703b 2028 ck = pos & ( │ │ │ -0005be40: 2831 2026 6c74 3b26 6c74 3b20 6d5f 626c (1 << m_bl │ │ │ -0005be50: 6f63 6b73 5f70 6572 5f70 6965 6365 5f6c ocks_per_piece_l │ │ │ -0005be60: 6f67 2920 2d20 3129 3b0a 0a09 0909 0909 og) - 1);....... │ │ │ -0005be70: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -0005be80: 706f 7320 266c 743b 206d 5f6e 756d 5f62 pos < m_num_b │ │ │ -0005be90: 6c6f 636b 7329 3b0a 0909 0909 0909 6966 locks);.......if │ │ │ -0005bea0: 2028 2172 6574 2e66 6169 6c65 642e 656d (!ret.failed.em │ │ │ -0005beb0: 7074 7928 2920 2661 6d70 3b26 616d 703b pty() && │ │ │ -0005bec0: 2072 6574 2e66 6169 6c65 642e 6261 636b ret.failed.back │ │ │ -0005bed0: 2829 2e66 6972 7374 203d 3d20 7069 6563 ().first == piec │ │ │ -0005bee0: 6529 0a09 0909 0909 0909 7265 742e 6661 e)........ret.fa │ │ │ -0005bef0: 696c 6564 2e62 6163 6b28 292e 7365 636f iled.back().seco │ │ │ -0005bf00: 6e64 2e70 7573 685f 6261 636b 2862 6c6f nd.push_back(blo │ │ │ -0005bf10: 636b 293b 0a09 0909 0909 0965 6c73 650a ck);.......else. │ │ │ -0005bf20: 0909 0909 0909 0972 6574 2e66 6169 6c65 .......ret.faile │ │ │ -0005bf30: 642e 656d 706c 6163 655f 6261 636b 2870 d.emplace_back(p │ │ │ -0005bf40: 6965 6365 2c20 7374 643a 3a76 6563 746f iece, std::vecto │ │ │ -0005bf50: 7226 6c74 3b69 6e74 2667 743b 7b62 6c6f r<int>{blo │ │ │ -0005bf60: 636b 7d29 3b0a 0a09 0909 0909 092f 2f20 ck});........// │ │ │ -0005bf70: 6e6f 7720 7468 6174 2074 6869 7320 6861 now that this ha │ │ │ -0005bf80: 7368 2068 6173 2062 6565 6e20 7265 706f sh has been repo │ │ │ -0005bf90: 7274 6564 2061 7320 6661 696c 696e 672c rted as failing, │ │ │ -0005bfa0: 2077 650a 0909 0909 0909 2f2f 2063 616e we.......// can │ │ │ -0005bfb0: 2063 6c65 6172 2069 742e 2054 6869 7320 clear it. This │ │ │ -0005bfc0: 7769 6c6c 2070 7265 7665 6e74 2069 7420 will prevent it │ │ │ -0005bfd0: 6672 6f6d 2062 6569 6e67 0a09 0909 0909 from being...... │ │ │ -0005bfe0: 092f 2f20 7265 706f 7274 6564 2061 7320 .// reported as │ │ │ -0005bff0: 6661 696c 696e 6720 6167 6169 6e2e 0a09 failing again... │ │ │ -0005c000: 0909 0909 096d 5f74 7265 655b 6473 745f .....m_tree[dst_ │ │ │ -0005c010: 6964 785d 2e63 6c65 6172 2829 3b0a 0909 idx].clear();... │ │ │ -0005c020: 0909 097d 0a09 0909 0909 656c 7365 2069 ...}......else i │ │ │ -0005c030: 6620 2864 7374 5f69 6478 2026 6774 3b3d f (dst_idx >= │ │ │ -0005c040: 2066 6972 7374 5f6c 6561 6629 0a3c 2f70 first_leaf).

    re │ │ │ -0005c080: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/m │ │ │ -0005c0c0: 6572 6b6c 655f 7472 6565 2e63 7070 3a34 erkle_tree.cpp:4 │ │ │ -0005c0d0: 3537 3c2f 613e 3c2f 7464 3e3c 7464 3e69 57i │ │ │ -0005c0e0: 6e73 7465 6164 206f 6620 6f76 6572 7772 nstead of overwr │ │ │ -0005c0f0: 6974 696e 6720 7468 6520 726f 6f74 2061 iting the root a │ │ │ -0005c100: 6e64 2063 6f6d 7061 7269 6e67 2069 7420 nd comparing it │ │ │ -0005c110: 6167 6169 6e73 7420 6861 7368 6573 5b5d against hashes[] │ │ │ -0005c120: 2c20 7772 6974 6520 6120 6675 6e63 7469 , write a functi │ │ │ -0005c130: 6f6e 7320 7468 6174 202a 7661 6c69 6461 ons that *valida │ │ │ -0005c140: 7465 732a 2061 2074 7265 6520 6279 206a tes* a tree by j │ │ │ -0005c150: 7573 7420 6669 6c6c 696e 6720 6974 2075 ust filling it u │ │ │ -0005c160: 7020 746f 2074 6865 206c 6576 656c 2062 p to the level b │ │ │ -0005c170: 656c 6f77 2074 6865 2072 6f6f 7420 616e elow the root an │ │ │ -0005c180: 6420 7468 656e 2076 616c 6964 6174 6573 d then validates │ │ │ -0005c190: 2069 742e 3c2f 7464 3e3c 2f74 723e 3c74 it.instead of ove │ │ │ -0005c1f0: 7277 7269 7469 6e67 2074 6865 2072 6f6f rwriting the roo │ │ │ -0005c200: 7420 616e 6420 636f 6d70 6172 696e 6720 t and comparing │ │ │ -0005c210: 6974 0a61 6761 696e 7374 2068 6173 6865 it.against hashe │ │ │ -0005c220: 735b 5d2c 2077 7269 7465 2061 2066 756e s[], write a fun │ │ │ -0005c230: 6374 696f 6e73 2074 6861 7420 2a76 616c ctions that *val │ │ │ -0005c240: 6964 6174 6573 2a20 6120 7472 6565 0a62 idates* a tree.b │ │ │ -0005c250: 7920 6a75 7374 2066 696c 6c69 6e67 2069 y just filling i │ │ │ -0005c260: 7420 7570 2074 6f20 7468 6520 6c65 7665 t up to the leve │ │ │ -0005c270: 6c20 6265 6c6f 7720 7468 6520 726f 6f74 l below the root │ │ │ -0005c280: 2061 6e64 2074 6865 6e0a 7661 6c69 6461 and then.valida │ │ │ -0005c290: 7465 7320 6974 2e3c 2f68 323e 3c68 343e tes it.

    │ │ │ -0005c2a0: 2e2e 2f73 7263 2f6d 6572 6b6c 655f 7472 ../src/merkle_tr │ │ │ -0005c2b0: 6565 2e63 7070 3a34 3537 3c2f 6834 3e3c ee.cpp:457

    < │ │ │ -0005c2c0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -0005c2d0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -0005c2e0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -0005c2f0: 7820 2364 6464 3b22 3e09 0909 2661 6d70 x #ddd;">...& │ │ │ -0005c300: 3b26 616d 703b 2064 6573 745f 7374 6172 ;& dest_star │ │ │ -0005c310: 745f 6964 7820 266c 743b 2066 6972 7374 t_idx < first │ │ │ -0005c320: 5f70 6965 6365 5f69 6478 202b 206e 756d _piece_idx + num │ │ │ -0005c330: 5f70 6965 6365 7328 2929 0a09 097b 0a09 _pieces())...{.. │ │ │ -0005c340: 0909 696e 7420 636f 6e73 7420 626c 6f63 ..int const bloc │ │ │ -0005c350: 6b73 5f69 6e5f 7069 6563 6520 3d20 3120 ks_in_piece = 1 │ │ │ -0005c360: 266c 743b 266c 743b 2062 6173 653b 0a0a << base;.. │ │ │ -0005c370: 0909 092f 2f20 6974 206d 6179 206e 6f77 ...// it may now │ │ │ -0005c380: 2062 6520 706f 7373 6962 6c65 2074 6f20 be possible to │ │ │ -0005c390: 7665 7269 6679 2074 6865 2068 6173 6865 verify the hashe │ │ │ -0005c3a0: 7320 6f66 2070 7265 7669 6f75 736c 7920 s of previously │ │ │ -0005c3b0: 7265 6365 6976 6564 2062 6c6f 636b 730a received blocks. │ │ │ -0005c3c0: 0909 092f 2f20 7472 7920 746f 2076 6572 ...// try to ver │ │ │ -0005c3d0: 6966 7920 6173 206d 616e 7920 6368 696c ify as many chil │ │ │ -0005c3e0: 6420 6e6f 6465 7320 6f66 2074 6865 2072 d nodes of the r │ │ │ -0005c3f0: 6563 6569 7665 6420 6861 7368 6573 2061 eceived hashes a │ │ │ -0005c400: 7320 706f 7373 6962 6c65 0a09 0909 666f s possible....fo │ │ │ -0005c410: 7220 2869 6e74 2069 203d 2030 3b20 6920 r (int i = 0; i │ │ │ -0005c420: 266c 743b 2069 6e74 2868 6173 6865 732e < int(hashes. │ │ │ -0005c430: 7369 7a65 2829 293b 202b 2b69 290a 0909 size()); ++i)... │ │ │ -0005c440: 097b 0a09 0909 0969 6e74 2063 6f6e 7374 .{.....int const │ │ │ -0005c450: 2070 6965 6365 203d 2064 6573 745f 7374 piece = dest_st │ │ │ -0005c460: 6172 745f 6964 7820 2b20 693b 0a09 0909 art_idx + i;.... │ │ │ -0005c470: 0969 6620 2870 6965 6365 202d 2066 6972 .if (piece - fir │ │ │ -0005c480: 7374 5f70 6965 6365 5f69 6478 2026 6774 st_piece_idx > │ │ │ -0005c490: 3b3d 206e 756d 5f70 6965 6365 7328 2929 ;= num_pieces()) │ │ │ -0005c4a0: 0a09 0909 0909 6272 6561 6b3b 0a09 0909 ......break;.... │ │ │ -0005c4b0: 092f 2f20 7468 6520 6669 7273 7420 626c .// the first bl │ │ │ -0005c4c0: 6f63 6b20 696e 2074 6869 7320 7069 6563 ock in this piec │ │ │ -0005c4d0: 650a 0909 0909 696e 7420 636f 6e73 7420 e.....int const │ │ │ -0005c4e0: 626c 6f63 6b5f 6964 7820 3d20 6d65 726b block_idx = merk │ │ │ -0005c4f0: 6c65 5f67 6574 5f66 6972 7374 5f63 6869 le_get_first_chi │ │ │ -0005c500: 6c64 2870 6965 6365 2c20 6261 7365 293b ld(piece, base); │ │ │ -0005c510: 0a0a 0909 0909 696e 7420 636f 6e73 7420 ......int const │ │ │ -0005c520: 626c 6f63 6b5f 656e 645f 6964 7820 3d20 block_end_idx = │ │ │ -0005c530: 7374 643a 3a6d 696e 2862 6c6f 636b 5f69 std::min(block_i │ │ │ -0005c540: 6478 202b 2062 6c6f 636b 735f 696e 5f70 dx + blocks_in_p │ │ │ -0005c550: 6965 6365 2c20 6669 7273 745f 6c65 6166 iece, first_leaf │ │ │ -0005c560: 202b 206d 5f6e 756d 5f62 6c6f 636b 7329 + m_num_blocks) │ │ │ -0005c570: 3b0a 0909 0909 6966 2028 7374 643a 3a61 ;.....if (std::a │ │ │ -0005c580: 6e79 5f6f 6628 6d5f 7472 6565 2e62 6567 ny_of(m_tree.beg │ │ │ -0005c590: 696e 2829 202b 2062 6c6f 636b 5f69 6478 in() + block_idx │ │ │ -0005c5a0: 0a09 0909 0909 2c20 6d5f 7472 6565 2e62 ......, m_tree.b │ │ │ -0005c5b0: 6567 696e 2829 202b 2062 6c6f 636b 5f65 egin() + block_e │ │ │ -0005c5c0: 6e64 5f69 6478 0a09 0909 0909 2c20 5b5d nd_idx......, [] │ │ │ -0005c5d0: 2873 6861 3235 365f 6861 7368 2063 6f6e (sha256_hash con │ │ │ -0005c5e0: 7374 2661 6d70 3b20 6829 207b 2072 6574 st& h) { ret │ │ │ -0005c5f0: 7572 6e20 682e 6973 5f61 6c6c 5f7a 6572 urn h.is_all_zer │ │ │ -0005c600: 6f73 2829 3b20 7d29 290a 0909 0909 0963 os(); }))......c │ │ │ -0005c610: 6f6e 7469 6e75 653b 0a0a 3c64 6976 2073 ontinue;..
    ....merk │ │ │ -0005c650: 6c65 5f66 696c 6c5f 7472 6565 286d 5f74 le_fill_tree(m_t │ │ │ -0005c660: 7265 652c 2062 6c6f 636b 735f 696e 5f70 ree, blocks_in_p │ │ │ -0005c670: 6965 6365 2c20 626c 6f63 6b5f 6964 7829 iece, block_idx) │ │ │ -0005c680: 3b0a 3c2f 6469 763e 0909 0909 6966 2028 ;.
    ....if ( │ │ │ -0005c690: 6d5f 7472 6565 5b70 6965 6365 5d20 213d m_tree[piece] != │ │ │ -0005c6a0: 2068 6173 6865 735b 695d 290a 0909 0909 hashes[i])..... │ │ │ -0005c6b0: 7b0a 0909 0909 096d 6572 6b6c 655f 636c {......merkle_cl │ │ │ -0005c6c0: 6561 725f 7472 6565 286d 5f74 7265 652c ear_tree(m_tree, │ │ │ -0005c6d0: 2062 6c6f 636b 735f 696e 5f70 6965 6365 blocks_in_piece │ │ │ -0005c6e0: 2c20 626c 6f63 6b5f 6964 7829 3b0a 0909 , block_idx);... │ │ │ -0005c6f0: 0909 092f 2f20 7772 6974 6520 6261 636b ...// write back │ │ │ -0005c700: 2074 6865 2063 6f72 7265 6374 2068 6173 the correct has │ │ │ -0005c710: 680a 0909 0909 096d 5f74 7265 655b 7069 h......m_tree[pi │ │ │ -0005c720: 6563 655d 203d 2068 6173 6865 735b 695d ece] = hashes[i] │ │ │ -0005c730: 3b0a 0909 0909 0954 4f52 5245 4e54 5f41 ;......TORRENT_A │ │ │ -0005c740: 5353 4552 5428 626c 6f63 6b73 5f69 6e5f SSERT(blocks_in_ │ │ │ -0005c750: 7069 6563 6520 3d3d 2062 6c6f 636b 735f piece == blocks_ │ │ │ -0005c760: 7065 725f 7069 6563 6528 2929 3b0a 0a09 per_piece());... │ │ │ -0005c770: 0909 0909 2f2f 2061 6e20 656d 7074 7920 ....// an empty │ │ │ -0005c780: 626c 6f63 6b73 2076 6563 746f 7220 696e blocks vector in │ │ │ -0005c790: 6469 6361 7465 7320 7468 6174 2077 6520 dicates that we │ │ │ -0005c7a0: 646f 6e27 7420 6861 7665 2074 6865 0a09 don't have the.. │ │ │ -0005c7b0: 0909 0909 2f2f 2062 6c6f 636b 2068 6173 ....// block has │ │ │ -0005c7c0: 6865 732c 2061 6e64 2077 6520 6361 6e27 hes, and we can' │ │ │ -0005c7d0: 7420 6b6e 6f77 2077 6869 6368 2062 6c6f t know which blo │ │ │ -0005c7e0: 636b 2066 6169 6c65 640a 0909 0909 092f ck failed....../ │ │ │ -0005c7f0: 2f20 7468 6973 2077 696c 6c20 6361 7573 / this will caus │ │ │ -0005c800: 6520 7468 6520 626c 6f63 6b20 6861 7368 e the block hash │ │ │ -0005c810: 6573 2074 6f20 6265 2072 6571 7565 7374 es to be request │ │ │ -0005c820: 6564 0a09 0909 0909 7265 742e 6661 696c ed......ret.fail │ │ │ -0005c830: 6564 2e65 6d70 6c61 6365 5f62 6163 6b28 ed.emplace_back( │ │ │ -0005c840: 7069 6563 655f 696e 6465 785f 747b 7069 piece_index_t{pi │ │ │ -0005c850: 6563 6520 2d20 6669 7273 745f 7069 6563 ece - first_piec │ │ │ -0005c860: 655f 6964 787d 202b 2066 696c 655f 7069 e_idx} + file_pi │ │ │ -0005c870: 6563 655f 6f66 6673 6574 0a09 0909 0909 ece_offset...... │ │ │ -0005c880: 092c 2073 7464 3a3a 7665 6374 6f72 266c ., std::vector&l │ │ │ -0005c890: 743b 696e 7426 6774 3b28 2929 3b0a 0909 t;int>());... │ │ │ -0005c8a0: 0909 7d0a 0909 0909 656c 7365 0a09 0909 ..}.....else.... │ │ │ -0005c8b0: 097b 0a09 0909 0909 7265 742e 7061 7373 .{......ret.pass │ │ │ -0005c8c0: 6564 2e70 7573 685f 6261 636b 2870 6965 ed.push_back(pie │ │ │ -0005c8d0: 6365 5f69 6e64 6578 5f74 7b70 6965 6365 ce_index_t{piece │ │ │ -0005c8e0: 202d 2066 6972 7374 5f70 6965 6365 5f69 - first_piece_i │ │ │ -0005c8f0: 6478 7d20 2b20 6669 6c65 5f70 6965 6365 dx} + file_piece │ │ │ -0005c900: 5f6f 6666 7365 7429 3b0a 0909 0909 092f _offset);....../ │ │ │ -0005c910: 2f20 7265 636f 7264 2074 6861 7420 7468 / record that th │ │ │ -0005c920: 6573 6520 626c 6f63 6b20 6861 7368 6573 ese block hashes │ │ │ -0005c930: 2061 7265 2063 6f72 7265 6374 210a 0909 are correct!... │ │ │ -0005c940: 0909 0969 6e74 2063 6f6e 7374 206c 6561 ...int const lea │ │ │ -0005c950: 6673 5f73 7461 7274 203d 2062 6c6f 636b fs_start = block │ │ │ -0005c960: 5f69 6478 202d 2062 6c6f 636b 5f6c 6179 _idx - block_lay │ │ │ -0005c970: 6572 5f73 7461 7274 2829 3b0a 0909 0909 er_start();..... │ │ │ -0005c980: 0969 6e74 2063 6f6e 7374 206c 6561 6673 .int const leafs │ │ │ -0005c990: 5f65 6e64 203d 2073 7464 3a3a 6d69 6e28 _end = std::min( │ │ │ -0005c9a0: 6d5f 6e75 6d5f 626c 6f63 6b73 2c20 6c65 m_num_blocks, le │ │ │ -0005c9b0: 6166 735f 7374 6172 7420 2b20 626c 6f63 afs_start + bloc │ │ │ -0005c9c0: 6b73 5f69 6e5f 7069 6563 6529 3b0a 3c2f ks_in_piece);.r │ │ │ -0005ca00: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -0005ca10: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -0005ca40: 6d65 726b 6c65 5f74 7265 652e 6370 703a merkle_tree.cpp: │ │ │ -0005ca50: 3438 313c 2f61 3e3c 2f74 643e 3c74 643e 481 │ │ │ -0005ca60: 7468 6973 2063 6f75 6c64 2062 6520 646f this could be do │ │ │ -0005ca70: 6e65 206d 6f72 6520 6566 6669 6369 656e ne more efficien │ │ │ -0005ca80: 746c 7920 6966 2062 6974 6669 656c 6420 tly if bitfield │ │ │ -0005ca90: 6861 6420 6120 6675 6e63 7469 6f6e 2074 had a function t │ │ │ -0005caa0: 6f20 7365 7420 6120 7261 6e67 6520 6f66 o set a range of │ │ │ -0005cab0: 2062 6974 733c 2f74 643e 3c2f 7472 3e3c bits< │ │ │ -0005cac0: 7472 2069 643d 2232 3135 2220 7374 796c tr id="215" styl │ │ │ -0005cad0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -0005cae0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -0005caf0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -0005cb00: 6832 3e74 6869 7320 636f 756c 6420 6265 h2>this could be │ │ │ -0005cb10: 2064 6f6e 6520 6d6f 7265 2065 6666 6963 done more effic │ │ │ -0005cb20: 6965 6e74 6c79 2069 6620 6269 7466 6965 iently if bitfie │ │ │ -0005cb30: 6c64 2068 6164 2061 2066 756e 6374 696f ld had a functio │ │ │ -0005cb40: 6e0a 746f 2073 6574 2061 2072 616e 6765 n.to set a range │ │ │ -0005cb50: 206f 6620 6269 7473 3c2f 6832 3e3c 6834 of bits

    ../src/merkle_t │ │ │ -0005cb70: 7265 652e 6370 703a 3438 313c 2f68 343e ree.cpp:481

    │ │ │ -0005cb80: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ....me
    │ │ │ -0005cbc0: 726b 6c65 5f66 696c 6c5f 7472 6565 286d  rkle_fill_tree(m
    │ │ │ -0005cbd0: 5f74 7265 652c 2062 6c6f 636b 735f 696e  _tree, blocks_in
    │ │ │ -0005cbe0: 5f70 6965 6365 2c20 626c 6f63 6b5f 6964  _piece, block_id
    │ │ │ -0005cbf0: 7829 3b0a 0909 0909 6966 2028 6d5f 7472  x);.....if (m_tr
    │ │ │ -0005cc00: 6565 5b70 6965 6365 5d20 213d 2068 6173  ee[piece] != has
    │ │ │ -0005cc10: 6865 735b 695d 290a 0909 0909 7b0a 0909  hes[i]).....{...
    │ │ │ -0005cc20: 0909 096d 6572 6b6c 655f 636c 6561 725f  ...merkle_clear_
    │ │ │ -0005cc30: 7472 6565 286d 5f74 7265 652c 2062 6c6f  tree(m_tree, blo
    │ │ │ -0005cc40: 636b 735f 696e 5f70 6965 6365 2c20 626c  cks_in_piece, bl
    │ │ │ -0005cc50: 6f63 6b5f 6964 7829 3b0a 0909 0909 092f  ock_idx);....../
    │ │ │ -0005cc60: 2f20 7772 6974 6520 6261 636b 2074 6865  / write back the
    │ │ │ -0005cc70: 2063 6f72 7265 6374 2068 6173 680a 0909   correct hash...
    │ │ │ -0005cc80: 0909 096d 5f74 7265 655b 7069 6563 655d  ...m_tree[piece]
    │ │ │ -0005cc90: 203d 2068 6173 6865 735b 695d 3b0a 0909   = hashes[i];...
    │ │ │ -0005cca0: 0909 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ -0005ccb0: 5428 626c 6f63 6b73 5f69 6e5f 7069 6563  T(blocks_in_piec
    │ │ │ -0005ccc0: 6520 3d3d 2062 6c6f 636b 735f 7065 725f  e == blocks_per_
    │ │ │ -0005ccd0: 7069 6563 6528 2929 3b0a 0a09 0909 0909  piece());.......
    │ │ │ -0005cce0: 2f2f 2061 6e20 656d 7074 7920 626c 6f63  // an empty bloc
    │ │ │ -0005ccf0: 6b73 2076 6563 746f 7220 696e 6469 6361  ks vector indica
    │ │ │ -0005cd00: 7465 7320 7468 6174 2077 6520 646f 6e27  tes that we don'
    │ │ │ -0005cd10: 7420 6861 7665 2074 6865 0a09 0909 0909  t have the......
    │ │ │ -0005cd20: 2f2f 2062 6c6f 636b 2068 6173 6865 732c  // block hashes,
    │ │ │ -0005cd30: 2061 6e64 2077 6520 6361 6e27 7420 6b6e   and we can't kn
    │ │ │ -0005cd40: 6f77 2077 6869 6368 2062 6c6f 636b 2066  ow which block f
    │ │ │ -0005cd50: 6169 6c65 640a 0909 0909 092f 2f20 7468  ailed......// th
    │ │ │ -0005cd60: 6973 2077 696c 6c20 6361 7573 6520 7468  is will cause th
    │ │ │ -0005cd70: 6520 626c 6f63 6b20 6861 7368 6573 2074  e block hashes t
    │ │ │ -0005cd80: 6f20 6265 2072 6571 7565 7374 6564 0a09  o be requested..
    │ │ │ -0005cd90: 0909 0909 7265 742e 6661 696c 6564 2e65  ....ret.failed.e
    │ │ │ -0005cda0: 6d70 6c61 6365 5f62 6163 6b28 7069 6563  mplace_back(piec
    │ │ │ -0005cdb0: 655f 696e 6465 785f 747b 7069 6563 6520  e_index_t{piece 
    │ │ │ -0005cdc0: 2d20 6669 7273 745f 7069 6563 655f 6964  - first_piece_id
    │ │ │ -0005cdd0: 787d 202b 2066 696c 655f 7069 6563 655f  x} + file_piece_
    │ │ │ -0005cde0: 6f66 6673 6574 0a09 0909 0909 092c 2073  offset......., s
    │ │ │ -0005cdf0: 7464 3a3a 7665 6374 6f72 266c 743b 696e  td::vector<in
    │ │ │ -0005ce00: 7426 6774 3b28 2929 3b0a 0909 0909 7d0a  t>());.....}.
    │ │ │ -0005ce10: 0909 0909 656c 7365 0a09 0909 097b 0a09  ....else.....{..
    │ │ │ -0005ce20: 0909 0909 7265 742e 7061 7373 6564 2e70  ....ret.passed.p
    │ │ │ -0005ce30: 7573 685f 6261 636b 2870 6965 6365 5f69  ush_back(piece_i
    │ │ │ -0005ce40: 6e64 6578 5f74 7b70 6965 6365 202d 2066  ndex_t{piece - f
    │ │ │ -0005ce50: 6972 7374 5f70 6965 6365 5f69 6478 7d20  irst_piece_idx} 
    │ │ │ -0005ce60: 2b20 6669 6c65 5f70 6965 6365 5f6f 6666  + file_piece_off
    │ │ │ -0005ce70: 7365 7429 3b0a 0909 0909 092f 2f20 7265  set);......// re
    │ │ │ -0005ce80: 636f 7264 2074 6861 7420 7468 6573 6520  cord that these 
    │ │ │ -0005ce90: 626c 6f63 6b20 6861 7368 6573 2061 7265  block hashes are
    │ │ │ -0005cea0: 2063 6f72 7265 6374 210a 0909 0909 0969   correct!......i
    │ │ │ -0005ceb0: 6e74 2063 6f6e 7374 206c 6561 6673 5f73  nt const leafs_s
    │ │ │ -0005cec0: 7461 7274 203d 2062 6c6f 636b 5f69 6478  tart = block_idx
    │ │ │ -0005ced0: 202d 2062 6c6f 636b 5f6c 6179 6572 5f73   - block_layer_s
    │ │ │ -0005cee0: 7461 7274 2829 3b0a 0909 0909 0969 6e74  tart();......int
    │ │ │ -0005cef0: 2063 6f6e 7374 206c 6561 6673 5f65 6e64   const leafs_end
    │ │ │ -0005cf00: 203d 2073 7464 3a3a 6d69 6e28 6d5f 6e75   = std::min(m_nu
    │ │ │ -0005cf10: 6d5f 626c 6f63 6b73 2c20 6c65 6166 735f  m_blocks, leafs_
    │ │ │ -0005cf20: 7374 6172 7420 2b20 626c 6f63 6b73 5f69  start + blocks_i
    │ │ │ -0005cf30: 6e5f 7069 6563 6529 3b0a 3c64 6976 2073  n_piece);.
    .....for │ │ │ -0005cf70: 2028 696e 7420 6b20 3d20 6c65 6166 735f (int k = leafs_ │ │ │ -0005cf80: 7374 6172 743b 206b 2026 6c74 3b20 6c65 start; k < le │ │ │ -0005cf90: 6166 735f 656e 643b 202b 2b6b 290a 3c2f afs_end; ++k).......m_bloc │ │ │ -0005cfb0: 6b5f 7665 7269 6669 6564 2e73 6574 5f62 k_verified.set_b │ │ │ -0005cfc0: 6974 286b 293b 0a09 0909 097d 0a09 0909 it(k);.....}.... │ │ │ -0005cfd0: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -0005cfe0: 2870 6965 6365 202d 2066 6972 7374 5f70 (piece - first_p │ │ │ -0005cff0: 6965 6365 5f69 6478 2920 2667 743b 3d20 iece_idx) >= │ │ │ -0005d000: 3029 3b0a 0909 097d 0a09 097d 0a0a 0909 0);....}...}.... │ │ │ -0005d010: 6f70 7469 6d69 7a65 5f73 746f 7261 6765 optimize_storage │ │ │ -0005d020: 2829 3b0a 0a09 0972 6574 7572 6e20 7265 ();....return re │ │ │ -0005d030: 743b 0a09 7d0a 0a09 7374 643a 3a74 7570 t;..}...std::tup │ │ │ -0005d040: 6c65 266c 743b 6d65 726b 6c65 5f74 7265 le<merkle_tre │ │ │ -0005d050: 653a 3a73 6574 5f62 6c6f 636b 5f72 6573 e::set_block_res │ │ │ -0005d060: 756c 742c 2069 6e74 2c20 696e 7426 6774 ult, int, int> │ │ │ -0005d070: 3b20 6d65 726b 6c65 5f74 7265 653a 3a73 ; merkle_tree::s │ │ │ -0005d080: 6574 5f62 6c6f 636b 2869 6e74 2063 6f6e et_block(int con │ │ │ -0005d090: 7374 2062 6c6f 636b 5f69 6e64 6578 0a09 st block_index.. │ │ │ -0005d0a0: 092c 2073 6861 3235 365f 6861 7368 2063 ., sha256_hash c │ │ │ -0005d0b0: 6f6e 7374 2661 6d70 3b20 6829 0a09 7b0a onst& h)..{. │ │ │ -0005d0c0: 2369 6664 6566 2054 4f52 5245 4e54 5f45 #ifdef TORRENT_E │ │ │ -0005d0d0: 5850 454e 5349 5645 5f49 4e56 4152 4941 XPENSIVE_INVARIA │ │ │ -0005d0e0: 4e54 5f43 4845 434b 530a 0909 494e 5641 NT_CHECKS...INVA │ │ │ -0005d0f0: 5249 414e 545f 4348 4543 4b3b 0a23 656e RIANT_CHECK;.#en │ │ │ -0005d100: 6469 660a 0909 544f 5252 454e 545f 4153 dif...TORRENT_AS │ │ │ -0005d110: 5345 5254 2862 6c6f 636b 5f69 6e64 6578 SERT(block_index │ │ │ -0005d120: 2026 6c74 3b20 6d5f 6e75 6d5f 626c 6f63 < m_num_bloc │ │ │ -0005d130: 6b73 293b 0a0a 0909 6175 746f 2063 6f6e ks);....auto con │ │ │ -0005d140: 7374 206e 756d 5f6c 6561 6673 203d 206d st num_leafs = m │ │ │ -0005d150: 6572 6b6c 655f 6e75 6d5f 6c65 6166 7328 erkle_num_leafs( │ │ │ -0005d160: 6d5f 6e75 6d5f 626c 6f63 6b73 293b 0a09 m_num_blocks);.. │ │ │ -0005d170: 0961 7574 6f20 636f 6e73 7420 6669 7273 .auto const firs │ │ │ -0005d180: 745f 6c65 6166 203d 206d 6572 6b6c 655f t_leaf = merkle_ │ │ │ -0005d190: 6669 7273 745f 6c65 6166 286e 756d 5f6c first_leaf(num_l │ │ │ -0005d1a0: 6561 6673 293b 0a09 0961 7574 6f20 636f eafs);...auto co │ │ │ -0005d1b0: 6e73 7420 626c 6f63 6b5f 7472 6565 5f69 nst block_tree_i │ │ │ -0005d1c0: 6e64 6578 203d 2066 6972 7374 5f6c 6561 ndex = first_lea │ │ │ -0005d1d0: 6620 2b20 626c 6f63 6b5f 696e 6465 783b f + block_index; │ │ │ -0005d1e0: 0a0a 0909 6966 2028 626c 6f63 6b73 5f76 ....if (blocks_v │ │ │ -0005d1f0: 6572 6966 6965 6428 626c 6f63 6b5f 696e erified(block_in │ │ │ -0005d200: 6465 782c 2031 2929 0a09 097b 0a09 0909 dex, 1))...{.... │ │ │ -0005d210: 2f2f 2069 6620 7468 6973 2062 6c6f 636b // if this block │ │ │ -0005d220: 7327 7320 6861 7368 2069 7320 616c 7265 s's hash is alre │ │ │ -0005d230: 6164 7920 6b6e 6f77 6e2c 2063 6865 636b ady known, check │ │ │ -0005d240: 2074 6865 2070 6173 7365 642d 696e 2068 the passed-in h │ │ │ -0005d250: 6173 6820 6167 6169 6e73 7420 6974 0a09 ash against it.. │ │ │ -0005d260: 0909 6966 2028 636f 6d70 6172 655f 6e6f ..if (compare_no │ │ │ -0005d270: 6465 2862 6c6f 636b 5f74 7265 655f 696e de(block_tree_in │ │ │ -0005d280: 6465 782c 2068 2929 0a09 0909 0972 6574 dex, h)).....ret │ │ │ -0005d290: 7572 6e20 7374 643a 3a6d 616b 655f 7475 urn std::make_tu │ │ │ -0005d2a0: 706c 6528 7365 745f 626c 6f63 6b5f 7265 ple(set_block_re │ │ │ -0005d2b0: 7375 6c74 3a3a 6f6b 2c20 626c 6f63 6b5f sult::ok, block_ │ │ │ -0005d2c0: 696e 6465 782c 2031 293b 0a09 0909 656c index, 1);....el │ │ │ -0005d2d0: 7365 0a09 0909 0972 6574 7572 6e20 7374 se.....return st │ │ │ -0005d2e0: 643a 3a6d 616b 655f 7475 706c 6528 7365 d::make_tuple(se │ │ │ -0005d2f0: 745f 626c 6f63 6b5f 7265 7375 6c74 3a3a t_block_result:: │ │ │ -0005d300: 626c 6f63 6b5f 6861 7368 5f66 6169 6c65 block_hash_faile │ │ │ -0005d310: 642c 2062 6c6f 636b 5f69 6e64 6578 2c20 d, block_index, │ │ │ -0005d320: 3129 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 1);.
    < │ │ │ -0005d330: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -0005d360: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -0005d390: 2e2f 7372 632f 6d65 726b 6c65 5f74 7265 ./src/merkle_tre │ │ │ -0005d3a0: 652e 6370 703a 3532 343c 2f61 3e3c 2f74 e.cpp:524use struct │ │ │ -0005d3c0: 7572 6564 2062 696e 6469 6e67 2069 6e20 ured binding in │ │ │ -0005d3d0: 432b 2b31 373c 2f74 643e 3c2f 7472 3e3c C++17< │ │ │ -0005d3e0: 7472 2069 643d 2232 3136 2220 7374 796c tr id="216" styl │ │ │ -0005d3f0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -0005d400: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -0005d410: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -0005d420: 6832 3e75 7365 2073 7472 7563 7475 7265 h2>use structure │ │ │ -0005d430: 6420 6269 6e64 696e 6720 696e 2043 2b2b d binding in C++ │ │ │ -0005d440: 3137 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 17

    ../sr │ │ │ -0005d450: 632f 6d65 726b 6c65 5f74 7265 652e 6370 c/merkle_tree.cp │ │ │ -0005d460: 703a 3532 343c 2f68 343e 3c70 7265 2073 p:524

    ..auto const
    │ │ │ -0005d4b0: 2066 6972 7374 5f6c 6561 6620 3d20 6d65   first_leaf = me
    │ │ │ -0005d4c0: 726b 6c65 5f66 6972 7374 5f6c 6561 6628  rkle_first_leaf(
    │ │ │ -0005d4d0: 6e75 6d5f 6c65 6166 7329 3b0a 0909 6175  num_leafs);...au
    │ │ │ -0005d4e0: 746f 2063 6f6e 7374 2062 6c6f 636b 5f74  to const block_t
    │ │ │ -0005d4f0: 7265 655f 696e 6465 7820 3d20 6669 7273  ree_index = firs
    │ │ │ -0005d500: 745f 6c65 6166 202b 2062 6c6f 636b 5f69  t_leaf + block_i
    │ │ │ -0005d510: 6e64 6578 3b0a 0a09 0969 6620 2862 6c6f  ndex;....if (blo
    │ │ │ -0005d520: 636b 735f 7665 7269 6669 6564 2862 6c6f  cks_verified(blo
    │ │ │ -0005d530: 636b 5f69 6e64 6578 2c20 3129 290a 0909  ck_index, 1))...
    │ │ │ -0005d540: 7b0a 0909 092f 2f20 6966 2074 6869 7320  {....// if this 
    │ │ │ -0005d550: 626c 6f63 6b73 2773 2068 6173 6820 6973  blocks's hash is
    │ │ │ -0005d560: 2061 6c72 6561 6479 206b 6e6f 776e 2c20   already known, 
    │ │ │ -0005d570: 6368 6563 6b20 7468 6520 7061 7373 6564  check the passed
    │ │ │ -0005d580: 2d69 6e20 6861 7368 2061 6761 696e 7374  -in hash against
    │ │ │ -0005d590: 2069 740a 0909 0969 6620 2863 6f6d 7061   it....if (compa
    │ │ │ -0005d5a0: 7265 5f6e 6f64 6528 626c 6f63 6b5f 7472  re_node(block_tr
    │ │ │ -0005d5b0: 6565 5f69 6e64 6578 2c20 6829 290a 0909  ee_index, h))...
    │ │ │ -0005d5c0: 0909 7265 7475 726e 2073 7464 3a3a 6d61  ..return std::ma
    │ │ │ -0005d5d0: 6b65 5f74 7570 6c65 2873 6574 5f62 6c6f  ke_tuple(set_blo
    │ │ │ -0005d5e0: 636b 5f72 6573 756c 743a 3a6f 6b2c 2062  ck_result::ok, b
    │ │ │ -0005d5f0: 6c6f 636b 5f69 6e64 6578 2c20 3129 3b0a  lock_index, 1);.
    │ │ │ -0005d600: 0909 0965 6c73 650a 0909 0909 7265 7475  ...else.....retu
    │ │ │ -0005d610: 726e 2073 7464 3a3a 6d61 6b65 5f74 7570  rn std::make_tup
    │ │ │ -0005d620: 6c65 2873 6574 5f62 6c6f 636b 5f72 6573  le(set_block_res
    │ │ │ -0005d630: 756c 743a 3a62 6c6f 636b 5f68 6173 685f  ult::block_hash_
    │ │ │ -0005d640: 6661 696c 6564 2c20 626c 6f63 6b5f 696e  failed, block_in
    │ │ │ -0005d650: 6465 782c 2031 293b 0a09 097d 0a0a 0909  dex, 1);...}....
    │ │ │ -0005d660: 616c 6c6f 6361 7465 5f66 756c 6c28 293b  allocate_full();
    │ │ │ -0005d670: 0a0a 0909 6d5f 7472 6565 5b62 6c6f 636b  ....m_tree[block
    │ │ │ -0005d680: 5f74 7265 655f 696e 6465 785d 203d 2068  _tree_index] = h
    │ │ │ -0005d690: 3b0a 0a09 092f 2f20 746f 2061 766f 6964  ;....// to avoid
    │ │ │ -0005d6a0: 2077 6173 7469 6e67 2061 206c 6f74 206f   wasting a lot o
    │ │ │ -0005d6b0: 6620 7469 6d65 2068 6173 6869 6e67 206e  f time hashing n
    │ │ │ -0005d6c0: 6f64 6573 206f 6e6c 7920 746f 2064 6973  odes only to dis
    │ │ │ -0005d6d0: 636f 7665 7220 7468 6579 0a09 092f 2f20  cover they...// 
    │ │ │ -0005d6e0: 6361 6e6e 6f74 2062 6520 7665 7269 6669  cannot be verifi
    │ │ │ -0005d6f0: 6564 2c20 6368 6563 6b20 6669 7273 7420  ed, check first 
    │ │ │ -0005d700: 746f 2073 6565 2069 6620 7468 6520 726f  to see if the ro
    │ │ │ -0005d710: 6f74 206f 6620 7468 6520 6c61 7267 6573  ot of the larges
    │ │ │ -0005d720: 740a 0909 2f2f 2063 6f6d 7075 7461 626c  t...// computabl
    │ │ │ -0005d730: 6520 7375 6274 7265 6520 6973 206b 6e6f  e subtree is kno
    │ │ │ -0005d740: 776e 0a0a 3c64 6976 2073 7479 6c65 3d22  wn..
    ..int leafs_st │ │ │ -0005d780: 6172 743b 0a3c 2f64 6976 3e09 0969 6e74 art;.
    ..int │ │ │ -0005d790: 206c 6561 6673 5f73 697a 653b 0a09 0969 leafs_size;...i │ │ │ -0005d7a0: 6e74 2072 6f6f 745f 696e 6465 783b 0a09 nt root_index;.. │ │ │ -0005d7b0: 0973 7464 3a3a 7469 6528 6c65 6166 735f .std::tie(leafs_ │ │ │ -0005d7c0: 7374 6172 742c 206c 6561 6673 5f73 697a start, leafs_siz │ │ │ -0005d7d0: 652c 2072 6f6f 745f 696e 6465 7829 203d e, root_index) = │ │ │ -0005d7e0: 0a09 0909 6d65 726b 6c65 5f66 696e 645f ....merkle_find_ │ │ │ -0005d7f0: 6b6e 6f77 6e5f 7375 6274 7265 6528 6d5f known_subtree(m_ │ │ │ -0005d800: 7472 6565 2c20 626c 6f63 6b5f 696e 6465 tree, block_inde │ │ │ -0005d810: 782c 206d 5f6e 756d 5f62 6c6f 636b 7329 x, m_num_blocks) │ │ │ -0005d820: 3b0a 0a09 092f 2f20 6966 2074 6865 2072 ;....// if the r │ │ │ -0005d830: 6f6f 7420 6e6f 6465 2069 7320 756e 6b6e oot node is unkn │ │ │ -0005d840: 6f77 6e20 7468 6520 6861 7368 6573 2063 own the hashes c │ │ │ -0005d850: 616e 6e6f 7420 6265 2076 6572 6966 6965 annot be verifie │ │ │ -0005d860: 6420 7965 740a 0909 6966 2028 6d5f 7472 d yet...if (m_tr │ │ │ -0005d870: 6565 5b72 6f6f 745f 696e 6465 785d 2e69 ee[root_index].i │ │ │ -0005d880: 735f 616c 6c5f 7a65 726f 7328 2929 0a09 s_all_zeros()).. │ │ │ -0005d890: 0909 7265 7475 726e 2073 7464 3a3a 6d61 ..return std::ma │ │ │ -0005d8a0: 6b65 5f74 7570 6c65 2873 6574 5f62 6c6f ke_tuple(set_blo │ │ │ -0005d8b0: 636b 5f72 6573 756c 743a 3a75 6e6b 6e6f ck_result::unkno │ │ │ -0005d8c0: 776e 2c20 6c65 6166 735f 7374 6172 742c wn, leafs_start, │ │ │ -0005d8d0: 206c 6561 6673 5f73 697a 6529 3b0a 0a09 leafs_size);... │ │ │ -0005d8e0: 092f 2f20 7361 7665 2074 6865 2072 6f6f .// save the roo │ │ │ -0005d8f0: 7420 6861 7368 2062 6563 6175 7365 206d t hash because m │ │ │ -0005d900: 6572 6b6c 655f 6669 6c6c 5f74 7265 6520 erkle_fill_tree │ │ │ -0005d910: 7769 6c6c 206f 7665 7277 7269 7465 2069 will overwrite i │ │ │ -0005d920: 740a 0909 7368 6132 3536 5f68 6173 6820 t...sha256_hash │ │ │ -0005d930: 636f 6e73 7420 726f 6f74 203d 206d 5f74 const root = m_t │ │ │ -0005d940: 7265 655b 726f 6f74 5f69 6e64 6578 5d3b ree[root_index]; │ │ │ -0005d950: 0a09 096d 6572 6b6c 655f 6669 6c6c 5f74 ...merkle_fill_t │ │ │ -0005d960: 7265 6528 6d5f 7472 6565 2c20 6c65 6166 ree(m_tree, leaf │ │ │ -0005d970: 735f 7369 7a65 2c20 6669 7273 745f 6c65 s_size, first_le │ │ │ -0005d980: 6166 202b 206c 6561 6673 5f73 7461 7274 af + leafs_start │ │ │ -0005d990: 293b 0a0a 0909 6966 2028 726f 6f74 2021 );....if (root ! │ │ │ -0005d9a0: 3d20 6d5f 7472 6565 5b72 6f6f 745f 696e = m_tree[root_in │ │ │ -0005d9b0: 6465 785d 290a 0909 7b0a 0909 092f 2f20 dex])...{....// │ │ │ -0005d9c0: 6861 7368 2066 6169 6c75 7265 2c20 636c hash failure, cl │ │ │ -0005d9d0: 6561 7220 616c 6c20 7468 6520 696e 7465 ear all the inte │ │ │ -0005d9e0: 726e 616c 206e 6f64 6573 0a09 0909 2f2f rnal nodes....// │ │ │ -0005d9f0: 2074 6865 2077 686f 6c65 2070 6965 6365 the whole piece │ │ │ -0005da00: 2066 6169 6c65 6420 7468 6520 6861 7368 failed the hash │ │ │ -0005da10: 2063 6865 636b 2e20 436c 6561 7220 616c check. Clear al │ │ │ -0005da20: 6c20 626c 6f63 6b20 6861 7368 6573 0a09 l block hashes.. │ │ │ -0005da30: 0909 2f2f 2069 6e20 7468 6973 2070 6965 ..// in this pie │ │ │ -0005da40: 6365 2061 6e64 2072 6570 6f72 7420 6120 ce and report a │ │ │ -0005da50: 6861 7368 2066 6169 6c75 7265 0a09 0909 hash failure.... │ │ │ -0005da60: 6d65 726b 6c65 5f63 6c65 6172 5f74 7265 merkle_clear_tre │ │ │ -0005da70: 6528 6d5f 7472 6565 2c20 6c65 6166 735f e(m_tree, leafs_ │ │ │ -0005da80: 7369 7a65 2c20 6669 7273 745f 6c65 6166 size, first_leaf │ │ │ -0005da90: 202b 206c 6561 6673 5f73 7461 7274 293b + leafs_start); │ │ │ -0005daa0: 0a09 0909 6d5f 7472 6565 5b72 6f6f 745f ....m_tree[root_ │ │ │ -0005dab0: 696e 6465 785d 203d 2072 6f6f 743b 0a09 index] = root;.. │ │ │ -0005dac0: 0909 7265 7475 726e 2073 7464 3a3a 6d61 ..return std::ma │ │ │ -0005dad0: 6b65 5f74 7570 6c65 2873 6574 5f62 6c6f ke_tuple(set_blo │ │ │ -0005dae0: 636b 5f72 6573 756c 743a 3a68 6173 685f ck_result::hash_ │ │ │ -0005daf0: 6661 696c 6564 2c20 6c65 6166 735f 7374 failed, leafs_st │ │ │ -0005db00: 6172 742c 206c 6561 6673 5f73 697a 6529 art, leafs_size) │ │ │ -0005db10: 3b0a 0909 7d0a 0a3c 2f70 7265 3e3c 2f74 ;...}..
    relevanc │ │ │ -0005db50: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/merkle_ │ │ │ -0005db90: 7472 6565 2e63 7070 3a35 3439 3c2f 613e tree.cpp:549 │ │ │ -0005dba0: 3c2f 7464 3e3c 7464 3e74 6869 7320 636f this co │ │ │ -0005dbb0: 756c 6420 6265 2064 6f6e 6520 6d6f 7265 uld be done more │ │ │ -0005dbc0: 2065 6666 6963 6965 6e74 6c79 2069 6620 efficiently if │ │ │ -0005dbd0: 6269 7466 6965 6c64 2068 6164 2061 2066 bitfield had a f │ │ │ -0005dbe0: 756e 6374 696f 6e20 746f 2073 6574 2061 unction to set a │ │ │ -0005dbf0: 2072 616e 6765 206f 6620 6269 7473 3c2f range of bits

    this │ │ │ -0005dc50: 2063 6f75 6c64 2062 6520 646f 6e65 206d could be done m │ │ │ -0005dc60: 6f72 6520 6566 6669 6369 656e 746c 7920 ore efficiently │ │ │ -0005dc70: 6966 2062 6974 6669 656c 6420 6861 6420 if bitfield had │ │ │ -0005dc80: 6120 6675 6e63 7469 6f6e 0a74 6f20 7365 a function.to se │ │ │ -0005dc90: 7420 6120 7261 6e67 6520 6f66 2062 6974 t a range of bit │ │ │ -0005dca0: 733c 2f68 323e 3c68 343e 2e2e 2f73 7263 s

    ../src │ │ │ -0005dcb0: 2f6d 6572 6b6c 655f 7472 6565 2e63 7070 /merkle_tree.cpp │ │ │ -0005dcc0: 3a35 3439 3c2f 6834 3e3c 7072 6520 7374 :549

    ...merkle_fin
    │ │ │ -0005dd10: 645f 6b6e 6f77 6e5f 7375 6274 7265 6528  d_known_subtree(
    │ │ │ -0005dd20: 6d5f 7472 6565 2c20 626c 6f63 6b5f 696e  m_tree, block_in
    │ │ │ -0005dd30: 6465 782c 206d 5f6e 756d 5f62 6c6f 636b  dex, m_num_block
    │ │ │ -0005dd40: 7329 3b0a 0a09 092f 2f20 6966 2074 6865  s);....// if the
    │ │ │ -0005dd50: 2072 6f6f 7420 6e6f 6465 2069 7320 756e   root node is un
    │ │ │ -0005dd60: 6b6e 6f77 6e20 7468 6520 6861 7368 6573  known the hashes
    │ │ │ -0005dd70: 2063 616e 6e6f 7420 6265 2076 6572 6966   cannot be verif
    │ │ │ -0005dd80: 6965 6420 7965 740a 0909 6966 2028 6d5f  ied yet...if (m_
    │ │ │ -0005dd90: 7472 6565 5b72 6f6f 745f 696e 6465 785d  tree[root_index]
    │ │ │ -0005dda0: 2e69 735f 616c 6c5f 7a65 726f 7328 2929  .is_all_zeros())
    │ │ │ -0005ddb0: 0a09 0909 7265 7475 726e 2073 7464 3a3a  ....return std::
    │ │ │ -0005ddc0: 6d61 6b65 5f74 7570 6c65 2873 6574 5f62  make_tuple(set_b
    │ │ │ -0005ddd0: 6c6f 636b 5f72 6573 756c 743a 3a75 6e6b  lock_result::unk
    │ │ │ -0005dde0: 6e6f 776e 2c20 6c65 6166 735f 7374 6172  nown, leafs_star
    │ │ │ -0005ddf0: 742c 206c 6561 6673 5f73 697a 6529 3b0a  t, leafs_size);.
    │ │ │ -0005de00: 0a09 092f 2f20 7361 7665 2074 6865 2072  ...// save the r
    │ │ │ -0005de10: 6f6f 7420 6861 7368 2062 6563 6175 7365  oot hash because
    │ │ │ -0005de20: 206d 6572 6b6c 655f 6669 6c6c 5f74 7265   merkle_fill_tre
    │ │ │ -0005de30: 6520 7769 6c6c 206f 7665 7277 7269 7465  e will overwrite
    │ │ │ -0005de40: 2069 740a 0909 7368 6132 3536 5f68 6173   it...sha256_has
    │ │ │ -0005de50: 6820 636f 6e73 7420 726f 6f74 203d 206d  h const root = m
    │ │ │ -0005de60: 5f74 7265 655b 726f 6f74 5f69 6e64 6578  _tree[root_index
    │ │ │ -0005de70: 5d3b 0a09 096d 6572 6b6c 655f 6669 6c6c  ];...merkle_fill
    │ │ │ -0005de80: 5f74 7265 6528 6d5f 7472 6565 2c20 6c65  _tree(m_tree, le
    │ │ │ -0005de90: 6166 735f 7369 7a65 2c20 6669 7273 745f  afs_size, first_
    │ │ │ -0005dea0: 6c65 6166 202b 206c 6561 6673 5f73 7461  leaf + leafs_sta
    │ │ │ -0005deb0: 7274 293b 0a0a 0909 6966 2028 726f 6f74  rt);....if (root
    │ │ │ -0005dec0: 2021 3d20 6d5f 7472 6565 5b72 6f6f 745f   != m_tree[root_
    │ │ │ -0005ded0: 696e 6465 785d 290a 0909 7b0a 0909 092f  index])...{..../
    │ │ │ -0005dee0: 2f20 6861 7368 2066 6169 6c75 7265 2c20  / hash failure, 
    │ │ │ -0005def0: 636c 6561 7220 616c 6c20 7468 6520 696e  clear all the in
    │ │ │ -0005df00: 7465 726e 616c 206e 6f64 6573 0a09 0909  ternal nodes....
    │ │ │ -0005df10: 2f2f 2074 6865 2077 686f 6c65 2070 6965  // the whole pie
    │ │ │ -0005df20: 6365 2066 6169 6c65 6420 7468 6520 6861  ce failed the ha
    │ │ │ -0005df30: 7368 2063 6865 636b 2e20 436c 6561 7220  sh check. Clear 
    │ │ │ -0005df40: 616c 6c20 626c 6f63 6b20 6861 7368 6573  all block hashes
    │ │ │ -0005df50: 0a09 0909 2f2f 2069 6e20 7468 6973 2070  ....// in this p
    │ │ │ -0005df60: 6965 6365 2061 6e64 2072 6570 6f72 7420  iece and report 
    │ │ │ -0005df70: 6120 6861 7368 2066 6169 6c75 7265 0a09  a hash failure..
    │ │ │ -0005df80: 0909 6d65 726b 6c65 5f63 6c65 6172 5f74  ..merkle_clear_t
    │ │ │ -0005df90: 7265 6528 6d5f 7472 6565 2c20 6c65 6166  ree(m_tree, leaf
    │ │ │ -0005dfa0: 735f 7369 7a65 2c20 6669 7273 745f 6c65  s_size, first_le
    │ │ │ -0005dfb0: 6166 202b 206c 6561 6673 5f73 7461 7274  af + leafs_start
    │ │ │ -0005dfc0: 293b 0a09 0909 6d5f 7472 6565 5b72 6f6f  );....m_tree[roo
    │ │ │ -0005dfd0: 745f 696e 6465 785d 203d 2072 6f6f 743b  t_index] = root;
    │ │ │ -0005dfe0: 0a09 0909 7265 7475 726e 2073 7464 3a3a  ....return std::
    │ │ │ -0005dff0: 6d61 6b65 5f74 7570 6c65 2873 6574 5f62  make_tuple(set_b
    │ │ │ -0005e000: 6c6f 636b 5f72 6573 756c 743a 3a68 6173  lock_result::has
    │ │ │ -0005e010: 685f 6661 696c 6564 2c20 6c65 6166 735f  h_failed, leafs_
    │ │ │ -0005e020: 7374 6172 742c 206c 6561 6673 5f73 697a  start, leafs_siz
    │ │ │ -0005e030: 6529 3b0a 0909 7d0a 0a3c 6469 7620 7374  e);...}..
    ..int con │ │ │ -0005e070: 7374 206c 6561 6673 5f65 6e64 203d 2073 st leafs_end = s │ │ │ -0005e080: 7464 3a3a 6d69 6e28 6d5f 6e75 6d5f 626c td::min(m_num_bl │ │ │ -0005e090: 6f63 6b73 2c20 6c65 6166 735f 7374 6172 ocks, leafs_star │ │ │ -0005e0a0: 7420 2b20 6c65 6166 735f 7369 7a65 293b t + leafs_size); │ │ │ -0005e0b0: 0a3c 2f64 6976 3e09 0966 6f72 2028 696e .
    ..for (in │ │ │ -0005e0c0: 7420 6920 3d20 6c65 6166 735f 7374 6172 t i = leafs_star │ │ │ -0005e0d0: 743b 2069 2026 6c74 3b20 6c65 6166 735f t; i < leafs_ │ │ │ -0005e0e0: 656e 643b 202b 2b69 290a 0909 096d 5f62 end; ++i)....m_b │ │ │ -0005e0f0: 6c6f 636b 5f76 6572 6966 6965 642e 7365 lock_verified.se │ │ │ -0005e100: 745f 6269 7428 6929 3b0a 0a09 092f 2f20 t_bit(i);....// │ │ │ -0005e110: 6174 7465 6d70 7469 6e67 2074 6f20 6f70 attempting to op │ │ │ -0005e120: 7469 6d69 7a65 2073 746f 7261 6765 2069 timize storage i │ │ │ -0005e130: 7320 7175 6974 6520 636f 7374 6c79 2c20 s quite costly, │ │ │ -0005e140: 6f6e 6c79 2064 6f20 6974 2069 6620 7765 only do it if we │ │ │ -0005e150: 2068 6176 650a 0909 2f2f 2061 2072 6561 have...// a rea │ │ │ -0005e160: 736f 6e20 746f 2062 656c 6965 7665 2069 son to believe i │ │ │ -0005e170: 7420 6d69 6768 7420 6861 7665 2061 6e20 t might have an │ │ │ -0005e180: 6566 6665 6374 0a09 0969 6620 2862 6c6f effect...if (blo │ │ │ -0005e190: 636b 5f69 6e64 6578 203d 3d20 6d5f 6e75 ck_index == m_nu │ │ │ -0005e1a0: 6d5f 626c 6f63 6b73 202d 2031 207c 7c20 m_blocks - 1 || │ │ │ -0005e1b0: 216d 5f74 7265 655b 626c 6f63 6b5f 7472 !m_tree[block_tr │ │ │ -0005e1c0: 6565 5f69 6e64 6578 202b 2031 5d2e 6973 ee_index + 1].is │ │ │ -0005e1d0: 5f61 6c6c 5f7a 6572 6f73 2829 290a 0909 _all_zeros())... │ │ │ -0005e1e0: 096f 7074 696d 697a 655f 7374 6f72 6167 .optimize_storag │ │ │ -0005e1f0: 6528 293b 0a0a 0909 7265 7475 726e 2073 e();....return s │ │ │ -0005e200: 7464 3a3a 6d61 6b65 5f74 7570 6c65 2873 td::make_tuple(s │ │ │ -0005e210: 6574 5f62 6c6f 636b 5f72 6573 756c 743a et_block_result: │ │ │ -0005e220: 3a6f 6b2c 206c 6561 6673 5f73 7461 7274 :ok, leafs_start │ │ │ -0005e230: 2c20 6c65 6166 735f 7369 7a65 293b 0a09 , leafs_size);.. │ │ │ -0005e240: 7d0a 0a09 7374 643a 3a73 697a 655f 7420 }...std::size_t │ │ │ -0005e250: 6d65 726b 6c65 5f74 7265 653a 3a73 697a merkle_tree::siz │ │ │ -0005e260: 6528 2920 636f 6e73 740a 097b 0a09 0972 e() const..{...r │ │ │ -0005e270: 6574 7572 6e20 7374 6174 6963 5f63 6173 eturn static_cas │ │ │ -0005e280: 7426 6c74 3b73 7464 3a3a 7369 7a65 5f74 t<std::size_t │ │ │ -0005e290: 2667 743b 286d 6572 6b6c 655f 6e75 6d5f >(merkle_num_ │ │ │ -0005e2a0: 6e6f 6465 7328 6d65 726b 6c65 5f6e 756d nodes(merkle_num │ │ │ -0005e2b0: 5f6c 6561 6673 286d 5f6e 756d 5f62 6c6f _leafs(m_num_blo │ │ │ -0005e2c0: 636b 7329 2929 3b0a 097d 0a0a 0969 6e74 cks)));..}...int │ │ │ -0005e2d0: 206d 6572 6b6c 655f 7472 6565 3a3a 6e75 merkle_tree::nu │ │ │ -0005e2e0: 6d5f 7069 6563 6573 2829 2063 6f6e 7374 m_pieces() const │ │ │ -0005e2f0: 0a09 7b0a 0909 696e 7420 636f 6e73 7420 ..{...int const │ │ │ -0005e300: 7073 203d 2062 6c6f 636b 735f 7065 725f ps = blocks_per_ │ │ │ -0005e310: 7069 6563 6528 293b 0a09 0954 4f52 5245 piece();...TORRE │ │ │ -0005e320: 4e54 5f41 5353 4552 5428 7073 2026 6774 NT_ASSERT(ps > │ │ │ -0005e330: 3b20 3029 3b0a 0909 7265 7475 726e 2028 ; 0);...return ( │ │ │ -0005e340: 6d5f 6e75 6d5f 626c 6f63 6b73 202b 2070 m_num_blocks + p │ │ │ -0005e350: 7320 2d20 3129 2026 6774 3b26 6774 3b20 s - 1) >> │ │ │ -0005e360: 6d5f 626c 6f63 6b73 5f70 6572 5f70 6965 m_blocks_per_pie │ │ │ -0005e370: 6365 5f6c 6f67 3b0a 097d 0a0a 0969 6e74 ce_log;..}...int │ │ │ -0005e380: 206d 6572 6b6c 655f 7472 6565 3a3a 626c merkle_tree::bl │ │ │ -0005e390: 6f63 6b5f 6c61 7965 725f 7374 6172 7428 ock_layer_start( │ │ │ -0005e3a0: 2920 636f 6e73 740a 097b 0a09 0969 6e74 ) const..{...int │ │ │ -0005e3b0: 2063 6f6e 7374 206e 756d 5f6c 6561 6673 const num_leafs │ │ │ -0005e3c0: 203d 206d 6572 6b6c 655f 6e75 6d5f 6c65 = merkle_num_le │ │ │ -0005e3d0: 6166 7328 6d5f 6e75 6d5f 626c 6f63 6b73 afs(m_num_blocks │ │ │ -0005e3e0: 293b 0a09 0954 4f52 5245 4e54 5f41 5353 );...TORRENT_ASS │ │ │ -0005e3f0: 4552 5428 6e75 6d5f 6c65 6166 7320 2667 ERT(num_leafs &g │ │ │ -0005e400: 743b 2030 293b 0a09 0972 6574 7572 6e20 t; 0);...return │ │ │ -0005e410: 6d65 726b 6c65 5f66 6972 7374 5f6c 6561 merkle_first_lea │ │ │ -0005e420: 6628 6e75 6d5f 6c65 6166 7329 3b0a 097d f(num_leafs);..} │ │ │ -0005e430: 0a0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ..
    < │ │ │ -0005e460: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0005e470: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0005e4a0: 7372 632f 6d61 676e 6574 5f75 7269 2e63 src/magnet_uri.c │ │ │ -0005e4b0: 7070 3a34 3531 3c2f 613e 3c2f 7464 3e3c pp:451< │ │ │ -0005e4c0: 7464 3e77 6861 7427 7320 7468 6520 7269 td>what's the ri │ │ │ -0005e4d0: 6768 7420 6e75 6d62 6572 2068 6572 653f ght number here? │ │ │ -0005e4e0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    wh │ │ │ -0005e530: 6174 2773 2074 6865 2072 6967 6874 206e at's the right n │ │ │ -0005e540: 756d 6265 7220 6865 7265 3f3c 2f68 323e umber here?

    │ │ │ -0005e550: 3c68 343e 2e2e 2f73 7263 2f6d 6167 6e65

    ../src/magne │ │ │ -0005e560: 745f 7572 692e 6370 703a 3435 313c 2f68 t_uri.cpp:451
    ...}
    │ │ │ -0005e5b0: 0a09 0909 656c 7365 2069 6620 2873 7472  ....else if (str
    │ │ │ -0005e5c0: 696e 675f 6571 7561 6c5f 6e6f 5f63 6173  ing_equal_no_cas
    │ │ │ -0005e5d0: 6528 6e61 6d65 2c20 2273 6f22 5f73 7629  e(name, "so"_sv)
    │ │ │ -0005e5e0: 2920 2f2f 2073 656c 6563 742d 6f6e 6c79  ) // select-only
    │ │ │ -0005e5f0: 2028 6669 6c65 7329 0a09 0909 7b0a 0909   (files)....{...
    │ │ │ -0005e600: 0909 2f2f 2061 6363 6570 7420 6f6e 6c79  ..// accept only
    │ │ │ -0005e610: 2064 6967 6974 732c 2027 2d27 2061 6e64   digits, '-' and
    │ │ │ -0005e620: 2027 2c27 0a09 0909 0969 6620 2873 7464   ','.....if (std
    │ │ │ -0005e630: 3a3a 616e 795f 6f66 2876 616c 7565 2e62  ::any_of(value.b
    │ │ │ -0005e640: 6567 696e 2829 2c20 7661 6c75 652e 656e  egin(), value.en
    │ │ │ -0005e650: 6428 292c 205b 5d28 6368 6172 2063 290a  d(), [](char c).
    │ │ │ -0005e660: 0909 0909 097b 2072 6574 7572 6e20 2169  .....{ return !i
    │ │ │ -0005e670: 735f 6469 6769 7428 6329 2026 616d 703b  s_digit(c) &
    │ │ │ -0005e680: 2661 6d70 3b20 6320 213d 2027 2d27 2026  & c != '-' &
    │ │ │ -0005e690: 616d 703b 2661 6d70 3b20 6320 213d 2027  amp;& c != '
    │ │ │ -0005e6a0: 2c27 3b20 7d29 290a 0909 0909 0963 6f6e  ,'; }))......con
    │ │ │ -0005e6b0: 7469 6e75 653b 0a0a 0909 0909 2f2f 206d  tinue;......// m
    │ │ │ -0005e6c0: 616b 6520 7375 7265 2061 6c6c 2066 696c  ake sure all fil
    │ │ │ -0005e6d0: 6520 7072 696f 7269 7469 6573 2061 7265  e priorities are
    │ │ │ -0005e6e0: 2073 6574 2074 6f20 302c 2065 7863 6570   set to 0, excep
    │ │ │ -0005e6f0: 7420 7468 6520 6f6e 6573 0a09 0909 092f  t the ones...../
    │ │ │ -0005e700: 2f20 7765 2073 7065 6369 6679 2069 6e20  / we specify in 
    │ │ │ -0005e710: 7468 6520 6669 6c65 5f70 7269 6f72 6974  the file_priorit
    │ │ │ -0005e720: 6965 730a 0909 0909 702e 666c 6167 7320  ies.....p.flags 
    │ │ │ -0005e730: 7c3d 2074 6f72 7265 6e74 5f66 6c61 6773  |= torrent_flags
    │ │ │ -0005e740: 3a3a 6465 6661 756c 745f 646f 6e74 5f64  ::default_dont_d
    │ │ │ -0005e750: 6f77 6e6c 6f61 643b 0a0a 0909 0909 646f  ownload;......do
    │ │ │ -0005e760: 0a09 0909 097b 0a09 0909 0909 7374 7269  .....{......stri
    │ │ │ -0005e770: 6e67 5f76 6965 7720 746f 6b65 6e3b 0a09  ng_view token;..
    │ │ │ -0005e780: 0909 0909 7374 643a 3a74 6965 2874 6f6b  ....std::tie(tok
    │ │ │ -0005e790: 656e 2c20 7661 6c75 6529 203d 2073 706c  en, value) = spl
    │ │ │ -0005e7a0: 6974 5f73 7472 696e 6728 7661 6c75 652c  it_string(value,
    │ │ │ -0005e7b0: 2027 2c27 293b 0a0a 0909 0909 0969 6620   ',');.......if 
    │ │ │ -0005e7c0: 2874 6f6b 656e 2e65 6d70 7479 2829 2920  (token.empty()) 
    │ │ │ -0005e7d0: 636f 6e74 696e 7565 3b0a 0a09 0909 0909  continue;.......
    │ │ │ -0005e7e0: 696e 7420 6964 7831 2c20 6964 7832 3b0a  int idx1, idx2;.
    │ │ │ -0005e7f0: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ -0005e820: 0909 0963 6f6e 7374 6578 7072 2069 6e74 ...constexpr int │ │ │ -0005e830: 206d 6178 5f69 6e64 6578 203d 2031 3030 max_index = 100 │ │ │ -0005e840: 3030 3b20 2f2f 2063 616e 2774 2072 6973 00; // can't ris │ │ │ -0005e850: 6b20 6f75 7420 6f66 206d 656d 6f72 790a k out of memory. │ │ │ -0005e860: 3c2f 6469 763e 0a09 0909 0909 6175 746f
    ......auto │ │ │ -0005e870: 2063 6f6e 7374 2064 6976 6964 6572 203d const divider = │ │ │ -0005e880: 2074 6f6b 656e 2e66 696e 645f 6669 7273 token.find_firs │ │ │ -0005e890: 745f 6f66 2827 2d27 293b 0a09 0909 0909 t_of('-');...... │ │ │ -0005e8a0: 6966 2028 6469 7669 6465 7220 213d 2073 if (divider != s │ │ │ -0005e8b0: 7464 3a3a 7374 7269 6e67 3a3a 6e70 6f73 td::string::npos │ │ │ -0005e8c0: 2920 2f2f 2069 7427 7320 6120 7261 6e67 ) // it's a rang │ │ │ -0005e8d0: 650a 0909 0909 097b 0a09 0909 0909 0969 e......{.......i │ │ │ -0005e8e0: 6620 2864 6976 6964 6572 203d 3d20 3029 f (divider == 0) │ │ │ -0005e8f0: 202f 2f20 6e6f 2073 7461 7274 2069 6e64 // no start ind │ │ │ -0005e900: 6578 0a09 0909 0909 0909 636f 6e74 696e ex........contin │ │ │ -0005e910: 7565 3b0a 0909 0909 0909 6966 2028 6469 ue;.......if (di │ │ │ -0005e920: 7669 6465 7220 3d3d 2074 6f6b 656e 2e73 vider == token.s │ │ │ -0005e930: 697a 6528 2920 2d20 3129 202f 2f20 6e6f ize() - 1) // no │ │ │ -0005e940: 2065 6e64 2069 6e64 6578 0a09 0909 0909 end index...... │ │ │ -0005e950: 0909 636f 6e74 696e 7565 3b0a 0a09 0909 ..continue;..... │ │ │ -0005e960: 0909 0969 6478 3120 3d20 7374 643a 3a61 ...idx1 = std::a │ │ │ -0005e970: 746f 6928 746f 6b65 6e2e 7375 6273 7472 toi(token.substr │ │ │ -0005e980: 2830 2c20 6469 7669 6465 7229 2e74 6f5f (0, divider).to_ │ │ │ -0005e990: 7374 7269 6e67 2829 2e63 5f73 7472 2829 string().c_str() │ │ │ -0005e9a0: 293b 0a09 0909 0909 0969 6620 2869 6478 );.......if (idx │ │ │ -0005e9b0: 3120 266c 743b 2030 207c 7c20 6964 7831 1 < 0 || idx1 │ │ │ -0005e9c0: 2026 6774 3b20 6d61 785f 696e 6465 7829 > max_index) │ │ │ -0005e9d0: 202f 2f20 696e 7661 6c69 6420 696e 6465 // invalid inde │ │ │ -0005e9e0: 780a 0909 0909 0909 0963 6f6e 7469 6e75 x........continu │ │ │ -0005e9f0: 653b 0a09 0909 0909 0969 6478 3220 3d20 e;.......idx2 = │ │ │ -0005ea00: 7374 643a 3a61 746f 6928 746f 6b65 6e2e std::atoi(token. │ │ │ -0005ea10: 7375 6273 7472 2864 6976 6964 6572 202b substr(divider + │ │ │ -0005ea20: 2031 292e 746f 5f73 7472 696e 6728 292e 1).to_string(). │ │ │ -0005ea30: 635f 7374 7228 2929 3b0a 0909 0909 0909 c_str());....... │ │ │ -0005ea40: 6966 2028 6964 7832 2026 6c74 3b20 3020 if (idx2 < 0 │ │ │ -0005ea50: 7c7c 2069 6478 3220 2667 743b 206d 6178 || idx2 > max │ │ │ -0005ea60: 5f69 6e64 6578 2920 2f2f 2069 6e76 616c _index) // inval │ │ │ -0005ea70: 6964 2069 6e64 6578 0a09 0909 0909 0909 id index........ │ │ │ -0005ea80: 636f 6e74 696e 7565 3b0a 0a09 0909 0909 continue;....... │ │ │ -0005ea90: 0969 6620 2869 6478 3120 2667 743b 2069 .if (idx1 > i │ │ │ -0005eaa0: 6478 3229 202f 2f20 7772 6f6e 6720 7261 dx2) // wrong ra │ │ │ -0005eab0: 6e67 6520 6c69 6d69 7473 0a09 0909 0909 nge limits...... │ │ │ -0005eac0: 0909 636f 6e74 696e 7565 3b0a 0909 0909 ..continue;..... │ │ │ -0005ead0: 097d 0a09 0909 0909 656c 7365 202f 2f20 .}......else // │ │ │ -0005eae0: 6974 2773 2061 6e20 696e 6465 780a 0909 it's an index... │ │ │ -0005eaf0: 0909 097b 0a09 0909 0909 0969 6478 3120 ...{.......idx1 │ │ │ -0005eb00: 3d20 7374 643a 3a61 746f 6928 746f 6b65 = std::atoi(toke │ │ │ -0005eb10: 6e2e 746f 5f73 7472 696e 6728 292e 635f n.to_string().c_ │ │ │ -0005eb20: 7374 7228 2929 3b0a 0909 0909 0909 6966 str());.......if │ │ │ -0005eb30: 2028 6964 7831 2026 6c74 3b20 3020 7c7c (idx1 < 0 || │ │ │ -0005eb40: 2069 6478 3120 2667 743b 206d 6178 5f69 idx1 > max_i │ │ │ -0005eb50: 6e64 6578 2920 2f2f 2069 6e76 616c 6964 ndex) // invalid │ │ │ -0005eb60: 2069 6e64 6578 0a09 0909 0909 0909 636f index........co │ │ │ -0005eb70: 6e74 696e 7565 3b0a 0909 0909 0909 6964 ntinue;.......id │ │ │ -0005eb80: 7832 203d 2069 6478 313b 0a09 0909 0909 x2 = idx1;...... │ │ │ -0005eb90: 7d0a 0a09 0909 0909 6966 2028 696e 7428 }.......if (int( │ │ │ -0005eba0: 702e 6669 6c65 5f70 7269 6f72 6974 6965 p.file_prioritie │ │ │ -0005ebb0: 732e 7369 7a65 2829 2920 266c 743b 3d20 s.size()) <= │ │ │ -0005ebc0: 6964 7832 290a 0909 0909 0909 702e 6669 idx2).......p.fi │ │ │ -0005ebd0: 6c65 5f70 7269 6f72 6974 6965 732e 7265 le_priorities.re │ │ │ -0005ebe0: 7369 7a65 2873 7461 7469 635f 6361 7374 size(static_cast │ │ │ -0005ebf0: 266c 743b 7374 643a 3a73 697a 655f 7426 <std::size_t& │ │ │ -0005ec00: 6774 3b28 6964 7832 2920 2b20 312c 2064 gt;(idx2) + 1, d │ │ │ -0005ec10: 6f6e 745f 646f 776e 6c6f 6164 293b 0a0a ont_download);.. │ │ │ -0005ec20: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0005ec30: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0005ec60: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -0005ec90: 632f 6c6f 6164 5f74 6f72 7265 6e74 2e63 c/load_torrent.c │ │ │ -0005eca0: 7070 3a31 3231 3c2f 613e 3c2f 7464 3e3c pp:121< │ │ │ -0005ecb0: 7464 3e6d 6f76 6520 7468 6520 6c6f 6164 td>move the load │ │ │ -0005ecc0: 696e 6720 6c6f 6769 6320 6672 6f6d 2074 ing logic from t │ │ │ -0005ecd0: 6f72 7265 6e74 5f69 6e66 6f20 636f 6e73 orrent_info cons │ │ │ -0005ece0: 7472 7563 746f 7220 696e 746f 2068 6572 tructor into her │ │ │ -0005ecf0: 653c 2f74 643e 3c2f 7472 3e3c 7472 2069 e

    m │ │ │ -0005ed40: 6f76 6520 7468 6520 6c6f 6164 696e 6720 ove the loading │ │ │ -0005ed50: 6c6f 6769 6320 6672 6f6d 2074 6f72 7265 logic from torre │ │ │ -0005ed60: 6e74 5f69 6e66 6f20 636f 6e73 7472 7563 nt_info construc │ │ │ -0005ed70: 746f 7220 696e 746f 2068 6572 653c 2f68 tor into here

    ../src/loa │ │ │ -0005ed90: 645f 746f 7272 656e 742e 6370 703a 3132 d_torrent.cpp:12 │ │ │ -0005eda0: 313c 2f68 343e 3c70 7265 2073 7479 6c65 1

    │ │ │ -0005ede0: 0909 0909 6d61 736b 2e72 6573 697a 6528  ....mask.resize(
    │ │ │ -0005edf0: 7374 643a 3a73 697a 655f 7428 6675 6c6c  std::size_t(full
    │ │ │ -0005ee00: 5f73 697a 6529 2c20 6661 6c73 6529 3b0a  _size), false);.
    │ │ │ -0005ee10: 0909 0909 666f 7220 2869 6e74 2069 203d  ....for (int i =
    │ │ │ -0005ee20: 206d 6572 6b6c 655f 6669 7273 745f 6c65   merkle_first_le
    │ │ │ -0005ee30: 6166 2870 6965 6365 5f6c 6179 6572 5f73  af(piece_layer_s
    │ │ │ -0005ee40: 697a 6529 0a09 0909 0909 2c20 656e 6420  ize)......, end 
    │ │ │ -0005ee50: 3d20 6920 2b20 6e75 6d5f 7069 6563 6573  = i + num_pieces
    │ │ │ -0005ee60: 3b20 6920 266c 743b 2065 6e64 3b20 2b2b  ; i < end; ++
    │ │ │ -0005ee70: 6929 0a09 0909 097b 0a09 0909 0909 6d61  i).....{......ma
    │ │ │ -0005ee80: 736b 5b73 7464 3a3a 7369 7a65 5f74 2869  sk[std::size_t(i
    │ │ │ -0005ee90: 295d 203d 2074 7275 653b 0a09 0909 097d  )] = true;.....}
    │ │ │ -0005eea0: 0a09 0909 7d0a 0909 0974 692d 2667 743b  ....}....ti->
    │ │ │ -0005eeb0: 6672 6565 5f70 6965 6365 5f6c 6179 6572  free_piece_layer
    │ │ │ -0005eec0: 7328 293b 0a09 097d 0a09 0961 7470 2e69  s();...}...atp.i
    │ │ │ -0005eed0: 6e66 6f5f 6861 7368 6573 203d 2061 7470  nfo_hashes = atp
    │ │ │ -0005eee0: 2e74 692d 2667 743b 696e 666f 5f68 6173  .ti->info_has
    │ │ │ -0005eef0: 6865 7328 293b 0a09 7d0a 7d0a 0a09 6164  hes();..}.}...ad
    │ │ │ -0005ef00: 645f 746f 7272 656e 745f 7061 7261 6d73  d_torrent_params
    │ │ │ -0005ef10: 206c 6f61 645f 746f 7272 656e 745f 6669   load_torrent_fi
    │ │ │ -0005ef20: 6c65 2873 7464 3a3a 7374 7269 6e67 2063  le(std::string c
    │ │ │ -0005ef30: 6f6e 7374 2661 6d70 3b20 6669 6c65 6e61  onst& filena
    │ │ │ -0005ef40: 6d65 290a 097b 2072 6574 7572 6e20 6c6f  me)..{ return lo
    │ │ │ -0005ef50: 6164 5f74 6f72 7265 6e74 5f66 696c 6528  ad_torrent_file(
    │ │ │ -0005ef60: 6669 6c65 6e61 6d65 2c20 6c6f 6164 5f74  filename, load_t
    │ │ │ -0005ef70: 6f72 7265 6e74 5f6c 696d 6974 737b 7d29  orrent_limits{})
    │ │ │ -0005ef80: 3b20 7d0a 0961 6464 5f74 6f72 7265 6e74  ; }..add_torrent
    │ │ │ -0005ef90: 5f70 6172 616d 7320 6c6f 6164 5f74 6f72  _params load_tor
    │ │ │ -0005efa0: 7265 6e74 5f62 7566 6665 7228 7370 616e  rent_buffer(span
    │ │ │ -0005efb0: 266c 743b 6368 6172 2063 6f6e 7374 2667  <char const&g
    │ │ │ -0005efc0: 743b 2062 7566 6665 7229 0a09 7b20 7265  t; buffer)..{ re
    │ │ │ -0005efd0: 7475 726e 206c 6f61 645f 746f 7272 656e  turn load_torren
    │ │ │ -0005efe0: 745f 6275 6666 6572 2862 7566 6665 722c  t_buffer(buffer,
    │ │ │ -0005eff0: 206c 6f61 645f 746f 7272 656e 745f 6c69   load_torrent_li
    │ │ │ -0005f000: 6d69 7473 7b7d 293b 207d 0a09 6164 645f  mits{}); }..add_
    │ │ │ -0005f010: 746f 7272 656e 745f 7061 7261 6d73 206c  torrent_params l
    │ │ │ -0005f020: 6f61 645f 746f 7272 656e 745f 7061 7273  oad_torrent_pars
    │ │ │ -0005f030: 6564 2862 6465 636f 6465 5f6e 6f64 6520  ed(bdecode_node 
    │ │ │ -0005f040: 636f 6e73 7426 616d 703b 2074 6f72 7265  const& torre
    │ │ │ -0005f050: 6e74 5f66 696c 6529 0a09 7b20 7265 7475  nt_file)..{ retu
    │ │ │ -0005f060: 726e 206c 6f61 645f 746f 7272 656e 745f  rn load_torrent_
    │ │ │ -0005f070: 7061 7273 6564 2874 6f72 7265 6e74 5f66  parsed(torrent_f
    │ │ │ -0005f080: 696c 652c 206c 6f61 645f 746f 7272 656e  ile, load_torren
    │ │ │ -0005f090: 745f 6c69 6d69 7473 7b7d 293b 207d 0a0a  t_limits{}); }..
    │ │ │ -0005f0a0: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .a │ │ │ -0005f0d0: 6464 5f74 6f72 7265 6e74 5f70 6172 616d dd_torrent_param │ │ │ -0005f0e0: 7320 6c6f 6164 5f74 6f72 7265 6e74 5f66 s load_torrent_f │ │ │ -0005f0f0: 696c 6528 7374 643a 3a73 7472 696e 6720 ile(std::string │ │ │ -0005f100: 636f 6e73 7426 616d 703b 2066 696c 656e const& filen │ │ │ -0005f110: 616d 652c 206c 6f61 645f 746f 7272 656e ame, load_torren │ │ │ -0005f120: 745f 6c69 6d69 7473 2063 6f6e 7374 2661 t_limits const&a │ │ │ -0005f130: 6d70 3b20 6366 6729 0a3c 2f64 6976 3e09 mp; cfg).
    . │ │ │ -0005f140: 7b0a 0909 6164 645f 746f 7272 656e 745f {...add_torrent_ │ │ │ -0005f150: 7061 7261 6d73 2072 6574 3b0a 0909 7265 params ret;...re │ │ │ -0005f160: 742e 7469 203d 2073 7464 3a3a 6d61 6b65 t.ti = std::make │ │ │ -0005f170: 5f73 6861 7265 6426 6c74 3b74 6f72 7265 _shared<torre │ │ │ -0005f180: 6e74 5f69 6e66 6f26 6774 3b28 6669 6c65 nt_info>(file │ │ │ -0005f190: 6e61 6d65 2c20 6366 6729 3b0a 0909 7570 name, cfg);...up │ │ │ -0005f1a0: 6461 7465 5f61 7470 2872 6574 293b 0a09 date_atp(ret);.. │ │ │ -0005f1b0: 0972 6574 7572 6e20 7265 743b 0a09 7d0a .return ret;..}. │ │ │ -0005f1c0: 0a09 6164 645f 746f 7272 656e 745f 7061 ..add_torrent_pa │ │ │ -0005f1d0: 7261 6d73 206c 6f61 645f 746f 7272 656e rams load_torren │ │ │ -0005f1e0: 745f 6275 6666 6572 2873 7061 6e26 6c74 t_buffer(span< │ │ │ -0005f1f0: 3b63 6861 7220 636f 6e73 7426 6774 3b20 ;char const> │ │ │ -0005f200: 6275 6666 6572 2c20 6c6f 6164 5f74 6f72 buffer, load_tor │ │ │ -0005f210: 7265 6e74 5f6c 696d 6974 7320 636f 6e73 rent_limits cons │ │ │ -0005f220: 7426 616d 703b 2063 6667 290a 097b 0a09 t& cfg)..{.. │ │ │ -0005f230: 0961 6464 5f74 6f72 7265 6e74 5f70 6172 .add_torrent_par │ │ │ -0005f240: 616d 7320 7265 743b 0a09 0972 6574 2e74 ams ret;...ret.t │ │ │ -0005f250: 6920 3d20 7374 643a 3a6d 616b 655f 7368 i = std::make_sh │ │ │ -0005f260: 6172 6564 266c 743b 746f 7272 656e 745f ared<torrent_ │ │ │ -0005f270: 696e 666f 2667 743b 2862 7566 6665 722c info>(buffer, │ │ │ -0005f280: 2063 6667 2c20 6672 6f6d 5f73 7061 6e29 cfg, from_span) │ │ │ -0005f290: 3b0a 0909 7570 6461 7465 5f61 7470 2872 ;...update_atp(r │ │ │ -0005f2a0: 6574 293b 0a09 0972 6574 7572 6e20 7265 et);...return re │ │ │ -0005f2b0: 743b 0a09 7d0a 0a09 6164 645f 746f 7272 t;..}...add_torr │ │ │ -0005f2c0: 656e 745f 7061 7261 6d73 206c 6f61 645f ent_params load_ │ │ │ -0005f2d0: 746f 7272 656e 745f 7061 7273 6564 2862 torrent_parsed(b │ │ │ -0005f2e0: 6465 636f 6465 5f6e 6f64 6520 636f 6e73 decode_node cons │ │ │ -0005f2f0: 7426 616d 703b 2074 6f72 7265 6e74 5f66 t& torrent_f │ │ │ -0005f300: 696c 652c 206c 6f61 645f 746f 7272 656e ile, load_torren │ │ │ -0005f310: 745f 6c69 6d69 7473 2063 6f6e 7374 2661 t_limits const&a │ │ │ -0005f320: 6d70 3b20 6366 6729 0a09 7b0a 0909 6164 mp; cfg)..{...ad │ │ │ -0005f330: 645f 746f 7272 656e 745f 7061 7261 6d73 d_torrent_params │ │ │ -0005f340: 2072 6574 3b0a 0909 7265 742e 7469 203d ret;...ret.ti = │ │ │ -0005f350: 2073 7464 3a3a 6d61 6b65 5f73 6861 7265 std::make_share │ │ │ -0005f360: 6426 6c74 3b74 6f72 7265 6e74 5f69 6e66 d<torrent_inf │ │ │ -0005f370: 6f26 6774 3b28 746f 7272 656e 745f 6669 o>(torrent_fi │ │ │ -0005f380: 6c65 2c20 6366 6729 3b0a 0909 7570 6461 le, cfg);...upda │ │ │ -0005f390: 7465 5f61 7470 2872 6574 293b 0a09 0972 te_atp(ret);...r │ │ │ -0005f3a0: 6574 7572 6e20 7265 743b 0a09 7d0a 0a7d eturn ret;..}..} │ │ │ -0005f3b0: 0a0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ..
    < │ │ │ -0005f3e0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0005f3f0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0005f420: 7372 632f 6970 5f6e 6f74 6966 6965 722e src/ip_notifier. │ │ │ -0005f430: 6370 703a 3431 3c2f 613e 3c2f 7464 3e3c cpp:41< │ │ │ -0005f440: 7464 3e73 696d 756c 6174 6f72 2073 7570 td>simulator sup │ │ │ -0005f450: 706f 7274 3c2f 7464 3e3c 2f74 723e 3c74 portsimulator supp │ │ │ -0005f4b0: 6f72 743c 2f68 323e 3c68 343e 2e2e 2f73 ort

    ../s │ │ │ -0005f4c0: 7263 2f69 705f 6e6f 7469 6669 6572 2e63 rc/ip_notifier.c │ │ │ -0005f4d0: 7070 3a34 313c 2f68 343e 3c70 7265 2073 pp:41

          from t
    │ │ │ -0005f520: 6869 7320 736f 6674 7761 7265 2077 6974  his software wit
    │ │ │ -0005f530: 686f 7574 2073 7065 6369 6669 6320 7072  hout specific pr
    │ │ │ -0005f540: 696f 7220 7772 6974 7465 6e20 7065 726d  ior written perm
    │ │ │ -0005f550: 6973 7369 6f6e 2e0a 0a54 4849 5320 534f  ission...THIS SO
    │ │ │ -0005f560: 4654 5741 5245 2049 5320 5052 4f56 4944  FTWARE IS PROVID
    │ │ │ -0005f570: 4544 2042 5920 5448 4520 434f 5059 5249  ED BY THE COPYRI
    │ │ │ -0005f580: 4748 5420 484f 4c44 4552 5320 414e 4420  GHT HOLDERS AND 
    │ │ │ -0005f590: 434f 4e54 5249 4255 544f 5253 2022 4153  CONTRIBUTORS "AS
    │ │ │ -0005f5a0: 2049 5322 0a41 4e44 2041 4e59 2045 5850   IS".AND ANY EXP
    │ │ │ -0005f5b0: 5245 5353 204f 5220 494d 504c 4945 4420  RESS OR IMPLIED 
    │ │ │ -0005f5c0: 5741 5252 414e 5449 4553 2c20 494e 434c  WARRANTIES, INCL
    │ │ │ -0005f5d0: 5544 494e 472c 2042 5554 204e 4f54 204c  UDING, BUT NOT L
    │ │ │ -0005f5e0: 494d 4954 4544 2054 4f2c 2054 4845 0a49  IMITED TO, THE.I
    │ │ │ -0005f5f0: 4d50 4c49 4544 2057 4152 5241 4e54 4945  MPLIED WARRANTIE
    │ │ │ -0005f600: 5320 4f46 204d 4552 4348 414e 5441 4249  S OF MERCHANTABI
    │ │ │ -0005f610: 4c49 5459 2041 4e44 2046 4954 4e45 5353  LITY AND FITNESS
    │ │ │ -0005f620: 2046 4f52 2041 2050 4152 5449 4355 4c41   FOR A PARTICULA
    │ │ │ -0005f630: 5220 5055 5250 4f53 450a 4152 4520 4449  R PURPOSE.ARE DI
    │ │ │ -0005f640: 5343 4c41 494d 4544 2e20 494e 204e 4f20  SCLAIMED. IN NO 
    │ │ │ -0005f650: 4556 454e 5420 5348 414c 4c20 5448 4520  EVENT SHALL THE 
    │ │ │ -0005f660: 434f 5059 5249 4748 5420 4f57 4e45 5220  COPYRIGHT OWNER 
    │ │ │ -0005f670: 4f52 2043 4f4e 5452 4942 5554 4f52 5320  OR CONTRIBUTORS 
    │ │ │ -0005f680: 4245 0a4c 4941 424c 4520 464f 5220 414e  BE.LIABLE FOR AN
    │ │ │ -0005f690: 5920 4449 5245 4354 2c20 494e 4449 5245  Y DIRECT, INDIRE
    │ │ │ -0005f6a0: 4354 2c20 494e 4349 4445 4e54 414c 2c20  CT, INCIDENTAL, 
    │ │ │ -0005f6b0: 5350 4543 4941 4c2c 2045 5845 4d50 4c41  SPECIAL, EXEMPLA
    │ │ │ -0005f6c0: 5259 2c20 4f52 0a43 4f4e 5345 5155 454e  RY, OR.CONSEQUEN
    │ │ │ -0005f6d0: 5449 414c 2044 414d 4147 4553 2028 494e  TIAL DAMAGES (IN
    │ │ │ -0005f6e0: 434c 5544 494e 472c 2042 5554 204e 4f54  CLUDING, BUT NOT
    │ │ │ -0005f6f0: 204c 494d 4954 4544 2054 4f2c 2050 524f   LIMITED TO, PRO
    │ │ │ -0005f700: 4355 5245 4d45 4e54 204f 460a 5355 4253  CUREMENT OF.SUBS
    │ │ │ -0005f710: 5449 5455 5445 2047 4f4f 4453 204f 5220  TITUTE GOODS OR 
    │ │ │ -0005f720: 5345 5256 4943 4553 3b20 4c4f 5353 204f  SERVICES; LOSS O
    │ │ │ -0005f730: 4620 5553 452c 2044 4154 412c 204f 5220  F USE, DATA, OR 
    │ │ │ -0005f740: 5052 4f46 4954 533b 204f 5220 4255 5349  PROFITS; OR BUSI
    │ │ │ -0005f750: 4e45 5353 0a49 4e54 4552 5255 5054 494f  NESS.INTERRUPTIO
    │ │ │ -0005f760: 4e29 2048 4f57 4556 4552 2043 4155 5345  N) HOWEVER CAUSE
    │ │ │ -0005f770: 4420 414e 4420 4f4e 2041 4e59 2054 4845  D AND ON ANY THE
    │ │ │ -0005f780: 4f52 5920 4f46 204c 4941 4249 4c49 5459  ORY OF LIABILITY
    │ │ │ -0005f790: 2c20 5748 4554 4845 5220 494e 0a43 4f4e  , WHETHER IN.CON
    │ │ │ -0005f7a0: 5452 4143 542c 2053 5452 4943 5420 4c49  TRACT, STRICT LI
    │ │ │ -0005f7b0: 4142 494c 4954 592c 204f 5220 544f 5254  ABILITY, OR TORT
    │ │ │ -0005f7c0: 2028 494e 434c 5544 494e 4720 4e45 474c   (INCLUDING NEGL
    │ │ │ -0005f7d0: 4947 454e 4345 204f 5220 4f54 4845 5257  IGENCE OR OTHERW
    │ │ │ -0005f7e0: 4953 4529 0a41 5249 5349 4e47 2049 4e20  ISE).ARISING IN 
    │ │ │ -0005f7f0: 414e 5920 5741 5920 4f55 5420 4f46 2054  ANY WAY OUT OF T
    │ │ │ -0005f800: 4845 2055 5345 204f 4620 5448 4953 2053  HE USE OF THIS S
    │ │ │ -0005f810: 4f46 5457 4152 452c 2045 5645 4e20 4946  OFTWARE, EVEN IF
    │ │ │ -0005f820: 2041 4456 4953 4544 204f 4620 5448 450a   ADVISED OF THE.
    │ │ │ -0005f830: 504f 5353 4942 494c 4954 5920 4f46 2053  POSSIBILITY OF S
    │ │ │ -0005f840: 5543 4820 4441 4d41 4745 2e0a 0a2a 2f0a  UCH DAMAGE...*/.
    │ │ │ -0005f850: 0a23 696e 636c 7564 6520 226c 6962 746f  .#include "libto
    │ │ │ -0005f860: 7272 656e 742f 6175 785f 2f69 705f 6e6f  rrent/aux_/ip_no
    │ │ │ -0005f870: 7469 6669 6572 2e68 7070 220a 2369 6e63  tifier.hpp".#inc
    │ │ │ -0005f880: 6c75 6465 2022 6c69 6274 6f72 7265 6e74  lude "libtorrent
    │ │ │ -0005f890: 2f61 7373 6572 742e 6870 7022 0a0a 2369  /assert.hpp"..#i
    │ │ │ -0005f8a0: 6620 6465 6669 6e65 6420 544f 5252 454e  f defined TORREN
    │ │ │ -0005f8b0: 545f 4255 494c 445f 5349 4d55 4c41 544f  T_BUILD_SIMULATO
    │ │ │ -0005f8c0: 520a 3c64 6976 2073 7479 6c65 3d22 6261  R.
    │ │ │ -0005f8f0: 2365 6c69 6620 544f 5252 454e 545f 5553 #elif TORRENT_US │ │ │ -0005f900: 455f 4e45 544c 494e 4b0a 3c2f 6469 763e E_NETLINK.
    │ │ │ -0005f910: 2369 6e63 6c75 6465 2022 6c69 6274 6f72 #include "libtor │ │ │ -0005f920: 7265 6e74 2f6e 6574 6c69 6e6b 2e68 7070 rent/netlink.hpp │ │ │ -0005f930: 220a 2369 6e63 6c75 6465 2022 6c69 6274 ".#include "libt │ │ │ -0005f940: 6f72 7265 6e74 2f73 6f63 6b65 742e 6870 orrent/socket.hp │ │ │ -0005f950: 7022 0a23 696e 636c 7564 6520 266c 743b p".#include < │ │ │ -0005f960: 6172 7261 7926 6774 3b0a 2369 6e63 6c75 array>.#inclu │ │ │ -0005f970: 6465 2026 6c74 3b75 6e6f 7264 6572 6564 de <unordered │ │ │ -0005f980: 5f6d 6170 2667 743b 0a23 656c 6966 2054 _map>.#elif T │ │ │ -0005f990: 4f52 5245 4e54 5f55 5345 5f53 5953 5445 ORRENT_USE_SYSTE │ │ │ -0005f9a0: 4d43 4f4e 4649 4755 5241 5449 4f4e 207c MCONFIGURATION | │ │ │ -0005f9b0: 7c20 544f 5252 454e 545f 5553 455f 5343 | TORRENT_USE_SC │ │ │ -0005f9c0: 5f4e 4554 574f 524b 5f52 4541 4348 4142 _NETWORK_REACHAB │ │ │ -0005f9d0: 494c 4954 590a 2369 6e63 6c75 6465 2026 ILITY.#include & │ │ │ -0005f9e0: 6c74 3b53 7973 7465 6d43 6f6e 6669 6775 lt;SystemConfigu │ │ │ -0005f9f0: 7261 7469 6f6e 2f53 7973 7465 6d43 6f6e ration/SystemCon │ │ │ -0005fa00: 6669 6775 7261 7469 6f6e 2e68 2667 743b figuration.h> │ │ │ -0005fa10: 0a23 656c 6966 2064 6566 696e 6564 2054 .#elif defined T │ │ │ -0005fa20: 4f52 5245 4e54 5f57 494e 444f 5753 0a23 ORRENT_WINDOWS.# │ │ │ -0005fa30: 696e 636c 7564 6520 226c 6962 746f 7272 include "libtorr │ │ │ -0005fa40: 656e 742f 6175 785f 2f74 6872 6f77 2e68 ent/aux_/throw.h │ │ │ -0005fa50: 7070 220a 2369 6e63 6c75 6465 2022 6c69 pp".#include "li │ │ │ -0005fa60: 6274 6f72 7265 6e74 2f61 7578 5f2f 6469 btorrent/aux_/di │ │ │ -0005fa70: 7361 626c 655f 7761 726e 696e 6773 5f70 sable_warnings_p │ │ │ -0005fa80: 7573 682e 6870 7022 0a23 696e 636c 7564 ush.hpp".#includ │ │ │ -0005fa90: 6520 266c 743b 6970 686c 7061 7069 2e68 e <iphlpapi.h │ │ │ -0005faa0: 2667 743b 0a23 6966 6465 6620 544f 5252 >.#ifdef TORR │ │ │ -0005fab0: 454e 545f 5749 4e52 540a 2369 6e63 6c75 ENT_WINRT.#inclu │ │ │ -0005fac0: 6465 2026 6c74 3b6e 6574 696f 6170 692e de <netioapi. │ │ │ -0005fad0: 6826 6774 3b0a 2365 6e64 6966 0a23 696e h>.#endif.#in │ │ │ -0005fae0: 636c 7564 6520 266c 743b 6d75 7465 7826 clude <mutex& │ │ │ -0005faf0: 6774 3b0a 2369 6e63 6c75 6465 2022 6c69 gt;.#include "li │ │ │ -0005fb00: 6274 6f72 7265 6e74 2f61 7578 5f2f 6469 btorrent/aux_/di │ │ │ -0005fb10: 7361 626c 655f 7761 726e 696e 6773 5f70 sable_warnings_p │ │ │ -0005fb20: 6f70 2e68 7070 220a 2365 6e64 6966 0a0a op.hpp".#endif.. │ │ │ -0005fb30: 2369 6e63 6c75 6465 2022 6c69 6274 6f72 #include "libtor │ │ │ -0005fb40: 7265 6e74 2f61 7578 5f2f 6e65 746c 696e rent/aux_/netlin │ │ │ -0005fb50: 6b5f 7574 696c 732e 6870 7022 0a0a 6e61 k_utils.hpp"..na │ │ │ -0005fb60: 6d65 7370 6163 6520 6c69 6274 6f72 7265 mespace libtorre │ │ │ -0005fb70: 6e74 207b 206e 616d 6573 7061 6365 2061 nt { namespace a │ │ │ -0005fb80: 7578 207b 0a0a 6e61 6d65 7370 6163 6520 ux {..namespace │ │ │ -0005fb90: 7b0a 0a23 6966 2028 544f 5252 454e 545f {..#if (TORRENT_ │ │ │ -0005fba0: 5553 455f 5359 5354 454d 434f 4e46 4947 USE_SYSTEMCONFIG │ │ │ -0005fbb0: 5552 4154 494f 4e20 7c7c 2054 4f52 5245 URATION || TORRE │ │ │ -0005fbc0: 4e54 5f55 5345 5f53 435f 4e45 5457 4f52 NT_USE_SC_NETWOR │ │ │ -0005fbd0: 4b5f 5245 4143 4841 4249 4c49 5459 2920 K_REACHABILITY) │ │ │ -0005fbe0: 2661 6d70 3b26 616d 703b 205c 0a09 2164 && \..!d │ │ │ -0005fbf0: 6566 696e 6564 2054 4f52 5245 4e54 5f42 efined TORRENT_B │ │ │ -0005fc00: 5549 4c44 5f53 494d 554c 4154 4f52 0a0a UILD_SIMULATOR.. │ │ │ -0005fc10: 2f2f 2063 6f6d 6d6f 6e20 7574 696c 6974 // common utilit │ │ │ -0005fc20: 6965 7320 666f 7220 4d61 6320 616e 6420 ies for Mac and │ │ │ -0005fc30: 694f 530a 7465 6d70 6c61 7465 2026 6c74 iOS.template < │ │ │ -0005fc40: 3b74 7970 656e 616d 6520 5426 6774 3b20 ;typename T> │ │ │ -0005fc50: 766f 6964 2043 4652 6566 5265 7461 696e void CFRefRetain │ │ │ -0005fc60: 2854 2068 2920 7b20 4346 5265 7461 696e (T h) { CFRetain │ │ │ -0005fc70: 2868 293b 207d 0a74 656d 706c 6174 6520 (h); }.template │ │ │ -0005fc80: 266c 743b 7479 7065 6e61 6d65 2054 2667 <typename T&g │ │ │ -0005fc90: 743b 2076 6f69 6420 4346 5265 6652 656c t; void CFRefRel │ │ │ -0005fca0: 6561 7365 2854 2068 2920 7b20 4346 5265 ease(T h) { CFRe │ │ │ -0005fcb0: 6c65 6173 6528 6829 3b20 7d0a 0a3c 2f70 lease(h); }..

    re │ │ │ -0005fcf0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/h │ │ │ -0005fd30: 7474 705f 7365 6564 5f63 6f6e 6e65 6374 ttp_seed_connect │ │ │ -0005fd40: 696f 6e2e 6370 703a 3433 373c 2f61 3e3c ion.cpp:437< │ │ │ -0005fd50: 2f74 643e 3c74 643e 7465 6368 6e69 6361 /td>technica │ │ │ -0005fd60: 6c6c 792c 2074 6869 7320 6973 6e27 7420 lly, this isn't │ │ │ -0005fd70: 7375 7070 6f73 6564 2074 6f20 6861 7070 supposed to happ │ │ │ -0005fd80: 656e 2c20 6275 7420 6974 2073 6565 6d73 en, but it seems │ │ │ -0005fd90: 2074 6f20 736f 6d65 7469 6d65 732e 2053 to sometimes. S │ │ │ -0005fda0: 6f6d 6520 6f66 2074 6865 2061 6363 6f75 ome of the accou │ │ │ -0005fdb0: 6e74 696e 6720 6973 2070 726f 6261 626c nting is probabl │ │ │ -0005fdc0: 7920 7772 6f6e 6720 696e 2063 6572 7461 y wrong in certa │ │ │ -0005fdd0: 696e 2063 6173 6573 3c2f 7464 3e3c 2f74 in cases

    technicall │ │ │ -0005fe30: 792c 2074 6869 7320 6973 6e27 7420 7375 y, this isn't su │ │ │ -0005fe40: 7070 6f73 6564 2074 6f20 6861 7070 656e pposed to happen │ │ │ -0005fe50: 2c20 6275 7420 6974 2073 6565 6d73 2074 , but it seems t │ │ │ -0005fe60: 6f0a 736f 6d65 7469 6d65 732e 2053 6f6d o.sometimes. Som │ │ │ -0005fe70: 6520 6f66 2074 6865 2061 6363 6f75 6e74 e of the account │ │ │ -0005fe80: 696e 6720 6973 2070 726f 6261 626c 7920 ing is probably │ │ │ -0005fe90: 7772 6f6e 6720 696e 2063 6572 7461 696e wrong in certain │ │ │ -0005fea0: 0a63 6173 6573 3c2f 6832 3e3c 6834 3e2e .cases

    . │ │ │ -0005feb0: 2e2f 7372 632f 6874 7470 5f73 6565 645f ./src/http_seed_ │ │ │ -0005fec0: 636f 6e6e 6563 7469 6f6e 2e63 7070 3a34 connection.cpp:4 │ │ │ -0005fed0: 3337 3c2f 6834 3e3c 7072 6520 7374 796c 37

    .....// cut out
    │ │ │ -0005ff20: 2074 6865 2063 6875 6e6b 2068 6561 6465   the chunk heade
    │ │ │ -0005ff30: 7220 6672 6f6d 2074 6865 2072 6563 6569  r from the recei
    │ │ │ -0005ff40: 7665 2062 7566 6665 720a 0909 0909 0954  ve buffer......T
    │ │ │ -0005ff50: 4f52 5245 4e54 5f41 5353 4552 5428 6d5f  ORRENT_ASSERT(m_
    │ │ │ -0005ff60: 6368 756e 6b5f 706f 7320 2b20 6d5f 626f  chunk_pos + m_bo
    │ │ │ -0005ff70: 6479 5f73 7461 7274 2026 6c74 3b20 494e  dy_start < IN
    │ │ │ -0005ff80: 545f 4d41 5829 3b0a 0909 0909 096d 5f72  T_MAX);......m_r
    │ │ │ -0005ff90: 6563 765f 6275 6666 6572 2e63 7574 2868  ecv_buffer.cut(h
    │ │ │ -0005ffa0: 6561 6465 725f 7369 7a65 2c20 742d 2667  eader_size, t-&g
    │ │ │ -0005ffb0: 743b 626c 6f63 6b5f 7369 7a65 2829 202b  t;block_size() +
    │ │ │ -0005ffc0: 2031 3032 342c 2061 7578 3a3a 6e75 6d65   1024, aux::nume
    │ │ │ -0005ffd0: 7269 635f 6361 7374 266c 743b 696e 7426  ric_cast<int&
    │ │ │ -0005ffe0: 6774 3b28 6d5f 6368 756e 6b5f 706f 7320  gt;(m_chunk_pos 
    │ │ │ -0005fff0: 2b20 6d5f 626f 6479 5f73 7461 7274 2929  + m_body_start))
    │ │ │ -00060000: 3b0a 0909 0909 0972 6563 765f 6275 6666  ;......recv_buff
    │ │ │ -00060010: 6572 203d 206d 5f72 6563 765f 6275 6666  er = m_recv_buff
    │ │ │ -00060020: 6572 2e67 6574 2829 3b0a 0909 0909 0972  er.get();......r
    │ │ │ -00060030: 6563 765f 6275 6666 6572 203d 2072 6563  ecv_buffer = rec
    │ │ │ -00060040: 765f 6275 6666 6572 2e73 7562 7370 616e  v_buffer.subspan
    │ │ │ -00060050: 286d 5f62 6f64 795f 7374 6172 7429 3b0a  (m_body_start);.
    │ │ │ -00060060: 0909 0909 096d 5f63 6875 6e6b 5f70 6f73  .....m_chunk_pos
    │ │ │ -00060070: 202b 3d20 6368 756e 6b5f 7369 7a65 3b0a   += chunk_size;.
    │ │ │ -00060080: 0909 0909 0969 6620 2863 6875 6e6b 5f73  .....if (chunk_s
    │ │ │ -00060090: 697a 6520 3d3d 2030 290a 0909 0909 097b  ize == 0)......{
    │ │ │ -000600a0: 0a09 0909 0909 0954 4f52 5245 4e54 5f41  .......TORRENT_A
    │ │ │ -000600b0: 5353 4552 5428 6d5f 7265 6376 5f62 7566  SSERT(m_recv_buf
    │ │ │ -000600c0: 6665 722e 6765 7428 292e 7369 7a65 2829  fer.get().size()
    │ │ │ -000600d0: 2026 6c74 3b20 6d5f 6368 756e 6b5f 706f   < m_chunk_po
    │ │ │ -000600e0: 7320 2b20 6d5f 626f 6479 5f73 7461 7274  s + m_body_start
    │ │ │ -000600f0: 202b 2031 0a09 0909 0909 0909 7c7c 206d   + 1........|| m
    │ │ │ -00060100: 5f72 6563 765f 6275 6666 6572 2e67 6574  _recv_buffer.get
    │ │ │ -00060110: 2829 5b73 7461 7469 635f 6361 7374 266c  ()[static_cast&l
    │ │ │ -00060120: 743b 7374 643a 3a70 7472 6469 6666 5f74  t;std::ptrdiff_t
    │ │ │ -00060130: 2667 743b 286d 5f63 6875 6e6b 5f70 6f73  >(m_chunk_pos
    │ │ │ -00060140: 202b 206d 5f62 6f64 795f 7374 6172 7429   + m_body_start)
    │ │ │ -00060150: 5d20 3d3d 2027 4827 0a09 0909 0909 0909  ] == 'H'........
    │ │ │ -00060160: 7c7c 2028 6d5f 7061 7273 6572 2e63 6875  || (m_parser.chu
    │ │ │ -00060170: 6e6b 6564 5f65 6e63 6f64 696e 6728 290a  nked_encoding().
    │ │ │ -00060180: 0909 0909 0909 0909 2661 6d70 3b26 616d  ........&&am
    │ │ │ -00060190: 703b 206d 5f72 6563 765f 6275 6666 6572  p; m_recv_buffer
    │ │ │ -000601a0: 2e67 6574 2829 5b73 7461 7469 635f 6361  .get()[static_ca
    │ │ │ -000601b0: 7374 266c 743b 7374 643a 3a70 7472 6469  st<std::ptrdi
    │ │ │ -000601c0: 6666 5f74 2667 743b 286d 5f63 6875 6e6b  ff_t>(m_chunk
    │ │ │ -000601d0: 5f70 6f73 202b 206d 5f62 6f64 795f 7374  _pos + m_body_st
    │ │ │ -000601e0: 6172 7429 5d20 3d3d 2027 5c72 2729 293b  art)] == '\r'));
    │ │ │ -000601f0: 0a09 0909 0909 096d 5f63 6875 6e6b 5f70  .......m_chunk_p
    │ │ │ -00060200: 6f73 203d 202d 313b 0a09 0909 0909 7d0a  os = -1;......}.
    │ │ │ -00060210: 0909 0909 7d0a 0909 097d 0a0a 0909 0969  ....}....}.....i
    │ │ │ -00060220: 6e74 2070 6179 6c6f 6164 203d 2069 6e74  nt payload = int
    │ │ │ -00060230: 2862 7974 6573 5f74 7261 6e73 6665 7272  (bytes_transferr
    │ │ │ -00060240: 6564 293b 0a09 0909 6966 2028 7061 796c  ed);....if (payl
    │ │ │ -00060250: 6f61 6420 2667 743b 206d 5f72 6573 706f  oad > m_respo
    │ │ │ -00060260: 6e73 655f 6c65 6674 2920 7061 796c 6f61  nse_left) payloa
    │ │ │ -00060270: 6420 3d20 696e 7428 6d5f 7265 7370 6f6e  d = int(m_respon
    │ │ │ -00060280: 7365 5f6c 6566 7429 3b0a 0909 0969 6620  se_left);....if 
    │ │ │ -00060290: 2870 6179 6c6f 6164 2026 6774 3b20 6672  (payload > fr
    │ │ │ -000602a0: 6f6e 745f 7265 7175 6573 742e 6c65 6e67  ont_request.leng
    │ │ │ -000602b0: 7468 2920 7061 796c 6f61 6420 3d20 6672  th) payload = fr
    │ │ │ -000602c0: 6f6e 745f 7265 7175 6573 742e 6c65 6e67  ont_request.leng
    │ │ │ -000602d0: 7468 3b0a 3c64 6976 2073 7479 6c65 3d22  th;.
    ...if (payload │ │ │ -00060310: 2026 6774 3b20 6f75 7473 7461 6e64 696e > outstandin │ │ │ -00060320: 675f 6279 7465 7328 2929 2070 6179 6c6f g_bytes()) paylo │ │ │ -00060330: 6164 203d 206f 7574 7374 616e 6469 6e67 ad = outstanding │ │ │ -00060340: 5f62 7974 6573 2829 3b0a 3c2f 6469 763e _bytes();.
    │ │ │ -00060350: 0909 0972 6563 6569 7665 645f 6279 7465 ...received_byte │ │ │ -00060360: 7328 7061 796c 6f61 642c 2030 293b 0a09 s(payload, 0);.. │ │ │ -00060370: 0909 696e 636f 6d69 6e67 5f70 6965 6365 ..incoming_piece │ │ │ -00060380: 5f66 7261 676d 656e 7428 7061 796c 6f61 _fragment(payloa │ │ │ -00060390: 6429 3b0a 0909 096d 5f72 6573 706f 6e73 d);....m_respons │ │ │ -000603a0: 655f 6c65 6674 202d 3d20 7061 796c 6f61 e_left -= payloa │ │ │ -000603b0: 643b 0a0a 0909 0969 6620 286d 5f70 6172 d;.....if (m_par │ │ │ -000603c0: 7365 722e 7374 6174 7573 5f63 6f64 6528 ser.status_code( │ │ │ -000603d0: 2920 3d3d 2035 3033 290a 0909 097b 0a09 ) == 503)....{.. │ │ │ -000603e0: 0909 0969 6620 2821 6d5f 7061 7273 6572 ...if (!m_parser │ │ │ -000603f0: 2e66 696e 6973 6865 6428 2929 2072 6574 .finished()) ret │ │ │ -00060400: 7572 6e3b 0a0a 0909 0909 696e 7420 7265 urn;......int re │ │ │ -00060410: 7472 795f 7469 6d65 203d 2073 7464 3a3a try_time = std:: │ │ │ -00060420: 6174 6f69 2873 7464 3a3a 7374 7269 6e67 atoi(std::string │ │ │ -00060430: 2872 6563 765f 6275 6666 6572 2e62 6567 (recv_buffer.beg │ │ │ -00060440: 696e 2829 2c20 7265 6376 5f62 7566 6665 in(), recv_buffe │ │ │ -00060450: 722e 656e 6428 2929 2e63 5f73 7472 2829 r.end()).c_str() │ │ │ -00060460: 293b 0a09 0909 0969 6620 2872 6574 7279 );.....if (retry │ │ │ -00060470: 5f74 696d 6520 266c 743b 3d20 3029 2072 _time <= 0) r │ │ │ -00060480: 6574 7279 5f74 696d 6520 3d20 3630 3b0a etry_time = 60;. │ │ │ -00060490: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ -000604a0: 4449 5341 424c 455f 4c4f 4747 494e 470a DISABLE_LOGGING. │ │ │ -000604b0: 0909 0909 7065 6572 5f6c 6f67 2870 6565 ....peer_log(pee │ │ │ -000604c0: 725f 6c6f 675f 616c 6572 743a 3a69 6e66 r_log_alert::inf │ │ │ -000604d0: 6f2c 2022 434f 4e4e 4543 5422 2c20 2272 o, "CONNECT", "r │ │ │ -000604e0: 6574 7279 696e 6720 696e 2025 6420 7365 etrying in %d se │ │ │ -000604f0: 636f 6e64 7322 2c20 7265 7472 795f 7469 conds", retry_ti │ │ │ -00060500: 6d65 293b 0a23 656e 6469 660a 0a09 0909 me);.#endif..... │ │ │ -00060510: 0972 6563 6569 7665 645f 6279 7465 7328 .received_bytes( │ │ │ -00060520: 302c 2069 6e74 2862 7974 6573 5f74 7261 0, int(bytes_tra │ │ │ -00060530: 6e73 6665 7272 6564 2929 3b0a 0909 0909 nsferred));..... │ │ │ -00060540: 2f2f 2074 656d 706f 7261 7269 6c79 2075 // temporarily u │ │ │ -00060550: 6e61 7661 696c 6162 6c65 2c20 7265 7472 navailable, retr │ │ │ -00060560: 7920 6c61 7465 720a 0909 0909 742d 2667 y later.....t-&g │ │ │ -00060570: 743b 7265 7472 795f 7765 625f 7365 6564 t;retry_web_seed │ │ │ -00060580: 2874 6869 732c 2073 6563 6f6e 6473 3332 (this, seconds32 │ │ │ -00060590: 2872 6574 7279 5f74 696d 6529 293b 0a09 (retry_time));.. │ │ │ -000605a0: 0909 0964 6973 636f 6e6e 6563 7428 6572 ...disconnect(er │ │ │ -000605b0: 726f 725f 636f 6465 286d 5f70 6172 7365 ror_code(m_parse │ │ │ -000605c0: 722e 7374 6174 7573 5f63 6f64 6528 292c r.status_code(), │ │ │ -000605d0: 2068 7474 705f 6361 7465 676f 7279 2829 http_category() │ │ │ -000605e0: 292c 206f 7065 7261 7469 6f6e 5f74 3a3a ), operation_t:: │ │ │ -000605f0: 6269 7474 6f72 7265 6e74 2c20 6661 696c bittorrent, fail │ │ │ -00060600: 7572 6529 3b0a 0909 0909 7265 7475 726e ure);.....return │ │ │ -00060610: 3b0a 0909 097d 0a0a 0a09 0909 2f2f 2077 ;....}......// w │ │ │ -00060620: 6520 6f6e 6c79 2072 6563 6569 7665 6420 e only received │ │ │ -00060630: 7468 6520 6865 6164 6572 2c20 6e6f 2064 the header, no d │ │ │ -00060640: 6174 610a 0909 0969 6620 2872 6563 765f ata....if (recv_ │ │ │ -00060650: 6275 6666 6572 2e65 6d70 7479 2829 2920 buffer.empty()) │ │ │ -00060660: 6272 6561 6b3b 0a0a 0909 0969 6620 2872 break;.....if (r │ │ │ -00060670: 6563 765f 6275 6666 6572 2e73 697a 6528 ecv_buffer.size( │ │ │ -00060680: 2920 266c 743b 2066 726f 6e74 5f72 6571 ) < front_req │ │ │ -00060690: 7565 7374 2e6c 656e 6774 6829 2062 7265 uest.length) bre │ │ │ -000606a0: 616b 3b0a 0a09 0909 2f2f 2069 6620 7468 ak;.....// if th │ │ │ -000606b0: 6520 7265 7370 6f6e 7365 2069 7320 6368 e response is ch │ │ │ -000606c0: 756e 6b65 642c 2077 6520 6e65 6564 2074 unked, we need t │ │ │ -000606d0: 6f20 7265 6365 6976 6520 7468 6520 6c61 o receive the la │ │ │ -000606e0: 7374 0a09 0909 2f2f 2074 6572 6d69 6e61 st....// termina │ │ │ -000606f0: 7469 6e67 2063 6875 6e6b 2061 6e64 2074 ting chunk and t │ │ │ -00060700: 6865 2074 6169 6c20 6865 6164 6572 7320 he tail headers │ │ │ -00060710: 6265 666f 7265 2077 6520 6361 6e20 7072 before we can pr │ │ │ -00060720: 6f63 6565 640a 0909 0969 6620 286d 5f70 oceed....if (m_p │ │ │ -00060730: 6172 7365 722e 6368 756e 6b65 645f 656e arser.chunked_en │ │ │ -00060740: 636f 6469 6e67 2829 2026 616d 703b 2661 coding() &&a │ │ │ -00060750: 6d70 3b20 6d5f 6368 756e 6b5f 706f 7320 mp; m_chunk_pos │ │ │ -00060760: 2667 743b 3d20 3029 2062 7265 616b 3b0a >= 0) break;. │ │ │ -00060770: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00060780: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -000607b0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -000607e0: 632f 6861 7368 5f70 6963 6b65 722e 6370 c/hash_picker.cp │ │ │ -000607f0: 703a 3333 353c 2f61 3e3c 2f74 643e 3c74 p:335use structured │ │ │ -00060810: 2062 696e 6469 6e67 7320 696e 2043 2b2b bindings in C++ │ │ │ -00060820: 3137 3c2f 7464 3e3c 2f74 723e 3c74 7220 17

    │ │ │ -00060870: 7573 6520 7374 7275 6374 7572 6564 2062 use structured b │ │ │ -00060880: 696e 6469 6e67 7320 696e 2043 2b2b 3137 indings in C++17 │ │ │ -00060890: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -000608a0: 6861 7368 5f70 6963 6b65 722e 6370 703a hash_picker.cpp: │ │ │ -000608b0: 3333 353c 2f68 343e 3c70 7265 2073 7479 335

    .., int const 
    │ │ │ -00060900: 6f66 6673 6574 2c20 7368 6132 3536 5f68  offset, sha256_h
    │ │ │ -00060910: 6173 6820 636f 6e73 7426 616d 703b 2068  ash const& h
    │ │ │ -00060920: 290a 097b 0a09 0954 4f52 5245 4e54 5f41  )..{...TORRENT_A
    │ │ │ -00060930: 5353 4552 5428 6f66 6673 6574 2026 6774  SSERT(offset >
    │ │ │ -00060940: 3b3d 2030 293b 0a09 0961 7574 6f20 636f  ;= 0);...auto co
    │ │ │ -00060950: 6e73 7420 6620 3d20 6d5f 6669 6c65 732e  nst f = m_files.
    │ │ │ -00060960: 6669 6c65 5f69 6e64 6578 5f61 745f 7069  file_index_at_pi
    │ │ │ -00060970: 6563 6528 7069 6563 6529 3b0a 0a09 0969  ece(piece);....i
    │ │ │ -00060980: 6620 286d 5f66 696c 6573 2e70 6164 5f66  f (m_files.pad_f
    │ │ │ -00060990: 696c 655f 6174 2866 2929 0a09 0909 7265  ile_at(f))....re
    │ │ │ -000609a0: 7475 726e 207b 2073 6574 5f62 6c6f 636b  turn { set_block
    │ │ │ -000609b0: 5f68 6173 685f 7265 7375 6c74 3a3a 7265  _hash_result::re
    │ │ │ -000609c0: 7375 6c74 3a3a 7375 6363 6573 732c 2030  sult::success, 0
    │ │ │ -000609d0: 2c20 3020 7d3b 0a0a 0909 6175 746f 2661  , 0 };....auto&a
    │ │ │ -000609e0: 6d70 3b20 6d65 726b 6c65 5f74 7265 6520  mp; merkle_tree 
    │ │ │ -000609f0: 3d20 6d5f 6d65 726b 6c65 5f74 7265 6573  = m_merkle_trees
    │ │ │ -00060a00: 5b66 5d3b 0a09 0970 6965 6365 5f69 6e64  [f];...piece_ind
    │ │ │ -00060a10: 6578 5f74 2063 6f6e 7374 2066 696c 655f  ex_t const file_
    │ │ │ -00060a20: 6669 7273 745f 7069 6563 6520 3d20 6d5f  first_piece = m_
    │ │ │ -00060a30: 6669 6c65 732e 7069 6563 655f 696e 6465  files.piece_inde
    │ │ │ -00060a40: 785f 6174 5f66 696c 6528 6629 3b0a 0909  x_at_file(f);...
    │ │ │ -00060a50: 7374 643a 3a69 6e74 3634 5f74 2063 6f6e  std::int64_t con
    │ │ │ -00060a60: 7374 2062 6c6f 636b 5f6f 6666 7365 7420  st block_offset 
    │ │ │ -00060a70: 3d20 7374 6174 6963 5f63 6173 7426 6c74  = static_cast<
    │ │ │ -00060a80: 3b69 6e74 2667 743b 2870 6965 6365 2920  ;int>(piece) 
    │ │ │ -00060a90: 2a20 7374 643a 3a69 6e74 3634 5f74 286d  * std::int64_t(m
    │ │ │ -00060aa0: 5f66 696c 6573 2e70 6965 6365 5f6c 656e  _files.piece_len
    │ │ │ -00060ab0: 6774 6828 2929 0a09 0909 2b20 6f66 6673  gth())....+ offs
    │ │ │ -00060ac0: 6574 202d 206d 5f66 696c 6573 2e66 696c  et - m_files.fil
    │ │ │ -00060ad0: 655f 6f66 6673 6574 2866 293b 0a09 0969  e_offset(f);...i
    │ │ │ -00060ae0: 6e74 2063 6f6e 7374 2062 6c6f 636b 5f69  nt const block_i
    │ │ │ -00060af0: 6e64 6578 203d 2061 7578 3a3a 6e75 6d65  ndex = aux::nume
    │ │ │ -00060b00: 7269 635f 6361 7374 266c 743b 696e 7426  ric_cast<int&
    │ │ │ -00060b10: 6774 3b28 626c 6f63 6b5f 6f66 6673 6574  gt;(block_offset
    │ │ │ -00060b20: 202f 2064 6566 6175 6c74 5f62 6c6f 636b   / default_block
    │ │ │ -00060b30: 5f73 697a 6529 3b0a 0a09 0969 6620 2868  _size);....if (h
    │ │ │ -00060b40: 2e69 735f 616c 6c5f 7a65 726f 7328 2929  .is_all_zeros())
    │ │ │ -00060b50: 0a09 097b 0a09 0909 544f 5252 454e 545f  ...{....TORRENT_
    │ │ │ -00060b60: 4153 5345 5254 5f46 4149 4c28 293b 0a09  ASSERT_FAIL();..
    │ │ │ -00060b70: 0909 7265 7475 726e 2073 6574 5f62 6c6f  ..return set_blo
    │ │ │ -00060b80: 636b 5f68 6173 685f 7265 7375 6c74 3a3a  ck_hash_result::
    │ │ │ -00060b90: 626c 6f63 6b5f 6861 7368 5f66 6169 6c65  block_hash_faile
    │ │ │ -00060ba0: 6428 293b 0a09 097d 0a0a 3c64 6976 2073  d();...}..
    ..aux::m │ │ │ -00060be0: 6572 6b6c 655f 7472 6565 3a3a 7365 745f erkle_tree::set_ │ │ │ -00060bf0: 626c 6f63 6b5f 7265 7375 6c74 2072 6573 block_result res │ │ │ -00060c00: 756c 743b 0a3c 2f64 6976 3e09 0969 6e74 ult;.
    ..int │ │ │ -00060c10: 206c 6561 6673 5f69 6e64 6578 3b0a 0909 leafs_index;... │ │ │ -00060c20: 696e 7420 6c65 6166 735f 7369 7a65 3b0a int leafs_size;. │ │ │ -00060c30: 0909 7374 643a 3a74 6965 2872 6573 756c ..std::tie(resul │ │ │ -00060c40: 742c 206c 6561 6673 5f69 6e64 6578 2c20 t, leafs_index, │ │ │ -00060c50: 6c65 6166 735f 7369 7a65 2920 3d20 6d65 leafs_size) = me │ │ │ -00060c60: 726b 6c65 5f74 7265 652e 7365 745f 626c rkle_tree.set_bl │ │ │ -00060c70: 6f63 6b28 626c 6f63 6b5f 696e 6465 782c ock(block_index, │ │ │ -00060c80: 2068 293b 0a0a 0909 6966 2028 7265 7375 h);....if (resu │ │ │ -00060c90: 6c74 203d 3d20 6175 783a 3a6d 6572 6b6c lt == aux::merkl │ │ │ -00060ca0: 655f 7472 6565 3a3a 7365 745f 626c 6f63 e_tree::set_bloc │ │ │ -00060cb0: 6b5f 7265 7375 6c74 3a3a 756e 6b6e 6f77 k_result::unknow │ │ │ -00060cc0: 6e29 0a09 0909 7265 7475 726e 2073 6574 n)....return set │ │ │ -00060cd0: 5f62 6c6f 636b 5f68 6173 685f 7265 7375 _block_hash_resu │ │ │ -00060ce0: 6c74 3a3a 756e 6b6e 6f77 6e28 293b 0a09 lt::unknown();.. │ │ │ -00060cf0: 0969 6620 2872 6573 756c 7420 3d3d 2061 .if (result == a │ │ │ -00060d00: 7578 3a3a 6d65 726b 6c65 5f74 7265 653a ux::merkle_tree: │ │ │ -00060d10: 3a73 6574 5f62 6c6f 636b 5f72 6573 756c :set_block_resul │ │ │ -00060d20: 743a 3a62 6c6f 636b 5f68 6173 685f 6661 t::block_hash_fa │ │ │ -00060d30: 696c 6564 290a 0909 0972 6574 7572 6e20 iled)....return │ │ │ -00060d40: 7365 745f 626c 6f63 6b5f 6861 7368 5f72 set_block_hash_r │ │ │ -00060d50: 6573 756c 743a 3a62 6c6f 636b 5f68 6173 esult::block_has │ │ │ -00060d60: 685f 6661 696c 6564 2829 3b0a 0a09 0961 h_failed();....a │ │ │ -00060d70: 7574 6f20 636f 6e73 7420 7374 6174 7573 uto const status │ │ │ -00060d80: 203d 2028 7265 7375 6c74 203d 3d20 6175 = (result == au │ │ │ -00060d90: 783a 3a6d 6572 6b6c 655f 7472 6565 3a3a x::merkle_tree:: │ │ │ -00060da0: 7365 745f 626c 6f63 6b5f 7265 7375 6c74 set_block_result │ │ │ -00060db0: 3a3a 6861 7368 5f66 6169 6c65 6429 0a09 ::hash_failed).. │ │ │ -00060dc0: 0909 3f20 7365 745f 626c 6f63 6b5f 6861 ..? set_block_ha │ │ │ -00060dd0: 7368 5f72 6573 756c 743a 3a72 6573 756c sh_result::resul │ │ │ -00060de0: 743a 3a70 6965 6365 5f68 6173 685f 6661 t::piece_hash_fa │ │ │ -00060df0: 696c 6564 0a09 0909 3a20 7365 745f 626c iled....: set_bl │ │ │ -00060e00: 6f63 6b5f 6861 7368 5f72 6573 756c 743a ock_hash_result: │ │ │ -00060e10: 3a72 6573 756c 743a 3a73 7563 6365 7373 :result::success │ │ │ -00060e20: 3b0a 0a09 0969 6e74 2063 6f6e 7374 2062 ;....int const b │ │ │ -00060e30: 6c6f 636b 735f 7065 725f 7069 6563 6520 locks_per_piece │ │ │ -00060e40: 3d20 6d5f 6669 6c65 732e 7069 6563 655f = m_files.piece_ │ │ │ -00060e50: 6c65 6e67 7468 2829 202f 2064 6566 6175 length() / defau │ │ │ -00060e60: 6c74 5f62 6c6f 636b 5f73 697a 653b 0a0a lt_block_size;.. │ │ │ -00060e70: 0909 7265 7475 726e 207b 2073 7461 7475 ..return { statu │ │ │ -00060e80: 730a 0909 092c 2069 6e74 286c 6561 6673 s...., int(leafs │ │ │ -00060e90: 5f69 6e64 6578 202d 2073 7461 7469 635f _index - static_ │ │ │ -00060ea0: 6361 7374 266c 743b 696e 7426 6774 3b28 cast<int>( │ │ │ -00060eb0: 7069 6563 6520 2d20 6669 6c65 5f66 6972 piece - file_fir │ │ │ -00060ec0: 7374 5f70 6965 6365 2920 2a20 626c 6f63 st_piece) * bloc │ │ │ -00060ed0: 6b73 5f70 6572 5f70 6965 6365 290a 0909 ks_per_piece)... │ │ │ -00060ee0: 092c 2073 7464 3a3a 6d69 6e28 6c65 6166 ., std::min(leaf │ │ │ -00060ef0: 735f 7369 7a65 2c20 6d5f 6669 6c65 732e s_size, m_files. │ │ │ -00060f00: 6669 6c65 5f6e 756d 5f70 6965 6365 7328 file_num_pieces( │ │ │ -00060f10: 6629 202a 2062 6c6f 636b 735f 7065 725f f) * blocks_per_ │ │ │ -00060f20: 7069 6563 6520 2d20 6c65 6166 735f 696e piece - leafs_in │ │ │ -00060f30: 6465 7829 207d 3b0a 097d 0a0a 0976 6f69 dex) };..}...voi │ │ │ -00060f40: 6420 6861 7368 5f70 6963 6b65 723a 3a68 d hash_picker::h │ │ │ -00060f50: 6173 6865 735f 7265 6a65 6374 6564 2868 ashes_rejected(h │ │ │ -00060f60: 6173 685f 7265 7175 6573 7420 636f 6e73 ash_request cons │ │ │ -00060f70: 7426 616d 703b 2072 6571 290a 097b 0a09 t& req)..{.. │ │ │ -00060f80: 092f 2f20 6f6e 6c79 2072 6571 7565 7374 .// only request │ │ │ -00060f90: 7320 6174 2074 6865 2070 6965 6365 206c s at the piece l │ │ │ -00060fa0: 6179 6572 2061 7265 2072 6563 6f72 6465 ayer are recorde │ │ │ -00060fb0: 6420 696e 0a09 092f 2f20 6d5f 7069 6563 d in...// m_piec │ │ │ -00060fc0: 655f 6861 7368 5f72 6571 7565 7374 6564 e_hash_requested │ │ │ -00060fd0: 2e0a 0909 6966 2028 7265 712e 6261 7365 ....if (req.base │ │ │ -00060fe0: 2021 3d20 6d5f 7069 6563 655f 6c61 7965 != m_piece_laye │ │ │ -00060ff0: 7220 7c7c 2072 6571 2e69 6e64 6578 2025 r || req.index % │ │ │ -00061000: 2035 3132 2021 3d20 3020 7c7c 2072 6571 512 != 0 || req │ │ │ -00061010: 2e63 6f75 6e74 2026 6774 3b20 3531 320a .count > 512. │ │ │ -00061020: 0909 097c 7c20 7265 712e 696e 6465 7820 ...|| req.index │ │ │ -00061030: 2667 743b 3d20 6d5f 6669 6c65 732e 6669 >= m_files.fi │ │ │ -00061040: 6c65 5f6e 756d 5f70 6965 6365 7328 7265 le_num_pieces(re │ │ │ -00061050: 712e 6669 6c65 2929 0a09 0909 7265 7475 q.file))....retu │ │ │ -00061060: 726e 3b0a 0a09 0966 6f72 2028 696e 7420 rn;....for (int │ │ │ -00061070: 6920 3d20 7265 712e 696e 6465 783b 2069 i = req.index; i │ │ │ -00061080: 2026 6c74 3b20 7265 712e 696e 6465 7820 < req.index │ │ │ -00061090: 2b20 7265 712e 636f 756e 743b 2069 202b + req.count; i + │ │ │ -000610a0: 3d20 3531 3229 0a09 097b 0a3c 2f70 7265 = 512)...{.
    rele │ │ │ -000610e0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/fil │ │ │ -00061120: 655f 7374 6f72 6167 652e 6370 703a 3435 e_storage.cpp:45 │ │ │ -00061130: 383c 2f61 3e3c 2f74 643e 3c74 643e 6d61 8ma │ │ │ -00061140: 7962 6520 6974 2077 6f75 6c64 2062 6520 ybe it would be │ │ │ -00061150: 6e69 6365 2074 6f20 6861 7665 2061 2062 nice to have a b │ │ │ -00061160: 6574 7465 7220 696e 6465 7820 6865 7265 etter index here │ │ │ -00061170: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    ma │ │ │ -000611c0: 7962 6520 6974 2077 6f75 6c64 2062 6520 ybe it would be │ │ │ -000611d0: 6e69 6365 2074 6f20 6861 7665 2061 2062 nice to have a b │ │ │ -000611e0: 6574 7465 7220 696e 6465 7820 6865 7265 etter index here │ │ │ -000611f0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -00061200: 6669 6c65 5f73 746f 7261 6765 2e63 7070 file_storage.cpp │ │ │ -00061210: 3a34 3538 3c2f 6834 3e3c 7072 6520 7374 :458

    ..// find the
    │ │ │ -00061260: 2066 696c 6520 6974 6572 6174 6f72 2061   file iterator a
    │ │ │ -00061270: 6e64 2066 696c 6520 6f66 6673 6574 0a09  nd file offset..
    │ │ │ -00061280: 0961 7578 3a3a 6669 6c65 5f65 6e74 7279  .aux::file_entry
    │ │ │ -00061290: 2074 6172 6765 743b 0a09 0974 6172 6765   target;...targe
    │ │ │ -000612a0: 742e 6f66 6673 6574 203d 2061 7578 3a3a  t.offset = aux::
    │ │ │ -000612b0: 6e75 6d65 7269 635f 6361 7374 266c 743b  numeric_cast<
    │ │ │ -000612c0: 7374 643a 3a75 696e 7436 345f 7426 6774  std::uint64_t>
    │ │ │ -000612d0: 3b28 6f66 6673 6574 293b 0a09 0954 4f52  ;(offset);...TOR
    │ │ │ -000612e0: 5245 4e54 5f41 5353 4552 5428 2163 6f6d  RENT_ASSERT(!com
    │ │ │ -000612f0: 7061 7265 5f66 696c 655f 6f66 6673 6574  pare_file_offset
    │ │ │ -00061300: 2874 6172 6765 742c 206d 5f66 696c 6573  (target, m_files
    │ │ │ -00061310: 2e66 726f 6e74 2829 2929 3b0a 0a09 0961  .front()));....a
    │ │ │ -00061320: 7574 6f20 6669 6c65 5f69 7465 7220 3d20  uto file_iter = 
    │ │ │ -00061330: 7374 643a 3a75 7070 6572 5f62 6f75 6e64  std::upper_bound
    │ │ │ -00061340: 280a 0909 096d 5f66 696c 6573 2e62 6567  (....m_files.beg
    │ │ │ -00061350: 696e 2829 2c20 6d5f 6669 6c65 732e 656e  in(), m_files.en
    │ │ │ -00061360: 6428 292c 2074 6172 6765 742c 2063 6f6d  d(), target, com
    │ │ │ -00061370: 7061 7265 5f66 696c 655f 6f66 6673 6574  pare_file_offset
    │ │ │ -00061380: 293b 0a0a 0909 544f 5252 454e 545f 4153  );....TORRENT_AS
    │ │ │ -00061390: 5345 5254 2866 696c 655f 6974 6572 2021  SERT(file_iter !
    │ │ │ -000613a0: 3d20 6d5f 6669 6c65 732e 6265 6769 6e28  = m_files.begin(
    │ │ │ -000613b0: 2929 3b0a 0909 2d2d 6669 6c65 5f69 7465  ));...--file_ite
    │ │ │ -000613c0: 723b 0a09 0972 6574 7572 6e20 6669 6c65  r;...return file
    │ │ │ -000613d0: 5f69 6e64 6578 5f74 7b69 6e74 2866 696c  _index_t{int(fil
    │ │ │ -000613e0: 655f 6974 6572 202d 206d 5f66 696c 6573  e_iter - m_files
    │ │ │ -000613f0: 2e62 6567 696e 2829 297d 3b0a 097d 0a0a  .begin())};..}..
    │ │ │ -00061400: 0966 696c 655f 696e 6465 785f 7420 6669  .file_index_t fi
    │ │ │ -00061410: 6c65 5f73 746f 7261 6765 3a3a 6669 6c65  le_storage::file
    │ │ │ -00061420: 5f69 6e64 6578 5f61 745f 7069 6563 6528  _index_at_piece(
    │ │ │ -00061430: 7069 6563 655f 696e 6465 785f 7420 636f  piece_index_t co
    │ │ │ -00061440: 6e73 7420 7069 6563 6529 2063 6f6e 7374  nst piece) const
    │ │ │ -00061450: 0a09 7b0a 0909 7265 7475 726e 2066 696c  ..{...return fil
    │ │ │ -00061460: 655f 696e 6465 785f 6174 5f6f 6666 7365  e_index_at_offse
    │ │ │ -00061470: 7428 7374 6174 6963 5f63 6173 7426 6c74  t(static_cast<
    │ │ │ -00061480: 3b69 6e74 2667 743b 2870 6965 6365 2920  ;int>(piece) 
    │ │ │ -00061490: 2a20 7374 643a 3a69 6e74 3634 5f74 2870  * std::int64_t(p
    │ │ │ -000614a0: 6965 6365 5f6c 656e 6774 6828 2929 293b  iece_length()));
    │ │ │ -000614b0: 0a09 7d0a 0a09 6669 6c65 5f69 6e64 6578  ..}...file_index
    │ │ │ -000614c0: 5f74 2066 696c 655f 7374 6f72 6167 653a  _t file_storage:
    │ │ │ -000614d0: 3a66 696c 655f 696e 6465 785f 666f 725f  :file_index_for_
    │ │ │ -000614e0: 726f 6f74 2873 6861 3235 365f 6861 7368  root(sha256_hash
    │ │ │ -000614f0: 2063 6f6e 7374 2661 6d70 3b20 726f 6f74   const& root
    │ │ │ -00061500: 5f68 6173 6829 2063 6f6e 7374 0a09 7b0a  _hash) const..{.
    │ │ │ -00061510: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ -00061540: 666f 7220 2866 696c 655f 696e 6465 785f for (file_index_ │ │ │ -00061550: 7420 636f 6e73 7420 6920 3a20 6669 6c65 t const i : file │ │ │ -00061560: 5f72 616e 6765 2829 290a 3c2f 6469 763e _range()).
    │ │ │ -00061570: 0909 7b0a 0909 0969 6620 2872 6f6f 7428 ..{....if (root( │ │ │ -00061580: 6929 203d 3d20 726f 6f74 5f68 6173 6829 i) == root_hash) │ │ │ -00061590: 2072 6574 7572 6e20 693b 0a09 097d 0a09 return i;...}.. │ │ │ -000615a0: 0972 6574 7572 6e20 6669 6c65 5f69 6e64 .return file_ind │ │ │ -000615b0: 6578 5f74 7b2d 317d 3b0a 097d 0a0a 0970 ex_t{-1};..}...p │ │ │ -000615c0: 6965 6365 5f69 6e64 6578 5f74 2066 696c iece_index_t fil │ │ │ -000615d0: 655f 7374 6f72 6167 653a 3a70 6965 6365 e_storage::piece │ │ │ -000615e0: 5f69 6e64 6578 5f61 745f 6669 6c65 2866 _index_at_file(f │ │ │ -000615f0: 696c 655f 696e 6465 785f 7420 6629 2063 ile_index_t f) c │ │ │ -00061600: 6f6e 7374 0a09 7b0a 0909 7265 7475 726e onst..{...return │ │ │ -00061610: 2070 6965 6365 5f69 6e64 6578 5f74 7b61 piece_index_t{a │ │ │ -00061620: 7578 3a3a 6e75 6d65 7269 635f 6361 7374 ux::numeric_cast │ │ │ -00061630: 266c 743b 696e 7426 6774 3b28 6669 6c65 <int>(file │ │ │ -00061640: 5f6f 6666 7365 7428 6629 202f 2070 6965 _offset(f) / pie │ │ │ -00061650: 6365 5f6c 656e 6774 6828 2929 7d3b 0a09 ce_length())};.. │ │ │ -00061660: 7d0a 0a23 6966 2054 4f52 5245 4e54 5f41 }..#if TORRENT_A │ │ │ -00061670: 4249 5f56 4552 5349 4f4e 2026 6c74 3b3d BI_VERSION <= │ │ │ -00061680: 2032 0a09 6368 6172 2063 6f6e 7374 2a20 2..char const* │ │ │ -00061690: 6669 6c65 5f73 746f 7261 6765 3a3a 6669 file_storage::fi │ │ │ -000616a0: 6c65 5f6e 616d 655f 7074 7228 6669 6c65 le_name_ptr(file │ │ │ -000616b0: 5f69 6e64 6578 5f74 2063 6f6e 7374 2069 _index_t const i │ │ │ -000616c0: 6e64 6578 2920 636f 6e73 740a 097b 0a09 ndex) const..{.. │ │ │ -000616d0: 0972 6574 7572 6e20 6d5f 6669 6c65 735b .return m_files[ │ │ │ -000616e0: 696e 6465 785d 2e6e 616d 653b 0a09 7d0a index].name;..}. │ │ │ -000616f0: 0a09 696e 7420 6669 6c65 5f73 746f 7261 ..int file_stora │ │ │ -00061700: 6765 3a3a 6669 6c65 5f6e 616d 655f 6c65 ge::file_name_le │ │ │ -00061710: 6e28 6669 6c65 5f69 6e64 6578 5f74 2063 n(file_index_t c │ │ │ -00061720: 6f6e 7374 2069 6e64 6578 2920 636f 6e73 onst index) cons │ │ │ -00061730: 740a 097b 0a09 0969 6620 286d 5f66 696c t..{...if (m_fil │ │ │ -00061740: 6573 5b69 6e64 6578 5d2e 6e61 6d65 5f6c es[index].name_l │ │ │ -00061750: 656e 203d 3d20 6175 783a 3a66 696c 655f en == aux::file_ │ │ │ -00061760: 656e 7472 793a 3a6e 616d 655f 6973 5f6f entry::name_is_o │ │ │ -00061770: 776e 6564 290a 0909 0972 6574 7572 6e20 wned)....return │ │ │ -00061780: 2d31 3b0a 0909 7265 7475 726e 206d 5f66 -1;...return m_f │ │ │ -00061790: 696c 6573 5b69 6e64 6578 5d2e 6e61 6d65 iles[index].name │ │ │ -000617a0: 5f6c 656e 3b0a 097d 0a23 656e 6469 660a _len;..}.#endif. │ │ │ -000617b0: 0a09 7374 643a 3a76 6563 746f 7226 6c74 ..std::vector< │ │ │ -000617c0: 3b66 696c 655f 736c 6963 6526 6774 3b20 ;file_slice> │ │ │ -000617d0: 6669 6c65 5f73 746f 7261 6765 3a3a 6d61 file_storage::ma │ │ │ -000617e0: 705f 626c 6f63 6b28 7069 6563 655f 696e p_block(piece_in │ │ │ -000617f0: 6465 785f 7420 636f 6e73 7420 7069 6563 dex_t const piec │ │ │ -00061800: 650a 0909 2c20 7374 643a 3a69 6e74 3634 e..., std::int64 │ │ │ -00061810: 5f74 2063 6f6e 7374 206f 6666 7365 742c _t const offset, │ │ │ -00061820: 2073 7464 3a3a 696e 7436 345f 7420 7369 std::int64_t si │ │ │ -00061830: 7a65 2920 636f 6e73 740a 097b 0a09 0954 ze) const..{...T │ │ │ -00061840: 4f52 5245 4e54 5f41 5353 4552 545f 5052 ORRENT_ASSERT_PR │ │ │ -00061850: 4543 4f4e 4428 7069 6563 6520 2667 743b ECOND(piece > │ │ │ -00061860: 3d20 7069 6563 655f 696e 6465 785f 747b = piece_index_t{ │ │ │ -00061870: 307d 293b 0a09 0954 4f52 5245 4e54 5f41 0});...TORRENT_A │ │ │ -00061880: 5353 4552 545f 5052 4543 4f4e 4428 7069 SSERT_PRECOND(pi │ │ │ -00061890: 6563 6520 266c 743b 2065 6e64 5f70 6965 ece < end_pie │ │ │ -000618a0: 6365 2829 293b 0a3c 2f70 7265 3e3c 2f74 ce());.
    relevanc │ │ │ -000618e0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/file_st │ │ │ -00061920: 6f72 6167 652e 6370 703a 3132 3433 3c2f orage.cpp:1243this │ │ │ -00061940: 776f 756c 6420 6265 206d 6f72 6520 6566 would be more ef │ │ │ -00061950: 6669 6369 656e 7420 6966 206d 5f70 6174 ficient if m_pat │ │ │ -00061960: 6873 2077 6173 2073 6f72 7465 6420 6669 hs was sorted fi │ │ │ -00061970: 7273 742c 2073 7563 6820 7468 6174 2061 rst, such that a │ │ │ -00061980: 206c 6f77 6572 2070 6174 6820 696e 6465 lower path inde │ │ │ -00061990: 7820 616c 7761 7973 206d 6561 6e74 2073 x always meant s │ │ │ -000619a0: 6f72 7465 642d 6265 666f 7265 3c2f 7464 orted-before

    this w │ │ │ -00061a00: 6f75 6c64 2062 6520 6d6f 7265 2065 6666 ould be more eff │ │ │ -00061a10: 6963 6965 6e74 2069 6620 6d5f 7061 7468 icient if m_path │ │ │ -00061a20: 7320 7761 7320 736f 7274 6564 2066 6972 s was sorted fir │ │ │ -00061a30: 7374 2c20 7375 6368 0a74 6861 7420 6120 st, such.that a │ │ │ -00061a40: 6c6f 7765 7220 7061 7468 2069 6e64 6578 lower path index │ │ │ -00061a50: 2061 6c77 6179 7320 6d65 616e 7420 736f always meant so │ │ │ -00061a60: 7274 6564 2d62 6566 6f72 653c 2f68 323e rted-before

    │ │ │ -00061a70: 3c68 343e 2e2e 2f73 7263 2f66 696c 655f

    ../src/file_ │ │ │ -00061a80: 7374 6f72 6167 652e 6370 703a 3132 3433 storage.cpp:1243 │ │ │ -00061a90: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00061ad0: 7d0a 0a09 766f 6964 2066 696c 655f 7374  }...void file_st
    │ │ │ -00061ae0: 6f72 6167 653a 3a63 616e 6f6e 6963 616c  orage::canonical
    │ │ │ -00061af0: 697a 655f 696d 706c 2862 6f6f 6c20 636f  ize_impl(bool co
    │ │ │ -00061b00: 6e73 7420 6261 636b 7761 7264 735f 636f  nst backwards_co
    │ │ │ -00061b10: 6d70 6174 6962 6c65 290a 097b 0a09 0954  mpatible)..{...T
    │ │ │ -00061b20: 4f52 5245 4e54 5f41 5353 4552 5428 7069  ORRENT_ASSERT(pi
    │ │ │ -00061b30: 6563 655f 6c65 6e67 7468 2829 2026 6774  ece_length() >
    │ │ │ -00061b40: 3b3d 2031 3620 2a20 3130 3234 293b 0a0a  ;= 16 * 1024);..
    │ │ │ -00061b50: 0909 2f2f 2075 7365 2074 6869 7320 7665  ..// use this ve
    │ │ │ -00061b60: 6374 6f72 2074 6f20 7472 6163 6b20 7468  ctor to track th
    │ │ │ -00061b70: 6520 6e65 7720 6f72 6465 7269 6e67 206f  e new ordering o
    │ │ │ -00061b80: 6620 6669 6c65 730a 0909 2f2f 2074 6869  f files...// thi
    │ │ │ -00061b90: 7320 616c 6c6f 7773 2074 6865 2075 7365  s allows the use
    │ │ │ -00061ba0: 206f 6620 5354 4c20 616c 676f 7269 7468   of STL algorith
    │ │ │ -00061bb0: 6d73 2064 6573 7069 7465 2074 6865 6d0a  ms despite them.
    │ │ │ -00061bc0: 0909 2f2f 206e 6f74 2073 7570 706f 7274  ..// not support
    │ │ │ -00061bd0: 696e 6720 6120 6375 7374 6f6d 2073 7761  ing a custom swa
    │ │ │ -00061be0: 7020 6675 6e63 746f 720a 0909 6175 783a  p functor...aux:
    │ │ │ -00061bf0: 3a76 6563 746f 7226 6c74 3b66 696c 655f  :vector<file_
    │ │ │ -00061c00: 696e 6465 785f 742c 2066 696c 655f 696e  index_t, file_in
    │ │ │ -00061c10: 6465 785f 7426 6774 3b20 6e65 775f 6f72  dex_t> new_or
    │ │ │ -00061c20: 6465 7228 656e 645f 6669 6c65 2829 293b  der(end_file());
    │ │ │ -00061c30: 0a09 0966 6f72 2028 6175 746f 2069 203a  ...for (auto i :
    │ │ │ -00061c40: 2066 696c 655f 7261 6e67 6528 2929 0a09   file_range())..
    │ │ │ -00061c50: 0909 6e65 775f 6f72 6465 725b 695d 203d  ..new_order[i] =
    │ │ │ -00061c60: 2069 3b0a 0a09 092f 2f20 7265 6d6f 7665   i;....// remove
    │ │ │ -00061c70: 2061 6e79 2065 7869 7374 696e 6720 7061   any existing pa
    │ │ │ -00061c80: 6420 6669 6c65 730a 0909 7b0a 0909 0961  d files...{....a
    │ │ │ -00061c90: 7574 6f20 7061 645f 6265 6769 6e20 3d20  uto pad_begin = 
    │ │ │ -00061ca0: 7374 643a 3a70 6172 7469 7469 6f6e 286e  std::partition(n
    │ │ │ -00061cb0: 6577 5f6f 7264 6572 2e62 6567 696e 2829  ew_order.begin()
    │ │ │ -00061cc0: 2c20 6e65 775f 6f72 6465 722e 656e 6428  , new_order.end(
    │ │ │ -00061cd0: 290a 0909 0909 2c20 5b74 6869 735d 2866  )....., [this](f
    │ │ │ -00061ce0: 696c 655f 696e 6465 785f 7420 6929 207b  ile_index_t i) {
    │ │ │ -00061cf0: 2072 6574 7572 6e20 216d 5f66 696c 6573   return !m_files
    │ │ │ -00061d00: 5b69 5d2e 7061 645f 6669 6c65 3b20 7d29  [i].pad_file; })
    │ │ │ -00061d10: 3b0a 0909 096e 6577 5f6f 7264 6572 2e65  ;....new_order.e
    │ │ │ -00061d20: 7261 7365 2870 6164 5f62 6567 696e 2c20  rase(pad_begin, 
    │ │ │ -00061d30: 6e65 775f 6f72 6465 722e 656e 6428 2929  new_order.end())
    │ │ │ -00061d40: 3b0a 0909 7d0a 0a3c 6469 7620 7374 796c  ;...}..
    .
    ..// │ │ │ -00061d80: 2073 6f72 7420 6669 6c65 7320 6279 2070 sort files by p │ │ │ -00061d90: 6174 682f 6e61 6d65 0a09 0973 7464 3a3a ath/name...std:: │ │ │ -00061da0: 736f 7274 286e 6577 5f6f 7264 6572 2e62 sort(new_order.b │ │ │ -00061db0: 6567 696e 2829 2c20 6e65 775f 6f72 6465 egin(), new_orde │ │ │ -00061dc0: 722e 656e 6428 290a 0909 092c 205b 7468 r.end()...., [th │ │ │ -00061dd0: 6973 5d28 6669 6c65 5f69 6e64 6578 5f74 is](file_index_t │ │ │ -00061de0: 206c 2c20 6669 6c65 5f69 6e64 6578 5f74 l, file_index_t │ │ │ -00061df0: 2072 290a 0909 7b0a 0909 092f 2f20 6173 r)...{....// as │ │ │ -00061e00: 7375 6d69 6e67 206d 5f70 6174 6873 2061 suming m_paths a │ │ │ -00061e10: 7265 2075 6e69 7175 6521 0a09 0909 6175 re unique!....au │ │ │ -00061e20: 746f 2063 6f6e 7374 2661 6d70 3b20 6c66 to const& lf │ │ │ -00061e30: 203d 206d 5f66 696c 6573 5b6c 5d3b 0a09 = m_files[l];.. │ │ │ -00061e40: 0909 6175 746f 2063 6f6e 7374 2661 6d70 ..auto const& │ │ │ -00061e50: 3b20 7266 203d 206d 5f66 696c 6573 5b72 ; rf = m_files[r │ │ │ -00061e60: 5d3b 0a09 0909 6966 2028 6c66 2e70 6174 ];....if (lf.pat │ │ │ -00061e70: 685f 696e 6465 7820 213d 2072 662e 7061 h_index != rf.pa │ │ │ -00061e80: 7468 5f69 6e64 6578 290a 0909 097b 0a09 th_index)....{.. │ │ │ -00061e90: 0909 0969 6e74 2063 6f6e 7374 2072 6574 ...int const ret │ │ │ -00061ea0: 203d 2070 6174 685f 636f 6d70 6172 6528 = path_compare( │ │ │ -00061eb0: 6d5f 7061 7468 735b 6c66 2e70 6174 685f m_paths[lf.path_ │ │ │ -00061ec0: 696e 6465 785d 2c20 6c66 2e66 696c 656e index], lf.filen │ │ │ -00061ed0: 616d 6528 290a 0909 0909 092c 206d 5f70 ame()......, m_p │ │ │ -00061ee0: 6174 6873 5b72 662e 7061 7468 5f69 6e64 aths[rf.path_ind │ │ │ -00061ef0: 6578 5d2c 2072 662e 6669 6c65 6e61 6d65 ex], rf.filename │ │ │ -00061f00: 2829 293b 0a09 0909 0969 6620 2872 6574 ());.....if (ret │ │ │ -00061f10: 2021 3d20 3029 2072 6574 7572 6e20 7265 != 0) return re │ │ │ -00061f20: 7420 266c 743b 2030 3b0a 0909 097d 0a09 t < 0;....}.. │ │ │ -00061f30: 0909 7265 7475 726e 206c 662e 6669 6c65 ..return lf.file │ │ │ -00061f40: 6e61 6d65 2829 2026 6c74 3b20 7266 2e66 name() < rf.f │ │ │ -00061f50: 696c 656e 616d 6528 293b 0a09 097d 293b ilename();...}); │ │ │ -00061f60: 0a0a 0909 6175 783a 3a76 6563 746f 7226 ....aux::vector& │ │ │ -00061f70: 6c74 3b61 7578 3a3a 6669 6c65 5f65 6e74 lt;aux::file_ent │ │ │ -00061f80: 7279 2c20 6669 6c65 5f69 6e64 6578 5f74 ry, file_index_t │ │ │ -00061f90: 2667 743b 206e 6577 5f66 696c 6573 3b0a > new_files;. │ │ │ -00061fa0: 0909 6175 783a 3a76 6563 746f 7226 6c74 ..aux::vector< │ │ │ -00061fb0: 3b63 6861 7220 636f 6e73 742a 2c20 6669 ;char const*, fi │ │ │ -00061fc0: 6c65 5f69 6e64 6578 5f74 2667 743b 206e le_index_t> n │ │ │ -00061fd0: 6577 5f66 696c 655f 6861 7368 6573 3b0a ew_file_hashes;. │ │ │ -00061fe0: 0909 6175 783a 3a76 6563 746f 7226 6c74 ..aux::vector< │ │ │ -00061ff0: 3b73 7464 3a3a 7469 6d65 5f74 2c20 6669 ;std::time_t, fi │ │ │ -00062000: 6c65 5f69 6e64 6578 5f74 2667 743b 206e le_index_t> n │ │ │ -00062010: 6577 5f6d 7469 6d65 3b0a 0a09 092f 2f20 ew_mtime;....// │ │ │ -00062020: 7265 7365 7276 6520 656e 6f75 6768 2073 reserve enough s │ │ │ -00062030: 7061 6365 2066 6f72 2074 6865 2077 6f72 pace for the wor │ │ │ -00062040: 7374 2063 6173 6520 6166 7465 7220 7061 st case after pa │ │ │ -00062050: 6464 696e 670a 0909 6e65 775f 6669 6c65 dding...new_file │ │ │ -00062060: 732e 7265 7365 7276 6528 6e65 775f 6f72 s.reserve(new_or │ │ │ -00062070: 6465 722e 7369 7a65 2829 202a 2032 202d der.size() * 2 - │ │ │ -00062080: 2031 293b 0a09 0969 6620 2821 6d5f 6669 1);...if (!m_fi │ │ │ -00062090: 6c65 5f68 6173 6865 732e 656d 7074 7928 le_hashes.empty( │ │ │ -000620a0: 2929 0a09 0909 6e65 775f 6669 6c65 5f68 ))....new_file_h │ │ │ -000620b0: 6173 6865 732e 7265 7365 7276 6528 6e65 ashes.reserve(ne │ │ │ -000620c0: 775f 6f72 6465 722e 7369 7a65 2829 202a w_order.size() * │ │ │ -000620d0: 2032 202d 2031 293b 0a09 0969 6620 2821 2 - 1);...if (! │ │ │ -000620e0: 6d5f 6d74 696d 652e 656d 7074 7928 2929 m_mtime.empty()) │ │ │ -000620f0: 0a09 0909 6e65 775f 6d74 696d 652e 7265 ....new_mtime.re │ │ │ -00062100: 7365 7276 6528 6e65 775f 6f72 6465 722e serve(new_order. │ │ │ -00062110: 7369 7a65 2829 202a 2032 202d 2031 293b size() * 2 - 1); │ │ │ -00062120: 0a0a 0909 2f2f 2072 652d 636f 6d70 7574 ....// re-comput │ │ │ -00062130: 6520 6f66 6673 6574 7320 616e 6420 696e e offsets and in │ │ │ -00062140: 7365 7274 2070 6164 2066 696c 6573 2061 sert pad files a │ │ │ -00062150: 7320 6e65 6365 7373 6172 790a 0909 7374 s necessary...st │ │ │ -00062160: 643a 3a69 6e74 3634 5f74 206f 6666 203d d::int64_t off = │ │ │ -00062170: 2030 3b0a 0a3c 2f70 7265 3e3c 2f74 643e 0;..
    │ │ │ -00062180: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -000621b0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -000621c0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -000621d0: 7074 3a65 7870 616e 6428 3232 3529 223e pt:expand(225)"> │ │ │ -000621e0: 2e2e 2f73 7263 2f65 6e75 6d5f 6e65 742e ../src/enum_net. │ │ │ -000621f0: 6370 703a 3134 343c 2f61 3e3c 2f74 643e cpp:144
    │ │ │ -00062200: 3c74 643e 696e 2043 2b2b 3137 2c20 7573 in C++17, us │ │ │ -00062210: 6520 5f5f 6861 735f 696e 636c 7564 6520 e __has_include │ │ │ -00062220: 666f 7220 7468 6973 2e20 4f74 6865 7220 for this. Other │ │ │ -00062230: 6f70 6572 6174 696e 6720 7379 7374 656d operating system │ │ │ -00062240: 7320 6172 6520 6c69 6b65 6c79 2074 6f20 s are likely to │ │ │ -00062250: 7265 7175 6972 6520 7468 6973 2061 7320 require this as │ │ │ -00062260: 7765 6c6c 3c2f 7464 3e3c 2f74 723e 3c74 wellin C++17, use │ │ │ -000622c0: 5f5f 6861 735f 696e 636c 7564 6520 666f __has_include fo │ │ │ -000622d0: 7220 7468 6973 2e20 4f74 6865 7220 6f70 r this. Other op │ │ │ -000622e0: 6572 6174 696e 6720 7379 7374 656d 7320 erating systems │ │ │ -000622f0: 6172 650a 6c69 6b65 6c79 2074 6f20 7265 are.likely to re │ │ │ -00062300: 7175 6972 6520 7468 6973 2061 7320 7765 quire this as we │ │ │ -00062310: 6c6c 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 ll

    ../sr │ │ │ -00062320: 632f 656e 756d 5f6e 6574 2e63 7070 3a31 c/enum_net.cpp:1 │ │ │ -00062330: 3434 3c2f 6834 3e3c 7072 6520 7374 796c 44

    #include <ar
    │ │ │ -00062380: 7061 2f69 6e65 742e 6826 6774 3b0a 2369  pa/inet.h>.#i
    │ │ │ -00062390: 6e63 6c75 6465 2026 6c74 3b63 7374 7269  nclude <cstri
    │ │ │ -000623a0: 6e67 2667 743b 0a23 696e 636c 7564 6520  ng>.#include 
    │ │ │ -000623b0: 266c 743b 6373 7464 6c69 6226 6774 3b0a  <cstdlib>.
    │ │ │ -000623c0: 2369 6e63 6c75 6465 2026 6c74 3b75 6e69  #include <uni
    │ │ │ -000623d0: 7374 642e 6826 6774 3b0a 2369 6e63 6c75  std.h>.#inclu
    │ │ │ -000623e0: 6465 2026 6c74 3b73 7973 2f74 7970 6573  de <sys/types
    │ │ │ -000623f0: 2e68 2667 743b 0a0a 2369 6620 6465 6669  .h>..#if defi
    │ │ │ -00062400: 6e65 6420 544f 5252 454e 545f 414e 4452  ned TORRENT_ANDR
    │ │ │ -00062410: 4f49 4420 2661 6d70 3b26 616d 703b 2021  OID && !
    │ │ │ -00062420: 6465 6669 6e65 6420 4946 415f 465f 4441  defined IFA_F_DA
    │ │ │ -00062430: 4446 4149 4c45 440a 2364 6566 696e 6520  DFAILED.#define 
    │ │ │ -00062440: 4946 415f 465f 4441 4446 4149 4c45 4420  IFA_F_DADFAILED 
    │ │ │ -00062450: 380a 2365 6e64 6966 0a0a 2365 6e64 6966  8.#endif..#endif
    │ │ │ -00062460: 0a0a 2369 6620 544f 5252 454e 545f 5553  ..#if TORRENT_US
    │ │ │ -00062470: 455f 4946 4144 4452 530a 2369 6e63 6c75  E_IFADDRS.#inclu
    │ │ │ -00062480: 6465 2026 6c74 3b69 6661 6464 7273 2e68  de <ifaddrs.h
    │ │ │ -00062490: 2667 743b 0a23 696e 636c 7564 6520 266c  >.#include &l
    │ │ │ -000624a0: 743b 6e65 742f 6966 2e68 2667 743b 0a23  t;net/if.h>.#
    │ │ │ -000624b0: 696e 636c 7564 6520 266c 743b 7379 732f  include <sys/
    │ │ │ -000624c0: 696f 6374 6c2e 6826 6774 3b0a 2365 6e64  ioctl.h>.#end
    │ │ │ -000624d0: 6966 0a0a 2369 6620 544f 5252 454e 545f  if..#if TORRENT_
    │ │ │ -000624e0: 5553 455f 4946 4144 4452 5320 7c7c 2054  USE_IFADDRS || T
    │ │ │ -000624f0: 4f52 5245 4e54 5f55 5345 5f49 4643 4f4e  ORRENT_USE_IFCON
    │ │ │ -00062500: 4620 7c7c 2054 4f52 5245 4e54 5f55 5345  F || TORRENT_USE
    │ │ │ -00062510: 5f4e 4554 4c49 4e4b 207c 7c20 544f 5252  _NETLINK || TORR
    │ │ │ -00062520: 454e 545f 5553 455f 5359 5343 544c 0a23  ENT_USE_SYSCTL.#
    │ │ │ -00062530: 6966 6465 6620 544f 5252 454e 545f 4245  ifdef TORRENT_BE
    │ │ │ -00062540: 4f53 0a3c 6469 7620 7374 796c 653d 2262  OS.
    #include <sy │ │ │ -00062580: 732f 736f 636b 696f 2e68 2667 743b 0a3c s/sockio.h>.< │ │ │ -00062590: 2f64 6976 3e23 656e 6469 660a 2f2f 2063 /div>#endif.// c │ │ │ -000625a0: 6170 7475 7265 2074 6869 7320 6865 7265 apture this here │ │ │ -000625b0: 2077 6865 7265 2077 6172 6e69 6e67 7320 where warnings │ │ │ -000625c0: 6172 6520 6469 7361 626c 6564 2028 7468 are disabled (th │ │ │ -000625d0: 6520 6d61 6372 6f20 6765 6e65 7261 7465 e macro generate │ │ │ -000625e0: 7320 7761 726e 696e 6773 290a 636f 6e73 s warnings).cons │ │ │ -000625f0: 7420 756e 7369 676e 6564 206c 6f6e 6720 t unsigned long │ │ │ -00062600: 7369 6f63 6769 666d 7475 203d 2053 494f siocgifmtu = SIO │ │ │ -00062610: 4347 4946 4d54 553b 0a23 656e 6469 660a CGIFMTU;.#endif. │ │ │ -00062620: 0a23 696e 636c 7564 6520 226c 6962 746f .#include "libto │ │ │ -00062630: 7272 656e 742f 6175 785f 2f64 6973 6162 rrent/aux_/disab │ │ │ -00062640: 6c65 5f77 6172 6e69 6e67 735f 706f 702e le_warnings_pop. │ │ │ -00062650: 6870 7022 0a0a 2369 6620 6465 6669 6e65 hpp"..#if define │ │ │ -00062660: 6428 544f 5252 454e 545f 4f53 3229 2026 d(TORRENT_OS2) & │ │ │ -00062670: 616d 703b 2661 6d70 3b20 2164 6566 696e amp;& !defin │ │ │ -00062680: 6564 2849 465f 4e41 4d45 5349 5a45 290a ed(IF_NAMESIZE). │ │ │ -00062690: 2364 6566 696e 6520 4946 5f4e 414d 4553 #define IF_NAMES │ │ │ -000626a0: 495a 4520 4946 4e41 4d53 495a 0a23 656e IZE IFNAMSIZ.#en │ │ │ -000626b0: 6469 660a 0a6e 616d 6573 7061 6365 206c dif..namespace l │ │ │ -000626c0: 6962 746f 7272 656e 7420 7b0a 0a6e 616d ibtorrent {..nam │ │ │ -000626d0: 6573 7061 6365 207b 0a0a 2369 6620 2164 espace {..#if !d │ │ │ -000626e0: 6566 696e 6564 2054 4f52 5245 4e54 5f57 efined TORRENT_W │ │ │ -000626f0: 494e 444f 5753 2026 616d 703b 2661 6d70 INDOWS && │ │ │ -00062700: 3b20 2164 6566 696e 6564 2054 4f52 5245 ; !defined TORRE │ │ │ -00062710: 4e54 5f42 5549 4c44 5f53 494d 554c 4154 NT_BUILD_SIMULAT │ │ │ -00062720: 4f52 0a09 7374 7275 6374 2073 6f63 6b65 OR..struct socke │ │ │ -00062730: 745f 636c 6f73 6572 0a09 7b0a 0909 736f t_closer..{...so │ │ │ -00062740: 636b 6574 5f63 6c6f 7365 7228 696e 7420 cket_closer(int │ │ │ -00062750: 7329 203a 206d 5f73 6f63 6b65 7428 7329 s) : m_socket(s) │ │ │ -00062760: 207b 7d0a 0909 736f 636b 6574 5f63 6c6f {}...socket_clo │ │ │ -00062770: 7365 7228 736f 636b 6574 5f63 6c6f 7365 ser(socket_close │ │ │ -00062780: 7220 636f 6e73 7426 616d 703b 2920 3d20 r const&) = │ │ │ -00062790: 6465 6c65 7465 3b0a 0909 736f 636b 6574 delete;...socket │ │ │ -000627a0: 5f63 6c6f 7365 7228 736f 636b 6574 5f63 _closer(socket_c │ │ │ -000627b0: 6c6f 7365 7220 2661 6d70 3b26 616d 703b loser && │ │ │ -000627c0: 2920 3d20 6465 6c65 7465 3b0a 0909 736f ) = delete;...so │ │ │ -000627d0: 636b 6574 5f63 6c6f 7365 7226 616d 703b cket_closer& │ │ │ -000627e0: 206f 7065 7261 746f 723d 2873 6f63 6b65 operator=(socke │ │ │ -000627f0: 745f 636c 6f73 6572 2063 6f6e 7374 2661 t_closer const&a │ │ │ -00062800: 6d70 3b29 203d 2064 656c 6574 653b 0a09 mp;) = delete;.. │ │ │ -00062810: 0973 6f63 6b65 745f 636c 6f73 6572 2661 .socket_closer&a │ │ │ -00062820: 6d70 3b20 6f70 6572 6174 6f72 3d28 736f mp; operator=(so │ │ │ -00062830: 636b 6574 5f63 6c6f 7365 7220 2661 6d70 cket_closer & │ │ │ -00062840: 3b26 616d 703b 2920 3d20 6465 6c65 7465 ;&) = delete │ │ │ -00062850: 3b0a 0909 7e73 6f63 6b65 745f 636c 6f73 ;...~socket_clos │ │ │ -00062860: 6572 2829 207b 203a 3a63 6c6f 7365 286d er() { ::close(m │ │ │ -00062870: 5f73 6f63 6b65 7429 3b20 7d0a 0970 7269 _socket); }..pri │ │ │ -00062880: 7661 7465 3a0a 0909 696e 7420 6d5f 736f vate:...int m_so │ │ │ -00062890: 636b 6574 3b0a 097d 3b0a 2365 6e64 6966 cket;..};.#endif │ │ │ -000628a0: 0a0a 2369 6620 2164 6566 696e 6564 2054 ..#if !defined T │ │ │ -000628b0: 4f52 5245 4e54 5f42 5549 4c44 5f53 494d ORRENT_BUILD_SIM │ │ │ -000628c0: 554c 4154 4f52 0a3c 2f70 7265 3e3c 2f74 ULATOR.
    relevanc │ │ │ -00062900: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/enum_ne │ │ │ -00062940: 742e 6370 703a 3236 383c 2f61 3e3c 2f74 t.cpp:268
    if we get │ │ │ -00062960: 6865 7265 2c20 7468 6520 6361 6c6c 6572 here, the caller │ │ │ -00062970: 2073 7469 6c6c 2061 7373 756d 6573 2074 still assumes t │ │ │ -00062980: 6865 2065 7272 6f72 2063 6f64 6520 6973 he error code is │ │ │ -00062990: 2072 6570 6f72 7465 6420 7669 6120 6572 reported via er │ │ │ -000629a0: 726e 6f3c 2f74 643e 3c2f 7472 3e3c 7472 rno

    if we get here, │ │ │ -00062a00: 2074 6865 2063 616c 6c65 7220 7374 696c the caller stil │ │ │ -00062a10: 6c20 6173 7375 6d65 7320 7468 6520 6572 l assumes the er │ │ │ -00062a20: 726f 7220 636f 6465 0a69 7320 7265 706f ror code.is repo │ │ │ -00062a30: 7274 6564 2076 6961 2065 7272 6e6f 3c2f rted via errno

    ../src/en │ │ │ -00062a50: 756d 5f6e 6574 2e63 7070 3a32 3638 3c2f um_net.cpp:268
    ..;
    │ │ │ -00062aa0: 0a09 7d0a 2365 6e64 6966 0a0a 2369 6620  ..}.#endif..#if 
    │ │ │ -00062ab0: 544f 5252 454e 545f 5553 455f 4e45 544c  TORRENT_USE_NETL
    │ │ │ -00062ac0: 494e 4b0a 0a09 696e 7420 7265 6164 5f6e  INK...int read_n
    │ │ │ -00062ad0: 6c5f 736f 636b 2869 6e74 2073 6f63 6b2c  l_sock(int sock,
    │ │ │ -00062ae0: 2073 7464 3a3a 7569 6e74 3332 5f74 2063   std::uint32_t c
    │ │ │ -00062af0: 6f6e 7374 2073 6571 2c20 7374 643a 3a75  onst seq, std::u
    │ │ │ -00062b00: 696e 7433 325f 7420 636f 6e73 7420 7069  int32_t const pi
    │ │ │ -00062b10: 640a 0909 2c20 7374 643a 3a66 756e 6374  d..., std::funct
    │ │ │ -00062b20: 696f 6e26 6c74 3b76 6f69 6428 6e6c 6d73  ion<void(nlms
    │ │ │ -00062b30: 6768 6472 2063 6f6e 7374 2a29 2667 743b  ghdr const*)>
    │ │ │ -00062b40: 206f 6e5f 6d73 6729 0a09 7b0a 0909 7374   on_msg)..{...st
    │ │ │ -00062b50: 643a 3a61 7272 6179 266c 743b 6368 6172  d::array<char
    │ │ │ -00062b60: 2c20 3430 3936 2667 743b 2062 7566 3b0a  , 4096> buf;.
    │ │ │ -00062b70: 0909 666f 7220 283b 3b29 0a09 097b 0a09  ..for (;;)...{..
    │ │ │ -00062b80: 0909 696e 7420 636f 6e73 7420 7265 6164  ..int const read
    │ │ │ -00062b90: 5f6c 656e 203d 2069 6e74 2872 6563 7628  _len = int(recv(
    │ │ │ -00062ba0: 736f 636b 2c20 6275 662e 6461 7461 2829  sock, buf.data()
    │ │ │ -00062bb0: 2c20 6275 662e 7369 7a65 2829 2c20 3029  , buf.size(), 0)
    │ │ │ -00062bc0: 293b 0a09 0909 6966 2028 7265 6164 5f6c  );....if (read_l
    │ │ │ -00062bd0: 656e 2026 6c74 3b20 3029 2072 6574 7572  en < 0) retur
    │ │ │ -00062be0: 6e20 2d31 3b0a 0a09 0909 6175 746f 2063  n -1;.....auto c
    │ │ │ -00062bf0: 6f6e 7374 2a20 6e6c 5f68 6472 203d 2072  onst* nl_hdr = r
    │ │ │ -00062c00: 6569 6e74 6572 7072 6574 5f63 6173 7426  einterpret_cast&
    │ │ │ -00062c10: 6c74 3b6e 6c6d 7367 6864 7220 636f 6e73  lt;nlmsghdr cons
    │ │ │ -00062c20: 742a 2667 743b 2862 7566 2e64 6174 6128  t*>(buf.data(
    │ │ │ -00062c30: 2929 3b0a 0909 0969 6e74 206c 656e 203d  ));....int len =
    │ │ │ -00062c40: 2072 6561 645f 6c65 6e3b 0a0a 0909 0966   read_len;.....f
    │ │ │ -00062c50: 6f72 2028 3b20 6c65 6e20 2667 743b 2030  or (; len > 0
    │ │ │ -00062c60: 2026 616d 703b 2661 6d70 3b20 6175 783a   && aux:
    │ │ │ -00062c70: 3a6e 6c6d 7367 5f6f 6b28 6e6c 5f68 6472  :nlmsg_ok(nl_hdr
    │ │ │ -00062c80: 2c20 6c65 6e29 3b20 6e6c 5f68 6472 203d  , len); nl_hdr =
    │ │ │ -00062c90: 2061 7578 3a3a 6e6c 6d73 675f 6e65 7874   aux::nlmsg_next
    │ │ │ -00062ca0: 286e 6c5f 6864 722c 206c 656e 2929 0a09  (nl_hdr, len))..
    │ │ │ -00062cb0: 0909 7b0a 3c64 6976 2073 7479 6c65 3d22  ..{.
    ....if ((aux:: │ │ │ -00062cf0: 6e6c 6d73 675f 6f6b 286e 6c5f 6864 722c nlmsg_ok(nl_hdr, │ │ │ -00062d00: 2072 6561 645f 6c65 6e29 203d 3d20 3029 read_len) == 0) │ │ │ -00062d10: 207c 7c20 286e 6c5f 6864 722d 2667 743b || (nl_hdr-> │ │ │ -00062d20: 6e6c 6d73 675f 7479 7065 203d 3d20 4e4c nlmsg_type == NL │ │ │ -00062d30: 4d53 475f 4552 524f 5229 290a 3c2f 6469 MSG_ERROR))......return -1 │ │ │ -00062d50: 3b0a 0909 0909 2f2f 2074 6869 7320 6675 ;.....// this fu │ │ │ -00062d60: 6e63 7469 6f6e 2064 6f65 736e 2774 2068 nction doesn't h │ │ │ -00062d70: 616e 646c 6520 6d75 6c74 6970 6c65 2072 andle multiple r │ │ │ -00062d80: 6571 7565 7374 7320 6174 2074 6865 2073 equests at the s │ │ │ -00062d90: 616d 6520 7469 6d65 0a09 0909 092f 2f20 ame time.....// │ │ │ -00062da0: 736f 2072 6570 6f72 7420 616e 2065 7272 so report an err │ │ │ -00062db0: 6f72 2069 6620 7468 6520 6d65 7373 6167 or if the messag │ │ │ -00062dc0: 6520 646f 6573 206e 6f74 2068 6176 6520 e does not have │ │ │ -00062dd0: 7468 6520 6578 7065 6374 6564 2073 6571 the expected seq │ │ │ -00062de0: 2061 6e64 2070 6964 0a3c 2f70 7265 3e3c and pid.
    < │ │ │ -00062df0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00062e20: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00062e30: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/enum_ │ │ │ -00062e60: 6e65 742e 6370 703a 3237 343c 2f61 3e3c net.cpp:274< │ │ │ -00062e70: 2f74 643e 3c74 643e 6966 2077 6520 6765 /td>if we ge │ │ │ -00062e80: 7420 6865 7265 2c20 7468 6520 6361 6c6c t here, the call │ │ │ -00062e90: 6572 2073 7469 6c6c 2061 7373 756d 6573 er still assumes │ │ │ -00062ea0: 2074 6865 2065 7272 6f72 2063 6f64 6520 the error code │ │ │ -00062eb0: 6973 2072 6570 6f72 7465 6420 7669 6120 is reported via │ │ │ -00062ec0: 6572 726e 6f3c 2f74 643e 3c2f 7472 3e3c errno< │ │ │ -00062ed0: 7472 2069 643d 2232 3237 2220 7374 796c tr id="227" styl │ │ │ -00062ee0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00062ef0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00062f00: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00062f10: 6832 3e69 6620 7765 2067 6574 2068 6572 h2>if we get her │ │ │ -00062f20: 652c 2074 6865 2063 616c 6c65 7220 7374 e, the caller st │ │ │ -00062f30: 696c 6c20 6173 7375 6d65 7320 7468 6520 ill assumes the │ │ │ -00062f40: 6572 726f 7220 636f 6465 0a69 7320 7265 error code.is re │ │ │ -00062f50: 706f 7274 6564 2076 6961 2065 7272 6e6f ported via errno │ │ │ -00062f60: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -00062f70: 656e 756d 5f6e 6574 2e63 7070 3a32 3734 enum_net.cpp:274 │ │ │ -00062f80: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    #
    │ │ │ -00062fc0: 6966 2054 4f52 5245 4e54 5f55 5345 5f4e  if TORRENT_USE_N
    │ │ │ -00062fd0: 4554 4c49 4e4b 0a0a 0969 6e74 2072 6561  ETLINK...int rea
    │ │ │ -00062fe0: 645f 6e6c 5f73 6f63 6b28 696e 7420 736f  d_nl_sock(int so
    │ │ │ -00062ff0: 636b 2c20 7374 643a 3a75 696e 7433 325f  ck, std::uint32_
    │ │ │ -00063000: 7420 636f 6e73 7420 7365 712c 2073 7464  t const seq, std
    │ │ │ -00063010: 3a3a 7569 6e74 3332 5f74 2063 6f6e 7374  ::uint32_t const
    │ │ │ -00063020: 2070 6964 0a09 092c 2073 7464 3a3a 6675   pid..., std::fu
    │ │ │ -00063030: 6e63 7469 6f6e 266c 743b 766f 6964 286e  nction<void(n
    │ │ │ -00063040: 6c6d 7367 6864 7220 636f 6e73 742a 2926  lmsghdr const*)&
    │ │ │ -00063050: 6774 3b20 6f6e 5f6d 7367 290a 097b 0a09  gt; on_msg)..{..
    │ │ │ -00063060: 0973 7464 3a3a 6172 7261 7926 6c74 3b63  .std::array<c
    │ │ │ -00063070: 6861 722c 2034 3039 3626 6774 3b20 6275  har, 4096> bu
    │ │ │ -00063080: 663b 0a09 0966 6f72 2028 3b3b 290a 0909  f;...for (;;)...
    │ │ │ -00063090: 7b0a 0909 0969 6e74 2063 6f6e 7374 2072  {....int const r
    │ │ │ -000630a0: 6561 645f 6c65 6e20 3d20 696e 7428 7265  ead_len = int(re
    │ │ │ -000630b0: 6376 2873 6f63 6b2c 2062 7566 2e64 6174  cv(sock, buf.dat
    │ │ │ -000630c0: 6128 292c 2062 7566 2e73 697a 6528 292c  a(), buf.size(),
    │ │ │ -000630d0: 2030 2929 3b0a 0909 0969 6620 2872 6561   0));....if (rea
    │ │ │ -000630e0: 645f 6c65 6e20 266c 743b 2030 2920 7265  d_len < 0) re
    │ │ │ -000630f0: 7475 726e 202d 313b 0a0a 0909 0961 7574  turn -1;.....aut
    │ │ │ -00063100: 6f20 636f 6e73 742a 206e 6c5f 6864 7220  o const* nl_hdr 
    │ │ │ -00063110: 3d20 7265 696e 7465 7270 7265 745f 6361  = reinterpret_ca
    │ │ │ -00063120: 7374 266c 743b 6e6c 6d73 6768 6472 2063  st<nlmsghdr c
    │ │ │ -00063130: 6f6e 7374 2a26 6774 3b28 6275 662e 6461  onst*>(buf.da
    │ │ │ -00063140: 7461 2829 293b 0a09 0909 696e 7420 6c65  ta());....int le
    │ │ │ -00063150: 6e20 3d20 7265 6164 5f6c 656e 3b0a 0a09  n = read_len;...
    │ │ │ -00063160: 0909 666f 7220 283b 206c 656e 2026 6774  ..for (; len >
    │ │ │ -00063170: 3b20 3020 2661 6d70 3b26 616d 703b 2061  ; 0 && a
    │ │ │ -00063180: 7578 3a3a 6e6c 6d73 675f 6f6b 286e 6c5f  ux::nlmsg_ok(nl_
    │ │ │ -00063190: 6864 722c 206c 656e 293b 206e 6c5f 6864  hdr, len); nl_hd
    │ │ │ -000631a0: 7220 3d20 6175 783a 3a6e 6c6d 7367 5f6e  r = aux::nlmsg_n
    │ │ │ -000631b0: 6578 7428 6e6c 5f68 6472 2c20 6c65 6e29  ext(nl_hdr, len)
    │ │ │ -000631c0: 290a 0909 097b 0a09 0909 0969 6620 2828  )....{.....if ((
    │ │ │ -000631d0: 6175 783a 3a6e 6c6d 7367 5f6f 6b28 6e6c  aux::nlmsg_ok(nl
    │ │ │ -000631e0: 5f68 6472 2c20 7265 6164 5f6c 656e 2920  _hdr, read_len) 
    │ │ │ -000631f0: 3d3d 2030 2920 7c7c 2028 6e6c 5f68 6472  == 0) || (nl_hdr
    │ │ │ -00063200: 2d26 6774 3b6e 6c6d 7367 5f74 7970 6520  ->nlmsg_type 
    │ │ │ -00063210: 3d3d 204e 4c4d 5347 5f45 5252 4f52 2929  == NLMSG_ERROR))
    │ │ │ -00063220: 0a09 0909 0909 7265 7475 726e 202d 313b  ......return -1;
    │ │ │ -00063230: 0a09 0909 092f 2f20 7468 6973 2066 756e  .....// this fun
    │ │ │ -00063240: 6374 696f 6e20 646f 6573 6e27 7420 6861  ction doesn't ha
    │ │ │ -00063250: 6e64 6c65 206d 756c 7469 706c 6520 7265  ndle multiple re
    │ │ │ -00063260: 7175 6573 7473 2061 7420 7468 6520 7361  quests at the sa
    │ │ │ -00063270: 6d65 2074 696d 650a 0909 0909 2f2f 2073  me time.....// s
    │ │ │ -00063280: 6f20 7265 706f 7274 2061 6e20 6572 726f  o report an erro
    │ │ │ -00063290: 7220 6966 2074 6865 206d 6573 7361 6765  r if the message
    │ │ │ -000632a0: 2064 6f65 7320 6e6f 7420 6861 7665 2074   does not have t
    │ │ │ -000632b0: 6865 2065 7870 6563 7465 6420 7365 7120  he expected seq 
    │ │ │ -000632c0: 616e 6420 7069 640a 3c64 6976 2073 7479  and pid.
    ....if (nl │ │ │ -00063300: 5f68 6472 2d26 6774 3b6e 6c6d 7367 5f73 _hdr->nlmsg_s │ │ │ -00063310: 6571 2021 3d20 7365 7120 7c7c 206e 6c5f eq != seq || nl_ │ │ │ -00063320: 6864 722d 2667 743b 6e6c 6d73 675f 7069 hdr->nlmsg_pi │ │ │ -00063330: 6420 213d 2070 6964 290a 3c2f 6469 763e d != pid).
    │ │ │ -00063340: 0909 0909 0972 6574 7572 6e20 2d31 3b0a .....return -1;. │ │ │ -00063350: 0a09 0909 0969 6620 286e 6c5f 6864 722d .....if (nl_hdr- │ │ │ -00063360: 2667 743b 6e6c 6d73 675f 7479 7065 203d >nlmsg_type = │ │ │ -00063370: 3d20 4e4c 4d53 475f 444f 4e45 2920 7265 = NLMSG_DONE) re │ │ │ -00063380: 7475 726e 2030 3b0a 0a09 0909 096f 6e5f turn 0;......on_ │ │ │ -00063390: 6d73 6728 6e6c 5f68 6472 293b 0a0a 0909 msg(nl_hdr);.... │ │ │ -000633a0: 0909 6966 2028 286e 6c5f 6864 722d 2667 ..if ((nl_hdr-&g │ │ │ -000633b0: 743b 6e6c 6d73 675f 666c 6167 7320 2661 t;nlmsg_flags &a │ │ │ -000633c0: 6d70 3b20 4e4c 4d5f 465f 4d55 4c54 4929 mp; NLM_F_MULTI) │ │ │ -000633d0: 203d 3d20 3029 2072 6574 7572 6e20 303b == 0) return 0; │ │ │ -000633e0: 0a09 0909 7d0a 0909 7d0a 2f2f 0909 7265 ....}...}.//..re │ │ │ -000633f0: 7475 726e 2030 3b0a 097d 0a0a 0969 6e74 turn 0;..}...int │ │ │ -00063400: 206e 6c5f 6475 6d70 5f72 6571 7565 7374 nl_dump_request │ │ │ -00063410: 2869 6e74 2063 6f6e 7374 2073 6f63 6b2c (int const sock, │ │ │ -00063420: 2073 7464 3a3a 7569 6e74 3332 5f74 2063 std::uint32_t c │ │ │ -00063430: 6f6e 7374 2073 6571 0a09 092c 206e 6c6d onst seq..., nlm │ │ │ -00063440: 7367 6864 722a 2063 6f6e 7374 2072 6571 sghdr* const req │ │ │ -00063450: 7565 7374 5f6d 7367 2c20 7374 643a 3a66 uest_msg, std::f │ │ │ -00063460: 756e 6374 696f 6e26 6c74 3b76 6f69 6428 unction<void( │ │ │ -00063470: 6e6c 6d73 6768 6472 2063 6f6e 7374 2a29 nlmsghdr const*) │ │ │ -00063480: 2667 743b 206f 6e5f 6d73 6729 0a09 7b0a > on_msg)..{. │ │ │ -00063490: 0909 7265 7175 6573 745f 6d73 672d 2667 ..request_msg-&g │ │ │ -000634a0: 743b 6e6c 6d73 675f 666c 6167 7320 3d20 t;nlmsg_flags = │ │ │ -000634b0: 4e4c 4d5f 465f 4455 4d50 207c 204e 4c4d NLM_F_DUMP | NLM │ │ │ -000634c0: 5f46 5f52 4551 5545 5354 3b0a 0909 7265 _F_REQUEST;...re │ │ │ -000634d0: 7175 6573 745f 6d73 672d 2667 743b 6e6c quest_msg->nl │ │ │ -000634e0: 6d73 675f 7365 7120 3d20 7365 713b 0a09 msg_seq = seq;.. │ │ │ -000634f0: 092f 2f20 696e 2074 6865 6f72 7920 6e6c .// in theory nl │ │ │ -00063500: 6d73 675f 7069 6420 7368 6f75 6c64 2062 msg_pid should b │ │ │ -00063510: 6520 7365 7420 746f 2074 6865 206e 6574 e set to the net │ │ │ -00063520: 6c69 6e6b 2070 6f72 7420 4944 2028 4e4f link port ID (NO │ │ │ -00063530: 5420 7468 6520 7072 6f63 6573 7320 4944 T the process ID │ │ │ -00063540: 290a 0909 2f2f 206f 6620 7468 6520 7365 )...// of the se │ │ │ -00063550: 6e64 6572 2c20 6275 7420 7468 6520 6b65 nder, but the ke │ │ │ -00063560: 726e 656c 2069 676e 6f72 6573 2074 6869 rnel ignores thi │ │ │ -00063570: 7320 6669 656c 6420 736f 2069 7420 6973 s field so it is │ │ │ -00063580: 2074 7970 6963 616c 6c79 2073 6574 2074 typically set t │ │ │ -00063590: 6f0a 0909 2f2f 207a 6572 6f0a 0909 7265 o...// zero...re │ │ │ -000635a0: 7175 6573 745f 6d73 672d 2667 743b 6e6c quest_msg->nl │ │ │ -000635b0: 6d73 675f 7069 6420 3d20 303b 0a0a 0909 msg_pid = 0;.... │ │ │ -000635c0: 6966 2028 3a3a 7365 6e64 2873 6f63 6b2c if (::send(sock, │ │ │ -000635d0: 2072 6571 7565 7374 5f6d 7367 2c20 7265 request_msg, re │ │ │ -000635e0: 7175 6573 745f 6d73 672d 2667 743b 6e6c quest_msg->nl │ │ │ -000635f0: 6d73 675f 6c65 6e2c 2030 2920 266c 743b msg_len, 0) < │ │ │ -00063600: 2030 290a 0909 0972 6574 7572 6e20 2d31 0)....return -1 │ │ │ -00063610: 3b0a 0a09 092f 2f20 6765 7420 7468 6520 ;....// get the │ │ │ -00063620: 736f 636b 6574 2773 2070 6f72 7420 4944 socket's port ID │ │ │ -00063630: 2073 6f20 7468 6174 2077 6520 6361 6e20 so that we can │ │ │ -00063640: 7665 7269 6679 2069 7420 696e 2074 6865 verify it in the │ │ │ -00063650: 2072 6573 706f 6e73 650a 0909 736f 636b response...sock │ │ │ -00063660: 6164 6472 5f6e 6c20 736f 636b 5f61 6464 addr_nl sock_add │ │ │ -00063670: 723b 0a09 0973 6f63 6b6c 656e 5f74 2073 r;...socklen_t s │ │ │ -00063680: 6f63 6b5f 6164 6472 5f6c 656e 203d 2073 ock_addr_len = s │ │ │ -00063690: 697a 656f 6628 736f 636b 5f61 6464 7229 izeof(sock_addr) │ │ │ -000636a0: 3b0a 0909 6966 2028 3a3a 6765 7473 6f63 ;...if (::getsoc │ │ │ -000636b0: 6b6e 616d 6528 736f 636b 2c20 7265 696e kname(sock, rein │ │ │ -000636c0: 7465 7270 7265 745f 6361 7374 266c 743b terpret_cast< │ │ │ -000636d0: 736f 636b 6164 6472 2a26 6774 3b28 2661 sockaddr*>(&a │ │ │ -000636e0: 6d70 3b73 6f63 6b5f 6164 6472 292c 2026 mp;sock_addr), & │ │ │ -000636f0: 616d 703b 736f 636b 5f61 6464 725f 6c65 amp;sock_addr_le │ │ │ -00063700: 6e29 2026 6c74 3b20 3029 0a09 0909 7265 n) < 0)....re │ │ │ -00063710: 7475 726e 202d 313b 0a3c 2f70 7265 3e3c turn -1;.
    < │ │ │ -00063720: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00063750: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00063760: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/disab │ │ │ -00063790: 6c65 645f 6469 736b 5f69 6f2e 6370 703a led_disk_io.cpp: │ │ │ -000637a0: 3130 363c 2f61 3e3c 2f74 643e 3c74 643e 106 │ │ │ -000637b0: 6974 2077 6f75 6c64 2062 6520 6e69 6365 it would be nice │ │ │ -000637c0: 2074 6f20 7265 7475 726e 2061 2076 616c to return a val │ │ │ -000637d0: 6964 2068 6173 6820 6f66 207a 6572 6f65 id hash of zeroe │ │ │ -000637e0: 7320 6865 7265 3c2f 7464 3e3c 2f74 723e s here │ │ │ -000637f0: 3c74 7220 6964 3d22 3232 3822 2073 7479 │ │ │ -00063820: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -00063830: 3c68 323e 6974 2077 6f75 6c64 2062 6520

    it would be │ │ │ -00063840: 6e69 6365 2074 6f20 7265 7475 726e 2061 nice to return a │ │ │ -00063850: 2076 616c 6964 2068 6173 6820 6f66 207a valid hash of z │ │ │ -00063860: 6572 6f65 7320 6865 7265 3c2f 6832 3e3c eroes here

    < │ │ │ -00063870: 6834 3e2e 2e2f 7372 632f 6469 7361 626c h4>../src/disabl │ │ │ -00063880: 6564 5f64 6973 6b5f 696f 2e63 7070 3a31 ed_disk_io.cpp:1 │ │ │ -00063890: 3036 3c2f 6834 3e3c 7072 6520 7374 796c 06
    ..});..}...bool
    │ │ │ -000638e0: 2061 7379 6e63 5f77 7269 7465 2873 746f   async_write(sto
    │ │ │ -000638f0: 7261 6765 5f69 6e64 6578 5f74 0a09 092c  rage_index_t...,
    │ │ │ -00063900: 2070 6565 725f 7265 7175 6573 7420 636f   peer_request co
    │ │ │ -00063910: 6e73 7426 616d 703b 2072 0a09 092c 2063  nst& r..., c
    │ │ │ -00063920: 6861 7220 636f 6e73 742a 2c20 7374 643a  har const*, std:
    │ │ │ -00063930: 3a73 6861 7265 645f 7074 7226 6c74 3b64  :shared_ptr<d
    │ │ │ -00063940: 6973 6b5f 6f62 7365 7276 6572 2667 743b  isk_observer>
    │ │ │ -00063950: 0a09 092c 2073 7464 3a3a 6675 6e63 7469  ..., std::functi
    │ │ │ -00063960: 6f6e 266c 743b 766f 6964 2873 746f 7261  on<void(stora
    │ │ │ -00063970: 6765 5f65 7272 6f72 2063 6f6e 7374 2661  ge_error const&a
    │ │ │ -00063980: 6d70 3b29 2667 743b 2068 616e 646c 6572  mp;)> handler
    │ │ │ -00063990: 0a09 092c 2064 6973 6b5f 6a6f 625f 666c  ..., disk_job_fl
    │ │ │ -000639a0: 6167 735f 7429 206f 7665 7272 6964 650a  ags_t) override.
    │ │ │ -000639b0: 097b 0a09 0954 4f52 5245 4e54 5f41 5353  .{...TORRENT_ASS
    │ │ │ -000639c0: 4552 5428 722e 6c65 6e67 7468 2026 6c74  ERT(r.length <
    │ │ │ -000639d0: 3b3d 2064 6566 6175 6c74 5f62 6c6f 636b  ;= default_block
    │ │ │ -000639e0: 5f73 697a 6529 3b0a 0909 544f 5252 454e  _size);...TORREN
    │ │ │ -000639f0: 545f 554e 5553 4544 2872 293b 0a0a 0909  T_UNUSED(r);....
    │ │ │ -00063a00: 706f 7374 286d 5f69 6f73 2c20 5b68 203d  post(m_ios, [h =
    │ │ │ -00063a10: 2073 7464 3a3a 6d6f 7665 2868 616e 646c   std::move(handl
    │ │ │ -00063a20: 6572 295d 207b 2068 2873 746f 7261 6765  er)] { h(storage
    │ │ │ -00063a30: 5f65 7272 6f72 7b7d 293b 207d 293b 0a09  _error{}); });..
    │ │ │ -00063a40: 0972 6574 7572 6e20 6661 6c73 653b 0a09  .return false;..
    │ │ │ -00063a50: 7d0a 0a09 766f 6964 2061 7379 6e63 5f68  }...void async_h
    │ │ │ -00063a60: 6173 6828 7374 6f72 6167 655f 696e 6465  ash(storage_inde
    │ │ │ -00063a70: 785f 740a 0909 2c20 7069 6563 655f 696e  x_t..., piece_in
    │ │ │ -00063a80: 6465 785f 7420 7069 6563 652c 2073 7061  dex_t piece, spa
    │ │ │ -00063a90: 6e26 6c74 3b73 6861 3235 365f 6861 7368  n<sha256_hash
    │ │ │ -00063aa0: 2667 743b 2c20 6469 736b 5f6a 6f62 5f66  >, disk_job_f
    │ │ │ -00063ab0: 6c61 6773 5f74 0a09 092c 2073 7464 3a3a  lags_t..., std::
    │ │ │ -00063ac0: 6675 6e63 7469 6f6e 266c 743b 766f 6964  function<void
    │ │ │ -00063ad0: 2870 6965 6365 5f69 6e64 6578 5f74 2c20  (piece_index_t, 
    │ │ │ -00063ae0: 7368 6131 5f68 6173 6820 636f 6e73 7426  sha1_hash const&
    │ │ │ -00063af0: 616d 703b 2c20 7374 6f72 6167 655f 6572  amp;, storage_er
    │ │ │ -00063b00: 726f 7220 636f 6e73 7426 616d 703b 2926  ror const&)&
    │ │ │ -00063b10: 6774 3b20 6861 6e64 6c65 7229 206f 7665  gt; handler) ove
    │ │ │ -00063b20: 7272 6964 650a 097b 0a3c 6469 7620 7374  rride..{.
    ..post(m_ │ │ │ -00063b60: 696f 732c 205b 6820 3d20 7374 643a 3a6d ios, [h = std::m │ │ │ -00063b70: 6f76 6528 6861 6e64 6c65 7229 2c20 7069 ove(handler), pi │ │ │ -00063b80: 6563 655d 207b 2068 2870 6965 6365 2c20 ece] { h(piece, │ │ │ -00063b90: 7368 6131 5f68 6173 687b 7d2c 2073 746f sha1_hash{}, sto │ │ │ -00063ba0: 7261 6765 5f65 7272 6f72 7b7d 293b 207d rage_error{}); } │ │ │ -00063bb0: 293b 0a3c 2f64 6976 3e09 7d0a 0a09 766f );.
    .}...vo │ │ │ -00063bc0: 6964 2061 7379 6e63 5f68 6173 6832 2873 id async_hash2(s │ │ │ -00063bd0: 746f 7261 6765 5f69 6e64 6578 5f74 2c20 torage_index_t, │ │ │ -00063be0: 7069 6563 655f 696e 6465 785f 7420 7069 piece_index_t pi │ │ │ -00063bf0: 6563 652c 2069 6e74 0a09 092c 2064 6973 ece, int..., dis │ │ │ -00063c00: 6b5f 6a6f 625f 666c 6167 735f 740a 0909 k_job_flags_t... │ │ │ -00063c10: 2c20 7374 643a 3a66 756e 6374 696f 6e26 , std::function& │ │ │ -00063c20: 6c74 3b76 6f69 6428 7069 6563 655f 696e lt;void(piece_in │ │ │ -00063c30: 6465 785f 742c 2073 6861 3235 365f 6861 dex_t, sha256_ha │ │ │ -00063c40: 7368 2063 6f6e 7374 2661 6d70 3b2c 2073 sh const&, s │ │ │ -00063c50: 746f 7261 6765 5f65 7272 6f72 2063 6f6e torage_error con │ │ │ -00063c60: 7374 2661 6d70 3b29 2667 743b 2068 616e st&)> han │ │ │ -00063c70: 646c 6572 2920 6f76 6572 7269 6465 0a09 dler) override.. │ │ │ -00063c80: 7b0a 0909 706f 7374 286d 5f69 6f73 2c20 {...post(m_ios, │ │ │ -00063c90: 5b68 203d 2073 7464 3a3a 6d6f 7665 2868 [h = std::move(h │ │ │ -00063ca0: 616e 646c 6572 292c 2070 6965 6365 5d28 andler), piece]( │ │ │ -00063cb0: 2920 7b20 6828 7069 6563 652c 2073 6861 ) { h(piece, sha │ │ │ -00063cc0: 3235 365f 6861 7368 7b7d 2c20 7374 6f72 256_hash{}, stor │ │ │ -00063cd0: 6167 655f 6572 726f 727b 7d29 3b20 7d29 age_error{}); }) │ │ │ -00063ce0: 3b0a 097d 0a0a 0976 6f69 6420 6173 796e ;..}...void asyn │ │ │ -00063cf0: 635f 6d6f 7665 5f73 746f 7261 6765 2873 c_move_storage(s │ │ │ -00063d00: 746f 7261 6765 5f69 6e64 6578 5f74 0a09 torage_index_t.. │ │ │ -00063d10: 092c 2073 7464 3a3a 7374 7269 6e67 2070 ., std::string p │ │ │ -00063d20: 2c20 6d6f 7665 5f66 6c61 6773 5f74 0a09 , move_flags_t.. │ │ │ -00063d30: 092c 2073 7464 3a3a 6675 6e63 7469 6f6e ., std::function │ │ │ -00063d40: 266c 743b 766f 6964 2873 7461 7475 735f <void(status_ │ │ │ -00063d50: 742c 2073 7464 3a3a 7374 7269 6e67 2063 t, std::string c │ │ │ -00063d60: 6f6e 7374 2661 6d70 3b2c 2073 746f 7261 onst&, stora │ │ │ -00063d70: 6765 5f65 7272 6f72 2063 6f6e 7374 2661 ge_error const&a │ │ │ -00063d80: 6d70 3b29 2667 743b 2068 616e 646c 6572 mp;)> handler │ │ │ -00063d90: 2920 6f76 6572 7269 6465 0a09 7b0a 0909 ) override..{... │ │ │ -00063da0: 706f 7374 286d 5f69 6f73 2c20 5b68 203d post(m_ios, [h = │ │ │ -00063db0: 2073 7464 3a3a 6d6f 7665 2868 616e 646c std::move(handl │ │ │ -00063dc0: 6572 292c 2070 6174 6820 3d20 7374 643a er), path = std: │ │ │ -00063dd0: 3a6d 6f76 6528 7029 5d20 2829 206d 7574 :move(p)] () mut │ │ │ -00063de0: 6162 6c65 0a09 0909 7b20 6828 7374 6174 able....{ h(stat │ │ │ -00063df0: 7573 5f74 3a3a 6e6f 5f65 7272 6f72 2c20 us_t::no_error, │ │ │ -00063e00: 7374 643a 3a6d 6f76 6528 7061 7468 292c std::move(path), │ │ │ -00063e10: 2073 746f 7261 6765 5f65 7272 6f72 7b7d storage_error{} │ │ │ -00063e20: 293b 207d 293b 0a09 7d0a 0a09 766f 6964 ); });..}...void │ │ │ -00063e30: 2061 7379 6e63 5f72 656c 6561 7365 5f66 async_release_f │ │ │ -00063e40: 696c 6573 2873 746f 7261 6765 5f69 6e64 iles(storage_ind │ │ │ -00063e50: 6578 5f74 2c20 7374 643a 3a66 756e 6374 ex_t, std::funct │ │ │ -00063e60: 696f 6e26 6c74 3b76 6f69 6428 2926 6774 ion<void()> │ │ │ -00063e70: 3b20 6861 6e64 6c65 7229 206f 7665 7272 ; handler) overr │ │ │ -00063e80: 6964 650a 097b 0a09 0970 6f73 7428 6d5f ide..{...post(m_ │ │ │ -00063e90: 696f 732c 205b 6820 3d20 7374 643a 3a6d ios, [h = std::m │ │ │ -00063ea0: 6f76 6528 6861 6e64 6c65 7229 5d20 7b20 ove(handler)] { │ │ │ -00063eb0: 6828 293b 207d 293b 0a09 7d0a 0a09 766f h(); });..}...vo │ │ │ -00063ec0: 6964 2061 7379 6e63 5f64 656c 6574 655f id async_delete_ │ │ │ -00063ed0: 6669 6c65 7328 7374 6f72 6167 655f 696e files(storage_in │ │ │ -00063ee0: 6465 785f 740a 0909 2c20 7265 6d6f 7665 dex_t..., remove │ │ │ -00063ef0: 5f66 6c61 6773 5f74 2c20 7374 643a 3a66 _flags_t, std::f │ │ │ -00063f00: 756e 6374 696f 6e26 6c74 3b76 6f69 6428 unction<void( │ │ │ -00063f10: 7374 6f72 6167 655f 6572 726f 7220 636f storage_error co │ │ │ -00063f20: 6e73 7426 616d 703b 2926 6774 3b20 6861 nst&)> ha │ │ │ -00063f30: 6e64 6c65 7229 206f 7665 7272 6964 650a ndler) override. │ │ │ -00063f40: 097b 0a09 0970 6f73 7428 6d5f 696f 732c .{...post(m_ios, │ │ │ -00063f50: 205b 6820 3d20 7374 643a 3a6d 6f76 6528 [h = std::move( │ │ │ -00063f60: 6861 6e64 6c65 7229 5d20 7b20 6828 7374 handler)] { h(st │ │ │ -00063f70: 6f72 6167 655f 6572 726f 727b 7d29 3b20 orage_error{}); │ │ │ -00063f80: 7d29 3b0a 097d 0a0a 0976 6f69 6420 6173 });..}...void as │ │ │ -00063f90: 796e 635f 6368 6563 6b5f 6669 6c65 7328 ync_check_files( │ │ │ -00063fa0: 7374 6f72 6167 655f 696e 6465 785f 740a storage_index_t. │ │ │ -00063fb0: 0909 2c20 6164 645f 746f 7272 656e 745f .., add_torrent_ │ │ │ -00063fc0: 7061 7261 6d73 2063 6f6e 7374 2a0a 3c2f params const*.r │ │ │ -00064000: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -00064010: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -00064040: 6372 6561 7465 5f74 6f72 7265 6e74 2e63 create_torrent.c │ │ │ -00064050: 7070 3a36 3435 3c2f 613e 3c2f 7464 3e3c pp:645< │ │ │ -00064060: 7464 3e74 6869 7320 6361 6e20 6265 206f td>this can be o │ │ │ -00064070: 7074 696d 697a 6564 3c2f 7464 3e3c 2f74 ptimized

    this can b │ │ │ -000640d0: 6520 6f70 7469 6d69 7a65 643c 2f68 323e e optimized

    │ │ │ -000640e0: 3c68 343e 2e2e 2f73 7263 2f63 7265 6174

    ../src/creat │ │ │ -000640f0: 655f 746f 7272 656e 742e 6370 703a 3634 e_torrent.cpp:64 │ │ │ -00064100: 353c 2f68 343e 3c70 7265 2073 7479 6c65 5

    │ │ │ -00064140: 0909 7374 643a 3a73 7472 696e 6726 616d  ..std::string&am
    │ │ │ -00064150: 703b 2061 7474 7220 3d20 655b 2261 7474  p; attr = e["att
    │ │ │ -00064160: 7222 5d2e 7374 7269 6e67 2829 3b0a 0909  r"].string();...
    │ │ │ -00064170: 6966 2028 666c 6167 7320 2661 6d70 3b20  if (flags & 
    │ │ │ -00064180: 6669 6c65 5f73 746f 7261 6765 3a3a 666c  file_storage::fl
    │ │ │ -00064190: 6167 5f70 6164 5f66 696c 6529 2061 7474  ag_pad_file) att
    │ │ │ -000641a0: 7220 2b3d 2027 7027 3b0a 0909 6966 2028  r += 'p';...if (
    │ │ │ -000641b0: 666c 6167 7320 2661 6d70 3b20 6669 6c65  flags & file
    │ │ │ -000641c0: 5f73 746f 7261 6765 3a3a 666c 6167 5f68  _storage::flag_h
    │ │ │ -000641d0: 6964 6465 6e29 2061 7474 7220 2b3d 2027  idden) attr += '
    │ │ │ -000641e0: 6827 3b0a 0909 6966 2028 666c 6167 7320  h';...if (flags 
    │ │ │ -000641f0: 2661 6d70 3b20 6669 6c65 5f73 746f 7261  & file_stora
    │ │ │ -00064200: 6765 3a3a 666c 6167 5f65 7865 6375 7461  ge::flag_executa
    │ │ │ -00064210: 626c 6529 2061 7474 7220 2b3d 2027 7827  ble) attr += 'x'
    │ │ │ -00064220: 3b0a 0909 6966 2028 696e 636c 7564 655f  ;...if (include_
    │ │ │ -00064230: 7379 6d6c 696e 6b73 2026 616d 703b 2661  symlinks &&a
    │ │ │ -00064240: 6d70 3b20 2866 6c61 6773 2026 616d 703b  mp; (flags &
    │ │ │ -00064250: 2066 696c 655f 7374 6f72 6167 653a 3a66   file_storage::f
    │ │ │ -00064260: 6c61 675f 7379 6d6c 696e 6b29 2920 6174  lag_symlink)) at
    │ │ │ -00064270: 7472 202b 3d20 276c 273b 0a09 7d0a 0a09  tr += 'l';..}...
    │ │ │ -00064280: 766f 6964 2061 6464 5f73 796d 6c69 6e6b  void add_symlink
    │ │ │ -00064290: 5f70 6174 6828 656e 7472 7926 616d 703b  _path(entry&
    │ │ │ -000642a0: 2065 2c20 7374 643a 3a73 7472 696e 6720   e, std::string 
    │ │ │ -000642b0: 7379 6d6c 696e 6b5f 7061 7468 290a 097b  symlink_path)..{
    │ │ │ -000642c0: 0a09 0965 6e74 7279 2661 6d70 3b20 7379  ...entry& sy
    │ │ │ -000642d0: 6d70 6174 685f 6520 3d20 655b 2273 796d  mpath_e = e["sym
    │ │ │ -000642e0: 6c69 6e6b 2070 6174 6822 5d3b 0a0a 0909  link path"];....
    │ │ │ -000642f0: 7374 643a 3a73 7472 696e 6720 636f 6e73  std::string cons
    │ │ │ -00064300: 7420 6c69 6e6b 203d 206c 6578 6963 616c  t link = lexical
    │ │ │ -00064310: 6c79 5f72 656c 6174 6976 6528 2222 2c20  ly_relative("", 
    │ │ │ -00064320: 7379 6d6c 696e 6b5f 7061 7468 293b 0a09  symlink_path);..
    │ │ │ -00064330: 0966 6f72 2028 6175 746f 2065 6c65 6d73  .for (auto elems
    │ │ │ -00064340: 203d 206c 7370 6c69 745f 7061 7468 286c   = lsplit_path(l
    │ │ │ -00064350: 696e 6b29 3b20 2165 6c65 6d73 2e66 6972  ink); !elems.fir
    │ │ │ -00064360: 7374 2e65 6d70 7479 2829 3b0a 0909 0965  st.empty();....e
    │ │ │ -00064370: 6c65 6d73 203d 206c 7370 6c69 745f 7061  lems = lsplit_pa
    │ │ │ -00064380: 7468 2865 6c65 6d73 2e73 6563 6f6e 6429  th(elems.second)
    │ │ │ -00064390: 290a 0909 0973 796d 7061 7468 5f65 2e6c  )....sympath_e.l
    │ │ │ -000643a0: 6973 7428 292e 656d 706c 6163 655f 6261  ist().emplace_ba
    │ │ │ -000643b0: 636b 2865 6c65 6d73 2e66 6972 7374 293b  ck(elems.first);
    │ │ │ -000643c0: 0a09 7d0a 7d0a 0a09 7374 643a 3a76 6563  ..}.}...std::vec
    │ │ │ -000643d0: 746f 7226 6c74 3b63 6861 7226 6774 3b20  tor<char> 
    │ │ │ -000643e0: 6372 6561 7465 5f74 6f72 7265 6e74 3a3a  create_torrent::
    │ │ │ -000643f0: 6765 6e65 7261 7465 5f62 7566 2829 2063  generate_buf() c
    │ │ │ -00064400: 6f6e 7374 0a09 7b0a 3c64 6976 2073 7479  onst..{.
    ..std::vec │ │ │ -00064440: 746f 7226 6c74 3b63 6861 7226 6774 3b20 tor<char> │ │ │ -00064450: 7265 743b 0a3c 2f64 6976 3e09 0962 656e ret;.
    ..ben │ │ │ -00064460: 636f 6465 2873 7464 3a3a 6261 636b 5f69 code(std::back_i │ │ │ -00064470: 6e73 6572 7465 7228 7265 7429 2c20 6765 nserter(ret), ge │ │ │ -00064480: 6e65 7261 7465 2829 293b 0a09 0972 6574 nerate());...ret │ │ │ -00064490: 7572 6e20 7265 743b 0a09 7d0a 0a09 656e urn ret;..}...en │ │ │ -000644a0: 7472 7920 6372 6561 7465 5f74 6f72 7265 try create_torre │ │ │ -000644b0: 6e74 3a3a 6765 6e65 7261 7465 2829 2063 nt::generate() c │ │ │ -000644c0: 6f6e 7374 0a09 7b0a 0909 6966 2028 6d5f onst..{...if (m_ │ │ │ -000644d0: 6669 6c65 732e 6e75 6d5f 6669 6c65 7328 files.num_files( │ │ │ -000644e0: 2920 3d3d 2030 207c 7c20 6d5f 6669 6c65 ) == 0 || m_file │ │ │ -000644f0: 732e 746f 7461 6c5f 7369 7a65 2829 203d s.total_size() = │ │ │ -00064500: 3d20 3029 0a09 0909 6175 783a 3a74 6872 = 0)....aux::thr │ │ │ -00064510: 6f77 5f65 7826 6c74 3b73 7973 7465 6d5f ow_ex<system_ │ │ │ -00064520: 6572 726f 7226 6774 3b28 6572 726f 7273 error>(errors │ │ │ -00064530: 3a3a 746f 7272 656e 745f 6d69 7373 696e ::torrent_missin │ │ │ -00064540: 675f 6669 6c65 5f74 7265 6529 3b0a 0a09 g_file_tree);... │ │ │ -00064550: 092f 2f20 6966 2061 6c6c 2076 3220 6861 .// if all v2 ha │ │ │ -00064560: 7368 6573 2061 7265 2073 6574 2063 6f72 shes are set cor │ │ │ -00064570: 7265 6374 6c79 2c20 6765 6e65 7261 7465 rectly, generate │ │ │ -00064580: 2074 6865 2076 3220 7061 7274 7320 6f66 the v2 parts of │ │ │ -00064590: 2074 6865 0a09 092f 2f20 746f 7272 656e the...// torren │ │ │ -000645a0: 740a 0909 626f 6f6c 2063 6f6e 7374 206d t...bool const m │ │ │ -000645b0: 616b 655f 7632 203d 2076 616c 6964 6174 ake_v2 = validat │ │ │ -000645c0: 655f 7632 5f68 6173 6865 7328 6d5f 6669 e_v2_hashes(m_fi │ │ │ -000645d0: 6c65 732c 206d 5f66 696c 655f 7069 6563 les, m_file_piec │ │ │ -000645e0: 655f 6861 7368 293b 0a09 0962 6f6f 6c20 e_hash);...bool │ │ │ -000645f0: 636f 6e73 7420 6d61 6b65 5f76 3120 3d20 const make_v1 = │ │ │ -00064600: 7661 6c69 6461 7465 5f76 315f 6861 7368 validate_v1_hash │ │ │ -00064610: 6573 286d 5f66 696c 6573 2c20 6d5f 7069 es(m_files, m_pi │ │ │ -00064620: 6563 655f 6861 7368 293b 0a0a 0909 2f2f ece_hash);....// │ │ │ -00064630: 2069 6620 6e65 6974 6865 7220 7631 206e if neither v1 n │ │ │ -00064640: 6f72 2076 3220 6861 7368 6573 2077 6572 or v2 hashes wer │ │ │ -00064650: 6520 7365 742c 2077 6520 6361 6e27 7420 e set, we can't │ │ │ -00064660: 6372 6561 7465 2061 2074 6f72 7265 6e74 create a torrent │ │ │ -00064670: 0a09 0969 6620 2821 6d61 6b65 5f76 3120 ...if (!make_v1 │ │ │ -00064680: 2661 6d70 3b26 616d 703b 2021 6d61 6b65 && !make │ │ │ -00064690: 5f76 3229 0a09 0909 6175 783a 3a74 6872 _v2)....aux::thr │ │ │ -000646a0: 6f77 5f65 7826 6c74 3b73 7973 7465 6d5f ow_ex<system_ │ │ │ -000646b0: 6572 726f 7226 6774 3b28 6572 726f 7273 error>(errors │ │ │ -000646c0: 3a3a 696e 7661 6c69 645f 6861 7368 5f65 ::invalid_hash_e │ │ │ -000646d0: 6e74 7279 293b 0a0a 0909 544f 5252 454e ntry);....TORREN │ │ │ -000646e0: 545f 4153 5345 5254 286d 5f66 696c 6573 T_ASSERT(m_files │ │ │ -000646f0: 2e70 6965 6365 5f6c 656e 6774 6828 2920 .piece_length() │ │ │ -00064700: 2667 743b 2030 293b 0a0a 0909 656e 7472 > 0);....entr │ │ │ -00064710: 7920 6469 6374 3b0a 0a09 0969 6620 2821 y dict;....if (! │ │ │ -00064720: 6d5f 7572 6c73 2e65 6d70 7479 2829 2920 m_urls.empty()) │ │ │ -00064730: 6469 6374 5b22 616e 6e6f 756e 6365 225d dict["announce"] │ │ │ -00064740: 203d 206d 5f75 726c 732e 6672 6f6e 7428 = m_urls.front( │ │ │ -00064750: 292e 6669 7273 743b 0a0a 0909 6966 2028 ).first;....if ( │ │ │ -00064760: 216d 5f6e 6f64 6573 2e65 6d70 7479 2829 !m_nodes.empty() │ │ │ -00064770: 290a 0909 7b0a 0909 0965 6e74 7279 2661 )...{....entry&a │ │ │ -00064780: 6d70 3b20 6e6f 6465 7320 3d20 6469 6374 mp; nodes = dict │ │ │ -00064790: 5b22 6e6f 6465 7322 5d3b 0a09 0909 656e ["nodes"];....en │ │ │ -000647a0: 7472 793a 3a6c 6973 745f 7479 7065 2661 try::list_type&a │ │ │ -000647b0: 6d70 3b20 6e6f 6465 735f 6c69 7374 203d mp; nodes_list = │ │ │ -000647c0: 206e 6f64 6573 2e6c 6973 7428 293b 0a09 nodes.list();.. │ │ │ -000647d0: 0909 666f 7220 2861 7574 6f20 636f 6e73 ..for (auto cons │ │ │ -000647e0: 7426 616d 703b 206e 203a 206d 5f6e 6f64 t& n : m_nod │ │ │ -000647f0: 6573 290a 0909 097b 0a3c 2f70 7265 3e3c es)....{.
    < │ │ │ -00064800: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00064830: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00064840: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/cpuid │ │ │ -00064870: 2e63 7070 3a31 3331 3c2f 613e 3c2f 7464 .cpp:131enable when │ │ │ -00064890: 2061 6172 6368 3634 2069 7320 7265 616c aarch64 is real │ │ │ -000648a0: 6c79 2074 6573 7465 643c 2f74 643e 3c2f ly tested

    enable wh │ │ │ -00064900: 656e 2061 6172 6368 3634 2069 7320 7265 en aarch64 is re │ │ │ -00064910: 616c 6c79 2074 6573 7465 643c 2f68 323e ally tested

    │ │ │ -00064920: 3c68 343e 2e2e 2f73 7263 2f63 7075 6964

    ../src/cpuid │ │ │ -00064930: 2e63 7070 3a31 3331 3c2f 6834 3e3c 7072 .cpp:131

    .bool sup │ │ │ -00064980: 706f 7274 735f 6d6d 7828 2920 6e6f 6578 ports_mmx() noex │ │ │ -00064990: 6365 7074 0a09 7b0a 2369 6620 544f 5252 cept..{.#if TORR │ │ │ -000649a0: 454e 545f 4841 535f 5353 450a 0909 7374 ENT_HAS_SSE...st │ │ │ -000649b0: 643a 3a75 696e 7433 325f 7420 6370 7569 d::uint32_t cpui │ │ │ -000649c0: 5b34 5d20 3d20 7b30 7d3b 0a09 0963 7075 [4] = {0};...cpu │ │ │ -000649d0: 6964 2863 7075 692c 2031 293b 0a09 0972 id(cpui, 1);...r │ │ │ -000649e0: 6574 7572 6e20 2863 7075 695b 325d 2026 eturn (cpui[2] & │ │ │ -000649f0: 616d 703b 2028 3120 266c 743b 266c 743b amp; (1 << │ │ │ -00064a00: 2032 3329 2920 213d 2030 3b0a 2365 6c73 23)) != 0;.#els │ │ │ -00064a10: 650a 0909 7265 7475 726e 2066 616c 7365 e...return false │ │ │ -00064a20: 3b0a 2365 6e64 6966 0a09 7d0a 0a09 626f ;.#endif..}...bo │ │ │ -00064a30: 6f6c 2073 7570 706f 7274 735f 6172 6d5f ol supports_arm_ │ │ │ -00064a40: 6e65 6f6e 2829 206e 6f65 7863 6570 740a neon() noexcept. │ │ │ -00064a50: 097b 0a23 6966 2054 4f52 5245 4e54 5f48 .{.#if TORRENT_H │ │ │ -00064a60: 4153 5f41 524d 5f4e 454f 4e20 2661 6d70 AS_ARM_NEON & │ │ │ -00064a70: 3b26 616d 703b 2054 4f52 5245 4e54 5f48 ;& TORRENT_H │ │ │ -00064a80: 4153 5f41 5558 560a 2369 6620 6465 6669 AS_AUXV.#if defi │ │ │ -00064a90: 6e65 6420 5f5f 6172 6d5f 5f0a 0909 2f2f ned __arm__...// │ │ │ -00064aa0: 7265 7475 726e 2028 6765 7461 7578 7661 return (getauxva │ │ │ -00064ab0: 6c28 4154 5f48 5743 4150 2920 2661 6d70 l(AT_HWCAP) & │ │ │ -00064ac0: 3b20 4857 4341 505f 4e45 4f4e 293b 0a09 ; HWCAP_NEON);.. │ │ │ -00064ad0: 0972 6574 7572 6e20 2868 656c 7065 725f .return (helper_ │ │ │ -00064ae0: 6765 7461 7578 7661 6c28 3136 2920 2661 getauxval(16) &a │ │ │ -00064af0: 6d70 3b20 2831 2026 6c74 3b26 6c74 3b20 mp; (1 << │ │ │ -00064b00: 3132 2929 3b0a 2365 6c69 6620 6465 6669 12));.#elif defi │ │ │ -00064b10: 6e65 6420 5f5f 6161 7263 6836 345f 5f0a ned __aarch64__. │ │ │ -00064b20: 0909 2f2f 7265 7475 726e 2028 6765 7461 ..//return (geta │ │ │ -00064b30: 7578 7661 6c28 4154 5f48 5743 4150 2920 uxval(AT_HWCAP) │ │ │ -00064b40: 2661 6d70 3b20 4857 4341 505f 4153 494d & HWCAP_ASIM │ │ │ -00064b50: 4429 3b0a 0909 2f2f 7265 7475 726e 2028 D);...//return ( │ │ │ -00064b60: 6765 7461 7578 7661 6c28 3136 2920 2661 getauxval(16) &a │ │ │ -00064b70: 6d70 3b20 2831 2026 6c74 3b26 6c74 3b20 mp; (1 << │ │ │ -00064b80: 3129 293b 0a3c 6469 7620 7374 796c 653d 1));.
    ..return fals │ │ │ -00064bc0: 653b 0a3c 2f64 6976 3e23 656e 6469 660a e;.
    #endif. │ │ │ -00064bd0: 2365 6c73 650a 0909 7265 7475 726e 2066 #else...return f │ │ │ -00064be0: 616c 7365 3b0a 2365 6e64 6966 0a09 7d0a alse;.#endif..}. │ │ │ -00064bf0: 0a09 626f 6f6c 2073 7570 706f 7274 735f ..bool supports_ │ │ │ -00064c00: 6172 6d5f 6372 6333 3263 2829 206e 6f65 arm_crc32c() noe │ │ │ -00064c10: 7863 6570 740a 097b 0a23 6966 2054 4f52 xcept..{.#if TOR │ │ │ -00064c20: 5245 4e54 5f48 4153 5f41 524d 5f43 5243 RENT_HAS_ARM_CRC │ │ │ -00064c30: 3332 2026 616d 703b 2661 6d70 3b20 544f 32 && TO │ │ │ -00064c40: 5252 454e 545f 4841 535f 4155 5856 0a23 RRENT_HAS_AUXV.# │ │ │ -00064c50: 6966 2064 6566 696e 6564 2054 4f52 5245 if defined TORRE │ │ │ -00064c60: 4e54 5f46 4f52 4345 5f41 524d 5f43 5243 NT_FORCE_ARM_CRC │ │ │ -00064c70: 3332 0a09 0972 6574 7572 6e20 7472 7565 32...return true │ │ │ -00064c80: 3b0a 2365 6c69 6620 6465 6669 6e65 6420 ;.#elif defined │ │ │ -00064c90: 5f5f 6172 6d5f 5f0a 0909 2f2f 7265 7475 __arm__...//retu │ │ │ -00064ca0: 726e 2028 6765 7461 7578 7661 6c28 4154 rn (getauxval(AT │ │ │ -00064cb0: 5f48 5743 4150 3229 2026 616d 703b 2048 _HWCAP2) & H │ │ │ -00064cc0: 5743 4150 325f 4352 4333 3229 3b0a 0909 WCAP2_CRC32);... │ │ │ -00064cd0: 7265 7475 726e 2028 6865 6c70 6572 5f67 return (helper_g │ │ │ -00064ce0: 6574 6175 7876 616c 2832 3629 2026 616d etauxval(26) &am │ │ │ -00064cf0: 703b 2028 3120 266c 743b 266c 743b 2034 p; (1 << 4 │ │ │ -00064d00: 2929 3b0a 2365 6c69 6620 6465 6669 6e65 ));.#elif define │ │ │ -00064d10: 6420 5f5f 6161 7263 6836 345f 5f0a 0909 d __aarch64__... │ │ │ -00064d20: 2f2f 7265 7475 726e 2028 6765 7461 7578 //return (getaux │ │ │ -00064d30: 7661 6c28 4154 5f48 5743 4150 2920 2661 val(AT_HWCAP) &a │ │ │ -00064d40: 6d70 3b20 4857 4341 505f 4352 4333 3229 mp; HWCAP_CRC32) │ │ │ -00064d50: 3b0a 0909 7265 7475 726e 2028 6865 6c70 ;...return (help │ │ │ -00064d60: 6572 5f67 6574 6175 7876 616c 2831 3629 er_getauxval(16) │ │ │ -00064d70: 2026 616d 703b 2028 3120 266c 743b 266c & (1 <&l │ │ │ -00064d80: 743b 2037 2929 3b0a 2365 6e64 6966 0a23 t; 7));.#endif.# │ │ │ -00064d90: 656c 7365 0a09 0972 6574 7572 6e20 6661 else...return fa │ │ │ -00064da0: 6c73 653b 0a23 656e 6469 660a 097d 0a0a lse;.#endif..}.. │ │ │ -00064db0: 7d20 2f2f 2061 6e6f 6e79 6d6f 7573 206e } // anonymous n │ │ │ -00064dc0: 616d 6573 7061 6365 0a0a 0962 6f6f 6c20 amespace...bool │ │ │ -00064dd0: 636f 6e73 7420 7373 6534 325f 7375 7070 const sse42_supp │ │ │ -00064de0: 6f72 7420 3d20 7375 7070 6f72 7473 5f73 ort = supports_s │ │ │ -00064df0: 7365 3432 2829 3b0a 0962 6f6f 6c20 636f se42();..bool co │ │ │ -00064e00: 6e73 7420 6d6d 785f 7375 7070 6f72 7420 nst mmx_support │ │ │ -00064e10: 3d20 7375 7070 6f72 7473 5f6d 6d78 2829 = supports_mmx() │ │ │ -00064e20: 3b0a 0962 6f6f 6c20 636f 6e73 7420 6172 ;..bool const ar │ │ │ -00064e30: 6d5f 6e65 6f6e 5f73 7570 706f 7274 203d m_neon_support = │ │ │ -00064e40: 2073 7570 706f 7274 735f 6172 6d5f 6e65 supports_arm_ne │ │ │ -00064e50: 6f6e 2829 3b0a 0962 6f6f 6c20 636f 6e73 on();..bool cons │ │ │ -00064e60: 7420 6172 6d5f 6372 6333 3263 5f73 7570 t arm_crc32c_sup │ │ │ -00064e70: 706f 7274 203d 2073 7570 706f 7274 735f port = supports_ │ │ │ -00064e80: 6172 6d5f 6372 6333 3263 2829 3b0a 7d20 arm_crc32c();.} │ │ │ -00064e90: 7d0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 }.
    < │ │ │ -00064ec0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00064ed0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00064f00: 7372 632f 6368 6f6b 6572 2e63 7070 3a32 src/choker.cpp:2 │ │ │ -00064f10: 3538 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 58m │ │ │ -00064f20: 616b 6520 636f 6e66 6967 7572 6162 6c65 ake configurable │ │ │ -00064f30: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    ma │ │ │ -00064f80: 6b65 2063 6f6e 6669 6775 7261 626c 653c ke configurable< │ │ │ -00064f90: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f63 /h2>

    ../src/c │ │ │ -00064fa0: 686f 6b65 722e 6370 703a 3235 383c 2f68 hoker.cpp:258
    .../
    │ │ │ -00064ff0: 2f20 6669 7273 7420 7265 7365 7420 7468  / first reset th
    │ │ │ -00065000: 6520 6e75 6d62 6572 206f 6620 756e 6368  e number of unch
    │ │ │ -00065010: 6f6b 6520 736c 6f74 732c 2062 6563 6175  oke slots, becau
    │ │ │ -00065020: 7365 2077 6527 6c6c 2063 616c 6375 6c61  se we'll calcula
    │ │ │ -00065030: 7465 0a09 0909 2f2f 2069 7420 7075 7265  te....// it pure
    │ │ │ -00065040: 6c79 2062 6173 6564 206f 6e20 7468 6520  ly based on the 
    │ │ │ -00065050: 6375 7272 656e 7420 7374 6174 6520 6f66  current state of
    │ │ │ -00065060: 206f 7572 2070 6565 7273 2e0a 0909 0975   our peers.....u
    │ │ │ -00065070: 706c 6f61 645f 736c 6f74 7320 3d20 303b  pload_slots = 0;
    │ │ │ -00065080: 0a0a 0909 0969 6e74 2072 6174 655f 7468  .....int rate_th
    │ │ │ -00065090: 7265 7368 6f6c 6420 3d20 7365 7474 2e67  reshold = sett.g
    │ │ │ -000650a0: 6574 5f69 6e74 2873 6574 7469 6e67 735f  et_int(settings_
    │ │ │ -000650b0: 7061 636b 3a3a 7261 7465 5f63 686f 6b65  pack::rate_choke
    │ │ │ -000650c0: 725f 696e 6974 6961 6c5f 7468 7265 7368  r_initial_thresh
    │ │ │ -000650d0: 6f6c 6429 3b0a 0a09 0909 7374 643a 3a73  old);.....std::s
    │ │ │ -000650e0: 6f72 7428 7065 6572 732e 6265 6769 6e28  ort(peers.begin(
    │ │ │ -000650f0: 292c 2070 6565 7273 2e65 6e64 2829 0a09  ), peers.end()..
    │ │ │ -00065100: 0909 092c 205b 5d28 7065 6572 5f63 6f6e  ..., [](peer_con
    │ │ │ -00065110: 6e65 6374 696f 6e20 636f 6e73 742a 206c  nection const* l
    │ │ │ -00065120: 6873 2c20 7065 6572 5f63 6f6e 6e65 6374  hs, peer_connect
    │ │ │ -00065130: 696f 6e20 636f 6e73 742a 2072 6873 290a  ion const* rhs).
    │ │ │ -00065140: 0909 0909 7b20 7265 7475 726e 2075 706c  ....{ return upl
    │ │ │ -00065150: 6f61 645f 7261 7465 5f63 6f6d 7061 7265  oad_rate_compare
    │ │ │ -00065160: 286c 6873 2c20 7268 7329 3b20 7d29 3b0a  (lhs, rhs); });.
    │ │ │ -00065170: 0a09 0909 666f 7220 2861 7574 6f20 636f  ....for (auto co
    │ │ │ -00065180: 6e73 742a 2070 203a 2070 6565 7273 290a  nst* p : peers).
    │ │ │ -00065190: 0909 097b 0a09 0909 0969 6e74 2063 6f6e  ...{.....int con
    │ │ │ -000651a0: 7374 2072 6174 6520 3d20 696e 7428 702d  st rate = int(p-
    │ │ │ -000651b0: 2667 743b 7570 6c6f 6164 6564 5f69 6e5f  >uploaded_in_
    │ │ │ -000651c0: 6c61 7374 5f72 6f75 6e64 2829 0a09 0909  last_round()....
    │ │ │ -000651d0: 0909 2a20 3130 3030 202f 2074 6f74 616c  ..* 1000 / total
    │ │ │ -000651e0: 5f6d 696c 6c69 7365 636f 6e64 7328 756e  _milliseconds(un
    │ │ │ -000651f0: 6368 6f6b 655f 696e 7465 7276 616c 2929  choke_interval))
    │ │ │ -00065200: 3b0a 0a09 0909 092f 2f20 616c 7761 7973  ;......// always
    │ │ │ -00065210: 2068 6176 6520 6174 206c 6561 7374 2031   have at least 1
    │ │ │ -00065220: 2075 6e63 686f 6b65 2073 6c6f 740a 0909   unchoke slot...
    │ │ │ -00065230: 0909 6966 2028 7261 7465 2026 6c74 3b20  ..if (rate < 
    │ │ │ -00065240: 7261 7465 5f74 6872 6573 686f 6c64 2920  rate_threshold) 
    │ │ │ -00065250: 6272 6561 6b3b 0a0a 0909 0909 2b2b 7570  break;......++up
    │ │ │ -00065260: 6c6f 6164 5f73 6c6f 7473 3b0a 0a3c 6469  load_slots;......r
    │ │ │ -000652a0: 6174 655f 7468 7265 7368 6f6c 6420 2b3d  ate_threshold +=
    │ │ │ -000652b0: 2032 3034 383b 0a3c 2f64 6976 3e09 0909   2048;....
    │ │ │ -000652c0: 7d0a 0909 092b 2b75 706c 6f61 645f 736c  }....++upload_sl
    │ │ │ -000652d0: 6f74 733b 0a09 097d 0a0a 0909 2f2f 2073  ots;...}....// s
    │ │ │ -000652e0: 6f72 7473 2074 6865 2070 6565 7273 2074  orts the peers t
    │ │ │ -000652f0: 6861 7420 6172 6520 656c 6967 6962 6c65  hat are eligible
    │ │ │ -00065300: 2066 6f72 2075 6e63 686f 6b65 2062 7920   for unchoke by 
    │ │ │ -00065310: 646f 776e 6c6f 6164 2072 6174 6520 616e  download rate an
    │ │ │ -00065320: 640a 0909 2f2f 2073 6563 6f6e 6461 7279  d...// secondary
    │ │ │ -00065330: 2062 7920 746f 7461 6c20 7570 6c6f 6164   by total upload
    │ │ │ -00065340: 2e20 5468 6520 7265 6173 6f6e 2066 6f72  . The reason for
    │ │ │ -00065350: 2074 6869 7320 6973 2c20 6966 2061 6c6c   this is, if all
    │ │ │ -00065360: 2074 6f72 7265 6e74 7320 6172 650a 0909   torrents are...
    │ │ │ -00065370: 2f2f 2062 6569 6e67 2073 6565 6465 642c  // being seeded,
    │ │ │ -00065380: 2074 6865 2064 6f77 6e6c 6f61 6420 7261   the download ra
    │ │ │ -00065390: 7465 2077 696c 6c20 6265 2030 2c20 616e  te will be 0, an
    │ │ │ -000653a0: 6420 7468 6520 7065 6572 7320 7765 2068  d the peers we h
    │ │ │ -000653b0: 6176 6520 7365 6e74 0a09 092f 2f20 7468  ave sent...// th
    │ │ │ -000653c0: 6520 6c65 6173 7420 746f 2073 686f 756c  e least to shoul
    │ │ │ -000653d0: 6420 6265 2075 6e63 686f 6b65 640a 0a09  d be unchoked...
    │ │ │ -000653e0: 092f 2f20 7765 2075 7365 2070 6172 7469  .// we use parti
    │ │ │ -000653f0: 616c 2073 6f72 7420 6865 7265 2c20 6265  al sort here, be
    │ │ │ -00065400: 6361 7573 6520 7765 206f 6e6c 7920 6361  cause we only ca
    │ │ │ -00065410: 7265 2061 626f 7574 2074 6865 2074 6f70  re about the top
    │ │ │ -00065420: 0a09 092f 2f20 7570 6c6f 6164 5f73 6c6f  ...// upload_slo
    │ │ │ -00065430: 7473 2070 6565 7273 2e0a 0a09 0969 6e74  ts peers.....int
    │ │ │ -00065440: 2063 6f6e 7374 2073 6c6f 7473 203d 2073   const slots = s
    │ │ │ -00065450: 7464 3a3a 6d69 6e28 7570 6c6f 6164 5f73  td::min(upload_s
    │ │ │ -00065460: 6c6f 7473 2c20 696e 7428 7065 6572 732e  lots, int(peers.
    │ │ │ -00065470: 7369 7a65 2829 2929 3b0a 0a09 0969 6620  size()));....if 
    │ │ │ -00065480: 2873 6574 742e 6765 745f 696e 7428 7365  (sett.get_int(se
    │ │ │ -00065490: 7474 696e 6773 5f70 6163 6b3a 3a73 6565  ttings_pack::see
    │ │ │ -000654a0: 645f 6368 6f6b 696e 675f 616c 676f 7269  d_choking_algori
    │ │ │ -000654b0: 7468 6d29 0a09 0909 3d3d 2073 6574 7469  thm)....== setti
    │ │ │ -000654c0: 6e67 735f 7061 636b 3a3a 726f 756e 645f  ngs_pack::round_
    │ │ │ -000654d0: 726f 6269 6e29 0a09 097b 0a09 0909 696e  robin)...{....in
    │ │ │ -000654e0: 7420 636f 6e73 7420 7069 6563 6573 203d  t const pieces =
    │ │ │ -000654f0: 2073 6574 742e 6765 745f 696e 7428 7365   sett.get_int(se
    │ │ │ -00065500: 7474 696e 6773 5f70 6163 6b3a 3a73 6565  ttings_pack::see
    │ │ │ -00065510: 6469 6e67 5f70 6965 6365 5f71 756f 7461  ding_piece_quota
    │ │ │ -00065520: 293b 0a0a 0909 0973 7464 3a3a 6e74 685f  );.....std::nth_
    │ │ │ -00065530: 656c 656d 656e 7428 7065 6572 732e 6265  element(peers.be
    │ │ │ -00065540: 6769 6e28 292c 2070 6565 7273 2e62 6567  gin(), peers.beg
    │ │ │ -00065550: 696e 2829 0a09 0909 092b 2073 6c6f 7473  in().....+ slots
    │ │ │ -00065560: 2c20 7065 6572 732e 656e 6428 290a 0909  , peers.end()...
    │ │ │ -00065570: 0909 2c20 5b70 6965 6365 735d 2870 6565  .., [pieces](pee
    │ │ │ -00065580: 725f 636f 6e6e 6563 7469 6f6e 2063 6f6e  r_connection con
    │ │ │ -00065590: 7374 2a20 6c68 732c 2070 6565 725f 636f  st* lhs, peer_co
    │ │ │ -000655a0: 6e6e 6563 7469 6f6e 2063 6f6e 7374 2a20  nnection const* 
    │ │ │ -000655b0: 7268 7329 0a09 0909 097b 2072 6574 7572  rhs).....{ retur
    │ │ │ -000655c0: 6e20 756e 6368 6f6b 655f 636f 6d70 6172  n unchoke_compar
    │ │ │ -000655d0: 655f 7272 286c 6873 2c20 7268 732c 2070  e_rr(lhs, rhs, p
    │ │ │ -000655e0: 6965 6365 7329 3b20 7d29 3b0a 0909 7d0a  ieces); });...}.
    │ │ │ -000655f0: 0909 656c 7365 2069 6620 2873 6574 742e  ..else if (sett.
    │ │ │ -00065600: 6765 745f 696e 7428 7365 7474 696e 6773  get_int(settings
    │ │ │ -00065610: 5f70 6163 6b3a 3a73 6565 645f 6368 6f6b  _pack::seed_chok
    │ │ │ -00065620: 696e 675f 616c 676f 7269 7468 6d29 0a09  ing_algorithm)..
    │ │ │ -00065630: 0909 3d3d 2073 6574 7469 6e67 735f 7061  ..== settings_pa
    │ │ │ -00065640: 636b 3a3a 6661 7374 6573 745f 7570 6c6f  ck::fastest_uplo
    │ │ │ -00065650: 6164 290a 0909 7b0a 0909 0973 7464 3a3a  ad)...{....std::
    │ │ │ -00065660: 6e74 685f 656c 656d 656e 7428 7065 6572  nth_element(peer
    │ │ │ -00065670: 732e 6265 6769 6e28 292c 2070 6565 7273  s.begin(), peers
    │ │ │ -00065680: 2e62 6567 696e 2829 0a09 0909 092b 2073  .begin().....+ s
    │ │ │ -00065690: 6c6f 7473 2c20 7065 6572 732e 656e 6428  lots, peers.end(
    │ │ │ -000656a0: 290a 0909 0909 2c20 5b5d 2870 6565 725f  )....., [](peer_
    │ │ │ -000656b0: 636f 6e6e 6563 7469 6f6e 2063 6f6e 7374  connection const
    │ │ │ -000656c0: 2a20 6c68 732c 2070 6565 725f 636f 6e6e  * lhs, peer_conn
    │ │ │ -000656d0: 6563 7469 6f6e 2063 6f6e 7374 2a20 7268  ection const* rh
    │ │ │ -000656e0: 7329 0a3c 2f70 7265 3e3c 2f74 643e 3c2f  s).
    │ │ │ -00065710: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -00065720: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -00065750: 2f73 7263 2f61 6c65 7274 2e63 7070 3a33 /src/alert.cpp:3 │ │ │ -00065760: 3837 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 87m │ │ │ -00065770: 6f76 6520 7468 6973 2066 6965 6c64 2069 ove this field i │ │ │ -00065780: 6e74 6f20 7472 6163 6b65 725f 616c 6572 nto tracker_aler │ │ │ -00065790: 743c 2f74 643e 3c2f 7472 3e3c 7472 2069 t

    m │ │ │ -000657e0: 6f76 6520 7468 6973 2066 6965 6c64 2069 ove this field i │ │ │ -000657f0: 6e74 6f20 7472 6163 6b65 725f 616c 6572 nto tracker_aler │ │ │ -00065800: 743c 2f68 323e 3c68 343e 2e2e 2f73 7263 t

    ../src │ │ │ -00065810: 2f61 6c65 7274 2e63 7070 3a33 3837 3c2f /alert.cpp:387
    ...
    │ │ │ -00065860: 7265 7475 726e 2074 6f72 7265 6e74 5f61  return torrent_a
    │ │ │ -00065870: 6c65 7274 3a3a 6d65 7373 6167 6528 2920  lert::message() 
    │ │ │ -00065880: 2b20 223a 2073 7461 7465 2063 6861 6e67  + ": state chang
    │ │ │ -00065890: 6564 2074 6f3a 2022 0a09 0909 2b20 7374  ed to: "....+ st
    │ │ │ -000658a0: 6174 655f 7374 725b 7374 6174 655d 3b0a  ate_str[state];.
    │ │ │ -000658b0: 2365 6e64 6966 0a09 7d0a 0a09 7472 6163  #endif..}...trac
    │ │ │ -000658c0: 6b65 725f 6572 726f 725f 616c 6572 743a  ker_error_alert:
    │ │ │ -000658d0: 3a74 7261 636b 6572 5f65 7272 6f72 5f61  :tracker_error_a
    │ │ │ -000658e0: 6c65 7274 2861 7578 3a3a 7374 6163 6b5f  lert(aux::stack_
    │ │ │ -000658f0: 616c 6c6f 6361 746f 7226 616d 703b 2061  allocator& a
    │ │ │ -00065900: 6c6c 6f63 0a09 092c 2074 6f72 7265 6e74  lloc..., torrent
    │ │ │ -00065910: 5f68 616e 646c 6520 636f 6e73 7426 616d  _handle const&am
    │ │ │ -00065920: 703b 2068 2c20 7463 703a 3a65 6e64 706f  p; h, tcp::endpo
    │ │ │ -00065930: 696e 7420 636f 6e73 7426 616d 703b 2065  int const& e
    │ │ │ -00065940: 702c 2069 6e74 2074 696d 6573 0a09 092c  p, int times...,
    │ │ │ -00065950: 2070 726f 746f 636f 6c5f 7665 7273 696f   protocol_versio
    │ │ │ -00065960: 6e20 762c 2073 7472 696e 675f 7669 6577  n v, string_view
    │ │ │ -00065970: 2075 2c20 6f70 6572 6174 696f 6e5f 7420   u, operation_t 
    │ │ │ -00065980: 636f 6e73 7420 6f70 6572 6174 696f 6e0a  const operation.
    │ │ │ -00065990: 0909 2c20 6572 726f 725f 636f 6465 2063  .., error_code c
    │ │ │ -000659a0: 6f6e 7374 2661 6d70 3b20 650a 0909 2c20  onst& e..., 
    │ │ │ -000659b0: 7374 7269 6e67 5f76 6965 7720 6d29 0a09  string_view m)..
    │ │ │ -000659c0: 093a 2074 7261 636b 6572 5f61 6c65 7274  .: tracker_alert
    │ │ │ -000659d0: 2861 6c6c 6f63 2c20 682c 2065 702c 2075  (alloc, h, ep, u
    │ │ │ -000659e0: 290a 0909 2c20 7469 6d65 735f 696e 5f72  )..., times_in_r
    │ │ │ -000659f0: 6f77 2874 696d 6573 290a 0909 2c20 6572  ow(times)..., er
    │ │ │ -00065a00: 726f 7228 6529 0a09 092c 206f 7028 6f70  ror(e)..., op(op
    │ │ │ -00065a10: 6572 6174 696f 6e29 0a09 092c 206d 5f6d  eration)..., m_m
    │ │ │ -00065a20: 7367 5f69 6478 2861 6c6c 6f63 2e63 6f70  sg_idx(alloc.cop
    │ │ │ -00065a30: 795f 7374 7269 6e67 286d 2929 0a23 6966  y_string(m)).#if
    │ │ │ -00065a40: 2054 4f52 5245 4e54 5f41 4249 5f56 4552   TORRENT_ABI_VER
    │ │ │ -00065a50: 5349 4f4e 203d 3d20 310a 0909 2c20 7374  SION == 1..., st
    │ │ │ -00065a60: 6174 7573 5f63 6f64 6528 6520 2661 6d70  atus_code(e &
    │ │ │ -00065a70: 3b26 616d 703b 2065 2e63 6174 6567 6f72  ;& e.categor
    │ │ │ -00065a80: 7928 2920 3d3d 2068 7474 705f 6361 7465  y() == http_cate
    │ │ │ -00065a90: 676f 7279 2829 203f 2065 2e76 616c 7565  gory() ? e.value
    │ │ │ -00065aa0: 2829 203a 202d 3129 0a09 092c 206d 7367  () : -1)..., msg
    │ │ │ -00065ab0: 286d 290a 2365 6e64 6966 0a3c 6469 7620  (m).#endif.
    .., ver │ │ │ -00065af0: 7369 6f6e 2876 290a 3c2f 6469 763e 097b sion(v).
    .{ │ │ │ -00065b00: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -00065b10: 5428 2175 2e65 6d70 7479 2829 293b 0a09 T(!u.empty());.. │ │ │ -00065b20: 7d0a 0a09 6368 6172 2063 6f6e 7374 2a20 }...char const* │ │ │ -00065b30: 7472 6163 6b65 725f 6572 726f 725f 616c tracker_error_al │ │ │ -00065b40: 6572 743a 3a66 6169 6c75 7265 5f72 6561 ert::failure_rea │ │ │ -00065b50: 736f 6e28 2920 636f 6e73 740a 097b 0a09 son() const..{.. │ │ │ -00065b60: 0972 6574 7572 6e20 6d5f 616c 6c6f 632e .return m_alloc. │ │ │ -00065b70: 6765 7428 292e 7074 7228 6d5f 6d73 675f get().ptr(m_msg_ │ │ │ -00065b80: 6964 7829 3b0a 097d 0a0a 0973 7464 3a3a idx);..}...std:: │ │ │ -00065b90: 7374 7269 6e67 2074 7261 636b 6572 5f65 string tracker_e │ │ │ -00065ba0: 7272 6f72 5f61 6c65 7274 3a3a 6d65 7373 rror_alert::mess │ │ │ -00065bb0: 6167 6528 2920 636f 6e73 740a 097b 0a23 age() const..{.# │ │ │ -00065bc0: 6966 6465 6620 544f 5252 454e 545f 4449 ifdef TORRENT_DI │ │ │ -00065bd0: 5341 424c 455f 414c 4552 545f 4d53 470a SABLE_ALERT_MSG. │ │ │ -00065be0: 0909 7265 7475 726e 207b 7d3b 0a23 656c ..return {};.#el │ │ │ -00065bf0: 7365 0a09 0963 6861 7220 7265 745b 3430 se...char ret[40 │ │ │ -00065c00: 305d 3b0a 0909 7374 643a 3a73 6e70 7269 0];...std::snpri │ │ │ -00065c10: 6e74 6628 7265 742c 2073 697a 656f 6628 ntf(ret, sizeof( │ │ │ -00065c20: 7265 7429 2c20 2225 7320 2573 2025 7320 ret), "%s %s %s │ │ │ -00065c30: 5c22 2573 5c22 2028 2564 2922 0a09 0909 \"%s\" (%d)".... │ │ │ -00065c40: 2c20 7472 6163 6b65 725f 616c 6572 743a , tracker_alert: │ │ │ -00065c50: 3a6d 6573 7361 6765 2829 2e63 5f73 7472 :message().c_str │ │ │ -00065c60: 2829 0a09 0909 2c20 7665 7273 696f 6e20 ()...., version │ │ │ -00065c70: 3d3d 2070 726f 746f 636f 6c5f 7665 7273 == protocol_vers │ │ │ -00065c80: 696f 6e3a 3a56 3120 3f20 2276 3122 203a ion::V1 ? "v1" : │ │ │ -00065c90: 2022 7632 220a 0909 092c 2063 6f6e 7665 "v2"...., conve │ │ │ -00065ca0: 7274 5f66 726f 6d5f 6e61 7469 7665 2865 rt_from_native(e │ │ │ -00065cb0: 7272 6f72 2e6d 6573 7361 6765 2829 292e rror.message()). │ │ │ -00065cc0: 635f 7374 7228 292c 2065 7272 6f72 5f6d c_str(), error_m │ │ │ -00065cd0: 6573 7361 6765 2829 0a09 0909 2c20 7469 essage()...., ti │ │ │ -00065ce0: 6d65 735f 696e 5f72 6f77 293b 0a09 0972 mes_in_row);...r │ │ │ -00065cf0: 6574 7572 6e20 7265 743b 0a23 656e 6469 eturn ret;.#endi │ │ │ -00065d00: 660a 097d 0a0a 0974 7261 636b 6572 5f77 f..}...tracker_w │ │ │ -00065d10: 6172 6e69 6e67 5f61 6c65 7274 3a3a 7472 arning_alert::tr │ │ │ -00065d20: 6163 6b65 725f 7761 726e 696e 675f 616c acker_warning_al │ │ │ -00065d30: 6572 7428 6175 783a 3a73 7461 636b 5f61 ert(aux::stack_a │ │ │ -00065d40: 6c6c 6f63 6174 6f72 2661 6d70 3b20 616c llocator& al │ │ │ -00065d50: 6c6f 630a 0909 2c20 746f 7272 656e 745f loc..., torrent_ │ │ │ -00065d60: 6861 6e64 6c65 2063 6f6e 7374 2661 6d70 handle const& │ │ │ -00065d70: 3b20 682c 2074 6370 3a3a 656e 6470 6f69 ; h, tcp::endpoi │ │ │ -00065d80: 6e74 2063 6f6e 7374 2661 6d70 3b20 6570 nt const& ep │ │ │ -00065d90: 0a09 092c 2073 7472 696e 675f 7669 6577 ..., string_view │ │ │ -00065da0: 2075 2c20 7072 6f74 6f63 6f6c 5f76 6572 u, protocol_ver │ │ │ -00065db0: 7369 6f6e 2076 2c20 7374 7269 6e67 5f76 sion v, string_v │ │ │ -00065dc0: 6965 7720 6d29 0a09 093a 2074 7261 636b iew m)...: track │ │ │ -00065dd0: 6572 5f61 6c65 7274 2861 6c6c 6f63 2c20 er_alert(alloc, │ │ │ -00065de0: 682c 2065 702c 2075 290a 0909 2c20 6d5f h, ep, u)..., m_ │ │ │ -00065df0: 6d73 675f 6964 7828 616c 6c6f 632e 636f msg_idx(alloc.co │ │ │ -00065e00: 7079 5f73 7472 696e 6728 6d29 290a 2369 py_string(m)).#i │ │ │ -00065e10: 6620 544f 5252 454e 545f 4142 495f 5645 f TORRENT_ABI_VE │ │ │ -00065e20: 5253 494f 4e20 3d3d 2031 0a3c 2f70 7265 RSION == 1.
    rele │ │ │ -00065e60: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/ale │ │ │ -00065ea0: 7274 2e63 7070 3a34 3231 3c2f 613e 3c2f rt.cpp:421move this │ │ │ -00065ec0: 2069 6e74 6f20 7472 6163 6b65 725f 616c into tracker_al │ │ │ -00065ed0: 6572 743c 2f74 643e 3c2f 7472 3e3c 7472 ert

    move this into │ │ │ -00065f30: 7472 6163 6b65 725f 616c 6572 743c 2f68 tracker_alert

    ../src/ale │ │ │ -00065f50: 7274 2e63 7070 3a34 3231 3c2f 6834 3e3c rt.cpp:421

    < │ │ │ -00065f60: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00065f70: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00065f80: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00065f90: 7820 2364 6464 3b22 3e09 0972 6574 7572 x #ddd;">..retur │ │ │ -00065fa0: 6e20 7b7d 3b0a 2365 6c73 650a 0909 6368 n {};.#else...ch │ │ │ -00065fb0: 6172 2072 6574 5b34 3030 5d3b 0a09 0973 ar ret[400];...s │ │ │ -00065fc0: 7464 3a3a 736e 7072 696e 7466 2872 6574 td::snprintf(ret │ │ │ -00065fd0: 2c20 7369 7a65 6f66 2872 6574 292c 2022 , sizeof(ret), " │ │ │ -00065fe0: 2573 2025 7320 2573 205c 2225 735c 2220 %s %s %s \"%s\" │ │ │ -00065ff0: 2825 6429 220a 0909 092c 2074 7261 636b (%d)"...., track │ │ │ -00066000: 6572 5f61 6c65 7274 3a3a 6d65 7373 6167 er_alert::messag │ │ │ -00066010: 6528 292e 635f 7374 7228 290a 0909 092c e().c_str()...., │ │ │ -00066020: 2076 6572 7369 6f6e 203d 3d20 7072 6f74 version == prot │ │ │ -00066030: 6f63 6f6c 5f76 6572 7369 6f6e 3a3a 5631 ocol_version::V1 │ │ │ -00066040: 203f 2022 7631 2220 3a20 2276 3222 0a09 ? "v1" : "v2".. │ │ │ -00066050: 0909 2c20 636f 6e76 6572 745f 6672 6f6d .., convert_from │ │ │ -00066060: 5f6e 6174 6976 6528 6572 726f 722e 6d65 _native(error.me │ │ │ -00066070: 7373 6167 6528 2929 2e63 5f73 7472 2829 ssage()).c_str() │ │ │ -00066080: 2c20 6572 726f 725f 6d65 7373 6167 6528 , error_message( │ │ │ -00066090: 290a 0909 092c 2074 696d 6573 5f69 6e5f )...., times_in_ │ │ │ -000660a0: 726f 7729 3b0a 0909 7265 7475 726e 2072 row);...return r │ │ │ -000660b0: 6574 3b0a 2365 6e64 6966 0a09 7d0a 0a09 et;.#endif..}... │ │ │ -000660c0: 7472 6163 6b65 725f 7761 726e 696e 675f tracker_warning_ │ │ │ -000660d0: 616c 6572 743a 3a74 7261 636b 6572 5f77 alert::tracker_w │ │ │ -000660e0: 6172 6e69 6e67 5f61 6c65 7274 2861 7578 arning_alert(aux │ │ │ -000660f0: 3a3a 7374 6163 6b5f 616c 6c6f 6361 746f ::stack_allocato │ │ │ -00066100: 7226 616d 703b 2061 6c6c 6f63 0a09 092c r& alloc..., │ │ │ -00066110: 2074 6f72 7265 6e74 5f68 616e 646c 6520 torrent_handle │ │ │ -00066120: 636f 6e73 7426 616d 703b 2068 2c20 7463 const& h, tc │ │ │ -00066130: 703a 3a65 6e64 706f 696e 7420 636f 6e73 p::endpoint cons │ │ │ -00066140: 7426 616d 703b 2065 700a 0909 2c20 7374 t& ep..., st │ │ │ -00066150: 7269 6e67 5f76 6965 7720 752c 2070 726f ring_view u, pro │ │ │ -00066160: 746f 636f 6c5f 7665 7273 696f 6e20 762c tocol_version v, │ │ │ -00066170: 2073 7472 696e 675f 7669 6577 206d 290a string_view m). │ │ │ -00066180: 0909 3a20 7472 6163 6b65 725f 616c 6572 ..: tracker_aler │ │ │ -00066190: 7428 616c 6c6f 632c 2068 2c20 6570 2c20 t(alloc, h, ep, │ │ │ -000661a0: 7529 0a09 092c 206d 5f6d 7367 5f69 6478 u)..., m_msg_idx │ │ │ -000661b0: 2861 6c6c 6f63 2e63 6f70 795f 7374 7269 (alloc.copy_stri │ │ │ -000661c0: 6e67 286d 2929 0a23 6966 2054 4f52 5245 ng(m)).#if TORRE │ │ │ -000661d0: 4e54 5f41 4249 5f56 4552 5349 4f4e 203d NT_ABI_VERSION = │ │ │ -000661e0: 3d20 310a 0909 2c20 6d73 6728 6d29 0a23 = 1..., msg(m).# │ │ │ -000661f0: 656e 6469 660a 3c64 6976 2073 7479 6c65 endif.
    .., version( │ │ │ -00066230: 7629 0a3c 2f64 6976 3e09 7b0a 0909 544f v).
    .{...TO │ │ │ -00066240: 5252 454e 545f 4153 5345 5254 2821 752e RRENT_ASSERT(!u. │ │ │ -00066250: 656d 7074 7928 2929 3b0a 097d 0a0a 0963 empty());..}...c │ │ │ -00066260: 6861 7220 636f 6e73 742a 2074 7261 636b har const* track │ │ │ -00066270: 6572 5f77 6172 6e69 6e67 5f61 6c65 7274 er_warning_alert │ │ │ -00066280: 3a3a 7761 726e 696e 675f 6d65 7373 6167 ::warning_messag │ │ │ -00066290: 6528 2920 636f 6e73 740a 097b 0a09 0972 e() const..{...r │ │ │ -000662a0: 6574 7572 6e20 6d5f 616c 6c6f 632e 6765 eturn m_alloc.ge │ │ │ -000662b0: 7428 292e 7074 7228 6d5f 6d73 675f 6964 t().ptr(m_msg_id │ │ │ -000662c0: 7829 3b0a 097d 0a0a 0973 7464 3a3a 7374 x);..}...std::st │ │ │ -000662d0: 7269 6e67 2074 7261 636b 6572 5f77 6172 ring tracker_war │ │ │ -000662e0: 6e69 6e67 5f61 6c65 7274 3a3a 6d65 7373 ning_alert::mess │ │ │ -000662f0: 6167 6528 2920 636f 6e73 740a 097b 0a23 age() const..{.# │ │ │ -00066300: 6966 6465 6620 544f 5252 454e 545f 4449 ifdef TORRENT_DI │ │ │ -00066310: 5341 424c 455f 414c 4552 545f 4d53 470a SABLE_ALERT_MSG. │ │ │ -00066320: 0909 7265 7475 726e 207b 7d3b 0a23 656c ..return {};.#el │ │ │ -00066330: 7365 0a09 0972 6574 7572 6e20 7472 6163 se...return trac │ │ │ -00066340: 6b65 725f 616c 6572 743a 3a6d 6573 7361 ker_alert::messa │ │ │ -00066350: 6765 2829 202b 2028 7665 7273 696f 6e20 ge() + (version │ │ │ -00066360: 3d3d 2070 726f 746f 636f 6c5f 7665 7273 == protocol_vers │ │ │ -00066370: 696f 6e3a 3a56 3120 3f20 2220 7631 2220 ion::V1 ? " v1" │ │ │ -00066380: 3a20 2220 7632 2229 202b 2022 2077 6172 : " v2") + " war │ │ │ -00066390: 6e69 6e67 3a20 2220 2b20 7761 726e 696e ning: " + warnin │ │ │ -000663a0: 675f 6d65 7373 6167 6528 293b 0a23 656e g_message();.#en │ │ │ -000663b0: 6469 660a 097d 0a0a 0973 6372 6170 655f dif..}...scrape_ │ │ │ -000663c0: 7265 706c 795f 616c 6572 743a 3a73 6372 reply_alert::scr │ │ │ -000663d0: 6170 655f 7265 706c 795f 616c 6572 7428 ape_reply_alert( │ │ │ -000663e0: 6175 783a 3a73 7461 636b 5f61 6c6c 6f63 aux::stack_alloc │ │ │ -000663f0: 6174 6f72 2661 6d70 3b20 616c 6c6f 630a ator& alloc. │ │ │ -00066400: 0909 2c20 746f 7272 656e 745f 6861 6e64 .., torrent_hand │ │ │ -00066410: 6c65 2063 6f6e 7374 2661 6d70 3b20 682c le const& h, │ │ │ -00066420: 2074 6370 3a3a 656e 6470 6f69 6e74 2063 tcp::endpoint c │ │ │ -00066430: 6f6e 7374 2661 6d70 3b20 6570 0a09 092c onst& ep..., │ │ │ -00066440: 2069 6e74 2069 6e63 6f6d 702c 2069 6e74 int incomp, int │ │ │ -00066450: 2063 6f6d 702c 2073 7472 696e 675f 7669 comp, string_vi │ │ │ -00066460: 6577 2075 2c20 7072 6f74 6f63 6f6c 5f76 ew u, protocol_v │ │ │ -00066470: 6572 7369 6f6e 2063 6f6e 7374 2076 290a ersion const v). │ │ │ -00066480: 0909 3a20 7472 6163 6b65 725f 616c 6572 ..: tracker_aler │ │ │ -00066490: 7428 616c 6c6f 632c 2068 2c20 6570 2c20 t(alloc, h, ep, │ │ │ -000664a0: 7529 0a09 092c 2069 6e63 6f6d 706c 6574 u)..., incomplet │ │ │ -000664b0: 6528 696e 636f 6d70 290a 0909 2c20 636f e(incomp)..., co │ │ │ -000664c0: 6d70 6c65 7465 2863 6f6d 7029 0a3c 2f70 mplete(comp).

    re │ │ │ -00066500: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/a │ │ │ -00066540: 6c65 7274 2e63 7070 3a34 3437 3c2f 613e lert.cpp:447 │ │ │ -00066550: 3c2f 7464 3e3c 7464 3e6d 6f76 6520 7468 move th │ │ │ -00066560: 6973 2069 6e74 6f20 7472 6163 6b65 725f is into tracker_ │ │ │ -00066570: 616c 6572 743c 2f74 643e 3c2f 7472 3e3c alert< │ │ │ -00066580: 7472 2069 643d 2232 3334 2220 7374 796c tr id="234" styl │ │ │ -00066590: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -000665a0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -000665b0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -000665c0: 6832 3e6d 6f76 6520 7468 6973 2069 6e74 h2>move this int │ │ │ -000665d0: 6f20 7472 6163 6b65 725f 616c 6572 743c o tracker_alert< │ │ │ -000665e0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f61 /h2>

    ../src/a │ │ │ -000665f0: 6c65 7274 2e63 7070 3a34 3437 3c2f 6834 lert.cpp:447

    .char
    │ │ │ -00066640: 2063 6f6e 7374 2a20 7472 6163 6b65 725f   const* tracker_
    │ │ │ -00066650: 7761 726e 696e 675f 616c 6572 743a 3a77  warning_alert::w
    │ │ │ -00066660: 6172 6e69 6e67 5f6d 6573 7361 6765 2829  arning_message()
    │ │ │ -00066670: 2063 6f6e 7374 0a09 7b0a 0909 7265 7475   const..{...retu
    │ │ │ -00066680: 726e 206d 5f61 6c6c 6f63 2e67 6574 2829  rn m_alloc.get()
    │ │ │ -00066690: 2e70 7472 286d 5f6d 7367 5f69 6478 293b  .ptr(m_msg_idx);
    │ │ │ -000666a0: 0a09 7d0a 0a09 7374 643a 3a73 7472 696e  ..}...std::strin
    │ │ │ -000666b0: 6720 7472 6163 6b65 725f 7761 726e 696e  g tracker_warnin
    │ │ │ -000666c0: 675f 616c 6572 743a 3a6d 6573 7361 6765  g_alert::message
    │ │ │ -000666d0: 2829 2063 6f6e 7374 0a09 7b0a 2369 6664  () const..{.#ifd
    │ │ │ -000666e0: 6566 2054 4f52 5245 4e54 5f44 4953 4142  ef TORRENT_DISAB
    │ │ │ -000666f0: 4c45 5f41 4c45 5254 5f4d 5347 0a09 0972  LE_ALERT_MSG...r
    │ │ │ -00066700: 6574 7572 6e20 7b7d 3b0a 2365 6c73 650a  eturn {};.#else.
    │ │ │ -00066710: 0909 7265 7475 726e 2074 7261 636b 6572  ..return tracker
    │ │ │ -00066720: 5f61 6c65 7274 3a3a 6d65 7373 6167 6528  _alert::message(
    │ │ │ -00066730: 2920 2b20 2876 6572 7369 6f6e 203d 3d20  ) + (version == 
    │ │ │ -00066740: 7072 6f74 6f63 6f6c 5f76 6572 7369 6f6e  protocol_version
    │ │ │ -00066750: 3a3a 5631 203f 2022 2076 3122 203a 2022  ::V1 ? " v1" : "
    │ │ │ -00066760: 2076 3222 2920 2b20 2220 7761 726e 696e   v2") + " warnin
    │ │ │ -00066770: 673a 2022 202b 2077 6172 6e69 6e67 5f6d  g: " + warning_m
    │ │ │ -00066780: 6573 7361 6765 2829 3b0a 2365 6e64 6966  essage();.#endif
    │ │ │ -00066790: 0a09 7d0a 0a09 7363 7261 7065 5f72 6570  ..}...scrape_rep
    │ │ │ -000667a0: 6c79 5f61 6c65 7274 3a3a 7363 7261 7065  ly_alert::scrape
    │ │ │ -000667b0: 5f72 6570 6c79 5f61 6c65 7274 2861 7578  _reply_alert(aux
    │ │ │ -000667c0: 3a3a 7374 6163 6b5f 616c 6c6f 6361 746f  ::stack_allocato
    │ │ │ -000667d0: 7226 616d 703b 2061 6c6c 6f63 0a09 092c  r& alloc...,
    │ │ │ -000667e0: 2074 6f72 7265 6e74 5f68 616e 646c 6520   torrent_handle 
    │ │ │ -000667f0: 636f 6e73 7426 616d 703b 2068 2c20 7463  const& h, tc
    │ │ │ -00066800: 703a 3a65 6e64 706f 696e 7420 636f 6e73  p::endpoint cons
    │ │ │ -00066810: 7426 616d 703b 2065 700a 0909 2c20 696e  t& ep..., in
    │ │ │ -00066820: 7420 696e 636f 6d70 2c20 696e 7420 636f  t incomp, int co
    │ │ │ -00066830: 6d70 2c20 7374 7269 6e67 5f76 6965 7720  mp, string_view 
    │ │ │ -00066840: 752c 2070 726f 746f 636f 6c5f 7665 7273  u, protocol_vers
    │ │ │ -00066850: 696f 6e20 636f 6e73 7420 7629 0a09 093a  ion const v)...:
    │ │ │ -00066860: 2074 7261 636b 6572 5f61 6c65 7274 2861   tracker_alert(a
    │ │ │ -00066870: 6c6c 6f63 2c20 682c 2065 702c 2075 290a  lloc, h, ep, u).
    │ │ │ -00066880: 0909 2c20 696e 636f 6d70 6c65 7465 2869  .., incomplete(i
    │ │ │ -00066890: 6e63 6f6d 7029 0a09 092c 2063 6f6d 706c  ncomp)..., compl
    │ │ │ -000668a0: 6574 6528 636f 6d70 290a 3c64 6976 2073  ete(comp).
    .., vers │ │ │ -000668e0: 696f 6e28 7629 0a3c 2f64 6976 3e09 7b0a ion(v).
    .{. │ │ │ -000668f0: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -00066900: 2821 752e 656d 7074 7928 2929 3b0a 097d (!u.empty());..} │ │ │ -00066910: 0a0a 0973 7464 3a3a 7374 7269 6e67 2073 ...std::string s │ │ │ -00066920: 6372 6170 655f 7265 706c 795f 616c 6572 crape_reply_aler │ │ │ -00066930: 743a 3a6d 6573 7361 6765 2829 2063 6f6e t::message() con │ │ │ -00066940: 7374 0a09 7b0a 2369 6664 6566 2054 4f52 st..{.#ifdef TOR │ │ │ -00066950: 5245 4e54 5f44 4953 4142 4c45 5f41 4c45 RENT_DISABLE_ALE │ │ │ -00066960: 5254 5f4d 5347 0a09 0972 6574 7572 6e20 RT_MSG...return │ │ │ -00066970: 7b7d 3b0a 2365 6c73 650a 0909 6368 6172 {};.#else...char │ │ │ -00066980: 2072 6574 5b34 3030 5d3b 0a09 0973 7464 ret[400];...std │ │ │ -00066990: 3a3a 736e 7072 696e 7466 2872 6574 2c20 ::snprintf(ret, │ │ │ -000669a0: 7369 7a65 6f66 2872 6574 292c 2022 2573 sizeof(ret), "%s │ │ │ -000669b0: 2025 7320 7363 7261 7065 2072 6570 6c79 %s scrape reply │ │ │ -000669c0: 3a20 2564 2025 6422 0a09 0909 2c20 7472 : %d %d"...., tr │ │ │ -000669d0: 6163 6b65 725f 616c 6572 743a 3a6d 6573 acker_alert::mes │ │ │ -000669e0: 7361 6765 2829 2e63 5f73 7472 2829 0a09 sage().c_str().. │ │ │ -000669f0: 0909 2c20 7665 7273 696f 6e20 3d3d 2070 .., version == p │ │ │ -00066a00: 726f 746f 636f 6c5f 7665 7273 696f 6e3a rotocol_version: │ │ │ -00066a10: 3a56 3120 3f20 2276 3122 203a 2022 7632 :V1 ? "v1" : "v2 │ │ │ -00066a20: 220a 0909 092c 2069 6e63 6f6d 706c 6574 "...., incomplet │ │ │ -00066a30: 652c 2063 6f6d 706c 6574 6529 3b0a 0909 e, complete);... │ │ │ -00066a40: 7265 7475 726e 2072 6574 3b0a 2365 6e64 return ret;.#end │ │ │ -00066a50: 6966 0a09 7d0a 0a09 7363 7261 7065 5f66 if..}...scrape_f │ │ │ -00066a60: 6169 6c65 645f 616c 6572 743a 3a73 6372 ailed_alert::scr │ │ │ -00066a70: 6170 655f 6661 696c 6564 5f61 6c65 7274 ape_failed_alert │ │ │ -00066a80: 2861 7578 3a3a 7374 6163 6b5f 616c 6c6f (aux::stack_allo │ │ │ -00066a90: 6361 746f 7226 616d 703b 2061 6c6c 6f63 cator& alloc │ │ │ -00066aa0: 0a09 092c 2074 6f72 7265 6e74 5f68 616e ..., torrent_han │ │ │ -00066ab0: 646c 6520 636f 6e73 7426 616d 703b 2068 dle const& h │ │ │ -00066ac0: 2c20 7463 703a 3a65 6e64 706f 696e 7420 , tcp::endpoint │ │ │ -00066ad0: 636f 6e73 7426 616d 703b 2065 700a 0909 const& ep... │ │ │ -00066ae0: 2c20 7374 7269 6e67 5f76 6965 7720 752c , string_view u, │ │ │ -00066af0: 2070 726f 746f 636f 6c5f 7665 7273 696f protocol_versio │ │ │ -00066b00: 6e20 636f 6e73 7420 762c 2065 7272 6f72 n const v, error │ │ │ -00066b10: 5f63 6f64 6520 636f 6e73 7426 616d 703b _code const& │ │ │ -00066b20: 2065 290a 0909 3a20 7472 6163 6b65 725f e)...: tracker_ │ │ │ -00066b30: 616c 6572 7428 616c 6c6f 632c 2068 2c20 alert(alloc, h, │ │ │ -00066b40: 6570 2c20 7529 0a09 092c 2065 7272 6f72 ep, u)..., error │ │ │ -00066b50: 2865 290a 0909 2c20 6d5f 6d73 675f 6964 (e)..., m_msg_id │ │ │ -00066b60: 7828 290a 2369 6620 544f 5252 454e 545f x().#if TORRENT_ │ │ │ -00066b70: 4142 495f 5645 5253 494f 4e20 3d3d 2031 ABI_VERSION == 1 │ │ │ -00066b80: 0a09 092c 206d 7367 2863 6f6e 7665 7274 ..., msg(convert │ │ │ -00066b90: 5f66 726f 6d5f 6e61 7469 7665 2865 2e6d _from_native(e.m │ │ │ -00066ba0: 6573 7361 6765 2829 2929 0a23 656e 6469 essage())).#endi │ │ │ -00066bb0: 660a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 f.
    < │ │ │ -00066be0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00066bf0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00066c20: 7372 632f 616c 6572 742e 6370 703a 3437 src/alert.cpp:47 │ │ │ -00066c30: 363c 2f61 3e3c 2f74 643e 3c74 643e 6d6f 6mo │ │ │ -00066c40: 7665 2074 6869 7320 696e 746f 2074 7261 ve this into tra │ │ │ -00066c50: 636b 6572 5f61 6c65 7274 3c2f 7464 3e3c cker_alert< │ │ │ -00066c60: 2f74 723e 3c74 7220 6964 3d22 3233 3522 /tr>

    move thi │ │ │ -00066cb0: 7320 696e 746f 2074 7261 636b 6572 5f61 s into tracker_a │ │ │ -00066cc0: 6c65 7274 3c2f 6832 3e3c 6834 3e2e 2e2f lert

    ../ │ │ │ -00066cd0: 7372 632f 616c 6572 742e 6370 703a 3437 src/alert.cpp:47 │ │ │ -00066ce0: 363c 2f68 343e 3c70 7265 2073 7479 6c65 6

    │ │ │ -00066d20: 0909 7265 7475 726e 207b 7d3b 0a23 656c  ..return {};.#el
    │ │ │ -00066d30: 7365 0a09 0963 6861 7220 7265 745b 3430  se...char ret[40
    │ │ │ -00066d40: 305d 3b0a 0909 7374 643a 3a73 6e70 7269  0];...std::snpri
    │ │ │ -00066d50: 6e74 6628 7265 742c 2073 697a 656f 6628  ntf(ret, sizeof(
    │ │ │ -00066d60: 7265 7429 2c20 2225 7320 2573 2073 6372  ret), "%s %s scr
    │ │ │ -00066d70: 6170 6520 7265 706c 793a 2025 6420 2564  ape reply: %d %d
    │ │ │ -00066d80: 220a 0909 092c 2074 7261 636b 6572 5f61  "...., tracker_a
    │ │ │ -00066d90: 6c65 7274 3a3a 6d65 7373 6167 6528 292e  lert::message().
    │ │ │ -00066da0: 635f 7374 7228 290a 0909 092c 2076 6572  c_str()...., ver
    │ │ │ -00066db0: 7369 6f6e 203d 3d20 7072 6f74 6f63 6f6c  sion == protocol
    │ │ │ -00066dc0: 5f76 6572 7369 6f6e 3a3a 5631 203f 2022  _version::V1 ? "
    │ │ │ -00066dd0: 7631 2220 3a20 2276 3222 0a09 0909 2c20  v1" : "v2"...., 
    │ │ │ -00066de0: 696e 636f 6d70 6c65 7465 2c20 636f 6d70  incomplete, comp
    │ │ │ -00066df0: 6c65 7465 293b 0a09 0972 6574 7572 6e20  lete);...return 
    │ │ │ -00066e00: 7265 743b 0a23 656e 6469 660a 097d 0a0a  ret;.#endif..}..
    │ │ │ -00066e10: 0973 6372 6170 655f 6661 696c 6564 5f61  .scrape_failed_a
    │ │ │ -00066e20: 6c65 7274 3a3a 7363 7261 7065 5f66 6169  lert::scrape_fai
    │ │ │ -00066e30: 6c65 645f 616c 6572 7428 6175 783a 3a73  led_alert(aux::s
    │ │ │ -00066e40: 7461 636b 5f61 6c6c 6f63 6174 6f72 2661  tack_allocator&a
    │ │ │ -00066e50: 6d70 3b20 616c 6c6f 630a 0909 2c20 746f  mp; alloc..., to
    │ │ │ -00066e60: 7272 656e 745f 6861 6e64 6c65 2063 6f6e  rrent_handle con
    │ │ │ -00066e70: 7374 2661 6d70 3b20 682c 2074 6370 3a3a  st& h, tcp::
    │ │ │ -00066e80: 656e 6470 6f69 6e74 2063 6f6e 7374 2661  endpoint const&a
    │ │ │ -00066e90: 6d70 3b20 6570 0a09 092c 2073 7472 696e  mp; ep..., strin
    │ │ │ -00066ea0: 675f 7669 6577 2075 2c20 7072 6f74 6f63  g_view u, protoc
    │ │ │ -00066eb0: 6f6c 5f76 6572 7369 6f6e 2063 6f6e 7374  ol_version const
    │ │ │ -00066ec0: 2076 2c20 6572 726f 725f 636f 6465 2063   v, error_code c
    │ │ │ -00066ed0: 6f6e 7374 2661 6d70 3b20 6529 0a09 093a  onst& e)...:
    │ │ │ -00066ee0: 2074 7261 636b 6572 5f61 6c65 7274 2861   tracker_alert(a
    │ │ │ -00066ef0: 6c6c 6f63 2c20 682c 2065 702c 2075 290a  lloc, h, ep, u).
    │ │ │ -00066f00: 0909 2c20 6572 726f 7228 6529 0a09 092c  .., error(e)...,
    │ │ │ -00066f10: 206d 5f6d 7367 5f69 6478 2829 0a23 6966   m_msg_idx().#if
    │ │ │ -00066f20: 2054 4f52 5245 4e54 5f41 4249 5f56 4552   TORRENT_ABI_VER
    │ │ │ -00066f30: 5349 4f4e 203d 3d20 310a 0909 2c20 6d73  SION == 1..., ms
    │ │ │ -00066f40: 6728 636f 6e76 6572 745f 6672 6f6d 5f6e  g(convert_from_n
    │ │ │ -00066f50: 6174 6976 6528 652e 6d65 7373 6167 6528  ative(e.message(
    │ │ │ -00066f60: 2929 290a 2365 6e64 6966 0a3c 6469 7620  ))).#endif.
    .., ver │ │ │ -00066fa0: 7369 6f6e 2876 290a 3c2f 6469 763e 097b sion(v).
    .{ │ │ │ -00066fb0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ -00066fc0: 5428 2175 2e65 6d70 7479 2829 293b 0a09 T(!u.empty());.. │ │ │ -00066fd0: 7d0a 0a09 7363 7261 7065 5f66 6169 6c65 }...scrape_faile │ │ │ -00066fe0: 645f 616c 6572 743a 3a73 6372 6170 655f d_alert::scrape_ │ │ │ -00066ff0: 6661 696c 6564 5f61 6c65 7274 2861 7578 failed_alert(aux │ │ │ -00067000: 3a3a 7374 6163 6b5f 616c 6c6f 6361 746f ::stack_allocato │ │ │ -00067010: 7226 616d 703b 2061 6c6c 6f63 0a09 092c r& alloc..., │ │ │ -00067020: 2074 6f72 7265 6e74 5f68 616e 646c 6520 torrent_handle │ │ │ -00067030: 636f 6e73 7426 616d 703b 2068 2c20 7463 const& h, tc │ │ │ -00067040: 703a 3a65 6e64 706f 696e 7420 636f 6e73 p::endpoint cons │ │ │ -00067050: 7426 616d 703b 2065 700a 0909 2c20 7374 t& ep..., st │ │ │ -00067060: 7269 6e67 5f76 6965 7720 752c 2073 7472 ring_view u, str │ │ │ -00067070: 696e 675f 7669 6577 206d 290a 0909 3a20 ing_view m)...: │ │ │ -00067080: 7472 6163 6b65 725f 616c 6572 7428 616c tracker_alert(al │ │ │ -00067090: 6c6f 632c 2068 2c20 6570 2c20 7529 0a09 loc, h, ep, u).. │ │ │ -000670a0: 092c 2065 7272 6f72 2865 7272 6f72 733a ., error(errors: │ │ │ -000670b0: 3a74 7261 636b 6572 5f66 6169 6c75 7265 :tracker_failure │ │ │ -000670c0: 290a 0909 2c20 6d5f 6d73 675f 6964 7828 )..., m_msg_idx( │ │ │ -000670d0: 616c 6c6f 632e 636f 7079 5f73 7472 696e alloc.copy_strin │ │ │ -000670e0: 6728 6d29 290a 2369 6620 544f 5252 454e g(m)).#if TORREN │ │ │ -000670f0: 545f 4142 495f 5645 5253 494f 4e20 3d3d T_ABI_VERSION == │ │ │ -00067100: 2031 0a09 092c 206d 7367 286d 290a 2365 1..., msg(m).#e │ │ │ -00067110: 6e64 6966 0a09 7b0a 0909 544f 5252 454e ndif..{...TORREN │ │ │ -00067120: 545f 4153 5345 5254 2821 752e 656d 7074 T_ASSERT(!u.empt │ │ │ -00067130: 7928 2929 3b0a 097d 0a0a 0963 6861 7220 y());..}...char │ │ │ -00067140: 636f 6e73 742a 2073 6372 6170 655f 6661 const* scrape_fa │ │ │ -00067150: 696c 6564 5f61 6c65 7274 3a3a 6572 726f iled_alert::erro │ │ │ -00067160: 725f 6d65 7373 6167 6528 2920 636f 6e73 r_message() cons │ │ │ -00067170: 740a 097b 0a09 0969 6620 286d 5f6d 7367 t..{...if (m_msg │ │ │ -00067180: 5f69 6478 203d 3d20 6175 783a 3a61 6c6c _idx == aux::all │ │ │ -00067190: 6f63 6174 696f 6e5f 736c 6f74 2829 2920 ocation_slot()) │ │ │ -000671a0: 7265 7475 726e 2022 223b 0a09 0965 6c73 return "";...els │ │ │ -000671b0: 6520 7265 7475 726e 206d 5f61 6c6c 6f63 e return m_alloc │ │ │ -000671c0: 2e67 6574 2829 2e70 7472 286d 5f6d 7367 .get().ptr(m_msg │ │ │ -000671d0: 5f69 6478 293b 0a09 7d0a 0a09 7374 643a _idx);..}...std: │ │ │ -000671e0: 3a73 7472 696e 6720 7363 7261 7065 5f66 :string scrape_f │ │ │ -000671f0: 6169 6c65 645f 616c 6572 743a 3a6d 6573 ailed_alert::mes │ │ │ -00067200: 7361 6765 2829 2063 6f6e 7374 0a09 7b0a sage() const..{. │ │ │ -00067210: 2369 6664 6566 2054 4f52 5245 4e54 5f44 #ifdef TORRENT_D │ │ │ -00067220: 4953 4142 4c45 5f41 4c45 5254 5f4d 5347 ISABLE_ALERT_MSG │ │ │ -00067230: 0a09 0972 6574 7572 6e20 7b7d 3b0a 2365 ...return {};.#e │ │ │ -00067240: 6c73 650a 0909 7265 7475 726e 2074 7261 lse...return tra │ │ │ -00067250: 636b 6572 5f61 6c65 7274 3a3a 6d65 7373 cker_alert::mess │ │ │ -00067260: 6167 6528 2920 2b20 2220 7363 7261 7065 age() + " scrape │ │ │ -00067270: 2066 6169 6c65 643a 2022 202b 2065 7272 failed: " + err │ │ │ -00067280: 6f72 5f6d 6573 7361 6765 2829 3b0a 2365 or_message();.#e │ │ │ -00067290: 6e64 6966 0a3c 2f70 7265 3e3c 2f74 643e ndif.
    │ │ │ -000672a0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -000672d0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -000672e0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -000672f0: 7074 3a65 7870 616e 6428 3233 3629 223e pt:expand(236)"> │ │ │ -00067300: 2e2e 2f73 7263 2f61 6c65 7274 2e63 7070 ../src/alert.cpp │ │ │ -00067310: 3a35 3135 3c2f 613e 3c2f 7464 3e3c 7464 :515move this field │ │ │ -00067330: 2069 6e74 6f20 7472 6163 6b65 725f 616c into tracker_al │ │ │ -00067340: 6572 743c 2f74 643e 3c2f 7472 3e3c 7472 ert

    move this field │ │ │ -000673a0: 2069 6e74 6f20 7472 6163 6b65 725f 616c into tracker_al │ │ │ -000673b0: 6572 743c 2f68 323e 3c68 343e 2e2e 2f73 ert

    ../s │ │ │ -000673c0: 7263 2f61 6c65 7274 2e63 7070 3a35 3135 rc/alert.cpp:515 │ │ │ -000673d0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00067410: 6368 6172 2063 6f6e 7374 2a20 7363 7261  char const* scra
    │ │ │ -00067420: 7065 5f66 6169 6c65 645f 616c 6572 743a  pe_failed_alert:
    │ │ │ -00067430: 3a65 7272 6f72 5f6d 6573 7361 6765 2829  :error_message()
    │ │ │ -00067440: 2063 6f6e 7374 0a09 7b0a 0909 6966 2028   const..{...if (
    │ │ │ -00067450: 6d5f 6d73 675f 6964 7820 3d3d 2061 7578  m_msg_idx == aux
    │ │ │ -00067460: 3a3a 616c 6c6f 6361 7469 6f6e 5f73 6c6f  ::allocation_slo
    │ │ │ -00067470: 7428 2929 2072 6574 7572 6e20 2222 3b0a  t()) return "";.
    │ │ │ -00067480: 0909 656c 7365 2072 6574 7572 6e20 6d5f  ..else return m_
    │ │ │ -00067490: 616c 6c6f 632e 6765 7428 292e 7074 7228  alloc.get().ptr(
    │ │ │ -000674a0: 6d5f 6d73 675f 6964 7829 3b0a 097d 0a0a  m_msg_idx);..}..
    │ │ │ -000674b0: 0973 7464 3a3a 7374 7269 6e67 2073 6372  .std::string scr
    │ │ │ -000674c0: 6170 655f 6661 696c 6564 5f61 6c65 7274  ape_failed_alert
    │ │ │ -000674d0: 3a3a 6d65 7373 6167 6528 2920 636f 6e73  ::message() cons
    │ │ │ -000674e0: 740a 097b 0a23 6966 6465 6620 544f 5252  t..{.#ifdef TORR
    │ │ │ -000674f0: 454e 545f 4449 5341 424c 455f 414c 4552  ENT_DISABLE_ALER
    │ │ │ -00067500: 545f 4d53 470a 0909 7265 7475 726e 207b  T_MSG...return {
    │ │ │ -00067510: 7d3b 0a23 656c 7365 0a09 0972 6574 7572  };.#else...retur
    │ │ │ -00067520: 6e20 7472 6163 6b65 725f 616c 6572 743a  n tracker_alert:
    │ │ │ -00067530: 3a6d 6573 7361 6765 2829 202b 2022 2073  :message() + " s
    │ │ │ -00067540: 6372 6170 6520 6661 696c 6564 3a20 2220  crape failed: " 
    │ │ │ -00067550: 2b20 6572 726f 725f 6d65 7373 6167 6528  + error_message(
    │ │ │ -00067560: 293b 0a23 656e 6469 660a 097d 0a0a 0974  );.#endif..}...t
    │ │ │ -00067570: 7261 636b 6572 5f72 6570 6c79 5f61 6c65  racker_reply_ale
    │ │ │ -00067580: 7274 3a3a 7472 6163 6b65 725f 7265 706c  rt::tracker_repl
    │ │ │ -00067590: 795f 616c 6572 7428 6175 783a 3a73 7461  y_alert(aux::sta
    │ │ │ -000675a0: 636b 5f61 6c6c 6f63 6174 6f72 2661 6d70  ck_allocator&
    │ │ │ -000675b0: 3b20 616c 6c6f 630a 0909 2c20 746f 7272  ; alloc..., torr
    │ │ │ -000675c0: 656e 745f 6861 6e64 6c65 2063 6f6e 7374  ent_handle const
    │ │ │ -000675d0: 2661 6d70 3b20 682c 2074 6370 3a3a 656e  & h, tcp::en
    │ │ │ -000675e0: 6470 6f69 6e74 2063 6f6e 7374 2661 6d70  dpoint const&
    │ │ │ -000675f0: 3b20 6570 0a09 092c 2069 6e74 206e 702c  ; ep..., int np,
    │ │ │ -00067600: 2070 726f 746f 636f 6c5f 7665 7273 696f   protocol_versio
    │ │ │ -00067610: 6e20 762c 2073 7472 696e 675f 7669 6577  n v, string_view
    │ │ │ -00067620: 2075 290a 0909 3a20 7472 6163 6b65 725f   u)...: tracker_
    │ │ │ -00067630: 616c 6572 7428 616c 6c6f 632c 2068 2c20  alert(alloc, h, 
    │ │ │ -00067640: 6570 2c20 7529 0a09 092c 206e 756d 5f70  ep, u)..., num_p
    │ │ │ -00067650: 6565 7273 286e 7029 0a3c 6469 7620 7374  eers(np).
    .., versi │ │ │ -00067690: 6f6e 2876 290a 3c2f 6469 763e 097b 0a09 on(v).
    .{.. │ │ │ -000676a0: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -000676b0: 2175 2e65 6d70 7479 2829 293b 0a09 7d0a !u.empty());..}. │ │ │ -000676c0: 0a09 7374 643a 3a73 7472 696e 6720 7472 ..std::string tr │ │ │ -000676d0: 6163 6b65 725f 7265 706c 795f 616c 6572 acker_reply_aler │ │ │ -000676e0: 743a 3a6d 6573 7361 6765 2829 2063 6f6e t::message() con │ │ │ -000676f0: 7374 0a09 7b0a 2369 6664 6566 2054 4f52 st..{.#ifdef TOR │ │ │ -00067700: 5245 4e54 5f44 4953 4142 4c45 5f41 4c45 RENT_DISABLE_ALE │ │ │ -00067710: 5254 5f4d 5347 0a09 0972 6574 7572 6e20 RT_MSG...return │ │ │ -00067720: 7b7d 3b0a 2365 6c73 650a 0909 6368 6172 {};.#else...char │ │ │ -00067730: 2072 6574 5b34 3030 5d3b 0a09 0973 7464 ret[400];...std │ │ │ -00067740: 3a3a 736e 7072 696e 7466 2872 6574 2c20 ::snprintf(ret, │ │ │ -00067750: 7369 7a65 6f66 2872 6574 292c 2022 2573 sizeof(ret), "%s │ │ │ -00067760: 2025 7320 7265 6365 6976 6564 2070 6565 %s received pee │ │ │ -00067770: 7273 3a20 2564 220a 0909 092c 2074 7261 rs: %d"...., tra │ │ │ -00067780: 636b 6572 5f61 6c65 7274 3a3a 6d65 7373 cker_alert::mess │ │ │ -00067790: 6167 6528 292e 635f 7374 7228 290a 0909 age().c_str()... │ │ │ -000677a0: 092c 2076 6572 7369 6f6e 203d 3d20 7072 ., version == pr │ │ │ -000677b0: 6f74 6f63 6f6c 5f76 6572 7369 6f6e 3a3a otocol_version:: │ │ │ -000677c0: 5631 203f 2022 7631 2220 3a20 2276 3222 V1 ? "v1" : "v2" │ │ │ -000677d0: 0a09 0909 2c20 6e75 6d5f 7065 6572 7329 ...., num_peers) │ │ │ -000677e0: 3b0a 0909 7265 7475 726e 2072 6574 3b0a ;...return ret;. │ │ │ -000677f0: 2365 6e64 6966 0a09 7d0a 0a09 6468 745f #endif..}...dht_ │ │ │ -00067800: 7265 706c 795f 616c 6572 743a 3a64 6874 reply_alert::dht │ │ │ -00067810: 5f72 6570 6c79 5f61 6c65 7274 2861 7578 _reply_alert(aux │ │ │ -00067820: 3a3a 7374 6163 6b5f 616c 6c6f 6361 746f ::stack_allocato │ │ │ -00067830: 7226 616d 703b 2061 6c6c 6f63 0a09 092c r& alloc..., │ │ │ -00067840: 2074 6f72 7265 6e74 5f68 616e 646c 6520 torrent_handle │ │ │ -00067850: 636f 6e73 7426 616d 703b 2068 0a09 092c const& h..., │ │ │ -00067860: 2069 6e74 206e 7029 0a09 093a 2074 7261 int np)...: tra │ │ │ -00067870: 636b 6572 5f61 6c65 7274 2861 6c6c 6f63 cker_alert(alloc │ │ │ -00067880: 2c20 682c 207b 7d2c 2022 2229 0a09 092c , h, {}, "")..., │ │ │ -00067890: 206e 756d 5f70 6565 7273 286e 7029 0a09 num_peers(np).. │ │ │ -000678a0: 7b7d 0a0a 0973 7464 3a3a 7374 7269 6e67 {}...std::string │ │ │ -000678b0: 2064 6874 5f72 6570 6c79 5f61 6c65 7274 dht_reply_alert │ │ │ -000678c0: 3a3a 6d65 7373 6167 6528 2920 636f 6e73 ::message() cons │ │ │ -000678d0: 740a 097b 0a23 6966 6465 6620 544f 5252 t..{.#ifdef TORR │ │ │ -000678e0: 454e 545f 4449 5341 424c 455f 414c 4552 ENT_DISABLE_ALER │ │ │ -000678f0: 545f 4d53 470a 0909 7265 7475 726e 207b T_MSG...return { │ │ │ -00067900: 7d3b 0a23 656c 7365 0a3c 2f70 7265 3e3c };.#else.
    < │ │ │ -00067910: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00067940: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00067950: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/alert │ │ │ -00067980: 2e63 7070 3a35 3539 3c2f 613e 3c2f 7464 .cpp:559move this t │ │ │ -000679a0: 6f20 7472 6163 6b65 725f 616c 6572 743c o tracker_alert< │ │ │ -000679b0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    mov │ │ │ -00067a00: 6520 7468 6973 2074 6f20 7472 6163 6b65 e this to tracke │ │ │ -00067a10: 725f 616c 6572 743c 2f68 323e 3c68 343e r_alert

    │ │ │ -00067a20: 2e2e 2f73 7263 2f61 6c65 7274 2e63 7070 ../src/alert.cpp │ │ │ -00067a30: 3a35 3539 3c2f 6834 3e3c 7072 6520 7374 :559

    .., num_peers
    │ │ │ -00067a80: 286e 7029 0a09 7b7d 0a0a 0973 7464 3a3a  (np)..{}...std::
    │ │ │ -00067a90: 7374 7269 6e67 2064 6874 5f72 6570 6c79  string dht_reply
    │ │ │ -00067aa0: 5f61 6c65 7274 3a3a 6d65 7373 6167 6528  _alert::message(
    │ │ │ -00067ab0: 2920 636f 6e73 740a 097b 0a23 6966 6465  ) const..{.#ifde
    │ │ │ -00067ac0: 6620 544f 5252 454e 545f 4449 5341 424c  f TORRENT_DISABL
    │ │ │ -00067ad0: 455f 414c 4552 545f 4d53 470a 0909 7265  E_ALERT_MSG...re
    │ │ │ -00067ae0: 7475 726e 207b 7d3b 0a23 656c 7365 0a09  turn {};.#else..
    │ │ │ -00067af0: 0963 6861 7220 7265 745b 3430 305d 3b0a  .char ret[400];.
    │ │ │ -00067b00: 0909 7374 643a 3a73 6e70 7269 6e74 6628  ..std::snprintf(
    │ │ │ -00067b10: 7265 742c 2073 697a 656f 6628 7265 7429  ret, sizeof(ret)
    │ │ │ -00067b20: 2c20 2225 7320 7265 6365 6976 6564 2044  , "%s received D
    │ │ │ -00067b30: 4854 2070 6565 7273 3a20 2564 220a 0909  HT peers: %d"...
    │ │ │ -00067b40: 092c 2074 7261 636b 6572 5f61 6c65 7274  ., tracker_alert
    │ │ │ -00067b50: 3a3a 6d65 7373 6167 6528 292e 635f 7374  ::message().c_st
    │ │ │ -00067b60: 7228 292c 206e 756d 5f70 6565 7273 293b  r(), num_peers);
    │ │ │ -00067b70: 0a09 0972 6574 7572 6e20 7265 743b 0a23  ...return ret;.#
    │ │ │ -00067b80: 656e 6469 660a 097d 0a0a 0974 7261 636b  endif..}...track
    │ │ │ -00067b90: 6572 5f61 6e6e 6f75 6e63 655f 616c 6572  er_announce_aler
    │ │ │ -00067ba0: 743a 3a74 7261 636b 6572 5f61 6e6e 6f75  t::tracker_annou
    │ │ │ -00067bb0: 6e63 655f 616c 6572 7428 6175 783a 3a73  nce_alert(aux::s
    │ │ │ -00067bc0: 7461 636b 5f61 6c6c 6f63 6174 6f72 2661  tack_allocator&a
    │ │ │ -00067bd0: 6d70 3b20 616c 6c6f 630a 0909 2c20 746f  mp; alloc..., to
    │ │ │ -00067be0: 7272 656e 745f 6861 6e64 6c65 2063 6f6e  rrent_handle con
    │ │ │ -00067bf0: 7374 2661 6d70 3b20 682c 2074 6370 3a3a  st& h, tcp::
    │ │ │ -00067c00: 656e 6470 6f69 6e74 2063 6f6e 7374 2661  endpoint const&a
    │ │ │ -00067c10: 6d70 3b20 6570 2c20 7374 7269 6e67 5f76  mp; ep, string_v
    │ │ │ -00067c20: 6965 7720 750a 0909 2c20 7072 6f74 6f63  iew u..., protoc
    │ │ │ -00067c30: 6f6c 5f76 6572 7369 6f6e 2063 6f6e 7374  ol_version const
    │ │ │ -00067c40: 2076 2c20 6576 656e 745f 7420 636f 6e73   v, event_t cons
    │ │ │ -00067c50: 7420 6529 0a09 093a 2074 7261 636b 6572  t e)...: tracker
    │ │ │ -00067c60: 5f61 6c65 7274 2861 6c6c 6f63 2c20 682c  _alert(alloc, h,
    │ │ │ -00067c70: 2065 702c 2075 290a 0909 2c20 6576 656e   ep, u)..., even
    │ │ │ -00067c80: 7428 6529 0a3c 6469 7620 7374 796c 653d  t(e).
    .., version(v │ │ │ -00067cc0: 290a 3c2f 6469 763e 097b 0a09 0954 4f52 ).
    .{...TOR │ │ │ -00067cd0: 5245 4e54 5f41 5353 4552 5428 2175 2e65 RENT_ASSERT(!u.e │ │ │ -00067ce0: 6d70 7479 2829 293b 0a09 7d0a 0a09 7374 mpty());..}...st │ │ │ -00067cf0: 643a 3a73 7472 696e 6720 7472 6163 6b65 d::string tracke │ │ │ -00067d00: 725f 616e 6e6f 756e 6365 5f61 6c65 7274 r_announce_alert │ │ │ -00067d10: 3a3a 6d65 7373 6167 6528 2920 636f 6e73 ::message() cons │ │ │ -00067d20: 740a 097b 0a23 6966 6465 6620 544f 5252 t..{.#ifdef TORR │ │ │ -00067d30: 454e 545f 4449 5341 424c 455f 414c 4552 ENT_DISABLE_ALER │ │ │ -00067d40: 545f 4d53 470a 0909 7265 7475 726e 207b T_MSG...return { │ │ │ -00067d50: 7d3b 0a23 656c 7365 0a09 0973 7461 7469 };.#else...stati │ │ │ -00067d60: 6320 636f 6e73 7420 6368 6172 2a20 636f c const char* co │ │ │ -00067d70: 6e73 7420 6576 656e 745f 7374 725b 5d20 nst event_str[] │ │ │ -00067d80: 3d20 7b22 6e6f 6e65 222c 2022 636f 6d70 = {"none", "comp │ │ │ -00067d90: 6c65 7465 6422 2c20 2273 7461 7274 6564 leted", "started │ │ │ -00067da0: 222c 2022 7374 6f70 7065 6422 2c20 2270 ", "stopped", "p │ │ │ -00067db0: 6175 7365 6422 7d3b 0a09 0972 6574 7572 aused"};...retur │ │ │ -00067dc0: 6e20 7472 6163 6b65 725f 616c 6572 743a n tracker_alert: │ │ │ -00067dd0: 3a6d 6573 7361 6765 2829 0a09 0909 2b20 :message()....+ │ │ │ -00067de0: 2876 6572 7369 6f6e 203d 3d20 7072 6f74 (version == prot │ │ │ -00067df0: 6f63 6f6c 5f76 6572 7369 6f6e 3a3a 5631 ocol_version::V1 │ │ │ -00067e00: 203f 2022 2076 3122 203a 2022 2076 3222 ? " v1" : " v2" │ │ │ -00067e10: 290a 0909 092b 2022 2073 656e 6469 6e67 )....+ " sending │ │ │ -00067e20: 2061 6e6e 6f75 6e63 6520 2822 202b 2065 announce (" + e │ │ │ -00067e30: 7665 6e74 5f73 7472 5b73 7461 7469 635f vent_str[static_ │ │ │ -00067e40: 6361 7374 266c 743b 696e 7426 6774 3b28 cast<int>( │ │ │ -00067e50: 6576 656e 7429 5d20 2b20 2229 223b 0a23 event)] + ")";.# │ │ │ -00067e60: 656e 6469 660a 097d 0a0a 0968 6173 685f endif..}...hash_ │ │ │ -00067e70: 6661 696c 6564 5f61 6c65 7274 3a3a 6861 failed_alert::ha │ │ │ -00067e80: 7368 5f66 6169 6c65 645f 616c 6572 7428 sh_failed_alert( │ │ │ -00067e90: 0a09 0961 7578 3a3a 7374 6163 6b5f 616c ...aux::stack_al │ │ │ -00067ea0: 6c6f 6361 746f 7226 616d 703b 2061 6c6c locator& all │ │ │ -00067eb0: 6f63 0a09 092c 2074 6f72 7265 6e74 5f68 oc..., torrent_h │ │ │ -00067ec0: 616e 646c 6520 636f 6e73 7426 616d 703b andle const& │ │ │ -00067ed0: 2068 0a09 092c 2070 6965 6365 5f69 6e64 h..., piece_ind │ │ │ -00067ee0: 6578 5f74 2069 6e64 6578 290a 0909 3a20 ex_t index)...: │ │ │ -00067ef0: 746f 7272 656e 745f 616c 6572 7428 616c torrent_alert(al │ │ │ -00067f00: 6c6f 632c 2068 290a 0909 2c20 7069 6563 loc, h)..., piec │ │ │ -00067f10: 655f 696e 6465 7828 696e 6465 7829 0a09 e_index(index).. │ │ │ -00067f20: 7b0a 0909 544f 5252 454e 545f 4153 5345 {...TORRENT_ASSE │ │ │ -00067f30: 5254 2869 6e64 6578 2026 6774 3b3d 2070 RT(index >= p │ │ │ -00067f40: 6965 6365 5f69 6e64 6578 5f74 2830 2929 iece_index_t(0)) │ │ │ -00067f50: 3b0a 097d 0a0a 0973 7464 3a3a 7374 7269 ;..}...std::stri │ │ │ -00067f60: 6e67 2068 6173 685f 6661 696c 6564 5f61 ng hash_failed_a │ │ │ -00067f70: 6c65 7274 3a3a 6d65 7373 6167 6528 2920 lert::message() │ │ │ -00067f80: 636f 6e73 740a 097b 0a23 6966 6465 6620 const..{.#ifdef │ │ │ -00067f90: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -00067fa0: 414c 4552 545f 4d53 470a 0909 7265 7475 ALERT_MSG...retu │ │ │ -00067fb0: 726e 207b 7d3b 0a3c 2f70 7265 3e3c 2f74 rn {};.
    relevanc │ │ │ -00067ff0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/add_tor │ │ │ -00068030: 7265 6e74 5f70 6172 616d 732e 6370 703a rent_params.cpp: │ │ │ -00068040: 3738 3c2f 613e 3c2f 7464 3e3c 7464 3e70 78p │ │ │ -00068050: 7265 2043 2b2b 3137 2c20 4743 4320 616e re C++17, GCC an │ │ │ -00068060: 6420 6d73 7663 2064 6f65 7320 6e6f 7420 d msvc does not │ │ │ -00068070: 6d61 6b65 2073 7464 3a3a 7374 7269 6e67 make std::string │ │ │ -00068080: 206e 6f74 6872 6f77 206d 6f76 6520 6173 nothrow move as │ │ │ -00068090: 7369 676e 6162 6c65 2c20 7768 6963 6820 signable, which │ │ │ -000680a0: 6d65 616e 7320 6e6f 2074 7970 6520 636f means no type co │ │ │ -000680b0: 6e74 6169 6e69 6e67 2061 2073 7472 696e ntaining a strin │ │ │ -000680c0: 6720 7769 6c6c 2062 6520 6e6f 7468 726f g will be nothro │ │ │ -000680d0: 7720 6d6f 7665 2061 7373 6967 6e61 626c w move assignabl │ │ │ -000680e0: 6520 6279 2064 6566 6175 6c74 2065 6974 e by default eit │ │ │ -000680f0: 6865 7220 7374 6174 6963 5f61 7373 6572 her static_asser │ │ │ -00068100: 7428 7374 643a 3a69 735f 6e6f 7468 726f t(std::is_nothro │ │ │ -00068110: 775f 6d6f 7665 5f61 7373 6967 6e61 626c w_move_assignabl │ │ │ -00068120: 653c 6164 645f 746f 7272 656e 745f 7061 e::value , " │ │ │ -00068140: 7368 6f75 6c64 2062 6520 6e6f 7468 726f should be nothro │ │ │ -00068150: 7720 6d6f 7665 2061 7373 6967 6e61 626c w move assignabl │ │ │ -00068160: 6522 293b 3c2f 7464 3e3c 2f74 723e 3c74 e");pre C++17, GCC │ │ │ -000681c0: 2061 6e64 206d 7376 6320 646f 6573 206e and msvc does n │ │ │ -000681d0: 6f74 206d 616b 6520 7374 643a 3a73 7472 ot make std::str │ │ │ -000681e0: 696e 6720 6e6f 7468 726f 7720 6d6f 7665 ing nothrow move │ │ │ -000681f0: 0a61 7373 6967 6e61 626c 652c 2077 6869 .assignable, whi │ │ │ -00068200: 6368 206d 6561 6e73 206e 6f20 7479 7065 ch means no type │ │ │ -00068210: 2063 6f6e 7461 696e 696e 6720 6120 7374 containing a st │ │ │ -00068220: 7269 6e67 2077 696c 6c20 6265 206e 6f74 ring will be not │ │ │ -00068230: 6872 6f77 206d 6f76 650a 6173 7369 676e hrow move.assign │ │ │ -00068240: 6162 6c65 2062 7920 6465 6661 756c 7420 able by default │ │ │ -00068250: 6569 7468 6572 0a73 7461 7469 635f 6173 either.static_as │ │ │ -00068260: 7365 7274 2873 7464 3a3a 6973 5f6e 6f74 sert(std::is_not │ │ │ -00068270: 6872 6f77 5f6d 6f76 655f 6173 7369 676e hrow_move_assign │ │ │ -00068280: 6162 6c65 3c61 6464 5f74 6f72 7265 6e74 able::value. │ │ │ -000682a0: 2c20 2273 686f 756c 6420 6265 206e 6f74 , "should be not │ │ │ -000682b0: 6872 6f77 206d 6f76 6520 6173 7369 676e hrow move assign │ │ │ -000682c0: 6162 6c65 2229 3b3c 2f68 323e 3c68 343e able");

    │ │ │ -000682d0: 2e2e 2f73 7263 2f61 6464 5f74 6f72 7265 ../src/add_torre │ │ │ -000682e0: 6e74 5f70 6172 616d 732e 6370 703a 3738 nt_params.cpp:78 │ │ │ -000682f0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00068330: 0909 4445 434c 5f46 4c41 4728 7365 7175  ..DECL_FLAG(sequ
    │ │ │ -00068340: 656e 7469 616c 5f64 6f77 6e6c 6f61 6429  ential_download)
    │ │ │ -00068350: 3b0a 0909 0944 4543 4c5f 464c 4147 2870  ;....DECL_FLAG(p
    │ │ │ -00068360: 696e 6e65 6429 3b0a 0909 0944 4543 4c5f  inned);....DECL_
    │ │ │ -00068370: 464c 4147 2873 746f 705f 7768 656e 5f72  FLAG(stop_when_r
    │ │ │ -00068380: 6561 6479 293b 0a09 0909 4445 434c 5f46  eady);....DECL_F
    │ │ │ -00068390: 4c41 4728 6f76 6572 7269 6465 5f74 7261  LAG(override_tra
    │ │ │ -000683a0: 636b 6572 7329 3b0a 0909 0944 4543 4c5f  ckers);....DECL_
    │ │ │ -000683b0: 464c 4147 286f 7665 7272 6964 655f 7765  FLAG(override_we
    │ │ │ -000683c0: 625f 7365 6564 7329 3b0a 0909 0944 4543  b_seeds);....DEC
    │ │ │ -000683d0: 4c5f 464c 4147 286e 6565 645f 7361 7665  L_FLAG(need_save
    │ │ │ -000683e0: 5f72 6573 756d 6529 3b0a 0909 0944 4543  _resume);....DEC
    │ │ │ -000683f0: 4c5f 464c 4147 286f 7665 7272 6964 655f  L_FLAG(override_
    │ │ │ -00068400: 7265 7375 6d65 5f64 6174 6129 3b0a 0909  resume_data);...
    │ │ │ -00068410: 0944 4543 4c5f 464c 4147 286d 6572 6765  .DECL_FLAG(merge
    │ │ │ -00068420: 5f72 6573 756d 655f 7472 6163 6b65 7273  _resume_trackers
    │ │ │ -00068430: 293b 0a09 0909 4445 434c 5f46 4c41 4728  );....DECL_FLAG(
    │ │ │ -00068440: 7573 655f 7265 7375 6d65 5f73 6176 655f  use_resume_save_
    │ │ │ -00068450: 7061 7468 293b 0a09 0909 4445 434c 5f46  path);....DECL_F
    │ │ │ -00068460: 4c41 4728 6d65 7267 655f 7265 7375 6d65  LAG(merge_resume
    │ │ │ -00068470: 5f68 7474 705f 7365 6564 7329 3b0a 0909  _http_seeds);...
    │ │ │ -00068480: 0944 4543 4c5f 464c 4147 2864 6566 6175  .DECL_FLAG(defau
    │ │ │ -00068490: 6c74 5f66 6c61 6773 293b 0a23 756e 6465  lt_flags);.#unde
    │ │ │ -000684a0: 6620 4445 434c 5f46 4c41 470a 2365 6e64  f DECL_FLAG.#end
    │ │ │ -000684b0: 6966 202f 2f20 544f 5252 454e 545f 4142  if // TORRENT_AB
    │ │ │ -000684c0: 495f 5645 5253 494f 4e0a 0a09 7374 6174  I_VERSION...stat
    │ │ │ -000684d0: 6963 5f61 7373 6572 7428 7374 643a 3a69  ic_assert(std::i
    │ │ │ -000684e0: 735f 6e6f 7468 726f 775f 6d6f 7665 5f63  s_nothrow_move_c
    │ │ │ -000684f0: 6f6e 7374 7275 6374 6962 6c65 266c 743b  onstructible<
    │ │ │ -00068500: 6164 645f 746f 7272 656e 745f 7061 7261  add_torrent_para
    │ │ │ -00068510: 6d73 2667 743b 3a3a 7661 6c75 650a 0909  ms>::value...
    │ │ │ -00068520: 2c20 2273 686f 756c 6420 6265 206e 6f74  , "should be not
    │ │ │ -00068530: 6872 6f77 206d 6f76 6520 636f 6e73 7472  hrow move constr
    │ │ │ -00068540: 7563 7469 626c 6522 293b 0a0a 0973 7461  uctible");...sta
    │ │ │ -00068550: 7469 635f 6173 7365 7274 2873 7464 3a3a  tic_assert(std::
    │ │ │ -00068560: 6973 5f6e 6f74 6872 6f77 5f6d 6f76 655f  is_nothrow_move_
    │ │ │ -00068570: 636f 6e73 7472 7563 7469 626c 6526 6c74  constructible<
    │ │ │ -00068580: 3b73 7464 3a3a 7374 7269 6e67 2667 743b  ;std::string>
    │ │ │ -00068590: 3a3a 7661 6c75 650a 0909 2c20 2273 686f  ::value..., "sho
    │ │ │ -000685a0: 756c 6420 6265 206e 6f74 6872 6f77 206d  uld be nothrow m
    │ │ │ -000685b0: 6f76 6520 636f 6e73 7472 7563 7469 626c  ove constructibl
    │ │ │ -000685c0: 6522 293b 0a0a 3c64 6976 2073 7479 6c65  e");..
    .
    rele │ │ │ -00068630: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/add │ │ │ -00068670: 5f74 6f72 7265 6e74 5f70 6172 616d 732e _torrent_params. │ │ │ -00068680: 6370 703a 3834 3c2f 613e 3c2f 7464 3e3c cpp:84< │ │ │ -00068690: 7464 3e69 7420 776f 756c 6420 6265 206e td>it would be n │ │ │ -000686a0: 6963 6520 6966 2074 6869 7320 7761 7320 ice if this was │ │ │ -000686b0: 6e6f 7468 726f 7720 6465 6661 756c 7420 nothrow default │ │ │ -000686c0: 636f 6e73 7472 7563 7469 626c 6520 7374 constructible st │ │ │ -000686d0: 6174 6963 5f61 7373 6572 7428 7374 643a atic_assert(std: │ │ │ -000686e0: 3a69 735f 6e6f 7468 726f 775f 6465 6661 :is_nothrow_defa │ │ │ -000686f0: 756c 745f 636f 6e73 7472 7563 7469 626c ult_constructibl │ │ │ -00068700: 653c 6164 645f 746f 7272 656e 745f 7061 e::value , " │ │ │ -00068720: 7368 6f75 6c64 2062 6520 6e6f 7468 726f should be nothro │ │ │ -00068730: 7720 6465 6661 756c 7420 636f 6e73 7472 w default constr │ │ │ -00068740: 7563 7469 626c 6522 293b 3c2f 7464 3e3c uctible");< │ │ │ -00068750: 2f74 723e 3c74 7220 6964 3d22 3233 3922 /tr>

    it would │ │ │ -000687a0: 2062 6520 6e69 6365 2069 6620 7468 6973 be nice if this │ │ │ -000687b0: 2077 6173 206e 6f74 6872 6f77 2064 6566 was nothrow def │ │ │ -000687c0: 6175 6c74 2063 6f6e 7374 7275 6374 6962 ault constructib │ │ │ -000687d0: 6c65 0a73 7461 7469 635f 6173 7365 7274 le.static_assert │ │ │ -000687e0: 2873 7464 3a3a 6973 5f6e 6f74 6872 6f77 (std::is_nothrow │ │ │ -000687f0: 5f64 6566 6175 6c74 5f63 6f6e 7374 7275 _default_constru │ │ │ -00068800: 6374 6962 6c65 3c61 6464 5f74 6f72 7265 ctible::valu │ │ │ -00068820: 650a 2c20 2273 686f 756c 6420 6265 206e e., "should be n │ │ │ -00068830: 6f74 6872 6f77 2064 6566 6175 6c74 2063 othrow default c │ │ │ -00068840: 6f6e 7374 7275 6374 6962 6c65 2229 3b3c onstructible");< │ │ │ -00068850: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f61 /h2>

    ../src/a │ │ │ -00068860: 6464 5f74 6f72 7265 6e74 5f70 6172 616d dd_torrent_param │ │ │ -00068870: 732e 6370 703a 3834 3c2f 6834 3e3c 7072 s.cpp:84

    ...DECL_F │ │ │ -000688c0: 4c41 4728 7069 6e6e 6564 293b 0a09 0909 LAG(pinned);.... │ │ │ -000688d0: 4445 434c 5f46 4c41 4728 7374 6f70 5f77 DECL_FLAG(stop_w │ │ │ -000688e0: 6865 6e5f 7265 6164 7929 3b0a 0909 0944 hen_ready);....D │ │ │ -000688f0: 4543 4c5f 464c 4147 286f 7665 7272 6964 ECL_FLAG(overrid │ │ │ -00068900: 655f 7472 6163 6b65 7273 293b 0a09 0909 e_trackers);.... │ │ │ -00068910: 4445 434c 5f46 4c41 4728 6f76 6572 7269 DECL_FLAG(overri │ │ │ -00068920: 6465 5f77 6562 5f73 6565 6473 293b 0a09 de_web_seeds);.. │ │ │ -00068930: 0909 4445 434c 5f46 4c41 4728 6e65 6564 ..DECL_FLAG(need │ │ │ -00068940: 5f73 6176 655f 7265 7375 6d65 293b 0a09 _save_resume);.. │ │ │ -00068950: 0909 4445 434c 5f46 4c41 4728 6f76 6572 ..DECL_FLAG(over │ │ │ -00068960: 7269 6465 5f72 6573 756d 655f 6461 7461 ride_resume_data │ │ │ -00068970: 293b 0a09 0909 4445 434c 5f46 4c41 4728 );....DECL_FLAG( │ │ │ -00068980: 6d65 7267 655f 7265 7375 6d65 5f74 7261 merge_resume_tra │ │ │ -00068990: 636b 6572 7329 3b0a 0909 0944 4543 4c5f ckers);....DECL_ │ │ │ -000689a0: 464c 4147 2875 7365 5f72 6573 756d 655f FLAG(use_resume_ │ │ │ -000689b0: 7361 7665 5f70 6174 6829 3b0a 0909 0944 save_path);....D │ │ │ -000689c0: 4543 4c5f 464c 4147 286d 6572 6765 5f72 ECL_FLAG(merge_r │ │ │ -000689d0: 6573 756d 655f 6874 7470 5f73 6565 6473 esume_http_seeds │ │ │ -000689e0: 293b 0a09 0909 4445 434c 5f46 4c41 4728 );....DECL_FLAG( │ │ │ -000689f0: 6465 6661 756c 745f 666c 6167 7329 3b0a default_flags);. │ │ │ -00068a00: 2375 6e64 6566 2044 4543 4c5f 464c 4147 #undef DECL_FLAG │ │ │ -00068a10: 0a23 656e 6469 6620 2f2f 2054 4f52 5245 .#endif // TORRE │ │ │ -00068a20: 4e54 5f41 4249 5f56 4552 5349 4f4e 0a0a NT_ABI_VERSION.. │ │ │ -00068a30: 0973 7461 7469 635f 6173 7365 7274 2873 .static_assert(s │ │ │ -00068a40: 7464 3a3a 6973 5f6e 6f74 6872 6f77 5f6d td::is_nothrow_m │ │ │ -00068a50: 6f76 655f 636f 6e73 7472 7563 7469 626c ove_constructibl │ │ │ -00068a60: 6526 6c74 3b61 6464 5f74 6f72 7265 6e74 e<add_torrent │ │ │ -00068a70: 5f70 6172 616d 7326 6774 3b3a 3a76 616c _params>::val │ │ │ -00068a80: 7565 0a09 092c 2022 7368 6f75 6c64 2062 ue..., "should b │ │ │ -00068a90: 6520 6e6f 7468 726f 7720 6d6f 7665 2063 e nothrow move c │ │ │ -00068aa0: 6f6e 7374 7275 6374 6962 6c65 2229 3b0a onstructible");. │ │ │ -00068ab0: 0a09 7374 6174 6963 5f61 7373 6572 7428 ..static_assert( │ │ │ -00068ac0: 7374 643a 3a69 735f 6e6f 7468 726f 775f std::is_nothrow_ │ │ │ -00068ad0: 6d6f 7665 5f63 6f6e 7374 7275 6374 6962 move_constructib │ │ │ -00068ae0: 6c65 266c 743b 7374 643a 3a73 7472 696e le<std::strin │ │ │ -00068af0: 6726 6774 3b3a 3a76 616c 7565 0a09 092c g>::value..., │ │ │ -00068b00: 2022 7368 6f75 6c64 2062 6520 6e6f 7468 "should be noth │ │ │ -00068b10: 726f 7720 6d6f 7665 2063 6f6e 7374 7275 row move constru │ │ │ -00068b20: 6374 6962 6c65 2229 3b0a 0a0a 3c64 6976 ctible");...
    .
    namespace aux { │ │ │ -00068b70: 0a0a 092f 2f20 7265 7475 726e 7320 7768 ...// returns wh │ │ │ -00068b80: 6574 6865 7220 7468 6973 2061 6464 5f74 ether this add_t │ │ │ -00068b90: 6f72 7265 6e74 5f70 6172 616d 7320 6f62 orrent_params ob │ │ │ -00068ba0: 6a65 6374 2068 6173 2022 7265 7375 6d65 ject has "resume │ │ │ -00068bb0: 2d64 6174 6122 2c20 692e 652e 0a09 2f2f -data", i.e...// │ │ │ -00068bc0: 2069 6e66 6f72 6d61 7469 6f6e 2061 626f information abo │ │ │ -00068bd0: 7574 2077 6869 6368 2070 6965 6365 7320 ut which pieces │ │ │ -00068be0: 7765 2068 6176 652e 0a09 626f 6f6c 2063 we have...bool c │ │ │ -00068bf0: 6f6e 7461 696e 735f 7265 7375 6d65 5f64 ontains_resume_d │ │ │ -00068c00: 6174 6128 6164 645f 746f 7272 656e 745f ata(add_torrent_ │ │ │ -00068c10: 7061 7261 6d73 2063 6f6e 7374 2661 6d70 params const& │ │ │ -00068c20: 3b20 6174 7029 0a09 7b0a 0909 7265 7475 ; atp)..{...retu │ │ │ -00068c30: 726e 2021 6174 702e 6861 7665 5f70 6965 rn !atp.have_pie │ │ │ -00068c40: 6365 732e 656d 7074 7928 290a 0909 097c ces.empty()....| │ │ │ -00068c50: 7c20 2861 7470 2e66 6c61 6773 2026 616d | (atp.flags &am │ │ │ -00068c60: 703b 2074 6f72 7265 6e74 5f66 6c61 6773 p; torrent_flags │ │ │ -00068c70: 3a3a 7365 6564 5f6d 6f64 6529 3b0a 097d ::seed_mode);..} │ │ │ -00068c80: 0a7d 0a0a 7d0a 3c2f 7072 653e 3c2f 7464 .}..}.

    │ │ │ +0003d7b0: 3c2f 7464 3e3c 7464 3e64 6570 7265 6361 depreca │ │ │ +0003d7c0: 7465 2074 6869 733c 2f74 643e 3c2f 7472 te this

    deprecate t │ │ │ +0003d820: 6869 733c 2f68 323e 3c68 343e 2e2e 2f73 his

    ../s │ │ │ +0003d830: 7263 2f73 6574 7469 6e67 735f 7061 636b rc/settings_pack │ │ │ +0003d840: 2e63 7070 3a33 3039 3c2f 6834 3e3c 7072 .cpp:309

    ..SET(out │ │ │ +0003d890: 676f 696e 675f 706f 7274 2c20 302c 206e going_port, 0, n │ │ │ +0003d8a0: 756c 6c70 7472 292c 0a09 0953 4554 286e ullptr),...SET(n │ │ │ +0003d8b0: 756d 5f6f 7574 676f 696e 675f 706f 7274 um_outgoing_port │ │ │ +0003d8c0: 732c 2030 2c20 6e75 6c6c 7074 7229 2c0a s, 0, nullptr),. │ │ │ +0003d8d0: 0909 5345 5428 7065 6572 5f64 7363 702c ..SET(peer_dscp, │ │ │ +0003d8e0: 2030 7830 312c 2026 616d 703b 7365 7373 0x01, &sess │ │ │ +0003d8f0: 696f 6e5f 696d 706c 3a3a 7570 6461 7465 ion_impl::update │ │ │ +0003d900: 5f70 6565 725f 6473 6370 292c 0a09 0953 _peer_dscp),...S │ │ │ +0003d910: 4554 2861 6374 6976 655f 646f 776e 6c6f ET(active_downlo │ │ │ +0003d920: 6164 732c 2033 2c20 2661 6d70 3b73 6573 ads, 3, &ses │ │ │ +0003d930: 7369 6f6e 5f69 6d70 6c3a 3a74 7269 6767 sion_impl::trigg │ │ │ +0003d940: 6572 5f61 7574 6f5f 6d61 6e61 6765 292c er_auto_manage), │ │ │ +0003d950: 0a09 0953 4554 2861 6374 6976 655f 7365 ...SET(active_se │ │ │ +0003d960: 6564 732c 2035 2c20 2661 6d70 3b73 6573 eds, 5, &ses │ │ │ +0003d970: 7369 6f6e 5f69 6d70 6c3a 3a74 7269 6767 sion_impl::trigg │ │ │ +0003d980: 6572 5f61 7574 6f5f 6d61 6e61 6765 292c er_auto_manage), │ │ │ +0003d990: 0a09 0953 4554 2861 6374 6976 655f 6368 ...SET(active_ch │ │ │ +0003d9a0: 6563 6b69 6e67 2c20 312c 2026 616d 703b ecking, 1, & │ │ │ +0003d9b0: 7365 7373 696f 6e5f 696d 706c 3a3a 7472 session_impl::tr │ │ │ +0003d9c0: 6967 6765 725f 6175 746f 5f6d 616e 6167 igger_auto_manag │ │ │ +0003d9d0: 6529 2c0a 0909 5345 5428 6163 7469 7665 e),...SET(active │ │ │ +0003d9e0: 5f64 6874 5f6c 696d 6974 2c20 3838 2c20 _dht_limit, 88, │ │ │ +0003d9f0: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428 nullptr),...SET( │ │ │ +0003da00: 6163 7469 7665 5f74 7261 636b 6572 5f6c active_tracker_l │ │ │ +0003da10: 696d 6974 2c20 3136 3030 2c20 6e75 6c6c imit, 1600, null │ │ │ +0003da20: 7074 7229 2c0a 0909 5345 5428 6163 7469 ptr),...SET(acti │ │ │ +0003da30: 7665 5f6c 7364 5f6c 696d 6974 2c20 3630 ve_lsd_limit, 60 │ │ │ +0003da40: 2c20 6e75 6c6c 7074 7229 2c0a 0909 5345 , nullptr),...SE │ │ │ +0003da50: 5428 6163 7469 7665 5f6c 696d 6974 2c20 T(active_limit, │ │ │ +0003da60: 3530 302c 2026 616d 703b 7365 7373 696f 500, &sessio │ │ │ +0003da70: 6e5f 696d 706c 3a3a 7472 6967 6765 725f n_impl::trigger_ │ │ │ +0003da80: 6175 746f 5f6d 616e 6167 6529 2c0a 0909 auto_manage),... │ │ │ +0003da90: 4445 5052 4543 4154 4544 5f53 4554 2861 DEPRECATED_SET(a │ │ │ +0003daa0: 6374 6976 655f 6c6f 6164 6564 5f6c 696d ctive_loaded_lim │ │ │ +0003dab0: 6974 2c20 302c 2026 616d 703b 7365 7373 it, 0, &sess │ │ │ +0003dac0: 696f 6e5f 696d 706c 3a3a 7472 6967 6765 ion_impl::trigge │ │ │ +0003dad0: 725f 6175 746f 5f6d 616e 6167 6529 2c0a r_auto_manage),. │ │ │ +0003dae0: 0909 5345 5428 6175 746f 5f6d 616e 6167 ..SET(auto_manag │ │ │ +0003daf0: 655f 696e 7465 7276 616c 2c20 3330 2c20 e_interval, 30, │ │ │ +0003db00: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428 nullptr),...SET( │ │ │ +0003db10: 7365 6564 5f74 696d 655f 6c69 6d69 742c seed_time_limit, │ │ │ +0003db20: 2032 3420 2a20 3630 202a 2036 302c 206e 24 * 60 * 60, n │ │ │ +0003db30: 756c 6c70 7472 292c 0a09 0953 4554 2861 ullptr),...SET(a │ │ │ +0003db40: 7574 6f5f 7363 7261 7065 5f69 6e74 6572 uto_scrape_inter │ │ │ +0003db50: 7661 6c2c 2031 3830 302c 206e 756c 6c70 val, 1800, nullp │ │ │ +0003db60: 7472 292c 0a09 0953 4554 2861 7574 6f5f tr),...SET(auto_ │ │ │ +0003db70: 7363 7261 7065 5f6d 696e 5f69 6e74 6572 scrape_min_inter │ │ │ +0003db80: 7661 6c2c 2033 3030 2c20 6e75 6c6c 7074 val, 300, nullpt │ │ │ +0003db90: 7229 2c0a 0909 5345 5428 6d61 785f 7065 r),...SET(max_pe │ │ │ +0003dba0: 6572 6c69 7374 5f73 697a 652c 2033 3030 erlist_size, 300 │ │ │ +0003dbb0: 302c 206e 756c 6c70 7472 292c 0a09 0953 0, nullptr),...S │ │ │ +0003dbc0: 4554 286d 6178 5f70 6175 7365 645f 7065 ET(max_paused_pe │ │ │ +0003dbd0: 6572 6c69 7374 5f73 697a 652c 2031 3030 erlist_size, 100 │ │ │ +0003dbe0: 302c 206e 756c 6c70 7472 292c 0a09 0953 0, nullptr),...S │ │ │ +0003dbf0: 4554 286d 696e 5f61 6e6e 6f75 6e63 655f ET(min_announce_ │ │ │ +0003dc00: 696e 7465 7276 616c 2c20 3520 2a20 3630 interval, 5 * 60 │ │ │ +0003dc10: 2c20 6e75 6c6c 7074 7229 2c0a 0909 5345 , nullptr),...SE │ │ │ +0003dc20: 5428 6175 746f 5f6d 616e 6167 655f 7374 T(auto_manage_st │ │ │ +0003dc30: 6172 7475 702c 2036 302c 206e 756c 6c70 artup, 60, nullp │ │ │ +0003dc40: 7472 292c 0a09 0953 4554 2873 6565 6469 tr),...SET(seedi │ │ │ +0003dc50: 6e67 5f70 6965 6365 5f71 756f 7461 2c20 ng_piece_quota, │ │ │ +0003dc60: 3230 2c20 6e75 6c6c 7074 7229 2c0a 3c64 20, nullptr),...SE │ │ │ +0003dca0: 5428 6d61 785f 7265 6a65 6374 732c 2035 T(max_rejects, 5 │ │ │ +0003dcb0: 302c 206e 756c 6c70 7472 292c 0a3c 2f64 0, nullptr),...SET(recv_so │ │ │ +0003dcd0: 636b 6574 5f62 7566 6665 725f 7369 7a65 cket_buffer_size │ │ │ +0003dce0: 2c20 302c 2026 616d 703b 7365 7373 696f , 0, &sessio │ │ │ +0003dcf0: 6e5f 696d 706c 3a3a 7570 6461 7465 5f73 n_impl::update_s │ │ │ +0003dd00: 6f63 6b65 745f 6275 6666 6572 5f73 697a ocket_buffer_siz │ │ │ +0003dd10: 6529 2c0a 0909 5345 5428 7365 6e64 5f73 e),...SET(send_s │ │ │ +0003dd20: 6f63 6b65 745f 6275 6666 6572 5f73 697a ocket_buffer_siz │ │ │ +0003dd30: 652c 2030 2c20 2661 6d70 3b73 6573 7369 e, 0, &sessi │ │ │ +0003dd40: 6f6e 5f69 6d70 6c3a 3a75 7064 6174 655f on_impl::update_ │ │ │ +0003dd50: 736f 636b 6574 5f62 7566 6665 725f 7369 socket_buffer_si │ │ │ +0003dd60: 7a65 292c 0a09 0953 4554 286d 6178 5f70 ze),...SET(max_p │ │ │ +0003dd70: 6565 725f 7265 6376 5f62 7566 6665 725f eer_recv_buffer_ │ │ │ +0003dd80: 7369 7a65 2c20 3220 2a20 3130 3234 202a size, 2 * 1024 * │ │ │ +0003dd90: 2031 3032 342c 206e 756c 6c70 7472 292c 1024, nullptr), │ │ │ +0003dda0: 0a09 0944 4550 5245 4341 5445 445f 5345 ...DEPRECATED_SE │ │ │ +0003ddb0: 5428 6669 6c65 5f63 6865 636b 735f 6465 T(file_checks_de │ │ │ +0003ddc0: 6c61 795f 7065 725f 626c 6f63 6b2c 2030 lay_per_block, 0 │ │ │ +0003ddd0: 2c20 6e75 6c6c 7074 7229 2c0a 0909 4445 , nullptr),...DE │ │ │ +0003dde0: 5052 4543 4154 4544 325f 5345 5428 7265 PRECATED2_SET(re │ │ │ +0003ddf0: 6164 5f63 6163 6865 5f6c 696e 655f 7369 ad_cache_line_si │ │ │ +0003de00: 7a65 2c20 3332 2c20 6e75 6c6c 7074 7229 ze, 32, nullptr) │ │ │ +0003de10: 2c0a 0909 4445 5052 4543 4154 4544 325f ,...DEPRECATED2_ │ │ │ +0003de20: 5345 5428 7772 6974 655f 6361 6368 655f SET(write_cache_ │ │ │ +0003de30: 6c69 6e65 5f73 697a 652c 2031 362c 206e line_size, 16, n │ │ │ +0003de40: 756c 6c70 7472 292c 0a09 0953 4554 286f ullptr),...SET(o │ │ │ +0003de50: 7074 696d 6973 7469 635f 6469 736b 5f72 ptimistic_disk_r │ │ │ +0003de60: 6574 7279 2c20 3130 202a 2036 302c 206e etry, 10 * 60, n │ │ │ +0003de70: 756c 6c70 7472 292c 0a09 0953 4554 286d ullptr),...SET(m │ │ │ +0003de80: 6178 5f73 7567 6765 7374 5f70 6965 6365 ax_suggest_piece │ │ │ +0003de90: 732c 2031 362c 206e 756c 6c70 7472 292c s, 16, nullptr), │ │ │ +0003dea0: 0a09 0953 4554 286c 6f63 616c 5f73 6572 ...SET(local_ser │ │ │ +0003deb0: 7669 6365 5f61 6e6e 6f75 6e63 655f 696e vice_announce_in │ │ │ +0003dec0: 7465 7276 616c 2c20 3520 2a20 3630 2c20 terval, 5 * 60, │ │ │ +0003ded0: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428 nullptr),...SET( │ │ │ +0003dee0: 6468 745f 616e 6e6f 756e 6365 5f69 6e74 dht_announce_int │ │ │ +0003def0: 6572 7661 6c2c 2031 3520 2a20 3630 2c20 erval, 15 * 60, │ │ │ +0003df00: 2661 6d70 3b73 6573 7369 6f6e 5f69 6d70 &session_imp │ │ │ +0003df10: 6c3a 3a75 7064 6174 655f 6468 745f 616e l::update_dht_an │ │ │ +0003df20: 6e6f 756e 6365 5f69 6e74 6572 7661 6c29 nounce_interval) │ │ │ +0003df30: 2c0a 0909 5345 5428 7564 705f 7472 6163 ,...SET(udp_trac │ │ │ +0003df40: 6b65 725f 746f 6b65 6e5f 6578 7069 7279 ker_token_expiry │ │ │ +0003df50: 2c20 3630 2c20 6e75 6c6c 7074 7229 2c0a , 60, nullptr),. │ │ │ +0003df60: 0909 4445 5052 4543 4154 4544 5f53 4554 ..DEPRECATED_SET │ │ │ +0003df70: 2864 6566 6175 6c74 5f63 6163 6865 5f6d (default_cache_m │ │ │ +0003df80: 696e 5f61 6765 2c20 312c 206e 756c 6c70 in_age, 1, nullp │ │ │ +0003df90: 7472 292c 0a09 0953 4554 286e 756d 5f6f tr),...SET(num_o │ │ │ +0003dfa0: 7074 696d 6973 7469 635f 756e 6368 6f6b ptimistic_unchok │ │ │ +0003dfb0: 655f 736c 6f74 732c 2030 2c20 6e75 6c6c e_slots, 0, null │ │ │ +0003dfc0: 7074 7229 2c0a 0909 4445 5052 4543 4154 ptr),...DEPRECAT │ │ │ +0003dfd0: 4544 5f53 4554 2864 6566 6175 6c74 5f65 ED_SET(default_e │ │ │ +0003dfe0: 7374 5f72 6563 6970 726f 6361 7469 6f6e st_reciprocation │ │ │ +0003dff0: 5f72 6174 652c 2031 3630 3030 2c20 6e75 _rate, 16000, nu │ │ │ +0003e000: 6c6c 7074 7229 2c0a 0909 4445 5052 4543 llptr),...DEPREC │ │ │ +0003e010: 4154 4544 5f53 4554 2869 6e63 7265 6173 ATED_SET(increas │ │ │ +0003e020: 655f 6573 745f 7265 6369 7072 6f63 6174 e_est_reciprocat │ │ │ +0003e030: 696f 6e5f 7261 7465 2c20 3230 2c20 6e75 ion_rate, 20, nu │ │ │ +0003e040: 6c6c 7074 7229 2c0a 0909 4445 5052 4543 llptr),...DEPREC │ │ │ +0003e050: 4154 4544 5f53 4554 2864 6563 7265 6173 ATED_SET(decreas │ │ │ +0003e060: 655f 6573 745f 7265 6369 7072 6f63 6174 e_est_reciprocat │ │ │ +0003e070: 696f 6e5f 7261 7465 2c20 332c 206e 756c ion_rate, 3, nul │ │ │ +0003e080: 6c70 7472 292c 0a09 0953 4554 286d 6178 lptr),...SET(max │ │ │ +0003e090: 5f70 6578 5f70 6565 7273 2c20 3530 2c20 _pex_peers, 50, │ │ │ +0003e0a0: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428 nullptr),...SET( │ │ │ +0003e0b0: 7469 636b 5f69 6e74 6572 7661 6c2c 2035 tick_interval, 5 │ │ │ +0003e0c0: 3030 2c20 6e75 6c6c 7074 7229 2c0a 0909 00, nullptr),... │ │ │ +0003e0d0: 5345 5428 7368 6172 655f 6d6f 6465 5f74 SET(share_mode_t │ │ │ +0003e0e0: 6172 6765 742c 2033 2c20 6e75 6c6c 7074 arget, 3, nullpt │ │ │ +0003e0f0: 7229 2c0a 0909 5345 5428 7570 6c6f 6164 r),...SET(upload │ │ │ +0003e100: 5f72 6174 655f 6c69 6d69 742c 2030 2c20 _rate_limit, 0, │ │ │ +0003e110: 2661 6d70 3b73 6573 7369 6f6e 5f69 6d70 &session_imp │ │ │ +0003e120: 6c3a 3a75 7064 6174 655f 7570 6c6f 6164 l::update_upload │ │ │ +0003e130: 5f72 6174 6529 2c0a 0909 5345 5428 646f _rate),...SET(do │ │ │ +0003e140: 776e 6c6f 6164 5f72 6174 655f 6c69 6d69 wnload_rate_limi │ │ │ +0003e150: 742c 2030 2c20 2661 6d70 3b73 6573 7369 t, 0, &sessi │ │ │ +0003e160: 6f6e 5f69 6d70 6c3a 3a75 7064 6174 655f on_impl::update_ │ │ │ +0003e170: 646f 776e 6c6f 6164 5f72 6174 6529 2c0a download_rate),. │ │ │ +0003e180: 0909 4445 5052 4543 4154 4544 5f53 4554 ..DEPRECATED_SET │ │ │ +0003e190: 286c 6f63 616c 5f75 706c 6f61 645f 7261 (local_upload_ra │ │ │ +0003e1a0: 7465 5f6c 696d 6974 2c20 302c 2026 616d te_limit, 0, &am │ │ │ +0003e1b0: 703b 7365 7373 696f 6e5f 696d 706c 3a3a p;session_impl:: │ │ │ +0003e1c0: 7570 6461 7465 5f6c 6f63 616c 5f75 706c update_local_upl │ │ │ +0003e1d0: 6f61 645f 7261 7465 292c 0a09 0944 4550 oad_rate),...DEP │ │ │ +0003e1e0: 5245 4341 5445 445f 5345 5428 6c6f 6361 RECATED_SET(loca │ │ │ +0003e1f0: 6c5f 646f 776e 6c6f 6164 5f72 6174 655f l_download_rate_ │ │ │ +0003e200: 6c69 6d69 742c 2030 2c20 2661 6d70 3b73 limit, 0, &s │ │ │ +0003e210: 6573 7369 6f6e 5f69 6d70 6c3a 3a75 7064 ession_impl::upd │ │ │ +0003e220: 6174 655f 6c6f 6361 6c5f 646f 776e 6c6f ate_local_downlo │ │ │ +0003e230: 6164 5f72 6174 6529 2c0a 0909 5345 5428 ad_rate),...SET( │ │ │ +0003e240: 6468 745f 7570 6c6f 6164 5f72 6174 655f dht_upload_rate_ │ │ │ +0003e250: 6c69 6d69 742c 2038 3030 302c 2026 616d limit, 8000, &am │ │ │ +0003e260: 703b 7365 7373 696f 6e5f 696d 706c 3a3a p;session_impl:: │ │ │ +0003e270: 7570 6461 7465 5f64 6874 5f75 706c 6f61 update_dht_uploa │ │ │ +0003e280: 645f 7261 7465 5f6c 696d 6974 292c 0a09 d_rate_limit),.. │ │ │ +0003e290: 0953 4554 2875 6e63 686f 6b65 5f73 6c6f .SET(unchoke_slo │ │ │ +0003e2a0: 7473 5f6c 696d 6974 2c20 382c 2026 616d ts_limit, 8, &am │ │ │ +0003e2b0: 703b 7365 7373 696f 6e5f 696d 706c 3a3a p;session_impl:: │ │ │ +0003e2c0: 7570 6461 7465 5f75 6e63 686f 6b65 5f6c update_unchoke_l │ │ │ +0003e2d0: 696d 6974 292c 0a09 0944 4550 5245 4341 imit),...DEPRECA │ │ │ +0003e2e0: 5445 445f 5345 5428 6861 6c66 5f6f 7065 TED_SET(half_ope │ │ │ +0003e2f0: 6e5f 6c69 6d69 742c 2030 2c20 6e75 6c6c n_limit, 0, null │ │ │ +0003e300: 7074 7229 2c0a 0909 5345 5428 636f 6e6e ptr),...SET(conn │ │ │ +0003e310: 6563 7469 6f6e 735f 6c69 6d69 742c 2032 ections_limit, 2 │ │ │ +0003e320: 3030 2c20 2661 6d70 3b73 6573 7369 6f6e 00, &session │ │ │ +0003e330: 5f69 6d70 6c3a 3a75 7064 6174 655f 636f _impl::update_co │ │ │ +0003e340: 6e6e 6563 7469 6f6e 735f 6c69 6d69 7429 nnections_limit) │ │ │ +0003e350: 2c0a 0909 5345 5428 636f 6e6e 6563 7469 ,...SET(connecti │ │ │ +0003e360: 6f6e 735f 736c 6163 6b2c 2031 302c 206e ons_slack, 10, n │ │ │ +0003e370: 756c 6c70 7472 292c 0a09 0953 4554 2875 ullptr),...SET(u │ │ │ +0003e380: 7470 5f74 6172 6765 745f 6465 6c61 792c tp_target_delay, │ │ │ +0003e390: 2031 3030 2c20 6e75 6c6c 7074 7229 2c0a 100, nullptr),. │ │ │ +0003e3a0: 0909 5345 5428 7574 705f 6761 696e 5f66 ..SET(utp_gain_f │ │ │ +0003e3b0: 6163 746f 722c 2033 3030 302c 206e 756c actor, 3000, nul │ │ │ +0003e3c0: 6c70 7472 292c 0a3c 2f70 7265 3e3c 2f74 lptr),.
    relevanc │ │ │ +0003e400: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/setting │ │ │ +0003e440: 735f 7061 636b 2e63 7070 3a35 3937 3c2f s_pack.cpp:597it wo │ │ │ +0003e460: 756c 6420 6265 206e 6963 6520 746f 2072 uld be nice to r │ │ │ +0003e470: 6573 6572 7665 2829 2074 6865 7365 2076 eserve() these v │ │ │ +0003e480: 6563 746f 7273 2075 7020 6672 6f6e 743c ectors up front< │ │ │ +0003e490: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    it │ │ │ +0003e4e0: 776f 756c 6420 6265 206e 6963 6520 746f would be nice to │ │ │ +0003e4f0: 2072 6573 6572 7665 2829 2074 6865 7365 reserve() these │ │ │ +0003e500: 2076 6563 746f 7273 2075 7020 6672 6f6e vectors up fron │ │ │ +0003e510: 743c 2f68 323e 3c68 343e 2e2e 2f73 7263 t

    ../src │ │ │ +0003e520: 2f73 6574 7469 6e67 735f 7061 636b 2e63 /settings_pack.c │ │ │ +0003e530: 7070 3a35 3937 3c2f 6834 3e3c 7072 6520 pp:597

    ...s.set_st
    │ │ │ +0003e580: 7228 7365 7474 696e 6773 5f70 6163 6b3a  r(settings_pack:
    │ │ │ +0003e590: 3a73 7472 696e 675f 7479 7065 5f62 6173  :string_type_bas
    │ │ │ +0003e5a0: 6520 7c20 692c 2073 7472 5f73 6574 7469  e | i, str_setti
    │ │ │ +0003e5b0: 6e67 735b 695d 2e64 6566 6175 6c74 5f76  ngs[i].default_v
    │ │ │ +0003e5c0: 616c 7565 293b 0a09 0909 544f 5252 454e  alue);....TORREN
    │ │ │ +0003e5d0: 545f 4153 5345 5254 2873 2e67 6574 5f73  T_ASSERT(s.get_s
    │ │ │ +0003e5e0: 7472 2873 6574 7469 6e67 735f 7061 636b  tr(settings_pack
    │ │ │ +0003e5f0: 3a3a 7374 7269 6e67 5f74 7970 655f 6261  ::string_type_ba
    │ │ │ +0003e600: 7365 202b 2069 2920 3d3d 2073 7472 5f73  se + i) == str_s
    │ │ │ +0003e610: 6574 7469 6e67 735b 695d 2e64 6566 6175  ettings[i].defau
    │ │ │ +0003e620: 6c74 5f76 616c 7565 293b 0a09 097d 0a0a  lt_value);...}..
    │ │ │ +0003e630: 0909 666f 7220 2869 6e74 2069 203d 2030  ..for (int i = 0
    │ │ │ +0003e640: 3b20 6920 266c 743b 2073 6574 7469 6e67  ; i < setting
    │ │ │ +0003e650: 735f 7061 636b 3a3a 6e75 6d5f 696e 745f  s_pack::num_int_
    │ │ │ +0003e660: 7365 7474 696e 6773 3b20 2b2b 6929 0a09  settings; ++i)..
    │ │ │ +0003e670: 097b 0a09 0909 732e 7365 745f 696e 7428  .{....s.set_int(
    │ │ │ +0003e680: 7365 7474 696e 6773 5f70 6163 6b3a 3a69  settings_pack::i
    │ │ │ +0003e690: 6e74 5f74 7970 655f 6261 7365 207c 2069  nt_type_base | i
    │ │ │ +0003e6a0: 2c20 696e 745f 7365 7474 696e 6773 5b69  , int_settings[i
    │ │ │ +0003e6b0: 5d2e 6465 6661 756c 745f 7661 6c75 6529  ].default_value)
    │ │ │ +0003e6c0: 3b0a 0909 0954 4f52 5245 4e54 5f41 5353  ;....TORRENT_ASS
    │ │ │ +0003e6d0: 4552 5428 732e 6765 745f 696e 7428 7365  ERT(s.get_int(se
    │ │ │ +0003e6e0: 7474 696e 6773 5f70 6163 6b3a 3a69 6e74  ttings_pack::int
    │ │ │ +0003e6f0: 5f74 7970 655f 6261 7365 202b 2069 2920  _type_base + i) 
    │ │ │ +0003e700: 3d3d 2069 6e74 5f73 6574 7469 6e67 735b  == int_settings[
    │ │ │ +0003e710: 695d 2e64 6566 6175 6c74 5f76 616c 7565  i].default_value
    │ │ │ +0003e720: 293b 0a09 097d 0a0a 0909 666f 7220 2869  );...}....for (i
    │ │ │ +0003e730: 6e74 2069 203d 2030 3b20 6920 266c 743b  nt i = 0; i <
    │ │ │ +0003e740: 2073 6574 7469 6e67 735f 7061 636b 3a3a   settings_pack::
    │ │ │ +0003e750: 6e75 6d5f 626f 6f6c 5f73 6574 7469 6e67  num_bool_setting
    │ │ │ +0003e760: 733b 202b 2b69 290a 0909 7b0a 0909 0973  s; ++i)...{....s
    │ │ │ +0003e770: 2e73 6574 5f62 6f6f 6c28 7365 7474 696e  .set_bool(settin
    │ │ │ +0003e780: 6773 5f70 6163 6b3a 3a62 6f6f 6c5f 7479  gs_pack::bool_ty
    │ │ │ +0003e790: 7065 5f62 6173 6520 7c20 692c 2062 6f6f  pe_base | i, boo
    │ │ │ +0003e7a0: 6c5f 7365 7474 696e 6773 5b69 5d2e 6465  l_settings[i].de
    │ │ │ +0003e7b0: 6661 756c 745f 7661 6c75 6529 3b0a 0909  fault_value);...
    │ │ │ +0003e7c0: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ +0003e7d0: 732e 6765 745f 626f 6f6c 2873 6574 7469  s.get_bool(setti
    │ │ │ +0003e7e0: 6e67 735f 7061 636b 3a3a 626f 6f6c 5f74  ngs_pack::bool_t
    │ │ │ +0003e7f0: 7970 655f 6261 7365 202b 2069 2920 3d3d  ype_base + i) ==
    │ │ │ +0003e800: 2062 6f6f 6c5f 7365 7474 696e 6773 5b69   bool_settings[i
    │ │ │ +0003e810: 5d2e 6465 6661 756c 745f 7661 6c75 6529  ].default_value)
    │ │ │ +0003e820: 3b0a 0909 7d0a 097d 0a0a 0973 6574 7469  ;...}..}...setti
    │ │ │ +0003e830: 6e67 735f 7061 636b 2064 6566 6175 6c74  ngs_pack default
    │ │ │ +0003e840: 5f73 6574 7469 6e67 7328 290a 097b 0a09  _settings()..{..
    │ │ │ +0003e850: 0973 6574 7469 6e67 735f 7061 636b 2072  .settings_pack r
    │ │ │ +0003e860: 6574 3b0a 3c64 6976 2073 7479 6c65 3d22  et;.
    ..for (int i = │ │ │ +0003e8a0: 2030 3b20 6920 266c 743b 2073 6574 7469 0; i < setti │ │ │ +0003e8b0: 6e67 735f 7061 636b 3a3a 6e75 6d5f 7374 ngs_pack::num_st │ │ │ +0003e8c0: 7269 6e67 5f73 6574 7469 6e67 733b 202b ring_settings; + │ │ │ +0003e8d0: 2b69 290a 3c2f 6469 763e 0909 7b0a 0909 +i).
    ..{... │ │ │ +0003e8e0: 0969 6620 2873 7472 5f73 6574 7469 6e67 .if (str_setting │ │ │ +0003e8f0: 735b 695d 2e64 6566 6175 6c74 5f76 616c s[i].default_val │ │ │ +0003e900: 7565 203d 3d20 6e75 6c6c 7074 7229 2063 ue == nullptr) c │ │ │ +0003e910: 6f6e 7469 6e75 653b 0a09 0909 7265 742e ontinue;....ret. │ │ │ +0003e920: 7365 745f 7374 7228 7365 7474 696e 6773 set_str(settings │ │ │ +0003e930: 5f70 6163 6b3a 3a73 7472 696e 675f 7479 _pack::string_ty │ │ │ +0003e940: 7065 5f62 6173 6520 2b20 692c 2073 7472 pe_base + i, str │ │ │ +0003e950: 5f73 6574 7469 6e67 735b 695d 2e64 6566 _settings[i].def │ │ │ +0003e960: 6175 6c74 5f76 616c 7565 293b 0a09 097d ault_value);...} │ │ │ +0003e970: 0a0a 0909 666f 7220 2869 6e74 2069 203d ....for (int i = │ │ │ +0003e980: 2030 3b20 6920 266c 743b 2073 6574 7469 0; i < setti │ │ │ +0003e990: 6e67 735f 7061 636b 3a3a 6e75 6d5f 696e ngs_pack::num_in │ │ │ +0003e9a0: 745f 7365 7474 696e 6773 3b20 2b2b 6929 t_settings; ++i) │ │ │ +0003e9b0: 0a09 097b 0a09 0909 7265 742e 7365 745f ...{....ret.set_ │ │ │ +0003e9c0: 696e 7428 7365 7474 696e 6773 5f70 6163 int(settings_pac │ │ │ +0003e9d0: 6b3a 3a69 6e74 5f74 7970 655f 6261 7365 k::int_type_base │ │ │ +0003e9e0: 202b 2069 2c20 696e 745f 7365 7474 696e + i, int_settin │ │ │ +0003e9f0: 6773 5b69 5d2e 6465 6661 756c 745f 7661 gs[i].default_va │ │ │ +0003ea00: 6c75 6529 3b0a 0909 7d0a 0a09 0966 6f72 lue);...}....for │ │ │ +0003ea10: 2028 696e 7420 6920 3d20 303b 2069 2026 (int i = 0; i & │ │ │ +0003ea20: 6c74 3b20 7365 7474 696e 6773 5f70 6163 lt; settings_pac │ │ │ +0003ea30: 6b3a 3a6e 756d 5f62 6f6f 6c5f 7365 7474 k::num_bool_sett │ │ │ +0003ea40: 696e 6773 3b20 2b2b 6929 0a09 097b 0a09 ings; ++i)...{.. │ │ │ +0003ea50: 0909 7265 742e 7365 745f 626f 6f6c 2873 ..ret.set_bool(s │ │ │ +0003ea60: 6574 7469 6e67 735f 7061 636b 3a3a 626f ettings_pack::bo │ │ │ +0003ea70: 6f6c 5f74 7970 655f 6261 7365 202b 2069 ol_type_base + i │ │ │ +0003ea80: 2c20 626f 6f6c 5f73 6574 7469 6e67 735b , bool_settings[ │ │ │ +0003ea90: 695d 2e64 6566 6175 6c74 5f76 616c 7565 i].default_value │ │ │ +0003eaa0: 293b 0a09 097d 0a09 0972 6574 7572 6e20 );...}...return │ │ │ +0003eab0: 7265 743b 0a09 7d0a 0a09 766f 6964 2061 ret;..}...void a │ │ │ +0003eac0: 7070 6c79 5f70 6163 6b28 7365 7474 696e pply_pack(settin │ │ │ +0003ead0: 6773 5f70 6163 6b20 636f 6e73 742a 2070 gs_pack const* p │ │ │ +0003eae0: 6163 6b2c 2061 7578 3a3a 7365 7373 696f ack, aux::sessio │ │ │ +0003eaf0: 6e5f 7365 7474 696e 6773 2661 6d70 3b20 n_settings& │ │ │ +0003eb00: 7365 7474 0a09 092c 2061 7578 3a3a 7365 sett..., aux::se │ │ │ +0003eb10: 7373 696f 6e5f 696d 706c 2a20 7365 7329 ssion_impl* ses) │ │ │ +0003eb20: 0a09 7b0a 0909 7573 696e 6720 6675 6e5f ..{...using fun_ │ │ │ +0003eb30: 7420 3d20 766f 6964 2028 6175 783a 3a73 t = void (aux::s │ │ │ +0003eb40: 6573 7369 6f6e 5f69 6d70 6c3a 3a2a 2928 ession_impl::*)( │ │ │ +0003eb50: 293b 0a09 0973 7464 3a3a 7665 6374 6f72 );...std::vector │ │ │ +0003eb60: 266c 743b 6675 6e5f 7426 6774 3b20 6361 <fun_t> ca │ │ │ +0003eb70: 6c6c 6261 636b 733b 0a0a 0909 7365 7474 llbacks;....sett │ │ │ +0003eb80: 2e62 756c 6b5f 7365 7428 5b26 616d 703b .bulk_set([& │ │ │ +0003eb90: 5d28 6175 783a 3a73 6573 7369 6f6e 5f73 ](aux::session_s │ │ │ +0003eba0: 6574 7469 6e67 735f 7369 6e67 6c65 5f74 ettings_single_t │ │ │ +0003ebb0: 6872 6561 6426 616d 703b 2073 290a 0909 hread& s)... │ │ │ +0003ebc0: 7b0a 0909 0961 7070 6c79 5f70 6163 6b5f {....apply_pack_ │ │ │ +0003ebd0: 696d 706c 2870 6163 6b2c 2073 2c20 7365 impl(pack, s, se │ │ │ +0003ebe0: 7320 3f20 2661 6d70 3b63 616c 6c62 6163 s ? &callbac │ │ │ +0003ebf0: 6b73 203a 206e 756c 6c70 7472 293b 0a09 ks : nullptr);.. │ │ │ +0003ec00: 097d 293b 0a0a 0909 2f2f 2063 616c 6c20 .});....// call │ │ │ +0003ec10: 7468 6520 6361 6c6c 6261 636b 7320 6f6e the callbacks on │ │ │ +0003ec20: 6365 2061 6c6c 2074 6865 2073 6574 7469 ce all the setti │ │ │ +0003ec30: 6e67 7320 6861 7665 2062 6565 6e20 6170 ngs have been ap │ │ │ +0003ec40: 706c 6965 642c 2061 6e64 0a09 092f 2f20 plied, and...// │ │ │ +0003ec50: 6f6e 6c79 206f 6e63 6520 7065 7220 6361 only once per ca │ │ │ +0003ec60: 6c6c 6261 636b 0a3c 2f70 7265 3e3c 2f74 llback.
    relevanc │ │ │ +0003eca0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0
    ../src/session │ │ │ +0003ece0: 5f69 6d70 6c2e 6370 703a 3631 353c 2f61 _impl.cpp:615come u │ │ │ +0003ed00: 7020 7769 7468 2073 6f6d 6520 6162 7374 p with some abst │ │ │ +0003ed10: 7261 6374 696f 6e20 746f 2064 6f20 7468 raction to do th │ │ │ +0003ed20: 6973 2066 6f72 2067 6e75 746c 7320 6173 is for gnutls as │ │ │ +0003ed30: 2077 656c 6c20 6c6f 6164 2063 6572 7469 well load certi │ │ │ +0003ed40: 6669 6361 7465 7320 6672 6f6d 2074 6865 ficates from the │ │ │ +0003ed50: 2077 696e 646f 7773 2073 7973 7465 6d20 windows system │ │ │ +0003ed60: 6365 7274 6966 6963 6174 6520 7374 6f72 certificate stor │ │ │ +0003ed70: 653c 2f74 643e 3c2f 7472 3e3c 7472 2069 e

    c │ │ │ +0003edc0: 6f6d 6520 7570 2077 6974 6820 736f 6d65 ome up with some │ │ │ +0003edd0: 2061 6273 7472 6163 7469 6f6e 2074 6f20 abstraction to │ │ │ +0003ede0: 646f 2074 6869 7320 666f 7220 676e 7574 do this for gnut │ │ │ +0003edf0: 6c73 2061 7320 7765 6c6c 0a6c 6f61 6420 ls as well.load │ │ │ +0003ee00: 6365 7274 6966 6963 6174 6573 2066 726f certificates fro │ │ │ +0003ee10: 6d20 7468 6520 7769 6e64 6f77 7320 7379 m the windows sy │ │ │ +0003ee20: 7374 656d 2063 6572 7469 6669 6361 7465 stem certificate │ │ │ +0003ee30: 2073 746f 7265 3c2f 6832 3e3c 6834 3e2e store

    . │ │ │ +0003ee40: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ +0003ee50: 706c 2e63 7070 3a36 3135 3c2f 6834 3e3c pl.cpp:615

    < │ │ │ +0003ee60: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +0003ee70: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +0003ee80: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +0003ee90: 7820 2364 6464 3b22 3e09 0970 6175 7365 x #ddd;">..pause │ │ │ +0003eea0: 2829 3b0a 097d 0a23 656e 6469 660a 0a09 ();..}.#endif... │ │ │ +0003eeb0: 2f2f 2054 6869 7320 6675 6e63 7469 6f6e // This function │ │ │ +0003eec0: 2069 7320 6361 6c6c 6564 2062 7920 7468 is called by th │ │ │ +0003eed0: 6520 6372 6561 7469 6e67 2074 6872 6561 e creating threa │ │ │ +0003eee0: 642c 206e 6f74 2069 6e20 7468 6520 6d65 d, not in the me │ │ │ +0003eef0: 7373 6167 6520 6c6f 6f70 2773 0a09 2f2f ssage loop's..// │ │ │ +0003ef00: 2069 6f5f 636f 6e74 6578 7420 7468 7265 io_context thre │ │ │ +0003ef10: 6164 2e0a 0976 6f69 6420 7365 7373 696f ad...void sessio │ │ │ +0003ef20: 6e5f 696d 706c 3a3a 7374 6172 745f 7365 n_impl::start_se │ │ │ +0003ef30: 7373 696f 6e28 290a 097b 0a23 6966 6e64 ssion()..{.#ifnd │ │ │ +0003ef40: 6566 2054 4f52 5245 4e54 5f44 4953 4142 ef TORRENT_DISAB │ │ │ +0003ef50: 4c45 5f4c 4f47 4749 4e47 0a09 0973 6573 LE_LOGGING...ses │ │ │ +0003ef60: 7369 6f6e 5f6c 6f67 2822 7374 6172 7420 sion_log("start │ │ │ +0003ef70: 7365 7373 696f 6e22 293b 0a23 656e 6469 session");.#endi │ │ │ +0003ef80: 660a 0a23 6966 2054 4f52 5245 4e54 5f55 f..#if TORRENT_U │ │ │ +0003ef90: 5345 5f53 534c 0a09 0965 7272 6f72 5f63 SE_SSL...error_c │ │ │ +0003efa0: 6f64 6520 6563 3b0a 0909 6d5f 7373 6c5f ode ec;...m_ssl_ │ │ │ +0003efb0: 6374 782e 7365 745f 6465 6661 756c 745f ctx.set_default_ │ │ │ +0003efc0: 7665 7269 6679 5f70 6174 6873 2865 6329 verify_paths(ec) │ │ │ +0003efd0: 3b0a 2369 666e 6465 6620 544f 5252 454e ;.#ifndef TORREN │ │ │ +0003efe0: 545f 4449 5341 424c 455f 4c4f 4747 494e T_DISABLE_LOGGIN │ │ │ +0003eff0: 470a 0909 6966 2028 6563 2920 7365 7373 G...if (ec) sess │ │ │ +0003f000: 696f 6e5f 6c6f 6728 2253 534c 2073 6574 ion_log("SSL set │ │ │ +0003f010: 5f64 6566 6175 6c74 2076 6572 6966 795f _default verify_ │ │ │ +0003f020: 7061 7468 7320 6661 696c 6564 3a20 2573 paths failed: %s │ │ │ +0003f030: 222c 2065 632e 6d65 7373 6167 6528 292e ", ec.message(). │ │ │ +0003f040: 635f 7374 7228 2929 3b0a 0909 6563 2e63 c_str());...ec.c │ │ │ +0003f050: 6c65 6172 2829 3b0a 2365 6e64 6966 0a23 lear();.#endif.# │ │ │ +0003f060: 6966 2064 6566 696e 6564 2054 4f52 5245 if defined TORRE │ │ │ +0003f070: 4e54 5f57 494e 444f 5753 2026 616d 703b NT_WINDOWS & │ │ │ +0003f080: 2661 6d70 3b20 6465 6669 6e65 6420 544f & defined TO │ │ │ +0003f090: 5252 454e 545f 5553 455f 4f50 454e 5353 RRENT_USE_OPENSS │ │ │ +0003f0a0: 4c20 2661 6d70 3b26 616d 703b 2021 6465 L && !de │ │ │ +0003f0b0: 6669 6e65 6420 544f 5252 454e 545f 5749 fined TORRENT_WI │ │ │ +0003f0c0: 4e52 540a 3c64 6976 2073 7479 6c65 3d22 NRT.
    ..X509_STORE* │ │ │ +0003f100: 7374 6f72 6520 3d20 5835 3039 5f53 544f store = X509_STO │ │ │ +0003f110: 5245 5f6e 6577 2829 3b0a 3c2f 6469 763e RE_new();.
    │ │ │ +0003f120: 0909 6966 2028 7374 6f72 6529 0a09 097b ..if (store)...{ │ │ │ +0003f130: 0a09 0909 4843 4552 5453 544f 5245 2073 ....HCERTSTORE s │ │ │ +0003f140: 7973 7465 6d5f 7374 6f72 6520 3d20 4365 ystem_store = Ce │ │ │ +0003f150: 7274 4f70 656e 5379 7374 656d 5374 6f72 rtOpenSystemStor │ │ │ +0003f160: 6541 2830 2c20 2252 4f4f 5422 293b 0a09 eA(0, "ROOT");.. │ │ │ +0003f170: 0909 2f2f 2074 6869 7320 6973 2062 6573 ..// this is bes │ │ │ +0003f180: 7420 6566 666f 7274 0a09 0909 6966 2028 t effort....if ( │ │ │ +0003f190: 7379 7374 656d 5f73 746f 7265 290a 0909 system_store)... │ │ │ +0003f1a0: 097b 0a09 0909 0943 4552 545f 434f 4e54 .{.....CERT_CONT │ │ │ +0003f1b0: 4558 5420 636f 6e73 742a 2063 7478 203d EXT const* ctx = │ │ │ +0003f1c0: 206e 756c 6c70 7472 3b0a 0909 0909 7768 nullptr;.....wh │ │ │ +0003f1d0: 696c 6520 2828 6374 7820 3d20 4365 7274 ile ((ctx = Cert │ │ │ +0003f1e0: 456e 756d 4365 7274 6966 6963 6174 6573 EnumCertificates │ │ │ +0003f1f0: 496e 5374 6f72 6528 7379 7374 656d 5f73 InStore(system_s │ │ │ +0003f200: 746f 7265 2c20 6374 7829 2920 213d 206e tore, ctx)) != n │ │ │ +0003f210: 756c 6c70 7472 290a 0909 0909 7b0a 0909 ullptr).....{... │ │ │ +0003f220: 0909 0975 6e73 6967 6e65 6420 6368 6172 ...unsigned char │ │ │ +0003f230: 2063 6f6e 7374 2a20 6365 7274 5f70 7472 const* cert_ptr │ │ │ +0003f240: 203d 2072 6569 6e74 6572 7072 6574 5f63 = reinterpret_c │ │ │ +0003f250: 6173 7426 6c74 3b75 6e73 6967 6e65 6420 ast<unsigned │ │ │ +0003f260: 6368 6172 2063 6f6e 7374 2a26 6774 3b28 char const*>( │ │ │ +0003f270: 6374 782d 2667 743b 7062 4365 7274 456e ctx->pbCertEn │ │ │ +0003f280: 636f 6465 6429 3b0a 0909 0909 0958 3530 coded);......X50 │ │ │ +0003f290: 392a 2078 3530 3920 3d20 6432 695f 5835 9* x509 = d2i_X5 │ │ │ +0003f2a0: 3039 286e 756c 6c70 7472 2c20 2661 6d70 09(nullptr, & │ │ │ +0003f2b0: 3b63 6572 745f 7074 722c 2063 7478 2d26 ;cert_ptr, ctx-& │ │ │ +0003f2c0: 6774 3b63 6243 6572 7445 6e63 6f64 6564 gt;cbCertEncoded │ │ │ +0003f2d0: 293b 0a09 0909 0909 2f2f 2074 6869 7320 );......// this │ │ │ +0003f2e0: 6973 2062 6573 7420 6566 666f 7274 0a09 is best effort.. │ │ │ +0003f2f0: 0909 0909 6966 2028 2178 3530 3929 2063 ....if (!x509) c │ │ │ +0003f300: 6f6e 7469 6e75 653b 0a09 0909 0909 5835 ontinue;......X5 │ │ │ +0003f310: 3039 5f53 544f 5245 5f61 6464 5f63 6572 09_STORE_add_cer │ │ │ +0003f320: 7428 7374 6f72 652c 2078 3530 3929 3b0a t(store, x509);. │ │ │ +0003f330: 0909 0909 0958 3530 395f 6672 6565 2878 .....X509_free(x │ │ │ +0003f340: 3530 3929 3b0a 0909 0909 7d0a 0909 0909 509);.....}..... │ │ │ +0003f350: 4365 7274 4672 6565 4365 7274 6966 6963 CertFreeCertific │ │ │ +0003f360: 6174 6543 6f6e 7465 7874 2863 7478 293b ateContext(ctx); │ │ │ +0003f370: 0a09 0909 0943 6572 7443 6c6f 7365 5374 .....CertCloseSt │ │ │ +0003f380: 6f72 6528 7379 7374 656d 5f73 746f 7265 ore(system_store │ │ │ +0003f390: 2c20 3029 3b0a 0909 097d 0a09 097d 0a0a , 0);....}...}.. │ │ │ +0003f3a0: 0909 5353 4c5f 4354 582a 2073 736c 5f63 ..SSL_CTX* ssl_c │ │ │ +0003f3b0: 7478 203d 206d 5f73 736c 5f63 7478 2e6e tx = m_ssl_ctx.n │ │ │ +0003f3c0: 6174 6976 655f 6861 6e64 6c65 2829 3b0a ative_handle();. │ │ │ +0003f3d0: 0909 5353 4c5f 4354 585f 7365 745f 6365 ..SSL_CTX_set_ce │ │ │ +0003f3e0: 7274 5f73 746f 7265 2873 736c 5f63 7478 rt_store(ssl_ctx │ │ │ +0003f3f0: 2c20 7374 6f72 6529 3b0a 2365 6e64 6966 , store);.#endif │ │ │ +0003f400: 0a23 6966 6465 6620 5f5f 4150 504c 455f .#ifdef __APPLE_ │ │ │ +0003f410: 5f0a 0909 6d5f 7373 6c5f 6374 782e 6c6f _...m_ssl_ctx.lo │ │ │ +0003f420: 6164 5f76 6572 6966 795f 6669 6c65 2822 ad_verify_file(" │ │ │ +0003f430: 2f65 7463 2f73 736c 2f63 6572 742e 7065 /etc/ssl/cert.pe │ │ │ +0003f440: 6d22 2c20 6563 293b 0a23 6966 6e64 6566 m", ec);.#ifndef │ │ │ +0003f450: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ +0003f460: 5f4c 4f47 4749 4e47 0a09 0969 6620 2865 _LOGGING...if (e │ │ │ +0003f470: 6329 2073 6573 7369 6f6e 5f6c 6f67 2822 c) session_log(" │ │ │ +0003f480: 5353 4c20 6c6f 6164 5f76 6572 6966 795f SSL load_verify_ │ │ │ +0003f490: 6669 6c65 2066 6169 6c65 643a 2025 7322 file failed: %s" │ │ │ +0003f4a0: 2c20 6563 2e6d 6573 7361 6765 2829 2e63 , ec.message().c │ │ │ +0003f4b0: 5f73 7472 2829 293b 0a23 656e 6469 660a _str());.#endif. │ │ │ +0003f4c0: 0909 6563 2e63 6c65 6172 2829 3b0a 3c2f ..ec.clear();.r │ │ │ +0003f500: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +0003f510: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +0003f540: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ +0003f550: 3a31 3530 303c 2f61 3e3c 2f74 643e 3c74 :1500it would be ni │ │ │ +0003f570: 6365 2074 6f20 7265 7365 7276 6528 2920 ce to reserve() │ │ │ +0003f580: 7468 6573 6520 7665 6374 6f72 7320 7570 these vectors up │ │ │ +0003f590: 2066 726f 6e74 3c2f 7464 3e3c 2f74 723e front │ │ │ +0003f5a0: 3c74 7220 6964 3d22 3135 3622 2073 7479 │ │ │ +0003f5d0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0003f5e0: 3c68 323e 6974 2077 6f75 6c64 2062 6520

    it would be │ │ │ +0003f5f0: 6e69 6365 2074 6f20 7265 7365 7276 6528 nice to reserve( │ │ │ +0003f600: 2920 7468 6573 6520 7665 6374 6f72 7320 ) these vectors │ │ │ +0003f610: 7570 2066 726f 6e74 3c2f 6832 3e3c 6834 up front

    ../src/session_ │ │ │ +0003f630: 696d 706c 2e63 7070 3a31 3530 303c 2f68 impl.cpp:1500
    ...b
    │ │ │ +0003f680: 616e 6477 6964 7468 5f63 6861 6e6e 656c  andwidth_channel
    │ │ │ +0003f690: 2a20 6368 203d 2026 616d 703b 702d 2667  * ch = &p-&g
    │ │ │ +0003f6a0: 743b 6368 616e 6e65 6c5b 7065 6572 5f63  t;channel[peer_c
    │ │ │ +0003f6b0: 6f6e 6e65 6374 696f 6e3a 3a64 6f77 6e6c  onnection::downl
    │ │ │ +0003f6c0: 6f61 645f 6368 616e 6e65 6c5d 3b0a 0909  oad_channel];...
    │ │ │ +0003f6d0: 0969 6620 2875 7365 5f71 756f 7461 5f6f  .if (use_quota_o
    │ │ │ +0003f6e0: 7665 7268 6561 6428 6368 2c20 616d 6f75  verhead(ch, amou
    │ │ │ +0003f6f0: 6e74 5f64 6f77 6e29 290a 0909 0909 7265  nt_down)).....re
    │ │ │ +0003f700: 7420 7c3d 2031 2026 6c74 3b26 6c74 3b20  t |= 1 << 
    │ │ │ +0003f710: 7065 6572 5f63 6f6e 6e65 6374 696f 6e3a  peer_connection:
    │ │ │ +0003f720: 3a64 6f77 6e6c 6f61 645f 6368 616e 6e65  :download_channe
    │ │ │ +0003f730: 6c3b 0a09 0909 6368 203d 2026 616d 703b  l;....ch = &
    │ │ │ +0003f740: 702d 2667 743b 6368 616e 6e65 6c5b 7065  p->channel[pe
    │ │ │ +0003f750: 6572 5f63 6f6e 6e65 6374 696f 6e3a 3a75  er_connection::u
    │ │ │ +0003f760: 706c 6f61 645f 6368 616e 6e65 6c5d 3b0a  pload_channel];.
    │ │ │ +0003f770: 0909 0969 6620 2875 7365 5f71 756f 7461  ...if (use_quota
    │ │ │ +0003f780: 5f6f 7665 7268 6561 6428 6368 2c20 616d  _overhead(ch, am
    │ │ │ +0003f790: 6f75 6e74 5f75 7029 290a 0909 0909 7265  ount_up)).....re
    │ │ │ +0003f7a0: 7420 7c3d 2031 2026 6c74 3b26 6c74 3b20  t |= 1 << 
    │ │ │ +0003f7b0: 7065 6572 5f63 6f6e 6e65 6374 696f 6e3a  peer_connection:
    │ │ │ +0003f7c0: 3a75 706c 6f61 645f 6368 616e 6e65 6c3b  :upload_channel;
    │ │ │ +0003f7d0: 0a09 097d 0a09 0972 6574 7572 6e20 7265  ...}...return re
    │ │ │ +0003f7e0: 743b 0a09 7d0a 0a09 2f2f 2073 6573 7369  t;..}...// sessi
    │ │ │ +0003f7f0: 6f6e 5f69 6d70 6c20 6973 2072 6573 706f  on_impl is respo
    │ │ │ +0003f800: 6e73 6962 6c65 2066 6f72 2064 656c 6574  nsible for delet
    │ │ │ +0003f810: 696e 6720 2770 6163 6b27 0a09 766f 6964  ing 'pack'..void
    │ │ │ +0003f820: 2073 6573 7369 6f6e 5f69 6d70 6c3a 3a61   session_impl::a
    │ │ │ +0003f830: 7070 6c79 5f73 6574 7469 6e67 735f 7061  pply_settings_pa
    │ │ │ +0003f840: 636b 2873 7464 3a3a 7368 6172 6564 5f70  ck(std::shared_p
    │ │ │ +0003f850: 7472 266c 743b 7365 7474 696e 6773 5f70  tr<settings_p
    │ │ │ +0003f860: 6163 6b26 6774 3b20 7061 636b 290a 097b  ack> pack)..{
    │ │ │ +0003f870: 0a09 0949 4e56 4152 4941 4e54 5f43 4845  ...INVARIANT_CHE
    │ │ │ +0003f880: 434b 3b0a 0909 6170 706c 795f 7365 7474  CK;...apply_sett
    │ │ │ +0003f890: 696e 6773 5f70 6163 6b5f 696d 706c 282a  ings_pack_impl(*
    │ │ │ +0003f8a0: 7061 636b 293b 0a09 7d0a 0a09 7365 7474  pack);..}...sett
    │ │ │ +0003f8b0: 696e 6773 5f70 6163 6b20 7365 7373 696f  ings_pack sessio
    │ │ │ +0003f8c0: 6e5f 696d 706c 3a3a 6765 745f 7365 7474  n_impl::get_sett
    │ │ │ +0003f8d0: 696e 6773 2829 2063 6f6e 7374 0a09 7b0a  ings() const..{.
    │ │ │ +0003f8e0: 0909 7365 7474 696e 6773 5f70 6163 6b20  ..settings_pack 
    │ │ │ +0003f8f0: 7265 743b 0a3c 6469 7620 7374 796c 653d  ret;.
    ..for (int i │ │ │ +0003f930: 3d20 7365 7474 696e 6773 5f70 6163 6b3a = settings_pack: │ │ │ +0003f940: 3a73 7472 696e 675f 7479 7065 5f62 6173 :string_type_bas │ │ │ +0003f950: 653b 0a3c 2f64 6976 3e09 0909 6920 266c e;.
    ...i &l │ │ │ +0003f960: 743b 2073 6574 7469 6e67 735f 7061 636b t; settings_pack │ │ │ +0003f970: 3a3a 6d61 785f 7374 7269 6e67 5f73 6574 ::max_string_set │ │ │ +0003f980: 7469 6e67 5f69 6e74 6572 6e61 6c3b 202b ting_internal; + │ │ │ +0003f990: 2b69 290a 0909 7b0a 0909 0972 6574 2e73 +i)...{....ret.s │ │ │ +0003f9a0: 6574 5f73 7472 2869 2c20 6d5f 7365 7474 et_str(i, m_sett │ │ │ +0003f9b0: 696e 6773 2e67 6574 5f73 7472 2869 2929 ings.get_str(i)) │ │ │ +0003f9c0: 3b0a 0909 7d0a 0909 666f 7220 2869 6e74 ;...}...for (int │ │ │ +0003f9d0: 2069 203d 2073 6574 7469 6e67 735f 7061 i = settings_pa │ │ │ +0003f9e0: 636b 3a3a 696e 745f 7479 7065 5f62 6173 ck::int_type_bas │ │ │ +0003f9f0: 653b 0a09 0909 6920 266c 743b 2073 6574 e;....i < set │ │ │ +0003fa00: 7469 6e67 735f 7061 636b 3a3a 6d61 785f tings_pack::max_ │ │ │ +0003fa10: 696e 745f 7365 7474 696e 675f 696e 7465 int_setting_inte │ │ │ +0003fa20: 726e 616c 3b20 2b2b 6929 0a09 097b 0a09 rnal; ++i)...{.. │ │ │ +0003fa30: 0909 7265 742e 7365 745f 696e 7428 692c ..ret.set_int(i, │ │ │ +0003fa40: 206d 5f73 6574 7469 6e67 732e 6765 745f m_settings.get_ │ │ │ +0003fa50: 696e 7428 6929 293b 0a09 097d 0a09 0966 int(i));...}...f │ │ │ +0003fa60: 6f72 2028 696e 7420 6920 3d20 7365 7474 or (int i = sett │ │ │ +0003fa70: 696e 6773 5f70 6163 6b3a 3a62 6f6f 6c5f ings_pack::bool_ │ │ │ +0003fa80: 7479 7065 5f62 6173 653b 0a09 0909 6920 type_base;....i │ │ │ +0003fa90: 266c 743b 2073 6574 7469 6e67 735f 7061 < settings_pa │ │ │ +0003faa0: 636b 3a3a 6d61 785f 626f 6f6c 5f73 6574 ck::max_bool_set │ │ │ +0003fab0: 7469 6e67 5f69 6e74 6572 6e61 6c3b 202b ting_internal; + │ │ │ +0003fac0: 2b69 290a 0909 7b0a 0909 0972 6574 2e73 +i)...{....ret.s │ │ │ +0003fad0: 6574 5f62 6f6f 6c28 692c 206d 5f73 6574 et_bool(i, m_set │ │ │ +0003fae0: 7469 6e67 732e 6765 745f 626f 6f6c 2869 tings.get_bool(i │ │ │ +0003faf0: 2929 3b0a 0909 7d0a 0909 7265 7475 726e ));...}...return │ │ │ +0003fb00: 2072 6574 3b0a 097d 0a0a 6e61 6d65 7370 ret;..}..namesp │ │ │ +0003fb10: 6163 6520 7b0a 0974 656d 706c 6174 6520 ace {..template │ │ │ +0003fb20: 266c 743b 7479 7065 6e61 6d65 2050 6163 <typename Pac │ │ │ +0003fb30: 6b26 6774 3b0a 0969 6e74 2067 6574 5f73 k>..int get_s │ │ │ +0003fb40: 6574 7469 6e67 5f69 6d70 6c28 5061 636b etting_impl(Pack │ │ │ +0003fb50: 2063 6f6e 7374 2661 6d70 3b20 702c 2069 const& p, i │ │ │ +0003fb60: 6e74 206e 616d 652c 2069 6e74 2a29 0a09 nt name, int*).. │ │ │ +0003fb70: 7b20 7265 7475 726e 2070 2e67 6574 5f69 { return p.get_i │ │ │ +0003fb80: 6e74 286e 616d 6529 3b20 7d0a 0a09 7465 nt(name); }...te │ │ │ +0003fb90: 6d70 6c61 7465 2026 6c74 3b74 7970 656e mplate <typen │ │ │ +0003fba0: 616d 6520 5061 636b 2667 743b 0a09 626f ame Pack>..bo │ │ │ +0003fbb0: 6f6c 2067 6574 5f73 6574 7469 6e67 5f69 ol get_setting_i │ │ │ +0003fbc0: 6d70 6c28 5061 636b 2063 6f6e 7374 2661 mpl(Pack const&a │ │ │ +0003fbd0: 6d70 3b20 702c 2069 6e74 206e 616d 652c mp; p, int name, │ │ │ +0003fbe0: 2062 6f6f 6c2a 290a 097b 2072 6574 7572 bool*)..{ retur │ │ │ +0003fbf0: 6e20 702e 6765 745f 626f 6f6c 286e 616d n p.get_bool(nam │ │ │ +0003fc00: 6529 3b20 7d0a 0a09 7465 6d70 6c61 7465 e); }...template │ │ │ +0003fc10: 2026 6c74 3b74 7970 656e 616d 6520 5061 <typename Pa │ │ │ +0003fc20: 636b 2667 743b 0a09 7374 643a 3a73 7472 ck>..std::str │ │ │ +0003fc30: 696e 6720 6765 745f 7365 7474 696e 675f ing get_setting_ │ │ │ +0003fc40: 696d 706c 2850 6163 6b20 636f 6e73 7426 impl(Pack const& │ │ │ +0003fc50: 616d 703b 2070 2c20 696e 7420 6e61 6d65 amp; p, int name │ │ │ +0003fc60: 2c20 7374 643a 3a73 7472 696e 672a 290a , std::string*). │ │ │ +0003fc70: 097b 2072 6574 7572 6e20 702e 6765 745f .{ return p.get_ │ │ │ +0003fc80: 7374 7228 6e61 6d65 293b 207d 0a0a 3c2f str(name); }..r │ │ │ +0003fcc0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +0003fcd0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +0003fd00: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ +0003fd10: 3a32 3031 343c 2f61 3e3c 2f74 643e 3c74 :2014could this fun │ │ │ +0003fd30: 6374 696f 6e20 6265 206d 6572 6765 6420 ction be merged │ │ │ +0003fd40: 7769 7468 2065 7870 616e 645f 756e 7370 with expand_unsp │ │ │ +0003fd50: 6563 6966 6965 645f 6164 6472 6573 7365 ecified_addresse │ │ │ +0003fd60: 733f 2072 6967 6874 206e 6f77 2062 6f74 s? right now bot │ │ │ +0003fd70: 6820 6c69 7374 656e 5f65 6e64 706f 696e h listen_endpoin │ │ │ +0003fd80: 745f 7420 616e 6420 6c69 7374 656e 5f69 t_t and listen_i │ │ │ +0003fd90: 6e74 6572 6661 6365 5f74 2061 7265 2061 nterface_t are a │ │ │ +0003fda0: 6c6d 6f73 7420 6964 656e 7469 6361 6c2c lmost identical, │ │ │ +0003fdb0: 206d 6179 6265 2074 6865 206c 6174 7465 maybe the latte │ │ │ +0003fdc0: 7220 636f 756c 6420 6265 2072 656d 6f76 r could be remov │ │ │ +0003fdd0: 6564 2074 6f6f 3c2f 7464 3e3c 2f74 723e ed too │ │ │ +0003fde0: 3c74 7220 6964 3d22 3135 3722 2073 7479 │ │ │ +0003fe10: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0003fe20: 3c68 323e 636f 756c 6420 7468 6973 2066

    could this f │ │ │ +0003fe30: 756e 6374 696f 6e20 6265 206d 6572 6765 unction be merge │ │ │ +0003fe40: 6420 7769 7468 2065 7870 616e 645f 756e d with expand_un │ │ │ +0003fe50: 7370 6563 6966 6965 645f 6164 6472 6573 specified_addres │ │ │ +0003fe60: 7365 733f 0a72 6967 6874 206e 6f77 2062 ses?.right now b │ │ │ +0003fe70: 6f74 6820 6c69 7374 656e 5f65 6e64 706f oth listen_endpo │ │ │ +0003fe80: 696e 745f 7420 616e 6420 6c69 7374 656e int_t and listen │ │ │ +0003fe90: 5f69 6e74 6572 6661 6365 5f74 2061 7265 _interface_t are │ │ │ +0003fea0: 2061 6c6d 6f73 740a 6964 656e 7469 6361 almost.identica │ │ │ +0003feb0: 6c2c 206d 6179 6265 2074 6865 206c 6174 l, maybe the lat │ │ │ +0003fec0: 7465 7220 636f 756c 6420 6265 2072 656d ter could be rem │ │ │ +0003fed0: 6f76 6564 2074 6f6f 3c2f 6832 3e3c 6834 oved too

    ../src/session_ │ │ │ +0003fef0: 696d 706c 2e63 7070 3a32 3031 343c 2f68 impl.cpp:2014
    ..se
    │ │ │ +0003ff40: 7373 696f 6e5f 6c6f 6728 2246 4154 414c  ssion_log("FATAL
    │ │ │ +0003ff50: 2053 4553 5349 4f4e 2045 5252 4f52 2028   SESSION ERROR (
    │ │ │ +0003ff60: 2573 203a 2025 6429 205b 2573 5d22 0a09  %s : %d) [%s]"..
    │ │ │ +0003ff70: 0909 2c20 6563 2e63 6174 6567 6f72 7928  .., ec.category(
    │ │ │ +0003ff80: 292e 6e61 6d65 2829 2c20 6563 2e76 616c  ).name(), ec.val
    │ │ │ +0003ff90: 7565 2829 2c20 6563 2e6d 6573 7361 6765  ue(), ec.message
    │ │ │ +0003ffa0: 2829 2e63 5f73 7472 2829 293b 0a23 656e  ().c_str());.#en
    │ │ │ +0003ffb0: 6469 660a 0909 7468 6973 2d26 6774 3b61  dif...this->a
    │ │ │ +0003ffc0: 626f 7274 2829 3b0a 097d 0a0a 0976 6f69  bort();..}...voi
    │ │ │ +0003ffd0: 6420 7365 7373 696f 6e5f 696d 706c 3a3a  d session_impl::
    │ │ │ +0003ffe0: 6f6e 5f69 705f 6368 616e 6765 2865 7272  on_ip_change(err
    │ │ │ +0003fff0: 6f72 5f63 6f64 6520 636f 6e73 7426 616d  or_code const&am
    │ │ │ +00040000: 703b 2065 6329 0a09 7b0a 2369 666e 6465  p; ec)..{.#ifnde
    │ │ │ +00040010: 6620 544f 5252 454e 545f 4449 5341 424c  f TORRENT_DISABL
    │ │ │ +00040020: 455f 4c4f 4747 494e 470a 0909 6966 2028  E_LOGGING...if (
    │ │ │ +00040030: 2165 6329 0a09 0909 7365 7373 696f 6e5f  !ec)....session_
    │ │ │ +00040040: 6c6f 6728 2272 6563 6569 7665 6420 6970  log("received ip
    │ │ │ +00040050: 2063 6861 6e67 6520 6672 6f6d 2069 6e74   change from int
    │ │ │ +00040060: 6572 6e61 6c20 6970 5f6e 6f74 6966 6965  ernal ip_notifie
    │ │ │ +00040070: 7222 293b 0a09 0965 6c73 650a 0909 0973  r");...else....s
    │ │ │ +00040080: 6573 7369 6f6e 5f6c 6f67 2822 7265 6365  ession_log("rece
    │ │ │ +00040090: 6976 6564 2065 7272 6f72 206f 6e5f 6970  ived error on_ip
    │ │ │ +000400a0: 5f63 6861 6e67 653a 2025 642c 2025 7322  _change: %d, %s"
    │ │ │ +000400b0: 2c20 6563 2e76 616c 7565 2829 2c20 6563  , ec.value(), ec
    │ │ │ +000400c0: 2e6d 6573 7361 6765 2829 2e63 5f73 7472  .message().c_str
    │ │ │ +000400d0: 2829 293b 0a23 656e 6469 660a 0909 6966  ());.#endif...if
    │ │ │ +000400e0: 2028 6563 207c 7c20 6d5f 6162 6f72 7420   (ec || m_abort 
    │ │ │ +000400f0: 7c7c 2021 6d5f 6970 5f6e 6f74 6966 6965  || !m_ip_notifie
    │ │ │ +00040100: 7229 2072 6574 7572 6e3b 0a09 096d 5f69  r) return;...m_i
    │ │ │ +00040110: 705f 6e6f 7469 6669 6572 2d26 6774 3b61  p_notifier->a
    │ │ │ +00040120: 7379 6e63 5f77 6169 7428 5b74 6869 735d  sync_wait([this]
    │ │ │ +00040130: 2028 6572 726f 725f 636f 6465 2063 6f6e   (error_code con
    │ │ │ +00040140: 7374 2661 6d70 3b20 6529 0a09 0909 7b20  st& e)....{ 
    │ │ │ +00040150: 7772 6170 2826 616d 703b 7365 7373 696f  wrap(&sessio
    │ │ │ +00040160: 6e5f 696d 706c 3a3a 6f6e 5f69 705f 6368  n_impl::on_ip_ch
    │ │ │ +00040170: 616e 6765 2c20 6529 3b20 7d29 3b0a 0909  ange, e); });...
    │ │ │ +00040180: 7265 6f70 656e 5f6e 6574 776f 726b 5f73  reopen_network_s
    │ │ │ +00040190: 6f63 6b65 7473 287b 7d29 3b0a 097d 0a0a  ockets({});..}..
    │ │ │ +000401a0: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .v │ │ │ +000401d0: 6f69 6420 696e 7465 7266 6163 655f 746f oid interface_to │ │ │ +000401e0: 5f65 6e64 706f 696e 7473 286c 6973 7465 _endpoints(liste │ │ │ +000401f0: 6e5f 696e 7465 7266 6163 655f 7420 636f n_interface_t co │ │ │ +00040200: 6e73 7426 616d 703b 2069 6661 6365 0a3c nst& iface.< │ │ │ +00040210: 2f64 6976 3e09 092c 206c 6973 7465 6e5f /div>.., listen_ │ │ │ +00040220: 736f 636b 6574 5f66 6c61 6773 5f74 2066 socket_flags_t f │ │ │ +00040230: 6c61 6773 0a09 092c 2073 7061 6e26 6c74 lags..., span< │ │ │ +00040240: 3b69 705f 696e 7465 7266 6163 6520 636f ;ip_interface co │ │ │ +00040250: 6e73 7426 6774 3b20 636f 6e73 7420 6966 nst> const if │ │ │ +00040260: 730a 0909 2c20 7374 643a 3a76 6563 746f s..., std::vecto │ │ │ +00040270: 7226 6c74 3b6c 6973 7465 6e5f 656e 6470 r<listen_endp │ │ │ +00040280: 6f69 6e74 5f74 2667 743b 2661 6d70 3b20 oint_t>& │ │ │ +00040290: 6570 7329 0a09 7b0a 0909 666c 6167 7320 eps)..{...flags │ │ │ +000402a0: 7c3d 2069 6661 6365 2e6c 6f63 616c 203f |= iface.local ? │ │ │ +000402b0: 206c 6973 7465 6e5f 736f 636b 6574 5f74 listen_socket_t │ │ │ +000402c0: 3a3a 6c6f 6361 6c5f 6e65 7477 6f72 6b20 ::local_network │ │ │ +000402d0: 3a20 6c69 7374 656e 5f73 6f63 6b65 745f : listen_socket_ │ │ │ +000402e0: 666c 6167 735f 747b 7d3b 0a09 0974 7261 flags_t{};...tra │ │ │ +000402f0: 6e73 706f 7274 2063 6f6e 7374 2073 736c nsport const ssl │ │ │ +00040300: 203d 2069 6661 6365 2e73 736c 203f 2074 = iface.ssl ? t │ │ │ +00040310: 7261 6e73 706f 7274 3a3a 7373 6c20 3a20 ransport::ssl : │ │ │ +00040320: 7472 616e 7370 6f72 743a 3a70 6c61 696e transport::plain │ │ │ +00040330: 7465 7874 3b0a 0a09 092f 2f20 4669 7273 text;....// Firs │ │ │ +00040340: 742c 2063 6865 636b 2074 6f20 7365 6520 t, check to see │ │ │ +00040350: 6966 2069 7427 7320 616e 2049 5020 6164 if it's an IP ad │ │ │ +00040360: 6472 6573 730a 0909 6572 726f 725f 636f dress...error_co │ │ │ +00040370: 6465 2065 7272 3b0a 0909 6164 6472 6573 de err;...addres │ │ │ +00040380: 7320 636f 6e73 7420 6164 7220 3d20 6d61 s const adr = ma │ │ │ +00040390: 6b65 5f61 6464 7265 7373 2869 6661 6365 ke_address(iface │ │ │ +000403a0: 2e64 6576 6963 652e 635f 7374 7228 292c .device.c_str(), │ │ │ +000403b0: 2065 7272 293b 0a09 0969 6620 2821 6572 err);...if (!er │ │ │ +000403c0: 7229 0a09 097b 0a09 0909 6570 732e 656d r)...{....eps.em │ │ │ +000403d0: 706c 6163 655f 6261 636b 2861 6472 2c20 place_back(adr, │ │ │ +000403e0: 6966 6163 652e 706f 7274 2c20 7374 643a iface.port, std: │ │ │ +000403f0: 3a73 7472 696e 677b 7d2c 2073 736c 2c20 :string{}, ssl, │ │ │ +00040400: 666c 6167 7329 3b0a 0909 7d0a 0909 656c flags);...}...el │ │ │ +00040410: 7365 0a09 097b 0a09 0909 666c 6167 7320 se...{....flags │ │ │ +00040420: 7c3d 206c 6973 7465 6e5f 736f 636b 6574 |= listen_socket │ │ │ +00040430: 5f74 3a3a 7761 735f 6578 7061 6e64 6564 _t::was_expanded │ │ │ +00040440: 3b0a 0a09 0909 2f2f 2074 6869 7320 6973 ;.....// this is │ │ │ +00040450: 2074 6865 2063 6173 6520 7768 6572 6520 the case where │ │ │ +00040460: 6465 7669 6365 206e 616d 6573 2061 206e device names a n │ │ │ +00040470: 6574 776f 726b 2064 6576 6963 652e 2057 etwork device. W │ │ │ +00040480: 6520 6e65 6564 2074 6f0a 0909 092f 2f20 e need to....// │ │ │ +00040490: 656e 756d 6572 6174 6520 616c 6c20 4950 enumerate all IP │ │ │ +000404a0: 7320 6173 736f 6369 6174 6564 2077 6974 s associated wit │ │ │ +000404b0: 6820 7468 6973 2064 6576 6963 650a 0909 h this device... │ │ │ +000404c0: 0966 6f72 2028 6175 746f 2063 6f6e 7374 .for (auto const │ │ │ +000404d0: 2661 6d70 3b20 6970 6661 6365 203a 2069 & ipface : i │ │ │ +000404e0: 6673 290a 0909 097b 0a09 0909 092f 2f20 fs)....{.....// │ │ │ +000404f0: 7765 2772 6520 6c6f 6f6b 696e 6720 666f we're looking fo │ │ │ +00040500: 7220 6120 7370 6563 6966 6963 2069 6e74 r a specific int │ │ │ +00040510: 6572 6661 6365 2c20 616e 6420 6974 7320 erface, and its │ │ │ +00040520: 6164 6472 6573 730a 0909 0909 2f2f 2028 address.....// ( │ │ │ +00040530: 7768 6963 6820 6d75 7374 2062 6520 6f66 which must be of │ │ │ +00040540: 2074 6865 2073 616d 6520 6661 6d69 6c79 the same family │ │ │ +00040550: 2061 7320 7468 6520 6164 6472 6573 7320 as the address │ │ │ +00040560: 7765 2772 650a 0909 0909 2f2f 2063 6f6e we're.....// con │ │ │ +00040570: 6e65 6374 696e 6720 746f 290a 0909 0909 necting to)..... │ │ │ +00040580: 6966 2028 6966 6163 652e 6465 7669 6365 if (iface.device │ │ │ +00040590: 2021 3d20 6970 6661 6365 2e6e 616d 6529 != ipface.name) │ │ │ +000405a0: 2063 6f6e 7469 6e75 653b 0a0a 0909 0909 continue;...... │ │ │ +000405b0: 626f 6f6c 2063 6f6e 7374 206c 6f63 616c bool const local │ │ │ +000405c0: 203d 2069 6661 6365 2e6c 6f63 616c 0a09 = iface.local.. │ │ │ +000405d0: 0909 0909 7c7c 2069 7066 6163 652e 696e ....|| ipface.in │ │ │ +000405e0: 7465 7266 6163 655f 6164 6472 6573 732e terface_address. │ │ │ +000405f0: 6973 5f6c 6f6f 7062 6163 6b28 290a 0909 is_loopback()... │ │ │ +00040600: 0909 097c 7c20 6973 5f6c 696e 6b5f 6c6f ...|| is_link_lo │ │ │ +00040610: 6361 6c28 6970 6661 6365 2e69 6e74 6572 cal(ipface.inter │ │ │ +00040620: 6661 6365 5f61 6464 7265 7373 293b 0a3c face_address);.< │ │ │ +00040630: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00040640: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +00040650: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +00040660: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +00040670: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ +000406a0: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ +000406b0: 703a 3233 3232 3c2f 613e 3c2f 7464 3e3c p:2322< │ │ │ +000406c0: 7464 3e69 7420 776f 756c 6420 7072 6f62 td>it would prob │ │ │ +000406d0: 6162 6c79 2062 6520 6265 7474 6572 2074 ably be better t │ │ │ +000406e0: 6f20 646f 2074 6869 7320 6279 2068 6176 o do this by hav │ │ │ +000406f0: 696e 6720 6120 6c69 7374 656e 2d73 6f63 ing a listen-soc │ │ │ +00040700: 6b65 7420 2276 6572 7369 6f6e 2220 6e75 ket "version" nu │ │ │ +00040710: 6d62 6572 2074 6861 7420 6765 7473 2062 mber that gets b │ │ │ +00040720: 756d 7065 642e 2041 6e64 2069 6e73 7465 umped. And inste │ │ │ +00040730: 6164 206f 6620 7365 7474 696e 6720 6120 ad of setting a │ │ │ +00040740: 626f 6f6c 2074 6f20 6469 7361 626c 6520 bool to disable │ │ │ +00040750: 6120 7472 6163 6b65 722c 2077 6520 7365 a tracker, we se │ │ │ +00040760: 7420 7468 6520 7665 7273 696f 6e20 6e75 t the version nu │ │ │ +00040770: 6d62 6572 2074 6861 7420 6974 2077 6173 mber that it was │ │ │ +00040780: 2064 6973 6162 6c65 6420 6174 2e20 5468 disabled at. Th │ │ │ +00040790: 6973 2063 6861 6e67 6520 776f 756c 6420 is change would │ │ │ +000407a0: 6166 6665 6374 2074 6865 2041 4249 2069 affect the ABI i │ │ │ +000407b0: 6e20 312e 322c 2073 6f20 7368 6f75 6c64 n 1.2, so should │ │ │ +000407c0: 2062 6520 646f 6e65 2069 6e20 322e 3020 be done in 2.0 │ │ │ +000407d0: 6f72 206c 6174 6572 3c2f 7464 3e3c 2f74 or later

    it would p │ │ │ +00040830: 726f 6261 626c 7920 6265 2062 6574 7465 robably be bette │ │ │ +00040840: 7220 746f 2064 6f20 7468 6973 2062 7920 r to do this by │ │ │ +00040850: 6861 7669 6e67 2061 0a6c 6973 7465 6e2d having a.listen- │ │ │ +00040860: 736f 636b 6574 2022 7665 7273 696f 6e22 socket "version" │ │ │ +00040870: 206e 756d 6265 7220 7468 6174 2067 6574 number that get │ │ │ +00040880: 7320 6275 6d70 6564 2e20 416e 6420 696e s bumped. And in │ │ │ +00040890: 7374 6561 6420 6f66 0a73 6574 7469 6e67 stead of.setting │ │ │ +000408a0: 2061 2062 6f6f 6c20 746f 2064 6973 6162 a bool to disab │ │ │ +000408b0: 6c65 2061 2074 7261 636b 6572 2c20 7765 le a tracker, we │ │ │ +000408c0: 2073 6574 2074 6865 2076 6572 7369 6f6e set the version │ │ │ +000408d0: 206e 756d 6265 7220 7468 6174 0a69 7420 number that.it │ │ │ +000408e0: 7761 7320 6469 7361 626c 6564 2061 742e was disabled at. │ │ │ +000408f0: 2054 6869 7320 6368 616e 6765 2077 6f75 This change wou │ │ │ +00040900: 6c64 2061 6666 6563 7420 7468 6520 4142 ld affect the AB │ │ │ +00040910: 4920 696e 2031 2e32 2c20 736f 0a73 686f I in 1.2, so.sho │ │ │ +00040920: 756c 6420 6265 2064 6f6e 6520 696e 2032 uld be done in 2 │ │ │ +00040930: 2e30 206f 7220 6c61 7465 723c 2f68 323e .0 or later

    │ │ │ +00040940: 3c68 343e 2e2e 2f73 7263 2f73 6573 7369

    ../src/sessi │ │ │ +00040950: 6f6e 5f69 6d70 6c2e 6370 703a 3233 3232 on_impl.cpp:2322 │ │ │ +00040960: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +000409a0: 097b 0a09 0909 666f 7220 2861 7574 6f20  .{....for (auto 
    │ │ │ +000409b0: 636f 6e73 7426 616d 703b 2073 203a 206d  const& s : m
    │ │ │ +000409c0: 5f6c 6973 7465 6e5f 736f 636b 6574 7329  _listen_sockets)
    │ │ │ +000409d0: 0a09 0909 0972 656d 6170 5f70 6f72 7473  .....remap_ports
    │ │ │ +000409e0: 2872 656d 6170 5f6e 6174 706d 705f 616e  (remap_natpmp_an
    │ │ │ +000409f0: 645f 7570 6e70 2c20 2a73 293b 0a09 097d  d_upnp, *s);...}
    │ │ │ +00040a00: 0a09 0965 6c73 650a 0909 7b0a 0909 092f  ...else...{..../
    │ │ │ +00040a10: 2f20 6e65 7720 736f 636b 6574 7320 6e65  / new sockets ne
    │ │ │ +00040a20: 6564 2074 6f20 6d61 7020 706f 7274 7320  ed to map ports 
    │ │ │ +00040a30: 6576 656e 2069 6620 7468 6520 6361 6c6c  even if the call
    │ │ │ +00040a40: 6572 2064 6964 206e 6f74 2072 6571 7565  er did not reque
    │ │ │ +00040a50: 7374 0a09 0909 2f2f 2072 652d 6d61 7070  st....// re-mapp
    │ │ │ +00040a60: 696e 670a 0909 0966 6f72 2028 6175 746f  ing....for (auto
    │ │ │ +00040a70: 2063 6f6e 7374 2661 6d70 3b20 7320 3a20   const& s : 
    │ │ │ +00040a80: 6e65 775f 736f 636b 6574 7329 0a09 0909  new_sockets)....
    │ │ │ +00040a90: 0972 656d 6170 5f70 6f72 7473 2872 656d  .remap_ports(rem
    │ │ │ +00040aa0: 6170 5f6e 6174 706d 705f 616e 645f 7570  ap_natpmp_and_up
    │ │ │ +00040ab0: 6e70 2c20 2a73 293b 0a09 097d 0a0a 0909  np, *s);...}....
    │ │ │ +00040ac0: 7570 6461 7465 5f6c 7364 2829 3b0a 0a23  update_lsd();..#
    │ │ │ +00040ad0: 6966 2054 4f52 5245 4e54 5f55 5345 5f49  if TORRENT_USE_I
    │ │ │ +00040ae0: 3250 0a09 096f 7065 6e5f 6e65 775f 696e  2P...open_new_in
    │ │ │ +00040af0: 636f 6d69 6e67 5f69 3270 5f63 6f6e 6e65  coming_i2p_conne
    │ │ │ +00040b00: 6374 696f 6e28 293b 0a23 656e 6469 660a  ction();.#endif.
    │ │ │ +00040b10: 0a09 092f 2f20 7472 6163 6b65 7273 2074  ...// trackers t
    │ │ │ +00040b20: 6861 7420 7765 7265 206e 6f74 2072 6561  hat were not rea
    │ │ │ +00040b30: 6368 6162 6c65 2c20 6d61 7920 6861 7665  chable, may have
    │ │ │ +00040b40: 2062 6563 6f6d 6520 7265 6163 6861 626c   become reachabl
    │ │ │ +00040b50: 6520 6e6f 772e 0a09 092f 2f20 736f 2063  e now....// so c
    │ │ │ +00040b60: 6c65 6172 2074 6865 2022 6469 7361 626c  lear the "disabl
    │ │ │ +00040b70: 6564 2220 666c 6167 7320 746f 206c 6574  ed" flags to let
    │ │ │ +00040b80: 2074 6865 6d20 6265 2074 7269 6564 206f   them be tried o
    │ │ │ +00040b90: 6e65 206d 6f72 6520 7469 6d65 0a3c 6469  ne more time...for
    │ │ │ +00040bd0: 2028 6175 746f 2661 6d70 3b20 7420 3a20   (auto& t : 
    │ │ │ +00040be0: 6d5f 746f 7272 656e 7473 290a 3c2f 6469  m_torrents)....t->enabl
    │ │ │ +00040c00: 655f 616c 6c5f 7472 6163 6b65 7273 2829  e_all_trackers()
    │ │ │ +00040c10: 3b0a 097d 0a0a 0976 6f69 6420 7365 7373  ;..}...void sess
    │ │ │ +00040c20: 696f 6e5f 696d 706c 3a3a 7265 6f70 656e  ion_impl::reopen
    │ │ │ +00040c30: 5f6e 6574 776f 726b 5f73 6f63 6b65 7473  _network_sockets
    │ │ │ +00040c40: 2872 656f 7065 6e5f 6e65 7477 6f72 6b5f  (reopen_network_
    │ │ │ +00040c50: 666c 6167 735f 7420 636f 6e73 7420 6f70  flags_t const op
    │ │ │ +00040c60: 7469 6f6e 7329 0a09 7b0a 0909 7265 6f70  tions)..{...reop
    │ │ │ +00040c70: 656e 5f6c 6973 7465 6e5f 736f 636b 6574  en_listen_socket
    │ │ │ +00040c80: 7328 626f 6f6c 286f 7074 696f 6e73 2026  s(bool(options &
    │ │ │ +00040c90: 616d 703b 2073 6573 7369 6f6e 5f68 616e  amp; session_han
    │ │ │ +00040ca0: 646c 653a 3a72 656f 7065 6e5f 6d61 705f  dle::reopen_map_
    │ │ │ +00040cb0: 706f 7274 7329 293b 0a09 7d0a 0a09 6e61  ports));..}...na
    │ │ │ +00040cc0: 6d65 7370 6163 6520 7b0a 0909 7465 6d70  mespace {...temp
    │ │ │ +00040cd0: 6c61 7465 2026 6c74 3b74 7970 656e 616d  late <typenam
    │ │ │ +00040ce0: 6520 4d61 7050 726f 746f 636f 6c2c 2074  e MapProtocol, t
    │ │ │ +00040cf0: 7970 656e 616d 6520 5072 6f74 6f54 7970  ypename ProtoTyp
    │ │ │ +00040d00: 652c 2074 7970 656e 616d 6520 456e 6470  e, typename Endp
    │ │ │ +00040d10: 6f69 6e74 5479 7065 2667 743b 0a09 0976  ointType>...v
    │ │ │ +00040d20: 6f69 6420 6d61 705f 706f 7274 284d 6170  oid map_port(Map
    │ │ │ +00040d30: 5072 6f74 6f63 6f6c 2661 6d70 3b20 6d2c  Protocol& m,
    │ │ │ +00040d40: 2050 726f 746f 5479 7065 2070 726f 746f   ProtoType proto
    │ │ │ +00040d50: 636f 6c2c 2045 6e64 706f 696e 7454 7970  col, EndpointTyp
    │ │ │ +00040d60: 6520 636f 6e73 7426 616d 703b 2065 700a  e const& ep.
    │ │ │ +00040d70: 0909 092c 2070 6f72 745f 6d61 7070 696e  ..., port_mappin
    │ │ │ +00040d80: 675f 7426 616d 703b 206d 6170 5f68 616e  g_t& map_han
    │ │ │ +00040d90: 646c 652c 2073 7464 3a3a 7374 7269 6e67  dle, std::string
    │ │ │ +00040da0: 2063 6f6e 7374 2661 6d70 3b20 6465 7669   const& devi
    │ │ │ +00040db0: 6365 290a 0909 7b0a 0909 0969 6620 286d  ce)...{....if (m
    │ │ │ +00040dc0: 6170 5f68 616e 646c 6520 213d 2070 6f72  ap_handle != por
    │ │ │ +00040dd0: 745f 6d61 7070 696e 675f 747b 2d31 7d29  t_mapping_t{-1})
    │ │ │ +00040de0: 206d 2e64 656c 6574 655f 6d61 7070 696e   m.delete_mappin
    │ │ │ +00040df0: 6728 6d61 705f 6861 6e64 6c65 293b 0a09  g(map_handle);..
    │ │ │ +00040e00: 0909 6d61 705f 6861 6e64 6c65 203d 2070  ..map_handle = p
    │ │ │ +00040e10: 6f72 745f 6d61 7070 696e 675f 747b 2d31  ort_mapping_t{-1
    │ │ │ +00040e20: 7d3b 0a0a 0909 0961 6464 7265 7373 2063  };.....address c
    │ │ │ +00040e30: 6f6e 7374 2061 6464 7220 3d20 6570 2e61  onst addr = ep.a
    │ │ │ +00040e40: 6464 7265 7373 2829 3b0a 0909 092f 2f20  ddress();....// 
    │ │ │ +00040e50: 7769 7468 2049 5076 3420 7468 6520 696e  with IPv4 the in
    │ │ │ +00040e60: 7465 7266 6163 6520 6d69 6768 7420 6265  terface might be
    │ │ │ +00040e70: 2062 6568 696e 6420 4e41 5420 736f 2077   behind NAT so w
    │ │ │ +00040e80: 6520 6361 6e27 7420 736b 6970 2074 6865  e can't skip the
    │ │ │ +00040e90: 6d0a 0909 092f 2f20 6261 7365 6420 6f6e  m....// based on
    │ │ │ +00040ea0: 2074 6865 2073 636f 7065 206f 6620 7468   the scope of th
    │ │ │ +00040eb0: 6520 6c6f 6361 6c20 6164 6472 6573 730a  e local address.
    │ │ │ +00040ec0: 0909 0969 6620 2861 6464 722e 6973 5f76  ...if (addr.is_v
    │ │ │ +00040ed0: 3628 2920 2661 6d70 3b26 616d 703b 2069  6() && i
    │ │ │ +00040ee0: 735f 6c6f 6361 6c28 6164 6472 2929 0a09  s_local(addr))..
    │ │ │ +00040ef0: 0909 0972 6574 7572 6e3b 0a0a 0909 092f  ...return;...../
    │ │ │ +00040f00: 2f20 6f6e 6c79 2075 7064 6174 6520 7468  / only update th
    │ │ │ +00040f10: 6973 206d 6170 7069 6e67 2069 6620 7765  is mapping if we
    │ │ │ +00040f20: 2061 6374 7561 6c6c 7920 6861 7665 2061   actually have a
    │ │ │ +00040f30: 2073 6f63 6b65 7420 6c69 7374 656e 696e   socket listenin
    │ │ │ +00040f40: 670a 0909 0969 6620 2865 7020 213d 2045  g....if (ep != E
    │ │ │ +00040f50: 6e64 706f 696e 7454 7970 6528 2929 0a09  ndpointType())..
    │ │ │ +00040f60: 0909 096d 6170 5f68 616e 646c 6520 3d20  ...map_handle = 
    │ │ │ +00040f70: 6d2e 6164 645f 6d61 7070 696e 6728 7072  m.add_mapping(pr
    │ │ │ +00040f80: 6f74 6f63 6f6c 2c20 6570 2e70 6f72 7428  otocol, ep.port(
    │ │ │ +00040f90: 292c 2065 702c 2064 6576 6963 6529 3b0a  ), ep, device);.
    │ │ │ +00040fa0: 0909 7d0a 097d 0a0a 0976 6f69 6420 7365  ..}..}...void se
    │ │ │ +00040fb0: 7373 696f 6e5f 696d 706c 3a3a 7265 6d61  ssion_impl::rema
    │ │ │ +00040fc0: 705f 706f 7274 7328 7265 6d61 705f 706f  p_ports(remap_po
    │ │ │ +00040fd0: 7274 5f6d 6173 6b5f 7420 636f 6e73 7420  rt_mask_t const 
    │ │ │ +00040fe0: 6d61 736b 0a09 092c 206c 6973 7465 6e5f  mask..., listen_
    │ │ │ +00040ff0: 736f 636b 6574 5f74 2661 6d70 3b20 7329  socket_t& s)
    │ │ │ +00041000: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472  .
    relevance  │ │ │ +00041040: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +00041070: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ +00041080: 6370 703a 3238 3834 3c2f 613e 3c2f 7464 cpp:2884this size n │ │ │ +000410a0: 6565 6420 746f 2062 6520 6361 7070 6564 eed to be capped │ │ │ +000410b0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    th │ │ │ +00041100: 6973 2073 697a 6520 6e65 6564 2074 6f20 is size need to │ │ │ +00041110: 6265 2063 6170 7065 643c 2f68 323e 3c68 be capped

    ../src/session │ │ │ +00041130: 5f69 6d70 6c2e 6370 703a 3238 3834 3c2f _impl.cpp:2884
    ...
    │ │ │ +00041180: 092f 2f20 6861 6e64 7368 616b 696e 670a  .// handshaking.
    │ │ │ +00041190: 0909 0909 7265 7475 726e 2073 6f63 6b65  ....return socke
    │ │ │ +000411a0: 745f 7479 7065 2873 736c 5f73 7472 6561  t_type(ssl_strea
    │ │ │ +000411b0: 6d26 6c74 3b74 6370 3a3a 736f 636b 6574  m<tcp::socket
    │ │ │ +000411c0: 2667 743b 2874 6370 3a3a 736f 636b 6574  >(tcp::socket
    │ │ │ +000411d0: 2873 7464 3a3a 6d6f 7665 2873 2929 2c20  (std::move(s)), 
    │ │ │ +000411e0: 6d5f 7065 6572 5f73 736c 5f63 7478 2929  m_peer_ssl_ctx))
    │ │ │ +000411f0: 3b0a 0909 097d 0a09 0909 656c 7365 0a23  ;....}....else.#
    │ │ │ +00041200: 656e 6469 660a 0909 097b 0a09 0909 0972  endif....{.....r
    │ │ │ +00041210: 6574 7572 6e20 736f 636b 6574 5f74 7970  eturn socket_typ
    │ │ │ +00041220: 6528 7463 703a 3a73 6f63 6b65 7428 7374  e(tcp::socket(st
    │ │ │ +00041230: 643a 3a6d 6f76 6528 7329 2929 3b0a 0909  d::move(s)));...
    │ │ │ +00041240: 097d 0a09 097d 2829 3b0a 0a23 6966 6465  .}...}();..#ifde
    │ │ │ +00041250: 6620 544f 5252 454e 545f 5353 4c5f 5045  f TORRENT_SSL_PE
    │ │ │ +00041260: 4552 530a 0909 544f 5252 454e 545f 4153  ERS...TORRENT_AS
    │ │ │ +00041270: 5345 5254 2828 7373 6c20 3d3d 2074 7261  SERT((ssl == tra
    │ │ │ +00041280: 6e73 706f 7274 3a3a 7373 6c29 203d 3d20  nsport::ssl) == 
    │ │ │ +00041290: 6973 5f73 736c 2863 2929 3b0a 2365 6e64  is_ssl(c));.#end
    │ │ │ +000412a0: 6966 0a0a 2369 6664 6566 2054 4f52 5245  if..#ifdef TORRE
    │ │ │ +000412b0: 4e54 5f53 534c 5f50 4545 5253 0a09 0969  NT_SSL_PEERS...i
    │ │ │ +000412c0: 6620 2873 736c 203d 3d20 7472 616e 7370  f (ssl == transp
    │ │ │ +000412d0: 6f72 743a 3a73 736c 290a 0909 7b0a 0909  ort::ssl)...{...
    │ │ │ +000412e0: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ +000412f0: 6973 5f73 736c 2863 2929 3b0a 0a09 0909  is_ssl(c));.....
    │ │ │ +00041300: 2f2f 2073 6176 6520 7468 6520 736f 636b  // save the sock
    │ │ │ +00041310: 6574 2073 6f20 7765 2063 616e 2063 616e  et so we can can
    │ │ │ +00041320: 6365 6c20 7468 6520 6861 6e64 7368 616b  cel the handshak
    │ │ │ +00041330: 650a 3c64 6976 2073 7479 6c65 3d22 6261  e.
    │ │ │ +00041360: 0909 0961 7574 6f20 6974 6572 203d 206d ...auto iter = m │ │ │ +00041370: 5f69 6e63 6f6d 696e 675f 736f 636b 6574 _incoming_socket │ │ │ +00041380: 732e 656d 706c 6163 6528 7374 643a 3a6d s.emplace(std::m │ │ │ +00041390: 616b 655f 756e 6971 7565 266c 743b 736f ake_unique<so │ │ │ +000413a0: 636b 6574 5f74 7970 6526 6774 3b28 7374 cket_type>(st │ │ │ +000413b0: 643a 3a6d 6f76 6528 6329 2929 2e66 6972 d::move(c))).fir │ │ │ +000413c0: 7374 3b0a 3c2f 6469 763e 0a09 0909 6175 st;.
    ....au │ │ │ +000413d0: 746f 2073 6f63 6b20 3d20 6974 6572 2d26 to sock = iter-& │ │ │ +000413e0: 6774 3b67 6574 2829 3b0a 0909 092f 2f20 gt;get();....// │ │ │ +000413f0: 666f 7220 5353 4c20 636f 6e6e 6563 7469 for SSL connecti │ │ │ +00041400: 6f6e 732c 2069 6e63 6f6d 696e 675f 636f ons, incoming_co │ │ │ +00041410: 6e6e 6563 7469 6f6e 2829 2069 7320 6361 nnection() is ca │ │ │ +00041420: 6c6c 6564 0a09 0909 2f2f 2061 6674 6572 lled....// after │ │ │ +00041430: 2074 6865 2068 616e 6473 6861 6b65 2069 the handshake i │ │ │ +00041440: 7320 646f 6e65 0a09 0909 4144 445f 4f55 s done....ADD_OU │ │ │ +00041450: 5453 5441 4e44 494e 475f 4153 594e 4328 TSTANDING_ASYNC( │ │ │ +00041460: 2273 6573 7369 6f6e 5f69 6d70 6c3a 3a73 "session_impl::s │ │ │ +00041470: 736c 5f68 616e 6473 6861 6b65 2229 3b0a sl_handshake");. │ │ │ +00041480: 0909 0962 6f6f 7374 3a3a 6765 7426 6c74 ...boost::get< │ │ │ +00041490: 3b73 736c 5f73 7472 6561 6d26 6c74 3b74 ;ssl_stream<t │ │ │ +000414a0: 6370 3a3a 736f 636b 6574 2667 743b 2667 cp::socket>&g │ │ │ +000414b0: 743b 282a 2a69 7465 7229 2e61 7379 6e63 t;(**iter).async │ │ │ +000414c0: 5f61 6363 6570 745f 6861 6e64 7368 616b _accept_handshak │ │ │ +000414d0: 6528 0a09 0909 095b 7468 6973 2c20 736f e(.....[this, so │ │ │ +000414e0: 636b 5d20 2865 7272 6f72 5f63 6f64 6520 ck] (error_code │ │ │ +000414f0: 636f 6e73 7426 616d 703b 2065 7272 2920 const& err) │ │ │ +00041500: 7b20 7373 6c5f 6861 6e64 7368 616b 6528 { ssl_handshake( │ │ │ +00041510: 6572 722c 2073 6f63 6b29 3b20 7d29 3b0a err, sock); });. │ │ │ +00041520: 0909 7d0a 0909 656c 7365 0a23 656e 6469 ..}...else.#endi │ │ │ +00041530: 660a 0909 7b0a 0909 0969 6e63 6f6d 696e f...{....incomin │ │ │ +00041540: 675f 636f 6e6e 6563 7469 6f6e 2873 7464 g_connection(std │ │ │ +00041550: 3a3a 6d6f 7665 2863 2929 3b0a 0909 7d0a ::move(c));...}. │ │ │ +00041560: 097d 0a0a 2369 6664 6566 2054 4f52 5245 .}..#ifdef TORRE │ │ │ +00041570: 4e54 5f53 534c 5f50 4545 5253 0a0a 0976 NT_SSL_PEERS...v │ │ │ +00041580: 6f69 6420 7365 7373 696f 6e5f 696d 706c oid session_impl │ │ │ +00041590: 3a3a 6f6e 5f69 6e63 6f6d 696e 675f 7574 ::on_incoming_ut │ │ │ +000415a0: 705f 7373 6c28 736f 636b 6574 5f74 7970 p_ssl(socket_typ │ │ │ +000415b0: 6520 7329 0a09 7b0a 0909 544f 5252 454e e s)..{...TORREN │ │ │ +000415c0: 545f 4153 5345 5254 2869 735f 7373 6c28 T_ASSERT(is_ssl( │ │ │ +000415d0: 7329 293b 0a0a 0909 2f2f 2073 6176 6520 s));....// save │ │ │ +000415e0: 7468 6520 736f 636b 6574 2073 6f20 7765 the socket so we │ │ │ +000415f0: 2063 616e 2063 616e 6365 6c20 7468 6520 can cancel the │ │ │ +00041600: 6861 6e64 7368 616b 650a 0a3c 2f70 7265 handshake..
    rele │ │ │ +00041640: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/ses │ │ │ +00041680: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3239 sion_impl.cpp:29 │ │ │ +00041690: 3039 3c2f 613e 3c2f 7464 3e3c 7464 3e74 09t │ │ │ +000416a0: 6869 7320 7369 7a65 206e 6565 6420 746f his size need to │ │ │ +000416b0: 2062 6520 6361 7070 6564 3c2f 7464 3e3c be capped< │ │ │ +000416c0: 2f74 723e 3c74 7220 6964 3d22 3136 3022 /tr>

    this siz │ │ │ +00041710: 6520 6e65 6564 2074 6f20 6265 2063 6170 e need to be cap │ │ │ +00041720: 7065 643c 2f68 323e 3c68 343e 2e2e 2f73 ped

    ../s │ │ │ +00041730: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ +00041740: 6370 703a 3239 3039 3c2f 6834 3e3c 7072 cpp:2909

    ...// aft │ │ │ +00041790: 6572 2074 6865 2068 616e 6473 6861 6b65 er the handshake │ │ │ +000417a0: 2069 7320 646f 6e65 0a09 0909 4144 445f is done....ADD_ │ │ │ +000417b0: 4f55 5453 5441 4e44 494e 475f 4153 594e OUTSTANDING_ASYN │ │ │ +000417c0: 4328 2273 6573 7369 6f6e 5f69 6d70 6c3a C("session_impl: │ │ │ +000417d0: 3a73 736c 5f68 616e 6473 6861 6b65 2229 :ssl_handshake") │ │ │ +000417e0: 3b0a 0909 0962 6f6f 7374 3a3a 6765 7426 ;....boost::get& │ │ │ +000417f0: 6c74 3b73 736c 5f73 7472 6561 6d26 6c74 lt;ssl_stream< │ │ │ +00041800: 3b74 6370 3a3a 736f 636b 6574 2667 743b ;tcp::socket> │ │ │ +00041810: 2667 743b 282a 2a69 7465 7229 2e61 7379 >(**iter).asy │ │ │ +00041820: 6e63 5f61 6363 6570 745f 6861 6e64 7368 nc_accept_handsh │ │ │ +00041830: 616b 6528 0a09 0909 095b 7468 6973 2c20 ake(.....[this, │ │ │ +00041840: 736f 636b 5d20 2865 7272 6f72 5f63 6f64 sock] (error_cod │ │ │ +00041850: 6520 636f 6e73 7426 616d 703b 2065 7272 e const& err │ │ │ +00041860: 2920 7b20 7373 6c5f 6861 6e64 7368 616b ) { ssl_handshak │ │ │ +00041870: 6528 6572 722c 2073 6f63 6b29 3b20 7d29 e(err, sock); }) │ │ │ +00041880: 3b0a 0909 7d0a 0909 656c 7365 0a23 656e ;...}...else.#en │ │ │ +00041890: 6469 660a 0909 7b0a 0909 0969 6e63 6f6d dif...{....incom │ │ │ +000418a0: 696e 675f 636f 6e6e 6563 7469 6f6e 2873 ing_connection(s │ │ │ +000418b0: 7464 3a3a 6d6f 7665 2863 2929 3b0a 0909 td::move(c));... │ │ │ +000418c0: 7d0a 097d 0a0a 2369 6664 6566 2054 4f52 }..}..#ifdef TOR │ │ │ +000418d0: 5245 4e54 5f53 534c 5f50 4545 5253 0a0a RENT_SSL_PEERS.. │ │ │ +000418e0: 0976 6f69 6420 7365 7373 696f 6e5f 696d .void session_im │ │ │ +000418f0: 706c 3a3a 6f6e 5f69 6e63 6f6d 696e 675f pl::on_incoming_ │ │ │ +00041900: 7574 705f 7373 6c28 736f 636b 6574 5f74 utp_ssl(socket_t │ │ │ +00041910: 7970 6520 7329 0a09 7b0a 0909 544f 5252 ype s)..{...TORR │ │ │ +00041920: 454e 545f 4153 5345 5254 2869 735f 7373 ENT_ASSERT(is_ss │ │ │ +00041930: 6c28 7329 293b 0a0a 0909 2f2f 2073 6176 l(s));....// sav │ │ │ +00041940: 6520 7468 6520 736f 636b 6574 2073 6f20 e the socket so │ │ │ +00041950: 7765 2063 616e 2063 616e 6365 6c20 7468 we can cancel th │ │ │ +00041960: 6520 6861 6e64 7368 616b 650a 0a3c 6469 e handshake....aut │ │ │ +000419a0: 6f20 6974 6572 203d 206d 5f69 6e63 6f6d o iter = m_incom │ │ │ +000419b0: 696e 675f 736f 636b 6574 732e 656d 706c ing_sockets.empl │ │ │ +000419c0: 6163 6528 7374 643a 3a6d 616b 655f 756e ace(std::make_un │ │ │ +000419d0: 6971 7565 266c 743b 736f 636b 6574 5f74 ique<socket_t │ │ │ +000419e0: 7970 6526 6774 3b28 7374 643a 3a6d 6f76 ype>(std::mov │ │ │ +000419f0: 6528 7329 2929 2e66 6972 7374 3b0a 3c2f e(s))).first;...auto sock │ │ │ +00041a10: 3d20 6974 6572 2d26 6774 3b67 6574 2829 = iter->get() │ │ │ +00041a20: 3b0a 0a09 092f 2f20 666f 7220 5353 4c20 ;....// for SSL │ │ │ +00041a30: 636f 6e6e 6563 7469 6f6e 732c 2069 6e63 connections, inc │ │ │ +00041a40: 6f6d 696e 675f 636f 6e6e 6563 7469 6f6e oming_connection │ │ │ +00041a50: 2829 2069 7320 6361 6c6c 6564 0a09 092f () is called.../ │ │ │ +00041a60: 2f20 6166 7465 7220 7468 6520 6861 6e64 / after the hand │ │ │ +00041a70: 7368 616b 6520 6973 2064 6f6e 650a 0909 shake is done... │ │ │ +00041a80: 4144 445f 4f55 5453 5441 4e44 494e 475f ADD_OUTSTANDING_ │ │ │ +00041a90: 4153 594e 4328 2273 6573 7369 6f6e 5f69 ASYNC("session_i │ │ │ +00041aa0: 6d70 6c3a 3a73 736c 5f68 616e 6473 6861 mpl::ssl_handsha │ │ │ +00041ab0: 6b65 2229 3b0a 0909 626f 6f73 743a 3a67 ke");...boost::g │ │ │ +00041ac0: 6574 266c 743b 7373 6c5f 7374 7265 616d et<ssl_stream │ │ │ +00041ad0: 266c 743b 7574 705f 7374 7265 616d 2667 <utp_stream&g │ │ │ +00041ae0: 743b 2667 743b 282a 2a69 7465 7229 2e61 t;>(**iter).a │ │ │ +00041af0: 7379 6e63 5f61 6363 6570 745f 6861 6e64 sync_accept_hand │ │ │ +00041b00: 7368 616b 6528 0a09 0909 5b74 6869 732c shake(....[this, │ │ │ +00041b10: 2073 6f63 6b5d 2028 6572 726f 725f 636f sock] (error_co │ │ │ +00041b20: 6465 2063 6f6e 7374 2661 6d70 3b20 6572 de const& er │ │ │ +00041b30: 7229 207b 2073 736c 5f68 616e 6473 6861 r) { ssl_handsha │ │ │ +00041b40: 6b65 2865 7272 2c20 736f 636b 293b 207d ke(err, sock); } │ │ │ +00041b50: 293b 0a09 7d0a 0a09 2f2f 2074 6f20 7465 );..}...// to te │ │ │ +00041b60: 7374 2053 534c 2063 6f6e 6e65 6374 696f st SSL connectio │ │ │ +00041b70: 6e73 2c20 6f6e 6520 6361 6e20 7573 6520 ns, one can use │ │ │ +00041b80: 7468 6973 206f 7065 6e73 736c 2063 6f6d this openssl com │ │ │ +00041b90: 6d61 6e64 2074 656d 706c 6174 653a 0a09 mand template:.. │ │ │ +00041ba0: 2f2f 0a09 2f2f 206f 7065 6e73 736c 2073 //..// openssl s │ │ │ +00041bb0: 5f63 6c69 656e 7420 2d63 6572 7420 266c _client -cert &l │ │ │ +00041bc0: 743b 636c 6965 6e74 2d63 6572 7426 6774 t;client-cert> │ │ │ +00041bd0: 3b2e 7065 6d20 2d6b 6579 2026 6c74 3b63 ;.pem -key <c │ │ │ +00041be0: 6c69 656e 742d 7072 6976 6174 652d 6b65 lient-private-ke │ │ │ +00041bf0: 7926 6774 3b2e 7065 6d0a 092f 2f20 2020 y>.pem..// │ │ │ +00041c00: 2d43 4166 696c 6520 266c 743b 746f 7272 -CAfile <torr │ │ │ +00041c10: 656e 742d 6365 7274 2667 743b 2e70 656d ent-cert>.pem │ │ │ +00041c20: 2020 2d64 6562 7567 202d 636f 6e6e 6563 -debug -connec │ │ │ +00041c30: 7420 3132 372e 302e 302e 313a 3434 3333 t 127.0.0.1:4433 │ │ │ +00041c40: 202d 746c 7331 0a09 2f2f 2020 202d 7365 -tls1..// -se │ │ │ +00041c50: 7276 6572 6e61 6d65 2026 6c74 3b68 6578 rvername <hex │ │ │ +00041c60: 2d65 6e63 6f64 6564 2d69 6e66 6f2d 6861 -encoded-info-ha │ │ │ +00041c70: 7368 2667 743b 0a0a 0976 6f69 6420 7365 sh>...void se │ │ │ +00041c80: 7373 696f 6e5f 696d 706c 3a3a 7373 6c5f ssion_impl::ssl_ │ │ │ +00041c90: 6861 6e64 7368 616b 6528 6572 726f 725f handshake(error_ │ │ │ +00041ca0: 636f 6465 2063 6f6e 7374 2661 6d70 3b20 code const& │ │ │ +00041cb0: 6563 2c20 736f 636b 6574 5f74 7970 652a ec, socket_type* │ │ │ +00041cc0: 2073 6f63 6b29 0a09 7b0a 0909 434f 4d50 sock)..{...COMP │ │ │ +00041cd0: 4c45 5445 5f41 5359 4e43 2822 7365 7373 LETE_ASYNC("sess │ │ │ +00041ce0: 696f 6e5f 696d 706c 3a3a 7373 6c5f 6861 ion_impl::ssl_ha │ │ │ +00041cf0: 6e64 7368 616b 6522 293b 0a0a 0909 6175 ndshake");....au │ │ │ +00041d00: 746f 2069 7465 7220 3d20 6d5f 696e 636f to iter = m_inco │ │ │ +00041d10: 6d69 6e67 5f73 6f63 6b65 7473 2e66 696e ming_sockets.fin │ │ │ +00041d20: 6428 736f 636b 293b 0a0a 0909 2f2f 2074 d(sock);....// t │ │ │ +00041d30: 6869 7320 6861 7070 656e 7320 6966 2074 his happens if t │ │ │ +00041d40: 6865 2053 534c 2063 6f6e 6e65 6374 696f he SSL connectio │ │ │ +00041d50: 6e20 6973 2061 626f 7274 6564 2062 6563 n is aborted bec │ │ │ +00041d60: 6175 7365 2077 6527 7265 2073 6875 7474 ause we're shutt │ │ │ +00041d70: 696e 670a 0909 2f2f 2064 6f77 6e0a 0909 ing...// down... │ │ │ +00041d80: 6966 2028 6974 6572 203d 3d20 6d5f 696e if (iter == m_in │ │ │ +00041d90: 636f 6d69 6e67 5f73 6f63 6b65 7473 2e65 coming_sockets.e │ │ │ +00041da0: 6e64 2829 2920 7265 7475 726e 3b0a 0a09 nd()) return;... │ │ │ +00041db0: 0973 6f63 6b65 745f 7479 7065 2073 2873 .socket_type s(s │ │ │ +00041dc0: 7464 3a3a 6d6f 7665 282a 2a69 7465 7229 td::move(**iter) │ │ │ +00041dd0: 293b 0a09 0954 4f52 5245 4e54 5f41 5353 );...TORRENT_ASS │ │ │ +00041de0: 4552 5428 6973 5f73 736c 2873 2929 3b0a ERT(is_ssl(s));. │ │ │ +00041df0: 0909 6d5f 696e 636f 6d69 6e67 5f73 6f63 ..m_incoming_soc │ │ │ +00041e00: 6b65 7473 2e65 7261 7365 2869 7465 7229 kets.erase(iter) │ │ │ +00041e10: 3b0a 0a09 0965 7272 6f72 5f63 6f64 6520 ;....error_code │ │ │ +00041e20: 653b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f e;.
    │ │ │ +00041e50: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00041e60: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +00041e90: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ +00041ea0: 6c2e 6370 703a 3336 3038 3c2f 613e 3c2f l.cpp:3608have a se │ │ │ +00041ec0: 7061 7261 7465 206c 6973 7420 666f 7220 parate list for │ │ │ +00041ed0: 7468 6573 6520 636f 6e6e 6563 7469 6f6e these connection │ │ │ +00041ee0: 732c 2069 6e73 7465 6164 206f 6620 6861 s, instead of ha │ │ │ +00041ef0: 7669 6e67 2074 6f20 6c6f 6f70 2074 6872 ving to loop thr │ │ │ +00041f00: 6f75 6768 2061 6c6c 206f 6620 7468 656d ough all of them │ │ │ +00041f10: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    ha │ │ │ +00041f60: 7665 2061 2073 6570 6172 6174 6520 6c69 ve a separate li │ │ │ +00041f70: 7374 2066 6f72 2074 6865 7365 2063 6f6e st for these con │ │ │ +00041f80: 6e65 6374 696f 6e73 2c20 696e 7374 6561 nections, instea │ │ │ +00041f90: 6420 6f66 2068 6176 696e 6720 746f 206c d of having to l │ │ │ +00041fa0: 6f6f 7020 7468 726f 7567 6820 616c 6c20 oop through all │ │ │ +00041fb0: 6f66 2074 6865 6d3c 2f68 323e 3c68 343e of them

    │ │ │ +00041fc0: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ +00041fd0: 6d70 6c2e 6370 703a 3336 3038 3c2f 6834 mpl.cpp:3608

    ..// 
    │ │ │ +00042020: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00042030: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00042040: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00042050: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 0a09  --------------..
    │ │ │ +00042060: 0969 6620 2821 6d5f 7061 7573 6564 2920  .if (!m_paused) 
    │ │ │ +00042070: 6d5f 6175 746f 5f6d 616e 6167 655f 7469  m_auto_manage_ti
    │ │ │ +00042080: 6d65 5f73 6361 6c65 722d 2d3b 0a09 0969  me_scaler--;...i
    │ │ │ +00042090: 6620 286d 5f61 7574 6f5f 6d61 6e61 6765  f (m_auto_manage
    │ │ │ +000420a0: 5f74 696d 655f 7363 616c 6572 2026 6c74  _time_scaler <
    │ │ │ +000420b0: 3b20 3029 0a09 097b 0a09 0909 6d5f 6175  ; 0)...{....m_au
    │ │ │ +000420c0: 746f 5f6d 616e 6167 655f 7469 6d65 5f73  to_manage_time_s
    │ │ │ +000420d0: 6361 6c65 7220 3d20 7365 7474 696e 6773  caler = settings
    │ │ │ +000420e0: 2829 2e67 6574 5f69 6e74 2873 6574 7469  ().get_int(setti
    │ │ │ +000420f0: 6e67 735f 7061 636b 3a3a 6175 746f 5f6d  ngs_pack::auto_m
    │ │ │ +00042100: 616e 6167 655f 696e 7465 7276 616c 293b  anage_interval);
    │ │ │ +00042110: 0a09 0909 7265 6361 6c63 756c 6174 655f  ....recalculate_
    │ │ │ +00042120: 6175 746f 5f6d 616e 6167 6564 5f74 6f72  auto_managed_tor
    │ │ │ +00042130: 7265 6e74 7328 293b 0a09 097d 0a0a 0909  rents();...}....
    │ │ │ +00042140: 2f2f 202d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  // -------------
    │ │ │ +00042150: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00042160: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00042170: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00042180: 2d0a 0909 2f2f 2063 6865 636b 2066 6f72  -...// check for
    │ │ │ +00042190: 2069 6e63 6f6d 696e 6720 636f 6e6e 6563   incoming connec
    │ │ │ +000421a0: 7469 6f6e 7320 7468 6174 206d 6967 6874  tions that might
    │ │ │ +000421b0: 2068 6176 6520 7469 6d65 6420 6f75 740a   have timed out.
    │ │ │ +000421c0: 0909 2f2f 202d 2d2d 2d2d 2d2d 2d2d 2d2d  ..// -----------
    │ │ │ +000421d0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +000421e0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +000421f0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00042200: 2d2d 2d0a 0a09 0966 6f72 2028 6175 746f  ---....for (auto
    │ │ │ +00042210: 2069 203d 206d 5f63 6f6e 6e65 6374 696f   i = m_connectio
    │ │ │ +00042220: 6e73 2e62 6567 696e 2829 3b20 6920 213d  ns.begin(); i !=
    │ │ │ +00042230: 206d 5f63 6f6e 6e65 6374 696f 6e73 2e65   m_connections.e
    │ │ │ +00042240: 6e64 2829 3b29 0a09 097b 0a09 0909 7065  nd();)...{....pe
    │ │ │ +00042250: 6572 5f63 6f6e 6e65 6374 696f 6e2a 2070  er_connection* p
    │ │ │ +00042260: 203d 2028 2a69 292e 6765 7428 293b 0a09   = (*i).get();..
    │ │ │ +00042270: 0909 2b2b 693b 0a09 0909 2f2f 2069 676e  ..++i;....// ign
    │ │ │ +00042280: 6f72 6520 636f 6e6e 6563 7469 6f6e 7320  ore connections 
    │ │ │ +00042290: 7468 6174 2061 6c72 6561 6479 2068 6176  that already hav
    │ │ │ +000422a0: 6520 6120 746f 7272 656e 742c 2073 696e  e a torrent, sin
    │ │ │ +000422b0: 6365 2074 6865 790a 0909 092f 2f20 6172  ce they....// ar
    │ │ │ +000422c0: 6520 7469 636b 6564 2074 6872 6f75 6768  e ticked through
    │ │ │ +000422d0: 2074 6865 2074 6f72 7265 6e74 7327 2073   the torrents' s
    │ │ │ +000422e0: 6563 6f6e 645f 7469 636b 0a09 0909 6966  econd_tick....if
    │ │ │ +000422f0: 2028 2170 2d26 6774 3b61 7373 6f63 6961   (!p->associa
    │ │ │ +00042300: 7465 645f 746f 7272 656e 7428 292e 6578  ted_torrent().ex
    │ │ │ +00042310: 7069 7265 6428 2929 2063 6f6e 7469 6e75  pired()) continu
    │ │ │ +00042320: 653b 0a0a 3c64 6976 2073 7479 6c65 3d22  e;..
    ...int timeout │ │ │ +00042360: 203d 206d 5f73 6574 7469 6e67 732e 6765 = m_settings.ge │ │ │ +00042370: 745f 696e 7428 7365 7474 696e 6773 5f70 t_int(settings_p │ │ │ +00042380: 6163 6b3a 3a68 616e 6473 6861 6b65 5f74 ack::handshake_t │ │ │ +00042390: 696d 656f 7574 293b 0a3c 2f64 6976 3e23 imeout);.
    # │ │ │ +000423a0: 6966 2054 4f52 5245 4e54 5f55 5345 5f49 if TORRENT_USE_I │ │ │ +000423b0: 3250 0a09 0909 7469 6d65 6f75 7420 2a3d 2P....timeout *= │ │ │ +000423c0: 2069 735f 6932 7028 702d 2667 743b 6765 is_i2p(p->ge │ │ │ +000423d0: 745f 736f 636b 6574 2829 2920 3f20 3420 t_socket()) ? 4 │ │ │ +000423e0: 3a20 313b 0a23 656e 6469 660a 0909 0969 : 1;.#endif....i │ │ │ +000423f0: 6620 286d 5f6c 6173 745f 7469 636b 202d f (m_last_tick - │ │ │ +00042400: 2070 2d26 6774 3b63 6f6e 6e65 6374 6564 p->connected │ │ │ +00042410: 5f74 696d 6520 2829 2026 6774 3b20 7365 _time () > se │ │ │ +00042420: 636f 6e64 7328 7469 6d65 6f75 7429 290a conds(timeout)). │ │ │ +00042430: 0909 0909 702d 2667 743b 6469 7363 6f6e ....p->discon │ │ │ +00042440: 6e65 6374 2865 7272 6f72 733a 3a74 696d nect(errors::tim │ │ │ +00042450: 6564 5f6f 7574 2c20 6f70 6572 6174 696f ed_out, operatio │ │ │ +00042460: 6e5f 743a 3a62 6974 746f 7272 656e 7429 n_t::bittorrent) │ │ │ +00042470: 3b0a 0909 7d0a 0a09 092f 2f20 2d2d 2d2d ;...}....// ---- │ │ │ +00042480: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00042490: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +000424a0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +000424b0: 2d2d 2d2d 2d2d 2d2d 2d2d 0a09 092f 2f20 ----------...// │ │ │ +000424c0: 7365 636f 6e64 5f74 6963 6b20 6576 6572 second_tick ever │ │ │ +000424d0: 7920 746f 7272 656e 7420 2874 6861 7420 y torrent (that │ │ │ +000424e0: 7761 6e74 7320 6974 290a 0909 2f2f 202d wants it)...// - │ │ │ +000424f0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00042500: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00042510: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00042520: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d0a 0a23 -------------..# │ │ │ +00042530: 6966 2054 4f52 5245 4e54 5f44 4542 5547 if TORRENT_DEBUG │ │ │ +00042540: 5f53 5452 4541 4d49 4e47 2026 6774 3b20 _STREAMING > │ │ │ +00042550: 300a 0909 7374 643a 3a70 7269 6e74 6628 0...std::printf( │ │ │ +00042560: 225c 3033 335b 324a 5c30 3333 5b30 3b30 "\033[2J\033[0;0 │ │ │ +00042570: 4822 293b 0a23 656e 6469 660a 0a09 0961 H");.#endif....a │ │ │ +00042580: 7578 3a3a 7665 6374 6f72 266c 743b 746f ux::vector<to │ │ │ +00042590: 7272 656e 742a 2667 743b 2661 6d70 3b20 rrent*>& │ │ │ +000425a0: 7761 6e74 5f74 6963 6b20 3d20 6d5f 746f want_tick = m_to │ │ │ +000425b0: 7272 656e 745f 6c69 7374 735b 746f 7272 rrent_lists[torr │ │ │ +000425c0: 656e 745f 7761 6e74 5f74 6963 6b5d 3b0a ent_want_tick];. │ │ │ +000425d0: 0909 666f 7220 2869 6e74 2069 203d 2030 ..for (int i = 0 │ │ │ +000425e0: 3b20 6920 266c 743b 2069 6e74 2877 616e ; i < int(wan │ │ │ +000425f0: 745f 7469 636b 2e73 697a 6528 2929 3b20 t_tick.size()); │ │ │ +00042600: 2b2b 6929 0a09 097b 0a09 0909 746f 7272 ++i)...{....torr │ │ │ +00042610: 656e 7426 616d 703b 2074 203d 202a 7761 ent& t = *wa │ │ │ +00042620: 6e74 5f74 6963 6b5b 695d 3b0a 0909 0954 nt_tick[i];....T │ │ │ +00042630: 4f52 5245 4e54 5f41 5353 4552 5428 742e ORRENT_ASSERT(t. │ │ │ +00042640: 7761 6e74 5f74 6963 6b28 2929 3b0a 0909 want_tick());... │ │ │ +00042650: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ +00042660: 2174 2e69 735f 6162 6f72 7465 6428 2929 !t.is_aborted()) │ │ │ +00042670: 3b0a 0a09 0909 742e 7365 636f 6e64 5f74 ;.....t.second_t │ │ │ +00042680: 6963 6b28 7469 636b 5f69 6e74 6572 7661 ick(tick_interva │ │ │ +00042690: 6c5f 6d73 293b 0a0a 0909 092f 2f20 6966 l_ms);.....// if │ │ │ +000426a0: 2074 6865 2063 616c 6c20 746f 2073 6563 the call to sec │ │ │ +000426b0: 6f6e 645f 7469 636b 2063 6175 7365 6420 ond_tick caused │ │ │ +000426c0: 7468 6520 746f 7272 656e 740a 0909 092f the torrent..../ │ │ │ +000426d0: 2f20 746f 206e 6f20 6c6f 6e67 6572 2077 / to no longer w │ │ │ +000426e0: 616e 7420 746f 2062 6520 7469 636b 6564 ant to be ticked │ │ │ +000426f0: 2028 692e 652e 2069 7420 7761 730a 0909 (i.e. it was... │ │ │ +00042700: 092f 2f20 7265 6d6f 7665 6420 6672 6f6d .// removed from │ │ │ +00042710: 2074 6865 206c 6973 7429 2077 6520 6e65 the list) we ne │ │ │ +00042720: 6564 2074 6f20 6261 636b 2075 7020 7468 ed to back up th │ │ │ +00042730: 6520 636f 756e 7465 720a 0909 092f 2f20 e counter....// │ │ │ +00042740: 746f 206e 6f74 206d 6973 7320 7468 6520 to not miss the │ │ │ +00042750: 746f 7272 656e 7420 6166 7465 7220 6974 torrent after it │ │ │ +00042760: 0a09 0909 6966 2028 2174 2e77 616e 745f ....if (!t.want_ │ │ │ +00042770: 7469 636b 2829 2920 2d2d 693b 0a09 097d tick()) --i;...} │ │ │ +00042780: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +000427c0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +000427f0: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ +00042800: 6370 703a 3336 3431 3c2f 613e 3c2f 7464 cpp:3641this should │ │ │ +00042820: 2061 7070 6c79 2074 6f20 616c 6c20 6261 apply to all ba │ │ │ +00042830: 6e64 7769 6474 6820 6368 616e 6e65 6c73 ndwidth channels │ │ │ +00042840: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    th │ │ │ +00042890: 6973 2073 686f 756c 6420 6170 706c 7920 is should apply │ │ │ +000428a0: 746f 2061 6c6c 2062 616e 6477 6964 7468 to all bandwidth │ │ │ +000428b0: 2063 6861 6e6e 656c 733c 2f68 323e 3c68 channels

    ../src/session │ │ │ +000428d0: 5f69 6d70 6c2e 6370 703a 3336 3431 3c2f _impl.cpp:3641
    #if
    │ │ │ +00042920: 2054 4f52 5245 4e54 5f44 4542 5547 5f53   TORRENT_DEBUG_S
    │ │ │ +00042930: 5452 4541 4d49 4e47 2026 6774 3b20 300a  TREAMING > 0.
    │ │ │ +00042940: 0909 7374 643a 3a70 7269 6e74 6628 225c  ..std::printf("\
    │ │ │ +00042950: 3033 335b 324a 5c30 3333 5b30 3b30 4822  033[2J\033[0;0H"
    │ │ │ +00042960: 293b 0a23 656e 6469 660a 0a09 0961 7578  );.#endif....aux
    │ │ │ +00042970: 3a3a 7665 6374 6f72 266c 743b 746f 7272  ::vector<torr
    │ │ │ +00042980: 656e 742a 2667 743b 2661 6d70 3b20 7761  ent*>& wa
    │ │ │ +00042990: 6e74 5f74 6963 6b20 3d20 6d5f 746f 7272  nt_tick = m_torr
    │ │ │ +000429a0: 656e 745f 6c69 7374 735b 746f 7272 656e  ent_lists[torren
    │ │ │ +000429b0: 745f 7761 6e74 5f74 6963 6b5d 3b0a 0909  t_want_tick];...
    │ │ │ +000429c0: 666f 7220 2869 6e74 2069 203d 2030 3b20  for (int i = 0; 
    │ │ │ +000429d0: 6920 266c 743b 2069 6e74 2877 616e 745f  i < int(want_
    │ │ │ +000429e0: 7469 636b 2e73 697a 6528 2929 3b20 2b2b  tick.size()); ++
    │ │ │ +000429f0: 6929 0a09 097b 0a09 0909 746f 7272 656e  i)...{....torren
    │ │ │ +00042a00: 7426 616d 703b 2074 203d 202a 7761 6e74  t& t = *want
    │ │ │ +00042a10: 5f74 6963 6b5b 695d 3b0a 0909 0954 4f52  _tick[i];....TOR
    │ │ │ +00042a20: 5245 4e54 5f41 5353 4552 5428 742e 7761  RENT_ASSERT(t.wa
    │ │ │ +00042a30: 6e74 5f74 6963 6b28 2929 3b0a 0909 0954  nt_tick());....T
    │ │ │ +00042a40: 4f52 5245 4e54 5f41 5353 4552 5428 2174  ORRENT_ASSERT(!t
    │ │ │ +00042a50: 2e69 735f 6162 6f72 7465 6428 2929 3b0a  .is_aborted());.
    │ │ │ +00042a60: 0a09 0909 742e 7365 636f 6e64 5f74 6963  ....t.second_tic
    │ │ │ +00042a70: 6b28 7469 636b 5f69 6e74 6572 7661 6c5f  k(tick_interval_
    │ │ │ +00042a80: 6d73 293b 0a0a 0909 092f 2f20 6966 2074  ms);.....// if t
    │ │ │ +00042a90: 6865 2063 616c 6c20 746f 2073 6563 6f6e  he call to secon
    │ │ │ +00042aa0: 645f 7469 636b 2063 6175 7365 6420 7468  d_tick caused th
    │ │ │ +00042ab0: 6520 746f 7272 656e 740a 0909 092f 2f20  e torrent....// 
    │ │ │ +00042ac0: 746f 206e 6f20 6c6f 6e67 6572 2077 616e  to no longer wan
    │ │ │ +00042ad0: 7420 746f 2062 6520 7469 636b 6564 2028  t to be ticked (
    │ │ │ +00042ae0: 692e 652e 2069 7420 7761 730a 0909 092f  i.e. it was..../
    │ │ │ +00042af0: 2f20 7265 6d6f 7665 6420 6672 6f6d 2074  / removed from t
    │ │ │ +00042b00: 6865 206c 6973 7429 2077 6520 6e65 6564  he list) we need
    │ │ │ +00042b10: 2074 6f20 6261 636b 2075 7020 7468 6520   to back up the 
    │ │ │ +00042b20: 636f 756e 7465 720a 0909 092f 2f20 746f  counter....// to
    │ │ │ +00042b30: 206e 6f74 206d 6973 7320 7468 6520 746f   not miss the to
    │ │ │ +00042b40: 7272 656e 7420 6166 7465 7220 6974 0a09  rrent after it..
    │ │ │ +00042b50: 0909 6966 2028 2174 2e77 616e 745f 7469  ..if (!t.want_ti
    │ │ │ +00042b60: 636b 2829 2920 2d2d 693b 0a09 097d 0a0a  ck()) --i;...}..
    │ │ │ +00042b70: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ +00042ba0: 6966 2028 6d5f 7365 7474 696e 6773 2e67 if (m_settings.g │ │ │ +00042bb0: 6574 5f62 6f6f 6c28 7365 7474 696e 6773 et_bool(settings │ │ │ +00042bc0: 5f70 6163 6b3a 3a72 6174 655f 6c69 6d69 _pack::rate_limi │ │ │ +00042bd0: 745f 6970 5f6f 7665 7268 6561 6429 290a t_ip_overhead)). │ │ │ +00042be0: 3c2f 6469 763e 0909 7b0a 0909 0969 6e74
    ..{....int │ │ │ +00042bf0: 2063 6f6e 7374 2075 705f 6c69 6d69 7420 const up_limit │ │ │ +00042c00: 3d20 7570 6c6f 6164 5f72 6174 655f 6c69 = upload_rate_li │ │ │ +00042c10: 6d69 7428 6d5f 676c 6f62 616c 5f63 6c61 mit(m_global_cla │ │ │ +00042c20: 7373 293b 0a09 0909 696e 7420 636f 6e73 ss);....int cons │ │ │ +00042c30: 7420 646f 776e 5f6c 696d 6974 203d 2064 t down_limit = d │ │ │ +00042c40: 6f77 6e6c 6f61 645f 7261 7465 5f6c 696d ownload_rate_lim │ │ │ +00042c50: 6974 286d 5f67 6c6f 6261 6c5f 636c 6173 it(m_global_clas │ │ │ +00042c60: 7329 3b0a 0a09 0909 6966 2028 646f 776e s);.....if (down │ │ │ +00042c70: 5f6c 696d 6974 2026 6774 3b20 300a 0909 _limit > 0... │ │ │ +00042c80: 0909 2661 6d70 3b26 616d 703b 206d 5f73 ..&& m_s │ │ │ +00042c90: 7461 742e 646f 776e 6c6f 6164 5f69 705f tat.download_ip_ │ │ │ +00042ca0: 6f76 6572 6865 6164 2829 2026 6774 3b3d overhead() >= │ │ │ +00042cb0: 2064 6f77 6e5f 6c69 6d69 740a 0909 0909 down_limit..... │ │ │ +00042cc0: 2661 6d70 3b26 616d 703b 206d 5f61 6c65 && m_ale │ │ │ +00042cd0: 7274 732e 7368 6f75 6c64 5f70 6f73 7426 rts.should_post& │ │ │ +00042ce0: 6c74 3b70 6572 666f 726d 616e 6365 5f61 lt;performance_a │ │ │ +00042cf0: 6c65 7274 2667 743b 2829 290a 0909 097b lert>())....{ │ │ │ +00042d00: 0a09 0909 096d 5f61 6c65 7274 732e 656d .....m_alerts.em │ │ │ +00042d10: 706c 6163 655f 616c 6572 7426 6c74 3b70 place_alert<p │ │ │ +00042d20: 6572 666f 726d 616e 6365 5f61 6c65 7274 erformance_alert │ │ │ +00042d30: 2667 743b 2874 6f72 7265 6e74 5f68 616e >(torrent_han │ │ │ +00042d40: 646c 6528 290a 0909 0909 092c 2070 6572 dle()......, per │ │ │ +00042d50: 666f 726d 616e 6365 5f61 6c65 7274 3a3a formance_alert:: │ │ │ +00042d60: 646f 776e 6c6f 6164 5f6c 696d 6974 5f74 download_limit_t │ │ │ +00042d70: 6f6f 5f6c 6f77 293b 0a09 0909 7d0a 0a09 oo_low);....}... │ │ │ +00042d80: 0909 6966 2028 7570 5f6c 696d 6974 2026 ..if (up_limit & │ │ │ +00042d90: 6774 3b20 300a 0909 0909 2661 6d70 3b26 gt; 0.....&& │ │ │ +00042da0: 616d 703b 206d 5f73 7461 742e 7570 6c6f amp; m_stat.uplo │ │ │ +00042db0: 6164 5f69 705f 6f76 6572 6865 6164 2829 ad_ip_overhead() │ │ │ +00042dc0: 2026 6774 3b3d 2075 705f 6c69 6d69 740a >= up_limit. │ │ │ +00042dd0: 0909 0909 2661 6d70 3b26 616d 703b 206d ....&& m │ │ │ +00042de0: 5f61 6c65 7274 732e 7368 6f75 6c64 5f70 _alerts.should_p │ │ │ +00042df0: 6f73 7426 6c74 3b70 6572 666f 726d 616e ost<performan │ │ │ +00042e00: 6365 5f61 6c65 7274 2667 743b 2829 290a ce_alert>()). │ │ │ +00042e10: 0909 097b 0a09 0909 096d 5f61 6c65 7274 ...{.....m_alert │ │ │ +00042e20: 732e 656d 706c 6163 655f 616c 6572 7426 s.emplace_alert& │ │ │ +00042e30: 6c74 3b70 6572 666f 726d 616e 6365 5f61 lt;performance_a │ │ │ +00042e40: 6c65 7274 2667 743b 2874 6f72 7265 6e74 lert>(torrent │ │ │ +00042e50: 5f68 616e 646c 6528 290a 0909 0909 092c _handle()......, │ │ │ +00042e60: 2070 6572 666f 726d 616e 6365 5f61 6c65 performance_ale │ │ │ +00042e70: 7274 3a3a 7570 6c6f 6164 5f6c 696d 6974 rt::upload_limit │ │ │ +00042e80: 5f74 6f6f 5f6c 6f77 293b 0a09 0909 7d0a _too_low);....}. │ │ │ +00042e90: 0909 7d0a 0a23 6966 2054 4f52 5245 4e54 ..}..#if TORRENT │ │ │ +00042ea0: 5f41 4249 5f56 4552 5349 4f4e 203d 3d20 _ABI_VERSION == │ │ │ +00042eb0: 310a 0909 6d5f 7065 616b 5f75 705f 7261 1...m_peak_up_ra │ │ │ +00042ec0: 7465 203d 2073 7464 3a3a 6d61 7828 6d5f te = std::max(m_ │ │ │ +00042ed0: 7374 6174 2e75 706c 6f61 645f 7261 7465 stat.upload_rate │ │ │ +00042ee0: 2829 2c20 6d5f 7065 616b 5f75 705f 7261 (), m_peak_up_ra │ │ │ +00042ef0: 7465 293b 0a23 656e 6469 660a 0a09 096d te);.#endif....m │ │ │ +00042f00: 5f73 7461 742e 7365 636f 6e64 5f74 6963 _stat.second_tic │ │ │ +00042f10: 6b28 7469 636b 5f69 6e74 6572 7661 6c5f k(tick_interval_ │ │ │ +00042f20: 6d73 293b 0a0a 0909 2f2f 202d 2d2d 2d2d ms);....// ----- │ │ │ +00042f30: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00042f40: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00042f50: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00042f60: 2d2d 2d2d 2d2d 2d2d 2d0a 0909 2f2f 2073 ---------...// s │ │ │ +00042f70: 6372 6170 6520 7061 7573 6564 2074 6f72 crape paused tor │ │ │ +00042f80: 7265 6e74 7320 7468 6174 2061 7265 2061 rents that are a │ │ │ +00042f90: 7574 6f20 6d61 6e61 6765 640a 0909 2f2f uto managed...// │ │ │ +00042fa0: 2028 756e 6c65 7373 2074 6865 2073 6573 (unless the ses │ │ │ +00042fb0: 7369 6f6e 2069 7320 7061 7573 6564 290a sion is paused). │ │ │ +00042fc0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +00042fd0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00043000: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +00043030: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ +00043040: 7070 3a34 3333 323c 2f61 3e3c 2f74 643e pp:4332 │ │ │ +00043050: 3c74 643e 7573 6520 6120 6c6f 7765 7220 use a lower │ │ │ +00043060: 6c69 6d69 7420 7468 616e 206d 5f73 6574 limit than m_set │ │ │ +00043070: 7469 6e67 732e 636f 6e6e 6563 7469 6f6e tings.connection │ │ │ +00043080: 735f 6c69 6d69 7420 746f 2061 6c6c 6f63 s_limit to alloc │ │ │ +00043090: 6174 6520 7468 6520 746f 2031 3025 206f ate the to 10% o │ │ │ +000430a0: 7220 736f 206f 6620 636f 6e6e 6563 7469 r so of connecti │ │ │ +000430b0: 6f6e 2073 6c6f 7473 2066 6f72 2069 6e63 on slots for inc │ │ │ +000430c0: 6f6d 696e 6720 636f 6e6e 6563 7469 6f6e oming connection │ │ │ +000430d0: 7320 6361 7020 7468 6973 2061 7420 6d61 s cap this at ma │ │ │ +000430e0: 7820 2d20 312c 2073 696e 6365 2077 6520 x - 1, since we │ │ │ +000430f0: 6d61 7920 6164 6420 6f6e 6520 6265 6c6f may add one belo │ │ │ +00043100: 773c 2f74 643e 3c2f 7472 3e3c 7472 2069 w

    u │ │ │ +00043150: 7365 2061 206c 6f77 6572 206c 696d 6974 se a lower limit │ │ │ +00043160: 2074 6861 6e20 6d5f 7365 7474 696e 6773 than m_settings │ │ │ +00043170: 2e63 6f6e 6e65 6374 696f 6e73 5f6c 696d .connections_lim │ │ │ +00043180: 6974 0a74 6f20 616c 6c6f 6361 7465 2074 it.to allocate t │ │ │ +00043190: 6865 2074 6f20 3130 2520 6f72 2073 6f20 he to 10% or so │ │ │ +000431a0: 6f66 2063 6f6e 6e65 6374 696f 6e20 736c of connection sl │ │ │ +000431b0: 6f74 7320 666f 7220 696e 636f 6d69 6e67 ots for incoming │ │ │ +000431c0: 0a63 6f6e 6e65 6374 696f 6e73 0a63 6170 .connections.cap │ │ │ +000431d0: 2074 6869 7320 6174 206d 6178 202d 2031 this at max - 1 │ │ │ +000431e0: 2c20 7369 6e63 6520 7765 206d 6179 2061 , since we may a │ │ │ +000431f0: 6464 206f 6e65 2062 656c 6f77 3c2f 6832 dd one below

    ../src/sess │ │ │ +00043210: 696f 6e5f 696d 706c 2e63 7070 3a34 3333 ion_impl.cpp:433 │ │ │ +00043220: 323c 2f68 343e 3c70 7265 2073 7479 6c65 2

    │ │ │ +00043260: 0909 2f2f 2062 6f6f 7374 2c20 7768 6963  ..// boost, whic
    │ │ │ +00043270: 6820 6172 6520 646f 6e65 2069 6d6d 6564  h are done immed
    │ │ │ +00043280: 6961 7465 6c79 206f 6e20 6120 7472 6163  iately on a trac
    │ │ │ +00043290: 6b65 7220 7265 7370 6f6e 7365 2e20 5468  ker response. Th
    │ │ │ +000432a0: 6573 650a 0909 2f2f 2063 6f6e 6e65 6374  ese...// connect
    │ │ │ +000432b0: 696f 6e73 206e 6565 6473 2074 6f20 6265  ions needs to be
    │ │ │ +000432c0: 2064 6564 7563 7465 6420 6672 6f6d 2074   deducted from t
    │ │ │ +000432d0: 6865 2072 6567 756c 6172 2063 6f6e 6e65  he regular conne
    │ │ │ +000432e0: 6374 696f 6e20 6174 7465 6d70 740a 0909  ction attempt...
    │ │ │ +000432f0: 2f2f 2071 756f 7461 2066 6f72 2074 6869  // quota for thi
    │ │ │ +00043300: 7320 7469 636b 0a09 0969 6620 286d 5f62  s tick...if (m_b
    │ │ │ +00043310: 6f6f 7374 5f63 6f6e 6e65 6374 696f 6e73  oost_connections
    │ │ │ +00043320: 2026 6774 3b20 3029 0a09 097b 0a09 0909   > 0)...{....
    │ │ │ +00043330: 6966 2028 6d5f 626f 6f73 745f 636f 6e6e  if (m_boost_conn
    │ │ │ +00043340: 6563 7469 6f6e 7320 2667 743b 206d 6178  ections > max
    │ │ │ +00043350: 5f63 6f6e 6e65 6374 696f 6e73 290a 0909  _connections)...
    │ │ │ +00043360: 097b 0a09 0909 096d 5f62 6f6f 7374 5f63  .{.....m_boost_c
    │ │ │ +00043370: 6f6e 6e65 6374 696f 6e73 202d 3d20 6d61  onnections -= ma
    │ │ │ +00043380: 785f 636f 6e6e 6563 7469 6f6e 733b 0a09  x_connections;..
    │ │ │ +00043390: 0909 096d 6178 5f63 6f6e 6e65 6374 696f  ...max_connectio
    │ │ │ +000433a0: 6e73 203d 2030 3b0a 0909 097d 0a09 0909  ns = 0;....}....
    │ │ │ +000433b0: 656c 7365 0a09 0909 7b0a 0909 0909 6d61  else....{.....ma
    │ │ │ +000433c0: 785f 636f 6e6e 6563 7469 6f6e 7320 2d3d  x_connections -=
    │ │ │ +000433d0: 206d 5f62 6f6f 7374 5f63 6f6e 6e65 6374   m_boost_connect
    │ │ │ +000433e0: 696f 6e73 3b0a 0909 0909 6d5f 626f 6f73  ions;.....m_boos
    │ │ │ +000433f0: 745f 636f 6e6e 6563 7469 6f6e 7320 3d20  t_connections = 
    │ │ │ +00043400: 303b 0a09 0909 7d0a 0909 7d0a 0a09 092f  0;....}...}..../
    │ │ │ +00043410: 2f20 7a65 726f 2063 6f6e 6e65 6374 696f  / zero connectio
    │ │ │ +00043420: 6e73 2073 7065 6564 7320 6172 6520 616c  ns speeds are al
    │ │ │ +00043430: 6c6f 7765 642c 2077 6520 6a75 7374 2077  lowed, we just w
    │ │ │ +00043440: 6f6e 2774 206d 616b 6520 616e 7920 636f  on't make any co
    │ │ │ +00043450: 6e6e 6563 7469 6f6e 730a 0909 6966 2028  nnections...if (
    │ │ │ +00043460: 6d61 785f 636f 6e6e 6563 7469 6f6e 7320  max_connections 
    │ │ │ +00043470: 266c 743b 3d20 3029 2072 6574 7572 6e3b  <= 0) return;
    │ │ │ +00043480: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +000434b0: 0909 696e 7420 636f 6e73 7420 6c69 6d69 ..int const limi │ │ │ +000434c0: 7420 3d20 7374 643a 3a6d 696e 286d 5f73 t = std::min(m_s │ │ │ +000434d0: 6574 7469 6e67 732e 6765 745f 696e 7428 ettings.get_int( │ │ │ +000434e0: 7365 7474 696e 6773 5f70 6163 6b3a 3a63 settings_pack::c │ │ │ +000434f0: 6f6e 6e65 6374 696f 6e73 5f6c 696d 6974 onnections_limit │ │ │ +00043500: 290a 3c2f 6469 763e 0909 092d 206e 756d ).
    ...- num │ │ │ +00043510: 5f63 6f6e 6e65 6374 696f 6e73 2829 2c20 _connections(), │ │ │ +00043520: 7374 643a 3a6e 756d 6572 6963 5f6c 696d std::numeric_lim │ │ │ +00043530: 6974 7326 6c74 3b69 6e74 2667 743b 3a3a its<int>:: │ │ │ +00043540: 6d61 7828 2920 2d20 3129 3b0a 0a09 092f max() - 1);..../ │ │ │ +00043550: 2f20 7468 6973 206c 6f67 6963 2069 7320 / this logic is │ │ │ +00043560: 6865 7265 2074 6f20 736d 6f6f 7468 206f here to smooth o │ │ │ +00043570: 7574 2074 6865 206e 756d 6265 7220 6f66 ut the number of │ │ │ +00043580: 206e 6577 2063 6f6e 6e65 6374 696f 6e0a new connection. │ │ │ +00043590: 0909 2f2f 2061 7474 656d 7074 7320 6f76 ..// attempts ov │ │ │ +000435a0: 6572 2074 696d 652c 2074 6f20 7072 6576 er time, to prev │ │ │ +000435b0: 656e 7420 636f 6e6e 6563 7469 6e67 2061 ent connecting a │ │ │ +000435c0: 206c 6172 6765 206e 756d 6265 7220 6f66 large number of │ │ │ +000435d0: 0a09 092f 2f20 736f 636b 6574 732c 2077 ...// sockets, w │ │ │ +000435e0: 6169 7420 3130 2073 6563 6f6e 6473 2c20 ait 10 seconds, │ │ │ +000435f0: 616e 6420 7468 656e 2074 7279 2061 6761 and then try aga │ │ │ +00043600: 696e 0a09 0969 6620 286d 5f73 6574 7469 in...if (m_setti │ │ │ +00043610: 6e67 732e 6765 745f 626f 6f6c 2873 6574 ngs.get_bool(set │ │ │ +00043620: 7469 6e67 735f 7061 636b 3a3a 736d 6f6f tings_pack::smoo │ │ │ +00043630: 7468 5f63 6f6e 6e65 6374 7329 2026 616d th_connects) &am │ │ │ +00043640: 703b 2661 6d70 3b20 6d61 785f 636f 6e6e p;& max_conn │ │ │ +00043650: 6563 7469 6f6e 7320 2667 743b 2028 6c69 ections > (li │ │ │ +00043660: 6d69 742b 3129 202f 2032 290a 0909 096d mit+1) / 2)....m │ │ │ +00043670: 6178 5f63 6f6e 6e65 6374 696f 6e73 203d ax_connections = │ │ │ +00043680: 2028 6c69 6d69 7420 2b20 3129 202f 2032 (limit + 1) / 2 │ │ │ +00043690: 3b0a 0a09 0961 7578 3a3a 7665 6374 6f72 ;....aux::vector │ │ │ +000436a0: 266c 743b 746f 7272 656e 742a 2667 743b <torrent*> │ │ │ +000436b0: 2661 6d70 3b20 7761 6e74 5f70 6565 7273 & want_peers │ │ │ +000436c0: 5f64 6f77 6e6c 6f61 6420 3d20 6d5f 746f _download = m_to │ │ │ +000436d0: 7272 656e 745f 6c69 7374 735b 746f 7272 rrent_lists[torr │ │ │ +000436e0: 656e 745f 7761 6e74 5f70 6565 7273 5f64 ent_want_peers_d │ │ │ +000436f0: 6f77 6e6c 6f61 645d 3b0a 0909 6175 783a ownload];...aux: │ │ │ +00043700: 3a76 6563 746f 7226 6c74 3b74 6f72 7265 :vector<torre │ │ │ +00043710: 6e74 2a26 6774 3b26 616d 703b 2077 616e nt*>& wan │ │ │ +00043720: 745f 7065 6572 735f 6669 6e69 7368 6564 t_peers_finished │ │ │ +00043730: 203d 206d 5f74 6f72 7265 6e74 5f6c 6973 = m_torrent_lis │ │ │ +00043740: 7473 5b74 6f72 7265 6e74 5f77 616e 745f ts[torrent_want_ │ │ │ +00043750: 7065 6572 735f 6669 6e69 7368 6564 5d3b peers_finished]; │ │ │ +00043760: 0a0a 0909 2f2f 2069 6620 6e6f 2074 6f72 ....// if no tor │ │ │ +00043770: 7265 6e74 2077 616e 7420 616e 7920 7065 rent want any pe │ │ │ +00043780: 6572 732c 206a 7573 7420 7265 7475 726e ers, just return │ │ │ +00043790: 0a09 0969 6620 2877 616e 745f 7065 6572 ...if (want_peer │ │ │ +000437a0: 735f 646f 776e 6c6f 6164 2e65 6d70 7479 s_download.empty │ │ │ +000437b0: 2829 2026 616d 703b 2661 6d70 3b20 7761 () && wa │ │ │ +000437c0: 6e74 5f70 6565 7273 5f66 696e 6973 6865 nt_peers_finishe │ │ │ +000437d0: 642e 656d 7074 7928 2929 2072 6574 7572 d.empty()) retur │ │ │ +000437e0: 6e3b 0a0a 0909 2f2f 2069 6620 7765 2064 n;....// if we d │ │ │ +000437f0: 6f6e 2774 2068 6176 6520 616e 7920 636f on't have any co │ │ │ +00043800: 6e6e 6563 7469 6f6e 2061 7474 656d 7074 nnection attempt │ │ │ +00043810: 2071 756f 7461 2c20 7265 7475 726e 0a09 quota, return.. │ │ │ +00043820: 0969 6620 286d 6178 5f63 6f6e 6e65 6374 .if (max_connect │ │ │ +00043830: 696f 6e73 2026 6c74 3b3d 2030 2920 7265 ions <= 0) re │ │ │ +00043840: 7475 726e 3b0a 0a09 0969 6e74 2073 7465 turn;....int ste │ │ │ +00043850: 7073 5f73 696e 6365 5f6c 6173 745f 636f ps_since_last_co │ │ │ +00043860: 6e6e 6563 7420 3d20 303b 0a09 0969 6e74 nnect = 0;...int │ │ │ +00043870: 2063 6f6e 7374 206e 756d 5f74 6f72 7265 const num_torre │ │ │ +00043880: 6e74 7320 3d20 696e 7428 7761 6e74 5f70 nts = int(want_p │ │ │ +00043890: 6565 7273 5f66 696e 6973 6865 642e 7369 eers_finished.si │ │ │ +000438a0: 7a65 2829 202b 2077 616e 745f 7065 6572 ze() + want_peer │ │ │ +000438b0: 735f 646f 776e 6c6f 6164 2e73 697a 6528 s_download.size( │ │ │ +000438c0: 2929 3b0a 0909 666f 7220 283b 3b29 0a09 ));...for (;;).. │ │ │ +000438d0: 097b 0a09 0909 6966 2028 6d5f 6e65 7874 .{....if (m_next │ │ │ +000438e0: 5f64 6f77 6e6c 6f61 6469 6e67 5f63 6f6e _downloading_con │ │ │ +000438f0: 6e65 6374 5f74 6f72 7265 6e74 2026 6774 nect_torrent > │ │ │ +00043900: 3b3d 2069 6e74 2877 616e 745f 7065 6572 ;= int(want_peer │ │ │ +00043910: 735f 646f 776e 6c6f 6164 2e73 697a 6528 s_download.size( │ │ │ +00043920: 2929 290a 0909 0909 6d5f 6e65 7874 5f64 ))).....m_next_d │ │ │ +00043930: 6f77 6e6c 6f61 6469 6e67 5f63 6f6e 6e65 ownloading_conne │ │ │ +00043940: 6374 5f74 6f72 7265 6e74 203d 2030 3b0a ct_torrent = 0;. │ │ │ +00043950: 0a09 0909 6966 2028 6d5f 6e65 7874 5f66 ....if (m_next_f │ │ │ +00043960: 696e 6973 6865 645f 636f 6e6e 6563 745f inished_connect_ │ │ │ +00043970: 746f 7272 656e 7420 2667 743b 3d20 696e torrent >= in │ │ │ +00043980: 7428 7761 6e74 5f70 6565 7273 5f66 696e t(want_peers_fin │ │ │ +00043990: 6973 6865 642e 7369 7a65 2829 2929 0a09 ished.size())).. │ │ │ +000439a0: 0909 096d 5f6e 6578 745f 6669 6e69 7368 ...m_next_finish │ │ │ +000439b0: 6564 5f63 6f6e 6e65 6374 5f74 6f72 7265 ed_connect_torre │ │ │ +000439c0: 6e74 203d 2030 3b0a 0a09 0909 746f 7272 nt = 0;.....torr │ │ │ +000439d0: 656e 742a 2074 203d 206e 756c 6c70 7472 ent* t = nullptr │ │ │ +000439e0: 3b0a 0909 092f 2f20 7468 6572 6520 6172 ;....// there ar │ │ │ +000439f0: 6520 7072 696f 7269 7469 7a65 6420 746f e prioritized to │ │ │ +00043a00: 7272 656e 7473 2e20 5069 636b 206f 6e65 rrents. Pick one │ │ │ +00043a10: 206f 6620 7468 6f73 650a 0909 0977 6869 of those....whi │ │ │ +00043a20: 6c65 2028 216d 5f70 7269 6f5f 746f 7272 le (!m_prio_torr │ │ │ +00043a30: 656e 7473 2e65 6d70 7479 2829 290a 3c2f ents.empty()).r │ │ │ +00043a70: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +00043a80: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +00043ab0: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ +00043ac0: 3a34 3437 373c 2f61 3e3c 2f74 643e 3c74 :4477post a message │ │ │ +00043ae0: 2074 6f20 6861 7665 2074 6869 7320 6861 to have this ha │ │ │ +00043af0: 7070 656e 2069 6d6d 6564 6961 7465 6c79 ppen immediately │ │ │ +00043b00: 2069 6e73 7465 6164 206f 6620 7761 6974 instead of wait │ │ │ +00043b10: 696e 6720 666f 7220 7468 6520 6e65 7874 ing for the next │ │ │ +00043b20: 2074 6963 6b3c 2f74 643e 3c2f 7472 3e3c tick< │ │ │ +00043b30: 7472 2069 643d 2231 3634 2220 7374 796c tr id="164" styl │ │ │ +00043b40: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00043b50: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00043b60: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00043b70: 6832 3e70 6f73 7420 6120 6d65 7373 6167 h2>post a messag │ │ │ +00043b80: 6520 746f 2068 6176 6520 7468 6973 2068 e to have this h │ │ │ +00043b90: 6170 7065 6e0a 696d 6d65 6469 6174 656c appen.immediatel │ │ │ +00043ba0: 7920 696e 7374 6561 6420 6f66 2077 6169 y instead of wai │ │ │ +00043bb0: 7469 6e67 2066 6f72 2074 6865 206e 6578 ting for the nex │ │ │ +00043bc0: 7420 7469 636b 3c2f 6832 3e3c 6834 3e2e t tick

    . │ │ │ +00043bd0: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ +00043be0: 706c 2e63 7070 3a34 3437 373c 2f68 343e pl.cpp:4477

    │ │ │ +00043bf0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ....co
    │ │ │ +00043c30: 6e74 696e 7565 3b0a 0909 097d 0a0a 0909  ntinue;....}....
    │ │ │ +00043c40: 0969 6620 2821 702d 2667 743b 6973 5f70  .if (!p->is_p
    │ │ │ +00043c50: 6565 725f 696e 7465 7265 7374 6564 2829  eer_interested()
    │ │ │ +00043c60: 0a09 0909 097c 7c20 702d 2667 743b 6973  .....|| p->is
    │ │ │ +00043c70: 5f64 6973 636f 6e6e 6563 7469 6e67 2829  _disconnecting()
    │ │ │ +00043c80: 0a09 0909 097c 7c20 702d 2667 743b 6973  .....|| p->is
    │ │ │ +00043c90: 5f63 6f6e 6e65 6374 696e 6728 2929 0a09  _connecting())..
    │ │ │ +00043ca0: 0909 7b0a 0909 0909 2f2f 2074 6869 7320  ..{.....// this 
    │ │ │ +00043cb0: 7065 6572 2069 7320 6e6f 7420 756e 6368  peer is not unch
    │ │ │ +00043cc0: 6f6b 6162 6c65 2e20 536f 2c20 6966 2069  okable. So, if i
    │ │ │ +00043cd0: 7427 7320 756e 6368 6f6b 6564 0a09 0909  t's unchoked....
    │ │ │ +00043ce0: 092f 2f20 616c 7265 6164 792c 206d 616b  .// already, mak
    │ │ │ +00043cf0: 6520 7375 7265 2074 6f20 6368 6f6b 6520  e sure to choke 
    │ │ │ +00043d00: 6974 2e0a 0909 0909 6966 2028 702d 2667  it......if (p-&g
    │ │ │ +00043d10: 743b 6973 5f63 686f 6b65 6428 2929 0a09  t;is_choked())..
    │ │ │ +00043d20: 0909 097b 0a09 0909 0909 702d 2667 743b  ...{......p->
    │ │ │ +00043d30: 7265 7365 745f 6368 6f6b 655f 636f 756e  reset_choke_coun
    │ │ │ +00043d40: 7465 7273 2829 3b0a 0909 0909 0963 6f6e  ters();......con
    │ │ │ +00043d50: 7469 6e75 653b 0a09 0909 097d 0a09 0909  tinue;.....}....
    │ │ │ +00043d60: 0969 6620 2870 6920 2661 6d70 3b26 616d  .if (pi &&am
    │ │ │ +00043d70: 703b 2070 692d 2667 743b 6f70 7469 6d69  p; pi->optimi
    │ │ │ +00043d80: 7374 6963 616c 6c79 5f75 6e63 686f 6b65  stically_unchoke
    │ │ │ +00043d90: 6429 0a09 0909 097b 0a09 0909 0909 6d5f  d).....{......m_
    │ │ │ +00043da0: 7374 6174 735f 636f 756e 7465 7273 2e69  stats_counters.i
    │ │ │ +00043db0: 6e63 5f73 7461 7473 5f63 6f75 6e74 6572  nc_stats_counter
    │ │ │ +00043dc0: 2863 6f75 6e74 6572 733a 3a6e 756d 5f70  (counters::num_p
    │ │ │ +00043dd0: 6565 7273 5f75 705f 756e 6368 6f6b 6564  eers_up_unchoked
    │ │ │ +00043de0: 5f6f 7074 696d 6973 7469 632c 202d 3129  _optimistic, -1)
    │ │ │ +00043df0: 3b0a 0909 0909 0970 692d 2667 743b 6f70  ;......pi->op
    │ │ │ +00043e00: 7469 6d69 7374 6963 616c 6c79 5f75 6e63  timistically_unc
    │ │ │ +00043e10: 686f 6b65 6420 3d20 6661 6c73 653b 0a09  hoked = false;..
    │ │ │ +00043e20: 0909 0909 2f2f 2066 6f72 6365 2061 206e  ....// force a n
    │ │ │ +00043e30: 6577 206f 7074 696d 6973 7469 6320 756e  ew optimistic un
    │ │ │ +00043e40: 6368 6f6b 650a 0909 0909 096d 5f6f 7074  choke......m_opt
    │ │ │ +00043e50: 696d 6973 7469 635f 756e 6368 6f6b 655f  imistic_unchoke_
    │ │ │ +00043e60: 7469 6d65 5f73 6361 6c65 7220 3d20 303b  time_scaler = 0;
    │ │ │ +00043e70: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +00043ea0: 0909 097d 0a3c 2f64 6976 3e09 0909 0974 ...}.
    ....t │ │ │ +00043eb0: 2d26 6774 3b63 686f 6b65 5f70 6565 7228 ->choke_peer( │ │ │ +00043ec0: 2a70 293b 0a09 0909 0970 2d26 6774 3b72 *p);.....p->r │ │ │ +00043ed0: 6573 6574 5f63 686f 6b65 5f63 6f75 6e74 eset_choke_count │ │ │ +00043ee0: 6572 7328 293b 0a09 0909 0963 6f6e 7469 ers();.....conti │ │ │ +00043ef0: 6e75 653b 0a09 0909 7d0a 0a09 0909 7065 nue;....}.....pe │ │ │ +00043f00: 6572 732e 7075 7368 5f62 6163 6b28 702e ers.push_back(p. │ │ │ +00043f10: 6765 7428 2929 3b0a 0909 7d0a 0a09 0969 get());...}....i │ │ │ +00043f20: 6e74 2063 6f6e 7374 2061 6c6c 6f77 6564 nt const allowed │ │ │ +00043f30: 5f75 706c 6f61 645f 736c 6f74 7320 3d20 _upload_slots = │ │ │ +00043f40: 756e 6368 6f6b 655f 736f 7274 2870 6565 unchoke_sort(pee │ │ │ +00043f50: 7273 0a09 0909 2c20 756e 6368 6f6b 655f rs...., unchoke_ │ │ │ +00043f60: 696e 7465 7276 616c 2c20 6d5f 7365 7474 interval, m_sett │ │ │ +00043f70: 696e 6773 293b 0a0a 0909 6966 2028 6d5f ings);....if (m_ │ │ │ +00043f80: 7365 7474 696e 6773 2e67 6574 5f69 6e74 settings.get_int │ │ │ +00043f90: 2873 6574 7469 6e67 735f 7061 636b 3a3a (settings_pack:: │ │ │ +00043fa0: 6368 6f6b 696e 675f 616c 676f 7269 7468 choking_algorith │ │ │ +00043fb0: 6d29 203d 3d20 7365 7474 696e 6773 5f70 m) == settings_p │ │ │ +00043fc0: 6163 6b3a 3a66 6978 6564 5f73 6c6f 7473 ack::fixed_slots │ │ │ +00043fd0: 5f63 686f 6b65 7229 0a09 097b 0a09 0909 _choker)...{.... │ │ │ +00043fe0: 696e 7420 636f 6e73 7420 7570 6c6f 6164 int const upload │ │ │ +00043ff0: 5f73 6c6f 7473 203d 2067 6574 5f69 6e74 _slots = get_int │ │ │ +00044000: 5f73 6574 7469 6e67 2873 6574 7469 6e67 _setting(setting │ │ │ +00044010: 735f 7061 636b 3a3a 756e 6368 6f6b 655f s_pack::unchoke_ │ │ │ +00044020: 736c 6f74 735f 6c69 6d69 7429 3b0a 0909 slots_limit);... │ │ │ +00044030: 096d 5f73 7461 7473 5f63 6f75 6e74 6572 .m_stats_counter │ │ │ +00044040: 732e 7365 745f 7661 6c75 6528 636f 756e s.set_value(coun │ │ │ +00044050: 7465 7273 3a3a 6e75 6d5f 756e 6368 6f6b ters::num_unchok │ │ │ +00044060: 655f 736c 6f74 732c 2075 706c 6f61 645f e_slots, upload_ │ │ │ +00044070: 736c 6f74 7329 3b0a 0909 7d0a 0909 656c slots);...}...el │ │ │ +00044080: 7365 0a09 097b 0a09 0909 6d5f 7374 6174 se...{....m_stat │ │ │ +00044090: 735f 636f 756e 7465 7273 2e73 6574 5f76 s_counters.set_v │ │ │ +000440a0: 616c 7565 2863 6f75 6e74 6572 733a 3a6e alue(counters::n │ │ │ +000440b0: 756d 5f75 6e63 686f 6b65 5f73 6c6f 7473 um_unchoke_slots │ │ │ +000440c0: 0a09 0909 092c 2061 6c6c 6f77 6564 5f75 ....., allowed_u │ │ │ +000440d0: 706c 6f61 645f 736c 6f74 7329 3b0a 0909 pload_slots);... │ │ │ +000440e0: 7d0a 0a23 6966 6e64 6566 2054 4f52 5245 }..#ifndef TORRE │ │ │ +000440f0: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749 NT_DISABLE_LOGGI │ │ │ +00044100: 4e47 0a09 0969 6620 2873 686f 756c 645f NG...if (should_ │ │ │ +00044110: 6c6f 6728 2929 0a09 097b 0a09 0909 7365 log())...{....se │ │ │ +00044120: 7373 696f 6e5f 6c6f 6728 2252 4543 414c ssion_log("RECAL │ │ │ +00044130: 4355 4c41 5445 2055 4e43 484f 4b45 2053 CULATE UNCHOKE S │ │ │ +00044140: 4c4f 5453 3a20 5b20 7065 6572 733a 2025 LOTS: [ peers: % │ │ │ +00044150: 6420 220a 0909 0909 2265 6c69 6769 626c d "....."eligibl │ │ │ +00044160: 652d 7065 6572 733a 2025 6422 0a09 0909 e-peers: %d".... │ │ │ +00044170: 0922 2061 6c6c 6f77 6564 2d73 6c6f 7473 ." allowed-slots │ │ │ +00044180: 3a20 2564 205d 220a 0909 0909 2c20 696e : %d ]"....., in │ │ │ +00044190: 7428 6d5f 636f 6e6e 6563 7469 6f6e 732e t(m_connections. │ │ │ +000441a0: 7369 7a65 2829 290a 0909 0909 2c20 696e size())....., in │ │ │ +000441b0: 7428 7065 6572 732e 7369 7a65 2829 290a t(peers.size()). │ │ │ +000441c0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +000441d0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00044200: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +00044230: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ +00044240: 7070 3a34 3830 343c 2f61 3e3c 2f74 643e pp:4804 │ │ │ +00044250: 3c74 643e 6974 206d 6967 6874 2062 6520 it might be │ │ │ +00044260: 6120 6e69 6365 2066 6561 7475 7265 2068 a nice feature h │ │ │ +00044270: 6572 6520 746f 206c 696d 6974 2074 6865 ere to limit the │ │ │ +00044280: 206e 756d 6265 7220 6f66 2074 6f72 7265 number of torre │ │ │ +00044290: 6e74 7320 746f 2073 656e 6420 696e 2061 nts to send in a │ │ │ +000442a0: 2073 696e 676c 6520 7570 6461 7465 2e20 single update. │ │ │ +000442b0: 4279 206a 7573 7420 706f 7374 696e 6720 By just posting │ │ │ +000442c0: 7468 6520 6669 7273 7420 6e20 746f 7272 the first n torr │ │ │ +000442d0: 656e 7473 2c20 7468 6579 2077 6f75 6c64 ents, they would │ │ │ +000442e0: 206e 6963 656c 7920 6265 2072 6f75 6e64 nicely be round │ │ │ +000442f0: 2d72 6f62 696e 6564 2062 6563 6175 7365 -robined because │ │ │ +00044300: 2074 6865 2074 6f72 7265 6e74 206c 6973 the torrent lis │ │ │ +00044310: 7473 2061 7265 2061 6c77 6179 7320 7075 ts are always pu │ │ │ +00044320: 7368 6564 2062 6163 6b2e 2050 6572 6861 shed back. Perha │ │ │ +00044330: 7073 2074 6865 2073 7461 7475 735f 7570 ps the status_up │ │ │ +00044340: 6461 7465 5f61 6c65 7274 2063 6f75 6c64 date_alert could │ │ │ +00044350: 2065 7665 6e20 6861 7665 2061 2066 6978 even have a fix │ │ │ +00044360: 6564 2061 7272 6179 206f 6620 6e20 656e ed array of n en │ │ │ +00044370: 7472 6965 7320 7261 7468 6572 2074 6861 tries rather tha │ │ │ +00044380: 6e20 6120 7665 6374 6f72 2c20 746f 2066 n a vector, to f │ │ │ +00044390: 7572 7468 6572 2069 6d70 726f 7665 206d urther improve m │ │ │ +000443a0: 656d 6f72 7920 6c6f 6361 6c69 7479 2e3c emory locality.< │ │ │ +000443b0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    it │ │ │ +00044400: 6d69 6768 7420 6265 2061 206e 6963 6520 might be a nice │ │ │ +00044410: 6665 6174 7572 6520 6865 7265 2074 6f20 feature here to │ │ │ +00044420: 6c69 6d69 7420 7468 6520 6e75 6d62 6572 limit the number │ │ │ +00044430: 206f 6620 746f 7272 656e 7473 0a74 6f20 of torrents.to │ │ │ +00044440: 7365 6e64 2069 6e20 6120 7369 6e67 6c65 send in a single │ │ │ +00044450: 2075 7064 6174 652e 2042 7920 6a75 7374 update. By just │ │ │ +00044460: 2070 6f73 7469 6e67 2074 6865 2066 6972 posting the fir │ │ │ +00044470: 7374 206e 2074 6f72 7265 6e74 732c 2074 st n torrents, t │ │ │ +00044480: 6865 790a 776f 756c 6420 6e69 6365 6c79 hey.would nicely │ │ │ +00044490: 2062 6520 726f 756e 642d 726f 6269 6e65 be round-robine │ │ │ +000444a0: 6420 6265 6361 7573 6520 7468 6520 746f d because the to │ │ │ +000444b0: 7272 656e 7420 6c69 7374 7320 6172 6520 rrent lists are │ │ │ +000444c0: 616c 7761 7973 0a70 7573 6865 6420 6261 always.pushed ba │ │ │ +000444d0: 636b 2e20 5065 7268 6170 7320 7468 6520 ck. Perhaps the │ │ │ +000444e0: 7374 6174 7573 5f75 7064 6174 655f 616c status_update_al │ │ │ +000444f0: 6572 7420 636f 756c 6420 6576 656e 2068 ert could even h │ │ │ +00044500: 6176 6520 6120 6669 7865 640a 6172 7261 ave a fixed.arra │ │ │ +00044510: 7920 6f66 206e 2065 6e74 7269 6573 2072 y of n entries r │ │ │ +00044520: 6174 6865 7220 7468 616e 2061 2076 6563 ather than a vec │ │ │ +00044530: 746f 722c 2074 6f20 6675 7274 6865 7220 tor, to further │ │ │ +00044540: 696d 7072 6f76 6520 6d65 6d6f 7279 0a6c improve memory.l │ │ │ +00044550: 6f63 616c 6974 792e 3c2f 6832 3e3c 6834 ocality.

    ../src/session_ │ │ │ +00044570: 696d 706c 2e63 7070 3a34 3830 343c 2f68 impl.cpp:4804
    ...t
    │ │ │ +000445c0: 2d26 6774 3b73 7461 7475 7328 2661 6d70  ->status(&
    │ │ │ +000445d0: 3b73 742c 2066 6c61 6773 293b 0a09 097d  ;st, flags);...}
    │ │ │ +000445e0: 0a09 7d0a 0a09 766f 6964 2073 6573 7369  ..}...void sessi
    │ │ │ +000445f0: 6f6e 5f69 6d70 6c3a 3a70 6f73 745f 746f  on_impl::post_to
    │ │ │ +00044600: 7272 656e 745f 7570 6461 7465 7328 7374  rrent_updates(st
    │ │ │ +00044610: 6174 7573 5f66 6c61 6773 5f74 2063 6f6e  atus_flags_t con
    │ │ │ +00044620: 7374 2066 6c61 6773 290a 097b 0a09 0949  st flags)..{...I
    │ │ │ +00044630: 4e56 4152 4941 4e54 5f43 4845 434b 3b0a  NVARIANT_CHECK;.
    │ │ │ +00044640: 0a09 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ +00044650: 5428 6973 5f73 696e 676c 655f 7468 7265  T(is_single_thre
    │ │ │ +00044660: 6164 2829 293b 0a0a 0909 7374 643a 3a76  ad());....std::v
    │ │ │ +00044670: 6563 746f 7226 6c74 3b74 6f72 7265 6e74  ector<torrent
    │ │ │ +00044680: 2a26 6774 3b26 616d 703b 2073 7461 7465  *>& state
    │ │ │ +00044690: 5f75 7064 6174 6573 0a09 0909 3d20 6d5f  _updates....= m_
    │ │ │ +000446a0: 746f 7272 656e 745f 6c69 7374 735b 6175  torrent_lists[au
    │ │ │ +000446b0: 783a 3a73 6573 7369 6f6e 5f69 6d70 6c3a  x::session_impl:
    │ │ │ +000446c0: 3a74 6f72 7265 6e74 5f73 7461 7465 5f75  :torrent_state_u
    │ │ │ +000446d0: 7064 6174 6573 5d3b 0a0a 2369 6620 544f  pdates];..#if TO
    │ │ │ +000446e0: 5252 454e 545f 5553 455f 4153 5345 5254  RRENT_USE_ASSERT
    │ │ │ +000446f0: 530a 0909 6d5f 706f 7374 696e 675f 746f  S...m_posting_to
    │ │ │ +00044700: 7272 656e 745f 7570 6461 7465 7320 3d20  rrent_updates = 
    │ │ │ +00044710: 7472 7565 3b0a 2365 6e64 6966 0a0a 0909  true;.#endif....
    │ │ │ +00044720: 7374 643a 3a76 6563 746f 7226 6c74 3b74  std::vector<t
    │ │ │ +00044730: 6f72 7265 6e74 5f73 7461 7475 7326 6774  orrent_status>
    │ │ │ +00044740: 3b20 7374 6174 7573 3b0a 0909 7374 6174  ; status;...stat
    │ │ │ +00044750: 7573 2e72 6573 6572 7665 2873 7461 7465  us.reserve(state
    │ │ │ +00044760: 5f75 7064 6174 6573 2e73 697a 6528 2929  _updates.size())
    │ │ │ +00044770: 3b0a 0a3c 6469 7620 7374 796c 653d 2262  ;..
    ..for (auto& │ │ │ +000447b0: 3b20 7420 3a20 7374 6174 655f 7570 6461 ; t : state_upda │ │ │ +000447c0: 7465 7329 0a3c 2f64 6976 3e09 097b 0a09 tes).
    ..{.. │ │ │ +000447d0: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +000447e0: 2874 2d26 6774 3b6d 5f6c 696e 6b73 5b61 (t->m_links[a │ │ │ +000447f0: 7578 3a3a 7365 7373 696f 6e5f 696d 706c ux::session_impl │ │ │ +00044800: 3a3a 746f 7272 656e 745f 7374 6174 655f ::torrent_state_ │ │ │ +00044810: 7570 6461 7465 735d 2e69 6e5f 6c69 7374 updates].in_list │ │ │ +00044820: 2829 293b 0a09 0909 7374 6174 7573 2e65 ());....status.e │ │ │ +00044830: 6d70 6c61 6365 5f62 6163 6b28 293b 0a09 mplace_back();.. │ │ │ +00044840: 0909 2f2f 2071 7565 7279 696e 6720 6163 ..// querying ac │ │ │ +00044850: 6375 7261 7465 2064 6f77 6e6c 6f61 6420 curate download │ │ │ +00044860: 636f 756e 7465 7273 206d 6179 2072 6571 counters may req │ │ │ +00044870: 7569 7265 0a09 0909 2f2f 2074 6865 2074 uire....// the t │ │ │ +00044880: 6f72 7265 6e74 2074 6f20 6265 206c 6f61 orrent to be loa │ │ │ +00044890: 6465 642e 204c 6f61 6469 6e67 2061 2074 ded. Loading a t │ │ │ +000448a0: 6f72 7265 6e74 2c20 616e 6420 6576 6963 orrent, and evic │ │ │ +000448b0: 7469 6e67 2061 6e6f 7468 6572 0a09 0909 ting another.... │ │ │ +000448c0: 2f2f 206f 6e65 2077 696c 6c20 6c65 6164 // one will lead │ │ │ +000448d0: 2074 6f20 6361 6c6c 696e 6720 7374 6174 to calling stat │ │ │ +000448e0: 655f 7570 6461 7465 6428 292c 2077 6869 e_updated(), whi │ │ │ +000448f0: 6368 2073 6372 6577 7320 7769 7468 0a09 ch screws with.. │ │ │ +00044900: 0909 2f2f 2074 6869 7320 6c69 7374 2077 ..// this list w │ │ │ +00044910: 6869 6c65 2077 6527 7265 2077 6f72 6b69 hile we're worki │ │ │ +00044920: 6e67 206f 6e20 6974 2c20 616e 6420 6272 ng on it, and br │ │ │ +00044930: 6561 6b20 7468 696e 6773 0a09 0909 742d eak things....t- │ │ │ +00044940: 2667 743b 7374 6174 7573 2826 616d 703b >status(& │ │ │ +00044950: 7374 6174 7573 2e62 6163 6b28 292c 2066 status.back(), f │ │ │ +00044960: 6c61 6773 293b 0a09 0909 742d 2667 743b lags);....t-> │ │ │ +00044970: 636c 6561 725f 696e 5f73 7461 7465 5f75 clear_in_state_u │ │ │ +00044980: 7064 6174 6528 293b 0a09 097d 0a09 0973 pdate();...}...s │ │ │ +00044990: 7461 7465 5f75 7064 6174 6573 2e63 6c65 tate_updates.cle │ │ │ +000449a0: 6172 2829 3b0a 0a23 6966 2054 4f52 5245 ar();..#if TORRE │ │ │ +000449b0: 4e54 5f55 5345 5f41 5353 4552 5453 0a09 NT_USE_ASSERTS.. │ │ │ +000449c0: 096d 5f70 6f73 7469 6e67 5f74 6f72 7265 .m_posting_torre │ │ │ +000449d0: 6e74 5f75 7064 6174 6573 203d 2066 616c nt_updates = fal │ │ │ +000449e0: 7365 3b0a 2365 6e64 6966 0a0a 0909 6d5f se;.#endif....m_ │ │ │ +000449f0: 616c 6572 7473 2e65 6d70 6c61 6365 5f61 alerts.emplace_a │ │ │ +00044a00: 6c65 7274 266c 743b 7374 6174 655f 7570 lert<state_up │ │ │ +00044a10: 6461 7465 5f61 6c65 7274 2667 743b 2873 date_alert>(s │ │ │ +00044a20: 7464 3a3a 6d6f 7665 2873 7461 7475 7329 td::move(status) │ │ │ +00044a30: 293b 0a09 7d0a 0a09 766f 6964 2073 6573 );..}...void ses │ │ │ +00044a40: 7369 6f6e 5f69 6d70 6c3a 3a70 6f73 745f sion_impl::post_ │ │ │ +00044a50: 7365 7373 696f 6e5f 7374 6174 7328 290a session_stats(). │ │ │ +00044a60: 097b 0a09 0969 6620 2821 6d5f 706f 7374 .{...if (!m_post │ │ │ +00044a70: 6564 5f73 7461 7473 5f68 6561 6465 7229 ed_stats_header) │ │ │ +00044a80: 0a09 097b 0a09 0909 6d5f 706f 7374 6564 ...{....m_posted │ │ │ +00044a90: 5f73 7461 7473 5f68 6561 6465 7220 3d20 _stats_header = │ │ │ +00044aa0: 7472 7565 3b0a 0909 096d 5f61 6c65 7274 true;....m_alert │ │ │ +00044ab0: 732e 656d 706c 6163 655f 616c 6572 7426 s.emplace_alert& │ │ │ +00044ac0: 6c74 3b73 6573 7369 6f6e 5f73 7461 7473 lt;session_stats │ │ │ +00044ad0: 5f68 6561 6465 725f 616c 6572 7426 6774 _header_alert> │ │ │ +00044ae0: 3b28 293b 0a09 097d 0a09 096d 5f64 6973 ;();...}...m_dis │ │ │ +00044af0: 6b5f 7468 7265 6164 2d26 6774 3b75 7064 k_thread->upd │ │ │ +00044b00: 6174 655f 7374 6174 735f 636f 756e 7465 ate_stats_counte │ │ │ +00044b10: 7273 286d 5f73 7461 7473 5f63 6f75 6e74 rs(m_stats_count │ │ │ +00044b20: 6572 7329 3b0a 0a23 6966 6e64 6566 2054 ers);..#ifndef T │ │ │ +00044b30: 4f52 5245 4e54 5f44 4953 4142 4c45 5f44 ORRENT_DISABLE_D │ │ │ +00044b40: 4854 0a09 0969 6620 286d 5f64 6874 290a HT...if (m_dht). │ │ │ +00044b50: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +00044b60: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00044b90: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +00044bc0: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ +00044bd0: 7070 3a35 3138 363c 2f61 3e3c 2f74 643e pp:5186 │ │ │ +00044be0: 3c74 643e 6661 6374 6f72 206f 7574 2074 factor out t │ │ │ +00044bf0: 6869 7320 6c6f 6769 6320 696e 746f 2061 his logic into a │ │ │ +00044c00: 2073 6570 6172 6174 6520 6675 6e63 7469 separate functi │ │ │ +00044c10: 6f6e 2066 6f72 2075 6e69 7420 7465 7374 on for unit test │ │ │ +00044c20: 696e 673c 2f74 643e 3c2f 7472 3e3c 7472 ing

    factor out this │ │ │ +00044c80: 206c 6f67 6963 2069 6e74 6f20 6120 7365 logic into a se │ │ │ +00044c90: 7061 7261 7465 2066 756e 6374 696f 6e20 parate function │ │ │ +00044ca0: 666f 7220 756e 6974 0a74 6573 7469 6e67 for unit.testing │ │ │ +00044cb0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +00044cc0: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ +00044cd0: 3a35 3138 363c 2f68 343e 3c70 7265 2073 :5186

    ..if (m_sett
    │ │ │ +00044d20: 696e 6773 2e67 6574 5f69 6e74 2873 6574  ings.get_int(set
    │ │ │ +00044d30: 7469 6e67 735f 7061 636b 3a3a 6f75 7467  tings_pack::outg
    │ │ │ +00044d40: 6f69 6e67 5f70 6f72 7429 2026 6774 3b20  oing_port) > 
    │ │ │ +00044d50: 3029 0a09 097b 0a23 6966 6465 6620 544f  0)...{.#ifdef TO
    │ │ │ +00044d60: 5252 454e 545f 5749 4e44 4f57 530a 0909  RRENT_WINDOWS...
    │ │ │ +00044d70: 0973 2e73 6574 5f6f 7074 696f 6e28 6578  .s.set_option(ex
    │ │ │ +00044d80: 636c 7573 6976 655f 6164 6472 6573 735f  clusive_address_
    │ │ │ +00044d90: 7573 6528 7472 7565 292c 2065 6329 3b0a  use(true), ec);.
    │ │ │ +00044da0: 2365 6c73 650a 0909 0973 2e73 6574 5f6f  #else....s.set_o
    │ │ │ +00044db0: 7074 696f 6e28 7463 703a 3a61 6363 6570  ption(tcp::accep
    │ │ │ +00044dc0: 746f 723a 3a72 6575 7365 5f61 6464 7265  tor::reuse_addre
    │ │ │ +00044dd0: 7373 2874 7275 6529 2c20 6563 293b 0a23  ss(true), ec);.#
    │ │ │ +00044de0: 656e 6469 660a 0909 092f 2f20 6967 6e6f  endif....// igno
    │ │ │ +00044df0: 7265 2065 7272 6f72 7320 6265 6361 7573  re errors becaus
    │ │ │ +00044e00: 6520 7468 6520 756e 6465 726c 7969 6e67  e the underlying
    │ │ │ +00044e10: 2073 6f63 6b65 7420 6d61 7920 6e6f 740a   socket may not.
    │ │ │ +00044e20: 0909 092f 2f20 6265 206f 7065 6e65 6420  ...// be opened 
    │ │ │ +00044e30: 7965 742e 2054 6869 7320 6861 7070 656e  yet. This happen
    │ │ │ +00044e40: 7320 7768 656e 2077 6527 7265 2072 6f75  s when we're rou
    │ │ │ +00044e50: 7469 6e67 2074 6872 6f75 6768 0a09 0909  ting through....
    │ │ │ +00044e60: 2f2f 2061 2070 726f 7879 2e20 496e 2074  // a proxy. In t
    │ │ │ +00044e70: 6861 7420 6361 7365 2c20 7765 2064 6f6e  hat case, we don
    │ │ │ +00044e80: 2774 2079 6574 206b 6e6f 7720 7468 6520  't yet know the 
    │ │ │ +00044e90: 6164 6472 6573 7320 6f66 0a09 0909 2f2f  address of....//
    │ │ │ +00044ea0: 2074 6865 2070 726f 7879 2073 6572 7665   the proxy serve
    │ │ │ +00044eb0: 722c 2061 6e64 206d 6f72 6520 696d 706f  r, and more impo
    │ │ │ +00044ec0: 7274 616e 746c 792c 2077 6520 646f 6e27  rtantly, we don'
    │ │ │ +00044ed0: 7420 6b6e 6f77 0a09 0909 2f2f 2074 6865  t know....// the
    │ │ │ +00044ee0: 2061 6464 7265 7373 2066 616d 696c 7920   address family 
    │ │ │ +00044ef0: 6f66 2069 7473 2061 6464 7265 7373 2e20  of its address. 
    │ │ │ +00044f00: 5468 6973 206d 6561 6e73 2077 6520 6361  This means we ca
    │ │ │ +00044f10: 6e27 740a 0909 092f 2f20 6f70 656e 2074  n't....// open t
    │ │ │ +00044f20: 6865 2073 6f63 6b65 7420 7965 742e 2054  he socket yet. T
    │ │ │ +00044f30: 6865 2073 6f63 6b73 2061 6273 7472 6163  he socks abstrac
    │ │ │ +00044f40: 7469 6f6e 206c 6179 6572 2064 6566 6572  tion layer defer
    │ │ │ +00044f50: 730a 0909 092f 2f20 6f70 656e 696e 6720  s....// opening 
    │ │ │ +00044f60: 6974 2e0a 0909 0965 632e 636c 6561 7228  it.....ec.clear(
    │ │ │ +00044f70: 293b 0a09 0909 6269 6e64 5f65 702e 706f  );....bind_ep.po
    │ │ │ +00044f80: 7274 2873 7464 3a3a 7569 6e74 3136 5f74  rt(std::uint16_t
    │ │ │ +00044f90: 286e 6578 745f 706f 7274 2829 2929 3b0a  (next_port()));.
    │ │ │ +00044fa0: 0909 7d0a 0a09 0969 6620 2869 735f 7574  ..}....if (is_ut
    │ │ │ +00044fb0: 7028 7329 290a 0909 7b0a 3c64 6976 2073  p(s))...{.
    .
    . │ │ │ +00044ff0: 0909 7574 705f 736f 636b 6574 5f69 6d70 ..utp_socket_imp │ │ │ +00045000: 6c2a 2069 6d70 6c20 3d20 6e75 6c6c 7074 l* impl = nullpt │ │ │ +00045010: 723b 0a09 0909 7472 616e 7370 6f72 7420 r;....transport │ │ │ +00045020: 7373 6c20 3d20 7472 616e 7370 6f72 743a ssl = transport: │ │ │ +00045030: 3a70 6c61 696e 7465 7874 3b0a 2369 6620 :plaintext;.#if │ │ │ +00045040: 544f 5252 454e 545f 5553 455f 5353 4c0a TORRENT_USE_SSL. │ │ │ +00045050: 0909 0969 6620 2862 6f6f 7374 3a3a 6765 ...if (boost::ge │ │ │ +00045060: 7426 6c74 3b73 736c 5f73 7472 6561 6d26 t<ssl_stream& │ │ │ +00045070: 6c74 3b75 7470 5f73 7472 6561 6d26 6774 lt;utp_stream> │ │ │ +00045080: 3b26 6774 3b28 2661 6d70 3b73 2920 213d ;>(&s) != │ │ │ +00045090: 206e 756c 6c70 7472 290a 0909 097b 0a09 nullptr)....{.. │ │ │ +000450a0: 0909 0969 6d70 6c20 3d20 626f 6f73 743a ...impl = boost: │ │ │ +000450b0: 3a67 6574 266c 743b 7373 6c5f 7374 7265 :get<ssl_stre │ │ │ +000450c0: 616d 266c 743b 7574 705f 7374 7265 616d am<utp_stream │ │ │ +000450d0: 2667 743b 2667 743b 2873 292e 6e65 7874 >>(s).next │ │ │ +000450e0: 5f6c 6179 6572 2829 2e67 6574 5f69 6d70 _layer().get_imp │ │ │ +000450f0: 6c28 293b 0a09 0909 0973 736c 203d 2074 l();.....ssl = t │ │ │ +00045100: 7261 6e73 706f 7274 3a3a 7373 6c3b 0a09 ransport::ssl;.. │ │ │ +00045110: 0909 7d0a 0909 0965 6c73 650a 2365 6e64 ..}....else.#end │ │ │ +00045120: 6966 0a09 0909 0969 6d70 6c20 3d20 626f if.....impl = bo │ │ │ +00045130: 6f73 743a 3a67 6574 266c 743b 7574 705f ost::get<utp_ │ │ │ +00045140: 7374 7265 616d 2667 743b 2873 292e 6765 stream>(s).ge │ │ │ +00045150: 745f 696d 706c 2829 3b0a 0a09 0909 7374 t_impl();.....st │ │ │ +00045160: 643a 3a76 6563 746f 7226 6c74 3b73 7464 d::vector<std │ │ │ +00045170: 3a3a 7368 6172 6564 5f70 7472 266c 743b ::shared_ptr< │ │ │ +00045180: 6c69 7374 656e 5f73 6f63 6b65 745f 7426 listen_socket_t& │ │ │ +00045190: 6774 3b26 6774 3b20 7769 7468 5f67 6174 gt;> with_gat │ │ │ +000451a0: 6577 6179 733b 0a09 0909 7374 643a 3a73 eways;....std::s │ │ │ +000451b0: 6861 7265 645f 7074 7226 6c74 3b6c 6973 hared_ptr<lis │ │ │ +000451c0: 7465 6e5f 736f 636b 6574 5f74 2667 743b ten_socket_t> │ │ │ +000451d0: 206d 6174 6368 3b0a 0909 0966 6f72 2028 match;....for ( │ │ │ +000451e0: 6175 746f 2661 6d70 3b20 6c73 203a 206d auto& ls : m │ │ │ +000451f0: 5f6c 6973 7465 6e5f 736f 636b 6574 7329 _listen_sockets) │ │ │ +00045200: 0a09 0909 7b0a 0909 0909 2f2f 2074 6869 ....{.....// thi │ │ │ +00045210: 7320 6973 2061 6c6d 6f73 742c 2062 7574 s is almost, but │ │ │ +00045220: 206e 6f74 2071 7569 7465 2c20 6c69 6b65 not quite, like │ │ │ +00045230: 2063 616e 5f72 6f75 7465 2829 0a09 0909 can_route().... │ │ │ +00045240: 0969 6620 2821 286c 732d 2667 743b 666c .if (!(ls->fl │ │ │ +00045250: 6167 7320 2661 6d70 3b20 6c69 7374 656e ags & listen │ │ │ +00045260: 5f73 6f63 6b65 745f 743a 3a70 726f 7879 _socket_t::proxy │ │ │ +00045270: 290a 0909 0909 0926 616d 703b 2661 6d70 )......&& │ │ │ +00045280: 3b20 6973 5f76 3428 6c73 2d26 6774 3b6c ; is_v4(ls->l │ │ │ +00045290: 6f63 616c 5f65 6e64 706f 696e 7429 2021 ocal_endpoint) ! │ │ │ +000452a0: 3d20 7265 6d6f 7465 5f61 6464 7265 7373 = remote_address │ │ │ +000452b0: 2e69 735f 7634 2829 290a 0909 0909 0963 .is_v4())......c │ │ │ +000452c0: 6f6e 7469 6e75 653b 0a09 0909 0969 6620 ontinue;.....if │ │ │ +000452d0: 286c 732d 2667 743b 7373 6c20 213d 2073 (ls->ssl != s │ │ │ +000452e0: 736c 2920 636f 6e74 696e 7565 3b0a 0909 sl) continue;... │ │ │ +000452f0: 0909 6966 2028 2128 6c73 2d26 6774 3b66 ..if (!(ls->f │ │ │ +00045300: 6c61 6773 2026 616d 703b 206c 6973 7465 lags & liste │ │ │ +00045310: 6e5f 736f 636b 6574 5f74 3a3a 6c6f 6361 n_socket_t::loca │ │ │ +00045320: 6c5f 6e65 7477 6f72 6b29 290a 0909 0909 l_network))..... │ │ │ +00045330: 0977 6974 685f 6761 7465 7761 7973 2e70 .with_gateways.p │ │ │ +00045340: 7573 685f 6261 636b 286c 7329 3b0a 0a09 ush_back(ls);... │ │ │ +00045350: 0909 0969 6620 286c 732d 2667 743b 666c ...if (ls->fl │ │ │ +00045360: 6167 7320 2661 6d70 3b20 6c69 7374 656e ags & listen │ │ │ +00045370: 5f73 6f63 6b65 745f 743a 3a70 726f 7879 _socket_t::proxy │ │ │ +00045380: 0a09 0909 0909 7c7c 206d 6174 6368 5f61 ......|| match_a │ │ │ +00045390: 6464 725f 6d61 736b 286c 732d 2667 743b ddr_mask(ls-> │ │ │ +000453a0: 6c6f 6361 6c5f 656e 6470 6f69 6e74 2e61 local_endpoint.a │ │ │ +000453b0: 6464 7265 7373 2829 2c20 7265 6d6f 7465 ddress(), remote │ │ │ +000453c0: 5f61 6464 7265 7373 2c20 6c73 2d26 6774 _address, ls-> │ │ │ +000453d0: 3b6e 6574 6d61 736b 2929 0a09 0909 097b ;netmask)).....{ │ │ │ +000453e0: 0a09 0909 0909 2f2f 2069 7320 7468 6973 ......// is this │ │ │ +000453f0: 2062 6574 7465 7220 7468 616e 2074 6865 better than the │ │ │ +00045400: 2070 7265 7669 6f75 7320 6d61 7463 683f previous match? │ │ │ +00045410: 0a09 0909 0909 6d61 7463 6820 3d20 6c73 ......match = ls │ │ │ +00045420: 3b0a 0909 0909 7d0a 3c2f 7072 653e 3c2f ;.....}.
    relevan │ │ │ +00045460: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/sessio │ │ │ +000454a0: 6e5f 696d 706c 2e63 7070 3a35 3931 373c n_impl.cpp:5917< │ │ │ +000454b0: 2f61 3e3c 2f74 643e 3c74 643e 7265 6661 /a>refa │ │ │ +000454c0: 6374 6f72 2c20 6d6f 7665 2074 6865 2073 ctor, move the s │ │ │ +000454d0: 746f 7261 6765 2074 6f20 6468 745f 7472 torage to dht_tr │ │ │ +000454e0: 6163 6b65 723c 2f74 643e 3c2f 7472 3e3c acker< │ │ │ +000454f0: 7472 2069 643d 2231 3637 2220 7374 796c tr id="167" styl │ │ │ +00045500: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00045510: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00045520: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00045530: 6832 3e72 6566 6163 746f 722c 206d 6f76 h2>refactor, mov │ │ │ +00045540: 6520 7468 6520 7374 6f72 6167 6520 746f e the storage to │ │ │ +00045550: 2064 6874 5f74 7261 636b 6572 3c2f 6832 dht_tracker

    ../src/sess │ │ │ +00045570: 696f 6e5f 696d 706c 2e63 7070 3a35 3931 ion_impl.cpp:591 │ │ │ +00045580: 373c 2f68 343e 3c70 7265 2073 7479 6c65 7

    │ │ │ +000455c0: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ +000455d0: 4449 5341 424c 455f 4c4f 4747 494e 470a  DISABLE_LOGGING.
    │ │ │ +000455e0: 0909 0973 6573 7369 6f6e 5f6c 6f67 2822  ...session_log("
    │ │ │ +000455f0: 6e6f 7420 7374 6172 7469 6e67 2044 4854  not starting DHT
    │ │ │ +00045600: 2c20 6f75 7473 7461 6e64 696e 6720 726f  , outstanding ro
    │ │ │ +00045610: 7574 6572 206c 6f6f 6b75 7073 3a20 2564  uter lookups: %d
    │ │ │ +00045620: 220a 0909 0909 2c20 6d5f 6f75 7473 7461  "....., m_outsta
    │ │ │ +00045630: 6e64 696e 675f 726f 7574 6572 5f6c 6f6f  nding_router_loo
    │ │ │ +00045640: 6b75 7073 293b 0a23 656e 6469 660a 0909  kups);.#endif...
    │ │ │ +00045650: 0972 6574 7572 6e3b 0a09 097d 0a0a 0909  .return;...}....
    │ │ │ +00045660: 6966 2028 6d5f 6162 6f72 7429 0a09 097b  if (m_abort)...{
    │ │ │ +00045670: 0a23 6966 6e64 6566 2054 4f52 5245 4e54  .#ifndef TORRENT
    │ │ │ +00045680: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47  _DISABLE_LOGGING
    │ │ │ +00045690: 0a09 0909 7365 7373 696f 6e5f 6c6f 6728  ....session_log(
    │ │ │ +000456a0: 226e 6f74 2073 7461 7274 696e 6720 4448  "not starting DH
    │ │ │ +000456b0: 542c 2061 626f 7274 696e 6722 293b 0a23  T, aborting");.#
    │ │ │ +000456c0: 656e 6469 660a 0909 0972 6574 7572 6e3b  endif....return;
    │ │ │ +000456d0: 0a09 097d 0a0a 2369 666e 6465 6620 544f  ...}..#ifndef TO
    │ │ │ +000456e0: 5252 454e 545f 4449 5341 424c 455f 4c4f  RRENT_DISABLE_LO
    │ │ │ +000456f0: 4747 494e 470a 0909 7365 7373 696f 6e5f  GGING...session_
    │ │ │ +00045700: 6c6f 6728 2273 7461 7274 696e 6720 4448  log("starting DH
    │ │ │ +00045710: 542c 2072 756e 6e69 6e67 3a20 2573 2c20  T, running: %s, 
    │ │ │ +00045720: 726f 7574 6572 206c 6f6f 6b75 7073 3a20  router lookups: 
    │ │ │ +00045730: 2564 220a 0909 092c 206d 5f64 6874 203f  %d"...., m_dht ?
    │ │ │ +00045740: 2022 7472 7565 2220 3a20 2266 616c 7365   "true" : "false
    │ │ │ +00045750: 222c 206d 5f6f 7574 7374 616e 6469 6e67  ", m_outstanding
    │ │ │ +00045760: 5f72 6f75 7465 725f 6c6f 6f6b 7570 7329  _router_lookups)
    │ │ │ +00045770: 3b0a 2365 6e64 6966 0a0a 3c64 6976 2073  ;.#endif..
    ..m_dht_ │ │ │ +000457b0: 7374 6f72 6167 6520 3d20 6d5f 6468 745f storage = m_dht_ │ │ │ +000457c0: 7374 6f72 6167 655f 636f 6e73 7472 7563 storage_construc │ │ │ +000457d0: 746f 7228 6d5f 7365 7474 696e 6773 293b tor(m_settings); │ │ │ +000457e0: 0a3c 2f64 6976 3e09 096d 5f64 6874 203d .
    ..m_dht = │ │ │ +000457f0: 2073 7464 3a3a 6d61 6b65 5f73 6861 7265 std::make_share │ │ │ +00045800: 6426 6c74 3b64 6874 3a3a 6468 745f 7472 d<dht::dht_tr │ │ │ +00045810: 6163 6b65 7226 6774 3b28 0a09 0909 7374 acker>(....st │ │ │ +00045820: 6174 6963 5f63 6173 7426 6c74 3b64 6874 atic_cast<dht │ │ │ +00045830: 3a3a 6468 745f 6f62 7365 7276 6572 2a26 ::dht_observer*& │ │ │ +00045840: 6774 3b28 7468 6973 290a 0909 092c 206d gt;(this)...., m │ │ │ +00045850: 5f69 6f5f 636f 6e74 6578 740a 0909 092c _io_context...., │ │ │ +00045860: 205b 7468 6973 5d28 6175 783a 3a6c 6973 [this](aux::lis │ │ │ +00045870: 7465 6e5f 736f 636b 6574 5f68 616e 646c ten_socket_handl │ │ │ +00045880: 6520 636f 6e73 7426 616d 703b 2073 6f63 e const& soc │ │ │ +00045890: 6b0a 0909 0909 2c20 7564 703a 3a65 6e64 k....., udp::end │ │ │ +000458a0: 706f 696e 7420 636f 6e73 7426 616d 703b point const& │ │ │ +000458b0: 2065 700a 0909 0909 2c20 7370 616e 266c ep....., span&l │ │ │ +000458c0: 743b 6368 6172 2063 6f6e 7374 2667 743b t;char const> │ │ │ +000458d0: 2070 0a09 0909 092c 2065 7272 6f72 5f63 p....., error_c │ │ │ +000458e0: 6f64 6526 616d 703b 2065 630a 0909 0909 ode& ec..... │ │ │ +000458f0: 2c20 7564 705f 7365 6e64 5f66 6c61 6773 , udp_send_flags │ │ │ +00045900: 5f74 2063 6f6e 7374 2066 6c61 6773 290a _t const flags). │ │ │ +00045910: 0909 0909 7b20 7365 6e64 5f75 6470 5f70 ....{ send_udp_p │ │ │ +00045920: 6163 6b65 745f 6c69 7374 656e 2873 6f63 acket_listen(soc │ │ │ +00045930: 6b2c 2065 702c 2070 2c20 6563 2c20 666c k, ep, p, ec, fl │ │ │ +00045940: 6167 7329 3b20 7d0a 0909 092c 206d 5f73 ags); }...., m_s │ │ │ +00045950: 6574 7469 6e67 730a 0909 092c 206d 5f73 ettings...., m_s │ │ │ +00045960: 7461 7473 5f63 6f75 6e74 6572 730a 0909 tats_counters... │ │ │ +00045970: 092c 202a 6d5f 6468 745f 7374 6f72 6167 ., *m_dht_storag │ │ │ +00045980: 650a 0909 092c 2073 7464 3a3a 6d6f 7665 e...., std::move │ │ │ +00045990: 286d 5f64 6874 5f73 7461 7465 2929 3b0a (m_dht_state));. │ │ │ +000459a0: 0a09 0966 6f72 2028 6175 746f 2661 6d70 ...for (auto& │ │ │ +000459b0: 3b20 7320 3a20 6d5f 6c69 7374 656e 5f73 ; s : m_listen_s │ │ │ +000459c0: 6f63 6b65 7473 290a 0909 7b0a 0909 0969 ockets)...{....i │ │ │ +000459d0: 6620 2873 2d26 6774 3b73 736c 2021 3d20 f (s->ssl != │ │ │ +000459e0: 7472 616e 7370 6f72 743a 3a73 736c 0a09 transport::ssl.. │ │ │ +000459f0: 0909 0926 616d 703b 2661 6d70 3b20 2128 ...&& !( │ │ │ +00045a00: 732d 2667 743b 666c 6167 7320 2661 6d70 s->flags & │ │ │ +00045a10: 3b20 6c69 7374 656e 5f73 6f63 6b65 745f ; listen_socket_ │ │ │ +00045a20: 743a 3a6c 6f63 616c 5f6e 6574 776f 726b t::local_network │ │ │ +00045a30: 2929 0a09 0909 7b0a 0909 0909 6d5f 6468 ))....{.....m_dh │ │ │ +00045a40: 742d 2667 743b 6e65 775f 736f 636b 6574 t->new_socket │ │ │ +00045a50: 2873 293b 0a09 0909 7d0a 0909 7d0a 0a09 (s);....}...}... │ │ │ +00045a60: 0966 6f72 2028 6175 746f 2063 6f6e 7374 .for (auto const │ │ │ +00045a70: 2661 6d70 3b20 6e20 3a20 6d5f 6468 745f & n : m_dht_ │ │ │ +00045a80: 726f 7574 6572 5f6e 6f64 6573 290a 0909 router_nodes)... │ │ │ +00045a90: 7b0a 0909 096d 5f64 6874 2d26 6774 3b61 {....m_dht->a │ │ │ +00045aa0: 6464 5f72 6f75 7465 725f 6e6f 6465 286e dd_router_node(n │ │ │ +00045ab0: 293b 0a09 097d 0a0a 0909 666f 7220 2861 );...}....for (a │ │ │ +00045ac0: 7574 6f20 636f 6e73 7426 616d 703b 206e uto const& n │ │ │ +00045ad0: 203a 206d 5f64 6874 5f6e 6f64 6573 290a : m_dht_nodes). │ │ │ +00045ae0: 0909 7b0a 3c2f 7072 653e 3c2f 7464 3e3c ..{.
    < │ │ │ +00045af0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +00045b20: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0
    . │ │ │ +00045b50: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ +00045b60: 706c 2e63 7070 3a36 3330 343c 2f61 3e3c pl.cpp:6304< │ │ │ +00045b70: 2f74 643e 3c74 643e 6173 7365 7274 7320 /td>asserts │ │ │ +00045b80: 7468 6174 206e 6f20 6f75 7473 7461 6e64 that no outstand │ │ │ +00045b90: 696e 6720 6173 796e 6320 6f70 6572 6174 ing async operat │ │ │ +00045ba0: 696f 6e73 2061 7265 2073 7469 6c6c 2069 ions are still i │ │ │ +00045bb0: 6e20 666c 6967 6874 3c2f 7464 3e3c 2f74 n flight

    asserts th │ │ │ +00045c10: 6174 206e 6f20 6f75 7473 7461 6e64 696e at no outstandin │ │ │ +00045c20: 6720 6173 796e 6320 6f70 6572 6174 696f g async operatio │ │ │ +00045c30: 6e73 2061 7265 2073 7469 6c6c 2069 6e20 ns are still in │ │ │ +00045c40: 666c 6967 6874 3c2f 6832 3e3c 6834 3e2e flight

    . │ │ │ +00045c50: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ +00045c60: 706c 2e63 7070 3a36 3330 343c 2f68 343e pl.cpp:6304

    │ │ │ +00045c70: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..if (
    │ │ │ +00045cb0: 216d 5f64 6874 2920 7265 7475 726e 3b0a  !m_dht) return;.
    │ │ │ +00045cc0: 0909 6d5f 6468 742d 2667 743b 6469 7265  ..m_dht->dire
    │ │ │ +00045cd0: 6374 5f72 6571 7565 7374 2865 702c 2065  ct_request(ep, e
    │ │ │ +00045ce0: 2c20 7374 643a 3a62 696e 6428 2661 6d70  , std::bind(&
    │ │ │ +00045cf0: 3b6f 6e5f 6469 7265 6374 5f72 6573 706f  ;on_direct_respo
    │ │ │ +00045d00: 6e73 652c 2073 7464 3a3a 7265 6628 6d5f  nse, std::ref(m_
    │ │ │ +00045d10: 616c 6572 7473 292c 2075 7365 7264 6174  alerts), userdat
    │ │ │ +00045d20: 612c 205f 3129 293b 0a09 7d0a 0a23 656e  a, _1));..}..#en
    │ │ │ +00045d30: 6469 660a 0a09 626f 6f6c 2073 6573 7369  dif...bool sessi
    │ │ │ +00045d40: 6f6e 5f69 6d70 6c3a 3a69 735f 6c69 7374  on_impl::is_list
    │ │ │ +00045d50: 656e 696e 6728 2920 636f 6e73 740a 097b  ening() const..{
    │ │ │ +00045d60: 0a09 0972 6574 7572 6e20 216d 5f6c 6973  ...return !m_lis
    │ │ │ +00045d70: 7465 6e5f 736f 636b 6574 732e 656d 7074  ten_sockets.empt
    │ │ │ +00045d80: 7928 293b 0a09 7d0a 0a09 7365 7373 696f  y();..}...sessio
    │ │ │ +00045d90: 6e5f 696d 706c 3a3a 7e73 6573 7369 6f6e  n_impl::~session
    │ │ │ +00045da0: 5f69 6d70 6c28 290a 097b 0a09 092f 2f20  _impl()..{...// 
    │ │ │ +00045db0: 7369 6e63 6520 7765 2772 6520 6465 7374  since we're dest
    │ │ │ +00045dc0: 7275 6374 696e 6720 7468 6520 7365 7373  ructing the sess
    │ │ │ +00045dd0: 696f 6e2c 206e 6f20 6d6f 7265 2061 6c65  ion, no more ale
    │ │ │ +00045de0: 7274 7320 7769 6c6c 206d 616b 6520 6974  rts will make it
    │ │ │ +00045df0: 206f 7574 2074 6f0a 0909 2f2f 2074 6865   out to...// the
    │ │ │ +00045e00: 2075 7365 722e 2053 6f20 7374 6f70 2070   user. So stop p
    │ │ │ +00045e10: 6f73 7469 6e67 2074 6865 6d20 6e6f 770a  osting them now.
    │ │ │ +00045e20: 0909 6d5f 616c 6572 7473 2e73 6574 5f61  ..m_alerts.set_a
    │ │ │ +00045e30: 6c65 7274 5f6d 6173 6b28 7b7d 293b 0a09  lert_mask({});..
    │ │ │ +00045e40: 096d 5f61 6c65 7274 732e 7365 745f 6e6f  .m_alerts.set_no
    │ │ │ +00045e50: 7469 6679 5f66 756e 6374 696f 6e28 7b7d  tify_function({}
    │ │ │ +00045e60: 293b 0a0a 0909 2f2f 2074 6869 7320 6973  );....// this is
    │ │ │ +00045e70: 206e 6f74 2061 6c6c 6f77 6564 2074 6f20   not allowed to 
    │ │ │ +00045e80: 6265 2074 6865 206e 6574 776f 726b 2074  be the network t
    │ │ │ +00045e90: 6872 6561 6421 0a2f 2f09 0954 4f52 5245  hread!.//..TORRE
    │ │ │ +00045ea0: 4e54 5f41 5353 4552 5428 6973 5f6e 6f74  NT_ASSERT(is_not
    │ │ │ +00045eb0: 5f74 6872 6561 6428 2929 3b0a 3c64 6976  _thread());.
    .
    ..// this can h │ │ │ +00045f00: 6170 7065 6e20 6966 2077 6520 656e 6420 appen if we end │ │ │ +00045f10: 7468 6520 696f 5f63 6f6e 7465 7874 2072 the io_context r │ │ │ +00045f20: 756e 206c 6f6f 7020 7769 7468 2061 6e20 un loop with an │ │ │ +00045f30: 6578 6365 7074 696f 6e0a 0909 6d5f 636f exception...m_co │ │ │ +00045f40: 6e6e 6563 7469 6f6e 732e 636c 6561 7228 nnections.clear( │ │ │ +00045f50: 293b 0a09 0966 6f72 2028 6175 746f 2661 );...for (auto&a │ │ │ +00045f60: 6d70 3b20 7420 3a20 6d5f 746f 7272 656e mp; t : m_torren │ │ │ +00045f70: 7473 290a 0909 7b0a 0909 0974 2d26 6774 ts)...{....t-> │ │ │ +00045f80: 3b70 616e 6963 2829 3b0a 0909 0974 2d26 ;panic();....t-& │ │ │ +00045f90: 6774 3b61 626f 7274 2829 3b0a 0909 7d0a gt;abort();...}. │ │ │ +00045fa0: 0909 6d5f 746f 7272 656e 7473 2e63 6c65 ..m_torrents.cle │ │ │ +00045fb0: 6172 2829 3b0a 0a09 092f 2f20 7468 6973 ar();....// this │ │ │ +00045fc0: 2068 6173 2070 726f 6261 626c 7920 6265 has probably be │ │ │ +00045fd0: 656e 2063 616c 6c65 6420 616c 7265 6164 en called alread │ │ │ +00045fe0: 792c 2062 7574 2069 6e20 6361 7365 206f y, but in case o │ │ │ +00045ff0: 6620 7375 6464 656e 0a09 092f 2f20 7465 f sudden...// te │ │ │ +00046000: 726d 696e 6174 696f 6e20 7468 726f 7567 rmination throug │ │ │ +00046010: 6820 616e 2065 7863 6570 7469 6f6e 2c20 h an exception, │ │ │ +00046020: 6974 206d 6179 206e 6f74 2068 6176 6520 it may not have │ │ │ +00046030: 6265 656e 2064 6f6e 650a 0909 6162 6f72 been done...abor │ │ │ +00046040: 745f 7374 6167 6532 2829 3b0a 0a23 6966 t_stage2();..#if │ │ │ +00046050: 2064 6566 696e 6564 2054 4f52 5245 4e54 defined TORRENT │ │ │ +00046060: 5f41 5349 4f5f 4445 4255 4747 494e 470a _ASIO_DEBUGGING. │ │ │ +00046070: 0909 4649 4c45 2a20 6620 3d20 666f 7065 ..FILE* f = fope │ │ │ +00046080: 6e28 2277 616b 6575 7073 2e6c 6f67 222c n("wakeups.log", │ │ │ +00046090: 2022 772b 2229 3b0a 0909 6966 2028 6620 "w+");...if (f │ │ │ +000460a0: 213d 206e 756c 6c70 7472 290a 0909 7b0a != nullptr)...{. │ │ │ +000460b0: 0909 0974 696d 655f 706f 696e 7420 6d20 ...time_point m │ │ │ +000460c0: 3d20 6d69 6e5f 7469 6d65 2829 3b0a 0909 = min_time();... │ │ │ +000460d0: 0969 6620 2821 5f77 616b 6575 7073 2e65 .if (!_wakeups.e │ │ │ +000460e0: 6d70 7479 2829 2920 6d20 3d20 5f77 616b mpty()) m = _wak │ │ │ +000460f0: 6575 7073 5b30 5d2e 7469 6d65 7374 616d eups[0].timestam │ │ │ +00046100: 703b 0a09 0909 7469 6d65 5f70 6f69 6e74 p;....time_point │ │ │ +00046110: 2070 7265 7620 3d20 6d3b 0a09 0909 7374 prev = m;....st │ │ │ +00046120: 643a 3a75 696e 7436 345f 7420 7072 6576 d::uint64_t prev │ │ │ +00046130: 5f63 7377 203d 2030 3b0a 0909 0969 6620 _csw = 0;....if │ │ │ +00046140: 2821 5f77 616b 6575 7073 2e65 6d70 7479 (!_wakeups.empty │ │ │ +00046150: 2829 2920 7072 6576 5f63 7377 203d 205f ()) prev_csw = _ │ │ │ +00046160: 7761 6b65 7570 735b 305d 2e63 6f6e 7465 wakeups[0].conte │ │ │ +00046170: 7874 5f73 7769 7463 6865 733b 0a09 0909 xt_switches;.... │ │ │ +00046180: 7374 643a 3a66 7072 696e 7466 2866 2c20 std::fprintf(f, │ │ │ +00046190: 2261 6273 2e20 7469 6d65 5c74 7265 6c2e "abs. time\trel. │ │ │ +000461a0: 2074 696d 655c 7463 7478 2073 7769 7463 time\tctx switc │ │ │ +000461b0: 685c 7469 646c 652d 7761 6b65 7570 5c74 h\tidle-wakeup\t │ │ │ +000461c0: 6f70 6572 6174 696f 6e5c 6e22 293b 0a09 operation\n");.. │ │ │ +000461d0: 0909 666f 7220 2877 616b 6575 705f 7420 ..for (wakeup_t │ │ │ +000461e0: 636f 6e73 7426 616d 703b 2077 203a 205f const& w : _ │ │ │ +000461f0: 7761 6b65 7570 7329 0a09 0909 7b0a 0909 wakeups)....{... │ │ │ +00046200: 0909 626f 6f6c 2063 6f6e 7374 2069 646c ..bool const idl │ │ │ +00046210: 655f 7761 6b65 7570 203d 2077 2e63 6f6e e_wakeup = w.con │ │ │ +00046220: 7465 7874 5f73 7769 7463 6865 7320 2667 text_switches &g │ │ │ +00046230: 743b 2070 7265 765f 6373 773b 0a09 0909 t; prev_csw;.... │ │ │ +00046240: 0973 7464 3a3a 6670 7269 6e74 6628 662c .std::fprintf(f, │ │ │ +00046250: 2022 2522 2050 5249 6436 3420 225c 7425 "%" PRId64 "\t% │ │ │ +00046260: 2220 5052 4964 3634 2022 5c74 2522 2050 " PRId64 "\t%" P │ │ │ +00046270: 5249 6436 3420 225c 7425 635c 7425 735c RId64 "\t%c\t%s\ │ │ │ +00046280: 6e22 0a09 0909 0909 2c20 746f 7461 6c5f n"......, total_ │ │ │ +00046290: 6d69 6372 6f73 6563 6f6e 6473 2877 2e74 microseconds(w.t │ │ │ +000462a0: 696d 6573 7461 6d70 202d 206d 290a 0909 imestamp - m)... │ │ │ +000462b0: 0909 092c 2074 6f74 616c 5f6d 6963 726f ..., total_micro │ │ │ +000462c0: 7365 636f 6e64 7328 772e 7469 6d65 7374 seconds(w.timest │ │ │ +000462d0: 616d 7020 2d20 7072 6576 290a 0909 0909 amp - prev)..... │ │ │ +000462e0: 092c 2077 2e63 6f6e 7465 7874 5f73 7769 ., w.context_swi │ │ │ +000462f0: 7463 6865 730a 3c2f 7072 653e 3c2f 7464 tches.
    relevance │ │ │ +00046330: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +00046340: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/udp_sock │ │ │ +00046370: 6574 2e63 7070 3a36 3730 3c2f 613e 3c2f et.cpp:670perhaps a │ │ │ +00046390: 6e20 6174 7465 6d70 7420 7368 6f75 6c64 n attempt should │ │ │ +000463a0: 2062 6520 6d61 6465 2074 6f20 6269 6e64 be made to bind │ │ │ +000463b0: 206d 5f73 6f63 6b73 355f 736f 636b 2074 m_socks5_sock t │ │ │ +000463c0: 6f20 7468 6520 6465 7669 6365 206f 6620 o the device of │ │ │ +000463d0: 6d5f 6c69 7374 656e 5f73 6f63 6b65 743c m_listen_socket< │ │ │ +000463e0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    per │ │ │ +00046430: 6861 7073 2061 6e20 6174 7465 6d70 7420 haps an attempt │ │ │ +00046440: 7368 6f75 6c64 2062 6520 6d61 6465 2074 should be made t │ │ │ +00046450: 6f20 6269 6e64 206d 5f73 6f63 6b73 355f o bind m_socks5_ │ │ │ +00046460: 736f 636b 2074 6f20 7468 650a 6465 7669 sock to the.devi │ │ │ +00046470: 6365 206f 6620 6d5f 6c69 7374 656e 5f73 ce of m_listen_s │ │ │ +00046480: 6f63 6b65 743c 2f68 323e 3c68 343e 2e2e ocket

    .. │ │ │ +00046490: 2f73 7263 2f75 6470 5f73 6f63 6b65 742e /src/udp_socket. │ │ │ +000464a0: 6370 703a 3637 303c 2f68 343e 3c70 7265 cpp:670

    .if (ec)..
    │ │ │ +000464f0: 7b0a 0909 6966 2028 6d5f 616c 6572 7473  {...if (m_alerts
    │ │ │ +00046500: 2e73 686f 756c 645f 706f 7374 266c 743b  .should_post<
    │ │ │ +00046510: 736f 636b 7335 5f61 6c65 7274 2667 743b  socks5_alert>
    │ │ │ +00046520: 2829 290a 0909 096d 5f61 6c65 7274 732e  ())....m_alerts.
    │ │ │ +00046530: 656d 706c 6163 655f 616c 6572 7426 6c74  emplace_alert<
    │ │ │ +00046540: 3b73 6f63 6b73 355f 616c 6572 7426 6774  ;socks5_alert>
    │ │ │ +00046550: 3b28 6d5f 7072 6f78 795f 6164 6472 2c20  ;(m_proxy_addr, 
    │ │ │ +00046560: 6f70 6572 6174 696f 6e5f 743a 3a73 6f63  operation_t::soc
    │ │ │ +00046570: 6b5f 6f70 7469 6f6e 2c20 6563 293b 0a09  k_option, ec);..
    │ │ │ +00046580: 0965 632e 636c 6561 7228 293b 0a09 7d0a  .ec.clear();..}.
    │ │ │ +00046590: 2365 6e64 6966 0a23 656e 6469 660a 0a09  #endif.#endif...
    │ │ │ +000465a0: 7463 703a 3a65 6e64 706f 696e 7420 636f  tcp::endpoint co
    │ │ │ +000465b0: 6e73 7420 6269 6e64 5f65 7028 6d5f 6c69  nst bind_ep(m_li
    │ │ │ +000465c0: 7374 656e 5f73 6f63 6b65 742e 6765 745f  sten_socket.get_
    │ │ │ +000465d0: 6c6f 6361 6c5f 656e 6470 6f69 6e74 2829  local_endpoint()
    │ │ │ +000465e0: 2e61 6464 7265 7373 2829 2c20 3029 3b0a  .address(), 0);.
    │ │ │ +000465f0: 096d 5f73 6f63 6b73 355f 736f 636b 2e62  .m_socks5_sock.b
    │ │ │ +00046600: 696e 6428 6269 6e64 5f65 702c 2065 6329  ind(bind_ep, ec)
    │ │ │ +00046610: 3b0a 0969 6620 2865 6329 0a09 7b0a 0909  ;..if (ec)..{...
    │ │ │ +00046620: 6966 2028 6d5f 616c 6572 7473 2e73 686f  if (m_alerts.sho
    │ │ │ +00046630: 756c 645f 706f 7374 266c 743b 736f 636b  uld_post<sock
    │ │ │ +00046640: 7335 5f61 6c65 7274 2667 743b 2829 290a  s5_alert>()).
    │ │ │ +00046650: 0909 096d 5f61 6c65 7274 732e 656d 706c  ...m_alerts.empl
    │ │ │ +00046660: 6163 655f 616c 6572 7426 6c74 3b73 6f63  ace_alert<soc
    │ │ │ +00046670: 6b73 355f 616c 6572 7426 6774 3b28 6d5f  ks5_alert>(m_
    │ │ │ +00046680: 7072 6f78 795f 6164 6472 2c20 6f70 6572  proxy_addr, oper
    │ │ │ +00046690: 6174 696f 6e5f 743a 3a73 6f63 6b5f 6269  ation_t::sock_bi
    │ │ │ +000466a0: 6e64 2c20 6563 293b 0a09 092b 2b6d 5f66  nd, ec);...++m_f
    │ │ │ +000466b0: 6169 6c75 7265 733b 0a09 0972 6574 7279  ailures;...retry
    │ │ │ +000466c0: 5f63 6f6e 6e65 6374 696f 6e28 293b 0a09  _connection();..
    │ │ │ +000466d0: 0972 6574 7572 6e3b 0a09 7d0a 0a3c 6469  .return;..}....ADD_OUTSTANDI
    │ │ │ +00046720: 4e47 5f41 5359 4e43 2822 736f 636b 7335  NG_ASYNC("socks5
    │ │ │ +00046730: 3a3a 6f6e 5f63 6f6e 6e65 6374 6564 2229  ::on_connected")
    │ │ │ +00046740: 3b0a 096d 5f73 6f63 6b73 355f 736f 636b  ;..m_socks5_sock
    │ │ │ +00046750: 2e61 7379 6e63 5f63 6f6e 6e65 6374 286d  .async_connect(m
    │ │ │ +00046760: 5f70 726f 7879 5f61 6464 720a 0909 2c20  _proxy_addr..., 
    │ │ │ +00046770: 7374 643a 3a62 696e 6428 2661 6d70 3b73  std::bind(&s
    │ │ │ +00046780: 6f63 6b73 353a 3a6f 6e5f 636f 6e6e 6563  ocks5::on_connec
    │ │ │ +00046790: 7465 642c 2073 656c 6628 292c 205f 3129  ted, self(), _1)
    │ │ │ +000467a0: 293b 0a0a 0941 4444 5f4f 5554 5354 414e  );...ADD_OUTSTAN
    │ │ │ +000467b0: 4449 4e47 5f41 5359 4e43 2822 736f 636b  DING_ASYNC("sock
    │ │ │ +000467c0: 7335 3a3a 6f6e 5f63 6f6e 6e65 6374 5f74  s5::on_connect_t
    │ │ │ +000467d0: 696d 656f 7574 2229 3b0a 096d 5f74 696d  imeout");..m_tim
    │ │ │ +000467e0: 6572 2e65 7870 6972 6573 5f61 6674 6572  er.expires_after
    │ │ │ +000467f0: 2873 6563 6f6e 6473 2831 3029 293b 0a09  (seconds(10));..
    │ │ │ +00046800: 6d5f 7469 6d65 722e 6173 796e 635f 7761  m_timer.async_wa
    │ │ │ +00046810: 6974 2873 7464 3a3a 6269 6e64 2826 616d  it(std::bind(&am
    │ │ │ +00046820: 703b 736f 636b 7335 3a3a 6f6e 5f63 6f6e  p;socks5::on_con
    │ │ │ +00046830: 6e65 6374 5f74 696d 656f 7574 0a09 092c  nect_timeout...,
    │ │ │ +00046840: 2073 656c 6628 292c 205f 3129 293b 0a7d   self(), _1));.}
    │ │ │ +00046850: 0a0a 766f 6964 2073 6f63 6b73 353a 3a6f  ..void socks5::o
    │ │ │ +00046860: 6e5f 636f 6e6e 6563 745f 7469 6d65 6f75  n_connect_timeou
    │ │ │ +00046870: 7428 6572 726f 725f 636f 6465 2063 6f6e  t(error_code con
    │ │ │ +00046880: 7374 2661 6d70 3b20 6529 0a7b 0a09 434f  st& e).{..CO
    │ │ │ +00046890: 4d50 4c45 5445 5f41 5359 4e43 2822 736f  MPLETE_ASYNC("so
    │ │ │ +000468a0: 636b 7335 3a3a 6f6e 5f63 6f6e 6e65 6374  cks5::on_connect
    │ │ │ +000468b0: 5f74 696d 656f 7574 2229 3b0a 0a09 6966  _timeout");...if
    │ │ │ +000468c0: 2028 6520 3d3d 2062 6f6f 7374 3a3a 6173   (e == boost::as
    │ │ │ +000468d0: 696f 3a3a 6572 726f 723a 3a6f 7065 7261  io::error::opera
    │ │ │ +000468e0: 7469 6f6e 5f61 626f 7274 6564 2920 7265  tion_aborted) re
    │ │ │ +000468f0: 7475 726e 3b0a 0a09 6966 2028 6d5f 6162  turn;...if (m_ab
    │ │ │ +00046900: 6f72 7429 2072 6574 7572 6e3b 0a0a 0969  ort) return;...i
    │ │ │ +00046910: 6620 286d 5f61 6c65 7274 732e 7368 6f75  f (m_alerts.shou
    │ │ │ +00046920: 6c64 5f70 6f73 7426 6c74 3b73 6f63 6b73  ld_post<socks
    │ │ │ +00046930: 355f 616c 6572 7426 6774 3b28 2929 0a09  5_alert>())..
    │ │ │ +00046940: 096d 5f61 6c65 7274 732e 656d 706c 6163  .m_alerts.emplac
    │ │ │ +00046950: 655f 616c 6572 7426 6c74 3b73 6f63 6b73  e_alert<socks
    │ │ │ +00046960: 355f 616c 6572 7426 6774 3b28 6d5f 7072  5_alert>(m_pr
    │ │ │ +00046970: 6f78 795f 6164 6472 2c20 6f70 6572 6174  oxy_addr, operat
    │ │ │ +00046980: 696f 6e5f 743a 3a63 6f6e 6e65 6374 2c20  ion_t::connect, 
    │ │ │ +00046990: 6572 726f 7273 3a3a 7469 6d65 645f 6f75  errors::timed_ou
    │ │ │ +000469a0: 7429 3b0a 0a09 6572 726f 725f 636f 6465  t);...error_code
    │ │ │ +000469b0: 2069 676e 6f72 653b 0a09 6d5f 736f 636b   ignore;..m_sock
    │ │ │ +000469c0: 7335 5f73 6f63 6b2e 636c 6f73 6528 6967  s5_sock.close(ig
    │ │ │ +000469d0: 6e6f 7265 293b 0a0a 092b 2b6d 5f66 6169  nore);...++m_fai
    │ │ │ +000469e0: 6c75 7265 733b 0a09 7265 7472 795f 636f  lures;..retry_co
    │ │ │ +000469f0: 6e6e 6563 7469 6f6e 2829 3b0a 7d0a 0a76  nnection();.}..v
    │ │ │ +00046a00: 6f69 6420 736f 636b 7335 3a3a 6f6e 5f63  oid socks5::on_c
    │ │ │ +00046a10: 6f6e 6e65 6374 6564 2865 7272 6f72 5f63  onnected(error_c
    │ │ │ +00046a20: 6f64 6520 636f 6e73 7426 616d 703b 2065  ode const& e
    │ │ │ +00046a30: 290a 7b0a 3c2f 7072 653e 3c2f 7464 3e3c  ).{.
    < │ │ │ +00046a40: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +00046a70: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +00046aa0: 2e2f 7372 632f 7065 6572 5f63 6f6e 6e65 ./src/peer_conne │ │ │ +00046ab0: 6374 696f 6e2e 6370 703a 3131 3038 3c2f ction.cpp:1108this │ │ │ +00046ad0: 7368 6f75 6c64 2062 6520 7468 6520 676c should be the gl │ │ │ +00046ae0: 6f62 616c 2064 6f77 6e6c 6f61 6420 7261 obal download ra │ │ │ +00046af0: 7465 3c2f 7464 3e3c 2f74 723e 3c74 7220 te

    │ │ │ +00046b40: 7468 6973 2073 686f 756c 6420 6265 2074 this should be t │ │ │ +00046b50: 6865 2067 6c6f 6261 6c20 646f 776e 6c6f he global downlo │ │ │ +00046b60: 6164 2072 6174 653c 2f68 323e 3c68 343e ad rate

    │ │ │ +00046b70: 2e2e 2f73 7263 2f70 6565 725f 636f 6e6e ../src/peer_conn │ │ │ +00046b80: 6563 7469 6f6e 2e63 7070 3a31 3130 383c ection.cpp:1108< │ │ │ +00046b90: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +00046bd0: 0969 6e74 2072 6174 6520 3d20 303b 0a0a  .int rate = 0;..
    │ │ │ +00046be0: 0909 2f2f 2069 6620 7765 2068 6176 656e  ..// if we haven
    │ │ │ +00046bf0: 2774 2072 6563 6569 7665 6420 616e 7920  't received any 
    │ │ │ +00046c00: 6461 7461 2072 6563 656e 746c 792c 2074  data recently, t
    │ │ │ +00046c10: 6865 2063 7572 7265 6e74 2064 6f77 6e6c  he current downl
    │ │ │ +00046c20: 6f61 6420 7261 7465 0a09 092f 2f20 6973  oad rate...// is
    │ │ │ +00046c30: 206e 6f74 2072 6570 7265 7365 6e74 6174   not representat
    │ │ │ +00046c40: 6976 650a 0909 6966 2028 6175 783a 3a74  ive...if (aux::t
    │ │ │ +00046c50: 696d 655f 6e6f 7728 2920 2d20 6d5f 6c61  ime_now() - m_la
    │ │ │ +00046c60: 7374 5f70 6965 6365 2e67 6574 286d 5f63  st_piece.get(m_c
    │ │ │ +00046c70: 6f6e 6e65 6374 2920 2667 743b 2073 6563  onnect) > sec
    │ │ │ +00046c80: 6f6e 6473 2833 3029 2026 616d 703b 2661  onds(30) &&a
    │ │ │ +00046c90: 6d70 3b20 6d5f 646f 776e 6c6f 6164 5f72  mp; m_download_r
    │ │ │ +00046ca0: 6174 655f 7065 616b 2026 6774 3b20 3029  ate_peak > 0)
    │ │ │ +00046cb0: 0a09 097b 0a09 0909 7261 7465 203d 206d  ...{....rate = m
    │ │ │ +00046cc0: 5f64 6f77 6e6c 6f61 645f 7261 7465 5f70  _download_rate_p
    │ │ │ +00046cd0: 6561 6b3b 0a09 097d 0a09 0965 6c73 6520  eak;...}...else 
    │ │ │ +00046ce0: 6966 2028 6175 783a 3a74 696d 655f 6e6f  if (aux::time_no
    │ │ │ +00046cf0: 7728 2920 2d20 6d5f 6c61 7374 5f75 6e63  w() - m_last_unc
    │ │ │ +00046d00: 686f 6b65 642e 6765 7428 6d5f 636f 6e6e  hoked.get(m_conn
    │ │ │ +00046d10: 6563 7429 2026 6c74 3b20 7365 636f 6e64  ect) < second
    │ │ │ +00046d20: 7328 3529 0a09 0909 2661 6d70 3b26 616d  s(5)....&&am
    │ │ │ +00046d30: 703b 206d 5f73 7461 7469 7374 6963 732e  p; m_statistics.
    │ │ │ +00046d40: 746f 7461 6c5f 7061 796c 6f61 645f 7570  total_payload_up
    │ │ │ +00046d50: 6c6f 6164 2829 2026 6c74 3b20 3220 2a20  load() < 2 * 
    │ │ │ +00046d60: 3078 3430 3030 290a 0909 7b0a 0909 092f  0x4000)...{..../
    │ │ │ +00046d70: 2f20 6966 2077 6527 7265 2068 6176 6520  / if we're have 
    │ │ │ +00046d80: 6f6e 6c79 2062 6565 6e20 756e 6368 6f6b  only been unchok
    │ │ │ +00046d90: 6564 2066 6f72 2061 2073 686f 7274 2070  ed for a short p
    │ │ │ +00046da0: 6572 696f 6420 6f66 2074 696d 652c 0a09  eriod of time,..
    │ │ │ +00046db0: 0909 2f2f 2077 6520 646f 6e27 7420 6b6e  ..// we don't kn
    │ │ │ +00046dc0: 6f77 2077 6861 7420 7261 7465 2077 6520  ow what rate we 
    │ │ │ +00046dd0: 6361 6e20 6765 7420 6672 6f6d 2074 6869  can get from thi
    │ │ │ +00046de0: 7320 7065 6572 2e20 496e 7374 6561 6420  s peer. Instead 
    │ │ │ +00046df0: 6f66 2061 7373 756d 696e 670a 0909 092f  of assuming..../
    │ │ │ +00046e00: 2f20 7468 6520 6c6f 7765 7374 2070 6f73  / the lowest pos
    │ │ │ +00046e10: 7369 626c 6520 7261 7465 2c20 6173 7375  sible rate, assu
    │ │ │ +00046e20: 6d65 2074 6865 2061 7665 7261 6765 2e0a  me the average..
    │ │ │ +00046e30: 0a09 0909 696e 7420 7065 6572 735f 7769  ....int peers_wi
    │ │ │ +00046e40: 7468 5f72 6571 7565 7374 7320 3d20 696e  th_requests = in
    │ │ │ +00046e50: 7428 7374 6174 735f 636f 756e 7465 7273  t(stats_counters
    │ │ │ +00046e60: 2829 5b63 6f75 6e74 6572 733a 3a6e 756d  ()[counters::num
    │ │ │ +00046e70: 5f70 6565 7273 5f64 6f77 6e5f 7265 7175  _peers_down_requ
    │ │ │ +00046e80: 6573 7473 5d29 3b0a 0909 092f 2f20 6176  ests]);....// av
    │ │ │ +00046e90: 6f69 6420 6469 7669 7369 6f6e 2062 7920  oid division by 
    │ │ │ +00046ea0: 300a 0909 0969 6620 2870 6565 7273 5f77  0....if (peers_w
    │ │ │ +00046eb0: 6974 685f 7265 7175 6573 7473 203d 3d20  ith_requests == 
    │ │ │ +00046ec0: 3029 2070 6565 7273 5f77 6974 685f 7265  0) peers_with_re
    │ │ │ +00046ed0: 7175 6573 7473 203d 2031 3b0a 0a3c 6469  quests = 1;.....ra
    │ │ │ +00046f10: 7465 203d 2074 2d26 6774 3b73 7461 7469  te = t->stati
    │ │ │ +00046f20: 7374 6963 7328 292e 7472 616e 7366 6572  stics().transfer
    │ │ │ +00046f30: 5f72 6174 6528 7374 6174 3a3a 646f 776e  _rate(stat::down
    │ │ │ +00046f40: 6c6f 6164 5f70 6179 6c6f 6164 2920 2f20  load_payload) / 
    │ │ │ +00046f50: 7065 6572 735f 7769 7468 5f72 6571 7565  peers_with_reque
    │ │ │ +00046f60: 7374 733b 0a3c 2f64 6976 3e09 097d 0a09  sts;...}..
    │ │ │ +00046f70: 0965 6c73 650a 0909 7b0a 0909 092f 2f20  .else...{....// 
    │ │ │ +00046f80: 6375 7272 656e 7420 646f 776e 6c6f 6164  current download
    │ │ │ +00046f90: 2072 6174 6520 696e 2062 7974 6573 2070   rate in bytes p
    │ │ │ +00046fa0: 6572 2073 6563 6f6e 6473 0a09 0909 7261  er seconds....ra
    │ │ │ +00046fb0: 7465 203d 206d 5f73 7461 7469 7374 6963  te = m_statistic
    │ │ │ +00046fc0: 732e 7472 616e 7366 6572 5f72 6174 6528  s.transfer_rate(
    │ │ │ +00046fd0: 7374 6174 3a3a 646f 776e 6c6f 6164 5f70  stat::download_p
    │ │ │ +00046fe0: 6179 6c6f 6164 293b 0a09 097d 0a0a 0909  ayload);...}....
    │ │ │ +00046ff0: 2f2f 2061 766f 6964 2064 6976 6973 696f  // avoid divisio
    │ │ │ +00047000: 6e20 6279 207a 6572 6f0a 0909 6966 2028  n by zero...if (
    │ │ │ +00047010: 7261 7465 2026 6c74 3b20 3530 2920 7261  rate < 50) ra
    │ │ │ +00047020: 7465 203d 2035 303b 0a0a 0909 2f2f 2061  te = 50;....// a
    │ │ │ +00047030: 7665 7261 6765 206f 6620 6375 7272 656e  verage of curren
    │ │ │ +00047040: 7420 7261 7465 2061 6e64 2070 6561 6b0a  t rate and peak.
    │ │ │ +00047050: 2f2f 0909 7261 7465 203d 2028 7261 7465  //..rate = (rate
    │ │ │ +00047060: 202b 206d 5f64 6f77 6e6c 6f61 645f 7261   + m_download_ra
    │ │ │ +00047070: 7465 5f70 6561 6b29 202f 2032 3b0a 0a09  te_peak) / 2;...
    │ │ │ +00047080: 0972 6574 7572 6e20 6d69 6c6c 6973 6563  .return millisec
    │ │ │ +00047090: 6f6e 6473 2828 7374 643a 3a69 6e74 3634  onds((std::int64
    │ │ │ +000470a0: 5f74 286d 5f6f 7574 7374 616e 6469 6e67  _t(m_outstanding
    │ │ │ +000470b0: 5f62 7974 6573 2920 2b20 6578 7472 615f  _bytes) + extra_
    │ │ │ +000470c0: 6279 7465 730a 0909 092b 206d 5f71 7565  bytes....+ m_que
    │ │ │ +000470d0: 7565 645f 7469 6d65 5f63 7269 7469 6361  ued_time_critica
    │ │ │ +000470e0: 6c20 2a20 742d 2667 743b 626c 6f63 6b5f  l * t->block_
    │ │ │ +000470f0: 7369 7a65 2829 202a 2031 3030 3029 202f  size() * 1000) /
    │ │ │ +00047100: 2072 6174 6529 3b0a 097d 0a0a 0976 6f69   rate);..}...voi
    │ │ │ +00047110: 6420 7065 6572 5f63 6f6e 6e65 6374 696f  d peer_connectio
    │ │ │ +00047120: 6e3a 3a61 6464 5f73 7461 7428 7374 643a  n::add_stat(std:
    │ │ │ +00047130: 3a69 6e74 3634 5f74 2063 6f6e 7374 2064  :int64_t const d
    │ │ │ +00047140: 6f77 6e6c 6f61 6465 642c 2073 7464 3a3a  ownloaded, std::
    │ │ │ +00047150: 696e 7436 345f 7420 636f 6e73 7420 7570  int64_t const up
    │ │ │ +00047160: 6c6f 6164 6564 290a 097b 0a09 0954 4f52  loaded)..{...TOR
    │ │ │ +00047170: 5245 4e54 5f41 5353 4552 5428 6973 5f73  RENT_ASSERT(is_s
    │ │ │ +00047180: 696e 676c 655f 7468 7265 6164 2829 293b  ingle_thread());
    │ │ │ +00047190: 0a09 096d 5f73 7461 7469 7374 6963 732e  ...m_statistics.
    │ │ │ +000471a0: 6164 645f 7374 6174 2864 6f77 6e6c 6f61  add_stat(downloa
    │ │ │ +000471b0: 6465 642c 2075 706c 6f61 6465 6429 3b0a  ded, uploaded);.
    │ │ │ +000471c0: 097d 0a0a 0973 6861 315f 6861 7368 2070  .}...sha1_hash p
    │ │ │ +000471d0: 6565 725f 636f 6e6e 6563 7469 6f6e 3a3a  eer_connection::
    │ │ │ +000471e0: 6173 736f 6369 6174 6564 5f69 6e66 6f5f  associated_info_
    │ │ │ +000471f0: 6861 7368 2829 2063 6f6e 7374 0a09 7b0a  hash() const..{.
    │ │ │ +00047200: 0909 7374 643a 3a73 6861 7265 645f 7074  ..std::shared_pt
    │ │ │ +00047210: 7226 6c74 3b74 6f72 7265 6e74 2667 743b  r<torrent>
    │ │ │ +00047220: 2074 203d 2061 7373 6f63 6961 7465 645f   t = associated_
    │ │ │ +00047230: 746f 7272 656e 7428 292e 6c6f 636b 2829  torrent().lock()
    │ │ │ +00047240: 3b0a 0909 544f 5252 454e 545f 4153 5345  ;...TORRENT_ASSE
    │ │ │ +00047250: 5254 2874 293b 0a09 0961 7574 6f20 636f  RT(t);...auto co
    │ │ │ +00047260: 6e73 7426 616d 703b 2069 6820 3d20 742d  nst& ih = t-
    │ │ │ +00047270: 2667 743b 696e 666f 5f68 6173 6828 293b  >info_hash();
    │ │ │ +00047280: 0a09 092f 2f20 6120 7065 6572 2773 2070  ...// a peer's p
    │ │ │ +00047290: 726f 746f 636f 6c5f 7632 2066 6c61 6720  rotocol_v2 flag 
    │ │ │ +000472a0: 6d61 7920 6265 2073 6574 2073 7065 6375  may be set specu
    │ │ │ +000472b0: 6c61 7469 7665 6c79 2077 6869 6c65 206d  latively while m
    │ │ │ +000472c0: 6574 6164 6174 610a 0909 2f2f 2069 7320  etadata...// is 
    │ │ │ +000472d0: 6e6f 7420 7965 7420 7661 6c69 6420 2873  not yet valid (s
    │ │ │ +000472e0: 6565 2074 6f72 7265 6e74 3a3a 7365 745f  ee torrent::set_
    │ │ │ +000472f0: 6d65 7461 6461 7461 2829 292c 2062 7574  metadata()), but
    │ │ │ +00047300: 206f 6e63 6520 6d65 7461 6461 7461 0a3c   once metadata.<
    │ │ │ +00047310: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ +00047320: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ +00047330: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ +00047340: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ +00047350: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../src
    │ │ │ +00047380: 2f70 6565 725f 636f 6e6e 6563 7469 6f6e  /peer_connection
    │ │ │ +00047390: 2e63 7070 3a33 3535 303c 2f61 3e3c 2f74  .cpp:3550sort the a
    │ │ │ +000473b0: 6c6c 6f77 6564 2066 6173 7420 7365 7420  llowed fast set 
    │ │ │ +000473c0: 696e 2070 7269 6f72 6974 7920 6f72 6465  in priority orde
    │ │ │ +000473d0: 723c 2f74 643e 3c2f 7472 3e3c 7472 2069  r

    s │ │ │ +00047420: 6f72 7420 7468 6520 616c 6c6f 7765 6420 ort the allowed │ │ │ +00047430: 6661 7374 2073 6574 2069 6e20 7072 696f fast set in prio │ │ │ +00047440: 7269 7479 206f 7264 6572 3c2f 6832 3e3c rity order

    < │ │ │ +00047450: 6834 3e2e 2e2f 7372 632f 7065 6572 5f63 h4>../src/peer_c │ │ │ +00047460: 6f6e 6e65 6374 696f 6e2e 6370 703a 3335 onnection.cpp:35 │ │ │ +00047470: 3530 3c2f 6834 3e3c 7072 6520 7374 796c 50

    ...// if the pe
    │ │ │ +000474c0: 6572 2068 6173 2074 6865 2070 6965 6365  er has the piece
    │ │ │ +000474d0: 2061 6e64 2077 6520 7761 6e74 0a09 092f   and we want.../
    │ │ │ +000474e0: 2f20 746f 2064 6f77 6e6c 6f61 6420 6974  / to download it
    │ │ │ +000474f0: 2c20 7265 7175 6573 7420 6974 0a09 0969  , request it...i
    │ │ │ +00047500: 6620 2869 6e64 6578 2026 6c74 3b20 6d5f  f (index < m_
    │ │ │ +00047510: 6861 7665 5f70 6965 6365 2e65 6e64 5f69  have_piece.end_i
    │ │ │ +00047520: 6e64 6578 2829 0a09 0909 2661 6d70 3b26  ndex()....&&
    │ │ │ +00047530: 616d 703b 206d 5f68 6176 655f 7069 6563  amp; m_have_piec
    │ │ │ +00047540: 655b 696e 6465 785d 0a09 0909 2661 6d70  e[index]....&
    │ │ │ +00047550: 3b26 616d 703b 2021 742d 2667 743b 6861  ;& !t->ha
    │ │ │ +00047560: 7665 5f70 6965 6365 2869 6e64 6578 290a  ve_piece(index).
    │ │ │ +00047570: 0909 0926 616d 703b 2661 6d70 3b20 742d  ...&& t-
    │ │ │ +00047580: 2667 743b 7661 6c69 645f 6d65 7461 6461  >valid_metada
    │ │ │ +00047590: 7461 2829 0a09 0909 2661 6d70 3b26 616d  ta()....&&am
    │ │ │ +000475a0: 703b 2074 2d26 6774 3b68 6173 5f70 6963  p; t->has_pic
    │ │ │ +000475b0: 6b65 7228 290a 0909 0926 616d 703b 2661  ker()....&&a
    │ │ │ +000475c0: 6d70 3b20 742d 2667 743b 7069 636b 6572  mp; t->picker
    │ │ │ +000475d0: 2829 2e70 6965 6365 5f70 7269 6f72 6974  ().piece_priorit
    │ │ │ +000475e0: 7928 696e 6465 7829 2026 6774 3b20 646f  y(index) > do
    │ │ │ +000475f0: 6e74 5f64 6f77 6e6c 6f61 6429 0a09 097b  nt_download)...{
    │ │ │ +00047600: 0a09 0909 742d 2667 743b 7065 6572 5f69  ....t->peer_i
    │ │ │ +00047610: 735f 696e 7465 7265 7374 696e 6728 2a74  s_interesting(*t
    │ │ │ +00047620: 6869 7329 3b0a 0909 7d0a 097d 0a0a 0973  his);...}..}...s
    │ │ │ +00047630: 7464 3a3a 7665 6374 6f72 266c 743b 7069  td::vector<pi
    │ │ │ +00047640: 6563 655f 696e 6465 785f 7426 6774 3b20  ece_index_t> 
    │ │ │ +00047650: 636f 6e73 7426 616d 703b 2070 6565 725f  const& peer_
    │ │ │ +00047660: 636f 6e6e 6563 7469 6f6e 3a3a 616c 6c6f  connection::allo
    │ │ │ +00047670: 7765 645f 6661 7374 2829 0a09 7b0a 0909  wed_fast()..{...
    │ │ │ +00047680: 544f 5252 454e 545f 4153 5345 5254 2869  TORRENT_ASSERT(i
    │ │ │ +00047690: 735f 7369 6e67 6c65 5f74 6872 6561 6428  s_single_thread(
    │ │ │ +000476a0: 2929 3b0a 0909 7374 643a 3a73 6861 7265  ));...std::share
    │ │ │ +000476b0: 645f 7074 7226 6c74 3b74 6f72 7265 6e74  d_ptr<torrent
    │ │ │ +000476c0: 2667 743b 2074 203d 206d 5f74 6f72 7265  > t = m_torre
    │ │ │ +000476d0: 6e74 2e6c 6f63 6b28 293b 0a09 0954 4f52  nt.lock();...TOR
    │ │ │ +000476e0: 5245 4e54 5f41 5353 4552 5428 7429 3b0a  RENT_ASSERT(t);.
    │ │ │ +000476f0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +00047720: 0972 6574 7572 6e20 6d5f 616c 6c6f 7765 .return m_allowe │ │ │ +00047730: 645f 6661 7374 3b0a 3c2f 6469 763e 097d d_fast;.
    .} │ │ │ +00047740: 0a0a 0962 6f6f 6c20 7065 6572 5f63 6f6e ...bool peer_con │ │ │ +00047750: 6e65 6374 696f 6e3a 3a63 616e 5f72 6571 nection::can_req │ │ │ +00047760: 7565 7374 5f74 696d 655f 6372 6974 6963 uest_time_critic │ │ │ +00047770: 616c 2829 2063 6f6e 7374 0a09 7b0a 0909 al() const..{... │ │ │ +00047780: 544f 5252 454e 545f 4153 5345 5254 2869 TORRENT_ASSERT(i │ │ │ +00047790: 735f 7369 6e67 6c65 5f74 6872 6561 6428 s_single_thread( │ │ │ +000477a0: 2929 3b0a 0909 6966 2028 6861 735f 7065 ));...if (has_pe │ │ │ +000477b0: 6572 5f63 686f 6b65 6428 2920 7c7c 2021 er_choked() || ! │ │ │ +000477c0: 6973 5f69 6e74 6572 6573 7469 6e67 2829 is_interesting() │ │ │ +000477d0: 2920 7265 7475 726e 2066 616c 7365 3b0a ) return false;. │ │ │ +000477e0: 0909 6966 2028 696e 7428 6d5f 646f 776e ..if (int(m_down │ │ │ +000477f0: 6c6f 6164 5f71 7565 7565 2e73 697a 6528 load_queue.size( │ │ │ +00047800: 2929 202b 2069 6e74 286d 5f72 6571 7565 )) + int(m_reque │ │ │ +00047810: 7374 5f71 7565 7565 2e73 697a 6528 2929 st_queue.size()) │ │ │ +00047820: 0a09 0909 2667 743b 206d 5f64 6573 6972 ....> m_desir │ │ │ +00047830: 6564 5f71 7565 7565 5f73 697a 6520 2a20 ed_queue_size * │ │ │ +00047840: 3229 2072 6574 7572 6e20 6661 6c73 653b 2) return false; │ │ │ +00047850: 0a09 0969 6620 286f 6e5f 7061 726f 6c65 ...if (on_parole │ │ │ +00047860: 2829 2920 7265 7475 726e 2066 616c 7365 ()) return false │ │ │ +00047870: 3b0a 0909 6966 2028 6d5f 6469 7363 6f6e ;...if (m_discon │ │ │ +00047880: 6e65 6374 696e 6729 2072 6574 7572 6e20 necting) return │ │ │ +00047890: 6661 6c73 653b 0a09 0973 7464 3a3a 7368 false;...std::sh │ │ │ +000478a0: 6172 6564 5f70 7472 266c 743b 746f 7272 ared_ptr<torr │ │ │ +000478b0: 656e 7426 6774 3b20 7420 3d20 6d5f 746f ent> t = m_to │ │ │ +000478c0: 7272 656e 742e 6c6f 636b 2829 3b0a 0909 rrent.lock();... │ │ │ +000478d0: 544f 5252 454e 545f 4153 5345 5254 2874 TORRENT_ASSERT(t │ │ │ +000478e0: 293b 0a09 0969 6620 2874 2d26 6774 3b75 );...if (t->u │ │ │ +000478f0: 706c 6f61 645f 6d6f 6465 2829 2920 7265 pload_mode()) re │ │ │ +00047900: 7475 726e 2066 616c 7365 3b0a 0a09 092f turn false;..../ │ │ │ +00047910: 2f20 6967 6e6f 7265 2073 6e75 6262 6564 / ignore snubbed │ │ │ +00047920: 2070 6565 7273 2c20 7369 6e63 6520 7468 peers, since th │ │ │ +00047930: 6579 2772 6520 6e6f 7420 6c69 6b65 6c79 ey're not likely │ │ │ +00047940: 2074 6f20 7265 7475 726e 2070 6965 6365 to return piece │ │ │ +00047950: 7320 696e 2061 0a09 092f 2f20 7469 6d65 s in a...// time │ │ │ +00047960: 6c79 206d 616e 6e65 7220 616e 7977 6179 ly manner anyway │ │ │ +00047970: 0a09 0969 6620 286d 5f73 6e75 6262 6564 ...if (m_snubbed │ │ │ +00047980: 2920 7265 7475 726e 2066 616c 7365 3b0a ) return false;. │ │ │ +00047990: 0909 7265 7475 726e 2074 7275 653b 0a09 ..return true;.. │ │ │ +000479a0: 7d0a 0a09 626f 6f6c 2070 6565 725f 636f }...bool peer_co │ │ │ +000479b0: 6e6e 6563 7469 6f6e 3a3a 6d61 6b65 5f74 nnection::make_t │ │ │ +000479c0: 696d 655f 6372 6974 6963 616c 2870 6965 ime_critical(pie │ │ │ +000479d0: 6365 5f62 6c6f 636b 2063 6f6e 7374 2661 ce_block const&a │ │ │ +000479e0: 6d70 3b20 626c 6f63 6b29 0a09 7b0a 0909 mp; block)..{... │ │ │ +000479f0: 544f 5252 454e 545f 4153 5345 5254 2869 TORRENT_ASSERT(i │ │ │ +00047a00: 735f 7369 6e67 6c65 5f74 6872 6561 6428 s_single_thread( │ │ │ +00047a10: 2929 3b0a 0909 6175 746f 2063 6f6e 7374 ));...auto const │ │ │ +00047a20: 2072 6974 203d 2073 7464 3a3a 6669 6e64 rit = std::find │ │ │ +00047a30: 5f69 6628 6d5f 7265 7175 6573 745f 7175 _if(m_request_qu │ │ │ +00047a40: 6575 652e 6265 6769 6e28 290a 0909 092c eue.begin()...., │ │ │ +00047a50: 206d 5f72 6571 7565 7374 5f71 7565 7565 m_request_queue │ │ │ +00047a60: 2e65 6e64 2829 2c20 6175 783a 3a68 6173 .end(), aux::has │ │ │ +00047a70: 5f62 6c6f 636b 2862 6c6f 636b 2929 3b0a _block(block));. │ │ │ +00047a80: 0909 6966 2028 7269 7420 3d3d 206d 5f72 ..if (rit == m_r │ │ │ +00047a90: 6571 7565 7374 5f71 7565 7565 2e65 6e64 equest_queue.end │ │ │ +00047aa0: 2829 2920 7265 7475 726e 2066 616c 7365 ()) return false │ │ │ +00047ab0: 3b0a 2369 6620 544f 5252 454e 545f 5553 ;.#if TORRENT_US │ │ │ +00047ac0: 455f 4153 5345 5254 530a 0909 7374 643a E_ASSERTS...std: │ │ │ +00047ad0: 3a73 6861 7265 645f 7074 7226 6c74 3b74 :shared_ptr<t │ │ │ +00047ae0: 6f72 7265 6e74 2667 743b 2074 203d 206d orrent> t = m │ │ │ +00047af0: 5f74 6f72 7265 6e74 2e6c 6f63 6b28 293b _torrent.lock(); │ │ │ +00047b00: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00047b10: 5428 7429 3b0a 0909 544f 5252 454e 545f T(t);...TORRENT_ │ │ │ +00047b20: 4153 5345 5254 2874 2d26 6774 3b68 6173 ASSERT(t->has │ │ │ +00047b30: 5f70 6963 6b65 7228 2929 3b0a 3c2f 7072 _picker());.rel │ │ │ +00047b70: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/to │ │ │ +00047bb0: 7272 656e 742e 6370 703a 3230 3337 3c2f rrent.cpp:2037this │ │ │ +00047bd0: 636f 756c 6420 6265 206f 7074 696d 697a could be optimiz │ │ │ +00047be0: 6564 2062 7920 6c6f 6f6b 696e 6720 7570 ed by looking up │ │ │ +00047bf0: 2077 6869 6368 2066 696c 6573 2061 7265 which files are │ │ │ +00047c00: 2063 6f6d 706c 6574 6520 616e 6420 6a75 complete and ju │ │ │ +00047c10: 7374 206c 6f6f 6b20 6174 2074 686f 7365 st look at those │ │ │ +00047c20: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    th │ │ │ +00047c70: 6973 2063 6f75 6c64 2062 6520 6f70 7469 is could be opti │ │ │ +00047c80: 6d69 7a65 6420 6279 206c 6f6f 6b69 6e67 mized by looking │ │ │ +00047c90: 2075 7020 7768 6963 6820 6669 6c65 7320 up which files │ │ │ +00047ca0: 6172 650a 636f 6d70 6c65 7465 2061 6e64 are.complete and │ │ │ +00047cb0: 206a 7573 7420 6c6f 6f6b 2061 7420 7468 just look at th │ │ │ +00047cc0: 6f73 653c 2f68 323e 3c68 343e 2e2e 2f73 ose

    ../s │ │ │ +00047cd0: 7263 2f74 6f72 7265 6e74 2e63 7070 3a32 rc/torrent.cpp:2 │ │ │ +00047ce0: 3033 373c 2f68 343e 3c70 7265 2073 7479 037

    //....TORRENT_
    │ │ │ +00047d30: 4153 5345 5254 2870 6963 6b65 7228 292e  ASSERT(picker().
    │ │ │ +00047d40: 6861 7665 5f70 6965 6365 2869 2929 3b0a  have_piece(i));.
    │ │ │ +00047d50: 0909 0909 7765 5f68 6176 6528 6929 3b0a  ....we_have(i);.
    │ │ │ +00047d60: 0909 097d 0a09 097d 0a0a 0909 7365 745f  ...}...}....set_
    │ │ │ +00047d70: 7374 6174 6528 746f 7272 656e 745f 7374  state(torrent_st
    │ │ │ +00047d80: 6174 7573 3a3a 6368 6563 6b69 6e67 5f72  atus::checking_r
    │ │ │ +00047d90: 6573 756d 655f 6461 7461 293b 0a0a 0909  esume_data);....
    │ │ │ +00047da0: 6175 783a 3a76 6563 746f 7226 6c74 3b73  aux::vector<s
    │ │ │ +00047db0: 7464 3a3a 7374 7269 6e67 2c20 6669 6c65  td::string, file
    │ │ │ +00047dc0: 5f69 6e64 6578 5f74 2667 743b 206c 696e  _index_t> lin
    │ │ │ +00047dd0: 6b73 3b0a 2369 666e 6465 6620 544f 5252  ks;.#ifndef TORR
    │ │ │ +00047de0: 454e 545f 4449 5341 424c 455f 4d55 5441  ENT_DISABLE_MUTA
    │ │ │ +00047df0: 424c 455f 544f 5252 454e 5453 0a09 0969  BLE_TORRENTS...i
    │ │ │ +00047e00: 6620 2821 6d5f 746f 7272 656e 745f 6669  f (!m_torrent_fi
    │ │ │ +00047e10: 6c65 2d26 6774 3b73 696d 696c 6172 5f74  le->similar_t
    │ │ │ +00047e20: 6f72 7265 6e74 7328 292e 656d 7074 7928  orrents().empty(
    │ │ │ +00047e30: 290a 0909 097c 7c20 216d 5f74 6f72 7265  )....|| !m_torre
    │ │ │ +00047e40: 6e74 5f66 696c 652d 2667 743b 636f 6c6c  nt_file->coll
    │ │ │ +00047e50: 6563 7469 6f6e 7328 292e 656d 7074 7928  ections().empty(
    │ │ │ +00047e60: 2929 0a09 097b 0a09 0909 7265 736f 6c76  ))...{....resolv
    │ │ │ +00047e70: 655f 6c69 6e6b 7320 7265 7328 6d5f 746f  e_links res(m_to
    │ │ │ +00047e80: 7272 656e 745f 6669 6c65 293b 0a0a 0909  rrent_file);....
    │ │ │ +00047e90: 0966 6f72 2028 6175 746f 2063 6f6e 7374  .for (auto const
    │ │ │ +00047ea0: 2661 6d70 3b20 6968 203a 206d 5f74 6f72  & ih : m_tor
    │ │ │ +00047eb0: 7265 6e74 5f66 696c 652d 2667 743b 7369  rent_file->si
    │ │ │ +00047ec0: 6d69 6c61 725f 746f 7272 656e 7473 2829  milar_torrents()
    │ │ │ +00047ed0: 290a 0909 097b 0a09 0909 0973 7464 3a3a  )....{.....std::
    │ │ │ +00047ee0: 7368 6172 6564 5f70 7472 266c 743b 746f  shared_ptr<to
    │ │ │ +00047ef0: 7272 656e 7426 6774 3b20 7420 3d20 6d5f  rrent> t = m_
    │ │ │ +00047f00: 7365 732e 6669 6e64 5f74 6f72 7265 6e74  ses.find_torrent
    │ │ │ +00047f10: 2869 6e66 6f5f 6861 7368 5f74 2869 6829  (info_hash_t(ih)
    │ │ │ +00047f20: 292e 6c6f 636b 2829 3b0a 0909 0909 6966  ).lock();.....if
    │ │ │ +00047f30: 2028 2174 2920 636f 6e74 696e 7565 3b0a   (!t) continue;.
    │ │ │ +00047f40: 0a09 0909 092f 2f20 4f6e 6c79 2061 7474  .....// Only att
    │ │ │ +00047f50: 656d 7074 2074 6f20 7265 7573 6520 6669  empt to reuse fi
    │ │ │ +00047f60: 6c65 7320 6672 6f6d 2074 6f72 7265 6e74  les from torrent
    │ │ │ +00047f70: 7320 7468 6174 2061 7265 2073 6565 6469  s that are seedi
    │ │ │ +00047f80: 6e67 2e0a 3c64 6976 2073 7479 6c65 3d22  ng..
    ....if (!t-> │ │ │ +00047fc0: 3b69 735f 7365 6564 2829 2920 636f 6e74 ;is_seed()) cont │ │ │ +00047fd0: 696e 7565 3b0a 3c2f 6469 763e 0a09 0909 inue;.
    .... │ │ │ +00047fe0: 0972 6573 2e6d 6174 6368 2874 2d26 6774 .res.match(t-> │ │ │ +00047ff0: 3b67 6574 5f74 6f72 7265 6e74 5f66 696c ;get_torrent_fil │ │ │ +00048000: 6528 292c 2074 2d26 6774 3b73 6176 655f e(), t->save_ │ │ │ +00048010: 7061 7468 2829 293b 0a09 0909 7d0a 0909 path());....}... │ │ │ +00048020: 0966 6f72 2028 6175 746f 2063 6f6e 7374 .for (auto const │ │ │ +00048030: 2661 6d70 3b20 6320 3a20 6d5f 746f 7272 & c : m_torr │ │ │ +00048040: 656e 745f 6669 6c65 2d26 6774 3b63 6f6c ent_file->col │ │ │ +00048050: 6c65 6374 696f 6e73 2829 290a 0909 097b lections())....{ │ │ │ +00048060: 0a09 0909 0973 7464 3a3a 7665 6374 6f72 .....std::vector │ │ │ +00048070: 266c 743b 7374 643a 3a73 6861 7265 645f <std::shared_ │ │ │ +00048080: 7074 7226 6c74 3b74 6f72 7265 6e74 2667 ptr<torrent&g │ │ │ +00048090: 743b 2667 743b 2074 7320 3d20 6d5f 7365 t;> ts = m_se │ │ │ +000480a0: 732e 6669 6e64 5f63 6f6c 6c65 6374 696f s.find_collectio │ │ │ +000480b0: 6e28 6329 3b0a 0a09 0909 0966 6f72 2028 n(c);......for ( │ │ │ +000480c0: 6175 746f 2063 6f6e 7374 2661 6d70 3b20 auto const& │ │ │ +000480d0: 7420 3a20 7473 290a 0909 0909 7b0a 0909 t : ts).....{... │ │ │ +000480e0: 0909 092f 2f20 4f6e 6c79 2061 7474 656d ...// Only attem │ │ │ +000480f0: 7074 2074 6f20 7265 7573 6520 6669 6c65 pt to reuse file │ │ │ +00048100: 7320 6672 6f6d 2074 6f72 7265 6e74 7320 s from torrents │ │ │ +00048110: 7468 6174 2061 7265 2073 6565 6469 6e67 that are seeding │ │ │ +00048120: 2e0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ..
    < │ │ │ +00048150: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00048160: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0
    ../ │ │ │ +00048190: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ +000481a0: 3230 3530 3c2f 613e 3c2f 7464 3e3c 7464 2050this could be o │ │ │ +000481c0: 7074 696d 697a 6564 2062 7920 6c6f 6f6b ptimized by look │ │ │ +000481d0: 696e 6720 7570 2077 6869 6368 2066 696c ing up which fil │ │ │ +000481e0: 6573 2061 7265 2063 6f6d 706c 6574 6520 es are complete │ │ │ +000481f0: 616e 6420 6a75 7374 206c 6f6f 6b20 6174 and just look at │ │ │ +00048200: 2074 686f 7365 3c2f 7464 3e3c 2f74 723e those │ │ │ +00048210: 3c74 7220 6964 3d22 3137 3322 2073 7479 │ │ │ +00048240: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00048250: 3c68 323e 7468 6973 2063 6f75 6c64 2062

    this could b │ │ │ +00048260: 6520 6f70 7469 6d69 7a65 6420 6279 206c e optimized by l │ │ │ +00048270: 6f6f 6b69 6e67 2075 7020 7768 6963 6820 ooking up which │ │ │ +00048280: 6669 6c65 7320 6172 650a 636f 6d70 6c65 files are.comple │ │ │ +00048290: 7465 2061 6e64 206a 7573 7420 6c6f 6f6b te and just look │ │ │ +000482a0: 2061 7420 7468 6f73 653c 2f68 323e 3c68 at those

    ../src/torrent │ │ │ +000482c0: 2e63 7070 3a32 3035 303c 2f68 343e 3c70 .cpp:2050

    ..{....r │ │ │ +00048310: 6573 6f6c 7665 5f6c 696e 6b73 2072 6573 esolve_links res │ │ │ +00048320: 286d 5f74 6f72 7265 6e74 5f66 696c 6529 (m_torrent_file) │ │ │ +00048330: 3b0a 0a09 0909 666f 7220 2861 7574 6f20 ;.....for (auto │ │ │ +00048340: 636f 6e73 7426 616d 703b 2069 6820 3a20 const& ih : │ │ │ +00048350: 6d5f 746f 7272 656e 745f 6669 6c65 2d26 m_torrent_file-& │ │ │ +00048360: 6774 3b73 696d 696c 6172 5f74 6f72 7265 gt;similar_torre │ │ │ +00048370: 6e74 7328 2929 0a09 0909 7b0a 0909 0909 nts())....{..... │ │ │ +00048380: 7374 643a 3a73 6861 7265 645f 7074 7226 std::shared_ptr& │ │ │ +00048390: 6c74 3b74 6f72 7265 6e74 2667 743b 2074 lt;torrent> t │ │ │ +000483a0: 203d 206d 5f73 6573 2e66 696e 645f 746f = m_ses.find_to │ │ │ +000483b0: 7272 656e 7428 696e 666f 5f68 6173 685f rrent(info_hash_ │ │ │ +000483c0: 7428 6968 2929 2e6c 6f63 6b28 293b 0a09 t(ih)).lock();.. │ │ │ +000483d0: 0909 0969 6620 2821 7429 2063 6f6e 7469 ...if (!t) conti │ │ │ +000483e0: 6e75 653b 0a0a 0909 0909 2f2f 204f 6e6c nue;......// Onl │ │ │ +000483f0: 7920 6174 7465 6d70 7420 746f 2072 6575 y attempt to reu │ │ │ +00048400: 7365 2066 696c 6573 2066 726f 6d20 746f se files from to │ │ │ +00048410: 7272 656e 7473 2074 6861 7420 6172 6520 rrents that are │ │ │ +00048420: 7365 6564 696e 672e 0a09 0909 0969 6620 seeding......if │ │ │ +00048430: 2821 742d 2667 743b 6973 5f73 6565 6428 (!t->is_seed( │ │ │ +00048440: 2929 2063 6f6e 7469 6e75 653b 0a0a 0909 )) continue;.... │ │ │ +00048450: 0909 7265 732e 6d61 7463 6828 742d 2667 ..res.match(t-&g │ │ │ +00048460: 743b 6765 745f 746f 7272 656e 745f 6669 t;get_torrent_fi │ │ │ +00048470: 6c65 2829 2c20 742d 2667 743b 7361 7665 le(), t->save │ │ │ +00048480: 5f70 6174 6828 2929 3b0a 0909 097d 0a09 _path());....}.. │ │ │ +00048490: 0909 666f 7220 2861 7574 6f20 636f 6e73 ..for (auto cons │ │ │ +000484a0: 7426 616d 703b 2063 203a 206d 5f74 6f72 t& c : m_tor │ │ │ +000484b0: 7265 6e74 5f66 696c 652d 2667 743b 636f rent_file->co │ │ │ +000484c0: 6c6c 6563 7469 6f6e 7328 2929 0a09 0909 llections()).... │ │ │ +000484d0: 7b0a 0909 0909 7374 643a 3a76 6563 746f {.....std::vecto │ │ │ +000484e0: 7226 6c74 3b73 7464 3a3a 7368 6172 6564 r<std::shared │ │ │ +000484f0: 5f70 7472 266c 743b 746f 7272 656e 7426 _ptr<torrent& │ │ │ +00048500: 6774 3b26 6774 3b20 7473 203d 206d 5f73 gt;> ts = m_s │ │ │ +00048510: 6573 2e66 696e 645f 636f 6c6c 6563 7469 es.find_collecti │ │ │ +00048520: 6f6e 2863 293b 0a0a 0909 0909 666f 7220 on(c);......for │ │ │ +00048530: 2861 7574 6f20 636f 6e73 7426 616d 703b (auto const& │ │ │ +00048540: 2074 203a 2074 7329 0a09 0909 097b 0a09 t : ts).....{.. │ │ │ +00048550: 0909 0909 2f2f 204f 6e6c 7920 6174 7465 ....// Only atte │ │ │ +00048560: 6d70 7420 746f 2072 6575 7365 2066 696c mpt to reuse fil │ │ │ +00048570: 6573 2066 726f 6d20 746f 7272 656e 7473 es from torrents │ │ │ +00048580: 2074 6861 7420 6172 6520 7365 6564 696e that are seedin │ │ │ +00048590: 672e 0a3c 6469 7620 7374 796c 653d 2262 g..

    .....if (!t-> │ │ │ +000485d0: 3b69 735f 7365 6564 2829 2920 636f 6e74 ;is_seed()) cont │ │ │ +000485e0: 696e 7565 3b0a 3c2f 6469 763e 0a09 0909 inue;.
    .... │ │ │ +000485f0: 0909 7265 732e 6d61 7463 6828 742d 2667 ..res.match(t-&g │ │ │ +00048600: 743b 6765 745f 746f 7272 656e 745f 6669 t;get_torrent_fi │ │ │ +00048610: 6c65 2829 2c20 742d 2667 743b 7361 7665 le(), t->save │ │ │ +00048620: 5f70 6174 6828 2929 3b0a 0909 0909 7d0a _path());.....}. │ │ │ +00048630: 0909 097d 0a0a 0909 0973 7464 3a3a 7665 ...}.....std::ve │ │ │ +00048640: 6374 6f72 266c 743b 7265 736f 6c76 655f ctor<resolve_ │ │ │ +00048650: 6c69 6e6b 733a 3a6c 696e 6b5f 7426 6774 links::link_t> │ │ │ +00048660: 3b20 636f 6e73 7426 616d 703b 206c 203d ; const& l = │ │ │ +00048670: 2072 6573 2e67 6574 5f6c 696e 6b73 2829 res.get_links() │ │ │ +00048680: 3b0a 0909 0969 6620 2821 6c2e 656d 7074 ;....if (!l.empt │ │ │ +00048690: 7928 2929 0a09 0909 7b0a 0909 0909 6c69 y())....{.....li │ │ │ +000486a0: 6e6b 732e 7265 7369 7a65 286d 5f74 6f72 nks.resize(m_tor │ │ │ +000486b0: 7265 6e74 5f66 696c 652d 2667 743b 6669 rent_file->fi │ │ │ +000486c0: 6c65 7328 292e 6e75 6d5f 6669 6c65 7328 les().num_files( │ │ │ +000486d0: 2929 3b0a 0909 0909 666f 7220 2861 7574 ));.....for (aut │ │ │ +000486e0: 6f20 636f 6e73 7426 616d 703b 2069 203a o const& i : │ │ │ +000486f0: 206c 290a 0909 0909 7b0a 0909 0909 0969 l).....{......i │ │ │ +00048700: 6620 2821 692e 7469 2920 636f 6e74 696e f (!i.ti) contin │ │ │ +00048710: 7565 3b0a 0909 0909 096c 696e 6b73 5b69 ue;......links[i │ │ │ +00048720: 2e66 696c 655f 6964 785d 203d 2063 6f6d .file_idx] = com │ │ │ +00048730: 6269 6e65 5f70 6174 6828 692e 7361 7665 bine_path(i.save │ │ │ +00048740: 5f70 6174 680a 0909 0909 0909 2c20 692e _path......., i. │ │ │ +00048750: 7469 2d26 6774 3b66 696c 6573 2829 2e66 ti->files().f │ │ │ +00048760: 696c 655f 7061 7468 2869 2e66 696c 655f ile_path(i.file_ │ │ │ +00048770: 6964 7829 293b 0a09 0909 097d 0a09 0909 idx));.....}.... │ │ │ +00048780: 7d0a 0909 7d0a 2365 6e64 6966 202f 2f20 }...}.#endif // │ │ │ +00048790: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ +000487a0: 4d55 5441 424c 455f 544f 5252 454e 5453 MUTABLE_TORRENTS │ │ │ +000487b0: 0a0a 2369 6620 544f 5252 454e 545f 5553 ..#if TORRENT_US │ │ │ +000487c0: 455f 4153 5345 5254 530a 0909 544f 5252 E_ASSERTS...TORR │ │ │ +000487d0: 454e 545f 4153 5345 5254 286d 5f6f 7574 ENT_ASSERT(m_out │ │ │ +000487e0: 7374 616e 6469 6e67 5f63 6865 636b 5f66 standing_check_f │ │ │ +000487f0: 696c 6573 203d 3d20 6661 6c73 6529 3b0a iles == false);. │ │ │ +00048800: 0909 6d5f 6f75 7473 7461 6e64 696e 675f ..m_outstanding_ │ │ │ +00048810: 6368 6563 6b5f 6669 6c65 7320 3d20 7472 check_files = tr │ │ │ +00048820: 7565 3b0a 2365 6e64 6966 0a0a 0909 6966 ue;.#endif....if │ │ │ +00048830: 2028 216d 5f61 6464 5f74 6f72 7265 6e74 (!m_add_torrent │ │ │ +00048840: 5f70 6172 616d 7320 7c7c 2021 286d 5f61 _params || !(m_a │ │ │ +00048850: 6464 5f74 6f72 7265 6e74 5f70 6172 616d dd_torrent_param │ │ │ +00048860: 732d 2667 743b 666c 6167 7320 2661 6d70 s->flags & │ │ │ +00048870: 3b20 746f 7272 656e 745f 666c 6167 733a ; torrent_flags: │ │ │ +00048880: 3a6e 6f5f 7665 7269 6679 5f66 696c 6573 :no_verify_files │ │ │ +00048890: 2929 0a09 097b 0a09 0909 6d5f 7365 732e ))...{....m_ses. │ │ │ +000488a0: 6469 736b 5f74 6872 6561 6428 292e 6173 disk_thread().as │ │ │ +000488b0: 796e 635f 6368 6563 6b5f 6669 6c65 7328 ync_check_files( │ │ │ +000488c0: 0a09 0909 096d 5f73 746f 7261 6765 2c20 .....m_storage, │ │ │ +000488d0: 6d5f 6164 645f 746f 7272 656e 745f 7061 m_add_torrent_pa │ │ │ +000488e0: 7261 6d73 203f 206d 5f61 6464 5f74 6f72 rams ? m_add_tor │ │ │ +000488f0: 7265 6e74 5f70 6172 616d 732e 6765 7428 rent_params.get( │ │ │ +00048900: 2920 3a20 6e75 6c6c 7074 720a 0909 0909 ) : nullptr..... │ │ │ +00048910: 2c20 7374 643a 3a6d 6f76 6528 6c69 6e6b , std::move(link │ │ │ +00048920: 7329 2c20 5b73 656c 6620 3d20 7368 6172 s), [self = shar │ │ │ +00048930: 6564 5f66 726f 6d5f 7468 6973 2829 5d28 ed_from_this()]( │ │ │ +00048940: 7374 6174 7573 5f74 2073 742c 2073 746f status_t st, sto │ │ │ +00048950: 7261 6765 5f65 7272 6f72 2063 6f6e 7374 rage_error const │ │ │ +00048960: 2661 6d70 3b20 6572 726f 7229 0a09 0909 & error).... │ │ │ +00048970: 097b 2073 656c 662d 2667 743b 6f6e 5f72 .{ self->on_r │ │ │ +00048980: 6573 756d 655f 6461 7461 5f63 6865 636b esume_data_check │ │ │ +00048990: 6564 2873 742c 2065 7272 6f72 293b 207d ed(st, error); } │ │ │ +000489a0: 293b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f );.
    │ │ │ +000489d0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +000489e0: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +00048a10: 2f73 7263 2f74 6f72 7265 6e74 2e63 7070 /src/torrent.cpp │ │ │ +00048a20: 3a32 3831 383c 2f61 3e3c 2f74 643e 3c74 :2818this pattern i │ │ │ +00048a40: 7320 7265 7065 6174 6564 2069 6e20 6120 s repeated in a │ │ │ +00048a50: 6665 7720 706c 6163 6573 2e20 4661 6374 few places. Fact │ │ │ +00048a60: 6f72 2074 6869 7320 696e 746f 2061 2066 or this into a f │ │ │ +00048a70: 756e 6374 696f 6e20 616e 6420 6765 6e65 unction and gene │ │ │ +00048a80: 7261 6c69 7a65 2074 6865 2063 6f6e 6365 ralize the conce │ │ │ +00048a90: 7074 206f 6620 6120 746f 7272 656e 7420 pt of a torrent │ │ │ +00048aa0: 6861 7669 6e67 2061 2064 6564 6963 6174 having a dedicat │ │ │ +00048ab0: 6564 206c 6973 7465 6e20 706f 7274 3c2f ed listen port

    this │ │ │ +00048b10: 2070 6174 7465 726e 2069 7320 7265 7065 pattern is repe │ │ │ +00048b20: 6174 6564 2069 6e20 6120 6665 7720 706c ated in a few pl │ │ │ +00048b30: 6163 6573 2e20 4661 6374 6f72 2074 6869 aces. Factor thi │ │ │ +00048b40: 7320 696e 746f 0a61 2066 756e 6374 696f s into.a functio │ │ │ +00048b50: 6e20 616e 6420 6765 6e65 7261 6c69 7a65 n and generalize │ │ │ +00048b60: 2074 6865 2063 6f6e 6365 7074 206f 6620 the concept of │ │ │ +00048b70: 6120 746f 7272 656e 7420 6861 7669 6e67 a torrent having │ │ │ +00048b80: 2061 0a64 6564 6963 6174 6564 206c 6973 a.dedicated lis │ │ │ +00048b90: 7465 6e20 706f 7274 3c2f 6832 3e3c 6834 ten port

    ../src/torrent. │ │ │ +00048bb0: 6370 703a 3238 3138 3c2f 6834 3e3c 7072 cpp:2818

    ..// not │ │ │ +00048c00: 7265 6164 7920 666f 7220 7065 6572 732e ready for peers. │ │ │ +00048c10: 2045 7863 6570 742c 2069 6620 7765 2064 Except, if we d │ │ │ +00048c20: 6f6e 2774 2068 6176 6520 6d65 7461 6461 on't have metada │ │ │ +00048c30: 7461 2c0a 0909 2f2f 2077 6520 6e65 6564 ta,...// we need │ │ │ +00048c40: 2070 6565 7273 2074 6f20 646f 776e 6c6f peers to downlo │ │ │ +00048c50: 6164 2066 726f 6d0a 0909 6966 2028 216d ad from...if (!m │ │ │ +00048c60: 5f66 696c 6573 5f63 6865 636b 6564 2026 _files_checked & │ │ │ +00048c70: 616d 703b 2661 6d70 3b20 7661 6c69 645f amp;& valid_ │ │ │ +00048c80: 6d65 7461 6461 7461 2829 2920 7265 7475 metadata()) retu │ │ │ +00048c90: 726e 3b0a 0a09 0969 6620 2821 6d5f 616e rn;....if (!m_an │ │ │ +00048ca0: 6e6f 756e 6365 5f74 6f5f 6c73 6429 2072 nounce_to_lsd) r │ │ │ +00048cb0: 6574 7572 6e3b 0a0a 0909 2f2f 2070 7269 eturn;....// pri │ │ │ +00048cc0: 7661 7465 2074 6f72 7265 6e74 7320 6172 vate torrents ar │ │ │ +00048cd0: 6520 6e65 7665 7220 616e 6e6f 756e 6365 e never announce │ │ │ +00048ce0: 6420 6f6e 204c 5344 0a09 0969 6620 286d d on LSD...if (m │ │ │ +00048cf0: 5f74 6f72 7265 6e74 5f66 696c 652d 2667 _torrent_file-&g │ │ │ +00048d00: 743b 6973 5f76 616c 6964 2829 2026 616d t;is_valid() &am │ │ │ +00048d10: 703b 2661 6d70 3b20 6d5f 746f 7272 656e p;& m_torren │ │ │ +00048d20: 745f 6669 6c65 2d26 6774 3b70 7269 7628 t_file->priv( │ │ │ +00048d30: 2929 2072 6574 7572 6e3b 0a0a 2369 6620 )) return;..#if │ │ │ +00048d40: 544f 5252 454e 545f 5553 455f 4932 500a TORRENT_USE_I2P. │ │ │ +00048d50: 0909 2f2f 2069 3270 2074 6f72 7265 6e74 ..// i2p torrent │ │ │ +00048d60: 7320 6172 6520 616c 736f 206e 6576 6572 s are also never │ │ │ +00048d70: 2061 6e6e 6f75 6e63 6564 206f 6e20 4c53 announced on LS │ │ │ +00048d80: 440a 0909 2f2f 2075 6e6c 6573 7320 7765 D...// unless we │ │ │ +00048d90: 2061 6c6c 6f77 206d 6978 6564 2073 7761 allow mixed swa │ │ │ +00048da0: 726d 730a 0909 6966 2028 6973 5f69 3270 rms...if (is_i2p │ │ │ +00048db0: 2829 2026 616d 703b 2661 6d70 3b20 2173 () && !s │ │ │ +00048dc0: 6574 7469 6e67 7328 292e 6765 745f 626f ettings().get_bo │ │ │ +00048dd0: 6f6c 2873 6574 7469 6e67 735f 7061 636b ol(settings_pack │ │ │ +00048de0: 3a3a 616c 6c6f 775f 6932 705f 6d69 7865 ::allow_i2p_mixe │ │ │ +00048df0: 6429 290a 0909 0972 6574 7572 6e3b 0a23 d))....return;.# │ │ │ +00048e00: 656e 6469 660a 0a09 0969 6620 2869 735f endif....if (is_ │ │ │ +00048e10: 7061 7573 6564 2829 2920 7265 7475 726e paused()) return │ │ │ +00048e20: 3b0a 0a09 0969 6620 2821 6d5f 7365 732e ;....if (!m_ses. │ │ │ +00048e30: 6861 735f 6c73 6428 2929 2072 6574 7572 has_lsd()) retur │ │ │ +00048e40: 6e3b 0a0a 3c64 6976 2073 7479 6c65 3d22 n;..
    #ifdef TORRENT │ │ │ +00048e80: 5f53 534c 5f50 4545 5253 0a3c 2f64 6976 _SSL_PEERS.
    ..int port = is │ │ │ +00048ea0: 5f73 736c 5f74 6f72 7265 6e74 2829 203f _ssl_torrent() ? │ │ │ +00048eb0: 206d 5f73 6573 2e73 736c 5f6c 6973 7465 m_ses.ssl_liste │ │ │ +00048ec0: 6e5f 706f 7274 2829 203a 206d 5f73 6573 n_port() : m_ses │ │ │ +00048ed0: 2e6c 6973 7465 6e5f 706f 7274 2829 3b0a .listen_port();. │ │ │ +00048ee0: 2365 6c73 650a 0909 696e 7420 706f 7274 #else...int port │ │ │ +00048ef0: 203d 206d 5f73 6573 2e6c 6973 7465 6e5f = m_ses.listen_ │ │ │ +00048f00: 706f 7274 2829 3b0a 2365 6e64 6966 0a0a port();.#endif.. │ │ │ +00048f10: 0909 2f2f 2061 6e6e 6f75 6e63 6520 7769 ..// announce wi │ │ │ +00048f20: 7468 2074 6865 206c 6f63 616c 2064 6973 th the local dis │ │ │ +00048f30: 636f 7665 7279 2073 6572 7669 6365 0a09 covery service.. │ │ │ +00048f40: 096d 5f74 6f72 7265 6e74 5f66 696c 652d .m_torrent_file- │ │ │ +00048f50: 2667 743b 696e 666f 5f68 6173 6865 7328 >info_hashes( │ │ │ +00048f60: 292e 666f 725f 6561 6368 285b 2661 6d70 ).for_each([& │ │ │ +00048f70: 3b5d 2873 6861 315f 6861 7368 2063 6f6e ;](sha1_hash con │ │ │ +00048f80: 7374 2661 6d70 3b20 6968 2c20 7072 6f74 st& ih, prot │ │ │ +00048f90: 6f63 6f6c 5f76 6572 7369 6f6e 290a 0909 ocol_version)... │ │ │ +00048fa0: 7b0a 0909 096d 5f73 6573 2e61 6e6e 6f75 {....m_ses.annou │ │ │ +00048fb0: 6e63 655f 6c73 6428 6968 2c20 706f 7274 nce_lsd(ih, port │ │ │ +00048fc0: 293b 0a09 097d 293b 0a09 7d0a 0a23 6966 );...});..}..#if │ │ │ +00048fd0: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ +00048fe0: 4142 4c45 5f44 4854 0a0a 0976 6f69 6420 ABLE_DHT...void │ │ │ +00048ff0: 746f 7272 656e 743a 3a64 6874 5f61 6e6e torrent::dht_ann │ │ │ +00049000: 6f75 6e63 6528 290a 097b 0a09 0954 4f52 ounce()..{...TOR │ │ │ +00049010: 5245 4e54 5f41 5353 4552 5428 6973 5f73 RENT_ASSERT(is_s │ │ │ +00049020: 696e 676c 655f 7468 7265 6164 2829 293b ingle_thread()); │ │ │ +00049030: 0a09 0969 6620 2821 6d5f 7365 732e 6468 ...if (!m_ses.dh │ │ │ +00049040: 7428 2929 0a09 097b 0a23 6966 6e64 6566 t())...{.#ifndef │ │ │ +00049050: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ +00049060: 5f4c 4f47 4749 4e47 0a09 0909 6465 6275 _LOGGING....debu │ │ │ +00049070: 675f 6c6f 6728 2244 4854 3a20 6e6f 2064 g_log("DHT: no d │ │ │ +00049080: 6874 2069 6e69 7469 616c 697a 6564 2229 ht initialized") │ │ │ +00049090: 3b0a 2365 6e64 6966 0a09 0909 7265 7475 ;.#endif....retu │ │ │ +000490a0: 726e 3b0a 0909 7d0a 0909 6966 2028 2173 rn;...}...if (!s │ │ │ +000490b0: 686f 756c 645f 616e 6e6f 756e 6365 5f64 hould_announce_d │ │ │ +000490c0: 6874 2829 290a 0909 7b0a 2369 666e 6465 ht())...{.#ifnde │ │ │ +000490d0: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ +000490e0: 455f 4c4f 4747 494e 470a 0909 0969 6620 E_LOGGING....if │ │ │ +000490f0: 2873 686f 756c 645f 6c6f 6728 2929 0a09 (should_log()).. │ │ │ +00049100: 0909 7b0a 2369 6620 544f 5252 454e 545f ..{.#if TORRENT_ │ │ │ +00049110: 5553 455f 4932 500a 3c2f 7072 653e 3c2f USE_I2P.relevan │ │ │ +00049150: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/torren │ │ │ +00049190: 742e 6370 703a 3339 3932 3c2f 613e 3c2f t.cpp:3992add one p │ │ │ +000491b0: 6565 7220 7065 7220 4950 2074 6865 2068 eer per IP the h │ │ │ +000491c0: 6f73 746e 616d 6520 7265 736f 6c76 6573 ostname resolves │ │ │ +000491d0: 2074 6f3c 2f74 643e 3c2f 7472 3e3c 7472 to

    add one peer pe │ │ │ +00049230: 7220 4950 2074 6865 2068 6f73 746e 616d r IP the hostnam │ │ │ +00049240: 6520 7265 736f 6c76 6573 2074 6f3c 2f68 e resolves to

    ../src/tor │ │ │ +00049260: 7265 6e74 2e63 7070 3a33 3939 323c 2f68 rent.cpp:3992
    .cat
    │ │ │ +000492b0: 6368 2028 2e2e 2e29 207b 2068 616e 646c  ch (...) { handl
    │ │ │ +000492c0: 655f 6578 6365 7074 696f 6e28 293b 207d  e_exception(); }
    │ │ │ +000492d0: 0a23 656e 6469 660a 0a09 766f 6964 2074  .#endif...void t
    │ │ │ +000492e0: 6f72 7265 6e74 3a3a 6f6e 5f70 6565 725f  orrent::on_peer_
    │ │ │ +000492f0: 6e61 6d65 5f6c 6f6f 6b75 7028 6572 726f  name_lookup(erro
    │ │ │ +00049300: 725f 636f 6465 2063 6f6e 7374 2661 6d70  r_code const&
    │ │ │ +00049310: 3b20 650a 0909 2c20 7374 643a 3a76 6563  ; e..., std::vec
    │ │ │ +00049320: 746f 7226 6c74 3b61 6464 7265 7373 2667  tor<address&g
    │ │ │ +00049330: 743b 2063 6f6e 7374 2661 6d70 3b20 686f  t; const& ho
    │ │ │ +00049340: 7374 5f6c 6973 742c 2069 6e74 2063 6f6e  st_list, int con
    │ │ │ +00049350: 7374 2070 6f72 740a 0909 2c20 7072 6f74  st port..., prot
    │ │ │ +00049360: 6f63 6f6c 5f76 6572 7369 6f6e 2063 6f6e  ocol_version con
    │ │ │ +00049370: 7374 2076 2920 7472 790a 097b 0a09 0954  st v) try..{...T
    │ │ │ +00049380: 4f52 5245 4e54 5f41 5353 4552 5428 6973  ORRENT_ASSERT(is
    │ │ │ +00049390: 5f73 696e 676c 655f 7468 7265 6164 2829  _single_thread()
    │ │ │ +000493a0: 293b 0a0a 0909 494e 5641 5249 414e 545f  );....INVARIANT_
    │ │ │ +000493b0: 4348 4543 4b3b 0a0a 0909 434f 4d50 4c45  CHECK;....COMPLE
    │ │ │ +000493c0: 5445 5f41 5359 4e43 2822 746f 7272 656e  TE_ASYNC("torren
    │ │ │ +000493d0: 743a 3a6f 6e5f 7065 6572 5f6e 616d 655f  t::on_peer_name_
    │ │ │ +000493e0: 6c6f 6f6b 7570 2229 3b0a 0a23 6966 6e64  lookup");..#ifnd
    │ │ │ +000493f0: 6566 2054 4f52 5245 4e54 5f44 4953 4142  ef TORRENT_DISAB
    │ │ │ +00049400: 4c45 5f4c 4f47 4749 4e47 0a09 0969 6620  LE_LOGGING...if 
    │ │ │ +00049410: 2865 2026 616d 703b 2661 6d70 3b20 7368  (e && sh
    │ │ │ +00049420: 6f75 6c64 5f6c 6f67 2829 290a 0909 0964  ould_log())....d
    │ │ │ +00049430: 6562 7567 5f6c 6f67 2822 7065 6572 206e  ebug_log("peer n
    │ │ │ +00049440: 616d 6520 6c6f 6f6b 7570 2065 7272 6f72  ame lookup error
    │ │ │ +00049450: 3a20 2573 222c 2065 2e6d 6573 7361 6765  : %s", e.message
    │ │ │ +00049460: 2829 2e63 5f73 7472 2829 293b 0a23 656e  ().c_str());.#en
    │ │ │ +00049470: 6469 660a 0a09 0969 6620 2865 207c 7c20  dif....if (e || 
    │ │ │ +00049480: 6d5f 6162 6f72 7420 7c7c 2068 6f73 745f  m_abort || host_
    │ │ │ +00049490: 6c69 7374 2e65 6d70 7479 2829 207c 7c20  list.empty() || 
    │ │ │ +000494a0: 6d5f 7365 732e 6973 5f61 626f 7274 6564  m_ses.is_aborted
    │ │ │ +000494b0: 2829 2920 7265 7475 726e 3b0a 0a3c 6469  ()) return;....tcp
    │ │ │ +000494f0: 3a3a 656e 6470 6f69 6e74 2068 6f73 7428  ::endpoint host(
    │ │ │ +00049500: 686f 7374 5f6c 6973 742e 6672 6f6e 7428  host_list.front(
    │ │ │ +00049510: 292c 2073 7464 3a3a 7569 6e74 3136 5f74  ), std::uint16_t
    │ │ │ +00049520: 2870 6f72 7429 293b 0a3c 2f64 6976 3e0a  (port));..
    │ │ │ +00049530: 0909 6966 2028 6d5f 6970 5f66 696c 7465  ..if (m_ip_filte
    │ │ │ +00049540: 7220 2661 6d70 3b26 616d 703b 206d 5f69  r && m_i
    │ │ │ +00049550: 705f 6669 6c74 6572 2d26 6774 3b61 6363  p_filter->acc
    │ │ │ +00049560: 6573 7328 686f 7374 2e61 6464 7265 7373  ess(host.address
    │ │ │ +00049570: 2829 2920 2661 6d70 3b20 6970 5f66 696c  ()) & ip_fil
    │ │ │ +00049580: 7465 723a 3a62 6c6f 636b 6564 290a 0909  ter::blocked)...
    │ │ │ +00049590: 7b0a 2369 666e 6465 6620 544f 5252 454e  {.#ifndef TORREN
    │ │ │ +000495a0: 545f 4449 5341 424c 455f 4c4f 4747 494e  T_DISABLE_LOGGIN
    │ │ │ +000495b0: 470a 0909 0969 6620 2873 686f 756c 645f  G....if (should_
    │ │ │ +000495c0: 6c6f 6728 2929 0a09 0909 7b0a 0909 0909  log())....{.....
    │ │ │ +000495d0: 6465 6275 675f 6c6f 6728 2262 6c6f 636b  debug_log("block
    │ │ │ +000495e0: 6564 2069 7020 6672 6f6d 2074 7261 636b  ed ip from track
    │ │ │ +000495f0: 6572 3a20 2573 222c 2068 6f73 742e 6164  er: %s", host.ad
    │ │ │ +00049600: 6472 6573 7328 292e 746f 5f73 7472 696e  dress().to_strin
    │ │ │ +00049610: 6728 292e 635f 7374 7228 2929 3b0a 0909  g().c_str());...
    │ │ │ +00049620: 097d 0a23 656e 6469 660a 0909 0969 6620  .}.#endif....if 
    │ │ │ +00049630: 286d 5f73 6573 2e61 6c65 7274 7328 292e  (m_ses.alerts().
    │ │ │ +00049640: 7368 6f75 6c64 5f70 6f73 7426 6c74 3b70  should_post<p
    │ │ │ +00049650: 6565 725f 626c 6f63 6b65 645f 616c 6572  eer_blocked_aler
    │ │ │ +00049660: 7426 6774 3b28 2929 0a09 0909 096d 5f73  t>()).....m_s
    │ │ │ +00049670: 6573 2e61 6c65 7274 7328 292e 656d 706c  es.alerts().empl
    │ │ │ +00049680: 6163 655f 616c 6572 7426 6c74 3b70 6565  ace_alert<pee
    │ │ │ +00049690: 725f 626c 6f63 6b65 645f 616c 6572 7426  r_blocked_alert&
    │ │ │ +000496a0: 6774 3b28 6765 745f 6861 6e64 6c65 2829  gt;(get_handle()
    │ │ │ +000496b0: 0a09 0909 0909 2c20 686f 7374 2c20 7065  ......, host, pe
    │ │ │ +000496c0: 6572 5f62 6c6f 636b 6564 5f61 6c65 7274  er_blocked_alert
    │ │ │ +000496d0: 3a3a 6970 5f66 696c 7465 7229 3b0a 0909  ::ip_filter);...
    │ │ │ +000496e0: 0972 6574 7572 6e3b 0a09 097d 0a0a 0909  .return;...}....
    │ │ │ +000496f0: 6966 2028 6164 645f 7065 6572 2868 6f73  if (add_peer(hos
    │ │ │ +00049700: 742c 2070 6565 725f 696e 666f 3a3a 7472  t, peer_info::tr
    │ │ │ +00049710: 6163 6b65 722c 2076 203d 3d20 7072 6f74  acker, v == prot
    │ │ │ +00049720: 6f63 6f6c 5f76 6572 7369 6f6e 3a3a 5632  ocol_version::V2
    │ │ │ +00049730: 203f 2070 6578 5f6c 745f 7632 203a 2070   ? pex_lt_v2 : p
    │ │ │ +00049740: 6578 5f66 6c61 6773 5f74 2830 2929 290a  ex_flags_t(0))).
    │ │ │ +00049750: 0909 7b0a 0909 0973 7461 7465 5f75 7064  ..{....state_upd
    │ │ │ +00049760: 6174 6564 2829 3b0a 0a23 6966 6e64 6566  ated();..#ifndef
    │ │ │ +00049770: 2054 4f52 5245 4e54 5f44 4953 4142 4c45   TORRENT_DISABLE
    │ │ │ +00049780: 5f4c 4f47 4749 4e47 0a09 0909 6966 2028  _LOGGING....if (
    │ │ │ +00049790: 7368 6f75 6c64 5f6c 6f67 2829 290a 0909  should_log())...
    │ │ │ +000497a0: 097b 0a09 0909 0964 6562 7567 5f6c 6f67  .{.....debug_log
    │ │ │ +000497b0: 2822 6e61 6d65 2d6c 6f6f 6b75 7020 6164  ("name-lookup ad
    │ │ │ +000497c0: 645f 7065 6572 2829 205b 2025 7320 5d20  d_peer() [ %s ] 
    │ │ │ +000497d0: 636f 6e6e 6563 742d 6361 6e64 6964 6174  connect-candidat
    │ │ │ +000497e0: 6573 3a20 2564 220a 0909 0909 092c 2068  es: %d"......, h
    │ │ │ +000497f0: 6f73 742e 6164 6472 6573 7328 292e 746f  ost.address().to
    │ │ │ +00049800: 5f73 7472 696e 6728 292e 635f 7374 7228  _string().c_str(
    │ │ │ +00049810: 290a 0909 0909 092c 206d 5f70 6565 725f  )......, m_peer_
    │ │ │ +00049820: 6c69 7374 203f 206d 5f70 6565 725f 6c69  list ? m_peer_li
    │ │ │ +00049830: 7374 2d26 6774 3b6e 756d 5f63 6f6e 6e65  st->num_conne
    │ │ │ +00049840: 6374 5f63 616e 6469 6461 7465 7328 2920  ct_candidates() 
    │ │ │ +00049850: 3a20 2d31 293b 0a09 0909 7d0a 2365 6e64  : -1);....}.#end
    │ │ │ +00049860: 6966 0a09 097d 0a09 0975 7064 6174 655f  if...}...update_
    │ │ │ +00049870: 7761 6e74 5f70 6565 7273 2829 3b0a 097d  want_peers();..}
    │ │ │ +00049880: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472  .
    relevance  │ │ │ +000498c0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +000498f0: 7263 2f74 6f72 7265 6e74 2e63 7070 3a34 rc/torrent.cpp:4 │ │ │ +00049900: 3730 393c 2f61 3e3c 2f74 643e 3c74 643e 709 │ │ │ +00049910: 6f6e 6c79 2064 6f20 7468 6973 2069 6620 only do this if │ │ │ +00049920: 7468 6520 7069 6563 6520 7369 7a65 203e the piece size > │ │ │ +00049930: 2031 2062 6c6f 636b 7320 5468 6973 2069 1 blocks This i │ │ │ +00049940: 7320 6120 7632 2074 6f72 7265 6e74 2073 s a v2 torrent s │ │ │ +00049950: 6f20 7765 2063 616e 2072 6571 7565 7374 o we can request │ │ │ +00049960: 2067 6574 2062 6c6f 636b 206c 6576 656c get block level │ │ │ +00049970: 2068 6173 6865 732e 3c2f 7464 3e3c 2f74 hashes.

    only do th │ │ │ +000499d0: 6973 2069 6620 7468 6520 7069 6563 6520 is if the piece │ │ │ +000499e0: 7369 7a65 203e 2031 2062 6c6f 636b 730a size > 1 blocks. │ │ │ +000499f0: 5468 6973 2069 7320 6120 7632 2074 6f72 This is a v2 tor │ │ │ +00049a00: 7265 6e74 2073 6f20 7765 2063 616e 2072 rent so we can r │ │ │ +00049a10: 6571 7565 7374 2067 6574 2062 6c6f 636b equest get block │ │ │ +00049a20: 0a6c 6576 656c 2068 6173 6865 732e 3c2f .level hashes.

    ../src/to │ │ │ +00049a40: 7272 656e 742e 6370 703a 3437 3039 3c2f rrent.cpp:4709
    ..{
    │ │ │ +00049a90: 0a09 0909 7374 643a 3a73 6574 266c 743b  ....std::set<
    │ │ │ +00049aa0: 746f 7272 656e 745f 7065 6572 2a26 6774  torrent_peer*>
    │ │ │ +00049ab0: 3b20 7265 743b 0a09 0909 6966 2028 2162  ; ret;....if (!b
    │ │ │ +00049ac0: 6c6f 636b 732e 656d 7074 7928 2920 2661  locks.empty() &a
    │ │ │ +00049ad0: 6d70 3b26 616d 703b 2021 646f 776e 6c6f  mp;& !downlo
    │ │ │ +00049ae0: 6164 6572 732e 656d 7074 7928 2929 0a09  aders.empty())..
    │ │ │ +00049af0: 0909 7b0a 0909 0909 666f 7220 2861 7574  ..{.....for (aut
    │ │ │ +00049b00: 6f20 636f 6e73 7420 6220 3a20 626c 6f63  o const b : bloc
    │ │ │ +00049b10: 6b73 2920 7265 742e 696e 7365 7274 2864  ks) ret.insert(d
    │ │ │ +00049b20: 6f77 6e6c 6f61 6465 7273 5b73 7464 3a3a  ownloaders[std::
    │ │ │ +00049b30: 7369 7a65 5f74 2862 295d 293b 0a09 0909  size_t(b)]);....
    │ │ │ +00049b40: 7d0a 0909 0965 6c73 650a 0909 097b 0a09  }....else....{..
    │ │ │ +00049b50: 0909 0973 7464 3a3a 636f 7079 2864 6f77  ...std::copy(dow
    │ │ │ +00049b60: 6e6c 6f61 6465 7273 2e62 6567 696e 2829  nloaders.begin()
    │ │ │ +00049b70: 2c20 646f 776e 6c6f 6164 6572 732e 656e  , downloaders.en
    │ │ │ +00049b80: 6428 292c 2073 7464 3a3a 696e 7365 7274  d(), std::insert
    │ │ │ +00049b90: 6572 2872 6574 2c20 7265 742e 6265 6769  er(ret, ret.begi
    │ │ │ +00049ba0: 6e28 2929 293b 0a09 0909 7d0a 0909 0972  n()));....}....r
    │ │ │ +00049bb0: 6574 7572 6e20 7265 743b 0a09 097d 2829  eturn ret;...}()
    │ │ │ +00049bc0: 3b0a 0a09 092f 2f20 6966 2074 6869 7320  ;....// if this 
    │ │ │ +00049bd0: 7069 6563 6520 7761 736e 2774 2064 6f77  piece wasn't dow
    │ │ │ +00049be0: 6e6c 6f61 6465 6420 6672 6f6d 2070 6565  nloaded from pee
    │ │ │ +00049bf0: 7273 2c20 7765 206a 7573 7420 666f 756e  rs, we just foun
    │ │ │ +00049c00: 6420 6974 206f 6e20 6469 736b 2e0a 0909  d it on disk....
    │ │ │ +00049c10: 2f2f 2049 6e20 7468 6174 2063 6173 652c  // In that case,
    │ │ │ +00049c20: 2077 6520 7368 6f75 6c64 206a 7573 7420   we should just 
    │ │ │ +00049c30: 636f 6e73 6964 6572 2069 7420 6173 2022  consider it as "
    │ │ │ +00049c40: 6e6f 742d 6861 7665 2220 616e 6420 7468  not-have" and th
    │ │ │ +00049c50: 6572 6527 7320 6e6f 0a09 092f 2f20 6e65  ere's no...// ne
    │ │ │ +00049c60: 6564 2074 6f20 7472 7920 746f 2067 6574  ed to try to get
    │ │ │ +00049c70: 2068 6967 6865 7220 6669 6465 6c69 7479   higher fidelity
    │ │ │ +00049c80: 2068 6173 6865 7320 2879 6574 290a 0909   hashes (yet)...
    │ │ │ +00049c90: 626f 6f6c 2063 6f6e 7374 2066 6f75 6e64  bool const found
    │ │ │ +00049ca0: 5f6f 6e5f 6469 736b 203d 2070 6565 7273  _on_disk = peers
    │ │ │ +00049cb0: 2e73 697a 6528 2920 3d3d 2031 2026 616d  .size() == 1 &am
    │ │ │ +00049cc0: 703b 2661 6d70 3b20 7065 6572 732e 636f  p;& peers.co
    │ │ │ +00049cd0: 756e 7428 6e75 6c6c 7074 7229 3b0a 0a09  unt(nullptr);...
    │ │ │ +00049ce0: 0969 6620 2874 6f72 7265 6e74 5f66 696c  .if (torrent_fil
    │ │ │ +00049cf0: 6528 292e 696e 666f 5f68 6173 6865 7328  e().info_hashes(
    │ │ │ +00049d00: 292e 6861 735f 7632 2829 2026 616d 703b  ).has_v2() &
    │ │ │ +00049d10: 2661 6d70 3b20 626c 6f63 6b73 2e65 6d70  & blocks.emp
    │ │ │ +00049d20: 7479 2829 2026 616d 703b 2661 6d70 3b20  ty() && 
    │ │ │ +00049d30: 2166 6f75 6e64 5f6f 6e5f 6469 736b 290a  !found_on_disk).
    │ │ │ +00049d40: 0909 7b0a 3c64 6976 2073 7479 6c65 3d22  ..{.
    ...verify_bloc │ │ │ +00049d80: 6b5f 6861 7368 6573 2869 6e64 6578 293b k_hashes(index); │ │ │ +00049d90: 0a3c 2f64 6976 3e09 097d 0a0a 0909 2f2f .
    ..}....// │ │ │ +00049da0: 2074 6865 2062 656c 6f77 2063 6f64 6520 the below code │ │ │ +00049db0: 6973 2070 656e 616c 697a 696e 6720 7065 is penalizing pe │ │ │ +00049dc0: 6572 7320 7468 6174 2073 656e 7420 7573 ers that sent us │ │ │ +00049dd0: 6520 6261 6420 6461 7461 2e0a 0909 2f2f e bad data....// │ │ │ +00049de0: 2069 6e63 7265 6173 6520 7468 6520 746f increase the to │ │ │ +00049df0: 7461 6c20 616d 6f75 6e74 206f 6620 6661 tal amount of fa │ │ │ +00049e00: 696c 6564 2062 7974 6573 0a09 0969 6620 iled bytes...if │ │ │ +00049e10: 2821 666f 756e 645f 6f6e 5f64 6973 6b29 (!found_on_disk) │ │ │ +00049e20: 0a09 097b 0a09 0909 6966 2028 626c 6f63 ...{....if (bloc │ │ │ +00049e30: 6b73 2e65 6d70 7479 2829 290a 0909 0909 ks.empty())..... │ │ │ +00049e40: 6164 645f 6661 696c 6564 5f62 7974 6573 add_failed_bytes │ │ │ +00049e50: 286d 5f74 6f72 7265 6e74 5f66 696c 652d (m_torrent_file- │ │ │ +00049e60: 2667 743b 7069 6563 655f 7369 7a65 2869 >piece_size(i │ │ │ +00049e70: 6e64 6578 2929 3b0a 0909 0965 6c73 650a ndex));....else. │ │ │ +00049e80: 0909 0909 6164 645f 6661 696c 6564 5f62 ....add_failed_b │ │ │ +00049e90: 7974 6573 2873 7461 7469 635f 6361 7374 ytes(static_cast │ │ │ +00049ea0: 266c 743b 696e 7426 6774 3b28 626c 6f63 <int>(bloc │ │ │ +00049eb0: 6b73 2e73 697a 6528 2929 202a 2064 6566 ks.size()) * def │ │ │ +00049ec0: 6175 6c74 5f62 6c6f 636b 5f73 697a 6529 ault_block_size) │ │ │ +00049ed0: 3b0a 0a23 6966 6e64 6566 2054 4f52 5245 ;..#ifndef TORRE │ │ │ +00049ee0: 4e54 5f44 4953 4142 4c45 5f45 5854 454e NT_DISABLE_EXTEN │ │ │ +00049ef0: 5349 4f4e 530a 0909 0966 6f72 2028 6175 SIONS....for (au │ │ │ +00049f00: 746f 2661 6d70 3b20 6578 7420 3a20 6d5f to& ext : m_ │ │ │ +00049f10: 6578 7465 6e73 696f 6e73 290a 0909 097b extensions)....{ │ │ │ +00049f20: 0a09 0909 0965 7874 2d26 6774 3b6f 6e5f .....ext->on_ │ │ │ +00049f30: 7069 6563 655f 6661 696c 6564 2869 6e64 piece_failed(ind │ │ │ +00049f40: 6578 293b 0a09 0909 7d0a 2365 6e64 6966 ex);....}.#endif │ │ │ +00049f50: 0a0a 0909 092f 2f20 6469 6420 7765 2072 .....// did we r │ │ │ +00049f60: 6563 6569 7665 2074 6869 7320 7069 6563 eceive this piec │ │ │ +00049f70: 6520 6672 6f6d 2061 2073 696e 676c 6520 e from a single │ │ │ +00049f80: 7065 6572 3f0a 0909 092f 2f20 6966 2077 peer?....// if w │ │ │ +00049f90: 6520 6b6e 6f77 2065 7861 6374 6c79 2077 e know exactly w │ │ │ +00049fa0: 6869 6368 2062 6c6f 636b 7320 6661 696c hich blocks fail │ │ │ +00049fb0: 6564 2074 6865 2068 6173 682c 2077 6520 ed the hash, we │ │ │ +00049fc0: 6361 6e20 616c 736f 2062 6520 6365 7274 can also be cert │ │ │ +00049fd0: 6169 6e0a 0909 092f 2f20 7468 6174 2061 ain....// that a │ │ │ +00049fe0: 6c6c 2070 6565 7273 2069 6e20 7468 6520 ll peers in the │ │ │ +00049ff0: 6c69 7374 2073 656e 7420 7573 2062 6164 list sent us bad │ │ │ +0004a000: 2064 6174 610a 0909 0962 6f6f 6c20 636f data....bool co │ │ │ +0004a010: 6e73 7420 6b6e 6f77 6e5f 6261 645f 7065 nst known_bad_pe │ │ │ +0004a020: 6572 203d 2028 2166 6f75 6e64 5f6f 6e5f er = (!found_on_ │ │ │ +0004a030: 6469 736b 2026 616d 703b 2661 6d70 3b20 disk && │ │ │ +0004a040: 7065 6572 732e 7369 7a65 2829 203d 3d20 peers.size() == │ │ │ +0004a050: 3129 207c 7c20 2162 6c6f 636b 732e 656d 1) || !blocks.em │ │ │ +0004a060: 7074 7928 293b 0a0a 0909 0970 656e 616c pty();.....penal │ │ │ +0004a070: 697a 655f 7065 6572 7328 7065 6572 732c ize_peers(peers, │ │ │ +0004a080: 2069 6e64 6578 2c20 6b6e 6f77 6e5f 6261 index, known_ba │ │ │ +0004a090: 645f 7065 6572 293b 0a09 097d 0a0a 0909 d_peer);...}.... │ │ │ +0004a0a0: 2f2f 2049 6620 6d5f 7374 6f72 6167 6520 // If m_storage │ │ │ +0004a0b0: 6973 6e27 7420 7365 7420 6865 7265 2c20 isn't set here, │ │ │ +0004a0c0: 6974 206d 6561 6e73 2077 6527 7265 2073 it means we're s │ │ │ +0004a0d0: 6875 7474 696e 6720 646f 776e 0a09 0969 hutting down...i │ │ │ +0004a0e0: 6620 286d 5f73 746f 7261 6765 290a 0909 f (m_storage)... │ │ │ +0004a0f0: 7b0a 0909 092f 2f20 6974 2064 6f65 736e {....// it doesn │ │ │ +0004a100: 2774 206d 616b 6520 6d75 6368 2073 656e 't make much sen │ │ │ +0004a110: 7365 2074 6f20 6661 696c 2074 6f20 6861 se to fail to ha │ │ │ +0004a120: 7368 2061 2070 6965 6365 0a3c 2f70 7265 sh a piece.
    rele │ │ │ +0004a160: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/tor │ │ │ +0004a1a0: 7265 6e74 2e63 7070 3a37 3636 353c 2f61 rent.cpp:7665come u │ │ │ +0004a1c0: 7020 7769 7468 2061 2062 6574 7465 7220 p with a better │ │ │ +0004a1d0: 7761 7920 6f66 2064 6f69 6e67 2074 6869 way of doing thi │ │ │ +0004a1e0: 732c 2069 6e73 7465 6164 206f 6620 616e s, instead of an │ │ │ +0004a1f0: 2069 6d6d 6564 6961 7465 6c79 2069 6e76 immediately inv │ │ │ +0004a200: 6f6b 6564 206c 616d 6264 6120 6578 7072 oked lambda expr │ │ │ +0004a210: 6573 7369 6f6e 2e3c 2f74 643e 3c2f 7472 ession.

    come up wit │ │ │ +0004a270: 6820 6120 6265 7474 6572 2077 6179 206f h a better way o │ │ │ +0004a280: 6620 646f 696e 6720 7468 6973 2c20 696e f doing this, in │ │ │ +0004a290: 7374 6561 6420 6f66 2061 6e0a 696d 6d65 stead of an.imme │ │ │ +0004a2a0: 6469 6174 656c 7920 696e 766f 6b65 6420 diately invoked │ │ │ +0004a2b0: 6c61 6d62 6461 2065 7870 7265 7373 696f lambda expressio │ │ │ +0004a2c0: 6e2e 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 n.

    ../sr │ │ │ +0004a2d0: 632f 746f 7272 656e 742e 6370 703a 3736 c/torrent.cpp:76 │ │ │ +0004a2e0: 3635 3c2f 6834 3e3c 7072 6520 7374 796c 65

    .....|| peerinf
    │ │ │ +0004a330: 6f2d 2667 743b 636f 6e66 6972 6d65 645f  o->confirmed_
    │ │ │ +0004a340: 7375 7070 6f72 7473 5f75 7470 2929 0a09  supports_utp))..
    │ │ │ +0004a350: 0909 7b0a 0909 0909 736d 203d 206d 5f73  ..{.....sm = m_s
    │ │ │ +0004a360: 6573 2e75 7470 5f73 6f63 6b65 745f 6d61  es.utp_socket_ma
    │ │ │ +0004a370: 6e61 6765 7228 293b 0a09 0909 7d0a 0a09  nager();....}...
    │ │ │ +0004a380: 0909 2f2f 2064 6f6e 2774 206d 616b 6520  ..// don't make 
    │ │ │ +0004a390: 6120 5443 5020 636f 6e6e 6563 7469 6f6e  a TCP connection
    │ │ │ +0004a3a0: 2069 6620 6974 2773 2064 6973 6162 6c65   if it's disable
    │ │ │ +0004a3b0: 640a 0909 0969 6620 2873 6d20 3d3d 206e  d....if (sm == n
    │ │ │ +0004a3c0: 756c 6c70 7472 2026 616d 703b 2661 6d70  ullptr &&
    │ │ │ +0004a3d0: 3b20 2173 6574 7469 6e67 7328 292e 6765  ; !settings().ge
    │ │ │ +0004a3e0: 745f 626f 6f6c 2873 6574 7469 6e67 735f  t_bool(settings_
    │ │ │ +0004a3f0: 7061 636b 3a3a 656e 6162 6c65 5f6f 7574  pack::enable_out
    │ │ │ +0004a400: 676f 696e 675f 7463 7029 290a 0909 097b  going_tcp))....{
    │ │ │ +0004a410: 0a23 6966 6e64 6566 2054 4f52 5245 4e54  .#ifndef TORRENT
    │ │ │ +0004a420: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47  _DISABLE_LOGGING
    │ │ │ +0004a430: 0a09 0909 0969 6620 2873 686f 756c 645f  .....if (should_
    │ │ │ +0004a440: 6c6f 6728 2929 0a09 0909 097b 0a09 0909  log()).....{....
    │ │ │ +0004a450: 0909 6465 6275 675f 6c6f 6728 2264 6973  ..debug_log("dis
    │ │ │ +0004a460: 6361 7264 696e 6720 7065 6572 205c 2225  carding peer \"%
    │ │ │ +0004a470: 735c 223a 2054 4350 2063 6f6e 6e65 6374  s\": TCP connect
    │ │ │ +0004a480: 696f 6e73 2064 6973 6162 6c65 6420 220a  ions disabled ".
    │ │ │ +0004a490: 0909 0909 0909 225b 2073 7570 706f 7274  ......"[ support
    │ │ │ +0004a4a0: 732d 7574 703a 2025 6420 5d22 2c20 7065  s-utp: %d ]", pe
    │ │ │ +0004a4b0: 6572 696e 666f 2d26 6774 3b74 6f5f 7374  erinfo->to_st
    │ │ │ +0004a4c0: 7269 6e67 2829 2e63 5f73 7472 2829 0a09  ring().c_str()..
    │ │ │ +0004a4d0: 0909 0909 092c 2070 6565 7269 6e66 6f2d  ....., peerinfo-
    │ │ │ +0004a4e0: 2667 743b 7375 7070 6f72 7473 5f75 7470  >supports_utp
    │ │ │ +0004a4f0: 293b 0a09 0909 097d 0a23 656e 6469 660a  );.....}.#endif.
    │ │ │ +0004a500: 0909 0909 7265 7475 726e 2066 616c 7365  ....return false
    │ │ │ +0004a510: 3b0a 0909 097d 0a09 097d 0a0a 3c64 6976  ;....}...}..
    ..aux: │ │ │ +0004a550: 3a73 6f63 6b65 745f 7479 7065 2073 203d :socket_type s = │ │ │ +0004a560: 205b 2661 6d70 3b5d 207b 0a3c 2f64 6976 [&] {.
    .#if TORRENT_US │ │ │ +0004a580: 455f 4932 500a 0909 6966 2028 7065 6572 E_I2P...if (peer │ │ │ +0004a590: 696e 666f 2d26 6774 3b69 735f 6932 705f info->is_i2p_ │ │ │ +0004a5a0: 6164 6472 290a 0909 7b0a 0909 092f 2f20 addr)...{....// │ │ │ +0004a5b0: 4974 2773 206e 6f74 2065 6e74 6972 656c It's not entirel │ │ │ +0004a5c0: 7920 6f62 7669 6f75 7320 7768 7920 7468 y obvious why th │ │ │ +0004a5d0: 6973 2070 6565 7220 636f 6e6e 6563 7469 is peer connecti │ │ │ +0004a5e0: 6f6e 2069 7320 6e6f 7420 6d61 726b 6564 on is not marked │ │ │ +0004a5f0: 2061 730a 0909 092f 2f20 6f6e 652e 2054 as....// one. T │ │ │ +0004a600: 6865 206d 6169 6e20 6665 6174 7572 6520 he main feature │ │ │ +0004a610: 6f66 2061 2070 6565 7220 636f 6e6e 6563 of a peer connec │ │ │ +0004a620: 7469 6f6e 2069 7320 7468 6174 2077 6865 tion is that whe │ │ │ +0004a630: 7468 6572 206f 7220 6e6f 7420 7765 0a09 ther or not we.. │ │ │ +0004a640: 0909 2f2f 2070 726f 7879 2069 7420 6973 ..// proxy it is │ │ │ +0004a650: 2063 6f6e 6669 6775 7261 626c 652e 2057 configurable. W │ │ │ +0004a660: 6865 6e20 7765 2075 7365 2069 3270 2c20 hen we use i2p, │ │ │ +0004a670: 7765 2077 616e 7420 746f 2061 6c77 6179 we want to alway │ │ │ +0004a680: 7320 7072 6f78 0a09 0909 2f2f 2065 7665 s prox....// eve │ │ │ +0004a690: 7279 7468 696e 6720 7669 6120 6932 702e rything via i2p. │ │ │ +0004a6a0: 0a0a 0909 0961 7578 3a3a 7072 6f78 795f .....aux::proxy_ │ │ │ +0004a6b0: 7365 7474 696e 6773 2070 726f 7879 3b0a settings proxy;. │ │ │ +0004a6c0: 0909 0970 726f 7879 2e68 6f73 746e 616d ...proxy.hostnam │ │ │ +0004a6d0: 6520 3d20 7365 7474 696e 6773 2829 2e67 e = settings().g │ │ │ +0004a6e0: 6574 5f73 7472 2873 6574 7469 6e67 735f et_str(settings_ │ │ │ +0004a6f0: 7061 636b 3a3a 6932 705f 686f 7374 6e61 pack::i2p_hostna │ │ │ +0004a700: 6d65 293b 0a09 0909 7072 6f78 792e 706f me);....proxy.po │ │ │ +0004a710: 7274 203d 2073 7464 3a3a 7569 6e74 3136 rt = std::uint16 │ │ │ +0004a720: 5f74 2873 6574 7469 6e67 7328 292e 6765 _t(settings().ge │ │ │ +0004a730: 745f 696e 7428 7365 7474 696e 6773 5f70 t_int(settings_p │ │ │ +0004a740: 6163 6b3a 3a69 3270 5f70 6f72 7429 293b ack::i2p_port)); │ │ │ +0004a750: 0a09 0909 7072 6f78 792e 7479 7065 203d ....proxy.type = │ │ │ +0004a760: 2073 6574 7469 6e67 735f 7061 636b 3a3a settings_pack:: │ │ │ +0004a770: 6932 705f 7072 6f78 793b 0a0a 0909 0961 i2p_proxy;.....a │ │ │ +0004a780: 7578 3a3a 736f 636b 6574 5f74 7970 6520 ux::socket_type │ │ │ +0004a790: 7265 7420 3d20 696e 7374 616e 7469 6174 ret = instantiat │ │ │ +0004a7a0: 655f 636f 6e6e 6563 7469 6f6e 286d 5f73 e_connection(m_s │ │ │ +0004a7b0: 6573 2e67 6574 5f63 6f6e 7465 7874 2829 es.get_context() │ │ │ +0004a7c0: 0a09 0909 092c 2070 726f 7879 2c20 6e75 ....., proxy, nu │ │ │ +0004a7d0: 6c6c 7074 722c 206e 756c 6c70 7472 2c20 llptr, nullptr, │ │ │ +0004a7e0: 6661 6c73 652c 2066 616c 7365 293b 0a09 false, false);.. │ │ │ +0004a7f0: 0909 6932 705f 7374 7265 616d 2661 6d70 ..i2p_stream& │ │ │ +0004a800: 3b20 7374 7220 3d20 626f 6f73 743a 3a67 ; str = boost::g │ │ │ +0004a810: 6574 266c 743b 6932 705f 7374 7265 616d et<i2p_stream │ │ │ +0004a820: 2667 743b 2872 6574 293b 0a09 0909 7374 >(ret);....st │ │ │ +0004a830: 722e 7365 745f 6c6f 6361 6c5f 6932 705f r.set_local_i2p_ │ │ │ +0004a840: 656e 6470 6f69 6e74 286d 5f73 6573 2e6c endpoint(m_ses.l │ │ │ +0004a850: 6f63 616c 5f69 3270 5f65 6e64 706f 696e ocal_i2p_endpoin │ │ │ +0004a860: 7428 2929 3b0a 0909 0973 7472 2e73 6574 t());....str.set │ │ │ +0004a870: 5f64 6573 7469 6e61 7469 6f6e 2873 7461 _destination(sta │ │ │ +0004a880: 7469 635f 6361 7374 266c 743b 6932 705f tic_cast<i2p_ │ │ │ +0004a890: 7065 6572 2a26 6774 3b28 7065 6572 696e peer*>(peerin │ │ │ +0004a8a0: 666f 292d 2667 743b 6465 7374 2829 293b fo)->dest()); │ │ │ +0004a8b0: 0a09 0909 7374 722e 7365 745f 636f 6d6d ....str.set_comm │ │ │ +0004a8c0: 616e 6428 6932 705f 7374 7265 616d 3a3a and(i2p_stream:: │ │ │ +0004a8d0: 636d 645f 636f 6e6e 6563 7429 3b0a 0909 cmd_connect);... │ │ │ +0004a8e0: 0973 7472 2e73 6574 5f73 6573 7369 6f6e .str.set_session │ │ │ +0004a8f0: 5f69 6428 6d5f 7365 732e 6932 705f 7365 _id(m_ses.i2p_se │ │ │ +0004a900: 7373 696f 6e28 2929 3b0a 0909 0972 6574 ssion());....ret │ │ │ +0004a910: 7572 6e20 7265 743b 0a09 097d 0a09 0965 urn ret;...}...e │ │ │ +0004a920: 6c73 650a 2365 6e64 6966 0a09 097b 0a09 lse.#endif...{.. │ │ │ +0004a930: 0909 766f 6964 2a20 7573 6572 6461 7461 ..void* userdata │ │ │ +0004a940: 203d 206e 756c 6c70 7472 3b0a 2369 6664 = nullptr;.#ifd │ │ │ +0004a950: 6566 2054 4f52 5245 4e54 5f53 534c 5f50 ef TORRENT_SSL_P │ │ │ +0004a960: 4545 5253 0a09 0909 6966 2028 6973 5f73 EERS....if (is_s │ │ │ +0004a970: 736c 5f74 6f72 7265 6e74 2829 290a 0909 sl_torrent())... │ │ │ +0004a980: 097b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f .{.
    │ │ │ +0004a9b0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +0004a9c0: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +0004a9f0: 2f73 7263 2f74 6f72 7265 6e74 2e63 7070 /src/torrent.cpp │ │ │ +0004aa00: 3a39 3331 313c 2f61 3e3c 2f74 643e 3c74 :9311perhaps 0 shou │ │ │ +0004aa20: 6c64 2061 6374 7561 6c6c 7920 6d65 616e ld actually mean │ │ │ +0004aa30: 2030 3c2f 7464 3e3c 2f74 723e 3c74 7220 0

    │ │ │ +0004aa80: 7065 7268 6170 7320 3020 7368 6f75 6c64 perhaps 0 should │ │ │ +0004aa90: 2061 6374 7561 6c6c 7920 6d65 616e 2030 actually mean 0 │ │ │ +0004aaa0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +0004aab0: 746f 7272 656e 742e 6370 703a 3933 3131 torrent.cpp:9311 │ │ │ +0004aac0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +0004ab00: 092f 2f20 6669 6e69 7368 6564 2074 6f72  .// finished tor
    │ │ │ +0004ab10: 7265 6e74 7320 6d61 7920 6e6f 7420 6368  rents may not ch
    │ │ │ +0004ab20: 616e 6765 2074 6865 6972 2071 7565 7565  ange their queue
    │ │ │ +0004ab30: 2070 6f73 6974 696f 6e73 2c20 6173 2069   positions, as i
    │ │ │ +0004ab40: 7427 7320 7365 7420 746f 0a09 092f 2f20  t's set to...// 
    │ │ │ +0004ab50: 2d31 0a09 0969 6620 2828 6d5f 6162 6f72  -1...if ((m_abor
    │ │ │ +0004ab60: 7420 7c7c 2069 735f 6669 6e69 7368 6564  t || is_finished
    │ │ │ +0004ab70: 2829 2920 2661 6d70 3b26 616d 703b 2070  ()) && p
    │ │ │ +0004ab80: 2021 3d20 6e6f 5f70 6f73 2920 7265 7475   != no_pos) retu
    │ │ │ +0004ab90: 726e 3b0a 0a09 0954 4f52 5245 4e54 5f41  rn;....TORRENT_A
    │ │ │ +0004aba0: 5353 4552 5428 2870 203d 3d20 6e6f 5f70  SSERT((p == no_p
    │ │ │ +0004abb0: 6f73 2920 3d3d 2069 735f 6669 6e69 7368  os) == is_finish
    │ │ │ +0004abc0: 6564 2829 0a09 0909 7c7c 2028 216d 5f61  ed()....|| (!m_a
    │ │ │ +0004abd0: 7574 6f5f 6d61 6e61 6765 6420 2661 6d70  uto_managed &
    │ │ │ +0004abe0: 3b26 616d 703b 2070 203d 3d20 6e6f 5f70  ;& p == no_p
    │ │ │ +0004abf0: 6f73 290a 0909 097c 7c20 286d 5f61 626f  os)....|| (m_abo
    │ │ │ +0004ac00: 7274 2026 616d 703b 2661 6d70 3b20 7020  rt && p 
    │ │ │ +0004ac10: 3d3d 206e 6f5f 706f 7329 0a09 0909 7c7c  == no_pos)....||
    │ │ │ +0004ac20: 2028 216d 5f61 6464 6564 2026 616d 703b   (!m_added &
    │ │ │ +0004ac30: 2661 6d70 3b20 7020 3d3d 206e 6f5f 706f  & p == no_po
    │ │ │ +0004ac40: 7329 293b 0a09 0969 6620 2870 203d 3d20  s));...if (p == 
    │ │ │ +0004ac50: 6d5f 7365 7175 656e 6365 5f6e 756d 6265  m_sequence_numbe
    │ │ │ +0004ac60: 7229 2072 6574 7572 6e3b 0a0a 0909 544f  r) return;....TO
    │ │ │ +0004ac70: 5252 454e 545f 4153 5345 5254 2870 2026  RRENT_ASSERT(p &
    │ │ │ +0004ac80: 6774 3b3d 206e 6f5f 706f 7329 3b0a 0a09  gt;= no_pos);...
    │ │ │ +0004ac90: 0973 7461 7465 5f75 7064 6174 6564 2829  .state_updated()
    │ │ │ +0004aca0: 3b0a 0a09 096d 5f73 6573 2e73 6574 5f71  ;....m_ses.set_q
    │ │ │ +0004acb0: 7565 7565 5f70 6f73 6974 696f 6e28 7468  ueue_position(th
    │ │ │ +0004acc0: 6973 2c20 7029 3b0a 097d 0a0a 0976 6f69  is, p);..}...voi
    │ │ │ +0004acd0: 6420 746f 7272 656e 743a 3a73 6574 5f6d  d torrent::set_m
    │ │ │ +0004ace0: 6178 5f75 706c 6f61 6473 2869 6e74 206c  ax_uploads(int l
    │ │ │ +0004acf0: 696d 6974 2c20 626f 6f6c 2063 6f6e 7374  imit, bool const
    │ │ │ +0004ad00: 2073 7461 7465 5f75 7064 6174 6529 0a09   state_update)..
    │ │ │ +0004ad10: 7b0a 0909 544f 5252 454e 545f 4153 5345  {...TORRENT_ASSE
    │ │ │ +0004ad20: 5254 2869 735f 7369 6e67 6c65 5f74 6872  RT(is_single_thr
    │ │ │ +0004ad30: 6561 6428 2929 3b0a 3c64 6976 2073 7479  ead());.
    ..if (limi │ │ │ +0004ad70: 7420 266c 743b 3d20 3029 206c 696d 6974 t <= 0) limit │ │ │ +0004ad80: 203d 2028 3120 266c 743b 266c 743b 2032 = (1 << 2 │ │ │ +0004ad90: 3429 202d 2031 3b0a 3c2f 6469 763e 0909 4) - 1;.
    .. │ │ │ +0004ada0: 6966 2028 696e 7428 6d5f 6d61 785f 7570 if (int(m_max_up │ │ │ +0004adb0: 6c6f 6164 7329 203d 3d20 6c69 6d69 7429 loads) == limit) │ │ │ +0004adc0: 2072 6574 7572 6e3b 0a09 0969 6620 2873 return;...if (s │ │ │ +0004add0: 7461 7465 5f75 7064 6174 6529 2073 7461 tate_update) sta │ │ │ +0004ade0: 7465 5f75 7064 6174 6564 2829 3b0a 0909 te_updated();... │ │ │ +0004adf0: 6d5f 6d61 785f 7570 6c6f 6164 7320 3d20 m_max_uploads = │ │ │ +0004ae00: 6175 783a 3a6e 756d 6572 6963 5f63 6173 aux::numeric_cas │ │ │ +0004ae10: 7426 6c74 3b73 7464 3a3a 7569 6e74 3332 t<std::uint32 │ │ │ +0004ae20: 5f74 2667 743b 286c 696d 6974 293b 0a23 _t>(limit);.# │ │ │ +0004ae30: 6966 6e64 6566 2054 4f52 5245 4e54 5f44 ifndef TORRENT_D │ │ │ +0004ae40: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09 ISABLE_LOGGING.. │ │ │ +0004ae50: 0969 6620 2873 686f 756c 645f 6c6f 6728 .if (should_log( │ │ │ +0004ae60: 2920 2661 6d70 3b26 616d 703b 2073 7461 ) && sta │ │ │ +0004ae70: 7465 5f75 7064 6174 6529 0a09 0909 6465 te_update)....de │ │ │ +0004ae80: 6275 675f 6c6f 6728 222a 2a2a 2073 6574 bug_log("*** set │ │ │ +0004ae90: 2d6d 6178 2d75 706c 6f61 6473 3a20 2564 -max-uploads: %d │ │ │ +0004aea0: 222c 206d 5f6d 6178 5f75 706c 6f61 6473 ", m_max_uploads │ │ │ +0004aeb0: 293b 0a23 656e 6469 660a 0a09 0969 6620 );.#endif....if │ │ │ +0004aec0: 2873 7461 7465 5f75 7064 6174 6529 0a09 (state_update).. │ │ │ +0004aed0: 0909 7365 745f 6e65 6564 5f73 6176 655f ..set_need_save_ │ │ │ +0004aee0: 7265 7375 6d65 2874 6f72 7265 6e74 5f68 resume(torrent_h │ │ │ +0004aef0: 616e 646c 653a 3a69 665f 636f 6e66 6967 andle::if_config │ │ │ +0004af00: 5f63 6861 6e67 6564 293b 0a09 7d0a 0a09 _changed);..}... │ │ │ +0004af10: 766f 6964 2074 6f72 7265 6e74 3a3a 7365 void torrent::se │ │ │ +0004af20: 745f 6d61 785f 636f 6e6e 6563 7469 6f6e t_max_connection │ │ │ +0004af30: 7328 696e 7420 6c69 6d69 742c 2062 6f6f s(int limit, boo │ │ │ +0004af40: 6c20 636f 6e73 7420 7374 6174 655f 7570 l const state_up │ │ │ +0004af50: 6461 7465 290a 097b 0a09 0954 4f52 5245 date)..{...TORRE │ │ │ +0004af60: 4e54 5f41 5353 4552 5428 6973 5f73 696e NT_ASSERT(is_sin │ │ │ +0004af70: 676c 655f 7468 7265 6164 2829 293b 0a3c gle_thread());.< │ │ │ +0004af80: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +0004af90: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +0004afa0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +0004afb0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +0004afc0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ +0004aff0: 2f74 6f72 7265 6e74 2e63 7070 3a39 3332 /torrent.cpp:932 │ │ │ +0004b000: 383c 2f61 3e3c 2f74 643e 3c74 643e 7065 8pe │ │ │ +0004b010: 7268 6170 7320 3020 7368 6f75 6c64 2061 rhaps 0 should a │ │ │ +0004b020: 6374 7561 6c6c 7920 6d65 616e 2030 3c2f ctually mean 0

    perh │ │ │ +0004b080: 6170 7320 3020 7368 6f75 6c64 2061 6374 aps 0 should act │ │ │ +0004b090: 7561 6c6c 7920 6d65 616e 2030 3c2f 6832 ually mean 0

    ../src/torr │ │ │ +0004b0b0: 656e 742e 6370 703a 3933 3238 3c2f 6834 ent.cpp:9328

    ..voi
    │ │ │ +0004b100: 6420 746f 7272 656e 743a 3a73 6574 5f6d  d torrent::set_m
    │ │ │ +0004b110: 6178 5f75 706c 6f61 6473 2869 6e74 206c  ax_uploads(int l
    │ │ │ +0004b120: 696d 6974 2c20 626f 6f6c 2063 6f6e 7374  imit, bool const
    │ │ │ +0004b130: 2073 7461 7465 5f75 7064 6174 6529 0a09   state_update)..
    │ │ │ +0004b140: 7b0a 0909 544f 5252 454e 545f 4153 5345  {...TORRENT_ASSE
    │ │ │ +0004b150: 5254 2869 735f 7369 6e67 6c65 5f74 6872  RT(is_single_thr
    │ │ │ +0004b160: 6561 6428 2929 3b0a 0909 6966 2028 6c69  ead());...if (li
    │ │ │ +0004b170: 6d69 7420 266c 743b 3d20 3029 206c 696d  mit <= 0) lim
    │ │ │ +0004b180: 6974 203d 2028 3120 266c 743b 266c 743b  it = (1 <<
    │ │ │ +0004b190: 2032 3429 202d 2031 3b0a 0909 6966 2028   24) - 1;...if (
    │ │ │ +0004b1a0: 696e 7428 6d5f 6d61 785f 7570 6c6f 6164  int(m_max_upload
    │ │ │ +0004b1b0: 7329 203d 3d20 6c69 6d69 7429 2072 6574  s) == limit) ret
    │ │ │ +0004b1c0: 7572 6e3b 0a09 0969 6620 2873 7461 7465  urn;...if (state
    │ │ │ +0004b1d0: 5f75 7064 6174 6529 2073 7461 7465 5f75  _update) state_u
    │ │ │ +0004b1e0: 7064 6174 6564 2829 3b0a 0909 6d5f 6d61  pdated();...m_ma
    │ │ │ +0004b1f0: 785f 7570 6c6f 6164 7320 3d20 6175 783a  x_uploads = aux:
    │ │ │ +0004b200: 3a6e 756d 6572 6963 5f63 6173 7426 6c74  :numeric_cast<
    │ │ │ +0004b210: 3b73 7464 3a3a 7569 6e74 3332 5f74 2667  ;std::uint32_t&g
    │ │ │ +0004b220: 743b 286c 696d 6974 293b 0a23 6966 6e64  t;(limit);.#ifnd
    │ │ │ +0004b230: 6566 2054 4f52 5245 4e54 5f44 4953 4142  ef TORRENT_DISAB
    │ │ │ +0004b240: 4c45 5f4c 4f47 4749 4e47 0a09 0969 6620  LE_LOGGING...if 
    │ │ │ +0004b250: 2873 686f 756c 645f 6c6f 6728 2920 2661  (should_log() &a
    │ │ │ +0004b260: 6d70 3b26 616d 703b 2073 7461 7465 5f75  mp;& state_u
    │ │ │ +0004b270: 7064 6174 6529 0a09 0909 6465 6275 675f  pdate)....debug_
    │ │ │ +0004b280: 6c6f 6728 222a 2a2a 2073 6574 2d6d 6178  log("*** set-max
    │ │ │ +0004b290: 2d75 706c 6f61 6473 3a20 2564 222c 206d  -uploads: %d", m
    │ │ │ +0004b2a0: 5f6d 6178 5f75 706c 6f61 6473 293b 0a23  _max_uploads);.#
    │ │ │ +0004b2b0: 656e 6469 660a 0a09 0969 6620 2873 7461  endif....if (sta
    │ │ │ +0004b2c0: 7465 5f75 7064 6174 6529 0a09 0909 7365  te_update)....se
    │ │ │ +0004b2d0: 745f 6e65 6564 5f73 6176 655f 7265 7375  t_need_save_resu
    │ │ │ +0004b2e0: 6d65 2874 6f72 7265 6e74 5f68 616e 646c  me(torrent_handl
    │ │ │ +0004b2f0: 653a 3a69 665f 636f 6e66 6967 5f63 6861  e::if_config_cha
    │ │ │ +0004b300: 6e67 6564 293b 0a09 7d0a 0a09 766f 6964  nged);..}...void
    │ │ │ +0004b310: 2074 6f72 7265 6e74 3a3a 7365 745f 6d61   torrent::set_ma
    │ │ │ +0004b320: 785f 636f 6e6e 6563 7469 6f6e 7328 696e  x_connections(in
    │ │ │ +0004b330: 7420 6c69 6d69 742c 2062 6f6f 6c20 636f  t limit, bool co
    │ │ │ +0004b340: 6e73 7420 7374 6174 655f 7570 6461 7465  nst state_update
    │ │ │ +0004b350: 290a 097b 0a09 0954 4f52 5245 4e54 5f41  )..{...TORRENT_A
    │ │ │ +0004b360: 5353 4552 5428 6973 5f73 696e 676c 655f  SSERT(is_single_
    │ │ │ +0004b370: 7468 7265 6164 2829 293b 0a3c 6469 7620  thread());.
    ..if (l │ │ │ +0004b3b0: 696d 6974 2026 6c74 3b3d 2030 2920 6c69 imit <= 0) li │ │ │ +0004b3c0: 6d69 7420 3d20 2831 2026 6c74 3b26 6c74 mit = (1 << │ │ │ +0004b3d0: 3b20 3234 2920 2d20 313b 0a3c 2f64 6976 ; 24) - 1;.
    ..if (int(m_max │ │ │ +0004b3f0: 5f63 6f6e 6e65 6374 696f 6e73 2920 3d3d _connections) == │ │ │ +0004b400: 206c 696d 6974 2920 7265 7475 726e 3b0a limit) return;. │ │ │ +0004b410: 0909 6966 2028 7374 6174 655f 7570 6461 ..if (state_upda │ │ │ +0004b420: 7465 2920 7374 6174 655f 7570 6461 7465 te) state_update │ │ │ +0004b430: 6428 293b 0a09 096d 5f6d 6178 5f63 6f6e d();...m_max_con │ │ │ +0004b440: 6e65 6374 696f 6e73 203d 2061 7578 3a3a nections = aux:: │ │ │ +0004b450: 6e75 6d65 7269 635f 6361 7374 266c 743b numeric_cast< │ │ │ +0004b460: 7374 643a 3a75 696e 7433 325f 7426 6774 std::uint32_t> │ │ │ +0004b470: 3b28 6c69 6d69 7429 3b0a 0909 7570 6461 ;(limit);...upda │ │ │ +0004b480: 7465 5f77 616e 745f 7065 6572 7328 293b te_want_peers(); │ │ │ +0004b490: 0a0a 2369 666e 6465 6620 544f 5252 454e ..#ifndef TORREN │ │ │ +0004b4a0: 545f 4449 5341 424c 455f 4c4f 4747 494e T_DISABLE_LOGGIN │ │ │ +0004b4b0: 470a 0909 6966 2028 7368 6f75 6c64 5f6c G...if (should_l │ │ │ +0004b4c0: 6f67 2829 2026 616d 703b 2661 6d70 3b20 og() && │ │ │ +0004b4d0: 7374 6174 655f 7570 6461 7465 290a 0909 state_update)... │ │ │ +0004b4e0: 0964 6562 7567 5f6c 6f67 2822 2a2a 2a20 .debug_log("*** │ │ │ +0004b4f0: 7365 742d 6d61 782d 636f 6e6e 6563 7469 set-max-connecti │ │ │ +0004b500: 6f6e 733a 2025 6422 2c20 6d5f 6d61 785f ons: %d", m_max_ │ │ │ +0004b510: 636f 6e6e 6563 7469 6f6e 7329 3b0a 2365 connections);.#e │ │ │ +0004b520: 6e64 6966 0a0a 0909 6966 2028 6e75 6d5f ndif....if (num_ │ │ │ +0004b530: 7065 6572 7328 2920 2667 743b 2069 6e74 peers() > int │ │ │ +0004b540: 286d 5f6d 6178 5f63 6f6e 6e65 6374 696f (m_max_connectio │ │ │ +0004b550: 6e73 2929 0a09 097b 0a09 0909 6469 7363 ns))...{....disc │ │ │ +0004b560: 6f6e 6e65 6374 5f70 6565 7273 286e 756d onnect_peers(num │ │ │ +0004b570: 5f70 6565 7273 2829 202d 206d 5f6d 6178 _peers() - m_max │ │ │ +0004b580: 5f63 6f6e 6e65 6374 696f 6e73 0a09 0909 _connections.... │ │ │ +0004b590: 092c 2065 7272 6f72 733a 3a74 6f6f 5f6d ., errors::too_m │ │ │ +0004b5a0: 616e 795f 636f 6e6e 6563 7469 6f6e 7329 any_connections) │ │ │ +0004b5b0: 3b0a 0909 7d0a 0a09 0969 6620 2873 7461 ;...}....if (sta │ │ │ +0004b5c0: 7465 5f75 7064 6174 6529 0a09 0909 7365 te_update)....se │ │ │ +0004b5d0: 745f 6e65 6564 5f73 6176 655f 7265 7375 t_need_save_resu │ │ │ +0004b5e0: 6d65 2874 6f72 7265 6e74 5f68 616e 646c me(torrent_handl │ │ │ +0004b5f0: 653a 3a69 665f 636f 6e66 6967 5f63 6861 e::if_config_cha │ │ │ +0004b600: 6e67 6564 293b 0a09 7d0a 0a09 766f 6964 nged);..}...void │ │ │ +0004b610: 2074 6f72 7265 6e74 3a3a 7365 745f 7570 torrent::set_up │ │ │ +0004b620: 6c6f 6164 5f6c 696d 6974 2869 6e74 2063 load_limit(int c │ │ │ +0004b630: 6f6e 7374 206c 696d 6974 290a 097b 0a09 onst limit)..{.. │ │ │ +0004b640: 0973 6574 5f6c 696d 6974 5f69 6d70 6c28 .set_limit_impl( │ │ │ +0004b650: 6c69 6d69 742c 2070 6565 725f 636f 6e6e limit, peer_conn │ │ │ +0004b660: 6563 7469 6f6e 3a3a 7570 6c6f 6164 5f63 ection::upload_c │ │ │ +0004b670: 6861 6e6e 656c 293b 0a23 6966 6e64 6566 hannel);.#ifndef │ │ │ +0004b680: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ +0004b690: 5f4c 4f47 4749 4e47 0a09 0964 6562 7567 _LOGGING...debug │ │ │ +0004b6a0: 5f6c 6f67 2822 2a2a 2a20 7365 742d 7570 _log("*** set-up │ │ │ +0004b6b0: 6c6f 6164 2d6c 696d 6974 3a20 2564 222c load-limit: %d", │ │ │ +0004b6c0: 206c 696d 6974 293b 0a23 656e 6469 660a limit);.#endif. │ │ │ +0004b6d0: 097d 0a0a 0976 6f69 6420 746f 7272 656e .}...void torren │ │ │ +0004b6e0: 743a 3a73 6574 5f64 6f77 6e6c 6f61 645f t::set_download_ │ │ │ +0004b6f0: 6c69 6d69 7428 696e 7420 636f 6e73 7420 limit(int const │ │ │ +0004b700: 6c69 6d69 7429 0a09 7b0a 3c2f 7072 653e limit)..{.
    │ │ │ +0004b710: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +0004b740: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +0004b750: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/torr │ │ │ +0004b780: 656e 742e 6370 703a 3131 3237 303c 2f61 ent.cpp:11270instea │ │ │ +0004b7a0: 6420 6f66 2072 6573 6f72 7469 6e67 2074 d of resorting t │ │ │ +0004b7b0: 6865 2077 686f 6c65 206c 6973 742c 2069 he whole list, i │ │ │ +0004b7c0: 6e73 6572 7420 7468 6520 7065 6572 7320 nsert the peers │ │ │ +0004b7d0: 6469 7265 6374 6c79 2069 6e74 6f20 7468 directly into th │ │ │ +0004b7e0: 6520 7269 6768 7420 706c 6163 653c 2f74 e right place

    inste │ │ │ +0004b840: 6164 206f 6620 7265 736f 7274 696e 6720 ad of resorting │ │ │ +0004b850: 7468 6520 7768 6f6c 6520 6c69 7374 2c20 the whole list, │ │ │ +0004b860: 696e 7365 7274 2074 6865 2070 6565 7273 insert the peers │ │ │ +0004b870: 0a64 6972 6563 746c 7920 696e 746f 2074 .directly into t │ │ │ +0004b880: 6865 2072 6967 6874 2070 6c61 6365 3c2f he right place

    ../src/to │ │ │ +0004b8a0: 7272 656e 742e 6370 703a 3131 3237 303c rrent.cpp:11270< │ │ │ +0004b8b0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +0004b8f0: 0909 7374 643a 3a70 7269 6e74 6628 2274  ..std::printf("t
    │ │ │ +0004b900: 696d 6564 206f 7574 205b 6176 6572 6167  imed out [averag
    │ │ │ +0004b910: 652d 7069 6563 652d 7469 6d65 3a20 2564  e-piece-time: %d
    │ │ │ +0004b920: 206d 7320 5d5c 6e22 0a09 0909 0909 2c20   ms ]\n"......, 
    │ │ │ +0004b930: 6d5f 6176 6572 6167 655f 7069 6563 655f  m_average_piece_
    │ │ │ +0004b940: 7469 6d65 293b 0a23 656e 6469 660a 0909  time);.#endif...
    │ │ │ +0004b950: 097d 0a0a 0909 092f 2f20 7069 636b 2061  .}.....// pick a
    │ │ │ +0004b960: 6c6c 2062 6c6f 636b 7320 666f 7220 7468  ll blocks for th
    │ │ │ +0004b970: 6973 2070 6965 6365 2e20 7468 6520 7065  is piece. the pe
    │ │ │ +0004b980: 6572 7320 6c69 7374 2069 7320 6b65 7074  ers list is kept
    │ │ │ +0004b990: 2075 7020 746f 2064 6174 650a 0909 092f   up to date..../
    │ │ │ +0004b9a0: 2f20 616e 6420 736f 7274 6564 2e20 7768  / and sorted. wh
    │ │ │ +0004b9b0: 656e 2077 6520 6973 7375 6520 6120 7265  en we issue a re
    │ │ │ +0004b9c0: 7175 6573 7420 746f 2061 2070 6565 722c  quest to a peer,
    │ │ │ +0004b9d0: 2069 7473 2064 6f77 6e6c 6f61 6420 7175   its download qu
    │ │ │ +0004b9e0: 6575 650a 0909 092f 2f20 7469 6d65 2077  eue....// time w
    │ │ │ +0004b9f0: 696c 6c20 696e 6372 6561 7365 2061 6e64  ill increase and
    │ │ │ +0004ba00: 2069 7420 6d61 7920 6e65 6564 2074 6f20   it may need to 
    │ │ │ +0004ba10: 6265 2062 756d 7065 6420 696e 2074 6865  be bumped in the
    │ │ │ +0004ba20: 2070 6565 7273 206c 6973 742c 0a09 0909   peers list,....
    │ │ │ +0004ba30: 2f2f 2073 696e 6365 2069 7427 7320 6f72  // since it's or
    │ │ │ +0004ba40: 6465 7265 6420 6279 2064 6f77 6e6c 6f61  dered by downloa
    │ │ │ +0004ba50: 6420 7175 6575 6520 7469 6d65 0a09 0909  d queue time....
    │ │ │ +0004ba60: 7069 636b 5f74 696d 655f 6372 6974 6963  pick_time_critic
    │ │ │ +0004ba70: 616c 5f62 6c6f 636b 2870 6565 7273 2c20  al_block(peers, 
    │ │ │ +0004ba80: 6967 6e6f 7265 5f70 6565 7273 0a09 0909  ignore_peers....
    │ │ │ +0004ba90: 092c 2070 6565 7273 5f77 6974 685f 7265  ., peers_with_re
    │ │ │ +0004baa0: 7175 6573 7473 0a09 0909 092c 2070 692c  quests....., pi,
    │ │ │ +0004bab0: 2026 616d 703b 692c 206d 5f70 6963 6b65   &i, m_picke
    │ │ │ +0004bac0: 722e 6765 7428 290a 0909 0909 2c20 626c  r.get()....., bl
    │ │ │ +0004bad0: 6f63 6b73 5f69 6e5f 7069 6563 652c 2074  ocks_in_piece, t
    │ │ │ +0004bae0: 696d 6564 5f6f 7574 293b 0a0a 0909 092f  imed_out);...../
    │ │ │ +0004baf0: 2f20 7075 7420 6261 636b 2074 6865 2070  / put back the p
    │ │ │ +0004bb00: 6565 7273 2077 6520 6967 6e6f 7265 6420  eers we ignored 
    │ │ │ +0004bb10: 696e 746f 2074 6865 2070 6565 7220 6c69  into the peer li
    │ │ │ +0004bb20: 7374 2066 6f72 2074 6865 206e 6578 7420  st for the next 
    │ │ │ +0004bb30: 7069 6563 650a 0909 0969 6620 2821 6967  piece....if (!ig
    │ │ │ +0004bb40: 6e6f 7265 5f70 6565 7273 2e65 6d70 7479  nore_peers.empty
    │ │ │ +0004bb50: 2829 290a 0909 097b 0a09 0909 0970 6565  ())....{.....pee
    │ │ │ +0004bb60: 7273 2e69 6e73 6572 7428 7065 6572 732e  rs.insert(peers.
    │ │ │ +0004bb70: 6265 6769 6e28 292c 2069 676e 6f72 655f  begin(), ignore_
    │ │ │ +0004bb80: 7065 6572 732e 6265 6769 6e28 292c 2069  peers.begin(), i
    │ │ │ +0004bb90: 676e 6f72 655f 7065 6572 732e 656e 6428  gnore_peers.end(
    │ │ │ +0004bba0: 2929 3b0a 0909 0909 6967 6e6f 7265 5f70  ));.....ignore_p
    │ │ │ +0004bbb0: 6565 7273 2e63 6c65 6172 2829 3b0a 0a3c  eers.clear();..<
    │ │ │ +0004bbc0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +0004bbd0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +0004bbe0: 7769 6474 683d 2231 3030 2522 3e09 0909  width="100%">...
    │ │ │ +0004bbf0: 0973 7464 3a3a 736f 7274 2870 6565 7273  .std::sort(peers
    │ │ │ +0004bc00: 2e62 6567 696e 2829 2c20 7065 6572 732e  .begin(), peers.
    │ │ │ +0004bc10: 656e 6428 290a 3c2f 6469 763e 0909 0909  end().....
    │ │ │ +0004bc20: 092c 205b 5d20 2870 6565 725f 636f 6e6e  ., [] (peer_conn
    │ │ │ +0004bc30: 6563 7469 6f6e 2063 6f6e 7374 2a20 6c68  ection const* lh
    │ │ │ +0004bc40: 732c 2070 6565 725f 636f 6e6e 6563 7469  s, peer_connecti
    │ │ │ +0004bc50: 6f6e 2063 6f6e 7374 2a20 7268 7329 0a09  on const* rhs)..
    │ │ │ +0004bc60: 0909 0909 7b20 7265 7475 726e 206c 6873  ....{ return lhs
    │ │ │ +0004bc70: 2d26 6774 3b64 6f77 6e6c 6f61 645f 7175  ->download_qu
    │ │ │ +0004bc80: 6575 655f 7469 6d65 2831 362a 3130 3234  eue_time(16*1024
    │ │ │ +0004bc90: 2920 266c 743b 2072 6873 2d26 6774 3b64  ) < rhs->d
    │ │ │ +0004bca0: 6f77 6e6c 6f61 645f 7175 6575 655f 7469  ownload_queue_ti
    │ │ │ +0004bcb0: 6d65 2831 362a 3130 3234 293b 207d 293b  me(16*1024); });
    │ │ │ +0004bcc0: 0a09 0909 7d0a 0a09 0909 2f2f 2069 6620  ....}.....// if 
    │ │ │ +0004bcd0: 7468 6973 2070 6565 7227 7320 646f 776e  this peer's down
    │ │ │ +0004bce0: 6c6f 6164 2074 696d 6520 6578 6365 6564  load time exceed
    │ │ │ +0004bcf0: 7320 3220 7365 636f 6e64 732c 2077 6527  s 2 seconds, we'
    │ │ │ +0004bd00: 7265 2064 6f6e 652e 0a09 0909 2f2f 2057  re done.....// W
    │ │ │ +0004bd10: 6520 646f 6e27 7420 7761 6e74 2074 6f20  e don't want to 
    │ │ │ +0004bd20: 6275 696c 6420 756e 7265 6173 6f6e 6162  build unreasonab
    │ │ │ +0004bd30: 6c79 206c 6f6e 6720 7265 7175 6573 7420  ly long request 
    │ │ │ +0004bd40: 7175 6575 6573 0a09 0909 6966 2028 2170  queues....if (!p
    │ │ │ +0004bd50: 6565 7273 2e65 6d70 7479 2829 2026 616d  eers.empty() &am
    │ │ │ +0004bd60: 703b 2661 6d70 3b20 7065 6572 735b 305d  p;& peers[0]
    │ │ │ +0004bd70: 2d26 6774 3b64 6f77 6e6c 6f61 645f 7175  ->download_qu
    │ │ │ +0004bd80: 6575 655f 7469 6d65 2829 2026 6774 3b20  eue_time() > 
    │ │ │ +0004bd90: 6d69 6c6c 6973 6563 6f6e 6473 2832 3030  milliseconds(200
    │ │ │ +0004bda0: 3029 290a 0909 0909 6272 6561 6b3b 0a09  0)).....break;..
    │ │ │ +0004bdb0: 097d 0a0a 0909 2f2f 2063 6f6d 6d69 7420  .}....// commit 
    │ │ │ +0004bdc0: 616c 6c20 7468 6520 7469 6d65 2063 7269  all the time cri
    │ │ │ +0004bdd0: 7469 6361 6c20 7265 7175 6573 7473 0a09  tical requests..
    │ │ │ +0004bde0: 0966 6f72 2028 6175 746f 2070 203a 2070  .for (auto p : p
    │ │ │ +0004bdf0: 6565 7273 5f77 6974 685f 7265 7175 6573  eers_with_reques
    │ │ │ +0004be00: 7473 290a 0909 7b0a 0909 0970 2d26 6774  ts)...{....p->
    │ │ │ +0004be10: 3b73 656e 645f 626c 6f63 6b5f 7265 7175  ;send_block_requ
    │ │ │ +0004be20: 6573 7473 2829 3b0a 0909 7d0a 097d 0a23  ests();...}..}.#
    │ │ │ +0004be30: 656e 6469 6620 2f2f 2054 4f52 5245 4e54  endif // TORRENT
    │ │ │ +0004be40: 5f44 4953 4142 4c45 5f53 5452 4541 4d49  _DISABLE_STREAMI
    │ │ │ +0004be50: 4e47 0a0a 0973 7464 3a3a 7365 7426 6c74  NG...std::set<
    │ │ │ +0004be60: 3b73 7464 3a3a 7374 7269 6e67 2667 743b  ;std::string>
    │ │ │ +0004be70: 2074 6f72 7265 6e74 3a3a 7765 625f 7365   torrent::web_se
    │ │ │ +0004be80: 6564 7328 7765 625f 7365 6564 5f65 6e74  eds(web_seed_ent
    │ │ │ +0004be90: 7279 3a3a 7479 7065 5f74 2063 6f6e 7374  ry::type_t const
    │ │ │ +0004bea0: 2074 7970 6529 2063 6f6e 7374 0a09 7b0a   type) const..{.
    │ │ │ +0004beb0: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ +0004bec0: 2869 735f 7369 6e67 6c65 5f74 6872 6561  (is_single_threa
    │ │ │ +0004bed0: 6428 2929 3b0a 0909 7374 643a 3a73 6574  d());...std::set
    │ │ │ +0004bee0: 266c 743b 7374 643a 3a73 7472 696e 6726  <std::string&
    │ │ │ +0004bef0: 6774 3b20 7265 743b 0a09 0966 6f72 2028  gt; ret;...for (
    │ │ │ +0004bf00: 6175 746f 2063 6f6e 7374 2661 6d70 3b20  auto const& 
    │ │ │ +0004bf10: 7320 3a20 6d5f 7765 625f 7365 6564 7329  s : m_web_seeds)
    │ │ │ +0004bf20: 0a09 097b 0a09 0909 6966 2028 732e 7065  ...{....if (s.pe
    │ │ │ +0004bf30: 6572 5f69 6e66 6f2e 6261 6e6e 6564 2920  er_info.banned) 
    │ │ │ +0004bf40: 636f 6e74 696e 7565 3b0a 0909 0969 6620  continue;....if 
    │ │ │ +0004bf50: 2873 2e72 656d 6f76 6564 2920 636f 6e74  (s.removed) cont
    │ │ │ +0004bf60: 696e 7565 3b0a 0909 0969 6620 2873 2e74  inue;....if (s.t
    │ │ │ +0004bf70: 7970 6520 213d 2074 7970 6529 2063 6f6e  ype != type) con
    │ │ │ +0004bf80: 7469 6e75 653b 0a09 0909 7265 742e 696e  tinue;....ret.in
    │ │ │ +0004bf90: 7365 7274 2873 2e75 726c 293b 0a09 097d  sert(s.url);...}
    │ │ │ +0004bfa0: 0a09 0972 6574 7572 6e20 7265 743b 0a3c  ...return ret;.<
    │ │ │ +0004bfb0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ +0004bfc0: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ +0004bfd0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ +0004bfe0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ +0004bff0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../src
    │ │ │ +0004c020: 2f77 6562 5f63 6f6e 6e65 6374 696f 6e5f  /web_connection_
    │ │ │ +0004c030: 6261 7365 2e63 7070 3a37 333c 2f61 3e3c  base.cpp:73<
    │ │ │ +0004c040: 2f74 643e 3c74 643e 696e 7472 6f64 7563  /td>introduc
    │ │ │ +0004c050: 6520 6120 7765 622d 7365 6564 2064 6566  e a web-seed def
    │ │ │ +0004c060: 6175 6c74 2063 6c61 7373 2077 6869 6368  ault class which
    │ │ │ +0004c070: 2068 6173 2061 206c 6f77 2064 6f77 6e6c   has a low downl
    │ │ │ +0004c080: 6f61 6420 7072 696f 7269 7479 3c2f 7464  oad priority

    introd │ │ │ +0004c0e0: 7563 6520 6120 7765 622d 7365 6564 2064 uce a web-seed d │ │ │ +0004c0f0: 6566 6175 6c74 2063 6c61 7373 2077 6869 efault class whi │ │ │ +0004c100: 6368 2068 6173 2061 206c 6f77 2064 6f77 ch has a low dow │ │ │ +0004c110: 6e6c 6f61 6420 7072 696f 7269 7479 3c2f nload priority

    ../src/we │ │ │ +0004c130: 625f 636f 6e6e 6563 7469 6f6e 5f62 6173 b_connection_bas │ │ │ +0004c140: 652e 6370 703a 3733 3c2f 6834 3e3c 7072 e.cpp:73

    ..: peer_ │ │ │ +0004c190: 636f 6e6e 6563 7469 6f6e 2870 6163 6b29 connection(pack) │ │ │ +0004c1a0: 0a09 092c 206d 5f66 6972 7374 5f72 6571 ..., m_first_req │ │ │ +0004c1b0: 7565 7374 2874 7275 6529 0a09 092c 206d uest(true)..., m │ │ │ +0004c1c0: 5f73 736c 2866 616c 7365 290a 0909 2c20 _ssl(false)..., │ │ │ +0004c1d0: 6d5f 6578 7465 726e 616c 5f61 7574 6828 m_external_auth( │ │ │ +0004c1e0: 7765 622e 6175 7468 290a 0909 2c20 6d5f web.auth)..., m_ │ │ │ +0004c1f0: 6578 7472 615f 6865 6164 6572 7328 7765 extra_headers(we │ │ │ +0004c200: 622e 6578 7472 615f 6865 6164 6572 7329 b.extra_headers) │ │ │ +0004c210: 0a09 092c 206d 5f70 6172 7365 7228 6874 ..., m_parser(ht │ │ │ +0004c220: 7470 5f70 6172 7365 723a 3a64 6f6e 745f tp_parser::dont_ │ │ │ +0004c230: 7061 7273 655f 6368 756e 6b73 290a 0909 parse_chunks)... │ │ │ +0004c240: 2c20 6d5f 626f 6479 5f73 7461 7274 2830 , m_body_start(0 │ │ │ +0004c250: 290a 097b 0a09 0954 4f52 5245 4e54 5f41 )..{...TORRENT_A │ │ │ +0004c260: 5353 4552 5428 2661 6d70 3b77 6562 2e70 SSERT(&web.p │ │ │ +0004c270: 6565 725f 696e 666f 203d 3d20 7061 636b eer_info == pack │ │ │ +0004c280: 2e70 6565 7269 6e66 6f29 3b0a 0909 2f2f .peerinfo);...// │ │ │ +0004c290: 2077 6865 6e20 676f 696e 6720 7468 726f when going thro │ │ │ +0004c2a0: 7567 6820 6120 7072 6f78 792c 2077 6520 ugh a proxy, we │ │ │ +0004c2b0: 646f 6e27 7420 6e65 6365 7373 6172 696c don't necessaril │ │ │ +0004c2c0: 7920 6861 7665 2061 6e20 656e 6470 6f69 y have an endpoi │ │ │ +0004c2d0: 6e74 2068 6572 652c 0a09 092f 2f20 7369 nt here,...// si │ │ │ +0004c2e0: 6e63 6520 7468 6520 7072 6f78 7920 6d69 nce the proxy mi │ │ │ +0004c2f0: 6768 7420 6265 2072 6573 6f6c 7669 6e67 ght be resolving │ │ │ +0004c300: 2074 6865 2068 6f73 746e 616d 652c 206e the hostname, n │ │ │ +0004c310: 6f74 2075 730a 0909 544f 5252 454e 545f ot us...TORRENT_ │ │ │ +0004c320: 4153 5345 5254 2877 6562 2e65 6e64 706f ASSERT(web.endpo │ │ │ +0004c330: 696e 7473 2e65 6d70 7479 2829 207c 7c20 ints.empty() || │ │ │ +0004c340: 7765 622e 656e 6470 6f69 6e74 732e 6672 web.endpoints.fr │ │ │ +0004c350: 6f6e 7428 2920 3d3d 2070 6163 6b2e 656e ont() == pack.en │ │ │ +0004c360: 6470 293b 0a0a 0909 494e 5641 5249 414e dp);....INVARIAN │ │ │ +0004c370: 545f 4348 4543 4b3b 0a0a 0909 544f 5252 T_CHECK;....TORR │ │ │ +0004c380: 454e 545f 4153 5345 5254 2869 735f 6f75 ENT_ASSERT(is_ou │ │ │ +0004c390: 7467 6f69 6e67 2829 293b 0a0a 0909 544f tgoing());....TO │ │ │ +0004c3a0: 5252 454e 545f 4153 5345 5254 2821 6d5f RRENT_ASSERT(!m_ │ │ │ +0004c3b0: 746f 7272 656e 742e 6c6f 636b 2829 2d26 torrent.lock()-& │ │ │ +0004c3c0: 6774 3b69 735f 7570 6c6f 6164 5f6f 6e6c gt;is_upload_onl │ │ │ +0004c3d0: 7928 2929 3b0a 0a09 092f 2f20 7765 206f y());....// we o │ │ │ +0004c3e0: 6e6c 7920 7761 6e74 206c 6566 742d 6f76 nly want left-ov │ │ │ +0004c3f0: 6572 2062 616e 6477 6964 7468 0a3c 6469 er bandwidth....std::string │ │ │ +0004c440: 7072 6f74 6f63 6f6c 3b0a 0909 6572 726f protocol;...erro │ │ │ +0004c450: 725f 636f 6465 2065 633b 0a09 0973 7464 r_code ec;...std │ │ │ +0004c460: 3a3a 7469 6528 7072 6f74 6f63 6f6c 2c20 ::tie(protocol, │ │ │ +0004c470: 6d5f 6261 7369 635f 6175 7468 2c20 6d5f m_basic_auth, m_ │ │ │ +0004c480: 686f 7374 2c20 6d5f 706f 7274 2c20 6d5f host, m_port, m_ │ │ │ +0004c490: 7061 7468 290a 0909 093d 2070 6172 7365 path)....= parse │ │ │ +0004c4a0: 5f75 726c 5f63 6f6d 706f 6e65 6e74 7328 _url_components( │ │ │ +0004c4b0: 7765 622e 7572 6c2c 2065 6329 3b0a 0909 web.url, ec);... │ │ │ +0004c4c0: 544f 5252 454e 545f 4153 5345 5254 2821 TORRENT_ASSERT(! │ │ │ +0004c4d0: 6563 293b 0a0a 0909 6966 2028 6d5f 706f ec);....if (m_po │ │ │ +0004c4e0: 7274 203d 3d20 2d31 2026 616d 703b 2661 rt == -1 &&a │ │ │ +0004c4f0: 6d70 3b20 7072 6f74 6f63 6f6c 203d 3d20 mp; protocol == │ │ │ +0004c500: 2268 7474 7022 290a 0909 096d 5f70 6f72 "http")....m_por │ │ │ +0004c510: 7420 3d20 3830 3b0a 0a23 6966 2054 4f52 t = 80;..#if TOR │ │ │ +0004c520: 5245 4e54 5f55 5345 5f53 534c 0a09 0969 RENT_USE_SSL...i │ │ │ +0004c530: 6620 2870 726f 746f 636f 6c20 3d3d 2022 f (protocol == " │ │ │ +0004c540: 6874 7470 7322 290a 0909 7b0a 0909 096d https")...{....m │ │ │ +0004c550: 5f73 736c 203d 2074 7275 653b 0a09 0909 _ssl = true;.... │ │ │ +0004c560: 6966 2028 6d5f 706f 7274 203d 3d20 2d31 if (m_port == -1 │ │ │ +0004c570: 2920 6d5f 706f 7274 203d 2034 3433 3b0a ) m_port = 443;. │ │ │ +0004c580: 0909 7d0a 2365 6e64 6966 0a0a 0909 6966 ..}.#endif....if │ │ │ +0004c590: 2028 216d 5f62 6173 6963 5f61 7574 682e (!m_basic_auth. │ │ │ +0004c5a0: 656d 7074 7928 2929 0a09 0909 6d5f 6261 empty())....m_ba │ │ │ +0004c5b0: 7369 635f 6175 7468 203d 2062 6173 6536 sic_auth = base6 │ │ │ +0004c5c0: 3465 6e63 6f64 6528 6d5f 6261 7369 635f 4encode(m_basic_ │ │ │ +0004c5d0: 6175 7468 293b 0a0a 0909 6d5f 7365 7276 auth);....m_serv │ │ │ +0004c5e0: 6572 5f73 7472 696e 6720 3d20 6d5f 686f er_string = m_ho │ │ │ +0004c5f0: 7374 3b0a 0909 6175 783a 3a76 6572 6966 st;...aux::verif │ │ │ +0004c600: 795f 656e 636f 6469 6e67 286d 5f73 6572 y_encoding(m_ser │ │ │ +0004c610: 7665 725f 7374 7269 6e67 293b 0a09 7d0a ver_string);..}. │ │ │ +0004c620: 0a09 696e 7420 7765 625f 636f 6e6e 6563 ..int web_connec │ │ │ +0004c630: 7469 6f6e 5f62 6173 653a 3a74 696d 656f tion_base::timeo │ │ │ +0004c640: 7574 2829 2063 6f6e 7374 0a09 7b0a 0909 ut() const..{... │ │ │ +0004c650: 2f2f 2073 696e 6365 2074 6869 7320 6973 // since this is │ │ │ +0004c660: 2061 2077 6562 2073 6565 642c 2063 6861 a web seed, cha │ │ │ +0004c670: 6e67 6520 7468 6520 7469 6d65 6f75 740a nge the timeout. │ │ │ +0004c680: 0909 2f2f 2061 6363 6f72 6469 6e67 2074 ..// according t │ │ │ +0004c690: 6f20 7468 6520 7365 7474 696e 6773 2e0a o the settings.. │ │ │ +0004c6a0: 0909 7265 7475 726e 206d 5f73 6574 7469 ..return m_setti │ │ │ +0004c6b0: 6e67 732e 6765 745f 696e 7428 7365 7474 ngs.get_int(sett │ │ │ +0004c6c0: 696e 6773 5f70 6163 6b3a 3a75 726c 7365 ings_pack::urlse │ │ │ +0004c6d0: 6564 5f74 696d 656f 7574 293b 0a09 7d0a ed_timeout);..}. │ │ │ +0004c6e0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +0004c6f0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +0004c720: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +0004c750: 632f 7374 6f72 6167 655f 7574 696c 732e c/storage_utils. │ │ │ +0004c760: 6370 703a 3233 313c 2f61 3e3c 2f74 643e cpp:231 │ │ │ +0004c770: 3c74 643e 6964 6561 6c6c 792c 2069 6620 ideally, if │ │ │ +0004c780: 7765 2065 6e64 2075 7020 636f 7079 696e we end up copyin │ │ │ +0004c790: 6720 6669 6c65 7320 6265 6361 7573 6520 g files because │ │ │ +0004c7a0: 6f66 2061 206d 6f76 6520 6163 726f 7373 of a move across │ │ │ +0004c7b0: 2076 6f6c 756d 6573 2c20 7468 6520 736f volumes, the so │ │ │ +0004c7c0: 7572 6365 2073 686f 756c 6420 6e6f 7420 urce should not │ │ │ +0004c7d0: 6265 2064 656c 6574 6564 2075 6e74 696c be deleted until │ │ │ +0004c7e0: 2074 6865 7927 7665 2061 6c6c 2062 6565 they've all bee │ │ │ +0004c7f0: 6e20 636f 7069 6564 2e20 5468 6174 2077 n copied. That w │ │ │ +0004c800: 6f75 6c64 206c 6574 2075 7320 726f 6c6c ould let us roll │ │ │ +0004c810: 6261 636b 2077 6974 6820 6869 6768 6572 back with higher │ │ │ +0004c820: 2063 6f6e 6669 6465 6e63 652e 3c2f 7464 confidence.

    ideall │ │ │ +0004c880: 792c 2069 6620 7765 2065 6e64 2075 7020 y, if we end up │ │ │ +0004c890: 636f 7079 696e 6720 6669 6c65 7320 6265 copying files be │ │ │ +0004c8a0: 6361 7573 6520 6f66 2061 206d 6f76 6520 cause of a move │ │ │ +0004c8b0: 6163 726f 7373 0a76 6f6c 756d 6573 2c20 across.volumes, │ │ │ +0004c8c0: 7468 6520 736f 7572 6365 2073 686f 756c the source shoul │ │ │ +0004c8d0: 6420 6e6f 7420 6265 2064 656c 6574 6564 d not be deleted │ │ │ +0004c8e0: 2075 6e74 696c 2074 6865 7927 7665 2061 until they've a │ │ │ +0004c8f0: 6c6c 2062 6565 6e0a 636f 7069 6564 2e20 ll been.copied. │ │ │ +0004c900: 5468 6174 2077 6f75 6c64 206c 6574 2075 That would let u │ │ │ +0004c910: 7320 726f 6c6c 6261 636b 2077 6974 6820 s rollback with │ │ │ +0004c920: 6869 6768 6572 2063 6f6e 6669 6465 6e63 higher confidenc │ │ │ +0004c930: 652e 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 e.

    ../sr │ │ │ +0004c940: 632f 7374 6f72 6167 655f 7574 696c 732e c/storage_utils. │ │ │ +0004c950: 6370 703a 3233 313c 2f68 343e 3c70 7265 cpp:231

    ..// later
    │ │ │ +0004c9a0: 0a09 0961 7578 3a3a 7665 6374 6f72 266c  ...aux::vector&l
    │ │ │ +0004c9b0: 743b 626f 6f6c 2c20 6669 6c65 5f69 6e64  t;bool, file_ind
    │ │ │ +0004c9c0: 6578 5f74 2667 743b 2063 6f70 6965 645f  ex_t> copied_
    │ │ │ +0004c9d0: 6669 6c65 7328 7374 643a 3a73 697a 655f  files(std::size_
    │ │ │ +0004c9e0: 7428 662e 6e75 6d5f 6669 6c65 7328 2929  t(f.num_files())
    │ │ │ +0004c9f0: 2c20 6661 6c73 6529 3b0a 0a09 092f 2f20  , false);....// 
    │ │ │ +0004ca00: 7472 6163 6b20 686f 7720 6661 7220 7765  track how far we
    │ │ │ +0004ca10: 2067 6f74 2069 6e20 6361 7365 206f 6620   got in case of 
    │ │ │ +0004ca20: 616e 2065 7272 6f72 0a09 0966 696c 655f  an error...file_
    │ │ │ +0004ca30: 696e 6465 785f 7420 6669 6c65 5f69 6e64  index_t file_ind
    │ │ │ +0004ca40: 6578 7b7d 3b0a 0909 666f 7220 2861 7574  ex{};...for (aut
    │ │ │ +0004ca50: 6f20 636f 6e73 7420 6920 3a20 662e 6669  o const i : f.fi
    │ │ │ +0004ca60: 6c65 5f72 616e 6765 2829 290a 0909 7b0a  le_range())...{.
    │ │ │ +0004ca70: 0909 092f 2f20 6669 6c65 7320 6d6f 7665  ...// files move
    │ │ │ +0004ca80: 6420 6f75 7420 746f 2061 6273 6f6c 7574  d out to absolut
    │ │ │ +0004ca90: 6520 7061 7468 7320 6172 6520 6e6f 7420  e paths are not 
    │ │ │ +0004caa0: 6d6f 7665 640a 0909 0969 6620 2866 2e66  moved....if (f.f
    │ │ │ +0004cab0: 696c 655f 6162 736f 6c75 7465 5f70 6174  ile_absolute_pat
    │ │ │ +0004cac0: 6828 6929 2920 636f 6e74 696e 7565 3b0a  h(i)) continue;.
    │ │ │ +0004cad0: 0a09 0909 7374 643a 3a73 7472 696e 6720  ....std::string 
    │ │ │ +0004cae0: 636f 6e73 7420 6f6c 645f 7061 7468 203d  const old_path =
    │ │ │ +0004caf0: 2063 6f6d 6269 6e65 5f70 6174 6828 7361   combine_path(sa
    │ │ │ +0004cb00: 7665 5f70 6174 682c 2066 2e66 696c 655f  ve_path, f.file_
    │ │ │ +0004cb10: 7061 7468 2869 2929 3b0a 0909 0973 7464  path(i));....std
    │ │ │ +0004cb20: 3a3a 7374 7269 6e67 2063 6f6e 7374 206e  ::string const n
    │ │ │ +0004cb30: 6577 5f70 6174 6820 3d20 636f 6d62 696e  ew_path = combin
    │ │ │ +0004cb40: 655f 7061 7468 286e 6577 5f73 6176 655f  e_path(new_save_
    │ │ │ +0004cb50: 7061 7468 2c20 662e 6669 6c65 5f70 6174  path, f.file_pat
    │ │ │ +0004cb60: 6828 6929 293b 0a0a 0909 0965 7272 6f72  h(i));.....error
    │ │ │ +0004cb70: 5f63 6f64 6520 6967 6e6f 7265 3b0a 0909  _code ignore;...
    │ │ │ +0004cb80: 0969 6620 2866 6c61 6773 203d 3d20 6d6f  .if (flags == mo
    │ │ │ +0004cb90: 7665 5f66 6c61 6773 5f74 3a3a 646f 6e74  ve_flags_t::dont
    │ │ │ +0004cba0: 5f72 6570 6c61 6365 2026 616d 703b 2661  _replace &&a
    │ │ │ +0004cbb0: 6d70 3b20 6578 6973 7473 286e 6577 5f70  mp; exists(new_p
    │ │ │ +0004cbc0: 6174 682c 2069 676e 6f72 6529 290a 0909  ath, ignore))...
    │ │ │ +0004cbd0: 097b 0a09 0909 0969 6620 2872 6574 203d  .{.....if (ret =
    │ │ │ +0004cbe0: 3d20 7374 6174 7573 5f74 3a3a 6e6f 5f65  = status_t::no_e
    │ │ │ +0004cbf0: 7272 6f72 2920 7265 7420 3d20 7374 6174  rror) ret = stat
    │ │ │ +0004cc00: 7573 5f74 3a3a 6e65 6564 5f66 756c 6c5f  us_t::need_full_
    │ │ │ +0004cc10: 6368 6563 6b3b 0a09 0909 0963 6f6e 7469  check;.....conti
    │ │ │ +0004cc20: 6e75 653b 0a09 0909 7d0a 0a3c 6469 7620  nue;....}..
    ...move │ │ │ +0004cc60: 5f66 696c 6528 6f6c 645f 7061 7468 2c20 _file(old_path, │ │ │ +0004cc70: 6e65 775f 7061 7468 2c20 6563 293b 0a3c new_path, ec);.< │ │ │ +0004cc80: 2f64 6976 3e0a 0909 092f 2f20 6966 2074 /div>....// if t │ │ │ +0004cc90: 6865 2073 6f75 7263 6520 6669 6c65 2064 he source file d │ │ │ +0004cca0: 6f65 736e 2774 2065 7869 7374 2e20 5468 oesn't exist. Th │ │ │ +0004ccb0: 6174 2773 206e 6f74 2061 2070 726f 626c at's not a probl │ │ │ +0004ccc0: 656d 0a09 0909 2f2f 2077 6520 6a75 7374 em....// we just │ │ │ +0004ccd0: 2069 676e 6f72 6520 7468 6174 2066 696c ignore that fil │ │ │ +0004cce0: 650a 0909 0969 6620 2865 632e 6563 203d e....if (ec.ec = │ │ │ +0004ccf0: 3d20 626f 6f73 743a 3a73 7973 7465 6d3a = boost::system: │ │ │ +0004cd00: 3a65 7272 633a 3a6e 6f5f 7375 6368 5f66 :errc::no_such_f │ │ │ +0004cd10: 696c 655f 6f72 5f64 6972 6563 746f 7279 ile_or_directory │ │ │ +0004cd20: 290a 0909 0909 6563 2e65 632e 636c 6561 ).....ec.ec.clea │ │ │ +0004cd30: 7228 293b 0a09 0909 656c 7365 2069 6620 r();....else if │ │ │ +0004cd40: 2865 630a 0909 0909 2661 6d70 3b26 616d (ec.....&&am │ │ │ +0004cd50: 703b 2065 632e 6563 2021 3d20 626f 6f73 p; ec.ec != boos │ │ │ +0004cd60: 743a 3a73 7973 7465 6d3a 3a65 7272 633a t::system::errc: │ │ │ +0004cd70: 3a69 6e76 616c 6964 5f61 7267 756d 656e :invalid_argumen │ │ │ +0004cd80: 740a 0909 0909 2661 6d70 3b26 616d 703b t.....&& │ │ │ +0004cd90: 2065 632e 6563 2021 3d20 626f 6f73 743a ec.ec != boost: │ │ │ +0004cda0: 3a73 7973 7465 6d3a 3a65 7272 633a 3a70 :system::errc::p │ │ │ +0004cdb0: 6572 6d69 7373 696f 6e5f 6465 6e69 6564 ermission_denied │ │ │ +0004cdc0: 290a 0909 097b 0a09 0909 092f 2f20 6d6f )....{.....// mo │ │ │ +0004cdd0: 7669 6e67 2074 6865 2066 696c 6520 6661 ving the file fa │ │ │ +0004cde0: 696c 6564 0a09 0909 092f 2f20 6f6e 204f iled.....// on O │ │ │ +0004cdf0: 5358 2c20 7468 6520 6572 726f 7220 7768 SX, the error wh │ │ │ +0004ce00: 656e 2074 7279 696e 6720 746f 2072 656e en trying to ren │ │ │ +0004ce10: 616d 6520 6120 6669 6c65 2061 6372 6f73 ame a file acros │ │ │ +0004ce20: 7320 6469 6666 6572 656e 740a 0909 0909 s different..... │ │ │ +0004ce30: 2f2f 2076 6f6c 756d 6573 2069 7320 4558 // volumes is EX │ │ │ +0004ce40: 4445 562c 2077 6869 6368 2077 696c 6c20 DEV, which will │ │ │ +0004ce50: 6d61 6b65 2069 7420 6661 6c6c 2062 6163 make it fall bac │ │ │ +0004ce60: 6b20 746f 2063 6f70 7969 6e67 2e0a 0909 k to copying.... │ │ │ +0004ce70: 0909 6563 2e65 632e 636c 6561 7228 293b ..ec.ec.clear(); │ │ │ +0004ce80: 0a09 0909 0963 6f70 795f 6669 6c65 286f .....copy_file(o │ │ │ +0004ce90: 6c64 5f70 6174 682c 206e 6577 5f70 6174 ld_path, new_pat │ │ │ +0004cea0: 682c 2065 6329 3b0a 0909 0909 6966 2028 h, ec);.....if ( │ │ │ +0004ceb0: 2165 6329 2063 6f70 6965 645f 6669 6c65 !ec) copied_file │ │ │ +0004cec0: 735b 695d 203d 2074 7275 653b 0a09 0909 s[i] = true;.... │ │ │ +0004ced0: 7d0a 0a09 0909 6966 2028 6563 290a 0909 }.....if (ec)... │ │ │ +0004cee0: 097b 0a09 0909 0965 632e 6669 6c65 2869 .{.....ec.file(i │ │ │ +0004cef0: 293b 0a09 0909 0966 696c 655f 696e 6465 );.....file_inde │ │ │ +0004cf00: 7820 3d20 693b 0a09 0909 0962 7265 616b x = i;.....break │ │ │ +0004cf10: 3b0a 0909 097d 0a09 097d 0a0a 0909 6966 ;....}...}....if │ │ │ +0004cf20: 2028 2165 6320 2661 6d70 3b26 616d 703b (!ec && │ │ │ +0004cf30: 206d 6f76 655f 7061 7274 6669 6c65 290a move_partfile). │ │ │ +0004cf40: 0909 7b0a 0909 0965 7272 6f72 5f63 6f64 ..{....error_cod │ │ │ +0004cf50: 6520 653b 0a09 0909 6d6f 7665 5f70 6172 e e;....move_par │ │ │ +0004cf60: 7466 696c 6528 6e65 775f 7361 7665 5f70 tfile(new_save_p │ │ │ +0004cf70: 6174 682c 2065 293b 0a09 0909 6966 2028 ath, e);....if ( │ │ │ +0004cf80: 6529 0a3c 2f70 7265 3e3c 2f74 643e 3c2f e).
    │ │ │ +0004cfb0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +0004cfc0: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +0004cff0: 2f73 7263 2f73 746f 7261 6765 5f75 7469 /src/storage_uti │ │ │ +0004d000: 6c73 2e63 7070 3a35 3339 3c2f 613e 3c2f ls.cpp:539it would │ │ │ +0004d020: 7365 656d 2072 6561 736f 6e61 626c 6520 seem reasonable │ │ │ +0004d030: 746f 2c20 696e 7374 6561 642c 2073 6574 to, instead, set │ │ │ +0004d040: 2074 6865 2068 6176 655f 7069 6563 6573 the have_pieces │ │ │ +0004d050: 2062 6974 7320 666f 7220 7468 6520 7069 bits for the pi │ │ │ +0004d060: 6563 6573 2072 6570 7265 7365 6e74 696e eces representin │ │ │ +0004d070: 6720 7468 6573 6520 6669 6c65 732c 2061 g these files, a │ │ │ +0004d080: 6e64 2072 6573 756d 6520 7769 7468 2074 nd resume with t │ │ │ +0004d090: 6865 206e 6f72 6d61 6c20 6c6f 6769 633c he normal logic< │ │ │ +0004d0a0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    it │ │ │ +0004d0f0: 776f 756c 6420 7365 656d 2072 6561 736f would seem reaso │ │ │ +0004d100: 6e61 626c 6520 746f 2c20 696e 7374 6561 nable to, instea │ │ │ +0004d110: 642c 2073 6574 2074 6865 2068 6176 655f d, set the have_ │ │ │ +0004d120: 7069 6563 6573 2062 6974 730a 666f 7220 pieces bits.for │ │ │ +0004d130: 7468 6520 7069 6563 6573 2072 6570 7265 the pieces repre │ │ │ +0004d140: 7365 6e74 696e 6720 7468 6573 6520 6669 senting these fi │ │ │ +0004d150: 6c65 732c 2061 6e64 2072 6573 756d 6520 les, and resume │ │ │ +0004d160: 7769 7468 2074 6865 206e 6f72 6d61 6c0a with the normal. │ │ │ +0004d170: 6c6f 6769 633c 2f68 323e 3c68 343e 2e2e logic

    .. │ │ │ +0004d180: 2f73 7263 2f73 746f 7261 6765 5f75 7469 /src/storage_uti │ │ │ +0004d190: 6c73 2e63 7070 3a35 3339 3c2f 6834 3e3c ls.cpp:539

    < │ │ │ +0004d1a0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +0004d1b0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +0004d1c0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +0004d1d0: 7820 2364 6464 3b22 3e09 0909 0909 636f x #ddd;">.....co │ │ │ +0004d1e0: 6e74 696e 7565 3b0a 0a09 0909 0973 7464 ntinue;......std │ │ │ +0004d1f0: 3a3a 696e 7436 345f 7420 636f 6e73 7420 ::int64_t const │ │ │ +0004d200: 7369 7a65 203d 2067 6574 5f66 696c 6573 size = get_files │ │ │ +0004d210: 697a 6528 7374 6174 2c20 6669 6c65 5f69 ize(stat, file_i │ │ │ +0004d220: 6e64 6578 2c20 6673 0a09 0909 0909 2c20 ndex, fs......, │ │ │ +0004d230: 7361 7665 5f70 6174 682c 2065 6329 3b0a save_path, ec);. │ │ │ +0004d240: 0909 0909 6966 2028 7369 7a65 2026 6c74 ....if (size < │ │ │ +0004d250: 3b20 3029 2072 6574 7572 6e20 6661 6c73 ; 0) return fals │ │ │ +0004d260: 653b 0a0a 0909 0909 6966 2028 7369 7a65 e;......if (size │ │ │ +0004d270: 2026 6c74 3b20 6673 2e66 696c 655f 7369 < fs.file_si │ │ │ +0004d280: 7a65 2866 696c 655f 696e 6465 7829 290a ze(file_index)). │ │ │ +0004d290: 0909 0909 7b0a 0909 0909 0965 632e 6563 ....{......ec.ec │ │ │ +0004d2a0: 203d 2065 7272 6f72 733a 3a6d 6973 6d61 = errors::misma │ │ │ +0004d2b0: 7463 6869 6e67 5f66 696c 655f 7369 7a65 tching_file_size │ │ │ +0004d2c0: 3b0a 0909 0909 0965 632e 6669 6c65 2866 ;......ec.file(f │ │ │ +0004d2d0: 696c 655f 696e 6465 7829 3b0a 0909 0909 ile_index);..... │ │ │ +0004d2e0: 0965 632e 6f70 6572 6174 696f 6e20 3d20 .ec.operation = │ │ │ +0004d2f0: 6f70 6572 6174 696f 6e5f 743a 3a63 6865 operation_t::che │ │ │ +0004d300: 636b 5f72 6573 756d 653b 0a09 0909 0909 ck_resume;...... │ │ │ +0004d310: 7265 7475 726e 2066 616c 7365 3b0a 0909 return false;... │ │ │ +0004d320: 0909 7d0a 0909 097d 0a09 0909 7265 7475 ..}....}....retu │ │ │ +0004d330: 726e 2074 7275 653b 0a09 097d 0a0a 2369 rn true;...}..#i │ │ │ +0004d340: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ +0004d350: 5341 424c 455f 4d55 5441 424c 455f 544f SABLE_MUTABLE_TO │ │ │ +0004d360: 5252 454e 5453 0a09 092f 2f20 616c 7761 RRENTS...// alwa │ │ │ +0004d370: 7973 2074 7269 6767 6572 2061 2066 756c ys trigger a ful │ │ │ +0004d380: 6c20 7265 6368 6563 6b20 7768 656e 2077 l recheck when w │ │ │ +0004d390: 6520 7075 6c6c 2069 6e20 6669 6c65 7320 e pull in files │ │ │ +0004d3a0: 6672 6f6d 206f 7468 6572 0a09 092f 2f20 from other...// │ │ │ +0004d3b0: 746f 7272 656e 7473 2c20 7669 6120 6861 torrents, via ha │ │ │ +0004d3c0: 7264 206c 696e 6b73 0a3c 6469 7620 7374 rd links.
    ..if (add │ │ │ +0004d400: 6564 5f66 696c 6573 2920 7265 7475 726e ed_files) return │ │ │ +0004d410: 2066 616c 7365 3b0a 3c2f 6469 763e 2365 false;.
    #e │ │ │ +0004d420: 6e64 6966 0a0a 0909 2f2f 2070 6172 7365 ndif....// parse │ │ │ +0004d430: 2068 6176 6520 6269 746d 6173 6b2e 2056 have bitmask. V │ │ │ +0004d440: 6572 6966 7920 7468 6174 2066 696c 6573 erify that files │ │ │ +0004d450: 2074 6f75 6368 6564 2062 7920 636f 6d70 touched by comp │ │ │ +0004d460: 6c65 7465 6420 7069 6563 6573 0a09 092f leted pieces.../ │ │ │ +0004d470: 2f20 6163 7475 616c 6c79 2065 7869 7374 / actually exist │ │ │ +0004d480: 2e20 4120 636f 6d70 6c65 7465 6420 7069 . A completed pi │ │ │ +0004d490: 6563 6520 6d61 7920 7370 616e 206d 756c ece may span mul │ │ │ +0004d4a0: 7469 706c 6520 6669 6c65 732e 0a09 0966 tiple files....f │ │ │ +0004d4b0: 6f72 2028 6669 6c65 5f69 6e64 6578 5f74 or (file_index_t │ │ │ +0004d4c0: 2063 6f6e 7374 2066 696c 655f 696e 6465 const file_inde │ │ │ +0004d4d0: 7820 3a20 6673 2e66 696c 655f 7261 6e67 x : fs.file_rang │ │ │ +0004d4e0: 6528 2929 0a09 097b 0a09 0909 2f2f 2066 e())...{....// f │ │ │ +0004d4f0: 696c 6573 2077 6974 6820 7072 696f 7269 iles with priori │ │ │ +0004d500: 7479 207a 6572 6f20 6d61 7920 6e6f 7420 ty zero may not │ │ │ +0004d510: 6861 7665 2062 6565 6e20 7361 7665 6420 have been saved │ │ │ +0004d520: 746f 2064 6973 6b20 6174 2074 6865 6972 to disk at their │ │ │ +0004d530: 0a09 0909 2f2f 2065 7870 6563 7465 6420 ....// expected │ │ │ +0004d540: 6c6f 6361 7469 6f6e 2c20 6275 7420 6973 location, but is │ │ │ +0004d550: 206c 696b 656c 7920 746f 2062 6520 696e likely to be in │ │ │ +0004d560: 2061 2070 6172 7466 696c 652e 204a 7573 a partfile. Jus │ │ │ +0004d570: 7420 6578 656d 7074 2069 740a 0909 092f t exempt it..../ │ │ │ +0004d580: 2f20 6672 6f6d 2063 6865 636b 696e 670a / from checking. │ │ │ +0004d590: 0909 0969 6620 2866 696c 655f 696e 6465 ...if (file_inde │ │ │ +0004d5a0: 7820 266c 743b 2066 696c 655f 7072 696f x < file_prio │ │ │ +0004d5b0: 7269 7479 2e65 6e64 5f69 6e64 6578 2829 rity.end_index() │ │ │ +0004d5c0: 0a09 0909 0926 616d 703b 2661 6d70 3b20 .....&& │ │ │ +0004d5d0: 6669 6c65 5f70 7269 6f72 6974 795b 6669 file_priority[fi │ │ │ +0004d5e0: 6c65 5f69 6e64 6578 5d20 3d3d 2064 6f6e le_index] == don │ │ │ +0004d5f0: 745f 646f 776e 6c6f 6164 290a 0909 0909 t_download)..... │ │ │ +0004d600: 636f 6e74 696e 7565 3b0a 0a09 0909 6966 continue;.....if │ │ │ +0004d610: 2028 6673 2e70 6164 5f66 696c 655f 6174 (fs.pad_file_at │ │ │ +0004d620: 2866 696c 655f 696e 6465 7829 2920 636f (file_index)) co │ │ │ +0004d630: 6e74 696e 7565 3b0a 0909 0969 6620 2866 ntinue;....if (f │ │ │ +0004d640: 732e 6669 6c65 5f73 697a 6528 6669 6c65 s.file_size(file │ │ │ +0004d650: 5f69 6e64 6578 2920 3d3d 2030 2920 636f _index) == 0) co │ │ │ +0004d660: 6e74 696e 7565 3b0a 0a09 0909 7069 6563 ntinue;.....piec │ │ │ +0004d670: 655f 696e 6465 785f 7420 7374 6172 745f e_index_t start_ │ │ │ +0004d680: 7069 6563 653b 0a09 0909 7069 6563 655f piece;....piece_ │ │ │ +0004d690: 696e 6465 785f 7420 6669 6c65 5f65 6e64 index_t file_end │ │ │ +0004d6a0: 5f70 6965 6365 3b0a 0909 0973 7464 3a3a _piece;....std:: │ │ │ +0004d6b0: 7469 6528 7374 6172 745f 7069 6563 652c tie(start_piece, │ │ │ +0004d6c0: 2066 696c 655f 656e 645f 7069 6563 6529 file_end_piece) │ │ │ +0004d6d0: 0a09 0909 093d 2061 7578 3a3a 6669 6c65 .....= aux::file │ │ │ +0004d6e0: 5f70 6965 6365 5f72 616e 6765 5f69 6e63 _piece_range_inc │ │ │ +0004d6f0: 6c75 7369 7665 2866 732c 2066 696c 655f lusive(fs, file_ │ │ │ +0004d700: 696e 6465 7829 3b0a 0a09 0909 7069 6563 index);.....piec │ │ │ +0004d710: 655f 696e 6465 785f 7420 636f 6e73 7420 e_index_t const │ │ │ +0004d720: 656e 645f 7069 6563 6520 3d20 7374 643a end_piece = std: │ │ │ +0004d730: 3a6d 696e 2866 696c 655f 656e 645f 7069 :min(file_end_pi │ │ │ +0004d740: 6563 650a 0909 0909 2c20 7264 2e68 6176 ece....., rd.hav │ │ │ +0004d750: 655f 7069 6563 6573 2e65 6e64 5f69 6e64 e_pieces.end_ind │ │ │ +0004d760: 6578 2829 293b 0a0a 0909 0962 6f6f 6c20 ex());.....bool │ │ │ +0004d770: 6861 735f 636f 6d70 6c65 7465 645f 7265 has_completed_re │ │ │ +0004d780: 7375 6d65 5f70 6965 6365 203d 2066 616c sume_piece = fal │ │ │ +0004d790: 7365 3b0a 0909 0966 6f72 2028 7069 6563 se;....for (piec │ │ │ +0004d7a0: 655f 696e 6465 785f 7420 7069 6563 6520 e_index_t piece │ │ │ +0004d7b0: 3d20 7374 6172 745f 7069 6563 653b 2070 = start_piece; p │ │ │ +0004d7c0: 6965 6365 2026 6c74 3b20 656e 645f 7069 iece < end_pi │ │ │ +0004d7d0: 6563 653b 202b 2b70 6965 6365 290a 0909 ece; ++piece)... │ │ │ +0004d7e0: 097b 0a09 0909 0969 6620 2821 7264 2e68 .{.....if (!rd.h │ │ │ +0004d7f0: 6176 655f 7069 6563 6573 2e67 6574 5f62 ave_pieces.get_b │ │ │ +0004d800: 6974 2870 6965 6365 2929 2063 6f6e 7469 it(piece)) conti │ │ │ +0004d810: 6e75 653b 0a09 0909 0968 6173 5f63 6f6d nue;.....has_com │ │ │ +0004d820: 706c 6574 6564 5f72 6573 756d 655f 7069 pleted_resume_pi │ │ │ +0004d830: 6563 6520 3d20 7472 7565 3b0a 0909 0909 ece = true;..... │ │ │ +0004d840: 6272 6561 6b3b 0a3c 2f70 7265 3e3c 2f74 break;.
    relevanc │ │ │ +0004d880: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/enum_ne │ │ │ +0004d8c0: 742e 6370 703a 3134 343c 2f61 3e3c 2f74 t.cpp:144
    in C++17, │ │ │ +0004d8e0: 7573 6520 5f5f 6861 735f 696e 636c 7564 use __has_includ │ │ │ +0004d8f0: 6520 666f 7220 7468 6973 2e20 4f74 6865 e for this. Othe │ │ │ +0004d900: 7220 6f70 6572 6174 696e 6720 7379 7374 r operating syst │ │ │ +0004d910: 656d 7320 6172 6520 6c69 6b65 6c79 2074 ems are likely t │ │ │ +0004d920: 6f20 7265 7175 6972 6520 7468 6973 2061 o require this a │ │ │ +0004d930: 7320 7765 6c6c 3c2f 7464 3e3c 2f74 723e s well │ │ │ +0004d940: 3c74 7220 6964 3d22 3138 3422 2073 7479 │ │ │ +0004d970: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0004d980: 3c68 323e 696e 2043 2b2b 3137 2c20 7573

    in C++17, us │ │ │ +0004d990: 6520 5f5f 6861 735f 696e 636c 7564 6520 e __has_include │ │ │ +0004d9a0: 666f 7220 7468 6973 2e20 4f74 6865 7220 for this. Other │ │ │ +0004d9b0: 6f70 6572 6174 696e 6720 7379 7374 656d operating system │ │ │ +0004d9c0: 7320 6172 650a 6c69 6b65 6c79 2074 6f20 s are.likely to │ │ │ +0004d9d0: 7265 7175 6972 6520 7468 6973 2061 7320 require this as │ │ │ +0004d9e0: 7765 6c6c 3c2f 6832 3e3c 6834 3e2e 2e2f well

    ../ │ │ │ +0004d9f0: 7372 632f 656e 756d 5f6e 6574 2e63 7070 src/enum_net.cpp │ │ │ +0004da00: 3a31 3434 3c2f 6834 3e3c 7072 6520 7374 :144

    #include <
    │ │ │ +0004da50: 6172 7061 2f69 6e65 742e 6826 6774 3b0a  arpa/inet.h>.
    │ │ │ +0004da60: 2369 6e63 6c75 6465 2026 6c74 3b63 7374  #include <cst
    │ │ │ +0004da70: 7269 6e67 2667 743b 0a23 696e 636c 7564  ring>.#includ
    │ │ │ +0004da80: 6520 266c 743b 6373 7464 6c69 6226 6774  e <cstdlib>
    │ │ │ +0004da90: 3b0a 2369 6e63 6c75 6465 2026 6c74 3b75  ;.#include <u
    │ │ │ +0004daa0: 6e69 7374 642e 6826 6774 3b0a 2369 6e63  nistd.h>.#inc
    │ │ │ +0004dab0: 6c75 6465 2026 6c74 3b73 7973 2f74 7970  lude <sys/typ
    │ │ │ +0004dac0: 6573 2e68 2667 743b 0a0a 2369 6620 6465  es.h>..#if de
    │ │ │ +0004dad0: 6669 6e65 6420 544f 5252 454e 545f 414e  fined TORRENT_AN
    │ │ │ +0004dae0: 4452 4f49 4420 2661 6d70 3b26 616d 703b  DROID &&
    │ │ │ +0004daf0: 2021 6465 6669 6e65 6420 4946 415f 465f   !defined IFA_F_
    │ │ │ +0004db00: 4441 4446 4149 4c45 440a 2364 6566 696e  DADFAILED.#defin
    │ │ │ +0004db10: 6520 4946 415f 465f 4441 4446 4149 4c45  e IFA_F_DADFAILE
    │ │ │ +0004db20: 4420 380a 2365 6e64 6966 0a0a 2365 6e64  D 8.#endif..#end
    │ │ │ +0004db30: 6966 0a0a 2369 6620 544f 5252 454e 545f  if..#if TORRENT_
    │ │ │ +0004db40: 5553 455f 4946 4144 4452 530a 2369 6e63  USE_IFADDRS.#inc
    │ │ │ +0004db50: 6c75 6465 2026 6c74 3b69 6661 6464 7273  lude <ifaddrs
    │ │ │ +0004db60: 2e68 2667 743b 0a23 696e 636c 7564 6520  .h>.#include 
    │ │ │ +0004db70: 266c 743b 6e65 742f 6966 2e68 2667 743b  <net/if.h>
    │ │ │ +0004db80: 0a23 696e 636c 7564 6520 266c 743b 7379  .#include <sy
    │ │ │ +0004db90: 732f 696f 6374 6c2e 6826 6774 3b0a 2365  s/ioctl.h>.#e
    │ │ │ +0004dba0: 6e64 6966 0a0a 2369 6620 544f 5252 454e  ndif..#if TORREN
    │ │ │ +0004dbb0: 545f 5553 455f 4946 4144 4452 5320 7c7c  T_USE_IFADDRS ||
    │ │ │ +0004dbc0: 2054 4f52 5245 4e54 5f55 5345 5f49 4643   TORRENT_USE_IFC
    │ │ │ +0004dbd0: 4f4e 4620 7c7c 2054 4f52 5245 4e54 5f55  ONF || TORRENT_U
    │ │ │ +0004dbe0: 5345 5f4e 4554 4c49 4e4b 207c 7c20 544f  SE_NETLINK || TO
    │ │ │ +0004dbf0: 5252 454e 545f 5553 455f 5359 5343 544c  RRENT_USE_SYSCTL
    │ │ │ +0004dc00: 0a23 6966 6465 6620 544f 5252 454e 545f  .#ifdef TORRENT_
    │ │ │ +0004dc10: 4245 4f53 0a3c 6469 7620 7374 796c 653d  BEOS.
    #include < │ │ │ +0004dc50: 7379 732f 736f 636b 696f 2e68 2667 743b sys/sockio.h> │ │ │ +0004dc60: 0a3c 2f64 6976 3e23 656e 6469 660a 2f2f .
    #endif.// │ │ │ +0004dc70: 2063 6170 7475 7265 2074 6869 7320 6865 capture this he │ │ │ +0004dc80: 7265 2077 6865 7265 2077 6172 6e69 6e67 re where warning │ │ │ +0004dc90: 7320 6172 6520 6469 7361 626c 6564 2028 s are disabled ( │ │ │ +0004dca0: 7468 6520 6d61 6372 6f20 6765 6e65 7261 the macro genera │ │ │ +0004dcb0: 7465 7320 7761 726e 696e 6773 290a 636f tes warnings).co │ │ │ +0004dcc0: 6e73 7420 756e 7369 676e 6564 206c 6f6e nst unsigned lon │ │ │ +0004dcd0: 6720 7369 6f63 6769 666d 7475 203d 2053 g siocgifmtu = S │ │ │ +0004dce0: 494f 4347 4946 4d54 553b 0a23 656e 6469 IOCGIFMTU;.#endi │ │ │ +0004dcf0: 660a 0a23 696e 636c 7564 6520 226c 6962 f..#include "lib │ │ │ +0004dd00: 746f 7272 656e 742f 6175 785f 2f64 6973 torrent/aux_/dis │ │ │ +0004dd10: 6162 6c65 5f77 6172 6e69 6e67 735f 706f able_warnings_po │ │ │ +0004dd20: 702e 6870 7022 0a0a 2369 6620 6465 6669 p.hpp"..#if defi │ │ │ +0004dd30: 6e65 6428 544f 5252 454e 545f 4f53 3229 ned(TORRENT_OS2) │ │ │ +0004dd40: 2026 616d 703b 2661 6d70 3b20 2164 6566 && !def │ │ │ +0004dd50: 696e 6564 2849 465f 4e41 4d45 5349 5a45 ined(IF_NAMESIZE │ │ │ +0004dd60: 290a 2364 6566 696e 6520 4946 5f4e 414d ).#define IF_NAM │ │ │ +0004dd70: 4553 495a 4520 4946 4e41 4d53 495a 0a23 ESIZE IFNAMSIZ.# │ │ │ +0004dd80: 656e 6469 660a 0a6e 616d 6573 7061 6365 endif..namespace │ │ │ +0004dd90: 206c 6962 746f 7272 656e 7420 7b0a 0a6e libtorrent {..n │ │ │ +0004dda0: 616d 6573 7061 6365 207b 0a0a 2369 6620 amespace {..#if │ │ │ +0004ddb0: 2164 6566 696e 6564 2054 4f52 5245 4e54 !defined TORRENT │ │ │ +0004ddc0: 5f57 494e 444f 5753 2026 616d 703b 2661 _WINDOWS &&a │ │ │ +0004ddd0: 6d70 3b20 2164 6566 696e 6564 2054 4f52 mp; !defined TOR │ │ │ +0004dde0: 5245 4e54 5f42 5549 4c44 5f53 494d 554c RENT_BUILD_SIMUL │ │ │ +0004ddf0: 4154 4f52 0a09 7374 7275 6374 2073 6f63 ATOR..struct soc │ │ │ +0004de00: 6b65 745f 636c 6f73 6572 0a09 7b0a 0909 ket_closer..{... │ │ │ +0004de10: 736f 636b 6574 5f63 6c6f 7365 7228 696e socket_closer(in │ │ │ +0004de20: 7420 7329 203a 206d 5f73 6f63 6b65 7428 t s) : m_socket( │ │ │ +0004de30: 7329 207b 7d0a 0909 736f 636b 6574 5f63 s) {}...socket_c │ │ │ +0004de40: 6c6f 7365 7228 736f 636b 6574 5f63 6c6f loser(socket_clo │ │ │ +0004de50: 7365 7220 636f 6e73 7426 616d 703b 2920 ser const&) │ │ │ +0004de60: 3d20 6465 6c65 7465 3b0a 0909 736f 636b = delete;...sock │ │ │ +0004de70: 6574 5f63 6c6f 7365 7228 736f 636b 6574 et_closer(socket │ │ │ +0004de80: 5f63 6c6f 7365 7220 2661 6d70 3b26 616d _closer &&am │ │ │ +0004de90: 703b 2920 3d20 6465 6c65 7465 3b0a 0909 p;) = delete;... │ │ │ +0004dea0: 736f 636b 6574 5f63 6c6f 7365 7226 616d socket_closer&am │ │ │ +0004deb0: 703b 206f 7065 7261 746f 723d 2873 6f63 p; operator=(soc │ │ │ +0004dec0: 6b65 745f 636c 6f73 6572 2063 6f6e 7374 ket_closer const │ │ │ +0004ded0: 2661 6d70 3b29 203d 2064 656c 6574 653b &) = delete; │ │ │ +0004dee0: 0a09 0973 6f63 6b65 745f 636c 6f73 6572 ...socket_closer │ │ │ +0004def0: 2661 6d70 3b20 6f70 6572 6174 6f72 3d28 & operator=( │ │ │ +0004df00: 736f 636b 6574 5f63 6c6f 7365 7220 2661 socket_closer &a │ │ │ +0004df10: 6d70 3b26 616d 703b 2920 3d20 6465 6c65 mp;&) = dele │ │ │ +0004df20: 7465 3b0a 0909 7e73 6f63 6b65 745f 636c te;...~socket_cl │ │ │ +0004df30: 6f73 6572 2829 207b 203a 3a63 6c6f 7365 oser() { ::close │ │ │ +0004df40: 286d 5f73 6f63 6b65 7429 3b20 7d0a 0970 (m_socket); }..p │ │ │ +0004df50: 7269 7661 7465 3a0a 0909 696e 7420 6d5f rivate:...int m_ │ │ │ +0004df60: 736f 636b 6574 3b0a 097d 3b0a 2365 6e64 socket;..};.#end │ │ │ +0004df70: 6966 0a0a 2369 6620 2164 6566 696e 6564 if..#if !defined │ │ │ +0004df80: 2054 4f52 5245 4e54 5f42 5549 4c44 5f53 TORRENT_BUILD_S │ │ │ +0004df90: 494d 554c 4154 4f52 0a3c 2f70 7265 3e3c IMULATOR.
    < │ │ │ +0004dfa0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +0004dfd0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +0004dfe0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/enum_ │ │ │ +0004e010: 6e65 742e 6370 703a 3236 383c 2f61 3e3c net.cpp:268< │ │ │ +0004e020: 2f74 643e 3c74 643e 6966 2077 6520 6765 /td>if we ge │ │ │ +0004e030: 7420 6865 7265 2c20 7468 6520 6361 6c6c t here, the call │ │ │ +0004e040: 6572 2073 7469 6c6c 2061 7373 756d 6573 er still assumes │ │ │ +0004e050: 2074 6865 2065 7272 6f72 2063 6f64 6520 the error code │ │ │ +0004e060: 6973 2072 6570 6f72 7465 6420 7669 6120 is reported via │ │ │ +0004e070: 6572 726e 6f3c 2f74 643e 3c2f 7472 3e3c errno< │ │ │ +0004e080: 7472 2069 643d 2231 3835 2220 7374 796c tr id="185" styl │ │ │ +0004e090: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +0004e0a0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +0004e0b0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +0004e0c0: 6832 3e69 6620 7765 2067 6574 2068 6572 h2>if we get her │ │ │ +0004e0d0: 652c 2074 6865 2063 616c 6c65 7220 7374 e, the caller st │ │ │ +0004e0e0: 696c 6c20 6173 7375 6d65 7320 7468 6520 ill assumes the │ │ │ +0004e0f0: 6572 726f 7220 636f 6465 0a69 7320 7265 error code.is re │ │ │ +0004e100: 706f 7274 6564 2076 6961 2065 7272 6e6f ported via errno │ │ │ +0004e110: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +0004e120: 656e 756d 5f6e 6574 2e63 7070 3a32 3638 enum_net.cpp:268 │ │ │ +0004e130: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +0004e170: 093b 0a09 7d0a 2365 6e64 6966 0a0a 2369  .;..}.#endif..#i
    │ │ │ +0004e180: 6620 544f 5252 454e 545f 5553 455f 4e45  f TORRENT_USE_NE
    │ │ │ +0004e190: 544c 494e 4b0a 0a09 696e 7420 7265 6164  TLINK...int read
    │ │ │ +0004e1a0: 5f6e 6c5f 736f 636b 2869 6e74 2073 6f63  _nl_sock(int soc
    │ │ │ +0004e1b0: 6b2c 2073 7464 3a3a 7569 6e74 3332 5f74  k, std::uint32_t
    │ │ │ +0004e1c0: 2063 6f6e 7374 2073 6571 2c20 7374 643a   const seq, std:
    │ │ │ +0004e1d0: 3a75 696e 7433 325f 7420 636f 6e73 7420  :uint32_t const 
    │ │ │ +0004e1e0: 7069 640a 0909 2c20 7374 643a 3a66 756e  pid..., std::fun
    │ │ │ +0004e1f0: 6374 696f 6e26 6c74 3b76 6f69 6428 6e6c  ction<void(nl
    │ │ │ +0004e200: 6d73 6768 6472 2063 6f6e 7374 2a29 2667  msghdr const*)&g
    │ │ │ +0004e210: 743b 206f 6e5f 6d73 6729 0a09 7b0a 0909  t; on_msg)..{...
    │ │ │ +0004e220: 7374 643a 3a61 7272 6179 266c 743b 6368  std::array<ch
    │ │ │ +0004e230: 6172 2c20 3430 3936 2667 743b 2062 7566  ar, 4096> buf
    │ │ │ +0004e240: 3b0a 0909 666f 7220 283b 3b29 0a09 097b  ;...for (;;)...{
    │ │ │ +0004e250: 0a09 0909 696e 7420 636f 6e73 7420 7265  ....int const re
    │ │ │ +0004e260: 6164 5f6c 656e 203d 2069 6e74 2872 6563  ad_len = int(rec
    │ │ │ +0004e270: 7628 736f 636b 2c20 6275 662e 6461 7461  v(sock, buf.data
    │ │ │ +0004e280: 2829 2c20 6275 662e 7369 7a65 2829 2c20  (), buf.size(), 
    │ │ │ +0004e290: 3029 293b 0a09 0909 6966 2028 7265 6164  0));....if (read
    │ │ │ +0004e2a0: 5f6c 656e 2026 6c74 3b20 3029 2072 6574  _len < 0) ret
    │ │ │ +0004e2b0: 7572 6e20 2d31 3b0a 0a09 0909 6175 746f  urn -1;.....auto
    │ │ │ +0004e2c0: 2063 6f6e 7374 2a20 6e6c 5f68 6472 203d   const* nl_hdr =
    │ │ │ +0004e2d0: 2072 6569 6e74 6572 7072 6574 5f63 6173   reinterpret_cas
    │ │ │ +0004e2e0: 7426 6c74 3b6e 6c6d 7367 6864 7220 636f  t<nlmsghdr co
    │ │ │ +0004e2f0: 6e73 742a 2667 743b 2862 7566 2e64 6174  nst*>(buf.dat
    │ │ │ +0004e300: 6128 2929 3b0a 0909 0969 6e74 206c 656e  a());....int len
    │ │ │ +0004e310: 203d 2072 6561 645f 6c65 6e3b 0a0a 0909   = read_len;....
    │ │ │ +0004e320: 0966 6f72 2028 3b20 6c65 6e20 2667 743b  .for (; len >
    │ │ │ +0004e330: 2030 2026 616d 703b 2661 6d70 3b20 6175   0 && au
    │ │ │ +0004e340: 783a 3a6e 6c6d 7367 5f6f 6b28 6e6c 5f68  x::nlmsg_ok(nl_h
    │ │ │ +0004e350: 6472 2c20 6c65 6e29 3b20 6e6c 5f68 6472  dr, len); nl_hdr
    │ │ │ +0004e360: 203d 2061 7578 3a3a 6e6c 6d73 675f 6e65   = aux::nlmsg_ne
    │ │ │ +0004e370: 7874 286e 6c5f 6864 722c 206c 656e 2929  xt(nl_hdr, len))
    │ │ │ +0004e380: 0a09 0909 7b0a 3c64 6976 2073 7479 6c65  ....{.
    ....if ((aux │ │ │ +0004e3c0: 3a3a 6e6c 6d73 675f 6f6b 286e 6c5f 6864 ::nlmsg_ok(nl_hd │ │ │ +0004e3d0: 722c 2072 6561 645f 6c65 6e29 203d 3d20 r, read_len) == │ │ │ +0004e3e0: 3029 207c 7c20 286e 6c5f 6864 722d 2667 0) || (nl_hdr-&g │ │ │ +0004e3f0: 743b 6e6c 6d73 675f 7479 7065 203d 3d20 t;nlmsg_type == │ │ │ +0004e400: 4e4c 4d53 475f 4552 524f 5229 290a 3c2f NLMSG_ERROR))......return │ │ │ +0004e420: 2d31 3b0a 0909 0909 2f2f 2074 6869 7320 -1;.....// this │ │ │ +0004e430: 6675 6e63 7469 6f6e 2064 6f65 736e 2774 function doesn't │ │ │ +0004e440: 2068 616e 646c 6520 6d75 6c74 6970 6c65 handle multiple │ │ │ +0004e450: 2072 6571 7565 7374 7320 6174 2074 6865 requests at the │ │ │ +0004e460: 2073 616d 6520 7469 6d65 0a09 0909 092f same time...../ │ │ │ +0004e470: 2f20 736f 2072 6570 6f72 7420 616e 2065 / so report an e │ │ │ +0004e480: 7272 6f72 2069 6620 7468 6520 6d65 7373 rror if the mess │ │ │ +0004e490: 6167 6520 646f 6573 206e 6f74 2068 6176 age does not hav │ │ │ +0004e4a0: 6520 7468 6520 6578 7065 6374 6564 2073 e the expected s │ │ │ +0004e4b0: 6571 2061 6e64 2070 6964 0a3c 2f70 7265 eq and pid.
    rele │ │ │ +0004e4f0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/enu │ │ │ +0004e530: 6d5f 6e65 742e 6370 703a 3237 343c 2f61 m_net.cpp:274if we │ │ │ +0004e550: 6765 7420 6865 7265 2c20 7468 6520 6361 get here, the ca │ │ │ +0004e560: 6c6c 6572 2073 7469 6c6c 2061 7373 756d ller still assum │ │ │ +0004e570: 6573 2074 6865 2065 7272 6f72 2063 6f64 es the error cod │ │ │ +0004e580: 6520 6973 2072 6570 6f72 7465 6420 7669 e is reported vi │ │ │ +0004e590: 6120 6572 726e 6f3c 2f74 643e 3c2f 7472 a errno

    if we get h │ │ │ +0004e5f0: 6572 652c 2074 6865 2063 616c 6c65 7220 ere, the caller │ │ │ +0004e600: 7374 696c 6c20 6173 7375 6d65 7320 7468 still assumes th │ │ │ +0004e610: 6520 6572 726f 7220 636f 6465 0a69 7320 e error code.is │ │ │ +0004e620: 7265 706f 7274 6564 2076 6961 2065 7272 reported via err │ │ │ +0004e630: 6e6f 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 no

    ../sr │ │ │ +0004e640: 632f 656e 756d 5f6e 6574 2e63 7070 3a32 c/enum_net.cpp:2 │ │ │ +0004e650: 3734 3c2f 6834 3e3c 7072 6520 7374 796c 74

    #if TORRENT_USE
    │ │ │ +0004e6a0: 5f4e 4554 4c49 4e4b 0a0a 0969 6e74 2072  _NETLINK...int r
    │ │ │ +0004e6b0: 6561 645f 6e6c 5f73 6f63 6b28 696e 7420  ead_nl_sock(int 
    │ │ │ +0004e6c0: 736f 636b 2c20 7374 643a 3a75 696e 7433  sock, std::uint3
    │ │ │ +0004e6d0: 325f 7420 636f 6e73 7420 7365 712c 2073  2_t const seq, s
    │ │ │ +0004e6e0: 7464 3a3a 7569 6e74 3332 5f74 2063 6f6e  td::uint32_t con
    │ │ │ +0004e6f0: 7374 2070 6964 0a09 092c 2073 7464 3a3a  st pid..., std::
    │ │ │ +0004e700: 6675 6e63 7469 6f6e 266c 743b 766f 6964  function<void
    │ │ │ +0004e710: 286e 6c6d 7367 6864 7220 636f 6e73 742a  (nlmsghdr const*
    │ │ │ +0004e720: 2926 6774 3b20 6f6e 5f6d 7367 290a 097b  )> on_msg)..{
    │ │ │ +0004e730: 0a09 0973 7464 3a3a 6172 7261 7926 6c74  ...std::array<
    │ │ │ +0004e740: 3b63 6861 722c 2034 3039 3626 6774 3b20  ;char, 4096> 
    │ │ │ +0004e750: 6275 663b 0a09 0966 6f72 2028 3b3b 290a  buf;...for (;;).
    │ │ │ +0004e760: 0909 7b0a 0909 0969 6e74 2063 6f6e 7374  ..{....int const
    │ │ │ +0004e770: 2072 6561 645f 6c65 6e20 3d20 696e 7428   read_len = int(
    │ │ │ +0004e780: 7265 6376 2873 6f63 6b2c 2062 7566 2e64  recv(sock, buf.d
    │ │ │ +0004e790: 6174 6128 292c 2062 7566 2e73 697a 6528  ata(), buf.size(
    │ │ │ +0004e7a0: 292c 2030 2929 3b0a 0909 0969 6620 2872  ), 0));....if (r
    │ │ │ +0004e7b0: 6561 645f 6c65 6e20 266c 743b 2030 2920  ead_len < 0) 
    │ │ │ +0004e7c0: 7265 7475 726e 202d 313b 0a0a 0909 0961  return -1;.....a
    │ │ │ +0004e7d0: 7574 6f20 636f 6e73 742a 206e 6c5f 6864  uto const* nl_hd
    │ │ │ +0004e7e0: 7220 3d20 7265 696e 7465 7270 7265 745f  r = reinterpret_
    │ │ │ +0004e7f0: 6361 7374 266c 743b 6e6c 6d73 6768 6472  cast<nlmsghdr
    │ │ │ +0004e800: 2063 6f6e 7374 2a26 6774 3b28 6275 662e   const*>(buf.
    │ │ │ +0004e810: 6461 7461 2829 293b 0a09 0909 696e 7420  data());....int 
    │ │ │ +0004e820: 6c65 6e20 3d20 7265 6164 5f6c 656e 3b0a  len = read_len;.
    │ │ │ +0004e830: 0a09 0909 666f 7220 283b 206c 656e 2026  ....for (; len &
    │ │ │ +0004e840: 6774 3b20 3020 2661 6d70 3b26 616d 703b  gt; 0 &&
    │ │ │ +0004e850: 2061 7578 3a3a 6e6c 6d73 675f 6f6b 286e   aux::nlmsg_ok(n
    │ │ │ +0004e860: 6c5f 6864 722c 206c 656e 293b 206e 6c5f  l_hdr, len); nl_
    │ │ │ +0004e870: 6864 7220 3d20 6175 783a 3a6e 6c6d 7367  hdr = aux::nlmsg
    │ │ │ +0004e880: 5f6e 6578 7428 6e6c 5f68 6472 2c20 6c65  _next(nl_hdr, le
    │ │ │ +0004e890: 6e29 290a 0909 097b 0a09 0909 0969 6620  n))....{.....if 
    │ │ │ +0004e8a0: 2828 6175 783a 3a6e 6c6d 7367 5f6f 6b28  ((aux::nlmsg_ok(
    │ │ │ +0004e8b0: 6e6c 5f68 6472 2c20 7265 6164 5f6c 656e  nl_hdr, read_len
    │ │ │ +0004e8c0: 2920 3d3d 2030 2920 7c7c 2028 6e6c 5f68  ) == 0) || (nl_h
    │ │ │ +0004e8d0: 6472 2d26 6774 3b6e 6c6d 7367 5f74 7970  dr->nlmsg_typ
    │ │ │ +0004e8e0: 6520 3d3d 204e 4c4d 5347 5f45 5252 4f52  e == NLMSG_ERROR
    │ │ │ +0004e8f0: 2929 0a09 0909 0909 7265 7475 726e 202d  ))......return -
    │ │ │ +0004e900: 313b 0a09 0909 092f 2f20 7468 6973 2066  1;.....// this f
    │ │ │ +0004e910: 756e 6374 696f 6e20 646f 6573 6e27 7420  unction doesn't 
    │ │ │ +0004e920: 6861 6e64 6c65 206d 756c 7469 706c 6520  handle multiple 
    │ │ │ +0004e930: 7265 7175 6573 7473 2061 7420 7468 6520  requests at the 
    │ │ │ +0004e940: 7361 6d65 2074 696d 650a 0909 0909 2f2f  same time.....//
    │ │ │ +0004e950: 2073 6f20 7265 706f 7274 2061 6e20 6572   so report an er
    │ │ │ +0004e960: 726f 7220 6966 2074 6865 206d 6573 7361  ror if the messa
    │ │ │ +0004e970: 6765 2064 6f65 7320 6e6f 7420 6861 7665  ge does not have
    │ │ │ +0004e980: 2074 6865 2065 7870 6563 7465 6420 7365   the expected se
    │ │ │ +0004e990: 7120 616e 6420 7069 640a 3c64 6976 2073  q and pid.
    ....if ( │ │ │ +0004e9d0: 6e6c 5f68 6472 2d26 6774 3b6e 6c6d 7367 nl_hdr->nlmsg │ │ │ +0004e9e0: 5f73 6571 2021 3d20 7365 7120 7c7c 206e _seq != seq || n │ │ │ +0004e9f0: 6c5f 6864 722d 2667 743b 6e6c 6d73 675f l_hdr->nlmsg_ │ │ │ +0004ea00: 7069 6420 213d 2070 6964 290a 3c2f 6469 pid != pid)......return -1 │ │ │ +0004ea20: 3b0a 0a09 0909 0969 6620 286e 6c5f 6864 ;......if (nl_hd │ │ │ +0004ea30: 722d 2667 743b 6e6c 6d73 675f 7479 7065 r->nlmsg_type │ │ │ +0004ea40: 203d 3d20 4e4c 4d53 475f 444f 4e45 2920 == NLMSG_DONE) │ │ │ +0004ea50: 7265 7475 726e 2030 3b0a 0a09 0909 096f return 0;......o │ │ │ +0004ea60: 6e5f 6d73 6728 6e6c 5f68 6472 293b 0a0a n_msg(nl_hdr);.. │ │ │ +0004ea70: 0909 0909 6966 2028 286e 6c5f 6864 722d ....if ((nl_hdr- │ │ │ +0004ea80: 2667 743b 6e6c 6d73 675f 666c 6167 7320 >nlmsg_flags │ │ │ +0004ea90: 2661 6d70 3b20 4e4c 4d5f 465f 4d55 4c54 & NLM_F_MULT │ │ │ +0004eaa0: 4929 203d 3d20 3029 2072 6574 7572 6e20 I) == 0) return │ │ │ +0004eab0: 303b 0a09 0909 7d0a 0909 7d0a 2f2f 0909 0;....}...}.//.. │ │ │ +0004eac0: 7265 7475 726e 2030 3b0a 097d 0a0a 0969 return 0;..}...i │ │ │ +0004ead0: 6e74 206e 6c5f 6475 6d70 5f72 6571 7565 nt nl_dump_reque │ │ │ +0004eae0: 7374 2869 6e74 2063 6f6e 7374 2073 6f63 st(int const soc │ │ │ +0004eaf0: 6b2c 2073 7464 3a3a 7569 6e74 3332 5f74 k, std::uint32_t │ │ │ +0004eb00: 2063 6f6e 7374 2073 6571 0a09 092c 206e const seq..., n │ │ │ +0004eb10: 6c6d 7367 6864 722a 2063 6f6e 7374 2072 lmsghdr* const r │ │ │ +0004eb20: 6571 7565 7374 5f6d 7367 2c20 7374 643a equest_msg, std: │ │ │ +0004eb30: 3a66 756e 6374 696f 6e26 6c74 3b76 6f69 :function<voi │ │ │ +0004eb40: 6428 6e6c 6d73 6768 6472 2063 6f6e 7374 d(nlmsghdr const │ │ │ +0004eb50: 2a29 2667 743b 206f 6e5f 6d73 6729 0a09 *)> on_msg).. │ │ │ +0004eb60: 7b0a 0909 7265 7175 6573 745f 6d73 672d {...request_msg- │ │ │ +0004eb70: 2667 743b 6e6c 6d73 675f 666c 6167 7320 >nlmsg_flags │ │ │ +0004eb80: 3d20 4e4c 4d5f 465f 4455 4d50 207c 204e = NLM_F_DUMP | N │ │ │ +0004eb90: 4c4d 5f46 5f52 4551 5545 5354 3b0a 0909 LM_F_REQUEST;... │ │ │ +0004eba0: 7265 7175 6573 745f 6d73 672d 2667 743b request_msg-> │ │ │ +0004ebb0: 6e6c 6d73 675f 7365 7120 3d20 7365 713b nlmsg_seq = seq; │ │ │ +0004ebc0: 0a09 092f 2f20 696e 2074 6865 6f72 7920 ...// in theory │ │ │ +0004ebd0: 6e6c 6d73 675f 7069 6420 7368 6f75 6c64 nlmsg_pid should │ │ │ +0004ebe0: 2062 6520 7365 7420 746f 2074 6865 206e be set to the n │ │ │ +0004ebf0: 6574 6c69 6e6b 2070 6f72 7420 4944 2028 etlink port ID ( │ │ │ +0004ec00: 4e4f 5420 7468 6520 7072 6f63 6573 7320 NOT the process │ │ │ +0004ec10: 4944 290a 0909 2f2f 206f 6620 7468 6520 ID)...// of the │ │ │ +0004ec20: 7365 6e64 6572 2c20 6275 7420 7468 6520 sender, but the │ │ │ +0004ec30: 6b65 726e 656c 2069 676e 6f72 6573 2074 kernel ignores t │ │ │ +0004ec40: 6869 7320 6669 656c 6420 736f 2069 7420 his field so it │ │ │ +0004ec50: 6973 2074 7970 6963 616c 6c79 2073 6574 is typically set │ │ │ +0004ec60: 2074 6f0a 0909 2f2f 207a 6572 6f0a 0909 to...// zero... │ │ │ +0004ec70: 7265 7175 6573 745f 6d73 672d 2667 743b request_msg-> │ │ │ +0004ec80: 6e6c 6d73 675f 7069 6420 3d20 303b 0a0a nlmsg_pid = 0;.. │ │ │ +0004ec90: 0909 6966 2028 3a3a 7365 6e64 2873 6f63 ..if (::send(soc │ │ │ +0004eca0: 6b2c 2072 6571 7565 7374 5f6d 7367 2c20 k, request_msg, │ │ │ +0004ecb0: 7265 7175 6573 745f 6d73 672d 2667 743b request_msg-> │ │ │ +0004ecc0: 6e6c 6d73 675f 6c65 6e2c 2030 2920 266c nlmsg_len, 0) &l │ │ │ +0004ecd0: 743b 2030 290a 0909 0972 6574 7572 6e20 t; 0)....return │ │ │ +0004ece0: 2d31 3b0a 0a09 092f 2f20 6765 7420 7468 -1;....// get th │ │ │ +0004ecf0: 6520 736f 636b 6574 2773 2070 6f72 7420 e socket's port │ │ │ +0004ed00: 4944 2073 6f20 7468 6174 2077 6520 6361 ID so that we ca │ │ │ +0004ed10: 6e20 7665 7269 6679 2069 7420 696e 2074 n verify it in t │ │ │ +0004ed20: 6865 2072 6573 706f 6e73 650a 0909 736f he response...so │ │ │ +0004ed30: 636b 6164 6472 5f6e 6c20 736f 636b 5f61 ckaddr_nl sock_a │ │ │ +0004ed40: 6464 723b 0a09 0973 6f63 6b6c 656e 5f74 ddr;...socklen_t │ │ │ +0004ed50: 2073 6f63 6b5f 6164 6472 5f6c 656e 203d sock_addr_len = │ │ │ +0004ed60: 2073 697a 656f 6628 736f 636b 5f61 6464 sizeof(sock_add │ │ │ +0004ed70: 7229 3b0a 0909 6966 2028 3a3a 6765 7473 r);...if (::gets │ │ │ +0004ed80: 6f63 6b6e 616d 6528 736f 636b 2c20 7265 ockname(sock, re │ │ │ +0004ed90: 696e 7465 7270 7265 745f 6361 7374 266c interpret_cast&l │ │ │ +0004eda0: 743b 736f 636b 6164 6472 2a26 6774 3b28 t;sockaddr*>( │ │ │ +0004edb0: 2661 6d70 3b73 6f63 6b5f 6164 6472 292c &sock_addr), │ │ │ +0004edc0: 2026 616d 703b 736f 636b 5f61 6464 725f &sock_addr_ │ │ │ +0004edd0: 6c65 6e29 2026 6c74 3b20 3029 0a09 0909 len) < 0).... │ │ │ +0004ede0: 7265 7475 726e 202d 313b 0a3c 2f70 7265 return -1;.
    rele │ │ │ +0004ee20: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/pos │ │ │ +0004ee60: 6978 5f70 6172 745f 6669 6c65 2e63 7070 ix_part_file.cpp │ │ │ +0004ee70: 3a33 3339 3c2f 613e 3c2f 7464 3e3c 7464 :339what do we do i │ │ │ +0004ee90: 6620 736f 6d65 6f6e 6520 6973 2063 7572 f someone is cur │ │ │ +0004eea0: 7265 6e74 6c79 2072 6561 6469 6e67 2066 rently reading f │ │ │ +0004eeb0: 726f 6d20 7468 6520 6469 736b 2066 726f rom the disk fro │ │ │ +0004eec0: 6d20 7468 6973 2070 6965 6365 3f20 646f m this piece? do │ │ │ +0004eed0: 6573 2069 7420 6d61 7474 6572 3f20 5369 es it matter? Si │ │ │ +0004eee0: 6e63 6520 7765 2077 6f6e 2774 2061 6374 nce we won't act │ │ │ +0004eef0: 6976 656c 7920 6572 6173 6520 7468 6520 ively erase the │ │ │ +0004ef00: 6461 7461 2066 726f 6d20 6469 736b 2c20 data from disk, │ │ │ +0004ef10: 6275 7420 6974 206d 6179 2062 6520 6f76 but it may be ov │ │ │ +0004ef20: 6572 7772 6974 7465 6e20 736f 6f6e 2c20 erwritten soon, │ │ │ +0004ef30: 6974 2773 2070 726f 6261 626c 7920 6e6f it's probably no │ │ │ +0004ef40: 7420 7468 6174 2062 6967 206f 6620 6120 t that big of a │ │ │ +0004ef50: 6465 616c 3c2f 7464 3e3c 2f74 723e 3c74 dealwhat do we do │ │ │ +0004efb0: 6966 2073 6f6d 656f 6e65 2069 7320 6375 if someone is cu │ │ │ +0004efc0: 7272 656e 746c 7920 7265 6164 696e 6720 rrently reading │ │ │ +0004efd0: 6672 6f6d 2074 6865 2064 6973 6b0a 6672 from the disk.fr │ │ │ +0004efe0: 6f6d 2074 6869 7320 7069 6563 653f 2064 om this piece? d │ │ │ +0004eff0: 6f65 7320 6974 206d 6174 7465 723f 2053 oes it matter? S │ │ │ +0004f000: 696e 6365 2077 6520 776f 6e27 7420 6163 ince we won't ac │ │ │ +0004f010: 7469 7665 6c79 2065 7261 7365 2074 6865 tively erase the │ │ │ +0004f020: 0a64 6174 6120 6672 6f6d 2064 6973 6b2c .data from disk, │ │ │ +0004f030: 2062 7574 2069 7420 6d61 7920 6265 206f but it may be o │ │ │ +0004f040: 7665 7277 7269 7474 656e 2073 6f6f 6e2c verwritten soon, │ │ │ +0004f050: 2069 7427 7320 7072 6f62 6162 6c79 206e it's probably n │ │ │ +0004f060: 6f74 2074 6861 740a 6269 6720 6f66 2061 ot that.big of a │ │ │ +0004f070: 2064 6561 6c3c 2f68 323e 3c68 343e 2e2e deal

    .. │ │ │ +0004f080: 2f73 7263 2f70 6f73 6978 5f70 6172 745f /src/posix_part_ │ │ │ +0004f090: 6669 6c65 2e63 7070 3a33 3339 3c2f 6834 file.cpp:339

    ....i
    │ │ │ +0004f0e0: 6620 2865 6329 2072 6574 7572 6e20 7b7d  f (ec) return {}
    │ │ │ +0004f0f0: 3b0a 0a23 6966 6465 6620 544f 5252 454e  ;..#ifdef TORREN
    │ │ │ +0004f100: 545f 5749 4e44 4f57 530a 0909 0972 6574  T_WINDOWS....ret
    │ │ │ +0004f110: 203d 2066 696c 655f 706f 696e 7465 7228   = file_pointer(
    │ │ │ +0004f120: 3a3a 5f77 666f 7065 6e28 636f 6e76 6572  ::_wfopen(conver
    │ │ │ +0004f130: 745f 746f 5f6e 6174 6976 655f 7061 7468  t_to_native_path
    │ │ │ +0004f140: 5f73 7472 696e 6728 666e 292e 635f 7374  _string(fn).c_st
    │ │ │ +0004f150: 7228 292c 204c 2277 622b 2229 293b 0a23  r(), L"wb+"));.#
    │ │ │ +0004f160: 656c 7365 0a09 0909 7265 7420 3d20 6669  else....ret = fi
    │ │ │ +0004f170: 6c65 5f70 6f69 6e74 6572 283a 3a66 6f70  le_pointer(::fop
    │ │ │ +0004f180: 656e 2866 6e2e 635f 7374 7228 292c 2022  en(fn.c_str(), "
    │ │ │ +0004f190: 7762 2b22 2929 3b0a 2365 6e64 6966 0a09  wb+"));.#endif..
    │ │ │ +0004f1a0: 0909 6966 2028 7265 742e 6669 6c65 2829  ..if (ret.file()
    │ │ │ +0004f1b0: 203d 3d20 6e75 6c6c 7074 7229 0a09 0909   == nullptr)....
    │ │ │ +0004f1c0: 0965 632e 6173 7369 676e 2865 7272 6e6f  .ec.assign(errno
    │ │ │ +0004f1d0: 2c20 6765 6e65 7269 635f 6361 7465 676f  , generic_catego
    │ │ │ +0004f1e0: 7279 2829 293b 0a09 097d 0a09 0969 6620  ry());...}...if 
    │ │ │ +0004f1f0: 2865 6329 2072 6574 7572 6e20 7b7d 3b0a  (ec) return {};.
    │ │ │ +0004f200: 0909 7265 7475 726e 2072 6574 3b0a 097d  ..return ret;..}
    │ │ │ +0004f210: 0a0a 0976 6f69 6420 706f 7369 785f 7061  ...void posix_pa
    │ │ │ +0004f220: 7274 5f66 696c 653a 3a66 7265 655f 7069  rt_file::free_pi
    │ │ │ +0004f230: 6563 6528 7069 6563 655f 696e 6465 785f  ece(piece_index_
    │ │ │ +0004f240: 7420 636f 6e73 7420 7069 6563 6529 0a09  t const piece)..
    │ │ │ +0004f250: 7b0a 0909 6175 746f 2063 6f6e 7374 2069  {...auto const i
    │ │ │ +0004f260: 203d 206d 5f70 6965 6365 5f6d 6170 2e66   = m_piece_map.f
    │ │ │ +0004f270: 696e 6428 7069 6563 6529 3b0a 0909 6966  ind(piece);...if
    │ │ │ +0004f280: 2028 6920 3d3d 206d 5f70 6965 6365 5f6d   (i == m_piece_m
    │ │ │ +0004f290: 6170 2e65 6e64 2829 2920 7265 7475 726e  ap.end()) return
    │ │ │ +0004f2a0: 3b0a 0a3c 6469 7620 7374 796c 653d 2262  ;..
    .
    ..m_free │ │ │ +0004f2e0: 5f73 6c6f 7473 2e70 7573 685f 6261 636b _slots.push_back │ │ │ +0004f2f0: 2869 2d26 6774 3b73 6563 6f6e 6429 3b0a (i->second);. │ │ │ +0004f300: 0909 6d5f 7069 6563 655f 6d61 702e 6572 ..m_piece_map.er │ │ │ +0004f310: 6173 6528 6929 3b0a 0909 6d5f 6469 7274 ase(i);...m_dirt │ │ │ +0004f320: 795f 6d65 7461 6461 7461 203d 2074 7275 y_metadata = tru │ │ │ +0004f330: 653b 0a09 7d0a 0a09 766f 6964 2070 6f73 e;..}...void pos │ │ │ +0004f340: 6978 5f70 6172 745f 6669 6c65 3a3a 6d6f ix_part_file::mo │ │ │ +0004f350: 7665 5f70 6172 7466 696c 6528 7374 643a ve_partfile(std: │ │ │ +0004f360: 3a73 7472 696e 6720 636f 6e73 7426 616d :string const&am │ │ │ +0004f370: 703b 2070 6174 682c 2065 7272 6f72 5f63 p; path, error_c │ │ │ +0004f380: 6f64 6526 616d 703b 2065 6329 0a09 7b0a ode& ec)..{. │ │ │ +0004f390: 0909 666c 7573 685f 6d65 7461 6461 7461 ..flush_metadata │ │ │ +0004f3a0: 5f69 6d70 6c28 6563 293b 0a09 0969 6620 _impl(ec);...if │ │ │ +0004f3b0: 2865 6329 2072 6574 7572 6e3b 0a0a 0909 (ec) return;.... │ │ │ +0004f3c0: 6966 2028 216d 5f70 6965 6365 5f6d 6170 if (!m_piece_map │ │ │ +0004f3d0: 2e65 6d70 7479 2829 290a 0909 7b0a 0909 .empty())...{... │ │ │ +0004f3e0: 0973 7464 3a3a 7374 7269 6e67 206f 6c64 .std::string old │ │ │ +0004f3f0: 5f70 6174 6820 3d20 636f 6d62 696e 655f _path = combine_ │ │ │ +0004f400: 7061 7468 286d 5f70 6174 682c 206d 5f6e path(m_path, m_n │ │ │ +0004f410: 616d 6529 3b0a 0909 0973 7464 3a3a 7374 ame);....std::st │ │ │ +0004f420: 7269 6e67 206e 6577 5f70 6174 6820 3d20 ring new_path = │ │ │ +0004f430: 636f 6d62 696e 655f 7061 7468 2870 6174 combine_path(pat │ │ │ +0004f440: 682c 206d 5f6e 616d 6529 3b0a 0a09 0909 h, m_name);..... │ │ │ +0004f450: 7265 6e61 6d65 286f 6c64 5f70 6174 682c rename(old_path, │ │ │ +0004f460: 206e 6577 5f70 6174 682c 2065 6329 3b0a new_path, ec);. │ │ │ +0004f470: 0909 0969 6620 2865 6320 3d3d 2062 6f6f ...if (ec == boo │ │ │ +0004f480: 7374 3a3a 7379 7374 656d 3a3a 6572 7263 st::system::errc │ │ │ +0004f490: 3a3a 6e6f 5f73 7563 685f 6669 6c65 5f6f ::no_such_file_o │ │ │ +0004f4a0: 725f 6469 7265 6374 6f72 7929 0a09 0909 r_directory).... │ │ │ +0004f4b0: 0965 632e 636c 6561 7228 293b 0a0a 0909 .ec.clear();.... │ │ │ +0004f4c0: 0969 6620 2865 6329 0a09 0909 7b0a 0909 .if (ec)....{... │ │ │ +0004f4d0: 0909 7374 6f72 6167 655f 6572 726f 7220 ..storage_error │ │ │ +0004f4e0: 7365 3b0a 0909 0909 6175 783a 3a63 6f70 se;.....aux::cop │ │ │ +0004f4f0: 795f 6669 6c65 286f 6c64 5f70 6174 682c y_file(old_path, │ │ │ +0004f500: 206e 6577 5f70 6174 682c 2073 6529 3b0a new_path, se);. │ │ │ +0004f510: 0909 0909 6563 203d 2073 652e 6563 3b0a ....ec = se.ec;. │ │ │ +0004f520: 0909 0909 6966 2028 6563 2920 7265 7475 ....if (ec) retu │ │ │ +0004f530: 726e 3b0a 0909 0909 7265 6d6f 7665 286f rn;.....remove(o │ │ │ +0004f540: 6c64 5f70 6174 682c 2065 6329 3b0a 0909 ld_path, ec);... │ │ │ +0004f550: 097d 0a09 097d 0a09 096d 5f70 6174 6820 .}...}...m_path │ │ │ +0004f560: 3d20 7061 7468 3b0a 097d 0a3c 2f70 7265 = path;..}.
    rele │ │ │ +0004f5a0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/pos │ │ │ +0004f5e0: 6978 5f70 6172 745f 6669 6c65 2e63 7070 ix_part_file.cpp │ │ │ +0004f5f0: 3a34 3239 3c2f 613e 3c2f 7464 3e3c 7464 :429instead of rebu │ │ │ +0004f610: 696c 6469 6e67 2074 6865 2077 686f 6c65 ilding the whole │ │ │ +0004f620: 2066 696c 6520 6865 6164 6572 2061 6e64 file header and │ │ │ +0004f630: 2066 6c75 7368 696e 6720 6974 2c20 7570 flushing it, up │ │ │ +0004f640: 6461 7465 2074 6865 2073 6c6f 7420 656e date the slot en │ │ │ +0004f650: 7472 6965 7320 6173 2077 6520 676f 3c2f tries as we go

    inst │ │ │ +0004f6b0: 6561 6420 6f66 2072 6562 7569 6c64 696e ead of rebuildin │ │ │ +0004f6c0: 6720 7468 6520 7768 6f6c 6520 6669 6c65 g the whole file │ │ │ +0004f6d0: 2068 6561 6465 720a 616e 6420 666c 7573 header.and flus │ │ │ +0004f6e0: 6869 6e67 2069 742c 2075 7064 6174 6520 hing it, update │ │ │ +0004f6f0: 7468 6520 736c 6f74 2065 6e74 7269 6573 the slot entries │ │ │ +0004f700: 2061 7320 7765 2067 6f3c 2f68 323e 3c68 as we go

    ../src/posix_p │ │ │ +0004f720: 6172 745f 6669 6c65 2e63 7070 3a34 3239 art_file.cpp:429 │ │ │ +0004f730: 3c2f 6834 3e3c 7072 6520 7374 796c 653d
    .
    │ │ │ +0004f770: 0909 097b 0a09 0909 0909 6966 2028 7374  ...{......if (st
    │ │ │ +0004f780: 643a 3a66 6572 726f 7228 6669 6c65 2e66  d::ferror(file.f
    │ │ │ +0004f790: 696c 6528 2929 2920 6563 2e61 7373 6967  ile())) ec.assig
    │ │ │ +0004f7a0: 6e28 6572 726e 6f2c 2067 656e 6572 6963  n(errno, generic
    │ │ │ +0004f7b0: 5f63 6174 6567 6f72 7928 2929 3b0a 0909  _category());...
    │ │ │ +0004f7c0: 0909 0965 6c73 6520 6563 2e61 7373 6967  ...else ec.assig
    │ │ │ +0004f7d0: 6e28 6572 726f 7273 3a3a 6669 6c65 5f74  n(errors::file_t
    │ │ │ +0004f7e0: 6f6f 5f73 686f 7274 2c20 6c69 6274 6f72  oo_short, libtor
    │ │ │ +0004f7f0: 7265 6e74 5f63 6174 6567 6f72 7928 2929  rent_category())
    │ │ │ +0004f800: 3b0a 0909 0909 7d0a 0a09 0909 0969 6620  ;.....}......if 
    │ │ │ +0004f810: 2865 6329 2072 6574 7572 6e3b 0a0a 0909  (ec) return;....
    │ │ │ +0004f820: 0909 6628 6669 6c65 5f6f 6666 7365 742c  ..f(file_offset,
    │ │ │ +0004f830: 207b 6275 662e 6765 7428 292c 2062 6c6f   {buf.get(), blo
    │ │ │ +0004f840: 636b 5f74 6f5f 636f 7079 7d29 3b0a 0909  ck_to_copy});...
    │ │ │ +0004f850: 097d 0a09 0909 6669 6c65 5f6f 6666 7365  .}....file_offse
    │ │ │ +0004f860: 7420 2b3d 2062 6c6f 636b 5f74 6f5f 636f  t += block_to_co
    │ │ │ +0004f870: 7079 3b0a 0909 0970 6965 6365 5f6f 6666  py;....piece_off
    │ │ │ +0004f880: 7365 7420 3d20 303b 0a09 0909 7369 7a65  set = 0;....size
    │ │ │ +0004f890: 202d 3d20 626c 6f63 6b5f 746f 5f63 6f70   -= block_to_cop
    │ │ │ +0004f8a0: 793b 0a09 097d 0a09 7d0a 0a09 766f 6964  y;...}..}...void
    │ │ │ +0004f8b0: 2070 6f73 6978 5f70 6172 745f 6669 6c65   posix_part_file
    │ │ │ +0004f8c0: 3a3a 666c 7573 685f 6d65 7461 6461 7461  ::flush_metadata
    │ │ │ +0004f8d0: 2865 7272 6f72 5f63 6f64 6526 616d 703b  (error_code&
    │ │ │ +0004f8e0: 2065 6329 0a09 7b0a 0909 666c 7573 685f   ec)..{...flush_
    │ │ │ +0004f8f0: 6d65 7461 6461 7461 5f69 6d70 6c28 6563  metadata_impl(ec
    │ │ │ +0004f900: 293b 0a09 7d0a 0a3c 6469 7620 7374 796c  );..}..
    .void posix │ │ │ +0004f940: 5f70 6172 745f 6669 6c65 3a3a 666c 7573 _part_file::flus │ │ │ +0004f950: 685f 6d65 7461 6461 7461 5f69 6d70 6c28 h_metadata_impl( │ │ │ +0004f960: 6572 726f 725f 636f 6465 2661 6d70 3b20 error_code& │ │ │ +0004f970: 6563 290a 3c2f 6469 763e 097b 0a09 092f ec).
    .{.../ │ │ │ +0004f980: 2f20 646f 2077 6520 6e65 6564 2074 6f20 / do we need to │ │ │ +0004f990: 666c 7573 6820 7468 6520 6d65 7461 6461 flush the metada │ │ │ +0004f9a0: 7461 3f0a 0909 6966 2028 6d5f 6469 7274 ta?...if (m_dirt │ │ │ +0004f9b0: 795f 6d65 7461 6461 7461 203d 3d20 6661 y_metadata == fa │ │ │ +0004f9c0: 6c73 6529 2072 6574 7572 6e3b 0a0a 0909 lse) return;.... │ │ │ +0004f9d0: 6966 2028 6d5f 7069 6563 655f 6d61 702e if (m_piece_map. │ │ │ +0004f9e0: 656d 7074 7928 2929 0a09 097b 0a09 0909 empty())...{.... │ │ │ +0004f9f0: 2f2f 2069 6620 7765 2064 6f6e 2774 2068 // if we don't h │ │ │ +0004fa00: 6176 6520 616e 7920 7069 6563 6573 206c ave any pieces l │ │ │ +0004fa10: 6566 7420 696e 2074 6865 0a09 0909 2f2f eft in the....// │ │ │ +0004fa20: 2070 6172 7420 6669 6c65 2c20 7265 6d6f part file, remo │ │ │ +0004fa30: 7665 2069 740a 0909 0973 7464 3a3a 7374 ve it....std::st │ │ │ +0004fa40: 7269 6e67 2063 6f6e 7374 2070 203d 2063 ring const p = c │ │ │ +0004fa50: 6f6d 6269 6e65 5f70 6174 6828 6d5f 7061 ombine_path(m_pa │ │ │ +0004fa60: 7468 2c20 6d5f 6e61 6d65 293b 0a09 0909 th, m_name);.... │ │ │ +0004fa70: 7265 6d6f 7665 2870 2c20 6563 293b 0a0a remove(p, ec);.. │ │ │ +0004fa80: 0909 0969 6620 2865 6320 3d3d 2062 6f6f ...if (ec == boo │ │ │ +0004fa90: 7374 3a3a 7379 7374 656d 3a3a 6572 7263 st::system::errc │ │ │ +0004faa0: 3a3a 6e6f 5f73 7563 685f 6669 6c65 5f6f ::no_such_file_o │ │ │ +0004fab0: 725f 6469 7265 6374 6f72 7929 0a09 0909 r_directory).... │ │ │ +0004fac0: 0965 632e 636c 6561 7228 293b 0a09 0909 .ec.clear();.... │ │ │ +0004fad0: 7265 7475 726e 3b0a 0909 7d0a 0a09 0961 return;...}....a │ │ │ +0004fae0: 7574 6f20 6620 3d20 6f70 656e 5f66 696c uto f = open_fil │ │ │ +0004faf0: 6528 6f70 656e 5f6d 6f64 653a 3a72 6561 e(open_mode::rea │ │ │ +0004fb00: 645f 7772 6974 652c 2065 6329 3b0a 0909 d_write, ec);... │ │ │ +0004fb10: 6966 2028 6563 2920 7265 7475 726e 3b0a if (ec) return;. │ │ │ +0004fb20: 0a09 0973 7464 3a3a 7665 6374 6f72 266c ...std::vector&l │ │ │ +0004fb30: 743b 6368 6172 2667 743b 2068 6561 6465 t;char> heade │ │ │ +0004fb40: 7228 7374 6174 6963 5f63 6173 7426 6c74 r(static_cast< │ │ │ +0004fb50: 3b73 7464 3a3a 7369 7a65 5f74 2667 743b ;std::size_t> │ │ │ +0004fb60: 286d 5f68 6561 6465 725f 7369 7a65 2929 (m_header_size)) │ │ │ +0004fb70: 3b0a 0a09 0975 7369 6e67 206e 616d 6573 ;....using names │ │ │ +0004fb80: 7061 6365 206c 6962 746f 7272 656e 743a pace libtorrent: │ │ │ +0004fb90: 3a61 7578 3b0a 0a09 0963 6861 722a 2070 :aux;....char* p │ │ │ +0004fba0: 7472 203d 2068 6561 6465 722e 6461 7461 tr = header.data │ │ │ +0004fbb0: 2829 3b0a 0909 7772 6974 655f 7569 6e74 ();...write_uint │ │ │ +0004fbc0: 3332 286d 5f6d 6178 5f70 6965 6365 732c 32(m_max_pieces, │ │ │ +0004fbd0: 2070 7472 293b 0a09 0977 7269 7465 5f75 ptr);...write_u │ │ │ +0004fbe0: 696e 7433 3228 6d5f 7069 6563 655f 7369 int32(m_piece_si │ │ │ +0004fbf0: 7a65 2c20 7074 7229 3b0a 0a09 0966 6f72 ze, ptr);....for │ │ │ +0004fc00: 2028 7069 6563 655f 696e 6465 785f 7420 (piece_index_t │ │ │ +0004fc10: 7069 6563 6528 3029 3b20 7069 6563 6520 piece(0); piece │ │ │ +0004fc20: 266c 743b 2070 6965 6365 5f69 6e64 6578 < piece_index │ │ │ +0004fc30: 5f74 286d 5f6d 6178 5f70 6965 6365 7329 _t(m_max_pieces) │ │ │ +0004fc40: 3b20 2b2b 7069 6563 6529 0a09 097b 0a09 ; ++piece)...{.. │ │ │ +0004fc50: 0909 6175 746f 2063 6f6e 7374 2069 203d ..auto const i = │ │ │ +0004fc60: 206d 5f70 6965 6365 5f6d 6170 2e66 696e m_piece_map.fin │ │ │ +0004fc70: 6428 7069 6563 6529 3b0a 3c2f 7072 653e d(piece);.
    │ │ │ +0004fc80: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +0004fcb0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +0004fcc0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/torr │ │ │ +0004fcf0: 656e 745f 7065 6572 2e63 7070 3a31 3933 ent_peer.cpp:193 │ │ │ +0004fd00: 3c2f 613e 3c2f 7464 3e3c 7464 3e68 6f77 how │ │ │ +0004fd10: 2064 6f20 7765 2064 6561 6c20 7769 7468 do we deal with │ │ │ +0004fd20: 206f 7572 2065 7874 6572 6e61 6c20 6164 our external ad │ │ │ +0004fd30: 6472 6573 7320 6368 616e 6769 6e67 3f3c dress changing?< │ │ │ +0004fd40: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    how │ │ │ +0004fd90: 2064 6f20 7765 2064 6561 6c20 7769 7468 do we deal with │ │ │ +0004fda0: 206f 7572 2065 7874 6572 6e61 6c20 6164 our external ad │ │ │ +0004fdb0: 6472 6573 7320 6368 616e 6769 6e67 3f3c dress changing?< │ │ │ +0004fdc0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f74 /h2>

    ../src/t │ │ │ +0004fdd0: 6f72 7265 6e74 5f70 6565 722e 6370 703a orrent_peer.cpp: │ │ │ +0004fde0: 3139 333c 2f68 343e 3c70 7265 2073 7479 193

    ..// connectio
    │ │ │ +0004fe30: 6e73 2e20 4966 2069 7420 6661 696c 732c  ns. If it fails,
    │ │ │ +0004fe40: 2077 6527 6c6c 0a09 092f 2f20 7265 7472   we'll...// retr
    │ │ │ +0004fe50: 7920 7769 7468 2065 6e63 7279 7074 696f  y with encryptio
    │ │ │ +0004fe60: 6e0a 0909 2c20 7065 5f73 7570 706f 7274  n..., pe_support
    │ │ │ +0004fe70: 2866 616c 7365 290a 2365 6e64 6966 0a09  (false).#endif..
    │ │ │ +0004fe80: 092c 2069 735f 7636 5f61 6464 7228 6661  ., is_v6_addr(fa
    │ │ │ +0004fe90: 6c73 6529 0a23 6966 2054 4f52 5245 4e54  lse).#if TORRENT
    │ │ │ +0004fea0: 5f55 5345 5f49 3250 0a09 092c 2069 735f  _USE_I2P..., is_
    │ │ │ +0004feb0: 6932 705f 6164 6472 2866 616c 7365 290a  i2p_addr(false).
    │ │ │ +0004fec0: 2365 6e64 6966 0a09 092c 206f 6e5f 7061  #endif..., on_pa
    │ │ │ +0004fed0: 726f 6c65 2866 616c 7365 290a 0909 2c20  role(false)..., 
    │ │ │ +0004fee0: 6261 6e6e 6564 2866 616c 7365 290a 0909  banned(false)...
    │ │ │ +0004fef0: 2c20 7375 7070 6f72 7473 5f75 7470 2874  , supports_utp(t
    │ │ │ +0004ff00: 7275 6529 202f 2f20 6173 7375 6d65 2070  rue) // assume p
    │ │ │ +0004ff10: 6565 7273 2073 7570 706f 7274 2075 7470  eers support utp
    │ │ │ +0004ff20: 0a09 092c 2063 6f6e 6669 726d 6564 5f73  ..., confirmed_s
    │ │ │ +0004ff30: 7570 706f 7274 735f 7574 7028 6661 6c73  upports_utp(fals
    │ │ │ +0004ff40: 6529 0a09 092c 2073 7570 706f 7274 735f  e)..., supports_
    │ │ │ +0004ff50: 686f 6c65 7075 6e63 6828 6661 6c73 6529  holepunch(false)
    │ │ │ +0004ff60: 0a09 092c 2077 6562 5f73 6565 6428 6661  ..., web_seed(fa
    │ │ │ +0004ff70: 6c73 6529 0a09 092c 2070 726f 746f 636f  lse)..., protoco
    │ │ │ +0004ff80: 6c5f 7632 2866 616c 7365 290a 097b 7d0a  l_v2(false)..{}.
    │ │ │ +0004ff90: 0a09 7374 643a 3a75 696e 7433 325f 7420  ..std::uint32_t 
    │ │ │ +0004ffa0: 746f 7272 656e 745f 7065 6572 3a3a 7261  torrent_peer::ra
    │ │ │ +0004ffb0: 6e6b 2865 7874 6572 6e61 6c5f 6970 2063  nk(external_ip c
    │ │ │ +0004ffc0: 6f6e 7374 2661 6d70 3b20 6578 7465 726e  onst& extern
    │ │ │ +0004ffd0: 616c 2c20 696e 7420 6578 7465 726e 616c  al, int external
    │ │ │ +0004ffe0: 5f70 6f72 7429 2063 6f6e 7374 0a09 7b0a  _port) const..{.
    │ │ │ +0004fff0: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ +00050000: 2869 6e5f 7573 6529 3b0a 3c64 6976 2073  (in_use);.
    ..if (pe │ │ │ +00050040: 6572 5f72 616e 6b20 3d3d 2030 290a 3c2f er_rank == 0)....peer_rank │ │ │ +00050060: 203d 2070 6565 725f 7072 696f 7269 7479 = peer_priority │ │ │ +00050070: 280a 0909 0909 7463 703a 3a65 6e64 706f (.....tcp::endpo │ │ │ +00050080: 696e 7428 6578 7465 726e 616c 2e65 7874 int(external.ext │ │ │ +00050090: 6572 6e61 6c5f 6164 6472 6573 7328 7468 ernal_address(th │ │ │ +000500a0: 6973 2d26 6774 3b61 6464 7265 7373 2829 is->address() │ │ │ +000500b0: 292c 2073 7464 3a3a 7569 6e74 3136 5f74 ), std::uint16_t │ │ │ +000500c0: 2865 7874 6572 6e61 6c5f 706f 7274 2929 (external_port)) │ │ │ +000500d0: 0a09 0909 092c 2074 6370 3a3a 656e 6470 ....., tcp::endp │ │ │ +000500e0: 6f69 6e74 2874 6869 732d 2667 743b 6164 oint(this->ad │ │ │ +000500f0: 6472 6573 7328 292c 2074 6869 732d 2667 dress(), this-&g │ │ │ +00050100: 743b 706f 7274 2929 3b0a 0909 7265 7475 t;port));...retu │ │ │ +00050110: 726e 2070 6565 725f 7261 6e6b 3b0a 097d rn peer_rank;..} │ │ │ +00050120: 0a0a 2369 666e 6465 6620 544f 5252 454e ..#ifndef TORREN │ │ │ +00050130: 545f 4449 5341 424c 455f 4c4f 4747 494e T_DISABLE_LOGGIN │ │ │ +00050140: 470a 0973 7464 3a3a 7374 7269 6e67 2074 G..std::string t │ │ │ +00050150: 6f72 7265 6e74 5f70 6565 723a 3a74 6f5f orrent_peer::to_ │ │ │ +00050160: 7374 7269 6e67 2829 2063 6f6e 7374 0a09 string() const.. │ │ │ +00050170: 7b0a 0909 544f 5252 454e 545f 4153 5345 {...TORRENT_ASSE │ │ │ +00050180: 5254 2869 6e5f 7573 6529 3b0a 2369 6620 RT(in_use);.#if │ │ │ +00050190: 544f 5252 454e 545f 5553 455f 4932 500a TORRENT_USE_I2P. │ │ │ +000501a0: 0909 6966 2028 6973 5f69 3270 5f61 6464 ..if (is_i2p_add │ │ │ +000501b0: 7229 2072 6574 7572 6e20 6465 7374 2829 r) return dest() │ │ │ +000501c0: 2e74 6f5f 7374 7269 6e67 2829 3b0a 2365 .to_string();.#e │ │ │ +000501d0: 6e64 6966 202f 2f20 544f 5252 454e 545f ndif // TORRENT_ │ │ │ +000501e0: 5553 455f 4932 500a 0909 7265 7475 726e USE_I2P...return │ │ │ +000501f0: 2061 6464 7265 7373 2829 2e74 6f5f 7374 address().to_st │ │ │ +00050200: 7269 6e67 2829 3b0a 097d 0a23 656e 6469 ring();..}.#endi │ │ │ +00050210: 660a 0a09 7374 643a 3a69 6e74 3634 5f74 f...std::int64_t │ │ │ +00050220: 2074 6f72 7265 6e74 5f70 6565 723a 3a74 torrent_peer::t │ │ │ +00050230: 6f74 616c 5f64 6f77 6e6c 6f61 6428 2920 otal_download() │ │ │ +00050240: 636f 6e73 740a 097b 0a09 0954 4f52 5245 const..{...TORRE │ │ │ +00050250: 4e54 5f41 5353 4552 5428 696e 5f75 7365 NT_ASSERT(in_use │ │ │ +00050260: 293b 0a09 0969 6620 2863 6f6e 6e65 6374 );...if (connect │ │ │ +00050270: 696f 6e20 213d 206e 756c 6c70 7472 290a ion != nullptr). │ │ │ +00050280: 0909 7b0a 0909 0954 4f52 5245 4e54 5f41 ..{....TORRENT_A │ │ │ +00050290: 5353 4552 5428 7072 6576 5f61 6d6f 756e SSERT(prev_amoun │ │ │ +000502a0: 745f 646f 776e 6c6f 6164 203d 3d20 3029 t_download == 0) │ │ │ +000502b0: 3b0a 0909 0972 6574 7572 6e20 636f 6e6e ;....return conn │ │ │ +000502c0: 6563 7469 6f6e 2d26 6774 3b73 7461 7469 ection->stati │ │ │ +000502d0: 7374 6963 7328 292e 746f 7461 6c5f 7061 stics().total_pa │ │ │ +000502e0: 796c 6f61 645f 646f 776e 6c6f 6164 2829 yload_download() │ │ │ +000502f0: 3b0a 0909 7d0a 0909 656c 7365 0a09 097b ;...}...else...{ │ │ │ +00050300: 0a09 0909 7265 7475 726e 2073 7464 3a3a ....return std:: │ │ │ +00050310: 696e 7436 345f 7428 7072 6576 5f61 6d6f int64_t(prev_amo │ │ │ +00050320: 756e 745f 646f 776e 6c6f 6164 2920 266c unt_download) &l │ │ │ +00050330: 743b 266c 743b 2031 303b 0a09 097d 0a09 t;< 10;...}.. │ │ │ +00050340: 7d0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 }.
    < │ │ │ +00050370: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00050380: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +000503b0: 7372 632f 6861 7368 5f70 6963 6b65 722e src/hash_picker. │ │ │ +000503c0: 6370 703a 3333 353c 2f61 3e3c 2f74 643e cpp:335 │ │ │ +000503d0: 3c74 643e 7573 6520 7374 7275 6374 7572 use structur │ │ │ +000503e0: 6564 2062 696e 6469 6e67 7320 696e 2043 ed bindings in C │ │ │ +000503f0: 2b2b 3137 3c2f 7464 3e3c 2f74 723e 3c74 ++17use structured │ │ │ +00050450: 2062 696e 6469 6e67 7320 696e 2043 2b2b bindings in C++ │ │ │ +00050460: 3137 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 17

    ../sr │ │ │ +00050470: 632f 6861 7368 5f70 6963 6b65 722e 6370 c/hash_picker.cp │ │ │ +00050480: 703a 3333 353c 2f68 343e 3c70 7265 2073 p:335

    .., int cons
    │ │ │ +000504d0: 7420 6f66 6673 6574 2c20 7368 6132 3536  t offset, sha256
    │ │ │ +000504e0: 5f68 6173 6820 636f 6e73 7426 616d 703b  _hash const&
    │ │ │ +000504f0: 2068 290a 097b 0a09 0954 4f52 5245 4e54   h)..{...TORRENT
    │ │ │ +00050500: 5f41 5353 4552 5428 6f66 6673 6574 2026  _ASSERT(offset &
    │ │ │ +00050510: 6774 3b3d 2030 293b 0a09 0961 7574 6f20  gt;= 0);...auto 
    │ │ │ +00050520: 636f 6e73 7420 6620 3d20 6d5f 6669 6c65  const f = m_file
    │ │ │ +00050530: 732e 6669 6c65 5f69 6e64 6578 5f61 745f  s.file_index_at_
    │ │ │ +00050540: 7069 6563 6528 7069 6563 6529 3b0a 0a09  piece(piece);...
    │ │ │ +00050550: 0969 6620 286d 5f66 696c 6573 2e70 6164  .if (m_files.pad
    │ │ │ +00050560: 5f66 696c 655f 6174 2866 2929 0a09 0909  _file_at(f))....
    │ │ │ +00050570: 7265 7475 726e 207b 2073 6574 5f62 6c6f  return { set_blo
    │ │ │ +00050580: 636b 5f68 6173 685f 7265 7375 6c74 3a3a  ck_hash_result::
    │ │ │ +00050590: 7265 7375 6c74 3a3a 7375 6363 6573 732c  result::success,
    │ │ │ +000505a0: 2030 2c20 3020 7d3b 0a0a 0909 6175 746f   0, 0 };....auto
    │ │ │ +000505b0: 2661 6d70 3b20 6d65 726b 6c65 5f74 7265  & merkle_tre
    │ │ │ +000505c0: 6520 3d20 6d5f 6d65 726b 6c65 5f74 7265  e = m_merkle_tre
    │ │ │ +000505d0: 6573 5b66 5d3b 0a09 0970 6965 6365 5f69  es[f];...piece_i
    │ │ │ +000505e0: 6e64 6578 5f74 2063 6f6e 7374 2066 696c  ndex_t const fil
    │ │ │ +000505f0: 655f 6669 7273 745f 7069 6563 6520 3d20  e_first_piece = 
    │ │ │ +00050600: 6d5f 6669 6c65 732e 7069 6563 655f 696e  m_files.piece_in
    │ │ │ +00050610: 6465 785f 6174 5f66 696c 6528 6629 3b0a  dex_at_file(f);.
    │ │ │ +00050620: 0909 7374 643a 3a69 6e74 3634 5f74 2063  ..std::int64_t c
    │ │ │ +00050630: 6f6e 7374 2062 6c6f 636b 5f6f 6666 7365  onst block_offse
    │ │ │ +00050640: 7420 3d20 7374 6174 6963 5f63 6173 7426  t = static_cast&
    │ │ │ +00050650: 6c74 3b69 6e74 2667 743b 2870 6965 6365  lt;int>(piece
    │ │ │ +00050660: 2920 2a20 7374 643a 3a69 6e74 3634 5f74  ) * std::int64_t
    │ │ │ +00050670: 286d 5f66 696c 6573 2e70 6965 6365 5f6c  (m_files.piece_l
    │ │ │ +00050680: 656e 6774 6828 2929 0a09 0909 2b20 6f66  ength())....+ of
    │ │ │ +00050690: 6673 6574 202d 206d 5f66 696c 6573 2e66  fset - m_files.f
    │ │ │ +000506a0: 696c 655f 6f66 6673 6574 2866 293b 0a09  ile_offset(f);..
    │ │ │ +000506b0: 0969 6e74 2063 6f6e 7374 2062 6c6f 636b  .int const block
    │ │ │ +000506c0: 5f69 6e64 6578 203d 2061 7578 3a3a 6e75  _index = aux::nu
    │ │ │ +000506d0: 6d65 7269 635f 6361 7374 266c 743b 696e  meric_cast<in
    │ │ │ +000506e0: 7426 6774 3b28 626c 6f63 6b5f 6f66 6673  t>(block_offs
    │ │ │ +000506f0: 6574 202f 2064 6566 6175 6c74 5f62 6c6f  et / default_blo
    │ │ │ +00050700: 636b 5f73 697a 6529 3b0a 0a09 0969 6620  ck_size);....if 
    │ │ │ +00050710: 2868 2e69 735f 616c 6c5f 7a65 726f 7328  (h.is_all_zeros(
    │ │ │ +00050720: 2929 0a09 097b 0a09 0909 544f 5252 454e  ))...{....TORREN
    │ │ │ +00050730: 545f 4153 5345 5254 5f46 4149 4c28 293b  T_ASSERT_FAIL();
    │ │ │ +00050740: 0a09 0909 7265 7475 726e 2073 6574 5f62  ....return set_b
    │ │ │ +00050750: 6c6f 636b 5f68 6173 685f 7265 7375 6c74  lock_hash_result
    │ │ │ +00050760: 3a3a 626c 6f63 6b5f 6861 7368 5f66 6169  ::block_hash_fai
    │ │ │ +00050770: 6c65 6428 293b 0a09 097d 0a0a 3c64 6976  led();...}..
    ..aux: │ │ │ +000507b0: 3a6d 6572 6b6c 655f 7472 6565 3a3a 7365 :merkle_tree::se │ │ │ +000507c0: 745f 626c 6f63 6b5f 7265 7375 6c74 2072 t_block_result r │ │ │ +000507d0: 6573 756c 743b 0a3c 2f64 6976 3e09 0969 esult;.
    ..i │ │ │ +000507e0: 6e74 206c 6561 6673 5f69 6e64 6578 3b0a nt leafs_index;. │ │ │ +000507f0: 0909 696e 7420 6c65 6166 735f 7369 7a65 ..int leafs_size │ │ │ +00050800: 3b0a 0909 7374 643a 3a74 6965 2872 6573 ;...std::tie(res │ │ │ +00050810: 756c 742c 206c 6561 6673 5f69 6e64 6578 ult, leafs_index │ │ │ +00050820: 2c20 6c65 6166 735f 7369 7a65 2920 3d20 , leafs_size) = │ │ │ +00050830: 6d65 726b 6c65 5f74 7265 652e 7365 745f merkle_tree.set_ │ │ │ +00050840: 626c 6f63 6b28 626c 6f63 6b5f 696e 6465 block(block_inde │ │ │ +00050850: 782c 2068 293b 0a0a 0909 6966 2028 7265 x, h);....if (re │ │ │ +00050860: 7375 6c74 203d 3d20 6175 783a 3a6d 6572 sult == aux::mer │ │ │ +00050870: 6b6c 655f 7472 6565 3a3a 7365 745f 626c kle_tree::set_bl │ │ │ +00050880: 6f63 6b5f 7265 7375 6c74 3a3a 756e 6b6e ock_result::unkn │ │ │ +00050890: 6f77 6e29 0a09 0909 7265 7475 726e 2073 own)....return s │ │ │ +000508a0: 6574 5f62 6c6f 636b 5f68 6173 685f 7265 et_block_hash_re │ │ │ +000508b0: 7375 6c74 3a3a 756e 6b6e 6f77 6e28 293b sult::unknown(); │ │ │ +000508c0: 0a09 0969 6620 2872 6573 756c 7420 3d3d ...if (result == │ │ │ +000508d0: 2061 7578 3a3a 6d65 726b 6c65 5f74 7265 aux::merkle_tre │ │ │ +000508e0: 653a 3a73 6574 5f62 6c6f 636b 5f72 6573 e::set_block_res │ │ │ +000508f0: 756c 743a 3a62 6c6f 636b 5f68 6173 685f ult::block_hash_ │ │ │ +00050900: 6661 696c 6564 290a 0909 0972 6574 7572 failed)....retur │ │ │ +00050910: 6e20 7365 745f 626c 6f63 6b5f 6861 7368 n set_block_hash │ │ │ +00050920: 5f72 6573 756c 743a 3a62 6c6f 636b 5f68 _result::block_h │ │ │ +00050930: 6173 685f 6661 696c 6564 2829 3b0a 0a09 ash_failed();... │ │ │ +00050940: 0961 7574 6f20 636f 6e73 7420 7374 6174 .auto const stat │ │ │ +00050950: 7573 203d 2028 7265 7375 6c74 203d 3d20 us = (result == │ │ │ +00050960: 6175 783a 3a6d 6572 6b6c 655f 7472 6565 aux::merkle_tree │ │ │ +00050970: 3a3a 7365 745f 626c 6f63 6b5f 7265 7375 ::set_block_resu │ │ │ +00050980: 6c74 3a3a 6861 7368 5f66 6169 6c65 6429 lt::hash_failed) │ │ │ +00050990: 0a09 0909 3f20 7365 745f 626c 6f63 6b5f ....? set_block_ │ │ │ +000509a0: 6861 7368 5f72 6573 756c 743a 3a72 6573 hash_result::res │ │ │ +000509b0: 756c 743a 3a70 6965 6365 5f68 6173 685f ult::piece_hash_ │ │ │ +000509c0: 6661 696c 6564 0a09 0909 3a20 7365 745f failed....: set_ │ │ │ +000509d0: 626c 6f63 6b5f 6861 7368 5f72 6573 756c block_hash_resul │ │ │ +000509e0: 743a 3a72 6573 756c 743a 3a73 7563 6365 t::result::succe │ │ │ +000509f0: 7373 3b0a 0a09 0969 6e74 2063 6f6e 7374 ss;....int const │ │ │ +00050a00: 2062 6c6f 636b 735f 7065 725f 7069 6563 blocks_per_piec │ │ │ +00050a10: 6520 3d20 6d5f 6669 6c65 732e 7069 6563 e = m_files.piec │ │ │ +00050a20: 655f 6c65 6e67 7468 2829 202f 2064 6566 e_length() / def │ │ │ +00050a30: 6175 6c74 5f62 6c6f 636b 5f73 697a 653b ault_block_size; │ │ │ +00050a40: 0a0a 0909 7265 7475 726e 207b 2073 7461 ....return { sta │ │ │ +00050a50: 7475 730a 0909 092c 2069 6e74 286c 6561 tus...., int(lea │ │ │ +00050a60: 6673 5f69 6e64 6578 202d 2073 7461 7469 fs_index - stati │ │ │ +00050a70: 635f 6361 7374 266c 743b 696e 7426 6774 c_cast<int> │ │ │ +00050a80: 3b28 7069 6563 6520 2d20 6669 6c65 5f66 ;(piece - file_f │ │ │ +00050a90: 6972 7374 5f70 6965 6365 2920 2a20 626c irst_piece) * bl │ │ │ +00050aa0: 6f63 6b73 5f70 6572 5f70 6965 6365 290a ocks_per_piece). │ │ │ +00050ab0: 0909 092c 2073 7464 3a3a 6d69 6e28 6c65 ..., std::min(le │ │ │ +00050ac0: 6166 735f 7369 7a65 2c20 6d5f 6669 6c65 afs_size, m_file │ │ │ +00050ad0: 732e 6669 6c65 5f6e 756d 5f70 6965 6365 s.file_num_piece │ │ │ +00050ae0: 7328 6629 202a 2062 6c6f 636b 735f 7065 s(f) * blocks_pe │ │ │ +00050af0: 725f 7069 6563 6520 2d20 6c65 6166 735f r_piece - leafs_ │ │ │ +00050b00: 696e 6465 7829 207d 3b0a 097d 0a0a 0976 index) };..}...v │ │ │ +00050b10: 6f69 6420 6861 7368 5f70 6963 6b65 723a oid hash_picker: │ │ │ +00050b20: 3a68 6173 6865 735f 7265 6a65 6374 6564 :hashes_rejected │ │ │ +00050b30: 2868 6173 685f 7265 7175 6573 7420 636f (hash_request co │ │ │ +00050b40: 6e73 7426 616d 703b 2072 6571 290a 097b nst& req)..{ │ │ │ +00050b50: 0a09 092f 2f20 6f6e 6c79 2072 6571 7565 ...// only reque │ │ │ +00050b60: 7374 7320 6174 2074 6865 2070 6965 6365 sts at the piece │ │ │ +00050b70: 206c 6179 6572 2061 7265 2072 6563 6f72 layer are recor │ │ │ +00050b80: 6465 6420 696e 0a09 092f 2f20 6d5f 7069 ded in...// m_pi │ │ │ +00050b90: 6563 655f 6861 7368 5f72 6571 7565 7374 ece_hash_request │ │ │ +00050ba0: 6564 2e0a 0909 6966 2028 7265 712e 6261 ed....if (req.ba │ │ │ +00050bb0: 7365 2021 3d20 6d5f 7069 6563 655f 6c61 se != m_piece_la │ │ │ +00050bc0: 7965 7220 7c7c 2072 6571 2e69 6e64 6578 yer || req.index │ │ │ +00050bd0: 2025 2035 3132 2021 3d20 3020 7c7c 2072 % 512 != 0 || r │ │ │ +00050be0: 6571 2e63 6f75 6e74 2026 6774 3b20 3531 eq.count > 51 │ │ │ +00050bf0: 320a 0909 097c 7c20 7265 712e 696e 6465 2....|| req.inde │ │ │ +00050c00: 7820 2667 743b 3d20 6d5f 6669 6c65 732e x >= m_files. │ │ │ +00050c10: 6669 6c65 5f6e 756d 5f70 6965 6365 7328 file_num_pieces( │ │ │ +00050c20: 7265 712e 6669 6c65 2929 0a09 0909 7265 req.file))....re │ │ │ +00050c30: 7475 726e 3b0a 0a09 0966 6f72 2028 696e turn;....for (in │ │ │ +00050c40: 7420 6920 3d20 7265 712e 696e 6465 783b t i = req.index; │ │ │ +00050c50: 2069 2026 6c74 3b20 7265 712e 696e 6465 i < req.inde │ │ │ +00050c60: 7820 2b20 7265 712e 636f 756e 743b 2069 x + req.count; i │ │ │ +00050c70: 202b 3d20 3531 3229 0a09 097b 0a3c 2f70 += 512)...{.

    re │ │ │ +00050cb0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/m │ │ │ +00050cf0: 6167 6e65 745f 7572 692e 6370 703a 3435 agnet_uri.cpp:45 │ │ │ +00050d00: 313c 2f61 3e3c 2f74 643e 3c74 643e 7768 1wh │ │ │ +00050d10: 6174 2773 2074 6865 2072 6967 6874 206e at's the right n │ │ │ +00050d20: 756d 6265 7220 6865 7265 3f3c 2f74 643e umber here? │ │ │ +00050d30: 3c2f 7472 3e3c 7472 2069 643d 2231 3931

    what's │ │ │ +00050d80: 7468 6520 7269 6768 7420 6e75 6d62 6572 the right number │ │ │ +00050d90: 2068 6572 653f 3c2f 6832 3e3c 6834 3e2e here?

    . │ │ │ +00050da0: 2e2f 7372 632f 6d61 676e 6574 5f75 7269 ./src/magnet_uri │ │ │ +00050db0: 2e63 7070 3a34 3531 3c2f 6834 3e3c 7072 .cpp:451

    ...}....e │ │ │ +00050e00: 6c73 6520 6966 2028 7374 7269 6e67 5f65 lse if (string_e │ │ │ +00050e10: 7175 616c 5f6e 6f5f 6361 7365 286e 616d qual_no_case(nam │ │ │ +00050e20: 652c 2022 736f 225f 7376 2929 202f 2f20 e, "so"_sv)) // │ │ │ +00050e30: 7365 6c65 6374 2d6f 6e6c 7920 2866 696c select-only (fil │ │ │ +00050e40: 6573 290a 0909 097b 0a09 0909 092f 2f20 es)....{.....// │ │ │ +00050e50: 6163 6365 7074 206f 6e6c 7920 6469 6769 accept only digi │ │ │ +00050e60: 7473 2c20 272d 2720 616e 6420 272c 270a ts, '-' and ','. │ │ │ +00050e70: 0909 0909 6966 2028 7374 643a 3a61 6e79 ....if (std::any │ │ │ +00050e80: 5f6f 6628 7661 6c75 652e 6265 6769 6e28 _of(value.begin( │ │ │ +00050e90: 292c 2076 616c 7565 2e65 6e64 2829 2c20 ), value.end(), │ │ │ +00050ea0: 5b5d 2863 6861 7220 6329 0a09 0909 0909 [](char c)...... │ │ │ +00050eb0: 7b20 7265 7475 726e 2021 6973 5f64 6967 { return !is_dig │ │ │ +00050ec0: 6974 2863 2920 2661 6d70 3b26 616d 703b it(c) && │ │ │ +00050ed0: 2063 2021 3d20 272d 2720 2661 6d70 3b26 c != '-' && │ │ │ +00050ee0: 616d 703b 2063 2021 3d20 272c 273b 207d amp; c != ','; } │ │ │ +00050ef0: 2929 0a09 0909 0909 636f 6e74 696e 7565 ))......continue │ │ │ +00050f00: 3b0a 0a09 0909 092f 2f20 6d61 6b65 2073 ;......// make s │ │ │ +00050f10: 7572 6520 616c 6c20 6669 6c65 2070 7269 ure all file pri │ │ │ +00050f20: 6f72 6974 6965 7320 6172 6520 7365 7420 orities are set │ │ │ +00050f30: 746f 2030 2c20 6578 6365 7074 2074 6865 to 0, except the │ │ │ +00050f40: 206f 6e65 730a 0909 0909 2f2f 2077 6520 ones.....// we │ │ │ +00050f50: 7370 6563 6966 7920 696e 2074 6865 2066 specify in the f │ │ │ +00050f60: 696c 655f 7072 696f 7269 7469 6573 0a09 ile_priorities.. │ │ │ +00050f70: 0909 0970 2e66 6c61 6773 207c 3d20 746f ...p.flags |= to │ │ │ +00050f80: 7272 656e 745f 666c 6167 733a 3a64 6566 rrent_flags::def │ │ │ +00050f90: 6175 6c74 5f64 6f6e 745f 646f 776e 6c6f ault_dont_downlo │ │ │ +00050fa0: 6164 3b0a 0a09 0909 0964 6f0a 0909 0909 ad;......do..... │ │ │ +00050fb0: 7b0a 0909 0909 0973 7472 696e 675f 7669 {......string_vi │ │ │ +00050fc0: 6577 2074 6f6b 656e 3b0a 0909 0909 0973 ew token;......s │ │ │ +00050fd0: 7464 3a3a 7469 6528 746f 6b65 6e2c 2076 td::tie(token, v │ │ │ +00050fe0: 616c 7565 2920 3d20 7370 6c69 745f 7374 alue) = split_st │ │ │ +00050ff0: 7269 6e67 2876 616c 7565 2c20 272c 2729 ring(value, ',') │ │ │ +00051000: 3b0a 0a09 0909 0909 6966 2028 746f 6b65 ;.......if (toke │ │ │ +00051010: 6e2e 656d 7074 7928 2929 2063 6f6e 7469 n.empty()) conti │ │ │ +00051020: 6e75 653b 0a0a 0909 0909 0969 6e74 2069 nue;.......int i │ │ │ +00051030: 6478 312c 2069 6478 323b 0a3c 6469 7620 dx1, idx2;.
    .....co │ │ │ +00051070: 6e73 7465 7870 7220 696e 7420 6d61 785f nstexpr int max_ │ │ │ +00051080: 696e 6465 7820 3d20 3130 3030 303b 202f index = 10000; / │ │ │ +00051090: 2f20 6361 6e27 7420 7269 736b 206f 7574 / can't risk out │ │ │ +000510a0: 206f 6620 6d65 6d6f 7279 0a3c 2f64 6976 of memory.
    ......auto cons │ │ │ +000510c0: 7420 6469 7669 6465 7220 3d20 746f 6b65 t divider = toke │ │ │ +000510d0: 6e2e 6669 6e64 5f66 6972 7374 5f6f 6628 n.find_first_of( │ │ │ +000510e0: 272d 2729 3b0a 0909 0909 0969 6620 2864 '-');......if (d │ │ │ +000510f0: 6976 6964 6572 2021 3d20 7374 643a 3a73 ivider != std::s │ │ │ +00051100: 7472 696e 673a 3a6e 706f 7329 202f 2f20 tring::npos) // │ │ │ +00051110: 6974 2773 2061 2072 616e 6765 0a09 0909 it's a range.... │ │ │ +00051120: 0909 7b0a 0909 0909 0909 6966 2028 6469 ..{.......if (di │ │ │ +00051130: 7669 6465 7220 3d3d 2030 2920 2f2f 206e vider == 0) // n │ │ │ +00051140: 6f20 7374 6172 7420 696e 6465 780a 0909 o start index... │ │ │ +00051150: 0909 0909 0963 6f6e 7469 6e75 653b 0a09 .....continue;.. │ │ │ +00051160: 0909 0909 0969 6620 2864 6976 6964 6572 .....if (divider │ │ │ +00051170: 203d 3d20 746f 6b65 6e2e 7369 7a65 2829 == token.size() │ │ │ +00051180: 202d 2031 2920 2f2f 206e 6f20 656e 6420 - 1) // no end │ │ │ +00051190: 696e 6465 780a 0909 0909 0909 0963 6f6e index........con │ │ │ +000511a0: 7469 6e75 653b 0a0a 0909 0909 0909 6964 tinue;........id │ │ │ +000511b0: 7831 203d 2073 7464 3a3a 6174 6f69 2874 x1 = std::atoi(t │ │ │ +000511c0: 6f6b 656e 2e73 7562 7374 7228 302c 2064 oken.substr(0, d │ │ │ +000511d0: 6976 6964 6572 292e 746f 5f73 7472 696e ivider).to_strin │ │ │ +000511e0: 6728 292e 635f 7374 7228 2929 3b0a 0909 g().c_str());... │ │ │ +000511f0: 0909 0909 6966 2028 6964 7831 2026 6c74 ....if (idx1 < │ │ │ +00051200: 3b20 3020 7c7c 2069 6478 3120 2667 743b ; 0 || idx1 > │ │ │ +00051210: 206d 6178 5f69 6e64 6578 2920 2f2f 2069 max_index) // i │ │ │ +00051220: 6e76 616c 6964 2069 6e64 6578 0a09 0909 nvalid index.... │ │ │ +00051230: 0909 0909 636f 6e74 696e 7565 3b0a 0909 ....continue;... │ │ │ +00051240: 0909 0909 6964 7832 203d 2073 7464 3a3a ....idx2 = std:: │ │ │ +00051250: 6174 6f69 2874 6f6b 656e 2e73 7562 7374 atoi(token.subst │ │ │ +00051260: 7228 6469 7669 6465 7220 2b20 3129 2e74 r(divider + 1).t │ │ │ +00051270: 6f5f 7374 7269 6e67 2829 2e63 5f73 7472 o_string().c_str │ │ │ +00051280: 2829 293b 0a09 0909 0909 0969 6620 2869 ());.......if (i │ │ │ +00051290: 6478 3220 266c 743b 2030 207c 7c20 6964 dx2 < 0 || id │ │ │ +000512a0: 7832 2026 6774 3b20 6d61 785f 696e 6465 x2 > max_inde │ │ │ +000512b0: 7829 202f 2f20 696e 7661 6c69 6420 696e x) // invalid in │ │ │ +000512c0: 6465 780a 0909 0909 0909 0963 6f6e 7469 dex........conti │ │ │ +000512d0: 6e75 653b 0a0a 0909 0909 0909 6966 2028 nue;........if ( │ │ │ +000512e0: 6964 7831 2026 6774 3b20 6964 7832 2920 idx1 > idx2) │ │ │ +000512f0: 2f2f 2077 726f 6e67 2072 616e 6765 206c // wrong range l │ │ │ +00051300: 696d 6974 730a 0909 0909 0909 0963 6f6e imits........con │ │ │ +00051310: 7469 6e75 653b 0a09 0909 0909 7d0a 0909 tinue;......}... │ │ │ +00051320: 0909 0965 6c73 6520 2f2f 2069 7427 7320 ...else // it's │ │ │ +00051330: 616e 2069 6e64 6578 0a09 0909 0909 7b0a an index......{. │ │ │ +00051340: 0909 0909 0909 6964 7831 203d 2073 7464 ......idx1 = std │ │ │ +00051350: 3a3a 6174 6f69 2874 6f6b 656e 2e74 6f5f ::atoi(token.to_ │ │ │ +00051360: 7374 7269 6e67 2829 2e63 5f73 7472 2829 string().c_str() │ │ │ +00051370: 293b 0a09 0909 0909 0969 6620 2869 6478 );.......if (idx │ │ │ +00051380: 3120 266c 743b 2030 207c 7c20 6964 7831 1 < 0 || idx1 │ │ │ +00051390: 2026 6774 3b20 6d61 785f 696e 6465 7829 > max_index) │ │ │ +000513a0: 202f 2f20 696e 7661 6c69 6420 696e 6465 // invalid inde │ │ │ +000513b0: 780a 0909 0909 0909 0963 6f6e 7469 6e75 x........continu │ │ │ +000513c0: 653b 0a09 0909 0909 0969 6478 3220 3d20 e;.......idx2 = │ │ │ +000513d0: 6964 7831 3b0a 0909 0909 097d 0a0a 0909 idx1;......}.... │ │ │ +000513e0: 0909 0969 6620 2869 6e74 2870 2e66 696c ...if (int(p.fil │ │ │ +000513f0: 655f 7072 696f 7269 7469 6573 2e73 697a e_priorities.siz │ │ │ +00051400: 6528 2929 2026 6c74 3b3d 2069 6478 3229 e()) <= idx2) │ │ │ +00051410: 0a09 0909 0909 0970 2e66 696c 655f 7072 .......p.file_pr │ │ │ +00051420: 696f 7269 7469 6573 2e72 6573 697a 6528 iorities.resize( │ │ │ +00051430: 7374 6174 6963 5f63 6173 7426 6c74 3b73 static_cast<s │ │ │ +00051440: 7464 3a3a 7369 7a65 5f74 2667 743b 2869 td::size_t>(i │ │ │ +00051450: 6478 3229 202b 2031 2c20 646f 6e74 5f64 dx2) + 1, dont_d │ │ │ +00051460: 6f77 6e6c 6f61 6429 3b0a 0a3c 2f70 7265 ownload);..
    rele │ │ │ +000514a0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/ran │ │ │ +000514e0: 646f 6d2e 6370 703a 3134 313c 2f61 3e3c dom.cpp:141< │ │ │ +000514f0: 2f74 643e 3c74 643e 696d 7072 6f76 6520 /td>improve │ │ │ +00051500: 6361 6c6c 696e 6720 5241 4e44 5f62 7974 calling RAND_byt │ │ │ +00051510: 6573 206d 756c 7469 706c 6520 7469 6d65 es multiple time │ │ │ +00051520: 732c 2075 7369 6e67 2066 616c 6c62 6163 s, using fallbac │ │ │ +00051530: 6b20 666f 7220 6e6f 773c 2f74 643e 3c2f k for now

    improve c │ │ │ +00051590: 616c 6c69 6e67 2052 414e 445f 6279 7465 alling RAND_byte │ │ │ +000515a0: 7320 6d75 6c74 6970 6c65 2074 696d 6573 s multiple times │ │ │ +000515b0: 2c20 7573 696e 6720 6661 6c6c 6261 636b , using fallback │ │ │ +000515c0: 2066 6f72 206e 6f77 3c2f 6832 3e3c 6834 for now

    ../src/random.c │ │ │ +000515e0: 7070 3a31 3431 3c2f 6834 3e3c 7072 6520 pp:141

    #else....st
    │ │ │ +00051630: 643a 3a67 656e 6572 6174 6528 6275 6666  d::generate(buff
    │ │ │ +00051640: 6572 2e62 6567 696e 2829 2c20 6275 6666  er.begin(), buff
    │ │ │ +00051650: 6572 2e65 6e64 2829 2c20 5b5d 207b 2072  er.end(), [] { r
    │ │ │ +00051660: 6574 7572 6e20 6368 6172 2872 616e 646f  eturn char(rando
    │ │ │ +00051670: 6d28 3078 6666 2929 3b20 7d29 3b0a 2365  m(0xff)); });.#e
    │ │ │ +00051680: 6e64 6966 0a09 097d 0a0a 0909 766f 6964  ndif...}....void
    │ │ │ +00051690: 2063 7279 7074 6f5f 7261 6e64 6f6d 5f62   crypto_random_b
    │ │ │ +000516a0: 7974 6573 2873 7061 6e26 6c74 3b63 6861  ytes(span<cha
    │ │ │ +000516b0: 7226 6774 3b20 6275 6666 6572 290a 0909  r> buffer)...
    │ │ │ +000516c0: 7b0a 2369 6664 6566 2054 4f52 5245 4e54  {.#ifdef TORRENT
    │ │ │ +000516d0: 5f42 5549 4c44 5f53 494d 554c 4154 4f52  _BUILD_SIMULATOR
    │ │ │ +000516e0: 0a09 0909 2f2f 2049 6e20 7468 6520 7369  ....// In the si
    │ │ │ +000516f0: 6d75 6c61 746f 7220 7765 2077 616e 7420  mulator we want 
    │ │ │ +00051700: 6465 7465 726d 696e 6973 7469 6320 7261  deterministic ra
    │ │ │ +00051710: 6e64 6f6d 206e 756d 6265 7273 0a09 0909  ndom numbers....
    │ │ │ +00051720: 7374 643a 3a67 656e 6572 6174 6528 6275  std::generate(bu
    │ │ │ +00051730: 6666 6572 2e62 6567 696e 2829 2c20 6275  ffer.begin(), bu
    │ │ │ +00051740: 6666 6572 2e65 6e64 2829 2c20 5b5d 207b  ffer.end(), [] {
    │ │ │ +00051750: 2072 6574 7572 6e20 6368 6172 2872 616e   return char(ran
    │ │ │ +00051760: 646f 6d28 3078 6666 2929 3b20 7d29 3b0a  dom(0xff)); });.
    │ │ │ +00051770: 2365 6c69 6620 544f 5252 454e 545f 5553  #elif TORRENT_US
    │ │ │ +00051780: 455f 434e 470a 0909 0961 7578 3a3a 636e  E_CNG....aux::cn
    │ │ │ +00051790: 675f 6765 6e5f 7261 6e64 6f6d 2862 7566  g_gen_random(buf
    │ │ │ +000517a0: 6665 7229 3b0a 2365 6c69 6620 544f 5252  fer);.#elif TORR
    │ │ │ +000517b0: 454e 545f 5553 455f 4352 5950 544f 4150  ENT_USE_CRYPTOAP
    │ │ │ +000517c0: 490a 0909 092f 2f20 7769 6e64 6f77 730a  I....// windows.
    │ │ │ +000517d0: 0909 0961 7578 3a3a 6372 7970 745f 6765  ...aux::crypt_ge
    │ │ │ +000517e0: 6e5f 7261 6e64 6f6d 2862 7566 6665 7229  n_random(buffer)
    │ │ │ +000517f0: 3b0a 2365 6c69 6620 6465 6669 6e65 6420  ;.#elif defined 
    │ │ │ +00051800: 544f 5252 454e 545f 5553 455f 4c49 4243  TORRENT_USE_LIBC
    │ │ │ +00051810: 5259 5054 4f20 2661 6d70 3b26 616d 703b  RYPTO &&
    │ │ │ +00051820: 2021 6465 6669 6e65 6420 544f 5252 454e   !defined TORREN
    │ │ │ +00051830: 545f 5553 455f 574f 4c46 5353 4c0a 2f2f  T_USE_WOLFSSL.//
    │ │ │ +00051840: 2077 6f6c 6653 534c 2075 7365 7320 7763   wolfSSL uses wc
    │ │ │ +00051850: 5f52 4e47 5f47 656e 6572 6174 6542 6c6f  _RNG_GenerateBlo
    │ │ │ +00051860: 636b 2061 7320 7468 6520 696e 7465 726e  ck as the intern
    │ │ │ +00051870: 616c 2066 756e 6374 696f 6e20 666f 7220  al function for 
    │ │ │ +00051880: 7468 650a 2f2f 206f 7065 6e73 736c 2063  the.// openssl c
    │ │ │ +00051890: 6f6d 7061 7469 6269 6c69 7479 206c 6179  ompatibility lay
    │ │ │ +000518a0: 6572 2e20 5468 6973 2066 756e 6374 696f  er. This functio
    │ │ │ +000518b0: 6e20 4150 4920 646f 6573 206e 6f74 2073  n API does not s
    │ │ │ +000518c0: 7570 706f 7274 0a2f 2f20 616e 2061 7262  upport.// an arb
    │ │ │ +000518d0: 6974 7261 7279 2062 7566 6665 7220 7369  itrary buffer si
    │ │ │ +000518e0: 7a65 2028 6f70 656e 7373 6c20 646f 6573  ze (openssl does
    │ │ │ +000518f0: 292c 2069 7420 6973 206c 696d 6974 6564  ), it is limited
    │ │ │ +00051900: 2062 7920 7468 650a 2f2f 2063 6f6e 7374   by the.// const
    │ │ │ +00051910: 616e 7420 524e 475f 4d41 585f 424c 4f43  ant RNG_MAX_BLOC
    │ │ │ +00051920: 4b5f 4c45 4e2e 0a3c 6469 7620 7374 796c  K_LEN..
    .
    .../ │ │ │ +00051960: 2f20 6f70 656e 7373 6c0a 0909 0969 6e74 / openssl....int │ │ │ +00051970: 2072 203d 2052 414e 445f 6279 7465 7328 r = RAND_bytes( │ │ │ +00051980: 7265 696e 7465 7270 7265 745f 6361 7374 reinterpret_cast │ │ │ +00051990: 266c 743b 756e 7369 676e 6564 2063 6861 <unsigned cha │ │ │ +000519a0: 722a 2667 743b 2862 7566 6665 722e 6461 r*>(buffer.da │ │ │ +000519b0: 7461 2829 290a 0909 0909 2c20 696e 7428 ta())....., int( │ │ │ +000519c0: 6275 6666 6572 2e73 697a 6528 2929 293b buffer.size())); │ │ │ +000519d0: 0a09 0909 6966 2028 7220 213d 2031 2920 ....if (r != 1) │ │ │ +000519e0: 6175 783a 3a74 6872 6f77 5f65 7826 6c74 aux::throw_ex< │ │ │ +000519f0: 3b73 7973 7465 6d5f 6572 726f 7226 6774 ;system_error> │ │ │ +00051a00: 3b28 6572 726f 7273 3a3a 6e6f 5f65 6e74 ;(errors::no_ent │ │ │ +00051a10: 726f 7079 293b 0a23 656c 6966 2054 4f52 ropy);.#elif TOR │ │ │ +00051a20: 5245 4e54 5f55 5345 5f47 4554 5241 4e44 RENT_USE_GETRAND │ │ │ +00051a30: 4f4d 0a09 0909 7373 697a 655f 7420 636f OM....ssize_t co │ │ │ +00051a40: 6e73 7420 7220 3d20 3a3a 6765 7472 616e nst r = ::getran │ │ │ +00051a50: 646f 6d28 6275 6666 6572 2e64 6174 6128 dom(buffer.data( │ │ │ +00051a60: 292c 2073 7461 7469 635f 6361 7374 266c ), static_cast&l │ │ │ +00051a70: 743b 7374 643a 3a73 697a 655f 7426 6774 t;std::size_t> │ │ │ +00051a80: 3b28 6275 6666 6572 2e73 697a 6528 2929 ;(buffer.size()) │ │ │ +00051a90: 2c20 3029 3b0a 0909 0969 6620 2872 203d , 0);....if (r = │ │ │ +00051aa0: 3d20 7373 697a 655f 7428 6275 6666 6572 = ssize_t(buffer │ │ │ +00051ab0: 2e73 697a 6528 2929 2920 7265 7475 726e .size())) return │ │ │ +00051ac0: 3b0a 0909 0969 6620 2872 203d 3d20 2d31 ;....if (r == -1 │ │ │ +00051ad0: 2026 616d 703b 2661 6d70 3b20 6572 726e && errn │ │ │ +00051ae0: 6f20 213d 2045 4e4f 5359 5329 2061 7578 o != ENOSYS) aux │ │ │ +00051af0: 3a3a 7468 726f 775f 6578 266c 743b 7379 ::throw_ex<sy │ │ │ +00051b00: 7374 656d 5f65 7272 6f72 2667 743b 2865 stem_error>(e │ │ │ +00051b10: 7272 6f72 5f63 6f64 6528 6572 726e 6f2c rror_code(errno, │ │ │ +00051b20: 2067 656e 6572 6963 5f63 6174 6567 6f72 generic_categor │ │ │ +00051b30: 7928 2929 293b 0a09 0909 7374 6174 6963 y()));....static │ │ │ +00051b40: 2064 6576 5f72 616e 646f 6d20 6465 763b dev_random dev; │ │ │ +00051b50: 0a09 0909 6465 762e 7265 6164 2862 7566 ....dev.read(buf │ │ │ +00051b60: 6665 7229 3b0a 2365 6c69 6620 544f 5252 fer);.#elif TORR │ │ │ +00051b70: 454e 545f 5553 455f 4445 565f 5241 4e44 ENT_USE_DEV_RAND │ │ │ +00051b80: 4f4d 0a09 0909 7374 6174 6963 2064 6576 OM....static dev │ │ │ +00051b90: 5f72 616e 646f 6d20 6465 763b 0a09 0909 _random dev;.... │ │ │ +00051ba0: 6465 762e 7265 6164 2862 7566 6665 7229 dev.read(buffer) │ │ │ +00051bb0: 3b0a 2365 6c73 650a 0a23 6966 2054 4f52 ;.#else..#if TOR │ │ │ +00051bc0: 5245 4e54 5f42 524f 4b45 4e5f 5241 4e44 RENT_BROKEN_RAND │ │ │ +00051bd0: 4f4d 5f44 4556 4943 450a 0909 092f 2f20 OM_DEVICE....// │ │ │ +00051be0: 6576 656e 2070 7365 7564 6f20 7261 6e64 even pseudo rand │ │ │ +00051bf0: 6f6d 206e 756d 6265 7273 2072 656c 7920 om numbers rely │ │ │ +00051c00: 6f6e 2062 6569 6e67 2061 626c 6520 746f on being able to │ │ │ +00051c10: 2073 6565 6420 7468 6520 7261 6e64 6f6d seed the random │ │ │ +00051c20: 0a09 0909 2f2f 2067 656e 6572 6174 6f72 ....// generator │ │ │ +00051c30: 0a23 6572 726f 7220 226e 6f20 656e 7472 .#error "no entr │ │ │ +00051c40: 6f70 7920 736f 7572 6365 2061 7661 696c opy source avail │ │ │ +00051c50: 6162 6c65 220a 2365 6c73 650a 2369 6664 able".#else.#ifd │ │ │ +00051c60: 6566 2054 4f52 5245 4e54 5f49 5f57 414e ef TORRENT_I_WAN │ │ │ +00051c70: 545f 494e 5345 4355 5245 5f52 414e 444f T_INSECURE_RANDO │ │ │ +00051c80: 4d5f 4e55 4d42 4552 530a 0909 0973 7464 M_NUMBERS....std │ │ │ +00051c90: 3a3a 6765 6e65 7261 7465 2862 7566 6665 ::generate(buffe │ │ │ +00051ca0: 722e 6265 6769 6e28 292c 2062 7566 6665 r.begin(), buffe │ │ │ +00051cb0: 722e 656e 6428 292c 205b 5d20 7b20 7265 r.end(), [] { re │ │ │ +00051cc0: 7475 726e 2063 6861 7228 7261 6e64 6f6d turn char(random │ │ │ +00051cd0: 2830 7866 6629 293b 207d 293b 0a23 656c (0xff)); });.#el │ │ │ +00051ce0: 7365 0a23 6572 726f 7220 226e 6f20 7365 se.#error "no se │ │ │ +00051cf0: 6375 7265 2065 6e74 726f 7079 2073 6f75 cure entropy sou │ │ │ +00051d00: 7263 6520 6176 6169 6c61 626c 652e 2049 rce available. I │ │ │ +00051d10: 6620 796f 7520 7265 616c 6c79 2077 616e f you really wan │ │ │ +00051d20: 7420 696e 7365 6375 7265 2072 616e 646f t insecure rando │ │ │ +00051d30: 6d20 6e75 6d62 6572 732c 2064 6566 696e m numbers, defin │ │ │ +00051d40: 6520 544f 5252 454e 545f 495f 5741 4e54 e TORRENT_I_WANT │ │ │ +00051d50: 5f49 4e53 4543 5552 455f 5241 4e44 4f4d _INSECURE_RANDOM │ │ │ +00051d60: 5f4e 554d 4245 5253 220a 2365 6e64 6966 _NUMBERS".#endif │ │ │ +00051d70: 0a23 656e 6469 660a 0a23 656e 6469 660a .#endif..#endif. │ │ │ +00051d80: 0909 7d0a 7d0a 3c2f 7072 653e 3c2f 7464 ..}.}.
    relevance │ │ │ +00051dc0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +00051dd0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/http_see │ │ │ +00051e00: 645f 636f 6e6e 6563 7469 6f6e 2e63 7070 d_connection.cpp │ │ │ +00051e10: 3a34 3337 3c2f 613e 3c2f 7464 3e3c 7464 :437technically, th │ │ │ +00051e30: 6973 2069 736e 2774 2073 7570 706f 7365 is isn't suppose │ │ │ +00051e40: 6420 746f 2068 6170 7065 6e2c 2062 7574 d to happen, but │ │ │ +00051e50: 2069 7420 7365 656d 7320 746f 2073 6f6d it seems to som │ │ │ +00051e60: 6574 696d 6573 2e20 536f 6d65 206f 6620 etimes. Some of │ │ │ +00051e70: 7468 6520 6163 636f 756e 7469 6e67 2069 the accounting i │ │ │ +00051e80: 7320 7072 6f62 6162 6c79 2077 726f 6e67 s probably wrong │ │ │ +00051e90: 2069 6e20 6365 7274 6169 6e20 6361 7365 in certain case │ │ │ +00051ea0: 733c 2f74 643e 3c2f 7472 3e3c 7472 2069 s

    t │ │ │ +00051ef0: 6563 686e 6963 616c 6c79 2c20 7468 6973 echnically, this │ │ │ +00051f00: 2069 736e 2774 2073 7570 706f 7365 6420 isn't supposed │ │ │ +00051f10: 746f 2068 6170 7065 6e2c 2062 7574 2069 to happen, but i │ │ │ +00051f20: 7420 7365 656d 7320 746f 0a73 6f6d 6574 t seems to.somet │ │ │ +00051f30: 696d 6573 2e20 536f 6d65 206f 6620 7468 imes. Some of th │ │ │ +00051f40: 6520 6163 636f 756e 7469 6e67 2069 7320 e accounting is │ │ │ +00051f50: 7072 6f62 6162 6c79 2077 726f 6e67 2069 probably wrong i │ │ │ +00051f60: 6e20 6365 7274 6169 6e0a 6361 7365 733c n certain.cases< │ │ │ +00051f70: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f68 /h2>

    ../src/h │ │ │ +00051f80: 7474 705f 7365 6564 5f63 6f6e 6e65 6374 ttp_seed_connect │ │ │ +00051f90: 696f 6e2e 6370 703a 3433 373c 2f68 343e ion.cpp:437

    │ │ │ +00051fa0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ...../
    │ │ │ +00051fe0: 2f20 6375 7420 6f75 7420 7468 6520 6368  / cut out the ch
    │ │ │ +00051ff0: 756e 6b20 6865 6164 6572 2066 726f 6d20  unk header from 
    │ │ │ +00052000: 7468 6520 7265 6365 6976 6520 6275 6666  the receive buff
    │ │ │ +00052010: 6572 0a09 0909 0909 544f 5252 454e 545f  er......TORRENT_
    │ │ │ +00052020: 4153 5345 5254 286d 5f63 6875 6e6b 5f70  ASSERT(m_chunk_p
    │ │ │ +00052030: 6f73 202b 206d 5f62 6f64 795f 7374 6172  os + m_body_star
    │ │ │ +00052040: 7420 266c 743b 2049 4e54 5f4d 4158 293b  t < INT_MAX);
    │ │ │ +00052050: 0a09 0909 0909 6d5f 7265 6376 5f62 7566  ......m_recv_buf
    │ │ │ +00052060: 6665 722e 6375 7428 6865 6164 6572 5f73  fer.cut(header_s
    │ │ │ +00052070: 697a 652c 2074 2d26 6774 3b62 6c6f 636b  ize, t->block
    │ │ │ +00052080: 5f73 697a 6528 2920 2b20 3130 3234 2c20  _size() + 1024, 
    │ │ │ +00052090: 6175 783a 3a6e 756d 6572 6963 5f63 6173  aux::numeric_cas
    │ │ │ +000520a0: 7426 6c74 3b69 6e74 2667 743b 286d 5f63  t<int>(m_c
    │ │ │ +000520b0: 6875 6e6b 5f70 6f73 202b 206d 5f62 6f64  hunk_pos + m_bod
    │ │ │ +000520c0: 795f 7374 6172 7429 293b 0a09 0909 0909  y_start));......
    │ │ │ +000520d0: 7265 6376 5f62 7566 6665 7220 3d20 6d5f  recv_buffer = m_
    │ │ │ +000520e0: 7265 6376 5f62 7566 6665 722e 6765 7428  recv_buffer.get(
    │ │ │ +000520f0: 293b 0a09 0909 0909 7265 6376 5f62 7566  );......recv_buf
    │ │ │ +00052100: 6665 7220 3d20 7265 6376 5f62 7566 6665  fer = recv_buffe
    │ │ │ +00052110: 722e 7375 6273 7061 6e28 6d5f 626f 6479  r.subspan(m_body
    │ │ │ +00052120: 5f73 7461 7274 293b 0a09 0909 0909 6d5f  _start);......m_
    │ │ │ +00052130: 6368 756e 6b5f 706f 7320 2b3d 2063 6875  chunk_pos += chu
    │ │ │ +00052140: 6e6b 5f73 697a 653b 0a09 0909 0909 6966  nk_size;......if
    │ │ │ +00052150: 2028 6368 756e 6b5f 7369 7a65 203d 3d20   (chunk_size == 
    │ │ │ +00052160: 3029 0a09 0909 0909 7b0a 0909 0909 0909  0)......{.......
    │ │ │ +00052170: 544f 5252 454e 545f 4153 5345 5254 286d  TORRENT_ASSERT(m
    │ │ │ +00052180: 5f72 6563 765f 6275 6666 6572 2e67 6574  _recv_buffer.get
    │ │ │ +00052190: 2829 2e73 697a 6528 2920 266c 743b 206d  ().size() < m
    │ │ │ +000521a0: 5f63 6875 6e6b 5f70 6f73 202b 206d 5f62  _chunk_pos + m_b
    │ │ │ +000521b0: 6f64 795f 7374 6172 7420 2b20 310a 0909  ody_start + 1...
    │ │ │ +000521c0: 0909 0909 097c 7c20 6d5f 7265 6376 5f62  .....|| m_recv_b
    │ │ │ +000521d0: 7566 6665 722e 6765 7428 295b 7374 6174  uffer.get()[stat
    │ │ │ +000521e0: 6963 5f63 6173 7426 6c74 3b73 7464 3a3a  ic_cast<std::
    │ │ │ +000521f0: 7074 7264 6966 665f 7426 6774 3b28 6d5f  ptrdiff_t>(m_
    │ │ │ +00052200: 6368 756e 6b5f 706f 7320 2b20 6d5f 626f  chunk_pos + m_bo
    │ │ │ +00052210: 6479 5f73 7461 7274 295d 203d 3d20 2748  dy_start)] == 'H
    │ │ │ +00052220: 270a 0909 0909 0909 097c 7c20 286d 5f70  '........|| (m_p
    │ │ │ +00052230: 6172 7365 722e 6368 756e 6b65 645f 656e  arser.chunked_en
    │ │ │ +00052240: 636f 6469 6e67 2829 0a09 0909 0909 0909  coding()........
    │ │ │ +00052250: 0926 616d 703b 2661 6d70 3b20 6d5f 7265  .&& m_re
    │ │ │ +00052260: 6376 5f62 7566 6665 722e 6765 7428 295b  cv_buffer.get()[
    │ │ │ +00052270: 7374 6174 6963 5f63 6173 7426 6c74 3b73  static_cast<s
    │ │ │ +00052280: 7464 3a3a 7074 7264 6966 665f 7426 6774  td::ptrdiff_t>
    │ │ │ +00052290: 3b28 6d5f 6368 756e 6b5f 706f 7320 2b20  ;(m_chunk_pos + 
    │ │ │ +000522a0: 6d5f 626f 6479 5f73 7461 7274 295d 203d  m_body_start)] =
    │ │ │ +000522b0: 3d20 275c 7227 2929 3b0a 0909 0909 0909  = '\r'));.......
    │ │ │ +000522c0: 6d5f 6368 756e 6b5f 706f 7320 3d20 2d31  m_chunk_pos = -1
    │ │ │ +000522d0: 3b0a 0909 0909 097d 0a09 0909 097d 0a09  ;......}.....}..
    │ │ │ +000522e0: 0909 7d0a 0a09 0909 696e 7420 7061 796c  ..}.....int payl
    │ │ │ +000522f0: 6f61 6420 3d20 696e 7428 6279 7465 735f  oad = int(bytes_
    │ │ │ +00052300: 7472 616e 7366 6572 7265 6429 3b0a 0909  transferred);...
    │ │ │ +00052310: 0969 6620 2870 6179 6c6f 6164 2026 6774  .if (payload >
    │ │ │ +00052320: 3b20 6d5f 7265 7370 6f6e 7365 5f6c 6566  ; m_response_lef
    │ │ │ +00052330: 7429 2070 6179 6c6f 6164 203d 2069 6e74  t) payload = int
    │ │ │ +00052340: 286d 5f72 6573 706f 6e73 655f 6c65 6674  (m_response_left
    │ │ │ +00052350: 293b 0a09 0909 6966 2028 7061 796c 6f61  );....if (payloa
    │ │ │ +00052360: 6420 2667 743b 2066 726f 6e74 5f72 6571  d > front_req
    │ │ │ +00052370: 7565 7374 2e6c 656e 6774 6829 2070 6179  uest.length) pay
    │ │ │ +00052380: 6c6f 6164 203d 2066 726f 6e74 5f72 6571  load = front_req
    │ │ │ +00052390: 7565 7374 2e6c 656e 6774 683b 0a3c 6469  uest.length;....if
    │ │ │ +000523d0: 2028 7061 796c 6f61 6420 2667 743b 206f   (payload > o
    │ │ │ +000523e0: 7574 7374 616e 6469 6e67 5f62 7974 6573  utstanding_bytes
    │ │ │ +000523f0: 2829 2920 7061 796c 6f61 6420 3d20 6f75  ()) payload = ou
    │ │ │ +00052400: 7473 7461 6e64 696e 675f 6279 7465 7328  tstanding_bytes(
    │ │ │ +00052410: 293b 0a3c 2f64 6976 3e09 0909 7265 6365  );....rece
    │ │ │ +00052420: 6976 6564 5f62 7974 6573 2870 6179 6c6f  ived_bytes(paylo
    │ │ │ +00052430: 6164 2c20 3029 3b0a 0909 0969 6e63 6f6d  ad, 0);....incom
    │ │ │ +00052440: 696e 675f 7069 6563 655f 6672 6167 6d65  ing_piece_fragme
    │ │ │ +00052450: 6e74 2870 6179 6c6f 6164 293b 0a09 0909  nt(payload);....
    │ │ │ +00052460: 6d5f 7265 7370 6f6e 7365 5f6c 6566 7420  m_response_left 
    │ │ │ +00052470: 2d3d 2070 6179 6c6f 6164 3b0a 0a09 0909  -= payload;.....
    │ │ │ +00052480: 6966 2028 6d5f 7061 7273 6572 2e73 7461  if (m_parser.sta
    │ │ │ +00052490: 7475 735f 636f 6465 2829 203d 3d20 3530  tus_code() == 50
    │ │ │ +000524a0: 3329 0a09 0909 7b0a 0909 0909 6966 2028  3)....{.....if (
    │ │ │ +000524b0: 216d 5f70 6172 7365 722e 6669 6e69 7368  !m_parser.finish
    │ │ │ +000524c0: 6564 2829 2920 7265 7475 726e 3b0a 0a09  ed()) return;...
    │ │ │ +000524d0: 0909 0969 6e74 2072 6574 7279 5f74 696d  ...int retry_tim
    │ │ │ +000524e0: 6520 3d20 7374 643a 3a61 746f 6928 7374  e = std::atoi(st
    │ │ │ +000524f0: 643a 3a73 7472 696e 6728 7265 6376 5f62  d::string(recv_b
    │ │ │ +00052500: 7566 6665 722e 6265 6769 6e28 292c 2072  uffer.begin(), r
    │ │ │ +00052510: 6563 765f 6275 6666 6572 2e65 6e64 2829  ecv_buffer.end()
    │ │ │ +00052520: 292e 635f 7374 7228 2929 3b0a 0909 0909  ).c_str());.....
    │ │ │ +00052530: 6966 2028 7265 7472 795f 7469 6d65 2026  if (retry_time &
    │ │ │ +00052540: 6c74 3b3d 2030 2920 7265 7472 795f 7469  lt;= 0) retry_ti
    │ │ │ +00052550: 6d65 203d 2036 303b 0a23 6966 6e64 6566  me = 60;.#ifndef
    │ │ │ +00052560: 2054 4f52 5245 4e54 5f44 4953 4142 4c45   TORRENT_DISABLE
    │ │ │ +00052570: 5f4c 4f47 4749 4e47 0a09 0909 0970 6565  _LOGGING.....pee
    │ │ │ +00052580: 725f 6c6f 6728 7065 6572 5f6c 6f67 5f61  r_log(peer_log_a
    │ │ │ +00052590: 6c65 7274 3a3a 696e 666f 2c20 2243 4f4e  lert::info, "CON
    │ │ │ +000525a0: 4e45 4354 222c 2022 7265 7472 7969 6e67  NECT", "retrying
    │ │ │ +000525b0: 2069 6e20 2564 2073 6563 6f6e 6473 222c   in %d seconds",
    │ │ │ +000525c0: 2072 6574 7279 5f74 696d 6529 3b0a 2365   retry_time);.#e
    │ │ │ +000525d0: 6e64 6966 0a0a 0909 0909 7265 6365 6976  ndif......receiv
    │ │ │ +000525e0: 6564 5f62 7974 6573 2830 2c20 696e 7428  ed_bytes(0, int(
    │ │ │ +000525f0: 6279 7465 735f 7472 616e 7366 6572 7265  bytes_transferre
    │ │ │ +00052600: 6429 293b 0a09 0909 092f 2f20 7465 6d70  d));.....// temp
    │ │ │ +00052610: 6f72 6172 696c 7920 756e 6176 6169 6c61  orarily unavaila
    │ │ │ +00052620: 626c 652c 2072 6574 7279 206c 6174 6572  ble, retry later
    │ │ │ +00052630: 0a09 0909 0974 2d26 6774 3b72 6574 7279  .....t->retry
    │ │ │ +00052640: 5f77 6562 5f73 6565 6428 7468 6973 2c20  _web_seed(this, 
    │ │ │ +00052650: 7365 636f 6e64 7333 3228 7265 7472 795f  seconds32(retry_
    │ │ │ +00052660: 7469 6d65 2929 3b0a 0909 0909 6469 7363  time));.....disc
    │ │ │ +00052670: 6f6e 6e65 6374 2865 7272 6f72 5f63 6f64  onnect(error_cod
    │ │ │ +00052680: 6528 6d5f 7061 7273 6572 2e73 7461 7475  e(m_parser.statu
    │ │ │ +00052690: 735f 636f 6465 2829 2c20 6874 7470 5f63  s_code(), http_c
    │ │ │ +000526a0: 6174 6567 6f72 7928 2929 2c20 6f70 6572  ategory()), oper
    │ │ │ +000526b0: 6174 696f 6e5f 743a 3a62 6974 746f 7272  ation_t::bittorr
    │ │ │ +000526c0: 656e 742c 2066 6169 6c75 7265 293b 0a09  ent, failure);..
    │ │ │ +000526d0: 0909 0972 6574 7572 6e3b 0a09 0909 7d0a  ...return;....}.
    │ │ │ +000526e0: 0a0a 0909 092f 2f20 7765 206f 6e6c 7920  .....// we only 
    │ │ │ +000526f0: 7265 6365 6976 6564 2074 6865 2068 6561  received the hea
    │ │ │ +00052700: 6465 722c 206e 6f20 6461 7461 0a09 0909  der, no data....
    │ │ │ +00052710: 6966 2028 7265 6376 5f62 7566 6665 722e  if (recv_buffer.
    │ │ │ +00052720: 656d 7074 7928 2929 2062 7265 616b 3b0a  empty()) break;.
    │ │ │ +00052730: 0a09 0909 6966 2028 7265 6376 5f62 7566  ....if (recv_buf
    │ │ │ +00052740: 6665 722e 7369 7a65 2829 2026 6c74 3b20  fer.size() < 
    │ │ │ +00052750: 6672 6f6e 745f 7265 7175 6573 742e 6c65  front_request.le
    │ │ │ +00052760: 6e67 7468 2920 6272 6561 6b3b 0a0a 0909  ngth) break;....
    │ │ │ +00052770: 092f 2f20 6966 2074 6865 2072 6573 706f  .// if the respo
    │ │ │ +00052780: 6e73 6520 6973 2063 6875 6e6b 6564 2c20  nse is chunked, 
    │ │ │ +00052790: 7765 206e 6565 6420 746f 2072 6563 6569  we need to recei
    │ │ │ +000527a0: 7665 2074 6865 206c 6173 740a 0909 092f  ve the last..../
    │ │ │ +000527b0: 2f20 7465 726d 696e 6174 696e 6720 6368  / terminating ch
    │ │ │ +000527c0: 756e 6b20 616e 6420 7468 6520 7461 696c  unk and the tail
    │ │ │ +000527d0: 2068 6561 6465 7273 2062 6566 6f72 6520   headers before 
    │ │ │ +000527e0: 7765 2063 616e 2070 726f 6365 6564 0a09  we can proceed..
    │ │ │ +000527f0: 0909 6966 2028 6d5f 7061 7273 6572 2e63  ..if (m_parser.c
    │ │ │ +00052800: 6875 6e6b 6564 5f65 6e63 6f64 696e 6728  hunked_encoding(
    │ │ │ +00052810: 2920 2661 6d70 3b26 616d 703b 206d 5f63  ) && m_c
    │ │ │ +00052820: 6875 6e6b 5f70 6f73 2026 6774 3b3d 2030  hunk_pos >= 0
    │ │ │ +00052830: 2920 6272 6561 6b3b 0a3c 2f70 7265 3e3c  ) break;.
    < │ │ │ +00052840: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00052870: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +00052880: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/torre │ │ │ +000528b0: 6e74 5f68 616e 646c 652e 6370 703a 3630 nt_handle.cpp:60 │ │ │ +000528c0: 343c 2f61 3e3c 2f74 643e 3c74 643e 7375 4su │ │ │ +000528d0: 7070 6f72 7420 6d6f 7669 6e67 2066 696c pport moving fil │ │ │ +000528e0: 6573 2069 6e74 6f20 7468 6973 2063 616c es into this cal │ │ │ +000528f0: 6c3c 2f74 643e 3c2f 7472 3e3c 7472 2069 l

    s │ │ │ +00052940: 7570 706f 7274 206d 6f76 696e 6720 6669 upport moving fi │ │ │ +00052950: 6c65 7320 696e 746f 2074 6869 7320 6361 les into this ca │ │ │ +00052960: 6c6c 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 ll

    ../sr │ │ │ +00052970: 632f 746f 7272 656e 745f 6861 6e64 6c65 c/torrent_handle │ │ │ +00052980: 2e63 7070 3a36 3034 3c2f 6834 3e3c 7072 .cpp:604

    ..auto re │ │ │ +000529d0: 7470 203d 2026 616d 703b 7072 696f 3b0a tp = &prio;. │ │ │ +000529e0: 0909 7379 6e63 5f63 616c 6c28 2661 6d70 ..sync_call(& │ │ │ +000529f0: 3b74 6f72 7265 6e74 3a3a 7069 6563 655f ;torrent::piece_ │ │ │ +00052a00: 7072 696f 7269 7469 6573 2c20 7265 7470 priorities, retp │ │ │ +00052a10: 293b 0a09 0973 7464 3a3a 7665 6374 6f72 );...std::vector │ │ │ +00052a20: 266c 743b 696e 7426 6774 3b20 7265 743b <int> ret; │ │ │ +00052a30: 0a09 0972 6574 2e72 6573 6572 7665 2870 ...ret.reserve(p │ │ │ +00052a40: 7269 6f2e 7369 7a65 2829 293b 0a09 0966 rio.size());...f │ │ │ +00052a50: 6f72 2028 6175 746f 2070 203a 2070 7269 or (auto p : pri │ │ │ +00052a60: 6f29 0a09 0909 7265 742e 7075 7368 5f62 o)....ret.push_b │ │ │ +00052a70: 6163 6b28 696e 7428 7374 6174 6963 5f63 ack(int(static_c │ │ │ +00052a80: 6173 7426 6c74 3b73 7464 3a3a 7569 6e74 ast<std::uint │ │ │ +00052a90: 385f 7426 6774 3b28 7029 2929 3b0a 0909 8_t>(p)));... │ │ │ +00052aa0: 7265 7475 726e 2072 6574 3b0a 097d 0a23 return ret;..}.# │ │ │ +00052ab0: 656e 6469 660a 0a09 766f 6964 2074 6f72 endif...void tor │ │ │ +00052ac0: 7265 6e74 5f68 616e 646c 653a 3a66 696c rent_handle::fil │ │ │ +00052ad0: 655f 7072 696f 7269 7479 2866 696c 655f e_priority(file_ │ │ │ +00052ae0: 696e 6465 785f 7420 696e 6465 782c 2064 index_t index, d │ │ │ +00052af0: 6f77 6e6c 6f61 645f 7072 696f 7269 7479 ownload_priority │ │ │ +00052b00: 5f74 2070 7269 6f72 6974 7929 2063 6f6e _t priority) con │ │ │ +00052b10: 7374 0a09 7b0a 0909 6173 796e 635f 6361 st..{...async_ca │ │ │ +00052b20: 6c6c 2826 616d 703b 746f 7272 656e 743a ll(&torrent: │ │ │ +00052b30: 3a73 6574 5f66 696c 655f 7072 696f 7269 :set_file_priori │ │ │ +00052b40: 7479 2c20 696e 6465 782c 2070 7269 6f72 ty, index, prior │ │ │ +00052b50: 6974 7929 3b0a 097d 0a0a 0964 6f77 6e6c ity);..}...downl │ │ │ +00052b60: 6f61 645f 7072 696f 7269 7479 5f74 2074 oad_priority_t t │ │ │ +00052b70: 6f72 7265 6e74 5f68 616e 646c 653a 3a66 orrent_handle::f │ │ │ +00052b80: 696c 655f 7072 696f 7269 7479 2866 696c ile_priority(fil │ │ │ +00052b90: 655f 696e 6465 785f 7420 696e 6465 7829 e_index_t index) │ │ │ +00052ba0: 2063 6f6e 7374 0a09 7b0a 0909 7265 7475 const..{...retu │ │ │ +00052bb0: 726e 2073 796e 635f 6361 6c6c 5f72 6574 rn sync_call_ret │ │ │ +00052bc0: 266c 743b 646f 776e 6c6f 6164 5f70 7269 <download_pri │ │ │ +00052bd0: 6f72 6974 795f 7426 6774 3b28 646f 6e74 ority_t>(dont │ │ │ +00052be0: 5f64 6f77 6e6c 6f61 642c 2026 616d 703b _download, & │ │ │ +00052bf0: 746f 7272 656e 743a 3a66 696c 655f 7072 torrent::file_pr │ │ │ +00052c00: 696f 7269 7479 2c20 696e 6465 7829 3b0a iority, index);. │ │ │ +00052c10: 097d 0a0a 3c64 6976 2073 7479 6c65 3d22 .}..
    .void torrent_ │ │ │ +00052c50: 6861 6e64 6c65 3a3a 7072 696f 7269 7469 handle::prioriti │ │ │ +00052c60: 7a65 5f66 696c 6573 2873 7464 3a3a 7665 ze_files(std::ve │ │ │ +00052c70: 6374 6f72 266c 743b 646f 776e 6c6f 6164 ctor<download │ │ │ +00052c80: 5f70 7269 6f72 6974 795f 7426 6774 3b20 _priority_t> │ │ │ +00052c90: 636f 6e73 7426 616d 703b 2066 696c 6573 const& files │ │ │ +00052ca0: 2920 636f 6e73 740a 3c2f 6469 763e 097b ) const.
    .{ │ │ │ +00052cb0: 0a09 0961 7379 6e63 5f63 616c 6c28 2661 ...async_call(&a │ │ │ +00052cc0: 6d70 3b74 6f72 7265 6e74 3a3a 7072 696f mp;torrent::prio │ │ │ +00052cd0: 7269 7469 7a65 5f66 696c 6573 0a09 0909 ritize_files.... │ │ │ +00052ce0: 2c20 7374 6174 6963 5f63 6173 7426 6c74 , static_cast< │ │ │ +00052cf0: 3b61 7578 3a3a 7665 6374 6f72 266c 743b ;aux::vector< │ │ │ +00052d00: 646f 776e 6c6f 6164 5f70 7269 6f72 6974 download_priorit │ │ │ +00052d10: 795f 742c 2066 696c 655f 696e 6465 785f y_t, file_index_ │ │ │ +00052d20: 7426 6774 3b20 636f 6e73 7426 616d 703b t> const& │ │ │ +00052d30: 2667 743b 2866 696c 6573 2929 3b0a 097d >(files));..} │ │ │ +00052d40: 0a0a 0973 7464 3a3a 7665 6374 6f72 266c ...std::vector&l │ │ │ +00052d50: 743b 646f 776e 6c6f 6164 5f70 7269 6f72 t;download_prior │ │ │ +00052d60: 6974 795f 7426 6774 3b20 746f 7272 656e ity_t> torren │ │ │ +00052d70: 745f 6861 6e64 6c65 3a3a 6765 745f 6669 t_handle::get_fi │ │ │ +00052d80: 6c65 5f70 7269 6f72 6974 6965 7328 2920 le_priorities() │ │ │ +00052d90: 636f 6e73 740a 097b 0a09 0961 7578 3a3a const..{...aux:: │ │ │ +00052da0: 7665 6374 6f72 266c 743b 646f 776e 6c6f vector<downlo │ │ │ +00052db0: 6164 5f70 7269 6f72 6974 795f 742c 2066 ad_priority_t, f │ │ │ +00052dc0: 696c 655f 696e 6465 785f 7426 6774 3b20 ile_index_t> │ │ │ +00052dd0: 7265 743b 0a09 0961 7574 6f20 7265 7470 ret;...auto retp │ │ │ +00052de0: 203d 2026 616d 703b 7265 743b 0a09 0973 = &ret;...s │ │ │ +00052df0: 796e 635f 6361 6c6c 2826 616d 703b 746f ync_call(&to │ │ │ +00052e00: 7272 656e 743a 3a66 696c 655f 7072 696f rrent::file_prio │ │ │ +00052e10: 7269 7469 6573 2c20 7265 7470 293b 0a09 rities, retp);.. │ │ │ +00052e20: 0972 6574 7572 6e20 544f 5252 454e 545f .return TORRENT_ │ │ │ +00052e30: 5256 4f28 7265 7429 3b0a 097d 0a0a 2369 RVO(ret);..}..#i │ │ │ +00052e40: 6620 544f 5252 454e 545f 4142 495f 5645 f TORRENT_ABI_VE │ │ │ +00052e50: 5253 494f 4e20 3d3d 2031 0a0a 2f2f 203d RSION == 1..// = │ │ │ +00052e60: 3d3d 3d3d 3d3d 3d3d 3d3d 3d20 7374 6172 =========== star │ │ │ +00052e70: 7420 6465 7072 6563 6174 696f 6e20 3d3d t deprecation == │ │ │ +00052e80: 3d3d 3d3d 3d3d 3d3d 3d3d 3d3d 3d0a 0a09 =============... │ │ │ +00052e90: 766f 6964 2074 6f72 7265 6e74 5f68 616e void torrent_han │ │ │ +00052ea0: 646c 653a 3a70 7269 6f72 6974 697a 655f dle::prioritize_ │ │ │ +00052eb0: 6669 6c65 7328 7374 643a 3a76 6563 746f files(std::vecto │ │ │ +00052ec0: 7226 6c74 3b69 6e74 2667 743b 2063 6f6e r<int> con │ │ │ +00052ed0: 7374 2661 6d70 3b20 6669 6c65 7329 2063 st& files) c │ │ │ +00052ee0: 6f6e 7374 0a09 7b0a 0909 6175 783a 3a76 onst..{...aux::v │ │ │ +00052ef0: 6563 746f 7226 6c74 3b64 6f77 6e6c 6f61 ector<downloa │ │ │ +00052f00: 645f 7072 696f 7269 7479 5f74 2c20 6669 d_priority_t, fi │ │ │ +00052f10: 6c65 5f69 6e64 6578 5f74 2667 743b 2066 le_index_t> f │ │ │ +00052f20: 696c 655f 7072 696f 3b0a 0909 6669 6c65 ile_prio;...file │ │ │ +00052f30: 5f70 7269 6f2e 7265 7365 7276 6528 6669 _prio.reserve(fi │ │ │ +00052f40: 6c65 732e 7369 7a65 2829 293b 0a09 0966 les.size());...f │ │ │ +00052f50: 6f72 2028 6175 746f 2063 6f6e 7374 2070 or (auto const p │ │ │ +00052f60: 203a 2066 696c 6573 2920 7b0a 0909 0966 : files) {....f │ │ │ +00052f70: 696c 655f 7072 696f 2e70 7573 685f 6261 ile_prio.push_ba │ │ │ +00052f80: 636b 2864 6f77 6e6c 6f61 645f 7072 696f ck(download_prio │ │ │ +00052f90: 7269 7479 5f74 2873 7461 7469 635f 6361 rity_t(static_ca │ │ │ +00052fa0: 7374 266c 743b 7374 643a 3a75 696e 7438 st<std::uint8 │ │ │ +00052fb0: 5f74 2667 743b 2870 2929 293b 0a09 097d _t>(p)));...} │ │ │ +00052fc0: 0a09 0961 7379 6e63 5f63 616c 6c28 2661 ...async_call(&a │ │ │ +00052fd0: 6d70 3b74 6f72 7265 6e74 3a3a 7072 696f mp;torrent::prio │ │ │ +00052fe0: 7269 7469 7a65 5f66 696c 6573 2c20 6669 ritize_files, fi │ │ │ +00052ff0: 6c65 5f70 7269 6f29 3b0a 097d 0a0a 0973 le_prio);..}...s │ │ │ +00053000: 7464 3a3a 7665 6374 6f72 266c 743b 696e td::vector<in │ │ │ +00053010: 7426 6774 3b20 746f 7272 656e 745f 6861 t> torrent_ha │ │ │ +00053020: 6e64 6c65 3a3a 6669 6c65 5f70 7269 6f72 ndle::file_prior │ │ │ +00053030: 6974 6965 7328 2920 636f 6e73 740a 097b ities() const..{ │ │ │ +00053040: 0a09 0961 7578 3a3a 7665 6374 6f72 266c ...aux::vector&l │ │ │ +00053050: 743b 646f 776e 6c6f 6164 5f70 7269 6f72 t;download_prior │ │ │ +00053060: 6974 795f 742c 2066 696c 655f 696e 6465 ity_t, file_inde │ │ │ +00053070: 785f 7426 6774 3b20 7072 696f 3b0a 3c2f x_t> prio;.r │ │ │ +000530b0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +000530c0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +000530f0: 7061 7274 5f66 696c 652e 6370 703a 3330 part_file.cpp:30 │ │ │ +00053100: 323c 2f61 3e3c 2f74 643e 3c74 643e 7768 2wh │ │ │ +00053110: 6174 2064 6f20 7765 2064 6f20 6966 2073 at do we do if s │ │ │ +00053120: 6f6d 656f 6e65 2069 7320 6375 7272 656e omeone is curren │ │ │ +00053130: 746c 7920 7265 6164 696e 6720 6672 6f6d tly reading from │ │ │ +00053140: 2074 6865 2064 6973 6b20 6672 6f6d 2074 the disk from t │ │ │ +00053150: 6869 7320 7069 6563 653f 2064 6f65 7320 his piece? does │ │ │ +00053160: 6974 206d 6174 7465 723f 2053 696e 6365 it matter? Since │ │ │ +00053170: 2077 6520 776f 6e27 7420 6163 7469 7665 we won't active │ │ │ +00053180: 6c79 2065 7261 7365 2074 6865 2064 6174 ly erase the dat │ │ │ +00053190: 6120 6672 6f6d 2064 6973 6b2c 2062 7574 a from disk, but │ │ │ +000531a0: 2069 7420 6d61 7920 6265 206f 7665 7277 it may be overw │ │ │ +000531b0: 7269 7474 656e 2073 6f6f 6e2c 2069 7427 ritten soon, it' │ │ │ +000531c0: 7320 7072 6f62 6162 6c79 206e 6f74 2074 s probably not t │ │ │ +000531d0: 6861 7420 6269 6720 6f66 2061 2064 6561 hat big of a dea │ │ │ +000531e0: 6c3c 2f74 643e 3c2f 7472 3e3c 7472 2069 l

    w │ │ │ +00053230: 6861 7420 646f 2077 6520 646f 2069 6620 hat do we do if │ │ │ +00053240: 736f 6d65 6f6e 6520 6973 2063 7572 7265 someone is curre │ │ │ +00053250: 6e74 6c79 2072 6561 6469 6e67 2066 726f ntly reading fro │ │ │ +00053260: 6d20 7468 6520 6469 736b 0a66 726f 6d20 m the disk.from │ │ │ +00053270: 7468 6973 2070 6965 6365 3f20 646f 6573 this piece? does │ │ │ +00053280: 2069 7420 6d61 7474 6572 3f20 5369 6e63 it matter? Sinc │ │ │ +00053290: 6520 7765 2077 6f6e 2774 2061 6374 6976 e we won't activ │ │ │ +000532a0: 656c 7920 6572 6173 6520 7468 650a 6461 ely erase the.da │ │ │ +000532b0: 7461 2066 726f 6d20 6469 736b 2c20 6275 ta from disk, bu │ │ │ +000532c0: 7420 6974 206d 6179 2062 6520 6f76 6572 t it may be over │ │ │ +000532d0: 7772 6974 7465 6e20 736f 6f6e 2c20 6974 written soon, it │ │ │ +000532e0: 2773 2070 726f 6261 626c 7920 6e6f 7420 's probably not │ │ │ +000532f0: 7468 6174 0a62 6967 206f 6620 6120 6465 that.big of a de │ │ │ +00053300: 616c 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 al

    ../sr │ │ │ +00053310: 632f 7061 7274 5f66 696c 652e 6370 703a c/part_file.cpp: │ │ │ +00053320: 3330 323c 2f68 343e 3c70 7265 2073 7479 302

    ....create_dir
    │ │ │ +00053370: 6563 746f 7269 6573 286d 5f70 6174 682c  ectories(m_path,
    │ │ │ +00053380: 2065 6329 3b0a 0909 0909 6966 2028 6563   ec);.....if (ec
    │ │ │ +00053390: 2920 7265 7475 726e 207b 7d3b 0a09 0909  ) return {};....
    │ │ │ +000533a0: 0972 6574 7572 6e20 6175 783a 3a66 696c  .return aux::fil
    │ │ │ +000533b0: 655f 6861 6e64 6c65 2866 6e2c 2030 2c20  e_handle(fn, 0, 
    │ │ │ +000533c0: 6d6f 6465 293b 0a09 0909 7d0a 0909 0972  mode);....}....r
    │ │ │ +000533d0: 6574 7572 6e20 7b7d 3b0a 0909 7d0a 097d  eturn {};...}..}
    │ │ │ +000533e0: 0a09 6361 7463 6820 2873 746f 7261 6765  ..catch (storage
    │ │ │ +000533f0: 5f65 7272 6f72 2063 6f6e 7374 2661 6d70  _error const&
    │ │ │ +00053400: 3b20 6529 0a09 7b0a 0909 6563 203d 2065  ; e)..{...ec = e
    │ │ │ +00053410: 2e65 633b 0a09 0972 6574 7572 6e20 7b7d  .ec;...return {}
    │ │ │ +00053420: 3b0a 097d 0a0a 0976 6f69 6420 7061 7274  ;..}...void part
    │ │ │ +00053430: 5f66 696c 653a 3a66 7265 655f 7069 6563  _file::free_piec
    │ │ │ +00053440: 6528 7069 6563 655f 696e 6465 785f 7420  e(piece_index_t 
    │ │ │ +00053450: 636f 6e73 7420 7069 6563 6529 0a09 7b0a  const piece)..{.
    │ │ │ +00053460: 0909 7374 643a 3a6c 6f63 6b5f 6775 6172  ..std::lock_guar
    │ │ │ +00053470: 6426 6c74 3b73 7464 3a3a 6d75 7465 7826  d<std::mutex&
    │ │ │ +00053480: 6774 3b20 6c28 6d5f 6d75 7465 7829 3b0a  gt; l(m_mutex);.
    │ │ │ +00053490: 0a09 0961 7574 6f20 636f 6e73 7420 6920  ...auto const i 
    │ │ │ +000534a0: 3d20 6d5f 7069 6563 655f 6d61 702e 6669  = m_piece_map.fi
    │ │ │ +000534b0: 6e64 2870 6965 6365 293b 0a09 0969 6620  nd(piece);...if 
    │ │ │ +000534c0: 2869 203d 3d20 6d5f 7069 6563 655f 6d61  (i == m_piece_ma
    │ │ │ +000534d0: 702e 656e 6428 2929 2072 6574 7572 6e3b  p.end()) return;
    │ │ │ +000534e0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +00053510: 0a3c 2f64 6976 3e09 096d 5f66 7265 655f .
    ..m_free_ │ │ │ +00053520: 736c 6f74 732e 7075 7368 5f62 6163 6b28 slots.push_back( │ │ │ +00053530: 692d 2667 743b 7365 636f 6e64 293b 0a09 i->second);.. │ │ │ +00053540: 096d 5f70 6965 6365 5f6d 6170 2e65 7261 .m_piece_map.era │ │ │ +00053550: 7365 2869 293b 0a09 096d 5f64 6972 7479 se(i);...m_dirty │ │ │ +00053560: 5f6d 6574 6164 6174 6120 3d20 7472 7565 _metadata = true │ │ │ +00053570: 3b0a 097d 0a0a 0976 6f69 6420 7061 7274 ;..}...void part │ │ │ +00053580: 5f66 696c 653a 3a6d 6f76 655f 7061 7274 _file::move_part │ │ │ +00053590: 6669 6c65 2873 7464 3a3a 7374 7269 6e67 file(std::string │ │ │ +000535a0: 2063 6f6e 7374 2661 6d70 3b20 7061 7468 const& path │ │ │ +000535b0: 2c20 6572 726f 725f 636f 6465 2661 6d70 , error_code& │ │ │ +000535c0: 3b20 6563 290a 097b 0a09 0973 7464 3a3a ; ec)..{...std:: │ │ │ +000535d0: 6c6f 636b 5f67 7561 7264 266c 743b 7374 lock_guard<st │ │ │ +000535e0: 643a 3a6d 7574 6578 2667 743b 206c 286d d::mutex> l(m │ │ │ +000535f0: 5f6d 7574 6578 293b 0a0a 0909 666c 7573 _mutex);....flus │ │ │ +00053600: 685f 6d65 7461 6461 7461 5f69 6d70 6c28 h_metadata_impl( │ │ │ +00053610: 6563 293b 0a09 0969 6620 2865 6329 2072 ec);...if (ec) r │ │ │ +00053620: 6574 7572 6e3b 0a0a 0909 6966 2028 216d eturn;....if (!m │ │ │ +00053630: 5f70 6965 6365 5f6d 6170 2e65 6d70 7479 _piece_map.empty │ │ │ +00053640: 2829 290a 0909 7b0a 0909 0973 7464 3a3a ())...{....std:: │ │ │ +00053650: 7374 7269 6e67 206f 6c64 5f70 6174 6820 string old_path │ │ │ +00053660: 3d20 636f 6d62 696e 655f 7061 7468 286d = combine_path(m │ │ │ +00053670: 5f70 6174 682c 206d 5f6e 616d 6529 3b0a _path, m_name);. │ │ │ +00053680: 0909 0973 7464 3a3a 7374 7269 6e67 206e ...std::string n │ │ │ +00053690: 6577 5f70 6174 6820 3d20 636f 6d62 696e ew_path = combin │ │ │ +000536a0: 655f 7061 7468 2870 6174 682c 206d 5f6e e_path(path, m_n │ │ │ +000536b0: 616d 6529 3b0a 0a09 0909 7265 6e61 6d65 ame);.....rename │ │ │ +000536c0: 286f 6c64 5f70 6174 682c 206e 6577 5f70 (old_path, new_p │ │ │ +000536d0: 6174 682c 2065 6329 3b0a 0909 0969 6620 ath, ec);....if │ │ │ +000536e0: 2865 6320 3d3d 2062 6f6f 7374 3a3a 7379 (ec == boost::sy │ │ │ +000536f0: 7374 656d 3a3a 6572 7263 3a3a 6e6f 5f73 stem::errc::no_s │ │ │ +00053700: 7563 685f 6669 6c65 5f6f 725f 6469 7265 uch_file_or_dire │ │ │ +00053710: 6374 6f72 7929 0a09 0909 0965 632e 636c ctory).....ec.cl │ │ │ +00053720: 6561 7228 293b 0a0a 0909 0969 6620 2865 ear();.....if (e │ │ │ +00053730: 6329 0a09 0909 7b0a 0909 0909 7374 6f72 c)....{.....stor │ │ │ +00053740: 6167 655f 6572 726f 7220 7365 3b0a 0909 age_error se;... │ │ │ +00053750: 0909 6175 783a 3a63 6f70 795f 6669 6c65 ..aux::copy_file │ │ │ +00053760: 286f 6c64 5f70 6174 682c 206e 6577 5f70 (old_path, new_p │ │ │ +00053770: 6174 682c 2073 6529 3b0a 0909 0909 6563 ath, se);.....ec │ │ │ +00053780: 203d 2073 652e 6563 3b0a 0909 0909 6966 = se.ec;.....if │ │ │ +00053790: 2028 6563 2920 7265 7475 726e 3b0a 0909 (ec) return;... │ │ │ +000537a0: 0909 7265 6d6f 7665 286f 6c64 5f70 6174 ..remove(old_pat │ │ │ +000537b0: 682c 2065 6329 3b0a 0909 097d 0a09 097d h, ec);....}...} │ │ │ +000537c0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +00053800: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +00053830: 7263 2f70 6172 745f 6669 6c65 2e63 7070 rc/part_file.cpp │ │ │ +00053840: 3a34 3132 3c2f 613e 3c2f 7464 3e3c 7464 :412instead of rebu │ │ │ +00053860: 696c 6469 6e67 2074 6865 2077 686f 6c65 ilding the whole │ │ │ +00053870: 2066 696c 6520 6865 6164 6572 2061 6e64 file header and │ │ │ +00053880: 2066 6c75 7368 696e 6720 6974 2c20 7570 flushing it, up │ │ │ +00053890: 6461 7465 2074 6865 2073 6c6f 7420 656e date the slot en │ │ │ +000538a0: 7472 6965 7320 6173 2077 6520 676f 3c2f tries as we go

    inst │ │ │ +00053900: 6561 6420 6f66 2072 6562 7569 6c64 696e ead of rebuildin │ │ │ +00053910: 6720 7468 6520 7768 6f6c 6520 6669 6c65 g the whole file │ │ │ +00053920: 2068 6561 6465 720a 616e 6420 666c 7573 header.and flus │ │ │ +00053930: 6869 6e67 2069 742c 2075 7064 6174 6520 hing it, update │ │ │ +00053940: 7468 6520 736c 6f74 2065 6e74 7269 6573 the slot entries │ │ │ +00053950: 2061 7320 7765 2067 6f3c 2f68 323e 3c68 as we go

    ../src/part_fi │ │ │ +00053970: 6c65 2e63 7070 3a34 3132 3c2f 6834 3e3c le.cpp:412< │ │ │ +00053980: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00053990: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +000539a0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +000539b0: 7820 2364 6464 3b22 3e09 0909 0909 0954 x #ddd;">......T │ │ │ +000539c0: 4f52 5245 4e54 5f41 5353 4552 5428 6a2d ORRENT_ASSERT(j- │ │ │ +000539d0: 2667 743b 7365 636f 6e64 203d 3d20 736c >second == sl │ │ │ +000539e0: 6f74 293b 0a09 0909 0909 096d 5f66 7265 ot);.......m_fre │ │ │ +000539f0: 655f 736c 6f74 732e 7075 7368 5f62 6163 e_slots.push_bac │ │ │ +00053a00: 6b28 6a2d 2667 743b 7365 636f 6e64 293b k(j->second); │ │ │ +00053a10: 0a09 0909 0909 096d 5f70 6965 6365 5f6d .......m_piece_m │ │ │ +00053a20: 6170 2e65 7261 7365 286a 293b 0a09 0909 ap.erase(j);.... │ │ │ +00053a30: 0909 096d 5f64 6972 7479 5f6d 6574 6164 ...m_dirty_metad │ │ │ +00053a40: 6174 6120 3d20 7472 7565 3b0a 0909 0909 ata = true;..... │ │ │ +00053a50: 097d 0a09 0909 097d 0a09 0909 7d0a 0909 .}.....}....}... │ │ │ +00053a60: 0966 696c 655f 6f66 6673 6574 202b 3d20 .file_offset += │ │ │ +00053a70: 626c 6f63 6b5f 746f 5f63 6f70 793b 0a09 block_to_copy;.. │ │ │ +00053a80: 0909 7069 6563 655f 6f66 6673 6574 203d ..piece_offset = │ │ │ +00053a90: 2030 3b0a 0909 0973 697a 6520 2d3d 2062 0;....size -= b │ │ │ +00053aa0: 6c6f 636b 5f74 6f5f 636f 7079 3b0a 0909 lock_to_copy;... │ │ │ +00053ab0: 7d0a 097d 0a0a 0976 6f69 6420 7061 7274 }..}...void part │ │ │ +00053ac0: 5f66 696c 653a 3a66 6c75 7368 5f6d 6574 _file::flush_met │ │ │ +00053ad0: 6164 6174 6128 6572 726f 725f 636f 6465 adata(error_code │ │ │ +00053ae0: 2661 6d70 3b20 6563 290a 097b 0a09 0973 & ec)..{...s │ │ │ +00053af0: 7464 3a3a 6c6f 636b 5f67 7561 7264 266c td::lock_guard&l │ │ │ +00053b00: 743b 7374 643a 3a6d 7574 6578 2667 743b t;std::mutex> │ │ │ +00053b10: 206c 286d 5f6d 7574 6578 293b 0a0a 0909 l(m_mutex);.... │ │ │ +00053b20: 666c 7573 685f 6d65 7461 6461 7461 5f69 flush_metadata_i │ │ │ +00053b30: 6d70 6c28 6563 293b 0a09 7d0a 0a3c 6469 mpl(ec);..}...void │ │ │ +00053b70: 2070 6172 745f 6669 6c65 3a3a 666c 7573 part_file::flus │ │ │ +00053b80: 685f 6d65 7461 6461 7461 5f69 6d70 6c28 h_metadata_impl( │ │ │ +00053b90: 6572 726f 725f 636f 6465 2661 6d70 3b20 error_code& │ │ │ +00053ba0: 6563 290a 3c2f 6469 763e 097b 0a09 092f ec)..{.../ │ │ │ +00053bb0: 2f20 646f 2077 6520 6e65 6564 2074 6f20 / do we need to │ │ │ +00053bc0: 666c 7573 6820 7468 6520 6d65 7461 6461 flush the metada │ │ │ +00053bd0: 7461 3f0a 0909 6966 2028 6d5f 6469 7274 ta?...if (m_dirt │ │ │ +00053be0: 795f 6d65 7461 6461 7461 203d 3d20 6661 y_metadata == fa │ │ │ +00053bf0: 6c73 6529 2072 6574 7572 6e3b 0a0a 0909 lse) return;.... │ │ │ +00053c00: 6966 2028 6d5f 7069 6563 655f 6d61 702e if (m_piece_map. │ │ │ +00053c10: 656d 7074 7928 2929 0a09 097b 0a09 0909 empty())...{.... │ │ │ +00053c20: 2f2f 2069 6620 7765 2064 6f6e 2774 2068 // if we don't h │ │ │ +00053c30: 6176 6520 616e 7920 7069 6563 6573 206c ave any pieces l │ │ │ +00053c40: 6566 7420 696e 2074 6865 0a09 0909 2f2f eft in the....// │ │ │ +00053c50: 2070 6172 7420 6669 6c65 2c20 7265 6d6f part file, remo │ │ │ +00053c60: 7665 2069 740a 0909 0973 7464 3a3a 7374 ve it....std::st │ │ │ +00053c70: 7269 6e67 2063 6f6e 7374 2070 203d 2063 ring const p = c │ │ │ +00053c80: 6f6d 6269 6e65 5f70 6174 6828 6d5f 7061 ombine_path(m_pa │ │ │ +00053c90: 7468 2c20 6d5f 6e61 6d65 293b 0a09 0909 th, m_name);.... │ │ │ +00053ca0: 7265 6d6f 7665 2870 2c20 6563 293b 0a0a remove(p, ec);.. │ │ │ +00053cb0: 0909 0969 6620 2865 6320 3d3d 2062 6f6f ...if (ec == boo │ │ │ +00053cc0: 7374 3a3a 7379 7374 656d 3a3a 6572 7263 st::system::errc │ │ │ +00053cd0: 3a3a 6e6f 5f73 7563 685f 6669 6c65 5f6f ::no_such_file_o │ │ │ +00053ce0: 725f 6469 7265 6374 6f72 7929 0a09 0909 r_directory).... │ │ │ +00053cf0: 0965 632e 636c 6561 7228 293b 0a09 0909 .ec.clear();.... │ │ │ +00053d00: 7265 7475 726e 3b0a 0909 7d0a 0a09 0961 return;...}....a │ │ │ +00053d10: 7574 6f20 6620 3d20 6f70 656e 5f66 696c uto f = open_fil │ │ │ +00053d20: 6528 6175 783a 3a6f 7065 6e5f 6d6f 6465 e(aux::open_mode │ │ │ +00053d30: 3a3a 7772 6974 6520 7c20 6175 783a 3a6f ::write | aux::o │ │ │ +00053d40: 7065 6e5f 6d6f 6465 3a3a 6869 6464 656e pen_mode::hidden │ │ │ +00053d50: 2c20 6563 293b 0a09 0969 6620 2865 6329 , ec);...if (ec) │ │ │ +00053d60: 2072 6574 7572 6e3b 0a0a 0909 7374 643a return;....std: │ │ │ +00053d70: 3a76 6563 746f 7226 6c74 3b63 6861 7226 :vector<char& │ │ │ +00053d80: 6774 3b20 6865 6164 6572 2873 7461 7469 gt; header(stati │ │ │ +00053d90: 635f 6361 7374 266c 743b 7374 643a 3a73 c_cast<std::s │ │ │ +00053da0: 697a 655f 7426 6774 3b28 6d5f 6865 6164 ize_t>(m_head │ │ │ +00053db0: 6572 5f73 697a 6529 293b 0a0a 0909 7573 er_size));....us │ │ │ +00053dc0: 696e 6720 6e61 6d65 7370 6163 6520 6c69 ing namespace li │ │ │ +00053dd0: 6274 6f72 7265 6e74 3a3a 6175 783b 0a0a btorrent::aux;.. │ │ │ +00053de0: 0909 6368 6172 2a20 7074 7220 3d20 6865 ..char* ptr = he │ │ │ +00053df0: 6164 6572 2e64 6174 6128 293b 0a09 0977 ader.data();...w │ │ │ +00053e00: 7269 7465 5f75 696e 7433 3228 6d5f 6d61 rite_uint32(m_ma │ │ │ +00053e10: 785f 7069 6563 6573 2c20 7074 7229 3b0a x_pieces, ptr);. │ │ │ +00053e20: 0909 7772 6974 655f 7569 6e74 3332 286d ..write_uint32(m │ │ │ +00053e30: 5f70 6965 6365 5f73 697a 652c 2070 7472 _piece_size, ptr │ │ │ +00053e40: 293b 0a0a 0909 666f 7220 2870 6965 6365 );....for (piece │ │ │ +00053e50: 5f69 6e64 6578 5f74 2070 6965 6365 2830 _index_t piece(0 │ │ │ +00053e60: 293b 2070 6965 6365 2026 6c74 3b20 7069 ); piece < pi │ │ │ +00053e70: 6563 655f 696e 6465 785f 7428 6d5f 6d61 ece_index_t(m_ma │ │ │ +00053e80: 785f 7069 6563 6573 293b 202b 2b70 6965 x_pieces); ++pie │ │ │ +00053e90: 6365 290a 0909 7b0a 0909 0961 7574 6f20 ce)...{....auto │ │ │ +00053ea0: 636f 6e73 7420 6920 3d20 6d5f 7069 6563 const i = m_piec │ │ │ +00053eb0: 655f 6d61 702e 6669 6e64 2870 6965 6365 e_map.find(piece │ │ │ +00053ec0: 293b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f );. │ │ │ +00053ef0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00053f00: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +00053f30: 2f73 7263 2f61 6464 5f74 6f72 7265 6e74 /src/add_torrent │ │ │ +00053f40: 5f70 6172 616d 732e 6370 703a 3738 3c2f _params.cpp:78pre C │ │ │ +00053f60: 2b2b 3137 2c20 4743 4320 616e 6420 6d73 ++17, GCC and ms │ │ │ +00053f70: 7663 2064 6f65 7320 6e6f 7420 6d61 6b65 vc does not make │ │ │ +00053f80: 2073 7464 3a3a 7374 7269 6e67 206e 6f74 std::string not │ │ │ +00053f90: 6872 6f77 206d 6f76 6520 6173 7369 676e hrow move assign │ │ │ +00053fa0: 6162 6c65 2c20 7768 6963 6820 6d65 616e able, which mean │ │ │ +00053fb0: 7320 6e6f 2074 7970 6520 636f 6e74 6169 s no type contai │ │ │ +00053fc0: 6e69 6e67 2061 2073 7472 696e 6720 7769 ning a string wi │ │ │ +00053fd0: 6c6c 2062 6520 6e6f 7468 726f 7720 6d6f ll be nothrow mo │ │ │ +00053fe0: 7665 2061 7373 6967 6e61 626c 6520 6279 ve assignable by │ │ │ +00053ff0: 2064 6566 6175 6c74 2065 6974 6865 7220 default either │ │ │ +00054000: 7374 6174 6963 5f61 7373 6572 7428 7374 static_assert(st │ │ │ +00054010: 643a 3a69 735f 6e6f 7468 726f 775f 6d6f d::is_nothrow_mo │ │ │ +00054020: 7665 5f61 7373 6967 6e61 626c 653c 6164 ve_assignable::value , "shou │ │ │ +00054050: 6c64 2062 6520 6e6f 7468 726f 7720 6d6f ld be nothrow mo │ │ │ +00054060: 7665 2061 7373 6967 6e61 626c 6522 293b ve assignable"); │ │ │ +00054070: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    pr │ │ │ +000540c0: 6520 432b 2b31 372c 2047 4343 2061 6e64 e C++17, GCC and │ │ │ +000540d0: 206d 7376 6320 646f 6573 206e 6f74 206d msvc does not m │ │ │ +000540e0: 616b 6520 7374 643a 3a73 7472 696e 6720 ake std::string │ │ │ +000540f0: 6e6f 7468 726f 7720 6d6f 7665 0a61 7373 nothrow move.ass │ │ │ +00054100: 6967 6e61 626c 652c 2077 6869 6368 206d ignable, which m │ │ │ +00054110: 6561 6e73 206e 6f20 7479 7065 2063 6f6e eans no type con │ │ │ +00054120: 7461 696e 696e 6720 6120 7374 7269 6e67 taining a string │ │ │ +00054130: 2077 696c 6c20 6265 206e 6f74 6872 6f77 will be nothrow │ │ │ +00054140: 206d 6f76 650a 6173 7369 676e 6162 6c65 move.assignable │ │ │ +00054150: 2062 7920 6465 6661 756c 7420 6569 7468 by default eith │ │ │ +00054160: 6572 0a73 7461 7469 635f 6173 7365 7274 er.static_assert │ │ │ +00054170: 2873 7464 3a3a 6973 5f6e 6f74 6872 6f77 (std::is_nothrow │ │ │ +00054180: 5f6d 6f76 655f 6173 7369 676e 6162 6c65 _move_assignable │ │ │ +00054190: 3c61 6464 5f74 6f72 7265 6e74 5f70 6172 ::value., "s │ │ │ +000541b0: 686f 756c 6420 6265 206e 6f74 6872 6f77 hould be nothrow │ │ │ +000541c0: 206d 6f76 6520 6173 7369 676e 6162 6c65 move assignable │ │ │ +000541d0: 2229 3b3c 2f68 323e 3c68 343e 2e2e 2f73 ");

    ../s │ │ │ +000541e0: 7263 2f61 6464 5f74 6f72 7265 6e74 5f70 rc/add_torrent_p │ │ │ +000541f0: 6172 616d 732e 6370 703a 3738 3c2f 6834 arams.cpp:78

    ...DE
    │ │ │ +00054240: 434c 5f46 4c41 4728 7365 7175 656e 7469  CL_FLAG(sequenti
    │ │ │ +00054250: 616c 5f64 6f77 6e6c 6f61 6429 3b0a 0909  al_download);...
    │ │ │ +00054260: 0944 4543 4c5f 464c 4147 2870 696e 6e65  .DECL_FLAG(pinne
    │ │ │ +00054270: 6429 3b0a 0909 0944 4543 4c5f 464c 4147  d);....DECL_FLAG
    │ │ │ +00054280: 2873 746f 705f 7768 656e 5f72 6561 6479  (stop_when_ready
    │ │ │ +00054290: 293b 0a09 0909 4445 434c 5f46 4c41 4728  );....DECL_FLAG(
    │ │ │ +000542a0: 6f76 6572 7269 6465 5f74 7261 636b 6572  override_tracker
    │ │ │ +000542b0: 7329 3b0a 0909 0944 4543 4c5f 464c 4147  s);....DECL_FLAG
    │ │ │ +000542c0: 286f 7665 7272 6964 655f 7765 625f 7365  (override_web_se
    │ │ │ +000542d0: 6564 7329 3b0a 0909 0944 4543 4c5f 464c  eds);....DECL_FL
    │ │ │ +000542e0: 4147 286e 6565 645f 7361 7665 5f72 6573  AG(need_save_res
    │ │ │ +000542f0: 756d 6529 3b0a 0909 0944 4543 4c5f 464c  ume);....DECL_FL
    │ │ │ +00054300: 4147 286f 7665 7272 6964 655f 7265 7375  AG(override_resu
    │ │ │ +00054310: 6d65 5f64 6174 6129 3b0a 0909 0944 4543  me_data);....DEC
    │ │ │ +00054320: 4c5f 464c 4147 286d 6572 6765 5f72 6573  L_FLAG(merge_res
    │ │ │ +00054330: 756d 655f 7472 6163 6b65 7273 293b 0a09  ume_trackers);..
    │ │ │ +00054340: 0909 4445 434c 5f46 4c41 4728 7573 655f  ..DECL_FLAG(use_
    │ │ │ +00054350: 7265 7375 6d65 5f73 6176 655f 7061 7468  resume_save_path
    │ │ │ +00054360: 293b 0a09 0909 4445 434c 5f46 4c41 4728  );....DECL_FLAG(
    │ │ │ +00054370: 6d65 7267 655f 7265 7375 6d65 5f68 7474  merge_resume_htt
    │ │ │ +00054380: 705f 7365 6564 7329 3b0a 0909 0944 4543  p_seeds);....DEC
    │ │ │ +00054390: 4c5f 464c 4147 2864 6566 6175 6c74 5f66  L_FLAG(default_f
    │ │ │ +000543a0: 6c61 6773 293b 0a23 756e 6465 6620 4445  lags);.#undef DE
    │ │ │ +000543b0: 434c 5f46 4c41 470a 2365 6e64 6966 202f  CL_FLAG.#endif /
    │ │ │ +000543c0: 2f20 544f 5252 454e 545f 4142 495f 5645  / TORRENT_ABI_VE
    │ │ │ +000543d0: 5253 494f 4e0a 0a09 7374 6174 6963 5f61  RSION...static_a
    │ │ │ +000543e0: 7373 6572 7428 7374 643a 3a69 735f 6e6f  ssert(std::is_no
    │ │ │ +000543f0: 7468 726f 775f 6d6f 7665 5f63 6f6e 7374  throw_move_const
    │ │ │ +00054400: 7275 6374 6962 6c65 266c 743b 6164 645f  ructible<add_
    │ │ │ +00054410: 746f 7272 656e 745f 7061 7261 6d73 2667  torrent_params&g
    │ │ │ +00054420: 743b 3a3a 7661 6c75 650a 0909 2c20 2273  t;::value..., "s
    │ │ │ +00054430: 686f 756c 6420 6265 206e 6f74 6872 6f77  hould be nothrow
    │ │ │ +00054440: 206d 6f76 6520 636f 6e73 7472 7563 7469   move constructi
    │ │ │ +00054450: 626c 6522 293b 0a0a 0973 7461 7469 635f  ble");...static_
    │ │ │ +00054460: 6173 7365 7274 2873 7464 3a3a 6973 5f6e  assert(std::is_n
    │ │ │ +00054470: 6f74 6872 6f77 5f6d 6f76 655f 636f 6e73  othrow_move_cons
    │ │ │ +00054480: 7472 7563 7469 626c 6526 6c74 3b73 7464  tructible<std
    │ │ │ +00054490: 3a3a 7374 7269 6e67 2667 743b 3a3a 7661  ::string>::va
    │ │ │ +000544a0: 6c75 650a 0909 2c20 2273 686f 756c 6420  lue..., "should 
    │ │ │ +000544b0: 6265 206e 6f74 6872 6f77 206d 6f76 6520  be nothrow move 
    │ │ │ +000544c0: 636f 6e73 7472 7563 7469 626c 6522 293b  constructible");
    │ │ │ +000544d0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +00054500: 0a3c 2f64 6976 3e3c 2f70 7265 3e3c 2f74 .
    relevanc │ │ │ +00054540: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/add_tor │ │ │ +00054580: 7265 6e74 5f70 6172 616d 732e 6370 703a rent_params.cpp: │ │ │ +00054590: 3834 3c2f 613e 3c2f 7464 3e3c 7464 3e69 84i │ │ │ +000545a0: 7420 776f 756c 6420 6265 206e 6963 6520 t would be nice │ │ │ +000545b0: 6966 2074 6869 7320 7761 7320 6e6f 7468 if this was noth │ │ │ +000545c0: 726f 7720 6465 6661 756c 7420 636f 6e73 row default cons │ │ │ +000545d0: 7472 7563 7469 626c 6520 7374 6174 6963 tructible static │ │ │ +000545e0: 5f61 7373 6572 7428 7374 643a 3a69 735f _assert(std::is_ │ │ │ +000545f0: 6e6f 7468 726f 775f 6465 6661 756c 745f nothrow_default_ │ │ │ +00054600: 636f 6e73 7472 7563 7469 626c 653c 6164 constructible::value , "shou │ │ │ +00054630: 6c64 2062 6520 6e6f 7468 726f 7720 6465 ld be nothrow de │ │ │ +00054640: 6661 756c 7420 636f 6e73 7472 7563 7469 fault constructi │ │ │ +00054650: 626c 6522 293b 3c2f 7464 3e3c 2f74 723e ble"); │ │ │ +00054660: 3c74 7220 6964 3d22 3139 3822 2073 7479 │ │ │ +00054690: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +000546a0: 3c68 323e 6974 2077 6f75 6c64 2062 6520

    it would be │ │ │ +000546b0: 6e69 6365 2069 6620 7468 6973 2077 6173 nice if this was │ │ │ +000546c0: 206e 6f74 6872 6f77 2064 6566 6175 6c74 nothrow default │ │ │ +000546d0: 2063 6f6e 7374 7275 6374 6962 6c65 0a73 constructible.s │ │ │ +000546e0: 7461 7469 635f 6173 7365 7274 2873 7464 tatic_assert(std │ │ │ +000546f0: 3a3a 6973 5f6e 6f74 6872 6f77 5f64 6566 ::is_nothrow_def │ │ │ +00054700: 6175 6c74 5f63 6f6e 7374 7275 6374 6962 ault_constructib │ │ │ +00054710: 6c65 3c61 6464 5f74 6f72 7265 6e74 5f70 le::value., │ │ │ +00054730: 2273 686f 756c 6420 6265 206e 6f74 6872 "should be nothr │ │ │ +00054740: 6f77 2064 6566 6175 6c74 2063 6f6e 7374 ow default const │ │ │ +00054750: 7275 6374 6962 6c65 2229 3b3c 2f68 323e ructible");

    │ │ │ +00054760: 3c68 343e 2e2e 2f73 7263 2f61 6464 5f74

    ../src/add_t │ │ │ +00054770: 6f72 7265 6e74 5f70 6172 616d 732e 6370 orrent_params.cp │ │ │ +00054780: 703a 3834 3c2f 6834 3e3c 7072 6520 7374 p:84

    ...DECL_FLAG(
    │ │ │ +000547d0: 7069 6e6e 6564 293b 0a09 0909 4445 434c  pinned);....DECL
    │ │ │ +000547e0: 5f46 4c41 4728 7374 6f70 5f77 6865 6e5f  _FLAG(stop_when_
    │ │ │ +000547f0: 7265 6164 7929 3b0a 0909 0944 4543 4c5f  ready);....DECL_
    │ │ │ +00054800: 464c 4147 286f 7665 7272 6964 655f 7472  FLAG(override_tr
    │ │ │ +00054810: 6163 6b65 7273 293b 0a09 0909 4445 434c  ackers);....DECL
    │ │ │ +00054820: 5f46 4c41 4728 6f76 6572 7269 6465 5f77  _FLAG(override_w
    │ │ │ +00054830: 6562 5f73 6565 6473 293b 0a09 0909 4445  eb_seeds);....DE
    │ │ │ +00054840: 434c 5f46 4c41 4728 6e65 6564 5f73 6176  CL_FLAG(need_sav
    │ │ │ +00054850: 655f 7265 7375 6d65 293b 0a09 0909 4445  e_resume);....DE
    │ │ │ +00054860: 434c 5f46 4c41 4728 6f76 6572 7269 6465  CL_FLAG(override
    │ │ │ +00054870: 5f72 6573 756d 655f 6461 7461 293b 0a09  _resume_data);..
    │ │ │ +00054880: 0909 4445 434c 5f46 4c41 4728 6d65 7267  ..DECL_FLAG(merg
    │ │ │ +00054890: 655f 7265 7375 6d65 5f74 7261 636b 6572  e_resume_tracker
    │ │ │ +000548a0: 7329 3b0a 0909 0944 4543 4c5f 464c 4147  s);....DECL_FLAG
    │ │ │ +000548b0: 2875 7365 5f72 6573 756d 655f 7361 7665  (use_resume_save
    │ │ │ +000548c0: 5f70 6174 6829 3b0a 0909 0944 4543 4c5f  _path);....DECL_
    │ │ │ +000548d0: 464c 4147 286d 6572 6765 5f72 6573 756d  FLAG(merge_resum
    │ │ │ +000548e0: 655f 6874 7470 5f73 6565 6473 293b 0a09  e_http_seeds);..
    │ │ │ +000548f0: 0909 4445 434c 5f46 4c41 4728 6465 6661  ..DECL_FLAG(defa
    │ │ │ +00054900: 756c 745f 666c 6167 7329 3b0a 2375 6e64  ult_flags);.#und
    │ │ │ +00054910: 6566 2044 4543 4c5f 464c 4147 0a23 656e  ef DECL_FLAG.#en
    │ │ │ +00054920: 6469 6620 2f2f 2054 4f52 5245 4e54 5f41  dif // TORRENT_A
    │ │ │ +00054930: 4249 5f56 4552 5349 4f4e 0a0a 0973 7461  BI_VERSION...sta
    │ │ │ +00054940: 7469 635f 6173 7365 7274 2873 7464 3a3a  tic_assert(std::
    │ │ │ +00054950: 6973 5f6e 6f74 6872 6f77 5f6d 6f76 655f  is_nothrow_move_
    │ │ │ +00054960: 636f 6e73 7472 7563 7469 626c 6526 6c74  constructible<
    │ │ │ +00054970: 3b61 6464 5f74 6f72 7265 6e74 5f70 6172  ;add_torrent_par
    │ │ │ +00054980: 616d 7326 6774 3b3a 3a76 616c 7565 0a09  ams>::value..
    │ │ │ +00054990: 092c 2022 7368 6f75 6c64 2062 6520 6e6f  ., "should be no
    │ │ │ +000549a0: 7468 726f 7720 6d6f 7665 2063 6f6e 7374  throw move const
    │ │ │ +000549b0: 7275 6374 6962 6c65 2229 3b0a 0a09 7374  ructible");...st
    │ │ │ +000549c0: 6174 6963 5f61 7373 6572 7428 7374 643a  atic_assert(std:
    │ │ │ +000549d0: 3a69 735f 6e6f 7468 726f 775f 6d6f 7665  :is_nothrow_move
    │ │ │ +000549e0: 5f63 6f6e 7374 7275 6374 6962 6c65 266c  _constructible&l
    │ │ │ +000549f0: 743b 7374 643a 3a73 7472 696e 6726 6774  t;std::string>
    │ │ │ +00054a00: 3b3a 3a76 616c 7565 0a09 092c 2022 7368  ;::value..., "sh
    │ │ │ +00054a10: 6f75 6c64 2062 6520 6e6f 7468 726f 7720  ould be nothrow 
    │ │ │ +00054a20: 6d6f 7665 2063 6f6e 7374 7275 6374 6962  move constructib
    │ │ │ +00054a30: 6c65 2229 3b0a 0a0a 3c64 6976 2073 7479  le");...
    .
    nam │ │ │ +00054a70: 6573 7061 6365 2061 7578 207b 0a0a 092f espace aux {.../ │ │ │ +00054a80: 2f20 7265 7475 726e 7320 7768 6574 6865 / returns whethe │ │ │ +00054a90: 7220 7468 6973 2061 6464 5f74 6f72 7265 r this add_torre │ │ │ +00054aa0: 6e74 5f70 6172 616d 7320 6f62 6a65 6374 nt_params object │ │ │ +00054ab0: 2068 6173 2022 7265 7375 6d65 2d64 6174 has "resume-dat │ │ │ +00054ac0: 6122 2c20 692e 652e 0a09 2f2f 2069 6e66 a", i.e...// inf │ │ │ +00054ad0: 6f72 6d61 7469 6f6e 2061 626f 7574 2077 ormation about w │ │ │ +00054ae0: 6869 6368 2070 6965 6365 7320 7765 2068 hich pieces we h │ │ │ +00054af0: 6176 652e 0a09 626f 6f6c 2063 6f6e 7461 ave...bool conta │ │ │ +00054b00: 696e 735f 7265 7375 6d65 5f64 6174 6128 ins_resume_data( │ │ │ +00054b10: 6164 645f 746f 7272 656e 745f 7061 7261 add_torrent_para │ │ │ +00054b20: 6d73 2063 6f6e 7374 2661 6d70 3b20 6174 ms const& at │ │ │ +00054b30: 7029 0a09 7b0a 0909 7265 7475 726e 2021 p)..{...return ! │ │ │ +00054b40: 6174 702e 6861 7665 5f70 6965 6365 732e atp.have_pieces. │ │ │ +00054b50: 656d 7074 7928 290a 0909 097c 7c20 2861 empty()....|| (a │ │ │ +00054b60: 7470 2e66 6c61 6773 2026 616d 703b 2074 tp.flags & t │ │ │ +00054b70: 6f72 7265 6e74 5f66 6c61 6773 3a3a 7365 orrent_flags::se │ │ │ +00054b80: 6564 5f6d 6f64 6529 3b0a 097d 0a7d 0a0a ed_mode);..}.}.. │ │ │ +00054b90: 7d0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 }.
    < │ │ │ +00054bc0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00054bd0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +00054c00: 7372 632f 6368 6f6b 6572 2e63 7070 3a32 src/choker.cpp:2 │ │ │ +00054c10: 3538 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 58m │ │ │ +00054c20: 616b 6520 636f 6e66 6967 7572 6162 6c65 ake configurable │ │ │ +00054c30: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    ma │ │ │ +00054c80: 6b65 2063 6f6e 6669 6775 7261 626c 653c ke configurable< │ │ │ +00054c90: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f63 /h2>

    ../src/c │ │ │ +00054ca0: 686f 6b65 722e 6370 703a 3235 383c 2f68 hoker.cpp:258
    .../
    │ │ │ +00054cf0: 2f20 6669 7273 7420 7265 7365 7420 7468  / first reset th
    │ │ │ +00054d00: 6520 6e75 6d62 6572 206f 6620 756e 6368  e number of unch
    │ │ │ +00054d10: 6f6b 6520 736c 6f74 732c 2062 6563 6175  oke slots, becau
    │ │ │ +00054d20: 7365 2077 6527 6c6c 2063 616c 6375 6c61  se we'll calcula
    │ │ │ +00054d30: 7465 0a09 0909 2f2f 2069 7420 7075 7265  te....// it pure
    │ │ │ +00054d40: 6c79 2062 6173 6564 206f 6e20 7468 6520  ly based on the 
    │ │ │ +00054d50: 6375 7272 656e 7420 7374 6174 6520 6f66  current state of
    │ │ │ +00054d60: 206f 7572 2070 6565 7273 2e0a 0909 0975   our peers.....u
    │ │ │ +00054d70: 706c 6f61 645f 736c 6f74 7320 3d20 303b  pload_slots = 0;
    │ │ │ +00054d80: 0a0a 0909 0969 6e74 2072 6174 655f 7468  .....int rate_th
    │ │ │ +00054d90: 7265 7368 6f6c 6420 3d20 7365 7474 2e67  reshold = sett.g
    │ │ │ +00054da0: 6574 5f69 6e74 2873 6574 7469 6e67 735f  et_int(settings_
    │ │ │ +00054db0: 7061 636b 3a3a 7261 7465 5f63 686f 6b65  pack::rate_choke
    │ │ │ +00054dc0: 725f 696e 6974 6961 6c5f 7468 7265 7368  r_initial_thresh
    │ │ │ +00054dd0: 6f6c 6429 3b0a 0a09 0909 7374 643a 3a73  old);.....std::s
    │ │ │ +00054de0: 6f72 7428 7065 6572 732e 6265 6769 6e28  ort(peers.begin(
    │ │ │ +00054df0: 292c 2070 6565 7273 2e65 6e64 2829 0a09  ), peers.end()..
    │ │ │ +00054e00: 0909 092c 205b 5d28 7065 6572 5f63 6f6e  ..., [](peer_con
    │ │ │ +00054e10: 6e65 6374 696f 6e20 636f 6e73 742a 206c  nection const* l
    │ │ │ +00054e20: 6873 2c20 7065 6572 5f63 6f6e 6e65 6374  hs, peer_connect
    │ │ │ +00054e30: 696f 6e20 636f 6e73 742a 2072 6873 290a  ion const* rhs).
    │ │ │ +00054e40: 0909 0909 7b20 7265 7475 726e 2075 706c  ....{ return upl
    │ │ │ +00054e50: 6f61 645f 7261 7465 5f63 6f6d 7061 7265  oad_rate_compare
    │ │ │ +00054e60: 286c 6873 2c20 7268 7329 3b20 7d29 3b0a  (lhs, rhs); });.
    │ │ │ +00054e70: 0a09 0909 666f 7220 2861 7574 6f20 636f  ....for (auto co
    │ │ │ +00054e80: 6e73 742a 2070 203a 2070 6565 7273 290a  nst* p : peers).
    │ │ │ +00054e90: 0909 097b 0a09 0909 0969 6e74 2063 6f6e  ...{.....int con
    │ │ │ +00054ea0: 7374 2072 6174 6520 3d20 696e 7428 702d  st rate = int(p-
    │ │ │ +00054eb0: 2667 743b 7570 6c6f 6164 6564 5f69 6e5f  >uploaded_in_
    │ │ │ +00054ec0: 6c61 7374 5f72 6f75 6e64 2829 0a09 0909  last_round()....
    │ │ │ +00054ed0: 0909 2a20 3130 3030 202f 2074 6f74 616c  ..* 1000 / total
    │ │ │ +00054ee0: 5f6d 696c 6c69 7365 636f 6e64 7328 756e  _milliseconds(un
    │ │ │ +00054ef0: 6368 6f6b 655f 696e 7465 7276 616c 2929  choke_interval))
    │ │ │ +00054f00: 3b0a 0a09 0909 092f 2f20 616c 7761 7973  ;......// always
    │ │ │ +00054f10: 2068 6176 6520 6174 206c 6561 7374 2031   have at least 1
    │ │ │ +00054f20: 2075 6e63 686f 6b65 2073 6c6f 740a 0909   unchoke slot...
    │ │ │ +00054f30: 0909 6966 2028 7261 7465 2026 6c74 3b20  ..if (rate < 
    │ │ │ +00054f40: 7261 7465 5f74 6872 6573 686f 6c64 2920  rate_threshold) 
    │ │ │ +00054f50: 6272 6561 6b3b 0a0a 0909 0909 2b2b 7570  break;......++up
    │ │ │ +00054f60: 6c6f 6164 5f73 6c6f 7473 3b0a 0a3c 6469  load_slots;......r
    │ │ │ +00054fa0: 6174 655f 7468 7265 7368 6f6c 6420 2b3d  ate_threshold +=
    │ │ │ +00054fb0: 2032 3034 383b 0a3c 2f64 6976 3e09 0909   2048;....
    │ │ │ +00054fc0: 7d0a 0909 092b 2b75 706c 6f61 645f 736c  }....++upload_sl
    │ │ │ +00054fd0: 6f74 733b 0a09 097d 0a0a 0909 2f2f 2073  ots;...}....// s
    │ │ │ +00054fe0: 6f72 7473 2074 6865 2070 6565 7273 2074  orts the peers t
    │ │ │ +00054ff0: 6861 7420 6172 6520 656c 6967 6962 6c65  hat are eligible
    │ │ │ +00055000: 2066 6f72 2075 6e63 686f 6b65 2062 7920   for unchoke by 
    │ │ │ +00055010: 646f 776e 6c6f 6164 2072 6174 6520 616e  download rate an
    │ │ │ +00055020: 640a 0909 2f2f 2073 6563 6f6e 6461 7279  d...// secondary
    │ │ │ +00055030: 2062 7920 746f 7461 6c20 7570 6c6f 6164   by total upload
    │ │ │ +00055040: 2e20 5468 6520 7265 6173 6f6e 2066 6f72  . The reason for
    │ │ │ +00055050: 2074 6869 7320 6973 2c20 6966 2061 6c6c   this is, if all
    │ │ │ +00055060: 2074 6f72 7265 6e74 7320 6172 650a 0909   torrents are...
    │ │ │ +00055070: 2f2f 2062 6569 6e67 2073 6565 6465 642c  // being seeded,
    │ │ │ +00055080: 2074 6865 2064 6f77 6e6c 6f61 6420 7261   the download ra
    │ │ │ +00055090: 7465 2077 696c 6c20 6265 2030 2c20 616e  te will be 0, an
    │ │ │ +000550a0: 6420 7468 6520 7065 6572 7320 7765 2068  d the peers we h
    │ │ │ +000550b0: 6176 6520 7365 6e74 0a09 092f 2f20 7468  ave sent...// th
    │ │ │ +000550c0: 6520 6c65 6173 7420 746f 2073 686f 756c  e least to shoul
    │ │ │ +000550d0: 6420 6265 2075 6e63 686f 6b65 640a 0a09  d be unchoked...
    │ │ │ +000550e0: 092f 2f20 7765 2075 7365 2070 6172 7469  .// we use parti
    │ │ │ +000550f0: 616c 2073 6f72 7420 6865 7265 2c20 6265  al sort here, be
    │ │ │ +00055100: 6361 7573 6520 7765 206f 6e6c 7920 6361  cause we only ca
    │ │ │ +00055110: 7265 2061 626f 7574 2074 6865 2074 6f70  re about the top
    │ │ │ +00055120: 0a09 092f 2f20 7570 6c6f 6164 5f73 6c6f  ...// upload_slo
    │ │ │ +00055130: 7473 2070 6565 7273 2e0a 0a09 0969 6e74  ts peers.....int
    │ │ │ +00055140: 2063 6f6e 7374 2073 6c6f 7473 203d 2073   const slots = s
    │ │ │ +00055150: 7464 3a3a 6d69 6e28 7570 6c6f 6164 5f73  td::min(upload_s
    │ │ │ +00055160: 6c6f 7473 2c20 696e 7428 7065 6572 732e  lots, int(peers.
    │ │ │ +00055170: 7369 7a65 2829 2929 3b0a 0a09 0969 6620  size()));....if 
    │ │ │ +00055180: 2873 6574 742e 6765 745f 696e 7428 7365  (sett.get_int(se
    │ │ │ +00055190: 7474 696e 6773 5f70 6163 6b3a 3a73 6565  ttings_pack::see
    │ │ │ +000551a0: 645f 6368 6f6b 696e 675f 616c 676f 7269  d_choking_algori
    │ │ │ +000551b0: 7468 6d29 0a09 0909 3d3d 2073 6574 7469  thm)....== setti
    │ │ │ +000551c0: 6e67 735f 7061 636b 3a3a 726f 756e 645f  ngs_pack::round_
    │ │ │ +000551d0: 726f 6269 6e29 0a09 097b 0a09 0909 696e  robin)...{....in
    │ │ │ +000551e0: 7420 636f 6e73 7420 7069 6563 6573 203d  t const pieces =
    │ │ │ +000551f0: 2073 6574 742e 6765 745f 696e 7428 7365   sett.get_int(se
    │ │ │ +00055200: 7474 696e 6773 5f70 6163 6b3a 3a73 6565  ttings_pack::see
    │ │ │ +00055210: 6469 6e67 5f70 6965 6365 5f71 756f 7461  ding_piece_quota
    │ │ │ +00055220: 293b 0a0a 0909 0973 7464 3a3a 6e74 685f  );.....std::nth_
    │ │ │ +00055230: 656c 656d 656e 7428 7065 6572 732e 6265  element(peers.be
    │ │ │ +00055240: 6769 6e28 292c 2070 6565 7273 2e62 6567  gin(), peers.beg
    │ │ │ +00055250: 696e 2829 0a09 0909 092b 2073 6c6f 7473  in().....+ slots
    │ │ │ +00055260: 2c20 7065 6572 732e 656e 6428 290a 0909  , peers.end()...
    │ │ │ +00055270: 0909 2c20 5b70 6965 6365 735d 2870 6565  .., [pieces](pee
    │ │ │ +00055280: 725f 636f 6e6e 6563 7469 6f6e 2063 6f6e  r_connection con
    │ │ │ +00055290: 7374 2a20 6c68 732c 2070 6565 725f 636f  st* lhs, peer_co
    │ │ │ +000552a0: 6e6e 6563 7469 6f6e 2063 6f6e 7374 2a20  nnection const* 
    │ │ │ +000552b0: 7268 7329 0a09 0909 097b 2072 6574 7572  rhs).....{ retur
    │ │ │ +000552c0: 6e20 756e 6368 6f6b 655f 636f 6d70 6172  n unchoke_compar
    │ │ │ +000552d0: 655f 7272 286c 6873 2c20 7268 732c 2070  e_rr(lhs, rhs, p
    │ │ │ +000552e0: 6965 6365 7329 3b20 7d29 3b0a 0909 7d0a  ieces); });...}.
    │ │ │ +000552f0: 0909 656c 7365 2069 6620 2873 6574 742e  ..else if (sett.
    │ │ │ +00055300: 6765 745f 696e 7428 7365 7474 696e 6773  get_int(settings
    │ │ │ +00055310: 5f70 6163 6b3a 3a73 6565 645f 6368 6f6b  _pack::seed_chok
    │ │ │ +00055320: 696e 675f 616c 676f 7269 7468 6d29 0a09  ing_algorithm)..
    │ │ │ +00055330: 0909 3d3d 2073 6574 7469 6e67 735f 7061  ..== settings_pa
    │ │ │ +00055340: 636b 3a3a 6661 7374 6573 745f 7570 6c6f  ck::fastest_uplo
    │ │ │ +00055350: 6164 290a 0909 7b0a 0909 0973 7464 3a3a  ad)...{....std::
    │ │ │ +00055360: 6e74 685f 656c 656d 656e 7428 7065 6572  nth_element(peer
    │ │ │ +00055370: 732e 6265 6769 6e28 292c 2070 6565 7273  s.begin(), peers
    │ │ │ +00055380: 2e62 6567 696e 2829 0a09 0909 092b 2073  .begin().....+ s
    │ │ │ +00055390: 6c6f 7473 2c20 7065 6572 732e 656e 6428  lots, peers.end(
    │ │ │ +000553a0: 290a 0909 0909 2c20 5b5d 2870 6565 725f  )....., [](peer_
    │ │ │ +000553b0: 636f 6e6e 6563 7469 6f6e 2063 6f6e 7374  connection const
    │ │ │ +000553c0: 2a20 6c68 732c 2070 6565 725f 636f 6e6e  * lhs, peer_conn
    │ │ │ +000553d0: 6563 7469 6f6e 2063 6f6e 7374 2a20 7268  ection const* rh
    │ │ │ +000553e0: 7329 0a3c 2f70 7265 3e3c 2f74 643e 3c2f  s).
    │ │ │ +00055410: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00055420: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +00055450: 2f73 7263 2f6d 6572 6b6c 655f 7472 6565 /src/merkle_tree │ │ │ +00055460: 2e63 7070 3a31 3130 3c2f 613e 3c2f 7464 .cpp:110in C++20, u │ │ │ +00055480: 7365 2073 7464 3a3a 6964 656e 7469 7479 se std::identity │ │ │ +00055490: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    in │ │ │ +000554e0: 2043 2b2b 3230 2c20 7573 6520 7374 643a C++20, use std: │ │ │ +000554f0: 3a69 6465 6e74 6974 793c 2f68 323e 3c68 :identity

    ../src/merkle_ │ │ │ +00055510: 7472 6565 2e63 7070 3a31 3130 3c2f 6834 tree.cpp:110
    ..all
    │ │ │ +00055560: 6f63 6174 655f 6675 6c6c 2829 3b0a 0a09  ocate_full();...
    │ │ │ +00055570: 096d 6572 6b6c 655f 7661 6c69 6461 7465  .merkle_validate
    │ │ │ +00055580: 5f63 6f70 7928 742c 206d 5f74 7265 652c  _copy(t, m_tree,
    │ │ │ +00055590: 2072 6f6f 7428 292c 206d 5f62 6c6f 636b   root(), m_block
    │ │ │ +000555a0: 5f76 6572 6966 6965 6429 3b0a 0a09 096c  _verified);....l
    │ │ │ +000555b0: 6f61 645f 7665 7269 6669 6564 5f62 6974  oad_verified_bit
    │ │ │ +000555c0: 7328 7665 7269 6669 6564 293b 0a0a 0909  s(verified);....
    │ │ │ +000555d0: 6f70 7469 6d69 7a65 5f73 746f 7261 6765  optimize_storage
    │ │ │ +000555e0: 2829 3b0a 0909 6f70 7469 6d69 7a65 5f73  ();...optimize_s
    │ │ │ +000555f0: 746f 7261 6765 5f70 6965 6365 5f6c 6179  torage_piece_lay
    │ │ │ +00055600: 6572 2829 3b0a 097d 0a0a 0976 6f69 6420  er();..}...void 
    │ │ │ +00055610: 6d65 726b 6c65 5f74 7265 653a 3a63 6c65  merkle_tree::cle
    │ │ │ +00055620: 6172 2829 0a09 7b0a 0909 6d5f 7472 6565  ar()..{...m_tree
    │ │ │ +00055630: 2e63 6c65 6172 2829 3b0a 0909 6d5f 7472  .clear();...m_tr
    │ │ │ +00055640: 6565 2e73 6872 696e 6b5f 746f 5f66 6974  ee.shrink_to_fit
    │ │ │ +00055650: 2829 3b0a 0909 6d5f 626c 6f63 6b5f 7665  ();...m_block_ve
    │ │ │ +00055660: 7269 6669 6564 2e63 6c65 6172 2829 3b0a  rified.clear();.
    │ │ │ +00055670: 0909 6d5f 6d6f 6465 203d 206d 6f64 655f  ..m_mode = mode_
    │ │ │ +00055680: 743a 3a65 6d70 7479 5f74 7265 653b 0a09  t::empty_tree;..
    │ │ │ +00055690: 7d0a 0a6e 616d 6573 7061 6365 207b 0a0a  }..namespace {..
    │ │ │ +000556a0: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .s │ │ │ +000556d0: 7472 7563 7420 6964 656e 7469 7479 0a3c truct identity.< │ │ │ +000556e0: 2f64 6976 3e09 7b0a 0909 626f 6f6c 206f /div>.{...bool o │ │ │ +000556f0: 7065 7261 746f 7228 2928 626f 6f6c 2062 perator()(bool b │ │ │ +00055700: 2920 636f 6e73 7420 7b20 7265 7475 726e ) const { return │ │ │ +00055710: 2062 3b20 7d0a 097d 3b0a 7d0a 0a09 766f b; }..};.}...vo │ │ │ +00055720: 6964 206d 6572 6b6c 655f 7472 6565 3a3a id merkle_tree:: │ │ │ +00055730: 6c6f 6164 5f73 7061 7273 655f 7472 6565 load_sparse_tree │ │ │ +00055740: 2873 7061 6e26 6c74 3b73 6861 3235 365f (span<sha256_ │ │ │ +00055750: 6861 7368 2063 6f6e 7374 2667 743b 2074 hash const> t │ │ │ +00055760: 0a09 092c 2073 7464 3a3a 7665 6374 6f72 ..., std::vector │ │ │ +00055770: 266c 743b 626f 6f6c 2667 743b 2063 6f6e <bool> con │ │ │ +00055780: 7374 2661 6d70 3b20 6d61 736b 0a09 092c st& mask..., │ │ │ +00055790: 2073 7464 3a3a 7665 6374 6f72 266c 743b std::vector< │ │ │ +000557a0: 626f 6f6c 2667 743b 2063 6f6e 7374 2661 bool> const&a │ │ │ +000557b0: 6d70 3b20 7665 7269 6669 6564 290a 097b mp; verified)..{ │ │ │ +000557c0: 0a09 0949 4e56 4152 4941 4e54 5f43 4845 ...INVARIANT_CHE │ │ │ +000557d0: 434b 3b0a 0a09 092f 2f20 5468 6520 7369 CK;....// The si │ │ │ +000557e0: 7a65 206f 6620 7468 6520 6d61 736b 2073 ze of the mask s │ │ │ +000557f0: 686f 756c 6420 6e6f 7420 6578 6365 6564 hould not exceed │ │ │ +00055800: 2074 6865 2073 697a 6520 6f66 2074 6865 the size of the │ │ │ +00055810: 2074 7265 652c 2062 7574 2061 206d 6173 tree, but a mas │ │ │ +00055820: 6b20 6c61 7267 6572 2074 6861 6e0a 0909 k larger than... │ │ │ +00055830: 2f2f 2074 6865 2074 7265 6520 6361 6e20 // the tree can │ │ │ +00055840: 6265 2065 6e63 6f75 6e74 6572 6564 2069 be encountered i │ │ │ +00055850: 6e20 7468 6520 2272 6573 756d 6520 6461 n the "resume da │ │ │ +00055860: 7461 2220 666f 7220 736f 6d65 2072 6561 ta" for some rea │ │ │ +00055870: 736f 6e2c 2070 6572 6861 7073 2074 6865 son, perhaps the │ │ │ +00055880: 7265 2069 730a 0909 2f2f 2061 2062 7567 re is...// a bug │ │ │ +00055890: 2069 6e20 7468 6520 2272 6573 756d 6520 in the "resume │ │ │ +000558a0: 6461 7461 2220 6765 6e65 7261 7469 6f6e data" generation │ │ │ +000558b0: 2061 6c67 6f72 6974 686d 2e0a 0909 2f2f algorithm....// │ │ │ +000558c0: 2053 6f20 7765 206a 7573 7420 7072 6f63 So we just proc │ │ │ +000558d0: 6573 7320 6d61 736b 2069 7465 6d73 2063 ess mask items c │ │ │ +000558e0: 6f75 6e74 2075 7020 746f 2074 7265 6520 ount up to tree │ │ │ +000558f0: 7369 7a65 2e0a 0909 696e 7420 636f 6e73 size....int cons │ │ │ +00055900: 7420 6d61 736b 5f73 697a 6520 3d20 696e t mask_size = in │ │ │ +00055910: 7428 7374 643a 3a6d 696e 286d 6173 6b2e t(std::min(mask. │ │ │ +00055920: 7369 7a65 2829 2c20 7369 7a65 2829 2929 size(), size())) │ │ │ +00055930: 3b0a 0a09 0969 6e74 2063 6f6e 7374 2066 ;....int const f │ │ │ +00055940: 6972 7374 5f62 6c6f 636b 203d 2062 6c6f irst_block = blo │ │ │ +00055950: 636b 5f6c 6179 6572 5f73 7461 7274 2829 ck_layer_start() │ │ │ +00055960: 3b0a 0909 696e 7420 636f 6e73 7420 656e ;...int const en │ │ │ +00055970: 645f 626c 6f63 6b20 3d20 6669 7273 745f d_block = first_ │ │ │ +00055980: 626c 6f63 6b20 2b20 6d5f 6e75 6d5f 626c block + m_num_bl │ │ │ +00055990: 6f63 6b73 3b0a 0a09 0954 4f52 5245 4e54 ocks;....TORRENT │ │ │ +000559a0: 5f41 5353 4552 5428 6669 7273 745f 626c _ASSERT(first_bl │ │ │ +000559b0: 6f63 6b20 266c 743b 2069 6e74 2873 697a ock < int(siz │ │ │ +000559c0: 6528 2929 293b 0a09 0954 4f52 5245 4e54 e()));...TORRENT │ │ │ +000559d0: 5f41 5353 4552 5428 656e 645f 626c 6f63 _ASSERT(end_bloc │ │ │ +000559e0: 6b20 266c 743b 3d20 696e 7428 7369 7a65 k <= int(size │ │ │ +000559f0: 2829 2929 3b0a 0a09 092f 2f20 6966 2074 ()));....// if t │ │ │ +00055a00: 6865 206d 6173 6b20 636f 7665 7273 2061 he mask covers a │ │ │ +00055a10: 6c6c 2062 6c6f 636b 732c 2067 6f20 7374 ll blocks, go st │ │ │ +00055a20: 7261 6967 6874 2074 6f20 626c 6f63 6b5f raight to block_ │ │ │ +00055a30: 6c61 7965 720a 0909 2f2f 206d 6f64 652c layer...// mode, │ │ │ +00055a40: 2061 6e64 2076 616c 6964 6174 650a 0909 and validate... │ │ │ +00055a50: 6966 2028 2866 6972 7374 5f62 6c6f 636b if ((first_block │ │ │ +00055a60: 2026 6c74 3b20 6d61 736b 5f73 697a 6529 < mask_size) │ │ │ +00055a70: 2026 616d 703b 2661 6d70 3b20 2865 6e64 && (end │ │ │ +00055a80: 5f62 6c6f 636b 2026 6c74 3b3d 206d 6173 _block <= mas │ │ │ +00055a90: 6b5f 7369 7a65 290a 0909 0926 616d 703b k_size)....& │ │ │ +00055aa0: 2661 6d70 3b20 7374 643a 3a61 6c6c 5f6f & std::all_o │ │ │ +00055ab0: 6628 6d61 736b 2e62 6567 696e 2829 202b f(mask.begin() + │ │ │ +00055ac0: 2066 6972 7374 5f62 6c6f 636b 2c20 6d61 first_block, ma │ │ │ +00055ad0: 736b 2e62 6567 696e 2829 202b 2065 6e64 sk.begin() + end │ │ │ +00055ae0: 5f62 6c6f 636b 2c20 6964 656e 7469 7479 _block, identity │ │ │ +00055af0: 2829 2929 0a09 097b 0a09 0909 2f2f 2074 ()))...{....// t │ │ │ +00055b00: 6865 2069 6e64 6578 2069 6e20 7420 7468 he index in t th │ │ │ +00055b10: 6174 2070 6f69 6e74 7320 746f 2066 6972 at points to fir │ │ │ +00055b20: 7374 5f62 6c6f 636b 0a09 0909 6175 746f st_block....auto │ │ │ +00055b30: 2063 6f6e 7374 2062 6c6f 636b 5f69 6e64 const block_ind │ │ │ +00055b40: 6578 203d 2073 7464 3a3a 636f 756e 745f ex = std::count_ │ │ │ +00055b50: 6966 286d 6173 6b2e 6265 6769 6e28 292c if(mask.begin(), │ │ │ +00055b60: 206d 6173 6b2e 6265 6769 6e28 2920 2b20 mask.begin() + │ │ │ +00055b70: 6669 7273 745f 626c 6f63 6b2c 2069 6465 first_block, ide │ │ │ +00055b80: 6e74 6974 7928 2929 3b0a 3c2f 7072 653e ntity());.
    │ │ │ +00055b90: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +00055bc0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +00055bd0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/merk │ │ │ +00055c00: 6c65 5f74 7265 652e 6370 703a 3332 393c le_tree.cpp:329< │ │ │ +00055c10: 2f61 3e3c 2f74 643e 3c74 643e 7468 6973 /a>this │ │ │ +00055c20: 2063 616e 2062 6520 6f70 7469 6d69 7a65 can be optimize │ │ │ +00055c30: 6420 6279 2075 7369 6e67 206d 5f74 7265 d by using m_tre │ │ │ +00055c40: 6520 6173 2073 746f 7261 6765 2074 6f20 e as storage to │ │ │ +00055c50: 6669 6c6c 2074 6869 7320 7472 6565 2069 fill this tree i │ │ │ +00055c60: 6e74 6f2c 2061 6e64 2074 6865 6e20 636c nto, and then cl │ │ │ +00055c70: 6561 7220 6974 2069 6620 7468 6520 6861 ear it if the ha │ │ │ +00055c80: 7368 6573 2066 6169 6c3c 2f74 643e 3c2f shes fail

    this can │ │ │ +00055ce0: 6265 206f 7074 696d 697a 6564 2062 7920 be optimized by │ │ │ +00055cf0: 7573 696e 6720 6d5f 7472 6565 2061 7320 using m_tree as │ │ │ +00055d00: 7374 6f72 6167 6520 746f 2066 696c 6c20 storage to fill │ │ │ +00055d10: 7468 6973 0a74 7265 6520 696e 746f 2c20 this.tree into, │ │ │ +00055d20: 616e 6420 7468 656e 2063 6c65 6172 2069 and then clear i │ │ │ +00055d30: 7420 6966 2074 6865 2068 6173 6865 7320 t if the hashes │ │ │ +00055d40: 6661 696c 3c2f 6832 3e3c 6834 3e2e 2e2f fail

    ../ │ │ │ +00055d50: 7372 632f 6d65 726b 6c65 5f74 7265 652e src/merkle_tree. │ │ │ +00055d60: 6370 703a 3332 393c 2f68 343e 3c70 7265 cpp:329

    .{...INVAR
    │ │ │ +00055db0: 4941 4e54 5f43 4845 434b 3b0a 0a09 092f  IANT_CHECK;..../
    │ │ │ +00055dc0: 2f20 6173 2077 6520 7365 7420 7468 6520  / as we set the 
    │ │ │ +00055dd0: 6861 7368 6573 206f 6620 696e 7465 7269  hashes of interi
    │ │ │ +00055de0: 6f72 206e 6f64 6573 2c20 7765 206d 6179  or nodes, we may
    │ │ │ +00055df0: 2062 6520 6162 6c65 2074 6f20 7661 6c69   be able to vali
    │ │ │ +00055e00: 6461 7465 0a09 092f 2f20 626c 6f63 6b20  date...// block 
    │ │ │ +00055e10: 6861 7368 6573 2074 6861 7420 7765 2068  hashes that we h
    │ │ │ +00055e20: 6164 2073 696e 6365 2065 6172 6c69 6572  ad since earlier
    │ │ │ +00055e30: 2e20 416e 7920 626c 6f63 6b73 2074 6861  . Any blocks tha
    │ │ │ +00055e40: 7420 6361 6e20 6265 0a09 092f 2f20 7661  t can be...// va
    │ │ │ +00055e50: 6c69 6461 7465 642c 2061 6e64 2066 6169  lidated, and fai
    │ │ │ +00055e60: 6c65 642c 2061 7265 2061 6464 6564 2074  led, are added t
    │ │ │ +00055e70: 6f20 7468 6973 206c 6973 740a 0909 6164  o this list...ad
    │ │ │ +00055e80: 645f 6861 7368 6573 5f72 6573 756c 745f  d_hashes_result_
    │ │ │ +00055e90: 7420 7265 743b 0a0a 0909 2f2f 2077 6520  t ret;....// we 
    │ │ │ +00055ea0: 616c 7265 6164 7920 6861 7665 2061 6c6c  already have all
    │ │ │ +00055eb0: 2068 6173 6865 730a 0909 6966 2028 6d5f   hashes...if (m_
    │ │ │ +00055ec0: 6d6f 6465 203d 3d20 6d6f 6465 5f74 3a3a  mode == mode_t::
    │ │ │ +00055ed0: 626c 6f63 6b5f 6c61 7965 7229 0a09 097b  block_layer)...{
    │ │ │ +00055ee0: 0a09 0909 2f2f 2073 696e 6365 2077 6527  ....// since we'
    │ │ │ +00055ef0: 7265 2061 6c72 6561 6479 206f 6e20 7468  re already on th
    │ │ │ +00055f00: 6520 626c 6f63 6b20 6c61 7965 7220 6d6f  e block layer mo
    │ │ │ +00055f10: 6465 2c20 7765 2068 6176 6520 7468 6520  de, we have the 
    │ │ │ +00055f20: 7768 6f6c 650a 0909 092f 2f20 7472 6565  whole....// tree
    │ │ │ +00055f30: 2c20 616e 6420 7765 2776 6520 616c 7265  , and we've alre
    │ │ │ +00055f40: 6164 7920 7265 706f 7274 6564 2061 6e79  ady reported any
    │ │ │ +00055f50: 2070 6965 6365 7320 6173 2070 6173 7369   pieces as passi
    │ │ │ +00055f60: 6e67 2074 6861 7420 6d61 790a 0909 092f  ng that may..../
    │ │ │ +00055f70: 2f20 6861 7665 2065 7869 7374 6564 2069  / have existed i
    │ │ │ +00055f80: 6e20 7468 6520 7472 6565 2077 6865 6e20  n the tree when 
    │ │ │ +00055f90: 7765 2063 6f6d 706c 6574 6564 2069 742e  we completed it.
    │ │ │ +00055fa0: 2041 7420 7468 6973 2070 6f69 6e74 206e   At this point n
    │ │ │ +00055fb0: 6f0a 0909 092f 2f20 6d6f 7265 2070 6965  o....// more pie
    │ │ │ +00055fc0: 6365 7320 7368 6f75 6c64 2062 6520 7265  ces should be re
    │ │ │ +00055fd0: 706f 7274 6564 2061 7320 7061 7373 6564  ported as passed
    │ │ │ +00055fe0: 0a09 0909 7265 7475 726e 2072 6574 3b0a  ....return ret;.
    │ │ │ +00055ff0: 0909 7d0a 0a09 0961 6c6c 6f63 6174 655f  ..}....allocate_
    │ │ │ +00056000: 6675 6c6c 2829 3b0a 0a3c 6469 7620 7374  full();..
    ..int con │ │ │ +00056040: 7374 206c 6561 665f 636f 756e 7420 3d20 st leaf_count = │ │ │ +00056050: 6d65 726b 6c65 5f6e 756d 5f6c 6561 6673 merkle_num_leafs │ │ │ +00056060: 2869 6e74 2868 6173 6865 732e 7369 7a65 (int(hashes.size │ │ │ +00056070: 2829 2929 3b0a 3c2f 6469 763e 0909 6175 ()));.
    ..au │ │ │ +00056080: 783a 3a76 6563 746f 7226 6c74 3b73 6861 x::vector<sha │ │ │ +00056090: 3235 365f 6861 7368 2667 743b 2074 7265 256_hash> tre │ │ │ +000560a0: 6528 6d65 726b 6c65 5f6e 756d 5f6e 6f64 e(merkle_num_nod │ │ │ +000560b0: 6573 286c 6561 665f 636f 756e 7429 293b es(leaf_count)); │ │ │ +000560c0: 0a09 0973 7464 3a3a 636f 7079 2868 6173 ...std::copy(has │ │ │ +000560d0: 6865 732e 6265 6769 6e28 292c 2068 6173 hes.begin(), has │ │ │ +000560e0: 6865 732e 656e 6428 292c 2074 7265 652e hes.end(), tree. │ │ │ +000560f0: 656e 6428 2920 2d20 6c65 6166 5f63 6f75 end() - leaf_cou │ │ │ +00056100: 6e74 293b 0a0a 0909 2f2f 2074 6865 2065 nt);....// the e │ │ │ +00056110: 6e64 206f 6620 6120 6669 6c65 2069 7320 nd of a file is │ │ │ +00056120: 6120 7370 6563 6961 6c20 6361 7365 2c20 a special case, │ │ │ +00056130: 7765 206d 6179 206e 6565 6420 746f 2070 we may need to p │ │ │ +00056140: 6164 2074 6865 206c 6561 6620 6c61 7965 ad the leaf laye │ │ │ +00056150: 720a 0909 6966 2028 6c65 6166 5f63 6f75 r...if (leaf_cou │ │ │ +00056160: 6e74 2026 6774 3b20 6861 7368 6573 2e73 nt > hashes.s │ │ │ +00056170: 697a 6528 2929 0a09 097b 0a09 0909 696e ize())...{....in │ │ │ +00056180: 7420 636f 6e73 7420 6c65 6166 5f6c 6179 t const leaf_lay │ │ │ +00056190: 6572 5f73 697a 6520 3d20 6e75 6d5f 6c65 er_size = num_le │ │ │ +000561a0: 6166 7328 293b 0a09 0909 2f2f 2061 7373 afs();....// ass │ │ │ +000561b0: 756d 696e 6720 756e 636c 655f 6861 7368 uming uncle_hash │ │ │ +000561c0: 6573 206c 6561 6420 616c 6c20 7468 6520 es lead all the │ │ │ +000561d0: 7761 7920 746f 2074 6865 2072 6f6f 742c way to the root, │ │ │ +000561e0: 2074 6865 7920 7465 6c6c 2075 730a 0909 they tell us... │ │ │ +000561f0: 092f 2f20 686f 7720 6d61 6e79 206c 6179 .// how many lay │ │ │ +00056200: 6572 7320 646f 776e 2077 6520 6172 650a ers down we are. │ │ │ +00056210: 0909 0969 6e74 2063 6f6e 7374 2069 6e73 ...int const ins │ │ │ +00056220: 6572 745f 6c61 7965 725f 7369 7a65 203d ert_layer_size = │ │ │ +00056230: 206c 6561 665f 636f 756e 7420 266c 743b leaf_count < │ │ │ +00056240: 266c 743b 2075 6e63 6c65 5f68 6173 6865 < uncle_hashe │ │ │ +00056250: 732e 7369 7a65 2829 3b0a 0909 0969 6620 s.size();....if │ │ │ +00056260: 286c 6561 665f 6c61 7965 725f 7369 7a65 (leaf_layer_size │ │ │ +00056270: 2021 3d20 696e 7365 7274 5f6c 6179 6572 != insert_layer │ │ │ +00056280: 5f73 697a 6529 0a09 0909 7b0a 0909 0909 _size)....{..... │ │ │ +00056290: 7368 6132 3536 5f68 6173 6820 636f 6e73 sha256_hash cons │ │ │ +000562a0: 7420 7061 645f 6861 7368 203d 206d 6572 t pad_hash = mer │ │ │ +000562b0: 6b6c 655f 7061 6428 6c65 6166 5f6c 6179 kle_pad(leaf_lay │ │ │ +000562c0: 6572 5f73 697a 652c 2069 6e73 6572 745f er_size, insert_ │ │ │ +000562d0: 6c61 7965 725f 7369 7a65 293b 0a09 0909 layer_size);.... │ │ │ +000562e0: 0966 6f72 2028 696e 7420 6920 3d20 696e .for (int i = in │ │ │ +000562f0: 7428 6861 7368 6573 2e73 697a 6528 2929 t(hashes.size()) │ │ │ +00056300: 3b20 6920 266c 743b 206c 6561 665f 636f ; i < leaf_co │ │ │ +00056310: 756e 743b 202b 2b69 290a 0909 0909 0974 unt; ++i)......t │ │ │ +00056320: 7265 655b 7472 6565 2e65 6e64 5f69 6e64 ree[tree.end_ind │ │ │ +00056330: 6578 2829 202d 206c 6561 665f 636f 756e ex() - leaf_coun │ │ │ +00056340: 7420 2b20 695d 203d 2070 6164 5f68 6173 t + i] = pad_has │ │ │ +00056350: 683b 0a09 0909 7d0a 0909 7d0a 0a09 096d h;....}...}....m │ │ │ +00056360: 6572 6b6c 655f 6669 6c6c 5f74 7265 6528 erkle_fill_tree( │ │ │ +00056370: 7472 6565 2c20 6c65 6166 5f63 6f75 6e74 tree, leaf_count │ │ │ +00056380: 293b 0a0a 0909 696e 7420 636f 6e73 7420 );....int const │ │ │ +00056390: 6261 7365 5f6e 756d 5f6c 6179 6572 7320 base_num_layers │ │ │ +000563a0: 3d20 6d65 726b 6c65 5f6e 756d 5f6c 6179 = merkle_num_lay │ │ │ +000563b0: 6572 7328 6c65 6166 5f63 6f75 6e74 293b ers(leaf_count); │ │ │ +000563c0: 0a0a 0909 2f2f 2074 6869 7320 6973 2074 ....// this is t │ │ │ +000563d0: 6865 2069 6e64 6578 206f 6620 7468 6520 he index of the │ │ │ +000563e0: 6e6f 6465 2077 6865 7265 2077 6527 6c6c node where we'll │ │ │ +000563f0: 2069 6e73 6572 7420 7468 6520 726f 6f74 insert the root │ │ │ +00056400: 206f 6620 7468 650a 0909 2f2f 2073 7562 of the...// sub │ │ │ +00056410: 7472 6565 2028 7472 6565 292e 2049 7427 tree (tree). It' │ │ │ +00056420: 7320 616c 736f 2074 6865 2068 6173 6820 s also the hash │ │ │ +00056430: 7468 6520 756e 636c 655f 6861 7368 6573 the uncle_hashes │ │ │ +00056440: 2061 7265 2068 6572 6520 746f 2070 726f are here to pro │ │ │ +00056450: 7665 0a09 092f 2f20 6973 2076 616c 6964 ve...// is valid │ │ │ +00056460: 2e0a 0909 696e 7420 636f 6e73 7420 696e ....int const in │ │ │ +00056470: 7365 7274 5f72 6f6f 745f 6964 7820 3d20 sert_root_idx = │ │ │ +00056480: 6465 7374 5f73 7461 7274 5f69 6478 2026 dest_start_idx & │ │ │ +00056490: 6774 3b26 6774 3b20 6261 7365 5f6e 756d gt;> base_num │ │ │ +000564a0: 5f6c 6179 6572 733b 0a0a 0909 2f2f 2073 _layers;....// s │ │ │ +000564b0: 7461 7274 2077 6974 6820 7661 6c69 6461 tart with valida │ │ │ +000564c0: 7469 6e67 2074 6865 2070 726f 6f66 732c ting the proofs, │ │ │ +000564d0: 2061 6e64 2069 6e73 6572 7469 6e67 2074 and inserting t │ │ │ +000564e0: 6865 6d20 6173 2077 6520 676f 2e0a 0909 hem as we go.... │ │ │ +000564f0: 6966 2028 216d 6572 6b6c 655f 7661 6c69 if (!merkle_vali │ │ │ +00056500: 6461 7465 5f61 6e64 5f69 6e73 6572 745f date_and_insert_ │ │ │ +00056510: 7072 6f6f 6673 286d 5f74 7265 652c 2069 proofs(m_tree, i │ │ │ +00056520: 6e73 6572 745f 726f 6f74 5f69 6478 2c20 nsert_root_idx, │ │ │ +00056530: 7472 6565 5b30 5d2c 2075 6e63 6c65 5f68 tree[0], uncle_h │ │ │ +00056540: 6173 6865 7329 290a 0909 0972 6574 7572 ashes))....retur │ │ │ +00056550: 6e20 7b7d 3b0a 3c2f 7072 653e 3c2f 7464 n {};.
    relevance │ │ │ +00056590: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +000565a0: 3c61 2068 7265 663d 226a 6176 6173 6372
    ../src/merkle_t │ │ │ +000565d0: 7265 652e 6370 703a 3337 373c 2f61 3e3c ree.cpp:377< │ │ │ +000565e0: 2f74 643e 3c74 643e 6120 7069 6563 6520 /td>a piece │ │ │ +000565f0: 6f75 7473 6964 6520 6f66 2074 6869 7320 outside of this │ │ │ +00056600: 7261 6e67 6520 6d61 7920 616c 736f 2066 range may also f │ │ │ +00056610: 6169 6c2c 2069 6620 6f6e 6520 6f66 2074 ail, if one of t │ │ │ +00056620: 6865 2075 6e63 6c65 2068 6173 6865 7320 he uncle hashes │ │ │ +00056630: 6973 2061 7420 7468 6520 6c61 7965 7220 is at the layer │ │ │ +00056640: 7269 6768 7420 6162 6f76 6520 7468 6520 right above the │ │ │ +00056650: 626c 6f63 6b20 6861 7368 6573 3c2f 7464 block hashes

    a piec │ │ │ +000566b0: 6520 6f75 7473 6964 6520 6f66 2074 6869 e outside of thi │ │ │ +000566c0: 7320 7261 6e67 6520 6d61 7920 616c 736f s range may also │ │ │ +000566d0: 2066 6169 6c2c 2069 6620 6f6e 6520 6f66 fail, if one of │ │ │ +000566e0: 2074 6865 2075 6e63 6c65 0a68 6173 6865 the uncle.hashe │ │ │ +000566f0: 7320 6973 2061 7420 7468 6520 6c61 7965 s is at the laye │ │ │ +00056700: 7220 7269 6768 7420 6162 6f76 6520 7468 r right above th │ │ │ +00056710: 6520 626c 6f63 6b20 6861 7368 6573 3c2f e block hashes

    ../src/me │ │ │ +00056730: 726b 6c65 5f74 7265 652e 6370 703a 3337 rkle_tree.cpp:37 │ │ │ +00056740: 373c 2f68 343e 3c70 7265 2073 7479 6c65 7

    │ │ │ +00056780: 0909 696e 7420 636f 6e73 7420 696e 7365  ..int const inse
    │ │ │ +00056790: 7274 5f72 6f6f 745f 6964 7820 3d20 6465  rt_root_idx = de
    │ │ │ +000567a0: 7374 5f73 7461 7274 5f69 6478 2026 6774  st_start_idx >
    │ │ │ +000567b0: 3b26 6774 3b20 6261 7365 5f6e 756d 5f6c  ;> base_num_l
    │ │ │ +000567c0: 6179 6572 733b 0a0a 0909 2f2f 2073 7461  ayers;....// sta
    │ │ │ +000567d0: 7274 2077 6974 6820 7661 6c69 6461 7469  rt with validati
    │ │ │ +000567e0: 6e67 2074 6865 2070 726f 6f66 732c 2061  ng the proofs, a
    │ │ │ +000567f0: 6e64 2069 6e73 6572 7469 6e67 2074 6865  nd inserting the
    │ │ │ +00056800: 6d20 6173 2077 6520 676f 2e0a 0909 6966  m as we go....if
    │ │ │ +00056810: 2028 216d 6572 6b6c 655f 7661 6c69 6461   (!merkle_valida
    │ │ │ +00056820: 7465 5f61 6e64 5f69 6e73 6572 745f 7072  te_and_insert_pr
    │ │ │ +00056830: 6f6f 6673 286d 5f74 7265 652c 2069 6e73  oofs(m_tree, ins
    │ │ │ +00056840: 6572 745f 726f 6f74 5f69 6478 2c20 7472  ert_root_idx, tr
    │ │ │ +00056850: 6565 5b30 5d2c 2075 6e63 6c65 5f68 6173  ee[0], uncle_has
    │ │ │ +00056860: 6865 7329 290a 0909 0972 6574 7572 6e20  hes))....return 
    │ │ │ +00056870: 7b7d 3b0a 0a09 092f 2f20 6669 7273 7420  {};....// first 
    │ │ │ +00056880: 6669 6c6c 2069 6e20 7468 6520 7375 6274  fill in the subt
    │ │ │ +00056890: 7265 6520 6f66 206b 6e6f 776e 2068 6173  ree of known has
    │ │ │ +000568a0: 6865 7320 6672 6f6d 2074 6865 2062 6173  hes from the bas
    │ │ │ +000568b0: 6520 6c61 7965 720a 0909 6175 746f 2063  e layer...auto c
    │ │ │ +000568c0: 6f6e 7374 206e 756d 5f6c 6561 6673 203d  onst num_leafs =
    │ │ │ +000568d0: 206d 6572 6b6c 655f 6e75 6d5f 6c65 6166   merkle_num_leaf
    │ │ │ +000568e0: 7328 6d5f 6e75 6d5f 626c 6f63 6b73 293b  s(m_num_blocks);
    │ │ │ +000568f0: 0a09 0961 7574 6f20 636f 6e73 7420 6669  ...auto const fi
    │ │ │ +00056900: 7273 745f 6c65 6166 203d 206d 6572 6b6c  rst_leaf = merkl
    │ │ │ +00056910: 655f 6669 7273 745f 6c65 6166 286e 756d  e_first_leaf(num
    │ │ │ +00056920: 5f6c 6561 6673 293b 0a0a 0909 2f2f 2074  _leafs);....// t
    │ │ │ +00056930: 6869 7320 6973 2074 6865 2073 7461 7274  his is the start
    │ │ │ +00056940: 206f 6620 7468 6520 6c65 6166 206c 6179   of the leaf lay
    │ │ │ +00056950: 6572 206f 6620 2274 7265 6522 2e20 5765  er of "tree". We
    │ │ │ +00056960: 276c 6c20 7573 6520 7468 6973 0a09 092f  'll use this.../
    │ │ │ +00056970: 2f20 7661 7269 6162 6c65 2074 6f20 7374  / variable to st
    │ │ │ +00056980: 6570 2075 7077 6172 6473 2074 6f77 6172  ep upwards towar
    │ │ │ +00056990: 6473 2074 6865 2072 6f6f 740a 0909 696e  ds the root...in
    │ │ │ +000569a0: 7420 736f 7572 6365 5f63 7572 736f 7220  t source_cursor 
    │ │ │ +000569b0: 3d20 696e 7428 7472 6565 2e73 697a 6528  = int(tree.size(
    │ │ │ +000569c0: 2929 202d 206c 6561 665f 636f 756e 743b  )) - leaf_count;
    │ │ │ +000569d0: 0a09 092f 2f20 7468 6520 7275 6e6e 696e  ...// the runnin
    │ │ │ +000569e0: 6720 696e 6465 7820 696e 2074 6865 206c  g index in the l
    │ │ │ +000569f0: 6f6f 700a 0909 696e 7420 6465 7374 5f63  oop...int dest_c
    │ │ │ +00056a00: 7572 736f 7220 3d20 6465 7374 5f73 7461  ursor = dest_sta
    │ │ │ +00056a10: 7274 5f69 6478 3b0a 0a09 092f 2f20 7468  rt_idx;....// th
    │ │ │ +00056a20: 6520 6e75 6d62 6572 206f 6620 7472 6565  e number of tree
    │ │ │ +00056a30: 206c 6576 656c 7320 696e 2061 2070 6965   levels in a pie
    │ │ │ +00056a40: 6365 2068 6173 682e 2030 206d 6561 6e73  ce hash. 0 means
    │ │ │ +00056a50: 2074 6865 2062 6c6f 636b 206c 6179 6572   the block layer
    │ │ │ +00056a60: 2069 730a 0909 2f2f 2074 6865 2073 616d   is...// the sam
    │ │ │ +00056a70: 6520 6173 2074 6865 2070 6965 6365 206c  e as the piece l
    │ │ │ +00056a80: 6179 6572 0a09 0969 6e74 2063 6f6e 7374  ayer...int const
    │ │ │ +00056a90: 2062 6173 6520 3d20 7069 6563 655f 6c65   base = piece_le
    │ │ │ +00056aa0: 7665 6c73 2829 3b0a 0a3c 6469 7620 7374  vels();..
    ..for (in │ │ │ +00056ae0: 7420 6c61 7965 725f 7369 7a65 203d 206c t layer_size = l │ │ │ +00056af0: 6561 665f 636f 756e 743b 206c 6179 6572 eaf_count; layer │ │ │ +00056b00: 5f73 697a 6520 213d 2030 3b20 6c61 7965 _size != 0; laye │ │ │ +00056b10: 725f 7369 7a65 202f 3d20 3229 0a3c 2f64 r_size /= 2)...{....for (i │ │ │ +00056b30: 6e74 2069 203d 2030 3b20 6920 266c 743b nt i = 0; i < │ │ │ +00056b40: 206c 6179 6572 5f73 697a 653b 202b 2b69 layer_size; ++i │ │ │ +00056b50: 290a 0909 097b 0a09 0909 0969 6e74 2063 )....{.....int c │ │ │ +00056b60: 6f6e 7374 2064 7374 5f69 6478 203d 2064 onst dst_idx = d │ │ │ +00056b70: 6573 745f 6375 7273 6f72 202b 2069 3b0a est_cursor + i;. │ │ │ +00056b80: 0909 0909 696e 7420 636f 6e73 7420 7372 ....int const sr │ │ │ +00056b90: 635f 6964 7820 3d20 736f 7572 6365 5f63 c_idx = source_c │ │ │ +00056ba0: 7572 736f 7220 2b20 693b 0a09 0909 0969 ursor + i;.....i │ │ │ +00056bb0: 6620 2868 6173 5f6e 6f64 6528 6473 745f f (has_node(dst_ │ │ │ +00056bc0: 6964 7829 290a 0909 0909 7b0a 0909 0909 idx)).....{..... │ │ │ +00056bd0: 0969 6620 286d 5f74 7265 655b 6473 745f .if (m_tree[dst_ │ │ │ +00056be0: 6964 785d 2021 3d20 7472 6565 5b73 7263 idx] != tree[src │ │ │ +00056bf0: 5f69 6478 5d29 0a09 0909 0909 7b0a 0909 _idx])......{... │ │ │ +00056c00: 0909 0909 2f2f 2074 6869 7320 6d75 7374 ....// this must │ │ │ +00056c10: 2062 6520 6120 626c 6f63 6b20 6861 7368 be a block hash │ │ │ +00056c20: 2062 6563 6175 7365 2069 6e6e 6572 206e because inner n │ │ │ +00056c30: 6f64 6573 2061 7265 206e 6f74 2066 696c odes are not fil │ │ │ +00056c40: 6c65 6420 696e 2075 6e74 696c 0a09 0909 led in until.... │ │ │ +00056c50: 0909 092f 2f20 7468 6579 2063 616e 2062 ...// they can b │ │ │ +00056c60: 6520 7665 7269 6669 6564 2e20 5468 6973 e verified. This │ │ │ +00056c70: 2061 7373 6572 7420 656e 7375 7265 7320 assert ensures │ │ │ +00056c80: 7765 2772 6520 6174 2074 6865 0a09 0909 we're at the.... │ │ │ +00056c90: 0909 092f 2f20 6c65 6166 206c 6179 6572 ...// leaf layer │ │ │ +00056ca0: 206f 6620 7468 6520 6669 6c65 2074 7265 of the file tre │ │ │ +00056cb0: 650a 0909 0909 0909 544f 5252 454e 545f e.......TORRENT_ │ │ │ +00056cc0: 4153 5345 5254 2864 7374 5f69 6478 2026 ASSERT(dst_idx & │ │ │ +00056cd0: 6774 3b3d 2066 6972 7374 5f6c 6561 6629 gt;= first_leaf) │ │ │ +00056ce0: 3b0a 0a09 0909 0909 0969 6e74 2063 6f6e ;........int con │ │ │ +00056cf0: 7374 2070 6f73 203d 2064 7374 5f69 6478 st pos = dst_idx │ │ │ +00056d00: 202d 2066 6972 7374 5f6c 6561 663b 0a09 - first_leaf;.. │ │ │ +00056d10: 0909 0909 0961 7574 6f20 636f 6e73 7420 .....auto const │ │ │ +00056d20: 7069 6563 6520 3d20 7069 6563 655f 696e piece = piece_in │ │ │ +00056d30: 6465 785f 747b 706f 7320 2667 743b 2667 dex_t{pos >&g │ │ │ +00056d40: 743b 206d 5f62 6c6f 636b 735f 7065 725f t; m_blocks_per_ │ │ │ +00056d50: 7069 6563 655f 6c6f 677d 202b 2066 696c piece_log} + fil │ │ │ +00056d60: 655f 7069 6563 655f 6f66 6673 6574 3b0a e_piece_offset;. │ │ │ +00056d70: 0909 0909 0909 696e 7420 636f 6e73 7420 ......int const │ │ │ +00056d80: 626c 6f63 6b20 3d20 706f 7320 2661 6d70 block = pos & │ │ │ +00056d90: 3b20 2828 3120 266c 743b 266c 743b 206d ; ((1 << m │ │ │ +00056da0: 5f62 6c6f 636b 735f 7065 725f 7069 6563 _blocks_per_piec │ │ │ +00056db0: 655f 6c6f 6729 202d 2031 293b 0a0a 0909 e_log) - 1);.... │ │ │ +00056dc0: 0909 0909 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ +00056dd0: 5254 2870 6f73 2026 6c74 3b20 6d5f 6e75 RT(pos < m_nu │ │ │ +00056de0: 6d5f 626c 6f63 6b73 293b 0a09 0909 0909 m_blocks);...... │ │ │ +00056df0: 0969 6620 2821 7265 742e 6661 696c 6564 .if (!ret.failed │ │ │ +00056e00: 2e65 6d70 7479 2829 2026 616d 703b 2661 .empty() &&a │ │ │ +00056e10: 6d70 3b20 7265 742e 6661 696c 6564 2e62 mp; ret.failed.b │ │ │ +00056e20: 6163 6b28 292e 6669 7273 7420 3d3d 2070 ack().first == p │ │ │ +00056e30: 6965 6365 290a 0909 0909 0909 0972 6574 iece)........ret │ │ │ +00056e40: 2e66 6169 6c65 642e 6261 636b 2829 2e73 .failed.back().s │ │ │ +00056e50: 6563 6f6e 642e 7075 7368 5f62 6163 6b28 econd.push_back( │ │ │ +00056e60: 626c 6f63 6b29 3b0a 0909 0909 0909 656c block);.......el │ │ │ +00056e70: 7365 0a09 0909 0909 0909 7265 742e 6661 se........ret.fa │ │ │ +00056e80: 696c 6564 2e65 6d70 6c61 6365 5f62 6163 iled.emplace_bac │ │ │ +00056e90: 6b28 7069 6563 652c 2073 7464 3a3a 7665 k(piece, std::ve │ │ │ +00056ea0: 6374 6f72 266c 743b 696e 7426 6774 3b7b ctor<int>{ │ │ │ +00056eb0: 626c 6f63 6b7d 293b 0a0a 0909 0909 0909 block});........ │ │ │ +00056ec0: 2f2f 206e 6f77 2074 6861 7420 7468 6973 // now that this │ │ │ +00056ed0: 2068 6173 6820 6861 7320 6265 656e 2072 hash has been r │ │ │ +00056ee0: 6570 6f72 7465 6420 6173 2066 6169 6c69 eported as faili │ │ │ +00056ef0: 6e67 2c20 7765 0a09 0909 0909 092f 2f20 ng, we.......// │ │ │ +00056f00: 6361 6e20 636c 6561 7220 6974 2e20 5468 can clear it. Th │ │ │ +00056f10: 6973 2077 696c 6c20 7072 6576 656e 7420 is will prevent │ │ │ +00056f20: 6974 2066 726f 6d20 6265 696e 670a 0909 it from being... │ │ │ +00056f30: 0909 0909 2f2f 2072 6570 6f72 7465 6420 ....// reported │ │ │ +00056f40: 6173 2066 6169 6c69 6e67 2061 6761 696e as failing again │ │ │ +00056f50: 2e0a 0909 0909 0909 6d5f 7472 6565 5b64 ........m_tree[d │ │ │ +00056f60: 7374 5f69 6478 5d2e 636c 6561 7228 293b st_idx].clear(); │ │ │ +00056f70: 0a09 0909 0909 7d0a 0909 0909 0965 6c73 ......}......els │ │ │ +00056f80: 6520 6966 2028 6473 745f 6964 7820 2667 e if (dst_idx &g │ │ │ +00056f90: 743b 3d20 6669 7273 745f 6c65 6166 290a t;= first_leaf). │ │ │ +00056fa0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +00056fb0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00056fe0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +00057010: 632f 6d65 726b 6c65 5f74 7265 652e 6370 c/merkle_tree.cp │ │ │ +00057020: 703a 3435 373c 2f61 3e3c 2f74 643e 3c74 p:457instead of ove │ │ │ +00057040: 7277 7269 7469 6e67 2074 6865 2072 6f6f rwriting the roo │ │ │ +00057050: 7420 616e 6420 636f 6d70 6172 696e 6720 t and comparing │ │ │ +00057060: 6974 2061 6761 696e 7374 2068 6173 6865 it against hashe │ │ │ +00057070: 735b 5d2c 2077 7269 7465 2061 2066 756e s[], write a fun │ │ │ +00057080: 6374 696f 6e73 2074 6861 7420 2a76 616c ctions that *val │ │ │ +00057090: 6964 6174 6573 2a20 6120 7472 6565 2062 idates* a tree b │ │ │ +000570a0: 7920 6a75 7374 2066 696c 6c69 6e67 2069 y just filling i │ │ │ +000570b0: 7420 7570 2074 6f20 7468 6520 6c65 7665 t up to the leve │ │ │ +000570c0: 6c20 6265 6c6f 7720 7468 6520 726f 6f74 l below the root │ │ │ +000570d0: 2061 6e64 2074 6865 6e20 7661 6c69 6461 and then valida │ │ │ +000570e0: 7465 7320 6974 2e3c 2f74 643e 3c2f 7472 tes it.

    instead of │ │ │ +00057140: 6f76 6572 7772 6974 696e 6720 7468 6520 overwriting the │ │ │ +00057150: 726f 6f74 2061 6e64 2063 6f6d 7061 7269 root and compari │ │ │ +00057160: 6e67 2069 740a 6167 6169 6e73 7420 6861 ng it.against ha │ │ │ +00057170: 7368 6573 5b5d 2c20 7772 6974 6520 6120 shes[], write a │ │ │ +00057180: 6675 6e63 7469 6f6e 7320 7468 6174 202a functions that * │ │ │ +00057190: 7661 6c69 6461 7465 732a 2061 2074 7265 validates* a tre │ │ │ +000571a0: 650a 6279 206a 7573 7420 6669 6c6c 696e e.by just fillin │ │ │ +000571b0: 6720 6974 2075 7020 746f 2074 6865 206c g it up to the l │ │ │ +000571c0: 6576 656c 2062 656c 6f77 2074 6865 2072 evel below the r │ │ │ +000571d0: 6f6f 7420 616e 6420 7468 656e 0a76 616c oot and then.val │ │ │ +000571e0: 6964 6174 6573 2069 742e 3c2f 6832 3e3c idates it.

    < │ │ │ +000571f0: 6834 3e2e 2e2f 7372 632f 6d65 726b 6c65 h4>../src/merkle │ │ │ +00057200: 5f74 7265 652e 6370 703a 3435 373c 2f68 _tree.cpp:457
    ...&
    │ │ │ +00057250: 616d 703b 2661 6d70 3b20 6465 7374 5f73  amp;& dest_s
    │ │ │ +00057260: 7461 7274 5f69 6478 2026 6c74 3b20 6669  tart_idx < fi
    │ │ │ +00057270: 7273 745f 7069 6563 655f 6964 7820 2b20  rst_piece_idx + 
    │ │ │ +00057280: 6e75 6d5f 7069 6563 6573 2829 290a 0909  num_pieces())...
    │ │ │ +00057290: 7b0a 0909 0969 6e74 2063 6f6e 7374 2062  {....int const b
    │ │ │ +000572a0: 6c6f 636b 735f 696e 5f70 6965 6365 203d  locks_in_piece =
    │ │ │ +000572b0: 2031 2026 6c74 3b26 6c74 3b20 6261 7365   1 << base
    │ │ │ +000572c0: 3b0a 0a09 0909 2f2f 2069 7420 6d61 7920  ;.....// it may 
    │ │ │ +000572d0: 6e6f 7720 6265 2070 6f73 7369 626c 6520  now be possible 
    │ │ │ +000572e0: 746f 2076 6572 6966 7920 7468 6520 6861  to verify the ha
    │ │ │ +000572f0: 7368 6573 206f 6620 7072 6576 696f 7573  shes of previous
    │ │ │ +00057300: 6c79 2072 6563 6569 7665 6420 626c 6f63  ly received bloc
    │ │ │ +00057310: 6b73 0a09 0909 2f2f 2074 7279 2074 6f20  ks....// try to 
    │ │ │ +00057320: 7665 7269 6679 2061 7320 6d61 6e79 2063  verify as many c
    │ │ │ +00057330: 6869 6c64 206e 6f64 6573 206f 6620 7468  hild nodes of th
    │ │ │ +00057340: 6520 7265 6365 6976 6564 2068 6173 6865  e received hashe
    │ │ │ +00057350: 7320 6173 2070 6f73 7369 626c 650a 0909  s as possible...
    │ │ │ +00057360: 0966 6f72 2028 696e 7420 6920 3d20 303b  .for (int i = 0;
    │ │ │ +00057370: 2069 2026 6c74 3b20 696e 7428 6861 7368   i < int(hash
    │ │ │ +00057380: 6573 2e73 697a 6528 2929 3b20 2b2b 6929  es.size()); ++i)
    │ │ │ +00057390: 0a09 0909 7b0a 0909 0909 696e 7420 636f  ....{.....int co
    │ │ │ +000573a0: 6e73 7420 7069 6563 6520 3d20 6465 7374  nst piece = dest
    │ │ │ +000573b0: 5f73 7461 7274 5f69 6478 202b 2069 3b0a  _start_idx + i;.
    │ │ │ +000573c0: 0909 0909 6966 2028 7069 6563 6520 2d20  ....if (piece - 
    │ │ │ +000573d0: 6669 7273 745f 7069 6563 655f 6964 7820  first_piece_idx 
    │ │ │ +000573e0: 2667 743b 3d20 6e75 6d5f 7069 6563 6573  >= num_pieces
    │ │ │ +000573f0: 2829 290a 0909 0909 0962 7265 616b 3b0a  ())......break;.
    │ │ │ +00057400: 0909 0909 2f2f 2074 6865 2066 6972 7374  ....// the first
    │ │ │ +00057410: 2062 6c6f 636b 2069 6e20 7468 6973 2070   block in this p
    │ │ │ +00057420: 6965 6365 0a09 0909 0969 6e74 2063 6f6e  iece.....int con
    │ │ │ +00057430: 7374 2062 6c6f 636b 5f69 6478 203d 206d  st block_idx = m
    │ │ │ +00057440: 6572 6b6c 655f 6765 745f 6669 7273 745f  erkle_get_first_
    │ │ │ +00057450: 6368 696c 6428 7069 6563 652c 2062 6173  child(piece, bas
    │ │ │ +00057460: 6529 3b0a 0a09 0909 0969 6e74 2063 6f6e  e);......int con
    │ │ │ +00057470: 7374 2062 6c6f 636b 5f65 6e64 5f69 6478  st block_end_idx
    │ │ │ +00057480: 203d 2073 7464 3a3a 6d69 6e28 626c 6f63   = std::min(bloc
    │ │ │ +00057490: 6b5f 6964 7820 2b20 626c 6f63 6b73 5f69  k_idx + blocks_i
    │ │ │ +000574a0: 6e5f 7069 6563 652c 2066 6972 7374 5f6c  n_piece, first_l
    │ │ │ +000574b0: 6561 6620 2b20 6d5f 6e75 6d5f 626c 6f63  eaf + m_num_bloc
    │ │ │ +000574c0: 6b73 293b 0a09 0909 0969 6620 2873 7464  ks);.....if (std
    │ │ │ +000574d0: 3a3a 616e 795f 6f66 286d 5f74 7265 652e  ::any_of(m_tree.
    │ │ │ +000574e0: 6265 6769 6e28 2920 2b20 626c 6f63 6b5f  begin() + block_
    │ │ │ +000574f0: 6964 780a 0909 0909 092c 206d 5f74 7265  idx......, m_tre
    │ │ │ +00057500: 652e 6265 6769 6e28 2920 2b20 626c 6f63  e.begin() + bloc
    │ │ │ +00057510: 6b5f 656e 645f 6964 780a 0909 0909 092c  k_end_idx......,
    │ │ │ +00057520: 205b 5d28 7368 6132 3536 5f68 6173 6820   [](sha256_hash 
    │ │ │ +00057530: 636f 6e73 7426 616d 703b 2068 2920 7b20  const& h) { 
    │ │ │ +00057540: 7265 7475 726e 2068 2e69 735f 616c 6c5f  return h.is_all_
    │ │ │ +00057550: 7a65 726f 7328 293b 207d 2929 0a09 0909  zeros(); }))....
    │ │ │ +00057560: 0909 636f 6e74 696e 7565 3b0a 0a3c 6469  ..continue;......m
    │ │ │ +000575a0: 6572 6b6c 655f 6669 6c6c 5f74 7265 6528  erkle_fill_tree(
    │ │ │ +000575b0: 6d5f 7472 6565 2c20 626c 6f63 6b73 5f69  m_tree, blocks_i
    │ │ │ +000575c0: 6e5f 7069 6563 652c 2062 6c6f 636b 5f69  n_piece, block_i
    │ │ │ +000575d0: 6478 293b 0a3c 2f64 6976 3e09 0909 0969  dx);.....i
    │ │ │ +000575e0: 6620 286d 5f74 7265 655b 7069 6563 655d  f (m_tree[piece]
    │ │ │ +000575f0: 2021 3d20 6861 7368 6573 5b69 5d29 0a09   != hashes[i])..
    │ │ │ +00057600: 0909 097b 0a09 0909 0909 6d65 726b 6c65  ...{......merkle
    │ │ │ +00057610: 5f63 6c65 6172 5f74 7265 6528 6d5f 7472  _clear_tree(m_tr
    │ │ │ +00057620: 6565 2c20 626c 6f63 6b73 5f69 6e5f 7069  ee, blocks_in_pi
    │ │ │ +00057630: 6563 652c 2062 6c6f 636b 5f69 6478 293b  ece, block_idx);
    │ │ │ +00057640: 0a09 0909 0909 2f2f 2077 7269 7465 2062  ......// write b
    │ │ │ +00057650: 6163 6b20 7468 6520 636f 7272 6563 7420  ack the correct 
    │ │ │ +00057660: 6861 7368 0a09 0909 0909 6d5f 7472 6565  hash......m_tree
    │ │ │ +00057670: 5b70 6965 6365 5d20 3d20 6861 7368 6573  [piece] = hashes
    │ │ │ +00057680: 5b69 5d3b 0a09 0909 0909 544f 5252 454e  [i];......TORREN
    │ │ │ +00057690: 545f 4153 5345 5254 2862 6c6f 636b 735f  T_ASSERT(blocks_
    │ │ │ +000576a0: 696e 5f70 6965 6365 203d 3d20 626c 6f63  in_piece == bloc
    │ │ │ +000576b0: 6b73 5f70 6572 5f70 6965 6365 2829 293b  ks_per_piece());
    │ │ │ +000576c0: 0a0a 0909 0909 092f 2f20 616e 2065 6d70  .......// an emp
    │ │ │ +000576d0: 7479 2062 6c6f 636b 7320 7665 6374 6f72  ty blocks vector
    │ │ │ +000576e0: 2069 6e64 6963 6174 6573 2074 6861 7420   indicates that 
    │ │ │ +000576f0: 7765 2064 6f6e 2774 2068 6176 6520 7468  we don't have th
    │ │ │ +00057700: 650a 0909 0909 092f 2f20 626c 6f63 6b20  e......// block 
    │ │ │ +00057710: 6861 7368 6573 2c20 616e 6420 7765 2063  hashes, and we c
    │ │ │ +00057720: 616e 2774 206b 6e6f 7720 7768 6963 6820  an't know which 
    │ │ │ +00057730: 626c 6f63 6b20 6661 696c 6564 0a09 0909  block failed....
    │ │ │ +00057740: 0909 2f2f 2074 6869 7320 7769 6c6c 2063  ..// this will c
    │ │ │ +00057750: 6175 7365 2074 6865 2062 6c6f 636b 2068  ause the block h
    │ │ │ +00057760: 6173 6865 7320 746f 2062 6520 7265 7175  ashes to be requ
    │ │ │ +00057770: 6573 7465 640a 0909 0909 0972 6574 2e66  ested......ret.f
    │ │ │ +00057780: 6169 6c65 642e 656d 706c 6163 655f 6261  ailed.emplace_ba
    │ │ │ +00057790: 636b 2870 6965 6365 5f69 6e64 6578 5f74  ck(piece_index_t
    │ │ │ +000577a0: 7b70 6965 6365 202d 2066 6972 7374 5f70  {piece - first_p
    │ │ │ +000577b0: 6965 6365 5f69 6478 7d20 2b20 6669 6c65  iece_idx} + file
    │ │ │ +000577c0: 5f70 6965 6365 5f6f 6666 7365 740a 0909  _piece_offset...
    │ │ │ +000577d0: 0909 0909 2c20 7374 643a 3a76 6563 746f  ...., std::vecto
    │ │ │ +000577e0: 7226 6c74 3b69 6e74 2667 743b 2829 293b  r<int>());
    │ │ │ +000577f0: 0a09 0909 097d 0a09 0909 0965 6c73 650a  .....}.....else.
    │ │ │ +00057800: 0909 0909 7b0a 0909 0909 0972 6574 2e70  ....{......ret.p
    │ │ │ +00057810: 6173 7365 642e 7075 7368 5f62 6163 6b28  assed.push_back(
    │ │ │ +00057820: 7069 6563 655f 696e 6465 785f 747b 7069  piece_index_t{pi
    │ │ │ +00057830: 6563 6520 2d20 6669 7273 745f 7069 6563  ece - first_piec
    │ │ │ +00057840: 655f 6964 787d 202b 2066 696c 655f 7069  e_idx} + file_pi
    │ │ │ +00057850: 6563 655f 6f66 6673 6574 293b 0a09 0909  ece_offset);....
    │ │ │ +00057860: 0909 2f2f 2072 6563 6f72 6420 7468 6174  ..// record that
    │ │ │ +00057870: 2074 6865 7365 2062 6c6f 636b 2068 6173   these block has
    │ │ │ +00057880: 6865 7320 6172 6520 636f 7272 6563 7421  hes are correct!
    │ │ │ +00057890: 0a09 0909 0909 696e 7420 636f 6e73 7420  ......int const 
    │ │ │ +000578a0: 6c65 6166 735f 7374 6172 7420 3d20 626c  leafs_start = bl
    │ │ │ +000578b0: 6f63 6b5f 6964 7820 2d20 626c 6f63 6b5f  ock_idx - block_
    │ │ │ +000578c0: 6c61 7965 725f 7374 6172 7428 293b 0a09  layer_start();..
    │ │ │ +000578d0: 0909 0909 696e 7420 636f 6e73 7420 6c65  ....int const le
    │ │ │ +000578e0: 6166 735f 656e 6420 3d20 7374 643a 3a6d  afs_end = std::m
    │ │ │ +000578f0: 696e 286d 5f6e 756d 5f62 6c6f 636b 732c  in(m_num_blocks,
    │ │ │ +00057900: 206c 6561 6673 5f73 7461 7274 202b 2062   leafs_start + b
    │ │ │ +00057910: 6c6f 636b 735f 696e 5f70 6965 6365 293b  locks_in_piece);
    │ │ │ +00057920: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472  .
    relevance  │ │ │ +00057960: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +00057990: 7263 2f6d 6572 6b6c 655f 7472 6565 2e63 rc/merkle_tree.c │ │ │ +000579a0: 7070 3a34 3831 3c2f 613e 3c2f 7464 3e3c pp:481< │ │ │ +000579b0: 7464 3e74 6869 7320 636f 756c 6420 6265 td>this could be │ │ │ +000579c0: 2064 6f6e 6520 6d6f 7265 2065 6666 6963 done more effic │ │ │ +000579d0: 6965 6e74 6c79 2069 6620 6269 7466 6965 iently if bitfie │ │ │ +000579e0: 6c64 2068 6164 2061 2066 756e 6374 696f ld had a functio │ │ │ +000579f0: 6e20 746f 2073 6574 2061 2072 616e 6765 n to set a range │ │ │ +00057a00: 206f 6620 6269 7473 3c2f 7464 3e3c 2f74 of bits

    this could │ │ │ +00057a60: 2062 6520 646f 6e65 206d 6f72 6520 6566 be done more ef │ │ │ +00057a70: 6669 6369 656e 746c 7920 6966 2062 6974 ficiently if bit │ │ │ +00057a80: 6669 656c 6420 6861 6420 6120 6675 6e63 field had a func │ │ │ +00057a90: 7469 6f6e 0a74 6f20 7365 7420 6120 7261 tion.to set a ra │ │ │ +00057aa0: 6e67 6520 6f66 2062 6974 733c 2f68 323e nge of bits

    │ │ │ +00057ab0: 3c68 343e 2e2e 2f73 7263 2f6d 6572 6b6c

    ../src/merkl │ │ │ +00057ac0: 655f 7472 6565 2e63 7070 3a34 3831 3c2f e_tree.cpp:481
    ...
    │ │ │ +00057b10: 096d 6572 6b6c 655f 6669 6c6c 5f74 7265  .merkle_fill_tre
    │ │ │ +00057b20: 6528 6d5f 7472 6565 2c20 626c 6f63 6b73  e(m_tree, blocks
    │ │ │ +00057b30: 5f69 6e5f 7069 6563 652c 2062 6c6f 636b  _in_piece, block
    │ │ │ +00057b40: 5f69 6478 293b 0a09 0909 0969 6620 286d  _idx);.....if (m
    │ │ │ +00057b50: 5f74 7265 655b 7069 6563 655d 2021 3d20  _tree[piece] != 
    │ │ │ +00057b60: 6861 7368 6573 5b69 5d29 0a09 0909 097b  hashes[i]).....{
    │ │ │ +00057b70: 0a09 0909 0909 6d65 726b 6c65 5f63 6c65  ......merkle_cle
    │ │ │ +00057b80: 6172 5f74 7265 6528 6d5f 7472 6565 2c20  ar_tree(m_tree, 
    │ │ │ +00057b90: 626c 6f63 6b73 5f69 6e5f 7069 6563 652c  blocks_in_piece,
    │ │ │ +00057ba0: 2062 6c6f 636b 5f69 6478 293b 0a09 0909   block_idx);....
    │ │ │ +00057bb0: 0909 2f2f 2077 7269 7465 2062 6163 6b20  ..// write back 
    │ │ │ +00057bc0: 7468 6520 636f 7272 6563 7420 6861 7368  the correct hash
    │ │ │ +00057bd0: 0a09 0909 0909 6d5f 7472 6565 5b70 6965  ......m_tree[pie
    │ │ │ +00057be0: 6365 5d20 3d20 6861 7368 6573 5b69 5d3b  ce] = hashes[i];
    │ │ │ +00057bf0: 0a09 0909 0909 544f 5252 454e 545f 4153  ......TORRENT_AS
    │ │ │ +00057c00: 5345 5254 2862 6c6f 636b 735f 696e 5f70  SERT(blocks_in_p
    │ │ │ +00057c10: 6965 6365 203d 3d20 626c 6f63 6b73 5f70  iece == blocks_p
    │ │ │ +00057c20: 6572 5f70 6965 6365 2829 293b 0a0a 0909  er_piece());....
    │ │ │ +00057c30: 0909 092f 2f20 616e 2065 6d70 7479 2062  ...// an empty b
    │ │ │ +00057c40: 6c6f 636b 7320 7665 6374 6f72 2069 6e64  locks vector ind
    │ │ │ +00057c50: 6963 6174 6573 2074 6861 7420 7765 2064  icates that we d
    │ │ │ +00057c60: 6f6e 2774 2068 6176 6520 7468 650a 0909  on't have the...
    │ │ │ +00057c70: 0909 092f 2f20 626c 6f63 6b20 6861 7368  ...// block hash
    │ │ │ +00057c80: 6573 2c20 616e 6420 7765 2063 616e 2774  es, and we can't
    │ │ │ +00057c90: 206b 6e6f 7720 7768 6963 6820 626c 6f63   know which bloc
    │ │ │ +00057ca0: 6b20 6661 696c 6564 0a09 0909 0909 2f2f  k failed......//
    │ │ │ +00057cb0: 2074 6869 7320 7769 6c6c 2063 6175 7365   this will cause
    │ │ │ +00057cc0: 2074 6865 2062 6c6f 636b 2068 6173 6865   the block hashe
    │ │ │ +00057cd0: 7320 746f 2062 6520 7265 7175 6573 7465  s to be requeste
    │ │ │ +00057ce0: 640a 0909 0909 0972 6574 2e66 6169 6c65  d......ret.faile
    │ │ │ +00057cf0: 642e 656d 706c 6163 655f 6261 636b 2870  d.emplace_back(p
    │ │ │ +00057d00: 6965 6365 5f69 6e64 6578 5f74 7b70 6965  iece_index_t{pie
    │ │ │ +00057d10: 6365 202d 2066 6972 7374 5f70 6965 6365  ce - first_piece
    │ │ │ +00057d20: 5f69 6478 7d20 2b20 6669 6c65 5f70 6965  _idx} + file_pie
    │ │ │ +00057d30: 6365 5f6f 6666 7365 740a 0909 0909 0909  ce_offset.......
    │ │ │ +00057d40: 2c20 7374 643a 3a76 6563 746f 7226 6c74  , std::vector<
    │ │ │ +00057d50: 3b69 6e74 2667 743b 2829 293b 0a09 0909  ;int>());....
    │ │ │ +00057d60: 097d 0a09 0909 0965 6c73 650a 0909 0909  .}.....else.....
    │ │ │ +00057d70: 7b0a 0909 0909 0972 6574 2e70 6173 7365  {......ret.passe
    │ │ │ +00057d80: 642e 7075 7368 5f62 6163 6b28 7069 6563  d.push_back(piec
    │ │ │ +00057d90: 655f 696e 6465 785f 747b 7069 6563 6520  e_index_t{piece 
    │ │ │ +00057da0: 2d20 6669 7273 745f 7069 6563 655f 6964  - first_piece_id
    │ │ │ +00057db0: 787d 202b 2066 696c 655f 7069 6563 655f  x} + file_piece_
    │ │ │ +00057dc0: 6f66 6673 6574 293b 0a09 0909 0909 2f2f  offset);......//
    │ │ │ +00057dd0: 2072 6563 6f72 6420 7468 6174 2074 6865   record that the
    │ │ │ +00057de0: 7365 2062 6c6f 636b 2068 6173 6865 7320  se block hashes 
    │ │ │ +00057df0: 6172 6520 636f 7272 6563 7421 0a09 0909  are correct!....
    │ │ │ +00057e00: 0909 696e 7420 636f 6e73 7420 6c65 6166  ..int const leaf
    │ │ │ +00057e10: 735f 7374 6172 7420 3d20 626c 6f63 6b5f  s_start = block_
    │ │ │ +00057e20: 6964 7820 2d20 626c 6f63 6b5f 6c61 7965  idx - block_laye
    │ │ │ +00057e30: 725f 7374 6172 7428 293b 0a09 0909 0909  r_start();......
    │ │ │ +00057e40: 696e 7420 636f 6e73 7420 6c65 6166 735f  int const leafs_
    │ │ │ +00057e50: 656e 6420 3d20 7374 643a 3a6d 696e 286d  end = std::min(m
    │ │ │ +00057e60: 5f6e 756d 5f62 6c6f 636b 732c 206c 6561  _num_blocks, lea
    │ │ │ +00057e70: 6673 5f73 7461 7274 202b 2062 6c6f 636b  fs_start + block
    │ │ │ +00057e80: 735f 696e 5f70 6965 6365 293b 0a3c 6469  s_in_piece);......
    │ │ │ +00057ec0: 666f 7220 2869 6e74 206b 203d 206c 6561  for (int k = lea
    │ │ │ +00057ed0: 6673 5f73 7461 7274 3b20 6b20 266c 743b  fs_start; k <
    │ │ │ +00057ee0: 206c 6561 6673 5f65 6e64 3b20 2b2b 6b29   leafs_end; ++k)
    │ │ │ +00057ef0: 0a3c 2f64 6976 3e09 0909 0909 096d 5f62  .......m_b
    │ │ │ +00057f00: 6c6f 636b 5f76 6572 6966 6965 642e 7365  lock_verified.se
    │ │ │ +00057f10: 745f 6269 7428 6b29 3b0a 0909 0909 7d0a  t_bit(k);.....}.
    │ │ │ +00057f20: 0909 0909 544f 5252 454e 545f 4153 5345  ....TORRENT_ASSE
    │ │ │ +00057f30: 5254 2828 7069 6563 6520 2d20 6669 7273  RT((piece - firs
    │ │ │ +00057f40: 745f 7069 6563 655f 6964 7829 2026 6774  t_piece_idx) >
    │ │ │ +00057f50: 3b3d 2030 293b 0a09 0909 7d0a 0909 7d0a  ;= 0);....}...}.
    │ │ │ +00057f60: 0a09 096f 7074 696d 697a 655f 7374 6f72  ...optimize_stor
    │ │ │ +00057f70: 6167 6528 293b 0a0a 0909 7265 7475 726e  age();....return
    │ │ │ +00057f80: 2072 6574 3b0a 097d 0a0a 0973 7464 3a3a   ret;..}...std::
    │ │ │ +00057f90: 7475 706c 6526 6c74 3b6d 6572 6b6c 655f  tuple<merkle_
    │ │ │ +00057fa0: 7472 6565 3a3a 7365 745f 626c 6f63 6b5f  tree::set_block_
    │ │ │ +00057fb0: 7265 7375 6c74 2c20 696e 742c 2069 6e74  result, int, int
    │ │ │ +00057fc0: 2667 743b 206d 6572 6b6c 655f 7472 6565  > merkle_tree
    │ │ │ +00057fd0: 3a3a 7365 745f 626c 6f63 6b28 696e 7420  ::set_block(int 
    │ │ │ +00057fe0: 636f 6e73 7420 626c 6f63 6b5f 696e 6465  const block_inde
    │ │ │ +00057ff0: 780a 0909 2c20 7368 6132 3536 5f68 6173  x..., sha256_has
    │ │ │ +00058000: 6820 636f 6e73 7426 616d 703b 2068 290a  h const& h).
    │ │ │ +00058010: 097b 0a23 6966 6465 6620 544f 5252 454e  .{.#ifdef TORREN
    │ │ │ +00058020: 545f 4558 5045 4e53 4956 455f 494e 5641  T_EXPENSIVE_INVA
    │ │ │ +00058030: 5249 414e 545f 4348 4543 4b53 0a09 0949  RIANT_CHECKS...I
    │ │ │ +00058040: 4e56 4152 4941 4e54 5f43 4845 434b 3b0a  NVARIANT_CHECK;.
    │ │ │ +00058050: 2365 6e64 6966 0a09 0954 4f52 5245 4e54  #endif...TORRENT
    │ │ │ +00058060: 5f41 5353 4552 5428 626c 6f63 6b5f 696e  _ASSERT(block_in
    │ │ │ +00058070: 6465 7820 266c 743b 206d 5f6e 756d 5f62  dex < m_num_b
    │ │ │ +00058080: 6c6f 636b 7329 3b0a 0a09 0961 7574 6f20  locks);....auto 
    │ │ │ +00058090: 636f 6e73 7420 6e75 6d5f 6c65 6166 7320  const num_leafs 
    │ │ │ +000580a0: 3d20 6d65 726b 6c65 5f6e 756d 5f6c 6561  = merkle_num_lea
    │ │ │ +000580b0: 6673 286d 5f6e 756d 5f62 6c6f 636b 7329  fs(m_num_blocks)
    │ │ │ +000580c0: 3b0a 0909 6175 746f 2063 6f6e 7374 2066  ;...auto const f
    │ │ │ +000580d0: 6972 7374 5f6c 6561 6620 3d20 6d65 726b  irst_leaf = merk
    │ │ │ +000580e0: 6c65 5f66 6972 7374 5f6c 6561 6628 6e75  le_first_leaf(nu
    │ │ │ +000580f0: 6d5f 6c65 6166 7329 3b0a 0909 6175 746f  m_leafs);...auto
    │ │ │ +00058100: 2063 6f6e 7374 2062 6c6f 636b 5f74 7265   const block_tre
    │ │ │ +00058110: 655f 696e 6465 7820 3d20 6669 7273 745f  e_index = first_
    │ │ │ +00058120: 6c65 6166 202b 2062 6c6f 636b 5f69 6e64  leaf + block_ind
    │ │ │ +00058130: 6578 3b0a 0a09 0969 6620 2862 6c6f 636b  ex;....if (block
    │ │ │ +00058140: 735f 7665 7269 6669 6564 2862 6c6f 636b  s_verified(block
    │ │ │ +00058150: 5f69 6e64 6578 2c20 3129 290a 0909 7b0a  _index, 1))...{.
    │ │ │ +00058160: 0909 092f 2f20 6966 2074 6869 7320 626c  ...// if this bl
    │ │ │ +00058170: 6f63 6b73 2773 2068 6173 6820 6973 2061  ocks's hash is a
    │ │ │ +00058180: 6c72 6561 6479 206b 6e6f 776e 2c20 6368  lready known, ch
    │ │ │ +00058190: 6563 6b20 7468 6520 7061 7373 6564 2d69  eck the passed-i
    │ │ │ +000581a0: 6e20 6861 7368 2061 6761 696e 7374 2069  n hash against i
    │ │ │ +000581b0: 740a 0909 0969 6620 2863 6f6d 7061 7265  t....if (compare
    │ │ │ +000581c0: 5f6e 6f64 6528 626c 6f63 6b5f 7472 6565  _node(block_tree
    │ │ │ +000581d0: 5f69 6e64 6578 2c20 6829 290a 0909 0909  _index, h)).....
    │ │ │ +000581e0: 7265 7475 726e 2073 7464 3a3a 6d61 6b65  return std::make
    │ │ │ +000581f0: 5f74 7570 6c65 2873 6574 5f62 6c6f 636b  _tuple(set_block
    │ │ │ +00058200: 5f72 6573 756c 743a 3a6f 6b2c 2062 6c6f  _result::ok, blo
    │ │ │ +00058210: 636b 5f69 6e64 6578 2c20 3129 3b0a 0909  ck_index, 1);...
    │ │ │ +00058220: 0965 6c73 650a 0909 0909 7265 7475 726e  .else.....return
    │ │ │ +00058230: 2073 7464 3a3a 6d61 6b65 5f74 7570 6c65   std::make_tuple
    │ │ │ +00058240: 2873 6574 5f62 6c6f 636b 5f72 6573 756c  (set_block_resul
    │ │ │ +00058250: 743a 3a62 6c6f 636b 5f68 6173 685f 6661  t::block_hash_fa
    │ │ │ +00058260: 696c 6564 2c20 626c 6f63 6b5f 696e 6465  iled, block_inde
    │ │ │ +00058270: 782c 2031 293b 0a3c 2f70 7265 3e3c 2f74  x, 1);.
    relevanc │ │ │ +000582b0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/merkle_ │ │ │ +000582f0: 7472 6565 2e63 7070 3a35 3234 3c2f 613e tree.cpp:524 │ │ │ +00058300: 3c2f 7464 3e3c 7464 3e75 7365 2073 7472 use str │ │ │ +00058310: 7563 7475 7265 6420 6269 6e64 696e 6720 uctured binding │ │ │ +00058320: 696e 2043 2b2b 3137 3c2f 7464 3e3c 2f74 in C++17

    use struct │ │ │ +00058380: 7572 6564 2062 696e 6469 6e67 2069 6e20 ured binding in │ │ │ +00058390: 432b 2b31 373c 2f68 323e 3c68 343e 2e2e C++17

    .. │ │ │ +000583a0: 2f73 7263 2f6d 6572 6b6c 655f 7472 6565 /src/merkle_tree │ │ │ +000583b0: 2e63 7070 3a35 3234 3c2f 6834 3e3c 7072 .cpp:524

    ..auto co │ │ │ +00058400: 6e73 7420 6669 7273 745f 6c65 6166 203d nst first_leaf = │ │ │ +00058410: 206d 6572 6b6c 655f 6669 7273 745f 6c65 merkle_first_le │ │ │ +00058420: 6166 286e 756d 5f6c 6561 6673 293b 0a09 af(num_leafs);.. │ │ │ +00058430: 0961 7574 6f20 636f 6e73 7420 626c 6f63 .auto const bloc │ │ │ +00058440: 6b5f 7472 6565 5f69 6e64 6578 203d 2066 k_tree_index = f │ │ │ +00058450: 6972 7374 5f6c 6561 6620 2b20 626c 6f63 irst_leaf + bloc │ │ │ +00058460: 6b5f 696e 6465 783b 0a0a 0909 6966 2028 k_index;....if ( │ │ │ +00058470: 626c 6f63 6b73 5f76 6572 6966 6965 6428 blocks_verified( │ │ │ +00058480: 626c 6f63 6b5f 696e 6465 782c 2031 2929 block_index, 1)) │ │ │ +00058490: 0a09 097b 0a09 0909 2f2f 2069 6620 7468 ...{....// if th │ │ │ +000584a0: 6973 2062 6c6f 636b 7327 7320 6861 7368 is blocks's hash │ │ │ +000584b0: 2069 7320 616c 7265 6164 7920 6b6e 6f77 is already know │ │ │ +000584c0: 6e2c 2063 6865 636b 2074 6865 2070 6173 n, check the pas │ │ │ +000584d0: 7365 642d 696e 2068 6173 6820 6167 6169 sed-in hash agai │ │ │ +000584e0: 6e73 7420 6974 0a09 0909 6966 2028 636f nst it....if (co │ │ │ +000584f0: 6d70 6172 655f 6e6f 6465 2862 6c6f 636b mpare_node(block │ │ │ +00058500: 5f74 7265 655f 696e 6465 782c 2068 2929 _tree_index, h)) │ │ │ +00058510: 0a09 0909 0972 6574 7572 6e20 7374 643a .....return std: │ │ │ +00058520: 3a6d 616b 655f 7475 706c 6528 7365 745f :make_tuple(set_ │ │ │ +00058530: 626c 6f63 6b5f 7265 7375 6c74 3a3a 6f6b block_result::ok │ │ │ +00058540: 2c20 626c 6f63 6b5f 696e 6465 782c 2031 , block_index, 1 │ │ │ +00058550: 293b 0a09 0909 656c 7365 0a09 0909 0972 );....else.....r │ │ │ +00058560: 6574 7572 6e20 7374 643a 3a6d 616b 655f eturn std::make_ │ │ │ +00058570: 7475 706c 6528 7365 745f 626c 6f63 6b5f tuple(set_block_ │ │ │ +00058580: 7265 7375 6c74 3a3a 626c 6f63 6b5f 6861 result::block_ha │ │ │ +00058590: 7368 5f66 6169 6c65 642c 2062 6c6f 636b sh_failed, block │ │ │ +000585a0: 5f69 6e64 6578 2c20 3129 3b0a 0909 7d0a _index, 1);...}. │ │ │ +000585b0: 0a09 0961 6c6c 6f63 6174 655f 6675 6c6c ...allocate_full │ │ │ +000585c0: 2829 3b0a 0a09 096d 5f74 7265 655b 626c ();....m_tree[bl │ │ │ +000585d0: 6f63 6b5f 7472 6565 5f69 6e64 6578 5d20 ock_tree_index] │ │ │ +000585e0: 3d20 683b 0a0a 0909 2f2f 2074 6f20 6176 = h;....// to av │ │ │ +000585f0: 6f69 6420 7761 7374 696e 6720 6120 6c6f oid wasting a lo │ │ │ +00058600: 7420 6f66 2074 696d 6520 6861 7368 696e t of time hashin │ │ │ +00058610: 6720 6e6f 6465 7320 6f6e 6c79 2074 6f20 g nodes only to │ │ │ +00058620: 6469 7363 6f76 6572 2074 6865 790a 0909 discover they... │ │ │ +00058630: 2f2f 2063 616e 6e6f 7420 6265 2076 6572 // cannot be ver │ │ │ +00058640: 6966 6965 642c 2063 6865 636b 2066 6972 ified, check fir │ │ │ +00058650: 7374 2074 6f20 7365 6520 6966 2074 6865 st to see if the │ │ │ +00058660: 2072 6f6f 7420 6f66 2074 6865 206c 6172 root of the lar │ │ │ +00058670: 6765 7374 0a09 092f 2f20 636f 6d70 7574 gest...// comput │ │ │ +00058680: 6162 6c65 2073 7562 7472 6565 2069 7320 able subtree is │ │ │ +00058690: 6b6e 6f77 6e0a 0a3c 6469 7620 7374 796c known..
    ..int leafs │ │ │ +000586d0: 5f73 7461 7274 3b0a 3c2f 6469 763e 0909 _start;.
    .. │ │ │ +000586e0: 696e 7420 6c65 6166 735f 7369 7a65 3b0a int leafs_size;. │ │ │ +000586f0: 0909 696e 7420 726f 6f74 5f69 6e64 6578 ..int root_index │ │ │ +00058700: 3b0a 0909 7374 643a 3a74 6965 286c 6561 ;...std::tie(lea │ │ │ +00058710: 6673 5f73 7461 7274 2c20 6c65 6166 735f fs_start, leafs_ │ │ │ +00058720: 7369 7a65 2c20 726f 6f74 5f69 6e64 6578 size, root_index │ │ │ +00058730: 2920 3d0a 0909 096d 6572 6b6c 655f 6669 ) =....merkle_fi │ │ │ +00058740: 6e64 5f6b 6e6f 776e 5f73 7562 7472 6565 nd_known_subtree │ │ │ +00058750: 286d 5f74 7265 652c 2062 6c6f 636b 5f69 (m_tree, block_i │ │ │ +00058760: 6e64 6578 2c20 6d5f 6e75 6d5f 626c 6f63 ndex, m_num_bloc │ │ │ +00058770: 6b73 293b 0a0a 0909 2f2f 2069 6620 7468 ks);....// if th │ │ │ +00058780: 6520 726f 6f74 206e 6f64 6520 6973 2075 e root node is u │ │ │ +00058790: 6e6b 6e6f 776e 2074 6865 2068 6173 6865 nknown the hashe │ │ │ +000587a0: 7320 6361 6e6e 6f74 2062 6520 7665 7269 s cannot be veri │ │ │ +000587b0: 6669 6564 2079 6574 0a09 0969 6620 286d fied yet...if (m │ │ │ +000587c0: 5f74 7265 655b 726f 6f74 5f69 6e64 6578 _tree[root_index │ │ │ +000587d0: 5d2e 6973 5f61 6c6c 5f7a 6572 6f73 2829 ].is_all_zeros() │ │ │ +000587e0: 290a 0909 0972 6574 7572 6e20 7374 643a )....return std: │ │ │ +000587f0: 3a6d 616b 655f 7475 706c 6528 7365 745f :make_tuple(set_ │ │ │ +00058800: 626c 6f63 6b5f 7265 7375 6c74 3a3a 756e block_result::un │ │ │ +00058810: 6b6e 6f77 6e2c 206c 6561 6673 5f73 7461 known, leafs_sta │ │ │ +00058820: 7274 2c20 6c65 6166 735f 7369 7a65 293b rt, leafs_size); │ │ │ +00058830: 0a0a 0909 2f2f 2073 6176 6520 7468 6520 ....// save the │ │ │ +00058840: 726f 6f74 2068 6173 6820 6265 6361 7573 root hash becaus │ │ │ +00058850: 6520 6d65 726b 6c65 5f66 696c 6c5f 7472 e merkle_fill_tr │ │ │ +00058860: 6565 2077 696c 6c20 6f76 6572 7772 6974 ee will overwrit │ │ │ +00058870: 6520 6974 0a09 0973 6861 3235 365f 6861 e it...sha256_ha │ │ │ +00058880: 7368 2063 6f6e 7374 2072 6f6f 7420 3d20 sh const root = │ │ │ +00058890: 6d5f 7472 6565 5b72 6f6f 745f 696e 6465 m_tree[root_inde │ │ │ +000588a0: 785d 3b0a 0909 6d65 726b 6c65 5f66 696c x];...merkle_fil │ │ │ +000588b0: 6c5f 7472 6565 286d 5f74 7265 652c 206c l_tree(m_tree, l │ │ │ +000588c0: 6561 6673 5f73 697a 652c 2066 6972 7374 eafs_size, first │ │ │ +000588d0: 5f6c 6561 6620 2b20 6c65 6166 735f 7374 _leaf + leafs_st │ │ │ +000588e0: 6172 7429 3b0a 0a09 0969 6620 2872 6f6f art);....if (roo │ │ │ +000588f0: 7420 213d 206d 5f74 7265 655b 726f 6f74 t != m_tree[root │ │ │ +00058900: 5f69 6e64 6578 5d29 0a09 097b 0a09 0909 _index])...{.... │ │ │ +00058910: 2f2f 2068 6173 6820 6661 696c 7572 652c // hash failure, │ │ │ +00058920: 2063 6c65 6172 2061 6c6c 2074 6865 2069 clear all the i │ │ │ +00058930: 6e74 6572 6e61 6c20 6e6f 6465 730a 0909 nternal nodes... │ │ │ +00058940: 092f 2f20 7468 6520 7768 6f6c 6520 7069 .// the whole pi │ │ │ +00058950: 6563 6520 6661 696c 6564 2074 6865 2068 ece failed the h │ │ │ +00058960: 6173 6820 6368 6563 6b2e 2043 6c65 6172 ash check. Clear │ │ │ +00058970: 2061 6c6c 2062 6c6f 636b 2068 6173 6865 all block hashe │ │ │ +00058980: 730a 0909 092f 2f20 696e 2074 6869 7320 s....// in this │ │ │ +00058990: 7069 6563 6520 616e 6420 7265 706f 7274 piece and report │ │ │ +000589a0: 2061 2068 6173 6820 6661 696c 7572 650a a hash failure. │ │ │ +000589b0: 0909 096d 6572 6b6c 655f 636c 6561 725f ...merkle_clear_ │ │ │ +000589c0: 7472 6565 286d 5f74 7265 652c 206c 6561 tree(m_tree, lea │ │ │ +000589d0: 6673 5f73 697a 652c 2066 6972 7374 5f6c fs_size, first_l │ │ │ +000589e0: 6561 6620 2b20 6c65 6166 735f 7374 6172 eaf + leafs_star │ │ │ +000589f0: 7429 3b0a 0909 096d 5f74 7265 655b 726f t);....m_tree[ro │ │ │ +00058a00: 6f74 5f69 6e64 6578 5d20 3d20 726f 6f74 ot_index] = root │ │ │ +00058a10: 3b0a 0909 0972 6574 7572 6e20 7374 643a ;....return std: │ │ │ +00058a20: 3a6d 616b 655f 7475 706c 6528 7365 745f :make_tuple(set_ │ │ │ +00058a30: 626c 6f63 6b5f 7265 7375 6c74 3a3a 6861 block_result::ha │ │ │ +00058a40: 7368 5f66 6169 6c65 642c 206c 6561 6673 sh_failed, leafs │ │ │ +00058a50: 5f73 7461 7274 2c20 6c65 6166 735f 7369 _start, leafs_si │ │ │ +00058a60: 7a65 293b 0a09 097d 0a0a 3c2f 7072 653e ze);...}.. │ │ │ +00058a70: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +00058aa0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +00058ab0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/merk │ │ │ +00058ae0: 6c65 5f74 7265 652e 6370 703a 3534 393c le_tree.cpp:549< │ │ │ +00058af0: 2f61 3e3c 2f74 643e 3c74 643e 7468 6973 /a>this │ │ │ +00058b00: 2063 6f75 6c64 2062 6520 646f 6e65 206d could be done m │ │ │ +00058b10: 6f72 6520 6566 6669 6369 656e 746c 7920 ore efficiently │ │ │ +00058b20: 6966 2062 6974 6669 656c 6420 6861 6420 if bitfield had │ │ │ +00058b30: 6120 6675 6e63 7469 6f6e 2074 6f20 7365 a function to se │ │ │ +00058b40: 7420 6120 7261 6e67 6520 6f66 2062 6974 t a range of bit │ │ │ +00058b50: 733c 2f74 643e 3c2f 7472 3e3c 7472 2069 s

    t │ │ │ +00058ba0: 6869 7320 636f 756c 6420 6265 2064 6f6e his could be don │ │ │ +00058bb0: 6520 6d6f 7265 2065 6666 6963 6965 6e74 e more efficient │ │ │ +00058bc0: 6c79 2069 6620 6269 7466 6965 6c64 2068 ly if bitfield h │ │ │ +00058bd0: 6164 2061 2066 756e 6374 696f 6e0a 746f ad a function.to │ │ │ +00058be0: 2073 6574 2061 2072 616e 6765 206f 6620 set a range of │ │ │ +00058bf0: 6269 7473 3c2f 6832 3e3c 6834 3e2e 2e2f bits

    ../ │ │ │ +00058c00: 7372 632f 6d65 726b 6c65 5f74 7265 652e src/merkle_tree. │ │ │ +00058c10: 6370 703a 3534 393c 2f68 343e 3c70 7265 cpp:549

    ...merkle_
    │ │ │ +00058c60: 6669 6e64 5f6b 6e6f 776e 5f73 7562 7472  find_known_subtr
    │ │ │ +00058c70: 6565 286d 5f74 7265 652c 2062 6c6f 636b  ee(m_tree, block
    │ │ │ +00058c80: 5f69 6e64 6578 2c20 6d5f 6e75 6d5f 626c  _index, m_num_bl
    │ │ │ +00058c90: 6f63 6b73 293b 0a0a 0909 2f2f 2069 6620  ocks);....// if 
    │ │ │ +00058ca0: 7468 6520 726f 6f74 206e 6f64 6520 6973  the root node is
    │ │ │ +00058cb0: 2075 6e6b 6e6f 776e 2074 6865 2068 6173   unknown the has
    │ │ │ +00058cc0: 6865 7320 6361 6e6e 6f74 2062 6520 7665  hes cannot be ve
    │ │ │ +00058cd0: 7269 6669 6564 2079 6574 0a09 0969 6620  rified yet...if 
    │ │ │ +00058ce0: 286d 5f74 7265 655b 726f 6f74 5f69 6e64  (m_tree[root_ind
    │ │ │ +00058cf0: 6578 5d2e 6973 5f61 6c6c 5f7a 6572 6f73  ex].is_all_zeros
    │ │ │ +00058d00: 2829 290a 0909 0972 6574 7572 6e20 7374  ())....return st
    │ │ │ +00058d10: 643a 3a6d 616b 655f 7475 706c 6528 7365  d::make_tuple(se
    │ │ │ +00058d20: 745f 626c 6f63 6b5f 7265 7375 6c74 3a3a  t_block_result::
    │ │ │ +00058d30: 756e 6b6e 6f77 6e2c 206c 6561 6673 5f73  unknown, leafs_s
    │ │ │ +00058d40: 7461 7274 2c20 6c65 6166 735f 7369 7a65  tart, leafs_size
    │ │ │ +00058d50: 293b 0a0a 0909 2f2f 2073 6176 6520 7468  );....// save th
    │ │ │ +00058d60: 6520 726f 6f74 2068 6173 6820 6265 6361  e root hash beca
    │ │ │ +00058d70: 7573 6520 6d65 726b 6c65 5f66 696c 6c5f  use merkle_fill_
    │ │ │ +00058d80: 7472 6565 2077 696c 6c20 6f76 6572 7772  tree will overwr
    │ │ │ +00058d90: 6974 6520 6974 0a09 0973 6861 3235 365f  ite it...sha256_
    │ │ │ +00058da0: 6861 7368 2063 6f6e 7374 2072 6f6f 7420  hash const root 
    │ │ │ +00058db0: 3d20 6d5f 7472 6565 5b72 6f6f 745f 696e  = m_tree[root_in
    │ │ │ +00058dc0: 6465 785d 3b0a 0909 6d65 726b 6c65 5f66  dex];...merkle_f
    │ │ │ +00058dd0: 696c 6c5f 7472 6565 286d 5f74 7265 652c  ill_tree(m_tree,
    │ │ │ +00058de0: 206c 6561 6673 5f73 697a 652c 2066 6972   leafs_size, fir
    │ │ │ +00058df0: 7374 5f6c 6561 6620 2b20 6c65 6166 735f  st_leaf + leafs_
    │ │ │ +00058e00: 7374 6172 7429 3b0a 0a09 0969 6620 2872  start);....if (r
    │ │ │ +00058e10: 6f6f 7420 213d 206d 5f74 7265 655b 726f  oot != m_tree[ro
    │ │ │ +00058e20: 6f74 5f69 6e64 6578 5d29 0a09 097b 0a09  ot_index])...{..
    │ │ │ +00058e30: 0909 2f2f 2068 6173 6820 6661 696c 7572  ..// hash failur
    │ │ │ +00058e40: 652c 2063 6c65 6172 2061 6c6c 2074 6865  e, clear all the
    │ │ │ +00058e50: 2069 6e74 6572 6e61 6c20 6e6f 6465 730a   internal nodes.
    │ │ │ +00058e60: 0909 092f 2f20 7468 6520 7768 6f6c 6520  ...// the whole 
    │ │ │ +00058e70: 7069 6563 6520 6661 696c 6564 2074 6865  piece failed the
    │ │ │ +00058e80: 2068 6173 6820 6368 6563 6b2e 2043 6c65   hash check. Cle
    │ │ │ +00058e90: 6172 2061 6c6c 2062 6c6f 636b 2068 6173  ar all block has
    │ │ │ +00058ea0: 6865 730a 0909 092f 2f20 696e 2074 6869  hes....// in thi
    │ │ │ +00058eb0: 7320 7069 6563 6520 616e 6420 7265 706f  s piece and repo
    │ │ │ +00058ec0: 7274 2061 2068 6173 6820 6661 696c 7572  rt a hash failur
    │ │ │ +00058ed0: 650a 0909 096d 6572 6b6c 655f 636c 6561  e....merkle_clea
    │ │ │ +00058ee0: 725f 7472 6565 286d 5f74 7265 652c 206c  r_tree(m_tree, l
    │ │ │ +00058ef0: 6561 6673 5f73 697a 652c 2066 6972 7374  eafs_size, first
    │ │ │ +00058f00: 5f6c 6561 6620 2b20 6c65 6166 735f 7374  _leaf + leafs_st
    │ │ │ +00058f10: 6172 7429 3b0a 0909 096d 5f74 7265 655b  art);....m_tree[
    │ │ │ +00058f20: 726f 6f74 5f69 6e64 6578 5d20 3d20 726f  root_index] = ro
    │ │ │ +00058f30: 6f74 3b0a 0909 0972 6574 7572 6e20 7374  ot;....return st
    │ │ │ +00058f40: 643a 3a6d 616b 655f 7475 706c 6528 7365  d::make_tuple(se
    │ │ │ +00058f50: 745f 626c 6f63 6b5f 7265 7375 6c74 3a3a  t_block_result::
    │ │ │ +00058f60: 6861 7368 5f66 6169 6c65 642c 206c 6561  hash_failed, lea
    │ │ │ +00058f70: 6673 5f73 7461 7274 2c20 6c65 6166 735f  fs_start, leafs_
    │ │ │ +00058f80: 7369 7a65 293b 0a09 097d 0a0a 3c64 6976  size);...}..
    ..int │ │ │ +00058fc0: 636f 6e73 7420 6c65 6166 735f 656e 6420 const leafs_end │ │ │ +00058fd0: 3d20 7374 643a 3a6d 696e 286d 5f6e 756d = std::min(m_num │ │ │ +00058fe0: 5f62 6c6f 636b 732c 206c 6561 6673 5f73 _blocks, leafs_s │ │ │ +00058ff0: 7461 7274 202b 206c 6561 6673 5f73 697a tart + leafs_siz │ │ │ +00059000: 6529 3b0a 3c2f 6469 763e 0909 666f 7220 e);.
    ..for │ │ │ +00059010: 2869 6e74 2069 203d 206c 6561 6673 5f73 (int i = leafs_s │ │ │ +00059020: 7461 7274 3b20 6920 266c 743b 206c 6561 tart; i < lea │ │ │ +00059030: 6673 5f65 6e64 3b20 2b2b 6929 0a09 0909 fs_end; ++i).... │ │ │ +00059040: 6d5f 626c 6f63 6b5f 7665 7269 6669 6564 m_block_verified │ │ │ +00059050: 2e73 6574 5f62 6974 2869 293b 0a0a 0909 .set_bit(i);.... │ │ │ +00059060: 2f2f 2061 7474 656d 7074 696e 6720 746f // attempting to │ │ │ +00059070: 206f 7074 696d 697a 6520 7374 6f72 6167 optimize storag │ │ │ +00059080: 6520 6973 2071 7569 7465 2063 6f73 746c e is quite costl │ │ │ +00059090: 792c 206f 6e6c 7920 646f 2069 7420 6966 y, only do it if │ │ │ +000590a0: 2077 6520 6861 7665 0a09 092f 2f20 6120 we have...// a │ │ │ +000590b0: 7265 6173 6f6e 2074 6f20 6265 6c69 6576 reason to believ │ │ │ +000590c0: 6520 6974 206d 6967 6874 2068 6176 6520 e it might have │ │ │ +000590d0: 616e 2065 6666 6563 740a 0909 6966 2028 an effect...if ( │ │ │ +000590e0: 626c 6f63 6b5f 696e 6465 7820 3d3d 206d block_index == m │ │ │ +000590f0: 5f6e 756d 5f62 6c6f 636b 7320 2d20 3120 _num_blocks - 1 │ │ │ +00059100: 7c7c 2021 6d5f 7472 6565 5b62 6c6f 636b || !m_tree[block │ │ │ +00059110: 5f74 7265 655f 696e 6465 7820 2b20 315d _tree_index + 1] │ │ │ +00059120: 2e69 735f 616c 6c5f 7a65 726f 7328 2929 .is_all_zeros()) │ │ │ +00059130: 0a09 0909 6f70 7469 6d69 7a65 5f73 746f ....optimize_sto │ │ │ +00059140: 7261 6765 2829 3b0a 0a09 0972 6574 7572 rage();....retur │ │ │ +00059150: 6e20 7374 643a 3a6d 616b 655f 7475 706c n std::make_tupl │ │ │ +00059160: 6528 7365 745f 626c 6f63 6b5f 7265 7375 e(set_block_resu │ │ │ +00059170: 6c74 3a3a 6f6b 2c20 6c65 6166 735f 7374 lt::ok, leafs_st │ │ │ +00059180: 6172 742c 206c 6561 6673 5f73 697a 6529 art, leafs_size) │ │ │ +00059190: 3b0a 097d 0a0a 0973 7464 3a3a 7369 7a65 ;..}...std::size │ │ │ +000591a0: 5f74 206d 6572 6b6c 655f 7472 6565 3a3a _t merkle_tree:: │ │ │ +000591b0: 7369 7a65 2829 2063 6f6e 7374 0a09 7b0a size() const..{. │ │ │ +000591c0: 0909 7265 7475 726e 2073 7461 7469 635f ..return static_ │ │ │ +000591d0: 6361 7374 266c 743b 7374 643a 3a73 697a cast<std::siz │ │ │ +000591e0: 655f 7426 6774 3b28 6d65 726b 6c65 5f6e e_t>(merkle_n │ │ │ +000591f0: 756d 5f6e 6f64 6573 286d 6572 6b6c 655f um_nodes(merkle_ │ │ │ +00059200: 6e75 6d5f 6c65 6166 7328 6d5f 6e75 6d5f num_leafs(m_num_ │ │ │ +00059210: 626c 6f63 6b73 2929 293b 0a09 7d0a 0a09 blocks)));..}... │ │ │ +00059220: 696e 7420 6d65 726b 6c65 5f74 7265 653a int merkle_tree: │ │ │ +00059230: 3a6e 756d 5f70 6965 6365 7328 2920 636f :num_pieces() co │ │ │ +00059240: 6e73 740a 097b 0a09 0969 6e74 2063 6f6e nst..{...int con │ │ │ +00059250: 7374 2070 7320 3d20 626c 6f63 6b73 5f70 st ps = blocks_p │ │ │ +00059260: 6572 5f70 6965 6365 2829 3b0a 0909 544f er_piece();...TO │ │ │ +00059270: 5252 454e 545f 4153 5345 5254 2870 7320 RRENT_ASSERT(ps │ │ │ +00059280: 2667 743b 2030 293b 0a09 0972 6574 7572 > 0);...retur │ │ │ +00059290: 6e20 286d 5f6e 756d 5f62 6c6f 636b 7320 n (m_num_blocks │ │ │ +000592a0: 2b20 7073 202d 2031 2920 2667 743b 2667 + ps - 1) >&g │ │ │ +000592b0: 743b 206d 5f62 6c6f 636b 735f 7065 725f t; m_blocks_per_ │ │ │ +000592c0: 7069 6563 655f 6c6f 673b 0a09 7d0a 0a09 piece_log;..}... │ │ │ +000592d0: 696e 7420 6d65 726b 6c65 5f74 7265 653a int merkle_tree: │ │ │ +000592e0: 3a62 6c6f 636b 5f6c 6179 6572 5f73 7461 :block_layer_sta │ │ │ +000592f0: 7274 2829 2063 6f6e 7374 0a09 7b0a 0909 rt() const..{... │ │ │ +00059300: 696e 7420 636f 6e73 7420 6e75 6d5f 6c65 int const num_le │ │ │ +00059310: 6166 7320 3d20 6d65 726b 6c65 5f6e 756d afs = merkle_num │ │ │ +00059320: 5f6c 6561 6673 286d 5f6e 756d 5f62 6c6f _leafs(m_num_blo │ │ │ +00059330: 636b 7329 3b0a 0909 544f 5252 454e 545f cks);...TORRENT_ │ │ │ +00059340: 4153 5345 5254 286e 756d 5f6c 6561 6673 ASSERT(num_leafs │ │ │ +00059350: 2026 6774 3b20 3029 3b0a 0909 7265 7475 > 0);...retu │ │ │ +00059360: 726e 206d 6572 6b6c 655f 6669 7273 745f rn merkle_first_ │ │ │ +00059370: 6c65 6166 286e 756d 5f6c 6561 6673 293b leaf(num_leafs); │ │ │ +00059380: 0a09 7d0a 0a3c 2f70 7265 3e3c 2f74 643e ..}..
    │ │ │ +00059390: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +000593c0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +000593d0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +000593e0: 7074 3a65 7870 616e 6428 3230 3729 223e pt:expand(207)"> │ │ │ +000593f0: 2e2e 2f73 7263 2f74 6f72 7265 6e74 5f69 ../src/torrent_i │ │ │ +00059400: 6e66 6f2e 6370 703a 3930 313c 2f61 3e3c nfo.cpp:901
    < │ │ │ +00059410: 2f74 643e 3c74 643e 7468 6973 2073 686f /td>this sho │ │ │ +00059420: 756c 6420 6265 2063 6f6e 7369 6465 7265 uld be considere │ │ │ +00059430: 6420 6120 6661 696c 7572 652c 2061 6e64 d a failure, and │ │ │ +00059440: 2074 6865 202e 746f 7272 656e 7420 6669 the .torrent fi │ │ │ +00059450: 6c65 2072 656a 6563 7465 643c 2f74 643e le rejected │ │ │ +00059460: 3c2f 7472 3e3c 7472 2069 643d 2232 3037

    this sh │ │ │ +000594b0: 6f75 6c64 2062 6520 636f 6e73 6964 6572 ould be consider │ │ │ +000594c0: 6564 2061 2066 6169 6c75 7265 2c20 616e ed a failure, an │ │ │ +000594d0: 6420 7468 6520 2e74 6f72 7265 6e74 2066 d the .torrent f │ │ │ +000594e0: 696c 650a 7265 6a65 6374 6564 3c2f 6832 ile.rejected

    ../src/torr │ │ │ +00059500: 656e 745f 696e 666f 2e63 7070 3a39 3031 ent_info.cpp:901 │ │ │ +00059510: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +00059550: 0909 7374 643a 3a73 7472 696e 6720 6578  ..std::string ex
    │ │ │ +00059560: 7420 3d20 6578 7465 6e73 696f 6e28 6669  t = extension(fi
    │ │ │ +00059570: 6c65 6e61 6d65 293b 0a09 0909 696e 7420  lename);....int 
    │ │ │ +00059580: 636e 7420 3d20 303b 0a09 0909 666f 7220  cnt = 0;....for 
    │ │ │ +00059590: 283b 3b29 0a09 0909 7b0a 0909 0909 2b2b  (;;)....{.....++
    │ │ │ +000595a0: 636e 743b 0a09 0909 0963 6861 7220 6e65  cnt;.....char ne
    │ │ │ +000595b0: 775f 6578 745b 3530 5d3b 0a09 0909 0973  w_ext[50];.....s
    │ │ │ +000595c0: 7464 3a3a 736e 7072 696e 7466 286e 6577  td::snprintf(new
    │ │ │ +000595d0: 5f65 7874 2c20 7369 7a65 6f66 286e 6577  _ext, sizeof(new
    │ │ │ +000595e0: 5f65 7874 292c 2022 2e25 6425 7322 2c20  _ext), ".%d%s", 
    │ │ │ +000595f0: 636e 742c 2065 7874 2e63 5f73 7472 2829  cnt, ext.c_str()
    │ │ │ +00059600: 293b 0a09 0909 0966 696c 656e 616d 6520  );.....filename 
    │ │ │ +00059610: 3d20 6261 7365 202b 206e 6577 5f65 7874  = base + new_ext
    │ │ │ +00059620: 3b0a 0a09 0909 0962 6f6f 7374 3a3a 6372  ;......boost::cr
    │ │ │ +00059630: 635f 6f70 7469 6d61 6c26 6c74 3b33 322c  c_optimal<32,
    │ │ │ +00059640: 2030 7831 4544 4336 4634 312c 2030 7846   0x1EDC6F41, 0xF
    │ │ │ +00059650: 4646 4646 4646 462c 2030 7846 4646 4646  FFFFFFF, 0xFFFFF
    │ │ │ +00059660: 4646 462c 2074 7275 652c 2074 7275 6526  FFF, true, true&
    │ │ │ +00059670: 6774 3b20 6372 633b 0a09 0909 0970 726f  gt; crc;.....pro
    │ │ │ +00059680: 6365 7373 5f73 7472 696e 675f 6c6f 7765  cess_string_lowe
    │ │ │ +00059690: 7263 6173 6528 6372 632c 2066 696c 656e  rcase(crc, filen
    │ │ │ +000596a0: 616d 6529 3b0a 0909 0909 7374 643a 3a75  ame);.....std::u
    │ │ │ +000596b0: 696e 7433 325f 7420 636f 6e73 7420 6e65  int32_t const ne
    │ │ │ +000596c0: 775f 6861 7368 203d 2063 7263 2e63 6865  w_hash = crc.che
    │ │ │ +000596d0: 636b 7375 6d28 293b 0a09 0909 0969 6620  cksum();.....if 
    │ │ │ +000596e0: 2866 696c 6573 2e66 696e 6428 6e65 775f  (files.find(new_
    │ │ │ +000596f0: 6861 7368 2920 3d3d 2066 696c 6573 2e65  hash) == files.e
    │ │ │ +00059700: 6e64 2829 290a 0909 0909 7b0a 0909 0909  nd()).....{.....
    │ │ │ +00059710: 0966 696c 6573 2e69 6e73 6572 7428 7b6e  .files.insert({n
    │ │ │ +00059720: 6577 5f68 6173 682c 207b 692c 2030 7d7d  ew_hash, {i, 0}}
    │ │ │ +00059730: 293b 0a09 0909 0909 6272 6561 6b3b 0a09  );......break;..
    │ │ │ +00059740: 0909 097d 0a09 0909 092b 2b6e 756d 5f63  ...}.....++num_c
    │ │ │ +00059750: 6f6c 6c69 7369 6f6e 733b 0a09 0909 0969  ollisions;.....i
    │ │ │ +00059760: 6620 286e 756d 5f63 6f6c 6c69 7369 6f6e  f (num_collision
    │ │ │ +00059770: 7320 2667 743b 2031 3030 290a 0909 0909  s > 100).....
    │ │ │ +00059780: 7b0a 3c64 6976 2073 7479 6c65 3d22 6261  {.
    │ │ │ +000597b0: 0909 0909 7d0a 3c2f 6469 763e 0909 097d ....}.
    ...} │ │ │ +000597c0: 0a0a 0909 0963 6f70 795f 6f6e 5f77 7269 .....copy_on_wri │ │ │ +000597d0: 7465 2829 3b0a 0909 096d 5f66 696c 6573 te();....m_files │ │ │ +000597e0: 2e72 656e 616d 655f 6669 6c65 2869 2c20 .rename_file(i, │ │ │ +000597f0: 6669 6c65 6e61 6d65 293b 0a09 097d 0a09 filename);...}.. │ │ │ +00059800: 7d0a 0a09 766f 6964 2074 6f72 7265 6e74 }...void torrent │ │ │ +00059810: 5f69 6e66 6f3a 3a72 656d 6170 5f66 696c _info::remap_fil │ │ │ +00059820: 6573 2866 696c 655f 7374 6f72 6167 6520 es(file_storage │ │ │ +00059830: 636f 6e73 7426 616d 703b 2066 290a 097b const& f)..{ │ │ │ +00059840: 0a09 0949 4e56 4152 4941 4e54 5f43 4845 ...INVARIANT_CHE │ │ │ +00059850: 434b 3b0a 0a09 0954 4f52 5245 4e54 5f41 CK;....TORRENT_A │ │ │ +00059860: 5353 4552 5428 6973 5f6c 6f61 6465 6428 SSERT(is_loaded( │ │ │ +00059870: 2929 3b0a 0909 2f2f 2074 6865 206e 6577 ));...// the new │ │ │ +00059880: 2073 7065 6369 6669 6564 2066 696c 6520 specified file │ │ │ +00059890: 7374 6f72 6167 6520 6d75 7374 2068 6176 storage must hav │ │ │ +000598a0: 6520 7468 6520 6578 6163 740a 0909 2f2f e the exact...// │ │ │ +000598b0: 2073 616d 6520 7369 7a65 2061 7320 7468 same size as th │ │ │ +000598c0: 6520 6375 7272 656e 7420 6669 6c65 2073 e current file s │ │ │ +000598d0: 746f 7261 6765 0a09 0954 4f52 5245 4e54 torage...TORRENT │ │ │ +000598e0: 5f41 5353 4552 5428 6d5f 6669 6c65 732e _ASSERT(m_files. │ │ │ +000598f0: 746f 7461 6c5f 7369 7a65 2829 203d 3d20 total_size() == │ │ │ +00059900: 662e 746f 7461 6c5f 7369 7a65 2829 293b f.total_size()); │ │ │ +00059910: 0a0a 0909 6966 2028 6d5f 6669 6c65 732e ....if (m_files. │ │ │ +00059920: 746f 7461 6c5f 7369 7a65 2829 2021 3d20 total_size() != │ │ │ +00059930: 662e 746f 7461 6c5f 7369 7a65 2829 2920 f.total_size()) │ │ │ +00059940: 7265 7475 726e 3b0a 0909 636f 7079 5f6f return;...copy_o │ │ │ +00059950: 6e5f 7772 6974 6528 293b 0a09 096d 5f66 n_write();...m_f │ │ │ +00059960: 696c 6573 203d 2066 3b0a 0909 6d5f 6669 iles = f;...m_fi │ │ │ +00059970: 6c65 732e 7365 745f 6e75 6d5f 7069 6563 les.set_num_piec │ │ │ +00059980: 6573 286d 5f6f 7269 675f 6669 6c65 732d es(m_orig_files- │ │ │ +00059990: 2667 743b 6e75 6d5f 7069 6563 6573 2829 >num_pieces() │ │ │ +000599a0: 293b 0a09 096d 5f66 696c 6573 2e73 6574 );...m_files.set │ │ │ +000599b0: 5f70 6965 6365 5f6c 656e 6774 6828 6d5f _piece_length(m_ │ │ │ +000599c0: 6f72 6967 5f66 696c 6573 2d26 6774 3b70 orig_files->p │ │ │ +000599d0: 6965 6365 5f6c 656e 6774 6828 2929 3b0a iece_length());. │ │ │ +000599e0: 097d 0a0a 2369 6620 544f 5252 454e 545f .}..#if TORRENT_ │ │ │ +000599f0: 4142 495f 5645 5253 494f 4e20 3d3d 2031 ABI_VERSION == 1 │ │ │ +00059a00: 0a09 2f2f 2073 7461 6e64 6172 6420 636f ..// standard co │ │ │ +00059a10: 6e73 7472 7563 746f 7220 7468 6174 2070 nstructor that p │ │ │ +00059a20: 6172 7365 7320 6120 746f 7272 656e 7420 arses a torrent │ │ │ +00059a30: 6669 6c65 0a09 746f 7272 656e 745f 696e file..torrent_in │ │ │ +00059a40: 666f 3a3a 746f 7272 656e 745f 696e 666f fo::torrent_info │ │ │ +00059a50: 2865 6e74 7279 2063 6f6e 7374 2661 6d70 (entry const& │ │ │ +00059a60: 3b20 746f 7272 656e 745f 6669 6c65 290a ; torrent_file). │ │ │ +00059a70: 097b 0a09 0973 7464 3a3a 7665 6374 6f72 .{...std::vector │ │ │ +00059a80: 266c 743b 6368 6172 2667 743b 2074 6d70 <char> tmp │ │ │ +00059a90: 3b0a 0909 7374 643a 3a62 6163 6b5f 696e ;...std::back_in │ │ │ +00059aa0: 7365 7274 5f69 7465 7261 746f 7226 6c74 sert_iterator< │ │ │ +00059ab0: 3b73 7464 3a3a 7665 6374 6f72 266c 743b ;std::vector< │ │ │ +00059ac0: 6368 6172 2667 743b 2667 743b 206f 7574 char>> out │ │ │ +00059ad0: 2874 6d70 293b 0a09 0962 656e 636f 6465 (tmp);...bencode │ │ │ +00059ae0: 286f 7574 2c20 746f 7272 656e 745f 6669 (out, torrent_fi │ │ │ +00059af0: 6c65 293b 0a3c 2f70 7265 3e3c 2f74 643e le);.
    │ │ │ +00059b00: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +00059b30: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +00059b40: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +00059b50: 7074 3a65 7870 616e 6428 3230 3829 223e pt:expand(208)"> │ │ │ +00059b60: 2e2e 2f73 7263 2f63 7075 6964 2e63 7070 ../src/cpuid.cpp │ │ │ +00059b70: 3a31 3331 3c2f 613e 3c2f 7464 3e3c 7464 :131enable when aar │ │ │ +00059b90: 6368 3634 2069 7320 7265 616c 6c79 2074 ch64 is really t │ │ │ +00059ba0: 6573 7465 643c 2f74 643e 3c2f 7472 3e3c ested< │ │ │ +00059bb0: 7472 2069 643d 2232 3038 2220 7374 796c tr id="208" styl │ │ │ +00059bc0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00059bd0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00059be0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00059bf0: 6832 3e65 6e61 626c 6520 7768 656e 2061 h2>enable when a │ │ │ +00059c00: 6172 6368 3634 2069 7320 7265 616c 6c79 arch64 is really │ │ │ +00059c10: 2074 6573 7465 643c 2f68 323e 3c68 343e tested

    │ │ │ +00059c20: 2e2e 2f73 7263 2f63 7075 6964 2e63 7070 ../src/cpuid.cpp │ │ │ +00059c30: 3a31 3331 3c2f 6834 3e3c 7072 6520 7374 :131

    .bool support
    │ │ │ +00059c80: 735f 6d6d 7828 2920 6e6f 6578 6365 7074  s_mmx() noexcept
    │ │ │ +00059c90: 0a09 7b0a 2369 6620 544f 5252 454e 545f  ..{.#if TORRENT_
    │ │ │ +00059ca0: 4841 535f 5353 450a 0909 7374 643a 3a75  HAS_SSE...std::u
    │ │ │ +00059cb0: 696e 7433 325f 7420 6370 7569 5b34 5d20  int32_t cpui[4] 
    │ │ │ +00059cc0: 3d20 7b30 7d3b 0a09 0963 7075 6964 2863  = {0};...cpuid(c
    │ │ │ +00059cd0: 7075 692c 2031 293b 0a09 0972 6574 7572  pui, 1);...retur
    │ │ │ +00059ce0: 6e20 2863 7075 695b 325d 2026 616d 703b  n (cpui[2] &
    │ │ │ +00059cf0: 2028 3120 266c 743b 266c 743b 2032 3329   (1 << 23)
    │ │ │ +00059d00: 2920 213d 2030 3b0a 2365 6c73 650a 0909  ) != 0;.#else...
    │ │ │ +00059d10: 7265 7475 726e 2066 616c 7365 3b0a 2365  return false;.#e
    │ │ │ +00059d20: 6e64 6966 0a09 7d0a 0a09 626f 6f6c 2073  ndif..}...bool s
    │ │ │ +00059d30: 7570 706f 7274 735f 6172 6d5f 6e65 6f6e  upports_arm_neon
    │ │ │ +00059d40: 2829 206e 6f65 7863 6570 740a 097b 0a23  () noexcept..{.#
    │ │ │ +00059d50: 6966 2054 4f52 5245 4e54 5f48 4153 5f41  if TORRENT_HAS_A
    │ │ │ +00059d60: 524d 5f4e 454f 4e20 2661 6d70 3b26 616d  RM_NEON &&am
    │ │ │ +00059d70: 703b 2054 4f52 5245 4e54 5f48 4153 5f41  p; TORRENT_HAS_A
    │ │ │ +00059d80: 5558 560a 2369 6620 6465 6669 6e65 6420  UXV.#if defined 
    │ │ │ +00059d90: 5f5f 6172 6d5f 5f0a 0909 2f2f 7265 7475  __arm__...//retu
    │ │ │ +00059da0: 726e 2028 6765 7461 7578 7661 6c28 4154  rn (getauxval(AT
    │ │ │ +00059db0: 5f48 5743 4150 2920 2661 6d70 3b20 4857  _HWCAP) & HW
    │ │ │ +00059dc0: 4341 505f 4e45 4f4e 293b 0a09 0972 6574  CAP_NEON);...ret
    │ │ │ +00059dd0: 7572 6e20 2868 656c 7065 725f 6765 7461  urn (helper_geta
    │ │ │ +00059de0: 7578 7661 6c28 3136 2920 2661 6d70 3b20  uxval(16) & 
    │ │ │ +00059df0: 2831 2026 6c74 3b26 6c74 3b20 3132 2929  (1 << 12))
    │ │ │ +00059e00: 3b0a 2365 6c69 6620 6465 6669 6e65 6420  ;.#elif defined 
    │ │ │ +00059e10: 5f5f 6161 7263 6836 345f 5f0a 0909 2f2f  __aarch64__...//
    │ │ │ +00059e20: 7265 7475 726e 2028 6765 7461 7578 7661  return (getauxva
    │ │ │ +00059e30: 6c28 4154 5f48 5743 4150 2920 2661 6d70  l(AT_HWCAP) &
    │ │ │ +00059e40: 3b20 4857 4341 505f 4153 494d 4429 3b0a  ; HWCAP_ASIMD);.
    │ │ │ +00059e50: 0909 2f2f 7265 7475 726e 2028 6765 7461  ..//return (geta
    │ │ │ +00059e60: 7578 7661 6c28 3136 2920 2661 6d70 3b20  uxval(16) & 
    │ │ │ +00059e70: 2831 2026 6c74 3b26 6c74 3b20 3129 293b  (1 << 1));
    │ │ │ +00059e80: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +00059eb0: 0972 6574 7572 6e20 6661 6c73 653b 0a3c .return false;.< │ │ │ +00059ec0: 2f64 6976 3e23 656e 6469 660a 2365 6c73 /div>#endif.#els │ │ │ +00059ed0: 650a 0909 7265 7475 726e 2066 616c 7365 e...return false │ │ │ +00059ee0: 3b0a 2365 6e64 6966 0a09 7d0a 0a09 626f ;.#endif..}...bo │ │ │ +00059ef0: 6f6c 2073 7570 706f 7274 735f 6172 6d5f ol supports_arm_ │ │ │ +00059f00: 6372 6333 3263 2829 206e 6f65 7863 6570 crc32c() noexcep │ │ │ +00059f10: 740a 097b 0a23 6966 2054 4f52 5245 4e54 t..{.#if TORRENT │ │ │ +00059f20: 5f48 4153 5f41 524d 5f43 5243 3332 2026 _HAS_ARM_CRC32 & │ │ │ +00059f30: 616d 703b 2661 6d70 3b20 544f 5252 454e amp;& TORREN │ │ │ +00059f40: 545f 4841 535f 4155 5856 0a23 6966 2064 T_HAS_AUXV.#if d │ │ │ +00059f50: 6566 696e 6564 2054 4f52 5245 4e54 5f46 efined TORRENT_F │ │ │ +00059f60: 4f52 4345 5f41 524d 5f43 5243 3332 0a09 ORCE_ARM_CRC32.. │ │ │ +00059f70: 0972 6574 7572 6e20 7472 7565 3b0a 2365 .return true;.#e │ │ │ +00059f80: 6c69 6620 6465 6669 6e65 6420 5f5f 6172 lif defined __ar │ │ │ +00059f90: 6d5f 5f0a 0909 2f2f 7265 7475 726e 2028 m__...//return ( │ │ │ +00059fa0: 6765 7461 7578 7661 6c28 4154 5f48 5743 getauxval(AT_HWC │ │ │ +00059fb0: 4150 3229 2026 616d 703b 2048 5743 4150 AP2) & HWCAP │ │ │ +00059fc0: 325f 4352 4333 3229 3b0a 0909 7265 7475 2_CRC32);...retu │ │ │ +00059fd0: 726e 2028 6865 6c70 6572 5f67 6574 6175 rn (helper_getau │ │ │ +00059fe0: 7876 616c 2832 3629 2026 616d 703b 2028 xval(26) & ( │ │ │ +00059ff0: 3120 266c 743b 266c 743b 2034 2929 3b0a 1 << 4));. │ │ │ +0005a000: 2365 6c69 6620 6465 6669 6e65 6420 5f5f #elif defined __ │ │ │ +0005a010: 6161 7263 6836 345f 5f0a 0909 2f2f 7265 aarch64__...//re │ │ │ +0005a020: 7475 726e 2028 6765 7461 7578 7661 6c28 turn (getauxval( │ │ │ +0005a030: 4154 5f48 5743 4150 2920 2661 6d70 3b20 AT_HWCAP) & │ │ │ +0005a040: 4857 4341 505f 4352 4333 3229 3b0a 0909 HWCAP_CRC32);... │ │ │ +0005a050: 7265 7475 726e 2028 6865 6c70 6572 5f67 return (helper_g │ │ │ +0005a060: 6574 6175 7876 616c 2831 3629 2026 616d etauxval(16) &am │ │ │ +0005a070: 703b 2028 3120 266c 743b 266c 743b 2037 p; (1 << 7 │ │ │ +0005a080: 2929 3b0a 2365 6e64 6966 0a23 656c 7365 ));.#endif.#else │ │ │ +0005a090: 0a09 0972 6574 7572 6e20 6661 6c73 653b ...return false; │ │ │ +0005a0a0: 0a23 656e 6469 660a 097d 0a0a 7d20 2f2f .#endif..}..} // │ │ │ +0005a0b0: 2061 6e6f 6e79 6d6f 7573 206e 616d 6573 anonymous names │ │ │ +0005a0c0: 7061 6365 0a0a 0962 6f6f 6c20 636f 6e73 pace...bool cons │ │ │ +0005a0d0: 7420 7373 6534 325f 7375 7070 6f72 7420 t sse42_support │ │ │ +0005a0e0: 3d20 7375 7070 6f72 7473 5f73 7365 3432 = supports_sse42 │ │ │ +0005a0f0: 2829 3b0a 0962 6f6f 6c20 636f 6e73 7420 ();..bool const │ │ │ +0005a100: 6d6d 785f 7375 7070 6f72 7420 3d20 7375 mmx_support = su │ │ │ +0005a110: 7070 6f72 7473 5f6d 6d78 2829 3b0a 0962 pports_mmx();..b │ │ │ +0005a120: 6f6f 6c20 636f 6e73 7420 6172 6d5f 6e65 ool const arm_ne │ │ │ +0005a130: 6f6e 5f73 7570 706f 7274 203d 2073 7570 on_support = sup │ │ │ +0005a140: 706f 7274 735f 6172 6d5f 6e65 6f6e 2829 ports_arm_neon() │ │ │ +0005a150: 3b0a 0962 6f6f 6c20 636f 6e73 7420 6172 ;..bool const ar │ │ │ +0005a160: 6d5f 6372 6333 3263 5f73 7570 706f 7274 m_crc32c_support │ │ │ +0005a170: 203d 2073 7570 706f 7274 735f 6172 6d5f = supports_arm_ │ │ │ +0005a180: 6372 6333 3263 2829 3b0a 7d20 7d0a 3c2f crc32c();.} }.r │ │ │ +0005a1c0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +0005a1d0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +0005a200: 7365 7373 696f 6e2e 6370 703a 3534 303c session.cpp:540< │ │ │ +0005a210: 2f61 3e3c 2f74 643e 3c74 643e 496e 2043 /a>In C │ │ │ +0005a220: 2b2b 3137 2e20 7573 6520 6966 2063 6f6e ++17. use if con │ │ │ +0005a230: 7374 6578 7072 2069 6e73 7465 6164 3c2f stexpr instead

    In C │ │ │ +0005a290: 2b2b 3137 2e20 7573 6520 6966 2063 6f6e ++17. use if con │ │ │ +0005a2a0: 7374 6578 7072 2069 6e73 7465 6164 3c2f stexpr instead

    ../src/se │ │ │ +0005a2c0: 7373 696f 6e2e 6370 703a 3534 303c 2f68 ssion.cpp:540
    .{}.
    │ │ │ +0005a310: 0973 6573 7369 6f6e 5f70 726f 7879 3a3a  .session_proxy::
    │ │ │ +0005a320: 7365 7373 696f 6e5f 7072 6f78 7928 7365  session_proxy(se
    │ │ │ +0005a330: 7373 696f 6e5f 7072 6f78 7920 636f 6e73  ssion_proxy cons
    │ │ │ +0005a340: 7426 616d 703b 2920 3d20 6465 6661 756c  t&) = defaul
    │ │ │ +0005a350: 743b 0a09 7365 7373 696f 6e5f 7072 6f78  t;..session_prox
    │ │ │ +0005a360: 7926 616d 703b 2073 6573 7369 6f6e 5f70  y& session_p
    │ │ │ +0005a370: 726f 7879 3a3a 6f70 6572 6174 6f72 3d28  roxy::operator=(
    │ │ │ +0005a380: 7365 7373 696f 6e5f 7072 6f78 7920 636f  session_proxy co
    │ │ │ +0005a390: 6e73 7426 616d 703b 2920 2661 6d70 3b20  nst&) & 
    │ │ │ +0005a3a0: 3d20 6465 6661 756c 743b 0a09 7365 7373  = default;..sess
    │ │ │ +0005a3b0: 696f 6e5f 7072 6f78 793a 3a73 6573 7369  ion_proxy::sessi
    │ │ │ +0005a3c0: 6f6e 5f70 726f 7879 2873 6573 7369 6f6e  on_proxy(session
    │ │ │ +0005a3d0: 5f70 726f 7879 2661 6d70 3b26 616d 703b  _proxy&&
    │ │ │ +0005a3e0: 2920 6e6f 6578 6365 7074 203d 2064 6566  ) noexcept = def
    │ │ │ +0005a3f0: 6175 6c74 3b0a 0973 6573 7369 6f6e 5f70  ault;..session_p
    │ │ │ +0005a400: 726f 7879 2661 6d70 3b20 7365 7373 696f  roxy& sessio
    │ │ │ +0005a410: 6e5f 7072 6f78 793a 3a6f 7065 7261 746f  n_proxy::operato
    │ │ │ +0005a420: 723d 2873 6573 7369 6f6e 5f70 726f 7879  r=(session_proxy
    │ │ │ +0005a430: 2661 6d70 3b26 616d 703b 2920 2661 6d70  &&) &
    │ │ │ +0005a440: 3b20 6e6f 6578 6365 7074 203d 2064 6566  ; noexcept = def
    │ │ │ +0005a450: 6175 6c74 3b0a 0973 6573 7369 6f6e 5f70  ault;..session_p
    │ │ │ +0005a460: 726f 7879 3a3a 7e73 6573 7369 6f6e 5f70  roxy::~session_p
    │ │ │ +0005a470: 726f 7879 2829 0a09 7b0a 0909 6966 2028  roxy()..{...if (
    │ │ │ +0005a480: 6d5f 7468 7265 6164 2026 616d 703b 2661  m_thread &&a
    │ │ │ +0005a490: 6d70 3b20 6d5f 7468 7265 6164 2e75 7365  mp; m_thread.use
    │ │ │ +0005a4a0: 5f63 6f75 6e74 2829 203d 3d20 3129 0a09  _count() == 1)..
    │ │ │ +0005a4b0: 097b 0a23 6966 2064 6566 696e 6564 2054  .{.#if defined T
    │ │ │ +0005a4c0: 4f52 5245 4e54 5f41 5349 4f5f 4445 4255  ORRENT_ASIO_DEBU
    │ │ │ +0005a4d0: 4747 494e 470a 0909 0977 6169 745f 666f  GGING....wait_fo
    │ │ │ +0005a4e0: 725f 6173 696f 5f68 616e 646c 6572 7328  r_asio_handlers(
    │ │ │ +0005a4f0: 293b 0a23 656e 6469 660a 0909 096d 5f74  );.#endif....m_t
    │ │ │ +0005a500: 6872 6561 642d 2667 743b 6a6f 696e 2829  hread->join()
    │ │ │ +0005a510: 3b0a 0909 7d0a 097d 0a0a 0954 4f52 5245  ;...}..}...TORRE
    │ │ │ +0005a520: 4e54 5f45 5850 4f52 5420 7374 643a 3a75  NT_EXPORT std::u
    │ │ │ +0005a530: 6e69 7175 655f 7074 7226 6c74 3b64 6973  nique_ptr<dis
    │ │ │ +0005a540: 6b5f 696e 7465 7266 6163 6526 6774 3b20  k_interface> 
    │ │ │ +0005a550: 6465 6661 756c 745f 6469 736b 5f69 6f5f  default_disk_io_
    │ │ │ +0005a560: 636f 6e73 7472 7563 746f 7228 0a09 0969  constructor(...i
    │ │ │ +0005a570: 6f5f 636f 6e74 6578 7426 616d 703b 2069  o_context& i
    │ │ │ +0005a580: 6f73 2c20 7365 7474 696e 6773 5f69 6e74  os, settings_int
    │ │ │ +0005a590: 6572 6661 6365 2063 6f6e 7374 2661 6d70  erface const&
    │ │ │ +0005a5a0: 3b20 7365 7474 2c20 636f 756e 7465 7273  ; sett, counters
    │ │ │ +0005a5b0: 2661 6d70 3b20 636e 7429 0a09 7b0a 2369  & cnt)..{.#i
    │ │ │ +0005a5c0: 6620 544f 5252 454e 545f 4841 5645 5f4d  f TORRENT_HAVE_M
    │ │ │ +0005a5d0: 4d41 5020 7c7c 2054 4f52 5245 4e54 5f48  MAP || TORRENT_H
    │ │ │ +0005a5e0: 4156 455f 4d41 505f 5649 4557 5f4f 465f  AVE_MAP_VIEW_OF_
    │ │ │ +0005a5f0: 4649 4c45 0a3c 6469 7620 7374 796c 653d  FILE.
    #include "lib │ │ │ +0005a630: 746f 7272 656e 742f 6175 785f 2f64 6973 torrent/aux_/dis │ │ │ +0005a640: 6162 6c65 5f64 6570 7265 6361 7469 6f6e able_deprecation │ │ │ +0005a650: 5f77 6172 6e69 6e67 735f 7075 7368 2e68 _warnings_push.h │ │ │ +0005a660: 7070 220a 3c2f 6469 763e 0909 6966 2028 pp".
    ..if ( │ │ │ +0005a670: 7369 7a65 6f66 2876 6f69 642a 2920 3d3d sizeof(void*) == │ │ │ +0005a680: 2038 290a 0909 0972 6574 7572 6e20 6d6d 8)....return mm │ │ │ +0005a690: 6170 5f64 6973 6b5f 696f 5f63 6f6e 7374 ap_disk_io_const │ │ │ +0005a6a0: 7275 6374 6f72 2869 6f73 2c20 7365 7474 ructor(ios, sett │ │ │ +0005a6b0: 2c20 636e 7429 3b0a 0909 656c 7365 0a09 , cnt);...else.. │ │ │ +0005a6c0: 0909 7265 7475 726e 2070 6f73 6978 5f64 ..return posix_d │ │ │ +0005a6d0: 6973 6b5f 696f 5f63 6f6e 7374 7275 6374 isk_io_construct │ │ │ +0005a6e0: 6f72 2869 6f73 2c20 7365 7474 2c20 636e or(ios, sett, cn │ │ │ +0005a6f0: 7429 3b0a 2369 6e63 6c75 6465 2022 6c69 t);.#include "li │ │ │ +0005a700: 6274 6f72 7265 6e74 2f61 7578 5f2f 6469 btorrent/aux_/di │ │ │ +0005a710: 7361 626c 655f 7761 726e 696e 6773 5f70 sable_warnings_p │ │ │ +0005a720: 6f70 2e68 7070 220a 2365 6c73 650a 0909 op.hpp".#else... │ │ │ +0005a730: 7265 7475 726e 2070 6f73 6978 5f64 6973 return posix_dis │ │ │ +0005a740: 6b5f 696f 5f63 6f6e 7374 7275 6374 6f72 k_io_constructor │ │ │ +0005a750: 2869 6f73 2c20 7365 7474 2c20 636e 7429 (ios, sett, cnt) │ │ │ +0005a760: 3b0a 2365 6e64 6966 0a09 7d0a 0a7d 0a3c ;.#endif..}..}.< │ │ │ +0005a770: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +0005a780: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +0005a790: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +0005a7a0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +0005a7b0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566
    ../src │ │ │ +0005a7e0: 2f75 7470 5f73 6f63 6b65 745f 6d61 6e61 /utp_socket_mana │ │ │ +0005a7f0: 6765 722e 6370 703a 3230 343c 2f61 3e3c ger.cpp:204< │ │ │ +0005a800: 2f74 643e 3c74 643e 7468 6973 2073 686f /td>this sho │ │ │ +0005a810: 756c 6420 6e6f 7420 6265 2068 6561 7020 uld not be heap │ │ │ +0005a820: 616c 6c6f 6361 7465 642c 2073 6f63 6b65 allocated, socke │ │ │ +0005a830: 7473 2073 686f 756c 6420 6265 206d 6f76 ts should be mov │ │ │ +0005a840: 6162 6c65 3c2f 7464 3e3c 2f74 723e 3c74 ablethis should no │ │ │ +0005a8a0: 7420 6265 2068 6561 7020 616c 6c6f 6361 t be heap alloca │ │ │ +0005a8b0: 7465 642c 2073 6f63 6b65 7473 2073 686f ted, sockets sho │ │ │ +0005a8c0: 756c 6420 6265 206d 6f76 6162 6c65 3c2f uld be movable

    ../src/ut │ │ │ +0005a8e0: 705f 736f 636b 6574 5f6d 616e 6167 6572 p_socket_manager │ │ │ +0005a8f0: 2e63 7070 3a32 3034 3c2f 6834 3e3c 7072 .cpp:204

    .//..UTP_ │ │ │ +0005a940: 4c4f 4756 2822 696e 636f 6d69 6e67 2070 LOGV("incoming p │ │ │ +0005a950: 6163 6b65 7420 6964 3a25 6420 736f 7572 acket id:%d sour │ │ │ +0005a960: 6365 3a25 735c 6e22 2c20 6964 2c20 7072 ce:%s\n", id, pr │ │ │ +0005a970: 696e 745f 656e 6470 6f69 6e74 2865 7029 int_endpoint(ep) │ │ │ +0005a980: 2e63 5f73 7472 2829 293b 0a0a 0909 6966 .c_str());....if │ │ │ +0005a990: 2028 216d 5f73 6574 742e 6765 745f 626f (!m_sett.get_bo │ │ │ +0005a9a0: 6f6c 2873 6574 7469 6e67 735f 7061 636b ol(settings_pack │ │ │ +0005a9b0: 3a3a 656e 6162 6c65 5f69 6e63 6f6d 696e ::enable_incomin │ │ │ +0005a9c0: 675f 7574 7029 290a 0909 0972 6574 7572 g_utp))....retur │ │ │ +0005a9d0: 6e20 6661 6c73 653b 0a0a 0909 2f2f 2069 n false;....// i │ │ │ +0005a9e0: 6620 6e6f 7420 666f 756e 642c 2073 6565 f not found, see │ │ │ +0005a9f0: 2069 6620 6974 2773 2061 2053 594e 2070 if it's a SYN p │ │ │ +0005aa00: 6163 6b65 742c 2069 6620 6974 2069 732c acket, if it is, │ │ │ +0005aa10: 0a09 092f 2f20 6372 6561 7465 2061 206e ...// create a n │ │ │ +0005aa20: 6577 2075 7470 5f73 7472 6561 6d0a 0909 ew utp_stream... │ │ │ +0005aa30: 6966 2028 7068 2d26 6774 3b67 6574 5f74 if (ph->get_t │ │ │ +0005aa40: 7970 6528 2920 3d3d 2053 545f 5359 4e29 ype() == ST_SYN) │ │ │ +0005aa50: 0a09 097b 0a09 0909 2f2f 2070 6f73 7369 ...{....// possi │ │ │ +0005aa60: 626c 6520 5359 4e20 666c 6f6f 642e 204a ble SYN flood. J │ │ │ +0005aa70: 7573 7420 6967 6e6f 7265 0a09 0909 6966 ust ignore....if │ │ │ +0005aa80: 2028 696e 7428 6d5f 7574 705f 736f 636b (int(m_utp_sock │ │ │ +0005aa90: 6574 732e 7369 7a65 2829 2920 2667 743b ets.size()) > │ │ │ +0005aaa0: 206d 5f73 6574 742e 6765 745f 696e 7428 m_sett.get_int( │ │ │ +0005aab0: 7365 7474 696e 6773 5f70 6163 6b3a 3a63 settings_pack::c │ │ │ +0005aac0: 6f6e 6e65 6374 696f 6e73 5f6c 696d 6974 onnections_limit │ │ │ +0005aad0: 2920 2a20 3229 0a09 0909 0972 6574 7572 ) * 2).....retur │ │ │ +0005aae0: 6e20 6661 6c73 653b 0a0a 0909 0954 4f52 n false;.....TOR │ │ │ +0005aaf0: 5245 4e54 5f41 5353 4552 5428 6d5f 6e65 RENT_ASSERT(m_ne │ │ │ +0005ab00: 775f 636f 6e6e 6563 7469 6f6e 203d 3d20 w_connection == │ │ │ +0005ab10: 2d31 293b 0a09 0909 2f2f 2063 7265 6174 -1);....// creat │ │ │ +0005ab20: 6520 7468 6520 6e65 7720 736f 636b 6574 e the new socket │ │ │ +0005ab30: 2077 6974 6820 7468 6973 2049 440a 0909 with this ID... │ │ │ +0005ab40: 096d 5f6e 6577 5f63 6f6e 6e65 6374 696f .m_new_connectio │ │ │ +0005ab50: 6e20 3d20 6964 3b0a 0a2f 2f09 0909 5554 n = id;..//...UT │ │ │ +0005ab60: 505f 4c4f 4756 2822 6e6f 7420 666f 756e P_LOGV("not foun │ │ │ +0005ab70: 642c 206e 6577 2063 6f6e 6e65 6374 696f d, new connectio │ │ │ +0005ab80: 6e20 6964 3a25 645c 6e22 2c20 6d5f 6e65 n id:%d\n", m_ne │ │ │ +0005ab90: 775f 636f 6e6e 6563 7469 6f6e 293b 0a0a w_connection);.. │ │ │ +0005aba0: 3c64 6976 2073 7479 6c65 3d22 6261 636b
    .. │ │ │ +0005abd0: 0961 7578 3a3a 736f 636b 6574 5f74 7970 .aux::socket_typ │ │ │ +0005abe0: 6520 6328 6175 783a 3a69 6e73 7461 6e74 e c(aux::instant │ │ │ +0005abf0: 6961 7465 5f63 6f6e 6e65 6374 696f 6e28 iate_connection( │ │ │ +0005ac00: 6d5f 696f 732c 2061 7578 3a3a 7072 6f78 m_ios, aux::prox │ │ │ +0005ac10: 795f 7365 7474 696e 6773 2829 2c20 6d5f y_settings(), m_ │ │ │ +0005ac20: 7373 6c5f 636f 6e74 6578 742c 2074 6869 ssl_context, thi │ │ │ +0005ac30: 732c 2074 7275 652c 2066 616c 7365 2929 s, true, false)) │ │ │ +0005ac40: 3b0a 3c2f 6469 763e 0a09 0909 7574 705f ;.
    ....utp_ │ │ │ +0005ac50: 7374 7265 616d 2a20 7374 7220 3d20 6e75 stream* str = nu │ │ │ +0005ac60: 6c6c 7074 723b 0a23 6966 6465 6620 544f llptr;.#ifdef TO │ │ │ +0005ac70: 5252 454e 545f 5353 4c5f 5045 4552 530a RRENT_SSL_PEERS. │ │ │ +0005ac80: 0909 0969 6620 2869 735f 7373 6c28 6329 ...if (is_ssl(c) │ │ │ +0005ac90: 290a 0909 0909 7374 7220 3d20 2661 6d70 ).....str = & │ │ │ +0005aca0: 3b62 6f6f 7374 3a3a 6765 7426 6c74 3b73 ;boost::get<s │ │ │ +0005acb0: 736c 5f73 7472 6561 6d26 6c74 3b75 7470 sl_stream<utp │ │ │ +0005acc0: 5f73 7472 6561 6d26 6774 3b26 6774 3b28 _stream>>( │ │ │ +0005acd0: 6329 2e6e 6578 745f 6c61 7965 7228 293b c).next_layer(); │ │ │ +0005ace0: 0a09 0909 656c 7365 0a23 656e 6469 660a ....else.#endif. │ │ │ +0005acf0: 0909 0909 7374 7220 3d20 626f 6f73 743a ....str = boost: │ │ │ +0005ad00: 3a67 6574 266c 743b 7574 705f 7374 7265 :get<utp_stre │ │ │ +0005ad10: 616d 2667 743b 2826 616d 703b 6329 3b0a am>(&c);. │ │ │ +0005ad20: 0a09 0909 544f 5252 454e 545f 4153 5345 ....TORRENT_ASSE │ │ │ +0005ad30: 5254 2873 7472 293b 0a09 0909 696e 7420 RT(str);....int │ │ │ +0005ad40: 636f 6e73 7420 6d74 7520 3d20 6d74 755f const mtu = mtu_ │ │ │ +0005ad50: 666f 725f 6465 7374 2865 702e 6164 6472 for_dest(ep.addr │ │ │ +0005ad60: 6573 7328 2929 3b0a 0909 0973 7472 2d26 ess());....str-& │ │ │ +0005ad70: 6774 3b67 6574 5f69 6d70 6c28 292d 2667 gt;get_impl()-&g │ │ │ +0005ad80: 743b 696e 6974 5f6d 7475 286d 7475 293b t;init_mtu(mtu); │ │ │ +0005ad90: 0a09 0909 7374 722d 2667 743b 6765 745f ....str->get_ │ │ │ +0005ada0: 696d 706c 2829 2d26 6774 3b6d 5f73 6f63 impl()->m_soc │ │ │ +0005adb0: 6b20 3d20 7374 643a 3a6d 6f76 6528 736f k = std::move(so │ │ │ +0005adc0: 636b 6574 293b 0a09 0909 626f 6f6c 2063 cket);....bool c │ │ │ +0005add0: 6f6e 7374 2072 6574 203d 2073 7472 2d26 onst ret = str-& │ │ │ +0005ade0: 6774 3b67 6574 5f69 6d70 6c28 292d 2667 gt;get_impl()-&g │ │ │ +0005adf0: 743b 696e 636f 6d69 6e67 5f70 6163 6b65 t;incoming_packe │ │ │ +0005ae00: 7428 702c 2065 702c 2072 6563 6569 7665 t(p, ep, receive │ │ │ +0005ae10: 5f74 696d 6529 3b0a 0909 0969 6620 2821 _time);....if (! │ │ │ +0005ae20: 7265 7429 2072 6574 7572 6e20 6661 6c73 ret) return fals │ │ │ +0005ae30: 653b 0a09 0909 6d5f 6c61 7374 5f73 6f63 e;....m_last_soc │ │ │ +0005ae40: 6b65 7420 3d20 7374 722d 2667 743b 6765 ket = str->ge │ │ │ +0005ae50: 745f 696d 706c 2829 3b0a 0909 096d 5f63 t_impl();....m_c │ │ │ +0005ae60: 6228 7374 643a 3a6d 6f76 6528 6329 293b b(std::move(c)); │ │ │ +0005ae70: 0a09 0909 2f2f 2074 6865 2063 6f6e 6e65 ....// the conne │ │ │ +0005ae80: 6374 696f 6e20 6d6f 7374 206c 696b 656c ction most likel │ │ │ +0005ae90: 7920 6368 616e 6765 6420 6974 7320 636f y changed its co │ │ │ +0005aea0: 6e6e 6563 7469 6f6e 2049 4420 6865 7265 nnection ID here │ │ │ +0005aeb0: 0a09 0909 2f2f 2077 6520 6e65 6564 2074 ....// we need t │ │ │ +0005aec0: 6f20 6d6f 7665 2069 7420 746f 2074 6865 o move it to the │ │ │ +0005aed0: 2063 6f72 7265 6374 2049 440a 0909 0972 correct ID....r │ │ │ +0005aee0: 6574 7572 6e20 7472 7565 3b0a 0909 7d0a eturn true;...}. │ │ │ +0005aef0: 0a09 0969 6620 2870 682d 2667 743b 6765 ...if (ph->ge │ │ │ +0005af00: 745f 7479 7065 2829 203d 3d20 5354 5f52 t_type() == ST_R │ │ │ +0005af10: 4553 4554 2920 7265 7475 726e 2066 616c ESET) return fal │ │ │ +0005af20: 7365 3b0a 0a09 092f 2f20 2365 7272 6f72 se;....// #error │ │ │ +0005af30: 2073 656e 6420 7265 7365 740a 0a09 0972 send reset....r │ │ │ +0005af40: 6574 7572 6e20 6661 6c73 653b 0a09 7d0a eturn false;..}. │ │ │ +0005af50: 0a09 766f 6964 2075 7470 5f73 6f63 6b65 ..void utp_socke │ │ │ +0005af60: 745f 6d61 6e61 6765 723a 3a73 7562 7363 t_manager::subsc │ │ │ +0005af70: 7269 6265 5f77 7269 7461 626c 6528 7574 ribe_writable(ut │ │ │ +0005af80: 705f 736f 636b 6574 5f69 6d70 6c2a 2073 p_socket_impl* s │ │ │ +0005af90: 290a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ).
    < │ │ │ +0005afc0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +0005afd0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +0005b000: 7372 632f 736d 6172 745f 6261 6e2e 6370 src/smart_ban.cp │ │ │ +0005b010: 703a 3137 383c 2f61 3e3c 2f74 643e 3c74 p:178replace with s │ │ │ +0005b030: 7464 3a3a 6572 6173 655f 6966 2829 206f td::erase_if() o │ │ │ +0005b040: 6e63 6520 7765 2072 6571 7569 7265 2043 nce we require C │ │ │ +0005b050: 2b2b 3230 3c2f 7464 3e3c 2f74 723e 3c74 ++20replace with s │ │ │ +0005b0b0: 7464 3a3a 6572 6173 655f 6966 2829 206f td::erase_if() o │ │ │ +0005b0c0: 6e63 6520 7765 2072 6571 7569 7265 2043 nce we require C │ │ │ +0005b0d0: 2b2b 3230 3c2f 6832 3e3c 6834 3e2e 2e2f ++20

    ../ │ │ │ +0005b0e0: 7372 632f 736d 6172 745f 6261 6e2e 6370 src/smart_ban.cp │ │ │ +0005b0f0: 703a 3137 383c 2f68 343e 3c70 7265 2073 p:178

    ......, disk
    │ │ │ +0005b140: 5f69 6e74 6572 6661 6365 3a3a 666f 7263  _interface::forc
    │ │ │ +0005b150: 655f 636f 7079 293b 0a09 0909 097d 0a0a  e_copy);.....}..
    │ │ │ +0005b160: 0909 0909 722e 7374 6172 7420 2b3d 2031  ....r.start += 1
    │ │ │ +0005b170: 362a 3130 3234 3b0a 0909 0909 7369 7a65  6*1024;.....size
    │ │ │ +0005b180: 202d 3d20 3136 2a31 3032 343b 0a09 0909   -= 16*1024;....
    │ │ │ +0005b190: 0972 2e6c 656e 6774 6820 3d20 7374 643a  .r.length = std:
    │ │ │ +0005b1a0: 3a6d 696e 2831 362a 3130 3234 2c20 7369  :min(16*1024, si
    │ │ │ +0005b1b0: 7a65 293b 0a09 0909 092b 2b70 622e 626c  ze);.....++pb.bl
    │ │ │ +0005b1c0: 6f63 6b5f 696e 6465 783b 0a09 0909 7d0a  ock_index;....}.
    │ │ │ +0005b1d0: 0909 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ +0005b1e0: 5428 7369 7a65 2026 6c74 3b3d 2030 293b  T(size <= 0);
    │ │ │ +0005b1f0: 0a09 097d 0a0a 0909 2f2f 206e 6f74 2064  ...}....// not d
    │ │ │ +0005b200: 6563 6c61 7265 6420 6f6e 2074 6f72 7265  eclared on torre
    │ │ │ +0005b210: 6e74 5f70 6c75 6769 6e20 2877 6f75 6c64  nt_plugin (would
    │ │ │ +0005b220: 2072 6571 7569 7265 2061 6e20 4142 492d   require an ABI-
    │ │ │ +0005b230: 6272 6561 6b69 6e67 206e 6577 0a09 092f  breaking new.../
    │ │ │ +0005b240: 2f20 7669 7274 7561 6c29 2e20 4361 6c6c  / virtual). Call
    │ │ │ +0005b250: 6564 2076 6961 2061 2064 6f77 6e63 6173  ed via a downcas
    │ │ │ +0005b260: 7420 696e 2074 6f72 7265 6e74 3a3a 7065  t in torrent::pe
    │ │ │ +0005b270: 6572 735f 6572 6173 6564 2829 20e2 8094  ers_erased() ...
    │ │ │ +0005b280: 2073 6565 0a09 092f 2f20 736d 6172 745f   see...// smart_
    │ │ │ +0005b290: 6261 6e5f 6e6f 7469 6679 5f65 7261 7365  ban_notify_erase
    │ │ │ +0005b2a0: 5f70 6565 7273 2829 2062 656c 6f77 0a09  _peers() below..
    │ │ │ +0005b2b0: 0976 6f69 6420 6f6e 5f65 7261 7365 5f70  .void on_erase_p
    │ │ │ +0005b2c0: 6565 7273 2873 7061 6e26 6c74 3b74 6f72  eers(span<tor
    │ │ │ +0005b2d0: 7265 6e74 5f70 6565 722a 2063 6f6e 7374  rent_peer* const
    │ │ │ +0005b2e0: 2667 743b 2070 6565 7273 290a 0909 7b0a  > peers)...{.
    │ │ │ +0005b2f0: 0909 0969 6620 286d 5f62 6c6f 636b 5f68  ...if (m_block_h
    │ │ │ +0005b300: 6173 6865 732e 656d 7074 7928 2920 7c7c  ashes.empty() ||
    │ │ │ +0005b310: 2070 6565 7273 2e65 6d70 7479 2829 2920   peers.empty()) 
    │ │ │ +0005b320: 7265 7475 726e 3b0a 0a09 0909 7374 643a  return;.....std:
    │ │ │ +0005b330: 3a76 6563 746f 7226 6c74 3b74 6f72 7265  :vector<torre
    │ │ │ +0005b340: 6e74 5f70 6565 722a 2667 743b 2065 7261  nt_peer*> era
    │ │ │ +0005b350: 7365 6428 7065 6572 732e 6265 6769 6e28  sed(peers.begin(
    │ │ │ +0005b360: 292c 2070 6565 7273 2e65 6e64 2829 293b  ), peers.end());
    │ │ │ +0005b370: 0a09 0909 7374 643a 3a73 6f72 7428 6572  ....std::sort(er
    │ │ │ +0005b380: 6173 6564 2e62 6567 696e 2829 2c20 6572  ased.begin(), er
    │ │ │ +0005b390: 6173 6564 2e65 6e64 2829 293b 0a3c 6469  ased.end());....fo
    │ │ │ +0005b3d0: 7220 2861 7574 6f20 6920 3d20 6d5f 626c  r (auto i = m_bl
    │ │ │ +0005b3e0: 6f63 6b5f 6861 7368 6573 2e62 6567 696e  ock_hashes.begin
    │ │ │ +0005b3f0: 2829 3b20 6920 213d 206d 5f62 6c6f 636b  (); i != m_block
    │ │ │ +0005b400: 5f68 6173 6865 732e 656e 6428 293b 290a  _hashes.end();).
    │ │ │ +0005b410: 3c2f 6469 763e 0909 097b 0a09 0909 0969  
    ...{.....i │ │ │ +0005b420: 6620 2873 7464 3a3a 6269 6e61 7279 5f73 f (std::binary_s │ │ │ +0005b430: 6561 7263 6828 6572 6173 6564 2e62 6567 earch(erased.beg │ │ │ +0005b440: 696e 2829 2c20 6572 6173 6564 2e65 6e64 in(), erased.end │ │ │ +0005b450: 2829 2c20 692d 2667 743b 7365 636f 6e64 (), i->second │ │ │ +0005b460: 2e70 6565 7229 290a 0909 0909 0969 203d .peer))......i = │ │ │ +0005b470: 206d 5f62 6c6f 636b 5f68 6173 6865 732e m_block_hashes. │ │ │ +0005b480: 6572 6173 6528 6929 3b0a 0909 0909 656c erase(i);.....el │ │ │ +0005b490: 7365 0a09 0909 0909 2b2b 693b 0a09 0909 se......++i;.... │ │ │ +0005b4a0: 7d0a 0909 7d0a 0a09 7072 6976 6174 653a }...}...private: │ │ │ +0005b4b0: 0a0a 0909 2f2f 2074 6869 7320 656e 7472 ....// this entr │ │ │ +0005b4c0: 7920 7469 6573 2061 2073 7065 6369 6669 y ties a specifi │ │ │ +0005b4d0: 6320 626c 6f63 6b20 4352 4320 746f 0a09 c block CRC to.. │ │ │ +0005b4e0: 092f 2f20 6120 7065 6572 2e0a 0909 7374 .// a peer....st │ │ │ +0005b4f0: 7275 6374 2062 6c6f 636b 5f65 6e74 7279 ruct block_entry │ │ │ +0005b500: 0a09 097b 0a09 0909 746f 7272 656e 745f ...{....torrent_ │ │ │ +0005b510: 7065 6572 2a20 7065 6572 3b0a 0909 0973 peer* peer;....s │ │ │ +0005b520: 6861 315f 6861 7368 2064 6967 6573 743b ha1_hash digest; │ │ │ +0005b530: 0a09 097d 3b0a 0a09 0976 6f69 6420 6f6e ...};....void on │ │ │ +0005b540: 5f72 6561 645f 6661 696c 6564 5f62 6c6f _read_failed_blo │ │ │ +0005b550: 636b 2870 6965 6365 5f62 6c6f 636b 2063 ck(piece_block c │ │ │ +0005b560: 6f6e 7374 2062 2c20 6164 6472 6573 7320 onst b, address │ │ │ +0005b570: 636f 6e73 7420 610a 0909 092c 2064 6973 const a...., dis │ │ │ +0005b580: 6b5f 6275 6666 6572 5f68 6f6c 6465 7220 k_buffer_holder │ │ │ +0005b590: 6275 6666 6572 2c20 696e 7420 636f 6e73 buffer, int cons │ │ │ +0005b5a0: 7420 626c 6f63 6b5f 7369 7a65 0a09 0909 t block_size.... │ │ │ +0005b5b0: 2c20 7374 6f72 6167 655f 6572 726f 7220 , storage_error │ │ │ +0005b5c0: 636f 6e73 7426 616d 703b 2065 7272 6f72 const& error │ │ │ +0005b5d0: 290a 0909 7b0a 0909 0954 4f52 5245 4e54 )...{....TORRENT │ │ │ +0005b5e0: 5f41 5353 4552 5428 6d5f 746f 7272 656e _ASSERT(m_torren │ │ │ +0005b5f0: 742e 7365 7373 696f 6e28 292e 6973 5f73 t.session().is_s │ │ │ +0005b600: 696e 676c 655f 7468 7265 6164 2829 293b ingle_thread()); │ │ │ +0005b610: 0a0a 0909 092f 2f20 6967 6e6f 7265 2072 .....// ignore r │ │ │ +0005b620: 6561 6420 6572 726f 7273 0a09 0909 6966 ead errors....if │ │ │ +0005b630: 2028 6572 726f 7229 2072 6574 7572 6e3b (error) return; │ │ │ +0005b640: 0a0a 0909 0968 6173 6865 7220 683b 0a09 .....hasher h;.. │ │ │ +0005b650: 0909 682e 7570 6461 7465 287b 6275 6666 ..h.update({buff │ │ │ +0005b660: 6572 2e64 6174 6128 292c 2062 6c6f 636b er.data(), block │ │ │ +0005b670: 5f73 697a 657d 293b 0a0a 3c2f 7072 653e _size});..
    │ │ │ +0005b680: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +0005b6b0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +0005b6c0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/ut_m │ │ │ +0005b6f0: 6574 6164 6174 612e 6370 703a 3238 313c etadata.cpp:281< │ │ │ +0005b700: 2f61 3e3c 2f74 643e 3c74 643e 7765 2072 /a>we r │ │ │ +0005b710: 6561 6c6c 7920 6e65 6564 2074 6f20 696e eally need to in │ │ │ +0005b720: 6372 656d 656e 7420 7468 6520 7265 6663 crement the refc │ │ │ +0005b730: 6f75 6e74 6572 206f 6e20 7468 6520 746f ounter on the to │ │ │ +0005b740: 7272 656e 7420 7768 696c 6520 7468 6973 rrent while this │ │ │ +0005b750: 2062 7566 6665 7220 6973 2073 7469 6c6c buffer is still │ │ │ +0005b760: 2069 6e20 7468 6520 7065 6572 2773 2073 in the peer's s │ │ │ +0005b770: 656e 6420 6275 6666 6572 3c2f 7464 3e3c end buffer< │ │ │ +0005b780: 2f74 723e 3c74 7220 6964 3d22 3231 3222 /tr>

    we reall │ │ │ +0005b7d0: 7920 6e65 6564 2074 6f20 696e 6372 656d y need to increm │ │ │ +0005b7e0: 656e 7420 7468 6520 7265 6663 6f75 6e74 ent the refcount │ │ │ +0005b7f0: 6572 206f 6e20 7468 6520 746f 7272 656e er on the torren │ │ │ +0005b800: 740a 7768 696c 6520 7468 6973 2062 7566 t.while this buf │ │ │ +0005b810: 6665 7220 6973 2073 7469 6c6c 2069 6e20 fer is still in │ │ │ +0005b820: 7468 6520 7065 6572 2773 2073 656e 6420 the peer's send │ │ │ +0005b830: 6275 6666 6572 3c2f 6832 3e3c 6834 3e2e buffer

    . │ │ │ +0005b840: 2e2f 7372 632f 7574 5f6d 6574 6164 6174 ./src/ut_metadat │ │ │ +0005b850: 612e 6370 703a 3238 313c 2f68 343e 3c70 a.cpp:281

    ....int │ │ │ +0005b8a0: 636f 6e73 7420 6f66 6673 6574 203d 2070 const offset = p │ │ │ +0005b8b0: 6965 6365 202a 2031 3620 2a20 3130 3234 iece * 16 * 1024 │ │ │ +0005b8c0: 3b0a 0909 0909 6d65 7461 6461 7461 203d ;.....metadata = │ │ │ +0005b8d0: 206d 5f74 702e 6d65 7461 6461 7461 2829 m_tp.metadata() │ │ │ +0005b8e0: 2e64 6174 6128 2920 2b20 6f66 6673 6574 .data() + offset │ │ │ +0005b8f0: 3b0a 0909 0909 6d65 7461 6461 7461 5f70 ;.....metadata_p │ │ │ +0005b900: 6965 6365 5f73 697a 6520 3d20 7374 643a iece_size = std: │ │ │ +0005b910: 3a6d 696e 280a 0909 0909 0969 6e74 286d :min(......int(m │ │ │ +0005b920: 5f74 702e 6d65 7461 6461 7461 2829 2e73 _tp.metadata().s │ │ │ +0005b930: 697a 6528 2929 202d 206f 6666 7365 742c ize()) - offset, │ │ │ +0005b940: 2031 3620 2a20 3130 3234 293b 0a09 0909 16 * 1024);.... │ │ │ +0005b950: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ +0005b960: 6d65 7461 6461 7461 5f70 6965 6365 5f73 metadata_piece_s │ │ │ +0005b970: 697a 6520 2667 743b 2030 293b 0a09 0909 ize > 0);.... │ │ │ +0005b980: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ +0005b990: 6f66 6673 6574 2026 6774 3b3d 2030 293b offset >= 0); │ │ │ +0005b9a0: 0a09 0909 0954 4f52 5245 4e54 5f41 5353 .....TORRENT_ASS │ │ │ +0005b9b0: 4552 5428 6f66 6673 6574 202b 206d 6574 ERT(offset + met │ │ │ +0005b9c0: 6164 6174 615f 7069 6563 655f 7369 7a65 adata_piece_size │ │ │ +0005b9d0: 2026 6c74 3b3d 206d 5f74 702e 6d65 7461 <= m_tp.meta │ │ │ +0005b9e0: 6461 7461 2829 2e73 697a 6528 2929 3b0a data().size());. │ │ │ +0005b9f0: 0909 097d 0a0a 0909 0963 6861 7220 6d73 ...}.....char ms │ │ │ +0005ba00: 675b 3230 305d 3b0a 0909 0963 6861 722a g[200];....char* │ │ │ +0005ba10: 2068 6561 6465 7220 3d20 6d73 673b 0a09 header = msg;.. │ │ │ +0005ba20: 0909 6368 6172 2a20 7020 3d20 2661 6d70 ..char* p = & │ │ │ +0005ba30: 3b6d 7367 5b36 5d3b 0a09 0909 696e 7420 ;msg[6];....int │ │ │ +0005ba40: 636f 6e73 7420 6c65 6e20 3d20 6265 6e63 const len = benc │ │ │ +0005ba50: 6f64 6528 702c 2065 293b 0a09 0909 696e ode(p, e);....in │ │ │ +0005ba60: 7420 636f 6e73 7420 746f 7461 6c5f 7369 t const total_si │ │ │ +0005ba70: 7a65 203d 2032 202b 206c 656e 202b 206d ze = 2 + len + m │ │ │ +0005ba80: 6574 6164 6174 615f 7069 6563 655f 7369 etadata_piece_si │ │ │ +0005ba90: 7a65 3b0a 0909 096e 616d 6573 7061 6365 ze;....namespace │ │ │ +0005baa0: 2069 6f20 3d20 6175 783b 0a09 0909 696f io = aux;....io │ │ │ +0005bab0: 3a3a 7772 6974 655f 7569 6e74 3332 2874 ::write_uint32(t │ │ │ +0005bac0: 6f74 616c 5f73 697a 652c 2068 6561 6465 otal_size, heade │ │ │ +0005bad0: 7229 3b0a 0909 0969 6f3a 3a77 7269 7465 r);....io::write │ │ │ +0005bae0: 5f75 696e 7438 2862 745f 7065 6572 5f63 _uint8(bt_peer_c │ │ │ +0005baf0: 6f6e 6e65 6374 696f 6e3a 3a6d 7367 5f65 onnection::msg_e │ │ │ +0005bb00: 7874 656e 6465 642c 2068 6561 6465 7229 xtended, header) │ │ │ +0005bb10: 3b0a 0909 0969 6f3a 3a77 7269 7465 5f75 ;....io::write_u │ │ │ +0005bb20: 696e 7438 286d 5f6d 6573 7361 6765 5f69 int8(m_message_i │ │ │ +0005bb30: 6e64 6578 2c20 6865 6164 6572 293b 0a0a ndex, header);.. │ │ │ +0005bb40: 0909 096d 5f70 632e 7365 6e64 5f62 7566 ...m_pc.send_buf │ │ │ +0005bb50: 6665 7228 7b6d 7367 2c20 6c65 6e20 2b20 fer({msg, len + │ │ │ +0005bb60: 367d 293b 0a3c 6469 7620 7374 796c 653d 6});.

    ...if (metada │ │ │ +0005bba0: 7461 5f70 6965 6365 5f73 697a 6529 0a3c ta_piece_size).< │ │ │ +0005bbb0: 2f64 6976 3e09 0909 7b0a 0909 0909 6d5f /div>...{.....m_ │ │ │ +0005bbc0: 7063 2e61 7070 656e 645f 636f 6e73 745f pc.append_const_ │ │ │ +0005bbd0: 7365 6e64 5f62 7566 6665 7228 0a09 0909 send_buffer(.... │ │ │ +0005bbe0: 0909 7370 616e 266c 743b 6368 6172 2667 ..span<char&g │ │ │ +0005bbf0: 743b 2863 6f6e 7374 5f63 6173 7426 6c74 t;(const_cast< │ │ │ +0005bc00: 3b63 6861 722a 2667 743b 286d 6574 6164 ;char*>(metad │ │ │ +0005bc10: 6174 6129 2c20 6d65 7461 6461 7461 5f70 ata), metadata_p │ │ │ +0005bc20: 6965 6365 5f73 697a 6529 2c20 6d65 7461 iece_size), meta │ │ │ +0005bc30: 6461 7461 5f70 6965 6365 5f73 697a 6529 data_piece_size) │ │ │ +0005bc40: 3b0a 0909 097d 0a0a 0909 096d 5f70 632e ;....}.....m_pc. │ │ │ +0005bc50: 7374 6174 735f 636f 756e 7465 7273 2829 stats_counters() │ │ │ +0005bc60: 2e69 6e63 5f73 7461 7473 5f63 6f75 6e74 .inc_stats_count │ │ │ +0005bc70: 6572 2863 6f75 6e74 6572 733a 3a6e 756d er(counters::num │ │ │ +0005bc80: 5f6f 7574 676f 696e 675f 6578 7465 6e64 _outgoing_extend │ │ │ +0005bc90: 6564 293b 0a09 0909 6d5f 7063 2e73 7461 ed);....m_pc.sta │ │ │ +0005bca0: 7473 5f63 6f75 6e74 6572 7328 292e 696e ts_counters().in │ │ │ +0005bcb0: 635f 7374 6174 735f 636f 756e 7465 7228 c_stats_counter( │ │ │ +0005bcc0: 636f 756e 7465 7273 3a3a 6e75 6d5f 6f75 counters::num_ou │ │ │ +0005bcd0: 7467 6f69 6e67 5f6d 6574 6164 6174 6129 tgoing_metadata) │ │ │ +0005bce0: 3b0a 0909 7d0a 0a09 0962 6f6f 6c20 6f6e ;...}....bool on │ │ │ +0005bcf0: 5f65 7874 656e 6465 6428 696e 7420 636f _extended(int co │ │ │ +0005bd00: 6e73 7420 6c65 6e67 7468 0a09 0909 2c20 nst length...., │ │ │ +0005bd10: 696e 7420 636f 6e73 7420 6578 7465 6e64 int const extend │ │ │ +0005bd20: 6564 5f6d 7367 2c20 7370 616e 266c 743b ed_msg, span< │ │ │ +0005bd30: 6368 6172 2063 6f6e 7374 2667 743b 2062 char const> b │ │ │ +0005bd40: 6f64 7929 206f 7665 7272 6964 650a 0909 ody) override... │ │ │ +0005bd50: 7b0a 0909 0969 6620 2865 7874 656e 6465 {....if (extende │ │ │ +0005bd60: 645f 6d73 6720 213d 2032 2920 7265 7475 d_msg != 2) retu │ │ │ +0005bd70: 726e 2066 616c 7365 3b0a 0909 0969 6620 rn false;....if │ │ │ +0005bd80: 286d 5f6d 6573 7361 6765 5f69 6e64 6578 (m_message_index │ │ │ +0005bd90: 203d 3d20 3029 2072 6574 7572 6e20 6661 == 0) return fa │ │ │ +0005bda0: 6c73 653b 0a0a 0909 0969 6620 286c 656e lse;.....if (len │ │ │ +0005bdb0: 6774 6820 2667 743b 2031 3720 2a20 3130 gth > 17 * 10 │ │ │ +0005bdc0: 3234 290a 0909 097b 0a23 6966 6e64 6566 24)....{.#ifndef │ │ │ +0005bdd0: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ +0005bde0: 5f4c 4f47 4749 4e47 0a09 0909 096d 5f70 _LOGGING.....m_p │ │ │ +0005bdf0: 632e 7065 6572 5f6c 6f67 2870 6565 725f c.peer_log(peer_ │ │ │ +0005be00: 6c6f 675f 616c 6572 743a 3a69 6e63 6f6d log_alert::incom │ │ │ +0005be10: 696e 675f 6d65 7373 6167 652c 2022 5554 ing_message, "UT │ │ │ +0005be20: 5f4d 4554 4144 4154 4122 0a09 0909 0909 _METADATA"...... │ │ │ +0005be30: 2c20 2270 6163 6b65 7420 746f 6f20 6269 , "packet too bi │ │ │ +0005be40: 6720 2564 222c 206c 656e 6774 6829 3b0a g %d", length);. │ │ │ +0005be50: 2365 6e64 6966 0a09 0909 096d 5f70 632e #endif.....m_pc. │ │ │ +0005be60: 6469 7363 6f6e 6e65 6374 2865 7272 6f72 disconnect(error │ │ │ +0005be70: 733a 3a69 6e76 616c 6964 5f6d 6574 6164 s::invalid_metad │ │ │ +0005be80: 6174 615f 6d65 7373 6167 652c 206f 7065 ata_message, ope │ │ │ +0005be90: 7261 7469 6f6e 5f74 3a3a 6269 7474 6f72 ration_t::bittor │ │ │ +0005bea0: 7265 6e74 2c20 7065 6572 5f63 6f6e 6e65 rent, peer_conne │ │ │ +0005beb0: 6374 696f 6e5f 696e 7465 7266 6163 653a ction_interface: │ │ │ +0005bec0: 3a70 6565 725f 6572 726f 7229 3b0a 0909 :peer_error);... │ │ │ +0005bed0: 0909 7265 7475 726e 2074 7275 653b 0a09 ..return true;.. │ │ │ +0005bee0: 0909 7d0a 0a09 0909 6966 2028 216d 5f70 ..}.....if (!m_p │ │ │ +0005bef0: 632e 7061 636b 6574 5f66 696e 6973 6865 c.packet_finishe │ │ │ +0005bf00: 6428 2929 2072 6574 7572 6e20 7472 7565 d()) return true │ │ │ +0005bf10: 3b0a 0a09 0909 6572 726f 725f 636f 6465 ;.....error_code │ │ │ +0005bf20: 2065 633b 0a09 0909 6264 6563 6f64 655f ec;....bdecode_ │ │ │ +0005bf30: 6e6f 6465 206d 7367 203d 2062 6465 636f node msg = bdeco │ │ │ +0005bf40: 6465 2862 6f64 792c 2065 6329 3b0a 0909 de(body, ec);... │ │ │ +0005bf50: 0969 6620 286d 7367 2e74 7970 6528 2920 .if (msg.type() │ │ │ +0005bf60: 213d 2062 6465 636f 6465 5f6e 6f64 653a != bdecode_node: │ │ │ +0005bf70: 3a64 6963 745f 7429 0a3c 2f70 7265 3e3c :dict_t).< │ │ │ +0005bf80: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +0005bfb0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +0005bfc0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/disab │ │ │ +0005bff0: 6c65 645f 6469 736b 5f69 6f2e 6370 703a led_disk_io.cpp: │ │ │ +0005c000: 3130 363c 2f61 3e3c 2f74 643e 3c74 643e 106 │ │ │ +0005c010: 6974 2077 6f75 6c64 2062 6520 6e69 6365 it would be nice │ │ │ +0005c020: 2074 6f20 7265 7475 726e 2061 2076 616c to return a val │ │ │ +0005c030: 6964 2068 6173 6820 6f66 207a 6572 6f65 id hash of zeroe │ │ │ +0005c040: 7320 6865 7265 3c2f 7464 3e3c 2f74 723e s here │ │ │ +0005c050: 3c74 7220 6964 3d22 3231 3322 2073 7479 │ │ │ +0005c080: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0005c090: 3c68 323e 6974 2077 6f75 6c64 2062 6520

    it would be │ │ │ +0005c0a0: 6e69 6365 2074 6f20 7265 7475 726e 2061 nice to return a │ │ │ +0005c0b0: 2076 616c 6964 2068 6173 6820 6f66 207a valid hash of z │ │ │ +0005c0c0: 6572 6f65 7320 6865 7265 3c2f 6832 3e3c eroes here

    < │ │ │ +0005c0d0: 6834 3e2e 2e2f 7372 632f 6469 7361 626c h4>../src/disabl │ │ │ +0005c0e0: 6564 5f64 6973 6b5f 696f 2e63 7070 3a31 ed_disk_io.cpp:1 │ │ │ +0005c0f0: 3036 3c2f 6834 3e3c 7072 6520 7374 796c 06
    ..});..}...bool
    │ │ │ +0005c140: 2061 7379 6e63 5f77 7269 7465 2873 746f   async_write(sto
    │ │ │ +0005c150: 7261 6765 5f69 6e64 6578 5f74 0a09 092c  rage_index_t...,
    │ │ │ +0005c160: 2070 6565 725f 7265 7175 6573 7420 636f   peer_request co
    │ │ │ +0005c170: 6e73 7426 616d 703b 2072 0a09 092c 2063  nst& r..., c
    │ │ │ +0005c180: 6861 7220 636f 6e73 742a 2c20 7374 643a  har const*, std:
    │ │ │ +0005c190: 3a73 6861 7265 645f 7074 7226 6c74 3b64  :shared_ptr<d
    │ │ │ +0005c1a0: 6973 6b5f 6f62 7365 7276 6572 2667 743b  isk_observer>
    │ │ │ +0005c1b0: 0a09 092c 2073 7464 3a3a 6675 6e63 7469  ..., std::functi
    │ │ │ +0005c1c0: 6f6e 266c 743b 766f 6964 2873 746f 7261  on<void(stora
    │ │ │ +0005c1d0: 6765 5f65 7272 6f72 2063 6f6e 7374 2661  ge_error const&a
    │ │ │ +0005c1e0: 6d70 3b29 2667 743b 2068 616e 646c 6572  mp;)> handler
    │ │ │ +0005c1f0: 0a09 092c 2064 6973 6b5f 6a6f 625f 666c  ..., disk_job_fl
    │ │ │ +0005c200: 6167 735f 7429 206f 7665 7272 6964 650a  ags_t) override.
    │ │ │ +0005c210: 097b 0a09 0954 4f52 5245 4e54 5f41 5353  .{...TORRENT_ASS
    │ │ │ +0005c220: 4552 5428 722e 6c65 6e67 7468 2026 6c74  ERT(r.length <
    │ │ │ +0005c230: 3b3d 2064 6566 6175 6c74 5f62 6c6f 636b  ;= default_block
    │ │ │ +0005c240: 5f73 697a 6529 3b0a 0909 544f 5252 454e  _size);...TORREN
    │ │ │ +0005c250: 545f 554e 5553 4544 2872 293b 0a0a 0909  T_UNUSED(r);....
    │ │ │ +0005c260: 706f 7374 286d 5f69 6f73 2c20 5b68 203d  post(m_ios, [h =
    │ │ │ +0005c270: 2073 7464 3a3a 6d6f 7665 2868 616e 646c   std::move(handl
    │ │ │ +0005c280: 6572 295d 207b 2068 2873 746f 7261 6765  er)] { h(storage
    │ │ │ +0005c290: 5f65 7272 6f72 7b7d 293b 207d 293b 0a09  _error{}); });..
    │ │ │ +0005c2a0: 0972 6574 7572 6e20 6661 6c73 653b 0a09  .return false;..
    │ │ │ +0005c2b0: 7d0a 0a09 766f 6964 2061 7379 6e63 5f68  }...void async_h
    │ │ │ +0005c2c0: 6173 6828 7374 6f72 6167 655f 696e 6465  ash(storage_inde
    │ │ │ +0005c2d0: 785f 740a 0909 2c20 7069 6563 655f 696e  x_t..., piece_in
    │ │ │ +0005c2e0: 6465 785f 7420 7069 6563 652c 2073 7061  dex_t piece, spa
    │ │ │ +0005c2f0: 6e26 6c74 3b73 6861 3235 365f 6861 7368  n<sha256_hash
    │ │ │ +0005c300: 2667 743b 2c20 6469 736b 5f6a 6f62 5f66  >, disk_job_f
    │ │ │ +0005c310: 6c61 6773 5f74 0a09 092c 2073 7464 3a3a  lags_t..., std::
    │ │ │ +0005c320: 6675 6e63 7469 6f6e 266c 743b 766f 6964  function<void
    │ │ │ +0005c330: 2870 6965 6365 5f69 6e64 6578 5f74 2c20  (piece_index_t, 
    │ │ │ +0005c340: 7368 6131 5f68 6173 6820 636f 6e73 7426  sha1_hash const&
    │ │ │ +0005c350: 616d 703b 2c20 7374 6f72 6167 655f 6572  amp;, storage_er
    │ │ │ +0005c360: 726f 7220 636f 6e73 7426 616d 703b 2926  ror const&)&
    │ │ │ +0005c370: 6774 3b20 6861 6e64 6c65 7229 206f 7665  gt; handler) ove
    │ │ │ +0005c380: 7272 6964 650a 097b 0a3c 6469 7620 7374  rride..{.
    ..post(m_ │ │ │ +0005c3c0: 696f 732c 205b 6820 3d20 7374 643a 3a6d ios, [h = std::m │ │ │ +0005c3d0: 6f76 6528 6861 6e64 6c65 7229 2c20 7069 ove(handler), pi │ │ │ +0005c3e0: 6563 655d 207b 2068 2870 6965 6365 2c20 ece] { h(piece, │ │ │ +0005c3f0: 7368 6131 5f68 6173 687b 7d2c 2073 746f sha1_hash{}, sto │ │ │ +0005c400: 7261 6765 5f65 7272 6f72 7b7d 293b 207d rage_error{}); } │ │ │ +0005c410: 293b 0a3c 2f64 6976 3e09 7d0a 0a09 766f );.
    .}...vo │ │ │ +0005c420: 6964 2061 7379 6e63 5f68 6173 6832 2873 id async_hash2(s │ │ │ +0005c430: 746f 7261 6765 5f69 6e64 6578 5f74 2c20 torage_index_t, │ │ │ +0005c440: 7069 6563 655f 696e 6465 785f 7420 7069 piece_index_t pi │ │ │ +0005c450: 6563 652c 2069 6e74 0a09 092c 2064 6973 ece, int..., dis │ │ │ +0005c460: 6b5f 6a6f 625f 666c 6167 735f 740a 0909 k_job_flags_t... │ │ │ +0005c470: 2c20 7374 643a 3a66 756e 6374 696f 6e26 , std::function& │ │ │ +0005c480: 6c74 3b76 6f69 6428 7069 6563 655f 696e lt;void(piece_in │ │ │ +0005c490: 6465 785f 742c 2073 6861 3235 365f 6861 dex_t, sha256_ha │ │ │ +0005c4a0: 7368 2063 6f6e 7374 2661 6d70 3b2c 2073 sh const&, s │ │ │ +0005c4b0: 746f 7261 6765 5f65 7272 6f72 2063 6f6e torage_error con │ │ │ +0005c4c0: 7374 2661 6d70 3b29 2667 743b 2068 616e st&)> han │ │ │ +0005c4d0: 646c 6572 2920 6f76 6572 7269 6465 0a09 dler) override.. │ │ │ +0005c4e0: 7b0a 0909 706f 7374 286d 5f69 6f73 2c20 {...post(m_ios, │ │ │ +0005c4f0: 5b68 203d 2073 7464 3a3a 6d6f 7665 2868 [h = std::move(h │ │ │ +0005c500: 616e 646c 6572 292c 2070 6965 6365 5d28 andler), piece]( │ │ │ +0005c510: 2920 7b20 6828 7069 6563 652c 2073 6861 ) { h(piece, sha │ │ │ +0005c520: 3235 365f 6861 7368 7b7d 2c20 7374 6f72 256_hash{}, stor │ │ │ +0005c530: 6167 655f 6572 726f 727b 7d29 3b20 7d29 age_error{}); }) │ │ │ +0005c540: 3b0a 097d 0a0a 0976 6f69 6420 6173 796e ;..}...void asyn │ │ │ +0005c550: 635f 6d6f 7665 5f73 746f 7261 6765 2873 c_move_storage(s │ │ │ +0005c560: 746f 7261 6765 5f69 6e64 6578 5f74 0a09 torage_index_t.. │ │ │ +0005c570: 092c 2073 7464 3a3a 7374 7269 6e67 2070 ., std::string p │ │ │ +0005c580: 2c20 6d6f 7665 5f66 6c61 6773 5f74 0a09 , move_flags_t.. │ │ │ +0005c590: 092c 2073 7464 3a3a 6675 6e63 7469 6f6e ., std::function │ │ │ +0005c5a0: 266c 743b 766f 6964 2873 7461 7475 735f <void(status_ │ │ │ +0005c5b0: 742c 2073 7464 3a3a 7374 7269 6e67 2063 t, std::string c │ │ │ +0005c5c0: 6f6e 7374 2661 6d70 3b2c 2073 746f 7261 onst&, stora │ │ │ +0005c5d0: 6765 5f65 7272 6f72 2063 6f6e 7374 2661 ge_error const&a │ │ │ +0005c5e0: 6d70 3b29 2667 743b 2068 616e 646c 6572 mp;)> handler │ │ │ +0005c5f0: 2920 6f76 6572 7269 6465 0a09 7b0a 0909 ) override..{... │ │ │ +0005c600: 706f 7374 286d 5f69 6f73 2c20 5b68 203d post(m_ios, [h = │ │ │ +0005c610: 2073 7464 3a3a 6d6f 7665 2868 616e 646c std::move(handl │ │ │ +0005c620: 6572 292c 2070 6174 6820 3d20 7374 643a er), path = std: │ │ │ +0005c630: 3a6d 6f76 6528 7029 5d20 2829 206d 7574 :move(p)] () mut │ │ │ +0005c640: 6162 6c65 0a09 0909 7b20 6828 7374 6174 able....{ h(stat │ │ │ +0005c650: 7573 5f74 3a3a 6e6f 5f65 7272 6f72 2c20 us_t::no_error, │ │ │ +0005c660: 7374 643a 3a6d 6f76 6528 7061 7468 292c std::move(path), │ │ │ +0005c670: 2073 746f 7261 6765 5f65 7272 6f72 7b7d storage_error{} │ │ │ +0005c680: 293b 207d 293b 0a09 7d0a 0a09 766f 6964 ); });..}...void │ │ │ +0005c690: 2061 7379 6e63 5f72 656c 6561 7365 5f66 async_release_f │ │ │ +0005c6a0: 696c 6573 2873 746f 7261 6765 5f69 6e64 iles(storage_ind │ │ │ +0005c6b0: 6578 5f74 2c20 7374 643a 3a66 756e 6374 ex_t, std::funct │ │ │ +0005c6c0: 696f 6e26 6c74 3b76 6f69 6428 2926 6774 ion<void()> │ │ │ +0005c6d0: 3b20 6861 6e64 6c65 7229 206f 7665 7272 ; handler) overr │ │ │ +0005c6e0: 6964 650a 097b 0a09 0970 6f73 7428 6d5f ide..{...post(m_ │ │ │ +0005c6f0: 696f 732c 205b 6820 3d20 7374 643a 3a6d ios, [h = std::m │ │ │ +0005c700: 6f76 6528 6861 6e64 6c65 7229 5d20 7b20 ove(handler)] { │ │ │ +0005c710: 6828 293b 207d 293b 0a09 7d0a 0a09 766f h(); });..}...vo │ │ │ +0005c720: 6964 2061 7379 6e63 5f64 656c 6574 655f id async_delete_ │ │ │ +0005c730: 6669 6c65 7328 7374 6f72 6167 655f 696e files(storage_in │ │ │ +0005c740: 6465 785f 740a 0909 2c20 7265 6d6f 7665 dex_t..., remove │ │ │ +0005c750: 5f66 6c61 6773 5f74 2c20 7374 643a 3a66 _flags_t, std::f │ │ │ +0005c760: 756e 6374 696f 6e26 6c74 3b76 6f69 6428 unction<void( │ │ │ +0005c770: 7374 6f72 6167 655f 6572 726f 7220 636f storage_error co │ │ │ +0005c780: 6e73 7426 616d 703b 2926 6774 3b20 6861 nst&)> ha │ │ │ +0005c790: 6e64 6c65 7229 206f 7665 7272 6964 650a ndler) override. │ │ │ +0005c7a0: 097b 0a09 0970 6f73 7428 6d5f 696f 732c .{...post(m_ios, │ │ │ +0005c7b0: 205b 6820 3d20 7374 643a 3a6d 6f76 6528 [h = std::move( │ │ │ +0005c7c0: 6861 6e64 6c65 7229 5d20 7b20 6828 7374 handler)] { h(st │ │ │ +0005c7d0: 6f72 6167 655f 6572 726f 727b 7d29 3b20 orage_error{}); │ │ │ +0005c7e0: 7d29 3b0a 097d 0a0a 0976 6f69 6420 6173 });..}...void as │ │ │ +0005c7f0: 796e 635f 6368 6563 6b5f 6669 6c65 7328 ync_check_files( │ │ │ +0005c800: 7374 6f72 6167 655f 696e 6465 785f 740a storage_index_t. │ │ │ +0005c810: 0909 2c20 6164 645f 746f 7272 656e 745f .., add_torrent_ │ │ │ +0005c820: 7061 7261 6d73 2063 6f6e 7374 2a0a 3c2f params const*.r │ │ │ +0005c860: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +0005c870: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +0005c8a0: 7069 6563 655f 7069 636b 6572 2e63 7070 piece_picker.cpp │ │ │ +0005c8b0: 3a31 3231 3c2f 613e 3c2f 7464 3e3c 7464 :121find a better p │ │ │ +0005c8d0: 6c61 6365 2066 6f72 2074 6869 733c 2f74 lace for this

    find │ │ │ +0005c930: 6120 6265 7474 6572 2070 6c61 6365 2066 a better place f │ │ │ +0005c940: 6f72 2074 6869 733c 2f68 323e 3c68 343e or this

    │ │ │ +0005c950: 2e2e 2f73 7263 2f70 6965 6365 5f70 6963 ../src/piece_pic │ │ │ +0005c960: 6b65 722e 6370 703a 3132 313c 2f68 343e ker.cpp:121

    │ │ │ +0005c970: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ...if 
    │ │ │ +0005c9b0: 286c 696d 6974 203d 3d20 3029 0a09 0909  (limit == 0)....
    │ │ │ +0005c9c0: 7b0a 0909 0909 7374 643a 3a63 6572 7220  {.....std::cerr 
    │ │ │ +0005c9d0: 266c 743b 266c 743b 2022 202e 2e2e 223b  << " ...";
    │ │ │ +0005c9e0: 0a09 0909 0962 7265 616b 3b0a 0909 097d  .....break;....}
    │ │ │ +0005c9f0: 0a09 0909 6966 2028 2a69 203d 3d20 2d31  ....if (*i == -1
    │ │ │ +0005ca00: 2920 6272 6561 6b3b 0a09 0909 7768 696c  ) break;....whil
    │ │ │ +0005ca10: 6520 286a 2021 3d20 702e 6d5f 7072 696f  e (j != p.m_prio
    │ │ │ +0005ca20: 7269 7479 5f62 6f75 6e64 6172 6965 732e  rity_boundaries.
    │ │ │ +0005ca30: 656e 6428 2920 2661 6d70 3b26 616d 703b  end() &&
    │ │ │ +0005ca40: 202a 6a20 266c 743b 3d20 696e 6465 7829   *j <= index)
    │ │ │ +0005ca50: 0a09 0909 7b0a 0909 0909 7374 643a 3a63  ....{.....std::c
    │ │ │ +0005ca60: 6572 7220 266c 743b 266c 743b 2022 7c20  err << "| 
    │ │ │ +0005ca70: 223b 0a09 0909 092b 2b6a 3b0a 0909 097d  ";.....++j;....}
    │ │ │ +0005ca80: 0a09 0909 7374 643a 3a63 6572 7220 266c  ....std::cerr &l
    │ │ │ +0005ca90: 743b 266c 743b 202a 6920 266c 743b 266c  t;< *i <&l
    │ │ │ +0005caa0: 743b 2022 2822 2026 6c74 3b26 6c74 3b20  t; "(" << 
    │ │ │ +0005cab0: 702e 6d5f 7069 6563 655f 6d61 705b 2a69  p.m_piece_map[*i
    │ │ │ +0005cac0: 5d2e 696e 6465 7820 266c 743b 266c 743b  ].index <<
    │ │ │ +0005cad0: 2022 2920 223b 0a09 0909 2d2d 6c69 6d69   ") ";....--limi
    │ │ │ +0005cae0: 743b 0a09 097d 0a09 0973 7464 3a3a 6365  t;...}...std::ce
    │ │ │ +0005caf0: 7272 2026 6c74 3b26 6c74 3b20 7374 643a  rr << std:
    │ │ │ +0005cb00: 3a65 6e64 6c3b 0a09 7d0a 7d0a 2365 6e64  :endl;..}.}.#end
    │ │ │ +0005cb10: 6966 202f 2f20 544f 5252 454e 545f 5049  if // TORRENT_PI
    │ │ │ +0005cb20: 434b 4552 5f4c 4f47 0a6e 616d 6573 7061  CKER_LOG.namespa
    │ │ │ +0005cb30: 6365 206c 6962 746f 7272 656e 7420 7b0a  ce libtorrent {.
    │ │ │ +0005cb40: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +0005cb70: 636f 6e73 7420 7069 6563 655f 626c 6f63 const piece_bloc │ │ │ +0005cb80: 6b20 7069 6563 655f 626c 6f63 6b3a 3a69 k piece_block::i │ │ │ +0005cb90: 6e76 616c 6964 280a 3c2f 6469 763e 0909 nvalid(.
    .. │ │ │ +0005cba0: 7374 643a 3a6e 756d 6572 6963 5f6c 696d std::numeric_lim │ │ │ +0005cbb0: 6974 7326 6c74 3b70 6965 6365 5f69 6e64 its<piece_ind │ │ │ +0005cbc0: 6578 5f74 2667 743b 3a3a 6d61 7828 290a ex_t>::max(). │ │ │ +0005cbd0: 0909 2c20 7374 643a 3a6e 756d 6572 6963 .., std::numeric │ │ │ +0005cbe0: 5f6c 696d 6974 7326 6c74 3b69 6e74 2667 _limits<int&g │ │ │ +0005cbf0: 743b 3a3a 6d61 7828 2929 3b0a 0a09 636f t;::max());...co │ │ │ +0005cc00: 6e73 7465 7870 7220 7072 696f 5f69 6e64 nstexpr prio_ind │ │ │ +0005cc10: 6578 5f74 2070 6965 6365 5f70 6963 6b65 ex_t piece_picke │ │ │ +0005cc20: 723a 3a70 6965 6365 5f70 6f73 3a3a 7765 r::piece_pos::we │ │ │ +0005cc30: 5f68 6176 655f 696e 6465 783b 0a0a 0963 _have_index;...c │ │ │ +0005cc40: 6f6e 7374 6578 7072 2070 6963 6b65 725f onstexpr picker_ │ │ │ +0005cc50: 6f70 7469 6f6e 735f 7420 7069 6563 655f options_t piece_ │ │ │ +0005cc60: 7069 636b 6572 3a3a 7261 7265 7374 5f66 picker::rarest_f │ │ │ +0005cc70: 6972 7374 3b0a 0963 6f6e 7374 6578 7072 irst;..constexpr │ │ │ +0005cc80: 2070 6963 6b65 725f 6f70 7469 6f6e 735f picker_options_ │ │ │ +0005cc90: 7420 7069 6563 655f 7069 636b 6572 3a3a t piece_picker:: │ │ │ +0005cca0: 7265 7665 7273 653b 0a09 636f 6e73 7465 reverse;..conste │ │ │ +0005ccb0: 7870 7220 7069 636b 6572 5f6f 7074 696f xpr picker_optio │ │ │ +0005ccc0: 6e73 5f74 2070 6965 6365 5f70 6963 6b65 ns_t piece_picke │ │ │ +0005ccd0: 723a 3a6f 6e5f 7061 726f 6c65 3b0a 0963 r::on_parole;..c │ │ │ +0005cce0: 6f6e 7374 6578 7072 2070 6963 6b65 725f onstexpr picker_ │ │ │ +0005ccf0: 6f70 7469 6f6e 735f 7420 7069 6563 655f options_t piece_ │ │ │ +0005cd00: 7069 636b 6572 3a3a 7072 696f 7269 7469 picker::prioriti │ │ │ +0005cd10: 7a65 5f70 6172 7469 616c 733b 0a09 636f ze_partials;..co │ │ │ +0005cd20: 6e73 7465 7870 7220 7069 636b 6572 5f6f nstexpr picker_o │ │ │ +0005cd30: 7074 696f 6e73 5f74 2070 6965 6365 5f70 ptions_t piece_p │ │ │ +0005cd40: 6963 6b65 723a 3a73 6571 7565 6e74 6961 icker::sequentia │ │ │ +0005cd50: 6c3b 0a09 636f 6e73 7465 7870 7220 7069 l;..constexpr pi │ │ │ +0005cd60: 636b 6572 5f6f 7074 696f 6e73 5f74 2070 cker_options_t p │ │ │ +0005cd70: 6965 6365 5f70 6963 6b65 723a 3a61 6c69 iece_picker::ali │ │ │ +0005cd80: 676e 5f65 7870 616e 6465 645f 7069 6563 gn_expanded_piec │ │ │ +0005cd90: 6573 3b0a 0963 6f6e 7374 6578 7072 2070 es;..constexpr p │ │ │ +0005cda0: 6963 6b65 725f 6f70 7469 6f6e 735f 7420 icker_options_t │ │ │ +0005cdb0: 7069 6563 655f 7069 636b 6572 3a3a 7069 piece_picker::pi │ │ │ +0005cdc0: 6563 655f 6578 7465 6e74 5f61 6666 696e ece_extent_affin │ │ │ +0005cdd0: 6974 793b 0a0a 0963 6f6e 7374 6578 7072 ity;...constexpr │ │ │ +0005cde0: 2064 6f77 6e6c 6f61 645f 7175 6575 655f download_queue_ │ │ │ +0005cdf0: 7420 7069 6563 655f 7069 636b 6572 3a3a t piece_picker:: │ │ │ +0005ce00: 7069 6563 655f 706f 733a 3a70 6965 6365 piece_pos::piece │ │ │ +0005ce10: 5f64 6f77 6e6c 6f61 6469 6e67 3b0a 0963 _downloading;..c │ │ │ +0005ce20: 6f6e 7374 6578 7072 2064 6f77 6e6c 6f61 onstexpr downloa │ │ │ +0005ce30: 645f 7175 6575 655f 7420 7069 6563 655f d_queue_t piece_ │ │ │ +0005ce40: 7069 636b 6572 3a3a 7069 6563 655f 706f picker::piece_po │ │ │ +0005ce50: 733a 3a70 6965 6365 5f66 756c 6c3b 0a09 s::piece_full;.. │ │ │ +0005ce60: 636f 6e73 7465 7870 7220 646f 776e 6c6f constexpr downlo │ │ │ +0005ce70: 6164 5f71 7565 7565 5f74 2070 6965 6365 ad_queue_t piece │ │ │ +0005ce80: 5f70 6963 6b65 723a 3a70 6965 6365 5f70 _picker::piece_p │ │ │ +0005ce90: 6f73 3a3a 7069 6563 655f 6669 6e69 7368 os::piece_finish │ │ │ +0005cea0: 6564 3b0a 0963 6f6e 7374 6578 7072 2064 ed;..constexpr d │ │ │ +0005ceb0: 6f77 6e6c 6f61 645f 7175 6575 655f 7420 ownload_queue_t │ │ │ +0005cec0: 7069 6563 655f 7069 636b 6572 3a3a 7069 piece_picker::pi │ │ │ +0005ced0: 6563 655f 706f 733a 3a70 6965 6365 5f7a ece_pos::piece_z │ │ │ +0005cee0: 6572 6f5f 7072 696f 3b0a 0963 6f6e 7374 ero_prio;..const │ │ │ +0005cef0: 6578 7072 2064 6f77 6e6c 6f61 645f 7175 expr download_qu │ │ │ +0005cf00: 6575 655f 7420 7069 6563 655f 7069 636b eue_t piece_pick │ │ │ +0005cf10: 6572 3a3a 7069 6563 655f 706f 733a 3a6e er::piece_pos::n │ │ │ +0005cf20: 756d 5f64 6f77 6e6c 6f61 645f 6361 7465 um_download_cate │ │ │ +0005cf30: 676f 7269 6573 3b0a 0963 6f6e 7374 6578 gories;..constex │ │ │ +0005cf40: 7072 2064 6f77 6e6c 6f61 645f 7175 6575 pr download_queu │ │ │ +0005cf50: 655f 7420 7069 6563 655f 7069 636b 6572 e_t piece_picker │ │ │ +0005cf60: 3a3a 7069 6563 655f 706f 733a 3a70 6965 ::piece_pos::pie │ │ │ +0005cf70: 6365 5f6f 7065 6e3b 0a09 636f 6e73 7465 ce_open;..conste │ │ │ +0005cf80: 7870 7220 646f 776e 6c6f 6164 5f71 7565 xpr download_que │ │ │ +0005cf90: 7565 5f74 2070 6965 6365 5f70 6963 6b65 ue_t piece_picke │ │ │ +0005cfa0: 723a 3a70 6965 6365 5f70 6f73 3a3a 7069 r::piece_pos::pi │ │ │ +0005cfb0: 6563 655f 646f 776e 6c6f 6164 696e 675f ece_downloading_ │ │ │ +0005cfc0: 7265 7665 7273 653b 0a09 636f 6e73 7465 reverse;..conste │ │ │ +0005cfd0: 7870 7220 646f 776e 6c6f 6164 5f71 7565 xpr download_que │ │ │ +0005cfe0: 7565 5f74 2070 6965 6365 5f70 6963 6b65 ue_t piece_picke │ │ │ +0005cff0: 723a 3a70 6965 6365 5f70 6f73 3a3a 7069 r::piece_pos::pi │ │ │ +0005d000: 6563 655f 6675 6c6c 5f72 6576 6572 7365 ece_full_reverse │ │ │ +0005d010: 3b0a 0a09 2f2f 2074 6865 206d 6178 206e ;...// the max n │ │ │ +0005d020: 756d 6265 7220 6f66 2062 6c6f 636b 7320 umber of blocks │ │ │ +0005d030: 746f 2063 7265 6174 6520 616e 2061 6666 to create an aff │ │ │ +0005d040: 696e 6974 7920 666f 720a 0963 6f6e 7374 inity for..const │ │ │ +0005d050: 6578 7072 2069 6e74 206d 6178 5f70 6965 expr int max_pie │ │ │ +0005d060: 6365 5f61 6666 696e 6974 795f 6578 7465 ce_affinity_exte │ │ │ +0005d070: 6e74 203d 2034 202a 2031 3032 3420 2a20 nt = 4 * 1024 * │ │ │ +0005d080: 3130 3234 202f 2064 6566 6175 6c74 5f62 1024 / default_b │ │ │ +0005d090: 6c6f 636b 5f73 697a 653b 0a0a 0970 6965 lock_size;...pie │ │ │ +0005d0a0: 6365 5f70 6963 6b65 723a 3a70 6965 6365 ce_picker::piece │ │ │ +0005d0b0: 5f70 6963 6b65 7228 7374 643a 3a69 6e74 _picker(std::int │ │ │ +0005d0c0: 3634 5f74 2063 6f6e 7374 2074 6f74 616c 64_t const total │ │ │ +0005d0d0: 5f73 697a 652c 2069 6e74 2063 6f6e 7374 _size, int const │ │ │ +0005d0e0: 2070 6965 6365 5f73 697a 6529 0a09 093a piece_size)...: │ │ │ +0005d0f0: 206d 5f70 7269 6f72 6974 795f 626f 756e m_priority_boun │ │ │ +0005d100: 6461 7269 6573 2831 2c20 6d5f 7069 6563 daries(1, m_piec │ │ │ +0005d110: 6573 2e65 6e64 5f69 6e64 6578 2829 290a es.end_index()). │ │ │ +0005d120: 097b 0a09 0954 4f52 5245 4e54 5f41 5353 .{...TORRENT_ASS │ │ │ +0005d130: 4552 5428 746f 7461 6c5f 7369 7a65 2026 ERT(total_size & │ │ │ +0005d140: 6774 3b20 3029 3b0a 0909 544f 5252 454e gt; 0);...TORREN │ │ │ +0005d150: 545f 4153 5345 5254 2870 6965 6365 5f73 T_ASSERT(piece_s │ │ │ +0005d160: 697a 6520 2667 743b 2030 293b 0a3c 2f70 ize > 0);.

    re │ │ │ +0005d1a0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/p │ │ │ +0005d1e0: 6965 6365 5f70 6963 6b65 722e 6370 703a iece_picker.cpp: │ │ │ +0005d1f0: 3230 3834 3c2f 613e 3c2f 7464 3e3c 7464 2084this could prob │ │ │ +0005d210: 6162 6c79 2062 6520 6f70 7469 6d69 7a65 ably be optimize │ │ │ +0005d220: 6420 6279 2069 6e63 7265 6d65 6e74 616c d by incremental │ │ │ +0005d230: 6c79 2063 616c 6c69 6e67 2070 6172 7469 ly calling parti │ │ │ +0005d240: 616c 5f73 6f72 7420 746f 2073 6f72 7420 al_sort to sort │ │ │ +0005d250: 6f6e 6520 6d6f 7265 2065 6c65 6d65 6e74 one more element │ │ │ +0005d260: 2069 6e20 7468 6520 6c69 7374 2e20 4265 in the list. Be │ │ │ +0005d270: 6361 7573 6520 6368 616e 6365 7320 6172 cause chances ar │ │ │ +0005d280: 6520 7468 6174 2077 6527 6c6c 206a 7573 e that we'll jus │ │ │ +0005d290: 7420 6e65 6564 2061 2073 696e 676c 6520 t need a single │ │ │ +0005d2a0: 7069 6563 652c 2061 6e64 206f 6e63 6520 piece, and once │ │ │ +0005d2b0: 7765 2776 6520 7069 636b 6564 2066 726f we've picked fro │ │ │ +0005d2c0: 6d20 6974 2077 6527 7265 2064 6f6e 652e m it we're done. │ │ │ +0005d2d0: 2053 6f72 7469 6e67 2074 6865 2072 6573 Sorting the res │ │ │ +0005d2e0: 7420 6f66 2074 6865 206c 6973 7420 696e t of the list in │ │ │ +0005d2f0: 2074 6861 7420 6361 7365 2069 7320 6120 that case is a │ │ │ +0005d300: 7761 7374 6520 6f66 2074 696d 652e 3c2f waste of time.

    this │ │ │ +0005d360: 2063 6f75 6c64 2070 726f 6261 626c 7920 could probably │ │ │ +0005d370: 6265 206f 7074 696d 697a 6564 2062 7920 be optimized by │ │ │ +0005d380: 696e 6372 656d 656e 7461 6c6c 790a 6361 incrementally.ca │ │ │ +0005d390: 6c6c 696e 6720 7061 7274 6961 6c5f 736f lling partial_so │ │ │ +0005d3a0: 7274 2074 6f20 736f 7274 206f 6e65 206d rt to sort one m │ │ │ +0005d3b0: 6f72 6520 656c 656d 656e 7420 696e 2074 ore element in t │ │ │ +0005d3c0: 6865 206c 6973 742e 2042 6563 6175 7365 he list. Because │ │ │ +0005d3d0: 0a63 6861 6e63 6573 2061 7265 2074 6861 .chances are tha │ │ │ +0005d3e0: 7420 7765 276c 6c20 6a75 7374 206e 6565 t we'll just nee │ │ │ +0005d3f0: 6420 6120 7369 6e67 6c65 2070 6965 6365 d a single piece │ │ │ +0005d400: 2c20 616e 6420 6f6e 6365 2077 6527 7665 , and once we've │ │ │ +0005d410: 0a70 6963 6b65 6420 6672 6f6d 2069 7420 .picked from it │ │ │ +0005d420: 7765 2772 6520 646f 6e65 2e20 536f 7274 we're done. Sort │ │ │ +0005d430: 696e 6720 7468 6520 7265 7374 206f 6620 ing the rest of │ │ │ +0005d440: 7468 6520 6c69 7374 2069 6e20 7468 6174 the list in that │ │ │ +0005d450: 0a63 6173 6520 6973 2061 2077 6173 7465 .case is a waste │ │ │ +0005d460: 206f 6620 7469 6d65 2e3c 2f68 323e 3c68 of time.

    ../src/piece_p │ │ │ +0005d480: 6963 6b65 722e 6370 703a 3230 3834 3c2f icker.cpp:2084
    ...
    │ │ │ +0005d4d0: 2f2f 206e 6f77 2c20 636f 7079 206f 7665  // now, copy ove
    │ │ │ +0005d4e0: 7220 7468 6520 706f 696e 7465 7273 2e20  r the pointers. 
    │ │ │ +0005d4f0: 5765 2061 6c73 6f20 6170 706c 7920 6120  We also apply a 
    │ │ │ +0005d500: 6669 6c74 6572 2068 6572 6520 746f 206e  filter here to n
    │ │ │ +0005d510: 6f74 0a09 0909 2f2f 2069 6e63 6c75 6465  ot....// include
    │ │ │ +0005d520: 2069 6e65 6c69 6769 626c 6520 7069 6563   ineligible piec
    │ │ │ +0005d530: 6573 2069 6e20 6365 7274 6169 6e20 6d6f  es in certain mo
    │ │ │ +0005d540: 6465 732e 2046 6f72 2069 6e73 7461 6e63  des. For instanc
    │ │ │ +0005d550: 652c 2061 2070 6965 6365 0a09 0909 2f2f  e, a piece....//
    │ │ │ +0005d560: 2074 6861 7420 7468 6520 6375 7272 656e   that the curren
    │ │ │ +0005d570: 7420 7065 6572 2064 6f65 736e 2774 2068  t peer doesn't h
    │ │ │ +0005d580: 6176 6520 6973 206e 6f74 2069 6e63 6c75  ave is not inclu
    │ │ │ +0005d590: 6465 642e 0a09 0909 666f 7220 2861 7574  ded.....for (aut
    │ │ │ +0005d5a0: 6f26 616d 703b 2064 7020 3a20 6d5f 646f  o& dp : m_do
    │ │ │ +0005d5b0: 776e 6c6f 6164 735b 7069 6563 655f 706f  wnloads[piece_po
    │ │ │ +0005d5c0: 733a 3a70 6965 6365 5f64 6f77 6e6c 6f61  s::piece_downloa
    │ │ │ +0005d5d0: 6469 6e67 5d29 0a09 0909 7b0a 0909 0909  ding])....{.....
    │ │ │ +0005d5e0: 7063 2e69 6e63 5f73 7461 7473 5f63 6f75  pc.inc_stats_cou
    │ │ │ +0005d5f0: 6e74 6572 2863 6f75 6e74 6572 733a 3a70  nter(counters::p
    │ │ │ +0005d600: 6965 6365 5f70 6963 6b65 725f 7061 7274  iece_picker_part
    │ │ │ +0005d610: 6961 6c5f 6c6f 6f70 7329 3b0a 0a09 0909  ial_loops);.....
    │ │ │ +0005d620: 0969 6620 2821 6973 5f70 6965 6365 5f66  .if (!is_piece_f
    │ │ │ +0005d630: 7265 6528 6470 2e69 6e64 6578 2c20 7069  ree(dp.index, pi
    │ │ │ +0005d640: 6563 6573 2929 2063 6f6e 7469 6e75 653b  eces)) continue;
    │ │ │ +0005d650: 0a0a 0909 0909 544f 5252 454e 545f 4153  ......TORRENT_AS
    │ │ │ +0005d660: 5345 5254 286d 5f70 6965 6365 5f6d 6170  SERT(m_piece_map
    │ │ │ +0005d670: 5b64 702e 696e 6465 785d 2e64 6f77 6e6c  [dp.index].downl
    │ │ │ +0005d680: 6f61 645f 7175 6575 6528 290a 0909 0909  oad_queue().....
    │ │ │ +0005d690: 093d 3d20 7069 6563 655f 706f 733a 3a70  .== piece_pos::p
    │ │ │ +0005d6a0: 6965 6365 5f64 6f77 6e6c 6f61 6469 6e67  iece_downloading
    │ │ │ +0005d6b0: 293b 0a0a 0909 0909 6f72 6465 7265 645f  );......ordered_
    │ │ │ +0005d6c0: 7061 7274 6961 6c73 5b6e 756d 5f6f 7264  partials[num_ord
    │ │ │ +0005d6d0: 6572 6564 5f70 6172 7469 616c 732b 2b5d  ered_partials++]
    │ │ │ +0005d6e0: 203d 2026 616d 703b 6470 3b0a 0909 097d   = &dp;....}
    │ │ │ +0005d6f0: 0a0a 0909 092f 2f20 6e6f 772c 2073 6f72  .....// now, sor
    │ │ │ +0005d700: 7420 7468 6520 6c69 7374 2e0a 0909 0969  t the list.....i
    │ │ │ +0005d710: 6620 286f 7074 696f 6e73 2026 616d 703b  f (options &
    │ │ │ +0005d720: 2072 6172 6573 745f 6669 7273 7429 0a09   rarest_first)..
    │ │ │ +0005d730: 0909 7b0a 0909 0909 7265 7420 7c3d 2070  ..{.....ret |= p
    │ │ │ +0005d740: 6963 6b65 725f 6c6f 675f 616c 6572 743a  icker_log_alert:
    │ │ │ +0005d750: 3a72 6172 6573 745f 6669 7273 745f 7061  :rarest_first_pa
    │ │ │ +0005d760: 7274 6961 6c73 3b0a 0a3c 6469 7620 7374  rtials;..
    ....std:: │ │ │ +0005d7a0: 736f 7274 286f 7264 6572 6564 5f70 6172 sort(ordered_par │ │ │ +0005d7b0: 7469 616c 732e 6265 6769 6e28 292c 206f tials.begin(), o │ │ │ +0005d7c0: 7264 6572 6564 5f70 6172 7469 616c 732e rdered_partials. │ │ │ +0005d7d0: 6265 6769 6e28 2920 2b20 6e75 6d5f 6f72 begin() + num_or │ │ │ +0005d7e0: 6465 7265 645f 7061 7274 6961 6c73 0a3c dered_partials.< │ │ │ +0005d7f0: 2f64 6976 3e09 0909 0909 2c20 7374 643a /div>....., std: │ │ │ +0005d800: 3a62 696e 6428 2661 6d70 3b70 6965 6365 :bind(&piece │ │ │ +0005d810: 5f70 6963 6b65 723a 3a70 6172 7469 616c _picker::partial │ │ │ +0005d820: 5f63 6f6d 7061 7265 5f72 6172 6573 745f _compare_rarest_ │ │ │ +0005d830: 6669 7273 742c 2074 6869 730a 0909 0909 first, this..... │ │ │ +0005d840: 0909 2c20 5f31 2c20 5f32 2929 3b0a 0909 .., _1, _2));... │ │ │ +0005d850: 097d 0a0a 0909 0966 6f72 2028 696e 7420 .}.....for (int │ │ │ +0005d860: 6920 3d20 303b 2069 2026 6c74 3b20 6e75 i = 0; i < nu │ │ │ +0005d870: 6d5f 6f72 6465 7265 645f 7061 7274 6961 m_ordered_partia │ │ │ +0005d880: 6c73 3b20 2b2b 6929 0a09 0909 7b0a 0909 ls; ++i)....{... │ │ │ +0005d890: 0909 7265 7420 7c3d 2070 6963 6b65 725f ..ret |= picker_ │ │ │ +0005d8a0: 6c6f 675f 616c 6572 743a 3a70 7269 6f72 log_alert::prior │ │ │ +0005d8b0: 6974 697a 655f 7061 7274 6961 6c73 3b0a itize_partials;. │ │ │ +0005d8c0: 0a09 0909 096e 756d 5f62 6c6f 636b 7320 .....num_blocks │ │ │ +0005d8d0: 3d20 6164 645f 626c 6f63 6b73 5f64 6f77 = add_blocks_dow │ │ │ +0005d8e0: 6e6c 6f61 6469 6e67 282a 6f72 6465 7265 nloading(*ordere │ │ │ +0005d8f0: 645f 7061 7274 6961 6c73 5b69 5d2c 2070 d_partials[i], p │ │ │ +0005d900: 6965 6365 730a 0909 0909 092c 2069 6e74 ieces......, int │ │ │ +0005d910: 6572 6573 7469 6e67 5f62 6c6f 636b 732c eresting_blocks, │ │ │ +0005d920: 2062 6163 6b75 705f 626c 6f63 6b73 2c20 backup_blocks, │ │ │ +0005d930: 6261 636b 7570 5f62 6c6f 636b 7332 0a09 backup_blocks2.. │ │ │ +0005d940: 0909 0909 2c20 6e75 6d5f 626c 6f63 6b73 ...., num_blocks │ │ │ +0005d950: 2c20 7072 6566 6572 5f63 6f6e 7469 6775 , prefer_contigu │ │ │ +0005d960: 6f75 735f 626c 6f63 6b73 2c20 7065 6572 ous_blocks, peer │ │ │ +0005d970: 2c20 6f70 7469 6f6e 7329 3b0a 0909 0909 , options);..... │ │ │ +0005d980: 6966 2028 6e75 6d5f 626c 6f63 6b73 2026 if (num_blocks & │ │ │ +0005d990: 6c74 3b3d 2030 2920 7265 7475 726e 2072 lt;= 0) return r │ │ │ +0005d9a0: 6574 3b0a 0909 0909 6966 2028 696e 7428 et;.....if (int( │ │ │ +0005d9b0: 6261 636b 7570 5f62 6c6f 636b 732e 7369 backup_blocks.si │ │ │ +0005d9c0: 7a65 2829 2920 2667 743b 3d20 6e75 6d5f ze()) >= num_ │ │ │ +0005d9d0: 626c 6f63 6b73 0a09 0909 0909 2661 6d70 blocks......& │ │ │ +0005d9e0: 3b26 616d 703b 2069 6e74 2862 6163 6b75 ;& int(backu │ │ │ +0005d9f0: 705f 626c 6f63 6b73 322e 7369 7a65 2829 p_blocks2.size() │ │ │ +0005da00: 2920 2667 743b 3d20 6e75 6d5f 626c 6f63 ) >= num_bloc │ │ │ +0005da10: 6b73 290a 0909 0909 0962 7265 616b 3b0a ks)......break;. │ │ │ +0005da20: 0909 097d 0a0a 0909 096e 756d 5f62 6c6f ...}.....num_blo │ │ │ +0005da30: 636b 7320 3d20 6170 7065 6e64 5f62 6c6f cks = append_blo │ │ │ +0005da40: 636b 7328 696e 7465 7265 7374 696e 675f cks(interesting_ │ │ │ +0005da50: 626c 6f63 6b73 2c20 6261 636b 7570 5f62 blocks, backup_b │ │ │ +0005da60: 6c6f 636b 730a 0909 0909 2c20 6e75 6d5f locks....., num_ │ │ │ +0005da70: 626c 6f63 6b73 293b 0a09 0909 6966 2028 blocks);....if ( │ │ │ +0005da80: 6e75 6d5f 626c 6f63 6b73 2026 6c74 3b3d num_blocks <= │ │ │ +0005da90: 2030 2920 7265 7475 726e 2072 6574 3b0a 0) return ret;. │ │ │ +0005daa0: 0a09 0909 6e75 6d5f 626c 6f63 6b73 203d ....num_blocks = │ │ │ +0005dab0: 2061 7070 656e 645f 626c 6f63 6b73 2869 append_blocks(i │ │ │ +0005dac0: 6e74 6572 6573 7469 6e67 5f62 6c6f 636b nteresting_block │ │ │ +0005dad0: 732c 2062 6163 6b75 705f 626c 6f63 6b73 s, backup_blocks │ │ │ +0005dae0: 320a 0909 0909 2c20 6e75 6d5f 626c 6f63 2....., num_bloc │ │ │ +0005daf0: 6b73 293b 0a09 0909 6966 2028 6e75 6d5f ks);....if (num_ │ │ │ +0005db00: 626c 6f63 6b73 2026 6c74 3b3d 2030 2920 blocks <= 0) │ │ │ +0005db10: 7265 7475 726e 2072 6574 3b0a 0909 7d0a return ret;...}. │ │ │ +0005db20: 0a09 0969 6620 2821 7375 6767 6573 7465 ...if (!suggeste │ │ │ +0005db30: 645f 7069 6563 6573 2e65 6d70 7479 2829 d_pieces.empty() │ │ │ +0005db40: 290a 0909 7b0a 0909 0966 6f72 2028 7069 )...{....for (pi │ │ │ +0005db50: 6563 655f 696e 6465 785f 7420 6920 3a20 ece_index_t i : │ │ │ +0005db60: 7375 6767 6573 7465 645f 7069 6563 6573 suggested_pieces │ │ │ +0005db70: 290a 0909 097b 0a3c 2f70 7265 3e3c 2f74 )....{.
    relevanc │ │ │ +0005dbb0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/piece_p │ │ │ +0005dbf0: 6963 6b65 722e 6370 703a 3232 3238 3c2f icker.cpp:2228Is it │ │ │ +0005dc10: 2061 2067 6f6f 6420 6964 6561 2074 6861 a good idea tha │ │ │ +0005dc20: 7420 7468 6973 2061 6666 696e 6974 7920 t this affinity │ │ │ +0005dc30: 7461 6b65 7320 7072 6563 6564 656e 6365 takes precedence │ │ │ +0005dc40: 206f 7665 7220 7069 6563 6520 7072 696f over piece prio │ │ │ +0005dc50: 7269 7479 3f3c 2f74 643e 3c2f 7472 3e3c rity?< │ │ │ +0005dc60: 7472 2069 643d 2232 3136 2220 7374 796c tr id="216" styl │ │ │ +0005dc70: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +0005dc80: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +0005dc90: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +0005dca0: 6832 3e49 7320 6974 2061 2067 6f6f 6420 h2>Is it a good │ │ │ +0005dcb0: 6964 6561 2074 6861 7420 7468 6973 2061 idea that this a │ │ │ +0005dcc0: 6666 696e 6974 7920 7461 6b65 7320 7072 ffinity takes pr │ │ │ +0005dcd0: 6563 6564 656e 6365 206f 7665 720a 7069 ecedence over.pi │ │ │ +0005dce0: 6563 6520 7072 696f 7269 7479 3f3c 2f68 ece priority?

    ../src/pie │ │ │ +0005dd00: 6365 5f70 6963 6b65 722e 6370 703a 3232 ce_picker.cpp:22 │ │ │ +0005dd10: 3238 3c2f 6834 3e3c 7072 6520 7374 796c 28

    .....prio_index
    │ │ │ +0005dd60: 5f74 2063 6f6e 7374 2065 6e64 203d 2070  _t const end = p
    │ │ │ +0005dd70: 7269 6f72 6974 795f 656e 6428 6929 3b0a  riority_end(i);.
    │ │ │ +0005dd80: 0909 0909 0966 6f72 2028 7072 696f 5f69  .....for (prio_i
    │ │ │ +0005dd90: 6e64 6578 5f74 2070 203d 2070 7265 7628  ndex_t p = prev(
    │ │ │ +0005dda0: 656e 6429 3b20 7020 2667 743b 3d20 7374  end); p >= st
    │ │ │ +0005ddb0: 6172 743b 202d 2d70 290a 0909 0909 097b  art; --p)......{
    │ │ │ +0005ddc0: 0a09 0909 0909 0970 632e 696e 635f 7374  .......pc.inc_st
    │ │ │ +0005ddd0: 6174 735f 636f 756e 7465 7228 636f 756e  ats_counter(coun
    │ │ │ +0005dde0: 7465 7273 3a3a 7069 6563 655f 7069 636b  ters::piece_pick
    │ │ │ +0005ddf0: 6572 5f72 6576 6572 7365 5f72 6172 655f  er_reverse_rare_
    │ │ │ +0005de00: 6c6f 6f70 7329 3b0a 0a09 0909 0909 0969  loops);........i
    │ │ │ +0005de10: 6620 2821 6973 5f70 6965 6365 5f66 7265  f (!is_piece_fre
    │ │ │ +0005de20: 6528 6d5f 7069 6563 6573 5b70 5d2c 2070  e(m_pieces[p], p
    │ │ │ +0005de30: 6965 6365 7329 2920 636f 6e74 696e 7565  ieces)) continue
    │ │ │ +0005de40: 3b0a 0a09 0909 0909 0972 6574 207c 3d20  ;........ret |= 
    │ │ │ +0005de50: 7069 636b 6572 5f6c 6f67 5f61 6c65 7274  picker_log_alert
    │ │ │ +0005de60: 3a3a 7265 7665 7273 655f 7261 7265 7374  ::reverse_rarest
    │ │ │ +0005de70: 5f66 6972 7374 3b0a 0a09 0909 0909 096e  _first;........n
    │ │ │ +0005de80: 756d 5f62 6c6f 636b 7320 3d20 6164 645f  um_blocks = add_
    │ │ │ +0005de90: 626c 6f63 6b73 286d 5f70 6965 6365 735b  blocks(m_pieces[
    │ │ │ +0005dea0: 705d 2c20 7069 6563 6573 0a09 0909 0909  p], pieces......
    │ │ │ +0005deb0: 0909 2c20 696e 7465 7265 7374 696e 675f  .., interesting_
    │ │ │ +0005dec0: 626c 6f63 6b73 2c20 6261 636b 7570 5f62  blocks, backup_b
    │ │ │ +0005ded0: 6c6f 636b 730a 0909 0909 0909 092c 2062  locks........, b
    │ │ │ +0005dee0: 6163 6b75 705f 626c 6f63 6b73 322c 206e  ackup_blocks2, n
    │ │ │ +0005def0: 756d 5f62 6c6f 636b 730a 0909 0909 0909  um_blocks.......
    │ │ │ +0005df00: 092c 2070 7265 6665 725f 636f 6e74 6967  ., prefer_contig
    │ │ │ +0005df10: 756f 7573 5f62 6c6f 636b 732c 2070 6565  uous_blocks, pee
    │ │ │ +0005df20: 722c 2069 676e 6f72 6564 5f70 6965 6365  r, ignored_piece
    │ │ │ +0005df30: 730a 0909 0909 0909 092c 206f 7074 696f  s........, optio
    │ │ │ +0005df40: 6e73 293b 0a09 0909 0909 0969 6620 286e  ns);.......if (n
    │ │ │ +0005df50: 756d 5f62 6c6f 636b 7320 266c 743b 3d20  um_blocks <= 
    │ │ │ +0005df60: 3029 2072 6574 7572 6e20 7265 743b 0a09  0) return ret;..
    │ │ │ +0005df70: 0909 0909 7d0a 0909 0909 7d0a 0909 097d  ....}.....}....}
    │ │ │ +0005df80: 0a09 0909 656c 7365 0a09 0909 7b0a 3c64  ....else....{.....
    │ │ │ +0005dfc0: 6966 2028 6f70 7469 6f6e 7320 2661 6d70  if (options &
    │ │ │ +0005dfd0: 3b20 7069 6563 655f 6578 7465 6e74 5f61  ; piece_extent_a
    │ │ │ +0005dfe0: 6666 696e 6974 7929 0a3c 2f64 6976 3e09  ffinity).
    . │ │ │ +0005dff0: 0909 097b 0a09 0909 0909 696e 7420 746f ...{......int to │ │ │ +0005e000: 5f65 7261 7365 203d 202d 313b 0a09 0909 _erase = -1;.... │ │ │ +0005e010: 0909 696e 7420 6964 7820 3d20 2d31 3b0a ..int idx = -1;. │ │ │ +0005e020: 0909 0909 0966 6f72 2028 7069 6563 655f .....for (piece_ │ │ │ +0005e030: 6578 7465 6e74 5f74 2063 6f6e 7374 2065 extent_t const e │ │ │ +0005e040: 203a 206d 5f72 6563 656e 745f 6578 7465 : m_recent_exte │ │ │ +0005e050: 6e74 7329 0a09 0909 0909 7b0a 0909 0909 nts)......{..... │ │ │ +0005e060: 0909 2b2b 6964 783b 0a09 0909 0909 0962 ..++idx;.......b │ │ │ +0005e070: 6f6f 6c20 6861 7665 5f61 6c6c 203d 2074 ool have_all = t │ │ │ +0005e080: 7275 653b 0a09 0909 0909 0966 6f72 2028 rue;.......for ( │ │ │ +0005e090: 7069 6563 655f 696e 6465 785f 7420 636f piece_index_t co │ │ │ +0005e0a0: 6e73 7420 7020 3a20 6578 7465 6e74 5f66 nst p : extent_f │ │ │ +0005e0b0: 6f72 2865 2929 0a09 0909 0909 097b 0a09 or(e)).......{.. │ │ │ +0005e0c0: 0909 0909 0909 6966 2028 216d 5f70 6965 ......if (!m_pie │ │ │ +0005e0d0: 6365 5f6d 6170 5b70 5d2e 6861 7665 2829 ce_map[p].have() │ │ │ +0005e0e0: 2920 6861 7665 5f61 6c6c 203d 2066 616c ) have_all = fal │ │ │ +0005e0f0: 7365 3b0a 0909 0909 0909 0969 6620 2821 se;........if (! │ │ │ +0005e100: 6973 5f70 6965 6365 5f66 7265 6528 702c is_piece_free(p, │ │ │ +0005e110: 2070 6965 6365 7329 2920 636f 6e74 696e pieces)) contin │ │ │ +0005e120: 7565 3b0a 0a09 0909 0909 0909 7265 7420 ue;.........ret │ │ │ +0005e130: 7c3d 2070 6963 6b65 725f 6c6f 675f 616c |= picker_log_al │ │ │ +0005e140: 6572 743a 3a65 7874 656e 745f 6166 6669 ert::extent_affi │ │ │ +0005e150: 6e69 7479 3b0a 0a09 0909 0909 0909 6e75 nity;.........nu │ │ │ +0005e160: 6d5f 626c 6f63 6b73 203d 2061 6464 5f62 m_blocks = add_b │ │ │ +0005e170: 6c6f 636b 7328 702c 2070 6965 6365 730a locks(p, pieces. │ │ │ +0005e180: 0909 0909 0909 0909 2c20 696e 7465 7265 ........, intere │ │ │ +0005e190: 7374 696e 675f 626c 6f63 6b73 2c20 6261 sting_blocks, ba │ │ │ +0005e1a0: 636b 7570 5f62 6c6f 636b 730a 0909 0909 ckup_blocks..... │ │ │ +0005e1b0: 0909 0909 2c20 6261 636b 7570 5f62 6c6f ...., backup_blo │ │ │ +0005e1c0: 636b 7332 2c20 6e75 6d5f 626c 6f63 6b73 cks2, num_blocks │ │ │ +0005e1d0: 0a09 0909 0909 0909 092c 2070 7265 6665 ........., prefe │ │ │ +0005e1e0: 725f 636f 6e74 6967 756f 7573 5f62 6c6f r_contiguous_blo │ │ │ +0005e1f0: 636b 732c 2070 6565 722c 2069 676e 6f72 cks, peer, ignor │ │ │ +0005e200: 6564 5f70 6965 6365 730a 0909 0909 0909 ed_pieces....... │ │ │ +0005e210: 0909 2c20 6f70 7469 6f6e 7329 3b0a 0909 .., options);... │ │ │ +0005e220: 0909 0909 0969 6620 286e 756d 5f62 6c6f .....if (num_blo │ │ │ +0005e230: 636b 7320 266c 743b 3d20 3029 0a09 0909 cks <= 0).... │ │ │ +0005e240: 0909 0909 7b0a 0909 0909 0909 0909 2f2f ....{.........// │ │ │ +0005e250: 2069 6620 7765 2068 6176 6520 616c 6c20 if we have all │ │ │ +0005e260: 7069 6563 6573 2062 656c 6f6e 6769 6e67 pieces belonging │ │ │ +0005e270: 2074 6f20 7468 6973 2065 7874 656e 742c to this extent, │ │ │ +0005e280: 2072 656d 6f76 6520 6974 0a09 0909 0909 remove it...... │ │ │ +0005e290: 0909 0969 6620 2874 6f5f 6572 6173 6520 ...if (to_erase │ │ │ +0005e2a0: 213d 202d 3129 206d 5f72 6563 656e 745f != -1) m_recent_ │ │ │ +0005e2b0: 6578 7465 6e74 732e 6572 6173 6528 6d5f extents.erase(m_ │ │ │ +0005e2c0: 7265 6365 6e74 5f65 7874 656e 7473 2e62 recent_extents.b │ │ │ +0005e2d0: 6567 696e 2829 202b 2074 6f5f 6572 6173 egin() + to_eras │ │ │ +0005e2e0: 6529 3b0a 0909 0909 0909 0909 7265 7475 e);.........retu │ │ │ +0005e2f0: 726e 2072 6574 3b0a 0909 0909 0909 097d rn ret;........} │ │ │ +0005e300: 0a09 0909 0909 097d 0a09 0909 0909 092f .......}......./ │ │ │ +0005e310: 2f20 6966 2077 6520 6861 7665 2061 6c6c / if we have all │ │ │ +0005e320: 2070 6965 6365 7320 6265 6c6f 6e67 696e pieces belongin │ │ │ +0005e330: 6720 746f 2074 6869 7320 6578 7465 6e74 g to this extent │ │ │ +0005e340: 2c20 7265 6d6f 7665 2069 740a 0909 0909 , remove it..... │ │ │ +0005e350: 0909 6966 2028 6861 7665 5f61 6c6c 2920 ..if (have_all) │ │ │ +0005e360: 746f 5f65 7261 7365 203d 2069 6478 3b0a to_erase = idx;. │ │ │ +0005e370: 0909 0909 097d 0a09 0909 0909 6966 2028 .....}......if ( │ │ │ +0005e380: 746f 5f65 7261 7365 2021 3d20 2d31 2920 to_erase != -1) │ │ │ +0005e390: 6d5f 7265 6365 6e74 5f65 7874 656e 7473 m_recent_extents │ │ │ +0005e3a0: 2e65 7261 7365 286d 5f72 6563 656e 745f .erase(m_recent_ │ │ │ +0005e3b0: 6578 7465 6e74 732e 6265 6769 6e28 2920 extents.begin() │ │ │ +0005e3c0: 2b20 746f 5f65 7261 7365 293b 0a3c 2f70 + to_erase);.

    re │ │ │ +0005e400: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0
    ../src/p │ │ │ +0005e440: 6965 6365 5f70 6963 6b65 722e 6370 703a iece_picker.cpp: │ │ │ +0005e450: 3235 3833 3c2f 613e 3c2f 7464 3e3c 7464 2583when expanding │ │ │ +0005e470: 7069 6563 6573 2066 6f72 2063 6163 6865 pieces for cache │ │ │ +0005e480: 2073 7472 6970 6520 7265 6173 6f6e 732c stripe reasons, │ │ │ +0005e490: 2074 6865 2021 646f 776e 6c6f 6164 696e the !downloadin │ │ │ +0005e4a0: 6720 636f 6e64 6974 696f 6e20 646f 6573 g condition does │ │ │ +0005e4b0: 6e27 7420 6d61 6b65 206d 7563 6820 7365 n't make much se │ │ │ +0005e4c0: 6e73 653c 2f74 643e 3c2f 7472 3e3c 7472 nse

    when expanding │ │ │ +0005e520: 7069 6563 6573 2066 6f72 2063 6163 6865 pieces for cache │ │ │ +0005e530: 2073 7472 6970 6520 7265 6173 6f6e 732c stripe reasons, │ │ │ +0005e540: 0a74 6865 2021 646f 776e 6c6f 6164 696e .the !downloadin │ │ │ +0005e550: 6720 636f 6e64 6974 696f 6e20 646f 6573 g condition does │ │ │ +0005e560: 6e27 7420 6d61 6b65 206d 7563 6820 7365 n't make much se │ │ │ +0005e570: 6e73 653c 2f68 323e 3c68 343e 2e2e 2f73 nse

    ../s │ │ │ +0005e580: 7263 2f70 6965 6365 5f70 6963 6b65 722e rc/piece_picker. │ │ │ +0005e590: 6370 703a 3235 3833 3c2f 6834 3e3c 7072 cpp:2583

    ..TORRENT │ │ │ +0005e5e0: 5f41 5353 4552 5428 696e 6465 7820 266c _ASSERT(index &l │ │ │ +0005e5f0: 743b 206d 5f70 6965 6365 5f6d 6170 2e65 t; m_piece_map.e │ │ │ +0005e600: 6e64 5f69 6e64 6578 2829 293b 0a09 0969 nd_index());...i │ │ │ +0005e610: 6620 286e 6578 7428 696e 6465 7829 203d f (next(index) = │ │ │ +0005e620: 3d20 6d5f 7069 6563 655f 6d61 702e 656e = m_piece_map.en │ │ │ +0005e630: 645f 696e 6465 7828 2929 0a09 0909 7265 d_index())....re │ │ │ +0005e640: 7475 726e 206d 5f62 6c6f 636b 735f 696e turn m_blocks_in │ │ │ +0005e650: 5f6c 6173 745f 7069 6563 653b 0a09 0965 _last_piece;...e │ │ │ +0005e660: 6c73 650a 0909 0972 6574 7572 6e20 626c lse....return bl │ │ │ +0005e670: 6f63 6b73 5f70 6572 5f70 6965 6365 2829 ocks_per_piece() │ │ │ +0005e680: 3b0a 097d 0a0a 0962 6f6f 6c20 7069 6563 ;..}...bool piec │ │ │ +0005e690: 655f 7069 636b 6572 3a3a 6973 5f70 6965 e_picker::is_pie │ │ │ +0005e6a0: 6365 5f66 7265 6528 7069 6563 655f 696e ce_free(piece_in │ │ │ +0005e6b0: 6465 785f 7420 636f 6e73 7420 7069 6563 dex_t const piec │ │ │ +0005e6c0: 650a 0909 2c20 7479 7065 645f 6269 7466 e..., typed_bitf │ │ │ +0005e6d0: 6965 6c64 266c 743b 7069 6563 655f 696e ield<piece_in │ │ │ +0005e6e0: 6465 785f 7426 6774 3b20 636f 6e73 7426 dex_t> const& │ │ │ +0005e6f0: 616d 703b 2062 6974 6d61 736b 2920 636f amp; bitmask) co │ │ │ +0005e700: 6e73 740a 097b 0a09 0972 6574 7572 6e20 nst..{...return │ │ │ +0005e710: 6269 746d 6173 6b5b 7069 6563 655d 0a09 bitmask[piece].. │ │ │ +0005e720: 0909 2661 6d70 3b26 616d 703b 2021 6d5f ..&& !m_ │ │ │ +0005e730: 7069 6563 655f 6d61 705b 7069 6563 655d piece_map[piece] │ │ │ +0005e740: 2e68 6176 6528 290a 0909 0926 616d 703b .have()....& │ │ │ +0005e750: 2661 6d70 3b20 216d 5f70 6965 6365 5f6d & !m_piece_m │ │ │ +0005e760: 6170 5b70 6965 6365 5d2e 6669 6c74 6572 ap[piece].filter │ │ │ +0005e770: 6564 2829 3b0a 097d 0a0a 0962 6f6f 6c20 ed();..}...bool │ │ │ +0005e780: 7069 6563 655f 7069 636b 6572 3a3a 6361 piece_picker::ca │ │ │ +0005e790: 6e5f 7069 636b 2870 6965 6365 5f69 6e64 n_pick(piece_ind │ │ │ +0005e7a0: 6578 5f74 2063 6f6e 7374 2070 6965 6365 ex_t const piece │ │ │ +0005e7b0: 0a09 092c 2074 7970 6564 5f62 6974 6669 ..., typed_bitfi │ │ │ +0005e7c0: 656c 6426 6c74 3b70 6965 6365 5f69 6e64 eld<piece_ind │ │ │ +0005e7d0: 6578 5f74 2667 743b 2063 6f6e 7374 2661 ex_t> const&a │ │ │ +0005e7e0: 6d70 3b20 6269 746d 6173 6b29 2063 6f6e mp; bitmask) con │ │ │ +0005e7f0: 7374 0a09 7b0a 0909 7265 7475 726e 2062 st..{...return b │ │ │ +0005e800: 6974 6d61 736b 5b70 6965 6365 5d0a 0909 itmask[piece]... │ │ │ +0005e810: 0926 616d 703b 2661 6d70 3b20 216d 5f70 .&& !m_p │ │ │ +0005e820: 6965 6365 5f6d 6170 5b70 6965 6365 5d2e iece_map[piece]. │ │ │ +0005e830: 6861 7665 2829 0a3c 6469 7620 7374 796c have().
    ...&&am │ │ │ +0005e870: 703b 2021 6d5f 7069 6563 655f 6d61 705b p; !m_piece_map[ │ │ │ +0005e880: 7069 6563 655d 2e64 6f77 6e6c 6f61 6469 piece].downloadi │ │ │ +0005e890: 6e67 2829 0a3c 2f64 6976 3e09 0909 2661 ng().
    ...&a │ │ │ +0005e8a0: 6d70 3b26 616d 703b 2021 6d5f 7069 6563 mp;& !m_piec │ │ │ +0005e8b0: 655f 6d61 705b 7069 6563 655d 2e66 696c e_map[piece].fil │ │ │ +0005e8c0: 7465 7265 6428 293b 0a09 7d0a 0a23 6966 tered();..}..#if │ │ │ +0005e8d0: 2054 4f52 5245 4e54 5f55 5345 5f49 4e56 TORRENT_USE_INV │ │ │ +0005e8e0: 4152 4941 4e54 5f43 4845 434b 530a 0976 ARIANT_CHECKS..v │ │ │ +0005e8f0: 6f69 6420 7069 6563 655f 7069 636b 6572 oid piece_picker │ │ │ +0005e900: 3a3a 6368 6563 6b5f 7065 6572 7328 290a ::check_peers(). │ │ │ +0005e910: 097b 0a09 0966 6f72 2028 6175 746f 2063 .{...for (auto c │ │ │ +0005e920: 6f6e 7374 2661 6d70 3b20 6220 3a20 6d5f onst& b : m_ │ │ │ +0005e930: 626c 6f63 6b5f 696e 666f 290a 0909 7b0a block_info)...{. │ │ │ +0005e940: 0909 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0005e950: 5428 622e 7065 6572 203d 3d20 6e75 6c6c T(b.peer == null │ │ │ +0005e960: 7074 7220 7c7c 2073 7461 7469 635f 6361 ptr || static_ca │ │ │ +0005e970: 7374 266c 743b 746f 7272 656e 745f 7065 st<torrent_pe │ │ │ +0005e980: 6572 2a26 6774 3b28 622e 7065 6572 292d er*>(b.peer)- │ │ │ +0005e990: 2667 743b 696e 5f75 7365 293b 0a09 097d >in_use);...} │ │ │ +0005e9a0: 0a09 7d0a 2365 6e64 6966 0a0a 0976 6f69 ..}.#endif...voi │ │ │ +0005e9b0: 6420 7069 6563 655f 7069 636b 6572 3a3a d piece_picker:: │ │ │ +0005e9c0: 636c 6561 725f 7065 6572 2874 6f72 7265 clear_peer(torre │ │ │ +0005e9d0: 6e74 5f70 6565 722a 2070 6565 7229 0a09 nt_peer* peer).. │ │ │ +0005e9e0: 7b0a 0909 666f 7220 2861 7574 6f26 616d {...for (auto&am │ │ │ +0005e9f0: 703b 2062 203a 206d 5f62 6c6f 636b 5f69 p; b : m_block_i │ │ │ +0005ea00: 6e66 6f29 0a09 097b 0a09 0909 6966 2028 nfo)...{....if ( │ │ │ +0005ea10: 622e 7065 6572 203d 3d20 7065 6572 2920 b.peer == peer) │ │ │ +0005ea20: 622e 7065 6572 203d 206e 756c 6c70 7472 b.peer = nullptr │ │ │ +0005ea30: 3b0a 0909 7d0a 097d 0a0a 092f 2f20 7468 ;...}..}...// th │ │ │ +0005ea40: 6520 6669 7273 7420 626f 6f6c 2069 7320 e first bool is │ │ │ +0005ea50: 7472 7565 2069 6620 7468 6973 2069 7320 true if this is │ │ │ +0005ea60: 7468 6520 6f6e 6c79 2070 6565 7220 7468 the only peer th │ │ │ +0005ea70: 6174 2068 6173 2072 6571 7565 7374 6564 at has requested │ │ │ +0005ea80: 2061 6e64 2064 6f77 6e6c 6f61 6465 640a and downloaded. │ │ │ +0005ea90: 092f 2f20 626c 6f63 6b73 2066 726f 6d20 .// blocks from │ │ │ +0005eaa0: 7468 6973 2070 6965 6365 2e0a 092f 2f20 this piece...// │ │ │ +0005eab0: 7468 6520 7365 636f 6e64 2062 6f6f 6c20 the second bool │ │ │ +0005eac0: 6973 2074 7275 6520 6966 2074 6869 7320 is true if this │ │ │ +0005ead0: 6973 2074 6865 206f 6e6c 7920 6163 7469 is the only acti │ │ │ +0005eae0: 7665 2070 6565 7220 7468 6174 2069 7320 ve peer that is │ │ │ +0005eaf0: 7265 7175 6573 7469 6e67 0a09 2f2f 2061 requesting..// a │ │ │ +0005eb00: 6e64 2064 6f77 6e6c 6f61 6469 6e67 2062 nd downloading b │ │ │ +0005eb10: 6c6f 636b 7320 6672 6f6d 2074 6869 7320 locks from this │ │ │ +0005eb20: 7069 6563 652e 2041 6374 6976 6520 6d65 piece. Active me │ │ │ +0005eb30: 616e 7320 6861 7669 6e67 2061 2063 6f6e ans having a con │ │ │ +0005eb40: 6e65 6374 696f 6e2e 0a3c 2f70 7265 3e3c nection..< │ │ │ +0005eb50: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +0005eb80: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +0005eb90: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/piece │ │ │ +0005ebc0: 5f70 6963 6b65 722e 6370 703a 3331 3631 _picker.cpp:3161 │ │ │ +0005ebd0: 3c2f 613e 3c2f 7464 3e3c 7464 3e73 686f sho │ │ │ +0005ebe0: 756c 6420 3520 6265 2063 6f6e 6669 6775 uld 5 be configu │ │ │ +0005ebf0: 7261 626c 653f 3c2f 7464 3e3c 2f74 723e rable? │ │ │ +0005ec00: 3c74 7220 6964 3d22 3231 3822 2073 7479 │ │ │ +0005ec30: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0005ec40: 3c68 323e 7368 6f75 6c64 2035 2062 6520

    should 5 be │ │ │ +0005ec50: 636f 6e66 6967 7572 6162 6c65 3f3c 2f68 configurable?

    ../src/pie │ │ │ +0005ec70: 6365 5f70 6963 6b65 722e 6370 703a 3331 ce_picker.cpp:31 │ │ │ +0005ec80: 3631 3c2f 6834 3e3c 7072 6520 7374 796c 61

    ..bool have_all
    │ │ │ +0005ecd0: 203d 2074 7275 653b 0a0a 0909 666f 7220   = true;....for 
    │ │ │ +0005ece0: 2861 7574 6f20 636f 6e73 7420 7069 6563  (auto const piec
    │ │ │ +0005ecf0: 6520 3a20 6578 7465 6e74 5f66 6f72 2874  e : extent_for(t
    │ │ │ +0005ed00: 6869 735f 6578 7465 6e74 2929 0a09 097b  his_extent))...{
    │ │ │ +0005ed10: 0a09 0909 6966 2028 7069 6563 6520 3d3d  ....if (piece ==
    │ │ │ +0005ed20: 2070 2920 636f 6e74 696e 7565 3b0a 0a09   p) continue;...
    │ │ │ +0005ed30: 0909 6966 2028 216d 5f70 6965 6365 5f6d  ..if (!m_piece_m
    │ │ │ +0005ed40: 6170 5b70 6965 6365 5d2e 6861 7665 2829  ap[piece].have()
    │ │ │ +0005ed50: 2920 6861 7665 5f61 6c6c 203d 2066 616c  ) have_all = fal
    │ │ │ +0005ed60: 7365 3b0a 0a09 0909 2f2f 2069 6620 6174  se;.....// if at
    │ │ │ +0005ed70: 206c 6561 7374 206f 6e65 2070 6965 6365   least one piece
    │ │ │ +0005ed80: 2069 6e20 7468 6973 2065 7874 656e 7420   in this extent 
    │ │ │ +0005ed90: 6861 7320 6120 6469 6666 6572 656e 7420  has a different 
    │ │ │ +0005eda0: 7072 696f 7269 7479 2074 6861 6e0a 0909  priority than...
    │ │ │ +0005edb0: 092f 2f20 7468 6520 6f6e 6520 7765 206a  .// the one we j
    │ │ │ +0005edc0: 7573 7420 7374 6172 7465 6420 646f 776e  ust started down
    │ │ │ +0005edd0: 6c6f 6164 696e 672c 2064 6f6e 2774 2063  loading, don't c
    │ │ │ +0005ede0: 7265 6174 6520 616e 2061 6666 696e 6974  reate an affinit
    │ │ │ +0005edf0: 7920 666f 720a 0909 092f 2f20 6164 6a61  y for....// adja
    │ │ │ +0005ee00: 6365 6e74 2070 6965 6365 732e 2054 6869  cent pieces. Thi
    │ │ │ +0005ee10: 7320 7072 6f62 6162 6c79 206d 6561 6e73  s probably means
    │ │ │ +0005ee20: 2074 6865 2070 6965 6365 7320 6265 6c6f   the pieces belo
    │ │ │ +0005ee30: 6e67 2074 6f20 6469 6666 6572 656e 740a  ng to different.
    │ │ │ +0005ee40: 0909 092f 2f20 6669 6c65 732c 206f 7220  ...// files, or 
    │ │ │ +0005ee50: 7468 6174 2073 6f6d 6520 6f74 6865 7220  that some other 
    │ │ │ +0005ee60: 6d65 6368 616e 6973 6d20 6465 7465 726d  mechanism determ
    │ │ │ +0005ee70: 696e 696e 6720 7468 6520 7072 696f 7269  ining the priori
    │ │ │ +0005ee80: 7479 2073 686f 756c 640a 0909 092f 2f20  ty should....// 
    │ │ │ +0005ee90: 7461 6b65 2070 7265 6365 6465 6e63 652e  take precedence.
    │ │ │ +0005eea0: 0a09 0909 6966 2028 7069 6563 655f 7072  ....if (piece_pr
    │ │ │ +0005eeb0: 696f 7269 7479 2870 6965 6365 2920 213d  iority(piece) !=
    │ │ │ +0005eec0: 2074 6869 735f 7072 696f 2920 7265 7475   this_prio) retu
    │ │ │ +0005eed0: 726e 3b0a 0909 7d0a 0a09 092f 2f20 6966  rn;...}....// if
    │ │ │ +0005eee0: 2077 6520 616c 7265 6164 7920 6861 7665   we already have
    │ │ │ +0005eef0: 2061 6c6c 2074 6865 202a 6f74 6865 722a   all the *other*
    │ │ │ +0005ef00: 2070 6965 6365 7320 696e 2074 6869 7320   pieces in this 
    │ │ │ +0005ef10: 6578 7465 6e74 2c20 7468 6572 6527 7320  extent, there's 
    │ │ │ +0005ef20: 6e6f 0a09 092f 2f20 6e65 6564 2074 6f20  no...// need to 
    │ │ │ +0005ef30: 696e 666c 6174 6520 7468 6569 7220 7072  inflate their pr
    │ │ │ +0005ef40: 696f 7269 7469 6573 0a09 0969 6620 2868  iorities...if (h
    │ │ │ +0005ef50: 6176 655f 616c 6c29 2072 6574 7572 6e3b  ave_all) return;
    │ │ │ +0005ef60: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +0005ef90: 0909 6966 2028 6d5f 7265 6365 6e74 5f65 ..if (m_recent_e │ │ │ +0005efa0: 7874 656e 7473 2e73 697a 6528 2920 266c xtents.size() &l │ │ │ +0005efb0: 743b 2035 290a 3c2f 6469 763e 0909 096d t; 5).
    ...m │ │ │ +0005efc0: 5f72 6563 656e 745f 6578 7465 6e74 732e _recent_extents. │ │ │ +0005efd0: 7075 7368 5f62 6163 6b28 7468 6973 5f65 push_back(this_e │ │ │ +0005efe0: 7874 656e 7429 3b0a 0a09 092f 2f20 6c69 xtent);....// li │ │ │ +0005eff0: 6d69 7420 7468 6520 6e75 6d62 6572 206f mit the number o │ │ │ +0005f000: 6620 6578 7465 6e74 2061 6666 696e 6974 f extent affinit │ │ │ +0005f010: 6965 7320 6163 7469 7665 2061 7420 616e ies active at an │ │ │ +0005f020: 7920 6769 7665 6e20 7469 6d65 2074 6f20 y given time to │ │ │ +0005f030: 6c69 6d69 740a 0909 2f2f 2074 6865 2063 limit...// the c │ │ │ +0005f040: 6f73 7420 6f66 2063 6865 636b 696e 6720 ost of checking │ │ │ +0005f050: 7468 656d 2e20 416c 736f 2c20 646f 6e27 them. Also, don' │ │ │ +0005f060: 7420 7265 706c 6163 6520 7468 656d 2c20 t replace them, │ │ │ +0005f070: 636f 6d6d 6974 2074 6f0a 0909 2f2f 2066 commit to...// f │ │ │ +0005f080: 696e 6973 6869 6e67 2074 6865 6d20 6265 inishing them be │ │ │ +0005f090: 666f 7265 2073 7461 7274 696e 6720 616e fore starting an │ │ │ +0005f0a0: 6f74 6865 7220 6578 7465 6e74 2e20 5468 other extent. Th │ │ │ +0005f0b0: 6973 2069 7320 616e 616c 6f67 6f75 7320 is is analogous │ │ │ +0005f0c0: 746f 0a09 092f 2f20 6c69 6d69 7469 6e67 to...// limiting │ │ │ +0005f0d0: 2074 6865 206e 756d 6265 7220 6f66 2070 the number of p │ │ │ +0005f0e0: 6172 7469 616c 2070 6965 6365 732e 0a09 artial pieces... │ │ │ +0005f0f0: 7d0a 0a09 2f2f 206f 7074 696f 6e73 206d }...// options m │ │ │ +0005f100: 6179 2062 6520 3020 6f72 2070 6965 6365 ay be 0 or piece │ │ │ +0005f110: 5f70 6963 6b65 723a 3a72 6576 6572 7365 _picker::reverse │ │ │ +0005f120: 0a09 2f2f 2072 6574 7572 6e73 2066 616c ..// returns fal │ │ │ +0005f130: 7365 2069 6620 7468 6520 626c 6f63 6b20 se if the block │ │ │ +0005f140: 636f 756c 6420 6e6f 7420 6265 206d 6172 could not be mar │ │ │ +0005f150: 6b65 6420 6173 2064 6f77 6e6c 6f61 6469 ked as downloadi │ │ │ +0005f160: 6e67 0a09 626f 6f6c 2070 6965 6365 5f70 ng..bool piece_p │ │ │ +0005f170: 6963 6b65 723a 3a6d 6172 6b5f 6173 5f64 icker::mark_as_d │ │ │ +0005f180: 6f77 6e6c 6f61 6469 6e67 2870 6965 6365 ownloading(piece │ │ │ +0005f190: 5f62 6c6f 636b 2063 6f6e 7374 2062 6c6f _block const blo │ │ │ +0005f1a0: 636b 0a09 092c 2074 6f72 7265 6e74 5f70 ck..., torrent_p │ │ │ +0005f1b0: 6565 722a 2070 6565 722c 2070 6963 6b65 eer* peer, picke │ │ │ +0005f1c0: 725f 6f70 7469 6f6e 735f 7420 636f 6e73 r_options_t cons │ │ │ +0005f1d0: 7420 6f70 7469 6f6e 7329 0a09 7b0a 2369 t options)..{.#i │ │ │ +0005f1e0: 6664 6566 2054 4f52 5245 4e54 5f50 4943 fdef TORRENT_PIC │ │ │ +0005f1f0: 4b45 525f 4c4f 470a 0909 7374 643a 3a63 KER_LOG...std::c │ │ │ +0005f200: 6572 7220 266c 743b 266c 743b 2022 5b22 err << "[" │ │ │ +0005f210: 2026 6c74 3b26 6c74 3b20 7468 6973 2026 << this & │ │ │ +0005f220: 6c74 3b26 6c74 3b20 225d 2022 2026 6c74 lt;< "] " < │ │ │ +0005f230: 3b26 6c74 3b20 226d 6172 6b5f 6173 5f64 ;< "mark_as_d │ │ │ +0005f240: 6f77 6e6c 6f61 6469 6e67 2820 7b22 0a09 ownloading( {".. │ │ │ +0005f250: 0909 266c 743b 266c 743b 2062 6c6f 636b ..<< block │ │ │ +0005f260: 2e70 6965 6365 5f69 6e64 6578 2026 6c74 .piece_index < │ │ │ +0005f270: 3b26 6c74 3b20 222c 2022 2026 6c74 3b26 ;< ", " <& │ │ │ +0005f280: 6c74 3b20 626c 6f63 6b2e 626c 6f63 6b5f lt; block.block_ │ │ │ +0005f290: 696e 6465 7820 266c 743b 266c 743b 2022 index << " │ │ │ +0005f2a0: 7d20 2922 2026 6c74 3b26 6c74 3b20 7374 } )" << st │ │ │ +0005f2b0: 643a 3a65 6e64 6c3b 0a23 656e 6469 660a d::endl;.#endif. │ │ │ +0005f2c0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +0005f2d0: 5428 7065 6572 203d 3d20 6e75 6c6c 7074 T(peer == nullpt │ │ │ +0005f2e0: 7220 7c7c 2070 6565 722d 2667 743b 696e r || peer->in │ │ │ +0005f2f0: 5f75 7365 293b 0a09 0954 4f52 5245 4e54 _use);...TORRENT │ │ │ +0005f300: 5f41 5353 4552 5428 626c 6f63 6b2e 626c _ASSERT(block.bl │ │ │ +0005f310: 6f63 6b5f 696e 6465 7820 213d 2070 6965 ock_index != pie │ │ │ +0005f320: 6365 5f62 6c6f 636b 3a3a 696e 7661 6c69 ce_block::invali │ │ │ +0005f330: 642e 626c 6f63 6b5f 696e 6465 7829 3b0a d.block_index);. │ │ │ +0005f340: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +0005f350: 2862 6c6f 636b 2e70 6965 6365 5f69 6e64 (block.piece_ind │ │ │ +0005f360: 6578 2021 3d20 7069 6563 655f 626c 6f63 ex != piece_bloc │ │ │ +0005f370: 6b3a 3a69 6e76 616c 6964 2e70 6965 6365 k::invalid.piece │ │ │ +0005f380: 5f69 6e64 6578 293b 0a09 0954 4f52 5245 _index);...TORRE │ │ │ +0005f390: 4e54 5f41 5353 4552 5428 626c 6f63 6b2e NT_ASSERT(block. │ │ │ +0005f3a0: 7069 6563 655f 696e 6465 7820 266c 743b piece_index < │ │ │ +0005f3b0: 206d 5f70 6965 6365 5f6d 6170 2e65 6e64 m_piece_map.end │ │ │ +0005f3c0: 5f69 6e64 6578 2829 293b 0a09 0954 4f52 _index());...TOR │ │ │ +0005f3d0: 5245 4e54 5f41 5353 4552 5428 626c 6f63 RENT_ASSERT(bloc │ │ │ +0005f3e0: 6b2e 626c 6f63 6b5f 696e 6465 7820 266c k.block_index &l │ │ │ +0005f3f0: 743b 2062 6c6f 636b 735f 696e 5f70 6965 t; blocks_in_pie │ │ │ +0005f400: 6365 2862 6c6f 636b 2e70 6965 6365 5f69 ce(block.piece_i │ │ │ +0005f410: 6e64 6578 2929 3b0a 0909 544f 5252 454e ndex));...TORREN │ │ │ +0005f420: 545f 4153 5345 5254 2821 6d5f 7069 6563 T_ASSERT(!m_piec │ │ │ +0005f430: 655f 6d61 705b 626c 6f63 6b2e 7069 6563 e_map[block.piec │ │ │ +0005f440: 655f 696e 6465 785d 2e68 6176 6528 2929 e_index].have()) │ │ │ +0005f450: 3b0a 0a09 0970 6965 6365 5f70 6f73 2661 ;....piece_pos&a │ │ │ +0005f460: 6d70 3b20 7020 3d20 6d5f 7069 6563 655f mp; p = m_piece_ │ │ │ +0005f470: 6d61 705b 626c 6f63 6b2e 7069 6563 655f map[block.piece_ │ │ │ +0005f480: 696e 6465 785d 3b0a 0909 6966 2028 702e index];...if (p. │ │ │ +0005f490: 646f 776e 6c6f 6164 5f71 7565 7565 2829 download_queue() │ │ │ +0005f4a0: 203d 3d20 7069 6563 655f 706f 733a 3a70 == piece_pos::p │ │ │ +0005f4b0: 6965 6365 5f6f 7065 6e29 0a09 097b 0a23 iece_open)...{.# │ │ │ +0005f4c0: 6966 6465 6620 544f 5252 454e 545f 4558 ifdef TORRENT_EX │ │ │ +0005f4d0: 5045 4e53 4956 455f 494e 5641 5249 414e PENSIVE_INVARIAN │ │ │ +0005f4e0: 545f 4348 4543 4b53 0a09 0909 494e 5641 T_CHECKS....INVA │ │ │ +0005f4f0: 5249 414e 545f 4348 4543 4b3b 0a3c 2f70 RIANT_CHECK;.

    re │ │ │ +0005f530: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/i │ │ │ +0005f570: 705f 6e6f 7469 6669 6572 2e63 7070 3a34 p_notifier.cpp:4 │ │ │ +0005f580: 313c 2f61 3e3c 2f74 643e 3c74 643e 7369 1si │ │ │ +0005f590: 6d75 6c61 746f 7220 7375 7070 6f72 743c mulator support< │ │ │ +0005f5a0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    sim │ │ │ +0005f5f0: 756c 6174 6f72 2073 7570 706f 7274 3c2f ulator support

    ../src/ip │ │ │ +0005f610: 5f6e 6f74 6966 6965 722e 6370 703a 3431 _notifier.cpp:41 │ │ │ +0005f620: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

     
    │ │ │ +0005f660: 2020 2020 2066 726f 6d20 7468 6973 2073       from this s
    │ │ │ +0005f670: 6f66 7477 6172 6520 7769 7468 6f75 7420  oftware without 
    │ │ │ +0005f680: 7370 6563 6966 6963 2070 7269 6f72 2077  specific prior w
    │ │ │ +0005f690: 7269 7474 656e 2070 6572 6d69 7373 696f  ritten permissio
    │ │ │ +0005f6a0: 6e2e 0a0a 5448 4953 2053 4f46 5457 4152  n...THIS SOFTWAR
    │ │ │ +0005f6b0: 4520 4953 2050 524f 5649 4445 4420 4259  E IS PROVIDED BY
    │ │ │ +0005f6c0: 2054 4845 2043 4f50 5952 4947 4854 2048   THE COPYRIGHT H
    │ │ │ +0005f6d0: 4f4c 4445 5253 2041 4e44 2043 4f4e 5452  OLDERS AND CONTR
    │ │ │ +0005f6e0: 4942 5554 4f52 5320 2241 5320 4953 220a  IBUTORS "AS IS".
    │ │ │ +0005f6f0: 414e 4420 414e 5920 4558 5052 4553 5320  AND ANY EXPRESS 
    │ │ │ +0005f700: 4f52 2049 4d50 4c49 4544 2057 4152 5241  OR IMPLIED WARRA
    │ │ │ +0005f710: 4e54 4945 532c 2049 4e43 4c55 4449 4e47  NTIES, INCLUDING
    │ │ │ +0005f720: 2c20 4255 5420 4e4f 5420 4c49 4d49 5445  , BUT NOT LIMITE
    │ │ │ +0005f730: 4420 544f 2c20 5448 450a 494d 504c 4945  D TO, THE.IMPLIE
    │ │ │ +0005f740: 4420 5741 5252 414e 5449 4553 204f 4620  D WARRANTIES OF 
    │ │ │ +0005f750: 4d45 5243 4841 4e54 4142 494c 4954 5920  MERCHANTABILITY 
    │ │ │ +0005f760: 414e 4420 4649 544e 4553 5320 464f 5220  AND FITNESS FOR 
    │ │ │ +0005f770: 4120 5041 5254 4943 554c 4152 2050 5552  A PARTICULAR PUR
    │ │ │ +0005f780: 504f 5345 0a41 5245 2044 4953 434c 4149  POSE.ARE DISCLAI
    │ │ │ +0005f790: 4d45 442e 2049 4e20 4e4f 2045 5645 4e54  MED. IN NO EVENT
    │ │ │ +0005f7a0: 2053 4841 4c4c 2054 4845 2043 4f50 5952   SHALL THE COPYR
    │ │ │ +0005f7b0: 4947 4854 204f 574e 4552 204f 5220 434f  IGHT OWNER OR CO
    │ │ │ +0005f7c0: 4e54 5249 4255 544f 5253 2042 450a 4c49  NTRIBUTORS BE.LI
    │ │ │ +0005f7d0: 4142 4c45 2046 4f52 2041 4e59 2044 4952  ABLE FOR ANY DIR
    │ │ │ +0005f7e0: 4543 542c 2049 4e44 4952 4543 542c 2049  ECT, INDIRECT, I
    │ │ │ +0005f7f0: 4e43 4944 454e 5441 4c2c 2053 5045 4349  NCIDENTAL, SPECI
    │ │ │ +0005f800: 414c 2c20 4558 454d 504c 4152 592c 204f  AL, EXEMPLARY, O
    │ │ │ +0005f810: 520a 434f 4e53 4551 5545 4e54 4941 4c20  R.CONSEQUENTIAL 
    │ │ │ +0005f820: 4441 4d41 4745 5320 2849 4e43 4c55 4449  DAMAGES (INCLUDI
    │ │ │ +0005f830: 4e47 2c20 4255 5420 4e4f 5420 4c49 4d49  NG, BUT NOT LIMI
    │ │ │ +0005f840: 5445 4420 544f 2c20 5052 4f43 5552 454d  TED TO, PROCUREM
    │ │ │ +0005f850: 454e 5420 4f46 0a53 5542 5354 4954 5554  ENT OF.SUBSTITUT
    │ │ │ +0005f860: 4520 474f 4f44 5320 4f52 2053 4552 5649  E GOODS OR SERVI
    │ │ │ +0005f870: 4345 533b 204c 4f53 5320 4f46 2055 5345  CES; LOSS OF USE
    │ │ │ +0005f880: 2c20 4441 5441 2c20 4f52 2050 524f 4649  , DATA, OR PROFI
    │ │ │ +0005f890: 5453 3b20 4f52 2042 5553 494e 4553 530a  TS; OR BUSINESS.
    │ │ │ +0005f8a0: 494e 5445 5252 5550 5449 4f4e 2920 484f  INTERRUPTION) HO
    │ │ │ +0005f8b0: 5745 5645 5220 4341 5553 4544 2041 4e44  WEVER CAUSED AND
    │ │ │ +0005f8c0: 204f 4e20 414e 5920 5448 454f 5259 204f   ON ANY THEORY O
    │ │ │ +0005f8d0: 4620 4c49 4142 494c 4954 592c 2057 4845  F LIABILITY, WHE
    │ │ │ +0005f8e0: 5448 4552 2049 4e0a 434f 4e54 5241 4354  THER IN.CONTRACT
    │ │ │ +0005f8f0: 2c20 5354 5249 4354 204c 4941 4249 4c49  , STRICT LIABILI
    │ │ │ +0005f900: 5459 2c20 4f52 2054 4f52 5420 2849 4e43  TY, OR TORT (INC
    │ │ │ +0005f910: 4c55 4449 4e47 204e 4547 4c49 4745 4e43  LUDING NEGLIGENC
    │ │ │ +0005f920: 4520 4f52 204f 5448 4552 5749 5345 290a  E OR OTHERWISE).
    │ │ │ +0005f930: 4152 4953 494e 4720 494e 2041 4e59 2057  ARISING IN ANY W
    │ │ │ +0005f940: 4159 204f 5554 204f 4620 5448 4520 5553  AY OUT OF THE US
    │ │ │ +0005f950: 4520 4f46 2054 4849 5320 534f 4654 5741  E OF THIS SOFTWA
    │ │ │ +0005f960: 5245 2c20 4556 454e 2049 4620 4144 5649  RE, EVEN IF ADVI
    │ │ │ +0005f970: 5345 4420 4f46 2054 4845 0a50 4f53 5349  SED OF THE.POSSI
    │ │ │ +0005f980: 4249 4c49 5459 204f 4620 5355 4348 2044  BILITY OF SUCH D
    │ │ │ +0005f990: 414d 4147 452e 0a0a 2a2f 0a0a 2369 6e63  AMAGE...*/..#inc
    │ │ │ +0005f9a0: 6c75 6465 2022 6c69 6274 6f72 7265 6e74  lude "libtorrent
    │ │ │ +0005f9b0: 2f61 7578 5f2f 6970 5f6e 6f74 6966 6965  /aux_/ip_notifie
    │ │ │ +0005f9c0: 722e 6870 7022 0a23 696e 636c 7564 6520  r.hpp".#include 
    │ │ │ +0005f9d0: 226c 6962 746f 7272 656e 742f 6173 7365  "libtorrent/asse
    │ │ │ +0005f9e0: 7274 2e68 7070 220a 0a23 6966 2064 6566  rt.hpp"..#if def
    │ │ │ +0005f9f0: 696e 6564 2054 4f52 5245 4e54 5f42 5549  ined TORRENT_BUI
    │ │ │ +0005fa00: 4c44 5f53 494d 554c 4154 4f52 0a3c 6469  LD_SIMULATOR.#elif
    │ │ │ +0005fa40: 2054 4f52 5245 4e54 5f55 5345 5f4e 4554   TORRENT_USE_NET
    │ │ │ +0005fa50: 4c49 4e4b 0a3c 2f64 6976 3e23 696e 636c  LINK.#incl
    │ │ │ +0005fa60: 7564 6520 226c 6962 746f 7272 656e 742f  ude "libtorrent/
    │ │ │ +0005fa70: 6e65 746c 696e 6b2e 6870 7022 0a23 696e  netlink.hpp".#in
    │ │ │ +0005fa80: 636c 7564 6520 226c 6962 746f 7272 656e  clude "libtorren
    │ │ │ +0005fa90: 742f 736f 636b 6574 2e68 7070 220a 2369  t/socket.hpp".#i
    │ │ │ +0005faa0: 6e63 6c75 6465 2026 6c74 3b61 7272 6179  nclude <array
    │ │ │ +0005fab0: 2667 743b 0a23 696e 636c 7564 6520 266c  >.#include &l
    │ │ │ +0005fac0: 743b 756e 6f72 6465 7265 645f 6d61 7026  t;unordered_map&
    │ │ │ +0005fad0: 6774 3b0a 2365 6c69 6620 544f 5252 454e  gt;.#elif TORREN
    │ │ │ +0005fae0: 545f 5553 455f 5359 5354 454d 434f 4e46  T_USE_SYSTEMCONF
    │ │ │ +0005faf0: 4947 5552 4154 494f 4e20 7c7c 2054 4f52  IGURATION || TOR
    │ │ │ +0005fb00: 5245 4e54 5f55 5345 5f53 435f 4e45 5457  RENT_USE_SC_NETW
    │ │ │ +0005fb10: 4f52 4b5f 5245 4143 4841 4249 4c49 5459  ORK_REACHABILITY
    │ │ │ +0005fb20: 0a23 696e 636c 7564 6520 266c 743b 5379  .#include <Sy
    │ │ │ +0005fb30: 7374 656d 436f 6e66 6967 7572 6174 696f  stemConfiguratio
    │ │ │ +0005fb40: 6e2f 5379 7374 656d 436f 6e66 6967 7572  n/SystemConfigur
    │ │ │ +0005fb50: 6174 696f 6e2e 6826 6774 3b0a 2365 6c69  ation.h>.#eli
    │ │ │ +0005fb60: 6620 6465 6669 6e65 6420 544f 5252 454e  f defined TORREN
    │ │ │ +0005fb70: 545f 5749 4e44 4f57 530a 2369 6e63 6c75  T_WINDOWS.#inclu
    │ │ │ +0005fb80: 6465 2022 6c69 6274 6f72 7265 6e74 2f61  de "libtorrent/a
    │ │ │ +0005fb90: 7578 5f2f 7468 726f 772e 6870 7022 0a23  ux_/throw.hpp".#
    │ │ │ +0005fba0: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ +0005fbb0: 656e 742f 6175 785f 2f64 6973 6162 6c65  ent/aux_/disable
    │ │ │ +0005fbc0: 5f77 6172 6e69 6e67 735f 7075 7368 2e68  _warnings_push.h
    │ │ │ +0005fbd0: 7070 220a 2369 6e63 6c75 6465 2026 6c74  pp".#include <
    │ │ │ +0005fbe0: 3b69 7068 6c70 6170 692e 6826 6774 3b0a  ;iphlpapi.h>.
    │ │ │ +0005fbf0: 2369 6664 6566 2054 4f52 5245 4e54 5f57  #ifdef TORRENT_W
    │ │ │ +0005fc00: 494e 5254 0a23 696e 636c 7564 6520 266c  INRT.#include &l
    │ │ │ +0005fc10: 743b 6e65 7469 6f61 7069 2e68 2667 743b  t;netioapi.h>
    │ │ │ +0005fc20: 0a23 656e 6469 660a 2369 6e63 6c75 6465  .#endif.#include
    │ │ │ +0005fc30: 2026 6c74 3b6d 7574 6578 2667 743b 0a23   <mutex>.#
    │ │ │ +0005fc40: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ +0005fc50: 656e 742f 6175 785f 2f64 6973 6162 6c65  ent/aux_/disable
    │ │ │ +0005fc60: 5f77 6172 6e69 6e67 735f 706f 702e 6870  _warnings_pop.hp
    │ │ │ +0005fc70: 7022 0a23 656e 6469 660a 0a23 696e 636c  p".#endif..#incl
    │ │ │ +0005fc80: 7564 6520 226c 6962 746f 7272 656e 742f  ude "libtorrent/
    │ │ │ +0005fc90: 6175 785f 2f6e 6574 6c69 6e6b 5f75 7469  aux_/netlink_uti
    │ │ │ +0005fca0: 6c73 2e68 7070 220a 0a6e 616d 6573 7061  ls.hpp"..namespa
    │ │ │ +0005fcb0: 6365 206c 6962 746f 7272 656e 7420 7b20  ce libtorrent { 
    │ │ │ +0005fcc0: 6e61 6d65 7370 6163 6520 6175 7820 7b0a  namespace aux {.
    │ │ │ +0005fcd0: 0a6e 616d 6573 7061 6365 207b 0a0a 2369  .namespace {..#i
    │ │ │ +0005fce0: 6620 2854 4f52 5245 4e54 5f55 5345 5f53  f (TORRENT_USE_S
    │ │ │ +0005fcf0: 5953 5445 4d43 4f4e 4649 4755 5241 5449  YSTEMCONFIGURATI
    │ │ │ +0005fd00: 4f4e 207c 7c20 544f 5252 454e 545f 5553  ON || TORRENT_US
    │ │ │ +0005fd10: 455f 5343 5f4e 4554 574f 524b 5f52 4541  E_SC_NETWORK_REA
    │ │ │ +0005fd20: 4348 4142 494c 4954 5929 2026 616d 703b  CHABILITY) &
    │ │ │ +0005fd30: 2661 6d70 3b20 5c0a 0921 6465 6669 6e65  & \..!define
    │ │ │ +0005fd40: 6420 544f 5252 454e 545f 4255 494c 445f  d TORRENT_BUILD_
    │ │ │ +0005fd50: 5349 4d55 4c41 544f 520a 0a2f 2f20 636f  SIMULATOR..// co
    │ │ │ +0005fd60: 6d6d 6f6e 2075 7469 6c69 7469 6573 2066  mmon utilities f
    │ │ │ +0005fd70: 6f72 204d 6163 2061 6e64 2069 4f53 0a74  or Mac and iOS.t
    │ │ │ +0005fd80: 656d 706c 6174 6520 266c 743b 7479 7065  emplate <type
    │ │ │ +0005fd90: 6e61 6d65 2054 2667 743b 2076 6f69 6420  name T> void 
    │ │ │ +0005fda0: 4346 5265 6652 6574 6169 6e28 5420 6829  CFRefRetain(T h)
    │ │ │ +0005fdb0: 207b 2043 4652 6574 6169 6e28 6829 3b20   { CFRetain(h); 
    │ │ │ +0005fdc0: 7d0a 7465 6d70 6c61 7465 2026 6c74 3b74  }.template <t
    │ │ │ +0005fdd0: 7970 656e 616d 6520 5426 6774 3b20 766f  ypename T> vo
    │ │ │ +0005fde0: 6964 2043 4652 6566 5265 6c65 6173 6528  id CFRefRelease(
    │ │ │ +0005fdf0: 5420 6829 207b 2043 4652 656c 6561 7365  T h) { CFRelease
    │ │ │ +0005fe00: 2868 293b 207d 0a0a 3c2f 7072 653e 3c2f  (h); }..
    relevan │ │ │ +0005fe40: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/pe_cry │ │ │ +0005fe80: 7074 6f2e 6370 703a 3630 3c2f 613e 3c2f pto.cpp:60it would │ │ │ +0005fea0: 6265 206e 6963 6520 746f 2067 6574 2074 be nice to get t │ │ │ +0005feb0: 6865 206c 6974 6572 616c 2077 6f72 6b69 he literal worki │ │ │ +0005fec0: 6e67 3c2f 7464 3e3c 2f74 723e 3c74 7220 ng

    │ │ │ +0005ff10: 6974 2077 6f75 6c64 2062 6520 6e69 6365 it would be nice │ │ │ +0005ff20: 2074 6f20 6765 7420 7468 6520 6c69 7465 to get the lite │ │ │ +0005ff30: 7261 6c20 776f 726b 696e 673c 2f68 323e ral working

    │ │ │ +0005ff40: 3c68 343e 2e2e 2f73 7263 2f70 655f 6372

    ../src/pe_cr │ │ │ +0005ff50: 7970 746f 2e63 7070 3a36 303c 2f68 343e ypto.cpp:60

    │ │ │ +0005ff60: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    #inclu
    │ │ │ +0005ffa0: 6465 2026 6c74 3b61 6c67 6f72 6974 686d  de <algorithm
    │ │ │ +0005ffb0: 2667 743b 0a23 696e 636c 7564 6520 266c  >.#include &l
    │ │ │ +0005ffc0: 743b 7261 6e64 6f6d 2667 743b 0a0a 2369  t;random>..#i
    │ │ │ +0005ffd0: 6e63 6c75 6465 2022 6c69 6274 6f72 7265  nclude "libtorre
    │ │ │ +0005ffe0: 6e74 2f61 7578 5f2f 6469 7361 626c 655f  nt/aux_/disable_
    │ │ │ +0005fff0: 7761 726e 696e 6773 5f70 7573 682e 6870  warnings_push.hp
    │ │ │ +00060000: 7022 0a0a 2369 6e63 6c75 6465 2026 6c74  p"..#include <
    │ │ │ +00060010: 3b62 6f6f 7374 2f6d 756c 7469 7072 6563  ;boost/multiprec
    │ │ │ +00060020: 6973 696f 6e2f 696e 7465 6765 722e 6870  ision/integer.hp
    │ │ │ +00060030: 7026 6774 3b0a 2369 6e63 6c75 6465 2026  p>.#include &
    │ │ │ +00060040: 6c74 3b62 6f6f 7374 2f6d 756c 7469 7072  lt;boost/multipr
    │ │ │ +00060050: 6563 6973 696f 6e2f 6370 705f 696e 742e  ecision/cpp_int.
    │ │ │ +00060060: 6870 7026 6774 3b0a 0a23 696e 636c 7564  hpp>..#includ
    │ │ │ +00060070: 6520 226c 6962 746f 7272 656e 742f 6175  e "libtorrent/au
    │ │ │ +00060080: 785f 2f64 6973 6162 6c65 5f77 6172 6e69  x_/disable_warni
    │ │ │ +00060090: 6e67 735f 706f 702e 6870 7022 0a0a 2369  ngs_pop.hpp"..#i
    │ │ │ +000600a0: 6e63 6c75 6465 2022 6c69 6274 6f72 7265  nclude "libtorre
    │ │ │ +000600b0: 6e74 2f72 616e 646f 6d2e 6870 7022 0a23  nt/random.hpp".#
    │ │ │ +000600c0: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ +000600d0: 656e 742f 6175 785f 2f61 6c6c 6f63 612e  ent/aux_/alloca.
    │ │ │ +000600e0: 6870 7022 0a23 696e 636c 7564 6520 226c  hpp".#include "l
    │ │ │ +000600f0: 6962 746f 7272 656e 742f 7065 5f63 7279  ibtorrent/pe_cry
    │ │ │ +00060100: 7074 6f2e 6870 7022 0a23 696e 636c 7564  pto.hpp".#includ
    │ │ │ +00060110: 6520 226c 6962 746f 7272 656e 742f 6861  e "libtorrent/ha
    │ │ │ +00060120: 7368 6572 2e68 7070 220a 0a6e 616d 6573  sher.hpp"..names
    │ │ │ +00060130: 7061 6365 206c 6962 746f 7272 656e 7420  pace libtorrent 
    │ │ │ +00060140: 7b0a 0a09 6e61 6d65 7370 6163 6520 6d70  {...namespace mp
    │ │ │ +00060150: 203d 2062 6f6f 7374 3a3a 6d75 6c74 6970   = boost::multip
    │ │ │ +00060160: 7265 6369 7369 6f6e 3b0a 0a09 6e61 6d65  recision;...name
    │ │ │ +00060170: 7370 6163 6520 7b0a 3c64 6976 2073 7479  space {.
    ..key_t co │ │ │ +000601b0: 6e73 7420 6468 5f70 7269 6d65 0a3c 2f64 nst dh_prime....("0xFFFFFF │ │ │ +000601d0: 4646 4646 4646 4646 4646 4339 3046 4441 FFFFFFFFFFC90FDA │ │ │ +000601e0: 4132 3231 3638 4332 3334 4334 4336 3632 A22168C234C4C662 │ │ │ +000601f0: 3842 3830 4443 3143 4431 3239 3032 3445 8B80DC1CD129024E │ │ │ +00060200: 3038 3841 3637 4343 3734 3032 3042 4245 088A67CC74020BBE │ │ │ +00060210: 4136 3342 3133 3942 3232 3531 3441 3038 A63B139B22514A08 │ │ │ +00060220: 3739 3845 3334 3034 4444 4546 3935 3139 798E3404DDEF9519 │ │ │ +00060230: 4233 4344 3341 3433 3142 3330 3242 3041 B3CD3A431B302B0A │ │ │ +00060240: 3644 4632 3546 3134 3337 3446 4531 3335 6DF25F14374FE135 │ │ │ +00060250: 3644 3644 3531 4332 3435 4534 3835 4235 6D6D51C245E485B5 │ │ │ +00060260: 3736 3632 3545 3745 4336 4634 3443 3432 76625E7EC6F44C42 │ │ │ +00060270: 4539 4136 3341 3336 3231 3030 3030 3030 E9A63A3621000000 │ │ │ +00060280: 3030 3030 3039 3035 3633 2229 3b0a 097d 0000090563");..} │ │ │ +00060290: 0a0a 0973 7464 3a3a 6172 7261 7926 6c74 ...std::array< │ │ │ +000602a0: 3b63 6861 722c 2039 3626 6774 3b20 6578 ;char, 96> ex │ │ │ +000602b0: 706f 7274 5f6b 6579 286b 6579 5f74 2063 port_key(key_t c │ │ │ +000602c0: 6f6e 7374 2661 6d70 3b20 6b29 0a09 7b0a onst& k)..{. │ │ │ +000602d0: 0909 7374 643a 3a61 7272 6179 266c 743b ..std::array< │ │ │ +000602e0: 6368 6172 2c20 3936 2667 743b 2072 6574 char, 96> ret │ │ │ +000602f0: 3b0a 0909 6175 746f 2a20 6265 6769 6e20 ;...auto* begin │ │ │ +00060300: 3d20 7265 696e 7465 7270 7265 745f 6361 = reinterpret_ca │ │ │ +00060310: 7374 266c 743b 7374 643a 3a75 696e 7438 st<std::uint8 │ │ │ +00060320: 5f74 2a26 6774 3b28 7265 742e 6461 7461 _t*>(ret.data │ │ │ +00060330: 2829 293b 0a09 0973 7464 3a3a 7569 6e74 ());...std::uint │ │ │ +00060340: 385f 742a 2065 6e64 203d 206d 703a 3a65 8_t* end = mp::e │ │ │ +00060350: 7870 6f72 745f 6269 7473 286b 2c20 6265 xport_bits(k, be │ │ │ +00060360: 6769 6e2c 2038 293b 0a0a 3c2f 7072 653e gin, 8);..
    │ │ │ +00060370: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +000603a0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +000603b0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/pe_c │ │ │ +000603e0: 7279 7074 6f2e 6370 703a 3731 3c2f 613e rypto.cpp:71 │ │ │ +000603f0: 3c2f 7464 3e3c 7464 3e69 7420 776f 756c it woul │ │ │ +00060400: 6420 6265 206e 6963 6520 746f 2062 6520 d be nice to be │ │ │ +00060410: 6162 6c65 2074 6f20 6578 706f 7274 2074 able to export t │ │ │ +00060420: 6f20 6120 6669 7865 6420 7769 6474 6820 o a fixed width │ │ │ +00060430: 6669 656c 642c 2073 6f20 7765 2077 6f75 field, so we wou │ │ │ +00060440: 6c64 6e27 7420 6861 7665 2074 6f20 7368 ldn't have to sh │ │ │ +00060450: 6966 7420 6974 206c 6174 6572 3c2f 7464 ift it later

    it wou │ │ │ +000604b0: 6c64 2062 6520 6e69 6365 2074 6f20 6265 ld be nice to be │ │ │ +000604c0: 2061 626c 6520 746f 2065 7870 6f72 7420 able to export │ │ │ +000604d0: 746f 2061 2066 6978 6564 2077 6964 7468 to a fixed width │ │ │ +000604e0: 2066 6965 6c64 2c20 736f 0a77 6520 776f field, so.we wo │ │ │ +000604f0: 756c 646e 2774 2068 6176 6520 746f 2073 uldn't have to s │ │ │ +00060500: 6869 6674 2069 7420 6c61 7465 723c 2f68 hift it later

    ../src/pe_ │ │ │ +00060520: 6372 7970 746f 2e63 7070 3a37 313c 2f68 crypto.cpp:71
    #inc
    │ │ │ +00060570: 6c75 6465 2022 6c69 6274 6f72 7265 6e74  lude "libtorrent
    │ │ │ +00060580: 2f72 616e 646f 6d2e 6870 7022 0a23 696e  /random.hpp".#in
    │ │ │ +00060590: 636c 7564 6520 226c 6962 746f 7272 656e  clude "libtorren
    │ │ │ +000605a0: 742f 6175 785f 2f61 6c6c 6f63 612e 6870  t/aux_/alloca.hp
    │ │ │ +000605b0: 7022 0a23 696e 636c 7564 6520 226c 6962  p".#include "lib
    │ │ │ +000605c0: 746f 7272 656e 742f 7065 5f63 7279 7074  torrent/pe_crypt
    │ │ │ +000605d0: 6f2e 6870 7022 0a23 696e 636c 7564 6520  o.hpp".#include 
    │ │ │ +000605e0: 226c 6962 746f 7272 656e 742f 6861 7368  "libtorrent/hash
    │ │ │ +000605f0: 6572 2e68 7070 220a 0a6e 616d 6573 7061  er.hpp"..namespa
    │ │ │ +00060600: 6365 206c 6962 746f 7272 656e 7420 7b0a  ce libtorrent {.
    │ │ │ +00060610: 0a09 6e61 6d65 7370 6163 6520 6d70 203d  ..namespace mp =
    │ │ │ +00060620: 2062 6f6f 7374 3a3a 6d75 6c74 6970 7265   boost::multipre
    │ │ │ +00060630: 6369 7369 6f6e 3b0a 0a09 6e61 6d65 7370  cision;...namesp
    │ │ │ +00060640: 6163 6520 7b0a 0909 6b65 795f 7420 636f  ace {...key_t co
    │ │ │ +00060650: 6e73 7420 6468 5f70 7269 6d65 0a09 0909  nst dh_prime....
    │ │ │ +00060660: 2822 3078 4646 4646 4646 4646 4646 4646  ("0xFFFFFFFFFFFF
    │ │ │ +00060670: 4646 4646 4339 3046 4441 4132 3231 3638  FFFFC90FDAA22168
    │ │ │ +00060680: 4332 3334 4334 4336 3632 3842 3830 4443  C234C4C6628B80DC
    │ │ │ +00060690: 3143 4431 3239 3032 3445 3038 3841 3637  1CD129024E088A67
    │ │ │ +000606a0: 4343 3734 3032 3042 4245 4136 3342 3133  CC74020BBEA63B13
    │ │ │ +000606b0: 3942 3232 3531 3441 3038 3739 3845 3334  9B22514A08798E34
    │ │ │ +000606c0: 3034 4444 4546 3935 3139 4233 4344 3341  04DDEF9519B3CD3A
    │ │ │ +000606d0: 3433 3142 3330 3242 3041 3644 4632 3546  431B302B0A6DF25F
    │ │ │ +000606e0: 3134 3337 3446 4531 3335 3644 3644 3531  14374FE1356D6D51
    │ │ │ +000606f0: 4332 3435 4534 3835 4235 3736 3632 3545  C245E485B576625E
    │ │ │ +00060700: 3745 4336 4634 3443 3432 4539 4136 3341  7EC6F44C42E9A63A
    │ │ │ +00060710: 3336 3231 3030 3030 3030 3030 3030 3039  3621000000000009
    │ │ │ +00060720: 3035 3633 2229 3b0a 097d 0a0a 0973 7464  0563");..}...std
    │ │ │ +00060730: 3a3a 6172 7261 7926 6c74 3b63 6861 722c  ::array<char,
    │ │ │ +00060740: 2039 3626 6774 3b20 6578 706f 7274 5f6b   96> export_k
    │ │ │ +00060750: 6579 286b 6579 5f74 2063 6f6e 7374 2661  ey(key_t const&a
    │ │ │ +00060760: 6d70 3b20 6b29 0a09 7b0a 0909 7374 643a  mp; k)..{...std:
    │ │ │ +00060770: 3a61 7272 6179 266c 743b 6368 6172 2c20  :array<char, 
    │ │ │ +00060780: 3936 2667 743b 2072 6574 3b0a 0909 6175  96> ret;...au
    │ │ │ +00060790: 746f 2a20 6265 6769 6e20 3d20 7265 696e  to* begin = rein
    │ │ │ +000607a0: 7465 7270 7265 745f 6361 7374 266c 743b  terpret_cast<
    │ │ │ +000607b0: 7374 643a 3a75 696e 7438 5f74 2a26 6774  std::uint8_t*>
    │ │ │ +000607c0: 3b28 7265 742e 6461 7461 2829 293b 0a09  ;(ret.data());..
    │ │ │ +000607d0: 0973 7464 3a3a 7569 6e74 385f 742a 2065  .std::uint8_t* e
    │ │ │ +000607e0: 6e64 203d 206d 703a 3a65 7870 6f72 745f  nd = mp::export_
    │ │ │ +000607f0: 6269 7473 286b 2c20 6265 6769 6e2c 2038  bits(k, begin, 8
    │ │ │ +00060800: 293b 0a0a 3c64 6976 2073 7479 6c65 3d22  );..
    ..if (end < │ │ │ +00060840: 2062 6567 696e 202b 2039 3629 0a3c 2f64 begin + 96)...{....int co │ │ │ +00060860: 6e73 7420 6c65 6e20 3d20 696e 7428 656e nst len = int(en │ │ │ +00060870: 6420 2d20 6265 6769 6e29 3b0a 2369 6620 d - begin);.#if │ │ │ +00060880: 6465 6669 6e65 6420 5f5f 474e 5543 5f5f defined __GNUC__ │ │ │ +00060890: 2026 616d 703b 2661 6d70 3b20 5f5f 474e && __GN │ │ │ +000608a0: 5543 5f5f 203d 3d20 3132 0a23 7072 6167 UC__ == 12.#prag │ │ │ +000608b0: 6d61 2047 4343 2064 6961 676e 6f73 7469 ma GCC diagnosti │ │ │ +000608c0: 6320 7075 7368 0a23 7072 6167 6d61 2047 c push.#pragma G │ │ │ +000608d0: 4343 2064 6961 676e 6f73 7469 6320 6967 CC diagnostic ig │ │ │ +000608e0: 6e6f 7265 6420 222d 5773 7472 696e 676f nored "-Wstringo │ │ │ +000608f0: 702d 6f76 6572 666c 6f77 220a 2365 6e64 p-overflow".#end │ │ │ +00060900: 6966 0a09 0909 7374 643a 3a6d 656d 6d6f if....std::memmo │ │ │ +00060910: 7665 2862 6567 696e 202b 2039 3620 2d20 ve(begin + 96 - │ │ │ +00060920: 6c65 6e2c 2062 6567 696e 2c20 6175 783a len, begin, aux: │ │ │ +00060930: 3a6e 756d 6572 6963 5f63 6173 7426 6c74 :numeric_cast< │ │ │ +00060940: 3b73 7464 3a3a 7369 7a65 5f74 2667 743b ;std::size_t> │ │ │ +00060950: 286c 656e 2929 3b0a 2369 6620 6465 6669 (len));.#if defi │ │ │ +00060960: 6e65 6420 5f5f 474e 5543 5f5f 2026 616d ned __GNUC__ &am │ │ │ +00060970: 703b 2661 6d70 3b20 5f5f 474e 5543 5f5f p;& __GNUC__ │ │ │ +00060980: 203d 3d20 3132 0a23 7072 6167 6d61 2047 == 12.#pragma G │ │ │ +00060990: 4343 2064 6961 676e 6f73 7469 6320 706f CC diagnostic po │ │ │ +000609a0: 700a 2365 6e64 6966 0a09 0909 7374 643a p.#endif....std: │ │ │ +000609b0: 3a6d 656d 7365 7428 6265 6769 6e2c 2030 :memset(begin, 0 │ │ │ +000609c0: 2c20 6175 783a 3a6e 756d 6572 6963 5f63 , aux::numeric_c │ │ │ +000609d0: 6173 7426 6c74 3b73 7464 3a3a 7369 7a65 ast<std::size │ │ │ +000609e0: 5f74 2667 743b 2839 3620 2d20 6c65 6e29 _t>(96 - len) │ │ │ +000609f0: 293b 0a09 097d 0a09 0972 6574 7572 6e20 );...}...return │ │ │ +00060a00: 7265 743b 0a09 7d0a 0a09 766f 6964 2072 ret;..}...void r │ │ │ +00060a10: 6334 5f69 6e69 7428 636f 6e73 7420 756e c4_init(const un │ │ │ +00060a20: 7369 676e 6564 2063 6861 722a 2069 6e2c signed char* in, │ │ │ +00060a30: 2073 7464 3a3a 7369 7a65 5f74 206c 656e std::size_t len │ │ │ +00060a40: 2c20 7263 3420 2a73 7461 7465 293b 0a09 , rc4 *state);.. │ │ │ +00060a50: 7374 643a 3a73 697a 655f 7420 7263 345f std::size_t rc4_ │ │ │ +00060a60: 656e 6372 7970 7428 756e 7369 676e 6564 encrypt(unsigned │ │ │ +00060a70: 2063 6861 7220 2a6f 7574 2c20 7374 643a char *out, std: │ │ │ +00060a80: 3a73 697a 655f 7420 6f75 746c 656e 2c20 :size_t outlen, │ │ │ +00060a90: 7263 3420 2a73 7461 7465 293b 0a0a 092f rc4 *state);.../ │ │ │ +00060aa0: 2f20 5365 7420 7468 6520 7072 696d 6520 / Set the prime │ │ │ +00060ab0: 5020 616e 6420 7468 6520 6765 6e65 7261 P and the genera │ │ │ +00060ac0: 746f 722c 2067 656e 6572 6174 6520 6c6f tor, generate lo │ │ │ +00060ad0: 6361 6c20 7075 626c 6963 206b 6579 0a09 cal public key.. │ │ │ +00060ae0: 6468 5f6b 6579 5f65 7863 6861 6e67 653a dh_key_exchange: │ │ │ +00060af0: 3a64 685f 6b65 795f 6578 6368 616e 6765 :dh_key_exchange │ │ │ +00060b00: 2829 0a09 7b0a 0909 6175 783a 3a61 7272 ()..{...aux::arr │ │ │ +00060b10: 6179 266c 743b 7374 643a 3a75 696e 7438 ay<std::uint8 │ │ │ +00060b20: 5f74 2c20 3230 2667 743b 2072 616e 646f _t, 20> rando │ │ │ +00060b30: 6d5f 6b65 793b 0a09 0961 7578 3a3a 7261 m_key;...aux::ra │ │ │ +00060b40: 6e64 6f6d 5f62 7974 6573 287b 7265 696e ndom_bytes({rein │ │ │ +00060b50: 7465 7270 7265 745f 6361 7374 266c 743b terpret_cast< │ │ │ +00060b60: 6368 6172 2a26 6774 3b28 7261 6e64 6f6d char*>(random │ │ │ +00060b70: 5f6b 6579 2e64 6174 6128 2929 0a09 0909 _key.data()).... │ │ │ +00060b80: 2c20 7374 6174 6963 5f63 6173 7426 6c74 , static_cast< │ │ │ +00060b90: 3b73 7464 3a3a 7074 7264 6966 665f 7426 ;std::ptrdiff_t& │ │ │ +00060ba0: 6774 3b28 7261 6e64 6f6d 5f6b 6579 2e73 gt;(random_key.s │ │ │ +00060bb0: 697a 6528 2929 7d29 3b0a 0a09 092f 2f20 ize())});....// │ │ │ +00060bc0: 6372 6561 7465 206c 6f63 616c 206b 6579 create local key │ │ │ +00060bd0: 2028 7261 6e64 6f6d 290a 0909 6d70 3a3a (random)...mp:: │ │ │ +00060be0: 696d 706f 7274 5f62 6974 7328 6d5f 6468 import_bits(m_dh │ │ │ +00060bf0: 5f6c 6f63 616c 5f73 6563 7265 742c 2072 _local_secret, r │ │ │ +00060c00: 616e 646f 6d5f 6b65 792e 6265 6769 6e28 andom_key.begin( │ │ │ +00060c10: 292c 2072 616e 646f 6d5f 6b65 792e 656e ), random_key.en │ │ │ +00060c20: 6428 2929 3b0a 0a09 092f 2f20 6b65 7920 d());....// key │ │ │ +00060c30: 3d20 2832 205e 2073 6563 7265 7429 2025 = (2 ^ secret) % │ │ │ +00060c40: 2070 7269 6d65 0a09 096d 5f64 685f 6c6f prime...m_dh_lo │ │ │ +00060c50: 6361 6c5f 6b65 7920 3d20 6d70 3a3a 706f cal_key = mp::po │ │ │ +00060c60: 776d 286b 6579 5f74 2832 292c 206d 5f64 wm(key_t(2), m_d │ │ │ +00060c70: 685f 6c6f 6361 6c5f 7365 6372 6574 2c20 h_local_secret, │ │ │ +00060c80: 6468 5f70 7269 6d65 293b 0a3c 2f70 7265 dh_prime);.
    rele │ │ │ +00060cc0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/mma │ │ │ +00060d00: 705f 6469 736b 5f69 6f2e 6370 703a 3537 p_disk_io.cpp:57 │ │ │ +00060d10: 383c 2f61 3e3c 2f74 643e 3c74 643e 696e 8in │ │ │ +00060d20: 2074 6865 2066 7574 7572 652c 2070 726f the future, pro │ │ │ +00060d30: 7061 6761 7465 2065 7863 6570 7469 6f6e pagate exception │ │ │ +00060d40: 7320 6261 636b 2074 6f20 7468 6520 6861 s back to the ha │ │ │ +00060d50: 6e64 6c65 7273 3c2f 7464 3e3c 2f74 723e ndlers │ │ │ +00060d60: 3c74 7220 6964 3d22 3232 3222 2073 7479 │ │ │ +00060d90: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00060da0: 3c68 323e 696e 2074 6865 2066 7574 7572

    in the futur │ │ │ +00060db0: 652c 2070 726f 7061 6761 7465 2065 7863 e, propagate exc │ │ │ +00060dc0: 6570 7469 6f6e 7320 6261 636b 2074 6f20 eptions back to │ │ │ +00060dd0: 7468 6520 6861 6e64 6c65 7273 3c2f 6832 the handlers

    ../src/mmap │ │ │ +00060df0: 5f64 6973 6b5f 696f 2e63 7070 3a35 3738 _disk_io.cpp:578 │ │ │ +00060e00: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    #
    │ │ │ +00060e40: 6966 2044 4542 5547 5f44 4953 4b5f 5448  if DEBUG_DISK_TH
    │ │ │ +00060e50: 5245 4144 0a09 097b 0a09 0909 7374 643a  READ...{....std:
    │ │ │ +00060e60: 3a75 6e69 7175 655f 6c6f 636b 266c 743b  :unique_lock<
    │ │ │ +00060e70: 7374 643a 3a6d 7574 6578 2667 743b 206c  std::mutex> l
    │ │ │ +00060e80: 286d 5f6a 6f62 5f6d 7574 6578 293b 0a0a  (m_job_mutex);..
    │ │ │ +00060e90: 0909 0944 4c4f 4728 2270 6572 666f 726d  ...DLOG("perform
    │ │ │ +00060ea0: 5f6a 6f62 206a 6f62 3a20 2573 2028 2025  _job job: %s ( %
    │ │ │ +00060eb0: 7325 7329 2070 6965 6365 3a20 2564 206f  s%s) piece: %d o
    │ │ │ +00060ec0: 6666 7365 743a 2025 6420 6f75 7473 7461  ffset: %d outsta
    │ │ │ +00060ed0: 6e64 696e 673a 2025 645c 6e22 0a09 0909  nding: %d\n"....
    │ │ │ +00060ee0: 092c 206a 6f62 5f61 6374 696f 6e5f 6e61  ., job_action_na
    │ │ │ +00060ef0: 6d65 5b6a 2d26 6774 3b61 6374 696f 6e5d  me[j->action]
    │ │ │ +00060f00: 0a09 0909 092c 2028 6a2d 2667 743b 666c  ....., (j->fl
    │ │ │ +00060f10: 6167 7320 2661 6d70 3b20 6d6d 6170 5f64  ags & mmap_d
    │ │ │ +00060f20: 6973 6b5f 6a6f 623a 3a66 656e 6365 2920  isk_job::fence) 
    │ │ │ +00060f30: 3f20 2266 656e 6365 2022 3a20 2222 0a09  ? "fence ": ""..
    │ │ │ +00060f40: 0909 092c 2028 6a2d 2667 743b 666c 6167  ..., (j->flag
    │ │ │ +00060f50: 7320 2661 6d70 3b20 6d6d 6170 5f64 6973  s & mmap_dis
    │ │ │ +00060f60: 6b5f 6a6f 623a 3a66 6f72 6365 5f63 6f70  k_job::force_cop
    │ │ │ +00060f70: 7929 203f 2022 666f 7263 655f 636f 7079  y) ? "force_copy
    │ │ │ +00060f80: 2022 3a20 2222 0a09 0909 092c 2073 7461   ": ""....., sta
    │ │ │ +00060f90: 7469 635f 6361 7374 266c 743b 696e 7426  tic_cast<int&
    │ │ │ +00060fa0: 6774 3b28 6a2d 2667 743b 7069 6563 6529  gt;(j->piece)
    │ │ │ +00060fb0: 2c20 6a2d 2667 743b 642e 696f 2e6f 6666  , j->d.io.off
    │ │ │ +00060fc0: 7365 740a 0909 0909 2c20 6a2d 2667 743b  set....., j->
    │ │ │ +00060fd0: 7374 6f72 6167 6520 3f20 6a2d 2667 743b  storage ? j->
    │ │ │ +00060fe0: 7374 6f72 6167 652d 2667 743b 6e75 6d5f  storage->num_
    │ │ │ +00060ff0: 6f75 7473 7461 6e64 696e 675f 6a6f 6273  outstanding_jobs
    │ │ │ +00061000: 2829 203a 202d 3129 3b0a 0909 7d0a 2365  () : -1);...}.#e
    │ │ │ +00061010: 6e64 6966 0a0a 0909 7374 643a 3a73 6861  ndif....std::sha
    │ │ │ +00061020: 7265 645f 7074 7226 6c74 3b6d 6d61 705f  red_ptr<mmap_
    │ │ │ +00061030: 7374 6f72 6167 6526 6774 3b20 7374 6f72  storage> stor
    │ │ │ +00061040: 6167 6520 3d20 6a2d 2667 743b 7374 6f72  age = j->stor
    │ │ │ +00061050: 6167 653b 0a0a 0909 544f 5252 454e 545f  age;....TORRENT_
    │ │ │ +00061060: 4153 5345 5254 2873 7461 7469 635f 6361  ASSERT(static_ca
    │ │ │ +00061070: 7374 266c 743b 696e 7426 6774 3b28 6a2d  st<int>(j-
    │ │ │ +00061080: 2667 743b 6163 7469 6f6e 2920 266c 743b  >action) <
    │ │ │ +00061090: 2069 6e74 286a 6f62 5f66 756e 6374 696f   int(job_functio
    │ │ │ +000610a0: 6e73 2e73 697a 6528 2929 293b 0a0a 0909  ns.size()));....
    │ │ │ +000610b0: 6d5f 7374 6174 735f 636f 756e 7465 7273  m_stats_counters
    │ │ │ +000610c0: 2e69 6e63 5f73 7461 7473 5f63 6f75 6e74  .inc_stats_count
    │ │ │ +000610d0: 6572 2863 6f75 6e74 6572 733a 3a6e 756d  er(counters::num
    │ │ │ +000610e0: 5f72 756e 6e69 6e67 5f64 6973 6b5f 6a6f  _running_disk_jo
    │ │ │ +000610f0: 6273 2c20 3129 3b0a 0a09 092f 2f20 6361  bs, 1);....// ca
    │ │ │ +00061100: 6c6c 2064 6973 6b20 6675 6e63 7469 6f6e  ll disk function
    │ │ │ +00061110: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +00061140: 0973 7461 7475 735f 7420 7265 7420 3d20 .status_t ret = │ │ │ +00061150: 7374 6174 7573 5f74 3a3a 6e6f 5f65 7272 status_t::no_err │ │ │ +00061160: 6f72 3b0a 3c2f 6469 763e 0909 7472 790a or;.
    ..try. │ │ │ +00061170: 0909 7b0a 0909 0969 6e74 2063 6f6e 7374 ..{....int const │ │ │ +00061180: 2069 6478 203d 2073 7461 7469 635f 6361 idx = static_ca │ │ │ +00061190: 7374 266c 743b 696e 7426 6774 3b28 6a2d st<int>(j- │ │ │ +000611a0: 2667 743b 6163 7469 6f6e 293b 0a09 0909 >action);.... │ │ │ +000611b0: 7265 7420 3d20 2874 6869 732d 2667 743b ret = (this-> │ │ │ +000611c0: 2a28 6a6f 625f 6675 6e63 7469 6f6e 735b *(job_functions[ │ │ │ +000611d0: 7374 6174 6963 5f63 6173 7426 6c74 3b73 static_cast<s │ │ │ +000611e0: 7464 3a3a 7369 7a65 5f74 2667 743b 2869 td::size_t>(i │ │ │ +000611f0: 6478 295d 2929 286a 293b 0a09 097d 0a09 dx)]))(j);...}.. │ │ │ +00061200: 0963 6174 6368 2028 626f 6f73 743a 3a73 .catch (boost::s │ │ │ +00061210: 7973 7465 6d3a 3a73 7973 7465 6d5f 6572 ystem::system_er │ │ │ +00061220: 726f 7220 636f 6e73 7426 616d 703b 2065 ror const& e │ │ │ +00061230: 7272 290a 0909 7b0a 0909 0972 6574 203d rr)...{....ret = │ │ │ +00061240: 2073 7461 7475 735f 743a 3a66 6174 616c status_t::fatal │ │ │ +00061250: 5f64 6973 6b5f 6572 726f 723b 0a09 0909 _disk_error;.... │ │ │ +00061260: 6a2d 2667 743b 6572 726f 722e 6563 203d j->error.ec = │ │ │ +00061270: 2065 7272 2e63 6f64 6528 293b 0a09 0909 err.code();.... │ │ │ +00061280: 6a2d 2667 743b 6572 726f 722e 6f70 6572 j->error.oper │ │ │ +00061290: 6174 696f 6e20 3d20 6f70 6572 6174 696f ation = operatio │ │ │ +000612a0: 6e5f 743a 3a65 7863 6570 7469 6f6e 3b0a n_t::exception;. │ │ │ +000612b0: 0909 7d0a 0909 6361 7463 6820 2873 7464 ..}...catch (std │ │ │ +000612c0: 3a3a 6261 645f 616c 6c6f 6320 636f 6e73 ::bad_alloc cons │ │ │ +000612d0: 7426 616d 703b 290a 0909 7b0a 0909 0972 t&)...{....r │ │ │ +000612e0: 6574 203d 2073 7461 7475 735f 743a 3a66 et = status_t::f │ │ │ +000612f0: 6174 616c 5f64 6973 6b5f 6572 726f 723b atal_disk_error; │ │ │ +00061300: 0a09 0909 6a2d 2667 743b 6572 726f 722e ....j->error. │ │ │ +00061310: 6563 203d 2065 7272 6f72 733a 3a6e 6f5f ec = errors::no_ │ │ │ +00061320: 6d65 6d6f 7279 3b0a 0909 096a 2d26 6774 memory;....j-> │ │ │ +00061330: 3b65 7272 6f72 2e6f 7065 7261 7469 6f6e ;error.operation │ │ │ +00061340: 203d 206f 7065 7261 7469 6f6e 5f74 3a3a = operation_t:: │ │ │ +00061350: 6578 6365 7074 696f 6e3b 0a09 097d 0a09 exception;...}.. │ │ │ +00061360: 0963 6174 6368 2028 7374 643a 3a65 7863 .catch (std::exc │ │ │ +00061370: 6570 7469 6f6e 2063 6f6e 7374 2661 6d70 eption const& │ │ │ +00061380: 3b29 0a09 097b 0a09 0909 7265 7420 3d20 ;)...{....ret = │ │ │ +00061390: 7374 6174 7573 5f74 3a3a 6661 7461 6c5f status_t::fatal_ │ │ │ +000613a0: 6469 736b 5f65 7272 6f72 3b0a 0909 096a disk_error;....j │ │ │ +000613b0: 2d26 6774 3b65 7272 6f72 2e65 6320 3d20 ->error.ec = │ │ │ +000613c0: 626f 6f73 743a 3a61 7369 6f3a 3a65 7272 boost::asio::err │ │ │ +000613d0: 6f72 3a3a 6661 756c 743b 0a09 0909 6a2d or::fault;....j- │ │ │ +000613e0: 2667 743b 6572 726f 722e 6f70 6572 6174 >error.operat │ │ │ +000613f0: 696f 6e20 3d20 6f70 6572 6174 696f 6e5f ion = operation_ │ │ │ +00061400: 743a 3a65 7863 6570 7469 6f6e 3b0a 0909 t::exception;... │ │ │ +00061410: 7d0a 0a09 092f 2f20 6e6f 7465 2074 6861 }....// note tha │ │ │ +00061420: 7420 2d32 2065 7272 6f72 7320 6172 6520 t -2 errors are │ │ │ +00061430: 4f4b 0a09 0954 4f52 5245 4e54 5f41 5353 OK...TORRENT_ASS │ │ │ +00061440: 4552 5428 7265 7420 213d 2073 7461 7475 ERT(ret != statu │ │ │ +00061450: 735f 743a 3a66 6174 616c 5f64 6973 6b5f s_t::fatal_disk_ │ │ │ +00061460: 6572 726f 720a 0909 097c 7c20 286a 2d26 error....|| (j-& │ │ │ +00061470: 6774 3b65 7272 6f72 2e65 6320 2661 6d70 gt;error.ec & │ │ │ +00061480: 3b26 616d 703b 206a 2d26 6774 3b65 7272 ;& j->err │ │ │ +00061490: 6f72 2e6f 7065 7261 7469 6f6e 2021 3d20 or.operation != │ │ │ +000614a0: 6f70 6572 6174 696f 6e5f 743a 3a75 6e6b operation_t::unk │ │ │ +000614b0: 6e6f 776e 2929 3b0a 0a09 096d 5f73 7461 nown));....m_sta │ │ │ +000614c0: 7473 5f63 6f75 6e74 6572 732e 696e 635f ts_counters.inc_ │ │ │ +000614d0: 7374 6174 735f 636f 756e 7465 7228 636f stats_counter(co │ │ │ +000614e0: 756e 7465 7273 3a3a 6e75 6d5f 7275 6e6e unters::num_runn │ │ │ +000614f0: 696e 675f 6469 736b 5f6a 6f62 732c 202d ing_disk_jobs, - │ │ │ +00061500: 3129 3b0a 0a3c 2f70 7265 3e3c 2f74 643e 1);..
    │ │ │ +00061510: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +00061540: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +00061550: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +00061560: 7074 3a65 7870 616e 6428 3232 3329 223e pt:expand(223)"> │ │ │ +00061570: 2e2e 2f73 7263 2f6d 6d61 705f 6469 736b ../src/mmap_disk │ │ │ +00061580: 5f69 6f2e 6370 703a 3130 3137 3c2f 613e _io.cpp:1017 │ │ │ +00061590: 3c2f 7464 3e3c 7464 3e74 6869 7320 6973 this is │ │ │ +000615a0: 2070 6f74 656e 7469 616c 6c79 2076 6572 potentially ver │ │ │ +000615b0: 7920 6578 7065 6e73 6976 652e 204f 6e65 y expensive. One │ │ │ +000615c0: 2077 6179 2074 6f20 736f 6c76 6520 6974 way to solve it │ │ │ +000615d0: 2077 6f75 6c64 2062 6520 746f 2068 6176 would be to hav │ │ │ +000615e0: 6520 6120 6665 6e63 6520 666f 7220 6a75 e a fence for ju │ │ │ +000615f0: 7374 2074 6869 7320 6f6e 6520 7069 6563 st this one piec │ │ │ +00061600: 652e 2062 7574 2069 7420 6861 7264 6c79 e. but it hardly │ │ │ +00061610: 2073 6565 6d73 2077 6f72 7468 2074 6865 seems worth the │ │ │ +00061620: 2063 6f6d 706c 6578 6974 7920 616e 6420 complexity and │ │ │ +00061630: 636f 7374 206a 7573 7420 666f 7220 7468 cost just for th │ │ │ +00061640: 6520 6564 6765 2063 6173 6520 6f66 2072 e edge case of r │ │ │ +00061650: 6563 6569 7669 6e67 2061 2063 6f72 7275 eceiving a corru │ │ │ +00061660: 7074 2070 6965 6365 3c2f 7464 3e3c 2f74 pt piece

    this is po │ │ │ +000616c0: 7465 6e74 6961 6c6c 7920 7665 7279 2065 tentially very e │ │ │ +000616d0: 7870 656e 7369 7665 2e20 4f6e 6520 7761 xpensive. One wa │ │ │ +000616e0: 7920 746f 2073 6f6c 7665 0a69 7420 776f y to solve.it wo │ │ │ +000616f0: 756c 6420 6265 2074 6f20 6861 7665 2061 uld be to have a │ │ │ +00061700: 2066 656e 6365 2066 6f72 206a 7573 7420 fence for just │ │ │ +00061710: 7468 6973 206f 6e65 2070 6965 6365 2e0a this one piece.. │ │ │ +00061720: 6275 7420 6974 2068 6172 646c 7920 7365 but it hardly se │ │ │ +00061730: 656d 7320 776f 7274 6820 7468 6520 636f ems worth the co │ │ │ +00061740: 6d70 6c65 7869 7479 2061 6e64 2063 6f73 mplexity and cos │ │ │ +00061750: 7420 6a75 7374 2066 6f72 2074 6865 2065 t just for the e │ │ │ +00061760: 6467 650a 6361 7365 206f 6620 7265 6365 dge.case of rece │ │ │ +00061770: 6976 696e 6720 6120 636f 7272 7570 7420 iving a corrupt │ │ │ +00061780: 7069 6563 653c 2f68 323e 3c68 343e 2e2e piece

    .. │ │ │ +00061790: 2f73 7263 2f6d 6d61 705f 6469 736b 5f69 /src/mmap_disk_i │ │ │ +000617a0: 6f2e 6370 703a 3130 3137 3c2f 6834 3e3c o.cpp:1017

    < │ │ │ +000617b0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +000617c0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +000617d0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +000617e0: 7820 2364 6464 3b22 3e09 0961 7578 3a3a x #ddd;">..aux:: │ │ │ +000617f0: 6d6d 6170 5f64 6973 6b5f 6a6f 622a 206a mmap_disk_job* j │ │ │ +00061800: 203d 206d 5f6a 6f62 5f70 6f6f 6c2e 616c = m_job_pool.al │ │ │ +00061810: 6c6f 6361 7465 5f6a 6f62 2861 7578 3a3a locate_job(aux:: │ │ │ +00061820: 6a6f 625f 6163 7469 6f6e 5f74 3a3a 6669 job_action_t::fi │ │ │ +00061830: 6c65 5f70 7269 6f72 6974 7929 3b0a 0909 le_priority);... │ │ │ +00061840: 6a2d 2667 743b 7374 6f72 6167 6520 3d20 j->storage = │ │ │ +00061850: 6d5f 746f 7272 656e 7473 5b73 746f 7261 m_torrents[stora │ │ │ +00061860: 6765 5d2d 2667 743b 7368 6172 6564 5f66 ge]->shared_f │ │ │ +00061870: 726f 6d5f 7468 6973 2829 3b0a 0909 6a2d rom_this();...j- │ │ │ +00061880: 2667 743b 6172 6775 6d65 6e74 203d 2073 >argument = s │ │ │ +00061890: 7464 3a3a 6d6f 7665 2870 7269 6f73 293b td::move(prios); │ │ │ +000618a0: 0a09 096a 2d26 6774 3b63 616c 6c62 6163 ...j->callbac │ │ │ +000618b0: 6b20 3d20 7374 643a 3a6d 6f76 6528 6861 k = std::move(ha │ │ │ +000618c0: 6e64 6c65 7229 3b0a 0a09 0961 6464 5f66 ndler);....add_f │ │ │ +000618d0: 656e 6365 5f6a 6f62 286a 293b 0a09 7d0a ence_job(j);..}. │ │ │ +000618e0: 0a09 766f 6964 206d 6d61 705f 6469 736b ..void mmap_disk │ │ │ +000618f0: 5f69 6f3a 3a61 7379 6e63 5f63 6c65 6172 _io::async_clear │ │ │ +00061900: 5f70 6965 6365 2873 746f 7261 6765 5f69 _piece(storage_i │ │ │ +00061910: 6e64 6578 5f74 2063 6f6e 7374 2073 746f ndex_t const sto │ │ │ +00061920: 7261 6765 0a09 092c 2070 6965 6365 5f69 rage..., piece_i │ │ │ +00061930: 6e64 6578 5f74 2063 6f6e 7374 2069 6e64 ndex_t const ind │ │ │ +00061940: 6578 2c20 7374 643a 3a66 756e 6374 696f ex, std::functio │ │ │ +00061950: 6e26 6c74 3b76 6f69 6428 7069 6563 655f n<void(piece_ │ │ │ +00061960: 696e 6465 785f 7429 2667 743b 2068 616e index_t)> han │ │ │ +00061970: 646c 6572 290a 097b 0a09 0961 7578 3a3a dler)..{...aux:: │ │ │ +00061980: 6d6d 6170 5f64 6973 6b5f 6a6f 622a 206a mmap_disk_job* j │ │ │ +00061990: 203d 206d 5f6a 6f62 5f70 6f6f 6c2e 616c = m_job_pool.al │ │ │ +000619a0: 6c6f 6361 7465 5f6a 6f62 2861 7578 3a3a locate_job(aux:: │ │ │ +000619b0: 6a6f 625f 6163 7469 6f6e 5f74 3a3a 636c job_action_t::cl │ │ │ +000619c0: 6561 725f 7069 6563 6529 3b0a 0909 6a2d ear_piece);...j- │ │ │ +000619d0: 2667 743b 7374 6f72 6167 6520 3d20 6d5f >storage = m_ │ │ │ +000619e0: 746f 7272 656e 7473 5b73 746f 7261 6765 torrents[storage │ │ │ +000619f0: 5d2d 2667 743b 7368 6172 6564 5f66 726f ]->shared_fro │ │ │ +00061a00: 6d5f 7468 6973 2829 3b0a 0909 6a2d 2667 m_this();...j-&g │ │ │ +00061a10: 743b 7069 6563 6520 3d20 696e 6465 783b t;piece = index; │ │ │ +00061a20: 0a09 096a 2d26 6774 3b63 616c 6c62 6163 ...j->callbac │ │ │ +00061a30: 6b20 3d20 7374 643a 3a6d 6f76 6528 6861 k = std::move(ha │ │ │ +00061a40: 6e64 6c65 7229 3b0a 0a09 092f 2f20 7265 ndler);....// re │ │ │ +00061a50: 6775 6c61 7220 6a6f 6273 2061 7265 206e gular jobs are n │ │ │ +00061a60: 6f74 2067 7561 7261 6e74 6565 6420 746f ot guaranteed to │ │ │ +00061a70: 2062 6520 6578 6563 7574 6564 2069 6e2d be executed in- │ │ │ +00061a80: 6f72 6465 720a 0909 2f2f 2073 696e 6365 order...// since │ │ │ +00061a90: 2063 6c65 6172 2070 6965 6365 206d 7573 clear piece mus │ │ │ +00061aa0: 7420 6775 6172 616e 7465 6520 7468 6174 t guarantee that │ │ │ +00061ab0: 2061 6c6c 2077 7269 7465 206a 6f62 7320 all write jobs │ │ │ +00061ac0: 7468 6174 0a09 092f 2f20 6861 7665 2062 that...// have b │ │ │ +00061ad0: 6565 6e20 6973 7375 6564 2066 696e 6973 een issued finis │ │ │ +00061ae0: 6820 6265 666f 7265 2074 6865 2063 6c65 h before the cle │ │ │ +00061af0: 6172 2070 6965 6365 206a 6f62 2063 6f6d ar piece job com │ │ │ +00061b00: 706c 6574 6573 0a0a 3c64 6976 2073 7479 pletes..
    .

    re │ │ │ +00061b70: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/m │ │ │ +00061bb0: 6d61 705f 6469 736b 5f69 6f2e 6370 703a map_disk_io.cpp: │ │ │ +00061bc0: 3130 3232 3c2f 613e 3c2f 7464 3e3c 7464 1022Perhaps the job │ │ │ +00061be0: 2071 7565 7565 2063 6f75 6c64 2062 6520 queue could be │ │ │ +00061bf0: 7472 6176 6572 7365 6420 616e 6420 616c traversed and al │ │ │ +00061c00: 6c20 6a6f 6273 2066 6f72 2074 6869 7320 l jobs for this │ │ │ +00061c10: 7069 6563 6520 636f 756c 6420 6265 2063 piece could be c │ │ │ +00061c20: 616e 6365 6c6c 6564 2e20 4966 2074 6865 ancelled. If the │ │ │ +00061c30: 7265 2061 7265 206e 6f20 7468 7265 6164 re are no thread │ │ │ +00061c40: 7320 6375 7272 656e 746c 7920 7772 6974 s currently writ │ │ │ +00061c50: 696e 6720 746f 2074 6869 7320 7069 6563 ing to this piec │ │ │ +00061c60: 652c 2077 6520 636f 756c 6420 736b 6970 e, we could skip │ │ │ +00061c70: 2074 6865 2066 656e 6365 2061 6c74 6f67 the fence altog │ │ │ +00061c80: 6574 6865 723c 2f74 643e 3c2f 7472 3e3c ether< │ │ │ +00061c90: 7472 2069 643d 2232 3234 2220 7374 796c tr id="224" styl │ │ │ +00061ca0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00061cb0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00061cc0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00061cd0: 6832 3e50 6572 6861 7073 2074 6865 206a h2>Perhaps the j │ │ │ +00061ce0: 6f62 2071 7565 7565 2063 6f75 6c64 2062 ob queue could b │ │ │ +00061cf0: 6520 7472 6176 6572 7365 6420 616e 6420 e traversed and │ │ │ +00061d00: 616c 6c20 6a6f 6273 2066 6f72 2074 6869 all jobs for thi │ │ │ +00061d10: 730a 7069 6563 6520 636f 756c 6420 6265 s.piece could be │ │ │ +00061d20: 2063 616e 6365 6c6c 6564 2e20 4966 2074 cancelled. If t │ │ │ +00061d30: 6865 7265 2061 7265 206e 6f20 7468 7265 here are no thre │ │ │ +00061d40: 6164 7320 6375 7272 656e 746c 7920 7772 ads currently wr │ │ │ +00061d50: 6974 696e 670a 746f 2074 6869 7320 7069 iting.to this pi │ │ │ +00061d60: 6563 652c 2077 6520 636f 756c 6420 736b ece, we could sk │ │ │ +00061d70: 6970 2074 6865 2066 656e 6365 2061 6c74 ip the fence alt │ │ │ +00061d80: 6f67 6574 6865 723c 2f68 323e 3c68 343e ogether

    │ │ │ +00061d90: 2e2e 2f73 7263 2f6d 6d61 705f 6469 736b ../src/mmap_disk │ │ │ +00061da0: 5f69 6f2e 6370 703a 3130 3232 3c2f 6834 _io.cpp:1022

    ..j-&
    │ │ │ +00061df0: 6774 3b73 746f 7261 6765 203d 206d 5f74  gt;storage = m_t
    │ │ │ +00061e00: 6f72 7265 6e74 735b 7374 6f72 6167 655d  orrents[storage]
    │ │ │ +00061e10: 2d26 6774 3b73 6861 7265 645f 6672 6f6d  ->shared_from
    │ │ │ +00061e20: 5f74 6869 7328 293b 0a09 096a 2d26 6774  _this();...j->
    │ │ │ +00061e30: 3b61 7267 756d 656e 7420 3d20 7374 643a  ;argument = std:
    │ │ │ +00061e40: 3a6d 6f76 6528 7072 696f 7329 3b0a 0909  :move(prios);...
    │ │ │ +00061e50: 6a2d 2667 743b 6361 6c6c 6261 636b 203d  j->callback =
    │ │ │ +00061e60: 2073 7464 3a3a 6d6f 7665 2868 616e 646c   std::move(handl
    │ │ │ +00061e70: 6572 293b 0a0a 0909 6164 645f 6665 6e63  er);....add_fenc
    │ │ │ +00061e80: 655f 6a6f 6228 6a29 3b0a 097d 0a0a 0976  e_job(j);..}...v
    │ │ │ +00061e90: 6f69 6420 6d6d 6170 5f64 6973 6b5f 696f  oid mmap_disk_io
    │ │ │ +00061ea0: 3a3a 6173 796e 635f 636c 6561 725f 7069  ::async_clear_pi
    │ │ │ +00061eb0: 6563 6528 7374 6f72 6167 655f 696e 6465  ece(storage_inde
    │ │ │ +00061ec0: 785f 7420 636f 6e73 7420 7374 6f72 6167  x_t const storag
    │ │ │ +00061ed0: 650a 0909 2c20 7069 6563 655f 696e 6465  e..., piece_inde
    │ │ │ +00061ee0: 785f 7420 636f 6e73 7420 696e 6465 782c  x_t const index,
    │ │ │ +00061ef0: 2073 7464 3a3a 6675 6e63 7469 6f6e 266c   std::function&l
    │ │ │ +00061f00: 743b 766f 6964 2870 6965 6365 5f69 6e64  t;void(piece_ind
    │ │ │ +00061f10: 6578 5f74 2926 6774 3b20 6861 6e64 6c65  ex_t)> handle
    │ │ │ +00061f20: 7229 0a09 7b0a 0909 6175 783a 3a6d 6d61  r)..{...aux::mma
    │ │ │ +00061f30: 705f 6469 736b 5f6a 6f62 2a20 6a20 3d20  p_disk_job* j = 
    │ │ │ +00061f40: 6d5f 6a6f 625f 706f 6f6c 2e61 6c6c 6f63  m_job_pool.alloc
    │ │ │ +00061f50: 6174 655f 6a6f 6228 6175 783a 3a6a 6f62  ate_job(aux::job
    │ │ │ +00061f60: 5f61 6374 696f 6e5f 743a 3a63 6c65 6172  _action_t::clear
    │ │ │ +00061f70: 5f70 6965 6365 293b 0a09 096a 2d26 6774  _piece);...j->
    │ │ │ +00061f80: 3b73 746f 7261 6765 203d 206d 5f74 6f72  ;storage = m_tor
    │ │ │ +00061f90: 7265 6e74 735b 7374 6f72 6167 655d 2d26  rents[storage]-&
    │ │ │ +00061fa0: 6774 3b73 6861 7265 645f 6672 6f6d 5f74  gt;shared_from_t
    │ │ │ +00061fb0: 6869 7328 293b 0a09 096a 2d26 6774 3b70  his();...j->p
    │ │ │ +00061fc0: 6965 6365 203d 2069 6e64 6578 3b0a 0909  iece = index;...
    │ │ │ +00061fd0: 6a2d 2667 743b 6361 6c6c 6261 636b 203d  j->callback =
    │ │ │ +00061fe0: 2073 7464 3a3a 6d6f 7665 2868 616e 646c   std::move(handl
    │ │ │ +00061ff0: 6572 293b 0a0a 0909 2f2f 2072 6567 756c  er);....// regul
    │ │ │ +00062000: 6172 206a 6f62 7320 6172 6520 6e6f 7420  ar jobs are not 
    │ │ │ +00062010: 6775 6172 616e 7465 6564 2074 6f20 6265  guaranteed to be
    │ │ │ +00062020: 2065 7865 6375 7465 6420 696e 2d6f 7264   executed in-ord
    │ │ │ +00062030: 6572 0a09 092f 2f20 7369 6e63 6520 636c  er...// since cl
    │ │ │ +00062040: 6561 7220 7069 6563 6520 6d75 7374 2067  ear piece must g
    │ │ │ +00062050: 7561 7261 6e74 6565 2074 6861 7420 616c  uarantee that al
    │ │ │ +00062060: 6c20 7772 6974 6520 6a6f 6273 2074 6861  l write jobs tha
    │ │ │ +00062070: 740a 0909 2f2f 2068 6176 6520 6265 656e  t...// have been
    │ │ │ +00062080: 2069 7373 7565 6420 6669 6e69 7368 2062   issued finish b
    │ │ │ +00062090: 6566 6f72 6520 7468 6520 636c 6561 7220  efore the clear 
    │ │ │ +000620a0: 7069 6563 6520 6a6f 6220 636f 6d70 6c65  piece job comple
    │ │ │ +000620b0: 7465 730a 0a0a 3c64 6976 2073 7479 6c65  tes...
    ..add_fence_ │ │ │ +000620f0: 6a6f 6228 6a29 3b0a 3c2f 6469 763e 097d job(j);.
    .} │ │ │ +00062100: 0a0a 0973 7461 7475 735f 7420 6d6d 6170 ...status_t mmap │ │ │ +00062110: 5f64 6973 6b5f 696f 3a3a 646f 5f68 6173 _disk_io::do_has │ │ │ +00062120: 6828 6175 783a 3a6d 6d61 705f 6469 736b h(aux::mmap_disk │ │ │ +00062130: 5f6a 6f62 2a20 6a29 0a09 7b0a 0909 2f2f _job* j)..{...// │ │ │ +00062140: 2077 6527 7265 206e 6f74 2075 7369 6e67 we're not using │ │ │ +00062150: 2061 2063 6163 6865 2e20 5468 6973 2069 a cache. This i │ │ │ +00062160: 7320 7468 6520 7369 6d70 6c65 2070 6174 s the simple pat │ │ │ +00062170: 680a 0909 2f2f 206a 7573 7420 7265 6164 h...// just read │ │ │ +00062180: 2073 7472 6169 6768 7420 6672 6f6d 2074 straight from t │ │ │ +00062190: 6865 2066 696c 650a 0909 544f 5252 454e he file...TORREN │ │ │ +000621a0: 545f 4153 5345 5254 286d 5f6d 6167 6963 T_ASSERT(m_magic │ │ │ +000621b0: 203d 3d20 3078 3133 3337 293b 0a0a 0909 == 0x1337);.... │ │ │ +000621c0: 626f 6f6c 2063 6f6e 7374 2076 3120 3d20 bool const v1 = │ │ │ +000621d0: 626f 6f6c 286a 2d26 6774 3b66 6c61 6773 bool(j->flags │ │ │ +000621e0: 2026 616d 703b 2064 6973 6b5f 696e 7465 & disk_inte │ │ │ +000621f0: 7266 6163 653a 3a76 315f 6861 7368 293b rface::v1_hash); │ │ │ +00062200: 0a09 0962 6f6f 6c20 636f 6e73 7420 7632 ...bool const v2 │ │ │ +00062210: 203d 2021 6a2d 2667 743b 642e 682e 626c = !j->d.h.bl │ │ │ +00062220: 6f63 6b5f 6861 7368 6573 2e65 6d70 7479 ock_hashes.empty │ │ │ +00062230: 2829 3b0a 0a09 0969 6e74 2063 6f6e 7374 ();....int const │ │ │ +00062240: 2070 6965 6365 5f73 697a 6520 3d20 7631 piece_size = v1 │ │ │ +00062250: 203f 206a 2d26 6774 3b73 746f 7261 6765 ? j->storage │ │ │ +00062260: 2d26 6774 3b66 696c 6573 2829 2e70 6965 ->files().pie │ │ │ +00062270: 6365 5f73 697a 6528 6a2d 2667 743b 7069 ce_size(j->pi │ │ │ +00062280: 6563 6529 203a 2030 3b0a 0909 696e 7420 ece) : 0;...int │ │ │ +00062290: 636f 6e73 7420 7069 6563 655f 7369 7a65 const piece_size │ │ │ +000622a0: 3220 3d20 7632 203f 206a 2d26 6774 3b73 2 = v2 ? j->s │ │ │ +000622b0: 746f 7261 6765 2d26 6774 3b66 696c 6573 torage->files │ │ │ +000622c0: 2829 2e70 6965 6365 5f73 697a 6532 286a ().piece_size2(j │ │ │ +000622d0: 2d26 6774 3b70 6965 6365 2920 3a20 303b ->piece) : 0; │ │ │ +000622e0: 0a09 0969 6e74 2063 6f6e 7374 2062 6c6f ...int const blo │ │ │ +000622f0: 636b 735f 696e 5f70 6965 6365 203d 2076 cks_in_piece = v │ │ │ +00062300: 3120 3f20 2870 6965 6365 5f73 697a 6520 1 ? (piece_size │ │ │ +00062310: 2b20 6465 6661 756c 745f 626c 6f63 6b5f + default_block_ │ │ │ +00062320: 7369 7a65 202d 2031 2920 2f20 6465 6661 size - 1) / defa │ │ │ +00062330: 756c 745f 626c 6f63 6b5f 7369 7a65 203a ult_block_size : │ │ │ +00062340: 2030 3b0a 0909 696e 7420 636f 6e73 7420 0;...int const │ │ │ +00062350: 626c 6f63 6b73 5f69 6e5f 7069 6563 6532 blocks_in_piece2 │ │ │ +00062360: 203d 2076 3220 3f20 6a2d 2667 743b 7374 = v2 ? j->st │ │ │ +00062370: 6f72 6167 652d 2667 743b 6669 6c65 7328 orage->files( │ │ │ +00062380: 292e 626c 6f63 6b73 5f69 6e5f 7069 6563 ).blocks_in_piec │ │ │ +00062390: 6532 286a 2d26 6774 3b70 6965 6365 2920 e2(j->piece) │ │ │ +000623a0: 3a20 303b 0a09 0961 7578 3a3a 6f70 656e : 0;...aux::open │ │ │ +000623b0: 5f6d 6f64 655f 7420 636f 6e73 7420 6669 _mode_t const fi │ │ │ +000623c0: 6c65 5f6d 6f64 6520 3d20 6669 6c65 5f6d le_mode = file_m │ │ │ +000623d0: 6f64 655f 666f 725f 6a6f 6228 6a29 3b0a ode_for_job(j);. │ │ │ +000623e0: 0a09 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +000623f0: 5428 2176 3220 7c7c 2069 6e74 286a 2d26 T(!v2 || int(j-& │ │ │ +00062400: 6774 3b64 2e68 2e62 6c6f 636b 5f68 6173 gt;d.h.block_has │ │ │ +00062410: 6865 732e 7369 7a65 2829 2920 2667 743b hes.size()) > │ │ │ +00062420: 3d20 626c 6f63 6b73 5f69 6e5f 7069 6563 = blocks_in_piec │ │ │ +00062430: 6532 293b 0a09 0954 4f52 5245 4e54 5f41 e2);...TORRENT_A │ │ │ +00062440: 5353 4552 5428 7631 207c 7c20 7632 293b SSERT(v1 || v2); │ │ │ +00062450: 0a0a 0909 6861 7368 6572 2068 3b0a 0909 ....hasher h;... │ │ │ +00062460: 696e 7420 7265 7420 3d20 303b 0a09 0969 int ret = 0;...i │ │ │ +00062470: 6e74 206f 6666 7365 7420 3d20 303b 0a09 nt offset = 0;.. │ │ │ +00062480: 0969 6e74 2063 6f6e 7374 2062 6c6f 636b .int const block │ │ │ +00062490: 735f 746f 5f72 6561 6420 3d20 7374 643a s_to_read = std: │ │ │ +000624a0: 3a6d 6178 2862 6c6f 636b 735f 696e 5f70 :max(blocks_in_p │ │ │ +000624b0: 6965 6365 2c20 626c 6f63 6b73 5f69 6e5f iece, blocks_in_ │ │ │ +000624c0: 7069 6563 6532 293b 0a09 0974 696d 655f piece2);...time_ │ │ │ +000624d0: 706f 696e 7420 636f 6e73 7420 7374 6172 point const star │ │ │ +000624e0: 745f 7469 6d65 203d 2063 6c6f 636b 5f74 t_time = clock_t │ │ │ +000624f0: 7970 653a 3a6e 6f77 2829 3b0a 0909 666f ype::now();...fo │ │ │ +00062500: 7220 2869 6e74 2069 203d 2030 3b20 6920 r (int i = 0; i │ │ │ +00062510: 266c 743b 2062 6c6f 636b 735f 746f 5f72 < blocks_to_r │ │ │ +00062520: 6561 643b 202b 2b69 290a 0909 7b0a 0909 ead; ++i)...{... │ │ │ +00062530: 0962 6f6f 6c20 636f 6e73 7420 7632 5f62 .bool const v2_b │ │ │ +00062540: 6c6f 636b 203d 2069 2026 6c74 3b20 626c lock = i < bl │ │ │ +00062550: 6f63 6b73 5f69 6e5f 7069 6563 6532 3b0a ocks_in_piece2;. │ │ │ +00062560: 0a09 0909 444c 4f47 2822 646f 5f68 6173 ....DLOG("do_has │ │ │ +00062570: 683a 2072 6561 6469 6e67 2028 7069 6563 h: reading (piec │ │ │ +00062580: 653a 2025 6420 626c 6f63 6b3a 2025 6429 e: %d block: %d) │ │ │ +00062590: 5c6e 222c 2069 6e74 286a 2d26 6774 3b70 \n", int(j->p │ │ │ +000625a0: 6965 6365 292c 2069 293b 0a3c 2f70 7265 iece), i);.
    rele │ │ │ +000625e0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/loa │ │ │ +00062620: 645f 746f 7272 656e 742e 6370 703a 3132 d_torrent.cpp:12 │ │ │ +00062630: 313c 2f61 3e3c 2f74 643e 3c74 643e 6d6f 1mo │ │ │ +00062640: 7665 2074 6865 206c 6f61 6469 6e67 206c ve the loading l │ │ │ +00062650: 6f67 6963 2066 726f 6d20 746f 7272 656e ogic from torren │ │ │ +00062660: 745f 696e 666f 2063 6f6e 7374 7275 6374 t_info construct │ │ │ +00062670: 6f72 2069 6e74 6f20 6865 7265 3c2f 7464 or into here

    move t │ │ │ +000626d0: 6865 206c 6f61 6469 6e67 206c 6f67 6963 he loading logic │ │ │ +000626e0: 2066 726f 6d20 746f 7272 656e 745f 696e from torrent_in │ │ │ +000626f0: 666f 2063 6f6e 7374 7275 6374 6f72 2069 fo constructor i │ │ │ +00062700: 6e74 6f20 6865 7265 3c2f 6832 3e3c 6834 nto here

    ../src/load_tor │ │ │ +00062720: 7265 6e74 2e63 7070 3a31 3231 3c2f 6834 rent.cpp:121

    ....m
    │ │ │ +00062770: 6173 6b2e 7265 7369 7a65 2873 7464 3a3a  ask.resize(std::
    │ │ │ +00062780: 7369 7a65 5f74 2866 756c 6c5f 7369 7a65  size_t(full_size
    │ │ │ +00062790: 292c 2066 616c 7365 293b 0a09 0909 0966  ), false);.....f
    │ │ │ +000627a0: 6f72 2028 696e 7420 6920 3d20 6d65 726b  or (int i = merk
    │ │ │ +000627b0: 6c65 5f66 6972 7374 5f6c 6561 6628 7069  le_first_leaf(pi
    │ │ │ +000627c0: 6563 655f 6c61 7965 725f 7369 7a65 290a  ece_layer_size).
    │ │ │ +000627d0: 0909 0909 092c 2065 6e64 203d 2069 202b  ....., end = i +
    │ │ │ +000627e0: 206e 756d 5f70 6965 6365 733b 2069 2026   num_pieces; i &
    │ │ │ +000627f0: 6c74 3b20 656e 643b 202b 2b69 290a 0909  lt; end; ++i)...
    │ │ │ +00062800: 0909 7b0a 0909 0909 096d 6173 6b5b 7374  ..{......mask[st
    │ │ │ +00062810: 643a 3a73 697a 655f 7428 6929 5d20 3d20  d::size_t(i)] = 
    │ │ │ +00062820: 7472 7565 3b0a 0909 0909 7d0a 0909 097d  true;.....}....}
    │ │ │ +00062830: 0a09 0909 7469 2d26 6774 3b66 7265 655f  ....ti->free_
    │ │ │ +00062840: 7069 6563 655f 6c61 7965 7273 2829 3b0a  piece_layers();.
    │ │ │ +00062850: 0909 7d0a 0909 6174 702e 696e 666f 5f68  ..}...atp.info_h
    │ │ │ +00062860: 6173 6865 7320 3d20 6174 702e 7469 2d26  ashes = atp.ti-&
    │ │ │ +00062870: 6774 3b69 6e66 6f5f 6861 7368 6573 2829  gt;info_hashes()
    │ │ │ +00062880: 3b0a 097d 0a7d 0a0a 0961 6464 5f74 6f72  ;..}.}...add_tor
    │ │ │ +00062890: 7265 6e74 5f70 6172 616d 7320 6c6f 6164  rent_params load
    │ │ │ +000628a0: 5f74 6f72 7265 6e74 5f66 696c 6528 7374  _torrent_file(st
    │ │ │ +000628b0: 643a 3a73 7472 696e 6720 636f 6e73 7426  d::string const&
    │ │ │ +000628c0: 616d 703b 2066 696c 656e 616d 6529 0a09  amp; filename)..
    │ │ │ +000628d0: 7b20 7265 7475 726e 206c 6f61 645f 746f  { return load_to
    │ │ │ +000628e0: 7272 656e 745f 6669 6c65 2866 696c 656e  rrent_file(filen
    │ │ │ +000628f0: 616d 652c 206c 6f61 645f 746f 7272 656e  ame, load_torren
    │ │ │ +00062900: 745f 6c69 6d69 7473 7b7d 293b 207d 0a09  t_limits{}); }..
    │ │ │ +00062910: 6164 645f 746f 7272 656e 745f 7061 7261  add_torrent_para
    │ │ │ +00062920: 6d73 206c 6f61 645f 746f 7272 656e 745f  ms load_torrent_
    │ │ │ +00062930: 6275 6666 6572 2873 7061 6e26 6c74 3b63  buffer(span<c
    │ │ │ +00062940: 6861 7220 636f 6e73 7426 6774 3b20 6275  har const> bu
    │ │ │ +00062950: 6666 6572 290a 097b 2072 6574 7572 6e20  ffer)..{ return 
    │ │ │ +00062960: 6c6f 6164 5f74 6f72 7265 6e74 5f62 7566  load_torrent_buf
    │ │ │ +00062970: 6665 7228 6275 6666 6572 2c20 6c6f 6164  fer(buffer, load
    │ │ │ +00062980: 5f74 6f72 7265 6e74 5f6c 696d 6974 737b  _torrent_limits{
    │ │ │ +00062990: 7d29 3b20 7d0a 0961 6464 5f74 6f72 7265  }); }..add_torre
    │ │ │ +000629a0: 6e74 5f70 6172 616d 7320 6c6f 6164 5f74  nt_params load_t
    │ │ │ +000629b0: 6f72 7265 6e74 5f70 6172 7365 6428 6264  orrent_parsed(bd
    │ │ │ +000629c0: 6563 6f64 655f 6e6f 6465 2063 6f6e 7374  ecode_node const
    │ │ │ +000629d0: 2661 6d70 3b20 746f 7272 656e 745f 6669  & torrent_fi
    │ │ │ +000629e0: 6c65 290a 097b 2072 6574 7572 6e20 6c6f  le)..{ return lo
    │ │ │ +000629f0: 6164 5f74 6f72 7265 6e74 5f70 6172 7365  ad_torrent_parse
    │ │ │ +00062a00: 6428 746f 7272 656e 745f 6669 6c65 2c20  d(torrent_file, 
    │ │ │ +00062a10: 6c6f 6164 5f74 6f72 7265 6e74 5f6c 696d  load_torrent_lim
    │ │ │ +00062a20: 6974 737b 7d29 3b20 7d0a 0a3c 6469 7620  its{}); }..
    .add_to │ │ │ +00062a60: 7272 656e 745f 7061 7261 6d73 206c 6f61 rrent_params loa │ │ │ +00062a70: 645f 746f 7272 656e 745f 6669 6c65 2873 d_torrent_file(s │ │ │ +00062a80: 7464 3a3a 7374 7269 6e67 2063 6f6e 7374 td::string const │ │ │ +00062a90: 2661 6d70 3b20 6669 6c65 6e61 6d65 2c20 & filename, │ │ │ +00062aa0: 6c6f 6164 5f74 6f72 7265 6e74 5f6c 696d load_torrent_lim │ │ │ +00062ab0: 6974 7320 636f 6e73 7426 616d 703b 2063 its const& c │ │ │ +00062ac0: 6667 290a 3c2f 6469 763e 097b 0a09 0961 fg).
    .{...a │ │ │ +00062ad0: 6464 5f74 6f72 7265 6e74 5f70 6172 616d dd_torrent_param │ │ │ +00062ae0: 7320 7265 743b 0a09 0972 6574 2e74 6920 s ret;...ret.ti │ │ │ +00062af0: 3d20 7374 643a 3a6d 616b 655f 7368 6172 = std::make_shar │ │ │ +00062b00: 6564 266c 743b 746f 7272 656e 745f 696e ed<torrent_in │ │ │ +00062b10: 666f 2667 743b 2866 696c 656e 616d 652c fo>(filename, │ │ │ +00062b20: 2063 6667 293b 0a09 0975 7064 6174 655f cfg);...update_ │ │ │ +00062b30: 6174 7028 7265 7429 3b0a 0909 7265 7475 atp(ret);...retu │ │ │ +00062b40: 726e 2072 6574 3b0a 097d 0a0a 0961 6464 rn ret;..}...add │ │ │ +00062b50: 5f74 6f72 7265 6e74 5f70 6172 616d 7320 _torrent_params │ │ │ +00062b60: 6c6f 6164 5f74 6f72 7265 6e74 5f62 7566 load_torrent_buf │ │ │ +00062b70: 6665 7228 7370 616e 266c 743b 6368 6172 fer(span<char │ │ │ +00062b80: 2063 6f6e 7374 2667 743b 2062 7566 6665 const> buffe │ │ │ +00062b90: 722c 206c 6f61 645f 746f 7272 656e 745f r, load_torrent_ │ │ │ +00062ba0: 6c69 6d69 7473 2063 6f6e 7374 2661 6d70 limits const& │ │ │ +00062bb0: 3b20 6366 6729 0a09 7b0a 0909 6164 645f ; cfg)..{...add_ │ │ │ +00062bc0: 746f 7272 656e 745f 7061 7261 6d73 2072 torrent_params r │ │ │ +00062bd0: 6574 3b0a 0909 7265 742e 7469 203d 2073 et;...ret.ti = s │ │ │ +00062be0: 7464 3a3a 6d61 6b65 5f73 6861 7265 6426 td::make_shared& │ │ │ +00062bf0: 6c74 3b74 6f72 7265 6e74 5f69 6e66 6f26 lt;torrent_info& │ │ │ +00062c00: 6774 3b28 6275 6666 6572 2c20 6366 672c gt;(buffer, cfg, │ │ │ +00062c10: 2066 726f 6d5f 7370 616e 293b 0a09 0975 from_span);...u │ │ │ +00062c20: 7064 6174 655f 6174 7028 7265 7429 3b0a pdate_atp(ret);. │ │ │ +00062c30: 0909 7265 7475 726e 2072 6574 3b0a 097d ..return ret;..} │ │ │ +00062c40: 0a0a 0961 6464 5f74 6f72 7265 6e74 5f70 ...add_torrent_p │ │ │ +00062c50: 6172 616d 7320 6c6f 6164 5f74 6f72 7265 arams load_torre │ │ │ +00062c60: 6e74 5f70 6172 7365 6428 6264 6563 6f64 nt_parsed(bdecod │ │ │ +00062c70: 655f 6e6f 6465 2063 6f6e 7374 2661 6d70 e_node const& │ │ │ +00062c80: 3b20 746f 7272 656e 745f 6669 6c65 2c20 ; torrent_file, │ │ │ +00062c90: 6c6f 6164 5f74 6f72 7265 6e74 5f6c 696d load_torrent_lim │ │ │ +00062ca0: 6974 7320 636f 6e73 7426 616d 703b 2063 its const& c │ │ │ +00062cb0: 6667 290a 097b 0a09 0961 6464 5f74 6f72 fg)..{...add_tor │ │ │ +00062cc0: 7265 6e74 5f70 6172 616d 7320 7265 743b rent_params ret; │ │ │ +00062cd0: 0a09 0972 6574 2e74 6920 3d20 7374 643a ...ret.ti = std: │ │ │ +00062ce0: 3a6d 616b 655f 7368 6172 6564 266c 743b :make_shared< │ │ │ +00062cf0: 746f 7272 656e 745f 696e 666f 2667 743b torrent_info> │ │ │ +00062d00: 2874 6f72 7265 6e74 5f66 696c 652c 2063 (torrent_file, c │ │ │ +00062d10: 6667 293b 0a09 0975 7064 6174 655f 6174 fg);...update_at │ │ │ +00062d20: 7028 7265 7429 3b0a 0909 7265 7475 726e p(ret);...return │ │ │ +00062d30: 2072 6574 3b0a 097d 0a0a 7d0a 0a3c 2f70 ret;..}..}..

    re │ │ │ +00062d70: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/p │ │ │ +00062db0: 6572 666f 726d 616e 6365 5f63 6f75 6e74 erformance_count │ │ │ +00062dc0: 6572 732e 6370 703a 3430 3c2f 613e 3c2f ers.cpp:40move stat │ │ │ +00062de0: 735f 636f 756e 7465 725f 7420 6f75 7420 s_counter_t out │ │ │ +00062df0: 6f66 2063 6f75 6e74 6572 733c 2f74 643e of counters │ │ │ +00062e00: 3c2f 7472 3e3c 7472 2069 643d 2232 3236

    move st │ │ │ +00062e50: 6174 735f 636f 756e 7465 725f 7420 6f75 ats_counter_t ou │ │ │ +00062e60: 7420 6f66 2063 6f75 6e74 6572 733c 2f68 t of counters

    ../src/per │ │ │ +00062e80: 666f 726d 616e 6365 5f63 6f75 6e74 6572 formance_counter │ │ │ +00062e90: 732e 6370 703a 3430 3c2f 6834 3e3c 7072 s.cpp:40

    relevanc │ │ │ +00062f10: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/perform │ │ │ +00062f50: 616e 6365 5f63 6f75 6e74 6572 732e 6370 ance_counters.cp │ │ │ +00062f60: 703a 3431 3c2f 613e 3c2f 7464 3e3c 7464 p:41should bittorre │ │ │ +00062f80: 6e74 206b 6565 702d 616c 6976 6520 6d65 nt keep-alive me │ │ │ +00062f90: 7373 6167 6573 2068 6176 6520 6120 636f ssages have a co │ │ │ +00062fa0: 756e 7465 7220 746f 6f3f 3c2f 7464 3e3c unter too?< │ │ │ +00062fb0: 2f74 723e 3c74 7220 6964 3d22 3232 3722 /tr>

    should b │ │ │ +00063000: 6974 746f 7272 656e 7420 6b65 6570 2d61 ittorrent keep-a │ │ │ +00063010: 6c69 7665 206d 6573 7361 6765 7320 6861 live messages ha │ │ │ +00063020: 7665 2061 2063 6f75 6e74 6572 2074 6f6f ve a counter too │ │ │ +00063030: 3f3c 2f68 323e 3c68 343e 2e2e 2f73 7263 ?

    ../src │ │ │ +00063040: 2f70 6572 666f 726d 616e 6365 5f63 6f75 /performance_cou │ │ │ +00063050: 6e74 6572 732e 6370 703a 3431 3c2f 6834 nters.cpp:41

    rele
    │ │ │ +000630d0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../src/per
    │ │ │ +00063110: 666f 726d 616e 6365 5f63 6f75 6e74 6572  formance_counter
    │ │ │ +00063120: 732e 6370 703a 3432 3c2f 613e 3c2f 7464  s.cpp:42It would be
    │ │ │ +00063140: 206e 6963 6520 6966 2074 6869 7320 636f   nice if this co
    │ │ │ +00063150: 756c 6420 6265 2061 6e20 696e 7465 726e  uld be an intern
    │ │ │ +00063160: 616c 2074 7970 652e 2064 6566 6175 6c74  al type. default
    │ │ │ +00063170: 5f64 6973 6b5f 636f 6e73 7472 7563 746f  _disk_constructo
    │ │ │ +00063180: 7220 6465 7065 6e64 7320 6f6e 2069 7420  r depends on it 
    │ │ │ +00063190: 6e6f 773c 2f74 643e 3c2f 7472 3e3c 7472  now

    It would be nic │ │ │ +000631f0: 6520 6966 2074 6869 7320 636f 756c 6420 e if this could │ │ │ +00063200: 6265 2061 6e20 696e 7465 726e 616c 2074 be an internal t │ │ │ +00063210: 7970 652e 2064 6566 6175 6c74 5f64 6973 ype. default_dis │ │ │ +00063220: 6b5f 636f 6e73 7472 7563 746f 7220 6465 k_constructor de │ │ │ +00063230: 7065 6e64 7320 6f6e 2069 7420 6e6f 773c pends on it now< │ │ │ +00063240: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ +00063250: 6572 666f 726d 616e 6365 5f63 6f75 6e74 erformance_count │ │ │ +00063260: 6572 732e 6370 703a 3432 3c2f 6834 3e3c ers.cpp:42

    < │ │ │ +00063270: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00063280: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00063290: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +000632a0: 7820 2364 6464 3b22 3e54 4849 5320 534f x #ddd;">THIS SO │ │ │ +000632b0: 4654 5741 5245 2049 5320 5052 4f56 4944 FTWARE IS PROVID │ │ │ +000632c0: 4544 2042 5920 5448 4520 434f 5059 5249 ED BY THE COPYRI │ │ │ +000632d0: 4748 5420 484f 4c44 4552 5320 414e 4420 GHT HOLDERS AND │ │ │ +000632e0: 434f 4e54 5249 4255 544f 5253 2022 4153 CONTRIBUTORS "AS │ │ │ +000632f0: 2049 5322 0a41 4e44 2041 4e59 2045 5850 IS".AND ANY EXP │ │ │ +00063300: 5245 5353 204f 5220 494d 504c 4945 4420 RESS OR IMPLIED │ │ │ +00063310: 5741 5252 414e 5449 4553 2c20 494e 434c WARRANTIES, INCL │ │ │ +00063320: 5544 494e 472c 2042 5554 204e 4f54 204c UDING, BUT NOT L │ │ │ +00063330: 494d 4954 4544 2054 4f2c 2054 4845 0a49 IMITED TO, THE.I │ │ │ +00063340: 4d50 4c49 4544 2057 4152 5241 4e54 4945 MPLIED WARRANTIE │ │ │ +00063350: 5320 4f46 204d 4552 4348 414e 5441 4249 S OF MERCHANTABI │ │ │ +00063360: 4c49 5459 2041 4e44 2046 4954 4e45 5353 LITY AND FITNESS │ │ │ +00063370: 2046 4f52 2041 2050 4152 5449 4355 4c41 FOR A PARTICULA │ │ │ +00063380: 5220 5055 5250 4f53 450a 4152 4520 4449 R PURPOSE.ARE DI │ │ │ +00063390: 5343 4c41 494d 4544 2e20 494e 204e 4f20 SCLAIMED. IN NO │ │ │ +000633a0: 4556 454e 5420 5348 414c 4c20 5448 4520 EVENT SHALL THE │ │ │ +000633b0: 434f 5059 5249 4748 5420 4f57 4e45 5220 COPYRIGHT OWNER │ │ │ +000633c0: 4f52 2043 4f4e 5452 4942 5554 4f52 5320 OR CONTRIBUTORS │ │ │ +000633d0: 4245 0a4c 4941 424c 4520 464f 5220 414e BE.LIABLE FOR AN │ │ │ +000633e0: 5920 4449 5245 4354 2c20 494e 4449 5245 Y DIRECT, INDIRE │ │ │ +000633f0: 4354 2c20 494e 4349 4445 4e54 414c 2c20 CT, INCIDENTAL, │ │ │ +00063400: 5350 4543 4941 4c2c 2045 5845 4d50 4c41 SPECIAL, EXEMPLA │ │ │ +00063410: 5259 2c20 4f52 0a43 4f4e 5345 5155 454e RY, OR.CONSEQUEN │ │ │ +00063420: 5449 414c 2044 414d 4147 4553 2028 494e TIAL DAMAGES (IN │ │ │ +00063430: 434c 5544 494e 472c 2042 5554 204e 4f54 CLUDING, BUT NOT │ │ │ +00063440: 204c 494d 4954 4544 2054 4f2c 2050 524f LIMITED TO, PRO │ │ │ +00063450: 4355 5245 4d45 4e54 204f 460a 5355 4253 CUREMENT OF.SUBS │ │ │ +00063460: 5449 5455 5445 2047 4f4f 4453 204f 5220 TITUTE GOODS OR │ │ │ +00063470: 5345 5256 4943 4553 3b20 4c4f 5353 204f SERVICES; LOSS O │ │ │ +00063480: 4620 5553 452c 2044 4154 412c 204f 5220 F USE, DATA, OR │ │ │ +00063490: 5052 4f46 4954 533b 204f 5220 4255 5349 PROFITS; OR BUSI │ │ │ +000634a0: 4e45 5353 0a49 4e54 4552 5255 5054 494f NESS.INTERRUPTIO │ │ │ +000634b0: 4e29 2048 4f57 4556 4552 2043 4155 5345 N) HOWEVER CAUSE │ │ │ +000634c0: 4420 414e 4420 4f4e 2041 4e59 2054 4845 D AND ON ANY THE │ │ │ +000634d0: 4f52 5920 4f46 204c 4941 4249 4c49 5459 ORY OF LIABILITY │ │ │ +000634e0: 2c20 5748 4554 4845 5220 494e 0a43 4f4e , WHETHER IN.CON │ │ │ +000634f0: 5452 4143 542c 2053 5452 4943 5420 4c49 TRACT, STRICT LI │ │ │ +00063500: 4142 494c 4954 592c 204f 5220 544f 5254 ABILITY, OR TORT │ │ │ +00063510: 2028 494e 434c 5544 494e 4720 4e45 474c (INCLUDING NEGL │ │ │ +00063520: 4947 454e 4345 204f 5220 4f54 4845 5257 IGENCE OR OTHERW │ │ │ +00063530: 4953 4529 0a41 5249 5349 4e47 2049 4e20 ISE).ARISING IN │ │ │ +00063540: 414e 5920 5741 5920 4f55 5420 4f46 2054 ANY WAY OUT OF T │ │ │ +00063550: 4845 2055 5345 204f 4620 5448 4953 2053 HE USE OF THIS S │ │ │ +00063560: 4f46 5457 4152 452c 2045 5645 4e20 4946 OFTWARE, EVEN IF │ │ │ +00063570: 2041 4456 4953 4544 204f 4620 5448 450a ADVISED OF THE. │ │ │ +00063580: 504f 5353 4942 494c 4954 5920 4f46 2053 POSSIBILITY OF S │ │ │ +00063590: 5543 4820 4441 4d41 4745 2e0a 0a2a 2f0a UCH DAMAGE...*/. │ │ │ +000635a0: 0a23 696e 636c 7564 6520 226c 6962 746f .#include "libto │ │ │ +000635b0: 7272 656e 742f 7065 7266 6f72 6d61 6e63 rrent/performanc │ │ │ +000635c0: 655f 636f 756e 7465 7273 2e68 7070 220a e_counters.hpp". │ │ │ +000635d0: 2369 6e63 6c75 6465 2022 6c69 6274 6f72 #include "libtor │ │ │ +000635e0: 7265 6e74 2f61 7373 6572 742e 6870 7022 rent/assert.hpp" │ │ │ +000635f0: 0a23 696e 636c 7564 6520 266c 743b 6373 .#include <cs │ │ │ +00063600: 7472 696e 6726 6774 3b20 2f2f 2066 6f72 tring> // for │ │ │ +00063610: 206d 656d 7365 740a 0a6e 616d 6573 7061 memset..namespa │ │ │ +00063620: 6365 206c 6962 746f 7272 656e 7420 7b0a ce libtorrent {. │ │ │ +00063630: 0a3c 6469 7620 7374 796c 653d 2262 6163 .
    . │ │ │ +00063660: 636f 756e 7465 7273 3a3a 636f 756e 7465 counters::counte │ │ │ +00063670: 7273 2829 2054 4f52 5245 4e54 5f43 4f55 rs() TORRENT_COU │ │ │ +00063680: 4e54 4552 5f4e 4f45 5843 4550 540a 3c2f NTER_NOEXCEPT..{.#ifdef AT │ │ │ +000636a0: 4f4d 4943 5f4c 4c4f 4e47 5f4c 4f43 4b5f OMIC_LLONG_LOCK_ │ │ │ +000636b0: 4652 4545 0a09 0966 6f72 2028 6175 746f FREE...for (auto │ │ │ +000636c0: 2661 6d70 3b20 636f 756e 7465 7220 3a20 & counter : │ │ │ +000636d0: 6d5f 7374 6174 735f 636f 756e 7465 7229 m_stats_counter) │ │ │ +000636e0: 0a09 0909 636f 756e 7465 722e 7374 6f72 ....counter.stor │ │ │ +000636f0: 6528 302c 2073 7464 3a3a 6d65 6d6f 7279 e(0, std::memory │ │ │ +00063700: 5f6f 7264 6572 5f72 656c 6178 6564 293b _order_relaxed); │ │ │ +00063710: 0a23 656c 7365 0a09 096d 5f73 7461 7473 .#else...m_stats │ │ │ +00063720: 5f63 6f75 6e74 6572 2e66 696c 6c28 3029 _counter.fill(0) │ │ │ +00063730: 3b0a 2365 6e64 6966 0a09 7d0a 0a09 636f ;.#endif..}...co │ │ │ +00063740: 756e 7465 7273 3a3a 636f 756e 7465 7273 unters::counters │ │ │ +00063750: 2863 6f75 6e74 6572 7320 636f 6e73 7426 (counters const& │ │ │ +00063760: 616d 703b 2063 2920 544f 5252 454e 545f amp; c) TORRENT_ │ │ │ +00063770: 434f 554e 5445 525f 4e4f 4558 4345 5054 COUNTER_NOEXCEPT │ │ │ +00063780: 0a09 7b0a 2369 6664 6566 2041 544f 4d49 ..{.#ifdef ATOMI │ │ │ +00063790: 435f 4c4c 4f4e 475f 4c4f 434b 5f46 5245 C_LLONG_LOCK_FRE │ │ │ +000637a0: 450a 0909 666f 7220 2869 6e74 2069 203d E...for (int i = │ │ │ +000637b0: 2030 3b20 6920 266c 743b 206d 5f73 7461 0; i < m_sta │ │ │ +000637c0: 7473 5f63 6f75 6e74 6572 2e65 6e64 5f69 ts_counter.end_i │ │ │ +000637d0: 6e64 6578 2829 3b20 2b2b 6929 0a09 0909 ndex(); ++i).... │ │ │ +000637e0: 6d5f 7374 6174 735f 636f 756e 7465 725b m_stats_counter[ │ │ │ +000637f0: 695d 2e73 746f 7265 280a 0909 0909 632e i].store(.....c. │ │ │ +00063800: 6d5f 7374 6174 735f 636f 756e 7465 725b m_stats_counter[ │ │ │ +00063810: 695d 2e6c 6f61 6428 7374 643a 3a6d 656d i].load(std::mem │ │ │ +00063820: 6f72 795f 6f72 6465 725f 7265 6c61 7865 ory_order_relaxe │ │ │ +00063830: 6429 0a09 0909 0909 2c20 7374 643a 3a6d d)......, std::m │ │ │ +00063840: 656d 6f72 795f 6f72 6465 725f 7265 6c61 emory_order_rela │ │ │ +00063850: 7865 6429 3b0a 2365 6c73 650a 0909 7374 xed);.#else...st │ │ │ +00063860: 643a 3a6c 6f63 6b5f 6775 6172 6426 6c74 d::lock_guard< │ │ │ +00063870: 3b73 7464 3a3a 6d75 7465 7826 6774 3b20 ;std::mutex> │ │ │ +00063880: 6c28 632e 6d5f 6d75 7465 7829 3b0a 0909 l(c.m_mutex);... │ │ │ +00063890: 6d5f 7374 6174 735f 636f 756e 7465 7220 m_stats_counter │ │ │ +000638a0: 3d20 632e 6d5f 7374 6174 735f 636f 756e = c.m_stats_coun │ │ │ +000638b0: 7465 723b 0a23 656e 6469 660a 097d 0a0a ter;.#endif..}.. │ │ │ +000638c0: 0963 6f75 6e74 6572 7326 616d 703b 2063 .counters& c │ │ │ +000638d0: 6f75 6e74 6572 733a 3a6f 7065 7261 746f ounters::operato │ │ │ +000638e0: 723d 2863 6f75 6e74 6572 7320 636f 6e73 r=(counters cons │ │ │ +000638f0: 7426 616d 703b 2063 2920 2661 6d70 3b20 t& c) & │ │ │ +00063900: 544f 5252 454e 545f 434f 554e 5445 525f TORRENT_COUNTER_ │ │ │ +00063910: 4e4f 4558 4345 5054 0a09 7b0a 0909 6966 NOEXCEPT..{...if │ │ │ +00063920: 2028 2661 6d70 3b63 203d 3d20 7468 6973 (&c == this │ │ │ +00063930: 2920 7265 7475 726e 202a 7468 6973 3b0a ) return *this;. │ │ │ +00063940: 2369 6664 6566 2041 544f 4d49 435f 4c4c #ifdef ATOMIC_LL │ │ │ +00063950: 4f4e 475f 4c4f 434b 5f46 5245 450a 0909 ONG_LOCK_FREE... │ │ │ +00063960: 666f 7220 2869 6e74 2069 203d 2030 3b20 for (int i = 0; │ │ │ +00063970: 6920 266c 743b 206d 5f73 7461 7473 5f63 i < m_stats_c │ │ │ +00063980: 6f75 6e74 6572 2e65 6e64 5f69 6e64 6578 ounter.end_index │ │ │ +00063990: 2829 3b20 2b2b 6929 0a09 0909 6d5f 7374 (); ++i)....m_st │ │ │ +000639a0: 6174 735f 636f 756e 7465 725b 695d 2e73 ats_counter[i].s │ │ │ +000639b0: 746f 7265 280a 0909 0909 632e 6d5f 7374 tore(.....c.m_st │ │ │ +000639c0: 6174 735f 636f 756e 7465 725b 695d 2e6c ats_counter[i].l │ │ │ +000639d0: 6f61 6428 7374 643a 3a6d 656d 6f72 795f oad(std::memory_ │ │ │ +000639e0: 6f72 6465 725f 7265 6c61 7865 6429 0a09 order_relaxed).. │ │ │ +000639f0: 0909 0909 2c20 7374 643a 3a6d 656d 6f72 ...., std::memor │ │ │ +00063a00: 795f 6f72 6465 725f 7265 6c61 7865 6429 y_order_relaxed) │ │ │ +00063a10: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ +00063a40: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00063a50: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +00063a80: 7372 632f 6372 6561 7465 5f74 6f72 7265 src/create_torre │ │ │ +00063a90: 6e74 2e63 7070 3a36 3435 3c2f 613e 3c2f nt.cpp:645this can │ │ │ +00063ab0: 6265 206f 7074 696d 697a 6564 3c2f 7464 be optimized

    this c │ │ │ +00063b10: 616e 2062 6520 6f70 7469 6d69 7a65 643c an be optimized< │ │ │ +00063b20: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f63 /h2>

    ../src/c │ │ │ +00063b30: 7265 6174 655f 746f 7272 656e 742e 6370 reate_torrent.cp │ │ │ +00063b40: 703a 3634 353c 2f68 343e 3c70 7265 2073 p:645

    ..std::strin
    │ │ │ +00063b90: 6726 616d 703b 2061 7474 7220 3d20 655b  g& attr = e[
    │ │ │ +00063ba0: 2261 7474 7222 5d2e 7374 7269 6e67 2829  "attr"].string()
    │ │ │ +00063bb0: 3b0a 0909 6966 2028 666c 6167 7320 2661  ;...if (flags &a
    │ │ │ +00063bc0: 6d70 3b20 6669 6c65 5f73 746f 7261 6765  mp; file_storage
    │ │ │ +00063bd0: 3a3a 666c 6167 5f70 6164 5f66 696c 6529  ::flag_pad_file)
    │ │ │ +00063be0: 2061 7474 7220 2b3d 2027 7027 3b0a 0909   attr += 'p';...
    │ │ │ +00063bf0: 6966 2028 666c 6167 7320 2661 6d70 3b20  if (flags & 
    │ │ │ +00063c00: 6669 6c65 5f73 746f 7261 6765 3a3a 666c  file_storage::fl
    │ │ │ +00063c10: 6167 5f68 6964 6465 6e29 2061 7474 7220  ag_hidden) attr 
    │ │ │ +00063c20: 2b3d 2027 6827 3b0a 0909 6966 2028 666c  += 'h';...if (fl
    │ │ │ +00063c30: 6167 7320 2661 6d70 3b20 6669 6c65 5f73  ags & file_s
    │ │ │ +00063c40: 746f 7261 6765 3a3a 666c 6167 5f65 7865  torage::flag_exe
    │ │ │ +00063c50: 6375 7461 626c 6529 2061 7474 7220 2b3d  cutable) attr +=
    │ │ │ +00063c60: 2027 7827 3b0a 0909 6966 2028 696e 636c   'x';...if (incl
    │ │ │ +00063c70: 7564 655f 7379 6d6c 696e 6b73 2026 616d  ude_symlinks &am
    │ │ │ +00063c80: 703b 2661 6d70 3b20 2866 6c61 6773 2026  p;& (flags &
    │ │ │ +00063c90: 616d 703b 2066 696c 655f 7374 6f72 6167  amp; file_storag
    │ │ │ +00063ca0: 653a 3a66 6c61 675f 7379 6d6c 696e 6b29  e::flag_symlink)
    │ │ │ +00063cb0: 2920 6174 7472 202b 3d20 276c 273b 0a09  ) attr += 'l';..
    │ │ │ +00063cc0: 7d0a 0a09 766f 6964 2061 6464 5f73 796d  }...void add_sym
    │ │ │ +00063cd0: 6c69 6e6b 5f70 6174 6828 656e 7472 7926  link_path(entry&
    │ │ │ +00063ce0: 616d 703b 2065 2c20 7374 643a 3a73 7472  amp; e, std::str
    │ │ │ +00063cf0: 696e 6720 7379 6d6c 696e 6b5f 7061 7468  ing symlink_path
    │ │ │ +00063d00: 290a 097b 0a09 0965 6e74 7279 2661 6d70  )..{...entry&
    │ │ │ +00063d10: 3b20 7379 6d70 6174 685f 6520 3d20 655b  ; sympath_e = e[
    │ │ │ +00063d20: 2273 796d 6c69 6e6b 2070 6174 6822 5d3b  "symlink path"];
    │ │ │ +00063d30: 0a0a 0909 7374 643a 3a73 7472 696e 6720  ....std::string 
    │ │ │ +00063d40: 636f 6e73 7420 6c69 6e6b 203d 206c 6578  const link = lex
    │ │ │ +00063d50: 6963 616c 6c79 5f72 656c 6174 6976 6528  ically_relative(
    │ │ │ +00063d60: 2222 2c20 7379 6d6c 696e 6b5f 7061 7468  "", symlink_path
    │ │ │ +00063d70: 293b 0a09 0966 6f72 2028 6175 746f 2065  );...for (auto e
    │ │ │ +00063d80: 6c65 6d73 203d 206c 7370 6c69 745f 7061  lems = lsplit_pa
    │ │ │ +00063d90: 7468 286c 696e 6b29 3b20 2165 6c65 6d73  th(link); !elems
    │ │ │ +00063da0: 2e66 6972 7374 2e65 6d70 7479 2829 3b0a  .first.empty();.
    │ │ │ +00063db0: 0909 0965 6c65 6d73 203d 206c 7370 6c69  ...elems = lspli
    │ │ │ +00063dc0: 745f 7061 7468 2865 6c65 6d73 2e73 6563  t_path(elems.sec
    │ │ │ +00063dd0: 6f6e 6429 290a 0909 0973 796d 7061 7468  ond))....sympath
    │ │ │ +00063de0: 5f65 2e6c 6973 7428 292e 656d 706c 6163  _e.list().emplac
    │ │ │ +00063df0: 655f 6261 636b 2865 6c65 6d73 2e66 6972  e_back(elems.fir
    │ │ │ +00063e00: 7374 293b 0a09 7d0a 7d0a 0a09 7374 643a  st);..}.}...std:
    │ │ │ +00063e10: 3a76 6563 746f 7226 6c74 3b63 6861 7226  :vector<char&
    │ │ │ +00063e20: 6774 3b20 6372 6561 7465 5f74 6f72 7265  gt; create_torre
    │ │ │ +00063e30: 6e74 3a3a 6765 6e65 7261 7465 5f62 7566  nt::generate_buf
    │ │ │ +00063e40: 2829 2063 6f6e 7374 0a09 7b0a 3c64 6976  () const..{.
    ..std: │ │ │ +00063e80: 3a76 6563 746f 7226 6c74 3b63 6861 7226 :vector<char& │ │ │ +00063e90: 6774 3b20 7265 743b 0a3c 2f64 6976 3e09 gt; ret;.
    . │ │ │ +00063ea0: 0962 656e 636f 6465 2873 7464 3a3a 6261 .bencode(std::ba │ │ │ +00063eb0: 636b 5f69 6e73 6572 7465 7228 7265 7429 ck_inserter(ret) │ │ │ +00063ec0: 2c20 6765 6e65 7261 7465 2829 293b 0a09 , generate());.. │ │ │ +00063ed0: 0972 6574 7572 6e20 7265 743b 0a09 7d0a .return ret;..}. │ │ │ +00063ee0: 0a09 656e 7472 7920 6372 6561 7465 5f74 ..entry create_t │ │ │ +00063ef0: 6f72 7265 6e74 3a3a 6765 6e65 7261 7465 orrent::generate │ │ │ +00063f00: 2829 2063 6f6e 7374 0a09 7b0a 0909 6966 () const..{...if │ │ │ +00063f10: 2028 6d5f 6669 6c65 732e 6e75 6d5f 6669 (m_files.num_fi │ │ │ +00063f20: 6c65 7328 2920 3d3d 2030 207c 7c20 6d5f les() == 0 || m_ │ │ │ +00063f30: 6669 6c65 732e 746f 7461 6c5f 7369 7a65 files.total_size │ │ │ +00063f40: 2829 203d 3d20 3029 0a09 0909 6175 783a () == 0)....aux: │ │ │ +00063f50: 3a74 6872 6f77 5f65 7826 6c74 3b73 7973 :throw_ex<sys │ │ │ +00063f60: 7465 6d5f 6572 726f 7226 6774 3b28 6572 tem_error>(er │ │ │ +00063f70: 726f 7273 3a3a 746f 7272 656e 745f 6d69 rors::torrent_mi │ │ │ +00063f80: 7373 696e 675f 6669 6c65 5f74 7265 6529 ssing_file_tree) │ │ │ +00063f90: 3b0a 0a09 092f 2f20 6966 2061 6c6c 2076 ;....// if all v │ │ │ +00063fa0: 3220 6861 7368 6573 2061 7265 2073 6574 2 hashes are set │ │ │ +00063fb0: 2063 6f72 7265 6374 6c79 2c20 6765 6e65 correctly, gene │ │ │ +00063fc0: 7261 7465 2074 6865 2076 3220 7061 7274 rate the v2 part │ │ │ +00063fd0: 7320 6f66 2074 6865 0a09 092f 2f20 746f s of the...// to │ │ │ +00063fe0: 7272 656e 740a 0909 626f 6f6c 2063 6f6e rrent...bool con │ │ │ +00063ff0: 7374 206d 616b 655f 7632 203d 2076 616c st make_v2 = val │ │ │ +00064000: 6964 6174 655f 7632 5f68 6173 6865 7328 idate_v2_hashes( │ │ │ +00064010: 6d5f 6669 6c65 732c 206d 5f66 696c 655f m_files, m_file_ │ │ │ +00064020: 7069 6563 655f 6861 7368 293b 0a09 0962 piece_hash);...b │ │ │ +00064030: 6f6f 6c20 636f 6e73 7420 6d61 6b65 5f76 ool const make_v │ │ │ +00064040: 3120 3d20 7661 6c69 6461 7465 5f76 315f 1 = validate_v1_ │ │ │ +00064050: 6861 7368 6573 286d 5f66 696c 6573 2c20 hashes(m_files, │ │ │ +00064060: 6d5f 7069 6563 655f 6861 7368 293b 0a0a m_piece_hash);.. │ │ │ +00064070: 0909 2f2f 2069 6620 6e65 6974 6865 7220 ..// if neither │ │ │ +00064080: 7631 206e 6f72 2076 3220 6861 7368 6573 v1 nor v2 hashes │ │ │ +00064090: 2077 6572 6520 7365 742c 2077 6520 6361 were set, we ca │ │ │ +000640a0: 6e27 7420 6372 6561 7465 2061 2074 6f72 n't create a tor │ │ │ +000640b0: 7265 6e74 0a09 0969 6620 2821 6d61 6b65 rent...if (!make │ │ │ +000640c0: 5f76 3120 2661 6d70 3b26 616d 703b 2021 _v1 && ! │ │ │ +000640d0: 6d61 6b65 5f76 3229 0a09 0909 6175 783a make_v2)....aux: │ │ │ +000640e0: 3a74 6872 6f77 5f65 7826 6c74 3b73 7973 :throw_ex<sys │ │ │ +000640f0: 7465 6d5f 6572 726f 7226 6774 3b28 6572 tem_error>(er │ │ │ +00064100: 726f 7273 3a3a 696e 7661 6c69 645f 6861 rors::invalid_ha │ │ │ +00064110: 7368 5f65 6e74 7279 293b 0a0a 0909 544f sh_entry);....TO │ │ │ +00064120: 5252 454e 545f 4153 5345 5254 286d 5f66 RRENT_ASSERT(m_f │ │ │ +00064130: 696c 6573 2e70 6965 6365 5f6c 656e 6774 iles.piece_lengt │ │ │ +00064140: 6828 2920 2667 743b 2030 293b 0a0a 0909 h() > 0);.... │ │ │ +00064150: 656e 7472 7920 6469 6374 3b0a 0a09 0969 entry dict;....i │ │ │ +00064160: 6620 2821 6d5f 7572 6c73 2e65 6d70 7479 f (!m_urls.empty │ │ │ +00064170: 2829 2920 6469 6374 5b22 616e 6e6f 756e ()) dict["announ │ │ │ +00064180: 6365 225d 203d 206d 5f75 726c 732e 6672 ce"] = m_urls.fr │ │ │ +00064190: 6f6e 7428 292e 6669 7273 743b 0a0a 0909 ont().first;.... │ │ │ +000641a0: 6966 2028 216d 5f6e 6f64 6573 2e65 6d70 if (!m_nodes.emp │ │ │ +000641b0: 7479 2829 290a 0909 7b0a 0909 0965 6e74 ty())...{....ent │ │ │ +000641c0: 7279 2661 6d70 3b20 6e6f 6465 7320 3d20 ry& nodes = │ │ │ +000641d0: 6469 6374 5b22 6e6f 6465 7322 5d3b 0a09 dict["nodes"];.. │ │ │ +000641e0: 0909 656e 7472 793a 3a6c 6973 745f 7479 ..entry::list_ty │ │ │ +000641f0: 7065 2661 6d70 3b20 6e6f 6465 735f 6c69 pe& nodes_li │ │ │ +00064200: 7374 203d 206e 6f64 6573 2e6c 6973 7428 st = nodes.list( │ │ │ +00064210: 293b 0a09 0909 666f 7220 2861 7574 6f20 );....for (auto │ │ │ +00064220: 636f 6e73 7426 616d 703b 206e 203a 206d const& n : m │ │ │ +00064230: 5f6e 6f64 6573 290a 0909 097b 0a3c 2f70 _nodes)....{.

    re │ │ │ +00064270: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/u │ │ │ +000642b0: 6470 5f74 7261 636b 6572 5f63 6f6e 6e65 dp_tracker_conne │ │ │ +000642c0: 6374 696f 6e2e 6370 703a 3633 333c 2f61 ction.cpp:633why is │ │ │ +000642e0: 2074 6869 7320 6120 6c69 6e6b 6564 206c this a linked l │ │ │ +000642f0: 6973 743f 3c2f 7464 3e3c 2f74 723e 3c74 ist?why is this a │ │ │ +00064350: 6c69 6e6b 6564 206c 6973 743f 3c2f 6832 linked list?

    ../src/udp_ │ │ │ +00064370: 7472 6163 6b65 725f 636f 6e6e 6563 7469 tracker_connecti │ │ │ +00064380: 6f6e 2e63 7070 3a36 3333 3c2f 6834 3e3c on.cpp:633

    < │ │ │ +00064390: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +000643a0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +000643b0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +000643c0: 7820 2364 6464 3b22 3e09 0909 0969 7076 x #ddd;">....ipv │ │ │ +000643d0: 365f 7065 6572 5f65 6e74 7279 2065 7b7d 6_peer_entry e{} │ │ │ +000643e0: 3b0a 0909 0909 7374 643a 3a6d 656d 6370 ;.....std::memcp │ │ │ +000643f0: 7928 652e 6970 2e64 6174 6128 292c 2062 y(e.ip.data(), b │ │ │ +00064400: 7566 2e64 6174 6128 292c 2031 3629 3b0a uf.data(), 16);. │ │ │ +00064410: 0909 0909 6275 6620 3d20 6275 662e 7375 ....buf = buf.su │ │ │ +00064420: 6273 7061 6e28 3136 293b 0a09 0909 0965 bspan(16);.....e │ │ │ +00064430: 2e70 6f72 7420 3d20 6175 783a 3a72 6561 .port = aux::rea │ │ │ +00064440: 645f 7569 6e74 3136 2862 7566 293b 0a09 d_uint16(buf);.. │ │ │ +00064450: 0909 0972 6573 702e 7065 6572 7336 2e70 ...resp.peers6.p │ │ │ +00064460: 7573 685f 6261 636b 2865 293b 0a09 0909 ush_back(e);.... │ │ │ +00064470: 7d0a 0909 7d0a 0909 656c 7365 0a09 097b }...}...else...{ │ │ │ +00064480: 0a09 0909 7265 7370 2e70 6565 7273 342e ....resp.peers4. │ │ │ +00064490: 7265 7365 7276 6528 7374 6174 6963 5f63 reserve(static_c │ │ │ +000644a0: 6173 7426 6c74 3b73 7464 3a3a 7369 7a65 ast<std::size │ │ │ +000644b0: 5f74 2667 743b 286e 756d 5f70 6565 7273 _t>(num_peers │ │ │ +000644c0: 2929 3b0a 0909 0966 6f72 2028 696e 7420 ));....for (int │ │ │ +000644d0: 6920 3d20 303b 2069 2026 6c74 3b20 6e75 i = 0; i < nu │ │ │ +000644e0: 6d5f 7065 6572 733b 202b 2b69 290a 0909 m_peers; ++i)... │ │ │ +000644f0: 097b 0a09 0909 0969 7076 345f 7065 6572 .{.....ipv4_peer │ │ │ +00064500: 5f65 6e74 7279 2065 7b7d 3b0a 0909 0909 _entry e{};..... │ │ │ +00064510: 7374 643a 3a6d 656d 6370 7928 652e 6970 std::memcpy(e.ip │ │ │ +00064520: 2e64 6174 6128 292c 2062 7566 2e64 6174 .data(), buf.dat │ │ │ +00064530: 6128 292c 2034 293b 0a09 0909 0962 7566 a(), 4);.....buf │ │ │ +00064540: 203d 2062 7566 2e73 7562 7370 616e 2834 = buf.subspan(4 │ │ │ +00064550: 293b 0a09 0909 0965 2e70 6f72 7420 3d20 );.....e.port = │ │ │ +00064560: 6175 783a 3a72 6561 645f 7569 6e74 3136 aux::read_uint16 │ │ │ +00064570: 2862 7566 293b 0a09 0909 0972 6573 702e (buf);.....resp. │ │ │ +00064580: 7065 6572 7334 2e70 7573 685f 6261 636b peers4.push_back │ │ │ +00064590: 2865 293b 0a09 0909 7d0a 0909 7d0a 0a3c (e);....}...}..< │ │ │ +000645a0: 6469 7620 7374 796c 653d 2262 6163 6b67 div style="backg │ │ │ +000645b0: 726f 756e 643a 2023 6666 6666 3030 2220 round: #ffff00" │ │ │ +000645c0: 7769 6474 683d 2231 3030 2522 3e09 0973 width="100%">..s │ │ │ +000645d0: 7464 3a3a 6c69 7374 266c 743b 6164 6472 td::list<addr │ │ │ +000645e0: 6573 7326 6774 3b20 6970 5f6c 6973 743b ess> ip_list; │ │ │ +000645f0: 0a3c 2f64 6976 3e09 0973 7464 3a3a 7472 ...std::tr │ │ │ +00064600: 616e 7366 6f72 6d28 6d5f 656e 6470 6f69 ansform(m_endpoi │ │ │ +00064610: 6e74 732e 6265 6769 6e28 292c 206d 5f65 nts.begin(), m_e │ │ │ +00064620: 6e64 706f 696e 7473 2e65 6e64 2829 2c20 ndpoints.end(), │ │ │ +00064630: 7374 643a 3a62 6163 6b5f 696e 7365 7274 std::back_insert │ │ │ +00064640: 6572 2869 705f 6c69 7374 290a 0909 092c er(ip_list)...., │ │ │ +00064650: 205b 5d28 7463 703a 3a65 6e64 706f 696e [](tcp::endpoin │ │ │ +00064660: 7420 636f 6e73 7426 616d 703b 2065 7029 t const& ep) │ │ │ +00064670: 207b 2072 6574 7572 6e20 6570 2e61 6464 { return ep.add │ │ │ +00064680: 7265 7373 2829 3b20 7d20 293b 0a0a 0909 ress(); } );.... │ │ │ +00064690: 2f2f 2061 626f 7574 2074 6f20 7265 706f // about to repo │ │ │ +000646a0: 7274 2074 6865 2072 6573 706f 6e73 6520 rt the response │ │ │ +000646b0: 6265 6c6f 773b 206d 6172 6b20 6974 2061 below; mark it a │ │ │ +000646c0: 7320 6e6f 206c 6f6e 6765 7220 7065 6e64 s no longer pend │ │ │ +000646d0: 696e 670a 0909 2f2f 2066 6972 7374 2c20 ing...// first, │ │ │ +000646e0: 736f 2061 2066 6169 6c28 2920 616c 7265 so a fail() alre │ │ │ +000646f0: 6164 7920 706f 7374 6564 2028 652e 672e ady posted (e.g. │ │ │ +00064700: 2062 790a 0909 2f2f 2074 7261 636b 6572 by...// tracker │ │ │ +00064710: 5f6d 616e 6167 6572 3a3a 6162 6f72 745f _manager::abort_ │ │ │ +00064720: 616c 6c5f 7265 7175 6573 7473 2829 2072 all_requests() r │ │ │ +00064730: 6163 696e 6720 7468 6973 2072 6573 706f acing this respo │ │ │ +00064740: 6e73 6529 2066 696e 6473 0a09 092f 2f20 nse) finds...// │ │ │ +00064750: 6e6f 7468 696e 6720 6c65 6674 2074 6f20 nothing left to │ │ │ +00064760: 7265 706f 7274 2077 6865 6e20 6974 2072 report when it r │ │ │ +00064770: 756e 732e 0a09 096d 5f72 6571 5f70 656e uns....m_req_pen │ │ │ +00064780: 6469 6e67 203d 2066 616c 7365 3b0a 0909 ding = false;... │ │ │ +00064790: 6362 2d26 6774 3b74 7261 636b 6572 5f72 cb->tracker_r │ │ │ +000647a0: 6573 706f 6e73 6528 7472 6163 6b65 725f esponse(tracker_ │ │ │ +000647b0: 7265 7128 292c 206d 5f74 6172 6765 742e req(), m_target. │ │ │ +000647c0: 6164 6472 6573 7328 292c 2069 705f 6c69 address(), ip_li │ │ │ +000647d0: 7374 2c20 7265 7370 293b 0a0a 0909 636c st, resp);....cl │ │ │ +000647e0: 6f73 6528 293b 0a09 0972 6574 7572 6e20 ose();...return │ │ │ +000647f0: 7472 7565 3b0a 097d 0a0a 0962 6f6f 6c20 true;..}...bool │ │ │ +00064800: 7564 705f 7472 6163 6b65 725f 636f 6e6e udp_tracker_conn │ │ │ +00064810: 6563 7469 6f6e 3a3a 6f6e 5f73 6372 6170 ection::on_scrap │ │ │ +00064820: 655f 7265 7370 6f6e 7365 2873 7061 6e26 e_response(span& │ │ │ +00064830: 6c74 3b63 6861 7220 636f 6e73 7426 6774 lt;char const> │ │ │ +00064840: 3b20 6275 6629 0a09 7b0a 0909 7265 7374 ; buf)..{...rest │ │ │ +00064850: 6172 745f 7265 6164 5f74 696d 656f 7574 art_read_timeout │ │ │ +00064860: 2829 3b0a 0909 6175 746f 2063 6f6e 7374 ();...auto const │ │ │ +00064870: 2061 6374 696f 6e20 3d20 7374 6174 6963 action = static │ │ │ +00064880: 5f63 6173 7426 6c74 3b61 6374 696f 6e5f _cast<action_ │ │ │ +00064890: 7426 6774 3b28 6175 783a 3a72 6561 645f t>(aux::read_ │ │ │ +000648a0: 696e 7433 3228 6275 6629 293b 0a09 0973 int32(buf));...s │ │ │ +000648b0: 7464 3a3a 7569 6e74 3332 5f74 2063 6f6e td::uint32_t con │ │ │ +000648c0: 7374 2074 7261 6e73 6163 7469 6f6e 203d st transaction = │ │ │ +000648d0: 2061 7578 3a3a 7265 6164 5f75 696e 7433 aux::read_uint3 │ │ │ +000648e0: 3228 6275 6629 3b0a 0a09 0969 6620 2874 2(buf);....if (t │ │ │ +000648f0: 7261 6e73 6163 7469 6f6e 2021 3d20 6d5f ransaction != m_ │ │ │ +00064900: 7472 616e 7361 6374 696f 6e5f 6964 290a transaction_id). │ │ │ +00064910: 0909 7b0a 0909 0966 6169 6c28 6572 726f ..{....fail(erro │ │ │ +00064920: 725f 636f 6465 2865 7272 6f72 733a 3a69 r_code(errors::i │ │ │ +00064930: 6e76 616c 6964 5f74 7261 636b 6572 5f74 nvalid_tracker_t │ │ │ +00064940: 7261 6e73 6163 7469 6f6e 5f69 6429 2c20 ransaction_id), │ │ │ +00064950: 6f70 6572 6174 696f 6e5f 743a 3a62 6974 operation_t::bit │ │ │ +00064960: 746f 7272 656e 7429 3b0a 0909 0972 6574 torrent);....ret │ │ │ +00064970: 7572 6e20 6661 6c73 653b 0a09 097d 0a0a urn false;...}.. │ │ │ +00064980: 0909 6966 2028 6163 7469 6f6e 203d 3d20 ..if (action == │ │ │ +00064990: 6163 7469 6f6e 5f74 3a3a 6572 726f 7229 action_t::error) │ │ │ +000649a0: 0a09 097b 0a09 0909 6661 696c 2865 7272 ...{....fail(err │ │ │ +000649b0: 6f72 5f63 6f64 6528 6572 726f 7273 3a3a or_code(errors:: │ │ │ +000649c0: 7472 6163 6b65 725f 6661 696c 7572 6529 tracker_failure) │ │ │ +000649d0: 2c20 6f70 6572 6174 696f 6e5f 743a 3a62 , operation_t::b │ │ │ +000649e0: 6974 746f 7272 656e 740a 0909 0909 2c20 ittorrent....., │ │ │ +000649f0: 7374 643a 3a73 7472 696e 6728 6275 662e std::string(buf. │ │ │ +00064a00: 6461 7461 2829 2c20 7374 6174 6963 5f63 data(), static_c │ │ │ +00064a10: 6173 7426 6c74 3b73 7464 3a3a 7369 7a65 ast<std::size │ │ │ +00064a20: 5f74 2667 743b 2862 7566 2e73 697a 6528 _t>(buf.size( │ │ │ +00064a30: 2929 292e 635f 7374 7228 2929 3b0a 3c2f ))).c_str());.r │ │ │ +00064a70: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +00064a80: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +00064ab0: 616c 6572 742e 6370 703a 3338 373c 2f61 alert.cpp:387move t │ │ │ +00064ad0: 6869 7320 6669 656c 6420 696e 746f 2074 his field into t │ │ │ +00064ae0: 7261 636b 6572 5f61 6c65 7274 3c2f 7464 racker_alert

    move t │ │ │ +00064b40: 6869 7320 6669 656c 6420 696e 746f 2074 his field into t │ │ │ +00064b50: 7261 636b 6572 5f61 6c65 7274 3c2f 6832 racker_alert

    ../src/aler │ │ │ +00064b70: 742e 6370 703a 3338 373c 2f68 343e 3c70 t.cpp:387

    ...retur │ │ │ +00064bc0: 6e20 746f 7272 656e 745f 616c 6572 743a n torrent_alert: │ │ │ +00064bd0: 3a6d 6573 7361 6765 2829 202b 2022 3a20 :message() + ": │ │ │ +00064be0: 7374 6174 6520 6368 616e 6765 6420 746f state changed to │ │ │ +00064bf0: 3a20 220a 0909 092b 2073 7461 7465 5f73 : "....+ state_s │ │ │ +00064c00: 7472 5b73 7461 7465 5d3b 0a23 656e 6469 tr[state];.#endi │ │ │ +00064c10: 660a 097d 0a0a 0974 7261 636b 6572 5f65 f..}...tracker_e │ │ │ +00064c20: 7272 6f72 5f61 6c65 7274 3a3a 7472 6163 rror_alert::trac │ │ │ +00064c30: 6b65 725f 6572 726f 725f 616c 6572 7428 ker_error_alert( │ │ │ +00064c40: 6175 783a 3a73 7461 636b 5f61 6c6c 6f63 aux::stack_alloc │ │ │ +00064c50: 6174 6f72 2661 6d70 3b20 616c 6c6f 630a ator& alloc. │ │ │ +00064c60: 0909 2c20 746f 7272 656e 745f 6861 6e64 .., torrent_hand │ │ │ +00064c70: 6c65 2063 6f6e 7374 2661 6d70 3b20 682c le const& h, │ │ │ +00064c80: 2074 6370 3a3a 656e 6470 6f69 6e74 2063 tcp::endpoint c │ │ │ +00064c90: 6f6e 7374 2661 6d70 3b20 6570 2c20 696e onst& ep, in │ │ │ +00064ca0: 7420 7469 6d65 730a 0909 2c20 7072 6f74 t times..., prot │ │ │ +00064cb0: 6f63 6f6c 5f76 6572 7369 6f6e 2076 2c20 ocol_version v, │ │ │ +00064cc0: 7374 7269 6e67 5f76 6965 7720 752c 206f string_view u, o │ │ │ +00064cd0: 7065 7261 7469 6f6e 5f74 2063 6f6e 7374 peration_t const │ │ │ +00064ce0: 206f 7065 7261 7469 6f6e 0a09 092c 2065 operation..., e │ │ │ +00064cf0: 7272 6f72 5f63 6f64 6520 636f 6e73 7426 rror_code const& │ │ │ +00064d00: 616d 703b 2065 0a09 092c 2073 7472 696e amp; e..., strin │ │ │ +00064d10: 675f 7669 6577 206d 290a 0909 3a20 7472 g_view m)...: tr │ │ │ +00064d20: 6163 6b65 725f 616c 6572 7428 616c 6c6f acker_alert(allo │ │ │ +00064d30: 632c 2068 2c20 6570 2c20 7529 0a09 092c c, h, ep, u)..., │ │ │ +00064d40: 2074 696d 6573 5f69 6e5f 726f 7728 7469 times_in_row(ti │ │ │ +00064d50: 6d65 7329 0a09 092c 2065 7272 6f72 2865 mes)..., error(e │ │ │ +00064d60: 290a 0909 2c20 6f70 286f 7065 7261 7469 )..., op(operati │ │ │ +00064d70: 6f6e 290a 0909 2c20 6d5f 6d73 675f 6964 on)..., m_msg_id │ │ │ +00064d80: 7828 616c 6c6f 632e 636f 7079 5f73 7472 x(alloc.copy_str │ │ │ +00064d90: 696e 6728 6d29 290a 2369 6620 544f 5252 ing(m)).#if TORR │ │ │ +00064da0: 454e 545f 4142 495f 5645 5253 494f 4e20 ENT_ABI_VERSION │ │ │ +00064db0: 3d3d 2031 0a09 092c 2073 7461 7475 735f == 1..., status_ │ │ │ +00064dc0: 636f 6465 2865 2026 616d 703b 2661 6d70 code(e && │ │ │ +00064dd0: 3b20 652e 6361 7465 676f 7279 2829 203d ; e.category() = │ │ │ +00064de0: 3d20 6874 7470 5f63 6174 6567 6f72 7928 = http_category( │ │ │ +00064df0: 2920 3f20 652e 7661 6c75 6528 2920 3a20 ) ? e.value() : │ │ │ +00064e00: 2d31 290a 0909 2c20 6d73 6728 6d29 0a23 -1)..., msg(m).# │ │ │ +00064e10: 656e 6469 660a 3c64 6976 2073 7479 6c65 endif.

    .., version( │ │ │ +00064e50: 7629 0a3c 2f64 6976 3e09 7b0a 0909 544f v).
    .{...TO │ │ │ +00064e60: 5252 454e 545f 4153 5345 5254 2821 752e RRENT_ASSERT(!u. │ │ │ +00064e70: 656d 7074 7928 2929 3b0a 097d 0a0a 0963 empty());..}...c │ │ │ +00064e80: 6861 7220 636f 6e73 742a 2074 7261 636b har const* track │ │ │ +00064e90: 6572 5f65 7272 6f72 5f61 6c65 7274 3a3a er_error_alert:: │ │ │ +00064ea0: 6661 696c 7572 655f 7265 6173 6f6e 2829 failure_reason() │ │ │ +00064eb0: 2063 6f6e 7374 0a09 7b0a 0909 7265 7475 const..{...retu │ │ │ +00064ec0: 726e 206d 5f61 6c6c 6f63 2e67 6574 2829 rn m_alloc.get() │ │ │ +00064ed0: 2e70 7472 286d 5f6d 7367 5f69 6478 293b .ptr(m_msg_idx); │ │ │ +00064ee0: 0a09 7d0a 0a09 7374 643a 3a73 7472 696e ..}...std::strin │ │ │ +00064ef0: 6720 7472 6163 6b65 725f 6572 726f 725f g tracker_error_ │ │ │ +00064f00: 616c 6572 743a 3a6d 6573 7361 6765 2829 alert::message() │ │ │ +00064f10: 2063 6f6e 7374 0a09 7b0a 2369 6664 6566 const..{.#ifdef │ │ │ +00064f20: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ +00064f30: 5f41 4c45 5254 5f4d 5347 0a09 0972 6574 _ALERT_MSG...ret │ │ │ +00064f40: 7572 6e20 7b7d 3b0a 2365 6c73 650a 0909 urn {};.#else... │ │ │ +00064f50: 6368 6172 2072 6574 5b34 3030 5d3b 0a09 char ret[400];.. │ │ │ +00064f60: 0973 7464 3a3a 736e 7072 696e 7466 2872 .std::snprintf(r │ │ │ +00064f70: 6574 2c20 7369 7a65 6f66 2872 6574 292c et, sizeof(ret), │ │ │ +00064f80: 2022 2573 2025 7320 2573 205c 2225 735c "%s %s %s \"%s\ │ │ │ +00064f90: 2220 2825 6429 220a 0909 092c 2074 7261 " (%d)"...., tra │ │ │ +00064fa0: 636b 6572 5f61 6c65 7274 3a3a 6d65 7373 cker_alert::mess │ │ │ +00064fb0: 6167 6528 292e 635f 7374 7228 290a 0909 age().c_str()... │ │ │ +00064fc0: 092c 2076 6572 7369 6f6e 203d 3d20 7072 ., version == pr │ │ │ +00064fd0: 6f74 6f63 6f6c 5f76 6572 7369 6f6e 3a3a otocol_version:: │ │ │ +00064fe0: 5631 203f 2022 7631 2220 3a20 2276 3222 V1 ? "v1" : "v2" │ │ │ +00064ff0: 0a09 0909 2c20 636f 6e76 6572 745f 6672 ...., convert_fr │ │ │ +00065000: 6f6d 5f6e 6174 6976 6528 6572 726f 722e om_native(error. │ │ │ +00065010: 6d65 7373 6167 6528 2929 2e63 5f73 7472 message()).c_str │ │ │ +00065020: 2829 2c20 6572 726f 725f 6d65 7373 6167 (), error_messag │ │ │ +00065030: 6528 290a 0909 092c 2074 696d 6573 5f69 e()...., times_i │ │ │ +00065040: 6e5f 726f 7729 3b0a 0909 7265 7475 726e n_row);...return │ │ │ +00065050: 2072 6574 3b0a 2365 6e64 6966 0a09 7d0a ret;.#endif..}. │ │ │ +00065060: 0a09 7472 6163 6b65 725f 7761 726e 696e ..tracker_warnin │ │ │ +00065070: 675f 616c 6572 743a 3a74 7261 636b 6572 g_alert::tracker │ │ │ +00065080: 5f77 6172 6e69 6e67 5f61 6c65 7274 2861 _warning_alert(a │ │ │ +00065090: 7578 3a3a 7374 6163 6b5f 616c 6c6f 6361 ux::stack_alloca │ │ │ +000650a0: 746f 7226 616d 703b 2061 6c6c 6f63 0a09 tor& alloc.. │ │ │ +000650b0: 092c 2074 6f72 7265 6e74 5f68 616e 646c ., torrent_handl │ │ │ +000650c0: 6520 636f 6e73 7426 616d 703b 2068 2c20 e const& h, │ │ │ +000650d0: 7463 703a 3a65 6e64 706f 696e 7420 636f tcp::endpoint co │ │ │ +000650e0: 6e73 7426 616d 703b 2065 700a 0909 2c20 nst& ep..., │ │ │ +000650f0: 7374 7269 6e67 5f76 6965 7720 752c 2070 string_view u, p │ │ │ +00065100: 726f 746f 636f 6c5f 7665 7273 696f 6e20 rotocol_version │ │ │ +00065110: 762c 2073 7472 696e 675f 7669 6577 206d v, string_view m │ │ │ +00065120: 290a 0909 3a20 7472 6163 6b65 725f 616c )...: tracker_al │ │ │ +00065130: 6572 7428 616c 6c6f 632c 2068 2c20 6570 ert(alloc, h, ep │ │ │ +00065140: 2c20 7529 0a09 092c 206d 5f6d 7367 5f69 , u)..., m_msg_i │ │ │ +00065150: 6478 2861 6c6c 6f63 2e63 6f70 795f 7374 dx(alloc.copy_st │ │ │ +00065160: 7269 6e67 286d 2929 0a23 6966 2054 4f52 ring(m)).#if TOR │ │ │ +00065170: 5245 4e54 5f41 4249 5f56 4552 5349 4f4e RENT_ABI_VERSION │ │ │ +00065180: 203d 3d20 310a 3c2f 7072 653e 3c2f 7464 == 1.
    relevance │ │ │ +000651c0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +000651d0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/alert.cp │ │ │ +00065200: 703a 3432 313c 2f61 3e3c 2f74 643e 3c74 p:421move this into │ │ │ +00065220: 2074 7261 636b 6572 5f61 6c65 7274 3c2f tracker_alert

    move │ │ │ +00065280: 2074 6869 7320 696e 746f 2074 7261 636b this into track │ │ │ +00065290: 6572 5f61 6c65 7274 3c2f 6832 3e3c 6834 er_alert

    ../src/alert.cp │ │ │ +000652b0: 703a 3432 313c 2f68 343e 3c70 7265 2073 p:421

    ..return {};
    │ │ │ +00065300: 0a23 656c 7365 0a09 0963 6861 7220 7265  .#else...char re
    │ │ │ +00065310: 745b 3430 305d 3b0a 0909 7374 643a 3a73  t[400];...std::s
    │ │ │ +00065320: 6e70 7269 6e74 6628 7265 742c 2073 697a  nprintf(ret, siz
    │ │ │ +00065330: 656f 6628 7265 7429 2c20 2225 7320 2573  eof(ret), "%s %s
    │ │ │ +00065340: 2025 7320 5c22 2573 5c22 2028 2564 2922   %s \"%s\" (%d)"
    │ │ │ +00065350: 0a09 0909 2c20 7472 6163 6b65 725f 616c  ...., tracker_al
    │ │ │ +00065360: 6572 743a 3a6d 6573 7361 6765 2829 2e63  ert::message().c
    │ │ │ +00065370: 5f73 7472 2829 0a09 0909 2c20 7665 7273  _str()...., vers
    │ │ │ +00065380: 696f 6e20 3d3d 2070 726f 746f 636f 6c5f  ion == protocol_
    │ │ │ +00065390: 7665 7273 696f 6e3a 3a56 3120 3f20 2276  version::V1 ? "v
    │ │ │ +000653a0: 3122 203a 2022 7632 220a 0909 092c 2063  1" : "v2"...., c
    │ │ │ +000653b0: 6f6e 7665 7274 5f66 726f 6d5f 6e61 7469  onvert_from_nati
    │ │ │ +000653c0: 7665 2865 7272 6f72 2e6d 6573 7361 6765  ve(error.message
    │ │ │ +000653d0: 2829 292e 635f 7374 7228 292c 2065 7272  ()).c_str(), err
    │ │ │ +000653e0: 6f72 5f6d 6573 7361 6765 2829 0a09 0909  or_message()....
    │ │ │ +000653f0: 2c20 7469 6d65 735f 696e 5f72 6f77 293b  , times_in_row);
    │ │ │ +00065400: 0a09 0972 6574 7572 6e20 7265 743b 0a23  ...return ret;.#
    │ │ │ +00065410: 656e 6469 660a 097d 0a0a 0974 7261 636b  endif..}...track
    │ │ │ +00065420: 6572 5f77 6172 6e69 6e67 5f61 6c65 7274  er_warning_alert
    │ │ │ +00065430: 3a3a 7472 6163 6b65 725f 7761 726e 696e  ::tracker_warnin
    │ │ │ +00065440: 675f 616c 6572 7428 6175 783a 3a73 7461  g_alert(aux::sta
    │ │ │ +00065450: 636b 5f61 6c6c 6f63 6174 6f72 2661 6d70  ck_allocator&
    │ │ │ +00065460: 3b20 616c 6c6f 630a 0909 2c20 746f 7272  ; alloc..., torr
    │ │ │ +00065470: 656e 745f 6861 6e64 6c65 2063 6f6e 7374  ent_handle const
    │ │ │ +00065480: 2661 6d70 3b20 682c 2074 6370 3a3a 656e  & h, tcp::en
    │ │ │ +00065490: 6470 6f69 6e74 2063 6f6e 7374 2661 6d70  dpoint const&
    │ │ │ +000654a0: 3b20 6570 0a09 092c 2073 7472 696e 675f  ; ep..., string_
    │ │ │ +000654b0: 7669 6577 2075 2c20 7072 6f74 6f63 6f6c  view u, protocol
    │ │ │ +000654c0: 5f76 6572 7369 6f6e 2076 2c20 7374 7269  _version v, stri
    │ │ │ +000654d0: 6e67 5f76 6965 7720 6d29 0a09 093a 2074  ng_view m)...: t
    │ │ │ +000654e0: 7261 636b 6572 5f61 6c65 7274 2861 6c6c  racker_alert(all
    │ │ │ +000654f0: 6f63 2c20 682c 2065 702c 2075 290a 0909  oc, h, ep, u)...
    │ │ │ +00065500: 2c20 6d5f 6d73 675f 6964 7828 616c 6c6f  , m_msg_idx(allo
    │ │ │ +00065510: 632e 636f 7079 5f73 7472 696e 6728 6d29  c.copy_string(m)
    │ │ │ +00065520: 290a 2369 6620 544f 5252 454e 545f 4142  ).#if TORRENT_AB
    │ │ │ +00065530: 495f 5645 5253 494f 4e20 3d3d 2031 0a09  I_VERSION == 1..
    │ │ │ +00065540: 092c 206d 7367 286d 290a 2365 6e64 6966  ., msg(m).#endif
    │ │ │ +00065550: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +00065580: 092c 2076 6572 7369 6f6e 2876 290a 3c2f ., version(v)..{...TORRENT │ │ │ +000655a0: 5f41 5353 4552 5428 2175 2e65 6d70 7479 _ASSERT(!u.empty │ │ │ +000655b0: 2829 293b 0a09 7d0a 0a09 6368 6172 2063 ());..}...char c │ │ │ +000655c0: 6f6e 7374 2a20 7472 6163 6b65 725f 7761 onst* tracker_wa │ │ │ +000655d0: 726e 696e 675f 616c 6572 743a 3a77 6172 rning_alert::war │ │ │ +000655e0: 6e69 6e67 5f6d 6573 7361 6765 2829 2063 ning_message() c │ │ │ +000655f0: 6f6e 7374 0a09 7b0a 0909 7265 7475 726e onst..{...return │ │ │ +00065600: 206d 5f61 6c6c 6f63 2e67 6574 2829 2e70 m_alloc.get().p │ │ │ +00065610: 7472 286d 5f6d 7367 5f69 6478 293b 0a09 tr(m_msg_idx);.. │ │ │ +00065620: 7d0a 0a09 7374 643a 3a73 7472 696e 6720 }...std::string │ │ │ +00065630: 7472 6163 6b65 725f 7761 726e 696e 675f tracker_warning_ │ │ │ +00065640: 616c 6572 743a 3a6d 6573 7361 6765 2829 alert::message() │ │ │ +00065650: 2063 6f6e 7374 0a09 7b0a 2369 6664 6566 const..{.#ifdef │ │ │ +00065660: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ +00065670: 5f41 4c45 5254 5f4d 5347 0a09 0972 6574 _ALERT_MSG...ret │ │ │ +00065680: 7572 6e20 7b7d 3b0a 2365 6c73 650a 0909 urn {};.#else... │ │ │ +00065690: 7265 7475 726e 2074 7261 636b 6572 5f61 return tracker_a │ │ │ +000656a0: 6c65 7274 3a3a 6d65 7373 6167 6528 2920 lert::message() │ │ │ +000656b0: 2b20 2876 6572 7369 6f6e 203d 3d20 7072 + (version == pr │ │ │ +000656c0: 6f74 6f63 6f6c 5f76 6572 7369 6f6e 3a3a otocol_version:: │ │ │ +000656d0: 5631 203f 2022 2076 3122 203a 2022 2076 V1 ? " v1" : " v │ │ │ +000656e0: 3222 2920 2b20 2220 7761 726e 696e 673a 2") + " warning: │ │ │ +000656f0: 2022 202b 2077 6172 6e69 6e67 5f6d 6573 " + warning_mes │ │ │ +00065700: 7361 6765 2829 3b0a 2365 6e64 6966 0a09 sage();.#endif.. │ │ │ +00065710: 7d0a 0a09 7363 7261 7065 5f72 6570 6c79 }...scrape_reply │ │ │ +00065720: 5f61 6c65 7274 3a3a 7363 7261 7065 5f72 _alert::scrape_r │ │ │ +00065730: 6570 6c79 5f61 6c65 7274 2861 7578 3a3a eply_alert(aux:: │ │ │ +00065740: 7374 6163 6b5f 616c 6c6f 6361 746f 7226 stack_allocator& │ │ │ +00065750: 616d 703b 2061 6c6c 6f63 0a09 092c 2074 amp; alloc..., t │ │ │ +00065760: 6f72 7265 6e74 5f68 616e 646c 6520 636f orrent_handle co │ │ │ +00065770: 6e73 7426 616d 703b 2068 2c20 7463 703a nst& h, tcp: │ │ │ +00065780: 3a65 6e64 706f 696e 7420 636f 6e73 7426 :endpoint const& │ │ │ +00065790: 616d 703b 2065 700a 0909 2c20 696e 7420 amp; ep..., int │ │ │ +000657a0: 696e 636f 6d70 2c20 696e 7420 636f 6d70 incomp, int comp │ │ │ +000657b0: 2c20 7374 7269 6e67 5f76 6965 7720 752c , string_view u, │ │ │ +000657c0: 2070 726f 746f 636f 6c5f 7665 7273 696f protocol_versio │ │ │ +000657d0: 6e20 636f 6e73 7420 7629 0a09 093a 2074 n const v)...: t │ │ │ +000657e0: 7261 636b 6572 5f61 6c65 7274 2861 6c6c racker_alert(all │ │ │ +000657f0: 6f63 2c20 682c 2065 702c 2075 290a 0909 oc, h, ep, u)... │ │ │ +00065800: 2c20 696e 636f 6d70 6c65 7465 2869 6e63 , incomplete(inc │ │ │ +00065810: 6f6d 7029 0a09 092c 2063 6f6d 706c 6574 omp)..., complet │ │ │ +00065820: 6528 636f 6d70 290a 3c2f 7072 653e 3c2f e(comp).
    relevan │ │ │ +00065860: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/alert. │ │ │ +000658a0: 6370 703a 3434 373c 2f61 3e3c 2f74 643e cpp:447 │ │ │ +000658b0: 3c74 643e 6d6f 7665 2074 6869 7320 696e move this in │ │ │ +000658c0: 746f 2074 7261 636b 6572 5f61 6c65 7274 to tracker_alert │ │ │ +000658d0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    mo │ │ │ +00065920: 7665 2074 6869 7320 696e 746f 2074 7261 ve this into tra │ │ │ +00065930: 636b 6572 5f61 6c65 7274 3c2f 6832 3e3c cker_alert

    < │ │ │ +00065940: 6834 3e2e 2e2f 7372 632f 616c 6572 742e h4>../src/alert. │ │ │ +00065950: 6370 703a 3434 373c 2f68 343e 3c70 7265 cpp:447
    .char cons
    │ │ │ +000659a0: 742a 2074 7261 636b 6572 5f77 6172 6e69  t* tracker_warni
    │ │ │ +000659b0: 6e67 5f61 6c65 7274 3a3a 7761 726e 696e  ng_alert::warnin
    │ │ │ +000659c0: 675f 6d65 7373 6167 6528 2920 636f 6e73  g_message() cons
    │ │ │ +000659d0: 740a 097b 0a09 0972 6574 7572 6e20 6d5f  t..{...return m_
    │ │ │ +000659e0: 616c 6c6f 632e 6765 7428 292e 7074 7228  alloc.get().ptr(
    │ │ │ +000659f0: 6d5f 6d73 675f 6964 7829 3b0a 097d 0a0a  m_msg_idx);..}..
    │ │ │ +00065a00: 0973 7464 3a3a 7374 7269 6e67 2074 7261  .std::string tra
    │ │ │ +00065a10: 636b 6572 5f77 6172 6e69 6e67 5f61 6c65  cker_warning_ale
    │ │ │ +00065a20: 7274 3a3a 6d65 7373 6167 6528 2920 636f  rt::message() co
    │ │ │ +00065a30: 6e73 740a 097b 0a23 6966 6465 6620 544f  nst..{.#ifdef TO
    │ │ │ +00065a40: 5252 454e 545f 4449 5341 424c 455f 414c  RRENT_DISABLE_AL
    │ │ │ +00065a50: 4552 545f 4d53 470a 0909 7265 7475 726e  ERT_MSG...return
    │ │ │ +00065a60: 207b 7d3b 0a23 656c 7365 0a09 0972 6574   {};.#else...ret
    │ │ │ +00065a70: 7572 6e20 7472 6163 6b65 725f 616c 6572  urn tracker_aler
    │ │ │ +00065a80: 743a 3a6d 6573 7361 6765 2829 202b 2028  t::message() + (
    │ │ │ +00065a90: 7665 7273 696f 6e20 3d3d 2070 726f 746f  version == proto
    │ │ │ +00065aa0: 636f 6c5f 7665 7273 696f 6e3a 3a56 3120  col_version::V1 
    │ │ │ +00065ab0: 3f20 2220 7631 2220 3a20 2220 7632 2229  ? " v1" : " v2")
    │ │ │ +00065ac0: 202b 2022 2077 6172 6e69 6e67 3a20 2220   + " warning: " 
    │ │ │ +00065ad0: 2b20 7761 726e 696e 675f 6d65 7373 6167  + warning_messag
    │ │ │ +00065ae0: 6528 293b 0a23 656e 6469 660a 097d 0a0a  e();.#endif..}..
    │ │ │ +00065af0: 0973 6372 6170 655f 7265 706c 795f 616c  .scrape_reply_al
    │ │ │ +00065b00: 6572 743a 3a73 6372 6170 655f 7265 706c  ert::scrape_repl
    │ │ │ +00065b10: 795f 616c 6572 7428 6175 783a 3a73 7461  y_alert(aux::sta
    │ │ │ +00065b20: 636b 5f61 6c6c 6f63 6174 6f72 2661 6d70  ck_allocator&
    │ │ │ +00065b30: 3b20 616c 6c6f 630a 0909 2c20 746f 7272  ; alloc..., torr
    │ │ │ +00065b40: 656e 745f 6861 6e64 6c65 2063 6f6e 7374  ent_handle const
    │ │ │ +00065b50: 2661 6d70 3b20 682c 2074 6370 3a3a 656e  & h, tcp::en
    │ │ │ +00065b60: 6470 6f69 6e74 2063 6f6e 7374 2661 6d70  dpoint const&
    │ │ │ +00065b70: 3b20 6570 0a09 092c 2069 6e74 2069 6e63  ; ep..., int inc
    │ │ │ +00065b80: 6f6d 702c 2069 6e74 2063 6f6d 702c 2073  omp, int comp, s
    │ │ │ +00065b90: 7472 696e 675f 7669 6577 2075 2c20 7072  tring_view u, pr
    │ │ │ +00065ba0: 6f74 6f63 6f6c 5f76 6572 7369 6f6e 2063  otocol_version c
    │ │ │ +00065bb0: 6f6e 7374 2076 290a 0909 3a20 7472 6163  onst v)...: trac
    │ │ │ +00065bc0: 6b65 725f 616c 6572 7428 616c 6c6f 632c  ker_alert(alloc,
    │ │ │ +00065bd0: 2068 2c20 6570 2c20 7529 0a09 092c 2069   h, ep, u)..., i
    │ │ │ +00065be0: 6e63 6f6d 706c 6574 6528 696e 636f 6d70  ncomplete(incomp
    │ │ │ +00065bf0: 290a 0909 2c20 636f 6d70 6c65 7465 2863  )..., complete(c
    │ │ │ +00065c00: 6f6d 7029 0a3c 6469 7620 7374 796c 653d  omp).
    .., version(v │ │ │ +00065c40: 290a 3c2f 6469 763e 097b 0a09 0954 4f52 ).
    .{...TOR │ │ │ +00065c50: 5245 4e54 5f41 5353 4552 5428 2175 2e65 RENT_ASSERT(!u.e │ │ │ +00065c60: 6d70 7479 2829 293b 0a09 7d0a 0a09 7374 mpty());..}...st │ │ │ +00065c70: 643a 3a73 7472 696e 6720 7363 7261 7065 d::string scrape │ │ │ +00065c80: 5f72 6570 6c79 5f61 6c65 7274 3a3a 6d65 _reply_alert::me │ │ │ +00065c90: 7373 6167 6528 2920 636f 6e73 740a 097b ssage() const..{ │ │ │ +00065ca0: 0a23 6966 6465 6620 544f 5252 454e 545f .#ifdef TORRENT_ │ │ │ +00065cb0: 4449 5341 424c 455f 414c 4552 545f 4d53 DISABLE_ALERT_MS │ │ │ +00065cc0: 470a 0909 7265 7475 726e 207b 7d3b 0a23 G...return {};.# │ │ │ +00065cd0: 656c 7365 0a09 0963 6861 7220 7265 745b else...char ret[ │ │ │ +00065ce0: 3430 305d 3b0a 0909 7374 643a 3a73 6e70 400];...std::snp │ │ │ +00065cf0: 7269 6e74 6628 7265 742c 2073 697a 656f rintf(ret, sizeo │ │ │ +00065d00: 6628 7265 7429 2c20 2225 7320 2573 2073 f(ret), "%s %s s │ │ │ +00065d10: 6372 6170 6520 7265 706c 793a 2025 6420 crape reply: %d │ │ │ +00065d20: 2564 220a 0909 092c 2074 7261 636b 6572 %d"...., tracker │ │ │ +00065d30: 5f61 6c65 7274 3a3a 6d65 7373 6167 6528 _alert::message( │ │ │ +00065d40: 292e 635f 7374 7228 290a 0909 092c 2076 ).c_str()...., v │ │ │ +00065d50: 6572 7369 6f6e 203d 3d20 7072 6f74 6f63 ersion == protoc │ │ │ +00065d60: 6f6c 5f76 6572 7369 6f6e 3a3a 5631 203f ol_version::V1 ? │ │ │ +00065d70: 2022 7631 2220 3a20 2276 3222 0a09 0909 "v1" : "v2".... │ │ │ +00065d80: 2c20 696e 636f 6d70 6c65 7465 2c20 636f , incomplete, co │ │ │ +00065d90: 6d70 6c65 7465 293b 0a09 0972 6574 7572 mplete);...retur │ │ │ +00065da0: 6e20 7265 743b 0a23 656e 6469 660a 097d n ret;.#endif..} │ │ │ +00065db0: 0a0a 0973 6372 6170 655f 6661 696c 6564 ...scrape_failed │ │ │ +00065dc0: 5f61 6c65 7274 3a3a 7363 7261 7065 5f66 _alert::scrape_f │ │ │ +00065dd0: 6169 6c65 645f 616c 6572 7428 6175 783a ailed_alert(aux: │ │ │ +00065de0: 3a73 7461 636b 5f61 6c6c 6f63 6174 6f72 :stack_allocator │ │ │ +00065df0: 2661 6d70 3b20 616c 6c6f 630a 0909 2c20 & alloc..., │ │ │ +00065e00: 746f 7272 656e 745f 6861 6e64 6c65 2063 torrent_handle c │ │ │ +00065e10: 6f6e 7374 2661 6d70 3b20 682c 2074 6370 onst& h, tcp │ │ │ +00065e20: 3a3a 656e 6470 6f69 6e74 2063 6f6e 7374 ::endpoint const │ │ │ +00065e30: 2661 6d70 3b20 6570 0a09 092c 2073 7472 & ep..., str │ │ │ +00065e40: 696e 675f 7669 6577 2075 2c20 7072 6f74 ing_view u, prot │ │ │ +00065e50: 6f63 6f6c 5f76 6572 7369 6f6e 2063 6f6e ocol_version con │ │ │ +00065e60: 7374 2076 2c20 6572 726f 725f 636f 6465 st v, error_code │ │ │ +00065e70: 2063 6f6e 7374 2661 6d70 3b20 6529 0a09 const& e).. │ │ │ +00065e80: 093a 2074 7261 636b 6572 5f61 6c65 7274 .: tracker_alert │ │ │ +00065e90: 2861 6c6c 6f63 2c20 682c 2065 702c 2075 (alloc, h, ep, u │ │ │ +00065ea0: 290a 0909 2c20 6572 726f 7228 6529 0a09 )..., error(e).. │ │ │ +00065eb0: 092c 206d 5f6d 7367 5f69 6478 2829 0a23 ., m_msg_idx().# │ │ │ +00065ec0: 6966 2054 4f52 5245 4e54 5f41 4249 5f56 if TORRENT_ABI_V │ │ │ +00065ed0: 4552 5349 4f4e 203d 3d20 310a 0909 2c20 ERSION == 1..., │ │ │ +00065ee0: 6d73 6728 636f 6e76 6572 745f 6672 6f6d msg(convert_from │ │ │ +00065ef0: 5f6e 6174 6976 6528 652e 6d65 7373 6167 _native(e.messag │ │ │ +00065f00: 6528 2929 290a 2365 6e64 6966 0a3c 2f70 e())).#endif.

    re │ │ │ +00065f40: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/a │ │ │ +00065f80: 6c65 7274 2e63 7070 3a34 3736 3c2f 613e lert.cpp:476 │ │ │ +00065f90: 3c2f 7464 3e3c 7464 3e6d 6f76 6520 7468 move th │ │ │ +00065fa0: 6973 2069 6e74 6f20 7472 6163 6b65 725f is into tracker_ │ │ │ +00065fb0: 616c 6572 743c 2f74 643e 3c2f 7472 3e3c alert< │ │ │ +00065fc0: 7472 2069 643d 2232 3334 2220 7374 796c tr id="234" styl │ │ │ +00065fd0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00065fe0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00065ff0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00066000: 6832 3e6d 6f76 6520 7468 6973 2069 6e74 h2>move this int │ │ │ +00066010: 6f20 7472 6163 6b65 725f 616c 6572 743c o tracker_alert< │ │ │ +00066020: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f61 /h2>

    ../src/a │ │ │ +00066030: 6c65 7274 2e63 7070 3a34 3736 3c2f 6834 lert.cpp:476

    ..ret
    │ │ │ +00066080: 7572 6e20 7b7d 3b0a 2365 6c73 650a 0909  urn {};.#else...
    │ │ │ +00066090: 6368 6172 2072 6574 5b34 3030 5d3b 0a09  char ret[400];..
    │ │ │ +000660a0: 0973 7464 3a3a 736e 7072 696e 7466 2872  .std::snprintf(r
    │ │ │ +000660b0: 6574 2c20 7369 7a65 6f66 2872 6574 292c  et, sizeof(ret),
    │ │ │ +000660c0: 2022 2573 2025 7320 7363 7261 7065 2072   "%s %s scrape r
    │ │ │ +000660d0: 6570 6c79 3a20 2564 2025 6422 0a09 0909  eply: %d %d"....
    │ │ │ +000660e0: 2c20 7472 6163 6b65 725f 616c 6572 743a  , tracker_alert:
    │ │ │ +000660f0: 3a6d 6573 7361 6765 2829 2e63 5f73 7472  :message().c_str
    │ │ │ +00066100: 2829 0a09 0909 2c20 7665 7273 696f 6e20  ()...., version 
    │ │ │ +00066110: 3d3d 2070 726f 746f 636f 6c5f 7665 7273  == protocol_vers
    │ │ │ +00066120: 696f 6e3a 3a56 3120 3f20 2276 3122 203a  ion::V1 ? "v1" :
    │ │ │ +00066130: 2022 7632 220a 0909 092c 2069 6e63 6f6d   "v2"...., incom
    │ │ │ +00066140: 706c 6574 652c 2063 6f6d 706c 6574 6529  plete, complete)
    │ │ │ +00066150: 3b0a 0909 7265 7475 726e 2072 6574 3b0a  ;...return ret;.
    │ │ │ +00066160: 2365 6e64 6966 0a09 7d0a 0a09 7363 7261  #endif..}...scra
    │ │ │ +00066170: 7065 5f66 6169 6c65 645f 616c 6572 743a  pe_failed_alert:
    │ │ │ +00066180: 3a73 6372 6170 655f 6661 696c 6564 5f61  :scrape_failed_a
    │ │ │ +00066190: 6c65 7274 2861 7578 3a3a 7374 6163 6b5f  lert(aux::stack_
    │ │ │ +000661a0: 616c 6c6f 6361 746f 7226 616d 703b 2061  allocator& a
    │ │ │ +000661b0: 6c6c 6f63 0a09 092c 2074 6f72 7265 6e74  lloc..., torrent
    │ │ │ +000661c0: 5f68 616e 646c 6520 636f 6e73 7426 616d  _handle const&am
    │ │ │ +000661d0: 703b 2068 2c20 7463 703a 3a65 6e64 706f  p; h, tcp::endpo
    │ │ │ +000661e0: 696e 7420 636f 6e73 7426 616d 703b 2065  int const& e
    │ │ │ +000661f0: 700a 0909 2c20 7374 7269 6e67 5f76 6965  p..., string_vie
    │ │ │ +00066200: 7720 752c 2070 726f 746f 636f 6c5f 7665  w u, protocol_ve
    │ │ │ +00066210: 7273 696f 6e20 636f 6e73 7420 762c 2065  rsion const v, e
    │ │ │ +00066220: 7272 6f72 5f63 6f64 6520 636f 6e73 7426  rror_code const&
    │ │ │ +00066230: 616d 703b 2065 290a 0909 3a20 7472 6163  amp; e)...: trac
    │ │ │ +00066240: 6b65 725f 616c 6572 7428 616c 6c6f 632c  ker_alert(alloc,
    │ │ │ +00066250: 2068 2c20 6570 2c20 7529 0a09 092c 2065   h, ep, u)..., e
    │ │ │ +00066260: 7272 6f72 2865 290a 0909 2c20 6d5f 6d73  rror(e)..., m_ms
    │ │ │ +00066270: 675f 6964 7828 290a 2369 6620 544f 5252  g_idx().#if TORR
    │ │ │ +00066280: 454e 545f 4142 495f 5645 5253 494f 4e20  ENT_ABI_VERSION 
    │ │ │ +00066290: 3d3d 2031 0a09 092c 206d 7367 2863 6f6e  == 1..., msg(con
    │ │ │ +000662a0: 7665 7274 5f66 726f 6d5f 6e61 7469 7665  vert_from_native
    │ │ │ +000662b0: 2865 2e6d 6573 7361 6765 2829 2929 0a23  (e.message())).#
    │ │ │ +000662c0: 656e 6469 660a 3c64 6976 2073 7479 6c65  endif.
    .., version( │ │ │ +00066300: 7629 0a3c 2f64 6976 3e09 7b0a 0909 544f v).
    .{...TO │ │ │ +00066310: 5252 454e 545f 4153 5345 5254 2821 752e RRENT_ASSERT(!u. │ │ │ +00066320: 656d 7074 7928 2929 3b0a 097d 0a0a 0973 empty());..}...s │ │ │ +00066330: 6372 6170 655f 6661 696c 6564 5f61 6c65 crape_failed_ale │ │ │ +00066340: 7274 3a3a 7363 7261 7065 5f66 6169 6c65 rt::scrape_faile │ │ │ +00066350: 645f 616c 6572 7428 6175 783a 3a73 7461 d_alert(aux::sta │ │ │ +00066360: 636b 5f61 6c6c 6f63 6174 6f72 2661 6d70 ck_allocator& │ │ │ +00066370: 3b20 616c 6c6f 630a 0909 2c20 746f 7272 ; alloc..., torr │ │ │ +00066380: 656e 745f 6861 6e64 6c65 2063 6f6e 7374 ent_handle const │ │ │ +00066390: 2661 6d70 3b20 682c 2074 6370 3a3a 656e & h, tcp::en │ │ │ +000663a0: 6470 6f69 6e74 2063 6f6e 7374 2661 6d70 dpoint const& │ │ │ +000663b0: 3b20 6570 0a09 092c 2073 7472 696e 675f ; ep..., string_ │ │ │ +000663c0: 7669 6577 2075 2c20 7374 7269 6e67 5f76 view u, string_v │ │ │ +000663d0: 6965 7720 6d29 0a09 093a 2074 7261 636b iew m)...: track │ │ │ +000663e0: 6572 5f61 6c65 7274 2861 6c6c 6f63 2c20 er_alert(alloc, │ │ │ +000663f0: 682c 2065 702c 2075 290a 0909 2c20 6572 h, ep, u)..., er │ │ │ +00066400: 726f 7228 6572 726f 7273 3a3a 7472 6163 ror(errors::trac │ │ │ +00066410: 6b65 725f 6661 696c 7572 6529 0a09 092c ker_failure)..., │ │ │ +00066420: 206d 5f6d 7367 5f69 6478 2861 6c6c 6f63 m_msg_idx(alloc │ │ │ +00066430: 2e63 6f70 795f 7374 7269 6e67 286d 2929 .copy_string(m)) │ │ │ +00066440: 0a23 6966 2054 4f52 5245 4e54 5f41 4249 .#if TORRENT_ABI │ │ │ +00066450: 5f56 4552 5349 4f4e 203d 3d20 310a 0909 _VERSION == 1... │ │ │ +00066460: 2c20 6d73 6728 6d29 0a23 656e 6469 660a , msg(m).#endif. │ │ │ +00066470: 097b 0a09 0954 4f52 5245 4e54 5f41 5353 .{...TORRENT_ASS │ │ │ +00066480: 4552 5428 2175 2e65 6d70 7479 2829 293b ERT(!u.empty()); │ │ │ +00066490: 0a09 7d0a 0a09 6368 6172 2063 6f6e 7374 ..}...char const │ │ │ +000664a0: 2a20 7363 7261 7065 5f66 6169 6c65 645f * scrape_failed_ │ │ │ +000664b0: 616c 6572 743a 3a65 7272 6f72 5f6d 6573 alert::error_mes │ │ │ +000664c0: 7361 6765 2829 2063 6f6e 7374 0a09 7b0a sage() const..{. │ │ │ +000664d0: 0909 6966 2028 6d5f 6d73 675f 6964 7820 ..if (m_msg_idx │ │ │ +000664e0: 3d3d 2061 7578 3a3a 616c 6c6f 6361 7469 == aux::allocati │ │ │ +000664f0: 6f6e 5f73 6c6f 7428 2929 2072 6574 7572 on_slot()) retur │ │ │ +00066500: 6e20 2222 3b0a 0909 656c 7365 2072 6574 n "";...else ret │ │ │ +00066510: 7572 6e20 6d5f 616c 6c6f 632e 6765 7428 urn m_alloc.get( │ │ │ +00066520: 292e 7074 7228 6d5f 6d73 675f 6964 7829 ).ptr(m_msg_idx) │ │ │ +00066530: 3b0a 097d 0a0a 0973 7464 3a3a 7374 7269 ;..}...std::stri │ │ │ +00066540: 6e67 2073 6372 6170 655f 6661 696c 6564 ng scrape_failed │ │ │ +00066550: 5f61 6c65 7274 3a3a 6d65 7373 6167 6528 _alert::message( │ │ │ +00066560: 2920 636f 6e73 740a 097b 0a23 6966 6465 ) const..{.#ifde │ │ │ +00066570: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ +00066580: 455f 414c 4552 545f 4d53 470a 0909 7265 E_ALERT_MSG...re │ │ │ +00066590: 7475 726e 207b 7d3b 0a23 656c 7365 0a09 turn {};.#else.. │ │ │ +000665a0: 0972 6574 7572 6e20 7472 6163 6b65 725f .return tracker_ │ │ │ +000665b0: 616c 6572 743a 3a6d 6573 7361 6765 2829 alert::message() │ │ │ +000665c0: 202b 2022 2073 6372 6170 6520 6661 696c + " scrape fail │ │ │ +000665d0: 6564 3a20 2220 2b20 6572 726f 725f 6d65 ed: " + error_me │ │ │ +000665e0: 7373 6167 6528 293b 0a23 656e 6469 660a ssage();.#endif. │ │ │ +000665f0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +00066600: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00066630: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +00066660: 632f 616c 6572 742e 6370 703a 3531 353c c/alert.cpp:515< │ │ │ +00066670: 2f61 3e3c 2f74 643e 3c74 643e 6d6f 7665 /a>move │ │ │ +00066680: 2074 6869 7320 6669 656c 6420 696e 746f this field into │ │ │ +00066690: 2074 7261 636b 6572 5f61 6c65 7274 3c2f tracker_alert

    move │ │ │ +000666f0: 2074 6869 7320 6669 656c 6420 696e 746f this field into │ │ │ +00066700: 2074 7261 636b 6572 5f61 6c65 7274 3c2f tracker_alert

    ../src/al │ │ │ +00066720: 6572 742e 6370 703a 3531 353c 2f68 343e ert.cpp:515

    │ │ │ +00066730: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .char 
    │ │ │ +00066770: 636f 6e73 742a 2073 6372 6170 655f 6661  const* scrape_fa
    │ │ │ +00066780: 696c 6564 5f61 6c65 7274 3a3a 6572 726f  iled_alert::erro
    │ │ │ +00066790: 725f 6d65 7373 6167 6528 2920 636f 6e73  r_message() cons
    │ │ │ +000667a0: 740a 097b 0a09 0969 6620 286d 5f6d 7367  t..{...if (m_msg
    │ │ │ +000667b0: 5f69 6478 203d 3d20 6175 783a 3a61 6c6c  _idx == aux::all
    │ │ │ +000667c0: 6f63 6174 696f 6e5f 736c 6f74 2829 2920  ocation_slot()) 
    │ │ │ +000667d0: 7265 7475 726e 2022 223b 0a09 0965 6c73  return "";...els
    │ │ │ +000667e0: 6520 7265 7475 726e 206d 5f61 6c6c 6f63  e return m_alloc
    │ │ │ +000667f0: 2e67 6574 2829 2e70 7472 286d 5f6d 7367  .get().ptr(m_msg
    │ │ │ +00066800: 5f69 6478 293b 0a09 7d0a 0a09 7374 643a  _idx);..}...std:
    │ │ │ +00066810: 3a73 7472 696e 6720 7363 7261 7065 5f66  :string scrape_f
    │ │ │ +00066820: 6169 6c65 645f 616c 6572 743a 3a6d 6573  ailed_alert::mes
    │ │ │ +00066830: 7361 6765 2829 2063 6f6e 7374 0a09 7b0a  sage() const..{.
    │ │ │ +00066840: 2369 6664 6566 2054 4f52 5245 4e54 5f44  #ifdef TORRENT_D
    │ │ │ +00066850: 4953 4142 4c45 5f41 4c45 5254 5f4d 5347  ISABLE_ALERT_MSG
    │ │ │ +00066860: 0a09 0972 6574 7572 6e20 7b7d 3b0a 2365  ...return {};.#e
    │ │ │ +00066870: 6c73 650a 0909 7265 7475 726e 2074 7261  lse...return tra
    │ │ │ +00066880: 636b 6572 5f61 6c65 7274 3a3a 6d65 7373  cker_alert::mess
    │ │ │ +00066890: 6167 6528 2920 2b20 2220 7363 7261 7065  age() + " scrape
    │ │ │ +000668a0: 2066 6169 6c65 643a 2022 202b 2065 7272   failed: " + err
    │ │ │ +000668b0: 6f72 5f6d 6573 7361 6765 2829 3b0a 2365  or_message();.#e
    │ │ │ +000668c0: 6e64 6966 0a09 7d0a 0a09 7472 6163 6b65  ndif..}...tracke
    │ │ │ +000668d0: 725f 7265 706c 795f 616c 6572 743a 3a74  r_reply_alert::t
    │ │ │ +000668e0: 7261 636b 6572 5f72 6570 6c79 5f61 6c65  racker_reply_ale
    │ │ │ +000668f0: 7274 2861 7578 3a3a 7374 6163 6b5f 616c  rt(aux::stack_al
    │ │ │ +00066900: 6c6f 6361 746f 7226 616d 703b 2061 6c6c  locator& all
    │ │ │ +00066910: 6f63 0a09 092c 2074 6f72 7265 6e74 5f68  oc..., torrent_h
    │ │ │ +00066920: 616e 646c 6520 636f 6e73 7426 616d 703b  andle const&
    │ │ │ +00066930: 2068 2c20 7463 703a 3a65 6e64 706f 696e   h, tcp::endpoin
    │ │ │ +00066940: 7420 636f 6e73 7426 616d 703b 2065 700a  t const& ep.
    │ │ │ +00066950: 0909 2c20 696e 7420 6e70 2c20 7072 6f74  .., int np, prot
    │ │ │ +00066960: 6f63 6f6c 5f76 6572 7369 6f6e 2076 2c20  ocol_version v, 
    │ │ │ +00066970: 7374 7269 6e67 5f76 6965 7720 7529 0a09  string_view u)..
    │ │ │ +00066980: 093a 2074 7261 636b 6572 5f61 6c65 7274  .: tracker_alert
    │ │ │ +00066990: 2861 6c6c 6f63 2c20 682c 2065 702c 2075  (alloc, h, ep, u
    │ │ │ +000669a0: 290a 0909 2c20 6e75 6d5f 7065 6572 7328  )..., num_peers(
    │ │ │ +000669b0: 6e70 290a 3c64 6976 2073 7479 6c65 3d22  np).
    .., version(v) │ │ │ +000669f0: 0a3c 2f64 6976 3e09 7b0a 0909 544f 5252 .
    .{...TORR │ │ │ +00066a00: 454e 545f 4153 5345 5254 2821 752e 656d ENT_ASSERT(!u.em │ │ │ +00066a10: 7074 7928 2929 3b0a 097d 0a0a 0973 7464 pty());..}...std │ │ │ +00066a20: 3a3a 7374 7269 6e67 2074 7261 636b 6572 ::string tracker │ │ │ +00066a30: 5f72 6570 6c79 5f61 6c65 7274 3a3a 6d65 _reply_alert::me │ │ │ +00066a40: 7373 6167 6528 2920 636f 6e73 740a 097b ssage() const..{ │ │ │ +00066a50: 0a23 6966 6465 6620 544f 5252 454e 545f .#ifdef TORRENT_ │ │ │ +00066a60: 4449 5341 424c 455f 414c 4552 545f 4d53 DISABLE_ALERT_MS │ │ │ +00066a70: 470a 0909 7265 7475 726e 207b 7d3b 0a23 G...return {};.# │ │ │ +00066a80: 656c 7365 0a09 0963 6861 7220 7265 745b else...char ret[ │ │ │ +00066a90: 3430 305d 3b0a 0909 7374 643a 3a73 6e70 400];...std::snp │ │ │ +00066aa0: 7269 6e74 6628 7265 742c 2073 697a 656f rintf(ret, sizeo │ │ │ +00066ab0: 6628 7265 7429 2c20 2225 7320 2573 2072 f(ret), "%s %s r │ │ │ +00066ac0: 6563 6569 7665 6420 7065 6572 733a 2025 eceived peers: % │ │ │ +00066ad0: 6422 0a09 0909 2c20 7472 6163 6b65 725f d"...., tracker_ │ │ │ +00066ae0: 616c 6572 743a 3a6d 6573 7361 6765 2829 alert::message() │ │ │ +00066af0: 2e63 5f73 7472 2829 0a09 0909 2c20 7665 .c_str()...., ve │ │ │ +00066b00: 7273 696f 6e20 3d3d 2070 726f 746f 636f rsion == protoco │ │ │ +00066b10: 6c5f 7665 7273 696f 6e3a 3a56 3120 3f20 l_version::V1 ? │ │ │ +00066b20: 2276 3122 203a 2022 7632 220a 0909 092c "v1" : "v2"...., │ │ │ +00066b30: 206e 756d 5f70 6565 7273 293b 0a09 0972 num_peers);...r │ │ │ +00066b40: 6574 7572 6e20 7265 743b 0a23 656e 6469 eturn ret;.#endi │ │ │ +00066b50: 660a 097d 0a0a 0964 6874 5f72 6570 6c79 f..}...dht_reply │ │ │ +00066b60: 5f61 6c65 7274 3a3a 6468 745f 7265 706c _alert::dht_repl │ │ │ +00066b70: 795f 616c 6572 7428 6175 783a 3a73 7461 y_alert(aux::sta │ │ │ +00066b80: 636b 5f61 6c6c 6f63 6174 6f72 2661 6d70 ck_allocator& │ │ │ +00066b90: 3b20 616c 6c6f 630a 0909 2c20 746f 7272 ; alloc..., torr │ │ │ +00066ba0: 656e 745f 6861 6e64 6c65 2063 6f6e 7374 ent_handle const │ │ │ +00066bb0: 2661 6d70 3b20 680a 0909 2c20 696e 7420 & h..., int │ │ │ +00066bc0: 6e70 290a 0909 3a20 7472 6163 6b65 725f np)...: tracker_ │ │ │ +00066bd0: 616c 6572 7428 616c 6c6f 632c 2068 2c20 alert(alloc, h, │ │ │ +00066be0: 7b7d 2c20 2222 290a 0909 2c20 6e75 6d5f {}, "")..., num_ │ │ │ +00066bf0: 7065 6572 7328 6e70 290a 097b 7d0a 0a09 peers(np)..{}... │ │ │ +00066c00: 7374 643a 3a73 7472 696e 6720 6468 745f std::string dht_ │ │ │ +00066c10: 7265 706c 795f 616c 6572 743a 3a6d 6573 reply_alert::mes │ │ │ +00066c20: 7361 6765 2829 2063 6f6e 7374 0a09 7b0a sage() const..{. │ │ │ +00066c30: 2369 6664 6566 2054 4f52 5245 4e54 5f44 #ifdef TORRENT_D │ │ │ +00066c40: 4953 4142 4c45 5f41 4c45 5254 5f4d 5347 ISABLE_ALERT_MSG │ │ │ +00066c50: 0a09 0972 6574 7572 6e20 7b7d 3b0a 2365 ...return {};.#e │ │ │ +00066c60: 6c73 650a 3c2f 7072 653e 3c2f 7464 3e3c lse.
    < │ │ │ +00066c70: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +00066ca0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0
    . │ │ │ +00066cd0: 2e2f 7372 632f 616c 6572 742e 6370 703a ./src/alert.cpp: │ │ │ +00066ce0: 3535 393c 2f61 3e3c 2f74 643e 3c74 643e 559 │ │ │ +00066cf0: 6d6f 7665 2074 6869 7320 746f 2074 7261 move this to tra │ │ │ +00066d00: 636b 6572 5f61 6c65 7274 3c2f 7464 3e3c cker_alert< │ │ │ +00066d10: 2f74 723e 3c74 7220 6964 3d22 3233 3622 /tr>

    move thi │ │ │ +00066d60: 7320 746f 2074 7261 636b 6572 5f61 6c65 s to tracker_ale │ │ │ +00066d70: 7274 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 rt

    ../sr │ │ │ +00066d80: 632f 616c 6572 742e 6370 703a 3535 393c c/alert.cpp:559< │ │ │ +00066d90: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +00066dd0: 2c20 6e75 6d5f 7065 6572 7328 6e70 290a  , num_peers(np).
    │ │ │ +00066de0: 097b 7d0a 0a09 7374 643a 3a73 7472 696e  .{}...std::strin
    │ │ │ +00066df0: 6720 6468 745f 7265 706c 795f 616c 6572  g dht_reply_aler
    │ │ │ +00066e00: 743a 3a6d 6573 7361 6765 2829 2063 6f6e  t::message() con
    │ │ │ +00066e10: 7374 0a09 7b0a 2369 6664 6566 2054 4f52  st..{.#ifdef TOR
    │ │ │ +00066e20: 5245 4e54 5f44 4953 4142 4c45 5f41 4c45  RENT_DISABLE_ALE
    │ │ │ +00066e30: 5254 5f4d 5347 0a09 0972 6574 7572 6e20  RT_MSG...return 
    │ │ │ +00066e40: 7b7d 3b0a 2365 6c73 650a 0909 6368 6172  {};.#else...char
    │ │ │ +00066e50: 2072 6574 5b34 3030 5d3b 0a09 0973 7464   ret[400];...std
    │ │ │ +00066e60: 3a3a 736e 7072 696e 7466 2872 6574 2c20  ::snprintf(ret, 
    │ │ │ +00066e70: 7369 7a65 6f66 2872 6574 292c 2022 2573  sizeof(ret), "%s
    │ │ │ +00066e80: 2072 6563 6569 7665 6420 4448 5420 7065   received DHT pe
    │ │ │ +00066e90: 6572 733a 2025 6422 0a09 0909 2c20 7472  ers: %d"...., tr
    │ │ │ +00066ea0: 6163 6b65 725f 616c 6572 743a 3a6d 6573  acker_alert::mes
    │ │ │ +00066eb0: 7361 6765 2829 2e63 5f73 7472 2829 2c20  sage().c_str(), 
    │ │ │ +00066ec0: 6e75 6d5f 7065 6572 7329 3b0a 0909 7265  num_peers);...re
    │ │ │ +00066ed0: 7475 726e 2072 6574 3b0a 2365 6e64 6966  turn ret;.#endif
    │ │ │ +00066ee0: 0a09 7d0a 0a09 7472 6163 6b65 725f 616e  ..}...tracker_an
    │ │ │ +00066ef0: 6e6f 756e 6365 5f61 6c65 7274 3a3a 7472  nounce_alert::tr
    │ │ │ +00066f00: 6163 6b65 725f 616e 6e6f 756e 6365 5f61  acker_announce_a
    │ │ │ +00066f10: 6c65 7274 2861 7578 3a3a 7374 6163 6b5f  lert(aux::stack_
    │ │ │ +00066f20: 616c 6c6f 6361 746f 7226 616d 703b 2061  allocator& a
    │ │ │ +00066f30: 6c6c 6f63 0a09 092c 2074 6f72 7265 6e74  lloc..., torrent
    │ │ │ +00066f40: 5f68 616e 646c 6520 636f 6e73 7426 616d  _handle const&am
    │ │ │ +00066f50: 703b 2068 2c20 7463 703a 3a65 6e64 706f  p; h, tcp::endpo
    │ │ │ +00066f60: 696e 7420 636f 6e73 7426 616d 703b 2065  int const& e
    │ │ │ +00066f70: 702c 2073 7472 696e 675f 7669 6577 2075  p, string_view u
    │ │ │ +00066f80: 0a09 092c 2070 726f 746f 636f 6c5f 7665  ..., protocol_ve
    │ │ │ +00066f90: 7273 696f 6e20 636f 6e73 7420 762c 2065  rsion const v, e
    │ │ │ +00066fa0: 7665 6e74 5f74 2063 6f6e 7374 2065 290a  vent_t const e).
    │ │ │ +00066fb0: 0909 3a20 7472 6163 6b65 725f 616c 6572  ..: tracker_aler
    │ │ │ +00066fc0: 7428 616c 6c6f 632c 2068 2c20 6570 2c20  t(alloc, h, ep, 
    │ │ │ +00066fd0: 7529 0a09 092c 2065 7665 6e74 2865 290a  u)..., event(e).
    │ │ │ +00066fe0: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ +00067010: 2c20 7665 7273 696f 6e28 7629 0a3c 2f64 , version(v)..{...TORRENT_ │ │ │ +00067030: 4153 5345 5254 2821 752e 656d 7074 7928 ASSERT(!u.empty( │ │ │ +00067040: 2929 3b0a 097d 0a0a 0973 7464 3a3a 7374 ));..}...std::st │ │ │ +00067050: 7269 6e67 2074 7261 636b 6572 5f61 6e6e ring tracker_ann │ │ │ +00067060: 6f75 6e63 655f 616c 6572 743a 3a6d 6573 ounce_alert::mes │ │ │ +00067070: 7361 6765 2829 2063 6f6e 7374 0a09 7b0a sage() const..{. │ │ │ +00067080: 2369 6664 6566 2054 4f52 5245 4e54 5f44 #ifdef TORRENT_D │ │ │ +00067090: 4953 4142 4c45 5f41 4c45 5254 5f4d 5347 ISABLE_ALERT_MSG │ │ │ +000670a0: 0a09 0972 6574 7572 6e20 7b7d 3b0a 2365 ...return {};.#e │ │ │ +000670b0: 6c73 650a 0909 7374 6174 6963 2063 6f6e lse...static con │ │ │ +000670c0: 7374 2063 6861 722a 2063 6f6e 7374 2065 st char* const e │ │ │ +000670d0: 7665 6e74 5f73 7472 5b5d 203d 207b 226e vent_str[] = {"n │ │ │ +000670e0: 6f6e 6522 2c20 2263 6f6d 706c 6574 6564 one", "completed │ │ │ +000670f0: 222c 2022 7374 6172 7465 6422 2c20 2273 ", "started", "s │ │ │ +00067100: 746f 7070 6564 222c 2022 7061 7573 6564 topped", "paused │ │ │ +00067110: 227d 3b0a 0909 7265 7475 726e 2074 7261 "};...return tra │ │ │ +00067120: 636b 6572 5f61 6c65 7274 3a3a 6d65 7373 cker_alert::mess │ │ │ +00067130: 6167 6528 290a 0909 092b 2028 7665 7273 age()....+ (vers │ │ │ +00067140: 696f 6e20 3d3d 2070 726f 746f 636f 6c5f ion == protocol_ │ │ │ +00067150: 7665 7273 696f 6e3a 3a56 3120 3f20 2220 version::V1 ? " │ │ │ +00067160: 7631 2220 3a20 2220 7632 2229 0a09 0909 v1" : " v2").... │ │ │ +00067170: 2b20 2220 7365 6e64 696e 6720 616e 6e6f + " sending anno │ │ │ +00067180: 756e 6365 2028 2220 2b20 6576 656e 745f unce (" + event_ │ │ │ +00067190: 7374 725b 7374 6174 6963 5f63 6173 7426 str[static_cast& │ │ │ +000671a0: 6c74 3b69 6e74 2667 743b 2865 7665 6e74 lt;int>(event │ │ │ +000671b0: 295d 202b 2022 2922 3b0a 2365 6e64 6966 )] + ")";.#endif │ │ │ +000671c0: 0a09 7d0a 0a09 6861 7368 5f66 6169 6c65 ..}...hash_faile │ │ │ +000671d0: 645f 616c 6572 743a 3a68 6173 685f 6661 d_alert::hash_fa │ │ │ +000671e0: 696c 6564 5f61 6c65 7274 280a 0909 6175 iled_alert(...au │ │ │ +000671f0: 783a 3a73 7461 636b 5f61 6c6c 6f63 6174 x::stack_allocat │ │ │ +00067200: 6f72 2661 6d70 3b20 616c 6c6f 630a 0909 or& alloc... │ │ │ +00067210: 2c20 746f 7272 656e 745f 6861 6e64 6c65 , torrent_handle │ │ │ +00067220: 2063 6f6e 7374 2661 6d70 3b20 680a 0909 const& h... │ │ │ +00067230: 2c20 7069 6563 655f 696e 6465 785f 7420 , piece_index_t │ │ │ +00067240: 696e 6465 7829 0a09 093a 2074 6f72 7265 index)...: torre │ │ │ +00067250: 6e74 5f61 6c65 7274 2861 6c6c 6f63 2c20 nt_alert(alloc, │ │ │ +00067260: 6829 0a09 092c 2070 6965 6365 5f69 6e64 h)..., piece_ind │ │ │ +00067270: 6578 2869 6e64 6578 290a 097b 0a09 0954 ex(index)..{...T │ │ │ +00067280: 4f52 5245 4e54 5f41 5353 4552 5428 696e ORRENT_ASSERT(in │ │ │ +00067290: 6465 7820 2667 743b 3d20 7069 6563 655f dex >= piece_ │ │ │ +000672a0: 696e 6465 785f 7428 3029 293b 0a09 7d0a index_t(0));..}. │ │ │ +000672b0: 0a09 7374 643a 3a73 7472 696e 6720 6861 ..std::string ha │ │ │ +000672c0: 7368 5f66 6169 6c65 645f 616c 6572 743a sh_failed_alert: │ │ │ +000672d0: 3a6d 6573 7361 6765 2829 2063 6f6e 7374 :message() const │ │ │ +000672e0: 0a09 7b0a 2369 6664 6566 2054 4f52 5245 ..{.#ifdef TORRE │ │ │ +000672f0: 4e54 5f44 4953 4142 4c45 5f41 4c45 5254 NT_DISABLE_ALERT │ │ │ +00067300: 5f4d 5347 0a09 0972 6574 7572 6e20 7b7d _MSG...return {} │ │ │ +00067310: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ +00067340: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +00067350: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +00067380: 7372 632f 6669 6c65 5f73 746f 7261 6765 src/file_storage │ │ │ +00067390: 2e63 7070 3a34 3538 3c2f 613e 3c2f 7464 .cpp:458maybe it wo │ │ │ +000673b0: 756c 6420 6265 206e 6963 6520 746f 2068 uld be nice to h │ │ │ +000673c0: 6176 6520 6120 6265 7474 6572 2069 6e64 ave a better ind │ │ │ +000673d0: 6578 2068 6572 653c 2f74 643e 3c2f 7472 ex here

    maybe it wo │ │ │ +00067430: 756c 6420 6265 206e 6963 6520 746f 2068 uld be nice to h │ │ │ +00067440: 6176 6520 6120 6265 7474 6572 2069 6e64 ave a better ind │ │ │ +00067450: 6578 2068 6572 653c 2f68 323e 3c68 343e ex here

    │ │ │ +00067460: 2e2e 2f73 7263 2f66 696c 655f 7374 6f72 ../src/file_stor │ │ │ +00067470: 6167 652e 6370 703a 3435 383c 2f68 343e age.cpp:458

    │ │ │ +00067480: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..// f
    │ │ │ +000674c0: 696e 6420 7468 6520 6669 6c65 2069 7465  ind the file ite
    │ │ │ +000674d0: 7261 746f 7220 616e 6420 6669 6c65 206f  rator and file o
    │ │ │ +000674e0: 6666 7365 740a 0909 6175 783a 3a66 696c  ffset...aux::fil
    │ │ │ +000674f0: 655f 656e 7472 7920 7461 7267 6574 3b0a  e_entry target;.
    │ │ │ +00067500: 0909 7461 7267 6574 2e6f 6666 7365 7420  ..target.offset 
    │ │ │ +00067510: 3d20 6175 783a 3a6e 756d 6572 6963 5f63  = aux::numeric_c
    │ │ │ +00067520: 6173 7426 6c74 3b73 7464 3a3a 7569 6e74  ast<std::uint
    │ │ │ +00067530: 3634 5f74 2667 743b 286f 6666 7365 7429  64_t>(offset)
    │ │ │ +00067540: 3b0a 0909 544f 5252 454e 545f 4153 5345  ;...TORRENT_ASSE
    │ │ │ +00067550: 5254 2821 636f 6d70 6172 655f 6669 6c65  RT(!compare_file
    │ │ │ +00067560: 5f6f 6666 7365 7428 7461 7267 6574 2c20  _offset(target, 
    │ │ │ +00067570: 6d5f 6669 6c65 732e 6672 6f6e 7428 2929  m_files.front())
    │ │ │ +00067580: 293b 0a0a 0909 6175 746f 2066 696c 655f  );....auto file_
    │ │ │ +00067590: 6974 6572 203d 2073 7464 3a3a 7570 7065  iter = std::uppe
    │ │ │ +000675a0: 725f 626f 756e 6428 0a09 0909 6d5f 6669  r_bound(....m_fi
    │ │ │ +000675b0: 6c65 732e 6265 6769 6e28 292c 206d 5f66  les.begin(), m_f
    │ │ │ +000675c0: 696c 6573 2e65 6e64 2829 2c20 7461 7267  iles.end(), targ
    │ │ │ +000675d0: 6574 2c20 636f 6d70 6172 655f 6669 6c65  et, compare_file
    │ │ │ +000675e0: 5f6f 6666 7365 7429 3b0a 0a09 0954 4f52  _offset);....TOR
    │ │ │ +000675f0: 5245 4e54 5f41 5353 4552 5428 6669 6c65  RENT_ASSERT(file
    │ │ │ +00067600: 5f69 7465 7220 213d 206d 5f66 696c 6573  _iter != m_files
    │ │ │ +00067610: 2e62 6567 696e 2829 293b 0a09 092d 2d66  .begin());...--f
    │ │ │ +00067620: 696c 655f 6974 6572 3b0a 0909 7265 7475  ile_iter;...retu
    │ │ │ +00067630: 726e 2066 696c 655f 696e 6465 785f 747b  rn file_index_t{
    │ │ │ +00067640: 696e 7428 6669 6c65 5f69 7465 7220 2d20  int(file_iter - 
    │ │ │ +00067650: 6d5f 6669 6c65 732e 6265 6769 6e28 2929  m_files.begin())
    │ │ │ +00067660: 7d3b 0a09 7d0a 0a09 6669 6c65 5f69 6e64  };..}...file_ind
    │ │ │ +00067670: 6578 5f74 2066 696c 655f 7374 6f72 6167  ex_t file_storag
    │ │ │ +00067680: 653a 3a66 696c 655f 696e 6465 785f 6174  e::file_index_at
    │ │ │ +00067690: 5f70 6965 6365 2870 6965 6365 5f69 6e64  _piece(piece_ind
    │ │ │ +000676a0: 6578 5f74 2063 6f6e 7374 2070 6965 6365  ex_t const piece
    │ │ │ +000676b0: 2920 636f 6e73 740a 097b 0a09 0972 6574  ) const..{...ret
    │ │ │ +000676c0: 7572 6e20 6669 6c65 5f69 6e64 6578 5f61  urn file_index_a
    │ │ │ +000676d0: 745f 6f66 6673 6574 2873 7461 7469 635f  t_offset(static_
    │ │ │ +000676e0: 6361 7374 266c 743b 696e 7426 6774 3b28  cast<int>(
    │ │ │ +000676f0: 7069 6563 6529 202a 2073 7464 3a3a 696e  piece) * std::in
    │ │ │ +00067700: 7436 345f 7428 7069 6563 655f 6c65 6e67  t64_t(piece_leng
    │ │ │ +00067710: 7468 2829 2929 3b0a 097d 0a0a 0966 696c  th()));..}...fil
    │ │ │ +00067720: 655f 696e 6465 785f 7420 6669 6c65 5f73  e_index_t file_s
    │ │ │ +00067730: 746f 7261 6765 3a3a 6669 6c65 5f69 6e64  torage::file_ind
    │ │ │ +00067740: 6578 5f66 6f72 5f72 6f6f 7428 7368 6132  ex_for_root(sha2
    │ │ │ +00067750: 3536 5f68 6173 6820 636f 6e73 7426 616d  56_hash const&am
    │ │ │ +00067760: 703b 2072 6f6f 745f 6861 7368 2920 636f  p; root_hash) co
    │ │ │ +00067770: 6e73 740a 097b 0a3c 6469 7620 7374 796c  nst..{.
    ..for (file │ │ │ +000677b0: 5f69 6e64 6578 5f74 2063 6f6e 7374 2069 _index_t const i │ │ │ +000677c0: 203a 2066 696c 655f 7261 6e67 6528 2929 : file_range()) │ │ │ +000677d0: 0a3c 2f64 6976 3e09 097b 0a09 0909 6966 .
    ..{....if │ │ │ +000677e0: 2028 726f 6f74 2869 2920 3d3d 2072 6f6f (root(i) == roo │ │ │ +000677f0: 745f 6861 7368 2920 7265 7475 726e 2069 t_hash) return i │ │ │ +00067800: 3b0a 0909 7d0a 0909 7265 7475 726e 2066 ;...}...return f │ │ │ +00067810: 696c 655f 696e 6465 785f 747b 2d31 7d3b ile_index_t{-1}; │ │ │ +00067820: 0a09 7d0a 0a09 7069 6563 655f 696e 6465 ..}...piece_inde │ │ │ +00067830: 785f 7420 6669 6c65 5f73 746f 7261 6765 x_t file_storage │ │ │ +00067840: 3a3a 7069 6563 655f 696e 6465 785f 6174 ::piece_index_at │ │ │ +00067850: 5f66 696c 6528 6669 6c65 5f69 6e64 6578 _file(file_index │ │ │ +00067860: 5f74 2066 2920 636f 6e73 740a 097b 0a09 _t f) const..{.. │ │ │ +00067870: 0972 6574 7572 6e20 7069 6563 655f 696e .return piece_in │ │ │ +00067880: 6465 785f 747b 6175 783a 3a6e 756d 6572 dex_t{aux::numer │ │ │ +00067890: 6963 5f63 6173 7426 6c74 3b69 6e74 2667 ic_cast<int&g │ │ │ +000678a0: 743b 2866 696c 655f 6f66 6673 6574 2866 t;(file_offset(f │ │ │ +000678b0: 2920 2f20 7069 6563 655f 6c65 6e67 7468 ) / piece_length │ │ │ +000678c0: 2829 297d 3b0a 097d 0a0a 2369 6620 544f ())};..}..#if TO │ │ │ +000678d0: 5252 454e 545f 4142 495f 5645 5253 494f RRENT_ABI_VERSIO │ │ │ +000678e0: 4e20 266c 743b 3d20 320a 0963 6861 7220 N <= 2..char │ │ │ +000678f0: 636f 6e73 742a 2066 696c 655f 7374 6f72 const* file_stor │ │ │ +00067900: 6167 653a 3a66 696c 655f 6e61 6d65 5f70 age::file_name_p │ │ │ +00067910: 7472 2866 696c 655f 696e 6465 785f 7420 tr(file_index_t │ │ │ +00067920: 636f 6e73 7420 696e 6465 7829 2063 6f6e const index) con │ │ │ +00067930: 7374 0a09 7b0a 0909 7265 7475 726e 206d st..{...return m │ │ │ +00067940: 5f66 696c 6573 5b69 6e64 6578 5d2e 6e61 _files[index].na │ │ │ +00067950: 6d65 3b0a 097d 0a0a 0969 6e74 2066 696c me;..}...int fil │ │ │ +00067960: 655f 7374 6f72 6167 653a 3a66 696c 655f e_storage::file_ │ │ │ +00067970: 6e61 6d65 5f6c 656e 2866 696c 655f 696e name_len(file_in │ │ │ +00067980: 6465 785f 7420 636f 6e73 7420 696e 6465 dex_t const inde │ │ │ +00067990: 7829 2063 6f6e 7374 0a09 7b0a 0909 6966 x) const..{...if │ │ │ +000679a0: 2028 6d5f 6669 6c65 735b 696e 6465 785d (m_files[index] │ │ │ +000679b0: 2e6e 616d 655f 6c65 6e20 3d3d 2061 7578 .name_len == aux │ │ │ +000679c0: 3a3a 6669 6c65 5f65 6e74 7279 3a3a 6e61 ::file_entry::na │ │ │ +000679d0: 6d65 5f69 735f 6f77 6e65 6429 0a09 0909 me_is_owned).... │ │ │ +000679e0: 7265 7475 726e 202d 313b 0a09 0972 6574 return -1;...ret │ │ │ +000679f0: 7572 6e20 6d5f 6669 6c65 735b 696e 6465 urn m_files[inde │ │ │ +00067a00: 785d 2e6e 616d 655f 6c65 6e3b 0a09 7d0a x].name_len;..}. │ │ │ +00067a10: 2365 6e64 6966 0a0a 0973 7464 3a3a 7665 #endif...std::ve │ │ │ +00067a20: 6374 6f72 266c 743b 6669 6c65 5f73 6c69 ctor<file_sli │ │ │ +00067a30: 6365 2667 743b 2066 696c 655f 7374 6f72 ce> file_stor │ │ │ +00067a40: 6167 653a 3a6d 6170 5f62 6c6f 636b 2870 age::map_block(p │ │ │ +00067a50: 6965 6365 5f69 6e64 6578 5f74 2063 6f6e iece_index_t con │ │ │ +00067a60: 7374 2070 6965 6365 0a09 092c 2073 7464 st piece..., std │ │ │ +00067a70: 3a3a 696e 7436 345f 7420 636f 6e73 7420 ::int64_t const │ │ │ +00067a80: 6f66 6673 6574 2c20 7374 643a 3a69 6e74 offset, std::int │ │ │ +00067a90: 3634 5f74 2073 697a 6529 2063 6f6e 7374 64_t size) const │ │ │ +00067aa0: 0a09 7b0a 0909 544f 5252 454e 545f 4153 ..{...TORRENT_AS │ │ │ +00067ab0: 5345 5254 5f50 5245 434f 4e44 2870 6965 SERT_PRECOND(pie │ │ │ +00067ac0: 6365 2026 6774 3b3d 2070 6965 6365 5f69 ce >= piece_i │ │ │ +00067ad0: 6e64 6578 5f74 7b30 7d29 3b0a 0909 544f ndex_t{0});...TO │ │ │ +00067ae0: 5252 454e 545f 4153 5345 5254 5f50 5245 RRENT_ASSERT_PRE │ │ │ +00067af0: 434f 4e44 2870 6965 6365 2026 6c74 3b20 COND(piece < │ │ │ +00067b00: 656e 645f 7069 6563 6528 2929 3b0a 3c2f end_piece());.r │ │ │ +00067b40: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +00067b50: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +00067b80: 6669 6c65 5f73 746f 7261 6765 2e63 7070 file_storage.cpp │ │ │ +00067b90: 3a31 3234 333c 2f61 3e3c 2f74 643e 3c74 :1243this would be │ │ │ +00067bb0: 6d6f 7265 2065 6666 6963 6965 6e74 2069 more efficient i │ │ │ +00067bc0: 6620 6d5f 7061 7468 7320 7761 7320 736f f m_paths was so │ │ │ +00067bd0: 7274 6564 2066 6972 7374 2c20 7375 6368 rted first, such │ │ │ +00067be0: 2074 6861 7420 6120 6c6f 7765 7220 7061 that a lower pa │ │ │ +00067bf0: 7468 2069 6e64 6578 2061 6c77 6179 7320 th index always │ │ │ +00067c00: 6d65 616e 7420 736f 7274 6564 2d62 6566 meant sorted-bef │ │ │ +00067c10: 6f72 653c 2f74 643e 3c2f 7472 3e3c 7472 ore

    this would be m │ │ │ +00067c70: 6f72 6520 6566 6669 6369 656e 7420 6966 ore efficient if │ │ │ +00067c80: 206d 5f70 6174 6873 2077 6173 2073 6f72 m_paths was sor │ │ │ +00067c90: 7465 6420 6669 7273 742c 2073 7563 680a ted first, such. │ │ │ +00067ca0: 7468 6174 2061 206c 6f77 6572 2070 6174 that a lower pat │ │ │ +00067cb0: 6820 696e 6465 7820 616c 7761 7973 206d h index always m │ │ │ +00067cc0: 6561 6e74 2073 6f72 7465 642d 6265 666f eant sorted-befo │ │ │ +00067cd0: 7265 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 re

    ../sr │ │ │ +00067ce0: 632f 6669 6c65 5f73 746f 7261 6765 2e63 c/file_storage.c │ │ │ +00067cf0: 7070 3a31 3234 333c 2f68 343e 3c70 7265 pp:1243

    .}...void 
    │ │ │ +00067d40: 6669 6c65 5f73 746f 7261 6765 3a3a 6361  file_storage::ca
    │ │ │ +00067d50: 6e6f 6e69 6361 6c69 7a65 5f69 6d70 6c28  nonicalize_impl(
    │ │ │ +00067d60: 626f 6f6c 2063 6f6e 7374 2062 6163 6b77  bool const backw
    │ │ │ +00067d70: 6172 6473 5f63 6f6d 7061 7469 626c 6529  ards_compatible)
    │ │ │ +00067d80: 0a09 7b0a 0909 544f 5252 454e 545f 4153  ..{...TORRENT_AS
    │ │ │ +00067d90: 5345 5254 2870 6965 6365 5f6c 656e 6774  SERT(piece_lengt
    │ │ │ +00067da0: 6828 2920 2667 743b 3d20 3136 202a 2031  h() >= 16 * 1
    │ │ │ +00067db0: 3032 3429 3b0a 0a09 092f 2f20 7573 6520  024);....// use 
    │ │ │ +00067dc0: 7468 6973 2076 6563 746f 7220 746f 2074  this vector to t
    │ │ │ +00067dd0: 7261 636b 2074 6865 206e 6577 206f 7264  rack the new ord
    │ │ │ +00067de0: 6572 696e 6720 6f66 2066 696c 6573 0a09  ering of files..
    │ │ │ +00067df0: 092f 2f20 7468 6973 2061 6c6c 6f77 7320  .// this allows 
    │ │ │ +00067e00: 7468 6520 7573 6520 6f66 2053 544c 2061  the use of STL a
    │ │ │ +00067e10: 6c67 6f72 6974 686d 7320 6465 7370 6974  lgorithms despit
    │ │ │ +00067e20: 6520 7468 656d 0a09 092f 2f20 6e6f 7420  e them...// not 
    │ │ │ +00067e30: 7375 7070 6f72 7469 6e67 2061 2063 7573  supporting a cus
    │ │ │ +00067e40: 746f 6d20 7377 6170 2066 756e 6374 6f72  tom swap functor
    │ │ │ +00067e50: 0a09 0961 7578 3a3a 7665 6374 6f72 266c  ...aux::vector&l
    │ │ │ +00067e60: 743b 6669 6c65 5f69 6e64 6578 5f74 2c20  t;file_index_t, 
    │ │ │ +00067e70: 6669 6c65 5f69 6e64 6578 5f74 2667 743b  file_index_t>
    │ │ │ +00067e80: 206e 6577 5f6f 7264 6572 2865 6e64 5f66   new_order(end_f
    │ │ │ +00067e90: 696c 6528 2929 3b0a 0909 666f 7220 2861  ile());...for (a
    │ │ │ +00067ea0: 7574 6f20 6920 3a20 6669 6c65 5f72 616e  uto i : file_ran
    │ │ │ +00067eb0: 6765 2829 290a 0909 096e 6577 5f6f 7264  ge())....new_ord
    │ │ │ +00067ec0: 6572 5b69 5d20 3d20 693b 0a0a 0909 2f2f  er[i] = i;....//
    │ │ │ +00067ed0: 2072 656d 6f76 6520 616e 7920 6578 6973   remove any exis
    │ │ │ +00067ee0: 7469 6e67 2070 6164 2066 696c 6573 0a09  ting pad files..
    │ │ │ +00067ef0: 097b 0a09 0909 6175 746f 2070 6164 5f62  .{....auto pad_b
    │ │ │ +00067f00: 6567 696e 203d 2073 7464 3a3a 7061 7274  egin = std::part
    │ │ │ +00067f10: 6974 696f 6e28 6e65 775f 6f72 6465 722e  ition(new_order.
    │ │ │ +00067f20: 6265 6769 6e28 292c 206e 6577 5f6f 7264  begin(), new_ord
    │ │ │ +00067f30: 6572 2e65 6e64 2829 0a09 0909 092c 205b  er.end()....., [
    │ │ │ +00067f40: 7468 6973 5d28 6669 6c65 5f69 6e64 6578  this](file_index
    │ │ │ +00067f50: 5f74 2069 2920 7b20 7265 7475 726e 2021  _t i) { return !
    │ │ │ +00067f60: 6d5f 6669 6c65 735b 695d 2e70 6164 5f66  m_files[i].pad_f
    │ │ │ +00067f70: 696c 653b 207d 293b 0a09 0909 6e65 775f  ile; });....new_
    │ │ │ +00067f80: 6f72 6465 722e 6572 6173 6528 7061 645f  order.erase(pad_
    │ │ │ +00067f90: 6265 6769 6e2c 206e 6577 5f6f 7264 6572  begin, new_order
    │ │ │ +00067fa0: 2e65 6e64 2829 293b 0a09 097d 0a0a 3c64  .end());...}.....// sort fil
    │ │ │ +00067ff0: 6573 2062 7920 7061 7468 2f6e 616d 650a  es by path/name.
    │ │ │ +00068000: 0909 7374 643a 3a73 6f72 7428 6e65 775f  ..std::sort(new_
    │ │ │ +00068010: 6f72 6465 722e 6265 6769 6e28 292c 206e  order.begin(), n
    │ │ │ +00068020: 6577 5f6f 7264 6572 2e65 6e64 2829 0a09  ew_order.end()..
    │ │ │ +00068030: 0909 2c20 5b74 6869 735d 2866 696c 655f  .., [this](file_
    │ │ │ +00068040: 696e 6465 785f 7420 6c2c 2066 696c 655f  index_t l, file_
    │ │ │ +00068050: 696e 6465 785f 7420 7229 0a09 097b 0a09  index_t r)...{..
    │ │ │ +00068060: 0909 2f2f 2061 7373 756d 696e 6720 6d5f  ..// assuming m_
    │ │ │ +00068070: 7061 7468 7320 6172 6520 756e 6971 7565  paths are unique
    │ │ │ +00068080: 210a 0909 0961 7574 6f20 636f 6e73 7426  !....auto const&
    │ │ │ +00068090: 616d 703b 206c 6620 3d20 6d5f 6669 6c65  amp; lf = m_file
    │ │ │ +000680a0: 735b 6c5d 3b0a 0909 0961 7574 6f20 636f  s[l];....auto co
    │ │ │ +000680b0: 6e73 7426 616d 703b 2072 6620 3d20 6d5f  nst& rf = m_
    │ │ │ +000680c0: 6669 6c65 735b 725d 3b0a 0909 0969 6620  files[r];....if 
    │ │ │ +000680d0: 286c 662e 7061 7468 5f69 6e64 6578 2021  (lf.path_index !
    │ │ │ +000680e0: 3d20 7266 2e70 6174 685f 696e 6465 7829  = rf.path_index)
    │ │ │ +000680f0: 0a09 0909 7b0a 0909 0909 696e 7420 636f  ....{.....int co
    │ │ │ +00068100: 6e73 7420 7265 7420 3d20 7061 7468 5f63  nst ret = path_c
    │ │ │ +00068110: 6f6d 7061 7265 286d 5f70 6174 6873 5b6c  ompare(m_paths[l
    │ │ │ +00068120: 662e 7061 7468 5f69 6e64 6578 5d2c 206c  f.path_index], l
    │ │ │ +00068130: 662e 6669 6c65 6e61 6d65 2829 0a09 0909  f.filename()....
    │ │ │ +00068140: 0909 2c20 6d5f 7061 7468 735b 7266 2e70  .., m_paths[rf.p
    │ │ │ +00068150: 6174 685f 696e 6465 785d 2c20 7266 2e66  ath_index], rf.f
    │ │ │ +00068160: 696c 656e 616d 6528 2929 3b0a 0909 0909  ilename());.....
    │ │ │ +00068170: 6966 2028 7265 7420 213d 2030 2920 7265  if (ret != 0) re
    │ │ │ +00068180: 7475 726e 2072 6574 2026 6c74 3b20 303b  turn ret < 0;
    │ │ │ +00068190: 0a09 0909 7d0a 0909 0972 6574 7572 6e20  ....}....return 
    │ │ │ +000681a0: 6c66 2e66 696c 656e 616d 6528 2920 266c  lf.filename() &l
    │ │ │ +000681b0: 743b 2072 662e 6669 6c65 6e61 6d65 2829  t; rf.filename()
    │ │ │ +000681c0: 3b0a 0909 7d29 3b0a 0a09 0961 7578 3a3a  ;...});....aux::
    │ │ │ +000681d0: 7665 6374 6f72 266c 743b 6175 783a 3a66  vector<aux::f
    │ │ │ +000681e0: 696c 655f 656e 7472 792c 2066 696c 655f  ile_entry, file_
    │ │ │ +000681f0: 696e 6465 785f 7426 6774 3b20 6e65 775f  index_t> new_
    │ │ │ +00068200: 6669 6c65 733b 0a09 0961 7578 3a3a 7665  files;...aux::ve
    │ │ │ +00068210: 6374 6f72 266c 743b 6368 6172 2063 6f6e  ctor<char con
    │ │ │ +00068220: 7374 2a2c 2066 696c 655f 696e 6465 785f  st*, file_index_
    │ │ │ +00068230: 7426 6774 3b20 6e65 775f 6669 6c65 5f68  t> new_file_h
    │ │ │ +00068240: 6173 6865 733b 0a09 0961 7578 3a3a 7665  ashes;...aux::ve
    │ │ │ +00068250: 6374 6f72 266c 743b 7374 643a 3a74 696d  ctor<std::tim
    │ │ │ +00068260: 655f 742c 2066 696c 655f 696e 6465 785f  e_t, file_index_
    │ │ │ +00068270: 7426 6774 3b20 6e65 775f 6d74 696d 653b  t> new_mtime;
    │ │ │ +00068280: 0a0a 0909 2f2f 2072 6573 6572 7665 2065  ....// reserve e
    │ │ │ +00068290: 6e6f 7567 6820 7370 6163 6520 666f 7220  nough space for 
    │ │ │ +000682a0: 7468 6520 776f 7273 7420 6361 7365 2061  the worst case a
    │ │ │ +000682b0: 6674 6572 2070 6164 6469 6e67 0a09 096e  fter padding...n
    │ │ │ +000682c0: 6577 5f66 696c 6573 2e72 6573 6572 7665  ew_files.reserve
    │ │ │ +000682d0: 286e 6577 5f6f 7264 6572 2e73 697a 6528  (new_order.size(
    │ │ │ +000682e0: 2920 2a20 3220 2d20 3129 3b0a 0909 6966  ) * 2 - 1);...if
    │ │ │ +000682f0: 2028 216d 5f66 696c 655f 6861 7368 6573   (!m_file_hashes
    │ │ │ +00068300: 2e65 6d70 7479 2829 290a 0909 096e 6577  .empty())....new
    │ │ │ +00068310: 5f66 696c 655f 6861 7368 6573 2e72 6573  _file_hashes.res
    │ │ │ +00068320: 6572 7665 286e 6577 5f6f 7264 6572 2e73  erve(new_order.s
    │ │ │ +00068330: 697a 6528 2920 2a20 3220 2d20 3129 3b0a  ize() * 2 - 1);.
    │ │ │ +00068340: 0909 6966 2028 216d 5f6d 7469 6d65 2e65  ..if (!m_mtime.e
    │ │ │ +00068350: 6d70 7479 2829 290a 0909 096e 6577 5f6d  mpty())....new_m
    │ │ │ +00068360: 7469 6d65 2e72 6573 6572 7665 286e 6577  time.reserve(new
    │ │ │ +00068370: 5f6f 7264 6572 2e73 697a 6528 2920 2a20  _order.size() * 
    │ │ │ +00068380: 3220 2d20 3129 3b0a 0a09 092f 2f20 7265  2 - 1);....// re
    │ │ │ +00068390: 2d63 6f6d 7075 7465 206f 6666 7365 7473  -compute offsets
    │ │ │ +000683a0: 2061 6e64 2069 6e73 6572 7420 7061 6420   and insert pad 
    │ │ │ +000683b0: 6669 6c65 7320 6173 206e 6563 6573 7361  files as necessa
    │ │ │ +000683c0: 7279 0a09 0973 7464 3a3a 696e 7436 345f  ry...std::int64_
    │ │ │ +000683d0: 7420 6f66 6620 3d20 303b 0a0a 3c2f 7072  t off = 0;..rel
    │ │ │ +00068410: 6576 616e 6365 266e 6273 703b 303c 2f74  evance 0../src/se
    │ │ │ +00068450: 7373 696f 6e5f 6861 6e64 6c65 2e63 7070  ssion_handle.cpp
    │ │ │ +00068460: 3a35 3033 3c2f 613e 3c2f 7464 3e3c 7464  :503in C++14, use u
    │ │ │ +00068480: 6e69 7175 655f 7074 7220 616e 6420 6d6f  nique_ptr and mo
    │ │ │ +00068490: 7665 2069 7420 696e 746f 2074 6865 206c  ve it into the l
    │ │ │ +000684a0: 616d 6264 613c 2f74 643e 3c2f 7472 3e3c  ambda<
    │ │ │ +000684b0: 7472 2069 643d 2232 3339 2220 7374 796c  tr id="239" styl
    │ │ │ +000684c0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65  e="display: none
    │ │ │ +000684d0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c  ;" colspan="3"><
    │ │ │ +000684e0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c  td colspan="3"><
    │ │ │ +000684f0: 6832 3e69 6e20 432b 2b31 342c 2075 7365  h2>in C++14, use
    │ │ │ +00068500: 2075 6e69 7175 655f 7074 7220 616e 6420   unique_ptr and 
    │ │ │ +00068510: 6d6f 7665 2069 7420 696e 746f 2074 6865  move it into the
    │ │ │ +00068520: 206c 616d 6264 613c 2f68 323e 3c68 343e   lambda

    │ │ │ +00068530: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f68 ../src/session_h │ │ │ +00068540: 616e 646c 652e 6370 703a 3530 333c 2f68 andle.cpp:503
    #ifn
    │ │ │ +00068590: 6465 6620 424f 4f53 545f 4e4f 5f45 5843  def BOOST_NO_EXC
    │ │ │ +000685a0: 4550 5449 4f4e 530a 0909 6966 2028 7061  EPTIONS...if (pa
    │ │ │ +000685b0: 7261 6d73 2e73 6176 655f 7061 7468 2e65  rams.save_path.e
    │ │ │ +000685c0: 6d70 7479 2829 290a 0909 0961 7578 3a3a  mpty())....aux::
    │ │ │ +000685d0: 7468 726f 775f 6578 266c 743b 7379 7374  throw_ex<syst
    │ │ │ +000685e0: 656d 5f65 7272 6f72 2667 743b 2865 7272  em_error>(err
    │ │ │ +000685f0: 6f72 5f63 6f64 6528 6572 726f 7273 3a3a  or_code(errors::
    │ │ │ +00068600: 696e 7661 6c69 645f 7361 7665 5f70 6174  invalid_save_pat
    │ │ │ +00068610: 6829 293b 0a23 656c 7365 0a09 0954 4f52  h));.#else...TOR
    │ │ │ +00068620: 5245 4e54 5f41 5353 4552 545f 5052 4543  RENT_ASSERT_PREC
    │ │ │ +00068630: 4f4e 4428 2170 6172 616d 732e 7361 7665  OND(!params.save
    │ │ │ +00068640: 5f70 6174 682e 656d 7074 7928 2929 3b0a  _path.empty());.
    │ │ │ +00068650: 2365 6e64 6966 0a0a 2369 6620 544f 5252  #endif..#if TORR
    │ │ │ +00068660: 454e 545f 4142 495f 5645 5253 494f 4e20  ENT_ABI_VERSION 
    │ │ │ +00068670: 266c 743b 2033 0a09 0969 6620 2821 7061  < 3...if (!pa
    │ │ │ +00068680: 7261 6d73 2e69 6e66 6f5f 6861 7368 6573  rams.info_hashes
    │ │ │ +00068690: 2e68 6173 5f76 3128 2920 2661 6d70 3b26  .has_v1() &&
    │ │ │ +000686a0: 616d 703b 2021 7061 7261 6d73 2e69 6e66  amp; !params.inf
    │ │ │ +000686b0: 6f5f 6861 7368 6573 2e68 6173 5f76 3228  o_hashes.has_v2(
    │ │ │ +000686c0: 2920 2661 6d70 3b26 616d 703b 2021 7061  ) && !pa
    │ │ │ +000686d0: 7261 6d73 2e74 6929 0a09 0909 7061 7261  rams.ti)....para
    │ │ │ +000686e0: 6d73 2e69 6e66 6f5f 6861 7368 6573 2e76  ms.info_hashes.v
    │ │ │ +000686f0: 3120 3d20 7061 7261 6d73 2e69 6e66 6f5f  1 = params.info_
    │ │ │ +00068700: 6861 7368 3b0a 2365 6e64 6966 0a0a 0909  hash;.#endif....
    │ │ │ +00068710: 2f2f 2074 6865 2069 6e74 6572 6e61 6c20  // the internal 
    │ │ │ +00068720: 746f 7272 656e 7420 6f62 6a65 6374 206b  torrent object k
    │ │ │ +00068730: 6565 7073 2061 6e64 206d 7574 6174 6573  eeps and mutates
    │ │ │ +00068740: 2073 7461 7465 2069 6e20 7468 650a 0909   state in the...
    │ │ │ +00068750: 2f2f 2074 6f72 7265 6e74 5f69 6e66 6f20  // torrent_info 
    │ │ │ +00068760: 6f62 6a65 6374 2e20 5765 2063 616e 2774  object. We can't
    │ │ │ +00068770: 206c 6574 2074 6861 7420 6c65 616b 2062   let that leak b
    │ │ │ +00068780: 6163 6b20 746f 2074 6865 2063 6c69 656e  ack to the clien
    │ │ │ +00068790: 740a 0909 6966 2028 7061 7261 6d73 2e74  t...if (params.t
    │ │ │ +000687a0: 6929 0a09 0909 7061 7261 6d73 2e74 6920  i)....params.ti 
    │ │ │ +000687b0: 3d20 7374 643a 3a6d 616b 655f 7368 6172  = std::make_shar
    │ │ │ +000687c0: 6564 266c 743b 746f 7272 656e 745f 696e  ed<torrent_in
    │ │ │ +000687d0: 666f 2667 743b 282a 7061 7261 6d73 2e74  fo>(*params.t
    │ │ │ +000687e0: 6929 3b0a 0a09 092f 2f20 7765 2063 616e  i);....// we can
    │ │ │ +000687f0: 6e6f 7420 6361 7074 7572 6520 6120 756e  not capture a un
    │ │ │ +00068800: 6971 7565 5f70 7472 2069 6e74 6f20 6120  ique_ptr into a 
    │ │ │ +00068810: 6c61 6d62 6461 2069 6e20 632b 2b31 312c  lambda in c++11,
    │ │ │ +00068820: 2073 6f20 7765 2075 7365 2061 2072 6177   so we use a raw
    │ │ │ +00068830: 0a09 092f 2f20 706f 696e 7465 7220 666f  ...// pointer fo
    │ │ │ +00068840: 7220 6e6f 772e 2061 7379 6e63 5f63 616c  r now. async_cal
    │ │ │ +00068850: 6c20 7573 6573 2061 206c 616d 6264 6120  l uses a lambda 
    │ │ │ +00068860: 6578 7072 6573 7369 6f6e 2074 6f20 706f  expression to po
    │ │ │ +00068870: 7374 2074 6865 2063 616c 6c0a 0909 2f2f  st the call...//
    │ │ │ +00068880: 2074 6f20 7468 6520 6d61 696e 2074 6872   to the main thr
    │ │ │ +00068890: 6561 640a 3c64 6976 2073 7479 6c65 3d22  ead.
    ..auto* p = ne │ │ │ +000688d0: 7720 6164 645f 746f 7272 656e 745f 7061 w add_torrent_pa │ │ │ +000688e0: 7261 6d73 2873 7464 3a3a 6d6f 7665 2870 rams(std::move(p │ │ │ +000688f0: 6172 616d 7329 293b 0a3c 2f64 6976 3e09 arams));.
    . │ │ │ +00068900: 0961 7574 6f20 6775 6172 6420 3d20 6175 .auto guard = au │ │ │ +00068910: 783a 3a73 636f 7065 5f65 6e64 285b 705d x::scope_end([p] │ │ │ +00068920: 7b20 6465 6c65 7465 2070 3b20 7d29 3b0a { delete p; });. │ │ │ +00068930: 0909 702d 2667 743b 7361 7665 5f70 6174 ..p->save_pat │ │ │ +00068940: 6820 3d20 636f 6d70 6c65 7465 2870 2d26 h = complete(p-& │ │ │ +00068950: 6774 3b73 6176 655f 7061 7468 293b 0a0a gt;save_path);.. │ │ │ +00068960: 2369 6620 544f 5252 454e 545f 4142 495f #if TORRENT_ABI_ │ │ │ +00068970: 5645 5253 494f 4e20 3d3d 2031 0a09 0968 VERSION == 1...h │ │ │ +00068980: 616e 646c 655f 6261 636b 7761 7264 735f andle_backwards_ │ │ │ +00068990: 636f 6d70 6174 6962 6c65 5f72 6573 756d compatible_resum │ │ │ +000689a0: 655f 6461 7461 282a 7029 3b0a 2365 6e64 e_data(*p);.#end │ │ │ +000689b0: 6966 0a0a 0909 6173 796e 635f 6361 6c6c if....async_call │ │ │ +000689c0: 2826 616d 703b 7365 7373 696f 6e5f 696d (&session_im │ │ │ +000689d0: 706c 3a3a 6173 796e 635f 6164 645f 746f pl::async_add_to │ │ │ +000689e0: 7272 656e 742c 2070 293b 0a09 0967 7561 rrent, p);...gua │ │ │ +000689f0: 7264 2e64 6973 6172 6d28 293b 0a09 7d0a rd.disarm();..}. │ │ │ +00068a00: 0a23 6966 6e64 6566 2042 4f4f 5354 5f4e .#ifndef BOOST_N │ │ │ +00068a10: 4f5f 4558 4345 5054 494f 4e53 0a23 6966 O_EXCEPTIONS.#if │ │ │ +00068a20: 2054 4f52 5245 4e54 5f41 4249 5f56 4552 TORRENT_ABI_VER │ │ │ +00068a30: 5349 4f4e 203d 3d20 310a 092f 2f20 6966 SION == 1..// if │ │ │ +00068a40: 2074 6865 2074 6f72 7265 6e74 2061 6c72 the torrent alr │ │ │ +00068a50: 6561 6479 2065 7869 7374 732c 2074 6869 eady exists, thi │ │ │ +00068a60: 7320 7769 6c6c 2074 6872 6f77 2064 7570 s will throw dup │ │ │ +00068a70: 6c69 6361 7465 5f74 6f72 7265 6e74 0a09 licate_torrent.. │ │ │ +00068a80: 746f 7272 656e 745f 6861 6e64 6c65 2073 torrent_handle s │ │ │ +00068a90: 6573 7369 6f6e 5f68 616e 646c 653a 3a61 ession_handle::a │ │ │ +00068aa0: 6464 5f74 6f72 7265 6e74 280a 0909 746f dd_torrent(...to │ │ │ +00068ab0: 7272 656e 745f 696e 666f 2063 6f6e 7374 rrent_info const │ │ │ +00068ac0: 2661 6d70 3b20 7469 0a09 092c 2073 7464 & ti..., std │ │ │ +00068ad0: 3a3a 7374 7269 6e67 2063 6f6e 7374 2661 ::string const&a │ │ │ +00068ae0: 6d70 3b20 7361 7665 5f70 6174 680a 0909 mp; save_path... │ │ │ +00068af0: 2c20 656e 7472 7920 636f 6e73 7426 616d , entry const&am │ │ │ +00068b00: 703b 2072 6573 756d 655f 6461 7461 0a09 p; resume_data.. │ │ │ +00068b10: 092c 2073 746f 7261 6765 5f6d 6f64 655f ., storage_mode_ │ │ │ +00068b20: 7420 7374 6f72 6167 655f 6d6f 6465 0a09 t storage_mode.. │ │ │ +00068b30: 092c 2062 6f6f 6c20 636f 6e73 7420 6164 ., bool const ad │ │ │ +00068b40: 645f 7061 7573 6564 290a 097b 0a09 0961 d_paused)..{...a │ │ │ +00068b50: 6464 5f74 6f72 7265 6e74 5f70 6172 616d dd_torrent_param │ │ │ +00068b60: 7320 703b 0a09 0970 2e74 6920 3d20 7374 s p;...p.ti = st │ │ │ +00068b70: 643a 3a6d 616b 655f 7368 6172 6564 266c d::make_shared&l │ │ │ +00068b80: 743b 746f 7272 656e 745f 696e 666f 2667 t;torrent_info&g │ │ │ +00068b90: 743b 2874 6929 3b0a 0909 702e 7361 7665 t;(ti);...p.save │ │ │ +00068ba0: 5f70 6174 6820 3d20 7361 7665 5f70 6174 _path = save_pat │ │ │ +00068bb0: 683b 0a09 0969 6620 2872 6573 756d 655f h;...if (resume_ │ │ │ +00068bc0: 6461 7461 2e74 7970 6528 2920 213d 2065 data.type() != e │ │ │ +00068bd0: 6e74 7279 3a3a 756e 6465 6669 6e65 645f ntry::undefined_ │ │ │ +00068be0: 7429 0a09 097b 0a09 0909 6265 6e63 6f64 t)...{....bencod │ │ │ +00068bf0: 6528 7374 643a 3a62 6163 6b5f 696e 7365 e(std::back_inse │ │ │ +00068c00: 7274 6572 2870 2e72 6573 756d 655f 6461 rter(p.resume_da │ │ │ +00068c10: 7461 292c 2072 6573 756d 655f 6461 7461 ta), resume_data │ │ │ +00068c20: 293b 0a09 097d 0a09 0970 2e73 746f 7261 );...}...p.stora │ │ │ +00068c30: 6765 5f6d 6f64 6520 3d20 7374 6f72 6167 ge_mode = storag │ │ │ +00068c40: 655f 6d6f 6465 3b0a 0909 6966 2028 6164 e_mode;...if (ad │ │ │ +00068c50: 645f 7061 7573 6564 2920 702e 666c 6167 d_paused) p.flag │ │ │ +00068c60: 7320 7c3d 2061 6464 5f74 6f72 7265 6e74 s |= add_torrent │ │ │ +00068c70: 5f70 6172 616d 733a 3a66 6c61 675f 7061 _params::flag_pa │ │ │ +00068c80: 7573 6564 3b0a 3c2f 7072 653e 3c2f 7464 used;.
    relevance │ │ │ 00068cc0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ 00068cd0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/kademlia │ │ │ -00068d00: 2f72 6f75 7469 6e67 5f74 6162 6c65 2e63 /routing_table.c │ │ │ -00068d10: 7070 3a32 3839 3c2f 613e 3c2f 7464 3e3c pp:289< │ │ │ -00068d20: 7464 3e54 6869 7320 6973 2074 656d 706f td>This is tempo │ │ │ -00068d30: 7261 7279 2e20 466f 7220 6e6f 772c 206f rary. For now, o │ │ │ -00068d40: 6e6c 7920 7265 706f 7274 2074 6865 206c nly report the l │ │ │ -00068d50: 6172 6765 7374 2072 6f75 7469 6e67 2074 argest routing t │ │ │ -00068d60: 6162 6c65 2028 6f66 2070 6f74 656e 7469 able (of potenti │ │ │ -00068d70: 616c 6c79 206d 756c 7469 706c 6520 6f6e ally multiple on │ │ │ -00068d80: 6573 2c20 666f 7220 6d75 6c74 692d 686f es, for multi-ho │ │ │ -00068d90: 6d65 6420 7379 7374 656d 7329 2069 6e20 med systems) in │ │ │ -00068da0: 6e65 7874 206d 616a 6f72 2076 6572 7369 next major versi │ │ │ -00068db0: 6f6e 2c20 6272 6561 6b20 7468 6520 4142 on, break the AB │ │ │ -00068dc0: 4920 616e 6420 7375 7070 6f72 7420 7265 I and support re │ │ │ -00068dd0: 706f 7274 696e 6720 616c 6c20 6f66 2074 porting all of t │ │ │ -00068de0: 6865 6d20 696e 2074 6865 2064 6874 5f73 hem in the dht_s │ │ │ -00068df0: 7461 7473 5f61 6c65 7274 3c2f 7464 3e3c tats_alert< │ │ │ -00068e00: 2f74 723e 3c74 7220 6964 3d22 3234 3022 /tr>

    This is │ │ │ -00068e50: 7465 6d70 6f72 6172 792e 2046 6f72 206e temporary. For n │ │ │ -00068e60: 6f77 2c20 6f6e 6c79 2072 6570 6f72 7420 ow, only report │ │ │ -00068e70: 7468 6520 6c61 7267 6573 7420 726f 7574 the largest rout │ │ │ -00068e80: 696e 6720 7461 626c 650a 286f 6620 706f ing table.(of po │ │ │ -00068e90: 7465 6e74 6961 6c6c 7920 6d75 6c74 6970 tentially multip │ │ │ -00068ea0: 6c65 206f 6e65 732c 2066 6f72 206d 756c le ones, for mul │ │ │ -00068eb0: 7469 2d68 6f6d 6564 2073 7973 7465 6d73 ti-homed systems │ │ │ -00068ec0: 290a 696e 206e 6578 7420 6d61 6a6f 7220 ).in next major │ │ │ -00068ed0: 7665 7273 696f 6e2c 2062 7265 616b 2074 version, break t │ │ │ -00068ee0: 6865 2041 4249 2061 6e64 2073 7570 706f he ABI and suppo │ │ │ -00068ef0: 7274 2072 6570 6f72 7469 6e67 2061 6c6c rt reporting all │ │ │ -00068f00: 206f 6620 7468 656d 2069 6e0a 7468 6520 of them in.the │ │ │ -00068f10: 6468 745f 7374 6174 735f 616c 6572 743c dht_stats_alert< │ │ │ -00068f20: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f6b /h2>

    ../src/k │ │ │ -00068f30: 6164 656d 6c69 612f 726f 7574 696e 675f ademlia/routing_ │ │ │ -00068f40: 7461 626c 652e 6370 703a 3238 393c 2f68 table.cpp:289
    ., m
    │ │ │ -00068f90: 5f62 7563 6b65 745f 7369 7a65 2862 7563  _bucket_size(buc
    │ │ │ -00068fa0: 6b65 745f 7369 7a65 290a 7b0a 092f 2f20  ket_size).{..// 
    │ │ │ -00068fb0: 6275 636b 6574 2073 697a 6573 206d 7573  bucket sizes mus
    │ │ │ -00068fc0: 7420 6265 2061 2070 6f77 6572 206f 6620  t be a power of 
    │ │ │ -00068fd0: 320a 0954 4f52 5245 4e54 5f41 5353 4552  2..TORRENT_ASSER
    │ │ │ -00068fe0: 545f 5641 4c28 2828 6275 636b 6574 5f73  T_VAL(((bucket_s
    │ │ │ -00068ff0: 697a 6520 2d20 3129 2026 616d 703b 2062  ize - 1) & b
    │ │ │ -00069000: 7563 6b65 745f 7369 7a65 2920 3d3d 2030  ucket_size) == 0
    │ │ │ -00069010: 2c20 6275 636b 6574 5f73 697a 6529 3b0a  , bucket_size);.
    │ │ │ -00069020: 0954 4f52 5245 4e54 5f55 4e55 5345 4428  .TORRENT_UNUSED(
    │ │ │ -00069030: 6c6f 6729 3b0a 096d 5f62 7563 6b65 7473  log);..m_buckets
    │ │ │ -00069040: 2e72 6573 6572 7665 2833 3029 3b0a 7d0a  .reserve(30);.}.
    │ │ │ -00069050: 0a69 6e74 2072 6f75 7469 6e67 5f74 6162  .int routing_tab
    │ │ │ -00069060: 6c65 3a3a 6275 636b 6574 5f6c 696d 6974  le::bucket_limit
    │ │ │ -00069070: 2869 6e74 2062 7563 6b65 7429 2063 6f6e  (int bucket) con
    │ │ │ -00069080: 7374 0a7b 0a09 6966 2028 216d 5f73 6574  st.{..if (!m_set
    │ │ │ -00069090: 7469 6e67 732e 6765 745f 626f 6f6c 2873  tings.get_bool(s
    │ │ │ -000690a0: 6574 7469 6e67 735f 7061 636b 3a3a 6468  ettings_pack::dh
    │ │ │ -000690b0: 745f 6578 7465 6e64 6564 5f72 6f75 7469  t_extended_routi
    │ │ │ -000690c0: 6e67 5f74 6162 6c65 2929 2072 6574 7572  ng_table)) retur
    │ │ │ -000690d0: 6e20 6d5f 6275 636b 6574 5f73 697a 653b  n m_bucket_size;
    │ │ │ -000690e0: 0a0a 0973 7461 7469 6320 636f 6e73 7420  ...static const 
    │ │ │ -000690f0: 6175 783a 3a61 7272 6179 266c 743b 696e  aux::array<in
    │ │ │ -00069100: 742c 2034 2667 743b 2073 697a 655f 6578  t, 4> size_ex
    │ │ │ -00069110: 6365 7074 696f 6e73 7b7b 7b31 362c 2038  ceptions{{{16, 8
    │ │ │ -00069120: 2c20 342c 2032 7d7d 7d3b 0a09 6966 2028  , 4, 2}}};..if (
    │ │ │ -00069130: 6275 636b 6574 2026 6c74 3b20 7369 7a65  bucket < size
    │ │ │ -00069140: 5f65 7863 6570 7469 6f6e 732e 656e 645f  _exceptions.end_
    │ │ │ -00069150: 696e 6465 7828 2929 0a09 0972 6574 7572  index())...retur
    │ │ │ -00069160: 6e20 6d5f 6275 636b 6574 5f73 697a 6520  n m_bucket_size 
    │ │ │ -00069170: 2a20 7369 7a65 5f65 7863 6570 7469 6f6e  * size_exception
    │ │ │ -00069180: 735b 6275 636b 6574 5d3b 0a09 7265 7475  s[bucket];..retu
    │ │ │ -00069190: 726e 206d 5f62 7563 6b65 745f 7369 7a65  rn m_bucket_size
    │ │ │ -000691a0: 3b0a 7d0a 0a76 6f69 6420 726f 7574 696e  ;.}..void routin
    │ │ │ -000691b0: 675f 7461 626c 653a 3a73 7461 7475 7328  g_table::status(
    │ │ │ -000691c0: 7374 643a 3a76 6563 746f 7226 6c74 3b64  std::vector<d
    │ │ │ -000691d0: 6874 5f72 6f75 7469 6e67 5f62 7563 6b65  ht_routing_bucke
    │ │ │ -000691e0: 7426 6774 3b26 616d 703b 2073 2920 636f  t>& s) co
    │ │ │ -000691f0: 6e73 740a 7b0a 3c64 6976 2073 7479 6c65  nst.{.
    .if (s.size( │ │ │ -00069230: 2920 2667 743b 206d 5f62 7563 6b65 7473 ) > m_buckets │ │ │ -00069240: 2e73 697a 6528 2929 2072 6574 7572 6e3b .size()) return; │ │ │ -00069250: 0a3c 2f64 6976 3e09 732e 636c 6561 7228 .
    .s.clear( │ │ │ -00069260: 293b 0a09 666f 7220 2861 7574 6f20 636f );..for (auto co │ │ │ -00069270: 6e73 7426 616d 703b 2069 203a 206d 5f62 nst& i : m_b │ │ │ -00069280: 7563 6b65 7473 290a 097b 0a09 0964 6874 uckets)..{...dht │ │ │ -00069290: 5f72 6f75 7469 6e67 5f62 7563 6b65 7420 _routing_bucket │ │ │ -000692a0: 623b 0a09 0962 2e6e 756d 5f6e 6f64 6573 b;...b.num_nodes │ │ │ -000692b0: 203d 2069 6e74 2869 2e6c 6976 655f 6e6f = int(i.live_no │ │ │ -000692c0: 6465 732e 7369 7a65 2829 293b 0a09 0962 des.size());...b │ │ │ -000692d0: 2e6e 756d 5f72 6570 6c61 6365 6d65 6e74 .num_replacement │ │ │ -000692e0: 7320 3d20 696e 7428 692e 7265 706c 6163 s = int(i.replac │ │ │ -000692f0: 656d 656e 7473 2e73 697a 6528 2929 3b0a ements.size());. │ │ │ -00069300: 0909 732e 7075 7368 5f62 6163 6b28 6229 ..s.push_back(b) │ │ │ -00069310: 3b0a 097d 0a7d 0a0a 2369 6620 544f 5252 ;..}.}..#if TORR │ │ │ -00069320: 454e 545f 4142 495f 5645 5253 494f 4e20 ENT_ABI_VERSION │ │ │ -00069330: 3d3d 2031 0a3c 2f70 7265 3e3c 2f74 643e == 1.
    │ │ │ -00069340: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00069370: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00069380: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00069390: 7074 3a65 7870 616e 6428 3234 3129 223e pt:expand(241)"> │ │ │ -000693a0: 2e2e 2f73 7263 2f6b 6164 656d 6c69 612f ../src/kademlia/ │ │ │ -000693b0: 726f 7574 696e 675f 7461 626c 652e 6370 routing_table.cp │ │ │ -000693c0: 703a 3331 343c 2f61 3e3c 2f74 643e 3c74 p:314arvidn note wh │ │ │ -000693e0: 656e 2069 7427 7320 6163 726f 7373 2049 en it's across I │ │ │ -000693f0: 5076 3420 616e 6420 4950 7636 2c20 6164 Pv4 and IPv6, ad │ │ │ -00069400: 6469 6e67 2028 6468 745f 676c 6f62 616c ding (dht_global │ │ │ -00069410: 5f6e 6f64 6573 2920 776f 756c 6420 6d61 _nodes) would ma │ │ │ -00069420: 6b65 2073 656e 7365 2e20 696e 2074 6865 ke sense. in the │ │ │ -00069430: 2066 7574 7572 6520 7468 6f75 6768 2c20 future though, │ │ │ -00069440: 7768 6572 6520 7765 206d 6179 2068 6176 where we may hav │ │ │ -00069450: 6520 6f6e 6520 4448 5420 6e6f 6465 2070 e one DHT node p │ │ │ -00069460: 6572 2065 7874 6572 6e61 6c20 696e 7465 er external inte │ │ │ -00069470: 7266 6163 6520 2877 6869 6368 206d 6179 rface (which may │ │ │ -00069480: 2062 6520 6d75 6c74 6970 6c65 206f 6620 be multiple of │ │ │ -00069490: 7468 6520 7361 6d65 2061 6464 7265 7373 the same address │ │ │ -000694a0: 2066 616d 696c 7929 2c20 7468 656e 2069 family), then i │ │ │ -000694b0: 7420 6265 636f 6d65 7320 6120 6269 7420 t becomes a bit │ │ │ -000694c0: 7472 6963 6b69 6572 3c2f 7464 3e3c 2f74 trickier

    arvidn not │ │ │ -00069520: 650a 7768 656e 2069 7427 7320 6163 726f e.when it's acro │ │ │ -00069530: 7373 2049 5076 3420 616e 6420 4950 7636 ss IPv4 and IPv6 │ │ │ -00069540: 2c20 6164 6469 6e67 2028 6468 745f 676c , adding (dht_gl │ │ │ -00069550: 6f62 616c 5f6e 6f64 6573 2920 776f 756c obal_nodes) woul │ │ │ -00069560: 640a 6d61 6b65 2073 656e 7365 2e20 696e d.make sense. in │ │ │ -00069570: 2074 6865 2066 7574 7572 6520 7468 6f75 the future thou │ │ │ -00069580: 6768 2c20 7768 6572 6520 7765 206d 6179 gh, where we may │ │ │ -00069590: 2068 6176 6520 6f6e 6520 4448 5420 6e6f have one DHT no │ │ │ -000695a0: 6465 0a70 6572 2065 7874 6572 6e61 6c20 de.per external │ │ │ -000695b0: 696e 7465 7266 6163 6520 2877 6869 6368 interface (which │ │ │ -000695c0: 206d 6179 2062 6520 6d75 6c74 6970 6c65 may be multiple │ │ │ -000695d0: 206f 6620 7468 6520 7361 6d65 2061 6464 of the same add │ │ │ -000695e0: 7265 7373 0a66 616d 696c 7929 2c20 7468 ress.family), th │ │ │ -000695f0: 656e 2069 7420 6265 636f 6d65 7320 6120 en it becomes a │ │ │ -00069600: 6269 7420 7472 6963 6b69 6572 3c2f 6832 bit trickier

    ../src/kade │ │ │ -00069620: 6d6c 6961 2f72 6f75 7469 6e67 5f74 6162 mlia/routing_tab │ │ │ -00069630: 6c65 2e63 7070 3a33 3134 3c2f 6834 3e3c le.cpp:314

    < │ │ │ -00069640: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00069650: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00069660: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00069670: 7820 2364 6464 3b22 3e09 6966 2028 732e x #ddd;">.if (s. │ │ │ -00069680: 7369 7a65 2829 2026 6774 3b20 6d5f 6275 size() > m_bu │ │ │ -00069690: 636b 6574 732e 7369 7a65 2829 2920 7265 ckets.size()) re │ │ │ -000696a0: 7475 726e 3b0a 0973 2e63 6c65 6172 2829 turn;..s.clear() │ │ │ -000696b0: 3b0a 0966 6f72 2028 6175 746f 2063 6f6e ;..for (auto con │ │ │ -000696c0: 7374 2661 6d70 3b20 6920 3a20 6d5f 6275 st& i : m_bu │ │ │ -000696d0: 636b 6574 7329 0a09 7b0a 0909 6468 745f ckets)..{...dht_ │ │ │ -000696e0: 726f 7574 696e 675f 6275 636b 6574 2062 routing_bucket b │ │ │ -000696f0: 3b0a 0909 622e 6e75 6d5f 6e6f 6465 7320 ;...b.num_nodes │ │ │ -00069700: 3d20 696e 7428 692e 6c69 7665 5f6e 6f64 = int(i.live_nod │ │ │ -00069710: 6573 2e73 697a 6528 2929 3b0a 0909 622e es.size());...b. │ │ │ -00069720: 6e75 6d5f 7265 706c 6163 656d 656e 7473 num_replacements │ │ │ -00069730: 203d 2069 6e74 2869 2e72 6570 6c61 6365 = int(i.replace │ │ │ -00069740: 6d65 6e74 732e 7369 7a65 2829 293b 0a09 ments.size());.. │ │ │ -00069750: 0973 2e70 7573 685f 6261 636b 2862 293b .s.push_back(b); │ │ │ -00069760: 0a09 7d0a 7d0a 0a23 6966 2054 4f52 5245 ..}.}..#if TORRE │ │ │ -00069770: 4e54 5f41 4249 5f56 4552 5349 4f4e 203d NT_ABI_VERSION = │ │ │ -00069780: 3d20 310a 766f 6964 2072 6f75 7469 6e67 = 1.void routing │ │ │ -00069790: 5f74 6162 6c65 3a3a 7374 6174 7573 2873 _table::status(s │ │ │ -000697a0: 6573 7369 6f6e 5f73 7461 7475 7326 616d ession_status&am │ │ │ -000697b0: 703b 2073 2920 636f 6e73 740a 7b0a 0969 p; s) const.{..i │ │ │ -000697c0: 6e74 2064 6874 5f6e 6f64 6573 3b0a 0969 nt dht_nodes;..i │ │ │ -000697d0: 6e74 2064 6874 5f6e 6f64 655f 6361 6368 nt dht_node_cach │ │ │ -000697e0: 653b 0a09 696e 7420 6967 6e6f 7265 3b0a e;..int ignore;. │ │ │ -000697f0: 0973 7464 3a3a 7469 6528 6468 745f 6e6f .std::tie(dht_no │ │ │ -00069800: 6465 732c 2064 6874 5f6e 6f64 655f 6361 des, dht_node_ca │ │ │ -00069810: 6368 652c 2069 676e 6f72 6529 203d 2073 che, ignore) = s │ │ │ -00069820: 697a 6528 293b 0a09 732e 6468 745f 6e6f ize();..s.dht_no │ │ │ -00069830: 6465 7320 2b3d 2064 6874 5f6e 6f64 6573 des += dht_nodes │ │ │ -00069840: 3b0a 0973 2e64 6874 5f6e 6f64 655f 6361 ;..s.dht_node_ca │ │ │ -00069850: 6368 6520 2b3d 2064 6874 5f6e 6f64 655f che += dht_node_ │ │ │ -00069860: 6361 6368 653b 0a3c 6469 7620 7374 796c cache;.
    .s.dht_glob │ │ │ -000698a0: 616c 5f6e 6f64 6573 202b 3d20 6e75 6d5f al_nodes += num_ │ │ │ -000698b0: 676c 6f62 616c 5f6e 6f64 6573 2829 3b0a global_nodes();. │ │ │ -000698c0: 3c2f 6469 763e 0a09 666f 7220 2861 7574
    ..for (aut │ │ │ -000698d0: 6f20 636f 6e73 7426 616d 703b 2069 203a o const& i : │ │ │ -000698e0: 206d 5f62 7563 6b65 7473 290a 097b 0a09 m_buckets)..{.. │ │ │ -000698f0: 0964 6874 5f72 6f75 7469 6e67 5f62 7563 .dht_routing_buc │ │ │ -00069900: 6b65 7420 623b 0a09 0962 2e6e 756d 5f6e ket b;...b.num_n │ │ │ -00069910: 6f64 6573 203d 2069 6e74 2869 2e6c 6976 odes = int(i.liv │ │ │ -00069920: 655f 6e6f 6465 732e 7369 7a65 2829 293b e_nodes.size()); │ │ │ -00069930: 0a09 0962 2e6e 756d 5f72 6570 6c61 6365 ...b.num_replace │ │ │ -00069940: 6d65 6e74 7320 3d20 696e 7428 692e 7265 ments = int(i.re │ │ │ -00069950: 706c 6163 656d 656e 7473 2e73 697a 6528 placements.size( │ │ │ -00069960: 2929 3b0a 2369 6620 544f 5252 454e 545f ));.#if TORRENT_ │ │ │ -00069970: 4142 495f 5645 5253 494f 4e20 3d3d 2031 ABI_VERSION == 1 │ │ │ -00069980: 0a09 0962 2e6c 6173 745f 6163 7469 7665 ...b.last_active │ │ │ -00069990: 203d 2030 3b0a 2365 6e64 6966 0a09 0973 = 0;.#endif...s │ │ │ -000699a0: 2e64 6874 5f72 6f75 7469 6e67 5f74 6162 .dht_routing_tab │ │ │ -000699b0: 6c65 2e70 7573 685f 6261 636b 2862 293b le.push_back(b); │ │ │ -000699c0: 0a09 7d0a 7d0a 2365 6e64 6966 0a0a 7374 ..}.}.#endif..st │ │ │ -000699d0: 643a 3a74 7570 6c65 266c 743b 696e 742c d::tuple<int, │ │ │ -000699e0: 2069 6e74 2c20 696e 7426 6774 3b20 726f int, int> ro │ │ │ -000699f0: 7574 696e 675f 7461 626c 653a 3a73 697a uting_table::siz │ │ │ -00069a00: 6528 2920 636f 6e73 740a 7b0a 0969 6e74 e() const.{..int │ │ │ -00069a10: 206e 6f64 6573 203d 2030 3b0a 0969 6e74 nodes = 0;..int │ │ │ -00069a20: 2072 6570 6c61 6365 6d65 6e74 7320 3d20 replacements = │ │ │ -00069a30: 303b 0a09 696e 7420 636f 6e66 6972 6d65 0;..int confirme │ │ │ -00069a40: 6420 3d20 303b 0a09 666f 7220 2861 7574 d = 0;..for (aut │ │ │ -00069a50: 6f20 636f 6e73 7426 616d 703b 2069 203a o const& i : │ │ │ -00069a60: 206d 5f62 7563 6b65 7473 290a 097b 0a09 m_buckets)..{.. │ │ │ -00069a70: 096e 6f64 6573 202b 3d20 696e 7428 692e .nodes += int(i. │ │ │ -00069a80: 6c69 7665 5f6e 6f64 6573 2e73 697a 6528 live_nodes.size( │ │ │ -00069a90: 2929 3b0a 0909 636f 6e66 6972 6d65 6420 ));...confirmed │ │ │ -00069aa0: 2b3d 2073 7461 7469 635f 6361 7374 266c += static_cast&l │ │ │ -00069ab0: 743b 696e 7426 6774 3b28 7374 643a 3a63 t;int>(std::c │ │ │ -00069ac0: 6f75 6e74 5f69 6628 692e 6c69 7665 5f6e ount_if(i.live_n │ │ │ -00069ad0: 6f64 6573 2e62 6567 696e 2829 2c20 692e odes.begin(), i. │ │ │ -00069ae0: 6c69 7665 5f6e 6f64 6573 2e65 6e64 2829 live_nodes.end() │ │ │ -00069af0: 0a09 0909 2c20 5b5d 286e 6f64 655f 656e ...., [](node_en │ │ │ -00069b00: 7472 7920 636f 6e73 7426 616d 703b 206b try const& k │ │ │ -00069b10: 2920 7b20 7265 7475 726e 206b 2e63 6f6e ) { return k.con │ │ │ -00069b20: 6669 726d 6564 2829 3b20 7d20 2929 3b0a firmed(); } ));. │ │ │ -00069b30: 0a09 0972 6570 6c61 6365 6d65 6e74 7320 ...replacements │ │ │ -00069b40: 2b3d 2069 6e74 2869 2e72 6570 6c61 6365 += int(i.replace │ │ │ -00069b50: 6d65 6e74 732e 7369 7a65 2829 293b 0a09 ments.size());.. │ │ │ -00069b60: 7d0a 0972 6574 7572 6e20 7374 643a 3a6d }..return std::m │ │ │ -00069b70: 616b 655f 7475 706c 6528 6e6f 6465 732c ake_tuple(nodes, │ │ │ -00069b80: 2072 6570 6c61 6365 6d65 6e74 732c 2063 replacements, c │ │ │ -00069b90: 6f6e 6669 726d 6564 293b 0a7d 0a0a 3c2f onfirmed);.}..r │ │ │ -00069bd0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -00069be0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -00069c10: 6b61 6465 6d6c 6961 2f72 6f75 7469 6e67 kademlia/routing │ │ │ -00069c20: 5f74 6162 6c65 2e63 7070 3a35 3138 3c2f _table.cpp:518this │ │ │ -00069c40: 6e65 6564 2074 6f20 7461 6b65 2062 7563 need to take buc │ │ │ -00069c50: 6b65 7420 2270 7265 6669 7822 2069 6e74 ket "prefix" int │ │ │ -00069c60: 6f20 6163 636f 756e 742e 2049 7420 7368 o account. It sh │ │ │ -00069c70: 6f75 6c64 2062 6520 756e 6966 6965 6420 ould be unified │ │ │ -00069c80: 7769 7468 2061 6464 5f6e 6f64 655f 696d with add_node_im │ │ │ -00069c90: 706c 2829 3c2f 7464 3e3c 2f74 723e 3c74 pl()this need to t │ │ │ -00069cf0: 616b 6520 6275 636b 6574 2022 7072 6566 ake bucket "pref │ │ │ -00069d00: 6978 2220 696e 746f 2061 6363 6f75 6e74 ix" into account │ │ │ -00069d10: 2e20 4974 2073 686f 756c 6420 6265 2075 . It should be u │ │ │ -00069d20: 6e69 6669 6564 0a77 6974 6820 6164 645f nified.with add_ │ │ │ -00069d30: 6e6f 6465 5f69 6d70 6c28 293c 2f68 323e node_impl() │ │ │ -00069d40: 3c68 343e 2e2e 2f73 7263 2f6b 6164 656d

    ../src/kadem │ │ │ -00069d50: 6c69 612f 726f 7574 696e 675f 7461 626c lia/routing_tabl │ │ │ -00069d60: 652e 6370 703a 3531 383c 2f68 343e 3c70 e.cpp:518

    {..for ( │ │ │ -00069db0: 6175 746f 2069 203d 206d 5f62 7563 6b65 auto i = m_bucke │ │ │ -00069dc0: 7473 2e62 6567 696e 2829 202c 2065 6e64 ts.begin() , end │ │ │ -00069dd0: 286d 5f62 7563 6b65 7473 2e65 6e64 2829 (m_buckets.end() │ │ │ -00069de0: 293b 2069 2021 3d20 656e 643b 202b 2b69 ); i != end; ++i │ │ │ -00069df0: 290a 097b 0a09 0966 6f72 2028 6175 746f )..{...for (auto │ │ │ -00069e00: 206a 203d 2069 2d26 6774 3b72 6570 6c61 j = i->repla │ │ │ -00069e10: 6365 6d65 6e74 732e 6265 6769 6e28 293b cements.begin(); │ │ │ -00069e20: 206a 2021 3d20 692d 2667 743b 7265 706c j != i->repl │ │ │ -00069e30: 6163 656d 656e 7473 2e65 6e64 2829 3b20 acements.end(); │ │ │ -00069e40: 2b2b 6a29 0a09 097b 0a09 0909 6966 2028 ++j)...{....if ( │ │ │ -00069e50: 6a2d 2667 743b 6164 6472 2829 2021 3d20 j->addr() != │ │ │ -00069e60: 6570 2e61 6464 7265 7373 2829 2920 636f ep.address()) co │ │ │ -00069e70: 6e74 696e 7565 3b0a 0909 0969 6620 286a ntinue;....if (j │ │ │ -00069e80: 2d26 6774 3b70 6f72 7428 2920 213d 2065 ->port() != e │ │ │ -00069e90: 702e 706f 7274 2829 2920 636f 6e74 696e p.port()) contin │ │ │ -00069ea0: 7565 3b0a 0909 0972 6574 7572 6e20 7374 ue;....return st │ │ │ -00069eb0: 643a 3a6d 616b 655f 7475 706c 6528 2661 d::make_tuple(&a │ │ │ -00069ec0: 6d70 3b2a 6a2c 2069 2c20 2661 6d70 3b69 mp;*j, i, &i │ │ │ -00069ed0: 2d26 6774 3b72 6570 6c61 6365 6d65 6e74 ->replacement │ │ │ -00069ee0: 7329 3b0a 0909 7d0a 0909 666f 7220 2861 s);...}...for (a │ │ │ -00069ef0: 7574 6f20 6a20 3d20 692d 2667 743b 6c69 uto j = i->li │ │ │ -00069f00: 7665 5f6e 6f64 6573 2e62 6567 696e 2829 ve_nodes.begin() │ │ │ -00069f10: 3b20 6a20 213d 2069 2d26 6774 3b6c 6976 ; j != i->liv │ │ │ -00069f20: 655f 6e6f 6465 732e 656e 6428 293b 202b e_nodes.end(); + │ │ │ -00069f30: 2b6a 290a 0909 7b0a 0909 0969 6620 286a +j)...{....if (j │ │ │ -00069f40: 2d26 6774 3b61 6464 7228 2920 213d 2065 ->addr() != e │ │ │ -00069f50: 702e 6164 6472 6573 7328 2929 2063 6f6e p.address()) con │ │ │ -00069f60: 7469 6e75 653b 0a09 0909 6966 2028 6a2d tinue;....if (j- │ │ │ -00069f70: 2667 743b 706f 7274 2829 2021 3d20 6570 >port() != ep │ │ │ -00069f80: 2e70 6f72 7428 2929 2063 6f6e 7469 6e75 .port()) continu │ │ │ -00069f90: 653b 0a09 0909 7265 7475 726e 2073 7464 e;....return std │ │ │ -00069fa0: 3a3a 6d61 6b65 5f74 7570 6c65 2826 616d ::make_tuple(&am │ │ │ -00069fb0: 703b 2a6a 2c20 692c 2026 616d 703b 692d p;*j, i, &i- │ │ │ -00069fc0: 2667 743b 6c69 7665 5f6e 6f64 6573 293b >live_nodes); │ │ │ -00069fd0: 0a09 097d 0a09 7d0a 0972 6574 7572 6e20 ...}..}..return │ │ │ -00069fe0: 7374 643a 3a74 7570 6c65 266c 743b 6e6f std::tuple<no │ │ │ -00069ff0: 6465 5f65 6e74 7279 2a2c 2072 6f75 7469 de_entry*, routi │ │ │ -0006a000: 6e67 5f74 6162 6c65 3a3a 7461 626c 655f ng_table::table_ │ │ │ -0006a010: 743a 3a69 7465 7261 746f 722c 2062 7563 t::iterator, buc │ │ │ -0006a020: 6b65 745f 742a 2667 743b 0a09 7b6e 756c ket_t*>..{nul │ │ │ -0006a030: 6c70 7472 2c20 6d5f 6275 636b 6574 732e lptr, m_buckets. │ │ │ -0006a040: 656e 6428 292c 206e 756c 6c70 7472 7d3b end(), nullptr}; │ │ │ -0006a050: 0a7d 0a0a 3c64 6976 2073 7479 6c65 3d22 .}..

    void routing_t │ │ │ -0006a090: 6162 6c65 3a3a 6669 6c6c 5f66 726f 6d5f able::fill_from_ │ │ │ -0006a0a0: 7265 706c 6163 656d 656e 7473 2874 6162 replacements(tab │ │ │ -0006a0b0: 6c65 5f74 3a3a 6974 6572 6174 6f72 2062 le_t::iterator b │ │ │ -0006a0c0: 7563 6b65 7429 0a3c 2f64 6976 3e7b 0a09 ucket).
    {.. │ │ │ -0006a0d0: 6275 636b 6574 5f74 2661 6d70 3b20 6220 bucket_t& b │ │ │ -0006a0e0: 3d20 6275 636b 6574 2d26 6774 3b6c 6976 = bucket->liv │ │ │ -0006a0f0: 655f 6e6f 6465 733b 0a09 6275 636b 6574 e_nodes;..bucket │ │ │ -0006a100: 5f74 2661 6d70 3b20 7262 203d 2062 7563 _t& rb = buc │ │ │ -0006a110: 6b65 742d 2667 743b 7265 706c 6163 656d ket->replacem │ │ │ -0006a120: 656e 7473 3b0a 0969 6e74 2063 6f6e 7374 ents;..int const │ │ │ -0006a130: 2062 7563 6b65 745f 7369 7a65 203d 2062 bucket_size = b │ │ │ -0006a140: 7563 6b65 745f 6c69 6d69 7428 696e 7428 ucket_limit(int( │ │ │ -0006a150: 7374 643a 3a64 6973 7461 6e63 6528 6d5f std::distance(m_ │ │ │ -0006a160: 6275 636b 6574 732e 6265 6769 6e28 292c buckets.begin(), │ │ │ -0006a170: 2062 7563 6b65 7429 2929 3b0a 0a09 6966 bucket)));...if │ │ │ -0006a180: 2028 696e 7428 622e 7369 7a65 2829 2920 (int(b.size()) │ │ │ -0006a190: 2667 743b 3d20 6275 636b 6574 5f73 697a >= bucket_siz │ │ │ -0006a1a0: 6529 2072 6574 7572 6e3b 0a0a 092f 2f20 e) return;...// │ │ │ -0006a1b0: 736f 7274 2062 7920 5254 5420 6669 7273 sort by RTT firs │ │ │ -0006a1c0: 742c 2074 6f20 6669 6e64 2074 6865 206e t, to find the n │ │ │ -0006a1d0: 6f64 6520 7769 7468 2074 6865 206c 6f77 ode with the low │ │ │ -0006a1e0: 6573 740a 092f 2f20 5254 5420 7468 6174 est..// RTT that │ │ │ -0006a1f0: 2069 7320 7069 6e67 6564 0a09 7374 643a is pinged..std: │ │ │ -0006a200: 3a73 6f72 7428 7262 2e62 6567 696e 2829 :sort(rb.begin() │ │ │ -0006a210: 2c20 7262 2e65 6e64 2829 293b 0a0a 0977 , rb.end());...w │ │ │ -0006a220: 6869 6c65 2028 696e 7428 622e 7369 7a65 hile (int(b.size │ │ │ -0006a230: 2829 2920 266c 743b 2062 7563 6b65 745f ()) < bucket_ │ │ │ -0006a240: 7369 7a65 2026 616d 703b 2661 6d70 3b20 size && │ │ │ -0006a250: 2172 622e 656d 7074 7928 2929 0a09 7b0a !rb.empty())..{. │ │ │ -0006a260: 0909 6175 746f 206a 203d 2073 7464 3a3a ..auto j = std:: │ │ │ -0006a270: 6669 6e64 5f69 6628 7262 2e62 6567 696e find_if(rb.begin │ │ │ -0006a280: 2829 2c20 7262 2e65 6e64 2829 2c20 7374 (), rb.end(), st │ │ │ -0006a290: 643a 3a62 696e 6428 2661 6d70 3b6e 6f64 d::bind(&nod │ │ │ -0006a2a0: 655f 656e 7472 793a 3a70 696e 6765 642c e_entry::pinged, │ │ │ -0006a2b0: 205f 3129 293b 0a09 0969 6620 286a 203d _1));...if (j = │ │ │ -0006a2c0: 3d20 7262 2e65 6e64 2829 2920 6272 6561 = rb.end()) brea │ │ │ -0006a2d0: 6b3b 0a09 0962 2e70 7573 685f 6261 636b k;...b.push_back │ │ │ -0006a2e0: 282a 6a29 3b0a 0909 7262 2e65 7261 7365 (*j);...rb.erase │ │ │ -0006a2f0: 286a 293b 0a09 7d0a 7d0a 0a76 6f69 6420 (j);..}.}..void │ │ │ -0006a300: 726f 7574 696e 675f 7461 626c 653a 3a70 routing_table::p │ │ │ -0006a310: 7275 6e65 5f65 6d70 7479 5f62 7563 6b65 rune_empty_bucke │ │ │ -0006a320: 7428 290a 7b0a 0969 6620 286d 5f62 7563 t().{..if (m_buc │ │ │ -0006a330: 6b65 7473 2e62 6163 6b28 292e 6c69 7665 kets.back().live │ │ │ -0006a340: 5f6e 6f64 6573 2e65 6d70 7479 2829 0a09 _nodes.empty().. │ │ │ -0006a350: 0926 616d 703b 2661 6d70 3b20 6d5f 6275 .&& m_bu │ │ │ -0006a360: 636b 6574 732e 6261 636b 2829 2e72 6570 ckets.back().rep │ │ │ -0006a370: 6c61 6365 6d65 6e74 732e 656d 7074 7928 lacements.empty( │ │ │ -0006a380: 2929 0a09 7b0a 0909 6d5f 6275 636b 6574 ))..{...m_bucket │ │ │ -0006a390: 732e 6572 6173 6528 6d5f 6275 636b 6574 s.erase(m_bucket │ │ │ -0006a3a0: 732e 656e 6428 2920 2d20 3129 3b0a 097d s.end() - 1);..} │ │ │ -0006a3b0: 0a7d 0a0a 766f 6964 2072 6f75 7469 6e67 .}..void routing │ │ │ -0006a3c0: 5f74 6162 6c65 3a3a 7265 6d6f 7665 5f6e _table::remove_n │ │ │ -0006a3d0: 6f64 6528 6e6f 6465 5f65 6e74 7279 2a20 ode(node_entry* │ │ │ -0006a3e0: 6e2c 2062 7563 6b65 745f 742a 2062 290a n, bucket_t* b). │ │ │ -0006a3f0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0006a400: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0006a430: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -0006a460: 632f 6b61 6465 6d6c 6961 2f70 7574 5f64 c/kademlia/put_d │ │ │ -0006a470: 6174 612e 6370 703a 3932 3c2f 613e 3c2f ata.cpp:92what if o │ │ │ -0006a490: 2069 7320 6e6f 7420 616e 2069 6e73 7461 is not an insta │ │ │ -0006a4a0: 6e63 6520 6f66 2070 7574 5f64 6174 615f nce of put_data_ │ │ │ -0006a4b0: 6f62 7365 7276 6572 3f20 5468 6973 206e observer? This n │ │ │ -0006a4c0: 6565 6420 746f 2062 6520 7265 6465 7369 eed to be redesi │ │ │ -0006a4d0: 676e 6564 2066 6f72 2062 6574 7465 7220 gned for better │ │ │ -0006a4e0: 7479 7065 2073 6166 6574 792e 3c2f 7464 type safety.

    what i │ │ │ -0006a540: 6620 6f20 6973 206e 6f74 2061 6e20 696e f o is not an in │ │ │ -0006a550: 7374 616e 6365 206f 6620 7075 745f 6461 stance of put_da │ │ │ -0006a560: 7461 5f6f 6273 6572 7665 723f 2054 6869 ta_observer? Thi │ │ │ -0006a570: 7320 6e65 6564 2074 6f20 6265 0a72 6564 s need to be.red │ │ │ -0006a580: 6573 6967 6e65 6420 666f 7220 6265 7474 esigned for bett │ │ │ -0006a590: 6572 2074 7970 6520 7361 6665 7479 2e3c er type safety.< │ │ │ -0006a5a0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f6b /h2>

    ../src/k │ │ │ -0006a5b0: 6164 656d 6c69 612f 7075 745f 6461 7461 ademlia/put_data │ │ │ -0006a5c0: 2e63 7070 3a39 323c 2f68 343e 3c70 7265 .cpp:92

    .}.}..void
    │ │ │ -0006a610: 2070 7574 5f64 6174 613a 3a64 6f6e 6528   put_data::done(
    │ │ │ -0006a620: 290a 7b0a 096d 5f64 6f6e 6520 3d20 7472  ).{..m_done = tr
    │ │ │ -0006a630: 7565 3b0a 0a23 6966 6e64 6566 2054 4f52  ue;..#ifndef TOR
    │ │ │ -0006a640: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47  RENT_DISABLE_LOG
    │ │ │ -0006a650: 4749 4e47 0a09 6765 745f 6e6f 6465 2829  GING..get_node()
    │ │ │ -0006a660: 2e6f 6273 6572 7665 7228 292d 2667 743b  .observer()->
    │ │ │ -0006a670: 6c6f 6728 6468 745f 6c6f 6767 6572 3a3a  log(dht_logger::
    │ │ │ -0006a680: 7472 6176 6572 7361 6c2c 2022 5b25 755d  traversal, "[%u]
    │ │ │ -0006a690: 2025 7320 444f 4e45 2c20 7265 7370 6f6e   %s DONE, respon
    │ │ │ -0006a6a0: 7365 2025 642c 2074 696d 656f 7574 2025  se %d, timeout %
    │ │ │ -0006a6b0: 6422 0a09 092c 2069 6428 292c 206e 616d  d"..., id(), nam
    │ │ │ -0006a6c0: 6528 292c 206e 756d 5f72 6573 706f 6e73  e(), num_respons
    │ │ │ -0006a6d0: 6573 2829 2c20 6e75 6d5f 7469 6d65 6f75  es(), num_timeou
    │ │ │ -0006a6e0: 7473 2829 293b 0a23 656e 6469 660a 0a09  ts());.#endif...
    │ │ │ -0006a6f0: 6d5f 7075 745f 6361 6c6c 6261 636b 286d  m_put_callback(m
    │ │ │ -0006a700: 5f64 6174 612c 206e 756d 5f72 6573 706f  _data, num_respo
    │ │ │ -0006a710: 6e73 6573 2829 293b 0a09 7472 6176 6572  nses());..traver
    │ │ │ -0006a720: 7361 6c5f 616c 676f 7269 7468 6d3a 3a64  sal_algorithm::d
    │ │ │ -0006a730: 6f6e 6528 293b 0a7d 0a0a 626f 6f6c 2070  one();.}..bool p
    │ │ │ -0006a740: 7574 5f64 6174 613a 3a69 6e76 6f6b 6528  ut_data::invoke(
    │ │ │ -0006a750: 6f62 7365 7276 6572 5f70 7472 206f 290a  observer_ptr o).
    │ │ │ -0006a760: 7b0a 0969 6620 286d 5f64 6f6e 6529 2072  {..if (m_done) r
    │ │ │ -0006a770: 6574 7572 6e20 6661 6c73 653b 0a0a 3c64  eturn false;...aut
    │ │ │ -0006a7b0: 6f2a 2070 6f20 3d20 7374 6174 6963 5f63  o* po = static_c
    │ │ │ -0006a7c0: 6173 7426 6c74 3b70 7574 5f64 6174 615f  ast<put_data_
    │ │ │ -0006a7d0: 6f62 7365 7276 6572 2a26 6774 3b28 6f2e  observer*>(o.
    │ │ │ -0006a7e0: 6765 7428 2929 3b0a 3c2f 6469 763e 0a09  get());...
    │ │ │ -0006a7f0: 656e 7472 7920 653b 0a09 655b 2279 225d  entry e;..e["y"]
    │ │ │ -0006a800: 203d 2022 7122 3b0a 0965 5b22 7122 5d20   = "q";..e["q"] 
    │ │ │ -0006a810: 3d20 2270 7574 223b 0a09 656e 7472 7926  = "put";..entry&
    │ │ │ -0006a820: 616d 703b 2061 203d 2065 5b22 6122 5d3b  amp; a = e["a"];
    │ │ │ -0006a830: 0a09 615b 2276 225d 203d 206d 5f64 6174  ..a["v"] = m_dat
    │ │ │ -0006a840: 612e 7661 6c75 6528 293b 0a09 615b 2274  a.value();..a["t
    │ │ │ -0006a850: 6f6b 656e 225d 203d 2070 6f2d 2667 743b  oken"] = po->
    │ │ │ -0006a860: 6d5f 746f 6b65 6e3b 0a09 6966 2028 6d5f  m_token;..if (m_
    │ │ │ -0006a870: 6461 7461 2e69 735f 6d75 7461 626c 6528  data.is_mutable(
    │ │ │ -0006a880: 2929 0a09 7b0a 0909 615b 226b 225d 203d  ))..{...a["k"] =
    │ │ │ -0006a890: 206d 5f64 6174 612e 706b 2829 2e62 7974   m_data.pk().byt
    │ │ │ -0006a8a0: 6573 3b0a 0909 615b 2273 6571 225d 203d  es;...a["seq"] =
    │ │ │ -0006a8b0: 206d 5f64 6174 612e 7365 7128 292e 7661   m_data.seq().va
    │ │ │ -0006a8c0: 6c75 653b 0a09 0961 5b22 7369 6722 5d20  lue;...a["sig"] 
    │ │ │ -0006a8d0: 3d20 6d5f 6461 7461 2e73 6967 2829 2e62  = m_data.sig().b
    │ │ │ -0006a8e0: 7974 6573 3b0a 0909 6966 2028 216d 5f64  ytes;...if (!m_d
    │ │ │ -0006a8f0: 6174 612e 7361 6c74 2829 2e65 6d70 7479  ata.salt().empty
    │ │ │ -0006a900: 2829 290a 0909 7b0a 0909 0961 5b22 7361  ())...{....a["sa
    │ │ │ -0006a910: 6c74 225d 203d 206d 5f64 6174 612e 7361  lt"] = m_data.sa
    │ │ │ -0006a920: 6c74 2829 3b0a 0909 7d0a 097d 0a0a 096d  lt();...}..}...m
    │ │ │ -0006a930: 5f6e 6f64 652e 7374 6174 735f 636f 756e  _node.stats_coun
    │ │ │ -0006a940: 7465 7273 2829 2e69 6e63 5f73 7461 7473  ters().inc_stats
    │ │ │ -0006a950: 5f63 6f75 6e74 6572 2863 6f75 6e74 6572  _counter(counter
    │ │ │ -0006a960: 733a 3a64 6874 5f70 7574 5f6f 7574 293b  s::dht_put_out);
    │ │ │ -0006a970: 0a0a 0972 6574 7572 6e20 6d5f 6e6f 6465  ...return m_node
    │ │ │ -0006a980: 2e6d 5f72 7063 2e69 6e76 6f6b 6528 652c  .m_rpc.invoke(e,
    │ │ │ -0006a990: 206f 2d26 6774 3b74 6172 6765 745f 6570   o->target_ep
    │ │ │ -0006a9a0: 2829 2c20 6f29 3b0a 7d0a 0a7d 207d 202f  (), o);.}..} } /
    │ │ │ -0006a9b0: 2f20 6e61 6d65 7370 6163 6520 6c69 6274  / namespace libt
    │ │ │ -0006a9c0: 6f72 7265 6e74 3a3a 6468 740a 3c2f 7072  orrent::dht.rel
    │ │ │ -0006aa00: 6576 616e 6365 266e 6273 703b 303c 2f74  evance 0../src/ka
    │ │ │ -0006aa40: 6465 6d6c 6961 2f6e 6f64 655f 6964 2e63  demlia/node_id.c
    │ │ │ -0006aa50: 7070 3a36 363c 2f61 3e3c 2f74 643e 3c74  pp:66it's a little 
    │ │ │ -0006aa70: 6269 7420 7765 6972 6420 746f 2072 6574  bit weird to ret
    │ │ │ -0006aa80: 7572 6e20 3135 3920 2d20 6c65 6164 696e  urn 159 - leadin
    │ │ │ -0006aa90: 6720 7a65 726f 6573 2e20 4974 2073 686f  g zeroes. It sho
    │ │ │ -0006aaa0: 756c 6420 7072 6f62 6162 6c79 2062 6520  uld probably be 
    │ │ │ -0006aab0: 3136 3020 2d20 6c65 6164 696e 6720 7a65  160 - leading ze
    │ │ │ -0006aac0: 726f 6573 2c20 6275 7420 616c 6c20 6f74  roes, but all ot
    │ │ │ -0006aad0: 6865 7220 636f 6465 2069 6e20 6865 7265  her code in here
    │ │ │ -0006aae0: 2069 7320 7475 6e65 6420 746f 2074 6869   is tuned to thi
    │ │ │ -0006aaf0: 7320 6578 7065 6374 6174 696f 6e20 6e6f  s expectation no
    │ │ │ -0006ab00: 772c 2061 6e64 2069 7420 646f 6573 6e27  w, and it doesn'
    │ │ │ -0006ab10: 7420 7265 616c 6c79 206d 6174 7465 7220  t really matter 
    │ │ │ -0006ab20: 286f 7468 6572 2074 6861 6e20 636f 6d70  (other than comp
    │ │ │ -0006ab30: 6c65 7869 7479 293c 2f74 643e 3c2f 7472  lexity)

    it's a litt │ │ │ -0006ab90: 6c65 2062 6974 2077 6569 7264 2074 6f20 le bit weird to │ │ │ -0006aba0: 7265 7475 726e 2031 3539 202d 206c 6561 return 159 - lea │ │ │ -0006abb0: 6469 6e67 207a 6572 6f65 732e 2049 7420 ding zeroes. It │ │ │ -0006abc0: 7368 6f75 6c64 0a70 726f 6261 626c 7920 should.probably │ │ │ -0006abd0: 6265 2031 3630 202d 206c 6561 6469 6e67 be 160 - leading │ │ │ -0006abe0: 207a 6572 6f65 732c 2062 7574 2061 6c6c zeroes, but all │ │ │ -0006abf0: 206f 7468 6572 2063 6f64 6520 696e 2068 other code in h │ │ │ -0006ac00: 6572 6520 6973 2074 756e 6564 2074 6f0a ere is tuned to. │ │ │ -0006ac10: 7468 6973 2065 7870 6563 7461 7469 6f6e this expectation │ │ │ -0006ac20: 206e 6f77 2c20 616e 6420 6974 2064 6f65 now, and it doe │ │ │ -0006ac30: 736e 2774 2072 6561 6c6c 7920 6d61 7474 sn't really matt │ │ │ -0006ac40: 6572 2028 6f74 6865 7220 7468 616e 2063 er (other than c │ │ │ -0006ac50: 6f6d 706c 6578 6974 7929 3c2f 6832 3e3c omplexity)

    < │ │ │ -0006ac60: 6834 3e2e 2e2f 7372 632f 6b61 6465 6d6c h4>../src/kademl │ │ │ -0006ac70: 6961 2f6e 6f64 655f 6964 2e63 7070 3a36 ia/node_id.cpp:6 │ │ │ -0006ac80: 363c 2f68 343e 3c70 7265 2073 7479 6c65 6
    │ │ │ -0006acc0: 0a2f 2f20 7265 7475 726e 7320 7468 6520  .// returns the 
    │ │ │ -0006acd0: 6469 7374 616e 6365 2062 6574 7765 656e  distance between
    │ │ │ -0006ace0: 2074 6865 2074 776f 206e 6f64 6573 0a2f   the two nodes./
    │ │ │ -0006acf0: 2f20 7573 696e 6720 7468 6520 6b61 6465  / using the kade
    │ │ │ -0006ad00: 6d6c 6961 2058 4f52 2d6d 6574 7269 630a  mlia XOR-metric.
    │ │ │ -0006ad10: 6e6f 6465 5f69 6420 6469 7374 616e 6365  node_id distance
    │ │ │ -0006ad20: 286e 6f64 655f 6964 2063 6f6e 7374 2661  (node_id const&a
    │ │ │ -0006ad30: 6d70 3b20 6e31 2c20 6e6f 6465 5f69 6420  mp; n1, node_id 
    │ │ │ -0006ad40: 636f 6e73 7426 616d 703b 206e 3229 0a7b  const& n2).{
    │ │ │ -0006ad50: 0a09 7265 7475 726e 206e 3120 5e20 6e32  ..return n1 ^ n2
    │ │ │ -0006ad60: 3b0a 7d0a 0a2f 2f20 7265 7475 726e 7320  ;.}..// returns 
    │ │ │ -0006ad70: 7472 7565 2069 663a 2064 6973 7461 6e63  true if: distanc
    │ │ │ -0006ad80: 6528 6e31 2c20 7265 6629 2026 6c74 3b20  e(n1, ref) < 
    │ │ │ -0006ad90: 6469 7374 616e 6365 286e 322c 2072 6566  distance(n2, ref
    │ │ │ -0006ada0: 290a 626f 6f6c 2063 6f6d 7061 7265 5f72  ).bool compare_r
    │ │ │ -0006adb0: 6566 286e 6f64 655f 6964 2063 6f6e 7374  ef(node_id const
    │ │ │ -0006adc0: 2661 6d70 3b20 6e31 2c20 6e6f 6465 5f69  & n1, node_i
    │ │ │ -0006add0: 6420 636f 6e73 7426 616d 703b 206e 322c  d const& n2,
    │ │ │ -0006ade0: 206e 6f64 655f 6964 2063 6f6e 7374 2661   node_id const&a
    │ │ │ -0006adf0: 6d70 3b20 7265 6629 0a7b 0a09 6e6f 6465  mp; ref).{..node
    │ │ │ -0006ae00: 5f69 6420 636f 6e73 7420 6c68 7320 3d20  _id const lhs = 
    │ │ │ -0006ae10: 6e31 205e 2072 6566 3b0a 096e 6f64 655f  n1 ^ ref;..node_
    │ │ │ -0006ae20: 6964 2063 6f6e 7374 2072 6873 203d 206e  id const rhs = n
    │ │ │ -0006ae30: 3220 5e20 7265 663b 0a09 7265 7475 726e  2 ^ ref;..return
    │ │ │ -0006ae40: 206c 6873 2026 6c74 3b20 7268 733b 0a7d   lhs < rhs;.}
    │ │ │ -0006ae50: 0a0a 2f2f 2072 6574 7572 6e73 206e 2069  ..// returns n i
    │ │ │ -0006ae60: 6e3a 2032 5e6e 2026 6c74 3b3d 2064 6973  n: 2^n <= dis
    │ │ │ -0006ae70: 7461 6e63 6528 6e31 2c20 6e32 2920 266c  tance(n1, n2) &l
    │ │ │ -0006ae80: 743b 2032 5e28 6e2b 3129 0a2f 2f20 7573  t; 2^(n+1).// us
    │ │ │ -0006ae90: 6566 756c 2066 6f72 2066 696e 6469 6e67  eful for finding
    │ │ │ -0006aea0: 206f 7574 2077 6869 6368 2062 7563 6b65   out which bucke
    │ │ │ -0006aeb0: 7420 6120 6e6f 6465 2062 656c 6f6e 6773  t a node belongs
    │ │ │ -0006aec0: 2074 6f0a 696e 7420 6469 7374 616e 6365   to.int distance
    │ │ │ -0006aed0: 5f65 7870 286e 6f64 655f 6964 2063 6f6e  _exp(node_id con
    │ │ │ -0006aee0: 7374 2661 6d70 3b20 6e31 2c20 6e6f 6465  st& n1, node
    │ │ │ -0006aef0: 5f69 6420 636f 6e73 7426 616d 703b 206e  _id const& n
    │ │ │ -0006af00: 3229 0a7b 0a3c 6469 7620 7374 796c 653d  2).{.
    .return std:: │ │ │ -0006af40: 6d61 7828 3135 3920 2d20 6469 7374 616e max(159 - distan │ │ │ -0006af50: 6365 286e 312c 206e 3229 2e63 6f75 6e74 ce(n1, n2).count │ │ │ -0006af60: 5f6c 6561 6469 6e67 5f7a 6572 6f65 7328 _leading_zeroes( │ │ │ -0006af70: 292c 2030 293b 0a3c 2f64 6976 3e7d 0a0a ), 0);.
    }.. │ │ │ -0006af80: 696e 7420 6d69 6e5f 6469 7374 616e 6365 int min_distance │ │ │ -0006af90: 5f65 7870 286e 6f64 655f 6964 2063 6f6e _exp(node_id con │ │ │ -0006afa0: 7374 2661 6d70 3b20 6e31 2c20 7374 643a st& n1, std: │ │ │ -0006afb0: 3a76 6563 746f 7226 6c74 3b6e 6f64 655f :vector<node_ │ │ │ -0006afc0: 6964 2667 743b 2063 6f6e 7374 2661 6d70 id> const& │ │ │ -0006afd0: 3b20 6964 7329 0a7b 0a09 544f 5252 454e ; ids).{..TORREN │ │ │ -0006afe0: 545f 4153 5345 5254 2869 6473 2e73 697a T_ASSERT(ids.siz │ │ │ -0006aff0: 6528 2920 2667 743b 2030 293b 0a0a 0969 e() > 0);...i │ │ │ -0006b000: 6e74 206d 696e 203d 2031 3630 3b20 2f2f nt min = 160; // │ │ │ -0006b010: 2073 6565 2064 6973 7461 6e63 655f 6578 see distance_ex │ │ │ -0006b020: 7020 666f 7220 7468 6520 7768 7920 6f66 p for the why of │ │ │ -0006b030: 2074 6869 7320 636f 6e73 7461 6e74 0a09 this constant.. │ │ │ -0006b040: 666f 7220 2861 7574 6f20 636f 6e73 7426 for (auto const& │ │ │ -0006b050: 616d 703b 206e 6f64 655f 6964 203a 2069 amp; node_id : i │ │ │ -0006b060: 6473 290a 097b 0a09 096d 696e 203d 2073 ds)..{...min = s │ │ │ -0006b070: 7464 3a3a 6d69 6e28 6d69 6e2c 2064 6973 td::min(min, dis │ │ │ -0006b080: 7461 6e63 655f 6578 7028 6e31 2c20 6e6f tance_exp(n1, no │ │ │ -0006b090: 6465 5f69 6429 293b 0a09 7d0a 0a09 7265 de_id));..}...re │ │ │ -0006b0a0: 7475 726e 206d 696e 3b0a 7d0a 0a6e 6f64 turn min;.}..nod │ │ │ -0006b0b0: 655f 6964 2067 656e 6572 6174 655f 6964 e_id generate_id │ │ │ -0006b0c0: 5f69 6d70 6c28 6164 6472 6573 7320 636f _impl(address co │ │ │ -0006b0d0: 6e73 7426 616d 703b 2069 705f 2c20 7374 nst& ip_, st │ │ │ -0006b0e0: 643a 3a75 696e 7433 325f 7420 7229 0a7b d::uint32_t r).{ │ │ │ -0006b0f0: 0a09 7374 643a 3a75 696e 7438 5f74 2a20 ..std::uint8_t* │ │ │ -0006b100: 6970 203d 206e 756c 6c70 7472 3b0a 0a09 ip = nullptr;... │ │ │ -0006b110: 7374 6174 6963 2073 7464 3a3a 7569 6e74 static std::uint │ │ │ -0006b120: 385f 7420 636f 6e73 7420 7634 6d61 736b 8_t const v4mask │ │ │ -0006b130: 5b5d 203d 207b 2030 7830 332c 2030 7830 [] = { 0x03, 0x0 │ │ │ -0006b140: 662c 2030 7833 662c 2030 7866 6620 7d3b f, 0x3f, 0xff }; │ │ │ -0006b150: 0a09 7374 6174 6963 2073 7464 3a3a 7569 ..static std::ui │ │ │ -0006b160: 6e74 385f 7420 636f 6e73 7420 7636 6d61 nt8_t const v6ma │ │ │ -0006b170: 736b 5b5d 203d 207b 2030 7830 312c 2030 sk[] = { 0x01, 0 │ │ │ -0006b180: 7830 332c 2030 7830 372c 2030 7830 662c x03, 0x07, 0x0f, │ │ │ -0006b190: 2030 7831 662c 2030 7833 662c 2030 7837 0x1f, 0x3f, 0x7 │ │ │ -0006b1a0: 662c 2030 7866 6620 7d3b 0a09 7374 643a f, 0xff };..std: │ │ │ -0006b1b0: 3a75 696e 7438 5f74 2063 6f6e 7374 2a20 :uint8_t const* │ │ │ -0006b1c0: 6d61 736b 203d 206e 756c 6c70 7472 3b0a mask = nullptr;. │ │ │ -0006b1d0: 0969 6e74 206e 756d 5f6f 6374 6574 7320 .int num_octets │ │ │ -0006b1e0: 3d20 303b 0a0a 0961 6464 7265 7373 5f76 = 0;...address_v │ │ │ -0006b1f0: 343a 3a62 7974 6573 5f74 7970 6520 6234 4::bytes_type b4 │ │ │ -0006b200: 7b7d 3b0a 0961 6464 7265 7373 5f76 363a {};..address_v6: │ │ │ -0006b210: 3a62 7974 6573 5f74 7970 6520 6236 7b7d :bytes_type b6{} │ │ │ -0006b220: 3b0a 0969 6620 2869 705f 2e69 735f 7636 ;..if (ip_.is_v6 │ │ │ -0006b230: 2829 290a 097b 0a09 0962 3620 3d20 6970 ())..{...b6 = ip │ │ │ -0006b240: 5f2e 746f 5f76 3628 292e 746f 5f62 7974 _.to_v6().to_byt │ │ │ -0006b250: 6573 2829 3b0a 0909 6970 203d 2062 362e es();...ip = b6. │ │ │ -0006b260: 6461 7461 2829 3b0a 3c2f 7072 653e 3c2f data();.
    relevan │ │ │ -0006b2a0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/kademl │ │ │ -0006b2e0: 6961 2f6e 6f64 652e 6370 703a 3131 3737 ia/node.cpp:1177 │ │ │ -0006b2f0: 3c2f 613e 3c2f 7464 3e3c 7464 3e6b 6565 kee │ │ │ -0006b300: 7020 7468 6520 7265 7475 726e 6564 2076 p the returned v │ │ │ -0006b310: 616c 7565 2074 6f20 7061 7373 2061 7320 alue to pass as │ │ │ -0006b320: 6120 6c69 6d69 7420 746f 2077 7269 7465 a limit to write │ │ │ -0006b330: 5f6e 6f64 6573 5f65 6e74 7269 6573 2077 _nodes_entries w │ │ │ -0006b340: 6865 6e20 696d 706c 656d 656e 7465 643c hen implemented< │ │ │ -0006b350: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    kee │ │ │ -0006b3a0: 7020 7468 6520 7265 7475 726e 6564 2076 p the returned v │ │ │ -0006b3b0: 616c 7565 2074 6f20 7061 7373 2061 7320 alue to pass as │ │ │ -0006b3c0: 6120 6c69 6d69 740a 746f 2077 7269 7465 a limit.to write │ │ │ -0006b3d0: 5f6e 6f64 6573 5f65 6e74 7269 6573 2077 _nodes_entries w │ │ │ -0006b3e0: 6865 6e20 696d 706c 656d 656e 7465 643c hen implemented< │ │ │ -0006b3f0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f6b /h2>

    ../src/k │ │ │ -0006b400: 6164 656d 6c69 612f 6e6f 6465 2e63 7070 ademlia/node.cpp │ │ │ -0006b410: 3a31 3137 373c 2f68 343e 3c70 7265 2073 :1177

    ..}..}..else
    │ │ │ -0006b460: 2069 6620 2871 7565 7279 203d 3d20 2273   if (query == "s
    │ │ │ -0006b470: 616d 706c 655f 696e 666f 6861 7368 6573  ample_infohashes
    │ │ │ -0006b480: 2229 0a09 7b0a 0909 7374 6174 6963 206b  ")..{...static k
    │ │ │ -0006b490: 6579 5f64 6573 635f 7420 636f 6e73 7420  ey_desc_t const 
    │ │ │ -0006b4a0: 6d73 675f 6465 7363 5b5d 203d 207b 0a09  msg_desc[] = {..
    │ │ │ -0006b4b0: 0909 7b22 7461 7267 6574 222c 2062 6465  ..{"target", bde
    │ │ │ -0006b4c0: 636f 6465 5f6e 6f64 653a 3a73 7472 696e  code_node::strin
    │ │ │ -0006b4d0: 675f 742c 2032 302c 2030 7d2c 0a09 0909  g_t, 20, 0},....
    │ │ │ -0006b4e0: 7b22 7761 6e74 222c 2062 6465 636f 6465  {"want", bdecode
    │ │ │ -0006b4f0: 5f6e 6f64 653a 3a6c 6973 745f 742c 2030  _node::list_t, 0
    │ │ │ -0006b500: 2c20 6b65 795f 6465 7363 5f74 3a3a 6f70  , key_desc_t::op
    │ │ │ -0006b510: 7469 6f6e 616c 7d2c 0a09 097d 3b0a 0a09  tional},...};...
    │ │ │ -0006b520: 0962 6465 636f 6465 5f6e 6f64 6520 6d73  .bdecode_node ms
    │ │ │ -0006b530: 675f 6b65 7973 5b32 5d3b 0a09 0969 6620  g_keys[2];...if 
    │ │ │ -0006b540: 2821 7665 7269 6679 5f6d 6573 7361 6765  (!verify_message
    │ │ │ -0006b550: 2861 7267 5f65 6e74 2c20 6d73 675f 6465  (arg_ent, msg_de
    │ │ │ -0006b560: 7363 2c20 6d73 675f 6b65 7973 2c20 6572  sc, msg_keys, er
    │ │ │ -0006b570: 726f 725f 7374 7269 6e67 2929 0a09 097b  ror_string))...{
    │ │ │ -0006b580: 0a09 0909 6d5f 636f 756e 7465 7273 2e69  ....m_counters.i
    │ │ │ -0006b590: 6e63 5f73 7461 7473 5f63 6f75 6e74 6572  nc_stats_counter
    │ │ │ -0006b5a0: 2863 6f75 6e74 6572 733a 3a64 6874 5f69  (counters::dht_i
    │ │ │ -0006b5b0: 6e76 616c 6964 5f73 616d 706c 655f 696e  nvalid_sample_in
    │ │ │ -0006b5c0: 666f 6861 7368 6573 293b 0a09 0909 696e  fohashes);....in
    │ │ │ -0006b5d0: 636f 6d69 6e67 5f65 7272 6f72 2865 2c20  coming_error(e, 
    │ │ │ -0006b5e0: 6572 726f 725f 7374 7269 6e67 293b 0a09  error_string);..
    │ │ │ -0006b5f0: 0909 7265 7475 726e 3b0a 0909 7d0a 0a09  ..return;...}...
    │ │ │ -0006b600: 096d 5f63 6f75 6e74 6572 732e 696e 635f  .m_counters.inc_
    │ │ │ -0006b610: 7374 6174 735f 636f 756e 7465 7228 636f  stats_counter(co
    │ │ │ -0006b620: 756e 7465 7273 3a3a 6468 745f 7361 6d70  unters::dht_samp
    │ │ │ -0006b630: 6c65 5f69 6e66 6f68 6173 6865 735f 696e  le_infohashes_in
    │ │ │ -0006b640: 293b 0a09 0973 6861 315f 6861 7368 2063  );...sha1_hash c
    │ │ │ -0006b650: 6f6e 7374 2074 6172 6765 7428 6d73 675f  onst target(msg_
    │ │ │ -0006b660: 6b65 7973 5b30 5d2e 7374 7269 6e67 5f70  keys[0].string_p
    │ │ │ -0006b670: 7472 2829 293b 0a0a 3c64 6976 2073 7479  tr());..
    ..m_storag │ │ │ -0006b6b0: 652e 6765 745f 696e 666f 6861 7368 6573 e.get_infohashes │ │ │ -0006b6c0: 5f73 616d 706c 6528 7265 706c 7929 3b0a _sample(reply);. │ │ │ -0006b6d0: 3c2f 6469 763e 0a09 0977 7269 7465 5f6e
    ...write_n │ │ │ -0006b6e0: 6f64 6573 5f65 6e74 7269 6573 2874 6172 odes_entries(tar │ │ │ -0006b6f0: 6765 742c 206d 7367 5f6b 6579 735b 315d get, msg_keys[1] │ │ │ -0006b700: 2c20 7265 706c 7929 3b0a 097d 0a09 656c , reply);..}..el │ │ │ -0006b710: 7365 0a09 7b0a 0909 2f2f 2069 6620 7765 se..{...// if we │ │ │ -0006b720: 2064 6f6e 2774 2072 6563 6f67 6e69 7a65 don't recognize │ │ │ -0006b730: 2074 6865 206d 6573 7361 6765 2062 7574 the message but │ │ │ -0006b740: 2074 6865 7265 2773 2061 0a09 092f 2f20 there's a...// │ │ │ -0006b750: 2774 6172 6765 7427 206f 7220 2769 6e66 'target' or 'inf │ │ │ -0006b760: 6f5f 6861 7368 2720 696e 2074 6865 2061 o_hash' in the a │ │ │ -0006b770: 7267 756d 656e 7473 2c20 7472 6561 7420 rguments, treat │ │ │ -0006b780: 6974 0a09 092f 2f20 6173 2066 696e 645f it...// as find_ │ │ │ -0006b790: 6e6f 6465 2074 6f20 6265 2066 7574 7572 node to be futur │ │ │ -0006b7a0: 6520 636f 6d70 6174 6962 6c65 0a09 0962 e compatible...b │ │ │ -0006b7b0: 6465 636f 6465 5f6e 6f64 6520 7461 7267 decode_node targ │ │ │ -0006b7c0: 6574 5f65 6e74 203d 2061 7267 5f65 6e74 et_ent = arg_ent │ │ │ -0006b7d0: 2e64 6963 745f 6669 6e64 5f73 7472 696e .dict_find_strin │ │ │ -0006b7e0: 6728 2274 6172 6765 7422 293b 0a09 0969 g("target");...i │ │ │ -0006b7f0: 6620 2821 7461 7267 6574 5f65 6e74 207c f (!target_ent | │ │ │ -0006b800: 7c20 7461 7267 6574 5f65 6e74 2e73 7472 | target_ent.str │ │ │ -0006b810: 696e 675f 6c65 6e67 7468 2829 2021 3d20 ing_length() != │ │ │ -0006b820: 3230 290a 0909 7b0a 0909 0974 6172 6765 20)...{....targe │ │ │ -0006b830: 745f 656e 7420 3d20 6172 675f 656e 742e t_ent = arg_ent. │ │ │ -0006b840: 6469 6374 5f66 696e 645f 7374 7269 6e67 dict_find_string │ │ │ -0006b850: 2822 696e 666f 5f68 6173 6822 293b 0a09 ("info_hash");.. │ │ │ -0006b860: 0909 6966 2028 2174 6172 6765 745f 656e ..if (!target_en │ │ │ -0006b870: 7420 7c7c 2074 6172 6765 745f 656e 742e t || target_ent. │ │ │ -0006b880: 7374 7269 6e67 5f6c 656e 6774 6828 2920 string_length() │ │ │ -0006b890: 213d 2032 3029 0a09 0909 7b0a 0909 0909 != 20)....{..... │ │ │ -0006b8a0: 696e 636f 6d69 6e67 5f65 7272 6f72 2865 incoming_error(e │ │ │ -0006b8b0: 2c20 2275 6e6b 6e6f 776e 206d 6573 7361 , "unknown messa │ │ │ -0006b8c0: 6765 2229 3b0a 0909 0909 7265 7475 726e ge");.....return │ │ │ -0006b8d0: 3b0a 0909 097d 0a09 097d 0a0a 0909 7368 ;....}...}....sh │ │ │ -0006b8e0: 6131 5f68 6173 6820 636f 6e73 7420 7461 a1_hash const ta │ │ │ -0006b8f0: 7267 6574 2874 6172 6765 745f 656e 742e rget(target_ent. │ │ │ -0006b900: 7374 7269 6e67 5f70 7472 2829 293b 0a09 string_ptr());.. │ │ │ -0006b910: 092f 2f20 616c 7761 7973 2072 6574 7572 .// always retur │ │ │ -0006b920: 6e20 6e6f 6465 7320 6173 2077 656c 6c20 n nodes as well │ │ │ -0006b930: 6173 2070 6565 7273 0a09 0977 7269 7465 as peers...write │ │ │ -0006b940: 5f6e 6f64 6573 5f65 6e74 7269 6573 2874 _nodes_entries(t │ │ │ -0006b950: 6172 6765 742c 2061 7267 5f65 6e74 2e64 arget, arg_ent.d │ │ │ -0006b960: 6963 745f 6669 6e64 5f6c 6973 7428 2277 ict_find_list("w │ │ │ -0006b970: 616e 7422 292c 2072 6570 6c79 293b 0a09 ant"), reply);.. │ │ │ -0006b980: 7d0a 7d0a 0a3c 2f70 7265 3e3c 2f74 643e }.}..
    │ │ │ -0006b990: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -0006b9c0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -0006b9d0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -0006b9e0: 7074 3a65 7870 616e 6428 3234 3629 223e pt:expand(246)"> │ │ │ -0006b9f0: 2e2e 2f73 7263 2f6b 6164 656d 6c69 612f ../src/kademlia/ │ │ │ -0006ba00: 6e6f 6465 2e63 7070 3a31 3230 353c 2f61 node.cpp:1205limit │ │ │ -0006ba20: 6e75 6d62 6572 206f 6620 656e 7472 6965 number of entrie │ │ │ -0006ba30: 7320 696e 2074 6865 2072 6573 756c 743c s in the result< │ │ │ -0006ba40: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    lim │ │ │ -0006ba90: 6974 206e 756d 6265 7220 6f66 2065 6e74 it number of ent │ │ │ -0006baa0: 7269 6573 2069 6e20 7468 6520 7265 7375 ries in the resu │ │ │ -0006bab0: 6c74 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 lt

    ../sr │ │ │ -0006bac0: 632f 6b61 6465 6d6c 6961 2f6e 6f64 652e c/kademlia/node. │ │ │ -0006bad0: 6370 703a 3132 3035 3c2f 6834 3e3c 7072 cpp:1205

    ..// if w │ │ │ -0006bb20: 6520 646f 6e27 7420 7265 636f 676e 697a e don't recogniz │ │ │ -0006bb30: 6520 7468 6520 6d65 7373 6167 6520 6275 e the message bu │ │ │ -0006bb40: 7420 7468 6572 6527 7320 610a 0909 2f2f t there's a...// │ │ │ -0006bb50: 2027 7461 7267 6574 2720 6f72 2027 696e 'target' or 'in │ │ │ -0006bb60: 666f 5f68 6173 6827 2069 6e20 7468 6520 fo_hash' in the │ │ │ -0006bb70: 6172 6775 6d65 6e74 732c 2074 7265 6174 arguments, treat │ │ │ -0006bb80: 2069 740a 0909 2f2f 2061 7320 6669 6e64 it...// as find │ │ │ -0006bb90: 5f6e 6f64 6520 746f 2062 6520 6675 7475 _node to be futu │ │ │ -0006bba0: 7265 2063 6f6d 7061 7469 626c 650a 0909 re compatible... │ │ │ -0006bbb0: 6264 6563 6f64 655f 6e6f 6465 2074 6172 bdecode_node tar │ │ │ -0006bbc0: 6765 745f 656e 7420 3d20 6172 675f 656e get_ent = arg_en │ │ │ -0006bbd0: 742e 6469 6374 5f66 696e 645f 7374 7269 t.dict_find_stri │ │ │ -0006bbe0: 6e67 2822 7461 7267 6574 2229 3b0a 0909 ng("target");... │ │ │ -0006bbf0: 6966 2028 2174 6172 6765 745f 656e 7420 if (!target_ent │ │ │ -0006bc00: 7c7c 2074 6172 6765 745f 656e 742e 7374 || target_ent.st │ │ │ -0006bc10: 7269 6e67 5f6c 656e 6774 6828 2920 213d ring_length() != │ │ │ -0006bc20: 2032 3029 0a09 097b 0a09 0909 7461 7267 20)...{....targ │ │ │ -0006bc30: 6574 5f65 6e74 203d 2061 7267 5f65 6e74 et_ent = arg_ent │ │ │ -0006bc40: 2e64 6963 745f 6669 6e64 5f73 7472 696e .dict_find_strin │ │ │ -0006bc50: 6728 2269 6e66 6f5f 6861 7368 2229 3b0a g("info_hash");. │ │ │ -0006bc60: 0909 0969 6620 2821 7461 7267 6574 5f65 ...if (!target_e │ │ │ -0006bc70: 6e74 207c 7c20 7461 7267 6574 5f65 6e74 nt || target_ent │ │ │ -0006bc80: 2e73 7472 696e 675f 6c65 6e67 7468 2829 .string_length() │ │ │ -0006bc90: 2021 3d20 3230 290a 0909 097b 0a09 0909 != 20)....{.... │ │ │ -0006bca0: 0969 6e63 6f6d 696e 675f 6572 726f 7228 .incoming_error( │ │ │ -0006bcb0: 652c 2022 756e 6b6e 6f77 6e20 6d65 7373 e, "unknown mess │ │ │ -0006bcc0: 6167 6522 293b 0a09 0909 0972 6574 7572 age");.....retur │ │ │ -0006bcd0: 6e3b 0a09 0909 7d0a 0909 7d0a 0a09 0973 n;....}...}....s │ │ │ -0006bce0: 6861 315f 6861 7368 2063 6f6e 7374 2074 ha1_hash const t │ │ │ -0006bcf0: 6172 6765 7428 7461 7267 6574 5f65 6e74 arget(target_ent │ │ │ -0006bd00: 2e73 7472 696e 675f 7074 7228 2929 3b0a .string_ptr());. │ │ │ -0006bd10: 0909 2f2f 2061 6c77 6179 7320 7265 7475 ..// always retu │ │ │ -0006bd20: 726e 206e 6f64 6573 2061 7320 7765 6c6c rn nodes as well │ │ │ -0006bd30: 2061 7320 7065 6572 730a 0909 7772 6974 as peers...writ │ │ │ -0006bd40: 655f 6e6f 6465 735f 656e 7472 6965 7328 e_nodes_entries( │ │ │ -0006bd50: 7461 7267 6574 2c20 6172 675f 656e 742e target, arg_ent. │ │ │ -0006bd60: 6469 6374 5f66 696e 645f 6c69 7374 2822 dict_find_list(" │ │ │ -0006bd70: 7761 6e74 2229 2c20 7265 706c 7929 3b0a want"), reply);. │ │ │ -0006bd80: 097d 0a7d 0a0a 3c64 6976 2073 7479 6c65 .}.}..
    void node::w │ │ │ -0006bdc0: 7269 7465 5f6e 6f64 6573 5f65 6e74 7269 rite_nodes_entri │ │ │ -0006bdd0: 6573 2873 6861 315f 6861 7368 2063 6f6e es(sha1_hash con │ │ │ -0006bde0: 7374 2661 6d70 3b20 696e 666f 5f68 6173 st& info_has │ │ │ -0006bdf0: 680a 3c2f 6469 763e 092c 2062 6465 636f h.
    ., bdeco │ │ │ -0006be00: 6465 5f6e 6f64 6520 636f 6e73 7426 616d de_node const&am │ │ │ -0006be10: 703b 2077 616e 742c 2065 6e74 7279 2661 p; want, entry&a │ │ │ -0006be20: 6d70 3b20 7229 0a7b 0a09 2f2f 2069 6620 mp; r).{..// if │ │ │ -0006be30: 6e6f 2077 616e 7473 2065 6e74 7279 2077 no wants entry w │ │ │ -0006be40: 6173 2073 7065 6369 6669 6564 2c20 696e as specified, in │ │ │ -0006be50: 636c 7564 6520 6120 6e6f 6465 730a 092f clude a nodes../ │ │ │ -0006be60: 2f20 656e 7472 7920 6261 7365 6420 6f6e / entry based on │ │ │ -0006be70: 2074 6865 2070 726f 746f 636f 6c20 7468 the protocol th │ │ │ -0006be80: 6520 7265 7175 6573 7420 6361 6d65 2069 e request came i │ │ │ -0006be90: 6e20 7769 7468 0a09 6966 2028 7761 6e74 n with..if (want │ │ │ -0006bea0: 2e74 7970 6528 2920 213d 2062 6465 636f .type() != bdeco │ │ │ -0006beb0: 6465 5f6e 6f64 653a 3a6c 6973 745f 7429 de_node::list_t) │ │ │ -0006bec0: 0a09 7b0a 0909 7374 643a 3a76 6563 746f ..{...std::vecto │ │ │ -0006bed0: 7226 6c74 3b6e 6f64 655f 656e 7472 7926 r<node_entry& │ │ │ -0006bee0: 6774 3b20 636f 6e73 7420 6e20 3d20 6d5f gt; const n = m_ │ │ │ -0006bef0: 7461 626c 652e 6669 6e64 5f6e 6f64 6528 table.find_node( │ │ │ -0006bf00: 696e 666f 5f68 6173 682c 207b 7d29 3b0a info_hash, {});. │ │ │ -0006bf10: 0909 725b 7072 6f74 6f63 6f6c 5f6e 6f64 ..r[protocol_nod │ │ │ -0006bf20: 6573 5f6b 6579 2829 5d20 3d20 7772 6974 es_key()] = writ │ │ │ -0006bf30: 655f 6e6f 6465 735f 656e 7472 7928 6e29 e_nodes_entry(n) │ │ │ -0006bf40: 3b0a 0909 7265 7475 726e 3b0a 097d 0a0a ;...return;..}.. │ │ │ -0006bf50: 092f 2f20 6966 2074 6865 7265 2069 7320 .// if there is │ │ │ -0006bf60: 6120 7761 6e74 7320 656e 7472 7920 7468 a wants entry th │ │ │ -0006bf70: 656e 2077 6520 6d61 7920 6e65 6564 2074 en we may need t │ │ │ -0006bf80: 6f20 7265 6163 6820 696e 746f 0a09 2f2f o reach into..// │ │ │ -0006bf90: 2061 6e6f 7468 6572 206e 6f64 6527 7320 another node's │ │ │ -0006bfa0: 726f 7574 696e 6720 7461 626c 6520 746f routing table to │ │ │ -0006bfb0: 2067 6574 206e 6f64 6573 206f 6620 7468 get nodes of th │ │ │ -0006bfc0: 6520 7265 7175 6573 7465 6420 7479 7065 e requested type │ │ │ -0006bfd0: 0a09 2f2f 2077 6520 7573 6520 6120 6d61 ..// we use a ma │ │ │ -0006bfe0: 7020 6d61 696e 7461 696e 6564 2062 7920 p maintained by │ │ │ -0006bff0: 7468 6520 6f77 6e69 6e67 2064 6874 5f74 the owning dht_t │ │ │ -0006c000: 7261 636b 6572 2074 6f20 6669 6e64 2074 racker to find t │ │ │ -0006c010: 6865 0a09 2f2f 206e 6f64 6520 6173 736f he..// node asso │ │ │ -0006c020: 6369 6174 6564 2077 6974 6820 6561 6368 ciated with each │ │ │ -0006c030: 2073 7472 696e 6720 696e 2074 6865 2077 string in the w │ │ │ -0006c040: 616e 7420 6c69 7374 2c20 7768 6963 6820 ant list, which │ │ │ -0006c050: 6d61 790a 092f 2f20 696e 636c 7564 6520 may..// include │ │ │ -0006c060: 7468 6973 206e 6f64 650a 0966 6f72 2028 this node..for ( │ │ │ -0006c070: 696e 7420 6920 3d20 303b 2069 2026 6c74 int i = 0; i < │ │ │ -0006c080: 3b20 7761 6e74 2e6c 6973 745f 7369 7a65 ; want.list_size │ │ │ -0006c090: 2829 3b20 2b2b 6929 0a09 7b0a 0909 6264 (); ++i)..{...bd │ │ │ -0006c0a0: 6563 6f64 655f 6e6f 6465 2077 616e 7465 ecode_node wante │ │ │ -0006c0b0: 6420 3d20 7761 6e74 2e6c 6973 745f 6174 d = want.list_at │ │ │ -0006c0c0: 2869 293b 0a09 0969 6620 2877 616e 7465 (i);...if (wante │ │ │ -0006c0d0: 642e 7479 7065 2829 2021 3d20 6264 6563 d.type() != bdec │ │ │ -0006c0e0: 6f64 655f 6e6f 6465 3a3a 7374 7269 6e67 ode_node::string │ │ │ -0006c0f0: 5f74 290a 0909 0963 6f6e 7469 6e75 653b _t)....continue; │ │ │ -0006c100: 0a09 096e 6f64 652a 2077 616e 7465 645f ...node* wanted_ │ │ │ -0006c110: 6e6f 6465 203d 206d 5f67 6574 5f66 6f72 node = m_get_for │ │ │ -0006c120: 6569 676e 5f6e 6f64 6528 696e 666f 5f68 eign_node(info_h │ │ │ -0006c130: 6173 682c 2077 616e 7465 642e 7374 7269 ash, wanted.stri │ │ │ -0006c140: 6e67 5f76 616c 7565 2829 2e74 6f5f 7374 ng_value().to_st │ │ │ -0006c150: 7269 6e67 2829 293b 0a09 0969 6620 2821 ring());...if (! │ │ │ -0006c160: 7761 6e74 6564 5f6e 6f64 6529 2063 6f6e wanted_node) con │ │ │ -0006c170: 7469 6e75 653b 0a09 0973 7464 3a3a 7665 tinue;...std::ve │ │ │ -0006c180: 6374 6f72 266c 743b 6e6f 6465 5f65 6e74 ctor<node_ent │ │ │ -0006c190: 7279 2667 743b 2063 6f6e 7374 206e 203d ry> const n = │ │ │ -0006c1a0: 2077 616e 7465 645f 6e6f 6465 2d26 6774 wanted_node-> │ │ │ -0006c1b0: 3b6d 5f74 6162 6c65 2e66 696e 645f 6e6f ;m_table.find_no │ │ │ -0006c1c0: 6465 2869 6e66 6f5f 6861 7368 2c20 7b7d de(info_hash, {} │ │ │ -0006c1d0: 293b 0a09 0972 5b77 616e 7465 645f 6e6f );...r[wanted_no │ │ │ -0006c1e0: 6465 2d26 6774 3b70 726f 746f 636f 6c5f de->protocol_ │ │ │ -0006c1f0: 6e6f 6465 735f 6b65 7928 295d 203d 2077 nodes_key()] = w │ │ │ -0006c200: 7269 7465 5f6e 6f64 6573 5f65 6e74 7279 rite_nodes_entry │ │ │ -0006c210: 286e 293b 0a09 7d0a 7d0a 0a6e 6f64 653a (n);..}.}..node: │ │ │ -0006c220: 3a70 726f 746f 636f 6c5f 6465 7363 7269 :protocol_descri │ │ │ -0006c230: 7074 6f72 2063 6f6e 7374 2661 6d70 3b20 ptor const& │ │ │ -0006c240: 6e6f 6465 3a3a 6d61 705f 7072 6f74 6f63 node::map_protoc │ │ │ -0006c250: 6f6c 5f74 6f5f 6465 7363 7269 7074 6f72 ol_to_descriptor │ │ │ -0006c260: 2875 6470 2063 6f6e 7374 2070 726f 746f (udp const proto │ │ │ -0006c270: 636f 6c29 0a7b 0a3c 2f70 7265 3e3c 2f74 col).{.
    relevanc │ │ │ -0006c2b0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/kademli │ │ │ -0006c2f0: 612f 6974 656d 2e63 7070 3a31 3433 3c2f a/item.cpp:143imple │ │ │ -0006c310: 6d65 6e74 2063 746f 7220 666f 7220 656e ment ctor for en │ │ │ -0006c320: 7472 7920 6672 6f6d 2062 6465 636f 6465 try from bdecode │ │ │ -0006c330: 5f6e 6f64 653f 3c2f 7464 3e3c 2f74 723e _node? │ │ │ -0006c340: 3c74 7220 6964 3d22 3234 3722 2073 7479 │ │ │ -0006c370: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0006c380: 3c68 323e 696d 706c 656d 656e 7420 6374

    implement ct │ │ │ -0006c390: 6f72 2066 6f72 2065 6e74 7279 2066 726f or for entry fro │ │ │ -0006c3a0: 6d20 6264 6563 6f64 655f 6e6f 6465 3f3c m bdecode_node?< │ │ │ -0006c3b0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f6b /h2>

    ../src/k │ │ │ -0006c3c0: 6164 656d 6c69 612f 6974 656d 2e63 7070 ademlia/item.cpp │ │ │ -0006c3d0: 3a31 3433 3c2f 6834 3e3c 7072 6520 7374 :143

    ., secret_key
    │ │ │ -0006c420: 2063 6f6e 7374 2661 6d70 3b20 736b 290a   const& sk).
    │ │ │ -0006c430: 7b0a 0963 6861 7220 7374 725b 3132 3030  {..char str[1200
    │ │ │ -0006c440: 5d3b 0a09 696e 7420 636f 6e73 7420 6c65  ];..int const le
    │ │ │ -0006c450: 6e20 3d20 6361 6e6f 6e69 6361 6c5f 7374  n = canonical_st
    │ │ │ -0006c460: 7269 6e67 2876 2c20 7365 712c 2073 616c  ring(v, seq, sal
    │ │ │ -0006c470: 742c 2073 7472 293b 0a0a 0972 6574 7572  t, str);...retur
    │ │ │ -0006c480: 6e20 6564 3235 3531 395f 7369 676e 287b  n ed25519_sign({
    │ │ │ -0006c490: 7374 722c 206c 656e 7d2c 2070 6b2c 2073  str, len}, pk, s
    │ │ │ -0006c4a0: 6b29 3b0a 7d0a 0a69 7465 6d3a 3a69 7465  k);.}..item::ite
    │ │ │ -0006c4b0: 6d28 7075 626c 6963 5f6b 6579 2063 6f6e  m(public_key con
    │ │ │ -0006c4c0: 7374 2661 6d70 3b20 706b 2c20 7370 616e  st& pk, span
    │ │ │ -0006c4d0: 266c 743b 6368 6172 2063 6f6e 7374 2667  <char const&g
    │ │ │ -0006c4e0: 743b 2073 616c 7429 0a09 3a20 6d5f 7361  t; salt)..: m_sa
    │ │ │ -0006c4f0: 6c74 2873 616c 742e 6461 7461 2829 2c20  lt(salt.data(), 
    │ │ │ -0006c500: 7374 6174 6963 5f63 6173 7426 6c74 3b73  static_cast<s
    │ │ │ -0006c510: 7464 3a3a 7369 7a65 5f74 2667 743b 2873  td::size_t>(s
    │ │ │ -0006c520: 616c 742e 7369 7a65 2829 2929 0a09 2c20  alt.size())).., 
    │ │ │ -0006c530: 6d5f 706b 2870 6b29 0a09 2c20 6d5f 6d75  m_pk(pk).., m_mu
    │ │ │ -0006c540: 7461 626c 6528 7472 7565 290a 7b7d 0a0a  table(true).{}..
    │ │ │ -0006c550: 6974 656d 3a3a 6974 656d 2865 6e74 7279  item::item(entry
    │ │ │ -0006c560: 2076 290a 093a 206d 5f76 616c 7565 2873   v)..: m_value(s
    │ │ │ -0006c570: 7464 3a3a 6d6f 7665 2876 2929 0a7b 7d0a  td::move(v)).{}.
    │ │ │ -0006c580: 0a69 7465 6d3a 3a69 7465 6d28 6264 6563  .item::item(bdec
    │ │ │ -0006c590: 6f64 655f 6e6f 6465 2063 6f6e 7374 2661  ode_node const&a
    │ │ │ -0006c5a0: 6d70 3b20 7629 0a7b 0a3c 6469 7620 7374  mp; v).{.
    .m_value │ │ │ -0006c5e0: 3d20 763b 0a3c 2f64 6976 3e7d 0a0a 6974 = v;.
    }..it │ │ │ -0006c5f0: 656d 3a3a 6974 656d 2865 6e74 7279 2076 em::item(entry v │ │ │ -0006c600: 2c20 7370 616e 266c 743b 6368 6172 2063 , span<char c │ │ │ -0006c610: 6f6e 7374 2667 743b 2073 616c 740a 092c onst> salt.., │ │ │ -0006c620: 2073 6571 7565 6e63 655f 6e75 6d62 6572 sequence_number │ │ │ -0006c630: 2063 6f6e 7374 2073 6571 2c20 7075 626c const seq, publ │ │ │ -0006c640: 6963 5f6b 6579 2063 6f6e 7374 2661 6d70 ic_key const& │ │ │ -0006c650: 3b20 706b 2c20 7365 6372 6574 5f6b 6579 ; pk, secret_key │ │ │ -0006c660: 2063 6f6e 7374 2661 6d70 3b20 736b 290a const& sk). │ │ │ -0006c670: 7b0a 0961 7373 6967 6e28 7374 643a 3a6d {..assign(std::m │ │ │ -0006c680: 6f76 6528 7629 2c20 7361 6c74 2c20 7365 ove(v), salt, se │ │ │ -0006c690: 712c 2070 6b2c 2073 6b29 3b0a 7d0a 0a76 q, pk, sk);.}..v │ │ │ -0006c6a0: 6f69 6420 6974 656d 3a3a 6173 7369 676e oid item::assign │ │ │ -0006c6b0: 2865 6e74 7279 2076 290a 7b0a 096d 5f6d (entry v).{..m_m │ │ │ -0006c6c0: 7574 6162 6c65 203d 2066 616c 7365 3b0a utable = false;. │ │ │ -0006c6d0: 096d 5f76 616c 7565 203d 2073 7464 3a3a .m_value = std:: │ │ │ -0006c6e0: 6d6f 7665 2876 293b 0a7d 0a0a 766f 6964 move(v);.}..void │ │ │ -0006c6f0: 2069 7465 6d3a 3a61 7373 6967 6e28 656e item::assign(en │ │ │ -0006c700: 7472 7920 762c 2073 7061 6e26 6c74 3b63 try v, span<c │ │ │ -0006c710: 6861 7220 636f 6e73 7426 6774 3b20 7361 har const> sa │ │ │ -0006c720: 6c74 0a09 2c20 7365 7175 656e 6365 5f6e lt.., sequence_n │ │ │ -0006c730: 756d 6265 7220 636f 6e73 7420 7365 712c umber const seq, │ │ │ -0006c740: 2070 7562 6c69 635f 6b65 7920 636f 6e73 public_key cons │ │ │ -0006c750: 7426 616d 703b 2070 6b2c 2073 6563 7265 t& pk, secre │ │ │ -0006c760: 745f 6b65 7920 636f 6e73 7426 616d 703b t_key const& │ │ │ -0006c770: 2073 6b29 0a7b 0a09 7374 643a 3a61 7272 sk).{..std::arr │ │ │ -0006c780: 6179 266c 743b 6368 6172 2c20 3130 3030 ay<char, 1000 │ │ │ -0006c790: 2667 743b 2062 7566 6665 723b 0a09 696e > buffer;..in │ │ │ -0006c7a0: 7420 636f 6e73 7420 6273 697a 6520 3d20 t const bsize = │ │ │ -0006c7b0: 6265 6e63 6f64 6528 6275 6666 6572 2e62 bencode(buffer.b │ │ │ -0006c7c0: 6567 696e 2829 2c20 7629 3b0a 0954 4f52 egin(), v);..TOR │ │ │ -0006c7d0: 5245 4e54 5f41 5353 4552 5428 6273 697a RENT_ASSERT(bsiz │ │ │ -0006c7e0: 6520 266c 743b 3d20 3130 3030 293b 0a09 e <= 1000);.. │ │ │ -0006c7f0: 6d5f 7369 6720 3d20 7369 676e 5f6d 7574 m_sig = sign_mut │ │ │ -0006c800: 6162 6c65 5f69 7465 6d28 7370 616e 266c able_item(span&l │ │ │ -0006c810: 743b 6368 6172 2063 6f6e 7374 2667 743b t;char const> │ │ │ -0006c820: 2862 7566 6665 7229 2e66 6972 7374 2862 (buffer).first(b │ │ │ -0006c830: 7369 7a65 290a 0909 2c20 7361 6c74 2c20 size)..., salt, │ │ │ -0006c840: 7365 712c 2070 6b2c 2073 6b29 3b0a 096d seq, pk, sk);..m │ │ │ -0006c850: 5f73 616c 742e 6173 7369 676e 2873 616c _salt.assign(sal │ │ │ -0006c860: 742e 6461 7461 2829 2c20 7374 6174 6963 t.data(), static │ │ │ -0006c870: 5f63 6173 7426 6c74 3b73 7464 3a3a 7369 _cast<std::si │ │ │ -0006c880: 7a65 5f74 2667 743b 2873 616c 742e 7369 ze_t>(salt.si │ │ │ -0006c890: 7a65 2829 2929 3b0a 096d 5f70 6b20 3d20 ze()));..m_pk = │ │ │ -0006c8a0: 706b 3b0a 096d 5f73 6571 203d 2073 6571 pk;..m_seq = seq │ │ │ -0006c8b0: 3b0a 096d 5f6d 7574 6162 6c65 203d 2074 ;..m_mutable = t │ │ │ -0006c8c0: 7275 653b 0a09 6d5f 7661 6c75 6520 3d20 rue;..m_value = │ │ │ -0006c8d0: 7374 643a 3a6d 6f76 6528 7629 3b0a 7d0a std::move(v);.}. │ │ │ -0006c8e0: 0a76 6f69 6420 6974 656d 3a3a 6173 7369 .void item::assi │ │ │ -0006c8f0: 676e 2862 6465 636f 6465 5f6e 6f64 6520 gn(bdecode_node │ │ │ -0006c900: 636f 6e73 7426 616d 703b 2076 290a 3c2f const& v).r │ │ │ -0006c940: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -0006c950: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>
    ../src/ │ │ │ -0006c980: 6b61 6465 6d6c 6961 2f64 6874 5f74 7261 kademlia/dht_tra │ │ │ -0006c990: 636b 6572 2e63 7070 3a33 3137 3c2f 613e cker.cpp:317 │ │ │ -0006c9a0: 3c2f 7464 3e3c 7464 3e70 6963 6b20 7468 pick th │ │ │ -0006c9b0: 6520 636c 6f73 6573 7420 6e6f 6465 2072 e closest node r │ │ │ -0006c9c0: 6174 6865 7220 7468 616e 2074 6865 2066 ather than the f │ │ │ -0006c9d0: 6972 7374 3c2f 7464 3e3c 2f74 723e 3c74 irstpick the close │ │ │ -0006ca30: 7374 206e 6f64 6520 7261 7468 6572 2074 st node rather t │ │ │ -0006ca40: 6861 6e20 7468 6520 6669 7273 743c 2f68 han the first

    ../src/kad │ │ │ -0006ca60: 656d 6c69 612f 6468 745f 7472 6163 6b65 emlia/dht_tracke │ │ │ -0006ca70: 722e 6370 703a 3331 373c 2f68 343e 3c70 r.cpp:317

    .#ifndef │ │ │ -0006cac0: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ -0006cad0: 5f4c 4f47 4749 4e47 0a09 096d 5f6c 6f67 _LOGGING...m_log │ │ │ -0006cae0: 2d26 6774 3b6c 6f67 2864 6874 5f6c 6f67 ->log(dht_log │ │ │ -0006caf0: 6765 723a 3a74 7261 636b 6572 2c20 222a ger::tracker, "* │ │ │ -0006cb00: 2a2a 206e 6577 2077 7269 7465 206b 6579 ** new write key │ │ │ -0006cb10: 2a2a 2a20 2564 206e 6f64 6573 220a 0909 *** %d nodes"... │ │ │ -0006cb20: 092c 2069 6e74 286d 5f6e 6f64 6573 2e73 ., int(m_nodes.s │ │ │ -0006cb30: 697a 6528 2929 293b 0a23 656e 6469 660a ize()));.#endif. │ │ │ -0006cb40: 097d 0a0a 0976 6f69 6420 6468 745f 7472 .}...void dht_tr │ │ │ -0006cb50: 6163 6b65 723a 3a75 7064 6174 655f 7374 acker::update_st │ │ │ -0006cb60: 6f72 6167 655f 6e6f 6465 5f69 6473 2829 orage_node_ids() │ │ │ -0006cb70: 0a09 7b0a 0909 7374 643a 3a76 6563 746f ..{...std::vecto │ │ │ -0006cb80: 7226 6c74 3b73 6861 315f 6861 7368 2667 r<sha1_hash&g │ │ │ -0006cb90: 743b 2069 6473 3b0a 0909 666f 7220 2861 t; ids;...for (a │ │ │ -0006cba0: 7574 6f26 616d 703b 206e 203a 206d 5f6e uto& n : m_n │ │ │ -0006cbb0: 6f64 6573 290a 0909 0969 6473 2e70 7573 odes)....ids.pus │ │ │ -0006cbc0: 685f 6261 636b 286e 2e73 6563 6f6e 642e h_back(n.second. │ │ │ -0006cbd0: 6468 742e 6e69 6428 2929 3b0a 0909 6d5f dht.nid());...m_ │ │ │ -0006cbe0: 7374 6f72 6167 652e 7570 6461 7465 5f6e storage.update_n │ │ │ -0006cbf0: 6f64 655f 6964 7328 6964 7329 3b0a 097d ode_ids(ids);..} │ │ │ -0006cc00: 0a0a 096e 6f64 652a 2064 6874 5f74 7261 ...node* dht_tra │ │ │ -0006cc10: 636b 6572 3a3a 6765 745f 6e6f 6465 286e cker::get_node(n │ │ │ -0006cc20: 6f64 655f 6964 2063 6f6e 7374 2661 6d70 ode_id const& │ │ │ -0006cc30: 3b20 6964 2c20 7374 643a 3a73 7472 696e ; id, std::strin │ │ │ -0006cc40: 6720 636f 6e73 7426 616d 703b 2066 616d g const& fam │ │ │ -0006cc50: 696c 795f 6e61 6d65 290a 097b 0a09 0954 ily_name)..{...T │ │ │ -0006cc60: 4f52 5245 4e54 5f55 4e55 5345 4428 6964 ORRENT_UNUSED(id │ │ │ -0006cc70: 293b 0a09 0966 6f72 2028 6175 746f 2661 );...for (auto&a │ │ │ -0006cc80: 6d70 3b20 6e20 3a20 6d5f 6e6f 6465 7329 mp; n : m_nodes) │ │ │ -0006cc90: 0a09 097b 0a3c 6469 7620 7374 796c 653d ...{.

    ...if (n.seco │ │ │ -0006ccd0: 6e64 2e64 6874 2e70 726f 746f 636f 6c5f nd.dht.protocol_ │ │ │ -0006cce0: 6661 6d69 6c79 5f6e 616d 6528 2920 3d3d family_name() == │ │ │ -0006ccf0: 2066 616d 696c 795f 6e61 6d65 290a 3c2f family_name).....return & │ │ │ -0006cd10: 616d 703b 6e2e 7365 636f 6e64 2e64 6874 amp;n.second.dht │ │ │ -0006cd20: 3b0a 0909 7d0a 0a09 0972 6574 7572 6e20 ;...}....return │ │ │ -0006cd30: 6e75 6c6c 7074 723b 0a09 7d0a 0a09 766f nullptr;..}...vo │ │ │ -0006cd40: 6964 2064 6874 5f74 7261 636b 6572 3a3a id dht_tracker:: │ │ │ -0006cd50: 6765 745f 7065 6572 7328 7368 6131 5f68 get_peers(sha1_h │ │ │ -0006cd60: 6173 6820 636f 6e73 7426 616d 703b 2069 ash const& i │ │ │ -0006cd70: 680a 0909 2c20 7374 643a 3a66 756e 6374 h..., std::funct │ │ │ -0006cd80: 696f 6e26 6c74 3b76 6f69 6428 7374 643a ion<void(std: │ │ │ -0006cd90: 3a76 6563 746f 7226 6c74 3b74 6370 3a3a :vector<tcp:: │ │ │ -0006cda0: 656e 6470 6f69 6e74 2667 743b 2063 6f6e endpoint> con │ │ │ -0006cdb0: 7374 2661 6d70 3b29 2667 743b 2066 290a st&)> f). │ │ │ -0006cdc0: 097b 0a09 0966 6f72 2028 6175 746f 2661 .{...for (auto&a │ │ │ -0006cdd0: 6d70 3b20 6e20 3a20 6d5f 6e6f 6465 7329 mp; n : m_nodes) │ │ │ -0006cde0: 0a09 0909 6e2e 7365 636f 6e64 2e64 6874 ....n.second.dht │ │ │ -0006cdf0: 2e67 6574 5f70 6565 7273 2869 682c 2066 .get_peers(ih, f │ │ │ -0006ce00: 2c20 7b7d 2c20 7b7d 293b 0a09 7d0a 0a09 , {}, {});..}... │ │ │ -0006ce10: 766f 6964 2064 6874 5f74 7261 636b 6572 void dht_tracker │ │ │ -0006ce20: 3a3a 616e 6e6f 756e 6365 2873 6861 315f ::announce(sha1_ │ │ │ -0006ce30: 6861 7368 2063 6f6e 7374 2661 6d70 3b20 hash const& │ │ │ -0006ce40: 6968 2c20 696e 7420 6c69 7374 656e 5f70 ih, int listen_p │ │ │ -0006ce50: 6f72 740a 0909 2c20 616e 6e6f 756e 6365 ort..., announce │ │ │ -0006ce60: 5f66 6c61 6773 5f74 2063 6f6e 7374 2066 _flags_t const f │ │ │ -0006ce70: 6c61 6773 0a09 092c 2073 7464 3a3a 6675 lags..., std::fu │ │ │ -0006ce80: 6e63 7469 6f6e 266c 743b 766f 6964 2873 nction<void(s │ │ │ -0006ce90: 7464 3a3a 7665 6374 6f72 266c 743b 7463 td::vector<tc │ │ │ -0006cea0: 703a 3a65 6e64 706f 696e 7426 6774 3b20 p::endpoint> │ │ │ -0006ceb0: 636f 6e73 7426 616d 703b 2926 6774 3b20 const&)> │ │ │ -0006cec0: 6629 0a09 7b0a 0909 666f 7220 2861 7574 f)..{...for (aut │ │ │ -0006ced0: 6f26 616d 703b 206e 203a 206d 5f6e 6f64 o& n : m_nod │ │ │ -0006cee0: 6573 290a 0909 096e 2e73 6563 6f6e 642e es)....n.second. │ │ │ -0006cef0: 6468 742e 616e 6e6f 756e 6365 2869 682c dht.announce(ih, │ │ │ -0006cf00: 206c 6973 7465 6e5f 706f 7274 2c20 666c listen_port, fl │ │ │ -0006cf10: 6167 732c 2066 293b 0a09 7d0a 0a09 766f ags, f);..}...vo │ │ │ -0006cf20: 6964 2064 6874 5f74 7261 636b 6572 3a3a id dht_tracker:: │ │ │ -0006cf30: 7361 6d70 6c65 5f69 6e66 6f68 6173 6865 sample_infohashe │ │ │ -0006cf40: 7328 7564 703a 3a65 6e64 706f 696e 7420 s(udp::endpoint │ │ │ -0006cf50: 636f 6e73 7426 616d 703b 2065 702c 2073 const& ep, s │ │ │ -0006cf60: 6861 315f 6861 7368 2063 6f6e 7374 2661 ha1_hash const&a │ │ │ -0006cf70: 6d70 3b20 7461 7267 6574 0a09 092c 2073 mp; target..., s │ │ │ -0006cf80: 7464 3a3a 6675 6e63 7469 6f6e 266c 743b td::function< │ │ │ -0006cf90: 766f 6964 286e 6f64 655f 6964 0a09 0909 void(node_id.... │ │ │ -0006cfa0: 2c20 7469 6d65 5f64 7572 6174 696f 6e0a , time_duration. │ │ │ -0006cfb0: 0909 092c 2069 6e74 2c20 7374 643a 3a76 ..., int, std::v │ │ │ -0006cfc0: 6563 746f 7226 6c74 3b73 6861 315f 6861 ector<sha1_ha │ │ │ -0006cfd0: 7368 2667 743b 0a09 0909 2c20 7374 643a sh>...., std: │ │ │ -0006cfe0: 3a76 6563 746f 7226 6c74 3b73 7464 3a3a :vector<std:: │ │ │ -0006cff0: 7061 6972 266c 743b 7368 6131 5f68 6173 pair<sha1_has │ │ │ -0006d000: 682c 2075 6470 3a3a 656e 6470 6f69 6e74 h, udp::endpoint │ │ │ -0006d010: 2667 743b 2667 743b 2926 6774 3b20 6629 >>)> f) │ │ │ -0006d020: 0a09 7b0a 0909 666f 7220 2861 7574 6f26 ..{...for (auto& │ │ │ -0006d030: 616d 703b 206e 203a 206d 5f6e 6f64 6573 amp; n : m_nodes │ │ │ -0006d040: 290a 0909 7b0a 0909 0969 6620 2865 702e )...{....if (ep. │ │ │ -0006d050: 7072 6f74 6f63 6f6c 2829 2021 3d20 286e protocol() != (n │ │ │ -0006d060: 2e66 6972 7374 2e67 6574 5f65 7874 6572 .first.get_exter │ │ │ -0006d070: 6e61 6c5f 6164 6472 6573 7328 292e 6973 nal_address().is │ │ │ -0006d080: 5f76 3428 2920 3f20 7564 703a 3a76 3428 _v4() ? udp::v4( │ │ │ -0006d090: 2920 3a20 7564 703a 3a76 3628 2929 290a ) : udp::v6())). │ │ │ +00068d00: 2f70 7574 5f64 6174 612e 6370 703a 3932 /put_data.cpp:92 │ │ │ +00068d10: 3c2f 613e 3c2f 7464 3e3c 7464 3e77 6861 wha │ │ │ +00068d20: 7420 6966 206f 2069 7320 6e6f 7420 616e t if o is not an │ │ │ +00068d30: 2069 6e73 7461 6e63 6520 6f66 2070 7574 instance of put │ │ │ +00068d40: 5f64 6174 615f 6f62 7365 7276 6572 3f20 _data_observer? │ │ │ +00068d50: 5468 6973 206e 6565 6420 746f 2062 6520 This need to be │ │ │ +00068d60: 7265 6465 7369 676e 6564 2066 6f72 2062 redesigned for b │ │ │ +00068d70: 6574 7465 7220 7479 7065 2073 6166 6574 etter type safet │ │ │ +00068d80: 792e 3c2f 7464 3e3c 2f74 723e 3c74 7220 y.

    │ │ │ +00068dd0: 7768 6174 2069 6620 6f20 6973 206e 6f74 what if o is not │ │ │ +00068de0: 2061 6e20 696e 7374 616e 6365 206f 6620 an instance of │ │ │ +00068df0: 7075 745f 6461 7461 5f6f 6273 6572 7665 put_data_observe │ │ │ +00068e00: 723f 2054 6869 7320 6e65 6564 2074 6f20 r? This need to │ │ │ +00068e10: 6265 0a72 6564 6573 6967 6e65 6420 666f be.redesigned fo │ │ │ +00068e20: 7220 6265 7474 6572 2074 7970 6520 7361 r better type sa │ │ │ +00068e30: 6665 7479 2e3c 2f68 323e 3c68 343e 2e2e fety.

    .. │ │ │ +00068e40: 2f73 7263 2f6b 6164 656d 6c69 612f 7075 /src/kademlia/pu │ │ │ +00068e50: 745f 6461 7461 2e63 7070 3a39 323c 2f68 t_data.cpp:92
    .}.}
    │ │ │ +00068ea0: 0a0a 766f 6964 2070 7574 5f64 6174 613a  ..void put_data:
    │ │ │ +00068eb0: 3a64 6f6e 6528 290a 7b0a 096d 5f64 6f6e  :done().{..m_don
    │ │ │ +00068ec0: 6520 3d20 7472 7565 3b0a 0a23 6966 6e64  e = true;..#ifnd
    │ │ │ +00068ed0: 6566 2054 4f52 5245 4e54 5f44 4953 4142  ef TORRENT_DISAB
    │ │ │ +00068ee0: 4c45 5f4c 4f47 4749 4e47 0a09 6765 745f  LE_LOGGING..get_
    │ │ │ +00068ef0: 6e6f 6465 2829 2e6f 6273 6572 7665 7228  node().observer(
    │ │ │ +00068f00: 292d 2667 743b 6c6f 6728 6468 745f 6c6f  )->log(dht_lo
    │ │ │ +00068f10: 6767 6572 3a3a 7472 6176 6572 7361 6c2c  gger::traversal,
    │ │ │ +00068f20: 2022 5b25 755d 2025 7320 444f 4e45 2c20   "[%u] %s DONE, 
    │ │ │ +00068f30: 7265 7370 6f6e 7365 2025 642c 2074 696d  response %d, tim
    │ │ │ +00068f40: 656f 7574 2025 6422 0a09 092c 2069 6428  eout %d"..., id(
    │ │ │ +00068f50: 292c 206e 616d 6528 292c 206e 756d 5f72  ), name(), num_r
    │ │ │ +00068f60: 6573 706f 6e73 6573 2829 2c20 6e75 6d5f  esponses(), num_
    │ │ │ +00068f70: 7469 6d65 6f75 7473 2829 293b 0a23 656e  timeouts());.#en
    │ │ │ +00068f80: 6469 660a 0a09 6d5f 7075 745f 6361 6c6c  dif...m_put_call
    │ │ │ +00068f90: 6261 636b 286d 5f64 6174 612c 206e 756d  back(m_data, num
    │ │ │ +00068fa0: 5f72 6573 706f 6e73 6573 2829 293b 0a09  _responses());..
    │ │ │ +00068fb0: 7472 6176 6572 7361 6c5f 616c 676f 7269  traversal_algori
    │ │ │ +00068fc0: 7468 6d3a 3a64 6f6e 6528 293b 0a7d 0a0a  thm::done();.}..
    │ │ │ +00068fd0: 626f 6f6c 2070 7574 5f64 6174 613a 3a69  bool put_data::i
    │ │ │ +00068fe0: 6e76 6f6b 6528 6f62 7365 7276 6572 5f70  nvoke(observer_p
    │ │ │ +00068ff0: 7472 206f 290a 7b0a 0969 6620 286d 5f64  tr o).{..if (m_d
    │ │ │ +00069000: 6f6e 6529 2072 6574 7572 6e20 6661 6c73  one) return fals
    │ │ │ +00069010: 653b 0a0a 3c64 6976 2073 7479 6c65 3d22  e;..
    .auto* po = st │ │ │ +00069050: 6174 6963 5f63 6173 7426 6c74 3b70 7574 atic_cast<put │ │ │ +00069060: 5f64 6174 615f 6f62 7365 7276 6572 2a26 _data_observer*& │ │ │ +00069070: 6774 3b28 6f2e 6765 7428 2929 3b0a 3c2f gt;(o.get());...entry e;.. │ │ │ +00069090: 655b 2279 225d 203d 2022 7122 3b0a 0965 e["y"] = "q";..e │ │ │ +000690a0: 5b22 7122 5d20 3d20 2270 7574 223b 0a09 ["q"] = "put";.. │ │ │ +000690b0: 656e 7472 7926 616d 703b 2061 203d 2065 entry& a = e │ │ │ +000690c0: 5b22 6122 5d3b 0a09 615b 2276 225d 203d ["a"];..a["v"] = │ │ │ +000690d0: 206d 5f64 6174 612e 7661 6c75 6528 293b m_data.value(); │ │ │ +000690e0: 0a09 615b 2274 6f6b 656e 225d 203d 2070 ..a["token"] = p │ │ │ +000690f0: 6f2d 2667 743b 6d5f 746f 6b65 6e3b 0a09 o->m_token;.. │ │ │ +00069100: 6966 2028 6d5f 6461 7461 2e69 735f 6d75 if (m_data.is_mu │ │ │ +00069110: 7461 626c 6528 2929 0a09 7b0a 0909 615b table())..{...a[ │ │ │ +00069120: 226b 225d 203d 206d 5f64 6174 612e 706b "k"] = m_data.pk │ │ │ +00069130: 2829 2e62 7974 6573 3b0a 0909 615b 2273 ().bytes;...a["s │ │ │ +00069140: 6571 225d 203d 206d 5f64 6174 612e 7365 eq"] = m_data.se │ │ │ +00069150: 7128 292e 7661 6c75 653b 0a09 0961 5b22 q().value;...a[" │ │ │ +00069160: 7369 6722 5d20 3d20 6d5f 6461 7461 2e73 sig"] = m_data.s │ │ │ +00069170: 6967 2829 2e62 7974 6573 3b0a 0909 6966 ig().bytes;...if │ │ │ +00069180: 2028 216d 5f64 6174 612e 7361 6c74 2829 (!m_data.salt() │ │ │ +00069190: 2e65 6d70 7479 2829 290a 0909 7b0a 0909 .empty())...{... │ │ │ +000691a0: 0961 5b22 7361 6c74 225d 203d 206d 5f64 .a["salt"] = m_d │ │ │ +000691b0: 6174 612e 7361 6c74 2829 3b0a 0909 7d0a ata.salt();...}. │ │ │ +000691c0: 097d 0a0a 096d 5f6e 6f64 652e 7374 6174 .}...m_node.stat │ │ │ +000691d0: 735f 636f 756e 7465 7273 2829 2e69 6e63 s_counters().inc │ │ │ +000691e0: 5f73 7461 7473 5f63 6f75 6e74 6572 2863 _stats_counter(c │ │ │ +000691f0: 6f75 6e74 6572 733a 3a64 6874 5f70 7574 ounters::dht_put │ │ │ +00069200: 5f6f 7574 293b 0a0a 0972 6574 7572 6e20 _out);...return │ │ │ +00069210: 6d5f 6e6f 6465 2e6d 5f72 7063 2e69 6e76 m_node.m_rpc.inv │ │ │ +00069220: 6f6b 6528 652c 206f 2d26 6774 3b74 6172 oke(e, o->tar │ │ │ +00069230: 6765 745f 6570 2829 2c20 6f29 3b0a 7d0a get_ep(), o);.}. │ │ │ +00069240: 0a7d 207d 202f 2f20 6e61 6d65 7370 6163 .} } // namespac │ │ │ +00069250: 6520 6c69 6274 6f72 7265 6e74 3a3a 6468 e libtorrent::dh │ │ │ +00069260: 740a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 t.
    < │ │ │ +00069290: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +000692a0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +000692d0: 7372 632f 6b61 6465 6d6c 6961 2f64 6874 src/kademlia/dht │ │ │ +000692e0: 5f74 7261 636b 6572 2e63 7070 3a33 3137 _tracker.cpp:317 │ │ │ +000692f0: 3c2f 613e 3c2f 7464 3e3c 7464 3e70 6963 pic │ │ │ +00069300: 6b20 7468 6520 636c 6f73 6573 7420 6e6f k the closest no │ │ │ +00069310: 6465 2072 6174 6865 7220 7468 616e 2074 de rather than t │ │ │ +00069320: 6865 2066 6972 7374 3c2f 7464 3e3c 2f74 he first

    pick the c │ │ │ +00069380: 6c6f 7365 7374 206e 6f64 6520 7261 7468 losest node rath │ │ │ +00069390: 6572 2074 6861 6e20 7468 6520 6669 7273 er than the firs │ │ │ +000693a0: 743c 2f68 323e 3c68 343e 2e2e 2f73 7263 t

    ../src │ │ │ +000693b0: 2f6b 6164 656d 6c69 612f 6468 745f 7472 /kademlia/dht_tr │ │ │ +000693c0: 6163 6b65 722e 6370 703a 3331 373c 2f68 acker.cpp:317
    .#if
    │ │ │ +00069410: 6e64 6566 2054 4f52 5245 4e54 5f44 4953  ndef TORRENT_DIS
    │ │ │ +00069420: 4142 4c45 5f4c 4f47 4749 4e47 0a09 096d  ABLE_LOGGING...m
    │ │ │ +00069430: 5f6c 6f67 2d26 6774 3b6c 6f67 2864 6874  _log->log(dht
    │ │ │ +00069440: 5f6c 6f67 6765 723a 3a74 7261 636b 6572  _logger::tracker
    │ │ │ +00069450: 2c20 222a 2a2a 206e 6577 2077 7269 7465  , "*** new write
    │ │ │ +00069460: 206b 6579 2a2a 2a20 2564 206e 6f64 6573   key*** %d nodes
    │ │ │ +00069470: 220a 0909 092c 2069 6e74 286d 5f6e 6f64  "...., int(m_nod
    │ │ │ +00069480: 6573 2e73 697a 6528 2929 293b 0a23 656e  es.size()));.#en
    │ │ │ +00069490: 6469 660a 097d 0a0a 0976 6f69 6420 6468  dif..}...void dh
    │ │ │ +000694a0: 745f 7472 6163 6b65 723a 3a75 7064 6174  t_tracker::updat
    │ │ │ +000694b0: 655f 7374 6f72 6167 655f 6e6f 6465 5f69  e_storage_node_i
    │ │ │ +000694c0: 6473 2829 0a09 7b0a 0909 7374 643a 3a76  ds()..{...std::v
    │ │ │ +000694d0: 6563 746f 7226 6c74 3b73 6861 315f 6861  ector<sha1_ha
    │ │ │ +000694e0: 7368 2667 743b 2069 6473 3b0a 0909 666f  sh> ids;...fo
    │ │ │ +000694f0: 7220 2861 7574 6f26 616d 703b 206e 203a  r (auto& n :
    │ │ │ +00069500: 206d 5f6e 6f64 6573 290a 0909 0969 6473   m_nodes)....ids
    │ │ │ +00069510: 2e70 7573 685f 6261 636b 286e 2e73 6563  .push_back(n.sec
    │ │ │ +00069520: 6f6e 642e 6468 742e 6e69 6428 2929 3b0a  ond.dht.nid());.
    │ │ │ +00069530: 0909 6d5f 7374 6f72 6167 652e 7570 6461  ..m_storage.upda
    │ │ │ +00069540: 7465 5f6e 6f64 655f 6964 7328 6964 7329  te_node_ids(ids)
    │ │ │ +00069550: 3b0a 097d 0a0a 096e 6f64 652a 2064 6874  ;..}...node* dht
    │ │ │ +00069560: 5f74 7261 636b 6572 3a3a 6765 745f 6e6f  _tracker::get_no
    │ │ │ +00069570: 6465 286e 6f64 655f 6964 2063 6f6e 7374  de(node_id const
    │ │ │ +00069580: 2661 6d70 3b20 6964 2c20 7374 643a 3a73  & id, std::s
    │ │ │ +00069590: 7472 696e 6720 636f 6e73 7426 616d 703b  tring const&
    │ │ │ +000695a0: 2066 616d 696c 795f 6e61 6d65 290a 097b   family_name)..{
    │ │ │ +000695b0: 0a09 0954 4f52 5245 4e54 5f55 4e55 5345  ...TORRENT_UNUSE
    │ │ │ +000695c0: 4428 6964 293b 0a09 0966 6f72 2028 6175  D(id);...for (au
    │ │ │ +000695d0: 746f 2661 6d70 3b20 6e20 3a20 6d5f 6e6f  to& n : m_no
    │ │ │ +000695e0: 6465 7329 0a09 097b 0a3c 6469 7620 7374  des)...{.
    ...if (n. │ │ │ +00069620: 7365 636f 6e64 2e64 6874 2e70 726f 746f second.dht.proto │ │ │ +00069630: 636f 6c5f 6661 6d69 6c79 5f6e 616d 6528 col_family_name( │ │ │ +00069640: 2920 3d3d 2066 616d 696c 795f 6e61 6d65 ) == family_name │ │ │ +00069650: 290a 3c2f 6469 763e 0909 0909 7265 7475 ).
    ....retu │ │ │ +00069660: 726e 2026 616d 703b 6e2e 7365 636f 6e64 rn &n.second │ │ │ +00069670: 2e64 6874 3b0a 0909 7d0a 0a09 0972 6574 .dht;...}....ret │ │ │ +00069680: 7572 6e20 6e75 6c6c 7074 723b 0a09 7d0a urn nullptr;..}. │ │ │ +00069690: 0a09 766f 6964 2064 6874 5f74 7261 636b ..void dht_track │ │ │ +000696a0: 6572 3a3a 6765 745f 7065 6572 7328 7368 er::get_peers(sh │ │ │ +000696b0: 6131 5f68 6173 6820 636f 6e73 7426 616d a1_hash const&am │ │ │ +000696c0: 703b 2069 680a 0909 2c20 7374 643a 3a66 p; ih..., std::f │ │ │ +000696d0: 756e 6374 696f 6e26 6c74 3b76 6f69 6428 unction<void( │ │ │ +000696e0: 7374 643a 3a76 6563 746f 7226 6c74 3b74 std::vector<t │ │ │ +000696f0: 6370 3a3a 656e 6470 6f69 6e74 2667 743b cp::endpoint> │ │ │ +00069700: 2063 6f6e 7374 2661 6d70 3b29 2667 743b const&)> │ │ │ +00069710: 2066 290a 097b 0a09 0966 6f72 2028 6175 f)..{...for (au │ │ │ +00069720: 746f 2661 6d70 3b20 6e20 3a20 6d5f 6e6f to& n : m_no │ │ │ +00069730: 6465 7329 0a09 0909 6e2e 7365 636f 6e64 des)....n.second │ │ │ +00069740: 2e64 6874 2e67 6574 5f70 6565 7273 2869 .dht.get_peers(i │ │ │ +00069750: 682c 2066 2c20 7b7d 2c20 7b7d 293b 0a09 h, f, {}, {});.. │ │ │ +00069760: 7d0a 0a09 766f 6964 2064 6874 5f74 7261 }...void dht_tra │ │ │ +00069770: 636b 6572 3a3a 616e 6e6f 756e 6365 2873 cker::announce(s │ │ │ +00069780: 6861 315f 6861 7368 2063 6f6e 7374 2661 ha1_hash const&a │ │ │ +00069790: 6d70 3b20 6968 2c20 696e 7420 6c69 7374 mp; ih, int list │ │ │ +000697a0: 656e 5f70 6f72 740a 0909 2c20 616e 6e6f en_port..., anno │ │ │ +000697b0: 756e 6365 5f66 6c61 6773 5f74 2063 6f6e unce_flags_t con │ │ │ +000697c0: 7374 2066 6c61 6773 0a09 092c 2073 7464 st flags..., std │ │ │ +000697d0: 3a3a 6675 6e63 7469 6f6e 266c 743b 766f ::function<vo │ │ │ +000697e0: 6964 2873 7464 3a3a 7665 6374 6f72 266c id(std::vector&l │ │ │ +000697f0: 743b 7463 703a 3a65 6e64 706f 696e 7426 t;tcp::endpoint& │ │ │ +00069800: 6774 3b20 636f 6e73 7426 616d 703b 2926 gt; const&)& │ │ │ +00069810: 6774 3b20 6629 0a09 7b0a 0909 666f 7220 gt; f)..{...for │ │ │ +00069820: 2861 7574 6f26 616d 703b 206e 203a 206d (auto& n : m │ │ │ +00069830: 5f6e 6f64 6573 290a 0909 096e 2e73 6563 _nodes)....n.sec │ │ │ +00069840: 6f6e 642e 6468 742e 616e 6e6f 756e 6365 ond.dht.announce │ │ │ +00069850: 2869 682c 206c 6973 7465 6e5f 706f 7274 (ih, listen_port │ │ │ +00069860: 2c20 666c 6167 732c 2066 293b 0a09 7d0a , flags, f);..}. │ │ │ +00069870: 0a09 766f 6964 2064 6874 5f74 7261 636b ..void dht_track │ │ │ +00069880: 6572 3a3a 7361 6d70 6c65 5f69 6e66 6f68 er::sample_infoh │ │ │ +00069890: 6173 6865 7328 7564 703a 3a65 6e64 706f ashes(udp::endpo │ │ │ +000698a0: 696e 7420 636f 6e73 7426 616d 703b 2065 int const& e │ │ │ +000698b0: 702c 2073 6861 315f 6861 7368 2063 6f6e p, sha1_hash con │ │ │ +000698c0: 7374 2661 6d70 3b20 7461 7267 6574 0a09 st& target.. │ │ │ +000698d0: 092c 2073 7464 3a3a 6675 6e63 7469 6f6e ., std::function │ │ │ +000698e0: 266c 743b 766f 6964 286e 6f64 655f 6964 <void(node_id │ │ │ +000698f0: 0a09 0909 2c20 7469 6d65 5f64 7572 6174 ...., time_durat │ │ │ +00069900: 696f 6e0a 0909 092c 2069 6e74 2c20 7374 ion...., int, st │ │ │ +00069910: 643a 3a76 6563 746f 7226 6c74 3b73 6861 d::vector<sha │ │ │ +00069920: 315f 6861 7368 2667 743b 0a09 0909 2c20 1_hash>...., │ │ │ +00069930: 7374 643a 3a76 6563 746f 7226 6c74 3b73 std::vector<s │ │ │ +00069940: 7464 3a3a 7061 6972 266c 743b 7368 6131 td::pair<sha1 │ │ │ +00069950: 5f68 6173 682c 2075 6470 3a3a 656e 6470 _hash, udp::endp │ │ │ +00069960: 6f69 6e74 2667 743b 2667 743b 2926 6774 oint>>)> │ │ │ +00069970: 3b20 6629 0a09 7b0a 0909 666f 7220 2861 ; f)..{...for (a │ │ │ +00069980: 7574 6f26 616d 703b 206e 203a 206d 5f6e uto& n : m_n │ │ │ +00069990: 6f64 6573 290a 0909 7b0a 0909 0969 6620 odes)...{....if │ │ │ +000699a0: 2865 702e 7072 6f74 6f63 6f6c 2829 2021 (ep.protocol() ! │ │ │ +000699b0: 3d20 286e 2e66 6972 7374 2e67 6574 5f65 = (n.first.get_e │ │ │ +000699c0: 7874 6572 6e61 6c5f 6164 6472 6573 7328 xternal_address( │ │ │ +000699d0: 292e 6973 5f76 3428 2920 3f20 7564 703a ).is_v4() ? udp: │ │ │ +000699e0: 3a76 3428 2920 3a20 7564 703a 3a76 3628 :v4() : udp::v6( │ │ │ +000699f0: 2929 290a 3c2f 7072 653e 3c2f 7464 3e3c ))).
    < │ │ │ +00069a00: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +00069a30: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +00069a60: 2e2f 7372 632f 6b61 6465 6d6c 6961 2f72 ./src/kademlia/r │ │ │ +00069a70: 6f75 7469 6e67 5f74 6162 6c65 2e63 7070 outing_table.cpp │ │ │ +00069a80: 3a32 3839 3c2f 613e 3c2f 7464 3e3c 7464 :289This is tempora │ │ │ +00069aa0: 7279 2e20 466f 7220 6e6f 772c 206f 6e6c ry. For now, onl │ │ │ +00069ab0: 7920 7265 706f 7274 2074 6865 206c 6172 y report the lar │ │ │ +00069ac0: 6765 7374 2072 6f75 7469 6e67 2074 6162 gest routing tab │ │ │ +00069ad0: 6c65 2028 6f66 2070 6f74 656e 7469 616c le (of potential │ │ │ +00069ae0: 6c79 206d 756c 7469 706c 6520 6f6e 6573 ly multiple ones │ │ │ +00069af0: 2c20 666f 7220 6d75 6c74 692d 686f 6d65 , for multi-home │ │ │ +00069b00: 6420 7379 7374 656d 7329 2069 6e20 6e65 d systems) in ne │ │ │ +00069b10: 7874 206d 616a 6f72 2076 6572 7369 6f6e xt major version │ │ │ +00069b20: 2c20 6272 6561 6b20 7468 6520 4142 4920 , break the ABI │ │ │ +00069b30: 616e 6420 7375 7070 6f72 7420 7265 706f and support repo │ │ │ +00069b40: 7274 696e 6720 616c 6c20 6f66 2074 6865 rting all of the │ │ │ +00069b50: 6d20 696e 2074 6865 2064 6874 5f73 7461 m in the dht_sta │ │ │ +00069b60: 7473 5f61 6c65 7274 3c2f 7464 3e3c 2f74 ts_alert

    This is te │ │ │ +00069bc0: 6d70 6f72 6172 792e 2046 6f72 206e 6f77 mporary. For now │ │ │ +00069bd0: 2c20 6f6e 6c79 2072 6570 6f72 7420 7468 , only report th │ │ │ +00069be0: 6520 6c61 7267 6573 7420 726f 7574 696e e largest routin │ │ │ +00069bf0: 6720 7461 626c 650a 286f 6620 706f 7465 g table.(of pote │ │ │ +00069c00: 6e74 6961 6c6c 7920 6d75 6c74 6970 6c65 ntially multiple │ │ │ +00069c10: 206f 6e65 732c 2066 6f72 206d 756c 7469 ones, for multi │ │ │ +00069c20: 2d68 6f6d 6564 2073 7973 7465 6d73 290a -homed systems). │ │ │ +00069c30: 696e 206e 6578 7420 6d61 6a6f 7220 7665 in next major ve │ │ │ +00069c40: 7273 696f 6e2c 2062 7265 616b 2074 6865 rsion, break the │ │ │ +00069c50: 2041 4249 2061 6e64 2073 7570 706f 7274 ABI and support │ │ │ +00069c60: 2072 6570 6f72 7469 6e67 2061 6c6c 206f reporting all o │ │ │ +00069c70: 6620 7468 656d 2069 6e0a 7468 6520 6468 f them in.the dh │ │ │ +00069c80: 745f 7374 6174 735f 616c 6572 743c 2f68 t_stats_alert

    ../src/kad │ │ │ +00069ca0: 656d 6c69 612f 726f 7574 696e 675f 7461 emlia/routing_ta │ │ │ +00069cb0: 626c 652e 6370 703a 3238 393c 2f68 343e ble.cpp:289

    │ │ │ +00069cc0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ., m_b
    │ │ │ +00069d00: 7563 6b65 745f 7369 7a65 2862 7563 6b65  ucket_size(bucke
    │ │ │ +00069d10: 745f 7369 7a65 290a 7b0a 092f 2f20 6275  t_size).{..// bu
    │ │ │ +00069d20: 636b 6574 2073 697a 6573 206d 7573 7420  cket sizes must 
    │ │ │ +00069d30: 6265 2061 2070 6f77 6572 206f 6620 320a  be a power of 2.
    │ │ │ +00069d40: 0954 4f52 5245 4e54 5f41 5353 4552 545f  .TORRENT_ASSERT_
    │ │ │ +00069d50: 5641 4c28 2828 6275 636b 6574 5f73 697a  VAL(((bucket_siz
    │ │ │ +00069d60: 6520 2d20 3129 2026 616d 703b 2062 7563  e - 1) & buc
    │ │ │ +00069d70: 6b65 745f 7369 7a65 2920 3d3d 2030 2c20  ket_size) == 0, 
    │ │ │ +00069d80: 6275 636b 6574 5f73 697a 6529 3b0a 0954  bucket_size);..T
    │ │ │ +00069d90: 4f52 5245 4e54 5f55 4e55 5345 4428 6c6f  ORRENT_UNUSED(lo
    │ │ │ +00069da0: 6729 3b0a 096d 5f62 7563 6b65 7473 2e72  g);..m_buckets.r
    │ │ │ +00069db0: 6573 6572 7665 2833 3029 3b0a 7d0a 0a69  eserve(30);.}..i
    │ │ │ +00069dc0: 6e74 2072 6f75 7469 6e67 5f74 6162 6c65  nt routing_table
    │ │ │ +00069dd0: 3a3a 6275 636b 6574 5f6c 696d 6974 2869  ::bucket_limit(i
    │ │ │ +00069de0: 6e74 2062 7563 6b65 7429 2063 6f6e 7374  nt bucket) const
    │ │ │ +00069df0: 0a7b 0a09 6966 2028 216d 5f73 6574 7469  .{..if (!m_setti
    │ │ │ +00069e00: 6e67 732e 6765 745f 626f 6f6c 2873 6574  ngs.get_bool(set
    │ │ │ +00069e10: 7469 6e67 735f 7061 636b 3a3a 6468 745f  tings_pack::dht_
    │ │ │ +00069e20: 6578 7465 6e64 6564 5f72 6f75 7469 6e67  extended_routing
    │ │ │ +00069e30: 5f74 6162 6c65 2929 2072 6574 7572 6e20  _table)) return 
    │ │ │ +00069e40: 6d5f 6275 636b 6574 5f73 697a 653b 0a0a  m_bucket_size;..
    │ │ │ +00069e50: 0973 7461 7469 6320 636f 6e73 7420 6175  .static const au
    │ │ │ +00069e60: 783a 3a61 7272 6179 266c 743b 696e 742c  x::array<int,
    │ │ │ +00069e70: 2034 2667 743b 2073 697a 655f 6578 6365   4> size_exce
    │ │ │ +00069e80: 7074 696f 6e73 7b7b 7b31 362c 2038 2c20  ptions{{{16, 8, 
    │ │ │ +00069e90: 342c 2032 7d7d 7d3b 0a09 6966 2028 6275  4, 2}}};..if (bu
    │ │ │ +00069ea0: 636b 6574 2026 6c74 3b20 7369 7a65 5f65  cket < size_e
    │ │ │ +00069eb0: 7863 6570 7469 6f6e 732e 656e 645f 696e  xceptions.end_in
    │ │ │ +00069ec0: 6465 7828 2929 0a09 0972 6574 7572 6e20  dex())...return 
    │ │ │ +00069ed0: 6d5f 6275 636b 6574 5f73 697a 6520 2a20  m_bucket_size * 
    │ │ │ +00069ee0: 7369 7a65 5f65 7863 6570 7469 6f6e 735b  size_exceptions[
    │ │ │ +00069ef0: 6275 636b 6574 5d3b 0a09 7265 7475 726e  bucket];..return
    │ │ │ +00069f00: 206d 5f62 7563 6b65 745f 7369 7a65 3b0a   m_bucket_size;.
    │ │ │ +00069f10: 7d0a 0a76 6f69 6420 726f 7574 696e 675f  }..void routing_
    │ │ │ +00069f20: 7461 626c 653a 3a73 7461 7475 7328 7374  table::status(st
    │ │ │ +00069f30: 643a 3a76 6563 746f 7226 6c74 3b64 6874  d::vector<dht
    │ │ │ +00069f40: 5f72 6f75 7469 6e67 5f62 7563 6b65 7426  _routing_bucket&
    │ │ │ +00069f50: 6774 3b26 616d 703b 2073 2920 636f 6e73  gt;& s) cons
    │ │ │ +00069f60: 740a 7b0a 3c64 6976 2073 7479 6c65 3d22  t.{.
    .if (s.size() │ │ │ +00069fa0: 2667 743b 206d 5f62 7563 6b65 7473 2e73 > m_buckets.s │ │ │ +00069fb0: 697a 6528 2929 2072 6574 7572 6e3b 0a3c ize()) return;.< │ │ │ +00069fc0: 2f64 6976 3e09 732e 636c 6561 7228 293b /div>.s.clear(); │ │ │ +00069fd0: 0a09 666f 7220 2861 7574 6f20 636f 6e73 ..for (auto cons │ │ │ +00069fe0: 7426 616d 703b 2069 203a 206d 5f62 7563 t& i : m_buc │ │ │ +00069ff0: 6b65 7473 290a 097b 0a09 0964 6874 5f72 kets)..{...dht_r │ │ │ +0006a000: 6f75 7469 6e67 5f62 7563 6b65 7420 623b outing_bucket b; │ │ │ +0006a010: 0a09 0962 2e6e 756d 5f6e 6f64 6573 203d ...b.num_nodes = │ │ │ +0006a020: 2069 6e74 2869 2e6c 6976 655f 6e6f 6465 int(i.live_node │ │ │ +0006a030: 732e 7369 7a65 2829 293b 0a09 0962 2e6e s.size());...b.n │ │ │ +0006a040: 756d 5f72 6570 6c61 6365 6d65 6e74 7320 um_replacements │ │ │ +0006a050: 3d20 696e 7428 692e 7265 706c 6163 656d = int(i.replacem │ │ │ +0006a060: 656e 7473 2e73 697a 6528 2929 3b0a 0909 ents.size());... │ │ │ +0006a070: 732e 7075 7368 5f62 6163 6b28 6229 3b0a s.push_back(b);. │ │ │ +0006a080: 097d 0a7d 0a0a 2369 6620 544f 5252 454e .}.}..#if TORREN │ │ │ +0006a090: 545f 4142 495f 5645 5253 494f 4e20 3d3d T_ABI_VERSION == │ │ │ +0006a0a0: 2031 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 1.
    │ │ │ +0006a0d0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +0006a0e0: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +0006a110: 2f73 7263 2f6b 6164 656d 6c69 612f 726f /src/kademlia/ro │ │ │ +0006a120: 7574 696e 675f 7461 626c 652e 6370 703a uting_table.cpp: │ │ │ +0006a130: 3331 343c 2f61 3e3c 2f74 643e 3c74 643e 314 │ │ │ +0006a140: 6172 7669 646e 206e 6f74 6520 7768 656e arvidn note when │ │ │ +0006a150: 2069 7427 7320 6163 726f 7373 2049 5076 it's across IPv │ │ │ +0006a160: 3420 616e 6420 4950 7636 2c20 6164 6469 4 and IPv6, addi │ │ │ +0006a170: 6e67 2028 6468 745f 676c 6f62 616c 5f6e ng (dht_global_n │ │ │ +0006a180: 6f64 6573 2920 776f 756c 6420 6d61 6b65 odes) would make │ │ │ +0006a190: 2073 656e 7365 2e20 696e 2074 6865 2066 sense. in the f │ │ │ +0006a1a0: 7574 7572 6520 7468 6f75 6768 2c20 7768 uture though, wh │ │ │ +0006a1b0: 6572 6520 7765 206d 6179 2068 6176 6520 ere we may have │ │ │ +0006a1c0: 6f6e 6520 4448 5420 6e6f 6465 2070 6572 one DHT node per │ │ │ +0006a1d0: 2065 7874 6572 6e61 6c20 696e 7465 7266 external interf │ │ │ +0006a1e0: 6163 6520 2877 6869 6368 206d 6179 2062 ace (which may b │ │ │ +0006a1f0: 6520 6d75 6c74 6970 6c65 206f 6620 7468 e multiple of th │ │ │ +0006a200: 6520 7361 6d65 2061 6464 7265 7373 2066 e same address f │ │ │ +0006a210: 616d 696c 7929 2c20 7468 656e 2069 7420 amily), then it │ │ │ +0006a220: 6265 636f 6d65 7320 6120 6269 7420 7472 becomes a bit tr │ │ │ +0006a230: 6963 6b69 6572 3c2f 7464 3e3c 2f74 723e ickier │ │ │ +0006a240: 3c74 7220 6964 3d22 3234 3322 2073 7479 │ │ │ +0006a270: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0006a280: 3c68 323e 6172 7669 646e 206e 6f74 650a

    arvidn note. │ │ │ +0006a290: 7768 656e 2069 7427 7320 6163 726f 7373 when it's across │ │ │ +0006a2a0: 2049 5076 3420 616e 6420 4950 7636 2c20 IPv4 and IPv6, │ │ │ +0006a2b0: 6164 6469 6e67 2028 6468 745f 676c 6f62 adding (dht_glob │ │ │ +0006a2c0: 616c 5f6e 6f64 6573 2920 776f 756c 640a al_nodes) would. │ │ │ +0006a2d0: 6d61 6b65 2073 656e 7365 2e20 696e 2074 make sense. in t │ │ │ +0006a2e0: 6865 2066 7574 7572 6520 7468 6f75 6768 he future though │ │ │ +0006a2f0: 2c20 7768 6572 6520 7765 206d 6179 2068 , where we may h │ │ │ +0006a300: 6176 6520 6f6e 6520 4448 5420 6e6f 6465 ave one DHT node │ │ │ +0006a310: 0a70 6572 2065 7874 6572 6e61 6c20 696e .per external in │ │ │ +0006a320: 7465 7266 6163 6520 2877 6869 6368 206d terface (which m │ │ │ +0006a330: 6179 2062 6520 6d75 6c74 6970 6c65 206f ay be multiple o │ │ │ +0006a340: 6620 7468 6520 7361 6d65 2061 6464 7265 f the same addre │ │ │ +0006a350: 7373 0a66 616d 696c 7929 2c20 7468 656e ss.family), then │ │ │ +0006a360: 2069 7420 6265 636f 6d65 7320 6120 6269 it becomes a bi │ │ │ +0006a370: 7420 7472 6963 6b69 6572 3c2f 6832 3e3c t trickier

    < │ │ │ +0006a380: 6834 3e2e 2e2f 7372 632f 6b61 6465 6d6c h4>../src/kademl │ │ │ +0006a390: 6961 2f72 6f75 7469 6e67 5f74 6162 6c65 ia/routing_table │ │ │ +0006a3a0: 2e63 7070 3a33 3134 3c2f 6834 3e3c 7072 .cpp:314.if (s.si │ │ │ +0006a3f0: 7a65 2829 2026 6774 3b20 6d5f 6275 636b ze() > m_buck │ │ │ +0006a400: 6574 732e 7369 7a65 2829 2920 7265 7475 ets.size()) retu │ │ │ +0006a410: 726e 3b0a 0973 2e63 6c65 6172 2829 3b0a rn;..s.clear();. │ │ │ +0006a420: 0966 6f72 2028 6175 746f 2063 6f6e 7374 .for (auto const │ │ │ +0006a430: 2661 6d70 3b20 6920 3a20 6d5f 6275 636b & i : m_buck │ │ │ +0006a440: 6574 7329 0a09 7b0a 0909 6468 745f 726f ets)..{...dht_ro │ │ │ +0006a450: 7574 696e 675f 6275 636b 6574 2062 3b0a uting_bucket b;. │ │ │ +0006a460: 0909 622e 6e75 6d5f 6e6f 6465 7320 3d20 ..b.num_nodes = │ │ │ +0006a470: 696e 7428 692e 6c69 7665 5f6e 6f64 6573 int(i.live_nodes │ │ │ +0006a480: 2e73 697a 6528 2929 3b0a 0909 622e 6e75 .size());...b.nu │ │ │ +0006a490: 6d5f 7265 706c 6163 656d 656e 7473 203d m_replacements = │ │ │ +0006a4a0: 2069 6e74 2869 2e72 6570 6c61 6365 6d65 int(i.replaceme │ │ │ +0006a4b0: 6e74 732e 7369 7a65 2829 293b 0a09 0973 nts.size());...s │ │ │ +0006a4c0: 2e70 7573 685f 6261 636b 2862 293b 0a09 .push_back(b);.. │ │ │ +0006a4d0: 7d0a 7d0a 0a23 6966 2054 4f52 5245 4e54 }.}..#if TORRENT │ │ │ +0006a4e0: 5f41 4249 5f56 4552 5349 4f4e 203d 3d20 _ABI_VERSION == │ │ │ +0006a4f0: 310a 766f 6964 2072 6f75 7469 6e67 5f74 1.void routing_t │ │ │ +0006a500: 6162 6c65 3a3a 7374 6174 7573 2873 6573 able::status(ses │ │ │ +0006a510: 7369 6f6e 5f73 7461 7475 7326 616d 703b sion_status& │ │ │ +0006a520: 2073 2920 636f 6e73 740a 7b0a 0969 6e74 s) const.{..int │ │ │ +0006a530: 2064 6874 5f6e 6f64 6573 3b0a 0969 6e74 dht_nodes;..int │ │ │ +0006a540: 2064 6874 5f6e 6f64 655f 6361 6368 653b dht_node_cache; │ │ │ +0006a550: 0a09 696e 7420 6967 6e6f 7265 3b0a 0973 ..int ignore;..s │ │ │ +0006a560: 7464 3a3a 7469 6528 6468 745f 6e6f 6465 td::tie(dht_node │ │ │ +0006a570: 732c 2064 6874 5f6e 6f64 655f 6361 6368 s, dht_node_cach │ │ │ +0006a580: 652c 2069 676e 6f72 6529 203d 2073 697a e, ignore) = siz │ │ │ +0006a590: 6528 293b 0a09 732e 6468 745f 6e6f 6465 e();..s.dht_node │ │ │ +0006a5a0: 7320 2b3d 2064 6874 5f6e 6f64 6573 3b0a s += dht_nodes;. │ │ │ +0006a5b0: 0973 2e64 6874 5f6e 6f64 655f 6361 6368 .s.dht_node_cach │ │ │ +0006a5c0: 6520 2b3d 2064 6874 5f6e 6f64 655f 6361 e += dht_node_ca │ │ │ +0006a5d0: 6368 653b 0a3c 6469 7620 7374 796c 653d che;.
    .s.dht_global │ │ │ +0006a610: 5f6e 6f64 6573 202b 3d20 6e75 6d5f 676c _nodes += num_gl │ │ │ +0006a620: 6f62 616c 5f6e 6f64 6573 2829 3b0a 3c2f obal_nodes();...for (auto │ │ │ +0006a640: 636f 6e73 7426 616d 703b 2069 203a 206d const& i : m │ │ │ +0006a650: 5f62 7563 6b65 7473 290a 097b 0a09 0964 _buckets)..{...d │ │ │ +0006a660: 6874 5f72 6f75 7469 6e67 5f62 7563 6b65 ht_routing_bucke │ │ │ +0006a670: 7420 623b 0a09 0962 2e6e 756d 5f6e 6f64 t b;...b.num_nod │ │ │ +0006a680: 6573 203d 2069 6e74 2869 2e6c 6976 655f es = int(i.live_ │ │ │ +0006a690: 6e6f 6465 732e 7369 7a65 2829 293b 0a09 nodes.size());.. │ │ │ +0006a6a0: 0962 2e6e 756d 5f72 6570 6c61 6365 6d65 .b.num_replaceme │ │ │ +0006a6b0: 6e74 7320 3d20 696e 7428 692e 7265 706c nts = int(i.repl │ │ │ +0006a6c0: 6163 656d 656e 7473 2e73 697a 6528 2929 acements.size()) │ │ │ +0006a6d0: 3b0a 2369 6620 544f 5252 454e 545f 4142 ;.#if TORRENT_AB │ │ │ +0006a6e0: 495f 5645 5253 494f 4e20 3d3d 2031 0a09 I_VERSION == 1.. │ │ │ +0006a6f0: 0962 2e6c 6173 745f 6163 7469 7665 203d .b.last_active = │ │ │ +0006a700: 2030 3b0a 2365 6e64 6966 0a09 0973 2e64 0;.#endif...s.d │ │ │ +0006a710: 6874 5f72 6f75 7469 6e67 5f74 6162 6c65 ht_routing_table │ │ │ +0006a720: 2e70 7573 685f 6261 636b 2862 293b 0a09 .push_back(b);.. │ │ │ +0006a730: 7d0a 7d0a 2365 6e64 6966 0a0a 7374 643a }.}.#endif..std: │ │ │ +0006a740: 3a74 7570 6c65 266c 743b 696e 742c 2069 :tuple<int, i │ │ │ +0006a750: 6e74 2c20 696e 7426 6774 3b20 726f 7574 nt, int> rout │ │ │ +0006a760: 696e 675f 7461 626c 653a 3a73 697a 6528 ing_table::size( │ │ │ +0006a770: 2920 636f 6e73 740a 7b0a 0969 6e74 206e ) const.{..int n │ │ │ +0006a780: 6f64 6573 203d 2030 3b0a 0969 6e74 2072 odes = 0;..int r │ │ │ +0006a790: 6570 6c61 6365 6d65 6e74 7320 3d20 303b eplacements = 0; │ │ │ +0006a7a0: 0a09 696e 7420 636f 6e66 6972 6d65 6420 ..int confirmed │ │ │ +0006a7b0: 3d20 303b 0a09 666f 7220 2861 7574 6f20 = 0;..for (auto │ │ │ +0006a7c0: 636f 6e73 7426 616d 703b 2069 203a 206d const& i : m │ │ │ +0006a7d0: 5f62 7563 6b65 7473 290a 097b 0a09 096e _buckets)..{...n │ │ │ +0006a7e0: 6f64 6573 202b 3d20 696e 7428 692e 6c69 odes += int(i.li │ │ │ +0006a7f0: 7665 5f6e 6f64 6573 2e73 697a 6528 2929 ve_nodes.size()) │ │ │ +0006a800: 3b0a 0909 636f 6e66 6972 6d65 6420 2b3d ;...confirmed += │ │ │ +0006a810: 2073 7461 7469 635f 6361 7374 266c 743b static_cast< │ │ │ +0006a820: 696e 7426 6774 3b28 7374 643a 3a63 6f75 int>(std::cou │ │ │ +0006a830: 6e74 5f69 6628 692e 6c69 7665 5f6e 6f64 nt_if(i.live_nod │ │ │ +0006a840: 6573 2e62 6567 696e 2829 2c20 692e 6c69 es.begin(), i.li │ │ │ +0006a850: 7665 5f6e 6f64 6573 2e65 6e64 2829 0a09 ve_nodes.end().. │ │ │ +0006a860: 0909 2c20 5b5d 286e 6f64 655f 656e 7472 .., [](node_entr │ │ │ +0006a870: 7920 636f 6e73 7426 616d 703b 206b 2920 y const& k) │ │ │ +0006a880: 7b20 7265 7475 726e 206b 2e63 6f6e 6669 { return k.confi │ │ │ +0006a890: 726d 6564 2829 3b20 7d20 2929 3b0a 0a09 rmed(); } ));... │ │ │ +0006a8a0: 0972 6570 6c61 6365 6d65 6e74 7320 2b3d .replacements += │ │ │ +0006a8b0: 2069 6e74 2869 2e72 6570 6c61 6365 6d65 int(i.replaceme │ │ │ +0006a8c0: 6e74 732e 7369 7a65 2829 293b 0a09 7d0a nts.size());..}. │ │ │ +0006a8d0: 0972 6574 7572 6e20 7374 643a 3a6d 616b .return std::mak │ │ │ +0006a8e0: 655f 7475 706c 6528 6e6f 6465 732c 2072 e_tuple(nodes, r │ │ │ +0006a8f0: 6570 6c61 6365 6d65 6e74 732c 2063 6f6e eplacements, con │ │ │ +0006a900: 6669 726d 6564 293b 0a7d 0a0a 3c2f 7072 firmed);.}..rel │ │ │ +0006a940: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/ka │ │ │ +0006a980: 6465 6d6c 6961 2f72 6f75 7469 6e67 5f74 demlia/routing_t │ │ │ +0006a990: 6162 6c65 2e63 7070 3a35 3138 3c2f 613e able.cpp:518 │ │ │ +0006a9a0: 3c2f 7464 3e3c 7464 3e74 6869 7320 6e65 this ne │ │ │ +0006a9b0: 6564 2074 6f20 7461 6b65 2062 7563 6b65 ed to take bucke │ │ │ +0006a9c0: 7420 2270 7265 6669 7822 2069 6e74 6f20 t "prefix" into │ │ │ +0006a9d0: 6163 636f 756e 742e 2049 7420 7368 6f75 account. It shou │ │ │ +0006a9e0: 6c64 2062 6520 756e 6966 6965 6420 7769 ld be unified wi │ │ │ +0006a9f0: 7468 2061 6464 5f6e 6f64 655f 696d 706c th add_node_impl │ │ │ +0006aa00: 2829 3c2f 7464 3e3c 2f74 723e 3c74 7220 ()

    │ │ │ +0006aa50: 7468 6973 206e 6565 6420 746f 2074 616b this need to tak │ │ │ +0006aa60: 6520 6275 636b 6574 2022 7072 6566 6978 e bucket "prefix │ │ │ +0006aa70: 2220 696e 746f 2061 6363 6f75 6e74 2e20 " into account. │ │ │ +0006aa80: 4974 2073 686f 756c 6420 6265 2075 6e69 It should be uni │ │ │ +0006aa90: 6669 6564 0a77 6974 6820 6164 645f 6e6f fied.with add_no │ │ │ +0006aaa0: 6465 5f69 6d70 6c28 293c 2f68 323e 3c68 de_impl()

    ../src/kademli │ │ │ +0006aac0: 612f 726f 7574 696e 675f 7461 626c 652e a/routing_table. │ │ │ +0006aad0: 6370 703a 3531 383c 2f68 343e 3c70 7265 cpp:518
    {..for (au
    │ │ │ +0006ab20: 746f 2069 203d 206d 5f62 7563 6b65 7473  to i = m_buckets
    │ │ │ +0006ab30: 2e62 6567 696e 2829 202c 2065 6e64 286d  .begin() , end(m
    │ │ │ +0006ab40: 5f62 7563 6b65 7473 2e65 6e64 2829 293b  _buckets.end());
    │ │ │ +0006ab50: 2069 2021 3d20 656e 643b 202b 2b69 290a   i != end; ++i).
    │ │ │ +0006ab60: 097b 0a09 0966 6f72 2028 6175 746f 206a  .{...for (auto j
    │ │ │ +0006ab70: 203d 2069 2d26 6774 3b72 6570 6c61 6365   = i->replace
    │ │ │ +0006ab80: 6d65 6e74 732e 6265 6769 6e28 293b 206a  ments.begin(); j
    │ │ │ +0006ab90: 2021 3d20 692d 2667 743b 7265 706c 6163   != i->replac
    │ │ │ +0006aba0: 656d 656e 7473 2e65 6e64 2829 3b20 2b2b  ements.end(); ++
    │ │ │ +0006abb0: 6a29 0a09 097b 0a09 0909 6966 2028 6a2d  j)...{....if (j-
    │ │ │ +0006abc0: 2667 743b 6164 6472 2829 2021 3d20 6570  >addr() != ep
    │ │ │ +0006abd0: 2e61 6464 7265 7373 2829 2920 636f 6e74  .address()) cont
    │ │ │ +0006abe0: 696e 7565 3b0a 0909 0969 6620 286a 2d26  inue;....if (j-&
    │ │ │ +0006abf0: 6774 3b70 6f72 7428 2920 213d 2065 702e  gt;port() != ep.
    │ │ │ +0006ac00: 706f 7274 2829 2920 636f 6e74 696e 7565  port()) continue
    │ │ │ +0006ac10: 3b0a 0909 0972 6574 7572 6e20 7374 643a  ;....return std:
    │ │ │ +0006ac20: 3a6d 616b 655f 7475 706c 6528 2661 6d70  :make_tuple(&
    │ │ │ +0006ac30: 3b2a 6a2c 2069 2c20 2661 6d70 3b69 2d26  ;*j, i, &i-&
    │ │ │ +0006ac40: 6774 3b72 6570 6c61 6365 6d65 6e74 7329  gt;replacements)
    │ │ │ +0006ac50: 3b0a 0909 7d0a 0909 666f 7220 2861 7574  ;...}...for (aut
    │ │ │ +0006ac60: 6f20 6a20 3d20 692d 2667 743b 6c69 7665  o j = i->live
    │ │ │ +0006ac70: 5f6e 6f64 6573 2e62 6567 696e 2829 3b20  _nodes.begin(); 
    │ │ │ +0006ac80: 6a20 213d 2069 2d26 6774 3b6c 6976 655f  j != i->live_
    │ │ │ +0006ac90: 6e6f 6465 732e 656e 6428 293b 202b 2b6a  nodes.end(); ++j
    │ │ │ +0006aca0: 290a 0909 7b0a 0909 0969 6620 286a 2d26  )...{....if (j-&
    │ │ │ +0006acb0: 6774 3b61 6464 7228 2920 213d 2065 702e  gt;addr() != ep.
    │ │ │ +0006acc0: 6164 6472 6573 7328 2929 2063 6f6e 7469  address()) conti
    │ │ │ +0006acd0: 6e75 653b 0a09 0909 6966 2028 6a2d 2667  nue;....if (j-&g
    │ │ │ +0006ace0: 743b 706f 7274 2829 2021 3d20 6570 2e70  t;port() != ep.p
    │ │ │ +0006acf0: 6f72 7428 2929 2063 6f6e 7469 6e75 653b  ort()) continue;
    │ │ │ +0006ad00: 0a09 0909 7265 7475 726e 2073 7464 3a3a  ....return std::
    │ │ │ +0006ad10: 6d61 6b65 5f74 7570 6c65 2826 616d 703b  make_tuple(&
    │ │ │ +0006ad20: 2a6a 2c20 692c 2026 616d 703b 692d 2667  *j, i, &i-&g
    │ │ │ +0006ad30: 743b 6c69 7665 5f6e 6f64 6573 293b 0a09  t;live_nodes);..
    │ │ │ +0006ad40: 097d 0a09 7d0a 0972 6574 7572 6e20 7374  .}..}..return st
    │ │ │ +0006ad50: 643a 3a74 7570 6c65 266c 743b 6e6f 6465  d::tuple<node
    │ │ │ +0006ad60: 5f65 6e74 7279 2a2c 2072 6f75 7469 6e67  _entry*, routing
    │ │ │ +0006ad70: 5f74 6162 6c65 3a3a 7461 626c 655f 743a  _table::table_t:
    │ │ │ +0006ad80: 3a69 7465 7261 746f 722c 2062 7563 6b65  :iterator, bucke
    │ │ │ +0006ad90: 745f 742a 2667 743b 0a09 7b6e 756c 6c70  t_t*>..{nullp
    │ │ │ +0006ada0: 7472 2c20 6d5f 6275 636b 6574 732e 656e  tr, m_buckets.en
    │ │ │ +0006adb0: 6428 292c 206e 756c 6c70 7472 7d3b 0a7d  d(), nullptr};.}
    │ │ │ +0006adc0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +0006adf0: 766f 6964 2072 6f75 7469 6e67 5f74 6162 void routing_tab │ │ │ +0006ae00: 6c65 3a3a 6669 6c6c 5f66 726f 6d5f 7265 le::fill_from_re │ │ │ +0006ae10: 706c 6163 656d 656e 7473 2874 6162 6c65 placements(table │ │ │ +0006ae20: 5f74 3a3a 6974 6572 6174 6f72 2062 7563 _t::iterator buc │ │ │ +0006ae30: 6b65 7429 0a3c 2f64 6976 3e7b 0a09 6275 ket).
    {..bu │ │ │ +0006ae40: 636b 6574 5f74 2661 6d70 3b20 6220 3d20 cket_t& b = │ │ │ +0006ae50: 6275 636b 6574 2d26 6774 3b6c 6976 655f bucket->live_ │ │ │ +0006ae60: 6e6f 6465 733b 0a09 6275 636b 6574 5f74 nodes;..bucket_t │ │ │ +0006ae70: 2661 6d70 3b20 7262 203d 2062 7563 6b65 & rb = bucke │ │ │ +0006ae80: 742d 2667 743b 7265 706c 6163 656d 656e t->replacemen │ │ │ +0006ae90: 7473 3b0a 0969 6e74 2063 6f6e 7374 2062 ts;..int const b │ │ │ +0006aea0: 7563 6b65 745f 7369 7a65 203d 2062 7563 ucket_size = buc │ │ │ +0006aeb0: 6b65 745f 6c69 6d69 7428 696e 7428 7374 ket_limit(int(st │ │ │ +0006aec0: 643a 3a64 6973 7461 6e63 6528 6d5f 6275 d::distance(m_bu │ │ │ +0006aed0: 636b 6574 732e 6265 6769 6e28 292c 2062 ckets.begin(), b │ │ │ +0006aee0: 7563 6b65 7429 2929 3b0a 0a09 6966 2028 ucket)));...if ( │ │ │ +0006aef0: 696e 7428 622e 7369 7a65 2829 2920 2667 int(b.size()) &g │ │ │ +0006af00: 743b 3d20 6275 636b 6574 5f73 697a 6529 t;= bucket_size) │ │ │ +0006af10: 2072 6574 7572 6e3b 0a0a 092f 2f20 736f return;...// so │ │ │ +0006af20: 7274 2062 7920 5254 5420 6669 7273 742c rt by RTT first, │ │ │ +0006af30: 2074 6f20 6669 6e64 2074 6865 206e 6f64 to find the nod │ │ │ +0006af40: 6520 7769 7468 2074 6865 206c 6f77 6573 e with the lowes │ │ │ +0006af50: 740a 092f 2f20 5254 5420 7468 6174 2069 t..// RTT that i │ │ │ +0006af60: 7320 7069 6e67 6564 0a09 7374 643a 3a73 s pinged..std::s │ │ │ +0006af70: 6f72 7428 7262 2e62 6567 696e 2829 2c20 ort(rb.begin(), │ │ │ +0006af80: 7262 2e65 6e64 2829 293b 0a0a 0977 6869 rb.end());...whi │ │ │ +0006af90: 6c65 2028 696e 7428 622e 7369 7a65 2829 le (int(b.size() │ │ │ +0006afa0: 2920 266c 743b 2062 7563 6b65 745f 7369 ) < bucket_si │ │ │ +0006afb0: 7a65 2026 616d 703b 2661 6d70 3b20 2172 ze && !r │ │ │ +0006afc0: 622e 656d 7074 7928 2929 0a09 7b0a 0909 b.empty())..{... │ │ │ +0006afd0: 6175 746f 206a 203d 2073 7464 3a3a 6669 auto j = std::fi │ │ │ +0006afe0: 6e64 5f69 6628 7262 2e62 6567 696e 2829 nd_if(rb.begin() │ │ │ +0006aff0: 2c20 7262 2e65 6e64 2829 2c20 7374 643a , rb.end(), std: │ │ │ +0006b000: 3a62 696e 6428 2661 6d70 3b6e 6f64 655f :bind(&node_ │ │ │ +0006b010: 656e 7472 793a 3a70 696e 6765 642c 205f entry::pinged, _ │ │ │ +0006b020: 3129 293b 0a09 0969 6620 286a 203d 3d20 1));...if (j == │ │ │ +0006b030: 7262 2e65 6e64 2829 2920 6272 6561 6b3b rb.end()) break; │ │ │ +0006b040: 0a09 0962 2e70 7573 685f 6261 636b 282a ...b.push_back(* │ │ │ +0006b050: 6a29 3b0a 0909 7262 2e65 7261 7365 286a j);...rb.erase(j │ │ │ +0006b060: 293b 0a09 7d0a 7d0a 0a76 6f69 6420 726f );..}.}..void ro │ │ │ +0006b070: 7574 696e 675f 7461 626c 653a 3a70 7275 uting_table::pru │ │ │ +0006b080: 6e65 5f65 6d70 7479 5f62 7563 6b65 7428 ne_empty_bucket( │ │ │ +0006b090: 290a 7b0a 0969 6620 286d 5f62 7563 6b65 ).{..if (m_bucke │ │ │ +0006b0a0: 7473 2e62 6163 6b28 292e 6c69 7665 5f6e ts.back().live_n │ │ │ +0006b0b0: 6f64 6573 2e65 6d70 7479 2829 0a09 0926 odes.empty()...& │ │ │ +0006b0c0: 616d 703b 2661 6d70 3b20 6d5f 6275 636b amp;& m_buck │ │ │ +0006b0d0: 6574 732e 6261 636b 2829 2e72 6570 6c61 ets.back().repla │ │ │ +0006b0e0: 6365 6d65 6e74 732e 656d 7074 7928 2929 cements.empty()) │ │ │ +0006b0f0: 0a09 7b0a 0909 6d5f 6275 636b 6574 732e ..{...m_buckets. │ │ │ +0006b100: 6572 6173 6528 6d5f 6275 636b 6574 732e erase(m_buckets. │ │ │ +0006b110: 656e 6428 2920 2d20 3129 3b0a 097d 0a7d end() - 1);..}.} │ │ │ +0006b120: 0a0a 766f 6964 2072 6f75 7469 6e67 5f74 ..void routing_t │ │ │ +0006b130: 6162 6c65 3a3a 7265 6d6f 7665 5f6e 6f64 able::remove_nod │ │ │ +0006b140: 6528 6e6f 6465 5f65 6e74 7279 2a20 6e2c e(node_entry* n, │ │ │ +0006b150: 2062 7563 6b65 745f 742a 2062 290a 3c2f bucket_t* b).r │ │ │ +0006b190: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +0006b1a0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +0006b1d0: 6b61 6465 6d6c 6961 2f6e 6f64 655f 6964 kademlia/node_id │ │ │ +0006b1e0: 2e63 7070 3a36 363c 2f61 3e3c 2f74 643e .cpp:66 │ │ │ +0006b1f0: 3c74 643e 6974 2773 2061 206c 6974 746c it's a littl │ │ │ +0006b200: 6520 6269 7420 7765 6972 6420 746f 2072 e bit weird to r │ │ │ +0006b210: 6574 7572 6e20 3135 3920 2d20 6c65 6164 eturn 159 - lead │ │ │ +0006b220: 696e 6720 7a65 726f 6573 2e20 4974 2073 ing zeroes. It s │ │ │ +0006b230: 686f 756c 6420 7072 6f62 6162 6c79 2062 hould probably b │ │ │ +0006b240: 6520 3136 3020 2d20 6c65 6164 696e 6720 e 160 - leading │ │ │ +0006b250: 7a65 726f 6573 2c20 6275 7420 616c 6c20 zeroes, but all │ │ │ +0006b260: 6f74 6865 7220 636f 6465 2069 6e20 6865 other code in he │ │ │ +0006b270: 7265 2069 7320 7475 6e65 6420 746f 2074 re is tuned to t │ │ │ +0006b280: 6869 7320 6578 7065 6374 6174 696f 6e20 his expectation │ │ │ +0006b290: 6e6f 772c 2061 6e64 2069 7420 646f 6573 now, and it does │ │ │ +0006b2a0: 6e27 7420 7265 616c 6c79 206d 6174 7465 n't really matte │ │ │ +0006b2b0: 7220 286f 7468 6572 2074 6861 6e20 636f r (other than co │ │ │ +0006b2c0: 6d70 6c65 7869 7479 293c 2f74 643e 3c2f mplexity)

    it's a li │ │ │ +0006b320: 7474 6c65 2062 6974 2077 6569 7264 2074 ttle bit weird t │ │ │ +0006b330: 6f20 7265 7475 726e 2031 3539 202d 206c o return 159 - l │ │ │ +0006b340: 6561 6469 6e67 207a 6572 6f65 732e 2049 eading zeroes. I │ │ │ +0006b350: 7420 7368 6f75 6c64 0a70 726f 6261 626c t should.probabl │ │ │ +0006b360: 7920 6265 2031 3630 202d 206c 6561 6469 y be 160 - leadi │ │ │ +0006b370: 6e67 207a 6572 6f65 732c 2062 7574 2061 ng zeroes, but a │ │ │ +0006b380: 6c6c 206f 7468 6572 2063 6f64 6520 696e ll other code in │ │ │ +0006b390: 2068 6572 6520 6973 2074 756e 6564 2074 here is tuned t │ │ │ +0006b3a0: 6f0a 7468 6973 2065 7870 6563 7461 7469 o.this expectati │ │ │ +0006b3b0: 6f6e 206e 6f77 2c20 616e 6420 6974 2064 on now, and it d │ │ │ +0006b3c0: 6f65 736e 2774 2072 6561 6c6c 7920 6d61 oesn't really ma │ │ │ +0006b3d0: 7474 6572 2028 6f74 6865 7220 7468 616e tter (other than │ │ │ +0006b3e0: 2063 6f6d 706c 6578 6974 7929 3c2f 6832 complexity)

    ../src/kade │ │ │ +0006b400: 6d6c 6961 2f6e 6f64 655f 6964 2e63 7070 mlia/node_id.cpp │ │ │ +0006b410: 3a36 363c 2f68 343e 3c70 7265 2073 7479 :66

    .// returns th
    │ │ │ +0006b460: 6520 6469 7374 616e 6365 2062 6574 7765  e distance betwe
    │ │ │ +0006b470: 656e 2074 6865 2074 776f 206e 6f64 6573  en the two nodes
    │ │ │ +0006b480: 0a2f 2f20 7573 696e 6720 7468 6520 6b61  .// using the ka
    │ │ │ +0006b490: 6465 6d6c 6961 2058 4f52 2d6d 6574 7269  demlia XOR-metri
    │ │ │ +0006b4a0: 630a 6e6f 6465 5f69 6420 6469 7374 616e  c.node_id distan
    │ │ │ +0006b4b0: 6365 286e 6f64 655f 6964 2063 6f6e 7374  ce(node_id const
    │ │ │ +0006b4c0: 2661 6d70 3b20 6e31 2c20 6e6f 6465 5f69  & n1, node_i
    │ │ │ +0006b4d0: 6420 636f 6e73 7426 616d 703b 206e 3229  d const& n2)
    │ │ │ +0006b4e0: 0a7b 0a09 7265 7475 726e 206e 3120 5e20  .{..return n1 ^ 
    │ │ │ +0006b4f0: 6e32 3b0a 7d0a 0a2f 2f20 7265 7475 726e  n2;.}..// return
    │ │ │ +0006b500: 7320 7472 7565 2069 663a 2064 6973 7461  s true if: dista
    │ │ │ +0006b510: 6e63 6528 6e31 2c20 7265 6629 2026 6c74  nce(n1, ref) <
    │ │ │ +0006b520: 3b20 6469 7374 616e 6365 286e 322c 2072  ; distance(n2, r
    │ │ │ +0006b530: 6566 290a 626f 6f6c 2063 6f6d 7061 7265  ef).bool compare
    │ │ │ +0006b540: 5f72 6566 286e 6f64 655f 6964 2063 6f6e  _ref(node_id con
    │ │ │ +0006b550: 7374 2661 6d70 3b20 6e31 2c20 6e6f 6465  st& n1, node
    │ │ │ +0006b560: 5f69 6420 636f 6e73 7426 616d 703b 206e  _id const& n
    │ │ │ +0006b570: 322c 206e 6f64 655f 6964 2063 6f6e 7374  2, node_id const
    │ │ │ +0006b580: 2661 6d70 3b20 7265 6629 0a7b 0a09 6e6f  & ref).{..no
    │ │ │ +0006b590: 6465 5f69 6420 636f 6e73 7420 6c68 7320  de_id const lhs 
    │ │ │ +0006b5a0: 3d20 6e31 205e 2072 6566 3b0a 096e 6f64  = n1 ^ ref;..nod
    │ │ │ +0006b5b0: 655f 6964 2063 6f6e 7374 2072 6873 203d  e_id const rhs =
    │ │ │ +0006b5c0: 206e 3220 5e20 7265 663b 0a09 7265 7475   n2 ^ ref;..retu
    │ │ │ +0006b5d0: 726e 206c 6873 2026 6c74 3b20 7268 733b  rn lhs < rhs;
    │ │ │ +0006b5e0: 0a7d 0a0a 2f2f 2072 6574 7572 6e73 206e  .}..// returns n
    │ │ │ +0006b5f0: 2069 6e3a 2032 5e6e 2026 6c74 3b3d 2064   in: 2^n <= d
    │ │ │ +0006b600: 6973 7461 6e63 6528 6e31 2c20 6e32 2920  istance(n1, n2) 
    │ │ │ +0006b610: 266c 743b 2032 5e28 6e2b 3129 0a2f 2f20  < 2^(n+1).// 
    │ │ │ +0006b620: 7573 6566 756c 2066 6f72 2066 696e 6469  useful for findi
    │ │ │ +0006b630: 6e67 206f 7574 2077 6869 6368 2062 7563  ng out which buc
    │ │ │ +0006b640: 6b65 7420 6120 6e6f 6465 2062 656c 6f6e  ket a node belon
    │ │ │ +0006b650: 6773 2074 6f0a 696e 7420 6469 7374 616e  gs to.int distan
    │ │ │ +0006b660: 6365 5f65 7870 286e 6f64 655f 6964 2063  ce_exp(node_id c
    │ │ │ +0006b670: 6f6e 7374 2661 6d70 3b20 6e31 2c20 6e6f  onst& n1, no
    │ │ │ +0006b680: 6465 5f69 6420 636f 6e73 7426 616d 703b  de_id const&
    │ │ │ +0006b690: 206e 3229 0a7b 0a3c 6469 7620 7374 796c   n2).{.
    .return std │ │ │ +0006b6d0: 3a3a 6d61 7828 3135 3920 2d20 6469 7374 ::max(159 - dist │ │ │ +0006b6e0: 616e 6365 286e 312c 206e 3229 2e63 6f75 ance(n1, n2).cou │ │ │ +0006b6f0: 6e74 5f6c 6561 6469 6e67 5f7a 6572 6f65 nt_leading_zeroe │ │ │ +0006b700: 7328 292c 2030 293b 0a3c 2f64 6976 3e7d s(), 0);.
    } │ │ │ +0006b710: 0a0a 696e 7420 6d69 6e5f 6469 7374 616e ..int min_distan │ │ │ +0006b720: 6365 5f65 7870 286e 6f64 655f 6964 2063 ce_exp(node_id c │ │ │ +0006b730: 6f6e 7374 2661 6d70 3b20 6e31 2c20 7374 onst& n1, st │ │ │ +0006b740: 643a 3a76 6563 746f 7226 6c74 3b6e 6f64 d::vector<nod │ │ │ +0006b750: 655f 6964 2667 743b 2063 6f6e 7374 2661 e_id> const&a │ │ │ +0006b760: 6d70 3b20 6964 7329 0a7b 0a09 544f 5252 mp; ids).{..TORR │ │ │ +0006b770: 454e 545f 4153 5345 5254 2869 6473 2e73 ENT_ASSERT(ids.s │ │ │ +0006b780: 697a 6528 2920 2667 743b 2030 293b 0a0a ize() > 0);.. │ │ │ +0006b790: 0969 6e74 206d 696e 203d 2031 3630 3b20 .int min = 160; │ │ │ +0006b7a0: 2f2f 2073 6565 2064 6973 7461 6e63 655f // see distance_ │ │ │ +0006b7b0: 6578 7020 666f 7220 7468 6520 7768 7920 exp for the why │ │ │ +0006b7c0: 6f66 2074 6869 7320 636f 6e73 7461 6e74 of this constant │ │ │ +0006b7d0: 0a09 666f 7220 2861 7574 6f20 636f 6e73 ..for (auto cons │ │ │ +0006b7e0: 7426 616d 703b 206e 6f64 655f 6964 203a t& node_id : │ │ │ +0006b7f0: 2069 6473 290a 097b 0a09 096d 696e 203d ids)..{...min = │ │ │ +0006b800: 2073 7464 3a3a 6d69 6e28 6d69 6e2c 2064 std::min(min, d │ │ │ +0006b810: 6973 7461 6e63 655f 6578 7028 6e31 2c20 istance_exp(n1, │ │ │ +0006b820: 6e6f 6465 5f69 6429 293b 0a09 7d0a 0a09 node_id));..}... │ │ │ +0006b830: 7265 7475 726e 206d 696e 3b0a 7d0a 0a6e return min;.}..n │ │ │ +0006b840: 6f64 655f 6964 2067 656e 6572 6174 655f ode_id generate_ │ │ │ +0006b850: 6964 5f69 6d70 6c28 6164 6472 6573 7320 id_impl(address │ │ │ +0006b860: 636f 6e73 7426 616d 703b 2069 705f 2c20 const& ip_, │ │ │ +0006b870: 7374 643a 3a75 696e 7433 325f 7420 7229 std::uint32_t r) │ │ │ +0006b880: 0a7b 0a09 7374 643a 3a75 696e 7438 5f74 .{..std::uint8_t │ │ │ +0006b890: 2a20 6970 203d 206e 756c 6c70 7472 3b0a * ip = nullptr;. │ │ │ +0006b8a0: 0a09 7374 6174 6963 2073 7464 3a3a 7569 ..static std::ui │ │ │ +0006b8b0: 6e74 385f 7420 636f 6e73 7420 7634 6d61 nt8_t const v4ma │ │ │ +0006b8c0: 736b 5b5d 203d 207b 2030 7830 332c 2030 sk[] = { 0x03, 0 │ │ │ +0006b8d0: 7830 662c 2030 7833 662c 2030 7866 6620 x0f, 0x3f, 0xff │ │ │ +0006b8e0: 7d3b 0a09 7374 6174 6963 2073 7464 3a3a };..static std:: │ │ │ +0006b8f0: 7569 6e74 385f 7420 636f 6e73 7420 7636 uint8_t const v6 │ │ │ +0006b900: 6d61 736b 5b5d 203d 207b 2030 7830 312c mask[] = { 0x01, │ │ │ +0006b910: 2030 7830 332c 2030 7830 372c 2030 7830 0x03, 0x07, 0x0 │ │ │ +0006b920: 662c 2030 7831 662c 2030 7833 662c 2030 f, 0x1f, 0x3f, 0 │ │ │ +0006b930: 7837 662c 2030 7866 6620 7d3b 0a09 7374 x7f, 0xff };..st │ │ │ +0006b940: 643a 3a75 696e 7438 5f74 2063 6f6e 7374 d::uint8_t const │ │ │ +0006b950: 2a20 6d61 736b 203d 206e 756c 6c70 7472 * mask = nullptr │ │ │ +0006b960: 3b0a 0969 6e74 206e 756d 5f6f 6374 6574 ;..int num_octet │ │ │ +0006b970: 7320 3d20 303b 0a0a 0961 6464 7265 7373 s = 0;...address │ │ │ +0006b980: 5f76 343a 3a62 7974 6573 5f74 7970 6520 _v4::bytes_type │ │ │ +0006b990: 6234 7b7d 3b0a 0961 6464 7265 7373 5f76 b4{};..address_v │ │ │ +0006b9a0: 363a 3a62 7974 6573 5f74 7970 6520 6236 6::bytes_type b6 │ │ │ +0006b9b0: 7b7d 3b0a 0969 6620 2869 705f 2e69 735f {};..if (ip_.is_ │ │ │ +0006b9c0: 7636 2829 290a 097b 0a09 0962 3620 3d20 v6())..{...b6 = │ │ │ +0006b9d0: 6970 5f2e 746f 5f76 3628 292e 746f 5f62 ip_.to_v6().to_b │ │ │ +0006b9e0: 7974 6573 2829 3b0a 0909 6970 203d 2062 ytes();...ip = b │ │ │ +0006b9f0: 362e 6461 7461 2829 3b0a 3c2f 7072 653e 6.data();.
    │ │ │ +0006ba00: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +0006ba30: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +0006ba40: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/kade │ │ │ +0006ba70: 6d6c 6961 2f6e 6f64 652e 6370 703a 3131 mlia/node.cpp:11 │ │ │ +0006ba80: 3737 3c2f 613e 3c2f 7464 3e3c 7464 3e6b 77k │ │ │ +0006ba90: 6565 7020 7468 6520 7265 7475 726e 6564 eep the returned │ │ │ +0006baa0: 2076 616c 7565 2074 6f20 7061 7373 2061 value to pass a │ │ │ +0006bab0: 7320 6120 6c69 6d69 7420 746f 2077 7269 s a limit to wri │ │ │ +0006bac0: 7465 5f6e 6f64 6573 5f65 6e74 7269 6573 te_nodes_entries │ │ │ +0006bad0: 2077 6865 6e20 696d 706c 656d 656e 7465 when implemente │ │ │ +0006bae0: 643c 2f74 643e 3c2f 7472 3e3c 7472 2069 d

    k │ │ │ +0006bb30: 6565 7020 7468 6520 7265 7475 726e 6564 eep the returned │ │ │ +0006bb40: 2076 616c 7565 2074 6f20 7061 7373 2061 value to pass a │ │ │ +0006bb50: 7320 6120 6c69 6d69 740a 746f 2077 7269 s a limit.to wri │ │ │ +0006bb60: 7465 5f6e 6f64 6573 5f65 6e74 7269 6573 te_nodes_entries │ │ │ +0006bb70: 2077 6865 6e20 696d 706c 656d 656e 7465 when implemente │ │ │ +0006bb80: 643c 2f68 323e 3c68 343e 2e2e 2f73 7263 d

    ../src │ │ │ +0006bb90: 2f6b 6164 656d 6c69 612f 6e6f 6465 2e63 /kademlia/node.c │ │ │ +0006bba0: 7070 3a31 3137 373c 2f68 343e 3c70 7265 pp:1177

    ..}..}..el
    │ │ │ +0006bbf0: 7365 2069 6620 2871 7565 7279 203d 3d20  se if (query == 
    │ │ │ +0006bc00: 2273 616d 706c 655f 696e 666f 6861 7368  "sample_infohash
    │ │ │ +0006bc10: 6573 2229 0a09 7b0a 0909 7374 6174 6963  es")..{...static
    │ │ │ +0006bc20: 206b 6579 5f64 6573 635f 7420 636f 6e73   key_desc_t cons
    │ │ │ +0006bc30: 7420 6d73 675f 6465 7363 5b5d 203d 207b  t msg_desc[] = {
    │ │ │ +0006bc40: 0a09 0909 7b22 7461 7267 6574 222c 2062  ....{"target", b
    │ │ │ +0006bc50: 6465 636f 6465 5f6e 6f64 653a 3a73 7472  decode_node::str
    │ │ │ +0006bc60: 696e 675f 742c 2032 302c 2030 7d2c 0a09  ing_t, 20, 0},..
    │ │ │ +0006bc70: 0909 7b22 7761 6e74 222c 2062 6465 636f  ..{"want", bdeco
    │ │ │ +0006bc80: 6465 5f6e 6f64 653a 3a6c 6973 745f 742c  de_node::list_t,
    │ │ │ +0006bc90: 2030 2c20 6b65 795f 6465 7363 5f74 3a3a   0, key_desc_t::
    │ │ │ +0006bca0: 6f70 7469 6f6e 616c 7d2c 0a09 097d 3b0a  optional},...};.
    │ │ │ +0006bcb0: 0a09 0962 6465 636f 6465 5f6e 6f64 6520  ...bdecode_node 
    │ │ │ +0006bcc0: 6d73 675f 6b65 7973 5b32 5d3b 0a09 0969  msg_keys[2];...i
    │ │ │ +0006bcd0: 6620 2821 7665 7269 6679 5f6d 6573 7361  f (!verify_messa
    │ │ │ +0006bce0: 6765 2861 7267 5f65 6e74 2c20 6d73 675f  ge(arg_ent, msg_
    │ │ │ +0006bcf0: 6465 7363 2c20 6d73 675f 6b65 7973 2c20  desc, msg_keys, 
    │ │ │ +0006bd00: 6572 726f 725f 7374 7269 6e67 2929 0a09  error_string))..
    │ │ │ +0006bd10: 097b 0a09 0909 6d5f 636f 756e 7465 7273  .{....m_counters
    │ │ │ +0006bd20: 2e69 6e63 5f73 7461 7473 5f63 6f75 6e74  .inc_stats_count
    │ │ │ +0006bd30: 6572 2863 6f75 6e74 6572 733a 3a64 6874  er(counters::dht
    │ │ │ +0006bd40: 5f69 6e76 616c 6964 5f73 616d 706c 655f  _invalid_sample_
    │ │ │ +0006bd50: 696e 666f 6861 7368 6573 293b 0a09 0909  infohashes);....
    │ │ │ +0006bd60: 696e 636f 6d69 6e67 5f65 7272 6f72 2865  incoming_error(e
    │ │ │ +0006bd70: 2c20 6572 726f 725f 7374 7269 6e67 293b  , error_string);
    │ │ │ +0006bd80: 0a09 0909 7265 7475 726e 3b0a 0909 7d0a  ....return;...}.
    │ │ │ +0006bd90: 0a09 096d 5f63 6f75 6e74 6572 732e 696e  ...m_counters.in
    │ │ │ +0006bda0: 635f 7374 6174 735f 636f 756e 7465 7228  c_stats_counter(
    │ │ │ +0006bdb0: 636f 756e 7465 7273 3a3a 6468 745f 7361  counters::dht_sa
    │ │ │ +0006bdc0: 6d70 6c65 5f69 6e66 6f68 6173 6865 735f  mple_infohashes_
    │ │ │ +0006bdd0: 696e 293b 0a09 0973 6861 315f 6861 7368  in);...sha1_hash
    │ │ │ +0006bde0: 2063 6f6e 7374 2074 6172 6765 7428 6d73   const target(ms
    │ │ │ +0006bdf0: 675f 6b65 7973 5b30 5d2e 7374 7269 6e67  g_keys[0].string
    │ │ │ +0006be00: 5f70 7472 2829 293b 0a0a 3c64 6976 2073  _ptr());..
    ..m_stor │ │ │ +0006be40: 6167 652e 6765 745f 696e 666f 6861 7368 age.get_infohash │ │ │ +0006be50: 6573 5f73 616d 706c 6528 7265 706c 7929 es_sample(reply) │ │ │ +0006be60: 3b0a 3c2f 6469 763e 0a09 0977 7269 7465 ;.
    ...write │ │ │ +0006be70: 5f6e 6f64 6573 5f65 6e74 7269 6573 2874 _nodes_entries(t │ │ │ +0006be80: 6172 6765 742c 206d 7367 5f6b 6579 735b arget, msg_keys[ │ │ │ +0006be90: 315d 2c20 7265 706c 7929 3b0a 097d 0a09 1], reply);..}.. │ │ │ +0006bea0: 656c 7365 0a09 7b0a 0909 2f2f 2069 6620 else..{...// if │ │ │ +0006beb0: 7765 2064 6f6e 2774 2072 6563 6f67 6e69 we don't recogni │ │ │ +0006bec0: 7a65 2074 6865 206d 6573 7361 6765 2062 ze the message b │ │ │ +0006bed0: 7574 2074 6865 7265 2773 2061 0a09 092f ut there's a.../ │ │ │ +0006bee0: 2f20 2774 6172 6765 7427 206f 7220 2769 / 'target' or 'i │ │ │ +0006bef0: 6e66 6f5f 6861 7368 2720 696e 2074 6865 nfo_hash' in the │ │ │ +0006bf00: 2061 7267 756d 656e 7473 2c20 7472 6561 arguments, trea │ │ │ +0006bf10: 7420 6974 0a09 092f 2f20 6173 2066 696e t it...// as fin │ │ │ +0006bf20: 645f 6e6f 6465 2074 6f20 6265 2066 7574 d_node to be fut │ │ │ +0006bf30: 7572 6520 636f 6d70 6174 6962 6c65 0a09 ure compatible.. │ │ │ +0006bf40: 0962 6465 636f 6465 5f6e 6f64 6520 7461 .bdecode_node ta │ │ │ +0006bf50: 7267 6574 5f65 6e74 203d 2061 7267 5f65 rget_ent = arg_e │ │ │ +0006bf60: 6e74 2e64 6963 745f 6669 6e64 5f73 7472 nt.dict_find_str │ │ │ +0006bf70: 696e 6728 2274 6172 6765 7422 293b 0a09 ing("target");.. │ │ │ +0006bf80: 0969 6620 2821 7461 7267 6574 5f65 6e74 .if (!target_ent │ │ │ +0006bf90: 207c 7c20 7461 7267 6574 5f65 6e74 2e73 || target_ent.s │ │ │ +0006bfa0: 7472 696e 675f 6c65 6e67 7468 2829 2021 tring_length() ! │ │ │ +0006bfb0: 3d20 3230 290a 0909 7b0a 0909 0974 6172 = 20)...{....tar │ │ │ +0006bfc0: 6765 745f 656e 7420 3d20 6172 675f 656e get_ent = arg_en │ │ │ +0006bfd0: 742e 6469 6374 5f66 696e 645f 7374 7269 t.dict_find_stri │ │ │ +0006bfe0: 6e67 2822 696e 666f 5f68 6173 6822 293b ng("info_hash"); │ │ │ +0006bff0: 0a09 0909 6966 2028 2174 6172 6765 745f ....if (!target_ │ │ │ +0006c000: 656e 7420 7c7c 2074 6172 6765 745f 656e ent || target_en │ │ │ +0006c010: 742e 7374 7269 6e67 5f6c 656e 6774 6828 t.string_length( │ │ │ +0006c020: 2920 213d 2032 3029 0a09 0909 7b0a 0909 ) != 20)....{... │ │ │ +0006c030: 0909 696e 636f 6d69 6e67 5f65 7272 6f72 ..incoming_error │ │ │ +0006c040: 2865 2c20 2275 6e6b 6e6f 776e 206d 6573 (e, "unknown mes │ │ │ +0006c050: 7361 6765 2229 3b0a 0909 0909 7265 7475 sage");.....retu │ │ │ +0006c060: 726e 3b0a 0909 097d 0a09 097d 0a0a 0909 rn;....}...}.... │ │ │ +0006c070: 7368 6131 5f68 6173 6820 636f 6e73 7420 sha1_hash const │ │ │ +0006c080: 7461 7267 6574 2874 6172 6765 745f 656e target(target_en │ │ │ +0006c090: 742e 7374 7269 6e67 5f70 7472 2829 293b t.string_ptr()); │ │ │ +0006c0a0: 0a09 092f 2f20 616c 7761 7973 2072 6574 ...// always ret │ │ │ +0006c0b0: 7572 6e20 6e6f 6465 7320 6173 2077 656c urn nodes as wel │ │ │ +0006c0c0: 6c20 6173 2070 6565 7273 0a09 0977 7269 l as peers...wri │ │ │ +0006c0d0: 7465 5f6e 6f64 6573 5f65 6e74 7269 6573 te_nodes_entries │ │ │ +0006c0e0: 2874 6172 6765 742c 2061 7267 5f65 6e74 (target, arg_ent │ │ │ +0006c0f0: 2e64 6963 745f 6669 6e64 5f6c 6973 7428 .dict_find_list( │ │ │ +0006c100: 2277 616e 7422 292c 2072 6570 6c79 293b "want"), reply); │ │ │ +0006c110: 0a09 7d0a 7d0a 0a3c 2f70 7265 3e3c 2f74 ..}.}..
    relevanc │ │ │ +0006c150: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/kademli │ │ │ +0006c190: 612f 6e6f 6465 2e63 7070 3a31 3230 353c a/node.cpp:1205< │ │ │ +0006c1a0: 2f61 3e3c 2f74 643e 3c74 643e 6c69 6d69 /a>limi │ │ │ +0006c1b0: 7420 6e75 6d62 6572 206f 6620 656e 7472 t number of entr │ │ │ +0006c1c0: 6965 7320 696e 2074 6865 2072 6573 756c ies in the resul │ │ │ +0006c1d0: 743c 2f74 643e 3c2f 7472 3e3c 7472 2069 t

    l │ │ │ +0006c220: 696d 6974 206e 756d 6265 7220 6f66 2065 imit number of e │ │ │ +0006c230: 6e74 7269 6573 2069 6e20 7468 6520 7265 ntries in the re │ │ │ +0006c240: 7375 6c74 3c2f 6832 3e3c 6834 3e2e 2e2f sult

    ../ │ │ │ +0006c250: 7372 632f 6b61 6465 6d6c 6961 2f6e 6f64 src/kademlia/nod │ │ │ +0006c260: 652e 6370 703a 3132 3035 3c2f 6834 3e3c e.cpp:1205

    < │ │ │ +0006c270: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +0006c280: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +0006c290: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +0006c2a0: 7820 2364 6464 3b22 3e09 092f 2f20 6966 x #ddd;">..// if │ │ │ +0006c2b0: 2077 6520 646f 6e27 7420 7265 636f 676e we don't recogn │ │ │ +0006c2c0: 697a 6520 7468 6520 6d65 7373 6167 6520 ize the message │ │ │ +0006c2d0: 6275 7420 7468 6572 6527 7320 610a 0909 but there's a... │ │ │ +0006c2e0: 2f2f 2027 7461 7267 6574 2720 6f72 2027 // 'target' or ' │ │ │ +0006c2f0: 696e 666f 5f68 6173 6827 2069 6e20 7468 info_hash' in th │ │ │ +0006c300: 6520 6172 6775 6d65 6e74 732c 2074 7265 e arguments, tre │ │ │ +0006c310: 6174 2069 740a 0909 2f2f 2061 7320 6669 at it...// as fi │ │ │ +0006c320: 6e64 5f6e 6f64 6520 746f 2062 6520 6675 nd_node to be fu │ │ │ +0006c330: 7475 7265 2063 6f6d 7061 7469 626c 650a ture compatible. │ │ │ +0006c340: 0909 6264 6563 6f64 655f 6e6f 6465 2074 ..bdecode_node t │ │ │ +0006c350: 6172 6765 745f 656e 7420 3d20 6172 675f arget_ent = arg_ │ │ │ +0006c360: 656e 742e 6469 6374 5f66 696e 645f 7374 ent.dict_find_st │ │ │ +0006c370: 7269 6e67 2822 7461 7267 6574 2229 3b0a ring("target");. │ │ │ +0006c380: 0909 6966 2028 2174 6172 6765 745f 656e ..if (!target_en │ │ │ +0006c390: 7420 7c7c 2074 6172 6765 745f 656e 742e t || target_ent. │ │ │ +0006c3a0: 7374 7269 6e67 5f6c 656e 6774 6828 2920 string_length() │ │ │ +0006c3b0: 213d 2032 3029 0a09 097b 0a09 0909 7461 != 20)...{....ta │ │ │ +0006c3c0: 7267 6574 5f65 6e74 203d 2061 7267 5f65 rget_ent = arg_e │ │ │ +0006c3d0: 6e74 2e64 6963 745f 6669 6e64 5f73 7472 nt.dict_find_str │ │ │ +0006c3e0: 696e 6728 2269 6e66 6f5f 6861 7368 2229 ing("info_hash") │ │ │ +0006c3f0: 3b0a 0909 0969 6620 2821 7461 7267 6574 ;....if (!target │ │ │ +0006c400: 5f65 6e74 207c 7c20 7461 7267 6574 5f65 _ent || target_e │ │ │ +0006c410: 6e74 2e73 7472 696e 675f 6c65 6e67 7468 nt.string_length │ │ │ +0006c420: 2829 2021 3d20 3230 290a 0909 097b 0a09 () != 20)....{.. │ │ │ +0006c430: 0909 0969 6e63 6f6d 696e 675f 6572 726f ...incoming_erro │ │ │ +0006c440: 7228 652c 2022 756e 6b6e 6f77 6e20 6d65 r(e, "unknown me │ │ │ +0006c450: 7373 6167 6522 293b 0a09 0909 0972 6574 ssage");.....ret │ │ │ +0006c460: 7572 6e3b 0a09 0909 7d0a 0909 7d0a 0a09 urn;....}...}... │ │ │ +0006c470: 0973 6861 315f 6861 7368 2063 6f6e 7374 .sha1_hash const │ │ │ +0006c480: 2074 6172 6765 7428 7461 7267 6574 5f65 target(target_e │ │ │ +0006c490: 6e74 2e73 7472 696e 675f 7074 7228 2929 nt.string_ptr()) │ │ │ +0006c4a0: 3b0a 0909 2f2f 2061 6c77 6179 7320 7265 ;...// always re │ │ │ +0006c4b0: 7475 726e 206e 6f64 6573 2061 7320 7765 turn nodes as we │ │ │ +0006c4c0: 6c6c 2061 7320 7065 6572 730a 0909 7772 ll as peers...wr │ │ │ +0006c4d0: 6974 655f 6e6f 6465 735f 656e 7472 6965 ite_nodes_entrie │ │ │ +0006c4e0: 7328 7461 7267 6574 2c20 6172 675f 656e s(target, arg_en │ │ │ +0006c4f0: 742e 6469 6374 5f66 696e 645f 6c69 7374 t.dict_find_list │ │ │ +0006c500: 2822 7761 6e74 2229 2c20 7265 706c 7929 ("want"), reply) │ │ │ +0006c510: 3b0a 097d 0a7d 0a0a 3c64 6976 2073 7479 ;..}.}..
    void node: │ │ │ +0006c550: 3a77 7269 7465 5f6e 6f64 6573 5f65 6e74 :write_nodes_ent │ │ │ +0006c560: 7269 6573 2873 6861 315f 6861 7368 2063 ries(sha1_hash c │ │ │ +0006c570: 6f6e 7374 2661 6d70 3b20 696e 666f 5f68 onst& info_h │ │ │ +0006c580: 6173 680a 3c2f 6469 763e 092c 2062 6465 ash.
    ., bde │ │ │ +0006c590: 636f 6465 5f6e 6f64 6520 636f 6e73 7426 code_node const& │ │ │ +0006c5a0: 616d 703b 2077 616e 742c 2065 6e74 7279 amp; want, entry │ │ │ +0006c5b0: 2661 6d70 3b20 7229 0a7b 0a09 2f2f 2069 & r).{..// i │ │ │ +0006c5c0: 6620 6e6f 2077 616e 7473 2065 6e74 7279 f no wants entry │ │ │ +0006c5d0: 2077 6173 2073 7065 6369 6669 6564 2c20 was specified, │ │ │ +0006c5e0: 696e 636c 7564 6520 6120 6e6f 6465 730a include a nodes. │ │ │ +0006c5f0: 092f 2f20 656e 7472 7920 6261 7365 6420 .// entry based │ │ │ +0006c600: 6f6e 2074 6865 2070 726f 746f 636f 6c20 on the protocol │ │ │ +0006c610: 7468 6520 7265 7175 6573 7420 6361 6d65 the request came │ │ │ +0006c620: 2069 6e20 7769 7468 0a09 6966 2028 7761 in with..if (wa │ │ │ +0006c630: 6e74 2e74 7970 6528 2920 213d 2062 6465 nt.type() != bde │ │ │ +0006c640: 636f 6465 5f6e 6f64 653a 3a6c 6973 745f code_node::list_ │ │ │ +0006c650: 7429 0a09 7b0a 0909 7374 643a 3a76 6563 t)..{...std::vec │ │ │ +0006c660: 746f 7226 6c74 3b6e 6f64 655f 656e 7472 tor<node_entr │ │ │ +0006c670: 7926 6774 3b20 636f 6e73 7420 6e20 3d20 y> const n = │ │ │ +0006c680: 6d5f 7461 626c 652e 6669 6e64 5f6e 6f64 m_table.find_nod │ │ │ +0006c690: 6528 696e 666f 5f68 6173 682c 207b 7d29 e(info_hash, {}) │ │ │ +0006c6a0: 3b0a 0909 725b 7072 6f74 6f63 6f6c 5f6e ;...r[protocol_n │ │ │ +0006c6b0: 6f64 6573 5f6b 6579 2829 5d20 3d20 7772 odes_key()] = wr │ │ │ +0006c6c0: 6974 655f 6e6f 6465 735f 656e 7472 7928 ite_nodes_entry( │ │ │ +0006c6d0: 6e29 3b0a 0909 7265 7475 726e 3b0a 097d n);...return;..} │ │ │ +0006c6e0: 0a0a 092f 2f20 6966 2074 6865 7265 2069 ...// if there i │ │ │ +0006c6f0: 7320 6120 7761 6e74 7320 656e 7472 7920 s a wants entry │ │ │ +0006c700: 7468 656e 2077 6520 6d61 7920 6e65 6564 then we may need │ │ │ +0006c710: 2074 6f20 7265 6163 6820 696e 746f 0a09 to reach into.. │ │ │ +0006c720: 2f2f 2061 6e6f 7468 6572 206e 6f64 6527 // another node' │ │ │ +0006c730: 7320 726f 7574 696e 6720 7461 626c 6520 s routing table │ │ │ +0006c740: 746f 2067 6574 206e 6f64 6573 206f 6620 to get nodes of │ │ │ +0006c750: 7468 6520 7265 7175 6573 7465 6420 7479 the requested ty │ │ │ +0006c760: 7065 0a09 2f2f 2077 6520 7573 6520 6120 pe..// we use a │ │ │ +0006c770: 6d61 7020 6d61 696e 7461 696e 6564 2062 map maintained b │ │ │ +0006c780: 7920 7468 6520 6f77 6e69 6e67 2064 6874 y the owning dht │ │ │ +0006c790: 5f74 7261 636b 6572 2074 6f20 6669 6e64 _tracker to find │ │ │ +0006c7a0: 2074 6865 0a09 2f2f 206e 6f64 6520 6173 the..// node as │ │ │ +0006c7b0: 736f 6369 6174 6564 2077 6974 6820 6561 sociated with ea │ │ │ +0006c7c0: 6368 2073 7472 696e 6720 696e 2074 6865 ch string in the │ │ │ +0006c7d0: 2077 616e 7420 6c69 7374 2c20 7768 6963 want list, whic │ │ │ +0006c7e0: 6820 6d61 790a 092f 2f20 696e 636c 7564 h may..// includ │ │ │ +0006c7f0: 6520 7468 6973 206e 6f64 650a 0966 6f72 e this node..for │ │ │ +0006c800: 2028 696e 7420 6920 3d20 303b 2069 2026 (int i = 0; i & │ │ │ +0006c810: 6c74 3b20 7761 6e74 2e6c 6973 745f 7369 lt; want.list_si │ │ │ +0006c820: 7a65 2829 3b20 2b2b 6929 0a09 7b0a 0909 ze(); ++i)..{... │ │ │ +0006c830: 6264 6563 6f64 655f 6e6f 6465 2077 616e bdecode_node wan │ │ │ +0006c840: 7465 6420 3d20 7761 6e74 2e6c 6973 745f ted = want.list_ │ │ │ +0006c850: 6174 2869 293b 0a09 0969 6620 2877 616e at(i);...if (wan │ │ │ +0006c860: 7465 642e 7479 7065 2829 2021 3d20 6264 ted.type() != bd │ │ │ +0006c870: 6563 6f64 655f 6e6f 6465 3a3a 7374 7269 ecode_node::stri │ │ │ +0006c880: 6e67 5f74 290a 0909 0963 6f6e 7469 6e75 ng_t)....continu │ │ │ +0006c890: 653b 0a09 096e 6f64 652a 2077 616e 7465 e;...node* wante │ │ │ +0006c8a0: 645f 6e6f 6465 203d 206d 5f67 6574 5f66 d_node = m_get_f │ │ │ +0006c8b0: 6f72 6569 676e 5f6e 6f64 6528 696e 666f oreign_node(info │ │ │ +0006c8c0: 5f68 6173 682c 2077 616e 7465 642e 7374 _hash, wanted.st │ │ │ +0006c8d0: 7269 6e67 5f76 616c 7565 2829 2e74 6f5f ring_value().to_ │ │ │ +0006c8e0: 7374 7269 6e67 2829 293b 0a09 0969 6620 string());...if │ │ │ +0006c8f0: 2821 7761 6e74 6564 5f6e 6f64 6529 2063 (!wanted_node) c │ │ │ +0006c900: 6f6e 7469 6e75 653b 0a09 0973 7464 3a3a ontinue;...std:: │ │ │ +0006c910: 7665 6374 6f72 266c 743b 6e6f 6465 5f65 vector<node_e │ │ │ +0006c920: 6e74 7279 2667 743b 2063 6f6e 7374 206e ntry> const n │ │ │ +0006c930: 203d 2077 616e 7465 645f 6e6f 6465 2d26 = wanted_node-& │ │ │ +0006c940: 6774 3b6d 5f74 6162 6c65 2e66 696e 645f gt;m_table.find_ │ │ │ +0006c950: 6e6f 6465 2869 6e66 6f5f 6861 7368 2c20 node(info_hash, │ │ │ +0006c960: 7b7d 293b 0a09 0972 5b77 616e 7465 645f {});...r[wanted_ │ │ │ +0006c970: 6e6f 6465 2d26 6774 3b70 726f 746f 636f node->protoco │ │ │ +0006c980: 6c5f 6e6f 6465 735f 6b65 7928 295d 203d l_nodes_key()] = │ │ │ +0006c990: 2077 7269 7465 5f6e 6f64 6573 5f65 6e74 write_nodes_ent │ │ │ +0006c9a0: 7279 286e 293b 0a09 7d0a 7d0a 0a6e 6f64 ry(n);..}.}..nod │ │ │ +0006c9b0: 653a 3a70 726f 746f 636f 6c5f 6465 7363 e::protocol_desc │ │ │ +0006c9c0: 7269 7074 6f72 2063 6f6e 7374 2661 6d70 riptor const& │ │ │ +0006c9d0: 3b20 6e6f 6465 3a3a 6d61 705f 7072 6f74 ; node::map_prot │ │ │ +0006c9e0: 6f63 6f6c 5f74 6f5f 6465 7363 7269 7074 ocol_to_descript │ │ │ +0006c9f0: 6f72 2875 6470 2063 6f6e 7374 2070 726f or(udp const pro │ │ │ +0006ca00: 746f 636f 6c29 0a7b 0a3c 2f70 7265 3e3c tocol).{.
    < │ │ │ +0006ca10: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +0006ca40: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +0006ca50: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/kadem │ │ │ +0006ca80: 6c69 612f 6974 656d 2e63 7070 3a31 3433 lia/item.cpp:143 │ │ │ +0006ca90: 3c2f 613e 3c2f 7464 3e3c 7464 3e69 6d70 imp │ │ │ +0006caa0: 6c65 6d65 6e74 2063 746f 7220 666f 7220 lement ctor for │ │ │ +0006cab0: 656e 7472 7920 6672 6f6d 2062 6465 636f entry from bdeco │ │ │ +0006cac0: 6465 5f6e 6f64 653f 3c2f 7464 3e3c 2f74 de_node?

    implement │ │ │ +0006cb20: 6374 6f72 2066 6f72 2065 6e74 7279 2066 ctor for entry f │ │ │ +0006cb30: 726f 6d20 6264 6563 6f64 655f 6e6f 6465 rom bdecode_node │ │ │ +0006cb40: 3f3c 2f68 323e 3c68 343e 2e2e 2f73 7263 ?

    ../src │ │ │ +0006cb50: 2f6b 6164 656d 6c69 612f 6974 656d 2e63 /kademlia/item.c │ │ │ +0006cb60: 7070 3a31 3433 3c2f 6834 3e3c 7072 6520 pp:143

    ., secret_k
    │ │ │ +0006cbb0: 6579 2063 6f6e 7374 2661 6d70 3b20 736b  ey const& sk
    │ │ │ +0006cbc0: 290a 7b0a 0963 6861 7220 7374 725b 3132  ).{..char str[12
    │ │ │ +0006cbd0: 3030 5d3b 0a09 696e 7420 636f 6e73 7420  00];..int const 
    │ │ │ +0006cbe0: 6c65 6e20 3d20 6361 6e6f 6e69 6361 6c5f  len = canonical_
    │ │ │ +0006cbf0: 7374 7269 6e67 2876 2c20 7365 712c 2073  string(v, seq, s
    │ │ │ +0006cc00: 616c 742c 2073 7472 293b 0a0a 0972 6574  alt, str);...ret
    │ │ │ +0006cc10: 7572 6e20 6564 3235 3531 395f 7369 676e  urn ed25519_sign
    │ │ │ +0006cc20: 287b 7374 722c 206c 656e 7d2c 2070 6b2c  ({str, len}, pk,
    │ │ │ +0006cc30: 2073 6b29 3b0a 7d0a 0a69 7465 6d3a 3a69   sk);.}..item::i
    │ │ │ +0006cc40: 7465 6d28 7075 626c 6963 5f6b 6579 2063  tem(public_key c
    │ │ │ +0006cc50: 6f6e 7374 2661 6d70 3b20 706b 2c20 7370  onst& pk, sp
    │ │ │ +0006cc60: 616e 266c 743b 6368 6172 2063 6f6e 7374  an<char const
    │ │ │ +0006cc70: 2667 743b 2073 616c 7429 0a09 3a20 6d5f  > salt)..: m_
    │ │ │ +0006cc80: 7361 6c74 2873 616c 742e 6461 7461 2829  salt(salt.data()
    │ │ │ +0006cc90: 2c20 7374 6174 6963 5f63 6173 7426 6c74  , static_cast<
    │ │ │ +0006cca0: 3b73 7464 3a3a 7369 7a65 5f74 2667 743b  ;std::size_t>
    │ │ │ +0006ccb0: 2873 616c 742e 7369 7a65 2829 2929 0a09  (salt.size()))..
    │ │ │ +0006ccc0: 2c20 6d5f 706b 2870 6b29 0a09 2c20 6d5f  , m_pk(pk).., m_
    │ │ │ +0006ccd0: 6d75 7461 626c 6528 7472 7565 290a 7b7d  mutable(true).{}
    │ │ │ +0006cce0: 0a0a 6974 656d 3a3a 6974 656d 2865 6e74  ..item::item(ent
    │ │ │ +0006ccf0: 7279 2076 290a 093a 206d 5f76 616c 7565  ry v)..: m_value
    │ │ │ +0006cd00: 2873 7464 3a3a 6d6f 7665 2876 2929 0a7b  (std::move(v)).{
    │ │ │ +0006cd10: 7d0a 0a69 7465 6d3a 3a69 7465 6d28 6264  }..item::item(bd
    │ │ │ +0006cd20: 6563 6f64 655f 6e6f 6465 2063 6f6e 7374  ecode_node const
    │ │ │ +0006cd30: 2661 6d70 3b20 7629 0a7b 0a3c 6469 7620  & v).{.
    .m_valu │ │ │ +0006cd70: 6520 3d20 763b 0a3c 2f64 6976 3e7d 0a0a e = v;.
    }.. │ │ │ +0006cd80: 6974 656d 3a3a 6974 656d 2865 6e74 7279 item::item(entry │ │ │ +0006cd90: 2076 2c20 7370 616e 266c 743b 6368 6172 v, span<char │ │ │ +0006cda0: 2063 6f6e 7374 2667 743b 2073 616c 740a const> salt. │ │ │ +0006cdb0: 092c 2073 6571 7565 6e63 655f 6e75 6d62 ., sequence_numb │ │ │ +0006cdc0: 6572 2063 6f6e 7374 2073 6571 2c20 7075 er const seq, pu │ │ │ +0006cdd0: 626c 6963 5f6b 6579 2063 6f6e 7374 2661 blic_key const&a │ │ │ +0006cde0: 6d70 3b20 706b 2c20 7365 6372 6574 5f6b mp; pk, secret_k │ │ │ +0006cdf0: 6579 2063 6f6e 7374 2661 6d70 3b20 736b ey const& sk │ │ │ +0006ce00: 290a 7b0a 0961 7373 6967 6e28 7374 643a ).{..assign(std: │ │ │ +0006ce10: 3a6d 6f76 6528 7629 2c20 7361 6c74 2c20 :move(v), salt, │ │ │ +0006ce20: 7365 712c 2070 6b2c 2073 6b29 3b0a 7d0a seq, pk, sk);.}. │ │ │ +0006ce30: 0a76 6f69 6420 6974 656d 3a3a 6173 7369 .void item::assi │ │ │ +0006ce40: 676e 2865 6e74 7279 2076 290a 7b0a 096d gn(entry v).{..m │ │ │ +0006ce50: 5f6d 7574 6162 6c65 203d 2066 616c 7365 _mutable = false │ │ │ +0006ce60: 3b0a 096d 5f76 616c 7565 203d 2073 7464 ;..m_value = std │ │ │ +0006ce70: 3a3a 6d6f 7665 2876 293b 0a7d 0a0a 766f ::move(v);.}..vo │ │ │ +0006ce80: 6964 2069 7465 6d3a 3a61 7373 6967 6e28 id item::assign( │ │ │ +0006ce90: 656e 7472 7920 762c 2073 7061 6e26 6c74 entry v, span< │ │ │ +0006cea0: 3b63 6861 7220 636f 6e73 7426 6774 3b20 ;char const> │ │ │ +0006ceb0: 7361 6c74 0a09 2c20 7365 7175 656e 6365 salt.., sequence │ │ │ +0006cec0: 5f6e 756d 6265 7220 636f 6e73 7420 7365 _number const se │ │ │ +0006ced0: 712c 2070 7562 6c69 635f 6b65 7920 636f q, public_key co │ │ │ +0006cee0: 6e73 7426 616d 703b 2070 6b2c 2073 6563 nst& pk, sec │ │ │ +0006cef0: 7265 745f 6b65 7920 636f 6e73 7426 616d ret_key const&am │ │ │ +0006cf00: 703b 2073 6b29 0a7b 0a09 7374 643a 3a61 p; sk).{..std::a │ │ │ +0006cf10: 7272 6179 266c 743b 6368 6172 2c20 3130 rray<char, 10 │ │ │ +0006cf20: 3030 2667 743b 2062 7566 6665 723b 0a09 00> buffer;.. │ │ │ +0006cf30: 696e 7420 636f 6e73 7420 6273 697a 6520 int const bsize │ │ │ +0006cf40: 3d20 6265 6e63 6f64 6528 6275 6666 6572 = bencode(buffer │ │ │ +0006cf50: 2e62 6567 696e 2829 2c20 7629 3b0a 0954 .begin(), v);..T │ │ │ +0006cf60: 4f52 5245 4e54 5f41 5353 4552 5428 6273 ORRENT_ASSERT(bs │ │ │ +0006cf70: 697a 6520 266c 743b 3d20 3130 3030 293b ize <= 1000); │ │ │ +0006cf80: 0a09 6d5f 7369 6720 3d20 7369 676e 5f6d ..m_sig = sign_m │ │ │ +0006cf90: 7574 6162 6c65 5f69 7465 6d28 7370 616e utable_item(span │ │ │ +0006cfa0: 266c 743b 6368 6172 2063 6f6e 7374 2667 <char const&g │ │ │ +0006cfb0: 743b 2862 7566 6665 7229 2e66 6972 7374 t;(buffer).first │ │ │ +0006cfc0: 2862 7369 7a65 290a 0909 2c20 7361 6c74 (bsize)..., salt │ │ │ +0006cfd0: 2c20 7365 712c 2070 6b2c 2073 6b29 3b0a , seq, pk, sk);. │ │ │ +0006cfe0: 096d 5f73 616c 742e 6173 7369 676e 2873 .m_salt.assign(s │ │ │ +0006cff0: 616c 742e 6461 7461 2829 2c20 7374 6174 alt.data(), stat │ │ │ +0006d000: 6963 5f63 6173 7426 6c74 3b73 7464 3a3a ic_cast<std:: │ │ │ +0006d010: 7369 7a65 5f74 2667 743b 2873 616c 742e size_t>(salt. │ │ │ +0006d020: 7369 7a65 2829 2929 3b0a 096d 5f70 6b20 size()));..m_pk │ │ │ +0006d030: 3d20 706b 3b0a 096d 5f73 6571 203d 2073 = pk;..m_seq = s │ │ │ +0006d040: 6571 3b0a 096d 5f6d 7574 6162 6c65 203d eq;..m_mutable = │ │ │ +0006d050: 2074 7275 653b 0a09 6d5f 7661 6c75 6520 true;..m_value │ │ │ +0006d060: 3d20 7374 643a 3a6d 6f76 6528 7629 3b0a = std::move(v);. │ │ │ +0006d070: 7d0a 0a76 6f69 6420 6974 656d 3a3a 6173 }..void item::as │ │ │ +0006d080: 7369 676e 2862 6465 636f 6465 5f6e 6f64 sign(bdecode_nod │ │ │ +0006d090: 6520 636f 6e73 7426 616d 703b 2076 290a e const& v). │ │ │ 0006d0a0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ 0006d0b0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ 0006d0e0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../in │ │ │ 0006d110: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -0006d120: 2f75 706e 702e 6870 703a 3136 343c 2f61 /upnp.hpp:164suppor │ │ │ -0006d140: 7420 7573 696e 6720 7468 6520 7769 6e64 t using the wind │ │ │ -0006d150: 6f77 7320 4150 4920 666f 7220 5550 6e50 ows API for UPnP │ │ │ -0006d160: 206f 7065 7261 7469 6f6e 7320 6173 2077 operations as w │ │ │ -0006d170: 656c 6c3c 2f74 643e 3c2f 7472 3e3c 7472 ell

    support using t │ │ │ -0006d1d0: 6865 2077 696e 646f 7773 2041 5049 2066 he windows API f │ │ │ -0006d1e0: 6f72 2055 506e 5020 6f70 6572 6174 696f or UPnP operatio │ │ │ -0006d1f0: 6e73 2061 7320 7765 6c6c 3c2f 6832 3e3c ns as well

    < │ │ │ -0006d200: 6834 3e2e 2e2f 696e 636c 7564 652f 6c69 h4>../include/li │ │ │ -0006d210: 6274 6f72 7265 6e74 2f75 706e 702e 6870 btorrent/upnp.hp │ │ │ -0006d220: 703a 3136 343c 2f68 343e 3c70 7265 2073 p:164
    {..bool in_e
    │ │ │ -0006d270: 7272 6f72 5f63 6f64 6520 3d20 6661 6c73  rror_code = fals
    │ │ │ -0006d280: 653b 0a09 626f 6f6c 2065 7869 7420 3d20  e;..bool exit = 
    │ │ │ -0006d290: 6661 6c73 653b 0a09 696e 7420 6572 726f  false;..int erro
    │ │ │ -0006d2a0: 725f 636f 6465 203d 202d 313b 0a7d 3b0a  r_code = -1;.};.
    │ │ │ -0006d2b0: 0a73 7472 7563 7420 6970 5f61 6464 7265  .struct ip_addre
    │ │ │ -0006d2c0: 7373 5f70 6172 7365 5f73 7461 7465 3a20  ss_parse_state: 
    │ │ │ -0006d2d0: 6572 726f 725f 636f 6465 5f70 6172 7365  error_code_parse
    │ │ │ -0006d2e0: 5f73 7461 7465 0a7b 0a09 626f 6f6c 2069  _state.{..bool i
    │ │ │ -0006d2f0: 6e5f 6970 5f61 6464 7265 7373 203d 2066  n_ip_address = f
    │ │ │ -0006d300: 616c 7365 3b0a 0973 7464 3a3a 7374 7269  alse;..std::stri
    │ │ │ -0006d310: 6e67 2069 705f 6164 6472 6573 733b 0a7d  ng ip_address;.}
    │ │ │ -0006d320: 3b0a 0a54 4f52 5245 4e54 5f45 5854 5241  ;..TORRENT_EXTRA
    │ │ │ -0006d330: 5f45 5850 4f52 5420 766f 6964 2066 696e  _EXPORT void fin
    │ │ │ -0006d340: 645f 636f 6e74 726f 6c5f 7572 6c28 696e  d_control_url(in
    │ │ │ -0006d350: 7420 7479 7065 2c20 7374 7269 6e67 5f76  t type, string_v
    │ │ │ -0006d360: 6965 772c 2070 6172 7365 5f73 7461 7465  iew, parse_state
    │ │ │ -0006d370: 2661 6d70 3b20 7374 6174 6529 3b0a 0a54  & state);..T
    │ │ │ -0006d380: 4f52 5245 4e54 5f45 5854 5241 5f45 5850  ORRENT_EXTRA_EXP
    │ │ │ -0006d390: 4f52 5420 766f 6964 2066 696e 645f 6572  ORT void find_er
    │ │ │ -0006d3a0: 726f 725f 636f 6465 2869 6e74 2074 7970  ror_code(int typ
    │ │ │ -0006d3b0: 652c 2073 7472 696e 675f 7669 6577 2073  e, string_view s
    │ │ │ -0006d3c0: 7472 696e 670a 092c 2065 7272 6f72 5f63  tring.., error_c
    │ │ │ -0006d3d0: 6f64 655f 7061 7273 655f 7374 6174 6526  ode_parse_state&
    │ │ │ -0006d3e0: 616d 703b 2073 7461 7465 293b 0a0a 544f  amp; state);..TO
    │ │ │ -0006d3f0: 5252 454e 545f 4558 5452 415f 4558 504f  RRENT_EXTRA_EXPO
    │ │ │ -0006d400: 5254 2076 6f69 6420 6669 6e64 5f69 705f  RT void find_ip_
    │ │ │ -0006d410: 6164 6472 6573 7328 696e 7420 7479 7065  address(int type
    │ │ │ -0006d420: 2c20 7374 7269 6e67 5f76 6965 7720 7374  , string_view st
    │ │ │ -0006d430: 7269 6e67 0a09 2c20 6970 5f61 6464 7265  ring.., ip_addre
    │ │ │ -0006d440: 7373 5f70 6172 7365 5f73 7461 7465 2661  ss_parse_state&a
    │ │ │ -0006d450: 6d70 3b20 7374 6174 6529 3b0a 0a3c 6469  mp; state);..struc
    │ │ │ -0006d490: 7420 544f 5252 454e 545f 4558 5452 415f  t TORRENT_EXTRA_
    │ │ │ -0006d4a0: 4558 504f 5254 2075 706e 7020 6669 6e61  EXPORT upnp fina
    │ │ │ -0006d4b0: 6c0a 3c2f 6469 763e 093a 2073 7464 3a3a  l.
    .: std:: │ │ │ -0006d4c0: 656e 6162 6c65 5f73 6861 7265 645f 6672 enable_shared_fr │ │ │ -0006d4d0: 6f6d 5f74 6869 7326 6c74 3b75 706e 7026 om_this<upnp& │ │ │ -0006d4e0: 6774 3b0a 092c 2073 696e 676c 655f 7468 gt;.., single_th │ │ │ -0006d4f0: 7265 6164 6564 0a7b 0a09 7570 6e70 2869 readed.{..upnp(i │ │ │ -0006d500: 6f5f 636f 6e74 6578 7426 616d 703b 2069 o_context& i │ │ │ -0006d510: 6f73 0a09 092c 2061 7578 3a3a 7365 7373 os..., aux::sess │ │ │ -0006d520: 696f 6e5f 7365 7474 696e 6773 2063 6f6e ion_settings con │ │ │ -0006d530: 7374 2661 6d70 3b20 7365 7474 696e 6773 st& settings │ │ │ -0006d540: 0a09 092c 2061 7578 3a3a 706f 7274 6d61 ..., aux::portma │ │ │ -0006d550: 705f 6361 6c6c 6261 636b 2661 6d70 3b20 p_callback& │ │ │ -0006d560: 6362 0a09 092c 2061 6464 7265 7373 5f76 cb..., address_v │ │ │ -0006d570: 3420 6c69 7374 656e 5f61 6464 7265 7373 4 listen_address │ │ │ -0006d580: 0a09 092c 2061 6464 7265 7373 5f76 3420 ..., address_v4 │ │ │ -0006d590: 6e65 746d 6173 6b0a 0909 2c20 7374 643a netmask..., std: │ │ │ -0006d5a0: 3a73 7472 696e 6720 6c69 7374 656e 5f64 :string listen_d │ │ │ -0006d5b0: 6576 6963 650a 0909 2c20 6175 783a 3a6c evice..., aux::l │ │ │ -0006d5c0: 6973 7465 6e5f 736f 636b 6574 5f68 616e isten_socket_han │ │ │ -0006d5d0: 646c 6520 6c73 293b 0a09 7e75 706e 7028 dle ls);..~upnp( │ │ │ -0006d5e0: 293b 0a0a 0976 6f69 6420 7374 6172 7428 );...void start( │ │ │ -0006d5f0: 293b 0a0a 092f 2f20 4174 7465 6d70 7473 );...// Attempts │ │ │ -0006d600: 2074 6f20 6164 6420 6120 706f 7274 206d to add a port m │ │ │ -0006d610: 6170 7069 6e67 2066 6f72 2074 6865 2073 apping for the s │ │ │ -0006d620: 7065 6369 6669 6564 2070 726f 746f 636f pecified protoco │ │ │ -0006d630: 6c2e 2056 616c 6964 2070 726f 746f 636f l. Valid protoco │ │ │ -0006d640: 6c73 2061 7265 0a09 2f2f 2060 6075 706e ls are..// ``upn │ │ │ -0006d650: 703a 3a74 6370 6060 2061 6e64 2060 6075 p::tcp`` and ``u │ │ │ -0006d660: 706e 703a 3a75 6470 6060 2066 6f72 2074 pnp::udp`` for t │ │ │ -0006d670: 6865 2055 506e 5020 636c 6173 7320 616e he UPnP class an │ │ │ -0006d680: 6420 6060 6e61 7470 6d70 3a3a 7463 7060 d ``natpmp::tcp` │ │ │ -0006d690: 6020 616e 640a 092f 2f20 6060 6e61 7470 ` and..// ``natp │ │ │ -0006d6a0: 6d70 3a3a 7564 7060 6020 666f 7220 7468 mp::udp`` for th │ │ │ -0006d6b0: 6520 4e41 542d 504d 5020 636c 6173 732e e NAT-PMP class. │ │ │ -0006d6c0: 0a09 2f2f 0a09 2f2f 2060 6065 7874 6572 ..//..// ``exter │ │ │ -0006d6d0: 6e61 6c5f 706f 7274 6060 2069 7320 7468 nal_port`` is th │ │ │ -0006d6e0: 6520 706f 7274 206f 6e20 7468 6520 6578 e port on the ex │ │ │ -0006d6f0: 7465 726e 616c 2061 6464 7265 7373 2074 ternal address t │ │ │ -0006d700: 6861 7420 7769 6c6c 2062 6520 6d61 7070 hat will be mapp │ │ │ -0006d710: 6564 2e20 5468 6973 0a09 2f2f 2069 7320 ed. This..// is │ │ │ -0006d720: 6120 6869 6e74 2c20 796f 7520 6172 6520 a hint, you are │ │ │ -0006d730: 6e6f 7420 6775 6172 616e 7465 6564 2074 not guaranteed t │ │ │ -0006d740: 6861 7420 7468 6973 2070 6f72 7420 7769 hat this port wi │ │ │ -0006d750: 6c6c 2062 6520 6176 6169 6c61 626c 652c ll be available, │ │ │ -0006d760: 2061 6e64 2069 7420 6d61 790a 092f 2f20 and it may..// │ │ │ -0006d770: 656e 6420 7570 2062 6569 6e67 2073 6f6d end up being som │ │ │ -0006d780: 6574 6869 6e67 2065 6c73 652e 2049 6e20 ething else. In │ │ │ -0006d790: 7468 6520 706f 7274 6d61 705f 616c 6572 the portmap_aler │ │ │ -0006d7a0: 745f 206e 6f74 6966 6963 6174 696f 6e2c t_ notification, │ │ │ -0006d7b0: 2074 6865 2061 6374 7561 6c0a 092f 2f20 the actual..// │ │ │ -0006d7c0: 6578 7465 726e 616c 2070 6f72 7420 6973 external port is │ │ │ -0006d7d0: 2072 6570 6f72 7465 642e 0a09 2f2f 0a09 reported...//.. │ │ │ -0006d7e0: 2f2f 2060 606c 6f63 616c 5f70 6f72 7460 // ``local_port` │ │ │ -0006d7f0: 6020 6973 2074 6865 2070 6f72 7420 696e ` is the port in │ │ │ -0006d800: 2074 6865 206c 6f63 616c 206d 6163 6869 the local machi │ │ │ -0006d810: 6e65 2074 6861 7420 7468 6520 6d61 7070 ne that the mapp │ │ │ -0006d820: 696e 6720 7368 6f75 6c64 2066 6f72 7761 ing should forwa │ │ │ -0006d830: 7264 0a09 2f2f 2074 6f2e 0a09 2f2f 0a09 rd..// to...//.. │ │ │ -0006d840: 2f2f 2054 6865 2072 6574 7572 6e20 7661 // The return va │ │ │ -0006d850: 6c75 6520 6973 2061 6e20 696e 6465 7820 lue is an index │ │ │ -0006d860: 7468 6174 2069 6465 6e74 6966 6965 7320 that identifies │ │ │ -0006d870: 7468 6973 2070 6f72 7420 6d61 7070 696e this port mappin │ │ │ -0006d880: 672e 2054 6869 7320 6973 2075 7365 640a g. This is used. │ │ │ -0006d890: 092f 2f20 746f 2072 6566 6572 2074 6f20 .// to refer to │ │ │ -0006d8a0: 6d61 7070 696e 6773 2074 6861 7420 6661 mappings that fa │ │ │ -0006d8b0: 696c 7320 6f72 2073 7563 6365 6564 7320 ils or succeeds │ │ │ -0006d8c0: 696e 2074 6865 2070 6f72 746d 6170 5f65 in the portmap_e │ │ │ -0006d8d0: 7272 6f72 5f61 6c65 7274 5f20 616e 640a rror_alert_ and. │ │ │ -0006d8e0: 092f 2f20 706f 7274 6d61 705f 616c 6572 .// portmap_aler │ │ │ -0006d8f0: 745f 2072 6573 7065 6374 6976 656c 792e t_ respectively. │ │ │ -0006d900: 2049 6620 5468 6520 6d61 7070 696e 6720 If The mapping │ │ │ -0006d910: 6661 696c 7320 696d 6d65 6469 6174 656c fails immediatel │ │ │ -0006d920: 792c 2074 6865 2072 6574 7572 6e20 7661 y, the return va │ │ │ -0006d930: 6c75 650a 092f 2f20 6973 202d 312c 2077 lue..// is -1, w │ │ │ -0006d940: 6869 6368 206d 6561 6e73 2066 6169 6c75 hich means failu │ │ │ -0006d950: 7265 2e20 5468 6572 6520 7769 6c6c 206e re. There will n │ │ │ -0006d960: 6f74 2062 6520 616e 7920 6572 726f 7220 ot be any error │ │ │ -0006d970: 616c 6572 7420 6e6f 7469 6669 6361 7469 alert notificati │ │ │ -0006d980: 6f6e 2066 6f72 0a3c 2f70 7265 3e3c 2f74 on for.
    relevanc │ │ │ -0006d9c0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../include/lib │ │ │ -0006da00: 746f 7272 656e 742f 746f 7272 656e 745f torrent/torrent_ │ │ │ -0006da10: 696e 666f 2e68 7070 3a37 3538 3c2f 613e info.hpp:758 │ │ │ -0006da20: 3c2f 7464 3e3c 7464 3e63 6861 6e67 6520 change │ │ │ -0006da30: 7468 6520 7479 7065 2074 6f20 7374 643a the type to std: │ │ │ -0006da40: 3a73 6861 7265 645f 7074 723c 6368 6172 :shared_ptr in C++17 │ │ │ -0006da60: 2069 7420 6973 2075 7365 6420 6173 2069 it is used as i │ │ │ -0006da70: 6620 696d 6d75 7461 626c 652c 2069 7420 f immutable, it │ │ │ -0006da80: 6361 6e6e 6f74 2062 6520 636f 6e73 7420 cannot be const │ │ │ -0006da90: 666f 7220 7465 6368 6e69 6361 6c20 7265 for technical re │ │ │ -0006daa0: 6173 6f6e 7320 7269 6768 7420 6e6f 772e asons right now. │ │ │ -0006dab0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    ch │ │ │ -0006db00: 616e 6765 2074 6865 2074 7970 6520 746f ange the type to │ │ │ -0006db10: 2073 7464 3a3a 7368 6172 6564 5f70 7472 std::shared_ptr │ │ │ -0006db20: 3c63 6861 7220 636f 6e73 743e 2069 6e20 in │ │ │ -0006db30: 432b 2b31 370a 6974 2069 7320 7573 6564 C++17.it is used │ │ │ -0006db40: 2061 7320 6966 2069 6d6d 7574 6162 6c65 as if immutable │ │ │ -0006db50: 2c20 6974 2063 616e 6e6f 7420 6265 2063 , it cannot be c │ │ │ -0006db60: 6f6e 7374 2066 6f72 2074 6563 686e 6963 onst for technic │ │ │ -0006db70: 616c 2072 6561 736f 6e73 0a72 6967 6874 al reasons.right │ │ │ -0006db80: 206e 6f77 2e3c 2f68 323e 3c68 343e 2e2e now.

    .. │ │ │ -0006db90: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -0006dba0: 656e 742f 746f 7272 656e 745f 696e 666f ent/torrent_info │ │ │ -0006dbb0: 2e68 7070 3a37 3538 3c2f 6834 3e3c 7072 .hpp:758

    ...// the │ │ │ -0006dc00: 7365 2061 7265 2074 6865 2063 6f6c 6c65 se are the colle │ │ │ -0006dc10: 6374 696f 6e73 2066 726f 6d20 6f75 7473 ctions from outs │ │ │ -0006dc20: 6964 6520 6f66 2074 6865 2069 6e66 6f2d ide of the info- │ │ │ -0006dc30: 6469 6374 2e20 5468 6573 6520 6172 650a dict. These are. │ │ │ -0006dc40: 0909 2f2f 206f 776e 696e 6720 7374 7269 ..// owning stri │ │ │ -0006dc50: 6e67 732c 2073 696e 6365 2077 6520 6f6e ngs, since we on │ │ │ -0006dc60: 6c79 206b 6565 7020 7468 6520 696e 666f ly keep the info │ │ │ -0006dc70: 2d73 6563 7469 6f6e 2061 726f 756e 642c -section around, │ │ │ -0006dc80: 2074 6865 7365 0a09 092f 2f20 6361 6e6e these...// cann │ │ │ -0006dc90: 6f74 2062 6520 706f 696e 7465 7273 2069 ot be pointers i │ │ │ -0006dca0: 6e74 6f20 7468 6174 2062 7566 6665 722e nto that buffer. │ │ │ -0006dcb0: 0a09 0973 7464 3a3a 7665 6374 6f72 266c ...std::vector&l │ │ │ -0006dcc0: 743b 7374 643a 3a73 7472 696e 6726 6774 t;std::string> │ │ │ -0006dcd0: 3b20 6d5f 6f77 6e65 645f 636f 6c6c 6563 ; m_owned_collec │ │ │ -0006dce0: 7469 6f6e 733b 0a0a 2369 6620 544f 5252 tions;..#if TORR │ │ │ -0006dcf0: 454e 545f 4142 495f 5645 5253 494f 4e20 ENT_ABI_VERSION │ │ │ -0006dd00: 266c 743b 3d20 320a 0909 2f2f 2069 6620 <= 2...// if │ │ │ -0006dd10: 7468 6973 2069 7320 6120 6d65 726b 6c65 this is a merkle │ │ │ -0006dd20: 2074 6f72 7265 6e74 2c20 7468 6973 2069 torrent, this i │ │ │ -0006dd30: 7320 7468 6520 6d65 726b 6c65 0a09 092f s the merkle.../ │ │ │ -0006dd40: 2f20 7472 6565 2e20 4974 2068 6173 2073 / tree. It has s │ │ │ -0006dd50: 7061 6365 2066 6f72 206d 6572 6b6c 655f pace for merkle_ │ │ │ -0006dd60: 6e75 6d5f 6e6f 6465 7328 6d65 726b 6c65 num_nodes(merkle │ │ │ -0006dd70: 5f6e 756d 5f6c 6561 6673 286e 756d 5f70 _num_leafs(num_p │ │ │ -0006dd80: 6965 6365 7329 290a 0909 2f2f 2068 6173 ieces))...// has │ │ │ -0006dd90: 6865 730a 0909 6175 783a 3a76 6563 746f hes...aux::vecto │ │ │ -0006dda0: 7226 6c74 3b73 6861 315f 6861 7368 2667 r<sha1_hash&g │ │ │ -0006ddb0: 743b 206d 5f6d 6572 6b6c 655f 7472 6565 t; m_merkle_tree │ │ │ -0006ddc0: 3b0a 2365 6e64 6966 0a0a 0909 2f2f 2076 ;.#endif....// v │ │ │ -0006ddd0: 3220 6d65 726b 6c65 2074 7265 6520 666f 2 merkle tree fo │ │ │ -0006dde0: 7220 6561 6368 2066 696c 650a 0909 2f2f r each file...// │ │ │ -0006ddf0: 2074 6865 2061 6374 7561 6c20 6861 7368 the actual hash │ │ │ -0006de00: 2062 7566 6665 7273 2061 7265 2061 6c77 buffers are alw │ │ │ -0006de10: 6179 7320 6469 7669 7369 626c 6520 6279 ays divisible by │ │ │ -0006de20: 2033 3220 2873 6861 3235 365f 6861 7368 32 (sha256_hash │ │ │ -0006de30: 3a3a 7369 7a65 2829 290a 0909 6175 783a ::size())...aux: │ │ │ -0006de40: 3a76 6563 746f 7226 6c74 3b61 7578 3a3a :vector<aux:: │ │ │ -0006de50: 7665 6374 6f72 266c 743b 6368 6172 2667 vector<char&g │ │ │ -0006de60: 743b 2c20 6669 6c65 5f69 6e64 6578 5f74 t;, file_index_t │ │ │ -0006de70: 2667 743b 206d 5f70 6965 6365 5f6c 6179 > m_piece_lay │ │ │ -0006de80: 6572 733b 0a0a 0909 2f2f 2074 6869 7320 ers;....// this │ │ │ -0006de90: 6973 2061 2063 6f70 7920 6f66 2074 6865 is a copy of the │ │ │ -0006dea0: 2069 6e66 6f20 7365 6374 696f 6e20 6672 info section fr │ │ │ -0006deb0: 6f6d 2074 6865 2074 6f72 7265 6e74 2e0a om the torrent.. │ │ │ -0006dec0: 0909 2f2f 2069 7420 7573 6520 6d61 696e ..// it use main │ │ │ -0006ded0: 7461 696e 6564 2069 6e20 7468 6973 2066 tained in this f │ │ │ -0006dee0: 6c61 7420 666f 726d 6174 2069 6e20 6f72 lat format in or │ │ │ -0006def0: 6465 7220 746f 0a09 092f 2f20 6d61 6b65 der to...// make │ │ │ -0006df00: 2069 7420 6176 6169 6c61 626c 6520 7468 it available th │ │ │ -0006df10: 726f 7567 6820 7468 6520 6d65 7461 6461 rough the metada │ │ │ -0006df20: 7461 2065 7874 656e 7369 6f6e 0a3c 6469 ta extension...boo │ │ │ -0006df60: 7374 3a3a 7368 6172 6564 5f61 7272 6179 st::shared_array │ │ │ -0006df70: 266c 743b 6368 6172 2667 743b 206d 5f69 <char> m_i │ │ │ -0006df80: 6e66 6f5f 7365 6374 696f 6e3b 0a3c 2f64 nfo_section;....// if a co │ │ │ -0006dfa0: 6d6d 656e 7420 6973 2066 6f75 6e64 2069 mment is found i │ │ │ -0006dfb0: 6e20 7468 6520 746f 7272 656e 7420 6669 n the torrent fi │ │ │ -0006dfc0: 6c65 0a09 092f 2f20 7468 6973 2077 696c le...// this wil │ │ │ -0006dfd0: 6c20 6265 2073 6574 2074 6f20 7468 6174 l be set to that │ │ │ -0006dfe0: 2063 6f6d 6d65 6e74 0a09 0973 7464 3a3a comment...std:: │ │ │ -0006dff0: 7374 7269 6e67 206d 5f63 6f6d 6d65 6e74 string m_comment │ │ │ -0006e000: 3b0a 0a09 092f 2f20 616e 206f 7074 696f ;....// an optio │ │ │ -0006e010: 6e61 6c20 7374 7269 6e67 206e 616d 696e nal string namin │ │ │ -0006e020: 6720 7468 6520 736f 6674 7761 7265 2075 g the software u │ │ │ -0006e030: 7365 640a 0909 2f2f 2074 6f20 6372 6561 sed...// to crea │ │ │ -0006e040: 7465 2074 6865 2074 6f72 7265 6e74 2066 te the torrent f │ │ │ -0006e050: 696c 650a 0909 7374 643a 3a73 7472 696e ile...std::strin │ │ │ -0006e060: 6720 6d5f 6372 6561 7465 645f 6279 3b0a g m_created_by;. │ │ │ -0006e070: 0a09 092f 2f20 7468 6520 696e 666f 2073 ...// the info s │ │ │ -0006e080: 6563 7469 6f6e 2070 6172 7365 642e 2070 ection parsed. p │ │ │ -0006e090: 6f69 6e74 7320 696e 746f 206d 5f69 6e66 oints into m_inf │ │ │ -0006e0a0: 6f5f 7365 6374 696f 6e0a 0909 2f2f 2070 o_section...// p │ │ │ -0006e0b0: 6172 7365 6420 6c61 7a69 6c79 0a09 096d arsed lazily...m │ │ │ -0006e0c0: 7574 6162 6c65 2062 6465 636f 6465 5f6e utable bdecode_n │ │ │ -0006e0d0: 6f64 6520 6d5f 696e 666f 5f64 6963 743b ode m_info_dict; │ │ │ -0006e0e0: 0a0a 0909 2f2f 2069 6620 6120 6372 6561 ....// if a crea │ │ │ -0006e0f0: 7469 6f6e 2064 6174 6520 6973 2066 6f75 tion date is fou │ │ │ -0006e100: 6e64 2069 6e20 7468 6520 746f 7272 656e nd in the torren │ │ │ -0006e110: 7420 6669 6c65 0a09 092f 2f20 7468 6973 t file...// this │ │ │ -0006e120: 2077 696c 6c20 6265 2073 6574 2074 6f20 will be set to │ │ │ -0006e130: 7468 6174 2c20 6f74 6865 7277 6973 6520 that, otherwise │ │ │ -0006e140: 6974 276c 6c20 6265 0a09 092f 2f20 3139 it'll be...// 19 │ │ │ -0006e150: 3730 2c20 4a61 6e20 310a 0909 7374 643a 70, Jan 1...std: │ │ │ -0006e160: 3a74 696d 655f 7420 6d5f 6372 6561 7469 :time_t m_creati │ │ │ -0006e170: 6f6e 5f64 6174 6520 3d20 303b 0a0a 0909 on_date = 0;.... │ │ │ -0006e180: 2f2f 2074 6865 2068 6173 6828 6573 2920 // the hash(es) │ │ │ -0006e190: 7468 6174 2069 6465 6e74 6966 7920 7468 that identify th │ │ │ -0006e1a0: 6973 2074 6f72 7265 6e74 0a09 0969 6e66 is torrent...inf │ │ │ -0006e1b0: 6f5f 6861 7368 5f74 206d 5f69 6e66 6f5f o_hash_t m_info_ │ │ │ -0006e1c0: 6861 7368 3b0a 0a09 092f 2f20 7468 6973 hash;....// this │ │ │ -0006e1d0: 2069 7320 7468 6520 6f66 6673 6574 2069 is the offset i │ │ │ -0006e1e0: 6e74 6f20 7468 6520 6d5f 696e 666f 5f73 nto the m_info_s │ │ │ -0006e1f0: 6563 7469 6f6e 2062 7566 6665 7220 746f ection buffer to │ │ │ -0006e200: 2074 6865 2066 6972 7374 2062 7974 6520 the first byte │ │ │ -0006e210: 6f66 0a09 092f 2f20 7468 6520 6669 7273 of...// the firs │ │ │ -0006e220: 7420 5348 412d 3120 6861 7368 0a09 0973 t SHA-1 hash...s │ │ │ -0006e230: 7464 3a3a 696e 7433 325f 7420 6d5f 7069 td::int32_t m_pi │ │ │ -0006e240: 6563 655f 6861 7368 6573 203d 2030 3b0a ece_hashes = 0;. │ │ │ -0006e250: 0a09 092f 2f20 7468 6520 6e75 6d62 6572 ...// the number │ │ │ -0006e260: 206f 6620 6279 7465 7320 696e 206d 5f69 of bytes in m_i │ │ │ -0006e270: 6e66 6f5f 7365 6374 696f 6e0a 0909 7374 nfo_section...st │ │ │ -0006e280: 643a 3a69 6e74 3332 5f74 206d 5f69 6e66 d::int32_t m_inf │ │ │ -0006e290: 6f5f 7365 6374 696f 6e5f 7369 7a65 203d o_section_size = │ │ │ -0006e2a0: 2030 3b0a 0a09 092f 2f20 7468 6973 2069 0;....// this i │ │ │ -0006e2b0: 7320 7573 6564 2077 6865 6e20 6372 6561 s used when crea │ │ │ -0006e2c0: 7469 6e67 2061 2074 6f72 7265 6e74 2e20 ting a torrent. │ │ │ -0006e2d0: 4966 2074 6865 7265 2773 0a09 092f 2f20 If there's...// │ │ │ -0006e2e0: 6f6e 6c79 206f 6e65 2066 696c 6520 7468 only one file th │ │ │ -0006e2f0: 6572 6520 6172 6520 6361 7365 7320 7768 ere are cases wh │ │ │ -0006e300: 6572 6520 6974 2773 2069 6d70 6f73 7369 ere it's impossi │ │ │ -0006e310: 626c 650a 3c2f 7072 653e 3c2f 7464 3e3c ble.
    < │ │ │ -0006e320: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -0006e350: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -0006e380: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -0006e390: 7265 6e74 2f74 6f72 7265 6e74 2e68 7070 rent/torrent.hpp │ │ │ -0006e3a0: 3a33 3131 3c2f 613e 3c2f 7464 3e3c 7464 :311make this a raw │ │ │ -0006e3c0: 2070 6f69 6e74 6572 2e20 7065 7268 6170 pointer. perhap │ │ │ -0006e3d0: 7320 6b65 6570 2074 6865 2073 6861 7265 s keep the share │ │ │ -0006e3e0: 645f 7074 7220 6172 6f75 6e64 2066 7572 d_ptr around fur │ │ │ -0006e3f0: 7468 6572 2064 6f77 6e20 7468 6520 6f62 ther down the ob │ │ │ -0006e400: 6a65 6374 2074 6f20 6d61 696e 7461 696e ject to maintain │ │ │ -0006e410: 2061 6e20 6f77 6e65 723c 2f74 643e 3c2f an owner

    make this │ │ │ -0006e470: 2061 2072 6177 2070 6f69 6e74 6572 2e20 a raw pointer. │ │ │ -0006e480: 7065 7268 6170 7320 6b65 6570 2074 6865 perhaps keep the │ │ │ -0006e490: 2073 6861 7265 645f 7074 720a 6172 6f75 shared_ptr.arou │ │ │ -0006e4a0: 6e64 2066 7572 7468 6572 2064 6f77 6e20 nd further down │ │ │ -0006e4b0: 7468 6520 6f62 6a65 6374 2074 6f20 6d61 the object to ma │ │ │ -0006e4c0: 696e 7461 696e 2061 6e20 6f77 6e65 723c intain an owner< │ │ │ -0006e4d0: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ -0006e4e0: 6465 2f6c 6962 746f 7272 656e 742f 746f de/libtorrent/to │ │ │ -0006e4f0: 7272 656e 742e 6870 703a 3331 313c 2f68 rrent.hpp:311
    ..bo
    │ │ │ -0006e540: 6f6c 206d 5f6c 6976 6520 3d20 6661 6c73  ol m_live = fals
    │ │ │ -0006e550: 653b 0a09 7d3b 0a0a 0973 7472 7563 7420  e;..};...struct 
    │ │ │ -0006e560: 544f 5252 454e 545f 4558 5452 415f 4558  TORRENT_EXTRA_EX
    │ │ │ -0006e570: 504f 5254 2074 6f72 7265 6e74 5f68 6f74  PORT torrent_hot
    │ │ │ -0006e580: 5f6d 656d 6265 7273 0a09 7b0a 0909 746f  _members..{...to
    │ │ │ -0006e590: 7272 656e 745f 686f 745f 6d65 6d62 6572  rrent_hot_member
    │ │ │ -0006e5a0: 7328 6175 783a 3a73 6573 7369 6f6e 5f69  s(aux::session_i
    │ │ │ -0006e5b0: 6e74 6572 6661 6365 2661 6d70 3b20 7365  nterface& se
    │ │ │ -0006e5c0: 730a 0909 092c 2061 6464 5f74 6f72 7265  s...., add_torre
    │ │ │ -0006e5d0: 6e74 5f70 6172 616d 7320 636f 6e73 7426  nt_params const&
    │ │ │ -0006e5e0: 616d 703b 2070 2c20 626f 6f6c 2073 6573  amp; p, bool ses
    │ │ │ -0006e5f0: 7369 6f6e 5f70 6175 7365 6429 3b0a 0a09  sion_paused);...
    │ │ │ -0006e600: 7072 6f74 6563 7465 643a 0a09 092f 2f20  protected:...// 
    │ │ │ -0006e610: 7468 6520 7069 6563 6520 7069 636b 6572  the piece picker
    │ │ │ -0006e620: 2e20 5468 6973 2069 7320 616c 6c6f 6361  . This is alloca
    │ │ │ -0006e630: 7465 6420 6c61 7a69 6c79 2e20 5768 656e  ted lazily. When
    │ │ │ -0006e640: 2077 6520 646f 6e27 740a 0909 2f2f 2068   we don't...// h
    │ │ │ -0006e650: 6176 6520 616e 7974 6869 6e67 2069 6e20  ave anything in 
    │ │ │ -0006e660: 7468 6520 746f 7272 656e 7420 2866 6f72  the torrent (for
    │ │ │ -0006e670: 2069 6e73 7461 6e63 652c 2069 6620 6974   instance, if it
    │ │ │ -0006e680: 2068 6173 6e27 740a 0909 2f2f 2062 6565   hasn't...// bee
    │ │ │ -0006e690: 6e20 7374 6172 7465 6420 7965 7429 206f  n started yet) o
    │ │ │ -0006e6a0: 7220 6966 2077 6520 6861 7665 2065 7665  r if we have eve
    │ │ │ -0006e6b0: 7279 7468 696e 672c 2074 6865 7265 2069  rything, there i
    │ │ │ -0006e6c0: 7320 6e6f 0a09 092f 2f20 7069 636b 6572  s no...// picker
    │ │ │ -0006e6d0: 2e20 4974 2773 2061 6c6c 6f63 6174 6564  . It's allocated
    │ │ │ -0006e6e0: 206f 6e2d 6465 6d61 6e64 2074 6865 2066   on-demand the f
    │ │ │ -0006e6f0: 6972 7374 2074 696d 6520 7765 206e 6565  irst time we nee
    │ │ │ -0006e700: 640a 0909 2f2f 2069 7420 696e 2074 6f72  d...// it in tor
    │ │ │ -0006e710: 7265 6e74 3a3a 6e65 6564 5f70 6963 6b65  rent::need_picke
    │ │ │ -0006e720: 7228 292e 2049 6e20 6f72 6465 7220 746f  r(). In order to
    │ │ │ -0006e730: 2074 656c 6c20 7468 650a 0909 2f2f 2064   tell the...// d
    │ │ │ -0006e740: 6966 6665 7265 6e63 6520 6265 7477 6565  ifference betwee
    │ │ │ -0006e750: 6e20 6861 7669 6e67 2065 7665 7279 7468  n having everyth
    │ │ │ -0006e760: 696e 6720 616e 6420 6e6f 7468 696e 6720  ing and nothing 
    │ │ │ -0006e770: 696e 0a09 092f 2f20 7468 6520 6361 7365  in...// the case
    │ │ │ -0006e780: 2074 6865 7265 2069 7320 6e6f 2070 6965   there is no pie
    │ │ │ -0006e790: 6365 2070 6963 6b65 722c 2073 6565 206d  ce picker, see m
    │ │ │ -0006e7a0: 5f68 6176 655f 616c 6c2e 0a09 0973 7464  _have_all....std
    │ │ │ -0006e7b0: 3a3a 756e 6971 7565 5f70 7472 266c 743b  ::unique_ptr<
    │ │ │ -0006e7c0: 7069 6563 655f 7069 636b 6572 2667 743b  piece_picker>
    │ │ │ -0006e7d0: 206d 5f70 6963 6b65 723b 0a0a 0909 7374   m_picker;....st
    │ │ │ -0006e7e0: 643a 3a75 6e69 7175 655f 7074 7226 6c74  d::unique_ptr<
    │ │ │ -0006e7f0: 3b68 6173 685f 7069 636b 6572 2667 743b  ;hash_picker>
    │ │ │ -0006e800: 206d 5f68 6173 685f 7069 636b 6572 3b0a   m_hash_picker;.
    │ │ │ -0006e810: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -0006e840: 0973 7464 3a3a 7368 6172 6564 5f70 7472 .std::shared_ptr │ │ │ -0006e850: 266c 743b 746f 7272 656e 745f 696e 666f <torrent_info │ │ │ -0006e860: 2667 743b 206d 5f74 6f72 7265 6e74 5f66 > m_torrent_f │ │ │ -0006e870: 696c 653b 0a3c 2f64 6976 3e0a 0909 2f2f ile;.
    ...// │ │ │ -0006e880: 2054 6869 7320 6973 2074 6865 2073 756d This is the sum │ │ │ -0006e890: 206f 6620 616c 6c20 6e6f 6e2d 7061 6420 of all non-pad │ │ │ -0006e8a0: 6669 6c65 2073 697a 6573 2e20 496e 2074 file sizes. In t │ │ │ -0006e8b0: 6865 206e 6578 7420 6d61 6a6f 7220 7665 he next major ve │ │ │ -0006e8c0: 7273 696f 6e0a 0909 2f2f 2074 6869 7320 rsion...// this │ │ │ -0006e8d0: 6973 2073 746f 7265 6420 696e 2066 696c is stored in fil │ │ │ -0006e8e0: 655f 7374 6f72 6167 6520 616e 6420 6e6f e_storage and no │ │ │ -0006e8f0: 206c 6f6e 6765 7220 6e65 6564 2074 6f20 longer need to │ │ │ -0006e900: 6265 206b 6570 7420 6865 7265 2e0a 0909 be kept here.... │ │ │ -0006e910: 7374 643a 3a69 6e74 3634 5f74 206d 5f73 std::int64_t m_s │ │ │ -0006e920: 697a 655f 6f6e 5f64 6973 6b20 3d20 303b ize_on_disk = 0; │ │ │ -0006e930: 0a0a 0909 2f2f 2061 2062 6163 6b20 7265 ....// a back re │ │ │ -0006e940: 6665 7265 6e63 6520 746f 2074 6865 2073 ference to the s │ │ │ -0006e950: 6573 7369 6f6e 0a09 092f 2f20 7468 6973 ession...// this │ │ │ -0006e960: 2074 6f72 7265 6e74 2062 656c 6f6e 6773 torrent belongs │ │ │ -0006e970: 2074 6f2e 0a09 0961 7578 3a3a 7365 7373 to....aux::sess │ │ │ -0006e980: 696f 6e5f 696e 7465 7266 6163 6526 616d ion_interface&am │ │ │ -0006e990: 703b 206d 5f73 6573 3b0a 0a09 092f 2f20 p; m_ses;....// │ │ │ -0006e9a0: 7468 6973 2076 6563 746f 7220 6973 2073 this vector is s │ │ │ -0006e9b0: 6f72 7465 6420 6174 2061 6c6c 2074 696d orted at all tim │ │ │ -0006e9c0: 6573 2c20 6279 2074 6865 2070 6f69 6e74 es, by the point │ │ │ -0006e9d0: 6572 2076 616c 7565 2e0a 0909 2f2f 2075 er value....// u │ │ │ -0006e9e0: 7365 2073 6f72 7465 645f 696e 7365 7274 se sorted_insert │ │ │ -0006e9f0: 2829 2061 6e64 2073 6f72 7465 645f 6669 () and sorted_fi │ │ │ -0006ea00: 6e64 2829 206f 6e20 6974 2e20 5468 6520 nd() on it. The │ │ │ -0006ea10: 474e 5520 5354 4c0a 0909 2f2f 2069 6d70 GNU STL...// imp │ │ │ -0006ea20: 6c65 6d65 6e74 6174 696f 6e20 6f6e 2044 lementation on D │ │ │ -0006ea30: 6172 7769 6e20 7573 6573 2073 6967 6e69 arwin uses signi │ │ │ -0006ea40: 6669 6361 6e74 6c79 206c 6573 7320 6d65 ficantly less me │ │ │ -0006ea50: 6d6f 7279 2074 6f0a 0909 2f2f 2072 6570 mory to...// rep │ │ │ -0006ea60: 7265 7365 6e74 2061 2076 6563 746f 7220 resent a vector │ │ │ -0006ea70: 7468 616e 2061 2073 6574 2c20 616e 6420 than a set, and │ │ │ -0006ea80: 7468 6973 2073 6574 2069 7320 7479 7069 this set is typi │ │ │ -0006ea90: 6361 6c6c 790a 0909 2f2f 2072 656c 6174 cally...// relat │ │ │ -0006eaa0: 6976 656c 7920 736d 616c 6c2c 2061 6e64 ively small, and │ │ │ -0006eab0: 2069 7427 7320 6368 6561 7020 746f 2063 it's cheap to c │ │ │ -0006eac0: 6f70 7920 706f 696e 7465 7273 2e0a 0909 opy pointers.... │ │ │ -0006ead0: 6175 783a 3a76 6563 746f 7226 6c74 3b70 aux::vector<p │ │ │ -0006eae0: 6565 725f 636f 6e6e 6563 7469 6f6e 2a26 eer_connection*& │ │ │ -0006eaf0: 6774 3b20 6d5f 636f 6e6e 6563 7469 6f6e gt; m_connection │ │ │ -0006eb00: 733b 0a0a 0909 2f2f 2074 6865 2073 6372 s;....// the scr │ │ │ -0006eb10: 6170 6520 6461 7461 2066 726f 6d20 7468 ape data from th │ │ │ -0006eb20: 6520 7472 6163 6b65 7220 7265 7370 6f6e e tracker respon │ │ │ -0006eb30: 7365 2c20 7468 6973 0a09 092f 2f20 6973 se, this...// is │ │ │ -0006eb40: 206f 7074 696f 6e61 6c20 616e 6420 6d61 optional and ma │ │ │ -0006eb50: 7920 6265 2030 7866 6666 6666 660a 0909 y be 0xffffff... │ │ │ -0006eb60: 7374 643a 3a75 696e 7433 325f 7420 6d5f std::uint32_t m_ │ │ │ -0006eb70: 636f 6d70 6c65 7465 3a32 343b 0a0a 0909 complete:24;.... │ │ │ -0006eb80: 2f2f 2073 6574 2074 6f20 7472 7565 2077 // set to true w │ │ │ -0006eb90: 6865 6e20 7468 6973 2074 6f72 7265 6e74 hen this torrent │ │ │ -0006eba0: 206d 6179 206e 6f74 2064 6f77 6e6c 6f61 may not downloa │ │ │ -0006ebb0: 6420 616e 7974 6869 6e67 0a09 0962 6f6f d anything...boo │ │ │ -0006ebc0: 6c20 6d5f 7570 6c6f 6164 5f6d 6f64 653a l m_upload_mode: │ │ │ -0006ebd0: 313b 0a0a 0909 2f2f 2074 6869 7320 6973 1;....// this is │ │ │ -0006ebe0: 2073 6574 2074 6f20 6661 6c73 6520 6173 set to false as │ │ │ -0006ebf0: 206c 6f6e 6720 6173 2074 6865 2063 6f6e long as the con │ │ │ -0006ec00: 6e65 6374 696f 6e73 0a09 092f 2f20 6f66 nections...// of │ │ │ -0006ec10: 2074 6869 7320 746f 7272 656e 7420 6861 this torrent ha │ │ │ -0006ec20: 7665 6e27 7420 6265 656e 2069 6e69 7469 ven't been initi │ │ │ -0006ec30: 616c 697a 6564 2e20 4966 2077 650a 0909 alized. If we... │ │ │ -0006ec40: 2f2f 2068 6176 6520 6d65 7461 6461 7461 // have metadata │ │ │ -0006ec50: 2066 726f 6d20 7468 6520 7374 6172 742c from the start, │ │ │ -0006ec60: 2063 6f6e 6e65 6374 696f 6e73 2061 7265 connections are │ │ │ -0006ec70: 0a09 092f 2f20 696e 6974 6961 6c69 7a65 ...// initialize │ │ │ -0006ec80: 6420 696d 6d65 6469 6174 656c 792c 2069 d immediately, i │ │ │ -0006ec90: 6620 7765 2064 6964 6e27 7420 6861 7665 f we didn't have │ │ │ -0006eca0: 206d 6574 6164 6174 612c 0a09 092f 2f20 metadata,...// │ │ │ -0006ecb0: 7468 6579 2061 7265 2069 6e69 7469 616c they are initial │ │ │ -0006ecc0: 697a 6564 2072 6967 6874 2061 6674 6572 ized right after │ │ │ -0006ecd0: 2066 696c 6573 5f63 6865 636b 6564 2829 files_checked() │ │ │ -0006ece0: 2e0a 0909 2f2f 2076 616c 6964 5f72 6573 ....// valid_res │ │ │ -0006ecf0: 756d 655f 6461 7461 2829 2077 696c 6c20 ume_data() will │ │ │ -0006ed00: 7265 7475 726e 2066 616c 7365 2061 7320 return false as │ │ │ -0006ed10: 6c6f 6e67 2061 730a 0909 2f2f 2074 6865 long as...// the │ │ │ -0006ed20: 2063 6f6e 6e65 6374 696f 6e73 2061 7265 connections are │ │ │ -0006ed30: 6e27 7420 696e 6974 6961 6c69 7a65 642c n't initialized, │ │ │ -0006ed40: 2074 6f20 6176 6f69 640a 3c2f 7072 653e to avoid.
    │ │ │ -0006ed50: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0006ed80: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0006ed90: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../include/ │ │ │ -0006edc0: 6c69 6274 6f72 7265 6e74 2f74 6f72 7265 libtorrent/torre │ │ │ -0006edd0: 6e74 2e68 7070 3a34 3934 3c2f 613e 3c2f nt.hpp:494make grac │ │ │ -0006edf0: 6566 756c 2070 6175 7365 2061 6c73 6f20 eful pause also │ │ │ -0006ee00: 6669 6e69 7368 2061 6c6c 2073 656e 6469 finish all sendi │ │ │ -0006ee10: 6e67 2062 6c6f 636b 7320 6265 666f 7265 ng blocks before │ │ │ -0006ee20: 2064 6973 636f 6e6e 6563 7469 6e67 3c2f disconnecting

    make │ │ │ -0006ee80: 2067 7261 6365 6675 6c20 7061 7573 6520 graceful pause │ │ │ -0006ee90: 616c 736f 2066 696e 6973 6820 616c 6c20 also finish all │ │ │ -0006eea0: 7365 6e64 696e 6720 626c 6f63 6b73 0a62 sending blocks.b │ │ │ -0006eeb0: 6566 6f72 6520 6469 7363 6f6e 6e65 6374 efore disconnect │ │ │ -0006eec0: 696e 673c 2f68 323e 3c68 343e 2e2e 2f69 ing

    ../i │ │ │ -0006eed0: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -0006eee0: 742f 746f 7272 656e 742e 6870 703a 3439 t/torrent.hpp:49 │ │ │ -0006eef0: 343c 2f68 343e 3c70 7265 2073 7479 6c65 4

    │ │ │ -0006ef30: 0a09 0976 6f69 6420 6f6e 5f72 6573 756d  ...void on_resum
    │ │ │ -0006ef40: 655f 6461 7461 5f63 6865 636b 6564 2873  e_data_checked(s
    │ │ │ -0006ef50: 7461 7475 735f 7420 7374 6174 7573 2c20  tatus_t status, 
    │ │ │ -0006ef60: 7374 6f72 6167 655f 6572 726f 7220 636f  storage_error co
    │ │ │ -0006ef70: 6e73 7426 616d 703b 2065 7272 6f72 293b  nst& error);
    │ │ │ -0006ef80: 0a09 0976 6f69 6420 6f6e 5f66 6f72 6365  ...void on_force
    │ │ │ -0006ef90: 5f72 6563 6865 636b 2873 7461 7475 735f  _recheck(status_
    │ │ │ -0006efa0: 7420 7374 6174 7573 2c20 7374 6f72 6167  t status, storag
    │ │ │ -0006efb0: 655f 6572 726f 7220 636f 6e73 7426 616d  e_error const&am
    │ │ │ -0006efc0: 703b 2065 7272 6f72 293b 0a09 0976 6f69  p; error);...voi
    │ │ │ -0006efd0: 6420 6f6e 5f70 6965 6365 5f68 6173 6865  d on_piece_hashe
    │ │ │ -0006efe0: 6428 6175 783a 3a76 6563 746f 7226 6c74  d(aux::vector<
    │ │ │ -0006eff0: 3b73 6861 3235 365f 6861 7368 2667 743b  ;sha256_hash>
    │ │ │ -0006f000: 2062 6c6f 636b 5f68 6173 6865 730a 0909   block_hashes...
    │ │ │ -0006f010: 092c 2070 6965 6365 5f69 6e64 6578 5f74  ., piece_index_t
    │ │ │ -0006f020: 2070 6965 6365 2c20 7368 6131 5f68 6173   piece, sha1_has
    │ │ │ -0006f030: 6820 636f 6e73 7426 616d 703b 2070 6965  h const& pie
    │ │ │ -0006f040: 6365 5f68 6173 680a 0909 092c 2073 746f  ce_hash...., sto
    │ │ │ -0006f050: 7261 6765 5f65 7272 6f72 2063 6f6e 7374  rage_error const
    │ │ │ -0006f060: 2661 6d70 3b20 6572 726f 7229 3b0a 0909  & error);...
    │ │ │ -0006f070: 766f 6964 2066 696c 6573 5f63 6865 636b  void files_check
    │ │ │ -0006f080: 6564 2829 3b0a 0909 766f 6964 2073 7461  ed();...void sta
    │ │ │ -0006f090: 7274 5f63 6865 636b 696e 6728 293b 0a0a  rt_checking();..
    │ │ │ -0006f0a0: 0909 766f 6964 2073 7461 7274 5f61 6e6e  ..void start_ann
    │ │ │ -0006f0b0: 6f75 6e63 696e 6728 293b 0a09 0976 6f69  ouncing();...voi
    │ │ │ -0006f0c0: 6420 7374 6f70 5f61 6e6e 6f75 6e63 696e  d stop_announcin
    │ │ │ -0006f0d0: 6728 293b 0a0a 0909 766f 6964 2073 656e  g();....void sen
    │ │ │ -0006f0e0: 645f 7570 6c6f 6164 5f6f 6e6c 7928 293b  d_upload_only();
    │ │ │ -0006f0f0: 0a0a 2369 666e 6465 6620 544f 5252 454e  ..#ifndef TORREN
    │ │ │ -0006f100: 545f 4449 5341 424c 455f 5348 4152 455f  T_DISABLE_SHARE_
    │ │ │ -0006f110: 4d4f 4445 0a09 0976 6f69 6420 7365 6e64  MODE...void send
    │ │ │ -0006f120: 5f73 6861 7265 5f6d 6f64 6528 293b 0a09  _share_mode();..
    │ │ │ -0006f130: 0976 6f69 6420 7365 745f 7368 6172 655f  .void set_share_
    │ │ │ -0006f140: 6d6f 6465 2862 6f6f 6c20 7329 3b0a 0909  mode(bool s);...
    │ │ │ -0006f150: 626f 6f6c 2073 6861 7265 5f6d 6f64 6528  bool share_mode(
    │ │ │ -0006f160: 2920 636f 6e73 7420 7b20 7265 7475 726e  ) const { return
    │ │ │ -0006f170: 206d 5f73 6861 7265 5f6d 6f64 653b 207d   m_share_mode; }
    │ │ │ -0006f180: 0a23 656e 6469 660a 0a3c 6469 7620 7374  .#endif..
    ..bool gr │ │ │ -0006f1c0: 6163 6566 756c 5f70 6175 7365 2829 2063 aceful_pause() c │ │ │ -0006f1d0: 6f6e 7374 207b 2072 6574 7572 6e20 6d5f onst { return m_ │ │ │ -0006f1e0: 6772 6163 6566 756c 5f70 6175 7365 5f6d graceful_pause_m │ │ │ -0006f1f0: 6f64 653b 207d 0a3c 2f64 6976 3e0a 0909 ode; }.
    ... │ │ │ -0006f200: 746f 7272 656e 745f 666c 6167 735f 7420 torrent_flags_t │ │ │ -0006f210: 666c 6167 7328 2920 636f 6e73 743b 0a09 flags() const;.. │ │ │ -0006f220: 0976 6f69 6420 7365 745f 666c 6167 7328 .void set_flags( │ │ │ -0006f230: 746f 7272 656e 745f 666c 6167 735f 7420 torrent_flags_t │ │ │ -0006f240: 666c 6167 732c 2074 6f72 7265 6e74 5f66 flags, torrent_f │ │ │ -0006f250: 6c61 6773 5f74 206d 6173 6b29 3b0a 0a09 lags_t mask);... │ │ │ -0006f260: 0976 6f69 6420 7365 745f 7570 6c6f 6164 .void set_upload │ │ │ -0006f270: 5f6d 6f64 6528 626f 6f6c 2062 293b 0a09 _mode(bool b);.. │ │ │ -0006f280: 0962 6f6f 6c20 7570 6c6f 6164 5f6d 6f64 .bool upload_mod │ │ │ -0006f290: 6528 2920 636f 6e73 7420 7b20 7265 7475 e() const { retu │ │ │ -0006f2a0: 726e 206d 5f75 706c 6f61 645f 6d6f 6465 rn m_upload_mode │ │ │ -0006f2b0: 207c 7c20 6d5f 6772 6163 6566 756c 5f70 || m_graceful_p │ │ │ -0006f2c0: 6175 7365 5f6d 6f64 653b 207d 0a09 0962 ause_mode; }...b │ │ │ -0006f2d0: 6f6f 6c20 6973 5f75 706c 6f61 645f 6f6e ool is_upload_on │ │ │ -0006f2e0: 6c79 2829 2063 6f6e 7374 207b 2072 6574 ly() const { ret │ │ │ -0006f2f0: 7572 6e20 6973 5f66 696e 6973 6865 6428 urn is_finished( │ │ │ -0006f300: 2920 7c7c 2075 706c 6f61 645f 6d6f 6465 ) || upload_mode │ │ │ -0006f310: 2829 3b20 7d0a 0a09 0969 6e74 2073 6565 (); }....int see │ │ │ -0006f320: 645f 7261 6e6b 2861 7578 3a3a 7365 7373 d_rank(aux::sess │ │ │ -0006f330: 696f 6e5f 7365 7474 696e 6773 2063 6f6e ion_settings con │ │ │ -0006f340: 7374 2661 6d70 3b20 7329 2063 6f6e 7374 st& s) const │ │ │ -0006f350: 3b0a 0a09 0976 6f69 6420 6164 645f 7069 ;....void add_pi │ │ │ -0006f360: 6563 6528 7069 6563 655f 696e 6465 785f ece(piece_index_ │ │ │ -0006f370: 7420 7069 6563 652c 2063 6861 7220 636f t piece, char co │ │ │ -0006f380: 6e73 742a 2064 6174 612c 2061 6464 5f70 nst* data, add_p │ │ │ -0006f390: 6965 6365 5f66 6c61 6773 5f74 2066 6c61 iece_flags_t fla │ │ │ -0006f3a0: 6773 293b 0a09 0976 6f69 6420 6164 645f gs);...void add_ │ │ │ -0006f3b0: 7069 6563 655f 6173 796e 6328 7069 6563 piece_async(piec │ │ │ -0006f3c0: 655f 696e 6465 785f 7420 7069 6563 652c e_index_t piece, │ │ │ -0006f3d0: 2073 7464 3a3a 7665 6374 6f72 266c 743b std::vector< │ │ │ -0006f3e0: 6368 6172 2667 743b 2064 6174 612c 2061 char> data, a │ │ │ -0006f3f0: 6464 5f70 6965 6365 5f66 6c61 6773 5f74 dd_piece_flags_t │ │ │ -0006f400: 2066 6c61 6773 293b 0a09 0976 6f69 6420 flags);...void │ │ │ -0006f410: 6f6e 5f64 6973 6b5f 7772 6974 655f 636f on_disk_write_co │ │ │ -0006f420: 6d70 6c65 7465 2873 746f 7261 6765 5f65 mplete(storage_e │ │ │ -0006f430: 7272 6f72 2063 6f6e 7374 2661 6d70 3b20 rror const& │ │ │ -0006f440: 6572 726f 720a 0909 092c 2070 6565 725f error...., peer_ │ │ │ -0006f450: 7265 7175 6573 7420 636f 6e73 7426 616d request const&am │ │ │ -0006f460: 703b 2070 293b 0a0a 0909 766f 6964 2073 p; p);....void s │ │ │ -0006f470: 6574 5f70 726f 6772 6573 735f 7070 6d28 et_progress_ppm( │ │ │ -0006f480: 696e 7420 7029 207b 206d 5f70 726f 6772 int p) { m_progr │ │ │ -0006f490: 6573 735f 7070 6d20 3d20 7374 643a 3a75 ess_ppm = std::u │ │ │ -0006f4a0: 696e 7433 325f 7428 7029 3b20 7d0a 0909 int32_t(p); }... │ │ │ -0006f4b0: 7374 7275 6374 2072 6561 645f 7069 6563 struct read_piec │ │ │ -0006f4c0: 655f 7374 7275 6374 0a09 097b 0a09 0909 e_struct...{.... │ │ │ -0006f4d0: 626f 6f73 743a 3a73 6861 7265 645f 6172 boost::shared_ar │ │ │ -0006f4e0: 7261 7926 6c74 3b63 6861 7226 6774 3b20 ray<char> │ │ │ -0006f4f0: 7069 6563 655f 6461 7461 3b0a 0909 0969 piece_data;....i │ │ │ -0006f500: 6e74 2062 6c6f 636b 735f 6c65 6674 3b0a nt blocks_left;. │ │ │ -0006f510: 0909 0962 6f6f 6c20 6661 696c 3b0a 0909 ...bool fail;... │ │ │ -0006f520: 0965 7272 6f72 5f63 6f64 6520 6572 726f .error_code erro │ │ │ -0006f530: 723b 0a09 097d 3b0a 0909 766f 6964 2072 r;...};...void r │ │ │ -0006f540: 6561 645f 7069 6563 6528 7069 6563 655f ead_piece(piece_ │ │ │ -0006f550: 696e 6465 785f 7429 3b0a 0909 766f 6964 index_t);...void │ │ │ -0006f560: 206f 6e5f 6469 736b 5f72 6561 645f 636f on_disk_read_co │ │ │ -0006f570: 6d70 6c65 7465 2864 6973 6b5f 6275 6666 mplete(disk_buff │ │ │ -0006f580: 6572 5f68 6f6c 6465 722c 2073 746f 7261 er_holder, stora │ │ │ -0006f590: 6765 5f65 7272 6f72 2063 6f6e 7374 2661 ge_error const&a │ │ │ -0006f5a0: 6d70 3b0a 0909 092c 2070 6565 725f 7265 mp;...., peer_re │ │ │ -0006f5b0: 7175 6573 7420 636f 6e73 7426 616d 703b quest const& │ │ │ -0006f5c0: 2c20 7374 643a 3a73 6861 7265 645f 7074 , std::shared_pt │ │ │ -0006f5d0: 7226 6c74 3b72 6561 645f 7069 6563 655f r<read_piece_ │ │ │ -0006f5e0: 7374 7275 6374 2667 743b 293b 0a0a 0909 struct>);.... │ │ │ -0006f5f0: 7374 6f72 6167 655f 6d6f 6465 5f74 2073 storage_mode_t s │ │ │ -0006f600: 746f 7261 6765 5f6d 6f64 6528 2920 636f torage_mode() co │ │ │ -0006f610: 6e73 743b 0a0a 0909 2f2f 2074 6869 7320 nst;....// this │ │ │ -0006f620: 7769 6c6c 2066 6c61 6720 7468 6520 746f will flag the to │ │ │ -0006f630: 7272 656e 7420 6173 2061 626f 7274 6564 rrent as aborted │ │ │ -0006f640: 2e20 5468 6520 6d61 696e 0a3c 2f70 7265 . The main.
    rele │ │ │ -0006f680: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../include │ │ │ -0006f6c0: 2f6c 6962 746f 7272 656e 742f 746f 7272 /libtorrent/torr │ │ │ -0006f6d0: 656e 742e 6870 703a 3633 313c 2f61 3e3c ent.hpp:631< │ │ │ -0006f6e0: 2f74 643e 3c74 643e 6d61 6b65 2074 6869 /td>make thi │ │ │ -0006f6f0: 7320 666c 6167 2061 2063 6f6d 6269 6e61 s flag a combina │ │ │ -0006f700: 7469 6f6e 206f 6620 7468 6520 6f74 6865 tion of the othe │ │ │ -0006f710: 7220 6f6e 6573 3c2f 7464 3e3c 2f74 723e r ones │ │ │ -0006f720: 3c74 7220 6964 3d22 3235 3322 2073 7479 │ │ │ -0006f750: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0006f760: 3c68 323e 6d61 6b65 2074 6869 7320 666c

    make this fl │ │ │ -0006f770: 6167 2061 2063 6f6d 6269 6e61 7469 6f6e ag a combination │ │ │ -0006f780: 0a6f 6620 7468 6520 6f74 6865 7220 6f6e .of the other on │ │ │ -0006f790: 6573 3c2f 6832 3e3c 6834 3e2e 2e2f 696e es

    ../in │ │ │ -0006f7a0: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -0006f7b0: 2f74 6f72 7265 6e74 2e68 7070 3a36 3331 /torrent.hpp:631 │ │ │ -0006f7c0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -0006f800: 0976 6f69 6420 646f 5f70 6175 7365 2829  .void do_pause()
    │ │ │ -0006f810: 3b0a 0909 766f 6964 2064 6f5f 7265 7375  ;...void do_resu
    │ │ │ -0006f820: 6d65 2829 3b0a 0a09 0973 6563 6f6e 6473  me();....seconds
    │ │ │ -0006f830: 3332 2066 696e 6973 6865 645f 7469 6d65  32 finished_time
    │ │ │ -0006f840: 2829 2063 6f6e 7374 3b0a 0909 7365 636f  () const;...seco
    │ │ │ -0006f850: 6e64 7333 3220 6163 7469 7665 5f74 696d  nds32 active_tim
    │ │ │ -0006f860: 6528 2920 636f 6e73 743b 0a09 0973 6563  e() const;...sec
    │ │ │ -0006f870: 6f6e 6473 3332 2073 6565 6469 6e67 5f74  onds32 seeding_t
    │ │ │ -0006f880: 696d 6528 2920 636f 6e73 743b 0a09 0973  ime() const;...s
    │ │ │ -0006f890: 6563 6f6e 6473 3332 2075 706c 6f61 645f  econds32 upload_
    │ │ │ -0006f8a0: 6d6f 6465 5f74 696d 6528 2920 636f 6e73  mode_time() cons
    │ │ │ -0006f8b0: 743b 0a0a 0909 626f 6f6c 2069 735f 7061  t;....bool is_pa
    │ │ │ -0006f8c0: 7573 6564 2829 2063 6f6e 7374 3b0a 0909  used() const;...
    │ │ │ -0006f8d0: 626f 6f6c 2069 735f 746f 7272 656e 745f  bool is_torrent_
    │ │ │ -0006f8e0: 7061 7573 6564 2829 2063 6f6e 7374 207b  paused() const {
    │ │ │ -0006f8f0: 2072 6574 7572 6e20 6d5f 7061 7573 6564   return m_paused
    │ │ │ -0006f900: 3b20 7d0a 0909 766f 6964 2066 6f72 6365  ; }...void force
    │ │ │ -0006f910: 5f72 6563 6865 636b 2829 3b0a 0909 766f  _recheck();...vo
    │ │ │ -0006f920: 6964 2073 6176 655f 7265 7375 6d65 5f64  id save_resume_d
    │ │ │ -0006f930: 6174 6128 7265 7375 6d65 5f64 6174 615f  ata(resume_data_
    │ │ │ -0006f940: 666c 6167 735f 7420 666c 6167 7329 3b0a  flags_t flags);.
    │ │ │ -0006f950: 0a09 0962 6f6f 6c20 6e65 6564 5f73 6176  ...bool need_sav
    │ │ │ -0006f960: 655f 7265 7375 6d65 5f64 6174 6128 7265  e_resume_data(re
    │ │ │ -0006f970: 7375 6d65 5f64 6174 615f 666c 6167 735f  sume_data_flags_
    │ │ │ -0006f980: 7420 666c 6167 7329 2063 6f6e 7374 0a09  t flags) const..
    │ │ │ -0006f990: 097b 0a09 0909 7265 7475 726e 2062 6f6f  .{....return boo
    │ │ │ -0006f9a0: 6c28 6d5f 6e65 6564 5f73 6176 655f 7265  l(m_need_save_re
    │ │ │ -0006f9b0: 7375 6d65 5f64 6174 6120 2661 6d70 3b20  sume_data & 
    │ │ │ -0006f9c0: 666c 6167 7329 3b0a 0909 7d0a 0a09 0976  flags);...}....v
    │ │ │ -0006f9d0: 6f69 6420 7365 745f 6e65 6564 5f73 6176  oid set_need_sav
    │ │ │ -0006f9e0: 655f 7265 7375 6d65 2872 6573 756d 655f  e_resume(resume_
    │ │ │ -0006f9f0: 6461 7461 5f66 6c61 6773 5f74 2063 6f6e  data_flags_t con
    │ │ │ -0006fa00: 7374 2066 6c61 6729 0a09 097b 0a3c 6469  st flag)...{....m_
    │ │ │ -0006fa40: 6e65 6564 5f73 6176 655f 7265 7375 6d65  need_save_resume
    │ │ │ -0006fa50: 5f64 6174 6120 7c3d 2074 6f72 7265 6e74  _data |= torrent
    │ │ │ -0006fa60: 5f68 616e 646c 653a 3a6f 6e6c 795f 6966  _handle::only_if
    │ │ │ -0006fa70: 5f6d 6f64 6966 6965 643b 0a3c 2f64 6976  _modified;.....if (m_need_
    │ │ │ -0006fa90: 7361 7665 5f72 6573 756d 655f 6461 7461  save_resume_data
    │ │ │ -0006faa0: 2026 616d 703b 2066 6c61 6729 2072 6574   & flag) ret
    │ │ │ -0006fab0: 7572 6e3b 0a09 0909 6d5f 6e65 6564 5f73  urn;....m_need_s
    │ │ │ -0006fac0: 6176 655f 7265 7375 6d65 5f64 6174 6120  ave_resume_data 
    │ │ │ -0006fad0: 7c3d 2066 6c61 673b 0a09 0909 7374 6174  |= flag;....stat
    │ │ │ -0006fae0: 655f 7570 6461 7465 6428 293b 0a09 097d  e_updated();...}
    │ │ │ -0006faf0: 0a0a 0909 6164 645f 746f 7272 656e 745f  ....add_torrent_
    │ │ │ -0006fb00: 7061 7261 6d73 2067 6574 5f72 6573 756d  params get_resum
    │ │ │ -0006fb10: 655f 6461 7461 2872 6573 756d 655f 6461  e_data(resume_da
    │ │ │ -0006fb20: 7461 5f66 6c61 6773 5f74 2066 6c61 6773  ta_flags_t flags
    │ │ │ -0006fb30: 2920 636f 6e73 743b 0a0a 0909 626f 6f6c  ) const;....bool
    │ │ │ -0006fb40: 2069 735f 6175 746f 5f6d 616e 6167 6564   is_auto_managed
    │ │ │ -0006fb50: 2829 2063 6f6e 7374 207b 2072 6574 7572  () const { retur
    │ │ │ -0006fb60: 6e20 6d5f 6175 746f 5f6d 616e 6167 6564  n m_auto_managed
    │ │ │ -0006fb70: 3b20 7d0a 0909 766f 6964 2061 7574 6f5f  ; }...void auto_
    │ │ │ -0006fb80: 6d61 6e61 6765 6428 626f 6f6c 2061 293b  managed(bool a);
    │ │ │ -0006fb90: 0a0a 0909 626f 6f6c 2073 686f 756c 645f  ....bool should_
    │ │ │ -0006fba0: 6368 6563 6b5f 6669 6c65 7328 2920 636f  check_files() co
    │ │ │ -0006fbb0: 6e73 743b 0a0a 0909 626f 6f6c 2064 656c  nst;....bool del
    │ │ │ -0006fbc0: 6574 655f 6669 6c65 7328 7265 6d6f 7665  ete_files(remove
    │ │ │ -0006fbd0: 5f66 6c61 6773 5f74 206f 7074 696f 6e73  _flags_t options
    │ │ │ -0006fbe0: 293b 0a09 0976 6f69 6420 7065 6572 735f  );...void peers_
    │ │ │ -0006fbf0: 6572 6173 6564 2873 7464 3a3a 7665 6374  erased(std::vect
    │ │ │ -0006fc00: 6f72 266c 743b 746f 7272 656e 745f 7065  or<torrent_pe
    │ │ │ -0006fc10: 6572 2a26 6774 3b20 636f 6e73 7426 616d  er*> const&am
    │ │ │ -0006fc20: 703b 2070 6565 7273 293b 0a0a 2369 6620  p; peers);..#if 
    │ │ │ -0006fc30: 544f 5252 454e 545f 4142 495f 5645 5253  TORRENT_ABI_VERS
    │ │ │ -0006fc40: 494f 4e20 3d3d 2031 0a23 6966 2021 544f  ION == 1.#if !TO
    │ │ │ -0006fc50: 5252 454e 545f 4e4f 5f46 5055 0a09 0976  RRENT_NO_FPU...v
    │ │ │ -0006fc60: 6f69 6420 6669 6c65 5f70 726f 6772 6573  oid file_progres
    │ │ │ -0006fc70: 735f 666c 6f61 7428 6175 783a 3a76 6563  s_float(aux::vec
    │ │ │ -0006fc80: 746f 7226 6c74 3b66 6c6f 6174 2c20 6669  tor<float, fi
    │ │ │ -0006fc90: 6c65 5f69 6e64 6578 5f74 2667 743b 2661  le_index_t>&a
    │ │ │ -0006fca0: 6d70 3b20 6670 293b 0a23 656e 6469 660a  mp; fp);.#endif.
    │ │ │ -0006fcb0: 2365 6e64 6966 202f 2f20 544f 5252 454e  #endif // TORREN
    │ │ │ -0006fcc0: 545f 4142 495f 5645 5253 494f 4e0a 0a09  T_ABI_VERSION...
    │ │ │ -0006fcd0: 0976 6f69 6420 706f 7374 5f70 6965 6365  .void post_piece
    │ │ │ -0006fce0: 5f61 7661 696c 6162 696c 6974 7928 293b  _availability();
    │ │ │ -0006fcf0: 0a09 0976 6f69 6420 7069 6563 655f 6176  ...void piece_av
    │ │ │ -0006fd00: 6169 6c61 6269 6c69 7479 2861 7578 3a3a  ailability(aux::
    │ │ │ -0006fd10: 7665 6374 6f72 266c 743b 696e 742c 2070  vector<int, p
    │ │ │ -0006fd20: 6965 6365 5f69 6e64 6578 5f74 2667 743b  iece_index_t>
    │ │ │ -0006fd30: 2661 6d70 3b20 6176 6169 6c29 2063 6f6e  & avail) con
    │ │ │ -0006fd40: 7374 3b0a 0a09 0976 6f69 6420 7365 745f  st;....void set_
    │ │ │ -0006fd50: 7069 6563 655f 7072 696f 7269 7479 2870  piece_priority(p
    │ │ │ -0006fd60: 6965 6365 5f69 6e64 6578 5f74 2069 6e64  iece_index_t ind
    │ │ │ -0006fd70: 6578 2c20 646f 776e 6c6f 6164 5f70 7269  ex, download_pri
    │ │ │ -0006fd80: 6f72 6974 795f 7420 7072 696f 7269 7479  ority_t priority
    │ │ │ -0006fd90: 293b 0a09 0964 6f77 6e6c 6f61 645f 7072  );...download_pr
    │ │ │ -0006fda0: 696f 7269 7479 5f74 2070 6965 6365 5f70  iority_t piece_p
    │ │ │ -0006fdb0: 7269 6f72 6974 7928 7069 6563 655f 696e  riority(piece_in
    │ │ │ -0006fdc0: 6465 785f 7420 696e 6465 7829 2063 6f6e  dex_t index) con
    │ │ │ -0006fdd0: 7374 3b0a 0a09 0976 6f69 6420 7072 696f  st;....void prio
    │ │ │ -0006fde0: 7269 7469 7a65 5f70 6965 6365 7328 6175  ritize_pieces(au
    │ │ │ -0006fdf0: 783a 3a76 6563 746f 7226 6c74 3b64 6f77  x::vector<dow
    │ │ │ -0006fe00: 6e6c 6f61 645f 7072 696f 7269 7479 5f74  nload_priority_t
    │ │ │ -0006fe10: 2c20 7069 6563 655f 696e 6465 785f 7426  , piece_index_t&
    │ │ │ -0006fe20: 6774 3b20 636f 6e73 7426 616d 703b 2070  gt; const& p
    │ │ │ -0006fe30: 6965 6365 7329 3b0a 0909 766f 6964 2070  ieces);...void p
    │ │ │ -0006fe40: 7269 6f72 6974 697a 655f 7069 6563 655f  rioritize_piece_
    │ │ │ -0006fe50: 6c69 7374 2873 7464 3a3a 7665 6374 6f72  list(std::vector
    │ │ │ -0006fe60: 266c 743b 7374 643a 3a70 6169 7226 6c74  <std::pair<
    │ │ │ -0006fe70: 3b70 6965 6365 5f69 6e64 6578 5f74 2c20  ;piece_index_t, 
    │ │ │ -0006fe80: 646f 776e 6c6f 6164 5f70 7269 6f72 6974  download_priorit
    │ │ │ -0006fe90: 795f 7426 6774 3b26 6774 3b20 636f 6e73  y_t>> cons
    │ │ │ -0006fea0: 7426 616d 703b 2070 6965 6365 7329 3b0a  t& pieces);.
    │ │ │ -0006feb0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e  
    │ │ │ -0006fec0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0006fef0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../in │ │ │ -0006ff20: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -0006ff30: 2f74 6f72 7265 6e74 2e68 7070 3a31 3434 /torrent.hpp:144 │ │ │ -0006ff40: 303c 2f61 3e3c 2f74 643e 3c74 643e 7468 0th │ │ │ -0006ff50: 6973 2077 6173 7465 7320 3520 6269 7473 is wastes 5 bits │ │ │ -0006ff60: 2070 6572 2066 696c 653c 2f74 643e 3c2f per file

    this wast │ │ │ -0006ffc0: 6573 2035 2062 6974 7320 7065 7220 6669 es 5 bits per fi │ │ │ -0006ffd0: 6c65 3c2f 6832 3e3c 6834 3e2e 2e2f 696e le

    ../in │ │ │ -0006ffe0: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -0006fff0: 2f74 6f72 7265 6e74 2e68 7070 3a31 3434 /torrent.hpp:144 │ │ │ -00070000: 303c 2f68 343e 3c70 7265 2073 7479 6c65 0

    │ │ │ -00070040: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ -00070050: 4449 5341 424c 455f 4558 5445 4e53 494f  DISABLE_EXTENSIO
    │ │ │ -00070060: 4e53 0a09 0973 7464 3a3a 6c69 7374 266c  NS...std::list&l
    │ │ │ -00070070: 743b 7374 643a 3a73 6861 7265 645f 7074  t;std::shared_pt
    │ │ │ -00070080: 7226 6c74 3b74 6f72 7265 6e74 5f70 6c75  r<torrent_plu
    │ │ │ -00070090: 6769 6e26 6774 3b26 6774 3b20 6d5f 6578  gin>> m_ex
    │ │ │ -000700a0: 7465 6e73 696f 6e73 3b0a 2365 6e64 6966  tensions;.#endif
    │ │ │ -000700b0: 0a0a 0909 2f2f 2075 7365 6420 666f 7220  ....// used for 
    │ │ │ -000700c0: 7472 6163 6b65 7220 616e 6e6f 756e 6365  tracker announce
    │ │ │ -000700d0: 730a 0909 6465 6164 6c69 6e65 5f74 696d  s...deadline_tim
    │ │ │ -000700e0: 6572 206d 5f74 7261 636b 6572 5f74 696d  er m_tracker_tim
    │ │ │ -000700f0: 6572 3b0a 0a09 092f 2f20 7573 6564 2074  er;....// used t
    │ │ │ -00070100: 6f20 6465 7465 6374 2077 6865 6e20 7765  o detect when we
    │ │ │ -00070110: 2061 7265 2061 6374 6976 6520 6f72 2069   are active or i
    │ │ │ -00070120: 6e61 6374 6976 6520 666f 7220 6c6f 6e67  nactive for long
    │ │ │ -00070130: 2065 6e6f 7567 680a 0909 2f2f 2074 6f20   enough...// to 
    │ │ │ -00070140: 7472 6967 6765 7220 7468 6520 6175 746f  trigger the auto
    │ │ │ -00070150: 2d6d 616e 6167 6520 6c6f 6769 630a 0909  -manage logic...
    │ │ │ -00070160: 6465 6164 6c69 6e65 5f74 696d 6572 206d  deadline_timer m
    │ │ │ -00070170: 5f69 6e61 6374 6976 6974 795f 7469 6d65  _inactivity_time
    │ │ │ -00070180: 723b 0a0a 0909 2f2f 2074 6869 7320 6973  r;....// this is
    │ │ │ -00070190: 2074 6865 2075 706c 6f61 6420 616e 6420   the upload and 
    │ │ │ -000701a0: 646f 776e 6c6f 6164 2073 7461 7469 7374  download statist
    │ │ │ -000701b0: 6963 7320 666f 7220 7468 6520 7768 6f6c  ics for the whol
    │ │ │ -000701c0: 6520 746f 7272 656e 742e 0a09 092f 2f20  e torrent....// 
    │ │ │ -000701d0: 6974 2773 2075 7064 6174 6564 2066 726f  it's updated fro
    │ │ │ -000701e0: 6d20 616c 6c20 6974 7320 7065 6572 7320  m all its peers 
    │ │ │ -000701f0: 6f6e 6365 2065 7665 7279 2073 6563 6f6e  once every secon
    │ │ │ -00070200: 642e 0a09 096c 6962 746f 7272 656e 743a  d....libtorrent:
    │ │ │ -00070210: 3a73 7461 7420 6d5f 7374 6174 3b0a 0a09  :stat m_stat;...
    │ │ │ -00070220: 092f 2f20 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  .// ------------
    │ │ │ -00070230: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -00070240: 2d0a 0a09 092f 2f20 7468 6973 2076 6563  -....// this vec
    │ │ │ -00070250: 746f 7220 6973 2061 6c6c 6f63 6174 6564  tor is allocated
    │ │ │ -00070260: 206c 617a 696c 792e 2049 6620 6e6f 2066   lazily. If no f
    │ │ │ -00070270: 696c 6520 7072 696f 7269 7469 6573 2061  ile priorities a
    │ │ │ -00070280: 7265 0a09 092f 2f20 6576 6572 2063 6861  re...// ever cha
    │ │ │ -00070290: 6e67 6564 2c20 7468 6973 2072 656d 6169  nged, this remai
    │ │ │ -000702a0: 6e73 2065 6d70 7479 2e20 416e 7920 756e  ns empty. Any un
    │ │ │ -000702b0: 616c 6c6f 6361 7465 6420 736c 6f74 0a09  allocated slot..
    │ │ │ -000702c0: 092f 2f20 696d 706c 6963 6974 6c79 206d  .// implicitly m
    │ │ │ -000702d0: 6561 6e73 2074 6865 2066 696c 6520 6861  eans the file ha
    │ │ │ -000702e0: 7320 7072 696f 7269 7479 2034 2e0a 3c64  s priority 4....au
    │ │ │ -00070320: 783a 3a76 6563 746f 7226 6c74 3b64 6f77  x::vector<dow
    │ │ │ -00070330: 6e6c 6f61 645f 7072 696f 7269 7479 5f74  nload_priority_t
    │ │ │ -00070340: 2c20 6669 6c65 5f69 6e64 6578 5f74 2667  , file_index_t&g
    │ │ │ -00070350: 743b 206d 5f66 696c 655f 7072 696f 7269  t; m_file_priori
    │ │ │ -00070360: 7479 3b0a 3c2f 6469 763e 0a09 092f 2f20  ty;....// 
    │ │ │ -00070370: 616e 7920 6669 6c65 2070 7269 6f72 6974  any file priorit
    │ │ │ -00070380: 7920 7570 6461 7465 7320 6174 7465 6d70  y updates attemp
    │ │ │ -00070390: 7465 6420 7768 696c 6520 616e 6f74 6865  ted while anothe
    │ │ │ -000703a0: 7220 6669 6c65 2070 7269 6f72 6974 7920  r file priority 
    │ │ │ -000703b0: 7570 6461 7465 0a09 092f 2f20 6973 2069  update...// is i
    │ │ │ -000703c0: 6e2d 7072 6f67 7265 7373 2f6f 7574 7374  n-progress/outst
    │ │ │ -000703d0: 616e 6469 6e67 2077 6974 6820 7468 6520  anding with the 
    │ │ │ -000703e0: 6469 736b 2049 2f4f 2074 6872 6561 642c  disk I/O thread,
    │ │ │ -000703f0: 2061 7265 2071 7565 7565 6420 7570 2069   are queued up i
    │ │ │ -00070400: 6e0a 0909 2f2f 2074 6869 7320 6469 6374  n...// this dict
    │ │ │ -00070410: 696f 6e61 7279 2e20 4f6e 6365 2074 6865  ionary. Once the
    │ │ │ -00070420: 206f 7574 7374 616e 6469 6e67 2075 7064   outstanding upd
    │ │ │ -00070430: 6174 6520 636f 6d65 7320 6261 636b 2c20  ate comes back, 
    │ │ │ -00070440: 616c 6c20 6f66 2074 6865 7365 0a09 092f  all of these.../
    │ │ │ -00070450: 2f20 6172 6520 6170 706c 6965 6420 696e  / are applied in
    │ │ │ -00070460: 206f 6e65 2062 6174 6368 0a09 0973 7464   one batch...std
    │ │ │ -00070470: 3a3a 6d61 7026 6c74 3b66 696c 655f 696e  ::map<file_in
    │ │ │ -00070480: 6465 785f 742c 2064 6f77 6e6c 6f61 645f  dex_t, download_
    │ │ │ -00070490: 7072 696f 7269 7479 5f74 2667 743b 206d  priority_t> m
    │ │ │ -000704a0: 5f64 6566 6572 7265 645f 6669 6c65 5f70  _deferred_file_p
    │ │ │ -000704b0: 7269 6f72 6974 6965 733b 0a0a 0909 2f2f  riorities;....//
    │ │ │ -000704c0: 2074 6869 7320 6f62 6a65 6374 2069 7320   this object is 
    │ │ │ -000704d0: 7573 6564 2074 6f20 7472 6163 6b20 646f  used to track do
    │ │ │ -000704e0: 776e 6c6f 6164 2070 726f 6772 6573 7320  wnload progress 
    │ │ │ -000704f0: 6f66 2069 6e64 6976 6964 7561 6c20 6669  of individual fi
    │ │ │ -00070500: 6c65 730a 0909 6175 783a 3a66 696c 655f  les...aux::file_
    │ │ │ -00070510: 7072 6f67 7265 7373 206d 5f66 696c 655f  progress m_file_
    │ │ │ -00070520: 7072 6f67 7265 7373 3b0a 0a09 092f 2f20  progress;....// 
    │ │ │ -00070530: 6120 7175 6575 6520 6f66 2074 6865 206d  a queue of the m
    │ │ │ -00070540: 6f73 7420 7265 6365 6e74 206c 6f77 2d61  ost recent low-a
    │ │ │ -00070550: 7661 696c 6162 696c 6974 7920 7069 6563  vailability piec
    │ │ │ -00070560: 6573 2077 6520 6163 6365 7373 6564 206f  es we accessed o
    │ │ │ -00070570: 6e20 6469 736b 2e0a 0909 2f2f 2054 6865  n disk....// The
    │ │ │ -00070580: 7365 2061 7265 2067 6f6f 6420 6361 6e64  se are good cand
    │ │ │ -00070590: 6964 6174 6573 2066 6f72 2073 7567 6765  idates for sugge
    │ │ │ -000705a0: 7374 696e 6720 6f74 6865 7220 7065 6572  sting other peer
    │ │ │ -000705b0: 7320 746f 2072 6571 7565 7374 2066 726f  s to request fro
    │ │ │ -000705c0: 6d0a 0909 2f2f 2075 732e 0a09 0961 7578  m...// us....aux
    │ │ │ -000705d0: 3a3a 7375 6767 6573 745f 7069 6563 6520  ::suggest_piece 
    │ │ │ -000705e0: 6d5f 7375 6767 6573 745f 7069 6563 6573  m_suggest_pieces
    │ │ │ -000705f0: 3b0a 0a09 0961 7578 3a3a 7665 6374 6f72  ;....aux::vector
    │ │ │ -00070600: 266c 743b 6175 783a 3a61 6e6e 6f75 6e63  <aux::announc
    │ │ │ -00070610: 655f 656e 7472 7926 6774 3b20 6d5f 7472  e_entry> m_tr
    │ │ │ -00070620: 6163 6b65 7273 3b0a 0a23 6966 6e64 6566  ackers;..#ifndef
    │ │ │ -00070630: 2054 4f52 5245 4e54 5f44 4953 4142 4c45   TORRENT_DISABLE
    │ │ │ -00070640: 5f53 5452 4541 4d49 4e47 0a09 092f 2f20  _STREAMING...// 
    │ │ │ -00070650: 7468 6973 206c 6973 7420 6973 2073 6f72  this list is sor
    │ │ │ -00070660: 7465 6420 6279 2074 696d 655f 6372 6974  ted by time_crit
    │ │ │ -00070670: 6963 616c 5f70 6965 6365 3a3a 6465 6164  ical_piece::dead
    │ │ │ -00070680: 6c69 6e65 0a09 0973 7464 3a3a 7665 6374  line...std::vect
    │ │ │ -00070690: 6f72 266c 743b 7469 6d65 5f63 7269 7469  or<time_criti
    │ │ │ -000706a0: 6361 6c5f 7069 6563 6526 6774 3b20 6d5f  cal_piece> m_
    │ │ │ -000706b0: 7469 6d65 5f63 7269 7469 6361 6c5f 7069  time_critical_pi
    │ │ │ -000706c0: 6563 6573 3b0a 2365 6e64 6966 0a0a 0909  eces;.#endif....
    │ │ │ -000706d0: 7374 643a 3a73 7472 696e 6720 6d5f 7472  std::string m_tr
    │ │ │ -000706e0: 6163 6b65 7269 643b 0a23 6966 2054 4f52  ackerid;.#if TOR
    │ │ │ -000706f0: 5245 4e54 5f41 4249 5f56 4552 5349 4f4e  RENT_ABI_VERSION
    │ │ │ -00070700: 203d 3d20 310a 0909 2f2f 2064 6570 7265   == 1...// depre
    │ │ │ -00070710: 6361 7465 6420 696e 2031 2e31 0a09 0973  cated in 1.1...s
    │ │ │ -00070720: 7464 3a3a 7374 7269 6e67 206d 5f75 7365  td::string m_use
    │ │ │ -00070730: 726e 616d 653b 0a09 0973 7464 3a3a 7374  rname;...std::st
    │ │ │ -00070740: 7269 6e67 206d 5f70 6173 7377 6f72 643b  ring m_password;
    │ │ │ -00070750: 0a23 656e 6469 660a 0a09 0973 7464 3a3a  .#endif....std::
    │ │ │ -00070760: 7374 7269 6e67 206d 5f73 6176 655f 7061  string m_save_pa
    │ │ │ -00070770: 7468 3b0a 3c2f 7072 653e 3c2f 7464 3e3c  th;.
    < │ │ │ -00070780: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -000707b0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -000707e0: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -000707f0: 7265 6e74 2f74 6f72 7265 6e74 2e68 7070 rent/torrent.hpp │ │ │ -00070800: 3a31 3733 373c 2f61 3e3c 2f74 643e 3c74 :1737this member ca │ │ │ -00070820: 6e20 7072 6f62 6162 6c79 2062 6520 7265 n probably be re │ │ │ -00070830: 6d6f 7665 643c 2f74 643e 3c2f 7472 3e3c moved< │ │ │ -00070840: 7472 2069 643d 2232 3535 2220 7374 796c tr id="255" styl │ │ │ -00070850: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00070860: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00070870: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00070880: 6832 3e74 6869 7320 6d65 6d62 6572 2063 h2>this member c │ │ │ -00070890: 616e 2070 726f 6261 626c 7920 6265 2072 an probably be r │ │ │ -000708a0: 656d 6f76 6564 3c2f 6832 3e3c 6834 3e2e emoved

    . │ │ │ -000708b0: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -000708c0: 7265 6e74 2f74 6f72 7265 6e74 2e68 7070 rent/torrent.hpp │ │ │ -000708d0: 3a31 3733 373c 2f68 343e 3c70 7265 2073 :1737

    ..unsigned i
    │ │ │ -00070920: 6e74 206d 5f6e 756d 5f75 706c 6f61 6473  nt m_num_uploads
    │ │ │ -00070930: 3a32 343b 0a0a 0909 2f2f 2034 2075 6e75  :24;....// 4 unu
    │ │ │ -00070940: 7365 6420 6269 7473 0a0a 0909 2f2f 2077  sed bits....// w
    │ │ │ -00070950: 6865 6e20 7468 6973 2069 7320 7472 7565  hen this is true
    │ │ │ -00070960: 2c20 7468 6973 2074 6f72 7265 6e74 2073  , this torrent s
    │ │ │ -00070970: 7570 706f 7274 7320 7065 6572 2065 7863  upports peer exc
    │ │ │ -00070980: 6861 6e67 650a 0909 626f 6f6c 206d 5f65  hange...bool m_e
    │ │ │ -00070990: 6e61 626c 655f 7065 783a 313b 0a0a 0909  nable_pex:1;....
    │ │ │ -000709a0: 2f2f 2073 6574 2074 6f20 7472 7565 2069  // set to true i
    │ │ │ -000709b0: 6620 7468 6520 7365 7373 696f 6e20 4950  f the session IP
    │ │ │ -000709c0: 2066 696c 7465 7220 6170 706c 6965 7320   filter applies 
    │ │ │ -000709d0: 746f 2074 6869 730a 0909 2f2f 2074 6f72  to this...// tor
    │ │ │ -000709e0: 7265 6e74 206f 7220 6e6f 742e 2044 6566  rent or not. Def
    │ │ │ -000709f0: 6175 6c74 7320 746f 2074 7275 652e 0a09  aults to true...
    │ │ │ -00070a00: 0962 6f6f 6c20 6d5f 6170 706c 795f 6970  .bool m_apply_ip
    │ │ │ -00070a10: 5f66 696c 7465 723a 313b 0a0a 0909 2f2f  _filter:1;....//
    │ │ │ -00070a20: 2074 6869 7320 6973 2074 7275 6520 7768   this is true wh
    │ │ │ -00070a30: 656e 206f 7572 2065 6666 6563 7469 7665  en our effective
    │ │ │ -00070a40: 2069 6e61 6374 6976 6520 7374 6174 6520   inactive state 
    │ │ │ -00070a50: 6973 2064 6966 6665 7265 6e74 2066 726f  is different fro
    │ │ │ -00070a60: 6d20 6f75 720a 0909 2f2f 2061 6374 7561  m our...// actua
    │ │ │ -00070a70: 6c20 696e 6163 7469 7665 2073 7461 7465  l inactive state
    │ │ │ -00070a80: 2e20 5768 656e 6576 6572 2074 6869 7320  . Whenever this 
    │ │ │ -00070a90: 7374 6174 6520 6368 616e 6765 732c 2074  state changes, t
    │ │ │ -00070aa0: 6865 7265 2069 7320 610a 0909 2f2f 2071  here is a...// q
    │ │ │ -00070ab0: 7561 7261 6e74 696e 6520 7065 7269 6f64  uarantine period
    │ │ │ -00070ac0: 2075 6e74 696c 2077 6520 6368 616e 6765   until we change
    │ │ │ -00070ad0: 2074 6865 2065 6666 6563 7469 7665 2073   the effective s
    │ │ │ -00070ae0: 7461 7465 2e20 5468 6973 2069 7320 746f  tate. This is to
    │ │ │ -00070af0: 2061 766f 6964 0a09 092f 2f20 666c 6170   avoid...// flap
    │ │ │ -00070b00: 7069 6e67 2e20 4966 2074 6865 2073 7461  ping. If the sta
    │ │ │ -00070b10: 7465 2063 6861 6e67 6573 2062 6163 6b20  te changes back 
    │ │ │ -00070b20: 6475 7269 6e67 2074 6869 7320 7065 7269  during this peri
    │ │ │ -00070b30: 6f64 2c20 7765 2063 616e 6365 6c20 7468  od, we cancel th
    │ │ │ -00070b40: 650a 0909 2f2f 2071 7561 7261 6e74 696e  e...// quarantin
    │ │ │ -00070b50: 650a 0909 626f 6f6c 206d 5f70 656e 6469  e...bool m_pendi
    │ │ │ -00070b60: 6e67 5f61 6374 6976 655f 6368 616e 6765  ng_active_change
    │ │ │ -00070b70: 3a31 3b0a 0a09 092f 2f20 7468 6973 2069  :1;....// this i
    │ │ │ -00070b80: 7320 7365 7420 746f 2074 7275 6520 6966  s set to true if
    │ │ │ -00070b90: 2061 6c6c 2070 6965 6365 206c 6179 6572   all piece layer
    │ │ │ -00070ba0: 7320 7765 7265 2073 7563 6365 7373 6675  s were successfu
    │ │ │ -00070bb0: 6c6c 7920 6c6f 6164 6564 2061 6e64 0a09  lly loaded and..
    │ │ │ -00070bc0: 092f 2f20 7661 6c69 6461 7465 642e 204f  .// validated. O
    │ │ │ -00070bd0: 6e6c 7920 666f 7220 7632 2074 6f72 7265  nly for v2 torre
    │ │ │ -00070be0: 6e74 730a 3c64 6976 2073 7479 6c65 3d22  nts.
    ..bool m_v2_pi │ │ │ -00070c20: 6563 655f 6c61 7965 7273 5f76 616c 6964 ece_layers_valid │ │ │ -00070c30: 6174 6564 3a31 3b0a 3c2f 6469 763e 0a2f ated:1;.
    ./ │ │ │ -00070c40: 2f20 2d2d 2d2d 0a0a 0909 2f2f 2074 6869 / ----....// thi │ │ │ -00070c50: 7320 6973 2073 6574 2074 6f20 7468 6520 s is set to the │ │ │ -00070c60: 636f 6e6e 6563 7420 626f 6f73 7420 7175 connect boost qu │ │ │ -00070c70: 6f74 6120 666f 7220 7468 6973 2074 6f72 ota for this tor │ │ │ -00070c80: 7265 6e74 2e0a 0909 2f2f 2041 6674 6572 rent....// After │ │ │ -00070c90: 2068 6176 696e 6720 7265 6365 6976 6564 having received │ │ │ -00070ca0: 2074 6869 7320 6d61 6e79 2070 7269 6f72 this many prior │ │ │ -00070cb0: 6974 7920 7065 6572 2063 6f6e 6e65 6374 ity peer connect │ │ │ -00070cc0: 696f 6e20 6174 7465 6d70 7473 2c20 6974 ion attempts, it │ │ │ -00070cd0: 0a09 092f 2f20 6661 6c6c 7320 6261 636b ...// falls back │ │ │ -00070ce0: 206f 6e74 6f20 7468 6520 7374 6561 6479 onto the steady │ │ │ -00070cf0: 2073 7461 7465 2070 6565 7220 636f 6e6e state peer conn │ │ │ -00070d00: 6563 7469 6f6e 206c 6f67 6963 2c20 6472 ection logic, dr │ │ │ -00070d10: 6976 656e 2062 7920 7468 650a 0909 2f2f iven by the...// │ │ │ -00070d20: 2073 6573 7369 6f6e 2074 6963 6b2e 2045 session tick. E │ │ │ -00070d30: 6163 6820 7472 6163 6b65 7220 7265 7370 ach tracker resp │ │ │ -00070d40: 6f6e 7365 2c20 6173 206c 6f6e 6720 6173 onse, as long as │ │ │ -00070d50: 2074 6869 7320 6973 206e 6f6e 2d7a 6572 this is non-zer │ │ │ -00070d60: 6f2c 2077 696c 6c0a 0909 2f2f 2061 7474 o, will...// att │ │ │ -00070d70: 656d 7074 2074 6f20 636f 6e6e 6563 7420 empt to connect │ │ │ -00070d80: 746f 2070 6565 7273 2069 6d6d 6564 6961 to peers immedia │ │ │ -00070d90: 7465 6c79 2061 6e64 2064 6563 7265 6d65 tely and decreme │ │ │ -00070da0: 6e74 2074 6865 2063 6f75 6e74 6572 2e0a nt the counter.. │ │ │ -00070db0: 0909 2f2f 2057 6520 6769 7665 2074 6f72 ..// We give tor │ │ │ -00070dc0: 7265 6e74 7320 6120 636f 6e6e 6563 7420 rents a connect │ │ │ -00070dd0: 626f 6f73 7420 7768 656e 2074 6865 7920 boost when they │ │ │ -00070de0: 6172 6520 6669 7273 7420 6164 6465 6420 are first added │ │ │ -00070df0: 616e 6420 7468 656e 0a09 092f 2f20 6576 and then...// ev │ │ │ -00070e00: 6572 7920 7469 6d65 2074 6865 7920 7265 ery time they re │ │ │ -00070e10: 7375 6d65 2066 726f 6d20 6265 696e 6720 sume from being │ │ │ -00070e20: 7061 7573 6564 2e0a 0909 7374 643a 3a75 paused....std::u │ │ │ -00070e30: 696e 7438 5f74 206d 5f63 6f6e 6e65 6374 int8_t m_connect │ │ │ -00070e40: 5f62 6f6f 7374 5f63 6f75 6e74 6572 3b0a _boost_counter;. │ │ │ -00070e50: 0a2f 2f20 2d2d 2d2d 0a0a 0909 2f2f 2074 .// ----....// t │ │ │ -00070e60: 6865 2073 6372 6170 6520 6461 7461 2066 he scrape data f │ │ │ -00070e70: 726f 6d20 7468 6520 7472 6163 6b65 7220 rom the tracker │ │ │ -00070e80: 7265 7370 6f6e 7365 2c20 7468 6973 0a09 response, this.. │ │ │ -00070e90: 092f 2f20 6973 206f 7074 696f 6e61 6c20 .// is optional │ │ │ -00070ea0: 616e 6420 6d61 7920 6265 2030 7866 6666 and may be 0xfff │ │ │ -00070eb0: 6666 660a 0909 7374 643a 3a75 696e 7433 fff...std::uint3 │ │ │ -00070ec0: 325f 7420 6d5f 696e 636f 6d70 6c65 7465 2_t m_incomplete │ │ │ -00070ed0: 3a32 343b 0a0a 0909 2f2f 2074 7275 6520 :24;....// true │ │ │ -00070ee0: 7768 656e 2074 6865 2074 6f72 7265 6e74 when the torrent │ │ │ -00070ef0: 2073 686f 756c 6420 616e 6e6f 756e 6365 should announce │ │ │ -00070f00: 2074 6f0a 0909 2f2f 2074 6865 2044 4854 to...// the DHT │ │ │ -00070f10: 0a09 0962 6f6f 6c20 6d5f 616e 6e6f 756e ...bool m_announ │ │ │ -00070f20: 6365 5f74 6f5f 6468 743a 313b 0a0a 0909 ce_to_dht:1;.... │ │ │ -00070f30: 2f2f 2065 7665 6e20 6966 2077 6527 7265 // even if we're │ │ │ -00070f40: 206e 6f74 2062 7569 6c74 2074 6f20 7375 not built to su │ │ │ -00070f50: 7070 6f72 7420 5353 4c20 746f 7272 656e pport SSL torren │ │ │ -00070f60: 7473 2c0a 0909 2f2f 2072 656d 656d 6265 ts,...// remembe │ │ │ -00070f70: 7220 7468 6174 2074 6869 7320 6973 2061 r that this is a │ │ │ -00070f80: 6e20 5353 4c20 746f 7272 656e 742c 2073 n SSL torrent, s │ │ │ -00070f90: 6f20 7468 6174 2077 6520 646f 6e27 740a o that we don't. │ │ │ -00070fa0: 0909 2f2f 2061 6363 6964 656e 7461 6c6c ..// accidentall │ │ │ -00070fb0: 7920 7374 6172 7420 7365 6564 696e 6720 y start seeding │ │ │ -00070fc0: 6974 2077 6974 686f 7574 2061 6e79 2061 it without any a │ │ │ -00070fd0: 7574 6865 6e74 6963 6174 696f 6e2e 0a09 uthentication... │ │ │ -00070fe0: 0962 6f6f 6c20 6d5f 7373 6c5f 746f 7272 .bool m_ssl_torr │ │ │ -00070ff0: 656e 743a 313b 0a0a 0909 2f2f 2074 6869 ent:1;....// thi │ │ │ -00071000: 7320 6973 2073 6574 2074 6f20 7472 7565 s is set to true │ │ │ -00071010: 2069 6620 7765 2772 6520 7472 7969 6e67 if we're trying │ │ │ -00071020: 2074 6f20 6465 6c65 7465 2074 6865 0a09 to delete the.. │ │ │ -00071030: 092f 2f20 6669 6c65 7320 6265 6c6f 6e67 .// files belong │ │ │ -00071040: 696e 6720 746f 2069 742e 2057 6865 6e20 ing to it. When │ │ │ -00071050: 7365 742c 2064 6f6e 2774 2077 7269 7465 set, don't write │ │ │ -00071060: 2061 6e79 0a09 092f 2f20 6d6f 7265 2062 any...// more b │ │ │ -00071070: 6c6f 636b 7320 746f 2064 6973 6b21 0a3c locks to disk!.< │ │ │ -00071080: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00071090: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -000710a0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -000710b0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -000710c0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../inc │ │ │ -000710f0: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -00071100: 7374 7269 6e67 5f76 6965 772e 6870 703a string_view.hpp: │ │ │ -00071110: 3430 3c2f 613e 3c2f 7464 3e3c 7464 3e72 40r │ │ │ -00071120: 6570 6c61 6365 2074 6869 7320 6279 2074 eplace this by t │ │ │ -00071130: 6865 2073 7461 6e64 6172 6420 7374 7269 he standard stri │ │ │ -00071140: 6e67 5f76 6965 7720 696e 2043 2b2b 3137 ng_view in C++17 │ │ │ -00071150: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    re │ │ │ -000711a0: 706c 6163 6520 7468 6973 2062 7920 7468 place this by th │ │ │ -000711b0: 6520 7374 616e 6461 7264 2073 7472 696e e standard strin │ │ │ -000711c0: 675f 7669 6577 2069 6e20 432b 2b31 373c g_view in C++17< │ │ │ -000711d0: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ -000711e0: 6465 2f6c 6962 746f 7272 656e 742f 7374 de/libtorrent/st │ │ │ -000711f0: 7269 6e67 5f76 6965 772e 6870 703a 3430 ring_view.hpp:40 │ │ │ -00071200: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    A
    │ │ │ -00071240: 4e44 2041 4e59 2045 5850 5245 5353 204f  ND ANY EXPRESS O
    │ │ │ -00071250: 5220 494d 504c 4945 4420 5741 5252 414e  R IMPLIED WARRAN
    │ │ │ -00071260: 5449 4553 2c20 494e 434c 5544 494e 472c  TIES, INCLUDING,
    │ │ │ -00071270: 2042 5554 204e 4f54 204c 494d 4954 4544   BUT NOT LIMITED
    │ │ │ -00071280: 2054 4f2c 2054 4845 0a49 4d50 4c49 4544   TO, THE.IMPLIED
    │ │ │ -00071290: 2057 4152 5241 4e54 4945 5320 4f46 204d   WARRANTIES OF M
    │ │ │ -000712a0: 4552 4348 414e 5441 4249 4c49 5459 2041  ERCHANTABILITY A
    │ │ │ -000712b0: 4e44 2046 4954 4e45 5353 2046 4f52 2041  ND FITNESS FOR A
    │ │ │ -000712c0: 2050 4152 5449 4355 4c41 5220 5055 5250   PARTICULAR PURP
    │ │ │ -000712d0: 4f53 450a 4152 4520 4449 5343 4c41 494d  OSE.ARE DISCLAIM
    │ │ │ -000712e0: 4544 2e20 494e 204e 4f20 4556 454e 5420  ED. IN NO EVENT 
    │ │ │ -000712f0: 5348 414c 4c20 5448 4520 434f 5059 5249  SHALL THE COPYRI
    │ │ │ -00071300: 4748 5420 4f57 4e45 5220 4f52 2043 4f4e  GHT OWNER OR CON
    │ │ │ -00071310: 5452 4942 5554 4f52 5320 4245 0a4c 4941  TRIBUTORS BE.LIA
    │ │ │ -00071320: 424c 4520 464f 5220 414e 5920 4449 5245  BLE FOR ANY DIRE
    │ │ │ -00071330: 4354 2c20 494e 4449 5245 4354 2c20 494e  CT, INDIRECT, IN
    │ │ │ -00071340: 4349 4445 4e54 414c 2c20 5350 4543 4941  CIDENTAL, SPECIA
    │ │ │ -00071350: 4c2c 2045 5845 4d50 4c41 5259 2c20 4f52  L, EXEMPLARY, OR
    │ │ │ -00071360: 0a43 4f4e 5345 5155 454e 5449 414c 2044  .CONSEQUENTIAL D
    │ │ │ -00071370: 414d 4147 4553 2028 494e 434c 5544 494e  AMAGES (INCLUDIN
    │ │ │ -00071380: 472c 2042 5554 204e 4f54 204c 494d 4954  G, BUT NOT LIMIT
    │ │ │ -00071390: 4544 2054 4f2c 2050 524f 4355 5245 4d45  ED TO, PROCUREME
    │ │ │ -000713a0: 4e54 204f 460a 5355 4253 5449 5455 5445  NT OF.SUBSTITUTE
    │ │ │ -000713b0: 2047 4f4f 4453 204f 5220 5345 5256 4943   GOODS OR SERVIC
    │ │ │ -000713c0: 4553 3b20 4c4f 5353 204f 4620 5553 452c  ES; LOSS OF USE,
    │ │ │ -000713d0: 2044 4154 412c 204f 5220 5052 4f46 4954   DATA, OR PROFIT
    │ │ │ -000713e0: 533b 204f 5220 4255 5349 4e45 5353 0a49  S; OR BUSINESS.I
    │ │ │ -000713f0: 4e54 4552 5255 5054 494f 4e29 2048 4f57  NTERRUPTION) HOW
    │ │ │ -00071400: 4556 4552 2043 4155 5345 4420 414e 4420  EVER CAUSED AND 
    │ │ │ -00071410: 4f4e 2041 4e59 2054 4845 4f52 5920 4f46  ON ANY THEORY OF
    │ │ │ -00071420: 204c 4941 4249 4c49 5459 2c20 5748 4554   LIABILITY, WHET
    │ │ │ -00071430: 4845 5220 494e 0a43 4f4e 5452 4143 542c  HER IN.CONTRACT,
    │ │ │ -00071440: 2053 5452 4943 5420 4c49 4142 494c 4954   STRICT LIABILIT
    │ │ │ -00071450: 592c 204f 5220 544f 5254 2028 494e 434c  Y, OR TORT (INCL
    │ │ │ -00071460: 5544 494e 4720 4e45 474c 4947 454e 4345  UDING NEGLIGENCE
    │ │ │ -00071470: 204f 5220 4f54 4845 5257 4953 4529 0a41   OR OTHERWISE).A
    │ │ │ -00071480: 5249 5349 4e47 2049 4e20 414e 5920 5741  RISING IN ANY WA
    │ │ │ -00071490: 5920 4f55 5420 4f46 2054 4845 2055 5345  Y OUT OF THE USE
    │ │ │ -000714a0: 204f 4620 5448 4953 2053 4f46 5457 4152   OF THIS SOFTWAR
    │ │ │ -000714b0: 452c 2045 5645 4e20 4946 2041 4456 4953  E, EVEN IF ADVIS
    │ │ │ -000714c0: 4544 204f 4620 5448 450a 504f 5353 4942  ED OF THE.POSSIB
    │ │ │ -000714d0: 494c 4954 5920 4f46 2053 5543 4820 4441  ILITY OF SUCH DA
    │ │ │ -000714e0: 4d41 4745 2e0a 0a2a 2f0a 0a23 6966 6e64  MAGE...*/..#ifnd
    │ │ │ -000714f0: 6566 2054 4f52 5245 4e54 5f53 5452 494e  ef TORRENT_STRIN
    │ │ │ -00071500: 475f 5649 4557 5f48 5050 5f49 4e43 4c55  G_VIEW_HPP_INCLU
    │ │ │ -00071510: 4445 440a 2364 6566 696e 6520 544f 5252  DED.#define TORR
    │ │ │ -00071520: 454e 545f 5354 5249 4e47 5f56 4945 575f  ENT_STRING_VIEW_
    │ │ │ -00071530: 4850 505f 494e 434c 5544 4544 0a0a 2369  HPP_INCLUDED..#i
    │ │ │ -00071540: 6e63 6c75 6465 2026 6c74 3b62 6f6f 7374  nclude <boost
    │ │ │ -00071550: 2f76 6572 7369 6f6e 2e68 7070 2667 743b  /version.hpp>
    │ │ │ -00071560: 0a0a 2369 6e63 6c75 6465 2022 6c69 6274  ..#include "libt
    │ │ │ -00071570: 6f72 7265 6e74 2f61 7578 5f2f 6469 7361  orrent/aux_/disa
    │ │ │ -00071580: 626c 655f 7761 726e 696e 6773 5f70 7573  ble_warnings_pus
    │ │ │ -00071590: 682e 6870 7022 0a0a 3c64 6976 2073 7479  h.hpp"..
    .
    #if │ │ │ -000715d0: 2042 4f4f 5354 5f56 4552 5349 4f4e 2026 BOOST_VERSION & │ │ │ -000715e0: 6c74 3b20 3130 3631 3030 0a23 696e 636c lt; 106100.#incl │ │ │ -000715f0: 7564 6520 266c 743b 626f 6f73 742f 7574 ude <boost/ut │ │ │ -00071600: 696c 6974 792f 7374 7269 6e67 5f72 6566 ility/string_ref │ │ │ -00071610: 2e68 7070 2667 743b 0a23 696e 636c 7564 .hpp>.#includ │ │ │ -00071620: 6520 266c 743b 6373 7472 696e 6726 6774 e <cstring> │ │ │ -00071630: 3b20 2f2f 2066 6f72 2073 7472 6368 720a ; // for strchr. │ │ │ -00071640: 6e61 6d65 7370 6163 6520 6c69 6274 6f72 namespace libtor │ │ │ -00071650: 7265 6e74 207b 0a0a 7573 696e 6720 7374 rent {..using st │ │ │ -00071660: 7269 6e67 5f76 6965 7720 3d20 626f 6f73 ring_view = boos │ │ │ -00071670: 743a 3a73 7472 696e 675f 7265 663b 0a75 t::string_ref;.u │ │ │ -00071680: 7369 6e67 2077 7374 7269 6e67 5f76 6965 sing wstring_vie │ │ │ -00071690: 7720 3d20 626f 6f73 743a 3a77 7374 7269 w = boost::wstri │ │ │ -000716a0: 6e67 5f72 6566 3b0a 0a2f 2f20 696e 7465 ng_ref;..// inte │ │ │ -000716b0: 726e 616c 0a69 6e6c 696e 6520 7374 7269 rnal.inline stri │ │ │ -000716c0: 6e67 5f76 6965 773a 3a73 697a 655f 7479 ng_view::size_ty │ │ │ -000716d0: 7065 2066 696e 645f 6669 7273 745f 6f66 pe find_first_of │ │ │ -000716e0: 2873 7472 696e 675f 7669 6577 2063 6f6e (string_view con │ │ │ -000716f0: 7374 2076 2c20 6368 6172 2063 6f6e 7374 st v, char const │ │ │ -00071700: 2063 0a09 2c20 7374 7269 6e67 5f76 6965 c.., string_vie │ │ │ -00071710: 773a 3a73 697a 655f 7479 7065 2070 6f73 w::size_type pos │ │ │ -00071720: 290a 7b0a 0977 6869 6c65 2028 706f 7320 ).{..while (pos │ │ │ -00071730: 266c 743b 2076 2e73 697a 6528 2929 0a09 < v.size()).. │ │ │ -00071740: 7b0a 0909 6966 2028 765b 706f 735d 203d {...if (v[pos] = │ │ │ -00071750: 3d20 6329 2072 6574 7572 6e20 706f 733b = c) return pos; │ │ │ -00071760: 0a09 092b 2b70 6f73 3b0a 097d 0a09 7265 ...++pos;..}..re │ │ │ -00071770: 7475 726e 2073 7472 696e 675f 7669 6577 turn string_view │ │ │ -00071780: 3a3a 6e70 6f73 3b0a 7d0a 0a2f 2f20 696e ::npos;.}..// in │ │ │ -00071790: 7465 726e 616c 0a69 6e6c 696e 6520 7374 ternal.inline st │ │ │ -000717a0: 7269 6e67 5f76 6965 773a 3a73 697a 655f ring_view::size_ │ │ │ -000717b0: 7479 7065 2066 696e 645f 6669 7273 745f type find_first_ │ │ │ -000717c0: 6f66 2873 7472 696e 675f 7669 6577 2063 of(string_view c │ │ │ -000717d0: 6f6e 7374 2076 2c20 6368 6172 2063 6f6e onst v, char con │ │ │ -000717e0: 7374 2a20 630a 092c 2073 7472 696e 675f st* c.., string_ │ │ │ -000717f0: 7669 6577 3a3a 7369 7a65 5f74 7970 6520 view::size_type │ │ │ -00071800: 706f 7329 0a7b 0a09 7768 696c 6520 2870 pos).{..while (p │ │ │ -00071810: 6f73 2026 6c74 3b20 762e 7369 7a65 2829 os < v.size() │ │ │ -00071820: 290a 097b 0a09 0969 6620 2873 7464 3a3a )..{...if (std:: │ │ │ -00071830: 7374 7263 6872 2863 2c20 765b 706f 735d strchr(c, v[pos] │ │ │ -00071840: 2920 213d 206e 756c 6c70 7472 2920 7265 ) != nullptr) re │ │ │ -00071850: 7475 726e 2070 6f73 3b0a 0909 2b2b 706f turn pos;...++po │ │ │ -00071860: 733b 0a09 7d0a 0972 6574 7572 6e20 7374 s;..}..return st │ │ │ -00071870: 7269 6e67 5f76 6965 773a 3a6e 706f 733b ring_view::npos; │ │ │ -00071880: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -000718c0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../i │ │ │ -000718f0: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -00071900: 742f 736f 636b 7335 5f73 7472 6561 6d2e t/socks5_stream. │ │ │ -00071910: 6870 703a 3139 393c 2f61 3e3c 2f74 643e hpp:199 │ │ │ -00071920: 3c74 643e 7765 2063 6f75 6c64 2062 696e we could bin │ │ │ -00071930: 6420 7468 6520 736f 636b 6574 2068 6572 d the socket her │ │ │ -00071940: 652c 2073 696e 6365 2077 6520 6b6e 6f77 e, since we know │ │ │ -00071950: 2077 6861 7420 7468 6520 7461 7267 6574 what the target │ │ │ -00071960: 2065 6e64 706f 696e 7420 6973 206f 6620 endpoint is of │ │ │ -00071970: 7468 6520 7072 6f78 793c 2f74 643e 3c2f the proxy

    we could │ │ │ -000719d0: 6269 6e64 2074 6865 2073 6f63 6b65 7420 bind the socket │ │ │ -000719e0: 6865 7265 2c20 7369 6e63 6520 7765 206b here, since we k │ │ │ -000719f0: 6e6f 7720 7768 6174 2074 6865 0a74 6172 now what the.tar │ │ │ -00071a00: 6765 7420 656e 6470 6f69 6e74 2069 7320 get endpoint is │ │ │ -00071a10: 6f66 2074 6865 2070 726f 7879 3c2f 6832 of the proxy

    ../include/ │ │ │ -00071a30: 6c69 6274 6f72 7265 6e74 2f73 6f63 6b73 libtorrent/socks │ │ │ -00071a40: 355f 7374 7265 616d 2e68 7070 3a31 3939 5_stream.hpp:199 │ │ │ -00071a50: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00071a90: 0909 7d2c 2073 7464 3a3a 6d6f 7665 2868  ..}, std::move(h
    │ │ │ -00071aa0: 616e 646c 6572 2929 293b 0a09 7d0a 0a70  andler)));..}..p
    │ │ │ -00071ab0: 7269 7661 7465 3a0a 0a09 7465 6d70 6c61  rivate:...templa
    │ │ │ -00071ac0: 7465 2026 6c74 3b74 7970 656e 616d 6520  te <typename 
    │ │ │ -00071ad0: 4861 6e64 6c65 7226 6774 3b0a 0976 6f69  Handler>..voi
    │ │ │ -00071ae0: 6420 6e61 6d65 5f6c 6f6f 6b75 7028 6572  d name_lookup(er
    │ │ │ -00071af0: 726f 725f 636f 6465 2063 6f6e 7374 2661  ror_code const&a
    │ │ │ -00071b00: 6d70 3b20 652c 2074 6370 3a3a 7265 736f  mp; e, tcp::reso
    │ │ │ -00071b10: 6c76 6572 3a3a 7265 7375 6c74 735f 7479  lver::results_ty
    │ │ │ -00071b20: 7065 2069 7073 0a09 092c 2048 616e 646c  pe ips..., Handl
    │ │ │ -00071b30: 6572 2068 290a 097b 0a09 0943 4f4d 504c  er h)..{...COMPL
    │ │ │ -00071b40: 4554 455f 4153 594e 4328 2273 6f63 6b73  ETE_ASYNC("socks
    │ │ │ -00071b50: 355f 7374 7265 616d 3a3a 6e61 6d65 5f6c  5_stream::name_l
    │ │ │ -00071b60: 6f6f 6b75 7022 293b 0a09 0969 6620 2868  ookup");...if (h
    │ │ │ -00071b70: 616e 646c 655f 6572 726f 7228 652c 2073  andle_error(e, s
    │ │ │ -00071b80: 7464 3a3a 6d6f 7665 2868 2929 2920 7265  td::move(h))) re
    │ │ │ -00071b90: 7475 726e 3b0a 0a09 0961 7574 6f20 6920  turn;....auto i 
    │ │ │ -00071ba0: 3d20 6970 732e 6265 6769 6e28 293b 0a09  = ips.begin();..
    │ │ │ -00071bb0: 0969 6620 2821 6d5f 736f 636b 2e69 735f  .if (!m_sock.is_
    │ │ │ -00071bc0: 6f70 656e 2829 290a 0909 7b0a 0909 0965  open())...{....e
    │ │ │ -00071bd0: 7272 6f72 5f63 6f64 6520 6563 3b0a 0909  rror_code ec;...
    │ │ │ -00071be0: 096d 5f73 6f63 6b2e 6f70 656e 2869 2d26  .m_sock.open(i-&
    │ │ │ -00071bf0: 6774 3b65 6e64 706f 696e 7428 292e 7072  gt;endpoint().pr
    │ │ │ -00071c00: 6f74 6f63 6f6c 2829 2c20 6563 293b 0a09  otocol(), ec);..
    │ │ │ -00071c10: 0909 6966 2028 6861 6e64 6c65 5f65 7272  ..if (handle_err
    │ │ │ -00071c20: 6f72 2865 632c 2073 7464 3a3a 6d6f 7665  or(ec, std::move
    │ │ │ -00071c30: 2868 2929 2920 7265 7475 726e 3b0a 0909  (h))) return;...
    │ │ │ -00071c40: 7d0a 0a3c 6469 7620 7374 796c 653d 2262  }..
    ..ADD_OUTSTANDI │ │ │ -00071c80: 4e47 5f41 5359 4e43 2822 736f 636b 7335 NG_ASYNC("socks5 │ │ │ -00071c90: 5f73 7472 6561 6d3a 3a63 6f6e 6e65 6374 _stream::connect │ │ │ -00071ca0: 6564 2229 3b0a 3c2f 6469 763e 0909 6d5f ed");.
    ..m_ │ │ │ -00071cb0: 736f 636b 2e61 7379 6e63 5f63 6f6e 6e65 sock.async_conne │ │ │ -00071cc0: 6374 2869 2d26 6774 3b65 6e64 706f 696e ct(i->endpoin │ │ │ -00071cd0: 7428 292c 2077 7261 705f 616c 6c6f 6361 t(), wrap_alloca │ │ │ -00071ce0: 746f 7228 0a09 0909 5b74 6869 735d 2865 tor(....[this](e │ │ │ -00071cf0: 7272 6f72 5f63 6f64 6520 636f 6e73 7426 rror_code const& │ │ │ -00071d00: 616d 703b 2065 632c 2048 616e 646c 6572 amp; ec, Handler │ │ │ -00071d10: 2068 6e29 0a09 0909 7b20 636f 6e6e 6563 hn)....{ connec │ │ │ -00071d20: 7465 6428 6563 2c20 7374 643a 3a6d 6f76 ted(ec, std::mov │ │ │ -00071d30: 6528 686e 2929 3b20 7d2c 2073 7464 3a3a e(hn)); }, std:: │ │ │ -00071d40: 6d6f 7665 2868 2929 293b 0a09 7d0a 0a09 move(h)));..}... │ │ │ -00071d50: 7465 6d70 6c61 7465 2026 6c74 3b74 7970 template <typ │ │ │ -00071d60: 656e 616d 6520 4861 6e64 6c65 7226 6774 ename Handler> │ │ │ -00071d70: 3b0a 0976 6f69 6420 636f 6e6e 6563 7465 ;..void connecte │ │ │ -00071d80: 6428 6572 726f 725f 636f 6465 2063 6f6e d(error_code con │ │ │ -00071d90: 7374 2661 6d70 3b20 652c 2048 616e 646c st& e, Handl │ │ │ -00071da0: 6572 2068 290a 097b 0a09 0943 4f4d 504c er h)..{...COMPL │ │ │ -00071db0: 4554 455f 4153 594e 4328 2273 6f63 6b73 ETE_ASYNC("socks │ │ │ -00071dc0: 355f 7374 7265 616d 3a3a 636f 6e6e 6563 5_stream::connec │ │ │ -00071dd0: 7465 6422 293b 0a09 0969 6620 2868 616e ted");...if (han │ │ │ -00071de0: 646c 655f 6572 726f 7228 652c 2073 7464 dle_error(e, std │ │ │ -00071df0: 3a3a 6d6f 7665 2868 2929 2920 7265 7475 ::move(h))) retu │ │ │ -00071e00: 726e 3b0a 0a09 0975 7369 6e67 206e 616d rn;....using nam │ │ │ -00071e10: 6573 7061 6365 206c 6962 746f 7272 656e espace libtorren │ │ │ -00071e20: 743a 3a61 7578 3b0a 0909 6966 2028 6d5f t::aux;...if (m_ │ │ │ -00071e30: 7665 7273 696f 6e20 3d3d 2035 290a 0909 version == 5)... │ │ │ -00071e40: 7b0a 0909 092f 2f20 7365 6e64 2053 4f43 {....// send SOC │ │ │ -00071e50: 4b53 3520 6175 7468 656e 7469 6361 7469 KS5 authenticati │ │ │ -00071e60: 6f6e 206d 6574 686f 6473 0a09 0909 6d5f on methods....m_ │ │ │ -00071e70: 6275 6666 6572 2e72 6573 697a 6528 6d5f buffer.resize(m_ │ │ │ -00071e80: 7573 6572 2e65 6d70 7479 2829 3f33 3a34 user.empty()?3:4 │ │ │ -00071e90: 293b 0a09 0909 6368 6172 2a20 7020 3d20 );....char* p = │ │ │ -00071ea0: 2661 6d70 3b6d 5f62 7566 6665 725b 305d &m_buffer[0] │ │ │ -00071eb0: 3b0a 0909 0977 7269 7465 5f75 696e 7438 ;....write_uint8 │ │ │ -00071ec0: 2835 2c20 7029 3b20 2f2f 2053 4f43 4b53 (5, p); // SOCKS │ │ │ -00071ed0: 2056 4552 5349 4f4e 2035 0a09 0909 6966 VERSION 5....if │ │ │ -00071ee0: 2028 6d5f 7573 6572 2e65 6d70 7479 2829 (m_user.empty() │ │ │ -00071ef0: 290a 0909 097b 0a09 0909 0977 7269 7465 )....{.....write │ │ │ -00071f00: 5f75 696e 7438 2831 2c20 7029 3b20 2f2f _uint8(1, p); // │ │ │ -00071f10: 2031 2061 7574 6865 6e74 6963 6174 696f 1 authenticatio │ │ │ -00071f20: 6e20 6d65 7468 6f64 2028 6e6f 2061 7574 n method (no aut │ │ │ -00071f30: 6829 0a09 0909 0977 7269 7465 5f75 696e h).....write_uin │ │ │ -00071f40: 7438 2830 2c20 7029 3b20 2f2f 206e 6f20 t8(0, p); // no │ │ │ -00071f50: 6175 7468 656e 7469 6361 7469 6f6e 0a09 authentication.. │ │ │ -00071f60: 0909 7d0a 0909 0965 6c73 650a 0909 097b ..}....else....{ │ │ │ -00071f70: 0a09 0909 0977 7269 7465 5f75 696e 7438 .....write_uint8 │ │ │ -00071f80: 2832 2c20 7029 3b20 2f2f 2032 2061 7574 (2, p); // 2 aut │ │ │ -00071f90: 6865 6e74 6963 6174 696f 6e20 6d65 7468 hentication meth │ │ │ -00071fa0: 6f64 730a 0909 0909 7772 6974 655f 7569 ods.....write_ui │ │ │ -00071fb0: 6e74 3828 302c 2070 293b 202f 2f20 6e6f nt8(0, p); // no │ │ │ -00071fc0: 2061 7574 6865 6e74 6963 6174 696f 6e0a authentication. │ │ │ -00071fd0: 0909 0909 7772 6974 655f 7569 6e74 3828 ....write_uint8( │ │ │ -00071fe0: 322c 2070 293b 202f 2f20 7573 6572 6e61 2, p); // userna │ │ │ -00071ff0: 6d65 2f70 6173 7377 6f72 640a 0909 097d me/password....} │ │ │ -00072000: 0a09 0909 4144 445f 4f55 5453 5441 4e44 ....ADD_OUTSTAND │ │ │ -00072010: 494e 475f 4153 594e 4328 2273 6f63 6b73 ING_ASYNC("socks │ │ │ -00072020: 355f 7374 7265 616d 3a3a 6861 6e64 7368 5_stream::handsh │ │ │ -00072030: 616b 6531 2229 3b0a 3c2f 7072 653e 3c2f ake1");.
    relevan │ │ │ -00072070: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../include/li │ │ │ -000720b0: 6274 6f72 7265 6e74 2f73 6f63 6b65 745f btorrent/socket_ │ │ │ -000720c0: 7479 7065 2e68 7070 3a36 303c 2f61 3e3c type.hpp:60< │ │ │ -000720d0: 2f74 643e 3c74 643e 6d6f 7665 2074 6f20 /td>move to │ │ │ -000720e0: 6175 783c 2f74 643e 3c2f 7472 3e3c 7472 aux

    move to aux

    ../include/ │ │ │ -00072150: 6c69 6274 6f72 7265 6e74 2f73 6f63 6b65 libtorrent/socke │ │ │ -00072160: 745f 7479 7065 2e68 7070 3a36 303c 2f68 t_type.hpp:60
    name
    │ │ │ -000721b0: 7370 6163 6520 6c69 6274 6f72 7265 6e74  space libtorrent
    │ │ │ -000721c0: 207b 0a0a 2f2f 2041 2074 7970 6520 6465   {..// A type de
    │ │ │ -000721d0: 7363 7269 6269 6e67 206b 696e 6473 206f  scribing kinds o
    │ │ │ -000721e0: 6620 736f 636b 6574 7320 696e 766f 6c76  f sockets involv
    │ │ │ -000721f0: 6564 2069 6e20 7661 7269 6f75 7320 6f70  ed in various op
    │ │ │ -00072200: 6572 6174 696f 6e73 206f 7220 6576 656e  erations or even
    │ │ │ -00072210: 7473 2e0a 656e 756d 2063 6c61 7373 2073  ts..enum class s
    │ │ │ -00072220: 6f63 6b65 745f 7479 7065 5f74 203a 2073  ocket_type_t : s
    │ │ │ -00072230: 7464 3a3a 7569 6e74 385f 7420 7b0a 0974  td::uint8_t {..t
    │ │ │ -00072240: 6370 2c0a 0973 6f63 6b73 352c 0a09 6874  cp,..socks5,..ht
    │ │ │ -00072250: 7470 2c0a 0975 7470 2c0a 0969 3270 2c0a  tp,..utp,..i2p,.
    │ │ │ -00072260: 0974 6370 5f73 736c 2c0a 0973 6f63 6b73  .tcp_ssl,..socks
    │ │ │ -00072270: 355f 7373 6c2c 0a09 6874 7470 5f73 736c  5_ssl,..http_ssl
    │ │ │ -00072280: 2c0a 0975 7470 5f73 736c 2c0a 0a23 6966  ,..utp_ssl,..#if
    │ │ │ -00072290: 2054 4f52 5245 4e54 5f41 4249 5f56 4552   TORRENT_ABI_VER
    │ │ │ -000722a0: 5349 4f4e 2026 6c74 3b3d 2032 0a09 7564  SION <= 2..ud
    │ │ │ -000722b0: 7020 544f 5252 454e 545f 4445 5052 4543  p TORRENT_DEPREC
    │ │ │ -000722c0: 4154 4544 5f45 4e55 4d20 3d20 7574 702c  ATED_ENUM = utp,
    │ │ │ -000722d0: 0a23 656e 6469 660a 7d3b 0a0a 2f2f 2072  .#endif.};..// r
    │ │ │ -000722e0: 6574 7572 6e20 6120 7368 6f72 7420 6875  eturn a short hu
    │ │ │ -000722f0: 6d61 6e20 7265 6164 6162 6c65 206e 616d  man readable nam
    │ │ │ -00072300: 6520 666f 7220 7479 7065 7320 6f66 2073  e for types of s
    │ │ │ -00072310: 6f63 6b65 740a 3c64 6976 2073 7479 6c65  ocket.
    char const* │ │ │ -00072350: 736f 636b 6574 5f74 7970 655f 6e61 6d65 socket_type_name │ │ │ -00072360: 2873 6f63 6b65 745f 7479 7065 5f74 293b (socket_type_t); │ │ │ -00072370: 0a3c 2f64 6976 3e0a 7d0a 0a23 656e 6469 .
    .}..#endi │ │ │ -00072380: 660a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 f.
    < │ │ │ -000723b0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -000723c0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -000723f0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -00072400: 6e74 2f70 726f 7879 5f62 6173 652e 6870 nt/proxy_base.hp │ │ │ -00072410: 703a 3232 373c 2f61 3e3c 2f74 643e 3c74 p:227it would be ni │ │ │ -00072430: 6365 2074 6f20 7265 6d65 6d62 6572 2074 ce to remember t │ │ │ -00072440: 6865 2062 696e 6420 706f 7274 2061 6e64 he bind port and │ │ │ -00072450: 2062 696e 6420 6f6e 6365 2077 6520 6b6e bind once we kn │ │ │ -00072460: 6f77 2077 6865 7265 2074 6865 2070 726f ow where the pro │ │ │ -00072470: 7879 2069 7320 6d5f 736f 636b 2e62 696e xy is m_sock.bin │ │ │ -00072480: 6428 656e 6470 6f69 6e74 2c20 6563 293b d(endpoint, ec); │ │ │ -00072490: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    it │ │ │ -000724e0: 2077 6f75 6c64 2062 6520 6e69 6365 2074 would be nice t │ │ │ -000724f0: 6f20 7265 6d65 6d62 6572 2074 6865 2062 o remember the b │ │ │ -00072500: 696e 6420 706f 7274 2061 6e64 2062 696e ind port and bin │ │ │ -00072510: 6420 6f6e 6365 2077 6520 6b6e 6f77 2077 d once we know w │ │ │ -00072520: 6865 7265 2074 6865 2070 726f 7879 2069 here the proxy i │ │ │ -00072530: 730a 6d5f 736f 636b 2e62 696e 6428 656e s.m_sock.bind(en │ │ │ -00072540: 6470 6f69 6e74 2c20 6563 293b 3c2f 6832 dpoint, ec);

    ../include/ │ │ │ -00072560: 6c69 6274 6f72 7265 6e74 2f70 726f 7879 libtorrent/proxy │ │ │ -00072570: 5f62 6173 652e 6870 703a 3232 373c 2f68 _base.hpp:227
    ..TO
    │ │ │ -000725c0: 5252 454e 545f 4153 5345 5254 286d 5f6d  RRENT_ASSERT(m_m
    │ │ │ -000725d0: 6167 6963 203d 3d20 3078 3133 3337 293b  agic == 0x1337);
    │ │ │ -000725e0: 0a09 096d 5f73 6f63 6b2e 6361 6e63 656c  ...m_sock.cancel
    │ │ │ -000725f0: 2829 3b0a 097d 0a0a 0976 6f69 6420 6361  ();..}...void ca
    │ │ │ -00072600: 6e63 656c 2865 7272 6f72 5f63 6f64 6526  ncel(error_code&
    │ │ │ -00072610: 616d 703b 2065 6329 0a09 7b0a 0909 544f  amp; ec)..{...TO
    │ │ │ -00072620: 5252 454e 545f 4153 5345 5254 286d 5f6d  RRENT_ASSERT(m_m
    │ │ │ -00072630: 6167 6963 203d 3d20 3078 3133 3337 293b  agic == 0x1337);
    │ │ │ -00072640: 0a09 096d 5f73 6f63 6b2e 6361 6e63 656c  ...m_sock.cancel
    │ │ │ -00072650: 2865 6329 3b0a 097d 0a0a 0976 6f69 6420  (ec);..}...void 
    │ │ │ -00072660: 6269 6e64 2865 6e64 706f 696e 745f 7479  bind(endpoint_ty
    │ │ │ -00072670: 7065 2063 6f6e 7374 2661 6d70 3b20 2f2a  pe const& /*
    │ │ │ -00072680: 2065 6e64 706f 696e 7420 2a2f 2c20 6572   endpoint */, er
    │ │ │ -00072690: 726f 725f 636f 6465 2661 6d70 3b20 2f2a  ror_code& /*
    │ │ │ -000726a0: 2065 6320 2a2f 290a 097b 0a09 0954 4f52   ec */)..{...TOR
    │ │ │ -000726b0: 5245 4e54 5f41 5353 4552 5428 6d5f 6d61  RENT_ASSERT(m_ma
    │ │ │ -000726c0: 6769 6320 3d3d 2030 7831 3333 3729 3b0a  gic == 0x1337);.
    │ │ │ -000726d0: 0909 2f2f 2074 6865 2072 6561 736f 6e20  ..// the reason 
    │ │ │ -000726e0: 7768 7920 7765 2069 676e 6f72 6520 6269  why we ignore bi
    │ │ │ -000726f0: 6e64 7320 6865 7265 2069 7320 6265 6361  nds here is beca
    │ │ │ -00072700: 7573 6520 7765 2064 6f6e 2774 0a09 092f  use we don't.../
    │ │ │ -00072710: 2f20 286e 6563 6573 7361 7269 6c79 2920  / (necessarily) 
    │ │ │ -00072720: 7965 7420 6b6e 6f77 2077 6861 7420 6164  yet know what ad
    │ │ │ -00072730: 6472 6573 7320 6661 6d69 6c79 2074 6865  dress family the
    │ │ │ -00072740: 2070 726f 7879 0a09 092f 2f20 7769 6c6c   proxy...// will
    │ │ │ -00072750: 2072 6573 6f6c 7665 2074 6f2c 2061 6e64   resolve to, and
    │ │ │ -00072760: 2062 696e 6469 6e67 2074 6f20 7468 6520   binding to the 
    │ │ │ -00072770: 7772 6f6e 6720 6f6e 6520 776f 756c 640a  wrong one would.
    │ │ │ -00072780: 0909 2f2f 2062 7265 616b 206f 7572 2063  ..// break our c
    │ │ │ -00072790: 6f6e 6e65 6374 696f 6e20 6174 7465 6d70  onnection attemp
    │ │ │ -000727a0: 7420 6c61 7465 722e 2054 6865 2063 616c  t later. The cal
    │ │ │ -000727b0: 6c65 7220 6865 7265 0a09 092f 2f20 646f  ler here...// do
    │ │ │ -000727c0: 6573 6e27 7420 6e65 6365 7373 6172 696c  esn't necessaril
    │ │ │ -000727d0: 7920 6b6e 6f77 2074 6861 7420 7765 2772  y know that we'r
    │ │ │ -000727e0: 6520 7072 6f78 7969 6e67 2c20 736f 2074  e proxying, so t
    │ │ │ -000727f0: 6869 730a 0909 2f2f 2062 696e 6420 6164  his...// bind ad
    │ │ │ -00072800: 6472 6573 7320 6973 2062 6173 6564 206f  dress is based o
    │ │ │ -00072810: 6e20 7468 6520 6669 6e61 6c20 656e 6470  n the final endp
    │ │ │ -00072820: 6f69 6e74 2c20 6e6f 7420 7468 650a 0909  oint, not the...
    │ │ │ -00072830: 2f2f 2070 726f 7879 2e0a 3c64 6976 2073  // proxy..
    .}.
    .#ifndef BOOST_ │ │ │ -00072880: 4e4f 5f45 5843 4550 5449 4f4e 530a 0976 NO_EXCEPTIONS..v │ │ │ -00072890: 6f69 6420 6f70 656e 2870 726f 746f 636f oid open(protoco │ │ │ -000728a0: 6c5f 7479 7065 2063 6f6e 7374 2661 6d70 l_type const& │ │ │ -000728b0: 3b29 0a09 7b0a 0909 544f 5252 454e 545f ;)..{...TORRENT_ │ │ │ -000728c0: 4153 5345 5254 286d 5f6d 6167 6963 203d ASSERT(m_magic = │ │ │ -000728d0: 3d20 3078 3133 3337 293b 0a2f 2f09 096d = 0x1337);.//..m │ │ │ -000728e0: 5f73 6f63 6b2e 6f70 656e 2870 293b 0a09 _sock.open(p);.. │ │ │ -000728f0: 7d0a 2365 6e64 6966 0a0a 0976 6f69 6420 }.#endif...void │ │ │ -00072900: 6f70 656e 2870 726f 746f 636f 6c5f 7479 open(protocol_ty │ │ │ -00072910: 7065 2063 6f6e 7374 2661 6d70 3b2c 2065 pe const&, e │ │ │ -00072920: 7272 6f72 5f63 6f64 6526 616d 703b 290a rror_code&). │ │ │ -00072930: 097b 0a09 0954 4f52 5245 4e54 5f41 5353 .{...TORRENT_ASS │ │ │ -00072940: 4552 5428 6d5f 6d61 6769 6320 3d3d 2030 ERT(m_magic == 0 │ │ │ -00072950: 7831 3333 3729 3b0a 0909 2f2f 2077 6520 x1337);...// we │ │ │ -00072960: 6e65 6564 2074 6f20 6967 6e6f 7265 2074 need to ignore t │ │ │ -00072970: 6869 7320 666f 7220 7468 6520 7361 6d65 his for the same │ │ │ -00072980: 2072 6561 736f 6e20 6173 2073 7461 7465 reason as state │ │ │ -00072990: 640a 0909 2f2f 2066 6f72 2069 676e 6f72 d...// for ignor │ │ │ -000729a0: 696e 6720 6269 6e64 2829 0a2f 2f09 096d ing bind().//..m │ │ │ -000729b0: 5f73 6f63 6b2e 6f70 656e 2870 2c20 6563 _sock.open(p, ec │ │ │ -000729c0: 293b 0a09 7d0a 0a23 6966 6e64 6566 2042 );..}..#ifndef B │ │ │ -000729d0: 4f4f 5354 5f4e 4f5f 4558 4345 5054 494f OOST_NO_EXCEPTIO │ │ │ -000729e0: 4e53 0a09 766f 6964 2063 6c6f 7365 2829 NS..void close() │ │ │ -000729f0: 0a09 7b0a 0909 544f 5252 454e 545f 4153 ..{...TORRENT_AS │ │ │ -00072a00: 5345 5254 286d 5f6d 6167 6963 203d 3d20 SERT(m_magic == │ │ │ -00072a10: 3078 3133 3337 293b 0a09 096d 5f72 656d 0x1337);...m_rem │ │ │ -00072a20: 6f74 655f 656e 6470 6f69 6e74 203d 2065 ote_endpoint = e │ │ │ -00072a30: 6e64 706f 696e 745f 7479 7065 2829 3b0a ndpoint_type();. │ │ │ -00072a40: 0909 6d5f 736f 636b 2e63 6c6f 7365 2829 ..m_sock.close() │ │ │ -00072a50: 3b0a 0909 6d5f 7265 736f 6c76 6572 2e63 ;...m_resolver.c │ │ │ -00072a60: 616e 6365 6c28 293b 0a09 7d0a 2365 6e64 ancel();..}.#end │ │ │ -00072a70: 6966 0a0a 0976 6f69 6420 636c 6f73 6528 if...void close( │ │ │ -00072a80: 6572 726f 725f 636f 6465 2661 6d70 3b20 error_code& │ │ │ -00072a90: 6563 290a 097b 0a09 0954 4f52 5245 4e54 ec)..{...TORRENT │ │ │ -00072aa0: 5f41 5353 4552 5428 6d5f 6d61 6769 6320 _ASSERT(m_magic │ │ │ -00072ab0: 3d3d 2030 7831 3333 3729 3b0a 3c2f 7072 == 0x1337);.rel │ │ │ -00072af0: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../includ │ │ │ -00072b30: 652f 6c69 6274 6f72 7265 6e74 2f70 6965 e/libtorrent/pie │ │ │ -00072b40: 6365 5f70 6963 6b65 722e 6870 703a 3832 ce_picker.hpp:82 │ │ │ -00072b50: 333c 2f61 3e3c 2f74 643e 3c74 643e 7368 3sh │ │ │ -00072b60: 6f75 6c64 2074 6869 7320 6265 2061 6c6c ould this be all │ │ │ -00072b70: 6f63 6174 6564 206c 617a 696c 793f 3c2f ocated lazily?

    shou │ │ │ -00072bd0: 6c64 2074 6869 7320 6265 2061 6c6c 6f63 ld this be alloc │ │ │ -00072be0: 6174 6564 206c 617a 696c 793f 3c2f 6832 ated lazily?

    ../include/ │ │ │ -00072c00: 6c69 6274 6f72 7265 6e74 2f70 6965 6365 libtorrent/piece │ │ │ -00072c10: 5f70 6963 6b65 722e 6870 703a 3832 333c _picker.hpp:823< │ │ │ -00072c20: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -00072c60: 2f2f 2064 6f77 6e6c 6f61 6420 6c69 7374  // download list
    │ │ │ -00072c70: 2069 7420 6d61 7920 6c69 7665 2069 6e20   it may live in 
    │ │ │ -00072c80: 6e6f 770a 0909 7374 643a 3a76 6563 746f  now...std::vecto
    │ │ │ -00072c90: 7226 6c74 3b64 6f77 6e6c 6f61 6469 6e67  r<downloading
    │ │ │ -00072ca0: 5f70 6965 6365 2667 743b 3a3a 6974 6572  _piece>::iter
    │ │ │ -00072cb0: 6174 6f72 2075 7064 6174 655f 7069 6563  ator update_piec
    │ │ │ -00072cc0: 655f 7374 6174 6528 0a09 0909 7374 643a  e_state(....std:
    │ │ │ -00072cd0: 3a76 6563 746f 7226 6c74 3b64 6f77 6e6c  :vector<downl
    │ │ │ -00072ce0: 6f61 6469 6e67 5f70 6965 6365 2667 743b  oading_piece>
    │ │ │ -00072cf0: 3a3a 6974 6572 6174 6f72 2064 7029 3b0a  ::iterator dp);.
    │ │ │ -00072d00: 0a09 7072 6976 6174 653a 0a0a 2369 6620  ..private:..#if 
    │ │ │ -00072d10: 544f 5252 454e 545f 5553 455f 4153 5345  TORRENT_USE_ASSE
    │ │ │ -00072d20: 5254 5320 7c7c 2054 4f52 5245 4e54 5f55  RTS || TORRENT_U
    │ │ │ -00072d30: 5345 5f49 4e56 4152 4941 4e54 5f43 4845  SE_INVARIANT_CHE
    │ │ │ -00072d40: 434b 530a 0909 696e 6465 785f 7261 6e67  CKS...index_rang
    │ │ │ -00072d50: 6526 6c74 3b64 6f77 6e6c 6f61 645f 7175  e<download_qu
    │ │ │ -00072d60: 6575 655f 7426 6774 3b20 6361 7465 676f  eue_t> catego
    │ │ │ -00072d70: 7269 6573 2829 2063 6f6e 7374 0a09 097b  ries() const...{
    │ │ │ -00072d80: 2072 6574 7572 6e20 7b7b 7d2c 2070 6965   return {{}, pie
    │ │ │ -00072d90: 6365 5f70 6963 6b65 723a 3a70 6965 6365  ce_picker::piece
    │ │ │ -00072da0: 5f70 6f73 3a3a 6e75 6d5f 646f 776e 6c6f  _pos::num_downlo
    │ │ │ -00072db0: 6164 5f63 6174 6567 6f72 6965 737d 3b20  ad_categories}; 
    │ │ │ -00072dc0: 7d0a 2365 6e64 6966 0a0a 0909 2f2f 2074  }.#endif....// t
    │ │ │ -00072dd0: 6865 2066 6f6c 6c6f 7769 6e67 2076 6563  he following vec
    │ │ │ -00072de0: 746f 7273 2061 7265 206d 7574 6162 6c65  tors are mutable
    │ │ │ -00072df0: 2062 6563 6175 7365 2074 6865 7920 736f   because they so
    │ │ │ -00072e00: 6d65 7469 6d65 7320 6d61 790a 0909 2f2f  metimes may...//
    │ │ │ -00072e10: 2062 6520 7570 6461 7465 6420 6c61 7a69   be updated lazi
    │ │ │ -00072e20: 6c79 2c20 7472 6967 6765 7265 6420 6279  ly, triggered by
    │ │ │ -00072e30: 2063 6f6e 7374 2066 756e 6374 696f 6e73   const functions
    │ │ │ -00072e40: 0a0a 0909 2f2f 2074 6869 7320 6d61 7073  ....// this maps
    │ │ │ -00072e50: 2069 6e64 6963 6573 2074 6f20 6e75 6d62   indices to numb
    │ │ │ -00072e60: 6572 206f 6620 7065 6572 7320 7468 6174  er of peers that
    │ │ │ -00072e70: 2068 6173 2074 6869 7320 7069 6563 6520   has this piece 
    │ │ │ -00072e80: 616e 640a 0909 2f2f 2069 6e64 6578 2069  and...// index i
    │ │ │ -00072e90: 6e74 6f20 7468 6520 6d5f 7069 6563 655f  nto the m_piece_
    │ │ │ -00072ea0: 696e 666f 2076 6563 746f 7273 2e0a 0909  info vectors....
    │ │ │ -00072eb0: 2f2f 2070 6965 6365 5f70 6f73 3a3a 7765  // piece_pos::we
    │ │ │ -00072ec0: 5f68 6176 655f 696e 6465 7820 6d65 616e  _have_index mean
    │ │ │ -00072ed0: 7320 7468 6174 2077 6520 6861 7665 2074  s that we have t
    │ │ │ -00072ee0: 6865 2070 6965 6365 2c20 736f 2069 740a  he piece, so it.
    │ │ │ -00072ef0: 0909 2f2f 2064 6f65 736e 2774 2065 7869  ..// doesn't exi
    │ │ │ -00072f00: 7374 2069 6e20 7468 6520 7069 6563 655f  st in the piece_
    │ │ │ -00072f10: 696e 666f 2062 7563 6b65 7473 0a09 092f  info buckets.../
    │ │ │ -00072f20: 2f20 7069 6563 6573 2077 6974 6820 7468  / pieces with th
    │ │ │ -00072f30: 6520 6669 6c74 6572 6564 2066 6c61 6720  e filtered flag 
    │ │ │ -00072f40: 7365 7420 646f 6573 6e27 7420 6861 7665  set doesn't have
    │ │ │ -00072f50: 2065 6e74 7269 6573 2069 6e0a 0909 2f2f   entries in...//
    │ │ │ -00072f60: 2074 6865 206d 5f70 6965 6365 5f69 6e66   the m_piece_inf
    │ │ │ -00072f70: 6f20 6275 636b 6574 7320 6569 7468 6572  o buckets either
    │ │ │ -00072f80: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -00072fb0: 096d 7574 6162 6c65 2061 7578 3a3a 7665 .mutable aux::ve │ │ │ -00072fc0: 6374 6f72 266c 743b 7069 6563 655f 706f ctor<piece_po │ │ │ -00072fd0: 732c 2070 6965 6365 5f69 6e64 6578 5f74 s, piece_index_t │ │ │ -00072fe0: 2667 743b 206d 5f70 6965 6365 5f6d 6170 > m_piece_map │ │ │ -00072ff0: 3b0a 3c2f 6469 763e 0a09 092f 2f20 7472 ;.
    ...// tr │ │ │ -00073000: 6163 6b73 2074 6865 206e 756d 6265 7220 acks the number │ │ │ -00073010: 6f66 2062 7974 6573 2069 6e20 6120 7370 of bytes in a sp │ │ │ -00073020: 6563 6966 6963 2070 6965 6365 2074 6861 ecific piece tha │ │ │ -00073030: 7420 6172 6520 7061 7274 206f 6620 6120 t are part of a │ │ │ -00073040: 7061 640a 0909 2f2f 2066 696c 652e 2054 pad...// file. T │ │ │ -00073050: 6865 2070 6164 6469 6e67 2069 7320 6173 he padding is as │ │ │ -00073060: 7375 6d65 6420 746f 2062 6520 6174 2074 sumed to be at t │ │ │ -00073070: 6865 2065 6e64 206f 6620 7468 6520 7069 he end of the pi │ │ │ -00073080: 6563 652c 2061 6e64 2074 6865 0a09 092f ece, and the.../ │ │ │ -00073090: 2f20 626c 6f63 6b73 2063 6f76 6572 6564 / blocks covered │ │ │ -000730a0: 2062 7920 7468 6520 7061 6420 6279 7465 by the pad byte │ │ │ -000730b0: 7320 6172 6520 6e6f 7420 7069 636b 6564 s are not picked │ │ │ -000730c0: 2062 7920 7468 6520 7069 6563 6520 7069 by the piece pi │ │ │ -000730d0: 636b 6572 0a09 0973 7464 3a3a 756e 6f72 cker...std::unor │ │ │ -000730e0: 6465 7265 645f 6d61 7026 6c74 3b70 6965 dered_map<pie │ │ │ -000730f0: 6365 5f69 6e64 6578 5f74 2c20 696e 7426 ce_index_t, int& │ │ │ -00073100: 6774 3b20 6d5f 7061 6473 5f69 6e5f 7069 gt; m_pads_in_pi │ │ │ -00073110: 6563 653b 0a0a 0909 2f2f 2077 6865 6e20 ece;....// when │ │ │ -00073120: 7468 6520 6164 6a61 6365 6e74 5f70 6965 the adjacent_pie │ │ │ -00073130: 6365 2061 6666 696e 6974 7920 6973 2065 ce affinity is e │ │ │ -00073140: 6e61 626c 6564 2c20 7468 6973 2063 6f6e nabled, this con │ │ │ -00073150: 7461 696e 7320 7468 6520 6d6f 7374 0a09 tains the most.. │ │ │ -00073160: 092f 2f20 7265 6365 6e74 2022 6578 7465 .// recent "exte │ │ │ -00073170: 6e74 7322 206f 6620 6164 6a61 6365 6e74 nts" of adjacent │ │ │ -00073180: 2070 6965 6365 7320 7468 6174 2068 6176 pieces that hav │ │ │ -00073190: 6520 6265 656e 2072 6571 7565 7374 6564 e been requested │ │ │ -000731a0: 2066 726f 6d0a 0909 2f2f 2074 6869 7320 from...// this │ │ │ -000731b0: 6973 206d 7574 6162 6c65 2062 6563 6175 is mutable becau │ │ │ -000731c0: 7365 2069 7427 7320 7570 6461 7465 6420 se it's updated │ │ │ -000731d0: 6279 2066 756e 6374 696f 6e73 2074 6f20 by functions to │ │ │ -000731e0: 7069 636b 2070 6965 6365 732c 2077 6869 pick pieces, whi │ │ │ -000731f0: 6368 0a09 092f 2f20 6172 6520 636f 6e73 ch...// are cons │ │ │ -00073200: 742e 2054 6861 7427 7320 616e 2065 6666 t. That's an eff │ │ │ -00073210: 6963 6965 6e74 2070 6c61 6365 2074 6f20 icient place to │ │ │ -00073220: 7570 6461 7465 2069 742c 2073 696e 6365 update it, since │ │ │ -00073230: 2069 7427 7320 6265 696e 670a 0909 2f2f it's being...// │ │ │ -00073240: 2074 7261 7665 7273 6564 2061 6c72 6561 traversed alrea │ │ │ -00073250: 6479 2e0a 0909 6d75 7461 626c 6520 7374 dy....mutable st │ │ │ -00073260: 643a 3a76 6563 746f 7226 6c74 3b70 6965 d::vector<pie │ │ │ -00073270: 6365 5f65 7874 656e 745f 7426 6774 3b20 ce_extent_t> │ │ │ -00073280: 6d5f 7265 6365 6e74 5f65 7874 656e 7473 m_recent_extents │ │ │ -00073290: 3b0a 0a09 092f 2f20 7468 6520 6e75 6d62 ;....// the numb │ │ │ -000732a0: 6572 206f 6620 6279 7465 7320 6f66 2070 er of bytes of p │ │ │ -000732b0: 6164 2066 696c 6520 7365 7420 696e 2074 ad file set in t │ │ │ -000732c0: 6869 7320 7069 6563 6520 7069 636b 6572 his piece picker │ │ │ -000732d0: 0a09 0973 7464 3a3a 696e 7436 345f 7420 ...std::int64_t │ │ │ -000732e0: 6d5f 6e75 6d5f 7061 645f 6279 7465 7320 m_num_pad_bytes │ │ │ -000732f0: 3d20 303b 0a0a 0909 2f2f 2074 6865 206e = 0;....// the n │ │ │ -00073300: 756d 6265 7220 6f66 2070 6164 2062 6c6f umber of pad blo │ │ │ -00073310: 636b 7320 7468 6174 2077 6520 616c 7265 cks that we alre │ │ │ -00073320: 6164 7920 6861 7665 0a09 0973 7464 3a3a ady have...std:: │ │ │ -00073330: 696e 7436 345f 7420 6d5f 6861 7665 5f70 int64_t m_have_p │ │ │ -00073340: 6164 5f62 7974 6573 203d 2030 3b0a 0a09 ad_bytes = 0;... │ │ │ -00073350: 092f 2f20 7468 6520 6e75 6d62 6572 206f .// the number o │ │ │ -00073360: 6620 7061 6420 626c 6f63 6b73 2070 6172 f pad blocks par │ │ │ -00073370: 7420 6f66 2066 696c 7465 7265 6420 7069 t of filtered pi │ │ │ -00073380: 6563 6573 2077 6520 646f 6e27 7420 6861 eces we don't ha │ │ │ -00073390: 7665 0a09 0973 7464 3a3a 696e 7436 345f ve...std::int64_ │ │ │ -000733a0: 7420 6d5f 6669 6c74 6572 6564 5f70 6164 t m_filtered_pad │ │ │ -000733b0: 5f62 7974 6573 203d 2030 3b0a 0a09 092f _bytes = 0;..../ │ │ │ -000733c0: 2f20 7468 6520 6e75 6d62 6572 206f 6620 / the number of │ │ │ -000733d0: 7061 6420 626c 6f63 6b73 2077 6520 6861 pad blocks we ha │ │ │ -000733e0: 7665 2074 6861 7420 6172 6520 616c 736f ve that are also │ │ │ -000733f0: 2066 696c 7465 7265 640a 0909 7374 643a filtered...std: │ │ │ -00073400: 3a69 6e74 3634 5f74 206d 5f68 6176 655f :int64_t m_have_ │ │ │ -00073410: 6669 6c74 6572 6564 5f70 6164 5f62 7974 filtered_pad_byt │ │ │ -00073420: 6573 203d 2030 3b0a 0a09 092f 2f20 7468 es = 0;....// th │ │ │ -00073430: 6520 6e75 6d62 6572 206f 6620 7365 6564 e number of seed │ │ │ -00073440: 732e 2054 6865 7365 2061 7265 206e 6f74 s. These are not │ │ │ -00073450: 2061 6464 6564 2074 6f0a 0909 2f2f 2074 added to...// t │ │ │ -00073460: 6865 2061 7661 696c 6162 696c 6974 7920 he availability │ │ │ -00073470: 636f 756e 7465 7273 206f 6620 7468 6520 counters of the │ │ │ -00073480: 7069 6563 6573 0a09 0969 6e74 206d 5f73 pieces...int m_s │ │ │ -00073490: 6565 6473 203d 2030 3b0a 0a09 092f 2f20 eeds = 0;....// │ │ │ -000734a0: 7468 6973 2076 6563 746f 7220 636f 6e74 this vector cont │ │ │ -000734b0: 6169 6e73 2061 6c6c 2070 6965 6365 2069 ains all piece i │ │ │ -000734c0: 6e64 6963 6573 2074 6861 7420 6172 6520 ndices that are │ │ │ -000734d0: 7069 636b 6162 6c65 0a3c 2f70 7265 3e3c pickable.
    < │ │ │ -000734e0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00073510: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00073520: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../include/l │ │ │ -00073550: 6962 746f 7272 656e 742f 7069 6563 655f ibtorrent/piece_ │ │ │ -00073560: 7069 636b 6572 2e68 7070 3a38 3935 3c2f picker.hpp:895it wo │ │ │ -00073580: 756c 6420 6265 206d 6f72 6520 696e 7475 uld be more intu │ │ │ -00073590: 6974 6976 6520 746f 2061 6363 6f75 6e74 itive to account │ │ │ -000735a0: 2022 7761 6e74 6564 2220 7069 6563 6573 "wanted" pieces │ │ │ -000735b0: 2069 6e73 7465 6164 206f 6620 6669 6c74 instead of filt │ │ │ -000735c0: 6572 6564 3c2f 7464 3e3c 2f74 723e 3c74 eredit would be mo │ │ │ -00073620: 7265 2069 6e74 7569 7469 7665 2074 6f20 re intuitive to │ │ │ -00073630: 6163 636f 756e 7420 2277 616e 7465 6422 account "wanted" │ │ │ -00073640: 2070 6965 6365 730a 696e 7374 6561 6420 pieces.instead │ │ │ -00073650: 6f66 2066 696c 7465 7265 643c 2f68 323e of filtered

    │ │ │ -00073660: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ -00073670: 6962 746f 7272 656e 742f 7069 6563 655f ibtorrent/piece_ │ │ │ -00073680: 7069 636b 6572 2e68 7070 3a38 3935 3c2f picker.hpp:895
    ...
    │ │ │ -000736d0: 2f2f 2074 6869 7320 686f 6c64 7320 7468  // this holds th
    │ │ │ -000736e0: 6520 696e 666f 726d 6174 696f 6e20 6f66  e information of
    │ │ │ -000736f0: 2074 6865 2062 6c6f 636b 7320 696e 2070   the blocks in p
    │ │ │ -00073700: 6172 7469 616c 6c79 2064 6f77 6e6c 6f61  artially downloa
    │ │ │ -00073710: 6465 640a 0909 2f2f 2070 6965 6365 732e  ded...// pieces.
    │ │ │ -00073720: 2074 6865 2064 6f77 6e6c 6f61 6469 6e67   the downloading
    │ │ │ -00073730: 5f70 6965 6365 3a3a 696e 666f 2069 6e64  _piece::info ind
    │ │ │ -00073740: 6578 2070 6f69 6e74 2069 6e74 6f20 7468  ex point into th
    │ │ │ -00073750: 6973 2076 6563 746f 7220 666f 720a 0909  is vector for...
    │ │ │ -00073760: 2f2f 2069 7473 2073 746f 7261 6765 0a09  // its storage..
    │ │ │ -00073770: 0961 7578 3a3a 7665 6374 6f72 266c 743b  .aux::vector<
    │ │ │ -00073780: 626c 6f63 6b5f 696e 666f 2667 743b 206d  block_info> m
    │ │ │ -00073790: 5f62 6c6f 636b 5f69 6e66 6f3b 0a0a 0909  _block_info;....
    │ │ │ -000737a0: 2f2f 2074 6865 7365 2061 7265 2062 6c6f  // these are blo
    │ │ │ -000737b0: 636b 2072 616e 6765 7320 696e 206d 5f62  ck ranges in m_b
    │ │ │ -000737c0: 6c6f 636b 5f69 6e66 6f20 7468 6174 2061  lock_info that a
    │ │ │ -000737d0: 7265 2066 7265 652e 2054 6865 206e 756d  re free. The num
    │ │ │ -000737e0: 6265 7273 0a09 092f 2f20 696e 2068 6572  bers...// in her
    │ │ │ -000737f0: 652c 2077 6865 6e20 6d75 6c74 6970 6c69  e, when multipli
    │ │ │ -00073800: 6564 2062 7920 626c 6f63 6b73 5f70 6572  ed by blocks_per
    │ │ │ -00073810: 5f70 6965 6365 2069 7320 7468 6520 696e  _piece is the in
    │ │ │ -00073820: 6465 7820 746f 2074 6865 0a09 092f 2f20  dex to the...// 
    │ │ │ -00073830: 6669 7273 7420 626c 6f63 6b20 696e 2074  first block in t
    │ │ │ -00073840: 6865 2072 616e 6765 2074 6861 7427 7320  he range that's 
    │ │ │ -00073850: 6672 6565 2074 6f20 7573 6520 6279 2061  free to use by a
    │ │ │ -00073860: 206e 6577 2064 6f77 6e6c 6f61 6469 6e67   new downloading
    │ │ │ -00073870: 5f70 6965 6365 2e0a 0909 2f2f 2074 6869  _piece....// thi
    │ │ │ -00073880: 7320 6973 2061 2066 7265 652d 6c69 7374  s is a free-list
    │ │ │ -00073890: 2e0a 0909 7374 643a 3a76 6563 746f 7226  ....std::vector&
    │ │ │ -000738a0: 6c74 3b73 7464 3a3a 7569 6e74 3136 5f74  lt;std::uint16_t
    │ │ │ -000738b0: 2667 743b 206d 5f66 7265 655f 626c 6f63  > m_free_bloc
    │ │ │ -000738c0: 6b5f 696e 666f 733b 0a0a 0909 7374 643a  k_infos;....std:
    │ │ │ -000738d0: 3a75 696e 7431 365f 7420 6d5f 626c 6f63  :uint16_t m_bloc
    │ │ │ -000738e0: 6b73 5f69 6e5f 6c61 7374 5f70 6965 6365  ks_in_last_piece
    │ │ │ -000738f0: 203d 2030 3b0a 0909 696e 7420 6d5f 7069   = 0;...int m_pi
    │ │ │ -00073900: 6563 655f 7369 7a65 203d 2030 3b0a 0909  ece_size = 0;...
    │ │ │ -00073910: 7374 643a 3a69 6e74 3634 5f74 206d 5f74  std::int64_t m_t
    │ │ │ -00073920: 6f74 616c 5f73 697a 6520 3d20 303b 0a0a  otal_size = 0;..
    │ │ │ -00073930: 0909 2f2f 2074 6865 206e 756d 6265 7220  ..// the number 
    │ │ │ -00073940: 6f66 2066 696c 7465 7265 6420 7069 6563  of filtered piec
    │ │ │ -00073950: 6573 2074 6861 7420 7765 2064 6f6e 2774  es that we don't
    │ │ │ -00073960: 2061 6c72 6561 6479 0a09 092f 2f20 6861   already...// ha
    │ │ │ -00073970: 7665 2e20 746f 7461 6c5f 6e75 6d62 6572  ve. total_number
    │ │ │ -00073980: 5f6f 665f 7069 6563 6573 202d 206e 756d  _of_pieces - num
    │ │ │ -00073990: 6265 725f 6f66 5f70 6965 6365 735f 7765  ber_of_pieces_we
    │ │ │ -000739a0: 5f68 6176 650a 0909 2f2f 202d 206e 756d  _have...// - num
    │ │ │ -000739b0: 5f66 696c 7465 7265 6420 6973 2073 7570  _filtered is sup
    │ │ │ -000739c0: 706f 7365 6420 746f 2074 6865 206e 756d  posed to the num
    │ │ │ -000739d0: 6265 7220 6f66 2070 6965 6365 730a 0909  ber of pieces...
    │ │ │ -000739e0: 2f2f 2077 6520 7374 696c 6c20 7761 6e74  // we still want
    │ │ │ -000739f0: 2074 6f20 646f 776e 6c6f 6164 0a3c 6469   to download...int
    │ │ │ -00073a30: 206d 5f6e 756d 5f66 696c 7465 7265 6420   m_num_filtered 
    │ │ │ -00073a40: 3d20 303b 0a3c 2f64 6976 3e0a 0909 2f2f  = 0;....//
    │ │ │ -00073a50: 2074 6865 206e 756d 6265 7220 6f66 2070   the number of p
    │ │ │ -00073a60: 6965 6365 7320 7765 2068 6176 6520 7468  ieces we have th
    │ │ │ -00073a70: 6174 2061 6c73 6f20 6172 6520 6669 6c74  at also are filt
    │ │ │ -00073a80: 6572 6564 0a09 0969 6e74 206d 5f6e 756d  ered...int m_num
    │ │ │ -00073a90: 5f68 6176 655f 6669 6c74 6572 6564 203d  _have_filtered =
    │ │ │ -00073aa0: 2030 3b0a 0a09 092f 2f20 7765 2068 6176   0;....// we hav
    │ │ │ -00073ab0: 6520 616c 6c20 7069 6563 6573 2069 6e20  e all pieces in 
    │ │ │ -00073ac0: 7468 6520 7261 6e67 6520 5b30 2c20 6d5f  the range [0, m_
    │ │ │ -00073ad0: 6375 7273 6f72 290a 0909 2f2f 206d 5f63  cursor)...// m_c
    │ │ │ -00073ae0: 7572 736f 7220 6973 2074 6865 2066 6972  ursor is the fir
    │ │ │ -00073af0: 7374 2070 6965 6365 2077 6520 646f 6e27  st piece we don'
    │ │ │ -00073b00: 7420 6861 7665 0a09 0970 6965 6365 5f69  t have...piece_i
    │ │ │ -00073b10: 6e64 6578 5f74 206d 5f63 7572 736f 727b  ndex_t m_cursor{
    │ │ │ -00073b20: 307d 3b0a 0a09 092f 2f20 7765 2068 6176  0};....// we hav
    │ │ │ -00073b30: 6520 616c 6c20 7069 6563 6573 2069 6e20  e all pieces in 
    │ │ │ -00073b40: 7468 6520 7261 6e67 6520 5b6d 5f72 6576  the range [m_rev
    │ │ │ -00073b50: 6572 7365 5f63 7572 736f 722c 2065 6e64  erse_cursor, end
    │ │ │ -00073b60: 290a 0909 2f2f 206d 5f72 6576 6572 7365  )...// m_reverse
    │ │ │ -00073b70: 5f63 7572 736f 7220 6973 2074 6865 2066  _cursor is the f
    │ │ │ -00073b80: 6972 7374 2070 6965 6365 2077 6865 7265  irst piece where
    │ │ │ -00073b90: 2077 6520 616c 736f 2068 6176 650a 0909   we also have...
    │ │ │ -00073ba0: 2f2f 2061 6c6c 2074 6865 2073 7562 7365  // all the subse
    │ │ │ -00073bb0: 7175 656e 7420 7069 6563 6573 0a09 0970  quent pieces...p
    │ │ │ -00073bc0: 6965 6365 5f69 6e64 6578 5f74 206d 5f72  iece_index_t m_r
    │ │ │ -00073bd0: 6576 6572 7365 5f63 7572 736f 727b 307d  everse_cursor{0}
    │ │ │ -00073be0: 3b0a 0a09 092f 2f20 7468 6520 6e75 6d62  ;....// the numb
    │ │ │ -00073bf0: 6572 206f 6620 7069 6563 6573 2077 6520  er of pieces we 
    │ │ │ -00073c00: 6861 7665 2028 692e 652e 2070 6173 7365  have (i.e. passe
    │ │ │ -00073c10: 6420 6861 7368 2063 6865 636b 292e 0a09  d hash check)...
    │ │ │ -00073c20: 092f 2f20 5468 6973 2069 6e63 6c75 6465  .// This include
    │ │ │ -00073c30: 7320 7069 6563 6573 2074 6861 7420 7765  s pieces that we
    │ │ │ -00073c40: 2068 6176 6520 6669 6c74 6572 6564 2062   have filtered b
    │ │ │ -00073c50: 7574 2073 7469 6c6c 2068 6176 650a 0909  ut still have...
    │ │ │ -00073c60: 696e 7420 6d5f 6e75 6d5f 6861 7665 203d  int m_num_have =
    │ │ │ -00073c70: 2030 3b0a 0a09 092f 2f20 6966 2074 6869   0;....// if thi
    │ │ │ -00073c80: 7320 6973 2073 6574 2074 6f20 7472 7565  s is set to true
    │ │ │ -00073c90: 2c20 6974 206d 6561 6e73 2075 7064 6174  , it means updat
    │ │ │ -00073ca0: 655f 7069 6563 6573 2829 0a09 092f 2f20  e_pieces()...// 
    │ │ │ -00073cb0: 6861 7320 746f 2062 6520 6361 6c6c 6564  has to be called
    │ │ │ -00073cc0: 2062 6566 6f72 6520 6163 6365 7373 696e   before accessin
    │ │ │ -00073cd0: 6720 6d5f 7069 6563 6573 2e0a 0909 6d75  g m_pieces....mu
    │ │ │ -00073ce0: 7461 626c 6520 626f 6f6c 206d 5f64 6972  table bool m_dir
    │ │ │ -00073cf0: 7479 203d 2066 616c 7365 3b0a 0970 7562  ty = false;..pub
    │ │ │ -00073d00: 6c69 633a 0a0a 0909 656e 756d 207b 206d  lic:....enum { m
    │ │ │ -00073d10: 6178 5f70 6965 6365 7320 3d20 2873 7464  ax_pieces = (std
    │ │ │ -00073d20: 3a3a 6e75 6d65 7269 635f 6c69 6d69 7473  ::numeric_limits
    │ │ │ -00073d30: 266c 743b 696e 7426 6774 3b3a 3a6d 6178  <int>::max
    │ │ │ -00073d40: 2928 2920 2d20 3120 7d3b 0a0a 097d 3b0a  )() - 1 };...};.
    │ │ │ -00073d50: 7d0a 0a23 656e 6469 6620 2f2f 2054 4f52  }..#endif // TOR
    │ │ │ -00073d60: 5245 4e54 5f50 4945 4345 5f50 4943 4b45  RENT_PIECE_PICKE
    │ │ │ -00073d70: 525f 4850 505f 494e 434c 5544 4544 0a3c  R_HPP_INCLUDED.<
    │ │ │ -00073d80: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ -00073d90: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ -00073da0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ -00073db0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ -00073dc0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../inc
    │ │ │ -00073df0: 6c75 6465 2f6c 6962 746f 7272 656e 742f  lude/libtorrent/
    │ │ │ -00073e00: 7065 7266 6f72 6d61 6e63 655f 636f 756e  performance_coun
    │ │ │ -00073e10: 7465 7273 2e68 7070 3a34 3931 3c2f 613e  ters.hpp:491
    │ │ │ -00073e20: 3c2f 7464 3e3c 7464 3e73 6f6d 6520 7370  some sp
    │ │ │ -00073e30: 6163 6520 636f 756c 6420 6265 2073 6176  ace could be sav
    │ │ │ -00073e40: 6564 2068 6572 6520 6279 206d 616b 696e  ed here by makin
    │ │ │ -00073e50: 6720 6761 7567 6573 2033 3220 6269 7473  g gauges 32 bits
    │ │ │ -00073e60: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964  

    so │ │ │ -00073eb0: 6d65 2073 7061 6365 2063 6f75 6c64 2062 me space could b │ │ │ -00073ec0: 6520 7361 7665 6420 6865 7265 2062 7920 e saved here by │ │ │ -00073ed0: 6d61 6b69 6e67 2067 6175 6765 7320 3332 making gauges 32 │ │ │ -00073ee0: 2062 6974 733c 2f68 323e 3c68 343e 2e2e bits

    .. │ │ │ -00073ef0: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -00073f00: 656e 742f 7065 7266 6f72 6d61 6e63 655f ent/performance_ │ │ │ -00073f10: 636f 756e 7465 7273 2e68 7070 3a34 3931 counters.hpp:491 │ │ │ -00073f20: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    <
    │ │ │ -00073f60: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c  /pre><
    │ │ │ -00073f70: 7472 2073 7479 6c65 3d22 6261 636b 6772  tr style="backgr
    │ │ │ -00073f80: 6f75 6e64 3a20 2363 6363 223e 3c74 643e  ound: #ccc">
    │ │ │ -00073f90: 7265 6c65 7661 6e63 6526 6e62 7370 3b30  relevance 0
    │ │ │ -00073fa0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566  ../inc
    │ │ │ -00073fd0: 6c75 6465 2f6c 6962 746f 7272 656e 742f  lude/libtorrent/
    │ │ │ -00073fe0: 7065 7266 6f72 6d61 6e63 655f 636f 756e  performance_coun
    │ │ │ -00073ff0: 7465 7273 2e68 7070 3a34 3932 3c2f 613e  ters.hpp:492
    │ │ │ -00074000: 3c2f 7464 3e3c 7464 3e72 6573 746f 7265  restore
    │ │ │ -00074010: 2074 6865 7365 2074 6f20 7265 6775 6c61   these to regula
    │ │ │ -00074020: 7220 696e 7465 6765 7273 2e20 496e 7374  r integers. Inst
    │ │ │ -00074030: 6561 6420 6861 7665 206f 6e65 2063 6f70  ead have one cop
    │ │ │ -00074040: 7920 6f66 2074 6865 2063 6f75 6e74 6572  y of the counter
    │ │ │ -00074050: 7320 7065 7220 7468 7265 6164 2061 6e64  s per thread and
    │ │ │ -00074060: 2063 6f6c 6c65 6374 2074 6865 6d20 6174   collect them at
    │ │ │ -00074070: 2063 6f6e 7665 6e69 656e 7420 7379 6e63   convenient sync
    │ │ │ -00074080: 6872 6f6e 697a 6174 696f 6e20 706f 696e  hronization poin
    │ │ │ -00074090: 7473 3c2f 7464 3e3c 2f74 723e 3c74 7220  ts

    │ │ │ -000740e0: 7265 7374 6f72 6520 7468 6573 6520 746f restore these to │ │ │ -000740f0: 2072 6567 756c 6172 2069 6e74 6567 6572 regular integer │ │ │ -00074100: 732e 2049 6e73 7465 6164 2068 6176 6520 s. Instead have │ │ │ -00074110: 6f6e 6520 636f 7079 0a6f 6620 7468 6520 one copy.of the │ │ │ -00074120: 636f 756e 7465 7273 2070 6572 2074 6872 counters per thr │ │ │ -00074130: 6561 6420 616e 6420 636f 6c6c 6563 7420 ead and collect │ │ │ -00074140: 7468 656d 2061 7420 636f 6e76 656e 6965 them at convenie │ │ │ -00074150: 6e74 0a73 796e 6368 726f 6e69 7a61 7469 nt.synchronizati │ │ │ -00074160: 6f6e 2070 6f69 6e74 733c 2f68 323e 3c68 on points

    ../include/lib │ │ │ -00074180: 746f 7272 656e 742f 7065 7266 6f72 6d61 torrent/performa │ │ │ -00074190: 6e63 655f 636f 756e 7465 7273 2e68 7070 nce_counters.hpp │ │ │ -000741a0: 3a34 3932 3c2f 6834 3e3c 7072 6520 7374 :492

    #ifdef ATOMIC
    │ │ │ -000741f0: 5f4c 4c4f 4e47 5f4c 4f43 4b5f 4652 4545  _LLONG_LOCK_FREE
    │ │ │ -00074200: 0a23 6465 6669 6e65 2054 4f52 5245 4e54  .#define TORRENT
    │ │ │ -00074210: 5f43 4f55 4e54 4552 5f4e 4f45 5843 4550  _COUNTER_NOEXCEP
    │ │ │ -00074220: 5420 6e6f 6578 6365 7074 0a23 656c 7365  T noexcept.#else
    │ │ │ -00074230: 0a23 6465 6669 6e65 2054 4f52 5245 4e54  .#define TORRENT
    │ │ │ -00074240: 5f43 4f55 4e54 4552 5f4e 4f45 5843 4550  _COUNTER_NOEXCEP
    │ │ │ -00074250: 540a 2365 6e64 6966 0a0a 0909 636f 756e  T.#endif....coun
    │ │ │ -00074260: 7465 7273 2829 2054 4f52 5245 4e54 5f43  ters() TORRENT_C
    │ │ │ -00074270: 4f55 4e54 4552 5f4e 4f45 5843 4550 543b  OUNTER_NOEXCEPT;
    │ │ │ -00074280: 0a0a 0909 636f 756e 7465 7273 2863 6f75  ....counters(cou
    │ │ │ -00074290: 6e74 6572 7320 636f 6e73 7426 616d 703b  nters const&
    │ │ │ -000742a0: 2920 544f 5252 454e 545f 434f 554e 5445  ) TORRENT_COUNTE
    │ │ │ -000742b0: 525f 4e4f 4558 4345 5054 3b0a 0909 636f  R_NOEXCEPT;...co
    │ │ │ -000742c0: 756e 7465 7273 2661 6d70 3b20 6f70 6572  unters& oper
    │ │ │ -000742d0: 6174 6f72 3d28 636f 756e 7465 7273 2063  ator=(counters c
    │ │ │ -000742e0: 6f6e 7374 2661 6d70 3b29 2026 616d 703b  onst&) &
    │ │ │ -000742f0: 2054 4f52 5245 4e54 5f43 4f55 4e54 4552   TORRENT_COUNTER
    │ │ │ -00074300: 5f4e 4f45 5843 4550 543b 0a0a 0909 2f2f  _NOEXCEPT;....//
    │ │ │ -00074310: 2072 6574 7572 6e73 2074 6865 206e 6577   returns the new
    │ │ │ -00074320: 2076 616c 7565 0a09 0973 7464 3a3a 696e   value...std::in
    │ │ │ -00074330: 7436 345f 7420 696e 635f 7374 6174 735f  t64_t inc_stats_
    │ │ │ -00074340: 636f 756e 7465 7228 696e 7420 632c 2073  counter(int c, s
    │ │ │ -00074350: 7464 3a3a 696e 7436 345f 7420 7661 6c75  td::int64_t valu
    │ │ │ -00074360: 6520 3d20 3129 2054 4f52 5245 4e54 5f43  e = 1) TORRENT_C
    │ │ │ -00074370: 4f55 4e54 4552 5f4e 4f45 5843 4550 543b  OUNTER_NOEXCEPT;
    │ │ │ -00074380: 0a09 0973 7464 3a3a 696e 7436 345f 7420  ...std::int64_t 
    │ │ │ -00074390: 6f70 6572 6174 6f72 5b5d 2869 6e74 2069  operator[](int i
    │ │ │ -000743a0: 2920 636f 6e73 7420 544f 5252 454e 545f  ) const TORRENT_
    │ │ │ -000743b0: 434f 554e 5445 525f 4e4f 4558 4345 5054  COUNTER_NOEXCEPT
    │ │ │ -000743c0: 3b0a 0a09 0976 6f69 6420 7365 745f 7661  ;....void set_va
    │ │ │ -000743d0: 6c75 6528 696e 7420 632c 2073 7464 3a3a  lue(int c, std::
    │ │ │ -000743e0: 696e 7436 345f 7420 7661 6c75 6529 2054  int64_t value) T
    │ │ │ -000743f0: 4f52 5245 4e54 5f43 4f55 4e54 4552 5f4e  ORRENT_COUNTER_N
    │ │ │ -00074400: 4f45 5843 4550 543b 0a09 0976 6f69 6420  OEXCEPT;...void 
    │ │ │ -00074410: 626c 656e 645f 7374 6174 735f 636f 756e  blend_stats_coun
    │ │ │ -00074420: 7465 7228 696e 7420 632c 2073 7464 3a3a  ter(int c, std::
    │ │ │ -00074430: 696e 7436 345f 7420 7661 6c75 652c 2069  int64_t value, i
    │ │ │ -00074440: 6e74 2072 6174 696f 2920 544f 5252 454e  nt ratio) TORREN
    │ │ │ -00074450: 545f 434f 554e 5445 525f 4e4f 4558 4345  T_COUNTER_NOEXCE
    │ │ │ -00074460: 5054 3b0a 0a09 7072 6976 6174 653a 0a0a  PT;...private:..
    │ │ │ -00074470: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    #i │ │ │ -000744a0: 6664 6566 2041 544f 4d49 435f 4c4c 4f4e fdef ATOMIC_LLON │ │ │ -000744b0: 475f 4c4f 434b 5f46 5245 450a 3c2f 6469 G_LOCK_FREE...aux::array&l │ │ │ -000744d0: 743b 7374 643a 3a61 746f 6d69 6326 6c74 t;std::atomic< │ │ │ -000744e0: 3b73 7464 3a3a 696e 7436 345f 7426 6774 ;std::int64_t> │ │ │ -000744f0: 3b2c 206e 756d 5f63 6f75 6e74 6572 7326 ;, num_counters& │ │ │ -00074500: 6774 3b20 6d5f 7374 6174 735f 636f 756e gt; m_stats_coun │ │ │ -00074510: 7465 723b 0a23 656c 7365 0a09 092f 2f20 ter;.#else...// │ │ │ -00074520: 6966 2074 6865 2061 746f 6d69 6320 7479 if the atomic ty │ │ │ -00074530: 7065 2069 736e 2774 206c 6f63 6b2d 6672 pe isn't lock-fr │ │ │ -00074540: 6565 2c20 7573 6520 6120 7369 6e67 6c65 ee, use a single │ │ │ -00074550: 206c 6f63 6b20 696e 7374 6561 642c 2066 lock instead, f │ │ │ -00074560: 6f72 0a09 092f 2f20 7468 6520 7768 6f6c or...// the whol │ │ │ -00074570: 6520 6172 7261 790a 0909 6d75 7461 626c e array...mutabl │ │ │ -00074580: 6520 7374 643a 3a6d 7574 6578 206d 5f6d e std::mutex m_m │ │ │ -00074590: 7574 6578 3b0a 0909 6175 783a 3a61 7272 utex;...aux::arr │ │ │ -000745a0: 6179 266c 743b 7374 643a 3a69 6e74 3634 ay<std::int64 │ │ │ -000745b0: 5f74 2c20 6e75 6d5f 636f 756e 7465 7273 _t, num_counters │ │ │ -000745c0: 2667 743b 206d 5f73 7461 7473 5f63 6f75 > m_stats_cou │ │ │ -000745d0: 6e74 6572 3b0a 2365 6e64 6966 0a09 7d3b nter;.#endif..}; │ │ │ -000745e0: 0a7d 0a0a 2365 6e64 6966 0a3c 2f70 7265 .}..#endif.
    rele │ │ │ -00074620: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../include │ │ │ -00074660: 2f6c 6962 746f 7272 656e 742f 7065 6572 /libtorrent/peer │ │ │ -00074670: 5f63 6f6e 6e65 6374 696f 6e5f 696e 7465 _connection_inte │ │ │ -00074680: 7266 6163 652e 6870 703a 3531 3c2f 613e rface.hpp:51 │ │ │ -00074690: 3c2f 7464 3e3c 7464 3e6d 616b 6520 7468 make th │ │ │ -000746a0: 6973 2069 6e74 6572 6661 6365 2073 6d61 is interface sma │ │ │ -000746b0: 6c6c 6572 213c 2f74 643e 3c2f 7472 3e3c ller!< │ │ │ -000746c0: 7472 2069 643d 2232 3634 2220 7374 796c tr id="264" styl │ │ │ -000746d0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -000746e0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -000746f0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00074700: 6832 3e6d 616b 6520 7468 6973 2069 6e74 h2>make this int │ │ │ -00074710: 6572 6661 6365 2073 6d61 6c6c 6572 213c erface smaller!< │ │ │ -00074720: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ -00074730: 6465 2f6c 6962 746f 7272 656e 742f 7065 de/libtorrent/pe │ │ │ -00074740: 6572 5f63 6f6e 6e65 6374 696f 6e5f 696e er_connection_in │ │ │ -00074750: 7465 7266 6163 652e 6870 703a 3531 3c2f terface.hpp:51
    .*/
    │ │ │ -000747a0: 0a0a 2369 666e 6465 6620 544f 5252 454e  ..#ifndef TORREN
    │ │ │ -000747b0: 545f 5045 4552 5f43 4f4e 4e45 4354 494f  T_PEER_CONNECTIO
    │ │ │ -000747c0: 4e5f 494e 5445 5246 4143 455f 4850 500a  N_INTERFACE_HPP.
    │ │ │ -000747d0: 2364 6566 696e 6520 544f 5252 454e 545f  #define TORRENT_
    │ │ │ -000747e0: 5045 4552 5f43 4f4e 4e45 4354 494f 4e5f  PEER_CONNECTION_
    │ │ │ -000747f0: 494e 5445 5246 4143 455f 4850 500a 0a23  INTERFACE_HPP..#
    │ │ │ -00074800: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ -00074810: 656e 742f 6677 642e 6870 7022 0a23 696e  ent/fwd.hpp".#in
    │ │ │ -00074820: 636c 7564 6520 226c 6962 746f 7272 656e  clude "libtorren
    │ │ │ -00074830: 742f 736f 636b 6574 2e68 7070 220a 2369  t/socket.hpp".#i
    │ │ │ -00074840: 6e63 6c75 6465 2022 6c69 6274 6f72 7265  nclude "libtorre
    │ │ │ -00074850: 6e74 2f65 7272 6f72 5f63 6f64 652e 6870  nt/error_code.hp
    │ │ │ -00074860: 7022 0a23 696e 636c 7564 6520 226c 6962  p".#include "lib
    │ │ │ -00074870: 746f 7272 656e 742f 616c 6572 745f 7479  torrent/alert_ty
    │ │ │ -00074880: 7065 732e 6870 7022 0a23 696e 636c 7564  pes.hpp".#includ
    │ │ │ -00074890: 6520 226c 6962 746f 7272 656e 742f 6f70  e "libtorrent/op
    │ │ │ -000748a0: 6572 6174 696f 6e73 2e68 7070 2220 2f2f  erations.hpp" //
    │ │ │ -000748b0: 2066 6f72 206f 7065 7261 7469 6f6e 5f74   for operation_t
    │ │ │ -000748c0: 2065 6e75 6d0a 2369 6e63 6c75 6465 2022   enum.#include "
    │ │ │ -000748d0: 6c69 6274 6f72 7265 6e74 2f75 6e69 7473  libtorrent/units
    │ │ │ -000748e0: 2e68 7070 220a 0a6e 616d 6573 7061 6365  .hpp"..namespace
    │ │ │ -000748f0: 206c 6962 746f 7272 656e 7420 7b0a 0a09   libtorrent {...
    │ │ │ -00074900: 7374 7275 6374 2074 6f72 7265 6e74 5f70  struct torrent_p
    │ │ │ -00074910: 6565 723b 0a09 636c 6173 7320 7374 6174  eer;..class stat
    │ │ │ -00074920: 3b0a 0a09 7573 696e 6720 6469 7363 6f6e  ;...using discon
    │ │ │ -00074930: 6e65 6374 5f73 6576 6572 6974 795f 7420  nect_severity_t 
    │ │ │ -00074940: 3d20 6175 783a 3a73 7472 6f6e 675f 7479  = aux::strong_ty
    │ │ │ -00074950: 7065 6465 6626 6c74 3b73 7464 3a3a 7569  pedef<std::ui
    │ │ │ -00074960: 6e74 385f 742c 2073 7472 7563 7420 6469  nt8_t, struct di
    │ │ │ -00074970: 7363 6f6e 6e65 6374 5f73 6576 6572 6974  sconnect_severit
    │ │ │ -00074980: 795f 7461 6726 6774 3b3b 0a0a 3c64 6976  y_tag>;..
    .struc │ │ │ -000749c0: 7420 544f 5252 454e 545f 4558 5452 415f t TORRENT_EXTRA_ │ │ │ -000749d0: 4558 504f 5254 2070 6565 725f 636f 6e6e EXPORT peer_conn │ │ │ -000749e0: 6563 7469 6f6e 5f69 6e74 6572 6661 6365 ection_interface │ │ │ -000749f0: 0a3c 2f64 6976 3e09 7b0a 0909 7374 6174 .
    .{...stat │ │ │ -00074a00: 6963 2063 6f6e 7374 6578 7072 2064 6973 ic constexpr dis │ │ │ -00074a10: 636f 6e6e 6563 745f 7365 7665 7269 7479 connect_severity │ │ │ -00074a20: 5f74 206e 6f72 6d61 6c7b 307d 3b0a 0909 _t normal{0};... │ │ │ -00074a30: 7374 6174 6963 2063 6f6e 7374 6578 7072 static constexpr │ │ │ -00074a40: 2064 6973 636f 6e6e 6563 745f 7365 7665 disconnect_seve │ │ │ -00074a50: 7269 7479 5f74 2066 6169 6c75 7265 7b31 rity_t failure{1 │ │ │ -00074a60: 7d3b 0a09 0973 7461 7469 6320 636f 6e73 };...static cons │ │ │ -00074a70: 7465 7870 7220 6469 7363 6f6e 6e65 6374 texpr disconnect │ │ │ -00074a80: 5f73 6576 6572 6974 795f 7420 7065 6572 _severity_t peer │ │ │ -00074a90: 5f65 7272 6f72 7b32 7d3b 0a0a 2369 6620 _error{2};..#if │ │ │ -00074aa0: 544f 5252 454e 545f 5553 455f 4932 500a TORRENT_USE_I2P. │ │ │ -00074ab0: 0909 7669 7274 7561 6c20 7374 643a 3a73 ..virtual std::s │ │ │ -00074ac0: 7472 696e 6720 636f 6e73 7426 616d 703b tring const& │ │ │ -00074ad0: 2064 6573 7469 6e61 7469 6f6e 2829 2063 destination() c │ │ │ -00074ae0: 6f6e 7374 203d 2030 3b0a 0909 7669 7274 onst = 0;...virt │ │ │ -00074af0: 7561 6c20 7374 643a 3a73 7472 696e 6720 ual std::string │ │ │ -00074b00: 636f 6e73 7426 616d 703b 206c 6f63 616c const& local │ │ │ -00074b10: 5f69 3270 5f65 6e64 706f 696e 7428 2920 _i2p_endpoint() │ │ │ -00074b20: 636f 6e73 7420 3d20 303b 0a23 656e 6469 const = 0;.#endi │ │ │ -00074b30: 660a 0909 7669 7274 7561 6c20 7463 703a f...virtual tcp: │ │ │ -00074b40: 3a65 6e64 706f 696e 7420 636f 6e73 7426 :endpoint const& │ │ │ -00074b50: 616d 703b 2072 656d 6f74 6528 2920 636f amp; remote() co │ │ │ -00074b60: 6e73 7420 3d20 303b 0a09 0976 6972 7475 nst = 0;...virtu │ │ │ -00074b70: 616c 2074 6370 3a3a 656e 6470 6f69 6e74 al tcp::endpoint │ │ │ -00074b80: 206c 6f63 616c 5f65 6e64 706f 696e 7428 local_endpoint( │ │ │ -00074b90: 2920 636f 6e73 7420 3d20 303b 0a09 0976 ) const = 0;...v │ │ │ -00074ba0: 6972 7475 616c 2076 6f69 6420 6469 7363 irtual void disc │ │ │ -00074bb0: 6f6e 6e65 6374 2865 7272 6f72 5f63 6f64 onnect(error_cod │ │ │ -00074bc0: 6520 636f 6e73 7426 616d 703b 2065 630a e const& ec. │ │ │ -00074bd0: 0909 092c 206f 7065 7261 7469 6f6e 5f74 ..., operation_t │ │ │ -00074be0: 206f 702c 2064 6973 636f 6e6e 6563 745f op, disconnect_ │ │ │ -00074bf0: 7365 7665 7269 7479 5f74 203d 2070 6565 severity_t = pee │ │ │ -00074c00: 725f 636f 6e6e 6563 7469 6f6e 5f69 6e74 r_connection_int │ │ │ -00074c10: 6572 6661 6365 3a3a 6e6f 726d 616c 2920 erface::normal) │ │ │ -00074c20: 3d20 303b 0a09 0976 6972 7475 616c 2070 = 0;...virtual p │ │ │ -00074c30: 6565 725f 6964 2063 6f6e 7374 2661 6d70 eer_id const& │ │ │ -00074c40: 3b20 7069 6428 2920 636f 6e73 7420 3d20 ; pid() const = │ │ │ -00074c50: 303b 0a09 0976 6972 7475 616c 2070 6565 0;...virtual pee │ │ │ -00074c60: 725f 6964 206f 7572 5f70 6964 2829 2063 r_id our_pid() c │ │ │ -00074c70: 6f6e 7374 203d 2030 3b0a 0909 7669 7274 onst = 0;...virt │ │ │ -00074c80: 7561 6c20 766f 6964 2073 6574 5f68 6f6c ual void set_hol │ │ │ -00074c90: 6570 756e 6368 5f6d 6f64 6528 2920 3d20 epunch_mode() = │ │ │ -00074ca0: 303b 0a09 0976 6972 7475 616c 2074 6f72 0;...virtual tor │ │ │ -00074cb0: 7265 6e74 5f70 6565 722a 2070 6565 725f rent_peer* peer_ │ │ │ -00074cc0: 696e 666f 5f73 7472 7563 7428 2920 636f info_struct() co │ │ │ -00074cd0: 6e73 7420 3d20 303b 0a09 0976 6972 7475 nst = 0;...virtu │ │ │ -00074ce0: 616c 2076 6f69 6420 7365 745f 7065 6572 al void set_peer │ │ │ -00074cf0: 5f69 6e66 6f28 746f 7272 656e 745f 7065 _info(torrent_pe │ │ │ -00074d00: 6572 2a20 7069 2920 3d20 303b 0a09 0976 er* pi) = 0;...v │ │ │ -00074d10: 6972 7475 616c 2062 6f6f 6c20 6973 5f6f irtual bool is_o │ │ │ -00074d20: 7574 676f 696e 6728 2920 636f 6e73 7420 utgoing() const │ │ │ -00074d30: 3d20 303b 0a09 0976 6972 7475 616c 2076 = 0;...virtual v │ │ │ -00074d40: 6f69 6420 6164 645f 7374 6174 2873 7464 oid add_stat(std │ │ │ -00074d50: 3a3a 696e 7436 345f 7420 646f 776e 6c6f ::int64_t downlo │ │ │ -00074d60: 6164 6564 2c20 7374 643a 3a69 6e74 3634 aded, std::int64 │ │ │ -00074d70: 5f74 2075 706c 6f61 6465 6429 203d 2030 _t uploaded) = 0 │ │ │ -00074d80: 3b0a 0909 7669 7274 7561 6c20 626f 6f6c ;...virtual bool │ │ │ -00074d90: 2066 6173 745f 7265 636f 6e6e 6563 7428 fast_reconnect( │ │ │ -00074da0: 2920 636f 6e73 7420 3d20 303b 0a09 0976 ) const = 0;...v │ │ │ -00074db0: 6972 7475 616c 2062 6f6f 6c20 6973 5f63 irtual bool is_c │ │ │ -00074dc0: 686f 6b65 6428 2920 636f 6e73 7420 3d20 hoked() const = │ │ │ -00074dd0: 303b 0a09 0976 6972 7475 616c 2062 6f6f 0;...virtual boo │ │ │ -00074de0: 6c20 6661 696c 6564 2829 2063 6f6e 7374 l failed() const │ │ │ -00074df0: 203d 2030 3b0a 0909 7669 7274 7561 6c20 = 0;...virtual │ │ │ -00074e00: 7374 6174 2063 6f6e 7374 2661 6d70 3b20 stat const& │ │ │ -00074e10: 7374 6174 6973 7469 6373 2829 2063 6f6e statistics() con │ │ │ -00074e20: 7374 203d 2030 3b0a 0909 7669 7274 7561 st = 0;...virtua │ │ │ -00074e30: 6c20 766f 6964 2067 6574 5f70 6565 725f l void get_peer_ │ │ │ -00074e40: 696e 666f 2870 6565 725f 696e 666f 2661 info(peer_info&a │ │ │ -00074e50: 6d70 3b20 7029 2063 6f6e 7374 203d 2030 mp; p) const = 0 │ │ │ -00074e60: 3b0a 2369 666e 6465 6620 544f 5252 454e ;.#ifndef TORREN │ │ │ -00074e70: 545f 4449 5341 424c 455f 4c4f 4747 494e T_DISABLE_LOGGIN │ │ │ -00074e80: 470a 0909 7669 7274 7561 6c20 626f 6f6c G...virtual bool │ │ │ -00074e90: 2073 686f 756c 645f 6c6f 6728 7065 6572 should_log(peer │ │ │ -00074ea0: 5f6c 6f67 5f61 6c65 7274 3a3a 6469 7265 _log_alert::dire │ │ │ -00074eb0: 6374 696f 6e5f 7420 6469 7265 6374 696f ction_t directio │ │ │ -00074ec0: 6e29 2063 6f6e 7374 203d 2030 3b0a 0909 n) const = 0;... │ │ │ -00074ed0: 7669 7274 7561 6c20 766f 6964 2070 6565 virtual void pee │ │ │ -00074ee0: 725f 6c6f 6728 7065 6572 5f6c 6f67 5f61 r_log(peer_log_a │ │ │ -00074ef0: 6c65 7274 3a3a 6469 7265 6374 696f 6e5f lert::direction_ │ │ │ -00074f00: 7420 6469 7265 6374 696f 6e0a 0909 092c t direction...., │ │ │ -00074f10: 2063 6861 7220 636f 6e73 742a 2065 7665 char const* eve │ │ │ -00074f20: 6e74 2c20 6368 6172 2063 6f6e 7374 2a20 nt, char const* │ │ │ -00074f30: 666d 7420 3d20 2222 2c20 2e2e 2e29 2063 fmt = "", ...) c │ │ │ -00074f40: 6f6e 7374 206e 6f65 7863 6570 7420 544f onst noexcept TO │ │ │ -00074f50: 5252 454e 545f 464f 524d 4154 2834 2c35 RRENT_FORMAT(4,5 │ │ │ -00074f60: 2920 3d20 303b 0a23 656e 6469 660a 3c2f ) = 0;.#endif.r │ │ │ -00074fa0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -00074fb0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../incl │ │ │ -00074fe0: 7564 652f 6c69 6274 6f72 7265 6e74 2f70 ude/libtorrent/p │ │ │ -00074ff0: 6565 725f 636f 6e6e 6563 7469 6f6e 2e68 eer_connection.h │ │ │ -00075000: 7070 3a32 3138 3c2f 613e 3c2f 7464 3e3c pp:218< │ │ │ -00075010: 7464 3e6d 616b 6520 7468 6973 2061 2072 td>make this a r │ │ │ -00075020: 6177 2070 6f69 6e74 6572 2028 746f 2073 aw pointer (to s │ │ │ -00075030: 6176 6520 7369 7a65 2069 6e20 7468 6520 ave size in the │ │ │ -00075040: 6669 7273 7420 6361 6368 6520 6c69 6e65 first cache line │ │ │ -00075050: 2920 616e 6420 6d61 6b65 2074 6865 2063 ) and make the c │ │ │ -00075060: 6f6e 7374 7275 6374 6f72 2074 616b 6520 onstructor take │ │ │ -00075070: 6120 7261 7720 706f 696e 7465 722e 2074 a raw pointer. t │ │ │ -00075080: 6f72 7265 6e74 206f 626a 6563 7473 2073 orrent objects s │ │ │ -00075090: 686f 756c 6420 616c 7761 7973 206f 7574 hould always out │ │ │ -000750a0: 6c69 7665 2074 6865 6972 2070 6565 7273 live their peers │ │ │ -000750b0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    ma │ │ │ -00075100: 6b65 2074 6869 7320 6120 7261 7720 706f ke this a raw po │ │ │ -00075110: 696e 7465 7220 2874 6f20 7361 7665 2073 inter (to save s │ │ │ -00075120: 697a 6520 696e 0a74 6865 2066 6972 7374 ize in.the first │ │ │ -00075130: 2063 6163 6865 206c 696e 6529 2061 6e64 cache line) and │ │ │ -00075140: 206d 616b 6520 7468 6520 636f 6e73 7472 make the constr │ │ │ -00075150: 7563 746f 720a 7461 6b65 2061 2072 6177 uctor.take a raw │ │ │ -00075160: 2070 6f69 6e74 6572 2e20 746f 7272 656e pointer. torren │ │ │ -00075170: 7420 6f62 6a65 6374 7320 7368 6f75 6c64 t objects should │ │ │ -00075180: 2061 6c77 6179 730a 6f75 746c 6976 6520 always.outlive │ │ │ -00075190: 7468 6569 7220 7065 6572 733c 2f68 323e their peers

    │ │ │ -000751a0: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ -000751b0: 6962 746f 7272 656e 742f 7065 6572 5f63 ibtorrent/peer_c │ │ │ -000751c0: 6f6e 6e65 6374 696f 6e2e 6870 703a 3231 onnection.hpp:21 │ │ │ -000751d0: 383c 2f68 343e 3c70 7265 2073 7479 6c65 8

    │ │ │ -00075210: 0909 092c 206d 5f73 6e75 6262 6564 2866  ..., m_snubbed(f
    │ │ │ -00075220: 616c 7365 290a 0909 092c 206d 5f69 6e74  alse)...., m_int
    │ │ │ -00075230: 6572 6573 7469 6e67 2866 616c 7365 290a  eresting(false).
    │ │ │ -00075240: 0909 092c 206d 5f63 686f 6b65 6428 7472  ..., m_choked(tr
    │ │ │ -00075250: 7565 290a 0909 092c 206d 5f69 676e 6f72  ue)...., m_ignor
    │ │ │ -00075260: 655f 7374 6174 7328 6661 6c73 6529 0a09  e_stats(false)..
    │ │ │ -00075270: 097b 7d0a 0a09 092f 2f20 6578 706c 6963  .{}....// explic
    │ │ │ -00075280: 6974 6c79 2064 6973 616c 6c6f 7720 6173  itly disallow as
    │ │ │ -00075290: 7369 676e 6d65 6e74 2c20 746f 2073 696c  signment, to sil
    │ │ │ -000752a0: 656e 6365 206d 7376 6320 7761 726e 696e  ence msvc warnin
    │ │ │ -000752b0: 670a 0909 7065 6572 5f63 6f6e 6e65 6374  g...peer_connect
    │ │ │ -000752c0: 696f 6e5f 686f 745f 6d65 6d62 6572 7326  ion_hot_members&
    │ │ │ -000752d0: 616d 703b 206f 7065 7261 746f 723d 2870  amp; operator=(p
    │ │ │ -000752e0: 6565 725f 636f 6e6e 6563 7469 6f6e 5f68  eer_connection_h
    │ │ │ -000752f0: 6f74 5f6d 656d 6265 7273 2063 6f6e 7374  ot_members const
    │ │ │ -00075300: 2661 6d70 3b29 203d 2064 656c 6574 653b  &) = delete;
    │ │ │ -00075310: 0a0a 0970 726f 7465 6374 6564 3a0a 0a09  ...protected:...
    │ │ │ -00075320: 092f 2f20 7468 6520 7069 6563 6573 2074  .// the pieces t
    │ │ │ -00075330: 6865 206f 7468 6572 2065 6e64 2068 6176  he other end hav
    │ │ │ -00075340: 650a 0909 7479 7065 645f 6269 7466 6965  e...typed_bitfie
    │ │ │ -00075350: 6c64 266c 743b 7069 6563 655f 696e 6465  ld<piece_inde
    │ │ │ -00075360: 785f 7426 6774 3b20 6d5f 6861 7665 5f70  x_t> m_have_p
    │ │ │ -00075370: 6965 6365 3b0a 0a09 092f 2f20 7468 6973  iece;....// this
    │ │ │ -00075380: 2069 7320 7468 6520 746f 7272 656e 7420   is the torrent 
    │ │ │ -00075390: 7468 6973 2063 6f6e 6e65 6374 696f 6e20  this connection 
    │ │ │ -000753a0: 6973 0a09 092f 2f20 6173 736f 6369 6174  is...// associat
    │ │ │ -000753b0: 6564 2077 6974 682e 2049 6620 7468 6520  ed with. If the 
    │ │ │ -000753c0: 636f 6e6e 6563 7469 6f6e 2069 7320 616e  connection is an
    │ │ │ -000753d0: 0a09 092f 2f20 696e 636f 6d69 6e67 2063  ...// incoming c
    │ │ │ -000753e0: 6f6e 6e65 6374 696f 6e2c 2074 6869 7320  onnection, this 
    │ │ │ -000753f0: 6973 2073 6574 2074 6f20 7a65 726f 0a09  is set to zero..
    │ │ │ -00075400: 092f 2f20 756e 7469 6c20 7468 6520 696e  .// until the in
    │ │ │ -00075410: 666f 5f68 6173 6820 6973 2072 6563 6569  fo_hash is recei
    │ │ │ -00075420: 7665 642e 2054 6865 6e20 6974 2773 0a09  ved. Then it's..
    │ │ │ -00075430: 092f 2f20 7365 7420 746f 2074 6865 2074  .// set to the t
    │ │ │ -00075440: 6f72 7265 6e74 2069 7420 6265 6c6f 6e67  orrent it belong
    │ │ │ -00075450: 7320 746f 2e0a 0a3c 6469 7620 7374 796c  s to...
    ..std::weak │ │ │ -00075490: 5f70 7472 266c 743b 746f 7272 656e 7426 _ptr<torrent& │ │ │ -000754a0: 6774 3b20 6d5f 746f 7272 656e 743b 0a3c gt; m_torrent;.< │ │ │ -000754b0: 2f64 6976 3e0a 0970 7562 6c69 633a 0a0a /div>..public:.. │ │ │ -000754c0: 0909 2f2f 2061 2062 6163 6b20 7265 6665 ..// a back refe │ │ │ -000754d0: 7265 6e63 6520 746f 2074 6865 2073 6573 rence to the ses │ │ │ -000754e0: 7369 6f6e 0a09 092f 2f20 7468 6520 7065 sion...// the pe │ │ │ -000754f0: 6572 2062 656c 6f6e 6773 2074 6f2e 0a09 er belongs to... │ │ │ -00075500: 0961 7578 3a3a 7365 7373 696f 6e5f 696e .aux::session_in │ │ │ -00075510: 7465 7266 6163 6526 616d 703b 206d 5f73 terface& m_s │ │ │ -00075520: 6573 3b0a 0a09 092f 2f20 7365 7474 696e es;....// settin │ │ │ -00075530: 6773 2074 6861 7420 6170 706c 7920 746f gs that apply to │ │ │ -00075540: 2074 6869 7320 7065 6572 0a09 0961 7578 this peer...aux │ │ │ -00075550: 3a3a 7365 7373 696f 6e5f 7365 7474 696e ::session_settin │ │ │ -00075560: 6773 2063 6f6e 7374 2661 6d70 3b20 6d5f gs const& m_ │ │ │ -00075570: 7365 7474 696e 6773 3b0a 0a09 7072 6f74 settings;...prot │ │ │ -00075580: 6563 7465 643a 0a0a 0909 2f2f 2074 6869 ected:....// thi │ │ │ -00075590: 7320 6973 2074 7275 6520 6966 2074 6869 s is true if thi │ │ │ -000755a0: 7320 636f 6e6e 6563 7469 6f6e 2068 6173 s connection has │ │ │ -000755b0: 2062 6565 6e20 6164 6465 640a 0909 2f2f been added...// │ │ │ -000755c0: 2074 6f20 7468 6520 6c69 7374 206f 6620 to the list of │ │ │ -000755d0: 636f 6e6e 6563 7469 6f6e 7320 7468 6174 connections that │ │ │ -000755e0: 2077 696c 6c20 6265 2063 6c6f 7365 642e will be closed. │ │ │ -000755f0: 0a09 0962 6f6f 6c20 6d5f 6469 7363 6f6e ...bool m_discon │ │ │ -00075600: 6e65 6374 696e 673a 313b 0a0a 0909 2f2f necting:1;....// │ │ │ -00075610: 2074 6869 7320 6973 2074 7275 6520 756e this is true un │ │ │ -00075620: 7469 6c20 7468 6973 2073 6f63 6b65 7420 til this socket │ │ │ -00075630: 6861 7320 6265 636f 6d65 0a09 092f 2f20 has become...// │ │ │ -00075640: 7772 6974 6162 6c65 2066 6f72 2074 6865 writable for the │ │ │ -00075650: 2066 6972 7374 2074 696d 6520 2869 2e65 first time (i.e │ │ │ -00075660: 2e20 7468 650a 0909 2f2f 2063 6f6e 6e65 . the...// conne │ │ │ -00075670: 6374 696f 6e20 636f 6d70 6c65 7465 6429 ction completed) │ │ │ -00075680: 2e20 5768 696c 6520 636f 6e6e 6563 7469 . While connecti │ │ │ -00075690: 6e67 0a09 092f 2f20 7468 6520 7469 6d65 ng...// the time │ │ │ -000756a0: 6f75 7420 7769 6c6c 206e 6f74 2062 6520 out will not be │ │ │ -000756b0: 7472 6967 6765 7265 642e 2054 6869 7320 triggered. This │ │ │ -000756c0: 6973 0a09 092f 2f20 6265 6361 7573 6520 is...// because │ │ │ -000756d0: 7769 6e64 6f77 7320 5850 2053 5032 206d windows XP SP2 m │ │ │ -000756e0: 6179 2064 656c 6179 2063 6f6e 6e65 6374 ay delay connect │ │ │ -000756f0: 696f 6e0a 0909 2f2f 2061 7474 656d 7074 ion...// attempt │ │ │ -00075700: 732c 2077 6869 6368 206d 6561 6e73 2074 s, which means t │ │ │ -00075710: 6861 7420 7468 6520 636f 6e6e 6563 7469 hat the connecti │ │ │ -00075720: 6f6e 0a09 092f 2f20 6d61 7920 6e6f 7420 on...// may not │ │ │ -00075730: 6576 656e 2068 6176 6520 6265 656e 2061 even have been a │ │ │ -00075740: 7474 656d 7074 6564 2077 6865 6e20 7468 ttempted when th │ │ │ -00075750: 650a 0909 2f2f 2074 696d 6520 6f75 7420 e...// time out │ │ │ -00075760: 6973 2072 6561 6368 6564 2e0a 0909 626f is reached....bo │ │ │ -00075770: 6f6c 206d 5f63 6f6e 6e65 6374 696e 673a ol m_connecting: │ │ │ -00075780: 313b 0a0a 0909 2f2f 2074 6869 7320 6973 1;....// this is │ │ │ -00075790: 2073 6574 2074 6f20 7472 7565 2069 6620 set to true if │ │ │ -000757a0: 7468 6520 6c61 7374 2074 696d 6520 7765 the last time we │ │ │ -000757b0: 2074 7269 6564 2074 6f0a 0909 2f2f 2070 tried to...// p │ │ │ -000757c0: 6963 6b20 6120 7069 6563 6520 746f 2064 ick a piece to d │ │ │ -000757d0: 6f77 6e6c 6f61 642c 2077 6520 636f 756c ownload, we coul │ │ │ -000757e0: 6420 6f6e 6c79 2066 696e 640a 0909 2f2f d only find...// │ │ │ -000757f0: 2062 6c6f 636b 7320 7468 6174 2077 6572 blocks that wer │ │ │ -00075800: 6520 616c 7265 6164 7920 7265 7175 6573 e already reques │ │ │ -00075810: 7465 6420 6672 6f6d 206f 7468 6572 0a09 ted from other.. │ │ │ -00075820: 092f 2f20 7065 6572 732e 2049 6e20 7468 .// peers. In th │ │ │ -00075830: 6973 2063 6173 652c 2077 6520 7368 6f75 is case, we shou │ │ │ -00075840: 6c64 206e 6f74 2074 7279 2074 6f20 7069 ld not try to pi │ │ │ -00075850: 636b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f ck.
    │ │ │ -00075880: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -00075890: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -000758c0: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -000758d0: 656e 742f 7065 6572 5f63 6f6e 6e65 6374 ent/peer_connect │ │ │ -000758e0: 696f 6e2e 6870 703a 3130 3236 3c2f 613e ion.hpp:1026 │ │ │ -000758f0: 3c2f 7464 3e3c 7464 3e66 6163 746f 7220 factor │ │ │ -00075900: 7468 6973 206f 7574 2069 6e74 6f20 6974 this out into it │ │ │ -00075910: 7320 6f77 6e20 636c 6173 7320 7769 7468 s own class with │ │ │ -00075920: 2061 2076 6972 7475 616c 2069 6e74 6572 a virtual inter │ │ │ -00075930: 6661 6365 2074 6f72 7265 6e74 2061 6e64 face torrent and │ │ │ -00075940: 2073 6573 7369 6f6e 2073 686f 756c 6420 session should │ │ │ -00075950: 696d 706c 656d 656e 7420 7468 6973 2069 implement this i │ │ │ -00075960: 6e74 6572 6661 6365 3c2f 7464 3e3c 2f74 nterface

    factor thi │ │ │ -000759c0: 7320 6f75 7420 696e 746f 2069 7473 206f s out into its o │ │ │ -000759d0: 776e 2063 6c61 7373 2077 6974 6820 6120 wn class with a │ │ │ -000759e0: 7669 7274 7561 6c20 696e 7465 7266 6163 virtual interfac │ │ │ -000759f0: 650a 746f 7272 656e 7420 616e 6420 7365 e.torrent and se │ │ │ -00075a00: 7373 696f 6e20 7368 6f75 6c64 2069 6d70 ssion should imp │ │ │ -00075a10: 6c65 6d65 6e74 2074 6869 7320 696e 7465 lement this inte │ │ │ -00075a20: 7266 6163 653c 2f68 323e 3c68 343e 2e2e rface

    .. │ │ │ -00075a30: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -00075a40: 656e 742f 7065 6572 5f63 6f6e 6e65 6374 ent/peer_connect │ │ │ -00075a50: 696f 6e2e 6870 703a 3130 3236 3c2f 6834 ion.hpp:1026

    ...//
    │ │ │ -00075aa0: 2074 6865 206c 6f63 616c 2065 6e64 706f   the local endpo
    │ │ │ -00075ab0: 696e 7420 666f 7220 7468 6973 2070 6565  int for this pee
    │ │ │ -00075ac0: 722c 2069 2e65 2e20 6f75 7220 6164 6472  r, i.e. our addr
    │ │ │ -00075ad0: 6573 730a 0909 2f2f 2061 6e64 206f 7572  ess...// and our
    │ │ │ -00075ae0: 2070 6f72 742e 2049 6620 7468 6973 2069   port. If this i
    │ │ │ -00075af0: 7320 7365 7420 666f 7220 6f75 7467 6f69  s set for outgoi
    │ │ │ -00075b00: 6e67 2063 6f6e 6e65 6374 696f 6e73 0a09  ng connections..
    │ │ │ -00075b10: 092f 2f20 6265 666f 7265 2074 6865 2063  .// before the c
    │ │ │ -00075b20: 6f6e 6e65 6374 696f 6e20 636f 6d70 6c65  onnection comple
    │ │ │ -00075b30: 7465 732c 2069 7420 6d65 616e 7320 7765  tes, it means we
    │ │ │ -00075b40: 2077 616e 7420 746f 0a09 092f 2f20 666f   want to...// fo
    │ │ │ -00075b50: 7263 6520 7468 6520 636f 6e6e 6563 7469  rce the connecti
    │ │ │ -00075b60: 6f6e 2074 6f20 6265 2062 6f75 6e64 2074  on to be bound t
    │ │ │ -00075b70: 6f20 7468 6520 7370 6563 6966 6965 6420  o the specified 
    │ │ │ -00075b80: 696e 7465 7266 6163 652e 0a09 092f 2f20  interface....// 
    │ │ │ -00075b90: 6966 2069 7420 656e 6473 2075 7020 6265  if it ends up be
    │ │ │ -00075ba0: 696e 6720 626f 756e 6420 746f 2061 2064  ing bound to a d
    │ │ │ -00075bb0: 6966 6665 7265 6e74 206c 6f63 616c 2049  ifferent local I
    │ │ │ -00075bc0: 502c 2074 6865 2063 6f6e 6e65 6374 696f  P, the connectio
    │ │ │ -00075bd0: 6e0a 0909 2f2f 2069 7320 636c 6f73 6564  n...// is closed
    │ │ │ -00075be0: 2e0a 0909 7463 703a 3a65 6e64 706f 696e  ....tcp::endpoin
    │ │ │ -00075bf0: 7420 6d5f 6c6f 6361 6c3b 0a0a 0909 2f2f  t m_local;....//
    │ │ │ -00075c00: 2072 656d 6f74 6520 7065 6572 2773 2069   remote peer's i
    │ │ │ -00075c10: 640a 0909 7065 6572 5f69 6420 6d5f 7065  d...peer_id m_pe
    │ │ │ -00075c20: 6572 5f69 643b 0a0a 0970 726f 7465 6374  er_id;...protect
    │ │ │ -00075c30: 6564 3a0a 0a09 0974 656d 706c 6174 6520  ed:....template 
    │ │ │ -00075c40: 266c 743b 7479 7065 6e61 6d65 2046 756e  <typename Fun
    │ │ │ -00075c50: 2c20 7479 7065 6e61 6d65 2e2e 2e20 4172  , typename... Ar
    │ │ │ -00075c60: 6773 2667 743b 0a09 0976 6f69 6420 7772  gs>...void wr
    │ │ │ -00075c70: 6170 2846 756e 2066 2c20 4172 6773 2661  ap(Fun f, Args&a
    │ │ │ -00075c80: 6d70 3b26 616d 703b 2e2e 2e20 6129 3b0a  mp;&... a);.
    │ │ │ -00075c90: 0a09 092f 2f20 7374 6174 6973 7469 6373  ...// statistics
    │ │ │ -00075ca0: 2061 626f 7574 2075 706c 6f61 6420 616e   about upload an
    │ │ │ -00075cb0: 6420 646f 776e 6c6f 6164 2073 7065 6564  d download speed
    │ │ │ -00075cc0: 730a 0909 2f2f 2061 6e64 2074 6f74 616c  s...// and total
    │ │ │ -00075cd0: 2061 6d6f 756e 7420 6f66 2075 706c 6f61   amount of uploa
    │ │ │ -00075ce0: 6473 2061 6e64 2064 6f77 6e6c 6f61 6473  ds and downloads
    │ │ │ -00075cf0: 2066 6f72 0a09 092f 2f20 7468 6973 2070   for...// this p
    │ │ │ -00075d00: 6565 720a 3c64 6976 2073 7479 6c65 3d22  eer.
    ..stat m_stati │ │ │ -00075d40: 7374 6963 733b 0a3c 2f64 6976 3e0a 0909 stics;.
    ... │ │ │ -00075d50: 2f2f 2074 6865 206e 756d 6265 7220 6f66 // the number of │ │ │ -00075d60: 206f 7574 7374 616e 6469 6e67 2062 7974 outstanding byt │ │ │ -00075d70: 6573 2065 7870 6563 7465 640a 0909 2f2f es expected...// │ │ │ -00075d80: 2074 6f20 6265 2072 6563 6569 7665 6420 to be received │ │ │ -00075d90: 6279 2065 7874 656e 7369 6f6e 730a 0909 by extensions... │ │ │ -00075da0: 696e 7420 6d5f 6578 7465 6e73 696f 6e5f int m_extension_ │ │ │ -00075db0: 6f75 7473 7461 6e64 696e 675f 6279 7465 outstanding_byte │ │ │ -00075dc0: 7320 3d20 303b 0a0a 0909 2f2f 2074 6865 s = 0;....// the │ │ │ -00075dd0: 206e 756d 6265 7220 6f66 2074 696d 6520 number of time │ │ │ -00075de0: 6372 6974 6963 616c 2072 6571 7565 7374 critical request │ │ │ -00075df0: 730a 0909 2f2f 2071 7565 7565 6420 7570 s...// queued up │ │ │ -00075e00: 2069 6e20 7468 6520 6d5f 7265 7175 6573 in the m_reques │ │ │ -00075e10: 745f 7175 6575 6520 7468 6174 0a09 092f t_queue that.../ │ │ │ -00075e20: 2f20 736f 6f6e 2077 696c 6c20 6265 2063 / soon will be c │ │ │ -00075e30: 6f6d 6d69 7474 6564 2074 6f20 7468 6520 ommitted to the │ │ │ -00075e40: 646f 776e 6c6f 6164 0a09 092f 2f20 7175 download...// qu │ │ │ -00075e50: 6575 652e 2054 6869 7320 6973 2069 6e63 eue. This is inc │ │ │ -00075e60: 6c75 6465 6420 696e 2064 6f77 6e6c 6f61 luded in downloa │ │ │ -00075e70: 645f 7175 6575 655f 7469 6d65 2829 0a09 d_queue_time().. │ │ │ -00075e80: 092f 2f20 736f 2074 6861 7420 6974 2063 .// so that it c │ │ │ -00075e90: 616e 2062 6520 7573 6564 2077 6869 6c65 an be used while │ │ │ -00075ea0: 2061 6464 696e 6720 6d6f 7265 0a09 092f adding more.../ │ │ │ -00075eb0: 2f20 7265 7175 6573 7473 2061 6e64 2074 / requests and t │ │ │ -00075ec0: 616b 6520 7468 6520 7072 6576 696f 7573 ake the previous │ │ │ -00075ed0: 2072 6571 7565 7374 730a 0909 2f2f 2069 requests...// i │ │ │ -00075ee0: 6e74 6f20 6163 636f 756e 7420 7769 7468 nto account with │ │ │ -00075ef0: 6f75 7420 7375 626d 6974 7469 6e67 2069 out submitting i │ │ │ -00075f00: 7420 616c 6c0a 0909 2f2f 2069 6d6d 6564 t all...// immed │ │ │ -00075f10: 6961 7465 6c79 0a09 0973 7464 3a3a 7569 iately...std::ui │ │ │ -00075f20: 6e74 3136 5f74 206d 5f71 7565 7565 645f nt16_t m_queued_ │ │ │ -00075f30: 7469 6d65 5f63 7269 7469 6361 6c20 3d20 time_critical = │ │ │ -00075f40: 303b 0a0a 0909 2f2f 2074 6865 206e 756d 0;....// the num │ │ │ -00075f50: 6265 7220 6f66 2062 7974 6573 2077 6520 ber of bytes we │ │ │ -00075f60: 6172 6520 6375 7272 656e 746c 7920 7265 are currently re │ │ │ -00075f70: 6164 696e 670a 0909 2f2f 2066 726f 6d20 ading...// from │ │ │ -00075f80: 6469 736b 2c20 7468 6174 2077 696c 6c20 disk, that will │ │ │ -00075f90: 6265 2061 6464 6564 2074 6f20 7468 6520 be added to the │ │ │ -00075fa0: 7365 6e64 0a09 092f 2f20 6275 6666 6572 send...// buffer │ │ │ -00075fb0: 2061 7320 736f 6f6e 2061 7320 7468 6579 as soon as they │ │ │ -00075fc0: 2063 6f6d 706c 6574 650a 0909 696e 7420 complete...int │ │ │ -00075fd0: 6d5f 7265 6164 696e 675f 6279 7465 7320 m_reading_bytes │ │ │ -00075fe0: 3d20 303b 0a0a 0909 2f2f 206f 7074 696f = 0;....// optio │ │ │ -00075ff0: 6e73 2075 7365 6420 666f 7220 7468 6520 ns used for the │ │ │ -00076000: 7069 6563 6520 7069 636b 6572 2e20 5468 piece picker. Th │ │ │ -00076010: 6573 6520 666c 6167 7320 7769 6c6c 0a09 ese flags will.. │ │ │ -00076020: 092f 2f20 6265 2061 7567 6d65 6e74 6564 .// be augmented │ │ │ -00076030: 2077 6974 6820 666c 6167 7320 636f 6e74 with flags cont │ │ │ -00076040: 726f 6c6c 6564 2062 7920 6f74 6865 7220 rolled by other │ │ │ -00076050: 7365 7474 696e 6773 0a09 092f 2f20 6c69 settings...// li │ │ │ -00076060: 6b65 2073 6571 7565 6e74 6961 6c20 646f ke sequential do │ │ │ -00076070: 776e 6c6f 6164 2065 7463 2e20 5468 6573 wnload etc. Thes │ │ │ -00076080: 6520 6172 6520 6865 7265 2074 6f0a 0909 e are here to... │ │ │ -00076090: 2f2f 206c 6574 2070 6c75 6769 6e73 2063 // let plugins c │ │ │ -000760a0: 6f6e 7472 6f6c 2066 6c61 6773 2074 6861 ontrol flags tha │ │ │ -000760b0: 7420 7368 6f75 6c64 2061 6c77 6179 7320 t should always │ │ │ -000760c0: 6265 2073 6574 0a09 0970 6963 6b65 725f be set...picker_ │ │ │ -000760d0: 6f70 7469 6f6e 735f 7420 6d5f 7069 636b options_t m_pick │ │ │ -000760e0: 6572 5f6f 7074 696f 6e73 7b7d 3b0a 0a09 er_options{};... │ │ │ -000760f0: 092f 2f20 7468 6520 6e75 6d62 6572 206f .// the number o │ │ │ -00076100: 6620 696e 7661 6c69 6420 7069 6563 652d f invalid piece- │ │ │ -00076110: 7265 7175 6573 7473 0a09 092f 2f20 7765 requests...// we │ │ │ -00076120: 2068 6176 6520 676f 7420 6672 6f6d 2074 have got from t │ │ │ -00076130: 6869 7320 7065 6572 2e20 4966 2074 6865 his peer. If the │ │ │ -00076140: 2072 6571 7565 7374 0a09 092f 2f20 7175 request...// qu │ │ │ -00076150: 6575 6520 6765 7473 2065 6d70 7479 2c20 eue gets empty, │ │ │ -00076160: 616e 6420 7468 6572 6520 6861 7665 2062 and there have b │ │ │ -00076170: 6565 6e0a 0909 2f2f 2069 6e76 616c 6964 een...// invalid │ │ │ -00076180: 2072 6571 7565 7374 732c 2077 6520 6361 requests, we ca │ │ │ -00076190: 6e20 6173 7375 6d65 2074 6865 0a3c 2f70 n assume the.

    re │ │ │ -000761d0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../inclu │ │ │ -00076210: 6465 2f6c 6962 746f 7272 656e 742f 6964 de/libtorrent/id │ │ │ -00076220: 656e 7469 6679 5f63 6c69 656e 742e 6870 entify_client.hp │ │ │ -00076230: 703a 3438 3c2f 613e 3c2f 7464 3e3c 7464 p:48hide this decla │ │ │ -00076250: 7261 7469 6f6e 2077 6865 6e20 6465 7072 ration when depr │ │ │ -00076260: 6563 6174 6564 2066 756e 6374 696f 6e73 ecated functions │ │ │ -00076270: 2061 7265 2064 6973 6162 6c65 642c 2061 are disabled, a │ │ │ -00076280: 6e64 2072 656d 6f76 6520 6974 7320 696e nd remove its in │ │ │ -00076290: 7465 726e 616c 2075 7365 3c2f 7464 3e3c ternal use< │ │ │ -000762a0: 2f74 723e 3c74 7220 6964 3d22 3236 3722 /tr>

    hide thi │ │ │ -000762f0: 7320 6465 636c 6172 6174 696f 6e20 7768 s declaration wh │ │ │ -00076300: 656e 2064 6570 7265 6361 7465 6420 6675 en deprecated fu │ │ │ -00076310: 6e63 7469 6f6e 7320 6172 6520 6469 7361 nctions are disa │ │ │ -00076320: 626c 6564 2c20 616e 640a 7265 6d6f 7665 bled, and.remove │ │ │ -00076330: 2069 7473 2069 6e74 6572 6e61 6c20 7573 its internal us │ │ │ -00076340: 653c 2f68 323e 3c68 343e 2e2e 2f69 6e63 e

    ../inc │ │ │ -00076350: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -00076360: 6964 656e 7469 6679 5f63 6c69 656e 742e identify_client. │ │ │ -00076370: 6870 703a 3438 3c2f 6834 3e3c 7072 6520 hpp:48

    CONTRACT, S
    │ │ │ -000763c0: 5452 4943 5420 4c49 4142 494c 4954 592c  TRICT LIABILITY,
    │ │ │ -000763d0: 204f 5220 544f 5254 2028 494e 434c 5544   OR TORT (INCLUD
    │ │ │ -000763e0: 494e 4720 4e45 474c 4947 454e 4345 204f  ING NEGLIGENCE O
    │ │ │ -000763f0: 5220 4f54 4845 5257 4953 4529 0a41 5249  R OTHERWISE).ARI
    │ │ │ -00076400: 5349 4e47 2049 4e20 414e 5920 5741 5920  SING IN ANY WAY 
    │ │ │ -00076410: 4f55 5420 4f46 2054 4845 2055 5345 204f  OUT OF THE USE O
    │ │ │ -00076420: 4620 5448 4953 2053 4f46 5457 4152 452c  F THIS SOFTWARE,
    │ │ │ -00076430: 2045 5645 4e20 4946 2041 4456 4953 4544   EVEN IF ADVISED
    │ │ │ -00076440: 204f 4620 5448 450a 504f 5353 4942 494c   OF THE.POSSIBIL
    │ │ │ -00076450: 4954 5920 4f46 2053 5543 4820 4441 4d41  ITY OF SUCH DAMA
    │ │ │ -00076460: 4745 2e0a 0a2a 2f0a 0a23 6966 6e64 6566  GE...*/..#ifndef
    │ │ │ -00076470: 2054 4f52 5245 4e54 5f49 4445 4e54 4946   TORRENT_IDENTIF
    │ │ │ -00076480: 595f 434c 4945 4e54 5f48 5050 5f49 4e43  Y_CLIENT_HPP_INC
    │ │ │ -00076490: 4c55 4445 440a 2364 6566 696e 6520 544f  LUDED.#define TO
    │ │ │ -000764a0: 5252 454e 545f 4944 454e 5449 4659 5f43  RRENT_IDENTIFY_C
    │ │ │ -000764b0: 4c49 454e 545f 4850 505f 494e 434c 5544  LIENT_HPP_INCLUD
    │ │ │ -000764c0: 4544 0a0a 2369 6e63 6c75 6465 2022 6c69  ED..#include "li
    │ │ │ -000764d0: 6274 6f72 7265 6e74 2f63 6f6e 6669 672e  btorrent/config.
    │ │ │ -000764e0: 6870 7022 0a0a 2369 6620 544f 5252 454e  hpp"..#if TORREN
    │ │ │ -000764f0: 545f 4142 495f 5645 5253 494f 4e20 3d3d  T_ABI_VERSION ==
    │ │ │ -00076500: 2031 0a23 696e 636c 7564 6520 226c 6962   1.#include "lib
    │ │ │ -00076510: 746f 7272 656e 742f 6175 785f 2f64 6973  torrent/aux_/dis
    │ │ │ -00076520: 6162 6c65 5f77 6172 6e69 6e67 735f 7075  able_warnings_pu
    │ │ │ -00076530: 7368 2e68 7070 220a 2369 6e63 6c75 6465  sh.hpp".#include
    │ │ │ -00076540: 2026 6c74 3b62 6f6f 7374 2f6f 7074 696f   <boost/optio
    │ │ │ -00076550: 6e61 6c2e 6870 7026 6774 3b0a 2369 6e63  nal.hpp>.#inc
    │ │ │ -00076560: 6c75 6465 2022 6c69 6274 6f72 7265 6e74  lude "libtorrent
    │ │ │ -00076570: 2f61 7578 5f2f 6469 7361 626c 655f 7761  /aux_/disable_wa
    │ │ │ -00076580: 726e 696e 6773 5f70 6f70 2e68 7070 220a  rnings_pop.hpp".
    │ │ │ -00076590: 2365 6e64 6966 0a0a 2369 6e63 6c75 6465  #endif..#include
    │ │ │ -000765a0: 2022 6c69 6274 6f72 7265 6e74 2f70 6565   "libtorrent/pee
    │ │ │ -000765b0: 725f 6964 2e68 7070 220a 2369 6e63 6c75  r_id.hpp".#inclu
    │ │ │ -000765c0: 6465 2022 6c69 6274 6f72 7265 6e74 2f66  de "libtorrent/f
    │ │ │ -000765d0: 696e 6765 7270 7269 6e74 2e68 7070 220a  ingerprint.hpp".
    │ │ │ -000765e0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    n │ │ │ -00076610: 616d 6573 7061 6365 206c 6962 746f 7272 amespace libtorr │ │ │ -00076620: 656e 7420 7b0a 3c2f 6469 763e 0a6e 616d ent {.
    .nam │ │ │ -00076630: 6573 7061 6365 2061 7578 207b 0a0a 0954 espace aux {...T │ │ │ -00076640: 4f52 5245 4e54 5f45 5854 5241 5f45 5850 ORRENT_EXTRA_EXP │ │ │ -00076650: 4f52 540a 0973 7464 3a3a 7374 7269 6e67 ORT..std::string │ │ │ -00076660: 2069 6465 6e74 6966 795f 636c 6965 6e74 identify_client │ │ │ -00076670: 5f69 6d70 6c28 636f 6e73 7420 7065 6572 _impl(const peer │ │ │ -00076680: 5f69 6426 616d 703b 2070 293b 0a0a 7d0a _id& p);..}. │ │ │ -00076690: 0a09 2f2f 2074 6865 7365 2066 756e 6374 ..// these funct │ │ │ -000766a0: 696f 6e73 2064 6f6e 2774 2072 6561 6c6c ions don't reall │ │ │ -000766b0: 7920 6e65 6564 2074 6f20 6265 2070 7562 y need to be pub │ │ │ -000766c0: 6c69 632e 2054 6869 7320 6d65 6368 616e lic. This mechan │ │ │ -000766d0: 6973 6d20 6f66 0a09 2f2f 2061 6476 6572 ism of..// adver │ │ │ -000766e0: 7469 7369 6e67 2063 6c69 656e 7420 736f tising client so │ │ │ -000766f0: 6674 7761 7265 2061 6e64 2076 6572 7369 ftware and versi │ │ │ -00076700: 6f6e 2069 7320 616c 736f 206f 7574 2d64 on is also out-d │ │ │ -00076710: 6174 6564 2e0a 0a09 2f2f 2054 6869 7320 ated....// This │ │ │ -00076720: 6675 6e63 7469 6f6e 2063 616e 2063 616e function can can │ │ │ -00076730: 2062 6520 7573 6564 2074 6f20 6578 7472 be used to extr │ │ │ -00076740: 6163 7420 6120 7374 7269 6e67 2064 6573 act a string des │ │ │ -00076750: 6372 6962 696e 6720 6120 636c 6965 6e74 cribing a client │ │ │ -00076760: 0a09 2f2f 2076 6572 7369 6f6e 2066 726f ..// version fro │ │ │ -00076770: 6d20 6974 7320 7065 6572 2d69 642e 2049 m its peer-id. I │ │ │ -00076780: 7420 7769 6c6c 2072 6563 6f67 6e69 7a65 t will recognize │ │ │ -00076790: 206d 6f73 7420 636c 6965 6e74 7320 7468 most clients th │ │ │ -000767a0: 6174 2068 6176 6520 7468 6973 0a09 2f2f at have this..// │ │ │ -000767b0: 206b 696e 6420 6f66 2069 6465 6e74 6966 kind of identif │ │ │ -000767c0: 6963 6174 696f 6e20 696e 2074 6865 2070 ication in the p │ │ │ -000767d0: 6565 722d 6964 2e0a 0954 4f52 5245 4e54 eer-id...TORRENT │ │ │ -000767e0: 5f44 4550 5245 4341 5445 445f 4558 504f _DEPRECATED_EXPO │ │ │ -000767f0: 5254 0a09 7374 643a 3a73 7472 696e 6720 RT..std::string │ │ │ -00076800: 6964 656e 7469 6679 5f63 6c69 656e 7428 identify_client( │ │ │ -00076810: 636f 6e73 7420 7065 6572 5f69 6426 616d const peer_id&am │ │ │ -00076820: 703b 2070 293b 0a0a 2369 6620 544f 5252 p; p);..#if TORR │ │ │ -00076830: 454e 545f 4142 495f 5645 5253 494f 4e20 ENT_ABI_VERSION │ │ │ -00076840: 3d3d 2031 0a0a 2369 6e63 6c75 6465 2022 == 1..#include " │ │ │ -00076850: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -00076860: 6469 7361 626c 655f 6465 7072 6563 6174 disable_deprecat │ │ │ -00076870: 696f 6e5f 7761 726e 696e 6773 5f70 7573 ion_warnings_pus │ │ │ -00076880: 682e 6870 7022 0a0a 092f 2f20 5265 7475 h.hpp"...// Retu │ │ │ -00076890: 726e 7320 616e 206f 7074 696f 6e61 6c20 rns an optional │ │ │ -000768a0: 6669 6e67 6572 7072 696e 7420 6966 2061 fingerprint if a │ │ │ -000768b0: 6e79 2063 616e 2062 6520 6964 656e 7469 ny can be identi │ │ │ -000768c0: 6669 6564 2066 726f 6d20 7468 6520 7065 fied from the pe │ │ │ -000768d0: 6572 0a09 2f2f 2069 642e 2054 6869 7320 er..// id. This │ │ │ -000768e0: 6361 6e20 6265 2075 7365 6420 746f 2061 can be used to a │ │ │ -000768f0: 7574 6f6d 6174 6520 7468 6520 6964 656e utomate the iden │ │ │ -00076900: 7469 6669 6361 7469 6f6e 206f 6620 636c tification of cl │ │ │ -00076910: 6965 6e74 732e 2049 7420 7769 6c6c 0a09 ients. It will.. │ │ │ -00076920: 2f2f 206e 6f74 2062 6520 6162 6c65 2074 // not be able t │ │ │ -00076930: 6f20 6964 656e 7469 6679 2070 6565 7273 o identify peers │ │ │ -00076940: 2077 6974 6820 6e6f 6e2d 2073 7461 6e64 with non- stand │ │ │ -00076950: 6172 6420 656e 636f 6469 6e67 732e 204f ard encodings. O │ │ │ -00076960: 6e6c 7920 417a 7572 6575 730a 092f 2f20 nly Azureus..// │ │ │ -00076970: 7374 796c 652c 2053 6861 646f 7727 7320 style, Shadow's │ │ │ -00076980: 7374 796c 6520 616e 6420 4d61 696e 6c69 style and Mainli │ │ │ -00076990: 6e65 2073 7479 6c65 2e0a 0954 4f52 5245 ne style...TORRE │ │ │ -000769a0: 4e54 5f44 4550 5245 4341 5445 445f 4558 NT_DEPRECATED_EX │ │ │ -000769b0: 504f 5254 0a09 626f 6f73 743a 3a6f 7074 PORT..boost::opt │ │ │ -000769c0: 696f 6e61 6c26 6c74 3b66 696e 6765 7270 ional<fingerp │ │ │ -000769d0: 7269 6e74 2667 743b 0a09 0963 6c69 656e rint>...clien │ │ │ -000769e0: 745f 6669 6e67 6572 7072 696e 7428 7065 t_fingerprint(pe │ │ │ -000769f0: 6572 5f69 6420 636f 6e73 7426 616d 703b er_id const& │ │ │ -00076a00: 2070 293b 0a0a 2369 6e63 6c75 6465 2022 p);..#include " │ │ │ -00076a10: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -00076a20: 6469 7361 626c 655f 7761 726e 696e 6773 disable_warnings │ │ │ -00076a30: 5f70 6f70 2e68 7070 220a 3c2f 7072 653e _pop.hpp".
    │ │ │ -00076a40: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -00076a70: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -00076a80: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../include/ │ │ │ -00076ab0: 6c69 6274 6f72 7265 6e74 2f69 3270 5f73 libtorrent/i2p_s │ │ │ -00076ac0: 7472 6561 6d2e 6870 703a 3538 353c 2f61 tream.hpp:585make t │ │ │ -00076ae0: 6869 7320 6120 7374 7269 6e67 5f76 6965 his a string_vie │ │ │ -00076af0: 773c 2f74 643e 3c2f 7472 3e3c 7472 2069 w

    m │ │ │ -00076b40: 616b 6520 7468 6973 2061 2073 7472 696e ake this a strin │ │ │ -00076b50: 675f 7669 6577 3c2f 6832 3e3c 6834 3e2e g_view

    . │ │ │ -00076b60: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -00076b70: 7265 6e74 2f69 3270 5f73 7472 6561 6d2e rent/i2p_stream. │ │ │ -00076b80: 6870 703a 3538 353c 2f68 343e 3c70 7265 hpp:585

    ...char tm
    │ │ │ -00076bd0: 705b 3230 5d3b 0a09 0961 7578 3a3a 7261  p[20];...aux::ra
    │ │ │ -00076be0: 6e64 6f6d 5f62 7974 6573 2874 6d70 293b  ndom_bytes(tmp);
    │ │ │ -00076bf0: 0a09 096d 5f73 6573 7369 6f6e 5f69 642e  ...m_session_id.
    │ │ │ -00076c00: 7265 7369 7a65 2873 697a 656f 6628 746d  resize(sizeof(tm
    │ │ │ -00076c10: 7029 2a32 293b 0a09 0961 7578 3a3a 746f  p)*2);...aux::to
    │ │ │ -00076c20: 5f68 6578 2874 6d70 2c20 2661 6d70 3b6d  _hex(tmp, &m
    │ │ │ -00076c30: 5f73 6573 7369 6f6e 5f69 645b 305d 293b  _session_id[0]);
    │ │ │ -00076c40: 0a0a 0909 6d5f 7361 6d5f 736f 636b 6574  ....m_sam_socket
    │ │ │ -00076c50: 203d 2073 7464 3a3a 6d61 6b65 5f73 6861   = std::make_sha
    │ │ │ -00076c60: 7265 6426 6c74 3b69 3270 5f73 7472 6561  red<i2p_strea
    │ │ │ -00076c70: 6d26 6774 3b28 6d5f 696f 5f73 6572 7669  m>(m_io_servi
    │ │ │ -00076c80: 6365 293b 0a09 096d 5f73 616d 5f73 6f63  ce);...m_sam_soc
    │ │ │ -00076c90: 6b65 742d 2667 743b 7365 745f 7072 6f78  ket->set_prox
    │ │ │ -00076ca0: 7928 6d5f 686f 7374 6e61 6d65 2c20 6d5f  y(m_hostname, m_
    │ │ │ -00076cb0: 706f 7274 293b 0a09 096d 5f73 616d 5f73  port);...m_sam_s
    │ │ │ -00076cc0: 6f63 6b65 742d 2667 743b 7365 745f 636f  ocket->set_co
    │ │ │ -00076cd0: 6d6d 616e 6428 6932 705f 7374 7265 616d  mmand(i2p_stream
    │ │ │ -00076ce0: 3a3a 636d 645f 6372 6561 7465 5f73 6573  ::cmd_create_ses
    │ │ │ -00076cf0: 7369 6f6e 293b 0a09 096d 5f73 616d 5f73  sion);...m_sam_s
    │ │ │ -00076d00: 6f63 6b65 742d 2667 743b 7365 745f 7365  ocket->set_se
    │ │ │ -00076d10: 7373 696f 6e5f 6964 286d 5f73 6573 7369  ssion_id(m_sessi
    │ │ │ -00076d20: 6f6e 5f69 642e 635f 7374 7228 2929 3b0a  on_id.c_str());.
    │ │ │ -00076d30: 0909 6d5f 7361 6d5f 736f 636b 6574 2d26  ..m_sam_socket-&
    │ │ │ -00076d40: 6774 3b73 6574 5f73 6573 7369 6f6e 5f6f  gt;set_session_o
    │ │ │ -00076d50: 7074 696f 6e73 2873 6573 7369 6f6e 5f6f  ptions(session_o
    │ │ │ -00076d60: 7074 696f 6e73 293b 0a0a 0909 4144 445f  ptions);....ADD_
    │ │ │ -00076d70: 4f55 5453 5441 4e44 494e 475f 4153 594e  OUTSTANDING_ASYN
    │ │ │ -00076d80: 4328 2269 3270 5f73 7472 6561 6d3a 3a6f  C("i2p_stream::o
    │ │ │ -00076d90: 6e5f 7361 6d5f 636f 6e6e 6563 7422 293b  n_sam_connect");
    │ │ │ -00076da0: 0a09 096d 5f73 616d 5f73 6f63 6b65 742d  ...m_sam_socket-
    │ │ │ -00076db0: 2667 743b 6173 796e 635f 636f 6e6e 6563  >async_connec
    │ │ │ -00076dc0: 7428 7463 703a 3a65 6e64 706f 696e 7428  t(tcp::endpoint(
    │ │ │ -00076dd0: 292c 2077 7261 705f 616c 6c6f 6361 746f  ), wrap_allocato
    │ │ │ -00076de0: 7228 0a09 0909 5b74 6869 732c 733d 6d5f  r(....[this,s=m_
    │ │ │ -00076df0: 7361 6d5f 736f 636b 6574 5d28 6572 726f  sam_socket](erro
    │ │ │ -00076e00: 725f 636f 6465 2063 6f6e 7374 2661 6d70  r_code const&
    │ │ │ -00076e10: 3b20 6563 2c20 4861 6e64 6c65 7220 686e  ; ec, Handler hn
    │ │ │ -00076e20: 2920 7b0a 0909 0909 6f6e 5f73 616d 5f63  ) {.....on_sam_c
    │ │ │ -00076e30: 6f6e 6e65 6374 2865 632c 2073 2c20 7374  onnect(ec, s, st
    │ │ │ -00076e40: 643a 3a6d 6f76 6528 686e 2929 3b0a 0909  d::move(hn));...
    │ │ │ -00076e50: 097d 2c20 7374 643a 3a6d 6f76 6528 6861  .}, std::move(ha
    │ │ │ -00076e60: 6e64 6c65 7229 2929 3b0a 097d 0a09 766f  ndler)));..}..vo
    │ │ │ -00076e70: 6964 2063 6c6f 7365 2865 7272 6f72 5f63  id close(error_c
    │ │ │ -00076e80: 6f64 6526 616d 703b 293b 0a0a 3c64 6976  ode&);..
    .char │ │ │ -00076ec0: 636f 6e73 742a 2073 6573 7369 6f6e 5f69 const* session_i │ │ │ -00076ed0: 6428 2920 636f 6e73 7420 7b20 7265 7475 d() const { retu │ │ │ -00076ee0: 726e 206d 5f73 6573 7369 6f6e 5f69 642e rn m_session_id. │ │ │ -00076ef0: 635f 7374 7228 293b 207d 0a3c 2f64 6976 c_str(); }.
    .std::string co │ │ │ -00076f10: 6e73 7426 616d 703b 206c 6f63 616c 5f65 nst& local_e │ │ │ -00076f20: 6e64 706f 696e 7428 2920 636f 6e73 7420 ndpoint() const │ │ │ -00076f30: 7b20 7265 7475 726e 206d 5f69 3270 5f6c { return m_i2p_l │ │ │ -00076f40: 6f63 616c 5f65 6e64 706f 696e 743b 207d ocal_endpoint; } │ │ │ -00076f50: 0a0a 0974 656d 706c 6174 6520 266c 743b ...template < │ │ │ -00076f60: 7479 7065 6e61 6d65 2048 616e 646c 6572 typename Handler │ │ │ -00076f70: 2667 743b 0a09 766f 6964 2061 7379 6e63 >..void async │ │ │ -00076f80: 5f6e 616d 655f 6c6f 6f6b 7570 2863 6861 _name_lookup(cha │ │ │ -00076f90: 7220 636f 6e73 742a 206e 616d 652c 2048 r const* name, H │ │ │ -00076fa0: 616e 646c 6572 2068 616e 646c 6572 290a andler handler). │ │ │ -00076fb0: 097b 0a09 0969 6620 286d 5f73 7461 7465 .{...if (m_state │ │ │ -00076fc0: 203d 3d20 7361 6d5f 6964 6c65 2026 616d == sam_idle &am │ │ │ -00076fd0: 703b 2661 6d70 3b20 6d5f 6e61 6d65 5f6c p;& m_name_l │ │ │ -00076fe0: 6f6f 6b75 702e 656d 7074 7928 2920 2661 ookup.empty() &a │ │ │ -00076ff0: 6d70 3b26 616d 703b 2069 735f 6f70 656e mp;& is_open │ │ │ -00077000: 2829 290a 0909 0964 6f5f 6e61 6d65 5f6c ())....do_name_l │ │ │ -00077010: 6f6f 6b75 7028 6e61 6d65 2c20 7374 643a ookup(name, std: │ │ │ -00077020: 3a6d 6f76 6528 6861 6e64 6c65 7229 293b :move(handler)); │ │ │ -00077030: 0a09 0965 6c73 650a 0909 096d 5f6e 616d ...else....m_nam │ │ │ -00077040: 655f 6c6f 6f6b 7570 2e65 6d70 6c61 6365 e_lookup.emplace │ │ │ -00077050: 5f62 6163 6b28 7374 643a 3a73 7472 696e _back(std::strin │ │ │ -00077060: 6728 6e61 6d65 290a 0909 0909 2c20 7374 g(name)....., st │ │ │ -00077070: 643a 3a6d 6f76 6528 6861 6e64 6c65 7229 d::move(handler) │ │ │ -00077080: 293b 0a09 7d0a 0a70 7269 7661 7465 3a0a );..}..private:. │ │ │ -00077090: 0a09 7465 6d70 6c61 7465 2026 6c74 3b74 ..template <t │ │ │ -000770a0: 7970 656e 616d 6520 4861 6e64 6c65 7226 ypename Handler& │ │ │ -000770b0: 6774 3b0a 0976 6f69 6420 6f6e 5f73 616d gt;..void on_sam │ │ │ -000770c0: 5f63 6f6e 6e65 6374 2865 7272 6f72 5f63 _connect(error_c │ │ │ -000770d0: 6f64 6520 636f 6e73 7426 616d 703b 2065 ode const& e │ │ │ -000770e0: 632c 2073 7464 3a3a 7368 6172 6564 5f70 c, std::shared_p │ │ │ -000770f0: 7472 266c 743b 6932 705f 7374 7265 616d tr<i2p_stream │ │ │ -00077100: 2667 743b 2c20 4861 6e64 6c65 7220 6829 >, Handler h) │ │ │ -00077110: 0a09 7b0a 0909 434f 4d50 4c45 5445 5f41 ..{...COMPLETE_A │ │ │ -00077120: 5359 4e43 2822 6932 705f 7374 7265 616d SYNC("i2p_stream │ │ │ -00077130: 3a3a 6f6e 5f73 616d 5f63 6f6e 6e65 6374 ::on_sam_connect │ │ │ -00077140: 2229 3b0a 0909 6d5f 7374 6174 6520 3d20 ");...m_state = │ │ │ -00077150: 7361 6d5f 6964 6c65 3b0a 0a09 0969 6620 sam_idle;....if │ │ │ -00077160: 2865 6329 0a09 097b 0a09 0909 6828 6563 (ec)...{....h(ec │ │ │ -00077170: 293b 0a09 0909 7265 7475 726e 3b0a 0909 );....return;... │ │ │ -00077180: 7d0a 0a09 0964 6f5f 6e61 6d65 5f6c 6f6f }....do_name_loo │ │ │ -00077190: 6b75 7028 224d 4522 2c20 7772 6170 5f61 kup("ME", wrap_a │ │ │ -000771a0: 6c6c 6f63 6174 6f72 280a 0909 095b 7468 llocator(....[th │ │ │ -000771b0: 6973 5d28 6572 726f 725f 636f 6465 2063 is](error_code c │ │ │ -000771c0: 6f6e 7374 2661 6d70 3b20 652c 2063 6861 onst& e, cha │ │ │ -000771d0: 7220 636f 6e73 742a 2064 7374 2c20 4861 r const* dst, Ha │ │ │ -000771e0: 6e64 6c65 7220 686e 2920 7b0a 0909 0909 ndler hn) {..... │ │ │ -000771f0: 7365 745f 6c6f 6361 6c5f 656e 6470 6f69 set_local_endpoi │ │ │ -00077200: 6e74 2865 2c20 6473 742c 2073 7464 3a3a nt(e, dst, std:: │ │ │ -00077210: 6d6f 7665 2868 6e29 293b 0a09 0909 7d2c move(hn));....}, │ │ │ -00077220: 2073 7464 3a3a 6d6f 7665 2868 2929 293b std::move(h))); │ │ │ -00077230: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -00077270: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../i │ │ │ -000772a0: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -000772b0: 742f 6861 7368 5f70 6963 6b65 722e 6870 t/hash_picker.hp │ │ │ -000772c0: 703a 3135 353c 2f61 3e3c 2f74 643e 3c74 p:155support batche │ │ │ -000772e0: 6420 6164 6469 6e67 206f 6620 626c 6f63 d adding of bloc │ │ │ -000772f0: 6b20 6861 7368 6573 2066 6f72 2072 6564 k hashes for red │ │ │ -00077300: 7563 6564 206f 7665 7268 6561 643f 3c2f uced overhead?

    supp │ │ │ -00077360: 6f72 7420 6261 7463 6865 6420 6164 6469 ort batched addi │ │ │ -00077370: 6e67 206f 6620 626c 6f63 6b20 6861 7368 ng of block hash │ │ │ -00077380: 6573 2066 6f72 2072 6564 7563 6564 206f es for reduced o │ │ │ -00077390: 7665 7268 6561 643f 3c2f 6832 3e3c 6834 verhead?

    ../include/libt │ │ │ -000773b0: 6f72 7265 6e74 2f68 6173 685f 7069 636b orrent/hash_pick │ │ │ -000773c0: 6572 2e68 7070 3a31 3535 3c2f 6834 3e3c er.hpp:155

    < │ │ │ -000773d0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -000773e0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -000773f0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00077400: 7820 2364 6464 3b22 3e09 092f 2f20 7468 x #ddd;">..// th │ │ │ -00077410: 6520 6e75 6d62 6572 206f 6620 6861 7368 e number of hash │ │ │ -00077420: 6573 2069 6e20 7468 6520 7261 6e67 650a es in the range. │ │ │ -00077430: 0909 696e 7420 636f 756e 7420 3d20 303b ..int count = 0; │ │ │ -00077440: 0a09 0969 6e74 2070 726f 6f66 5f6c 6179 ...int proof_lay │ │ │ -00077450: 6572 7320 3d20 303b 0a09 7d3b 0a0a 092f ers = 0;..};.../ │ │ │ -00077460: 2f20 7661 6c69 6461 7465 7320 7468 6520 / validates the │ │ │ -00077470: 6861 7368 5f72 6571 7565 7374 2c20 746f hash_request, to │ │ │ -00077480: 2065 6e73 7572 6520 6974 7320 696e 7661 ensure its inva │ │ │ -00077490: 7269 616e 7420 6173 2077 656c 6c20 6173 riant as well as │ │ │ -000774a0: 206d 6174 6368 696e 670a 092f 2f20 7468 matching..// th │ │ │ -000774b0: 6520 746f 7272 656e 7427 7320 6669 6c65 e torrent's file │ │ │ -000774c0: 5f73 746f 7261 6765 2061 6e64 2074 6865 _storage and the │ │ │ -000774d0: 206e 756d 6265 7220 6f66 2068 6173 6865 number of hashe │ │ │ -000774e0: 7320 6163 636f 6d70 616e 7969 6e67 2074 s accompanying t │ │ │ -000774f0: 6865 0a09 2f2f 2072 6571 7565 7374 0a09 he..// request.. │ │ │ -00077500: 544f 5252 454e 545f 4558 5452 415f 4558 TORRENT_EXTRA_EX │ │ │ -00077510: 504f 5254 0a09 626f 6f6c 2076 616c 6964 PORT..bool valid │ │ │ -00077520: 6174 655f 6861 7368 5f72 6571 7565 7374 ate_hash_request │ │ │ -00077530: 2868 6173 685f 7265 7175 6573 7420 636f (hash_request co │ │ │ -00077540: 6e73 7426 616d 703b 2068 722c 2066 696c nst& hr, fil │ │ │ -00077550: 655f 7374 6f72 6167 6520 636f 6e73 7426 e_storage const& │ │ │ -00077560: 616d 703b 2066 7329 3b0a 0a09 636c 6173 amp; fs);...clas │ │ │ -00077570: 7320 544f 5252 454e 545f 4558 5452 415f s TORRENT_EXTRA_ │ │ │ -00077580: 4558 504f 5254 2068 6173 685f 7069 636b EXPORT hash_pick │ │ │ -00077590: 6572 0a09 7b0a 0970 7562 6c69 633a 0a09 er..{..public:.. │ │ │ -000775a0: 0968 6173 685f 7069 636b 6572 2866 696c .hash_picker(fil │ │ │ -000775b0: 655f 7374 6f72 6167 6520 636f 6e73 7426 e_storage const& │ │ │ -000775c0: 616d 703b 2066 696c 6573 0a09 0909 2c20 amp; files...., │ │ │ -000775d0: 6175 783a 3a76 6563 746f 7226 6c74 3b61 aux::vector<a │ │ │ -000775e0: 7578 3a3a 6d65 726b 6c65 5f74 7265 652c ux::merkle_tree, │ │ │ -000775f0: 2066 696c 655f 696e 6465 785f 7426 6774 file_index_t> │ │ │ -00077600: 3b26 616d 703b 2074 7265 6573 293b 0a0a ;& trees);.. │ │ │ -00077610: 0909 6861 7368 5f72 6571 7565 7374 2070 ..hash_request p │ │ │ -00077620: 6963 6b5f 6861 7368 6573 2874 7970 6564 ick_hashes(typed │ │ │ -00077630: 5f62 6974 6669 656c 6426 6c74 3b70 6965 _bitfield<pie │ │ │ -00077640: 6365 5f69 6e64 6578 5f74 2667 743b 2063 ce_index_t> c │ │ │ -00077650: 6f6e 7374 2661 6d70 3b20 7069 6563 6573 onst& pieces │ │ │ -00077660: 293b 0a0a 0909 6164 645f 6861 7368 6573 );....add_hashes │ │ │ -00077670: 5f72 6573 756c 7420 6164 645f 6861 7368 _result add_hash │ │ │ -00077680: 6573 2868 6173 685f 7265 7175 6573 7420 es(hash_request │ │ │ -00077690: 636f 6e73 7426 616d 703b 2072 6571 2c20 const& req, │ │ │ -000776a0: 7370 616e 266c 743b 7368 6132 3536 5f68 span<sha256_h │ │ │ -000776b0: 6173 6820 636f 6e73 7426 6774 3b20 6861 ash const> ha │ │ │ -000776c0: 7368 6573 293b 0a3c 6469 7620 7374 796c shes);.
    ..set_block │ │ │ -00077700: 5f68 6173 685f 7265 7375 6c74 2073 6574 _hash_result set │ │ │ -00077710: 5f62 6c6f 636b 5f68 6173 6828 7069 6563 _block_hash(piec │ │ │ -00077720: 655f 696e 6465 785f 7420 7069 6563 652c e_index_t piece, │ │ │ -00077730: 2069 6e74 206f 6666 7365 742c 2073 6861 int offset, sha │ │ │ -00077740: 3235 365f 6861 7368 2063 6f6e 7374 2661 256_hash const&a │ │ │ -00077750: 6d70 3b20 6829 3b0a 3c2f 6469 763e 0909 mp; h);.
    .. │ │ │ -00077760: 766f 6964 2068 6173 6865 735f 7265 6a65 void hashes_reje │ │ │ -00077770: 6374 6564 2868 6173 685f 7265 7175 6573 cted(hash_reques │ │ │ -00077780: 7420 636f 6e73 7426 616d 703b 2072 6571 t const& req │ │ │ -00077790: 293b 0a09 0976 6f69 6420 7665 7269 6679 );...void verify │ │ │ -000777a0: 5f62 6c6f 636b 5f68 6173 6865 7328 7069 _block_hashes(pi │ │ │ -000777b0: 6563 655f 696e 6465 785f 7420 696e 6465 ece_index_t inde │ │ │ -000777c0: 7829 3b0a 0a09 092f 2f20 646f 2077 6520 x);....// do we │ │ │ -000777d0: 6b6e 6f77 2074 6865 2070 6965 6365 206c know the piece l │ │ │ -000777e0: 6179 6572 2068 6173 6820 666f 7220 6120 ayer hash for a │ │ │ -000777f0: 7069 6563 650a 0909 626f 6f6c 2068 6176 piece...bool hav │ │ │ -00077800: 655f 6861 7368 2870 6965 6365 5f69 6e64 e_hash(piece_ind │ │ │ -00077810: 6578 5f74 2069 6e64 6578 2920 636f 6e73 ex_t index) cons │ │ │ -00077820: 743b 0a09 092f 2f20 646f 2077 6520 6b6e t;...// do we kn │ │ │ -00077830: 6f77 2061 6c6c 2074 6865 2062 6c6f 636b ow all the block │ │ │ -00077840: 2068 6173 6865 7320 666f 7220 6120 6669 hashes for a fi │ │ │ -00077850: 6c65 3f0a 0909 626f 6f6c 2068 6176 655f le?...bool have_ │ │ │ -00077860: 616c 6c28 6669 6c65 5f69 6e64 6578 5f74 all(file_index_t │ │ │ -00077870: 2066 696c 6529 2063 6f6e 7374 3b0a 0909 file) const;... │ │ │ -00077880: 626f 6f6c 2068 6176 655f 616c 6c28 2920 bool have_all() │ │ │ -00077890: 636f 6e73 743b 0a09 0962 6f6f 6c20 7069 const;...bool pi │ │ │ -000778a0: 6563 655f 7665 7269 6669 6564 2870 6965 ece_verified(pie │ │ │ -000778b0: 6365 5f69 6e64 6578 5f74 2070 6965 6365 ce_index_t piece │ │ │ -000778c0: 2920 636f 6e73 743b 0a0a 0909 696e 7420 ) const;....int │ │ │ -000778d0: 7069 6563 655f 6c61 7965 7228 2920 636f piece_layer() co │ │ │ -000778e0: 6e73 7420 7b20 7265 7475 726e 206d 5f70 nst { return m_p │ │ │ -000778f0: 6965 6365 5f6c 6179 6572 3b20 7d0a 0a09 iece_layer; }... │ │ │ -00077900: 7072 6976 6174 653a 0a09 092f 2f20 7265 private:...// re │ │ │ -00077910: 7475 726e 7320 7468 6520 6e75 6d62 6572 turns the number │ │ │ -00077920: 206f 6620 7072 6f6f 6620 6c61 7965 7273 of proof layers │ │ │ -00077930: 206e 6565 6465 6420 746f 2076 6572 6966 needed to verif │ │ │ -00077940: 7920 7468 6520 6e6f 6465 2773 2068 6173 y the node's has │ │ │ -00077950: 680a 0909 696e 7420 6c61 7965 7273 5f74 h...int layers_t │ │ │ -00077960: 6f5f 7665 7269 6679 286e 6f64 655f 696e o_verify(node_in │ │ │ -00077970: 6465 7820 6964 7829 2063 6f6e 7374 3b0a dex idx) const;. │ │ │ -00077980: 0909 696e 7420 6669 6c65 5f6e 756d 5f6c ..int file_num_l │ │ │ -00077990: 6179 6572 7328 6669 6c65 5f69 6e64 6578 ayers(file_index │ │ │ -000779a0: 5f74 2069 6478 2920 636f 6e73 743b 0a0a _t idx) const;.. │ │ │ -000779b0: 0909 7374 7275 6374 2070 6965 6365 5f68 ..struct piece_h │ │ │ -000779c0: 6173 685f 7265 7175 6573 740a 0909 7b0a ash_request...{. │ │ │ -000779d0: 0909 0974 696d 655f 706f 696e 7420 6c61 ...time_point la │ │ │ -000779e0: 7374 5f72 6571 7565 7374 203d 206d 696e st_request = min │ │ │ -000779f0: 5f74 696d 6528 293b 0a09 0909 696e 7420 _time();....int │ │ │ -00077a00: 6e75 6d5f 7265 7175 6573 7473 203d 2030 num_requests = 0 │ │ │ -00077a10: 3b0a 0909 0962 6f6f 6c20 6861 7665 203d ;....bool have = │ │ │ -00077a20: 2066 616c 7365 3b0a 0909 7d3b 0a0a 0909 false;...};.... │ │ │ -00077a30: 7374 7275 6374 2070 7269 6f72 6974 795f struct priority_ │ │ │ -00077a40: 626c 6f63 6b5f 7265 7175 6573 740a 0909 block_request... │ │ │ -00077a50: 7b0a 0909 0970 7269 6f72 6974 795f 626c {....priority_bl │ │ │ -00077a60: 6f63 6b5f 7265 7175 6573 7428 6669 6c65 ock_request(file │ │ │ -00077a70: 5f69 6e64 6578 5f74 2063 6f6e 7374 2066 _index_t const f │ │ │ -00077a80: 2c20 696e 7420 636f 6e73 7420 6229 0a09 , int const b).. │ │ │ -00077a90: 0909 093a 2066 696c 6528 6629 2c20 626c ...: file(f), bl │ │ │ -00077aa0: 6f63 6b28 6229 207b 7d0a 0909 0966 696c ock(b) {}....fil │ │ │ -00077ab0: 655f 696e 6465 785f 7420 6669 6c65 3b0a e_index_t file;. │ │ │ -00077ac0: 0909 0969 6e74 2062 6c6f 636b 3b0a 3c2f ...int block;.r │ │ │ -00077b00: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -00077b10: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../incl │ │ │ -00077b40: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -00077b50: 6e6e 6f75 6e63 655f 656e 7472 792e 6870 nnounce_entry.hp │ │ │ -00077b60: 703a 3736 3c2f 613e 3c2f 7464 3e3c 7464 p:76include the num │ │ │ -00077b80: 6265 7220 6f66 2070 6565 7273 2072 6563 ber of peers rec │ │ │ -00077b90: 6569 7665 6420 6672 6f6d 2074 6869 7320 eived from this │ │ │ -00077ba0: 7472 6163 6b65 722c 2061 7420 6c61 7374 tracker, at last │ │ │ -00077bb0: 2061 6e6e 6f75 6e63 653c 2f74 643e 3c2f announce

    include t │ │ │ -00077c10: 6865 206e 756d 6265 7220 6f66 2070 6565 he number of pee │ │ │ -00077c20: 7273 2072 6563 6569 7665 6420 6672 6f6d rs received from │ │ │ -00077c30: 2074 6869 7320 7472 6163 6b65 722c 2061 this tracker, a │ │ │ -00077c40: 7420 6c61 7374 0a61 6e6e 6f75 6e63 653c t last.announce< │ │ │ -00077c50: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ -00077c60: 6465 2f6c 6962 746f 7272 656e 742f 616e de/libtorrent/an │ │ │ -00077c70: 6e6f 756e 6365 5f65 6e74 7279 2e68 7070 nounce_entry.hpp │ │ │ -00077c80: 3a37 363c 2f68 343e 3c70 7265 2073 7479 :76

    ..struct TORRE
    │ │ │ -00077cd0: 4e54 5f45 5850 4f52 5420 616e 6e6f 756e  NT_EXPORT announ
    │ │ │ -00077ce0: 6365 5f69 6e66 6f68 6173 680a 097b 0a09  ce_infohash..{..
    │ │ │ -00077cf0: 092f 2f20 696e 7465 726e 616c 0a09 0954  .// internal...T
    │ │ │ -00077d00: 4f52 5245 4e54 5f55 4e45 5850 4f52 5420  ORRENT_UNEXPORT 
    │ │ │ -00077d10: 616e 6e6f 756e 6365 5f69 6e66 6f68 6173  announce_infohas
    │ │ │ -00077d20: 6828 293b 0a0a 0909 2f2f 2069 6620 7468  h();....// if th
    │ │ │ -00077d30: 6973 2074 7261 636b 6572 2068 6173 2072  is tracker has r
    │ │ │ -00077d40: 6574 7572 6e65 6420 616e 2065 7272 6f72  eturned an error
    │ │ │ -00077d50: 206f 7220 7761 726e 696e 6720 6d65 7373   or warning mess
    │ │ │ -00077d60: 6167 650a 0909 2f2f 2074 6861 7420 6d65  age...// that me
    │ │ │ -00077d70: 7373 6167 6520 6973 2073 746f 7265 6420  ssage is stored 
    │ │ │ -00077d80: 6865 7265 0a09 0973 7464 3a3a 7374 7269  here...std::stri
    │ │ │ -00077d90: 6e67 206d 6573 7361 6765 3b0a 0a09 092f  ng message;..../
    │ │ │ -00077da0: 2f20 6966 2074 6869 7320 7472 6163 6b65  / if this tracke
    │ │ │ -00077db0: 7220 6661 696c 6564 2074 6865 206c 6173  r failed the las
    │ │ │ -00077dc0: 7420 7469 6d65 2069 7420 7761 7320 636f  t time it was co
    │ │ │ -00077dd0: 6e74 6163 7465 640a 0909 2f2f 2074 6869  ntacted...// thi
    │ │ │ -00077de0: 7320 6572 726f 7220 636f 6465 2073 7065  s error code spe
    │ │ │ -00077df0: 6369 6669 6573 2077 6861 7420 6572 726f  cifies what erro
    │ │ │ -00077e00: 7220 6f63 6375 7272 6564 0a09 0965 7272  r occurred...err
    │ │ │ -00077e10: 6f72 5f63 6f64 6520 6c61 7374 5f65 7272  or_code last_err
    │ │ │ -00077e20: 6f72 3b0a 0a09 092f 2f20 7468 6520 7469  or;....// the ti
    │ │ │ -00077e30: 6d65 206f 6620 6e65 7874 2074 7261 636b  me of next track
    │ │ │ -00077e40: 6572 2061 6e6e 6f75 6e63 650a 0909 7469  er announce...ti
    │ │ │ -00077e50: 6d65 5f70 6f69 6e74 3332 206e 6578 745f  me_point32 next_
    │ │ │ -00077e60: 616e 6e6f 756e 6365 203d 2028 7469 6d65  announce = (time
    │ │ │ -00077e70: 5f70 6f69 6e74 3332 3a3a 6d69 6e29 2829  _point32::min)()
    │ │ │ -00077e80: 3b0a 0a09 092f 2f20 6e6f 2061 6e6e 6f75  ;....// no annou
    │ │ │ -00077e90: 6e63 6573 2062 6566 6f72 6520 7468 6973  nces before this
    │ │ │ -00077ea0: 2074 696d 650a 0909 7469 6d65 5f70 6f69   time...time_poi
    │ │ │ -00077eb0: 6e74 3332 206d 696e 5f61 6e6e 6f75 6e63  nt32 min_announc
    │ │ │ -00077ec0: 6520 3d20 2874 696d 655f 706f 696e 7433  e = (time_point3
    │ │ │ -00077ed0: 323a 3a6d 696e 2928 293b 0a0a 3c64 6976  2::min)();..
    .
    ..// these are │ │ │ -00077f20: 6569 7468 6572 202d 3120 6f72 2074 6865 either -1 or the │ │ │ -00077f30: 2073 6372 6170 6520 696e 666f 726d 6174 scrape informat │ │ │ -00077f40: 696f 6e20 7468 6973 2074 7261 636b 6572 ion this tracker │ │ │ -00077f50: 206c 6173 740a 0909 2f2f 2072 6573 706f last...// respo │ │ │ -00077f60: 6e64 6564 2077 6974 682e 202a 696e 636f nded with. *inco │ │ │ -00077f70: 6d70 6c65 7465 2a20 6973 2074 6865 2063 mplete* is the c │ │ │ -00077f80: 7572 7265 6e74 206e 756d 6265 7220 6f66 urrent number of │ │ │ -00077f90: 2064 6f77 6e6c 6f61 6465 7273 2069 6e0a downloaders in. │ │ │ -00077fa0: 0909 2f2f 2074 6865 2073 7761 726d 2c20 ..// the swarm, │ │ │ -00077fb0: 2a63 6f6d 706c 6574 652a 2069 7320 7468 *complete* is th │ │ │ -00077fc0: 6520 6375 7272 656e 7420 6e75 6d62 6572 e current number │ │ │ -00077fd0: 206f 6620 7365 6564 7320 696e 2074 6865 of seeds in the │ │ │ -00077fe0: 2073 7761 726d 2061 6e64 0a09 092f 2f20 swarm and...// │ │ │ -00077ff0: 2a64 6f77 6e6c 6f61 6465 642a 2069 7320 *downloaded* is │ │ │ -00078000: 7468 6520 6375 6d75 6c61 7469 7665 206e the cumulative n │ │ │ -00078010: 756d 6265 7220 6f66 2063 6f6d 706c 6574 umber of complet │ │ │ -00078020: 6564 2064 6f77 6e6c 6f61 6473 206f 6620 ed downloads of │ │ │ -00078030: 7468 6973 0a09 092f 2f20 746f 7272 656e this...// torren │ │ │ -00078040: 742c 2073 696e 6365 2074 6865 2062 6567 t, since the beg │ │ │ -00078050: 696e 6e69 6e67 206f 6620 7469 6d65 2028 inning of time ( │ │ │ -00078060: 6672 6f6d 2074 6869 7320 7472 6163 6b65 from this tracke │ │ │ -00078070: 7227 7320 706f 696e 7420 6f66 0a09 092f r's point of.../ │ │ │ -00078080: 2f20 7669 6577 292e 0a0a 0909 2f2f 2069 / view).....// i │ │ │ -00078090: 6620 7468 6973 2074 7261 636b 6572 2068 f this tracker h │ │ │ -000780a0: 6173 2072 6574 7572 6e65 6420 7363 7261 as returned scra │ │ │ -000780b0: 7065 2064 6174 612c 2074 6865 7365 2066 pe data, these f │ │ │ -000780c0: 6965 6c64 7320 6172 6520 6669 6c6c 6564 ields are filled │ │ │ -000780d0: 2069 6e0a 0909 2f2f 2077 6974 6820 7661 in...// with va │ │ │ -000780e0: 6c69 6420 6e75 6d62 6572 732e 204f 7468 lid numbers. Oth │ │ │ -000780f0: 6572 7769 7365 2074 6865 7920 6172 6520 erwise they are │ │ │ -00078100: 7365 7420 746f 202d 312e 2060 6069 6e63 set to -1. ``inc │ │ │ -00078110: 6f6d 706c 6574 6560 6020 636f 756e 7473 omplete`` counts │ │ │ -00078120: 0a09 092f 2f20 7468 6520 6e75 6d62 6572 ...// the number │ │ │ -00078130: 206f 6620 6375 7272 656e 7420 646f 776e of current down │ │ │ -00078140: 6c6f 6164 6572 732e 2060 6063 6f6d 706c loaders. ``compl │ │ │ -00078150: 6574 6560 6020 636f 756e 7473 2074 6865 ete`` counts the │ │ │ -00078160: 206e 756d 6265 7220 6f66 0a09 092f 2f20 number of...// │ │ │ -00078170: 6375 7272 656e 7420 7065 6572 7320 636f current peers co │ │ │ -00078180: 6d70 6c65 7465 6420 7468 6520 646f 776e mpleted the down │ │ │ -00078190: 6c6f 6164 2c20 6f72 2022 7365 6564 7322 load, or "seeds" │ │ │ -000781a0: 2e20 6060 646f 776e 6c6f 6164 6564 6060 . ``downloaded`` │ │ │ -000781b0: 2069 7320 7468 650a 0909 2f2f 2063 756d is the...// cum │ │ │ -000781c0: 756c 6174 6976 6520 6e75 6d62 6572 206f ulative number o │ │ │ -000781d0: 6620 636f 6d70 6c65 7465 6420 646f 776e f completed down │ │ │ -000781e0: 6c6f 6164 732e 0a09 0969 6e74 2073 6372 loads....int scr │ │ │ -000781f0: 6170 655f 696e 636f 6d70 6c65 7465 203d ape_incomplete = │ │ │ -00078200: 202d 313b 0a09 0969 6e74 2073 6372 6170 -1;...int scrap │ │ │ -00078210: 655f 636f 6d70 6c65 7465 203d 202d 313b e_complete = -1; │ │ │ -00078220: 0a09 0969 6e74 2073 6372 6170 655f 646f ...int scrape_do │ │ │ -00078230: 776e 6c6f 6164 6564 203d 202d 313b 0a0a wnloaded = -1;.. │ │ │ -00078240: 0909 2f2f 2074 6865 206e 756d 6265 7220 ..// the number │ │ │ -00078250: 6f66 2074 696d 6573 2069 6e20 6120 726f of times in a ro │ │ │ -00078260: 7720 7765 2068 6176 6520 6661 696c 6564 w we have failed │ │ │ -00078270: 2074 6f20 616e 6e6f 756e 6365 2074 6f20 to announce to │ │ │ -00078280: 7468 6973 0a09 092f 2f20 7472 6163 6b65 this...// tracke │ │ │ -00078290: 722e 0a09 0973 7464 3a3a 7569 6e74 385f r....std::uint8_ │ │ │ -000782a0: 7420 6661 696c 7320 3a20 373b 0a0a 0909 t fails : 7;.... │ │ │ -000782b0: 2f2f 2074 7275 6520 7768 696c 6520 7765 // true while we │ │ │ -000782c0: 2772 6520 7761 6974 696e 6720 666f 7220 're waiting for │ │ │ -000782d0: 6120 7265 7370 6f6e 7365 2066 726f 6d20 a response from │ │ │ -000782e0: 7468 6520 7472 6163 6b65 722e 0a09 0962 the tracker....b │ │ │ -000782f0: 6f6f 6c20 7570 6461 7469 6e67 203a 2031 ool updating : 1 │ │ │ -00078300: 3b0a 0a09 092f 2f20 7365 7420 746f 2074 ;....// set to t │ │ │ -00078310: 7275 6520 7768 656e 2077 6520 6765 7420 rue when we get │ │ │ -00078320: 6120 7661 6c69 6420 7265 7370 6f6e 7365 a valid response │ │ │ -00078330: 2066 726f 6d20 616e 2061 6e6e 6f75 6e63 from an announc │ │ │ -00078340: 650a 0909 2f2f 2077 6974 6820 6576 656e e...// with even │ │ │ -00078350: 743d 7374 6172 7465 642e 2049 6620 6974 t=started. If it │ │ │ -00078360: 2069 7320 7365 742c 2077 6520 776f 6e27 is set, we won' │ │ │ -00078370: 7420 7365 6e64 2073 7461 7274 2069 6e20 t send start in │ │ │ -00078380: 7468 6520 7375 6273 6571 7565 6e74 0a09 the subsequent.. │ │ │ -00078390: 092f 2f20 616e 6e6f 756e 6365 732e 0a09 .// announces... │ │ │ -000783a0: 0962 6f6f 6c20 7374 6172 745f 7365 6e74 .bool start_sent │ │ │ -000783b0: 203a 2031 3b0a 0a09 092f 2f20 7365 7420 : 1;....// set │ │ │ -000783c0: 746f 2074 7275 6520 7768 656e 2077 6520 to true when we │ │ │ -000783d0: 7365 6e64 2061 2065 7665 6e74 3d63 6f6d send a event=com │ │ │ -000783e0: 706c 6574 6564 2e0a 0909 626f 6f6c 2063 pleted....bool c │ │ │ -000783f0: 6f6d 706c 6574 655f 7365 6e74 203a 2031 omplete_sent : 1 │ │ │ +0006d120: 2f61 6e6e 6f75 6e63 655f 656e 7472 792e /announce_entry. │ │ │ +0006d130: 6870 703a 3736 3c2f 613e 3c2f 7464 3e3c hpp:76< │ │ │ +0006d140: 7464 3e69 6e63 6c75 6465 2074 6865 206e td>include the n │ │ │ +0006d150: 756d 6265 7220 6f66 2070 6565 7273 2072 umber of peers r │ │ │ +0006d160: 6563 6569 7665 6420 6672 6f6d 2074 6869 eceived from thi │ │ │ +0006d170: 7320 7472 6163 6b65 722c 2061 7420 6c61 s tracker, at la │ │ │ +0006d180: 7374 2061 6e6e 6f75 6e63 653c 2f74 643e st announce │ │ │ +0006d190: 3c2f 7472 3e3c 7472 2069 643d 2232 3439

    include │ │ │ +0006d1e0: 2074 6865 206e 756d 6265 7220 6f66 2070 the number of p │ │ │ +0006d1f0: 6565 7273 2072 6563 6569 7665 6420 6672 eers received fr │ │ │ +0006d200: 6f6d 2074 6869 7320 7472 6163 6b65 722c om this tracker, │ │ │ +0006d210: 2061 7420 6c61 7374 0a61 6e6e 6f75 6e63 at last.announc │ │ │ +0006d220: 653c 2f68 323e 3c68 343e 2e2e 2f69 6e63 e

    ../inc │ │ │ +0006d230: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ +0006d240: 616e 6e6f 756e 6365 5f65 6e74 7279 2e68 announce_entry.h │ │ │ +0006d250: 7070 3a37 363c 2f68 343e 3c70 7265 2073 pp:76

    ..struct TOR
    │ │ │ +0006d2a0: 5245 4e54 5f45 5850 4f52 5420 616e 6e6f  RENT_EXPORT anno
    │ │ │ +0006d2b0: 756e 6365 5f69 6e66 6f68 6173 680a 097b  unce_infohash..{
    │ │ │ +0006d2c0: 0a09 092f 2f20 696e 7465 726e 616c 0a09  ...// internal..
    │ │ │ +0006d2d0: 0954 4f52 5245 4e54 5f55 4e45 5850 4f52  .TORRENT_UNEXPOR
    │ │ │ +0006d2e0: 5420 616e 6e6f 756e 6365 5f69 6e66 6f68  T announce_infoh
    │ │ │ +0006d2f0: 6173 6828 293b 0a0a 0909 2f2f 2069 6620  ash();....// if 
    │ │ │ +0006d300: 7468 6973 2074 7261 636b 6572 2068 6173  this tracker has
    │ │ │ +0006d310: 2072 6574 7572 6e65 6420 616e 2065 7272   returned an err
    │ │ │ +0006d320: 6f72 206f 7220 7761 726e 696e 6720 6d65  or or warning me
    │ │ │ +0006d330: 7373 6167 650a 0909 2f2f 2074 6861 7420  ssage...// that 
    │ │ │ +0006d340: 6d65 7373 6167 6520 6973 2073 746f 7265  message is store
    │ │ │ +0006d350: 6420 6865 7265 0a09 0973 7464 3a3a 7374  d here...std::st
    │ │ │ +0006d360: 7269 6e67 206d 6573 7361 6765 3b0a 0a09  ring message;...
    │ │ │ +0006d370: 092f 2f20 6966 2074 6869 7320 7472 6163  .// if this trac
    │ │ │ +0006d380: 6b65 7220 6661 696c 6564 2074 6865 206c  ker failed the l
    │ │ │ +0006d390: 6173 7420 7469 6d65 2069 7420 7761 7320  ast time it was 
    │ │ │ +0006d3a0: 636f 6e74 6163 7465 640a 0909 2f2f 2074  contacted...// t
    │ │ │ +0006d3b0: 6869 7320 6572 726f 7220 636f 6465 2073  his error code s
    │ │ │ +0006d3c0: 7065 6369 6669 6573 2077 6861 7420 6572  pecifies what er
    │ │ │ +0006d3d0: 726f 7220 6f63 6375 7272 6564 0a09 0965  ror occurred...e
    │ │ │ +0006d3e0: 7272 6f72 5f63 6f64 6520 6c61 7374 5f65  rror_code last_e
    │ │ │ +0006d3f0: 7272 6f72 3b0a 0a09 092f 2f20 7468 6520  rror;....// the 
    │ │ │ +0006d400: 7469 6d65 206f 6620 6e65 7874 2074 7261  time of next tra
    │ │ │ +0006d410: 636b 6572 2061 6e6e 6f75 6e63 650a 0909  cker announce...
    │ │ │ +0006d420: 7469 6d65 5f70 6f69 6e74 3332 206e 6578  time_point32 nex
    │ │ │ +0006d430: 745f 616e 6e6f 756e 6365 203d 2028 7469  t_announce = (ti
    │ │ │ +0006d440: 6d65 5f70 6f69 6e74 3332 3a3a 6d69 6e29  me_point32::min)
    │ │ │ +0006d450: 2829 3b0a 0a09 092f 2f20 6e6f 2061 6e6e  ();....// no ann
    │ │ │ +0006d460: 6f75 6e63 6573 2062 6566 6f72 6520 7468  ounces before th
    │ │ │ +0006d470: 6973 2074 696d 650a 0909 7469 6d65 5f70  is time...time_p
    │ │ │ +0006d480: 6f69 6e74 3332 206d 696e 5f61 6e6e 6f75  oint32 min_annou
    │ │ │ +0006d490: 6e63 6520 3d20 2874 696d 655f 706f 696e  nce = (time_poin
    │ │ │ +0006d4a0: 7433 323a 3a6d 696e 2928 293b 0a0a 3c64  t32::min)();.....// these ar
    │ │ │ +0006d4f0: 6520 6569 7468 6572 202d 3120 6f72 2074  e either -1 or t
    │ │ │ +0006d500: 6865 2073 6372 6170 6520 696e 666f 726d  he scrape inform
    │ │ │ +0006d510: 6174 696f 6e20 7468 6973 2074 7261 636b  ation this track
    │ │ │ +0006d520: 6572 206c 6173 740a 0909 2f2f 2072 6573  er last...// res
    │ │ │ +0006d530: 706f 6e64 6564 2077 6974 682e 202a 696e  ponded with. *in
    │ │ │ +0006d540: 636f 6d70 6c65 7465 2a20 6973 2074 6865  complete* is the
    │ │ │ +0006d550: 2063 7572 7265 6e74 206e 756d 6265 7220   current number 
    │ │ │ +0006d560: 6f66 2064 6f77 6e6c 6f61 6465 7273 2069  of downloaders i
    │ │ │ +0006d570: 6e0a 0909 2f2f 2074 6865 2073 7761 726d  n...// the swarm
    │ │ │ +0006d580: 2c20 2a63 6f6d 706c 6574 652a 2069 7320  , *complete* is 
    │ │ │ +0006d590: 7468 6520 6375 7272 656e 7420 6e75 6d62  the current numb
    │ │ │ +0006d5a0: 6572 206f 6620 7365 6564 7320 696e 2074  er of seeds in t
    │ │ │ +0006d5b0: 6865 2073 7761 726d 2061 6e64 0a09 092f  he swarm and.../
    │ │ │ +0006d5c0: 2f20 2a64 6f77 6e6c 6f61 6465 642a 2069  / *downloaded* i
    │ │ │ +0006d5d0: 7320 7468 6520 6375 6d75 6c61 7469 7665  s the cumulative
    │ │ │ +0006d5e0: 206e 756d 6265 7220 6f66 2063 6f6d 706c   number of compl
    │ │ │ +0006d5f0: 6574 6564 2064 6f77 6e6c 6f61 6473 206f  eted downloads o
    │ │ │ +0006d600: 6620 7468 6973 0a09 092f 2f20 746f 7272  f this...// torr
    │ │ │ +0006d610: 656e 742c 2073 696e 6365 2074 6865 2062  ent, since the b
    │ │ │ +0006d620: 6567 696e 6e69 6e67 206f 6620 7469 6d65  eginning of time
    │ │ │ +0006d630: 2028 6672 6f6d 2074 6869 7320 7472 6163   (from this trac
    │ │ │ +0006d640: 6b65 7227 7320 706f 696e 7420 6f66 0a09  ker's point of..
    │ │ │ +0006d650: 092f 2f20 7669 6577 292e 0a0a 0909 2f2f  .// view).....//
    │ │ │ +0006d660: 2069 6620 7468 6973 2074 7261 636b 6572   if this tracker
    │ │ │ +0006d670: 2068 6173 2072 6574 7572 6e65 6420 7363   has returned sc
    │ │ │ +0006d680: 7261 7065 2064 6174 612c 2074 6865 7365  rape data, these
    │ │ │ +0006d690: 2066 6965 6c64 7320 6172 6520 6669 6c6c   fields are fill
    │ │ │ +0006d6a0: 6564 2069 6e0a 0909 2f2f 2077 6974 6820  ed in...// with 
    │ │ │ +0006d6b0: 7661 6c69 6420 6e75 6d62 6572 732e 204f  valid numbers. O
    │ │ │ +0006d6c0: 7468 6572 7769 7365 2074 6865 7920 6172  therwise they ar
    │ │ │ +0006d6d0: 6520 7365 7420 746f 202d 312e 2060 6069  e set to -1. ``i
    │ │ │ +0006d6e0: 6e63 6f6d 706c 6574 6560 6020 636f 756e  ncomplete`` coun
    │ │ │ +0006d6f0: 7473 0a09 092f 2f20 7468 6520 6e75 6d62  ts...// the numb
    │ │ │ +0006d700: 6572 206f 6620 6375 7272 656e 7420 646f  er of current do
    │ │ │ +0006d710: 776e 6c6f 6164 6572 732e 2060 6063 6f6d  wnloaders. ``com
    │ │ │ +0006d720: 706c 6574 6560 6020 636f 756e 7473 2074  plete`` counts t
    │ │ │ +0006d730: 6865 206e 756d 6265 7220 6f66 0a09 092f  he number of.../
    │ │ │ +0006d740: 2f20 6375 7272 656e 7420 7065 6572 7320  / current peers 
    │ │ │ +0006d750: 636f 6d70 6c65 7465 6420 7468 6520 646f  completed the do
    │ │ │ +0006d760: 776e 6c6f 6164 2c20 6f72 2022 7365 6564  wnload, or "seed
    │ │ │ +0006d770: 7322 2e20 6060 646f 776e 6c6f 6164 6564  s". ``downloaded
    │ │ │ +0006d780: 6060 2069 7320 7468 650a 0909 2f2f 2063  `` is the...// c
    │ │ │ +0006d790: 756d 756c 6174 6976 6520 6e75 6d62 6572  umulative number
    │ │ │ +0006d7a0: 206f 6620 636f 6d70 6c65 7465 6420 646f   of completed do
    │ │ │ +0006d7b0: 776e 6c6f 6164 732e 0a09 0969 6e74 2073  wnloads....int s
    │ │ │ +0006d7c0: 6372 6170 655f 696e 636f 6d70 6c65 7465  crape_incomplete
    │ │ │ +0006d7d0: 203d 202d 313b 0a09 0969 6e74 2073 6372   = -1;...int scr
    │ │ │ +0006d7e0: 6170 655f 636f 6d70 6c65 7465 203d 202d  ape_complete = -
    │ │ │ +0006d7f0: 313b 0a09 0969 6e74 2073 6372 6170 655f  1;...int scrape_
    │ │ │ +0006d800: 646f 776e 6c6f 6164 6564 203d 202d 313b  downloaded = -1;
    │ │ │ +0006d810: 0a0a 0909 2f2f 2074 6865 206e 756d 6265  ....// the numbe
    │ │ │ +0006d820: 7220 6f66 2074 696d 6573 2069 6e20 6120  r of times in a 
    │ │ │ +0006d830: 726f 7720 7765 2068 6176 6520 6661 696c  row we have fail
    │ │ │ +0006d840: 6564 2074 6f20 616e 6e6f 756e 6365 2074  ed to announce t
    │ │ │ +0006d850: 6f20 7468 6973 0a09 092f 2f20 7472 6163  o this...// trac
    │ │ │ +0006d860: 6b65 722e 0a09 0973 7464 3a3a 7569 6e74  ker....std::uint
    │ │ │ +0006d870: 385f 7420 6661 696c 7320 3a20 373b 0a0a  8_t fails : 7;..
    │ │ │ +0006d880: 0909 2f2f 2074 7275 6520 7768 696c 6520  ..// true while 
    │ │ │ +0006d890: 7765 2772 6520 7761 6974 696e 6720 666f  we're waiting fo
    │ │ │ +0006d8a0: 7220 6120 7265 7370 6f6e 7365 2066 726f  r a response fro
    │ │ │ +0006d8b0: 6d20 7468 6520 7472 6163 6b65 722e 0a09  m the tracker...
    │ │ │ +0006d8c0: 0962 6f6f 6c20 7570 6461 7469 6e67 203a  .bool updating :
    │ │ │ +0006d8d0: 2031 3b0a 0a09 092f 2f20 7365 7420 746f   1;....// set to
    │ │ │ +0006d8e0: 2074 7275 6520 7768 656e 2077 6520 6765   true when we ge
    │ │ │ +0006d8f0: 7420 6120 7661 6c69 6420 7265 7370 6f6e  t a valid respon
    │ │ │ +0006d900: 7365 2066 726f 6d20 616e 2061 6e6e 6f75  se from an annou
    │ │ │ +0006d910: 6e63 650a 0909 2f2f 2077 6974 6820 6576  nce...// with ev
    │ │ │ +0006d920: 656e 743d 7374 6172 7465 642e 2049 6620  ent=started. If 
    │ │ │ +0006d930: 6974 2069 7320 7365 742c 2077 6520 776f  it is set, we wo
    │ │ │ +0006d940: 6e27 7420 7365 6e64 2073 7461 7274 2069  n't send start i
    │ │ │ +0006d950: 6e20 7468 6520 7375 6273 6571 7565 6e74  n the subsequent
    │ │ │ +0006d960: 0a09 092f 2f20 616e 6e6f 756e 6365 732e  ...// announces.
    │ │ │ +0006d970: 0a09 0962 6f6f 6c20 7374 6172 745f 7365  ...bool start_se
    │ │ │ +0006d980: 6e74 203a 2031 3b0a 0a09 092f 2f20 7365  nt : 1;....// se
    │ │ │ +0006d990: 7420 746f 2074 7275 6520 7768 656e 2077  t to true when w
    │ │ │ +0006d9a0: 6520 7365 6e64 2061 2065 7665 6e74 3d63  e send a event=c
    │ │ │ +0006d9b0: 6f6d 706c 6574 6564 2e0a 0909 626f 6f6c  ompleted....bool
    │ │ │ +0006d9c0: 2063 6f6d 706c 6574 655f 7365 6e74 203a   complete_sent :
    │ │ │ +0006d9d0: 2031 3b0a 3c2f 7072 653e 3c2f 7464 3e3c   1;.
    < │ │ │ +0006d9e0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +0006da10: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +0006da40: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ +0006da50: 7265 6e74 2f70 726f 7879 5f62 6173 652e rent/proxy_base. │ │ │ +0006da60: 6870 703a 3232 373c 2f61 3e3c 2f74 643e hpp:227 │ │ │ +0006da70: 3c74 643e 6974 2077 6f75 6c64 2062 6520 it would be │ │ │ +0006da80: 6e69 6365 2074 6f20 7265 6d65 6d62 6572 nice to remember │ │ │ +0006da90: 2074 6865 2062 696e 6420 706f 7274 2061 the bind port a │ │ │ +0006daa0: 6e64 2062 696e 6420 6f6e 6365 2077 6520 nd bind once we │ │ │ +0006dab0: 6b6e 6f77 2077 6865 7265 2074 6865 2070 know where the p │ │ │ +0006dac0: 726f 7879 2069 7320 6d5f 736f 636b 2e62 roxy is m_sock.b │ │ │ +0006dad0: 696e 6428 656e 6470 6f69 6e74 2c20 6563 ind(endpoint, ec │ │ │ +0006dae0: 293b 3c2f 7464 3e3c 2f74 723e 3c74 7220 );

    │ │ │ +0006db30: 6974 2077 6f75 6c64 2062 6520 6e69 6365 it would be nice │ │ │ +0006db40: 2074 6f20 7265 6d65 6d62 6572 2074 6865 to remember the │ │ │ +0006db50: 2062 696e 6420 706f 7274 2061 6e64 2062 bind port and b │ │ │ +0006db60: 696e 6420 6f6e 6365 2077 6520 6b6e 6f77 ind once we know │ │ │ +0006db70: 2077 6865 7265 2074 6865 2070 726f 7879 where the proxy │ │ │ +0006db80: 2069 730a 6d5f 736f 636b 2e62 696e 6428 is.m_sock.bind( │ │ │ +0006db90: 656e 6470 6f69 6e74 2c20 6563 293b 3c2f endpoint, ec);

    ../includ │ │ │ +0006dbb0: 652f 6c69 6274 6f72 7265 6e74 2f70 726f e/libtorrent/pro │ │ │ +0006dbc0: 7879 5f62 6173 652e 6870 703a 3232 373c xy_base.hpp:227< │ │ │ +0006dbd0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +0006dc10: 544f 5252 454e 545f 4153 5345 5254 286d  TORRENT_ASSERT(m
    │ │ │ +0006dc20: 5f6d 6167 6963 203d 3d20 3078 3133 3337  _magic == 0x1337
    │ │ │ +0006dc30: 293b 0a09 096d 5f73 6f63 6b2e 6361 6e63  );...m_sock.canc
    │ │ │ +0006dc40: 656c 2829 3b0a 097d 0a0a 0976 6f69 6420  el();..}...void 
    │ │ │ +0006dc50: 6361 6e63 656c 2865 7272 6f72 5f63 6f64  cancel(error_cod
    │ │ │ +0006dc60: 6526 616d 703b 2065 6329 0a09 7b0a 0909  e& ec)..{...
    │ │ │ +0006dc70: 544f 5252 454e 545f 4153 5345 5254 286d  TORRENT_ASSERT(m
    │ │ │ +0006dc80: 5f6d 6167 6963 203d 3d20 3078 3133 3337  _magic == 0x1337
    │ │ │ +0006dc90: 293b 0a09 096d 5f73 6f63 6b2e 6361 6e63  );...m_sock.canc
    │ │ │ +0006dca0: 656c 2865 6329 3b0a 097d 0a0a 0976 6f69  el(ec);..}...voi
    │ │ │ +0006dcb0: 6420 6269 6e64 2865 6e64 706f 696e 745f  d bind(endpoint_
    │ │ │ +0006dcc0: 7479 7065 2063 6f6e 7374 2661 6d70 3b20  type const& 
    │ │ │ +0006dcd0: 2f2a 2065 6e64 706f 696e 7420 2a2f 2c20  /* endpoint */, 
    │ │ │ +0006dce0: 6572 726f 725f 636f 6465 2661 6d70 3b20  error_code& 
    │ │ │ +0006dcf0: 2f2a 2065 6320 2a2f 290a 097b 0a09 0954  /* ec */)..{...T
    │ │ │ +0006dd00: 4f52 5245 4e54 5f41 5353 4552 5428 6d5f  ORRENT_ASSERT(m_
    │ │ │ +0006dd10: 6d61 6769 6320 3d3d 2030 7831 3333 3729  magic == 0x1337)
    │ │ │ +0006dd20: 3b0a 0909 2f2f 2074 6865 2072 6561 736f  ;...// the reaso
    │ │ │ +0006dd30: 6e20 7768 7920 7765 2069 676e 6f72 6520  n why we ignore 
    │ │ │ +0006dd40: 6269 6e64 7320 6865 7265 2069 7320 6265  binds here is be
    │ │ │ +0006dd50: 6361 7573 6520 7765 2064 6f6e 2774 0a09  cause we don't..
    │ │ │ +0006dd60: 092f 2f20 286e 6563 6573 7361 7269 6c79  .// (necessarily
    │ │ │ +0006dd70: 2920 7965 7420 6b6e 6f77 2077 6861 7420  ) yet know what 
    │ │ │ +0006dd80: 6164 6472 6573 7320 6661 6d69 6c79 2074  address family t
    │ │ │ +0006dd90: 6865 2070 726f 7879 0a09 092f 2f20 7769  he proxy...// wi
    │ │ │ +0006dda0: 6c6c 2072 6573 6f6c 7665 2074 6f2c 2061  ll resolve to, a
    │ │ │ +0006ddb0: 6e64 2062 696e 6469 6e67 2074 6f20 7468  nd binding to th
    │ │ │ +0006ddc0: 6520 7772 6f6e 6720 6f6e 6520 776f 756c  e wrong one woul
    │ │ │ +0006ddd0: 640a 0909 2f2f 2062 7265 616b 206f 7572  d...// break our
    │ │ │ +0006dde0: 2063 6f6e 6e65 6374 696f 6e20 6174 7465   connection atte
    │ │ │ +0006ddf0: 6d70 7420 6c61 7465 722e 2054 6865 2063  mpt later. The c
    │ │ │ +0006de00: 616c 6c65 7220 6865 7265 0a09 092f 2f20  aller here...// 
    │ │ │ +0006de10: 646f 6573 6e27 7420 6e65 6365 7373 6172  doesn't necessar
    │ │ │ +0006de20: 696c 7920 6b6e 6f77 2074 6861 7420 7765  ily know that we
    │ │ │ +0006de30: 2772 6520 7072 6f78 7969 6e67 2c20 736f  're proxying, so
    │ │ │ +0006de40: 2074 6869 730a 0909 2f2f 2062 696e 6420   this...// bind 
    │ │ │ +0006de50: 6164 6472 6573 7320 6973 2062 6173 6564  address is based
    │ │ │ +0006de60: 206f 6e20 7468 6520 6669 6e61 6c20 656e   on the final en
    │ │ │ +0006de70: 6470 6f69 6e74 2c20 6e6f 7420 7468 650a  dpoint, not the.
    │ │ │ +0006de80: 0909 2f2f 2070 726f 7879 2e0a 3c64 6976  ..// proxy..
    .}..#ifndef BOOS │ │ │ +0006ded0: 545f 4e4f 5f45 5843 4550 5449 4f4e 530a T_NO_EXCEPTIONS. │ │ │ +0006dee0: 0976 6f69 6420 6f70 656e 2870 726f 746f .void open(proto │ │ │ +0006def0: 636f 6c5f 7479 7065 2063 6f6e 7374 2661 col_type const&a │ │ │ +0006df00: 6d70 3b29 0a09 7b0a 0909 544f 5252 454e mp;)..{...TORREN │ │ │ +0006df10: 545f 4153 5345 5254 286d 5f6d 6167 6963 T_ASSERT(m_magic │ │ │ +0006df20: 203d 3d20 3078 3133 3337 293b 0a2f 2f09 == 0x1337);.//. │ │ │ +0006df30: 096d 5f73 6f63 6b2e 6f70 656e 2870 293b .m_sock.open(p); │ │ │ +0006df40: 0a09 7d0a 2365 6e64 6966 0a0a 0976 6f69 ..}.#endif...voi │ │ │ +0006df50: 6420 6f70 656e 2870 726f 746f 636f 6c5f d open(protocol_ │ │ │ +0006df60: 7479 7065 2063 6f6e 7374 2661 6d70 3b2c type const&, │ │ │ +0006df70: 2065 7272 6f72 5f63 6f64 6526 616d 703b error_code& │ │ │ +0006df80: 290a 097b 0a09 0954 4f52 5245 4e54 5f41 )..{...TORRENT_A │ │ │ +0006df90: 5353 4552 5428 6d5f 6d61 6769 6320 3d3d SSERT(m_magic == │ │ │ +0006dfa0: 2030 7831 3333 3729 3b0a 0909 2f2f 2077 0x1337);...// w │ │ │ +0006dfb0: 6520 6e65 6564 2074 6f20 6967 6e6f 7265 e need to ignore │ │ │ +0006dfc0: 2074 6869 7320 666f 7220 7468 6520 7361 this for the sa │ │ │ +0006dfd0: 6d65 2072 6561 736f 6e20 6173 2073 7461 me reason as sta │ │ │ +0006dfe0: 7465 640a 0909 2f2f 2066 6f72 2069 676e ted...// for ign │ │ │ +0006dff0: 6f72 696e 6720 6269 6e64 2829 0a2f 2f09 oring bind().//. │ │ │ +0006e000: 096d 5f73 6f63 6b2e 6f70 656e 2870 2c20 .m_sock.open(p, │ │ │ +0006e010: 6563 293b 0a09 7d0a 0a23 6966 6e64 6566 ec);..}..#ifndef │ │ │ +0006e020: 2042 4f4f 5354 5f4e 4f5f 4558 4345 5054 BOOST_NO_EXCEPT │ │ │ +0006e030: 494f 4e53 0a09 766f 6964 2063 6c6f 7365 IONS..void close │ │ │ +0006e040: 2829 0a09 7b0a 0909 544f 5252 454e 545f ()..{...TORRENT_ │ │ │ +0006e050: 4153 5345 5254 286d 5f6d 6167 6963 203d ASSERT(m_magic = │ │ │ +0006e060: 3d20 3078 3133 3337 293b 0a09 096d 5f72 = 0x1337);...m_r │ │ │ +0006e070: 656d 6f74 655f 656e 6470 6f69 6e74 203d emote_endpoint = │ │ │ +0006e080: 2065 6e64 706f 696e 745f 7479 7065 2829 endpoint_type() │ │ │ +0006e090: 3b0a 0909 6d5f 736f 636b 2e63 6c6f 7365 ;...m_sock.close │ │ │ +0006e0a0: 2829 3b0a 0909 6d5f 7265 736f 6c76 6572 ();...m_resolver │ │ │ +0006e0b0: 2e63 616e 6365 6c28 293b 0a09 7d0a 2365 .cancel();..}.#e │ │ │ +0006e0c0: 6e64 6966 0a0a 0976 6f69 6420 636c 6f73 ndif...void clos │ │ │ +0006e0d0: 6528 6572 726f 725f 636f 6465 2661 6d70 e(error_code& │ │ │ +0006e0e0: 3b20 6563 290a 097b 0a09 0954 4f52 5245 ; ec)..{...TORRE │ │ │ +0006e0f0: 4e54 5f41 5353 4552 5428 6d5f 6d61 6769 NT_ASSERT(m_magi │ │ │ +0006e100: 6320 3d3d 2030 7831 3333 3729 3b0a 3c2f c == 0x1337);.r │ │ │ +0006e140: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +0006e150: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../incl │ │ │ +0006e180: 7564 652f 6c69 6274 6f72 7265 6e74 2f70 ude/libtorrent/p │ │ │ +0006e190: 6565 725f 636f 6e6e 6563 7469 6f6e 2e68 eer_connection.h │ │ │ +0006e1a0: 7070 3a32 3138 3c2f 613e 3c2f 7464 3e3c pp:218< │ │ │ +0006e1b0: 7464 3e6d 616b 6520 7468 6973 2061 2072 td>make this a r │ │ │ +0006e1c0: 6177 2070 6f69 6e74 6572 2028 746f 2073 aw pointer (to s │ │ │ +0006e1d0: 6176 6520 7369 7a65 2069 6e20 7468 6520 ave size in the │ │ │ +0006e1e0: 6669 7273 7420 6361 6368 6520 6c69 6e65 first cache line │ │ │ +0006e1f0: 2920 616e 6420 6d61 6b65 2074 6865 2063 ) and make the c │ │ │ +0006e200: 6f6e 7374 7275 6374 6f72 2074 616b 6520 onstructor take │ │ │ +0006e210: 6120 7261 7720 706f 696e 7465 722e 2074 a raw pointer. t │ │ │ +0006e220: 6f72 7265 6e74 206f 626a 6563 7473 2073 orrent objects s │ │ │ +0006e230: 686f 756c 6420 616c 7761 7973 206f 7574 hould always out │ │ │ +0006e240: 6c69 7665 2074 6865 6972 2070 6565 7273 live their peers │ │ │ +0006e250: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    ma │ │ │ +0006e2a0: 6b65 2074 6869 7320 6120 7261 7720 706f ke this a raw po │ │ │ +0006e2b0: 696e 7465 7220 2874 6f20 7361 7665 2073 inter (to save s │ │ │ +0006e2c0: 697a 6520 696e 0a74 6865 2066 6972 7374 ize in.the first │ │ │ +0006e2d0: 2063 6163 6865 206c 696e 6529 2061 6e64 cache line) and │ │ │ +0006e2e0: 206d 616b 6520 7468 6520 636f 6e73 7472 make the constr │ │ │ +0006e2f0: 7563 746f 720a 7461 6b65 2061 2072 6177 uctor.take a raw │ │ │ +0006e300: 2070 6f69 6e74 6572 2e20 746f 7272 656e pointer. torren │ │ │ +0006e310: 7420 6f62 6a65 6374 7320 7368 6f75 6c64 t objects should │ │ │ +0006e320: 2061 6c77 6179 730a 6f75 746c 6976 6520 always.outlive │ │ │ +0006e330: 7468 6569 7220 7065 6572 733c 2f68 323e their peers

    │ │ │ +0006e340: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ +0006e350: 6962 746f 7272 656e 742f 7065 6572 5f63 ibtorrent/peer_c │ │ │ +0006e360: 6f6e 6e65 6374 696f 6e2e 6870 703a 3231 onnection.hpp:21 │ │ │ +0006e370: 383c 2f68 343e 3c70 7265 2073 7479 6c65 8

    │ │ │ +0006e3b0: 0909 092c 206d 5f73 6e75 6262 6564 2866  ..., m_snubbed(f
    │ │ │ +0006e3c0: 616c 7365 290a 0909 092c 206d 5f69 6e74  alse)...., m_int
    │ │ │ +0006e3d0: 6572 6573 7469 6e67 2866 616c 7365 290a  eresting(false).
    │ │ │ +0006e3e0: 0909 092c 206d 5f63 686f 6b65 6428 7472  ..., m_choked(tr
    │ │ │ +0006e3f0: 7565 290a 0909 092c 206d 5f69 676e 6f72  ue)...., m_ignor
    │ │ │ +0006e400: 655f 7374 6174 7328 6661 6c73 6529 0a09  e_stats(false)..
    │ │ │ +0006e410: 097b 7d0a 0a09 092f 2f20 6578 706c 6963  .{}....// explic
    │ │ │ +0006e420: 6974 6c79 2064 6973 616c 6c6f 7720 6173  itly disallow as
    │ │ │ +0006e430: 7369 676e 6d65 6e74 2c20 746f 2073 696c  signment, to sil
    │ │ │ +0006e440: 656e 6365 206d 7376 6320 7761 726e 696e  ence msvc warnin
    │ │ │ +0006e450: 670a 0909 7065 6572 5f63 6f6e 6e65 6374  g...peer_connect
    │ │ │ +0006e460: 696f 6e5f 686f 745f 6d65 6d62 6572 7326  ion_hot_members&
    │ │ │ +0006e470: 616d 703b 206f 7065 7261 746f 723d 2870  amp; operator=(p
    │ │ │ +0006e480: 6565 725f 636f 6e6e 6563 7469 6f6e 5f68  eer_connection_h
    │ │ │ +0006e490: 6f74 5f6d 656d 6265 7273 2063 6f6e 7374  ot_members const
    │ │ │ +0006e4a0: 2661 6d70 3b29 203d 2064 656c 6574 653b  &) = delete;
    │ │ │ +0006e4b0: 0a0a 0970 726f 7465 6374 6564 3a0a 0a09  ...protected:...
    │ │ │ +0006e4c0: 092f 2f20 7468 6520 7069 6563 6573 2074  .// the pieces t
    │ │ │ +0006e4d0: 6865 206f 7468 6572 2065 6e64 2068 6176  he other end hav
    │ │ │ +0006e4e0: 650a 0909 7479 7065 645f 6269 7466 6965  e...typed_bitfie
    │ │ │ +0006e4f0: 6c64 266c 743b 7069 6563 655f 696e 6465  ld<piece_inde
    │ │ │ +0006e500: 785f 7426 6774 3b20 6d5f 6861 7665 5f70  x_t> m_have_p
    │ │ │ +0006e510: 6965 6365 3b0a 0a09 092f 2f20 7468 6973  iece;....// this
    │ │ │ +0006e520: 2069 7320 7468 6520 746f 7272 656e 7420   is the torrent 
    │ │ │ +0006e530: 7468 6973 2063 6f6e 6e65 6374 696f 6e20  this connection 
    │ │ │ +0006e540: 6973 0a09 092f 2f20 6173 736f 6369 6174  is...// associat
    │ │ │ +0006e550: 6564 2077 6974 682e 2049 6620 7468 6520  ed with. If the 
    │ │ │ +0006e560: 636f 6e6e 6563 7469 6f6e 2069 7320 616e  connection is an
    │ │ │ +0006e570: 0a09 092f 2f20 696e 636f 6d69 6e67 2063  ...// incoming c
    │ │ │ +0006e580: 6f6e 6e65 6374 696f 6e2c 2074 6869 7320  onnection, this 
    │ │ │ +0006e590: 6973 2073 6574 2074 6f20 7a65 726f 0a09  is set to zero..
    │ │ │ +0006e5a0: 092f 2f20 756e 7469 6c20 7468 6520 696e  .// until the in
    │ │ │ +0006e5b0: 666f 5f68 6173 6820 6973 2072 6563 6569  fo_hash is recei
    │ │ │ +0006e5c0: 7665 642e 2054 6865 6e20 6974 2773 0a09  ved. Then it's..
    │ │ │ +0006e5d0: 092f 2f20 7365 7420 746f 2074 6865 2074  .// set to the t
    │ │ │ +0006e5e0: 6f72 7265 6e74 2069 7420 6265 6c6f 6e67  orrent it belong
    │ │ │ +0006e5f0: 7320 746f 2e0a 0a3c 6469 7620 7374 796c  s to...
    ..std::weak │ │ │ +0006e630: 5f70 7472 266c 743b 746f 7272 656e 7426 _ptr<torrent& │ │ │ +0006e640: 6774 3b20 6d5f 746f 7272 656e 743b 0a3c gt; m_torrent;.< │ │ │ +0006e650: 2f64 6976 3e0a 0970 7562 6c69 633a 0a0a /div>..public:.. │ │ │ +0006e660: 0909 2f2f 2061 2062 6163 6b20 7265 6665 ..// a back refe │ │ │ +0006e670: 7265 6e63 6520 746f 2074 6865 2073 6573 rence to the ses │ │ │ +0006e680: 7369 6f6e 0a09 092f 2f20 7468 6520 7065 sion...// the pe │ │ │ +0006e690: 6572 2062 656c 6f6e 6773 2074 6f2e 0a09 er belongs to... │ │ │ +0006e6a0: 0961 7578 3a3a 7365 7373 696f 6e5f 696e .aux::session_in │ │ │ +0006e6b0: 7465 7266 6163 6526 616d 703b 206d 5f73 terface& m_s │ │ │ +0006e6c0: 6573 3b0a 0a09 092f 2f20 7365 7474 696e es;....// settin │ │ │ +0006e6d0: 6773 2074 6861 7420 6170 706c 7920 746f gs that apply to │ │ │ +0006e6e0: 2074 6869 7320 7065 6572 0a09 0961 7578 this peer...aux │ │ │ +0006e6f0: 3a3a 7365 7373 696f 6e5f 7365 7474 696e ::session_settin │ │ │ +0006e700: 6773 2063 6f6e 7374 2661 6d70 3b20 6d5f gs const& m_ │ │ │ +0006e710: 7365 7474 696e 6773 3b0a 0a09 7072 6f74 settings;...prot │ │ │ +0006e720: 6563 7465 643a 0a0a 0909 2f2f 2074 6869 ected:....// thi │ │ │ +0006e730: 7320 6973 2074 7275 6520 6966 2074 6869 s is true if thi │ │ │ +0006e740: 7320 636f 6e6e 6563 7469 6f6e 2068 6173 s connection has │ │ │ +0006e750: 2062 6565 6e20 6164 6465 640a 0909 2f2f been added...// │ │ │ +0006e760: 2074 6f20 7468 6520 6c69 7374 206f 6620 to the list of │ │ │ +0006e770: 636f 6e6e 6563 7469 6f6e 7320 7468 6174 connections that │ │ │ +0006e780: 2077 696c 6c20 6265 2063 6c6f 7365 642e will be closed. │ │ │ +0006e790: 0a09 0962 6f6f 6c20 6d5f 6469 7363 6f6e ...bool m_discon │ │ │ +0006e7a0: 6e65 6374 696e 673a 313b 0a0a 0909 2f2f necting:1;....// │ │ │ +0006e7b0: 2074 6869 7320 6973 2074 7275 6520 756e this is true un │ │ │ +0006e7c0: 7469 6c20 7468 6973 2073 6f63 6b65 7420 til this socket │ │ │ +0006e7d0: 6861 7320 6265 636f 6d65 0a09 092f 2f20 has become...// │ │ │ +0006e7e0: 7772 6974 6162 6c65 2066 6f72 2074 6865 writable for the │ │ │ +0006e7f0: 2066 6972 7374 2074 696d 6520 2869 2e65 first time (i.e │ │ │ +0006e800: 2e20 7468 650a 0909 2f2f 2063 6f6e 6e65 . the...// conne │ │ │ +0006e810: 6374 696f 6e20 636f 6d70 6c65 7465 6429 ction completed) │ │ │ +0006e820: 2e20 5768 696c 6520 636f 6e6e 6563 7469 . While connecti │ │ │ +0006e830: 6e67 0a09 092f 2f20 7468 6520 7469 6d65 ng...// the time │ │ │ +0006e840: 6f75 7420 7769 6c6c 206e 6f74 2062 6520 out will not be │ │ │ +0006e850: 7472 6967 6765 7265 642e 2054 6869 7320 triggered. This │ │ │ +0006e860: 6973 0a09 092f 2f20 6265 6361 7573 6520 is...// because │ │ │ +0006e870: 7769 6e64 6f77 7320 5850 2053 5032 206d windows XP SP2 m │ │ │ +0006e880: 6179 2064 656c 6179 2063 6f6e 6e65 6374 ay delay connect │ │ │ +0006e890: 696f 6e0a 0909 2f2f 2061 7474 656d 7074 ion...// attempt │ │ │ +0006e8a0: 732c 2077 6869 6368 206d 6561 6e73 2074 s, which means t │ │ │ +0006e8b0: 6861 7420 7468 6520 636f 6e6e 6563 7469 hat the connecti │ │ │ +0006e8c0: 6f6e 0a09 092f 2f20 6d61 7920 6e6f 7420 on...// may not │ │ │ +0006e8d0: 6576 656e 2068 6176 6520 6265 656e 2061 even have been a │ │ │ +0006e8e0: 7474 656d 7074 6564 2077 6865 6e20 7468 ttempted when th │ │ │ +0006e8f0: 650a 0909 2f2f 2074 696d 6520 6f75 7420 e...// time out │ │ │ +0006e900: 6973 2072 6561 6368 6564 2e0a 0909 626f is reached....bo │ │ │ +0006e910: 6f6c 206d 5f63 6f6e 6e65 6374 696e 673a ol m_connecting: │ │ │ +0006e920: 313b 0a0a 0909 2f2f 2074 6869 7320 6973 1;....// this is │ │ │ +0006e930: 2073 6574 2074 6f20 7472 7565 2069 6620 set to true if │ │ │ +0006e940: 7468 6520 6c61 7374 2074 696d 6520 7765 the last time we │ │ │ +0006e950: 2074 7269 6564 2074 6f0a 0909 2f2f 2070 tried to...// p │ │ │ +0006e960: 6963 6b20 6120 7069 6563 6520 746f 2064 ick a piece to d │ │ │ +0006e970: 6f77 6e6c 6f61 642c 2077 6520 636f 756c ownload, we coul │ │ │ +0006e980: 6420 6f6e 6c79 2066 696e 640a 0909 2f2f d only find...// │ │ │ +0006e990: 2062 6c6f 636b 7320 7468 6174 2077 6572 blocks that wer │ │ │ +0006e9a0: 6520 616c 7265 6164 7920 7265 7175 6573 e already reques │ │ │ +0006e9b0: 7465 6420 6672 6f6d 206f 7468 6572 0a09 ted from other.. │ │ │ +0006e9c0: 092f 2f20 7065 6572 732e 2049 6e20 7468 .// peers. In th │ │ │ +0006e9d0: 6973 2063 6173 652c 2077 6520 7368 6f75 is case, we shou │ │ │ +0006e9e0: 6c64 206e 6f74 2074 7279 2074 6f20 7069 ld not try to pi │ │ │ +0006e9f0: 636b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f ck.
    │ │ │ +0006ea20: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +0006ea30: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +0006ea60: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ +0006ea70: 656e 742f 7065 6572 5f63 6f6e 6e65 6374 ent/peer_connect │ │ │ +0006ea80: 696f 6e2e 6870 703a 3130 3236 3c2f 613e ion.hpp:1026 │ │ │ +0006ea90: 3c2f 7464 3e3c 7464 3e66 6163 746f 7220 factor │ │ │ +0006eaa0: 7468 6973 206f 7574 2069 6e74 6f20 6974 this out into it │ │ │ +0006eab0: 7320 6f77 6e20 636c 6173 7320 7769 7468 s own class with │ │ │ +0006eac0: 2061 2076 6972 7475 616c 2069 6e74 6572 a virtual inter │ │ │ +0006ead0: 6661 6365 2074 6f72 7265 6e74 2061 6e64 face torrent and │ │ │ +0006eae0: 2073 6573 7369 6f6e 2073 686f 756c 6420 session should │ │ │ +0006eaf0: 696d 706c 656d 656e 7420 7468 6973 2069 implement this i │ │ │ +0006eb00: 6e74 6572 6661 6365 3c2f 7464 3e3c 2f74 nterface

    factor thi │ │ │ +0006eb60: 7320 6f75 7420 696e 746f 2069 7473 206f s out into its o │ │ │ +0006eb70: 776e 2063 6c61 7373 2077 6974 6820 6120 wn class with a │ │ │ +0006eb80: 7669 7274 7561 6c20 696e 7465 7266 6163 virtual interfac │ │ │ +0006eb90: 650a 746f 7272 656e 7420 616e 6420 7365 e.torrent and se │ │ │ +0006eba0: 7373 696f 6e20 7368 6f75 6c64 2069 6d70 ssion should imp │ │ │ +0006ebb0: 6c65 6d65 6e74 2074 6869 7320 696e 7465 lement this inte │ │ │ +0006ebc0: 7266 6163 653c 2f68 323e 3c68 343e 2e2e rface

    .. │ │ │ +0006ebd0: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ +0006ebe0: 656e 742f 7065 6572 5f63 6f6e 6e65 6374 ent/peer_connect │ │ │ +0006ebf0: 696f 6e2e 6870 703a 3130 3236 3c2f 6834 ion.hpp:1026

    ...//
    │ │ │ +0006ec40: 2074 6865 206c 6f63 616c 2065 6e64 706f   the local endpo
    │ │ │ +0006ec50: 696e 7420 666f 7220 7468 6973 2070 6565  int for this pee
    │ │ │ +0006ec60: 722c 2069 2e65 2e20 6f75 7220 6164 6472  r, i.e. our addr
    │ │ │ +0006ec70: 6573 730a 0909 2f2f 2061 6e64 206f 7572  ess...// and our
    │ │ │ +0006ec80: 2070 6f72 742e 2049 6620 7468 6973 2069   port. If this i
    │ │ │ +0006ec90: 7320 7365 7420 666f 7220 6f75 7467 6f69  s set for outgoi
    │ │ │ +0006eca0: 6e67 2063 6f6e 6e65 6374 696f 6e73 0a09  ng connections..
    │ │ │ +0006ecb0: 092f 2f20 6265 666f 7265 2074 6865 2063  .// before the c
    │ │ │ +0006ecc0: 6f6e 6e65 6374 696f 6e20 636f 6d70 6c65  onnection comple
    │ │ │ +0006ecd0: 7465 732c 2069 7420 6d65 616e 7320 7765  tes, it means we
    │ │ │ +0006ece0: 2077 616e 7420 746f 0a09 092f 2f20 666f   want to...// fo
    │ │ │ +0006ecf0: 7263 6520 7468 6520 636f 6e6e 6563 7469  rce the connecti
    │ │ │ +0006ed00: 6f6e 2074 6f20 6265 2062 6f75 6e64 2074  on to be bound t
    │ │ │ +0006ed10: 6f20 7468 6520 7370 6563 6966 6965 6420  o the specified 
    │ │ │ +0006ed20: 696e 7465 7266 6163 652e 0a09 092f 2f20  interface....// 
    │ │ │ +0006ed30: 6966 2069 7420 656e 6473 2075 7020 6265  if it ends up be
    │ │ │ +0006ed40: 696e 6720 626f 756e 6420 746f 2061 2064  ing bound to a d
    │ │ │ +0006ed50: 6966 6665 7265 6e74 206c 6f63 616c 2049  ifferent local I
    │ │ │ +0006ed60: 502c 2074 6865 2063 6f6e 6e65 6374 696f  P, the connectio
    │ │ │ +0006ed70: 6e0a 0909 2f2f 2069 7320 636c 6f73 6564  n...// is closed
    │ │ │ +0006ed80: 2e0a 0909 7463 703a 3a65 6e64 706f 696e  ....tcp::endpoin
    │ │ │ +0006ed90: 7420 6d5f 6c6f 6361 6c3b 0a0a 0909 2f2f  t m_local;....//
    │ │ │ +0006eda0: 2072 656d 6f74 6520 7065 6572 2773 2069   remote peer's i
    │ │ │ +0006edb0: 640a 0909 7065 6572 5f69 6420 6d5f 7065  d...peer_id m_pe
    │ │ │ +0006edc0: 6572 5f69 643b 0a0a 0970 726f 7465 6374  er_id;...protect
    │ │ │ +0006edd0: 6564 3a0a 0a09 0974 656d 706c 6174 6520  ed:....template 
    │ │ │ +0006ede0: 266c 743b 7479 7065 6e61 6d65 2046 756e  <typename Fun
    │ │ │ +0006edf0: 2c20 7479 7065 6e61 6d65 2e2e 2e20 4172  , typename... Ar
    │ │ │ +0006ee00: 6773 2667 743b 0a09 0976 6f69 6420 7772  gs>...void wr
    │ │ │ +0006ee10: 6170 2846 756e 2066 2c20 4172 6773 2661  ap(Fun f, Args&a
    │ │ │ +0006ee20: 6d70 3b26 616d 703b 2e2e 2e20 6129 3b0a  mp;&... a);.
    │ │ │ +0006ee30: 0a09 092f 2f20 7374 6174 6973 7469 6373  ...// statistics
    │ │ │ +0006ee40: 2061 626f 7574 2075 706c 6f61 6420 616e   about upload an
    │ │ │ +0006ee50: 6420 646f 776e 6c6f 6164 2073 7065 6564  d download speed
    │ │ │ +0006ee60: 730a 0909 2f2f 2061 6e64 2074 6f74 616c  s...// and total
    │ │ │ +0006ee70: 2061 6d6f 756e 7420 6f66 2075 706c 6f61   amount of uploa
    │ │ │ +0006ee80: 6473 2061 6e64 2064 6f77 6e6c 6f61 6473  ds and downloads
    │ │ │ +0006ee90: 2066 6f72 0a09 092f 2f20 7468 6973 2070   for...// this p
    │ │ │ +0006eea0: 6565 720a 3c64 6976 2073 7479 6c65 3d22  eer.
    ..stat m_stati │ │ │ +0006eee0: 7374 6963 733b 0a3c 2f64 6976 3e0a 0909 stics;.
    ... │ │ │ +0006eef0: 2f2f 2074 6865 206e 756d 6265 7220 6f66 // the number of │ │ │ +0006ef00: 206f 7574 7374 616e 6469 6e67 2062 7974 outstanding byt │ │ │ +0006ef10: 6573 2065 7870 6563 7465 640a 0909 2f2f es expected...// │ │ │ +0006ef20: 2074 6f20 6265 2072 6563 6569 7665 6420 to be received │ │ │ +0006ef30: 6279 2065 7874 656e 7369 6f6e 730a 0909 by extensions... │ │ │ +0006ef40: 696e 7420 6d5f 6578 7465 6e73 696f 6e5f int m_extension_ │ │ │ +0006ef50: 6f75 7473 7461 6e64 696e 675f 6279 7465 outstanding_byte │ │ │ +0006ef60: 7320 3d20 303b 0a0a 0909 2f2f 2074 6865 s = 0;....// the │ │ │ +0006ef70: 206e 756d 6265 7220 6f66 2074 696d 6520 number of time │ │ │ +0006ef80: 6372 6974 6963 616c 2072 6571 7565 7374 critical request │ │ │ +0006ef90: 730a 0909 2f2f 2071 7565 7565 6420 7570 s...// queued up │ │ │ +0006efa0: 2069 6e20 7468 6520 6d5f 7265 7175 6573 in the m_reques │ │ │ +0006efb0: 745f 7175 6575 6520 7468 6174 0a09 092f t_queue that.../ │ │ │ +0006efc0: 2f20 736f 6f6e 2077 696c 6c20 6265 2063 / soon will be c │ │ │ +0006efd0: 6f6d 6d69 7474 6564 2074 6f20 7468 6520 ommitted to the │ │ │ +0006efe0: 646f 776e 6c6f 6164 0a09 092f 2f20 7175 download...// qu │ │ │ +0006eff0: 6575 652e 2054 6869 7320 6973 2069 6e63 eue. This is inc │ │ │ +0006f000: 6c75 6465 6420 696e 2064 6f77 6e6c 6f61 luded in downloa │ │ │ +0006f010: 645f 7175 6575 655f 7469 6d65 2829 0a09 d_queue_time().. │ │ │ +0006f020: 092f 2f20 736f 2074 6861 7420 6974 2063 .// so that it c │ │ │ +0006f030: 616e 2062 6520 7573 6564 2077 6869 6c65 an be used while │ │ │ +0006f040: 2061 6464 696e 6720 6d6f 7265 0a09 092f adding more.../ │ │ │ +0006f050: 2f20 7265 7175 6573 7473 2061 6e64 2074 / requests and t │ │ │ +0006f060: 616b 6520 7468 6520 7072 6576 696f 7573 ake the previous │ │ │ +0006f070: 2072 6571 7565 7374 730a 0909 2f2f 2069 requests...// i │ │ │ +0006f080: 6e74 6f20 6163 636f 756e 7420 7769 7468 nto account with │ │ │ +0006f090: 6f75 7420 7375 626d 6974 7469 6e67 2069 out submitting i │ │ │ +0006f0a0: 7420 616c 6c0a 0909 2f2f 2069 6d6d 6564 t all...// immed │ │ │ +0006f0b0: 6961 7465 6c79 0a09 0973 7464 3a3a 7569 iately...std::ui │ │ │ +0006f0c0: 6e74 3136 5f74 206d 5f71 7565 7565 645f nt16_t m_queued_ │ │ │ +0006f0d0: 7469 6d65 5f63 7269 7469 6361 6c20 3d20 time_critical = │ │ │ +0006f0e0: 303b 0a0a 0909 2f2f 2074 6865 206e 756d 0;....// the num │ │ │ +0006f0f0: 6265 7220 6f66 2062 7974 6573 2077 6520 ber of bytes we │ │ │ +0006f100: 6172 6520 6375 7272 656e 746c 7920 7265 are currently re │ │ │ +0006f110: 6164 696e 670a 0909 2f2f 2066 726f 6d20 ading...// from │ │ │ +0006f120: 6469 736b 2c20 7468 6174 2077 696c 6c20 disk, that will │ │ │ +0006f130: 6265 2061 6464 6564 2074 6f20 7468 6520 be added to the │ │ │ +0006f140: 7365 6e64 0a09 092f 2f20 6275 6666 6572 send...// buffer │ │ │ +0006f150: 2061 7320 736f 6f6e 2061 7320 7468 6579 as soon as they │ │ │ +0006f160: 2063 6f6d 706c 6574 650a 0909 696e 7420 complete...int │ │ │ +0006f170: 6d5f 7265 6164 696e 675f 6279 7465 7320 m_reading_bytes │ │ │ +0006f180: 3d20 303b 0a0a 0909 2f2f 206f 7074 696f = 0;....// optio │ │ │ +0006f190: 6e73 2075 7365 6420 666f 7220 7468 6520 ns used for the │ │ │ +0006f1a0: 7069 6563 6520 7069 636b 6572 2e20 5468 piece picker. Th │ │ │ +0006f1b0: 6573 6520 666c 6167 7320 7769 6c6c 0a09 ese flags will.. │ │ │ +0006f1c0: 092f 2f20 6265 2061 7567 6d65 6e74 6564 .// be augmented │ │ │ +0006f1d0: 2077 6974 6820 666c 6167 7320 636f 6e74 with flags cont │ │ │ +0006f1e0: 726f 6c6c 6564 2062 7920 6f74 6865 7220 rolled by other │ │ │ +0006f1f0: 7365 7474 696e 6773 0a09 092f 2f20 6c69 settings...// li │ │ │ +0006f200: 6b65 2073 6571 7565 6e74 6961 6c20 646f ke sequential do │ │ │ +0006f210: 776e 6c6f 6164 2065 7463 2e20 5468 6573 wnload etc. Thes │ │ │ +0006f220: 6520 6172 6520 6865 7265 2074 6f0a 0909 e are here to... │ │ │ +0006f230: 2f2f 206c 6574 2070 6c75 6769 6e73 2063 // let plugins c │ │ │ +0006f240: 6f6e 7472 6f6c 2066 6c61 6773 2074 6861 ontrol flags tha │ │ │ +0006f250: 7420 7368 6f75 6c64 2061 6c77 6179 7320 t should always │ │ │ +0006f260: 6265 2073 6574 0a09 0970 6963 6b65 725f be set...picker_ │ │ │ +0006f270: 6f70 7469 6f6e 735f 7420 6d5f 7069 636b options_t m_pick │ │ │ +0006f280: 6572 5f6f 7074 696f 6e73 7b7d 3b0a 0a09 er_options{};... │ │ │ +0006f290: 092f 2f20 7468 6520 6e75 6d62 6572 206f .// the number o │ │ │ +0006f2a0: 6620 696e 7661 6c69 6420 7069 6563 652d f invalid piece- │ │ │ +0006f2b0: 7265 7175 6573 7473 0a09 092f 2f20 7765 requests...// we │ │ │ +0006f2c0: 2068 6176 6520 676f 7420 6672 6f6d 2074 have got from t │ │ │ +0006f2d0: 6869 7320 7065 6572 2e20 4966 2074 6865 his peer. If the │ │ │ +0006f2e0: 2072 6571 7565 7374 0a09 092f 2f20 7175 request...// qu │ │ │ +0006f2f0: 6575 6520 6765 7473 2065 6d70 7479 2c20 eue gets empty, │ │ │ +0006f300: 616e 6420 7468 6572 6520 6861 7665 2062 and there have b │ │ │ +0006f310: 6565 6e0a 0909 2f2f 2069 6e76 616c 6964 een...// invalid │ │ │ +0006f320: 2072 6571 7565 7374 732c 2077 6520 6361 requests, we ca │ │ │ +0006f330: 6e20 6173 7375 6d65 2074 6865 0a3c 2f70 n assume the.

    re │ │ │ +0006f370: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../inclu │ │ │ +0006f3b0: 6465 2f6c 6962 746f 7272 656e 742f 746f de/libtorrent/to │ │ │ +0006f3c0: 7272 656e 745f 696e 666f 2e68 7070 3a37 rrent_info.hpp:7 │ │ │ +0006f3d0: 3538 3c2f 613e 3c2f 7464 3e3c 7464 3e63 58c │ │ │ +0006f3e0: 6861 6e67 6520 7468 6520 7479 7065 2074 hange the type t │ │ │ +0006f3f0: 6f20 7374 643a 3a73 6861 7265 645f 7074 o std::shared_pt │ │ │ +0006f400: 723c 6368 6172 2063 6f6e 7374 3e20 696e r in │ │ │ +0006f410: 2043 2b2b 3137 2069 7420 6973 2075 7365 C++17 it is use │ │ │ +0006f420: 6420 6173 2069 6620 696d 6d75 7461 626c d as if immutabl │ │ │ +0006f430: 652c 2069 7420 6361 6e6e 6f74 2062 6520 e, it cannot be │ │ │ +0006f440: 636f 6e73 7420 666f 7220 7465 6368 6e69 const for techni │ │ │ +0006f450: 6361 6c20 7265 6173 6f6e 7320 7269 6768 cal reasons righ │ │ │ +0006f460: 7420 6e6f 772e 3c2f 7464 3e3c 2f74 723e t now. │ │ │ +0006f470: 3c74 7220 6964 3d22 3235 3322 2073 7479 │ │ │ +0006f4a0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0006f4b0: 3c68 323e 6368 616e 6765 2074 6865 2074

    change the t │ │ │ +0006f4c0: 7970 6520 746f 2073 7464 3a3a 7368 6172 ype to std::shar │ │ │ +0006f4d0: 6564 5f70 7472 3c63 6861 7220 636f 6e73 ed_ptr in C++17.it i │ │ │ +0006f4f0: 7320 7573 6564 2061 7320 6966 2069 6d6d s used as if imm │ │ │ +0006f500: 7574 6162 6c65 2c20 6974 2063 616e 6e6f utable, it canno │ │ │ +0006f510: 7420 6265 2063 6f6e 7374 2066 6f72 2074 t be const for t │ │ │ +0006f520: 6563 686e 6963 616c 2072 6561 736f 6e73 echnical reasons │ │ │ +0006f530: 0a72 6967 6874 206e 6f77 2e3c 2f68 323e .right now.

    │ │ │ +0006f540: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ +0006f550: 6962 746f 7272 656e 742f 746f 7272 656e ibtorrent/torren │ │ │ +0006f560: 745f 696e 666f 2e68 7070 3a37 3538 3c2f t_info.hpp:758
    ...
    │ │ │ +0006f5b0: 2f2f 2074 6865 7365 2061 7265 2074 6865  // these are the
    │ │ │ +0006f5c0: 2063 6f6c 6c65 6374 696f 6e73 2066 726f   collections fro
    │ │ │ +0006f5d0: 6d20 6f75 7473 6964 6520 6f66 2074 6865  m outside of the
    │ │ │ +0006f5e0: 2069 6e66 6f2d 6469 6374 2e20 5468 6573   info-dict. Thes
    │ │ │ +0006f5f0: 6520 6172 650a 0909 2f2f 206f 776e 696e  e are...// ownin
    │ │ │ +0006f600: 6720 7374 7269 6e67 732c 2073 696e 6365  g strings, since
    │ │ │ +0006f610: 2077 6520 6f6e 6c79 206b 6565 7020 7468   we only keep th
    │ │ │ +0006f620: 6520 696e 666f 2d73 6563 7469 6f6e 2061  e info-section a
    │ │ │ +0006f630: 726f 756e 642c 2074 6865 7365 0a09 092f  round, these.../
    │ │ │ +0006f640: 2f20 6361 6e6e 6f74 2062 6520 706f 696e  / cannot be poin
    │ │ │ +0006f650: 7465 7273 2069 6e74 6f20 7468 6174 2062  ters into that b
    │ │ │ +0006f660: 7566 6665 722e 0a09 0973 7464 3a3a 7665  uffer....std::ve
    │ │ │ +0006f670: 6374 6f72 266c 743b 7374 643a 3a73 7472  ctor<std::str
    │ │ │ +0006f680: 696e 6726 6774 3b20 6d5f 6f77 6e65 645f  ing> m_owned_
    │ │ │ +0006f690: 636f 6c6c 6563 7469 6f6e 733b 0a0a 2369  collections;..#i
    │ │ │ +0006f6a0: 6620 544f 5252 454e 545f 4142 495f 5645  f TORRENT_ABI_VE
    │ │ │ +0006f6b0: 5253 494f 4e20 266c 743b 3d20 320a 0909  RSION <= 2...
    │ │ │ +0006f6c0: 2f2f 2069 6620 7468 6973 2069 7320 6120  // if this is a 
    │ │ │ +0006f6d0: 6d65 726b 6c65 2074 6f72 7265 6e74 2c20  merkle torrent, 
    │ │ │ +0006f6e0: 7468 6973 2069 7320 7468 6520 6d65 726b  this is the merk
    │ │ │ +0006f6f0: 6c65 0a09 092f 2f20 7472 6565 2e20 4974  le...// tree. It
    │ │ │ +0006f700: 2068 6173 2073 7061 6365 2066 6f72 206d   has space for m
    │ │ │ +0006f710: 6572 6b6c 655f 6e75 6d5f 6e6f 6465 7328  erkle_num_nodes(
    │ │ │ +0006f720: 6d65 726b 6c65 5f6e 756d 5f6c 6561 6673  merkle_num_leafs
    │ │ │ +0006f730: 286e 756d 5f70 6965 6365 7329 290a 0909  (num_pieces))...
    │ │ │ +0006f740: 2f2f 2068 6173 6865 730a 0909 6175 783a  // hashes...aux:
    │ │ │ +0006f750: 3a76 6563 746f 7226 6c74 3b73 6861 315f  :vector<sha1_
    │ │ │ +0006f760: 6861 7368 2667 743b 206d 5f6d 6572 6b6c  hash> m_merkl
    │ │ │ +0006f770: 655f 7472 6565 3b0a 2365 6e64 6966 0a0a  e_tree;.#endif..
    │ │ │ +0006f780: 0909 2f2f 2076 3220 6d65 726b 6c65 2074  ..// v2 merkle t
    │ │ │ +0006f790: 7265 6520 666f 7220 6561 6368 2066 696c  ree for each fil
    │ │ │ +0006f7a0: 650a 0909 2f2f 2074 6865 2061 6374 7561  e...// the actua
    │ │ │ +0006f7b0: 6c20 6861 7368 2062 7566 6665 7273 2061  l hash buffers a
    │ │ │ +0006f7c0: 7265 2061 6c77 6179 7320 6469 7669 7369  re always divisi
    │ │ │ +0006f7d0: 626c 6520 6279 2033 3220 2873 6861 3235  ble by 32 (sha25
    │ │ │ +0006f7e0: 365f 6861 7368 3a3a 7369 7a65 2829 290a  6_hash::size()).
    │ │ │ +0006f7f0: 0909 6175 783a 3a76 6563 746f 7226 6c74  ..aux::vector<
    │ │ │ +0006f800: 3b61 7578 3a3a 7665 6374 6f72 266c 743b  ;aux::vector<
    │ │ │ +0006f810: 6368 6172 2667 743b 2c20 6669 6c65 5f69  char>, file_i
    │ │ │ +0006f820: 6e64 6578 5f74 2667 743b 206d 5f70 6965  ndex_t> m_pie
    │ │ │ +0006f830: 6365 5f6c 6179 6572 733b 0a0a 0909 2f2f  ce_layers;....//
    │ │ │ +0006f840: 2074 6869 7320 6973 2061 2063 6f70 7920   this is a copy 
    │ │ │ +0006f850: 6f66 2074 6865 2069 6e66 6f20 7365 6374  of the info sect
    │ │ │ +0006f860: 696f 6e20 6672 6f6d 2074 6865 2074 6f72  ion from the tor
    │ │ │ +0006f870: 7265 6e74 2e0a 0909 2f2f 2069 7420 7573  rent....// it us
    │ │ │ +0006f880: 6520 6d61 696e 7461 696e 6564 2069 6e20  e maintained in 
    │ │ │ +0006f890: 7468 6973 2066 6c61 7420 666f 726d 6174  this flat format
    │ │ │ +0006f8a0: 2069 6e20 6f72 6465 7220 746f 0a09 092f   in order to.../
    │ │ │ +0006f8b0: 2f20 6d61 6b65 2069 7420 6176 6169 6c61  / make it availa
    │ │ │ +0006f8c0: 626c 6520 7468 726f 7567 6820 7468 6520  ble through the 
    │ │ │ +0006f8d0: 6d65 7461 6461 7461 2065 7874 656e 7369  metadata extensi
    │ │ │ +0006f8e0: 6f6e 0a3c 6469 7620 7374 796c 653d 2262  on.
    ..boost::shared │ │ │ +0006f920: 5f61 7272 6179 266c 743b 6368 6172 2667 _array<char&g │ │ │ +0006f930: 743b 206d 5f69 6e66 6f5f 7365 6374 696f t; m_info_sectio │ │ │ +0006f940: 6e3b 0a3c 2f64 6976 3e0a 0909 2f2f 2069 n;.
    ...// i │ │ │ +0006f950: 6620 6120 636f 6d6d 656e 7420 6973 2066 f a comment is f │ │ │ +0006f960: 6f75 6e64 2069 6e20 7468 6520 746f 7272 ound in the torr │ │ │ +0006f970: 656e 7420 6669 6c65 0a09 092f 2f20 7468 ent file...// th │ │ │ +0006f980: 6973 2077 696c 6c20 6265 2073 6574 2074 is will be set t │ │ │ +0006f990: 6f20 7468 6174 2063 6f6d 6d65 6e74 0a09 o that comment.. │ │ │ +0006f9a0: 0973 7464 3a3a 7374 7269 6e67 206d 5f63 .std::string m_c │ │ │ +0006f9b0: 6f6d 6d65 6e74 3b0a 0a09 092f 2f20 616e omment;....// an │ │ │ +0006f9c0: 206f 7074 696f 6e61 6c20 7374 7269 6e67 optional string │ │ │ +0006f9d0: 206e 616d 696e 6720 7468 6520 736f 6674 naming the soft │ │ │ +0006f9e0: 7761 7265 2075 7365 640a 0909 2f2f 2074 ware used...// t │ │ │ +0006f9f0: 6f20 6372 6561 7465 2074 6865 2074 6f72 o create the tor │ │ │ +0006fa00: 7265 6e74 2066 696c 650a 0909 7374 643a rent file...std: │ │ │ +0006fa10: 3a73 7472 696e 6720 6d5f 6372 6561 7465 :string m_create │ │ │ +0006fa20: 645f 6279 3b0a 0a09 092f 2f20 7468 6520 d_by;....// the │ │ │ +0006fa30: 696e 666f 2073 6563 7469 6f6e 2070 6172 info section par │ │ │ +0006fa40: 7365 642e 2070 6f69 6e74 7320 696e 746f sed. points into │ │ │ +0006fa50: 206d 5f69 6e66 6f5f 7365 6374 696f 6e0a m_info_section. │ │ │ +0006fa60: 0909 2f2f 2070 6172 7365 6420 6c61 7a69 ..// parsed lazi │ │ │ +0006fa70: 6c79 0a09 096d 7574 6162 6c65 2062 6465 ly...mutable bde │ │ │ +0006fa80: 636f 6465 5f6e 6f64 6520 6d5f 696e 666f code_node m_info │ │ │ +0006fa90: 5f64 6963 743b 0a0a 0909 2f2f 2069 6620 _dict;....// if │ │ │ +0006faa0: 6120 6372 6561 7469 6f6e 2064 6174 6520 a creation date │ │ │ +0006fab0: 6973 2066 6f75 6e64 2069 6e20 7468 6520 is found in the │ │ │ +0006fac0: 746f 7272 656e 7420 6669 6c65 0a09 092f torrent file.../ │ │ │ +0006fad0: 2f20 7468 6973 2077 696c 6c20 6265 2073 / this will be s │ │ │ +0006fae0: 6574 2074 6f20 7468 6174 2c20 6f74 6865 et to that, othe │ │ │ +0006faf0: 7277 6973 6520 6974 276c 6c20 6265 0a09 rwise it'll be.. │ │ │ +0006fb00: 092f 2f20 3139 3730 2c20 4a61 6e20 310a .// 1970, Jan 1. │ │ │ +0006fb10: 0909 7374 643a 3a74 696d 655f 7420 6d5f ..std::time_t m_ │ │ │ +0006fb20: 6372 6561 7469 6f6e 5f64 6174 6520 3d20 creation_date = │ │ │ +0006fb30: 303b 0a0a 0909 2f2f 2074 6865 2068 6173 0;....// the has │ │ │ +0006fb40: 6828 6573 2920 7468 6174 2069 6465 6e74 h(es) that ident │ │ │ +0006fb50: 6966 7920 7468 6973 2074 6f72 7265 6e74 ify this torrent │ │ │ +0006fb60: 0a09 0969 6e66 6f5f 6861 7368 5f74 206d ...info_hash_t m │ │ │ +0006fb70: 5f69 6e66 6f5f 6861 7368 3b0a 0a09 092f _info_hash;..../ │ │ │ +0006fb80: 2f20 7468 6973 2069 7320 7468 6520 6f66 / this is the of │ │ │ +0006fb90: 6673 6574 2069 6e74 6f20 7468 6520 6d5f fset into the m_ │ │ │ +0006fba0: 696e 666f 5f73 6563 7469 6f6e 2062 7566 info_section buf │ │ │ +0006fbb0: 6665 7220 746f 2074 6865 2066 6972 7374 fer to the first │ │ │ +0006fbc0: 2062 7974 6520 6f66 0a09 092f 2f20 7468 byte of...// th │ │ │ +0006fbd0: 6520 6669 7273 7420 5348 412d 3120 6861 e first SHA-1 ha │ │ │ +0006fbe0: 7368 0a09 0973 7464 3a3a 696e 7433 325f sh...std::int32_ │ │ │ +0006fbf0: 7420 6d5f 7069 6563 655f 6861 7368 6573 t m_piece_hashes │ │ │ +0006fc00: 203d 2030 3b0a 0a09 092f 2f20 7468 6520 = 0;....// the │ │ │ +0006fc10: 6e75 6d62 6572 206f 6620 6279 7465 7320 number of bytes │ │ │ +0006fc20: 696e 206d 5f69 6e66 6f5f 7365 6374 696f in m_info_sectio │ │ │ +0006fc30: 6e0a 0909 7374 643a 3a69 6e74 3332 5f74 n...std::int32_t │ │ │ +0006fc40: 206d 5f69 6e66 6f5f 7365 6374 696f 6e5f m_info_section_ │ │ │ +0006fc50: 7369 7a65 203d 2030 3b0a 0a09 092f 2f20 size = 0;....// │ │ │ +0006fc60: 7468 6973 2069 7320 7573 6564 2077 6865 this is used whe │ │ │ +0006fc70: 6e20 6372 6561 7469 6e67 2061 2074 6f72 n creating a tor │ │ │ +0006fc80: 7265 6e74 2e20 4966 2074 6865 7265 2773 rent. If there's │ │ │ +0006fc90: 0a09 092f 2f20 6f6e 6c79 206f 6e65 2066 ...// only one f │ │ │ +0006fca0: 696c 6520 7468 6572 6520 6172 6520 6361 ile there are ca │ │ │ +0006fcb0: 7365 7320 7768 6572 6520 6974 2773 2069 ses where it's i │ │ │ +0006fcc0: 6d70 6f73 7369 626c 650a 3c2f 7072 653e mpossible.
    │ │ │ +0006fcd0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +0006fd00: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +0006fd10: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../include/ │ │ │ +0006fd40: 6c69 6274 6f72 7265 6e74 2f70 6572 666f libtorrent/perfo │ │ │ +0006fd50: 726d 616e 6365 5f63 6f75 6e74 6572 732e rmance_counters. │ │ │ +0006fd60: 6870 703a 3439 313c 2f61 3e3c 2f74 643e hpp:491 │ │ │ +0006fd70: 3c74 643e 736f 6d65 2073 7061 6365 2063 some space c │ │ │ +0006fd80: 6f75 6c64 2062 6520 7361 7665 6420 6865 ould be saved he │ │ │ +0006fd90: 7265 2062 7920 6d61 6b69 6e67 2067 6175 re by making gau │ │ │ +0006fda0: 6765 7320 3332 2062 6974 733c 2f74 643e ges 32 bits │ │ │ +0006fdb0: 3c2f 7472 3e3c 7472 2069 643d 2232 3534

    some sp │ │ │ +0006fe00: 6163 6520 636f 756c 6420 6265 2073 6176 ace could be sav │ │ │ +0006fe10: 6564 2068 6572 6520 6279 206d 616b 696e ed here by makin │ │ │ +0006fe20: 6720 6761 7567 6573 2033 3220 6269 7473 g gauges 32 bits │ │ │ +0006fe30: 3c2f 6832 3e3c 6834 3e2e 2e2f 696e 636c

    ../incl │ │ │ +0006fe40: 7564 652f 6c69 6274 6f72 7265 6e74 2f70 ude/libtorrent/p │ │ │ +0006fe50: 6572 666f 726d 616e 6365 5f63 6f75 6e74 erformance_count │ │ │ +0006fe60: 6572 732e 6870 703a 3439 313c 2f68 343e ers.hpp:491

    │ │ │ +0006fe70: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    
    │ │ │ +0006feb0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374  relev
    │ │ │ +0006fee0: 616e 6365 266e 6273 703b 303c 2f74 643e  ance 0
    │ │ │ +0006fef0: 3c74 643e 3c61 2068 7265 663d 226a 6176  ../include/
    │ │ │ +0006ff20: 6c69 6274 6f72 7265 6e74 2f70 6572 666f  libtorrent/perfo
    │ │ │ +0006ff30: 726d 616e 6365 5f63 6f75 6e74 6572 732e  rmance_counters.
    │ │ │ +0006ff40: 6870 703a 3439 323c 2f61 3e3c 2f74 643e  hpp:492
    │ │ │ +0006ff50: 3c74 643e 7265 7374 6f72 6520 7468 6573  restore thes
    │ │ │ +0006ff60: 6520 746f 2072 6567 756c 6172 2069 6e74  e to regular int
    │ │ │ +0006ff70: 6567 6572 732e 2049 6e73 7465 6164 2068  egers. Instead h
    │ │ │ +0006ff80: 6176 6520 6f6e 6520 636f 7079 206f 6620  ave one copy of 
    │ │ │ +0006ff90: 7468 6520 636f 756e 7465 7273 2070 6572  the counters per
    │ │ │ +0006ffa0: 2074 6872 6561 6420 616e 6420 636f 6c6c   thread and coll
    │ │ │ +0006ffb0: 6563 7420 7468 656d 2061 7420 636f 6e76  ect them at conv
    │ │ │ +0006ffc0: 656e 6965 6e74 2073 796e 6368 726f 6e69  enient synchroni
    │ │ │ +0006ffd0: 7a61 7469 6f6e 2070 6f69 6e74 733c 2f74  zation points

    resto │ │ │ +00070030: 7265 2074 6865 7365 2074 6f20 7265 6775 re these to regu │ │ │ +00070040: 6c61 7220 696e 7465 6765 7273 2e20 496e lar integers. In │ │ │ +00070050: 7374 6561 6420 6861 7665 206f 6e65 2063 stead have one c │ │ │ +00070060: 6f70 790a 6f66 2074 6865 2063 6f75 6e74 opy.of the count │ │ │ +00070070: 6572 7320 7065 7220 7468 7265 6164 2061 ers per thread a │ │ │ +00070080: 6e64 2063 6f6c 6c65 6374 2074 6865 6d20 nd collect them │ │ │ +00070090: 6174 2063 6f6e 7665 6e69 656e 740a 7379 at convenient.sy │ │ │ +000700a0: 6e63 6872 6f6e 697a 6174 696f 6e20 706f nchronization po │ │ │ +000700b0: 696e 7473 3c2f 6832 3e3c 6834 3e2e 2e2f ints

    ../ │ │ │ +000700c0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ +000700d0: 6e74 2f70 6572 666f 726d 616e 6365 5f63 nt/performance_c │ │ │ +000700e0: 6f75 6e74 6572 732e 6870 703a 3439 323c ounters.hpp:492< │ │ │ +000700f0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    #i
    │ │ │ +00070130: 6664 6566 2041 544f 4d49 435f 4c4c 4f4e  fdef ATOMIC_LLON
    │ │ │ +00070140: 475f 4c4f 434b 5f46 5245 450a 2364 6566  G_LOCK_FREE.#def
    │ │ │ +00070150: 696e 6520 544f 5252 454e 545f 434f 554e  ine TORRENT_COUN
    │ │ │ +00070160: 5445 525f 4e4f 4558 4345 5054 206e 6f65  TER_NOEXCEPT noe
    │ │ │ +00070170: 7863 6570 740a 2365 6c73 650a 2364 6566  xcept.#else.#def
    │ │ │ +00070180: 696e 6520 544f 5252 454e 545f 434f 554e  ine TORRENT_COUN
    │ │ │ +00070190: 5445 525f 4e4f 4558 4345 5054 0a23 656e  TER_NOEXCEPT.#en
    │ │ │ +000701a0: 6469 660a 0a09 0963 6f75 6e74 6572 7328  dif....counters(
    │ │ │ +000701b0: 2920 544f 5252 454e 545f 434f 554e 5445  ) TORRENT_COUNTE
    │ │ │ +000701c0: 525f 4e4f 4558 4345 5054 3b0a 0a09 0963  R_NOEXCEPT;....c
    │ │ │ +000701d0: 6f75 6e74 6572 7328 636f 756e 7465 7273  ounters(counters
    │ │ │ +000701e0: 2063 6f6e 7374 2661 6d70 3b29 2054 4f52   const&) TOR
    │ │ │ +000701f0: 5245 4e54 5f43 4f55 4e54 4552 5f4e 4f45  RENT_COUNTER_NOE
    │ │ │ +00070200: 5843 4550 543b 0a09 0963 6f75 6e74 6572  XCEPT;...counter
    │ │ │ +00070210: 7326 616d 703b 206f 7065 7261 746f 723d  s& operator=
    │ │ │ +00070220: 2863 6f75 6e74 6572 7320 636f 6e73 7426  (counters const&
    │ │ │ +00070230: 616d 703b 2920 2661 6d70 3b20 544f 5252  amp;) & TORR
    │ │ │ +00070240: 454e 545f 434f 554e 5445 525f 4e4f 4558  ENT_COUNTER_NOEX
    │ │ │ +00070250: 4345 5054 3b0a 0a09 092f 2f20 7265 7475  CEPT;....// retu
    │ │ │ +00070260: 726e 7320 7468 6520 6e65 7720 7661 6c75  rns the new valu
    │ │ │ +00070270: 650a 0909 7374 643a 3a69 6e74 3634 5f74  e...std::int64_t
    │ │ │ +00070280: 2069 6e63 5f73 7461 7473 5f63 6f75 6e74   inc_stats_count
    │ │ │ +00070290: 6572 2869 6e74 2063 2c20 7374 643a 3a69  er(int c, std::i
    │ │ │ +000702a0: 6e74 3634 5f74 2076 616c 7565 203d 2031  nt64_t value = 1
    │ │ │ +000702b0: 2920 544f 5252 454e 545f 434f 554e 5445  ) TORRENT_COUNTE
    │ │ │ +000702c0: 525f 4e4f 4558 4345 5054 3b0a 0909 7374  R_NOEXCEPT;...st
    │ │ │ +000702d0: 643a 3a69 6e74 3634 5f74 206f 7065 7261  d::int64_t opera
    │ │ │ +000702e0: 746f 725b 5d28 696e 7420 6929 2063 6f6e  tor[](int i) con
    │ │ │ +000702f0: 7374 2054 4f52 5245 4e54 5f43 4f55 4e54  st TORRENT_COUNT
    │ │ │ +00070300: 4552 5f4e 4f45 5843 4550 543b 0a0a 0909  ER_NOEXCEPT;....
    │ │ │ +00070310: 766f 6964 2073 6574 5f76 616c 7565 2869  void set_value(i
    │ │ │ +00070320: 6e74 2063 2c20 7374 643a 3a69 6e74 3634  nt c, std::int64
    │ │ │ +00070330: 5f74 2076 616c 7565 2920 544f 5252 454e  _t value) TORREN
    │ │ │ +00070340: 545f 434f 554e 5445 525f 4e4f 4558 4345  T_COUNTER_NOEXCE
    │ │ │ +00070350: 5054 3b0a 0909 766f 6964 2062 6c65 6e64  PT;...void blend
    │ │ │ +00070360: 5f73 7461 7473 5f63 6f75 6e74 6572 2869  _stats_counter(i
    │ │ │ +00070370: 6e74 2063 2c20 7374 643a 3a69 6e74 3634  nt c, std::int64
    │ │ │ +00070380: 5f74 2076 616c 7565 2c20 696e 7420 7261  _t value, int ra
    │ │ │ +00070390: 7469 6f29 2054 4f52 5245 4e54 5f43 4f55  tio) TORRENT_COU
    │ │ │ +000703a0: 4e54 4552 5f4e 4f45 5843 4550 543b 0a0a  NTER_NOEXCEPT;..
    │ │ │ +000703b0: 0970 7269 7661 7465 3a0a 0a3c 6469 7620  .private:..
    #ifdef │ │ │ +000703f0: 4154 4f4d 4943 5f4c 4c4f 4e47 5f4c 4f43 ATOMIC_LLONG_LOC │ │ │ +00070400: 4b5f 4652 4545 0a3c 2f64 6976 3e09 0961 K_FREE.
    ..a │ │ │ +00070410: 7578 3a3a 6172 7261 7926 6c74 3b73 7464 ux::array<std │ │ │ +00070420: 3a3a 6174 6f6d 6963 266c 743b 7374 643a ::atomic<std: │ │ │ +00070430: 3a69 6e74 3634 5f74 2667 743b 2c20 6e75 :int64_t>, nu │ │ │ +00070440: 6d5f 636f 756e 7465 7273 2667 743b 206d m_counters> m │ │ │ +00070450: 5f73 7461 7473 5f63 6f75 6e74 6572 3b0a _stats_counter;. │ │ │ +00070460: 2365 6c73 650a 0909 2f2f 2069 6620 7468 #else...// if th │ │ │ +00070470: 6520 6174 6f6d 6963 2074 7970 6520 6973 e atomic type is │ │ │ +00070480: 6e27 7420 6c6f 636b 2d66 7265 652c 2075 n't lock-free, u │ │ │ +00070490: 7365 2061 2073 696e 676c 6520 6c6f 636b se a single lock │ │ │ +000704a0: 2069 6e73 7465 6164 2c20 666f 720a 0909 instead, for... │ │ │ +000704b0: 2f2f 2074 6865 2077 686f 6c65 2061 7272 // the whole arr │ │ │ +000704c0: 6179 0a09 096d 7574 6162 6c65 2073 7464 ay...mutable std │ │ │ +000704d0: 3a3a 6d75 7465 7820 6d5f 6d75 7465 783b ::mutex m_mutex; │ │ │ +000704e0: 0a09 0961 7578 3a3a 6172 7261 7926 6c74 ...aux::array< │ │ │ +000704f0: 3b73 7464 3a3a 696e 7436 345f 742c 206e ;std::int64_t, n │ │ │ +00070500: 756d 5f63 6f75 6e74 6572 7326 6774 3b20 um_counters> │ │ │ +00070510: 6d5f 7374 6174 735f 636f 756e 7465 723b m_stats_counter; │ │ │ +00070520: 0a23 656e 6469 660a 097d 3b0a 7d0a 0a23 .#endif..};.}..# │ │ │ +00070530: 656e 6469 660a 3c2f 7072 653e 3c2f 7464 endif.
    relevance │ │ │ +00070570: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +00070580: 3c61 2068 7265 663d 226a 6176 6173 6372 ../include/libt │ │ │ +000705b0: 6f72 7265 6e74 2f75 706e 702e 6870 703a orrent/upnp.hpp: │ │ │ +000705c0: 3136 343c 2f61 3e3c 2f74 643e 3c74 643e 164 │ │ │ +000705d0: 7375 7070 6f72 7420 7573 696e 6720 7468 support using th │ │ │ +000705e0: 6520 7769 6e64 6f77 7320 4150 4920 666f e windows API fo │ │ │ +000705f0: 7220 5550 6e50 206f 7065 7261 7469 6f6e r UPnP operation │ │ │ +00070600: 7320 6173 2077 656c 6c3c 2f74 643e 3c2f s as well

    support u │ │ │ +00070660: 7369 6e67 2074 6865 2077 696e 646f 7773 sing the windows │ │ │ +00070670: 2041 5049 2066 6f72 2055 506e 5020 6f70 API for UPnP op │ │ │ +00070680: 6572 6174 696f 6e73 2061 7320 7765 6c6c erations as well │ │ │ +00070690: 3c2f 6832 3e3c 6834 3e2e 2e2f 696e 636c

    ../incl │ │ │ +000706a0: 7564 652f 6c69 6274 6f72 7265 6e74 2f75 ude/libtorrent/u │ │ │ +000706b0: 706e 702e 6870 703a 3136 343c 2f68 343e pnp.hpp:164

    │ │ │ +000706c0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    {..boo
    │ │ │ +00070700: 6c20 696e 5f65 7272 6f72 5f63 6f64 6520  l in_error_code 
    │ │ │ +00070710: 3d20 6661 6c73 653b 0a09 626f 6f6c 2065  = false;..bool e
    │ │ │ +00070720: 7869 7420 3d20 6661 6c73 653b 0a09 696e  xit = false;..in
    │ │ │ +00070730: 7420 6572 726f 725f 636f 6465 203d 202d  t error_code = -
    │ │ │ +00070740: 313b 0a7d 3b0a 0a73 7472 7563 7420 6970  1;.};..struct ip
    │ │ │ +00070750: 5f61 6464 7265 7373 5f70 6172 7365 5f73  _address_parse_s
    │ │ │ +00070760: 7461 7465 3a20 6572 726f 725f 636f 6465  tate: error_code
    │ │ │ +00070770: 5f70 6172 7365 5f73 7461 7465 0a7b 0a09  _parse_state.{..
    │ │ │ +00070780: 626f 6f6c 2069 6e5f 6970 5f61 6464 7265  bool in_ip_addre
    │ │ │ +00070790: 7373 203d 2066 616c 7365 3b0a 0973 7464  ss = false;..std
    │ │ │ +000707a0: 3a3a 7374 7269 6e67 2069 705f 6164 6472  ::string ip_addr
    │ │ │ +000707b0: 6573 733b 0a7d 3b0a 0a54 4f52 5245 4e54  ess;.};..TORRENT
    │ │ │ +000707c0: 5f45 5854 5241 5f45 5850 4f52 5420 766f  _EXTRA_EXPORT vo
    │ │ │ +000707d0: 6964 2066 696e 645f 636f 6e74 726f 6c5f  id find_control_
    │ │ │ +000707e0: 7572 6c28 696e 7420 7479 7065 2c20 7374  url(int type, st
    │ │ │ +000707f0: 7269 6e67 5f76 6965 772c 2070 6172 7365  ring_view, parse
    │ │ │ +00070800: 5f73 7461 7465 2661 6d70 3b20 7374 6174  _state& stat
    │ │ │ +00070810: 6529 3b0a 0a54 4f52 5245 4e54 5f45 5854  e);..TORRENT_EXT
    │ │ │ +00070820: 5241 5f45 5850 4f52 5420 766f 6964 2066  RA_EXPORT void f
    │ │ │ +00070830: 696e 645f 6572 726f 725f 636f 6465 2869  ind_error_code(i
    │ │ │ +00070840: 6e74 2074 7970 652c 2073 7472 696e 675f  nt type, string_
    │ │ │ +00070850: 7669 6577 2073 7472 696e 670a 092c 2065  view string.., e
    │ │ │ +00070860: 7272 6f72 5f63 6f64 655f 7061 7273 655f  rror_code_parse_
    │ │ │ +00070870: 7374 6174 6526 616d 703b 2073 7461 7465  state& state
    │ │ │ +00070880: 293b 0a0a 544f 5252 454e 545f 4558 5452  );..TORRENT_EXTR
    │ │ │ +00070890: 415f 4558 504f 5254 2076 6f69 6420 6669  A_EXPORT void fi
    │ │ │ +000708a0: 6e64 5f69 705f 6164 6472 6573 7328 696e  nd_ip_address(in
    │ │ │ +000708b0: 7420 7479 7065 2c20 7374 7269 6e67 5f76  t type, string_v
    │ │ │ +000708c0: 6965 7720 7374 7269 6e67 0a09 2c20 6970  iew string.., ip
    │ │ │ +000708d0: 5f61 6464 7265 7373 5f70 6172 7365 5f73  _address_parse_s
    │ │ │ +000708e0: 7461 7465 2661 6d70 3b20 7374 6174 6529  tate& state)
    │ │ │ +000708f0: 3b0a 0a3c 6469 7620 7374 796c 653d 2262  ;..
    struct TORRENT_ │ │ │ +00070930: 4558 5452 415f 4558 504f 5254 2075 706e EXTRA_EXPORT upn │ │ │ +00070940: 7020 6669 6e61 6c0a 3c2f 6469 763e 093a p final.
    .: │ │ │ +00070950: 2073 7464 3a3a 656e 6162 6c65 5f73 6861 std::enable_sha │ │ │ +00070960: 7265 645f 6672 6f6d 5f74 6869 7326 6c74 red_from_this< │ │ │ +00070970: 3b75 706e 7026 6774 3b0a 092c 2073 696e ;upnp>.., sin │ │ │ +00070980: 676c 655f 7468 7265 6164 6564 0a7b 0a09 gle_threaded.{.. │ │ │ +00070990: 7570 6e70 2869 6f5f 636f 6e74 6578 7426 upnp(io_context& │ │ │ +000709a0: 616d 703b 2069 6f73 0a09 092c 2061 7578 amp; ios..., aux │ │ │ +000709b0: 3a3a 7365 7373 696f 6e5f 7365 7474 696e ::session_settin │ │ │ +000709c0: 6773 2063 6f6e 7374 2661 6d70 3b20 7365 gs const& se │ │ │ +000709d0: 7474 696e 6773 0a09 092c 2061 7578 3a3a ttings..., aux:: │ │ │ +000709e0: 706f 7274 6d61 705f 6361 6c6c 6261 636b portmap_callback │ │ │ +000709f0: 2661 6d70 3b20 6362 0a09 092c 2061 6464 & cb..., add │ │ │ +00070a00: 7265 7373 5f76 3420 6c69 7374 656e 5f61 ress_v4 listen_a │ │ │ +00070a10: 6464 7265 7373 0a09 092c 2061 6464 7265 ddress..., addre │ │ │ +00070a20: 7373 5f76 3420 6e65 746d 6173 6b0a 0909 ss_v4 netmask... │ │ │ +00070a30: 2c20 7374 643a 3a73 7472 696e 6720 6c69 , std::string li │ │ │ +00070a40: 7374 656e 5f64 6576 6963 650a 0909 2c20 sten_device..., │ │ │ +00070a50: 6175 783a 3a6c 6973 7465 6e5f 736f 636b aux::listen_sock │ │ │ +00070a60: 6574 5f68 616e 646c 6520 6c73 293b 0a09 et_handle ls);.. │ │ │ +00070a70: 7e75 706e 7028 293b 0a0a 0976 6f69 6420 ~upnp();...void │ │ │ +00070a80: 7374 6172 7428 293b 0a0a 092f 2f20 4174 start();...// At │ │ │ +00070a90: 7465 6d70 7473 2074 6f20 6164 6420 6120 tempts to add a │ │ │ +00070aa0: 706f 7274 206d 6170 7069 6e67 2066 6f72 port mapping for │ │ │ +00070ab0: 2074 6865 2073 7065 6369 6669 6564 2070 the specified p │ │ │ +00070ac0: 726f 746f 636f 6c2e 2056 616c 6964 2070 rotocol. Valid p │ │ │ +00070ad0: 726f 746f 636f 6c73 2061 7265 0a09 2f2f rotocols are..// │ │ │ +00070ae0: 2060 6075 706e 703a 3a74 6370 6060 2061 ``upnp::tcp`` a │ │ │ +00070af0: 6e64 2060 6075 706e 703a 3a75 6470 6060 nd ``upnp::udp`` │ │ │ +00070b00: 2066 6f72 2074 6865 2055 506e 5020 636c for the UPnP cl │ │ │ +00070b10: 6173 7320 616e 6420 6060 6e61 7470 6d70 ass and ``natpmp │ │ │ +00070b20: 3a3a 7463 7060 6020 616e 640a 092f 2f20 ::tcp`` and..// │ │ │ +00070b30: 6060 6e61 7470 6d70 3a3a 7564 7060 6020 ``natpmp::udp`` │ │ │ +00070b40: 666f 7220 7468 6520 4e41 542d 504d 5020 for the NAT-PMP │ │ │ +00070b50: 636c 6173 732e 0a09 2f2f 0a09 2f2f 2060 class...//..// ` │ │ │ +00070b60: 6065 7874 6572 6e61 6c5f 706f 7274 6060 `external_port`` │ │ │ +00070b70: 2069 7320 7468 6520 706f 7274 206f 6e20 is the port on │ │ │ +00070b80: 7468 6520 6578 7465 726e 616c 2061 6464 the external add │ │ │ +00070b90: 7265 7373 2074 6861 7420 7769 6c6c 2062 ress that will b │ │ │ +00070ba0: 6520 6d61 7070 6564 2e20 5468 6973 0a09 e mapped. This.. │ │ │ +00070bb0: 2f2f 2069 7320 6120 6869 6e74 2c20 796f // is a hint, yo │ │ │ +00070bc0: 7520 6172 6520 6e6f 7420 6775 6172 616e u are not guaran │ │ │ +00070bd0: 7465 6564 2074 6861 7420 7468 6973 2070 teed that this p │ │ │ +00070be0: 6f72 7420 7769 6c6c 2062 6520 6176 6169 ort will be avai │ │ │ +00070bf0: 6c61 626c 652c 2061 6e64 2069 7420 6d61 lable, and it ma │ │ │ +00070c00: 790a 092f 2f20 656e 6420 7570 2062 6569 y..// end up bei │ │ │ +00070c10: 6e67 2073 6f6d 6574 6869 6e67 2065 6c73 ng something els │ │ │ +00070c20: 652e 2049 6e20 7468 6520 706f 7274 6d61 e. In the portma │ │ │ +00070c30: 705f 616c 6572 745f 206e 6f74 6966 6963 p_alert_ notific │ │ │ +00070c40: 6174 696f 6e2c 2074 6865 2061 6374 7561 ation, the actua │ │ │ +00070c50: 6c0a 092f 2f20 6578 7465 726e 616c 2070 l..// external p │ │ │ +00070c60: 6f72 7420 6973 2072 6570 6f72 7465 642e ort is reported. │ │ │ +00070c70: 0a09 2f2f 0a09 2f2f 2060 606c 6f63 616c ..//..// ``local │ │ │ +00070c80: 5f70 6f72 7460 6020 6973 2074 6865 2070 _port`` is the p │ │ │ +00070c90: 6f72 7420 696e 2074 6865 206c 6f63 616c ort in the local │ │ │ +00070ca0: 206d 6163 6869 6e65 2074 6861 7420 7468 machine that th │ │ │ +00070cb0: 6520 6d61 7070 696e 6720 7368 6f75 6c64 e mapping should │ │ │ +00070cc0: 2066 6f72 7761 7264 0a09 2f2f 2074 6f2e forward..// to. │ │ │ +00070cd0: 0a09 2f2f 0a09 2f2f 2054 6865 2072 6574 ..//..// The ret │ │ │ +00070ce0: 7572 6e20 7661 6c75 6520 6973 2061 6e20 urn value is an │ │ │ +00070cf0: 696e 6465 7820 7468 6174 2069 6465 6e74 index that ident │ │ │ +00070d00: 6966 6965 7320 7468 6973 2070 6f72 7420 ifies this port │ │ │ +00070d10: 6d61 7070 696e 672e 2054 6869 7320 6973 mapping. This is │ │ │ +00070d20: 2075 7365 640a 092f 2f20 746f 2072 6566 used..// to ref │ │ │ +00070d30: 6572 2074 6f20 6d61 7070 696e 6773 2074 er to mappings t │ │ │ +00070d40: 6861 7420 6661 696c 7320 6f72 2073 7563 hat fails or suc │ │ │ +00070d50: 6365 6564 7320 696e 2074 6865 2070 6f72 ceeds in the por │ │ │ +00070d60: 746d 6170 5f65 7272 6f72 5f61 6c65 7274 tmap_error_alert │ │ │ +00070d70: 5f20 616e 640a 092f 2f20 706f 7274 6d61 _ and..// portma │ │ │ +00070d80: 705f 616c 6572 745f 2072 6573 7065 6374 p_alert_ respect │ │ │ +00070d90: 6976 656c 792e 2049 6620 5468 6520 6d61 ively. If The ma │ │ │ +00070da0: 7070 696e 6720 6661 696c 7320 696d 6d65 pping fails imme │ │ │ +00070db0: 6469 6174 656c 792c 2074 6865 2072 6574 diately, the ret │ │ │ +00070dc0: 7572 6e20 7661 6c75 650a 092f 2f20 6973 urn value..// is │ │ │ +00070dd0: 202d 312c 2077 6869 6368 206d 6561 6e73 -1, which means │ │ │ +00070de0: 2066 6169 6c75 7265 2e20 5468 6572 6520 failure. There │ │ │ +00070df0: 7769 6c6c 206e 6f74 2062 6520 616e 7920 will not be any │ │ │ +00070e00: 6572 726f 7220 616c 6572 7420 6e6f 7469 error alert noti │ │ │ +00070e10: 6669 6361 7469 6f6e 2066 6f72 0a3c 2f70 fication for.

    re │ │ │ +00070e50: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../inclu │ │ │ +00070e90: 6465 2f6c 6962 746f 7272 656e 742f 736f de/libtorrent/so │ │ │ +00070ea0: 636b 7335 5f73 7472 6561 6d2e 6870 703a cks5_stream.hpp: │ │ │ +00070eb0: 3139 393c 2f61 3e3c 2f74 643e 3c74 643e 199 │ │ │ +00070ec0: 7765 2063 6f75 6c64 2062 696e 6420 7468 we could bind th │ │ │ +00070ed0: 6520 736f 636b 6574 2068 6572 652c 2073 e socket here, s │ │ │ +00070ee0: 696e 6365 2077 6520 6b6e 6f77 2077 6861 ince we know wha │ │ │ +00070ef0: 7420 7468 6520 7461 7267 6574 2065 6e64 t the target end │ │ │ +00070f00: 706f 696e 7420 6973 206f 6620 7468 6520 point is of the │ │ │ +00070f10: 7072 6f78 793c 2f74 643e 3c2f 7472 3e3c proxy< │ │ │ +00070f20: 7472 2069 643d 2232 3537 2220 7374 796c tr id="257" styl │ │ │ +00070f30: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00070f40: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00070f50: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00070f60: 6832 3e77 6520 636f 756c 6420 6269 6e64 h2>we could bind │ │ │ +00070f70: 2074 6865 2073 6f63 6b65 7420 6865 7265 the socket here │ │ │ +00070f80: 2c20 7369 6e63 6520 7765 206b 6e6f 7720 , since we know │ │ │ +00070f90: 7768 6174 2074 6865 0a74 6172 6765 7420 what the.target │ │ │ +00070fa0: 656e 6470 6f69 6e74 2069 7320 6f66 2074 endpoint is of t │ │ │ +00070fb0: 6865 2070 726f 7879 3c2f 6832 3e3c 6834 he proxy

    ../include/libt │ │ │ +00070fd0: 6f72 7265 6e74 2f73 6f63 6b73 355f 7374 orrent/socks5_st │ │ │ +00070fe0: 7265 616d 2e68 7070 3a31 3939 3c2f 6834 ream.hpp:199

    ...},
    │ │ │ +00071030: 2073 7464 3a3a 6d6f 7665 2868 616e 646c   std::move(handl
    │ │ │ +00071040: 6572 2929 293b 0a09 7d0a 0a70 7269 7661  er)));..}..priva
    │ │ │ +00071050: 7465 3a0a 0a09 7465 6d70 6c61 7465 2026  te:...template &
    │ │ │ +00071060: 6c74 3b74 7970 656e 616d 6520 4861 6e64  lt;typename Hand
    │ │ │ +00071070: 6c65 7226 6774 3b0a 0976 6f69 6420 6e61  ler>..void na
    │ │ │ +00071080: 6d65 5f6c 6f6f 6b75 7028 6572 726f 725f  me_lookup(error_
    │ │ │ +00071090: 636f 6465 2063 6f6e 7374 2661 6d70 3b20  code const& 
    │ │ │ +000710a0: 652c 2074 6370 3a3a 7265 736f 6c76 6572  e, tcp::resolver
    │ │ │ +000710b0: 3a3a 7265 7375 6c74 735f 7479 7065 2069  ::results_type i
    │ │ │ +000710c0: 7073 0a09 092c 2048 616e 646c 6572 2068  ps..., Handler h
    │ │ │ +000710d0: 290a 097b 0a09 0943 4f4d 504c 4554 455f  )..{...COMPLETE_
    │ │ │ +000710e0: 4153 594e 4328 2273 6f63 6b73 355f 7374  ASYNC("socks5_st
    │ │ │ +000710f0: 7265 616d 3a3a 6e61 6d65 5f6c 6f6f 6b75  ream::name_looku
    │ │ │ +00071100: 7022 293b 0a09 0969 6620 2868 616e 646c  p");...if (handl
    │ │ │ +00071110: 655f 6572 726f 7228 652c 2073 7464 3a3a  e_error(e, std::
    │ │ │ +00071120: 6d6f 7665 2868 2929 2920 7265 7475 726e  move(h))) return
    │ │ │ +00071130: 3b0a 0a09 0961 7574 6f20 6920 3d20 6970  ;....auto i = ip
    │ │ │ +00071140: 732e 6265 6769 6e28 293b 0a09 0969 6620  s.begin();...if 
    │ │ │ +00071150: 2821 6d5f 736f 636b 2e69 735f 6f70 656e  (!m_sock.is_open
    │ │ │ +00071160: 2829 290a 0909 7b0a 0909 0965 7272 6f72  ())...{....error
    │ │ │ +00071170: 5f63 6f64 6520 6563 3b0a 0909 096d 5f73  _code ec;....m_s
    │ │ │ +00071180: 6f63 6b2e 6f70 656e 2869 2d26 6774 3b65  ock.open(i->e
    │ │ │ +00071190: 6e64 706f 696e 7428 292e 7072 6f74 6f63  ndpoint().protoc
    │ │ │ +000711a0: 6f6c 2829 2c20 6563 293b 0a09 0909 6966  ol(), ec);....if
    │ │ │ +000711b0: 2028 6861 6e64 6c65 5f65 7272 6f72 2865   (handle_error(e
    │ │ │ +000711c0: 632c 2073 7464 3a3a 6d6f 7665 2868 2929  c, std::move(h))
    │ │ │ +000711d0: 2920 7265 7475 726e 3b0a 0909 7d0a 0a3c  ) return;...}..<
    │ │ │ +000711e0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +000711f0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +00071200: 7769 6474 683d 2231 3030 2522 3e09 0941  width="100%">..A
    │ │ │ +00071210: 4444 5f4f 5554 5354 414e 4449 4e47 5f41  DD_OUTSTANDING_A
    │ │ │ +00071220: 5359 4e43 2822 736f 636b 7335 5f73 7472  SYNC("socks5_str
    │ │ │ +00071230: 6561 6d3a 3a63 6f6e 6e65 6374 6564 2229  eam::connected")
    │ │ │ +00071240: 3b0a 3c2f 6469 763e 0909 6d5f 736f 636b  ;...m_sock
    │ │ │ +00071250: 2e61 7379 6e63 5f63 6f6e 6e65 6374 2869  .async_connect(i
    │ │ │ +00071260: 2d26 6774 3b65 6e64 706f 696e 7428 292c  ->endpoint(),
    │ │ │ +00071270: 2077 7261 705f 616c 6c6f 6361 746f 7228   wrap_allocator(
    │ │ │ +00071280: 0a09 0909 5b74 6869 735d 2865 7272 6f72  ....[this](error
    │ │ │ +00071290: 5f63 6f64 6520 636f 6e73 7426 616d 703b  _code const&
    │ │ │ +000712a0: 2065 632c 2048 616e 646c 6572 2068 6e29   ec, Handler hn)
    │ │ │ +000712b0: 0a09 0909 7b20 636f 6e6e 6563 7465 6428  ....{ connected(
    │ │ │ +000712c0: 6563 2c20 7374 643a 3a6d 6f76 6528 686e  ec, std::move(hn
    │ │ │ +000712d0: 2929 3b20 7d2c 2073 7464 3a3a 6d6f 7665  )); }, std::move
    │ │ │ +000712e0: 2868 2929 293b 0a09 7d0a 0a09 7465 6d70  (h)));..}...temp
    │ │ │ +000712f0: 6c61 7465 2026 6c74 3b74 7970 656e 616d  late <typenam
    │ │ │ +00071300: 6520 4861 6e64 6c65 7226 6774 3b0a 0976  e Handler>..v
    │ │ │ +00071310: 6f69 6420 636f 6e6e 6563 7465 6428 6572  oid connected(er
    │ │ │ +00071320: 726f 725f 636f 6465 2063 6f6e 7374 2661  ror_code const&a
    │ │ │ +00071330: 6d70 3b20 652c 2048 616e 646c 6572 2068  mp; e, Handler h
    │ │ │ +00071340: 290a 097b 0a09 0943 4f4d 504c 4554 455f  )..{...COMPLETE_
    │ │ │ +00071350: 4153 594e 4328 2273 6f63 6b73 355f 7374  ASYNC("socks5_st
    │ │ │ +00071360: 7265 616d 3a3a 636f 6e6e 6563 7465 6422  ream::connected"
    │ │ │ +00071370: 293b 0a09 0969 6620 2868 616e 646c 655f  );...if (handle_
    │ │ │ +00071380: 6572 726f 7228 652c 2073 7464 3a3a 6d6f  error(e, std::mo
    │ │ │ +00071390: 7665 2868 2929 2920 7265 7475 726e 3b0a  ve(h))) return;.
    │ │ │ +000713a0: 0a09 0975 7369 6e67 206e 616d 6573 7061  ...using namespa
    │ │ │ +000713b0: 6365 206c 6962 746f 7272 656e 743a 3a61  ce libtorrent::a
    │ │ │ +000713c0: 7578 3b0a 0909 6966 2028 6d5f 7665 7273  ux;...if (m_vers
    │ │ │ +000713d0: 696f 6e20 3d3d 2035 290a 0909 7b0a 0909  ion == 5)...{...
    │ │ │ +000713e0: 092f 2f20 7365 6e64 2053 4f43 4b53 3520  .// send SOCKS5 
    │ │ │ +000713f0: 6175 7468 656e 7469 6361 7469 6f6e 206d  authentication m
    │ │ │ +00071400: 6574 686f 6473 0a09 0909 6d5f 6275 6666  ethods....m_buff
    │ │ │ +00071410: 6572 2e72 6573 697a 6528 6d5f 7573 6572  er.resize(m_user
    │ │ │ +00071420: 2e65 6d70 7479 2829 3f33 3a34 293b 0a09  .empty()?3:4);..
    │ │ │ +00071430: 0909 6368 6172 2a20 7020 3d20 2661 6d70  ..char* p = &
    │ │ │ +00071440: 3b6d 5f62 7566 6665 725b 305d 3b0a 0909  ;m_buffer[0];...
    │ │ │ +00071450: 0977 7269 7465 5f75 696e 7438 2835 2c20  .write_uint8(5, 
    │ │ │ +00071460: 7029 3b20 2f2f 2053 4f43 4b53 2056 4552  p); // SOCKS VER
    │ │ │ +00071470: 5349 4f4e 2035 0a09 0909 6966 2028 6d5f  SION 5....if (m_
    │ │ │ +00071480: 7573 6572 2e65 6d70 7479 2829 290a 0909  user.empty())...
    │ │ │ +00071490: 097b 0a09 0909 0977 7269 7465 5f75 696e  .{.....write_uin
    │ │ │ +000714a0: 7438 2831 2c20 7029 3b20 2f2f 2031 2061  t8(1, p); // 1 a
    │ │ │ +000714b0: 7574 6865 6e74 6963 6174 696f 6e20 6d65  uthentication me
    │ │ │ +000714c0: 7468 6f64 2028 6e6f 2061 7574 6829 0a09  thod (no auth)..
    │ │ │ +000714d0: 0909 0977 7269 7465 5f75 696e 7438 2830  ...write_uint8(0
    │ │ │ +000714e0: 2c20 7029 3b20 2f2f 206e 6f20 6175 7468  , p); // no auth
    │ │ │ +000714f0: 656e 7469 6361 7469 6f6e 0a09 0909 7d0a  entication....}.
    │ │ │ +00071500: 0909 0965 6c73 650a 0909 097b 0a09 0909  ...else....{....
    │ │ │ +00071510: 0977 7269 7465 5f75 696e 7438 2832 2c20  .write_uint8(2, 
    │ │ │ +00071520: 7029 3b20 2f2f 2032 2061 7574 6865 6e74  p); // 2 authent
    │ │ │ +00071530: 6963 6174 696f 6e20 6d65 7468 6f64 730a  ication methods.
    │ │ │ +00071540: 0909 0909 7772 6974 655f 7569 6e74 3828  ....write_uint8(
    │ │ │ +00071550: 302c 2070 293b 202f 2f20 6e6f 2061 7574  0, p); // no aut
    │ │ │ +00071560: 6865 6e74 6963 6174 696f 6e0a 0909 0909  hentication.....
    │ │ │ +00071570: 7772 6974 655f 7569 6e74 3828 322c 2070  write_uint8(2, p
    │ │ │ +00071580: 293b 202f 2f20 7573 6572 6e61 6d65 2f70  ); // username/p
    │ │ │ +00071590: 6173 7377 6f72 640a 0909 097d 0a09 0909  assword....}....
    │ │ │ +000715a0: 4144 445f 4f55 5453 5441 4e44 494e 475f  ADD_OUTSTANDING_
    │ │ │ +000715b0: 4153 594e 4328 2273 6f63 6b73 355f 7374  ASYNC("socks5_st
    │ │ │ +000715c0: 7265 616d 3a3a 6861 6e64 7368 616b 6531  ream::handshake1
    │ │ │ +000715d0: 2229 3b0a 3c2f 7072 653e 3c2f 7464 3e3c  ");.
    < │ │ │ +000715e0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +00071610: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +00071640: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ +00071650: 7265 6e74 2f69 3270 5f73 7472 6561 6d2e rent/i2p_stream. │ │ │ +00071660: 6870 703a 3538 353c 2f61 3e3c 2f74 643e hpp:585 │ │ │ +00071670: 3c74 643e 6d61 6b65 2074 6869 7320 6120 make this a │ │ │ +00071680: 7374 7269 6e67 5f76 6965 773c 2f74 643e string_view │ │ │ +00071690: 3c2f 7472 3e3c 7472 2069 643d 2232 3538

    make th │ │ │ +000716e0: 6973 2061 2073 7472 696e 675f 7669 6577 is a string_view │ │ │ +000716f0: 3c2f 6832 3e3c 6834 3e2e 2e2f 696e 636c

    ../incl │ │ │ +00071700: 7564 652f 6c69 6274 6f72 7265 6e74 2f69 ude/libtorrent/i │ │ │ +00071710: 3270 5f73 7472 6561 6d2e 6870 703a 3538 2p_stream.hpp:58 │ │ │ +00071720: 353c 2f68 343e 3c70 7265 2073 7479 6c65 5

    │ │ │ +00071760: 0a09 0963 6861 7220 746d 705b 3230 5d3b  ...char tmp[20];
    │ │ │ +00071770: 0a09 0961 7578 3a3a 7261 6e64 6f6d 5f62  ...aux::random_b
    │ │ │ +00071780: 7974 6573 2874 6d70 293b 0a09 096d 5f73  ytes(tmp);...m_s
    │ │ │ +00071790: 6573 7369 6f6e 5f69 642e 7265 7369 7a65  ession_id.resize
    │ │ │ +000717a0: 2873 697a 656f 6628 746d 7029 2a32 293b  (sizeof(tmp)*2);
    │ │ │ +000717b0: 0a09 0961 7578 3a3a 746f 5f68 6578 2874  ...aux::to_hex(t
    │ │ │ +000717c0: 6d70 2c20 2661 6d70 3b6d 5f73 6573 7369  mp, &m_sessi
    │ │ │ +000717d0: 6f6e 5f69 645b 305d 293b 0a0a 0909 6d5f  on_id[0]);....m_
    │ │ │ +000717e0: 7361 6d5f 736f 636b 6574 203d 2073 7464  sam_socket = std
    │ │ │ +000717f0: 3a3a 6d61 6b65 5f73 6861 7265 6426 6c74  ::make_shared<
    │ │ │ +00071800: 3b69 3270 5f73 7472 6561 6d26 6774 3b28  ;i2p_stream>(
    │ │ │ +00071810: 6d5f 696f 5f73 6572 7669 6365 293b 0a09  m_io_service);..
    │ │ │ +00071820: 096d 5f73 616d 5f73 6f63 6b65 742d 2667  .m_sam_socket-&g
    │ │ │ +00071830: 743b 7365 745f 7072 6f78 7928 6d5f 686f  t;set_proxy(m_ho
    │ │ │ +00071840: 7374 6e61 6d65 2c20 6d5f 706f 7274 293b  stname, m_port);
    │ │ │ +00071850: 0a09 096d 5f73 616d 5f73 6f63 6b65 742d  ...m_sam_socket-
    │ │ │ +00071860: 2667 743b 7365 745f 636f 6d6d 616e 6428  >set_command(
    │ │ │ +00071870: 6932 705f 7374 7265 616d 3a3a 636d 645f  i2p_stream::cmd_
    │ │ │ +00071880: 6372 6561 7465 5f73 6573 7369 6f6e 293b  create_session);
    │ │ │ +00071890: 0a09 096d 5f73 616d 5f73 6f63 6b65 742d  ...m_sam_socket-
    │ │ │ +000718a0: 2667 743b 7365 745f 7365 7373 696f 6e5f  >set_session_
    │ │ │ +000718b0: 6964 286d 5f73 6573 7369 6f6e 5f69 642e  id(m_session_id.
    │ │ │ +000718c0: 635f 7374 7228 2929 3b0a 0909 6d5f 7361  c_str());...m_sa
    │ │ │ +000718d0: 6d5f 736f 636b 6574 2d26 6774 3b73 6574  m_socket->set
    │ │ │ +000718e0: 5f73 6573 7369 6f6e 5f6f 7074 696f 6e73  _session_options
    │ │ │ +000718f0: 2873 6573 7369 6f6e 5f6f 7074 696f 6e73  (session_options
    │ │ │ +00071900: 293b 0a0a 0909 4144 445f 4f55 5453 5441  );....ADD_OUTSTA
    │ │ │ +00071910: 4e44 494e 475f 4153 594e 4328 2269 3270  NDING_ASYNC("i2p
    │ │ │ +00071920: 5f73 7472 6561 6d3a 3a6f 6e5f 7361 6d5f  _stream::on_sam_
    │ │ │ +00071930: 636f 6e6e 6563 7422 293b 0a09 096d 5f73  connect");...m_s
    │ │ │ +00071940: 616d 5f73 6f63 6b65 742d 2667 743b 6173  am_socket->as
    │ │ │ +00071950: 796e 635f 636f 6e6e 6563 7428 7463 703a  ync_connect(tcp:
    │ │ │ +00071960: 3a65 6e64 706f 696e 7428 292c 2077 7261  :endpoint(), wra
    │ │ │ +00071970: 705f 616c 6c6f 6361 746f 7228 0a09 0909  p_allocator(....
    │ │ │ +00071980: 5b74 6869 732c 733d 6d5f 7361 6d5f 736f  [this,s=m_sam_so
    │ │ │ +00071990: 636b 6574 5d28 6572 726f 725f 636f 6465  cket](error_code
    │ │ │ +000719a0: 2063 6f6e 7374 2661 6d70 3b20 6563 2c20   const& ec, 
    │ │ │ +000719b0: 4861 6e64 6c65 7220 686e 2920 7b0a 0909  Handler hn) {...
    │ │ │ +000719c0: 0909 6f6e 5f73 616d 5f63 6f6e 6e65 6374  ..on_sam_connect
    │ │ │ +000719d0: 2865 632c 2073 2c20 7374 643a 3a6d 6f76  (ec, s, std::mov
    │ │ │ +000719e0: 6528 686e 2929 3b0a 0909 097d 2c20 7374  e(hn));....}, st
    │ │ │ +000719f0: 643a 3a6d 6f76 6528 6861 6e64 6c65 7229  d::move(handler)
    │ │ │ +00071a00: 2929 3b0a 097d 0a09 766f 6964 2063 6c6f  ));..}..void clo
    │ │ │ +00071a10: 7365 2865 7272 6f72 5f63 6f64 6526 616d  se(error_code&am
    │ │ │ +00071a20: 703b 293b 0a0a 3c64 6976 2073 7479 6c65  p;);..
    .char const* │ │ │ +00071a60: 2073 6573 7369 6f6e 5f69 6428 2920 636f session_id() co │ │ │ +00071a70: 6e73 7420 7b20 7265 7475 726e 206d 5f73 nst { return m_s │ │ │ +00071a80: 6573 7369 6f6e 5f69 642e 635f 7374 7228 ession_id.c_str( │ │ │ +00071a90: 293b 207d 0a3c 2f64 6976 3e09 7374 643a ); }.
    .std: │ │ │ +00071aa0: 3a73 7472 696e 6720 636f 6e73 7426 616d :string const&am │ │ │ +00071ab0: 703b 206c 6f63 616c 5f65 6e64 706f 696e p; local_endpoin │ │ │ +00071ac0: 7428 2920 636f 6e73 7420 7b20 7265 7475 t() const { retu │ │ │ +00071ad0: 726e 206d 5f69 3270 5f6c 6f63 616c 5f65 rn m_i2p_local_e │ │ │ +00071ae0: 6e64 706f 696e 743b 207d 0a0a 0974 656d ndpoint; }...tem │ │ │ +00071af0: 706c 6174 6520 266c 743b 7479 7065 6e61 plate <typena │ │ │ +00071b00: 6d65 2048 616e 646c 6572 2667 743b 0a09 me Handler>.. │ │ │ +00071b10: 766f 6964 2061 7379 6e63 5f6e 616d 655f void async_name_ │ │ │ +00071b20: 6c6f 6f6b 7570 2863 6861 7220 636f 6e73 lookup(char cons │ │ │ +00071b30: 742a 206e 616d 652c 2048 616e 646c 6572 t* name, Handler │ │ │ +00071b40: 2068 616e 646c 6572 290a 097b 0a09 0969 handler)..{...i │ │ │ +00071b50: 6620 286d 5f73 7461 7465 203d 3d20 7361 f (m_state == sa │ │ │ +00071b60: 6d5f 6964 6c65 2026 616d 703b 2661 6d70 m_idle && │ │ │ +00071b70: 3b20 6d5f 6e61 6d65 5f6c 6f6f 6b75 702e ; m_name_lookup. │ │ │ +00071b80: 656d 7074 7928 2920 2661 6d70 3b26 616d empty() &&am │ │ │ +00071b90: 703b 2069 735f 6f70 656e 2829 290a 0909 p; is_open())... │ │ │ +00071ba0: 0964 6f5f 6e61 6d65 5f6c 6f6f 6b75 7028 .do_name_lookup( │ │ │ +00071bb0: 6e61 6d65 2c20 7374 643a 3a6d 6f76 6528 name, std::move( │ │ │ +00071bc0: 6861 6e64 6c65 7229 293b 0a09 0965 6c73 handler));...els │ │ │ +00071bd0: 650a 0909 096d 5f6e 616d 655f 6c6f 6f6b e....m_name_look │ │ │ +00071be0: 7570 2e65 6d70 6c61 6365 5f62 6163 6b28 up.emplace_back( │ │ │ +00071bf0: 7374 643a 3a73 7472 696e 6728 6e61 6d65 std::string(name │ │ │ +00071c00: 290a 0909 0909 2c20 7374 643a 3a6d 6f76 )....., std::mov │ │ │ +00071c10: 6528 6861 6e64 6c65 7229 293b 0a09 7d0a e(handler));..}. │ │ │ +00071c20: 0a70 7269 7661 7465 3a0a 0a09 7465 6d70 .private:...temp │ │ │ +00071c30: 6c61 7465 2026 6c74 3b74 7970 656e 616d late <typenam │ │ │ +00071c40: 6520 4861 6e64 6c65 7226 6774 3b0a 0976 e Handler>..v │ │ │ +00071c50: 6f69 6420 6f6e 5f73 616d 5f63 6f6e 6e65 oid on_sam_conne │ │ │ +00071c60: 6374 2865 7272 6f72 5f63 6f64 6520 636f ct(error_code co │ │ │ +00071c70: 6e73 7426 616d 703b 2065 632c 2073 7464 nst& ec, std │ │ │ +00071c80: 3a3a 7368 6172 6564 5f70 7472 266c 743b ::shared_ptr< │ │ │ +00071c90: 6932 705f 7374 7265 616d 2667 743b 2c20 i2p_stream>, │ │ │ +00071ca0: 4861 6e64 6c65 7220 6829 0a09 7b0a 0909 Handler h)..{... │ │ │ +00071cb0: 434f 4d50 4c45 5445 5f41 5359 4e43 2822 COMPLETE_ASYNC(" │ │ │ +00071cc0: 6932 705f 7374 7265 616d 3a3a 6f6e 5f73 i2p_stream::on_s │ │ │ +00071cd0: 616d 5f63 6f6e 6e65 6374 2229 3b0a 0909 am_connect");... │ │ │ +00071ce0: 6d5f 7374 6174 6520 3d20 7361 6d5f 6964 m_state = sam_id │ │ │ +00071cf0: 6c65 3b0a 0a09 0969 6620 2865 6329 0a09 le;....if (ec).. │ │ │ +00071d00: 097b 0a09 0909 6828 6563 293b 0a09 0909 .{....h(ec);.... │ │ │ +00071d10: 7265 7475 726e 3b0a 0909 7d0a 0a09 0964 return;...}....d │ │ │ +00071d20: 6f5f 6e61 6d65 5f6c 6f6f 6b75 7028 224d o_name_lookup("M │ │ │ +00071d30: 4522 2c20 7772 6170 5f61 6c6c 6f63 6174 E", wrap_allocat │ │ │ +00071d40: 6f72 280a 0909 095b 7468 6973 5d28 6572 or(....[this](er │ │ │ +00071d50: 726f 725f 636f 6465 2063 6f6e 7374 2661 ror_code const&a │ │ │ +00071d60: 6d70 3b20 652c 2063 6861 7220 636f 6e73 mp; e, char cons │ │ │ +00071d70: 742a 2064 7374 2c20 4861 6e64 6c65 7220 t* dst, Handler │ │ │ +00071d80: 686e 2920 7b0a 0909 0909 7365 745f 6c6f hn) {.....set_lo │ │ │ +00071d90: 6361 6c5f 656e 6470 6f69 6e74 2865 2c20 cal_endpoint(e, │ │ │ +00071da0: 6473 742c 2073 7464 3a3a 6d6f 7665 2868 dst, std::move(h │ │ │ +00071db0: 6e29 293b 0a09 0909 7d2c 2073 7464 3a3a n));....}, std:: │ │ │ +00071dc0: 6d6f 7665 2868 2929 293b 0a3c 2f70 7265 move(h)));.
    rele │ │ │ +00071e00: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../include │ │ │ +00071e40: 2f6c 6962 746f 7272 656e 742f 7374 7269 /libtorrent/stri │ │ │ +00071e50: 6e67 5f76 6965 772e 6870 703a 3430 3c2f ng_view.hpp:40repla │ │ │ +00071e70: 6365 2074 6869 7320 6279 2074 6865 2073 ce this by the s │ │ │ +00071e80: 7461 6e64 6172 6420 7374 7269 6e67 5f76 tandard string_v │ │ │ +00071e90: 6965 7720 696e 2043 2b2b 3137 3c2f 7464 iew in C++17

    replac │ │ │ +00071ef0: 6520 7468 6973 2062 7920 7468 6520 7374 e this by the st │ │ │ +00071f00: 616e 6461 7264 2073 7472 696e 675f 7669 andard string_vi │ │ │ +00071f10: 6577 2069 6e20 432b 2b31 373c 2f68 323e ew in C++17

    │ │ │ +00071f20: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ +00071f30: 6962 746f 7272 656e 742f 7374 7269 6e67 ibtorrent/string │ │ │ +00071f40: 5f76 6965 772e 6870 703a 3430 3c2f 6834 _view.hpp:40

    AND A
    │ │ │ +00071f90: 4e59 2045 5850 5245 5353 204f 5220 494d  NY EXPRESS OR IM
    │ │ │ +00071fa0: 504c 4945 4420 5741 5252 414e 5449 4553  PLIED WARRANTIES
    │ │ │ +00071fb0: 2c20 494e 434c 5544 494e 472c 2042 5554  , INCLUDING, BUT
    │ │ │ +00071fc0: 204e 4f54 204c 494d 4954 4544 2054 4f2c   NOT LIMITED TO,
    │ │ │ +00071fd0: 2054 4845 0a49 4d50 4c49 4544 2057 4152   THE.IMPLIED WAR
    │ │ │ +00071fe0: 5241 4e54 4945 5320 4f46 204d 4552 4348  RANTIES OF MERCH
    │ │ │ +00071ff0: 414e 5441 4249 4c49 5459 2041 4e44 2046  ANTABILITY AND F
    │ │ │ +00072000: 4954 4e45 5353 2046 4f52 2041 2050 4152  ITNESS FOR A PAR
    │ │ │ +00072010: 5449 4355 4c41 5220 5055 5250 4f53 450a  TICULAR PURPOSE.
    │ │ │ +00072020: 4152 4520 4449 5343 4c41 494d 4544 2e20  ARE DISCLAIMED. 
    │ │ │ +00072030: 494e 204e 4f20 4556 454e 5420 5348 414c  IN NO EVENT SHAL
    │ │ │ +00072040: 4c20 5448 4520 434f 5059 5249 4748 5420  L THE COPYRIGHT 
    │ │ │ +00072050: 4f57 4e45 5220 4f52 2043 4f4e 5452 4942  OWNER OR CONTRIB
    │ │ │ +00072060: 5554 4f52 5320 4245 0a4c 4941 424c 4520  UTORS BE.LIABLE 
    │ │ │ +00072070: 464f 5220 414e 5920 4449 5245 4354 2c20  FOR ANY DIRECT, 
    │ │ │ +00072080: 494e 4449 5245 4354 2c20 494e 4349 4445  INDIRECT, INCIDE
    │ │ │ +00072090: 4e54 414c 2c20 5350 4543 4941 4c2c 2045  NTAL, SPECIAL, E
    │ │ │ +000720a0: 5845 4d50 4c41 5259 2c20 4f52 0a43 4f4e  XEMPLARY, OR.CON
    │ │ │ +000720b0: 5345 5155 454e 5449 414c 2044 414d 4147  SEQUENTIAL DAMAG
    │ │ │ +000720c0: 4553 2028 494e 434c 5544 494e 472c 2042  ES (INCLUDING, B
    │ │ │ +000720d0: 5554 204e 4f54 204c 494d 4954 4544 2054  UT NOT LIMITED T
    │ │ │ +000720e0: 4f2c 2050 524f 4355 5245 4d45 4e54 204f  O, PROCUREMENT O
    │ │ │ +000720f0: 460a 5355 4253 5449 5455 5445 2047 4f4f  F.SUBSTITUTE GOO
    │ │ │ +00072100: 4453 204f 5220 5345 5256 4943 4553 3b20  DS OR SERVICES; 
    │ │ │ +00072110: 4c4f 5353 204f 4620 5553 452c 2044 4154  LOSS OF USE, DAT
    │ │ │ +00072120: 412c 204f 5220 5052 4f46 4954 533b 204f  A, OR PROFITS; O
    │ │ │ +00072130: 5220 4255 5349 4e45 5353 0a49 4e54 4552  R BUSINESS.INTER
    │ │ │ +00072140: 5255 5054 494f 4e29 2048 4f57 4556 4552  RUPTION) HOWEVER
    │ │ │ +00072150: 2043 4155 5345 4420 414e 4420 4f4e 2041   CAUSED AND ON A
    │ │ │ +00072160: 4e59 2054 4845 4f52 5920 4f46 204c 4941  NY THEORY OF LIA
    │ │ │ +00072170: 4249 4c49 5459 2c20 5748 4554 4845 5220  BILITY, WHETHER 
    │ │ │ +00072180: 494e 0a43 4f4e 5452 4143 542c 2053 5452  IN.CONTRACT, STR
    │ │ │ +00072190: 4943 5420 4c49 4142 494c 4954 592c 204f  ICT LIABILITY, O
    │ │ │ +000721a0: 5220 544f 5254 2028 494e 434c 5544 494e  R TORT (INCLUDIN
    │ │ │ +000721b0: 4720 4e45 474c 4947 454e 4345 204f 5220  G NEGLIGENCE OR 
    │ │ │ +000721c0: 4f54 4845 5257 4953 4529 0a41 5249 5349  OTHERWISE).ARISI
    │ │ │ +000721d0: 4e47 2049 4e20 414e 5920 5741 5920 4f55  NG IN ANY WAY OU
    │ │ │ +000721e0: 5420 4f46 2054 4845 2055 5345 204f 4620  T OF THE USE OF 
    │ │ │ +000721f0: 5448 4953 2053 4f46 5457 4152 452c 2045  THIS SOFTWARE, E
    │ │ │ +00072200: 5645 4e20 4946 2041 4456 4953 4544 204f  VEN IF ADVISED O
    │ │ │ +00072210: 4620 5448 450a 504f 5353 4942 494c 4954  F THE.POSSIBILIT
    │ │ │ +00072220: 5920 4f46 2053 5543 4820 4441 4d41 4745  Y OF SUCH DAMAGE
    │ │ │ +00072230: 2e0a 0a2a 2f0a 0a23 6966 6e64 6566 2054  ...*/..#ifndef T
    │ │ │ +00072240: 4f52 5245 4e54 5f53 5452 494e 475f 5649  ORRENT_STRING_VI
    │ │ │ +00072250: 4557 5f48 5050 5f49 4e43 4c55 4445 440a  EW_HPP_INCLUDED.
    │ │ │ +00072260: 2364 6566 696e 6520 544f 5252 454e 545f  #define TORRENT_
    │ │ │ +00072270: 5354 5249 4e47 5f56 4945 575f 4850 505f  STRING_VIEW_HPP_
    │ │ │ +00072280: 494e 434c 5544 4544 0a0a 2369 6e63 6c75  INCLUDED..#inclu
    │ │ │ +00072290: 6465 2026 6c74 3b62 6f6f 7374 2f76 6572  de <boost/ver
    │ │ │ +000722a0: 7369 6f6e 2e68 7070 2667 743b 0a0a 2369  sion.hpp>..#i
    │ │ │ +000722b0: 6e63 6c75 6465 2022 6c69 6274 6f72 7265  nclude "libtorre
    │ │ │ +000722c0: 6e74 2f61 7578 5f2f 6469 7361 626c 655f  nt/aux_/disable_
    │ │ │ +000722d0: 7761 726e 696e 6773 5f70 7573 682e 6870  warnings_push.hp
    │ │ │ +000722e0: 7022 0a0a 3c64 6976 2073 7479 6c65 3d22  p"..
    .
    #if BOO │ │ │ +00072320: 5354 5f56 4552 5349 4f4e 2026 6c74 3b20 ST_VERSION < │ │ │ +00072330: 3130 3631 3030 0a23 696e 636c 7564 6520 106100.#include │ │ │ +00072340: 266c 743b 626f 6f73 742f 7574 696c 6974 <boost/utilit │ │ │ +00072350: 792f 7374 7269 6e67 5f72 6566 2e68 7070 y/string_ref.hpp │ │ │ +00072360: 2667 743b 0a23 696e 636c 7564 6520 266c >.#include &l │ │ │ +00072370: 743b 6373 7472 696e 6726 6774 3b20 2f2f t;cstring> // │ │ │ +00072380: 2066 6f72 2073 7472 6368 720a 6e61 6d65 for strchr.name │ │ │ +00072390: 7370 6163 6520 6c69 6274 6f72 7265 6e74 space libtorrent │ │ │ +000723a0: 207b 0a0a 7573 696e 6720 7374 7269 6e67 {..using string │ │ │ +000723b0: 5f76 6965 7720 3d20 626f 6f73 743a 3a73 _view = boost::s │ │ │ +000723c0: 7472 696e 675f 7265 663b 0a75 7369 6e67 tring_ref;.using │ │ │ +000723d0: 2077 7374 7269 6e67 5f76 6965 7720 3d20 wstring_view = │ │ │ +000723e0: 626f 6f73 743a 3a77 7374 7269 6e67 5f72 boost::wstring_r │ │ │ +000723f0: 6566 3b0a 0a2f 2f20 696e 7465 726e 616c ef;..// internal │ │ │ +00072400: 0a69 6e6c 696e 6520 7374 7269 6e67 5f76 .inline string_v │ │ │ +00072410: 6965 773a 3a73 697a 655f 7479 7065 2066 iew::size_type f │ │ │ +00072420: 696e 645f 6669 7273 745f 6f66 2873 7472 ind_first_of(str │ │ │ +00072430: 696e 675f 7669 6577 2063 6f6e 7374 2076 ing_view const v │ │ │ +00072440: 2c20 6368 6172 2063 6f6e 7374 2063 0a09 , char const c.. │ │ │ +00072450: 2c20 7374 7269 6e67 5f76 6965 773a 3a73 , string_view::s │ │ │ +00072460: 697a 655f 7479 7065 2070 6f73 290a 7b0a ize_type pos).{. │ │ │ +00072470: 0977 6869 6c65 2028 706f 7320 266c 743b .while (pos < │ │ │ +00072480: 2076 2e73 697a 6528 2929 0a09 7b0a 0909 v.size())..{... │ │ │ +00072490: 6966 2028 765b 706f 735d 203d 3d20 6329 if (v[pos] == c) │ │ │ +000724a0: 2072 6574 7572 6e20 706f 733b 0a09 092b return pos;...+ │ │ │ +000724b0: 2b70 6f73 3b0a 097d 0a09 7265 7475 726e +pos;..}..return │ │ │ +000724c0: 2073 7472 696e 675f 7669 6577 3a3a 6e70 string_view::np │ │ │ +000724d0: 6f73 3b0a 7d0a 0a2f 2f20 696e 7465 726e os;.}..// intern │ │ │ +000724e0: 616c 0a69 6e6c 696e 6520 7374 7269 6e67 al.inline string │ │ │ +000724f0: 5f76 6965 773a 3a73 697a 655f 7479 7065 _view::size_type │ │ │ +00072500: 2066 696e 645f 6669 7273 745f 6f66 2873 find_first_of(s │ │ │ +00072510: 7472 696e 675f 7669 6577 2063 6f6e 7374 tring_view const │ │ │ +00072520: 2076 2c20 6368 6172 2063 6f6e 7374 2a20 v, char const* │ │ │ +00072530: 630a 092c 2073 7472 696e 675f 7669 6577 c.., string_view │ │ │ +00072540: 3a3a 7369 7a65 5f74 7970 6520 706f 7329 ::size_type pos) │ │ │ +00072550: 0a7b 0a09 7768 696c 6520 2870 6f73 2026 .{..while (pos & │ │ │ +00072560: 6c74 3b20 762e 7369 7a65 2829 290a 097b lt; v.size())..{ │ │ │ +00072570: 0a09 0969 6620 2873 7464 3a3a 7374 7263 ...if (std::strc │ │ │ +00072580: 6872 2863 2c20 765b 706f 735d 2920 213d hr(c, v[pos]) != │ │ │ +00072590: 206e 756c 6c70 7472 2920 7265 7475 726e nullptr) return │ │ │ +000725a0: 2070 6f73 3b0a 0909 2b2b 706f 733b 0a09 pos;...++pos;.. │ │ │ +000725b0: 7d0a 0972 6574 7572 6e20 7374 7269 6e67 }..return string │ │ │ +000725c0: 5f76 6965 773a 3a6e 706f 733b 0a3c 2f70 _view::npos;.

    re │ │ │ +00072600: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0
    ../inclu │ │ │ +00072640: 6465 2f6c 6962 746f 7272 656e 742f 7065 de/libtorrent/pe │ │ │ +00072650: 6572 5f63 6f6e 6e65 6374 696f 6e5f 696e er_connection_in │ │ │ +00072660: 7465 7266 6163 652e 6870 703a 3531 3c2f terface.hpp:51make │ │ │ +00072680: 7468 6973 2069 6e74 6572 6661 6365 2073 this interface s │ │ │ +00072690: 6d61 6c6c 6572 213c 2f74 643e 3c2f 7472 maller!

    make this i │ │ │ +000726f0: 6e74 6572 6661 6365 2073 6d61 6c6c 6572 nterface smaller │ │ │ +00072700: 213c 2f68 323e 3c68 343e 2e2e 2f69 6e63 !

    ../inc │ │ │ +00072710: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ +00072720: 7065 6572 5f63 6f6e 6e65 6374 696f 6e5f peer_connection_ │ │ │ +00072730: 696e 7465 7266 6163 652e 6870 703a 3531 interface.hpp:51 │ │ │ +00072740: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +00072780: 2a2f 0a0a 2369 666e 6465 6620 544f 5252  */..#ifndef TORR
    │ │ │ +00072790: 454e 545f 5045 4552 5f43 4f4e 4e45 4354  ENT_PEER_CONNECT
    │ │ │ +000727a0: 494f 4e5f 494e 5445 5246 4143 455f 4850  ION_INTERFACE_HP
    │ │ │ +000727b0: 500a 2364 6566 696e 6520 544f 5252 454e  P.#define TORREN
    │ │ │ +000727c0: 545f 5045 4552 5f43 4f4e 4e45 4354 494f  T_PEER_CONNECTIO
    │ │ │ +000727d0: 4e5f 494e 5445 5246 4143 455f 4850 500a  N_INTERFACE_HPP.
    │ │ │ +000727e0: 0a23 696e 636c 7564 6520 226c 6962 746f  .#include "libto
    │ │ │ +000727f0: 7272 656e 742f 6677 642e 6870 7022 0a23  rrent/fwd.hpp".#
    │ │ │ +00072800: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ +00072810: 656e 742f 736f 636b 6574 2e68 7070 220a  ent/socket.hpp".
    │ │ │ +00072820: 2369 6e63 6c75 6465 2022 6c69 6274 6f72  #include "libtor
    │ │ │ +00072830: 7265 6e74 2f65 7272 6f72 5f63 6f64 652e  rent/error_code.
    │ │ │ +00072840: 6870 7022 0a23 696e 636c 7564 6520 226c  hpp".#include "l
    │ │ │ +00072850: 6962 746f 7272 656e 742f 616c 6572 745f  ibtorrent/alert_
    │ │ │ +00072860: 7479 7065 732e 6870 7022 0a23 696e 636c  types.hpp".#incl
    │ │ │ +00072870: 7564 6520 226c 6962 746f 7272 656e 742f  ude "libtorrent/
    │ │ │ +00072880: 6f70 6572 6174 696f 6e73 2e68 7070 2220  operations.hpp" 
    │ │ │ +00072890: 2f2f 2066 6f72 206f 7065 7261 7469 6f6e  // for operation
    │ │ │ +000728a0: 5f74 2065 6e75 6d0a 2369 6e63 6c75 6465  _t enum.#include
    │ │ │ +000728b0: 2022 6c69 6274 6f72 7265 6e74 2f75 6e69   "libtorrent/uni
    │ │ │ +000728c0: 7473 2e68 7070 220a 0a6e 616d 6573 7061  ts.hpp"..namespa
    │ │ │ +000728d0: 6365 206c 6962 746f 7272 656e 7420 7b0a  ce libtorrent {.
    │ │ │ +000728e0: 0a09 7374 7275 6374 2074 6f72 7265 6e74  ..struct torrent
    │ │ │ +000728f0: 5f70 6565 723b 0a09 636c 6173 7320 7374  _peer;..class st
    │ │ │ +00072900: 6174 3b0a 0a09 7573 696e 6720 6469 7363  at;...using disc
    │ │ │ +00072910: 6f6e 6e65 6374 5f73 6576 6572 6974 795f  onnect_severity_
    │ │ │ +00072920: 7420 3d20 6175 783a 3a73 7472 6f6e 675f  t = aux::strong_
    │ │ │ +00072930: 7479 7065 6465 6626 6c74 3b73 7464 3a3a  typedef<std::
    │ │ │ +00072940: 7569 6e74 385f 742c 2073 7472 7563 7420  uint8_t, struct 
    │ │ │ +00072950: 6469 7363 6f6e 6e65 6374 5f73 6576 6572  disconnect_sever
    │ │ │ +00072960: 6974 795f 7461 6726 6774 3b3b 0a0a 3c64  ity_tag>;...str
    │ │ │ +000729a0: 7563 7420 544f 5252 454e 545f 4558 5452  uct TORRENT_EXTR
    │ │ │ +000729b0: 415f 4558 504f 5254 2070 6565 725f 636f  A_EXPORT peer_co
    │ │ │ +000729c0: 6e6e 6563 7469 6f6e 5f69 6e74 6572 6661  nnection_interfa
    │ │ │ +000729d0: 6365 0a3c 2f64 6976 3e09 7b0a 0909 7374  ce..{...st
    │ │ │ +000729e0: 6174 6963 2063 6f6e 7374 6578 7072 2064  atic constexpr d
    │ │ │ +000729f0: 6973 636f 6e6e 6563 745f 7365 7665 7269  isconnect_severi
    │ │ │ +00072a00: 7479 5f74 206e 6f72 6d61 6c7b 307d 3b0a  ty_t normal{0};.
    │ │ │ +00072a10: 0909 7374 6174 6963 2063 6f6e 7374 6578  ..static constex
    │ │ │ +00072a20: 7072 2064 6973 636f 6e6e 6563 745f 7365  pr disconnect_se
    │ │ │ +00072a30: 7665 7269 7479 5f74 2066 6169 6c75 7265  verity_t failure
    │ │ │ +00072a40: 7b31 7d3b 0a09 0973 7461 7469 6320 636f  {1};...static co
    │ │ │ +00072a50: 6e73 7465 7870 7220 6469 7363 6f6e 6e65  nstexpr disconne
    │ │ │ +00072a60: 6374 5f73 6576 6572 6974 795f 7420 7065  ct_severity_t pe
    │ │ │ +00072a70: 6572 5f65 7272 6f72 7b32 7d3b 0a0a 2369  er_error{2};..#i
    │ │ │ +00072a80: 6620 544f 5252 454e 545f 5553 455f 4932  f TORRENT_USE_I2
    │ │ │ +00072a90: 500a 0909 7669 7274 7561 6c20 7374 643a  P...virtual std:
    │ │ │ +00072aa0: 3a73 7472 696e 6720 636f 6e73 7426 616d  :string const&am
    │ │ │ +00072ab0: 703b 2064 6573 7469 6e61 7469 6f6e 2829  p; destination()
    │ │ │ +00072ac0: 2063 6f6e 7374 203d 2030 3b0a 0909 7669   const = 0;...vi
    │ │ │ +00072ad0: 7274 7561 6c20 7374 643a 3a73 7472 696e  rtual std::strin
    │ │ │ +00072ae0: 6720 636f 6e73 7426 616d 703b 206c 6f63  g const& loc
    │ │ │ +00072af0: 616c 5f69 3270 5f65 6e64 706f 696e 7428  al_i2p_endpoint(
    │ │ │ +00072b00: 2920 636f 6e73 7420 3d20 303b 0a23 656e  ) const = 0;.#en
    │ │ │ +00072b10: 6469 660a 0909 7669 7274 7561 6c20 7463  dif...virtual tc
    │ │ │ +00072b20: 703a 3a65 6e64 706f 696e 7420 636f 6e73  p::endpoint cons
    │ │ │ +00072b30: 7426 616d 703b 2072 656d 6f74 6528 2920  t& remote() 
    │ │ │ +00072b40: 636f 6e73 7420 3d20 303b 0a09 0976 6972  const = 0;...vir
    │ │ │ +00072b50: 7475 616c 2074 6370 3a3a 656e 6470 6f69  tual tcp::endpoi
    │ │ │ +00072b60: 6e74 206c 6f63 616c 5f65 6e64 706f 696e  nt local_endpoin
    │ │ │ +00072b70: 7428 2920 636f 6e73 7420 3d20 303b 0a09  t() const = 0;..
    │ │ │ +00072b80: 0976 6972 7475 616c 2076 6f69 6420 6469  .virtual void di
    │ │ │ +00072b90: 7363 6f6e 6e65 6374 2865 7272 6f72 5f63  sconnect(error_c
    │ │ │ +00072ba0: 6f64 6520 636f 6e73 7426 616d 703b 2065  ode const& e
    │ │ │ +00072bb0: 630a 0909 092c 206f 7065 7261 7469 6f6e  c...., operation
    │ │ │ +00072bc0: 5f74 206f 702c 2064 6973 636f 6e6e 6563  _t op, disconnec
    │ │ │ +00072bd0: 745f 7365 7665 7269 7479 5f74 203d 2070  t_severity_t = p
    │ │ │ +00072be0: 6565 725f 636f 6e6e 6563 7469 6f6e 5f69  eer_connection_i
    │ │ │ +00072bf0: 6e74 6572 6661 6365 3a3a 6e6f 726d 616c  nterface::normal
    │ │ │ +00072c00: 2920 3d20 303b 0a09 0976 6972 7475 616c  ) = 0;...virtual
    │ │ │ +00072c10: 2070 6565 725f 6964 2063 6f6e 7374 2661   peer_id const&a
    │ │ │ +00072c20: 6d70 3b20 7069 6428 2920 636f 6e73 7420  mp; pid() const 
    │ │ │ +00072c30: 3d20 303b 0a09 0976 6972 7475 616c 2070  = 0;...virtual p
    │ │ │ +00072c40: 6565 725f 6964 206f 7572 5f70 6964 2829  eer_id our_pid()
    │ │ │ +00072c50: 2063 6f6e 7374 203d 2030 3b0a 0909 7669   const = 0;...vi
    │ │ │ +00072c60: 7274 7561 6c20 766f 6964 2073 6574 5f68  rtual void set_h
    │ │ │ +00072c70: 6f6c 6570 756e 6368 5f6d 6f64 6528 2920  olepunch_mode() 
    │ │ │ +00072c80: 3d20 303b 0a09 0976 6972 7475 616c 2074  = 0;...virtual t
    │ │ │ +00072c90: 6f72 7265 6e74 5f70 6565 722a 2070 6565  orrent_peer* pee
    │ │ │ +00072ca0: 725f 696e 666f 5f73 7472 7563 7428 2920  r_info_struct() 
    │ │ │ +00072cb0: 636f 6e73 7420 3d20 303b 0a09 0976 6972  const = 0;...vir
    │ │ │ +00072cc0: 7475 616c 2076 6f69 6420 7365 745f 7065  tual void set_pe
    │ │ │ +00072cd0: 6572 5f69 6e66 6f28 746f 7272 656e 745f  er_info(torrent_
    │ │ │ +00072ce0: 7065 6572 2a20 7069 2920 3d20 303b 0a09  peer* pi) = 0;..
    │ │ │ +00072cf0: 0976 6972 7475 616c 2062 6f6f 6c20 6973  .virtual bool is
    │ │ │ +00072d00: 5f6f 7574 676f 696e 6728 2920 636f 6e73  _outgoing() cons
    │ │ │ +00072d10: 7420 3d20 303b 0a09 0976 6972 7475 616c  t = 0;...virtual
    │ │ │ +00072d20: 2076 6f69 6420 6164 645f 7374 6174 2873   void add_stat(s
    │ │ │ +00072d30: 7464 3a3a 696e 7436 345f 7420 646f 776e  td::int64_t down
    │ │ │ +00072d40: 6c6f 6164 6564 2c20 7374 643a 3a69 6e74  loaded, std::int
    │ │ │ +00072d50: 3634 5f74 2075 706c 6f61 6465 6429 203d  64_t uploaded) =
    │ │ │ +00072d60: 2030 3b0a 0909 7669 7274 7561 6c20 626f   0;...virtual bo
    │ │ │ +00072d70: 6f6c 2066 6173 745f 7265 636f 6e6e 6563  ol fast_reconnec
    │ │ │ +00072d80: 7428 2920 636f 6e73 7420 3d20 303b 0a09  t() const = 0;..
    │ │ │ +00072d90: 0976 6972 7475 616c 2062 6f6f 6c20 6973  .virtual bool is
    │ │ │ +00072da0: 5f63 686f 6b65 6428 2920 636f 6e73 7420  _choked() const 
    │ │ │ +00072db0: 3d20 303b 0a09 0976 6972 7475 616c 2062  = 0;...virtual b
    │ │ │ +00072dc0: 6f6f 6c20 6661 696c 6564 2829 2063 6f6e  ool failed() con
    │ │ │ +00072dd0: 7374 203d 2030 3b0a 0909 7669 7274 7561  st = 0;...virtua
    │ │ │ +00072de0: 6c20 7374 6174 2063 6f6e 7374 2661 6d70  l stat const&
    │ │ │ +00072df0: 3b20 7374 6174 6973 7469 6373 2829 2063  ; statistics() c
    │ │ │ +00072e00: 6f6e 7374 203d 2030 3b0a 0909 7669 7274  onst = 0;...virt
    │ │ │ +00072e10: 7561 6c20 766f 6964 2067 6574 5f70 6565  ual void get_pee
    │ │ │ +00072e20: 725f 696e 666f 2870 6565 725f 696e 666f  r_info(peer_info
    │ │ │ +00072e30: 2661 6d70 3b20 7029 2063 6f6e 7374 203d  & p) const =
    │ │ │ +00072e40: 2030 3b0a 2369 666e 6465 6620 544f 5252   0;.#ifndef TORR
    │ │ │ +00072e50: 454e 545f 4449 5341 424c 455f 4c4f 4747  ENT_DISABLE_LOGG
    │ │ │ +00072e60: 494e 470a 0909 7669 7274 7561 6c20 626f  ING...virtual bo
    │ │ │ +00072e70: 6f6c 2073 686f 756c 645f 6c6f 6728 7065  ol should_log(pe
    │ │ │ +00072e80: 6572 5f6c 6f67 5f61 6c65 7274 3a3a 6469  er_log_alert::di
    │ │ │ +00072e90: 7265 6374 696f 6e5f 7420 6469 7265 6374  rection_t direct
    │ │ │ +00072ea0: 696f 6e29 2063 6f6e 7374 203d 2030 3b0a  ion) const = 0;.
    │ │ │ +00072eb0: 0909 7669 7274 7561 6c20 766f 6964 2070  ..virtual void p
    │ │ │ +00072ec0: 6565 725f 6c6f 6728 7065 6572 5f6c 6f67  eer_log(peer_log
    │ │ │ +00072ed0: 5f61 6c65 7274 3a3a 6469 7265 6374 696f  _alert::directio
    │ │ │ +00072ee0: 6e5f 7420 6469 7265 6374 696f 6e0a 0909  n_t direction...
    │ │ │ +00072ef0: 092c 2063 6861 7220 636f 6e73 742a 2065  ., char const* e
    │ │ │ +00072f00: 7665 6e74 2c20 6368 6172 2063 6f6e 7374  vent, char const
    │ │ │ +00072f10: 2a20 666d 7420 3d20 2222 2c20 2e2e 2e29  * fmt = "", ...)
    │ │ │ +00072f20: 2063 6f6e 7374 206e 6f65 7863 6570 7420   const noexcept 
    │ │ │ +00072f30: 544f 5252 454e 545f 464f 524d 4154 2834  TORRENT_FORMAT(4
    │ │ │ +00072f40: 2c35 2920 3d20 303b 0a23 656e 6469 660a  ,5) = 0;.#endif.
    │ │ │ +00072f50: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e  
    │ │ │ +00072f60: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00072f90: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0
    ../in │ │ │ +00072fc0: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ +00072fd0: 2f74 6f72 7265 6e74 2e68 7070 3a33 3131 /torrent.hpp:311 │ │ │ +00072fe0: 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 616b mak │ │ │ +00072ff0: 6520 7468 6973 2061 2072 6177 2070 6f69 e this a raw poi │ │ │ +00073000: 6e74 6572 2e20 7065 7268 6170 7320 6b65 nter. perhaps ke │ │ │ +00073010: 6570 2074 6865 2073 6861 7265 645f 7074 ep the shared_pt │ │ │ +00073020: 7220 6172 6f75 6e64 2066 7572 7468 6572 r around further │ │ │ +00073030: 2064 6f77 6e20 7468 6520 6f62 6a65 6374 down the object │ │ │ +00073040: 2074 6f20 6d61 696e 7461 696e 2061 6e20 to maintain an │ │ │ +00073050: 6f77 6e65 723c 2f74 643e 3c2f 7472 3e3c owner< │ │ │ +00073060: 7472 2069 643d 2232 3631 2220 7374 796c tr id="261" styl │ │ │ +00073070: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00073080: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00073090: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +000730a0: 6832 3e6d 616b 6520 7468 6973 2061 2072 h2>make this a r │ │ │ +000730b0: 6177 2070 6f69 6e74 6572 2e20 7065 7268 aw pointer. perh │ │ │ +000730c0: 6170 7320 6b65 6570 2074 6865 2073 6861 aps keep the sha │ │ │ +000730d0: 7265 645f 7074 720a 6172 6f75 6e64 2066 red_ptr.around f │ │ │ +000730e0: 7572 7468 6572 2064 6f77 6e20 7468 6520 urther down the │ │ │ +000730f0: 6f62 6a65 6374 2074 6f20 6d61 696e 7461 object to mainta │ │ │ +00073100: 696e 2061 6e20 6f77 6e65 723c 2f68 323e in an owner

    │ │ │ +00073110: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ +00073120: 6962 746f 7272 656e 742f 746f 7272 656e ibtorrent/torren │ │ │ +00073130: 742e 6870 703a 3331 313c 2f68 343e 3c70 t.hpp:311

    ..bool m │ │ │ +00073180: 5f6c 6976 6520 3d20 6661 6c73 653b 0a09 _live = false;.. │ │ │ +00073190: 7d3b 0a0a 0973 7472 7563 7420 544f 5252 };...struct TORR │ │ │ +000731a0: 454e 545f 4558 5452 415f 4558 504f 5254 ENT_EXTRA_EXPORT │ │ │ +000731b0: 2074 6f72 7265 6e74 5f68 6f74 5f6d 656d torrent_hot_mem │ │ │ +000731c0: 6265 7273 0a09 7b0a 0909 746f 7272 656e bers..{...torren │ │ │ +000731d0: 745f 686f 745f 6d65 6d62 6572 7328 6175 t_hot_members(au │ │ │ +000731e0: 783a 3a73 6573 7369 6f6e 5f69 6e74 6572 x::session_inter │ │ │ +000731f0: 6661 6365 2661 6d70 3b20 7365 730a 0909 face& ses... │ │ │ +00073200: 092c 2061 6464 5f74 6f72 7265 6e74 5f70 ., add_torrent_p │ │ │ +00073210: 6172 616d 7320 636f 6e73 7426 616d 703b arams const& │ │ │ +00073220: 2070 2c20 626f 6f6c 2073 6573 7369 6f6e p, bool session │ │ │ +00073230: 5f70 6175 7365 6429 3b0a 0a09 7072 6f74 _paused);...prot │ │ │ +00073240: 6563 7465 643a 0a09 092f 2f20 7468 6520 ected:...// the │ │ │ +00073250: 7069 6563 6520 7069 636b 6572 2e20 5468 piece picker. Th │ │ │ +00073260: 6973 2069 7320 616c 6c6f 6361 7465 6420 is is allocated │ │ │ +00073270: 6c61 7a69 6c79 2e20 5768 656e 2077 6520 lazily. When we │ │ │ +00073280: 646f 6e27 740a 0909 2f2f 2068 6176 6520 don't...// have │ │ │ +00073290: 616e 7974 6869 6e67 2069 6e20 7468 6520 anything in the │ │ │ +000732a0: 746f 7272 656e 7420 2866 6f72 2069 6e73 torrent (for ins │ │ │ +000732b0: 7461 6e63 652c 2069 6620 6974 2068 6173 tance, if it has │ │ │ +000732c0: 6e27 740a 0909 2f2f 2062 6565 6e20 7374 n't...// been st │ │ │ +000732d0: 6172 7465 6420 7965 7429 206f 7220 6966 arted yet) or if │ │ │ +000732e0: 2077 6520 6861 7665 2065 7665 7279 7468 we have everyth │ │ │ +000732f0: 696e 672c 2074 6865 7265 2069 7320 6e6f ing, there is no │ │ │ +00073300: 0a09 092f 2f20 7069 636b 6572 2e20 4974 ...// picker. It │ │ │ +00073310: 2773 2061 6c6c 6f63 6174 6564 206f 6e2d 's allocated on- │ │ │ +00073320: 6465 6d61 6e64 2074 6865 2066 6972 7374 demand the first │ │ │ +00073330: 2074 696d 6520 7765 206e 6565 640a 0909 time we need... │ │ │ +00073340: 2f2f 2069 7420 696e 2074 6f72 7265 6e74 // it in torrent │ │ │ +00073350: 3a3a 6e65 6564 5f70 6963 6b65 7228 292e ::need_picker(). │ │ │ +00073360: 2049 6e20 6f72 6465 7220 746f 2074 656c In order to tel │ │ │ +00073370: 6c20 7468 650a 0909 2f2f 2064 6966 6665 l the...// diffe │ │ │ +00073380: 7265 6e63 6520 6265 7477 6565 6e20 6861 rence between ha │ │ │ +00073390: 7669 6e67 2065 7665 7279 7468 696e 6720 ving everything │ │ │ +000733a0: 616e 6420 6e6f 7468 696e 6720 696e 0a09 and nothing in.. │ │ │ +000733b0: 092f 2f20 7468 6520 6361 7365 2074 6865 .// the case the │ │ │ +000733c0: 7265 2069 7320 6e6f 2070 6965 6365 2070 re is no piece p │ │ │ +000733d0: 6963 6b65 722c 2073 6565 206d 5f68 6176 icker, see m_hav │ │ │ +000733e0: 655f 616c 6c2e 0a09 0973 7464 3a3a 756e e_all....std::un │ │ │ +000733f0: 6971 7565 5f70 7472 266c 743b 7069 6563 ique_ptr<piec │ │ │ +00073400: 655f 7069 636b 6572 2667 743b 206d 5f70 e_picker> m_p │ │ │ +00073410: 6963 6b65 723b 0a0a 0909 7374 643a 3a75 icker;....std::u │ │ │ +00073420: 6e69 7175 655f 7074 7226 6c74 3b68 6173 nique_ptr<has │ │ │ +00073430: 685f 7069 636b 6572 2667 743b 206d 5f68 h_picker> m_h │ │ │ +00073440: 6173 685f 7069 636b 6572 3b0a 0a3c 6469 ash_picker;....std │ │ │ +00073480: 3a3a 7368 6172 6564 5f70 7472 266c 743b ::shared_ptr< │ │ │ +00073490: 746f 7272 656e 745f 696e 666f 2667 743b torrent_info> │ │ │ +000734a0: 206d 5f74 6f72 7265 6e74 5f66 696c 653b m_torrent_file; │ │ │ +000734b0: 0a3c 2f64 6976 3e0a 0909 2f2f 2054 6869 ....// Thi │ │ │ +000734c0: 7320 6973 2074 6865 2073 756d 206f 6620 s is the sum of │ │ │ +000734d0: 616c 6c20 6e6f 6e2d 7061 6420 6669 6c65 all non-pad file │ │ │ +000734e0: 2073 697a 6573 2e20 496e 2074 6865 206e sizes. In the n │ │ │ +000734f0: 6578 7420 6d61 6a6f 7220 7665 7273 696f ext major versio │ │ │ +00073500: 6e0a 0909 2f2f 2074 6869 7320 6973 2073 n...// this is s │ │ │ +00073510: 746f 7265 6420 696e 2066 696c 655f 7374 tored in file_st │ │ │ +00073520: 6f72 6167 6520 616e 6420 6e6f 206c 6f6e orage and no lon │ │ │ +00073530: 6765 7220 6e65 6564 2074 6f20 6265 206b ger need to be k │ │ │ +00073540: 6570 7420 6865 7265 2e0a 0909 7374 643a ept here....std: │ │ │ +00073550: 3a69 6e74 3634 5f74 206d 5f73 697a 655f :int64_t m_size_ │ │ │ +00073560: 6f6e 5f64 6973 6b20 3d20 303b 0a0a 0909 on_disk = 0;.... │ │ │ +00073570: 2f2f 2061 2062 6163 6b20 7265 6665 7265 // a back refere │ │ │ +00073580: 6e63 6520 746f 2074 6865 2073 6573 7369 nce to the sessi │ │ │ +00073590: 6f6e 0a09 092f 2f20 7468 6973 2074 6f72 on...// this tor │ │ │ +000735a0: 7265 6e74 2062 656c 6f6e 6773 2074 6f2e rent belongs to. │ │ │ +000735b0: 0a09 0961 7578 3a3a 7365 7373 696f 6e5f ...aux::session_ │ │ │ +000735c0: 696e 7465 7266 6163 6526 616d 703b 206d interface& m │ │ │ +000735d0: 5f73 6573 3b0a 0a09 092f 2f20 7468 6973 _ses;....// this │ │ │ +000735e0: 2076 6563 746f 7220 6973 2073 6f72 7465 vector is sorte │ │ │ +000735f0: 6420 6174 2061 6c6c 2074 696d 6573 2c20 d at all times, │ │ │ +00073600: 6279 2074 6865 2070 6f69 6e74 6572 2076 by the pointer v │ │ │ +00073610: 616c 7565 2e0a 0909 2f2f 2075 7365 2073 alue....// use s │ │ │ +00073620: 6f72 7465 645f 696e 7365 7274 2829 2061 orted_insert() a │ │ │ +00073630: 6e64 2073 6f72 7465 645f 6669 6e64 2829 nd sorted_find() │ │ │ +00073640: 206f 6e20 6974 2e20 5468 6520 474e 5520 on it. The GNU │ │ │ +00073650: 5354 4c0a 0909 2f2f 2069 6d70 6c65 6d65 STL...// impleme │ │ │ +00073660: 6e74 6174 696f 6e20 6f6e 2044 6172 7769 ntation on Darwi │ │ │ +00073670: 6e20 7573 6573 2073 6967 6e69 6669 6361 n uses significa │ │ │ +00073680: 6e74 6c79 206c 6573 7320 6d65 6d6f 7279 ntly less memory │ │ │ +00073690: 2074 6f0a 0909 2f2f 2072 6570 7265 7365 to...// represe │ │ │ +000736a0: 6e74 2061 2076 6563 746f 7220 7468 616e nt a vector than │ │ │ +000736b0: 2061 2073 6574 2c20 616e 6420 7468 6973 a set, and this │ │ │ +000736c0: 2073 6574 2069 7320 7479 7069 6361 6c6c set is typicall │ │ │ +000736d0: 790a 0909 2f2f 2072 656c 6174 6976 656c y...// relativel │ │ │ +000736e0: 7920 736d 616c 6c2c 2061 6e64 2069 7427 y small, and it' │ │ │ +000736f0: 7320 6368 6561 7020 746f 2063 6f70 7920 s cheap to copy │ │ │ +00073700: 706f 696e 7465 7273 2e0a 0909 6175 783a pointers....aux: │ │ │ +00073710: 3a76 6563 746f 7226 6c74 3b70 6565 725f :vector<peer_ │ │ │ +00073720: 636f 6e6e 6563 7469 6f6e 2a26 6774 3b20 connection*> │ │ │ +00073730: 6d5f 636f 6e6e 6563 7469 6f6e 733b 0a0a m_connections;.. │ │ │ +00073740: 0909 2f2f 2074 6865 2073 6372 6170 6520 ..// the scrape │ │ │ +00073750: 6461 7461 2066 726f 6d20 7468 6520 7472 data from the tr │ │ │ +00073760: 6163 6b65 7220 7265 7370 6f6e 7365 2c20 acker response, │ │ │ +00073770: 7468 6973 0a09 092f 2f20 6973 206f 7074 this...// is opt │ │ │ +00073780: 696f 6e61 6c20 616e 6420 6d61 7920 6265 ional and may be │ │ │ +00073790: 2030 7866 6666 6666 660a 0909 7374 643a 0xffffff...std: │ │ │ +000737a0: 3a75 696e 7433 325f 7420 6d5f 636f 6d70 :uint32_t m_comp │ │ │ +000737b0: 6c65 7465 3a32 343b 0a0a 0909 2f2f 2073 lete:24;....// s │ │ │ +000737c0: 6574 2074 6f20 7472 7565 2077 6865 6e20 et to true when │ │ │ +000737d0: 7468 6973 2074 6f72 7265 6e74 206d 6179 this torrent may │ │ │ +000737e0: 206e 6f74 2064 6f77 6e6c 6f61 6420 616e not download an │ │ │ +000737f0: 7974 6869 6e67 0a09 0962 6f6f 6c20 6d5f ything...bool m_ │ │ │ +00073800: 7570 6c6f 6164 5f6d 6f64 653a 313b 0a0a upload_mode:1;.. │ │ │ +00073810: 0909 2f2f 2074 6869 7320 6973 2073 6574 ..// this is set │ │ │ +00073820: 2074 6f20 6661 6c73 6520 6173 206c 6f6e to false as lon │ │ │ +00073830: 6720 6173 2074 6865 2063 6f6e 6e65 6374 g as the connect │ │ │ +00073840: 696f 6e73 0a09 092f 2f20 6f66 2074 6869 ions...// of thi │ │ │ +00073850: 7320 746f 7272 656e 7420 6861 7665 6e27 s torrent haven' │ │ │ +00073860: 7420 6265 656e 2069 6e69 7469 616c 697a t been initializ │ │ │ +00073870: 6564 2e20 4966 2077 650a 0909 2f2f 2068 ed. If we...// h │ │ │ +00073880: 6176 6520 6d65 7461 6461 7461 2066 726f ave metadata fro │ │ │ +00073890: 6d20 7468 6520 7374 6172 742c 2063 6f6e m the start, con │ │ │ +000738a0: 6e65 6374 696f 6e73 2061 7265 0a09 092f nections are.../ │ │ │ +000738b0: 2f20 696e 6974 6961 6c69 7a65 6420 696d / initialized im │ │ │ +000738c0: 6d65 6469 6174 656c 792c 2069 6620 7765 mediately, if we │ │ │ +000738d0: 2064 6964 6e27 7420 6861 7665 206d 6574 didn't have met │ │ │ +000738e0: 6164 6174 612c 0a09 092f 2f20 7468 6579 adata,...// they │ │ │ +000738f0: 2061 7265 2069 6e69 7469 616c 697a 6564 are initialized │ │ │ +00073900: 2072 6967 6874 2061 6674 6572 2066 696c right after fil │ │ │ +00073910: 6573 5f63 6865 636b 6564 2829 2e0a 0909 es_checked().... │ │ │ +00073920: 2f2f 2076 616c 6964 5f72 6573 756d 655f // valid_resume_ │ │ │ +00073930: 6461 7461 2829 2077 696c 6c20 7265 7475 data() will retu │ │ │ +00073940: 726e 2066 616c 7365 2061 7320 6c6f 6e67 rn false as long │ │ │ +00073950: 2061 730a 0909 2f2f 2074 6865 2063 6f6e as...// the con │ │ │ +00073960: 6e65 6374 696f 6e73 2061 7265 6e27 7420 nections aren't │ │ │ +00073970: 696e 6974 6961 6c69 7a65 642c 2074 6f20 initialized, to │ │ │ +00073980: 6176 6f69 640a 3c2f 7072 653e 3c2f 7464 avoid.

    relevance │ │ │ +000739c0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +000739d0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../include/libt │ │ │ +00073a00: 6f72 7265 6e74 2f74 6f72 7265 6e74 2e68 orrent/torrent.h │ │ │ +00073a10: 7070 3a34 3934 3c2f 613e 3c2f 7464 3e3c pp:494< │ │ │ +00073a20: 7464 3e6d 616b 6520 6772 6163 6566 756c td>make graceful │ │ │ +00073a30: 2070 6175 7365 2061 6c73 6f20 6669 6e69 pause also fini │ │ │ +00073a40: 7368 2061 6c6c 2073 656e 6469 6e67 2062 sh all sending b │ │ │ +00073a50: 6c6f 636b 7320 6265 666f 7265 2064 6973 locks before dis │ │ │ +00073a60: 636f 6e6e 6563 7469 6e67 3c2f 7464 3e3c connecting< │ │ │ +00073a70: 2f74 723e 3c74 7220 6964 3d22 3236 3222 /tr>

    make gra │ │ │ +00073ac0: 6365 6675 6c20 7061 7573 6520 616c 736f ceful pause also │ │ │ +00073ad0: 2066 696e 6973 6820 616c 6c20 7365 6e64 finish all send │ │ │ +00073ae0: 696e 6720 626c 6f63 6b73 0a62 6566 6f72 ing blocks.befor │ │ │ +00073af0: 6520 6469 7363 6f6e 6e65 6374 696e 673c e disconnecting< │ │ │ +00073b00: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ +00073b10: 6465 2f6c 6962 746f 7272 656e 742f 746f de/libtorrent/to │ │ │ +00073b20: 7272 656e 742e 6870 703a 3439 343c 2f68 rrent.hpp:494
    ...v
    │ │ │ +00073b70: 6f69 6420 6f6e 5f72 6573 756d 655f 6461  oid on_resume_da
    │ │ │ +00073b80: 7461 5f63 6865 636b 6564 2873 7461 7475  ta_checked(statu
    │ │ │ +00073b90: 735f 7420 7374 6174 7573 2c20 7374 6f72  s_t status, stor
    │ │ │ +00073ba0: 6167 655f 6572 726f 7220 636f 6e73 7426  age_error const&
    │ │ │ +00073bb0: 616d 703b 2065 7272 6f72 293b 0a09 0976  amp; error);...v
    │ │ │ +00073bc0: 6f69 6420 6f6e 5f66 6f72 6365 5f72 6563  oid on_force_rec
    │ │ │ +00073bd0: 6865 636b 2873 7461 7475 735f 7420 7374  heck(status_t st
    │ │ │ +00073be0: 6174 7573 2c20 7374 6f72 6167 655f 6572  atus, storage_er
    │ │ │ +00073bf0: 726f 7220 636f 6e73 7426 616d 703b 2065  ror const& e
    │ │ │ +00073c00: 7272 6f72 293b 0a09 0976 6f69 6420 6f6e  rror);...void on
    │ │ │ +00073c10: 5f70 6965 6365 5f68 6173 6865 6428 6175  _piece_hashed(au
    │ │ │ +00073c20: 783a 3a76 6563 746f 7226 6c74 3b73 6861  x::vector<sha
    │ │ │ +00073c30: 3235 365f 6861 7368 2667 743b 2062 6c6f  256_hash> blo
    │ │ │ +00073c40: 636b 5f68 6173 6865 730a 0909 092c 2070  ck_hashes...., p
    │ │ │ +00073c50: 6965 6365 5f69 6e64 6578 5f74 2070 6965  iece_index_t pie
    │ │ │ +00073c60: 6365 2c20 7368 6131 5f68 6173 6820 636f  ce, sha1_hash co
    │ │ │ +00073c70: 6e73 7426 616d 703b 2070 6965 6365 5f68  nst& piece_h
    │ │ │ +00073c80: 6173 680a 0909 092c 2073 746f 7261 6765  ash...., storage
    │ │ │ +00073c90: 5f65 7272 6f72 2063 6f6e 7374 2661 6d70  _error const&
    │ │ │ +00073ca0: 3b20 6572 726f 7229 3b0a 0909 766f 6964  ; error);...void
    │ │ │ +00073cb0: 2066 696c 6573 5f63 6865 636b 6564 2829   files_checked()
    │ │ │ +00073cc0: 3b0a 0909 766f 6964 2073 7461 7274 5f63  ;...void start_c
    │ │ │ +00073cd0: 6865 636b 696e 6728 293b 0a0a 0909 766f  hecking();....vo
    │ │ │ +00073ce0: 6964 2073 7461 7274 5f61 6e6e 6f75 6e63  id start_announc
    │ │ │ +00073cf0: 696e 6728 293b 0a09 0976 6f69 6420 7374  ing();...void st
    │ │ │ +00073d00: 6f70 5f61 6e6e 6f75 6e63 696e 6728 293b  op_announcing();
    │ │ │ +00073d10: 0a0a 0909 766f 6964 2073 656e 645f 7570  ....void send_up
    │ │ │ +00073d20: 6c6f 6164 5f6f 6e6c 7928 293b 0a0a 2369  load_only();..#i
    │ │ │ +00073d30: 666e 6465 6620 544f 5252 454e 545f 4449  fndef TORRENT_DI
    │ │ │ +00073d40: 5341 424c 455f 5348 4152 455f 4d4f 4445  SABLE_SHARE_MODE
    │ │ │ +00073d50: 0a09 0976 6f69 6420 7365 6e64 5f73 6861  ...void send_sha
    │ │ │ +00073d60: 7265 5f6d 6f64 6528 293b 0a09 0976 6f69  re_mode();...voi
    │ │ │ +00073d70: 6420 7365 745f 7368 6172 655f 6d6f 6465  d set_share_mode
    │ │ │ +00073d80: 2862 6f6f 6c20 7329 3b0a 0909 626f 6f6c  (bool s);...bool
    │ │ │ +00073d90: 2073 6861 7265 5f6d 6f64 6528 2920 636f   share_mode() co
    │ │ │ +00073da0: 6e73 7420 7b20 7265 7475 726e 206d 5f73  nst { return m_s
    │ │ │ +00073db0: 6861 7265 5f6d 6f64 653b 207d 0a23 656e  hare_mode; }.#en
    │ │ │ +00073dc0: 6469 660a 0a3c 6469 7620 7374 796c 653d  dif..
    ..bool gracef │ │ │ +00073e00: 756c 5f70 6175 7365 2829 2063 6f6e 7374 ul_pause() const │ │ │ +00073e10: 207b 2072 6574 7572 6e20 6d5f 6772 6163 { return m_grac │ │ │ +00073e20: 6566 756c 5f70 6175 7365 5f6d 6f64 653b eful_pause_mode; │ │ │ +00073e30: 207d 0a3c 2f64 6976 3e0a 0909 746f 7272 }.
    ...torr │ │ │ +00073e40: 656e 745f 666c 6167 735f 7420 666c 6167 ent_flags_t flag │ │ │ +00073e50: 7328 2920 636f 6e73 743b 0a09 0976 6f69 s() const;...voi │ │ │ +00073e60: 6420 7365 745f 666c 6167 7328 746f 7272 d set_flags(torr │ │ │ +00073e70: 656e 745f 666c 6167 735f 7420 666c 6167 ent_flags_t flag │ │ │ +00073e80: 732c 2074 6f72 7265 6e74 5f66 6c61 6773 s, torrent_flags │ │ │ +00073e90: 5f74 206d 6173 6b29 3b0a 0a09 0976 6f69 _t mask);....voi │ │ │ +00073ea0: 6420 7365 745f 7570 6c6f 6164 5f6d 6f64 d set_upload_mod │ │ │ +00073eb0: 6528 626f 6f6c 2062 293b 0a09 0962 6f6f e(bool b);...boo │ │ │ +00073ec0: 6c20 7570 6c6f 6164 5f6d 6f64 6528 2920 l upload_mode() │ │ │ +00073ed0: 636f 6e73 7420 7b20 7265 7475 726e 206d const { return m │ │ │ +00073ee0: 5f75 706c 6f61 645f 6d6f 6465 207c 7c20 _upload_mode || │ │ │ +00073ef0: 6d5f 6772 6163 6566 756c 5f70 6175 7365 m_graceful_pause │ │ │ +00073f00: 5f6d 6f64 653b 207d 0a09 0962 6f6f 6c20 _mode; }...bool │ │ │ +00073f10: 6973 5f75 706c 6f61 645f 6f6e 6c79 2829 is_upload_only() │ │ │ +00073f20: 2063 6f6e 7374 207b 2072 6574 7572 6e20 const { return │ │ │ +00073f30: 6973 5f66 696e 6973 6865 6428 2920 7c7c is_finished() || │ │ │ +00073f40: 2075 706c 6f61 645f 6d6f 6465 2829 3b20 upload_mode(); │ │ │ +00073f50: 7d0a 0a09 0969 6e74 2073 6565 645f 7261 }....int seed_ra │ │ │ +00073f60: 6e6b 2861 7578 3a3a 7365 7373 696f 6e5f nk(aux::session_ │ │ │ +00073f70: 7365 7474 696e 6773 2063 6f6e 7374 2661 settings const&a │ │ │ +00073f80: 6d70 3b20 7329 2063 6f6e 7374 3b0a 0a09 mp; s) const;... │ │ │ +00073f90: 0976 6f69 6420 6164 645f 7069 6563 6528 .void add_piece( │ │ │ +00073fa0: 7069 6563 655f 696e 6465 785f 7420 7069 piece_index_t pi │ │ │ +00073fb0: 6563 652c 2063 6861 7220 636f 6e73 742a ece, char const* │ │ │ +00073fc0: 2064 6174 612c 2061 6464 5f70 6965 6365 data, add_piece │ │ │ +00073fd0: 5f66 6c61 6773 5f74 2066 6c61 6773 293b _flags_t flags); │ │ │ +00073fe0: 0a09 0976 6f69 6420 6164 645f 7069 6563 ...void add_piec │ │ │ +00073ff0: 655f 6173 796e 6328 7069 6563 655f 696e e_async(piece_in │ │ │ +00074000: 6465 785f 7420 7069 6563 652c 2073 7464 dex_t piece, std │ │ │ +00074010: 3a3a 7665 6374 6f72 266c 743b 6368 6172 ::vector<char │ │ │ +00074020: 2667 743b 2064 6174 612c 2061 6464 5f70 > data, add_p │ │ │ +00074030: 6965 6365 5f66 6c61 6773 5f74 2066 6c61 iece_flags_t fla │ │ │ +00074040: 6773 293b 0a09 0976 6f69 6420 6f6e 5f64 gs);...void on_d │ │ │ +00074050: 6973 6b5f 7772 6974 655f 636f 6d70 6c65 isk_write_comple │ │ │ +00074060: 7465 2873 746f 7261 6765 5f65 7272 6f72 te(storage_error │ │ │ +00074070: 2063 6f6e 7374 2661 6d70 3b20 6572 726f const& erro │ │ │ +00074080: 720a 0909 092c 2070 6565 725f 7265 7175 r...., peer_requ │ │ │ +00074090: 6573 7420 636f 6e73 7426 616d 703b 2070 est const& p │ │ │ +000740a0: 293b 0a0a 0909 766f 6964 2073 6574 5f70 );....void set_p │ │ │ +000740b0: 726f 6772 6573 735f 7070 6d28 696e 7420 rogress_ppm(int │ │ │ +000740c0: 7029 207b 206d 5f70 726f 6772 6573 735f p) { m_progress_ │ │ │ +000740d0: 7070 6d20 3d20 7374 643a 3a75 696e 7433 ppm = std::uint3 │ │ │ +000740e0: 325f 7428 7029 3b20 7d0a 0909 7374 7275 2_t(p); }...stru │ │ │ +000740f0: 6374 2072 6561 645f 7069 6563 655f 7374 ct read_piece_st │ │ │ +00074100: 7275 6374 0a09 097b 0a09 0909 626f 6f73 ruct...{....boos │ │ │ +00074110: 743a 3a73 6861 7265 645f 6172 7261 7926 t::shared_array& │ │ │ +00074120: 6c74 3b63 6861 7226 6774 3b20 7069 6563 lt;char> piec │ │ │ +00074130: 655f 6461 7461 3b0a 0909 0969 6e74 2062 e_data;....int b │ │ │ +00074140: 6c6f 636b 735f 6c65 6674 3b0a 0909 0962 locks_left;....b │ │ │ +00074150: 6f6f 6c20 6661 696c 3b0a 0909 0965 7272 ool fail;....err │ │ │ +00074160: 6f72 5f63 6f64 6520 6572 726f 723b 0a09 or_code error;.. │ │ │ +00074170: 097d 3b0a 0909 766f 6964 2072 6561 645f .};...void read_ │ │ │ +00074180: 7069 6563 6528 7069 6563 655f 696e 6465 piece(piece_inde │ │ │ +00074190: 785f 7429 3b0a 0909 766f 6964 206f 6e5f x_t);...void on_ │ │ │ +000741a0: 6469 736b 5f72 6561 645f 636f 6d70 6c65 disk_read_comple │ │ │ +000741b0: 7465 2864 6973 6b5f 6275 6666 6572 5f68 te(disk_buffer_h │ │ │ +000741c0: 6f6c 6465 722c 2073 746f 7261 6765 5f65 older, storage_e │ │ │ +000741d0: 7272 6f72 2063 6f6e 7374 2661 6d70 3b0a rror const&. │ │ │ +000741e0: 0909 092c 2070 6565 725f 7265 7175 6573 ..., peer_reques │ │ │ +000741f0: 7420 636f 6e73 7426 616d 703b 2c20 7374 t const&, st │ │ │ +00074200: 643a 3a73 6861 7265 645f 7074 7226 6c74 d::shared_ptr< │ │ │ +00074210: 3b72 6561 645f 7069 6563 655f 7374 7275 ;read_piece_stru │ │ │ +00074220: 6374 2667 743b 293b 0a0a 0909 7374 6f72 ct>);....stor │ │ │ +00074230: 6167 655f 6d6f 6465 5f74 2073 746f 7261 age_mode_t stora │ │ │ +00074240: 6765 5f6d 6f64 6528 2920 636f 6e73 743b ge_mode() const; │ │ │ +00074250: 0a0a 0909 2f2f 2074 6869 7320 7769 6c6c ....// this will │ │ │ +00074260: 2066 6c61 6720 7468 6520 746f 7272 656e flag the torren │ │ │ +00074270: 7420 6173 2061 626f 7274 6564 2e20 5468 t as aborted. Th │ │ │ +00074280: 6520 6d61 696e 0a3c 2f70 7265 3e3c 2f74 e main.
    relevanc │ │ │ +000742c0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../include/lib │ │ │ +00074300: 746f 7272 656e 742f 746f 7272 656e 742e torrent/torrent. │ │ │ +00074310: 6870 703a 3633 313c 2f61 3e3c 2f74 643e hpp:631 │ │ │ +00074320: 3c74 643e 6d61 6b65 2074 6869 7320 666c make this fl │ │ │ +00074330: 6167 2061 2063 6f6d 6269 6e61 7469 6f6e ag a combination │ │ │ +00074340: 206f 6620 7468 6520 6f74 6865 7220 6f6e of the other on │ │ │ +00074350: 6573 3c2f 7464 3e3c 2f74 723e 3c74 7220 es

    │ │ │ +000743a0: 6d61 6b65 2074 6869 7320 666c 6167 2061 make this flag a │ │ │ +000743b0: 2063 6f6d 6269 6e61 7469 6f6e 0a6f 6620 combination.of │ │ │ +000743c0: 7468 6520 6f74 6865 7220 6f6e 6573 3c2f the other ones

    ../includ │ │ │ +000743e0: 652f 6c69 6274 6f72 7265 6e74 2f74 6f72 e/libtorrent/tor │ │ │ +000743f0: 7265 6e74 2e68 7070 3a36 3331 3c2f 6834 rent.hpp:631

    ..voi
    │ │ │ +00074440: 6420 646f 5f70 6175 7365 2829 3b0a 0909  d do_pause();...
    │ │ │ +00074450: 766f 6964 2064 6f5f 7265 7375 6d65 2829  void do_resume()
    │ │ │ +00074460: 3b0a 0a09 0973 6563 6f6e 6473 3332 2066  ;....seconds32 f
    │ │ │ +00074470: 696e 6973 6865 645f 7469 6d65 2829 2063  inished_time() c
    │ │ │ +00074480: 6f6e 7374 3b0a 0909 7365 636f 6e64 7333  onst;...seconds3
    │ │ │ +00074490: 3220 6163 7469 7665 5f74 696d 6528 2920  2 active_time() 
    │ │ │ +000744a0: 636f 6e73 743b 0a09 0973 6563 6f6e 6473  const;...seconds
    │ │ │ +000744b0: 3332 2073 6565 6469 6e67 5f74 696d 6528  32 seeding_time(
    │ │ │ +000744c0: 2920 636f 6e73 743b 0a09 0973 6563 6f6e  ) const;...secon
    │ │ │ +000744d0: 6473 3332 2075 706c 6f61 645f 6d6f 6465  ds32 upload_mode
    │ │ │ +000744e0: 5f74 696d 6528 2920 636f 6e73 743b 0a0a  _time() const;..
    │ │ │ +000744f0: 0909 626f 6f6c 2069 735f 7061 7573 6564  ..bool is_paused
    │ │ │ +00074500: 2829 2063 6f6e 7374 3b0a 0909 626f 6f6c  () const;...bool
    │ │ │ +00074510: 2069 735f 746f 7272 656e 745f 7061 7573   is_torrent_paus
    │ │ │ +00074520: 6564 2829 2063 6f6e 7374 207b 2072 6574  ed() const { ret
    │ │ │ +00074530: 7572 6e20 6d5f 7061 7573 6564 3b20 7d0a  urn m_paused; }.
    │ │ │ +00074540: 0909 766f 6964 2066 6f72 6365 5f72 6563  ..void force_rec
    │ │ │ +00074550: 6865 636b 2829 3b0a 0909 766f 6964 2073  heck();...void s
    │ │ │ +00074560: 6176 655f 7265 7375 6d65 5f64 6174 6128  ave_resume_data(
    │ │ │ +00074570: 7265 7375 6d65 5f64 6174 615f 666c 6167  resume_data_flag
    │ │ │ +00074580: 735f 7420 666c 6167 7329 3b0a 0a09 0962  s_t flags);....b
    │ │ │ +00074590: 6f6f 6c20 6e65 6564 5f73 6176 655f 7265  ool need_save_re
    │ │ │ +000745a0: 7375 6d65 5f64 6174 6128 7265 7375 6d65  sume_data(resume
    │ │ │ +000745b0: 5f64 6174 615f 666c 6167 735f 7420 666c  _data_flags_t fl
    │ │ │ +000745c0: 6167 7329 2063 6f6e 7374 0a09 097b 0a09  ags) const...{..
    │ │ │ +000745d0: 0909 7265 7475 726e 2062 6f6f 6c28 6d5f  ..return bool(m_
    │ │ │ +000745e0: 6e65 6564 5f73 6176 655f 7265 7375 6d65  need_save_resume
    │ │ │ +000745f0: 5f64 6174 6120 2661 6d70 3b20 666c 6167  _data & flag
    │ │ │ +00074600: 7329 3b0a 0909 7d0a 0a09 0976 6f69 6420  s);...}....void 
    │ │ │ +00074610: 7365 745f 6e65 6564 5f73 6176 655f 7265  set_need_save_re
    │ │ │ +00074620: 7375 6d65 2872 6573 756d 655f 6461 7461  sume(resume_data
    │ │ │ +00074630: 5f66 6c61 6773 5f74 2063 6f6e 7374 2066  _flags_t const f
    │ │ │ +00074640: 6c61 6729 0a09 097b 0a3c 6469 7620 7374  lag)...{.
    ...m_need │ │ │ +00074680: 5f73 6176 655f 7265 7375 6d65 5f64 6174 _save_resume_dat │ │ │ +00074690: 6120 7c3d 2074 6f72 7265 6e74 5f68 616e a |= torrent_han │ │ │ +000746a0: 646c 653a 3a6f 6e6c 795f 6966 5f6d 6f64 dle::only_if_mod │ │ │ +000746b0: 6966 6965 643b 0a3c 2f64 6976 3e0a 0909 ified;.
    ... │ │ │ +000746c0: 0969 6620 286d 5f6e 6565 645f 7361 7665 .if (m_need_save │ │ │ +000746d0: 5f72 6573 756d 655f 6461 7461 2026 616d _resume_data &am │ │ │ +000746e0: 703b 2066 6c61 6729 2072 6574 7572 6e3b p; flag) return; │ │ │ +000746f0: 0a09 0909 6d5f 6e65 6564 5f73 6176 655f ....m_need_save_ │ │ │ +00074700: 7265 7375 6d65 5f64 6174 6120 7c3d 2066 resume_data |= f │ │ │ +00074710: 6c61 673b 0a09 0909 7374 6174 655f 7570 lag;....state_up │ │ │ +00074720: 6461 7465 6428 293b 0a09 097d 0a0a 0909 dated();...}.... │ │ │ +00074730: 6164 645f 746f 7272 656e 745f 7061 7261 add_torrent_para │ │ │ +00074740: 6d73 2067 6574 5f72 6573 756d 655f 6461 ms get_resume_da │ │ │ +00074750: 7461 2872 6573 756d 655f 6461 7461 5f66 ta(resume_data_f │ │ │ +00074760: 6c61 6773 5f74 2066 6c61 6773 2920 636f lags_t flags) co │ │ │ +00074770: 6e73 743b 0a0a 0909 626f 6f6c 2069 735f nst;....bool is_ │ │ │ +00074780: 6175 746f 5f6d 616e 6167 6564 2829 2063 auto_managed() c │ │ │ +00074790: 6f6e 7374 207b 2072 6574 7572 6e20 6d5f onst { return m_ │ │ │ +000747a0: 6175 746f 5f6d 616e 6167 6564 3b20 7d0a auto_managed; }. │ │ │ +000747b0: 0909 766f 6964 2061 7574 6f5f 6d61 6e61 ..void auto_mana │ │ │ +000747c0: 6765 6428 626f 6f6c 2061 293b 0a0a 0909 ged(bool a);.... │ │ │ +000747d0: 626f 6f6c 2073 686f 756c 645f 6368 6563 bool should_chec │ │ │ +000747e0: 6b5f 6669 6c65 7328 2920 636f 6e73 743b k_files() const; │ │ │ +000747f0: 0a0a 0909 626f 6f6c 2064 656c 6574 655f ....bool delete_ │ │ │ +00074800: 6669 6c65 7328 7265 6d6f 7665 5f66 6c61 files(remove_fla │ │ │ +00074810: 6773 5f74 206f 7074 696f 6e73 293b 0a09 gs_t options);.. │ │ │ +00074820: 0976 6f69 6420 7065 6572 735f 6572 6173 .void peers_eras │ │ │ +00074830: 6564 2873 7464 3a3a 7665 6374 6f72 266c ed(std::vector&l │ │ │ +00074840: 743b 746f 7272 656e 745f 7065 6572 2a26 t;torrent_peer*& │ │ │ +00074850: 6774 3b20 636f 6e73 7426 616d 703b 2070 gt; const& p │ │ │ +00074860: 6565 7273 293b 0a0a 2369 6620 544f 5252 eers);..#if TORR │ │ │ +00074870: 454e 545f 4142 495f 5645 5253 494f 4e20 ENT_ABI_VERSION │ │ │ +00074880: 3d3d 2031 0a23 6966 2021 544f 5252 454e == 1.#if !TORREN │ │ │ +00074890: 545f 4e4f 5f46 5055 0a09 0976 6f69 6420 T_NO_FPU...void │ │ │ +000748a0: 6669 6c65 5f70 726f 6772 6573 735f 666c file_progress_fl │ │ │ +000748b0: 6f61 7428 6175 783a 3a76 6563 746f 7226 oat(aux::vector& │ │ │ +000748c0: 6c74 3b66 6c6f 6174 2c20 6669 6c65 5f69 lt;float, file_i │ │ │ +000748d0: 6e64 6578 5f74 2667 743b 2661 6d70 3b20 ndex_t>& │ │ │ +000748e0: 6670 293b 0a23 656e 6469 660a 2365 6e64 fp);.#endif.#end │ │ │ +000748f0: 6966 202f 2f20 544f 5252 454e 545f 4142 if // TORRENT_AB │ │ │ +00074900: 495f 5645 5253 494f 4e0a 0a09 0976 6f69 I_VERSION....voi │ │ │ +00074910: 6420 706f 7374 5f70 6965 6365 5f61 7661 d post_piece_ava │ │ │ +00074920: 696c 6162 696c 6974 7928 293b 0a09 0976 ilability();...v │ │ │ +00074930: 6f69 6420 7069 6563 655f 6176 6169 6c61 oid piece_availa │ │ │ +00074940: 6269 6c69 7479 2861 7578 3a3a 7665 6374 bility(aux::vect │ │ │ +00074950: 6f72 266c 743b 696e 742c 2070 6965 6365 or<int, piece │ │ │ +00074960: 5f69 6e64 6578 5f74 2667 743b 2661 6d70 _index_t>& │ │ │ +00074970: 3b20 6176 6169 6c29 2063 6f6e 7374 3b0a ; avail) const;. │ │ │ +00074980: 0a09 0976 6f69 6420 7365 745f 7069 6563 ...void set_piec │ │ │ +00074990: 655f 7072 696f 7269 7479 2870 6965 6365 e_priority(piece │ │ │ +000749a0: 5f69 6e64 6578 5f74 2069 6e64 6578 2c20 _index_t index, │ │ │ +000749b0: 646f 776e 6c6f 6164 5f70 7269 6f72 6974 download_priorit │ │ │ +000749c0: 795f 7420 7072 696f 7269 7479 293b 0a09 y_t priority);.. │ │ │ +000749d0: 0964 6f77 6e6c 6f61 645f 7072 696f 7269 .download_priori │ │ │ +000749e0: 7479 5f74 2070 6965 6365 5f70 7269 6f72 ty_t piece_prior │ │ │ +000749f0: 6974 7928 7069 6563 655f 696e 6465 785f ity(piece_index_ │ │ │ +00074a00: 7420 696e 6465 7829 2063 6f6e 7374 3b0a t index) const;. │ │ │ +00074a10: 0a09 0976 6f69 6420 7072 696f 7269 7469 ...void prioriti │ │ │ +00074a20: 7a65 5f70 6965 6365 7328 6175 783a 3a76 ze_pieces(aux::v │ │ │ +00074a30: 6563 746f 7226 6c74 3b64 6f77 6e6c 6f61 ector<downloa │ │ │ +00074a40: 645f 7072 696f 7269 7479 5f74 2c20 7069 d_priority_t, pi │ │ │ +00074a50: 6563 655f 696e 6465 785f 7426 6774 3b20 ece_index_t> │ │ │ +00074a60: 636f 6e73 7426 616d 703b 2070 6965 6365 const& piece │ │ │ +00074a70: 7329 3b0a 0909 766f 6964 2070 7269 6f72 s);...void prior │ │ │ +00074a80: 6974 697a 655f 7069 6563 655f 6c69 7374 itize_piece_list │ │ │ +00074a90: 2873 7464 3a3a 7665 6374 6f72 266c 743b (std::vector< │ │ │ +00074aa0: 7374 643a 3a70 6169 7226 6c74 3b70 6965 std::pair<pie │ │ │ +00074ab0: 6365 5f69 6e64 6578 5f74 2c20 646f 776e ce_index_t, down │ │ │ +00074ac0: 6c6f 6164 5f70 7269 6f72 6974 795f 7426 load_priority_t& │ │ │ +00074ad0: 6774 3b26 6774 3b20 636f 6e73 7426 616d gt;> const&am │ │ │ +00074ae0: 703b 2070 6965 6365 7329 3b0a 3c2f 7072 p; pieces);.rel │ │ │ +00074b20: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../includ │ │ │ +00074b60: 652f 6c69 6274 6f72 7265 6e74 2f74 6f72 e/libtorrent/tor │ │ │ +00074b70: 7265 6e74 2e68 7070 3a31 3434 303c 2f61 rent.hpp:1440this w │ │ │ +00074b90: 6173 7465 7320 3520 6269 7473 2070 6572 astes 5 bits per │ │ │ +00074ba0: 2066 696c 653c 2f74 643e 3c2f 7472 3e3c file< │ │ │ +00074bb0: 7472 2069 643d 2232 3634 2220 7374 796c tr id="264" styl │ │ │ +00074bc0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00074bd0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00074be0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00074bf0: 6832 3e74 6869 7320 7761 7374 6573 2035 h2>this wastes 5 │ │ │ +00074c00: 2062 6974 7320 7065 7220 6669 6c65 3c2f bits per file

    ../includ │ │ │ +00074c20: 652f 6c69 6274 6f72 7265 6e74 2f74 6f72 e/libtorrent/tor │ │ │ +00074c30: 7265 6e74 2e68 7070 3a31 3434 303c 2f68 rent.hpp:1440
    #ifn
    │ │ │ +00074c80: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ +00074c90: 424c 455f 4558 5445 4e53 494f 4e53 0a09  BLE_EXTENSIONS..
    │ │ │ +00074ca0: 0973 7464 3a3a 6c69 7374 266c 743b 7374  .std::list<st
    │ │ │ +00074cb0: 643a 3a73 6861 7265 645f 7074 7226 6c74  d::shared_ptr<
    │ │ │ +00074cc0: 3b74 6f72 7265 6e74 5f70 6c75 6769 6e26  ;torrent_plugin&
    │ │ │ +00074cd0: 6774 3b26 6774 3b20 6d5f 6578 7465 6e73  gt;> m_extens
    │ │ │ +00074ce0: 696f 6e73 3b0a 2365 6e64 6966 0a0a 0909  ions;.#endif....
    │ │ │ +00074cf0: 2f2f 2075 7365 6420 666f 7220 7472 6163  // used for trac
    │ │ │ +00074d00: 6b65 7220 616e 6e6f 756e 6365 730a 0909  ker announces...
    │ │ │ +00074d10: 6465 6164 6c69 6e65 5f74 696d 6572 206d  deadline_timer m
    │ │ │ +00074d20: 5f74 7261 636b 6572 5f74 696d 6572 3b0a  _tracker_timer;.
    │ │ │ +00074d30: 0a09 092f 2f20 7573 6564 2074 6f20 6465  ...// used to de
    │ │ │ +00074d40: 7465 6374 2077 6865 6e20 7765 2061 7265  tect when we are
    │ │ │ +00074d50: 2061 6374 6976 6520 6f72 2069 6e61 6374   active or inact
    │ │ │ +00074d60: 6976 6520 666f 7220 6c6f 6e67 2065 6e6f  ive for long eno
    │ │ │ +00074d70: 7567 680a 0909 2f2f 2074 6f20 7472 6967  ugh...// to trig
    │ │ │ +00074d80: 6765 7220 7468 6520 6175 746f 2d6d 616e  ger the auto-man
    │ │ │ +00074d90: 6167 6520 6c6f 6769 630a 0909 6465 6164  age logic...dead
    │ │ │ +00074da0: 6c69 6e65 5f74 696d 6572 206d 5f69 6e61  line_timer m_ina
    │ │ │ +00074db0: 6374 6976 6974 795f 7469 6d65 723b 0a0a  ctivity_timer;..
    │ │ │ +00074dc0: 0909 2f2f 2074 6869 7320 6973 2074 6865  ..// this is the
    │ │ │ +00074dd0: 2075 706c 6f61 6420 616e 6420 646f 776e   upload and down
    │ │ │ +00074de0: 6c6f 6164 2073 7461 7469 7374 6963 7320  load statistics 
    │ │ │ +00074df0: 666f 7220 7468 6520 7768 6f6c 6520 746f  for the whole to
    │ │ │ +00074e00: 7272 656e 742e 0a09 092f 2f20 6974 2773  rrent....// it's
    │ │ │ +00074e10: 2075 7064 6174 6564 2066 726f 6d20 616c   updated from al
    │ │ │ +00074e20: 6c20 6974 7320 7065 6572 7320 6f6e 6365  l its peers once
    │ │ │ +00074e30: 2065 7665 7279 2073 6563 6f6e 642e 0a09   every second...
    │ │ │ +00074e40: 096c 6962 746f 7272 656e 743a 3a73 7461  .libtorrent::sta
    │ │ │ +00074e50: 7420 6d5f 7374 6174 3b0a 0a09 092f 2f20  t m_stat;....// 
    │ │ │ +00074e60: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00074e70: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d0a 0a09  -------------...
    │ │ │ +00074e80: 092f 2f20 7468 6973 2076 6563 746f 7220  .// this vector 
    │ │ │ +00074e90: 6973 2061 6c6c 6f63 6174 6564 206c 617a  is allocated laz
    │ │ │ +00074ea0: 696c 792e 2049 6620 6e6f 2066 696c 6520  ily. If no file 
    │ │ │ +00074eb0: 7072 696f 7269 7469 6573 2061 7265 0a09  priorities are..
    │ │ │ +00074ec0: 092f 2f20 6576 6572 2063 6861 6e67 6564  .// ever changed
    │ │ │ +00074ed0: 2c20 7468 6973 2072 656d 6169 6e73 2065  , this remains e
    │ │ │ +00074ee0: 6d70 7479 2e20 416e 7920 756e 616c 6c6f  mpty. Any unallo
    │ │ │ +00074ef0: 6361 7465 6420 736c 6f74 0a09 092f 2f20  cated slot...// 
    │ │ │ +00074f00: 696d 706c 6963 6974 6c79 206d 6561 6e73  implicitly means
    │ │ │ +00074f10: 2074 6865 2066 696c 6520 6861 7320 7072   the file has pr
    │ │ │ +00074f20: 696f 7269 7479 2034 2e0a 3c64 6976 2073  iority 4..
    ..aux::v │ │ │ +00074f60: 6563 746f 7226 6c74 3b64 6f77 6e6c 6f61 ector<downloa │ │ │ +00074f70: 645f 7072 696f 7269 7479 5f74 2c20 6669 d_priority_t, fi │ │ │ +00074f80: 6c65 5f69 6e64 6578 5f74 2667 743b 206d le_index_t> m │ │ │ +00074f90: 5f66 696c 655f 7072 696f 7269 7479 3b0a _file_priority;. │ │ │ +00074fa0: 3c2f 6469 763e 0a09 092f 2f20 616e 7920
    ...// any │ │ │ +00074fb0: 6669 6c65 2070 7269 6f72 6974 7920 7570 file priority up │ │ │ +00074fc0: 6461 7465 7320 6174 7465 6d70 7465 6420 dates attempted │ │ │ +00074fd0: 7768 696c 6520 616e 6f74 6865 7220 6669 while another fi │ │ │ +00074fe0: 6c65 2070 7269 6f72 6974 7920 7570 6461 le priority upda │ │ │ +00074ff0: 7465 0a09 092f 2f20 6973 2069 6e2d 7072 te...// is in-pr │ │ │ +00075000: 6f67 7265 7373 2f6f 7574 7374 616e 6469 ogress/outstandi │ │ │ +00075010: 6e67 2077 6974 6820 7468 6520 6469 736b ng with the disk │ │ │ +00075020: 2049 2f4f 2074 6872 6561 642c 2061 7265 I/O thread, are │ │ │ +00075030: 2071 7565 7565 6420 7570 2069 6e0a 0909 queued up in... │ │ │ +00075040: 2f2f 2074 6869 7320 6469 6374 696f 6e61 // this dictiona │ │ │ +00075050: 7279 2e20 4f6e 6365 2074 6865 206f 7574 ry. Once the out │ │ │ +00075060: 7374 616e 6469 6e67 2075 7064 6174 6520 standing update │ │ │ +00075070: 636f 6d65 7320 6261 636b 2c20 616c 6c20 comes back, all │ │ │ +00075080: 6f66 2074 6865 7365 0a09 092f 2f20 6172 of these...// ar │ │ │ +00075090: 6520 6170 706c 6965 6420 696e 206f 6e65 e applied in one │ │ │ +000750a0: 2062 6174 6368 0a09 0973 7464 3a3a 6d61 batch...std::ma │ │ │ +000750b0: 7026 6c74 3b66 696c 655f 696e 6465 785f p<file_index_ │ │ │ +000750c0: 742c 2064 6f77 6e6c 6f61 645f 7072 696f t, download_prio │ │ │ +000750d0: 7269 7479 5f74 2667 743b 206d 5f64 6566 rity_t> m_def │ │ │ +000750e0: 6572 7265 645f 6669 6c65 5f70 7269 6f72 erred_file_prior │ │ │ +000750f0: 6974 6965 733b 0a0a 0909 2f2f 2074 6869 ities;....// thi │ │ │ +00075100: 7320 6f62 6a65 6374 2069 7320 7573 6564 s object is used │ │ │ +00075110: 2074 6f20 7472 6163 6b20 646f 776e 6c6f to track downlo │ │ │ +00075120: 6164 2070 726f 6772 6573 7320 6f66 2069 ad progress of i │ │ │ +00075130: 6e64 6976 6964 7561 6c20 6669 6c65 730a ndividual files. │ │ │ +00075140: 0909 6175 783a 3a66 696c 655f 7072 6f67 ..aux::file_prog │ │ │ +00075150: 7265 7373 206d 5f66 696c 655f 7072 6f67 ress m_file_prog │ │ │ +00075160: 7265 7373 3b0a 0a09 092f 2f20 6120 7175 ress;....// a qu │ │ │ +00075170: 6575 6520 6f66 2074 6865 206d 6f73 7420 eue of the most │ │ │ +00075180: 7265 6365 6e74 206c 6f77 2d61 7661 696c recent low-avail │ │ │ +00075190: 6162 696c 6974 7920 7069 6563 6573 2077 ability pieces w │ │ │ +000751a0: 6520 6163 6365 7373 6564 206f 6e20 6469 e accessed on di │ │ │ +000751b0: 736b 2e0a 0909 2f2f 2054 6865 7365 2061 sk....// These a │ │ │ +000751c0: 7265 2067 6f6f 6420 6361 6e64 6964 6174 re good candidat │ │ │ +000751d0: 6573 2066 6f72 2073 7567 6765 7374 696e es for suggestin │ │ │ +000751e0: 6720 6f74 6865 7220 7065 6572 7320 746f g other peers to │ │ │ +000751f0: 2072 6571 7565 7374 2066 726f 6d0a 0909 request from... │ │ │ +00075200: 2f2f 2075 732e 0a09 0961 7578 3a3a 7375 // us....aux::su │ │ │ +00075210: 6767 6573 745f 7069 6563 6520 6d5f 7375 ggest_piece m_su │ │ │ +00075220: 6767 6573 745f 7069 6563 6573 3b0a 0a09 ggest_pieces;... │ │ │ +00075230: 0961 7578 3a3a 7665 6374 6f72 266c 743b .aux::vector< │ │ │ +00075240: 6175 783a 3a61 6e6e 6f75 6e63 655f 656e aux::announce_en │ │ │ +00075250: 7472 7926 6774 3b20 6d5f 7472 6163 6b65 try> m_tracke │ │ │ +00075260: 7273 3b0a 0a23 6966 6e64 6566 2054 4f52 rs;..#ifndef TOR │ │ │ +00075270: 5245 4e54 5f44 4953 4142 4c45 5f53 5452 RENT_DISABLE_STR │ │ │ +00075280: 4541 4d49 4e47 0a09 092f 2f20 7468 6973 EAMING...// this │ │ │ +00075290: 206c 6973 7420 6973 2073 6f72 7465 6420 list is sorted │ │ │ +000752a0: 6279 2074 696d 655f 6372 6974 6963 616c by time_critical │ │ │ +000752b0: 5f70 6965 6365 3a3a 6465 6164 6c69 6e65 _piece::deadline │ │ │ +000752c0: 0a09 0973 7464 3a3a 7665 6374 6f72 266c ...std::vector&l │ │ │ +000752d0: 743b 7469 6d65 5f63 7269 7469 6361 6c5f t;time_critical_ │ │ │ +000752e0: 7069 6563 6526 6774 3b20 6d5f 7469 6d65 piece> m_time │ │ │ +000752f0: 5f63 7269 7469 6361 6c5f 7069 6563 6573 _critical_pieces │ │ │ +00075300: 3b0a 2365 6e64 6966 0a0a 0909 7374 643a ;.#endif....std: │ │ │ +00075310: 3a73 7472 696e 6720 6d5f 7472 6163 6b65 :string m_tracke │ │ │ +00075320: 7269 643b 0a23 6966 2054 4f52 5245 4e54 rid;.#if TORRENT │ │ │ +00075330: 5f41 4249 5f56 4552 5349 4f4e 203d 3d20 _ABI_VERSION == │ │ │ +00075340: 310a 0909 2f2f 2064 6570 7265 6361 7465 1...// deprecate │ │ │ +00075350: 6420 696e 2031 2e31 0a09 0973 7464 3a3a d in 1.1...std:: │ │ │ +00075360: 7374 7269 6e67 206d 5f75 7365 726e 616d string m_usernam │ │ │ +00075370: 653b 0a09 0973 7464 3a3a 7374 7269 6e67 e;...std::string │ │ │ +00075380: 206d 5f70 6173 7377 6f72 643b 0a23 656e m_password;.#en │ │ │ +00075390: 6469 660a 0a09 0973 7464 3a3a 7374 7269 dif....std::stri │ │ │ +000753a0: 6e67 206d 5f73 6176 655f 7061 7468 3b0a ng m_save_path;. │ │ │ +000753b0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +000753c0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +000753f0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../in │ │ │ +00075420: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ +00075430: 2f74 6f72 7265 6e74 2e68 7070 3a31 3733 /torrent.hpp:173 │ │ │ +00075440: 373c 2f61 3e3c 2f74 643e 3c74 643e 7468 7th │ │ │ +00075450: 6973 206d 656d 6265 7220 6361 6e20 7072 is member can pr │ │ │ +00075460: 6f62 6162 6c79 2062 6520 7265 6d6f 7665 obably be remove │ │ │ +00075470: 643c 2f74 643e 3c2f 7472 3e3c 7472 2069 d

    t │ │ │ +000754c0: 6869 7320 6d65 6d62 6572 2063 616e 2070 his member can p │ │ │ +000754d0: 726f 6261 626c 7920 6265 2072 656d 6f76 robably be remov │ │ │ +000754e0: 6564 3c2f 6832 3e3c 6834 3e2e 2e2f 696e ed

    ../in │ │ │ +000754f0: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ +00075500: 2f74 6f72 7265 6e74 2e68 7070 3a31 3733 /torrent.hpp:173 │ │ │ +00075510: 373c 2f68 343e 3c70 7265 2073 7479 6c65 7

    │ │ │ +00075550: 0909 756e 7369 676e 6564 2069 6e74 206d  ..unsigned int m
    │ │ │ +00075560: 5f6e 756d 5f75 706c 6f61 6473 3a32 343b  _num_uploads:24;
    │ │ │ +00075570: 0a0a 0909 2f2f 2034 2075 6e75 7365 6420  ....// 4 unused 
    │ │ │ +00075580: 6269 7473 0a0a 0909 2f2f 2077 6865 6e20  bits....// when 
    │ │ │ +00075590: 7468 6973 2069 7320 7472 7565 2c20 7468  this is true, th
    │ │ │ +000755a0: 6973 2074 6f72 7265 6e74 2073 7570 706f  is torrent suppo
    │ │ │ +000755b0: 7274 7320 7065 6572 2065 7863 6861 6e67  rts peer exchang
    │ │ │ +000755c0: 650a 0909 626f 6f6c 206d 5f65 6e61 626c  e...bool m_enabl
    │ │ │ +000755d0: 655f 7065 783a 313b 0a0a 0909 2f2f 2073  e_pex:1;....// s
    │ │ │ +000755e0: 6574 2074 6f20 7472 7565 2069 6620 7468  et to true if th
    │ │ │ +000755f0: 6520 7365 7373 696f 6e20 4950 2066 696c  e session IP fil
    │ │ │ +00075600: 7465 7220 6170 706c 6965 7320 746f 2074  ter applies to t
    │ │ │ +00075610: 6869 730a 0909 2f2f 2074 6f72 7265 6e74  his...// torrent
    │ │ │ +00075620: 206f 7220 6e6f 742e 2044 6566 6175 6c74   or not. Default
    │ │ │ +00075630: 7320 746f 2074 7275 652e 0a09 0962 6f6f  s to true....boo
    │ │ │ +00075640: 6c20 6d5f 6170 706c 795f 6970 5f66 696c  l m_apply_ip_fil
    │ │ │ +00075650: 7465 723a 313b 0a0a 0909 2f2f 2074 6869  ter:1;....// thi
    │ │ │ +00075660: 7320 6973 2074 7275 6520 7768 656e 206f  s is true when o
    │ │ │ +00075670: 7572 2065 6666 6563 7469 7665 2069 6e61  ur effective ina
    │ │ │ +00075680: 6374 6976 6520 7374 6174 6520 6973 2064  ctive state is d
    │ │ │ +00075690: 6966 6665 7265 6e74 2066 726f 6d20 6f75  ifferent from ou
    │ │ │ +000756a0: 720a 0909 2f2f 2061 6374 7561 6c20 696e  r...// actual in
    │ │ │ +000756b0: 6163 7469 7665 2073 7461 7465 2e20 5768  active state. Wh
    │ │ │ +000756c0: 656e 6576 6572 2074 6869 7320 7374 6174  enever this stat
    │ │ │ +000756d0: 6520 6368 616e 6765 732c 2074 6865 7265  e changes, there
    │ │ │ +000756e0: 2069 7320 610a 0909 2f2f 2071 7561 7261   is a...// quara
    │ │ │ +000756f0: 6e74 696e 6520 7065 7269 6f64 2075 6e74  ntine period unt
    │ │ │ +00075700: 696c 2077 6520 6368 616e 6765 2074 6865  il we change the
    │ │ │ +00075710: 2065 6666 6563 7469 7665 2073 7461 7465   effective state
    │ │ │ +00075720: 2e20 5468 6973 2069 7320 746f 2061 766f  . This is to avo
    │ │ │ +00075730: 6964 0a09 092f 2f20 666c 6170 7069 6e67  id...// flapping
    │ │ │ +00075740: 2e20 4966 2074 6865 2073 7461 7465 2063  . If the state c
    │ │ │ +00075750: 6861 6e67 6573 2062 6163 6b20 6475 7269  hanges back duri
    │ │ │ +00075760: 6e67 2074 6869 7320 7065 7269 6f64 2c20  ng this period, 
    │ │ │ +00075770: 7765 2063 616e 6365 6c20 7468 650a 0909  we cancel the...
    │ │ │ +00075780: 2f2f 2071 7561 7261 6e74 696e 650a 0909  // quarantine...
    │ │ │ +00075790: 626f 6f6c 206d 5f70 656e 6469 6e67 5f61  bool m_pending_a
    │ │ │ +000757a0: 6374 6976 655f 6368 616e 6765 3a31 3b0a  ctive_change:1;.
    │ │ │ +000757b0: 0a09 092f 2f20 7468 6973 2069 7320 7365  ...// this is se
    │ │ │ +000757c0: 7420 746f 2074 7275 6520 6966 2061 6c6c  t to true if all
    │ │ │ +000757d0: 2070 6965 6365 206c 6179 6572 7320 7765   piece layers we
    │ │ │ +000757e0: 7265 2073 7563 6365 7373 6675 6c6c 7920  re successfully 
    │ │ │ +000757f0: 6c6f 6164 6564 2061 6e64 0a09 092f 2f20  loaded and...// 
    │ │ │ +00075800: 7661 6c69 6461 7465 642e 204f 6e6c 7920  validated. Only 
    │ │ │ +00075810: 666f 7220 7632 2074 6f72 7265 6e74 730a  for v2 torrents.
    │ │ │ +00075820: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ +00075850: 626f 6f6c 206d 5f76 325f 7069 6563 655f bool m_v2_piece_ │ │ │ +00075860: 6c61 7965 7273 5f76 616c 6964 6174 6564 layers_validated │ │ │ +00075870: 3a31 3b0a 3c2f 6469 763e 0a2f 2f20 2d2d :1;.
    .// -- │ │ │ +00075880: 2d2d 0a0a 0909 2f2f 2074 6869 7320 6973 --....// this is │ │ │ +00075890: 2073 6574 2074 6f20 7468 6520 636f 6e6e set to the conn │ │ │ +000758a0: 6563 7420 626f 6f73 7420 7175 6f74 6120 ect boost quota │ │ │ +000758b0: 666f 7220 7468 6973 2074 6f72 7265 6e74 for this torrent │ │ │ +000758c0: 2e0a 0909 2f2f 2041 6674 6572 2068 6176 ....// After hav │ │ │ +000758d0: 696e 6720 7265 6365 6976 6564 2074 6869 ing received thi │ │ │ +000758e0: 7320 6d61 6e79 2070 7269 6f72 6974 7920 s many priority │ │ │ +000758f0: 7065 6572 2063 6f6e 6e65 6374 696f 6e20 peer connection │ │ │ +00075900: 6174 7465 6d70 7473 2c20 6974 0a09 092f attempts, it.../ │ │ │ +00075910: 2f20 6661 6c6c 7320 6261 636b 206f 6e74 / falls back ont │ │ │ +00075920: 6f20 7468 6520 7374 6561 6479 2073 7461 o the steady sta │ │ │ +00075930: 7465 2070 6565 7220 636f 6e6e 6563 7469 te peer connecti │ │ │ +00075940: 6f6e 206c 6f67 6963 2c20 6472 6976 656e on logic, driven │ │ │ +00075950: 2062 7920 7468 650a 0909 2f2f 2073 6573 by the...// ses │ │ │ +00075960: 7369 6f6e 2074 6963 6b2e 2045 6163 6820 sion tick. Each │ │ │ +00075970: 7472 6163 6b65 7220 7265 7370 6f6e 7365 tracker response │ │ │ +00075980: 2c20 6173 206c 6f6e 6720 6173 2074 6869 , as long as thi │ │ │ +00075990: 7320 6973 206e 6f6e 2d7a 6572 6f2c 2077 s is non-zero, w │ │ │ +000759a0: 696c 6c0a 0909 2f2f 2061 7474 656d 7074 ill...// attempt │ │ │ +000759b0: 2074 6f20 636f 6e6e 6563 7420 746f 2070 to connect to p │ │ │ +000759c0: 6565 7273 2069 6d6d 6564 6961 7465 6c79 eers immediately │ │ │ +000759d0: 2061 6e64 2064 6563 7265 6d65 6e74 2074 and decrement t │ │ │ +000759e0: 6865 2063 6f75 6e74 6572 2e0a 0909 2f2f he counter....// │ │ │ +000759f0: 2057 6520 6769 7665 2074 6f72 7265 6e74 We give torrent │ │ │ +00075a00: 7320 6120 636f 6e6e 6563 7420 626f 6f73 s a connect boos │ │ │ +00075a10: 7420 7768 656e 2074 6865 7920 6172 6520 t when they are │ │ │ +00075a20: 6669 7273 7420 6164 6465 6420 616e 6420 first added and │ │ │ +00075a30: 7468 656e 0a09 092f 2f20 6576 6572 7920 then...// every │ │ │ +00075a40: 7469 6d65 2074 6865 7920 7265 7375 6d65 time they resume │ │ │ +00075a50: 2066 726f 6d20 6265 696e 6720 7061 7573 from being paus │ │ │ +00075a60: 6564 2e0a 0909 7374 643a 3a75 696e 7438 ed....std::uint8 │ │ │ +00075a70: 5f74 206d 5f63 6f6e 6e65 6374 5f62 6f6f _t m_connect_boo │ │ │ +00075a80: 7374 5f63 6f75 6e74 6572 3b0a 0a2f 2f20 st_counter;..// │ │ │ +00075a90: 2d2d 2d2d 0a0a 0909 2f2f 2074 6865 2073 ----....// the s │ │ │ +00075aa0: 6372 6170 6520 6461 7461 2066 726f 6d20 crape data from │ │ │ +00075ab0: 7468 6520 7472 6163 6b65 7220 7265 7370 the tracker resp │ │ │ +00075ac0: 6f6e 7365 2c20 7468 6973 0a09 092f 2f20 onse, this...// │ │ │ +00075ad0: 6973 206f 7074 696f 6e61 6c20 616e 6420 is optional and │ │ │ +00075ae0: 6d61 7920 6265 2030 7866 6666 6666 660a may be 0xffffff. │ │ │ +00075af0: 0909 7374 643a 3a75 696e 7433 325f 7420 ..std::uint32_t │ │ │ +00075b00: 6d5f 696e 636f 6d70 6c65 7465 3a32 343b m_incomplete:24; │ │ │ +00075b10: 0a0a 0909 2f2f 2074 7275 6520 7768 656e ....// true when │ │ │ +00075b20: 2074 6865 2074 6f72 7265 6e74 2073 686f the torrent sho │ │ │ +00075b30: 756c 6420 616e 6e6f 756e 6365 2074 6f0a uld announce to. │ │ │ +00075b40: 0909 2f2f 2074 6865 2044 4854 0a09 0962 ..// the DHT...b │ │ │ +00075b50: 6f6f 6c20 6d5f 616e 6e6f 756e 6365 5f74 ool m_announce_t │ │ │ +00075b60: 6f5f 6468 743a 313b 0a0a 0909 2f2f 2065 o_dht:1;....// e │ │ │ +00075b70: 7665 6e20 6966 2077 6527 7265 206e 6f74 ven if we're not │ │ │ +00075b80: 2062 7569 6c74 2074 6f20 7375 7070 6f72 built to suppor │ │ │ +00075b90: 7420 5353 4c20 746f 7272 656e 7473 2c0a t SSL torrents,. │ │ │ +00075ba0: 0909 2f2f 2072 656d 656d 6265 7220 7468 ..// remember th │ │ │ +00075bb0: 6174 2074 6869 7320 6973 2061 6e20 5353 at this is an SS │ │ │ +00075bc0: 4c20 746f 7272 656e 742c 2073 6f20 7468 L torrent, so th │ │ │ +00075bd0: 6174 2077 6520 646f 6e27 740a 0909 2f2f at we don't...// │ │ │ +00075be0: 2061 6363 6964 656e 7461 6c6c 7920 7374 accidentally st │ │ │ +00075bf0: 6172 7420 7365 6564 696e 6720 6974 2077 art seeding it w │ │ │ +00075c00: 6974 686f 7574 2061 6e79 2061 7574 6865 ithout any authe │ │ │ +00075c10: 6e74 6963 6174 696f 6e2e 0a09 0962 6f6f ntication....boo │ │ │ +00075c20: 6c20 6d5f 7373 6c5f 746f 7272 656e 743a l m_ssl_torrent: │ │ │ +00075c30: 313b 0a0a 0909 2f2f 2074 6869 7320 6973 1;....// this is │ │ │ +00075c40: 2073 6574 2074 6f20 7472 7565 2069 6620 set to true if │ │ │ +00075c50: 7765 2772 6520 7472 7969 6e67 2074 6f20 we're trying to │ │ │ +00075c60: 6465 6c65 7465 2074 6865 0a09 092f 2f20 delete the...// │ │ │ +00075c70: 6669 6c65 7320 6265 6c6f 6e67 696e 6720 files belonging │ │ │ +00075c80: 746f 2069 742e 2057 6865 6e20 7365 742c to it. When set, │ │ │ +00075c90: 2064 6f6e 2774 2077 7269 7465 2061 6e79 don't write any │ │ │ +00075ca0: 0a09 092f 2f20 6d6f 7265 2062 6c6f 636b ...// more block │ │ │ +00075cb0: 7320 746f 2064 6973 6b21 0a3c 2f70 7265 s to disk!.
    rele │ │ │ +00075cf0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../include │ │ │ +00075d30: 2f6c 6962 746f 7272 656e 742f 7069 6563 /libtorrent/piec │ │ │ +00075d40: 655f 7069 636b 6572 2e68 7070 3a38 3233 e_picker.hpp:823 │ │ │ +00075d50: 3c2f 613e 3c2f 7464 3e3c 7464 3e73 686f sho │ │ │ +00075d60: 756c 6420 7468 6973 2062 6520 616c 6c6f uld this be allo │ │ │ +00075d70: 6361 7465 6420 6c61 7a69 6c79 3f3c 2f74 cated lazily?

    shoul │ │ │ +00075dd0: 6420 7468 6973 2062 6520 616c 6c6f 6361 d this be alloca │ │ │ +00075de0: 7465 6420 6c61 7a69 6c79 3f3c 2f68 323e ted lazily?

    │ │ │ +00075df0: 3c68 343e 2e2e 2f69 6e63 6c75 6465 2f6c

    ../include/l │ │ │ +00075e00: 6962 746f 7272 656e 742f 7069 6563 655f ibtorrent/piece_ │ │ │ +00075e10: 7069 636b 6572 2e68 7070 3a38 3233 3c2f picker.hpp:823
    ../
    │ │ │ +00075e60: 2f20 646f 776e 6c6f 6164 206c 6973 7420  / download list 
    │ │ │ +00075e70: 6974 206d 6179 206c 6976 6520 696e 206e  it may live in n
    │ │ │ +00075e80: 6f77 0a09 0973 7464 3a3a 7665 6374 6f72  ow...std::vector
    │ │ │ +00075e90: 266c 743b 646f 776e 6c6f 6164 696e 675f  <downloading_
    │ │ │ +00075ea0: 7069 6563 6526 6774 3b3a 3a69 7465 7261  piece>::itera
    │ │ │ +00075eb0: 746f 7220 7570 6461 7465 5f70 6965 6365  tor update_piece
    │ │ │ +00075ec0: 5f73 7461 7465 280a 0909 0973 7464 3a3a  _state(....std::
    │ │ │ +00075ed0: 7665 6374 6f72 266c 743b 646f 776e 6c6f  vector<downlo
    │ │ │ +00075ee0: 6164 696e 675f 7069 6563 6526 6774 3b3a  ading_piece>:
    │ │ │ +00075ef0: 3a69 7465 7261 746f 7220 6470 293b 0a0a  :iterator dp);..
    │ │ │ +00075f00: 0970 7269 7661 7465 3a0a 0a23 6966 2054  .private:..#if T
    │ │ │ +00075f10: 4f52 5245 4e54 5f55 5345 5f41 5353 4552  ORRENT_USE_ASSER
    │ │ │ +00075f20: 5453 207c 7c20 544f 5252 454e 545f 5553  TS || TORRENT_US
    │ │ │ +00075f30: 455f 494e 5641 5249 414e 545f 4348 4543  E_INVARIANT_CHEC
    │ │ │ +00075f40: 4b53 0a09 0969 6e64 6578 5f72 616e 6765  KS...index_range
    │ │ │ +00075f50: 266c 743b 646f 776e 6c6f 6164 5f71 7565  <download_que
    │ │ │ +00075f60: 7565 5f74 2667 743b 2063 6174 6567 6f72  ue_t> categor
    │ │ │ +00075f70: 6965 7328 2920 636f 6e73 740a 0909 7b20  ies() const...{ 
    │ │ │ +00075f80: 7265 7475 726e 207b 7b7d 2c20 7069 6563  return {{}, piec
    │ │ │ +00075f90: 655f 7069 636b 6572 3a3a 7069 6563 655f  e_picker::piece_
    │ │ │ +00075fa0: 706f 733a 3a6e 756d 5f64 6f77 6e6c 6f61  pos::num_downloa
    │ │ │ +00075fb0: 645f 6361 7465 676f 7269 6573 7d3b 207d  d_categories}; }
    │ │ │ +00075fc0: 0a23 656e 6469 660a 0a09 092f 2f20 7468  .#endif....// th
    │ │ │ +00075fd0: 6520 666f 6c6c 6f77 696e 6720 7665 6374  e following vect
    │ │ │ +00075fe0: 6f72 7320 6172 6520 6d75 7461 626c 6520  ors are mutable 
    │ │ │ +00075ff0: 6265 6361 7573 6520 7468 6579 2073 6f6d  because they som
    │ │ │ +00076000: 6574 696d 6573 206d 6179 0a09 092f 2f20  etimes may...// 
    │ │ │ +00076010: 6265 2075 7064 6174 6564 206c 617a 696c  be updated lazil
    │ │ │ +00076020: 792c 2074 7269 6767 6572 6564 2062 7920  y, triggered by 
    │ │ │ +00076030: 636f 6e73 7420 6675 6e63 7469 6f6e 730a  const functions.
    │ │ │ +00076040: 0a09 092f 2f20 7468 6973 206d 6170 7320  ...// this maps 
    │ │ │ +00076050: 696e 6469 6365 7320 746f 206e 756d 6265  indices to numbe
    │ │ │ +00076060: 7220 6f66 2070 6565 7273 2074 6861 7420  r of peers that 
    │ │ │ +00076070: 6861 7320 7468 6973 2070 6965 6365 2061  has this piece a
    │ │ │ +00076080: 6e64 0a09 092f 2f20 696e 6465 7820 696e  nd...// index in
    │ │ │ +00076090: 746f 2074 6865 206d 5f70 6965 6365 5f69  to the m_piece_i
    │ │ │ +000760a0: 6e66 6f20 7665 6374 6f72 732e 0a09 092f  nfo vectors..../
    │ │ │ +000760b0: 2f20 7069 6563 655f 706f 733a 3a77 655f  / piece_pos::we_
    │ │ │ +000760c0: 6861 7665 5f69 6e64 6578 206d 6561 6e73  have_index means
    │ │ │ +000760d0: 2074 6861 7420 7765 2068 6176 6520 7468   that we have th
    │ │ │ +000760e0: 6520 7069 6563 652c 2073 6f20 6974 0a09  e piece, so it..
    │ │ │ +000760f0: 092f 2f20 646f 6573 6e27 7420 6578 6973  .// doesn't exis
    │ │ │ +00076100: 7420 696e 2074 6865 2070 6965 6365 5f69  t in the piece_i
    │ │ │ +00076110: 6e66 6f20 6275 636b 6574 730a 0909 2f2f  nfo buckets...//
    │ │ │ +00076120: 2070 6965 6365 7320 7769 7468 2074 6865   pieces with the
    │ │ │ +00076130: 2066 696c 7465 7265 6420 666c 6167 2073   filtered flag s
    │ │ │ +00076140: 6574 2064 6f65 736e 2774 2068 6176 6520  et doesn't have 
    │ │ │ +00076150: 656e 7472 6965 7320 696e 0a09 092f 2f20  entries in...// 
    │ │ │ +00076160: 7468 6520 6d5f 7069 6563 655f 696e 666f  the m_piece_info
    │ │ │ +00076170: 2062 7563 6b65 7473 2065 6974 6865 720a   buckets either.
    │ │ │ +00076180: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ +000761b0: 6d75 7461 626c 6520 6175 783a 3a76 6563 mutable aux::vec │ │ │ +000761c0: 746f 7226 6c74 3b70 6965 6365 5f70 6f73 tor<piece_pos │ │ │ +000761d0: 2c20 7069 6563 655f 696e 6465 785f 7426 , piece_index_t& │ │ │ +000761e0: 6774 3b20 6d5f 7069 6563 655f 6d61 703b gt; m_piece_map; │ │ │ +000761f0: 0a3c 2f64 6976 3e0a 0909 2f2f 2074 7261 .
    ...// tra │ │ │ +00076200: 636b 7320 7468 6520 6e75 6d62 6572 206f cks the number o │ │ │ +00076210: 6620 6279 7465 7320 696e 2061 2073 7065 f bytes in a spe │ │ │ +00076220: 6369 6669 6320 7069 6563 6520 7468 6174 cific piece that │ │ │ +00076230: 2061 7265 2070 6172 7420 6f66 2061 2070 are part of a p │ │ │ +00076240: 6164 0a09 092f 2f20 6669 6c65 2e20 5468 ad...// file. Th │ │ │ +00076250: 6520 7061 6464 696e 6720 6973 2061 7373 e padding is ass │ │ │ +00076260: 756d 6564 2074 6f20 6265 2061 7420 7468 umed to be at th │ │ │ +00076270: 6520 656e 6420 6f66 2074 6865 2070 6965 e end of the pie │ │ │ +00076280: 6365 2c20 616e 6420 7468 650a 0909 2f2f ce, and the...// │ │ │ +00076290: 2062 6c6f 636b 7320 636f 7665 7265 6420 blocks covered │ │ │ +000762a0: 6279 2074 6865 2070 6164 2062 7974 6573 by the pad bytes │ │ │ +000762b0: 2061 7265 206e 6f74 2070 6963 6b65 6420 are not picked │ │ │ +000762c0: 6279 2074 6865 2070 6965 6365 2070 6963 by the piece pic │ │ │ +000762d0: 6b65 720a 0909 7374 643a 3a75 6e6f 7264 ker...std::unord │ │ │ +000762e0: 6572 6564 5f6d 6170 266c 743b 7069 6563 ered_map<piec │ │ │ +000762f0: 655f 696e 6465 785f 742c 2069 6e74 2667 e_index_t, int&g │ │ │ +00076300: 743b 206d 5f70 6164 735f 696e 5f70 6965 t; m_pads_in_pie │ │ │ +00076310: 6365 3b0a 0a09 092f 2f20 7768 656e 2074 ce;....// when t │ │ │ +00076320: 6865 2061 646a 6163 656e 745f 7069 6563 he adjacent_piec │ │ │ +00076330: 6520 6166 6669 6e69 7479 2069 7320 656e e affinity is en │ │ │ +00076340: 6162 6c65 642c 2074 6869 7320 636f 6e74 abled, this cont │ │ │ +00076350: 6169 6e73 2074 6865 206d 6f73 740a 0909 ains the most... │ │ │ +00076360: 2f2f 2072 6563 656e 7420 2265 7874 656e // recent "exten │ │ │ +00076370: 7473 2220 6f66 2061 646a 6163 656e 7420 ts" of adjacent │ │ │ +00076380: 7069 6563 6573 2074 6861 7420 6861 7665 pieces that have │ │ │ +00076390: 2062 6565 6e20 7265 7175 6573 7465 6420 been requested │ │ │ +000763a0: 6672 6f6d 0a09 092f 2f20 7468 6973 2069 from...// this i │ │ │ +000763b0: 7320 6d75 7461 626c 6520 6265 6361 7573 s mutable becaus │ │ │ +000763c0: 6520 6974 2773 2075 7064 6174 6564 2062 e it's updated b │ │ │ +000763d0: 7920 6675 6e63 7469 6f6e 7320 746f 2070 y functions to p │ │ │ +000763e0: 6963 6b20 7069 6563 6573 2c20 7768 6963 ick pieces, whic │ │ │ +000763f0: 680a 0909 2f2f 2061 7265 2063 6f6e 7374 h...// are const │ │ │ +00076400: 2e20 5468 6174 2773 2061 6e20 6566 6669 . That's an effi │ │ │ +00076410: 6369 656e 7420 706c 6163 6520 746f 2075 cient place to u │ │ │ +00076420: 7064 6174 6520 6974 2c20 7369 6e63 6520 pdate it, since │ │ │ +00076430: 6974 2773 2062 6569 6e67 0a09 092f 2f20 it's being...// │ │ │ +00076440: 7472 6176 6572 7365 6420 616c 7265 6164 traversed alread │ │ │ +00076450: 792e 0a09 096d 7574 6162 6c65 2073 7464 y....mutable std │ │ │ +00076460: 3a3a 7665 6374 6f72 266c 743b 7069 6563 ::vector<piec │ │ │ +00076470: 655f 6578 7465 6e74 5f74 2667 743b 206d e_extent_t> m │ │ │ +00076480: 5f72 6563 656e 745f 6578 7465 6e74 733b _recent_extents; │ │ │ +00076490: 0a0a 0909 2f2f 2074 6865 206e 756d 6265 ....// the numbe │ │ │ +000764a0: 7220 6f66 2062 7974 6573 206f 6620 7061 r of bytes of pa │ │ │ +000764b0: 6420 6669 6c65 2073 6574 2069 6e20 7468 d file set in th │ │ │ +000764c0: 6973 2070 6965 6365 2070 6963 6b65 720a is piece picker. │ │ │ +000764d0: 0909 7374 643a 3a69 6e74 3634 5f74 206d ..std::int64_t m │ │ │ +000764e0: 5f6e 756d 5f70 6164 5f62 7974 6573 203d _num_pad_bytes = │ │ │ +000764f0: 2030 3b0a 0a09 092f 2f20 7468 6520 6e75 0;....// the nu │ │ │ +00076500: 6d62 6572 206f 6620 7061 6420 626c 6f63 mber of pad bloc │ │ │ +00076510: 6b73 2074 6861 7420 7765 2061 6c72 6561 ks that we alrea │ │ │ +00076520: 6479 2068 6176 650a 0909 7374 643a 3a69 dy have...std::i │ │ │ +00076530: 6e74 3634 5f74 206d 5f68 6176 655f 7061 nt64_t m_have_pa │ │ │ +00076540: 645f 6279 7465 7320 3d20 303b 0a0a 0909 d_bytes = 0;.... │ │ │ +00076550: 2f2f 2074 6865 206e 756d 6265 7220 6f66 // the number of │ │ │ +00076560: 2070 6164 2062 6c6f 636b 7320 7061 7274 pad blocks part │ │ │ +00076570: 206f 6620 6669 6c74 6572 6564 2070 6965 of filtered pie │ │ │ +00076580: 6365 7320 7765 2064 6f6e 2774 2068 6176 ces we don't hav │ │ │ +00076590: 650a 0909 7374 643a 3a69 6e74 3634 5f74 e...std::int64_t │ │ │ +000765a0: 206d 5f66 696c 7465 7265 645f 7061 645f m_filtered_pad_ │ │ │ +000765b0: 6279 7465 7320 3d20 303b 0a0a 0909 2f2f bytes = 0;....// │ │ │ +000765c0: 2074 6865 206e 756d 6265 7220 6f66 2070 the number of p │ │ │ +000765d0: 6164 2062 6c6f 636b 7320 7765 2068 6176 ad blocks we hav │ │ │ +000765e0: 6520 7468 6174 2061 7265 2061 6c73 6f20 e that are also │ │ │ +000765f0: 6669 6c74 6572 6564 0a09 0973 7464 3a3a filtered...std:: │ │ │ +00076600: 696e 7436 345f 7420 6d5f 6861 7665 5f66 int64_t m_have_f │ │ │ +00076610: 696c 7465 7265 645f 7061 645f 6279 7465 iltered_pad_byte │ │ │ +00076620: 7320 3d20 303b 0a0a 0909 2f2f 2074 6865 s = 0;....// the │ │ │ +00076630: 206e 756d 6265 7220 6f66 2073 6565 6473 number of seeds │ │ │ +00076640: 2e20 5468 6573 6520 6172 6520 6e6f 7420 . These are not │ │ │ +00076650: 6164 6465 6420 746f 0a09 092f 2f20 7468 added to...// th │ │ │ +00076660: 6520 6176 6169 6c61 6269 6c69 7479 2063 e availability c │ │ │ +00076670: 6f75 6e74 6572 7320 6f66 2074 6865 2070 ounters of the p │ │ │ +00076680: 6965 6365 730a 0909 696e 7420 6d5f 7365 ieces...int m_se │ │ │ +00076690: 6564 7320 3d20 303b 0a0a 0909 2f2f 2074 eds = 0;....// t │ │ │ +000766a0: 6869 7320 7665 6374 6f72 2063 6f6e 7461 his vector conta │ │ │ +000766b0: 696e 7320 616c 6c20 7069 6563 6520 696e ins all piece in │ │ │ +000766c0: 6469 6365 7320 7468 6174 2061 7265 2070 dices that are p │ │ │ +000766d0: 6963 6b61 626c 650a 3c2f 7072 653e 3c2f ickable.
    relevan │ │ │ +00076710: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../include/li │ │ │ +00076750: 6274 6f72 7265 6e74 2f70 6965 6365 5f70 btorrent/piece_p │ │ │ +00076760: 6963 6b65 722e 6870 703a 3839 353c 2f61 icker.hpp:895it wou │ │ │ +00076780: 6c64 2062 6520 6d6f 7265 2069 6e74 7569 ld be more intui │ │ │ +00076790: 7469 7665 2074 6f20 6163 636f 756e 7420 tive to account │ │ │ +000767a0: 2277 616e 7465 6422 2070 6965 6365 7320 "wanted" pieces │ │ │ +000767b0: 696e 7374 6561 6420 6f66 2066 696c 7465 instead of filte │ │ │ +000767c0: 7265 643c 2f74 643e 3c2f 7472 3e3c 7472 red

    it would be mor │ │ │ +00076820: 6520 696e 7475 6974 6976 6520 746f 2061 e intuitive to a │ │ │ +00076830: 6363 6f75 6e74 2022 7761 6e74 6564 2220 ccount "wanted" │ │ │ +00076840: 7069 6563 6573 0a69 6e73 7465 6164 206f pieces.instead o │ │ │ +00076850: 6620 6669 6c74 6572 6564 3c2f 6832 3e3c f filtered

    < │ │ │ +00076860: 6834 3e2e 2e2f 696e 636c 7564 652f 6c69 h4>../include/li │ │ │ +00076870: 6274 6f72 7265 6e74 2f70 6965 6365 5f70 btorrent/piece_p │ │ │ +00076880: 6963 6b65 722e 6870 703a 3839 353c 2f68 icker.hpp:895
    .../
    │ │ │ +000768d0: 2f20 7468 6973 2068 6f6c 6473 2074 6865  / this holds the
    │ │ │ +000768e0: 2069 6e66 6f72 6d61 7469 6f6e 206f 6620   information of 
    │ │ │ +000768f0: 7468 6520 626c 6f63 6b73 2069 6e20 7061  the blocks in pa
    │ │ │ +00076900: 7274 6961 6c6c 7920 646f 776e 6c6f 6164  rtially download
    │ │ │ +00076910: 6564 0a09 092f 2f20 7069 6563 6573 2e20  ed...// pieces. 
    │ │ │ +00076920: 7468 6520 646f 776e 6c6f 6164 696e 675f  the downloading_
    │ │ │ +00076930: 7069 6563 653a 3a69 6e66 6f20 696e 6465  piece::info inde
    │ │ │ +00076940: 7820 706f 696e 7420 696e 746f 2074 6869  x point into thi
    │ │ │ +00076950: 7320 7665 6374 6f72 2066 6f72 0a09 092f  s vector for.../
    │ │ │ +00076960: 2f20 6974 7320 7374 6f72 6167 650a 0909  / its storage...
    │ │ │ +00076970: 6175 783a 3a76 6563 746f 7226 6c74 3b62  aux::vector<b
    │ │ │ +00076980: 6c6f 636b 5f69 6e66 6f26 6774 3b20 6d5f  lock_info> m_
    │ │ │ +00076990: 626c 6f63 6b5f 696e 666f 3b0a 0a09 092f  block_info;..../
    │ │ │ +000769a0: 2f20 7468 6573 6520 6172 6520 626c 6f63  / these are bloc
    │ │ │ +000769b0: 6b20 7261 6e67 6573 2069 6e20 6d5f 626c  k ranges in m_bl
    │ │ │ +000769c0: 6f63 6b5f 696e 666f 2074 6861 7420 6172  ock_info that ar
    │ │ │ +000769d0: 6520 6672 6565 2e20 5468 6520 6e75 6d62  e free. The numb
    │ │ │ +000769e0: 6572 730a 0909 2f2f 2069 6e20 6865 7265  ers...// in here
    │ │ │ +000769f0: 2c20 7768 656e 206d 756c 7469 706c 6965  , when multiplie
    │ │ │ +00076a00: 6420 6279 2062 6c6f 636b 735f 7065 725f  d by blocks_per_
    │ │ │ +00076a10: 7069 6563 6520 6973 2074 6865 2069 6e64  piece is the ind
    │ │ │ +00076a20: 6578 2074 6f20 7468 650a 0909 2f2f 2066  ex to the...// f
    │ │ │ +00076a30: 6972 7374 2062 6c6f 636b 2069 6e20 7468  irst block in th
    │ │ │ +00076a40: 6520 7261 6e67 6520 7468 6174 2773 2066  e range that's f
    │ │ │ +00076a50: 7265 6520 746f 2075 7365 2062 7920 6120  ree to use by a 
    │ │ │ +00076a60: 6e65 7720 646f 776e 6c6f 6164 696e 675f  new downloading_
    │ │ │ +00076a70: 7069 6563 652e 0a09 092f 2f20 7468 6973  piece....// this
    │ │ │ +00076a80: 2069 7320 6120 6672 6565 2d6c 6973 742e   is a free-list.
    │ │ │ +00076a90: 0a09 0973 7464 3a3a 7665 6374 6f72 266c  ...std::vector&l
    │ │ │ +00076aa0: 743b 7374 643a 3a75 696e 7431 365f 7426  t;std::uint16_t&
    │ │ │ +00076ab0: 6774 3b20 6d5f 6672 6565 5f62 6c6f 636b  gt; m_free_block
    │ │ │ +00076ac0: 5f69 6e66 6f73 3b0a 0a09 0973 7464 3a3a  _infos;....std::
    │ │ │ +00076ad0: 7569 6e74 3136 5f74 206d 5f62 6c6f 636b  uint16_t m_block
    │ │ │ +00076ae0: 735f 696e 5f6c 6173 745f 7069 6563 6520  s_in_last_piece 
    │ │ │ +00076af0: 3d20 303b 0a09 0969 6e74 206d 5f70 6965  = 0;...int m_pie
    │ │ │ +00076b00: 6365 5f73 697a 6520 3d20 303b 0a09 0973  ce_size = 0;...s
    │ │ │ +00076b10: 7464 3a3a 696e 7436 345f 7420 6d5f 746f  td::int64_t m_to
    │ │ │ +00076b20: 7461 6c5f 7369 7a65 203d 2030 3b0a 0a09  tal_size = 0;...
    │ │ │ +00076b30: 092f 2f20 7468 6520 6e75 6d62 6572 206f  .// the number o
    │ │ │ +00076b40: 6620 6669 6c74 6572 6564 2070 6965 6365  f filtered piece
    │ │ │ +00076b50: 7320 7468 6174 2077 6520 646f 6e27 7420  s that we don't 
    │ │ │ +00076b60: 616c 7265 6164 790a 0909 2f2f 2068 6176  already...// hav
    │ │ │ +00076b70: 652e 2074 6f74 616c 5f6e 756d 6265 725f  e. total_number_
    │ │ │ +00076b80: 6f66 5f70 6965 6365 7320 2d20 6e75 6d62  of_pieces - numb
    │ │ │ +00076b90: 6572 5f6f 665f 7069 6563 6573 5f77 655f  er_of_pieces_we_
    │ │ │ +00076ba0: 6861 7665 0a09 092f 2f20 2d20 6e75 6d5f  have...// - num_
    │ │ │ +00076bb0: 6669 6c74 6572 6564 2069 7320 7375 7070  filtered is supp
    │ │ │ +00076bc0: 6f73 6564 2074 6f20 7468 6520 6e75 6d62  osed to the numb
    │ │ │ +00076bd0: 6572 206f 6620 7069 6563 6573 0a09 092f  er of pieces.../
    │ │ │ +00076be0: 2f20 7765 2073 7469 6c6c 2077 616e 7420  / we still want 
    │ │ │ +00076bf0: 746f 2064 6f77 6e6c 6f61 640a 3c64 6976  to download.
    ..int │ │ │ +00076c30: 6d5f 6e75 6d5f 6669 6c74 6572 6564 203d m_num_filtered = │ │ │ +00076c40: 2030 3b0a 3c2f 6469 763e 0a09 092f 2f20 0;.
    ...// │ │ │ +00076c50: 7468 6520 6e75 6d62 6572 206f 6620 7069 the number of pi │ │ │ +00076c60: 6563 6573 2077 6520 6861 7665 2074 6861 eces we have tha │ │ │ +00076c70: 7420 616c 736f 2061 7265 2066 696c 7465 t also are filte │ │ │ +00076c80: 7265 640a 0909 696e 7420 6d5f 6e75 6d5f red...int m_num_ │ │ │ +00076c90: 6861 7665 5f66 696c 7465 7265 6420 3d20 have_filtered = │ │ │ +00076ca0: 303b 0a0a 0909 2f2f 2077 6520 6861 7665 0;....// we have │ │ │ +00076cb0: 2061 6c6c 2070 6965 6365 7320 696e 2074 all pieces in t │ │ │ +00076cc0: 6865 2072 616e 6765 205b 302c 206d 5f63 he range [0, m_c │ │ │ +00076cd0: 7572 736f 7229 0a09 092f 2f20 6d5f 6375 ursor)...// m_cu │ │ │ +00076ce0: 7273 6f72 2069 7320 7468 6520 6669 7273 rsor is the firs │ │ │ +00076cf0: 7420 7069 6563 6520 7765 2064 6f6e 2774 t piece we don't │ │ │ +00076d00: 2068 6176 650a 0909 7069 6563 655f 696e have...piece_in │ │ │ +00076d10: 6465 785f 7420 6d5f 6375 7273 6f72 7b30 dex_t m_cursor{0 │ │ │ +00076d20: 7d3b 0a0a 0909 2f2f 2077 6520 6861 7665 };....// we have │ │ │ +00076d30: 2061 6c6c 2070 6965 6365 7320 696e 2074 all pieces in t │ │ │ +00076d40: 6865 2072 616e 6765 205b 6d5f 7265 7665 he range [m_reve │ │ │ +00076d50: 7273 655f 6375 7273 6f72 2c20 656e 6429 rse_cursor, end) │ │ │ +00076d60: 0a09 092f 2f20 6d5f 7265 7665 7273 655f ...// m_reverse_ │ │ │ +00076d70: 6375 7273 6f72 2069 7320 7468 6520 6669 cursor is the fi │ │ │ +00076d80: 7273 7420 7069 6563 6520 7768 6572 6520 rst piece where │ │ │ +00076d90: 7765 2061 6c73 6f20 6861 7665 0a09 092f we also have.../ │ │ │ +00076da0: 2f20 616c 6c20 7468 6520 7375 6273 6571 / all the subseq │ │ │ +00076db0: 7565 6e74 2070 6965 6365 730a 0909 7069 uent pieces...pi │ │ │ +00076dc0: 6563 655f 696e 6465 785f 7420 6d5f 7265 ece_index_t m_re │ │ │ +00076dd0: 7665 7273 655f 6375 7273 6f72 7b30 7d3b verse_cursor{0}; │ │ │ +00076de0: 0a0a 0909 2f2f 2074 6865 206e 756d 6265 ....// the numbe │ │ │ +00076df0: 7220 6f66 2070 6965 6365 7320 7765 2068 r of pieces we h │ │ │ +00076e00: 6176 6520 2869 2e65 2e20 7061 7373 6564 ave (i.e. passed │ │ │ +00076e10: 2068 6173 6820 6368 6563 6b29 2e0a 0909 hash check).... │ │ │ +00076e20: 2f2f 2054 6869 7320 696e 636c 7564 6573 // This includes │ │ │ +00076e30: 2070 6965 6365 7320 7468 6174 2077 6520 pieces that we │ │ │ +00076e40: 6861 7665 2066 696c 7465 7265 6420 6275 have filtered bu │ │ │ +00076e50: 7420 7374 696c 6c20 6861 7665 0a09 0969 t still have...i │ │ │ +00076e60: 6e74 206d 5f6e 756d 5f68 6176 6520 3d20 nt m_num_have = │ │ │ +00076e70: 303b 0a0a 0909 2f2f 2069 6620 7468 6973 0;....// if this │ │ │ +00076e80: 2069 7320 7365 7420 746f 2074 7275 652c is set to true, │ │ │ +00076e90: 2069 7420 6d65 616e 7320 7570 6461 7465 it means update │ │ │ +00076ea0: 5f70 6965 6365 7328 290a 0909 2f2f 2068 _pieces()...// h │ │ │ +00076eb0: 6173 2074 6f20 6265 2063 616c 6c65 6420 as to be called │ │ │ +00076ec0: 6265 666f 7265 2061 6363 6573 7369 6e67 before accessing │ │ │ +00076ed0: 206d 5f70 6965 6365 732e 0a09 096d 7574 m_pieces....mut │ │ │ +00076ee0: 6162 6c65 2062 6f6f 6c20 6d5f 6469 7274 able bool m_dirt │ │ │ +00076ef0: 7920 3d20 6661 6c73 653b 0a09 7075 626c y = false;..publ │ │ │ +00076f00: 6963 3a0a 0a09 0965 6e75 6d20 7b20 6d61 ic:....enum { ma │ │ │ +00076f10: 785f 7069 6563 6573 203d 2028 7374 643a x_pieces = (std: │ │ │ +00076f20: 3a6e 756d 6572 6963 5f6c 696d 6974 7326 :numeric_limits& │ │ │ +00076f30: 6c74 3b69 6e74 2667 743b 3a3a 6d61 7829 lt;int>::max) │ │ │ +00076f40: 2829 202d 2031 207d 3b0a 0a09 7d3b 0a7d () - 1 };...};.} │ │ │ +00076f50: 0a0a 2365 6e64 6966 202f 2f20 544f 5252 ..#endif // TORR │ │ │ +00076f60: 454e 545f 5049 4543 455f 5049 434b 4552 ENT_PIECE_PICKER │ │ │ +00076f70: 5f48 5050 5f49 4e43 4c55 4445 440a 3c2f _HPP_INCLUDED.r │ │ │ +00076fb0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +00076fc0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../incl │ │ │ +00076ff0: 7564 652f 6c69 6274 6f72 7265 6e74 2f73 ude/libtorrent/s │ │ │ +00077000: 6f63 6b65 745f 7479 7065 2e68 7070 3a36 ocket_type.hpp:6 │ │ │ +00077010: 303c 2f61 3e3c 2f74 643e 3c74 643e 6d6f 0mo │ │ │ +00077020: 7665 2074 6f20 6175 783c 2f74 643e 3c2f ve to aux

    move to a │ │ │ +00077080: 7578 3c2f 6832 3e3c 6834 3e2e 2e2f 696e ux

    ../in │ │ │ +00077090: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ +000770a0: 2f73 6f63 6b65 745f 7479 7065 2e68 7070 /socket_type.hpp │ │ │ +000770b0: 3a36 303c 2f68 343e 3c70 7265 2073 7479 :60

    namespace libt
    │ │ │ +00077100: 6f72 7265 6e74 207b 0a0a 2f2f 2041 2074  orrent {..// A t
    │ │ │ +00077110: 7970 6520 6465 7363 7269 6269 6e67 206b  ype describing k
    │ │ │ +00077120: 696e 6473 206f 6620 736f 636b 6574 7320  inds of sockets 
    │ │ │ +00077130: 696e 766f 6c76 6564 2069 6e20 7661 7269  involved in vari
    │ │ │ +00077140: 6f75 7320 6f70 6572 6174 696f 6e73 206f  ous operations o
    │ │ │ +00077150: 7220 6576 656e 7473 2e0a 656e 756d 2063  r events..enum c
    │ │ │ +00077160: 6c61 7373 2073 6f63 6b65 745f 7479 7065  lass socket_type
    │ │ │ +00077170: 5f74 203a 2073 7464 3a3a 7569 6e74 385f  _t : std::uint8_
    │ │ │ +00077180: 7420 7b0a 0974 6370 2c0a 0973 6f63 6b73  t {..tcp,..socks
    │ │ │ +00077190: 352c 0a09 6874 7470 2c0a 0975 7470 2c0a  5,..http,..utp,.
    │ │ │ +000771a0: 0969 3270 2c0a 0974 6370 5f73 736c 2c0a  .i2p,..tcp_ssl,.
    │ │ │ +000771b0: 0973 6f63 6b73 355f 7373 6c2c 0a09 6874  .socks5_ssl,..ht
    │ │ │ +000771c0: 7470 5f73 736c 2c0a 0975 7470 5f73 736c  tp_ssl,..utp_ssl
    │ │ │ +000771d0: 2c0a 0a23 6966 2054 4f52 5245 4e54 5f41  ,..#if TORRENT_A
    │ │ │ +000771e0: 4249 5f56 4552 5349 4f4e 2026 6c74 3b3d  BI_VERSION <=
    │ │ │ +000771f0: 2032 0a09 7564 7020 544f 5252 454e 545f   2..udp TORRENT_
    │ │ │ +00077200: 4445 5052 4543 4154 4544 5f45 4e55 4d20  DEPRECATED_ENUM 
    │ │ │ +00077210: 3d20 7574 702c 0a23 656e 6469 660a 7d3b  = utp,.#endif.};
    │ │ │ +00077220: 0a0a 2f2f 2072 6574 7572 6e20 6120 7368  ..// return a sh
    │ │ │ +00077230: 6f72 7420 6875 6d61 6e20 7265 6164 6162  ort human readab
    │ │ │ +00077240: 6c65 206e 616d 6520 666f 7220 7479 7065  le name for type
    │ │ │ +00077250: 7320 6f66 2073 6f63 6b65 740a 3c64 6976  s of socket.
    char c │ │ │ +00077290: 6f6e 7374 2a20 736f 636b 6574 5f74 7970 onst* socket_typ │ │ │ +000772a0: 655f 6e61 6d65 2873 6f63 6b65 745f 7479 e_name(socket_ty │ │ │ +000772b0: 7065 5f74 293b 0a3c 2f64 6976 3e0a 7d0a pe_t);.
    .}. │ │ │ +000772c0: 0a23 656e 6469 660a 3c2f 7072 653e 3c2f .#endif.
    relevan │ │ │ +00077300: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../include/li │ │ │ +00077340: 6274 6f72 7265 6e74 2f69 6465 6e74 6966 btorrent/identif │ │ │ +00077350: 795f 636c 6965 6e74 2e68 7070 3a34 383c y_client.hpp:48< │ │ │ +00077360: 2f61 3e3c 2f74 643e 3c74 643e 6869 6465 /a>hide │ │ │ +00077370: 2074 6869 7320 6465 636c 6172 6174 696f this declaratio │ │ │ +00077380: 6e20 7768 656e 2064 6570 7265 6361 7465 n when deprecate │ │ │ +00077390: 6420 6675 6e63 7469 6f6e 7320 6172 6520 d functions are │ │ │ +000773a0: 6469 7361 626c 6564 2c20 616e 6420 7265 disabled, and re │ │ │ +000773b0: 6d6f 7665 2069 7473 2069 6e74 6572 6e61 move its interna │ │ │ +000773c0: 6c20 7573 653c 2f74 643e 3c2f 7472 3e3c l use< │ │ │ +000773d0: 7472 2069 643d 2232 3639 2220 7374 796c tr id="269" styl │ │ │ +000773e0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +000773f0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00077400: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00077410: 6832 3e68 6964 6520 7468 6973 2064 6563 h2>hide this dec │ │ │ +00077420: 6c61 7261 7469 6f6e 2077 6865 6e20 6465 laration when de │ │ │ +00077430: 7072 6563 6174 6564 2066 756e 6374 696f precated functio │ │ │ +00077440: 6e73 2061 7265 2064 6973 6162 6c65 642c ns are disabled, │ │ │ +00077450: 2061 6e64 0a72 656d 6f76 6520 6974 7320 and.remove its │ │ │ +00077460: 696e 7465 726e 616c 2075 7365 3c2f 6832 internal use

    ../include/ │ │ │ +00077480: 6c69 6274 6f72 7265 6e74 2f69 6465 6e74 libtorrent/ident │ │ │ +00077490: 6966 795f 636c 6965 6e74 2e68 7070 3a34 ify_client.hpp:4 │ │ │ +000774a0: 383c 2f68 343e 3c70 7265 2073 7479 6c65 8

    │ │ │ +000774e0: 434f 4e54 5241 4354 2c20 5354 5249 4354  CONTRACT, STRICT
    │ │ │ +000774f0: 204c 4941 4249 4c49 5459 2c20 4f52 2054   LIABILITY, OR T
    │ │ │ +00077500: 4f52 5420 2849 4e43 4c55 4449 4e47 204e  ORT (INCLUDING N
    │ │ │ +00077510: 4547 4c49 4745 4e43 4520 4f52 204f 5448  EGLIGENCE OR OTH
    │ │ │ +00077520: 4552 5749 5345 290a 4152 4953 494e 4720  ERWISE).ARISING 
    │ │ │ +00077530: 494e 2041 4e59 2057 4159 204f 5554 204f  IN ANY WAY OUT O
    │ │ │ +00077540: 4620 5448 4520 5553 4520 4f46 2054 4849  F THE USE OF THI
    │ │ │ +00077550: 5320 534f 4654 5741 5245 2c20 4556 454e  S SOFTWARE, EVEN
    │ │ │ +00077560: 2049 4620 4144 5649 5345 4420 4f46 2054   IF ADVISED OF T
    │ │ │ +00077570: 4845 0a50 4f53 5349 4249 4c49 5459 204f  HE.POSSIBILITY O
    │ │ │ +00077580: 4620 5355 4348 2044 414d 4147 452e 0a0a  F SUCH DAMAGE...
    │ │ │ +00077590: 2a2f 0a0a 2369 666e 6465 6620 544f 5252  */..#ifndef TORR
    │ │ │ +000775a0: 454e 545f 4944 454e 5449 4659 5f43 4c49  ENT_IDENTIFY_CLI
    │ │ │ +000775b0: 454e 545f 4850 505f 494e 434c 5544 4544  ENT_HPP_INCLUDED
    │ │ │ +000775c0: 0a23 6465 6669 6e65 2054 4f52 5245 4e54  .#define TORRENT
    │ │ │ +000775d0: 5f49 4445 4e54 4946 595f 434c 4945 4e54  _IDENTIFY_CLIENT
    │ │ │ +000775e0: 5f48 5050 5f49 4e43 4c55 4445 440a 0a23  _HPP_INCLUDED..#
    │ │ │ +000775f0: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ +00077600: 656e 742f 636f 6e66 6967 2e68 7070 220a  ent/config.hpp".
    │ │ │ +00077610: 0a23 6966 2054 4f52 5245 4e54 5f41 4249  .#if TORRENT_ABI
    │ │ │ +00077620: 5f56 4552 5349 4f4e 203d 3d20 310a 2369  _VERSION == 1.#i
    │ │ │ +00077630: 6e63 6c75 6465 2022 6c69 6274 6f72 7265  nclude "libtorre
    │ │ │ +00077640: 6e74 2f61 7578 5f2f 6469 7361 626c 655f  nt/aux_/disable_
    │ │ │ +00077650: 7761 726e 696e 6773 5f70 7573 682e 6870  warnings_push.hp
    │ │ │ +00077660: 7022 0a23 696e 636c 7564 6520 266c 743b  p".#include <
    │ │ │ +00077670: 626f 6f73 742f 6f70 7469 6f6e 616c 2e68  boost/optional.h
    │ │ │ +00077680: 7070 2667 743b 0a23 696e 636c 7564 6520  pp>.#include 
    │ │ │ +00077690: 226c 6962 746f 7272 656e 742f 6175 785f  "libtorrent/aux_
    │ │ │ +000776a0: 2f64 6973 6162 6c65 5f77 6172 6e69 6e67  /disable_warning
    │ │ │ +000776b0: 735f 706f 702e 6870 7022 0a23 656e 6469  s_pop.hpp".#endi
    │ │ │ +000776c0: 660a 0a23 696e 636c 7564 6520 226c 6962  f..#include "lib
    │ │ │ +000776d0: 746f 7272 656e 742f 7065 6572 5f69 642e  torrent/peer_id.
    │ │ │ +000776e0: 6870 7022 0a23 696e 636c 7564 6520 226c  hpp".#include "l
    │ │ │ +000776f0: 6962 746f 7272 656e 742f 6669 6e67 6572  ibtorrent/finger
    │ │ │ +00077700: 7072 696e 742e 6870 7022 0a0a 3c64 6976  print.hpp"..
    namesp │ │ │ +00077740: 6163 6520 6c69 6274 6f72 7265 6e74 207b ace libtorrent { │ │ │ +00077750: 0a3c 2f64 6976 3e0a 6e61 6d65 7370 6163 .
    .namespac │ │ │ +00077760: 6520 6175 7820 7b0a 0a09 544f 5252 454e e aux {...TORREN │ │ │ +00077770: 545f 4558 5452 415f 4558 504f 5254 0a09 T_EXTRA_EXPORT.. │ │ │ +00077780: 7374 643a 3a73 7472 696e 6720 6964 656e std::string iden │ │ │ +00077790: 7469 6679 5f63 6c69 656e 745f 696d 706c tify_client_impl │ │ │ +000777a0: 2863 6f6e 7374 2070 6565 725f 6964 2661 (const peer_id&a │ │ │ +000777b0: 6d70 3b20 7029 3b0a 0a7d 0a0a 092f 2f20 mp; p);..}...// │ │ │ +000777c0: 7468 6573 6520 6675 6e63 7469 6f6e 7320 these functions │ │ │ +000777d0: 646f 6e27 7420 7265 616c 6c79 206e 6565 don't really nee │ │ │ +000777e0: 6420 746f 2062 6520 7075 626c 6963 2e20 d to be public. │ │ │ +000777f0: 5468 6973 206d 6563 6861 6e69 736d 206f This mechanism o │ │ │ +00077800: 660a 092f 2f20 6164 7665 7274 6973 696e f..// advertisin │ │ │ +00077810: 6720 636c 6965 6e74 2073 6f66 7477 6172 g client softwar │ │ │ +00077820: 6520 616e 6420 7665 7273 696f 6e20 6973 e and version is │ │ │ +00077830: 2061 6c73 6f20 6f75 742d 6461 7465 642e also out-dated. │ │ │ +00077840: 0a0a 092f 2f20 5468 6973 2066 756e 6374 ...// This funct │ │ │ +00077850: 696f 6e20 6361 6e20 6361 6e20 6265 2075 ion can can be u │ │ │ +00077860: 7365 6420 746f 2065 7874 7261 6374 2061 sed to extract a │ │ │ +00077870: 2073 7472 696e 6720 6465 7363 7269 6269 string describi │ │ │ +00077880: 6e67 2061 2063 6c69 656e 740a 092f 2f20 ng a client..// │ │ │ +00077890: 7665 7273 696f 6e20 6672 6f6d 2069 7473 version from its │ │ │ +000778a0: 2070 6565 722d 6964 2e20 4974 2077 696c peer-id. It wil │ │ │ +000778b0: 6c20 7265 636f 676e 697a 6520 6d6f 7374 l recognize most │ │ │ +000778c0: 2063 6c69 656e 7473 2074 6861 7420 6861 clients that ha │ │ │ +000778d0: 7665 2074 6869 730a 092f 2f20 6b69 6e64 ve this..// kind │ │ │ +000778e0: 206f 6620 6964 656e 7469 6669 6361 7469 of identificati │ │ │ +000778f0: 6f6e 2069 6e20 7468 6520 7065 6572 2d69 on in the peer-i │ │ │ +00077900: 642e 0a09 544f 5252 454e 545f 4445 5052 d...TORRENT_DEPR │ │ │ +00077910: 4543 4154 4544 5f45 5850 4f52 540a 0973 ECATED_EXPORT..s │ │ │ +00077920: 7464 3a3a 7374 7269 6e67 2069 6465 6e74 td::string ident │ │ │ +00077930: 6966 795f 636c 6965 6e74 2863 6f6e 7374 ify_client(const │ │ │ +00077940: 2070 6565 725f 6964 2661 6d70 3b20 7029 peer_id& p) │ │ │ +00077950: 3b0a 0a23 6966 2054 4f52 5245 4e54 5f41 ;..#if TORRENT_A │ │ │ +00077960: 4249 5f56 4552 5349 4f4e 203d 3d20 310a BI_VERSION == 1. │ │ │ +00077970: 0a23 696e 636c 7564 6520 226c 6962 746f .#include "libto │ │ │ +00077980: 7272 656e 742f 6175 785f 2f64 6973 6162 rrent/aux_/disab │ │ │ +00077990: 6c65 5f64 6570 7265 6361 7469 6f6e 5f77 le_deprecation_w │ │ │ +000779a0: 6172 6e69 6e67 735f 7075 7368 2e68 7070 arnings_push.hpp │ │ │ +000779b0: 220a 0a09 2f2f 2052 6574 7572 6e73 2061 "...// Returns a │ │ │ +000779c0: 6e20 6f70 7469 6f6e 616c 2066 696e 6765 n optional finge │ │ │ +000779d0: 7270 7269 6e74 2069 6620 616e 7920 6361 rprint if any ca │ │ │ +000779e0: 6e20 6265 2069 6465 6e74 6966 6965 6420 n be identified │ │ │ +000779f0: 6672 6f6d 2074 6865 2070 6565 720a 092f from the peer../ │ │ │ +00077a00: 2f20 6964 2e20 5468 6973 2063 616e 2062 / id. This can b │ │ │ +00077a10: 6520 7573 6564 2074 6f20 6175 746f 6d61 e used to automa │ │ │ +00077a20: 7465 2074 6865 2069 6465 6e74 6966 6963 te the identific │ │ │ +00077a30: 6174 696f 6e20 6f66 2063 6c69 656e 7473 ation of clients │ │ │ +00077a40: 2e20 4974 2077 696c 6c0a 092f 2f20 6e6f . It will..// no │ │ │ +00077a50: 7420 6265 2061 626c 6520 746f 2069 6465 t be able to ide │ │ │ +00077a60: 6e74 6966 7920 7065 6572 7320 7769 7468 ntify peers with │ │ │ +00077a70: 206e 6f6e 2d20 7374 616e 6461 7264 2065 non- standard e │ │ │ +00077a80: 6e63 6f64 696e 6773 2e20 4f6e 6c79 2041 ncodings. Only A │ │ │ +00077a90: 7a75 7265 7573 0a09 2f2f 2073 7479 6c65 zureus..// style │ │ │ +00077aa0: 2c20 5368 6164 6f77 2773 2073 7479 6c65 , Shadow's style │ │ │ +00077ab0: 2061 6e64 204d 6169 6e6c 696e 6520 7374 and Mainline st │ │ │ +00077ac0: 796c 652e 0a09 544f 5252 454e 545f 4445 yle...TORRENT_DE │ │ │ +00077ad0: 5052 4543 4154 4544 5f45 5850 4f52 540a PRECATED_EXPORT. │ │ │ +00077ae0: 0962 6f6f 7374 3a3a 6f70 7469 6f6e 616c .boost::optional │ │ │ +00077af0: 266c 743b 6669 6e67 6572 7072 696e 7426 <fingerprint& │ │ │ +00077b00: 6774 3b0a 0909 636c 6965 6e74 5f66 696e gt;...client_fin │ │ │ +00077b10: 6765 7270 7269 6e74 2870 6565 725f 6964 gerprint(peer_id │ │ │ +00077b20: 2063 6f6e 7374 2661 6d70 3b20 7029 3b0a const& p);. │ │ │ +00077b30: 0a23 696e 636c 7564 6520 226c 6962 746f .#include "libto │ │ │ +00077b40: 7272 656e 742f 6175 785f 2f64 6973 6162 rrent/aux_/disab │ │ │ +00077b50: 6c65 5f77 6172 6e69 6e67 735f 706f 702e le_warnings_pop. │ │ │ +00077b60: 6870 7022 0a3c 2f70 7265 3e3c 2f74 643e hpp".
    │ │ │ +00077b70: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +00077ba0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +00077bb0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +00077bc0: 7074 3a65 7870 616e 6428 3237 3029 223e pt:expand(270)"> │ │ │ +00077bd0: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ +00077be0: 7272 656e 742f 6861 7368 5f70 6963 6b65 rrent/hash_picke │ │ │ +00077bf0: 722e 6870 703a 3135 353c 2f61 3e3c 2f74 r.hpp:155support ba │ │ │ +00077c10: 7463 6865 6420 6164 6469 6e67 206f 6620 tched adding of │ │ │ +00077c20: 626c 6f63 6b20 6861 7368 6573 2066 6f72 block hashes for │ │ │ +00077c30: 2072 6564 7563 6564 206f 7665 7268 6561 reduced overhea │ │ │ +00077c40: 643f 3c2f 7464 3e3c 2f74 723e 3c74 7220 d?

    │ │ │ +00077c90: 7375 7070 6f72 7420 6261 7463 6865 6420 support batched │ │ │ +00077ca0: 6164 6469 6e67 206f 6620 626c 6f63 6b20 adding of block │ │ │ +00077cb0: 6861 7368 6573 2066 6f72 2072 6564 7563 hashes for reduc │ │ │ +00077cc0: 6564 206f 7665 7268 6561 643f 3c2f 6832 ed overhead?

    ../include/ │ │ │ +00077ce0: 6c69 6274 6f72 7265 6e74 2f68 6173 685f libtorrent/hash_ │ │ │ +00077cf0: 7069 636b 6572 2e68 7070 3a31 3535 3c2f picker.hpp:155
    ../
    │ │ │ +00077d40: 2f20 7468 6520 6e75 6d62 6572 206f 6620  / the number of 
    │ │ │ +00077d50: 6861 7368 6573 2069 6e20 7468 6520 7261  hashes in the ra
    │ │ │ +00077d60: 6e67 650a 0909 696e 7420 636f 756e 7420  nge...int count 
    │ │ │ +00077d70: 3d20 303b 0a09 0969 6e74 2070 726f 6f66  = 0;...int proof
    │ │ │ +00077d80: 5f6c 6179 6572 7320 3d20 303b 0a09 7d3b  _layers = 0;..};
    │ │ │ +00077d90: 0a0a 092f 2f20 7661 6c69 6461 7465 7320  ...// validates 
    │ │ │ +00077da0: 7468 6520 6861 7368 5f72 6571 7565 7374  the hash_request
    │ │ │ +00077db0: 2c20 746f 2065 6e73 7572 6520 6974 7320  , to ensure its 
    │ │ │ +00077dc0: 696e 7661 7269 616e 7420 6173 2077 656c  invariant as wel
    │ │ │ +00077dd0: 6c20 6173 206d 6174 6368 696e 670a 092f  l as matching../
    │ │ │ +00077de0: 2f20 7468 6520 746f 7272 656e 7427 7320  / the torrent's 
    │ │ │ +00077df0: 6669 6c65 5f73 746f 7261 6765 2061 6e64  file_storage and
    │ │ │ +00077e00: 2074 6865 206e 756d 6265 7220 6f66 2068   the number of h
    │ │ │ +00077e10: 6173 6865 7320 6163 636f 6d70 616e 7969  ashes accompanyi
    │ │ │ +00077e20: 6e67 2074 6865 0a09 2f2f 2072 6571 7565  ng the..// reque
    │ │ │ +00077e30: 7374 0a09 544f 5252 454e 545f 4558 5452  st..TORRENT_EXTR
    │ │ │ +00077e40: 415f 4558 504f 5254 0a09 626f 6f6c 2076  A_EXPORT..bool v
    │ │ │ +00077e50: 616c 6964 6174 655f 6861 7368 5f72 6571  alidate_hash_req
    │ │ │ +00077e60: 7565 7374 2868 6173 685f 7265 7175 6573  uest(hash_reques
    │ │ │ +00077e70: 7420 636f 6e73 7426 616d 703b 2068 722c  t const& hr,
    │ │ │ +00077e80: 2066 696c 655f 7374 6f72 6167 6520 636f   file_storage co
    │ │ │ +00077e90: 6e73 7426 616d 703b 2066 7329 3b0a 0a09  nst& fs);...
    │ │ │ +00077ea0: 636c 6173 7320 544f 5252 454e 545f 4558  class TORRENT_EX
    │ │ │ +00077eb0: 5452 415f 4558 504f 5254 2068 6173 685f  TRA_EXPORT hash_
    │ │ │ +00077ec0: 7069 636b 6572 0a09 7b0a 0970 7562 6c69  picker..{..publi
    │ │ │ +00077ed0: 633a 0a09 0968 6173 685f 7069 636b 6572  c:...hash_picker
    │ │ │ +00077ee0: 2866 696c 655f 7374 6f72 6167 6520 636f  (file_storage co
    │ │ │ +00077ef0: 6e73 7426 616d 703b 2066 696c 6573 0a09  nst& files..
    │ │ │ +00077f00: 0909 2c20 6175 783a 3a76 6563 746f 7226  .., aux::vector&
    │ │ │ +00077f10: 6c74 3b61 7578 3a3a 6d65 726b 6c65 5f74  lt;aux::merkle_t
    │ │ │ +00077f20: 7265 652c 2066 696c 655f 696e 6465 785f  ree, file_index_
    │ │ │ +00077f30: 7426 6774 3b26 616d 703b 2074 7265 6573  t>& trees
    │ │ │ +00077f40: 293b 0a0a 0909 6861 7368 5f72 6571 7565  );....hash_reque
    │ │ │ +00077f50: 7374 2070 6963 6b5f 6861 7368 6573 2874  st pick_hashes(t
    │ │ │ +00077f60: 7970 6564 5f62 6974 6669 656c 6426 6c74  yped_bitfield<
    │ │ │ +00077f70: 3b70 6965 6365 5f69 6e64 6578 5f74 2667  ;piece_index_t&g
    │ │ │ +00077f80: 743b 2063 6f6e 7374 2661 6d70 3b20 7069  t; const& pi
    │ │ │ +00077f90: 6563 6573 293b 0a0a 0909 6164 645f 6861  eces);....add_ha
    │ │ │ +00077fa0: 7368 6573 5f72 6573 756c 7420 6164 645f  shes_result add_
    │ │ │ +00077fb0: 6861 7368 6573 2868 6173 685f 7265 7175  hashes(hash_requ
    │ │ │ +00077fc0: 6573 7420 636f 6e73 7426 616d 703b 2072  est const& r
    │ │ │ +00077fd0: 6571 2c20 7370 616e 266c 743b 7368 6132  eq, span<sha2
    │ │ │ +00077fe0: 3536 5f68 6173 6820 636f 6e73 7426 6774  56_hash const>
    │ │ │ +00077ff0: 3b20 6861 7368 6573 293b 0a3c 6469 7620  ; hashes);.
    ..set_b │ │ │ +00078030: 6c6f 636b 5f68 6173 685f 7265 7375 6c74 lock_hash_result │ │ │ +00078040: 2073 6574 5f62 6c6f 636b 5f68 6173 6828 set_block_hash( │ │ │ +00078050: 7069 6563 655f 696e 6465 785f 7420 7069 piece_index_t pi │ │ │ +00078060: 6563 652c 2069 6e74 206f 6666 7365 742c ece, int offset, │ │ │ +00078070: 2073 6861 3235 365f 6861 7368 2063 6f6e sha256_hash con │ │ │ +00078080: 7374 2661 6d70 3b20 6829 3b0a 3c2f 6469 st& h);...void hashes_ │ │ │ +000780a0: 7265 6a65 6374 6564 2868 6173 685f 7265 rejected(hash_re │ │ │ +000780b0: 7175 6573 7420 636f 6e73 7426 616d 703b quest const& │ │ │ +000780c0: 2072 6571 293b 0a09 0976 6f69 6420 7665 req);...void ve │ │ │ +000780d0: 7269 6679 5f62 6c6f 636b 5f68 6173 6865 rify_block_hashe │ │ │ +000780e0: 7328 7069 6563 655f 696e 6465 785f 7420 s(piece_index_t │ │ │ +000780f0: 696e 6465 7829 3b0a 0a09 092f 2f20 646f index);....// do │ │ │ +00078100: 2077 6520 6b6e 6f77 2074 6865 2070 6965 we know the pie │ │ │ +00078110: 6365 206c 6179 6572 2068 6173 6820 666f ce layer hash fo │ │ │ +00078120: 7220 6120 7069 6563 650a 0909 626f 6f6c r a piece...bool │ │ │ +00078130: 2068 6176 655f 6861 7368 2870 6965 6365 have_hash(piece │ │ │ +00078140: 5f69 6e64 6578 5f74 2069 6e64 6578 2920 _index_t index) │ │ │ +00078150: 636f 6e73 743b 0a09 092f 2f20 646f 2077 const;...// do w │ │ │ +00078160: 6520 6b6e 6f77 2061 6c6c 2074 6865 2062 e know all the b │ │ │ +00078170: 6c6f 636b 2068 6173 6865 7320 666f 7220 lock hashes for │ │ │ +00078180: 6120 6669 6c65 3f0a 0909 626f 6f6c 2068 a file?...bool h │ │ │ +00078190: 6176 655f 616c 6c28 6669 6c65 5f69 6e64 ave_all(file_ind │ │ │ +000781a0: 6578 5f74 2066 696c 6529 2063 6f6e 7374 ex_t file) const │ │ │ +000781b0: 3b0a 0909 626f 6f6c 2068 6176 655f 616c ;...bool have_al │ │ │ +000781c0: 6c28 2920 636f 6e73 743b 0a09 0962 6f6f l() const;...boo │ │ │ +000781d0: 6c20 7069 6563 655f 7665 7269 6669 6564 l piece_verified │ │ │ +000781e0: 2870 6965 6365 5f69 6e64 6578 5f74 2070 (piece_index_t p │ │ │ +000781f0: 6965 6365 2920 636f 6e73 743b 0a0a 0909 iece) const;.... │ │ │ +00078200: 696e 7420 7069 6563 655f 6c61 7965 7228 int piece_layer( │ │ │ +00078210: 2920 636f 6e73 7420 7b20 7265 7475 726e ) const { return │ │ │ +00078220: 206d 5f70 6965 6365 5f6c 6179 6572 3b20 m_piece_layer; │ │ │ +00078230: 7d0a 0a09 7072 6976 6174 653a 0a09 092f }...private:.../ │ │ │ +00078240: 2f20 7265 7475 726e 7320 7468 6520 6e75 / returns the nu │ │ │ +00078250: 6d62 6572 206f 6620 7072 6f6f 6620 6c61 mber of proof la │ │ │ +00078260: 7965 7273 206e 6565 6465 6420 746f 2076 yers needed to v │ │ │ +00078270: 6572 6966 7920 7468 6520 6e6f 6465 2773 erify the node's │ │ │ +00078280: 2068 6173 680a 0909 696e 7420 6c61 7965 hash...int laye │ │ │ +00078290: 7273 5f74 6f5f 7665 7269 6679 286e 6f64 rs_to_verify(nod │ │ │ +000782a0: 655f 696e 6465 7820 6964 7829 2063 6f6e e_index idx) con │ │ │ +000782b0: 7374 3b0a 0909 696e 7420 6669 6c65 5f6e st;...int file_n │ │ │ +000782c0: 756d 5f6c 6179 6572 7328 6669 6c65 5f69 um_layers(file_i │ │ │ +000782d0: 6e64 6578 5f74 2069 6478 2920 636f 6e73 ndex_t idx) cons │ │ │ +000782e0: 743b 0a0a 0909 7374 7275 6374 2070 6965 t;....struct pie │ │ │ +000782f0: 6365 5f68 6173 685f 7265 7175 6573 740a ce_hash_request. │ │ │ +00078300: 0909 7b0a 0909 0974 696d 655f 706f 696e ..{....time_poin │ │ │ +00078310: 7420 6c61 7374 5f72 6571 7565 7374 203d t last_request = │ │ │ +00078320: 206d 696e 5f74 696d 6528 293b 0a09 0909 min_time();.... │ │ │ +00078330: 696e 7420 6e75 6d5f 7265 7175 6573 7473 int num_requests │ │ │ +00078340: 203d 2030 3b0a 0909 0962 6f6f 6c20 6861 = 0;....bool ha │ │ │ +00078350: 7665 203d 2066 616c 7365 3b0a 0909 7d3b ve = false;...}; │ │ │ +00078360: 0a0a 0909 7374 7275 6374 2070 7269 6f72 ....struct prior │ │ │ +00078370: 6974 795f 626c 6f63 6b5f 7265 7175 6573 ity_block_reques │ │ │ +00078380: 740a 0909 7b0a 0909 0970 7269 6f72 6974 t...{....priorit │ │ │ +00078390: 795f 626c 6f63 6b5f 7265 7175 6573 7428 y_block_request( │ │ │ +000783a0: 6669 6c65 5f69 6e64 6578 5f74 2063 6f6e file_index_t con │ │ │ +000783b0: 7374 2066 2c20 696e 7420 636f 6e73 7420 st f, int const │ │ │ +000783c0: 6229 0a09 0909 093a 2066 696c 6528 6629 b).....: file(f) │ │ │ +000783d0: 2c20 626c 6f63 6b28 6229 207b 7d0a 0909 , block(b) {}... │ │ │ +000783e0: 0966 696c 655f 696e 6465 785f 7420 6669 .file_index_t fi │ │ │ +000783f0: 6c65 3b0a 0909 0969 6e74 2062 6c6f 636b le;....int block │ │ │ 00078400: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ 00078430: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ 00078440: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ @@ -31153,1428 +31153,1428 @@ │ │ │ 00079b00: 7472 3e3c 7472 2073 7479 6c65 3d22 6261 tr> │ │ │ 00079b20: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ 00079b30: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ 00079b60: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -00079b70: 656e 742f 6175 785f 2f73 6573 7369 6f6e ent/aux_/session │ │ │ -00079b80: 5f69 6e74 6572 6661 6365 2e68 7070 3a32 _interface.hpp:2 │ │ │ -00079b90: 3132 3c2f 613e 3c2f 7464 3e3c 7464 3e69 12i │ │ │ -00079ba0: 7420 776f 756c 6420 6265 206e 6963 6520 t would be nice │ │ │ -00079bb0: 746f 206e 6f74 2068 6176 6520 7468 6973 to not have this │ │ │ -00079bc0: 2062 6520 7061 7274 206f 6620 7365 7373 be part of sess │ │ │ -00079bd0: 696f 6e5f 696e 7465 7266 6163 653c 2f74 ion_interface

    it wo │ │ │ -00079c30: 756c 6420 6265 206e 6963 6520 746f 206e uld be nice to n │ │ │ -00079c40: 6f74 2068 6176 6520 7468 6973 2062 6520 ot have this be │ │ │ -00079c50: 7061 7274 206f 6620 7365 7373 696f 6e5f part of session_ │ │ │ -00079c60: 696e 7465 7266 6163 653c 2f68 323e 3c68 interface

    ../include/lib │ │ │ -00079c80: 746f 7272 656e 742f 6175 785f 2f73 6573 torrent/aux_/ses │ │ │ -00079c90: 7369 6f6e 5f69 6e74 6572 6661 6365 2e68 sion_interface.h │ │ │ -00079ca0: 7070 3a32 3132 3c2f 6834 3e3c 7072 6520 pp:212

    ..virtual v
    │ │ │ -00079cf0: 6f69 6420 6465 6665 7272 6564 5f73 7562  oid deferred_sub
    │ │ │ -00079d00: 6d69 745f 6a6f 6273 2829 203d 2030 3b0a  mit_jobs() = 0;.
    │ │ │ -00079d10: 0a09 0976 6972 7475 616c 2073 7464 3a3a  ...virtual std::
    │ │ │ -00079d20: 7569 6e74 3136 5f74 206c 6973 7465 6e5f  uint16_t listen_
    │ │ │ -00079d30: 706f 7274 2829 2063 6f6e 7374 203d 2030  port() const = 0
    │ │ │ -00079d40: 3b0a 0909 7669 7274 7561 6c20 7374 643a  ;...virtual std:
    │ │ │ -00079d50: 3a75 696e 7431 365f 7420 7373 6c5f 6c69  :uint16_t ssl_li
    │ │ │ -00079d60: 7374 656e 5f70 6f72 7428 2920 636f 6e73  sten_port() cons
    │ │ │ -00079d70: 7420 3d20 303b 0a0a 0909 7669 7274 7561  t = 0;....virtua
    │ │ │ -00079d80: 6c20 696e 7420 6c69 7374 656e 5f70 6f72  l int listen_por
    │ │ │ -00079d90: 7428 6175 783a 3a74 7261 6e73 706f 7274  t(aux::transport
    │ │ │ -00079da0: 2073 736c 2c20 6164 6472 6573 7320 636f   ssl, address co
    │ │ │ -00079db0: 6e73 7426 616d 703b 206c 6f63 616c 5f61  nst& local_a
    │ │ │ -00079dc0: 6464 7229 203d 2030 3b0a 0a09 0976 6972  ddr) = 0;....vir
    │ │ │ -00079dd0: 7475 616c 2076 6f69 6420 666f 725f 6561  tual void for_ea
    │ │ │ -00079de0: 6368 5f6c 6973 7465 6e5f 736f 636b 6574  ch_listen_socket
    │ │ │ -00079df0: 2873 7464 3a3a 6675 6e63 7469 6f6e 266c  (std::function&l
    │ │ │ -00079e00: 743b 766f 6964 2861 7578 3a3a 6c69 7374  t;void(aux::list
    │ │ │ -00079e10: 656e 5f73 6f63 6b65 745f 6861 6e64 6c65  en_socket_handle
    │ │ │ -00079e20: 2063 6f6e 7374 2661 6d70 3b29 2667 743b   const&)>
    │ │ │ -00079e30: 2066 2920 3d20 303b 0a0a 0909 2f2f 2061   f) = 0;....// a
    │ │ │ -00079e40: 736b 2066 6f72 2077 6869 6368 2069 6e74  sk for which int
    │ │ │ -00079e50: 6572 6661 6365 2061 6e64 2070 6f72 7420  erface and port 
    │ │ │ -00079e60: 746f 2062 696e 6420 6f75 7467 6f69 6e67  to bind outgoing
    │ │ │ -00079e70: 2070 6565 7220 636f 6e6e 6563 7469 6f6e   peer connection
    │ │ │ -00079e80: 7320 6f6e 0a09 0976 6972 7475 616c 2074  s on...virtual t
    │ │ │ -00079e90: 6370 3a3a 656e 6470 6f69 6e74 2062 696e  cp::endpoint bin
    │ │ │ -00079ea0: 645f 6f75 7467 6f69 6e67 5f73 6f63 6b65  d_outgoing_socke
    │ │ │ -00079eb0: 7428 736f 636b 6574 5f74 7970 6526 616d  t(socket_type&am
    │ │ │ -00079ec0: 703b 2073 2c20 6164 6472 6573 7320 636f  p; s, address co
    │ │ │ -00079ed0: 6e73 7426 616d 703b 0a09 0909 7265 6d6f  nst&....remo
    │ │ │ -00079ee0: 7465 5f61 6464 7265 7373 2c20 6572 726f  te_address, erro
    │ │ │ -00079ef0: 725f 636f 6465 2661 6d70 3b20 6563 2920  r_code& ec) 
    │ │ │ -00079f00: 636f 6e73 7420 3d20 303b 0a09 0976 6972  const = 0;...vir
    │ │ │ -00079f10: 7475 616c 2062 6f6f 6c20 7665 7269 6679  tual bool verify
    │ │ │ -00079f20: 5f62 6f75 6e64 5f61 6464 7265 7373 2861  _bound_address(a
    │ │ │ -00079f30: 6464 7265 7373 2063 6f6e 7374 2661 6d70  ddress const&
    │ │ │ -00079f40: 3b20 6164 6472 2c20 626f 6f6c 2075 7470  ; addr, bool utp
    │ │ │ -00079f50: 0a09 0909 2c20 6572 726f 725f 636f 6465  ...., error_code
    │ │ │ -00079f60: 2661 6d70 3b20 6563 2920 3d20 303b 0a0a  & ec) = 0;..
    │ │ │ -00079f70: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ -00079f80: 4449 5341 424c 455f 4d55 5441 424c 455f  DISABLE_MUTABLE_
    │ │ │ -00079f90: 544f 5252 454e 5453 0a09 0976 6972 7475  TORRENTS...virtu
    │ │ │ -00079fa0: 616c 2073 7464 3a3a 7665 6374 6f72 266c  al std::vector&l
    │ │ │ -00079fb0: 743b 7374 643a 3a73 6861 7265 645f 7074  t;std::shared_pt
    │ │ │ -00079fc0: 7226 6c74 3b74 6f72 7265 6e74 2667 743b  r<torrent>
    │ │ │ -00079fd0: 2667 743b 2066 696e 645f 636f 6c6c 6563  > find_collec
    │ │ │ -00079fe0: 7469 6f6e 280a 0909 0973 7464 3a3a 7374  tion(....std::st
    │ │ │ -00079ff0: 7269 6e67 2063 6f6e 7374 2661 6d70 3b20  ring const& 
    │ │ │ -0007a000: 636f 6c6c 6563 7469 6f6e 2920 636f 6e73  collection) cons
    │ │ │ -0007a010: 7420 3d20 303b 0a23 656e 6469 660a 0a3c  t = 0;.#endif..<
    │ │ │ -0007a020: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -0007a030: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -0007a040: 7769 6474 683d 2231 3030 2522 3e09 0976  width="100%">..v
    │ │ │ -0007a050: 6972 7475 616c 2070 726f 7879 5f73 6574  irtual proxy_set
    │ │ │ -0007a060: 7469 6e67 7320 7072 6f78 7928 2920 636f  tings proxy() co
    │ │ │ -0007a070: 6e73 7420 3d20 303b 0a3c 2f64 6976 3e0a  nst = 0;..
    │ │ │ -0007a080: 2369 6620 544f 5252 454e 545f 5553 455f  #if TORRENT_USE_
    │ │ │ -0007a090: 4932 500a 0909 7669 7274 7561 6c20 6368  I2P...virtual ch
    │ │ │ -0007a0a0: 6172 2063 6f6e 7374 2a20 6932 705f 7365  ar const* i2p_se
    │ │ │ -0007a0b0: 7373 696f 6e28 2920 636f 6e73 7420 3d20  ssion() const = 
    │ │ │ -0007a0c0: 303b 0a09 0976 6972 7475 616c 2073 7464  0;...virtual std
    │ │ │ -0007a0d0: 3a3a 7374 7269 6e67 2063 6f6e 7374 2661  ::string const&a
    │ │ │ -0007a0e0: 6d70 3b20 6c6f 6361 6c5f 6932 705f 656e  mp; local_i2p_en
    │ │ │ -0007a0f0: 6470 6f69 6e74 2829 2063 6f6e 7374 203d  dpoint() const =
    │ │ │ -0007a100: 2030 3b0a 2365 6e64 6966 0a0a 0909 7669   0;.#endif....vi
    │ │ │ -0007a110: 7274 7561 6c20 766f 6964 2070 7269 6f72  rtual void prior
    │ │ │ -0007a120: 6974 697a 655f 636f 6e6e 6563 7469 6f6e  itize_connection
    │ │ │ -0007a130: 7328 7374 643a 3a77 6561 6b5f 7074 7226  s(std::weak_ptr&
    │ │ │ -0007a140: 6c74 3b74 6f72 7265 6e74 2667 743b 2074  lt;torrent> t
    │ │ │ -0007a150: 2920 3d20 303b 0a0a 0909 7669 7274 7561  ) = 0;....virtua
    │ │ │ -0007a160: 6c20 766f 6964 2074 7269 6767 6572 5f61  l void trigger_a
    │ │ │ -0007a170: 7574 6f5f 6d61 6e61 6765 2829 203d 2030  uto_manage() = 0
    │ │ │ -0007a180: 3b0a 0a09 0976 6972 7475 616c 2076 6f69  ;....virtual voi
    │ │ │ -0007a190: 6420 6170 706c 795f 7365 7474 696e 6773  d apply_settings
    │ │ │ -0007a1a0: 5f70 6163 6b28 7374 643a 3a73 6861 7265  _pack(std::share
    │ │ │ -0007a1b0: 645f 7074 7226 6c74 3b73 6574 7469 6e67  d_ptr<setting
    │ │ │ -0007a1c0: 735f 7061 636b 2667 743b 2070 6163 6b29  s_pack> pack)
    │ │ │ -0007a1d0: 203d 2030 3b0a 0909 7669 7274 7561 6c20   = 0;...virtual 
    │ │ │ -0007a1e0: 7365 7373 696f 6e5f 7365 7474 696e 6773  session_settings
    │ │ │ -0007a1f0: 2063 6f6e 7374 2661 6d70 3b20 7365 7474   const& sett
    │ │ │ -0007a200: 696e 6773 2829 2063 6f6e 7374 203d 2030  ings() const = 0
    │ │ │ -0007a210: 3b0a 0a09 0976 6972 7475 616c 2076 6f69  ;....virtual voi
    │ │ │ -0007a220: 6420 7175 6575 655f 7472 6163 6b65 725f  d queue_tracker_
    │ │ │ -0007a230: 7265 7175 6573 7428 7472 6163 6b65 725f  request(tracker_
    │ │ │ -0007a240: 7265 7175 6573 7420 7265 710a 0909 092c  request req....,
    │ │ │ -0007a250: 2073 7464 3a3a 7765 616b 5f70 7472 266c   std::weak_ptr&l
    │ │ │ -0007a260: 743b 7265 7175 6573 745f 6361 6c6c 6261  t;request_callba
    │ │ │ -0007a270: 636b 2667 743b 2063 2920 3d20 303b 0a0a  ck> c) = 0;..
    │ │ │ -0007a280: 0909 2f2f 2070 6565 722d 636c 6173 7365  ..// peer-classe
    │ │ │ -0007a290: 730a 0909 7669 7274 7561 6c20 766f 6964  s...virtual void
    │ │ │ -0007a2a0: 2073 6574 5f70 6565 725f 636c 6173 7365   set_peer_classe
    │ │ │ -0007a2b0: 7328 7065 6572 5f63 6c61 7373 5f73 6574  s(peer_class_set
    │ │ │ -0007a2c0: 2a20 732c 2061 6464 7265 7373 2063 6f6e  * s, address con
    │ │ │ -0007a2d0: 7374 2661 6d70 3b20 612c 2073 6f63 6b65  st& a, socke
    │ │ │ -0007a2e0: 745f 7479 7065 5f74 2073 7429 203d 2030  t_type_t st) = 0
    │ │ │ -0007a2f0: 3b0a 0909 7669 7274 7561 6c20 7065 6572  ;...virtual peer
    │ │ │ -0007a300: 5f63 6c61 7373 5f70 6f6f 6c20 636f 6e73  _class_pool cons
    │ │ │ -0007a310: 7426 616d 703b 2070 6565 725f 636c 6173  t& peer_clas
    │ │ │ -0007a320: 7365 7328 2920 636f 6e73 7420 3d20 303b  ses() const = 0;
    │ │ │ -0007a330: 0a09 0976 6972 7475 616c 2070 6565 725f  ...virtual peer_
    │ │ │ -0007a340: 636c 6173 735f 706f 6f6c 2661 6d70 3b20  class_pool& 
    │ │ │ -0007a350: 7065 6572 5f63 6c61 7373 6573 2829 203d  peer_classes() =
    │ │ │ -0007a360: 2030 3b0a 0909 7669 7274 7561 6c20 626f   0;...virtual bo
    │ │ │ -0007a370: 6f6c 2069 676e 6f72 655f 756e 6368 6f6b  ol ignore_unchok
    │ │ │ -0007a380: 655f 736c 6f74 735f 7365 7428 7065 6572  e_slots_set(peer
    │ │ │ -0007a390: 5f63 6c61 7373 5f73 6574 2063 6f6e 7374  _class_set const
    │ │ │ -0007a3a0: 2661 6d70 3b20 7365 7429 2063 6f6e 7374  & set) const
    │ │ │ -0007a3b0: 203d 2030 3b0a 0909 7669 7274 7561 6c20   = 0;...virtual 
    │ │ │ -0007a3c0: 696e 7420 636f 7079 5f70 6572 7469 6e65  int copy_pertine
    │ │ │ -0007a3d0: 6e74 5f63 6861 6e6e 656c 7328 7065 6572  nt_channels(peer
    │ │ │ -0007a3e0: 5f63 6c61 7373 5f73 6574 2063 6f6e 7374  _class_set const
    │ │ │ -0007a3f0: 2661 6d70 3b20 7365 740a 0909 092c 2069  & set...., i
    │ │ │ -0007a400: 6e74 2063 6861 6e6e 656c 2c20 6261 6e64  nt channel, band
    │ │ │ -0007a410: 7769 6474 685f 6368 616e 6e65 6c2a 2a20  width_channel** 
    │ │ │ -0007a420: 6473 742c 2069 6e74 206d 2920 3d20 303b  dst, int m) = 0;
    │ │ │ -0007a430: 0a09 0976 6972 7475 616c 2069 6e74 2075  ...virtual int u
    │ │ │ -0007a440: 7365 5f71 756f 7461 5f6f 7665 7268 6561  se_quota_overhea
    │ │ │ -0007a450: 6428 7065 6572 5f63 6c61 7373 5f73 6574  d(peer_class_set
    │ │ │ -0007a460: 2661 6d70 3b20 7365 742c 2069 6e74 2061  & set, int a
    │ │ │ -0007a470: 6d6f 756e 745f 646f 776e 2c20 696e 7420  mount_down, int 
    │ │ │ -0007a480: 616d 6f75 6e74 5f75 7029 203d 2030 3b0a  amount_up) = 0;.
    │ │ │ -0007a490: 0a09 0976 6972 7475 616c 2062 616e 6477  ...virtual bandw
    │ │ │ -0007a4a0: 6964 7468 5f6d 616e 6167 6572 2a20 6765  idth_manager* ge
    │ │ │ -0007a4b0: 745f 6261 6e64 7769 6474 685f 6d61 6e61  t_bandwidth_mana
    │ │ │ -0007a4c0: 6765 7228 696e 7420 6368 616e 6e65 6c29  ger(int channel)
    │ │ │ -0007a4d0: 203d 2030 3b0a 0a09 0976 6972 7475 616c   = 0;....virtual
    │ │ │ -0007a4e0: 2076 6f69 6420 7365 6e74 5f62 7974 6573   void sent_bytes
    │ │ │ -0007a4f0: 2869 6e74 2062 7974 6573 5f70 6179 6c6f  (int bytes_paylo
    │ │ │ -0007a500: 6164 2c20 696e 7420 6279 7465 735f 7072  ad, int bytes_pr
    │ │ │ -0007a510: 6f74 6f63 6f6c 2920 3d20 303b 0a09 0976  otocol) = 0;...v
    │ │ │ -0007a520: 6972 7475 616c 2076 6f69 6420 7265 6365  irtual void rece
    │ │ │ -0007a530: 6976 6564 5f62 7974 6573 2869 6e74 2062  ived_bytes(int b
    │ │ │ -0007a540: 7974 6573 5f70 6179 6c6f 6164 2c20 696e  ytes_payload, in
    │ │ │ -0007a550: 7420 6279 7465 735f 7072 6f74 6f63 6f6c  t bytes_protocol
    │ │ │ -0007a560: 2920 3d20 303b 0a09 0976 6972 7475 616c  ) = 0;...virtual
    │ │ │ -0007a570: 2076 6f69 6420 7472 616e 6369 6576 655f   void trancieve_
    │ │ │ -0007a580: 6970 5f70 6163 6b65 7428 696e 7420 6279  ip_packet(int by
    │ │ │ -0007a590: 7465 732c 2062 6f6f 6c20 6970 7636 2920  tes, bool ipv6) 
    │ │ │ -0007a5a0: 3d20 303b 0a3c 2f70 7265 3e3c 2f74 643e  = 0;.
    │ │ │ -0007a5b0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -0007a5e0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -0007a5f0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -0007a600: 7074 3a65 7870 616e 6428 3237 3529 223e pt:expand(275)"> │ │ │ -0007a610: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -0007a620: 7272 656e 742f 6175 785f 2f73 6573 7369 rrent/aux_/sessi │ │ │ -0007a630: 6f6e 5f69 6d70 6c2e 6870 703a 3236 353c on_impl.hpp:265< │ │ │ -0007a640: 2f61 3e3c 2f74 643e 3c74 643e 6d61 6b65 /a>make │ │ │ -0007a650: 2074 6865 7365 2064 6972 6563 7420 6d65 these direct me │ │ │ -0007a660: 6d62 6572 7320 616e 6420 6765 6e65 7261 mbers and genera │ │ │ -0007a670: 7465 2073 6861 7265 645f 7074 7273 2074 te shared_ptrs t │ │ │ -0007a680: 6f20 7468 656d 2077 6869 6368 2061 6c69 o them which ali │ │ │ -0007a690: 6173 2074 6865 206c 6973 7465 6e5f 736f as the listen_so │ │ │ -0007a6a0: 636b 6574 5f74 2073 6861 7265 645f 7074 cket_t shared_pt │ │ │ -0007a6b0: 723c 2f74 643e 3c2f 7472 3e3c 7472 2069 r

    m │ │ │ -0007a700: 616b 6520 7468 6573 6520 6469 7265 6374 ake these direct │ │ │ -0007a710: 206d 656d 6265 7273 2061 6e64 2067 656e members and gen │ │ │ -0007a720: 6572 6174 6520 7368 6172 6564 5f70 7472 erate shared_ptr │ │ │ -0007a730: 7320 746f 2074 6865 6d0a 7768 6963 6820 s to them.which │ │ │ -0007a740: 616c 6961 7320 7468 6520 6c69 7374 656e alias the listen │ │ │ -0007a750: 5f73 6f63 6b65 745f 7420 7368 6172 6564 _socket_t shared │ │ │ -0007a760: 5f70 7472 3c2f 6832 3e3c 6834 3e2e 2e2f _ptr

    ../ │ │ │ -0007a770: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -0007a780: 6e74 2f61 7578 5f2f 7365 7373 696f 6e5f nt/aux_/session_ │ │ │ -0007a790: 696d 706c 2e68 7070 3a32 3635 3c2f 6834 impl.hpp:265

    ...if
    │ │ │ -0007a7e0: 2028 7564 705f 736f 636b 2920 7265 7475   (udp_sock) retu
    │ │ │ -0007a7f0: 726e 2075 6470 5f73 6f63 6b2d 2667 743b  rn udp_sock->
    │ │ │ -0007a800: 736f 636b 2e6c 6f63 616c 5f70 6f72 7428  sock.local_port(
    │ │ │ -0007a810: 293b 0a09 0909 7265 7475 726e 2030 3b0a  );....return 0;.
    │ │ │ -0007a820: 0909 7d0a 0a09 092f 2f20 3020 6973 206e  ..}....// 0 is n
    │ │ │ -0007a830: 6174 706d 7020 3120 6973 2075 706e 700a  atpmp 1 is upnp.
    │ │ │ -0007a840: 0909 2f2f 2074 6865 206f 7264 6572 206f  ..// the order o
    │ │ │ -0007a850: 6620 7468 6573 6520 6172 7261 7973 2064  f these arrays d
    │ │ │ -0007a860: 6574 6572 6d69 6e65 7320 7468 6520 7072  etermines the pr
    │ │ │ -0007a870: 696f 7269 7479 2069 6e0a 0909 2f2f 2077  iority in...// w
    │ │ │ -0007a880: 6869 6368 2074 6865 6972 2070 6f72 7473  hich their ports
    │ │ │ -0007a890: 2077 696c 6c20 6265 2061 6e6e 6f75 6e63   will be announc
    │ │ │ -0007a8a0: 6564 2074 6f20 7065 6572 730a 0909 6175  ed to peers...au
    │ │ │ -0007a8b0: 783a 3a61 7272 6179 266c 743b 6c69 7374  x::array<list
    │ │ │ -0007a8c0: 656e 5f70 6f72 745f 6d61 7070 696e 672c  en_port_mapping,
    │ │ │ -0007a8d0: 2032 2c20 706f 7274 6d61 705f 7472 616e   2, portmap_tran
    │ │ │ -0007a8e0: 7370 6f72 7426 6774 3b20 7463 705f 706f  sport> tcp_po
    │ │ │ -0007a8f0: 7274 5f6d 6170 7069 6e67 3b0a 0909 6175  rt_mapping;...au
    │ │ │ -0007a900: 783a 3a61 7272 6179 266c 743b 6c69 7374  x::array<list
    │ │ │ -0007a910: 656e 5f70 6f72 745f 6d61 7070 696e 672c  en_port_mapping,
    │ │ │ -0007a920: 2032 2c20 706f 7274 6d61 705f 7472 616e   2, portmap_tran
    │ │ │ -0007a930: 7370 6f72 7426 6774 3b20 7564 705f 706f  sport> udp_po
    │ │ │ -0007a940: 7274 5f6d 6170 7069 6e67 3b0a 0a09 092f  rt_mapping;..../
    │ │ │ -0007a950: 2f20 696e 6469 6361 7465 7320 7768 6574  / indicates whet
    │ │ │ -0007a960: 6865 7220 7468 6973 2069 7320 616e 2053  her this is an S
    │ │ │ -0007a970: 534c 206c 6973 7465 6e20 736f 636b 6574  SL listen socket
    │ │ │ -0007a980: 206f 7220 6e6f 740a 0909 7472 616e 7370   or not...transp
    │ │ │ -0007a990: 6f72 7420 7373 6c20 3d20 7472 616e 7370  ort ssl = transp
    │ │ │ -0007a9a0: 6f72 743a 3a70 6c61 696e 7465 7874 3b0a  ort::plaintext;.
    │ │ │ -0007a9b0: 0a09 096c 6973 7465 6e5f 736f 636b 6574  ...listen_socket
    │ │ │ -0007a9c0: 5f66 6c61 6773 5f74 2066 6c61 6773 203d  _flags_t flags =
    │ │ │ -0007a9d0: 2061 6363 6570 745f 696e 636f 6d69 6e67   accept_incoming
    │ │ │ -0007a9e0: 3b0a 0a09 092f 2f20 7468 6520 6163 7475  ;....// the actu
    │ │ │ -0007a9f0: 616c 2073 6f63 6b65 7473 2028 5443 5020  al sockets (TCP 
    │ │ │ -0007aa00: 6c69 7374 656e 2073 6f63 6b65 7420 616e  listen socket an
    │ │ │ -0007aa10: 6420 5544 5020 736f 636b 6574 290a 0909  d UDP socket)...
    │ │ │ -0007aa20: 2f2f 2041 6e20 656e 7472 7920 646f 6573  // An entry does
    │ │ │ -0007aa30: 206e 6f74 206e 6563 6573 7361 7269 6c79   not necessarily
    │ │ │ -0007aa40: 2068 6176 6520 6120 5544 5020 6f72 2054   have a UDP or T
    │ │ │ -0007aa50: 4350 2073 6f63 6b65 742e 204f 6e65 206f  CP socket. One o
    │ │ │ -0007aa60: 6620 7468 6573 650a 0909 2f2f 2070 6f69  f these...// poi
    │ │ │ -0007aa70: 6e74 6572 7320 6d61 7920 6265 206e 756c  nters may be nul
    │ │ │ -0007aa80: 6c70 7472 210a 0909 2f2f 2054 6865 7365  lptr!...// These
    │ │ │ -0007aa90: 206d 7573 7420 6265 2073 6861 7265 645f   must be shared_
    │ │ │ -0007aaa0: 7074 7220 746f 2061 766f 6964 2061 2064  ptr to avoid a d
    │ │ │ -0007aab0: 616e 676c 696e 6720 7265 6665 7265 6e63  angling referenc
    │ │ │ -0007aac0: 6520 6966 2061 6e0a 0909 2f2f 2069 6e63  e if an...// inc
    │ │ │ -0007aad0: 6f6d 696e 6720 7061 636b 6574 2069 7320  oming packet is 
    │ │ │ -0007aae0: 696e 2074 6865 2065 7665 6e74 2071 7565  in the event que
    │ │ │ -0007aaf0: 7565 2077 6865 6e20 7468 6520 736f 636b  ue when the sock
    │ │ │ -0007ab00: 6574 2069 7320 6572 6173 6564 0a3c 6469  et is erased...std
    │ │ │ -0007ab40: 3a3a 7368 6172 6564 5f70 7472 266c 743b  ::shared_ptr<
    │ │ │ -0007ab50: 7463 703a 3a61 6363 6570 746f 7226 6774  tcp::acceptor>
    │ │ │ -0007ab60: 3b20 736f 636b 3b0a 3c2f 6469 763e 0909  ; sock;...
    │ │ │ -0007ab70: 7374 643a 3a73 6861 7265 645f 7074 7226  std::shared_ptr&
    │ │ │ -0007ab80: 6c74 3b61 7578 3a3a 7365 7373 696f 6e5f  lt;aux::session_
    │ │ │ -0007ab90: 7564 705f 736f 636b 6574 2667 743b 2075  udp_socket> u
    │ │ │ -0007aba0: 6470 5f73 6f63 6b3b 0a0a 0909 2f2f 2073  dp_sock;....// s
    │ │ │ -0007abb0: 696e 6365 2075 6470 2070 6163 6b65 7473  ince udp packets
    │ │ │ -0007abc0: 2061 7265 2065 7870 6563 7465 6420 746f   are expected to
    │ │ │ -0007abd0: 2062 6520 6469 7370 6174 6368 6564 2066   be dispatched f
    │ │ │ -0007abe0: 7265 7175 656e 746c 792c 2074 6869 7320  requently, this 
    │ │ │ -0007abf0: 7361 7665 730a 0909 2f2f 2074 696d 6520  saves...// time 
    │ │ │ -0007ac00: 6f6e 2068 616e 646c 6572 2061 6c6c 6f63  on handler alloc
    │ │ │ -0007ac10: 6174 696f 6e20 6576 6572 7920 7469 6d65  ation every time
    │ │ │ -0007ac20: 2077 6520 7265 6164 2061 6761 696e 2e0a   we read again..
    │ │ │ -0007ac30: 0909 6175 783a 3a68 616e 646c 6572 5f73  ..aux::handler_s
    │ │ │ -0007ac40: 746f 7261 6765 266c 743b 6175 783a 3a75  torage<aux::u
    │ │ │ -0007ac50: 6470 5f68 616e 646c 6572 5f6d 6178 5f73  dp_handler_max_s
    │ │ │ -0007ac60: 697a 652c 2061 7578 3a3a 7564 705f 6861  ize, aux::udp_ha
    │ │ │ -0007ac70: 6e64 6c65 7226 6774 3b20 7564 705f 6861  ndler> udp_ha
    │ │ │ -0007ac80: 6e64 6c65 725f 7374 6f72 6167 653b 0a0a  ndler_storage;..
    │ │ │ -0007ac90: 0909 7374 643a 3a73 6861 7265 645f 7074  ..std::shared_pt
    │ │ │ -0007aca0: 7226 6c74 3b6e 6174 706d 7026 6774 3b20  r<natpmp> 
    │ │ │ -0007acb0: 6e61 7470 6d70 5f6d 6170 7065 723b 0a09  natpmp_mapper;..
    │ │ │ -0007acc0: 0973 7464 3a3a 7368 6172 6564 5f70 7472  .std::shared_ptr
    │ │ │ -0007acd0: 266c 743b 7570 6e70 2667 743b 2075 706e  <upnp> upn
    │ │ │ -0007ace0: 705f 6d61 7070 6572 3b0a 0a09 0973 7464  p_mapper;....std
    │ │ │ -0007acf0: 3a3a 7368 6172 6564 5f70 7472 266c 743b  ::shared_ptr<
    │ │ │ -0007ad00: 7374 7275 6374 206c 7364 2667 743b 206c  struct lsd> l
    │ │ │ -0007ad10: 7364 3b0a 0a09 092f 2f20 7365 7420 746f  sd;....// set to
    │ │ │ -0007ad20: 2074 7275 6520 7768 656e 2077 6520 7265   true when we re
    │ │ │ -0007ad30: 6365 6976 6520 616e 2069 6e63 6f6d 696e  ceive an incomin
    │ │ │ -0007ad40: 6720 636f 6e6e 6563 7469 6f6e 2066 726f  g connection fro
    │ │ │ -0007ad50: 6d20 7468 6973 206c 6973 7465 6e0a 0909  m this listen...
    │ │ │ -0007ad60: 2f2f 2073 6f63 6b65 740a 0909 626f 6f6c  // socket...bool
    │ │ │ -0007ad70: 2069 6e63 6f6d 696e 675f 636f 6e6e 6563   incoming_connec
    │ │ │ -0007ad80: 7469 6f6e 203d 2066 616c 7365 3b0a 097d  tion = false;..}
    │ │ │ -0007ad90: 3b0a 0a09 0973 7472 7563 7420 544f 5252  ;....struct TORR
    │ │ │ -0007ada0: 454e 545f 4558 5452 415f 4558 504f 5254  ENT_EXTRA_EXPORT
    │ │ │ -0007adb0: 206c 6973 7465 6e5f 656e 6470 6f69 6e74   listen_endpoint
    │ │ │ -0007adc0: 5f74 0a09 097b 0a09 0909 6c69 7374 656e  _t...{....listen
    │ │ │ -0007add0: 5f65 6e64 706f 696e 745f 7428 6164 6472  _endpoint_t(addr
    │ │ │ -0007ade0: 6573 7320 636f 6e73 7426 616d 703b 2061  ess const& a
    │ │ │ -0007adf0: 6472 2c20 696e 7420 702c 2073 7464 3a3a  dr, int p, std::
    │ │ │ -0007ae00: 7374 7269 6e67 2064 6576 2c20 7472 616e  string dev, tran
    │ │ │ -0007ae10: 7370 6f72 7420 730a 0909 0909 2c20 6c69  sport s....., li
    │ │ │ -0007ae20: 7374 656e 5f73 6f63 6b65 745f 666c 6167  sten_socket_flag
    │ │ │ -0007ae30: 735f 7420 662c 2061 6464 7265 7373 2063  s_t f, address c
    │ │ │ -0007ae40: 6f6e 7374 2661 6d70 3b20 6e6d 6173 6b20  onst& nmask 
    │ │ │ -0007ae50: 3d20 6164 6472 6573 737b 7d29 0a09 0909  = address{})....
    │ │ │ -0007ae60: 093a 2061 6464 7228 6164 7229 2c20 6e65  .: addr(adr), ne
    │ │ │ -0007ae70: 746d 6173 6b28 6e6d 6173 6b29 2c20 706f  tmask(nmask), po
    │ │ │ -0007ae80: 7274 2870 292c 2064 6576 6963 6528 7374  rt(p), device(st
    │ │ │ -0007ae90: 643a 3a6d 6f76 6528 6465 7629 292c 2073  d::move(dev)), s
    │ │ │ -0007aea0: 736c 2873 292c 2066 6c61 6773 2866 2920  sl(s), flags(f) 
    │ │ │ -0007aeb0: 7b7d 0a0a 0909 0962 6f6f 6c20 6f70 6572  {}.....bool oper
    │ │ │ -0007aec0: 6174 6f72 3d3d 286c 6973 7465 6e5f 656e  ator==(listen_en
    │ │ │ -0007aed0: 6470 6f69 6e74 5f74 2063 6f6e 7374 2661  dpoint_t const&a
    │ │ │ -0007aee0: 6d70 3b20 6f29 2063 6f6e 7374 0a09 0909  mp; o) const....
    │ │ │ -0007aef0: 7b0a 0909 0909 7265 7475 726e 2061 6464  {.....return add
    │ │ │ -0007af00: 7220 3d3d 206f 2e61 6464 720a 0909 0909  r == o.addr.....
    │ │ │ -0007af10: 0926 616d 703b 2661 6d70 3b20 706f 7274  .&& port
    │ │ │ -0007af20: 203d 3d20 6f2e 706f 7274 0a09 0909 0909   == o.port......
    │ │ │ -0007af30: 2661 6d70 3b26 616d 703b 2064 6576 6963  && devic
    │ │ │ -0007af40: 6520 3d3d 206f 2e64 6576 6963 650a 0909  e == o.device...
    │ │ │ -0007af50: 0909 0926 616d 703b 2661 6d70 3b20 7373  ...&& ss
    │ │ │ -0007af60: 6c20 3d3d 206f 2e73 736c 0a09 0909 0909  l == o.ssl......
    │ │ │ -0007af70: 2661 6d70 3b26 616d 703b 2066 6c61 6773  && flags
    │ │ │ -0007af80: 203d 3d20 6f2e 666c 6167 733b 0a09 0909   == o.flags;....
    │ │ │ -0007af90: 7d0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74  }.
    < │ │ │ -0007afc0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0007afd0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0007b000: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -0007b010: 6e74 2f61 7578 5f2f 7365 7373 696f 6e5f nt/aux_/session_ │ │ │ -0007b020: 696d 706c 2e68 7070 3a31 3039 303c 2f61 impl.hpp:1090replac │ │ │ -0007b040: 6520 7468 6973 2062 7920 6120 7072 6f70 e this by a prop │ │ │ -0007b050: 6572 2061 7369 6f20 7469 6d65 723c 2f74 er asio timer

    repla │ │ │ -0007b0b0: 6365 2074 6869 7320 6279 2061 2070 726f ce this by a pro │ │ │ -0007b0c0: 7065 7220 6173 696f 2074 696d 6572 3c2f per asio timer

    ../includ │ │ │ -0007b0e0: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ -0007b0f0: 5f2f 7365 7373 696f 6e5f 696d 706c 2e68 _/session_impl.h │ │ │ -0007b100: 7070 3a31 3039 303c 2f68 343e 3c70 7265 pp:1090

    #ifdef TOR
    │ │ │ -0007b150: 5245 4e54 5f53 534c 5f50 4545 5253 0a09  RENT_SSL_PEERS..
    │ │ │ -0007b160: 0909 766f 6964 206f 6e5f 696e 636f 6d69  ..void on_incomi
    │ │ │ -0007b170: 6e67 5f75 7470 5f73 736c 2873 6f63 6b65  ng_utp_ssl(socke
    │ │ │ -0007b180: 745f 7479 7065 2073 293b 0a09 0909 766f  t_type s);....vo
    │ │ │ -0007b190: 6964 2073 736c 5f68 616e 6473 6861 6b65  id ssl_handshake
    │ │ │ -0007b1a0: 2865 7272 6f72 5f63 6f64 6520 636f 6e73  (error_code cons
    │ │ │ -0007b1b0: 7426 616d 703b 2065 632c 2073 6f63 6b65  t& ec, socke
    │ │ │ -0007b1c0: 745f 7479 7065 2a20 7329 3b0a 2365 6e64  t_type* s);.#end
    │ │ │ -0007b1d0: 6966 0a0a 0909 092f 2f20 726f 756e 642d  if.....// round-
    │ │ │ -0007b1e0: 726f 6269 6e20 696e 6465 7820 696e 746f  robin index into
    │ │ │ -0007b1f0: 206d 5f6f 7574 676f 696e 675f 696e 7465   m_outgoing_inte
    │ │ │ -0007b200: 7266 6163 6573 0a09 0909 6d75 7461 626c  rfaces....mutabl
    │ │ │ -0007b210: 6520 7374 643a 3a75 696e 7438 5f74 206d  e std::uint8_t m
    │ │ │ -0007b220: 5f69 6e74 6572 6661 6365 5f69 6e64 6578  _interface_index
    │ │ │ -0007b230: 203d 2030 3b0a 0a09 0909 7374 643a 3a73   = 0;.....std::s
    │ │ │ -0007b240: 6861 7265 645f 7074 7226 6c74 3b6c 6973  hared_ptr<lis
    │ │ │ -0007b250: 7465 6e5f 736f 636b 6574 5f74 2667 743b  ten_socket_t>
    │ │ │ -0007b260: 2073 6574 7570 5f6c 6973 7465 6e65 7228   setup_listener(
    │ │ │ -0007b270: 0a09 0909 096c 6973 7465 6e5f 656e 6470  .....listen_endp
    │ │ │ -0007b280: 6f69 6e74 5f74 2063 6f6e 7374 2661 6d70  oint_t const&
    │ │ │ -0007b290: 3b20 6c65 702c 2065 7272 6f72 5f63 6f64  ; lep, error_cod
    │ │ │ -0007b2a0: 6526 616d 703b 2065 6329 3b0a 0a23 6966  e& ec);..#if
    │ │ │ -0007b2b0: 6e64 6566 2054 4f52 5245 4e54 5f44 4953  ndef TORRENT_DIS
    │ │ │ -0007b2c0: 4142 4c45 5f44 4854 0a09 0909 6468 743a  ABLE_DHT....dht:
    │ │ │ -0007b2d0: 3a64 6874 5f73 7461 7465 206d 5f64 6874  :dht_state m_dht
    │ │ │ -0007b2e0: 5f73 7461 7465 3b0a 2365 6e64 6966 0a0a  _state;.#endif..
    │ │ │ -0007b2f0: 0909 092f 2f20 7468 6973 2069 7320 696e  ...// this is in
    │ │ │ -0007b300: 6974 6961 6c69 7a65 6420 746f 2074 6865  itialized to the
    │ │ │ -0007b310: 2075 6e63 686f 6b65 5f69 6e74 6572 7661   unchoke_interva
    │ │ │ -0007b320: 6c0a 0909 092f 2f20 7365 7373 696f 6e5f  l....// session_
    │ │ │ -0007b330: 7365 7474 696e 6720 616e 6420 6465 6372  setting and decr
    │ │ │ -0007b340: 6561 7365 6420 6576 6572 7920 7365 636f  eased every seco
    │ │ │ -0007b350: 6e64 2e0a 0909 092f 2f20 7768 656e 2069  nd.....// when i
    │ │ │ -0007b360: 7420 7265 6163 6865 7320 7a65 726f 2c20  t reaches zero, 
    │ │ │ -0007b370: 6974 2069 7320 7265 7365 7420 746f 2074  it is reset to t
    │ │ │ -0007b380: 6865 0a09 0909 2f2f 2075 6e63 686f 6b65  he....// unchoke
    │ │ │ -0007b390: 5f69 6e74 6572 7661 6c20 616e 6420 7468  _interval and th
    │ │ │ -0007b3a0: 6520 756e 6368 6f6b 6520 7365 7420 6973  e unchoke set is
    │ │ │ -0007b3b0: 0a09 0909 2f2f 2072 6563 6f6d 7075 7465  ....// recompute
    │ │ │ -0007b3c0: 642e 0a3c 6469 7620 7374 796c 653d 2262  d..
    ...int m_unchok │ │ │ -0007b400: 655f 7469 6d65 5f73 6361 6c65 7220 3d20 e_time_scaler = │ │ │ -0007b410: 303b 0a3c 2f64 6976 3e0a 0909 092f 2f20 0;.
    ....// │ │ │ -0007b420: 7468 6973 2069 7320 7573 6564 2074 6f20 this is used to │ │ │ -0007b430: 6465 6369 6465 2077 6865 6e20 746f 2072 decide when to r │ │ │ -0007b440: 6563 616c 6375 6c61 7465 2077 6869 6368 ecalculate which │ │ │ -0007b450: 0a09 0909 2f2f 2074 6f72 7265 6e74 7320 ....// torrents │ │ │ -0007b460: 746f 206b 6565 7020 7175 6575 6564 2061 to keep queued a │ │ │ -0007b470: 6e64 2077 6869 6368 2074 6f20 6163 7469 nd which to acti │ │ │ -0007b480: 7661 7465 0a3c 2f70 7265 3e3c 2f74 643e vate.
    │ │ │ -0007b490: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -0007b4c0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -0007b4d0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -0007b4e0: 7074 3a65 7870 616e 6428 3237 3729 223e pt:expand(277)"> │ │ │ -0007b4f0: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -0007b500: 7272 656e 742f 6175 785f 2f73 6573 7369 rrent/aux_/sessi │ │ │ -0007b510: 6f6e 5f69 6d70 6c2e 6870 703a 3130 3935 on_impl.hpp:1095 │ │ │ -0007b520: 3c2f 613e 3c2f 7464 3e3c 7464 3e72 6570 rep │ │ │ -0007b530: 6c61 6365 2074 6869 7320 6279 2061 2070 lace this by a p │ │ │ -0007b540: 726f 7065 7220 6173 696f 2074 696d 6572 roper asio timer │ │ │ -0007b550: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    re │ │ │ -0007b5a0: 706c 6163 6520 7468 6973 2062 7920 6120 place this by a │ │ │ -0007b5b0: 7072 6f70 6572 2061 7369 6f20 7469 6d65 proper asio time │ │ │ -0007b5c0: 723c 2f68 323e 3c68 343e 2e2e 2f69 6e63 r

    ../inc │ │ │ -0007b5d0: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -0007b5e0: 6175 785f 2f73 6573 7369 6f6e 5f69 6d70 aux_/session_imp │ │ │ -0007b5f0: 6c2e 6870 703a 3130 3935 3c2f 6834 3e3c l.hpp:1095

    < │ │ │ -0007b600: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -0007b610: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -0007b620: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -0007b630: 7820 2364 6464 3b22 3e0a 0909 092f 2f20 x #ddd;">....// │ │ │ -0007b640: 726f 756e 642d 726f 6269 6e20 696e 6465 round-robin inde │ │ │ -0007b650: 7820 696e 746f 206d 5f6f 7574 676f 696e x into m_outgoin │ │ │ -0007b660: 675f 696e 7465 7266 6163 6573 0a09 0909 g_interfaces.... │ │ │ -0007b670: 6d75 7461 626c 6520 7374 643a 3a75 696e mutable std::uin │ │ │ -0007b680: 7438 5f74 206d 5f69 6e74 6572 6661 6365 t8_t m_interface │ │ │ -0007b690: 5f69 6e64 6578 203d 2030 3b0a 0a09 0909 _index = 0;..... │ │ │ -0007b6a0: 7374 643a 3a73 6861 7265 645f 7074 7226 std::shared_ptr& │ │ │ -0007b6b0: 6c74 3b6c 6973 7465 6e5f 736f 636b 6574 lt;listen_socket │ │ │ -0007b6c0: 5f74 2667 743b 2073 6574 7570 5f6c 6973 _t> setup_lis │ │ │ -0007b6d0: 7465 6e65 7228 0a09 0909 096c 6973 7465 tener(.....liste │ │ │ -0007b6e0: 6e5f 656e 6470 6f69 6e74 5f74 2063 6f6e n_endpoint_t con │ │ │ -0007b6f0: 7374 2661 6d70 3b20 6c65 702c 2065 7272 st& lep, err │ │ │ -0007b700: 6f72 5f63 6f64 6526 616d 703b 2065 6329 or_code& ec) │ │ │ -0007b710: 3b0a 0a23 6966 6e64 6566 2054 4f52 5245 ;..#ifndef TORRE │ │ │ -0007b720: 4e54 5f44 4953 4142 4c45 5f44 4854 0a09 NT_DISABLE_DHT.. │ │ │ -0007b730: 0909 6468 743a 3a64 6874 5f73 7461 7465 ..dht::dht_state │ │ │ -0007b740: 206d 5f64 6874 5f73 7461 7465 3b0a 2365 m_dht_state;.#e │ │ │ -0007b750: 6e64 6966 0a0a 0909 092f 2f20 7468 6973 ndif.....// this │ │ │ -0007b760: 2069 7320 696e 6974 6961 6c69 7a65 6420 is initialized │ │ │ -0007b770: 746f 2074 6865 2075 6e63 686f 6b65 5f69 to the unchoke_i │ │ │ -0007b780: 6e74 6572 7661 6c0a 0909 092f 2f20 7365 nterval....// se │ │ │ -0007b790: 7373 696f 6e5f 7365 7474 696e 6720 616e ssion_setting an │ │ │ -0007b7a0: 6420 6465 6372 6561 7365 6420 6576 6572 d decreased ever │ │ │ -0007b7b0: 7920 7365 636f 6e64 2e0a 0909 092f 2f20 y second.....// │ │ │ -0007b7c0: 7768 656e 2069 7420 7265 6163 6865 7320 when it reaches │ │ │ -0007b7d0: 7a65 726f 2c20 6974 2069 7320 7265 7365 zero, it is rese │ │ │ -0007b7e0: 7420 746f 2074 6865 0a09 0909 2f2f 2075 t to the....// u │ │ │ -0007b7f0: 6e63 686f 6b65 5f69 6e74 6572 7661 6c20 nchoke_interval │ │ │ -0007b800: 616e 6420 7468 6520 756e 6368 6f6b 6520 and the unchoke │ │ │ -0007b810: 7365 7420 6973 0a09 0909 2f2f 2072 6563 set is....// rec │ │ │ -0007b820: 6f6d 7075 7465 642e 0a09 0909 696e 7420 omputed.....int │ │ │ -0007b830: 6d5f 756e 6368 6f6b 655f 7469 6d65 5f73 m_unchoke_time_s │ │ │ -0007b840: 6361 6c65 7220 3d20 303b 0a0a 0909 092f caler = 0;...../ │ │ │ -0007b850: 2f20 7468 6973 2069 7320 7573 6564 2074 / this is used t │ │ │ -0007b860: 6f20 6465 6369 6465 2077 6865 6e20 746f o decide when to │ │ │ -0007b870: 2072 6563 616c 6375 6c61 7465 2077 6869 recalculate whi │ │ │ -0007b880: 6368 0a09 0909 2f2f 2074 6f72 7265 6e74 ch....// torrent │ │ │ -0007b890: 7320 746f 206b 6565 7020 7175 6575 6564 s to keep queued │ │ │ -0007b8a0: 2061 6e64 2077 6869 6368 2074 6f20 6163 and which to ac │ │ │ -0007b8b0: 7469 7661 7465 0a3c 6469 7620 7374 796c tivate.
    ...int m_au │ │ │ -0007b8f0: 746f 5f6d 616e 6167 655f 7469 6d65 5f73 to_manage_time_s │ │ │ -0007b900: 6361 6c65 7220 3d20 303b 0a3c 2f64 6976 caler = 0;.
    ....// works li │ │ │ -0007b920: 6b65 2075 6e63 686f 6b65 5f74 696d 655f ke unchoke_time_ │ │ │ -0007b930: 7363 616c 6572 2062 7574 2069 740a 0909 scaler but it... │ │ │ -0007b940: 092f 2f20 6973 206f 6e6c 7920 6465 6372 .// is only decr │ │ │ -0007b950: 6561 7365 6420 7768 656e 2074 6865 2075 eased when the u │ │ │ -0007b960: 6e63 686f 6b65 2073 6574 0a09 0909 2f2f nchoke set....// │ │ │ -0007b970: 2069 7320 7265 636f 6d70 7574 6564 2c20 is recomputed, │ │ │ -0007b980: 616e 6420 7768 656e 2069 7420 7265 6163 and when it reac │ │ │ -0007b990: 6865 7320 7a65 726f 2c0a 0909 092f 2f20 hes zero,....// │ │ │ -0007b9a0: 7468 6520 6f70 7469 6d69 7374 6963 2075 the optimistic u │ │ │ -0007b9b0: 6e63 686f 6b65 2069 7320 6d6f 7665 6420 nchoke is moved │ │ │ -0007b9c0: 746f 2061 6e6f 7468 6572 2070 6565 722e to another peer. │ │ │ -0007b9d0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -0007ba10: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../i │ │ │ -0007ba40: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -0007ba50: 742f 6175 785f 2f73 6573 7369 6f6e 5f69 t/aux_/session_i │ │ │ -0007ba60: 6d70 6c2e 6870 703a 3131 3032 3c2f 613e mpl.hpp:1102 │ │ │ -0007ba70: 3c2f 7464 3e3c 7464 3e72 6570 6c61 6365 replace │ │ │ -0007ba80: 2074 6869 7320 6279 2061 2070 726f 7065 this by a prope │ │ │ -0007ba90: 7220 6173 696f 2074 696d 6572 3c2f 7464 r asio timer

    replac │ │ │ -0007baf0: 6520 7468 6973 2062 7920 6120 7072 6f70 e this by a prop │ │ │ -0007bb00: 6572 2061 7369 6f20 7469 6d65 723c 2f68 er asio timer

    ../include │ │ │ -0007bb20: 2f6c 6962 746f 7272 656e 742f 6175 785f /libtorrent/aux_ │ │ │ -0007bb30: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6870 /session_impl.hp │ │ │ -0007bb40: 703a 3131 3032 3c2f 6834 3e3c 7072 6520 p:1102

    .#ifndef TO
    │ │ │ -0007bb90: 5252 454e 545f 4449 5341 424c 455f 4448  RRENT_DISABLE_DH
    │ │ │ -0007bba0: 540a 0909 0964 6874 3a3a 6468 745f 7374  T....dht::dht_st
    │ │ │ -0007bbb0: 6174 6520 6d5f 6468 745f 7374 6174 653b  ate m_dht_state;
    │ │ │ -0007bbc0: 0a23 656e 6469 660a 0a09 0909 2f2f 2074  .#endif.....// t
    │ │ │ -0007bbd0: 6869 7320 6973 2069 6e69 7469 616c 697a  his is initializ
    │ │ │ -0007bbe0: 6564 2074 6f20 7468 6520 756e 6368 6f6b  ed to the unchok
    │ │ │ -0007bbf0: 655f 696e 7465 7276 616c 0a09 0909 2f2f  e_interval....//
    │ │ │ -0007bc00: 2073 6573 7369 6f6e 5f73 6574 7469 6e67   session_setting
    │ │ │ -0007bc10: 2061 6e64 2064 6563 7265 6173 6564 2065   and decreased e
    │ │ │ -0007bc20: 7665 7279 2073 6563 6f6e 642e 0a09 0909  very second.....
    │ │ │ -0007bc30: 2f2f 2077 6865 6e20 6974 2072 6561 6368  // when it reach
    │ │ │ -0007bc40: 6573 207a 6572 6f2c 2069 7420 6973 2072  es zero, it is r
    │ │ │ -0007bc50: 6573 6574 2074 6f20 7468 650a 0909 092f  eset to the..../
    │ │ │ -0007bc60: 2f20 756e 6368 6f6b 655f 696e 7465 7276  / unchoke_interv
    │ │ │ -0007bc70: 616c 2061 6e64 2074 6865 2075 6e63 686f  al and the uncho
    │ │ │ -0007bc80: 6b65 2073 6574 2069 730a 0909 092f 2f20  ke set is....// 
    │ │ │ -0007bc90: 7265 636f 6d70 7574 6564 2e0a 0909 0969  recomputed.....i
    │ │ │ -0007bca0: 6e74 206d 5f75 6e63 686f 6b65 5f74 696d  nt m_unchoke_tim
    │ │ │ -0007bcb0: 655f 7363 616c 6572 203d 2030 3b0a 0a09  e_scaler = 0;...
    │ │ │ -0007bcc0: 0909 2f2f 2074 6869 7320 6973 2075 7365  ..// this is use
    │ │ │ -0007bcd0: 6420 746f 2064 6563 6964 6520 7768 656e  d to decide when
    │ │ │ -0007bce0: 2074 6f20 7265 6361 6c63 756c 6174 6520   to recalculate 
    │ │ │ -0007bcf0: 7768 6963 680a 0909 092f 2f20 746f 7272  which....// torr
    │ │ │ -0007bd00: 656e 7473 2074 6f20 6b65 6570 2071 7565  ents to keep que
    │ │ │ -0007bd10: 7565 6420 616e 6420 7768 6963 6820 746f  ued and which to
    │ │ │ -0007bd20: 2061 6374 6976 6174 650a 0909 0969 6e74   activate....int
    │ │ │ -0007bd30: 206d 5f61 7574 6f5f 6d61 6e61 6765 5f74   m_auto_manage_t
    │ │ │ -0007bd40: 696d 655f 7363 616c 6572 203d 2030 3b0a  ime_scaler = 0;.
    │ │ │ -0007bd50: 0a09 0909 2f2f 2077 6f72 6b73 206c 696b  ....// works lik
    │ │ │ -0007bd60: 6520 756e 6368 6f6b 655f 7469 6d65 5f73  e unchoke_time_s
    │ │ │ -0007bd70: 6361 6c65 7220 6275 7420 6974 0a09 0909  caler but it....
    │ │ │ -0007bd80: 2f2f 2069 7320 6f6e 6c79 2064 6563 7265  // is only decre
    │ │ │ -0007bd90: 6173 6564 2077 6865 6e20 7468 6520 756e  ased when the un
    │ │ │ -0007bda0: 6368 6f6b 6520 7365 740a 0909 092f 2f20  choke set....// 
    │ │ │ -0007bdb0: 6973 2072 6563 6f6d 7075 7465 642c 2061  is recomputed, a
    │ │ │ -0007bdc0: 6e64 2077 6865 6e20 6974 2072 6561 6368  nd when it reach
    │ │ │ -0007bdd0: 6573 207a 6572 6f2c 0a09 0909 2f2f 2074  es zero,....// t
    │ │ │ -0007bde0: 6865 206f 7074 696d 6973 7469 6320 756e  he optimistic un
    │ │ │ -0007bdf0: 6368 6f6b 6520 6973 206d 6f76 6564 2074  choke is moved t
    │ │ │ -0007be00: 6f20 616e 6f74 6865 7220 7065 6572 2e0a  o another peer..
    │ │ │ -0007be10: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ -0007be40: 0969 6e74 206d 5f6f 7074 696d 6973 7469 .int m_optimisti │ │ │ -0007be50: 635f 756e 6368 6f6b 655f 7469 6d65 5f73 c_unchoke_time_s │ │ │ -0007be60: 6361 6c65 7220 3d20 303b 0a3c 2f64 6976 caler = 0;.
    ....// works li │ │ │ -0007be80: 6b65 2075 6e63 686f 6b65 5f74 696d 655f ke unchoke_time_ │ │ │ -0007be90: 7363 616c 6572 2e20 4561 6368 2074 696d scaler. Each tim │ │ │ -0007bea0: 650a 0909 092f 2f20 6974 2072 6561 6368 e....// it reach │ │ │ -0007beb0: 6573 2030 2c20 616e 6420 616c 6c20 7468 es 0, and all th │ │ │ -0007bec0: 6520 636f 6e6e 6563 7469 6f6e 7320 6172 e connections ar │ │ │ -0007bed0: 650a 0909 092f 2f20 7573 6564 2c20 7468 e....// used, th │ │ │ -0007bee0: 6520 776f 7273 7420 636f 6e6e 6563 7469 e worst connecti │ │ │ -0007bef0: 6f6e 2077 696c 6c20 6265 2064 6973 636f on will be disco │ │ │ -0007bf00: 6e6e 6563 7465 640a 0909 092f 2f20 6672 nnected....// fr │ │ │ -0007bf10: 6f6d 2074 6865 2074 6f72 7265 6e74 2077 om the torrent w │ │ │ -0007bf20: 6974 6820 7468 6520 6d6f 7374 2070 6565 ith the most pee │ │ │ -0007bf30: 7273 0a09 0909 696e 7420 6d5f 6469 7363 rs....int m_disc │ │ │ -0007bf40: 6f6e 6e65 6374 5f74 696d 655f 7363 616c onnect_time_scal │ │ │ -0007bf50: 6572 203d 2039 303b 0a0a 0909 092f 2f20 er = 90;.....// │ │ │ -0007bf60: 7768 656e 2074 6869 7320 7363 616c 6572 when this scaler │ │ │ -0007bf70: 2072 6561 6368 6573 207a 6572 6f2c 2069 reaches zero, i │ │ │ -0007bf80: 7420 7769 6c6c 0a09 0909 2f2f 2073 6372 t will....// scr │ │ │ -0007bf90: 6170 6520 6f6e 6520 6f66 2074 6865 2061 ape one of the a │ │ │ -0007bfa0: 7574 6f20 6d61 6e61 6765 642c 2070 6175 uto managed, pau │ │ │ -0007bfb0: 7365 642c 0a09 0909 2f2f 2074 6f72 7265 sed,....// torre │ │ │ -0007bfc0: 6e74 732e 0a09 0909 696e 7420 6d5f 6175 nts.....int m_au │ │ │ -0007bfd0: 746f 5f73 6372 6170 655f 7469 6d65 5f73 to_scrape_time_s │ │ │ -0007bfe0: 6361 6c65 7220 3d20 3138 303b 0a0a 0909 caler = 180;.... │ │ │ -0007bff0: 092f 2f20 7374 6174 6973 7469 6373 2067 .// statistics g │ │ │ -0007c000: 6174 6865 7265 6420 6672 6f6d 2061 6c6c athered from all │ │ │ -0007c010: 2074 6f72 7265 6e74 732e 0a09 0909 7374 torrents.....st │ │ │ -0007c020: 6174 206d 5f73 7461 743b 0a0a 0909 092f at m_stat;...../ │ │ │ -0007c030: 2f20 696d 706c 656d 656e 7473 2073 6573 / implements ses │ │ │ -0007c040: 7369 6f6e 5f69 6e74 6572 6661 6365 0a09 sion_interface.. │ │ │ -0007c050: 0909 766f 6964 2073 656e 745f 6279 7465 ..void sent_byte │ │ │ -0007c060: 7328 696e 7420 6279 7465 735f 7061 796c s(int bytes_payl │ │ │ -0007c070: 6f61 642c 2069 6e74 2062 7974 6573 5f70 oad, int bytes_p │ │ │ -0007c080: 726f 746f 636f 6c29 206f 7665 7272 6964 rotocol) overrid │ │ │ -0007c090: 653b 0a09 0909 766f 6964 2072 6563 6569 e;....void recei │ │ │ -0007c0a0: 7665 645f 6279 7465 7328 696e 7420 6279 ved_bytes(int by │ │ │ -0007c0b0: 7465 735f 7061 796c 6f61 642c 2069 6e74 tes_payload, int │ │ │ -0007c0c0: 2062 7974 6573 5f70 726f 746f 636f 6c29 bytes_protocol) │ │ │ -0007c0d0: 206f 7665 7272 6964 653b 0a09 0909 766f override;....vo │ │ │ -0007c0e0: 6964 2074 7261 6e63 6965 7665 5f69 705f id trancieve_ip_ │ │ │ -0007c0f0: 7061 636b 6574 2869 6e74 2062 7974 6573 packet(int bytes │ │ │ -0007c100: 2c20 626f 6f6c 2069 7076 3629 206f 7665 , bool ipv6) ove │ │ │ -0007c110: 7272 6964 653b 0a09 0909 766f 6964 2073 rride;....void s │ │ │ -0007c120: 656e 745f 7379 6e28 626f 6f6c 2069 7076 ent_syn(bool ipv │ │ │ -0007c130: 3629 206f 7665 7272 6964 653b 0a09 0909 6) override;.... │ │ │ -0007c140: 766f 6964 2072 6563 6569 7665 645f 7379 void received_sy │ │ │ -0007c150: 6e61 636b 2862 6f6f 6c20 6970 7636 2920 nack(bool ipv6) │ │ │ -0007c160: 6f76 6572 7269 6465 3b0a 0a23 6966 2054 override;..#if T │ │ │ -0007c170: 4f52 5245 4e54 5f41 4249 5f56 4552 5349 ORRENT_ABI_VERSI │ │ │ -0007c180: 4f4e 203d 3d20 310a 0909 0969 6e74 206d ON == 1....int m │ │ │ -0007c190: 5f70 6561 6b5f 7570 5f72 6174 6520 3d20 _peak_up_rate = │ │ │ -0007c1a0: 303b 0a23 656e 6469 660a 0a09 0909 766f 0;.#endif.....vo │ │ │ -0007c1b0: 6964 206f 6e5f 7469 636b 2865 7272 6f72 id on_tick(error │ │ │ -0007c1c0: 5f63 6f64 6520 636f 6e73 7426 616d 703b _code const& │ │ │ -0007c1d0: 2065 293b 0a0a 0909 0976 6f69 6420 7472 e);.....void tr │ │ │ -0007c1e0: 795f 636f 6e6e 6563 745f 6d6f 7265 5f70 y_connect_more_p │ │ │ -0007c1f0: 6565 7273 2829 3b0a 0909 0976 6f69 6420 eers();....void │ │ │ -0007c200: 6175 746f 5f6d 616e 6167 655f 6368 6563 auto_manage_chec │ │ │ -0007c210: 6b69 6e67 5f74 6f72 7265 6e74 7328 7374 king_torrents(st │ │ │ -0007c220: 643a 3a76 6563 746f 7226 6c74 3b74 6f72 d::vector<tor │ │ │ -0007c230: 7265 6e74 2a26 6774 3b26 616d 703b 206c rent*>& l │ │ │ -0007c240: 6973 740a 3c2f 7072 653e 3c2f 7464 3e3c ist.
    < │ │ │ -0007c250: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -0007c280: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -0007c2b0: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -0007c2c0: 7265 6e74 2f61 7578 5f2f 706f 6f6c 2e68 rent/aux_/pool.h │ │ │ -0007c2d0: 7070 3a35 333c 2f61 3e3c 2f74 643e 3c74 pp:53ensure the ali │ │ │ -0007c2f0: 676e 6d65 6e74 2069 7320 676f 6f64 2068 gnment is good h │ │ │ -0007c300: 6572 653c 2f74 643e 3c2f 7472 3e3c 7472 ere

    ensure the alig │ │ │ -0007c360: 6e6d 656e 7420 6973 2067 6f6f 6420 6865 nment is good he │ │ │ -0007c370: 7265 3c2f 6832 3e3c 6834 3e2e 2e2f 696e re

    ../in │ │ │ -0007c380: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -0007c390: 2f61 7578 5f2f 706f 6f6c 2e68 7070 3a35 /aux_/pool.hpp:5 │ │ │ -0007c3a0: 333c 2f68 343e 3c70 7265 2073 7479 6c65 3

    │ │ │ -0007c3e0: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ -0007c3f0: 504f 4f4c 5f48 5050 0a23 6465 6669 6e65  POOL_HPP.#define
    │ │ │ -0007c400: 2054 4f52 5245 4e54 5f50 4f4f 4c5f 4850   TORRENT_POOL_HP
    │ │ │ -0007c410: 500a 0a23 696e 636c 7564 6520 226c 6962  P..#include "lib
    │ │ │ -0007c420: 746f 7272 656e 742f 6173 7365 7274 2e68  torrent/assert.h
    │ │ │ -0007c430: 7070 220a 0a23 696e 636c 7564 6520 226c  pp"..#include "l
    │ │ │ -0007c440: 6962 746f 7272 656e 742f 6175 785f 2f64  ibtorrent/aux_/d
    │ │ │ -0007c450: 6973 6162 6c65 5f77 6172 6e69 6e67 735f  isable_warnings_
    │ │ │ -0007c460: 7075 7368 2e68 7070 220a 2369 6e63 6c75  push.hpp".#inclu
    │ │ │ -0007c470: 6465 2026 6c74 3b62 6f6f 7374 2f70 6f6f  de <boost/poo
    │ │ │ -0007c480: 6c2f 706f 6f6c 2e68 7070 2667 743b 0a23  l/pool.hpp>.#
    │ │ │ -0007c490: 696e 636c 7564 6520 226c 6962 746f 7272  include "libtorr
    │ │ │ -0007c4a0: 656e 742f 6175 785f 2f64 6973 6162 6c65  ent/aux_/disable
    │ │ │ -0007c4b0: 5f77 6172 6e69 6e67 735f 706f 702e 6870  _warnings_pop.hp
    │ │ │ -0007c4c0: 7022 0a0a 2369 6e63 6c75 6465 2026 6c74  p"..#include <
    │ │ │ -0007c4d0: 3b63 7374 6464 6566 2667 743b 0a23 696e  ;cstddef>.#in
    │ │ │ -0007c4e0: 636c 7564 6520 266c 743b 6e65 7726 6774  clude <new>
    │ │ │ -0007c4f0: 3b20 2f2f 2066 6f72 2070 6c61 6365 6d65  ; // for placeme
    │ │ │ -0007c500: 6e74 206e 6577 0a0a 6e61 6d65 7370 6163  nt new..namespac
    │ │ │ -0007c510: 6520 6c69 6274 6f72 7265 6e74 207b 0a6e  e libtorrent {.n
    │ │ │ -0007c520: 616d 6573 7061 6365 2061 7578 207b 0a0a  amespace aux {..
    │ │ │ -0007c530: 7374 7275 6374 2061 6c6c 6f63 6174 6f72  struct allocator
    │ │ │ -0007c540: 5f6e 6577 5f64 656c 6574 650a 7b0a 0975  _new_delete.{..u
    │ │ │ -0007c550: 7369 6e67 2073 697a 655f 7479 7065 203d  sing size_type =
    │ │ │ -0007c560: 2073 7464 3a3a 7369 7a65 5f74 3b0a 0975   std::size_t;..u
    │ │ │ -0007c570: 7369 6e67 2064 6966 6665 7265 6e63 655f  sing difference_
    │ │ │ -0007c580: 7479 7065 203d 2073 7464 3a3a 7074 7264  type = std::ptrd
    │ │ │ -0007c590: 6966 665f 743b 0a0a 3c64 6976 2073 7479  iff_t;..
    .static ch │ │ │ -0007c5d0: 6172 2a20 6d61 6c6c 6f63 2873 697a 655f ar* malloc(size_ │ │ │ -0007c5e0: 7479 7065 2063 6f6e 7374 2062 7974 6573 type const bytes │ │ │ -0007c5f0: 290a 3c2f 6469 763e 097b 2072 6574 7572 ).
    .{ retur │ │ │ -0007c600: 6e20 6e65 7720 6368 6172 5b62 7974 6573 n new char[bytes │ │ │ -0007c610: 5d3b 207d 0a09 7374 6174 6963 2076 6f69 ]; }..static voi │ │ │ -0007c620: 6420 6672 6565 2863 6861 722a 2063 6f6e d free(char* con │ │ │ -0007c630: 7374 2062 6c6f 636b 290a 097b 2064 656c st block)..{ del │ │ │ -0007c640: 6574 6520 5b5d 2062 6c6f 636b 3b20 7d0a ete [] block; }. │ │ │ -0007c650: 7d3b 0a0a 7573 696e 6720 706f 6f6c 203d };..using pool = │ │ │ -0007c660: 2062 6f6f 7374 3a3a 706f 6f6c 266c 743b boost::pool< │ │ │ -0007c670: 616c 6c6f 6361 746f 725f 6e65 775f 6465 allocator_new_de │ │ │ -0007c680: 6c65 7465 2667 743b 3b0a 0a2f 2f20 4c69 lete>;..// Li │ │ │ -0007c690: 6b65 2062 6f6f 7374 3a3a 6f62 6a65 6374 ke boost::object │ │ │ -0007c6a0: 5f70 6f6f 6c20 6275 7420 7573 6573 2075 _pool but uses u │ │ │ -0007c6b0: 6e6f 7264 6572 6564 2066 7265 6528 2920 nordered free() │ │ │ -0007c6c0: 7261 7468 6572 2074 6861 6e20 7468 650a rather than the. │ │ │ -0007c6d0: 2f2f 204f 284e 2920 6f72 6465 7265 645f // O(N) ordered_ │ │ │ -0007c6e0: 6672 6565 2829 2074 6861 7420 626f 6f73 free() that boos │ │ │ -0007c6f0: 743a 3a6f 626a 6563 745f 706f 6f6c 3a3a t::object_pool:: │ │ │ -0007c700: 6465 7374 726f 7928 2920 7265 6c69 6573 destroy() relies │ │ │ -0007c710: 206f 6e2e 0a2f 2f20 5468 6520 706f 6f6c on..// The pool │ │ │ -0007c720: 2069 7473 656c 6620 646f 6573 206e 6f74 itself does not │ │ │ -0007c730: 2074 7261 636b 206f 7574 7374 616e 6469 track outstandi │ │ │ -0007c740: 6e67 2061 6c6c 6f63 6174 696f 6e73 2c20 ng allocations, │ │ │ -0007c750: 736f 2063 616c 6c65 7273 0a2f 2f20 6d75 so callers.// mu │ │ │ -0007c760: 7374 2064 6573 7472 6f79 2829 2065 7665 st destroy() eve │ │ │ -0007c770: 7279 206f 626a 6563 7420 6265 666f 7265 ry object before │ │ │ -0007c780: 2074 6865 2070 6f6f 6c20 6973 2064 6573 the pool is des │ │ │ -0007c790: 7472 6f79 6564 2e0a 7465 6d70 6c61 7465 troyed..template │ │ │ -0007c7a0: 2026 6c74 3b74 7970 656e 616d 6520 5426 <typename T& │ │ │ -0007c7b0: 6774 3b0a 7374 7275 6374 206f 626a 6563 gt;.struct objec │ │ │ -0007c7c0: 745f 706f 6f6c 0a7b 0a09 6f62 6a65 6374 t_pool.{..object │ │ │ -0007c7d0: 5f70 6f6f 6c28 2920 3a20 6d5f 706f 6f6c _pool() : m_pool │ │ │ -0007c7e0: 2873 697a 656f 6628 5429 2920 7b7d 0a09 (sizeof(T)) {}.. │ │ │ -0007c7f0: 6f62 6a65 6374 5f70 6f6f 6c28 6f62 6a65 object_pool(obje │ │ │ -0007c800: 6374 5f70 6f6f 6c20 636f 6e73 7426 616d ct_pool const&am │ │ │ -0007c810: 703b 2920 3d20 6465 6c65 7465 3b0a 096f p;) = delete;..o │ │ │ -0007c820: 626a 6563 745f 706f 6f6c 2661 6d70 3b20 bject_pool& │ │ │ -0007c830: 6f70 6572 6174 6f72 3d28 6f62 6a65 6374 operator=(object │ │ │ -0007c840: 5f70 6f6f 6c20 636f 6e73 7426 616d 703b _pool const& │ │ │ -0007c850: 2920 3d20 6465 6c65 7465 3b0a 0a09 542a ) = delete;...T* │ │ │ -0007c860: 2063 6f6e 7374 7275 6374 2829 0a09 7b0a construct()..{. │ │ │ -0007c870: 0909 766f 6964 2a20 636f 6e73 7420 7374 ..void* const st │ │ │ -0007c880: 6f72 6167 6520 3d20 6d5f 706f 6f6c 2e6d orage = m_pool.m │ │ │ -0007c890: 616c 6c6f 6328 293b 0a09 0974 7279 0a09 alloc();...try.. │ │ │ -0007c8a0: 097b 0a09 0909 7265 7475 726e 206e 6577 .{....return new │ │ │ -0007c8b0: 2028 7374 6f72 6167 6529 2054 2829 3b0a (storage) T();. │ │ │ -0007c8c0: 0909 7d0a 0909 6361 7463 6820 282e 2e2e ..}...catch (... │ │ │ -0007c8d0: 290a 0909 7b0a 0909 096d 5f70 6f6f 6c2e )...{....m_pool. │ │ │ -0007c8e0: 6672 6565 2873 746f 7261 6765 293b 0a09 free(storage);.. │ │ │ -0007c8f0: 0909 7468 726f 773b 0a09 097d 0a3c 2f70 ..throw;...}.

    re │ │ │ -0007c930: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../inclu │ │ │ -0007c970: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ -0007c980: 785f 2f6d 6572 6b6c 655f 7472 6565 2e68 x_/merkle_tree.h │ │ │ -0007c990: 7070 3a38 353c 2f61 3e3c 2f74 643e 3c74 pp:85remove this co │ │ │ -0007c9b0: 6e73 7472 7563 746f 722e 2044 6f6e 2774 nstructor. Don't │ │ │ -0007c9c0: 2073 7570 706f 7274 2022 756e 696e 6974 support "uninit │ │ │ -0007c9d0: 6961 6c69 7a65 6422 2074 7265 6573 2e20 ialized" trees. │ │ │ -0007c9e0: 5468 6973 2061 6c73 6f20 7265 7175 6972 This also requir │ │ │ -0007c9f0: 6573 206e 6f74 2063 6f6e 7374 7275 6374 es not construct │ │ │ -0007ca00: 696e 6720 7468 6573 6520 666f 7220 7061 ing these for pa │ │ │ -0007ca10: 642d 6669 6c65 7320 616e 6420 736d 616c d-files and smal │ │ │ -0007ca20: 6c20 6669 6c65 7320 6173 2077 656c 6c2e l files as well. │ │ │ -0007ca30: 2053 6f2c 2061 2073 7061 7273 6520 6861 So, a sparse ha │ │ │ -0007ca40: 7368 206c 6973 7420 696e 2074 6f72 7265 sh list in torre │ │ │ -0007ca50: 6e74 5f69 6e66 6f3c 2f74 643e 3c2f 7472 nt_info

    remove this │ │ │ -0007cab0: 2063 6f6e 7374 7275 6374 6f72 2e20 446f constructor. Do │ │ │ -0007cac0: 6e27 7420 7375 7070 6f72 7420 2275 6e69 n't support "uni │ │ │ -0007cad0: 6e69 7469 616c 697a 6564 2220 7472 6565 nitialized" tree │ │ │ -0007cae0: 732e 2054 6869 730a 616c 736f 2072 6571 s. This.also req │ │ │ -0007caf0: 7569 7265 7320 6e6f 7420 636f 6e73 7472 uires not constr │ │ │ -0007cb00: 7563 7469 6e67 2074 6865 7365 2066 6f72 ucting these for │ │ │ -0007cb10: 2070 6164 2d66 696c 6573 2061 6e64 2073 pad-files and s │ │ │ -0007cb20: 6d61 6c6c 2066 696c 6573 2061 730a 7765 mall files as.we │ │ │ -0007cb30: 6c6c 2e20 536f 2c20 6120 7370 6172 7365 ll. So, a sparse │ │ │ -0007cb40: 2068 6173 6820 6c69 7374 2069 6e20 746f hash list in to │ │ │ -0007cb50: 7272 656e 745f 696e 666f 3c2f 6832 3e3c rrent_info

    < │ │ │ -0007cb60: 6834 3e2e 2e2f 696e 636c 7564 652f 6c69 h4>../include/li │ │ │ -0007cb70: 6274 6f72 7265 6e74 2f61 7578 5f2f 6d65 btorrent/aux_/me │ │ │ -0007cb80: 726b 6c65 5f74 7265 652e 6870 703a 3835 rkle_tree.hpp:85 │ │ │ -0007cb90: 3c2f 6834 3e3c 7072 6520 7374 796c 653d
    /
    │ │ │ -0007cbd0: 2f20 5468 6520 696e 7661 7269 616e 7420  / The invariant 
    │ │ │ -0007cbe0: 6f66 2074 6865 2074 7265 6520 6973 2074  of the tree is t
    │ │ │ -0007cbf0: 6861 7420 616c 6c20 696e 7465 7269 6f72  hat all interior
    │ │ │ -0007cc00: 206e 6f64 6573 2028 692e 652e 2061 6c6c   nodes (i.e. all
    │ │ │ -0007cc10: 2062 7574 2074 6865 2076 6572 790a 2f2f   but the very.//
    │ │ │ -0007cc20: 2062 6f74 746f 6d20 6c65 6166 206e 6f64   bottom leaf nod
    │ │ │ -0007cc30: 6573 2c20 7265 7072 6573 656e 7469 6e67  es, representing
    │ │ │ -0007cc40: 2062 6c6f 636b 2068 6173 6865 7329 2061   block hashes) a
    │ │ │ -0007cc50: 7265 2065 6974 6865 7220 7365 7420 616e  re either set an
    │ │ │ -0007cc60: 6420 7661 6c69 642c 206f 720a 2f2f 2063  d valid, or.// c
    │ │ │ -0007cc70: 6c65 6172 2e20 4e6f 2069 6e76 616c 6964  lear. No invalid
    │ │ │ -0007cc80: 2068 6173 6865 7320 6172 6520 616c 6c6f   hashes are allo
    │ │ │ -0007cc90: 7765 642c 2061 6e64 2074 6865 7920 6361  wed, and they ca
    │ │ │ -0007cca0: 6e20 6f6e 6c79 2062 6520 6164 6465 6420  n only be added 
    │ │ │ -0007ccb0: 6279 2061 6c73 6f0a 2f2f 2070 726f 7669  by also.// provi
    │ │ │ -0007ccc0: 6469 6e67 2070 726f 6f66 206f 6620 6265  ding proof of be
    │ │ │ -0007ccd0: 696e 6720 7661 6c69 642e 0a0a 2f2f 2054  ing valid...// T
    │ │ │ -0007cce0: 6865 206c 6561 6620 626c 6f63 6b73 206f  he leaf blocks o
    │ │ │ -0007ccf0: 6e20 7468 6520 6f74 6865 7220 6861 6e64  n the other hand
    │ │ │ -0007cd00: 2c20 4d41 5920 6265 2069 6e76 616c 6964  , MAY be invalid
    │ │ │ -0007cd10: 2e20 466f 7220 696e 7374 616e 6365 2c20  . For instance, 
    │ │ │ -0007cd20: 7768 656e 2061 6464 696e 670a 2f2f 2061  when adding.// a
    │ │ │ -0007cd30: 206d 6167 6e65 7420 6c69 6e6b 2066 6f72   magnet link for
    │ │ │ -0007cd40: 2061 2074 6f72 7265 6e74 2074 6861 7420   a torrent that 
    │ │ │ -0007cd50: 7765 2061 6c72 6561 6479 2068 6176 6520  we already have 
    │ │ │ -0007cd60: 6669 6c65 7320 666f 722e 204f 6e63 6520  files for. Once 
    │ │ │ -0007cd70: 7765 2068 6176 6520 7468 650a 2f2f 206d  we have the.// m
    │ │ │ -0007cd80: 6574 6164 6174 612c 2077 6520 6861 7665  etadata, we have
    │ │ │ -0007cd90: 2066 696c 6573 206f 6e20 6469 736b 2062   files on disk b
    │ │ │ -0007cda0: 7574 206e 6f20 6861 7368 6573 2e20 5765  ut no hashes. We
    │ │ │ -0007cdb0: 2077 6f6e 2774 206b 6e6f 7720 7768 6574   won't know whet
    │ │ │ -0007cdc0: 6865 7220 7468 6520 6461 7461 0a2f 2f20  her the data.// 
    │ │ │ -0007cdd0: 6f6e 2064 6973 6b20 6973 2076 616c 6964  on disk is valid
    │ │ │ -0007cde0: 206f 7220 6e6f 742c 2075 6e74 696c 2077   or not, until w
    │ │ │ -0007cdf0: 6527 7665 2064 6f77 6e6c 6f61 6465 6420  e've downloaded 
    │ │ │ -0007ce00: 7468 6520 6861 7368 6573 2074 6f20 7661  the hashes to va
    │ │ │ -0007ce10: 6c69 6461 7465 2074 6865 6d2e 0a0a 2f2f  lidate them...//
    │ │ │ -0007ce20: 2049 6465 6120 666f 7220 6675 7475 7265   Idea for future
    │ │ │ -0007ce30: 2073 7061 6365 206f 7074 696d 697a 6174   space optimizat
    │ │ │ -0007ce40: 696f 6e3a 0a2f 2f20 7768 696c 6520 646f  ion:.// while do
    │ │ │ -0007ce50: 776e 6c6f 6164 696e 672c 2077 6520 6e65  wnloading, we ne
    │ │ │ -0007ce60: 6564 2074 6f20 7374 6f72 6520 696e 7465  ed to store inte
    │ │ │ -0007ce70: 7269 6f72 206e 6f64 6573 206f 6620 7468  rior nodes of th
    │ │ │ -0007ce80: 6973 2074 7265 652e 2048 6f77 6576 6572  is tree. However
    │ │ │ -0007ce90: 2c20 7765 0a2f 2f20 646f 6e27 7420 6e65  , we.// don't ne
    │ │ │ -0007cea0: 6564 2074 6f20 7374 6f72 6520 7468 6520  ed to store the 
    │ │ │ -0007ceb0: 7061 6464 696e 672e 2061 2053 4841 2d32  padding. a SHA-2
    │ │ │ -0007cec0: 3536 2069 7320 3332 2062 7974 6573 2e20  56 is 32 bytes. 
    │ │ │ -0007ced0: 496e 7374 6561 6420 6f66 2073 746f 7269  Instead of stori
    │ │ │ -0007cee0: 6e67 0a2f 2f20 7468 6520 6675 6c6c 2028  ng.// the full (
    │ │ │ -0007cef0: 7061 6464 6564 2920 7472 6565 206f 6620  padded) tree of 
    │ │ │ -0007cf00: 5348 412d 3235 3620 6861 7368 6573 2c20  SHA-256 hashes, 
    │ │ │ -0007cf10: 7374 6f72 6520 7468 6520 6675 6c6c 2074  store the full t
    │ │ │ -0007cf20: 7265 6520 6f66 2033 3220 6269 740a 2f2f  ree of 32 bit.//
    │ │ │ -0007cf30: 2073 6967 6e65 6420 696e 7465 6765 7273   signed integers
    │ │ │ -0007cf40: 2c20 6265 696e 6720 696e 6469 6365 7320  , being indices 
    │ │ │ -0007cf50: 696e 746f 2074 6865 2061 6374 7561 6c20  into the actual 
    │ │ │ -0007cf60: 7374 6f72 6167 6520 666f 7220 7468 6520  storage for the 
    │ │ │ -0007cf70: 7472 6565 2e20 5765 2063 6f75 6c64 0a2f  tree. We could./
    │ │ │ -0007cf80: 2f20 6576 656e 2067 726f 7720 7468 6520  / even grow the 
    │ │ │ -0007cf90: 7374 6f72 6167 6520 6c61 7a69 6c79 2e20  storage lazily. 
    │ │ │ -0007cfa0: 496e 7374 6561 6420 6f66 2073 746f 7269  Instead of stori
    │ │ │ -0007cfb0: 6e67 2074 6865 2070 6164 6469 6e67 2068  ng the padding h
    │ │ │ -0007cfc0: 6173 6865 732c 2075 7365 0a2f 2f20 6e65  ashes, use.// ne
    │ │ │ -0007cfd0: 6761 7469 7665 2069 6e64 6963 6573 2074  gative indices t
    │ │ │ -0007cfe0: 6f20 7265 6665 7220 746f 2066 6978 6564  o refer to fixed
    │ │ │ -0007cff0: 2053 4841 2d32 3536 2830 292c 2061 6e64   SHA-256(0), and
    │ │ │ -0007d000: 2053 4841 2d32 3536 2853 4841 2d32 3536   SHA-256(SHA-256
    │ │ │ -0007d010: 2830 2929 2061 6e64 2073 6f0a 2f2f 206f  (0)) and so.// o
    │ │ │ -0007d020: 6e0a 7374 7275 6374 2054 4f52 5245 4e54  n.struct TORRENT
    │ │ │ -0007d030: 5f45 5854 5241 5f45 5850 4f52 5420 6d65  _EXTRA_EXPORT me
    │ │ │ -0007d040: 726b 6c65 5f74 7265 650a 7b0a 3c64 6976  rkle_tree.{.
    .merkl │ │ │ -0007d080: 655f 7472 6565 2829 203d 2064 6566 6175 e_tree() = defau │ │ │ -0007d090: 6c74 3b0a 3c2f 6469 763e 096d 6572 6b6c lt;.
    .merkl │ │ │ -0007d0a0: 655f 7472 6565 2869 6e74 206e 756d 5f62 e_tree(int num_b │ │ │ -0007d0b0: 6c6f 636b 732c 2069 6e74 2062 6c6f 636b locks, int block │ │ │ -0007d0c0: 735f 7065 725f 7069 6563 652c 2063 6861 s_per_piece, cha │ │ │ -0007d0d0: 7220 636f 6e73 742a 2072 293b 0a0a 0973 r const* r);...s │ │ │ -0007d0e0: 6861 3235 365f 6861 7368 2072 6f6f 7428 ha256_hash root( │ │ │ -0007d0f0: 2920 636f 6e73 743b 0a0a 0976 6f69 6420 ) const;...void │ │ │ -0007d100: 6c6f 6164 5f74 7265 6528 7370 616e 266c load_tree(span&l │ │ │ -0007d110: 743b 7368 6132 3536 5f68 6173 6820 636f t;sha256_hash co │ │ │ -0007d120: 6e73 7426 6774 3b20 742c 2073 7464 3a3a nst> t, std:: │ │ │ -0007d130: 7665 6374 6f72 266c 743b 626f 6f6c 2667 vector<bool&g │ │ │ -0007d140: 743b 2063 6f6e 7374 2661 6d70 3b20 7665 t; const& ve │ │ │ -0007d150: 7269 6669 6564 293b 0a09 766f 6964 206c rified);..void l │ │ │ -0007d160: 6f61 645f 7370 6172 7365 5f74 7265 6528 oad_sparse_tree( │ │ │ -0007d170: 7370 616e 266c 743b 7368 6132 3536 5f68 span<sha256_h │ │ │ -0007d180: 6173 6820 636f 6e73 7426 6774 3b20 742c ash const> t, │ │ │ -0007d190: 2073 7464 3a3a 7665 6374 6f72 266c 743b std::vector< │ │ │ -0007d1a0: 626f 6f6c 2667 743b 2063 6f6e 7374 2661 bool> const&a │ │ │ -0007d1b0: 6d70 3b20 6d61 736b 0a09 092c 2073 7464 mp; mask..., std │ │ │ -0007d1c0: 3a3a 7665 6374 6f72 266c 743b 626f 6f6c ::vector<bool │ │ │ -0007d1d0: 2667 743b 2063 6f6e 7374 2661 6d70 3b20 > const& │ │ │ -0007d1e0: 7665 7269 6669 6564 293b 0a09 766f 6964 verified);..void │ │ │ -0007d1f0: 206c 6f61 645f 7665 7269 6669 6564 5f62 load_verified_b │ │ │ -0007d200: 6974 7328 7374 643a 3a76 6563 746f 7226 its(std::vector& │ │ │ -0007d210: 6c74 3b62 6f6f 6c26 6774 3b20 636f 6e73 lt;bool> cons │ │ │ -0007d220: 7426 616d 703b 2076 6572 6966 6965 6429 t& verified) │ │ │ -0007d230: 3b0a 0a09 7374 643a 3a73 697a 655f 7420 ;...std::size_t │ │ │ -0007d240: 7369 7a65 2829 2063 6f6e 7374 3b0a 0969 size() const;..i │ │ │ -0007d250: 6e74 2065 6e64 5f69 6e64 6578 2829 2063 nt end_index() c │ │ │ -0007d260: 6f6e 7374 207b 2072 6574 7572 6e20 696e onst { return in │ │ │ -0007d270: 7428 7369 7a65 2829 293b 207d 0a0a 0962 t(size()); }...b │ │ │ -0007d280: 6f6f 6c20 6861 735f 6e6f 6465 2869 6e74 ool has_node(int │ │ │ -0007d290: 2069 6478 2920 636f 6e73 743b 0a0a 0962 idx) const;...b │ │ │ -0007d2a0: 6f6f 6c20 636f 6d70 6172 655f 6e6f 6465 ool compare_node │ │ │ -0007d2b0: 2869 6e74 2069 6478 2c20 7368 6132 3536 (int idx, sha256 │ │ │ -0007d2c0: 5f68 6173 6820 636f 6e73 7426 616d 703b _hash const& │ │ │ -0007d2d0: 2068 2920 636f 6e73 743b 0a0a 0973 6861 h) const;...sha │ │ │ -0007d2e0: 3235 365f 6861 7368 206f 7065 7261 746f 256_hash operato │ │ │ -0007d2f0: 725b 5d28 696e 7420 6964 7829 2063 6f6e r[](int idx) con │ │ │ -0007d300: 7374 3b0a 0a09 7374 643a 3a76 6563 746f st;...std::vecto │ │ │ -0007d310: 7226 6c74 3b73 6861 3235 365f 6861 7368 r<sha256_hash │ │ │ -0007d320: 2667 743b 2062 7569 6c64 5f76 6563 746f > build_vecto │ │ │ -0007d330: 7228 2920 636f 6e73 743b 0a09 7374 643a r() const;..std: │ │ │ -0007d340: 3a70 6169 7226 6c74 3b73 7464 3a3a 7665 :pair<std::ve │ │ │ -0007d350: 6374 6f72 266c 743b 7368 6132 3536 5f68 ctor<sha256_h │ │ │ -0007d360: 6173 6826 6774 3b2c 2061 7578 3a3a 7665 ash>, aux::ve │ │ │ -0007d370: 6374 6f72 266c 743b 626f 6f6c 2667 743b ctor<bool> │ │ │ -0007d380: 2667 743b 2062 7569 6c64 5f73 7061 7273 > build_spars │ │ │ -0007d390: 655f 7665 6374 6f72 2829 2063 6f6e 7374 e_vector() const │ │ │ -0007d3a0: 3b0a 0a09 2f2f 2067 6574 2062 6974 7320 ;...// get bits │ │ │ -0007d3b0: 696e 6469 6361 7469 6e67 2069 6620 6561 indicating if ea │ │ │ -0007d3c0: 6368 206c 6561 6620 6861 7368 2069 7320 ch leaf hash is │ │ │ -0007d3d0: 7665 7269 6669 6564 0a09 7374 643a 3a76 verified..std::v │ │ │ -0007d3e0: 6563 746f 7226 6c74 3b62 6f6f 6c26 6774 ector<bool> │ │ │ -0007d3f0: 3b20 7665 7269 6669 6564 5f6c 6561 6673 ; verified_leafs │ │ │ -0007d400: 2829 2063 6f6e 7374 3b0a 0a09 2f2f 2072 () const;...// r │ │ │ -0007d410: 6574 7572 6e73 2074 7275 6520 6966 2074 eturns true if t │ │ │ -0007d420: 6865 2065 6e74 6972 6520 7472 6565 2069 he entire tree i │ │ │ -0007d430: 7320 6b6e 6f77 6e20 616e 6420 7665 7269 s known and veri │ │ │ -0007d440: 6669 6564 0a09 626f 6f6c 2069 735f 636f fied..bool is_co │ │ │ -0007d450: 6d70 6c65 7465 2829 2063 6f6e 7374 3b0a mplete() const;. │ │ │ -0007d460: 0a09 2f2f 2072 6574 7572 6e73 2074 7275 ..// returns tru │ │ │ -0007d470: 6520 6966 2061 6c6c 2062 6c6f 636b 2068 e if all block h │ │ │ -0007d480: 6173 6865 7320 696e 2074 6865 2073 7065 ashes in the spe │ │ │ -0007d490: 6369 6669 6564 2072 616e 6765 2068 6176 cified range hav │ │ │ -0007d4a0: 6520 6265 656e 2076 6572 6966 6965 640a e been verified. │ │ │ -0007d4b0: 0962 6f6f 6c20 626c 6f63 6b73 5f76 6572 .bool blocks_ver │ │ │ -0007d4c0: 6966 6965 6428 696e 7420 626c 6f63 6b5f ified(int block_ │ │ │ -0007d4d0: 6964 782c 2069 6e74 206e 756d 5f62 6c6f idx, int num_blo │ │ │ -0007d4e0: 636b 7329 2063 6f6e 7374 3b0a 0a3c 2f70 cks) const;..

    re │ │ │ -0007d520: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../inclu │ │ │ -0007d560: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ -0007d570: 785f 2f6d 6572 6b6c 655f 7472 6565 2e68 x_/merkle_tree.h │ │ │ -0007d580: 7070 3a31 3735 3c2f 613e 3c2f 7464 3e3c pp:175< │ │ │ -0007d590: 7464 3e6d 616b 6520 7468 6973 2061 2073 td>make this a s │ │ │ -0007d5a0: 7464 3a3a 756e 6971 7565 5f70 7472 3c73 td::unique_ptr

    make │ │ │ -0007d610: 7468 6973 2061 2073 7464 3a3a 756e 6971 this a std::uniq │ │ │ -0007d620: 7565 5f70 7472 3c73 6861 3235 365f 6861 ue_ptr

    .. │ │ │ -0007d640: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -0007d650: 656e 742f 6175 785f 2f6d 6572 6b6c 655f ent/aux_/merkle_ │ │ │ -0007d660: 7472 6565 2e68 7070 3a31 3735 3c2f 6834 tree.hpp:175

    ..int
    │ │ │ -0007d6b0: 2062 6c6f 636b 735f 7065 725f 7069 6563   blocks_per_piec
    │ │ │ -0007d6c0: 6528 2920 636f 6e73 7420 7b20 7265 7475  e() const { retu
    │ │ │ -0007d6d0: 726e 2031 2026 6c74 3b26 6c74 3b20 6d5f  rn 1 << m_
    │ │ │ -0007d6e0: 626c 6f63 6b73 5f70 6572 5f70 6965 6365  blocks_per_piece
    │ │ │ -0007d6f0: 5f6c 6f67 3b20 7d0a 092f 2f20 7468 6520  _log; }..// the 
    │ │ │ -0007d700: 6e75 6d62 6572 2074 7265 6520 6c65 7665  number tree leve
    │ │ │ -0007d710: 6c73 2070 6572 2070 6965 6365 2e20 5468  ls per piece. Th
    │ │ │ -0007d720: 6973 2069 7320 3020 6966 2074 6865 2062  is is 0 if the b
    │ │ │ -0007d730: 6c6f 636b 206c 6179 6572 2069 7320 616c  lock layer is al
    │ │ │ -0007d740: 736f 0a09 2f2f 2074 6865 2070 6965 6365  so..// the piece
    │ │ │ -0007d750: 206c 6179 6572 2e0a 0969 6e74 2070 6965   layer...int pie
    │ │ │ -0007d760: 6365 5f6c 6576 656c 7328 2920 636f 6e73  ce_levels() cons
    │ │ │ -0007d770: 7420 7b20 7265 7475 726e 206d 5f62 6c6f  t { return m_blo
    │ │ │ -0007d780: 636b 735f 7065 725f 7069 6563 655f 6c6f  cks_per_piece_lo
    │ │ │ -0007d790: 673b 207d 0a0a 0969 6e74 2062 6c6f 636b  g; }...int block
    │ │ │ -0007d7a0: 5f6c 6179 6572 5f73 7461 7274 2829 2063  _layer_start() c
    │ │ │ -0007d7b0: 6f6e 7374 3b0a 0969 6e74 2070 6965 6365  onst;..int piece
    │ │ │ -0007d7c0: 5f6c 6179 6572 5f73 7461 7274 2829 2063  _layer_start() c
    │ │ │ -0007d7d0: 6f6e 7374 3b0a 0969 6e74 206e 756d 5f70  onst;..int num_p
    │ │ │ -0007d7e0: 6965 6365 7328 2920 636f 6e73 743b 0a09  ieces() const;..
    │ │ │ -0007d7f0: 696e 7420 6e75 6d5f 6c65 6166 7328 2920  int num_leafs() 
    │ │ │ -0007d800: 636f 6e73 743b 0a0a 0976 6f69 6420 6f70  const;...void op
    │ │ │ -0007d810: 7469 6d69 7a65 5f73 746f 7261 6765 2829  timize_storage()
    │ │ │ -0007d820: 3b0a 0976 6f69 6420 6f70 7469 6d69 7a65  ;..void optimize
    │ │ │ -0007d830: 5f73 746f 7261 6765 5f70 6965 6365 5f6c  _storage_piece_l
    │ │ │ -0007d840: 6179 6572 2829 3b0a 0976 6f69 6420 616c  ayer();..void al
    │ │ │ -0007d850: 6c6f 6361 7465 5f66 756c 6c28 293b 0a0a  locate_full();..
    │ │ │ -0007d860: 092f 2f20 6120 706f 696e 7465 7220 746f  .// a pointer to
    │ │ │ -0007d870: 2074 6865 2072 6f6f 7420 6861 7368 2066   the root hash f
    │ │ │ -0007d880: 6f72 2074 6869 7320 6669 6c65 2e0a 0963  or this file...c
    │ │ │ -0007d890: 6861 7220 636f 6e73 742a 206d 5f72 6f6f  har const* m_roo
    │ │ │ -0007d8a0: 7420 3d20 6e75 6c6c 7074 723b 0a0a 092f  t = nullptr;.../
    │ │ │ -0007d8b0: 2f20 7468 6973 2069 7320 6569 7468 6572  / this is either
    │ │ │ -0007d8c0: 2074 6865 2066 756c 6c20 7472 6565 2c20   the full tree, 
    │ │ │ -0007d8d0: 6f72 2073 6f6d 6520 7370 6172 7365 2072  or some sparse r
    │ │ │ -0007d8e0: 6570 7265 7365 6e74 6174 696f 6e20 6f66  epresentation of
    │ │ │ -0007d8f0: 2069 742c 0a09 2f2f 2064 6570 656e 6469   it,..// dependi
    │ │ │ -0007d900: 6e67 206f 6e20 6d5f 6d6f 6465 0a3c 6469  ng on m_mode..aux:
    │ │ │ -0007d940: 3a76 6563 746f 7226 6c74 3b73 6861 3235  :vector<sha25
    │ │ │ -0007d950: 365f 6861 7368 2667 743b 206d 5f74 7265  6_hash> m_tre
    │ │ │ -0007d960: 653b 0a3c 2f64 6976 3e0a 092f 2f20 7768  e;...// wh
    │ │ │ -0007d970: 656e 2074 6865 2066 756c 6c20 7472 6565  en the full tree
    │ │ │ -0007d980: 2069 7320 616c 6c6f 6361 7465 642c 2074   is allocated, t
    │ │ │ -0007d990: 6869 7320 6861 7320 6f6e 6520 6269 7420  his has one bit 
    │ │ │ -0007d9a0: 666f 7220 6561 6368 2062 6c6f 636b 2068  for each block h
    │ │ │ -0007d9b0: 6173 682e 2061 0a09 2f2f 2031 206d 6561  ash. a..// 1 mea
    │ │ │ -0007d9c0: 6e73 2077 6520 6861 7665 2076 6572 6966  ns we have verif
    │ │ │ -0007d9d0: 6965 6420 7468 6520 626c 6f63 6b20 6861  ied the block ha
    │ │ │ -0007d9e0: 7368 2074 6f20 6265 2063 6f72 7265 6374  sh to be correct
    │ │ │ -0007d9f0: 2c20 6f74 6865 7277 6973 6520 7468 6520  , otherwise the 
    │ │ │ -0007da00: 626c 6f63 6b0a 092f 2f20 6861 7368 206d  block..// hash m
    │ │ │ -0007da10: 6179 2072 6570 7265 7365 6e74 2077 6861  ay represent wha
    │ │ │ -0007da20: 7427 7320 6f6e 2064 6973 6b2c 2062 7574  t's on disk, but
    │ │ │ -0007da30: 2077 6520 6861 7665 6e27 7420 6265 656e   we haven't been
    │ │ │ -0007da40: 2061 626c 6520 746f 2076 6572 6966 7920   able to verify 
    │ │ │ -0007da50: 6974 0a09 2f2f 2079 6574 0a09 6269 7466  it..// yet..bitf
    │ │ │ -0007da60: 6965 6c64 206d 5f62 6c6f 636b 5f76 6572  ield m_block_ver
    │ │ │ -0007da70: 6966 6965 643b 0a0a 092f 2f20 6e75 6d62  ified;...// numb
    │ │ │ -0007da80: 6572 206f 6620 626c 6f63 6b73 2069 6e20  er of blocks in 
    │ │ │ -0007da90: 7468 6520 6669 6c65 2074 6869 7320 7472  the file this tr
    │ │ │ -0007daa0: 6565 2072 6570 7265 7365 6e74 732e 2054  ee represents. T
    │ │ │ -0007dab0: 6865 206e 756d 6265 7220 6f66 206c 6561  he number of lea
    │ │ │ -0007dac0: 6673 2069 6e0a 092f 2f20 7468 6520 7472  fs in..// the tr
    │ │ │ -0007dad0: 6565 2069 7320 726f 756e 6465 6420 7570  ee is rounded up
    │ │ │ -0007dae0: 2074 6f20 616e 2065 7665 6e20 706f 7765   to an even powe
    │ │ │ -0007daf0: 7220 6f66 2032 2e0a 0969 6e74 206d 5f6e  r of 2...int m_n
    │ │ │ -0007db00: 756d 5f62 6c6f 636b 7320 3d20 303b 0a0a  um_blocks = 0;..
    │ │ │ -0007db10: 092f 2f20 7468 6520 6e75 6d62 6572 206f  .// the number o
    │ │ │ -0007db20: 6620 626c 6f63 6b73 2070 6572 2070 6965  f blocks per pie
    │ │ │ -0007db30: 6365 2c20 7370 6563 6966 6965 6420 6173  ce, specified as
    │ │ │ -0007db40: 2068 6f77 206d 616e 7920 7374 6570 7320   how many steps 
    │ │ │ -0007db50: 746f 2073 6869 6674 0a09 2f2f 2072 6967  to shift..// rig
    │ │ │ -0007db60: 6874 2031 2074 6f20 6765 7420 7468 6520  ht 1 to get the 
    │ │ │ -0007db70: 6e75 6d62 6572 206f 6620 626c 6f63 6b73  number of blocks
    │ │ │ -0007db80: 2069 6e20 6f6e 6520 7069 6563 652e 2054   in one piece. T
    │ │ │ -0007db90: 6869 7320 6973 2061 2063 6f6d 7061 6374  his is a compact
    │ │ │ -0007dba0: 0a09 2f2f 2072 6570 7265 7365 6e74 6174  ..// representat
    │ │ │ -0007dbb0: 696f 6e20 7468 6174 2773 2076 616c 6964  ion that's valid
    │ │ │ -0007dbc0: 2062 6563 6175 7365 2070 6965 6365 7320   because pieces 
    │ │ │ -0007dbd0: 6172 6520 616c 7761 7973 2070 6f77 6572  are always power
    │ │ │ -0007dbe0: 7320 6f66 2032 2e0a 092f 2f20 7468 6973  s of 2...// this
    │ │ │ -0007dbf0: 2069 7320 6e65 6365 7373 6172 7920 746f   is necessary to
    │ │ │ -0007dc00: 206b 6e6f 7720 7768 6963 6820 6c61 7965   know which laye
    │ │ │ -0007dc10: 7220 696e 2074 6865 2074 7265 6520 7468  r in the tree th
    │ │ │ -0007dc20: 6520 7069 6563 6520 6c61 7965 7220 6973  e piece layer is
    │ │ │ -0007dc30: 2e0a 0973 7464 3a3a 7569 6e74 385f 7420  ...std::uint8_t 
    │ │ │ -0007dc40: 6d5f 626c 6f63 6b73 5f70 6572 5f70 6965  m_blocks_per_pie
    │ │ │ -0007dc50: 6365 5f6c 6f67 203d 2030 3b0a 0a09 656e  ce_log = 0;...en
    │ │ │ -0007dc60: 756d 2063 6c61 7373 206d 6f64 655f 7420  um class mode_t 
    │ │ │ -0007dc70: 3a20 7374 643a 3a75 696e 7438 5f74 0a09  : std::uint8_t..
    │ │ │ -0007dc80: 7b0a 0909 2f2f 2061 2064 6566 6175 6c74  {...// a default
    │ │ │ -0007dc90: 2063 6f6e 7374 7275 6374 6564 2074 7265   constructed tre
    │ │ │ -0007dca0: 6520 6973 2074 7275 6c79 2065 6d70 7479  e is truly empty
    │ │ │ -0007dcb0: 2e20 4974 2064 6f65 7320 6e6f 7420 6576  . It does not ev
    │ │ │ -0007dcc0: 656e 2068 6176 6520 610a 0909 2f2f 2072  en have a...// r
    │ │ │ -0007dcd0: 6f6f 7420 6861 7368 0a09 0975 6e69 6e69  oot hash...unini
    │ │ │ -0007dce0: 7469 616c 697a 6564 5f74 7265 652c 0a0a  tialized_tree,..
    │ │ │ -0007dcf0: 0909 2f2f 2077 6520 646f 6e27 7420 6861  ..// we don't ha
    │ │ │ -0007dd00: 7665 2061 6e79 2068 6173 6865 7320 696e  ve any hashes in
    │ │ │ -0007dd10: 2074 6869 7320 7472 6565 2e20 6d5f 7472   this tree. m_tr
    │ │ │ -0007dd20: 6565 2073 686f 756c 6420 6265 2065 6d70  ee should be emp
    │ │ │ -0007dd30: 7479 0a09 092f 2f20 616e 2065 6d70 7479  ty...// an empty
    │ │ │ -0007dd40: 2074 7265 6520 7374 696c 6c20 616c 7761   tree still alwa
    │ │ │ -0007dd50: 7973 2068 6176 6520 7468 6520 726f 6f74  ys have the root
    │ │ │ -0007dd60: 2068 6173 6820 2861 7661 696c 6162 6c65   hash (available
    │ │ │ -0007dd70: 2061 7320 726f 6f74 2829 290a 0909 656d   as root())...em
    │ │ │ -0007dd80: 7074 795f 7472 6565 2c0a 0a09 092f 2f20  pty_tree,....// 
    │ │ │ -0007dd90: 696e 2074 6869 7320 6d6f 6465 2c20 6d5f  in this mode, m_
    │ │ │ -0007dda0: 7472 6565 2072 6570 7265 7365 6e74 7320  tree represents 
    │ │ │ -0007ddb0: 7468 6520 6675 6c6c 2074 7265 652c 2069  the full tree, i
    │ │ │ -0007ddc0: 6e63 6c75 6469 6e67 2070 6164 6469 6e67  ncluding padding
    │ │ │ -0007ddd0: 2e0a 0909 6675 6c6c 5f74 7265 652c 0a0a  ....full_tree,..
    │ │ │ -0007dde0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e  
    │ │ │ -0007ddf0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0007de20: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../in │ │ │ -0007de50: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -0007de60: 2f61 7578 5f2f 6465 7072 6563 6174 6564 /aux_/deprecated │ │ │ -0007de70: 2e68 7070 3a34 373c 2f61 3e3c 2f74 643e .hpp:47 │ │ │ -0007de80: 3c74 643e 6669 6775 7265 206f 7574 2077 figure out w │ │ │ -0007de90: 6869 6368 2076 6572 7369 6f6e 206f 6620 hich version of │ │ │ -0007dea0: 636c 616e 6720 7468 6973 2069 7320 7375 clang this is su │ │ │ -0007deb0: 7070 6f72 7465 6420 696e 3c2f 7464 3e3c pported in< │ │ │ -0007dec0: 2f74 723e 3c74 7220 6964 3d22 3238 3222 /tr>

    figure o │ │ │ -0007df10: 7574 2077 6869 6368 2076 6572 7369 6f6e ut which version │ │ │ -0007df20: 206f 6620 636c 616e 6720 7468 6973 2069 of clang this i │ │ │ -0007df30: 7320 7375 7070 6f72 7465 6420 696e 3c2f s supported in

    ../includ │ │ │ -0007df50: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ -0007df60: 5f2f 6465 7072 6563 6174 6564 2e68 7070 _/deprecated.hpp │ │ │ -0007df70: 3a34 373c 2f68 343e 3c70 7265 2073 7479 :47

    CONTRACT, STRI
    │ │ │ -0007dfc0: 4354 204c 4941 4249 4c49 5459 2c20 4f52  CT LIABILITY, OR
    │ │ │ -0007dfd0: 2054 4f52 5420 2849 4e43 4c55 4449 4e47   TORT (INCLUDING
    │ │ │ -0007dfe0: 204e 4547 4c49 4745 4e43 4520 4f52 204f   NEGLIGENCE OR O
    │ │ │ -0007dff0: 5448 4552 5749 5345 290a 4152 4953 494e  THERWISE).ARISIN
    │ │ │ -0007e000: 4720 494e 2041 4e59 2057 4159 204f 5554  G IN ANY WAY OUT
    │ │ │ -0007e010: 204f 4620 5448 4520 5553 4520 4f46 2054   OF THE USE OF T
    │ │ │ -0007e020: 4849 5320 534f 4654 5741 5245 2c20 4556  HIS SOFTWARE, EV
    │ │ │ -0007e030: 454e 2049 4620 4144 5649 5345 4420 4f46  EN IF ADVISED OF
    │ │ │ -0007e040: 2054 4845 0a50 4f53 5349 4249 4c49 5459   THE.POSSIBILITY
    │ │ │ -0007e050: 204f 4620 5355 4348 2044 414d 4147 452e   OF SUCH DAMAGE.
    │ │ │ -0007e060: 0a0a 2a2f 0a0a 2369 666e 6465 6620 544f  ..*/..#ifndef TO
    │ │ │ -0007e070: 5252 454e 545f 4445 5052 4543 4154 4544  RRENT_DEPRECATED
    │ │ │ -0007e080: 5f48 5050 5f49 4e43 4c55 4445 440a 2364  _HPP_INCLUDED.#d
    │ │ │ -0007e090: 6566 696e 6520 544f 5252 454e 545f 4445  efine TORRENT_DE
    │ │ │ -0007e0a0: 5052 4543 4154 4544 5f48 5050 5f49 4e43  PRECATED_HPP_INC
    │ │ │ -0007e0b0: 4c55 4445 440a 0a23 6966 2021 6465 6669  LUDED..#if !defi
    │ │ │ -0007e0c0: 6e65 6420 544f 5252 454e 545f 4255 494c  ned TORRENT_BUIL
    │ │ │ -0007e0d0: 4449 4e47 5f4c 4942 5241 5259 0a23 2064  DING_LIBRARY.# d
    │ │ │ -0007e0e0: 6566 696e 6520 544f 5252 454e 545f 4445  efine TORRENT_DE
    │ │ │ -0007e0f0: 5052 4543 4154 4544 205b 5b64 6570 7265  PRECATED [[depre
    │ │ │ -0007e100: 6361 7465 645d 5d0a 2365 6c73 650a 2320  cated]].#else.# 
    │ │ │ -0007e110: 6465 6669 6e65 2054 4f52 5245 4e54 5f44  define TORRENT_D
    │ │ │ -0007e120: 4550 5245 4341 5445 440a 2365 6e64 6966  EPRECATED.#endif
    │ │ │ -0007e130: 0a0a 2369 6620 6465 6669 6e65 6420 5f5f  ..#if defined __
    │ │ │ -0007e140: 636c 616e 675f 5f0a 0a2f 2f20 3d3d 3d3d  clang__..// ====
    │ │ │ -0007e150: 3d3d 2043 4c41 4e47 203d 3d3d 3d3d 3d3d  == CLANG =======
    │ │ │ -0007e160: 3d0a 0a23 2069 6620 2164 6566 696e 6564  =..# if !defined
    │ │ │ -0007e170: 2054 4f52 5245 4e54 5f42 5549 4c44 494e   TORRENT_BUILDIN
    │ │ │ -0007e180: 475f 4c49 4252 4152 590a 3c64 6976 2073  G_LIBRARY.
    # defin │ │ │ -0007e1c0: 6520 544f 5252 454e 545f 4445 5052 4543 e TORRENT_DEPREC │ │ │ -0007e1d0: 4154 4544 5f45 4e55 4d20 5f5f 6174 7472 ATED_ENUM __attr │ │ │ -0007e1e0: 6962 7574 655f 5f20 2828 6465 7072 6563 ibute__ ((deprec │ │ │ -0007e1f0: 6174 6564 2929 0a3c 2f64 6976 3e23 2065 ated)).
    # e │ │ │ -0007e200: 6e64 6966 0a0a 2365 6c69 6620 6465 6669 ndif..#elif defi │ │ │ -0007e210: 6e65 6420 5f5f 474e 5543 5f5f 0a0a 2f2f ned __GNUC__..// │ │ │ -0007e220: 203d 3d3d 3d3d 3d3d 3d20 4743 4320 3d3d ======== GCC == │ │ │ -0007e230: 3d3d 3d3d 3d3d 0a0a 2f2f 2064 6570 7265 ======..// depre │ │ │ -0007e240: 6361 7469 6f6e 206d 6172 6b75 7020 6973 cation markup is │ │ │ -0007e250: 206f 6e6c 7920 656e 6162 6c65 6420 7768 only enabled wh │ │ │ -0007e260: 656e 206c 6962 746f 7272 656e 740a 2f2f en libtorrent.// │ │ │ -0007e270: 2068 6561 6465 7273 2061 7265 2069 6e63 headers are inc │ │ │ -0007e280: 6c75 6465 6420 6279 2063 6c69 656e 7473 luded by clients │ │ │ -0007e290: 2c20 6e6f 7420 7768 696c 6520 6275 696c , not while buil │ │ │ -0007e2a0: 6469 6e67 0a2f 2f20 6c69 6274 6f72 7265 ding.// libtorre │ │ │ -0007e2b0: 6e74 2069 7473 656c 660a 2320 6966 205f nt itself.# if _ │ │ │ -0007e2c0: 5f47 4e55 435f 5f20 2667 743b 3d20 3620 _GNUC__ >= 6 │ │ │ -0007e2d0: 2661 6d70 3b26 616d 703b 2021 6465 6669 && !defi │ │ │ -0007e2e0: 6e65 6420 544f 5252 454e 545f 4255 494c ned TORRENT_BUIL │ │ │ -0007e2f0: 4449 4e47 5f4c 4942 5241 5259 0a23 2020 DING_LIBRARY.# │ │ │ -0007e300: 6465 6669 6e65 2054 4f52 5245 4e54 5f44 define TORRENT_D │ │ │ -0007e310: 4550 5245 4341 5445 445f 454e 554d 205f EPRECATED_ENUM _ │ │ │ -0007e320: 5f61 7474 7269 6275 7465 5f5f 2028 2864 _attribute__ ((d │ │ │ -0007e330: 6570 7265 6361 7465 6429 290a 2320 656e eprecated)).# en │ │ │ -0007e340: 6469 660a 0a23 656e 6469 660a 0a23 6966 dif..#endif..#if │ │ │ -0007e350: 6e64 6566 2054 4f52 5245 4e54 5f44 4550 ndef TORRENT_DEP │ │ │ -0007e360: 5245 4341 5445 445f 454e 554d 0a23 6465 RECATED_ENUM.#de │ │ │ -0007e370: 6669 6e65 2054 4f52 5245 4e54 5f44 4550 fine TORRENT_DEP │ │ │ -0007e380: 5245 4341 5445 445f 454e 554d 0a23 656e RECATED_ENUM.#en │ │ │ -0007e390: 6469 660a 0a23 656e 6469 660a 3c2f 7072 dif..#endif.rel │ │ │ -0007e3d0: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../includ │ │ │ -0007e410: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ -0007e420: 5f2f 616e 6e6f 756e 6365 5f65 6e74 7279 _/announce_entry │ │ │ -0007e430: 2e68 7070 3a37 343c 2f61 3e3c 2f74 643e .hpp:74 │ │ │ -0007e440: 3c74 643e 696e 636c 7564 6520 7468 6520 include the │ │ │ -0007e450: 6e75 6d62 6572 206f 6620 7065 6572 7320 number of peers │ │ │ -0007e460: 7265 6365 6976 6564 2066 726f 6d20 7468 received from th │ │ │ -0007e470: 6973 2074 7261 636b 6572 2c20 6174 206c is tracker, at l │ │ │ -0007e480: 6173 7420 616e 6e6f 756e 6365 3c2f 7464 ast announce

    includ │ │ │ -0007e4e0: 6520 7468 6520 6e75 6d62 6572 206f 6620 e the number of │ │ │ -0007e4f0: 7065 6572 7320 7265 6365 6976 6564 2066 peers received f │ │ │ -0007e500: 726f 6d20 7468 6973 2074 7261 636b 6572 rom this tracker │ │ │ -0007e510: 2c20 6174 206c 6173 740a 616e 6e6f 756e , at last.announ │ │ │ -0007e520: 6365 3c2f 6832 3e3c 6834 3e2e 2e2f 696e ce

    ../in │ │ │ -0007e530: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -0007e540: 2f61 7578 5f2f 616e 6e6f 756e 6365 5f65 /aux_/announce_e │ │ │ -0007e550: 6e74 7279 2e68 7070 3a37 343c 2f68 343e ntry.hpp:74

    │ │ │ -0007e560: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    namesp
    │ │ │ -0007e5a0: 6163 6520 6175 7820 7b0a 0a09 7374 7275  ace aux {...stru
    │ │ │ -0007e5b0: 6374 2054 4f52 5245 4e54 5f45 5854 5241  ct TORRENT_EXTRA
    │ │ │ -0007e5c0: 5f45 5850 4f52 5420 616e 6e6f 756e 6365  _EXPORT announce
    │ │ │ -0007e5d0: 5f69 6e66 6f68 6173 680a 097b 0a09 0961  _infohash..{...a
    │ │ │ -0007e5e0: 6e6e 6f75 6e63 655f 696e 666f 6861 7368  nnounce_infohash
    │ │ │ -0007e5f0: 2829 3b0a 0a09 092f 2f20 6966 2074 6869  ();....// if thi
    │ │ │ -0007e600: 7320 7472 6163 6b65 7220 6861 7320 7265  s tracker has re
    │ │ │ -0007e610: 7475 726e 6564 2061 6e20 6572 726f 7220  turned an error 
    │ │ │ -0007e620: 6f72 2077 6172 6e69 6e67 206d 6573 7361  or warning messa
    │ │ │ -0007e630: 6765 0a09 092f 2f20 7468 6174 206d 6573  ge...// that mes
    │ │ │ -0007e640: 7361 6765 2069 7320 7374 6f72 6564 2068  sage is stored h
    │ │ │ -0007e650: 6572 650a 0909 7374 643a 3a73 7472 696e  ere...std::strin
    │ │ │ -0007e660: 6720 6d65 7373 6167 653b 0a0a 0909 2f2f  g message;....//
    │ │ │ -0007e670: 2069 6620 7468 6973 2074 7261 636b 6572   if this tracker
    │ │ │ -0007e680: 2066 6169 6c65 6420 7468 6520 6c61 7374   failed the last
    │ │ │ -0007e690: 2074 696d 6520 6974 2077 6173 2063 6f6e   time it was con
    │ │ │ -0007e6a0: 7461 6374 6564 0a09 092f 2f20 7468 6973  tacted...// this
    │ │ │ -0007e6b0: 2065 7272 6f72 2063 6f64 6520 7370 6563   error code spec
    │ │ │ -0007e6c0: 6966 6965 7320 7768 6174 2065 7272 6f72  ifies what error
    │ │ │ -0007e6d0: 206f 6363 7572 7265 640a 0909 6572 726f   occurred...erro
    │ │ │ -0007e6e0: 725f 636f 6465 206c 6173 745f 6572 726f  r_code last_erro
    │ │ │ -0007e6f0: 723b 0a0a 0909 2f2f 2074 6865 2074 696d  r;....// the tim
    │ │ │ -0007e700: 6520 6f66 206e 6578 7420 7472 6163 6b65  e of next tracke
    │ │ │ -0007e710: 7220 616e 6e6f 756e 6365 0a09 0974 696d  r announce...tim
    │ │ │ -0007e720: 655f 706f 696e 7433 3220 6e65 7874 5f61  e_point32 next_a
    │ │ │ -0007e730: 6e6e 6f75 6e63 6520 3d20 2874 696d 655f  nnounce = (time_
    │ │ │ -0007e740: 706f 696e 7433 323a 3a6d 696e 2928 293b  point32::min)();
    │ │ │ -0007e750: 0a0a 0909 2f2f 206e 6f20 616e 6e6f 756e  ....// no announ
    │ │ │ -0007e760: 6365 7320 6265 666f 7265 2074 6869 7320  ces before this 
    │ │ │ -0007e770: 7469 6d65 0a09 0974 696d 655f 706f 696e  time...time_poin
    │ │ │ -0007e780: 7433 3220 6d69 6e5f 616e 6e6f 756e 6365  t32 min_announce
    │ │ │ -0007e790: 203d 2028 7469 6d65 5f70 6f69 6e74 3332   = (time_point32
    │ │ │ -0007e7a0: 3a3a 6d69 6e29 2829 3b0a 0a3c 6469 7620  ::min)();..
    .
    │ │ │ -0007e7e0: 0909 2f2f 2074 6865 7365 2061 7265 2065 ..// these are e │ │ │ -0007e7f0: 6974 6865 7220 2d31 206f 7220 7468 6520 ither -1 or the │ │ │ -0007e800: 7363 7261 7065 2069 6e66 6f72 6d61 7469 scrape informati │ │ │ -0007e810: 6f6e 2074 6869 7320 7472 6163 6b65 7220 on this tracker │ │ │ -0007e820: 6c61 7374 0a09 092f 2f20 7265 7370 6f6e last...// respon │ │ │ -0007e830: 6465 6420 7769 7468 2e20 2a69 6e63 6f6d ded with. *incom │ │ │ -0007e840: 706c 6574 652a 2069 7320 7468 6520 6375 plete* is the cu │ │ │ -0007e850: 7272 656e 7420 6e75 6d62 6572 206f 6620 rrent number of │ │ │ -0007e860: 646f 776e 6c6f 6164 6572 7320 696e 0a09 downloaders in.. │ │ │ -0007e870: 092f 2f20 7468 6520 7377 6172 6d2c 202a .// the swarm, * │ │ │ -0007e880: 636f 6d70 6c65 7465 2a20 6973 2074 6865 complete* is the │ │ │ -0007e890: 2063 7572 7265 6e74 206e 756d 6265 7220 current number │ │ │ -0007e8a0: 6f66 2073 6565 6473 2069 6e20 7468 6520 of seeds in the │ │ │ -0007e8b0: 7377 6172 6d20 616e 640a 0909 2f2f 202a swarm and...// * │ │ │ -0007e8c0: 646f 776e 6c6f 6164 6564 2a20 6973 2074 downloaded* is t │ │ │ -0007e8d0: 6865 2063 756d 756c 6174 6976 6520 6e75 he cumulative nu │ │ │ -0007e8e0: 6d62 6572 206f 6620 636f 6d70 6c65 7465 mber of complete │ │ │ -0007e8f0: 6420 646f 776e 6c6f 6164 7320 6f66 2074 d downloads of t │ │ │ -0007e900: 6869 730a 0909 2f2f 2074 6f72 7265 6e74 his...// torrent │ │ │ -0007e910: 2c20 7369 6e63 6520 7468 6520 6265 6769 , since the begi │ │ │ -0007e920: 6e6e 696e 6720 6f66 2074 696d 6520 2866 nning of time (f │ │ │ -0007e930: 726f 6d20 7468 6973 2074 7261 636b 6572 rom this tracker │ │ │ -0007e940: 2773 2070 6f69 6e74 206f 660a 0909 2f2f 's point of...// │ │ │ -0007e950: 2076 6965 7729 2e0a 0a09 092f 2f20 6966 view).....// if │ │ │ -0007e960: 2074 6869 7320 7472 6163 6b65 7220 6861 this tracker ha │ │ │ -0007e970: 7320 7265 7475 726e 6564 2073 6372 6170 s returned scrap │ │ │ -0007e980: 6520 6461 7461 2c20 7468 6573 6520 6669 e data, these fi │ │ │ -0007e990: 656c 6473 2061 7265 2066 696c 6c65 6420 elds are filled │ │ │ -0007e9a0: 696e 0a09 092f 2f20 7769 7468 2076 616c in...// with val │ │ │ -0007e9b0: 6964 206e 756d 6265 7273 2e20 4f74 6865 id numbers. Othe │ │ │ -0007e9c0: 7277 6973 6520 7468 6579 2061 7265 2073 rwise they are s │ │ │ -0007e9d0: 6574 2074 6f20 2d31 2e20 6060 696e 636f et to -1. ``inco │ │ │ -0007e9e0: 6d70 6c65 7465 6060 2063 6f75 6e74 730a mplete`` counts. │ │ │ -0007e9f0: 0909 2f2f 2074 6865 206e 756d 6265 7220 ..// the number │ │ │ -0007ea00: 6f66 2063 7572 7265 6e74 2064 6f77 6e6c of current downl │ │ │ -0007ea10: 6f61 6465 7273 2e20 6060 636f 6d70 6c65 oaders. ``comple │ │ │ -0007ea20: 7465 6060 2063 6f75 6e74 7320 7468 6520 te`` counts the │ │ │ -0007ea30: 6e75 6d62 6572 206f 660a 0909 2f2f 2063 number of...// c │ │ │ -0007ea40: 7572 7265 6e74 2070 6565 7273 2063 6f6d urrent peers com │ │ │ -0007ea50: 706c 6574 6564 2074 6865 2064 6f77 6e6c pleted the downl │ │ │ -0007ea60: 6f61 642c 206f 7220 2273 6565 6473 222e oad, or "seeds". │ │ │ -0007ea70: 2060 6064 6f77 6e6c 6f61 6465 6460 6020 ``downloaded`` │ │ │ -0007ea80: 6973 2074 6865 0a09 092f 2f20 6375 6d75 is the...// cumu │ │ │ -0007ea90: 6c61 7469 7665 206e 756d 6265 7220 6f66 lative number of │ │ │ -0007eaa0: 2063 6f6d 706c 6574 6564 2064 6f77 6e6c completed downl │ │ │ -0007eab0: 6f61 6473 2e0a 0909 696e 7420 7363 7261 oads....int scra │ │ │ -0007eac0: 7065 5f69 6e63 6f6d 706c 6574 6520 3d20 pe_incomplete = │ │ │ -0007ead0: 2d31 3b0a 0909 696e 7420 7363 7261 7065 -1;...int scrape │ │ │ -0007eae0: 5f63 6f6d 706c 6574 6520 3d20 2d31 3b0a _complete = -1;. │ │ │ -0007eaf0: 0909 696e 7420 7363 7261 7065 5f64 6f77 ..int scrape_dow │ │ │ -0007eb00: 6e6c 6f61 6465 6420 3d20 2d31 3b0a 0a09 nloaded = -1;... │ │ │ -0007eb10: 092f 2f20 7468 6520 6e75 6d62 6572 206f .// the number o │ │ │ -0007eb20: 6620 7469 6d65 7320 696e 2061 2072 6f77 f times in a row │ │ │ -0007eb30: 2077 6520 6861 7665 2066 6169 6c65 6420 we have failed │ │ │ -0007eb40: 746f 2061 6e6e 6f75 6e63 6520 746f 2074 to announce to t │ │ │ -0007eb50: 6869 730a 0909 2f2f 2074 7261 636b 6572 his...// tracker │ │ │ -0007eb60: 2e0a 0909 7374 643a 3a75 696e 7438 5f74 ....std::uint8_t │ │ │ -0007eb70: 2066 6169 6c73 203a 2037 3b0a 0a09 092f fails : 7;..../ │ │ │ -0007eb80: 2f20 7472 7565 2077 6869 6c65 2077 6527 / true while we' │ │ │ -0007eb90: 7265 2077 6169 7469 6e67 2066 6f72 2061 re waiting for a │ │ │ -0007eba0: 2072 6573 706f 6e73 6520 6672 6f6d 2074 response from t │ │ │ -0007ebb0: 6865 2074 7261 636b 6572 2e0a 0909 626f he tracker....bo │ │ │ -0007ebc0: 6f6c 2075 7064 6174 696e 6720 3a20 313b ol updating : 1; │ │ │ -0007ebd0: 0a0a 0909 2f2f 2073 6574 2074 6f20 7472 ....// set to tr │ │ │ -0007ebe0: 7565 2077 6865 6e20 7765 2067 6574 2061 ue when we get a │ │ │ -0007ebf0: 2076 616c 6964 2072 6573 706f 6e73 6520 valid response │ │ │ -0007ec00: 6672 6f6d 2061 6e20 616e 6e6f 756e 6365 from an announce │ │ │ -0007ec10: 0a09 092f 2f20 7769 7468 2065 7665 6e74 ...// with event │ │ │ -0007ec20: 3d73 7461 7274 6564 2e20 4966 2069 7420 =started. If it │ │ │ -0007ec30: 6973 2073 6574 2c20 7765 2077 6f6e 2774 is set, we won't │ │ │ -0007ec40: 2073 656e 6420 7374 6172 7420 696e 2074 send start in t │ │ │ -0007ec50: 6865 2073 7562 7365 7175 656e 740a 0909 he subsequent... │ │ │ -0007ec60: 2f2f 2061 6e6e 6f75 6e63 6573 2e0a 0909 // announces.... │ │ │ -0007ec70: 626f 6f6c 2073 7461 7274 5f73 656e 7420 bool start_sent │ │ │ -0007ec80: 3a20 313b 0a0a 0909 2f2f 2073 6574 2074 : 1;....// set t │ │ │ -0007ec90: 6f20 7472 7565 2077 6865 6e20 7765 2073 o true when we s │ │ │ -0007eca0: 656e 6420 6120 6576 656e 743d 636f 6d70 end a event=comp │ │ │ -0007ecb0: 6c65 7465 642e 0a09 0962 6f6f 6c20 636f leted....bool co │ │ │ -0007ecc0: 6d70 6c65 7465 5f73 656e 7420 3a20 313b mplete_sent : 1; │ │ │ -0007ecd0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -0007ed10: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../i │ │ │ -0007ed40: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -0007ed50: 742f 6175 785f 2f61 6c6c 6f63 6174 696e t/aux_/allocatin │ │ │ -0007ed60: 675f 6861 6e64 6c65 722e 6870 703a 3331 g_handler.hpp:31 │ │ │ -0007ed70: 363c 2f61 3e3c 2f74 643e 3c74 643e 696e 6in │ │ │ -0007ed80: 2043 2b2b 3137 2c20 4861 6e64 6c65 7220 C++17, Handler │ │ │ -0007ed90: 616e 6420 5374 6f72 6167 6520 636f 756c and Storage coul │ │ │ -0007eda0: 6420 6a75 7374 2075 7365 2022 6175 746f d just use "auto │ │ │ -0007edb0: 223c 2f74 643e 3c2f 7472 3e3c 7472 2069 "

    i │ │ │ -0007ee00: 6e20 432b 2b31 372c 2048 616e 646c 6572 n C++17, Handler │ │ │ -0007ee10: 2061 6e64 2053 746f 7261 6765 2063 6f75 and Storage cou │ │ │ -0007ee20: 6c64 206a 7573 7420 7573 6520 2261 7574 ld just use "aut │ │ │ -0007ee30: 6f22 3c2f 6832 3e3c 6834 3e2e 2e2f 696e o"

    ../in │ │ │ -0007ee40: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -0007ee50: 2f61 7578 5f2f 616c 6c6f 6361 7469 6e67 /aux_/allocating │ │ │ -0007ee60: 5f68 616e 646c 6572 2e68 7070 3a33 3136 _handler.hpp:316 │ │ │ -0007ee70: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -0007eeb0: 0970 7269 7661 7465 3a0a 0a09 0948 616e  .private:....Han
    │ │ │ -0007eec0: 646c 6572 2068 616e 646c 6572 3b0a 0909  dler handler;...
    │ │ │ -0007eed0: 6861 6e64 6c65 725f 7374 6f72 6167 6526  handler_storage&
    │ │ │ -0007eee0: 6c74 3b53 697a 652c 204e 616d 6526 6774  lt;Size, Name>
    │ │ │ -0007eef0: 3b2a 2073 746f 7261 6765 3b0a 2369 666e  ;* storage;.#ifn
    │ │ │ -0007ef00: 6465 6620 424f 4f53 545f 4e4f 5f45 5843  def BOOST_NO_EXC
    │ │ │ -0007ef10: 4550 5449 4f4e 530a 0909 6572 726f 725f  EPTIONS...error_
    │ │ │ -0007ef20: 6861 6e64 6c65 725f 696e 7465 7266 6163  handler_interfac
    │ │ │ -0007ef30: 652a 2065 7272 6f72 5f68 616e 646c 6572  e* error_handler
    │ │ │ -0007ef40: 3b0a 2365 6e64 6966 0a09 7d3b 0a0a 0974  ;.#endif..};...t
    │ │ │ -0007ef50: 656d 706c 6174 6520 266c 743b 636c 6173  emplate <clas
    │ │ │ -0007ef60: 7320 4861 6e64 6c65 722c 2073 697a 655f  s Handler, size_
    │ │ │ -0007ef70: 7420 5369 7a65 2c20 4861 6e64 6c65 724e  t Size, HandlerN
    │ │ │ -0007ef80: 616d 6520 4e61 6d65 2667 743b 0a09 6175  ame Name>..au
    │ │ │ -0007ef90: 783a 3a61 6c6c 6f63 6174 696e 675f 6861  x::allocating_ha
    │ │ │ -0007efa0: 6e64 6c65 7226 6c74 3b48 616e 646c 6572  ndler<Handler
    │ │ │ -0007efb0: 2c20 5369 7a65 2c20 4e61 6d65 2667 743b  , Size, Name>
    │ │ │ -0007efc0: 0a09 6d61 6b65 5f68 616e 646c 6572 2848  ..make_handler(H
    │ │ │ -0007efd0: 616e 646c 6572 2068 616e 646c 6572 0a09  andler handler..
    │ │ │ -0007efe0: 092c 2068 616e 646c 6572 5f73 746f 7261  ., handler_stora
    │ │ │ -0007eff0: 6765 266c 743b 5369 7a65 2c20 4e61 6d65  ge<Size, Name
    │ │ │ -0007f000: 2667 743b 2661 6d70 3b20 7374 6f72 6167  >& storag
    │ │ │ -0007f010: 650a 0909 2c20 6572 726f 725f 6861 6e64  e..., error_hand
    │ │ │ -0007f020: 6c65 725f 696e 7465 7266 6163 6526 616d  ler_interface&am
    │ │ │ -0007f030: 703b 2065 7272 5f68 616e 646c 6572 290a  p; err_handler).
    │ │ │ -0007f040: 097b 0a09 0972 6574 7572 6e20 6175 783a  .{...return aux:
    │ │ │ -0007f050: 3a61 6c6c 6f63 6174 696e 675f 6861 6e64  :allocating_hand
    │ │ │ -0007f060: 6c65 7226 6c74 3b48 616e 646c 6572 2c20  ler<Handler, 
    │ │ │ -0007f070: 5369 7a65 2c20 4e61 6d65 2667 743b 280a  Size, Name>(.
    │ │ │ -0007f080: 0909 0973 7464 3a3a 666f 7277 6172 6426  ...std::forward&
    │ │ │ -0007f090: 6c74 3b48 616e 646c 6572 2667 743b 2868  lt;Handler>(h
    │ │ │ -0007f0a0: 616e 646c 6572 292c 2026 616d 703b 7374  andler), &st
    │ │ │ -0007f0b0: 6f72 6167 652c 2026 616d 703b 6572 725f  orage, &err_
    │ │ │ -0007f0c0: 6861 6e64 6c65 7229 3b0a 097d 0a0a 3c64  handler);..}...tem
    │ │ │ -0007f100: 706c 6174 6520 266c 743b 7479 7065 6e61  plate <typena
    │ │ │ -0007f110: 6d65 2054 0a3c 2f64 6976 3e09 092c 2074  me T..., t
    │ │ │ -0007f120: 7970 656e 616d 6520 4861 6e64 6c65 7254  ypename HandlerT
    │ │ │ -0007f130: 7970 650a 0909 2c20 4861 6e64 6c65 7254  ype..., HandlerT
    │ │ │ -0007f140: 7970 6520 4861 6e64 6c65 720a 0909 2c20  ype Handler..., 
    │ │ │ -0007f150: 766f 6964 2028 543a 3a2a 4572 726f 7248  void (T::*ErrorH
    │ │ │ -0007f160: 616e 646c 6572 2928 6572 726f 725f 636f  andler)(error_co
    │ │ │ -0007f170: 6465 2063 6f6e 7374 2661 6d70 3b29 0a09  de const&)..
    │ │ │ -0007f180: 092c 2076 6f69 6420 2854 3a3a 2a45 7863  ., void (T::*Exc
    │ │ │ -0007f190: 6570 7448 616e 646c 6572 2928 7374 643a  eptHandler)(std:
    │ │ │ -0007f1a0: 3a65 7863 6570 7469 6f6e 2063 6f6e 7374  :exception const
    │ │ │ -0007f1b0: 2661 6d70 3b29 0a09 092c 2074 7970 656e  &)..., typen
    │ │ │ -0007f1c0: 616d 6520 5374 6f72 6167 6554 7970 650a  ame StorageType.
    │ │ │ -0007f1d0: 0909 2c20 5374 6f72 6167 6554 7970 6520  .., StorageType 
    │ │ │ -0007f1e0: 543a 3a2a 2053 746f 7261 6765 2667 743b  T::* Storage>
    │ │ │ -0007f1f0: 0a09 7374 7275 6374 2068 616e 646c 6572  ..struct handler
    │ │ │ -0007f200: 0a09 7b0a 0909 6578 706c 6963 6974 2068  ..{...explicit h
    │ │ │ -0007f210: 616e 646c 6572 2873 7464 3a3a 7368 6172  andler(std::shar
    │ │ │ -0007f220: 6564 5f70 7472 266c 743b 5426 6774 3b20  ed_ptr<T> 
    │ │ │ -0007f230: 7029 203a 2070 7472 5f28 7374 643a 3a6d  p) : ptr_(std::m
    │ │ │ -0007f240: 6f76 6528 7029 2920 7b7d 0a0a 0909 7374  ove(p)) {}....st
    │ │ │ -0007f250: 643a 3a73 6861 7265 645f 7074 7226 6c74  d::shared_ptr<
    │ │ │ -0007f260: 3b54 2667 743b 2070 7472 5f3b 0a0a 0909  ;T> ptr_;....
    │ │ │ -0007f270: 7465 6d70 6c61 7465 2026 6c74 3b63 6c61  template <cla
    │ │ │ -0007f280: 7373 2e2e 2e20 4126 6774 3b0a 0909 766f  ss... A>...vo
    │ │ │ -0007f290: 6964 206f 7065 7261 746f 7228 2928 4126  id operator()(A&
    │ │ │ -0007f2a0: 616d 703b 2661 6d70 3b2e 2e2e 2061 290a  amp;&... a).
    │ │ │ -0007f2b0: 0909 7b0a 2369 6664 6566 2042 4f4f 5354  ..{.#ifdef BOOST
    │ │ │ -0007f2c0: 5f4e 4f5f 4558 4345 5054 494f 4e53 0a09  _NO_EXCEPTIONS..
    │ │ │ -0007f2d0: 0909 2870 7472 5f2e 6765 7428 292d 2667  ..(ptr_.get()-&g
    │ │ │ -0007f2e0: 743b 2a48 616e 646c 6572 2928 7374 643a  t;*Handler)(std:
    │ │ │ -0007f2f0: 3a66 6f72 7761 7264 266c 743b 4126 6774  :forward<A>
    │ │ │ -0007f300: 3b28 6129 2e2e 2e29 3b0a 2365 6c73 650a  ;(a)...);.#else.
    │ │ │ -0007f310: 0909 0974 7279 0a09 0909 7b0a 0909 0909  ...try....{.....
    │ │ │ -0007f320: 2870 7472 5f2e 6765 7428 292d 2667 743b  (ptr_.get()->
    │ │ │ -0007f330: 2a48 616e 646c 6572 2928 7374 643a 3a66  *Handler)(std::f
    │ │ │ -0007f340: 6f72 7761 7264 266c 743b 4126 6774 3b28  orward<A>(
    │ │ │ -0007f350: 6129 2e2e 2e29 3b0a 0909 097d 0a09 0909  a)...);....}....
    │ │ │ -0007f360: 6361 7463 6820 2873 7973 7465 6d5f 6572  catch (system_er
    │ │ │ -0007f370: 726f 7220 636f 6e73 7426 616d 703b 2065  ror const& e
    │ │ │ -0007f380: 290a 0909 097b 0a09 0909 0928 7074 725f  )....{.....(ptr_
    │ │ │ -0007f390: 2e67 6574 2829 2d26 6774 3b2a 4572 726f  .get()->*Erro
    │ │ │ -0007f3a0: 7248 616e 646c 6572 2928 652e 636f 6465  rHandler)(e.code
    │ │ │ -0007f3b0: 2829 293b 0a09 0909 7d0a 0909 0963 6174  ());....}....cat
    │ │ │ -0007f3c0: 6368 2028 7374 643a 3a65 7863 6570 7469  ch (std::excepti
    │ │ │ -0007f3d0: 6f6e 2063 6f6e 7374 2661 6d70 3b20 6529  on const& e)
    │ │ │ -0007f3e0: 0a09 0909 7b0a 0909 0909 2870 7472 5f2e  ....{.....(ptr_.
    │ │ │ -0007f3f0: 6765 7428 292d 2667 743b 2a45 7863 6570  get()->*Excep
    │ │ │ -0007f400: 7448 616e 646c 6572 2928 6529 3b0a 0909  tHandler)(e);...
    │ │ │ +00079b70: 656e 742f 6175 785f 2f61 6e6e 6f75 6e63  ent/aux_/announc
    │ │ │ +00079b80: 655f 656e 7472 792e 6870 703a 3734 3c2f  e_entry.hpp:74inclu
    │ │ │ +00079ba0: 6465 2074 6865 206e 756d 6265 7220 6f66  de the number of
    │ │ │ +00079bb0: 2070 6565 7273 2072 6563 6569 7665 6420   peers received 
    │ │ │ +00079bc0: 6672 6f6d 2074 6869 7320 7472 6163 6b65  from this tracke
    │ │ │ +00079bd0: 722c 2061 7420 6c61 7374 2061 6e6e 6f75  r, at last annou
    │ │ │ +00079be0: 6e63 653c 2f74 643e 3c2f 7472 3e3c 7472  nce

    include the num │ │ │ +00079c40: 6265 7220 6f66 2070 6565 7273 2072 6563 ber of peers rec │ │ │ +00079c50: 6569 7665 6420 6672 6f6d 2074 6869 7320 eived from this │ │ │ +00079c60: 7472 6163 6b65 722c 2061 7420 6c61 7374 tracker, at last │ │ │ +00079c70: 0a61 6e6e 6f75 6e63 653c 2f68 323e 3c68 .announce

    ../include/lib │ │ │ +00079c90: 746f 7272 656e 742f 6175 785f 2f61 6e6e torrent/aux_/ann │ │ │ +00079ca0: 6f75 6e63 655f 656e 7472 792e 6870 703a ounce_entry.hpp: │ │ │ +00079cb0: 3734 3c2f 6834 3e3c 7072 6520 7374 796c 74
    namespace aux {
    │ │ │ +00079d00: 0a0a 0973 7472 7563 7420 544f 5252 454e  ...struct TORREN
    │ │ │ +00079d10: 545f 4558 5452 415f 4558 504f 5254 2061  T_EXTRA_EXPORT a
    │ │ │ +00079d20: 6e6e 6f75 6e63 655f 696e 666f 6861 7368  nnounce_infohash
    │ │ │ +00079d30: 0a09 7b0a 0909 616e 6e6f 756e 6365 5f69  ..{...announce_i
    │ │ │ +00079d40: 6e66 6f68 6173 6828 293b 0a0a 0909 2f2f  nfohash();....//
    │ │ │ +00079d50: 2069 6620 7468 6973 2074 7261 636b 6572   if this tracker
    │ │ │ +00079d60: 2068 6173 2072 6574 7572 6e65 6420 616e   has returned an
    │ │ │ +00079d70: 2065 7272 6f72 206f 7220 7761 726e 696e   error or warnin
    │ │ │ +00079d80: 6720 6d65 7373 6167 650a 0909 2f2f 2074  g message...// t
    │ │ │ +00079d90: 6861 7420 6d65 7373 6167 6520 6973 2073  hat message is s
    │ │ │ +00079da0: 746f 7265 6420 6865 7265 0a09 0973 7464  tored here...std
    │ │ │ +00079db0: 3a3a 7374 7269 6e67 206d 6573 7361 6765  ::string message
    │ │ │ +00079dc0: 3b0a 0a09 092f 2f20 6966 2074 6869 7320  ;....// if this 
    │ │ │ +00079dd0: 7472 6163 6b65 7220 6661 696c 6564 2074  tracker failed t
    │ │ │ +00079de0: 6865 206c 6173 7420 7469 6d65 2069 7420  he last time it 
    │ │ │ +00079df0: 7761 7320 636f 6e74 6163 7465 640a 0909  was contacted...
    │ │ │ +00079e00: 2f2f 2074 6869 7320 6572 726f 7220 636f  // this error co
    │ │ │ +00079e10: 6465 2073 7065 6369 6669 6573 2077 6861  de specifies wha
    │ │ │ +00079e20: 7420 6572 726f 7220 6f63 6375 7272 6564  t error occurred
    │ │ │ +00079e30: 0a09 0965 7272 6f72 5f63 6f64 6520 6c61  ...error_code la
    │ │ │ +00079e40: 7374 5f65 7272 6f72 3b0a 0a09 092f 2f20  st_error;....// 
    │ │ │ +00079e50: 7468 6520 7469 6d65 206f 6620 6e65 7874  the time of next
    │ │ │ +00079e60: 2074 7261 636b 6572 2061 6e6e 6f75 6e63   tracker announc
    │ │ │ +00079e70: 650a 0909 7469 6d65 5f70 6f69 6e74 3332  e...time_point32
    │ │ │ +00079e80: 206e 6578 745f 616e 6e6f 756e 6365 203d   next_announce =
    │ │ │ +00079e90: 2028 7469 6d65 5f70 6f69 6e74 3332 3a3a   (time_point32::
    │ │ │ +00079ea0: 6d69 6e29 2829 3b0a 0a09 092f 2f20 6e6f  min)();....// no
    │ │ │ +00079eb0: 2061 6e6e 6f75 6e63 6573 2062 6566 6f72   announces befor
    │ │ │ +00079ec0: 6520 7468 6973 2074 696d 650a 0909 7469  e this time...ti
    │ │ │ +00079ed0: 6d65 5f70 6f69 6e74 3332 206d 696e 5f61  me_point32 min_a
    │ │ │ +00079ee0: 6e6e 6f75 6e63 6520 3d20 2874 696d 655f  nnounce = (time_
    │ │ │ +00079ef0: 706f 696e 7433 323a 3a6d 696e 2928 293b  point32::min)();
    │ │ │ +00079f00: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +00079f30: 0a3c 2f64 6976 3e09 092f 2f20 7468 6573 .
    ..// thes │ │ │ +00079f40: 6520 6172 6520 6569 7468 6572 202d 3120 e are either -1 │ │ │ +00079f50: 6f72 2074 6865 2073 6372 6170 6520 696e or the scrape in │ │ │ +00079f60: 666f 726d 6174 696f 6e20 7468 6973 2074 formation this t │ │ │ +00079f70: 7261 636b 6572 206c 6173 740a 0909 2f2f racker last...// │ │ │ +00079f80: 2072 6573 706f 6e64 6564 2077 6974 682e responded with. │ │ │ +00079f90: 202a 696e 636f 6d70 6c65 7465 2a20 6973 *incomplete* is │ │ │ +00079fa0: 2074 6865 2063 7572 7265 6e74 206e 756d the current num │ │ │ +00079fb0: 6265 7220 6f66 2064 6f77 6e6c 6f61 6465 ber of downloade │ │ │ +00079fc0: 7273 2069 6e0a 0909 2f2f 2074 6865 2073 rs in...// the s │ │ │ +00079fd0: 7761 726d 2c20 2a63 6f6d 706c 6574 652a warm, *complete* │ │ │ +00079fe0: 2069 7320 7468 6520 6375 7272 656e 7420 is the current │ │ │ +00079ff0: 6e75 6d62 6572 206f 6620 7365 6564 7320 number of seeds │ │ │ +0007a000: 696e 2074 6865 2073 7761 726d 2061 6e64 in the swarm and │ │ │ +0007a010: 0a09 092f 2f20 2a64 6f77 6e6c 6f61 6465 ...// *downloade │ │ │ +0007a020: 642a 2069 7320 7468 6520 6375 6d75 6c61 d* is the cumula │ │ │ +0007a030: 7469 7665 206e 756d 6265 7220 6f66 2063 tive number of c │ │ │ +0007a040: 6f6d 706c 6574 6564 2064 6f77 6e6c 6f61 ompleted downloa │ │ │ +0007a050: 6473 206f 6620 7468 6973 0a09 092f 2f20 ds of this...// │ │ │ +0007a060: 746f 7272 656e 742c 2073 696e 6365 2074 torrent, since t │ │ │ +0007a070: 6865 2062 6567 696e 6e69 6e67 206f 6620 he beginning of │ │ │ +0007a080: 7469 6d65 2028 6672 6f6d 2074 6869 7320 time (from this │ │ │ +0007a090: 7472 6163 6b65 7227 7320 706f 696e 7420 tracker's point │ │ │ +0007a0a0: 6f66 0a09 092f 2f20 7669 6577 292e 0a0a of...// view)... │ │ │ +0007a0b0: 0909 2f2f 2069 6620 7468 6973 2074 7261 ..// if this tra │ │ │ +0007a0c0: 636b 6572 2068 6173 2072 6574 7572 6e65 cker has returne │ │ │ +0007a0d0: 6420 7363 7261 7065 2064 6174 612c 2074 d scrape data, t │ │ │ +0007a0e0: 6865 7365 2066 6965 6c64 7320 6172 6520 hese fields are │ │ │ +0007a0f0: 6669 6c6c 6564 2069 6e0a 0909 2f2f 2077 filled in...// w │ │ │ +0007a100: 6974 6820 7661 6c69 6420 6e75 6d62 6572 ith valid number │ │ │ +0007a110: 732e 204f 7468 6572 7769 7365 2074 6865 s. Otherwise the │ │ │ +0007a120: 7920 6172 6520 7365 7420 746f 202d 312e y are set to -1. │ │ │ +0007a130: 2060 6069 6e63 6f6d 706c 6574 6560 6020 ``incomplete`` │ │ │ +0007a140: 636f 756e 7473 0a09 092f 2f20 7468 6520 counts...// the │ │ │ +0007a150: 6e75 6d62 6572 206f 6620 6375 7272 656e number of curren │ │ │ +0007a160: 7420 646f 776e 6c6f 6164 6572 732e 2060 t downloaders. ` │ │ │ +0007a170: 6063 6f6d 706c 6574 6560 6020 636f 756e `complete`` coun │ │ │ +0007a180: 7473 2074 6865 206e 756d 6265 7220 6f66 ts the number of │ │ │ +0007a190: 0a09 092f 2f20 6375 7272 656e 7420 7065 ...// current pe │ │ │ +0007a1a0: 6572 7320 636f 6d70 6c65 7465 6420 7468 ers completed th │ │ │ +0007a1b0: 6520 646f 776e 6c6f 6164 2c20 6f72 2022 e download, or " │ │ │ +0007a1c0: 7365 6564 7322 2e20 6060 646f 776e 6c6f seeds". ``downlo │ │ │ +0007a1d0: 6164 6564 6060 2069 7320 7468 650a 0909 aded`` is the... │ │ │ +0007a1e0: 2f2f 2063 756d 756c 6174 6976 6520 6e75 // cumulative nu │ │ │ +0007a1f0: 6d62 6572 206f 6620 636f 6d70 6c65 7465 mber of complete │ │ │ +0007a200: 6420 646f 776e 6c6f 6164 732e 0a09 0969 d downloads....i │ │ │ +0007a210: 6e74 2073 6372 6170 655f 696e 636f 6d70 nt scrape_incomp │ │ │ +0007a220: 6c65 7465 203d 202d 313b 0a09 0969 6e74 lete = -1;...int │ │ │ +0007a230: 2073 6372 6170 655f 636f 6d70 6c65 7465 scrape_complete │ │ │ +0007a240: 203d 202d 313b 0a09 0969 6e74 2073 6372 = -1;...int scr │ │ │ +0007a250: 6170 655f 646f 776e 6c6f 6164 6564 203d ape_downloaded = │ │ │ +0007a260: 202d 313b 0a0a 0909 2f2f 2074 6865 206e -1;....// the n │ │ │ +0007a270: 756d 6265 7220 6f66 2074 696d 6573 2069 umber of times i │ │ │ +0007a280: 6e20 6120 726f 7720 7765 2068 6176 6520 n a row we have │ │ │ +0007a290: 6661 696c 6564 2074 6f20 616e 6e6f 756e failed to announ │ │ │ +0007a2a0: 6365 2074 6f20 7468 6973 0a09 092f 2f20 ce to this...// │ │ │ +0007a2b0: 7472 6163 6b65 722e 0a09 0973 7464 3a3a tracker....std:: │ │ │ +0007a2c0: 7569 6e74 385f 7420 6661 696c 7320 3a20 uint8_t fails : │ │ │ +0007a2d0: 373b 0a0a 0909 2f2f 2074 7275 6520 7768 7;....// true wh │ │ │ +0007a2e0: 696c 6520 7765 2772 6520 7761 6974 696e ile we're waitin │ │ │ +0007a2f0: 6720 666f 7220 6120 7265 7370 6f6e 7365 g for a response │ │ │ +0007a300: 2066 726f 6d20 7468 6520 7472 6163 6b65 from the tracke │ │ │ +0007a310: 722e 0a09 0962 6f6f 6c20 7570 6461 7469 r....bool updati │ │ │ +0007a320: 6e67 203a 2031 3b0a 0a09 092f 2f20 7365 ng : 1;....// se │ │ │ +0007a330: 7420 746f 2074 7275 6520 7768 656e 2077 t to true when w │ │ │ +0007a340: 6520 6765 7420 6120 7661 6c69 6420 7265 e get a valid re │ │ │ +0007a350: 7370 6f6e 7365 2066 726f 6d20 616e 2061 sponse from an a │ │ │ +0007a360: 6e6e 6f75 6e63 650a 0909 2f2f 2077 6974 nnounce...// wit │ │ │ +0007a370: 6820 6576 656e 743d 7374 6172 7465 642e h event=started. │ │ │ +0007a380: 2049 6620 6974 2069 7320 7365 742c 2077 If it is set, w │ │ │ +0007a390: 6520 776f 6e27 7420 7365 6e64 2073 7461 e won't send sta │ │ │ +0007a3a0: 7274 2069 6e20 7468 6520 7375 6273 6571 rt in the subseq │ │ │ +0007a3b0: 7565 6e74 0a09 092f 2f20 616e 6e6f 756e uent...// announ │ │ │ +0007a3c0: 6365 732e 0a09 0962 6f6f 6c20 7374 6172 ces....bool star │ │ │ +0007a3d0: 745f 7365 6e74 203a 2031 3b0a 0a09 092f t_sent : 1;..../ │ │ │ +0007a3e0: 2f20 7365 7420 746f 2074 7275 6520 7768 / set to true wh │ │ │ +0007a3f0: 656e 2077 6520 7365 6e64 2061 2065 7665 en we send a eve │ │ │ +0007a400: 6e74 3d63 6f6d 706c 6574 6564 2e0a 0909 nt=completed.... │ │ │ +0007a410: 626f 6f6c 2063 6f6d 706c 6574 655f 7365 bool complete_se │ │ │ +0007a420: 6e74 203a 2031 3b0a 3c2f 7072 653e 3c2f nt : 1;.
    relevan │ │ │ +0007a460: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../include/li │ │ │ +0007a4a0: 6274 6f72 7265 6e74 2f61 7578 5f2f 6465 btorrent/aux_/de │ │ │ +0007a4b0: 7072 6563 6174 6564 2e68 7070 3a34 373c precated.hpp:47< │ │ │ +0007a4c0: 2f61 3e3c 2f74 643e 3c74 643e 6669 6775 /a>figu │ │ │ +0007a4d0: 7265 206f 7574 2077 6869 6368 2076 6572 re out which ver │ │ │ +0007a4e0: 7369 6f6e 206f 6620 636c 616e 6720 7468 sion of clang th │ │ │ +0007a4f0: 6973 2069 7320 7375 7070 6f72 7465 6420 is is supported │ │ │ +0007a500: 696e 3c2f 7464 3e3c 2f74 723e 3c74 7220 in

    │ │ │ +0007a550: 6669 6775 7265 206f 7574 2077 6869 6368 figure out which │ │ │ +0007a560: 2076 6572 7369 6f6e 206f 6620 636c 616e version of clan │ │ │ +0007a570: 6720 7468 6973 2069 7320 7375 7070 6f72 g this is suppor │ │ │ +0007a580: 7465 6420 696e 3c2f 6832 3e3c 6834 3e2e ted in

    . │ │ │ +0007a590: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ +0007a5a0: 7265 6e74 2f61 7578 5f2f 6465 7072 6563 rent/aux_/deprec │ │ │ +0007a5b0: 6174 6564 2e68 7070 3a34 373c 2f68 343e ated.hpp:47

    │ │ │ +0007a5c0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    CONTRA
    │ │ │ +0007a600: 4354 2c20 5354 5249 4354 204c 4941 4249  CT, STRICT LIABI
    │ │ │ +0007a610: 4c49 5459 2c20 4f52 2054 4f52 5420 2849  LITY, OR TORT (I
    │ │ │ +0007a620: 4e43 4c55 4449 4e47 204e 4547 4c49 4745  NCLUDING NEGLIGE
    │ │ │ +0007a630: 4e43 4520 4f52 204f 5448 4552 5749 5345  NCE OR OTHERWISE
    │ │ │ +0007a640: 290a 4152 4953 494e 4720 494e 2041 4e59  ).ARISING IN ANY
    │ │ │ +0007a650: 2057 4159 204f 5554 204f 4620 5448 4520   WAY OUT OF THE 
    │ │ │ +0007a660: 5553 4520 4f46 2054 4849 5320 534f 4654  USE OF THIS SOFT
    │ │ │ +0007a670: 5741 5245 2c20 4556 454e 2049 4620 4144  WARE, EVEN IF AD
    │ │ │ +0007a680: 5649 5345 4420 4f46 2054 4845 0a50 4f53  VISED OF THE.POS
    │ │ │ +0007a690: 5349 4249 4c49 5459 204f 4620 5355 4348  SIBILITY OF SUCH
    │ │ │ +0007a6a0: 2044 414d 4147 452e 0a0a 2a2f 0a0a 2369   DAMAGE...*/..#i
    │ │ │ +0007a6b0: 666e 6465 6620 544f 5252 454e 545f 4445  fndef TORRENT_DE
    │ │ │ +0007a6c0: 5052 4543 4154 4544 5f48 5050 5f49 4e43  PRECATED_HPP_INC
    │ │ │ +0007a6d0: 4c55 4445 440a 2364 6566 696e 6520 544f  LUDED.#define TO
    │ │ │ +0007a6e0: 5252 454e 545f 4445 5052 4543 4154 4544  RRENT_DEPRECATED
    │ │ │ +0007a6f0: 5f48 5050 5f49 4e43 4c55 4445 440a 0a23  _HPP_INCLUDED..#
    │ │ │ +0007a700: 6966 2021 6465 6669 6e65 6420 544f 5252  if !defined TORR
    │ │ │ +0007a710: 454e 545f 4255 494c 4449 4e47 5f4c 4942  ENT_BUILDING_LIB
    │ │ │ +0007a720: 5241 5259 0a23 2064 6566 696e 6520 544f  RARY.# define TO
    │ │ │ +0007a730: 5252 454e 545f 4445 5052 4543 4154 4544  RRENT_DEPRECATED
    │ │ │ +0007a740: 205b 5b64 6570 7265 6361 7465 645d 5d0a   [[deprecated]].
    │ │ │ +0007a750: 2365 6c73 650a 2320 6465 6669 6e65 2054  #else.# define T
    │ │ │ +0007a760: 4f52 5245 4e54 5f44 4550 5245 4341 5445  ORRENT_DEPRECATE
    │ │ │ +0007a770: 440a 2365 6e64 6966 0a0a 2369 6620 6465  D.#endif..#if de
    │ │ │ +0007a780: 6669 6e65 6420 5f5f 636c 616e 675f 5f0a  fined __clang__.
    │ │ │ +0007a790: 0a2f 2f20 3d3d 3d3d 3d3d 2043 4c41 4e47  .// ====== CLANG
    │ │ │ +0007a7a0: 203d 3d3d 3d3d 3d3d 3d0a 0a23 2069 6620   ========..# if 
    │ │ │ +0007a7b0: 2164 6566 696e 6564 2054 4f52 5245 4e54  !defined TORRENT
    │ │ │ +0007a7c0: 5f42 5549 4c44 494e 475f 4c49 4252 4152  _BUILDING_LIBRAR
    │ │ │ +0007a7d0: 590a 3c64 6976 2073 7479 6c65 3d22 6261  Y.
    │ │ │ +0007a800: 2320 2064 6566 696e 6520 544f 5252 454e # define TORREN │ │ │ +0007a810: 545f 4445 5052 4543 4154 4544 5f45 4e55 T_DEPRECATED_ENU │ │ │ +0007a820: 4d20 5f5f 6174 7472 6962 7574 655f 5f20 M __attribute__ │ │ │ +0007a830: 2828 6465 7072 6563 6174 6564 2929 0a3c ((deprecated)).< │ │ │ +0007a840: 2f64 6976 3e23 2065 6e64 6966 0a0a 2365 /div># endif..#e │ │ │ +0007a850: 6c69 6620 6465 6669 6e65 6420 5f5f 474e lif defined __GN │ │ │ +0007a860: 5543 5f5f 0a0a 2f2f 203d 3d3d 3d3d 3d3d UC__..// ======= │ │ │ +0007a870: 3d20 4743 4320 3d3d 3d3d 3d3d 3d3d 0a0a = GCC ========.. │ │ │ +0007a880: 2f2f 2064 6570 7265 6361 7469 6f6e 206d // deprecation m │ │ │ +0007a890: 6172 6b75 7020 6973 206f 6e6c 7920 656e arkup is only en │ │ │ +0007a8a0: 6162 6c65 6420 7768 656e 206c 6962 746f abled when libto │ │ │ +0007a8b0: 7272 656e 740a 2f2f 2068 6561 6465 7273 rrent.// headers │ │ │ +0007a8c0: 2061 7265 2069 6e63 6c75 6465 6420 6279 are included by │ │ │ +0007a8d0: 2063 6c69 656e 7473 2c20 6e6f 7420 7768 clients, not wh │ │ │ +0007a8e0: 696c 6520 6275 696c 6469 6e67 0a2f 2f20 ile building.// │ │ │ +0007a8f0: 6c69 6274 6f72 7265 6e74 2069 7473 656c libtorrent itsel │ │ │ +0007a900: 660a 2320 6966 205f 5f47 4e55 435f 5f20 f.# if __GNUC__ │ │ │ +0007a910: 2667 743b 3d20 3620 2661 6d70 3b26 616d >= 6 &&am │ │ │ +0007a920: 703b 2021 6465 6669 6e65 6420 544f 5252 p; !defined TORR │ │ │ +0007a930: 454e 545f 4255 494c 4449 4e47 5f4c 4942 ENT_BUILDING_LIB │ │ │ +0007a940: 5241 5259 0a23 2020 6465 6669 6e65 2054 RARY.# define T │ │ │ +0007a950: 4f52 5245 4e54 5f44 4550 5245 4341 5445 ORRENT_DEPRECATE │ │ │ +0007a960: 445f 454e 554d 205f 5f61 7474 7269 6275 D_ENUM __attribu │ │ │ +0007a970: 7465 5f5f 2028 2864 6570 7265 6361 7465 te__ ((deprecate │ │ │ +0007a980: 6429 290a 2320 656e 6469 660a 0a23 656e d)).# endif..#en │ │ │ +0007a990: 6469 660a 0a23 6966 6e64 6566 2054 4f52 dif..#ifndef TOR │ │ │ +0007a9a0: 5245 4e54 5f44 4550 5245 4341 5445 445f RENT_DEPRECATED_ │ │ │ +0007a9b0: 454e 554d 0a23 6465 6669 6e65 2054 4f52 ENUM.#define TOR │ │ │ +0007a9c0: 5245 4e54 5f44 4550 5245 4341 5445 445f RENT_DEPRECATED_ │ │ │ +0007a9d0: 454e 554d 0a23 656e 6469 660a 0a23 656e ENUM.#endif..#en │ │ │ +0007a9e0: 6469 660a 3c2f 7072 653e 3c2f 7464 3e3c dif.
    < │ │ │ +0007a9f0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +0007aa20: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0
    . │ │ │ +0007aa50: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ +0007aa60: 7265 6e74 2f61 7578 5f2f 7365 7373 696f rent/aux_/sessio │ │ │ +0007aa70: 6e5f 696e 7465 7266 6163 652e 6870 703a n_interface.hpp: │ │ │ +0007aa80: 3231 323c 2f61 3e3c 2f74 643e 3c74 643e 212 │ │ │ +0007aa90: 6974 2077 6f75 6c64 2062 6520 6e69 6365 it would be nice │ │ │ +0007aaa0: 2074 6f20 6e6f 7420 6861 7665 2074 6869 to not have thi │ │ │ +0007aab0: 7320 6265 2070 6172 7420 6f66 2073 6573 s be part of ses │ │ │ +0007aac0: 7369 6f6e 5f69 6e74 6572 6661 6365 3c2f sion_interface

    it w │ │ │ +0007ab20: 6f75 6c64 2062 6520 6e69 6365 2074 6f20 ould be nice to │ │ │ +0007ab30: 6e6f 7420 6861 7665 2074 6869 7320 6265 not have this be │ │ │ +0007ab40: 2070 6172 7420 6f66 2073 6573 7369 6f6e part of session │ │ │ +0007ab50: 5f69 6e74 6572 6661 6365 3c2f 6832 3e3c _interface

    < │ │ │ +0007ab60: 6834 3e2e 2e2f 696e 636c 7564 652f 6c69 h4>../include/li │ │ │ +0007ab70: 6274 6f72 7265 6e74 2f61 7578 5f2f 7365 btorrent/aux_/se │ │ │ +0007ab80: 7373 696f 6e5f 696e 7465 7266 6163 652e ssion_interface. │ │ │ +0007ab90: 6870 703a 3231 323c 2f68 343e 3c70 7265 hpp:212
    ..virtual 
    │ │ │ +0007abe0: 766f 6964 2064 6566 6572 7265 645f 7375  void deferred_su
    │ │ │ +0007abf0: 626d 6974 5f6a 6f62 7328 2920 3d20 303b  bmit_jobs() = 0;
    │ │ │ +0007ac00: 0a0a 0909 7669 7274 7561 6c20 7374 643a  ....virtual std:
    │ │ │ +0007ac10: 3a75 696e 7431 365f 7420 6c69 7374 656e  :uint16_t listen
    │ │ │ +0007ac20: 5f70 6f72 7428 2920 636f 6e73 7420 3d20  _port() const = 
    │ │ │ +0007ac30: 303b 0a09 0976 6972 7475 616c 2073 7464  0;...virtual std
    │ │ │ +0007ac40: 3a3a 7569 6e74 3136 5f74 2073 736c 5f6c  ::uint16_t ssl_l
    │ │ │ +0007ac50: 6973 7465 6e5f 706f 7274 2829 2063 6f6e  isten_port() con
    │ │ │ +0007ac60: 7374 203d 2030 3b0a 0a09 0976 6972 7475  st = 0;....virtu
    │ │ │ +0007ac70: 616c 2069 6e74 206c 6973 7465 6e5f 706f  al int listen_po
    │ │ │ +0007ac80: 7274 2861 7578 3a3a 7472 616e 7370 6f72  rt(aux::transpor
    │ │ │ +0007ac90: 7420 7373 6c2c 2061 6464 7265 7373 2063  t ssl, address c
    │ │ │ +0007aca0: 6f6e 7374 2661 6d70 3b20 6c6f 6361 6c5f  onst& local_
    │ │ │ +0007acb0: 6164 6472 2920 3d20 303b 0a0a 0909 7669  addr) = 0;....vi
    │ │ │ +0007acc0: 7274 7561 6c20 766f 6964 2066 6f72 5f65  rtual void for_e
    │ │ │ +0007acd0: 6163 685f 6c69 7374 656e 5f73 6f63 6b65  ach_listen_socke
    │ │ │ +0007ace0: 7428 7374 643a 3a66 756e 6374 696f 6e26  t(std::function&
    │ │ │ +0007acf0: 6c74 3b76 6f69 6428 6175 783a 3a6c 6973  lt;void(aux::lis
    │ │ │ +0007ad00: 7465 6e5f 736f 636b 6574 5f68 616e 646c  ten_socket_handl
    │ │ │ +0007ad10: 6520 636f 6e73 7426 616d 703b 2926 6774  e const&)>
    │ │ │ +0007ad20: 3b20 6629 203d 2030 3b0a 0a09 092f 2f20  ; f) = 0;....// 
    │ │ │ +0007ad30: 6173 6b20 666f 7220 7768 6963 6820 696e  ask for which in
    │ │ │ +0007ad40: 7465 7266 6163 6520 616e 6420 706f 7274  terface and port
    │ │ │ +0007ad50: 2074 6f20 6269 6e64 206f 7574 676f 696e   to bind outgoin
    │ │ │ +0007ad60: 6720 7065 6572 2063 6f6e 6e65 6374 696f  g peer connectio
    │ │ │ +0007ad70: 6e73 206f 6e0a 0909 7669 7274 7561 6c20  ns on...virtual 
    │ │ │ +0007ad80: 7463 703a 3a65 6e64 706f 696e 7420 6269  tcp::endpoint bi
    │ │ │ +0007ad90: 6e64 5f6f 7574 676f 696e 675f 736f 636b  nd_outgoing_sock
    │ │ │ +0007ada0: 6574 2873 6f63 6b65 745f 7479 7065 2661  et(socket_type&a
    │ │ │ +0007adb0: 6d70 3b20 732c 2061 6464 7265 7373 2063  mp; s, address c
    │ │ │ +0007adc0: 6f6e 7374 2661 6d70 3b0a 0909 0972 656d  onst&....rem
    │ │ │ +0007add0: 6f74 655f 6164 6472 6573 732c 2065 7272  ote_address, err
    │ │ │ +0007ade0: 6f72 5f63 6f64 6526 616d 703b 2065 6329  or_code& ec)
    │ │ │ +0007adf0: 2063 6f6e 7374 203d 2030 3b0a 0909 7669   const = 0;...vi
    │ │ │ +0007ae00: 7274 7561 6c20 626f 6f6c 2076 6572 6966  rtual bool verif
    │ │ │ +0007ae10: 795f 626f 756e 645f 6164 6472 6573 7328  y_bound_address(
    │ │ │ +0007ae20: 6164 6472 6573 7320 636f 6e73 7426 616d  address const&am
    │ │ │ +0007ae30: 703b 2061 6464 722c 2062 6f6f 6c20 7574  p; addr, bool ut
    │ │ │ +0007ae40: 700a 0909 092c 2065 7272 6f72 5f63 6f64  p...., error_cod
    │ │ │ +0007ae50: 6526 616d 703b 2065 6329 203d 2030 3b0a  e& ec) = 0;.
    │ │ │ +0007ae60: 0a23 6966 6e64 6566 2054 4f52 5245 4e54  .#ifndef TORRENT
    │ │ │ +0007ae70: 5f44 4953 4142 4c45 5f4d 5554 4142 4c45  _DISABLE_MUTABLE
    │ │ │ +0007ae80: 5f54 4f52 5245 4e54 530a 0909 7669 7274  _TORRENTS...virt
    │ │ │ +0007ae90: 7561 6c20 7374 643a 3a76 6563 746f 7226  ual std::vector&
    │ │ │ +0007aea0: 6c74 3b73 7464 3a3a 7368 6172 6564 5f70  lt;std::shared_p
    │ │ │ +0007aeb0: 7472 266c 743b 746f 7272 656e 7426 6774  tr<torrent>
    │ │ │ +0007aec0: 3b26 6774 3b20 6669 6e64 5f63 6f6c 6c65  ;> find_colle
    │ │ │ +0007aed0: 6374 696f 6e28 0a09 0909 7374 643a 3a73  ction(....std::s
    │ │ │ +0007aee0: 7472 696e 6720 636f 6e73 7426 616d 703b  tring const&
    │ │ │ +0007aef0: 2063 6f6c 6c65 6374 696f 6e29 2063 6f6e   collection) con
    │ │ │ +0007af00: 7374 203d 2030 3b0a 2365 6e64 6966 0a0a  st = 0;.#endif..
    │ │ │ +0007af10: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ +0007af40: 7669 7274 7561 6c20 7072 6f78 795f 7365 virtual proxy_se │ │ │ +0007af50: 7474 696e 6773 2070 726f 7879 2829 2063 ttings proxy() c │ │ │ +0007af60: 6f6e 7374 203d 2030 3b0a 3c2f 6469 763e onst = 0;.
    │ │ │ +0007af70: 0a23 6966 2054 4f52 5245 4e54 5f55 5345 .#if TORRENT_USE │ │ │ +0007af80: 5f49 3250 0a09 0976 6972 7475 616c 2063 _I2P...virtual c │ │ │ +0007af90: 6861 7220 636f 6e73 742a 2069 3270 5f73 har const* i2p_s │ │ │ +0007afa0: 6573 7369 6f6e 2829 2063 6f6e 7374 203d ession() const = │ │ │ +0007afb0: 2030 3b0a 0909 7669 7274 7561 6c20 7374 0;...virtual st │ │ │ +0007afc0: 643a 3a73 7472 696e 6720 636f 6e73 7426 d::string const& │ │ │ +0007afd0: 616d 703b 206c 6f63 616c 5f69 3270 5f65 amp; local_i2p_e │ │ │ +0007afe0: 6e64 706f 696e 7428 2920 636f 6e73 7420 ndpoint() const │ │ │ +0007aff0: 3d20 303b 0a23 656e 6469 660a 0a09 0976 = 0;.#endif....v │ │ │ +0007b000: 6972 7475 616c 2076 6f69 6420 7072 696f irtual void prio │ │ │ +0007b010: 7269 7469 7a65 5f63 6f6e 6e65 6374 696f ritize_connectio │ │ │ +0007b020: 6e73 2873 7464 3a3a 7765 616b 5f70 7472 ns(std::weak_ptr │ │ │ +0007b030: 266c 743b 746f 7272 656e 7426 6774 3b20 <torrent> │ │ │ +0007b040: 7429 203d 2030 3b0a 0a09 0976 6972 7475 t) = 0;....virtu │ │ │ +0007b050: 616c 2076 6f69 6420 7472 6967 6765 725f al void trigger_ │ │ │ +0007b060: 6175 746f 5f6d 616e 6167 6528 2920 3d20 auto_manage() = │ │ │ +0007b070: 303b 0a0a 0909 7669 7274 7561 6c20 766f 0;....virtual vo │ │ │ +0007b080: 6964 2061 7070 6c79 5f73 6574 7469 6e67 id apply_setting │ │ │ +0007b090: 735f 7061 636b 2873 7464 3a3a 7368 6172 s_pack(std::shar │ │ │ +0007b0a0: 6564 5f70 7472 266c 743b 7365 7474 696e ed_ptr<settin │ │ │ +0007b0b0: 6773 5f70 6163 6b26 6774 3b20 7061 636b gs_pack> pack │ │ │ +0007b0c0: 2920 3d20 303b 0a09 0976 6972 7475 616c ) = 0;...virtual │ │ │ +0007b0d0: 2073 6573 7369 6f6e 5f73 6574 7469 6e67 session_setting │ │ │ +0007b0e0: 7320 636f 6e73 7426 616d 703b 2073 6574 s const& set │ │ │ +0007b0f0: 7469 6e67 7328 2920 636f 6e73 7420 3d20 tings() const = │ │ │ +0007b100: 303b 0a0a 0909 7669 7274 7561 6c20 766f 0;....virtual vo │ │ │ +0007b110: 6964 2071 7565 7565 5f74 7261 636b 6572 id queue_tracker │ │ │ +0007b120: 5f72 6571 7565 7374 2874 7261 636b 6572 _request(tracker │ │ │ +0007b130: 5f72 6571 7565 7374 2072 6571 0a09 0909 _request req.... │ │ │ +0007b140: 2c20 7374 643a 3a77 6561 6b5f 7074 7226 , std::weak_ptr& │ │ │ +0007b150: 6c74 3b72 6571 7565 7374 5f63 616c 6c62 lt;request_callb │ │ │ +0007b160: 6163 6b26 6774 3b20 6329 203d 2030 3b0a ack> c) = 0;. │ │ │ +0007b170: 0a09 092f 2f20 7065 6572 2d63 6c61 7373 ...// peer-class │ │ │ +0007b180: 6573 0a09 0976 6972 7475 616c 2076 6f69 es...virtual voi │ │ │ +0007b190: 6420 7365 745f 7065 6572 5f63 6c61 7373 d set_peer_class │ │ │ +0007b1a0: 6573 2870 6565 725f 636c 6173 735f 7365 es(peer_class_se │ │ │ +0007b1b0: 742a 2073 2c20 6164 6472 6573 7320 636f t* s, address co │ │ │ +0007b1c0: 6e73 7426 616d 703b 2061 2c20 736f 636b nst& a, sock │ │ │ +0007b1d0: 6574 5f74 7970 655f 7420 7374 2920 3d20 et_type_t st) = │ │ │ +0007b1e0: 303b 0a09 0976 6972 7475 616c 2070 6565 0;...virtual pee │ │ │ +0007b1f0: 725f 636c 6173 735f 706f 6f6c 2063 6f6e r_class_pool con │ │ │ +0007b200: 7374 2661 6d70 3b20 7065 6572 5f63 6c61 st& peer_cla │ │ │ +0007b210: 7373 6573 2829 2063 6f6e 7374 203d 2030 sses() const = 0 │ │ │ +0007b220: 3b0a 0909 7669 7274 7561 6c20 7065 6572 ;...virtual peer │ │ │ +0007b230: 5f63 6c61 7373 5f70 6f6f 6c26 616d 703b _class_pool& │ │ │ +0007b240: 2070 6565 725f 636c 6173 7365 7328 2920 peer_classes() │ │ │ +0007b250: 3d20 303b 0a09 0976 6972 7475 616c 2062 = 0;...virtual b │ │ │ +0007b260: 6f6f 6c20 6967 6e6f 7265 5f75 6e63 686f ool ignore_uncho │ │ │ +0007b270: 6b65 5f73 6c6f 7473 5f73 6574 2870 6565 ke_slots_set(pee │ │ │ +0007b280: 725f 636c 6173 735f 7365 7420 636f 6e73 r_class_set cons │ │ │ +0007b290: 7426 616d 703b 2073 6574 2920 636f 6e73 t& set) cons │ │ │ +0007b2a0: 7420 3d20 303b 0a09 0976 6972 7475 616c t = 0;...virtual │ │ │ +0007b2b0: 2069 6e74 2063 6f70 795f 7065 7274 696e int copy_pertin │ │ │ +0007b2c0: 656e 745f 6368 616e 6e65 6c73 2870 6565 ent_channels(pee │ │ │ +0007b2d0: 725f 636c 6173 735f 7365 7420 636f 6e73 r_class_set cons │ │ │ +0007b2e0: 7426 616d 703b 2073 6574 0a09 0909 2c20 t& set...., │ │ │ +0007b2f0: 696e 7420 6368 616e 6e65 6c2c 2062 616e int channel, ban │ │ │ +0007b300: 6477 6964 7468 5f63 6861 6e6e 656c 2a2a dwidth_channel** │ │ │ +0007b310: 2064 7374 2c20 696e 7420 6d29 203d 2030 dst, int m) = 0 │ │ │ +0007b320: 3b0a 0909 7669 7274 7561 6c20 696e 7420 ;...virtual int │ │ │ +0007b330: 7573 655f 7175 6f74 615f 6f76 6572 6865 use_quota_overhe │ │ │ +0007b340: 6164 2870 6565 725f 636c 6173 735f 7365 ad(peer_class_se │ │ │ +0007b350: 7426 616d 703b 2073 6574 2c20 696e 7420 t& set, int │ │ │ +0007b360: 616d 6f75 6e74 5f64 6f77 6e2c 2069 6e74 amount_down, int │ │ │ +0007b370: 2061 6d6f 756e 745f 7570 2920 3d20 303b amount_up) = 0; │ │ │ +0007b380: 0a0a 0909 7669 7274 7561 6c20 6261 6e64 ....virtual band │ │ │ +0007b390: 7769 6474 685f 6d61 6e61 6765 722a 2067 width_manager* g │ │ │ +0007b3a0: 6574 5f62 616e 6477 6964 7468 5f6d 616e et_bandwidth_man │ │ │ +0007b3b0: 6167 6572 2869 6e74 2063 6861 6e6e 656c ager(int channel │ │ │ +0007b3c0: 2920 3d20 303b 0a0a 0909 7669 7274 7561 ) = 0;....virtua │ │ │ +0007b3d0: 6c20 766f 6964 2073 656e 745f 6279 7465 l void sent_byte │ │ │ +0007b3e0: 7328 696e 7420 6279 7465 735f 7061 796c s(int bytes_payl │ │ │ +0007b3f0: 6f61 642c 2069 6e74 2062 7974 6573 5f70 oad, int bytes_p │ │ │ +0007b400: 726f 746f 636f 6c29 203d 2030 3b0a 0909 rotocol) = 0;... │ │ │ +0007b410: 7669 7274 7561 6c20 766f 6964 2072 6563 virtual void rec │ │ │ +0007b420: 6569 7665 645f 6279 7465 7328 696e 7420 eived_bytes(int │ │ │ +0007b430: 6279 7465 735f 7061 796c 6f61 642c 2069 bytes_payload, i │ │ │ +0007b440: 6e74 2062 7974 6573 5f70 726f 746f 636f nt bytes_protoco │ │ │ +0007b450: 6c29 203d 2030 3b0a 0909 7669 7274 7561 l) = 0;...virtua │ │ │ +0007b460: 6c20 766f 6964 2074 7261 6e63 6965 7665 l void trancieve │ │ │ +0007b470: 5f69 705f 7061 636b 6574 2869 6e74 2062 _ip_packet(int b │ │ │ +0007b480: 7974 6573 2c20 626f 6f6c 2069 7076 3629 ytes, bool ipv6) │ │ │ +0007b490: 203d 2030 3b0a 3c2f 7072 653e 3c2f 7464 = 0;.
    relevance │ │ │ +0007b4d0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +0007b4e0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../include/libt │ │ │ +0007b510: 6f72 7265 6e74 2f61 7578 5f2f 616c 6c6f orrent/aux_/allo │ │ │ +0007b520: 6361 7469 6e67 5f68 616e 646c 6572 2e68 cating_handler.h │ │ │ +0007b530: 7070 3a33 3136 3c2f 613e 3c2f 7464 3e3c pp:316< │ │ │ +0007b540: 7464 3e69 6e20 432b 2b31 372c 2048 616e td>in C++17, Han │ │ │ +0007b550: 646c 6572 2061 6e64 2053 746f 7261 6765 dler and Storage │ │ │ +0007b560: 2063 6f75 6c64 206a 7573 7420 7573 6520 could just use │ │ │ +0007b570: 2261 7574 6f22 3c2f 7464 3e3c 2f74 723e "auto" │ │ │ +0007b580: 3c74 7220 6964 3d22 3237 3722 2073 7479 │ │ │ +0007b5b0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0007b5c0: 3c68 323e 696e 2043 2b2b 3137 2c20 4861

    in C++17, Ha │ │ │ +0007b5d0: 6e64 6c65 7220 616e 6420 5374 6f72 6167 ndler and Storag │ │ │ +0007b5e0: 6520 636f 756c 6420 6a75 7374 2075 7365 e could just use │ │ │ +0007b5f0: 2022 6175 746f 223c 2f68 323e 3c68 343e "auto"

    │ │ │ +0007b600: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ +0007b610: 7272 656e 742f 6175 785f 2f61 6c6c 6f63 rrent/aux_/alloc │ │ │ +0007b620: 6174 696e 675f 6861 6e64 6c65 722e 6870 ating_handler.hp │ │ │ +0007b630: 703a 3331 363c 2f68 343e 3c70 7265 2073 p:316

    ..private:..
    │ │ │ +0007b680: 0909 4861 6e64 6c65 7220 6861 6e64 6c65  ..Handler handle
    │ │ │ +0007b690: 723b 0a09 0968 616e 646c 6572 5f73 746f  r;...handler_sto
    │ │ │ +0007b6a0: 7261 6765 266c 743b 5369 7a65 2c20 4e61  rage<Size, Na
    │ │ │ +0007b6b0: 6d65 2667 743b 2a20 7374 6f72 6167 653b  me>* storage;
    │ │ │ +0007b6c0: 0a23 6966 6e64 6566 2042 4f4f 5354 5f4e  .#ifndef BOOST_N
    │ │ │ +0007b6d0: 4f5f 4558 4345 5054 494f 4e53 0a09 0965  O_EXCEPTIONS...e
    │ │ │ +0007b6e0: 7272 6f72 5f68 616e 646c 6572 5f69 6e74  rror_handler_int
    │ │ │ +0007b6f0: 6572 6661 6365 2a20 6572 726f 725f 6861  erface* error_ha
    │ │ │ +0007b700: 6e64 6c65 723b 0a23 656e 6469 660a 097d  ndler;.#endif..}
    │ │ │ +0007b710: 3b0a 0a09 7465 6d70 6c61 7465 2026 6c74  ;...template <
    │ │ │ +0007b720: 3b63 6c61 7373 2048 616e 646c 6572 2c20  ;class Handler, 
    │ │ │ +0007b730: 7369 7a65 5f74 2053 697a 652c 2048 616e  size_t Size, Han
    │ │ │ +0007b740: 646c 6572 4e61 6d65 204e 616d 6526 6774  dlerName Name>
    │ │ │ +0007b750: 3b0a 0961 7578 3a3a 616c 6c6f 6361 7469  ;..aux::allocati
    │ │ │ +0007b760: 6e67 5f68 616e 646c 6572 266c 743b 4861  ng_handler<Ha
    │ │ │ +0007b770: 6e64 6c65 722c 2053 697a 652c 204e 616d  ndler, Size, Nam
    │ │ │ +0007b780: 6526 6774 3b0a 096d 616b 655f 6861 6e64  e>..make_hand
    │ │ │ +0007b790: 6c65 7228 4861 6e64 6c65 7220 6861 6e64  ler(Handler hand
    │ │ │ +0007b7a0: 6c65 720a 0909 2c20 6861 6e64 6c65 725f  ler..., handler_
    │ │ │ +0007b7b0: 7374 6f72 6167 6526 6c74 3b53 697a 652c  storage<Size,
    │ │ │ +0007b7c0: 204e 616d 6526 6774 3b26 616d 703b 2073   Name>& s
    │ │ │ +0007b7d0: 746f 7261 6765 0a09 092c 2065 7272 6f72  torage..., error
    │ │ │ +0007b7e0: 5f68 616e 646c 6572 5f69 6e74 6572 6661  _handler_interfa
    │ │ │ +0007b7f0: 6365 2661 6d70 3b20 6572 725f 6861 6e64  ce& err_hand
    │ │ │ +0007b800: 6c65 7229 0a09 7b0a 0909 7265 7475 726e  ler)..{...return
    │ │ │ +0007b810: 2061 7578 3a3a 616c 6c6f 6361 7469 6e67   aux::allocating
    │ │ │ +0007b820: 5f68 616e 646c 6572 266c 743b 4861 6e64  _handler<Hand
    │ │ │ +0007b830: 6c65 722c 2053 697a 652c 204e 616d 6526  ler, Size, Name&
    │ │ │ +0007b840: 6774 3b28 0a09 0909 7374 643a 3a66 6f72  gt;(....std::for
    │ │ │ +0007b850: 7761 7264 266c 743b 4861 6e64 6c65 7226  ward<Handler&
    │ │ │ +0007b860: 6774 3b28 6861 6e64 6c65 7229 2c20 2661  gt;(handler), &a
    │ │ │ +0007b870: 6d70 3b73 746f 7261 6765 2c20 2661 6d70  mp;storage, &
    │ │ │ +0007b880: 3b65 7272 5f68 616e 646c 6572 293b 0a09  ;err_handler);..
    │ │ │ +0007b890: 7d0a 0a3c 6469 7620 7374 796c 653d 2262  }..
    .template <t │ │ │ +0007b8d0: 7970 656e 616d 6520 540a 3c2f 6469 763e ypename T.
    │ │ │ +0007b8e0: 0909 2c20 7479 7065 6e61 6d65 2048 616e .., typename Han │ │ │ +0007b8f0: 646c 6572 5479 7065 0a09 092c 2048 616e dlerType..., Han │ │ │ +0007b900: 646c 6572 5479 7065 2048 616e 646c 6572 dlerType Handler │ │ │ +0007b910: 0a09 092c 2076 6f69 6420 2854 3a3a 2a45 ..., void (T::*E │ │ │ +0007b920: 7272 6f72 4861 6e64 6c65 7229 2865 7272 rrorHandler)(err │ │ │ +0007b930: 6f72 5f63 6f64 6520 636f 6e73 7426 616d or_code const&am │ │ │ +0007b940: 703b 290a 0909 2c20 766f 6964 2028 543a p;)..., void (T: │ │ │ +0007b950: 3a2a 4578 6365 7074 4861 6e64 6c65 7229 :*ExceptHandler) │ │ │ +0007b960: 2873 7464 3a3a 6578 6365 7074 696f 6e20 (std::exception │ │ │ +0007b970: 636f 6e73 7426 616d 703b 290a 0909 2c20 const&)..., │ │ │ +0007b980: 7479 7065 6e61 6d65 2053 746f 7261 6765 typename Storage │ │ │ +0007b990: 5479 7065 0a09 092c 2053 746f 7261 6765 Type..., Storage │ │ │ +0007b9a0: 5479 7065 2054 3a3a 2a20 5374 6f72 6167 Type T::* Storag │ │ │ +0007b9b0: 6526 6774 3b0a 0973 7472 7563 7420 6861 e>..struct ha │ │ │ +0007b9c0: 6e64 6c65 720a 097b 0a09 0965 7870 6c69 ndler..{...expli │ │ │ +0007b9d0: 6369 7420 6861 6e64 6c65 7228 7374 643a cit handler(std: │ │ │ +0007b9e0: 3a73 6861 7265 645f 7074 7226 6c74 3b54 :shared_ptr<T │ │ │ +0007b9f0: 2667 743b 2070 2920 3a20 7074 725f 2873 > p) : ptr_(s │ │ │ +0007ba00: 7464 3a3a 6d6f 7665 2870 2929 207b 7d0a td::move(p)) {}. │ │ │ +0007ba10: 0a09 0973 7464 3a3a 7368 6172 6564 5f70 ...std::shared_p │ │ │ +0007ba20: 7472 266c 743b 5426 6774 3b20 7074 725f tr<T> ptr_ │ │ │ +0007ba30: 3b0a 0a09 0974 656d 706c 6174 6520 266c ;....template &l │ │ │ +0007ba40: 743b 636c 6173 732e 2e2e 2041 2667 743b t;class... A> │ │ │ +0007ba50: 0a09 0976 6f69 6420 6f70 6572 6174 6f72 ...void operator │ │ │ +0007ba60: 2829 2841 2661 6d70 3b26 616d 703b 2e2e ()(A&&.. │ │ │ +0007ba70: 2e20 6129 0a09 097b 0a23 6966 6465 6620 . a)...{.#ifdef │ │ │ +0007ba80: 424f 4f53 545f 4e4f 5f45 5843 4550 5449 BOOST_NO_EXCEPTI │ │ │ +0007ba90: 4f4e 530a 0909 0928 7074 725f 2e67 6574 ONS....(ptr_.get │ │ │ +0007baa0: 2829 2d26 6774 3b2a 4861 6e64 6c65 7229 ()->*Handler) │ │ │ +0007bab0: 2873 7464 3a3a 666f 7277 6172 6426 6c74 (std::forward< │ │ │ +0007bac0: 3b41 2667 743b 2861 292e 2e2e 293b 0a23 ;A>(a)...);.# │ │ │ +0007bad0: 656c 7365 0a09 0909 7472 790a 0909 097b else....try....{ │ │ │ +0007bae0: 0a09 0909 0928 7074 725f 2e67 6574 2829 .....(ptr_.get() │ │ │ +0007baf0: 2d26 6774 3b2a 4861 6e64 6c65 7229 2873 ->*Handler)(s │ │ │ +0007bb00: 7464 3a3a 666f 7277 6172 6426 6c74 3b41 td::forward<A │ │ │ +0007bb10: 2667 743b 2861 292e 2e2e 293b 0a09 0909 >(a)...);.... │ │ │ +0007bb20: 7d0a 0909 0963 6174 6368 2028 7379 7374 }....catch (syst │ │ │ +0007bb30: 656d 5f65 7272 6f72 2063 6f6e 7374 2661 em_error const&a │ │ │ +0007bb40: 6d70 3b20 6529 0a09 0909 7b0a 0909 0909 mp; e)....{..... │ │ │ +0007bb50: 2870 7472 5f2e 6765 7428 292d 2667 743b (ptr_.get()-> │ │ │ +0007bb60: 2a45 7272 6f72 4861 6e64 6c65 7229 2865 *ErrorHandler)(e │ │ │ +0007bb70: 2e63 6f64 6528 2929 3b0a 0909 097d 0a09 .code());....}.. │ │ │ +0007bb80: 0909 6361 7463 6820 2873 7464 3a3a 6578 ..catch (std::ex │ │ │ +0007bb90: 6365 7074 696f 6e20 636f 6e73 7426 616d ception const&am │ │ │ +0007bba0: 703b 2065 290a 0909 097b 0a09 0909 0928 p; e)....{.....( │ │ │ +0007bbb0: 7074 725f 2e67 6574 2829 2d26 6774 3b2a ptr_.get()->* │ │ │ +0007bbc0: 4578 6365 7074 4861 6e64 6c65 7229 2865 ExceptHandler)(e │ │ │ +0007bbd0: 293b 0a09 0909 7d0a 3c2f 7072 653e 3c2f );....}.
    relevan │ │ │ +0007bc10: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../include/li │ │ │ +0007bc50: 6274 6f72 7265 6e74 2f61 7578 5f2f 7365 btorrent/aux_/se │ │ │ +0007bc60: 7373 696f 6e5f 696d 706c 2e68 7070 3a32 ssion_impl.hpp:2 │ │ │ +0007bc70: 3635 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 65m │ │ │ +0007bc80: 616b 6520 7468 6573 6520 6469 7265 6374 ake these direct │ │ │ +0007bc90: 206d 656d 6265 7273 2061 6e64 2067 656e members and gen │ │ │ +0007bca0: 6572 6174 6520 7368 6172 6564 5f70 7472 erate shared_ptr │ │ │ +0007bcb0: 7320 746f 2074 6865 6d20 7768 6963 6820 s to them which │ │ │ +0007bcc0: 616c 6961 7320 7468 6520 6c69 7374 656e alias the listen │ │ │ +0007bcd0: 5f73 6f63 6b65 745f 7420 7368 6172 6564 _socket_t shared │ │ │ +0007bce0: 5f70 7472 3c2f 7464 3e3c 2f74 723e 3c74 _ptrmake these dir │ │ │ +0007bd40: 6563 7420 6d65 6d62 6572 7320 616e 6420 ect members and │ │ │ +0007bd50: 6765 6e65 7261 7465 2073 6861 7265 645f generate shared_ │ │ │ +0007bd60: 7074 7273 2074 6f20 7468 656d 0a77 6869 ptrs to them.whi │ │ │ +0007bd70: 6368 2061 6c69 6173 2074 6865 206c 6973 ch alias the lis │ │ │ +0007bd80: 7465 6e5f 736f 636b 6574 5f74 2073 6861 ten_socket_t sha │ │ │ +0007bd90: 7265 645f 7074 723c 2f68 323e 3c68 343e red_ptr

    │ │ │ +0007bda0: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ +0007bdb0: 7272 656e 742f 6175 785f 2f73 6573 7369 rrent/aux_/sessi │ │ │ +0007bdc0: 6f6e 5f69 6d70 6c2e 6870 703a 3236 353c on_impl.hpp:265< │ │ │ +0007bdd0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +0007be10: 0969 6620 2875 6470 5f73 6f63 6b29 2072  .if (udp_sock) r
    │ │ │ +0007be20: 6574 7572 6e20 7564 705f 736f 636b 2d26  eturn udp_sock-&
    │ │ │ +0007be30: 6774 3b73 6f63 6b2e 6c6f 6361 6c5f 706f  gt;sock.local_po
    │ │ │ +0007be40: 7274 2829 3b0a 0909 0972 6574 7572 6e20  rt();....return 
    │ │ │ +0007be50: 303b 0a09 097d 0a0a 0909 2f2f 2030 2069  0;...}....// 0 i
    │ │ │ +0007be60: 7320 6e61 7470 6d70 2031 2069 7320 7570  s natpmp 1 is up
    │ │ │ +0007be70: 6e70 0a09 092f 2f20 7468 6520 6f72 6465  np...// the orde
    │ │ │ +0007be80: 7220 6f66 2074 6865 7365 2061 7272 6179  r of these array
    │ │ │ +0007be90: 7320 6465 7465 726d 696e 6573 2074 6865  s determines the
    │ │ │ +0007bea0: 2070 7269 6f72 6974 7920 696e 0a09 092f   priority in.../
    │ │ │ +0007beb0: 2f20 7768 6963 6820 7468 6569 7220 706f  / which their po
    │ │ │ +0007bec0: 7274 7320 7769 6c6c 2062 6520 616e 6e6f  rts will be anno
    │ │ │ +0007bed0: 756e 6365 6420 746f 2070 6565 7273 0a09  unced to peers..
    │ │ │ +0007bee0: 0961 7578 3a3a 6172 7261 7926 6c74 3b6c  .aux::array<l
    │ │ │ +0007bef0: 6973 7465 6e5f 706f 7274 5f6d 6170 7069  isten_port_mappi
    │ │ │ +0007bf00: 6e67 2c20 322c 2070 6f72 746d 6170 5f74  ng, 2, portmap_t
    │ │ │ +0007bf10: 7261 6e73 706f 7274 2667 743b 2074 6370  ransport> tcp
    │ │ │ +0007bf20: 5f70 6f72 745f 6d61 7070 696e 673b 0a09  _port_mapping;..
    │ │ │ +0007bf30: 0961 7578 3a3a 6172 7261 7926 6c74 3b6c  .aux::array<l
    │ │ │ +0007bf40: 6973 7465 6e5f 706f 7274 5f6d 6170 7069  isten_port_mappi
    │ │ │ +0007bf50: 6e67 2c20 322c 2070 6f72 746d 6170 5f74  ng, 2, portmap_t
    │ │ │ +0007bf60: 7261 6e73 706f 7274 2667 743b 2075 6470  ransport> udp
    │ │ │ +0007bf70: 5f70 6f72 745f 6d61 7070 696e 673b 0a0a  _port_mapping;..
    │ │ │ +0007bf80: 0909 2f2f 2069 6e64 6963 6174 6573 2077  ..// indicates w
    │ │ │ +0007bf90: 6865 7468 6572 2074 6869 7320 6973 2061  hether this is a
    │ │ │ +0007bfa0: 6e20 5353 4c20 6c69 7374 656e 2073 6f63  n SSL listen soc
    │ │ │ +0007bfb0: 6b65 7420 6f72 206e 6f74 0a09 0974 7261  ket or not...tra
    │ │ │ +0007bfc0: 6e73 706f 7274 2073 736c 203d 2074 7261  nsport ssl = tra
    │ │ │ +0007bfd0: 6e73 706f 7274 3a3a 706c 6169 6e74 6578  nsport::plaintex
    │ │ │ +0007bfe0: 743b 0a0a 0909 6c69 7374 656e 5f73 6f63  t;....listen_soc
    │ │ │ +0007bff0: 6b65 745f 666c 6167 735f 7420 666c 6167  ket_flags_t flag
    │ │ │ +0007c000: 7320 3d20 6163 6365 7074 5f69 6e63 6f6d  s = accept_incom
    │ │ │ +0007c010: 696e 673b 0a0a 0909 2f2f 2074 6865 2061  ing;....// the a
    │ │ │ +0007c020: 6374 7561 6c20 736f 636b 6574 7320 2854  ctual sockets (T
    │ │ │ +0007c030: 4350 206c 6973 7465 6e20 736f 636b 6574  CP listen socket
    │ │ │ +0007c040: 2061 6e64 2055 4450 2073 6f63 6b65 7429   and UDP socket)
    │ │ │ +0007c050: 0a09 092f 2f20 416e 2065 6e74 7279 2064  ...// An entry d
    │ │ │ +0007c060: 6f65 7320 6e6f 7420 6e65 6365 7373 6172  oes not necessar
    │ │ │ +0007c070: 696c 7920 6861 7665 2061 2055 4450 206f  ily have a UDP o
    │ │ │ +0007c080: 7220 5443 5020 736f 636b 6574 2e20 4f6e  r TCP socket. On
    │ │ │ +0007c090: 6520 6f66 2074 6865 7365 0a09 092f 2f20  e of these...// 
    │ │ │ +0007c0a0: 706f 696e 7465 7273 206d 6179 2062 6520  pointers may be 
    │ │ │ +0007c0b0: 6e75 6c6c 7074 7221 0a09 092f 2f20 5468  nullptr!...// Th
    │ │ │ +0007c0c0: 6573 6520 6d75 7374 2062 6520 7368 6172  ese must be shar
    │ │ │ +0007c0d0: 6564 5f70 7472 2074 6f20 6176 6f69 6420  ed_ptr to avoid 
    │ │ │ +0007c0e0: 6120 6461 6e67 6c69 6e67 2072 6566 6572  a dangling refer
    │ │ │ +0007c0f0: 656e 6365 2069 6620 616e 0a09 092f 2f20  ence if an...// 
    │ │ │ +0007c100: 696e 636f 6d69 6e67 2070 6163 6b65 7420  incoming packet 
    │ │ │ +0007c110: 6973 2069 6e20 7468 6520 6576 656e 7420  is in the event 
    │ │ │ +0007c120: 7175 6575 6520 7768 656e 2074 6865 2073  queue when the s
    │ │ │ +0007c130: 6f63 6b65 7420 6973 2065 7261 7365 640a  ocket is erased.
    │ │ │ +0007c140: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ +0007c170: 7374 643a 3a73 6861 7265 645f 7074 7226 std::shared_ptr& │ │ │ +0007c180: 6c74 3b74 6370 3a3a 6163 6365 7074 6f72 lt;tcp::acceptor │ │ │ +0007c190: 2667 743b 2073 6f63 6b3b 0a3c 2f64 6976 > sock;.
    ..std::shared_p │ │ │ +0007c1b0: 7472 266c 743b 6175 783a 3a73 6573 7369 tr<aux::sessi │ │ │ +0007c1c0: 6f6e 5f75 6470 5f73 6f63 6b65 7426 6774 on_udp_socket> │ │ │ +0007c1d0: 3b20 7564 705f 736f 636b 3b0a 0a09 092f ; udp_sock;..../ │ │ │ +0007c1e0: 2f20 7369 6e63 6520 7564 7020 7061 636b / since udp pack │ │ │ +0007c1f0: 6574 7320 6172 6520 6578 7065 6374 6564 ets are expected │ │ │ +0007c200: 2074 6f20 6265 2064 6973 7061 7463 6865 to be dispatche │ │ │ +0007c210: 6420 6672 6571 7565 6e74 6c79 2c20 7468 d frequently, th │ │ │ +0007c220: 6973 2073 6176 6573 0a09 092f 2f20 7469 is saves...// ti │ │ │ +0007c230: 6d65 206f 6e20 6861 6e64 6c65 7220 616c me on handler al │ │ │ +0007c240: 6c6f 6361 7469 6f6e 2065 7665 7279 2074 location every t │ │ │ +0007c250: 696d 6520 7765 2072 6561 6420 6167 6169 ime we read agai │ │ │ +0007c260: 6e2e 0a09 0961 7578 3a3a 6861 6e64 6c65 n....aux::handle │ │ │ +0007c270: 725f 7374 6f72 6167 6526 6c74 3b61 7578 r_storage<aux │ │ │ +0007c280: 3a3a 7564 705f 6861 6e64 6c65 725f 6d61 ::udp_handler_ma │ │ │ +0007c290: 785f 7369 7a65 2c20 6175 783a 3a75 6470 x_size, aux::udp │ │ │ +0007c2a0: 5f68 616e 646c 6572 2667 743b 2075 6470 _handler> udp │ │ │ +0007c2b0: 5f68 616e 646c 6572 5f73 746f 7261 6765 _handler_storage │ │ │ +0007c2c0: 3b0a 0a09 0973 7464 3a3a 7368 6172 6564 ;....std::shared │ │ │ +0007c2d0: 5f70 7472 266c 743b 6e61 7470 6d70 2667 _ptr<natpmp&g │ │ │ +0007c2e0: 743b 206e 6174 706d 705f 6d61 7070 6572 t; natpmp_mapper │ │ │ +0007c2f0: 3b0a 0909 7374 643a 3a73 6861 7265 645f ;...std::shared_ │ │ │ +0007c300: 7074 7226 6c74 3b75 706e 7026 6774 3b20 ptr<upnp> │ │ │ +0007c310: 7570 6e70 5f6d 6170 7065 723b 0a0a 0909 upnp_mapper;.... │ │ │ +0007c320: 7374 643a 3a73 6861 7265 645f 7074 7226 std::shared_ptr& │ │ │ +0007c330: 6c74 3b73 7472 7563 7420 6c73 6426 6774 lt;struct lsd> │ │ │ +0007c340: 3b20 6c73 643b 0a0a 0909 2f2f 2073 6574 ; lsd;....// set │ │ │ +0007c350: 2074 6f20 7472 7565 2077 6865 6e20 7765 to true when we │ │ │ +0007c360: 2072 6563 6569 7665 2061 6e20 696e 636f receive an inco │ │ │ +0007c370: 6d69 6e67 2063 6f6e 6e65 6374 696f 6e20 ming connection │ │ │ +0007c380: 6672 6f6d 2074 6869 7320 6c69 7374 656e from this listen │ │ │ +0007c390: 0a09 092f 2f20 736f 636b 6574 0a09 0962 ...// socket...b │ │ │ +0007c3a0: 6f6f 6c20 696e 636f 6d69 6e67 5f63 6f6e ool incoming_con │ │ │ +0007c3b0: 6e65 6374 696f 6e20 3d20 6661 6c73 653b nection = false; │ │ │ +0007c3c0: 0a09 7d3b 0a0a 0909 7374 7275 6374 2054 ..};....struct T │ │ │ +0007c3d0: 4f52 5245 4e54 5f45 5854 5241 5f45 5850 ORRENT_EXTRA_EXP │ │ │ +0007c3e0: 4f52 5420 6c69 7374 656e 5f65 6e64 706f ORT listen_endpo │ │ │ +0007c3f0: 696e 745f 740a 0909 7b0a 0909 096c 6973 int_t...{....lis │ │ │ +0007c400: 7465 6e5f 656e 6470 6f69 6e74 5f74 2861 ten_endpoint_t(a │ │ │ +0007c410: 6464 7265 7373 2063 6f6e 7374 2661 6d70 ddress const& │ │ │ +0007c420: 3b20 6164 722c 2069 6e74 2070 2c20 7374 ; adr, int p, st │ │ │ +0007c430: 643a 3a73 7472 696e 6720 6465 762c 2074 d::string dev, t │ │ │ +0007c440: 7261 6e73 706f 7274 2073 0a09 0909 092c ransport s....., │ │ │ +0007c450: 206c 6973 7465 6e5f 736f 636b 6574 5f66 listen_socket_f │ │ │ +0007c460: 6c61 6773 5f74 2066 2c20 6164 6472 6573 lags_t f, addres │ │ │ +0007c470: 7320 636f 6e73 7426 616d 703b 206e 6d61 s const& nma │ │ │ +0007c480: 736b 203d 2061 6464 7265 7373 7b7d 290a sk = address{}). │ │ │ +0007c490: 0909 0909 3a20 6164 6472 2861 6472 292c ....: addr(adr), │ │ │ +0007c4a0: 206e 6574 6d61 736b 286e 6d61 736b 292c netmask(nmask), │ │ │ +0007c4b0: 2070 6f72 7428 7029 2c20 6465 7669 6365 port(p), device │ │ │ +0007c4c0: 2873 7464 3a3a 6d6f 7665 2864 6576 2929 (std::move(dev)) │ │ │ +0007c4d0: 2c20 7373 6c28 7329 2c20 666c 6167 7328 , ssl(s), flags( │ │ │ +0007c4e0: 6629 207b 7d0a 0a09 0909 626f 6f6c 206f f) {}.....bool o │ │ │ +0007c4f0: 7065 7261 746f 723d 3d28 6c69 7374 656e perator==(listen │ │ │ +0007c500: 5f65 6e64 706f 696e 745f 7420 636f 6e73 _endpoint_t cons │ │ │ +0007c510: 7426 616d 703b 206f 2920 636f 6e73 740a t& o) const. │ │ │ +0007c520: 0909 097b 0a09 0909 0972 6574 7572 6e20 ...{.....return │ │ │ +0007c530: 6164 6472 203d 3d20 6f2e 6164 6472 0a09 addr == o.addr.. │ │ │ +0007c540: 0909 0909 2661 6d70 3b26 616d 703b 2070 ....&& p │ │ │ +0007c550: 6f72 7420 3d3d 206f 2e70 6f72 740a 0909 ort == o.port... │ │ │ +0007c560: 0909 0926 616d 703b 2661 6d70 3b20 6465 ...&& de │ │ │ +0007c570: 7669 6365 203d 3d20 6f2e 6465 7669 6365 vice == o.device │ │ │ +0007c580: 0a09 0909 0909 2661 6d70 3b26 616d 703b ......&& │ │ │ +0007c590: 2073 736c 203d 3d20 6f2e 7373 6c0a 0909 ssl == o.ssl... │ │ │ +0007c5a0: 0909 0926 616d 703b 2661 6d70 3b20 666c ...&& fl │ │ │ +0007c5b0: 6167 7320 3d3d 206f 2e66 6c61 6773 3b0a ags == o.flags;. │ │ │ +0007c5c0: 0909 097d 0a3c 2f70 7265 3e3c 2f74 643e ...}.
    │ │ │ +0007c5d0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +0007c600: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +0007c610: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +0007c620: 7074 3a65 7870 616e 6428 3237 3929 223e pt:expand(279)"> │ │ │ +0007c630: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ +0007c640: 7272 656e 742f 6175 785f 2f73 6573 7369 rrent/aux_/sessi │ │ │ +0007c650: 6f6e 5f69 6d70 6c2e 6870 703a 3130 3930 on_impl.hpp:1090 │ │ │ +0007c660: 3c2f 613e 3c2f 7464 3e3c 7464 3e72 6570 rep │ │ │ +0007c670: 6c61 6365 2074 6869 7320 6279 2061 2070 lace this by a p │ │ │ +0007c680: 726f 7065 7220 6173 696f 2074 696d 6572 roper asio timer │ │ │ +0007c690: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    re │ │ │ +0007c6e0: 706c 6163 6520 7468 6973 2062 7920 6120 place this by a │ │ │ +0007c6f0: 7072 6f70 6572 2061 7369 6f20 7469 6d65 proper asio time │ │ │ +0007c700: 723c 2f68 323e 3c68 343e 2e2e 2f69 6e63 r

    ../inc │ │ │ +0007c710: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ +0007c720: 6175 785f 2f73 6573 7369 6f6e 5f69 6d70 aux_/session_imp │ │ │ +0007c730: 6c2e 6870 703a 3130 3930 3c2f 6834 3e3c l.hpp:1090

    < │ │ │ +0007c740: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +0007c750: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +0007c760: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +0007c770: 7820 2364 6464 3b22 3e23 6966 6465 6620 x #ddd;">#ifdef │ │ │ +0007c780: 544f 5252 454e 545f 5353 4c5f 5045 4552 TORRENT_SSL_PEER │ │ │ +0007c790: 530a 0909 0976 6f69 6420 6f6e 5f69 6e63 S....void on_inc │ │ │ +0007c7a0: 6f6d 696e 675f 7574 705f 7373 6c28 736f oming_utp_ssl(so │ │ │ +0007c7b0: 636b 6574 5f74 7970 6520 7329 3b0a 0909 cket_type s);... │ │ │ +0007c7c0: 0976 6f69 6420 7373 6c5f 6861 6e64 7368 .void ssl_handsh │ │ │ +0007c7d0: 616b 6528 6572 726f 725f 636f 6465 2063 ake(error_code c │ │ │ +0007c7e0: 6f6e 7374 2661 6d70 3b20 6563 2c20 736f onst& ec, so │ │ │ +0007c7f0: 636b 6574 5f74 7970 652a 2073 293b 0a23 cket_type* s);.# │ │ │ +0007c800: 656e 6469 660a 0a09 0909 2f2f 2072 6f75 endif.....// rou │ │ │ +0007c810: 6e64 2d72 6f62 696e 2069 6e64 6578 2069 nd-robin index i │ │ │ +0007c820: 6e74 6f20 6d5f 6f75 7467 6f69 6e67 5f69 nto m_outgoing_i │ │ │ +0007c830: 6e74 6572 6661 6365 730a 0909 096d 7574 nterfaces....mut │ │ │ +0007c840: 6162 6c65 2073 7464 3a3a 7569 6e74 385f able std::uint8_ │ │ │ +0007c850: 7420 6d5f 696e 7465 7266 6163 655f 696e t m_interface_in │ │ │ +0007c860: 6465 7820 3d20 303b 0a0a 0909 0973 7464 dex = 0;.....std │ │ │ +0007c870: 3a3a 7368 6172 6564 5f70 7472 266c 743b ::shared_ptr< │ │ │ +0007c880: 6c69 7374 656e 5f73 6f63 6b65 745f 7426 listen_socket_t& │ │ │ +0007c890: 6774 3b20 7365 7475 705f 6c69 7374 656e gt; setup_listen │ │ │ +0007c8a0: 6572 280a 0909 0909 6c69 7374 656e 5f65 er(.....listen_e │ │ │ +0007c8b0: 6e64 706f 696e 745f 7420 636f 6e73 7426 ndpoint_t const& │ │ │ +0007c8c0: 616d 703b 206c 6570 2c20 6572 726f 725f amp; lep, error_ │ │ │ +0007c8d0: 636f 6465 2661 6d70 3b20 6563 293b 0a0a code& ec);.. │ │ │ +0007c8e0: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ +0007c8f0: 4449 5341 424c 455f 4448 540a 0909 0964 DISABLE_DHT....d │ │ │ +0007c900: 6874 3a3a 6468 745f 7374 6174 6520 6d5f ht::dht_state m_ │ │ │ +0007c910: 6468 745f 7374 6174 653b 0a23 656e 6469 dht_state;.#endi │ │ │ +0007c920: 660a 0a09 0909 2f2f 2074 6869 7320 6973 f.....// this is │ │ │ +0007c930: 2069 6e69 7469 616c 697a 6564 2074 6f20 initialized to │ │ │ +0007c940: 7468 6520 756e 6368 6f6b 655f 696e 7465 the unchoke_inte │ │ │ +0007c950: 7276 616c 0a09 0909 2f2f 2073 6573 7369 rval....// sessi │ │ │ +0007c960: 6f6e 5f73 6574 7469 6e67 2061 6e64 2064 on_setting and d │ │ │ +0007c970: 6563 7265 6173 6564 2065 7665 7279 2073 ecreased every s │ │ │ +0007c980: 6563 6f6e 642e 0a09 0909 2f2f 2077 6865 econd.....// whe │ │ │ +0007c990: 6e20 6974 2072 6561 6368 6573 207a 6572 n it reaches zer │ │ │ +0007c9a0: 6f2c 2069 7420 6973 2072 6573 6574 2074 o, it is reset t │ │ │ +0007c9b0: 6f20 7468 650a 0909 092f 2f20 756e 6368 o the....// unch │ │ │ +0007c9c0: 6f6b 655f 696e 7465 7276 616c 2061 6e64 oke_interval and │ │ │ +0007c9d0: 2074 6865 2075 6e63 686f 6b65 2073 6574 the unchoke set │ │ │ +0007c9e0: 2069 730a 0909 092f 2f20 7265 636f 6d70 is....// recomp │ │ │ +0007c9f0: 7574 6564 2e0a 3c64 6976 2073 7479 6c65 uted..
    ...int m_unc │ │ │ +0007ca30: 686f 6b65 5f74 696d 655f 7363 616c 6572 hoke_time_scaler │ │ │ +0007ca40: 203d 2030 3b0a 3c2f 6469 763e 0a09 0909 = 0;.
    .... │ │ │ +0007ca50: 2f2f 2074 6869 7320 6973 2075 7365 6420 // this is used │ │ │ +0007ca60: 746f 2064 6563 6964 6520 7768 656e 2074 to decide when t │ │ │ +0007ca70: 6f20 7265 6361 6c63 756c 6174 6520 7768 o recalculate wh │ │ │ +0007ca80: 6963 680a 0909 092f 2f20 746f 7272 656e ich....// torren │ │ │ +0007ca90: 7473 2074 6f20 6b65 6570 2071 7565 7565 ts to keep queue │ │ │ +0007caa0: 6420 616e 6420 7768 6963 6820 746f 2061 d and which to a │ │ │ +0007cab0: 6374 6976 6174 650a 3c2f 7072 653e 3c2f ctivate.
    relevan │ │ │ +0007caf0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../include/li │ │ │ +0007cb30: 6274 6f72 7265 6e74 2f61 7578 5f2f 7365 btorrent/aux_/se │ │ │ +0007cb40: 7373 696f 6e5f 696d 706c 2e68 7070 3a31 ssion_impl.hpp:1 │ │ │ +0007cb50: 3039 353c 2f61 3e3c 2f74 643e 3c74 643e 095 │ │ │ +0007cb60: 7265 706c 6163 6520 7468 6973 2062 7920 replace this by │ │ │ +0007cb70: 6120 7072 6f70 6572 2061 7369 6f20 7469 a proper asio ti │ │ │ +0007cb80: 6d65 723c 2f74 643e 3c2f 7472 3e3c 7472 mer

    replace this by │ │ │ +0007cbe0: 2061 2070 726f 7065 7220 6173 696f 2074 a proper asio t │ │ │ +0007cbf0: 696d 6572 3c2f 6832 3e3c 6834 3e2e 2e2f imer

    ../ │ │ │ +0007cc00: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ +0007cc10: 6e74 2f61 7578 5f2f 7365 7373 696f 6e5f nt/aux_/session_ │ │ │ +0007cc20: 696d 706c 2e68 7070 3a31 3039 353c 2f68 impl.hpp:1095
    ....
    │ │ │ +0007cc70: 2f2f 2072 6f75 6e64 2d72 6f62 696e 2069  // round-robin i
    │ │ │ +0007cc80: 6e64 6578 2069 6e74 6f20 6d5f 6f75 7467  ndex into m_outg
    │ │ │ +0007cc90: 6f69 6e67 5f69 6e74 6572 6661 6365 730a  oing_interfaces.
    │ │ │ +0007cca0: 0909 096d 7574 6162 6c65 2073 7464 3a3a  ...mutable std::
    │ │ │ +0007ccb0: 7569 6e74 385f 7420 6d5f 696e 7465 7266  uint8_t m_interf
    │ │ │ +0007ccc0: 6163 655f 696e 6465 7820 3d20 303b 0a0a  ace_index = 0;..
    │ │ │ +0007ccd0: 0909 0973 7464 3a3a 7368 6172 6564 5f70  ...std::shared_p
    │ │ │ +0007cce0: 7472 266c 743b 6c69 7374 656e 5f73 6f63  tr<listen_soc
    │ │ │ +0007ccf0: 6b65 745f 7426 6774 3b20 7365 7475 705f  ket_t> setup_
    │ │ │ +0007cd00: 6c69 7374 656e 6572 280a 0909 0909 6c69  listener(.....li
    │ │ │ +0007cd10: 7374 656e 5f65 6e64 706f 696e 745f 7420  sten_endpoint_t 
    │ │ │ +0007cd20: 636f 6e73 7426 616d 703b 206c 6570 2c20  const& lep, 
    │ │ │ +0007cd30: 6572 726f 725f 636f 6465 2661 6d70 3b20  error_code& 
    │ │ │ +0007cd40: 6563 293b 0a0a 2369 666e 6465 6620 544f  ec);..#ifndef TO
    │ │ │ +0007cd50: 5252 454e 545f 4449 5341 424c 455f 4448  RRENT_DISABLE_DH
    │ │ │ +0007cd60: 540a 0909 0964 6874 3a3a 6468 745f 7374  T....dht::dht_st
    │ │ │ +0007cd70: 6174 6520 6d5f 6468 745f 7374 6174 653b  ate m_dht_state;
    │ │ │ +0007cd80: 0a23 656e 6469 660a 0a09 0909 2f2f 2074  .#endif.....// t
    │ │ │ +0007cd90: 6869 7320 6973 2069 6e69 7469 616c 697a  his is initializ
    │ │ │ +0007cda0: 6564 2074 6f20 7468 6520 756e 6368 6f6b  ed to the unchok
    │ │ │ +0007cdb0: 655f 696e 7465 7276 616c 0a09 0909 2f2f  e_interval....//
    │ │ │ +0007cdc0: 2073 6573 7369 6f6e 5f73 6574 7469 6e67   session_setting
    │ │ │ +0007cdd0: 2061 6e64 2064 6563 7265 6173 6564 2065   and decreased e
    │ │ │ +0007cde0: 7665 7279 2073 6563 6f6e 642e 0a09 0909  very second.....
    │ │ │ +0007cdf0: 2f2f 2077 6865 6e20 6974 2072 6561 6368  // when it reach
    │ │ │ +0007ce00: 6573 207a 6572 6f2c 2069 7420 6973 2072  es zero, it is r
    │ │ │ +0007ce10: 6573 6574 2074 6f20 7468 650a 0909 092f  eset to the..../
    │ │ │ +0007ce20: 2f20 756e 6368 6f6b 655f 696e 7465 7276  / unchoke_interv
    │ │ │ +0007ce30: 616c 2061 6e64 2074 6865 2075 6e63 686f  al and the uncho
    │ │ │ +0007ce40: 6b65 2073 6574 2069 730a 0909 092f 2f20  ke set is....// 
    │ │ │ +0007ce50: 7265 636f 6d70 7574 6564 2e0a 0909 0969  recomputed.....i
    │ │ │ +0007ce60: 6e74 206d 5f75 6e63 686f 6b65 5f74 696d  nt m_unchoke_tim
    │ │ │ +0007ce70: 655f 7363 616c 6572 203d 2030 3b0a 0a09  e_scaler = 0;...
    │ │ │ +0007ce80: 0909 2f2f 2074 6869 7320 6973 2075 7365  ..// this is use
    │ │ │ +0007ce90: 6420 746f 2064 6563 6964 6520 7768 656e  d to decide when
    │ │ │ +0007cea0: 2074 6f20 7265 6361 6c63 756c 6174 6520   to recalculate 
    │ │ │ +0007ceb0: 7768 6963 680a 0909 092f 2f20 746f 7272  which....// torr
    │ │ │ +0007cec0: 656e 7473 2074 6f20 6b65 6570 2071 7565  ents to keep que
    │ │ │ +0007ced0: 7565 6420 616e 6420 7768 6963 6820 746f  ued and which to
    │ │ │ +0007cee0: 2061 6374 6976 6174 650a 3c64 6976 2073   activate.
    ...int m │ │ │ +0007cf20: 5f61 7574 6f5f 6d61 6e61 6765 5f74 696d _auto_manage_tim │ │ │ +0007cf30: 655f 7363 616c 6572 203d 2030 3b0a 3c2f e_scaler = 0;.....// works │ │ │ +0007cf50: 206c 696b 6520 756e 6368 6f6b 655f 7469 like unchoke_ti │ │ │ +0007cf60: 6d65 5f73 6361 6c65 7220 6275 7420 6974 me_scaler but it │ │ │ +0007cf70: 0a09 0909 2f2f 2069 7320 6f6e 6c79 2064 ....// is only d │ │ │ +0007cf80: 6563 7265 6173 6564 2077 6865 6e20 7468 ecreased when th │ │ │ +0007cf90: 6520 756e 6368 6f6b 6520 7365 740a 0909 e unchoke set... │ │ │ +0007cfa0: 092f 2f20 6973 2072 6563 6f6d 7075 7465 .// is recompute │ │ │ +0007cfb0: 642c 2061 6e64 2077 6865 6e20 6974 2072 d, and when it r │ │ │ +0007cfc0: 6561 6368 6573 207a 6572 6f2c 0a09 0909 eaches zero,.... │ │ │ +0007cfd0: 2f2f 2074 6865 206f 7074 696d 6973 7469 // the optimisti │ │ │ +0007cfe0: 6320 756e 6368 6f6b 6520 6973 206d 6f76 c unchoke is mov │ │ │ +0007cff0: 6564 2074 6f20 616e 6f74 6865 7220 7065 ed to another pe │ │ │ +0007d000: 6572 2e0a 3c2f 7072 653e 3c2f 7464 3e3c er..
    < │ │ │ +0007d010: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +0007d040: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +0007d070: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ +0007d080: 7265 6e74 2f61 7578 5f2f 7365 7373 696f rent/aux_/sessio │ │ │ +0007d090: 6e5f 696d 706c 2e68 7070 3a31 3130 323c n_impl.hpp:1102< │ │ │ +0007d0a0: 2f61 3e3c 2f74 643e 3c74 643e 7265 706c /a>repl │ │ │ +0007d0b0: 6163 6520 7468 6973 2062 7920 6120 7072 ace this by a pr │ │ │ +0007d0c0: 6f70 6572 2061 7369 6f20 7469 6d65 723c oper asio timer< │ │ │ +0007d0d0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    rep │ │ │ +0007d120: 6c61 6365 2074 6869 7320 6279 2061 2070 lace this by a p │ │ │ +0007d130: 726f 7065 7220 6173 696f 2074 696d 6572 roper asio timer │ │ │ +0007d140: 3c2f 6832 3e3c 6834 3e2e 2e2f 696e 636c

    ../incl │ │ │ +0007d150: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ +0007d160: 7578 5f2f 7365 7373 696f 6e5f 696d 706c ux_/session_impl │ │ │ +0007d170: 2e68 7070 3a31 3130 323c 2f68 343e 3c70 .hpp:1102

    .#ifndef │ │ │ +0007d1c0: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ +0007d1d0: 5f44 4854 0a09 0909 6468 743a 3a64 6874 _DHT....dht::dht │ │ │ +0007d1e0: 5f73 7461 7465 206d 5f64 6874 5f73 7461 _state m_dht_sta │ │ │ +0007d1f0: 7465 3b0a 2365 6e64 6966 0a0a 0909 092f te;.#endif...../ │ │ │ +0007d200: 2f20 7468 6973 2069 7320 696e 6974 6961 / this is initia │ │ │ +0007d210: 6c69 7a65 6420 746f 2074 6865 2075 6e63 lized to the unc │ │ │ +0007d220: 686f 6b65 5f69 6e74 6572 7661 6c0a 0909 hoke_interval... │ │ │ +0007d230: 092f 2f20 7365 7373 696f 6e5f 7365 7474 .// session_sett │ │ │ +0007d240: 696e 6720 616e 6420 6465 6372 6561 7365 ing and decrease │ │ │ +0007d250: 6420 6576 6572 7920 7365 636f 6e64 2e0a d every second.. │ │ │ +0007d260: 0909 092f 2f20 7768 656e 2069 7420 7265 ...// when it re │ │ │ +0007d270: 6163 6865 7320 7a65 726f 2c20 6974 2069 aches zero, it i │ │ │ +0007d280: 7320 7265 7365 7420 746f 2074 6865 0a09 s reset to the.. │ │ │ +0007d290: 0909 2f2f 2075 6e63 686f 6b65 5f69 6e74 ..// unchoke_int │ │ │ +0007d2a0: 6572 7661 6c20 616e 6420 7468 6520 756e erval and the un │ │ │ +0007d2b0: 6368 6f6b 6520 7365 7420 6973 0a09 0909 choke set is.... │ │ │ +0007d2c0: 2f2f 2072 6563 6f6d 7075 7465 642e 0a09 // recomputed... │ │ │ +0007d2d0: 0909 696e 7420 6d5f 756e 6368 6f6b 655f ..int m_unchoke_ │ │ │ +0007d2e0: 7469 6d65 5f73 6361 6c65 7220 3d20 303b time_scaler = 0; │ │ │ +0007d2f0: 0a0a 0909 092f 2f20 7468 6973 2069 7320 .....// this is │ │ │ +0007d300: 7573 6564 2074 6f20 6465 6369 6465 2077 used to decide w │ │ │ +0007d310: 6865 6e20 746f 2072 6563 616c 6375 6c61 hen to recalcula │ │ │ +0007d320: 7465 2077 6869 6368 0a09 0909 2f2f 2074 te which....// t │ │ │ +0007d330: 6f72 7265 6e74 7320 746f 206b 6565 7020 orrents to keep │ │ │ +0007d340: 7175 6575 6564 2061 6e64 2077 6869 6368 queued and which │ │ │ +0007d350: 2074 6f20 6163 7469 7661 7465 0a09 0909 to activate.... │ │ │ +0007d360: 696e 7420 6d5f 6175 746f 5f6d 616e 6167 int m_auto_manag │ │ │ +0007d370: 655f 7469 6d65 5f73 6361 6c65 7220 3d20 e_time_scaler = │ │ │ +0007d380: 303b 0a0a 0909 092f 2f20 776f 726b 7320 0;.....// works │ │ │ +0007d390: 6c69 6b65 2075 6e63 686f 6b65 5f74 696d like unchoke_tim │ │ │ +0007d3a0: 655f 7363 616c 6572 2062 7574 2069 740a e_scaler but it. │ │ │ +0007d3b0: 0909 092f 2f20 6973 206f 6e6c 7920 6465 ...// is only de │ │ │ +0007d3c0: 6372 6561 7365 6420 7768 656e 2074 6865 creased when the │ │ │ +0007d3d0: 2075 6e63 686f 6b65 2073 6574 0a09 0909 unchoke set.... │ │ │ +0007d3e0: 2f2f 2069 7320 7265 636f 6d70 7574 6564 // is recomputed │ │ │ +0007d3f0: 2c20 616e 6420 7768 656e 2069 7420 7265 , and when it re │ │ │ +0007d400: 6163 6865 7320 7a65 726f 2c0a 0909 092f aches zero,..../ │ │ │ +0007d410: 2f20 7468 6520 6f70 7469 6d69 7374 6963 / the optimistic │ │ │ +0007d420: 2075 6e63 686f 6b65 2069 7320 6d6f 7665 unchoke is move │ │ │ +0007d430: 6420 746f 2061 6e6f 7468 6572 2070 6565 d to another pee │ │ │ +0007d440: 722e 0a3c 6469 7620 7374 796c 653d 2262 r..

    ...int m_optimi │ │ │ +0007d480: 7374 6963 5f75 6e63 686f 6b65 5f74 696d stic_unchoke_tim │ │ │ +0007d490: 655f 7363 616c 6572 203d 2030 3b0a 3c2f e_scaler = 0;.....// works │ │ │ +0007d4b0: 206c 696b 6520 756e 6368 6f6b 655f 7469 like unchoke_ti │ │ │ +0007d4c0: 6d65 5f73 6361 6c65 722e 2045 6163 6820 me_scaler. Each │ │ │ +0007d4d0: 7469 6d65 0a09 0909 2f2f 2069 7420 7265 time....// it re │ │ │ +0007d4e0: 6163 6865 7320 302c 2061 6e64 2061 6c6c aches 0, and all │ │ │ +0007d4f0: 2074 6865 2063 6f6e 6e65 6374 696f 6e73 the connections │ │ │ +0007d500: 2061 7265 0a09 0909 2f2f 2075 7365 642c are....// used, │ │ │ +0007d510: 2074 6865 2077 6f72 7374 2063 6f6e 6e65 the worst conne │ │ │ +0007d520: 6374 696f 6e20 7769 6c6c 2062 6520 6469 ction will be di │ │ │ +0007d530: 7363 6f6e 6e65 6374 6564 0a09 0909 2f2f sconnected....// │ │ │ +0007d540: 2066 726f 6d20 7468 6520 746f 7272 656e from the torren │ │ │ +0007d550: 7420 7769 7468 2074 6865 206d 6f73 7420 t with the most │ │ │ +0007d560: 7065 6572 730a 0909 0969 6e74 206d 5f64 peers....int m_d │ │ │ +0007d570: 6973 636f 6e6e 6563 745f 7469 6d65 5f73 isconnect_time_s │ │ │ +0007d580: 6361 6c65 7220 3d20 3930 3b0a 0a09 0909 caler = 90;..... │ │ │ +0007d590: 2f2f 2077 6865 6e20 7468 6973 2073 6361 // when this sca │ │ │ +0007d5a0: 6c65 7220 7265 6163 6865 7320 7a65 726f ler reaches zero │ │ │ +0007d5b0: 2c20 6974 2077 696c 6c0a 0909 092f 2f20 , it will....// │ │ │ +0007d5c0: 7363 7261 7065 206f 6e65 206f 6620 7468 scrape one of th │ │ │ +0007d5d0: 6520 6175 746f 206d 616e 6167 6564 2c20 e auto managed, │ │ │ +0007d5e0: 7061 7573 6564 2c0a 0909 092f 2f20 746f paused,....// to │ │ │ +0007d5f0: 7272 656e 7473 2e0a 0909 0969 6e74 206d rrents.....int m │ │ │ +0007d600: 5f61 7574 6f5f 7363 7261 7065 5f74 696d _auto_scrape_tim │ │ │ +0007d610: 655f 7363 616c 6572 203d 2031 3830 3b0a e_scaler = 180;. │ │ │ +0007d620: 0a09 0909 2f2f 2073 7461 7469 7374 6963 ....// statistic │ │ │ +0007d630: 7320 6761 7468 6572 6564 2066 726f 6d20 s gathered from │ │ │ +0007d640: 616c 6c20 746f 7272 656e 7473 2e0a 0909 all torrents.... │ │ │ +0007d650: 0973 7461 7420 6d5f 7374 6174 3b0a 0a09 .stat m_stat;... │ │ │ +0007d660: 0909 2f2f 2069 6d70 6c65 6d65 6e74 7320 ..// implements │ │ │ +0007d670: 7365 7373 696f 6e5f 696e 7465 7266 6163 session_interfac │ │ │ +0007d680: 650a 0909 0976 6f69 6420 7365 6e74 5f62 e....void sent_b │ │ │ +0007d690: 7974 6573 2869 6e74 2062 7974 6573 5f70 ytes(int bytes_p │ │ │ +0007d6a0: 6179 6c6f 6164 2c20 696e 7420 6279 7465 ayload, int byte │ │ │ +0007d6b0: 735f 7072 6f74 6f63 6f6c 2920 6f76 6572 s_protocol) over │ │ │ +0007d6c0: 7269 6465 3b0a 0909 0976 6f69 6420 7265 ride;....void re │ │ │ +0007d6d0: 6365 6976 6564 5f62 7974 6573 2869 6e74 ceived_bytes(int │ │ │ +0007d6e0: 2062 7974 6573 5f70 6179 6c6f 6164 2c20 bytes_payload, │ │ │ +0007d6f0: 696e 7420 6279 7465 735f 7072 6f74 6f63 int bytes_protoc │ │ │ +0007d700: 6f6c 2920 6f76 6572 7269 6465 3b0a 0909 ol) override;... │ │ │ +0007d710: 0976 6f69 6420 7472 616e 6369 6576 655f .void trancieve_ │ │ │ +0007d720: 6970 5f70 6163 6b65 7428 696e 7420 6279 ip_packet(int by │ │ │ +0007d730: 7465 732c 2062 6f6f 6c20 6970 7636 2920 tes, bool ipv6) │ │ │ +0007d740: 6f76 6572 7269 6465 3b0a 0909 0976 6f69 override;....voi │ │ │ +0007d750: 6420 7365 6e74 5f73 796e 2862 6f6f 6c20 d sent_syn(bool │ │ │ +0007d760: 6970 7636 2920 6f76 6572 7269 6465 3b0a ipv6) override;. │ │ │ +0007d770: 0909 0976 6f69 6420 7265 6365 6976 6564 ...void received │ │ │ +0007d780: 5f73 796e 6163 6b28 626f 6f6c 2069 7076 _synack(bool ipv │ │ │ +0007d790: 3629 206f 7665 7272 6964 653b 0a0a 2369 6) override;..#i │ │ │ +0007d7a0: 6620 544f 5252 454e 545f 4142 495f 5645 f TORRENT_ABI_VE │ │ │ +0007d7b0: 5253 494f 4e20 3d3d 2031 0a09 0909 696e RSION == 1....in │ │ │ +0007d7c0: 7420 6d5f 7065 616b 5f75 705f 7261 7465 t m_peak_up_rate │ │ │ +0007d7d0: 203d 2030 3b0a 2365 6e64 6966 0a0a 0909 = 0;.#endif.... │ │ │ +0007d7e0: 0976 6f69 6420 6f6e 5f74 6963 6b28 6572 .void on_tick(er │ │ │ +0007d7f0: 726f 725f 636f 6465 2063 6f6e 7374 2661 ror_code const&a │ │ │ +0007d800: 6d70 3b20 6529 3b0a 0a09 0909 766f 6964 mp; e);.....void │ │ │ +0007d810: 2074 7279 5f63 6f6e 6e65 6374 5f6d 6f72 try_connect_mor │ │ │ +0007d820: 655f 7065 6572 7328 293b 0a09 0909 766f e_peers();....vo │ │ │ +0007d830: 6964 2061 7574 6f5f 6d61 6e61 6765 5f63 id auto_manage_c │ │ │ +0007d840: 6865 636b 696e 675f 746f 7272 656e 7473 hecking_torrents │ │ │ +0007d850: 2873 7464 3a3a 7665 6374 6f72 266c 743b (std::vector< │ │ │ +0007d860: 746f 7272 656e 742a 2667 743b 2661 6d70 torrent*>& │ │ │ +0007d870: 3b20 6c69 7374 0a3c 2f70 7265 3e3c 2f74 ; list.

    relevanc │ │ │ +0007d8b0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../include/lib │ │ │ +0007d8f0: 746f 7272 656e 742f 6175 785f 2f6d 6572 torrent/aux_/mer │ │ │ +0007d900: 6b6c 655f 7472 6565 2e68 7070 3a38 353c kle_tree.hpp:85< │ │ │ +0007d910: 2f61 3e3c 2f74 643e 3c74 643e 7265 6d6f /a>remo │ │ │ +0007d920: 7665 2074 6869 7320 636f 6e73 7472 7563 ve this construc │ │ │ +0007d930: 746f 722e 2044 6f6e 2774 2073 7570 706f tor. Don't suppo │ │ │ +0007d940: 7274 2022 756e 696e 6974 6961 6c69 7a65 rt "uninitialize │ │ │ +0007d950: 6422 2074 7265 6573 2e20 5468 6973 2061 d" trees. This a │ │ │ +0007d960: 6c73 6f20 7265 7175 6972 6573 206e 6f74 lso requires not │ │ │ +0007d970: 2063 6f6e 7374 7275 6374 696e 6720 7468 constructing th │ │ │ +0007d980: 6573 6520 666f 7220 7061 642d 6669 6c65 ese for pad-file │ │ │ +0007d990: 7320 616e 6420 736d 616c 6c20 6669 6c65 s and small file │ │ │ +0007d9a0: 7320 6173 2077 656c 6c2e 2053 6f2c 2061 s as well. So, a │ │ │ +0007d9b0: 2073 7061 7273 6520 6861 7368 206c 6973 sparse hash lis │ │ │ +0007d9c0: 7420 696e 2074 6f72 7265 6e74 5f69 6e66 t in torrent_inf │ │ │ +0007d9d0: 6f3c 2f74 643e 3c2f 7472 3e3c 7472 2069 o

    r │ │ │ +0007da20: 656d 6f76 6520 7468 6973 2063 6f6e 7374 emove this const │ │ │ +0007da30: 7275 6374 6f72 2e20 446f 6e27 7420 7375 ructor. Don't su │ │ │ +0007da40: 7070 6f72 7420 2275 6e69 6e69 7469 616c pport "uninitial │ │ │ +0007da50: 697a 6564 2220 7472 6565 732e 2054 6869 ized" trees. Thi │ │ │ +0007da60: 730a 616c 736f 2072 6571 7569 7265 7320 s.also requires │ │ │ +0007da70: 6e6f 7420 636f 6e73 7472 7563 7469 6e67 not constructing │ │ │ +0007da80: 2074 6865 7365 2066 6f72 2070 6164 2d66 these for pad-f │ │ │ +0007da90: 696c 6573 2061 6e64 2073 6d61 6c6c 2066 iles and small f │ │ │ +0007daa0: 696c 6573 2061 730a 7765 6c6c 2e20 536f iles as.well. So │ │ │ +0007dab0: 2c20 6120 7370 6172 7365 2068 6173 6820 , a sparse hash │ │ │ +0007dac0: 6c69 7374 2069 6e20 746f 7272 656e 745f list in torrent_ │ │ │ +0007dad0: 696e 666f 3c2f 6832 3e3c 6834 3e2e 2e2f info

    ../ │ │ │ +0007dae0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ +0007daf0: 6e74 2f61 7578 5f2f 6d65 726b 6c65 5f74 nt/aux_/merkle_t │ │ │ +0007db00: 7265 652e 6870 703a 3835 3c2f 6834 3e3c ree.hpp:85

    < │ │ │ +0007db10: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +0007db20: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +0007db30: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +0007db40: 7820 2364 6464 3b22 3e2f 2f20 5468 6520 x #ddd;">// The │ │ │ +0007db50: 696e 7661 7269 616e 7420 6f66 2074 6865 invariant of the │ │ │ +0007db60: 2074 7265 6520 6973 2074 6861 7420 616c tree is that al │ │ │ +0007db70: 6c20 696e 7465 7269 6f72 206e 6f64 6573 l interior nodes │ │ │ +0007db80: 2028 692e 652e 2061 6c6c 2062 7574 2074 (i.e. all but t │ │ │ +0007db90: 6865 2076 6572 790a 2f2f 2062 6f74 746f he very.// botto │ │ │ +0007dba0: 6d20 6c65 6166 206e 6f64 6573 2c20 7265 m leaf nodes, re │ │ │ +0007dbb0: 7072 6573 656e 7469 6e67 2062 6c6f 636b presenting block │ │ │ +0007dbc0: 2068 6173 6865 7329 2061 7265 2065 6974 hashes) are eit │ │ │ +0007dbd0: 6865 7220 7365 7420 616e 6420 7661 6c69 her set and vali │ │ │ +0007dbe0: 642c 206f 720a 2f2f 2063 6c65 6172 2e20 d, or.// clear. │ │ │ +0007dbf0: 4e6f 2069 6e76 616c 6964 2068 6173 6865 No invalid hashe │ │ │ +0007dc00: 7320 6172 6520 616c 6c6f 7765 642c 2061 s are allowed, a │ │ │ +0007dc10: 6e64 2074 6865 7920 6361 6e20 6f6e 6c79 nd they can only │ │ │ +0007dc20: 2062 6520 6164 6465 6420 6279 2061 6c73 be added by als │ │ │ +0007dc30: 6f0a 2f2f 2070 726f 7669 6469 6e67 2070 o.// providing p │ │ │ +0007dc40: 726f 6f66 206f 6620 6265 696e 6720 7661 roof of being va │ │ │ +0007dc50: 6c69 642e 0a0a 2f2f 2054 6865 206c 6561 lid...// The lea │ │ │ +0007dc60: 6620 626c 6f63 6b73 206f 6e20 7468 6520 f blocks on the │ │ │ +0007dc70: 6f74 6865 7220 6861 6e64 2c20 4d41 5920 other hand, MAY │ │ │ +0007dc80: 6265 2069 6e76 616c 6964 2e20 466f 7220 be invalid. For │ │ │ +0007dc90: 696e 7374 616e 6365 2c20 7768 656e 2061 instance, when a │ │ │ +0007dca0: 6464 696e 670a 2f2f 2061 206d 6167 6e65 dding.// a magne │ │ │ +0007dcb0: 7420 6c69 6e6b 2066 6f72 2061 2074 6f72 t link for a tor │ │ │ +0007dcc0: 7265 6e74 2074 6861 7420 7765 2061 6c72 rent that we alr │ │ │ +0007dcd0: 6561 6479 2068 6176 6520 6669 6c65 7320 eady have files │ │ │ +0007dce0: 666f 722e 204f 6e63 6520 7765 2068 6176 for. Once we hav │ │ │ +0007dcf0: 6520 7468 650a 2f2f 206d 6574 6164 6174 e the.// metadat │ │ │ +0007dd00: 612c 2077 6520 6861 7665 2066 696c 6573 a, we have files │ │ │ +0007dd10: 206f 6e20 6469 736b 2062 7574 206e 6f20 on disk but no │ │ │ +0007dd20: 6861 7368 6573 2e20 5765 2077 6f6e 2774 hashes. We won't │ │ │ +0007dd30: 206b 6e6f 7720 7768 6574 6865 7220 7468 know whether th │ │ │ +0007dd40: 6520 6461 7461 0a2f 2f20 6f6e 2064 6973 e data.// on dis │ │ │ +0007dd50: 6b20 6973 2076 616c 6964 206f 7220 6e6f k is valid or no │ │ │ +0007dd60: 742c 2075 6e74 696c 2077 6527 7665 2064 t, until we've d │ │ │ +0007dd70: 6f77 6e6c 6f61 6465 6420 7468 6520 6861 ownloaded the ha │ │ │ +0007dd80: 7368 6573 2074 6f20 7661 6c69 6461 7465 shes to validate │ │ │ +0007dd90: 2074 6865 6d2e 0a0a 2f2f 2049 6465 6120 them...// Idea │ │ │ +0007dda0: 666f 7220 6675 7475 7265 2073 7061 6365 for future space │ │ │ +0007ddb0: 206f 7074 696d 697a 6174 696f 6e3a 0a2f optimization:./ │ │ │ +0007ddc0: 2f20 7768 696c 6520 646f 776e 6c6f 6164 / while download │ │ │ +0007ddd0: 696e 672c 2077 6520 6e65 6564 2074 6f20 ing, we need to │ │ │ +0007dde0: 7374 6f72 6520 696e 7465 7269 6f72 206e store interior n │ │ │ +0007ddf0: 6f64 6573 206f 6620 7468 6973 2074 7265 odes of this tre │ │ │ +0007de00: 652e 2048 6f77 6576 6572 2c20 7765 0a2f e. However, we./ │ │ │ +0007de10: 2f20 646f 6e27 7420 6e65 6564 2074 6f20 / don't need to │ │ │ +0007de20: 7374 6f72 6520 7468 6520 7061 6464 696e store the paddin │ │ │ +0007de30: 672e 2061 2053 4841 2d32 3536 2069 7320 g. a SHA-256 is │ │ │ +0007de40: 3332 2062 7974 6573 2e20 496e 7374 6561 32 bytes. Instea │ │ │ +0007de50: 6420 6f66 2073 746f 7269 6e67 0a2f 2f20 d of storing.// │ │ │ +0007de60: 7468 6520 6675 6c6c 2028 7061 6464 6564 the full (padded │ │ │ +0007de70: 2920 7472 6565 206f 6620 5348 412d 3235 ) tree of SHA-25 │ │ │ +0007de80: 3620 6861 7368 6573 2c20 7374 6f72 6520 6 hashes, store │ │ │ +0007de90: 7468 6520 6675 6c6c 2074 7265 6520 6f66 the full tree of │ │ │ +0007dea0: 2033 3220 6269 740a 2f2f 2073 6967 6e65 32 bit.// signe │ │ │ +0007deb0: 6420 696e 7465 6765 7273 2c20 6265 696e d integers, bein │ │ │ +0007dec0: 6720 696e 6469 6365 7320 696e 746f 2074 g indices into t │ │ │ +0007ded0: 6865 2061 6374 7561 6c20 7374 6f72 6167 he actual storag │ │ │ +0007dee0: 6520 666f 7220 7468 6520 7472 6565 2e20 e for the tree. │ │ │ +0007def0: 5765 2063 6f75 6c64 0a2f 2f20 6576 656e We could.// even │ │ │ +0007df00: 2067 726f 7720 7468 6520 7374 6f72 6167 grow the storag │ │ │ +0007df10: 6520 6c61 7a69 6c79 2e20 496e 7374 6561 e lazily. Instea │ │ │ +0007df20: 6420 6f66 2073 746f 7269 6e67 2074 6865 d of storing the │ │ │ +0007df30: 2070 6164 6469 6e67 2068 6173 6865 732c padding hashes, │ │ │ +0007df40: 2075 7365 0a2f 2f20 6e65 6761 7469 7665 use.// negative │ │ │ +0007df50: 2069 6e64 6963 6573 2074 6f20 7265 6665 indices to refe │ │ │ +0007df60: 7220 746f 2066 6978 6564 2053 4841 2d32 r to fixed SHA-2 │ │ │ +0007df70: 3536 2830 292c 2061 6e64 2053 4841 2d32 56(0), and SHA-2 │ │ │ +0007df80: 3536 2853 4841 2d32 3536 2830 2929 2061 56(SHA-256(0)) a │ │ │ +0007df90: 6e64 2073 6f0a 2f2f 206f 6e0a 7374 7275 nd so.// on.stru │ │ │ +0007dfa0: 6374 2054 4f52 5245 4e54 5f45 5854 5241 ct TORRENT_EXTRA │ │ │ +0007dfb0: 5f45 5850 4f52 5420 6d65 726b 6c65 5f74 _EXPORT merkle_t │ │ │ +0007dfc0: 7265 650a 7b0a 3c64 6976 2073 7479 6c65 ree.{.
    .merkle_tree │ │ │ +0007e000: 2829 203d 2064 6566 6175 6c74 3b0a 3c2f () = default;..merkle_tree │ │ │ +0007e020: 2869 6e74 206e 756d 5f62 6c6f 636b 732c (int num_blocks, │ │ │ +0007e030: 2069 6e74 2062 6c6f 636b 735f 7065 725f int blocks_per_ │ │ │ +0007e040: 7069 6563 652c 2063 6861 7220 636f 6e73 piece, char cons │ │ │ +0007e050: 742a 2072 293b 0a0a 0973 6861 3235 365f t* r);...sha256_ │ │ │ +0007e060: 6861 7368 2072 6f6f 7428 2920 636f 6e73 hash root() cons │ │ │ +0007e070: 743b 0a0a 0976 6f69 6420 6c6f 6164 5f74 t;...void load_t │ │ │ +0007e080: 7265 6528 7370 616e 266c 743b 7368 6132 ree(span<sha2 │ │ │ +0007e090: 3536 5f68 6173 6820 636f 6e73 7426 6774 56_hash const> │ │ │ +0007e0a0: 3b20 742c 2073 7464 3a3a 7665 6374 6f72 ; t, std::vector │ │ │ +0007e0b0: 266c 743b 626f 6f6c 2667 743b 2063 6f6e <bool> con │ │ │ +0007e0c0: 7374 2661 6d70 3b20 7665 7269 6669 6564 st& verified │ │ │ +0007e0d0: 293b 0a09 766f 6964 206c 6f61 645f 7370 );..void load_sp │ │ │ +0007e0e0: 6172 7365 5f74 7265 6528 7370 616e 266c arse_tree(span&l │ │ │ +0007e0f0: 743b 7368 6132 3536 5f68 6173 6820 636f t;sha256_hash co │ │ │ +0007e100: 6e73 7426 6774 3b20 742c 2073 7464 3a3a nst> t, std:: │ │ │ +0007e110: 7665 6374 6f72 266c 743b 626f 6f6c 2667 vector<bool&g │ │ │ +0007e120: 743b 2063 6f6e 7374 2661 6d70 3b20 6d61 t; const& ma │ │ │ +0007e130: 736b 0a09 092c 2073 7464 3a3a 7665 6374 sk..., std::vect │ │ │ +0007e140: 6f72 266c 743b 626f 6f6c 2667 743b 2063 or<bool> c │ │ │ +0007e150: 6f6e 7374 2661 6d70 3b20 7665 7269 6669 onst& verifi │ │ │ +0007e160: 6564 293b 0a09 766f 6964 206c 6f61 645f ed);..void load_ │ │ │ +0007e170: 7665 7269 6669 6564 5f62 6974 7328 7374 verified_bits(st │ │ │ +0007e180: 643a 3a76 6563 746f 7226 6c74 3b62 6f6f d::vector<boo │ │ │ +0007e190: 6c26 6774 3b20 636f 6e73 7426 616d 703b l> const& │ │ │ +0007e1a0: 2076 6572 6966 6965 6429 3b0a 0a09 7374 verified);...st │ │ │ +0007e1b0: 643a 3a73 697a 655f 7420 7369 7a65 2829 d::size_t size() │ │ │ +0007e1c0: 2063 6f6e 7374 3b0a 0969 6e74 2065 6e64 const;..int end │ │ │ +0007e1d0: 5f69 6e64 6578 2829 2063 6f6e 7374 207b _index() const { │ │ │ +0007e1e0: 2072 6574 7572 6e20 696e 7428 7369 7a65 return int(size │ │ │ +0007e1f0: 2829 293b 207d 0a0a 0962 6f6f 6c20 6861 ()); }...bool ha │ │ │ +0007e200: 735f 6e6f 6465 2869 6e74 2069 6478 2920 s_node(int idx) │ │ │ +0007e210: 636f 6e73 743b 0a0a 0962 6f6f 6c20 636f const;...bool co │ │ │ +0007e220: 6d70 6172 655f 6e6f 6465 2869 6e74 2069 mpare_node(int i │ │ │ +0007e230: 6478 2c20 7368 6132 3536 5f68 6173 6820 dx, sha256_hash │ │ │ +0007e240: 636f 6e73 7426 616d 703b 2068 2920 636f const& h) co │ │ │ +0007e250: 6e73 743b 0a0a 0973 6861 3235 365f 6861 nst;...sha256_ha │ │ │ +0007e260: 7368 206f 7065 7261 746f 725b 5d28 696e sh operator[](in │ │ │ +0007e270: 7420 6964 7829 2063 6f6e 7374 3b0a 0a09 t idx) const;... │ │ │ +0007e280: 7374 643a 3a76 6563 746f 7226 6c74 3b73 std::vector<s │ │ │ +0007e290: 6861 3235 365f 6861 7368 2667 743b 2062 ha256_hash> b │ │ │ +0007e2a0: 7569 6c64 5f76 6563 746f 7228 2920 636f uild_vector() co │ │ │ +0007e2b0: 6e73 743b 0a09 7374 643a 3a70 6169 7226 nst;..std::pair& │ │ │ +0007e2c0: 6c74 3b73 7464 3a3a 7665 6374 6f72 266c lt;std::vector&l │ │ │ +0007e2d0: 743b 7368 6132 3536 5f68 6173 6826 6774 t;sha256_hash> │ │ │ +0007e2e0: 3b2c 2061 7578 3a3a 7665 6374 6f72 266c ;, aux::vector&l │ │ │ +0007e2f0: 743b 626f 6f6c 2667 743b 2667 743b 2062 t;bool>> b │ │ │ +0007e300: 7569 6c64 5f73 7061 7273 655f 7665 6374 uild_sparse_vect │ │ │ +0007e310: 6f72 2829 2063 6f6e 7374 3b0a 0a09 2f2f or() const;...// │ │ │ +0007e320: 2067 6574 2062 6974 7320 696e 6469 6361 get bits indica │ │ │ +0007e330: 7469 6e67 2069 6620 6561 6368 206c 6561 ting if each lea │ │ │ +0007e340: 6620 6861 7368 2069 7320 7665 7269 6669 f hash is verifi │ │ │ +0007e350: 6564 0a09 7374 643a 3a76 6563 746f 7226 ed..std::vector& │ │ │ +0007e360: 6c74 3b62 6f6f 6c26 6774 3b20 7665 7269 lt;bool> veri │ │ │ +0007e370: 6669 6564 5f6c 6561 6673 2829 2063 6f6e fied_leafs() con │ │ │ +0007e380: 7374 3b0a 0a09 2f2f 2072 6574 7572 6e73 st;...// returns │ │ │ +0007e390: 2074 7275 6520 6966 2074 6865 2065 6e74 true if the ent │ │ │ +0007e3a0: 6972 6520 7472 6565 2069 7320 6b6e 6f77 ire tree is know │ │ │ +0007e3b0: 6e20 616e 6420 7665 7269 6669 6564 0a09 n and verified.. │ │ │ +0007e3c0: 626f 6f6c 2069 735f 636f 6d70 6c65 7465 bool is_complete │ │ │ +0007e3d0: 2829 2063 6f6e 7374 3b0a 0a09 2f2f 2072 () const;...// r │ │ │ +0007e3e0: 6574 7572 6e73 2074 7275 6520 6966 2061 eturns true if a │ │ │ +0007e3f0: 6c6c 2062 6c6f 636b 2068 6173 6865 7320 ll block hashes │ │ │ +0007e400: 696e 2074 6865 2073 7065 6369 6669 6564 in the specified │ │ │ +0007e410: 2072 616e 6765 2068 6176 6520 6265 656e range have been │ │ │ +0007e420: 2076 6572 6966 6965 640a 0962 6f6f 6c20 verified..bool │ │ │ +0007e430: 626c 6f63 6b73 5f76 6572 6966 6965 6428 blocks_verified( │ │ │ +0007e440: 696e 7420 626c 6f63 6b5f 6964 782c 2069 int block_idx, i │ │ │ +0007e450: 6e74 206e 756d 5f62 6c6f 636b 7329 2063 nt num_blocks) c │ │ │ +0007e460: 6f6e 7374 3b0a 0a3c 2f70 7265 3e3c 2f74 onst;..
    relevanc │ │ │ +0007e4a0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../include/lib │ │ │ +0007e4e0: 746f 7272 656e 742f 6175 785f 2f6d 6572 torrent/aux_/mer │ │ │ +0007e4f0: 6b6c 655f 7472 6565 2e68 7070 3a31 3735 kle_tree.hpp:175 │ │ │ +0007e500: 3c2f 613e 3c2f 7464 3e3c 7464 3e6d 616b mak │ │ │ +0007e510: 6520 7468 6973 2061 2073 7464 3a3a 756e e this a std::un │ │ │ +0007e520: 6971 7565 5f70 7472 3c73 6861 3235 365f ique_ptr

    make this a │ │ │ +0007e590: 2073 7464 3a3a 756e 6971 7565 5f70 7472 std::unique_ptr │ │ │ +0007e5a0: 3c73 6861 3235 365f 6861 7368 5b5d 3e3c < │ │ │ +0007e5b0: 2f68 323e 3c68 343e 2e2e 2f69 6e63 6c75 /h2>

    ../inclu │ │ │ +0007e5c0: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ +0007e5d0: 785f 2f6d 6572 6b6c 655f 7472 6565 2e68 x_/merkle_tree.h │ │ │ +0007e5e0: 7070 3a31 3735 3c2f 6834 3e3c 7072 6520 pp:175

    ..int block
    │ │ │ +0007e630: 735f 7065 725f 7069 6563 6528 2920 636f  s_per_piece() co
    │ │ │ +0007e640: 6e73 7420 7b20 7265 7475 726e 2031 2026  nst { return 1 &
    │ │ │ +0007e650: 6c74 3b26 6c74 3b20 6d5f 626c 6f63 6b73  lt;< m_blocks
    │ │ │ +0007e660: 5f70 6572 5f70 6965 6365 5f6c 6f67 3b20  _per_piece_log; 
    │ │ │ +0007e670: 7d0a 092f 2f20 7468 6520 6e75 6d62 6572  }..// the number
    │ │ │ +0007e680: 2074 7265 6520 6c65 7665 6c73 2070 6572   tree levels per
    │ │ │ +0007e690: 2070 6965 6365 2e20 5468 6973 2069 7320   piece. This is 
    │ │ │ +0007e6a0: 3020 6966 2074 6865 2062 6c6f 636b 206c  0 if the block l
    │ │ │ +0007e6b0: 6179 6572 2069 7320 616c 736f 0a09 2f2f  ayer is also..//
    │ │ │ +0007e6c0: 2074 6865 2070 6965 6365 206c 6179 6572   the piece layer
    │ │ │ +0007e6d0: 2e0a 0969 6e74 2070 6965 6365 5f6c 6576  ...int piece_lev
    │ │ │ +0007e6e0: 656c 7328 2920 636f 6e73 7420 7b20 7265  els() const { re
    │ │ │ +0007e6f0: 7475 726e 206d 5f62 6c6f 636b 735f 7065  turn m_blocks_pe
    │ │ │ +0007e700: 725f 7069 6563 655f 6c6f 673b 207d 0a0a  r_piece_log; }..
    │ │ │ +0007e710: 0969 6e74 2062 6c6f 636b 5f6c 6179 6572  .int block_layer
    │ │ │ +0007e720: 5f73 7461 7274 2829 2063 6f6e 7374 3b0a  _start() const;.
    │ │ │ +0007e730: 0969 6e74 2070 6965 6365 5f6c 6179 6572  .int piece_layer
    │ │ │ +0007e740: 5f73 7461 7274 2829 2063 6f6e 7374 3b0a  _start() const;.
    │ │ │ +0007e750: 0969 6e74 206e 756d 5f70 6965 6365 7328  .int num_pieces(
    │ │ │ +0007e760: 2920 636f 6e73 743b 0a09 696e 7420 6e75  ) const;..int nu
    │ │ │ +0007e770: 6d5f 6c65 6166 7328 2920 636f 6e73 743b  m_leafs() const;
    │ │ │ +0007e780: 0a0a 0976 6f69 6420 6f70 7469 6d69 7a65  ...void optimize
    │ │ │ +0007e790: 5f73 746f 7261 6765 2829 3b0a 0976 6f69  _storage();..voi
    │ │ │ +0007e7a0: 6420 6f70 7469 6d69 7a65 5f73 746f 7261  d optimize_stora
    │ │ │ +0007e7b0: 6765 5f70 6965 6365 5f6c 6179 6572 2829  ge_piece_layer()
    │ │ │ +0007e7c0: 3b0a 0976 6f69 6420 616c 6c6f 6361 7465  ;..void allocate
    │ │ │ +0007e7d0: 5f66 756c 6c28 293b 0a0a 092f 2f20 6120  _full();...// a 
    │ │ │ +0007e7e0: 706f 696e 7465 7220 746f 2074 6865 2072  pointer to the r
    │ │ │ +0007e7f0: 6f6f 7420 6861 7368 2066 6f72 2074 6869  oot hash for thi
    │ │ │ +0007e800: 7320 6669 6c65 2e0a 0963 6861 7220 636f  s file...char co
    │ │ │ +0007e810: 6e73 742a 206d 5f72 6f6f 7420 3d20 6e75  nst* m_root = nu
    │ │ │ +0007e820: 6c6c 7074 723b 0a0a 092f 2f20 7468 6973  llptr;...// this
    │ │ │ +0007e830: 2069 7320 6569 7468 6572 2074 6865 2066   is either the f
    │ │ │ +0007e840: 756c 6c20 7472 6565 2c20 6f72 2073 6f6d  ull tree, or som
    │ │ │ +0007e850: 6520 7370 6172 7365 2072 6570 7265 7365  e sparse represe
    │ │ │ +0007e860: 6e74 6174 696f 6e20 6f66 2069 742c 0a09  ntation of it,..
    │ │ │ +0007e870: 2f2f 2064 6570 656e 6469 6e67 206f 6e20  // depending on 
    │ │ │ +0007e880: 6d5f 6d6f 6465 0a3c 6469 7620 7374 796c  m_mode.
    .aux::vecto │ │ │ +0007e8c0: 7226 6c74 3b73 6861 3235 365f 6861 7368 r<sha256_hash │ │ │ +0007e8d0: 2667 743b 206d 5f74 7265 653b 0a3c 2f64 > m_tree;...// when the │ │ │ +0007e8f0: 2066 756c 6c20 7472 6565 2069 7320 616c full tree is al │ │ │ +0007e900: 6c6f 6361 7465 642c 2074 6869 7320 6861 located, this ha │ │ │ +0007e910: 7320 6f6e 6520 6269 7420 666f 7220 6561 s one bit for ea │ │ │ +0007e920: 6368 2062 6c6f 636b 2068 6173 682e 2061 ch block hash. a │ │ │ +0007e930: 0a09 2f2f 2031 206d 6561 6e73 2077 6520 ..// 1 means we │ │ │ +0007e940: 6861 7665 2076 6572 6966 6965 6420 7468 have verified th │ │ │ +0007e950: 6520 626c 6f63 6b20 6861 7368 2074 6f20 e block hash to │ │ │ +0007e960: 6265 2063 6f72 7265 6374 2c20 6f74 6865 be correct, othe │ │ │ +0007e970: 7277 6973 6520 7468 6520 626c 6f63 6b0a rwise the block. │ │ │ +0007e980: 092f 2f20 6861 7368 206d 6179 2072 6570 .// hash may rep │ │ │ +0007e990: 7265 7365 6e74 2077 6861 7427 7320 6f6e resent what's on │ │ │ +0007e9a0: 2064 6973 6b2c 2062 7574 2077 6520 6861 disk, but we ha │ │ │ +0007e9b0: 7665 6e27 7420 6265 656e 2061 626c 6520 ven't been able │ │ │ +0007e9c0: 746f 2076 6572 6966 7920 6974 0a09 2f2f to verify it..// │ │ │ +0007e9d0: 2079 6574 0a09 6269 7466 6965 6c64 206d yet..bitfield m │ │ │ +0007e9e0: 5f62 6c6f 636b 5f76 6572 6966 6965 643b _block_verified; │ │ │ +0007e9f0: 0a0a 092f 2f20 6e75 6d62 6572 206f 6620 ...// number of │ │ │ +0007ea00: 626c 6f63 6b73 2069 6e20 7468 6520 6669 blocks in the fi │ │ │ +0007ea10: 6c65 2074 6869 7320 7472 6565 2072 6570 le this tree rep │ │ │ +0007ea20: 7265 7365 6e74 732e 2054 6865 206e 756d resents. The num │ │ │ +0007ea30: 6265 7220 6f66 206c 6561 6673 2069 6e0a ber of leafs in. │ │ │ +0007ea40: 092f 2f20 7468 6520 7472 6565 2069 7320 .// the tree is │ │ │ +0007ea50: 726f 756e 6465 6420 7570 2074 6f20 616e rounded up to an │ │ │ +0007ea60: 2065 7665 6e20 706f 7765 7220 6f66 2032 even power of 2 │ │ │ +0007ea70: 2e0a 0969 6e74 206d 5f6e 756d 5f62 6c6f ...int m_num_blo │ │ │ +0007ea80: 636b 7320 3d20 303b 0a0a 092f 2f20 7468 cks = 0;...// th │ │ │ +0007ea90: 6520 6e75 6d62 6572 206f 6620 626c 6f63 e number of bloc │ │ │ +0007eaa0: 6b73 2070 6572 2070 6965 6365 2c20 7370 ks per piece, sp │ │ │ +0007eab0: 6563 6966 6965 6420 6173 2068 6f77 206d ecified as how m │ │ │ +0007eac0: 616e 7920 7374 6570 7320 746f 2073 6869 any steps to shi │ │ │ +0007ead0: 6674 0a09 2f2f 2072 6967 6874 2031 2074 ft..// right 1 t │ │ │ +0007eae0: 6f20 6765 7420 7468 6520 6e75 6d62 6572 o get the number │ │ │ +0007eaf0: 206f 6620 626c 6f63 6b73 2069 6e20 6f6e of blocks in on │ │ │ +0007eb00: 6520 7069 6563 652e 2054 6869 7320 6973 e piece. This is │ │ │ +0007eb10: 2061 2063 6f6d 7061 6374 0a09 2f2f 2072 a compact..// r │ │ │ +0007eb20: 6570 7265 7365 6e74 6174 696f 6e20 7468 epresentation th │ │ │ +0007eb30: 6174 2773 2076 616c 6964 2062 6563 6175 at's valid becau │ │ │ +0007eb40: 7365 2070 6965 6365 7320 6172 6520 616c se pieces are al │ │ │ +0007eb50: 7761 7973 2070 6f77 6572 7320 6f66 2032 ways powers of 2 │ │ │ +0007eb60: 2e0a 092f 2f20 7468 6973 2069 7320 6e65 ...// this is ne │ │ │ +0007eb70: 6365 7373 6172 7920 746f 206b 6e6f 7720 cessary to know │ │ │ +0007eb80: 7768 6963 6820 6c61 7965 7220 696e 2074 which layer in t │ │ │ +0007eb90: 6865 2074 7265 6520 7468 6520 7069 6563 he tree the piec │ │ │ +0007eba0: 6520 6c61 7965 7220 6973 2e0a 0973 7464 e layer is...std │ │ │ +0007ebb0: 3a3a 7569 6e74 385f 7420 6d5f 626c 6f63 ::uint8_t m_bloc │ │ │ +0007ebc0: 6b73 5f70 6572 5f70 6965 6365 5f6c 6f67 ks_per_piece_log │ │ │ +0007ebd0: 203d 2030 3b0a 0a09 656e 756d 2063 6c61 = 0;...enum cla │ │ │ +0007ebe0: 7373 206d 6f64 655f 7420 3a20 7374 643a ss mode_t : std: │ │ │ +0007ebf0: 3a75 696e 7438 5f74 0a09 7b0a 0909 2f2f :uint8_t..{...// │ │ │ +0007ec00: 2061 2064 6566 6175 6c74 2063 6f6e 7374 a default const │ │ │ +0007ec10: 7275 6374 6564 2074 7265 6520 6973 2074 ructed tree is t │ │ │ +0007ec20: 7275 6c79 2065 6d70 7479 2e20 4974 2064 ruly empty. It d │ │ │ +0007ec30: 6f65 7320 6e6f 7420 6576 656e 2068 6176 oes not even hav │ │ │ +0007ec40: 6520 610a 0909 2f2f 2072 6f6f 7420 6861 e a...// root ha │ │ │ +0007ec50: 7368 0a09 0975 6e69 6e69 7469 616c 697a sh...uninitializ │ │ │ +0007ec60: 6564 5f74 7265 652c 0a0a 0909 2f2f 2077 ed_tree,....// w │ │ │ +0007ec70: 6520 646f 6e27 7420 6861 7665 2061 6e79 e don't have any │ │ │ +0007ec80: 2068 6173 6865 7320 696e 2074 6869 7320 hashes in this │ │ │ +0007ec90: 7472 6565 2e20 6d5f 7472 6565 2073 686f tree. m_tree sho │ │ │ +0007eca0: 756c 6420 6265 2065 6d70 7479 0a09 092f uld be empty.../ │ │ │ +0007ecb0: 2f20 616e 2065 6d70 7479 2074 7265 6520 / an empty tree │ │ │ +0007ecc0: 7374 696c 6c20 616c 7761 7973 2068 6176 still always hav │ │ │ +0007ecd0: 6520 7468 6520 726f 6f74 2068 6173 6820 e the root hash │ │ │ +0007ece0: 2861 7661 696c 6162 6c65 2061 7320 726f (available as ro │ │ │ +0007ecf0: 6f74 2829 290a 0909 656d 7074 795f 7472 ot())...empty_tr │ │ │ +0007ed00: 6565 2c0a 0a09 092f 2f20 696e 2074 6869 ee,....// in thi │ │ │ +0007ed10: 7320 6d6f 6465 2c20 6d5f 7472 6565 2072 s mode, m_tree r │ │ │ +0007ed20: 6570 7265 7365 6e74 7320 7468 6520 6675 epresents the fu │ │ │ +0007ed30: 6c6c 2074 7265 652c 2069 6e63 6c75 6469 ll tree, includi │ │ │ +0007ed40: 6e67 2070 6164 6469 6e67 2e0a 0909 6675 ng padding....fu │ │ │ +0007ed50: 6c6c 5f74 7265 652c 0a0a 3c2f 7072 653e ll_tree,..
    │ │ │ +0007ed60: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +0007ed90: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +0007eda0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../include/ │ │ │ +0007edd0: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ +0007ede0: 706f 6f6c 2e68 7070 3a35 333c 2f61 3e3c pool.hpp:53< │ │ │ +0007edf0: 2f74 643e 3c74 643e 656e 7375 7265 2074 /td>ensure t │ │ │ +0007ee00: 6865 2061 6c69 676e 6d65 6e74 2069 7320 he alignment is │ │ │ +0007ee10: 676f 6f64 2068 6572 653c 2f74 643e 3c2f good here

    ensure th │ │ │ +0007ee70: 6520 616c 6967 6e6d 656e 7420 6973 2067 e alignment is g │ │ │ +0007ee80: 6f6f 6420 6865 7265 3c2f 6832 3e3c 6834 ood here

    ../include/libt │ │ │ +0007eea0: 6f72 7265 6e74 2f61 7578 5f2f 706f 6f6c orrent/aux_/pool │ │ │ +0007eeb0: 2e68 7070 3a35 333c 2f68 343e 3c70 7265 .hpp:53

    #ifndef TO
    │ │ │ +0007ef00: 5252 454e 545f 504f 4f4c 5f48 5050 0a23  RRENT_POOL_HPP.#
    │ │ │ +0007ef10: 6465 6669 6e65 2054 4f52 5245 4e54 5f50  define TORRENT_P
    │ │ │ +0007ef20: 4f4f 4c5f 4850 500a 0a23 696e 636c 7564  OOL_HPP..#includ
    │ │ │ +0007ef30: 6520 226c 6962 746f 7272 656e 742f 6173  e "libtorrent/as
    │ │ │ +0007ef40: 7365 7274 2e68 7070 220a 0a23 696e 636c  sert.hpp"..#incl
    │ │ │ +0007ef50: 7564 6520 226c 6962 746f 7272 656e 742f  ude "libtorrent/
    │ │ │ +0007ef60: 6175 785f 2f64 6973 6162 6c65 5f77 6172  aux_/disable_war
    │ │ │ +0007ef70: 6e69 6e67 735f 7075 7368 2e68 7070 220a  nings_push.hpp".
    │ │ │ +0007ef80: 2369 6e63 6c75 6465 2026 6c74 3b62 6f6f  #include <boo
    │ │ │ +0007ef90: 7374 2f70 6f6f 6c2f 706f 6f6c 2e68 7070  st/pool/pool.hpp
    │ │ │ +0007efa0: 2667 743b 0a23 696e 636c 7564 6520 226c  >.#include "l
    │ │ │ +0007efb0: 6962 746f 7272 656e 742f 6175 785f 2f64  ibtorrent/aux_/d
    │ │ │ +0007efc0: 6973 6162 6c65 5f77 6172 6e69 6e67 735f  isable_warnings_
    │ │ │ +0007efd0: 706f 702e 6870 7022 0a0a 2369 6e63 6c75  pop.hpp"..#inclu
    │ │ │ +0007efe0: 6465 2026 6c74 3b63 7374 6464 6566 2667  de <cstddef&g
    │ │ │ +0007eff0: 743b 0a23 696e 636c 7564 6520 266c 743b  t;.#include <
    │ │ │ +0007f000: 6e65 7726 6774 3b20 2f2f 2066 6f72 2070  new> // for p
    │ │ │ +0007f010: 6c61 6365 6d65 6e74 206e 6577 0a0a 6e61  lacement new..na
    │ │ │ +0007f020: 6d65 7370 6163 6520 6c69 6274 6f72 7265  mespace libtorre
    │ │ │ +0007f030: 6e74 207b 0a6e 616d 6573 7061 6365 2061  nt {.namespace a
    │ │ │ +0007f040: 7578 207b 0a0a 7374 7275 6374 2061 6c6c  ux {..struct all
    │ │ │ +0007f050: 6f63 6174 6f72 5f6e 6577 5f64 656c 6574  ocator_new_delet
    │ │ │ +0007f060: 650a 7b0a 0975 7369 6e67 2073 697a 655f  e.{..using size_
    │ │ │ +0007f070: 7479 7065 203d 2073 7464 3a3a 7369 7a65  type = std::size
    │ │ │ +0007f080: 5f74 3b0a 0975 7369 6e67 2064 6966 6665  _t;..using diffe
    │ │ │ +0007f090: 7265 6e63 655f 7479 7065 203d 2073 7464  rence_type = std
    │ │ │ +0007f0a0: 3a3a 7074 7264 6966 665f 743b 0a0a 3c64  ::ptrdiff_t;...sta
    │ │ │ +0007f0e0: 7469 6320 6368 6172 2a20 6d61 6c6c 6f63  tic char* malloc
    │ │ │ +0007f0f0: 2873 697a 655f 7479 7065 2063 6f6e 7374  (size_type const
    │ │ │ +0007f100: 2062 7974 6573 290a 3c2f 6469 763e 097b   bytes)..{
    │ │ │ +0007f110: 2072 6574 7572 6e20 6e65 7720 6368 6172   return new char
    │ │ │ +0007f120: 5b62 7974 6573 5d3b 207d 0a09 7374 6174  [bytes]; }..stat
    │ │ │ +0007f130: 6963 2076 6f69 6420 6672 6565 2863 6861  ic void free(cha
    │ │ │ +0007f140: 722a 2063 6f6e 7374 2062 6c6f 636b 290a  r* const block).
    │ │ │ +0007f150: 097b 2064 656c 6574 6520 5b5d 2062 6c6f  .{ delete [] blo
    │ │ │ +0007f160: 636b 3b20 7d0a 7d3b 0a0a 7573 696e 6720  ck; }.};..using 
    │ │ │ +0007f170: 706f 6f6c 203d 2062 6f6f 7374 3a3a 706f  pool = boost::po
    │ │ │ +0007f180: 6f6c 266c 743b 616c 6c6f 6361 746f 725f  ol<allocator_
    │ │ │ +0007f190: 6e65 775f 6465 6c65 7465 2667 743b 3b0a  new_delete>;.
    │ │ │ +0007f1a0: 0a2f 2f20 4c69 6b65 2062 6f6f 7374 3a3a  .// Like boost::
    │ │ │ +0007f1b0: 6f62 6a65 6374 5f70 6f6f 6c20 6275 7420  object_pool but 
    │ │ │ +0007f1c0: 7573 6573 2075 6e6f 7264 6572 6564 2066  uses unordered f
    │ │ │ +0007f1d0: 7265 6528 2920 7261 7468 6572 2074 6861  ree() rather tha
    │ │ │ +0007f1e0: 6e20 7468 650a 2f2f 204f 284e 2920 6f72  n the.// O(N) or
    │ │ │ +0007f1f0: 6465 7265 645f 6672 6565 2829 2074 6861  dered_free() tha
    │ │ │ +0007f200: 7420 626f 6f73 743a 3a6f 626a 6563 745f  t boost::object_
    │ │ │ +0007f210: 706f 6f6c 3a3a 6465 7374 726f 7928 2920  pool::destroy() 
    │ │ │ +0007f220: 7265 6c69 6573 206f 6e2e 0a2f 2f20 5468  relies on..// Th
    │ │ │ +0007f230: 6520 706f 6f6c 2069 7473 656c 6620 646f  e pool itself do
    │ │ │ +0007f240: 6573 206e 6f74 2074 7261 636b 206f 7574  es not track out
    │ │ │ +0007f250: 7374 616e 6469 6e67 2061 6c6c 6f63 6174  standing allocat
    │ │ │ +0007f260: 696f 6e73 2c20 736f 2063 616c 6c65 7273  ions, so callers
    │ │ │ +0007f270: 0a2f 2f20 6d75 7374 2064 6573 7472 6f79  .// must destroy
    │ │ │ +0007f280: 2829 2065 7665 7279 206f 626a 6563 7420  () every object 
    │ │ │ +0007f290: 6265 666f 7265 2074 6865 2070 6f6f 6c20  before the pool 
    │ │ │ +0007f2a0: 6973 2064 6573 7472 6f79 6564 2e0a 7465  is destroyed..te
    │ │ │ +0007f2b0: 6d70 6c61 7465 2026 6c74 3b74 7970 656e  mplate <typen
    │ │ │ +0007f2c0: 616d 6520 5426 6774 3b0a 7374 7275 6374  ame T>.struct
    │ │ │ +0007f2d0: 206f 626a 6563 745f 706f 6f6c 0a7b 0a09   object_pool.{..
    │ │ │ +0007f2e0: 6f62 6a65 6374 5f70 6f6f 6c28 2920 3a20  object_pool() : 
    │ │ │ +0007f2f0: 6d5f 706f 6f6c 2873 697a 656f 6628 5429  m_pool(sizeof(T)
    │ │ │ +0007f300: 2920 7b7d 0a09 6f62 6a65 6374 5f70 6f6f  ) {}..object_poo
    │ │ │ +0007f310: 6c28 6f62 6a65 6374 5f70 6f6f 6c20 636f  l(object_pool co
    │ │ │ +0007f320: 6e73 7426 616d 703b 2920 3d20 6465 6c65  nst&) = dele
    │ │ │ +0007f330: 7465 3b0a 096f 626a 6563 745f 706f 6f6c  te;..object_pool
    │ │ │ +0007f340: 2661 6d70 3b20 6f70 6572 6174 6f72 3d28  & operator=(
    │ │ │ +0007f350: 6f62 6a65 6374 5f70 6f6f 6c20 636f 6e73  object_pool cons
    │ │ │ +0007f360: 7426 616d 703b 2920 3d20 6465 6c65 7465  t&) = delete
    │ │ │ +0007f370: 3b0a 0a09 542a 2063 6f6e 7374 7275 6374  ;...T* construct
    │ │ │ +0007f380: 2829 0a09 7b0a 0909 766f 6964 2a20 636f  ()..{...void* co
    │ │ │ +0007f390: 6e73 7420 7374 6f72 6167 6520 3d20 6d5f  nst storage = m_
    │ │ │ +0007f3a0: 706f 6f6c 2e6d 616c 6c6f 6328 293b 0a09  pool.malloc();..
    │ │ │ +0007f3b0: 0974 7279 0a09 097b 0a09 0909 7265 7475  .try...{....retu
    │ │ │ +0007f3c0: 726e 206e 6577 2028 7374 6f72 6167 6529  rn new (storage)
    │ │ │ +0007f3d0: 2054 2829 3b0a 0909 7d0a 0909 6361 7463   T();...}...catc
    │ │ │ +0007f3e0: 6820 282e 2e2e 290a 0909 7b0a 0909 096d  h (...)...{....m
    │ │ │ +0007f3f0: 5f70 6f6f 6c2e 6672 6565 2873 746f 7261  _pool.free(stora
    │ │ │ +0007f400: 6765 293b 0a09 0909 7468 726f 773b 0a09  ge);....throw;..
    │ │ │  0007f410: 097d 0a3c 2f70 7265 3e3c 2f74 643e 3c2f  .}.
    │ │ │ ├── html2text {} │ │ │ │ @@ -454,14 +454,379 @@ │ │ │ │ | | │ │ │ │ | auto o = rpc.allocate_observer(std::move(algo), source, node_id()); | │ │ │ │ |#if TORRENT_USE_ASSERTS | │ │ │ │ | o->m_in_constructor = false; | │ │ │ │ |#endif | │ │ │ │ | o->flags |= observer::flag_queried; | │ │ │ │ |_ _r_p_c_._i_n_v_o_k_e_(_r_e_q_,_ _s_o_u_r_c_e_,_ _o_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_1_1_5_2_ _ _|_c_l_o_s_i_n_g_ _t_h_e_ _u_d_p_ _s_o_c_k_e_t_s_ _h_e_r_e_ _m_e_a_n_s_ _t_h_a_t_ _t_h_e_ _u_T_P_ _c_o_n_n_e_c_t_i_o_n_s_ _c_a_n_n_o_t_ _b_e_ _c_l_o_s_e_d_ _g_r_a_c_e_f_u_l_l_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** cclloossiinngg tthhee uuddpp ssoocckkeettss hheerree mmeeaannss tthhaatt tthhee uuTTPP ccoonnnneeccttiioonnss ccaannnnoott bbee cclloosseedd ggrraacceeffuullllyy ********** | │ │ │ │ +|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::11115522 ****** | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| session_log(" aborting all connections (%d)", int(m_connections.size())); | │ │ │ │ +|#endif | │ │ │ │ +| // abort all connections | │ │ │ │ +| for (auto i = m_connections.begin(); i != m_connections.end();) | │ │ │ │ +| { | │ │ │ │ +| peer_connection* p = (*i).get(); | │ │ │ │ +| ++i; | │ │ │ │ +| p->disconnect(errors::stopping_torrent, operation_t::bittorrent); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| // close the listen sockets | │ │ │ │ +| for (auto const& l : m_listen_sockets) | │ │ │ │ +| { | │ │ │ │ +| if (l->sock) | │ │ │ │ +| { | │ │ │ │ +| l->sock->close(ec); | │ │ │ │ +| TORRENT_ASSERT(!ec); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +|if (l->udp_sock) | │ │ │ │ +|{ | │ │ │ │ +| l->udp_sock->sock.close(); | │ │ │ │ +| } | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| // we need to give all the sockets an opportunity to actually have their handlers | │ │ │ │ +| // called and cancelled before we continue the shutdown. This is a bit | │ │ │ │ +| // complicated, if there are no "undead" peers, it's safe to resume the | │ │ │ │ +| // shutdown, but if there are, we have to wait for them to be cleared out | │ │ │ │ +| // first. In session_impl::on_tick() we check them periodically. If we're | │ │ │ │ +| // shutting down and we remove the last one, we'll initiate | │ │ │ │ +| // shutdown_stage2 from there. | │ │ │ │ +| if (m_undead_peers.empty()) | │ │ │ │ +| { | │ │ │ │ +| post(m_io_context, make_handler([this] { abort_stage2(); } | │ │ │ │ +| , m_abort_handler_storage, *this)); | │ │ │ │ +| } | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| void session_impl::abort_stage2() noexcept | │ │ │ │ +| { | │ │ │ │ +| m_download_rate.close(); | │ │ │ │ +| m_upload_rate.close(); | │ │ │ │ +| | │ │ │ │ +| // it's OK to detach the threads here. The disk_io_thread | │ │ │ │ +| // has an internal counter and won't release the network | │ │ │ │ +| // thread until they're all dead (via m_work). | │ │ │ │ +| m_disk_thread->abort(false); | │ │ │ │ +| | │ │ │ │ +|_ _ _/_/_ _n_o_w_ _i_t_'_s_ _O_K_ _f_o_r_ _t_h_e_ _n_e_t_w_o_r_k_ _t_h_r_e_a_d_ _t_o_ _e_x_i_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_1_6_5_4_ _ _|_t_h_e_ _l_o_g_i_c_ _i_n_ _t_h_i_s_ _i_f_-_b_l_o_c_k_ _s_h_o_u_l_d_ _b_e_ _f_a_c_t_o_r_e_d_ _o_u_t_ _i_n_t_o_ _a_ _s_e_p_a_r_a_t_e_ _f_u_n_c_t_i_o_n_._ _A_t_ _l_e_a_s_t_ _m_o_s_t_ _o_f_ _i_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tthhee llooggiicc iinn tthhiiss iiff--bblloocckk sshhoouulldd bbee ffaaccttoorreedd oouutt iinnttoo aa sseeppaarraattee ffuunnccttiioonn.. AAtt lleeaasstt mmoosstt ooff iitt ********** | │ │ │ │ +|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::11665544 ****** | │ │ │ │ +|, (lep.flags & listen_socket_t::local_network) ? "local-network " : "" | │ │ │ │ +| , (lep.flags & listen_socket_t::accept_incoming) ? "accept-incoming " : "no-incoming " | │ │ │ │ +| , (lep.flags & listen_socket_t::was_expanded) ? "expanded-ip " : "" | │ │ │ │ +| , (lep.flags & listen_socket_t::proxy) ? "proxy " : ""); | │ │ │ │ +| } | │ │ │ │ +|#endif | │ │ │ │ +| | │ │ │ │ +| auto ret = std::make_shared(); | │ │ │ │ +| ret->ssl = lep.ssl; | │ │ │ │ +| ret->original_port = bind_ep.port(); | │ │ │ │ +| ret->flags = lep.flags; | │ │ │ │ +| ret->netmask = lep.netmask; | │ │ │ │ +| operation_t last_op = operation_t::unknown; | │ │ │ │ +| socket_type_t const sock_type | │ │ │ │ +| = (lep.ssl == transport::ssl) | │ │ │ │ +| ? socket_type_t::tcp_ssl | │ │ │ │ +| : socket_type_t::tcp; | │ │ │ │ +| | │ │ │ │ +| // if we're in force-proxy mode, don't open TCP listen sockets. We cannot | │ │ │ │ +| // accept connections on our local machine in this case. | │ │ │ │ +|if (ret->flags & listen_socket_t::accept_incoming) | │ │ │ │ +|{ | │ │ │ │ +| ret->sock = std::make_shared(m_io_context); | │ │ │ │ +| ret->sock->open(bind_ep.protocol(), ec); | │ │ │ │ +| last_op = operation_t::sock_open; | │ │ │ │ +| if (ec) | │ │ │ │ +| { | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| if (should_log()) | │ │ │ │ +| { | │ │ │ │ +| session_log("failed to open socket: %s" | │ │ │ │ +| , ec.message().c_str()); | │ │ │ │ +| } | │ │ │ │ +|#endif | │ │ │ │ +| | │ │ │ │ +| if (m_alerts.should_post()) | │ │ │ │ +| m_alerts.emplace_alert(lep.device, bind_ep, last_op | │ │ │ │ +| , ec, sock_type); | │ │ │ │ +| return ret; | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +|#ifdef TORRENT_WINDOWS | │ │ │ │ +| { | │ │ │ │ +| // this is best-effort. ignore errors | │ │ │ │ +| error_code err; | │ │ │ │ +| ret->sock->set_option(exclusive_address_use(true), err); | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| if (err && should_log()) | │ │ │ │ +| { | │ │ │ │ +| session_log("failed enable exclusive address use on listen socket: %s" | │ │ │ │ +|_ _ _ _ _ _ _,_ _e_r_r_._m_e_s_s_a_g_e_(_)_._c___s_t_r_(_)_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_2_6_2_4_ _ _|_i_t_ _w_o_u_l_d_ _b_e_ _n_e_a_t_ _i_f_ _t_h_e_ _u_t_p_ _s_o_c_k_e_t_ _m_a_n_a_g_e_r_ _w_o_u_l_d_ _h_a_n_d_l_e_ _I_C_M_P_ _e_r_r_o_r_s_ _t_o_o_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** iitt wwoouulldd bbee nneeaatt iiff tthhee uuttpp ssoocckkeett mmaannaaggeerr wwoouulldd hhaannddllee IICCMMPP eerrrroorrss ttoooo ********** | │ │ │ │ +|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::22662244 ****** | │ │ │ │ +| std::shared_ptr s = socket.lock(); | │ │ │ │ +| if (!s) return; | │ │ │ │ +| | │ │ │ │ +| struct utp_socket_manager& mgr = | │ │ │ │ +|#ifdef TORRENT_SSL_PEERS | │ │ │ │ +| ssl == transport::ssl ? m_ssl_utp_socket_manager : | │ │ │ │ +|#endif | │ │ │ │ +| m_utp_socket_manager; | │ │ │ │ +| | │ │ │ │ +| for (;;) | │ │ │ │ +| { | │ │ │ │ +| aux::array p; | │ │ │ │ +| error_code err; | │ │ │ │ +| int const num_packets = s->sock.read(p, err); | │ │ │ │ +| | │ │ │ │ +| for (udp_socket::packet& packet : span(p).first(num_packets)) | │ │ │ │ +| { | │ │ │ │ +| if (packet.error) | │ │ │ │ +| { | │ │ │ │ +| | │ │ │ │ +|#ifndef TORRENT_DISABLE_DHT | │ │ │ │ +| if (m_dht) | │ │ │ │ +| m_dht->incoming_error(packet.error, packet.from); | │ │ │ │ +|#endif | │ │ │ │ +| | │ │ │ │ +| m_tracker_manager.incoming_error(packet.error, packet.from); | │ │ │ │ +| continue; | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| span const buf = packet.data; | │ │ │ │ +| if (!packet.hostname.empty()) | │ │ │ │ +| { | │ │ │ │ +| // only the tracker manager supports receiving UDP packets | │ │ │ │ +| // from hostnames. If it won't handle it, no one else will | │ │ │ │ +| // either | │ │ │ │ +| m_tracker_manager.incoming_packet(packet.hostname, buf); | │ │ │ │ +| continue; | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| // give the uTP socket manager first dibs on the packet. Presumably | │ │ │ │ +| // the majority of packets are uTP packets. | │ │ │ │ +| if (!mgr.incoming_packet(ls, packet.from, buf)) | │ │ │ │ +| { | │ │ │ │ +| // if it wasn't a uTP packet, try the other users of the UDP | │ │ │ │ +| // socket | │ │ │ │ +| bool handled = false; | │ │ │ │ +|#ifndef TORRENT_DISABLE_DHT | │ │ │ │ +| auto listen_socket = ls.lock(); | │ │ │ │ +| if (m_dht && buf.size() > 20 | │ │ │ │ +|_ _ _ _ _ _ _&_&_ _b_u_f_._f_r_o_n_t_(_)_ _=_=_ _'_d_'_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| | |it would probably make sense to have a separate list of peers that are eligible for optimistic unchoke, similar to the torrents | │ │ │ │ +|relevance 3|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_4_1_7_3 |perhaps this could even iterate over the pool allocators of torrent_peer objects. It could probably be done in a single pass and | │ │ │ │ +| | |collect the n best candidates. maybe just a queue of peers would make even more sense, just pick the next peer in the queue for | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_u_n_c_h_o_k_i_n_g_._ _I_t_ _w_o_u_l_d_ _b_e_ _O_(_1_)_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** iitt wwoouulldd pprroobbaabbllyy mmaakkee sseennssee ttoo hhaavvee aa sseeppaarraattee lliisstt ooff ppeeeerrss tthhaatt aarree eelliiggiibbllee ffoorr ooppttiimmiissttiicc uunncchhookkee,, ssiimmiillaarr ttoo tthhee ttoorrrreennttss ppeerrhhaappss tthhiiss ccoouulldd eevveenn iitteerraattee oovveerr tthhee | │ │ │ │ +|ppooooll aallllooccaattoorrss ooff ttoorrrreenntt__ppeeeerr oobbjjeeccttss.. IItt ccoouulldd pprroobbaabbllyy bbee ddoonnee iinn aa ssiinnggllee ppaassss aanndd ccoolllleecctt tthhee nn bbeesstt ccaannddiiddaatteess.. mmaayybbee jjuusstt aa qquueeuuee ooff ppeeeerrss wwoouulldd mmaakkee eevveenn mmoorree sseennssee,, | │ │ │ │ +|jjuusstt ppiicckk tthhee nneexxtt ppeeeerr iinn tthhee qquueeuuee ffoorr uunncchhookkiinngg.. IItt wwoouulldd bbee OO((11)).. ********** | │ │ │ │ +|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::44117733 ****** | │ │ │ │ +|} | │ │ │ │ +| | │ │ │ │ +| void session_impl::recalculate_optimistic_unchoke_slots() | │ │ │ │ +| { | │ │ │ │ +| INVARIANT_CHECK; | │ │ │ │ +| | │ │ │ │ +| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ +| if (m_stats_counters[counters::num_unchoke_slots] == 0) return; | │ │ │ │ +| | │ │ │ │ +| // if we unchoke everyone, skip this logic | │ │ │ │ +| if (settings().get_int(settings_pack::choking_algorithm) == settings_pack::fixed_slots_choker | │ │ │ │ +| && settings().get_int(settings_pack::unchoke_slots_limit) < 0) | │ │ │ │ +| return; | │ │ │ │ +| | │ │ │ │ +| std::vector opt_unchoke; | │ │ │ │ +| | │ │ │ │ +| // collect the currently optimistically unchoked peers here, so we can | │ │ │ │ +| // choke them when we've found new optimistic unchoke candidates. | │ │ │ │ +| std::vector prev_opt_unchoke; | │ │ │ │ +| | │ │ │ │ +|for (auto& i : m_connections) | │ │ │ │ +|{ | │ │ │ │ +| peer_connection* const p = i.get(); | │ │ │ │ +| TORRENT_ASSERT(p); | │ │ │ │ +| torrent_peer* pi = p->peer_info_struct(); | │ │ │ │ +| if (!pi) continue; | │ │ │ │ +| if (pi->web_seed) continue; | │ │ │ │ +| | │ │ │ │ +| if (pi->optimistically_unchoked) | │ │ │ │ +| { | │ │ │ │ +| prev_opt_unchoke.push_back(pi); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| torrent const* t = p->associated_torrent().lock().get(); | │ │ │ │ +|_ _ _ _i_f_ _(_!_t_)_ _c_o_n_t_i_n_u_e_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_4_1_9_6_ _ _|_p_e_e_r_s_ _s_h_o_u_l_d_ _k_n_o_w_ _w_h_e_t_h_e_r_ _t_h_e_i_r_ _t_o_r_r_e_n_t_ _i_s_ _p_a_u_s_e_d_ _o_r_ _n_o_t_,_ _i_n_s_t_e_a_d_ _o_f_ _h_a_v_i_n_g_ _t_o_ _a_s_k_ _i_t_ _o_v_e_r_ _a_n_d_ _o_v_e_r_ _a_g_a_i_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** ppeeeerrss sshhoouulldd kknnooww wwhheetthheerr tthheeiirr ttoorrrreenntt iiss ppaauusseedd oorr nnoott,, iinnsstteeaadd ooff hhaavviinngg ttoo aasskk iitt oovveerr aanndd oovveerr aaggaaiinn ********** | │ │ │ │ +|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::44119966 ****** | │ │ │ │ +|// collect the currently optimistically unchoked peers here, so we can | │ │ │ │ +| // choke them when we've found new optimistic unchoke candidates. | │ │ │ │ +| std::vector prev_opt_unchoke; | │ │ │ │ +| | │ │ │ │ +| for (auto& i : m_connections) | │ │ │ │ +| { | │ │ │ │ +| peer_connection* const p = i.get(); | │ │ │ │ +| TORRENT_ASSERT(p); | │ │ │ │ +| torrent_peer* pi = p->peer_info_struct(); | │ │ │ │ +| if (!pi) continue; | │ │ │ │ +| if (pi->web_seed) continue; | │ │ │ │ +| | │ │ │ │ +| if (pi->optimistically_unchoked) | │ │ │ │ +| { | │ │ │ │ +| prev_opt_unchoke.push_back(pi); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| torrent const* t = p->associated_torrent().lock().get(); | │ │ │ │ +| if (!t) continue; | │ │ │ │ +| | │ │ │ │ +|if (t->is_paused()) continue; | │ │ │ │ +| | │ │ │ │ +| if (!p->is_connecting() | │ │ │ │ +| && !p->is_disconnecting() | │ │ │ │ +| && p->is_peer_interested() | │ │ │ │ +| && t->free_upload_slots() | │ │ │ │ +| && (p->is_choked() || pi->optimistically_unchoked) | │ │ │ │ +| && !p->ignore_unchoke_slots() | │ │ │ │ +| && t->valid_metadata()) | │ │ │ │ +| { | │ │ │ │ +| opt_unchoke.emplace_back(&i); | │ │ │ │ +| } | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| // find the peers that has been waiting the longest to be optimistically | │ │ │ │ +| // unchoked | │ │ │ │ +| | │ │ │ │ +| int num_opt_unchoke = m_settings.get_int(settings_pack::num_optimistic_unchoke_slots); | │ │ │ │ +| int const allowed_unchoke_slots = int(m_stats_counters[counters::num_unchoke_slots]); | │ │ │ │ +| if (num_opt_unchoke == 0) num_opt_unchoke = std::max(1, allowed_unchoke_slots / 5); | │ │ │ │ +| if (num_opt_unchoke > int(opt_unchoke.size())) num_opt_unchoke = | │ │ │ │ +| int(opt_unchoke.size()); | │ │ │ │ +| | │ │ │ │ +| // find the n best optimistic unchoke candidates | │ │ │ │ +| std::partial_sort(opt_unchoke.begin() | │ │ │ │ +| , opt_unchoke.begin() + num_opt_unchoke | │ │ │ │ +| , opt_unchoke.end() | │ │ │ │ +|#ifndef TORRENT_DISABLE_EXTENSIONS | │ │ │ │ +| , last_optimistic_unchoke_cmp(m_ses_extensions[plugins_optimistic_unchoke_idx]) | │ │ │ │ +|#else | │ │ │ │ +|_ _ _ _,_ _l_a_s_t___o_p_t_i_m_i_s_t_i_c___u_n_c_h_o_k_e___c_m_p_(_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_4_4_4_2_ _ _|_t_h_e_r_e_ _s_h_o_u_l_d_ _b_e_ _a_ _p_r_e_-_c_a_l_c_u_l_a_t_e_d_ _l_i_s_t_ _o_f_ _a_l_l_ _p_e_e_r_s_ _e_l_i_g_i_b_l_e_ _f_o_r_ _u_n_c_h_o_k_i_n_g_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tthheerree sshhoouulldd bbee aa pprree--ccaallccuullaatteedd lliisstt ooff aallll ppeeeerrss eelliiggiibbllee ffoorr uunncchhookkiinngg ********** | │ │ │ │ +|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::44444422 ****** | │ │ │ │ +|} | │ │ │ │ +| | │ │ │ │ +| void session_impl::recalculate_unchoke_slots() | │ │ │ │ +| { | │ │ │ │ +| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ +| | │ │ │ │ +| time_point const now = aux::time_now(); | │ │ │ │ +| time_duration const unchoke_interval = now - m_last_choke; | │ │ │ │ +| m_last_choke = now; | │ │ │ │ +| | │ │ │ │ +| // if we unchoke everyone, skip this logic | │ │ │ │ +| if (settings().get_int(settings_pack::choking_algorithm) == settings_pack::fixed_slots_choker | │ │ │ │ +| && settings().get_int(settings_pack::unchoke_slots_limit) < 0) | │ │ │ │ +| { | │ │ │ │ +| m_stats_counters.set_value(counters::num_unchoke_slots, std::numeric_limits::max()); | │ │ │ │ +| return; | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| // build list of all peers that are | │ │ │ │ +| // unchokable. | │ │ │ │ +|std::vector peers; | │ │ │ │ +|for (auto i = m_connections.begin(); i != m_connections.end();) | │ │ │ │ +| { | │ │ │ │ +| std::shared_ptr p = *i; | │ │ │ │ +| TORRENT_ASSERT(p); | │ │ │ │ +| ++i; | │ │ │ │ +| torrent* const t = p->associated_torrent().lock().get(); | │ │ │ │ +| torrent_peer* const pi = p->peer_info_struct(); | │ │ │ │ +| | │ │ │ │ +| if (p->ignore_unchoke_slots() || t == nullptr || pi == nullptr | │ │ │ │ +| || pi->web_seed || t->is_paused()) | │ │ │ │ +| { | │ │ │ │ +| p->reset_choke_counters(); | │ │ │ │ +| continue; | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| if (!p->is_peer_interested() | │ │ │ │ +| || p->is_disconnecting() | │ │ │ │ +| || p->is_connecting()) | │ │ │ │ +| { | │ │ │ │ +| // this peer is not unchokable. So, if it's unchoked | │ │ │ │ +| // already, make sure to choke it. | │ │ │ │ +| if (p->is_choked()) | │ │ │ │ +| { | │ │ │ │ +| p->reset_choke_counters(); | │ │ │ │ +| continue; | │ │ │ │ +| } | │ │ │ │ +| if (pi && pi->optimistically_unchoked) | │ │ │ │ +| { | │ │ │ │ +| m_stats_counters.inc_stats_counter(counters::num_peers_up_unchoked_optimistic, -1); | │ │ │ │ +|_ _ _ _ _ _p_i_-_>_o_p_t_i_m_i_s_t_i_c_a_l_l_y___u_n_c_h_o_k_e_d_ _=_ _f_a_l_s_e_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_6_1_7_3_ _ _|_u_s_e_ _p_u_b_l_i_c___k_e_y_ _h_e_r_e_ _i_n_s_t_e_a_d_ _o_f_ _s_t_d_:_:_a_r_r_a_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** uussee ppuubblliicc__kkeeyy hheerree iinnsstteeaadd ooff ssttdd::::aarrrraayy ********** | │ │ │ │ +|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::66117733 ****** | │ │ │ │ +| void session_impl::dht_get_immutable_item(sha1_hash const& target) | │ │ │ │ +| { | │ │ │ │ +| if (!m_dht) return; | │ │ │ │ +| m_dht->get_item(target, std::bind(&session_impl::get_immutable_callback | │ │ │ │ +| , this, target, _1)); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| // callback for dht_mutable_get | │ │ │ │ +| void session_impl::get_mutable_callback(dht::item const& i | │ │ │ │ +| , bool const authoritative) | │ │ │ │ +| { | │ │ │ │ +| TORRENT_ASSERT(i.is_mutable()); | │ │ │ │ +| m_alerts.emplace_alert(i.pk().bytes | │ │ │ │ +| , i.sig().bytes, i.seq().value | │ │ │ │ +| , i.salt(), i.value(), authoritative); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| // key is a 32-byte binary string, the public key to look up. | │ │ │ │ +| // the salt is optional | │ │ │ │ +|void session_impl::dht_get_mutable_item(std::array key | │ │ │ │ +|, std::string salt) | │ │ │ │ +| { | │ │ │ │ +| if (!m_dht) return; | │ │ │ │ +| m_dht->get_item(dht::public_key(key.data()), std::bind(&session_impl::get_mutable_callback | │ │ │ │ +| , this, _1, _2), std::move(salt)); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| namespace { | │ │ │ │ +| | │ │ │ │ +| void on_dht_put_immutable_item(aux::alert_manager& alerts, sha1_hash target, int num) | │ │ │ │ +| { | │ │ │ │ +| if (alerts.should_post()) | │ │ │ │ +| alerts.emplace_alert(target, num); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| void on_dht_put_mutable_item(aux::alert_manager& alerts, dht::item const& i, int num) | │ │ │ │ +| { | │ │ │ │ +| if (alerts.should_post()) | │ │ │ │ +| { | │ │ │ │ +| dht::signature const sig = i.sig(); | │ │ │ │ +| dht::public_key const pk = i.pk(); | │ │ │ │ +| dht::sequence_number const seq = i.seq(); | │ │ │ │ +| std::string salt = i.salt(); | │ │ │ │ +| alerts.emplace_alert(pk.bytes, sig.bytes | │ │ │ │ +| , std::move(salt), seq.value, num); | │ │ │ │ +| } | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| void put_mutable_callback(dht::item& i | │ │ │ │ +|_ _ _ _,_ _s_t_d_:_:_f_u_n_c_t_i_o_n_<_v_o_i_d_(_e_n_t_r_y_&_,_ _s_t_d_:_:_a_r_r_a_y_<_c_h_a_r_,_ _6_4_>_&_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |relevance 3|_._._/_s_r_c_/ |this should be an optional, piece index -1 should not be allowed | │ │ │ │ |_ _ _ _ _ _ _ _ _ _ _ _|_w_e_b___p_e_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_:_2_0_0_ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** tthhiiss sshhoouulldd bbee aann ooppttiioonnaall,, ppiieeccee iinnddeexx --11 sshhoouulldd nnoott bbee aalllloowweedd ********** | │ │ │ │ |****** ....//ssrrcc//wweebb__ppeeeerr__ccoonnnneeccttiioonn..ccpppp::220000 ****** | │ │ │ │ | auto const range = aux::file_piece_range_inclusive(fs, i); | │ │ │ │ | for (piece_index_t k = std::get<0>(range); k < std::get<1>(range); ++k) | │ │ │ │ | have.clear_bit(k); | │ │ │ │ @@ -673,48 +1038,179 @@ │ │ │ │ | // E.g. original "web_seed_t" request url points to "http://example1.com/file1" and | │ │ │ │ | // web server responses with redirect location "http://example2.com/subpath/file2". | │ │ │ │ | // "handle_redirect" process this location to create new "web_seed_t" | │ │ │ │ | // with base url=="http://example2.com/" and redirects[0]=="/subpath/file2"). | │ │ │ │ | // If we try to load resume with such "web_seed_t" then "web_peer_connection" will send | │ │ │ │ | // request with wrong path "http://example2.com/file1" (cause "redirects" map is not serialized in resume) | │ │ │ │ |_ _ _w_e_b___s_e_e_d___t_*_ _w_e_b_ _=_ _t_-_>_a_d_d___w_e_b___s_e_e_d_(_r_e_d_i_r_e_c_t___b_a_s_e_,_ _w_e_b___s_e_e_d___e_n_t_r_y_:_:_u_r_l___s_e_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_u_t___m_e_t_a_d_a_t_a_._c_p_p_:_2_6_8_ _ _ _ _|_u_s_e_ _t_h_e_ _a_u_x_:_:_w_r_i_t_e___*_ _f_u_n_c_t_i_o_n_s_ _a_n_d_ _t_h_e_ _s_p_a_n_ _h_e_r_e_ _i_n_s_t_e_a_d_,_ _i_t_ _w_i_l_l_ _f_i_t_ _b_e_t_t_e_r_ _w_i_t_h_ _s_e_n_d___b_u_f_f_e_r_(_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** uussee tthhee aauuxx::::wwrriittee__** ffuunnccttiioonnss aanndd tthhee ssppaann hheerree iinnsstteeaadd,, iitt wwiillll ffiitt bbeetttteerr wwiitthh sseenndd__bbuuffffeerr(()) ********** | │ │ │ │ -|****** ....//ssrrcc//uutt__mmeettaaddaattaa..ccpppp::226688 ****** | │ │ │ │ -|int metadata_piece_size = 0; | │ │ │ │ +| |_._._/_s_r_c_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_: |instead of having to ask the torrent whether it's in graceful pause mode or not, the peers should keep that state (and the torrent | │ │ │ │ +|relevance 3|_3_1_4_7 |should update them when it enters graceful pause). When a peer enters graceful pause mode, it should cancel all outstanding requests| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_a_n_d_ _c_l_e_a_r_ _i_t_s_ _r_e_q_u_e_s_t_ _q_u_e_u_e_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** iinnsstteeaadd ooff hhaavviinngg ttoo aasskk tthhee ttoorrrreenntt wwhheetthheerr iitt''ss iinn ggrraacceeffuull ppaauussee mmooddee oorr nnoott,, tthhee ppeeeerrss sshhoouulldd kkeeeepp tthhaatt ssttaattee ((aanndd tthhee ttoorrrreenntt sshhoouulldd uuppddaattee tthheemm wwhheenn iitt eenntteerrss | │ │ │ │ +|ggrraacceeffuull ppaauussee)).. WWhheenn aa ppeeeerr eenntteerrss ggrraacceeffuull ppaauussee mmooddee,, iitt sshhoouulldd ccaanncceell aallll oouuttssttaannddiinngg rreeqquueessttss aanndd cclleeaarr iittss rreeqquueesstt qquueeuuee.. ********** | │ │ │ │ +|****** ....//ssrrcc//ppeeeerr__ccoonnnneeccttiioonn..ccpppp::33114477 ****** | │ │ │ │ +|// to disk or are in the disk write cache | │ │ │ │ +| if (picker.is_piece_finished(p.piece) && !was_finished) | │ │ │ │ +| { | │ │ │ │ +|#if TORRENT_USE_INVARIANT_CHECKS | │ │ │ │ +| check_postcondition post_checker2_(t, false); | │ │ │ │ +|#endif | │ │ │ │ +| t->verify_piece(p.piece); | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -| if (m_torrent.valid_metadata()) | │ │ │ │ -| e["total_size"] = m_tp.metadata().size(); | │ │ │ │ +| check_graceful_pause(); | │ │ │ │ | | │ │ │ │ -| if (type == msg_t::piece) | │ │ │ │ -| { | │ │ │ │ -| TORRENT_ASSERT(piece >= 0 && piece < (m_tp.metadata().size() + 16 * 1024 - 1) / (16 * 1024)); | │ │ │ │ -| TORRENT_ASSERT(m_pc.associated_torrent().lock()->valid_metadata()); | │ │ │ │ -| TORRENT_ASSERT(m_torrent.valid_metadata()); | │ │ │ │ +| if (is_disconnecting()) return; | │ │ │ │ | | │ │ │ │ -| int const offset = piece * 16 * 1024; | │ │ │ │ -| metadata = m_tp.metadata().data() + offset; | │ │ │ │ -| metadata_piece_size = std::min( | │ │ │ │ -| int(m_tp.metadata().size()) - offset, 16 * 1024); | │ │ │ │ -| TORRENT_ASSERT(metadata_piece_size > 0); | │ │ │ │ -| TORRENT_ASSERT(offset >= 0); | │ │ │ │ -| TORRENT_ASSERT(offset + metadata_piece_size <= m_tp.metadata().size()); | │ │ │ │ -| } | │ │ │ │ +| if (request_a_block(*t, *this)) | │ │ │ │ +| m_counters.inc_stats_counter(counters::incoming_piece_picks); | │ │ │ │ +| send_block_requests(); | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -|char msg[200]; | │ │ │ │ -|char* header = msg; | │ │ │ │ -| char* p = &msg[6]; | │ │ │ │ -| int const len = bencode(p, e); | │ │ │ │ -| int const total_size = 2 + len + metadata_piece_size; | │ │ │ │ -| namespace io = aux; | │ │ │ │ -| io::write_uint32(total_size, header); | │ │ │ │ -| io::write_uint8(bt_peer_connection::msg_extended, header); | │ │ │ │ -| io::write_uint8(m_message_index, header); | │ │ │ │ +| void peer_connection::check_graceful_pause() | │ │ │ │ +| { | │ │ │ │ +|std::shared_ptr t = m_torrent.lock(); | │ │ │ │ +|if (!t || !t->graceful_pause()) return; | │ │ │ │ | | │ │ │ │ -|_ _ _ _m___p_c_._s_e_n_d___b_u_f_f_e_r_(_{_m_s_g_,_ _l_e_n_ _+_ _6_}_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| if (m_outstanding_bytes > 0) return; | │ │ │ │ +| | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| peer_log(peer_log_alert::info, "GRACEFUL_PAUSE", "NO MORE DOWNLOAD"); | │ │ │ │ +|#endif | │ │ │ │ +| disconnect(errors::torrent_paused, operation_t::bittorrent); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| void peer_connection::on_disk_write_complete(storage_error const& error | │ │ │ │ +| , peer_request const& p, std::shared_ptr t) | │ │ │ │ +| { | │ │ │ │ +| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| if (should_log(peer_log_alert::info)) | │ │ │ │ +| { | │ │ │ │ +| peer_log(peer_log_alert::info, "FILE_ASYNC_WRITE_COMPLETE", "piece: %d s: %x l: %x e: %s" | │ │ │ │ +| , static_cast(p.piece), std::uint32_t(p.start), std::uint32_t(p.length), error.ec.message().c_str()); | │ │ │ │ +| } | │ │ │ │ +|#endif | │ │ │ │ +| | │ │ │ │ +| m_counters.inc_stats_counter(counters::queued_write_bytes, -p.length); | │ │ │ │ +| m_outstanding_writing_bytes -= p.length; | │ │ │ │ +| | │ │ │ │ +| TORRENT_ASSERT(m_outstanding_writing_bytes >= 0); | │ │ │ │ +| | │ │ │ │ +| // every peer is entitled to allocate a disk buffer if it has no writes outstanding | │ │ │ │ +| // see the comment in incoming_piece | │ │ │ │ +|_ _ _i_f_ _(_m___o_u_t_s_t_a_n_d_i_n_g___w_r_i_t_i_n_g___b_y_t_e_s_ _=_=_ _0_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 3|_._._/_s_r_c_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_: |once peers are properly put in graceful pause mode, they can cancel all outstanding requests and this test can be removed. | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_4_0_3_8_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** oonnccee ppeeeerrss aarree pprrooppeerrllyy ppuutt iinn ggrraacceeffuull ppaauussee mmooddee,, tthheeyy ccaann ccaanncceell aallll oouuttssttaannddiinngg rreeqquueessttss aanndd tthhiiss tteesstt ccaann bbee rreemmoovveedd.. ********** | │ │ │ │ +|****** ....//ssrrcc//ppeeeerr__ccoonnnneeccttiioonn..ccpppp::44003388 ****** | │ │ │ │ +| if (!p->m_deferred_send_block_requests) | │ │ │ │ +| return; | │ │ │ │ +| | │ │ │ │ +| p->m_deferred_send_block_requests = false; | │ │ │ │ +| p->send_block_requests_impl(); | │ │ │ │ +| }); | │ │ │ │ +| m_deferred_send_block_requests = true; | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| void peer_connection::send_block_requests_impl() | │ │ │ │ +| { | │ │ │ │ +| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ +| INVARIANT_CHECK; | │ │ │ │ +| | │ │ │ │ +| std::shared_ptr t = m_torrent.lock(); | │ │ │ │ +| if (!t) return; | │ │ │ │ +| | │ │ │ │ +| if (m_disconnecting) return; | │ │ │ │ +| | │ │ │ │ +|if (t->graceful_pause()) return; | │ │ │ │ +| | │ │ │ │ +| // we can't download pieces in these states | │ │ │ │ +| if (t->state() == torrent_status::checking_files | │ │ │ │ +| || t->state() == torrent_status::checking_resume_data | │ │ │ │ +| || t->state() == torrent_status::downloading_metadata) | │ │ │ │ +| return; | │ │ │ │ +| | │ │ │ │ +| if (int(m_download_queue.size()) >= m_desired_queue_size | │ │ │ │ +| || t->upload_mode()) return; | │ │ │ │ +| | │ │ │ │ +| bool const empty_download_queue = m_download_queue.empty(); | │ │ │ │ +| | │ │ │ │ +| while (!m_request_queue.empty() | │ │ │ │ +| && (int(m_download_queue.size()) < m_desired_queue_size | │ │ │ │ +| || m_queued_time_critical > 0)) | │ │ │ │ +| { | │ │ │ │ +| pending_block block = m_request_queue.front(); | │ │ │ │ +| | │ │ │ │ +| m_request_queue.erase(m_request_queue.begin()); | │ │ │ │ +| if (m_queued_time_critical) --m_queued_time_critical; | │ │ │ │ +| | │ │ │ │ +| // if we're a seed, we don't have a piece picker | │ │ │ │ +| // so we don't have to worry about invariants getting | │ │ │ │ +| // out of sync with it | │ │ │ │ +| if (!t->has_picker()) continue; | │ │ │ │ +| | │ │ │ │ +| // this can happen if a block times out, is re-requested and | │ │ │ │ +| // then arrives "unexpectedly" | │ │ │ │ +| if (t->picker().is_downloaded(block.block)) | │ │ │ │ +|_ _ _ _{_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 3|_._._/_s_r_c_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_: |new_piece should be an optional. piece index -1 should not be allowed | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_4_7_1_5_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** nneeww__ppiieeccee sshhoouulldd bbee aann ooppttiioonnaall.. ppiieeccee iinnddeexx --11 sshhoouulldd nnoott bbee aalllloowweedd ********** | │ │ │ │ +|****** ....//ssrrcc//ppeeeerr__ccoonnnneeccttiioonn..ccpppp::44771155 ****** | │ │ │ │ +| // pieces may be empty if we don't have metadata yet | │ │ │ │ +| if (p.pieces.empty()) | │ │ │ │ +| { | │ │ │ │ +| p.progress = 0.f; | │ │ │ │ +| p.progress_ppm = 0; | │ │ │ │ +| } | │ │ │ │ +| else | │ │ │ │ +| { | │ │ │ │ +|#if TORRENT_NO_FPU | │ │ │ │ +| p.progress = 0.f; | │ │ │ │ +|#else | │ │ │ │ +| p.progress = float(p.pieces.count()) / float(p.pieces.size()); | │ │ │ │ +|#endif | │ │ │ │ +| p.progress_ppm = int(std::int64_t(p.pieces.count()) * 1000000 / p.pieces.size()); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +|#ifndef TORRENT_DISABLE_SUPERSEEDING | │ │ │ │ +|void peer_connection::superseed_piece(piece_index_t const replace_piece | │ │ │ │ +|, piece_index_t const new_piece) | │ │ │ │ +| { | │ │ │ │ +| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ +| | │ │ │ │ +| if (is_connecting()) return; | │ │ │ │ +| if (in_handshake()) return; | │ │ │ │ +| | │ │ │ │ +| if (new_piece == piece_index_t(-1)) | │ │ │ │ +| { | │ │ │ │ +| if (m_superseed_piece[0] == piece_index_t(-1)) return; | │ │ │ │ +| m_superseed_piece[0] = piece_index_t(-1); | │ │ │ │ +| m_superseed_piece[1] = piece_index_t(-1); | │ │ │ │ +| | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| peer_log(peer_log_alert::info, "SUPER_SEEDING", "ending"); | │ │ │ │ +|#endif | │ │ │ │ +| std::shared_ptr t = m_torrent.lock(); | │ │ │ │ +| TORRENT_ASSERT(t); | │ │ │ │ +| | │ │ │ │ +| // this will either send a full bitfield or | │ │ │ │ +| // a have-all message, effectively terminating | │ │ │ │ +| // super-seeding, since the peer may pick any piece | │ │ │ │ +| write_bitfield(); | │ │ │ │ +| | │ │ │ │ +| return; | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| TORRENT_ASSERT(!has_piece(new_piece)); | │ │ │ │ +| | │ │ │ │ +|_#_i_f_n_d_e_f_ _T_O_R_R_E_N_T___D_I_S_A_B_L_E___L_O_G_G_I_N_G_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_t_o_r_r_e_n_t_._c_p_p_:_4_6_1_ _ _ _ _ _ _ _ _|_w_e_ _c_o_u_l_d_ _p_r_o_b_a_b_l_y_ _g_e_t_ _a_w_a_y_ _w_i_t_h_ _j_u_s_t_ _s_a_v_i_n_g_ _a_ _f_e_w_ _f_i_e_l_d_s_ _h_e_r_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** wwee ccoouulldd pprroobbaabbllyy ggeett aawwaayy wwiitthh jjuusstt ssaavviinngg aa ffeeww ffiieellddss hheerree ********** | │ │ │ │ |****** ....//ssrrcc//ttoorrrreenntt..ccpppp::446611 ****** | │ │ │ │ |// --- V2 HASHES --- | │ │ │ │ | | │ │ │ │ | if (m_torrent_file->is_valid() && m_torrent_file->info_hashes().has_v2()) | │ │ │ │ | { | │ │ │ │ @@ -1011,379 +1507,48 @@ │ │ │ │ | } | │ │ │ │ | if (pc->has_piece(i)) ++availability; | │ │ │ │ | } | │ │ │ │ | if (availability > min_availability) continue; | │ │ │ │ | if (availability == min_availability) | │ │ │ │ | { | │ │ │ │ |_ _ _ _ _a_v_a_i_l___v_e_c_._p_u_s_h___b_a_c_k_(_i_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_1_1_5_2_ _ _|_c_l_o_s_i_n_g_ _t_h_e_ _u_d_p_ _s_o_c_k_e_t_s_ _h_e_r_e_ _m_e_a_n_s_ _t_h_a_t_ _t_h_e_ _u_T_P_ _c_o_n_n_e_c_t_i_o_n_s_ _c_a_n_n_o_t_ _b_e_ _c_l_o_s_e_d_ _g_r_a_c_e_f_u_l_l_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** cclloossiinngg tthhee uuddpp ssoocckkeettss hheerree mmeeaannss tthhaatt tthhee uuTTPP ccoonnnneeccttiioonnss ccaannnnoott bbee cclloosseedd ggrraacceeffuullllyy ********** | │ │ │ │ -|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::11115522 ****** | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| session_log(" aborting all connections (%d)", int(m_connections.size())); | │ │ │ │ -|#endif | │ │ │ │ -| // abort all connections | │ │ │ │ -| for (auto i = m_connections.begin(); i != m_connections.end();) | │ │ │ │ -| { | │ │ │ │ -| peer_connection* p = (*i).get(); | │ │ │ │ -| ++i; | │ │ │ │ -| p->disconnect(errors::stopping_torrent, operation_t::bittorrent); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // close the listen sockets | │ │ │ │ -| for (auto const& l : m_listen_sockets) | │ │ │ │ -| { | │ │ │ │ -| if (l->sock) | │ │ │ │ -| { | │ │ │ │ -| l->sock->close(ec); | │ │ │ │ -| TORRENT_ASSERT(!ec); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -|if (l->udp_sock) | │ │ │ │ -|{ | │ │ │ │ -| l->udp_sock->sock.close(); | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // we need to give all the sockets an opportunity to actually have their handlers | │ │ │ │ -| // called and cancelled before we continue the shutdown. This is a bit | │ │ │ │ -| // complicated, if there are no "undead" peers, it's safe to resume the | │ │ │ │ -| // shutdown, but if there are, we have to wait for them to be cleared out | │ │ │ │ -| // first. In session_impl::on_tick() we check them periodically. If we're | │ │ │ │ -| // shutting down and we remove the last one, we'll initiate | │ │ │ │ -| // shutdown_stage2 from there. | │ │ │ │ -| if (m_undead_peers.empty()) | │ │ │ │ -| { | │ │ │ │ -| post(m_io_context, make_handler([this] { abort_stage2(); } | │ │ │ │ -| , m_abort_handler_storage, *this)); | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| void session_impl::abort_stage2() noexcept | │ │ │ │ -| { | │ │ │ │ -| m_download_rate.close(); | │ │ │ │ -| m_upload_rate.close(); | │ │ │ │ -| | │ │ │ │ -| // it's OK to detach the threads here. The disk_io_thread | │ │ │ │ -| // has an internal counter and won't release the network | │ │ │ │ -| // thread until they're all dead (via m_work). | │ │ │ │ -| m_disk_thread->abort(false); | │ │ │ │ -| | │ │ │ │ -|_ _ _/_/_ _n_o_w_ _i_t_'_s_ _O_K_ _f_o_r_ _t_h_e_ _n_e_t_w_o_r_k_ _t_h_r_e_a_d_ _t_o_ _e_x_i_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_1_6_5_4_ _ _|_t_h_e_ _l_o_g_i_c_ _i_n_ _t_h_i_s_ _i_f_-_b_l_o_c_k_ _s_h_o_u_l_d_ _b_e_ _f_a_c_t_o_r_e_d_ _o_u_t_ _i_n_t_o_ _a_ _s_e_p_a_r_a_t_e_ _f_u_n_c_t_i_o_n_._ _A_t_ _l_e_a_s_t_ _m_o_s_t_ _o_f_ _i_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tthhee llooggiicc iinn tthhiiss iiff--bblloocckk sshhoouulldd bbee ffaaccttoorreedd oouutt iinnttoo aa sseeppaarraattee ffuunnccttiioonn.. AAtt lleeaasstt mmoosstt ooff iitt ********** | │ │ │ │ -|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::11665544 ****** | │ │ │ │ -|, (lep.flags & listen_socket_t::local_network) ? "local-network " : "" | │ │ │ │ -| , (lep.flags & listen_socket_t::accept_incoming) ? "accept-incoming " : "no-incoming " | │ │ │ │ -| , (lep.flags & listen_socket_t::was_expanded) ? "expanded-ip " : "" | │ │ │ │ -| , (lep.flags & listen_socket_t::proxy) ? "proxy " : ""); | │ │ │ │ -| } | │ │ │ │ -|#endif | │ │ │ │ -| | │ │ │ │ -| auto ret = std::make_shared(); | │ │ │ │ -| ret->ssl = lep.ssl; | │ │ │ │ -| ret->original_port = bind_ep.port(); | │ │ │ │ -| ret->flags = lep.flags; | │ │ │ │ -| ret->netmask = lep.netmask; | │ │ │ │ -| operation_t last_op = operation_t::unknown; | │ │ │ │ -| socket_type_t const sock_type | │ │ │ │ -| = (lep.ssl == transport::ssl) | │ │ │ │ -| ? socket_type_t::tcp_ssl | │ │ │ │ -| : socket_type_t::tcp; | │ │ │ │ -| | │ │ │ │ -| // if we're in force-proxy mode, don't open TCP listen sockets. We cannot | │ │ │ │ -| // accept connections on our local machine in this case. | │ │ │ │ -|if (ret->flags & listen_socket_t::accept_incoming) | │ │ │ │ -|{ | │ │ │ │ -| ret->sock = std::make_shared(m_io_context); | │ │ │ │ -| ret->sock->open(bind_ep.protocol(), ec); | │ │ │ │ -| last_op = operation_t::sock_open; | │ │ │ │ -| if (ec) | │ │ │ │ -| { | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| if (should_log()) | │ │ │ │ -| { | │ │ │ │ -| session_log("failed to open socket: %s" | │ │ │ │ -| , ec.message().c_str()); | │ │ │ │ -| } | │ │ │ │ -|#endif | │ │ │ │ -| | │ │ │ │ -| if (m_alerts.should_post()) | │ │ │ │ -| m_alerts.emplace_alert(lep.device, bind_ep, last_op | │ │ │ │ -| , ec, sock_type); | │ │ │ │ -| return ret; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -|#ifdef TORRENT_WINDOWS | │ │ │ │ -| { | │ │ │ │ -| // this is best-effort. ignore errors | │ │ │ │ -| error_code err; | │ │ │ │ -| ret->sock->set_option(exclusive_address_use(true), err); | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| if (err && should_log()) | │ │ │ │ -| { | │ │ │ │ -| session_log("failed enable exclusive address use on listen socket: %s" | │ │ │ │ -|_ _ _ _ _ _ _,_ _e_r_r_._m_e_s_s_a_g_e_(_)_._c___s_t_r_(_)_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_2_6_2_4_ _ _|_i_t_ _w_o_u_l_d_ _b_e_ _n_e_a_t_ _i_f_ _t_h_e_ _u_t_p_ _s_o_c_k_e_t_ _m_a_n_a_g_e_r_ _w_o_u_l_d_ _h_a_n_d_l_e_ _I_C_M_P_ _e_r_r_o_r_s_ _t_o_o_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** iitt wwoouulldd bbee nneeaatt iiff tthhee uuttpp ssoocckkeett mmaannaaggeerr wwoouulldd hhaannddllee IICCMMPP eerrrroorrss ttoooo ********** | │ │ │ │ -|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::22662244 ****** | │ │ │ │ -| std::shared_ptr s = socket.lock(); | │ │ │ │ -| if (!s) return; | │ │ │ │ -| | │ │ │ │ -| struct utp_socket_manager& mgr = | │ │ │ │ -|#ifdef TORRENT_SSL_PEERS | │ │ │ │ -| ssl == transport::ssl ? m_ssl_utp_socket_manager : | │ │ │ │ -|#endif | │ │ │ │ -| m_utp_socket_manager; | │ │ │ │ -| | │ │ │ │ -| for (;;) | │ │ │ │ -| { | │ │ │ │ -| aux::array p; | │ │ │ │ -| error_code err; | │ │ │ │ -| int const num_packets = s->sock.read(p, err); | │ │ │ │ -| | │ │ │ │ -| for (udp_socket::packet& packet : span(p).first(num_packets)) | │ │ │ │ -| { | │ │ │ │ -| if (packet.error) | │ │ │ │ -| { | │ │ │ │ -| | │ │ │ │ -|#ifndef TORRENT_DISABLE_DHT | │ │ │ │ -| if (m_dht) | │ │ │ │ -| m_dht->incoming_error(packet.error, packet.from); | │ │ │ │ -|#endif | │ │ │ │ -| | │ │ │ │ -| m_tracker_manager.incoming_error(packet.error, packet.from); | │ │ │ │ -| continue; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| span const buf = packet.data; | │ │ │ │ -| if (!packet.hostname.empty()) | │ │ │ │ -| { | │ │ │ │ -| // only the tracker manager supports receiving UDP packets | │ │ │ │ -| // from hostnames. If it won't handle it, no one else will | │ │ │ │ -| // either | │ │ │ │ -| m_tracker_manager.incoming_packet(packet.hostname, buf); | │ │ │ │ -| continue; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // give the uTP socket manager first dibs on the packet. Presumably | │ │ │ │ -| // the majority of packets are uTP packets. | │ │ │ │ -| if (!mgr.incoming_packet(ls, packet.from, buf)) | │ │ │ │ -| { | │ │ │ │ -| // if it wasn't a uTP packet, try the other users of the UDP | │ │ │ │ -| // socket | │ │ │ │ -| bool handled = false; | │ │ │ │ -|#ifndef TORRENT_DISABLE_DHT | │ │ │ │ -| auto listen_socket = ls.lock(); | │ │ │ │ -| if (m_dht && buf.size() > 20 | │ │ │ │ -|_ _ _ _ _ _ _&_&_ _b_u_f_._f_r_o_n_t_(_)_ _=_=_ _'_d_'_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| | |it would probably make sense to have a separate list of peers that are eligible for optimistic unchoke, similar to the torrents | │ │ │ │ -|relevance 3|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_4_1_7_3 |perhaps this could even iterate over the pool allocators of torrent_peer objects. It could probably be done in a single pass and | │ │ │ │ -| | |collect the n best candidates. maybe just a queue of peers would make even more sense, just pick the next peer in the queue for | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_u_n_c_h_o_k_i_n_g_._ _I_t_ _w_o_u_l_d_ _b_e_ _O_(_1_)_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** iitt wwoouulldd pprroobbaabbllyy mmaakkee sseennssee ttoo hhaavvee aa sseeppaarraattee lliisstt ooff ppeeeerrss tthhaatt aarree eelliiggiibbllee ffoorr ooppttiimmiissttiicc uunncchhookkee,, ssiimmiillaarr ttoo tthhee ttoorrrreennttss ppeerrhhaappss tthhiiss ccoouulldd eevveenn iitteerraattee oovveerr tthhee | │ │ │ │ -|ppooooll aallllooccaattoorrss ooff ttoorrrreenntt__ppeeeerr oobbjjeeccttss.. IItt ccoouulldd pprroobbaabbllyy bbee ddoonnee iinn aa ssiinnggllee ppaassss aanndd ccoolllleecctt tthhee nn bbeesstt ccaannddiiddaatteess.. mmaayybbee jjuusstt aa qquueeuuee ooff ppeeeerrss wwoouulldd mmaakkee eevveenn mmoorree sseennssee,, | │ │ │ │ -|jjuusstt ppiicckk tthhee nneexxtt ppeeeerr iinn tthhee qquueeuuee ffoorr uunncchhookkiinngg.. IItt wwoouulldd bbee OO((11)).. ********** | │ │ │ │ -|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::44117733 ****** | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -| void session_impl::recalculate_optimistic_unchoke_slots() | │ │ │ │ -| { | │ │ │ │ -| INVARIANT_CHECK; | │ │ │ │ -| | │ │ │ │ -| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ -| if (m_stats_counters[counters::num_unchoke_slots] == 0) return; | │ │ │ │ -| | │ │ │ │ -| // if we unchoke everyone, skip this logic | │ │ │ │ -| if (settings().get_int(settings_pack::choking_algorithm) == settings_pack::fixed_slots_choker | │ │ │ │ -| && settings().get_int(settings_pack::unchoke_slots_limit) < 0) | │ │ │ │ -| return; | │ │ │ │ -| | │ │ │ │ -| std::vector opt_unchoke; | │ │ │ │ -| | │ │ │ │ -| // collect the currently optimistically unchoked peers here, so we can | │ │ │ │ -| // choke them when we've found new optimistic unchoke candidates. | │ │ │ │ -| std::vector prev_opt_unchoke; | │ │ │ │ -| | │ │ │ │ -|for (auto& i : m_connections) | │ │ │ │ -|{ | │ │ │ │ -| peer_connection* const p = i.get(); | │ │ │ │ -| TORRENT_ASSERT(p); | │ │ │ │ -| torrent_peer* pi = p->peer_info_struct(); | │ │ │ │ -| if (!pi) continue; | │ │ │ │ -| if (pi->web_seed) continue; | │ │ │ │ -| | │ │ │ │ -| if (pi->optimistically_unchoked) | │ │ │ │ -| { | │ │ │ │ -| prev_opt_unchoke.push_back(pi); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| torrent const* t = p->associated_torrent().lock().get(); | │ │ │ │ -|_ _ _ _i_f_ _(_!_t_)_ _c_o_n_t_i_n_u_e_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_4_1_9_6_ _ _|_p_e_e_r_s_ _s_h_o_u_l_d_ _k_n_o_w_ _w_h_e_t_h_e_r_ _t_h_e_i_r_ _t_o_r_r_e_n_t_ _i_s_ _p_a_u_s_e_d_ _o_r_ _n_o_t_,_ _i_n_s_t_e_a_d_ _o_f_ _h_a_v_i_n_g_ _t_o_ _a_s_k_ _i_t_ _o_v_e_r_ _a_n_d_ _o_v_e_r_ _a_g_a_i_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ppeeeerrss sshhoouulldd kknnooww wwhheetthheerr tthheeiirr ttoorrrreenntt iiss ppaauusseedd oorr nnoott,, iinnsstteeaadd ooff hhaavviinngg ttoo aasskk iitt oovveerr aanndd oovveerr aaggaaiinn ********** | │ │ │ │ -|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::44119966 ****** | │ │ │ │ -|// collect the currently optimistically unchoked peers here, so we can | │ │ │ │ -| // choke them when we've found new optimistic unchoke candidates. | │ │ │ │ -| std::vector prev_opt_unchoke; | │ │ │ │ -| | │ │ │ │ -| for (auto& i : m_connections) | │ │ │ │ -| { | │ │ │ │ -| peer_connection* const p = i.get(); | │ │ │ │ -| TORRENT_ASSERT(p); | │ │ │ │ -| torrent_peer* pi = p->peer_info_struct(); | │ │ │ │ -| if (!pi) continue; | │ │ │ │ -| if (pi->web_seed) continue; | │ │ │ │ -| | │ │ │ │ -| if (pi->optimistically_unchoked) | │ │ │ │ -| { | │ │ │ │ -| prev_opt_unchoke.push_back(pi); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| torrent const* t = p->associated_torrent().lock().get(); | │ │ │ │ -| if (!t) continue; | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_u_t___m_e_t_a_d_a_t_a_._c_p_p_:_2_6_8_ _ _ _ _|_u_s_e_ _t_h_e_ _a_u_x_:_:_w_r_i_t_e___*_ _f_u_n_c_t_i_o_n_s_ _a_n_d_ _t_h_e_ _s_p_a_n_ _h_e_r_e_ _i_n_s_t_e_a_d_,_ _i_t_ _w_i_l_l_ _f_i_t_ _b_e_t_t_e_r_ _w_i_t_h_ _s_e_n_d___b_u_f_f_e_r_(_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** uussee tthhee aauuxx::::wwrriittee__** ffuunnccttiioonnss aanndd tthhee ssppaann hheerree iinnsstteeaadd,, iitt wwiillll ffiitt bbeetttteerr wwiitthh sseenndd__bbuuffffeerr(()) ********** | │ │ │ │ +|****** ....//ssrrcc//uutt__mmeettaaddaattaa..ccpppp::226688 ****** | │ │ │ │ +|int metadata_piece_size = 0; | │ │ │ │ | | │ │ │ │ -|if (t->is_paused()) continue; | │ │ │ │ +| if (m_torrent.valid_metadata()) | │ │ │ │ +| e["total_size"] = m_tp.metadata().size(); | │ │ │ │ | | │ │ │ │ -| if (!p->is_connecting() | │ │ │ │ -| && !p->is_disconnecting() | │ │ │ │ -| && p->is_peer_interested() | │ │ │ │ -| && t->free_upload_slots() | │ │ │ │ -| && (p->is_choked() || pi->optimistically_unchoked) | │ │ │ │ -| && !p->ignore_unchoke_slots() | │ │ │ │ -| && t->valid_metadata()) | │ │ │ │ +| if (type == msg_t::piece) | │ │ │ │ | { | │ │ │ │ -| opt_unchoke.emplace_back(&i); | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // find the peers that has been waiting the longest to be optimistically | │ │ │ │ -| // unchoked | │ │ │ │ -| | │ │ │ │ -| int num_opt_unchoke = m_settings.get_int(settings_pack::num_optimistic_unchoke_slots); | │ │ │ │ -| int const allowed_unchoke_slots = int(m_stats_counters[counters::num_unchoke_slots]); | │ │ │ │ -| if (num_opt_unchoke == 0) num_opt_unchoke = std::max(1, allowed_unchoke_slots / 5); | │ │ │ │ -| if (num_opt_unchoke > int(opt_unchoke.size())) num_opt_unchoke = | │ │ │ │ -| int(opt_unchoke.size()); | │ │ │ │ -| | │ │ │ │ -| // find the n best optimistic unchoke candidates | │ │ │ │ -| std::partial_sort(opt_unchoke.begin() | │ │ │ │ -| , opt_unchoke.begin() + num_opt_unchoke | │ │ │ │ -| , opt_unchoke.end() | │ │ │ │ -|#ifndef TORRENT_DISABLE_EXTENSIONS | │ │ │ │ -| , last_optimistic_unchoke_cmp(m_ses_extensions[plugins_optimistic_unchoke_idx]) | │ │ │ │ -|#else | │ │ │ │ -|_ _ _ _,_ _l_a_s_t___o_p_t_i_m_i_s_t_i_c___u_n_c_h_o_k_e___c_m_p_(_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_4_4_4_2_ _ _|_t_h_e_r_e_ _s_h_o_u_l_d_ _b_e_ _a_ _p_r_e_-_c_a_l_c_u_l_a_t_e_d_ _l_i_s_t_ _o_f_ _a_l_l_ _p_e_e_r_s_ _e_l_i_g_i_b_l_e_ _f_o_r_ _u_n_c_h_o_k_i_n_g_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tthheerree sshhoouulldd bbee aa pprree--ccaallccuullaatteedd lliisstt ooff aallll ppeeeerrss eelliiggiibbllee ffoorr uunncchhookkiinngg ********** | │ │ │ │ -|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::44444422 ****** | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -| void session_impl::recalculate_unchoke_slots() | │ │ │ │ -| { | │ │ │ │ -| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ -| | │ │ │ │ -| time_point const now = aux::time_now(); | │ │ │ │ -| time_duration const unchoke_interval = now - m_last_choke; | │ │ │ │ -| m_last_choke = now; | │ │ │ │ -| | │ │ │ │ -| // if we unchoke everyone, skip this logic | │ │ │ │ -| if (settings().get_int(settings_pack::choking_algorithm) == settings_pack::fixed_slots_choker | │ │ │ │ -| && settings().get_int(settings_pack::unchoke_slots_limit) < 0) | │ │ │ │ -| { | │ │ │ │ -| m_stats_counters.set_value(counters::num_unchoke_slots, std::numeric_limits::max()); | │ │ │ │ -| return; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // build list of all peers that are | │ │ │ │ -| // unchokable. | │ │ │ │ -|std::vector peers; | │ │ │ │ -|for (auto i = m_connections.begin(); i != m_connections.end();) | │ │ │ │ -| { | │ │ │ │ -| std::shared_ptr p = *i; | │ │ │ │ -| TORRENT_ASSERT(p); | │ │ │ │ -| ++i; | │ │ │ │ -| torrent* const t = p->associated_torrent().lock().get(); | │ │ │ │ -| torrent_peer* const pi = p->peer_info_struct(); | │ │ │ │ +| TORRENT_ASSERT(piece >= 0 && piece < (m_tp.metadata().size() + 16 * 1024 - 1) / (16 * 1024)); | │ │ │ │ +| TORRENT_ASSERT(m_pc.associated_torrent().lock()->valid_metadata()); | │ │ │ │ +| TORRENT_ASSERT(m_torrent.valid_metadata()); | │ │ │ │ | | │ │ │ │ -| if (p->ignore_unchoke_slots() || t == nullptr || pi == nullptr | │ │ │ │ -| || pi->web_seed || t->is_paused()) | │ │ │ │ -| { | │ │ │ │ -| p->reset_choke_counters(); | │ │ │ │ -| continue; | │ │ │ │ +| int const offset = piece * 16 * 1024; | │ │ │ │ +| metadata = m_tp.metadata().data() + offset; | │ │ │ │ +| metadata_piece_size = std::min( | │ │ │ │ +| int(m_tp.metadata().size()) - offset, 16 * 1024); | │ │ │ │ +| TORRENT_ASSERT(metadata_piece_size > 0); | │ │ │ │ +| TORRENT_ASSERT(offset >= 0); | │ │ │ │ +| TORRENT_ASSERT(offset + metadata_piece_size <= m_tp.metadata().size()); | │ │ │ │ | } | │ │ │ │ | | │ │ │ │ -| if (!p->is_peer_interested() | │ │ │ │ -| || p->is_disconnecting() | │ │ │ │ -| || p->is_connecting()) | │ │ │ │ -| { | │ │ │ │ -| // this peer is not unchokable. So, if it's unchoked | │ │ │ │ -| // already, make sure to choke it. | │ │ │ │ -| if (p->is_choked()) | │ │ │ │ -| { | │ │ │ │ -| p->reset_choke_counters(); | │ │ │ │ -| continue; | │ │ │ │ -| } | │ │ │ │ -| if (pi && pi->optimistically_unchoked) | │ │ │ │ -| { | │ │ │ │ -| m_stats_counters.inc_stats_counter(counters::num_peers_up_unchoked_optimistic, -1); | │ │ │ │ -|_ _ _ _ _ _p_i_-_>_o_p_t_i_m_i_s_t_i_c_a_l_l_y___u_n_c_h_o_k_e_d_ _=_ _f_a_l_s_e_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_6_1_7_3_ _ _|_u_s_e_ _p_u_b_l_i_c___k_e_y_ _h_e_r_e_ _i_n_s_t_e_a_d_ _o_f_ _s_t_d_:_:_a_r_r_a_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** uussee ppuubblliicc__kkeeyy hheerree iinnsstteeaadd ooff ssttdd::::aarrrraayy ********** | │ │ │ │ -|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::66117733 ****** | │ │ │ │ -| void session_impl::dht_get_immutable_item(sha1_hash const& target) | │ │ │ │ -| { | │ │ │ │ -| if (!m_dht) return; | │ │ │ │ -| m_dht->get_item(target, std::bind(&session_impl::get_immutable_callback | │ │ │ │ -| , this, target, _1)); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // callback for dht_mutable_get | │ │ │ │ -| void session_impl::get_mutable_callback(dht::item const& i | │ │ │ │ -| , bool const authoritative) | │ │ │ │ -| { | │ │ │ │ -| TORRENT_ASSERT(i.is_mutable()); | │ │ │ │ -| m_alerts.emplace_alert(i.pk().bytes | │ │ │ │ -| , i.sig().bytes, i.seq().value | │ │ │ │ -| , i.salt(), i.value(), authoritative); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // key is a 32-byte binary string, the public key to look up. | │ │ │ │ -| // the salt is optional | │ │ │ │ -|void session_impl::dht_get_mutable_item(std::array key | │ │ │ │ -|, std::string salt) | │ │ │ │ -| { | │ │ │ │ -| if (!m_dht) return; | │ │ │ │ -| m_dht->get_item(dht::public_key(key.data()), std::bind(&session_impl::get_mutable_callback | │ │ │ │ -| , this, _1, _2), std::move(salt)); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| namespace { | │ │ │ │ -| | │ │ │ │ -| void on_dht_put_immutable_item(aux::alert_manager& alerts, sha1_hash target, int num) | │ │ │ │ -| { | │ │ │ │ -| if (alerts.should_post()) | │ │ │ │ -| alerts.emplace_alert(target, num); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| void on_dht_put_mutable_item(aux::alert_manager& alerts, dht::item const& i, int num) | │ │ │ │ -| { | │ │ │ │ -| if (alerts.should_post()) | │ │ │ │ -| { | │ │ │ │ -| dht::signature const sig = i.sig(); | │ │ │ │ -| dht::public_key const pk = i.pk(); | │ │ │ │ -| dht::sequence_number const seq = i.seq(); | │ │ │ │ -| std::string salt = i.salt(); | │ │ │ │ -| alerts.emplace_alert(pk.bytes, sig.bytes | │ │ │ │ -| , std::move(salt), seq.value, num); | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ +|char msg[200]; | │ │ │ │ +|char* header = msg; | │ │ │ │ +| char* p = &msg[6]; | │ │ │ │ +| int const len = bencode(p, e); | │ │ │ │ +| int const total_size = 2 + len + metadata_piece_size; | │ │ │ │ +| namespace io = aux; | │ │ │ │ +| io::write_uint32(total_size, header); | │ │ │ │ +| io::write_uint8(bt_peer_connection::msg_extended, header); | │ │ │ │ +| io::write_uint8(m_message_index, header); | │ │ │ │ | | │ │ │ │ -| void put_mutable_callback(dht::item& i | │ │ │ │ -|_ _ _ _,_ _s_t_d_:_:_f_u_n_c_t_i_o_n_<_v_o_i_d_(_e_n_t_r_y_&_,_ _s_t_d_:_:_a_r_r_a_y_<_c_h_a_r_,_ _6_4_>_&_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_ _ _ _m___p_c_._s_e_n_d___b_u_f_f_e_r_(_{_m_s_g_,_ _l_e_n_ _+_ _6_}_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |_r_e_l_e_v_a_n_c_e_ _3_|_._._/_s_r_c_/_s_e_s_s_i_o_n___h_a_n_d_l_e_._c_p_p_:_6_9_5_ _|_e_x_p_o_s_e_ _t_h_e_ _s_e_q_u_e_n_c_e___n_u_m_b_e_r_,_ _p_u_b_l_i_c___k_e_y_,_ _s_e_c_r_e_t___k_e_y_ _a_n_d_ _s_i_g_n_a_t_u_r_e_ _t_y_p_e_s_ _t_o_ _t_h_e_ _c_l_i_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** eexxppoossee tthhee sseeqquueennccee__nnuummbbeerr,, ppuubblliicc__kkeeyy,, sseeccrreett__kkeeyy aanndd ssiiggnnaattuurree ttyyppeess ttoo tthhee cclliieenntt ********** | │ │ │ │ |****** ....//ssrrcc//sseessssiioonn__hhaannddllee..ccpppp::669955 ****** | │ │ │ │ |void session_handle::dht_get_item(sha1_hash const& target) | │ │ │ │ | { | │ │ │ │ |#ifndef TORRENT_DISABLE_DHT | │ │ │ │ | async_call(&session_impl::dht_get_immutable_item, target); | │ │ │ │ @@ -1430,179 +1595,14 @@ │ │ │ │ | } | │ │ │ │ | | │ │ │ │ | void session_handle::dht_get_peers(sha1_hash const& info_hash) | │ │ │ │ | { | │ │ │ │ |#ifndef TORRENT_DISABLE_DHT | │ │ │ │ | async_call(&session_impl::dht_get_peers, info_hash); | │ │ │ │ |_#_e_l_s_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| |_._._/_s_r_c_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_: |instead of having to ask the torrent whether it's in graceful pause mode or not, the peers should keep that state (and the torrent | │ │ │ │ -|relevance 3|_3_1_4_7 |should update them when it enters graceful pause). When a peer enters graceful pause mode, it should cancel all outstanding requests| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_a_n_d_ _c_l_e_a_r_ _i_t_s_ _r_e_q_u_e_s_t_ _q_u_e_u_e_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** iinnsstteeaadd ooff hhaavviinngg ttoo aasskk tthhee ttoorrrreenntt wwhheetthheerr iitt''ss iinn ggrraacceeffuull ppaauussee mmooddee oorr nnoott,, tthhee ppeeeerrss sshhoouulldd kkeeeepp tthhaatt ssttaattee ((aanndd tthhee ttoorrrreenntt sshhoouulldd uuppddaattee tthheemm wwhheenn iitt eenntteerrss | │ │ │ │ -|ggrraacceeffuull ppaauussee)).. WWhheenn aa ppeeeerr eenntteerrss ggrraacceeffuull ppaauussee mmooddee,, iitt sshhoouulldd ccaanncceell aallll oouuttssttaannddiinngg rreeqquueessttss aanndd cclleeaarr iittss rreeqquueesstt qquueeuuee.. ********** | │ │ │ │ -|****** ....//ssrrcc//ppeeeerr__ccoonnnneeccttiioonn..ccpppp::33114477 ****** | │ │ │ │ -|// to disk or are in the disk write cache | │ │ │ │ -| if (picker.is_piece_finished(p.piece) && !was_finished) | │ │ │ │ -| { | │ │ │ │ -|#if TORRENT_USE_INVARIANT_CHECKS | │ │ │ │ -| check_postcondition post_checker2_(t, false); | │ │ │ │ -|#endif | │ │ │ │ -| t->verify_piece(p.piece); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| check_graceful_pause(); | │ │ │ │ -| | │ │ │ │ -| if (is_disconnecting()) return; | │ │ │ │ -| | │ │ │ │ -| if (request_a_block(*t, *this)) | │ │ │ │ -| m_counters.inc_stats_counter(counters::incoming_piece_picks); | │ │ │ │ -| send_block_requests(); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| void peer_connection::check_graceful_pause() | │ │ │ │ -| { | │ │ │ │ -|std::shared_ptr t = m_torrent.lock(); | │ │ │ │ -|if (!t || !t->graceful_pause()) return; | │ │ │ │ -| | │ │ │ │ -| if (m_outstanding_bytes > 0) return; | │ │ │ │ -| | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| peer_log(peer_log_alert::info, "GRACEFUL_PAUSE", "NO MORE DOWNLOAD"); | │ │ │ │ -|#endif | │ │ │ │ -| disconnect(errors::torrent_paused, operation_t::bittorrent); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| void peer_connection::on_disk_write_complete(storage_error const& error | │ │ │ │ -| , peer_request const& p, std::shared_ptr t) | │ │ │ │ -| { | │ │ │ │ -| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| if (should_log(peer_log_alert::info)) | │ │ │ │ -| { | │ │ │ │ -| peer_log(peer_log_alert::info, "FILE_ASYNC_WRITE_COMPLETE", "piece: %d s: %x l: %x e: %s" | │ │ │ │ -| , static_cast(p.piece), std::uint32_t(p.start), std::uint32_t(p.length), error.ec.message().c_str()); | │ │ │ │ -| } | │ │ │ │ -|#endif | │ │ │ │ -| | │ │ │ │ -| m_counters.inc_stats_counter(counters::queued_write_bytes, -p.length); | │ │ │ │ -| m_outstanding_writing_bytes -= p.length; | │ │ │ │ -| | │ │ │ │ -| TORRENT_ASSERT(m_outstanding_writing_bytes >= 0); | │ │ │ │ -| | │ │ │ │ -| // every peer is entitled to allocate a disk buffer if it has no writes outstanding | │ │ │ │ -| // see the comment in incoming_piece | │ │ │ │ -|_ _ _i_f_ _(_m___o_u_t_s_t_a_n_d_i_n_g___w_r_i_t_i_n_g___b_y_t_e_s_ _=_=_ _0_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 3|_._._/_s_r_c_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_: |once peers are properly put in graceful pause mode, they can cancel all outstanding requests and this test can be removed. | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_0_3_8_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** oonnccee ppeeeerrss aarree pprrooppeerrllyy ppuutt iinn ggrraacceeffuull ppaauussee mmooddee,, tthheeyy ccaann ccaanncceell aallll oouuttssttaannddiinngg rreeqquueessttss aanndd tthhiiss tteesstt ccaann bbee rreemmoovveedd.. ********** | │ │ │ │ -|****** ....//ssrrcc//ppeeeerr__ccoonnnneeccttiioonn..ccpppp::44003388 ****** | │ │ │ │ -| if (!p->m_deferred_send_block_requests) | │ │ │ │ -| return; | │ │ │ │ -| | │ │ │ │ -| p->m_deferred_send_block_requests = false; | │ │ │ │ -| p->send_block_requests_impl(); | │ │ │ │ -| }); | │ │ │ │ -| m_deferred_send_block_requests = true; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| void peer_connection::send_block_requests_impl() | │ │ │ │ -| { | │ │ │ │ -| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ -| INVARIANT_CHECK; | │ │ │ │ -| | │ │ │ │ -| std::shared_ptr t = m_torrent.lock(); | │ │ │ │ -| if (!t) return; | │ │ │ │ -| | │ │ │ │ -| if (m_disconnecting) return; | │ │ │ │ -| | │ │ │ │ -|if (t->graceful_pause()) return; | │ │ │ │ -| | │ │ │ │ -| // we can't download pieces in these states | │ │ │ │ -| if (t->state() == torrent_status::checking_files | │ │ │ │ -| || t->state() == torrent_status::checking_resume_data | │ │ │ │ -| || t->state() == torrent_status::downloading_metadata) | │ │ │ │ -| return; | │ │ │ │ -| | │ │ │ │ -| if (int(m_download_queue.size()) >= m_desired_queue_size | │ │ │ │ -| || t->upload_mode()) return; | │ │ │ │ -| | │ │ │ │ -| bool const empty_download_queue = m_download_queue.empty(); | │ │ │ │ -| | │ │ │ │ -| while (!m_request_queue.empty() | │ │ │ │ -| && (int(m_download_queue.size()) < m_desired_queue_size | │ │ │ │ -| || m_queued_time_critical > 0)) | │ │ │ │ -| { | │ │ │ │ -| pending_block block = m_request_queue.front(); | │ │ │ │ -| | │ │ │ │ -| m_request_queue.erase(m_request_queue.begin()); | │ │ │ │ -| if (m_queued_time_critical) --m_queued_time_critical; | │ │ │ │ -| | │ │ │ │ -| // if we're a seed, we don't have a piece picker | │ │ │ │ -| // so we don't have to worry about invariants getting | │ │ │ │ -| // out of sync with it | │ │ │ │ -| if (!t->has_picker()) continue; | │ │ │ │ -| | │ │ │ │ -| // this can happen if a block times out, is re-requested and | │ │ │ │ -| // then arrives "unexpectedly" | │ │ │ │ -| if (t->picker().is_downloaded(block.block)) | │ │ │ │ -|_ _ _ _{_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 3|_._._/_s_r_c_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_: |new_piece should be an optional. piece index -1 should not be allowed | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_7_1_5_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** nneeww__ppiieeccee sshhoouulldd bbee aann ooppttiioonnaall.. ppiieeccee iinnddeexx --11 sshhoouulldd nnoott bbee aalllloowweedd ********** | │ │ │ │ -|****** ....//ssrrcc//ppeeeerr__ccoonnnneeccttiioonn..ccpppp::44771155 ****** | │ │ │ │ -| // pieces may be empty if we don't have metadata yet | │ │ │ │ -| if (p.pieces.empty()) | │ │ │ │ -| { | │ │ │ │ -| p.progress = 0.f; | │ │ │ │ -| p.progress_ppm = 0; | │ │ │ │ -| } | │ │ │ │ -| else | │ │ │ │ -| { | │ │ │ │ -|#if TORRENT_NO_FPU | │ │ │ │ -| p.progress = 0.f; | │ │ │ │ -|#else | │ │ │ │ -| p.progress = float(p.pieces.count()) / float(p.pieces.size()); | │ │ │ │ -|#endif | │ │ │ │ -| p.progress_ppm = int(std::int64_t(p.pieces.count()) * 1000000 / p.pieces.size()); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -|#ifndef TORRENT_DISABLE_SUPERSEEDING | │ │ │ │ -|void peer_connection::superseed_piece(piece_index_t const replace_piece | │ │ │ │ -|, piece_index_t const new_piece) | │ │ │ │ -| { | │ │ │ │ -| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ -| | │ │ │ │ -| if (is_connecting()) return; | │ │ │ │ -| if (in_handshake()) return; | │ │ │ │ -| | │ │ │ │ -| if (new_piece == piece_index_t(-1)) | │ │ │ │ -| { | │ │ │ │ -| if (m_superseed_piece[0] == piece_index_t(-1)) return; | │ │ │ │ -| m_superseed_piece[0] = piece_index_t(-1); | │ │ │ │ -| m_superseed_piece[1] = piece_index_t(-1); | │ │ │ │ -| | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| peer_log(peer_log_alert::info, "SUPER_SEEDING", "ending"); | │ │ │ │ -|#endif | │ │ │ │ -| std::shared_ptr t = m_torrent.lock(); | │ │ │ │ -| TORRENT_ASSERT(t); | │ │ │ │ -| | │ │ │ │ -| // this will either send a full bitfield or | │ │ │ │ -| // a have-all message, effectively terminating | │ │ │ │ -| // super-seeding, since the peer may pick any piece | │ │ │ │ -| write_bitfield(); | │ │ │ │ -| | │ │ │ │ -| return; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| TORRENT_ASSERT(!has_piece(new_piece)); | │ │ │ │ -| | │ │ │ │ -|_#_i_f_n_d_e_f_ _T_O_R_R_E_N_T___D_I_S_A_B_L_E___L_O_G_G_I_N_G_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |relevance 3|_._._/_s_r_c_/_k_a_d_e_m_l_i_a_/ |move this into it's own .cpp file | │ │ │ │ |_ _ _ _ _ _ _ _ _ _ _ _|_r_p_c___m_a_n_a_g_e_r_._c_p_p_:_7_1_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** mmoovvee tthhiiss iinnttoo iitt''ss oowwnn ..ccpppp ffiillee ********** | │ │ │ │ |****** ....//ssrrcc//kkaaddeemmlliiaa//rrppcc__mmaannaaggeerr..ccpppp::7711 ****** | │ │ │ │ |#include | │ │ │ │ |#include | │ │ │ │ |#include | │ │ │ │ @@ -1650,64 +1650,67 @@ │ │ │ │ | } | │ │ │ │ | else | │ │ │ │ | { | │ │ │ │ | flags &= ~flag_ipv6_address; | │ │ │ │ | m_addr.v4 = ep.address().to_v4().to_bytes(); | │ │ │ │ | } | │ │ │ │ |_}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 3|_._._/_i_n_c_l_u_d_e_/_l_i_b_t_o_r_r_e_n_t_/ |if we make this be a disk_buffer_holder instead we would save a copy use allocate_disk_receive_buffer and | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_w_e_b___p_e_e_r___c_o_n_n_e_c_t_i_o_n_._h_p_p_:_1_1_9_ _ _ _|_r_e_l_e_a_s_e___d_i_s_k___r_e_c_e_i_v_e___b_u_f_f_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** iiff wwee mmaakkee tthhiiss bbee aa ddiisskk__bbuuffffeerr__hhoollddeerr iinnsstteeaadd wwee wwoouulldd ssaavvee aa ccooppyy uussee aallllooccaattee__ddiisskk__rreecceeiivvee__bbuuffffeerr aanndd rreelleeaassee__ddiisskk__rreecceeiivvee__bbuuffffeerr ********** | │ │ │ │ -|****** ....//iinncclluuddee//lliibbttoorrrreenntt//wweebb__ppeeeerr__ccoonnnneeccttiioonn..hhpppp::111199 ****** | │ │ │ │ -|piece_block_progress downloading_piece_progress() const override; | │ │ │ │ +|relevance 3|_._._/_i_n_c_l_u_d_e_/_l_i_b_t_o_r_r_e_n_t_/ |everything but payload counters and rates could probably be removed from here | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_s_t_a_t_._h_p_p_:_2_5_7_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** eevveerryytthhiinngg bbuutt ppaayyllooaadd ccoouunntteerrss aanndd rraatteess ccoouulldd pprroobbaabbllyy bbee rreemmoovveedd ffrroomm hheerree ********** | │ │ │ │ +|****** ....//iinncclluuddee//lliibbttoorrrreenntt//ssttaatt..hhpppp::225577 ****** | │ │ │ │ +|// peer_connection is opened and have some previous | │ │ │ │ +| // transfers from earlier connections. | │ │ │ │ +| void add_stat(std::int64_t downloaded, std::int64_t uploaded) | │ │ │ │ +| { | │ │ │ │ +| m_stat[download_payload].offset(downloaded); | │ │ │ │ +| m_stat[upload_payload].offset(uploaded); | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -| void handle_padfile(); | │ │ │ │ +| int last_payload_downloaded() const | │ │ │ │ +| { return m_stat[download_payload].counter(); } | │ │ │ │ +| int last_payload_uploaded() const | │ │ │ │ +| { return m_stat[upload_payload].counter(); } | │ │ │ │ +| int last_protocol_downloaded() const | │ │ │ │ +| { return m_stat[download_protocol].counter(); } | │ │ │ │ +| int last_protocol_uploaded() const | │ │ │ │ +| { return m_stat[upload_protocol].counter(); } | │ │ │ │ | | │ │ │ │ -| // this has one entry per http-request | │ │ │ │ -| // (might be more than the bt requests) | │ │ │ │ -| struct file_request_t | │ │ │ │ +| // these are the channels we keep stats for | │ │ │ │ +| enum | │ │ │ │ | { | │ │ │ │ -| file_index_t file_index; | │ │ │ │ -| int length; | │ │ │ │ -| std::int64_t start; | │ │ │ │ +|upload_payload, | │ │ │ │ +|upload_protocol, | │ │ │ │ +| download_payload, | │ │ │ │ +| download_protocol, | │ │ │ │ +| upload_ip_protocol, | │ │ │ │ +| download_ip_protocol, | │ │ │ │ +| num_channels | │ │ │ │ | }; | │ │ │ │ -| std::deque m_file_requests; | │ │ │ │ -| | │ │ │ │ -| std::string m_url; | │ │ │ │ -| | │ │ │ │ -| web_seed_t* m_web; | │ │ │ │ -| | │ │ │ │ -| // this is used for intermediate storage of pieces to be delivered to the | │ │ │ │ -| // bittorrent engine | │ │ │ │ -|aux::vector m_piece; | │ │ │ │ | | │ │ │ │ -| // the number of bytes we've forwarded to the incoming_payload() function | │ │ │ │ -| // in the current HTTP response. used to know where in the buffer the | │ │ │ │ -| // next response starts | │ │ │ │ -| int m_received_body; | │ │ │ │ +| void clear() | │ │ │ │ +| { | │ │ │ │ +| for (int i = 0; i < num_channels; ++i) | │ │ │ │ +| m_stat[i].clear(); | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -| // this is the offset inside the current receive | │ │ │ │ -| // buffer where the next chunk header will be. | │ │ │ │ -| // this is updated for each chunk header that's | │ │ │ │ -| // parsed. It does not necessarily point to a valid | │ │ │ │ -| // offset in the receive buffer, if we haven't received | │ │ │ │ -| // it yet. This offset never includes the HTTP header | │ │ │ │ -| int m_chunk_pos; | │ │ │ │ +| stat_channel const& operator[](int i) const | │ │ │ │ +| { | │ │ │ │ +| TORRENT_ASSERT(i >= 0 && i < num_channels); | │ │ │ │ +| return m_stat[i]; | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -| // this is the number of bytes we've already received | │ │ │ │ -| // from the next chunk header we're waiting for | │ │ │ │ -| int m_partial_chunk_header; | │ │ │ │ +| private: | │ │ │ │ | | │ │ │ │ -| // the number of responses we've received so far on | │ │ │ │ -| // this connection | │ │ │ │ -| int m_num_responses; | │ │ │ │ +| stat_channel m_stat[num_channels]; | │ │ │ │ | }; | │ │ │ │ +| | │ │ │ │ |} | │ │ │ │ | | │ │ │ │ -|_#_e_n_d_i_f_ _/_/_ _T_O_R_R_E_N_T___W_E_B___P_E_E_R___C_O_N_N_E_C_T_I_O_N___H_P_P___I_N_C_L_U_D_E_D_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_#_e_n_d_i_f_ _/_/_ _T_O_R_R_E_N_T___S_T_A_T___H_P_P___I_N_C_L_U_D_E_D_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |relevance 3|_._._/_i_n_c_l_u_d_e_/_l_i_b_t_o_r_r_e_n_t_/ |unify url_seed and http_seed with just web_seed, using the web_seed_entry. | │ │ │ │ |_ _ _ _ _ _ _ _ _ _ _ _|_t_o_r_r_e_n_t___h_a_n_d_l_e_._h_p_p_:_5_4_8_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** uunniiffyy uurrll__sseeeedd aanndd hhttttpp__sseeeedd wwiitthh jjuusstt wweebb__sseeeedd,, uussiinngg tthhee wweebb__sseeeedd__eennttrryy.. ********** | │ │ │ │ |****** ....//iinncclluuddee//lliibbttoorrrreenntt//ttoorrrreenntt__hhaannddllee..hhpppp::554488 ****** | │ │ │ │ |// one returned from ``trackers()`` and will replace it. If you want an | │ │ │ │ | // immediate effect, you have to call force_reannounce(). See | │ │ │ │ | // announce_entry. | │ │ │ │ @@ -1755,14 +1758,64 @@ │ │ │ │ | // a function that will be called from within libtorrent's context | │ │ │ │ | // passing in the internal torrent object and the specified userdata | │ │ │ │ | // pointer. The function is expected to return a shared pointer to | │ │ │ │ | // a torrent_plugin instance. | │ │ │ │ | void add_extension( | │ │ │ │ | std::function(torrent_handle const&, client_data_t)> const& ext | │ │ │ │ |_ _ _ _,_ _c_l_i_e_n_t___d_a_t_a___t_ _u_s_e_r_d_a_t_a_ _=_ _c_l_i_e_n_t___d_a_t_a___t_{_}_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 3|_._._/_i_n_c_l_u_d_e_/_l_i_b_t_o_r_r_e_n_t_/ |if we make this be a disk_buffer_holder instead we would save a copy use allocate_disk_receive_buffer and | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_w_e_b___p_e_e_r___c_o_n_n_e_c_t_i_o_n_._h_p_p_:_1_1_9_ _ _ _|_r_e_l_e_a_s_e___d_i_s_k___r_e_c_e_i_v_e___b_u_f_f_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** iiff wwee mmaakkee tthhiiss bbee aa ddiisskk__bbuuffffeerr__hhoollddeerr iinnsstteeaadd wwee wwoouulldd ssaavvee aa ccooppyy uussee aallllooccaattee__ddiisskk__rreecceeiivvee__bbuuffffeerr aanndd rreelleeaassee__ddiisskk__rreecceeiivvee__bbuuffffeerr ********** | │ │ │ │ +|****** ....//iinncclluuddee//lliibbttoorrrreenntt//wweebb__ppeeeerr__ccoonnnneeccttiioonn..hhpppp::111199 ****** | │ │ │ │ +|piece_block_progress downloading_piece_progress() const override; | │ │ │ │ +| | │ │ │ │ +| void handle_padfile(); | │ │ │ │ +| | │ │ │ │ +| // this has one entry per http-request | │ │ │ │ +| // (might be more than the bt requests) | │ │ │ │ +| struct file_request_t | │ │ │ │ +| { | │ │ │ │ +| file_index_t file_index; | │ │ │ │ +| int length; | │ │ │ │ +| std::int64_t start; | │ │ │ │ +| }; | │ │ │ │ +| std::deque m_file_requests; | │ │ │ │ +| | │ │ │ │ +| std::string m_url; | │ │ │ │ +| | │ │ │ │ +| web_seed_t* m_web; | │ │ │ │ +| | │ │ │ │ +| // this is used for intermediate storage of pieces to be delivered to the | │ │ │ │ +| // bittorrent engine | │ │ │ │ +|aux::vector m_piece; | │ │ │ │ +| | │ │ │ │ +| // the number of bytes we've forwarded to the incoming_payload() function | │ │ │ │ +| // in the current HTTP response. used to know where in the buffer the | │ │ │ │ +| // next response starts | │ │ │ │ +| int m_received_body; | │ │ │ │ +| | │ │ │ │ +| // this is the offset inside the current receive | │ │ │ │ +| // buffer where the next chunk header will be. | │ │ │ │ +| // this is updated for each chunk header that's | │ │ │ │ +| // parsed. It does not necessarily point to a valid | │ │ │ │ +| // offset in the receive buffer, if we haven't received | │ │ │ │ +| // it yet. This offset never includes the HTTP header | │ │ │ │ +| int m_chunk_pos; | │ │ │ │ +| | │ │ │ │ +| // this is the number of bytes we've already received | │ │ │ │ +| // from the next chunk header we're waiting for | │ │ │ │ +| int m_partial_chunk_header; | │ │ │ │ +| | │ │ │ │ +| // the number of responses we've received so far on | │ │ │ │ +| // this connection | │ │ │ │ +| int m_num_responses; | │ │ │ │ +| }; | │ │ │ │ +|} | │ │ │ │ +| | │ │ │ │ +|_#_e_n_d_i_f_ _/_/_ _T_O_R_R_E_N_T___W_E_B___P_E_E_R___C_O_N_N_E_C_T_I_O_N___H_P_P___I_N_C_L_U_D_E_D_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |relevance 3|_._._/_i_n_c_l_u_d_e_/_l_i_b_t_o_r_r_e_n_t_/ |factor out predictive pieces and all operations on it into a separate class (to use as member here instead) | │ │ │ │ |_ _ _ _ _ _ _ _ _ _ _ _|_t_o_r_r_e_n_t_._h_p_p_:_1_4_8_3_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** ffaaccttoorr oouutt pprreeddiiccttiivvee ppiieecceess aanndd aallll ooppeerraattiioonnss oonn iitt iinnttoo aa sseeppaarraattee ccllaassss ((ttoo uussee aass mmeemmbbeerr hheerree iinnsstteeaadd)) ********** | │ │ │ │ |****** ....//iinncclluuddee//lliibbttoorrrreenntt//ttoorrrreenntt..hhpppp::11448833 ****** | │ │ │ │ | std::string m_trackerid; | │ │ │ │ |#if TORRENT_ABI_VERSION == 1 | │ │ │ │ | // deprecated in 1.1 | │ │ │ │ @@ -1863,67 +1916,14 @@ │ │ │ │ | piece_index_t m_checking_piece{0}; | │ │ │ │ | | │ │ │ │ | // the number of pieces we completed the check of | │ │ │ │ | piece_index_t m_num_checked_pieces{0}; | │ │ │ │ | | │ │ │ │ | // if the error occurred on a file, this is the index of that file | │ │ │ │ |_ _ _/_/_ _t_h_e_r_e_ _a_r_e_ _a_ _f_e_w_ _s_p_e_c_i_a_l_ _c_a_s_e_s_,_ _w_h_e_n_ _t_h_i_s_ _i_s_ _n_e_g_a_t_i_v_e_._ _S_e_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 3|_._._/_i_n_c_l_u_d_e_/_l_i_b_t_o_r_r_e_n_t_/ |everything but payload counters and rates could probably be removed from here | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_s_t_a_t_._h_p_p_:_2_5_7_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** eevveerryytthhiinngg bbuutt ppaayyllooaadd ccoouunntteerrss aanndd rraatteess ccoouulldd pprroobbaabbllyy bbee rreemmoovveedd ffrroomm hheerree ********** | │ │ │ │ -|****** ....//iinncclluuddee//lliibbttoorrrreenntt//ssttaatt..hhpppp::225577 ****** | │ │ │ │ -|// peer_connection is opened and have some previous | │ │ │ │ -| // transfers from earlier connections. | │ │ │ │ -| void add_stat(std::int64_t downloaded, std::int64_t uploaded) | │ │ │ │ -| { | │ │ │ │ -| m_stat[download_payload].offset(downloaded); | │ │ │ │ -| m_stat[upload_payload].offset(uploaded); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| int last_payload_downloaded() const | │ │ │ │ -| { return m_stat[download_payload].counter(); } | │ │ │ │ -| int last_payload_uploaded() const | │ │ │ │ -| { return m_stat[upload_payload].counter(); } | │ │ │ │ -| int last_protocol_downloaded() const | │ │ │ │ -| { return m_stat[download_protocol].counter(); } | │ │ │ │ -| int last_protocol_uploaded() const | │ │ │ │ -| { return m_stat[upload_protocol].counter(); } | │ │ │ │ -| | │ │ │ │ -| // these are the channels we keep stats for | │ │ │ │ -| enum | │ │ │ │ -| { | │ │ │ │ -|upload_payload, | │ │ │ │ -|upload_protocol, | │ │ │ │ -| download_payload, | │ │ │ │ -| download_protocol, | │ │ │ │ -| upload_ip_protocol, | │ │ │ │ -| download_ip_protocol, | │ │ │ │ -| num_channels | │ │ │ │ -| }; | │ │ │ │ -| | │ │ │ │ -| void clear() | │ │ │ │ -| { | │ │ │ │ -| for (int i = 0; i < num_channels; ++i) | │ │ │ │ -| m_stat[i].clear(); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| stat_channel const& operator[](int i) const | │ │ │ │ -| { | │ │ │ │ -| TORRENT_ASSERT(i >= 0 && i < num_channels); | │ │ │ │ -| return m_stat[i]; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| private: | │ │ │ │ -| | │ │ │ │ -| stat_channel m_stat[num_channels]; | │ │ │ │ -| }; | │ │ │ │ -| | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|_#_e_n_d_i_f_ _/_/_ _T_O_R_R_E_N_T___S_T_A_T___H_P_P___I_N_C_L_U_D_E_D_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |relevance 3|_._._/_i_n_c_l_u_d_e_/_l_i_b_t_o_r_r_e_n_t_/ |dh_key_exchange should probably move into its own file | │ │ │ │ |_ _ _ _ _ _ _ _ _ _ _ _|_p_e___c_r_y_p_t_o_._h_p_p_:_7_2_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** ddhh__kkeeyy__eexxcchhaannggee sshhoouulldd pprroobbaabbllyy mmoovvee iinnttoo iittss oowwnn ffiillee ********** | │ │ │ │ |****** ....//iinncclluuddee//lliibbttoorrrreenntt//ppee__ccrryyppttoo..hhpppp::7722 ****** | │ │ │ │ |#include | │ │ │ │ |#include | │ │ │ │ |#include | │ │ │ │ @@ -2301,14 +2301,376 @@ │ │ │ │ | bool ret = verify_message(ent, msg_desc, msg_keys, error_string); | │ │ │ │ | TEST_CHECK(ret); | │ │ │ │ | TEST_CHECK(msg_keys[0]); | │ │ │ │ | if (msg_keys[0]) TEST_EQUAL(msg_keys[0].string_value(), "test"); | │ │ │ │ | TEST_CHECK(msg_keys[1]); | │ │ │ │ | TEST_CHECK(msg_keys[2]); | │ │ │ │ |_ _i_f_ _(_m_s_g___k_e_y_s_[_2_]_)_ _T_E_S_T___E_Q_U_A_L_(_m_s_g___k_e_y_s_[_2_]_._s_t_r_i_n_g___v_a_l_u_e_(_)_,_ _"_t_e_s_t_2_"_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_e_s_c_a_p_e___s_t_r_i_n_g_._c_p_p_:_1_9_3_ _ _|_t_h_i_s_ _s_h_o_u_l_d_ _p_r_o_b_a_b_l_y_ _b_e_ _m_o_v_e_d_ _i_n_t_o_ _s_t_r_i_n_g___u_t_i_l_._c_p_p_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tthhiiss sshhoouulldd pprroobbaabbllyy bbee mmoovveedd iinnttoo ssttrriinngg__uuttiill..ccpppp ********** | │ │ │ │ +|****** ....//ssrrcc//eessccaappee__ssttrriinngg..ccpppp::119933 ****** | │ │ │ │ +|{ | │ │ │ │ +| return escape_string_impl(str.data(), int(str.size()), 10); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| bool need_encoding(char const* str, int const len) | │ │ │ │ +| { | │ │ │ │ +| for (int i = 0; i < len; ++i) | │ │ │ │ +| { | │ │ │ │ +| if (std::strchr(unreserved_chars, *str) == nullptr || *str == 0) | │ │ │ │ +| return true; | │ │ │ │ +| ++str; | │ │ │ │ +| } | │ │ │ │ +| return false; | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| void convert_path_to_posix(std::string& path) | │ │ │ │ +| { | │ │ │ │ +| std::replace(path.begin(), path.end(), '\\', '/'); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +|std::string read_until(char const*& str, char const delim, char const* end) | │ │ │ │ +|{ | │ │ │ │ +| TORRENT_ASSERT(str <= end); | │ │ │ │ +| | │ │ │ │ +| std::string ret; | │ │ │ │ +| while (str != end && *str != delim) | │ │ │ │ +| { | │ │ │ │ +| ret += *str; | │ │ │ │ +| ++str; | │ │ │ │ +| } | │ │ │ │ +| // skip the delimiter as well | │ │ │ │ +| while (str != end && *str == delim) ++str; | │ │ │ │ +| return ret; | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| std::string maybe_url_encode(std::string const& url) | │ │ │ │ +| { | │ │ │ │ +| std::string protocol, host, auth, path; | │ │ │ │ +| int port; | │ │ │ │ +| error_code ec; | │ │ │ │ +| std::tie(protocol, auth, host, port, path) = parse_url_components(url, ec); | │ │ │ │ +| if (ec) return url; | │ │ │ │ +| | │ │ │ │ +| // first figure out if this url contains unencoded characters | │ │ │ │ +| if (!need_encoding(path.c_str(), int(path.size()))) | │ │ │ │ +| return url; | │ │ │ │ +| | │ │ │ │ +| std::string msg; | │ │ │ │ +| std::string escaped_path { escape_path(path) }; | │ │ │ │ +| // reserve enough space so further append will | │ │ │ │ +|_ _ _/_/_ _o_n_l_y_ _c_o_p_y_ _v_a_l_u_e_s_ _t_o_ _e_x_i_s_t_i_n_g_ _l_o_c_a_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_5_9_9_ _ _ _|_i_s_ _t_h_e_r_e_ _a_ _r_e_a_s_o_n_ _n_o_t_ _t_o_ _m_o_v_e_ _a_l_l_ _o_f_ _t_h_i_s_ _i_n_t_o_ _i_n_i_t_(_)_?_ _a_n_d_ _j_u_s_t_ _p_o_s_t_ _i_t_ _t_o_ _t_h_e_ _i_o___c_o_n_t_e_x_t_?_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** iiss tthheerree aa rreeaassoonn nnoott ttoo mmoovvee aallll ooff tthhiiss iinnttoo iinniitt(())?? aanndd jjuusstt ppoosstt iitt ttoo tthhee iioo__ccoonntteexxtt?? ********** | │ │ │ │ +|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::559999 ****** | │ │ │ │ +|try | │ │ │ │ +|#endif | │ │ │ │ +| { | │ │ │ │ +| (this->*f)(std::forward(a)...); | │ │ │ │ +| } | │ │ │ │ +|#ifndef BOOST_NO_EXCEPTIONS | │ │ │ │ +| catch (system_error const& e) { | │ │ │ │ +| alerts().emplace_alert(e.code(), e.what()); | │ │ │ │ +| pause(); | │ │ │ │ +| } catch (std::exception const& e) { | │ │ │ │ +| alerts().emplace_alert(error_code(), e.what()); | │ │ │ │ +| pause(); | │ │ │ │ +| } catch (...) { | │ │ │ │ +| alerts().emplace_alert(error_code(), "unknown error"); | │ │ │ │ +| pause(); | │ │ │ │ +| } | │ │ │ │ +|#endif | │ │ │ │ +| | │ │ │ │ +| // This function is called by the creating thread, not in the message loop's | │ │ │ │ +| // io_context thread. | │ │ │ │ +|void session_impl::start_session() | │ │ │ │ +|{ | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| session_log("start session"); | │ │ │ │ +|#endif | │ │ │ │ +| | │ │ │ │ +|#if TORRENT_USE_SSL | │ │ │ │ +| error_code ec; | │ │ │ │ +| m_ssl_ctx.set_default_verify_paths(ec); | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| if (ec) session_log("SSL set_default verify_paths failed: %s", ec.message().c_str()); | │ │ │ │ +| ec.clear(); | │ │ │ │ +|#endif | │ │ │ │ +|_#_i_f_ _d_e_f_i_n_e_d_ _T_O_R_R_E_N_T___W_I_N_D_O_W_S_ _&_&_ _d_e_f_i_n_e_d_ _T_O_R_R_E_N_T___U_S_E___O_P_E_N_S_S_L_ _&_&_ _!_d_e_f_i_n_e_d_ _T_O_R_R_E_N_T___W_I_N_R_T_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_7_7_5_ _ _ _|_t_h_e_ _i_p_ _f_i_l_t_e_r_ _s_h_o_u_l_d_ _p_r_o_b_a_b_l_y_ _b_e_ _s_a_v_e_d_ _h_e_r_e_ _t_o_o_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tthhee iipp ffiilltteerr sshhoouulldd pprroobbaabbllyy bbee ssaavveedd hheerree ttoooo ********** | │ │ │ │ +|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::777755 ****** | │ │ │ │ +|m_lsd_announce_timer.async_wait([this](error_code const& e) { | │ │ │ │ +| wrap(&session_impl::on_lsd_announce, e); } ); | │ │ │ │ +| | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| session_log(" done starting session"); | │ │ │ │ +|#endif | │ │ │ │ +| | │ │ │ │ +| // this applies unchoke settings from m_settings | │ │ │ │ +| recalculate_unchoke_slots(); | │ │ │ │ +| | │ │ │ │ +| // apply all m_settings to this session | │ │ │ │ +| run_all_updates(*this); | │ │ │ │ +| reopen_listen_sockets(false); | │ │ │ │ +| | │ │ │ │ +|#if TORRENT_USE_INVARIANT_CHECKS | │ │ │ │ +| check_invariant(); | │ │ │ │ +|#endif | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +|#if TORRENT_ABI_VERSION <= 2 | │ │ │ │ +|void session_impl::save_state(entry* eptr, save_state_flags_t const flags) const | │ │ │ │ +|{ | │ │ │ │ +| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ +| | │ │ │ │ +| entry& e = *eptr; | │ │ │ │ +| // make it a dict | │ │ │ │ +| e.dict(); | │ │ │ │ +| | │ │ │ │ +| if (flags & session::save_settings) | │ │ │ │ +| { | │ │ │ │ +| entry::dictionary_type& sett = e["settings"].dict(); | │ │ │ │ +| save_settings_to_dict(non_default_settings(m_settings), sett); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +|#ifndef TORRENT_DISABLE_DHT | │ │ │ │ +| if (flags & session::save_dht_settings) | │ │ │ │ +| { | │ │ │ │ +| e["dht"] = dht::save_dht_settings(get_dht_settings()); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| if (m_dht && (flags & session::save_dht_state)) | │ │ │ │ +| { | │ │ │ │ +| e["dht state"] = dht::save_dht_state(m_dht->state()); | │ │ │ │ +| } | │ │ │ │ +|#endif | │ │ │ │ +| | │ │ │ │ +|#ifndef TORRENT_DISABLE_EXTENSIONS | │ │ │ │ +| for (auto const& ext : m_ses_extensions[plugins_all_idx]) | │ │ │ │ +| { | │ │ │ │ +| ext->save_state(*eptr); | │ │ │ │ +|_ _ _}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 2|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_3_9_0_0 |make a list for torrents that want to be announced on the DHT so we don't have to loop over all torrents, just to find the ones that| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_w_a_n_t_ _t_o_ _a_n_n_o_u_n_c_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** mmaakkee aa lliisstt ffoorr ttoorrrreennttss tthhaatt wwaanntt ttoo bbee aannnnoouunncceedd oonn tthhee DDHHTT ssoo wwee ddoonn''tt hhaavvee ttoo lloooopp oovveerr aallll ttoorrrreennttss,, jjuusstt ttoo ffiinndd tthhee oonneess tthhaatt wwaanntt ttoo aannnnoouunnccee ********** | │ │ │ │ +|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::33990000 ****** | │ │ │ │ +|if (!m_dht_torrents.empty()) | │ │ │ │ +| { | │ │ │ │ +| std::shared_ptr t; | │ │ │ │ +| do | │ │ │ │ +| { | │ │ │ │ +| t = m_dht_torrents.front().lock(); | │ │ │ │ +| m_dht_torrents.pop_front(); | │ │ │ │ +| } while (!t && !m_dht_torrents.empty()); | │ │ │ │ +| | │ │ │ │ +| if (t) | │ │ │ │ +| { | │ │ │ │ +| t->dht_announce(); | │ │ │ │ +| return; | │ │ │ │ +| } | │ │ │ │ +| } | │ │ │ │ +| if (m_torrents.empty()) return; | │ │ │ │ +| | │ │ │ │ +| if (m_next_dht_torrent >= m_torrents.size()) | │ │ │ │ +| m_next_dht_torrent = 0; | │ │ │ │ +| m_torrents[m_next_dht_torrent]->dht_announce(); | │ │ │ │ +|++m_next_dht_torrent; | │ │ │ │ +|if (m_next_dht_torrent >= m_torrents.size()) | │ │ │ │ +| m_next_dht_torrent = 0; | │ │ │ │ +| } | │ │ │ │ +|#endif | │ │ │ │ +| | │ │ │ │ +| void session_impl::on_lsd_announce(error_code const& e) | │ │ │ │ +| { | │ │ │ │ +| COMPLETE_ASYNC("session_impl::on_lsd_announce"); | │ │ │ │ +| m_stats_counters.inc_stats_counter(counters::on_lsd_counter); | │ │ │ │ +| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ +| if (e) return; | │ │ │ │ +| | │ │ │ │ +| if (m_abort) return; | │ │ │ │ +| | │ │ │ │ +| ADD_OUTSTANDING_ASYNC("session_impl::on_lsd_announce"); | │ │ │ │ +| // announce on local network every 5 minutes | │ │ │ │ +| int const delay = std::max(m_settings.get_int(settings_pack::local_service_announce_interval) | │ │ │ │ +| / std::max(int(m_torrents.size()), 1), 1); | │ │ │ │ +| m_lsd_announce_timer.expires_after(seconds(delay)); | │ │ │ │ +| m_lsd_announce_timer.async_wait([this](error_code const& err) { | │ │ │ │ +| wrap(&session_impl::on_lsd_announce, err); }); | │ │ │ │ +| | │ │ │ │ +| if (m_torrents.empty()) return; | │ │ │ │ +| | │ │ │ │ +| if (m_next_lsd_torrent >= m_torrents.size()) | │ │ │ │ +| m_next_lsd_torrent = 0; | │ │ │ │ +| m_torrents[m_next_lsd_torrent]->lsd_announce(); | │ │ │ │ +| ++m_next_lsd_torrent; | │ │ │ │ +| if (m_next_lsd_torrent >= m_torrents.size()) | │ │ │ │ +|_ _ _ _m___n_e_x_t___l_s_d___t_o_r_r_e_n_t_ _=_ _0_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_5_5_4_0_ _ _|_t_h_i_s_ _f_u_n_c_t_i_o_n_ _s_h_o_u_l_d_ _b_e_ _r_e_m_o_v_e_d_ _a_n_d_ _u_s_e_r_s_ _n_e_e_d_ _t_o_ _d_e_a_l_ _w_i_t_h_ _t_h_e_ _m_o_r_e_ _g_e_n_e_r_i_c_ _c_a_s_e_ _o_f_ _h_a_v_i_n_g_ _m_u_l_t_i_p_l_e_ _l_i_s_t_e_n_ _p_o_r_t_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tthhiiss ffuunnccttiioonn sshhoouulldd bbee rreemmoovveedd aanndd uusseerrss nneeeedd ttoo ddeeaall wwiitthh tthhee mmoorree ggeenneerriicc ccaassee ooff hhaavviinngg mmuullttiippllee lliisstteenn ppoorrttss ********** | │ │ │ │ +|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::55554400 ****** | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| if (!node_list.empty() && nodes.empty()) | │ │ │ │ +| { | │ │ │ │ +| session_log("ERROR: failed to parse DHT bootstrap list: %s", node_list.c_str()); | │ │ │ │ +| } | │ │ │ │ +|#endif | │ │ │ │ +| for (auto const& n : nodes) | │ │ │ │ +| add_dht_router(n); | │ │ │ │ +|#endif | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| void session_impl::update_count_slow() | │ │ │ │ +| { | │ │ │ │ +| error_code ec; | │ │ │ │ +| for (auto const& tp : m_torrents) | │ │ │ │ +| { | │ │ │ │ +| tp->on_inactivity_tick(ec); | │ │ │ │ +| } | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +|std::uint16_t session_impl::listen_port() const | │ │ │ │ +|{ | │ │ │ │ +| return listen_port(nullptr); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| std::uint16_t session_impl::listen_port(listen_socket_t* sock) const | │ │ │ │ +| { | │ │ │ │ +| if (m_listen_sockets.empty()) return 0; | │ │ │ │ +| if (sock) | │ │ │ │ +| { | │ │ │ │ +| // if we're using a proxy, we won't be able to accept any TCP | │ │ │ │ +| // connections. Not even uTP connections via the port we know about. | │ │ │ │ +| // The DHT may use the implied port to make it work, but the port we | │ │ │ │ +| // announce here has no relevance for that. | │ │ │ │ +| if (sock->flags & listen_socket_t::proxy) | │ │ │ │ +| return 0; | │ │ │ │ +| | │ │ │ │ +| if (!(sock->flags & listen_socket_t::accept_incoming)) | │ │ │ │ +| return 0; | │ │ │ │ +| | │ │ │ │ +| return std::uint16_t(sock->tcp_external_port()); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +|#ifdef TORRENT_SSL_PEERS | │ │ │ │ +| for (auto const& s : m_listen_sockets) | │ │ │ │ +| { | │ │ │ │ +| if (!(s->flags & listen_socket_t::accept_incoming)) continue; | │ │ │ │ +| if (s->ssl == transport::plaintext) | │ │ │ │ +| return std::uint16_t(s->tcp_external_port()); | │ │ │ │ +| } | │ │ │ │ +|_ _ _r_e_t_u_r_n_ _0_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_5_5_8_0_ _ _|_t_h_i_s_ _f_u_n_c_t_i_o_n_ _s_h_o_u_l_d_ _b_e_ _r_e_m_o_v_e_d_ _a_n_d_ _u_s_e_r_s_ _n_e_e_d_ _t_o_ _d_e_a_l_ _w_i_t_h_ _t_h_e_ _m_o_r_e_ _g_e_n_e_r_i_c_ _c_a_s_e_ _o_f_ _h_a_v_i_n_g_ _m_u_l_t_i_p_l_e_ _s_s_l_ _p_o_r_t_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tthhiiss ffuunnccttiioonn sshhoouulldd bbee rreemmoovveedd aanndd uusseerrss nneeeedd ttoo ddeeaall wwiitthh tthhee mmoorree ggeenneerriicc ccaassee ooff hhaavviinngg mmuullttiippllee ssssll ppoorrttss ********** | │ │ │ │ +|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::55558800 ****** | │ │ │ │ +|return 0; | │ │ │ │ +| | │ │ │ │ +| return std::uint16_t(sock->tcp_external_port()); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +|#ifdef TORRENT_SSL_PEERS | │ │ │ │ +| for (auto const& s : m_listen_sockets) | │ │ │ │ +| { | │ │ │ │ +| if (!(s->flags & listen_socket_t::accept_incoming)) continue; | │ │ │ │ +| if (s->ssl == transport::plaintext) | │ │ │ │ +| return std::uint16_t(s->tcp_external_port()); | │ │ │ │ +| } | │ │ │ │ +| return 0; | │ │ │ │ +|#else | │ │ │ │ +| sock = m_listen_sockets.front().get(); | │ │ │ │ +| if (!(sock->flags & listen_socket_t::accept_incoming)) return 0; | │ │ │ │ +| return std::uint16_t(sock->tcp_external_port()); | │ │ │ │ +|#endif | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +|std::uint16_t session_impl::ssl_listen_port() const | │ │ │ │ +|{ | │ │ │ │ +| return ssl_listen_port(nullptr); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| std::uint16_t session_impl::ssl_listen_port(listen_socket_t* sock) const | │ │ │ │ +| { | │ │ │ │ +|#ifdef TORRENT_SSL_PEERS | │ │ │ │ +| if (sock) | │ │ │ │ +| { | │ │ │ │ +| if (!(sock->flags & listen_socket_t::accept_incoming)) return 0; | │ │ │ │ +| return std::uint16_t(sock->tcp_external_port()); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| if (m_settings.get_int(settings_pack::proxy_type) != settings_pack::none | │ │ │ │ +| && m_settings.get_bool(settings_pack::proxy_peer_connections)) | │ │ │ │ +| return 0; | │ │ │ │ +| | │ │ │ │ +| for (auto const& s : m_listen_sockets) | │ │ │ │ +| { | │ │ │ │ +| if (!(s->flags & listen_socket_t::accept_incoming)) continue; | │ │ │ │ +| if (s->ssl == transport::ssl) | │ │ │ │ +| return std::uint16_t(s->tcp_external_port()); | │ │ │ │ +| } | │ │ │ │ +|#else | │ │ │ │ +| TORRENT_UNUSED(sock); | │ │ │ │ +|#endif | │ │ │ │ +| return 0; | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +|_ _i_n_t_ _s_e_s_s_i_o_n___i_m_p_l_:_:_g_e_t___l_i_s_t_e_n___p_o_r_t_(_t_r_a_n_s_p_o_r_t_ _c_o_n_s_t_ _s_s_l_,_ _a_u_x_:_:_l_i_s_t_e_n___s_o_c_k_e_t___h_a_n_d_l_e_ _c_o_n_s_t_&_ _s_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_6_4_2_7_ _ _|_t_h_i_s_ _s_h_o_u_l_d_ _b_e_ _f_a_c_t_o_r_e_d_ _i_n_t_o_ _t_h_e_ _u_d_p_ _s_o_c_k_e_t_,_ _s_o_ _w_e_ _o_n_l_y_ _h_a_v_e_ _t_h_e_ _c_o_d_e_ _o_n_c_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tthhiiss sshhoouulldd bbee ffaaccttoorreedd iinnttoo tthhee uuddpp ssoocckkeett,, ssoo wwee oonnllyy hhaavvee tthhee ccooddee oonnccee ********** | │ │ │ │ +|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::66442277 ****** | │ │ │ │ +|return upload_rate_limit(m_local_peer_class); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| int session_impl::local_download_rate_limit() const | │ │ │ │ +| { | │ │ │ │ +| return download_rate_limit(m_local_peer_class); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| int session_impl::upload_rate_limit_depr() const | │ │ │ │ +| { | │ │ │ │ +| return upload_rate_limit(m_global_class); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| int session_impl::download_rate_limit_depr() const | │ │ │ │ +| { | │ │ │ │ +| return download_rate_limit(m_global_class); | │ │ │ │ +| } | │ │ │ │ +|#endif // DEPRECATE | │ │ │ │ +| | │ │ │ │ +| | │ │ │ │ +|void session_impl::update_peer_dscp() | │ │ │ │ +|{ | │ │ │ │ +| int const value = m_settings.get_int(settings_pack::peer_dscp); | │ │ │ │ +| for (auto const& l : m_listen_sockets) | │ │ │ │ +| { | │ │ │ │ +| if (l->sock) | │ │ │ │ +| { | │ │ │ │ +| error_code ec; | │ │ │ │ +| set_traffic_class(*l->sock, value, ec); | │ │ │ │ +| | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| if (should_log()) | │ │ │ │ +| { | │ │ │ │ +| session_log(">>> SET_DSCP [ tcp (%s %d) value: %x e: %s ]" | │ │ │ │ +| , l->sock->local_endpoint().address().to_string().c_str() | │ │ │ │ +| , l->sock->local_endpoint().port(), std::uint32_t(value), ec.message().c_str()); | │ │ │ │ +| } | │ │ │ │ +|#endif | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| if (l->udp_sock) | │ │ │ │ +| { | │ │ │ │ +| error_code ec; | │ │ │ │ +| set_traffic_class(l->udp_sock->sock, value, ec); | │ │ │ │ +| | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| if (should_log()) | │ │ │ │ +| { | │ │ │ │ +| session_log(">>> SET_DSCP [ udp (%s %d) value: %x e: %s ]" | │ │ │ │ +| , l->udp_sock->sock.local_endpoint().address().to_string().c_str() | │ │ │ │ +|_ _ _ _ _ _ _,_ _l_-_>_u_d_p___s_o_c_k_-_>_s_o_c_k_._l_o_c_a_l___p_o_r_t_(_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |relevance 2|_._._/_s_r_c_/ |just make this peer not have the pieces associated with the file we just requested. Only when it doesn't have any of the file do the| │ │ │ │ |_ _ _ _ _ _ _ _ _ _ _ _|_w_e_b___p_e_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_:_6_3_6_ _ _ _|_f_o_l_l_o_w_i_n_g_ _p_a_d_ _f_i_l_e_s_ _w_i_l_l_ _m_a_k_e_ _i_t_ _c_o_m_p_l_i_c_a_t_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** jjuusstt mmaakkee tthhiiss ppeeeerr nnoott hhaavvee tthhee ppiieecceess aassssoocciiaatteedd wwiitthh tthhee ffiillee wwee jjuusstt rreeqquueesstteedd.. OOnnllyy wwhheenn iitt ddooeessnn''tt hhaavvee aannyy ooff tthhee ffiillee ddoo tthhee ffoolllloowwiinngg ppaadd ffiilleess wwiillll mmaakkee iitt | │ │ │ │ |ccoommpplliiccaatteedd ********** | │ │ │ │ |****** ....//ssrrcc//wweebb__ppeeeerr__ccoonnnneeccttiioonn..ccpppp::663366 ****** | │ │ │ │ | peer_connection::received_invalid_data(index, single_peer); | │ │ │ │ | | │ │ │ │ @@ -2356,177 +2718,182 @@ │ │ │ │ | } | │ │ │ │ | m_web = nullptr; | │ │ │ │ | TORRENT_ASSERT(is_disconnecting()); | │ │ │ │ |} | │ │ │ │ | | │ │ │ │ |void web_peer_connection::handle_redirect(int const bytes_left) | │ │ │ │ |_{_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_u_p_n_p_._c_p_p_:_1_1_6_ _ _ _ _ _ _ _ _ _ _ _|_u_s_e_ _b_o_o_s_t_:_:_a_s_i_o_:_:_i_p_:_:_n_e_t_w_o_r_k_ _i_n_s_t_e_a_d_ _o_f_ _n_e_t_m_a_s_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** uussee bboooosstt::::aassiioo::::iipp::::nneettwwoorrkk iinnsstteeaadd ooff nneettmmaasskk ********** | │ │ │ │ -|****** ....//ssrrcc//uuppnnpp..ccpppp::111166 ****** | │ │ │ │ -||| string_equal_no_case(content_type, "application/soap+xml"_sv); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|upnp::rootdevice::rootdevice() = default; | │ │ │ │ -| | │ │ │ │ -|#if TORRENT_USE_ASSERTS | │ │ │ │ -|upnp::rootdevice::~rootdevice() | │ │ │ │ -|{ | │ │ │ │ -| TORRENT_ASSERT(magic == 1337); | │ │ │ │ -| magic = 0; | │ │ │ │ +|relevance 2|_._._/_s_r_c_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_: |this should probably be based on time instead of number of request messages. For a very high throughput connection, 300 may be a | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_2_5_7_1_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_l_e_g_i_t_i_m_a_t_e_ _n_u_m_b_e_r_ _o_f_ _r_e_q_u_e_s_t_s_ _t_o_ _h_a_v_e_ _i_n_ _f_l_i_g_h_t_ _w_h_e_n_ _g_e_t_t_i_n_g_ _c_h_o_k_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tthhiiss sshhoouulldd pprroobbaabbllyy bbee bbaasseedd oonn ttiimmee iinnsstteeaadd ooff nnuummbbeerr ooff rreeqquueesstt mmeessssaaggeess.. FFoorr aa vveerryy hhiigghh tthhrroouugghhppuutt ccoonnnneeccttiioonn,, 330000 mmaayy bbee aa lleeggiittiimmaattee nnuummbbeerr ooff rreeqquueessttss ttoo hhaavvee iinn| │ │ │ │ +|fflliigghhtt wwhheenn ggeettttiinngg cchhookkeedd ********** | │ │ │ │ +|****** ....//ssrrcc//ppeeeerr__ccoonnnneeccttiioonn..ccpppp::22557711 ****** | │ │ │ │ |} | │ │ │ │ -|#else | │ │ │ │ -|upnp::rootdevice::~rootdevice() = default; | │ │ │ │ -|#endif | │ │ │ │ -| | │ │ │ │ -|upnp::rootdevice::rootdevice(rootdevice const&) = default; | │ │ │ │ -|upnp::rootdevice& upnp::rootdevice::operator=(rootdevice const&) & = default; | │ │ │ │ -|upnp::rootdevice::rootdevice(rootdevice&&) noexcept = default; | │ │ │ │ -|upnp::rootdevice& upnp::rootdevice::operator=(rootdevice&&) & = default; | │ │ │ │ -| | │ │ │ │ -|upnp::upnp(io_context& ios | │ │ │ │ -|, aux::session_settings const& settings | │ │ │ │ -| , aux::portmap_callback& cb | │ │ │ │ -| , address_v4 const listen_address | │ │ │ │ -| , address_v4 const netmask | │ │ │ │ -| , std::string listen_device | │ │ │ │ -| , listen_socket_handle ls) | │ │ │ │ -| : m_settings(settings) | │ │ │ │ -| , m_callback(cb) | │ │ │ │ -| , m_io_service(ios) | │ │ │ │ -| , m_resolver(ios) | │ │ │ │ -| , m_multicast(ios) | │ │ │ │ -| , m_unicast(ios) | │ │ │ │ -| , m_broadcast_timer(ios) | │ │ │ │ -| , m_refresh_timer(ios) | │ │ │ │ -| , m_map_timer(ios) | │ │ │ │ -| , m_listen_address(listen_address) | │ │ │ │ -| , m_netmask(netmask) | │ │ │ │ -| , m_device(std::move(listen_device)) | │ │ │ │ -|#if TORRENT_USE_SSL | │ │ │ │ -| , m_ssl_ctx(ssl::context::sslv23_client) | │ │ │ │ -|#endif | │ │ │ │ -| , m_listen_handle(std::move(ls)) | │ │ │ │ -|{ | │ │ │ │ -|#if TORRENT_USE_SSL | │ │ │ │ -| m_ssl_ctx.set_verify_mode(ssl::context::verify_none); | │ │ │ │ |#endif | │ │ │ │ -|} | │ │ │ │ | | │ │ │ │ -|void upnp::start() | │ │ │ │ -|_{_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 2|_._._/_s_r_c_/ |support authentication here. tracker_req().auth | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_u_d_p___t_r_a_c_k_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_:_8_1_ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ssuuppppoorrtt aauutthheennttiiccaattiioonn hheerree.. ttrraacckkeerr__rreeqq(())..aauutthh ********** | │ │ │ │ -|****** ....//ssrrcc//uuddpp__ttrraacckkeerr__ccoonnnneeccttiioonn..ccpppp::8811 ****** | │ │ │ │ -|udp_tracker_connection::m_connection_cache; | │ │ │ │ +| write_reject_request(r); | │ │ │ │ +| if (m_num_invalid_requests < std::numeric_limits::max()) | │ │ │ │ +| ++m_num_invalid_requests; | │ │ │ │ | | │ │ │ │ -| std::mutex udp_tracker_connection::m_cache_mutex; | │ │ │ │ +| if (t->alerts().should_post()) | │ │ │ │ +| { | │ │ │ │ +| // msvc 12 appears to deduce the rvalue reference template | │ │ │ │ +| // incorrectly for bool temporaries. So, create a dummy instance | │ │ │ │ +| bool const peer_interested = bool(m_peer_interested); | │ │ │ │ +| t->alerts().emplace_alert( | │ │ │ │ +| t->get_handle(), m_remote, m_peer_id, r | │ │ │ │ +| , t->user_have_piece(r.piece), peer_interested, false); | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -| udp_tracker_connection::udp_tracker_connection( | │ │ │ │ -| io_context& ios | │ │ │ │ -| , tracker_manager& man | │ │ │ │ -| , tracker_request const& req | │ │ │ │ -| , std::weak_ptr c) | │ │ │ │ -| : tracker_connection(man, req, ios, std::move(c)) | │ │ │ │ -| , m_transaction_id(0) | │ │ │ │ -| , m_attempts(0) | │ │ │ │ -| , m_state(action_t::error) | │ │ │ │ -| , m_abort(false) | │ │ │ │ -| { | │ │ │ │ -| update_transaction_id(); | │ │ │ │ -| } | │ │ │ │ +| // every ten invalid request, remind the peer that it's choked | │ │ │ │ +| if (!m_peer_interested && m_num_invalid_requests % 10 == 0 && m_choked) | │ │ │ │ +| { | │ │ │ │ +|if (m_num_invalid_requests > 300 && !m_peer_choked | │ │ │ │ +|&& can_disconnect(errors::too_many_requests_when_choked)) | │ │ │ │ +| { | │ │ │ │ +| disconnect(errors::too_many_requests_when_choked, operation_t::bittorrent, peer_error); | │ │ │ │ +| return; | │ │ │ │ +| } | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| peer_log(peer_log_alert::outgoing_message, "CHOKE"); | │ │ │ │ +|#endif | │ │ │ │ +| write_choke(); | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -| void udp_tracker_connection::start() | │ │ │ │ -| { | │ │ │ │ -|std::string hostname; | │ │ │ │ -|std::string protocol; | │ │ │ │ -| int port; | │ │ │ │ -| error_code ec; | │ │ │ │ +| return; | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -| std::tie(protocol, std::ignore, hostname, port, std::ignore) | │ │ │ │ -| = parse_url_components(tracker_req().url, ec); | │ │ │ │ -| if (port == -1) port = protocol == "http" ? 80 : 443; | │ │ │ │ +| // if we have choked the client | │ │ │ │ +| // ignore the request | │ │ │ │ +| int const blocks_per_piece = | │ │ │ │ +| (ti.piece_length() + t->block_size() - 1) / t->block_size(); | │ │ │ │ | | │ │ │ │ -| if (ec) | │ │ │ │ +| // disconnect peers that downloads more than foo times an allowed | │ │ │ │ +| // fast piece | │ │ │ │ +| if (m_choked && fast_idx != -1 && m_accept_fast_piece_cnt[fast_idx] >= 3 * blocks_per_piece | │ │ │ │ +| && can_disconnect(errors::too_many_requests_when_choked)) | │ │ │ │ | { | │ │ │ │ -| tracker_connection::fail(ec, operation_t::parse_address); | │ │ │ │ +| disconnect(errors::too_many_requests_when_choked, operation_t::bittorrent, peer_error); | │ │ │ │ | return; | │ │ │ │ | } | │ │ │ │ | | │ │ │ │ -| aux::session_settings const& settings = m_man.settings(); | │ │ │ │ +| if (m_choked && fast_idx == -1) | │ │ │ │ +|_ _ _{_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| |_._._/_s_r_c_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_: |since we throw away the queue entry once we issue the disk job, this may happen. Instead, we should keep the queue entry around, | │ │ │ │ +|relevance 2|_3_3_2_3 |mark it as having been requested from disk and once the disk job comes back, discard it if it has been cancelled. Maybe even be able| │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_t_o_ _c_a_n_c_e_l_ _d_i_s_k_ _j_o_b_s_?_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** ssiinnccee wwee tthhrrooww aawwaayy tthhee qquueeuuee eennttrryy oonnccee wwee iissssuuee tthhee ddiisskk jjoobb,, tthhiiss mmaayy hhaappppeenn.. IInnsstteeaadd,, wwee sshhoouulldd kkeeeepp tthhee qquueeuuee eennttrryy aarroouunndd,, mmaarrkk iitt aass hhaavviinngg bbeeeenn rreeqquueesstteedd ffrroomm | │ │ │ │ +|ddiisskk aanndd oonnccee tthhee ddiisskk jjoobb ccoommeess bbaacckk,, ddiissccaarrdd iitt iiff iitt hhaass bbeeeenn ccaanncceelllleedd.. MMaayybbee eevveenn bbee aabbllee ttoo ccaanncceell ddiisskk jjoobbss?? ********** | │ │ │ │ +|****** ....//ssrrcc//ppeeeerr__ccoonnnneeccttiioonn..ccpppp::33332233 ****** | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| peer_log(peer_log_alert::incoming_message, "CANCEL" | │ │ │ │ +| , "piece: %d s: %x l: %x", static_cast(r.piece), std::uint32_t(r.start), std::uint32_t(r.length)); | │ │ │ │ +|#endif | │ │ │ │ | | │ │ │ │ -| int const proxy_type = settings.get_int(settings_pack::proxy_type); | │ │ │ │ +| auto const i = std::find(m_requests.begin(), m_requests.end(), r); | │ │ │ │ | | │ │ │ │ -| if (settings.get_bool(settings_pack::proxy_hostnames) | │ │ │ │ -| && (proxy_type == settings_pack::socks5 | │ │ │ │ -| || proxy_type == settings_pack::socks5_pw)) | │ │ │ │ +| if (i != m_requests.end()) | │ │ │ │ | { | │ │ │ │ -| m_hostname = hostname; | │ │ │ │ -| m_target.port(std::uint16_t(port)); | │ │ │ │ -| start_announce(); | │ │ │ │ +| m_counters.inc_stats_counter(counters::cancelled_piece_requests); | │ │ │ │ +| m_requests.erase(i); | │ │ │ │ +| | │ │ │ │ +| if (m_requests.empty()) | │ │ │ │ +| m_counters.inc_stats_counter(counters::num_peers_up_requests, -1); | │ │ │ │ +| | │ │ │ │ +| write_reject_request(r); | │ │ │ │ | } | │ │ │ │ | else | │ │ │ │ | { | │ │ │ │ -| using namespace std::placeholders; | │ │ │ │ -|_ _ _ _A_D_D___O_U_T_S_T_A_N_D_I_N_G___A_S_Y_N_C_(_"_u_d_p___t_r_a_c_k_e_r___c_o_n_n_e_c_t_i_o_n_:_:_n_a_m_e___l_o_o_k_u_p_"_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_t_r_a_c_k_e_r___m_a_n_a_g_e_r_._c_p_p_:_3_8_9_|_i_m_p_l_e_m_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** iimmpplleemmeenntt ********** | │ │ │ │ -|****** ....//ssrrcc//ttrraacckkeerr__mmaannaaggeerr..ccpppp::338899 ****** | │ │ │ │ |#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| if (m_ses.should_log()) | │ │ │ │ -| { | │ │ │ │ -| m_ses.session_log("incoming UDP tracker packet from %s has invalid " | │ │ │ │ -| "transaction ID (%x)", print_endpoint(ep).c_str() | │ │ │ │ -| , transaction); | │ │ │ │ -| } | │ │ │ │ +|peer_log(peer_log_alert::info, "INVALID_CANCEL", "got cancel not in the queue"); | │ │ │ │ |#endif | │ │ │ │ -| return false; | │ │ │ │ | } | │ │ │ │ -| | │ │ │ │ -| std::shared_ptr const p = i->second; | │ │ │ │ -| // on_receive() may remove the tracker connection from the list | │ │ │ │ -| return p->on_receive(ep, buf); | │ │ │ │ | } | │ │ │ │ | | │ │ │ │ -| void tracker_manager::incoming_error(error_code const& | │ │ │ │ -| , udp::endpoint const&) | │ │ │ │ -| { | │ │ │ │ -| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ -|} | │ │ │ │ +| // ----------------------------- | │ │ │ │ +| // --------- DHT PORT ---------- | │ │ │ │ +| // ----------------------------- | │ │ │ │ | | │ │ │ │ -| bool tracker_manager::incoming_packet(string_view const hostname | │ │ │ │ -| , span const buf) | │ │ │ │ +| void peer_connection::incoming_dht_port(int const listen_port) | │ │ │ │ | { | │ │ │ │ | TORRENT_ASSERT(is_single_thread()); | │ │ │ │ -| // ignore packets smaller than 8 bytes | │ │ │ │ -| if (buf.size() < 16) return false; | │ │ │ │ +| INVARIANT_CHECK; | │ │ │ │ | | │ │ │ │ -| // the first word is the action, if it's not [0, 3] | │ │ │ │ -| // it's not a valid udp tracker response | │ │ │ │ -| span ptr = buf; | │ │ │ │ -| std::uint32_t const action = aux::read_uint32(ptr); | │ │ │ │ -| if (action > 3) return false; | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| peer_log(peer_log_alert::incoming_message, "DHT_PORT", "p: %d", listen_port); | │ │ │ │ +|#endif | │ │ │ │ +|#ifndef TORRENT_DISABLE_DHT | │ │ │ │ +| m_ses.add_dht_node({m_remote.address(), std::uint16_t(listen_port)}); | │ │ │ │ +|#else | │ │ │ │ +| TORRENT_UNUSED(listen_port); | │ │ │ │ +|#endif | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -| std::uint32_t const transaction = aux::read_uint32(ptr); | │ │ │ │ -| auto const i = m_udp_conns.find(transaction); | │ │ │ │ +| // ----------------------------- | │ │ │ │ +| // --------- HAVE ALL ---------- | │ │ │ │ +| // ----------------------------- | │ │ │ │ | | │ │ │ │ -| if (i == m_udp_conns.end()) | │ │ │ │ +| void peer_connection::incoming_have_all() | │ │ │ │ +|_ _{_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 2|_._._/_s_r_c_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_: |use a deadline_timer for timeouts. Don't rely on second_tick()! Hook this up to connect timeout as well. This would improve | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_4_9_6_1_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_p_e_r_f_o_r_m_a_n_c_e_ _b_e_c_a_u_s_e_ _o_f_ _l_e_s_s_ _w_o_r_k_ _i_n_ _s_e_c_o_n_d___t_i_c_k_(_)_,_ _a_n_d_ _m_i_g_h_t_ _l_e_t_ _u_s_e_ _r_e_m_o_v_e_ _t_i_c_k_i_n_g_ _e_n_t_i_r_e_l_y_ _e_v_e_n_t_u_a_l_l_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** uussee aa ddeeaaddlliinnee__ttiimmeerr ffoorr ttiimmeeoouuttss.. DDoonn''tt rreellyy oonn sseeccoonndd__ttiicckk(())!! HHooookk tthhiiss uupp ttoo ccoonnnneecctt ttiimmeeoouutt aass wweellll.. TThhiiss wwoouulldd iimmpprroovvee ppeerrffoorrmmaannccee bbeeccaauussee ooff lleessss wwoorrkk iinn | │ │ │ │ +|sseeccoonndd__ttiicckk(()),, aanndd mmiigghhtt lleett uussee rreemmoovvee ttiicckkiinngg eennttiirreellyy eevveennttuuaallllyy ********** | │ │ │ │ +|****** ....//ssrrcc//ppeeeerr__ccoonnnneeccttiioonn..ccpppp::44996611 ****** | │ │ │ │ +|if (d > seconds(connect_timeout) | │ │ │ │ +| && can_disconnect(errors::timed_out)) | │ │ │ │ +| { | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| peer_log(peer_log_alert::info, "CONNECT_FAILED", "waited %d seconds" | │ │ │ │ +| , int(total_seconds(d))); | │ │ │ │ +|#endif | │ │ │ │ +| connect_failed(errors::timed_out); | │ │ │ │ +| return; | │ │ │ │ +| } | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| // if the bw_network flag isn't set, it means we are not even trying to | │ │ │ │ +| // read from this peer's socket. Most likely because we're applying a | │ │ │ │ +| // rate limit. If the peer is "slow" because we are rate limiting it, | │ │ │ │ +| // don't enforce timeouts. However, as soon as we *do* read from the | │ │ │ │ +| // socket, we expect to receive data, and not have timed out. Then we | │ │ │ │ +| // can enforce the timeouts. | │ │ │ │ +| bool const reading_socket = bool(m_channel_state[download_channel] & peer_info::bw_network); | │ │ │ │ +| | │ │ │ │ +|if (reading_socket && d > seconds(timeout()) && !m_connecting && m_reading_bytes == 0 | │ │ │ │ +|&& can_disconnect(errors::timed_out_inactivity)) | │ │ │ │ | { | │ │ │ │ |#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| // now, this may not have been meant to be a tracker response, | │ │ │ │ -| // but chances are pretty good, so it's probably worth logging | │ │ │ │ -| m_ses.session_log("incoming UDP tracker packet from %s has invalid " | │ │ │ │ -| "transaction ID (%x)", std::string(hostname).c_str(), transaction); | │ │ │ │ +| peer_log(peer_log_alert::info, "LAST_ACTIVITY", "%d seconds ago" | │ │ │ │ +| , int(total_seconds(d))); | │ │ │ │ |#endif | │ │ │ │ -| return false; | │ │ │ │ +| disconnect(errors::timed_out_inactivity, operation_t::bittorrent); | │ │ │ │ +| return; | │ │ │ │ | } | │ │ │ │ | | │ │ │ │ -| std::shared_ptr const p = i->second; | │ │ │ │ -|_ _ _/_/_ _o_n___r_e_c_e_i_v_e_(_)_ _m_a_y_ _r_e_m_o_v_e_ _t_h_e_ _t_r_a_c_k_e_r_ _c_o_n_n_e_c_t_i_o_n_ _f_r_o_m_ _t_h_e_ _l_i_s_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| // do not stall waiting for a handshake | │ │ │ │ +| int timeout = m_settings.get_int (settings_pack::handshake_timeout); | │ │ │ │ +|#if TORRENT_USE_I2P | │ │ │ │ +| timeout *= is_i2p(m_socket) ? 4 : 1; | │ │ │ │ +|#endif | │ │ │ │ +| if (reading_socket | │ │ │ │ +| && !m_connecting | │ │ │ │ +| && in_handshake() | │ │ │ │ +| && d > seconds(timeout)) | │ │ │ │ +| { | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| peer_log(peer_log_alert::info, "NO_HANDSHAKE", "waited %d seconds" | │ │ │ │ +| , int(total_seconds(d))); | │ │ │ │ +|#endif | │ │ │ │ +| disconnect(errors::timed_out_no_handshake, operation_t::bittorrent); | │ │ │ │ +| return; | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| // disconnect peers that we unchoked, but they didn't send a request in | │ │ │ │ +|_ _ _/_/_ _t_h_e_ _l_a_s_t_ _6_0_ _s_e_c_o_n_d_s_,_ _a_n_d_ _w_e_ _h_a_v_e_n_'_t_ _b_e_e_n_ _w_o_r_k_i_n_g_ _o_n_ _s_e_r_v_i_c_i_n_g_ _a_ _r_e_q_u_e_s_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_t_o_r_r_e_n_t_._c_p_p_:_5_5_1_ _ _ _ _ _ _ _ _|_p_o_s_t_ _a_l_e_r_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** ppoosstt aalleerrtt ********** | │ │ │ │ |****** ....//ssrrcc//ttoorrrreenntt..ccpppp::555511 ****** | │ │ │ │ |if (m_current_gauge_state != no_gauge_state) | │ │ │ │ | inc_stats_counter(m_current_gauge_state + counters::num_checking_torrents, -1); | │ │ │ │ | if (new_gauge_state != no_gauge_state) | │ │ │ │ | inc_stats_counter(new_gauge_state + counters::num_checking_torrents, 1); | │ │ │ │ @@ -2899,322 +3266,343 @@ │ │ │ │ | // files with priority zero may not have been saved to disk at their | │ │ │ │ | // expected location, but is likely to be in a partfile. Just exempt it | │ │ │ │ | // from checking | │ │ │ │ | if (file_index < file_priority.end_index() | │ │ │ │ | && file_priority[file_index] == dont_download | │ │ │ │ | && !(rd.flags & torrent_flags::seed_mode)) | │ │ │ │ |_ _ _ _ _ _c_o_n_t_i_n_u_e_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_5_9_9_ _ _ _|_i_s_ _t_h_e_r_e_ _a_ _r_e_a_s_o_n_ _n_o_t_ _t_o_ _m_o_v_e_ _a_l_l_ _o_f_ _t_h_i_s_ _i_n_t_o_ _i_n_i_t_(_)_?_ _a_n_d_ _j_u_s_t_ _p_o_s_t_ _i_t_ _t_o_ _t_h_e_ _i_o___c_o_n_t_e_x_t_?_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** iiss tthheerree aa rreeaassoonn nnoott ttoo mmoovvee aallll ooff tthhiiss iinnttoo iinniitt(())?? aanndd jjuusstt ppoosstt iitt ttoo tthhee iioo__ccoonntteexxtt?? ********** | │ │ │ │ -|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::559999 ****** | │ │ │ │ -|try | │ │ │ │ -|#endif | │ │ │ │ -| { | │ │ │ │ -| (this->*f)(std::forward(a)...); | │ │ │ │ -| } | │ │ │ │ -|#ifndef BOOST_NO_EXCEPTIONS | │ │ │ │ -| catch (system_error const& e) { | │ │ │ │ -| alerts().emplace_alert(e.code(), e.what()); | │ │ │ │ -| pause(); | │ │ │ │ -| } catch (std::exception const& e) { | │ │ │ │ -| alerts().emplace_alert(error_code(), e.what()); | │ │ │ │ -| pause(); | │ │ │ │ -| } catch (...) { | │ │ │ │ -| alerts().emplace_alert(error_code(), "unknown error"); | │ │ │ │ -| pause(); | │ │ │ │ -| } | │ │ │ │ -|#endif | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_p_a_t_h_._c_p_p_:_4_3_6_ _ _ _ _ _ _ _ _ _ _ _|_t_e_s_t_ _t_h_i_s_ _o_n_ _a_ _F_A_T_ _v_o_l_u_m_e_ _t_o_ _s_e_e_ _w_h_a_t_ _e_r_r_o_r_ _w_e_ _g_e_t_!_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt tthhiiss oonn aa FFAATT vvoolluummee ttoo sseeee wwhhaatt eerrrroorr wwee ggeett!! ********** | │ │ │ │ +|****** ....//ssrrcc//ppaatthh..ccpppp::443366 ****** | │ │ │ │ +|// it's possible CreateHardLink will copy the file internally too, | │ │ │ │ +| // if the filesystem does not support it. | │ │ │ │ +| ec.assign(GetLastError(), system_category()); | │ │ │ │ +| return; | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -| // This function is called by the creating thread, not in the message loop's | │ │ │ │ -| // io_context thread. | │ │ │ │ -|void session_impl::start_session() | │ │ │ │ -|{ | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| session_log("start session"); | │ │ │ │ +| // fall back to making a copy | │ │ │ │ |#endif | │ │ │ │ +|#else | │ │ │ │ +| // assume posix's link() function exists | │ │ │ │ +| int ret = ::link(n_exist.c_str(), n_link.c_str()); | │ │ │ │ | | │ │ │ │ -|#if TORRENT_USE_SSL | │ │ │ │ -| error_code ec; | │ │ │ │ -| m_ssl_ctx.set_default_verify_paths(ec); | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| if (ec) session_log("SSL set_default verify_paths failed: %s", ec.message().c_str()); | │ │ │ │ -| ec.clear(); | │ │ │ │ -|#endif | │ │ │ │ -|_#_i_f_ _d_e_f_i_n_e_d_ _T_O_R_R_E_N_T___W_I_N_D_O_W_S_ _&_&_ _d_e_f_i_n_e_d_ _T_O_R_R_E_N_T___U_S_E___O_P_E_N_S_S_L_ _&_&_ _!_d_e_f_i_n_e_d_ _T_O_R_R_E_N_T___W_I_N_R_T_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_7_7_5_ _ _ _|_t_h_e_ _i_p_ _f_i_l_t_e_r_ _s_h_o_u_l_d_ _p_r_o_b_a_b_l_y_ _b_e_ _s_a_v_e_d_ _h_e_r_e_ _t_o_o_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tthhee iipp ffiilltteerr sshhoouulldd pprroobbaabbllyy bbee ssaavveedd hheerree ttoooo ********** | │ │ │ │ -|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::777755 ****** | │ │ │ │ -|m_lsd_announce_timer.async_wait([this](error_code const& e) { | │ │ │ │ -| wrap(&session_impl::on_lsd_announce, e); } ); | │ │ │ │ +| if (ret == 0) | │ │ │ │ +| { | │ │ │ │ +| ec.clear(); | │ │ │ │ +| return; | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| session_log(" done starting session"); | │ │ │ │ +| // most errors are passed through, except for the ones that indicate that | │ │ │ │ +| // hard links are not supported and require a copy. | │ │ │ │ +|if (errno != EMLINK | │ │ │ │ +|&& errno != EXDEV | │ │ │ │ +|#ifdef TORRENT_BEOS | │ │ │ │ +| // haiku returns EPERM when the filesystem doesn't support hard link | │ │ │ │ +| && errno != EPERM | │ │ │ │ |#endif | │ │ │ │ +| ) | │ │ │ │ +| { | │ │ │ │ +| // some error happened, report up to the caller | │ │ │ │ +| ec.assign(errno, system_category()); | │ │ │ │ +| return; | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -| // this applies unchoke settings from m_settings | │ │ │ │ -| recalculate_unchoke_slots(); | │ │ │ │ -| | │ │ │ │ -| // apply all m_settings to this session | │ │ │ │ -| run_all_updates(*this); | │ │ │ │ -| reopen_listen_sockets(false); | │ │ │ │ +| // fall back to making a copy | │ │ │ │ | | │ │ │ │ -|#if TORRENT_USE_INVARIANT_CHECKS | │ │ │ │ -| check_invariant(); | │ │ │ │ |#endif | │ │ │ │ +| | │ │ │ │ +| // if we get here, we should copy the file | │ │ │ │ +| storage_error se; | │ │ │ │ +| aux::copy_file(file, link, se); | │ │ │ │ +| ec = se.ec; | │ │ │ │ | } | │ │ │ │ | | │ │ │ │ -|#if TORRENT_ABI_VERSION <= 2 | │ │ │ │ -|void session_impl::save_state(entry* eptr, save_state_flags_t const flags) const | │ │ │ │ +| bool is_directory(std::string const& f, error_code& ec) | │ │ │ │ +| { | │ │ │ │ +| ec.clear(); | │ │ │ │ +| error_code e; | │ │ │ │ +| file_status s; | │ │ │ │ +| stat_file(f, &s, e); | │ │ │ │ +| if (!e && s.mode & file_status::directory) return true; | │ │ │ │ +|_ _ _e_c_ _=_ _e_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| |_._._/_s_r_c_/ | | │ │ │ │ +|relevance 2|_h_t_t_p___t_r_a_c_k_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_: |returning a bool here is redundant. Instead this function should return the peer_entry | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_4_8_6_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** rreettuurrnniinngg aa bbooooll hheerree iiss rreedduunnddaanntt.. IInnsstteeaadd tthhiiss ffuunnccttiioonn sshhoouulldd rreettuurrnn tthhee ppeeeerr__eennttrryy ********** | │ │ │ │ +|****** ....//ssrrcc//hhttttpp__ttrraacckkeerr__ccoonnnneeccttiioonn..ccpppp::448866 ****** | │ │ │ │ |{ | │ │ │ │ -| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ +| cb->tracker_scrape_response(tracker_req(), resp.complete | │ │ │ │ +| , resp.incomplete, resp.downloaded, resp.downloaders); | │ │ │ │ +| } | │ │ │ │ +| else | │ │ │ │ +| { | │ │ │ │ +| std::list
    ip_list; | │ │ │ │ +| if (m_tracker_connection) | │ │ │ │ +| { | │ │ │ │ +| for (auto const& endp : m_tracker_connection->endpoints()) | │ │ │ │ +| { | │ │ │ │ +| ip_list.push_back(endp.address()); | │ │ │ │ +| } | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -| entry& e = *eptr; | │ │ │ │ -| // make it a dict | │ │ │ │ -| e.dict(); | │ │ │ │ +| cb->tracker_response(tracker_req(), m_tracker_ip, ip_list, resp); | │ │ │ │ +| } | │ │ │ │ +| close(); | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -| if (flags & session::save_settings) | │ │ │ │ +|bool extract_peer_info(bdecode_node const& info, peer_entry& ret, error_code& ec) | │ │ │ │ +|{ | │ │ │ │ +| // extract peer id (if any) | │ │ │ │ +| if (info.type() != bdecode_node::dict_t) | │ │ │ │ | { | │ │ │ │ -| entry::dictionary_type& sett = e["settings"].dict(); | │ │ │ │ -| save_settings_to_dict(non_default_settings(m_settings), sett); | │ │ │ │ +| ec = errors::invalid_peer_dict; | │ │ │ │ +| return false; | │ │ │ │ | } | │ │ │ │ -| | │ │ │ │ -|#ifndef TORRENT_DISABLE_DHT | │ │ │ │ -| if (flags & session::save_dht_settings) | │ │ │ │ +| bdecode_node i = info.dict_find_string("peer id"); | │ │ │ │ +| if (i && i.string_length() == 20) | │ │ │ │ | { | │ │ │ │ -| e["dht"] = dht::save_dht_settings(get_dht_settings()); | │ │ │ │ +| std::copy(i.string_ptr(), i.string_ptr() + 20, ret.pid.begin()); | │ │ │ │ +| } | │ │ │ │ +| else | │ │ │ │ +| { | │ │ │ │ +| // if there's no peer_id, just initialize it to a bunch of zeroes | │ │ │ │ +| ret.pid.clear(); | │ │ │ │ | } | │ │ │ │ | | │ │ │ │ -| if (m_dht && (flags & session::save_dht_state)) | │ │ │ │ +| // extract ip | │ │ │ │ +| i = info.dict_find_string("ip"); | │ │ │ │ +| if (!i) | │ │ │ │ | { | │ │ │ │ -| e["dht state"] = dht::save_dht_state(m_dht->state()); | │ │ │ │ +| ec = errors::invalid_tracker_response; | │ │ │ │ +| return false; | │ │ │ │ | } | │ │ │ │ +| ret.hostname = i.string_value().to_string(); | │ │ │ │ +| | │ │ │ │ +| // extract port | │ │ │ │ +| i = info.dict_find_int("port"); | │ │ │ │ +|_ _ _i_f_ _(_!_i_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 2|_._._/_s_r_c_/ |peer_connection and tracker_connection should probably be flags | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_i_n_s_t_a_n_t_i_a_t_e___c_o_n_n_e_c_t_i_o_n_._c_p_p_:_4_4_ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** ppeeeerr__ccoonnnneeccttiioonn aanndd ttrraacckkeerr__ccoonnnneeccttiioonn sshhoouulldd pprroobbaabbllyy bbee ffllaaggss ********** | │ │ │ │ +|****** ....//ssrrcc//iinnssttaannttiiaattee__ccoonnnneeccttiioonn..ccpppp::4444 ****** | │ │ │ │ +|ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | │ │ │ │ +|LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | │ │ │ │ +|CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | │ │ │ │ +|SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | │ │ │ │ +|INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | │ │ │ │ +|CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | │ │ │ │ +|ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | │ │ │ │ +|POSSIBILITY OF SUCH DAMAGE. | │ │ │ │ +| | │ │ │ │ +|*/ | │ │ │ │ +| | │ │ │ │ +|#include "libtorrent/socket.hpp" | │ │ │ │ +|#include "libtorrent/aux_/socket_type.hpp" | │ │ │ │ +|#include "libtorrent/aux_/utp_socket_manager.hpp" | │ │ │ │ +|#include "libtorrent/aux_/instantiate_connection.hpp" | │ │ │ │ +|#include "libtorrent/aux_/utp_stream.hpp" | │ │ │ │ +|#include "libtorrent/ssl_stream.hpp" | │ │ │ │ +| | │ │ │ │ +|namespace libtorrent { namespace aux { | │ │ │ │ +| | │ │ │ │ +|aux::socket_type instantiate_connection(io_context& ios | │ │ │ │ +|, aux::proxy_settings const& ps | │ │ │ │ +| , void* ssl_context | │ │ │ │ +| , utp_socket_manager* sm | │ │ │ │ +| , bool peer_connection | │ │ │ │ +| , bool tracker_connection) | │ │ │ │ +| { | │ │ │ │ +|#if !TORRENT_USE_SSL | │ │ │ │ +| TORRENT_UNUSED(ssl_context); | │ │ │ │ |#endif | │ │ │ │ | | │ │ │ │ -|#ifndef TORRENT_DISABLE_EXTENSIONS | │ │ │ │ -| for (auto const& ext : m_ses_extensions[plugins_all_idx]) | │ │ │ │ -| { | │ │ │ │ -| ext->save_state(*eptr); | │ │ │ │ -|_ _ _}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 2|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_3_9_0_0 |make a list for torrents that want to be announced on the DHT so we don't have to loop over all torrents, just to find the ones that| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_w_a_n_t_ _t_o_ _a_n_n_o_u_n_c_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** mmaakkee aa lliisstt ffoorr ttoorrrreennttss tthhaatt wwaanntt ttoo bbee aannnnoouunncceedd oonn tthhee DDHHTT ssoo wwee ddoonn''tt hhaavvee ttoo lloooopp oovveerr aallll ttoorrrreennttss,, jjuusstt ttoo ffiinndd tthhee oonneess tthhaatt wwaanntt ttoo aannnnoouunnccee ********** | │ │ │ │ -|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::33990000 ****** | │ │ │ │ -|if (!m_dht_torrents.empty()) | │ │ │ │ +| if (sm) | │ │ │ │ | { | │ │ │ │ -| std::shared_ptr t; | │ │ │ │ -| do | │ │ │ │ +|#if TORRENT_USE_SSL | │ │ │ │ +| if (ssl_context) | │ │ │ │ | { | │ │ │ │ -| t = m_dht_torrents.front().lock(); | │ │ │ │ -| m_dht_torrents.pop_front(); | │ │ │ │ -| } while (!t && !m_dht_torrents.empty()); | │ │ │ │ -| | │ │ │ │ -| if (t) | │ │ │ │ +| ssl_stream s(ios, *static_cast(ssl_context)); | │ │ │ │ +| s.next_layer().set_impl(sm->new_utp_socket(&s.next_layer())); | │ │ │ │ +| return socket_type(std::move(s)); | │ │ │ │ +| } | │ │ │ │ +| else | │ │ │ │ +|#endif | │ │ │ │ | { | │ │ │ │ -| t->dht_announce(); | │ │ │ │ -| return; | │ │ │ │ +| utp_stream s(ios); | │ │ │ │ +| s.set_impl(sm->new_utp_socket(&s)); | │ │ │ │ +| return socket_type(std::move(s)); | │ │ │ │ | } | │ │ │ │ | } | │ │ │ │ -| if (m_torrents.empty()) return; | │ │ │ │ +|#if TORRENT_USE_I2P | │ │ │ │ +| else if (ps.type == settings_pack::i2p_proxy) | │ │ │ │ +|_ _ _{_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_a_l_e_r_t___m_a_n_a_g_e_r_._c_p_p_:_7_6_ _ _ _|_k_e_e_p_ _a_ _c_o_u_n_t_ _o_f_ _t_h_e_ _n_u_m_b_e_r_ _o_f_ _t_h_r_e_a_d_s_ _w_a_i_t_i_n_g_._ _O_n_l_y_ _i_f_ _i_t_'_s_ _>_ _0_ _n_o_t_i_f_y_ _t_h_e_m_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** kkeeeepp aa ccoouunntt ooff tthhee nnuummbbeerr ooff tthhrreeaaddss wwaaiittiinngg.. OOnnllyy iiff iitt''ss >> 00 nnoottiiffyy tthheemm ********** | │ │ │ │ +|****** ....//ssrrcc//aalleerrtt__mmaannaaggeerr..ccpppp::7766 ****** | │ │ │ │ +|{ | │ │ │ │ +| std::unique_lock lock(m_mutex); | │ │ │ │ | | │ │ │ │ -| if (m_next_dht_torrent >= m_torrents.size()) | │ │ │ │ -| m_next_dht_torrent = 0; | │ │ │ │ -| m_torrents[m_next_dht_torrent]->dht_announce(); | │ │ │ │ -|++m_next_dht_torrent; | │ │ │ │ -|if (m_next_dht_torrent >= m_torrents.size()) | │ │ │ │ -| m_next_dht_torrent = 0; | │ │ │ │ +| if (!m_alerts[m_generation & 1].empty()) return true; | │ │ │ │ +| | │ │ │ │ +| // this call can be interrupted prematurely by other signals | │ │ │ │ +| m_condition.wait_for(lock, max_wait); | │ │ │ │ +| return !m_alerts[m_generation & 1].empty(); | │ │ │ │ | } | │ │ │ │ -|#endif | │ │ │ │ | | │ │ │ │ -| void session_impl::on_lsd_announce(error_code const& e) | │ │ │ │ +| void alert_manager::maybe_notify(alert* a) | │ │ │ │ | { | │ │ │ │ -| COMPLETE_ASYNC("session_impl::on_lsd_announce"); | │ │ │ │ -| m_stats_counters.inc_stats_counter(counters::on_lsd_counter); | │ │ │ │ -| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ -| if (e) return; | │ │ │ │ -| | │ │ │ │ -| if (m_abort) return; | │ │ │ │ -| | │ │ │ │ -| ADD_OUTSTANDING_ASYNC("session_impl::on_lsd_announce"); | │ │ │ │ -| // announce on local network every 5 minutes | │ │ │ │ -| int const delay = std::max(m_settings.get_int(settings_pack::local_service_announce_interval) | │ │ │ │ -| / std::max(int(m_torrents.size()), 1), 1); | │ │ │ │ -| m_lsd_announce_timer.expires_after(seconds(delay)); | │ │ │ │ -| m_lsd_announce_timer.async_wait([this](error_code const& err) { | │ │ │ │ -| wrap(&session_impl::on_lsd_announce, err); }); | │ │ │ │ +| if (m_alerts[m_generation & 1].size() == 1) | │ │ │ │ +| { | │ │ │ │ +| // we just posted to an empty queue. If anyone is waiting for | │ │ │ │ +| // alerts, we need to notify them. Also (potentially) call the | │ │ │ │ +| // user supplied m_notify callback to let the client wake up its | │ │ │ │ +| // message loop to poll for alerts. | │ │ │ │ +| if (m_notify) m_notify(); | │ │ │ │ | | │ │ │ │ -| if (m_torrents.empty()) return; | │ │ │ │ +|m_condition.notify_all(); | │ │ │ │ +|} | │ │ │ │ | | │ │ │ │ -| if (m_next_lsd_torrent >= m_torrents.size()) | │ │ │ │ -| m_next_lsd_torrent = 0; | │ │ │ │ -| m_torrents[m_next_lsd_torrent]->lsd_announce(); | │ │ │ │ -| ++m_next_lsd_torrent; | │ │ │ │ -| if (m_next_lsd_torrent >= m_torrents.size()) | │ │ │ │ -|_ _ _ _m___n_e_x_t___l_s_d___t_o_r_r_e_n_t_ _=_ _0_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_5_5_4_0_ _ _|_t_h_i_s_ _f_u_n_c_t_i_o_n_ _s_h_o_u_l_d_ _b_e_ _r_e_m_o_v_e_d_ _a_n_d_ _u_s_e_r_s_ _n_e_e_d_ _t_o_ _d_e_a_l_ _w_i_t_h_ _t_h_e_ _m_o_r_e_ _g_e_n_e_r_i_c_ _c_a_s_e_ _o_f_ _h_a_v_i_n_g_ _m_u_l_t_i_p_l_e_ _l_i_s_t_e_n_ _p_o_r_t_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tthhiiss ffuunnccttiioonn sshhoouulldd bbee rreemmoovveedd aanndd uusseerrss nneeeedd ttoo ddeeaall wwiitthh tthhee mmoorree ggeenneerriicc ccaassee ooff hhaavviinngg mmuullttiippllee lliisstteenn ppoorrttss ********** | │ │ │ │ -|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::55554400 ****** | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| if (!node_list.empty() && nodes.empty()) | │ │ │ │ -| { | │ │ │ │ -| session_log("ERROR: failed to parse DHT bootstrap list: %s", node_list.c_str()); | │ │ │ │ -| } | │ │ │ │ -|#endif | │ │ │ │ -| for (auto const& n : nodes) | │ │ │ │ -| add_dht_router(n); | │ │ │ │ +|#ifndef TORRENT_DISABLE_EXTENSIONS | │ │ │ │ +| for (auto& e : m_ses_extensions) | │ │ │ │ +| e->on_alert(a); | │ │ │ │ +|#else | │ │ │ │ +| TORRENT_UNUSED(a); | │ │ │ │ |#endif | │ │ │ │ | } | │ │ │ │ | | │ │ │ │ -| void session_impl::update_count_slow() | │ │ │ │ +| void alert_manager::set_notify_function(std::function const& fun) | │ │ │ │ | { | │ │ │ │ -| error_code ec; | │ │ │ │ -| for (auto const& tp : m_torrents) | │ │ │ │ +| std::unique_lock lock(m_mutex); | │ │ │ │ +| m_notify = fun; | │ │ │ │ +| if (!m_alerts[m_generation & 1].empty()) | │ │ │ │ | { | │ │ │ │ -| tp->on_inactivity_tick(ec); | │ │ │ │ +| if (m_notify) m_notify(); | │ │ │ │ | } | │ │ │ │ | } | │ │ │ │ | | │ │ │ │ -|std::uint16_t session_impl::listen_port() const | │ │ │ │ -|{ | │ │ │ │ -| return listen_port(nullptr); | │ │ │ │ +|#ifndef TORRENT_DISABLE_EXTENSIONS | │ │ │ │ +| void alert_manager::add_extension(std::shared_ptr ext) | │ │ │ │ +| { | │ │ │ │ +| m_ses_extensions.push_back(std::move(ext)); | │ │ │ │ | } | │ │ │ │ +|#endif | │ │ │ │ | | │ │ │ │ -| std::uint16_t session_impl::listen_port(listen_socket_t* sock) const | │ │ │ │ +| void alert_manager::get_all(std::vector& alerts) | │ │ │ │ | { | │ │ │ │ -| if (m_listen_sockets.empty()) return 0; | │ │ │ │ -| if (sock) | │ │ │ │ -| { | │ │ │ │ -| // if we're using a proxy, we won't be able to accept any TCP | │ │ │ │ -| // connections. Not even uTP connections via the port we know about. | │ │ │ │ -| // The DHT may use the implied port to make it work, but the port we | │ │ │ │ -| // announce here has no relevance for that. | │ │ │ │ -| if (sock->flags & listen_socket_t::proxy) | │ │ │ │ -| return 0; | │ │ │ │ +|_ _ _s_t_d_:_:_l_o_c_k___g_u_a_r_d_<_s_t_d_:_:_r_e_c_u_r_s_i_v_e___m_u_t_e_x_>_ _l_o_c_k_(_m___m_u_t_e_x_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 2|_._._/_s_r_c_/_p_e_e_r___l_i_s_t_._c_p_p_:_5_3_5 |it would be nice if there was a way to iterate over these torrent_peer objects in the order they are allocated in the pool instead. | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_I_t_ _w_o_u_l_d_ _p_r_o_b_a_b_l_y_ _b_e_ _m_o_r_e_ _e_f_f_i_c_i_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** iitt wwoouulldd bbee nniiccee iiff tthheerree wwaass aa wwaayy ttoo iitteerraattee oovveerr tthheessee ttoorrrreenntt__ppeeeerr oobbjjeeccttss iinn tthhee oorrddeerr tthheeyy aarree aallllooccaatteedd iinn tthhee ppooooll iinnsstteeaadd.. IItt wwoouulldd pprroobbaabbllyy bbee mmoorree eeffffiicciieenntt | │ │ │ │ +|********** | │ │ │ │ +|****** ....//ssrrcc//ppeeeerr__lliisstt..ccpppp::553355 ****** | │ │ │ │ +|, int session_time, torrent_state* state) | │ │ │ │ +| { | │ │ │ │ +| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ +| INVARIANT_CHECK; | │ │ │ │ | | │ │ │ │ -| if (!(sock->flags & listen_socket_t::accept_incoming)) | │ │ │ │ -| return 0; | │ │ │ │ +| const int candidate_count = 10; | │ │ │ │ +| peers.reserve(candidate_count); | │ │ │ │ | | │ │ │ │ -| return std::uint16_t(sock->tcp_external_port()); | │ │ │ │ -| } | │ │ │ │ +| int erase_candidate = -1; | │ │ │ │ | | │ │ │ │ -|#ifdef TORRENT_SSL_PEERS | │ │ │ │ -| for (auto const& s : m_listen_sockets) | │ │ │ │ -| { | │ │ │ │ -| if (!(s->flags & listen_socket_t::accept_incoming)) continue; | │ │ │ │ -| if (s->ssl == transport::plaintext) | │ │ │ │ -| return std::uint16_t(s->tcp_external_port()); | │ │ │ │ -| } | │ │ │ │ -|_ _ _r_e_t_u_r_n_ _0_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_5_5_8_0_ _ _|_t_h_i_s_ _f_u_n_c_t_i_o_n_ _s_h_o_u_l_d_ _b_e_ _r_e_m_o_v_e_d_ _a_n_d_ _u_s_e_r_s_ _n_e_e_d_ _t_o_ _d_e_a_l_ _w_i_t_h_ _t_h_e_ _m_o_r_e_ _g_e_n_e_r_i_c_ _c_a_s_e_ _o_f_ _h_a_v_i_n_g_ _m_u_l_t_i_p_l_e_ _s_s_l_ _p_o_r_t_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tthhiiss ffuunnccttiioonn sshhoouulldd bbee rreemmoovveedd aanndd uusseerrss nneeeedd ttoo ddeeaall wwiitthh tthhee mmoorree ggeenneerriicc ccaassee ooff hhaavviinngg mmuullttiippllee ssssll ppoorrttss ********** | │ │ │ │ -|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::55558800 ****** | │ │ │ │ -|return 0; | │ │ │ │ +| if (bool(m_finished) != state->is_finished) | │ │ │ │ +| recalculate_connect_candidates(state); | │ │ │ │ | | │ │ │ │ -| return std::uint16_t(sock->tcp_external_port()); | │ │ │ │ -| } | │ │ │ │ +| external_ip const& external = state->ip; | │ │ │ │ +| int external_port = state->port; | │ │ │ │ | | │ │ │ │ -|#ifdef TORRENT_SSL_PEERS | │ │ │ │ -| for (auto const& s : m_listen_sockets) | │ │ │ │ -| { | │ │ │ │ -| if (!(s->flags & listen_socket_t::accept_incoming)) continue; | │ │ │ │ -| if (s->ssl == transport::plaintext) | │ │ │ │ -| return std::uint16_t(s->tcp_external_port()); | │ │ │ │ -| } | │ │ │ │ -| return 0; | │ │ │ │ -|#else | │ │ │ │ -| sock = m_listen_sockets.front().get(); | │ │ │ │ -| if (!(sock->flags & listen_socket_t::accept_incoming)) return 0; | │ │ │ │ -| return std::uint16_t(sock->tcp_external_port()); | │ │ │ │ -|#endif | │ │ │ │ -| } | │ │ │ │ +| if (m_round_robin >= int(m_peers.size())) m_round_robin = 0; | │ │ │ │ | | │ │ │ │ -|std::uint16_t session_impl::ssl_listen_port() const | │ │ │ │ -|{ | │ │ │ │ -| return ssl_listen_port(nullptr); | │ │ │ │ -| } | │ │ │ │ +| int max_peerlist_size = state->max_peerlist_size; | │ │ │ │ | | │ │ │ │ -| std::uint16_t session_impl::ssl_listen_port(listen_socket_t* sock) const | │ │ │ │ -| { | │ │ │ │ -|#ifdef TORRENT_SSL_PEERS | │ │ │ │ -| if (sock) | │ │ │ │ +|for (int iterations = std::min(int(m_peers.size()), 300); | │ │ │ │ +|iterations > 0; --iterations) | │ │ │ │ | { | │ │ │ │ -| if (!(sock->flags & listen_socket_t::accept_incoming)) return 0; | │ │ │ │ -| return std::uint16_t(sock->tcp_external_port()); | │ │ │ │ -| } | │ │ │ │ +| ++state->loop_counter; | │ │ │ │ | | │ │ │ │ -| if (m_settings.get_int(settings_pack::proxy_type) != settings_pack::none | │ │ │ │ -| && m_settings.get_bool(settings_pack::proxy_peer_connections)) | │ │ │ │ -| return 0; | │ │ │ │ +| if (m_round_robin >= int(m_peers.size())) m_round_robin = 0; | │ │ │ │ | | │ │ │ │ -| for (auto const& s : m_listen_sockets) | │ │ │ │ -| { | │ │ │ │ -| if (!(s->flags & listen_socket_t::accept_incoming)) continue; | │ │ │ │ -| if (s->ssl == transport::ssl) | │ │ │ │ -| return std::uint16_t(s->tcp_external_port()); | │ │ │ │ -| } | │ │ │ │ -|#else | │ │ │ │ -| TORRENT_UNUSED(sock); | │ │ │ │ +| torrent_peer& pe = *m_peers[m_round_robin]; | │ │ │ │ +| TORRENT_ASSERT(pe.in_use); | │ │ │ │ +| int current = m_round_robin; | │ │ │ │ +| | │ │ │ │ +| // if the number of peers is growing large | │ │ │ │ +| // we need to start weeding. | │ │ │ │ +| | │ │ │ │ +| if (int(m_peers.size()) >= max_peerlist_size * 0.95 | │ │ │ │ +| && max_peerlist_size > 0) | │ │ │ │ +| { | │ │ │ │ +| if (is_erase_candidate(pe) | │ │ │ │ +| && (erase_candidate == -1 | │ │ │ │ +| || !compare_peer_erase(*m_peers[erase_candidate], pe))) | │ │ │ │ +| { | │ │ │ │ +| if (should_erase_immediately(pe)) | │ │ │ │ +| { | │ │ │ │ +| if (erase_candidate > current) --erase_candidate; | │ │ │ │ +| erase_peer(m_peers.begin() + current, state); | │ │ │ │ +| continue; | │ │ │ │ +| } | │ │ │ │ +| else | │ │ │ │ +| { | │ │ │ │ +| erase_candidate = current; | │ │ │ │ +|_ _ _ _ _ _}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_t_r_a_c_k_e_r___m_a_n_a_g_e_r_._c_p_p_:_3_8_9_|_i_m_p_l_e_m_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** iimmpplleemmeenntt ********** | │ │ │ │ +|****** ....//ssrrcc//ttrraacckkeerr__mmaannaaggeerr..ccpppp::338899 ****** | │ │ │ │ +|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ +| if (m_ses.should_log()) | │ │ │ │ +| { | │ │ │ │ +| m_ses.session_log("incoming UDP tracker packet from %s has invalid " | │ │ │ │ +| "transaction ID (%x)", print_endpoint(ep).c_str() | │ │ │ │ +| , transaction); | │ │ │ │ +| } | │ │ │ │ |#endif | │ │ │ │ -| return 0; | │ │ │ │ -| } | │ │ │ │ +| return false; | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -|_ _i_n_t_ _s_e_s_s_i_o_n___i_m_p_l_:_:_g_e_t___l_i_s_t_e_n___p_o_r_t_(_t_r_a_n_s_p_o_r_t_ _c_o_n_s_t_ _s_s_l_,_ _a_u_x_:_:_l_i_s_t_e_n___s_o_c_k_e_t___h_a_n_d_l_e_ _c_o_n_s_t_&_ _s_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_6_4_2_7_ _ _|_t_h_i_s_ _s_h_o_u_l_d_ _b_e_ _f_a_c_t_o_r_e_d_ _i_n_t_o_ _t_h_e_ _u_d_p_ _s_o_c_k_e_t_,_ _s_o_ _w_e_ _o_n_l_y_ _h_a_v_e_ _t_h_e_ _c_o_d_e_ _o_n_c_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tthhiiss sshhoouulldd bbee ffaaccttoorreedd iinnttoo tthhee uuddpp ssoocckkeett,, ssoo wwee oonnllyy hhaavvee tthhee ccooddee oonnccee ********** | │ │ │ │ -|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::66442277 ****** | │ │ │ │ -|return upload_rate_limit(m_local_peer_class); | │ │ │ │ +| std::shared_ptr const p = i->second; | │ │ │ │ +| // on_receive() may remove the tracker connection from the list | │ │ │ │ +| return p->on_receive(ep, buf); | │ │ │ │ | } | │ │ │ │ | | │ │ │ │ -| int session_impl::local_download_rate_limit() const | │ │ │ │ +| void tracker_manager::incoming_error(error_code const& | │ │ │ │ +| , udp::endpoint const&) | │ │ │ │ | { | │ │ │ │ -| return download_rate_limit(m_local_peer_class); | │ │ │ │ -| } | │ │ │ │ +| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ +|} | │ │ │ │ | | │ │ │ │ -| int session_impl::upload_rate_limit_depr() const | │ │ │ │ +| bool tracker_manager::incoming_packet(string_view const hostname | │ │ │ │ +| , span const buf) | │ │ │ │ | { | │ │ │ │ -| return upload_rate_limit(m_global_class); | │ │ │ │ -| } | │ │ │ │ +| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ +| // ignore packets smaller than 8 bytes | │ │ │ │ +| if (buf.size() < 16) return false; | │ │ │ │ | | │ │ │ │ -| int session_impl::download_rate_limit_depr() const | │ │ │ │ -| { | │ │ │ │ -| return download_rate_limit(m_global_class); | │ │ │ │ -| } | │ │ │ │ -|#endif // DEPRECATE | │ │ │ │ +| // the first word is the action, if it's not [0, 3] | │ │ │ │ +| // it's not a valid udp tracker response | │ │ │ │ +| span ptr = buf; | │ │ │ │ +| std::uint32_t const action = aux::read_uint32(ptr); | │ │ │ │ +| if (action > 3) return false; | │ │ │ │ | | │ │ │ │ +| std::uint32_t const transaction = aux::read_uint32(ptr); | │ │ │ │ +| auto const i = m_udp_conns.find(transaction); | │ │ │ │ | | │ │ │ │ -|void session_impl::update_peer_dscp() | │ │ │ │ -|{ | │ │ │ │ -| int const value = m_settings.get_int(settings_pack::peer_dscp); | │ │ │ │ -| for (auto const& l : m_listen_sockets) | │ │ │ │ +| if (i == m_udp_conns.end()) | │ │ │ │ | { | │ │ │ │ -| if (l->sock) | │ │ │ │ -| { | │ │ │ │ -| error_code ec; | │ │ │ │ -| set_traffic_class(*l->sock, value, ec); | │ │ │ │ -| | │ │ │ │ |#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| if (should_log()) | │ │ │ │ -| { | │ │ │ │ -| session_log(">>> SET_DSCP [ tcp (%s %d) value: %x e: %s ]" | │ │ │ │ -| , l->sock->local_endpoint().address().to_string().c_str() | │ │ │ │ -| , l->sock->local_endpoint().port(), std::uint32_t(value), ec.message().c_str()); | │ │ │ │ -| } | │ │ │ │ +| // now, this may not have been meant to be a tracker response, | │ │ │ │ +| // but chances are pretty good, so it's probably worth logging | │ │ │ │ +| m_ses.session_log("incoming UDP tracker packet from %s has invalid " | │ │ │ │ +| "transaction ID (%x)", std::string(hostname).c_str(), transaction); | │ │ │ │ |#endif | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| if (l->udp_sock) | │ │ │ │ -| { | │ │ │ │ -| error_code ec; | │ │ │ │ -| set_traffic_class(l->udp_sock->sock, value, ec); | │ │ │ │ +| return false; | │ │ │ │ +| } | │ │ │ │ | | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| if (should_log()) | │ │ │ │ -| { | │ │ │ │ -| session_log(">>> SET_DSCP [ udp (%s %d) value: %x e: %s ]" | │ │ │ │ -| , l->udp_sock->sock.local_endpoint().address().to_string().c_str() | │ │ │ │ -|_ _ _ _ _ _ _,_ _l_-_>_u_d_p___s_o_c_k_-_>_s_o_c_k_._l_o_c_a_l___p_o_r_t_(_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| std::shared_ptr const p = i->second; | │ │ │ │ +|_ _ _/_/_ _o_n___r_e_c_e_i_v_e_(_)_ _m_a_y_ _r_e_m_o_v_e_ _t_h_e_ _t_r_a_c_k_e_r_ _c_o_n_n_e_c_t_i_o_n_ _f_r_o_m_ _t_h_e_ _l_i_s_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_p_i_e_c_e___p_i_c_k_e_r_._c_p_p_:_2_0_1_3_ _ _|_m_a_k_e_ _t_h_e_ _2_0_4_8_ _l_i_m_i_t_ _c_o_n_f_i_g_u_r_a_b_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** mmaakkee tthhee 22004488 lliimmiitt ccoonnffiigguurraabbllee ********** | │ │ │ │ |****** ....//ssrrcc//ppiieeccee__ppiicckkeerr..ccpppp::22001133 ****** | │ │ │ │ |// indicating which path thought the picker we took to arrive at the | │ │ │ │ | // returned block picks. | │ │ │ │ | picker_flags_t piece_picker::pick_pieces(typed_bitfield const& pieces | │ │ │ │ | , std::vector& interesting_blocks, int num_blocks | │ │ │ │ @@ -3370,457 +3758,68 @@ │ │ │ │ | TORRENT_ASSERT(info.num_peers == 0); | │ │ │ │ | | │ │ │ │ | TORRENT_ASSERT(i->writing > 0); | │ │ │ │ | TORRENT_ASSERT(info.state == block_info::state_writing); | │ │ │ │ | | │ │ │ │ | if (info.state == block_info::state_finished) return; | │ │ │ │ |_ _ _i_f_ _(_i_n_f_o_._s_t_a_t_e_ _=_=_ _b_l_o_c_k___i_n_f_o_:_:_s_t_a_t_e___w_r_i_t_i_n_g_)_ _-_-_i_-_>_w_r_i_t_i_n_g_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 2|_._._/_s_r_c_/_p_e_e_r___l_i_s_t_._c_p_p_:_5_3_5 |it would be nice if there was a way to iterate over these torrent_peer objects in the order they are allocated in the pool instead. | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_I_t_ _w_o_u_l_d_ _p_r_o_b_a_b_l_y_ _b_e_ _m_o_r_e_ _e_f_f_i_c_i_e_n_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** iitt wwoouulldd bbee nniiccee iiff tthheerree wwaass aa wwaayy ttoo iitteerraattee oovveerr tthheessee ttoorrrreenntt__ppeeeerr oobbjjeeccttss iinn tthhee oorrddeerr tthheeyy aarree aallllooccaatteedd iinn tthhee ppooooll iinnsstteeaadd.. IItt wwoouulldd pprroobbaabbllyy bbee mmoorree eeffffiicciieenntt | │ │ │ │ -|********** | │ │ │ │ -|****** ....//ssrrcc//ppeeeerr__lliisstt..ccpppp::553355 ****** | │ │ │ │ -|, int session_time, torrent_state* state) | │ │ │ │ -| { | │ │ │ │ -| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ -| INVARIANT_CHECK; | │ │ │ │ -| | │ │ │ │ -| const int candidate_count = 10; | │ │ │ │ -| peers.reserve(candidate_count); | │ │ │ │ -| | │ │ │ │ -| int erase_candidate = -1; | │ │ │ │ -| | │ │ │ │ -| if (bool(m_finished) != state->is_finished) | │ │ │ │ -| recalculate_connect_candidates(state); | │ │ │ │ -| | │ │ │ │ -| external_ip const& external = state->ip; | │ │ │ │ -| int external_port = state->port; | │ │ │ │ -| | │ │ │ │ -| if (m_round_robin >= int(m_peers.size())) m_round_robin = 0; | │ │ │ │ -| | │ │ │ │ -| int max_peerlist_size = state->max_peerlist_size; | │ │ │ │ -| | │ │ │ │ -|for (int iterations = std::min(int(m_peers.size()), 300); | │ │ │ │ -|iterations > 0; --iterations) | │ │ │ │ -| { | │ │ │ │ -| ++state->loop_counter; | │ │ │ │ -| | │ │ │ │ -| if (m_round_robin >= int(m_peers.size())) m_round_robin = 0; | │ │ │ │ -| | │ │ │ │ -| torrent_peer& pe = *m_peers[m_round_robin]; | │ │ │ │ -| TORRENT_ASSERT(pe.in_use); | │ │ │ │ -| int current = m_round_robin; | │ │ │ │ -| | │ │ │ │ -| // if the number of peers is growing large | │ │ │ │ -| // we need to start weeding. | │ │ │ │ -| | │ │ │ │ -| if (int(m_peers.size()) >= max_peerlist_size * 0.95 | │ │ │ │ -| && max_peerlist_size > 0) | │ │ │ │ -| { | │ │ │ │ -| if (is_erase_candidate(pe) | │ │ │ │ -| && (erase_candidate == -1 | │ │ │ │ -| || !compare_peer_erase(*m_peers[erase_candidate], pe))) | │ │ │ │ -| { | │ │ │ │ -| if (should_erase_immediately(pe)) | │ │ │ │ -| { | │ │ │ │ -| if (erase_candidate > current) --erase_candidate; | │ │ │ │ -| erase_peer(m_peers.begin() + current, state); | │ │ │ │ -| continue; | │ │ │ │ -| } | │ │ │ │ -| else | │ │ │ │ -| { | │ │ │ │ -| erase_candidate = current; | │ │ │ │ -|_ _ _ _ _ _}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 2|_._._/_s_r_c_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_: |this should probably be based on time instead of number of request messages. For a very high throughput connection, 300 may be a | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_2_5_7_1_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_l_e_g_i_t_i_m_a_t_e_ _n_u_m_b_e_r_ _o_f_ _r_e_q_u_e_s_t_s_ _t_o_ _h_a_v_e_ _i_n_ _f_l_i_g_h_t_ _w_h_e_n_ _g_e_t_t_i_n_g_ _c_h_o_k_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tthhiiss sshhoouulldd pprroobbaabbllyy bbee bbaasseedd oonn ttiimmee iinnsstteeaadd ooff nnuummbbeerr ooff rreeqquueesstt mmeessssaaggeess.. FFoorr aa vveerryy hhiigghh tthhrroouugghhppuutt ccoonnnneeccttiioonn,, 330000 mmaayy bbee aa lleeggiittiimmaattee nnuummbbeerr ooff rreeqquueessttss ttoo hhaavvee iinn| │ │ │ │ -|fflliigghhtt wwhheenn ggeettttiinngg cchhookkeedd ********** | │ │ │ │ -|****** ....//ssrrcc//ppeeeerr__ccoonnnneeccttiioonn..ccpppp::22557711 ****** | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_u_p_n_p_._c_p_p_:_1_1_6_ _ _ _ _ _ _ _ _ _ _ _|_u_s_e_ _b_o_o_s_t_:_:_a_s_i_o_:_:_i_p_:_:_n_e_t_w_o_r_k_ _i_n_s_t_e_a_d_ _o_f_ _n_e_t_m_a_s_k_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** uussee bboooosstt::::aassiioo::::iipp::::nneettwwoorrkk iinnsstteeaadd ooff nneettmmaasskk ********** | │ │ │ │ +|****** ....//ssrrcc//uuppnnpp..ccpppp::111166 ****** | │ │ │ │ +||| string_equal_no_case(content_type, "application/soap+xml"_sv); | │ │ │ │ |} | │ │ │ │ -|#endif | │ │ │ │ -| | │ │ │ │ -| write_reject_request(r); | │ │ │ │ -| if (m_num_invalid_requests < std::numeric_limits::max()) | │ │ │ │ -| ++m_num_invalid_requests; | │ │ │ │ -| | │ │ │ │ -| if (t->alerts().should_post()) | │ │ │ │ -| { | │ │ │ │ -| // msvc 12 appears to deduce the rvalue reference template | │ │ │ │ -| // incorrectly for bool temporaries. So, create a dummy instance | │ │ │ │ -| bool const peer_interested = bool(m_peer_interested); | │ │ │ │ -| t->alerts().emplace_alert( | │ │ │ │ -| t->get_handle(), m_remote, m_peer_id, r | │ │ │ │ -| , t->user_have_piece(r.piece), peer_interested, false); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // every ten invalid request, remind the peer that it's choked | │ │ │ │ -| if (!m_peer_interested && m_num_invalid_requests % 10 == 0 && m_choked) | │ │ │ │ -| { | │ │ │ │ -|if (m_num_invalid_requests > 300 && !m_peer_choked | │ │ │ │ -|&& can_disconnect(errors::too_many_requests_when_choked)) | │ │ │ │ -| { | │ │ │ │ -| disconnect(errors::too_many_requests_when_choked, operation_t::bittorrent, peer_error); | │ │ │ │ -| return; | │ │ │ │ -| } | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| peer_log(peer_log_alert::outgoing_message, "CHOKE"); | │ │ │ │ -|#endif | │ │ │ │ -| write_choke(); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| return; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // if we have choked the client | │ │ │ │ -| // ignore the request | │ │ │ │ -| int const blocks_per_piece = | │ │ │ │ -| (ti.piece_length() + t->block_size() - 1) / t->block_size(); | │ │ │ │ -| | │ │ │ │ -| // disconnect peers that downloads more than foo times an allowed | │ │ │ │ -| // fast piece | │ │ │ │ -| if (m_choked && fast_idx != -1 && m_accept_fast_piece_cnt[fast_idx] >= 3 * blocks_per_piece | │ │ │ │ -| && can_disconnect(errors::too_many_requests_when_choked)) | │ │ │ │ -| { | │ │ │ │ -| disconnect(errors::too_many_requests_when_choked, operation_t::bittorrent, peer_error); | │ │ │ │ -| return; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| if (m_choked && fast_idx == -1) | │ │ │ │ -|_ _ _{_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| |_._._/_s_r_c_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_: |since we throw away the queue entry once we issue the disk job, this may happen. Instead, we should keep the queue entry around, | │ │ │ │ -|relevance 2|_3_3_2_3 |mark it as having been requested from disk and once the disk job comes back, discard it if it has been cancelled. Maybe even be able| │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_t_o_ _c_a_n_c_e_l_ _d_i_s_k_ _j_o_b_s_?_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ssiinnccee wwee tthhrrooww aawwaayy tthhee qquueeuuee eennttrryy oonnccee wwee iissssuuee tthhee ddiisskk jjoobb,, tthhiiss mmaayy hhaappppeenn.. IInnsstteeaadd,, wwee sshhoouulldd kkeeeepp tthhee qquueeuuee eennttrryy aarroouunndd,, mmaarrkk iitt aass hhaavviinngg bbeeeenn rreeqquueesstteedd ffrroomm | │ │ │ │ -|ddiisskk aanndd oonnccee tthhee ddiisskk jjoobb ccoommeess bbaacckk,, ddiissccaarrdd iitt iiff iitt hhaass bbeeeenn ccaanncceelllleedd.. MMaayybbee eevveenn bbee aabbllee ttoo ccaanncceell ddiisskk jjoobbss?? ********** | │ │ │ │ -|****** ....//ssrrcc//ppeeeerr__ccoonnnneeccttiioonn..ccpppp::33332233 ****** | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| peer_log(peer_log_alert::incoming_message, "CANCEL" | │ │ │ │ -| , "piece: %d s: %x l: %x", static_cast(r.piece), std::uint32_t(r.start), std::uint32_t(r.length)); | │ │ │ │ -|#endif | │ │ │ │ -| | │ │ │ │ -| auto const i = std::find(m_requests.begin(), m_requests.end(), r); | │ │ │ │ -| | │ │ │ │ -| if (i != m_requests.end()) | │ │ │ │ -| { | │ │ │ │ -| m_counters.inc_stats_counter(counters::cancelled_piece_requests); | │ │ │ │ -| m_requests.erase(i); | │ │ │ │ -| | │ │ │ │ -| if (m_requests.empty()) | │ │ │ │ -| m_counters.inc_stats_counter(counters::num_peers_up_requests, -1); | │ │ │ │ -| | │ │ │ │ -| write_reject_request(r); | │ │ │ │ -| } | │ │ │ │ -| else | │ │ │ │ -| { | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -|peer_log(peer_log_alert::info, "INVALID_CANCEL", "got cancel not in the queue"); | │ │ │ │ -|#endif | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // ----------------------------- | │ │ │ │ -| // --------- DHT PORT ---------- | │ │ │ │ -| // ----------------------------- | │ │ │ │ -| | │ │ │ │ -| void peer_connection::incoming_dht_port(int const listen_port) | │ │ │ │ -| { | │ │ │ │ -| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ -| INVARIANT_CHECK; | │ │ │ │ -| | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| peer_log(peer_log_alert::incoming_message, "DHT_PORT", "p: %d", listen_port); | │ │ │ │ -|#endif | │ │ │ │ -|#ifndef TORRENT_DISABLE_DHT | │ │ │ │ -| m_ses.add_dht_node({m_remote.address(), std::uint16_t(listen_port)}); | │ │ │ │ -|#else | │ │ │ │ -| TORRENT_UNUSED(listen_port); | │ │ │ │ -|#endif | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // ----------------------------- | │ │ │ │ -| // --------- HAVE ALL ---------- | │ │ │ │ -| // ----------------------------- | │ │ │ │ -| | │ │ │ │ -| void peer_connection::incoming_have_all() | │ │ │ │ -|_ _{_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 2|_._._/_s_r_c_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_: |use a deadline_timer for timeouts. Don't rely on second_tick()! Hook this up to connect timeout as well. This would improve | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_9_6_1_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_p_e_r_f_o_r_m_a_n_c_e_ _b_e_c_a_u_s_e_ _o_f_ _l_e_s_s_ _w_o_r_k_ _i_n_ _s_e_c_o_n_d___t_i_c_k_(_)_,_ _a_n_d_ _m_i_g_h_t_ _l_e_t_ _u_s_e_ _r_e_m_o_v_e_ _t_i_c_k_i_n_g_ _e_n_t_i_r_e_l_y_ _e_v_e_n_t_u_a_l_l_y_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** uussee aa ddeeaaddlliinnee__ttiimmeerr ffoorr ttiimmeeoouuttss.. DDoonn''tt rreellyy oonn sseeccoonndd__ttiicckk(())!! HHooookk tthhiiss uupp ttoo ccoonnnneecctt ttiimmeeoouutt aass wweellll.. TThhiiss wwoouulldd iimmpprroovvee ppeerrffoorrmmaannccee bbeeccaauussee ooff lleessss wwoorrkk iinn | │ │ │ │ -|sseeccoonndd__ttiicckk(()),, aanndd mmiigghhtt lleett uussee rreemmoovvee ttiicckkiinngg eennttiirreellyy eevveennttuuaallllyy ********** | │ │ │ │ -|****** ....//ssrrcc//ppeeeerr__ccoonnnneeccttiioonn..ccpppp::44996611 ****** | │ │ │ │ -|if (d > seconds(connect_timeout) | │ │ │ │ -| && can_disconnect(errors::timed_out)) | │ │ │ │ -| { | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| peer_log(peer_log_alert::info, "CONNECT_FAILED", "waited %d seconds" | │ │ │ │ -| , int(total_seconds(d))); | │ │ │ │ -|#endif | │ │ │ │ -| connect_failed(errors::timed_out); | │ │ │ │ -| return; | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // if the bw_network flag isn't set, it means we are not even trying to | │ │ │ │ -| // read from this peer's socket. Most likely because we're applying a | │ │ │ │ -| // rate limit. If the peer is "slow" because we are rate limiting it, | │ │ │ │ -| // don't enforce timeouts. However, as soon as we *do* read from the | │ │ │ │ -| // socket, we expect to receive data, and not have timed out. Then we | │ │ │ │ -| // can enforce the timeouts. | │ │ │ │ -| bool const reading_socket = bool(m_channel_state[download_channel] & peer_info::bw_network); | │ │ │ │ -| | │ │ │ │ -|if (reading_socket && d > seconds(timeout()) && !m_connecting && m_reading_bytes == 0 | │ │ │ │ -|&& can_disconnect(errors::timed_out_inactivity)) | │ │ │ │ -| { | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| peer_log(peer_log_alert::info, "LAST_ACTIVITY", "%d seconds ago" | │ │ │ │ -| , int(total_seconds(d))); | │ │ │ │ -|#endif | │ │ │ │ -| disconnect(errors::timed_out_inactivity, operation_t::bittorrent); | │ │ │ │ -| return; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // do not stall waiting for a handshake | │ │ │ │ -| int timeout = m_settings.get_int (settings_pack::handshake_timeout); | │ │ │ │ -|#if TORRENT_USE_I2P | │ │ │ │ -| timeout *= is_i2p(m_socket) ? 4 : 1; | │ │ │ │ -|#endif | │ │ │ │ -| if (reading_socket | │ │ │ │ -| && !m_connecting | │ │ │ │ -| && in_handshake() | │ │ │ │ -| && d > seconds(timeout)) | │ │ │ │ -| { | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| peer_log(peer_log_alert::info, "NO_HANDSHAKE", "waited %d seconds" | │ │ │ │ -| , int(total_seconds(d))); | │ │ │ │ -|#endif | │ │ │ │ -| disconnect(errors::timed_out_no_handshake, operation_t::bittorrent); | │ │ │ │ -| return; | │ │ │ │ -| } | │ │ │ │ | | │ │ │ │ -| // disconnect peers that we unchoked, but they didn't send a request in | │ │ │ │ -|_ _ _/_/_ _t_h_e_ _l_a_s_t_ _6_0_ _s_e_c_o_n_d_s_,_ _a_n_d_ _w_e_ _h_a_v_e_n_'_t_ _b_e_e_n_ _w_o_r_k_i_n_g_ _o_n_ _s_e_r_v_i_c_i_n_g_ _a_ _r_e_q_u_e_s_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_p_a_t_h_._c_p_p_:_4_3_6_ _ _ _ _ _ _ _ _ _ _ _|_t_e_s_t_ _t_h_i_s_ _o_n_ _a_ _F_A_T_ _v_o_l_u_m_e_ _t_o_ _s_e_e_ _w_h_a_t_ _e_r_r_o_r_ _w_e_ _g_e_t_!_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt tthhiiss oonn aa FFAATT vvoolluummee ttoo sseeee wwhhaatt eerrrroorr wwee ggeett!! ********** | │ │ │ │ -|****** ....//ssrrcc//ppaatthh..ccpppp::443366 ****** | │ │ │ │ -|// it's possible CreateHardLink will copy the file internally too, | │ │ │ │ -| // if the filesystem does not support it. | │ │ │ │ -| ec.assign(GetLastError(), system_category()); | │ │ │ │ -| return; | │ │ │ │ -| } | │ │ │ │ +|upnp::rootdevice::rootdevice() = default; | │ │ │ │ | | │ │ │ │ -| // fall back to making a copy | │ │ │ │ -|#endif | │ │ │ │ +|#if TORRENT_USE_ASSERTS | │ │ │ │ +|upnp::rootdevice::~rootdevice() | │ │ │ │ +|{ | │ │ │ │ +| TORRENT_ASSERT(magic == 1337); | │ │ │ │ +| magic = 0; | │ │ │ │ +|} | │ │ │ │ |#else | │ │ │ │ -| // assume posix's link() function exists | │ │ │ │ -| int ret = ::link(n_exist.c_str(), n_link.c_str()); | │ │ │ │ -| | │ │ │ │ -| if (ret == 0) | │ │ │ │ -| { | │ │ │ │ -| ec.clear(); | │ │ │ │ -| return; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // most errors are passed through, except for the ones that indicate that | │ │ │ │ -| // hard links are not supported and require a copy. | │ │ │ │ -|if (errno != EMLINK | │ │ │ │ -|&& errno != EXDEV | │ │ │ │ -|#ifdef TORRENT_BEOS | │ │ │ │ -| // haiku returns EPERM when the filesystem doesn't support hard link | │ │ │ │ -| && errno != EPERM | │ │ │ │ -|#endif | │ │ │ │ -| ) | │ │ │ │ -| { | │ │ │ │ -| // some error happened, report up to the caller | │ │ │ │ -| ec.assign(errno, system_category()); | │ │ │ │ -| return; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // fall back to making a copy | │ │ │ │ -| | │ │ │ │ +|upnp::rootdevice::~rootdevice() = default; | │ │ │ │ |#endif | │ │ │ │ | | │ │ │ │ -| // if we get here, we should copy the file | │ │ │ │ -| storage_error se; | │ │ │ │ -| aux::copy_file(file, link, se); | │ │ │ │ -| ec = se.ec; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| bool is_directory(std::string const& f, error_code& ec) | │ │ │ │ -| { | │ │ │ │ -| ec.clear(); | │ │ │ │ -| error_code e; | │ │ │ │ -| file_status s; | │ │ │ │ -| stat_file(f, &s, e); | │ │ │ │ -| if (!e && s.mode & file_status::directory) return true; | │ │ │ │ -|_ _ _e_c_ _=_ _e_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 2|_._._/_s_r_c_/ |peer_connection and tracker_connection should probably be flags | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_i_n_s_t_a_n_t_i_a_t_e___c_o_n_n_e_c_t_i_o_n_._c_p_p_:_4_4_ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ppeeeerr__ccoonnnneeccttiioonn aanndd ttrraacckkeerr__ccoonnnneeccttiioonn sshhoouulldd pprroobbaabbllyy bbee ffllaaggss ********** | │ │ │ │ -|****** ....//ssrrcc//iinnssttaannttiiaattee__ccoonnnneeccttiioonn..ccpppp::4444 ****** | │ │ │ │ -|ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | │ │ │ │ -|LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | │ │ │ │ -|CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | │ │ │ │ -|SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | │ │ │ │ -|INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | │ │ │ │ -|CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | │ │ │ │ -|ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | │ │ │ │ -|POSSIBILITY OF SUCH DAMAGE. | │ │ │ │ -| | │ │ │ │ -|*/ | │ │ │ │ -| | │ │ │ │ -|#include "libtorrent/socket.hpp" | │ │ │ │ -|#include "libtorrent/aux_/socket_type.hpp" | │ │ │ │ -|#include "libtorrent/aux_/utp_socket_manager.hpp" | │ │ │ │ -|#include "libtorrent/aux_/instantiate_connection.hpp" | │ │ │ │ -|#include "libtorrent/aux_/utp_stream.hpp" | │ │ │ │ -|#include "libtorrent/ssl_stream.hpp" | │ │ │ │ -| | │ │ │ │ -|namespace libtorrent { namespace aux { | │ │ │ │ -| | │ │ │ │ -|aux::socket_type instantiate_connection(io_context& ios | │ │ │ │ -|, aux::proxy_settings const& ps | │ │ │ │ -| , void* ssl_context | │ │ │ │ -| , utp_socket_manager* sm | │ │ │ │ -| , bool peer_connection | │ │ │ │ -| , bool tracker_connection) | │ │ │ │ -| { | │ │ │ │ -|#if !TORRENT_USE_SSL | │ │ │ │ -| TORRENT_UNUSED(ssl_context); | │ │ │ │ -|#endif | │ │ │ │ +|upnp::rootdevice::rootdevice(rootdevice const&) = default; | │ │ │ │ +|upnp::rootdevice& upnp::rootdevice::operator=(rootdevice const&) & = default; | │ │ │ │ +|upnp::rootdevice::rootdevice(rootdevice&&) noexcept = default; | │ │ │ │ +|upnp::rootdevice& upnp::rootdevice::operator=(rootdevice&&) & = default; | │ │ │ │ | | │ │ │ │ -| if (sm) | │ │ │ │ -| { | │ │ │ │ +|upnp::upnp(io_context& ios | │ │ │ │ +|, aux::session_settings const& settings | │ │ │ │ +| , aux::portmap_callback& cb | │ │ │ │ +| , address_v4 const listen_address | │ │ │ │ +| , address_v4 const netmask | │ │ │ │ +| , std::string listen_device | │ │ │ │ +| , listen_socket_handle ls) | │ │ │ │ +| : m_settings(settings) | │ │ │ │ +| , m_callback(cb) | │ │ │ │ +| , m_io_service(ios) | │ │ │ │ +| , m_resolver(ios) | │ │ │ │ +| , m_multicast(ios) | │ │ │ │ +| , m_unicast(ios) | │ │ │ │ +| , m_broadcast_timer(ios) | │ │ │ │ +| , m_refresh_timer(ios) | │ │ │ │ +| , m_map_timer(ios) | │ │ │ │ +| , m_listen_address(listen_address) | │ │ │ │ +| , m_netmask(netmask) | │ │ │ │ +| , m_device(std::move(listen_device)) | │ │ │ │ |#if TORRENT_USE_SSL | │ │ │ │ -| if (ssl_context) | │ │ │ │ -| { | │ │ │ │ -| ssl_stream s(ios, *static_cast(ssl_context)); | │ │ │ │ -| s.next_layer().set_impl(sm->new_utp_socket(&s.next_layer())); | │ │ │ │ -| return socket_type(std::move(s)); | │ │ │ │ -| } | │ │ │ │ -| else | │ │ │ │ +| , m_ssl_ctx(ssl::context::sslv23_client) | │ │ │ │ |#endif | │ │ │ │ -| { | │ │ │ │ -| utp_stream s(ios); | │ │ │ │ -| s.set_impl(sm->new_utp_socket(&s)); | │ │ │ │ -| return socket_type(std::move(s)); | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ -|#if TORRENT_USE_I2P | │ │ │ │ -| else if (ps.type == settings_pack::i2p_proxy) | │ │ │ │ -|_ _ _{_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -| |_._._/_s_r_c_/ | | │ │ │ │ -|relevance 2|_h_t_t_p___t_r_a_c_k_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_: |returning a bool here is redundant. Instead this function should return the peer_entry | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_8_6_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** rreettuurrnniinngg aa bbooooll hheerree iiss rreedduunnddaanntt.. IInnsstteeaadd tthhiiss ffuunnccttiioonn sshhoouulldd rreettuurrnn tthhee ppeeeerr__eennttrryy ********** | │ │ │ │ -|****** ....//ssrrcc//hhttttpp__ttrraacckkeerr__ccoonnnneeccttiioonn..ccpppp::448866 ****** | │ │ │ │ -|{ | │ │ │ │ -| cb->tracker_scrape_response(tracker_req(), resp.complete | │ │ │ │ -| , resp.incomplete, resp.downloaded, resp.downloaders); | │ │ │ │ -| } | │ │ │ │ -| else | │ │ │ │ -| { | │ │ │ │ -| std::list
    ip_list; | │ │ │ │ -| if (m_tracker_connection) | │ │ │ │ -| { | │ │ │ │ -| for (auto const& endp : m_tracker_connection->endpoints()) | │ │ │ │ -| { | │ │ │ │ -| ip_list.push_back(endp.address()); | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| cb->tracker_response(tracker_req(), m_tracker_ip, ip_list, resp); | │ │ │ │ -| } | │ │ │ │ -| close(); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -|bool extract_peer_info(bdecode_node const& info, peer_entry& ret, error_code& ec) | │ │ │ │ -|{ | │ │ │ │ -| // extract peer id (if any) | │ │ │ │ -| if (info.type() != bdecode_node::dict_t) | │ │ │ │ -| { | │ │ │ │ -| ec = errors::invalid_peer_dict; | │ │ │ │ -| return false; | │ │ │ │ -| } | │ │ │ │ -| bdecode_node i = info.dict_find_string("peer id"); | │ │ │ │ -| if (i && i.string_length() == 20) | │ │ │ │ -| { | │ │ │ │ -| std::copy(i.string_ptr(), i.string_ptr() + 20, ret.pid.begin()); | │ │ │ │ -| } | │ │ │ │ -| else | │ │ │ │ -| { | │ │ │ │ -| // if there's no peer_id, just initialize it to a bunch of zeroes | │ │ │ │ -| ret.pid.clear(); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // extract ip | │ │ │ │ -| i = info.dict_find_string("ip"); | │ │ │ │ -| if (!i) | │ │ │ │ -| { | │ │ │ │ -| ec = errors::invalid_tracker_response; | │ │ │ │ -| return false; | │ │ │ │ -| } | │ │ │ │ -| ret.hostname = i.string_value().to_string(); | │ │ │ │ -| | │ │ │ │ -| // extract port | │ │ │ │ -| i = info.dict_find_int("port"); | │ │ │ │ -|_ _ _i_f_ _(_!_i_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_e_s_c_a_p_e___s_t_r_i_n_g_._c_p_p_:_1_9_3_ _ _|_t_h_i_s_ _s_h_o_u_l_d_ _p_r_o_b_a_b_l_y_ _b_e_ _m_o_v_e_d_ _i_n_t_o_ _s_t_r_i_n_g___u_t_i_l_._c_p_p_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tthhiiss sshhoouulldd pprroobbaabbllyy bbee mmoovveedd iinnttoo ssttrriinngg__uuttiill..ccpppp ********** | │ │ │ │ -|****** ....//ssrrcc//eessccaappee__ssttrriinngg..ccpppp::119933 ****** | │ │ │ │ -|{ | │ │ │ │ -| return escape_string_impl(str.data(), int(str.size()), 10); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| bool need_encoding(char const* str, int const len) | │ │ │ │ -| { | │ │ │ │ -| for (int i = 0; i < len; ++i) | │ │ │ │ -| { | │ │ │ │ -| if (std::strchr(unreserved_chars, *str) == nullptr || *str == 0) | │ │ │ │ -| return true; | │ │ │ │ -| ++str; | │ │ │ │ -| } | │ │ │ │ -| return false; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| void convert_path_to_posix(std::string& path) | │ │ │ │ -| { | │ │ │ │ -| std::replace(path.begin(), path.end(), '\\', '/'); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -|std::string read_until(char const*& str, char const delim, char const* end) | │ │ │ │ +| , m_listen_handle(std::move(ls)) | │ │ │ │ |{ | │ │ │ │ -| TORRENT_ASSERT(str <= end); | │ │ │ │ -| | │ │ │ │ -| std::string ret; | │ │ │ │ -| while (str != end && *str != delim) | │ │ │ │ -| { | │ │ │ │ -| ret += *str; | │ │ │ │ -| ++str; | │ │ │ │ -| } | │ │ │ │ -| // skip the delimiter as well | │ │ │ │ -| while (str != end && *str == delim) ++str; | │ │ │ │ -| return ret; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| std::string maybe_url_encode(std::string const& url) | │ │ │ │ -| { | │ │ │ │ -| std::string protocol, host, auth, path; | │ │ │ │ -| int port; | │ │ │ │ -| error_code ec; | │ │ │ │ -| std::tie(protocol, auth, host, port, path) = parse_url_components(url, ec); | │ │ │ │ -| if (ec) return url; | │ │ │ │ -| | │ │ │ │ -| // first figure out if this url contains unencoded characters | │ │ │ │ -| if (!need_encoding(path.c_str(), int(path.size()))) | │ │ │ │ -| return url; | │ │ │ │ +|#if TORRENT_USE_SSL | │ │ │ │ +| m_ssl_ctx.set_verify_mode(ssl::context::verify_none); | │ │ │ │ +|#endif | │ │ │ │ +|} | │ │ │ │ | | │ │ │ │ -| std::string msg; | │ │ │ │ -| std::string escaped_path { escape_path(path) }; | │ │ │ │ -| // reserve enough space so further append will | │ │ │ │ -|_ _ _/_/_ _o_n_l_y_ _c_o_p_y_ _v_a_l_u_e_s_ _t_o_ _e_x_i_s_t_i_n_g_ _l_o_c_a_t_i_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|void upnp::start() | │ │ │ │ +|_{_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_b_d_e_c_o_d_e_._c_p_p_:_8_2_7_ _ _ _ _ _ _ _ _|_a_t_t_e_m_p_t_ _t_o_ _s_i_m_p_l_i_f_y_ _t_h_i_s_ _i_m_p_l_e_m_e_n_t_a_t_i_o_n_ _b_y_ _e_m_b_r_a_c_i_n_g_ _t_h_e_ _s_p_a_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** aatttteemmpptt ttoo ssiimmpplliiffyy tthhiiss iimmpplleemmeennttaattiioonn bbyy eemmbbrraacciinngg tthhee ssppaann ********** | │ │ │ │ |****** ....//ssrrcc//bbddeeccooddee..ccpppp::882277 ****** | │ │ │ │ |} | │ │ │ │ | | │ │ │ │ | bdecode_node bdecode(span buffer | │ │ │ │ | , error_code& ec, int* error_pos, int depth_limit, int token_limit) | │ │ │ │ @@ -3867,68 +3866,69 @@ │ │ │ │ | // every other node is a string. | │ │ │ │ | if (current_frame > 0 | │ │ │ │ | && ret.m_tokens[stack[current_frame - 1].token].type == bdecode_token::dict) | │ │ │ │ | { | │ │ │ │ | if (stack[current_frame - 1].state == 0) | │ │ │ │ | { | │ │ │ │ |_ _ _ _ _ _/_/_ _t_h_e_ _c_u_r_r_e_n_t_ _p_a_r_e_n_t_ _i_s_ _a_ _d_i_c_t_ _a_n_d_ _w_e_ _a_r_e_ _p_a_r_s_i_n_g_ _a_ _k_e_y_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_a_l_e_r_t___m_a_n_a_g_e_r_._c_p_p_:_7_6_ _ _ _|_k_e_e_p_ _a_ _c_o_u_n_t_ _o_f_ _t_h_e_ _n_u_m_b_e_r_ _o_f_ _t_h_r_e_a_d_s_ _w_a_i_t_i_n_g_._ _O_n_l_y_ _i_f_ _i_t_'_s_ _>_ _0_ _n_o_t_i_f_y_ _t_h_e_m_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** kkeeeepp aa ccoouunntt ooff tthhee nnuummbbeerr ooff tthhrreeaaddss wwaaiittiinngg.. OOnnllyy iiff iitt''ss >> 00 nnoottiiffyy tthheemm ********** | │ │ │ │ -|****** ....//ssrrcc//aalleerrtt__mmaannaaggeerr..ccpppp::7766 ****** | │ │ │ │ -|{ | │ │ │ │ -| std::unique_lock lock(m_mutex); | │ │ │ │ +|relevance 2|_._._/_s_r_c_/ |support authentication here. tracker_req().auth | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_u_d_p___t_r_a_c_k_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_:_8_1_ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** ssuuppppoorrtt aauutthheennttiiccaattiioonn hheerree.. ttrraacckkeerr__rreeqq(())..aauutthh ********** | │ │ │ │ +|****** ....//ssrrcc//uuddpp__ttrraacckkeerr__ccoonnnneeccttiioonn..ccpppp::8811 ****** | │ │ │ │ +|udp_tracker_connection::m_connection_cache; | │ │ │ │ | | │ │ │ │ -| if (!m_alerts[m_generation & 1].empty()) return true; | │ │ │ │ +| std::mutex udp_tracker_connection::m_cache_mutex; | │ │ │ │ | | │ │ │ │ -| // this call can be interrupted prematurely by other signals | │ │ │ │ -| m_condition.wait_for(lock, max_wait); | │ │ │ │ -| return !m_alerts[m_generation & 1].empty(); | │ │ │ │ +| udp_tracker_connection::udp_tracker_connection( | │ │ │ │ +| io_context& ios | │ │ │ │ +| , tracker_manager& man | │ │ │ │ +| , tracker_request const& req | │ │ │ │ +| , std::weak_ptr c) | │ │ │ │ +| : tracker_connection(man, req, ios, std::move(c)) | │ │ │ │ +| , m_transaction_id(0) | │ │ │ │ +| , m_attempts(0) | │ │ │ │ +| , m_state(action_t::error) | │ │ │ │ +| , m_abort(false) | │ │ │ │ +| { | │ │ │ │ +| update_transaction_id(); | │ │ │ │ | } | │ │ │ │ | | │ │ │ │ -| void alert_manager::maybe_notify(alert* a) | │ │ │ │ +| void udp_tracker_connection::start() | │ │ │ │ | { | │ │ │ │ -| if (m_alerts[m_generation & 1].size() == 1) | │ │ │ │ -| { | │ │ │ │ -| // we just posted to an empty queue. If anyone is waiting for | │ │ │ │ -| // alerts, we need to notify them. Also (potentially) call the | │ │ │ │ -| // user supplied m_notify callback to let the client wake up its | │ │ │ │ -| // message loop to poll for alerts. | │ │ │ │ -| if (m_notify) m_notify(); | │ │ │ │ -| | │ │ │ │ -|m_condition.notify_all(); | │ │ │ │ -|} | │ │ │ │ +|std::string hostname; | │ │ │ │ +|std::string protocol; | │ │ │ │ +| int port; | │ │ │ │ +| error_code ec; | │ │ │ │ | | │ │ │ │ -|#ifndef TORRENT_DISABLE_EXTENSIONS | │ │ │ │ -| for (auto& e : m_ses_extensions) | │ │ │ │ -| e->on_alert(a); | │ │ │ │ -|#else | │ │ │ │ -| TORRENT_UNUSED(a); | │ │ │ │ -|#endif | │ │ │ │ -| } | │ │ │ │ +| std::tie(protocol, std::ignore, hostname, port, std::ignore) | │ │ │ │ +| = parse_url_components(tracker_req().url, ec); | │ │ │ │ +| if (port == -1) port = protocol == "http" ? 80 : 443; | │ │ │ │ | | │ │ │ │ -| void alert_manager::set_notify_function(std::function const& fun) | │ │ │ │ -| { | │ │ │ │ -| std::unique_lock lock(m_mutex); | │ │ │ │ -| m_notify = fun; | │ │ │ │ -| if (!m_alerts[m_generation & 1].empty()) | │ │ │ │ +| if (ec) | │ │ │ │ | { | │ │ │ │ -| if (m_notify) m_notify(); | │ │ │ │ +| tracker_connection::fail(ec, operation_t::parse_address); | │ │ │ │ +| return; | │ │ │ │ | } | │ │ │ │ -| } | │ │ │ │ | | │ │ │ │ -|#ifndef TORRENT_DISABLE_EXTENSIONS | │ │ │ │ -| void alert_manager::add_extension(std::shared_ptr ext) | │ │ │ │ -| { | │ │ │ │ -| m_ses_extensions.push_back(std::move(ext)); | │ │ │ │ -| } | │ │ │ │ -|#endif | │ │ │ │ +| aux::session_settings const& settings = m_man.settings(); | │ │ │ │ | | │ │ │ │ -| void alert_manager::get_all(std::vector& alerts) | │ │ │ │ -| { | │ │ │ │ -|_ _ _s_t_d_:_:_l_o_c_k___g_u_a_r_d_<_s_t_d_:_:_r_e_c_u_r_s_i_v_e___m_u_t_e_x_>_ _l_o_c_k_(_m___m_u_t_e_x_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +| int const proxy_type = settings.get_int(settings_pack::proxy_type); | │ │ │ │ +| | │ │ │ │ +| if (settings.get_bool(settings_pack::proxy_hostnames) | │ │ │ │ +| && (proxy_type == settings_pack::socks5 | │ │ │ │ +| || proxy_type == settings_pack::socks5_pw)) | │ │ │ │ +| { | │ │ │ │ +| m_hostname = hostname; | │ │ │ │ +| m_target.port(std::uint16_t(port)); | │ │ │ │ +| start_announce(); | │ │ │ │ +| } | │ │ │ │ +| else | │ │ │ │ +| { | │ │ │ │ +| using namespace std::placeholders; | │ │ │ │ +|_ _ _ _A_D_D___O_U_T_S_T_A_N_D_I_N_G___A_S_Y_N_C_(_"_u_d_p___t_r_a_c_k_e_r___c_o_n_n_e_c_t_i_o_n_:_:_n_a_m_e___l_o_o_k_u_p_"_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |_r_e_l_e_v_a_n_c_e_ _2_|_._._/_s_r_c_/_a_l_e_r_t_._c_p_p_:_2_0_0_4_ _ _ _ _ _ _ _ _ _|_t_h_e_ _s_a_l_t_ _h_e_r_e_ _i_s_ _a_l_l_o_c_a_t_e_d_ _o_n_ _t_h_e_ _h_e_a_p_._ _I_t_ _w_o_u_l_d_ _b_e_ _n_i_c_e_ _t_o_ _a_l_l_o_c_a_t_e_ _i_n_ _t_h_e_ _s_t_a_c_k___a_l_l_o_c_a_t_o_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** tthhee ssaalltt hheerree iiss aallllooccaatteedd oonn tthhee hheeaapp.. IItt wwoouulldd bbee nniiccee ttoo aallllooccaattee iinn tthhee ssttaacckk__aallllooccaattoorr ********** | │ │ │ │ |****** ....//ssrrcc//aalleerrtt..ccpppp::22000044 ****** | │ │ │ │ |} | │ │ │ │ | | │ │ │ │ | dht_immutable_item_alert::dht_immutable_item_alert(aux::stack_allocator& | │ │ │ │ | , sha1_hash const& t, entry i) | │ │ │ │ @@ -3975,14 +3975,69 @@ │ │ │ │ | } | │ │ │ │ | | │ │ │ │ | dht_put_alert::dht_put_alert(aux::stack_allocator&, sha1_hash const& t, int n) | │ │ │ │ | : target(t) | │ │ │ │ | , public_key() | │ │ │ │ | , signature() | │ │ │ │ |_ _ _,_ _s_a_l_t_(_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 2|_._._/_s_r_c_/_k_a_d_e_m_l_i_a_/ |make this configurable in dht_settings | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_d_h_t___s_t_o_r_a_g_e_._c_p_p_:_8_7_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** mmaakkee tthhiiss ccoonnffiigguurraabbllee iinn ddhhtt__sseettttiinnggss ********** | │ │ │ │ +|****** ....//ssrrcc//kkaaddeemmlliiaa//ddhhtt__ssttoorraaggee..ccpppp::8877 ****** | │ │ │ │ +|tcp::endpoint addr; | │ │ │ │ +| bool seed = 0; | │ │ │ │ +| }; | │ │ │ │ +| | │ │ │ │ +| // internal | │ │ │ │ +| bool operator<(peer_entry const& lhs, peer_entry const& rhs) | │ │ │ │ +| { | │ │ │ │ +| return lhs.addr.address() == rhs.addr.address() | │ │ │ │ +| ? lhs.addr.port() < rhs.addr.port() | │ │ │ │ +| : lhs.addr.address() < rhs.addr.address(); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| // this is a group. It contains a set of group members | │ │ │ │ +| struct torrent_entry | │ │ │ │ +| { | │ │ │ │ +| std::string name; | │ │ │ │ +| std::vector peers4; | │ │ │ │ +| std::vector peers6; | │ │ │ │ +| }; | │ │ │ │ +| | │ │ │ │ +|constexpr time_duration announce_interval = minutes(30); | │ │ │ │ +| | │ │ │ │ +| struct dht_immutable_item | │ │ │ │ +| { | │ │ │ │ +| // the actual value | │ │ │ │ +| std::unique_ptr value; | │ │ │ │ +| // this counts the number of IPs we have seen | │ │ │ │ +| // announcing this item, this is used to determine | │ │ │ │ +| // popularity if we reach the limit of items to store | │ │ │ │ +| bloom_filter<128> ips; | │ │ │ │ +| // the last time we heard about this item | │ │ │ │ +| // the correct interpretation of this field | │ │ │ │ +| // requires a time reference | │ │ │ │ +| time_point last_seen; | │ │ │ │ +| // number of IPs in the bloom filter | │ │ │ │ +| int num_announcers = 0; | │ │ │ │ +| // size of malloced space pointed to by value | │ │ │ │ +| int size = 0; | │ │ │ │ +| }; | │ │ │ │ +| | │ │ │ │ +| struct dht_mutable_item : dht_immutable_item | │ │ │ │ +| { | │ │ │ │ +| signature sig{}; | │ │ │ │ +| sequence_number seq{}; | │ │ │ │ +| public_key key{}; | │ │ │ │ +| std::string salt; | │ │ │ │ +| }; | │ │ │ │ +| | │ │ │ │ +| void set_value(dht_immutable_item& item, span buf) | │ │ │ │ +| { | │ │ │ │ +|_ _ _i_n_t_ _c_o_n_s_t_ _s_i_z_e_ _=_ _i_n_t_(_b_u_f_._s_i_z_e_(_)_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |relevance 2|_._._/_s_r_c_/_k_a_d_e_m_l_i_a_/ |use the non deprecated function instead of this one | │ │ │ │ |_ _ _ _ _ _ _ _ _ _ _ _|_r_o_u_t_i_n_g___t_a_b_l_e_._c_p_p_:_3_0_5_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** uussee tthhee nnoonn ddeepprreeccaatteedd ffuunnccttiioonn iinnsstteeaadd ooff tthhiiss oonnee ********** | │ │ │ │ |****** ....//ssrrcc//kkaaddeemmlliiaa//rroouuttiinngg__ttaabbllee..ccpppp::330055 ****** | │ │ │ │ |static const aux::array size_exceptions{{{16, 8, 4, 2}}}; | │ │ │ │ | if (bucket < size_exceptions.end_index()) | │ │ │ │ | return m_bucket_size * size_exceptions[bucket]; | │ │ │ │ @@ -4170,124 +4225,14 @@ │ │ │ │ |entry write_nodes_entry(std::vector const& nodes) | │ │ │ │ |{ | │ │ │ │ | entry r; | │ │ │ │ | std::back_insert_iterator out(r.string()); | │ │ │ │ | for (auto const& n : nodes) | │ │ │ │ | { | │ │ │ │ |_ _ _s_t_d_:_:_c_o_p_y_(_n_._i_d_._b_e_g_i_n_(_)_,_ _n_._i_d_._e_n_d_(_)_,_ _o_u_t_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 2|_._._/_s_r_c_/_k_a_d_e_m_l_i_a_/ |make this configurable in dht_settings | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_d_h_t___s_t_o_r_a_g_e_._c_p_p_:_8_7_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** mmaakkee tthhiiss ccoonnffiigguurraabbllee iinn ddhhtt__sseettttiinnggss ********** | │ │ │ │ -|****** ....//ssrrcc//kkaaddeemmlliiaa//ddhhtt__ssttoorraaggee..ccpppp::8877 ****** | │ │ │ │ -|tcp::endpoint addr; | │ │ │ │ -| bool seed = 0; | │ │ │ │ -| }; | │ │ │ │ -| | │ │ │ │ -| // internal | │ │ │ │ -| bool operator<(peer_entry const& lhs, peer_entry const& rhs) | │ │ │ │ -| { | │ │ │ │ -| return lhs.addr.address() == rhs.addr.address() | │ │ │ │ -| ? lhs.addr.port() < rhs.addr.port() | │ │ │ │ -| : lhs.addr.address() < rhs.addr.address(); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // this is a group. It contains a set of group members | │ │ │ │ -| struct torrent_entry | │ │ │ │ -| { | │ │ │ │ -| std::string name; | │ │ │ │ -| std::vector peers4; | │ │ │ │ -| std::vector peers6; | │ │ │ │ -| }; | │ │ │ │ -| | │ │ │ │ -|constexpr time_duration announce_interval = minutes(30); | │ │ │ │ -| | │ │ │ │ -| struct dht_immutable_item | │ │ │ │ -| { | │ │ │ │ -| // the actual value | │ │ │ │ -| std::unique_ptr value; | │ │ │ │ -| // this counts the number of IPs we have seen | │ │ │ │ -| // announcing this item, this is used to determine | │ │ │ │ -| // popularity if we reach the limit of items to store | │ │ │ │ -| bloom_filter<128> ips; | │ │ │ │ -| // the last time we heard about this item | │ │ │ │ -| // the correct interpretation of this field | │ │ │ │ -| // requires a time reference | │ │ │ │ -| time_point last_seen; | │ │ │ │ -| // number of IPs in the bloom filter | │ │ │ │ -| int num_announcers = 0; | │ │ │ │ -| // size of malloced space pointed to by value | │ │ │ │ -| int size = 0; | │ │ │ │ -| }; | │ │ │ │ -| | │ │ │ │ -| struct dht_mutable_item : dht_immutable_item | │ │ │ │ -| { | │ │ │ │ -| signature sig{}; | │ │ │ │ -| sequence_number seq{}; | │ │ │ │ -| public_key key{}; | │ │ │ │ -| std::string salt; | │ │ │ │ -| }; | │ │ │ │ -| | │ │ │ │ -| void set_value(dht_immutable_item& item, span buf) | │ │ │ │ -| { | │ │ │ │ -|_ _ _i_n_t_ _c_o_n_s_t_ _s_i_z_e_ _=_ _i_n_t_(_b_u_f_._s_i_z_e_(_)_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 2|_._._/_i_n_c_l_u_d_e_/_l_i_b_t_o_r_r_e_n_t_/ |add async_connect() that takes a hostname and port as well | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_s_o_c_k_s_5___s_t_r_e_a_m_._h_p_p_:_1_5_5_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** aadddd aassyynncc__ccoonnnneecctt(()) tthhaatt ttaakkeess aa hhoossttnnaammee aanndd ppoorrtt aass wweellll ********** | │ │ │ │ -|****** ....//iinncclluuddee//lliibbttoorrrreenntt//ssoocckkss55__ssttrreeaamm..hhpppp::115555 ****** | │ │ │ │ -|TORRENT_ASSERT(!aux::is_ip_address(host)); | │ │ │ │ -| m_dst_name = host; | │ │ │ │ -| if (m_dst_name.size() > 255) | │ │ │ │ -| m_dst_name.resize(255); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| void close(error_code& ec) | │ │ │ │ -| { | │ │ │ │ -| m_dst_name.clear(); | │ │ │ │ -| proxy_base::close(ec); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -|#ifndef BOOST_NO_EXCEPTIONS | │ │ │ │ -| void close() | │ │ │ │ -| { | │ │ │ │ -| m_dst_name.clear(); | │ │ │ │ -| proxy_base::close(); | │ │ │ │ -| } | │ │ │ │ -|#endif | │ │ │ │ -| | │ │ │ │ -|template | │ │ │ │ -|void async_connect(endpoint_type const& endpoint, Handler handler) | │ │ │ │ -| { | │ │ │ │ -| // make sure we don't try to connect to INADDR_ANY. binding is fine, | │ │ │ │ -| // and using a hostname is fine on SOCKS version 5. | │ │ │ │ -| TORRENT_ASSERT(endpoint.address() != address() | │ │ │ │ -| || (!m_dst_name.empty() && m_version == 5)); | │ │ │ │ -| | │ │ │ │ -| m_remote_endpoint = endpoint; | │ │ │ │ -| | │ │ │ │ -| // the connect is split up in the following steps: | │ │ │ │ -| // 1. resolve name of proxy server | │ │ │ │ -| // 2. connect to proxy server | │ │ │ │ -| // 3. if version == 5: | │ │ │ │ -| // 3.1 send SOCKS5 authentication method message | │ │ │ │ -| // 3.2 read SOCKS5 authentication response | │ │ │ │ -| // 3.3 send username+password | │ │ │ │ -| // 4. send SOCKS command message | │ │ │ │ -| | │ │ │ │ -| ADD_OUTSTANDING_ASYNC("socks5_stream::name_lookup"); | │ │ │ │ -| m_resolver.async_resolve(m_hostname, to_string(m_port).data(), wrap_allocator( | │ │ │ │ -| [this](error_code const& ec, tcp::resolver::results_type ips, Handler hn) { | │ │ │ │ -| name_lookup(ec, std::move(ips), std::move(hn)); | │ │ │ │ -| }, std::move(handler))); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -|private: | │ │ │ │ -| | │ │ │ │ -| template | │ │ │ │ -| void name_lookup(error_code const& e, tcp::resolver::results_type ips | │ │ │ │ -|_ _ _,_ _H_a_n_d_l_e_r_ _h_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |relevance 2|_._._/_i_n_c_l_u_d_e_/_l_i_b_t_o_r_r_e_n_t_/ |use the resolver interface that has a built-in cache | │ │ │ │ |_ _ _ _ _ _ _ _ _ _ _ _|_p_r_o_x_y___b_a_s_e_._h_p_p_:_3_2_8_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** uussee tthhee rreessoollvveerr iinntteerrffaaccee tthhaatt hhaass aa bbuuiilltt--iinn ccaacchhee ********** | │ │ │ │ |****** ....//iinncclluuddee//lliibbttoorrrreenntt//pprrooxxyy__bbaassee..hhpppp::332288 ****** | │ │ │ │ |// The handler must be taken as lvalue reference here since we may not call | │ │ │ │ | // it. But if we do, we want the call operator to own the function object. | │ │ │ │ | template | │ │ │ │ @@ -4335,69 +4280,14 @@ │ │ │ │ | using allocator_type = typename boost::asio::associated_allocator::type; | │ │ │ │ | using executor_type = typename boost::asio::associated_executor::type; | │ │ │ │ | | │ │ │ │ | allocator_type get_allocator() const noexcept | │ │ │ │ | { return boost::asio::get_associated_allocator(m_underlying_handler); } | │ │ │ │ | | │ │ │ │ |_ _e_x_e_c_u_t_o_r___t_y_p_e_ _g_e_t___e_x_e_c_u_t_o_r_(_)_ _c_o_n_s_t_ _n_o_e_x_c_e_p_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 2|_._._/_i_n_c_l_u_d_e_/_l_i_b_t_o_r_r_e_n_t_/ |having 8 priority levels is probably excessive. It should probably be changed to 3 levels + dont-download | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_p_i_e_c_e___p_i_c_k_e_r_._h_p_p_:_6_6_8_ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** hhaavviinngg 88 pprriioorriittyy lleevveellss iiss pprroobbaabbllyy eexxcceessssiivvee.. IItt sshhoouulldd pprroobbaabbllyy bbee cchhaannggeedd ttoo 33 lleevveellss ++ ddoonntt--ddoowwnnllooaadd ********** | │ │ │ │ -|****** ....//iinncclluuddee//lliibbttoorrrreenntt//ppiieeccee__ppiicckkeerr..hhpppp::666688 ****** | │ │ │ │ -|else if (state() == piece_full) | │ │ │ │ -| state(piece_full_reverse); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // the number of peers that has this piece | │ │ │ │ -| // (availability) | │ │ │ │ -| std::uint32_t peer_count : 26; | │ │ │ │ -| | │ │ │ │ -| // one of the download_queue_t values. This indicates whether this piece | │ │ │ │ -| // is currently being downloaded or not, and what state it's in if | │ │ │ │ -| // it is. Specifically, as an optimization, pieces that have all blocks | │ │ │ │ -| // requested from them are separated out into separate lists to make | │ │ │ │ -| // lookups quicker. The main oddity is that whether a downloading piece | │ │ │ │ -| // has only been requested from peers that are reverse, that's | │ │ │ │ -| // recorded as piece_downloading_reverse, which really means the same | │ │ │ │ -| // as piece_downloading, it just saves space to also indicate that it | │ │ │ │ -| // has a bit lower priority. The reverse bit is only relevant if the | │ │ │ │ -| // state is piece_downloading. | │ │ │ │ -| std::uint32_t download_state : 3; | │ │ │ │ -| | │ │ │ │ -| | │ │ │ │ -|// is 0 if the piece is filtered (not to be downloaded) | │ │ │ │ -| // 1 is low priority | │ │ │ │ -| // 2 is low priority | │ │ │ │ -| // 3 is mid priority | │ │ │ │ -| // 4 is default priority | │ │ │ │ -| // 5 is mid priority | │ │ │ │ -| // 6 is high priority | │ │ │ │ -| // 7 is high priority | │ │ │ │ -| std::uint32_t piece_priority : 3; | │ │ │ │ -| | │ │ │ │ -| // index in to the piece_info vector | │ │ │ │ -| prio_index_t index; | │ │ │ │ -| | │ │ │ │ -|#ifdef TORRENT_DEBUG_REFCOUNTS | │ │ │ │ -| // all the peers that have this piece | │ │ │ │ -| std::set have_peers; | │ │ │ │ -|#endif | │ │ │ │ -| | │ │ │ │ -| // index is set to this to indicate that we have the | │ │ │ │ -| // piece. There is no entry for the piece in the | │ │ │ │ -| // buckets if this is the case. | │ │ │ │ -| static constexpr prio_index_t we_have_index{-1}; | │ │ │ │ -| | │ │ │ │ -| // the priority value that means the piece is filtered | │ │ │ │ -| static constexpr std::uint32_t filter_priority = 0; | │ │ │ │ -| | │ │ │ │ -| // the max number the peer count can hold | │ │ │ │ -| static constexpr std::uint32_t max_peer_count = 0xffff; | │ │ │ │ -| | │ │ │ │ -|_ _ _ _b_o_o_l_ _h_a_v_e_(_)_ _c_o_n_s_t_ _{_ _r_e_t_u_r_n_ _i_n_d_e_x_ _=_=_ _w_e___h_a_v_e___i_n_d_e_x_;_ _}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |relevance 2|_._._/_i_n_c_l_u_d_e_/_l_i_b_t_o_r_r_e_n_t_/ |this should really be a circular buffer | │ │ │ │ |_ _ _ _ _ _ _ _ _ _ _ _|_p_e_e_r___c_o_n_n_e_c_t_i_o_n_._h_p_p_:_9_9_6_ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** tthhiiss sshhoouulldd rreeaallllyy bbee aa cciirrccuullaarr bbuuffffeerr ********** | │ │ │ │ |****** ....//iinncclluuddee//lliibbttoorrrreenntt//ppeeeerr__ccoonnnneeccttiioonn..hhpppp::999966 ****** | │ │ │ │ |// it just serves as a queue to remember what we've sent, to avoid | │ │ │ │ | // re-sending suggests for the same piece | │ │ │ │ | // i.e. outgoing suggest pieces | │ │ │ │ @@ -4497,14 +4387,124 @@ │ │ │ │ | // and false if we got an incoming connection | │ │ │ │ | // could be considered: true = local, false = remote | │ │ │ │ | bool m_outgoing:1; | │ │ │ │ | | │ │ │ │ | // is true if we learn the incoming connections listening | │ │ │ │ | // during the extended handshake | │ │ │ │ |_ _ _b_o_o_l_ _m___r_e_c_e_i_v_e_d___l_i_s_t_e_n___p_o_r_t_:_1_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 2|_._._/_i_n_c_l_u_d_e_/_l_i_b_t_o_r_r_e_n_t_/ |add async_connect() that takes a hostname and port as well | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_s_o_c_k_s_5___s_t_r_e_a_m_._h_p_p_:_1_5_5_ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** aadddd aassyynncc__ccoonnnneecctt(()) tthhaatt ttaakkeess aa hhoossttnnaammee aanndd ppoorrtt aass wweellll ********** | │ │ │ │ +|****** ....//iinncclluuddee//lliibbttoorrrreenntt//ssoocckkss55__ssttrreeaamm..hhpppp::115555 ****** | │ │ │ │ +|TORRENT_ASSERT(!aux::is_ip_address(host)); | │ │ │ │ +| m_dst_name = host; | │ │ │ │ +| if (m_dst_name.size() > 255) | │ │ │ │ +| m_dst_name.resize(255); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| void close(error_code& ec) | │ │ │ │ +| { | │ │ │ │ +| m_dst_name.clear(); | │ │ │ │ +| proxy_base::close(ec); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +|#ifndef BOOST_NO_EXCEPTIONS | │ │ │ │ +| void close() | │ │ │ │ +| { | │ │ │ │ +| m_dst_name.clear(); | │ │ │ │ +| proxy_base::close(); | │ │ │ │ +| } | │ │ │ │ +|#endif | │ │ │ │ +| | │ │ │ │ +|template | │ │ │ │ +|void async_connect(endpoint_type const& endpoint, Handler handler) | │ │ │ │ +| { | │ │ │ │ +| // make sure we don't try to connect to INADDR_ANY. binding is fine, | │ │ │ │ +| // and using a hostname is fine on SOCKS version 5. | │ │ │ │ +| TORRENT_ASSERT(endpoint.address() != address() | │ │ │ │ +| || (!m_dst_name.empty() && m_version == 5)); | │ │ │ │ +| | │ │ │ │ +| m_remote_endpoint = endpoint; | │ │ │ │ +| | │ │ │ │ +| // the connect is split up in the following steps: | │ │ │ │ +| // 1. resolve name of proxy server | │ │ │ │ +| // 2. connect to proxy server | │ │ │ │ +| // 3. if version == 5: | │ │ │ │ +| // 3.1 send SOCKS5 authentication method message | │ │ │ │ +| // 3.2 read SOCKS5 authentication response | │ │ │ │ +| // 3.3 send username+password | │ │ │ │ +| // 4. send SOCKS command message | │ │ │ │ +| | │ │ │ │ +| ADD_OUTSTANDING_ASYNC("socks5_stream::name_lookup"); | │ │ │ │ +| m_resolver.async_resolve(m_hostname, to_string(m_port).data(), wrap_allocator( | │ │ │ │ +| [this](error_code const& ec, tcp::resolver::results_type ips, Handler hn) { | │ │ │ │ +| name_lookup(ec, std::move(ips), std::move(hn)); | │ │ │ │ +| }, std::move(handler))); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +|private: | │ │ │ │ +| | │ │ │ │ +| template | │ │ │ │ +| void name_lookup(error_code const& e, tcp::resolver::results_type ips | │ │ │ │ +|_ _ _,_ _H_a_n_d_l_e_r_ _h_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 2|_._._/_i_n_c_l_u_d_e_/_l_i_b_t_o_r_r_e_n_t_/ |having 8 priority levels is probably excessive. It should probably be changed to 3 levels + dont-download | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_p_i_e_c_e___p_i_c_k_e_r_._h_p_p_:_6_6_8_ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** hhaavviinngg 88 pprriioorriittyy lleevveellss iiss pprroobbaabbllyy eexxcceessssiivvee.. IItt sshhoouulldd pprroobbaabbllyy bbee cchhaannggeedd ttoo 33 lleevveellss ++ ddoonntt--ddoowwnnllooaadd ********** | │ │ │ │ +|****** ....//iinncclluuddee//lliibbttoorrrreenntt//ppiieeccee__ppiicckkeerr..hhpppp::666688 ****** | │ │ │ │ +|else if (state() == piece_full) | │ │ │ │ +| state(piece_full_reverse); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| // the number of peers that has this piece | │ │ │ │ +| // (availability) | │ │ │ │ +| std::uint32_t peer_count : 26; | │ │ │ │ +| | │ │ │ │ +| // one of the download_queue_t values. This indicates whether this piece | │ │ │ │ +| // is currently being downloaded or not, and what state it's in if | │ │ │ │ +| // it is. Specifically, as an optimization, pieces that have all blocks | │ │ │ │ +| // requested from them are separated out into separate lists to make | │ │ │ │ +| // lookups quicker. The main oddity is that whether a downloading piece | │ │ │ │ +| // has only been requested from peers that are reverse, that's | │ │ │ │ +| // recorded as piece_downloading_reverse, which really means the same | │ │ │ │ +| // as piece_downloading, it just saves space to also indicate that it | │ │ │ │ +| // has a bit lower priority. The reverse bit is only relevant if the | │ │ │ │ +| // state is piece_downloading. | │ │ │ │ +| std::uint32_t download_state : 3; | │ │ │ │ +| | │ │ │ │ +| | │ │ │ │ +|// is 0 if the piece is filtered (not to be downloaded) | │ │ │ │ +| // 1 is low priority | │ │ │ │ +| // 2 is low priority | │ │ │ │ +| // 3 is mid priority | │ │ │ │ +| // 4 is default priority | │ │ │ │ +| // 5 is mid priority | │ │ │ │ +| // 6 is high priority | │ │ │ │ +| // 7 is high priority | │ │ │ │ +| std::uint32_t piece_priority : 3; | │ │ │ │ +| | │ │ │ │ +| // index in to the piece_info vector | │ │ │ │ +| prio_index_t index; | │ │ │ │ +| | │ │ │ │ +|#ifdef TORRENT_DEBUG_REFCOUNTS | │ │ │ │ +| // all the peers that have this piece | │ │ │ │ +| std::set have_peers; | │ │ │ │ +|#endif | │ │ │ │ +| | │ │ │ │ +| // index is set to this to indicate that we have the | │ │ │ │ +| // piece. There is no entry for the piece in the | │ │ │ │ +| // buckets if this is the case. | │ │ │ │ +| static constexpr prio_index_t we_have_index{-1}; | │ │ │ │ +| | │ │ │ │ +| // the priority value that means the piece is filtered | │ │ │ │ +| static constexpr std::uint32_t filter_priority = 0; | │ │ │ │ +| | │ │ │ │ +| // the max number the peer count can hold | │ │ │ │ +| static constexpr std::uint32_t max_peer_count = 0xffff; | │ │ │ │ +| | │ │ │ │ +|_ _ _ _b_o_o_l_ _h_a_v_e_(_)_ _c_o_n_s_t_ _{_ _r_e_t_u_r_n_ _i_n_d_e_x_ _=_=_ _w_e___h_a_v_e___i_n_d_e_x_;_ _}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |relevance 2|_._._/_i_n_c_l_u_d_e_/_l_i_b_t_o_r_r_e_n_t_/ |this could be done more efficiently by just looking up the interface with the given name, maybe even with if_nametoindex() | │ │ │ │ |_ _ _ _ _ _ _ _ _ _ _ _|_e_n_u_m___n_e_t_._h_p_p_:_1_9_6_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** tthhiiss ccoouulldd bbee ddoonnee mmoorree eeffffiicciieennttllyy bbyy jjuusstt llooookkiinngg uupp tthhee iinntteerrffaaccee wwiitthh tthhee ggiivveenn nnaammee,, mmaayybbee eevveenn wwiitthh iiff__nnaammeettooiinnddeexx(()) ********** | │ │ │ │ |****** ....//iinncclluuddee//lliibbttoorrrreenntt//eennuumm__nneett..hhpppp::119966 ****** | │ │ │ │ |// IPv6 address. If we're asking to be bound to an IPv6 address and | │ │ │ │ | // providing 0.0.0.0 as the device, turn it into "::" | │ │ │ │ | if (ip == address_v4::any() && protocol == boost::asio::ip::tcp::v6()) | │ │ │ │ @@ -4690,14 +4690,67 @@ │ │ │ │ | buf = rhs.buf; | │ │ │ │ | size = rhs.size; | │ │ │ │ | used_size = rhs.used_size; | │ │ │ │ | move_holder(&holder, &rhs.holder); | │ │ │ │ | } | │ │ │ │ | buffer_t& operator=(buffer_t&& rhs) & noexcept | │ │ │ │ |_ _ _ _{_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _1_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_5_7_4_1_ _ _|_r_e_p_o_r_t_ _t_h_e_ _p_r_o_p_e_r_ _a_d_d_r_e_s_s_ _o_f_ _t_h_e_ _r_o_u_t_e_r_ _a_s_ _t_h_e_ _s_o_u_r_c_e_ _I_P_ _o_f_ _t_h_i_s_ _v_o_t_e_ _o_f_ _o_u_r_ _e_x_t_e_r_n_a_l_ _a_d_d_r_e_s_s_,_ _i_n_s_t_e_a_d_ _o_f_ _t_h_e_ _e_m_p_t_y_ _a_d_d_r_e_s_s_ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** rreeppoorrtt tthhee pprrooppeerr aaddddrreessss ooff tthhee rroouutteerr aass tthhee ssoouurrccee IIPP ooff tthhiiss vvoottee ooff oouurr eexxtteerrnnaall aaddddrreessss,, iinnsstteeaadd ooff tthhee eemmppttyy aaddddrreessss ********** | │ │ │ │ +|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::55774411 ****** | │ │ │ │ +|, listen_socket_handle const& ls) | │ │ │ │ +| { | │ │ │ │ +| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ +| | │ │ │ │ +| listen_socket_t* listen_socket = ls.get(); | │ │ │ │ +| | │ │ │ │ +| // NOTE: don't assume that if ec != 0, the rest of the logic | │ │ │ │ +| // is not necessary, the ports still need to be set, in other | │ │ │ │ +| // words, don't early return without careful review of the | │ │ │ │ +| // remaining logic | │ │ │ │ +| if (ec && m_alerts.should_post()) | │ │ │ │ +| { | │ │ │ │ +| m_alerts.emplace_alert(mapping | │ │ │ │ +| , transport, ec, listen_socket ? listen_socket->local_endpoint.address() : address()); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| if (!listen_socket) return; | │ │ │ │ +| | │ │ │ │ +| if (!ec && !external_ip.is_unspecified()) | │ │ │ │ +| { | │ │ │ │ +|auto sock = ls.m_sock.lock(); | │ │ │ │ +|TORRENT_ASSERT(sock); | │ │ │ │ +| if (sock) | │ │ │ │ +| set_external_address(sock, external_ip, source_router, address()); | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +| // need to check whether this mapping is for one of session ports (it could also be a user mapping) | │ │ │ │ +| if ((proto == portmap_protocol::tcp) && (listen_socket->tcp_port_mapping[transport].mapping == mapping)) | │ │ │ │ +| listen_socket->tcp_port_mapping[transport].port = port; | │ │ │ │ +| else if ((proto == portmap_protocol::udp) && (listen_socket->udp_port_mapping[transport].mapping == mapping)) | │ │ │ │ +| listen_socket->udp_port_mapping[transport].port = port; | │ │ │ │ +| | │ │ │ │ +| if (!ec && m_alerts.should_post()) | │ │ │ │ +| { | │ │ │ │ +| m_alerts.emplace_alert(mapping, port | │ │ │ │ +| , transport, proto, listen_socket->local_endpoint.address()); | │ │ │ │ +| } | │ │ │ │ +| } | │ │ │ │ +| | │ │ │ │ +|#if TORRENT_ABI_VERSION == 1 | │ │ │ │ +| session_status session_impl::status() const | │ │ │ │ +| { | │ │ │ │ +|// INVARIANT_CHECK; | │ │ │ │ +| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ +| | │ │ │ │ +| session_status s; | │ │ │ │ +| | │ │ │ │ +| s.optimistic_unchoke_counter = m_optimistic_unchoke_time_scaler; | │ │ │ │ +| s.unchoke_counter = m_unchoke_time_scaler; | │ │ │ │ +|_ _ _s_._n_u_m___d_e_a_d___p_e_e_r_s_ _=_ _i_n_t_(_m___u_n_d_e_a_d___p_e_e_r_s_._s_i_z_e_(_)_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ | | |make this depend on the error and on the filesystem the files are being downloaded to. If the error is no_space_left_on_device and | │ │ │ │ |relevance 1|_._._/_s_r_c_/_t_o_r_r_e_n_t_._c_p_p_:_1_1_7_9 |the filesystem doesn't support sparse files, only zero the priorities of the pieces that are at the tails of all files, leaving | │ │ │ │ |_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_e_v_e_r_y_t_h_i_n_g_ _u_p_ _t_o_ _t_h_e_ _h_i_g_h_e_s_t_ _w_r_i_t_t_e_n_ _p_i_e_c_e_ _i_n_ _e_a_c_h_ _f_i_l_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** mmaakkee tthhiiss ddeeppeenndd oonn tthhee eerrrroorr aanndd oonn tthhee ffiilleessyysstteemm tthhee ffiilleess aarree bbeeiinngg ddoowwnnllooaaddeedd ttoo.. IIff tthhee eerrrroorr iiss nnoo__ssppaaccee__lleefftt__oonn__ddeevviiccee aanndd tthhee ffiilleessyysstteemm ddooeessnn''tt ssuuppppoorrtt ssppaarrssee | │ │ │ │ |ffiilleess,, oonnllyy zzeerroo tthhee pprriioorriittiieess ooff tthhee ppiieecceess tthhaatt aarree aatt tthhee ttaaiillss ooff aallll ffiilleess,, lleeaavviinngg eevveerryytthhiinngg uupp ttoo tthhee hhiigghheesstt wwrriitttteenn ppiieeccee iinn eeaacchh ffiillee ********** | │ │ │ │ |****** ....//ssrrcc//ttoorrrreenntt..ccpppp::11117799 ****** | │ │ │ │ | // notify the user of the error | │ │ │ │ @@ -4799,67 +4852,14 @@ │ │ │ │ | // we need to keep the object alive during this operation | │ │ │ │ | m_ses.disk_thread().async_release_files(m_storage | │ │ │ │ | , std::bind(&torrent::on_cache_flushed, shared_from_this(), false)); | │ │ │ │ | m_ses.deferred_submit_jobs(); | │ │ │ │ | } | │ │ │ │ | | │ │ │ │ |_ _ _/_/_ _t_h_i_s_ _t_o_r_r_e_n_t_ _j_u_s_t_ _c_o_m_p_l_e_t_e_d_ _d_o_w_n_l_o_a_d_s_,_ _w_h_i_c_h_ _m_e_a_n_s_ _i_t_ _w_i_l_l_ _f_a_l_l_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _1_|_._._/_s_r_c_/_s_e_s_s_i_o_n___i_m_p_l_._c_p_p_:_5_7_4_1_ _ _|_r_e_p_o_r_t_ _t_h_e_ _p_r_o_p_e_r_ _a_d_d_r_e_s_s_ _o_f_ _t_h_e_ _r_o_u_t_e_r_ _a_s_ _t_h_e_ _s_o_u_r_c_e_ _I_P_ _o_f_ _t_h_i_s_ _v_o_t_e_ _o_f_ _o_u_r_ _e_x_t_e_r_n_a_l_ _a_d_d_r_e_s_s_,_ _i_n_s_t_e_a_d_ _o_f_ _t_h_e_ _e_m_p_t_y_ _a_d_d_r_e_s_s_ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** rreeppoorrtt tthhee pprrooppeerr aaddddrreessss ooff tthhee rroouutteerr aass tthhee ssoouurrccee IIPP ooff tthhiiss vvoottee ooff oouurr eexxtteerrnnaall aaddddrreessss,, iinnsstteeaadd ooff tthhee eemmppttyy aaddddrreessss ********** | │ │ │ │ -|****** ....//ssrrcc//sseessssiioonn__iimmppll..ccpppp::55774411 ****** | │ │ │ │ -|, listen_socket_handle const& ls) | │ │ │ │ -| { | │ │ │ │ -| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ -| | │ │ │ │ -| listen_socket_t* listen_socket = ls.get(); | │ │ │ │ -| | │ │ │ │ -| // NOTE: don't assume that if ec != 0, the rest of the logic | │ │ │ │ -| // is not necessary, the ports still need to be set, in other | │ │ │ │ -| // words, don't early return without careful review of the | │ │ │ │ -| // remaining logic | │ │ │ │ -| if (ec && m_alerts.should_post()) | │ │ │ │ -| { | │ │ │ │ -| m_alerts.emplace_alert(mapping | │ │ │ │ -| , transport, ec, listen_socket ? listen_socket->local_endpoint.address() : address()); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| if (!listen_socket) return; | │ │ │ │ -| | │ │ │ │ -| if (!ec && !external_ip.is_unspecified()) | │ │ │ │ -| { | │ │ │ │ -|auto sock = ls.m_sock.lock(); | │ │ │ │ -|TORRENT_ASSERT(sock); | │ │ │ │ -| if (sock) | │ │ │ │ -| set_external_address(sock, external_ip, source_router, address()); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| // need to check whether this mapping is for one of session ports (it could also be a user mapping) | │ │ │ │ -| if ((proto == portmap_protocol::tcp) && (listen_socket->tcp_port_mapping[transport].mapping == mapping)) | │ │ │ │ -| listen_socket->tcp_port_mapping[transport].port = port; | │ │ │ │ -| else if ((proto == portmap_protocol::udp) && (listen_socket->udp_port_mapping[transport].mapping == mapping)) | │ │ │ │ -| listen_socket->udp_port_mapping[transport].port = port; | │ │ │ │ -| | │ │ │ │ -| if (!ec && m_alerts.should_post()) | │ │ │ │ -| { | │ │ │ │ -| m_alerts.emplace_alert(mapping, port | │ │ │ │ -| , transport, proto, listen_socket->local_endpoint.address()); | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -|#if TORRENT_ABI_VERSION == 1 | │ │ │ │ -| session_status session_impl::status() const | │ │ │ │ -| { | │ │ │ │ -|// INVARIANT_CHECK; | │ │ │ │ -| TORRENT_ASSERT(is_single_thread()); | │ │ │ │ -| | │ │ │ │ -| session_status s; | │ │ │ │ -| | │ │ │ │ -| s.optimistic_unchoke_counter = m_optimistic_unchoke_time_scaler; | │ │ │ │ -| s.unchoke_counter = m_unchoke_time_scaler; | │ │ │ │ -|_ _ _s_._n_u_m___d_e_a_d___p_e_e_r_s_ _=_ _i_n_t_(_m___u_n_d_e_a_d___p_e_e_r_s_._s_i_z_e_(_)_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |relevance 1|_._._/_i_n_c_l_u_d_e_/_l_i_b_t_o_r_r_e_n_t_/ |have one instance per possible subnet, 192.168.x.x, 10.x.x.x, etc. | │ │ │ │ |_ _ _ _ _ _ _ _ _ _ _ _|_i_p___v_o_t_e_r_._h_p_p_:_1_3_0_ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** hhaavvee oonnee iinnssttaannccee ppeerr ppoossssiibbllee ssuubbnneett,, 119922..116688..xx..xx,, 1100..xx..xx..xx,, eettcc.. ********** | │ │ │ │ |****** ....//iinncclluuddee//lliibbttoorrrreenntt//iipp__vvootteerr..hhpppp::113300 ****** | │ │ │ │ |// stores one address for each combination of local/global and ipv4/ipv6 | │ │ │ │ | // use of this class should be avoided, get the IP from the appropriate | │ │ │ │ | // listen interface wherever possible | │ │ │ │ @@ -4882,335 +4882,22 @@ │ │ │ │ | // [n][0] = IPv4 [n][1] = IPv6 | │ │ │ │ |address m_addresses[2][2]; | │ │ │ │ |}; | │ │ │ │ | | │ │ │ │ |} | │ │ │ │ | | │ │ │ │ |_#_e_n_d_i_f_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___u_p_n_p_._c_p_p_:_1_5_6_ _ _ _ _ _|_s_t_o_r_e_ _t_h_e_ _l_o_g_ _a_n_d_ _v_e_r_i_f_y_ _t_h_a_t_ _s_o_m_e_ _k_e_y_ _m_e_s_s_a_g_e_s_ _a_r_e_ _t_h_e_r_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ssttoorree tthhee lloogg aanndd vveerriiffyy tthhaatt ssoommee kkeeyy mmeessssaaggeess aarree tthheerree ********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__uuppnnpp..ccpppp::115566 ****** | │ │ │ │ -|, portmap_protocol const protocol, error_code const& err | │ │ │ │ -| , portmap_transport, aux::listen_socket_handle const&) override | │ │ │ │ -| { | │ │ │ │ -| callback_info info = {mapping, port, err}; | │ │ │ │ -| callbacks.push_back(info); | │ │ │ │ -| std::cout << "mapping: " << static_cast(mapping) | │ │ │ │ -| << ", port: " << port << ", IP: " << ip | │ │ │ │ -| << ", proto: " << static_cast(protocol) | │ │ │ │ -| << ", error: \"" << err.message() << "\"\n"; | │ │ │ │ -| } | │ │ │ │ -| #ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| bool should_log_portmap(portmap_transport) const override | │ │ │ │ -| { | │ │ │ │ -| return true; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| void log_portmap(portmap_transport, char const* msg | │ │ │ │ -| , aux::listen_socket_handle const&) const override | │ │ │ │ -| { | │ │ │ │ -| std::cout << "UPnP: " << msg << std::endl; | │ │ │ │ -|} | │ │ │ │ -|#endif | │ │ │ │ -| }; | │ │ │ │ -| | │ │ │ │ -|ip_interface pick_upnp_interface() | │ │ │ │ -|{ | │ │ │ │ -| lt::io_context ios; | │ │ │ │ -| error_code ec; | │ │ │ │ -| std::vector const routes = enum_routes(ios, ec); | │ │ │ │ -| if (ec) | │ │ │ │ -| { | │ │ │ │ -| std::cerr << "failed to enumerate routes: " << ec.message() << '\n'; | │ │ │ │ -| TEST_CHECK(false); | │ │ │ │ -| return {}; | │ │ │ │ -| } | │ │ │ │ -| std::vector const ifs = enum_net_interfaces(ios, ec); | │ │ │ │ -| if (ec) | │ │ │ │ -| { | │ │ │ │ -| std::cerr << "failed to enumerate network interfaces: " << ec.message() << '\n'; | │ │ │ │ -| TEST_CHECK(false); | │ │ │ │ -| return {}; | │ │ │ │ -| } | │ │ │ │ -| int idx = 0; | │ │ │ │ -| for (auto const& face : ifs) | │ │ │ │ -| { | │ │ │ │ -| if (!face.interface_address.is_v4()) continue; | │ │ │ │ -| std::cout << " - " << idx | │ │ │ │ -| << ' ' << face.interface_address.to_string() | │ │ │ │ -| << ' ' << int(static_cast(face.state)) | │ │ │ │ -| << ' ' << static_cast(face.flags) | │ │ │ │ -|_ _ _ _<_<_ _'_ _'_ _<_<_ _f_a_c_e_._n_a_m_e_ _<_<_ _'_\_n_'_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___t_r_a_n_s_f_e_r_._c_p_p_:_1_7_3_ _|_t_h_e_s_e_ _s_e_t_t_i_n_g_s___p_a_c_k_ _t_e_s_t_s_ _b_e_l_o_n_g_ _i_n_ _t_h_e_i_r_ _o_w_n_ _t_e_s_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tthheessee sseettttiinnggss__ppaacckk tteessttss bbeelloonngg iinn tthheeiirr oowwnn tteesstt ********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__ttrraannssffeerr..ccpppp::117733 ****** | │ │ │ │ -|// to the time it will take to complete the test | │ │ │ │ -| pack.set_int(settings_pack::min_reconnect_time, 0); | │ │ │ │ -| pack.set_int(settings_pack::stop_tracker_timeout, 1); | │ │ │ │ -| pack.set_bool(settings_pack::announce_to_all_trackers, true); | │ │ │ │ -| pack.set_bool(settings_pack::announce_to_all_tiers, true); | │ │ │ │ -| | │ │ │ │ -| // make sure we announce to both http and udp trackers | │ │ │ │ -| pack.set_bool(settings_pack::prefer_udp_trackers, false); | │ │ │ │ -| pack.set_bool(settings_pack::enable_outgoing_utp, false); | │ │ │ │ -| pack.set_bool(settings_pack::enable_incoming_utp, false); | │ │ │ │ -| pack.set_bool(settings_pack::enable_lsd, false); | │ │ │ │ -| pack.set_bool(settings_pack::enable_natpmp, false); | │ │ │ │ -| pack.set_bool(settings_pack::enable_upnp, false); | │ │ │ │ -| pack.set_bool(settings_pack::enable_dht, false); | │ │ │ │ -| | │ │ │ │ -| pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_disabled); | │ │ │ │ -| pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_disabled); | │ │ │ │ -| | │ │ │ │ -| pack.set_bool(settings_pack::allow_multiple_connections_per_ip, false); | │ │ │ │ -| | │ │ │ │ -|pack.set_int(settings_pack::unchoke_slots_limit, 0); | │ │ │ │ -|ses1.apply_settings(pack); | │ │ │ │ -| TEST_CHECK(ses1.get_settings().get_int(settings_pack::unchoke_slots_limit) == 0); | │ │ │ │ -| | │ │ │ │ -| pack.set_int(settings_pack::unchoke_slots_limit, -1); | │ │ │ │ -| ses1.apply_settings(pack); | │ │ │ │ -| TEST_CHECK(ses1.get_settings().get_int(settings_pack::unchoke_slots_limit) == -1); | │ │ │ │ -| | │ │ │ │ -| pack.set_int(settings_pack::unchoke_slots_limit, 8); | │ │ │ │ -| ses1.apply_settings(pack); | │ │ │ │ -| TEST_CHECK(ses1.get_settings().get_int(settings_pack::unchoke_slots_limit) == 8); | │ │ │ │ -| | │ │ │ │ -| ses2.apply_settings(pack); | │ │ │ │ -| | │ │ │ │ -| torrent_handle tor1; | │ │ │ │ -| torrent_handle tor2; | │ │ │ │ -| | │ │ │ │ -| create_directory("tmp1_transfer", ec); | │ │ │ │ -| std::ofstream file("tmp1_transfer/temporary"); | │ │ │ │ -| std::shared_ptr t = ::create_torrent(&file, "temporary", 32 * 1024, 13, false); | │ │ │ │ -| file.close(); | │ │ │ │ -| | │ │ │ │ -| TEST_CHECK(exists(combine_path("tmp1_transfer", "temporary"))); | │ │ │ │ -| | │ │ │ │ -| add_torrent_params params; | │ │ │ │ -| params.storage_mode = storage_mode; | │ │ │ │ -| params.flags &= ~torrent_flags::paused; | │ │ │ │ -| params.flags &= ~torrent_flags::auto_managed; | │ │ │ │ -| | │ │ │ │ -| wait_for_listen(ses1, "ses1"); | │ │ │ │ -|_ _w_a_i_t___f_o_r___l_i_s_t_e_n_(_s_e_s_2_,_ _"_s_e_s_2_"_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___t_r_a_c_k_e_r_._c_p_p_:_6_0_ _ _ _|_t_e_s_t_ _s_c_r_a_p_e_ _r_e_q_u_e_s_t_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt ssccrraappee rreeqquueessttss ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_rr_aa_cc_kk_ee_rr_.._cc_pp_pp_::_66_00_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___t_r_a_c_k_e_r_._c_p_p_:_6_1_ _ _ _|_t_e_s_t_ _p_a_r_s_e_ _p_e_e_r_s_6_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt ppaarrssee ppeeeerrss66 ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_rr_aa_cc_kk_ee_rr_.._cc_pp_pp_::_66_11_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___t_r_a_c_k_e_r_._c_p_p_:_6_2_ _ _ _|_t_e_s_t_ _p_a_r_s_e_ _t_r_a_c_k_e_r_-_i_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt ppaarrssee ttrraacckkeerr--iidd ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_rr_aa_cc_kk_ee_rr_.._cc_pp_pp_::_66_22_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___t_r_a_c_k_e_r_._c_p_p_:_6_3_ _ _ _|_t_e_s_t_ _p_a_r_s_e_ _f_a_i_l_u_r_e_-_r_e_a_s_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt ppaarrssee ffaaiilluurree--rreeaassoonn ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_rr_aa_cc_kk_ee_rr_.._cc_pp_pp_::_66_33_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_r_a_c_k_e_r_._c_p_p_:_6_4 |test all failure paths, including invalid bencoding not a dictionary no files entry in scrape response no info-hash entry in scrape | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_r_e_s_p_o_n_s_e_ _m_a_l_f_o_r_m_e_d_ _p_e_e_r_s_ _i_n_ _p_e_e_r_ _l_i_s_t_ _o_f_ _d_i_c_t_i_o_n_a_r_i_e_s_ _u_n_e_v_e_n_ _n_u_m_b_e_r_ _o_f_ _b_y_t_e_s_ _i_n_ _p_e_e_r_s_ _a_n_d_ _p_e_e_r_s_6_ _s_t_r_i_n_g_ _r_e_s_p_o_n_s_e_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt aallll ffaaiilluurree ppaatthhss,, iinncclluuddiinngg iinnvvaalliidd bbeennccooddiinngg nnoott aa ddiiccttiioonnaarryy nnoo ffiilleess eennttrryy iinn ssccrraappee rreessppoonnssee nnoo iinnffoo--hhaasshh eennttrryy iinn ssccrraappee rreessppoonnssee mmaallffoorrmmeedd ppeeeerrss iinn ppeeeerr lliisstt| │ │ │ │ -|ooff ddiiccttiioonnaarriieess uunneevveenn nnuummbbeerr ooff bbyytteess iinn ppeeeerrss aanndd ppeeeerrss66 ssttrriinngg rreessppoonnsseess ********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__ttrraacckkeerr..ccpppp::6644 ****** | │ │ │ │ -|#include "test_utils.hpp" | │ │ │ │ -|#include "udp_tracker.hpp" | │ │ │ │ -|#include "settings.hpp" | │ │ │ │ -|#include "test_utils.hpp" | │ │ │ │ -|#include "libtorrent/alert.hpp" | │ │ │ │ -|#include "libtorrent/peer_info.hpp" // for peer_list_entry | │ │ │ │ -|#include "libtorrent/alert_types.hpp" | │ │ │ │ -|#include "libtorrent/session.hpp" | │ │ │ │ -|#include "libtorrent/session_params.hpp" | │ │ │ │ -|#include "libtorrent/error_code.hpp" | │ │ │ │ -|#include "libtorrent/tracker_manager.hpp" | │ │ │ │ -|#include "libtorrent/http_tracker_connection.hpp" // for parse_tracker_response | │ │ │ │ -|#include "libtorrent/torrent_info.hpp" | │ │ │ │ -|#include "libtorrent/announce_entry.hpp" | │ │ │ │ -|#include "libtorrent/torrent.hpp" | │ │ │ │ -|#include "libtorrent/aux_/path.hpp" | │ │ │ │ -|#include "libtorrent/socket_io.hpp" | │ │ │ │ -| | │ │ │ │ -|using namespace lt; | │ │ │ │ -| | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(parse_hostname_peers) | │ │ │ │ -|{ | │ │ │ │ -| char const response[] = "d5:peersld7:peer id20:aaaaaaaaaaaaaaaaaaaa" | │ │ │ │ -| "2:ip13:test_hostname4:porti1000eed" | │ │ │ │ -| "7:peer id20:bbbbabaababababababa2:ip12:another_host4:porti1001eeee"; | │ │ │ │ -| error_code ec; | │ │ │ │ -| tracker_response resp = parse_tracker_response(response | │ │ │ │ -| , ec, {}, sha1_hash()); | │ │ │ │ -| | │ │ │ │ -| TEST_EQUAL(ec, error_code()); | │ │ │ │ -| TEST_EQUAL(resp.peers.size(), 2); | │ │ │ │ -| if (resp.peers.size() == 2) | │ │ │ │ -| { | │ │ │ │ -| peer_entry const& e0 = resp.peers[0]; | │ │ │ │ -| peer_entry const& e1 = resp.peers[1]; | │ │ │ │ -| TEST_EQUAL(e0.hostname, "test_hostname"); | │ │ │ │ -| TEST_EQUAL(e0.port, 1000); | │ │ │ │ -| TEST_EQUAL(e0.pid, peer_id("aaaaaaaaaaaaaaaaaaaa")); | │ │ │ │ -| | │ │ │ │ -| TEST_EQUAL(e1.hostname, "another_host"); | │ │ │ │ -| TEST_EQUAL(e1.port, 1001); | │ │ │ │ -| TEST_EQUAL(e1.pid, peer_id("bbbbabaababababababa")); | │ │ │ │ -| } | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(parse_peers4) | │ │ │ │ -|{ | │ │ │ │ -| char const response[] = "d5:peers12:\x01\x02\x03\x04\x30\x10" | │ │ │ │ -| "\x09\x08\x07\x06\x20\x10" "e"; | │ │ │ │ -|_ _e_r_r_o_r___c_o_d_e_ _e_c_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|test remap_files | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_7_5_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt rreemmaapp__ffiilleess ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_oo_rr_rr_ee_nn_tt____ii_nn_ff_oo_.._cc_pp_pp_::_44_77_55_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|torrent with 'p' (padfile) attribute | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_7_6_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ttoorrrreenntt wwiitthh ''pp'' ((ppaaddffiillee)) aattttrriibbuuttee ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_oo_rr_rr_ee_nn_tt____ii_nn_ff_oo_.._cc_pp_pp_::_44_77_66_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|torrent with 'h' (hidden) attribute | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_7_7_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ttoorrrreenntt wwiitthh ''hh'' ((hhiiddddeenn)) aattttrriibbuuttee ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_oo_rr_rr_ee_nn_tt____ii_nn_ff_oo_.._cc_pp_pp_::_44_77_77_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|torrent with 'x' (executable) attribute | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_7_8_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ttoorrrreenntt wwiitthh ''xx'' ((eexxeeccuuttaabbllee)) aattttrriibbuuttee ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_oo_rr_rr_ee_nn_tt____ii_nn_ff_oo_.._cc_pp_pp_::_44_77_88_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|torrent with 'l' (symlink) attribute | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_7_9_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ttoorrrreenntt wwiitthh ''ll'' ((ssyymmlliinnkk)) aattttrriibbuuttee ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_oo_rr_rr_ee_nn_tt____ii_nn_ff_oo_.._cc_pp_pp_::_44_77_99_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|torrent with multiple trackers in multiple tiers, making sure we shuffle them (how do you test shuffling?, load it multiple times | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_8_0_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_a_n_d_ _m_a_k_e_ _s_u_r_e_ _i_t_'_s_ _i_n_ _d_i_f_f_e_r_e_n_t_ _o_r_d_e_r_ _a_t_ _l_e_a_s_t_ _o_n_c_e_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ttoorrrreenntt wwiitthh mmuullttiippllee ttrraacckkeerrss iinn mmuullttiippllee ttiieerrss,, mmaakkiinngg ssuurree wwee sshhuuffffllee tthheemm ((hhooww ddoo yyoouu tteesstt sshhuufffflliinngg??,, llooaadd iitt mmuullttiippllee ttiimmeess aanndd mmaakkee ssuurree iitt''ss iinn ddiiffffeerreenntt oorrddeerr | │ │ │ │ -|aatt lleeaasstt oonnccee)) ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_oo_rr_rr_ee_nn_tt____ii_nn_ff_oo_.._cc_pp_pp_::_44_88_00_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|torrents with a zero-length name | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_8_3_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ttoorrrreennttss wwiitthh aa zzeerroo--lleennggtthh nnaammee ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_oo_rr_rr_ee_nn_tt____ii_nn_ff_oo_.._cc_pp_pp_::_44_88_33_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|torrent with a non-dictionary info-section | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_8_4_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ttoorrrreenntt wwiitthh aa nnoonn--ddiiccttiioonnaarryy iinnffoo--sseeccttiioonn ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_oo_rr_rr_ee_nn_tt____ii_nn_ff_oo_.._cc_pp_pp_::_44_88_44_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|torrents with DHT nodes | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_8_5_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ttoorrrreennttss wwiitthh DDHHTT nnooddeess ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_oo_rr_rr_ee_nn_tt____ii_nn_ff_oo_.._cc_pp_pp_::_44_88_55_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|torrent with url-list as a single string | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_8_6_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ttoorrrreenntt wwiitthh uurrll--lliisstt aass aa ssiinnggllee ssttrriinngg ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_oo_rr_rr_ee_nn_tt____ii_nn_ff_oo_.._cc_pp_pp_::_44_88_66_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|torrent with http seed as a single string | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_8_7_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ttoorrrreenntt wwiitthh hhttttpp sseeeedd aass aa ssiinnggllee ssttrriinngg ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_oo_rr_rr_ee_nn_tt____ii_nn_ff_oo_.._cc_pp_pp_::_44_88_77_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|torrent with a comment | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_8_8_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ttoorrrreenntt wwiitthh aa ccoommmmeenntt ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_oo_rr_rr_ee_nn_tt____ii_nn_ff_oo_.._cc_pp_pp_::_44_88_88_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|torrent with an SSL cert | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_8_9_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ttoorrrreenntt wwiitthh aann SSSSLL cceerrtt ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_oo_rr_rr_ee_nn_tt____ii_nn_ff_oo_.._cc_pp_pp_::_44_88_99_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|torrent with attributes (executable and hidden) | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_9_0_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ttoorrrreenntt wwiitthh aattttrriibbuutteess ((eexxeeccuuttaabbllee aanndd hhiiddddeenn)) ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_oo_rr_rr_ee_nn_tt____ii_nn_ff_oo_.._cc_pp_pp_::_44_99_00_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|torrent_info constructor that takes an invalid bencoded buffer | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_9_1_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ttoorrrreenntt__iinnffoo ccoonnssttrruuccttoorr tthhaatt ttaakkeess aann iinnvvaalliidd bbeennccooddeedd bbuuffffeerr ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_oo_rr_rr_ee_nn_tt____ii_nn_ff_oo_.._cc_pp_pp_::_44_99_11_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:|verify_encoding with a string that triggers character replacement | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_4_9_2_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** vveerriiffyy__eennccooddiinngg wwiitthh aa ssttrriinngg tthhaatt ttrriiggggeerrss cchhaarraacctteerr rreeppllaacceemmeenntt ********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__ttoorrrreenntt__iinnffoo..ccpppp::449922 ****** | │ │ │ │ -|{ "v2_piece_layer_invalid_file_hash.torrent", errors::torrent_invalid_piece_layer}, | │ │ │ │ -| { "v2_invalid_piece_layer.torrent", errors::torrent_invalid_piece_layer}, | │ │ │ │ -| { "v2_invalid_piece_layer_root.torrent", errors::torrent_invalid_piece_layer}, | │ │ │ │ -| { "v2_unknown_piece_layer_entry.torrent", errors::torrent_invalid_piece_layer}, | │ │ │ │ -| { "v2_invalid_piece_layer_size.torrent", errors::torrent_invalid_piece_layer}, | │ │ │ │ -| { "v2_bad_file_alignment.torrent", errors::torrent_inconsistent_files}, | │ │ │ │ -| { "v2_unordered_files.torrent", errors::invalid_bencoding}, | │ │ │ │ -| { "v2_overlong_integer.torrent", errors::invalid_bencoding}, | │ │ │ │ -| { "v2_missing_file_root_invalid_symlink.torrent", errors::torrent_missing_pieces_root}, | │ │ │ │ -| { "v2_large_file.torrent", errors::torrent_invalid_length}, | │ │ │ │ -| { "v2_large_offset.torrent", errors::too_many_pieces_in_torrent}, | │ │ │ │ -| { "v2_piece_size.torrent", errors::torrent_missing_piece_length}, | │ │ │ │ -| { "v2_invalid_pad_file.torrent", errors::torrent_invalid_pad_file}, | │ │ │ │ -| { "v2_zero_root.torrent", errors::torrent_missing_pieces_root}, | │ │ │ │ -| { "v2_zero_root_small.torrent", errors::torrent_missing_pieces_root}, | │ │ │ │ -| { "v2_empty_filename.torrent", errors::torrent_file_parse_failed}, | │ │ │ │ -|}; | │ │ │ │ -| | │ │ │ │ -|} // anonymous namespace | │ │ │ │ -| | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(add_tracker) | │ │ │ │ -|{ | │ │ │ │ -| torrent_info ti(info_hash_t(sha1_hash(" "))); | │ │ │ │ -| TEST_EQUAL(ti.trackers().size(), 0); | │ │ │ │ -| | │ │ │ │ -| ti.add_tracker("http://test.com/announce"); | │ │ │ │ -| TEST_EQUAL(ti.trackers().size(), 1); | │ │ │ │ -| | │ │ │ │ -| announce_entry ae = ti.trackers()[0]; | │ │ │ │ -| TEST_EQUAL(ae.url, "http://test.com/announce"); | │ │ │ │ -| | │ │ │ │ -| ti.clear_trackers(); | │ │ │ │ -| TEST_EQUAL(ti.trackers().size(), 0); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(url_list_and_httpseeds) | │ │ │ │ -|{ | │ │ │ │ -| entry info; | │ │ │ │ -| info["pieces"] = "aaaaaaaaaaaaaaaaaaaa"; | │ │ │ │ -| info["name.utf-8"] = "test1"; | │ │ │ │ -| info["name"] = "test__"; | │ │ │ │ -| info["piece length"] = 16 * 1024; | │ │ │ │ -| info["length"] = 3245; | │ │ │ │ -| entry::list_type l; | │ │ │ │ -| l.push_back(entry("http://foo.com/bar1")); | │ │ │ │ -| l.push_back(entry("http://foo.com/bar1")); | │ │ │ │ -| l.push_back(entry("http://foo.com/bar2")); | │ │ │ │ -| entry const e(l); | │ │ │ │ -| entry torrent; | │ │ │ │ -|_ _t_o_r_r_e_n_t_[_"_u_r_l_-_l_i_s_t_"_]_ _=_ _e_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/ |test the case where we have > 120 samples (and have the base delay actually be updated) | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_t_e_s_t___t_i_m_e_s_t_a_m_p___h_i_s_t_o_r_y_._c_p_p_:_5_4_ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt tthhee ccaassee wwhheerree wwee hhaavvee >> 112200 ssaammpplleess ((aanndd hhaavvee tthhee bbaassee ddeellaayy aaccttuuaallllyy bbee uuppddaatteedd)) ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_ii_mm_ee_ss_tt_aa_mm_pp____hh_ii_ss_tt_oo_rr_yy_.._cc_pp_pp_::_55_44_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/ |test the case where a sample is lower than the history entry but not lower than the base | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_t_e_s_t___t_i_m_e_s_t_a_m_p___h_i_s_t_o_r_y_._c_p_p_:_5_5_ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt tthhee ccaassee wwhheerree aa ssaammppllee iiss lloowweerr tthhaann tthhee hhiissttoorryy eennttrryy bbuutt nnoott lloowweerr tthhaann tthhee bbaassee ********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__ttiimmeessttaammpp__hhiissttoorryy..ccpppp::5555 ****** | │ │ │ │ -|#include "libtorrent/aux_/timestamp_history.hpp" | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(timestamp_history) | │ │ │ │ -|{ | │ │ │ │ -| using namespace lt; | │ │ │ │ -| | │ │ │ │ -| aux::timestamp_history h; | │ │ │ │ -| TEST_EQUAL(h.add_sample(0x32, false), 0); | │ │ │ │ -| TEST_EQUAL(h.base(), 0x32); | │ │ │ │ -| TEST_EQUAL(h.add_sample(0x33, false), 0x1); | │ │ │ │ -| TEST_EQUAL(h.base(), 0x32); | │ │ │ │ -| TEST_EQUAL(h.add_sample(0x3433, false), 0x3401); | │ │ │ │ -| TEST_EQUAL(h.base(), 0x32); | │ │ │ │ -| TEST_EQUAL(h.add_sample(0x30, false), 0); | │ │ │ │ -| TEST_EQUAL(h.base(), 0x30); | │ │ │ │ -| | │ │ │ │ -| // test that wrapping of the timestamp is properly handled | │ │ │ │ -| h.add_sample(0xfffffff3, false); | │ │ │ │ -| TEST_EQUAL(h.base(), 0xfffffff3); | │ │ │ │ -| | │ │ │ │ -|_}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___f_i_l_e___s_t_o_r_a_g_e_._c_p_p_:|test file attributes | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_3_5_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt ffiillee aattttrriibbuutteess ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____ff_ii_ll_ee____ss_tt_oo_rr_aa_gg_ee_.._cc_pp_pp_::_11_22_33_55_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___f_i_l_e___s_t_o_r_a_g_e_._c_p_p_:|test symlinks | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_3_6_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt ssyymmlliinnkkss ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____ff_ii_ll_ee____ss_tt_oo_rr_aa_gg_ee_.._cc_pp_pp_::_11_22_33_66_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___s_s_l_._c_p_p_:_4_0_7_ _ _ _ _ _ _|_t_e_s_t_ _u_s_i_n_g_ _a_ _s_i_g_n_e_d_ _c_e_r_t_i_f_i_c_a_t_e_ _w_i_t_h_ _t_h_e_ _w_r_o_n_g_ _i_n_f_o_-_h_a_s_h_ _i_n_ _D_N_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** tteesstt uussiinngg aa ssiiggnneedd cceerrttiiffiiccaattee wwiitthh tthhee wwrroonngg iinnffoo--hhaasshh iinn DDNN ********** | │ │ │ │ |****** ....//tteesstt//tteesstt__ssssll..ccpppp::440077 ****** | │ │ │ │ |// in verifying peers | │ │ │ │ | ctx.set_verify_mode(context::verify_none, ec); | │ │ │ │ | if (ec) | │ │ │ │ | { | │ │ │ │ @@ -5311,228 +4998,18 @@ │ │ │ │ | return false; | │ │ │ │ | } | │ │ │ │ | | │ │ │ │ | if (memcmp(buf, "\x13" "BitTorrent protocol", 20) != 0) | │ │ │ │ | { | │ │ │ │ | std::printf("invalid bittorrent handshake\n"); | │ │ │ │ |_ _ _r_e_t_u_r_n_ _f_a_l_s_e_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___r_e_s_u_m_e_._c_p_p_:_6_1_4_ _ _ _|_t_e_s_t_ _w_h_a_t_ _h_a_p_p_e_n_s_ _w_h_e_n_ _l_o_a_d_i_n_g_ _a_ _r_e_s_u_m_e_ _f_i_l_e_ _w_i_t_h_ _b_o_t_h_ _p_i_e_c_e_ _p_r_i_o_r_i_t_i_e_s_ _a_n_d_ _f_i_l_e_ _p_r_i_o_r_i_t_i_e_s_ _(_f_i_l_e_ _p_r_i_o_ _s_h_o_u_l_d_ _t_a_k_e_ _p_r_e_c_e_d_e_n_c_e_)_ _ _ _ _ _ | │ │ │ │ -|********** tteesstt wwhhaatt hhaappppeennss wwhheenn llooaaddiinngg aa rreessuummee ffiillee wwiitthh bbootthh ppiieeccee pprriioorriittiieess aanndd ffiillee pprriioorriittiieess ((ffiillee pprriioo sshhoouulldd ttaakkee pprreecceeddeennccee)) ********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__rreessuummee..ccpppp::661144 ****** | │ │ │ │ -|{ | │ │ │ │ -| TEST_EQUAL(pieces[i], true); | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|} // anonymous namespace | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(piece_slots_seed) | │ │ │ │ -|{ | │ │ │ │ -| test_piece_slots_seed(settings()); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(piece_slots_seed_suggest_cache) | │ │ │ │ -|{ | │ │ │ │ -| settings_pack sett = settings(); | │ │ │ │ -| sett.set_int(settings_pack::suggest_mode, settings_pack::suggest_read_cache); | │ │ │ │ -| test_piece_slots_seed(sett); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___r_e_s_u_m_e_._c_p_p_:_6_1_7_ _ _ _|_m_a_k_e_ _s_u_r_e_ _a_ _r_e_s_u_m_e_ _f_i_l_e_ _o_n_l_y_ _e_v_e_r_ _c_o_n_t_a_i_n_ _f_i_l_e_ _p_r_i_o_r_i_t_i_e_s_ _O_R_ _p_i_e_c_e_ _p_r_i_o_r_i_t_i_e_s_._ _N_e_v_e_r_ _b_o_t_h_._ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** mmaakkee ssuurree aa rreessuummee ffiillee oonnllyy eevveerr ccoonnttaaiinn ffiillee pprriioorriittiieess OORR ppiieeccee pprriioorriittiieess.. NNeevveerr bbootthh.. ********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__rreessuummee..ccpppp::661177 ****** | │ │ │ │ -|TEST_EQUAL(pieces[i], true); | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|} // anonymous namespace | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(piece_slots_seed) | │ │ │ │ -|{ | │ │ │ │ -| test_piece_slots_seed(settings()); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(piece_slots_seed_suggest_cache) | │ │ │ │ -|{ | │ │ │ │ -| settings_pack sett = settings(); | │ │ │ │ -| sett.set_int(settings_pack::suggest_mode, settings_pack::suggest_read_cache); | │ │ │ │ -| test_piece_slots_seed(sett); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -| | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___r_e_s_u_m_e_._c_p_p_:_6_2_0_ _ _ _|_g_e_n_e_r_a_l_l_y_ _s_a_v_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ggeenneerraallllyy ssaavvee ********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__rreessuummee..ccpppp::662200 ****** | │ │ │ │ -|} | │ │ │ │ -| } | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|} // anonymous namespace | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(piece_slots_seed) | │ │ │ │ -|{ | │ │ │ │ -| test_piece_slots_seed(settings()); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(piece_slots_seed_suggest_cache) | │ │ │ │ -|{ | │ │ │ │ -| settings_pack sett = settings(); | │ │ │ │ -| sett.set_int(settings_pack::suggest_mode, settings_pack::suggest_read_cache); | │ │ │ │ -| test_piece_slots_seed(sett); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -| | │ │ │ │ -| | │ │ │ │ -| | │ │ │ │ -|#if TORRENT_ABI_VERSION == 1 | │ │ │ │ -|TORRENT_TEST(file_priorities_default_deprecated) | │ │ │ │ -|{ | │ │ │ │ -| lt::session ses(settings()); | │ │ │ │ -| std::vector file_priorities = test_resume_flags(ses | │ │ │ │ -| , {}, "", "", true).get_file_priorities(); | │ │ │ │ -| | │ │ │ │ -| TEST_EQUAL(file_priorities.size(), 3); | │ │ │ │ -| TEST_EQUAL(file_priorities[0], 4); | │ │ │ │ -| TEST_EQUAL(file_priorities[1], 4); | │ │ │ │ -| TEST_EQUAL(file_priorities[2], 4); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|// As long as the add_torrent_params priorities are empty, the file_priorities | │ │ │ │ -|// from the resume data should take effect | │ │ │ │ -|TORRENT_TEST(file_priorities_in_resume_deprecated) | │ │ │ │ -|{ | │ │ │ │ -| lt::session ses(settings()); | │ │ │ │ -| std::vector file_priorities = test_resume_flags(ses, {}, "", "123").get_file_priorities(); | │ │ │ │ -| | │ │ │ │ -| TEST_EQUAL(file_priorities.size(), 3); | │ │ │ │ -| TEST_EQUAL(file_priorities[0], 1); | │ │ │ │ -| TEST_EQUAL(file_priorities[1], 2); | │ │ │ │ -| TEST_EQUAL(file_priorities[2], 3); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|// if both resume data and add_torrent_params has file_priorities, the | │ │ │ │ -|// add_torrent_params one take precedence | │ │ │ │ -|TORRENT_TEST(file_priorities_in_resume_and_params_deprecated) | │ │ │ │ -|_{_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___r_e_s_u_m_e_._c_p_p_:_9_4_3 |test all other resume flags here too. This would require returning more than just the torrent_status from test_resume_flags. Also | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_h_t_t_p_ _s_e_e_d_s_ _a_n_d_ _t_r_a_c_k_e_r_s_ _f_o_r_ _i_n_s_t_a_n_c_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt aallll ootthheerr rreessuummee ffllaaggss hheerree ttoooo.. TThhiiss wwoouulldd rreeqquuiirree rreettuurrnniinngg mmoorree tthhaann jjuusstt tthhee ttoorrrreenntt__ssttaattuuss ffrroomm tteesstt__rreessuummee__ffllaaggss.. AAllssoo hhttttpp sseeeeddss aanndd ttrraacckkeerrss ffoorr iinnssttaannccee | │ │ │ │ -|********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__rreessuummee..ccpppp::994433 ****** | │ │ │ │ -|TEST_EQUAL(s.connections_limit, 1345); | │ │ │ │ -| TEST_EQUAL(s.uploads_limit, 1346); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(paused_deprecated) | │ │ │ │ -|{ | │ │ │ │ -| lt::session ses(settings()); | │ │ │ │ -| // resume data overrides the paused flag | │ │ │ │ -| auto const now = lt::clock_type::now(); | │ │ │ │ -| torrent_status s = test_resume_flags(ses, torrent_flags::paused, "", "", true).status(); | │ │ │ │ -| default_tests(s, now); | │ │ │ │ -|#ifdef TORRENT_WINDOWS | │ │ │ │ -| TEST_EQUAL(s.save_path, "c:\\add_torrent_params save_path"); | │ │ │ │ -|#else | │ │ │ │ -| TEST_EQUAL(s.save_path, "/add_torrent_params save_path"); | │ │ │ │ -|#endif | │ │ │ │ -| TEST_EQUAL(s.flags & flags_mask, torrent_flags_t{}); | │ │ │ │ -| TEST_EQUAL(s.connections_limit, 1345); | │ │ │ │ -| TEST_EQUAL(s.uploads_limit, 1346); | │ │ │ │ -| | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(url_seed_resume_data_deprecated) | │ │ │ │ -|{ | │ │ │ │ -| // merge url seeds with resume data | │ │ │ │ -| std::printf("flags: merge_resume_http_seeds\n"); | │ │ │ │ -| lt::session ses(settings()); | │ │ │ │ -| torrent_handle h = test_resume_flags(ses, | │ │ │ │ -| torrent_flags::merge_resume_http_seeds, "", "", true); | │ │ │ │ -| std::set us = h.url_seeds(); | │ │ │ │ -| std::set ws = h.http_seeds(); | │ │ │ │ -| | │ │ │ │ -| TEST_EQUAL(us.size(), 3); | │ │ │ │ -| TEST_EQUAL(std::count(us.begin(), us.end() | │ │ │ │ -| , "http://add-torrent-params-url-seed.com/"), 1); | │ │ │ │ -| TEST_EQUAL(std::count(us.begin(), us.end() | │ │ │ │ -| , "http://torrent-file-url-seed.com/"), 1); | │ │ │ │ -| TEST_EQUAL(std::count(us.begin(), us.end() | │ │ │ │ -| , "http://resume-data-url-seed.com/"), 1); | │ │ │ │ -| | │ │ │ │ -| TEST_EQUAL(ws.size(), 1); | │ │ │ │ -| TEST_EQUAL(std::count(ws.begin(), ws.end() | │ │ │ │ -| , "http://resume-data-http-seed.com"), 1); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(resume_override_torrent_deprecated) | │ │ │ │ -|{ | │ │ │ │ -| // resume data overrides the .torrent_file | │ │ │ │ -| std::printf("flags: no merge_resume_http_seed\n"); | │ │ │ │ -| lt::session ses(settings()); | │ │ │ │ -|_ _t_o_r_r_e_n_t___h_a_n_d_l_e_ _h_ _=_ _t_e_s_t___r_e_s_u_m_e___f_l_a_g_s_(_s_e_s_,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___r_e_s_u_m_e_._c_p_p_:_1_7_1_5 |test all other resume flags here too. This would require returning more than just the torrent_status from test_resume_flags. Also | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_h_t_t_p_ _s_e_e_d_s_ _a_n_d_ _t_r_a_c_k_e_r_s_ _f_o_r_ _i_n_s_t_a_n_c_e_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt aallll ootthheerr rreessuummee ffllaaggss hheerree ttoooo.. TThhiiss wwoouulldd rreeqquuiirree rreettuurrnniinngg mmoorree tthhaann jjuusstt tthhee ttoorrrreenntt__ssttaattuuss ffrroomm tteesstt__rreessuummee__ffllaaggss.. AAllssoo hhttttpp sseeeeddss aanndd ttrraacckkeerrss ffoorr iinnssttaannccee | │ │ │ │ -|********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__rreessuummee..ccpppp::11771155 ****** | │ │ │ │ -|TEST_EQUAL(s.connections_limit, 1345); | │ │ │ │ -| TEST_EQUAL(s.uploads_limit, 1346); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(paused) | │ │ │ │ -|{ | │ │ │ │ -| lt::session ses(settings()); | │ │ │ │ -| // resume data overrides the paused flag | │ │ │ │ -| auto const now = lt::clock_type::now(); | │ │ │ │ -| torrent_status s = test_resume_flags(ses, torrent_flags::paused).status(); | │ │ │ │ -| default_tests(s, now); | │ │ │ │ -|#ifdef TORRENT_WINDOWS | │ │ │ │ -| TEST_EQUAL(s.save_path, "c:\\add_torrent_params save_path"); | │ │ │ │ -|#else | │ │ │ │ -| TEST_EQUAL(s.save_path, "/add_torrent_params save_path"); | │ │ │ │ -|#endif | │ │ │ │ -| TEST_EQUAL(s.flags & flags_mask, torrent_flags::paused); | │ │ │ │ -| TEST_EQUAL(s.connections_limit, 1345); | │ │ │ │ -| TEST_EQUAL(s.uploads_limit, 1346); | │ │ │ │ -| | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(no_metadata) | │ │ │ │ -|{ | │ │ │ │ -| lt::session ses(settings()); | │ │ │ │ -| | │ │ │ │ -| add_torrent_params p; | │ │ │ │ -| p.info_hashes.v1 = sha1_hash("abababababababababab"); | │ │ │ │ -| p.save_path = "."; | │ │ │ │ -| p.name = "foobar"; | │ │ │ │ -| torrent_handle h = ses.add_torrent(p); | │ │ │ │ -| h.save_resume_data(torrent_handle::save_info_dict); | │ │ │ │ -| alert const* a = wait_for_alert(ses, save_resume_data_alert::alert_type); | │ │ │ │ -| TEST_CHECK(a); | │ │ │ │ -| save_resume_data_alert const* ra = alert_cast(a); | │ │ │ │ -| TEST_CHECK(ra); | │ │ │ │ -| if (ra) | │ │ │ │ -| { | │ │ │ │ -| auto const& atp = ra->params; | │ │ │ │ -| TEST_EQUAL(atp.info_hashes, p.info_hashes); | │ │ │ │ -| TEST_EQUAL(atp.name, "foobar"); | │ │ │ │ -| } | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|template | │ │ │ │ -|void test_unfinished_pieces(Fun f) | │ │ │ │ -|{ | │ │ │ │ -| // create a torrent and complete files | │ │ │ │ -| std::shared_ptr ti = generate_torrent(true, true); | │ │ │ │ -| | │ │ │ │ -|_ _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s_ _p_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/ |test sending invalid requests (out of bound piece index, offsets and sizes) | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_t_e_s_t___f_a_s_t___e_x_t_e_n_s_i_o_n_._c_p_p_:_1_2_2_8_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt sseennddiinngg iinnvvaalliidd rreeqquueessttss ((oouutt ooff bboouunndd ppiieeccee iinnddeexx,, ooffffsseettss aanndd ssiizzeess)) ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____ff_aa_ss_tt____ee_xx_tt_ee_nn_ss_ii_oo_nn_.._cc_pp_pp_::_11_22_22_88_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |relevance 0|_._._/_t_e_s_t_/ |test files with different piece size (negative test) | │ │ │ │ |_ _ _ _ _ _ _ _ _ _ _ _|_t_e_s_t___r_e_s_o_l_v_e___l_i_n_k_s_._c_p_p_:_9_5_ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |********** tteesstt ffiilleess wwiitthh ddiiffffeerreenntt ppiieeccee ssiizzee ((nneeggaattiivvee tteesstt)) ********** | │ │ │ │ |****** ....//tteesstt//tteesstt__rreessoollvvee__lliinnkkss..ccpppp::9955 ****** | │ │ │ │ |{ "test2", "test1_pad_files", 0}, | │ │ │ │ | { "test3", "test1_pad_files", 0}, | │ │ │ │ | { "test2", "test1_single", 0}, | │ │ │ │ @@ -5605,309 +5082,79 @@ │ │ │ │ | auto const num_matches = std::size_t(std::count_if(links.begin(), links.end() | │ │ │ │ | , std::bind(&resolve_links::link_t::ti, _1))); | │ │ │ │ | | │ │ │ │ | // some debug output in case the test fails | │ │ │ │ | if (num_matches > e.expected_matches) | │ │ │ │ | { | │ │ │ │ |_ _ _ _f_i_l_e___s_t_o_r_a_g_e_ _c_o_n_s_t_&_ _f_s_ _=_ _t_i_1_-_>_f_i_l_e_s_(_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test erasing peers | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_1_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt eerraassiinngg ppeeeerrss ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_11_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test update_peer_port with allow_multiple_connections_per_ip and without | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_2_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt uuppddaattee__ppeeeerr__ppoorrtt wwiitthh aallllooww__mmuullttiippllee__ccoonnnneeccttiioonnss__ppeerr__iipp aanndd wwiitthhoouutt ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_22_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test add i2p peers | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_3_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt aadddd ii22pp ppeeeerrss ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_33_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test allow_i2p_mixed | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_4_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt aallllooww__ii22pp__mmiixxeedd ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_44_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test insert_peer failing with all error conditions | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_5_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt iinnsseerrtt__ppeeeerr ffaaiilliinngg wwiitthh aallll eerrrroorr ccoonnddiittiioonnss ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_55_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test IPv6 | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_6_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt IIPPvv66 ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_66_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test connect_to_peer() failing | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_7_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt ccoonnnneecctt__ttoo__ppeeeerr(()) ffaaiilliinngg ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_77_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test connection_closed | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_8_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt ccoonnnneeccttiioonn__cclloosseedd ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_88_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |connect candidates recalculation when incrementing failcount | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_9_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ccoonnnneecctt ccaannddiiddaatteess rreeccaallccuullaattiioonn wwhheenn iinnccrreemmeennttiinngg ffaaiillccoouunntt ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_99_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___m_e_r_k_l_e___t_r_e_e_._c_p_p_: |use structured bindings in C++17 | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_2_3_3_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** uussee ssttrruuccttuurreedd bbiinnddiinnggss iinn CC++++1177 ********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__mmeerrkkllee__ttrreeee..ccpppp::223333 ****** | │ │ │ │ -|mask[std::size_t(i)] = true; | │ │ │ │ -| t.load_sparse_tree(span(f).subspan(first_piece, num_pieces), mask, empty_verified); | │ │ │ │ -| int const end_piece_layer = first_piece + merkle_num_leafs(num_pieces); | │ │ │ │ -| for (int i = 0; i < end_piece_layer; ++i) | │ │ │ │ -| { | │ │ │ │ -| TEST_CHECK(t.has_node(i)); | │ │ │ │ -| TEST_CHECK(t.compare_node(i, f[i])); | │ │ │ │ -| } | │ │ │ │ -| for (int i = end_piece_layer; i < num_nodes; ++i) | │ │ │ │ -| { | │ │ │ │ -| TEST_CHECK(!t.has_node(i)); | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___b_l_o_o_m___f_i_l_t_e_r_._c_p_p_:|test size() | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_1_3_5_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt ssiizzee(()) ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____bb_ll_oo_oo_mm____ff_ii_ll_tt_ee_rr_.._cc_pp_pp_::_11_33_55_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___b_l_o_o_m___f_i_l_t_e_r_._c_p_p_:|test clear() | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_1_3_6_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt cclleeaarr(()) ********** | │ │ │ │ +|****** ....//tteesstt//tteesstt__bblloooomm__ffiilltteerr..ccpppp::113366 ****** | │ │ │ │ +|sha1_hash k("\x01\x00\x02\x00 "); | │ │ │ │ +| TEST_CHECK(!filter.find(k)); | │ │ │ │ +| filter.set(k); | │ │ │ │ +| TEST_CHECK(filter.find(k)); | │ │ │ │ +| | │ │ │ │ +| std::uint8_t compare[4] = { 0x16, 0xff, 0x55, 0xaa}; | │ │ │ │ +| | │ │ │ │ +| bits_out = filter.to_string(); | │ │ │ │ +| TEST_EQUAL(memcmp(compare, bits_out.c_str(), 4), 0); | │ │ │ │ |} | │ │ │ │ | | │ │ │ │ -|namespace { | │ │ │ │ -|void test_roundtrip(aux::merkle_tree const& t | │ │ │ │ -| , int const block_count | │ │ │ │ -| , int const blocks_per_piece) | │ │ │ │ +|} // anonymous namespace | │ │ │ │ +| | │ │ │ │ +|TORRENT_TEST(bloom_filter) | │ │ │ │ |{ | │ │ │ │ -|aux::vector mask; | │ │ │ │ -|std::vector tree; | │ │ │ │ -| std::tie(tree, mask) = t.build_sparse_vector(); | │ │ │ │ +| test_set_and_get(); | │ │ │ │ +| test_set_bits(); | │ │ │ │ +| test_count_zeroes(); | │ │ │ │ +| test_to_from_string(); | │ │ │ │ | | │ │ │ │ -| aux::merkle_tree t2(block_count, blocks_per_piece, f[0].data()); | │ │ │ │ -| t2.load_sparse_tree(tree, mask, empty_verified); | │ │ │ │ +|_}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___d_h_t_._c_p_p_:_4_8_8_ _ _ _ _ _ _|_c_h_e_c_k_ _t_o_ _m_a_k_e_ _s_u_r_e_ _t_h_e_ _"_b_e_s_t_"_ _i_t_e_m_s_ _a_r_e_ _s_t_o_r_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** cchheecckk ttoo mmaakkee ssuurree tthhee ""bbeesstt"" iitteemmss aarree ssttoorreedd ********** | │ │ │ │ +|****** ....//tteesstt//tteesstt__ddhhtt..ccpppp::448888 ****** | │ │ │ │ +|, msg_args().target(items[j].target)); | │ │ │ │ | | │ │ │ │ -| TEST_CHECK(t.build_vector() == t2.build_vector()); | │ │ │ │ -| for (int i = 0; i < int(t.size()); ++i) | │ │ │ │ -| { | │ │ │ │ -| TEST_EQUAL(t[i], t2[i]); | │ │ │ │ -| TEST_EQUAL(t.has_node(i), t2.has_node(i)); | │ │ │ │ +| key_desc_t const desc[] = | │ │ │ │ +| { | │ │ │ │ +| { "r", bdecode_node::dict_t, 0, key_desc_t::parse_children }, | │ │ │ │ +| { "v", bdecode_node::dict_t, 0, 0}, | │ │ │ │ +| { "id", bdecode_node::string_t, 20, key_desc_t::last_child}, | │ │ │ │ +| { "y", bdecode_node::string_t, 1, 0}, | │ │ │ │ +| }; | │ │ │ │ | | │ │ │ │ -| if (!t.has_node(i)) | │ │ │ │ -| TEST_CHECK(t[i].is_all_zeros()); | │ │ │ │ -| if (!t2.has_node(i)) | │ │ │ │ -| TEST_CHECK(t2[i].is_all_zeros()); | │ │ │ │ +| bdecode_node parsed[4]; | │ │ │ │ +| char error_string[200]; | │ │ │ │ | | │ │ │ │ -| TEST_CHECK(t.compare_node(i, t2[i])); | │ │ │ │ -| TEST_CHECK(t2.compare_node(i, t[i])); | │ │ │ │ +| int ret = verify_message(response, desc, parsed, error_string); | │ │ │ │ +| if (ret) | │ │ │ │ +| { | │ │ │ │ +| items_num.insert(items_num.begin(), j); | │ │ │ │ +| } | │ │ │ │ | } | │ │ │ │ +| | │ │ │ │ +|TEST_EQUAL(items_num.size(), 4); | │ │ │ │ |} | │ │ │ │ +| | │ │ │ │ +|int sum_distance_exp(int s, node_entry const& e, node_id const& ref) | │ │ │ │ +|{ | │ │ │ │ +| return s + distance_exp(e.id, ref); | │ │ │ │ |} | │ │ │ │ | | │ │ │ │ -|TORRENT_TEST(roundtrip_empty_tree) | │ │ │ │ +|std::vector g_got_peers; | │ │ │ │ +| | │ │ │ │ +|void get_peers_cb(std::vector const& peers) | │ │ │ │ |{ | │ │ │ │ -| aux::merkle_tree t(num_blocks, 1, f[0].data()); | │ │ │ │ -| test_roundtrip(t, num_blocks, 1); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|_T_O_R_R_E_N_T___T_E_S_T_(_r_o_u_n_d_t_r_i_p___f_u_l_l___t_r_e_e_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___m_e_r_k_l_e___t_r_e_e_._c_p_p_: |add test for load_piece_layer() | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_9_9_5_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** aadddd tteesstt ffoorr llooaadd__ppiieeccee__llaayyeerr(()) ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____mm_ee_rr_kk_ll_ee____tt_rr_ee_ee_.._cc_pp_pp_::_99_99_55_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___m_e_r_k_l_e___t_r_e_e_._c_p_p_: |add test for add_hashes() with an odd number of blocks | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_9_9_6_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** aadddd tteesstt ffoorr aadddd__hhaasshheess(()) wwiitthh aann oodddd nnuummbbeerr ooff bblloocckkss ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____mm_ee_rr_kk_ll_ee____tt_rr_ee_ee_.._cc_pp_pp_::_99_99_66_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___m_e_r_k_l_e___t_r_e_e_._c_p_p_: |add test for set_block() (setting the last block) with an odd number of blocks | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_9_9_7_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** aadddd tteesstt ffoorr sseett__bblloocckk(()) ((sseettttiinngg tthhee llaasstt bblloocckk)) wwiitthh aann oodddd nnuummbbeerr ooff bblloocckkss ********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__mmeerrkkllee__ttrreeee..ccpppp::999977 ****** | │ │ │ │ -|TEST_CHECK(t.load_piece_layer(piece_layer_bytes)); | │ │ │ │ -| | │ │ │ │ -| // in piece_layer mode with bpp > 1, no blocks should report as verified | │ │ │ │ -| TEST_CHECK(t.verified_leafs() == none_set(num_blocks)); | │ │ │ │ -| | │ │ │ │ -| // after load_piece_layer the tree is back in the piece_layer-only | │ │ │ │ -| // state, so a single set_block can't yet verify against the sibling. | │ │ │ │ -| auto const result = t.set_block(0, f[511]); | │ │ │ │ -| TEST_CHECK(std::get<0>(result) == aux::merkle_tree::set_block_result::unknown); | │ │ │ │ -| | │ │ │ │ -| // the set_block above ran allocate_full(), bringing us back to full_tree | │ │ │ │ -| // mode where verified_leafs()/blocks_verified() consult m_block_verified | │ │ │ │ -| // directly (in piece_layer mode they ignore it). allocate_full's resize | │ │ │ │ -| // preserves any pre-existing bits, so had load_piece_layer failed to | │ │ │ │ -| // clear them the stale piece-0 bits would resurface as "verified" here -- | │ │ │ │ -| // catching the bug even in builds compiled without invariant checks. | │ │ │ │ -| TEST_CHECK(!t.blocks_verified(0, blocks_per_piece)); | │ │ │ │ -| TEST_CHECK(t.verified_leafs() == none_set(num_blocks)); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(add_hashes_zero_block_hash) | │ │ │ │ -|{ | │ │ │ │ -| // a peer can ask us to insert a single block hash of all zeros. that's the | │ │ │ │ -| // same value an unknown node has, so the insert must be rejected rather | │ │ │ │ -| // than silently marking the block as verified | │ │ │ │ -| aux::merkle_tree t(num_blocks, 4, f[0].data()); | │ │ │ │ -| | │ │ │ │ -| std::vector const hashes{sha256_hash{}}; | │ │ │ │ -| std::vector const proofs{rand_sha256()}; | │ │ │ │ -| | │ │ │ │ -| auto const result = t.add_hashes(merkle_first_leaf(num_leafs) + 1, pdiff(0), hashes, proofs); | │ │ │ │ -| | │ │ │ │ -| TEST_CHECK(!result); | │ │ │ │ -| TEST_CHECK(t.verified_leafs() == none_set(num_blocks)); | │ │ │ │ -|_}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___f_l_a_g_s_._c_p_p_:_1_6_3 |change to a different test setup. currently always paused. test_set_after_add(torrent_flags::paused); test_unset_after_add | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_(_t_o_r_r_e_n_t___f_l_a_g_s_:_:_p_a_u_s_e_d_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** cchhaannggee ttoo aa ddiiffffeerreenntt tteesstt sseettuupp.. ccuurrrreennttllyy aallwwaayyss ppaauusseedd.. tteesstt__sseett__aafftteerr__aadddd((ttoorrrreenntt__ffllaaggss::::ppaauusseedd));; tteesstt__uunnsseett__aafftteerr__aadddd((ttoorrrreenntt__ffllaaggss::::ppaauusseedd));; ********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__ffllaaggss..ccpppp::116633 ****** | │ │ │ │ -|{ | │ │ │ │ -| // share-mode | │ │ │ │ -| test_add_and_get_flags(torrent_flags::share_mode); | │ │ │ │ -| test_set_after_add(torrent_flags::share_mode); | │ │ │ │ -| test_unset_after_add(torrent_flags::share_mode); | │ │ │ │ -|} | │ │ │ │ -|#endif | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(flag_apply_ip_filter) | │ │ │ │ -|{ | │ │ │ │ -| // apply-ip-filter | │ │ │ │ -| test_add_and_get_flags(torrent_flags::apply_ip_filter); | │ │ │ │ -| test_set_after_add(torrent_flags::apply_ip_filter); | │ │ │ │ -| test_unset_after_add(torrent_flags::apply_ip_filter); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(flag_paused) | │ │ │ │ -|{ | │ │ │ │ -| // paused | │ │ │ │ -| test_add_and_get_flags(torrent_flags::paused); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(flag_auto_managed) | │ │ │ │ -|{ | │ │ │ │ -| // auto-managed | │ │ │ │ -| test_add_and_get_flags(torrent_flags::auto_managed); | │ │ │ │ -| test_set_after_add(torrent_flags::auto_managed); | │ │ │ │ -| test_unset_after_add(torrent_flags::auto_managed); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|// super seeding mode is automatically turned off if we're not a seed | │ │ │ │ -|// since the posix_disk_io is not threaded, this will happen immediately | │ │ │ │ -|#if TORRENT_HAVE_MMAP | │ │ │ │ -|#ifndef TORRENT_DISABLE_SUPERSEEDING | │ │ │ │ -|TORRENT_TEST(flag_super_seeding) | │ │ │ │ -|{ | │ │ │ │ -| // super-seeding | │ │ │ │ -| test_add_and_get_flags(torrent_flags::super_seeding); | │ │ │ │ -| test_unset_after_add(torrent_flags::super_seeding); | │ │ │ │ -| test_set_after_add(torrent_flags::super_seeding); | │ │ │ │ -|} | │ │ │ │ -|#endif | │ │ │ │ -|#endif | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(flag_sequential_download) | │ │ │ │ -|{ | │ │ │ │ -| // sequential-download | │ │ │ │ -| test_add_and_get_flags(torrent_flags::sequential_download); | │ │ │ │ -| test_set_after_add(torrent_flags::sequential_download); | │ │ │ │ -| test_unset_after_add(torrent_flags::sequential_download); | │ │ │ │ -|_}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___f_l_a_g_s_._c_p_p_:_2_0_5 |this test is flaky, since the torrent will become ready before asking for the flags, and by then stop_when_ready will have been | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_c_l_e_a_r_e_d_ _t_e_s_t___a_d_d___a_n_d___g_e_t___f_l_a_g_s_(_t_o_r_r_e_n_t___f_l_a_g_s_:_:_s_t_o_p___w_h_e_n___r_e_a_d_y_)_;_ _s_e_t_t_i_n_g_ _s_t_o_p_-_w_h_e_n_-_r_e_a_d_y_ _w_h_e_n_ _a_l_r_e_a_d_y_ _s_t_o_p_p_e_d_ _h_a_s_ _n_o_ _e_f_f_e_c_t_._ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tthhiiss tteesstt iiss ffllaakkyy,, ssiinnccee tthhee ttoorrrreenntt wwiillll bbeeccoommee rreeaaddyy bbeeffoorree aasskkiinngg ffoorr tthhee ffllaaggss,, aanndd bbyy tthheenn ssttoopp__wwhheenn__rreeaaddyy wwiillll hhaavvee bbeeeenn cclleeaarreedd tteesstt__aadddd__aanndd__ggeett__ffllaaggss | │ │ │ │ -|((ttoorrrreenntt__ffllaaggss::::ssttoopp__wwhheenn__rreeaaddyy));; sseettttiinngg ssttoopp--wwhheenn--rreeaaddyy wwhheenn aallrreeaaddyy ssttooppppeedd hhaass nnoo eeffffeecctt.. ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____ff_ll_aa_gg_ss_.._cc_pp_pp_::_22_00_55_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___f_l_a_g_s_._c_p_p_:_2_0_9_ _ _ _ _|_c_h_a_n_g_e_ _t_o_ _a_ _d_i_f_f_e_r_e_n_t_ _t_e_s_t_ _s_e_t_u_p_._ _c_u_r_r_e_n_t_l_y_ _a_l_w_a_y_s_ _p_a_u_s_e_d_._ _t_e_s_t___s_e_t___a_f_t_e_r___a_d_d_(_t_o_r_r_e_n_t___f_l_a_g_s_:_:_s_t_o_p___w_h_e_n___r_e_a_d_y_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** cchhaannggee ttoo aa ddiiffffeerreenntt tteesstt sseettuupp.. ccuurrrreennttllyy aallwwaayyss ppaauusseedd.. tteesstt__sseett__aafftteerr__aadddd((ttoorrrreenntt__ffllaaggss::::ssttoopp__wwhheenn__rreeaaddyy));; ********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__ffllaaggss..ccpppp::220099 ****** | │ │ │ │ -|test_set_after_add(torrent_flags::super_seeding); | │ │ │ │ -|} | │ │ │ │ -|#endif | │ │ │ │ -|#endif | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(flag_sequential_download) | │ │ │ │ -|{ | │ │ │ │ -| // sequential-download | │ │ │ │ -| test_add_and_get_flags(torrent_flags::sequential_download); | │ │ │ │ -| test_set_after_add(torrent_flags::sequential_download); | │ │ │ │ -| test_unset_after_add(torrent_flags::sequential_download); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|// the stop when ready flag will be cleared when the torrent is ready to start | │ │ │ │ -|// downloading. | │ │ │ │ -|// since the posix_disk_io is not threaded, this will happen immediately | │ │ │ │ -|#if TORRENT_HAVE_MMAP | │ │ │ │ -|TORRENT_TEST(flag_stop_when_ready) | │ │ │ │ -|{ | │ │ │ │ -| // stop-when-ready | │ │ │ │ -|test_unset_after_add(torrent_flags::stop_when_ready); | │ │ │ │ -|} | │ │ │ │ -|#endif | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(flag_disable_dht) | │ │ │ │ -|{ | │ │ │ │ -| test_add_and_get_flags(torrent_flags::disable_dht); | │ │ │ │ -| test_set_after_add(torrent_flags::disable_dht); | │ │ │ │ -| test_unset_after_add(torrent_flags::disable_dht); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(flag_disable_lsd) | │ │ │ │ -|{ | │ │ │ │ -| test_add_and_get_flags(torrent_flags::disable_lsd); | │ │ │ │ -| test_set_after_add(torrent_flags::disable_lsd); | │ │ │ │ -| test_unset_after_add(torrent_flags::disable_lsd); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|TORRENT_TEST(flag_disable_pex) | │ │ │ │ -|{ | │ │ │ │ -| test_add_and_get_flags(torrent_flags::disable_pex); | │ │ │ │ -| test_set_after_add(torrent_flags::disable_pex); | │ │ │ │ -| test_unset_after_add(torrent_flags::disable_pex); | │ │ │ │ -|_}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___f_i_l_e___s_t_o_r_a_g_e_._c_p_p_:|test file attributes | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_3_5_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt ffiillee aattttrriibbuutteess ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____ff_ii_ll_ee____ss_tt_oo_rr_aa_gg_ee_.._cc_pp_pp_::_11_22_33_55_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___f_i_l_e___s_t_o_r_a_g_e_._c_p_p_:|test symlinks | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_3_6_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt ssyymmlliinnkkss ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____ff_ii_ll_ee____ss_tt_oo_rr_aa_gg_ee_.._cc_pp_pp_::_11_22_33_66_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/ |test sending invalid requests (out of bound piece index, offsets and sizes) | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_t_e_s_t___f_a_s_t___e_x_t_e_n_s_i_o_n_._c_p_p_:_1_2_2_8_ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt sseennddiinngg iinnvvaalliidd rreeqquueessttss ((oouutt ooff bboouunndd ppiieeccee iinnddeexx,, ooffffsseettss aanndd ssiizzeess)) ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____ff_aa_ss_tt____ee_xx_tt_ee_nn_ss_ii_oo_nn_.._cc_pp_pp_::_11_22_22_88_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___d_h_t_._c_p_p_:_4_8_8_ _ _ _ _ _ _|_c_h_e_c_k_ _t_o_ _m_a_k_e_ _s_u_r_e_ _t_h_e_ _"_b_e_s_t_"_ _i_t_e_m_s_ _a_r_e_ _s_t_o_r_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** cchheecckk ttoo mmaakkee ssuurree tthhee ""bbeesstt"" iitteemmss aarree ssttoorreedd ********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__ddhhtt..ccpppp::448888 ****** | │ │ │ │ -|, msg_args().target(items[j].target)); | │ │ │ │ -| | │ │ │ │ -| key_desc_t const desc[] = | │ │ │ │ -| { | │ │ │ │ -| { "r", bdecode_node::dict_t, 0, key_desc_t::parse_children }, | │ │ │ │ -| { "v", bdecode_node::dict_t, 0, 0}, | │ │ │ │ -| { "id", bdecode_node::string_t, 20, key_desc_t::last_child}, | │ │ │ │ -| { "y", bdecode_node::string_t, 1, 0}, | │ │ │ │ -| }; | │ │ │ │ -| | │ │ │ │ -| bdecode_node parsed[4]; | │ │ │ │ -| char error_string[200]; | │ │ │ │ -| | │ │ │ │ -| int ret = verify_message(response, desc, parsed, error_string); | │ │ │ │ -| if (ret) | │ │ │ │ -| { | │ │ │ │ -| items_num.insert(items_num.begin(), j); | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -|TEST_EQUAL(items_num.size(), 4); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|int sum_distance_exp(int s, node_entry const& e, node_id const& ref) | │ │ │ │ -|{ | │ │ │ │ -| return s + distance_exp(e.id, ref); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|std::vector g_got_peers; | │ │ │ │ -| | │ │ │ │ -|void get_peers_cb(std::vector const& peers) | │ │ │ │ -|{ | │ │ │ │ -| g_got_peers.insert(g_got_peers.end(), peers.begin(), peers.end()); | │ │ │ │ +| g_got_peers.insert(g_got_peers.end(), peers.begin(), peers.end()); | │ │ │ │ |} | │ │ │ │ | | │ │ │ │ |std::vector g_got_items; | │ │ │ │ |dht::item g_put_item; | │ │ │ │ |int g_put_count; | │ │ │ │ | | │ │ │ │ |void get_mutable_item_cb(dht::item const& i, bool a) | │ │ │ │ @@ -6003,1092 +5250,796 @@ │ │ │ │ |TORRENT_TEST(dht) | │ │ │ │ |{ | │ │ │ │ | // dummy dht test | │ │ │ │ | TEST_CHECK(true); | │ │ │ │ |} | │ │ │ │ | | │ │ │ │ |_#_e_n_d_i_f_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___b_l_o_o_m___f_i_l_t_e_r_._c_p_p_:|test size() | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_1_3_5_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt ssiizzee(()) ********** | │ │ │ │ -|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____bb_ll_oo_oo_mm____ff_ii_ll_tt_ee_rr_.._cc_pp_pp_::_11_33_55_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___b_l_o_o_m___f_i_l_t_e_r_._c_p_p_:|test clear() | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_1_3_6_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tteesstt cclleeaarr(()) ********** | │ │ │ │ -|****** ....//tteesstt//tteesstt__bblloooomm__ffiilltteerr..ccpppp::113366 ****** | │ │ │ │ -|sha1_hash k("\x01\x00\x02\x00 "); | │ │ │ │ -| TEST_CHECK(!filter.find(k)); | │ │ │ │ -| filter.set(k); | │ │ │ │ -| TEST_CHECK(filter.find(k)); | │ │ │ │ -| | │ │ │ │ -| std::uint8_t compare[4] = { 0x16, 0xff, 0x55, 0xaa}; | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___t_r_a_c_k_e_r_._c_p_p_:_6_0_ _ _ _|_t_e_s_t_ _s_c_r_a_p_e_ _r_e_q_u_e_s_t_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt ssccrraappee rreeqquueessttss ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_rr_aa_cc_kk_ee_rr_.._cc_pp_pp_::_66_00_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___t_r_a_c_k_e_r_._c_p_p_:_6_1_ _ _ _|_t_e_s_t_ _p_a_r_s_e_ _p_e_e_r_s_6_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt ppaarrssee ppeeeerrss66 ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_rr_aa_cc_kk_ee_rr_.._cc_pp_pp_::_66_11_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___t_r_a_c_k_e_r_._c_p_p_:_6_2_ _ _ _|_t_e_s_t_ _p_a_r_s_e_ _t_r_a_c_k_e_r_-_i_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt ppaarrssee ttrraacckkeerr--iidd ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_rr_aa_cc_kk_ee_rr_.._cc_pp_pp_::_66_22_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___t_r_a_c_k_e_r_._c_p_p_:_6_3_ _ _ _|_t_e_s_t_ _p_a_r_s_e_ _f_a_i_l_u_r_e_-_r_e_a_s_o_n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt ppaarrssee ffaaiilluurree--rreeaassoonn ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____tt_rr_aa_cc_kk_ee_rr_.._cc_pp_pp_::_66_33_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___t_r_a_c_k_e_r_._c_p_p_:_6_4 |test all failure paths, including invalid bencoding not a dictionary no files entry in scrape response no info-hash entry in scrape | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_r_e_s_p_o_n_s_e_ _m_a_l_f_o_r_m_e_d_ _p_e_e_r_s_ _i_n_ _p_e_e_r_ _l_i_s_t_ _o_f_ _d_i_c_t_i_o_n_a_r_i_e_s_ _u_n_e_v_e_n_ _n_u_m_b_e_r_ _o_f_ _b_y_t_e_s_ _i_n_ _p_e_e_r_s_ _a_n_d_ _p_e_e_r_s_6_ _s_t_r_i_n_g_ _r_e_s_p_o_n_s_e_s_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt aallll ffaaiilluurree ppaatthhss,, iinncclluuddiinngg iinnvvaalliidd bbeennccooddiinngg nnoott aa ddiiccttiioonnaarryy nnoo ffiilleess eennttrryy iinn ssccrraappee rreessppoonnssee nnoo iinnffoo--hhaasshh eennttrryy iinn ssccrraappee rreessppoonnssee mmaallffoorrmmeedd ppeeeerrss iinn ppeeeerr lliisstt| │ │ │ │ +|ooff ddiiccttiioonnaarriieess uunneevveenn nnuummbbeerr ooff bbyytteess iinn ppeeeerrss aanndd ppeeeerrss66 ssttrriinngg rreessppoonnsseess ********** | │ │ │ │ +|****** ....//tteesstt//tteesstt__ttrraacckkeerr..ccpppp::6644 ****** | │ │ │ │ +|#include "test_utils.hpp" | │ │ │ │ +|#include "udp_tracker.hpp" | │ │ │ │ +|#include "settings.hpp" | │ │ │ │ +|#include "test_utils.hpp" | │ │ │ │ +|#include "libtorrent/alert.hpp" | │ │ │ │ +|#include "libtorrent/peer_info.hpp" // for peer_list_entry | │ │ │ │ +|#include "libtorrent/alert_types.hpp" | │ │ │ │ +|#include "libtorrent/session.hpp" | │ │ │ │ +|#include "libtorrent/session_params.hpp" | │ │ │ │ +|#include "libtorrent/error_code.hpp" | │ │ │ │ +|#include "libtorrent/tracker_manager.hpp" | │ │ │ │ +|#include "libtorrent/http_tracker_connection.hpp" // for parse_tracker_response | │ │ │ │ +|#include "libtorrent/torrent_info.hpp" | │ │ │ │ +|#include "libtorrent/announce_entry.hpp" | │ │ │ │ +|#include "libtorrent/torrent.hpp" | │ │ │ │ +|#include "libtorrent/aux_/path.hpp" | │ │ │ │ +|#include "libtorrent/socket_io.hpp" | │ │ │ │ | | │ │ │ │ -| bits_out = filter.to_string(); | │ │ │ │ -| TEST_EQUAL(memcmp(compare, bits_out.c_str(), 4), 0); | │ │ │ │ -|} | │ │ │ │ +|using namespace lt; | │ │ │ │ | | │ │ │ │ -|} // anonymous namespace | │ │ │ │ | | │ │ │ │ -|TORRENT_TEST(bloom_filter) | │ │ │ │ +|TORRENT_TEST(parse_hostname_peers) | │ │ │ │ |{ | │ │ │ │ -| test_set_and_get(); | │ │ │ │ -| test_set_bits(); | │ │ │ │ -| test_count_zeroes(); | │ │ │ │ -| test_to_from_string(); | │ │ │ │ +| char const response[] = "d5:peersld7:peer id20:aaaaaaaaaaaaaaaaaaaa" | │ │ │ │ +| "2:ip13:test_hostname4:porti1000eed" | │ │ │ │ +| "7:peer id20:bbbbabaababababababa2:ip12:another_host4:porti1001eeee"; | │ │ │ │ +| error_code ec; | │ │ │ │ +| tracker_response resp = parse_tracker_response(response | │ │ │ │ +| , ec, {}, sha1_hash()); | │ │ │ │ | | │ │ │ │ -|_}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_s_r_c_/ |introduce a web-seed default class which has a low download priority | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_w_e_b___c_o_n_n_e_c_t_i_o_n___b_a_s_e_._c_p_p_:_7_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** iinnttrroodduuccee aa wweebb--sseeeedd ddeeffaauulltt ccllaassss wwhhiicchh hhaass aa llooww ddoowwnnllooaadd pprriioorriittyy ********** | │ │ │ │ -|****** ....//ssrrcc//wweebb__ccoonnnneeccttiioonn__bbaassee..ccpppp::7733 ****** | │ │ │ │ -|: peer_connection(pack) | │ │ │ │ -| , m_first_request(true) | │ │ │ │ -| , m_ssl(false) | │ │ │ │ -| , m_external_auth(web.auth) | │ │ │ │ -| , m_extra_headers(web.extra_headers) | │ │ │ │ -| , m_parser(http_parser::dont_parse_chunks) | │ │ │ │ -| , m_body_start(0) | │ │ │ │ +| TEST_EQUAL(ec, error_code()); | │ │ │ │ +| TEST_EQUAL(resp.peers.size(), 2); | │ │ │ │ +| if (resp.peers.size() == 2) | │ │ │ │ | { | │ │ │ │ -| TORRENT_ASSERT(&web.peer_info == pack.peerinfo); | │ │ │ │ -| // when going through a proxy, we don't necessarily have an endpoint here, | │ │ │ │ -| // since the proxy might be resolving the hostname, not us | │ │ │ │ -| TORRENT_ASSERT(web.endpoints.empty() || web.endpoints.front() == pack.endp); | │ │ │ │ -| | │ │ │ │ -| INVARIANT_CHECK; | │ │ │ │ -| | │ │ │ │ -| TORRENT_ASSERT(is_outgoing()); | │ │ │ │ -| | │ │ │ │ -| TORRENT_ASSERT(!m_torrent.lock()->is_upload_only()); | │ │ │ │ -| | │ │ │ │ -| // we only want left-over bandwidth | │ │ │ │ -| | │ │ │ │ -|std::string protocol; | │ │ │ │ -| error_code ec; | │ │ │ │ -| std::tie(protocol, m_basic_auth, m_host, m_port, m_path) | │ │ │ │ -| = parse_url_components(web.url, ec); | │ │ │ │ -| TORRENT_ASSERT(!ec); | │ │ │ │ -| | │ │ │ │ -| if (m_port == -1 && protocol == "http") | │ │ │ │ -| m_port = 80; | │ │ │ │ -| | │ │ │ │ -|#if TORRENT_USE_SSL | │ │ │ │ -| if (protocol == "https") | │ │ │ │ -| { | │ │ │ │ -| m_ssl = true; | │ │ │ │ -| if (m_port == -1) m_port = 443; | │ │ │ │ -| } | │ │ │ │ -|#endif | │ │ │ │ -| | │ │ │ │ -| if (!m_basic_auth.empty()) | │ │ │ │ -| m_basic_auth = base64encode(m_basic_auth); | │ │ │ │ +| peer_entry const& e0 = resp.peers[0]; | │ │ │ │ +| peer_entry const& e1 = resp.peers[1]; | │ │ │ │ +| TEST_EQUAL(e0.hostname, "test_hostname"); | │ │ │ │ +| TEST_EQUAL(e0.port, 1000); | │ │ │ │ +| TEST_EQUAL(e0.pid, peer_id("aaaaaaaaaaaaaaaaaaaa")); | │ │ │ │ | | │ │ │ │ -| m_server_string = m_host; | │ │ │ │ -| aux::verify_encoding(m_server_string); | │ │ │ │ +| TEST_EQUAL(e1.hostname, "another_host"); | │ │ │ │ +| TEST_EQUAL(e1.port, 1001); | │ │ │ │ +| TEST_EQUAL(e1.pid, peer_id("bbbbabaababababababa")); | │ │ │ │ | } | │ │ │ │ +|} | │ │ │ │ | | │ │ │ │ -| int web_connection_base::timeout() const | │ │ │ │ -| { | │ │ │ │ -| // since this is a web seed, change the timeout | │ │ │ │ -| // according to the settings. | │ │ │ │ -| return m_settings.get_int(settings_pack::urlseed_timeout); | │ │ │ │ -|_ _}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_s_r_c_/_u_t_p___s_o_c_k_e_t___m_a_n_a_g_e_r_._c_p_p_:|this should not be heap allocated, sockets should be movable | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_2_0_4_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tthhiiss sshhoouulldd nnoott bbee hheeaapp aallllooccaatteedd,, ssoocckkeettss sshhoouulldd bbee mmoovvaabbllee ********** | │ │ │ │ -|****** ....//ssrrcc//uuttpp__ssoocckkeett__mmaannaaggeerr..ccpppp::220044 ****** | │ │ │ │ -|// UTP_LOGV("incoming packet id:%d source:%s\n", id, print_endpoint(ep).c_str()); | │ │ │ │ -| | │ │ │ │ -| if (!m_sett.get_bool(settings_pack::enable_incoming_utp)) | │ │ │ │ -| return false; | │ │ │ │ +|TORRENT_TEST(parse_peers4) | │ │ │ │ +|{ | │ │ │ │ +| char const response[] = "d5:peers12:\x01\x02\x03\x04\x30\x10" | │ │ │ │ +| "\x09\x08\x07\x06\x20\x10" "e"; | │ │ │ │ +|_ _e_r_r_o_r___c_o_d_e_ _e_c_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___t_r_a_n_s_f_e_r_._c_p_p_:_1_7_3_ _|_t_h_e_s_e_ _s_e_t_t_i_n_g_s___p_a_c_k_ _t_e_s_t_s_ _b_e_l_o_n_g_ _i_n_ _t_h_e_i_r_ _o_w_n_ _t_e_s_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tthheessee sseettttiinnggss__ppaacckk tteessttss bbeelloonngg iinn tthheeiirr oowwnn tteesstt ********** | │ │ │ │ +|****** ....//tteesstt//tteesstt__ttrraannssffeerr..ccpppp::117733 ****** | │ │ │ │ +|// to the time it will take to complete the test | │ │ │ │ +| pack.set_int(settings_pack::min_reconnect_time, 0); | │ │ │ │ +| pack.set_int(settings_pack::stop_tracker_timeout, 1); | │ │ │ │ +| pack.set_bool(settings_pack::announce_to_all_trackers, true); | │ │ │ │ +| pack.set_bool(settings_pack::announce_to_all_tiers, true); | │ │ │ │ | | │ │ │ │ -| // if not found, see if it's a SYN packet, if it is, | │ │ │ │ -| // create a new utp_stream | │ │ │ │ -| if (ph->get_type() == ST_SYN) | │ │ │ │ -| { | │ │ │ │ -| // possible SYN flood. Just ignore | │ │ │ │ -| if (int(m_utp_sockets.size()) > m_sett.get_int(settings_pack::connections_limit) * 2) | │ │ │ │ -| return false; | │ │ │ │ +| // make sure we announce to both http and udp trackers | │ │ │ │ +| pack.set_bool(settings_pack::prefer_udp_trackers, false); | │ │ │ │ +| pack.set_bool(settings_pack::enable_outgoing_utp, false); | │ │ │ │ +| pack.set_bool(settings_pack::enable_incoming_utp, false); | │ │ │ │ +| pack.set_bool(settings_pack::enable_lsd, false); | │ │ │ │ +| pack.set_bool(settings_pack::enable_natpmp, false); | │ │ │ │ +| pack.set_bool(settings_pack::enable_upnp, false); | │ │ │ │ +| pack.set_bool(settings_pack::enable_dht, false); | │ │ │ │ | | │ │ │ │ -| TORRENT_ASSERT(m_new_connection == -1); | │ │ │ │ -| // create the new socket with this ID | │ │ │ │ -| m_new_connection = id; | │ │ │ │ +| pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_disabled); | │ │ │ │ +| pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_disabled); | │ │ │ │ | | │ │ │ │ -|// UTP_LOGV("not found, new connection id:%d\n", m_new_connection); | │ │ │ │ +| pack.set_bool(settings_pack::allow_multiple_connections_per_ip, false); | │ │ │ │ | | │ │ │ │ -|aux::socket_type c(aux::instantiate_connection(m_ios, aux::proxy_settings(), m_ssl_context, this, true, false)); | │ │ │ │ +|pack.set_int(settings_pack::unchoke_slots_limit, 0); | │ │ │ │ +|ses1.apply_settings(pack); | │ │ │ │ +| TEST_CHECK(ses1.get_settings().get_int(settings_pack::unchoke_slots_limit) == 0); | │ │ │ │ | | │ │ │ │ -| utp_stream* str = nullptr; | │ │ │ │ -|#ifdef TORRENT_SSL_PEERS | │ │ │ │ -| if (is_ssl(c)) | │ │ │ │ -| str = &boost::get>(c).next_layer(); | │ │ │ │ -| else | │ │ │ │ -|#endif | │ │ │ │ -| str = boost::get(&c); | │ │ │ │ +| pack.set_int(settings_pack::unchoke_slots_limit, -1); | │ │ │ │ +| ses1.apply_settings(pack); | │ │ │ │ +| TEST_CHECK(ses1.get_settings().get_int(settings_pack::unchoke_slots_limit) == -1); | │ │ │ │ | | │ │ │ │ -| TORRENT_ASSERT(str); | │ │ │ │ -| int const mtu = mtu_for_dest(ep.address()); | │ │ │ │ -| str->get_impl()->init_mtu(mtu); | │ │ │ │ -| str->get_impl()->m_sock = std::move(socket); | │ │ │ │ -| bool const ret = str->get_impl()->incoming_packet(p, ep, receive_time); | │ │ │ │ -| if (!ret) return false; | │ │ │ │ -| m_last_socket = str->get_impl(); | │ │ │ │ -| m_cb(std::move(c)); | │ │ │ │ -| // the connection most likely changed its connection ID here | │ │ │ │ -| // we need to move it to the correct ID | │ │ │ │ -| return true; | │ │ │ │ -| } | │ │ │ │ +| pack.set_int(settings_pack::unchoke_slots_limit, 8); | │ │ │ │ +| ses1.apply_settings(pack); | │ │ │ │ +| TEST_CHECK(ses1.get_settings().get_int(settings_pack::unchoke_slots_limit) == 8); | │ │ │ │ | | │ │ │ │ -| if (ph->get_type() == ST_RESET) return false; | │ │ │ │ +| ses2.apply_settings(pack); | │ │ │ │ | | │ │ │ │ -| // #error send reset | │ │ │ │ +| torrent_handle tor1; | │ │ │ │ +| torrent_handle tor2; | │ │ │ │ | | │ │ │ │ -| return false; | │ │ │ │ -| } | │ │ │ │ +| create_directory("tmp1_transfer", ec); | │ │ │ │ +| std::ofstream file("tmp1_transfer/temporary"); | │ │ │ │ +| std::shared_ptr t = ::create_torrent(&file, "temporary", 32 * 1024, 13, false); | │ │ │ │ +| file.close(); | │ │ │ │ | | │ │ │ │ -|_ _v_o_i_d_ _u_t_p___s_o_c_k_e_t___m_a_n_a_g_e_r_:_:_s_u_b_s_c_r_i_b_e___w_r_i_t_a_b_l_e_(_u_t_p___s_o_c_k_e_t___i_m_p_l_*_ _s_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_s_r_c_/_u_t___m_e_t_a_d_a_t_a_._c_p_p_:_2_8_1_ _ _ _ _|_w_e_ _r_e_a_l_l_y_ _n_e_e_d_ _t_o_ _i_n_c_r_e_m_e_n_t_ _t_h_e_ _r_e_f_c_o_u_n_t_e_r_ _o_n_ _t_h_e_ _t_o_r_r_e_n_t_ _w_h_i_l_e_ _t_h_i_s_ _b_u_f_f_e_r_ _i_s_ _s_t_i_l_l_ _i_n_ _t_h_e_ _p_e_e_r_'_s_ _s_e_n_d_ _b_u_f_f_e_r_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** wwee rreeaallllyy nneeeedd ttoo iinnccrreemmeenntt tthhee rreeffccoouunntteerr oonn tthhee ttoorrrreenntt wwhhiillee tthhiiss bbuuffffeerr iiss ssttiillll iinn tthhee ppeeeerr''ss sseenndd bbuuffffeerr ********** | │ │ │ │ -|****** ....//ssrrcc//uutt__mmeettaaddaattaa..ccpppp::228811 ****** | │ │ │ │ -|int const offset = piece * 16 * 1024; | │ │ │ │ -| metadata = m_tp.metadata().data() + offset; | │ │ │ │ -| metadata_piece_size = std::min( | │ │ │ │ -| int(m_tp.metadata().size()) - offset, 16 * 1024); | │ │ │ │ -| TORRENT_ASSERT(metadata_piece_size > 0); | │ │ │ │ -| TORRENT_ASSERT(offset >= 0); | │ │ │ │ -| TORRENT_ASSERT(offset + metadata_piece_size <= m_tp.metadata().size()); | │ │ │ │ -| } | │ │ │ │ +| TEST_CHECK(exists(combine_path("tmp1_transfer", "temporary"))); | │ │ │ │ | | │ │ │ │ -| char msg[200]; | │ │ │ │ -| char* header = msg; | │ │ │ │ -| char* p = &msg[6]; | │ │ │ │ -| int const len = bencode(p, e); | │ │ │ │ -| int const total_size = 2 + len + metadata_piece_size; | │ │ │ │ -| namespace io = aux; | │ │ │ │ -| io::write_uint32(total_size, header); | │ │ │ │ -| io::write_uint8(bt_peer_connection::msg_extended, header); | │ │ │ │ -| io::write_uint8(m_message_index, header); | │ │ │ │ +| add_torrent_params params; | │ │ │ │ +| params.storage_mode = storage_mode; | │ │ │ │ +| params.flags &= ~torrent_flags::paused; | │ │ │ │ +| params.flags &= ~torrent_flags::auto_managed; | │ │ │ │ | | │ │ │ │ -| m_pc.send_buffer({msg, len + 6}); | │ │ │ │ -|if (metadata_piece_size) | │ │ │ │ +| wait_for_listen(ses1, "ses1"); | │ │ │ │ +|_ _w_a_i_t___f_o_r___l_i_s_t_e_n_(_s_e_s_2_,_ _"_s_e_s_2_"_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test erasing peers | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_1_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt eerraassiinngg ppeeeerrss ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_11_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test update_peer_port with allow_multiple_connections_per_ip and without | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_2_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt uuppddaattee__ppeeeerr__ppoorrtt wwiitthh aallllooww__mmuullttiippllee__ccoonnnneeccttiioonnss__ppeerr__iipp aanndd wwiitthhoouutt ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_22_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test add i2p peers | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_3_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt aadddd ii22pp ppeeeerrss ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_33_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test allow_i2p_mixed | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_4_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt aallllooww__ii22pp__mmiixxeedd ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_44_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test insert_peer failing with all error conditions | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_5_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt iinnsseerrtt__ppeeeerr ffaaiilliinngg wwiitthh aallll eerrrroorr ccoonnddiittiioonnss ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_55_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test IPv6 | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_6_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt IIPPvv66 ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_66_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test connect_to_peer() failing | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_7_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt ccoonnnneecctt__ttoo__ppeeeerr(()) ffaaiilliinngg ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_77_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |test connection_closed | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_8_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tteesstt ccoonnnneeccttiioonn__cclloosseedd ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_88_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___p_e_e_r___l_i_s_t_._c_p_p_: |connect candidates recalculation when incrementing failcount | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_1_2_9_9_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** ccoonnnneecctt ccaannddiiddaatteess rreeccaallccuullaattiioonn wwhheenn iinnccrreemmeennttiinngg ffaaiillccoouunntt ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____pp_ee_ee_rr____ll_ii_ss_tt_.._cc_pp_pp_::_11_22_99_99_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___f_l_a_g_s_._c_p_p_:_1_6_3 |change to a different test setup. currently always paused. test_set_after_add(torrent_flags::paused); test_unset_after_add | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_(_t_o_r_r_e_n_t___f_l_a_g_s_:_:_p_a_u_s_e_d_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** cchhaannggee ttoo aa ddiiffffeerreenntt tteesstt sseettuupp.. ccuurrrreennttllyy aallwwaayyss ppaauusseedd.. tteesstt__sseett__aafftteerr__aadddd((ttoorrrreenntt__ffllaaggss::::ppaauusseedd));; tteesstt__uunnsseett__aafftteerr__aadddd((ttoorrrreenntt__ffllaaggss::::ppaauusseedd));; ********** | │ │ │ │ +|****** ....//tteesstt//tteesstt__ffllaaggss..ccpppp::116633 ****** | │ │ │ │ |{ | │ │ │ │ -| m_pc.append_const_send_buffer( | │ │ │ │ -| span(const_cast(metadata), metadata_piece_size), metadata_piece_size); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_extended); | │ │ │ │ -| m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_metadata); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| bool on_extended(int const length | │ │ │ │ -| , int const extended_msg, span body) override | │ │ │ │ -| { | │ │ │ │ -| if (extended_msg != 2) return false; | │ │ │ │ -| if (m_message_index == 0) return false; | │ │ │ │ -| | │ │ │ │ -| if (length > 17 * 1024) | │ │ │ │ -| { | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| m_pc.peer_log(peer_log_alert::incoming_message, "UT_METADATA" | │ │ │ │ -| , "packet too big %d", length); | │ │ │ │ +| // share-mode | │ │ │ │ +| test_add_and_get_flags(torrent_flags::share_mode); | │ │ │ │ +| test_set_after_add(torrent_flags::share_mode); | │ │ │ │ +| test_unset_after_add(torrent_flags::share_mode); | │ │ │ │ +|} | │ │ │ │ |#endif | │ │ │ │ -| m_pc.disconnect(errors::invalid_metadata_message, operation_t::bittorrent, peer_connection_interface::peer_error); | │ │ │ │ -| return true; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| if (!m_pc.packet_finished()) return true; | │ │ │ │ -| | │ │ │ │ -| error_code ec; | │ │ │ │ -| bdecode_node msg = bdecode(body, ec); | │ │ │ │ -|_ _ _ _i_f_ _(_m_s_g_._t_y_p_e_(_)_ _!_=_ _b_d_e_c_o_d_e___n_o_d_e_:_:_d_i_c_t___t_)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|relevance 0|_._._/_s_r_c_/ |why is this a linked list? | │ │ │ │ -|_ _ _ _ _ _ _ _ _ _ _ _|_u_d_p___t_r_a_c_k_e_r___c_o_n_n_e_c_t_i_o_n_._c_p_p_:_6_3_3_|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** wwhhyy iiss tthhiiss aa lliinnkkeedd lliisstt?? ********** | │ │ │ │ -|****** ....//ssrrcc//uuddpp__ttrraacckkeerr__ccoonnnneeccttiioonn..ccpppp::663333 ****** | │ │ │ │ -|ipv6_peer_entry e{}; | │ │ │ │ -| std::memcpy(e.ip.data(), buf.data(), 16); | │ │ │ │ -| buf = buf.subspan(16); | │ │ │ │ -| e.port = aux::read_uint16(buf); | │ │ │ │ -| resp.peers6.push_back(e); | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ -| else | │ │ │ │ -| { | │ │ │ │ -| resp.peers4.reserve(static_cast(num_peers)); | │ │ │ │ -| for (int i = 0; i < num_peers; ++i) | │ │ │ │ -| { | │ │ │ │ -| ipv4_peer_entry e{}; | │ │ │ │ -| std::memcpy(e.ip.data(), buf.data(), 4); | │ │ │ │ -| buf = buf.subspan(4); | │ │ │ │ -| e.port = aux::read_uint16(buf); | │ │ │ │ -| resp.peers4.push_back(e); | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -|std::list
    ip_list; | │ │ │ │ -|std::transform(m_endpoints.begin(), m_endpoints.end(), std::back_inserter(ip_list) | │ │ │ │ -| , [](tcp::endpoint const& ep) { return ep.address(); } ); | │ │ │ │ -| | │ │ │ │ -| // about to report the response below; mark it as no longer pending | │ │ │ │ -| // first, so a fail() already posted (e.g. by | │ │ │ │ -| // tracker_manager::abort_all_requests() racing this response) finds | │ │ │ │ -| // nothing left to report when it runs. | │ │ │ │ -| m_req_pending = false; | │ │ │ │ -| cb->tracker_response(tracker_req(), m_target.address(), ip_list, resp); | │ │ │ │ | | │ │ │ │ -| close(); | │ │ │ │ -| return true; | │ │ │ │ -| } | │ │ │ │ +|TORRENT_TEST(flag_apply_ip_filter) | │ │ │ │ +|{ | │ │ │ │ +| // apply-ip-filter | │ │ │ │ +| test_add_and_get_flags(torrent_flags::apply_ip_filter); | │ │ │ │ +| test_set_after_add(torrent_flags::apply_ip_filter); | │ │ │ │ +| test_unset_after_add(torrent_flags::apply_ip_filter); | │ │ │ │ +|} | │ │ │ │ | | │ │ │ │ -| bool udp_tracker_connection::on_scrape_response(span buf) | │ │ │ │ -| { | │ │ │ │ -| restart_read_timeout(); | │ │ │ │ -| auto const action = static_cast(aux::read_int32(buf)); | │ │ │ │ -| std::uint32_t const transaction = aux::read_uint32(buf); | │ │ │ │ +|TORRENT_TEST(flag_paused) | │ │ │ │ +|{ | │ │ │ │ +| // paused | │ │ │ │ +| test_add_and_get_flags(torrent_flags::paused); | │ │ │ │ +|} | │ │ │ │ | | │ │ │ │ -| if (transaction != m_transaction_id) | │ │ │ │ -| { | │ │ │ │ -| fail(error_code(errors::invalid_tracker_transaction_id), operation_t::bittorrent); | │ │ │ │ -| return false; | │ │ │ │ -| } | │ │ │ │ +|TORRENT_TEST(flag_auto_managed) | │ │ │ │ +|{ | │ │ │ │ +| // auto-managed | │ │ │ │ +| test_add_and_get_flags(torrent_flags::auto_managed); | │ │ │ │ +| test_set_after_add(torrent_flags::auto_managed); | │ │ │ │ +| test_unset_after_add(torrent_flags::auto_managed); | │ │ │ │ +|} | │ │ │ │ | | │ │ │ │ -| if (action == action_t::error) | │ │ │ │ -| { | │ │ │ │ -| fail(error_code(errors::tracker_failure), operation_t::bittorrent | │ │ │ │ -|_ _ _ _ _,_ _s_t_d_:_:_s_t_r_i_n_g_(_b_u_f_._d_a_t_a_(_)_,_ _s_t_a_t_i_c___c_a_s_t_<_s_t_d_:_:_s_i_z_e___t_>_(_b_u_f_._s_i_z_e_(_)_)_)_._c___s_t_r_(_)_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_s_r_c_/_u_d_p___s_o_c_k_e_t_._c_p_p_:_6_7_0_ _ _ _ _ _|_p_e_r_h_a_p_s_ _a_n_ _a_t_t_e_m_p_t_ _s_h_o_u_l_d_ _b_e_ _m_a_d_e_ _t_o_ _b_i_n_d_ _m___s_o_c_k_s_5___s_o_c_k_ _t_o_ _t_h_e_ _d_e_v_i_c_e_ _o_f_ _m___l_i_s_t_e_n___s_o_c_k_e_t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ppeerrhhaappss aann aatttteemmpptt sshhoouulldd bbee mmaaddee ttoo bbiinndd mm__ssoocckkss55__ssoocckk ttoo tthhee ddeevviiccee ooff mm__lliisstteenn__ssoocckkeett ********** | │ │ │ │ -|****** ....//ssrrcc//uuddpp__ssoocckkeett..ccpppp::667700 ****** | │ │ │ │ -|if (ec) | │ │ │ │ -| { | │ │ │ │ -| if (m_alerts.should_post()) | │ │ │ │ -| m_alerts.emplace_alert(m_proxy_addr, operation_t::sock_option, ec); | │ │ │ │ -| ec.clear(); | │ │ │ │ -| } | │ │ │ │ +|// super seeding mode is automatically turned off if we're not a seed | │ │ │ │ +|// since the posix_disk_io is not threaded, this will happen immediately | │ │ │ │ +|#if TORRENT_HAVE_MMAP | │ │ │ │ +|#ifndef TORRENT_DISABLE_SUPERSEEDING | │ │ │ │ +|TORRENT_TEST(flag_super_seeding) | │ │ │ │ +|{ | │ │ │ │ +| // super-seeding | │ │ │ │ +| test_add_and_get_flags(torrent_flags::super_seeding); | │ │ │ │ +| test_unset_after_add(torrent_flags::super_seeding); | │ │ │ │ +| test_set_after_add(torrent_flags::super_seeding); | │ │ │ │ +|} | │ │ │ │ |#endif | │ │ │ │ |#endif | │ │ │ │ | | │ │ │ │ -| tcp::endpoint const bind_ep(m_listen_socket.get_local_endpoint().address(), 0); | │ │ │ │ -| m_socks5_sock.bind(bind_ep, ec); | │ │ │ │ -| if (ec) | │ │ │ │ -| { | │ │ │ │ -| if (m_alerts.should_post()) | │ │ │ │ -| m_alerts.emplace_alert(m_proxy_addr, operation_t::sock_bind, ec); | │ │ │ │ -| ++m_failures; | │ │ │ │ -| retry_connection(); | │ │ │ │ -| return; | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -| | │ │ │ │ -|ADD_OUTSTANDING_ASYNC("socks5::on_connected"); | │ │ │ │ -| m_socks5_sock.async_connect(m_proxy_addr | │ │ │ │ -| , std::bind(&socks5::on_connected, self(), _1)); | │ │ │ │ -| | │ │ │ │ -| ADD_OUTSTANDING_ASYNC("socks5::on_connect_timeout"); | │ │ │ │ -| m_timer.expires_after(seconds(10)); | │ │ │ │ -| m_timer.async_wait(std::bind(&socks5::on_connect_timeout | │ │ │ │ -| , self(), _1)); | │ │ │ │ -|} | │ │ │ │ -| | │ │ │ │ -|void socks5::on_connect_timeout(error_code const& e) | │ │ │ │ +|TORRENT_TEST(flag_sequential_download) | │ │ │ │ |{ | │ │ │ │ -| COMPLETE_ASYNC("socks5::on_connect_timeout"); | │ │ │ │ -| | │ │ │ │ -| if (e == boost::asio::error::operation_aborted) return; | │ │ │ │ -| | │ │ │ │ -| if (m_abort) return; | │ │ │ │ -| | │ │ │ │ -| if (m_alerts.should_post()) | │ │ │ │ -| m_alerts.emplace_alert(m_proxy_addr, operation_t::connect, errors::timed_out); | │ │ │ │ -| | │ │ │ │ -| error_code ignore; | │ │ │ │ -| m_socks5_sock.close(ignore); | │ │ │ │ -| | │ │ │ │ -| ++m_failures; | │ │ │ │ -| retry_connection(); | │ │ │ │ +| // sequential-download | │ │ │ │ +| test_add_and_get_flags(torrent_flags::sequential_download); | │ │ │ │ +| test_set_after_add(torrent_flags::sequential_download); | │ │ │ │ +| test_unset_after_add(torrent_flags::sequential_download); | │ │ │ │ +|_}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|relevance 0|_._._/_t_e_s_t_/_t_e_s_t___f_l_a_g_s_._c_p_p_:_2_0_5 |this test is flaky, since the torrent will become ready before asking for the flags, and by then stop_when_ready will have been | │ │ │ │ +|_ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_c_l_e_a_r_e_d_ _t_e_s_t___a_d_d___a_n_d___g_e_t___f_l_a_g_s_(_t_o_r_r_e_n_t___f_l_a_g_s_:_:_s_t_o_p___w_h_e_n___r_e_a_d_y_)_;_ _s_e_t_t_i_n_g_ _s_t_o_p_-_w_h_e_n_-_r_e_a_d_y_ _w_h_e_n_ _a_l_r_e_a_d_y_ _s_t_o_p_p_e_d_ _h_a_s_ _n_o_ _e_f_f_e_c_t_._ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** tthhiiss tteesstt iiss ffllaakkyy,, ssiinnccee tthhee ttoorrrreenntt wwiillll bbeeccoommee rreeaaddyy bbeeffoorree aasskkiinngg ffoorr tthhee ffllaaggss,, aanndd bbyy tthheenn ssttoopp__wwhheenn__rreeaaddyy wwiillll hhaavvee bbeeeenn cclleeaarreedd tteesstt__aadddd__aanndd__ggeett__ffllaaggss | │ │ │ │ +|((ttoorrrreenntt__ffllaaggss::::ssttoopp__wwhheenn__rreeaaddyy));; sseettttiinngg ssttoopp--wwhheenn--rreeaaddyy wwhheenn aallrreeaaddyy ssttooppppeedd hhaass nnoo eeffffeecctt.. ********** | │ │ │ │ +|_**_**_**_ _.._.._//_tt_ee_ss_tt_//_tt_ee_ss_tt____ff_ll_aa_gg_ss_.._cc_pp_pp_::_22_00_55_ _**_**_**_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_t_e_s_t_/_t_e_s_t___f_l_a_g_s_._c_p_p_:_2_0_9_ _ _ _ _|_c_h_a_n_g_e_ _t_o_ _a_ _d_i_f_f_e_r_e_n_t_ _t_e_s_t_ _s_e_t_u_p_._ _c_u_r_r_e_n_t_l_y_ _a_l_w_a_y_s_ _p_a_u_s_e_d_._ _t_e_s_t___s_e_t___a_f_t_e_r___a_d_d_(_t_o_r_r_e_n_t___f_l_a_g_s_:_:_s_t_o_p___w_h_e_n___r_e_a_d_y_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|********** cchhaannggee ttoo aa ddiiffffeerreenntt tteesstt sseettuupp.. ccuurrrreennttllyy aallwwaayyss ppaauusseedd.. tteesstt__sseett__aafftteerr__aadddd((ttoorrrreenntt__ffllaaggss::::ssttoopp__wwhheenn__rreeaaddyy));; ********** | │ │ │ │ +|****** ....//tteesstt//tteesstt__ffllaaggss..ccpppp::220099 ****** | │ │ │ │ +|test_set_after_add(torrent_flags::super_seeding); | │ │ │ │ |} | │ │ │ │ -| | │ │ │ │ -|void socks5::on_connected(error_code const& e) | │ │ │ │ -|_{_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_s_r_c_/_t_o_r_r_e_n_t___p_e_e_r_._c_p_p_:_1_9_3_ _ _ _|_h_o_w_ _d_o_ _w_e_ _d_e_a_l_ _w_i_t_h_ _o_u_r_ _e_x_t_e_r_n_a_l_ _a_d_d_r_e_s_s_ _c_h_a_n_g_i_n_g_?_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** hhooww ddoo wwee ddeeaall wwiitthh oouurr eexxtteerrnnaall aaddddrreessss cchhaannggiinngg?? ********** | │ │ │ │ -|****** ....//ssrrcc//ttoorrrreenntt__ppeeeerr..ccpppp::119933 ****** | │ │ │ │ -|// connections. If it fails, we'll | │ │ │ │ -| // retry with encryption | │ │ │ │ -| , pe_support(false) | │ │ │ │ |#endif | │ │ │ │ -| , is_v6_addr(false) | │ │ │ │ -|#if TORRENT_USE_I2P | │ │ │ │ -| , is_i2p_addr(false) | │ │ │ │ |#endif | │ │ │ │ -| , on_parole(false) | │ │ │ │ -| , banned(false) | │ │ │ │ -| , supports_utp(true) // assume peers support utp | │ │ │ │ -| , confirmed_supports_utp(false) | │ │ │ │ -| , supports_holepunch(false) | │ │ │ │ -| , web_seed(false) | │ │ │ │ -| , protocol_v2(false) | │ │ │ │ -| {} | │ │ │ │ | | │ │ │ │ -| std::uint32_t torrent_peer::rank(external_ip const& external, int external_port) const | │ │ │ │ -| { | │ │ │ │ -| TORRENT_ASSERT(in_use); | │ │ │ │ -|if (peer_rank == 0) | │ │ │ │ -|peer_rank = peer_priority( | │ │ │ │ -| tcp::endpoint(external.external_address(this->address()), std::uint16_t(external_port)) | │ │ │ │ -| , tcp::endpoint(this->address(), this->port)); | │ │ │ │ -| return peer_rank; | │ │ │ │ -| } | │ │ │ │ +|TORRENT_TEST(flag_sequential_download) | │ │ │ │ +|{ | │ │ │ │ +| // sequential-download | │ │ │ │ +| test_add_and_get_flags(torrent_flags::sequential_download); | │ │ │ │ +| test_set_after_add(torrent_flags::sequential_download); | │ │ │ │ +| test_unset_after_add(torrent_flags::sequential_download); | │ │ │ │ +|} | │ │ │ │ | | │ │ │ │ -|#ifndef TORRENT_DISABLE_LOGGING | │ │ │ │ -| std::string torrent_peer::to_string() const | │ │ │ │ -| { | │ │ │ │ -| TORRENT_ASSERT(in_use); | │ │ │ │ -|#if TORRENT_USE_I2P | │ │ │ │ -| if (is_i2p_addr) return dest().to_string(); | │ │ │ │ -|#endif // TORRENT_USE_I2P | │ │ │ │ -| return address().to_string(); | │ │ │ │ -| } | │ │ │ │ +|// the stop when ready flag will be cleared when the torrent is ready to start | │ │ │ │ +|// downloading. | │ │ │ │ +|// since the posix_disk_io is not threaded, this will happen immediately | │ │ │ │ +|#if TORRENT_HAVE_MMAP | │ │ │ │ +|TORRENT_TEST(flag_stop_when_ready) | │ │ │ │ +|{ | │ │ │ │ +| // stop-when-ready | │ │ │ │ +|test_unset_after_add(torrent_flags::stop_when_ready); | │ │ │ │ +|} | │ │ │ │ |#endif | │ │ │ │ | | │ │ │ │ -| std::int64_t torrent_peer::total_download() const | │ │ │ │ -| { | │ │ │ │ -| TORRENT_ASSERT(in_use); | │ │ │ │ -| if (connection != nullptr) | │ │ │ │ -| { | │ │ │ │ -| TORRENT_ASSERT(prev_amount_download == 0); | │ │ │ │ -| return connection->statistics().total_payload_download(); | │ │ │ │ -| } | │ │ │ │ -| else | │ │ │ │ -| { | │ │ │ │ -| return std::int64_t(prev_amount_download) << 10; | │ │ │ │ -| } | │ │ │ │ -|_ _}_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_s_r_c_/_t_o_r_r_e_n_t___i_n_f_o_._c_p_p_:_9_0_1_ _ _ _|_t_h_i_s_ _s_h_o_u_l_d_ _b_e_ _c_o_n_s_i_d_e_r_e_d_ _a_ _f_a_i_l_u_r_e_,_ _a_n_d_ _t_h_e_ _._t_o_r_r_e_n_t_ _f_i_l_e_ _r_e_j_e_c_t_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** tthhiiss sshhoouulldd bbee ccoonnssiiddeerreedd aa ffaaiilluurree,, aanndd tthhee ..ttoorrrreenntt ffiillee rreejjeecctteedd ********** | │ │ │ │ -|****** ....//ssrrcc//ttoorrrreenntt__iinnffoo..ccpppp::990011 ****** | │ │ │ │ -|std::string ext = extension(filename); | │ │ │ │ -| int cnt = 0; | │ │ │ │ -| for (;;) | │ │ │ │ -| { | │ │ │ │ -| ++cnt; | │ │ │ │ -| char new_ext[50]; | │ │ │ │ -| std::snprintf(new_ext, sizeof(new_ext), ".%d%s", cnt, ext.c_str()); | │ │ │ │ -| filename = base + new_ext; | │ │ │ │ -| | │ │ │ │ -| boost::crc_optimal<32, 0x1EDC6F41, 0xFFFFFFFF, 0xFFFFFFFF, true, true> crc; | │ │ │ │ -| process_string_lowercase(crc, filename); | │ │ │ │ -| std::uint32_t const new_hash = crc.checksum(); | │ │ │ │ -| if (files.find(new_hash) == files.end()) | │ │ │ │ -| { | │ │ │ │ -| files.insert({new_hash, {i, 0}}); | │ │ │ │ -| break; | │ │ │ │ -| } | │ │ │ │ -| ++num_collisions; | │ │ │ │ -| if (num_collisions > 100) | │ │ │ │ -| { | │ │ │ │ -|} | │ │ │ │ +|TORRENT_TEST(flag_disable_dht) | │ │ │ │ +|{ | │ │ │ │ +| test_add_and_get_flags(torrent_flags::disable_dht); | │ │ │ │ +| test_set_after_add(torrent_flags::disable_dht); | │ │ │ │ +| test_unset_after_add(torrent_flags::disable_dht); | │ │ │ │ |} | │ │ │ │ | | │ │ │ │ -| copy_on_write(); | │ │ │ │ -| m_files.rename_file(i, filename); | │ │ │ │ -| } | │ │ │ │ -| } | │ │ │ │ | | │ │ │ │ -| void torrent_info::remap_files(file_storage const& f) | │ │ │ │ -| { | │ │ │ │ -| INVARIANT_CHECK; | │ │ │ │ -| | │ │ │ │ -| TORRENT_ASSERT(is_loaded()); | │ │ │ │ -| // the new specified file storage must have the exact | │ │ │ │ -| // same size as the current file storage | │ │ │ │ -| TORRENT_ASSERT(m_files.total_size() == f.total_size()); | │ │ │ │ -| | │ │ │ │ -| if (m_files.total_size() != f.total_size()) return; | │ │ │ │ -| copy_on_write(); | │ │ │ │ -| m_files = f; | │ │ │ │ -| m_files.set_num_pieces(m_orig_files->num_pieces()); | │ │ │ │ -| m_files.set_piece_length(m_orig_files->piece_length()); | │ │ │ │ -| } | │ │ │ │ -| | │ │ │ │ -|#if TORRENT_ABI_VERSION == 1 | │ │ │ │ -| // standard constructor that parses a torrent file | │ │ │ │ -| torrent_info::torrent_info(entry const& torrent_file) | │ │ │ │ -| { | │ │ │ │ -| std::vector tmp; | │ │ │ │ -| std::back_insert_iterator> out(tmp); | │ │ │ │ -|_ _ _b_e_n_c_o_d_e_(_o_u_t_,_ _t_o_r_r_e_n_t___f_i_l_e_)_;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_e_l_e_v_a_n_c_e_ _0_|_._._/_s_r_c_/_t_o_r_r_e_n_t___h_a_n_d_l_e_._c_p_p_:_6_0_4_ _|_s_u_p_p_o_r_t_ _m_o_v_i_n_g_ _f_i_l_e_s_ _i_n_t_o_ _t_h_i_s_ _c_a_l_l_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|********** ssuuppppoorrtt mmoovviinngg ffiilleess iinnttoo tthhiiss ccaallll ********** | │ │ │ │ -|****** ....//ssrrcc//ttoorrrreenntt__hhaannddllee..ccpppp::660044 ****** | │ │ │ │ -|auto retp = &prio; | │ │ │ │ -| sync_call(&torrent::piece_priorities, retp); | │ │ │ │ -| std::vector ret; | │ │ │ │ -| ret.reserve(prio.size()); | │ │ │ │ -| for (auto p : prio) | │ │ │ │ -| ret.push_back(int(static_cast(p))); | │ │ │ │ -| return ret; | │ │ │ │ -| } | │ │ │ │ -|#endif | │ │ │ │ -| | │ │ │ │ -| void t TRUNCATED DUE TO SIZE LIMIT: 10485760 bytes