--- /srv/rebuilderd/tmp/rebuilderdWi8Pyq/inputs/libtorrent-rasterbar-doc_2.1.2-1_all.deb +++ /srv/rebuilderd/tmp/rebuilderdWi8Pyq/out/libtorrent-rasterbar-doc_2.1.2-1_all.deb ├── file list │ @@ -1,3 +1,3 @@ │ -rw-r--r-- 0 0 0 4 2026-09-25 10:42:22.000000 debian-binary │ --rw-r--r-- 0 0 0 3700 2026-09-25 10:42:22.000000 control.tar.xz │ --rw-r--r-- 0 0 0 1718268 2026-09-25 10:42:22.000000 data.tar.xz │ +-rw-r--r-- 0 0 0 3708 2026-09-25 10:42:22.000000 control.tar.xz │ +-rw-r--r-- 0 0 0 1721960 2026-09-25 10:42:22.000000 data.tar.xz ├── control.tar.xz │ ├── control.tar │ │ ├── ./control │ │ │ @@ -1,13 +1,13 @@ │ │ │ Package: libtorrent-rasterbar-doc │ │ │ Source: libtorrent-rasterbar │ │ │ Version: 2.1.2-1 │ │ │ Architecture: all │ │ │ Maintainer: Christian Marillat │ │ │ -Installed-Size: 6089 │ │ │ +Installed-Size: 6260 │ │ │ Section: doc │ │ │ Priority: optional │ │ │ Multi-Arch: foreign │ │ │ Homepage: https://libtorrent.org/ │ │ │ Description: Documentation for libtorrent-rasterbar │ │ │ Bittorrent library by Rasterbar Software (Arvid Norberg). │ │ │ libtorrent-rasterbar is a C++ library that aims to be a good alternative to │ │ ├── ./md5sums │ │ │ ├── ./md5sums │ │ │ │┄ Files differ ├── data.tar.xz │ ├── data.tar │ │ ├── file list │ │ │ @@ -84,37 +84,37 @@ │ │ │ -rw-r--r-- 0 root (0) root (0) 23657 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/python_binding.html │ │ │ -rw-r--r-- 0 root (0) root (0) 38187 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Add_Torrent.html │ │ │ -rw-r--r-- 0 root (0) root (0) 255484 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Alerts.html │ │ │ -rw-r--r-- 0 root (0) root (0) 27779 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Bdecoding.html │ │ │ -rw-r--r-- 0 root (0) root (0) 25888 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Bencoding.html │ │ │ -rw-r--r-- 0 root (0) root (0) 95050 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Core.html │ │ │ -rw-r--r-- 0 root (0) root (0) 51639 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Create_Torrents.html │ │ │ --rw-r--r-- 0 root (0) root (0) 66106 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Custom_Storage.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 153591 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Custom_Storage.html │ │ │ -rw-r--r-- 0 root (0) root (0) 27743 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-DHT.html │ │ │ -rw-r--r-- 0 root (0) root (0) 50126 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Error_Codes.html │ │ │ -rw-r--r-- 0 root (0) root (0) 13567 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Filter.html │ │ │ -rw-r--r-- 0 root (0) root (0) 12817 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-PeerClass.html │ │ │ -rw-r--r-- 0 root (0) root (0) 99976 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Plugins.html │ │ │ -rw-r--r-- 0 root (0) root (0) 10892 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Resume_Data.html │ │ │ -rw-r--r-- 0 root (0) root (0) 103626 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Session.html │ │ │ -rw-r--r-- 0 root (0) root (0) 178714 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Settings.html │ │ │ -rw-r--r-- 0 root (0) root (0) 12837 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Stats.html │ │ │ --rw-r--r-- 0 root (0) root (0) 76255 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Storage.html │ │ │ --rw-r--r-- 0 root (0) root (0) 137236 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Handle.html │ │ │ --rw-r--r-- 0 root (0) root (0) 33232 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Info.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 76247 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Storage.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 137228 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Handle.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 33224 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Info.html │ │ │ -rw-r--r-- 0 root (0) root (0) 49666 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Torrent_Status.html │ │ │ -rw-r--r-- 0 root (0) root (0) 16901 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Trackers.html │ │ │ -rw-r--r-- 0 root (0) root (0) 26547 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Utility.html │ │ │ -rw-r--r-- 0 root (0) root (0) 9126 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-ed25519.html │ │ │ -rw-r--r-- 0 root (0) root (0) 35478 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/reference.html │ │ │ -rw-r--r-- 0 root (0) root (0) 29240 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/security-audit.html │ │ │ --rw-r--r-- 0 root (0) root (0) 1365665 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/single-page-ref.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 1453126 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/single-page-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 10118 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/streaming.html │ │ │ -rw-r--r-- 0 root (0) root (0) 8807 2026-09-24 14:20:58.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/style.css │ │ │ --rw-r--r-- 0 root (0) root (0) 554154 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/todo.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 554157 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/todo.html │ │ │ -rw-r--r-- 0 root (0) root (0) 3020 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/troubleshooting.html │ │ │ -rw-r--r-- 0 root (0) root (0) 25162 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/tuning-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 132627 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/tutorial-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 16381 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/udp_tracker_protocol.html │ │ │ -rw-r--r-- 0 root (0) root (0) 18160 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/upgrade_to_1.2-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 34650 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/upgrade_to_2.0-ref.html │ │ │ -rw-r--r-- 0 root (0) root (0) 20292 2026-09-25 10:42:22.000000 ./usr/share/doc/libtorrent-rasterbar-doc/html/upgrade_to_2.1-ref.html │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/manual-ref.html │ │ │ @@ -100,15 +100,15 @@ │ │ │ the session, it contains the main loop that serves all torrents.

│ │ │

The basic usage is as follows:

│ │ │ │ │ │ │ │ │

The overloads of these functions that accept an error_code parameter │ │ │ will not throw exceptions for I/O, general bdecode, or parsing errors. │ │ │ However, they may still throw std::bad_alloc if memory allocation │ │ │ fails.

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

truncate_files()

│ │ │ +

Declared in "libtorrent/truncate.hpp"

│ │ │ +
│ │ │ +void truncate_files (file_storage const& fs, std::string const& save_path, storage_error& ec);
│ │ │ +void truncate_files (
│ │ │ +   filenames 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. │ │ │ +The overload that takes filenames support taking renamed and de-duplicated files into account.

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

make_magnet_uri()

│ │ │

Declared in "libtorrent/magnet_uri.hpp"

│ │ │
│ │ │  std::string make_magnet_uri (add_torrent_params const& atp);
│ │ │  
│ │ │ @@ -848,26 +860,14 @@ │ │ │ add_torrent_params parse_magnet_uri (string_view uri, error_code& ec); │ │ │ │ │ │

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]
│ │ │ -
│ │ │ -

truncate_files()

│ │ │ -

Declared in "libtorrent/truncate.hpp"

│ │ │ -
│ │ │ -void truncate_files (file_storage const& fs, std::string const& save_path, storage_error& ec);
│ │ │ -void truncate_files (
│ │ │ -   filenames 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. │ │ │ -The overload that takes filenames support taking renamed and de-duplicated files into account.

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

pread_disk_io_constructor()

│ │ │

Declared in "libtorrent/pread_disk_io.hpp"

│ │ │
│ │ │  std::unique_ptr<disk_interface> pread_disk_io_constructor (
│ │ │     io_context& ios, settings_interface const&, counters& cnt);
│ │ │ @@ -889,73 +889,14 @@
│ │ │  
│ │ │  std::shared_ptr<torrent_plugin> create_i2p_pex_plugin (torrent_handle const&, client_data_t);
│ │ │  
│ │ │

The i2p_pex extension gossips i2p peer addresses, only on i2p torrents. │ │ │ The extension will not activate for non-i2p torrents.

│ │ │

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

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

enum socket_type_t

│ │ │ -

Declared in "libtorrent/socket_type.hpp"

│ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
namevaluedescription
tcp0 
socks51 
http2 
utp3 
i2p4 
rtc5 
tcp_ssl6 
socks5_ssl7 
http_ssl8 
utp_ssl9 
│ │ │ [report issue]
│ │ │
│ │ │

enum protocol_version

│ │ │

Declared in "libtorrent/info_hash.hpp"

│ │ │ │ │ │ │ │ │ │ │ │ @@ -1107,14 +1048,89 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
http_seed2BEP 17 web seed (no longer supported)
│ │ │ +[report issue]
│ │ │ +
│ │ │ +

enum socket_type_t

│ │ │ +

Declared in "libtorrent/socket_type.hpp"

│ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
namevaluedescription
tcp0 
socks51 
http2 
utp3 
i2p4 
rtc5 
tcp_ssl6 
socks5_ssl7 
http_ssl8 
utp_ssl9 
│ │ │ +[report issue]
│ │ │ +
│ │ │ +

int

│ │ │ +

Declared in "libtorrent/version.hpp"

│ │ │ +
│ │ │ +
version_major
│ │ │ +
the major, minor and tiny versions of libtorrent
│ │ │ +
│ │ │ +
│ │ │ +
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 │ │ │ @@ -1128,46 +1144,14 @@ │ │ │
low_priority
│ │ │
The lowest priority for files and pieces.
│ │ │
│ │ │
│ │ │
top_priority
│ │ │
The highest priority for files and pieces.
│ │ │
│ │ │ -[report issue]
│ │ │ -
│ │ │ -

int

│ │ │ -

Declared in "libtorrent/version.hpp"

│ │ │ -
│ │ │ -
version_major
│ │ │ -
the major, minor and tiny versions of libtorrent
│ │ │ -
│ │ │ -
│ │ │ -
version_minor
│ │ │ -
the major, minor and tiny versions of libtorrent
│ │ │ -
│ │ │ -
│ │ │ -
version_tiny
│ │ │ -
the major, minor and tiny versions of libtorrent
│ │ │ -
│ │ │ -[report issue]
│ │ │ -
│ │ │ -

char const*

│ │ │ -

Declared in "libtorrent/version.hpp"

│ │ │ -
│ │ │ -
version_str
│ │ │ -
the libtorrent version in string form
│ │ │ -
│ │ │ -[report issue]
│ │ │ -
│ │ │ -

std::uint64_t

│ │ │ -

Declared in "libtorrent/version.hpp"

│ │ │ -
│ │ │ -
version_revision
│ │ │ -
the git commit of this libtorrent version
│ │ │ -
│ │ │ [report issue]
│ │ │
│ │ │

pex_flags_t

│ │ │

Declared in "libtorrent/pex_flags.hpp"

│ │ │
│ │ │
pex_encryption
│ │ │
the peer supports protocol encryption
│ │ │ @@ -1187,14 +1171,30 @@ │ │ │ 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
│ │ │ +
│ │ │ +[report issue]
│ │ │ +
│ │ │ +

std::uint64_t

│ │ │ +

Declared in "libtorrent/version.hpp"

│ │ │ +
│ │ │ +
version_revision
│ │ │ +
the git commit of this libtorrent version
│ │ │ +
│ │ │ [report issue]
│ │ │
│ │ │

torrent_flags_t

│ │ │

Declared in "libtorrent/torrent_flags.hpp"

│ │ │
│ │ │
seed_mode
│ │ │

If seed_mode is set, libtorrent will assume that all files │ │ │ ├── html2text {} │ │ │ │ @@ -1,47 +1,201 @@ │ │ │ │ > │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.1.2 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ - * _p_e_e_r___i_n_f_o │ │ │ │ - o _r_e_m_o_t_e___e_n_d_p_o_i_n_t_(_) │ │ │ │ - o _l_o_c_a_l___e_n_d_p_o_i_n_t_(_) │ │ │ │ - o _i_2_p___d_e_s_t_i_n_a_t_i_o_n_(_) │ │ │ │ - * _i_n_f_o___h_a_s_h___t │ │ │ │ - o _i_n_f_o___h_a_s_h___t_(_) │ │ │ │ - o _h_a_s___v_1_(_)_ _h_a_s_(_)_ _h_a_s___v_2_(_) │ │ │ │ - o _g_e_t_(_) │ │ │ │ - o _g_e_t___b_e_s_t_(_) │ │ │ │ * _w_e_b___s_e_e_d___e_n_t_r_y │ │ │ │ o _o_p_e_r_a_t_o_r_=_=_(_) │ │ │ │ o _o_p_e_r_a_t_o_r_<_(_) │ │ │ │ * _p_i_e_c_e___b_l_o_c_k │ │ │ │ + * _i_n_f_o___h_a_s_h___t │ │ │ │ + o _i_n_f_o___h_a_s_h___t_(_) │ │ │ │ + o _h_a_s___v_1_(_)_ _h_a_s___v_2_(_)_ _h_a_s_(_) │ │ │ │ + o _g_e_t_(_) │ │ │ │ + o _g_e_t___b_e_s_t_(_) │ │ │ │ * _p_e_e_r___r_e_q_u_e_s_t │ │ │ │ o _o_p_e_r_a_t_o_r_=_=_(_) │ │ │ │ - * _l_o_a_d___t_o_r_r_e_n_t___f_i_l_e_(_)_ _l_o_a_d___t_o_r_r_e_n_t___p_a_r_s_e_d_(_)_ _l_o_a_d___t_o_r_r_e_n_t___b_u_f_f_e_r_(_) │ │ │ │ + * _p_e_e_r___i_n_f_o │ │ │ │ + o _r_e_m_o_t_e___e_n_d_p_o_i_n_t_(_) │ │ │ │ + o _l_o_c_a_l___e_n_d_p_o_i_n_t_(_) │ │ │ │ + o _i_2_p___d_e_s_t_i_n_a_t_i_o_n_(_) │ │ │ │ + * _l_o_a_d___t_o_r_r_e_n_t___p_a_r_s_e_d_(_)_ _l_o_a_d___t_o_r_r_e_n_t___f_i_l_e_(_)_ _l_o_a_d___t_o_r_r_e_n_t___b_u_f_f_e_r_(_) │ │ │ │ + * _t_r_u_n_c_a_t_e___f_i_l_e_s_(_) │ │ │ │ * _m_a_k_e___m_a_g_n_e_t___u_r_i_(_) │ │ │ │ * _p_a_r_s_e___m_a_g_n_e_t___u_r_i_(_) │ │ │ │ - * _t_r_u_n_c_a_t_e___f_i_l_e_s_(_) │ │ │ │ * _p_r_e_a_d___d_i_s_k___i_o___c_o_n_s_t_r_u_c_t_o_r_(_) │ │ │ │ * _v_e_r_s_i_o_n_(_) │ │ │ │ * _c_r_e_a_t_e___i_2_p___p_e_x___p_l_u_g_i_n_(_) │ │ │ │ - * _e_n_u_m_ _s_o_c_k_e_t___t_y_p_e___t │ │ │ │ * _e_n_u_m_ _p_r_o_t_o_c_o_l___v_e_r_s_i_o_n │ │ │ │ * _e_n_u_m_ _p_o_r_t_m_a_p___t_r_a_n_s_p_o_r_t │ │ │ │ * _e_n_u_m_ _p_o_r_t_m_a_p___p_r_o_t_o_c_o_l │ │ │ │ * _e_n_u_m_ _e_v_e_n_t___t │ │ │ │ * _e_n_u_m_ _c_o_n_n_e_c_t_i_o_n___t_y_p_e │ │ │ │ - * _d_o_w_n_l_o_a_d___p_r_i_o_r_i_t_y___t │ │ │ │ + * _e_n_u_m_ _s_o_c_k_e_t___t_y_p_e___t │ │ │ │ * _i_n_t │ │ │ │ + * _d_o_w_n_l_o_a_d___p_r_i_o_r_i_t_y___t │ │ │ │ + * _p_e_x___f_l_a_g_s___t │ │ │ │ * _c_h_a_r_ _c_o_n_s_t_* │ │ │ │ * _s_t_d_:_:_u_i_n_t_6_4___t │ │ │ │ - * _p_e_x___f_l_a_g_s___t │ │ │ │ * _t_o_r_r_e_n_t___f_l_a_g_s___t │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ wweebb__sseeeedd__eennttrryy ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_w_e_b___s_e_e_d___e_n_t_r_y_._h_p_p" │ │ │ │ +the _w_e_b___s_e_e_d___e_n_t_r_y holds information about a web seed (also known as URL seed │ │ │ │ +or HTTP seed). It is essentially a URL with some state associated with it. For │ │ │ │ +more information, see _B_E_P_ _1_7 and _B_E_P_ _1_9. │ │ │ │ +struct web_seed_entry │ │ │ │ +{ │ │ │ │ + wweebb__sseeeedd__eennttrryy (web_seed_entry&&) noexcept; │ │ │ │ + wweebb__sseeeedd__eennttrryy (web_seed_entry const&); │ │ │ │ + web_seed_entry& ooppeerraattoorr== (web_seed_entry&&) noexcept; │ │ │ │ + web_seed_entry& ooppeerraattoorr== (web_seed_entry const&); │ │ │ │ + bool ooppeerraattoorr==== (web_seed_entry const& e) const; │ │ │ │ + bool ooppeerraattoorr<< (web_seed_entry const& e) const; │ │ │ │ + │ │ │ │ + std::string url; │ │ │ │ + std::string auth; │ │ │ │ + headers_t extra_headers; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ooppeerraattoorr====(()) ********** │ │ │ │ +bool ooppeerraattoorr==== (web_seed_entry const& e) const; │ │ │ │ +URL and type comparison │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ooppeerraattoorr<<(()) ********** │ │ │ │ +bool ooppeerraattoorr<< (web_seed_entry const& e) const; │ │ │ │ +URL and type less-than comparison │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + url │ │ │ │ + The URL of the web seed │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + auth │ │ │ │ + Optional authentication. If set, this string is sent verbatim as the │ │ │ │ + value of the HTTP Authorization header, and it overrides any credentials │ │ │ │ + embedded in the URL. It is not transformed in any way, so it must be the │ │ │ │ + complete header value. For HTTP basic authentication that means "Basic " │ │ │ │ + followed by the base64 encoding of username:password. For security, this │ │ │ │ + value (as well as any credentials embedded in the URL as "username: │ │ │ │ + password@host") is only sent to the origin of the web seed URL. If the │ │ │ │ + web seed responds with a redirect to a different origin (a different │ │ │ │ + scheme, host or port), it is nnoott forwarded to the new origin. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + extra_headers │ │ │ │ + Any extra HTTP headers that need to be passed to the web seed. Warning: │ │ │ │ + unlike auth, these headers are sent verbatim with every request, │ │ │ │ + including requests to a different origin that the web seed may redirect │ │ │ │ + to. Do not put sensitive credentials (such as an Authorization or Cookie │ │ │ │ + header) here unless you trust every host the web seed might redirect to. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppiieeccee__bblloocckk ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_i_e_c_e___b_l_o_c_k_._h_p_p" │ │ │ │ +identifies a single block within a torrent. piece_index is the piece the block │ │ │ │ +is part of and block_index is the index of the block within the piece. Blocks │ │ │ │ +are normally 16 KiB. │ │ │ │ +struct piece_block │ │ │ │ +{ │ │ │ │ + ppiieeccee__bblloocckk () = default; │ │ │ │ + ppiieeccee__bblloocckk (piece_index_t p_index, int b_index); │ │ │ │ + bool ooppeerraattoorr<< (piece_block const& b) const; │ │ │ │ + bool ooppeerraattoorr==== (piece_block const& b) const; │ │ │ │ + bool ooppeerraattoorr!!== (piece_block const& b) const; │ │ │ │ + │ │ │ │ + static const piece_block invalid; │ │ │ │ + piece_index_t piece_index {0}; │ │ │ │ + int bblloocckk__iinnddeexx = 0; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + invalid piece_index block_index │ │ │ │ + sentinel value representing "no block". Compares unequal to any real │ │ │ │ + block. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ iinnffoo__hhaasshh__tt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_i_n_f_o___h_a_s_h_._h_p_p" │ │ │ │ +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 │ │ │ │ +{ │ │ │ │ + iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept; │ │ │ │ + iinnffoo__hhaasshh__tt () noexcept = default; │ │ │ │ + explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept; │ │ │ │ + explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept; │ │ │ │ + bool hhaass (protocol_version v) const; │ │ │ │ + bool hhaass__vv22 () const; │ │ │ │ + bool hhaass__vv11 () const; │ │ │ │ + sha1_hash ggeett (protocol_version v) const; │ │ │ │ + sha1_hash ggeett__bbeesstt () const; │ │ │ │ + friend bool ooppeerraattoorr!!== (info_hash_t const& lhs, info_hash_t const& rhs); │ │ │ │ + friend bool ooppeerraattoorr==== (info_hash_t const& lhs, info_hash_t const& rhs) │ │ │ │ +noexcept; │ │ │ │ + bool ooppeerraattoorr<< (info_hash_t const& o) const; │ │ │ │ + friend std::ostream& ooppeerraattoorr<<<< (std::ostream& os, info_hash_t const& ih); │ │ │ │ + │ │ │ │ + sha1_hash v1; │ │ │ │ + sha256_hash v2; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** iinnffoo__hhaasshh__tt(()) ********** │ │ │ │ +iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept; │ │ │ │ +iinnffoo__hhaasshh__tt () noexcept = default; │ │ │ │ +explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept; │ │ │ │ +explicit iinnffoo__hhaasshh__tt (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 iimmpplliicciitt conversion from a v1 hash, but the │ │ │ │ +implicitness is deprecated. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** hhaass__vv11(()) hhaass__vv22(()) hhaass(()) ********** │ │ │ │ +bool hhaass (protocol_version v) const; │ │ │ │ +bool hhaass__vv22 () const; │ │ │ │ +bool hhaass__vv11 () const; │ │ │ │ +returns true if the corresponding info hash is present in this object. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ggeett(()) ********** │ │ │ │ +sha1_hash ggeett (protocol_version v) const; │ │ │ │ +returns the has for the specified protocol version │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ggeett__bbeesstt(()) ********** │ │ │ │ +sha1_hash ggeett__bbeesstt () const; │ │ │ │ +returns the v2 (truncated) info-hash, if there is one, otherwise returns the v1 │ │ │ │ +info-hash │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + v1 v2 │ │ │ │ + the v1 (SHA-1) info-hash and the v2 (SHA-256) info-hash. For a hybrid │ │ │ │ + torrent both are populated. For a pure v1 or pure v2 torrent, the unused │ │ │ │ + field is the all-zero hash. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ppeeeerr__rreeqquueesstt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___r_e_q_u_e_s_t_._h_p_p" │ │ │ │ +represents a byte range within a piece. Internally this is is used for incoming │ │ │ │ +piece requests. │ │ │ │ +struct peer_request │ │ │ │ +{ │ │ │ │ + bool ooppeerraattoorr==== (peer_request const& r) const; │ │ │ │ + │ │ │ │ + piece_index_t piece; │ │ │ │ + int start; │ │ │ │ + int length; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ooppeerraattoorr====(()) ********** │ │ │ │ +bool ooppeerraattoorr==== (peer_request const& r) const; │ │ │ │ +returns true if the right hand side _p_e_e_r___r_e_q_u_e_s_t refers to the same range as │ │ │ │ +this does. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + piece │ │ │ │ + The index of the piece in which the range starts. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + start │ │ │ │ + The byte offset within that piece where the range starts. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ + length │ │ │ │ + The size of the range, in bytes. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ppeeeerr__iinnffoo ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___i_n_f_o_._h_p_p" │ │ │ │ holds information and statistics about one peer that libtorrent is connected to │ │ │ │ struct peer_info │ │ │ │ { │ │ │ │ _t_c_p_:_:_e_n_d_p_o_i_n_t rreemmoottee__eennddppooiinntt () const; │ │ │ │ _t_c_p_:_:_e_n_d_p_o_i_n_t llooccaall__eennddppooiinntt () const; │ │ │ │ @@ -407,201 +561,57 @@ │ │ │ │ to disk before downloading more. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ read_state write_state │ │ │ │ bitmasks indicating what state this peer is in with regards to sending │ │ │ │ and receiving data. The states are defined as independent flags of type │ │ │ │ bandwidth_state_flags_t, in this class. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ iinnffoo__hhaasshh__tt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_i_n_f_o___h_a_s_h_._h_p_p" │ │ │ │ -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 │ │ │ │ -{ │ │ │ │ - explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept; │ │ │ │ - iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept; │ │ │ │ - iinnffoo__hhaasshh__tt () noexcept = default; │ │ │ │ - explicit iinnffoo__hhaasshh__tt (sha1_hash h1) noexcept; │ │ │ │ - bool hhaass (protocol_version v) const; │ │ │ │ - bool hhaass__vv11 () const; │ │ │ │ - bool hhaass__vv22 () const; │ │ │ │ - sha1_hash ggeett (protocol_version v) const; │ │ │ │ - sha1_hash ggeett__bbeesstt () const; │ │ │ │ - friend bool ooppeerraattoorr!!== (info_hash_t const& lhs, info_hash_t const& rhs); │ │ │ │ - friend bool ooppeerraattoorr==== (info_hash_t const& lhs, info_hash_t const& rhs) │ │ │ │ -noexcept; │ │ │ │ - bool ooppeerraattoorr<< (info_hash_t const& o) const; │ │ │ │ - friend std::ostream& ooppeerraattoorr<<<< (std::ostream& os, info_hash_t const& ih); │ │ │ │ - │ │ │ │ - sha1_hash v1; │ │ │ │ - sha256_hash v2; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** iinnffoo__hhaasshh__tt(()) ********** │ │ │ │ -explicit iinnffoo__hhaasshh__tt (sha256_hash h2) noexcept; │ │ │ │ -iinnffoo__hhaasshh__tt (sha1_hash h1, sha256_hash h2) noexcept; │ │ │ │ -iinnffoo__hhaasshh__tt () noexcept = default; │ │ │ │ -explicit iinnffoo__hhaasshh__tt (sha1_hash h1) 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 iimmpplliicciitt conversion from a v1 hash, but the │ │ │ │ -implicitness is deprecated. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** hhaass__vv11(()) hhaass(()) hhaass__vv22(()) ********** │ │ │ │ -bool hhaass (protocol_version v) const; │ │ │ │ -bool hhaass__vv11 () const; │ │ │ │ -bool hhaass__vv22 () const; │ │ │ │ -returns true if the corresponding info hash is present in this object. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett(()) ********** │ │ │ │ -sha1_hash ggeett (protocol_version v) const; │ │ │ │ -returns the has for the specified protocol version │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__bbeesstt(()) ********** │ │ │ │ -sha1_hash ggeett__bbeesstt () const; │ │ │ │ -returns the v2 (truncated) info-hash, if there is one, otherwise returns the v1 │ │ │ │ -info-hash │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - v1 v2 │ │ │ │ - the v1 (SHA-1) info-hash and the v2 (SHA-256) info-hash. For a hybrid │ │ │ │ - torrent both are populated. For a pure v1 or pure v2 torrent, the unused │ │ │ │ - field is the all-zero hash. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ wweebb__sseeeedd__eennttrryy ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_w_e_b___s_e_e_d___e_n_t_r_y_._h_p_p" │ │ │ │ -the _w_e_b___s_e_e_d___e_n_t_r_y holds information about a web seed (also known as URL seed │ │ │ │ -or HTTP seed). It is essentially a URL with some state associated with it. For │ │ │ │ -more information, see _B_E_P_ _1_7 and _B_E_P_ _1_9. │ │ │ │ -struct web_seed_entry │ │ │ │ -{ │ │ │ │ - web_seed_entry& ooppeerraattoorr== (web_seed_entry&&) noexcept; │ │ │ │ - web_seed_entry& ooppeerraattoorr== (web_seed_entry const&); │ │ │ │ - wweebb__sseeeedd__eennttrryy (web_seed_entry&&) noexcept; │ │ │ │ - wweebb__sseeeedd__eennttrryy (web_seed_entry const&); │ │ │ │ - bool ooppeerraattoorr==== (web_seed_entry const& e) const; │ │ │ │ - bool ooppeerraattoorr<< (web_seed_entry const& e) const; │ │ │ │ - │ │ │ │ - std::string url; │ │ │ │ - std::string auth; │ │ │ │ - headers_t extra_headers; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr====(()) ********** │ │ │ │ -bool ooppeerraattoorr==== (web_seed_entry const& e) const; │ │ │ │ -URL and type comparison │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr<<(()) ********** │ │ │ │ -bool ooppeerraattoorr<< (web_seed_entry const& e) const; │ │ │ │ -URL and type less-than comparison │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - url │ │ │ │ - The URL of the web seed │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - auth │ │ │ │ - Optional authentication. If set, this string is sent verbatim as the │ │ │ │ - value of the HTTP Authorization header, and it overrides any credentials │ │ │ │ - embedded in the URL. It is not transformed in any way, so it must be the │ │ │ │ - complete header value. For HTTP basic authentication that means "Basic " │ │ │ │ - followed by the base64 encoding of username:password. For security, this │ │ │ │ - value (as well as any credentials embedded in the URL as "username: │ │ │ │ - password@host") is only sent to the origin of the web seed URL. If the │ │ │ │ - web seed responds with a redirect to a different origin (a different │ │ │ │ - scheme, host or port), it is nnoott forwarded to the new origin. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - extra_headers │ │ │ │ - Any extra HTTP headers that need to be passed to the web seed. Warning: │ │ │ │ - unlike auth, these headers are sent verbatim with every request, │ │ │ │ - including requests to a different origin that the web seed may redirect │ │ │ │ - to. Do not put sensitive credentials (such as an Authorization or Cookie │ │ │ │ - header) here unless you trust every host the web seed might redirect to. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppiieeccee__bblloocckk ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_i_e_c_e___b_l_o_c_k_._h_p_p" │ │ │ │ -identifies a single block within a torrent. piece_index is the piece the block │ │ │ │ -is part of and block_index is the index of the block within the piece. Blocks │ │ │ │ -are normally 16 KiB. │ │ │ │ -struct piece_block │ │ │ │ -{ │ │ │ │ - ppiieeccee__bblloocckk (piece_index_t p_index, int b_index); │ │ │ │ - ppiieeccee__bblloocckk () = default; │ │ │ │ - bool ooppeerraattoorr<< (piece_block const& b) const; │ │ │ │ - bool ooppeerraattoorr==== (piece_block const& b) const; │ │ │ │ - bool ooppeerraattoorr!!== (piece_block const& b) const; │ │ │ │ - │ │ │ │ - static const piece_block invalid; │ │ │ │ - piece_index_t piece_index {0}; │ │ │ │ - int bblloocckk__iinnddeexx = 0; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - invalid piece_index block_index │ │ │ │ - sentinel value representing "no block". Compares unequal to any real │ │ │ │ - block. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ppeeeerr__rreeqquueesstt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___r_e_q_u_e_s_t_._h_p_p" │ │ │ │ -represents a byte range within a piece. Internally this is is used for incoming │ │ │ │ -piece requests. │ │ │ │ -struct peer_request │ │ │ │ -{ │ │ │ │ - bool ooppeerraattoorr==== (peer_request const& r) const; │ │ │ │ - │ │ │ │ - piece_index_t piece; │ │ │ │ - int start; │ │ │ │ - int length; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ooppeerraattoorr====(()) ********** │ │ │ │ -bool ooppeerraattoorr==== (peer_request const& r) const; │ │ │ │ -returns true if the right hand side _p_e_e_r___r_e_q_u_e_s_t refers to the same range as │ │ │ │ -this does. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - piece │ │ │ │ - The index of the piece in which the range starts. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - start │ │ │ │ - The byte offset within that piece where the range starts. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ - length │ │ │ │ - The size of the range, in bytes. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ llooaadd__ttoorrrreenntt__ffiillee(()) llooaadd__ttoorrrreenntt__ppaarrsseedd(()) llooaadd__ttoorrrreenntt__bbuuffffeerr(()) ************ │ │ │ │ +************ llooaadd__ttoorrrreenntt__ppaarrsseedd(()) llooaadd__ttoorrrreenntt__ffiillee(()) llooaadd__ttoorrrreenntt__bbuuffffeerr(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_l_o_a_d___t_o_r_r_e_n_t_._h_p_p" │ │ │ │ -add_torrent_params llooaadd__ttoorrrreenntt__ppaarrsseedd ( │ │ │ │ - bdecode_node const& torrent_file, load_torrent_limits const& cfg); │ │ │ │ +add_torrent_params llooaadd__ttoorrrreenntt__ffiillee ( │ │ │ │ + std::string const& filename, load_torrent_limits const& cfg); │ │ │ │ +add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr ( │ │ │ │ + span buffer, error_code& ec, load_torrent_limits const& cfg); │ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__ppaarrsseedd ( │ │ │ │ bdecode_node const& torrent_file, error_code& ec, load_torrent_limits const& │ │ │ │ cfg); │ │ │ │ -add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr ( │ │ │ │ - span buffer, error_code& ec, load_torrent_limits const& cfg); │ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__ffiillee ( │ │ │ │ std::string const& filename); │ │ │ │ -add_torrent_params llooaadd__ttoorrrreenntt__ffiillee ( │ │ │ │ - std::string const& filename, error_code& ec, load_torrent_limits const& │ │ │ │ -cfg); │ │ │ │ +add_torrent_params llooaadd__ttoorrrreenntt__ppaarrsseedd ( │ │ │ │ + bdecode_node const& torrent_file); │ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr ( │ │ │ │ span buffer, load_torrent_limits const& cfg); │ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__ppaarrsseedd ( │ │ │ │ - bdecode_node const& torrent_file); │ │ │ │ -add_torrent_params llooaadd__ttoorrrreenntt__ffiillee ( │ │ │ │ - std::string const& filename, load_torrent_limits const& cfg); │ │ │ │ + bdecode_node const& torrent_file, load_torrent_limits const& cfg); │ │ │ │ add_torrent_params llooaadd__ttoorrrreenntt__bbuuffffeerr ( │ │ │ │ span buffer); │ │ │ │ +add_torrent_params llooaadd__ttoorrrreenntt__ffiillee ( │ │ │ │ + std::string const& filename, error_code& ec, load_torrent_limits const& │ │ │ │ +cfg); │ │ │ │ These functions load the content of a .torrent file into an _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s │ │ │ │ object. The immutable part of a torrent file (the info-dictionary) is stored in │ │ │ │ the ti field in the _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s object (as a _t_o_r_r_e_n_t___i_n_f_o object). The │ │ │ │ returned object is suitable to be: │ │ │ │ * added to a _s_e_s_s_i_o_n via _a_d_d___t_o_r_r_e_n_t_(_) or _a_s_y_n_c___a_d_d___t_o_r_r_e_n_t_(_) │ │ │ │ * saved as a .torrent_file via _w_r_i_t_e___t_o_r_r_e_n_t___f_i_l_e_(_) │ │ │ │ * turned into a magnet link via _m_a_k_e___m_a_g_n_e_t___u_r_i_(_) │ │ │ │ The overloads of these functions that accept anerror_codeparameter will not │ │ │ │ throw exceptions for I/O, general bdecode, or parsing errors. However, they may │ │ │ │ still throwstd::bad_allocif memory allocation fails. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ttrruunnccaattee__ffiilleess(()) ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_r_u_n_c_a_t_e_._h_p_p" │ │ │ │ +void ttrruunnccaattee__ffiilleess (file_storage const& fs, std::string const& save_path, │ │ │ │ +storage_error& ec); │ │ │ │ +void ttrruunnccaattee__ffiilleess ( │ │ │ │ + filenames const& fs, std::string const& save_path, storage_error& ec); │ │ │ │ +Truncates files larger than specified in the _f_i_l_e___s_t_o_r_a_g_e, saved under the │ │ │ │ +specified save_path. The overload that takes _f_i_l_e_n_a_m_e_s support taking renamed │ │ │ │ +and de-duplicated files into account. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ mmaakkee__mmaaggnneett__uurrii(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_m_a_g_n_e_t___u_r_i_._h_p_p" │ │ │ │ std::string mmaakkee__mmaaggnneett__uurrii (add_torrent_params const& atp); │ │ │ │ Generates a magnet URI from the specified torrent. │ │ │ │ Several fields from the _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s objects are recorded in the magnet │ │ │ │ link. In order to not include them, they have to be cleared before calling │ │ │ │ _m_a_k_e___m_a_g_n_e_t___u_r_i_(_). These fields are used: │ │ │ │ @@ -625,24 +635,14 @@ │ │ │ │ add_torrent_params ppaarrssee__mmaaggnneett__uurrii (string_view uri, error_code& ec); │ │ │ │ This function parses out information from the magnet link and populates the │ │ │ │ _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s 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. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ttrruunnccaattee__ffiilleess(()) ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_r_u_n_c_a_t_e_._h_p_p" │ │ │ │ -void ttrruunnccaattee__ffiilleess (file_storage const& fs, std::string const& save_path, │ │ │ │ -storage_error& ec); │ │ │ │ -void ttrruunnccaattee__ffiilleess ( │ │ │ │ - filenames const& fs, std::string const& save_path, storage_error& ec); │ │ │ │ -Truncates files larger than specified in the _f_i_l_e___s_t_o_r_a_g_e, saved under the │ │ │ │ -specified save_path. The overload that takes _f_i_l_e_n_a_m_e_s support taking renamed │ │ │ │ -and de-duplicated files into account. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ pprreeaadd__ddiisskk__iioo__ccoonnssttrruuccttoorr(()) ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_r_e_a_d___d_i_s_k___i_o_._h_p_p" │ │ │ │ std::unique_ptr pprreeaadd__ddiisskk__iioo__ccoonnssttrruuccttoorr ( │ │ │ │ io_context& ios, settings_interface const&, counters& cnt); │ │ │ │ constructs a multi-threaded file disk I/O using pread()/pwrite() │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ vveerrssiioonn(()) ************ │ │ │ │ @@ -656,29 +656,14 @@ │ │ │ │ std::shared_ptr ccrreeaattee__ii22pp__ppeexx__pplluuggiinn (torrent_handle const&, │ │ │ │ client_data_t); │ │ │ │ The i2p_pex extension gossips i2p peer addresses, only on i2p torrents. The │ │ │ │ extension will not activate for non-i2p torrents. │ │ │ │ This can either be passed in the add_torrent_params::extensions field, or via │ │ │ │ _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_a_d_d___e_x_t_e_n_s_i_o_n_(_). │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ eennuumm ssoocckkeett__ttyyppee__tt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_o_c_k_e_t___t_y_p_e_._h_p_p" │ │ │ │ - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ -|_nn_aa_mm_ee_ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ -|_t_c_p_ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_o_c_k_s_5_ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_h_t_t_p_ _ _ _ _ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_u_t_p_ _ _ _ _ _ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_i_2_p_ _ _ _ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_r_t_c_ _ _ _ _ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_t_c_p___s_s_l_ _ _ _|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_s_o_c_k_s_5___s_s_l_|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_h_t_t_p___s_s_l_ _ _|_8_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -|_u_t_p___s_s_l_ _ _ _|_9_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ eennuumm pprroottooccooll__vveerrssiioonn ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_i_n_f_o___h_a_s_h_._h_p_p" │ │ │ │ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ |_nn_aa_mm_ee_|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |_V_1_ _ _|_0_ _ _ _ _|_T_h_e_ _o_r_i_g_i_n_a_l_ _B_i_t_T_o_r_r_e_n_t_ _v_e_r_s_i_o_n_,_ _u_s_i_n_g_ _S_H_A_-_1_ _h_a_s_h_e_s_ _ _ _ _ _ _ | │ │ │ │ |_V_2_ _ _|_1_ _ _ _ _|_V_e_r_s_i_o_n_ _2_ _o_f_ _t_h_e_ _B_i_t_T_o_r_r_e_n_t_ _p_r_o_t_o_c_o_l_,_ _u_s_i_n_g_ _S_H_A_-_2_5_6_ _h_a_s_h_e_s| │ │ │ │ |_N_U_M_ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ @@ -712,45 +697,50 @@ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n___i_n_t_e_r_f_a_c_e_._h_p_p" │ │ │ │ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ |_nn_aa_mm_ee_ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |_b_i_t_t_o_r_r_e_n_t_|_0_ _ _ _ _|_t_h_i_s_ _i_s_ _a_ _r_e_g_u_l_a_r_ _b_i_t_t_o_r_r_e_n_t_ _p_e_e_r_ _c_o_n_n_e_c_t_i_o_n| │ │ │ │ |_u_r_l___s_e_e_d_ _ _|_1_ _ _ _ _|_B_E_P_ _1_9_ _w_e_b_ _s_e_e_d_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ |_h_t_t_p___s_e_e_d_ _|_2_ _ _ _ _|_B_E_P_ _1_7_ _w_e_b_ _s_e_e_d_ _(_n_o_ _l_o_n_g_e_r_ _s_u_p_p_o_r_t_e_d_)_ _ _ _ _ _ _ | │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ eennuumm ssoocckkeett__ttyyppee__tt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_s_o_c_k_e_t___t_y_p_e_._h_p_p" │ │ │ │ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ │ │ │ │ +|_nn_aa_mm_ee_ _ _ _ _ _ _|_vv_aa_ll_uu_ee_|_dd_ee_ss_cc_rr_ii_pp_tt_ii_oo_nn| │ │ │ │ +|_t_c_p_ _ _ _ _ _ _ _|_0_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_o_c_k_s_5_ _ _ _ _|_1_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_h_t_t_p_ _ _ _ _ _ _|_2_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_u_t_p_ _ _ _ _ _ _ _|_3_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_i_2_p_ _ _ _ _ _ _ _|_4_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_r_t_c_ _ _ _ _ _ _ _|_5_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_t_c_p___s_s_l_ _ _ _|_6_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_s_o_c_k_s_5___s_s_l_|_7_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_h_t_t_p___s_s_l_ _ _|_8_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +|_u_t_p___s_s_l_ _ _ _|_9_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ | │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ iinntt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_v_e_r_s_i_o_n_._h_p_p" │ │ │ │ + version_major │ │ │ │ + the major, minor and tiny versions of libtorrent │ │ │ │ + version_minor │ │ │ │ + the major, minor and tiny versions of libtorrent │ │ │ │ + version_tiny │ │ │ │ + the major, minor and tiny versions of libtorrent │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ddoowwnnllooaadd__pprriioorriittyy__tt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_d_o_w_n_l_o_a_d___p_r_i_o_r_i_t_y_._h_p_p" │ │ │ │ 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. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ iinntt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_v_e_r_s_i_o_n_._h_p_p" │ │ │ │ - version_major │ │ │ │ - the major, minor and tiny versions of libtorrent │ │ │ │ - version_minor │ │ │ │ - the major, minor and tiny versions of libtorrent │ │ │ │ - version_tiny │ │ │ │ - the major, minor and tiny versions of libtorrent │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ cchhaarr ccoonnsstt** ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_v_e_r_s_i_o_n_._h_p_p" │ │ │ │ - version_str │ │ │ │ - the libtorrent version in string form │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -************ ssttdd::::uuiinntt6644__tt ************ │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_v_e_r_s_i_o_n_._h_p_p" │ │ │ │ - version_revision │ │ │ │ - the git commit of this libtorrent version │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ppeexx__ffllaaggss__tt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_x___f_l_a_g_s_._h_p_p" │ │ │ │ pex_encryption │ │ │ │ the peer supports protocol encryption │ │ │ │ pex_seed │ │ │ │ the peer is a seed │ │ │ │ pex_utp │ │ │ │ @@ -758,14 +748,24 @@ │ │ │ │ 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 │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ cchhaarr ccoonnsstt** ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_v_e_r_s_i_o_n_._h_p_p" │ │ │ │ + version_str │ │ │ │ + the libtorrent version in string form │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +************ ssttdd::::uuiinntt6644__tt ************ │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_v_e_r_s_i_o_n_._h_p_p" │ │ │ │ + version_revision │ │ │ │ + the git commit of this libtorrent version │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ttoorrrreenntt__ffllaaggss__tt ************ │ │ │ │ Declared in "_l_i_b_t_o_r_r_e_n_t_/_t_o_r_r_e_n_t___f_l_a_g_s_._h_p_p" │ │ │ │ seed_mode │ │ │ │ If seed_mode is set, libtorrent will assume that all files are present │ │ │ │ for this torrent and that they all match the hashes in the torrent file. │ │ │ │ Each time a peer requests to download a block, the piece is verified │ │ │ │ against the hash, unless it has been verified already. If a hash fails, │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Create_Torrents.html │ │ │ @@ -35,36 +35,36 @@ │ │ │

  • create_file_entry │ │ │
  • │ │ │
  • create_torrent │ │ │
  • │ │ │
  • list_files()
  • │ │ │
  • set_piece_hashes()
  • │ │ │ │ │ │
    │ │ │

    This section describes the functions and classes that are used │ │ │ @@ -167,16 +167,16 @@ │ │ │ the torrent. The entry that's returned can then be bencoded into a │ │ │ .torrent file using bencode().

    │ │ │
    │ │ │  struct create_torrent
    │ │ │  {
    │ │ │     explicit create_torrent (std::vector<create_file_entry> files, int piece_size = 0
    │ │ │        , create_flags_t flags = {});
    │ │ │ -   entry generate () const;
    │ │ │     std::vector<char> generate_buf () const;
    │ │ │ +   entry generate () const;
    │ │ │     void set_comment (char const* str);
    │ │ │     void set_creator (char const* str);
    │ │ │     void set_creation_date (std::time_t timestamp);
    │ │ │     void set_hash (piece_index_t index, sha1_hash const& h);
    │ │ │     void set_hash2 (file_index_t file, piece_index_t::diff_type piece, sha256_hash const& h);
    │ │ │     void add_url_seed (string_view url);
    │ │ │     void add_node (std::pair<std::string, int> node);
    │ │ │ @@ -192,16 +192,16 @@
    │ │ │     file_index_t end_file () const;
    │ │ │     index_range<file_index_t> file_range () const noexcept;
    │ │ │     create_file_entry const& file_at (file_index_t f) const;
    │ │ │     index_range<piece_index_t::diff_type> file_piece_range (file_index_t f);
    │ │ │     std::int64_t total_size () const;
    │ │ │     int piece_length () const;
    │ │ │     int piece_size (piece_index_t i) const;
    │ │ │ -   void add_collection (string_view c);
    │ │ │     void add_similar_torrent (sha1_hash ih);
    │ │ │ +   void add_collection (string_view c);
    │ │ │  
    │ │ │     static inline constexpr create_flags_t modification_time  = 2_bit;
    │ │ │     static inline constexpr create_flags_t symlinks  = 3_bit;
    │ │ │     static inline constexpr create_flags_t v2_only  = 5_bit;
    │ │ │     static inline constexpr create_flags_t v1_only  = 6_bit;
    │ │ │     static inline constexpr create_flags_t canonical_files  = 7_bit;
    │ │ │     static inline constexpr create_flags_t no_attributes  = 8_bit;
    │ │ │ @@ -247,21 +247,21 @@
    │ │ │  have any affect. Instead of using this overload, consider using
    │ │ │  write_torrent_file() instead.

    │ │ │
    │ │ │

    Warning

    │ │ │

    The file_storage and torrent_info objects must stay alive for the │ │ │ entire duration of the create_torrent object.

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

    generate_buf() generate()

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

    generate() generate_buf()

    │ │ │
    │ │ │ -entry generate () const;
    │ │ │  std::vector<char> generate_buf () const;
    │ │ │ +entry generate () const;
    │ │ │  
    │ │ │

    This function will generate the .torrent file as a bencode tree, or a │ │ │ bencoded into a buffer. │ │ │ In order to encode the entry into a flat file, use the bencode() function.

    │ │ │

    The function returning an entry 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 │ │ │ @@ -381,30 +381,30 @@ │ │ │

    │ │ │

    This function sets an X.509 certificate in PEM format to the torrent. This makes the │ │ │ torrent an SSL torrent. An SSL torrent requires that each peer has a valid certificate │ │ │ signed by this root certificate. For SSL torrents, all peers are connecting over SSL │ │ │ connections. For more information, see the section on ssl torrents.

    │ │ │

    The string is not the path to the cert, it's the actual content of the │ │ │ certificate.

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

    set_priv() priv()

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

    priv() set_priv()

    │ │ │
    │ │ │  bool priv () const;
    │ │ │  void set_priv (bool p);
    │ │ │  
    │ │ │

    Sets and queries the private flag of the torrent. │ │ │ Torrents with the private flag set ask the client to not use any other │ │ │ sources than the tracker for peers, and to not use DHT to advertise itself publicly, │ │ │ only the tracker.

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

    is_v2_only() is_v1_only()

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

    is_v1_only() is_v2_only()

    │ │ │
    │ │ │  bool is_v2_only () const;
    │ │ │  bool is_v1_only () const;
    │ │ │  
    │ │ │

    query which protocol versions will be written by this │ │ │ builder. is_v2_only() returns true if no v1 info dict │ │ │ will be written; is_v1_only() returns true if no v2 │ │ │ @@ -478,21 +478,21 @@ │ │ │

    │ │ │  int piece_length () const;
    │ │ │  int piece_size (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 file_storage.

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

    add_collection() add_similar_torrent()

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

    add_similar_torrent() add_collection()

    │ │ │
    │ │ │ -void add_collection (string_view c);
    │ │ │  void add_similar_torrent (sha1_hash ih);
    │ │ │ +void add_collection (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 BEP 38.

    │ │ │ @@ -557,17 +557,17 @@ │ │ │ [report issue]
    │ │ │ │ │ │
    │ │ │

    list_files()

    │ │ │

    Declared in "libtorrent/create_torrent.hpp"

    │ │ │
    │ │ │  std::vector<create_file_entry> list_files (std::string const& file
    │ │ │ -   , std::function<bool(std::string)> p, create_flags_t flags = {});
    │ │ │ -std::vector<create_file_entry> list_files (std::string const& file
    │ │ │     , create_flags_t flags = {});
    │ │ │ +std::vector<create_file_entry> list_files (std::string const& file
    │ │ │ +   , std::function<bool(std::string)> p, 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:

    │ │ │
    │ │ │ @@ -580,29 +580,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
    │ │ │ -   , settings_pack const& settings
    │ │ │ -   , std::function<void(piece_index_t)> const& f);
    │ │ │ +inline void set_piece_hashes (create_torrent& t, std::string const& p);
    │ │ │  void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │     , 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, 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_pack const& settings
    │ │ │     , std::function<void(piece_index_t)> const& f, error_code& ec);
    │ │ │  void set_piece_hashes (create_torrent& t, std::string const& p
    │ │ │     , settings_pack 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
    │ │ │ +   , settings_pack const& settings
    │ │ │ +   , std::function<void(piece_index_t)> const& f);
    │ │ │ +inline void set_piece_hashes (create_torrent& t, std::string const& p, error_code& ec);
    │ │ │  
    │ │ │

    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 {}
    │ │ │ │ @@ -4,36 +4,36 @@
    │ │ │ │  _h_o_m_e
    │ │ │ │  Table of contents
    │ │ │ │      * _c_r_e_a_t_e___f_i_l_e___e_n_t_r_y
    │ │ │ │            o _c_r_e_a_t_e___f_i_l_e___e_n_t_r_y_(_)
    │ │ │ │      * _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 _d_e_p_r_e_c_a_t_e_d_ _o_v_e_r_l_o_a_d_s
    │ │ │ │ -          o _g_e_n_e_r_a_t_e___b_u_f_(_)_ _g_e_n_e_r_a_t_e_(_)
    │ │ │ │ +          o _g_e_n_e_r_a_t_e_(_)_ _g_e_n_e_r_a_t_e___b_u_f_(_)
    │ │ │ │            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___u_r_l___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 _s_e_t___p_r_i_v_(_)_ _p_r_i_v_(_)
    │ │ │ │ -          o _i_s___v_2___o_n_l_y_(_)_ _i_s___v_1___o_n_l_y_(_)
    │ │ │ │ +          o _p_r_i_v_(_)_ _s_e_t___p_r_i_v_(_)
    │ │ │ │ +          o _i_s___v_1___o_n_l_y_(_)_ _i_s___v_2___o_n_l_y_(_)
    │ │ │ │            o _n_u_m___p_i_e_c_e_s_(_)
    │ │ │ │            o _e_n_d___p_i_e_c_e_(_)
    │ │ │ │            o _p_i_e_c_e___r_a_n_g_e_(_)
    │ │ │ │            o _e_n_d___f_i_l_e_(_)
    │ │ │ │            o _f_i_l_e___r_a_n_g_e_(_)
    │ │ │ │            o _f_i_l_e___a_t_(_)
    │ │ │ │            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___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_(_)
    │ │ │ │ +          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_(_)
    │ │ │ │      * _l_i_s_t___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
    │ │ │ │ @@ -116,16 +116,16 @@
    │ │ │ │  _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 (std::vector files, int
    │ │ │ │  piece_size = 0
    │ │ │ │        , create_flags_t flags = {});
    │ │ │ │ -   entry ggeenneerraattee () const;
    │ │ │ │     std::vector ggeenneerraattee__bbuuff () const;
    │ │ │ │ +   entry ggeenneerraattee () 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__uurrll__sseeeedd (string_view url);
    │ │ │ │ @@ -142,16 +142,16 @@
    │ │ │ │     file_index_t eenndd__ffiillee () const;
    │ │ │ │     index_range ffiillee__rraannggee () const noexcept;
    │ │ │ │     create_file_entry const& ffiillee__aatt (file_index_t f) const;
    │ │ │ │     index_range ffiillee__ppiieeccee__rraannggee (file_index_t f);
    │ │ │ │     std::int64_t ttoottaall__ssiizzee () const;
    │ │ │ │     int ppiieeccee__lleennggtthh () const;
    │ │ │ │     int ppiieeccee__ssiizzee (piece_index_t i) const;
    │ │ │ │ -   void aadddd__ccoolllleeccttiioonn (string_view c);
    │ │ │ │     void aadddd__ssiimmiillaarr__ttoorrrreenntt (sha1_hash ih);
    │ │ │ │ +   void aadddd__ccoolllleeccttiioonn (string_view c);
    │ │ │ │  
    │ │ │ │     static inline constexpr create_flags_t mmooddiiffiiccaattiioonn__ttiimmee  = 2_bit;
    │ │ │ │     static inline constexpr create_flags_t ssyymmlliinnkkss  = 3_bit;
    │ │ │ │     static inline constexpr create_flags_t vv22__oonnllyy  = 5_bit;
    │ │ │ │     static inline constexpr create_flags_t vv11__oonnllyy  = 6_bit;
    │ │ │ │     static inline constexpr create_flags_t ccaannoonniiccaall__ffiilleess  = 7_bit;
    │ │ │ │     static inline constexpr create_flags_t nnoo__aattttrriibbuutteess  = 8_bit;
    │ │ │ │ @@ -190,17 +190,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__bbuuff(()) ggeenneerraattee(()) **********
    │ │ │ │ -entry ggeenneerraattee () const;
    │ │ │ │ +********** ggeenneerraattee(()) ggeenneerraattee__bbuuff(()) **********
    │ │ │ │  std::vector ggeenneerraattee__bbuuff () const;
    │ │ │ │ +entry ggeenneerraattee () 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
    │ │ │ │ @@ -287,22 +287,22 @@
    │ │ │ │  makes the torrent an SSSSLL ttoorrrreenntt. An SSL torrent requires that each peer has a
    │ │ │ │  valid certificate signed by this root certificate. For SSL torrents, all peers
    │ │ │ │  are connecting over SSL connections. For more information, see the section on
    │ │ │ │  _s_s_l_ _t_o_r_r_e_n_t_s.
    │ │ │ │  The string is not the path to the cert, it's the actual content of the
    │ │ │ │  certificate.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** sseett__pprriivv(()) pprriivv(()) **********
    │ │ │ │ +********** pprriivv(()) sseett__pprriivv(()) **********
    │ │ │ │  bool pprriivv () const;
    │ │ │ │  void sseett__pprriivv (bool p);
    │ │ │ │  Sets and queries the private flag of the torrent. Torrents with the private
    │ │ │ │  flag set ask the client to not use any other sources than the tracker for
    │ │ │ │  peers, and to not use DHT to advertise itself publicly, only the tracker.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** iiss__vv22__oonnllyy(()) iiss__vv11__oonnllyy(()) **********
    │ │ │ │ +********** iiss__vv11__oonnllyy(()) iiss__vv22__oonnllyy(()) **********
    │ │ │ │  bool iiss__vv22__oonnllyy () const;
    │ │ │ │  bool iiss__vv11__oonnllyy () const;
    │ │ │ │  query which protocol versions will be written by this builder. is_v2_only()
    │ │ │ │  returns true if no v1 info dict will be written; is_v1_only() returns true if
    │ │ │ │  no v2 file tree will be written. A torrent that is neither v1-only nor v2-only
    │ │ │ │  is a hybrid v1+v2 torrent.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ @@ -345,17 +345,17 @@
    │ │ │ │  ********** 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__ccoolllleeccttiioonn(()) aadddd__ssiimmiillaarr__ttoorrrreenntt(()) **********
    │ │ │ │ -void aadddd__ccoolllleeccttiioonn (string_view c);
    │ │ │ │ +********** aadddd__ssiimmiillaarr__ttoorrrreenntt(()) aadddd__ccoolllleeccttiioonn(()) **********
    │ │ │ │  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.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │    modification_time
    │ │ │ │ @@ -405,17 +405,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]
    │ │ │ │  ************ lliisstt__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"
    │ │ │ │  std::vector lliisstt__ffiilleess (std::string const& file
    │ │ │ │ -   , std::function p, create_flags_t flags = {});
    │ │ │ │ -std::vector lliisstt__ffiilleess (std::string const& file
    │ │ │ │     , create_flags_t flags = {});
    │ │ │ │ +std::vector lliisstt__ffiilleess (std::string const& file
    │ │ │ │ +   , std::function p, 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
    │ │ │ │ @@ -423,30 +423,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"
    │ │ │ │ -inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │ -   , settings_pack const& settings
    │ │ │ │ -   , std::function const& f);
    │ │ │ │ +inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& 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
    │ │ │ │     , std::function const& f);
    │ │ │ │ -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);
    │ │ │ │  void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │     , settings_pack const& settings
    │ │ │ │     , std::function const& f, error_code& ec);
    │ │ │ │  void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p
    │ │ │ │     , settings_pack 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
    │ │ │ │ +   , settings_pack const& settings
    │ │ │ │ +   , std::function const& f);
    │ │ │ │ +inline void sseett__ppiieeccee__hhaasshheess (create_torrent& t, std::string const& p,
    │ │ │ │ +error_code& ec);
    │ │ │ │  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
    │ │ │ @@ -28,92 +28,418 @@
    │ │ │  2.1.2
    │ │ │  
    │ │ │  
    │ │ │  

    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 │ │ │ -to the session when passed to session::apply_settings(). It's empty when │ │ │ -constructed.

    │ │ │ -

    You have control over proxy and authorization settings and also the user-agent │ │ │ -that will be sent to the tracker. The user-agent will also be used to identify the │ │ │ -client with other peers.

    │ │ │ -

    Each configuration option is named with an enum value inside the │ │ │ -settings_pack class. These are the available settings:

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

    The disk I/O can be customized in libtorrent. In previous versions, the │ │ │ +customization was at the level of each torrent. Now, the customization point │ │ │ +is at the session level. All torrents added to a session will use the same │ │ │ +disk I/O subsystem, as determined by the disk_io_constructor (in │ │ │ +session_params).

    │ │ │ +

    This allows the disk subsystem to also customize threading and disk job │ │ │ +management.

    │ │ │ +

    To customize the disk subsystem, implement disk_interface and provide a │ │ │ +factory function to the session constructor (via session_params).

    │ │ │ +

    Example use:

    │ │ │ +
    │ │ │ +struct temp_storage
    │ │ │ +{
    │ │ │ +  explicit temp_storage(lt::file_storage const& fs) : m_files(fs) {}
    │ │ │ +
    │ │ │ +  lt::span<char const> readv(lt::peer_request const r, lt::storage_error& ec) const
    │ │ │ +  {
    │ │ │ +    auto const i = m_file_data.find(r.piece);
    │ │ │ +    if (i == m_file_data.end())
    │ │ │ +    {
    │ │ │ +      ec.operation = lt::operation_t::file_read;
    │ │ │ +      ec.ec = boost::asio::error::eof;
    │ │ │ +      return {};
    │ │ │ +    }
    │ │ │ +    if (int(i->second.size()) <= r.start)
    │ │ │ +    {
    │ │ │ +      ec.operation = lt::operation_t::file_read;
    │ │ │ +      ec.ec = boost::asio::error::eof;
    │ │ │ +      return {};
    │ │ │ +    }
    │ │ │ +    return { i->second.data() + r.start, std::min(r.length, int(i->second.size()) - r.start) };
    │ │ │ +  }
    │ │ │ +  void writev(lt::span<char const> const b, lt::piece_index_t const piece, int const offset)
    │ │ │ +  {
    │ │ │ +    auto& data = m_file_data[piece];
    │ │ │ +    if (data.empty())
    │ │ │ +    {
    │ │ │ +      // allocate the whole piece, otherwise we'll invalidate the pointers
    │ │ │ +      // we have returned back to libtorrent
    │ │ │ +      int const size = piece_size(piece);
    │ │ │ +      data.resize(std::size_t(size));
    │ │ │ +    }
    │ │ │ +    TORRENT_ASSERT(offset + b.size() <= int(data.size()));
    │ │ │ +    std::memcpy(data.data() + offset, b.data(), std::size_t(b.size()));
    │ │ │ +  }
    │ │ │ +  lt::sha1_hash hash(lt::piece_index_t const piece
    │ │ │ +    , lt::span<lt::sha256_hash> const block_hashes, lt::storage_error& ec) const
    │ │ │ +  {
    │ │ │ +    auto const i = m_file_data.find(piece);
    │ │ │ +    if (i == m_file_data.end())
    │ │ │ +    {
    │ │ │ +      ec.operation = lt::operation_t::file_read;
    │ │ │ +      ec.ec = boost::asio::error::eof;
    │ │ │ +      return {};
    │ │ │ +    }
    │ │ │ +    if (!block_hashes.empty())
    │ │ │ +    {
    │ │ │ +      int const piece_size2 = m_files.piece_size2(piece);
    │ │ │ +      int const blocks_in_piece2 = m_files.blocks_in_piece2(piece);
    │ │ │ +      char const* buf = i->second.data();
    │ │ │ +      std::int64_t offset = 0;
    │ │ │ +      for (int k = 0; k < blocks_in_piece2; ++k)
    │ │ │ +      {
    │ │ │ +        lt::hasher256 h2;
    │ │ │ +        std::ptrdiff_t const len2 = std::min(lt::default_block_size, int(piece_size2 - offset));
    │ │ │ +        h2.update({ buf, len2 });
    │ │ │ +        buf += len2;
    │ │ │ +        offset += len2;
    │ │ │ +        block_hashes[k] = h2.final();
    │ │ │ +      }
    │ │ │ +    }
    │ │ │ +    return lt::hasher(i->second).final();
    │ │ │ +  }
    │ │ │ +  lt::sha256_hash hash2(lt::piece_index_t const piece, int const offset, lt::storage_error& ec)
    │ │ │ +  {
    │ │ │ +    auto const i = m_file_data.find(piece);
    │ │ │ +    if (i == m_file_data.end())
    │ │ │ +    {
    │ │ │ +      ec.operation = lt::operation_t::file_read;
    │ │ │ +      ec.ec = boost::asio::error::eof;
    │ │ │ +      return {};
    │ │ │ +    }
    │ │ │ +
    │ │ │ +    int const piece_size = m_files.piece_size2(piece);
    │ │ │ +
    │ │ │ +    std::ptrdiff_t const len = std::min(lt::default_block_size, piece_size - offset);
    │ │ │ +
    │ │ │ +    lt::span<char const> b = {i->second.data() + offset, len};
    │ │ │ +    return lt::hasher256(b).final();
    │ │ │ +  }
    │ │ │ +
    │ │ │ +private:
    │ │ │ +  int piece_size(lt::piece_index_t piece) const
    │ │ │ +  {
    │ │ │ +    int const num_pieces = static_cast<int>((m_files.total_size() + m_files.piece_length() - 1) / m_files.piece_length());
    │ │ │ +    return static_cast<int>(piece) < num_pieces - 1
    │ │ │ +      ? m_files.piece_length() : static_cast<int>(m_files.total_size() - std::int64_t(num_pieces - 1) * m_files.piece_length());
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  lt::file_storage const& m_files;
    │ │ │ +  std::map<lt::piece_index_t, std::vector<char>> m_file_data;
    │ │ │ +};
    │ │ │ +
    │ │ │ +lt::storage_index_t pop(std::vector<lt::storage_index_t>& q)
    │ │ │ +{
    │ │ │ +  TORRENT_ASSERT(!q.empty());
    │ │ │ +  lt::storage_index_t const ret = q.back();
    │ │ │ +  q.pop_back();
    │ │ │ +  return ret;
    │ │ │ +}
    │ │ │ +
    │ │ │ +struct temp_disk_io final : lt::disk_interface
    │ │ │ +  , lt::buffer_allocator_interface
    │ │ │ +{
    │ │ │ +  explicit temp_disk_io(lt::io_context& ioc): m_ioc(ioc) {}
    │ │ │ +
    │ │ │ +  void settings_updated() override {}
    │ │ │ +
    │ │ │ +  lt::storage_holder new_torrent(lt::storage_params const& params
    │ │ │ +    , std::shared_ptr<void> const&) override
    │ │ │ +  {
    │ │ │ +    lt::storage_index_t const idx = m_free_slots.empty()
    │ │ │ +      ? m_torrents.end_index()
    │ │ │ +      : pop(m_free_slots);
    │ │ │ +    auto storage = std::make_unique<temp_storage>(params.files);
    │ │ │ +    if (idx == m_torrents.end_index()) m_torrents.emplace_back(std::move(storage));
    │ │ │ +    else m_torrents[idx] = std::move(storage);
    │ │ │ +    return lt::storage_holder(idx, *this);
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void remove_torrent(lt::storage_index_t const idx) override
    │ │ │ +  {
    │ │ │ +    m_torrents[idx].reset();
    │ │ │ +    m_free_slots.push_back(idx);
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void abort(bool) override {}
    │ │ │ +
    │ │ │ +  void async_read(lt::storage_index_t storage, lt::peer_request const& r
    │ │ │ +    , std::function<void(lt::disk_buffer_holder block, lt::storage_error const& se)> handler
    │ │ │ +    , lt::disk_job_flags_t) override
    │ │ │ +  {
    │ │ │ +    // this buffer is owned by the storage. It will remain valid for as
    │ │ │ +    // long as the torrent remains in the session. We don't need any lifetime
    │ │ │ +    // management of it.
    │ │ │ +    lt::storage_error error;
    │ │ │ +    lt::span<char const> b = m_torrents[storage]->readv(r, error);
    │ │ │ +
    │ │ │ +    post(m_ioc, [handler, error, b, this] {
    │ │ │ +      handler(lt::disk_buffer_holder(*this, const_cast<char*>(b.data())), error);
    │ │ │ +    });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  bool async_write(lt::storage_index_t storage, lt::peer_request const& r
    │ │ │ +    , char const* buf, std::shared_ptr<lt::disk_observer>
    │ │ │ +    , std::function<void(lt::storage_error const&)> handler
    │ │ │ +    , lt::disk_job_flags_t) override
    │ │ │ +  {
    │ │ │ +    lt::span<char const> const b = { buf, r.length };
    │ │ │ +
    │ │ │ +    m_torrents[storage]->writev(b, r.piece, r.start);
    │ │ │ +
    │ │ │ +    post(m_ioc, [=]{ handler(lt::storage_error()); });
    │ │ │ +    return false;
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_hash(lt::storage_index_t storage, lt::piece_index_t const piece
    │ │ │ +    , lt::span<lt::sha256_hash> block_hashes, lt::disk_job_flags_t
    │ │ │ +    , std::function<void(lt::piece_index_t, lt::sha1_hash const&, lt::storage_error const&)> handler) override
    │ │ │ +  {
    │ │ │ +    lt::storage_error error;
    │ │ │ +    lt::sha1_hash const hash = m_torrents[storage]->hash(piece, block_hashes, error);
    │ │ │ +    post(m_ioc, [=]{ handler(piece, hash, error); });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_hash2(lt::storage_index_t storage, lt::piece_index_t const piece
    │ │ │ +    , int const offset, lt::disk_job_flags_t
    │ │ │ +    , std::function<void(lt::piece_index_t, lt::sha256_hash const&, lt::storage_error const&)> handler) override
    │ │ │ +  {
    │ │ │ +    lt::storage_error error;
    │ │ │ +    lt::sha256_hash const hash = m_torrents[storage]->hash2(piece, offset, error);
    │ │ │ +    post(m_ioc, [=]{ handler(piece, hash, error); });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_move_storage(lt::storage_index_t, std::string p, lt::move_flags_t
    │ │ │ +    , std::function<void(lt::status_t, std::string const&, lt::storage_error const&)> handler) override
    │ │ │ +  {
    │ │ │ +    post(m_ioc, [=]{
    │ │ │ +      handler(lt::disk_status::fatal_disk_error, p
    │ │ │ +        , lt::storage_error(lt::error_code(boost::system::errc::operation_not_supported, lt::system_category())));
    │ │ │ +    });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_release_files(lt::storage_index_t, std::function<void()>) override {}
    │ │ │ +
    │ │ │ +  void async_delete_files(lt::storage_index_t, lt::remove_flags_t
    │ │ │ +    , std::function<void(lt::storage_error const&)> handler) override
    │ │ │ +  {
    │ │ │ +    post(m_ioc, [=]{ handler(lt::storage_error()); });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_check_files(lt::storage_index_t
    │ │ │ +    , lt::add_torrent_params const*
    │ │ │ +    , lt::aux::vector<std::string, lt::file_index_t>
    │ │ │ +    , std::function<void(lt::status_t, lt::storage_error const&)> handler) override
    │ │ │ +  {
    │ │ │ +    post(m_ioc, [=]{ handler(lt::status_t{}, lt::storage_error()); });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_rename_file(lt::storage_index_t
    │ │ │ +    , lt::file_index_t const idx
    │ │ │ +    , std::string const name
    │ │ │ +    , std::function<void(std::string const&, lt::file_index_t, lt::storage_error const&)> handler) override
    │ │ │ +  {
    │ │ │ +    post(m_ioc, [=]{ handler(name, idx, lt::storage_error()); });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_stop_torrent(lt::storage_index_t, std::function<void()> handler) override
    │ │ │ +  {
    │ │ │ +    post(m_ioc, handler);
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_set_file_priority(lt::storage_index_t
    │ │ │ +    , lt::aux::vector<lt::download_priority_t, lt::file_index_t> prio
    │ │ │ +    , std::function<void(lt::storage_error const&
    │ │ │ +      , lt::aux::vector<lt::download_priority_t, lt::file_index_t>)> handler) override
    │ │ │ +  {
    │ │ │ +    post(m_ioc, [=]{
    │ │ │ +      handler(lt::storage_error(lt::error_code(
    │ │ │ +        boost::system::errc::operation_not_supported, lt::system_category())), std::move(prio));
    │ │ │ +    });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  void async_clear_piece(lt::storage_index_t, lt::piece_index_t index
    │ │ │ +    , std::function<void(lt::piece_index_t)> handler) override
    │ │ │ +  {
    │ │ │ +    post(m_ioc, [=]{ handler(index); });
    │ │ │ +  }
    │ │ │ +
    │ │ │ +  // implements buffer_allocator_interface
    │ │ │ +  void free_disk_buffer(char*) override
    │ │ │ +  {
    │ │ │ +    // never free any buffer. We only return buffers owned by the storage
    │ │ │ +    // object
    │ │ │ +  }
    │ │ │ +  void free_multiple_buffers(lt::span<char*>) override
    │ │ │ +  {
    │ │ │ +    // never free any buffer. We only return buffers owned by the storage
    │ │ │ +    // object
    │ │ │ +  }
    │ │ │ +#if TORRENT_DEBUG_BUFFER_POOL
    │ │ │ +  void rename_buffer(char*, char const*) override {}
    │ │ │ +#endif
    │ │ │ +
    │ │ │ +  void update_stats_counters(lt::counters&) const override {}
    │ │ │ +
    │ │ │ +  std::vector<lt::open_file_state> get_status(lt::storage_index_t) const override
    │ │ │ +  { return {}; }
    │ │ │ +
    │ │ │ +  void submit_jobs() override {}
    │ │ │ +
    │ │ │ +private:
    │ │ │ +
    │ │ │ +  lt::aux::vector<std::shared_ptr<temp_storage>, lt::storage_index_t> m_torrents;
    │ │ │ +
    │ │ │ +  // slots that are unused in the m_torrents vector
    │ │ │ +  std::vector<lt::storage_index_t> m_free_slots;
    │ │ │ +
    │ │ │ +  // callbacks are posted on this
    │ │ │ +  lt::io_context& m_ioc;
    │ │ │ +};
    │ │ │ +
    │ │ │ +std::unique_ptr<lt::disk_interface> temp_disk_constructor(
    │ │ │ +  lt::io_context& ioc, lt::settings_interface const&, lt::counters&)
    │ │ │ +{
    │ │ │ +  return std::make_unique<temp_disk_io>(ioc);
    │ │ │ +}
    │ │ │ +
    │ │ │ +[report issue]
    │ │ │ +

    settings_interface

    │ │ │ +

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ +

    the common interface to settings_pack and the internal representation of │ │ │ +settings.

    │ │ │ +
    │ │ │ +struct settings_interface
    │ │ │ +{
    │ │ │ +   virtual void set_str (int name, std::string val) = 0;
    │ │ │ +   virtual void set_int (int name, int val) = 0;
    │ │ │ +   virtual void set_bool (int name, bool val) = 0;
    │ │ │ +   virtual bool has_val (int name) const = 0;
    │ │ │ +   virtual std::string const& get_str (int name) const = 0;
    │ │ │ +   virtual int get_int (int name) const = 0;
    │ │ │ +   virtual bool get_bool (int name) const = 0;
    │ │ │ +};
    │ │ │ +
    │ │ │ + │ │ │ + │ │ │ +[report issue]
    │ │ │ +

    set_int() set_bool() set_str()

    │ │ │ +
    │ │ │ +virtual void set_str (int name, std::string val) = 0;
    │ │ │ +virtual void set_int (int name, int val) = 0;
    │ │ │ +virtual void set_bool (int name, bool val) = 0;
    │ │ │ +
    │ │ │ +

    store the value of a single setting. name is one of the │ │ │ +enum values from settings_pack::string_types, │ │ │ +int_types or bool_types. The setter must match the │ │ │ +type of the setting: set_str() only accepts names from │ │ │ +string_types, set_int() from int_types and │ │ │ +set_bool() from bool_types. Passing a name of the │ │ │ +wrong type asserts in debug builds and is ignored otherwise.

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

    has_val()

    │ │ │ +
    │ │ │ +virtual bool has_val (int name) const = 0;
    │ │ │ +
    │ │ │ +

    returns true if a value has been explicitly set for the │ │ │ +setting name. If false, reads of that setting return │ │ │ +the default value.

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

    get_bool() get_int() get_str()

    │ │ │ +
    │ │ │ +virtual std::string const& get_str (int name) const = 0;
    │ │ │ +virtual int get_int (int name) const = 0;
    │ │ │ +virtual bool get_bool (int name) const = 0;
    │ │ │ +
    │ │ │ +

    retrieve the current value of a single setting. name is │ │ │ +one of the enum values from settings_pack::string_types, │ │ │ +int_types or bool_types. The getter must match the │ │ │ +type of the setting; if no value has been set, the default │ │ │ +value of the setting is returned.

    │ │ │ +[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
    │ │ │  {
    │ │ │ @@ -156,21 +482,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;
    │ │ │ @@ -222,26 +548,26 @@
    │ │ │  

    remove_torrent()

    │ │ │
    │ │ │  virtual void remove_torrent (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.

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

    async_read() async_write()

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

    async_write() async_read()

    │ │ │
    │ │ │ -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 │ │ │ @@ -587,16 +913,16 @@ │ │ │

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

    │ │ │
    │ │ │  struct disk_buffer_holder
    │ │ │  {
    │ │ │     disk_buffer_holder& operator= (disk_buffer_holder&&) & noexcept;
    │ │ │     disk_buffer_holder (disk_buffer_holder&&) noexcept;
    │ │ │ -   disk_buffer_holder (disk_buffer_holder const&) = delete;
    │ │ │     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) noexcept;
    │ │ │     disk_buffer_holder () noexcept = default;
    │ │ │     ~disk_buffer_holder ();
    │ │ │     char* data () const noexcept;
    │ │ │     void reset ();
    │ │ │     void swap (disk_buffer_holder& h) noexcept;
    │ │ │     bool is_mutable () const noexcept;
    │ │ │ @@ -673,39 +999,39 @@
    │ │ │  before this goes out of scope. Since it has no allocator, it cannot free the
    │ │ │  buffer itself.

    │ │ │
    │ │ │  struct disk_buffer_ref
    │ │ │  {
    │ │ │     disk_buffer_ref () noexcept = default;
    │ │ │     explicit disk_buffer_ref (disk_buffer_holder&& h) noexcept;
    │ │ │ -   ~disk_buffer_ref ();
    │ │ │ -   disk_buffer_ref (disk_buffer_ref const&) = delete;
    │ │ │ -   disk_buffer_ref& operator= (disk_buffer_ref const&) = delete;
    │ │ │     disk_buffer_ref (disk_buffer_ref&&) noexcept;
    │ │ │     disk_buffer_ref& operator= (disk_buffer_ref&&) noexcept;
    │ │ │ -   char* data () const noexcept;
    │ │ │ +   disk_buffer_ref (disk_buffer_ref const&) = delete;
    │ │ │ +   ~disk_buffer_ref ();
    │ │ │ +   disk_buffer_ref& operator= (disk_buffer_ref const&) = delete;
    │ │ │     explicit operator bool () const noexcept;
    │ │ │ +   char* data () const noexcept;
    │ │ │  };
    │ │ │  
    │ │ │ [report issue]
    │ │ │

    disk_buffer_ref()

    │ │ │
    │ │ │  explicit disk_buffer_ref (disk_buffer_holder&& h) noexcept;
    │ │ │  
    │ │ │

    take ownership of the buffer held by h, leaving h │ │ │ empty. The buffer must subsequently be transferred to a │ │ │ bulk_free_buffer for release; this type cannot free the │ │ │ buffer itself.

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

    data() bool()

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

    bool() data()

    │ │ │
    │ │ │ -char* data () const noexcept;
    │ │ │  explicit operator bool () const noexcept;
    │ │ │ +char* data () const noexcept;
    │ │ │  
    │ │ │

    returns a pointer to the held buffer, or nullptr if this │ │ │ reference is empty. operator bool() returns true iff a │ │ │ buffer is held.

    │ │ │ [report issue]
    │ │ │
    │ │ │
    │ │ │ @@ -715,94 +1041,35 @@ │ │ │ allocator mutex acquisitions from one per buffer to one per batch. │ │ │ All buffers added must share the same allocator. │ │ │ Freeing happens in the destructor.

    │ │ │
    │ │ │  struct bulk_free_buffer
    │ │ │  {
    │ │ │     explicit bulk_free_buffer (buffer_allocator_interface& alloc);
    │ │ │ -   ~bulk_free_buffer ();
    │ │ │     void add (disk_buffer_ref r);
    │ │ │ +   ~bulk_free_buffer ();
    │ │ │  };
    │ │ │  
    │ │ │ [report issue]
    │ │ │

    bulk_free_buffer()

    │ │ │
    │ │ │  explicit bulk_free_buffer (buffer_allocator_interface& alloc);
    │ │ │  
    │ │ │

    construct an empty batch tied to the given allocator. All │ │ │ buffers added via add() must have come from this same │ │ │ allocator. The batch is freed in the destructor.

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

    ~bulk_free_buffer() add()

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

    add() ~bulk_free_buffer()

    │ │ │
    │ │ │ -~bulk_free_buffer ();
    │ │ │  void add (disk_buffer_ref r);
    │ │ │ +~bulk_free_buffer ();
    │ │ │  
    │ │ │

    transfer ownership of h's buffer into this batch.

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

    settings_interface

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

    │ │ │ -

    the common interface to settings_pack and the internal representation of │ │ │ -settings.

    │ │ │ -
    │ │ │ -struct settings_interface
    │ │ │ -{
    │ │ │ -   virtual void set_bool (int name, bool val) = 0;
    │ │ │ -   virtual void set_str (int name, std::string val) = 0;
    │ │ │ -   virtual void set_int (int name, int val) = 0;
    │ │ │ -   virtual bool has_val (int name) const = 0;
    │ │ │ -   virtual bool get_bool (int name) const = 0;
    │ │ │ -   virtual int get_int (int name) const = 0;
    │ │ │ -   virtual std::string const& get_str (int name) const = 0;
    │ │ │ -};
    │ │ │ -
    │ │ │ - │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    set_int() set_str() set_bool()

    │ │ │ -
    │ │ │ -virtual void set_bool (int name, bool val) = 0;
    │ │ │ -virtual void set_str (int name, std::string val) = 0;
    │ │ │ -virtual void set_int (int name, int val) = 0;
    │ │ │ -
    │ │ │ -

    store the value of a single setting. name is one of the │ │ │ -enum values from settings_pack::string_types, │ │ │ -int_types or bool_types. The setter must match the │ │ │ -type of the setting: set_str() only accepts names from │ │ │ -string_types, set_int() from int_types and │ │ │ -set_bool() from bool_types. Passing a name of the │ │ │ -wrong type asserts in debug builds and is ignored otherwise.

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

    has_val()

    │ │ │ -
    │ │ │ -virtual bool has_val (int name) const = 0;
    │ │ │ -
    │ │ │ -

    returns true if a value has been explicitly set for the │ │ │ -setting name. If false, reads of that setting return │ │ │ -the default value.

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

    get_int() get_bool() get_str()

    │ │ │ -
    │ │ │ -virtual bool get_bool (int name) const = 0;
    │ │ │ -virtual int get_int (int name) const = 0;
    │ │ │ -virtual std::string const& get_str (int name) const = 0;
    │ │ │ -
    │ │ │ -

    retrieve the current value of a single setting. name is │ │ │ -one of the enum values from settings_pack::string_types, │ │ │ -int_types or bool_types. The getter must match the │ │ │ -type of the setting; if no value has been set, the default │ │ │ -value of the setting is returned.

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

    status_t

    │ │ │

    Declared in "libtorrent/disk_interface.hpp"

    │ │ │
    │ │ │
    fatal_disk_error
    │ │ │ ├── html2text {} │ │ │ │ @@ -1,17 +1,21 @@ │ │ │ │ > │ │ │ │ _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_] │ │ │ │ VVeerrssiioonn:: 2.1.2 │ │ │ │ _h_o_m_e │ │ │ │ Table of contents │ │ │ │ + * _s_e_t_t_i_n_g_s___i_n_t_e_r_f_a_c_e │ │ │ │ + o _s_e_t___i_n_t_(_)_ _s_e_t___b_o_o_l_(_)_ _s_e_t___s_t_r_(_) │ │ │ │ + o _h_a_s___v_a_l_(_) │ │ │ │ + o _g_e_t___b_o_o_l_(_)_ _g_e_t___i_n_t_(_)_ _g_e_t___s_t_r_(_) │ │ │ │ * _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___w_r_i_t_e_(_)_ _a_s_y_n_c___r_e_a_d_(_) │ │ │ │ o _a_s_y_n_c___h_a_s_h_(_) │ │ │ │ o _a_s_y_n_c___h_a_s_h_2_(_) │ │ │ │ o _a_s_y_n_c___m_o_v_e___s_t_o_r_a_g_e_(_) │ │ │ │ o _a_s_y_n_c___r_e_l_e_a_s_e___f_i_l_e_s_(_) │ │ │ │ o _a_s_y_n_c___c_h_e_c_k___f_i_l_e_s_(_) │ │ │ │ o _a_s_y_n_c___s_t_o_p___t_o_r_r_e_n_t_(_) │ │ │ │ o _a_s_y_n_c___r_e_n_a_m_e___f_i_l_e_(_) │ │ │ │ @@ -37,36 +41,360 @@ │ │ │ │ o _d_a_t_a_(_) │ │ │ │ o _r_e_s_e_t_(_) │ │ │ │ o _s_w_a_p_(_) │ │ │ │ o _i_s___m_u_t_a_b_l_e_(_) │ │ │ │ o _b_o_o_l_(_) │ │ │ │ * _d_i_s_k___b_u_f_f_e_r___r_e_f │ │ │ │ o _d_i_s_k___b_u_f_f_e_r___r_e_f_(_) │ │ │ │ - o _d_a_t_a_(_)_ _b_o_o_l_(_) │ │ │ │ + o _b_o_o_l_(_)_ _d_a_t_a_(_) │ │ │ │ * _b_u_l_k___f_r_e_e___b_u_f_f_e_r │ │ │ │ o _b_u_l_k___f_r_e_e___b_u_f_f_e_r_(_) │ │ │ │ - o _~_b_u_l_k___f_r_e_e___b_u_f_f_e_r_(_)_ _a_d_d_(_) │ │ │ │ - * _s_e_t_t_i_n_g_s___i_n_t_e_r_f_a_c_e │ │ │ │ - o _s_e_t___i_n_t_(_)_ _s_e_t___s_t_r_(_)_ _s_e_t___b_o_o_l_(_) │ │ │ │ - o _h_a_s___v_a_l_(_) │ │ │ │ - o _g_e_t___i_n_t_(_)_ _g_e_t___b_o_o_l_(_)_ _g_e_t___s_t_r_(_) │ │ │ │ + o _a_d_d_(_)_ _~_b_u_l_k___f_r_e_e___b_u_f_f_e_r_(_) │ │ │ │ * _s_t_a_t_u_s___t │ │ │ │ * _f_i_l_e___o_p_e_n___m_o_d_e___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 │ │ │ │ -constructed. │ │ │ │ -You have control over proxy and authorization settings and also the user-agent │ │ │ │ -that will be sent to the tracker. The user-agent will also be used to identify │ │ │ │ -the client with other peers. │ │ │ │ -Each configuration option is named with an enum value inside the _s_e_t_t_i_n_g_s___p_a_c_k │ │ │ │ -class. These are the available settings: │ │ │ │ +The disk I/O can be customized in libtorrent. In previous versions, the │ │ │ │ +customization was at the level of each torrent. Now, the customization point is │ │ │ │ +at the _s_e_s_s_i_o_n level. All torrents added to a _s_e_s_s_i_o_n will use the same disk I/ │ │ │ │ +O subsystem, as determined by the disk_io_constructor (in _s_e_s_s_i_o_n___p_a_r_a_m_s). │ │ │ │ +This allows the disk subsystem to also customize threading and disk job │ │ │ │ +management. │ │ │ │ +To customize the disk subsystem, implement _d_i_s_k___i_n_t_e_r_f_a_c_e and provide a factory │ │ │ │ +function to the _s_e_s_s_i_o_n constructor (via _s_e_s_s_i_o_n___p_a_r_a_m_s). │ │ │ │ +Example use: │ │ │ │ +struct temp_storage │ │ │ │ +{ │ │ │ │ + explicit temp_storage(lt::file_storage const& fs) : m_files(fs) {} │ │ │ │ + │ │ │ │ + lt::span readv(lt::peer_request const r, lt::storage_error& ec) │ │ │ │ +const │ │ │ │ + { │ │ │ │ + auto const i = m_file_data.find(r.piece); │ │ │ │ + if (i == m_file_data.end()) │ │ │ │ + { │ │ │ │ + ec.operation = lt::operation_t::file_read; │ │ │ │ + ec.ec = boost::asio::error::eof; │ │ │ │ + return {}; │ │ │ │ + } │ │ │ │ + if (int(i->second.size()) <= r.start) │ │ │ │ + { │ │ │ │ + ec.operation = lt::operation_t::file_read; │ │ │ │ + ec.ec = boost::asio::error::eof; │ │ │ │ + return {}; │ │ │ │ + } │ │ │ │ + return { i->second.data() + r.start, std::min(r.length, int(i->second.size │ │ │ │ +()) - r.start) }; │ │ │ │ + } │ │ │ │ + void writev(lt::span const b, lt::piece_index_t const piece, int │ │ │ │ +const offset) │ │ │ │ + { │ │ │ │ + auto& data = m_file_data[piece]; │ │ │ │ + if (data.empty()) │ │ │ │ + { │ │ │ │ + // allocate the whole piece, otherwise we'll invalidate the pointers │ │ │ │ + // we have returned back to libtorrent │ │ │ │ + int const size = piece_size(piece); │ │ │ │ + data.resize(std::size_t(size)); │ │ │ │ + } │ │ │ │ + TORRENT_ASSERT(offset + b.size() <= int(data.size())); │ │ │ │ + std::memcpy(data.data() + offset, b.data(), std::size_t(b.size())); │ │ │ │ + } │ │ │ │ + lt::sha1_hash hash(lt::piece_index_t const piece │ │ │ │ + , lt::span const block_hashes, lt::storage_error& ec) │ │ │ │ +const │ │ │ │ + { │ │ │ │ + auto const i = m_file_data.find(piece); │ │ │ │ + if (i == m_file_data.end()) │ │ │ │ + { │ │ │ │ + ec.operation = lt::operation_t::file_read; │ │ │ │ + ec.ec = boost::asio::error::eof; │ │ │ │ + return {}; │ │ │ │ + } │ │ │ │ + if (!block_hashes.empty()) │ │ │ │ + { │ │ │ │ + int const piece_size2 = m_files.piece_size2(piece); │ │ │ │ + int const blocks_in_piece2 = m_files.blocks_in_piece2(piece); │ │ │ │ + char const* buf = i->second.data(); │ │ │ │ + std::int64_t offset = 0; │ │ │ │ + for (int k = 0; k < blocks_in_piece2; ++k) │ │ │ │ + { │ │ │ │ + lt::hasher256 h2; │ │ │ │ + std::ptrdiff_t const len2 = std::min(lt::default_block_size, int │ │ │ │ +(piece_size2 - offset)); │ │ │ │ + h2.update({ buf, len2 }); │ │ │ │ + buf += len2; │ │ │ │ + offset += len2; │ │ │ │ + block_hashes[k] = h2.final(); │ │ │ │ + } │ │ │ │ + } │ │ │ │ + return lt::hasher(i->second).final(); │ │ │ │ + } │ │ │ │ + lt::sha256_hash hash2(lt::piece_index_t const piece, int const offset, lt:: │ │ │ │ +storage_error& ec) │ │ │ │ + { │ │ │ │ + auto const i = m_file_data.find(piece); │ │ │ │ + if (i == m_file_data.end()) │ │ │ │ + { │ │ │ │ + ec.operation = lt::operation_t::file_read; │ │ │ │ + ec.ec = boost::asio::error::eof; │ │ │ │ + return {}; │ │ │ │ + } │ │ │ │ + │ │ │ │ + int const piece_size = m_files.piece_size2(piece); │ │ │ │ + │ │ │ │ + std::ptrdiff_t const len = std::min(lt::default_block_size, piece_size - │ │ │ │ +offset); │ │ │ │ + │ │ │ │ + lt::span b = {i->second.data() + offset, len}; │ │ │ │ + return lt::hasher256(b).final(); │ │ │ │ + } │ │ │ │ + │ │ │ │ +private: │ │ │ │ + int piece_size(lt::piece_index_t piece) const │ │ │ │ + { │ │ │ │ + int const num_pieces = static_cast((m_files.total_size() + │ │ │ │ +m_files.piece_length() - 1) / m_files.piece_length()); │ │ │ │ + return static_cast(piece) < num_pieces - 1 │ │ │ │ + ? m_files.piece_length() : static_cast(m_files.total_size() - std:: │ │ │ │ +int64_t(num_pieces - 1) * m_files.piece_length()); │ │ │ │ + } │ │ │ │ + │ │ │ │ + lt::file_storage const& m_files; │ │ │ │ + std::map> m_file_data; │ │ │ │ +}; │ │ │ │ + │ │ │ │ +lt::storage_index_t pop(std::vector& q) │ │ │ │ +{ │ │ │ │ + TORRENT_ASSERT(!q.empty()); │ │ │ │ + lt::storage_index_t const ret = q.back(); │ │ │ │ + q.pop_back(); │ │ │ │ + return ret; │ │ │ │ +} │ │ │ │ + │ │ │ │ +struct temp_disk_io final : lt::disk_interface │ │ │ │ + , lt::buffer_allocator_interface │ │ │ │ +{ │ │ │ │ + explicit temp_disk_io(lt::io_context& ioc): m_ioc(ioc) {} │ │ │ │ + │ │ │ │ + void settings_updated() override {} │ │ │ │ + │ │ │ │ + lt::storage_holder new_torrent(lt::storage_params const& params │ │ │ │ + , std::shared_ptr const&) override │ │ │ │ + { │ │ │ │ + lt::storage_index_t const idx = m_free_slots.empty() │ │ │ │ + ? m_torrents.end_index() │ │ │ │ + : pop(m_free_slots); │ │ │ │ + auto storage = std::make_unique(params.files); │ │ │ │ + if (idx == m_torrents.end_index()) m_torrents.emplace_back(std::move │ │ │ │ +(storage)); │ │ │ │ + else m_torrents[idx] = std::move(storage); │ │ │ │ + return lt::storage_holder(idx, *this); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void remove_torrent(lt::storage_index_t const idx) override │ │ │ │ + { │ │ │ │ + m_torrents[idx].reset(); │ │ │ │ + m_free_slots.push_back(idx); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void abort(bool) override {} │ │ │ │ + │ │ │ │ + void async_read(lt::storage_index_t storage, lt::peer_request const& r │ │ │ │ + , std::function handler │ │ │ │ + , lt::disk_job_flags_t) override │ │ │ │ + { │ │ │ │ + // this buffer is owned by the storage. It will remain valid for as │ │ │ │ + // long as the torrent remains in the session. We don't need any lifetime │ │ │ │ + // management of it. │ │ │ │ + lt::storage_error error; │ │ │ │ + lt::span b = m_torrents[storage]->readv(r, error); │ │ │ │ + │ │ │ │ + post(m_ioc, [handler, error, b, this] { │ │ │ │ + handler(lt::disk_buffer_holder(*this, const_cast(b.data())), │ │ │ │ +error); │ │ │ │ + }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + bool async_write(lt::storage_index_t storage, lt::peer_request const& r │ │ │ │ + , char const* buf, std::shared_ptr │ │ │ │ + , std::function handler │ │ │ │ + , lt::disk_job_flags_t) override │ │ │ │ + { │ │ │ │ + lt::span const b = { buf, r.length }; │ │ │ │ + │ │ │ │ + m_torrents[storage]->writev(b, r.piece, r.start); │ │ │ │ + │ │ │ │ + post(m_ioc, [=]{ handler(lt::storage_error()); }); │ │ │ │ + return false; │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_hash(lt::storage_index_t storage, lt::piece_index_t const piece │ │ │ │ + , lt::span block_hashes, lt::disk_job_flags_t │ │ │ │ + , std::function handler) override │ │ │ │ + { │ │ │ │ + lt::storage_error error; │ │ │ │ + lt::sha1_hash const hash = m_torrents[storage]->hash(piece, block_hashes, │ │ │ │ +error); │ │ │ │ + post(m_ioc, [=]{ handler(piece, hash, error); }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_hash2(lt::storage_index_t storage, lt::piece_index_t const piece │ │ │ │ + , int const offset, lt::disk_job_flags_t │ │ │ │ + , std::function handler) override │ │ │ │ + { │ │ │ │ + lt::storage_error error; │ │ │ │ + lt::sha256_hash const hash = m_torrents[storage]->hash2(piece, offset, │ │ │ │ +error); │ │ │ │ + post(m_ioc, [=]{ handler(piece, hash, error); }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_move_storage(lt::storage_index_t, std::string p, lt::move_flags_t │ │ │ │ + , std::function handler) override │ │ │ │ + { │ │ │ │ + post(m_ioc, [=]{ │ │ │ │ + handler(lt::disk_status::fatal_disk_error, p │ │ │ │ + , lt::storage_error(lt::error_code(boost::system::errc:: │ │ │ │ +operation_not_supported, lt::system_category()))); │ │ │ │ + }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_release_files(lt::storage_index_t, std::function) override │ │ │ │ +{} │ │ │ │ + │ │ │ │ + void async_delete_files(lt::storage_index_t, lt::remove_flags_t │ │ │ │ + , std::function handler) override │ │ │ │ + { │ │ │ │ + post(m_ioc, [=]{ handler(lt::storage_error()); }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_check_files(lt::storage_index_t │ │ │ │ + , lt::add_torrent_params const* │ │ │ │ + , lt::aux::vector │ │ │ │ + , std::function handler) │ │ │ │ +override │ │ │ │ + { │ │ │ │ + post(m_ioc, [=]{ handler(lt::status_t{}, lt::storage_error()); }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_rename_file(lt::storage_index_t │ │ │ │ + , lt::file_index_t const idx │ │ │ │ + , std::string const name │ │ │ │ + , std::function handler) override │ │ │ │ + { │ │ │ │ + post(m_ioc, [=]{ handler(name, idx, lt::storage_error()); }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_stop_torrent(lt::storage_index_t, std::function handler) │ │ │ │ +override │ │ │ │ + { │ │ │ │ + post(m_ioc, handler); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_set_file_priority(lt::storage_index_t │ │ │ │ + , lt::aux::vector prio │ │ │ │ + , std::function)> handler) │ │ │ │ +override │ │ │ │ + { │ │ │ │ + post(m_ioc, [=]{ │ │ │ │ + handler(lt::storage_error(lt::error_code( │ │ │ │ + boost::system::errc::operation_not_supported, lt::system_category())), │ │ │ │ +std::move(prio)); │ │ │ │ + }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + void async_clear_piece(lt::storage_index_t, lt::piece_index_t index │ │ │ │ + , std::function handler) override │ │ │ │ + { │ │ │ │ + post(m_ioc, [=]{ handler(index); }); │ │ │ │ + } │ │ │ │ + │ │ │ │ + // implements buffer_allocator_interface │ │ │ │ + void free_disk_buffer(char*) override │ │ │ │ + { │ │ │ │ + // never free any buffer. We only return buffers owned by the storage │ │ │ │ + // object │ │ │ │ + } │ │ │ │ + void free_multiple_buffers(lt::span) override │ │ │ │ + { │ │ │ │ + // never free any buffer. We only return buffers owned by the storage │ │ │ │ + // object │ │ │ │ + } │ │ │ │ +#if TORRENT_DEBUG_BUFFER_POOL │ │ │ │ + void rename_buffer(char*, char const*) override {} │ │ │ │ +#endif │ │ │ │ + │ │ │ │ + void update_stats_counters(lt::counters&) const override {} │ │ │ │ + │ │ │ │ + std::vector get_status(lt::storage_index_t) const │ │ │ │ +override │ │ │ │ + { return {}; } │ │ │ │ + │ │ │ │ + void submit_jobs() override {} │ │ │ │ + │ │ │ │ +private: │ │ │ │ + │ │ │ │ + lt::aux::vector, lt::storage_index_t> │ │ │ │ +m_torrents; │ │ │ │ + │ │ │ │ + // slots that are unused in the m_torrents vector │ │ │ │ + std::vector m_free_slots; │ │ │ │ + │ │ │ │ + // callbacks are posted on this │ │ │ │ + lt::io_context& m_ioc; │ │ │ │ +}; │ │ │ │ + │ │ │ │ +std::unique_ptr temp_disk_constructor( │ │ │ │ + lt::io_context& ioc, lt::settings_interface const&, lt::counters&) │ │ │ │ +{ │ │ │ │ + return std::make_unique(ioc); │ │ │ │ +} │ │ │ │ +[_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 void sseett__bbooooll (int name, bool val) = 0; │ │ │ │ + virtual bool hhaass__vvaall (int name) const = 0; │ │ │ │ + virtual std::string const& ggeett__ssttrr (int name) const = 0; │ │ │ │ + virtual int ggeett__iinntt (int name) const = 0; │ │ │ │ + virtual bool ggeett__bbooooll (int name) const = 0; │ │ │ │ +}; │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** sseett__iinntt(()) sseett__bbooooll(()) sseett__ssttrr(()) ********** │ │ │ │ +virtual void sseett__ssttrr (int name, std::string val) = 0; │ │ │ │ +virtual void sseett__iinntt (int name, int val) = 0; │ │ │ │ +virtual void sseett__bbooooll (int name, bool val) = 0; │ │ │ │ +store the value of a single setting. name is one of the enum values from │ │ │ │ +settings_pack::string_types, int_types or bool_types. The setter must match the │ │ │ │ +type of the setting: set_str() only accepts names from string_types, set_int() │ │ │ │ +from int_types and set_bool() from bool_types. Passing a name of the wrong type │ │ │ │ +asserts in debug builds and is ignored otherwise. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** hhaass__vvaall(()) ********** │ │ │ │ +virtual bool hhaass__vvaall (int name) const = 0; │ │ │ │ +returns true if a value has been explicitly set for the setting name. If false, │ │ │ │ +reads of that setting return the default value. │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ +********** ggeett__bbooooll(()) ggeett__iinntt(()) ggeett__ssttrr(()) ********** │ │ │ │ +virtual std::string const& ggeett__ssttrr (int name) const = 0; │ │ │ │ +virtual int ggeett__iinntt (int name) const = 0; │ │ │ │ +virtual bool ggeett__bbooooll (int name) const = 0; │ │ │ │ +retrieve the current value of a single setting. name is one of the enum values │ │ │ │ +from settings_pack::string_types, int_types or bool_types. The getter must │ │ │ │ +match the type of the setting; if no value has been set, the default value of │ │ │ │ +the setting is returned. │ │ │ │ [_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 │ │ │ │ { │ │ │ │ @@ -103,21 +431,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 │ │ │ │ @@ -172,22 +500,22 @@ │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** 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; │ │ │ │ +********** aassyynncc__wwrriittee(()) aassyynncc__rreeaadd(()) ********** │ │ │ │ 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 │ │ │ │ @@ -444,16 +772,16 @@ │ │ │ │ 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& ooppeerraattoorr== (disk_buffer_holder&&) & noexcept; │ │ │ │ ddiisskk__bbuuffffeerr__hhoollddeerr (disk_buffer_holder&&) noexcept; │ │ │ │ - ddiisskk__bbuuffffeerr__hhoollddeerr (disk_buffer_holder const&) = delete; │ │ │ │ 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) noexcept; │ │ │ │ ddiisskk__bbuuffffeerr__hhoollddeerr () noexcept = default; │ │ │ │ ~~ddiisskk__bbuuffffeerr__hhoollddeerr (); │ │ │ │ char* ddaattaa () const noexcept; │ │ │ │ void rreesseett (); │ │ │ │ void sswwaapp (disk_buffer_holder& h) noexcept; │ │ │ │ bool iiss__mmuuttaabbllee () const noexcept; │ │ │ │ @@ -501,97 +829,58 @@ │ │ │ │ pointer is null. The buffer must be transferred to a _b_u_l_k___f_r_e_e___b_u_f_f_e_r before │ │ │ │ this goes out of scope. Since it has no allocator, it cannot free the buffer │ │ │ │ itself. │ │ │ │ struct disk_buffer_ref │ │ │ │ { │ │ │ │ ddiisskk__bbuuffffeerr__rreeff () noexcept = default; │ │ │ │ explicit ddiisskk__bbuuffffeerr__rreeff (disk_buffer_holder&& h) noexcept; │ │ │ │ - ~~ddiisskk__bbuuffffeerr__rreeff (); │ │ │ │ - ddiisskk__bbuuffffeerr__rreeff (disk_buffer_ref const&) = delete; │ │ │ │ - disk_buffer_ref& ooppeerraattoorr== (disk_buffer_ref const&) = delete; │ │ │ │ ddiisskk__bbuuffffeerr__rreeff (disk_buffer_ref&&) noexcept; │ │ │ │ disk_buffer_ref& ooppeerraattoorr== (disk_buffer_ref&&) noexcept; │ │ │ │ - char* ddaattaa () const noexcept; │ │ │ │ + ddiisskk__bbuuffffeerr__rreeff (disk_buffer_ref const&) = delete; │ │ │ │ + ~~ddiisskk__bbuuffffeerr__rreeff (); │ │ │ │ + disk_buffer_ref& ooppeerraattoorr== (disk_buffer_ref const&) = delete; │ │ │ │ explicit operator bbooooll () const noexcept; │ │ │ │ + char* ddaattaa () const noexcept; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** ddiisskk__bbuuffffeerr__rreeff(()) ********** │ │ │ │ explicit ddiisskk__bbuuffffeerr__rreeff (disk_buffer_holder&& h) noexcept; │ │ │ │ take ownership of the buffer held by h, leaving h empty. The buffer must │ │ │ │ subsequently be transferred to a bulk_free_buffer for release; this type cannot │ │ │ │ free the buffer itself. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ddaattaa(()) bbooooll(()) ********** │ │ │ │ -char* ddaattaa () const noexcept; │ │ │ │ +********** bbooooll(()) ddaattaa(()) ********** │ │ │ │ explicit operator bbooooll () const noexcept; │ │ │ │ +char* ddaattaa () const noexcept; │ │ │ │ returns a pointer to the held buffer, or nullptr if this reference is empty. │ │ │ │ operator bool() returns true iff a buffer is held. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ bbuullkk__ffrreeee__bbuuffffeerr ************ │ │ │ │ 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" │ │ │ │ Accumulates disk buffers to be freed in a single batch call, reducing allocator │ │ │ │ mutex acquisitions from one per buffer to one per batch. All buffers added must │ │ │ │ share the same allocator. Freeing happens in the destructor. │ │ │ │ struct bulk_free_buffer │ │ │ │ { │ │ │ │ explicit bbuullkk__ffrreeee__bbuuffffeerr (buffer_allocator_interface& alloc); │ │ │ │ - ~~bbuullkk__ffrreeee__bbuuffffeerr (); │ │ │ │ void aadddd (disk_buffer_ref r); │ │ │ │ + ~~bbuullkk__ffrreeee__bbuuffffeerr (); │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** bbuullkk__ffrreeee__bbuuffffeerr(()) ********** │ │ │ │ explicit bbuullkk__ffrreeee__bbuuffffeerr (buffer_allocator_interface& alloc); │ │ │ │ construct an empty batch tied to the given allocator. All buffers added via add │ │ │ │ () must have come from this same allocator. The batch is freed in the │ │ │ │ destructor. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ~~bbuullkk__ffrreeee__bbuuffffeerr(()) aadddd(()) ********** │ │ │ │ -~~bbuullkk__ffrreeee__bbuuffffeerr (); │ │ │ │ +********** aadddd(()) ~~bbuullkk__ffrreeee__bbuuffffeerr(()) ********** │ │ │ │ void aadddd (disk_buffer_ref r); │ │ │ │ +~~bbuullkk__ffrreeee__bbuuffffeerr (); │ │ │ │ transfer ownership of h's buffer into this batch. │ │ │ │ [_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__bbooooll (int name, bool val) = 0; │ │ │ │ - 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 bool ggeett__bbooooll (int name) const = 0; │ │ │ │ - virtual int ggeett__iinntt (int name) const = 0; │ │ │ │ - virtual std::string const& ggeett__ssttrr (int name) const = 0; │ │ │ │ -}; │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** sseett__iinntt(()) sseett__ssttrr(()) sseett__bbooooll(()) ********** │ │ │ │ -virtual void sseett__bbooooll (int name, bool val) = 0; │ │ │ │ -virtual void sseett__ssttrr (int name, std::string val) = 0; │ │ │ │ -virtual void sseett__iinntt (int name, int val) = 0; │ │ │ │ -store the value of a single setting. name is one of the enum values from │ │ │ │ -settings_pack::string_types, int_types or bool_types. The setter must match the │ │ │ │ -type of the setting: set_str() only accepts names from string_types, set_int() │ │ │ │ -from int_types and set_bool() from bool_types. Passing a name of the wrong type │ │ │ │ -asserts in debug builds and is ignored otherwise. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** hhaass__vvaall(()) ********** │ │ │ │ -virtual bool hhaass__vvaall (int name) const = 0; │ │ │ │ -returns true if a value has been explicitly set for the setting name. If false, │ │ │ │ -reads of that setting return the default value. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__iinntt(()) ggeett__bbooooll(()) ggeett__ssttrr(()) ********** │ │ │ │ -virtual bool ggeett__bbooooll (int name) const = 0; │ │ │ │ -virtual int ggeett__iinntt (int name) const = 0; │ │ │ │ -virtual std::string const& ggeett__ssttrr (int name) const = 0; │ │ │ │ -retrieve the current value of a single setting. name is one of the enum values │ │ │ │ -from settings_pack::string_types, int_types or bool_types. The getter must │ │ │ │ -match the type of the setting; if no value has been set, the default value of │ │ │ │ -the setting is returned. │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ************ ssttaattuuss__tt ************ │ │ │ │ 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" │ │ │ │ fatal_disk_error │ │ │ │ the disk operation could not be completed because of an unrecoverable │ │ │ │ error (e.g. failed write). The torrent is paused and a file_error_alert │ │ │ │ is posted. │ │ │ │ need_full_check │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-DHT.html │ │ │ @@ -50,16 +50,16 @@ │ │ │
  • get_mutable_item()
  • │ │ │
  • put_mutable_item()
  • │ │ │
  • get_infohashes_sample()
  • │ │ │
  • tick()
  • │ │ │
  • counters()
  • │ │ │ │ │ │ │ │ │ -
  • sign_mutable_item()
  • │ │ │ -
  • dht_default_storage_constructor()
  • │ │ │ +
  • dht_default_storage_constructor()
  • │ │ │ +
  • sign_mutable_item()
  • │ │ │
  • announce_flags_t
  • │ │ │ │ │ │
    │ │ │ [report issue]
    │ │ │

    dht_state

    │ │ │

    Declared in "libtorrent/kademlia/dht_state.hpp"

    │ │ │

    This structure helps to store and load the state │ │ │ @@ -341,16 +341,27 @@ │ │ │ [report issue]

    │ │ │
    │ │ │

    counters()

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

    return stats counters for the store

    │ │ │ -[report issue]
    │ │ │ +[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]
    │ │ │
    │ │ │

    sign_mutable_item()

    │ │ │

    Declared in "libtorrent/kademlia/item.hpp"

    │ │ │
    │ │ │  signature sign_mutable_item (
    │ │ │     span<char const> v
    │ │ │     , span<char const> salt
    │ │ │ @@ -360,25 +371,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 {} │ │ │ │ @@ -15,16 +15,16 @@ │ │ │ │ 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_(_) │ │ │ │ - * _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 │ │ │ │ @@ -233,36 +233,36 @@ │ │ │ │ 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__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 │ │ │ │ , public_key const& pk │ │ │ │ , 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;
    │ │ │ -   file_index_t file () const;
    │ │ │     void file (file_index_t f);
    │ │ │ +   file_index_t file () const;
    │ │ │  
    │ │ │     error_code ec;
    │ │ │     operation_t operation;
    │ │ │  };
    │ │ │  
    │ │ │ [report issue]
    │ │ │

    bool()

    │ │ │ @@ -79,102 +79,511 @@ │ │ │ │ │ │

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

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

    file()

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

    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]
    │ │ │ │ │ │ -
    │ │ │ -

    libtorrent_category()

    │ │ │ -

    Declared in "libtorrent/error_code.hpp"

    │ │ │ -
    │ │ │ -boost::system::error_category& libtorrent_category ();
    │ │ │ -
    │ │ │ -

    return the instance of the libtorrent_error_category which │ │ │ -maps libtorrent error codes to human readable error messages.

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

    http_category()

    │ │ │ -

    Declared in "libtorrent/error_code.hpp"

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

    returns the error_category for HTTP errors

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

    gzip_category()

    │ │ │ -

    Declared in "libtorrent/gzip.hpp"

    │ │ │ +
    │ │ │ +

    pcp_category()

    │ │ │ +

    Declared in "libtorrent/natpmp.hpp"

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

    get the error_category for zip errors

    │ │ │ +

    returns the boost::system::error_category used for │ │ │ +errors::pcp_errors. error_code objects returned by the PCP │ │ │ +(Port Control Protocol) port-mapping code use this category.

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

    upnp_category()

    │ │ │

    Declared in "libtorrent/upnp.hpp"

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

    the boost.system error category for UPnP 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]
    │ │ │
    │ │ │

    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 ();
    │ │ │  
    │ │ │ -

    returns the boost::system::error_category used for │ │ │ -errors::pcp_errors. error_code objects returned by the PCP │ │ │ -(Port Control Protocol) port-mapping code use this 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]
    │ │ │
    │ │ │

    bdecode_category()

    │ │ │

    Declared in "libtorrent/bdecode.hpp"

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

    returns the boost::system::error_category used for the │ │ │ bdecode_errors::error_code_enum errors. error_code objects │ │ │ produced by bdecode() use this category.

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

    libtorrent_category()

    │ │ │ +

    Declared in "libtorrent/error_code.hpp"

    │ │ │ +
    │ │ │ +boost::system::error_category& libtorrent_category ();
    │ │ │ +
    │ │ │ +

    return the instance of the libtorrent_error_category which │ │ │ +maps libtorrent error codes to human readable error messages.

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

    http_category()

    │ │ │ +

    Declared in "libtorrent/error_code.hpp"

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

    returns the error_category for HTTP errors

    │ │ │ +[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"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    no_error0No error
    invalid_argument402One of the arguments in the request is invalid
    action_failed501The request failed
    value_not_in_array714The specified value does not exist in the array
    source_ip_cannot_be_wildcarded715The source IP address cannot be wild-carded, but │ │ │ +must be fully specified
    external_port_cannot_be_wildcarded716The external port cannot be a wildcard, but must │ │ │ +be specified
    port_mapping_conflict718The port mapping entry specified conflicts with a │ │ │ +mapping assigned previously to another client
    internal_port_must_match_external724Internal and external port value must be the same
    only_permanent_leases_supported725The NAT implementation only supports permanent │ │ │ +lease times on port mappings
    remote_host_must_be_wildcard726RemoteHost must be a wildcard and cannot be a │ │ │ +specific IP address or DNS name
    external_port_must_be_wildcard727ExternalPort must be a wildcard and cannot be a │ │ │ +specific port
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum socks_error_code

    │ │ │ +

    Declared in "libtorrent/socks5_stream.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    no_error0 
    unsupported_version1 
    unsupported_authentication_method2 
    unsupported_authentication_version3 
    authentication_error4 
    username_required5 
    general_failure6 
    command_not_supported7 
    no_identd8 
    identd_error9 
    num_errors10 
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum error_code_enum

    │ │ │ +

    Declared in "libtorrent/gzip.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    no_error0Not an error
    invalid_gzip_header1the supplied gzip buffer has invalid header
    inflated_data_too_large2the gzip buffer would inflate to more bytes than the specified │ │ │ +maximum size, and was rejected.
    data_did_not_terminate3available inflate data did not terminate
    space_exhausted4output space exhausted before completing inflate
    invalid_block_type5invalid block type (type == 3)
    invalid_stored_block_length6stored block length did not match one's complement
    too_many_length_or_distance_codes7dynamic 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 inflation
    error_code_max16the number of error codes
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum i2p_error_code

    │ │ │ +

    Declared in "libtorrent/i2p_stream.hpp"

    │ │ │ + │ │ │ +│ │ │ +│ │ │ +│ │ │ +│ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ + │ │ │ +
    namevaluedescription
    no_error0 
    parse_failed1 
    cant_reach_peer2 
    i2p_error3 
    invalid_key4 
    invalid_id5 
    timeout6 
    key_not_found7 
    duplicated_id8 
    num_errors9 
    │ │ │ +[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
    │ │ │ +[report issue]
    │ │ │ +
    │ │ │ +

    enum error_code_enum

    │ │ │

    Declared in "libtorrent/error_code.hpp"

    │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -1012,423 +1421,14 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
    service_unavailable503 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum error_code_enum

    │ │ │ -

    Declared in "libtorrent/gzip.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    no_error0Not an error
    invalid_gzip_header1the supplied gzip buffer has invalid header
    inflated_data_too_large2the gzip buffer would inflate to more bytes than the specified │ │ │ -maximum size, and was rejected.
    data_did_not_terminate3available inflate data did not terminate
    space_exhausted4output space exhausted before completing inflate
    invalid_block_type5invalid block type (type == 3)
    invalid_stored_block_length6stored block length did not match one's complement
    too_many_length_or_distance_codes7dynamic 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 inflation
    error_code_max16the number of error codes
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum error_code_enum

    │ │ │ -

    Declared in "libtorrent/upnp.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    no_error0No error
    invalid_argument402One of the arguments in the request is invalid
    action_failed501The request failed
    value_not_in_array714The specified value does not exist in the array
    source_ip_cannot_be_wildcarded715The source IP address cannot be wild-carded, but │ │ │ -must be fully specified
    external_port_cannot_be_wildcarded716The external port cannot be a wildcard, but must │ │ │ -be specified
    port_mapping_conflict718The port mapping entry specified conflicts with a │ │ │ -mapping assigned previously to another client
    internal_port_must_match_external724Internal and external port value must be the same
    only_permanent_leases_supported725The NAT implementation only supports permanent │ │ │ -lease times on port mappings
    remote_host_must_be_wildcard726RemoteHost must be a wildcard and cannot be a │ │ │ -specific IP address or DNS name
    external_port_must_be_wildcard727ExternalPort must be a wildcard and cannot be a │ │ │ -specific port
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum i2p_error_code

    │ │ │ -

    Declared in "libtorrent/i2p_stream.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    no_error0 
    parse_failed1 
    cant_reach_peer2 
    i2p_error3 
    invalid_key4 
    invalid_id5 
    timeout6 
    key_not_found7 
    duplicated_id8 
    num_errors9 
    │ │ │ -[report issue]
    │ │ │ -
    │ │ │ -

    enum socks_error_code

    │ │ │ -

    Declared in "libtorrent/socks5_stream.hpp"

    │ │ │ - │ │ │ -│ │ │ -│ │ │ -│ │ │ -│ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ - │ │ │ -
    namevaluedescription
    no_error0 
    unsupported_version1 
    unsupported_authentication_method2 
    unsupported_authentication_version3 
    authentication_error4 
    username_required5 
    general_failure6 
    command_not_supported7 
    no_identd8 
    identd_error9 
    num_errors10 
    │ │ │ -[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/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
    │ │ │
    │ │ │ │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ │ │ │ -
    │ │ │ -

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

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

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

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

    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]
    │ │ │ @@ -657,70 +990,70 @@ │ │ │ │ │ │

    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]
    │ │ │ -
    │ │ │ -

    on_reject() on_cancel() on_suggest()

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

    on_cancel() on_reject() on_suggest()

    │ │ │
    │ │ │ -virtual bool on_suggest (piece_index_t);
    │ │ │  virtual bool on_reject (peer_request const&);
    │ │ │ +virtual bool on_suggest (piece_index_t);
    │ │ │  virtual bool on_cancel (peer_request const&);
    │ │ │  
    │ │ │

    called when a CANCEL, REJECT or SUGGEST message is received from the │ │ │ peer. If the extension returns true, the message is not │ │ │ forwarded to the bittorrent engine. It's expected to have been │ │ │ handled by the extension.

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

    sent_request() sent_suggest() sent_have_all() sent_piece() sent_choke() sent_have_none() sent_not_interested() sent_allow_fast() sent_reject_request() sent_interested() sent_unchoke() sent_cancel() sent_have()

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

    sent_request() sent_interested() sent_have_none() sent_cancel() sent_not_interested() sent_have() sent_suggest() sent_allow_fast() sent_have_all() sent_piece() sent_reject_request() sent_unchoke() sent_choke()

    │ │ │
    │ │ │ -virtual void sent_have_none ();
    │ │ │ -virtual void sent_choke ();
    │ │ │ -virtual void sent_have (piece_index_t);
    │ │ │ -virtual void sent_interested ();
    │ │ │ -virtual void sent_request (peer_request const&);
    │ │ │  virtual void sent_allow_fast (piece_index_t);
    │ │ │ -virtual void sent_not_interested ();
    │ │ │  virtual void sent_piece (peer_request const&);
    │ │ │ -virtual void sent_reject_request (peer_request const&);
    │ │ │ -virtual void sent_unchoke ();
    │ │ │ -virtual void sent_suggest (piece_index_t);
    │ │ │  virtual void sent_have_all ();
    │ │ │ +virtual void sent_choke ();
    │ │ │ +virtual void sent_not_interested ();
    │ │ │ +virtual void sent_suggest (piece_index_t);
    │ │ │ +virtual void sent_request (peer_request const&);
    │ │ │ +virtual void sent_unchoke ();
    │ │ │  virtual void sent_cancel (peer_request const&);
    │ │ │ +virtual void sent_have_none ();
    │ │ │ +virtual void sent_reject_request (peer_request const&);
    │ │ │ +virtual void sent_interested ();
    │ │ │ +virtual void sent_have (piece_index_t);
    │ │ │  
    │ │ │

    called after the corresponding message has been sent │ │ │ to the peer.

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

    sent_payload()

    │ │ │
    │ │ │  virtual void sent_payload (int /* bytes */);
    │ │ │  
    │ │ │

    called after piece data has been sent to the peer │ │ │ this can be used for stats book keeping

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

    can_disconnect()

    │ │ │
    │ │ │  virtual bool can_disconnect (error_code const& /*ec*/);
    │ │ │  
    │ │ │

    called when libtorrent think this peer should be disconnected. │ │ │ if the plugin returns false, the peer will not be disconnected.

    │ │ │ [report issue]
    │ │ │ @@ -789,17 +1122,17 @@ │ │ │ { │ │ │ virtual void set_incoming_key (span<char const> key) = 0; │ │ │ virtual void set_outgoing_key (span<char const> key) = 0; │ │ │ encrypt (span<span<char>> /*send_vec*/) = 0; │ │ │ virtual std::tuple<int, int, int> decrypt (span<span<char>> /*receive_vec*/) = 0; │ │ │ }; │ │ │ │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    set_incoming_key() set_outgoing_key()

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

    set_outgoing_key() set_incoming_key()

    │ │ │
    │ │ │  virtual void set_incoming_key (span<char const> key) = 0;
    │ │ │  virtual void set_outgoing_key (span<char const> key) = 0;
    │ │ │  
    │ │ │

    configure the symmetric stream keys used by this plugin. │ │ │ set_incoming_key() provides the key for decrypting bytes │ │ │ received from the peer; set_outgoing_key() the key for │ │ │ @@ -832,347 +1165,14 @@ │ │ │ (consume, produce, packet_size)

    │ │ │

    consume is set to the number of bytes which should be trimmed from the │ │ │ head of the buffers, default is 0

    │ │ │

    produce is set to the number of bytes of payload which are now ready to │ │ │ be sent to the upper layer. default is the number of bytes passed in receive_vec

    │ │ │

    packet_size is set to the minimum number of bytes which must be read to │ │ │ advance the next step of decryption. default is 0

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

    peer_connection_handle

    │ │ │ -

    Declared in "libtorrent/peer_connection_handle.hpp"

    │ │ │ -

    the peer_connection_handle class provides a handle to the internal peer │ │ │ -connection object, to be used by plugins. This is a low level interface that │ │ │ -may not be stable across libtorrent versions

    │ │ │ -
    │ │ │ -struct peer_connection_handle
    │ │ │ -{
    │ │ │ -   explicit peer_connection_handle (std::weak_ptr<aux::peer_connection> impl);
    │ │ │ -   connection_type type () const;
    │ │ │ -   peer_plugin const* find_plugin (string_view type) const;
    │ │ │ -   void add_extension (std::shared_ptr<peer_plugin>);
    │ │ │ -   bool is_seed () const;
    │ │ │ -   bool upload_only () const;
    │ │ │ -   peer_id const& pid () const;
    │ │ │ -   bool has_piece (piece_index_t i) const;
    │ │ │ -   bool is_choked () const;
    │ │ │ -   bool is_interesting () const;
    │ │ │ -   bool is_peer_interested () const;
    │ │ │ -   bool has_peer_choked () const;
    │ │ │ -   void choke_this_peer ();
    │ │ │ -   void maybe_unchoke_this_peer ();
    │ │ │ -   void get_peer_info (peer_info& p) const;
    │ │ │ -   torrent_handle associated_torrent () const;
    │ │ │ -   tcp::endpoint const& remote () const;
    │ │ │ -   tcp::endpoint local_endpoint () const;
    │ │ │ -   bool is_disconnecting () const;
    │ │ │ -   void disconnect (error_code const& ec, operation_t op
    │ │ │ -      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ -   bool is_connecting () const;
    │ │ │ -   bool is_outgoing () const;
    │ │ │ -   bool on_local_network () const;
    │ │ │ -   bool ignore_unchoke_slots () const;
    │ │ │ -   bool failed () const;
    │ │ │ -   void peer_log (peer_log_alert::direction_t direction
    │ │ │ -      , peer_log_alert::event_t event, char const* fmt = "", ...) const TORRENT_FORMAT(4,5);
    │ │ │ -   bool should_log (peer_log_alert::direction_t direction) const;
    │ │ │ -   bool can_disconnect (error_code const& ec) const;
    │ │ │ -   bool has_metadata () const;
    │ │ │ -   bool in_handshake () const;
    │ │ │ -   void send_buffer (char const* begin, int size);
    │ │ │ -   time_point time_of_last_unchoke () const;
    │ │ │ -   std::time_t last_seen_complete () const;
    │ │ │ -   bool operator< (peer_connection_handle const& o) const;
    │ │ │ -   bool operator== (peer_connection_handle const& o) const;
    │ │ │ -   bool operator!= (peer_connection_handle const& o) const;
    │ │ │ -   std::shared_ptr<aux::peer_connection> native_handle () const;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    peer_connection_handle()

    │ │ │ -
    │ │ │ -explicit peer_connection_handle (std::weak_ptr<aux::peer_connection> impl);
    │ │ │ -
    │ │ │ -

    construct a handle wrapping the given internal peer_connection. │ │ │ -Typically created by libtorrent and passed to plugins; not │ │ │ -intended to be constructed by user code.

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

    type()

    │ │ │ -
    │ │ │ -connection_type type () const;
    │ │ │ -
    │ │ │ -

    the protocol type of this connection (bittorrent, url_seed, │ │ │ -http_seed)

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

    add_extension() find_plugin()

    │ │ │ -
    │ │ │ -peer_plugin const* find_plugin (string_view type) const;
    │ │ │ -void add_extension (std::shared_ptr<peer_plugin>);
    │ │ │ -
    │ │ │ -

    attach a peer_plugin to this connection. find_plugin() looks │ │ │ -up an attached plugin by its type() string and returns nullptr │ │ │ -if none is registered.

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

    is_seed()

    │ │ │ -
    │ │ │ -bool is_seed () const;
    │ │ │ -
    │ │ │ -

    returns true if the remote peer is a seed

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

    upload_only()

    │ │ │ -
    │ │ │ -bool upload_only () const;
    │ │ │ -
    │ │ │ -

    returns true if the remote peer has indicated upload-only (it │ │ │ -is a seed or has chosen not to download anything more from us)

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

    pid() has_piece()

    │ │ │ -
    │ │ │ -peer_id const& pid () const;
    │ │ │ -bool has_piece (piece_index_t i) const;
    │ │ │ -
    │ │ │ -

    the peer id reported by the remote during handshake. │ │ │ -has_piece(i) returns true if the remote peer has piece i.

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

    is_interesting() is_choked()

    │ │ │ -
    │ │ │ -bool is_choked () const;
    │ │ │ -bool is_interesting () const;
    │ │ │ -
    │ │ │ -

    is_interesting() returns true if we are interested in the peer │ │ │ -(it has pieces we want). is_choked() returns true if we have │ │ │ -choked the peer (we are not currently sending data to it).

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

    is_peer_interested() has_peer_choked()

    │ │ │ -
    │ │ │ -bool is_peer_interested () const;
    │ │ │ -bool has_peer_choked () const;
    │ │ │ -
    │ │ │ -

    is_peer_interested() returns true if the peer has indicated it │ │ │ -is interested in us. has_peer_choked() returns true if the peer │ │ │ -is choking us.

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

    maybe_unchoke_this_peer() choke_this_peer()

    │ │ │ -
    │ │ │ -void choke_this_peer ();
    │ │ │ -void maybe_unchoke_this_peer ();
    │ │ │ -
    │ │ │ -

    choke or possibly unchoke this peer immediately, bypassing the │ │ │ -regular unchoke selection. maybe_unchoke_this_peer() only │ │ │ -unchokes if there is an unchoke slot available.

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

    get_peer_info()

    │ │ │ -
    │ │ │ -void get_peer_info (peer_info& p) const;
    │ │ │ -
    │ │ │ -

    fills in p with statistics and state for this connection, │ │ │ -equivalent to the corresponding entry returned by │ │ │ -torrent_handle::get_peer_info().

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

    associated_torrent()

    │ │ │ -
    │ │ │ -torrent_handle associated_torrent () const;
    │ │ │ -
    │ │ │ -

    the torrent this peer is associated with. Returns an invalid │ │ │ -handle if the peer is not yet associated with a torrent.

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

    local_endpoint() remote()

    │ │ │ -
    │ │ │ -tcp::endpoint const& remote () const;
    │ │ │ -tcp::endpoint local_endpoint () const;
    │ │ │ -
    │ │ │ -

    the remote peer's address and port, and the local endpoint of │ │ │ -the socket on our side.

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

    is_outgoing() is_connecting() disconnect() is_disconnecting()

    │ │ │ -
    │ │ │ -bool is_disconnecting () const;
    │ │ │ -void disconnect (error_code const& ec, operation_t op
    │ │ │ -      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ -bool is_connecting () const;
    │ │ │ -bool is_outgoing () const;
    │ │ │ -
    │ │ │ -

    drop the connection with the given error code and operation │ │ │ -type. The disconnect is asynchronous; is_disconnecting() │ │ │ -becomes true immediately and the actual socket close happens │ │ │ -later. is_connecting() reports whether the outgoing socket │ │ │ -is still in the connect phase; is_outgoing() whether the │ │ │ -connection was initiated by us.

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

    on_local_network() ignore_unchoke_slots()

    │ │ │ -
    │ │ │ -bool on_local_network () const;
    │ │ │ -bool ignore_unchoke_slots () const;
    │ │ │ -
    │ │ │ -

    returns true if the peer's address is on the same local network │ │ │ -as us. ignore_unchoke_slots() returns true if this peer is │ │ │ -excluded from regular unchoke slot accounting.

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

    failed()

    │ │ │ -
    │ │ │ -bool failed () const;
    │ │ │ -
    │ │ │ -

    returns true if the connection has been closed because of an │ │ │ -error (rather than because of a normal disconnect)

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

    should_log() peer_log()

    │ │ │ -
    │ │ │ -void peer_log (peer_log_alert::direction_t direction
    │ │ │ -      , peer_log_alert::event_t event, char const* fmt = "", ...) const TORRENT_FORMAT(4,5);
    │ │ │ -bool should_log (peer_log_alert::direction_t direction) const;
    │ │ │ -
    │ │ │ -

    should_log() returns true if peer logging is enabled in the │ │ │ -given direction. peer_log() emits a peer_log_alert for this │ │ │ -connection, with printf-style formatting.

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

    can_disconnect()

    │ │ │ -
    │ │ │ -bool can_disconnect (error_code const& ec) const;
    │ │ │ -
    │ │ │ -

    returns true if a disconnect with error ec would be │ │ │ -permitted at this point (some errors are suppressed during │ │ │ -startup).

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

    has_metadata()

    │ │ │ -
    │ │ │ -bool has_metadata () const;
    │ │ │ -
    │ │ │ -

    returns true if we have received the metadata (info dict) for │ │ │ -this torrent from the peer or otherwise

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

    in_handshake()

    │ │ │ -
    │ │ │ -bool in_handshake () const;
    │ │ │ -
    │ │ │ -

    returns true if the connection is still in the BitTorrent │ │ │ -handshake phase

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

    send_buffer()

    │ │ │ -
    │ │ │ -void send_buffer (char const* begin, int size);
    │ │ │ -
    │ │ │ -

    queue size bytes of data to be sent to the peer. The data │ │ │ -is copied; the buffer does not need to outlive the call.

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

    last_seen_complete() time_of_last_unchoke()

    │ │ │ -
    │ │ │ -time_point time_of_last_unchoke () const;
    │ │ │ -std::time_t last_seen_complete () const;
    │ │ │ -
    │ │ │ -

    the most recent time_of_completion reported by the peer │ │ │ -(BEP 21), and the wall-clock time when we last unchoked it.

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

    native_handle()

    │ │ │ -
    │ │ │ -std::shared_ptr<aux::peer_connection> native_handle () const;
    │ │ │ -
    │ │ │ -

    returns a shared_ptr to the underlying peer_connection. The │ │ │ -pointer may be null if the connection has already been │ │ │ -destroyed.

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

    bt_peer_connection_handle

    │ │ │ -

    Declared in "libtorrent/peer_connection_handle.hpp"

    │ │ │ -

    The bt_peer_connection_handle provides a handle to the internal bittorrent │ │ │ -peer connection object to plugins. It's low level and may not be a stable API │ │ │ -across libtorrent versions.

    │ │ │ -
    │ │ │ -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);
    │ │ │ -   std::shared_ptr<aux::bt_peer_connection> native_handle () const;
    │ │ │ -};
    │ │ │ -
    │ │ │ -[report issue]
    │ │ │ -

    bt_peer_connection_handle()

    │ │ │ -
    │ │ │ -explicit bt_peer_connection_handle (peer_connection_handle pc);
    │ │ │ -
    │ │ │ -

    construct from a generic peer_connection_handle. Behavior │ │ │ -is undefined if the underlying connection is not actually a │ │ │ -bittorrent peer connection.

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

    packet_finished() support_extensions()

    │ │ │ -
    │ │ │ -bool packet_finished () const;
    │ │ │ -bool support_extensions () const;
    │ │ │ -
    │ │ │ -

    packet_finished() returns true if the receive buffer holds a │ │ │ -complete BitTorrent message. support_extensions() returns true │ │ │ -if the remote peer announced support for the LTEP extension │ │ │ -protocol (BEP 10).

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

    supports_encryption()

    │ │ │ -
    │ │ │ -bool supports_encryption () const;
    │ │ │ -
    │ │ │ -

    returns true if MSE (Message Stream Encryption) is in use on │ │ │ -this connection

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

    switch_recv_crypto() switch_send_crypto()

    │ │ │ -
    │ │ │ -void switch_recv_crypto (std::shared_ptr<crypto_plugin> crypto);
    │ │ │ -void switch_send_crypto (std::shared_ptr<crypto_plugin> crypto);
    │ │ │ -
    │ │ │ -

    install a custom crypto_plugin on the send or receive path. │ │ │ -Used to inject MSE / PE-style stream cipher into the peer │ │ │ -connection.

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

    native_handle()

    │ │ │ -
    │ │ │ -std::shared_ptr<aux::bt_peer_connection> native_handle () const;
    │ │ │ -
    │ │ │ -

    returns a shared_ptr to the underlying bt_peer_connection. May │ │ │ -be null if the connection has been destroyed.

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

    create_ut_pex_plugin()

    │ │ │

    Declared in "libtorrent/extensions/ut_pex.hpp"

    │ │ │
    │ │ │  std::shared_ptr<torrent_plugin> create_ut_pex_plugin (torrent_handle const&, client_data_t);
    │ │ │ ├── html2text {}
    │ │ │ │ @@ -2,14 +2,43 @@
    │ │ │ │  _[_l_i_b_t_o_r_r_e_n_t_ _l_o_g_o_]
    │ │ │ │  VVeerrssiioonn:: 2.1.2
    │ │ │ │  _h_o_m_e
    │ │ │ │  Table of contents
    │ │ │ │      * _a_ _w_o_r_d_ _o_f_ _c_a_u_t_i_o_n
    │ │ │ │      * _p_l_u_g_i_n_-_i_n_t_e_r_f_a_c_e
    │ │ │ │      * _c_u_s_t_o_m_ _a_l_e_r_t_s
    │ │ │ │ +    * _p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e
    │ │ │ │ +          o _p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_(_)
    │ │ │ │ +          o _t_y_p_e_(_)
    │ │ │ │ +          o _a_d_d___e_x_t_e_n_s_i_o_n_(_)_ _f_i_n_d___p_l_u_g_i_n_(_)
    │ │ │ │ +          o _i_s___s_e_e_d_(_)
    │ │ │ │ +          o _u_p_l_o_a_d___o_n_l_y_(_)
    │ │ │ │ +          o _h_a_s___p_i_e_c_e_(_)_ _p_i_d_(_)
    │ │ │ │ +          o _i_s___c_h_o_k_e_d_(_)_ _i_s___i_n_t_e_r_e_s_t_i_n_g_(_)
    │ │ │ │ +          o _i_s___p_e_e_r___i_n_t_e_r_e_s_t_e_d_(_)_ _h_a_s___p_e_e_r___c_h_o_k_e_d_(_)
    │ │ │ │ +          o _c_h_o_k_e___t_h_i_s___p_e_e_r_(_)_ _m_a_y_b_e___u_n_c_h_o_k_e___t_h_i_s___p_e_e_r_(_)
    │ │ │ │ +          o _g_e_t___p_e_e_r___i_n_f_o_(_)
    │ │ │ │ +          o _a_s_s_o_c_i_a_t_e_d___t_o_r_r_e_n_t_(_)
    │ │ │ │ +          o _l_o_c_a_l___e_n_d_p_o_i_n_t_(_)_ _r_e_m_o_t_e_(_)
    │ │ │ │ +          o _i_s___c_o_n_n_e_c_t_i_n_g_(_)_ _i_s___o_u_t_g_o_i_n_g_(_)_ _d_i_s_c_o_n_n_e_c_t_(_)_ _i_s___d_i_s_c_o_n_n_e_c_t_i_n_g_(_)
    │ │ │ │ +          o _o_n___l_o_c_a_l___n_e_t_w_o_r_k_(_)_ _i_g_n_o_r_e___u_n_c_h_o_k_e___s_l_o_t_s_(_)
    │ │ │ │ +          o _f_a_i_l_e_d_(_)
    │ │ │ │ +          o _p_e_e_r___l_o_g_(_)_ _s_h_o_u_l_d___l_o_g_(_)
    │ │ │ │ +          o _c_a_n___d_i_s_c_o_n_n_e_c_t_(_)
    │ │ │ │ +          o _h_a_s___m_e_t_a_d_a_t_a_(_)
    │ │ │ │ +          o _i_n___h_a_n_d_s_h_a_k_e_(_)
    │ │ │ │ +          o _s_e_n_d___b_u_f_f_e_r_(_)
    │ │ │ │ +          o _t_i_m_e___o_f___l_a_s_t___u_n_c_h_o_k_e_(_)_ _l_a_s_t___s_e_e_n___c_o_m_p_l_e_t_e_(_)
    │ │ │ │ +          o _n_a_t_i_v_e___h_a_n_d_l_e_(_)
    │ │ │ │ +    * _b_t___p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e
    │ │ │ │ +          o _b_t___p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_(_)
    │ │ │ │ +          o _s_u_p_p_o_r_t___e_x_t_e_n_s_i_o_n_s_(_)_ _p_a_c_k_e_t___f_i_n_i_s_h_e_d_(_)
    │ │ │ │ +          o _s_u_p_p_o_r_t_s___e_n_c_r_y_p_t_i_o_n_(_)
    │ │ │ │ +          o _s_w_i_t_c_h___r_e_c_v___c_r_y_p_t_o_(_)_ _s_w_i_t_c_h___s_e_n_d___c_r_y_p_t_o_(_)
    │ │ │ │ +          o _n_a_t_i_v_e___h_a_n_d_l_e_(_)
    │ │ │ │      * _p_l_u_g_i_n
    │ │ │ │            o _i_m_p_l_e_m_e_n_t_e_d___f_e_a_t_u_r_e_s_(_)
    │ │ │ │            o _n_e_w___t_o_r_r_e_n_t_(_)
    │ │ │ │            o _a_d_d_e_d_(_)
    │ │ │ │            o _a_b_o_r_t_(_)
    │ │ │ │            o _o_n___d_h_t___r_e_q_u_e_s_t_(_)
    │ │ │ │            o _o_n___a_l_e_r_t_(_)
    │ │ │ │ @@ -29,63 +58,34 @@
    │ │ │ │      * _p_e_e_r___p_l_u_g_i_n
    │ │ │ │            o _t_y_p_e_(_)
    │ │ │ │            o _a_d_d___h_a_n_d_s_h_a_k_e_(_)
    │ │ │ │            o _o_n___d_i_s_c_o_n_n_e_c_t_(_)
    │ │ │ │            o _o_n___c_o_n_n_e_c_t_e_d_(_)
    │ │ │ │            o _o_n___h_a_n_d_s_h_a_k_e_(_)
    │ │ │ │            o _o_n___e_x_t_e_n_s_i_o_n___h_a_n_d_s_h_a_k_e_(_)
    │ │ │ │ -          o _o_n___a_l_l_o_w_e_d___f_a_s_t_(_)_ _o_n___r_e_q_u_e_s_t_(_)_ _o_n___n_o_t___i_n_t_e_r_e_s_t_e_d_(_)_ _o_n___d_o_n_t___h_a_v_e_(_)
    │ │ │ │ -            _o_n___h_a_v_e_(_)_ _o_n___u_n_c_h_o_k_e_(_)_ _o_n___h_a_v_e___n_o_n_e_(_)_ _o_n___c_h_o_k_e_(_)_ _o_n___i_n_t_e_r_e_s_t_e_d_(_)
    │ │ │ │ -            _o_n___h_a_v_e___a_l_l_(_)_ _o_n___b_i_t_f_i_e_l_d_(_)
    │ │ │ │ +          o _o_n___h_a_v_e___n_o_n_e_(_)_ _o_n___a_l_l_o_w_e_d___f_a_s_t_(_)_ _o_n___u_n_c_h_o_k_e_(_)_ _o_n___c_h_o_k_e_(_)
    │ │ │ │ +            _o_n___b_i_t_f_i_e_l_d_(_)_ _o_n___h_a_v_e___a_l_l_(_)_ _o_n___r_e_q_u_e_s_t_(_)_ _o_n___i_n_t_e_r_e_s_t_e_d_(_)_ _o_n___h_a_v_e_(_)
    │ │ │ │ +            _o_n___d_o_n_t___h_a_v_e_(_)_ _o_n___n_o_t___i_n_t_e_r_e_s_t_e_d_(_)
    │ │ │ │            o _o_n___p_i_e_c_e_(_)
    │ │ │ │ -          o _o_n___r_e_j_e_c_t_(_)_ _o_n___c_a_n_c_e_l_(_)_ _o_n___s_u_g_g_e_s_t_(_)
    │ │ │ │ -          o _s_e_n_t___r_e_q_u_e_s_t_(_)_ _s_e_n_t___s_u_g_g_e_s_t_(_)_ _s_e_n_t___h_a_v_e___a_l_l_(_)_ _s_e_n_t___p_i_e_c_e_(_)
    │ │ │ │ -            _s_e_n_t___c_h_o_k_e_(_)_ _s_e_n_t___h_a_v_e___n_o_n_e_(_)_ _s_e_n_t___n_o_t___i_n_t_e_r_e_s_t_e_d_(_)_ _s_e_n_t___a_l_l_o_w___f_a_s_t
    │ │ │ │ -            _(_)_ _s_e_n_t___r_e_j_e_c_t___r_e_q_u_e_s_t_(_)_ _s_e_n_t___i_n_t_e_r_e_s_t_e_d_(_)_ _s_e_n_t___u_n_c_h_o_k_e_(_)
    │ │ │ │ -            _s_e_n_t___c_a_n_c_e_l_(_)_ _s_e_n_t___h_a_v_e_(_)
    │ │ │ │ +          o _o_n___c_a_n_c_e_l_(_)_ _o_n___r_e_j_e_c_t_(_)_ _o_n___s_u_g_g_e_s_t_(_)
    │ │ │ │ +          o _s_e_n_t___r_e_q_u_e_s_t_(_)_ _s_e_n_t___i_n_t_e_r_e_s_t_e_d_(_)_ _s_e_n_t___h_a_v_e___n_o_n_e_(_)_ _s_e_n_t___c_a_n_c_e_l_(_)
    │ │ │ │ +            _s_e_n_t___n_o_t___i_n_t_e_r_e_s_t_e_d_(_)_ _s_e_n_t___h_a_v_e_(_)_ _s_e_n_t___s_u_g_g_e_s_t_(_)_ _s_e_n_t___a_l_l_o_w___f_a_s_t_(_)
    │ │ │ │ +            _s_e_n_t___h_a_v_e___a_l_l_(_)_ _s_e_n_t___p_i_e_c_e_(_)_ _s_e_n_t___r_e_j_e_c_t___r_e_q_u_e_s_t_(_)_ _s_e_n_t___u_n_c_h_o_k_e_(_)
    │ │ │ │ +            _s_e_n_t___c_h_o_k_e_(_)
    │ │ │ │            o _s_e_n_t___p_a_y_l_o_a_d_(_)
    │ │ │ │            o _c_a_n___d_i_s_c_o_n_n_e_c_t_(_)
    │ │ │ │            o _o_n___e_x_t_e_n_d_e_d_(_)
    │ │ │ │            o _o_n___u_n_k_n_o_w_n___m_e_s_s_a_g_e_(_)
    │ │ │ │            o _o_n___p_i_e_c_e___f_a_i_l_e_d_(_)_ _o_n___p_i_e_c_e___p_a_s_s_(_)
    │ │ │ │            o _t_i_c_k_(_)
    │ │ │ │            o _w_r_i_t_e___r_e_q_u_e_s_t_(_)
    │ │ │ │      * _c_r_y_p_t_o___p_l_u_g_i_n
    │ │ │ │ -          o _s_e_t___i_n_c_o_m_i_n_g___k_e_y_(_)_ _s_e_t___o_u_t_g_o_i_n_g___k_e_y_(_)
    │ │ │ │ +          o _s_e_t___o_u_t_g_o_i_n_g___k_e_y_(_)_ _s_e_t___i_n_c_o_m_i_n_g___k_e_y_(_)
    │ │ │ │            o _e_n_c_r_y_p_t_(_)
    │ │ │ │            o _d_e_c_r_y_p_t_(_)
    │ │ │ │ -    * _p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e
    │ │ │ │ -          o _p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_(_)
    │ │ │ │ -          o _t_y_p_e_(_)
    │ │ │ │ -          o _a_d_d___e_x_t_e_n_s_i_o_n_(_)_ _f_i_n_d___p_l_u_g_i_n_(_)
    │ │ │ │ -          o _i_s___s_e_e_d_(_)
    │ │ │ │ -          o _u_p_l_o_a_d___o_n_l_y_(_)
    │ │ │ │ -          o _p_i_d_(_)_ _h_a_s___p_i_e_c_e_(_)
    │ │ │ │ -          o _i_s___i_n_t_e_r_e_s_t_i_n_g_(_)_ _i_s___c_h_o_k_e_d_(_)
    │ │ │ │ -          o _i_s___p_e_e_r___i_n_t_e_r_e_s_t_e_d_(_)_ _h_a_s___p_e_e_r___c_h_o_k_e_d_(_)
    │ │ │ │ -          o _m_a_y_b_e___u_n_c_h_o_k_e___t_h_i_s___p_e_e_r_(_)_ _c_h_o_k_e___t_h_i_s___p_e_e_r_(_)
    │ │ │ │ -          o _g_e_t___p_e_e_r___i_n_f_o_(_)
    │ │ │ │ -          o _a_s_s_o_c_i_a_t_e_d___t_o_r_r_e_n_t_(_)
    │ │ │ │ -          o _l_o_c_a_l___e_n_d_p_o_i_n_t_(_)_ _r_e_m_o_t_e_(_)
    │ │ │ │ -          o _i_s___o_u_t_g_o_i_n_g_(_)_ _i_s___c_o_n_n_e_c_t_i_n_g_(_)_ _d_i_s_c_o_n_n_e_c_t_(_)_ _i_s___d_i_s_c_o_n_n_e_c_t_i_n_g_(_)
    │ │ │ │ -          o _o_n___l_o_c_a_l___n_e_t_w_o_r_k_(_)_ _i_g_n_o_r_e___u_n_c_h_o_k_e___s_l_o_t_s_(_)
    │ │ │ │ -          o _f_a_i_l_e_d_(_)
    │ │ │ │ -          o _s_h_o_u_l_d___l_o_g_(_)_ _p_e_e_r___l_o_g_(_)
    │ │ │ │ -          o _c_a_n___d_i_s_c_o_n_n_e_c_t_(_)
    │ │ │ │ -          o _h_a_s___m_e_t_a_d_a_t_a_(_)
    │ │ │ │ -          o _i_n___h_a_n_d_s_h_a_k_e_(_)
    │ │ │ │ -          o _s_e_n_d___b_u_f_f_e_r_(_)
    │ │ │ │ -          o _l_a_s_t___s_e_e_n___c_o_m_p_l_e_t_e_(_)_ _t_i_m_e___o_f___l_a_s_t___u_n_c_h_o_k_e_(_)
    │ │ │ │ -          o _n_a_t_i_v_e___h_a_n_d_l_e_(_)
    │ │ │ │ -    * _b_t___p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e
    │ │ │ │ -          o _b_t___p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_(_)
    │ │ │ │ -          o _p_a_c_k_e_t___f_i_n_i_s_h_e_d_(_)_ _s_u_p_p_o_r_t___e_x_t_e_n_s_i_o_n_s_(_)
    │ │ │ │ -          o _s_u_p_p_o_r_t_s___e_n_c_r_y_p_t_i_o_n_(_)
    │ │ │ │ -          o _s_w_i_t_c_h___r_e_c_v___c_r_y_p_t_o_(_)_ _s_w_i_t_c_h___s_e_n_d___c_r_y_p_t_o_(_)
    │ │ │ │ -          o _n_a_t_i_v_e___h_a_n_d_l_e_(_)
    │ │ │ │      * _c_r_e_a_t_e___u_t___p_e_x___p_l_u_g_i_n_(_)
    │ │ │ │      * _c_r_e_a_t_e___s_m_a_r_t___b_a_n___p_l_u_g_i_n_(_)
    │ │ │ │      * _c_r_e_a_t_e___u_t___m_e_t_a_d_a_t_a___p_l_u_g_i_n_(_)
    │ │ │ │  libtorrent has a _p_l_u_g_i_n interface for implementing extensions to the protocol.
    │ │ │ │  These can be general extensions for transferring metadata or peer exchange
    │ │ │ │  extensions, or it could be used to provide a way to customize the protocol to
    │ │ │ │  fit a particular (closed) network.
    │ │ │ │ @@ -164,14 +164,236 @@
    │ │ │ │  The static category is required for checking whether or not the category for a
    │ │ │ │  specific _a_l_e_r_t is enabled or not, without instantiating the _a_l_e_r_t. The category
    │ │ │ │  virtual function is the run-time equivalence.
    │ │ │ │  The what() virtual function may simply be a string literal of the class name of
    │ │ │ │  your _a_l_e_r_t.
    │ │ │ │  For more information, see the _a_l_e_r_t_ _s_e_c_t_i_o_n.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +************ ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee ************
    │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_._h_p_p"
    │ │ │ │ +the _p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e class provides a handle to the internal peer
    │ │ │ │ +connection object, to be used by plugins. This is a low level interface that
    │ │ │ │ +may not be stable across libtorrent versions
    │ │ │ │ +struct peer_connection_handle
    │ │ │ │ +{
    │ │ │ │ +   explicit ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (std::weak_ptr impl);
    │ │ │ │ +   connection_type ttyyppee () const;
    │ │ │ │ +   peer_plugin const* ffiinndd__pplluuggiinn (string_view type) const;
    │ │ │ │ +   void aadddd__eexxtteennssiioonn (std::shared_ptr);
    │ │ │ │ +   bool iiss__sseeeedd () const;
    │ │ │ │ +   bool uuppllooaadd__oonnllyy () const;
    │ │ │ │ +   peer_id const& ppiidd () const;
    │ │ │ │ +   bool hhaass__ppiieeccee (piece_index_t i) const;
    │ │ │ │ +   bool iiss__iinntteerreessttiinngg () const;
    │ │ │ │ +   bool iiss__cchhookkeedd () const;
    │ │ │ │ +   bool hhaass__ppeeeerr__cchhookkeedd () const;
    │ │ │ │ +   bool iiss__ppeeeerr__iinntteerreesstteedd () const;
    │ │ │ │ +   void cchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ +   void mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ +   void ggeett__ppeeeerr__iinnffoo (peer_info& p) const;
    │ │ │ │ +   torrent_handle aassssoocciiaatteedd__ttoorrrreenntt () const;
    │ │ │ │ +   _t_c_p_:_:_e_n_d_p_o_i_n_t const& rreemmoottee () const;
    │ │ │ │ +   _t_c_p_:_:_e_n_d_p_o_i_n_t llooccaall__eennddppooiinntt () const;
    │ │ │ │ +   void ddiissccoonnnneecctt (error_code const& ec, operation_t op
    │ │ │ │ +      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ │ +   bool iiss__ddiissccoonnnneeccttiinngg () const;
    │ │ │ │ +   bool iiss__oouuttggooiinngg () const;
    │ │ │ │ +   bool iiss__ccoonnnneeccttiinngg () const;
    │ │ │ │ +   bool oonn__llooccaall__nneettwwoorrkk () const;
    │ │ │ │ +   bool iiggnnoorree__uunncchhookkee__sslloottss () const;
    │ │ │ │ +   bool ffaaiilleedd () const;
    │ │ │ │ +   bool sshhoouulldd__lloogg (peer_log_alert::direction_t direction) const;
    │ │ │ │ +   void ppeeeerr__lloogg (peer_log_alert::direction_t direction
    │ │ │ │ +      , peer_log_alert::event_t event, char const* fmt = "", ...) const
    │ │ │ │ +TORRENT_FORMAT(4,5);
    │ │ │ │ +   bool ccaann__ddiissccoonnnneecctt (error_code const& ec) const;
    │ │ │ │ +   bool hhaass__mmeettaaddaattaa () const;
    │ │ │ │ +   bool iinn__hhaannddsshhaakkee () const;
    │ │ │ │ +   void sseenndd__bbuuffffeerr (char const* begin, int size);
    │ │ │ │ +   std::time_t llaasstt__sseeeenn__ccoommpplleettee () const;
    │ │ │ │ +   time_point ttiimmee__ooff__llaasstt__uunncchhookkee () const;
    │ │ │ │ +   bool ooppeerraattoorr<< (peer_connection_handle const& o) const;
    │ │ │ │ +   bool ooppeerraattoorr==== (peer_connection_handle const& o) const;
    │ │ │ │ +   bool ooppeerraattoorr!!== (peer_connection_handle const& o) const;
    │ │ │ │ +   std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ +};
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee(()) **********
    │ │ │ │ +explicit ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (std::weak_ptr impl);
    │ │ │ │ +construct a handle wrapping the given internal peer_connection. Typically
    │ │ │ │ +created by libtorrent and passed to plugins; not intended to be constructed by
    │ │ │ │ +user code.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ttyyppee(()) **********
    │ │ │ │ +connection_type ttyyppee () const;
    │ │ │ │ +the protocol type of this connection (bittorrent, url_seed, http_seed)
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** aadddd__eexxtteennssiioonn(()) ffiinndd__pplluuggiinn(()) **********
    │ │ │ │ +peer_plugin const* ffiinndd__pplluuggiinn (string_view type) const;
    │ │ │ │ +void aadddd__eexxtteennssiioonn (std::shared_ptr);
    │ │ │ │ +attach a _p_e_e_r___p_l_u_g_i_n to this connection. find_plugin() looks up an attached
    │ │ │ │ +_p_l_u_g_i_n by its type() string and returns nullptr if none is registered.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** iiss__sseeeedd(()) **********
    │ │ │ │ +bool iiss__sseeeedd () const;
    │ │ │ │ +returns true if the remote peer is a seed
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** uuppllooaadd__oonnllyy(()) **********
    │ │ │ │ +bool uuppllooaadd__oonnllyy () const;
    │ │ │ │ +returns true if the remote peer has indicated upload-only (it is a seed or has
    │ │ │ │ +chosen not to download anything more from us)
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** hhaass__ppiieeccee(()) ppiidd(()) **********
    │ │ │ │ +peer_id const& ppiidd () const;
    │ │ │ │ +bool hhaass__ppiieeccee (piece_index_t i) const;
    │ │ │ │ +the peer id reported by the remote during handshake. has_piece(i) returns true
    │ │ │ │ +if the remote peer has piece i.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** iiss__cchhookkeedd(()) iiss__iinntteerreessttiinngg(()) **********
    │ │ │ │ +bool iiss__iinntteerreessttiinngg () const;
    │ │ │ │ +bool iiss__cchhookkeedd () const;
    │ │ │ │ +_i_s___i_n_t_e_r_e_s_t_i_n_g_(_) returns true if we are interested in the peer (it has pieces
    │ │ │ │ +we want). _i_s___c_h_o_k_e_d_(_) returns true if we have choked the peer (we are not
    │ │ │ │ +currently sending data to it).
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** iiss__ppeeeerr__iinntteerreesstteedd(()) hhaass__ppeeeerr__cchhookkeedd(()) **********
    │ │ │ │ +bool hhaass__ppeeeerr__cchhookkeedd () const;
    │ │ │ │ +bool iiss__ppeeeerr__iinntteerreesstteedd () const;
    │ │ │ │ +_i_s___p_e_e_r___i_n_t_e_r_e_s_t_e_d_(_) returns true if the peer has indicated it is interested in
    │ │ │ │ +us. _h_a_s___p_e_e_r___c_h_o_k_e_d_(_) returns true if the peer is choking us.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** cchhookkee__tthhiiss__ppeeeerr(()) mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr(()) **********
    │ │ │ │ +void cchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ +void mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ +choke or possibly unchoke this peer immediately, bypassing the regular unchoke
    │ │ │ │ +selection. maybe_unchoke_this_peer() only unchokes if there is an unchoke slot
    │ │ │ │ +available.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ggeett__ppeeeerr__iinnffoo(()) **********
    │ │ │ │ +void ggeett__ppeeeerr__iinnffoo (peer_info& p) const;
    │ │ │ │ +fills in p with statistics and state for this connection, equivalent to the
    │ │ │ │ +corresponding _e_n_t_r_y returned by _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_g_e_t___p_e_e_r___i_n_f_o_(_).
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** aassssoocciiaatteedd__ttoorrrreenntt(()) **********
    │ │ │ │ +torrent_handle aassssoocciiaatteedd__ttoorrrreenntt () const;
    │ │ │ │ +the torrent this peer is associated with. Returns an invalid handle if the peer
    │ │ │ │ +is not yet associated with a torrent.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** llooccaall__eennddppooiinntt(()) rreemmoottee(()) **********
    │ │ │ │ +_t_c_p_:_:_e_n_d_p_o_i_n_t const& rreemmoottee () const;
    │ │ │ │ +_t_c_p_:_:_e_n_d_p_o_i_n_t llooccaall__eennddppooiinntt () const;
    │ │ │ │ +the remote peer's address and port, and the local endpoint of the socket on our
    │ │ │ │ +side.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** iiss__ccoonnnneeccttiinngg(()) iiss__oouuttggooiinngg(()) ddiissccoonnnneecctt(()) iiss__ddiissccoonnnneeccttiinngg(()) **********
    │ │ │ │ +void ddiissccoonnnneecctt (error_code const& ec, operation_t op
    │ │ │ │ +      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ │ +bool iiss__ddiissccoonnnneeccttiinngg () const;
    │ │ │ │ +bool iiss__oouuttggooiinngg () const;
    │ │ │ │ +bool iiss__ccoonnnneeccttiinngg () const;
    │ │ │ │ +drop the connection with the given error code and operation type. The
    │ │ │ │ +disconnect is asynchronous; is_disconnecting() becomes true immediately and the
    │ │ │ │ +actual socket close happens later. is_connecting() reports whether the outgoing
    │ │ │ │ +socket is still in the connect phase; is_outgoing() whether the connection was
    │ │ │ │ +initiated by us.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** oonn__llooccaall__nneettwwoorrkk(()) iiggnnoorree__uunncchhookkee__sslloottss(()) **********
    │ │ │ │ +bool oonn__llooccaall__nneettwwoorrkk () const;
    │ │ │ │ +bool iiggnnoorree__uunncchhookkee__sslloottss () const;
    │ │ │ │ +returns true if the peer's address is on the same local network as us.
    │ │ │ │ +ignore_unchoke_slots() returns true if this peer is excluded from regular
    │ │ │ │ +unchoke slot accounting.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ffaaiilleedd(()) **********
    │ │ │ │ +bool ffaaiilleedd () const;
    │ │ │ │ +returns true if the connection has been closed because of an error (rather than
    │ │ │ │ +because of a normal disconnect)
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ppeeeerr__lloogg(()) sshhoouulldd__lloogg(()) **********
    │ │ │ │ +bool sshhoouulldd__lloogg (peer_log_alert::direction_t direction) const;
    │ │ │ │ +void ppeeeerr__lloogg (peer_log_alert::direction_t direction
    │ │ │ │ +      , peer_log_alert::event_t event, char const* fmt = "", ...) const
    │ │ │ │ +TORRENT_FORMAT(4,5);
    │ │ │ │ +_s_h_o_u_l_d___l_o_g_(_) returns true if peer logging is enabled in the given direction.
    │ │ │ │ +_p_e_e_r___l_o_g_(_) emits a peer_log_alert for this connection, with printf-style
    │ │ │ │ +formatting.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ccaann__ddiissccoonnnneecctt(()) **********
    │ │ │ │ +bool ccaann__ddiissccoonnnneecctt (error_code const& ec) const;
    │ │ │ │ +returns true if a disconnect with error ec would be permitted at this point
    │ │ │ │ +(some errors are suppressed during startup).
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** hhaass__mmeettaaddaattaa(()) **********
    │ │ │ │ +bool hhaass__mmeettaaddaattaa () const;
    │ │ │ │ +returns true if we have received the metadata (info dict) for this torrent from
    │ │ │ │ +the peer or otherwise
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** iinn__hhaannddsshhaakkee(()) **********
    │ │ │ │ +bool iinn__hhaannddsshhaakkee () const;
    │ │ │ │ +returns true if the connection is still in the BitTorrent handshake phase
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** sseenndd__bbuuffffeerr(()) **********
    │ │ │ │ +void sseenndd__bbuuffffeerr (char const* begin, int size);
    │ │ │ │ +queue size bytes of data to be sent to the peer. The data is copied; the buffer
    │ │ │ │ +does not need to outlive the call.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ttiimmee__ooff__llaasstt__uunncchhookkee(()) llaasstt__sseeeenn__ccoommpplleettee(()) **********
    │ │ │ │ +std::time_t llaasstt__sseeeenn__ccoommpplleettee () const;
    │ │ │ │ +time_point ttiimmee__ooff__llaasstt__uunncchhookkee () const;
    │ │ │ │ +the most recent time_of_completion reported by the peer (BEP 21), and the wall-
    │ │ │ │ +clock time when we last unchoked it.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** nnaattiivvee__hhaannddllee(()) **********
    │ │ │ │ +std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ +returns a shared_ptr to the underlying peer_connection. The pointer may be null
    │ │ │ │ +if the connection has already been destroyed.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +************ bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee ************
    │ │ │ │ +Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_._h_p_p"
    │ │ │ │ +The _b_t___p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e provides a handle to the internal bittorrent peer
    │ │ │ │ +connection object to plugins. It's low level and may not be a stable API across
    │ │ │ │ +libtorrent versions.
    │ │ │ │ +struct bt_peer_connection_handle : peer_connection_handle
    │ │ │ │ +{
    │ │ │ │ +   explicit bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (peer_connection_handle pc);
    │ │ │ │ +   bool ssuuppppoorrtt__eexxtteennssiioonnss () const;
    │ │ │ │ +   bool ppaacckkeett__ffiinniisshheedd () const;
    │ │ │ │ +   bool ssuuppppoorrttss__eennccrryyppttiioonn () const;
    │ │ │ │ +   void sswwiittcchh__rreeccvv__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ +   void sswwiittcchh__sseenndd__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ +   std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ +};
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee(()) **********
    │ │ │ │ +explicit bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (peer_connection_handle pc);
    │ │ │ │ +construct from a generic peer_connection_handle. Behavior is undefined if the
    │ │ │ │ +underlying connection is not actually a bittorrent peer connection.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ssuuppppoorrtt__eexxtteennssiioonnss(()) ppaacckkeett__ffiinniisshheedd(()) **********
    │ │ │ │ +bool ssuuppppoorrtt__eexxtteennssiioonnss () const;
    │ │ │ │ +bool ppaacckkeett__ffiinniisshheedd () const;
    │ │ │ │ +_p_a_c_k_e_t___f_i_n_i_s_h_e_d_(_) returns true if the receive buffer holds a complete
    │ │ │ │ +BitTorrent message. _s_u_p_p_o_r_t___e_x_t_e_n_s_i_o_n_s_(_) returns true if the remote peer
    │ │ │ │ +announced support for the LTEP extension protocol (BEP 10).
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** ssuuppppoorrttss__eennccrryyppttiioonn(()) **********
    │ │ │ │ +bool ssuuppppoorrttss__eennccrryyppttiioonn () const;
    │ │ │ │ +returns true if MSE (Message Stream Encryption) is in use on this connection
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** sswwiittcchh__rreeccvv__ccrryyppttoo(()) sswwiittcchh__sseenndd__ccrryyppttoo(()) **********
    │ │ │ │ +void sswwiittcchh__rreeccvv__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ +void sswwiittcchh__sseenndd__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ +install a custom crypto_plugin on the send or receive path. Used to inject MSE
    │ │ │ │ +/ PE-style stream cipher into the peer connection.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ +********** nnaattiivvee__hhaannddllee(()) **********
    │ │ │ │ +std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ +returns a shared_ptr to the underlying bt_peer_connection. May be null if the
    │ │ │ │ +connection has been destroyed.
    │ │ │ │ +[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ************ pplluuggiinn ************
    │ │ │ │  Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_x_t_e_n_s_i_o_n_s_._h_p_p"
    │ │ │ │  this is the base class for a _s_e_s_s_i_o_n _p_l_u_g_i_n. One primary feature is that it is
    │ │ │ │  notified of all torrents that are added to the _s_e_s_s_i_o_n, and can add its own
    │ │ │ │  torrent_plugins.
    │ │ │ │  struct plugin
    │ │ │ │  {
    │ │ │ │ @@ -298,16 +520,16 @@
    │ │ │ │  struct torrent_plugin
    │ │ │ │  {
    │ │ │ │     virtual std::shared_ptr nneeww__ccoonnnneeccttiioonn (peer_connection_handle
    │ │ │ │  const&);
    │ │ │ │     virtual void oonn__ppiieeccee__ppaassss (piece_index_t);
    │ │ │ │     virtual void oonn__ppiieeccee__ffaaiilleedd (piece_index_t);
    │ │ │ │     virtual void ttiicckk ();
    │ │ │ │ -   virtual bool oonn__rreessuummee ();
    │ │ │ │     virtual bool oonn__ppaauussee ();
    │ │ │ │ +   virtual bool oonn__rreessuummee ();
    │ │ │ │     virtual void oonn__ffiilleess__cchheecckkeedd ();
    │ │ │ │     virtual void oonn__ssttaattee (torrent_status::state_t);
    │ │ │ │     virtual void oonn__aadddd__ppeeeerr (tcp::endpoint const&,
    │ │ │ │        peer_source_flags_t, add_peer_flags_t);
    │ │ │ │  
    │ │ │ │     static inline constexpr add_peer_flags_t ffiirrsstt__ttiimmee  = 1_bit;
    │ │ │ │     static inline constexpr add_peer_flags_t ffiilltteerreedd  = 2_bit;
    │ │ │ │ @@ -338,16 +560,16 @@
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** ttiicckk(()) **********
    │ │ │ │  virtual void ttiicckk ();
    │ │ │ │  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.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** oonn__ppaauussee(()) oonn__rreessuummee(()) **********
    │ │ │ │ -virtual bool oonn__rreessuummee ();
    │ │ │ │  virtual bool oonn__ppaauussee ();
    │ │ │ │ +virtual bool oonn__rreessuummee ();
    │ │ │ │  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 _p_l_u_g_i_n 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.
    │ │ │ │  Note that if you call pause() or resume() on the torrent from your handler it
    │ │ │ │ @@ -393,43 +615,43 @@
    │ │ │ │  {
    │ │ │ │     virtual string_view ttyyppee () const;
    │ │ │ │     virtual void aadddd__hhaannddsshhaakkee (entry&);
    │ │ │ │     virtual void oonn__ddiissccoonnnneecctt (error_code const&);
    │ │ │ │     virtual void oonn__ccoonnnneecctteedd ();
    │ │ │ │     virtual bool oonn__hhaannddsshhaakkee (span);
    │ │ │ │     virtual bool oonn__eexxtteennssiioonn__hhaannddsshhaakkee (bdecode_node const&);
    │ │ │ │ -   virtual bool oonn__hhaavvee__nnoonnee ();
    │ │ │ │ +   virtual bool oonn__hhaavvee (piece_index_t);
    │ │ │ │ +   virtual bool oonn__cchhookkee ();
    │ │ │ │     virtual bool oonn__nnoott__iinntteerreesstteedd ();
    │ │ │ │ +   virtual bool oonn__hhaavvee__nnoonnee ();
    │ │ │ │ +   virtual bool oonn__hhaavvee__aallll ();
    │ │ │ │     virtual bool oonn__aalllloowweedd__ffaasstt (piece_index_t);
    │ │ │ │ -   virtual bool oonn__hhaavvee (piece_index_t);
    │ │ │ │     virtual bool oonn__bbiittffiieelldd (bitfield const& //**bbiittffiieelldd**//);
    │ │ │ │ -   virtual bool oonn__cchhookkee ();
    │ │ │ │ -   virtual bool oonn__iinntteerreesstteedd ();
    │ │ │ │ +   virtual bool oonn__uunncchhookkee ();
    │ │ │ │     virtual bool oonn__rreeqquueesstt (peer_request const&);
    │ │ │ │ +   virtual bool oonn__iinntteerreesstteedd ();
    │ │ │ │     virtual bool oonn__ddoonntt__hhaavvee (piece_index_t);
    │ │ │ │ -   virtual bool oonn__uunncchhookkee ();
    │ │ │ │ -   virtual bool oonn__hhaavvee__aallll ();
    │ │ │ │     virtual bool oonn__ppiieeccee (peer_request const& //**ppiieeccee**//
    │ │ │ │        , span //**bbuuff**//);
    │ │ │ │ -   virtual bool oonn__ssuuggggeesstt (piece_index_t);
    │ │ │ │     virtual bool oonn__rreejjeecctt (peer_request const&);
    │ │ │ │ +   virtual bool oonn__ssuuggggeesstt (piece_index_t);
    │ │ │ │     virtual bool oonn__ccaanncceell (peer_request const&);
    │ │ │ │ -   virtual void sseenntt__hhaavvee__nnoonnee ();
    │ │ │ │ -   virtual void sseenntt__cchhookkee ();
    │ │ │ │ -   virtual void sseenntt__hhaavvee (piece_index_t);
    │ │ │ │ -   virtual void sseenntt__iinntteerreesstteedd ();
    │ │ │ │ -   virtual void sseenntt__rreeqquueesstt (peer_request const&);
    │ │ │ │     virtual void sseenntt__aallllooww__ffaasstt (piece_index_t);
    │ │ │ │ -   virtual void sseenntt__nnoott__iinntteerreesstteedd ();
    │ │ │ │     virtual void sseenntt__ppiieeccee (peer_request const&);
    │ │ │ │ -   virtual void sseenntt__rreejjeecctt__rreeqquueesstt (peer_request const&);
    │ │ │ │ -   virtual void sseenntt__uunncchhookkee ();
    │ │ │ │ -   virtual void sseenntt__ssuuggggeesstt (piece_index_t);
    │ │ │ │     virtual void sseenntt__hhaavvee__aallll ();
    │ │ │ │ +   virtual void sseenntt__cchhookkee ();
    │ │ │ │ +   virtual void sseenntt__nnoott__iinntteerreesstteedd ();
    │ │ │ │ +   virtual void sseenntt__ssuuggggeesstt (piece_index_t);
    │ │ │ │ +   virtual void sseenntt__rreeqquueesstt (peer_request const&);
    │ │ │ │ +   virtual void sseenntt__uunncchhookkee ();
    │ │ │ │     virtual void sseenntt__ccaanncceell (peer_request const&);
    │ │ │ │ +   virtual void sseenntt__hhaavvee__nnoonnee ();
    │ │ │ │ +   virtual void sseenntt__rreejjeecctt__rreeqquueesstt (peer_request const&);
    │ │ │ │ +   virtual void sseenntt__iinntteerreesstteedd ();
    │ │ │ │ +   virtual void sseenntt__hhaavvee (piece_index_t);
    │ │ │ │     virtual void sseenntt__ppaayyllooaadd (int //** bbyytteess **//);
    │ │ │ │     virtual bool ccaann__ddiissccoonnnneecctt (error_code const& //**eecc**//);
    │ │ │ │     virtual bool oonn__eexxtteennddeedd (int //**lleennggtthh**//, int //**mmssgg**//,
    │ │ │ │        span //**bbooddyy**//);
    │ │ │ │     virtual bool oonn__uunnkknnoowwnn__mmeessssaaggee (int //**lleennggtthh**//, int //**mmssgg**//,
    │ │ │ │        span //**bbooddyy**//);
    │ │ │ │     virtual void oonn__ppiieeccee__ppaassss (piece_index_t);
    │ │ │ │ @@ -465,65 +687,66 @@
    │ │ │ │  ********** oonn__eexxtteennssiioonn__hhaannddsshhaakkee(()) **********
    │ │ │ │  virtual bool oonn__eexxtteennssiioonn__hhaannddsshhaakkee (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 _p_e_e_r___p_l_u_g_i_n being removed from the peer_connection and
    │ │ │ │  destructed. this is not called for web seeds
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** oonn__aalllloowweedd__ffaasstt(()) oonn__rreeqquueesstt(()) oonn__nnoott__iinntteerreesstteedd(()) oonn__ddoonntt__hhaavvee(()) oonn__hhaavvee
    │ │ │ │ -(()) oonn__uunncchhookkee(()) oonn__hhaavvee__nnoonnee(()) oonn__cchhookkee(()) oonn__iinntteerreesstteedd(()) oonn__hhaavvee__aallll(())
    │ │ │ │ -oonn__bbiittffiieelldd(()) **********
    │ │ │ │ -virtual bool oonn__hhaavvee__nnoonnee ();
    │ │ │ │ +********** oonn__hhaavvee__nnoonnee(()) oonn__aalllloowweedd__ffaasstt(()) oonn__uunncchhookkee(()) oonn__cchhookkee(()) oonn__bbiittffiieelldd(())
    │ │ │ │ +oonn__hhaavvee__aallll(()) oonn__rreeqquueesstt(()) oonn__iinntteerreesstteedd(()) oonn__hhaavvee(()) oonn__ddoonntt__hhaavvee(())
    │ │ │ │ +oonn__nnoott__iinntteerreesstteedd(()) **********
    │ │ │ │ +virtual bool oonn__hhaavvee (piece_index_t);
    │ │ │ │ +virtual bool oonn__cchhookkee ();
    │ │ │ │  virtual bool oonn__nnoott__iinntteerreesstteedd ();
    │ │ │ │ +virtual bool oonn__hhaavvee__nnoonnee ();
    │ │ │ │ +virtual bool oonn__hhaavvee__aallll ();
    │ │ │ │  virtual bool oonn__aalllloowweedd__ffaasstt (piece_index_t);
    │ │ │ │ -virtual bool oonn__hhaavvee (piece_index_t);
    │ │ │ │  virtual bool oonn__bbiittffiieelldd (bitfield const& //**bbiittffiieelldd**//);
    │ │ │ │ -virtual bool oonn__cchhookkee ();
    │ │ │ │ -virtual bool oonn__iinntteerreesstteedd ();
    │ │ │ │ +virtual bool oonn__uunncchhookkee ();
    │ │ │ │  virtual bool oonn__rreeqquueesstt (peer_request const&);
    │ │ │ │ +virtual bool oonn__iinntteerreesstteedd ();
    │ │ │ │  virtual bool oonn__ddoonntt__hhaavvee (piece_index_t);
    │ │ │ │ -virtual bool oonn__uunncchhookkee ();
    │ │ │ │ -virtual bool oonn__hhaavvee__aallll ();
    │ │ │ │  returning true from any of the message handlers indicates that the _p_l_u_g_i_n has
    │ │ │ │  handled the message. it will break the _p_l_u_g_i_n chain traversing and not let
    │ │ │ │  anyone else handle the message, including the default handler.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** oonn__ppiieeccee(()) **********
    │ │ │ │  virtual bool oonn__ppiieeccee (peer_request const& //**ppiieeccee**//
    │ │ │ │        , span //**bbuuff**//);
    │ │ │ │  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.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** oonn__rreejjeecctt(()) oonn__ccaanncceell(()) oonn__ssuuggggeesstt(()) **********
    │ │ │ │ -virtual bool oonn__ssuuggggeesstt (piece_index_t);
    │ │ │ │ +********** oonn__ccaanncceell(()) oonn__rreejjeecctt(()) oonn__ssuuggggeesstt(()) **********
    │ │ │ │  virtual bool oonn__rreejjeecctt (peer_request const&);
    │ │ │ │ +virtual bool oonn__ssuuggggeesstt (piece_index_t);
    │ │ │ │  virtual bool oonn__ccaanncceell (peer_request const&);
    │ │ │ │  called when a CANCEL, REJECT or SUGGEST message is received from the peer. If
    │ │ │ │  the extension returns true, the message is not forwarded to the bittorrent
    │ │ │ │  engine. It's expected to have been handled by the extension.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** sseenntt__rreeqquueesstt(()) sseenntt__ssuuggggeesstt(()) sseenntt__hhaavvee__aallll(()) sseenntt__ppiieeccee(()) sseenntt__cchhookkee(())
    │ │ │ │ -sseenntt__hhaavvee__nnoonnee(()) sseenntt__nnoott__iinntteerreesstteedd(()) sseenntt__aallllooww__ffaasstt(()) sseenntt__rreejjeecctt__rreeqquueesstt(())
    │ │ │ │ -sseenntt__iinntteerreesstteedd(()) sseenntt__uunncchhookkee(()) sseenntt__ccaanncceell(()) sseenntt__hhaavvee(()) **********
    │ │ │ │ -virtual void sseenntt__hhaavvee__nnoonnee ();
    │ │ │ │ -virtual void sseenntt__cchhookkee ();
    │ │ │ │ -virtual void sseenntt__hhaavvee (piece_index_t);
    │ │ │ │ -virtual void sseenntt__iinntteerreesstteedd ();
    │ │ │ │ -virtual void sseenntt__rreeqquueesstt (peer_request const&);
    │ │ │ │ +********** sseenntt__rreeqquueesstt(()) sseenntt__iinntteerreesstteedd(()) sseenntt__hhaavvee__nnoonnee(()) sseenntt__ccaanncceell(())
    │ │ │ │ +sseenntt__nnoott__iinntteerreesstteedd(()) sseenntt__hhaavvee(()) sseenntt__ssuuggggeesstt(()) sseenntt__aallllooww__ffaasstt(())
    │ │ │ │ +sseenntt__hhaavvee__aallll(()) sseenntt__ppiieeccee(()) sseenntt__rreejjeecctt__rreeqquueesstt(()) sseenntt__uunncchhookkee(()) sseenntt__cchhookkee(())
    │ │ │ │ +**********
    │ │ │ │  virtual void sseenntt__aallllooww__ffaasstt (piece_index_t);
    │ │ │ │ -virtual void sseenntt__nnoott__iinntteerreesstteedd ();
    │ │ │ │  virtual void sseenntt__ppiieeccee (peer_request const&);
    │ │ │ │ -virtual void sseenntt__rreejjeecctt__rreeqquueesstt (peer_request const&);
    │ │ │ │ -virtual void sseenntt__uunncchhookkee ();
    │ │ │ │ -virtual void sseenntt__ssuuggggeesstt (piece_index_t);
    │ │ │ │  virtual void sseenntt__hhaavvee__aallll ();
    │ │ │ │ +virtual void sseenntt__cchhookkee ();
    │ │ │ │ +virtual void sseenntt__nnoott__iinntteerreesstteedd ();
    │ │ │ │ +virtual void sseenntt__ssuuggggeesstt (piece_index_t);
    │ │ │ │ +virtual void sseenntt__rreeqquueesstt (peer_request const&);
    │ │ │ │ +virtual void sseenntt__uunncchhookkee ();
    │ │ │ │  virtual void sseenntt__ccaanncceell (peer_request const&);
    │ │ │ │ +virtual void sseenntt__hhaavvee__nnoonnee ();
    │ │ │ │ +virtual void sseenntt__rreejjeecctt__rreeqquueesstt (peer_request const&);
    │ │ │ │ +virtual void sseenntt__iinntteerreesstteedd ();
    │ │ │ │ +virtual void sseenntt__hhaavvee (piece_index_t);
    │ │ │ │  called after the corresponding message has been sent to the peer.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ********** sseenntt__ppaayyllooaadd(()) **********
    │ │ │ │  virtual void sseenntt__ppaayyllooaadd (int //** bbyytteess **//);
    │ │ │ │  called after piece data has been sent to the peer this can be used for stats
    │ │ │ │  book keeping
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ @@ -577,15 +800,15 @@
    │ │ │ │     virtual void sseett__iinnccoommiinngg__kkeeyy (span key) = 0;
    │ │ │ │     virtual void sseett__oouuttggooiinngg__kkeeyy (span key) = 0;
    │ │ │ │     eennccrryypptt (span> //**sseenndd__vveecc**//) = 0;
    │ │ │ │     virtual std::tuple ddeeccrryypptt (span> //**rreecceeiivvee__vveecc**//
    │ │ │ │  ) = 0;
    │ │ │ │  };
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** sseett__iinnccoommiinngg__kkeeyy(()) sseett__oouuttggooiinngg__kkeeyy(()) **********
    │ │ │ │ +********** sseett__oouuttggooiinngg__kkeeyy(()) sseett__iinnccoommiinngg__kkeeyy(()) **********
    │ │ │ │  virtual void sseett__iinnccoommiinngg__kkeeyy (span key) = 0;
    │ │ │ │  virtual void sseett__oouuttggooiinngg__kkeeyy (span key) = 0;
    │ │ │ │  configure the symmetric stream keys used by this _p_l_u_g_i_n. set_incoming_key()
    │ │ │ │  provides the key for decrypting bytes received from the peer; set_outgoing_key
    │ │ │ │  () the key for encrypting bytes sent to the peer. Both are called once during
    │ │ │ │  the handshake before any data flows through the _p_l_u_g_i_n.
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ @@ -608,236 +831,14 @@
    │ │ │ │  consume is set to the number of bytes which should be trimmed from the head of
    │ │ │ │  the buffers, default is 0
    │ │ │ │  produce is set to the number of bytes of payload which are now ready to be sent
    │ │ │ │  to the upper layer. default is the number of bytes passed in receive_vec
    │ │ │ │  packet_size is set to the minimum number of bytes which must be read to advance
    │ │ │ │  the next step of decryption. default is 0
    │ │ │ │  [_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -************ ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee ************
    │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_._h_p_p"
    │ │ │ │ -the _p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e class provides a handle to the internal peer
    │ │ │ │ -connection object, to be used by plugins. This is a low level interface that
    │ │ │ │ -may not be stable across libtorrent versions
    │ │ │ │ -struct peer_connection_handle
    │ │ │ │ -{
    │ │ │ │ -   explicit ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (std::weak_ptr impl);
    │ │ │ │ -   connection_type ttyyppee () const;
    │ │ │ │ -   peer_plugin const* ffiinndd__pplluuggiinn (string_view type) const;
    │ │ │ │ -   void aadddd__eexxtteennssiioonn (std::shared_ptr);
    │ │ │ │ -   bool iiss__sseeeedd () const;
    │ │ │ │ -   bool uuppllooaadd__oonnllyy () const;
    │ │ │ │ -   peer_id const& ppiidd () const;
    │ │ │ │ -   bool hhaass__ppiieeccee (piece_index_t i) const;
    │ │ │ │ -   bool iiss__cchhookkeedd () const;
    │ │ │ │ -   bool iiss__iinntteerreessttiinngg () const;
    │ │ │ │ -   bool iiss__ppeeeerr__iinntteerreesstteedd () const;
    │ │ │ │ -   bool hhaass__ppeeeerr__cchhookkeedd () const;
    │ │ │ │ -   void cchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ -   void mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ -   void ggeett__ppeeeerr__iinnffoo (peer_info& p) const;
    │ │ │ │ -   torrent_handle aassssoocciiaatteedd__ttoorrrreenntt () const;
    │ │ │ │ -   _t_c_p_:_:_e_n_d_p_o_i_n_t const& rreemmoottee () const;
    │ │ │ │ -   _t_c_p_:_:_e_n_d_p_o_i_n_t llooccaall__eennddppooiinntt () const;
    │ │ │ │ -   bool iiss__ddiissccoonnnneeccttiinngg () const;
    │ │ │ │ -   void ddiissccoonnnneecctt (error_code const& ec, operation_t op
    │ │ │ │ -      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ │ -   bool iiss__ccoonnnneeccttiinngg () const;
    │ │ │ │ -   bool iiss__oouuttggooiinngg () const;
    │ │ │ │ -   bool oonn__llooccaall__nneettwwoorrkk () const;
    │ │ │ │ -   bool iiggnnoorree__uunncchhookkee__sslloottss () const;
    │ │ │ │ -   bool ffaaiilleedd () const;
    │ │ │ │ -   void ppeeeerr__lloogg (peer_log_alert::direction_t direction
    │ │ │ │ -      , peer_log_alert::event_t event, char const* fmt = "", ...) const
    │ │ │ │ -TORRENT_FORMAT(4,5);
    │ │ │ │ -   bool sshhoouulldd__lloogg (peer_log_alert::direction_t direction) const;
    │ │ │ │ -   bool ccaann__ddiissccoonnnneecctt (error_code const& ec) const;
    │ │ │ │ -   bool hhaass__mmeettaaddaattaa () const;
    │ │ │ │ -   bool iinn__hhaannddsshhaakkee () const;
    │ │ │ │ -   void sseenndd__bbuuffffeerr (char const* begin, int size);
    │ │ │ │ -   time_point ttiimmee__ooff__llaasstt__uunncchhookkee () const;
    │ │ │ │ -   std::time_t llaasstt__sseeeenn__ccoommpplleettee () const;
    │ │ │ │ -   bool ooppeerraattoorr<< (peer_connection_handle const& o) const;
    │ │ │ │ -   bool ooppeerraattoorr==== (peer_connection_handle const& o) const;
    │ │ │ │ -   bool ooppeerraattoorr!!== (peer_connection_handle const& o) const;
    │ │ │ │ -   std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ -};
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee(()) **********
    │ │ │ │ -explicit ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (std::weak_ptr impl);
    │ │ │ │ -construct a handle wrapping the given internal peer_connection. Typically
    │ │ │ │ -created by libtorrent and passed to plugins; not intended to be constructed by
    │ │ │ │ -user code.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ttyyppee(()) **********
    │ │ │ │ -connection_type ttyyppee () const;
    │ │ │ │ -the protocol type of this connection (bittorrent, url_seed, http_seed)
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** aadddd__eexxtteennssiioonn(()) ffiinndd__pplluuggiinn(()) **********
    │ │ │ │ -peer_plugin const* ffiinndd__pplluuggiinn (string_view type) const;
    │ │ │ │ -void aadddd__eexxtteennssiioonn (std::shared_ptr);
    │ │ │ │ -attach a _p_e_e_r___p_l_u_g_i_n to this connection. find_plugin() looks up an attached
    │ │ │ │ -_p_l_u_g_i_n by its type() string and returns nullptr if none is registered.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** iiss__sseeeedd(()) **********
    │ │ │ │ -bool iiss__sseeeedd () const;
    │ │ │ │ -returns true if the remote peer is a seed
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** uuppllooaadd__oonnllyy(()) **********
    │ │ │ │ -bool uuppllooaadd__oonnllyy () const;
    │ │ │ │ -returns true if the remote peer has indicated upload-only (it is a seed or has
    │ │ │ │ -chosen not to download anything more from us)
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ppiidd(()) hhaass__ppiieeccee(()) **********
    │ │ │ │ -peer_id const& ppiidd () const;
    │ │ │ │ -bool hhaass__ppiieeccee (piece_index_t i) const;
    │ │ │ │ -the peer id reported by the remote during handshake. has_piece(i) returns true
    │ │ │ │ -if the remote peer has piece i.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** iiss__iinntteerreessttiinngg(()) iiss__cchhookkeedd(()) **********
    │ │ │ │ -bool iiss__cchhookkeedd () const;
    │ │ │ │ -bool iiss__iinntteerreessttiinngg () const;
    │ │ │ │ -_i_s___i_n_t_e_r_e_s_t_i_n_g_(_) returns true if we are interested in the peer (it has pieces
    │ │ │ │ -we want). _i_s___c_h_o_k_e_d_(_) returns true if we have choked the peer (we are not
    │ │ │ │ -currently sending data to it).
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** iiss__ppeeeerr__iinntteerreesstteedd(()) hhaass__ppeeeerr__cchhookkeedd(()) **********
    │ │ │ │ -bool iiss__ppeeeerr__iinntteerreesstteedd () const;
    │ │ │ │ -bool hhaass__ppeeeerr__cchhookkeedd () const;
    │ │ │ │ -_i_s___p_e_e_r___i_n_t_e_r_e_s_t_e_d_(_) returns true if the peer has indicated it is interested in
    │ │ │ │ -us. _h_a_s___p_e_e_r___c_h_o_k_e_d_(_) returns true if the peer is choking us.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr(()) cchhookkee__tthhiiss__ppeeeerr(()) **********
    │ │ │ │ -void cchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ -void mmaayybbee__uunncchhookkee__tthhiiss__ppeeeerr ();
    │ │ │ │ -choke or possibly unchoke this peer immediately, bypassing the regular unchoke
    │ │ │ │ -selection. maybe_unchoke_this_peer() only unchokes if there is an unchoke slot
    │ │ │ │ -available.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ggeett__ppeeeerr__iinnffoo(()) **********
    │ │ │ │ -void ggeett__ppeeeerr__iinnffoo (peer_info& p) const;
    │ │ │ │ -fills in p with statistics and state for this connection, equivalent to the
    │ │ │ │ -corresponding _e_n_t_r_y returned by _t_o_r_r_e_n_t___h_a_n_d_l_e_:_:_g_e_t___p_e_e_r___i_n_f_o_(_).
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** aassssoocciiaatteedd__ttoorrrreenntt(()) **********
    │ │ │ │ -torrent_handle aassssoocciiaatteedd__ttoorrrreenntt () const;
    │ │ │ │ -the torrent this peer is associated with. Returns an invalid handle if the peer
    │ │ │ │ -is not yet associated with a torrent.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** llooccaall__eennddppooiinntt(()) rreemmoottee(()) **********
    │ │ │ │ -_t_c_p_:_:_e_n_d_p_o_i_n_t const& rreemmoottee () const;
    │ │ │ │ -_t_c_p_:_:_e_n_d_p_o_i_n_t llooccaall__eennddppooiinntt () const;
    │ │ │ │ -the remote peer's address and port, and the local endpoint of the socket on our
    │ │ │ │ -side.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** iiss__oouuttggooiinngg(()) iiss__ccoonnnneeccttiinngg(()) ddiissccoonnnneecctt(()) iiss__ddiissccoonnnneeccttiinngg(()) **********
    │ │ │ │ -bool iiss__ddiissccoonnnneeccttiinngg () const;
    │ │ │ │ -void ddiissccoonnnneecctt (error_code const& ec, operation_t op
    │ │ │ │ -      , disconnect_severity_t = peer_connection_interface::normal);
    │ │ │ │ -bool iiss__ccoonnnneeccttiinngg () const;
    │ │ │ │ -bool iiss__oouuttggooiinngg () const;
    │ │ │ │ -drop the connection with the given error code and operation type. The
    │ │ │ │ -disconnect is asynchronous; is_disconnecting() becomes true immediately and the
    │ │ │ │ -actual socket close happens later. is_connecting() reports whether the outgoing
    │ │ │ │ -socket is still in the connect phase; is_outgoing() whether the connection was
    │ │ │ │ -initiated by us.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** oonn__llooccaall__nneettwwoorrkk(()) iiggnnoorree__uunncchhookkee__sslloottss(()) **********
    │ │ │ │ -bool oonn__llooccaall__nneettwwoorrkk () const;
    │ │ │ │ -bool iiggnnoorree__uunncchhookkee__sslloottss () const;
    │ │ │ │ -returns true if the peer's address is on the same local network as us.
    │ │ │ │ -ignore_unchoke_slots() returns true if this peer is excluded from regular
    │ │ │ │ -unchoke slot accounting.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ffaaiilleedd(()) **********
    │ │ │ │ -bool ffaaiilleedd () const;
    │ │ │ │ -returns true if the connection has been closed because of an error (rather than
    │ │ │ │ -because of a normal disconnect)
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** sshhoouulldd__lloogg(()) ppeeeerr__lloogg(()) **********
    │ │ │ │ -void ppeeeerr__lloogg (peer_log_alert::direction_t direction
    │ │ │ │ -      , peer_log_alert::event_t event, char const* fmt = "", ...) const
    │ │ │ │ -TORRENT_FORMAT(4,5);
    │ │ │ │ -bool sshhoouulldd__lloogg (peer_log_alert::direction_t direction) const;
    │ │ │ │ -_s_h_o_u_l_d___l_o_g_(_) returns true if peer logging is enabled in the given direction.
    │ │ │ │ -_p_e_e_r___l_o_g_(_) emits a peer_log_alert for this connection, with printf-style
    │ │ │ │ -formatting.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ccaann__ddiissccoonnnneecctt(()) **********
    │ │ │ │ -bool ccaann__ddiissccoonnnneecctt (error_code const& ec) const;
    │ │ │ │ -returns true if a disconnect with error ec would be permitted at this point
    │ │ │ │ -(some errors are suppressed during startup).
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** hhaass__mmeettaaddaattaa(()) **********
    │ │ │ │ -bool hhaass__mmeettaaddaattaa () const;
    │ │ │ │ -returns true if we have received the metadata (info dict) for this torrent from
    │ │ │ │ -the peer or otherwise
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** iinn__hhaannddsshhaakkee(()) **********
    │ │ │ │ -bool iinn__hhaannddsshhaakkee () const;
    │ │ │ │ -returns true if the connection is still in the BitTorrent handshake phase
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** sseenndd__bbuuffffeerr(()) **********
    │ │ │ │ -void sseenndd__bbuuffffeerr (char const* begin, int size);
    │ │ │ │ -queue size bytes of data to be sent to the peer. The data is copied; the buffer
    │ │ │ │ -does not need to outlive the call.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** llaasstt__sseeeenn__ccoommpplleettee(()) ttiimmee__ooff__llaasstt__uunncchhookkee(()) **********
    │ │ │ │ -time_point ttiimmee__ooff__llaasstt__uunncchhookkee () const;
    │ │ │ │ -std::time_t llaasstt__sseeeenn__ccoommpplleettee () const;
    │ │ │ │ -the most recent time_of_completion reported by the peer (BEP 21), and the wall-
    │ │ │ │ -clock time when we last unchoked it.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** nnaattiivvee__hhaannddllee(()) **********
    │ │ │ │ -std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ -returns a shared_ptr to the underlying peer_connection. The pointer may be null
    │ │ │ │ -if the connection has already been destroyed.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -************ bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee ************
    │ │ │ │ -Declared in "_l_i_b_t_o_r_r_e_n_t_/_p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e_._h_p_p"
    │ │ │ │ -The _b_t___p_e_e_r___c_o_n_n_e_c_t_i_o_n___h_a_n_d_l_e provides a handle to the internal bittorrent peer
    │ │ │ │ -connection object to plugins. It's low level and may not be a stable API across
    │ │ │ │ -libtorrent versions.
    │ │ │ │ -struct bt_peer_connection_handle : peer_connection_handle
    │ │ │ │ -{
    │ │ │ │ -   explicit bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (peer_connection_handle pc);
    │ │ │ │ -   bool ppaacckkeett__ffiinniisshheedd () const;
    │ │ │ │ -   bool ssuuppppoorrtt__eexxtteennssiioonnss () const;
    │ │ │ │ -   bool ssuuppppoorrttss__eennccrryyppttiioonn () const;
    │ │ │ │ -   void sswwiittcchh__rreeccvv__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ -   void sswwiittcchh__sseenndd__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ -   std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ -};
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee(()) **********
    │ │ │ │ -explicit bbtt__ppeeeerr__ccoonnnneeccttiioonn__hhaannddllee (peer_connection_handle pc);
    │ │ │ │ -construct from a generic peer_connection_handle. Behavior is undefined if the
    │ │ │ │ -underlying connection is not actually a bittorrent peer connection.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ppaacckkeett__ffiinniisshheedd(()) ssuuppppoorrtt__eexxtteennssiioonnss(()) **********
    │ │ │ │ -bool ppaacckkeett__ffiinniisshheedd () const;
    │ │ │ │ -bool ssuuppppoorrtt__eexxtteennssiioonnss () const;
    │ │ │ │ -_p_a_c_k_e_t___f_i_n_i_s_h_e_d_(_) returns true if the receive buffer holds a complete
    │ │ │ │ -BitTorrent message. _s_u_p_p_o_r_t___e_x_t_e_n_s_i_o_n_s_(_) returns true if the remote peer
    │ │ │ │ -announced support for the LTEP extension protocol (BEP 10).
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** ssuuppppoorrttss__eennccrryyppttiioonn(()) **********
    │ │ │ │ -bool ssuuppppoorrttss__eennccrryyppttiioonn () const;
    │ │ │ │ -returns true if MSE (Message Stream Encryption) is in use on this connection
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** sswwiittcchh__rreeccvv__ccrryyppttoo(()) sswwiittcchh__sseenndd__ccrryyppttoo(()) **********
    │ │ │ │ -void sswwiittcchh__rreeccvv__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ -void sswwiittcchh__sseenndd__ccrryyppttoo (std::shared_ptr crypto);
    │ │ │ │ -install a custom crypto_plugin on the send or receive path. Used to inject MSE
    │ │ │ │ -/ PE-style stream cipher into the peer connection.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │ -********** nnaattiivvee__hhaannddllee(()) **********
    │ │ │ │ -std::shared_ptr nnaattiivvee__hhaannddllee () const;
    │ │ │ │ -returns a shared_ptr to the underlying bt_peer_connection. May be null if the
    │ │ │ │ -connection has been destroyed.
    │ │ │ │ -[_r_e_p_o_r_t_ _i_s_s_u_e]
    │ │ │ │  ************ ccrreeaattee__uutt__ppeexx__pplluuggiinn(()) ************
    │ │ │ │  Declared in "_l_i_b_t_o_r_r_e_n_t_/_e_x_t_e_n_s_i_o_n_s_/_u_t___p_e_x_._h_p_p"
    │ │ │ │  std::shared_ptr ccrreeaattee__uutt__ppeexx__pplluuggiinn (torrent_handle const&,
    │ │ │ │  client_data_t);
    │ │ │ │  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
    │ │ ├── ./usr/share/doc/libtorrent-rasterbar-doc/html/reference-Resume_Data.html
    │ │ │┄ Ordering differences only
    │ │ │ @@ -38,22 +38,22 @@
    │ │ │  
  • write_torrent_flags_t
  • │ │ │ │ │ │
    │ │ │ [report issue]
    │ │ │

    read_resume_data()

    │ │ │

    Declared in "libtorrent/read_resume_data.hpp"

    │ │ │
    │ │ │ +add_torrent_params read_resume_data (bdecode_node const& rd
    │ │ │ +   , error_code& ec, int piece_limit = 0x200000);
    │ │ │  add_torrent_params read_resume_data (span<char const> buffer
    │ │ │     , load_torrent_limits const& cfg = {});
    │ │ │ -add_torrent_params read_resume_data (bdecode_node const& rd
    │ │ │ -   , int piece_limit = 0x200000);
    │ │ │  add_torrent_params read_resume_data (span<char const> buffer
    │ │ │     , error_code& ec, load_torrent_limits const& cfg = {});
    │ │ │  add_torrent_params read_resume_data (bdecode_node const& rd
    │ │ │ -   , error_code& ec, int piece_limit = 0x200000);
    │ │ │ +   , int piece_limit = 0x200000);
    │ │ │  
    │ │ │

    these functions are used to parse resume data and populate the appropriate │ │ │ fields in an add_torrent_params object. This object can then be used to add │ │ │ the actual torrent_info object to and pass to session::add_torrent() or │ │ │ session::async_add_torrent().

    │ │ │

    If the client wants to override any field that was loaded from the resume │ │ │ data, e.g. save_path, those fields must be changed after loading resume │ │ │ @@ -86,29 +86,29 @@ │ │ │

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

    write_resume_data_buf() write_resume_data()

    │ │ │

    Declared in "libtorrent/write_resume_data.hpp"

    │ │ │
    │ │ │ -std::vector<char> write_resume_data_buf (add_torrent_params const& atp);
    │ │ │  entry write_resume_data (add_torrent_params const& atp);
    │ │ │ +std::vector<char> write_resume_data_buf (add_torrent_params const& atp);
    │ │ │  
    │ │ │

    this function turns the resume data in an add_torrent_params object │ │ │ into a bencoded structure

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

    write_torrent_file() write_torrent_file_buf()

    │ │ │

    Declared in "libtorrent/write_resume_data.hpp"

    │ │ │
    │ │ │ -entry write_torrent_file (add_torrent_params const& atp);
    │ │ │  entry write_torrent_file (add_torrent_params const& atp, write_torrent_flags_t flags);
    │ │ │  std::vector<char> write_torrent_file_buf (add_torrent_params const& atp
    │ │ │     , write_torrent_flags_t flags);
    │ │ │ +entry write_torrent_file (add_torrent_params const& atp);
    │ │ │  
    │ │ │

    writes only the fields to create a .torrent file. This function may fail │ │ │ with a std::system_error exception if:

    │ │ │
    │ │ │ │ │ │
    │ │ │

    read_session_params() write_session_params_buf() write_session_params()

    │ │ │

    Declared in "libtorrent/session_params.hpp"

    │ │ │
    │ │ │ -entry write_session_params (session_params const& sp
    │ │ │ +session_params read_session_params (bdecode_node const& e
    │ │ │     , save_state_flags_t flags = save_state_flags_t::all());
    │ │ │  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 (span<char const> buf
    │ │ │ +entry write_session_params (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 {} │ │ │ │ @@ -3,96 +3,96 @@ │ │ │ │ VVeerrssiioonn:: 2.1.2 │ │ │ │ _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 _~_s_e_s_s_i_o_n___p_r_o_x_y_(_)_ _s_e_s_s_i_o_n___p_r_o_x_y_(_)_ _o_p_e_r_a_t_o_r_=_(_) │ │ │ │ + o _s_e_s_s_i_o_n___p_r_o_x_y_(_)_ _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 │ │ │ │ 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 _g_e_t___t_o_r_r_e_n_t___s_t_a_t_u_s_(_)_ _r_e_f_r_e_s_h___t_o_r_r_e_n_t___s_t_a_t_u_s_(_) │ │ │ │ + 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 _g_e_t___t_o_r_r_e_n_t_s_(_)_ _f_i_n_d___t_o_r_r_e_n_t_(_) │ │ │ │ - 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 _f_i_n_d___t_o_r_r_e_n_t_(_)_ _g_e_t___t_o_r_r_e_n_t_s_(_) │ │ │ │ + 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 _i_s___p_a_u_s_e_d_(_)_ _p_a_u_s_e_(_)_ _r_e_s_u_m_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 _i_s___l_i_s_t_e_n_i_n_g_(_)_ _l_i_s_t_e_n___p_o_r_t_(_)_ _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 _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 _s_e_t___p_e_e_r___c_l_a_s_s___f_i_l_t_e_r_(_)_ _g_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 _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 _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 _r_e_m_o_v_e___t_o_r_r_e_n_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 _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_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_(_) │ │ │ │ * _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 (); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack&& sp); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack const& sp); │ │ │ │ - sseessssiioonn__ppaarraammss (settings_pack&& sp │ │ │ │ - , std::vector> exts); │ │ │ │ + sseessssiioonn__ppaarraammss (); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack const& sp │ │ │ │ , std::vector> exts); │ │ │ │ + sseessssiioonn__ppaarraammss (settings_pack&& sp │ │ │ │ + , std::vector> exts); │ │ │ │ │ │ │ │ settings_pack settings; │ │ │ │ session_flags_t ffllaaggss {}; │ │ │ │ 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 (); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack&& sp); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack const& sp); │ │ │ │ +sseessssiioonn__ppaarraammss (); │ │ │ │ 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&& sp │ │ │ │ - , std::vector> exts); │ │ │ │ sseessssiioonn__ppaarraammss (settings_pack const& sp │ │ │ │ , std::vector> exts); │ │ │ │ +sseessssiioonn__ppaarraammss (settings_pack&& 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] │ │ │ │ flags │ │ │ │ @@ -136,29 +136,29 @@ │ │ │ │ _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&&) noexcept; │ │ │ │ - session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ - ~~sseessssiioonn__pprrooxxyy (); │ │ │ │ session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ - sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ + ~~sseessssiioonn__pprrooxxyy (); │ │ │ │ sseessssiioonn__pprrooxxyy (); │ │ │ │ + sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ + sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ + session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ~~sseessssiioonn__pprrooxxyy(()) sseessssiioonn__pprrooxxyy(()) ooppeerraattoorr==(()) ********** │ │ │ │ -sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ -session_proxy& ooppeerraattoorr== (session_proxy const&) &; │ │ │ │ -~~sseessssiioonn__pprrooxxyy (); │ │ │ │ +********** sseessssiioonn__pprrooxxyy(()) ooppeerraattoorr==(()) ~~sseessssiioonn__pprrooxxyy(()) ********** │ │ │ │ session_proxy& ooppeerraattoorr== (session_proxy&&) & noexcept; │ │ │ │ -sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ +~~sseessssiioonn__pprrooxxyy (); │ │ │ │ sseessssiioonn__pprrooxxyy (); │ │ │ │ +sseessssiioonn__pprrooxxyy (session_proxy&&) noexcept; │ │ │ │ +sseessssiioonn__pprrooxxyy (session_proxy const&); │ │ │ │ +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 │ │ │ │ @@ -166,26 +166,26 @@ │ │ │ │ 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 (); │ │ │ │ explicit sseessssiioonn (session_params&& params); │ │ │ │ + sseessssiioonn (); │ │ │ │ explicit sseessssiioonn (session_params const& params); │ │ │ │ sseessssiioonn (session_params const& params, io_context& ios); │ │ │ │ sseessssiioonn (session_params&& params, io_context& ios); │ │ │ │ ~~sseessssiioonn (); │ │ │ │ session_proxy aabboorrtt (); │ │ │ │ }; │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** sseessssiioonn(()) ********** │ │ │ │ -sseessssiioonn (); │ │ │ │ explicit sseessssiioonn (session_params&& params); │ │ │ │ +sseessssiioonn (); │ │ │ │ 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. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ ********** sseessssiioonn(()) ********** │ │ │ │ @@ -244,27 +244,27 @@ │ │ │ │ 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); │ │ │ │ - torrent_handle ffiinndd__ttoorrrreenntt (sha256_hash const& info_hash) const; │ │ │ │ torrent_handle ffiinndd__ttoorrrreenntt (sha1_hash const& info_hash) const; │ │ │ │ std::vector ggeett__ttoorrrreennttss () const; │ │ │ │ + torrent_handle ffiinndd__ttoorrrreenntt (sha256_hash const& info_hash) const; │ │ │ │ + torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params, error_code& │ │ │ │ +ec); │ │ │ │ + torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& 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); │ │ │ │ void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ - torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params, error_code& ec); │ │ │ │ - torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params, error_code& │ │ │ │ -ec); │ │ │ │ - void ppaauussee (); │ │ │ │ - void rreessuummee (); │ │ │ │ bool iiss__ppaauusseedd () const; │ │ │ │ + void rreessuummee (); │ │ │ │ + void ppaauussee (); │ │ │ │ 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); │ │ │ │ @@ -279,38 +279,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); │ │ │ │ - bool iiss__lliisstteenniinngg () const; │ │ │ │ - unsigned short ssssll__lliisstteenn__ppoorrtt () const; │ │ │ │ unsigned short lliisstteenn__ppoorrtt () const; │ │ │ │ - void sseett__ppeeeerr__ccllaassss__ffiilltteerr (ip_filter const& f); │ │ │ │ + unsigned short ssssll__lliisstteenn__ppoorrtt () const; │ │ │ │ + bool iiss__lliisstteenniinngg () 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); │ │ │ │ peer_class_type_filter ggeett__ppeeeerr__ccllaassss__ttyyppee__ffiilltteerr () const; │ │ │ │ peer_class_t ccrreeaattee__ppeeeerr__ccllaassss (char const* name); │ │ │ │ void ddeelleettee__ppeeeerr__ccllaassss (peer_class_t cid); │ │ │ │ - peer_class_info ggeett__ppeeeerr__ccllaassss (peer_class_t cid) const; │ │ │ │ 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 rreemmoovvee__ttoorrrreenntt (const torrent_handle&, remove_flags_t = {}); │ │ │ │ void aappppllyy__sseettttiinnggss (settings_pack&&); │ │ │ │ - void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ settings_pack ggeett__sseettttiinnggss () const; │ │ │ │ - bool wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ - void ppoopp__aalleerrttss (std::vector* alerts); │ │ │ │ + void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ void sseett__aalleerrtt__nnoottiiffyy (std::function const& fun); │ │ │ │ - void ddeelleettee__ppoorrtt__mmaappppiinngg (port_mapping_t handle); │ │ │ │ + void ppoopp__aalleerrttss (std::vector* alerts); │ │ │ │ + bool wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ 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 inline constexpr save_state_flags_t ssaavvee__sseettttiinnggss = 0_bit; │ │ │ │ static inline constexpr save_state_flags_t ssaavvee__ddhhtt__ssttaattee = 2_bit; │ │ │ │ static inline constexpr save_state_flags_t ssaavvee__eexxtteennssiioonn__ssttaattee = 11_bit; │ │ │ │ @@ -336,15 +336,15 @@ │ │ │ │ all()) const; │ │ │ │ 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] │ │ │ │ -********** ggeett__ttoorrrreenntt__ssttaattuuss(()) rreeffrreesshh__ttoorrrreenntt__ssttaattuuss(()) ********** │ │ │ │ +********** rreeffrreesshh__ttoorrrreenntt__ssttaattuuss(()) ggeett__ttoorrrreenntt__ssttaattuuss(()) ********** │ │ │ │ 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 │ │ │ │ @@ -400,32 +400,32 @@ │ │ │ │ ********** 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] │ │ │ │ -********** ggeett__ttoorrrreennttss(()) ffiinndd__ttoorrrreenntt(()) ********** │ │ │ │ -torrent_handle ffiinndd__ttoorrrreenntt (sha256_hash const& info_hash) const; │ │ │ │ +********** ffiinndd__ttoorrrreenntt(()) ggeett__ttoorrrreennttss(()) ********** │ │ │ │ torrent_handle ffiinndd__ttoorrrreenntt (sha1_hash const& info_hash) const; │ │ │ │ std::vector ggeett__ttoorrrreennttss () const; │ │ │ │ +torrent_handle ffiinndd__ttoorrrreenntt (sha256_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(()) ********** │ │ │ │ +********** aadddd__ttoorrrreenntt(()) aassyynncc__aadddd__ttoorrrreenntt(()) ********** │ │ │ │ +torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& params, error_code& ec); │ │ │ │ +torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& 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); │ │ │ │ void aassyynncc__aadddd__ttoorrrreenntt (add_torrent_params&& params); │ │ │ │ -torrent_handle aadddd__ttoorrrreenntt (add_torrent_params&& params, error_code& ec); │ │ │ │ -torrent_handle aadddd__ttoorrrreenntt (add_torrent_params const& 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. │ │ │ │ The save_path field in _a_d_d___t_o_r_r_e_n_t___p_a_r_a_m_s must be set to a valid path where the │ │ │ │ @@ -447,17 +447,17 @@ │ │ │ │ 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] │ │ │ │ ********** iiss__ppaauusseedd(()) ppaauussee(()) rreessuummee(()) ********** │ │ │ │ -void ppaauussee (); │ │ │ │ -void rreessuummee (); │ │ │ │ bool iiss__ppaauusseedd () const; │ │ │ │ +void rreessuummee (); │ │ │ │ +void ppaauussee (); │ │ │ │ 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. is_paused() returns true if the _s_e_s_s_i_o_n is │ │ │ │ currently paused. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ @@ -604,17 +604,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. │ │ │ │ @@ -622,29 +622,29 @@ │ │ │ │ ********** sseett__ppoorrtt__ffiilltteerr(()) ********** │ │ │ │ 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] │ │ │ │ -********** iiss__lliisstteenniinngg(()) lliisstteenn__ppoorrtt(()) ssssll__lliisstteenn__ppoorrtt(()) ********** │ │ │ │ -bool iiss__lliisstteenniinngg () const; │ │ │ │ -unsigned short ssssll__lliisstteenn__ppoorrtt () const; │ │ │ │ +********** lliisstteenn__ppoorrtt(()) iiss__lliisstteenniinngg(()) ssssll__lliisstteenn__ppoorrtt(()) ********** │ │ │ │ unsigned short lliisstteenn__ppoorrtt () const; │ │ │ │ +unsigned short ssssll__lliisstteenn__ppoorrtt () const; │ │ │ │ +bool iiss__lliisstteenniinngg () 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. │ │ │ │ ssl_listen_port() returns the port used for incoming SSL connections, or 0 if │ │ │ │ no SSL listen port is open. │ │ │ │ [_r_e_p_o_r_t_ _i_s_s_u_e] │ │ │ │ -********** ggeett__ppeeeerr__ccllaassss__ffiilltteerr(()) sseett__ppeeeerr__ccllaassss__ffiilltteerr(()) ********** │ │ │ │ -void sseett__ppeeeerr__ccllaassss__ffiilltteerr (ip_filter const& f); │ │ │ │ +********** sseett__ppeeeerr__ccllaassss__ffiilltteerr(()) ggeett__ppeeeerr__ccllaassss__ffiilltteerr(()) ********** │ │ │ │ ip_filter ggeett__ppeeeerr__ccllaassss__ffiilltteerr () const; │ │ │ │ +void sseett__ppeeeerr__ccllaassss__ffiilltteerr (ip_filter const& f); │ │ │ │ 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. │ │ │ │ @@ -699,17 +699,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] │ │ │ │ -********** sseett__ppeeeerr__ccllaassss(()) ggeett__ppeeeerr__ccllaassss(()) ********** │ │ │ │ -peer_class_info ggeett__ppeeeerr__ccllaassss (peer_class_t cid) const; │ │ │ │ +********** ggeett__ppeeeerr__ccllaassss(()) sseett__ppeeeerr__ccllaassss(()) ********** │ │ │ │ void sseett__ppeeeerr__ccllaassss (peer_class_t cid, peer_class_info const& pci); │ │ │ │ +peer_class_info ggeett__ppeeeerr__ccllaassss (peer_class_t cid) const; │ │ │ │ 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 │ │ │ │ @@ -741,24 +741,24 @@ │ │ │ │ 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] │ │ │ │ ********** aappppllyy__sseettttiinnggss(()) ggeett__sseettttiinnggss(()) ********** │ │ │ │ void aappppllyy__sseettttiinnggss (settings_pack&&); │ │ │ │ -void aappppllyy__sseettttiinnggss (settings_pack const&); │ │ │ │ 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] │ │ │ │ -********** wwaaiitt__ffoorr__aalleerrtt(()) ppoopp__aalleerrttss(()) sseett__aalleerrtt__nnoottiiffyy(()) ********** │ │ │ │ -bool wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ -void ppoopp__aalleerrttss (std::vector* alerts); │ │ │ │ +********** ppoopp__aalleerrttss(()) sseett__aalleerrtt__nnoottiiffyy(()) wwaaiitt__ffoorr__aalleerrtt(()) ********** │ │ │ │ void sseett__aalleerrtt__nnoottiiffyy (std::function const& fun); │ │ │ │ +void ppoopp__aalleerrttss (std::vector* alerts); │ │ │ │ +bool wwaaiitt__ffoorr__aalleerrtt (time_duration max_wait); │ │ │ │ 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. │ │ │ │ @@ -799,17 +799,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 = │ │ │ │ @@ -858,21 +858,21 @@ │ │ │ │ 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] │ │ │ │ ************ 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" │ │ │ │ -entry wwrriittee__sseessssiioonn__ppaarraammss (session_params const& sp │ │ │ │ +session_params rreeaadd__sseessssiioonn__ppaarraammss (bdecode_node const& e │ │ │ │ , save_state_flags_t flags = save_state_flags_t::all()); │ │ │ │ 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 (span buf │ │ │ │ +entry wwrriittee__sseessssiioonn__ppaarraammss (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,35 +29,35 @@ │ │ │ │ │ │ │ │ │

    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 │ │ │ to the session when passed to session::apply_settings(). It's empty when │ │ │ @@ -4891,23 +4891,23 @@ │ │ │

    the maximum number of WebRTC offers generated and advertised │ │ │ per WebTorrent tracker announce. It also limits the number of │ │ │ concurrent incoming WebRTC negotiations per torrent. Set this │ │ │ to 0 to disable WebTorrent offers.

    │ │ │
    │ │ │  struct settings_pack final : settings_interface
    │ │ │  {
    │ │ │ +   void set_str (int name, std::string val) override;
    │ │ │     void set_int (int name, int val) override;
    │ │ │     void set_bool (int name, bool val) override;
    │ │ │ -   void set_str (int name, std::string 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,
    │ │ │ @@ -4977,21 +4977,21 @@
    │ │ │        socks5_pw,
    │ │ │        http,
    │ │ │        http_pw,
    │ │ │     };
    │ │ │  };
    │ │ │  
    │ │ │ │ │ │ - │ │ │ -[report issue]
    │ │ │ -

    set_int() set_str() set_bool()

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

    set_int() set_bool() set_str()

    │ │ │
    │ │ │ +void set_str (int name, std::string val) override;
    │ │ │  void set_int (int name, int val) override;
    │ │ │  void set_bool (int name, bool val) override;
    │ │ │ -void set_str (int name, std::string 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]
    │ │ │
    │ │ │

    has_val()

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

    clear()

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

    clear a specific setting from the pack

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

    get_int() get_bool() get_str()

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

    get_bool() get_int() get_str()

    │ │ │
    │ │ │ +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]
    │ │ │ @@ -5387,16 +5387,64 @@ │ │ │ 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]
    │ │ │ │ │ │ +
    │ │ │ +

    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);
    │ │ │ +
    │ │ │ +

    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]
    │ │ │ +
    │ │ │ +

    min_memory_usage() high_performance_seed()

    │ │ │ +

    Declared in "libtorrent/session.hpp"

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

    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 │ │ │ +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 that each connection only has at most one block in │ │ │ +use at any one time. It lowers the outstanding blocks send to the disk │ │ │ +I/O thread so that connections only have one block waiting to be flushed │ │ │ +to disk at any given time. It lowers the max number of peers in the peer │ │ │ +list for torrents. It performs multiple smaller reads when it hashes │ │ │ +pieces, instead of reading it all into memory before hashing.

    │ │ │ +

    This configuration is intended to be the starting point for embedded │ │ │ +devices. It will significantly reduce memory usage.

    │ │ │ +

    high_performance_seed returns settings optimized for a seed box, │ │ │ +serving many peers and that doesn't do any downloading. It has a 128 MB │ │ │ +disk cache and has a limit of 400 files in its file pool. It support fast │ │ │ +upload rates by allowing large send buffers.

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

    generate_fingerprint()

    │ │ │

    Declared in "libtorrent/fingerprint.hpp"

    │ │ │
    │ │ │  std::string generate_fingerprint (std::string name
    │ │ │     , int major, int minor = 0, int revision = 0, int tag = 0);
    │ │ │  
    │ │ │ @@ -5445,62 +5493,14 @@ │ │ │ Tribler │ │ │ │ │ │ │ │ │ │ │ │

    There's an informal directory of client id's here.

    │ │ │

    The major, minor, revision and tag parameters are used to │ │ │ identify the version of your client.

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

    min_memory_usage() high_performance_seed()

    │ │ │ -

    Declared in "libtorrent/session.hpp"

    │ │ │ -
    │ │ │ -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 │ │ │ -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 that each connection only has at most one block in │ │ │ -use at any one time. It lowers the outstanding blocks send to the disk │ │ │ -I/O thread so that connections only have one block waiting to be flushed │ │ │ -to disk at any given time. It lowers the max number of peers in the peer │ │ │ -list for torrents. It performs multiple smaller reads when it hashes │ │ │ -pieces, instead of reading it all into memory before hashing.

    │ │ │ -

    This configuration is intended to be the starting point for embedded │ │ │ -devices. It will significantly reduce memory usage.

    │ │ │ -

    high_performance_seed returns settings optimized for a seed box, │ │ │ -serving many peers and that doesn't do any downloading. It has a 128 MB │ │ │ -disk cache and has a limit of 400 files in its file pool. It support fast │ │ │ -upload rates by allowing large send buffers.

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

    setting_by_name() name_for_setting()

    │ │ │ -

    Declared in "libtorrent/settings_pack.hpp"

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

    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

    │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │
    │ │ │
    │ │ │ .}...b │ │ │ -000579a0: 6f6f 6c20 7065 6572 5f63 6f6e 6e65 6374 ool peer_connect │ │ │ -000579b0: 696f 6e3a 3a63 616e 5f72 6571 7565 7374 ion::can_request │ │ │ -000579c0: 5f74 696d 655f 6372 6974 6963 616c 2829 _time_critical() │ │ │ -000579d0: 2063 6f6e 7374 0a09 7b0a 0909 544f 5252 const..{...TORR │ │ │ -000579e0: 454e 545f 4153 5345 5254 2869 735f 7369 ENT_ASSERT(is_si │ │ │ -000579f0: 6e67 6c65 5f74 6872 6561 6428 2929 3b0a ngle_thread());. │ │ │ -00057a00: 0909 6966 2028 6861 735f 7065 6572 5f63 ..if (has_peer_c │ │ │ -00057a10: 686f 6b65 6428 2920 7c7c 2021 6973 5f69 hoked() || !is_i │ │ │ -00057a20: 6e74 6572 6573 7469 6e67 2829 2920 7265 nteresting()) re │ │ │ -00057a30: 7475 726e 2066 616c 7365 3b0a 0909 6966 turn false;...if │ │ │ -00057a40: 2028 696e 7428 6d5f 646f 776e 6c6f 6164 (int(m_download │ │ │ -00057a50: 5f71 7565 7565 2e73 697a 6528 2929 202b _queue.size()) + │ │ │ -00057a60: 2069 6e74 286d 5f72 6571 7565 7374 5f71 int(m_request_q │ │ │ -00057a70: 7565 7565 2e73 697a 6528 2929 0a09 0909 ueue.size()).... │ │ │ -00057a80: 2667 743b 206d 5f64 6573 6972 6564 5f71 > m_desired_q │ │ │ -00057a90: 7565 7565 5f73 697a 6520 2a20 3229 2072 ueue_size * 2) r │ │ │ -00057aa0: 6574 7572 6e20 6661 6c73 653b 0a09 0969 eturn false;...i │ │ │ -00057ab0: 6620 286f 6e5f 7061 726f 6c65 2829 2920 f (on_parole()) │ │ │ -00057ac0: 7265 7475 726e 2066 616c 7365 3b0a 0909 return false;... │ │ │ -00057ad0: 6966 2028 6d5f 6469 7363 6f6e 6e65 6374 if (m_disconnect │ │ │ -00057ae0: 696e 6729 2072 6574 7572 6e20 6661 6c73 ing) return fals │ │ │ -00057af0: 653b 0a09 0961 7574 6f20 7420 3d20 6d5f e;...auto t = m_ │ │ │ -00057b00: 746f 7272 656e 742e 6c6f 636b 2829 3b0a torrent.lock();. │ │ │ -00057b10: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -00057b20: 2874 293b 0a09 0969 6620 2874 2d26 6774 (t);...if (t-> │ │ │ -00057b30: 3b75 706c 6f61 645f 6d6f 6465 2829 2920 ;upload_mode()) │ │ │ -00057b40: 7265 7475 726e 2066 616c 7365 3b0a 0a09 return false;... │ │ │ -00057b50: 092f 2f20 6967 6e6f 7265 2073 6e75 6262 .// ignore snubb │ │ │ -00057b60: 6564 2070 6565 7273 2c20 7369 6e63 6520 ed peers, since │ │ │ -00057b70: 7468 6579 2772 6520 6e6f 7420 6c69 6b65 they're not like │ │ │ -00057b80: 6c79 2074 6f20 7265 7475 726e 2070 6965 ly to return pie │ │ │ -00057b90: 6365 7320 696e 2061 0a09 092f 2f20 7469 ces in a...// ti │ │ │ -00057ba0: 6d65 6c79 206d 616e 6e65 7220 616e 7977 mely manner anyw │ │ │ -00057bb0: 6179 0a09 0969 6620 286d 5f73 6e75 6262 ay...if (m_snubb │ │ │ -00057bc0: 6564 2920 7265 7475 726e 2066 616c 7365 ed) return false │ │ │ -00057bd0: 3b0a 0909 7265 7475 726e 2074 7275 653b ;...return true; │ │ │ -00057be0: 0a09 7d0a 0a09 626f 6f6c 2070 6565 725f ..}...bool peer_ │ │ │ -00057bf0: 636f 6e6e 6563 7469 6f6e 3a3a 6d61 6b65 connection::make │ │ │ -00057c00: 5f74 696d 655f 6372 6974 6963 616c 2870 _time_critical(p │ │ │ -00057c10: 6965 6365 5f62 6c6f 636b 2063 6f6e 7374 iece_block const │ │ │ -00057c20: 2661 6d70 3b20 626c 6f63 6b29 0a09 7b0a & block)..{. │ │ │ -00057c30: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -00057c40: 2869 735f 7369 6e67 6c65 5f74 6872 6561 (is_single_threa │ │ │ -00057c50: 6428 2929 3b0a 0909 6175 746f 2063 6f6e d());...auto con │ │ │ -00057c60: 7374 2072 6974 203d 2073 7464 3a3a 6669 st rit = std::fi │ │ │ -00057c70: 6e64 5f69 6628 6d5f 7265 7175 6573 745f nd_if(m_request_ │ │ │ -00057c80: 7175 6575 652e 6265 6769 6e28 290a 0909 queue.begin()... │ │ │ -00057c90: 092c 206d 5f72 6571 7565 7374 5f71 7565 ., m_request_que │ │ │ -00057ca0: 7565 2e65 6e64 2829 2c20 6175 783a 3a68 ue.end(), aux::h │ │ │ -00057cb0: 6173 5f62 6c6f 636b 2862 6c6f 636b 2929 as_block(block)) │ │ │ -00057cc0: 3b0a 0909 6966 2028 7269 7420 3d3d 206d ;...if (rit == m │ │ │ -00057cd0: 5f72 6571 7565 7374 5f71 7565 7565 2e65 _request_queue.e │ │ │ -00057ce0: 6e64 2829 2920 7265 7475 726e 2066 616c nd()) return fal │ │ │ -00057cf0: 7365 3b0a 2369 6620 544f 5252 454e 545f se;.#if TORRENT_ │ │ │ -00057d00: 5553 455f 4153 5345 5254 530a 0909 6175 USE_ASSERTS...au │ │ │ -00057d10: 746f 2074 203d 206d 5f74 6f72 7265 6e74 to t = m_torrent │ │ │ -00057d20: 2e6c 6f63 6b28 293b 0a09 0954 4f52 5245 .lock();...TORRE │ │ │ -00057d30: 4e54 5f41 5353 4552 5428 7429 3b0a 0909 NT_ASSERT(t);... │ │ │ -00057d40: 544f 5252 454e 545f 4153 5345 5254 2874 TORRENT_ASSERT(t │ │ │ -00057d50: 2d26 6774 3b68 6173 5f70 6963 6b65 7228 ->has_picker( │ │ │ -00057d60: 2929 3b0a 3c2f 7072 653e 3c2f 7464 3e3c ));.< │ │ │ -00057d70: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00057da0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -00057dd0: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ -00057de0: 706c 2e63 7070 3a35 3837 3c2f 613e 3c2f pl.cpp:587come up w │ │ │ -00057e00: 6974 6820 736f 6d65 2061 6273 7472 6163 ith some abstrac │ │ │ -00057e10: 7469 6f6e 2074 6f20 646f 2074 6869 7320 tion to do this │ │ │ -00057e20: 666f 7220 676e 7574 6c73 2061 7320 7765 for gnutls as we │ │ │ -00057e30: 6c6c 206c 6f61 6420 6365 7274 6966 6963 ll load certific │ │ │ -00057e40: 6174 6573 2066 726f 6d20 7468 6520 7769 ates from the wi │ │ │ -00057e50: 6e64 6f77 7320 7379 7374 656d 2063 6572 ndows system cer │ │ │ -00057e60: 7469 6669 6361 7465 2073 746f 7265 3c2f tificate store

    come │ │ │ -00057ec0: 2075 7020 7769 7468 2073 6f6d 6520 6162 up with some ab │ │ │ -00057ed0: 7374 7261 6374 696f 6e20 746f 2064 6f20 straction to do │ │ │ -00057ee0: 7468 6973 2066 6f72 2067 6e75 746c 7320 this for gnutls │ │ │ -00057ef0: 6173 2077 656c 6c0a 6c6f 6164 2063 6572 as well.load cer │ │ │ -00057f00: 7469 6669 6361 7465 7320 6672 6f6d 2074 tificates from t │ │ │ -00057f10: 6865 2077 696e 646f 7773 2073 7973 7465 he windows syste │ │ │ -00057f20: 6d20 6365 7274 6966 6963 6174 6520 7374 m certificate st │ │ │ -00057f30: 6f72 653c 2f68 323e 3c68 343e 2e2e 2f73 ore

    ../s │ │ │ -00057f40: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ -00057f50: 6370 703a 3538 373c 2f68 343e 3c70 7265 cpp:587

    .void sess
    │ │ │ -00057fa0: 696f 6e5f 696d 706c 3a3a 7374 6172 745f  ion_impl::start_
    │ │ │ -00057fb0: 7365 7373 696f 6e28 290a 097b 0a23 6966  session()..{.#if
    │ │ │ -00057fc0: 6e64 6566 2054 4f52 5245 4e54 5f44 4953  ndef TORRENT_DIS
    │ │ │ -00057fd0: 4142 4c45 5f4c 4f47 4749 4e47 0a09 0973  ABLE_LOGGING...s
    │ │ │ -00057fe0: 6573 7369 6f6e 5f6c 6f67 2822 7374 6172  ession_log("star
    │ │ │ -00057ff0: 7420 7365 7373 696f 6e22 293b 0a23 656e  t session");.#en
    │ │ │ -00058000: 6469 660a 0a23 6966 2054 4f52 5245 4e54  dif..#if TORRENT
    │ │ │ -00058010: 5f55 5345 5f53 534c 0a09 0965 7272 6f72  _USE_SSL...error
    │ │ │ -00058020: 5f63 6f64 6520 6563 3b0a 0909 6d5f 7373  _code ec;...m_ss
    │ │ │ -00058030: 6c5f 6374 782e 7365 745f 6f70 7469 6f6e  l_ctx.set_option
    │ │ │ -00058040: 7328 7373 6c3a 3a6e 6f5f 6c65 6761 6379  s(ssl::no_legacy
    │ │ │ -00058050: 5f74 6c73 5f76 6572 7369 6f6e 732c 2065  _tls_versions, e
    │ │ │ -00058060: 6329 3b0a 2369 666e 6465 6620 544f 5252  c);.#ifndef TORR
    │ │ │ -00058070: 454e 545f 4449 5341 424c 455f 4c4f 4747  ENT_DISABLE_LOGG
    │ │ │ -00058080: 494e 470a 0909 6966 2028 6563 290a 0909  ING...if (ec)...
    │ │ │ -00058090: 0973 6573 7369 6f6e 5f6c 6f67 2822 5353  .session_log("SS
    │ │ │ -000580a0: 4c20 7365 745f 6f70 7469 6f6e 7320 6661  L set_options fa
    │ │ │ -000580b0: 696c 6564 3a20 2573 222c 2065 632e 6d65  iled: %s", ec.me
    │ │ │ -000580c0: 7373 6167 6528 292e 635f 7374 7228 2929  ssage().c_str())
    │ │ │ -000580d0: 3b0a 0909 6563 2e63 6c65 6172 2829 3b0a  ;...ec.clear();.
    │ │ │ -000580e0: 2365 6e64 6966 0a09 096d 5f73 736c 5f63  #endif...m_ssl_c
    │ │ │ -000580f0: 7478 2e73 6574 5f64 6566 6175 6c74 5f76  tx.set_default_v
    │ │ │ -00058100: 6572 6966 795f 7061 7468 7328 6563 293b  erify_paths(ec);
    │ │ │ -00058110: 0a23 6966 6e64 6566 2054 4f52 5245 4e54  .#ifndef TORRENT
    │ │ │ -00058120: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47  _DISABLE_LOGGING
    │ │ │ -00058130: 0a09 0969 6620 2865 6329 2073 6573 7369  ...if (ec) sessi
    │ │ │ -00058140: 6f6e 5f6c 6f67 2822 5353 4c20 7365 745f  on_log("SSL set_
    │ │ │ -00058150: 6465 6661 756c 7420 7665 7269 6679 5f70  default verify_p
    │ │ │ -00058160: 6174 6873 2066 6169 6c65 643a 2025 7322  aths failed: %s"
    │ │ │ -00058170: 2c20 6563 2e6d 6573 7361 6765 2829 2e63  , ec.message().c
    │ │ │ -00058180: 5f73 7472 2829 293b 0a09 0965 632e 636c  _str());...ec.cl
    │ │ │ -00058190: 6561 7228 293b 0a23 656e 6469 660a 2369  ear();.#endif.#i
    │ │ │ -000581a0: 6620 6465 6669 6e65 6420 544f 5252 454e  f defined TORREN
    │ │ │ -000581b0: 545f 5749 4e44 4f57 5320 2661 6d70 3b26  T_WINDOWS &&
    │ │ │ -000581c0: 616d 703b 2064 6566 696e 6564 2054 4f52  amp; defined TOR
    │ │ │ -000581d0: 5245 4e54 5f55 5345 5f4f 5045 4e53 534c  RENT_USE_OPENSSL
    │ │ │ -000581e0: 2026 616d 703b 2661 6d70 3b20 2164 6566   && !def
    │ │ │ -000581f0: 696e 6564 2054 4f52 5245 4e54 5f57 494e  ined TORRENT_WIN
    │ │ │ -00058200: 5254 0a3c 6469 7620 7374 796c 653d 2262  RT.
    ..X509_STORE* s │ │ │ -00058240: 746f 7265 203d 2058 3530 395f 5354 4f52 tore = X509_STOR │ │ │ -00058250: 455f 6e65 7728 293b 0a3c 2f64 6976 3e09 E_new();.
    . │ │ │ -00058260: 0969 6620 2873 746f 7265 290a 0909 7b0a .if (store)...{. │ │ │ -00058270: 0909 0948 4345 5254 5354 4f52 4520 7379 ...HCERTSTORE sy │ │ │ -00058280: 7374 656d 5f73 746f 7265 203d 2043 6572 stem_store = Cer │ │ │ -00058290: 744f 7065 6e53 7973 7465 6d53 746f 7265 tOpenSystemStore │ │ │ -000582a0: 4128 302c 2022 524f 4f54 2229 3b0a 0909 A(0, "ROOT");... │ │ │ -000582b0: 092f 2f20 7468 6973 2069 7320 6265 7374 .// this is best │ │ │ -000582c0: 2065 6666 6f72 740a 0909 0969 6620 2873 effort....if (s │ │ │ -000582d0: 7973 7465 6d5f 7374 6f72 6529 0a09 0909 ystem_store).... │ │ │ -000582e0: 7b0a 0909 0909 4345 5254 5f43 4f4e 5445 {.....CERT_CONTE │ │ │ -000582f0: 5854 2063 6f6e 7374 2a20 6374 7820 3d20 XT const* ctx = │ │ │ -00058300: 6e75 6c6c 7074 723b 0a09 0909 0977 6869 nullptr;.....whi │ │ │ -00058310: 6c65 2028 2863 7478 203d 2043 6572 7445 le ((ctx = CertE │ │ │ -00058320: 6e75 6d43 6572 7469 6669 6361 7465 7349 numCertificatesI │ │ │ -00058330: 6e53 746f 7265 2873 7973 7465 6d5f 7374 nStore(system_st │ │ │ -00058340: 6f72 652c 2063 7478 2929 2021 3d20 6e75 ore, ctx)) != nu │ │ │ -00058350: 6c6c 7074 7229 0a09 0909 097b 0a09 0909 llptr).....{.... │ │ │ -00058360: 0909 756e 7369 676e 6564 2063 6861 7220 ..unsigned char │ │ │ -00058370: 636f 6e73 742a 2063 6572 745f 7074 7220 const* cert_ptr │ │ │ -00058380: 3d20 7265 696e 7465 7270 7265 745f 6361 = reinterpret_ca │ │ │ -00058390: 7374 266c 743b 756e 7369 676e 6564 2063 st<unsigned c │ │ │ -000583a0: 6861 7220 636f 6e73 742a 2667 743b 2863 har const*>(c │ │ │ -000583b0: 7478 2d26 6774 3b70 6243 6572 7445 6e63 tx->pbCertEnc │ │ │ -000583c0: 6f64 6564 293b 0a09 0909 0909 5835 3039 oded);......X509 │ │ │ -000583d0: 2a20 7835 3039 203d 2064 3269 5f58 3530 * x509 = d2i_X50 │ │ │ -000583e0: 3928 6e75 6c6c 7074 722c 2026 616d 703b 9(nullptr, & │ │ │ -000583f0: 6365 7274 5f70 7472 2c20 6374 782d 2667 cert_ptr, ctx-&g │ │ │ -00058400: 743b 6362 4365 7274 456e 636f 6465 6429 t;cbCertEncoded) │ │ │ -00058410: 3b0a 0909 0909 092f 2f20 7468 6973 2069 ;......// this i │ │ │ -00058420: 7320 6265 7374 2065 6666 6f72 740a 0909 s best effort... │ │ │ -00058430: 0909 0969 6620 2821 7835 3039 2920 636f ...if (!x509) co │ │ │ -00058440: 6e74 696e 7565 3b0a 0909 0909 0958 3530 ntinue;......X50 │ │ │ -00058450: 395f 5354 4f52 455f 6164 645f 6365 7274 9_STORE_add_cert │ │ │ -00058460: 2873 746f 7265 2c20 7835 3039 293b 0a09 (store, x509);.. │ │ │ -00058470: 0909 0909 5835 3039 5f66 7265 6528 7835 ....X509_free(x5 │ │ │ -00058480: 3039 293b 0a09 0909 097d 0a09 0909 0943 09);.....}.....C │ │ │ -00058490: 6572 7446 7265 6543 6572 7469 6669 6361 ertFreeCertifica │ │ │ -000584a0: 7465 436f 6e74 6578 7428 6374 7829 3b0a teContext(ctx);. │ │ │ -000584b0: 0909 0909 4365 7274 436c 6f73 6553 746f ....CertCloseSto │ │ │ -000584c0: 7265 2873 7973 7465 6d5f 7374 6f72 652c re(system_store, │ │ │ -000584d0: 2030 293b 0a09 0909 7d0a 0909 7d0a 0a09 0);....}...}... │ │ │ -000584e0: 0953 534c 5f43 5458 2a20 7373 6c5f 6374 .SSL_CTX* ssl_ct │ │ │ -000584f0: 7820 3d20 6d5f 7373 6c5f 6374 782e 6e61 x = m_ssl_ctx.na │ │ │ -00058500: 7469 7665 5f68 616e 646c 6528 293b 0a09 tive_handle();.. │ │ │ -00058510: 0953 534c 5f43 5458 5f73 6574 5f63 6572 .SSL_CTX_set_cer │ │ │ -00058520: 745f 7374 6f72 6528 7373 6c5f 6374 782c t_store(ssl_ctx, │ │ │ -00058530: 2073 746f 7265 293b 0a23 656e 6469 660a store);.#endif. │ │ │ -00058540: 2369 6664 6566 205f 5f41 5050 4c45 5f5f #ifdef __APPLE__ │ │ │ -00058550: 0a09 096d 5f73 736c 5f63 7478 2e6c 6f61 ...m_ssl_ctx.loa │ │ │ -00058560: 645f 7665 7269 6679 5f66 696c 6528 222f d_verify_file("/ │ │ │ -00058570: 6574 632f 7373 6c2f 6365 7274 2e70 656d etc/ssl/cert.pem │ │ │ -00058580: 222c 2065 6329 3b0a 2369 666e 6465 6620 ", ec);.#ifndef │ │ │ -00058590: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -000585a0: 4c4f 4747 494e 470a 0909 6966 2028 6563 LOGGING...if (ec │ │ │ -000585b0: 2920 7365 7373 696f 6e5f 6c6f 6728 2253 ) session_log("S │ │ │ -000585c0: 534c 206c 6f61 645f 7665 7269 6679 5f66 SL load_verify_f │ │ │ -000585d0: 696c 6520 6661 696c 6564 3a20 2573 222c ile failed: %s", │ │ │ -000585e0: 2065 632e 6d65 7373 6167 6528 292e 635f ec.message().c_ │ │ │ -000585f0: 7374 7228 2929 3b0a 2365 6e64 6966 0a09 str());.#endif.. │ │ │ -00058600: 0965 632e 636c 6561 7228 293b 0a3c 2f70 .ec.clear();.

    re │ │ │ -00058640: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/s │ │ │ -00058680: 6573 7369 6f6e 5f69 6d70 6c2e 6370 703a ession_impl.cpp: │ │ │ -00058690: 3134 3634 3c2f 613e 3c2f 7464 3e3c 7464 1464it would be nic │ │ │ -000586b0: 6520 746f 2072 6573 6572 7665 2829 2074 e to reserve() t │ │ │ -000586c0: 6865 7365 2076 6563 746f 7273 2075 7020 hese vectors up │ │ │ -000586d0: 6672 6f6e 743c 2f74 643e 3c2f 7472 3e3c front< │ │ │ -000586e0: 7472 2069 643d 2232 3037 2220 7374 796c tr id="207" styl │ │ │ -000586f0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00058700: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00058710: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00058720: 6832 3e69 7420 776f 756c 6420 6265 206e h2>it would be n │ │ │ -00058730: 6963 6520 746f 2072 6573 6572 7665 2829 ice to reserve() │ │ │ -00058740: 2074 6865 7365 2076 6563 746f 7273 2075 these vectors u │ │ │ -00058750: 7020 6672 6f6e 743c 2f68 323e 3c68 343e p front

    │ │ │ -00058760: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ -00058770: 6d70 6c2e 6370 703a 3134 3634 3c2f 6834 mpl.cpp:1464

    ...ba
    │ │ │ -000587c0: 6e64 7769 6474 685f 6368 616e 6e65 6c2a  ndwidth_channel*
    │ │ │ -000587d0: 2063 6820 3d20 2661 6d70 3b70 2d26 6774   ch = &p->
    │ │ │ -000587e0: 3b63 6861 6e6e 656c 5b70 6565 725f 636f  ;channel[peer_co
    │ │ │ -000587f0: 6e6e 6563 7469 6f6e 3a3a 646f 776e 6c6f  nnection::downlo
    │ │ │ -00058800: 6164 5f63 6861 6e6e 656c 5d3b 0a09 0909  ad_channel];....
    │ │ │ -00058810: 6966 2028 7573 655f 7175 6f74 615f 6f76  if (use_quota_ov
    │ │ │ -00058820: 6572 6865 6164 2863 682c 2061 6d6f 756e  erhead(ch, amoun
    │ │ │ -00058830: 745f 646f 776e 2929 0a09 0909 0972 6574  t_down)).....ret
    │ │ │ -00058840: 207c 3d20 3175 2026 6c74 3b26 6c74 3b20   |= 1u << 
    │ │ │ -00058850: 7065 6572 5f63 6f6e 6e65 6374 696f 6e3a  peer_connection:
    │ │ │ -00058860: 3a64 6f77 6e6c 6f61 645f 6368 616e 6e65  :download_channe
    │ │ │ -00058870: 6c3b 0a09 0909 6368 203d 2026 616d 703b  l;....ch = &
    │ │ │ -00058880: 702d 2667 743b 6368 616e 6e65 6c5b 7065  p->channel[pe
    │ │ │ -00058890: 6572 5f63 6f6e 6e65 6374 696f 6e3a 3a75  er_connection::u
    │ │ │ -000588a0: 706c 6f61 645f 6368 616e 6e65 6c5d 3b0a  pload_channel];.
    │ │ │ -000588b0: 0909 0969 6620 2875 7365 5f71 756f 7461  ...if (use_quota
    │ │ │ -000588c0: 5f6f 7665 7268 6561 6428 6368 2c20 616d  _overhead(ch, am
    │ │ │ -000588d0: 6f75 6e74 5f75 7029 290a 0909 0909 7265  ount_up)).....re
    │ │ │ -000588e0: 7420 7c3d 2031 7520 266c 743b 266c 743b  t |= 1u <<
    │ │ │ -000588f0: 2070 6565 725f 636f 6e6e 6563 7469 6f6e   peer_connection
    │ │ │ -00058900: 3a3a 7570 6c6f 6164 5f63 6861 6e6e 656c  ::upload_channel
    │ │ │ -00058910: 3b0a 0909 7d0a 0909 7265 7475 726e 2072  ;...}...return r
    │ │ │ -00058920: 6574 3b0a 097d 0a0a 092f 2f20 7365 7373  et;..}...// sess
    │ │ │ -00058930: 696f 6e5f 696d 706c 2069 7320 7265 7370  ion_impl is resp
    │ │ │ -00058940: 6f6e 7369 626c 6520 666f 7220 6465 6c65  onsible for dele
    │ │ │ -00058950: 7469 6e67 2027 7061 636b 270a 0976 6f69  ting 'pack'..voi
    │ │ │ -00058960: 6420 7365 7373 696f 6e5f 696d 706c 3a3a  d session_impl::
    │ │ │ -00058970: 6170 706c 795f 7365 7474 696e 6773 5f70  apply_settings_p
    │ │ │ -00058980: 6163 6b28 7374 643a 3a73 6861 7265 645f  ack(std::shared_
    │ │ │ -00058990: 7074 7226 6c74 3b73 6574 7469 6e67 735f  ptr<settings_
    │ │ │ -000589a0: 7061 636b 2667 743b 2070 6163 6b29 0a09  pack> pack)..
    │ │ │ -000589b0: 7b0a 0909 494e 5641 5249 414e 545f 4348  {...INVARIANT_CH
    │ │ │ -000589c0: 4543 4b3b 0a09 0961 7070 6c79 5f73 6574  ECK;...apply_set
    │ │ │ -000589d0: 7469 6e67 735f 7061 636b 5f69 6d70 6c28  tings_pack_impl(
    │ │ │ -000589e0: 2a70 6163 6b29 3b0a 097d 0a0a 0973 6574  *pack);..}...set
    │ │ │ -000589f0: 7469 6e67 735f 7061 636b 2073 6573 7369  tings_pack sessi
    │ │ │ -00058a00: 6f6e 5f69 6d70 6c3a 3a67 6574 5f73 6574  on_impl::get_set
    │ │ │ -00058a10: 7469 6e67 7328 2920 636f 6e73 740a 097b  tings() const..{
    │ │ │ -00058a20: 0a09 0973 6574 7469 6e67 735f 7061 636b  ...settings_pack
    │ │ │ -00058a30: 2072 6574 3b0a 3c64 6976 2073 7479 6c65   ret;.
    ..for (int i │ │ │ -00058a70: 203d 2073 6574 7469 6e67 735f 7061 636b = settings_pack │ │ │ -00058a80: 3a3a 7374 7269 6e67 5f74 7970 655f 6261 ::string_type_ba │ │ │ -00058a90: 7365 3b0a 3c2f 6469 763e 0909 0969 2026 se;.
    ...i & │ │ │ -00058aa0: 6c74 3b20 7365 7474 696e 6773 5f70 6163 lt; settings_pac │ │ │ -00058ab0: 6b3a 3a6d 6178 5f73 7472 696e 675f 7365 k::max_string_se │ │ │ -00058ac0: 7474 696e 675f 696e 7465 726e 616c 3b20 tting_internal; │ │ │ -00058ad0: 2b2b 6929 0a09 097b 0a09 0909 7265 742e ++i)...{....ret. │ │ │ -00058ae0: 7365 745f 7374 7228 692c 206d 5f73 6574 set_str(i, m_set │ │ │ -00058af0: 7469 6e67 732e 6765 745f 7374 7228 6929 tings.get_str(i) │ │ │ -00058b00: 293b 0a09 097d 0a09 0966 6f72 2028 696e );...}...for (in │ │ │ -00058b10: 7420 6920 3d20 7365 7474 696e 6773 5f70 t i = settings_p │ │ │ -00058b20: 6163 6b3a 3a69 6e74 5f74 7970 655f 6261 ack::int_type_ba │ │ │ -00058b30: 7365 3b0a 0909 0969 2026 6c74 3b20 7365 se;....i < se │ │ │ -00058b40: 7474 696e 6773 5f70 6163 6b3a 3a6d 6178 ttings_pack::max │ │ │ -00058b50: 5f69 6e74 5f73 6574 7469 6e67 5f69 6e74 _int_setting_int │ │ │ -00058b60: 6572 6e61 6c3b 202b 2b69 290a 0909 7b0a ernal; ++i)...{. │ │ │ -00058b70: 0909 0972 6574 2e73 6574 5f69 6e74 2869 ...ret.set_int(i │ │ │ -00058b80: 2c20 6d5f 7365 7474 696e 6773 2e67 6574 , m_settings.get │ │ │ -00058b90: 5f69 6e74 2869 2929 3b0a 0909 7d0a 0909 _int(i));...}... │ │ │ -00058ba0: 666f 7220 2869 6e74 2069 203d 2073 6574 for (int i = set │ │ │ -00058bb0: 7469 6e67 735f 7061 636b 3a3a 626f 6f6c tings_pack::bool │ │ │ -00058bc0: 5f74 7970 655f 6261 7365 3b0a 0909 0969 _type_base;....i │ │ │ -00058bd0: 2026 6c74 3b20 7365 7474 696e 6773 5f70 < settings_p │ │ │ -00058be0: 6163 6b3a 3a6d 6178 5f62 6f6f 6c5f 7365 ack::max_bool_se │ │ │ -00058bf0: 7474 696e 675f 696e 7465 726e 616c 3b20 tting_internal; │ │ │ -00058c00: 2b2b 6929 0a09 097b 0a09 0909 7265 742e ++i)...{....ret. │ │ │ -00058c10: 7365 745f 626f 6f6c 2869 2c20 6d5f 7365 set_bool(i, m_se │ │ │ -00058c20: 7474 696e 6773 2e67 6574 5f62 6f6f 6c28 ttings.get_bool( │ │ │ -00058c30: 6929 293b 0a09 097d 0a09 0972 6574 7572 i));...}...retur │ │ │ -00058c40: 6e20 7265 743b 0a09 7d0a 0a6e 616d 6573 n ret;..}..names │ │ │ -00058c50: 7061 6365 207b 0a09 7465 6d70 6c61 7465 pace {..template │ │ │ -00058c60: 2026 6c74 3b74 7970 656e 616d 6520 5061 <typename Pa │ │ │ -00058c70: 636b 2667 743b 0a09 696e 7420 6765 745f ck>..int get_ │ │ │ -00058c80: 7365 7474 696e 675f 696d 706c 2850 6163 setting_impl(Pac │ │ │ -00058c90: 6b20 636f 6e73 7426 616d 703b 2070 2c20 k const& p, │ │ │ -00058ca0: 696e 7420 6e61 6d65 2c20 696e 742a 290a int name, int*). │ │ │ -00058cb0: 097b 2072 6574 7572 6e20 702e 6765 745f .{ return p.get_ │ │ │ -00058cc0: 696e 7428 6e61 6d65 293b 207d 0a0a 0974 int(name); }...t │ │ │ -00058cd0: 656d 706c 6174 6520 266c 743b 7479 7065 emplate <type │ │ │ -00058ce0: 6e61 6d65 2050 6163 6b26 6774 3b0a 0962 name Pack>..b │ │ │ -00058cf0: 6f6f 6c20 6765 745f 7365 7474 696e 675f ool get_setting_ │ │ │ -00058d00: 696d 706c 2850 6163 6b20 636f 6e73 7426 impl(Pack const& │ │ │ -00058d10: 616d 703b 2070 2c20 696e 7420 6e61 6d65 amp; p, int name │ │ │ -00058d20: 2c20 626f 6f6c 2a29 0a09 7b20 7265 7475 , bool*)..{ retu │ │ │ -00058d30: 726e 2070 2e67 6574 5f62 6f6f 6c28 6e61 rn p.get_bool(na │ │ │ -00058d40: 6d65 293b 207d 0a0a 0974 656d 706c 6174 me); }...templat │ │ │ -00058d50: 6520 266c 743b 7479 7065 6e61 6d65 2050 e <typename P │ │ │ -00058d60: 6163 6b26 6774 3b0a 0973 7464 3a3a 7374 ack>..std::st │ │ │ -00058d70: 7269 6e67 2067 6574 5f73 6574 7469 6e67 ring get_setting │ │ │ -00058d80: 5f69 6d70 6c28 5061 636b 2063 6f6e 7374 _impl(Pack const │ │ │ -00058d90: 2661 6d70 3b20 702c 2069 6e74 206e 616d & p, int nam │ │ │ -00058da0: 652c 2073 7464 3a3a 7374 7269 6e67 2a29 e, std::string*) │ │ │ -00058db0: 0a09 7b20 7265 7475 726e 2070 2e67 6574 ..{ return p.get │ │ │ -00058dc0: 5f73 7472 286e 616d 6529 3b20 7d0a 0a3c _str(name); }..< │ │ │ -00058dd0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00058de0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00058df0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -00058e00: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -00058e10: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -00058e40: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ -00058e50: 703a 3230 3239 3c2f 613e 3c2f 7464 3e3c p:2029< │ │ │ -00058e60: 7464 3e63 6f75 6c64 2074 6869 7320 6675 td>could this fu │ │ │ -00058e70: 6e63 7469 6f6e 2062 6520 6d65 7267 6564 nction be merged │ │ │ -00058e80: 2077 6974 6820 6578 7061 6e64 5f75 6e73 with expand_uns │ │ │ -00058e90: 7065 6369 6669 6564 5f61 6464 7265 7373 pecified_address │ │ │ -00058ea0: 6573 3f20 7269 6768 7420 6e6f 7720 626f es? right now bo │ │ │ -00058eb0: 7468 206c 6973 7465 6e5f 656e 6470 6f69 th listen_endpoi │ │ │ -00058ec0: 6e74 5f74 2061 6e64 206c 6973 7465 6e5f nt_t and listen_ │ │ │ -00058ed0: 696e 7465 7266 6163 655f 7420 6172 6520 interface_t are │ │ │ -00058ee0: 616c 6d6f 7374 2069 6465 6e74 6963 616c almost identical │ │ │ -00058ef0: 2c20 6d61 7962 6520 7468 6520 6c61 7474 , maybe the latt │ │ │ -00058f00: 6572 2063 6f75 6c64 2062 6520 7265 6d6f er could be remo │ │ │ -00058f10: 7665 6420 746f 6f3c 2f74 643e 3c2f 7472 ved too

    could this │ │ │ -00058f70: 6675 6e63 7469 6f6e 2062 6520 6d65 7267 function be merg │ │ │ -00058f80: 6564 2077 6974 6820 6578 7061 6e64 5f75 ed with expand_u │ │ │ -00058f90: 6e73 7065 6369 6669 6564 5f61 6464 7265 nspecified_addre │ │ │ -00058fa0: 7373 6573 3f0a 7269 6768 7420 6e6f 7720 sses?.right now │ │ │ -00058fb0: 626f 7468 206c 6973 7465 6e5f 656e 6470 both listen_endp │ │ │ -00058fc0: 6f69 6e74 5f74 2061 6e64 206c 6973 7465 oint_t and liste │ │ │ -00058fd0: 6e5f 696e 7465 7266 6163 655f 7420 6172 n_interface_t ar │ │ │ -00058fe0: 6520 616c 6d6f 7374 0a69 6465 6e74 6963 e almost.identic │ │ │ -00058ff0: 616c 2c20 6d61 7962 6520 7468 6520 6c61 al, maybe the la │ │ │ -00059000: 7474 6572 2063 6f75 6c64 2062 6520 7265 tter could be re │ │ │ -00059010: 6d6f 7665 6420 746f 6f3c 2f68 323e 3c68 moved too

    ../src/session │ │ │ -00059030: 5f69 6d70 6c2e 6370 703a 3230 3239 3c2f _impl.cpp:2029
    ..s
    │ │ │ -00059080: 6573 7369 6f6e 5f6c 6f67 2822 4641 5441  ession_log("FATA
    │ │ │ -00059090: 4c20 5345 5353 494f 4e20 4552 524f 5220  L SESSION ERROR 
    │ │ │ -000590a0: 2825 7320 3a20 2564 2920 5b25 735d 220a  (%s : %d) [%s]".
    │ │ │ -000590b0: 0909 092c 2065 632e 6361 7465 676f 7279  ..., ec.category
    │ │ │ -000590c0: 2829 2e6e 616d 6528 292c 2065 632e 7661  ().name(), ec.va
    │ │ │ -000590d0: 6c75 6528 292c 2065 632e 6d65 7373 6167  lue(), ec.messag
    │ │ │ -000590e0: 6528 292e 635f 7374 7228 2929 3b0a 2365  e().c_str());.#e
    │ │ │ -000590f0: 6e64 6966 0a09 0974 6869 732d 2667 743b  ndif...this->
    │ │ │ -00059100: 6162 6f72 7428 293b 0a09 7d0a 0a09 766f  abort();..}...vo
    │ │ │ -00059110: 6964 2073 6573 7369 6f6e 5f69 6d70 6c3a  id session_impl:
    │ │ │ -00059120: 3a6f 6e5f 6970 5f63 6861 6e67 6528 6572  :on_ip_change(er
    │ │ │ -00059130: 726f 725f 636f 6465 2063 6f6e 7374 2661  ror_code const&a
    │ │ │ -00059140: 6d70 3b20 6563 290a 097b 0a23 6966 6e64  mp; ec)..{.#ifnd
    │ │ │ -00059150: 6566 2054 4f52 5245 4e54 5f44 4953 4142  ef TORRENT_DISAB
    │ │ │ -00059160: 4c45 5f4c 4f47 4749 4e47 0a09 0969 6620  LE_LOGGING...if 
    │ │ │ -00059170: 2821 6563 290a 0909 0973 6573 7369 6f6e  (!ec)....session
    │ │ │ -00059180: 5f6c 6f67 2822 7265 6365 6976 6564 2069  _log("received i
    │ │ │ -00059190: 7020 6368 616e 6765 2066 726f 6d20 696e  p change from in
    │ │ │ -000591a0: 7465 726e 616c 2069 705f 6e6f 7469 6669  ternal ip_notifi
    │ │ │ -000591b0: 6572 2229 3b0a 0909 656c 7365 0a09 0909  er");...else....
    │ │ │ -000591c0: 7365 7373 696f 6e5f 6c6f 6728 2272 6563  session_log("rec
    │ │ │ -000591d0: 6569 7665 6420 6572 726f 7220 6f6e 5f69  eived error on_i
    │ │ │ -000591e0: 705f 6368 616e 6765 3a20 2564 2c20 2573  p_change: %d, %s
    │ │ │ -000591f0: 222c 2065 632e 7661 6c75 6528 292c 2065  ", ec.value(), e
    │ │ │ -00059200: 632e 6d65 7373 6167 6528 292e 635f 7374  c.message().c_st
    │ │ │ -00059210: 7228 2929 3b0a 2365 6e64 6966 0a09 0969  r());.#endif...i
    │ │ │ -00059220: 6620 2865 6320 7c7c 206d 5f61 626f 7274  f (ec || m_abort
    │ │ │ -00059230: 207c 7c20 216d 5f69 705f 6e6f 7469 6669   || !m_ip_notifi
    │ │ │ -00059240: 6572 2920 7265 7475 726e 3b0a 0909 6d5f  er) return;...m_
    │ │ │ -00059250: 6970 5f6e 6f74 6966 6965 722d 2667 743b  ip_notifier->
    │ │ │ -00059260: 6173 796e 635f 7761 6974 285b 7468 6973  async_wait([this
    │ │ │ -00059270: 5d20 2865 7272 6f72 5f63 6f64 6520 636f  ] (error_code co
    │ │ │ -00059280: 6e73 7426 616d 703b 2065 290a 0909 097b  nst& e)....{
    │ │ │ -00059290: 2077 7261 7028 2661 6d70 3b73 6573 7369   wrap(&sessi
    │ │ │ -000592a0: 6f6e 5f69 6d70 6c3a 3a6f 6e5f 6970 5f63  on_impl::on_ip_c
    │ │ │ -000592b0: 6861 6e67 652c 2065 293b 207d 293b 0a09  hange, e); });..
    │ │ │ -000592c0: 0972 656f 7065 6e5f 6e65 7477 6f72 6b5f  .reopen_network_
    │ │ │ -000592d0: 736f 636b 6574 7328 7b7d 293b 0a09 7d0a  sockets({});..}.
    │ │ │ -000592e0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -00059310: 766f 6964 2069 6e74 6572 6661 6365 5f74 void interface_t │ │ │ -00059320: 6f5f 656e 6470 6f69 6e74 7328 6c69 7374 o_endpoints(list │ │ │ -00059330: 656e 5f69 6e74 6572 6661 6365 5f74 2063 en_interface_t c │ │ │ -00059340: 6f6e 7374 2661 6d70 3b20 6966 6163 650a onst& iface. │ │ │ -00059350: 3c2f 6469 763e 0909 2c20 6c69 7374 656e
    .., listen │ │ │ -00059360: 5f73 6f63 6b65 745f 666c 6167 735f 7420 _socket_flags_t │ │ │ -00059370: 666c 6167 730a 0909 2c20 7370 616e 266c flags..., span&l │ │ │ -00059380: 743b 6970 5f69 6e74 6572 6661 6365 2063 t;ip_interface c │ │ │ -00059390: 6f6e 7374 2667 743b 2063 6f6e 7374 2069 onst> const i │ │ │ -000593a0: 6673 0a09 092c 2073 7464 3a3a 7665 6374 fs..., std::vect │ │ │ -000593b0: 6f72 266c 743b 6c69 7374 656e 5f65 6e64 or<listen_end │ │ │ -000593c0: 706f 696e 745f 7426 6774 3b26 616d 703b point_t>& │ │ │ -000593d0: 2065 7073 290a 097b 0a09 0966 6c61 6773 eps)..{...flags │ │ │ -000593e0: 207c 3d20 6966 6163 652e 6c6f 6361 6c20 |= iface.local │ │ │ -000593f0: 3f20 6c69 7374 656e 5f73 6f63 6b65 745f ? listen_socket_ │ │ │ -00059400: 743a 3a6c 6f63 616c 5f6e 6574 776f 726b t::local_network │ │ │ -00059410: 203a 206c 6973 7465 6e5f 736f 636b 6574 : listen_socket │ │ │ -00059420: 5f66 6c61 6773 5f74 7b7d 3b0a 0909 7472 _flags_t{};...tr │ │ │ -00059430: 616e 7370 6f72 7420 636f 6e73 7420 7373 ansport const ss │ │ │ -00059440: 6c20 3d20 6966 6163 652e 7373 6c20 3f20 l = iface.ssl ? │ │ │ -00059450: 7472 616e 7370 6f72 743a 3a73 736c 203a transport::ssl : │ │ │ -00059460: 2074 7261 6e73 706f 7274 3a3a 706c 6169 transport::plai │ │ │ -00059470: 6e74 6578 743b 0a0a 0909 2f2f 2046 6972 ntext;....// Fir │ │ │ -00059480: 7374 2c20 6368 6563 6b20 746f 2073 6565 st, check to see │ │ │ -00059490: 2069 6620 6974 2773 2061 6e20 4950 2061 if it's an IP a │ │ │ -000594a0: 6464 7265 7373 0a09 0965 7272 6f72 5f63 ddress...error_c │ │ │ -000594b0: 6f64 6520 6572 723b 0a09 0961 6464 7265 ode err;...addre │ │ │ -000594c0: 7373 2063 6f6e 7374 2061 6472 203d 206d ss const adr = m │ │ │ -000594d0: 616b 655f 6164 6472 6573 7328 6966 6163 ake_address(ifac │ │ │ -000594e0: 652e 6465 7669 6365 2e63 5f73 7472 2829 e.device.c_str() │ │ │ -000594f0: 2c20 6572 7229 3b0a 0909 6966 2028 2165 , err);...if (!e │ │ │ -00059500: 7272 290a 0909 7b0a 0909 0965 7073 2e65 rr)...{....eps.e │ │ │ -00059510: 6d70 6c61 6365 5f62 6163 6b28 6164 722c mplace_back(adr, │ │ │ -00059520: 2069 6661 6365 2e70 6f72 742c 2073 7464 iface.port, std │ │ │ -00059530: 3a3a 7374 7269 6e67 7b7d 2c20 7373 6c2c ::string{}, ssl, │ │ │ -00059540: 2066 6c61 6773 293b 0a09 097d 0a09 0965 flags);...}...e │ │ │ -00059550: 6c73 650a 0909 7b0a 0909 0966 6c61 6773 lse...{....flags │ │ │ -00059560: 207c 3d20 6c69 7374 656e 5f73 6f63 6b65 |= listen_socke │ │ │ -00059570: 745f 743a 3a77 6173 5f65 7870 616e 6465 t_t::was_expande │ │ │ -00059580: 643b 0a0a 0909 092f 2f20 7468 6973 2069 d;.....// this i │ │ │ -00059590: 7320 7468 6520 6361 7365 2077 6865 7265 s the case where │ │ │ -000595a0: 2064 6576 6963 6520 6e61 6d65 7320 6120 device names a │ │ │ -000595b0: 6e65 7477 6f72 6b20 6465 7669 6365 2e20 network device. │ │ │ -000595c0: 5765 206e 6565 6420 746f 0a09 0909 2f2f We need to....// │ │ │ -000595d0: 2065 6e75 6d65 7261 7465 2061 6c6c 2049 enumerate all I │ │ │ -000595e0: 5073 2061 7373 6f63 6961 7465 6420 7769 Ps associated wi │ │ │ -000595f0: 7468 2074 6869 7320 6465 7669 6365 0a09 th this device.. │ │ │ -00059600: 0909 666f 7220 2861 7574 6f20 636f 6e73 ..for (auto cons │ │ │ -00059610: 7426 616d 703b 2069 7066 6163 6520 3a20 t& ipface : │ │ │ -00059620: 6966 7329 0a09 0909 7b0a 0909 0909 2f2f ifs)....{.....// │ │ │ -00059630: 2077 6527 7265 206c 6f6f 6b69 6e67 2066 we're looking f │ │ │ -00059640: 6f72 2061 2073 7065 6369 6669 6320 696e or a specific in │ │ │ -00059650: 7465 7266 6163 652c 2061 6e64 2069 7473 terface, and its │ │ │ -00059660: 2061 6464 7265 7373 0a09 0909 092f 2f20 address.....// │ │ │ -00059670: 2877 6869 6368 206d 7573 7420 6265 206f (which must be o │ │ │ -00059680: 6620 7468 6520 7361 6d65 2066 616d 696c f the same famil │ │ │ -00059690: 7920 6173 2074 6865 2061 6464 7265 7373 y as the address │ │ │ -000596a0: 2077 6527 7265 0a09 0909 092f 2f20 636f we're.....// co │ │ │ -000596b0: 6e6e 6563 7469 6e67 2074 6f29 0a09 0909 nnecting to).... │ │ │ -000596c0: 0969 6620 2869 6661 6365 2e64 6576 6963 .if (iface.devic │ │ │ -000596d0: 6520 213d 2069 7066 6163 652e 6e61 6d65 e != ipface.name │ │ │ -000596e0: 2920 636f 6e74 696e 7565 3b0a 0a09 0909 ) continue;..... │ │ │ -000596f0: 0962 6f6f 6c20 636f 6e73 7420 6c6f 6361 .bool const loca │ │ │ -00059700: 6c20 3d20 6966 6163 652e 6c6f 6361 6c0a l = iface.local. │ │ │ -00059710: 0909 0909 097c 7c20 6970 6661 6365 2e69 .....|| ipface.i │ │ │ -00059720: 6e74 6572 6661 6365 5f61 6464 7265 7373 nterface_address │ │ │ -00059730: 2e69 735f 6c6f 6f70 6261 636b 2829 0a09 .is_loopback().. │ │ │ -00059740: 0909 0909 7c7c 2069 735f 6c69 6e6b 5f6c ....|| is_link_l │ │ │ -00059750: 6f63 616c 2869 7066 6163 652e 696e 7465 ocal(ipface.inte │ │ │ -00059760: 7266 6163 655f 6164 6472 6573 7329 3b0a rface_address);. │ │ │ -00059770: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00059780: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -000597b0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -000597e0: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ -000597f0: 7070 3a32 3335 373c 2f61 3e3c 2f74 643e pp:2357 │ │ │ -00059800: 3c74 643e 6974 2077 6f75 6c64 2070 726f it would pro │ │ │ -00059810: 6261 626c 7920 6265 2062 6574 7465 7220 bably be better │ │ │ -00059820: 746f 2064 6f20 7468 6973 2062 7920 6861 to do this by ha │ │ │ -00059830: 7669 6e67 2061 206c 6973 7465 6e2d 736f ving a listen-so │ │ │ -00059840: 636b 6574 2022 7665 7273 696f 6e22 206e cket "version" n │ │ │ -00059850: 756d 6265 7220 7468 6174 2067 6574 7320 umber that gets │ │ │ -00059860: 6275 6d70 6564 2e20 416e 6420 696e 7374 bumped. And inst │ │ │ -00059870: 6561 6420 6f66 2073 6574 7469 6e67 2061 ead of setting a │ │ │ -00059880: 2062 6f6f 6c20 746f 2064 6973 6162 6c65 bool to disable │ │ │ -00059890: 2061 2074 7261 636b 6572 2c20 7765 2073 a tracker, we s │ │ │ -000598a0: 6574 2074 6865 2076 6572 7369 6f6e 206e et the version n │ │ │ -000598b0: 756d 6265 7220 7468 6174 2069 7420 7761 umber that it wa │ │ │ -000598c0: 7320 6469 7361 626c 6564 2061 742e 2054 s disabled at. T │ │ │ -000598d0: 6869 7320 6368 616e 6765 2077 6f75 6c64 his change would │ │ │ -000598e0: 2061 6666 6563 7420 7468 6520 4142 4920 affect the ABI │ │ │ -000598f0: 696e 2031 2e32 2c20 736f 2073 686f 756c in 1.2, so shoul │ │ │ -00059900: 6420 6265 2064 6f6e 6520 696e 2032 2e30 d be done in 2.0 │ │ │ -00059910: 206f 7220 6c61 7465 723c 2f74 643e 3c2f or later

    it would │ │ │ -00059970: 7072 6f62 6162 6c79 2062 6520 6265 7474 probably be bett │ │ │ -00059980: 6572 2074 6f20 646f 2074 6869 7320 6279 er to do this by │ │ │ -00059990: 2068 6176 696e 6720 610a 6c69 7374 656e having a.listen │ │ │ -000599a0: 2d73 6f63 6b65 7420 2276 6572 7369 6f6e -socket "version │ │ │ -000599b0: 2220 6e75 6d62 6572 2074 6861 7420 6765 " number that ge │ │ │ -000599c0: 7473 2062 756d 7065 642e 2041 6e64 2069 ts bumped. And i │ │ │ -000599d0: 6e73 7465 6164 206f 660a 7365 7474 696e nstead of.settin │ │ │ -000599e0: 6720 6120 626f 6f6c 2074 6f20 6469 7361 g a bool to disa │ │ │ -000599f0: 626c 6520 6120 7472 6163 6b65 722c 2077 ble a tracker, w │ │ │ -00059a00: 6520 7365 7420 7468 6520 7665 7273 696f e set the versio │ │ │ -00059a10: 6e20 6e75 6d62 6572 2074 6861 740a 6974 n number that.it │ │ │ -00059a20: 2077 6173 2064 6973 6162 6c65 6420 6174 was disabled at │ │ │ -00059a30: 2e20 5468 6973 2063 6861 6e67 6520 776f . This change wo │ │ │ -00059a40: 756c 6420 6166 6665 6374 2074 6865 2041 uld affect the A │ │ │ -00059a50: 4249 2069 6e20 312e 322c 2073 6f0a 7368 BI in 1.2, so.sh │ │ │ -00059a60: 6f75 6c64 2062 6520 646f 6e65 2069 6e20 ould be done in │ │ │ -00059a70: 322e 3020 6f72 206c 6174 6572 3c2f 6832 2.0 or later

    ../src/sess │ │ │ -00059a90: 696f 6e5f 696d 706c 2e63 7070 3a32 3335 ion_impl.cpp:235 │ │ │ -00059aa0: 373c 2f68 343e 3c70 7265 2073 7479 6c65 7

    │ │ │ -00059ae0: 0909 7b0a 0909 0966 6f72 2028 6175 746f  ..{....for (auto
    │ │ │ -00059af0: 2063 6f6e 7374 2661 6d70 3b20 7320 3a20   const& s : 
    │ │ │ -00059b00: 6d5f 6c69 7374 656e 5f73 6f63 6b65 7473  m_listen_sockets
    │ │ │ -00059b10: 290a 0909 0909 7265 6d61 705f 706f 7274  ).....remap_port
    │ │ │ -00059b20: 7328 7265 6d61 705f 6e61 7470 6d70 5f61  s(remap_natpmp_a
    │ │ │ -00059b30: 6e64 5f75 706e 702c 202a 7329 3b0a 0909  nd_upnp, *s);...
    │ │ │ -00059b40: 7d0a 0909 656c 7365 0a09 097b 0a09 0909  }...else...{....
    │ │ │ -00059b50: 2f2f 206e 6577 2073 6f63 6b65 7473 206e  // new sockets n
    │ │ │ -00059b60: 6565 6420 746f 206d 6170 2070 6f72 7473  eed to map ports
    │ │ │ -00059b70: 2065 7665 6e20 6966 2074 6865 2063 616c   even if the cal
    │ │ │ -00059b80: 6c65 7220 6469 6420 6e6f 7420 7265 7175  ler did not requ
    │ │ │ -00059b90: 6573 740a 0909 092f 2f20 7265 2d6d 6170  est....// re-map
    │ │ │ -00059ba0: 7069 6e67 0a09 0909 666f 7220 2861 7574  ping....for (aut
    │ │ │ -00059bb0: 6f20 636f 6e73 7426 616d 703b 2073 203a  o const& s :
    │ │ │ -00059bc0: 206e 6577 5f73 6f63 6b65 7473 290a 0909   new_sockets)...
    │ │ │ -00059bd0: 0909 7265 6d61 705f 706f 7274 7328 7265  ..remap_ports(re
    │ │ │ -00059be0: 6d61 705f 6e61 7470 6d70 5f61 6e64 5f75  map_natpmp_and_u
    │ │ │ -00059bf0: 706e 702c 202a 7329 3b0a 0909 7d0a 0a09  pnp, *s);...}...
    │ │ │ -00059c00: 0975 7064 6174 655f 6c73 6428 293b 0a0a  .update_lsd();..
    │ │ │ -00059c10: 2369 6620 544f 5252 454e 545f 5553 455f  #if TORRENT_USE_
    │ │ │ -00059c20: 4932 500a 0909 6f70 656e 5f6e 6577 5f69  I2P...open_new_i
    │ │ │ -00059c30: 6e63 6f6d 696e 675f 6932 705f 636f 6e6e  ncoming_i2p_conn
    │ │ │ -00059c40: 6563 7469 6f6e 2829 3b0a 2365 6e64 6966  ection();.#endif
    │ │ │ -00059c50: 0a0a 0909 2f2f 2074 7261 636b 6572 7320  ....// trackers 
    │ │ │ -00059c60: 7468 6174 2077 6572 6520 6e6f 7420 7265  that were not re
    │ │ │ -00059c70: 6163 6861 626c 652c 206d 6179 2068 6176  achable, may hav
    │ │ │ -00059c80: 6520 6265 636f 6d65 2072 6561 6368 6162  e become reachab
    │ │ │ -00059c90: 6c65 206e 6f77 2e0a 0909 2f2f 2073 6f20  le now....// so 
    │ │ │ -00059ca0: 636c 6561 7220 7468 6520 2264 6973 6162  clear the "disab
    │ │ │ -00059cb0: 6c65 6422 2066 6c61 6773 2074 6f20 6c65  led" flags to le
    │ │ │ -00059cc0: 7420 7468 656d 2062 6520 7472 6965 6420  t them be tried 
    │ │ │ -00059cd0: 6f6e 6520 6d6f 7265 2074 696d 650a 3c64  one more time...fo
    │ │ │ -00059d10: 7220 2861 7574 6f26 616d 703b 2074 203a  r (auto& t :
    │ │ │ -00059d20: 206d 5f74 6f72 7265 6e74 7329 0a3c 2f64   m_torrents)....t->enab
    │ │ │ -00059d40: 6c65 5f61 6c6c 5f74 7261 636b 6572 7328  le_all_trackers(
    │ │ │ -00059d50: 293b 0a09 7d0a 0a09 766f 6964 2073 6573  );..}...void ses
    │ │ │ -00059d60: 7369 6f6e 5f69 6d70 6c3a 3a72 656f 7065  sion_impl::reope
    │ │ │ -00059d70: 6e5f 6e65 7477 6f72 6b5f 736f 636b 6574  n_network_socket
    │ │ │ -00059d80: 7328 7265 6f70 656e 5f6e 6574 776f 726b  s(reopen_network
    │ │ │ -00059d90: 5f66 6c61 6773 5f74 2063 6f6e 7374 206f  _flags_t const o
    │ │ │ -00059da0: 7074 696f 6e73 290a 097b 0a09 0972 656f  ptions)..{...reo
    │ │ │ -00059db0: 7065 6e5f 6c69 7374 656e 5f73 6f63 6b65  pen_listen_socke
    │ │ │ -00059dc0: 7473 2862 6f6f 6c28 6f70 7469 6f6e 7320  ts(bool(options 
    │ │ │ -00059dd0: 2661 6d70 3b20 7365 7373 696f 6e5f 6861  & session_ha
    │ │ │ -00059de0: 6e64 6c65 3a3a 7265 6f70 656e 5f6d 6170  ndle::reopen_map
    │ │ │ -00059df0: 5f70 6f72 7473 2929 3b0a 097d 0a0a 096e  _ports));..}...n
    │ │ │ -00059e00: 616d 6573 7061 6365 207b 0a09 0974 656d  amespace {...tem
    │ │ │ -00059e10: 706c 6174 6520 266c 743b 7479 7065 6e61  plate <typena
    │ │ │ -00059e20: 6d65 204d 6170 5072 6f74 6f63 6f6c 2c20  me MapProtocol, 
    │ │ │ -00059e30: 7479 7065 6e61 6d65 2050 726f 746f 5479  typename ProtoTy
    │ │ │ -00059e40: 7065 2c20 7479 7065 6e61 6d65 2045 6e64  pe, typename End
    │ │ │ -00059e50: 706f 696e 7454 7970 6526 6774 3b0a 0909  pointType>...
    │ │ │ -00059e60: 766f 6964 206d 6170 5f70 6f72 7428 4d61  void map_port(Ma
    │ │ │ -00059e70: 7050 726f 746f 636f 6c26 616d 703b 206d  pProtocol& m
    │ │ │ -00059e80: 2c20 5072 6f74 6f54 7970 6520 7072 6f74  , ProtoType prot
    │ │ │ -00059e90: 6f63 6f6c 2c20 456e 6470 6f69 6e74 5479  ocol, EndpointTy
    │ │ │ -00059ea0: 7065 2063 6f6e 7374 2661 6d70 3b20 6570  pe const& ep
    │ │ │ -00059eb0: 0a09 0909 2c20 706f 7274 5f6d 6170 7069  ...., port_mappi
    │ │ │ -00059ec0: 6e67 5f74 2661 6d70 3b20 6d61 705f 6861  ng_t& map_ha
    │ │ │ -00059ed0: 6e64 6c65 2c20 7374 643a 3a73 7472 696e  ndle, std::strin
    │ │ │ -00059ee0: 6720 636f 6e73 7426 616d 703b 2064 6576  g const& dev
    │ │ │ -00059ef0: 6963 6529 0a09 097b 0a09 0909 6966 2028  ice)...{....if (
    │ │ │ -00059f00: 6d61 705f 6861 6e64 6c65 2021 3d20 706f  map_handle != po
    │ │ │ -00059f10: 7274 5f6d 6170 7069 6e67 5f74 7b2d 317d  rt_mapping_t{-1}
    │ │ │ -00059f20: 2920 6d2e 6465 6c65 7465 5f6d 6170 7069  ) m.delete_mappi
    │ │ │ -00059f30: 6e67 286d 6170 5f68 616e 646c 6529 3b0a  ng(map_handle);.
    │ │ │ -00059f40: 0909 096d 6170 5f68 616e 646c 6520 3d20  ...map_handle = 
    │ │ │ -00059f50: 706f 7274 5f6d 6170 7069 6e67 5f74 7b2d  port_mapping_t{-
    │ │ │ -00059f60: 317d 3b0a 0a09 0909 6164 6472 6573 7320  1};.....address 
    │ │ │ -00059f70: 636f 6e73 7420 6164 6472 203d 2065 702e  const addr = ep.
    │ │ │ -00059f80: 6164 6472 6573 7328 293b 0a09 0909 2f2f  address();....//
    │ │ │ -00059f90: 2077 6974 6820 4950 7634 2074 6865 2069   with IPv4 the i
    │ │ │ -00059fa0: 6e74 6572 6661 6365 206d 6967 6874 2062  nterface might b
    │ │ │ -00059fb0: 6520 6265 6869 6e64 204e 4154 2073 6f20  e behind NAT so 
    │ │ │ -00059fc0: 7765 2063 616e 2774 2073 6b69 7020 7468  we can't skip th
    │ │ │ -00059fd0: 656d 0a09 0909 2f2f 2062 6173 6564 206f  em....// based o
    │ │ │ -00059fe0: 6e20 7468 6520 7363 6f70 6520 6f66 2074  n the scope of t
    │ │ │ -00059ff0: 6865 206c 6f63 616c 2061 6464 7265 7373  he local address
    │ │ │ -0005a000: 0a09 0909 6966 2028 6164 6472 2e69 735f  ....if (addr.is_
    │ │ │ -0005a010: 7636 2829 2026 616d 703b 2661 6d70 3b20  v6() && 
    │ │ │ -0005a020: 6973 5f6c 6f63 616c 2861 6464 7229 290a  is_local(addr)).
    │ │ │ -0005a030: 0909 0909 7265 7475 726e 3b0a 0a09 0909  ....return;.....
    │ │ │ -0005a040: 2f2f 206f 6e6c 7920 7570 6461 7465 2074  // only update t
    │ │ │ -0005a050: 6869 7320 6d61 7070 696e 6720 6966 2077  his mapping if w
    │ │ │ -0005a060: 6520 6163 7475 616c 6c79 2068 6176 6520  e actually have 
    │ │ │ -0005a070: 6120 736f 636b 6574 206c 6973 7465 6e69  a socket listeni
    │ │ │ -0005a080: 6e67 0a09 0909 6966 2028 6570 2021 3d20  ng....if (ep != 
    │ │ │ -0005a090: 456e 6470 6f69 6e74 5479 7065 2829 290a  EndpointType()).
    │ │ │ -0005a0a0: 0909 0909 6d61 705f 6861 6e64 6c65 203d  ....map_handle =
    │ │ │ -0005a0b0: 206d 2e61 6464 5f6d 6170 7069 6e67 2870   m.add_mapping(p
    │ │ │ -0005a0c0: 726f 746f 636f 6c2c 2065 702e 706f 7274  rotocol, ep.port
    │ │ │ -0005a0d0: 2829 2c20 6570 2c20 6465 7669 6365 293b  (), ep, device);
    │ │ │ -0005a0e0: 0a09 097d 0a09 7d0a 0a09 766f 6964 2073  ...}..}...void s
    │ │ │ -0005a0f0: 6573 7369 6f6e 5f69 6d70 6c3a 3a72 656d  ession_impl::rem
    │ │ │ -0005a100: 6170 5f70 6f72 7473 2872 656d 6170 5f70  ap_ports(remap_p
    │ │ │ -0005a110: 6f72 745f 6d61 736b 5f74 2063 6f6e 7374  ort_mask_t const
    │ │ │ -0005a120: 206d 6173 6b0a 0909 2c20 6c69 7374 656e   mask..., listen
    │ │ │ -0005a130: 5f73 6f63 6b65 745f 7426 616d 703b 2073  _socket_t& s
    │ │ │ -0005a140: 290a 3c2f 7072 653e 3c2f 7464 3e3c 2f74  ).
    < │ │ │ -0005a170: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0005a180: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0005a1b0: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ -0005a1c0: 2e63 7070 3a32 3939 363c 2f61 3e3c 2f74 .cpp:2996this size │ │ │ -0005a1e0: 6e65 6564 2074 6f20 6265 2063 6170 7065 need to be cappe │ │ │ -0005a1f0: 643c 2f74 643e 3c2f 7472 3e3c 7472 2069 d

    t │ │ │ -0005a240: 6869 7320 7369 7a65 206e 6565 6420 746f his size need to │ │ │ -0005a250: 2062 6520 6361 7070 6564 3c2f 6832 3e3c be capped

    < │ │ │ -0005a260: 6834 3e2e 2e2f 7372 632f 7365 7373 696f h4>../src/sessio │ │ │ -0005a270: 6e5f 696d 706c 2e63 7070 3a32 3939 363c n_impl.cpp:2996< │ │ │ -0005a280: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -0005a2c0: 0909 2f2f 2068 616e 6473 6861 6b69 6e67  ..// handshaking
    │ │ │ -0005a2d0: 0a09 0909 0972 6574 7572 6e20 736f 636b  .....return sock
    │ │ │ -0005a2e0: 6574 5f74 7970 6528 7373 6c5f 7374 7265  et_type(ssl_stre
    │ │ │ -0005a2f0: 616d 266c 743b 7463 703a 3a73 6f63 6b65  am<tcp::socke
    │ │ │ -0005a300: 7426 6774 3b28 7463 703a 3a73 6f63 6b65  t>(tcp::socke
    │ │ │ -0005a310: 7428 7374 643a 3a6d 6f76 6528 7329 292c  t(std::move(s)),
    │ │ │ -0005a320: 206d 5f70 6565 725f 7373 6c5f 6374 7829   m_peer_ssl_ctx)
    │ │ │ -0005a330: 293b 0a09 0909 7d0a 0909 0965 6c73 650a  );....}....else.
    │ │ │ -0005a340: 2365 6e64 6966 0a09 0909 7b0a 0909 0909  #endif....{.....
    │ │ │ -0005a350: 7265 7475 726e 2073 6f63 6b65 745f 7479  return socket_ty
    │ │ │ -0005a360: 7065 2874 6370 3a3a 736f 636b 6574 2873  pe(tcp::socket(s
    │ │ │ -0005a370: 7464 3a3a 6d6f 7665 2873 2929 293b 0a09  td::move(s)));..
    │ │ │ -0005a380: 0909 7d0a 0909 7d28 293b 0a0a 2369 6664  ..}...}();..#ifd
    │ │ │ -0005a390: 6566 2054 4f52 5245 4e54 5f53 534c 5f50  ef TORRENT_SSL_P
    │ │ │ -0005a3a0: 4545 5253 0a09 0954 4f52 5245 4e54 5f41  EERS...TORRENT_A
    │ │ │ -0005a3b0: 5353 4552 5428 2873 736c 203d 3d20 7472  SSERT((ssl == tr
    │ │ │ -0005a3c0: 616e 7370 6f72 743a 3a73 736c 2920 3d3d  ansport::ssl) ==
    │ │ │ -0005a3d0: 2069 735f 7373 6c28 6329 293b 0a23 656e   is_ssl(c));.#en
    │ │ │ -0005a3e0: 6469 660a 0a23 6966 6465 6620 544f 5252  dif..#ifdef TORR
    │ │ │ -0005a3f0: 454e 545f 5353 4c5f 5045 4552 530a 0909  ENT_SSL_PEERS...
    │ │ │ -0005a400: 6966 2028 7373 6c20 3d3d 2074 7261 6e73  if (ssl == trans
    │ │ │ -0005a410: 706f 7274 3a3a 7373 6c29 0a09 097b 0a09  port::ssl)...{..
    │ │ │ -0005a420: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ -0005a430: 2869 735f 7373 6c28 6329 293b 0a0a 0909  (is_ssl(c));....
    │ │ │ -0005a440: 092f 2f20 7361 7665 2074 6865 2073 6f63  .// save the soc
    │ │ │ -0005a450: 6b65 7420 736f 2077 6520 6361 6e20 6361  ket so we can ca
    │ │ │ -0005a460: 6e63 656c 2074 6865 2068 616e 6473 6861  ncel the handsha
    │ │ │ -0005a470: 6b65 0a3c 6469 7620 7374 796c 653d 2262  ke.
    ...auto iter = │ │ │ -0005a4b0: 6d5f 696e 636f 6d69 6e67 5f73 6f63 6b65 m_incoming_socke │ │ │ -0005a4c0: 7473 2e65 6d70 6c61 6365 2873 7464 3a3a ts.emplace(std:: │ │ │ -0005a4d0: 6d61 6b65 5f75 6e69 7175 6526 6c74 3b73 make_unique<s │ │ │ -0005a4e0: 6f63 6b65 745f 7479 7065 2667 743b 2873 ocket_type>(s │ │ │ -0005a4f0: 7464 3a3a 6d6f 7665 2863 2929 292e 6669 td::move(c))).fi │ │ │ -0005a500: 7273 743b 0a3c 2f64 6976 3e0a 0909 0961 rst;.
    ....a │ │ │ -0005a510: 7574 6f20 736f 636b 203d 2069 7465 722d uto sock = iter- │ │ │ -0005a520: 2667 743b 6765 7428 293b 0a09 0909 2f2f >get();....// │ │ │ -0005a530: 2066 6f72 2053 534c 2063 6f6e 6e65 6374 for SSL connect │ │ │ -0005a540: 696f 6e73 2c20 696e 636f 6d69 6e67 5f63 ions, incoming_c │ │ │ -0005a550: 6f6e 6e65 6374 696f 6e28 2920 6973 2063 onnection() is c │ │ │ -0005a560: 616c 6c65 640a 0909 092f 2f20 6166 7465 alled....// afte │ │ │ -0005a570: 7220 7468 6520 6861 6e64 7368 616b 6520 r the handshake │ │ │ -0005a580: 6973 2064 6f6e 650a 0909 0941 4444 5f4f is done....ADD_O │ │ │ -0005a590: 5554 5354 414e 4449 4e47 5f41 5359 4e43 UTSTANDING_ASYNC │ │ │ -0005a5a0: 2822 7365 7373 696f 6e5f 696d 706c 3a3a ("session_impl:: │ │ │ -0005a5b0: 7373 6c5f 6861 6e64 7368 616b 6522 293b ssl_handshake"); │ │ │ -0005a5c0: 0a09 0909 7374 643a 3a67 6574 266c 743b ....std::get< │ │ │ -0005a5d0: 7373 6c5f 7374 7265 616d 266c 743b 7463 ssl_stream<tc │ │ │ -0005a5e0: 703a 3a73 6f63 6b65 7426 6774 3b26 6774 p::socket>> │ │ │ -0005a5f0: 3b28 2a2a 6974 6572 292e 6173 796e 635f ;(**iter).async_ │ │ │ -0005a600: 6163 6365 7074 5f68 616e 6473 6861 6b65 accept_handshake │ │ │ -0005a610: 280a 0909 0909 5b74 6869 732c 2073 6f63 (.....[this, soc │ │ │ -0005a620: 6b5d 2028 6572 726f 725f 636f 6465 2063 k] (error_code c │ │ │ -0005a630: 6f6e 7374 2661 6d70 3b20 6572 7229 207b onst& err) { │ │ │ -0005a640: 2073 736c 5f68 616e 6473 6861 6b65 2865 ssl_handshake(e │ │ │ -0005a650: 7272 2c20 736f 636b 293b 207d 293b 0a09 rr, sock); });.. │ │ │ -0005a660: 097d 0a09 0965 6c73 650a 2365 6e64 6966 .}...else.#endif │ │ │ -0005a670: 0a09 097b 0a09 0909 696e 636f 6d69 6e67 ...{....incoming │ │ │ -0005a680: 5f63 6f6e 6e65 6374 696f 6e28 7374 643a _connection(std: │ │ │ -0005a690: 3a6d 6f76 6528 6329 293b 0a09 097d 0a09 :move(c));...}.. │ │ │ -0005a6a0: 7d0a 0a23 6966 6465 6620 544f 5252 454e }..#ifdef TORREN │ │ │ -0005a6b0: 545f 5353 4c5f 5045 4552 530a 0a09 766f T_SSL_PEERS...vo │ │ │ -0005a6c0: 6964 2073 6573 7369 6f6e 5f69 6d70 6c3a id session_impl: │ │ │ -0005a6d0: 3a6f 6e5f 696e 636f 6d69 6e67 5f75 7470 :on_incoming_utp │ │ │ -0005a6e0: 5f73 736c 2873 6f63 6b65 745f 7479 7065 _ssl(socket_type │ │ │ -0005a6f0: 2073 290a 097b 0a09 0954 4f52 5245 4e54 s)..{...TORRENT │ │ │ -0005a700: 5f41 5353 4552 5428 6973 5f73 736c 2873 _ASSERT(is_ssl(s │ │ │ -0005a710: 2929 3b0a 0a09 092f 2f20 7361 7665 2074 ));....// save t │ │ │ -0005a720: 6865 2073 6f63 6b65 7420 736f 2077 6520 he socket so we │ │ │ -0005a730: 6361 6e20 6361 6e63 656c 2074 6865 2068 can cancel the h │ │ │ -0005a740: 616e 6473 6861 6b65 0a0a 3c2f 7072 653e andshake..
    │ │ │ -0005a750: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0005a780: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0005a790: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/sess │ │ │ -0005a7c0: 696f 6e5f 696d 706c 2e63 7070 3a33 3032 ion_impl.cpp:302 │ │ │ -0005a7d0: 313c 2f61 3e3c 2f74 643e 3c74 643e 7468 1th │ │ │ -0005a7e0: 6973 2073 697a 6520 6e65 6564 2074 6f20 is size need to │ │ │ -0005a7f0: 6265 2063 6170 7065 643c 2f74 643e 3c2f be capped

    this size │ │ │ -0005a850: 206e 6565 6420 746f 2062 6520 6361 7070 need to be capp │ │ │ -0005a860: 6564 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 ed

    ../sr │ │ │ -0005a870: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ -0005a880: 7070 3a33 3032 313c 2f68 343e 3c70 7265 pp:3021

    ...// afte
    │ │ │ -0005a8d0: 7220 7468 6520 6861 6e64 7368 616b 6520  r the handshake 
    │ │ │ -0005a8e0: 6973 2064 6f6e 650a 0909 0941 4444 5f4f  is done....ADD_O
    │ │ │ -0005a8f0: 5554 5354 414e 4449 4e47 5f41 5359 4e43  UTSTANDING_ASYNC
    │ │ │ -0005a900: 2822 7365 7373 696f 6e5f 696d 706c 3a3a  ("session_impl::
    │ │ │ -0005a910: 7373 6c5f 6861 6e64 7368 616b 6522 293b  ssl_handshake");
    │ │ │ -0005a920: 0a09 0909 7374 643a 3a67 6574 266c 743b  ....std::get<
    │ │ │ -0005a930: 7373 6c5f 7374 7265 616d 266c 743b 7463  ssl_stream<tc
    │ │ │ -0005a940: 703a 3a73 6f63 6b65 7426 6774 3b26 6774  p::socket>>
    │ │ │ -0005a950: 3b28 2a2a 6974 6572 292e 6173 796e 635f  ;(**iter).async_
    │ │ │ -0005a960: 6163 6365 7074 5f68 616e 6473 6861 6b65  accept_handshake
    │ │ │ -0005a970: 280a 0909 0909 5b74 6869 732c 2073 6f63  (.....[this, soc
    │ │ │ -0005a980: 6b5d 2028 6572 726f 725f 636f 6465 2063  k] (error_code c
    │ │ │ -0005a990: 6f6e 7374 2661 6d70 3b20 6572 7229 207b  onst& err) {
    │ │ │ -0005a9a0: 2073 736c 5f68 616e 6473 6861 6b65 2865   ssl_handshake(e
    │ │ │ -0005a9b0: 7272 2c20 736f 636b 293b 207d 293b 0a09  rr, sock); });..
    │ │ │ -0005a9c0: 097d 0a09 0965 6c73 650a 2365 6e64 6966  .}...else.#endif
    │ │ │ -0005a9d0: 0a09 097b 0a09 0909 696e 636f 6d69 6e67  ...{....incoming
    │ │ │ -0005a9e0: 5f63 6f6e 6e65 6374 696f 6e28 7374 643a  _connection(std:
    │ │ │ -0005a9f0: 3a6d 6f76 6528 6329 293b 0a09 097d 0a09  :move(c));...}..
    │ │ │ -0005aa00: 7d0a 0a23 6966 6465 6620 544f 5252 454e  }..#ifdef TORREN
    │ │ │ -0005aa10: 545f 5353 4c5f 5045 4552 530a 0a09 766f  T_SSL_PEERS...vo
    │ │ │ -0005aa20: 6964 2073 6573 7369 6f6e 5f69 6d70 6c3a  id session_impl:
    │ │ │ -0005aa30: 3a6f 6e5f 696e 636f 6d69 6e67 5f75 7470  :on_incoming_utp
    │ │ │ -0005aa40: 5f73 736c 2873 6f63 6b65 745f 7479 7065  _ssl(socket_type
    │ │ │ -0005aa50: 2073 290a 097b 0a09 0954 4f52 5245 4e54   s)..{...TORRENT
    │ │ │ -0005aa60: 5f41 5353 4552 5428 6973 5f73 736c 2873  _ASSERT(is_ssl(s
    │ │ │ -0005aa70: 2929 3b0a 0a09 092f 2f20 7361 7665 2074  ));....// save t
    │ │ │ -0005aa80: 6865 2073 6f63 6b65 7420 736f 2077 6520  he socket so we 
    │ │ │ -0005aa90: 6361 6e20 6361 6e63 656c 2074 6865 2068  can cancel the h
    │ │ │ -0005aaa0: 616e 6473 6861 6b65 0a0a 3c64 6976 2073  andshake..
    ..auto i │ │ │ -0005aae0: 7465 7220 3d20 6d5f 696e 636f 6d69 6e67 ter = m_incoming │ │ │ -0005aaf0: 5f73 6f63 6b65 7473 2e65 6d70 6c61 6365 _sockets.emplace │ │ │ -0005ab00: 2873 7464 3a3a 6d61 6b65 5f75 6e69 7175 (std::make_uniqu │ │ │ -0005ab10: 6526 6c74 3b73 6f63 6b65 745f 7479 7065 e<socket_type │ │ │ -0005ab20: 2667 743b 2873 7464 3a3a 6d6f 7665 2873 >(std::move(s │ │ │ -0005ab30: 2929 292e 6669 7273 743b 0a3c 2f64 6976 ))).first;.
    ..auto sock = i │ │ │ -0005ab50: 7465 722d 2667 743b 6765 7428 293b 0a0a ter->get();.. │ │ │ -0005ab60: 0909 2f2f 2066 6f72 2053 534c 2063 6f6e ..// for SSL con │ │ │ -0005ab70: 6e65 6374 696f 6e73 2c20 696e 636f 6d69 nections, incomi │ │ │ -0005ab80: 6e67 5f63 6f6e 6e65 6374 696f 6e28 2920 ng_connection() │ │ │ -0005ab90: 6973 2063 616c 6c65 640a 0909 2f2f 2061 is called...// a │ │ │ -0005aba0: 6674 6572 2074 6865 2068 616e 6473 6861 fter the handsha │ │ │ -0005abb0: 6b65 2069 7320 646f 6e65 0a09 0941 4444 ke is done...ADD │ │ │ -0005abc0: 5f4f 5554 5354 414e 4449 4e47 5f41 5359 _OUTSTANDING_ASY │ │ │ -0005abd0: 4e43 2822 7365 7373 696f 6e5f 696d 706c NC("session_impl │ │ │ -0005abe0: 3a3a 7373 6c5f 6861 6e64 7368 616b 6522 ::ssl_handshake" │ │ │ -0005abf0: 293b 0a09 0973 7464 3a3a 6765 7426 6c74 );...std::get< │ │ │ -0005ac00: 3b73 736c 5f73 7472 6561 6d26 6c74 3b75 ;ssl_stream<u │ │ │ -0005ac10: 7470 5f73 7472 6561 6d26 6774 3b26 6774 tp_stream>> │ │ │ -0005ac20: 3b28 2a2a 6974 6572 292e 6173 796e 635f ;(**iter).async_ │ │ │ -0005ac30: 6163 6365 7074 5f68 616e 6473 6861 6b65 accept_handshake │ │ │ -0005ac40: 280a 0909 095b 7468 6973 2c20 736f 636b (....[this, sock │ │ │ -0005ac50: 5d20 2865 7272 6f72 5f63 6f64 6520 636f ] (error_code co │ │ │ -0005ac60: 6e73 7426 616d 703b 2065 7272 2920 7b20 nst& err) { │ │ │ -0005ac70: 7373 6c5f 6861 6e64 7368 616b 6528 6572 ssl_handshake(er │ │ │ -0005ac80: 722c 2073 6f63 6b29 3b20 7d29 3b0a 097d r, sock); });..} │ │ │ -0005ac90: 0a0a 092f 2f20 746f 2074 6573 7420 5353 ...// to test SS │ │ │ -0005aca0: 4c20 636f 6e6e 6563 7469 6f6e 732c 206f L connections, o │ │ │ -0005acb0: 6e65 2063 616e 2075 7365 2074 6869 7320 ne can use this │ │ │ -0005acc0: 6f70 656e 7373 6c20 636f 6d6d 616e 6420 openssl command │ │ │ -0005acd0: 7465 6d70 6c61 7465 3a0a 092f 2f0a 092f template:..//../ │ │ │ -0005ace0: 2f20 6f70 656e 7373 6c20 735f 636c 6965 / openssl s_clie │ │ │ -0005acf0: 6e74 202d 6365 7274 2026 6c74 3b63 6c69 nt -cert <cli │ │ │ -0005ad00: 656e 742d 6365 7274 2667 743b 2e70 656d ent-cert>.pem │ │ │ -0005ad10: 202d 6b65 7920 266c 743b 636c 6965 6e74 -key <client │ │ │ -0005ad20: 2d70 7269 7661 7465 2d6b 6579 2667 743b -private-key> │ │ │ -0005ad30: 2e70 656d 0a09 2f2f 2020 202d 4341 6669 .pem..// -CAfi │ │ │ -0005ad40: 6c65 2026 6c74 3b74 6f72 7265 6e74 2d63 le <torrent-c │ │ │ -0005ad50: 6572 7426 6774 3b2e 7065 6d20 202d 6465 ert>.pem -de │ │ │ -0005ad60: 6275 6720 2d63 6f6e 6e65 6374 2031 3237 bug -connect 127 │ │ │ -0005ad70: 2e30 2e30 2e31 3a34 3433 3320 2d74 6c73 .0.0.1:4433 -tls │ │ │ -0005ad80: 310a 092f 2f20 2020 2d73 6572 7665 726e 1..// -servern │ │ │ -0005ad90: 616d 6520 266c 743b 6865 782d 656e 636f ame <hex-enco │ │ │ -0005ada0: 6465 642d 696e 666f 2d68 6173 6826 6774 ded-info-hash> │ │ │ -0005adb0: 3b0a 0a09 766f 6964 2073 6573 7369 6f6e ;...void session │ │ │ -0005adc0: 5f69 6d70 6c3a 3a73 736c 5f68 616e 6473 _impl::ssl_hands │ │ │ -0005add0: 6861 6b65 2865 7272 6f72 5f63 6f64 6520 hake(error_code │ │ │ -0005ade0: 636f 6e73 7426 616d 703b 2065 632c 2073 const& ec, s │ │ │ -0005adf0: 6f63 6b65 745f 7479 7065 2a20 736f 636b ocket_type* sock │ │ │ -0005ae00: 290a 097b 0a09 0943 4f4d 504c 4554 455f )..{...COMPLETE_ │ │ │ -0005ae10: 4153 594e 4328 2273 6573 7369 6f6e 5f69 ASYNC("session_i │ │ │ -0005ae20: 6d70 6c3a 3a73 736c 5f68 616e 6473 6861 mpl::ssl_handsha │ │ │ -0005ae30: 6b65 2229 3b0a 0a09 0961 7574 6f20 6974 ke");....auto it │ │ │ -0005ae40: 6572 203d 206d 5f69 6e63 6f6d 696e 675f er = m_incoming_ │ │ │ -0005ae50: 736f 636b 6574 732e 6669 6e64 2873 6f63 sockets.find(soc │ │ │ -0005ae60: 6b29 3b0a 0a09 092f 2f20 7468 6973 2068 k);....// this h │ │ │ -0005ae70: 6170 7065 6e73 2069 6620 7468 6520 5353 appens if the SS │ │ │ -0005ae80: 4c20 636f 6e6e 6563 7469 6f6e 2069 7320 L connection is │ │ │ -0005ae90: 6162 6f72 7465 6420 6265 6361 7573 6520 aborted because │ │ │ -0005aea0: 7765 2772 6520 7368 7574 7469 6e67 0a09 we're shutting.. │ │ │ -0005aeb0: 092f 2f20 646f 776e 0a09 0969 6620 2869 .// down...if (i │ │ │ -0005aec0: 7465 7220 3d3d 206d 5f69 6e63 6f6d 696e ter == m_incomin │ │ │ -0005aed0: 675f 736f 636b 6574 732e 656e 6428 2929 g_sockets.end()) │ │ │ -0005aee0: 2072 6574 7572 6e3b 0a0a 0909 736f 636b return;....sock │ │ │ -0005aef0: 6574 5f74 7970 6520 7328 7374 643a 3a6d et_type s(std::m │ │ │ -0005af00: 6f76 6528 2a2a 6974 6572 2929 3b0a 0909 ove(**iter));... │ │ │ -0005af10: 544f 5252 454e 545f 4153 5345 5254 2869 TORRENT_ASSERT(i │ │ │ -0005af20: 735f 7373 6c28 7329 293b 0a09 096d 5f69 s_ssl(s));...m_i │ │ │ -0005af30: 6e63 6f6d 696e 675f 736f 636b 6574 732e ncoming_sockets. │ │ │ -0005af40: 6572 6173 6528 6974 6572 293b 0a0a 0909 erase(iter);.... │ │ │ -0005af50: 6572 726f 725f 636f 6465 2065 3b0a 3c2f error_code e;.r │ │ │ -0005af90: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -0005afa0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -0005afd0: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ -0005afe0: 3a33 3733 333c 2f61 3e3c 2f74 643e 3c74 :3733have a separat │ │ │ -0005b000: 6520 6c69 7374 2066 6f72 2074 6865 7365 e list for these │ │ │ -0005b010: 2063 6f6e 6e65 6374 696f 6e73 2c20 696e connections, in │ │ │ -0005b020: 7374 6561 6420 6f66 2068 6176 696e 6720 stead of having │ │ │ -0005b030: 746f 206c 6f6f 7020 7468 726f 7567 6820 to loop through │ │ │ -0005b040: 616c 6c20 6f66 2074 6865 6d3c 2f74 643e all of them │ │ │ -0005b050: 3c2f 7472 3e3c 7472 2069 643d 2232 3132

    have a │ │ │ -0005b0a0: 7365 7061 7261 7465 206c 6973 7420 666f separate list fo │ │ │ -0005b0b0: 7220 7468 6573 6520 636f 6e6e 6563 7469 r these connecti │ │ │ -0005b0c0: 6f6e 732c 2069 6e73 7465 6164 206f 6620 ons, instead of │ │ │ -0005b0d0: 6861 7669 6e67 2074 6f20 6c6f 6f70 2074 having to loop t │ │ │ -0005b0e0: 6872 6f75 6768 2061 6c6c 206f 6620 7468 hrough all of th │ │ │ -0005b0f0: 656d 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 em

    ../sr │ │ │ -0005b100: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ -0005b110: 7070 3a33 3733 333c 2f68 343e 3c70 7265 pp:3733

    ..// -----
    │ │ │ -0005b160: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0005b170: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0005b180: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0005b190: 2d2d 2d2d 2d2d 2d2d 2d0a 0909 6966 2028  ---------...if (
    │ │ │ -0005b1a0: 216d 5f70 6175 7365 6429 206d 5f61 7574  !m_paused) m_aut
    │ │ │ -0005b1b0: 6f5f 6d61 6e61 6765 5f74 696d 655f 7363  o_manage_time_sc
    │ │ │ -0005b1c0: 616c 6572 2d2d 3b0a 0909 6966 2028 6d5f  aler--;...if (m_
    │ │ │ -0005b1d0: 6175 746f 5f6d 616e 6167 655f 7469 6d65  auto_manage_time
    │ │ │ -0005b1e0: 5f73 6361 6c65 7220 266c 743b 2030 290a  _scaler < 0).
    │ │ │ -0005b1f0: 0909 7b0a 0909 096d 5f61 7574 6f5f 6d61  ..{....m_auto_ma
    │ │ │ -0005b200: 6e61 6765 5f74 696d 655f 7363 616c 6572  nage_time_scaler
    │ │ │ -0005b210: 203d 2073 6574 7469 6e67 7328 292e 6765   = settings().ge
    │ │ │ -0005b220: 745f 696e 7428 7365 7474 696e 6773 5f70  t_int(settings_p
    │ │ │ -0005b230: 6163 6b3a 3a61 7574 6f5f 6d61 6e61 6765  ack::auto_manage
    │ │ │ -0005b240: 5f69 6e74 6572 7661 6c29 3b0a 0909 0972  _interval);....r
    │ │ │ -0005b250: 6563 616c 6375 6c61 7465 5f61 7574 6f5f  ecalculate_auto_
    │ │ │ -0005b260: 6d61 6e61 6765 645f 746f 7272 656e 7473  managed_torrents
    │ │ │ -0005b270: 2829 3b0a 0909 7d0a 0a09 092f 2f20 2d2d  ();...}....// --
    │ │ │ -0005b280: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0005b290: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0005b2a0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0005b2b0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 0a09 092f  ------------.../
    │ │ │ -0005b2c0: 2f20 6368 6563 6b20 666f 7220 696e 636f  / check for inco
    │ │ │ -0005b2d0: 6d69 6e67 2063 6f6e 6e65 6374 696f 6e73  ming connections
    │ │ │ -0005b2e0: 2074 6861 7420 6d69 6768 7420 6861 7665   that might have
    │ │ │ -0005b2f0: 2074 696d 6564 206f 7574 0a09 092f 2f20   timed out...// 
    │ │ │ -0005b300: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0005b310: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0005b320: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ -0005b330: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 0a0a  --------------..
    │ │ │ -0005b340: 0909 666f 7220 2861 7574 6f20 6920 3d20  ..for (auto i = 
    │ │ │ -0005b350: 6d5f 636f 6e6e 6563 7469 6f6e 732e 6265  m_connections.be
    │ │ │ -0005b360: 6769 6e28 293b 2069 2021 3d20 6d5f 636f  gin(); i != m_co
    │ │ │ -0005b370: 6e6e 6563 7469 6f6e 732e 656e 6428 293b  nnections.end();
    │ │ │ -0005b380: 290a 0909 7b0a 0909 0970 6565 725f 636f  )...{....peer_co
    │ │ │ -0005b390: 6e6e 6563 7469 6f6e 2a20 7020 3d20 282a  nnection* p = (*
    │ │ │ -0005b3a0: 6929 2e67 6574 2829 3b0a 0909 092b 2b69  i).get();....++i
    │ │ │ -0005b3b0: 3b0a 0909 092f 2f20 6967 6e6f 7265 2063  ;....// ignore c
    │ │ │ -0005b3c0: 6f6e 6e65 6374 696f 6e73 2074 6861 7420  onnections that 
    │ │ │ -0005b3d0: 616c 7265 6164 7920 6861 7665 2061 2074  already have a t
    │ │ │ -0005b3e0: 6f72 7265 6e74 2c20 7369 6e63 6520 7468  orrent, since th
    │ │ │ -0005b3f0: 6579 0a09 0909 2f2f 2061 7265 2074 6963  ey....// are tic
    │ │ │ -0005b400: 6b65 6420 7468 726f 7567 6820 7468 6520  ked through the 
    │ │ │ -0005b410: 746f 7272 656e 7473 2720 7365 636f 6e64  torrents' second
    │ │ │ -0005b420: 5f74 6963 6b0a 0909 0969 6620 2821 702d  _tick....if (!p-
    │ │ │ -0005b430: 2667 743b 6173 736f 6369 6174 6564 5f74  >associated_t
    │ │ │ -0005b440: 6f72 7265 6e74 2829 2e65 7870 6972 6564  orrent().expired
    │ │ │ -0005b450: 2829 2920 636f 6e74 696e 7565 3b0a 0a3c  ()) continue;..<
    │ │ │ -0005b460: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -0005b470: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -0005b480: 7769 6474 683d 2231 3030 2522 3e09 0909  width="100%">...
    │ │ │ -0005b490: 696e 7420 7469 6d65 6f75 7420 3d20 6d5f  int timeout = m_
    │ │ │ -0005b4a0: 7365 7474 696e 6773 2e67 6574 5f69 6e74  settings.get_int
    │ │ │ -0005b4b0: 2873 6574 7469 6e67 735f 7061 636b 3a3a  (settings_pack::
    │ │ │ -0005b4c0: 6861 6e64 7368 616b 655f 7469 6d65 6f75  handshake_timeou
    │ │ │ -0005b4d0: 7429 3b0a 3c2f 6469 763e 2369 6620 544f  t);.
    #if TO │ │ │ -0005b4e0: 5252 454e 545f 5553 455f 4932 500a 0909 RRENT_USE_I2P... │ │ │ -0005b4f0: 0974 696d 656f 7574 202a 3d20 6973 5f69 .timeout *= is_i │ │ │ -0005b500: 3270 2870 2d26 6774 3b67 6574 5f73 6f63 2p(p->get_soc │ │ │ -0005b510: 6b65 7428 2929 203f 2034 203a 2031 3b0a ket()) ? 4 : 1;. │ │ │ -0005b520: 2365 6e64 6966 0a09 0909 6966 2028 6d5f #endif....if (m_ │ │ │ -0005b530: 6c61 7374 5f74 6963 6b20 2d20 702d 2667 last_tick - p-&g │ │ │ -0005b540: 743b 636f 6e6e 6563 7465 645f 7469 6d65 t;connected_time │ │ │ -0005b550: 2028 2920 2667 743b 2073 6563 6f6e 6473 () > seconds │ │ │ -0005b560: 2874 696d 656f 7574 2929 0a09 0909 0970 (timeout)).....p │ │ │ -0005b570: 2d26 6774 3b64 6973 636f 6e6e 6563 7428 ->disconnect( │ │ │ -0005b580: 6572 726f 7273 3a3a 7469 6d65 645f 6f75 errors::timed_ou │ │ │ -0005b590: 742c 206f 7065 7261 7469 6f6e 5f74 3a3a t, operation_t:: │ │ │ -0005b5a0: 6269 7474 6f72 7265 6e74 293b 0a09 097d bittorrent);...} │ │ │ -0005b5b0: 0a0a 0909 2f2f 202d 2d2d 2d2d 2d2d 2d2d ....// --------- │ │ │ -0005b5c0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0005b5d0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0005b5e0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0005b5f0: 2d2d 2d2d 2d0a 0909 2f2f 2073 6563 6f6e -----...// secon │ │ │ -0005b600: 645f 7469 636b 2065 7665 7279 2074 6f72 d_tick every tor │ │ │ -0005b610: 7265 6e74 2028 7468 6174 2077 616e 7473 rent (that wants │ │ │ -0005b620: 2069 7429 0a09 092f 2f20 2d2d 2d2d 2d2d it)...// ------ │ │ │ -0005b630: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0005b640: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0005b650: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0005b660: 2d2d 2d2d 2d2d 2d2d 0a0a 2369 6620 544f --------..#if TO │ │ │ -0005b670: 5252 454e 545f 4445 4255 475f 5354 5245 RRENT_DEBUG_STRE │ │ │ -0005b680: 414d 494e 4720 2667 743b 2030 0a09 0973 AMING > 0...s │ │ │ -0005b690: 7464 3a3a 7072 696e 7466 2822 5c30 3333 td::printf("\033 │ │ │ -0005b6a0: 5b32 4a5c 3033 335b 303b 3048 2229 3b0a [2J\033[0;0H");. │ │ │ -0005b6b0: 2365 6e64 6966 0a0a 0909 6175 783a 3a76 #endif....aux::v │ │ │ -0005b6c0: 6563 746f 7226 6c74 3b74 6f72 7265 6e74 ector<torrent │ │ │ -0005b6d0: 2a26 6774 3b26 616d 703b 2077 616e 745f *>& want_ │ │ │ -0005b6e0: 7469 636b 203d 206d 5f74 6f72 7265 6e74 tick = m_torrent │ │ │ -0005b6f0: 5f6c 6973 7473 5b74 6f72 7265 6e74 5f77 _lists[torrent_w │ │ │ -0005b700: 616e 745f 7469 636b 5d3b 0a09 0966 6f72 ant_tick];...for │ │ │ -0005b710: 2028 696e 7420 6920 3d20 303b 2069 2026 (int i = 0; i & │ │ │ -0005b720: 6c74 3b20 696e 7428 7761 6e74 5f74 6963 lt; int(want_tic │ │ │ -0005b730: 6b2e 7369 7a65 2829 293b 202b 2b69 290a k.size()); ++i). │ │ │ -0005b740: 0909 7b0a 0909 0974 6f72 7265 6e74 2661 ..{....torrent&a │ │ │ -0005b750: 6d70 3b20 7420 3d20 2a77 616e 745f 7469 mp; t = *want_ti │ │ │ -0005b760: 636b 5b69 5d3b 0a09 0909 544f 5252 454e ck[i];....TORREN │ │ │ -0005b770: 545f 4153 5345 5254 2874 2e77 616e 745f T_ASSERT(t.want_ │ │ │ -0005b780: 7469 636b 2829 293b 0a09 0909 544f 5252 tick());....TORR │ │ │ -0005b790: 454e 545f 4153 5345 5254 2821 742e 6973 ENT_ASSERT(!t.is │ │ │ -0005b7a0: 5f61 626f 7274 6564 2829 293b 0a0a 0909 _aborted());.... │ │ │ -0005b7b0: 0974 2e73 6563 6f6e 645f 7469 636b 2874 .t.second_tick(t │ │ │ -0005b7c0: 6963 6b5f 696e 7465 7276 616c 5f6d 7329 ick_interval_ms) │ │ │ -0005b7d0: 3b0a 0a09 0909 2f2f 2069 6620 7468 6520 ;.....// if the │ │ │ -0005b7e0: 6361 6c6c 2074 6f20 7365 636f 6e64 5f74 call to second_t │ │ │ -0005b7f0: 6963 6b20 6361 7573 6564 2074 6865 2074 ick caused the t │ │ │ -0005b800: 6f72 7265 6e74 0a09 0909 2f2f 2074 6f20 orrent....// to │ │ │ -0005b810: 6e6f 206c 6f6e 6765 7220 7761 6e74 2074 no longer want t │ │ │ -0005b820: 6f20 6265 2074 6963 6b65 6420 2869 2e65 o be ticked (i.e │ │ │ -0005b830: 2e20 6974 2077 6173 0a09 0909 2f2f 2072 . it was....// r │ │ │ -0005b840: 656d 6f76 6564 2066 726f 6d20 7468 6520 emoved from the │ │ │ -0005b850: 6c69 7374 2920 7765 206e 6565 6420 746f list) we need to │ │ │ -0005b860: 2062 6163 6b20 7570 2074 6865 2063 6f75 back up the cou │ │ │ -0005b870: 6e74 6572 0a09 0909 2f2f 2074 6f20 6e6f nter....// to no │ │ │ -0005b880: 7420 6d69 7373 2074 6865 2074 6f72 7265 t miss the torre │ │ │ -0005b890: 6e74 2061 6674 6572 2069 740a 0909 0969 nt after it....i │ │ │ -0005b8a0: 6620 2821 742e 7761 6e74 5f74 6963 6b28 f (!t.want_tick( │ │ │ -0005b8b0: 2929 202d 2d69 3b0a 0909 7d0a 3c2f 7072 )) --i;...}.rel │ │ │ -0005b8f0: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/se │ │ │ -0005b930: 7373 696f 6e5f 696d 706c 2e63 7070 3a33 ssion_impl.cpp:3 │ │ │ -0005b940: 3736 363c 2f61 3e3c 2f74 643e 3c74 643e 766 │ │ │ -0005b950: 7468 6973 2073 686f 756c 6420 6170 706c this should appl │ │ │ -0005b960: 7920 746f 2061 6c6c 2062 616e 6477 6964 y to all bandwid │ │ │ -0005b970: 7468 2063 6861 6e6e 656c 733c 2f74 643e th channels │ │ │ -0005b980: 3c2f 7472 3e3c 7472 2069 643d 2232 3133

    this sh │ │ │ -0005b9d0: 6f75 6c64 2061 7070 6c79 2074 6f20 616c ould apply to al │ │ │ -0005b9e0: 6c20 6261 6e64 7769 6474 6820 6368 616e l bandwidth chan │ │ │ -0005b9f0: 6e65 6c73 3c2f 6832 3e3c 6834 3e2e 2e2f nels

    ../ │ │ │ -0005ba00: 7372 632f 7365 7373 696f 6e5f 696d 706c src/session_impl │ │ │ -0005ba10: 2e63 7070 3a33 3736 363c 2f68 343e 3c70 .cpp:3766

    #if TORR │ │ │ -0005ba60: 454e 545f 4445 4255 475f 5354 5245 414d ENT_DEBUG_STREAM │ │ │ -0005ba70: 494e 4720 2667 743b 2030 0a09 0973 7464 ING > 0...std │ │ │ -0005ba80: 3a3a 7072 696e 7466 2822 5c30 3333 5b32 ::printf("\033[2 │ │ │ -0005ba90: 4a5c 3033 335b 303b 3048 2229 3b0a 2365 J\033[0;0H");.#e │ │ │ -0005baa0: 6e64 6966 0a0a 0909 6175 783a 3a76 6563 ndif....aux::vec │ │ │ -0005bab0: 746f 7226 6c74 3b74 6f72 7265 6e74 2a26 tor<torrent*& │ │ │ -0005bac0: 6774 3b26 616d 703b 2077 616e 745f 7469 gt;& want_ti │ │ │ -0005bad0: 636b 203d 206d 5f74 6f72 7265 6e74 5f6c ck = m_torrent_l │ │ │ -0005bae0: 6973 7473 5b74 6f72 7265 6e74 5f77 616e ists[torrent_wan │ │ │ -0005baf0: 745f 7469 636b 5d3b 0a09 0966 6f72 2028 t_tick];...for ( │ │ │ -0005bb00: 696e 7420 6920 3d20 303b 2069 2026 6c74 int i = 0; i < │ │ │ -0005bb10: 3b20 696e 7428 7761 6e74 5f74 6963 6b2e ; int(want_tick. │ │ │ -0005bb20: 7369 7a65 2829 293b 202b 2b69 290a 0909 size()); ++i)... │ │ │ -0005bb30: 7b0a 0909 0974 6f72 7265 6e74 2661 6d70 {....torrent& │ │ │ -0005bb40: 3b20 7420 3d20 2a77 616e 745f 7469 636b ; t = *want_tick │ │ │ -0005bb50: 5b69 5d3b 0a09 0909 544f 5252 454e 545f [i];....TORRENT_ │ │ │ -0005bb60: 4153 5345 5254 2874 2e77 616e 745f 7469 ASSERT(t.want_ti │ │ │ -0005bb70: 636b 2829 293b 0a09 0909 544f 5252 454e ck());....TORREN │ │ │ -0005bb80: 545f 4153 5345 5254 2821 742e 6973 5f61 T_ASSERT(!t.is_a │ │ │ -0005bb90: 626f 7274 6564 2829 293b 0a0a 0909 0974 borted());.....t │ │ │ -0005bba0: 2e73 6563 6f6e 645f 7469 636b 2874 6963 .second_tick(tic │ │ │ -0005bbb0: 6b5f 696e 7465 7276 616c 5f6d 7329 3b0a k_interval_ms);. │ │ │ -0005bbc0: 0a09 0909 2f2f 2069 6620 7468 6520 6361 ....// if the ca │ │ │ -0005bbd0: 6c6c 2074 6f20 7365 636f 6e64 5f74 6963 ll to second_tic │ │ │ -0005bbe0: 6b20 6361 7573 6564 2074 6865 2074 6f72 k caused the tor │ │ │ -0005bbf0: 7265 6e74 0a09 0909 2f2f 2074 6f20 6e6f rent....// to no │ │ │ -0005bc00: 206c 6f6e 6765 7220 7761 6e74 2074 6f20 longer want to │ │ │ -0005bc10: 6265 2074 6963 6b65 6420 2869 2e65 2e20 be ticked (i.e. │ │ │ -0005bc20: 6974 2077 6173 0a09 0909 2f2f 2072 656d it was....// rem │ │ │ -0005bc30: 6f76 6564 2066 726f 6d20 7468 6520 6c69 oved from the li │ │ │ -0005bc40: 7374 2920 7765 206e 6565 6420 746f 2062 st) we need to b │ │ │ -0005bc50: 6163 6b20 7570 2074 6865 2063 6f75 6e74 ack up the count │ │ │ -0005bc60: 6572 0a09 0909 2f2f 2074 6f20 6e6f 7420 er....// to not │ │ │ -0005bc70: 6d69 7373 2074 6865 2074 6f72 7265 6e74 miss the torrent │ │ │ -0005bc80: 2061 6674 6572 2069 740a 0909 0969 6620 after it....if │ │ │ -0005bc90: 2821 742e 7761 6e74 5f74 6963 6b28 2929 (!t.want_tick()) │ │ │ -0005bca0: 202d 2d69 3b0a 0909 7d0a 0a3c 6469 7620 --i;...}..

    ..if (m │ │ │ -0005bce0: 5f73 6574 7469 6e67 732e 6765 745f 626f _settings.get_bo │ │ │ -0005bcf0: 6f6c 2873 6574 7469 6e67 735f 7061 636b ol(settings_pack │ │ │ -0005bd00: 3a3a 7261 7465 5f6c 696d 6974 5f69 705f ::rate_limit_ip_ │ │ │ -0005bd10: 6f76 6572 6865 6164 2929 0a3c 2f64 6976 overhead)).
    ..{....int cons │ │ │ -0005bd30: 7420 7570 5f6c 696d 6974 203d 2075 706c t up_limit = upl │ │ │ -0005bd40: 6f61 645f 7261 7465 5f6c 696d 6974 286d oad_rate_limit(m │ │ │ -0005bd50: 5f67 6c6f 6261 6c5f 636c 6173 7329 3b0a _global_class);. │ │ │ -0005bd60: 0909 0969 6e74 2063 6f6e 7374 2064 6f77 ...int const dow │ │ │ -0005bd70: 6e5f 6c69 6d69 7420 3d20 646f 776e 6c6f n_limit = downlo │ │ │ -0005bd80: 6164 5f72 6174 655f 6c69 6d69 7428 6d5f ad_rate_limit(m_ │ │ │ -0005bd90: 676c 6f62 616c 5f63 6c61 7373 293b 0a0a global_class);.. │ │ │ -0005bda0: 0909 0969 6620 2864 6f77 6e5f 6c69 6d69 ...if (down_limi │ │ │ -0005bdb0: 7420 2667 743b 2030 0a09 0909 0926 616d t > 0.....&am │ │ │ -0005bdc0: 703b 2661 6d70 3b20 6d5f 7374 6174 2e64 p;& m_stat.d │ │ │ -0005bdd0: 6f77 6e6c 6f61 645f 6970 5f6f 7665 7268 ownload_ip_overh │ │ │ -0005bde0: 6561 6428 2920 2667 743b 3d20 646f 776e ead() >= down │ │ │ -0005bdf0: 5f6c 696d 6974 0a09 0909 0926 616d 703b _limit.....& │ │ │ -0005be00: 2661 6d70 3b20 6d5f 616c 6572 7473 2e73 & m_alerts.s │ │ │ -0005be10: 686f 756c 645f 706f 7374 266c 743b 7065 hould_post<pe │ │ │ -0005be20: 7266 6f72 6d61 6e63 655f 616c 6572 7426 rformance_alert& │ │ │ -0005be30: 6774 3b28 2929 0a09 0909 7b0a 0909 0909 gt;())....{..... │ │ │ -0005be40: 6d5f 616c 6572 7473 2e65 6d70 6c61 6365 m_alerts.emplace │ │ │ -0005be50: 5f61 6c65 7274 266c 743b 7065 7266 6f72 _alert<perfor │ │ │ -0005be60: 6d61 6e63 655f 616c 6572 7426 6774 3b28 mance_alert>( │ │ │ -0005be70: 746f 7272 656e 745f 6861 6e64 6c65 2829 torrent_handle() │ │ │ -0005be80: 0a09 0909 0909 2c20 7065 7266 6f72 6d61 ......, performa │ │ │ -0005be90: 6e63 655f 616c 6572 743a 3a64 6f77 6e6c nce_alert::downl │ │ │ -0005bea0: 6f61 645f 6c69 6d69 745f 746f 6f5f 6c6f oad_limit_too_lo │ │ │ -0005beb0: 7729 3b0a 0909 097d 0a0a 0909 0969 6620 w);....}.....if │ │ │ -0005bec0: 2875 705f 6c69 6d69 7420 2667 743b 2030 (up_limit > 0 │ │ │ -0005bed0: 0a09 0909 0926 616d 703b 2661 6d70 3b20 .....&& │ │ │ -0005bee0: 6d5f 7374 6174 2e75 706c 6f61 645f 6970 m_stat.upload_ip │ │ │ -0005bef0: 5f6f 7665 7268 6561 6428 2920 2667 743b _overhead() > │ │ │ -0005bf00: 3d20 7570 5f6c 696d 6974 0a09 0909 0926 = up_limit.....& │ │ │ -0005bf10: 616d 703b 2661 6d70 3b20 6d5f 616c 6572 amp;& m_aler │ │ │ -0005bf20: 7473 2e73 686f 756c 645f 706f 7374 266c ts.should_post&l │ │ │ -0005bf30: 743b 7065 7266 6f72 6d61 6e63 655f 616c t;performance_al │ │ │ -0005bf40: 6572 7426 6774 3b28 2929 0a09 0909 7b0a ert>())....{. │ │ │ -0005bf50: 0909 0909 6d5f 616c 6572 7473 2e65 6d70 ....m_alerts.emp │ │ │ -0005bf60: 6c61 6365 5f61 6c65 7274 266c 743b 7065 lace_alert<pe │ │ │ -0005bf70: 7266 6f72 6d61 6e63 655f 616c 6572 7426 rformance_alert& │ │ │ -0005bf80: 6774 3b28 746f 7272 656e 745f 6861 6e64 gt;(torrent_hand │ │ │ -0005bf90: 6c65 2829 0a09 0909 0909 2c20 7065 7266 le()......, perf │ │ │ -0005bfa0: 6f72 6d61 6e63 655f 616c 6572 743a 3a75 ormance_alert::u │ │ │ -0005bfb0: 706c 6f61 645f 6c69 6d69 745f 746f 6f5f pload_limit_too_ │ │ │ -0005bfc0: 6c6f 7729 3b0a 0909 097d 0a09 097d 0a0a low);....}...}.. │ │ │ -0005bfd0: 2369 6620 544f 5252 454e 545f 4142 495f #if TORRENT_ABI_ │ │ │ -0005bfe0: 5645 5253 494f 4e20 3d3d 2031 0a09 096d VERSION == 1...m │ │ │ -0005bff0: 5f70 6561 6b5f 7570 5f72 6174 6520 3d20 _peak_up_rate = │ │ │ -0005c000: 7374 643a 3a6d 6178 286d 5f73 7461 742e std::max(m_stat. │ │ │ -0005c010: 7570 6c6f 6164 5f72 6174 6528 292c 206d upload_rate(), m │ │ │ -0005c020: 5f70 6561 6b5f 7570 5f72 6174 6529 3b0a _peak_up_rate);. │ │ │ -0005c030: 2365 6e64 6966 0a0a 0909 6d5f 7374 6174 #endif....m_stat │ │ │ -0005c040: 2e73 6563 6f6e 645f 7469 636b 2874 6963 .second_tick(tic │ │ │ -0005c050: 6b5f 696e 7465 7276 616c 5f6d 7329 3b0a k_interval_ms);. │ │ │ -0005c060: 0a09 092f 2f20 2d2d 2d2d 2d2d 2d2d 2d2d ...// ---------- │ │ │ -0005c070: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0005c080: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0005c090: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ -0005c0a0: 2d2d 2d2d 0a09 092f 2f20 7363 7261 7065 ----...// scrape │ │ │ -0005c0b0: 2070 6175 7365 6420 746f 7272 656e 7473 paused torrents │ │ │ -0005c0c0: 2074 6861 7420 6172 6520 6175 746f 206d that are auto m │ │ │ -0005c0d0: 616e 6167 6564 0a09 092f 2f20 2875 6e6c anaged...// (unl │ │ │ -0005c0e0: 6573 7320 7468 6520 7365 7373 696f 6e20 ess the session │ │ │ -0005c0f0: 6973 2070 6175 7365 6429 0a3c 2f70 7265 is paused).rele │ │ │ -0005c130: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/ses │ │ │ -0005c170: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3435 sion_impl.cpp:45 │ │ │ -0005c180: 3231 3c2f 613e 3c2f 7464 3e3c 7464 3e75 21u │ │ │ -0005c190: 7365 2061 206c 6f77 6572 206c 696d 6974 se a lower limit │ │ │ -0005c1a0: 2074 6861 6e20 6d5f 7365 7474 696e 6773 than m_settings │ │ │ -0005c1b0: 2e63 6f6e 6e65 6374 696f 6e73 5f6c 696d .connections_lim │ │ │ -0005c1c0: 6974 2074 6f20 616c 6c6f 6361 7465 2074 it to allocate t │ │ │ -0005c1d0: 6865 2074 6f20 3130 2520 6f72 2073 6f20 he to 10% or so │ │ │ -0005c1e0: 6f66 2063 6f6e 6e65 6374 696f 6e20 736c of connection sl │ │ │ -0005c1f0: 6f74 7320 666f 7220 696e 636f 6d69 6e67 ots for incoming │ │ │ -0005c200: 2063 6f6e 6e65 6374 696f 6e73 2063 6170 connections cap │ │ │ -0005c210: 2074 6869 7320 6174 206d 6178 202d 2031 this at max - 1 │ │ │ -0005c220: 2c20 7369 6e63 6520 7765 206d 6179 2061 , since we may a │ │ │ -0005c230: 6464 206f 6e65 2062 656c 6f77 3c2f 7464 dd one below

    use a │ │ │ -0005c290: 6c6f 7765 7220 6c69 6d69 7420 7468 616e lower limit than │ │ │ -0005c2a0: 206d 5f73 6574 7469 6e67 732e 636f 6e6e m_settings.conn │ │ │ -0005c2b0: 6563 7469 6f6e 735f 6c69 6d69 740a 746f ections_limit.to │ │ │ -0005c2c0: 2061 6c6c 6f63 6174 6520 7468 6520 746f allocate the to │ │ │ -0005c2d0: 2031 3025 206f 7220 736f 206f 6620 636f 10% or so of co │ │ │ -0005c2e0: 6e6e 6563 7469 6f6e 2073 6c6f 7473 2066 nnection slots f │ │ │ -0005c2f0: 6f72 2069 6e63 6f6d 696e 670a 636f 6e6e or incoming.conn │ │ │ -0005c300: 6563 7469 6f6e 730a 6361 7020 7468 6973 ections.cap this │ │ │ -0005c310: 2061 7420 6d61 7820 2d20 312c 2073 696e at max - 1, sin │ │ │ -0005c320: 6365 2077 6520 6d61 7920 6164 6420 6f6e ce we may add on │ │ │ -0005c330: 6520 6265 6c6f 773c 2f68 323e 3c68 343e e below

    │ │ │ -0005c340: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ -0005c350: 6d70 6c2e 6370 703a 3435 3231 3c2f 6834 mpl.cpp:4521

    ..// 
    │ │ │ -0005c3a0: 626f 6f73 742c 2077 6869 6368 2061 7265  boost, which are
    │ │ │ -0005c3b0: 2064 6f6e 6520 696d 6d65 6469 6174 656c   done immediatel
    │ │ │ -0005c3c0: 7920 6f6e 2061 2074 7261 636b 6572 2072  y on a tracker r
    │ │ │ -0005c3d0: 6573 706f 6e73 652e 2054 6865 7365 0a09  esponse. These..
    │ │ │ -0005c3e0: 092f 2f20 636f 6e6e 6563 7469 6f6e 7320  .// connections 
    │ │ │ -0005c3f0: 6e65 6564 7320 746f 2062 6520 6465 6475  needs to be dedu
    │ │ │ -0005c400: 6374 6564 2066 726f 6d20 7468 6520 7265  cted from the re
    │ │ │ -0005c410: 6775 6c61 7220 636f 6e6e 6563 7469 6f6e  gular connection
    │ │ │ -0005c420: 2061 7474 656d 7074 0a09 092f 2f20 7175   attempt...// qu
    │ │ │ -0005c430: 6f74 6120 666f 7220 7468 6973 2074 6963  ota for this tic
    │ │ │ -0005c440: 6b0a 0909 6966 2028 6d5f 626f 6f73 745f  k...if (m_boost_
    │ │ │ -0005c450: 636f 6e6e 6563 7469 6f6e 7320 2667 743b  connections >
    │ │ │ -0005c460: 2030 290a 0909 7b0a 0909 0969 6620 286d   0)...{....if (m
    │ │ │ -0005c470: 5f62 6f6f 7374 5f63 6f6e 6e65 6374 696f  _boost_connectio
    │ │ │ -0005c480: 6e73 2026 6774 3b20 6d61 785f 636f 6e6e  ns > max_conn
    │ │ │ -0005c490: 6563 7469 6f6e 7329 0a09 0909 7b0a 0909  ections)....{...
    │ │ │ -0005c4a0: 0909 6d5f 626f 6f73 745f 636f 6e6e 6563  ..m_boost_connec
    │ │ │ -0005c4b0: 7469 6f6e 7320 2d3d 206d 6178 5f63 6f6e  tions -= max_con
    │ │ │ -0005c4c0: 6e65 6374 696f 6e73 3b0a 0909 0909 6d61  nections;.....ma
    │ │ │ -0005c4d0: 785f 636f 6e6e 6563 7469 6f6e 7320 3d20  x_connections = 
    │ │ │ -0005c4e0: 303b 0a09 0909 7d0a 0909 0965 6c73 650a  0;....}....else.
    │ │ │ -0005c4f0: 0909 097b 0a09 0909 096d 6178 5f63 6f6e  ...{.....max_con
    │ │ │ -0005c500: 6e65 6374 696f 6e73 202d 3d20 6d5f 626f  nections -= m_bo
    │ │ │ -0005c510: 6f73 745f 636f 6e6e 6563 7469 6f6e 733b  ost_connections;
    │ │ │ -0005c520: 0a09 0909 096d 5f62 6f6f 7374 5f63 6f6e  .....m_boost_con
    │ │ │ -0005c530: 6e65 6374 696f 6e73 203d 2030 3b0a 0909  nections = 0;...
    │ │ │ -0005c540: 097d 0a09 097d 0a0a 0909 2f2f 207a 6572  .}...}....// zer
    │ │ │ -0005c550: 6f20 636f 6e6e 6563 7469 6f6e 7320 7370  o connections sp
    │ │ │ -0005c560: 6565 6473 2061 7265 2061 6c6c 6f77 6564  eeds are allowed
    │ │ │ -0005c570: 2c20 7765 206a 7573 7420 776f 6e27 7420  , we just won't 
    │ │ │ -0005c580: 6d61 6b65 2061 6e79 2063 6f6e 6e65 6374  make any connect
    │ │ │ -0005c590: 696f 6e73 0a09 0969 6620 286d 6178 5f63  ions...if (max_c
    │ │ │ -0005c5a0: 6f6e 6e65 6374 696f 6e73 2026 6c74 3b3d  onnections <=
    │ │ │ -0005c5b0: 2030 2920 7265 7475 726e 3b0a 0a3c 6469   0) return;....int
    │ │ │ -0005c5f0: 2063 6f6e 7374 206c 696d 6974 203d 2073   const limit = s
    │ │ │ -0005c600: 7464 3a3a 6d69 6e28 6d5f 7365 7474 696e  td::min(m_settin
    │ │ │ -0005c610: 6773 2e67 6574 5f69 6e74 2873 6574 7469  gs.get_int(setti
    │ │ │ -0005c620: 6e67 735f 7061 636b 3a3a 636f 6e6e 6563  ngs_pack::connec
    │ │ │ -0005c630: 7469 6f6e 735f 6c69 6d69 7429 0a3c 2f64  tions_limit)....- num_conn
    │ │ │ -0005c650: 6563 7469 6f6e 7328 292c 2073 7464 3a3a  ections(), std::
    │ │ │ -0005c660: 6e75 6d65 7269 635f 6c69 6d69 7473 266c  numeric_limits&l
    │ │ │ -0005c670: 743b 696e 7426 6774 3b3a 3a6d 6178 2829  t;int>::max()
    │ │ │ -0005c680: 202d 2031 293b 0a0a 0909 2f2f 2074 6869   - 1);....// thi
    │ │ │ -0005c690: 7320 6c6f 6769 6320 6973 2068 6572 6520  s logic is here 
    │ │ │ -0005c6a0: 746f 2073 6d6f 6f74 6820 6f75 7420 7468  to smooth out th
    │ │ │ -0005c6b0: 6520 6e75 6d62 6572 206f 6620 6e65 7720  e number of new 
    │ │ │ -0005c6c0: 636f 6e6e 6563 7469 6f6e 0a09 092f 2f20  connection...// 
    │ │ │ -0005c6d0: 6174 7465 6d70 7473 206f 7665 7220 7469  attempts over ti
    │ │ │ -0005c6e0: 6d65 2c20 746f 2070 7265 7665 6e74 2063  me, to prevent c
    │ │ │ -0005c6f0: 6f6e 6e65 6374 696e 6720 6120 6c61 7267  onnecting a larg
    │ │ │ -0005c700: 6520 6e75 6d62 6572 206f 660a 0909 2f2f  e number of...//
    │ │ │ -0005c710: 2073 6f63 6b65 7473 2c20 7761 6974 2031   sockets, wait 1
    │ │ │ -0005c720: 3020 7365 636f 6e64 732c 2061 6e64 2074  0 seconds, and t
    │ │ │ -0005c730: 6865 6e20 7472 7920 6167 6169 6e0a 0909  hen try again...
    │ │ │ -0005c740: 6966 2028 6d5f 7365 7474 696e 6773 2e67  if (m_settings.g
    │ │ │ -0005c750: 6574 5f62 6f6f 6c28 7365 7474 696e 6773  et_bool(settings
    │ │ │ -0005c760: 5f70 6163 6b3a 3a73 6d6f 6f74 685f 636f  _pack::smooth_co
    │ │ │ -0005c770: 6e6e 6563 7473 2920 2661 6d70 3b26 616d  nnects) &&am
    │ │ │ -0005c780: 703b 206d 6178 5f63 6f6e 6e65 6374 696f  p; max_connectio
    │ │ │ -0005c790: 6e73 2026 6774 3b20 286c 696d 6974 2b31  ns > (limit+1
    │ │ │ -0005c7a0: 2920 2f20 3229 0a09 0909 6d61 785f 636f  ) / 2)....max_co
    │ │ │ -0005c7b0: 6e6e 6563 7469 6f6e 7320 3d20 286c 696d  nnections = (lim
    │ │ │ -0005c7c0: 6974 202b 2031 2920 2f20 323b 0a0a 0909  it + 1) / 2;....
    │ │ │ -0005c7d0: 6175 783a 3a76 6563 746f 7226 6c74 3b74  aux::vector<t
    │ │ │ -0005c7e0: 6f72 7265 6e74 2a26 6774 3b26 616d 703b  orrent*>&
    │ │ │ -0005c7f0: 2077 616e 745f 7065 6572 735f 646f 776e   want_peers_down
    │ │ │ -0005c800: 6c6f 6164 203d 206d 5f74 6f72 7265 6e74  load = m_torrent
    │ │ │ -0005c810: 5f6c 6973 7473 5b74 6f72 7265 6e74 5f77  _lists[torrent_w
    │ │ │ -0005c820: 616e 745f 7065 6572 735f 646f 776e 6c6f  ant_peers_downlo
    │ │ │ -0005c830: 6164 5d3b 0a09 0961 7578 3a3a 7665 6374  ad];...aux::vect
    │ │ │ -0005c840: 6f72 266c 743b 746f 7272 656e 742a 2667  or<torrent*&g
    │ │ │ -0005c850: 743b 2661 6d70 3b20 7761 6e74 5f70 6565  t;& want_pee
    │ │ │ -0005c860: 7273 5f66 696e 6973 6865 6420 3d20 6d5f  rs_finished = m_
    │ │ │ -0005c870: 746f 7272 656e 745f 6c69 7374 735b 746f  torrent_lists[to
    │ │ │ -0005c880: 7272 656e 745f 7761 6e74 5f70 6565 7273  rrent_want_peers
    │ │ │ -0005c890: 5f66 696e 6973 6865 645d 3b0a 0a09 092f  _finished];..../
    │ │ │ -0005c8a0: 2f20 6966 206e 6f20 746f 7272 656e 7420  / if no torrent 
    │ │ │ -0005c8b0: 7761 6e74 2061 6e79 2070 6565 7273 2c20  want any peers, 
    │ │ │ -0005c8c0: 6a75 7374 2072 6574 7572 6e0a 0909 6966  just return...if
    │ │ │ -0005c8d0: 2028 7761 6e74 5f70 6565 7273 5f64 6f77   (want_peers_dow
    │ │ │ -0005c8e0: 6e6c 6f61 642e 656d 7074 7928 2920 2661  nload.empty() &a
    │ │ │ -0005c8f0: 6d70 3b26 616d 703b 2077 616e 745f 7065  mp;& want_pe
    │ │ │ -0005c900: 6572 735f 6669 6e69 7368 6564 2e65 6d70  ers_finished.emp
    │ │ │ -0005c910: 7479 2829 2920 7265 7475 726e 3b0a 0a09  ty()) return;...
    │ │ │ -0005c920: 092f 2f20 6966 2077 6520 646f 6e27 7420  .// if we don't 
    │ │ │ -0005c930: 6861 7665 2061 6e79 2063 6f6e 6e65 6374  have any connect
    │ │ │ -0005c940: 696f 6e20 6174 7465 6d70 7420 7175 6f74  ion attempt quot
    │ │ │ -0005c950: 612c 2072 6574 7572 6e0a 0909 6966 2028  a, return...if (
    │ │ │ -0005c960: 6d61 785f 636f 6e6e 6563 7469 6f6e 7320  max_connections 
    │ │ │ -0005c970: 266c 743b 3d20 3029 2072 6574 7572 6e3b  <= 0) return;
    │ │ │ -0005c980: 0a0a 0909 696e 7420 7374 6570 735f 7369  ....int steps_si
    │ │ │ -0005c990: 6e63 655f 6c61 7374 5f63 6f6e 6e65 6374  nce_last_connect
    │ │ │ -0005c9a0: 203d 2030 3b0a 0909 696e 7420 636f 6e73   = 0;...int cons
    │ │ │ -0005c9b0: 7420 6e75 6d5f 746f 7272 656e 7473 203d  t num_torrents =
    │ │ │ -0005c9c0: 2069 6e74 2877 616e 745f 7065 6572 735f   int(want_peers_
    │ │ │ -0005c9d0: 6669 6e69 7368 6564 2e73 697a 6528 2920  finished.size() 
    │ │ │ -0005c9e0: 2b20 7761 6e74 5f70 6565 7273 5f64 6f77  + want_peers_dow
    │ │ │ -0005c9f0: 6e6c 6f61 642e 7369 7a65 2829 293b 0a09  nload.size());..
    │ │ │ -0005ca00: 0966 6f72 2028 3b3b 290a 0909 7b0a 0909  .for (;;)...{...
    │ │ │ -0005ca10: 0969 6620 286d 5f6e 6578 745f 646f 776e  .if (m_next_down
    │ │ │ -0005ca20: 6c6f 6164 696e 675f 636f 6e6e 6563 745f  loading_connect_
    │ │ │ -0005ca30: 746f 7272 656e 7420 2667 743b 3d20 696e  torrent >= in
    │ │ │ -0005ca40: 7428 7761 6e74 5f70 6565 7273 5f64 6f77  t(want_peers_dow
    │ │ │ -0005ca50: 6e6c 6f61 642e 7369 7a65 2829 2929 0a09  nload.size()))..
    │ │ │ -0005ca60: 0909 096d 5f6e 6578 745f 646f 776e 6c6f  ...m_next_downlo
    │ │ │ -0005ca70: 6164 696e 675f 636f 6e6e 6563 745f 746f  ading_connect_to
    │ │ │ -0005ca80: 7272 656e 7420 3d20 303b 0a0a 0909 0969  rrent = 0;.....i
    │ │ │ -0005ca90: 6620 286d 5f6e 6578 745f 6669 6e69 7368  f (m_next_finish
    │ │ │ -0005caa0: 6564 5f63 6f6e 6e65 6374 5f74 6f72 7265  ed_connect_torre
    │ │ │ -0005cab0: 6e74 2026 6774 3b3d 2069 6e74 2877 616e  nt >= int(wan
    │ │ │ -0005cac0: 745f 7065 6572 735f 6669 6e69 7368 6564  t_peers_finished
    │ │ │ -0005cad0: 2e73 697a 6528 2929 290a 0909 0909 6d5f  .size())).....m_
    │ │ │ -0005cae0: 6e65 7874 5f66 696e 6973 6865 645f 636f  next_finished_co
    │ │ │ -0005caf0: 6e6e 6563 745f 746f 7272 656e 7420 3d20  nnect_torrent = 
    │ │ │ -0005cb00: 303b 0a0a 0909 0974 6f72 7265 6e74 2a20  0;.....torrent* 
    │ │ │ -0005cb10: 7420 3d20 6e75 6c6c 7074 723b 0a09 0909  t = nullptr;....
    │ │ │ -0005cb20: 2f2f 2074 6865 7265 2061 7265 2070 7269  // there are pri
    │ │ │ -0005cb30: 6f72 6974 697a 6564 2074 6f72 7265 6e74  oritized torrent
    │ │ │ -0005cb40: 732e 2050 6963 6b20 6f6e 6520 6f66 2074  s. Pick one of t
    │ │ │ -0005cb50: 686f 7365 0a09 0909 7768 696c 6520 2821  hose....while (!
    │ │ │ -0005cb60: 6d5f 7072 696f 5f74 6f72 7265 6e74 732e  m_prio_torrents.
    │ │ │ -0005cb70: 656d 7074 7928 2929 0a3c 2f70 7265 3e3c  empty()).
    < │ │ │ -0005cb80: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -0005cbb0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -0005cbc0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/sessi │ │ │ -0005cbf0: 6f6e 5f69 6d70 6c2e 6370 703a 3436 3636 on_impl.cpp:4666 │ │ │ -0005cc00: 3c2f 613e 3c2f 7464 3e3c 7464 3e70 6f73 pos │ │ │ -0005cc10: 7420 6120 6d65 7373 6167 6520 746f 2068 t a message to h │ │ │ -0005cc20: 6176 6520 7468 6973 2068 6170 7065 6e20 ave this happen │ │ │ -0005cc30: 696d 6d65 6469 6174 656c 7920 696e 7374 immediately inst │ │ │ -0005cc40: 6561 6420 6f66 2077 6169 7469 6e67 2066 ead of waiting f │ │ │ -0005cc50: 6f72 2074 6865 206e 6578 7420 7469 636b or the next tick │ │ │ -0005cc60: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    po │ │ │ -0005ccb0: 7374 2061 206d 6573 7361 6765 2074 6f20 st a message to │ │ │ -0005ccc0: 6861 7665 2074 6869 7320 6861 7070 656e have this happen │ │ │ -0005ccd0: 0a69 6d6d 6564 6961 7465 6c79 2069 6e73 .immediately ins │ │ │ -0005cce0: 7465 6164 206f 6620 7761 6974 696e 6720 tead of waiting │ │ │ -0005ccf0: 666f 7220 7468 6520 6e65 7874 2074 6963 for the next tic │ │ │ -0005cd00: 6b3c 2f68 323e 3c68 343e 2e2e 2f73 7263 k

    ../src │ │ │ -0005cd10: 2f73 6573 7369 6f6e 5f69 6d70 6c2e 6370 /session_impl.cp │ │ │ -0005cd20: 703a 3436 3636 3c2f 6834 3e3c 7072 6520 p:4666

    ....continu
    │ │ │ -0005cd70: 653b 0a09 0909 7d0a 0a09 0909 6966 2028  e;....}.....if (
    │ │ │ -0005cd80: 2170 2d26 6774 3b69 735f 7065 6572 5f69  !p->is_peer_i
    │ │ │ -0005cd90: 6e74 6572 6573 7465 6428 290a 0909 0909  nterested().....
    │ │ │ -0005cda0: 7c7c 2070 2d26 6774 3b69 735f 6469 7363  || p->is_disc
    │ │ │ -0005cdb0: 6f6e 6e65 6374 696e 6728 290a 0909 0909  onnecting().....
    │ │ │ -0005cdc0: 7c7c 2070 2d26 6774 3b69 735f 636f 6e6e  || p->is_conn
    │ │ │ -0005cdd0: 6563 7469 6e67 2829 290a 0909 097b 0a09  ecting())....{..
    │ │ │ -0005cde0: 0909 092f 2f20 7468 6973 2070 6565 7220  ...// this peer 
    │ │ │ -0005cdf0: 6973 206e 6f74 2075 6e63 686f 6b61 626c  is not unchokabl
    │ │ │ -0005ce00: 652e 2053 6f2c 2069 6620 6974 2773 2075  e. So, if it's u
    │ │ │ -0005ce10: 6e63 686f 6b65 640a 0909 0909 2f2f 2061  nchoked.....// a
    │ │ │ -0005ce20: 6c72 6561 6479 2c20 6d61 6b65 2073 7572  lready, make sur
    │ │ │ -0005ce30: 6520 746f 2063 686f 6b65 2069 742e 0a09  e to choke it...
    │ │ │ -0005ce40: 0909 0969 6620 2870 2d26 6774 3b69 735f  ...if (p->is_
    │ │ │ -0005ce50: 6368 6f6b 6564 2829 290a 0909 0909 7b0a  choked()).....{.
    │ │ │ -0005ce60: 0909 0909 0970 2d26 6774 3b72 6573 6574  .....p->reset
    │ │ │ -0005ce70: 5f63 686f 6b65 5f63 6f75 6e74 6572 7328  _choke_counters(
    │ │ │ -0005ce80: 293b 0a09 0909 0909 636f 6e74 696e 7565  );......continue
    │ │ │ -0005ce90: 3b0a 0909 0909 7d0a 0909 0909 6966 2028  ;.....}.....if (
    │ │ │ -0005cea0: 7069 2026 616d 703b 2661 6d70 3b20 7069  pi && pi
    │ │ │ -0005ceb0: 2d26 6774 3b6f 7074 696d 6973 7469 6361  ->optimistica
    │ │ │ -0005cec0: 6c6c 795f 756e 6368 6f6b 6564 290a 0909  lly_unchoked)...
    │ │ │ -0005ced0: 0909 7b0a 0909 0909 096d 5f73 7461 7473  ..{......m_stats
    │ │ │ -0005cee0: 5f63 6f75 6e74 6572 732e 696e 635f 7374  _counters.inc_st
    │ │ │ -0005cef0: 6174 735f 636f 756e 7465 7228 636f 756e  ats_counter(coun
    │ │ │ -0005cf00: 7465 7273 3a3a 6e75 6d5f 7065 6572 735f  ters::num_peers_
    │ │ │ -0005cf10: 7570 5f75 6e63 686f 6b65 645f 6f70 7469  up_unchoked_opti
    │ │ │ -0005cf20: 6d69 7374 6963 2c20 2d31 293b 0a09 0909  mistic, -1);....
    │ │ │ -0005cf30: 0909 7069 2d26 6774 3b6f 7074 696d 6973  ..pi->optimis
    │ │ │ -0005cf40: 7469 6361 6c6c 795f 756e 6368 6f6b 6564  tically_unchoked
    │ │ │ -0005cf50: 203d 2066 616c 7365 3b0a 0909 0909 092f   = false;....../
    │ │ │ -0005cf60: 2f20 666f 7263 6520 6120 6e65 7720 6f70  / force a new op
    │ │ │ -0005cf70: 7469 6d69 7374 6963 2075 6e63 686f 6b65  timistic unchoke
    │ │ │ -0005cf80: 0a09 0909 0909 6d5f 6f70 7469 6d69 7374  ......m_optimist
    │ │ │ -0005cf90: 6963 5f75 6e63 686f 6b65 5f74 696d 655f  ic_unchoke_time_
    │ │ │ -0005cfa0: 7363 616c 6572 203d 2030 3b0a 3c64 6976  scaler = 0;.
    ....}. │ │ │ -0005cfe0: 3c2f 6469 763e 0909 0909 742d 2667 743b
    ....t-> │ │ │ -0005cff0: 6368 6f6b 655f 7065 6572 282a 7029 3b0a choke_peer(*p);. │ │ │ -0005d000: 0909 0909 702d 2667 743b 7265 7365 745f ....p->reset_ │ │ │ -0005d010: 6368 6f6b 655f 636f 756e 7465 7273 2829 choke_counters() │ │ │ -0005d020: 3b0a 0909 0909 636f 6e74 696e 7565 3b0a ;.....continue;. │ │ │ -0005d030: 0909 097d 0a0a 0909 0970 6565 7273 2e70 ...}.....peers.p │ │ │ -0005d040: 7573 685f 6261 636b 2870 2e67 6574 2829 ush_back(p.get() │ │ │ -0005d050: 293b 0a09 097d 0a0a 0909 696e 7420 636f );...}....int co │ │ │ -0005d060: 6e73 7420 616c 6c6f 7765 645f 7570 6c6f nst allowed_uplo │ │ │ -0005d070: 6164 5f73 6c6f 7473 203d 2075 6e63 686f ad_slots = uncho │ │ │ -0005d080: 6b65 5f73 6f72 7428 7065 6572 730a 0909 ke_sort(peers... │ │ │ -0005d090: 092c 2075 6e63 686f 6b65 5f69 6e74 6572 ., unchoke_inter │ │ │ -0005d0a0: 7661 6c2c 206d 5f73 6574 7469 6e67 7329 val, m_settings) │ │ │ -0005d0b0: 3b0a 0a09 0969 6620 286d 5f73 6574 7469 ;....if (m_setti │ │ │ -0005d0c0: 6e67 732e 6765 745f 696e 7428 7365 7474 ngs.get_int(sett │ │ │ -0005d0d0: 696e 6773 5f70 6163 6b3a 3a63 686f 6b69 ings_pack::choki │ │ │ -0005d0e0: 6e67 5f61 6c67 6f72 6974 686d 2920 3d3d ng_algorithm) == │ │ │ -0005d0f0: 2073 6574 7469 6e67 735f 7061 636b 3a3a settings_pack:: │ │ │ -0005d100: 6669 7865 645f 736c 6f74 735f 6368 6f6b fixed_slots_chok │ │ │ -0005d110: 6572 290a 0909 7b0a 0909 0969 6e74 2063 er)...{....int c │ │ │ -0005d120: 6f6e 7374 2075 706c 6f61 645f 736c 6f74 onst upload_slot │ │ │ -0005d130: 7320 3d20 6765 745f 696e 745f 7365 7474 s = get_int_sett │ │ │ -0005d140: 696e 6728 7365 7474 696e 6773 5f70 6163 ing(settings_pac │ │ │ -0005d150: 6b3a 3a75 6e63 686f 6b65 5f73 6c6f 7473 k::unchoke_slots │ │ │ -0005d160: 5f6c 696d 6974 293b 0a09 0909 6d5f 7374 _limit);....m_st │ │ │ -0005d170: 6174 735f 636f 756e 7465 7273 2e73 6574 ats_counters.set │ │ │ -0005d180: 5f76 616c 7565 2863 6f75 6e74 6572 733a _value(counters: │ │ │ -0005d190: 3a6e 756d 5f75 6e63 686f 6b65 5f73 6c6f :num_unchoke_slo │ │ │ -0005d1a0: 7473 2c20 7570 6c6f 6164 5f73 6c6f 7473 ts, upload_slots │ │ │ -0005d1b0: 293b 0a09 097d 0a09 0965 6c73 650a 0909 );...}...else... │ │ │ -0005d1c0: 7b0a 0909 096d 5f73 7461 7473 5f63 6f75 {....m_stats_cou │ │ │ -0005d1d0: 6e74 6572 732e 7365 745f 7661 6c75 6528 nters.set_value( │ │ │ -0005d1e0: 636f 756e 7465 7273 3a3a 6e75 6d5f 756e counters::num_un │ │ │ -0005d1f0: 6368 6f6b 655f 736c 6f74 730a 0909 0909 choke_slots..... │ │ │ -0005d200: 2c20 616c 6c6f 7765 645f 7570 6c6f 6164 , allowed_upload │ │ │ -0005d210: 5f73 6c6f 7473 293b 0a09 097d 0a0a 2369 _slots);...}..#i │ │ │ -0005d220: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ -0005d230: 5341 424c 455f 4c4f 4747 494e 470a 0909 SABLE_LOGGING... │ │ │ -0005d240: 6966 2028 7368 6f75 6c64 5f6c 6f67 2829 if (should_log() │ │ │ -0005d250: 290a 0909 7b0a 0909 0973 6573 7369 6f6e )...{....session │ │ │ -0005d260: 5f6c 6f67 2822 5245 4341 4c43 554c 4154 _log("RECALCULAT │ │ │ -0005d270: 4520 554e 4348 4f4b 4520 534c 4f54 533a E UNCHOKE SLOTS: │ │ │ -0005d280: 205b 2070 6565 7273 3a20 2564 2022 0a09 [ peers: %d ".. │ │ │ -0005d290: 0909 0922 656c 6967 6962 6c65 2d70 6565 ..."eligible-pee │ │ │ -0005d2a0: 7273 3a20 2564 220a 0909 0909 2220 616c rs: %d"....." al │ │ │ -0005d2b0: 6c6f 7765 642d 736c 6f74 733a 2025 6420 lowed-slots: %d │ │ │ -0005d2c0: 5d22 0a09 0909 092c 2069 6e74 286d 5f63 ]"....., int(m_c │ │ │ -0005d2d0: 6f6e 6e65 6374 696f 6e73 2e73 697a 6528 onnections.size( │ │ │ -0005d2e0: 2929 0a09 0909 092c 2069 6e74 2870 6565 ))....., int(pee │ │ │ -0005d2f0: 7273 2e73 697a 6528 2929 0a3c 2f70 7265 rs.size()).
    rele │ │ │ -0005d330: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/ses │ │ │ -0005d370: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3439 sion_impl.cpp:49 │ │ │ -0005d380: 3933 3c2f 613e 3c2f 7464 3e3c 7464 3e69 93i │ │ │ -0005d390: 7420 6d69 6768 7420 6265 2061 206e 6963 t might be a nic │ │ │ -0005d3a0: 6520 6665 6174 7572 6520 6865 7265 2074 e feature here t │ │ │ -0005d3b0: 6f20 6c69 6d69 7420 7468 6520 6e75 6d62 o limit the numb │ │ │ -0005d3c0: 6572 206f 6620 746f 7272 656e 7473 2074 er of torrents t │ │ │ -0005d3d0: 6f20 7365 6e64 2069 6e20 6120 7369 6e67 o send in a sing │ │ │ -0005d3e0: 6c65 2075 7064 6174 652e 2042 7920 6a75 le update. By ju │ │ │ -0005d3f0: 7374 2070 6f73 7469 6e67 2074 6865 2066 st posting the f │ │ │ -0005d400: 6972 7374 206e 2074 6f72 7265 6e74 732c irst n torrents, │ │ │ -0005d410: 2074 6865 7920 776f 756c 6420 6e69 6365 they would nice │ │ │ -0005d420: 6c79 2062 6520 726f 756e 642d 726f 6269 ly be round-robi │ │ │ -0005d430: 6e65 6420 6265 6361 7573 6520 7468 6520 ned because the │ │ │ -0005d440: 746f 7272 656e 7420 6c69 7374 7320 6172 torrent lists ar │ │ │ -0005d450: 6520 616c 7761 7973 2070 7573 6865 6420 e always pushed │ │ │ -0005d460: 6261 636b 2e20 5065 7268 6170 7320 7468 back. Perhaps th │ │ │ -0005d470: 6520 7374 6174 7573 5f75 7064 6174 655f e status_update_ │ │ │ -0005d480: 616c 6572 7420 636f 756c 6420 6576 656e alert could even │ │ │ -0005d490: 2068 6176 6520 6120 6669 7865 6420 6172 have a fixed ar │ │ │ -0005d4a0: 7261 7920 6f66 206e 2065 6e74 7269 6573 ray of n entries │ │ │ -0005d4b0: 2072 6174 6865 7220 7468 616e 2061 2076 rather than a v │ │ │ -0005d4c0: 6563 746f 722c 2074 6f20 6675 7274 6865 ector, to furthe │ │ │ -0005d4d0: 7220 696d 7072 6f76 6520 6d65 6d6f 7279 r improve memory │ │ │ -0005d4e0: 206c 6f63 616c 6974 792e 3c2f 7464 3e3c locality.< │ │ │ -0005d4f0: 2f74 723e 3c74 7220 6964 3d22 3231 3622 /tr>

    it might │ │ │ -0005d540: 2062 6520 6120 6e69 6365 2066 6561 7475 be a nice featu │ │ │ -0005d550: 7265 2068 6572 6520 746f 206c 696d 6974 re here to limit │ │ │ -0005d560: 2074 6865 206e 756d 6265 7220 6f66 2074 the number of t │ │ │ -0005d570: 6f72 7265 6e74 730a 746f 2073 656e 6420 orrents.to send │ │ │ -0005d580: 696e 2061 2073 696e 676c 6520 7570 6461 in a single upda │ │ │ -0005d590: 7465 2e20 4279 206a 7573 7420 706f 7374 te. By just post │ │ │ -0005d5a0: 696e 6720 7468 6520 6669 7273 7420 6e20 ing the first n │ │ │ -0005d5b0: 746f 7272 656e 7473 2c20 7468 6579 0a77 torrents, they.w │ │ │ -0005d5c0: 6f75 6c64 206e 6963 656c 7920 6265 2072 ould nicely be r │ │ │ -0005d5d0: 6f75 6e64 2d72 6f62 696e 6564 2062 6563 ound-robined bec │ │ │ -0005d5e0: 6175 7365 2074 6865 2074 6f72 7265 6e74 ause the torrent │ │ │ -0005d5f0: 206c 6973 7473 2061 7265 2061 6c77 6179 lists are alway │ │ │ -0005d600: 730a 7075 7368 6564 2062 6163 6b2e 2050 s.pushed back. P │ │ │ -0005d610: 6572 6861 7073 2074 6865 2073 7461 7475 erhaps the statu │ │ │ -0005d620: 735f 7570 6461 7465 5f61 6c65 7274 2063 s_update_alert c │ │ │ -0005d630: 6f75 6c64 2065 7665 6e20 6861 7665 2061 ould even have a │ │ │ -0005d640: 2066 6978 6564 0a61 7272 6179 206f 6620 fixed.array of │ │ │ -0005d650: 6e20 656e 7472 6965 7320 7261 7468 6572 n entries rather │ │ │ -0005d660: 2074 6861 6e20 6120 7665 6374 6f72 2c20 than a vector, │ │ │ -0005d670: 746f 2066 7572 7468 6572 2069 6d70 726f to further impro │ │ │ -0005d680: 7665 206d 656d 6f72 790a 6c6f 6361 6c69 ve memory.locali │ │ │ -0005d690: 7479 2e3c 2f68 323e 3c68 343e 2e2e 2f73 ty.

    ../s │ │ │ -0005d6a0: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ -0005d6b0: 6370 703a 3439 3933 3c2f 6834 3e3c 7072 cpp:4993

    ...t-> │ │ │ -0005d700: 7374 6174 7573 2826 616d 703b 7374 2c20 status(&st, │ │ │ -0005d710: 666c 6167 7329 3b0a 0909 7d0a 097d 0a0a flags);...}..}.. │ │ │ -0005d720: 0976 6f69 6420 7365 7373 696f 6e5f 696d .void session_im │ │ │ -0005d730: 706c 3a3a 706f 7374 5f74 6f72 7265 6e74 pl::post_torrent │ │ │ -0005d740: 5f75 7064 6174 6573 2873 7461 7475 735f _updates(status_ │ │ │ -0005d750: 666c 6167 735f 7420 636f 6e73 7420 666c flags_t const fl │ │ │ -0005d760: 6167 7329 0a09 7b0a 0909 494e 5641 5249 ags)..{...INVARI │ │ │ -0005d770: 414e 545f 4348 4543 4b3b 0a0a 0909 544f ANT_CHECK;....TO │ │ │ -0005d780: 5252 454e 545f 4153 5345 5254 2869 735f RRENT_ASSERT(is_ │ │ │ -0005d790: 7369 6e67 6c65 5f74 6872 6561 6428 2929 single_thread()) │ │ │ -0005d7a0: 3b0a 0a09 0973 7464 3a3a 7665 6374 6f72 ;....std::vector │ │ │ -0005d7b0: 266c 743b 746f 7272 656e 742a 2667 743b <torrent*> │ │ │ -0005d7c0: 2661 6d70 3b20 7374 6174 655f 7570 6461 & state_upda │ │ │ -0005d7d0: 7465 730a 0909 093d 206d 5f74 6f72 7265 tes....= m_torre │ │ │ -0005d7e0: 6e74 5f6c 6973 7473 5b61 7578 3a3a 7365 nt_lists[aux::se │ │ │ -0005d7f0: 7373 696f 6e5f 696d 706c 3a3a 746f 7272 ssion_impl::torr │ │ │ -0005d800: 656e 745f 7374 6174 655f 7570 6461 7465 ent_state_update │ │ │ -0005d810: 735d 3b0a 0a23 6966 2054 4f52 5245 4e54 s];..#if TORRENT │ │ │ -0005d820: 5f55 5345 5f41 5353 4552 5453 0a09 096d _USE_ASSERTS...m │ │ │ -0005d830: 5f70 6f73 7469 6e67 5f74 6f72 7265 6e74 _posting_torrent │ │ │ -0005d840: 5f75 7064 6174 6573 203d 2074 7275 653b _updates = true; │ │ │ -0005d850: 0a23 656e 6469 660a 0a09 0973 7464 3a3a .#endif....std:: │ │ │ -0005d860: 7665 6374 6f72 266c 743b 746f 7272 656e vector<torren │ │ │ -0005d870: 745f 7374 6174 7573 2667 743b 2073 7461 t_status> sta │ │ │ -0005d880: 7475 733b 0a09 0973 7461 7475 732e 7265 tus;...status.re │ │ │ -0005d890: 7365 7276 6528 7374 6174 655f 7570 6461 serve(state_upda │ │ │ -0005d8a0: 7465 732e 7369 7a65 2829 293b 0a0a 3c64 tes.size());....fo │ │ │ -0005d8e0: 7220 2861 7574 6f26 616d 703b 2074 203a r (auto& t : │ │ │ -0005d8f0: 2073 7461 7465 5f75 7064 6174 6573 290a state_updates). │ │ │ -0005d900: 3c2f 6469 763e 0909 7b0a 0909 0954 4f52 ..{....TOR │ │ │ -0005d910: 5245 4e54 5f41 5353 4552 5428 742d 2667 RENT_ASSERT(t-&g │ │ │ -0005d920: 743b 6d5f 6c69 6e6b 735b 6175 783a 3a73 t;m_links[aux::s │ │ │ -0005d930: 6573 7369 6f6e 5f69 6d70 6c3a 3a74 6f72 ession_impl::tor │ │ │ -0005d940: 7265 6e74 5f73 7461 7465 5f75 7064 6174 rent_state_updat │ │ │ -0005d950: 6573 5d2e 696e 5f6c 6973 7428 2929 3b0a es].in_list());. │ │ │ -0005d960: 0909 0973 7461 7475 732e 656d 706c 6163 ...status.emplac │ │ │ -0005d970: 655f 6261 636b 2829 3b0a 0909 092f 2f20 e_back();....// │ │ │ -0005d980: 7175 6572 7969 6e67 2061 6363 7572 6174 querying accurat │ │ │ -0005d990: 6520 646f 776e 6c6f 6164 2063 6f75 6e74 e download count │ │ │ -0005d9a0: 6572 7320 6d61 7920 7265 7175 6972 650a ers may require. │ │ │ -0005d9b0: 0909 092f 2f20 7468 6520 746f 7272 656e ...// the torren │ │ │ -0005d9c0: 7420 746f 2062 6520 6c6f 6164 6564 2e20 t to be loaded. │ │ │ -0005d9d0: 4c6f 6164 696e 6720 6120 746f 7272 656e Loading a torren │ │ │ -0005d9e0: 742c 2061 6e64 2065 7669 6374 696e 6720 t, and evicting │ │ │ -0005d9f0: 616e 6f74 6865 720a 0909 092f 2f20 6f6e another....// on │ │ │ -0005da00: 6520 7769 6c6c 206c 6561 6420 746f 2063 e will lead to c │ │ │ -0005da10: 616c 6c69 6e67 2073 7461 7465 5f75 7064 alling state_upd │ │ │ -0005da20: 6174 6564 2829 2c20 7768 6963 6820 7363 ated(), which sc │ │ │ -0005da30: 7265 7773 2077 6974 680a 0909 092f 2f20 rews with....// │ │ │ -0005da40: 7468 6973 206c 6973 7420 7768 696c 6520 this list while │ │ │ -0005da50: 7765 2772 6520 776f 726b 696e 6720 6f6e we're working on │ │ │ -0005da60: 2069 742c 2061 6e64 2062 7265 616b 2074 it, and break t │ │ │ -0005da70: 6869 6e67 730a 0909 0974 2d26 6774 3b73 hings....t->s │ │ │ -0005da80: 7461 7475 7328 2661 6d70 3b73 7461 7475 tatus(&statu │ │ │ -0005da90: 732e 6261 636b 2829 2c20 666c 6167 7329 s.back(), flags) │ │ │ -0005daa0: 3b0a 0909 0974 2d26 6774 3b63 6c65 6172 ;....t->clear │ │ │ -0005dab0: 5f69 6e5f 7374 6174 655f 7570 6461 7465 _in_state_update │ │ │ -0005dac0: 2829 3b0a 0909 7d0a 0909 7374 6174 655f ();...}...state_ │ │ │ -0005dad0: 7570 6461 7465 732e 636c 6561 7228 293b updates.clear(); │ │ │ -0005dae0: 0a0a 2369 6620 544f 5252 454e 545f 5553 ..#if TORRENT_US │ │ │ -0005daf0: 455f 4153 5345 5254 530a 0909 6d5f 706f E_ASSERTS...m_po │ │ │ -0005db00: 7374 696e 675f 746f 7272 656e 745f 7570 sting_torrent_up │ │ │ -0005db10: 6461 7465 7320 3d20 6661 6c73 653b 0a23 dates = false;.# │ │ │ -0005db20: 656e 6469 660a 0a09 096d 5f61 6c65 7274 endif....m_alert │ │ │ -0005db30: 732e 656d 706c 6163 655f 616c 6572 7426 s.emplace_alert& │ │ │ -0005db40: 6c74 3b73 7461 7465 5f75 7064 6174 655f lt;state_update_ │ │ │ -0005db50: 616c 6572 7426 6774 3b28 7374 643a 3a6d alert>(std::m │ │ │ -0005db60: 6f76 6528 7374 6174 7573 2929 3b0a 097d ove(status));..} │ │ │ -0005db70: 0a0a 0976 6f69 6420 7365 7373 696f 6e5f ...void session_ │ │ │ -0005db80: 696d 706c 3a3a 706f 7374 5f73 6573 7369 impl::post_sessi │ │ │ -0005db90: 6f6e 5f73 7461 7473 2829 0a09 7b0a 0909 on_stats()..{... │ │ │ -0005dba0: 6966 2028 216d 5f70 6f73 7465 645f 7374 if (!m_posted_st │ │ │ -0005dbb0: 6174 735f 6865 6164 6572 290a 0909 7b0a ats_header)...{. │ │ │ -0005dbc0: 0909 096d 5f70 6f73 7465 645f 7374 6174 ...m_posted_stat │ │ │ -0005dbd0: 735f 6865 6164 6572 203d 2074 7275 653b s_header = true; │ │ │ -0005dbe0: 0a09 0909 6d5f 616c 6572 7473 2e65 6d70 ....m_alerts.emp │ │ │ -0005dbf0: 6c61 6365 5f61 6c65 7274 266c 743b 7365 lace_alert<se │ │ │ -0005dc00: 7373 696f 6e5f 7374 6174 735f 6865 6164 ssion_stats_head │ │ │ -0005dc10: 6572 5f61 6c65 7274 2667 743b 2829 3b0a er_alert>();. │ │ │ -0005dc20: 0909 7d0a 0909 6d5f 6469 736b 5f74 6872 ..}...m_disk_thr │ │ │ -0005dc30: 6561 642d 2667 743b 7570 6461 7465 5f73 ead->update_s │ │ │ -0005dc40: 7461 7473 5f63 6f75 6e74 6572 7328 6d5f tats_counters(m_ │ │ │ -0005dc50: 7374 6174 735f 636f 756e 7465 7273 293b stats_counters); │ │ │ -0005dc60: 0a0a 2369 666e 6465 6620 544f 5252 454e ..#ifndef TORREN │ │ │ -0005dc70: 545f 4449 5341 424c 455f 4448 540a 0909 T_DISABLE_DHT... │ │ │ -0005dc80: 6966 2028 6d5f 6468 7429 0a3c 2f70 7265 if (m_dht).rele │ │ │ -0005dcc0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/ses │ │ │ -0005dd00: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3533 sion_impl.cpp:53 │ │ │ -0005dd10: 3837 3c2f 613e 3c2f 7464 3e3c 7464 3e66 87f │ │ │ -0005dd20: 6163 746f 7220 6f75 7420 7468 6973 206c actor out this l │ │ │ -0005dd30: 6f67 6963 2069 6e74 6f20 6120 7365 7061 ogic into a sepa │ │ │ -0005dd40: 7261 7465 2066 756e 6374 696f 6e20 666f rate function fo │ │ │ -0005dd50: 7220 756e 6974 2074 6573 7469 6e67 3c2f r unit testing

    fact │ │ │ -0005ddb0: 6f72 206f 7574 2074 6869 7320 6c6f 6769 or out this logi │ │ │ -0005ddc0: 6320 696e 746f 2061 2073 6570 6172 6174 c into a separat │ │ │ -0005ddd0: 6520 6675 6e63 7469 6f6e 2066 6f72 2075 e function for u │ │ │ -0005dde0: 6e69 740a 7465 7374 696e 673c 2f68 323e nit.testing

    │ │ │ -0005ddf0: 3c68 343e 2e2e 2f73 7263 2f73 6573 7369

    ../src/sessi │ │ │ -0005de00: 6f6e 5f69 6d70 6c2e 6370 703a 3533 3837 on_impl.cpp:5387 │ │ │ -0005de10: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -0005de50: 0969 6620 286d 5f73 6574 7469 6e67 732e  .if (m_settings.
    │ │ │ -0005de60: 6765 745f 696e 7428 7365 7474 696e 6773  get_int(settings
    │ │ │ -0005de70: 5f70 6163 6b3a 3a6f 7574 676f 696e 675f  _pack::outgoing_
    │ │ │ -0005de80: 706f 7274 2920 2667 743b 2030 290a 0909  port) > 0)...
    │ │ │ -0005de90: 7b0a 2369 6664 6566 2054 4f52 5245 4e54  {.#ifdef TORRENT
    │ │ │ -0005dea0: 5f57 494e 444f 5753 0a09 0909 732e 7365  _WINDOWS....s.se
    │ │ │ -0005deb0: 745f 6f70 7469 6f6e 2865 7863 6c75 7369  t_option(exclusi
    │ │ │ -0005dec0: 7665 5f61 6464 7265 7373 5f75 7365 2874  ve_address_use(t
    │ │ │ -0005ded0: 7275 6529 2c20 6563 293b 0a23 656c 7365  rue), ec);.#else
    │ │ │ -0005dee0: 0a09 0909 732e 7365 745f 6f70 7469 6f6e  ....s.set_option
    │ │ │ -0005def0: 2874 6370 3a3a 6163 6365 7074 6f72 3a3a  (tcp::acceptor::
    │ │ │ -0005df00: 7265 7573 655f 6164 6472 6573 7328 7472  reuse_address(tr
    │ │ │ -0005df10: 7565 292c 2065 6329 3b0a 2365 6e64 6966  ue), ec);.#endif
    │ │ │ -0005df20: 0a09 0909 2f2f 2069 676e 6f72 6520 6572  ....// ignore er
    │ │ │ -0005df30: 726f 7273 2062 6563 6175 7365 2074 6865  rors because the
    │ │ │ -0005df40: 2075 6e64 6572 6c79 696e 6720 736f 636b   underlying sock
    │ │ │ -0005df50: 6574 206d 6179 206e 6f74 0a09 0909 2f2f  et may not....//
    │ │ │ -0005df60: 2062 6520 6f70 656e 6564 2079 6574 2e20   be opened yet. 
    │ │ │ -0005df70: 5468 6973 2068 6170 7065 6e73 2077 6865  This happens whe
    │ │ │ -0005df80: 6e20 7765 2772 6520 726f 7574 696e 6720  n we're routing 
    │ │ │ -0005df90: 7468 726f 7567 680a 0909 092f 2f20 6120  through....// a 
    │ │ │ -0005dfa0: 7072 6f78 792e 2049 6e20 7468 6174 2063  proxy. In that c
    │ │ │ -0005dfb0: 6173 652c 2077 6520 646f 6e27 7420 7965  ase, we don't ye
    │ │ │ -0005dfc0: 7420 6b6e 6f77 2074 6865 2061 6464 7265  t know the addre
    │ │ │ -0005dfd0: 7373 206f 660a 0909 092f 2f20 7468 6520  ss of....// the 
    │ │ │ -0005dfe0: 7072 6f78 7920 7365 7276 6572 2c20 616e  proxy server, an
    │ │ │ -0005dff0: 6420 6d6f 7265 2069 6d70 6f72 7461 6e74  d more important
    │ │ │ -0005e000: 6c79 2c20 7765 2064 6f6e 2774 206b 6e6f  ly, we don't kno
    │ │ │ -0005e010: 770a 0909 092f 2f20 7468 6520 6164 6472  w....// the addr
    │ │ │ -0005e020: 6573 7320 6661 6d69 6c79 206f 6620 6974  ess family of it
    │ │ │ -0005e030: 7320 6164 6472 6573 732e 2054 6869 7320  s address. This 
    │ │ │ -0005e040: 6d65 616e 7320 7765 2063 616e 2774 0a09  means we can't..
    │ │ │ -0005e050: 0909 2f2f 206f 7065 6e20 7468 6520 736f  ..// open the so
    │ │ │ -0005e060: 636b 6574 2079 6574 2e20 5468 6520 736f  cket yet. The so
    │ │ │ -0005e070: 636b 7320 6162 7374 7261 6374 696f 6e20  cks abstraction 
    │ │ │ -0005e080: 6c61 7965 7220 6465 6665 7273 0a09 0909  layer defers....
    │ │ │ -0005e090: 2f2f 206f 7065 6e69 6e67 2069 742e 0a09  // opening it...
    │ │ │ -0005e0a0: 0909 6563 2e63 6c65 6172 2829 3b0a 0909  ..ec.clear();...
    │ │ │ -0005e0b0: 0962 696e 645f 6570 2e70 6f72 7428 7374  .bind_ep.port(st
    │ │ │ -0005e0c0: 643a 3a75 696e 7431 365f 7428 6e65 7874  d::uint16_t(next
    │ │ │ -0005e0d0: 5f70 6f72 7428 2929 293b 0a09 097d 0a0a  _port()));...}..
    │ │ │ -0005e0e0: 0909 6966 2028 6973 5f75 7470 2873 2929  ..if (is_utp(s))
    │ │ │ -0005e0f0: 0a09 097b 0a3c 6469 7620 7374 796c 653d  ...{.
    .
    ...utp │ │ │ -0005e130: 5f73 6f63 6b65 745f 696d 706c 2a20 696d _socket_impl* im │ │ │ -0005e140: 706c 203d 206e 756c 6c70 7472 3b0a 0909 pl = nullptr;... │ │ │ -0005e150: 0974 7261 6e73 706f 7274 2073 736c 203d .transport ssl = │ │ │ -0005e160: 2074 7261 6e73 706f 7274 3a3a 706c 6169 transport::plai │ │ │ -0005e170: 6e74 6578 743b 0a23 6966 2054 4f52 5245 ntext;.#if TORRE │ │ │ -0005e180: 4e54 5f55 5345 5f53 534c 0a09 0909 6966 NT_USE_SSL....if │ │ │ -0005e190: 2028 7374 643a 3a67 6574 5f69 6626 6c74 (std::get_if< │ │ │ -0005e1a0: 3b73 736c 5f73 7472 6561 6d26 6c74 3b75 ;ssl_stream<u │ │ │ -0005e1b0: 7470 5f73 7472 6561 6d26 6774 3b26 6774 tp_stream>> │ │ │ -0005e1c0: 3b28 2661 6d70 3b73 2e76 6172 2829 2920 ;(&s.var()) │ │ │ -0005e1d0: 213d 206e 756c 6c70 7472 290a 0909 097b != nullptr)....{ │ │ │ -0005e1e0: 0a09 0909 0969 6d70 6c20 3d20 7374 643a .....impl = std: │ │ │ -0005e1f0: 3a67 6574 266c 743b 7373 6c5f 7374 7265 :get<ssl_stre │ │ │ -0005e200: 616d 266c 743b 7574 705f 7374 7265 616d am<utp_stream │ │ │ -0005e210: 2667 743b 2667 743b 2873 292e 6e65 7874 >>(s).next │ │ │ -0005e220: 5f6c 6179 6572 2829 2e67 6574 5f69 6d70 _layer().get_imp │ │ │ -0005e230: 6c28 293b 0a09 0909 0973 736c 203d 2074 l();.....ssl = t │ │ │ -0005e240: 7261 6e73 706f 7274 3a3a 7373 6c3b 0a09 ransport::ssl;.. │ │ │ -0005e250: 0909 7d0a 0909 0965 6c73 650a 2365 6e64 ..}....else.#end │ │ │ -0005e260: 6966 0a09 0909 0969 6d70 6c20 3d20 7374 if.....impl = st │ │ │ -0005e270: 643a 3a67 6574 266c 743b 7574 705f 7374 d::get<utp_st │ │ │ -0005e280: 7265 616d 2667 743b 2873 292e 6765 745f ream>(s).get_ │ │ │ -0005e290: 696d 706c 2829 3b0a 0a09 0909 7374 643a impl();.....std: │ │ │ -0005e2a0: 3a76 6563 746f 7226 6c74 3b73 7464 3a3a :vector<std:: │ │ │ -0005e2b0: 7368 6172 6564 5f70 7472 266c 743b 6c69 shared_ptr<li │ │ │ -0005e2c0: 7374 656e 5f73 6f63 6b65 745f 7426 6774 sten_socket_t> │ │ │ -0005e2d0: 3b26 6774 3b20 7769 7468 5f67 6174 6577 ;> with_gatew │ │ │ -0005e2e0: 6179 733b 0a09 0909 7374 643a 3a73 6861 ays;....std::sha │ │ │ -0005e2f0: 7265 645f 7074 7226 6c74 3b6c 6973 7465 red_ptr<liste │ │ │ -0005e300: 6e5f 736f 636b 6574 5f74 2667 743b 206d n_socket_t> m │ │ │ -0005e310: 6174 6368 3b0a 0909 0966 6f72 2028 6175 atch;....for (au │ │ │ -0005e320: 746f 2063 6f6e 7374 2661 6d70 3b20 6c73 to const& ls │ │ │ -0005e330: 203a 206d 5f6c 6973 7465 6e5f 736f 636b : m_listen_sock │ │ │ -0005e340: 6574 7329 0a09 0909 7b0a 0909 0909 2f2f ets)....{.....// │ │ │ -0005e350: 2074 6869 7320 6973 2061 6c6d 6f73 742c this is almost, │ │ │ -0005e360: 2062 7574 206e 6f74 2071 7569 7465 2c20 but not quite, │ │ │ -0005e370: 6c69 6b65 2063 616e 5f72 6f75 7465 2829 like can_route() │ │ │ -0005e380: 0a09 0909 0969 6620 2821 286c 732d 2667 .....if (!(ls-&g │ │ │ -0005e390: 743b 666c 6167 7320 2661 6d70 3b20 6c69 t;flags & li │ │ │ -0005e3a0: 7374 656e 5f73 6f63 6b65 745f 743a 3a70 sten_socket_t::p │ │ │ -0005e3b0: 726f 7879 290a 0909 0909 0926 616d 703b roxy)......& │ │ │ -0005e3c0: 2661 6d70 3b20 6973 5f76 3428 6c73 2d26 & is_v4(ls-& │ │ │ -0005e3d0: 6774 3b6c 6f63 616c 5f65 6e64 706f 696e gt;local_endpoin │ │ │ -0005e3e0: 7429 2021 3d20 7265 6d6f 7465 5f61 6464 t) != remote_add │ │ │ -0005e3f0: 7265 7373 2e69 735f 7634 2829 290a 0909 ress.is_v4())... │ │ │ -0005e400: 0909 0963 6f6e 7469 6e75 653b 0a09 0909 ...continue;.... │ │ │ -0005e410: 0969 6620 286c 732d 2667 743b 7373 6c20 .if (ls->ssl │ │ │ -0005e420: 213d 2073 736c 2920 636f 6e74 696e 7565 != ssl) continue │ │ │ -0005e430: 3b0a 0909 0909 6966 2028 2128 6c73 2d26 ;.....if (!(ls-& │ │ │ -0005e440: 6774 3b66 6c61 6773 2026 616d 703b 206c gt;flags & l │ │ │ -0005e450: 6973 7465 6e5f 736f 636b 6574 5f74 3a3a isten_socket_t:: │ │ │ -0005e460: 6c6f 6361 6c5f 6e65 7477 6f72 6b29 290a local_network)). │ │ │ -0005e470: 0909 0909 0977 6974 685f 6761 7465 7761 .....with_gatewa │ │ │ -0005e480: 7973 2e70 7573 685f 6261 636b 286c 7329 ys.push_back(ls) │ │ │ -0005e490: 3b0a 0a09 0909 0969 6620 286c 732d 2667 ;......if (ls-&g │ │ │ -0005e4a0: 743b 666c 6167 7320 2661 6d70 3b20 6c69 t;flags & li │ │ │ -0005e4b0: 7374 656e 5f73 6f63 6b65 745f 743a 3a70 sten_socket_t::p │ │ │ -0005e4c0: 726f 7879 0a09 0909 0909 7c7c 206d 6174 roxy......|| mat │ │ │ -0005e4d0: 6368 5f61 6464 725f 6d61 736b 286c 732d ch_addr_mask(ls- │ │ │ -0005e4e0: 2667 743b 6c6f 6361 6c5f 656e 6470 6f69 >local_endpoi │ │ │ -0005e4f0: 6e74 2e61 6464 7265 7373 2829 2c20 7265 nt.address(), re │ │ │ -0005e500: 6d6f 7465 5f61 6464 7265 7373 2c20 6c73 mote_address, ls │ │ │ -0005e510: 2d26 6774 3b6e 6574 6d61 736b 2929 0a09 ->netmask)).. │ │ │ -0005e520: 0909 097b 0a09 0909 0909 2f2f 2069 7320 ...{......// is │ │ │ -0005e530: 7468 6973 2062 6574 7465 7220 7468 616e this better than │ │ │ -0005e540: 2074 6865 2070 7265 7669 6f75 7320 6d61 the previous ma │ │ │ -0005e550: 7463 683f 0a09 0909 0909 6d61 7463 6820 tch?......match │ │ │ -0005e560: 3d20 6c73 3b0a 0909 0909 7d0a 3c2f 7072 = ls;.....}.rel │ │ │ -0005e5a0: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/se │ │ │ -0005e5e0: 7373 696f 6e5f 696d 706c 2e63 7070 3a36 ssion_impl.cpp:6 │ │ │ -0005e5f0: 3131 393c 2f61 3e3c 2f74 643e 3c74 643e 119 │ │ │ -0005e600: 7265 6661 6374 6f72 2c20 6d6f 7665 2074 refactor, move t │ │ │ -0005e610: 6865 2073 746f 7261 6765 2074 6f20 6468 he storage to dh │ │ │ -0005e620: 745f 7472 6163 6b65 723c 2f74 643e 3c2f t_tracker

    refactor, │ │ │ -0005e680: 206d 6f76 6520 7468 6520 7374 6f72 6167 move the storag │ │ │ -0005e690: 6520 746f 2064 6874 5f74 7261 636b 6572 e to dht_tracker │ │ │ -0005e6a0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -0005e6b0: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ -0005e6c0: 3a36 3131 393c 2f68 343e 3c70 7265 2073 :6119

    #ifndef TORR
    │ │ │ -0005e710: 454e 545f 4449 5341 424c 455f 4c4f 4747  ENT_DISABLE_LOGG
    │ │ │ -0005e720: 494e 470a 0909 0973 6573 7369 6f6e 5f6c  ING....session_l
    │ │ │ -0005e730: 6f67 2822 6e6f 7420 7374 6172 7469 6e67  og("not starting
    │ │ │ -0005e740: 2044 4854 2c20 6f75 7473 7461 6e64 696e   DHT, outstandin
    │ │ │ -0005e750: 6720 726f 7574 6572 206c 6f6f 6b75 7073  g router lookups
    │ │ │ -0005e760: 3a20 2564 220a 0909 0909 2c20 6d5f 6f75  : %d"....., m_ou
    │ │ │ -0005e770: 7473 7461 6e64 696e 675f 726f 7574 6572  tstanding_router
    │ │ │ -0005e780: 5f6c 6f6f 6b75 7073 293b 0a23 656e 6469  _lookups);.#endi
    │ │ │ -0005e790: 660a 0909 0972 6574 7572 6e3b 0a09 097d  f....return;...}
    │ │ │ -0005e7a0: 0a0a 0909 6966 2028 6d5f 6162 6f72 7429  ....if (m_abort)
    │ │ │ -0005e7b0: 0a09 097b 0a23 6966 6e64 6566 2054 4f52  ...{.#ifndef TOR
    │ │ │ -0005e7c0: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47  RENT_DISABLE_LOG
    │ │ │ -0005e7d0: 4749 4e47 0a09 0909 7365 7373 696f 6e5f  GING....session_
    │ │ │ -0005e7e0: 6c6f 6728 226e 6f74 2073 7461 7274 696e  log("not startin
    │ │ │ -0005e7f0: 6720 4448 542c 2061 626f 7274 696e 6722  g DHT, aborting"
    │ │ │ -0005e800: 293b 0a23 656e 6469 660a 0909 0972 6574  );.#endif....ret
    │ │ │ -0005e810: 7572 6e3b 0a09 097d 0a0a 2369 666e 6465  urn;...}..#ifnde
    │ │ │ -0005e820: 6620 544f 5252 454e 545f 4449 5341 424c  f TORRENT_DISABL
    │ │ │ -0005e830: 455f 4c4f 4747 494e 470a 0909 7365 7373  E_LOGGING...sess
    │ │ │ -0005e840: 696f 6e5f 6c6f 6728 2273 7461 7274 696e  ion_log("startin
    │ │ │ -0005e850: 6720 4448 542c 2072 756e 6e69 6e67 3a20  g DHT, running: 
    │ │ │ -0005e860: 2573 2c20 726f 7574 6572 206c 6f6f 6b75  %s, router looku
    │ │ │ -0005e870: 7073 3a20 2564 220a 0909 092c 206d 5f64  ps: %d"...., m_d
    │ │ │ -0005e880: 6874 203f 2022 7472 7565 2220 3a20 2266  ht ? "true" : "f
    │ │ │ -0005e890: 616c 7365 222c 206d 5f6f 7574 7374 616e  alse", m_outstan
    │ │ │ -0005e8a0: 6469 6e67 5f72 6f75 7465 725f 6c6f 6f6b  ding_router_look
    │ │ │ -0005e8b0: 7570 7329 3b0a 2365 6e64 6966 0a0a 3c64  ups);.#endif....m_
    │ │ │ -0005e8f0: 6468 745f 7374 6f72 6167 6520 3d20 6d5f  dht_storage = m_
    │ │ │ -0005e900: 6468 745f 7374 6f72 6167 655f 636f 6e73  dht_storage_cons
    │ │ │ -0005e910: 7472 7563 746f 7228 6d5f 7365 7474 696e  tructor(m_settin
    │ │ │ -0005e920: 6773 293b 0a3c 2f64 6976 3e09 096d 5f64  gs);...m_d
    │ │ │ -0005e930: 6874 203d 2073 7464 3a3a 6d61 6b65 5f73  ht = std::make_s
    │ │ │ -0005e940: 6861 7265 6426 6c74 3b64 6874 3a3a 6468  hared<dht::dh
    │ │ │ -0005e950: 745f 7472 6163 6b65 7226 6774 3b28 0a09  t_tracker>(..
    │ │ │ -0005e960: 0909 7374 6174 6963 5f63 6173 7426 6c74  ..static_cast<
    │ │ │ -0005e970: 3b64 6874 3a3a 6468 745f 6f62 7365 7276  ;dht::dht_observ
    │ │ │ -0005e980: 6572 2a26 6774 3b28 7468 6973 290a 0909  er*>(this)...
    │ │ │ -0005e990: 092c 206d 5f69 6f5f 636f 6e74 6578 740a  ., m_io_context.
    │ │ │ -0005e9a0: 0909 092c 205b 7468 6973 5d28 6175 783a  ..., [this](aux:
    │ │ │ -0005e9b0: 3a6c 6973 7465 6e5f 736f 636b 6574 5f68  :listen_socket_h
    │ │ │ -0005e9c0: 616e 646c 6520 636f 6e73 7426 616d 703b  andle const&
    │ │ │ -0005e9d0: 2073 6f63 6b0a 0909 0909 2c20 7564 703a   sock....., udp:
    │ │ │ -0005e9e0: 3a65 6e64 706f 696e 7420 636f 6e73 7426  :endpoint const&
    │ │ │ -0005e9f0: 616d 703b 2065 700a 0909 0909 2c20 7370  amp; ep....., sp
    │ │ │ -0005ea00: 616e 266c 743b 6368 6172 2063 6f6e 7374  an<char const
    │ │ │ -0005ea10: 2667 743b 2070 0a09 0909 092c 2065 7272  > p....., err
    │ │ │ -0005ea20: 6f72 5f63 6f64 6526 616d 703b 2065 630a  or_code& ec.
    │ │ │ -0005ea30: 0909 0909 2c20 7564 705f 7365 6e64 5f66  ...., udp_send_f
    │ │ │ -0005ea40: 6c61 6773 5f74 2063 6f6e 7374 2066 6c61  lags_t const fla
    │ │ │ -0005ea50: 6773 290a 0909 0909 7b20 7365 6e64 5f75  gs).....{ send_u
    │ │ │ -0005ea60: 6470 5f70 6163 6b65 745f 6c69 7374 656e  dp_packet_listen
    │ │ │ -0005ea70: 2873 6f63 6b2c 2065 702c 2070 2c20 6563  (sock, ep, p, ec
    │ │ │ -0005ea80: 2c20 666c 6167 7329 3b20 7d0a 0909 092c  , flags); }....,
    │ │ │ -0005ea90: 206d 5f73 6574 7469 6e67 730a 0909 092c   m_settings....,
    │ │ │ -0005eaa0: 206d 5f73 7461 7473 5f63 6f75 6e74 6572   m_stats_counter
    │ │ │ -0005eab0: 730a 0909 092c 202a 6d5f 6468 745f 7374  s...., *m_dht_st
    │ │ │ -0005eac0: 6f72 6167 650a 0909 092c 2073 7464 3a3a  orage...., std::
    │ │ │ -0005ead0: 6d6f 7665 286d 5f64 6874 5f73 7461 7465  move(m_dht_state
    │ │ │ -0005eae0: 2929 3b0a 0a09 0966 6f72 2028 6175 746f  ));....for (auto
    │ │ │ -0005eaf0: 2661 6d70 3b20 7320 3a20 6d5f 6c69 7374  & s : m_list
    │ │ │ -0005eb00: 656e 5f73 6f63 6b65 7473 290a 0909 7b0a  en_sockets)...{.
    │ │ │ -0005eb10: 0909 0969 6620 2873 2d26 6774 3b73 736c  ...if (s->ssl
    │ │ │ -0005eb20: 2021 3d20 7472 616e 7370 6f72 743a 3a73   != transport::s
    │ │ │ -0005eb30: 736c 0a09 0909 0926 616d 703b 2661 6d70  sl.....&&
    │ │ │ -0005eb40: 3b20 2128 732d 2667 743b 666c 6167 7320  ; !(s->flags 
    │ │ │ -0005eb50: 2661 6d70 3b20 6c69 7374 656e 5f73 6f63  & listen_soc
    │ │ │ -0005eb60: 6b65 745f 743a 3a6c 6f63 616c 5f6e 6574  ket_t::local_net
    │ │ │ -0005eb70: 776f 726b 2929 0a09 0909 7b0a 0909 0909  work))....{.....
    │ │ │ -0005eb80: 6d5f 6468 742d 2667 743b 6e65 775f 736f  m_dht->new_so
    │ │ │ -0005eb90: 636b 6574 2873 293b 0a09 0909 7d0a 0909  cket(s);....}...
    │ │ │ -0005eba0: 7d0a 0a09 0966 6f72 2028 6175 746f 2063  }....for (auto c
    │ │ │ -0005ebb0: 6f6e 7374 2661 6d70 3b20 6e20 3a20 6d5f  onst& n : m_
    │ │ │ -0005ebc0: 6468 745f 726f 7574 6572 5f6e 6f64 6573  dht_router_nodes
    │ │ │ -0005ebd0: 290a 0909 7b0a 0909 096d 5f64 6874 2d26  )...{....m_dht-&
    │ │ │ -0005ebe0: 6774 3b61 6464 5f72 6f75 7465 725f 6e6f  gt;add_router_no
    │ │ │ -0005ebf0: 6465 286e 293b 0a09 097d 0a0a 0909 666f  de(n);...}....fo
    │ │ │ -0005ec00: 7220 2861 7574 6f20 636f 6e73 7426 616d  r (auto const&am
    │ │ │ -0005ec10: 703b 206e 203a 206d 5f64 6874 5f6e 6f64  p; n : m_dht_nod
    │ │ │ -0005ec20: 6573 290a 0909 7b0a 3c2f 7072 653e 3c2f  es)...{.
    relevan │ │ │ -0005ec60: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/sessio │ │ │ -0005eca0: 6e5f 696d 706c 2e63 7070 3a36 3530 323c n_impl.cpp:6502< │ │ │ -0005ecb0: 2f61 3e3c 2f74 643e 3c74 643e 6173 7365 /a>asse │ │ │ -0005ecc0: 7274 7320 7468 6174 206e 6f20 6f75 7473 rts that no outs │ │ │ -0005ecd0: 7461 6e64 696e 6720 6173 796e 6320 6f70 tanding async op │ │ │ -0005ece0: 6572 6174 696f 6e73 2061 7265 2073 7469 erations are sti │ │ │ -0005ecf0: 6c6c 2069 6e20 666c 6967 6874 3c2f 7464 ll in flight

    assert │ │ │ -0005ed50: 7320 7468 6174 206e 6f20 6f75 7473 7461 s that no outsta │ │ │ -0005ed60: 6e64 696e 6720 6173 796e 6320 6f70 6572 nding async oper │ │ │ -0005ed70: 6174 696f 6e73 2061 7265 2073 7469 6c6c ations are still │ │ │ -0005ed80: 2069 6e20 666c 6967 6874 3c2f 6832 3e3c in flight

    < │ │ │ -0005ed90: 6834 3e2e 2e2f 7372 632f 7365 7373 696f h4>../src/sessio │ │ │ -0005eda0: 6e5f 696d 706c 2e63 7070 3a36 3530 323c n_impl.cpp:6502< │ │ │ -0005edb0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -0005edf0: 6966 2028 216d 5f64 6874 2920 7265 7475  if (!m_dht) retu
    │ │ │ -0005ee00: 726e 3b0a 0909 6d5f 6468 742d 2667 743b  rn;...m_dht->
    │ │ │ -0005ee10: 6469 7265 6374 5f72 6571 7565 7374 2865  direct_request(e
    │ │ │ -0005ee20: 702c 2065 2c20 7374 643a 3a62 696e 6428  p, e, std::bind(
    │ │ │ -0005ee30: 2661 6d70 3b6f 6e5f 6469 7265 6374 5f72  &on_direct_r
    │ │ │ -0005ee40: 6573 706f 6e73 652c 2073 7464 3a3a 7265  esponse, std::re
    │ │ │ -0005ee50: 6628 6d5f 616c 6572 7473 292c 2075 7365  f(m_alerts), use
    │ │ │ -0005ee60: 7264 6174 612c 205f 3129 293b 0a09 7d0a  rdata, _1));..}.
    │ │ │ -0005ee70: 0a23 656e 6469 660a 0a09 626f 6f6c 2073  .#endif...bool s
    │ │ │ -0005ee80: 6573 7369 6f6e 5f69 6d70 6c3a 3a69 735f  ession_impl::is_
    │ │ │ -0005ee90: 6c69 7374 656e 696e 6728 2920 636f 6e73  listening() cons
    │ │ │ -0005eea0: 740a 097b 0a09 0972 6574 7572 6e20 216d  t..{...return !m
    │ │ │ -0005eeb0: 5f6c 6973 7465 6e5f 736f 636b 6574 732e  _listen_sockets.
    │ │ │ -0005eec0: 656d 7074 7928 293b 0a09 7d0a 0a09 7365  empty();..}...se
    │ │ │ -0005eed0: 7373 696f 6e5f 696d 706c 3a3a 7e73 6573  ssion_impl::~ses
    │ │ │ -0005eee0: 7369 6f6e 5f69 6d70 6c28 290a 097b 0a09  sion_impl()..{..
    │ │ │ -0005eef0: 092f 2f20 7369 6e63 6520 7765 2772 6520  .// since we're 
    │ │ │ -0005ef00: 6465 7374 7275 6374 696e 6720 7468 6520  destructing the 
    │ │ │ -0005ef10: 7365 7373 696f 6e2c 206e 6f20 6d6f 7265  session, no more
    │ │ │ -0005ef20: 2061 6c65 7274 7320 7769 6c6c 206d 616b   alerts will mak
    │ │ │ -0005ef30: 6520 6974 206f 7574 2074 6f0a 0909 2f2f  e it out to...//
    │ │ │ -0005ef40: 2074 6865 2075 7365 722e 2053 6f20 7374   the user. So st
    │ │ │ -0005ef50: 6f70 2070 6f73 7469 6e67 2074 6865 6d20  op posting them 
    │ │ │ -0005ef60: 6e6f 770a 0909 6d5f 616c 6572 7473 2e73  now...m_alerts.s
    │ │ │ -0005ef70: 6574 5f61 6c65 7274 5f6d 6173 6b28 7b7d  et_alert_mask({}
    │ │ │ -0005ef80: 293b 0a09 096d 5f61 6c65 7274 732e 7365  );...m_alerts.se
    │ │ │ -0005ef90: 745f 6e6f 7469 6679 5f66 756e 6374 696f  t_notify_functio
    │ │ │ -0005efa0: 6e28 7b7d 293b 0a0a 0909 2f2f 2074 6869  n({});....// thi
    │ │ │ -0005efb0: 7320 6973 206e 6f74 2061 6c6c 6f77 6564  s is not allowed
    │ │ │ -0005efc0: 2074 6f20 6265 2074 6865 206e 6574 776f   to be the netwo
    │ │ │ -0005efd0: 726b 2074 6872 6561 6421 0a2f 2f09 0954  rk thread!.//..T
    │ │ │ -0005efe0: 4f52 5245 4e54 5f41 5353 4552 5428 6973  ORRENT_ASSERT(is
    │ │ │ -0005eff0: 5f6e 6f74 5f74 6872 6561 6428 2929 3b0a  _not_thread());.
    │ │ │ -0005f000: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .< │ │ │ -0005f030: 2f64 6976 3e09 092f 2f20 7468 6973 2063 /div>..// this c │ │ │ -0005f040: 616e 2068 6170 7065 6e20 6966 2077 6520 an happen if we │ │ │ -0005f050: 656e 6420 7468 6520 696f 5f63 6f6e 7465 end the io_conte │ │ │ -0005f060: 7874 2072 756e 206c 6f6f 7020 7769 7468 xt run loop with │ │ │ -0005f070: 2061 6e20 6578 6365 7074 696f 6e0a 0909 an exception... │ │ │ -0005f080: 6d5f 636f 6e6e 6563 7469 6f6e 732e 636c m_connections.cl │ │ │ -0005f090: 6561 7228 293b 0a09 0966 6f72 2028 6175 ear();...for (au │ │ │ -0005f0a0: 746f 2661 6d70 3b20 7420 3a20 6d5f 746f to& t : m_to │ │ │ -0005f0b0: 7272 656e 7473 290a 0909 7b0a 0909 0974 rrents)...{....t │ │ │ -0005f0c0: 2d26 6774 3b70 616e 6963 2829 3b0a 0909 ->panic();... │ │ │ -0005f0d0: 0974 2d26 6774 3b61 626f 7274 2829 3b0a .t->abort();. │ │ │ -0005f0e0: 0909 7d0a 0909 6d5f 746f 7272 656e 7473 ..}...m_torrents │ │ │ -0005f0f0: 2e63 6c65 6172 2829 3b0a 0a09 092f 2f20 .clear();....// │ │ │ -0005f100: 7468 6973 2068 6173 2070 726f 6261 626c this has probabl │ │ │ -0005f110: 7920 6265 656e 2063 616c 6c65 6420 616c y been called al │ │ │ -0005f120: 7265 6164 792c 2062 7574 2069 6e20 6361 ready, but in ca │ │ │ -0005f130: 7365 206f 6620 7375 6464 656e 0a09 092f se of sudden.../ │ │ │ -0005f140: 2f20 7465 726d 696e 6174 696f 6e20 7468 / termination th │ │ │ -0005f150: 726f 7567 6820 616e 2065 7863 6570 7469 rough an excepti │ │ │ -0005f160: 6f6e 2c20 6974 206d 6179 206e 6f74 2068 on, it may not h │ │ │ -0005f170: 6176 6520 6265 656e 2064 6f6e 650a 0909 ave been done... │ │ │ -0005f180: 6162 6f72 745f 7374 6167 6532 2829 3b0a abort_stage2();. │ │ │ -0005f190: 0a23 6966 2064 6566 696e 6564 2054 4f52 .#if defined TOR │ │ │ -0005f1a0: 5245 4e54 5f41 5349 4f5f 4445 4255 4747 RENT_ASIO_DEBUGG │ │ │ -0005f1b0: 494e 470a 0909 4649 4c45 2a20 6620 3d20 ING...FILE* f = │ │ │ -0005f1c0: 666f 7065 6e28 2277 616b 6575 7073 2e6c fopen("wakeups.l │ │ │ -0005f1d0: 6f67 222c 2022 772b 2229 3b0a 0909 6966 og", "w+");...if │ │ │ -0005f1e0: 2028 6620 213d 206e 756c 6c70 7472 290a (f != nullptr). │ │ │ -0005f1f0: 0909 7b0a 0909 0974 696d 655f 706f 696e ..{....time_poin │ │ │ -0005f200: 7420 6d20 3d20 6d69 6e5f 7469 6d65 2829 t m = min_time() │ │ │ -0005f210: 3b0a 0909 0969 6620 2821 5f77 616b 6575 ;....if (!_wakeu │ │ │ -0005f220: 7073 2e65 6d70 7479 2829 2920 6d20 3d20 ps.empty()) m = │ │ │ -0005f230: 5f77 616b 6575 7073 5b30 5d2e 7469 6d65 _wakeups[0].time │ │ │ -0005f240: 7374 616d 703b 0a09 0909 7469 6d65 5f70 stamp;....time_p │ │ │ -0005f250: 6f69 6e74 2070 7265 7620 3d20 6d3b 0a09 oint prev = m;.. │ │ │ -0005f260: 0909 7374 643a 3a75 696e 7436 345f 7420 ..std::uint64_t │ │ │ -0005f270: 7072 6576 5f63 7377 203d 2030 3b0a 0909 prev_csw = 0;... │ │ │ -0005f280: 0969 6620 2821 5f77 616b 6575 7073 2e65 .if (!_wakeups.e │ │ │ -0005f290: 6d70 7479 2829 2920 7072 6576 5f63 7377 mpty()) prev_csw │ │ │ -0005f2a0: 203d 205f 7761 6b65 7570 735b 305d 2e63 = _wakeups[0].c │ │ │ -0005f2b0: 6f6e 7465 7874 5f73 7769 7463 6865 733b ontext_switches; │ │ │ -0005f2c0: 0a09 0909 7374 643a 3a66 7072 696e 7466 ....std::fprintf │ │ │ -0005f2d0: 2866 2c20 2261 6273 2e20 7469 6d65 5c74 (f, "abs. time\t │ │ │ -0005f2e0: 7265 6c2e 2074 696d 655c 7463 7478 2073 rel. time\tctx s │ │ │ -0005f2f0: 7769 7463 685c 7469 646c 652d 7761 6b65 witch\tidle-wake │ │ │ -0005f300: 7570 5c74 6f70 6572 6174 696f 6e5c 6e22 up\toperation\n" │ │ │ -0005f310: 293b 0a09 0909 666f 7220 2877 616b 6575 );....for (wakeu │ │ │ -0005f320: 705f 7420 636f 6e73 7426 616d 703b 2077 p_t const& w │ │ │ -0005f330: 203a 205f 7761 6b65 7570 7329 0a09 0909 : _wakeups).... │ │ │ -0005f340: 7b0a 0909 0909 626f 6f6c 2063 6f6e 7374 {.....bool const │ │ │ -0005f350: 2069 646c 655f 7761 6b65 7570 203d 2077 idle_wakeup = w │ │ │ -0005f360: 2e63 6f6e 7465 7874 5f73 7769 7463 6865 .context_switche │ │ │ -0005f370: 7320 2667 743b 2070 7265 765f 6373 773b s > prev_csw; │ │ │ -0005f380: 0a09 0909 0973 7464 3a3a 6670 7269 6e74 .....std::fprint │ │ │ -0005f390: 6628 662c 2022 2522 2050 5249 6436 3420 f(f, "%" PRId64 │ │ │ -0005f3a0: 225c 7425 2220 5052 4964 3634 2022 5c74 "\t%" PRId64 "\t │ │ │ -0005f3b0: 2522 2050 5249 6436 3420 225c 7425 635c %" PRId64 "\t%c\ │ │ │ -0005f3c0: 7425 735c 6e22 0a09 0909 0909 2c20 746f t%s\n"......, to │ │ │ -0005f3d0: 7461 6c5f 6d69 6372 6f73 6563 6f6e 6473 tal_microseconds │ │ │ -0005f3e0: 2877 2e74 696d 6573 7461 6d70 202d 206d (w.timestamp - m │ │ │ -0005f3f0: 290a 0909 0909 092c 2074 6f74 616c 5f6d )......, total_m │ │ │ -0005f400: 6963 726f 7365 636f 6e64 7328 772e 7469 icroseconds(w.ti │ │ │ -0005f410: 6d65 7374 616d 7020 2d20 7072 6576 290a mestamp - prev). │ │ │ -0005f420: 0909 0909 092c 2077 2e63 6f6e 7465 7874 ....., w.context │ │ │ -0005f430: 5f73 7769 7463 6865 730a 3c2f 7072 653e _switches.
    │ │ │ -0005f440: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0005f470: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0005f480: 3c74 643e 3c61 2068 7265 663d 226a 6176
    ../src/mmap │ │ │ -0005f4b0: 5f64 6973 6b5f 696f 2e63 7070 3a33 3737 _disk_io.cpp:377 │ │ │ -0005f4c0: 3c2f 613e 3c2f 7464 3e3c 7464 3e69 6e20 in │ │ │ -0005f4d0: 7468 6520 6675 7475 7265 2c20 7072 6f70 the future, prop │ │ │ -0005f4e0: 6167 6174 6520 6578 6365 7074 696f 6e73 agate exceptions │ │ │ -0005f4f0: 2062 6163 6b20 746f 2074 6865 2068 616e back to the han │ │ │ -0005f500: 646c 6572 733c 2f74 643e 3c2f 7472 3e3c dlers< │ │ │ -0005f510: 7472 2069 643d 2232 3230 2220 7374 796c tr id="220" styl │ │ │ -0005f520: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -0005f530: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -0005f540: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -0005f550: 6832 3e69 6e20 7468 6520 6675 7475 7265 h2>in the future │ │ │ -0005f560: 2c20 7072 6f70 6167 6174 6520 6578 6365 , propagate exce │ │ │ -0005f570: 7074 696f 6e73 2062 6163 6b20 746f 2074 ptions back to t │ │ │ -0005f580: 6865 2068 616e 646c 6572 733c 2f68 323e he handlers │ │ │ -0005f590: 3c68 343e 2e2e 2f73 7263 2f6d 6d61 705f

    ../src/mmap_ │ │ │ -0005f5a0: 6469 736b 5f69 6f2e 6370 703a 3337 373c disk_io.cpp:377< │ │ │ -0005f5b0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    .v
    │ │ │ -0005f5f0: 6f69 6420 6d6d 6170 5f64 6973 6b5f 696f  oid mmap_disk_io
    │ │ │ -0005f600: 3a3a 7065 7266 6f72 6d5f 6a6f 6228 6175  ::perform_job(au
    │ │ │ -0005f610: 783a 3a6d 6d61 705f 6469 736b 5f6a 6f62  x::mmap_disk_job
    │ │ │ -0005f620: 2a20 6a2c 206a 6f62 7175 6575 655f 7426  * j, jobqueue_t&
    │ │ │ -0005f630: 616d 703b 2063 6f6d 706c 6574 6564 5f6a  amp; completed_j
    │ │ │ -0005f640: 6f62 7329 0a09 7b0a 0909 544f 5252 454e  obs)..{...TORREN
    │ │ │ -0005f650: 545f 4153 5345 5254 286a 2d26 6774 3b6e  T_ASSERT(j->n
    │ │ │ -0005f660: 6578 7420 3d3d 206e 756c 6c70 7472 293b  ext == nullptr);
    │ │ │ -0005f670: 0a09 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ -0005f680: 5428 286a 2d26 6774 3b66 6c61 6773 2026  T((j->flags &
    │ │ │ -0005f690: 616d 703b 2061 7578 3a3a 6469 736b 5f6a  amp; aux::disk_j
    │ │ │ -0005f6a0: 6f62 3a3a 696e 5f70 726f 6772 6573 7329  ob::in_progress)
    │ │ │ -0005f6b0: 207c 7c20 216a 2d26 6774 3b73 746f 7261   || !j->stora
    │ │ │ -0005f6c0: 6765 293b 0a0a 2369 6620 4445 4255 475f  ge);..#if DEBUG_
    │ │ │ -0005f6d0: 4449 534b 5f54 4852 4541 440a 0909 7b0a  DISK_THREAD...{.
    │ │ │ -0005f6e0: 0909 0973 7464 3a3a 756e 6971 7565 5f6c  ...std::unique_l
    │ │ │ -0005f6f0: 6f63 6b26 6c74 3b73 7464 3a3a 6d75 7465  ock<std::mute
    │ │ │ -0005f700: 7826 6774 3b20 6c28 6d5f 6a6f 625f 6d75  x> l(m_job_mu
    │ │ │ -0005f710: 7465 7829 3b0a 0a09 0909 444c 4f47 2822  tex);.....DLOG("
    │ │ │ -0005f720: 7065 7266 6f72 6d5f 6a6f 6220 6a6f 623a  perform_job job:
    │ │ │ -0005f730: 2025 7320 6f75 7473 7461 6e64 696e 673a   %s outstanding:
    │ │ │ -0005f740: 2025 645c 6e22 0a09 0909 092c 2070 7269   %d\n"....., pri
    │ │ │ -0005f750: 6e74 5f6a 6f62 282a 6a29 2e63 5f73 7472  nt_job(*j).c_str
    │ │ │ -0005f760: 2829 0a09 0909 092c 206a 2d26 6774 3b73  ()....., j->s
    │ │ │ -0005f770: 746f 7261 6765 203f 206a 2d26 6774 3b73  torage ? j->s
    │ │ │ -0005f780: 746f 7261 6765 2d26 6774 3b6e 756d 5f6f  torage->num_o
    │ │ │ -0005f790: 7574 7374 616e 6469 6e67 5f6a 6f62 7328  utstanding_jobs(
    │ │ │ -0005f7a0: 2920 3a20 2d31 293b 0a09 097d 0a23 656e  ) : -1);...}.#en
    │ │ │ -0005f7b0: 6469 660a 0a09 0973 7464 3a3a 7368 6172  dif....std::shar
    │ │ │ -0005f7c0: 6564 5f70 7472 266c 743b 6175 783a 3a6d  ed_ptr<aux::m
    │ │ │ -0005f7d0: 6d61 705f 7374 6f72 6167 6526 6774 3b20  map_storage> 
    │ │ │ -0005f7e0: 7374 6f72 6167 6520 3d20 6a2d 2667 743b  storage = j->
    │ │ │ -0005f7f0: 7374 6f72 6167 653b 0a0a 0909 6d5f 7374  storage;....m_st
    │ │ │ -0005f800: 6174 735f 636f 756e 7465 7273 2e69 6e63  ats_counters.inc
    │ │ │ -0005f810: 5f73 7461 7473 5f63 6f75 6e74 6572 2863  _stats_counter(c
    │ │ │ -0005f820: 6f75 6e74 6572 733a 3a6e 756d 5f72 756e  ounters::num_run
    │ │ │ -0005f830: 6e69 6e67 5f64 6973 6b5f 6a6f 6273 2c20  ning_disk_jobs, 
    │ │ │ -0005f840: 3129 3b0a 0a09 092f 2f20 6361 6c6c 2064  1);....// call d
    │ │ │ -0005f850: 6973 6b20 6675 6e63 7469 6f6e 0a3c 6469  isk function...sta
    │ │ │ -0005f890: 7475 735f 7420 7265 747b 7d3b 0a3c 2f64  tus_t ret{};...try...{....
    │ │ │ -0005f8b0: 7265 7420 3d20 7374 643a 3a76 6973 6974  ret = std::visit
    │ │ │ -0005f8c0: 285b 7468 6973 2c20 6a5d 2861 7574 6f26  ([this, j](auto&
    │ │ │ -0005f8d0: 616d 703b 2061 2920 7b20 7265 7475 726e  amp; a) { return
    │ │ │ -0005f8e0: 2074 6869 732d 2667 743b 646f 5f6a 6f62   this->do_job
    │ │ │ -0005f8f0: 2861 2c20 6a29 3b20 7d2c 206a 2d26 6774  (a, j); }, j->
    │ │ │ -0005f900: 3b61 6374 696f 6e29 3b0a 0909 7d0a 0909  ;action);...}...
    │ │ │ -0005f910: 6361 7463 6820 2862 6f6f 7374 3a3a 7379  catch (boost::sy
    │ │ │ -0005f920: 7374 656d 3a3a 7379 7374 656d 5f65 7272  stem::system_err
    │ │ │ -0005f930: 6f72 2063 6f6e 7374 2661 6d70 3b20 6572  or const& er
    │ │ │ -0005f940: 7229 0a09 097b 0a09 0909 7265 7420 3d20  r)...{....ret = 
    │ │ │ -0005f950: 6469 736b 5f73 7461 7475 733a 3a66 6174  disk_status::fat
    │ │ │ -0005f960: 616c 5f64 6973 6b5f 6572 726f 723b 0a09  al_disk_error;..
    │ │ │ -0005f970: 0909 6a2d 2667 743b 6572 726f 722e 6563  ..j->error.ec
    │ │ │ -0005f980: 203d 2065 7272 2e63 6f64 6528 293b 0a09   = err.code();..
    │ │ │ -0005f990: 0909 6a2d 2667 743b 6572 726f 722e 6f70  ..j->error.op
    │ │ │ -0005f9a0: 6572 6174 696f 6e20 3d20 6f70 6572 6174  eration = operat
    │ │ │ -0005f9b0: 696f 6e5f 743a 3a65 7863 6570 7469 6f6e  ion_t::exception
    │ │ │ -0005f9c0: 3b0a 0909 7d0a 0909 6361 7463 6820 2873  ;...}...catch (s
    │ │ │ -0005f9d0: 7464 3a3a 6261 645f 616c 6c6f 6320 636f  td::bad_alloc co
    │ │ │ -0005f9e0: 6e73 7426 616d 703b 290a 0909 7b0a 0909  nst&)...{...
    │ │ │ -0005f9f0: 0972 6574 203d 2064 6973 6b5f 7374 6174  .ret = disk_stat
    │ │ │ -0005fa00: 7573 3a3a 6661 7461 6c5f 6469 736b 5f65  us::fatal_disk_e
    │ │ │ -0005fa10: 7272 6f72 3b0a 0909 096a 2d26 6774 3b65  rror;....j->e
    │ │ │ -0005fa20: 7272 6f72 2e65 6320 3d20 6572 726f 7273  rror.ec = errors
    │ │ │ -0005fa30: 3a3a 6e6f 5f6d 656d 6f72 793b 0a09 0909  ::no_memory;....
    │ │ │ -0005fa40: 6a2d 2667 743b 6572 726f 722e 6f70 6572  j->error.oper
    │ │ │ -0005fa50: 6174 696f 6e20 3d20 6f70 6572 6174 696f  ation = operatio
    │ │ │ -0005fa60: 6e5f 743a 3a65 7863 6570 7469 6f6e 3b0a  n_t::exception;.
    │ │ │ -0005fa70: 0909 7d0a 0909 6361 7463 6820 2873 7464  ..}...catch (std
    │ │ │ -0005fa80: 3a3a 6578 6365 7074 696f 6e20 636f 6e73  ::exception cons
    │ │ │ -0005fa90: 7426 616d 703b 290a 0909 7b0a 0909 0972  t&)...{....r
    │ │ │ -0005faa0: 6574 203d 2064 6973 6b5f 7374 6174 7573  et = disk_status
    │ │ │ -0005fab0: 3a3a 6661 7461 6c5f 6469 736b 5f65 7272  ::fatal_disk_err
    │ │ │ -0005fac0: 6f72 3b0a 0909 096a 2d26 6774 3b65 7272  or;....j->err
    │ │ │ -0005fad0: 6f72 2e65 6320 3d20 626f 6f73 743a 3a61  or.ec = boost::a
    │ │ │ -0005fae0: 7369 6f3a 3a65 7272 6f72 3a3a 6661 756c  sio::error::faul
    │ │ │ -0005faf0: 743b 0a09 0909 6a2d 2667 743b 6572 726f  t;....j->erro
    │ │ │ -0005fb00: 722e 6f70 6572 6174 696f 6e20 3d20 6f70  r.operation = op
    │ │ │ -0005fb10: 6572 6174 696f 6e5f 743a 3a65 7863 6570  eration_t::excep
    │ │ │ -0005fb20: 7469 6f6e 3b0a 0909 7d0a 0a09 092f 2f20  tion;...}....// 
    │ │ │ -0005fb30: 6e6f 7465 2074 6861 7420 2d32 2065 7272  note that -2 err
    │ │ │ -0005fb40: 6f72 7320 6172 6520 4f4b 0a09 0954 4f52  ors are OK...TOR
    │ │ │ -0005fb50: 5245 4e54 5f41 5353 4552 5428 2128 7265  RENT_ASSERT(!(re
    │ │ │ -0005fb60: 7420 2661 6d70 3b20 6469 736b 5f73 7461  t & disk_sta
    │ │ │ -0005fb70: 7475 733a 3a66 6174 616c 5f64 6973 6b5f  tus::fatal_disk_
    │ │ │ -0005fb80: 6572 726f 7229 0a09 0909 7c7c 2028 6a2d  error)....|| (j-
    │ │ │ -0005fb90: 2667 743b 6572 726f 722e 6563 2026 616d  >error.ec &am
    │ │ │ -0005fba0: 703b 2661 6d70 3b20 6a2d 2667 743b 6572  p;& j->er
    │ │ │ -0005fbb0: 726f 722e 6f70 6572 6174 696f 6e20 213d  ror.operation !=
    │ │ │ -0005fbc0: 206f 7065 7261 7469 6f6e 5f74 3a3a 756e   operation_t::un
    │ │ │ -0005fbd0: 6b6e 6f77 6e29 293b 0a0a 0909 6d5f 7374  known));....m_st
    │ │ │ -0005fbe0: 6174 735f 636f 756e 7465 7273 2e69 6e63  ats_counters.inc
    │ │ │ -0005fbf0: 5f73 7461 7473 5f63 6f75 6e74 6572 2863  _stats_counter(c
    │ │ │ -0005fc00: 6f75 6e74 6572 733a 3a6e 756d 5f72 756e  ounters::num_run
    │ │ │ -0005fc10: 6e69 6e67 5f64 6973 6b5f 6a6f 6273 2c20  ning_disk_jobs, 
    │ │ │ -0005fc20: 2d31 293b 0a0a 0909 6a2d 2667 743b 7265  -1);....j->re
    │ │ │ -0005fc30: 7420 3d20 7265 743b 0a3c 2f70 7265 3e3c  t = ret;.
    < │ │ │ -0005fc40: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -0005fc70: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -0005fc80: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/mmap_ │ │ │ -0005fcb0: 6469 736b 5f69 6f2e 6370 703a 3835 363c disk_io.cpp:856< │ │ │ -0005fcc0: 2f61 3e3c 2f74 643e 3c74 643e 7468 6973 /a>this │ │ │ -0005fcd0: 2069 7320 706f 7465 6e74 6961 6c6c 7920 is potentially │ │ │ -0005fce0: 7665 7279 2065 7870 656e 7369 7665 2e20 very expensive. │ │ │ -0005fcf0: 4f6e 6520 7761 7920 746f 2073 6f6c 7665 One way to solve │ │ │ -0005fd00: 2069 7420 776f 756c 6420 6265 2074 6f20 it would be to │ │ │ -0005fd10: 6861 7665 2061 2066 656e 6365 2066 6f72 have a fence for │ │ │ -0005fd20: 206a 7573 7420 7468 6973 206f 6e65 2070 just this one p │ │ │ -0005fd30: 6965 6365 2e20 6275 7420 6974 2068 6172 iece. but it har │ │ │ -0005fd40: 646c 7920 7365 656d 7320 776f 7274 6820 dly seems worth │ │ │ -0005fd50: 7468 6520 636f 6d70 6c65 7869 7479 2061 the complexity a │ │ │ -0005fd60: 6e64 2063 6f73 7420 6a75 7374 2066 6f72 nd cost just for │ │ │ -0005fd70: 2074 6865 2065 6467 6520 6361 7365 206f the edge case o │ │ │ -0005fd80: 6620 7265 6365 6976 696e 6720 6120 636f f receiving a co │ │ │ -0005fd90: 7272 7570 7420 7069 6563 653c 2f74 643e rrupt piece │ │ │ -0005fda0: 3c2f 7472 3e3c 7472 2069 643d 2232 3231

    this is │ │ │ -0005fdf0: 2070 6f74 656e 7469 616c 6c79 2076 6572 potentially ver │ │ │ -0005fe00: 7920 6578 7065 6e73 6976 652e 204f 6e65 y expensive. One │ │ │ -0005fe10: 2077 6179 2074 6f20 736f 6c76 650a 6974 way to solve.it │ │ │ -0005fe20: 2077 6f75 6c64 2062 6520 746f 2068 6176 would be to hav │ │ │ -0005fe30: 6520 6120 6665 6e63 6520 666f 7220 6a75 e a fence for ju │ │ │ -0005fe40: 7374 2074 6869 7320 6f6e 6520 7069 6563 st this one piec │ │ │ -0005fe50: 652e 0a62 7574 2069 7420 6861 7264 6c79 e..but it hardly │ │ │ -0005fe60: 2073 6565 6d73 2077 6f72 7468 2074 6865 seems worth the │ │ │ -0005fe70: 2063 6f6d 706c 6578 6974 7920 616e 6420 complexity and │ │ │ -0005fe80: 636f 7374 206a 7573 7420 666f 7220 7468 cost just for th │ │ │ -0005fe90: 6520 6564 6765 0a63 6173 6520 6f66 2072 e edge.case of r │ │ │ -0005fea0: 6563 6569 7669 6e67 2061 2063 6f72 7275 eceiving a corru │ │ │ -0005feb0: 7074 2070 6965 6365 3c2f 6832 3e3c 6834 pt piece

    ../src/mmap_dis │ │ │ -0005fed0: 6b5f 696f 2e63 7070 3a38 3536 3c2f 6834 k_io.cpp:856

    ...st
    │ │ │ -0005ff20: 643a 3a6d 6f76 6528 7072 696f 7329 0a09  d::move(prios)..
    │ │ │ -0005ff30: 0929 3b0a 0a09 0961 6464 5f66 656e 6365  .);....add_fence
    │ │ │ -0005ff40: 5f6a 6f62 286a 293b 0a09 7d0a 0a09 766f  _job(j);..}...vo
    │ │ │ -0005ff50: 6964 206d 6d61 705f 6469 736b 5f69 6f3a  id mmap_disk_io:
    │ │ │ -0005ff60: 3a61 7379 6e63 5f63 6c65 6172 5f70 6965  :async_clear_pie
    │ │ │ -0005ff70: 6365 2873 746f 7261 6765 5f69 6e64 6578  ce(storage_index
    │ │ │ -0005ff80: 5f74 2063 6f6e 7374 2073 746f 7261 6765  _t const storage
    │ │ │ -0005ff90: 0a09 092c 2070 6965 6365 5f69 6e64 6578  ..., piece_index
    │ │ │ -0005ffa0: 5f74 2063 6f6e 7374 2069 6e64 6578 2c20  _t const index, 
    │ │ │ -0005ffb0: 7374 643a 3a66 756e 6374 696f 6e26 6c74  std::function<
    │ │ │ -0005ffc0: 3b76 6f69 6428 7069 6563 655f 696e 6465  ;void(piece_inde
    │ │ │ -0005ffd0: 785f 7429 2667 743b 2068 616e 646c 6572  x_t)> handler
    │ │ │ -0005ffe0: 290a 097b 0a09 0961 7578 3a3a 6d6d 6170  )..{...aux::mmap
    │ │ │ -0005fff0: 5f64 6973 6b5f 6a6f 622a 206a 203d 206d  _disk_job* j = m
    │ │ │ -00060000: 5f6a 6f62 5f70 6f6f 6c2e 616c 6c6f 6361  _job_pool.alloca
    │ │ │ -00060010: 7465 5f6a 6f62 266c 743b 6175 783a 3a6a  te_job<aux::j
    │ │ │ -00060020: 6f62 3a3a 636c 6561 725f 7069 6563 6526  ob::clear_piece&
    │ │ │ -00060030: 6774 3b28 0a09 0909 7b7d 2c0a 0909 096d  gt;(....{},....m
    │ │ │ -00060040: 5f74 6f72 7265 6e74 735b 7374 6f72 6167  _torrents[storag
    │ │ │ -00060050: 655d 2d26 6774 3b73 6861 7265 645f 6672  e]->shared_fr
    │ │ │ -00060060: 6f6d 5f74 6869 7328 292c 0a09 0909 7374  om_this(),....st
    │ │ │ -00060070: 643a 3a6d 6f76 6528 6861 6e64 6c65 7229  d::move(handler)
    │ │ │ -00060080: 2c0a 0909 0969 6e64 6578 0a09 0929 3b0a  ,....index...);.
    │ │ │ -00060090: 0a09 092f 2f20 7265 6775 6c61 7220 6a6f  ...// regular jo
    │ │ │ -000600a0: 6273 2061 7265 206e 6f74 2067 7561 7261  bs are not guara
    │ │ │ -000600b0: 6e74 6565 6420 746f 2062 6520 6578 6563  nteed to be exec
    │ │ │ -000600c0: 7574 6564 2069 6e2d 6f72 6465 720a 0909  uted in-order...
    │ │ │ -000600d0: 2f2f 2073 696e 6365 2063 6c65 6172 2070  // since clear p
    │ │ │ -000600e0: 6965 6365 206d 7573 7420 6775 6172 616e  iece must guaran
    │ │ │ -000600f0: 7465 6520 7468 6174 2061 6c6c 2077 7269  tee that all wri
    │ │ │ -00060100: 7465 206a 6f62 7320 7468 6174 0a09 092f  te jobs that.../
    │ │ │ -00060110: 2f20 6861 7665 2062 6565 6e20 6973 7375  / have been issu
    │ │ │ -00060120: 6564 2066 696e 6973 6820 6265 666f 7265  ed finish before
    │ │ │ -00060130: 2074 6865 2063 6c65 6172 2070 6965 6365   the clear piece
    │ │ │ -00060140: 206a 6f62 2063 6f6d 706c 6574 6573 0a0a   job completes..
    │ │ │ -00060150: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .< │ │ │ -00060180: 2f64 6976 3e3c 2f70 7265 3e3c 2f74 643e /div>
    │ │ │ -00060190: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -000601c0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -000601d0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -000601e0: 7074 3a65 7870 616e 6428 3232 3229 223e pt:expand(222)"> │ │ │ -000601f0: 2e2e 2f73 7263 2f6d 6d61 705f 6469 736b ../src/mmap_disk │ │ │ -00060200: 5f69 6f2e 6370 703a 3836 313c 2f61 3e3c _io.cpp:861
    < │ │ │ -00060210: 2f74 643e 3c74 643e 5065 7268 6170 7320 /td>Perhaps │ │ │ -00060220: 7468 6520 6a6f 6220 7175 6575 6520 636f the job queue co │ │ │ -00060230: 756c 6420 6265 2074 7261 7665 7273 6564 uld be traversed │ │ │ -00060240: 2061 6e64 2061 6c6c 206a 6f62 7320 666f and all jobs fo │ │ │ -00060250: 7220 7468 6973 2070 6965 6365 2063 6f75 r this piece cou │ │ │ -00060260: 6c64 2062 6520 6361 6e63 656c 6c65 642e ld be cancelled. │ │ │ -00060270: 2049 6620 7468 6572 6520 6172 6520 6e6f If there are no │ │ │ -00060280: 2074 6872 6561 6473 2063 7572 7265 6e74 threads current │ │ │ -00060290: 6c79 2077 7269 7469 6e67 2074 6f20 7468 ly writing to th │ │ │ -000602a0: 6973 2070 6965 6365 2c20 7765 2063 6f75 is piece, we cou │ │ │ -000602b0: 6c64 2073 6b69 7020 7468 6520 6665 6e63 ld skip the fenc │ │ │ -000602c0: 6520 616c 746f 6765 7468 6572 3c2f 7464 e altogether

    Perhap │ │ │ -00060320: 7320 7468 6520 6a6f 6220 7175 6575 6520 s the job queue │ │ │ -00060330: 636f 756c 6420 6265 2074 7261 7665 7273 could be travers │ │ │ -00060340: 6564 2061 6e64 2061 6c6c 206a 6f62 7320 ed and all jobs │ │ │ -00060350: 666f 7220 7468 6973 0a70 6965 6365 2063 for this.piece c │ │ │ -00060360: 6f75 6c64 2062 6520 6361 6e63 656c 6c65 ould be cancelle │ │ │ -00060370: 642e 2049 6620 7468 6572 6520 6172 6520 d. If there are │ │ │ -00060380: 6e6f 2074 6872 6561 6473 2063 7572 7265 no threads curre │ │ │ -00060390: 6e74 6c79 2077 7269 7469 6e67 0a74 6f20 ntly writing.to │ │ │ -000603a0: 7468 6973 2070 6965 6365 2c20 7765 2063 this piece, we c │ │ │ -000603b0: 6f75 6c64 2073 6b69 7020 7468 6520 6665 ould skip the fe │ │ │ -000603c0: 6e63 6520 616c 746f 6765 7468 6572 3c2f nce altogether

    ../src/mm │ │ │ -000603e0: 6170 5f64 6973 6b5f 696f 2e63 7070 3a38 ap_disk_io.cpp:8 │ │ │ -000603f0: 3631 3c2f 6834 3e3c 7072 6520 7374 796c 61

    ..);....add_fen
    │ │ │ -00060440: 6365 5f6a 6f62 286a 293b 0a09 7d0a 0a09  ce_job(j);..}...
    │ │ │ -00060450: 766f 6964 206d 6d61 705f 6469 736b 5f69  void mmap_disk_i
    │ │ │ -00060460: 6f3a 3a61 7379 6e63 5f63 6c65 6172 5f70  o::async_clear_p
    │ │ │ -00060470: 6965 6365 2873 746f 7261 6765 5f69 6e64  iece(storage_ind
    │ │ │ -00060480: 6578 5f74 2063 6f6e 7374 2073 746f 7261  ex_t const stora
    │ │ │ -00060490: 6765 0a09 092c 2070 6965 6365 5f69 6e64  ge..., piece_ind
    │ │ │ -000604a0: 6578 5f74 2063 6f6e 7374 2069 6e64 6578  ex_t const index
    │ │ │ -000604b0: 2c20 7374 643a 3a66 756e 6374 696f 6e26  , std::function&
    │ │ │ -000604c0: 6c74 3b76 6f69 6428 7069 6563 655f 696e  lt;void(piece_in
    │ │ │ -000604d0: 6465 785f 7429 2667 743b 2068 616e 646c  dex_t)> handl
    │ │ │ -000604e0: 6572 290a 097b 0a09 0961 7578 3a3a 6d6d  er)..{...aux::mm
    │ │ │ -000604f0: 6170 5f64 6973 6b5f 6a6f 622a 206a 203d  ap_disk_job* j =
    │ │ │ -00060500: 206d 5f6a 6f62 5f70 6f6f 6c2e 616c 6c6f   m_job_pool.allo
    │ │ │ -00060510: 6361 7465 5f6a 6f62 266c 743b 6175 783a  cate_job<aux:
    │ │ │ -00060520: 3a6a 6f62 3a3a 636c 6561 725f 7069 6563  :job::clear_piec
    │ │ │ -00060530: 6526 6774 3b28 0a09 0909 7b7d 2c0a 0909  e>(....{},...
    │ │ │ -00060540: 096d 5f74 6f72 7265 6e74 735b 7374 6f72  .m_torrents[stor
    │ │ │ -00060550: 6167 655d 2d26 6774 3b73 6861 7265 645f  age]->shared_
    │ │ │ -00060560: 6672 6f6d 5f74 6869 7328 292c 0a09 0909  from_this(),....
    │ │ │ -00060570: 7374 643a 3a6d 6f76 6528 6861 6e64 6c65  std::move(handle
    │ │ │ -00060580: 7229 2c0a 0909 0969 6e64 6578 0a09 0929  r),....index...)
    │ │ │ -00060590: 3b0a 0a09 092f 2f20 7265 6775 6c61 7220  ;....// regular 
    │ │ │ -000605a0: 6a6f 6273 2061 7265 206e 6f74 2067 7561  jobs are not gua
    │ │ │ -000605b0: 7261 6e74 6565 6420 746f 2062 6520 6578  ranteed to be ex
    │ │ │ -000605c0: 6563 7574 6564 2069 6e2d 6f72 6465 720a  ecuted in-order.
    │ │ │ -000605d0: 0909 2f2f 2073 696e 6365 2063 6c65 6172  ..// since clear
    │ │ │ -000605e0: 2070 6965 6365 206d 7573 7420 6775 6172   piece must guar
    │ │ │ -000605f0: 616e 7465 6520 7468 6174 2061 6c6c 2077  antee that all w
    │ │ │ -00060600: 7269 7465 206a 6f62 7320 7468 6174 0a09  rite jobs that..
    │ │ │ -00060610: 092f 2f20 6861 7665 2062 6565 6e20 6973  .// have been is
    │ │ │ -00060620: 7375 6564 2066 696e 6973 6820 6265 666f  sued finish befo
    │ │ │ -00060630: 7265 2074 6865 2063 6c65 6172 2070 6965  re the clear pie
    │ │ │ -00060640: 6365 206a 6f62 2063 6f6d 706c 6574 6573  ce job completes
    │ │ │ -00060650: 0a0a 0a3c 6469 7620 7374 796c 653d 2262  ...
    ..add_fence_job │ │ │ -00060690: 286a 293b 0a3c 2f64 6976 3e09 7d0a 0a09 (j);.
    .}... │ │ │ -000606a0: 7374 6174 7573 5f74 206d 6d61 705f 6469 status_t mmap_di │ │ │ -000606b0: 736b 5f69 6f3a 3a64 6f5f 6a6f 6228 6175 sk_io::do_job(au │ │ │ -000606c0: 783a 3a6a 6f62 3a3a 6861 7368 2661 6d70 x::job::hash& │ │ │ -000606d0: 3b20 612c 2061 7578 3a3a 6d6d 6170 5f64 ; a, aux::mmap_d │ │ │ -000606e0: 6973 6b5f 6a6f 622a 206a 290a 097b 0a09 isk_job* j)..{.. │ │ │ -000606f0: 092f 2f20 7765 2772 6520 6e6f 7420 7573 .// we're not us │ │ │ -00060700: 696e 6720 6120 6361 6368 652e 2054 6869 ing a cache. Thi │ │ │ -00060710: 7320 6973 2074 6865 2073 696d 706c 6520 s is the simple │ │ │ -00060720: 7061 7468 0a09 092f 2f20 6a75 7374 2072 path...// just r │ │ │ -00060730: 6561 6420 7374 7261 6967 6874 2066 726f ead straight fro │ │ │ -00060740: 6d20 7468 6520 6669 6c65 0a09 0954 4f52 m the file...TOR │ │ │ -00060750: 5245 4e54 5f41 5353 4552 5428 6d5f 6d61 RENT_ASSERT(m_ma │ │ │ -00060760: 6769 6320 3d3d 2030 7831 3333 3729 3b0a gic == 0x1337);. │ │ │ -00060770: 0a09 0962 6f6f 6c20 636f 6e73 7420 7631 ...bool const v1 │ │ │ -00060780: 203d 2062 6f6f 6c28 6a2d 2667 743b 666c = bool(j->fl │ │ │ -00060790: 6167 7320 2661 6d70 3b20 6469 736b 5f69 ags & disk_i │ │ │ -000607a0: 6e74 6572 6661 6365 3a3a 7631 5f68 6173 nterface::v1_has │ │ │ -000607b0: 6829 3b0a 0909 626f 6f6c 2063 6f6e 7374 h);...bool const │ │ │ -000607c0: 2076 3220 3d20 2161 2e62 6c6f 636b 5f68 v2 = !a.block_h │ │ │ -000607d0: 6173 6865 732e 656d 7074 7928 293b 0a0a ashes.empty();.. │ │ │ -000607e0: 0909 696e 7420 636f 6e73 7420 7069 6563 ..int const piec │ │ │ -000607f0: 655f 7369 7a65 203d 2076 3120 3f20 6a2d e_size = v1 ? j- │ │ │ -00060800: 2667 743b 7374 6f72 6167 652d 2667 743b >storage-> │ │ │ -00060810: 6669 6c65 7328 292e 7069 6563 655f 7369 files().piece_si │ │ │ -00060820: 7a65 2861 2e70 6965 6365 2920 3a20 303b ze(a.piece) : 0; │ │ │ -00060830: 0a09 0969 6e74 2063 6f6e 7374 2070 6965 ...int const pie │ │ │ -00060840: 6365 5f73 697a 6532 203d 2076 3220 3f20 ce_size2 = v2 ? │ │ │ -00060850: 6a2d 2667 743b 7374 6f72 6167 652d 2667 j->storage-&g │ │ │ -00060860: 743b 6669 6c65 7328 292e 7069 6563 655f t;files().piece_ │ │ │ -00060870: 7369 7a65 3228 612e 7069 6563 6529 203a size2(a.piece) : │ │ │ -00060880: 2030 3b0a 0909 696e 7420 636f 6e73 7420 0;...int const │ │ │ -00060890: 626c 6f63 6b73 5f69 6e5f 7069 6563 6520 blocks_in_piece │ │ │ -000608a0: 3d20 7631 203f 2028 7069 6563 655f 7369 = v1 ? (piece_si │ │ │ -000608b0: 7a65 202b 2064 6566 6175 6c74 5f62 6c6f ze + default_blo │ │ │ -000608c0: 636b 5f73 697a 6520 2d20 3129 202f 2064 ck_size - 1) / d │ │ │ -000608d0: 6566 6175 6c74 5f62 6c6f 636b 5f73 697a efault_block_siz │ │ │ -000608e0: 6520 3a20 303b 0a09 0969 6e74 2063 6f6e e : 0;...int con │ │ │ -000608f0: 7374 2062 6c6f 636b 735f 696e 5f70 6965 st blocks_in_pie │ │ │ -00060900: 6365 3220 3d20 7632 203f 206a 2d26 6774 ce2 = v2 ? j-> │ │ │ -00060910: 3b73 746f 7261 6765 2d26 6774 3b66 696c ;storage->fil │ │ │ -00060920: 6573 2829 2e62 6c6f 636b 735f 696e 5f70 es().blocks_in_p │ │ │ -00060930: 6965 6365 3228 612e 7069 6563 6529 203a iece2(a.piece) : │ │ │ -00060940: 2030 3b0a 0909 6175 783a 3a6f 7065 6e5f 0;...aux::open_ │ │ │ -00060950: 6d6f 6465 5f74 2063 6f6e 7374 2066 696c mode_t const fil │ │ │ -00060960: 655f 6d6f 6465 203d 2066 696c 655f 6d6f e_mode = file_mo │ │ │ -00060970: 6465 5f66 6f72 5f6a 6f62 286a 293b 0a0a de_for_job(j);.. │ │ │ -00060980: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -00060990: 2821 7632 207c 7c20 696e 7428 612e 626c (!v2 || int(a.bl │ │ │ -000609a0: 6f63 6b5f 6861 7368 6573 2e73 697a 6528 ock_hashes.size( │ │ │ -000609b0: 2929 2026 6774 3b3d 2062 6c6f 636b 735f )) >= blocks_ │ │ │ -000609c0: 696e 5f70 6965 6365 3229 3b0a 0909 544f in_piece2);...TO │ │ │ -000609d0: 5252 454e 545f 4153 5345 5254 2876 3120 RRENT_ASSERT(v1 │ │ │ -000609e0: 7c7c 2076 3229 3b0a 0a09 092f 2f20 636f || v2);....// co │ │ │ -000609f0: 6e73 756d 6520 5348 412d 3235 3620 6861 nsume SHA-256 ha │ │ │ -00060a00: 7368 6573 2063 6f6d 7075 7465 6420 696e shes computed in │ │ │ -00060a10: 6c69 6e65 2064 7572 696e 6720 646f 5f6a line during do_j │ │ │ -00060a20: 6f62 2877 7269 7465 293b 2066 6f72 2061 ob(write); for a │ │ │ -00060a30: 6e79 0a09 092f 2f20 626c 6f63 6b20 7768 ny...// block wh │ │ │ -00060a40: 6572 6520 7765 2064 6f6e 2774 2068 6176 ere we don't hav │ │ │ -00060a50: 6520 6f6e 6520 2861 6e20 616c 6c2d 7a65 e one (an all-ze │ │ │ -00060a60: 726f 2065 6e74 7279 292c 2066 616c 6c20 ro entry), fall │ │ │ -00060a70: 7468 726f 7567 6820 746f 2074 6865 0a09 through to the.. │ │ │ -00060a80: 092f 2f20 6578 6973 7469 6e67 2070 6174 .// existing pat │ │ │ -00060a90: 680a 0909 6175 783a 3a76 6563 746f 7226 h...aux::vector& │ │ │ -00060aa0: 6c74 3b73 6861 3235 365f 6861 7368 2667 lt;sha256_hash&g │ │ │ -00060ab0: 743b 2063 6f6e 7374 2070 6320 3d0a 0909 t; const pc =... │ │ │ -00060ac0: 0976 3220 3f20 6a2d 2667 743b 7374 6f72 .v2 ? j->stor │ │ │ -00060ad0: 6167 652d 2667 743b 7461 6b65 5f70 7265 age->take_pre │ │ │ -00060ae0: 636f 6d70 7574 6564 5f76 3228 612e 7069 computed_v2(a.pi │ │ │ -00060af0: 6563 6529 203a 2061 7578 3a3a 7665 6374 ece) : aux::vect │ │ │ -00060b00: 6f72 266c 743b 7368 6132 3536 5f68 6173 or<sha256_has │ │ │ -00060b10: 6826 6774 3b7b 7d3b 0a0a 0909 6861 7368 h>{};....hash │ │ │ -00060b20: 6572 2068 3b0a 0909 696e 7420 7265 7420 er h;...int ret │ │ │ -00060b30: 3d20 303b 0a09 0969 6e74 206f 6666 7365 = 0;...int offse │ │ │ -00060b40: 7420 3d20 303b 0a09 0969 6e74 2063 6f6e t = 0;...int con │ │ │ -00060b50: 7374 2062 6c6f 636b 735f 746f 5f72 6561 st blocks_to_rea │ │ │ -00060b60: 6420 3d20 7374 643a 3a6d 6178 2862 6c6f d = std::max(blo │ │ │ -00060b70: 636b 735f 696e 5f70 6965 6365 2c20 626c cks_in_piece, bl │ │ │ -00060b80: 6f63 6b73 5f69 6e5f 7069 6563 6532 293b ocks_in_piece2); │ │ │ -00060b90: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -00060bd0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ -00060c00: 7263 2f73 6573 7369 6f6e 2e63 7070 3a32 rc/session.cpp:2 │ │ │ -00060c10: 3631 3c2f 613e 3c2f 7464 3e3c 7464 3e73 61s │ │ │ -00060c20: 7461 7274 2829 2073 686f 756c 6420 6a75 tart() should ju │ │ │ -00060c30: 7374 2075 7365 2066 6c61 6773 206f 7574 st use flags out │ │ │ -00060c40: 206f 6620 7468 6520 7365 7373 696f 6e5f of the session_ │ │ │ -00060c50: 7061 7261 6d73 206f 626a 6563 742c 3c2f params object,

    star │ │ │ -00060cb0: 7428 2920 7368 6f75 6c64 206a 7573 7420 t() should just │ │ │ -00060cc0: 7573 6520 666c 6167 7320 6f75 7420 6f66 use flags out of │ │ │ -00060cd0: 2074 6865 2073 6573 7369 6f6e 5f70 6172 the session_par │ │ │ -00060ce0: 616d 7320 6f62 6a65 6374 2c3c 2f68 323e ams object,

    │ │ │ -00060cf0: 3c68 343e 2e2e 2f73 7263 2f73 6573 7369

    ../src/sessi │ │ │ -00060d00: 6f6e 2e63 7070 3a32 3631 3c2f 6834 3e3c on.cpp:261

    < │ │ │ -00060d10: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00060d20: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00060d30: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00060d40: 7820 2364 6464 3b22 3e09 0953 4554 5f42 x #ddd;">..SET_B │ │ │ -00060d50: 4f4f 4c28 7265 7374 7269 6374 5f72 6f75 OOL(restrict_rou │ │ │ -00060d60: 7469 6e67 5f69 7073 293b 0a09 0953 4554 ting_ips);...SET │ │ │ -00060d70: 5f42 4f4f 4c28 7265 7374 7269 6374 5f73 _BOOL(restrict_s │ │ │ -00060d80: 6561 7263 685f 6970 7329 3b0a 0909 5345 earch_ips);...SE │ │ │ -00060d90: 545f 424f 4f4c 2865 7874 656e 6465 645f T_BOOL(extended_ │ │ │ -00060da0: 726f 7574 696e 675f 7461 626c 6529 3b0a routing_table);. │ │ │ -00060db0: 0909 5345 545f 424f 4f4c 2861 6767 7265 ..SET_BOOL(aggre │ │ │ -00060dc0: 7373 6976 655f 6c6f 6f6b 7570 7329 3b0a ssive_lookups);. │ │ │ -00060dd0: 0909 5345 545f 424f 4f4c 2870 7269 7661 ..SET_BOOL(priva │ │ │ -00060de0: 6379 5f6c 6f6f 6b75 7073 293b 0a09 0953 cy_lookups);...S │ │ │ -00060df0: 4554 5f42 4f4f 4c28 656e 666f 7263 655f ET_BOOL(enforce_ │ │ │ -00060e00: 6e6f 6465 5f69 6429 3b0a 0909 5345 545f node_id);...SET_ │ │ │ -00060e10: 424f 4f4c 2869 676e 6f72 655f 6461 726b BOOL(ignore_dark │ │ │ -00060e20: 5f69 6e74 6572 6e65 7429 3b0a 0909 5345 _internet);...SE │ │ │ -00060e30: 545f 494e 5428 626c 6f63 6b5f 7469 6d65 T_INT(block_time │ │ │ -00060e40: 6f75 7429 3b0a 0909 5345 545f 494e 5428 out);...SET_INT( │ │ │ -00060e50: 626c 6f63 6b5f 7261 7465 6c69 6d69 7429 block_ratelimit) │ │ │ -00060e60: 3b0a 0909 5345 545f 424f 4f4c 2872 6561 ;...SET_BOOL(rea │ │ │ -00060e70: 645f 6f6e 6c79 293b 0a09 0953 4554 5f49 d_only);...SET_I │ │ │ -00060e80: 4e54 2869 7465 6d5f 6c69 6665 7469 6d65 NT(item_lifetime │ │ │ -00060e90: 293b 0a09 0953 4554 5f49 4e54 2875 706c );...SET_INT(upl │ │ │ -00060ea0: 6f61 645f 7261 7465 5f6c 696d 6974 293b oad_rate_limit); │ │ │ -00060eb0: 0a09 0953 4554 5f49 4e54 2873 616d 706c ...SET_INT(sampl │ │ │ -00060ec0: 655f 696e 666f 6861 7368 6573 5f69 6e74 e_infohashes_int │ │ │ -00060ed0: 6572 7661 6c29 3b0a 0909 5345 545f 494e erval);...SET_IN │ │ │ -00060ee0: 5428 6d61 785f 696e 666f 6861 7368 6573 T(max_infohashes │ │ │ -00060ef0: 5f73 616d 706c 655f 636f 756e 7429 3b0a _sample_count);. │ │ │ -00060f00: 2375 6e64 6566 2053 4554 5f42 4f4f 4c0a #undef SET_BOOL. │ │ │ -00060f10: 2375 6e64 6566 2053 4554 5f49 4e54 0a09 #undef SET_INT.. │ │ │ -00060f20: 097d 0a23 656e 6469 660a 2365 6e64 6966 .}.#endif.#endif │ │ │ -00060f30: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261 ..
    │ │ │ -00060f60: 0909 6d5f 696d 706c 203d 2073 7464 3a3a ..m_impl = std:: │ │ │ -00060f70: 6d61 6b65 5f73 6861 7265 6426 6c74 3b61 make_shared<a │ │ │ -00060f80: 7578 3a3a 7365 7373 696f 6e5f 696d 706c ux::session_impl │ │ │ -00060f90: 2667 743b 2873 7464 3a3a 7265 6628 2a69 >(std::ref(*i │ │ │ -00060fa0: 6f73 290a 3c2f 6469 763e 0909 092c 2073 os).
    ..., s │ │ │ -00060fb0: 7464 3a3a 6d6f 7665 2870 6172 616d 732e td::move(params. │ │ │ -00060fc0: 7365 7474 696e 6773 290a 0909 092c 2073 settings)...., s │ │ │ -00060fd0: 7464 3a3a 6d6f 7665 2870 6172 616d 732e td::move(params. │ │ │ -00060fe0: 6469 736b 5f69 6f5f 636f 6e73 7472 7563 disk_io_construc │ │ │ -00060ff0: 746f 7229 0a09 0909 2c20 666c 6167 7329 tor)...., flags) │ │ │ -00061000: 3b0a 0909 2a73 7461 7469 635f 6361 7374 ;...*static_cast │ │ │ -00061010: 266c 743b 7365 7373 696f 6e5f 6861 6e64 <session_hand │ │ │ -00061020: 6c65 2a26 6774 3b28 7468 6973 2920 3d20 le*>(this) = │ │ │ -00061030: 7365 7373 696f 6e5f 6861 6e64 6c65 286d session_handle(m │ │ │ -00061040: 5f69 6d70 6c29 3b0a 0a23 6966 6e64 6566 _impl);..#ifndef │ │ │ -00061050: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ -00061060: 5f45 5854 454e 5349 4f4e 530a 0909 666f _EXTENSIONS...fo │ │ │ -00061070: 7220 2861 7574 6f26 616d 703b 2065 7874 r (auto& ext │ │ │ -00061080: 203a 2070 6172 616d 732e 6578 7465 6e73 : params.extens │ │ │ -00061090: 696f 6e73 290a 0909 7b0a 0909 0965 7874 ions)...{....ext │ │ │ -000610a0: 2d26 6774 3b6c 6f61 645f 7374 6174 6528 ->load_state( │ │ │ -000610b0: 7061 7261 6d73 2e65 7874 5f73 7461 7465 params.ext_state │ │ │ -000610c0: 293b 0a09 0909 6d5f 696d 706c 2d26 6774 );....m_impl-> │ │ │ -000610d0: 3b61 6464 5f73 6573 5f65 7874 656e 7369 ;add_ses_extensi │ │ │ -000610e0: 6f6e 2873 7464 3a3a 6d6f 7665 2865 7874 on(std::move(ext │ │ │ -000610f0: 2929 3b0a 0909 7d0a 2365 6e64 6966 0a0a ));...}.#endif.. │ │ │ -00061100: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ -00061110: 4449 5341 424c 455f 4448 540a 0909 6d5f DISABLE_DHT...m_ │ │ │ -00061120: 696d 706c 2d26 6774 3b73 6574 5f64 6874 impl->set_dht │ │ │ -00061130: 5f73 7461 7465 2873 7464 3a3a 6d6f 7665 _state(std::move │ │ │ -00061140: 2870 6172 616d 732e 6468 745f 7374 6174 (params.dht_stat │ │ │ -00061150: 6529 293b 0a0a 0909 544f 5252 454e 545f e));....TORRENT_ │ │ │ -00061160: 4153 5345 5254 2870 6172 616d 732e 6468 ASSERT(params.dh │ │ │ -00061170: 745f 7374 6f72 6167 655f 636f 6e73 7472 t_storage_constr │ │ │ -00061180: 7563 746f 7229 3b0a 0909 6d5f 696d 706c uctor);...m_impl │ │ │ -00061190: 2d26 6774 3b73 6574 5f64 6874 5f73 746f ->set_dht_sto │ │ │ -000611a0: 7261 6765 2873 7464 3a3a 6d6f 7665 2870 rage(std::move(p │ │ │ -000611b0: 6172 616d 732e 6468 745f 7374 6f72 6167 arams.dht_storag │ │ │ -000611c0: 655f 636f 6e73 7472 7563 746f 7229 293b e_constructor)); │ │ │ -000611d0: 0a23 656e 6469 660a 0a09 0969 6620 2821 .#endif....if (! │ │ │ -000611e0: 7061 7261 6d73 2e69 705f 6669 6c74 6572 params.ip_filter │ │ │ -000611f0: 2e65 6d70 7479 2829 290a 0909 7b0a 0909 .empty())...{... │ │ │ -00061200: 0973 7464 3a3a 7368 6172 6564 5f70 7472 .std::shared_ptr │ │ │ -00061210: 266c 743b 6970 5f66 696c 7465 7226 6774 <ip_filter> │ │ │ -00061220: 3b20 636f 7079 203d 2073 7464 3a3a 6d61 ; copy = std::ma │ │ │ -00061230: 6b65 5f73 6861 7265 6426 6c74 3b69 705f ke_shared<ip_ │ │ │ -00061240: 6669 6c74 6572 2667 743b 2873 7464 3a3a filter>(std:: │ │ │ -00061250: 6d6f 7665 2870 6172 616d 732e 6970 5f66 move(params.ip_f │ │ │ -00061260: 696c 7465 7229 293b 0a09 0909 6d5f 696d ilter));....m_im │ │ │ -00061270: 706c 2d26 6774 3b73 6574 5f69 705f 6669 pl->set_ip_fi │ │ │ -00061280: 6c74 6572 2873 7464 3a3a 6d6f 7665 2863 lter(std::move(c │ │ │ -00061290: 6f70 7929 293b 0a09 097d 0a0a 0909 6d5f opy));...}....m_ │ │ │ -000612a0: 696d 706c 2d26 6774 3b73 7461 7274 5f73 impl->start_s │ │ │ -000612b0: 6573 7369 6f6e 2829 3b0a 0a09 0969 6620 ession();....if │ │ │ -000612c0: 2869 6e74 6572 6e61 6c5f 6578 6563 7574 (internal_execut │ │ │ -000612d0: 6f72 290a 0909 7b0a 3c2f 7072 653e 3c2f or)...{.
    relevan │ │ │ -00061310: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/magnet │ │ │ -00061350: 5f75 7269 2e63 7070 3a34 3235 3c2f 613e _uri.cpp:425 │ │ │ -00061360: 3c2f 7464 3e3c 7464 3e77 6861 7427 7320 what's │ │ │ -00061370: 7468 6520 7269 6768 7420 6e75 6d62 6572 the right number │ │ │ -00061380: 2068 6572 653f 3c2f 7464 3e3c 2f74 723e here? │ │ │ -00061390: 3c74 7220 6964 3d22 3232 3422 2073 7479 │ │ │ -000613c0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -000613d0: 3c68 323e 7768 6174 2773 2074 6865 2072

    what's the r │ │ │ -000613e0: 6967 6874 206e 756d 6265 7220 6865 7265 ight number here │ │ │ -000613f0: 3f3c 2f68 323e 3c68 343e 2e2e 2f73 7263 ?

    ../src │ │ │ -00061400: 2f6d 6167 6e65 745f 7572 692e 6370 703a /magnet_uri.cpp: │ │ │ -00061410: 3432 353c 2f68 343e 3c70 7265 2073 7479 425

    ...}....else i
    │ │ │ -00061460: 6620 2861 7578 3a3a 7374 7269 6e67 5f65  f (aux::string_e
    │ │ │ -00061470: 7175 616c 5f6e 6f5f 6361 7365 286e 616d  qual_no_case(nam
    │ │ │ -00061480: 652c 2022 736f 225f 7376 2929 202f 2f20  e, "so"_sv)) // 
    │ │ │ -00061490: 7365 6c65 6374 2d6f 6e6c 7920 2866 696c  select-only (fil
    │ │ │ -000614a0: 6573 290a 0909 097b 0a09 0909 092f 2f20  es)....{.....// 
    │ │ │ -000614b0: 6163 6365 7074 206f 6e6c 7920 6469 6769  accept only digi
    │ │ │ -000614c0: 7473 2c20 272d 2720 616e 6420 272c 270a  ts, '-' and ','.
    │ │ │ -000614d0: 0909 0909 6966 2028 7374 643a 3a61 6e79  ....if (std::any
    │ │ │ -000614e0: 5f6f 6628 7661 6c75 652e 6265 6769 6e28  _of(value.begin(
    │ │ │ -000614f0: 292c 2076 616c 7565 2e65 6e64 2829 2c20  ), value.end(), 
    │ │ │ -00061500: 5b5d 2863 6861 7220 6329 0a09 0909 0909  [](char c)......
    │ │ │ -00061510: 7b20 7265 7475 726e 2021 6175 783a 3a69  { return !aux::i
    │ │ │ -00061520: 735f 6469 6769 7428 6329 2026 616d 703b  s_digit(c) &
    │ │ │ -00061530: 2661 6d70 3b20 6320 213d 2027 2d27 2026  & c != '-' &
    │ │ │ -00061540: 616d 703b 2661 6d70 3b20 6320 213d 2027  amp;& c != '
    │ │ │ -00061550: 2c27 3b20 7d29 290a 0909 0909 0963 6f6e  ,'; }))......con
    │ │ │ -00061560: 7469 6e75 653b 0a0a 0909 0909 2f2f 206d  tinue;......// m
    │ │ │ -00061570: 616b 6520 7375 7265 2061 6c6c 2066 696c  ake sure all fil
    │ │ │ -00061580: 6520 7072 696f 7269 7469 6573 2061 7265  e priorities are
    │ │ │ -00061590: 2073 6574 2074 6f20 302c 2065 7863 6570   set to 0, excep
    │ │ │ -000615a0: 7420 7468 6520 6f6e 6573 0a09 0909 092f  t the ones...../
    │ │ │ -000615b0: 2f20 7765 2073 7065 6369 6679 2069 6e20  / we specify in 
    │ │ │ -000615c0: 7468 6520 6669 6c65 5f70 7269 6f72 6974  the file_priorit
    │ │ │ -000615d0: 6965 730a 0909 0909 702e 666c 6167 7320  ies.....p.flags 
    │ │ │ -000615e0: 7c3d 2074 6f72 7265 6e74 5f66 6c61 6773  |= torrent_flags
    │ │ │ -000615f0: 3a3a 6465 6661 756c 745f 646f 6e74 5f64  ::default_dont_d
    │ │ │ -00061600: 6f77 6e6c 6f61 643b 0a0a 0909 0909 646f  ownload;......do
    │ │ │ -00061610: 0a09 0909 097b 0a09 0909 0909 7374 7269  .....{......stri
    │ │ │ -00061620: 6e67 5f76 6965 7720 746f 6b65 6e3b 0a09  ng_view token;..
    │ │ │ -00061630: 0909 0909 7374 643a 3a74 6965 2874 6f6b  ....std::tie(tok
    │ │ │ -00061640: 656e 2c20 7661 6c75 6529 203d 2061 7578  en, value) = aux
    │ │ │ -00061650: 3a3a 7370 6c69 745f 7374 7269 6e67 2876  ::split_string(v
    │ │ │ -00061660: 616c 7565 2c20 272c 2729 3b0a 0a09 0909  alue, ',');.....
    │ │ │ -00061670: 0909 6966 2028 746f 6b65 6e2e 656d 7074  ..if (token.empt
    │ │ │ -00061680: 7928 2929 2063 6f6e 7469 6e75 653b 0a0a  y()) continue;..
    │ │ │ -00061690: 0909 0909 0969 6e74 2069 6478 312c 2069  .....int idx1, i
    │ │ │ -000616a0: 6478 323b 0a3c 6469 7620 7374 796c 653d  dx2;.
    .....constexp │ │ │ -000616e0: 7220 696e 7420 6d61 785f 696e 6465 7820 r int max_index │ │ │ -000616f0: 3d20 3130 3030 303b 202f 2f20 6361 6e27 = 10000; // can' │ │ │ -00061700: 7420 7269 736b 206f 7574 206f 6620 6d65 t risk out of me │ │ │ -00061710: 6d6f 7279 0a3c 2f64 6976 3e0a 0909 0909 mory.
    ..... │ │ │ -00061720: 0961 7574 6f20 636f 6e73 7420 6469 7669 .auto const divi │ │ │ -00061730: 6465 7220 3d20 746f 6b65 6e2e 6669 6e64 der = token.find │ │ │ -00061740: 5f66 6972 7374 5f6f 6628 272d 2729 3b0a _first_of('-');. │ │ │ -00061750: 0909 0909 0969 6620 2864 6976 6964 6572 .....if (divider │ │ │ -00061760: 2021 3d20 7374 643a 3a73 7472 696e 673a != std::string: │ │ │ -00061770: 3a6e 706f 7329 202f 2f20 6974 2773 2061 :npos) // it's a │ │ │ -00061780: 2072 616e 6765 0a09 0909 0909 7b0a 0909 range......{... │ │ │ -00061790: 0909 0909 6966 2028 6469 7669 6465 7220 ....if (divider │ │ │ -000617a0: 3d3d 2030 2920 2f2f 206e 6f20 7374 6172 == 0) // no star │ │ │ -000617b0: 7420 696e 6465 780a 0909 0909 0909 0963 t index........c │ │ │ -000617c0: 6f6e 7469 6e75 653b 0a09 0909 0909 0969 ontinue;.......i │ │ │ -000617d0: 6620 2864 6976 6964 6572 203d 3d20 746f f (divider == to │ │ │ -000617e0: 6b65 6e2e 7369 7a65 2829 202d 2031 2920 ken.size() - 1) │ │ │ -000617f0: 2f2f 206e 6f20 656e 6420 696e 6465 780a // no end index. │ │ │ -00061800: 0909 0909 0909 0963 6f6e 7469 6e75 653b .......continue; │ │ │ -00061810: 0a0a 0909 0909 0909 6175 746f 2063 6f6e ........auto con │ │ │ -00061820: 7374 2066 6972 7374 203d 2061 7578 3a3a st first = aux:: │ │ │ -00061830: 7061 7273 655f 6465 6369 6d61 6c28 746f parse_decimal(to │ │ │ -00061840: 6b65 6e2e 7375 6273 7472 2830 2c20 6469 ken.substr(0, di │ │ │ -00061850: 7669 6465 7229 293b 0a09 0909 0909 0969 vider));.......i │ │ │ -00061860: 6620 2821 6669 7273 7420 7c7c 202a 6669 f (!first || *fi │ │ │ -00061870: 7273 7420 266c 743b 2030 207c 7c20 2a66 rst < 0 || *f │ │ │ -00061880: 6972 7374 2026 6774 3b20 6d61 785f 696e irst > max_in │ │ │ -00061890: 6465 7829 202f 2f20 696e 7661 6c69 6420 dex) // invalid │ │ │ -000618a0: 696e 6465 780a 0909 0909 0909 0963 6f6e index........con │ │ │ -000618b0: 7469 6e75 653b 0a09 0909 0909 0961 7574 tinue;.......aut │ │ │ -000618c0: 6f20 636f 6e73 7420 6c61 7374 203d 2061 o const last = a │ │ │ -000618d0: 7578 3a3a 7061 7273 655f 6465 6369 6d61 ux::parse_decima │ │ │ -000618e0: 6c28 746f 6b65 6e2e 7375 6273 7472 2864 l(token.substr(d │ │ │ -000618f0: 6976 6964 6572 202b 2031 2929 3b0a 0909 ivider + 1));... │ │ │ -00061900: 0909 0909 6966 2028 216c 6173 7420 7c7c ....if (!last || │ │ │ -00061910: 202a 6c61 7374 2026 6c74 3b20 3020 7c7c *last < 0 || │ │ │ -00061920: 202a 6c61 7374 2026 6774 3b20 6d61 785f *last > max_ │ │ │ -00061930: 696e 6465 7829 202f 2f20 696e 7661 6c69 index) // invali │ │ │ -00061940: 6420 696e 6465 780a 0909 0909 0909 0963 d index........c │ │ │ -00061950: 6f6e 7469 6e75 653b 0a09 0909 0909 0969 ontinue;.......i │ │ │ -00061960: 6478 3120 3d20 2a66 6972 7374 3b0a 0909 dx1 = *first;... │ │ │ -00061970: 0909 0909 6964 7832 203d 202a 6c61 7374 ....idx2 = *last │ │ │ -00061980: 3b0a 0a09 0909 0909 0969 6620 2869 6478 ;........if (idx │ │ │ -00061990: 3120 2667 743b 2069 6478 3229 202f 2f20 1 > idx2) // │ │ │ -000619a0: 7772 6f6e 6720 7261 6e67 6520 6c69 6d69 wrong range limi │ │ │ -000619b0: 7473 0a09 0909 0909 0909 636f 6e74 696e ts........contin │ │ │ -000619c0: 7565 3b0a 0909 0909 097d 0a09 0909 0909 ue;......}...... │ │ │ -000619d0: 656c 7365 202f 2f20 6974 2773 2061 6e20 else // it's an │ │ │ -000619e0: 696e 6465 780a 0909 0909 097b 0a09 0909 index......{.... │ │ │ -000619f0: 0909 0961 7574 6f20 636f 6e73 7420 6964 ...auto const id │ │ │ -00061a00: 7820 3d20 6175 783a 3a70 6172 7365 5f64 x = aux::parse_d │ │ │ -00061a10: 6563 696d 616c 2874 6f6b 656e 293b 0a09 ecimal(token);.. │ │ │ -00061a20: 0909 0909 0969 6620 2821 6964 7820 7c7c .....if (!idx || │ │ │ -00061a30: 202a 6964 7820 266c 743b 2030 207c 7c20 *idx < 0 || │ │ │ -00061a40: 2a69 6478 2026 6774 3b20 6d61 785f 696e *idx > max_in │ │ │ -00061a50: 6465 7829 202f 2f20 696e 7661 6c69 6420 dex) // invalid │ │ │ -00061a60: 696e 6465 780a 0909 0909 0909 0963 6f6e index........con │ │ │ -00061a70: 7469 6e75 653b 0a09 0909 0909 0969 6478 tinue;.......idx │ │ │ -00061a80: 3120 3d20 2a69 6478 3b0a 0909 0909 0909 1 = *idx;....... │ │ │ -00061a90: 6964 7832 203d 2069 6478 313b 0a09 0909 idx2 = idx1;.... │ │ │ -00061aa0: 0909 7d0a 0a3c 2f70 7265 3e3c 2f74 643e ..}..
    │ │ │ -00061ab0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00061ae0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00061af0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00061b00: 7074 3a65 7870 616e 6428 3232 3529 223e pt:expand(225)"> │ │ │ -00061b10: 2e2e 2f73 7263 2f75 6470 5f73 6f63 6b65 ../src/udp_socke │ │ │ -00061b20: 742e 6370 703a 3634 333c 2f61 3e3c 2f74 t.cpp:643
    perhaps an │ │ │ -00061b40: 2061 7474 656d 7074 2073 686f 756c 6420 attempt should │ │ │ -00061b50: 6265 206d 6164 6520 746f 2062 696e 6420 be made to bind │ │ │ -00061b60: 6d5f 736f 636b 7335 5f73 6f63 6b20 746f m_socks5_sock to │ │ │ -00061b70: 2074 6865 2064 6576 6963 6520 6f66 206d the device of m │ │ │ -00061b80: 5f6c 6973 7465 6e5f 736f 636b 6574 3c2f _listen_socket

    perh │ │ │ -00061be0: 6170 7320 616e 2061 7474 656d 7074 2073 aps an attempt s │ │ │ -00061bf0: 686f 756c 6420 6265 206d 6164 6520 746f hould be made to │ │ │ -00061c00: 2062 696e 6420 6d5f 736f 636b 7335 5f73 bind m_socks5_s │ │ │ -00061c10: 6f63 6b20 746f 2074 6865 0a64 6576 6963 ock to the.devic │ │ │ -00061c20: 6520 6f66 206d 5f6c 6973 7465 6e5f 736f e of m_listen_so │ │ │ -00061c30: 636b 6574 3c2f 6832 3e3c 6834 3e2e 2e2f cket

    ../ │ │ │ -00061c40: 7372 632f 7564 705f 736f 636b 6574 2e63 src/udp_socket.c │ │ │ -00061c50: 7070 3a36 3433 3c2f 6834 3e3c 7072 6520 pp:643

    .if (ec)..{
    │ │ │ -00061ca0: 0a09 0969 6620 286d 5f61 6c65 7274 732e  ...if (m_alerts.
    │ │ │ -00061cb0: 7368 6f75 6c64 5f70 6f73 7426 6c74 3b73  should_post<s
    │ │ │ -00061cc0: 6f63 6b73 355f 616c 6572 7426 6774 3b28  ocks5_alert>(
    │ │ │ -00061cd0: 2929 0a09 0909 6d5f 616c 6572 7473 2e65  ))....m_alerts.e
    │ │ │ -00061ce0: 6d70 6c61 6365 5f61 6c65 7274 266c 743b  mplace_alert<
    │ │ │ -00061cf0: 736f 636b 7335 5f61 6c65 7274 2667 743b  socks5_alert>
    │ │ │ -00061d00: 286d 5f70 726f 7879 5f61 6464 722c 206f  (m_proxy_addr, o
    │ │ │ -00061d10: 7065 7261 7469 6f6e 5f74 3a3a 736f 636b  peration_t::sock
    │ │ │ -00061d20: 5f6f 7074 696f 6e2c 2065 6329 3b0a 0909  _option, ec);...
    │ │ │ -00061d30: 6563 2e63 6c65 6172 2829 3b0a 097d 0a23  ec.clear();..}.#
    │ │ │ -00061d40: 656e 6469 660a 2365 6e64 6966 0a0a 0974  endif.#endif...t
    │ │ │ -00061d50: 6370 3a3a 656e 6470 6f69 6e74 2063 6f6e  cp::endpoint con
    │ │ │ -00061d60: 7374 2062 696e 645f 6570 286d 5f6c 6973  st bind_ep(m_lis
    │ │ │ -00061d70: 7465 6e5f 736f 636b 6574 2e67 6574 5f6c  ten_socket.get_l
    │ │ │ -00061d80: 6f63 616c 5f65 6e64 706f 696e 7428 292e  ocal_endpoint().
    │ │ │ -00061d90: 6164 6472 6573 7328 292c 2030 293b 0a09  address(), 0);..
    │ │ │ -00061da0: 6d5f 736f 636b 7335 5f73 6f63 6b2e 6269  m_socks5_sock.bi
    │ │ │ -00061db0: 6e64 2862 696e 645f 6570 2c20 6563 293b  nd(bind_ep, ec);
    │ │ │ -00061dc0: 0a09 6966 2028 6563 290a 097b 0a09 0969  ..if (ec)..{...i
    │ │ │ -00061dd0: 6620 286d 5f61 6c65 7274 732e 7368 6f75  f (m_alerts.shou
    │ │ │ -00061de0: 6c64 5f70 6f73 7426 6c74 3b73 6f63 6b73  ld_post<socks
    │ │ │ -00061df0: 355f 616c 6572 7426 6774 3b28 2929 0a09  5_alert>())..
    │ │ │ -00061e00: 0909 6d5f 616c 6572 7473 2e65 6d70 6c61  ..m_alerts.empla
    │ │ │ -00061e10: 6365 5f61 6c65 7274 266c 743b 736f 636b  ce_alert<sock
    │ │ │ -00061e20: 7335 5f61 6c65 7274 2667 743b 286d 5f70  s5_alert>(m_p
    │ │ │ -00061e30: 726f 7879 5f61 6464 722c 206f 7065 7261  roxy_addr, opera
    │ │ │ -00061e40: 7469 6f6e 5f74 3a3a 736f 636b 5f62 696e  tion_t::sock_bin
    │ │ │ -00061e50: 642c 2065 6329 3b0a 0909 2b2b 6d5f 6661  d, ec);...++m_fa
    │ │ │ -00061e60: 696c 7572 6573 3b0a 0909 7265 7472 795f  ilures;...retry_
    │ │ │ -00061e70: 636f 6e6e 6563 7469 6f6e 2829 3b0a 0909  connection();...
    │ │ │ -00061e80: 7265 7475 726e 3b0a 097d 0a0a 3c64 6976  return;..}..
    .
    .ADD_OUTSTANDIN │ │ │ -00061ed0: 475f 4153 594e 4328 2273 6f63 6b73 353a G_ASYNC("socks5: │ │ │ -00061ee0: 3a6f 6e5f 636f 6e6e 6563 7465 6422 293b :on_connected"); │ │ │ -00061ef0: 0a09 6d5f 736f 636b 7335 5f73 6f63 6b2e ..m_socks5_sock. │ │ │ -00061f00: 6173 796e 635f 636f 6e6e 6563 7428 6d5f async_connect(m_ │ │ │ -00061f10: 7072 6f78 795f 6164 6472 0a09 092c 2073 proxy_addr..., s │ │ │ -00061f20: 7464 3a3a 6269 6e64 2826 616d 703b 736f td::bind(&so │ │ │ -00061f30: 636b 7335 3a3a 6f6e 5f63 6f6e 6e65 6374 cks5::on_connect │ │ │ -00061f40: 6564 2c20 7365 6c66 2829 2c20 5f31 2929 ed, self(), _1)) │ │ │ -00061f50: 3b0a 0a09 4144 445f 4f55 5453 5441 4e44 ;...ADD_OUTSTAND │ │ │ -00061f60: 494e 475f 4153 594e 4328 2273 6f63 6b73 ING_ASYNC("socks │ │ │ -00061f70: 353a 3a6f 6e5f 636f 6e6e 6563 745f 7469 5::on_connect_ti │ │ │ -00061f80: 6d65 6f75 7422 293b 0a09 6d5f 7469 6d65 meout");..m_time │ │ │ -00061f90: 722e 6578 7069 7265 735f 6166 7465 7228 r.expires_after( │ │ │ -00061fa0: 7365 636f 6e64 7328 3130 2929 3b0a 096d seconds(10));..m │ │ │ -00061fb0: 5f74 696d 6572 2e61 7379 6e63 5f77 6169 _timer.async_wai │ │ │ -00061fc0: 7428 7374 643a 3a62 696e 6428 2661 6d70 t(std::bind(& │ │ │ -00061fd0: 3b73 6f63 6b73 353a 3a6f 6e5f 636f 6e6e ;socks5::on_conn │ │ │ -00061fe0: 6563 745f 7469 6d65 6f75 740a 0909 2c20 ect_timeout..., │ │ │ -00061ff0: 7365 6c66 2829 2c20 5f31 2929 3b0a 7d0a self(), _1));.}. │ │ │ -00062000: 0a76 6f69 6420 736f 636b 7335 3a3a 6f6e .void socks5::on │ │ │ -00062010: 5f63 6f6e 6e65 6374 5f74 696d 656f 7574 _connect_timeout │ │ │ -00062020: 2865 7272 6f72 5f63 6f64 6520 636f 6e73 (error_code cons │ │ │ -00062030: 7426 616d 703b 2065 290a 7b0a 0943 4f4d t& e).{..COM │ │ │ -00062040: 504c 4554 455f 4153 594e 4328 2273 6f63 PLETE_ASYNC("soc │ │ │ -00062050: 6b73 353a 3a6f 6e5f 636f 6e6e 6563 745f ks5::on_connect_ │ │ │ -00062060: 7469 6d65 6f75 7422 293b 0a0a 0969 6620 timeout");...if │ │ │ -00062070: 2865 203d 3d20 626f 6f73 743a 3a61 7369 (e == boost::asi │ │ │ -00062080: 6f3a 3a65 7272 6f72 3a3a 6f70 6572 6174 o::error::operat │ │ │ -00062090: 696f 6e5f 6162 6f72 7465 6429 2072 6574 ion_aborted) ret │ │ │ -000620a0: 7572 6e3b 0a0a 0969 6620 286d 5f61 626f urn;...if (m_abo │ │ │ -000620b0: 7274 2920 7265 7475 726e 3b0a 0a09 6966 rt) return;...if │ │ │ -000620c0: 2028 6d5f 616c 6572 7473 2e73 686f 756c (m_alerts.shoul │ │ │ -000620d0: 645f 706f 7374 266c 743b 736f 636b 7335 d_post<socks5 │ │ │ -000620e0: 5f61 6c65 7274 2667 743b 2829 290a 0909 _alert>())... │ │ │ -000620f0: 6d5f 616c 6572 7473 2e65 6d70 6c61 6365 m_alerts.emplace │ │ │ -00062100: 5f61 6c65 7274 266c 743b 736f 636b 7335 _alert<socks5 │ │ │ -00062110: 5f61 6c65 7274 2667 743b 286d 5f70 726f _alert>(m_pro │ │ │ -00062120: 7879 5f61 6464 722c 206f 7065 7261 7469 xy_addr, operati │ │ │ -00062130: 6f6e 5f74 3a3a 636f 6e6e 6563 742c 2065 on_t::connect, e │ │ │ -00062140: 7272 6f72 733a 3a74 696d 6564 5f6f 7574 rrors::timed_out │ │ │ -00062150: 293b 0a0a 0965 7272 6f72 5f63 6f64 6520 );...error_code │ │ │ -00062160: 6967 6e6f 7265 3b0a 096d 5f73 6f63 6b73 ignore;..m_socks │ │ │ -00062170: 355f 736f 636b 2e63 6c6f 7365 2869 676e 5_sock.close(ign │ │ │ -00062180: 6f72 6529 3b0a 0a09 2b2b 6d5f 6661 696c ore);...++m_fail │ │ │ -00062190: 7572 6573 3b0a 0972 6574 7279 5f63 6f6e ures;..retry_con │ │ │ -000621a0: 6e65 6374 696f 6e28 293b 0a7d 0a0a 766f nection();.}..vo │ │ │ -000621b0: 6964 2073 6f63 6b73 353a 3a6f 6e5f 636f id socks5::on_co │ │ │ -000621c0: 6e6e 6563 7465 6428 6572 726f 725f 636f nnected(error_co │ │ │ -000621d0: 6465 2063 6f6e 7374 2661 6d70 3b20 6529 de const& e) │ │ │ -000621e0: 0a7b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f .{.
    │ │ │ -00062210: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -00062220: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -00062250: 2f73 7263 2f70 7265 6164 5f64 6973 6b5f /src/pread_disk_ │ │ │ -00062260: 696f 2e63 7070 3a37 3532 3c2f 613e 3c2f io.cpp:752back-pres │ │ │ -00062280: 7375 7265 2028 7468 6520 6469 736b 5f6f sure (the disk_o │ │ │ -00062290: 6273 6572 7665 7220 6f29 2069 7320 6472 bserver o) is dr │ │ │ -000622a0: 6f70 7065 6420 6f6e 2074 6865 2062 6c6f opped on the blo │ │ │ -000622b0: 636b 6564 2070 6174 682e 2061 7379 6e63 cked path. async │ │ │ -000622c0: 5f77 7269 7465 2072 6574 7572 6e73 2066 _write returns f │ │ │ -000622d0: 616c 7365 2028 6b65 6570 2077 7269 7469 alse (keep writi │ │ │ -000622e0: 6e67 2920 6275 7420 7468 6520 6361 6368 ng) but the cach │ │ │ -000622f0: 6527 7320 6261 636b 2d70 7265 7373 7572 e's back-pressur │ │ │ -00062300: 6520 2864 7269 7665 6e20 6f66 6620 6d5f e (driven off m_ │ │ │ -00062310: 626c 6f63 6b73 2920 6361 6e27 7420 7365 blocks) can't se │ │ │ -00062320: 6520 7468 6520 7061 726b 6564 2077 7269 e the parked wri │ │ │ -00062330: 7465 732c 2073 6f20 6120 6c6f 6e67 2d6c tes, so a long-l │ │ │ -00062340: 6976 6564 2066 656e 6365 2028 652e 672e ived fence (e.g. │ │ │ -00062350: 206d 6f76 655f 7374 6f72 6167 6529 206f move_storage) o │ │ │ -00062360: 6e20 6120 6275 7379 2074 6f72 7265 6e74 n a busy torrent │ │ │ -00062370: 2063 616e 2067 726f 7720 6d5f 626c 6f63 can grow m_bloc │ │ │ -00062380: 6b65 645f 6a6f 6273 2075 6e62 6f75 6e64 ked_jobs unbound │ │ │ -00062390: 6564 2e20 4361 7272 7920 7468 6520 6f62 ed. Carry the ob │ │ │ -000623a0: 7365 7276 6572 2074 6872 6f75 6768 2074 server through t │ │ │ -000623b0: 6f20 7468 726f 7474 6c65 2074 6865 2070 o throttle the p │ │ │ -000623c0: 6565 7220 7768 696c 6520 6974 7320 7772 eer while its wr │ │ │ -000623d0: 6974 6573 2061 7265 2070 6172 6b65 642e ites are parked. │ │ │ -000623e0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    ba │ │ │ -00062430: 636b 2d70 7265 7373 7572 6520 2874 6865 ck-pressure (the │ │ │ -00062440: 2064 6973 6b5f 6f62 7365 7276 6572 206f disk_observer o │ │ │ -00062450: 2920 6973 2064 726f 7070 6564 206f 6e20 ) is dropped on │ │ │ -00062460: 7468 6520 626c 6f63 6b65 6420 7061 7468 the blocked path │ │ │ -00062470: 2e0a 6173 796e 635f 7772 6974 6520 7265 ..async_write re │ │ │ -00062480: 7475 726e 7320 6661 6c73 6520 286b 6565 turns false (kee │ │ │ -00062490: 7020 7772 6974 696e 6729 2062 7574 2074 p writing) but t │ │ │ -000624a0: 6865 2063 6163 6865 2773 2062 6163 6b2d he cache's back- │ │ │ -000624b0: 7072 6573 7375 7265 0a28 6472 6976 656e pressure.(driven │ │ │ -000624c0: 206f 6666 206d 5f62 6c6f 636b 7329 2063 off m_blocks) c │ │ │ -000624d0: 616e 2774 2073 6565 2074 6865 2070 6172 an't see the par │ │ │ -000624e0: 6b65 6420 7772 6974 6573 2c20 736f 2061 ked writes, so a │ │ │ -000624f0: 206c 6f6e 672d 6c69 7665 6420 6665 6e63 long-lived fenc │ │ │ -00062500: 650a 2865 2e67 2e20 6d6f 7665 5f73 746f e.(e.g. move_sto │ │ │ -00062510: 7261 6765 2920 6f6e 2061 2062 7573 7920 rage) on a busy │ │ │ -00062520: 746f 7272 656e 7420 6361 6e20 6772 6f77 torrent can grow │ │ │ -00062530: 206d 5f62 6c6f 636b 6564 5f6a 6f62 7320 m_blocked_jobs │ │ │ -00062540: 756e 626f 756e 6465 642e 0a43 6172 7279 unbounded..Carry │ │ │ -00062550: 2074 6865 206f 6273 6572 7665 7220 7468 the observer th │ │ │ -00062560: 726f 7567 6820 746f 2074 6872 6f74 746c rough to throttl │ │ │ -00062570: 6520 7468 6520 7065 6572 2077 6869 6c65 e the peer while │ │ │ -00062580: 2069 7473 2077 7269 7465 7320 6172 6520 its writes are │ │ │ -00062590: 7061 726b 6564 2e3c 2f68 323e 3c68 343e parked.

    │ │ │ -000625a0: 2e2e 2f73 7263 2f70 7265 6164 5f64 6973 ../src/pread_dis │ │ │ -000625b0: 6b5f 696f 2e63 7070 3a37 3532 3c2f 6834 k_io.cpp:752

    .// s
    │ │ │ -00062600: 746f 7261 6765 2773 206f 7574 7374 616e  torage's outstan
    │ │ │ -00062610: 6469 6e67 2d6a 6f62 2063 6f75 6e74 2e20  ding-job count. 
    │ │ │ -00062620: 6973 5f62 6c6f 636b 6564 2829 2068 6173  is_blocked() has
    │ │ │ -00062630: 206e 6f74 2072 756e 2c20 736f 206a 2069   not run, so j i
    │ │ │ -00062640: 7320 6e6f 740a 092f 2f20 696e 5f70 726f  s not..// in_pro
    │ │ │ -00062650: 6772 6573 7320 616e 6420 6d75 7374 206e  gress and must n
    │ │ │ -00062660: 6f74 2062 6520 6a6f 625f 636f 6d70 6c65  ot be job_comple
    │ │ │ -00062670: 7465 2829 6420 2d2d 2061 626f 7274 2069  te()d -- abort i
    │ │ │ -00062680: 7420 6469 7265 6374 6c79 2e0a 0969 6620  t directly...if 
    │ │ │ -00062690: 286d 5f61 626f 7274 290a 097b 0a09 096d  (m_abort)..{...m
    │ │ │ -000626a0: 5f63 6f6d 706c 6574 6564 5f6a 6f62 732e  _completed_jobs.
    │ │ │ -000626b0: 6162 6f72 745f 6a6f 6228 6d5f 696f 732c  abort_job(m_ios,
    │ │ │ -000626c0: 206a 293b 0a09 0972 6574 7572 6e20 6661   j);...return fa
    │ │ │ -000626d0: 6c73 653b 0a09 7d0a 0a09 2f2f 2061 2077  lse;..}...// a w
    │ │ │ -000626e0: 7269 7465 2063 6f75 6e74 7320 6173 2061  rite counts as a
    │ │ │ -000626f0: 6e20 6f75 7473 7461 6e64 696e 6720 6a6f  n outstanding jo
    │ │ │ -00062700: 6220 6f6e 2074 6865 2073 746f 7261 6765  b on the storage
    │ │ │ -00062710: 2028 6c69 6b65 2061 2072 6561 6420 6f72   (like a read or
    │ │ │ -00062720: 2068 6173 6829 2c0a 092f 2f20 736f 2061   hash),..// so a
    │ │ │ -00062730: 2066 656e 6365 2077 6169 7473 2066 6f72   fence waits for
    │ │ │ -00062740: 2062 7566 6665 7265 6420 7772 6974 6573   buffered writes
    │ │ │ -00062750: 2061 6e64 2074 6865 6972 2069 6e2d 666c   and their in-fl
    │ │ │ -00062760: 6967 6874 2066 6c75 7368 2062 6566 6f72  ight flush befor
    │ │ │ -00062770: 6520 6974 0a09 2f2f 2072 756e 732c 2072  e it..// runs, r
    │ │ │ -00062780: 6174 6865 7220 7468 616e 2074 6561 7269  ather than teari
    │ │ │ -00062790: 6e67 2074 6865 2073 746f 7261 6765 2064  ng the storage d
    │ │ │ -000627a0: 6f77 6e20 756e 6465 7220 6120 666c 7573  own under a flus
    │ │ │ -000627b0: 682e 2054 6869 7320 646f 6573 206e 6f74  h. This does not
    │ │ │ -000627c0: 0a09 2f2f 2064 6561 646c 6f63 6b20 7468  ..// deadlock th
    │ │ │ -000627d0: 6520 6665 6e63 653a 2061 6464 5f66 656e  e fence: add_fen
    │ │ │ -000627e0: 6365 5f6a 6f62 2829 2068 616e 6473 2061  ce_job() hands a
    │ │ │ -000627f0: 2073 746f 7261 6765 2077 6974 6820 6f75   storage with ou
    │ │ │ -00062800: 7473 7461 6e64 696e 6720 7772 6974 6573  tstanding writes
    │ │ │ -00062810: 0a09 2f2f 2074 6f20 6120 6765 6e65 7269  ..// to a generi
    │ │ │ -00062820: 6320 7468 7265 6164 2074 6f20 666c 7573  c thread to flus
    │ │ │ -00062830: 682c 2064 7261 696e 696e 6720 7468 6520  h, draining the 
    │ │ │ -00062840: 7772 6974 6573 2074 6865 2066 656e 6365  writes the fence
    │ │ │ -00062850: 2077 6169 7473 206f 6e2e 0a09 2f2f 0a09   waits on...//..
    │ │ │ -00062860: 2f2f 2077 6865 6e20 6120 6665 6e63 6520  // when a fence 
    │ │ │ -00062870: 6973 2075 702c 2069 735f 626c 6f63 6b65  is up, is_blocke
    │ │ │ -00062880: 6428 2920 7061 726b 7320 7468 6520 6a6f  d() parks the jo
    │ │ │ -00062890: 6220 696e 2074 6865 2066 656e 6365 2773  b in the fence's
    │ │ │ -000628a0: 2062 6c6f 636b 6564 2071 7565 7565 0a09   blocked queue..
    │ │ │ -000628b0: 2f2f 2074 6f20 6265 2072 6570 6f73 7465  // to be reposte
    │ │ │ -000628c0: 6420 696e 746f 2074 6865 2063 6163 6865  d into the cache
    │ │ │ -000628d0: 206f 6e63 6520 7468 6520 6665 6e63 6520   once the fence 
    │ │ │ -000628e0: 6c6f 7765 7273 2028 6164 645f 636f 6d70  lowers (add_comp
    │ │ │ -000628f0: 6c65 7465 645f 6a6f 6273 5f69 6d70 6c29  leted_jobs_impl)
    │ │ │ -00062900: 2e0a 092f 2f20 496e 7365 7274 696e 6720  ...// Inserting 
    │ │ │ -00062910: 6e6f 7720 776f 756c 6420 7261 6365 2074  now would race t
    │ │ │ -00062920: 6561 7264 6f77 6e3a 2066 6f72 2063 6c65  eardown: for cle
    │ │ │ -00062930: 6172 5f70 6965 6365 2074 6865 2063 7065  ar_piece the cpe
    │ │ │ -00062940: 2069 7320 6162 6f75 7420 746f 2062 650a   is about to be.
    │ │ │ -00062950: 092f 2f20 7265 7365 742c 2066 6f72 2073  .// reset, for s
    │ │ │ -00062960: 746f 7261 6765 2d77 6964 6520 6665 6e63  torage-wide fenc
    │ │ │ -00062970: 6573 2074 6865 2073 746f 7261 6765 2069  es the storage i
    │ │ │ -00062980: 7320 6162 6f75 7420 746f 2067 6f20 6177  s about to go aw
    │ │ │ -00062990: 6179 2e20 5061 726b 696e 670a 092f 2f20  ay. Parking..// 
    │ │ │ -000629a0: 6b65 6570 7320 7468 6520 626c 6f63 6b20  keeps the block 
    │ │ │ -000629b0: 2277 7269 7469 6e67 2220 696e 2074 6865  "writing" in the
    │ │ │ -000629c0: 2070 6963 6b65 7227 7320 7669 6577 2c20   picker's view, 
    │ │ │ -000629d0: 736f 2074 6865 2070 6965 6365 2069 736e  so the piece isn
    │ │ │ -000629e0: 2774 2072 6570 6f72 7465 640a 092f 2f20  't reported..// 
    │ │ │ -000629f0: 6669 6e69 7368 6564 2061 6e64 2069 7473  finished and its
    │ │ │ -00062a00: 2068 6173 6820 6973 6e27 7420 7265 7175   hash isn't requ
    │ │ │ -00062a10: 6573 7465 6420 6265 666f 7265 2074 6865  ested before the
    │ │ │ -00062a20: 2062 6c6f 636b 2068 6173 2062 6565 6e20   block has been 
    │ │ │ -00062a30: 696e 7365 7274 6564 2e0a 3c64 6976 2073  inserted..
    .if (j-& │ │ │ -00062a70: 6774 3b73 746f 7261 6765 2d26 6774 3b69 gt;storage->i │ │ │ -00062a80: 735f 626c 6f63 6b65 6428 6a2c 206d 5f73 s_blocked(j, m_s │ │ │ -00062a90: 7461 7473 5f63 6f75 6e74 6572 7329 290a tats_counters)). │ │ │ -00062aa0: 3c2f 6469 763e 097b 0a09 0972 6574 7572
    .{...retur │ │ │ -00062ab0: 6e20 6661 6c73 653b 0a09 7d0a 0a09 2f2f n false;..}...// │ │ │ -00062ac0: 2069 735f 626c 6f63 6b65 6428 2920 6d61 is_blocked() ma │ │ │ -00062ad0: 726b 6564 206a 2069 6e5f 7072 6f67 7265 rked j in_progre │ │ │ -00062ae0: 7373 2061 6e64 2063 6f75 6e74 6564 2069 ss and counted i │ │ │ -00062af0: 7420 6173 206f 7574 7374 616e 6469 6e67 t as outstanding │ │ │ -00062b00: 2e0a 0962 6f6f 6c20 636f 6e73 7420 6578 ...bool const ex │ │ │ -00062b10: 6365 6564 6564 203d 2061 6464 5f77 7269 ceeded = add_wri │ │ │ -00062b20: 7465 5f74 6f5f 6361 6368 6528 6a2c 2073 te_to_cache(j, s │ │ │ -00062b30: 7464 3a3a 6d6f 7665 286f 2929 3b0a 0973 td::move(o));..s │ │ │ -00062b40: 6368 6564 756c 655f 666c 7573 6828 293b chedule_flush(); │ │ │ -00062b50: 0a09 7265 7475 726e 2065 7863 6565 6465 ..return exceede │ │ │ -00062b60: 643b 0a7d 0a0a 6175 783a 3a69 6e73 6572 d;.}..aux::inser │ │ │ -00062b70: 745f 7265 7375 6c74 5f66 6c61 6773 2070 t_result_flags p │ │ │ -00062b80: 7265 6164 5f64 6973 6b5f 696f 3a3a 696e read_disk_io::in │ │ │ -00062b90: 7365 7274 5f77 7269 7465 280a 0961 7578 sert_write(..aux │ │ │ -00062ba0: 3a3a 7072 6561 645f 6469 736b 5f6a 6f62 ::pread_disk_job │ │ │ -00062bb0: 2a20 6a2c 2073 7464 3a3a 7368 6172 6564 * j, std::shared │ │ │ -00062bc0: 5f70 7472 266c 743b 6469 736b 5f6f 6273 _ptr<disk_obs │ │ │ -00062bd0: 6572 7665 7226 6774 3b20 6f29 0a7b 0a09 erver> o).{.. │ │ │ -00062be0: 6175 746f 2063 6f6e 7374 2661 6d70 3b20 auto const& │ │ │ -00062bf0: 6120 3d20 7374 643a 3a67 6574 266c 743b a = std::get< │ │ │ -00062c00: 6175 783a 3a6a 6f62 3a3a 7772 6974 6526 aux::job::write& │ │ │ -00062c10: 6774 3b28 6a2d 2667 743b 6163 7469 6f6e gt;(j->action │ │ │ -00062c20: 293b 0a09 7069 6563 655f 696e 6465 785f );..piece_index_ │ │ │ -00062c30: 7420 636f 6e73 7420 7069 6563 6520 3d20 t const piece = │ │ │ -00062c40: 612e 7069 6563 653b 0a09 696e 7420 636f a.piece;..int co │ │ │ -00062c50: 6e73 7420 6f66 6673 6574 203d 2061 2e6f nst offset = a.o │ │ │ -00062c60: 6666 7365 743b 0a0a 0944 4c4f 4728 2261 ffset;...DLOG("a │ │ │ -00062c70: 7379 6e63 5f77 7269 7465 3a20 7069 6563 sync_write: piec │ │ │ -00062c80: 653a 2025 6420 6f66 6673 6574 3a20 2564 e: %d offset: %d │ │ │ -00062c90: 2066 6c61 6773 3a20 2578 5c6e 222c 0a09 flags: %x\n",.. │ │ │ -00062ca0: 0969 6e74 2870 6965 6365 292c 0a09 0969 .int(piece),...i │ │ │ -00062cb0: 6e74 286f 6666 7365 7429 2c0a 0909 7374 nt(offset),...st │ │ │ -00062cc0: 6174 6963 5f63 6173 7426 6c74 3b73 7464 atic_cast<std │ │ │ -00062cd0: 3a3a 7569 6e74 385f 7426 6774 3b28 6a2d ::uint8_t>(j- │ │ │ -00062ce0: 2667 743b 666c 6167 7329 293b 0a09 626f >flags));..bo │ │ │ -00062cf0: 6f6c 2063 6f6e 7374 2066 6f72 6365 5f66 ol const force_f │ │ │ -00062d00: 6c75 7368 203d 2062 6f6f 6c28 6a2d 2667 lush = bool(j-&g │ │ │ -00062d10: 743b 666c 6167 7320 2661 6d70 3b20 666c t;flags & fl │ │ │ -00062d20: 7573 685f 7069 6563 6529 3b0a 0966 696c ush_piece);..fil │ │ │ -00062d30: 655f 7374 6f72 6167 6520 636f 6e73 7426 e_storage const& │ │ │ -00062d40: 616d 703b 2066 7320 3d20 6a2d 2667 743b amp; fs = j-> │ │ │ -00062d50: 7374 6f72 6167 652d 2667 743b 6669 6c65 storage->file │ │ │ -00062d60: 7328 293b 0a09 2f2f 2069 6e20 6f72 6465 s();..// in orde │ │ │ -00062d70: 7220 746f 2063 6f6d 7075 7465 2076 3120 r to compute v1 │ │ │ -00062d80: 6861 7368 6573 2c20 7765 206e 6565 6420 hashes, we need │ │ │ -00062d90: 7468 6520 6675 6c6c 2070 6965 6365 2c20 the full piece, │ │ │ -00062da0: 696e 636c 7564 696e 6720 7061 640a 092f including pad../ │ │ │ -00062db0: 2f20 6669 6c65 732e 2045 7665 6e20 7468 / files. Even th │ │ │ -00062dc0: 6f75 6768 2076 3220 746f 7272 656e 7473 ough v2 torrents │ │ │ -00062dd0: 2067 7561 7261 6e74 6565 2074 6861 7420 guarantee that │ │ │ -00062de0: 7468 6579 2061 7265 207a 6572 6f2e 0a09 they are zero... │ │ │ -00062df0: 696e 7420 636f 6e73 7420 7069 6563 655f int const piece_ │ │ │ -00062e00: 7369 7a65 203d 206a 2d26 6774 3b73 746f size = j->sto │ │ │ -00062e10: 7261 6765 2d26 6774 3b76 3128 2920 3f20 rage->v1() ? │ │ │ -00062e20: 6673 2e70 6965 6365 5f73 697a 6528 7069 fs.piece_size(pi │ │ │ -00062e30: 6563 6529 203a 2066 732e 7069 6563 655f ece) : fs.piece_ │ │ │ -00062e40: 7369 7a65 3228 7069 6563 6529 3b0a 0954 size2(piece);..T │ │ │ -00062e50: 4f52 5245 4e54 5f41 5353 4552 5428 612e ORRENT_ASSERT(a. │ │ │ -00062e60: 6275 6666 6572 5f73 697a 6520 3d3d 2073 buffer_size == s │ │ │ -00062e70: 7464 3a3a 6d69 6e28 7069 6563 655f 7369 td::min(piece_si │ │ │ -00062e80: 7a65 202d 206f 6666 7365 742c 2064 6566 ze - offset, def │ │ │ -00062e90: 6175 6c74 5f62 6c6f 636b 5f73 697a 6529 ault_block_size) │ │ │ -00062ea0: 293b 0a09 6175 783a 3a64 6973 6b5f 6361 );..aux::disk_ca │ │ │ -00062eb0: 6368 653a 3a70 6965 6365 5f65 6e74 7279 che::piece_entry │ │ │ -00062ec0: 5f70 6172 616d 7320 636f 6e73 7420 7069 _params const pi │ │ │ -00062ed0: 6563 655f 7061 7261 6d73 7b0a 0909 6673 ece_params{...fs │ │ │ -00062ee0: 2e70 6965 6365 5f73 697a 6532 2870 6965 .piece_size2(pie │ │ │ -00062ef0: 6365 292c 2070 6965 6365 5f73 697a 652c ce), piece_size, │ │ │ -00062f00: 206a 2d26 6774 3b73 746f 7261 6765 2d26 j->storage-& │ │ │ -00062f10: 6774 3b76 3128 292c 206a 2d26 6774 3b73 gt;v1(), j->s │ │ │ -00062f20: 746f 7261 6765 2d26 6774 3b76 3228 292c torage->v2(), │ │ │ -00062f30: 206a 2d26 6774 3b73 746f 7261 6765 7d3b j->storage}; │ │ │ -00062f40: 0a09 7265 7475 726e 206d 5f63 6163 6865 ..return m_cache │ │ │ -00062f50: 2e69 6e73 6572 7428 7b6a 2d26 6774 3b73 .insert({j->s │ │ │ -00062f60: 746f 7261 6765 2d26 6774 3b73 746f 7261 torage->stora │ │ │ -00062f70: 6765 5f69 6e64 6578 2829 2c20 7069 6563 ge_index(), piec │ │ │ -00062f80: 657d 2c0a 3c2f 7072 653e 3c2f 7464 3e3c e},.
    < │ │ │ -00062f90: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00062fc0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -00062ff0: 2e2f 7372 632f 7072 6561 645f 6469 736b ./src/pread_disk │ │ │ -00063000: 5f69 6f2e 6370 703a 3933 363c 2f61 3e3c _io.cpp:936< │ │ │ -00063010: 2f74 643e 3c74 643e 7765 206d 6179 206e /td>we may n │ │ │ -00063020: 6f74 206e 6565 6420 746f 2064 6f20 7468 ot need to do th │ │ │ -00063030: 6973 2c20 7468 6520 6361 6368 6520 636f is, the cache co │ │ │ -00063040: 756c 6420 7465 6c6c 2075 7320 7468 6973 uld tell us this │ │ │ -00063050: 2070 6965 6365 2073 686f 756c 6420 6265 piece should be │ │ │ -00063060: 2066 6c75 7368 6564 2074 6f20 6469 736b flushed to disk │ │ │ -00063070: 206e 6f77 2e3c 2f74 643e 3c2f 7472 3e3c now.< │ │ │ -00063080: 7472 2069 643d 2232 3237 2220 7374 796c tr id="227" styl │ │ │ -00063090: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -000630a0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -000630b0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -000630c0: 6832 3e77 6520 6d61 7920 6e6f 7420 6e65 h2>we may not ne │ │ │ -000630d0: 6564 2074 6f20 646f 2074 6869 732c 2074 ed to do this, t │ │ │ -000630e0: 6865 2063 6163 6865 2063 6f75 6c64 2074 he cache could t │ │ │ -000630f0: 656c 6c20 7573 0a74 6869 7320 7069 6563 ell us.this piec │ │ │ -00063100: 6520 7368 6f75 6c64 2062 6520 666c 7573 e should be flus │ │ │ -00063110: 6865 6420 746f 2064 6973 6b20 6e6f 772e hed to disk now. │ │ │ -00063120: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -00063130: 7072 6561 645f 6469 736b 5f69 6f2e 6370 pread_disk_io.cp │ │ │ -00063140: 703a 3933 363c 2f68 343e 3c70 7265 2073 p:936

    ...fill_prec
    │ │ │ -00063190: 6f6d 7075 7465 645f 7632 280a 0909 0909  omputed_v2(.....
    │ │ │ -000631a0: 612e 626c 6f63 6b5f 6861 7368 6573 2c20  a.block_hashes, 
    │ │ │ -000631b0: 6a2d 2667 743b 7374 6f72 6167 652d 2667  j->storage-&g
    │ │ │ -000631c0: 743b 7461 6b65 5f70 7265 636f 6d70 7574  t;take_precomput
    │ │ │ -000631d0: 6564 5f76 3228 7069 6563 6529 2c20 626c  ed_v2(piece), bl
    │ │ │ -000631e0: 6f63 6b73 5f69 6e5f 7069 6563 6532 293b  ocks_in_piece2);
    │ │ │ -000631f0: 0a0a 0909 0966 6f72 2028 696e 7420 6920  .....for (int i 
    │ │ │ -00063200: 3d20 303b 2069 2026 6c74 3b20 626c 6f63  = 0; i < bloc
    │ │ │ -00063210: 6b73 5f69 6e5f 7069 6563 6532 3b20 2b2b  ks_in_piece2; ++
    │ │ │ -00063220: 6929 0a09 0909 7b0a 0909 0909 6966 2028  i)....{.....if (
    │ │ │ -00063230: 6920 2667 743b 3d20 696e 7428 612e 626c  i >= int(a.bl
    │ │ │ -00063240: 6f63 6b5f 6861 7368 6573 2e73 697a 6528  ock_hashes.size(
    │ │ │ -00063250: 2929 207c 7c20 612e 626c 6f63 6b5f 6861  )) || a.block_ha
    │ │ │ -00063260: 7368 6573 5b69 5d2e 6973 5f61 6c6c 5f7a  shes[i].is_all_z
    │ │ │ -00063270: 6572 6f73 2829 290a 0909 0909 7b0a 0909  eros()).....{...
    │ │ │ -00063280: 0909 096e 6565 645f 6469 736b 5f66 616c  ...need_disk_fal
    │ │ │ -00063290: 6c62 6163 6b20 3d20 7472 7565 3b0a 0909  lback = true;...
    │ │ │ -000632a0: 0909 0962 7265 616b 3b0a 0909 0909 7d0a  ...break;.....}.
    │ │ │ -000632b0: 0909 097d 0a09 097d 0a0a 0909 6966 2028  ...}...}....if (
    │ │ │ -000632c0: 6e65 6564 5f64 6973 6b5f 6661 6c6c 6261  need_disk_fallba
    │ │ │ -000632d0: 636b 290a 0909 7b0a 0909 0944 4c4f 4728  ck)...{....DLOG(
    │ │ │ -000632e0: 2261 7379 6e63 5f68 6173 683a 2076 3220  "async_hash: v2 
    │ │ │ -000632f0: 6861 7368 6573 2069 6e63 6f6d 706c 6574  hashes incomplet
    │ │ │ -00063300: 652c 2066 616c 6c69 6e67 2062 6163 6b20  e, falling back 
    │ │ │ -00063310: 746f 2064 6f5f 6a6f 6228 6861 7368 295c  to do_job(hash)\
    │ │ │ -00063320: 6e22 293b 0a09 0909 6164 645f 6a6f 6228  n");....add_job(
    │ │ │ -00063330: 6a29 3b0a 0909 0972 6574 7572 6e3b 0a09  j);....return;..
    │ │ │ -00063340: 097d 0a0a 3c64 6976 2073 7479 6c65 3d22  .}..
    ..m_generic_th │ │ │ -00063380: 7265 6164 732e 696e 7465 7272 7570 7428 reads.interrupt( │ │ │ -00063390: 293b 0a3c 2f64 6976 3e0a 0909 6a6f 6271 );.
    ...jobq │ │ │ -000633a0: 7565 7565 5f74 206a 6f62 733b 0a09 096a ueue_t jobs;...j │ │ │ -000633b0: 6f62 732e 7075 7368 5f62 6163 6b28 6a29 obs.push_back(j) │ │ │ -000633c0: 3b0a 0909 6164 645f 636f 6d70 6c65 7465 ;...add_complete │ │ │ -000633d0: 645f 6a6f 6273 2873 7464 3a3a 6d6f 7665 d_jobs(std::move │ │ │ -000633e0: 286a 6f62 7329 293b 0a09 0972 6574 7572 (jobs));...retur │ │ │ -000633f0: 6e3b 0a09 7d0a 0a09 2f2f 2049 6e20 7468 n;..}...// In th │ │ │ -00063400: 6973 2063 6173 6520 7468 6520 6a6f 6220 is case the job │ │ │ -00063410: 6861 7320 6265 656e 2071 7565 7565 6420 has been queued │ │ │ -00063420: 6f6e 2074 6865 2070 6965 6365 2c20 616e on the piece, an │ │ │ -00063430: 6420 7769 6c6c 2062 6520 706f 7374 6564 d will be posted │ │ │ -00063440: 0a09 2f2f 206f 6e63 6520 7468 6520 6861 ..// once the ha │ │ │ -00063450: 7368 696e 6720 636f 6d70 6c65 7465 730a shing completes. │ │ │ -00063460: 0969 6620 2872 6574 203d 3d20 6175 783a .if (ret == aux: │ │ │ -00063470: 3a64 6973 6b5f 6361 6368 653a 3a6a 6f62 :disk_cache::job │ │ │ -00063480: 5f71 7565 7565 6429 0a09 0972 6574 7572 _queued)...retur │ │ │ -00063490: 6e3b 0a0a 0961 6464 5f6a 6f62 286a 293b n;...add_job(j); │ │ │ -000634a0: 0a7d 0a0a 766f 6964 2070 7265 6164 5f64 .}..void pread_d │ │ │ -000634b0: 6973 6b5f 696f 3a3a 6173 796e 635f 6861 isk_io::async_ha │ │ │ -000634c0: 7368 3228 7374 6f72 6167 655f 696e 6465 sh2(storage_inde │ │ │ -000634d0: 785f 7420 636f 6e73 7420 7374 6f72 6167 x_t const storag │ │ │ -000634e0: 650a 092c 2070 6965 6365 5f69 6e64 6578 e.., piece_index │ │ │ -000634f0: 5f74 2063 6f6e 7374 2070 6965 6365 2c20 _t const piece, │ │ │ -00063500: 696e 7420 636f 6e73 7420 6f66 6673 6574 int const offset │ │ │ -00063510: 2c20 6469 736b 5f6a 6f62 5f66 6c61 6773 , disk_job_flags │ │ │ -00063520: 5f74 2063 6f6e 7374 2066 6c61 6773 0a09 _t const flags.. │ │ │ -00063530: 2c20 7374 643a 3a66 756e 6374 696f 6e26 , std::function& │ │ │ -00063540: 6c74 3b76 6f69 6428 7069 6563 655f 696e lt;void(piece_in │ │ │ -00063550: 6465 785f 742c 2073 6861 3235 365f 6861 dex_t, sha256_ha │ │ │ -00063560: 7368 2063 6f6e 7374 2661 6d70 3b2c 2073 sh const&, s │ │ │ -00063570: 746f 7261 6765 5f65 7272 6f72 2063 6f6e torage_error con │ │ │ -00063580: 7374 2661 6d70 3b29 2667 743b 2068 616e st&)> han │ │ │ -00063590: 646c 6572 290a 7b0a 0954 4f52 5245 4e54 dler).{..TORRENT │ │ │ -000635a0: 5f41 5353 4552 5428 7661 6c69 645f 666c _ASSERT(valid_fl │ │ │ -000635b0: 6167 7328 666c 6167 7329 293b 0a09 6175 ags(flags));..au │ │ │ -000635c0: 783a 3a70 7265 6164 5f64 6973 6b5f 6a6f x::pread_disk_jo │ │ │ -000635d0: 622a 206a 203d 206d 5f6a 6f62 5f70 6f6f b* j = m_job_poo │ │ │ -000635e0: 6c2e 616c 6c6f 6361 7465 5f6a 6f62 266c l.allocate_job&l │ │ │ -000635f0: 743b 6175 783a 3a6a 6f62 3a3a 6861 7368 t;aux::job::hash │ │ │ -00063600: 3226 6774 3b28 0a09 0966 6c61 6773 2c0a 2>(...flags,. │ │ │ -00063610: 0909 6d5f 746f 7272 656e 7473 5b73 746f ..m_torrents[sto │ │ │ -00063620: 7261 6765 5d2d 2667 743b 7368 6172 6564 rage]->shared │ │ │ -00063630: 5f66 726f 6d5f 7468 6973 2829 2c0a 0909 _from_this(),... │ │ │ -00063640: 7374 643a 3a6d 6f76 6528 6861 6e64 6c65 std::move(handle │ │ │ -00063650: 7229 2c0a 0909 7069 6563 652c 0a09 096f r),...piece,...o │ │ │ -00063660: 6666 7365 742c 0a09 0973 6861 3235 365f ffset,...sha256_ │ │ │ -00063670: 6861 7368 7b7d 0a09 293b 0a0a 092f 2f20 hash{}..);...// │ │ │ -00063680: 496e 2074 6865 6f72 792c 2077 6520 636f In theory, we co │ │ │ -00063690: 756c 6420 6368 6563 6b20 7468 6520 6361 uld check the ca │ │ │ -000636a0: 6368 6520 666f 7220 7468 6973 2062 6c6f che for this blo │ │ │ -000636b0: 636b 2068 6173 682c 2062 7574 2077 650a ck hash, but we. │ │ │ -000636c0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -000636d0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00063700: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -00063730: 632f 7072 6561 645f 6469 736b 5f69 6f2e c/pread_disk_io. │ │ │ -00063740: 6370 703a 3134 3230 3c2f 613e 3c2f 7464 cpp:1420maybe we do │ │ │ -00063760: 6e27 7420 6e65 6564 2074 6f20 7772 6974 n't need to writ │ │ │ -00063770: 6520 746f 2066 696c 6573 2077 6527 7265 e to files we're │ │ │ -00063780: 2061 626f 7574 2074 6f20 6465 6c65 7465 about to delete │ │ │ -00063790: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    ma │ │ │ -000637e0: 7962 6520 7765 2064 6f6e 2774 206e 6565 ybe we don't nee │ │ │ -000637f0: 6420 746f 2077 7269 7465 2074 6f20 6669 d to write to fi │ │ │ -00063800: 6c65 7320 7765 2772 6520 6162 6f75 7420 les we're about │ │ │ -00063810: 746f 2064 656c 6574 653c 2f68 323e 3c68 to delete

    ../src/pread_d │ │ │ -00063830: 6973 6b5f 696f 2e63 7070 3a31 3432 303c isk_io.cpp:1420< │ │ │ -00063840: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    .a
    │ │ │ -00063880: 2e70 6174 6820 3d20 7374 643a 3a6d 6f76  .path = std::mov
    │ │ │ -00063890: 6528 7029 3b0a 0972 6574 7572 6e20 7265  e(p);..return re
    │ │ │ -000638a0: 743b 0a7d 0a0a 7374 6174 7573 5f74 2070  t;.}..status_t p
    │ │ │ -000638b0: 7265 6164 5f64 6973 6b5f 696f 3a3a 646f  read_disk_io::do
    │ │ │ -000638c0: 5f6a 6f62 2861 7578 3a3a 6a6f 623a 3a72  _job(aux::job::r
    │ │ │ -000638d0: 656c 6561 7365 5f66 696c 6573 2661 6d70  elease_files&
    │ │ │ -000638e0: 3b2c 2061 7578 3a3a 7072 6561 645f 6469  ;, aux::pread_di
    │ │ │ -000638f0: 736b 5f6a 6f62 2a20 6a29 0a7b 0a09 2f2f  sk_job* j).{..//
    │ │ │ -00063900: 2069 6620 7468 6973 2061 7373 6572 7420   if this assert 
    │ │ │ -00063910: 6661 696c 732c 2073 6f6d 6574 6869 6e67  fails, something
    │ │ │ -00063920: 2773 2077 726f 6e67 2077 6974 6820 7468  's wrong with th
    │ │ │ -00063930: 6520 6665 6e63 6520 6c6f 6769 630a 0954  e fence logic..T
    │ │ │ -00063940: 4f52 5245 4e54 5f41 5353 4552 5428 6a2d  ORRENT_ASSERT(j-
    │ │ │ -00063950: 2667 743b 7374 6f72 6167 652d 2667 743b  >storage->
    │ │ │ -00063960: 6e75 6d5f 6f75 7473 7461 6e64 696e 675f  num_outstanding_
    │ │ │ -00063970: 6a6f 6273 2829 203d 3d20 3129 3b0a 0966  jobs() == 1);..f
    │ │ │ -00063980: 6c75 7368 5f73 746f 7261 6765 286a 2d26  lush_storage(j-&
    │ │ │ -00063990: 6774 3b73 746f 7261 6765 293b 0a09 6a2d  gt;storage);..j-
    │ │ │ -000639a0: 2667 743b 7374 6f72 6167 652d 2667 743b  >storage->
    │ │ │ -000639b0: 7265 6c65 6173 655f 6669 6c65 7328 6a2d  release_files(j-
    │ │ │ -000639c0: 2667 743b 6572 726f 7229 3b0a 0972 6574  >error);..ret
    │ │ │ -000639d0: 7572 6e20 6a2d 2667 743b 6572 726f 7220  urn j->error 
    │ │ │ -000639e0: 3f20 6469 736b 5f73 7461 7475 733a 3a66  ? disk_status::f
    │ │ │ -000639f0: 6174 616c 5f64 6973 6b5f 6572 726f 7220  atal_disk_error 
    │ │ │ -00063a00: 3a20 7374 6174 7573 5f74 7b7d 3b0a 7d0a  : status_t{};.}.
    │ │ │ -00063a10: 0a73 7461 7475 735f 7420 7072 6561 645f  .status_t pread_
    │ │ │ -00063a20: 6469 736b 5f69 6f3a 3a64 6f5f 6a6f 6228  disk_io::do_job(
    │ │ │ -00063a30: 6175 783a 3a6a 6f62 3a3a 6465 6c65 7465  aux::job::delete
    │ │ │ -00063a40: 5f66 696c 6573 2661 6d70 3b20 612c 2061  _files& a, a
    │ │ │ -00063a50: 7578 3a3a 7072 6561 645f 6469 736b 5f6a  ux::pread_disk_j
    │ │ │ -00063a60: 6f62 2a20 6a29 0a7b 0a09 544f 5252 454e  ob* j).{..TORREN
    │ │ │ -00063a70: 545f 4153 5345 5254 2861 2e66 6c61 6773  T_ASSERT(a.flags
    │ │ │ -00063a80: 293b 0a0a 092f 2f20 6966 2074 6869 7320  );...// if this 
    │ │ │ -00063a90: 6173 7365 7274 2066 6169 6c73 2c20 736f  assert fails, so
    │ │ │ -00063aa0: 6d65 7468 696e 6727 7320 7772 6f6e 6720  mething's wrong 
    │ │ │ -00063ab0: 7769 7468 2074 6865 2066 656e 6365 206c  with the fence l
    │ │ │ -00063ac0: 6f67 6963 0a09 544f 5252 454e 545f 4153  ogic..TORRENT_AS
    │ │ │ -00063ad0: 5345 5254 286a 2d26 6774 3b73 746f 7261  SERT(j->stora
    │ │ │ -00063ae0: 6765 2d26 6774 3b6e 756d 5f6f 7574 7374  ge->num_outst
    │ │ │ -00063af0: 616e 6469 6e67 5f6a 6f62 7328 2920 3d3d  anding_jobs() ==
    │ │ │ -00063b00: 2031 293b 0a0a 3c64 6976 2073 7479 6c65   1);..
    .flush_stora │ │ │ -00063b40: 6765 286a 2d26 6774 3b73 746f 7261 6765 ge(j->storage │ │ │ -00063b50: 293b 0a3c 2f64 6976 3e0a 096a 2d26 6774 );.
    ..j-> │ │ │ -00063b60: 3b73 746f 7261 6765 2d26 6774 3b64 656c ;storage->del │ │ │ -00063b70: 6574 655f 6669 6c65 7328 612e 666c 6167 ete_files(a.flag │ │ │ -00063b80: 732c 206a 2d26 6774 3b65 7272 6f72 293b s, j->error); │ │ │ -00063b90: 0a09 7265 7475 726e 206a 2d26 6774 3b65 ..return j->e │ │ │ -00063ba0: 7272 6f72 203f 2064 6973 6b5f 7374 6174 rror ? disk_stat │ │ │ -00063bb0: 7573 3a3a 6661 7461 6c5f 6469 736b 5f65 us::fatal_disk_e │ │ │ -00063bc0: 7272 6f72 203a 2073 7461 7475 735f 747b rror : status_t{ │ │ │ -00063bd0: 7d3b 0a7d 0a0a 7374 6174 7573 5f74 2070 };.}..status_t p │ │ │ -00063be0: 7265 6164 5f64 6973 6b5f 696f 3a3a 646f read_disk_io::do │ │ │ -00063bf0: 5f6a 6f62 2861 7578 3a3a 6a6f 623a 3a63 _job(aux::job::c │ │ │ -00063c00: 6865 636b 5f66 6173 7472 6573 756d 6526 heck_fastresume& │ │ │ -00063c10: 616d 703b 2061 2c20 6175 783a 3a70 7265 amp; a, aux::pre │ │ │ -00063c20: 6164 5f64 6973 6b5f 6a6f 622a 206a 290a ad_disk_job* j). │ │ │ -00063c30: 7b0a 092f 2f20 6966 2074 6869 7320 6173 {..// if this as │ │ │ -00063c40: 7365 7274 2066 6169 6c73 2c20 736f 6d65 sert fails, some │ │ │ -00063c50: 7468 696e 6727 7320 7772 6f6e 6720 7769 thing's wrong wi │ │ │ -00063c60: 7468 2074 6865 2066 656e 6365 206c 6f67 th the fence log │ │ │ -00063c70: 6963 0a09 544f 5252 454e 545f 4153 5345 ic..TORRENT_ASSE │ │ │ -00063c80: 5254 286a 2d26 6774 3b73 746f 7261 6765 RT(j->storage │ │ │ -00063c90: 2d26 6774 3b6e 756d 5f6f 7574 7374 616e ->num_outstan │ │ │ -00063ca0: 6469 6e67 5f6a 6f62 7328 2920 3d3d 2031 ding_jobs() == 1 │ │ │ -00063cb0: 293b 0a09 666c 7573 685f 7374 6f72 6167 );..flush_storag │ │ │ -00063cc0: 6528 6a2d 2667 743b 7374 6f72 6167 6529 e(j->storage) │ │ │ -00063cd0: 3b0a 0961 6464 5f74 6f72 7265 6e74 5f70 ;..add_torrent_p │ │ │ -00063ce0: 6172 616d 7320 636f 6e73 742a 2072 6420 arams const* rd │ │ │ -00063cf0: 3d20 612e 7265 7375 6d65 5f64 6174 613b = a.resume_data; │ │ │ -00063d00: 0a09 6164 645f 746f 7272 656e 745f 7061 ..add_torrent_pa │ │ │ -00063d10: 7261 6d73 2074 6d70 3b0a 0969 6620 2872 rams tmp;..if (r │ │ │ -00063d20: 6420 3d3d 206e 756c 6c70 7472 2920 7264 d == nullptr) rd │ │ │ -00063d30: 203d 2026 616d 703b 746d 703b 0a0a 0973 = &tmp;...s │ │ │ -00063d40: 7464 3a3a 756e 6971 7565 5f70 7472 266c td::unique_ptr&l │ │ │ -00063d50: 743b 6175 783a 3a76 6563 746f 7226 6c74 t;aux::vector< │ │ │ -00063d60: 3b73 7464 3a3a 7374 7269 6e67 2c20 6669 ;std::string, fi │ │ │ -00063d70: 6c65 5f69 6e64 6578 5f74 2667 743b 2667 le_index_t>&g │ │ │ -00063d80: 743b 206c 696e 6b73 2861 2e6c 696e 6b73 t; links(a.links │ │ │ -00063d90: 293b 0a09 2f2f 2063 6865 636b 2069 6620 );..// check if │ │ │ -00063da0: 7468 6520 6661 7374 7265 7375 6d65 2064 the fastresume d │ │ │ -00063db0: 6174 6120 6973 2075 7020 746f 2064 6174 ata is up to dat │ │ │ -00063dc0: 650a 092f 2f20 6966 2069 7420 6973 2c20 e..// if it is, │ │ │ -00063dd0: 7573 6520 6974 2061 6e64 2072 6574 7572 use it and retur │ │ │ -00063de0: 6e20 7472 7565 2e20 4966 2069 740a 092f n true. If it../ │ │ │ -00063df0: 2f20 6973 6e27 7420 7265 7475 726e 2066 / isn't return f │ │ │ -00063e00: 616c 7365 2061 6e64 2074 6865 2066 756c alse and the ful │ │ │ -00063e10: 6c20 6368 6563 6b0a 092f 2f20 7769 6c6c l check..// will │ │ │ -00063e20: 2062 6520 7275 6e2e 2049 6620 7468 6520 be run. If the │ │ │ -00063e30: 6c69 6e6b 7320 706f 696e 7465 7220 6973 links pointer is │ │ │ -00063e40: 206e 6f6e 2d65 6d70 7479 2c20 6974 2068 non-empty, it h │ │ │ -00063e50: 6173 2074 6865 2073 616d 6520 6e75 6d62 as the same numb │ │ │ -00063e60: 6572 0a09 2f2f 206f 6620 656c 656d 656e er..// of elemen │ │ │ -00063e70: 7473 2061 7320 7468 6572 6520 6172 6520 ts as there are │ │ │ -00063e80: 6669 6c65 732e 2045 6163 6820 656c 656d files. Each elem │ │ │ -00063e90: 656e 7420 6973 2065 6974 6865 7220 656d ent is either em │ │ │ -00063ea0: 7074 7920 6f72 2063 6f6e 7461 696e 730a pty or contains. │ │ │ -00063eb0: 092f 2f20 7468 6520 6162 736f 6c75 7465 .// the absolute │ │ │ -00063ec0: 2070 6174 6820 746f 2061 2066 696c 6520 path to a file │ │ │ -00063ed0: 6964 656e 7469 6361 6c20 746f 2074 6865 identical to the │ │ │ -00063ee0: 2063 6f72 7265 7370 6f6e 6469 6e67 2066 corresponding f │ │ │ -00063ef0: 696c 6520 696e 2074 6869 730a 092f 2f20 ile in this..// │ │ │ -00063f00: 746f 7272 656e 742e 2054 6865 2073 746f torrent. The sto │ │ │ -00063f10: 7261 6765 206d 7573 7420 6372 6561 7465 rage must create │ │ │ -00063f20: 2068 6172 6420 6c69 6e6b 7320 286f 7220 hard links (or │ │ │ -00063f30: 636f 7079 2920 7468 6f73 6520 6669 6c65 copy) those file │ │ │ -00063f40: 732e 2049 660a 092f 2f20 616e 7920 6669 s. If..// any fi │ │ │ -00063f50: 6c65 2064 6f65 7320 6e6f 7420 6578 6973 le does not exis │ │ │ -00063f60: 7420 6f72 2069 7320 696e 6163 6365 7373 t or is inaccess │ │ │ -00063f70: 6962 6c65 2c20 7468 6520 6469 736b 206a ible, the disk j │ │ │ -00063f80: 6f62 206d 7573 7420 6661 696c 2e0a 0a09 ob must fail.... │ │ │ -00063f90: 544f 5252 454e 545f 4153 5345 5254 286a TORRENT_ASSERT(j │ │ │ -00063fa0: 2d26 6774 3b73 746f 7261 6765 2d26 6774 ->storage-> │ │ │ -00063fb0: 3b66 696c 6573 2829 2e70 6965 6365 5f6c ;files().piece_l │ │ │ -00063fc0: 656e 6774 6828 2920 2667 743b 2030 293b ength() > 0); │ │ │ -00063fd0: 0a0a 092f 2f20 616c 7761 7973 2069 6e69 ...// always ini │ │ │ -00063fe0: 7469 616c 697a 6520 7468 6520 7374 6f72 tialize the stor │ │ │ -00063ff0: 6167 650a 0961 7574 6f20 636f 6e73 7420 age..auto const │ │ │ -00064000: 7265 745f 666c 6167 203d 206a 2d26 6774 ret_flag = j-> │ │ │ -00064010: 3b73 746f 7261 6765 2d26 6774 3b69 6e69 ;storage->ini │ │ │ -00064020: 7469 616c 697a 6528 6d5f 7365 7474 696e tialize(m_settin │ │ │ -00064030: 6773 2c20 6a2d 2667 743b 6572 726f 7229 gs, j->error) │ │ │ -00064040: 3b0a 0969 6620 286a 2d26 6774 3b65 7272 ;..if (j->err │ │ │ -00064050: 6f72 2920 7265 7475 726e 2064 6973 6b5f or) return disk_ │ │ │ -00064060: 7374 6174 7573 3a3a 6661 7461 6c5f 6469 status::fatal_di │ │ │ -00064070: 736b 5f65 7272 6f72 207c 2072 6574 5f66 sk_error | ret_f │ │ │ -00064080: 6c61 673b 0a0a 3c2f 7072 653e 3c2f 7464 lag;..
    relevance │ │ │ -000640c0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -000640d0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/torrent. │ │ │ -00064100: 6370 703a 3231 3232 3c2f 613e 3c2f 7464 cpp:2122this could │ │ │ -00064120: 6265 206f 7074 696d 697a 6564 2062 7920 be optimized by │ │ │ -00064130: 6c6f 6f6b 696e 6720 7570 2077 6869 6368 looking up which │ │ │ -00064140: 2066 696c 6573 2061 7265 2063 6f6d 706c files are compl │ │ │ -00064150: 6574 6520 616e 6420 6a75 7374 206c 6f6f ete and just loo │ │ │ -00064160: 6b20 6174 2074 686f 7365 3c2f 7464 3e3c k at those< │ │ │ -00064170: 2f74 723e 3c74 7220 6964 3d22 3232 3922 /tr>

    this cou │ │ │ -000641c0: 6c64 2062 6520 6f70 7469 6d69 7a65 6420 ld be optimized │ │ │ -000641d0: 6279 206c 6f6f 6b69 6e67 2075 7020 7768 by looking up wh │ │ │ -000641e0: 6963 6820 6669 6c65 7320 6172 650a 636f ich files are.co │ │ │ -000641f0: 6d70 6c65 7465 2061 6e64 206a 7573 7420 mplete and just │ │ │ -00064200: 6c6f 6f6b 2061 7420 7468 6f73 653c 2f68 look at those

    ../src/tor │ │ │ -00064220: 7265 6e74 2e63 7070 3a32 3132 323c 2f68 rent.cpp:2122
    //..
    │ │ │ -00064270: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ -00064280: 2870 6963 6b65 7228 292e 6861 7665 5f70  (picker().have_p
    │ │ │ -00064290: 6965 6365 2869 2929 3b0a 0909 0909 7765  iece(i));.....we
    │ │ │ -000642a0: 5f68 6176 6528 6929 3b0a 0909 097d 0a09  _have(i);....}..
    │ │ │ -000642b0: 097d 0a0a 0909 7365 745f 7374 6174 6528  .}....set_state(
    │ │ │ -000642c0: 746f 7272 656e 745f 7374 6174 7573 3a3a  torrent_status::
    │ │ │ -000642d0: 6368 6563 6b69 6e67 5f72 6573 756d 655f  checking_resume_
    │ │ │ -000642e0: 6461 7461 293b 0a0a 0909 6175 783a 3a76  data);....aux::v
    │ │ │ -000642f0: 6563 746f 7226 6c74 3b73 7464 3a3a 7374  ector<std::st
    │ │ │ -00064300: 7269 6e67 2c20 6669 6c65 5f69 6e64 6578  ring, file_index
    │ │ │ -00064310: 5f74 2667 743b 206c 696e 6b73 3b0a 2369  _t> links;.#i
    │ │ │ -00064320: 666e 6465 6620 544f 5252 454e 545f 4449  fndef TORRENT_DI
    │ │ │ -00064330: 5341 424c 455f 4d55 5441 424c 455f 544f  SABLE_MUTABLE_TO
    │ │ │ -00064340: 5252 454e 5453 0a09 0969 6620 2821 6d5f  RRENTS...if (!m_
    │ │ │ -00064350: 746f 7272 656e 745f 6669 6c65 2d26 6774  torrent_file->
    │ │ │ -00064360: 3b73 696d 696c 6172 5f74 6f72 7265 6e74  ;similar_torrent
    │ │ │ -00064370: 7328 292e 656d 7074 7928 290a 0909 097c  s().empty()....|
    │ │ │ -00064380: 7c20 216d 5f74 6f72 7265 6e74 5f66 696c  | !m_torrent_fil
    │ │ │ -00064390: 652d 2667 743b 636f 6c6c 6563 7469 6f6e  e->collection
    │ │ │ -000643a0: 7328 292e 656d 7074 7928 2929 0a09 097b  s().empty())...{
    │ │ │ -000643b0: 0a09 0909 7265 736f 6c76 655f 6c69 6e6b  ....resolve_link
    │ │ │ -000643c0: 7320 7265 7328 6d5f 746f 7272 656e 745f  s res(m_torrent_
    │ │ │ -000643d0: 6669 6c65 293b 0a0a 0909 0966 6f72 2028  file);.....for (
    │ │ │ -000643e0: 6175 746f 2063 6f6e 7374 2661 6d70 3b20  auto const& 
    │ │ │ -000643f0: 6968 203a 206d 5f74 6f72 7265 6e74 5f66  ih : m_torrent_f
    │ │ │ -00064400: 696c 652d 2667 743b 7369 6d69 6c61 725f  ile->similar_
    │ │ │ -00064410: 746f 7272 656e 7473 2829 290a 0909 097b  torrents())....{
    │ │ │ -00064420: 0a09 0909 0973 7464 3a3a 7368 6172 6564  .....std::shared
    │ │ │ -00064430: 5f70 7472 266c 743b 746f 7272 656e 7426  _ptr<torrent&
    │ │ │ -00064440: 6774 3b20 7420 3d20 6d5f 7365 732e 6669  gt; t = m_ses.fi
    │ │ │ -00064450: 6e64 5f74 6f72 7265 6e74 2869 6e66 6f5f  nd_torrent(info_
    │ │ │ -00064460: 6861 7368 5f74 2869 6829 292e 6c6f 636b  hash_t(ih)).lock
    │ │ │ -00064470: 2829 3b0a 0909 0909 6966 2028 2174 2920  ();.....if (!t) 
    │ │ │ -00064480: 636f 6e74 696e 7565 3b0a 0a09 0909 092f  continue;....../
    │ │ │ -00064490: 2f20 4f6e 6c79 2061 7474 656d 7074 2074  / Only attempt t
    │ │ │ -000644a0: 6f20 7265 7573 6520 6669 6c65 7320 6672  o reuse files fr
    │ │ │ -000644b0: 6f6d 2074 6f72 7265 6e74 7320 7468 6174  om torrents that
    │ │ │ -000644c0: 2061 7265 2073 6565 6469 6e67 2e0a 3c64   are seeding......
    │ │ │ -00064500: 6966 2028 2174 2d26 6774 3b69 735f 7365  if (!t->is_se
    │ │ │ -00064510: 6564 2829 2920 636f 6e74 696e 7565 3b0a  ed()) continue;.
    │ │ │ -00064520: 3c2f 6469 763e 0a09 0909 0961 7574 6f20  .....auto 
    │ │ │ -00064530: 7469 203d 2074 2d26 6774 3b67 6574 5f74  ti = t->get_t
    │ │ │ -00064540: 6f72 7265 6e74 5f66 696c 6528 293b 0a09  orrent_file();..
    │ │ │ -00064550: 0909 0972 6573 2e6d 6174 6368 282a 7469  ...res.match(*ti
    │ │ │ -00064560: 2c20 6669 6c65 6e61 6d65 7328 7469 2d26  , filenames(ti-&
    │ │ │ -00064570: 6774 3b6c 6179 6f75 7428 292c 2074 2d26  gt;layout(), t-&
    │ │ │ -00064580: 6774 3b6d 5f72 656e 616d 6564 5f66 696c  gt;m_renamed_fil
    │ │ │ -00064590: 6573 292c 2074 2d26 6774 3b73 6176 655f  es), t->save_
    │ │ │ -000645a0: 7061 7468 2829 293b 0a09 0909 7d0a 0909  path());....}...
    │ │ │ -000645b0: 0966 6f72 2028 6175 746f 2063 6f6e 7374  .for (auto const
    │ │ │ -000645c0: 2661 6d70 3b20 6320 3a20 6d5f 746f 7272  & c : m_torr
    │ │ │ -000645d0: 656e 745f 6669 6c65 2d26 6774 3b63 6f6c  ent_file->col
    │ │ │ -000645e0: 6c65 6374 696f 6e73 2829 290a 0909 097b  lections())....{
    │ │ │ -000645f0: 0a09 0909 0973 7464 3a3a 7665 6374 6f72  .....std::vector
    │ │ │ -00064600: 266c 743b 7374 643a 3a73 6861 7265 645f  <std::shared_
    │ │ │ -00064610: 7074 7226 6c74 3b74 6f72 7265 6e74 2667  ptr<torrent&g
    │ │ │ -00064620: 743b 2667 743b 2074 7320 3d20 6d5f 7365  t;> ts = m_se
    │ │ │ -00064630: 732e 6669 6e64 5f63 6f6c 6c65 6374 696f  s.find_collectio
    │ │ │ -00064640: 6e28 6329 3b0a 0a09 0909 0966 6f72 2028  n(c);......for (
    │ │ │ -00064650: 6175 746f 2063 6f6e 7374 2661 6d70 3b20  auto const& 
    │ │ │ -00064660: 7420 3a20 7473 290a 0909 0909 7b0a 0909  t : ts).....{...
    │ │ │ -00064670: 0909 092f 2f20 4f6e 6c79 2061 7474 656d  ...// Only attem
    │ │ │ -00064680: 7074 2074 6f20 7265 7573 6520 6669 6c65  pt to reuse file
    │ │ │ -00064690: 7320 6672 6f6d 2074 6f72 7265 6e74 7320  s from torrents 
    │ │ │ -000646a0: 7468 6174 2061 7265 2073 6565 6469 6e67  that are seeding
    │ │ │ -000646b0: 2e0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74  ..
    < │ │ │ -000646e0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -000646f0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00064720: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ -00064730: 3231 3336 3c2f 613e 3c2f 7464 3e3c 7464 2136this could be o │ │ │ -00064750: 7074 696d 697a 6564 2062 7920 6c6f 6f6b ptimized by look │ │ │ -00064760: 696e 6720 7570 2077 6869 6368 2066 696c ing up which fil │ │ │ -00064770: 6573 2061 7265 2063 6f6d 706c 6574 6520 es are complete │ │ │ -00064780: 616e 6420 6a75 7374 206c 6f6f 6b20 6174 and just look at │ │ │ -00064790: 2074 686f 7365 3c2f 7464 3e3c 2f74 723e those │ │ │ -000647a0: 3c74 7220 6964 3d22 3233 3022 2073 7479 │ │ │ -000647d0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -000647e0: 3c68 323e 7468 6973 2063 6f75 6c64 2062

    this could b │ │ │ -000647f0: 6520 6f70 7469 6d69 7a65 6420 6279 206c e optimized by l │ │ │ -00064800: 6f6f 6b69 6e67 2075 7020 7768 6963 6820 ooking up which │ │ │ -00064810: 6669 6c65 7320 6172 650a 636f 6d70 6c65 files are.comple │ │ │ -00064820: 7465 2061 6e64 206a 7573 7420 6c6f 6f6b te and just look │ │ │ -00064830: 2061 7420 7468 6f73 653c 2f68 323e 3c68 at those

    ../src/torrent │ │ │ -00064850: 2e63 7070 3a32 3133 363c 2f68 343e 3c70 .cpp:2136

    ...resol │ │ │ -000648a0: 7665 5f6c 696e 6b73 2072 6573 286d 5f74 ve_links res(m_t │ │ │ -000648b0: 6f72 7265 6e74 5f66 696c 6529 3b0a 0a09 orrent_file);... │ │ │ -000648c0: 0909 666f 7220 2861 7574 6f20 636f 6e73 ..for (auto cons │ │ │ -000648d0: 7426 616d 703b 2069 6820 3a20 6d5f 746f t& ih : m_to │ │ │ -000648e0: 7272 656e 745f 6669 6c65 2d26 6774 3b73 rrent_file->s │ │ │ -000648f0: 696d 696c 6172 5f74 6f72 7265 6e74 7328 imilar_torrents( │ │ │ -00064900: 2929 0a09 0909 7b0a 0909 0909 7374 643a ))....{.....std: │ │ │ -00064910: 3a73 6861 7265 645f 7074 7226 6c74 3b74 :shared_ptr<t │ │ │ -00064920: 6f72 7265 6e74 2667 743b 2074 203d 206d orrent> t = m │ │ │ -00064930: 5f73 6573 2e66 696e 645f 746f 7272 656e _ses.find_torren │ │ │ -00064940: 7428 696e 666f 5f68 6173 685f 7428 6968 t(info_hash_t(ih │ │ │ -00064950: 2929 2e6c 6f63 6b28 293b 0a09 0909 0969 )).lock();.....i │ │ │ -00064960: 6620 2821 7429 2063 6f6e 7469 6e75 653b f (!t) continue; │ │ │ -00064970: 0a0a 0909 0909 2f2f 204f 6e6c 7920 6174 ......// Only at │ │ │ -00064980: 7465 6d70 7420 746f 2072 6575 7365 2066 tempt to reuse f │ │ │ -00064990: 696c 6573 2066 726f 6d20 746f 7272 656e iles from torren │ │ │ -000649a0: 7473 2074 6861 7420 6172 6520 7365 6564 ts that are seed │ │ │ -000649b0: 696e 672e 0a09 0909 0969 6620 2821 742d ing......if (!t- │ │ │ -000649c0: 2667 743b 6973 5f73 6565 6428 2929 2063 >is_seed()) c │ │ │ -000649d0: 6f6e 7469 6e75 653b 0a0a 0909 0909 6175 ontinue;......au │ │ │ -000649e0: 746f 2074 6920 3d20 742d 2667 743b 6765 to ti = t->ge │ │ │ -000649f0: 745f 746f 7272 656e 745f 6669 6c65 2829 t_torrent_file() │ │ │ -00064a00: 3b0a 0909 0909 7265 732e 6d61 7463 6828 ;.....res.match( │ │ │ -00064a10: 2a74 692c 2066 696c 656e 616d 6573 2874 *ti, filenames(t │ │ │ -00064a20: 692d 2667 743b 6c61 796f 7574 2829 2c20 i->layout(), │ │ │ -00064a30: 742d 2667 743b 6d5f 7265 6e61 6d65 645f t->m_renamed_ │ │ │ -00064a40: 6669 6c65 7329 2c20 742d 2667 743b 7361 files), t->sa │ │ │ -00064a50: 7665 5f70 6174 6828 2929 3b0a 0909 097d ve_path());....} │ │ │ -00064a60: 0a09 0909 666f 7220 2861 7574 6f20 636f ....for (auto co │ │ │ -00064a70: 6e73 7426 616d 703b 2063 203a 206d 5f74 nst& c : m_t │ │ │ -00064a80: 6f72 7265 6e74 5f66 696c 652d 2667 743b orrent_file-> │ │ │ -00064a90: 636f 6c6c 6563 7469 6f6e 7328 2929 0a09 collections()).. │ │ │ -00064aa0: 0909 7b0a 0909 0909 7374 643a 3a76 6563 ..{.....std::vec │ │ │ -00064ab0: 746f 7226 6c74 3b73 7464 3a3a 7368 6172 tor<std::shar │ │ │ -00064ac0: 6564 5f70 7472 266c 743b 746f 7272 656e ed_ptr<torren │ │ │ -00064ad0: 7426 6774 3b26 6774 3b20 7473 203d 206d t>> ts = m │ │ │ -00064ae0: 5f73 6573 2e66 696e 645f 636f 6c6c 6563 _ses.find_collec │ │ │ -00064af0: 7469 6f6e 2863 293b 0a0a 0909 0909 666f tion(c);......fo │ │ │ -00064b00: 7220 2861 7574 6f20 636f 6e73 7426 616d r (auto const&am │ │ │ -00064b10: 703b 2074 203a 2074 7329 0a09 0909 097b p; t : ts).....{ │ │ │ -00064b20: 0a09 0909 0909 2f2f 204f 6e6c 7920 6174 ......// Only at │ │ │ -00064b30: 7465 6d70 7420 746f 2072 6575 7365 2066 tempt to reuse f │ │ │ -00064b40: 696c 6573 2066 726f 6d20 746f 7272 656e iles from torren │ │ │ -00064b50: 7473 2074 6861 7420 6172 6520 7365 6564 ts that are seed │ │ │ -00064b60: 696e 672e 0a3c 6469 7620 7374 796c 653d ing..

    .....if (!t-& │ │ │ -00064ba0: 6774 3b69 735f 7365 6564 2829 2920 636f gt;is_seed()) co │ │ │ -00064bb0: 6e74 696e 7565 3b0a 3c2f 6469 763e 0a09 ntinue;.
    .. │ │ │ -00064bc0: 0909 0909 6175 746f 2074 6920 3d20 742d ....auto ti = t- │ │ │ -00064bd0: 2667 743b 6765 745f 746f 7272 656e 745f >get_torrent_ │ │ │ -00064be0: 6669 6c65 2829 3b0a 0909 0909 0972 6573 file();......res │ │ │ -00064bf0: 2e6d 6174 6368 282a 7469 2c20 6669 6c65 .match(*ti, file │ │ │ -00064c00: 6e61 6d65 7328 7469 2d26 6774 3b6c 6179 names(ti->lay │ │ │ -00064c10: 6f75 7428 292c 2074 2d26 6774 3b6d 5f72 out(), t->m_r │ │ │ -00064c20: 656e 616d 6564 5f66 696c 6573 292c 2074 enamed_files), t │ │ │ -00064c30: 2d26 6774 3b73 6176 655f 7061 7468 2829 ->save_path() │ │ │ -00064c40: 293b 0a09 0909 097d 0a09 0909 7d0a 0a09 );.....}....}... │ │ │ -00064c50: 0909 6c69 6e6b 7320 3d20 7374 643a 3a6d ..links = std::m │ │ │ -00064c60: 6f76 6528 7265 7329 2e67 6574 5f6c 696e ove(res).get_lin │ │ │ -00064c70: 6b73 2829 3b0a 0909 7d0a 2365 6e64 6966 ks();...}.#endif │ │ │ -00064c80: 202f 2f20 544f 5252 454e 545f 4449 5341 // TORRENT_DISA │ │ │ -00064c90: 424c 455f 4d55 5441 424c 455f 544f 5252 BLE_MUTABLE_TORR │ │ │ -00064ca0: 454e 5453 0a0a 2369 6620 544f 5252 454e ENTS..#if TORREN │ │ │ -00064cb0: 545f 5553 455f 4153 5345 5254 530a 0909 T_USE_ASSERTS... │ │ │ -00064cc0: 544f 5252 454e 545f 4153 5345 5254 286d TORRENT_ASSERT(m │ │ │ -00064cd0: 5f6f 7574 7374 616e 6469 6e67 5f63 6865 _outstanding_che │ │ │ -00064ce0: 636b 5f66 696c 6573 203d 3d20 6661 6c73 ck_files == fals │ │ │ -00064cf0: 6529 3b0a 0909 6d5f 6f75 7473 7461 6e64 e);...m_outstand │ │ │ -00064d00: 696e 675f 6368 6563 6b5f 6669 6c65 7320 ing_check_files │ │ │ -00064d10: 3d20 7472 7565 3b0a 2365 6e64 6966 0a0a = true;.#endif.. │ │ │ -00064d20: 0909 6966 2028 216d 5f61 6464 5f74 6f72 ..if (!m_add_tor │ │ │ -00064d30: 7265 6e74 5f70 6172 616d 7320 7c7c 2021 rent_params || ! │ │ │ -00064d40: 286d 5f61 6464 5f74 6f72 7265 6e74 5f70 (m_add_torrent_p │ │ │ -00064d50: 6172 616d 732d 2667 743b 666c 6167 7320 arams->flags │ │ │ -00064d60: 2661 6d70 3b20 746f 7272 656e 745f 666c & torrent_fl │ │ │ -00064d70: 6167 733a 3a6e 6f5f 7665 7269 6679 5f66 ags::no_verify_f │ │ │ -00064d80: 696c 6573 2929 0a09 097b 0a09 0909 6d5f iles))...{....m_ │ │ │ -00064d90: 7365 732e 6469 736b 5f74 6872 6561 6428 ses.disk_thread( │ │ │ -00064da0: 292e 6173 796e 635f 6368 6563 6b5f 6669 ).async_check_fi │ │ │ -00064db0: 6c65 7328 0a09 0909 096d 5f73 746f 7261 les(.....m_stora │ │ │ -00064dc0: 6765 2c20 6d5f 6164 645f 746f 7272 656e ge, m_add_torren │ │ │ -00064dd0: 745f 7061 7261 6d73 203f 206d 5f61 6464 t_params ? m_add │ │ │ -00064de0: 5f74 6f72 7265 6e74 5f70 6172 616d 732e _torrent_params. │ │ │ -00064df0: 6765 7428 2920 3a20 6e75 6c6c 7074 720a get() : nullptr. │ │ │ -00064e00: 0909 0909 2c20 7374 643a 3a6d 6f76 6528 ...., std::move( │ │ │ -00064e10: 6c69 6e6b 7329 2c20 5b73 656c 6620 3d20 links), [self = │ │ │ -00064e20: 7368 6172 6564 5f66 726f 6d5f 7468 6973 shared_from_this │ │ │ -00064e30: 2829 5d28 7374 6174 7573 5f74 2073 742c ()](status_t st, │ │ │ -00064e40: 2073 746f 7261 6765 5f65 7272 6f72 2063 storage_error c │ │ │ -00064e50: 6f6e 7374 2661 6d70 3b20 6572 726f 7229 onst& error) │ │ │ -00064e60: 0a09 0909 097b 2073 656c 662d 2667 743b .....{ self-> │ │ │ -00064e70: 6f6e 5f72 6573 756d 655f 6461 7461 5f63 on_resume_data_c │ │ │ -00064e80: 6865 636b 6564 2873 742c 2065 7272 6f72 hecked(st, error │ │ │ -00064e90: 293b 207d 293b 0a23 6966 6e64 6566 2054 ); });.#ifndef T │ │ │ -00064ea0: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c ORRENT_DISABLE_L │ │ │ -00064eb0: 4f47 4749 4e47 0a09 0909 6465 6275 675f OGGING....debug_ │ │ │ -00064ec0: 6c6f 6728 2269 6e69 742c 2061 7379 6e63 log("init, async │ │ │ -00064ed0: 5f63 6865 636b 5f66 696c 6573 2229 3b0a _check_files");. │ │ │ -00064ee0: 2365 6e64 6966 0a09 0909 6d5f 7365 732e #endif....m_ses. │ │ │ -00064ef0: 6465 6665 7272 6564 5f73 7562 6d69 745f deferred_submit_ │ │ │ -00064f00: 6a6f 6273 2829 3b0a 0909 7d0a 0909 656c jobs();...}...el │ │ │ -00064f10: 7365 0a09 097b 0a09 0909 6f6e 5f72 6573 se...{....on_res │ │ │ -00064f20: 756d 655f 6461 7461 5f63 6865 636b 6564 ume_data_checked │ │ │ -00064f30: 287b 7d2c 2073 746f 7261 6765 5f65 7272 ({}, storage_err │ │ │ -00064f40: 6f72 7b7d 293b 0a09 097d 0a3c 2f70 7265 or{});...}.rele │ │ │ -00064f80: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/tor │ │ │ -00064fc0: 7265 6e74 2e63 7070 3a32 3934 353c 2f61 rent.cpp:2945this p │ │ │ -00064fe0: 6174 7465 726e 2069 7320 7265 7065 6174 attern is repeat │ │ │ -00064ff0: 6564 2069 6e20 6120 6665 7720 706c 6163 ed in a few plac │ │ │ -00065000: 6573 2e20 4661 6374 6f72 2074 6869 7320 es. Factor this │ │ │ -00065010: 696e 746f 2061 2066 756e 6374 696f 6e20 into a function │ │ │ -00065020: 616e 6420 6765 6e65 7261 6c69 7a65 2074 and generalize t │ │ │ -00065030: 6865 2063 6f6e 6365 7074 206f 6620 6120 he concept of a │ │ │ -00065040: 746f 7272 656e 7420 6861 7669 6e67 2061 torrent having a │ │ │ -00065050: 2064 6564 6963 6174 6564 206c 6973 7465 dedicated liste │ │ │ -00065060: 6e20 706f 7274 3c2f 7464 3e3c 2f74 723e n port │ │ │ -00065070: 3c74 7220 6964 3d22 3233 3122 2073 7479 │ │ │ -000650a0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -000650b0: 3c68 323e 7468 6973 2070 6174 7465 726e

    this pattern │ │ │ -000650c0: 2069 7320 7265 7065 6174 6564 2069 6e20 is repeated in │ │ │ -000650d0: 6120 6665 7720 706c 6163 6573 2e20 4661 a few places. Fa │ │ │ -000650e0: 6374 6f72 2074 6869 7320 696e 746f 0a61 ctor this into.a │ │ │ -000650f0: 2066 756e 6374 696f 6e20 616e 6420 6765 function and ge │ │ │ -00065100: 6e65 7261 6c69 7a65 2074 6865 2063 6f6e neralize the con │ │ │ -00065110: 6365 7074 206f 6620 6120 746f 7272 656e cept of a torren │ │ │ -00065120: 7420 6861 7669 6e67 2061 0a64 6564 6963 t having a.dedic │ │ │ -00065130: 6174 6564 206c 6973 7465 6e20 706f 7274 ated listen port │ │ │ -00065140: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -00065150: 746f 7272 656e 742e 6370 703a 3239 3435 torrent.cpp:2945 │ │ │ -00065160: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -000651a0: 092f 2f20 6e6f 7420 7265 6164 7920 666f  .// not ready fo
    │ │ │ -000651b0: 7220 7065 6572 732e 2045 7863 6570 742c  r peers. Except,
    │ │ │ -000651c0: 2069 6620 7765 2064 6f6e 2774 2068 6176   if we don't hav
    │ │ │ -000651d0: 6520 6d65 7461 6461 7461 2c0a 0909 2f2f  e metadata,...//
    │ │ │ -000651e0: 2077 6520 6e65 6564 2070 6565 7273 2074   we need peers t
    │ │ │ -000651f0: 6f20 646f 776e 6c6f 6164 2066 726f 6d0a  o download from.
    │ │ │ -00065200: 0909 6966 2028 216d 5f66 696c 6573 5f63  ..if (!m_files_c
    │ │ │ -00065210: 6865 636b 6564 2026 616d 703b 2661 6d70  hecked &&
    │ │ │ -00065220: 3b20 7661 6c69 645f 6d65 7461 6461 7461  ; valid_metadata
    │ │ │ -00065230: 2829 2920 7265 7475 726e 3b0a 0a09 0969  ()) return;....i
    │ │ │ -00065240: 6620 2821 6d5f 616e 6e6f 756e 6365 5f74  f (!m_announce_t
    │ │ │ -00065250: 6f5f 6c73 6429 2072 6574 7572 6e3b 0a0a  o_lsd) return;..
    │ │ │ -00065260: 0909 2f2f 2070 7269 7661 7465 2074 6f72  ..// private tor
    │ │ │ -00065270: 7265 6e74 7320 6172 6520 6e65 7665 7220  rents are never 
    │ │ │ -00065280: 616e 6e6f 756e 6365 6420 6f6e 204c 5344  announced on LSD
    │ │ │ -00065290: 0a09 0969 6620 286d 5f74 6f72 7265 6e74  ...if (m_torrent
    │ │ │ -000652a0: 5f66 696c 652d 2667 743b 6973 5f76 616c  _file->is_val
    │ │ │ -000652b0: 6964 2829 2026 616d 703b 2661 6d70 3b20  id() && 
    │ │ │ -000652c0: 6d5f 746f 7272 656e 745f 6669 6c65 2d26  m_torrent_file-&
    │ │ │ -000652d0: 6774 3b70 7269 7628 2929 2072 6574 7572  gt;priv()) retur
    │ │ │ -000652e0: 6e3b 0a0a 2369 6620 544f 5252 454e 545f  n;..#if TORRENT_
    │ │ │ -000652f0: 5553 455f 4932 500a 0909 2f2f 2069 3270  USE_I2P...// i2p
    │ │ │ -00065300: 2074 6f72 7265 6e74 7320 6172 6520 616c   torrents are al
    │ │ │ -00065310: 736f 206e 6576 6572 2061 6e6e 6f75 6e63  so never announc
    │ │ │ -00065320: 6564 206f 6e20 4c53 440a 0909 2f2f 2075  ed on LSD...// u
    │ │ │ -00065330: 6e6c 6573 7320 7765 2061 6c6c 6f77 206d  nless we allow m
    │ │ │ -00065340: 6978 6564 2073 7761 726d 730a 0909 6966  ixed swarms...if
    │ │ │ -00065350: 2028 6973 5f69 3270 2829 2026 616d 703b   (is_i2p() &
    │ │ │ -00065360: 2661 6d70 3b20 2173 6574 7469 6e67 7328  & !settings(
    │ │ │ -00065370: 292e 6765 745f 626f 6f6c 2873 6574 7469  ).get_bool(setti
    │ │ │ -00065380: 6e67 735f 7061 636b 3a3a 616c 6c6f 775f  ngs_pack::allow_
    │ │ │ -00065390: 6932 705f 6d69 7865 6429 290a 0909 0972  i2p_mixed))....r
    │ │ │ -000653a0: 6574 7572 6e3b 0a23 656e 6469 660a 0a09  eturn;.#endif...
    │ │ │ -000653b0: 0969 6620 2869 735f 7061 7573 6564 2829  .if (is_paused()
    │ │ │ -000653c0: 2920 7265 7475 726e 3b0a 0a09 0969 6620  ) return;....if 
    │ │ │ -000653d0: 2821 6d5f 7365 732e 6861 735f 6c73 6428  (!m_ses.has_lsd(
    │ │ │ -000653e0: 2929 2072 6574 7572 6e3b 0a0a 3c64 6976  )) return;..
    #ifdef │ │ │ -00065420: 2054 4f52 5245 4e54 5f53 534c 5f50 4545 TORRENT_SSL_PEE │ │ │ -00065430: 5253 0a3c 2f64 6976 3e09 0969 6e74 2070 RS.
    ..int p │ │ │ -00065440: 6f72 7420 3d20 6973 5f73 736c 5f74 6f72 ort = is_ssl_tor │ │ │ -00065450: 7265 6e74 2829 203f 206d 5f73 6573 2e73 rent() ? m_ses.s │ │ │ -00065460: 736c 5f6c 6973 7465 6e5f 706f 7274 2829 sl_listen_port() │ │ │ -00065470: 203a 206d 5f73 6573 2e6c 6973 7465 6e5f : m_ses.listen_ │ │ │ -00065480: 706f 7274 2829 3b0a 2365 6c73 650a 0909 port();.#else... │ │ │ -00065490: 696e 7420 706f 7274 203d 206d 5f73 6573 int port = m_ses │ │ │ -000654a0: 2e6c 6973 7465 6e5f 706f 7274 2829 3b0a .listen_port();. │ │ │ -000654b0: 2365 6e64 6966 0a0a 0909 2f2f 2061 6e6e #endif....// ann │ │ │ -000654c0: 6f75 6e63 6520 7769 7468 2074 6865 206c ounce with the l │ │ │ -000654d0: 6f63 616c 2064 6973 636f 7665 7279 2073 ocal discovery s │ │ │ -000654e0: 6572 7669 6365 0a09 096d 5f74 6f72 7265 ervice...m_torre │ │ │ -000654f0: 6e74 5f66 696c 652d 2667 743b 696e 666f nt_file->info │ │ │ -00065500: 5f68 6173 6865 7328 292e 666f 725f 6561 _hashes().for_ea │ │ │ -00065510: 6368 285b 2661 6d70 3b5d 2873 6861 315f ch([&](sha1_ │ │ │ -00065520: 6861 7368 2063 6f6e 7374 2661 6d70 3b20 hash const& │ │ │ -00065530: 6968 2c20 7072 6f74 6f63 6f6c 5f76 6572 ih, protocol_ver │ │ │ -00065540: 7369 6f6e 290a 0909 7b0a 0909 096d 5f73 sion)...{....m_s │ │ │ -00065550: 6573 2e61 6e6e 6f75 6e63 655f 6c73 6428 es.announce_lsd( │ │ │ -00065560: 6968 2c20 706f 7274 293b 0a09 097d 293b ih, port);...}); │ │ │ -00065570: 0a09 7d0a 0a23 6966 6e64 6566 2054 4f52 ..}..#ifndef TOR │ │ │ -00065580: 5245 4e54 5f44 4953 4142 4c45 5f44 4854 RENT_DISABLE_DHT │ │ │ -00065590: 0a0a 0976 6f69 6420 746f 7272 656e 743a ...void torrent: │ │ │ -000655a0: 3a64 6874 5f61 6e6e 6f75 6e63 6528 290a :dht_announce(). │ │ │ -000655b0: 097b 0a09 0954 4f52 5245 4e54 5f41 5353 .{...TORRENT_ASS │ │ │ -000655c0: 4552 5428 6973 5f73 696e 676c 655f 7468 ERT(is_single_th │ │ │ -000655d0: 7265 6164 2829 293b 0a09 0969 6620 2821 read());...if (! │ │ │ -000655e0: 6d5f 7365 732e 6468 7428 2929 0a09 097b m_ses.dht())...{ │ │ │ -000655f0: 0a23 6966 6e64 6566 2054 4f52 5245 4e54 .#ifndef TORRENT │ │ │ -00065600: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47 _DISABLE_LOGGING │ │ │ -00065610: 0a09 0909 6465 6275 675f 6c6f 6728 2244 ....debug_log("D │ │ │ -00065620: 4854 3a20 6e6f 2064 6874 2069 6e69 7469 HT: no dht initi │ │ │ -00065630: 616c 697a 6564 2229 3b0a 2365 6e64 6966 alized");.#endif │ │ │ -00065640: 0a09 0909 7265 7475 726e 3b0a 0909 7d0a ....return;...}. │ │ │ -00065650: 0909 6966 2028 2173 686f 756c 645f 616e ..if (!should_an │ │ │ -00065660: 6e6f 756e 6365 5f64 6874 2829 290a 0909 nounce_dht())... │ │ │ -00065670: 7b0a 2369 666e 6465 6620 544f 5252 454e {.#ifndef TORREN │ │ │ -00065680: 545f 4449 5341 424c 455f 4c4f 4747 494e T_DISABLE_LOGGIN │ │ │ -00065690: 470a 0909 0969 6620 2873 686f 756c 645f G....if (should_ │ │ │ -000656a0: 6c6f 6728 2929 0a09 0909 7b0a 2369 6620 log())....{.#if │ │ │ -000656b0: 544f 5252 454e 545f 5553 455f 4932 500a TORRENT_USE_I2P. │ │ │ -000656c0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -000656d0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00065700: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -00065730: 632f 746f 7272 656e 742e 6370 703a 3332 c/torrent.cpp:32 │ │ │ -00065740: 3930 3c2f 613e 3c2f 7464 3e3c 7464 3e69 90i │ │ │ -00065750: 7420 776f 756c 6420 6265 206e 6963 6520 t would be nice │ │ │ -00065760: 746f 2072 6169 7365 2074 6865 2061 6273 to raise the abs │ │ │ -00065770: 7472 6163 7469 6f6e 206c 6576 656c 206f traction level o │ │ │ -00065780: 6620 7468 6520 7472 6163 6b65 725f 6c69 f the tracker_li │ │ │ -00065790: 7374 206f 7220 7472 6163 6b65 7273 2061 st or trackers a │ │ │ -000657a0: 2062 6974 2068 6572 653c 2f74 643e 3c2f bit here

    it would │ │ │ -00065800: 6265 206e 6963 6520 746f 2072 6169 7365 be nice to raise │ │ │ -00065810: 2074 6865 2061 6273 7472 6163 7469 6f6e the abstraction │ │ │ -00065820: 206c 6576 656c 206f 6620 7468 650a 7472 level of the.tr │ │ │ -00065830: 6163 6b65 725f 6c69 7374 206f 7220 7472 acker_list or tr │ │ │ -00065840: 6163 6b65 7273 2061 2062 6974 2068 6572 ackers a bit her │ │ │ -00065850: 653c 2f68 323e 3c68 343e 2e2e 2f73 7263 e

    ../src │ │ │ -00065860: 2f74 6f72 7265 6e74 2e63 7070 3a33 3239 /torrent.cpp:329 │ │ │ -00065870: 303c 2f68 343e 3c70 7265 2073 7479 6c65 0

    │ │ │ -000658b0: 0909 7469 6d65 5f70 6f69 6e74 3332 2063  ..time_point32 c
    │ │ │ -000658c0: 6f6e 7374 206e 6f77 203d 2061 7578 3a3a  onst now = aux::
    │ │ │ -000658d0: 7469 6d65 5f6e 6f77 3332 2829 3b0a 0a09  time_now32();...
    │ │ │ -000658e0: 092f 2f20 6561 6368 206c 6973 7465 6e20  .// each listen 
    │ │ │ -000658f0: 736f 636b 6574 2067 6574 7320 6974 7320  socket gets its 
    │ │ │ -00065900: 6f77 6e20 616e 6e6f 756e 6365 2073 7461  own announce sta
    │ │ │ -00065910: 7465 0a09 092f 2f20 736f 2074 6861 7420  te...// so that 
    │ │ │ -00065920: 6561 6368 206f 6e65 2073 686f 756c 6420  each one should 
    │ │ │ -00065930: 6765 7420 6174 206c 6561 7374 206f 6e65  get at least one
    │ │ │ -00065940: 2061 6e6e 6f75 6e63 650a 0909 7374 643a   announce...std:
    │ │ │ -00065950: 3a76 6563 746f 7226 6c74 3b61 6e6e 6f75  :vector<annou
    │ │ │ -00065960: 6e63 655f 7374 6174 6526 6774 3b20 6c69  nce_state> li
    │ │ │ -00065970: 7374 656e 5f73 6f63 6b65 745f 7374 6174  sten_socket_stat
    │ │ │ -00065980: 6573 3b0a 0a09 0962 6f6f 6c20 636f 6e73  es;....bool cons
    │ │ │ -00065990: 7420 616e 6e6f 756e 6365 5f74 6f5f 616c  t announce_to_al
    │ │ │ -000659a0: 6c5f 7469 6572 7320 3d20 7365 7474 696e  l_tiers = settin
    │ │ │ -000659b0: 6773 2829 2e67 6574 5f62 6f6f 6c28 7365  gs().get_bool(se
    │ │ │ -000659c0: 7474 696e 6773 5f70 6163 6b3a 3a61 6e6e  ttings_pack::ann
    │ │ │ -000659d0: 6f75 6e63 655f 746f 5f61 6c6c 5f74 6965  ounce_to_all_tie
    │ │ │ -000659e0: 7273 293b 0a09 0962 6f6f 6c20 636f 6e73  rs);...bool cons
    │ │ │ -000659f0: 7420 616e 6e6f 756e 6365 5f74 6f5f 616c  t announce_to_al
    │ │ │ -00065a00: 6c5f 7472 6163 6b65 7273 203d 2073 6574  l_trackers = set
    │ │ │ -00065a10: 7469 6e67 7328 292e 6765 745f 626f 6f6c  tings().get_bool
    │ │ │ -00065a20: 2873 6574 7469 6e67 735f 7061 636b 3a3a  (settings_pack::
    │ │ │ -00065a30: 616e 6e6f 756e 6365 5f74 6f5f 616c 6c5f  announce_to_all_
    │ │ │ -00065a40: 7472 6163 6b65 7273 293b 0a23 6966 6e64  trackers);.#ifnd
    │ │ │ -00065a50: 6566 2054 4f52 5245 4e54 5f44 4953 4142  ef TORRENT_DISAB
    │ │ │ -00065a60: 4c45 5f4c 4f47 4749 4e47 0a09 0969 6e74  LE_LOGGING...int
    │ │ │ -00065a70: 2069 6478 203d 202d 313b 0a09 0969 6620   idx = -1;...if 
    │ │ │ -00065a80: 2873 686f 756c 645f 6c6f 6728 2929 0a09  (should_log())..
    │ │ │ -00065a90: 097b 0a09 0909 6465 6275 675f 6c6f 6728  .{....debug_log(
    │ │ │ -00065aa0: 222a 2a2a 2061 6e6e 6f75 6e63 653a 2022  "*** announce: "
    │ │ │ -00065ab0: 0a09 0909 0922 5b20 616e 6e6f 756e 6365  ....."[ announce
    │ │ │ -00065ac0: 5f74 6f5f 616c 6c5f 7469 6572 733a 2025  _to_all_tiers: %
    │ │ │ -00065ad0: 6420 616e 6e6f 756e 6365 5f74 6f5f 616c  d announce_to_al
    │ │ │ -00065ae0: 6c5f 7472 6163 6b65 7273 3a20 2564 206e  l_trackers: %d n
    │ │ │ -00065af0: 756d 5f74 7261 636b 6572 733a 2025 6420  um_trackers: %d 
    │ │ │ -00065b00: 5d22 0a09 0909 092c 2061 6e6e 6f75 6e63  ]"....., announc
    │ │ │ -00065b10: 655f 746f 5f61 6c6c 5f74 6965 7273 0a09  e_to_all_tiers..
    │ │ │ -00065b20: 0909 092c 2061 6e6e 6f75 6e63 655f 746f  ..., announce_to
    │ │ │ -00065b30: 5f61 6c6c 5f74 7261 636b 6572 730a 0909  _all_trackers...
    │ │ │ -00065b40: 0909 2c20 696e 7428 6d5f 7472 6163 6b65  .., int(m_tracke
    │ │ │ -00065b50: 7273 2e73 697a 6528 2929 293b 0a09 097d  rs.size()));...}
    │ │ │ -00065b60: 0a23 656e 6469 660a 0a3c 6469 7620 7374  .#endif..
    ..for (au │ │ │ -00065ba0: 746f 2661 6d70 3b20 6165 203a 206d 5f74 to& ae : m_t │ │ │ -00065bb0: 7261 636b 6572 7329 0a3c 2f64 6976 3e09 rackers).
    . │ │ │ -00065bc0: 097b 0a23 6966 6e64 6566 2054 4f52 5245 .{.#ifndef TORRE │ │ │ -00065bd0: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749 NT_DISABLE_LOGGI │ │ │ -00065be0: 4e47 0a09 0909 2b2b 6964 783b 0a23 656e NG....++idx;.#en │ │ │ -00065bf0: 6469 660a 0909 0972 6566 7265 7368 5f65 dif....refresh_e │ │ │ -00065c00: 6e64 706f 696e 745f 6c69 7374 286d 5f73 ndpoint_list(m_s │ │ │ -00065c10: 6573 2c20 6973 5f73 736c 5f74 6f72 7265 es, is_ssl_torre │ │ │ -00065c20: 6e74 2829 2c20 626f 6f6c 286d 5f63 6f6d nt(), bool(m_com │ │ │ -00065c30: 706c 6574 655f 7365 6e74 292c 2061 6529 plete_sent), ae) │ │ │ -00065c40: 3b0a 0a09 0909 2f2f 2069 6620 7472 6163 ;.....// if trac │ │ │ -00065c50: 6b65 7269 6420 6973 206e 6f74 2073 7065 kerid is not spe │ │ │ -00065c60: 6369 6669 6564 2066 6f72 2074 7261 636b cified for track │ │ │ -00065c70: 6572 2075 7365 2064 6566 6175 6c74 206f er use default o │ │ │ -00065c80: 6e65 2c20 7072 6f62 6162 6c79 2073 6574 ne, probably set │ │ │ -00065c90: 2065 7870 6c69 6369 746c 790a 0909 0972 explicitly....r │ │ │ -00065ca0: 6571 2e74 7261 636b 6572 6964 203d 2061 eq.trackerid = a │ │ │ -00065cb0: 652e 7472 6163 6b65 7269 642e 656d 7074 e.trackerid.empt │ │ │ -00065cc0: 7928 2920 3f20 6d5f 7472 6163 6b65 7269 y() ? m_trackeri │ │ │ -00065cd0: 6420 3a20 6165 2e74 7261 636b 6572 6964 d : ae.trackerid │ │ │ -00065ce0: 3b0a 0909 0972 6571 2e75 726c 203d 2061 ;....req.url = a │ │ │ -00065cf0: 652e 7572 6c3b 0a0a 2369 6620 544f 5252 e.url;..#if TORR │ │ │ -00065d00: 454e 545f 5553 455f 4932 500a 0909 092f ENT_USE_I2P..../ │ │ │ -00065d10: 2f20 6966 2077 6520 646f 6e27 7420 616c / if we don't al │ │ │ -00065d20: 6c6f 7720 6d69 7869 6e67 206e 6f72 6d61 low mixing norma │ │ │ -00065d30: 6c20 7065 6572 7320 696e 746f 2074 6869 l peers into thi │ │ │ -00065d40: 7320 6932 7020 746f 7272 656e 742c 0a09 s i2p torrent,.. │ │ │ -00065d50: 0909 2f2f 2073 6b69 7020 6e6f 6e2d 6932 ..// skip non-i2 │ │ │ -00065d60: 7020 7472 6163 6b65 7273 2e20 7570 6461 p trackers. upda │ │ │ -00065d70: 7465 5f74 7261 636b 6572 5f74 696d 6572 te_tracker_timer │ │ │ -00065d80: 2829 2061 7070 6c69 6573 2074 6865 0a09 () applies the.. │ │ │ -00065d90: 0909 2f2f 2073 616d 6520 736b 6970 2073 ..// same skip s │ │ │ -00065da0: 6f20 7468 6520 7469 6d65 7220 646f 6573 o the timer does │ │ │ -00065db0: 6e27 7420 6b65 6570 2066 6972 696e 6720 n't keep firing │ │ │ -00065dc0: 666f 7220 7472 6163 6b65 7273 2077 6527 for trackers we' │ │ │ -00065dd0: 6c6c 0a09 0909 2f2f 206e 6576 6572 2063 ll....// never c │ │ │ -00065de0: 6f6e 7461 6374 2e0a 0909 0969 6620 2821 ontact.....if (! │ │ │ -00065df0: 6932 705f 636f 6d70 6174 6962 6c65 5f74 i2p_compatible_t │ │ │ -00065e00: 7261 636b 6572 2861 6529 2920 636f 6e74 racker(ae)) cont │ │ │ -00065e10: 696e 7565 3b0a 0909 092f 2f20 7265 7120 inue;....// req │ │ │ -00065e20: 6973 2072 6575 7365 6420 6163 726f 7373 is reused across │ │ │ -00065e30: 2069 7465 7261 7469 6f6e 732c 2073 6f20 iterations, so │ │ │ -00065e40: 7365 7420 7468 6520 6932 7020 6269 7420 set the i2p bit │ │ │ -00065e50: 746f 206d 6174 6368 0a09 0909 2f2f 2074 to match....// t │ │ │ -00065e60: 6869 7320 7472 6163 6b65 7220 7261 7468 his tracker rath │ │ │ -00065e70: 6572 2074 6861 6e20 6f6e 6c79 2065 7665 er than only eve │ │ │ -00065e80: 7220 4f52 2d69 6e67 2069 7420 696e 2e0a r OR-ing it in.. │ │ │ -00065e90: 0909 0969 6620 2861 652e 6932 7029 0a09 ...if (ae.i2p).. │ │ │ -00065ea0: 0909 0972 6571 2e6b 696e 6420 7c3d 2074 ...req.kind |= t │ │ │ -00065eb0: 7261 636b 6572 5f72 6571 7565 7374 3a3a racker_request:: │ │ │ -00065ec0: 6932 703b 0a09 0909 656c 7365 0a09 0909 i2p;....else.... │ │ │ -00065ed0: 0972 6571 2e6b 696e 6420 2661 6d70 3b3d .req.kind &= │ │ │ -00065ee0: 207e 7472 6163 6b65 725f 7265 7175 6573 ~tracker_reques │ │ │ -00065ef0: 743a 3a69 3270 3b0a 2365 6e64 6966 0a0a t::i2p;.#endif.. │ │ │ -00065f00: 0909 0966 6f72 2028 6175 746f 2661 6d70 ...for (auto& │ │ │ -00065f10: 3b20 6165 7020 3a20 6165 2e65 6e64 706f ; aep : ae.endpo │ │ │ -00065f20: 696e 7473 290a 0909 097b 0a09 0909 092f ints)....{...../ │ │ │ -00065f30: 2f20 646f 206e 6f74 2061 6464 2063 6f64 / do not add cod │ │ │ -00065f40: 6520 7768 6963 6820 636f 6e74 696e 7565 e which continue │ │ │ -00065f50: 7320 746f 2074 6865 206e 6578 7420 656e s to the next en │ │ │ -00065f60: 6470 6f69 6e74 2068 6572 6521 0a09 0909 dpoint here!.... │ │ │ -00065f70: 092f 2f20 6c69 7374 656e 5f73 6f63 6b65 .// listen_socke │ │ │ -00065f80: 745f 7374 6174 6573 206e 6565 6473 2074 t_states needs t │ │ │ -00065f90: 6f20 6265 2070 6f70 756c 6174 6564 2065 o be populated e │ │ │ -00065fa0: 7665 6e20 6966 206e 6f6e 6520 6f66 2074 ven if none of t │ │ │ -00065fb0: 6865 2065 6e64 706f 696e 7473 0a09 0909 he endpoints.... │ │ │ -00065fc0: 092f 2f20 7769 6c6c 2062 6520 616e 6e6f .// will be anno │ │ │ -00065fd0: 756e 6369 6e67 2066 6f72 2074 6869 7320 uncing for this │ │ │ -00065fe0: 7472 6163 6b65 720a 0909 0909 2f2f 206f tracker.....// o │ │ │ -00065ff0: 7468 6572 7769 7365 2074 6865 2065 6172 therwise the ear │ │ │ -00066000: 6c79 2062 6169 6c20 6f75 7420 7768 656e ly bail out when │ │ │ -00066010: 206e 6569 7468 6572 2061 6e6e 6f75 6e63 neither announc │ │ │ -00066020: 655f 746f 5f61 6c6c 5f74 7261 636b 6572 e_to_all_tracker │ │ │ -00066030: 730a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 s.
    < │ │ │ -00066060: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00066070: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -000660a0: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ -000660b0: 3338 3234 3c2f 613e 3c2f 7464 3e3c 7464 3824move this into │ │ │ -000660d0: 6120 6675 6e63 7469 6f6e 206f 6e20 7472 a function on tr │ │ │ -000660e0: 6163 6b65 725f 6c69 7374 3c2f 7464 3e3c acker_list< │ │ │ -000660f0: 2f74 723e 3c74 7220 6964 3d22 3233 3322 /tr>

    move thi │ │ │ -00066140: 7320 696e 746f 2061 2066 756e 6374 696f s into a functio │ │ │ -00066150: 6e20 6f6e 2074 7261 636b 6572 5f6c 6973 n on tracker_lis │ │ │ -00066160: 743c 2f68 323e 3c68 343e 2e2e 2f73 7263 t

    ../src │ │ │ -00066170: 2f74 6f72 7265 6e74 2e63 7070 3a33 3832 /torrent.cpp:382 │ │ │ -00066180: 343c 2f68 343e 3c70 7265 2073 7479 6c65 4

    │ │ │ -000661c0: 0909 2c20 7374 7275 6374 2074 7261 636b  .., struct track
    │ │ │ -000661d0: 6572 5f72 6573 706f 6e73 6520 636f 6e73  er_response cons
    │ │ │ -000661e0: 7426 616d 703b 2072 6573 7029 0a09 7b0a  t& resp)..{.
    │ │ │ -000661f0: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ -00066200: 2869 735f 7369 6e67 6c65 5f74 6872 6561  (is_single_threa
    │ │ │ -00066210: 6428 2929 3b0a 0a09 0949 4e56 4152 4941  d());....INVARIA
    │ │ │ -00066220: 4e54 5f43 4845 434b 3b0a 0909 544f 5252  NT_CHECK;...TORR
    │ │ │ -00066230: 454e 545f 4153 5345 5254 2821 2872 2e6b  ENT_ASSERT(!(r.k
    │ │ │ -00066240: 696e 6420 2661 6d70 3b20 7472 6163 6b65  ind & tracke
    │ │ │ -00066250: 725f 7265 7175 6573 743a 3a73 6372 6170  r_request::scrap
    │ │ │ -00066260: 655f 7265 7175 6573 7429 293b 0a0a 0909  e_request));....
    │ │ │ -00066270: 2f2f 2069 6620 7468 6520 7472 6163 6b65  // if the tracke
    │ │ │ -00066280: 7220 746f 6c64 2075 7320 7768 6174 206f  r told us what o
    │ │ │ -00066290: 7572 2065 7874 6572 6e61 6c20 4950 2061  ur external IP a
    │ │ │ -000662a0: 6464 7265 7373 2069 732c 2072 6563 6f72  ddress is, recor
    │ │ │ -000662b0: 6420 6974 2077 6974 680a 0909 2f2f 206f  d it with...// o
    │ │ │ -000662c0: 7574 2065 7874 6572 6e61 6c20 4950 2063  ut external IP c
    │ │ │ -000662d0: 6f75 6e74 6572 2028 616e 6420 7061 7373  ounter (and pass
    │ │ │ -000662e0: 2061 6c6f 6e67 2074 6865 2049 5020 6f66   along the IP of
    │ │ │ -000662f0: 2074 6865 2074 7261 636b 6572 2074 6f20   the tracker to 
    │ │ │ -00066300: 6b6e 6f77 0a09 092f 2f20 7768 6f20 746f  know...// who to
    │ │ │ -00066310: 2061 7474 7269 6275 7465 2074 6869 7320   attribute this 
    │ │ │ -00066320: 766f 7465 2074 6f29 0a09 0969 6620 2872  vote to)...if (r
    │ │ │ -00066330: 6573 702e 6578 7465 726e 616c 5f69 7020  esp.external_ip 
    │ │ │ -00066340: 213d 2061 6464 7265 7373 2829 2026 616d  != address() &am
    │ │ │ -00066350: 703b 2661 6d70 3b20 2174 7261 636b 6572  p;& !tracker
    │ │ │ -00066360: 5f69 702e 6973 5f75 6e73 7065 6369 6669  _ip.is_unspecifi
    │ │ │ -00066370: 6564 2829 2026 616d 703b 2661 6d70 3b20  ed() && 
    │ │ │ -00066380: 722e 6f75 7467 6f69 6e67 5f73 6f63 6b65  r.outgoing_socke
    │ │ │ -00066390: 7429 0a09 0909 6d5f 7365 732e 7365 745f  t)....m_ses.set_
    │ │ │ -000663a0: 6578 7465 726e 616c 5f61 6464 7265 7373  external_address
    │ │ │ -000663b0: 2872 2e6f 7574 676f 696e 675f 736f 636b  (r.outgoing_sock
    │ │ │ -000663c0: 6574 2e67 6574 5f6c 6f63 616c 5f65 6e64  et.get_local_end
    │ │ │ -000663d0: 706f 696e 7428 290a 0909 0909 2c20 7265  point()....., re
    │ │ │ -000663e0: 7370 2e65 7874 6572 6e61 6c5f 6970 0a09  sp.external_ip..
    │ │ │ -000663f0: 0909 092c 2061 7578 3a3a 7365 7373 696f  ..., aux::sessio
    │ │ │ -00066400: 6e5f 696e 7465 7266 6163 653a 3a73 6f75  n_interface::sou
    │ │ │ -00066410: 7263 655f 7472 6163 6b65 722c 2074 7261  rce_tracker, tra
    │ │ │ -00066420: 636b 6572 5f69 7029 3b0a 0a09 0974 696d  cker_ip);....tim
    │ │ │ -00066430: 655f 706f 696e 7433 3220 636f 6e73 7420  e_point32 const 
    │ │ │ -00066440: 6e6f 7720 3d20 6175 783a 3a74 696d 655f  now = aux::time_
    │ │ │ -00066450: 6e6f 7733 3228 293b 0a0a 0909 7072 6f74  now32();....prot
    │ │ │ -00066460: 6f63 6f6c 5f76 6572 7369 6f6e 2063 6f6e  ocol_version con
    │ │ │ -00066470: 7374 2076 203d 2072 2e69 6e66 6f5f 6861  st v = r.info_ha
    │ │ │ -00066480: 7368 203d 3d20 746f 7272 656e 745f 6669  sh == torrent_fi
    │ │ │ -00066490: 6c65 2829 2e69 6e66 6f5f 6861 7368 6573  le().info_hashes
    │ │ │ -000664a0: 2829 2e76 310a 0909 093f 2070 726f 746f  ().v1....? proto
    │ │ │ -000664b0: 636f 6c5f 7665 7273 696f 6e3a 3a56 3120  col_version::V1 
    │ │ │ -000664c0: 3a20 7072 6f74 6f63 6f6c 5f76 6572 7369  : protocol_versi
    │ │ │ -000664d0: 6f6e 3a3a 5632 3b0a 0a3c 6469 7620 7374  on::V2;..
    ..aux::an │ │ │ -00066510: 6e6f 756e 6365 5f65 6e74 7279 2a20 6165 nounce_entry* ae │ │ │ -00066520: 203d 206d 5f74 7261 636b 6572 732e 6669 = m_trackers.fi │ │ │ -00066530: 6e64 5f74 7261 636b 6572 2872 2e75 726c nd_tracker(r.url │ │ │ -00066540: 293b 0a3c 2f64 6976 3e0a 0909 7463 703a );.
    ...tcp: │ │ │ -00066550: 3a65 6e64 706f 696e 7420 6c6f 6361 6c5f :endpoint local_ │ │ │ -00066560: 656e 6470 6f69 6e74 3b0a 0909 6966 2028 endpoint;...if ( │ │ │ -00066570: 6165 290a 0909 7b0a 0909 0961 7574 6f2a ae)...{....auto* │ │ │ -00066580: 2061 6570 203d 2061 652d 2667 743b 6669 aep = ae->fi │ │ │ -00066590: 6e64 5f65 6e64 706f 696e 7428 722e 6f75 nd_endpoint(r.ou │ │ │ -000665a0: 7467 6f69 6e67 5f73 6f63 6b65 7429 3b0a tgoing_socket);. │ │ │ -000665b0: 0909 0969 6620 2861 6570 290a 0909 097b ...if (aep)....{ │ │ │ -000665c0: 0a09 0909 0961 7574 6f26 616d 703b 2061 .....auto& a │ │ │ -000665d0: 203d 2061 6570 2d26 6774 3b69 6e66 6f5f = aep->info_ │ │ │ -000665e0: 6861 7368 6573 5b76 5d3b 0a0a 0909 0909 hashes[v];...... │ │ │ -000665f0: 6c6f 6361 6c5f 656e 6470 6f69 6e74 203d local_endpoint = │ │ │ -00066600: 2061 6570 2d26 6774 3b6c 6f63 616c 5f65 aep->local_e │ │ │ -00066610: 6e64 706f 696e 743b 0a09 0909 0969 6620 ndpoint;.....if │ │ │ -00066620: 2872 6573 702e 696e 636f 6d70 6c65 7465 (resp.incomplete │ │ │ -00066630: 2026 6774 3b3d 2030 2920 612e 7363 7261 >= 0) a.scra │ │ │ -00066640: 7065 5f69 6e63 6f6d 706c 6574 6520 3d20 pe_incomplete = │ │ │ -00066650: 7265 7370 2e69 6e63 6f6d 706c 6574 653b resp.incomplete; │ │ │ -00066660: 0a09 0909 0969 6620 2872 6573 702e 636f .....if (resp.co │ │ │ -00066670: 6d70 6c65 7465 2026 6774 3b3d 2030 2920 mplete >= 0) │ │ │ -00066680: 612e 7363 7261 7065 5f63 6f6d 706c 6574 a.scrape_complet │ │ │ -00066690: 6520 3d20 7265 7370 2e63 6f6d 706c 6574 e = resp.complet │ │ │ -000666a0: 653b 0a09 0909 0969 6620 2872 6573 702e e;.....if (resp. │ │ │ -000666b0: 646f 776e 6c6f 6164 6564 2026 6774 3b3d downloaded >= │ │ │ -000666c0: 2030 2920 612e 7363 7261 7065 5f64 6f77 0) a.scrape_dow │ │ │ -000666d0: 6e6c 6f61 6465 6420 3d20 7265 7370 2e64 nloaded = resp.d │ │ │ -000666e0: 6f77 6e6c 6f61 6465 643b 0a09 0909 0969 ownloaded;.....i │ │ │ -000666f0: 6620 2821 612e 7374 6172 745f 7365 6e74 f (!a.start_sent │ │ │ -00066700: 2026 616d 703b 2661 6d70 3b20 722e 6576 && r.ev │ │ │ -00066710: 656e 7420 3d3d 2065 7665 6e74 5f74 3a3a ent == event_t:: │ │ │ -00066720: 7374 6172 7465 6429 0a09 0909 0909 612e started)......a. │ │ │ -00066730: 7374 6172 745f 7365 6e74 203d 2074 7275 start_sent = tru │ │ │ -00066740: 653b 0a09 0909 0969 6620 2821 612e 636f e;.....if (!a.co │ │ │ -00066750: 6d70 6c65 7465 5f73 656e 7420 2661 6d70 mplete_sent & │ │ │ -00066760: 3b26 616d 703b 2072 2e65 7665 6e74 203d ;& r.event = │ │ │ -00066770: 3d20 6576 656e 745f 743a 3a63 6f6d 706c = event_t::compl │ │ │ -00066780: 6574 6564 290a 0909 0909 7b0a 0909 0909 eted).....{..... │ │ │ -00066790: 0961 2e63 6f6d 706c 6574 655f 7365 6e74 .a.complete_sent │ │ │ -000667a0: 203d 2074 7275 653b 0a09 0909 0909 2f2f = true;......// │ │ │ -000667b0: 2077 6520 7375 6363 6573 7366 756c 6c79 we successfully │ │ │ -000667c0: 2072 6570 6f72 7465 6420 6576 656e 743d reported event= │ │ │ -000667d0: 636f 6d70 6c65 7465 6420 746f 206f 6e65 completed to one │ │ │ -000667e0: 2074 7261 636b 6572 2e20 446f 6e27 740a tracker. Don't. │ │ │ -000667f0: 0909 0909 092f 2f20 7365 6e64 2069 7420 .....// send it │ │ │ -00066800: 746f 2061 6e79 206f 7468 6572 206f 6e65 to any other one │ │ │ -00066810: 7320 6672 6f6d 206e 6f77 206f 6e20 2874 s from now on (t │ │ │ -00066820: 6865 7265 206d 6179 2062 6520 6f74 6865 here may be othe │ │ │ -00066830: 720a 0909 0909 092f 2f20 616e 6e6f 756e r......// announ │ │ │ -00066840: 6365 7320 6f75 7473 7461 6e64 696e 6720 ces outstanding │ │ │ -00066850: 7269 6768 7420 6e6f 7720 7468 6f75 6768 right now though │ │ │ -00066860: 290a 0909 0909 096d 5f63 6f6d 706c 6574 )......m_complet │ │ │ -00066870: 655f 7365 6e74 203d 2074 7275 653b 0a09 e_sent = true;.. │ │ │ -00066880: 0909 097d 0a09 0909 0961 652d 2667 743b ...}.....ae-> │ │ │ -00066890: 7665 7269 6669 6564 203d 2074 7275 653b verified = true; │ │ │ -000668a0: 0a09 0909 0961 2e6e 6578 745f 616e 6e6f .....a.next_anno │ │ │ -000668b0: 756e 6365 203d 206e 6f77 202b 2072 6573 unce = now + res │ │ │ -000668c0: 702e 696e 7465 7276 616c 3b0a 0909 0909 p.interval;..... │ │ │ -000668d0: 612e 6d69 6e5f 616e 6e6f 756e 6365 203d a.min_announce = │ │ │ -000668e0: 206e 6f77 202b 2072 6573 702e 6d69 6e5f now + resp.min_ │ │ │ -000668f0: 696e 7465 7276 616c 3b0a 0909 0909 612e interval;.....a. │ │ │ -00066900: 7570 6461 7469 6e67 203d 2066 616c 7365 updating = false │ │ │ -00066910: 3b0a 0909 0909 612e 6661 696c 7320 3d20 ;.....a.fails = │ │ │ -00066920: 303b 0a09 0909 0961 2e6c 6173 745f 6572 0;.....a.last_er │ │ │ -00066930: 726f 722e 636c 6561 7228 293b 0a09 0909 ror.clear();.... │ │ │ -00066940: 0961 2e6d 6573 7361 6765 203d 2021 7265 .a.message = !re │ │ │ -00066950: 7370 2e77 6172 6e69 6e67 5f6d 6573 7361 sp.warning_messa │ │ │ -00066960: 6765 2e65 6d70 7479 2829 203f 2072 6573 ge.empty() ? res │ │ │ -00066970: 702e 7761 726e 696e 675f 6d65 7373 6167 p.warning_messag │ │ │ -00066980: 6520 3a20 7374 643a 3a73 7472 696e 6728 e : std::string( │ │ │ -00066990: 293b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f );.
    │ │ │ -000669c0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ -000669d0: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ -00066a00: 2f73 7263 2f74 6f72 7265 6e74 2e63 7070 /src/torrent.cpp │ │ │ -00066a10: 3a33 3931 383c 2f61 3e3c 2f74 643e 3c74 :3918the destinatio │ │ │ -00066a30: 6e20 7374 7269 6e67 2073 686f 756c 6420 n string should │ │ │ -00066a40: 6265 2062 6173 6536 3420 6465 636f 6465 be base64 decode │ │ │ -00066a50: 6420 616e 6420 7368 6132 3536 2068 6173 d and sha256 has │ │ │ -00066a60: 6865 6420 746f 2066 6f72 6d20 7468 6520 hed to form the │ │ │ -00066a70: 6465 7374 696e 6174 696f 6e20 6164 6472 destination addr │ │ │ -00066a80: 6573 7320 616e 6420 7374 6f72 6520 7468 ess and store th │ │ │ -00066a90: 6174 2069 6e20 7468 6520 6932 705f 7065 at in the i2p_pe │ │ │ -00066aa0: 6572 206f 626a 6563 7420 6469 7265 6374 er object direct │ │ │ -00066ab0: 6c79 3c2f 7464 3e3c 2f74 723e 3c74 7220 ly

    │ │ │ -00066b00: 7468 6520 6465 7374 696e 6174 696f 6e20 the destination │ │ │ -00066b10: 7374 7269 6e67 2073 686f 756c 6420 6265 string should be │ │ │ -00066b20: 2062 6173 6536 3420 6465 636f 6465 6420 base64 decoded │ │ │ -00066b30: 616e 640a 7368 6132 3536 2068 6173 6865 and.sha256 hashe │ │ │ -00066b40: 6420 746f 2066 6f72 6d20 7468 6520 6465 d to form the de │ │ │ -00066b50: 7374 696e 6174 696f 6e20 6164 6472 6573 stination addres │ │ │ -00066b60: 7320 616e 6420 7374 6f72 650a 7468 6174 s and store.that │ │ │ -00066b70: 2069 6e20 7468 6520 6932 705f 7065 6572 in the i2p_peer │ │ │ -00066b80: 206f 626a 6563 7420 6469 7265 6374 6c79 object directly │ │ │ -00066b90: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -00066ba0: 746f 7272 656e 742e 6370 703a 3339 3138 torrent.cpp:3918 │ │ │ -00066bb0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00066bf0: 0966 6f72 2028 6175 746f 2063 6f6e 7374  .for (auto const
    │ │ │ -00066c00: 2661 6d70 3b20 6920 3a20 7265 7370 2e70  & i : resp.p
    │ │ │ -00066c10: 6565 7273 290a 0909 7b0a 0909 092f 2f20  eers)...{....// 
    │ │ │ -00066c20: 646f 6e27 7420 6d61 6b65 2063 6f6e 6e65  don't make conne
    │ │ │ -00066c30: 6374 696f 6e73 2074 6f20 6f75 7273 656c  ctions to oursel
    │ │ │ -00066c40: 660a 0909 0969 6620 2869 2e70 6964 203d  f....if (i.pid =
    │ │ │ -00066c50: 3d20 6d5f 7065 6572 5f69 6429 0a09 0909  = m_peer_id)....
    │ │ │ -00066c60: 0963 6f6e 7469 6e75 653b 0a0a 2369 6620  .continue;..#if 
    │ │ │ -00066c70: 544f 5252 454e 545f 5553 455f 4932 500a  TORRENT_USE_I2P.
    │ │ │ -00066c80: 0909 0969 6620 2872 2e69 3270 636f 6e6e  ...if (r.i2pconn
    │ │ │ -00066c90: 290a 0909 097b 0a09 0909 092f 2f20 7468  )....{.....// th
    │ │ │ -00066ca0: 6973 2069 7320 616e 2069 3270 206e 616d  is is an i2p nam
    │ │ │ -00066cb0: 652c 2077 6520 6e65 6564 2074 6f20 7573  e, we need to us
    │ │ │ -00066cc0: 6520 7468 6520 5341 4d20 636f 6e6e 6563  e the SAM connec
    │ │ │ -00066cd0: 7469 6f6e 0a09 0909 092f 2f20 746f 2064  tion.....// to d
    │ │ │ -00066ce0: 6f20 7468 6520 6e61 6d65 206c 6f6f 6b75  o the name looku
    │ │ │ -00066cf0: 700a 0909 0909 6966 2028 7374 7269 6e67  p.....if (string
    │ │ │ -00066d00: 5f65 6e64 735f 7769 7468 2869 2e68 6f73  _ends_with(i.hos
    │ │ │ -00066d10: 746e 616d 652c 2022 2e69 3270 2229 290a  tname, ".i2p")).
    │ │ │ -00066d20: 0909 0909 7b0a 0909 0909 0941 4444 5f4f  ....{......ADD_O
    │ │ │ -00066d30: 5554 5354 414e 4449 4e47 5f41 5359 4e43  UTSTANDING_ASYNC
    │ │ │ -00066d40: 2822 746f 7272 656e 743a 3a6f 6e5f 6932  ("torrent::on_i2
    │ │ │ -00066d50: 705f 7265 736f 6c76 6522 293b 0a09 0909  p_resolve");....
    │ │ │ -00066d60: 0909 722e 6932 7063 6f6e 6e2d 2667 743b  ..r.i2pconn->
    │ │ │ -00066d70: 6173 796e 635f 6e61 6d65 5f6c 6f6f 6b75  async_name_looku
    │ │ │ -00066d80: 7028 692e 686f 7374 6e61 6d65 2e63 5f73  p(i.hostname.c_s
    │ │ │ -00066d90: 7472 2829 0a09 0909 0909 092c 205b 7365  tr()......., [se
    │ │ │ -00066da0: 6c66 203d 2073 6861 7265 645f 6672 6f6d  lf = shared_from
    │ │ │ -00066db0: 5f74 6869 7328 295d 2028 6572 726f 725f  _this()] (error_
    │ │ │ -00066dc0: 636f 6465 2063 6f6e 7374 2661 6d70 3b20  code const& 
    │ │ │ -00066dd0: 6563 2c20 6368 6172 2063 6f6e 7374 2a20  ec, char const* 
    │ │ │ -00066de0: 6465 7374 290a 0909 0909 0909 7b20 7365  dest).......{ se
    │ │ │ -00066df0: 6c66 2d26 6774 3b74 6f72 7265 6e74 3a3a  lf->torrent::
    │ │ │ -00066e00: 6f6e 5f69 3270 5f72 6573 6f6c 7665 2865  on_i2p_resolve(e
    │ │ │ -00066e10: 632c 2064 6573 742c 2070 6565 725f 696e  c, dest, peer_in
    │ │ │ -00066e20: 666f 3a3a 7472 6163 6b65 7229 3b20 7d29  fo::tracker); })
    │ │ │ -00066e30: 3b0a 0909 0909 7d0a 0909 0909 656c 7365  ;.....}.....else
    │ │ │ -00066e40: 0a09 0909 097b 0a3c 6469 7620 7374 796c  .....{.
    .....torren │ │ │ -00066e80: 745f 7374 6174 6520 7374 203d 2067 6574 t_state st = get │ │ │ -00066e90: 5f70 6565 725f 6c69 7374 5f73 7461 7465 _peer_list_state │ │ │ -00066ea0: 2829 3b0a 3c2f 6469 763e 0909 0909 096e ();.
    .....n │ │ │ -00066eb0: 6565 645f 7065 6572 5f6c 6973 7428 293b eed_peer_list(); │ │ │ -00066ec0: 0a09 0909 0909 6966 2028 6d5f 7065 6572 ......if (m_peer │ │ │ -00066ed0: 5f6c 6973 742d 2667 743b 6164 645f 6932 _list->add_i2 │ │ │ -00066ee0: 705f 7065 6572 2869 2e68 6f73 746e 616d p_peer(i.hostnam │ │ │ -00066ef0: 652c 2070 6565 725f 696e 666f 3a3a 7472 e, peer_info::tr │ │ │ -00066f00: 6163 6b65 722c 207b 7d2c 2026 616d 703b acker, {}, & │ │ │ -00066f10: 7374 2929 0a09 0909 0909 0973 7461 7465 st)).......state │ │ │ -00066f20: 5f75 7064 6174 6564 2829 3b0a 0909 0909 _updated();..... │ │ │ -00066f30: 0970 6565 7273 5f65 7261 7365 6428 7374 .peers_erased(st │ │ │ -00066f40: 2e65 7261 7365 6429 3b0a 0909 0909 7d0a .erased);.....}. │ │ │ -00066f50: 0909 097d 0a09 0909 656c 7365 0a23 656e ...}....else.#en │ │ │ -00066f60: 6469 660a 0909 097b 0a09 0909 092f 2f20 dif....{.....// │ │ │ -00066f70: 7468 6572 6527 7320 6e6f 206d 6563 6861 there's no mecha │ │ │ -00066f80: 6e69 736d 2074 6f20 636f 6e6e 6563 7420 nism to connect │ │ │ -00066f90: 746f 2061 2070 6565 7220 6279 2068 6f73 to a peer by hos │ │ │ -00066fa0: 746e 616d 6520 7468 726f 7567 680a 0909 tname through... │ │ │ -00066fb0: 0909 2f2f 2061 2070 726f 7879 2c20 736f ..// a proxy, so │ │ │ -00066fc0: 2077 6974 6820 7072 6f78 795f 686f 7374 with proxy_host │ │ │ -00066fd0: 6e61 6d65 7320 7365 742c 2064 726f 7020 names set, drop │ │ │ -00066fe0: 686f 7374 6e61 6d65 6420 7065 6572 730a hostnamed peers. │ │ │ -00066ff0: 0909 0909 2f2f 2069 6e73 7465 6164 206f ....// instead o │ │ │ -00067000: 6620 6c65 616b 696e 6720 7468 656d 2074 f leaking them t │ │ │ -00067010: 6f20 7468 6520 7265 6775 6c61 7220 7265 o the regular re │ │ │ -00067020: 736f 6c76 6572 2e20 6120 6c69 7465 7261 solver. a litera │ │ │ -00067030: 6c20 4950 0a09 0909 092f 2f20 6164 6472 l IP.....// addr │ │ │ -00067040: 6573 7320 696e 2069 2e68 6f73 746e 616d ess in i.hostnam │ │ │ -00067050: 6520 6973 6e27 7420 6120 6c65 616b 2c20 e isn't a leak, │ │ │ -00067060: 7369 6e63 6520 6e6f 2072 6561 6c20 7265 since no real re │ │ │ -00067070: 736f 6c75 7469 6f6e 0a09 0909 092f 2f20 solution.....// │ │ │ -00067080: 6861 7070 656e 732e 2074 6869 7320 6f6e happens. this on │ │ │ -00067090: 6c79 206d 6174 7465 7273 2077 6865 6e20 ly matters when │ │ │ -000670a0: 7065 6572 2063 6f6e 6e65 6374 696f 6e73 peer connections │ │ │ -000670b0: 2061 7265 2061 6374 7561 6c6c 790a 0909 are actually... │ │ │ -000670c0: 0909 2f2f 2070 726f 7869 6564 2c20 736f ..// proxied, so │ │ │ -000670d0: 2077 6974 6820 6e6f 2070 726f 7879 2063 with no proxy c │ │ │ -000670e0: 6f6e 6669 6775 7265 6420 286f 7220 6f6e onfigured (or on │ │ │ -000670f0: 6520 7468 6174 2064 6f65 736e 2774 0a09 e that doesn't.. │ │ │ -00067100: 0909 092f 2f20 7072 6f78 7920 7065 6572 ...// proxy peer │ │ │ -00067110: 2063 6f6e 6e65 6374 696f 6e73 2920 7265 connections) re │ │ │ -00067120: 736f 6c76 6520 6e6f 726d 616c 6c79 0a09 solve normally.. │ │ │ -00067130: 0909 0961 7578 3a3a 7072 6f78 795f 7365 ...aux::proxy_se │ │ │ -00067140: 7474 696e 6773 2063 6f6e 7374 2661 6d70 ttings const& │ │ │ -00067150: 3b20 7073 203d 206d 5f73 6573 2e70 726f ; ps = m_ses.pro │ │ │ -00067160: 7879 2829 3b0a 0909 0909 6966 2028 2173 xy();.....if (!s │ │ │ -00067170: 6574 7469 6e67 7328 292e 6765 745f 626f ettings().get_bo │ │ │ -00067180: 6f6c 2873 6574 7469 6e67 735f 7061 636b ol(settings_pack │ │ │ -00067190: 3a3a 7072 6f78 795f 686f 7374 6e61 6d65 ::proxy_hostname │ │ │ -000671a0: 7329 0a09 0909 0909 7c7c 2061 7578 3a3a s)......|| aux:: │ │ │ -000671b0: 6973 5f69 705f 6164 6472 6573 7328 692e is_ip_address(i. │ │ │ -000671c0: 686f 7374 6e61 6d65 2920 7c7c 2070 732e hostname) || ps. │ │ │ -000671d0: 7479 7065 203d 3d20 7365 7474 696e 6773 type == settings │ │ │ -000671e0: 5f70 6163 6b3a 3a6e 6f6e 650a 0909 0909 _pack::none..... │ │ │ -000671f0: 097c 7c20 2170 732e 7072 6f78 795f 7065 .|| !ps.proxy_pe │ │ │ -00067200: 6572 5f63 6f6e 6e65 6374 696f 6e73 290a er_connections). │ │ │ -00067210: 0909 0909 7b0a 0909 0909 0941 4444 5f4f ....{......ADD_O │ │ │ -00067220: 5554 5354 414e 4449 4e47 5f41 5359 4e43 UTSTANDING_ASYNC │ │ │ -00067230: 2822 746f 7272 656e 743a 3a6f 6e5f 7065 ("torrent::on_pe │ │ │ -00067240: 6572 5f6e 616d 655f 6c6f 6f6b 7570 2229 er_name_lookup") │ │ │ -00067250: 3b0a 0909 0909 096d 5f73 6573 2e67 6574 ;......m_ses.get │ │ │ -00067260: 5f72 6573 6f6c 7665 7228 292e 6173 796e _resolver().asyn │ │ │ -00067270: 635f 7265 736f 6c76 6528 692e 686f 7374 c_resolve(i.host │ │ │ -00067280: 6e61 6d65 2c0a 0909 0909 0909 6175 783a name,.......aux: │ │ │ -00067290: 3a72 6573 6f6c 7665 725f 696e 7465 7266 :resolver_interf │ │ │ -000672a0: 6163 653a 3a61 626f 7274 5f6f 6e5f 7368 ace::abort_on_sh │ │ │ -000672b0: 7574 646f 776e 2c0a 0909 0909 0909 7374 utdown,.......st │ │ │ -000672c0: 643a 3a62 696e 6428 0a09 0909 0909 0909 d::bind(........ │ │ │ -000672d0: 2661 6d70 3b74 6f72 7265 6e74 3a3a 6f6e &torrent::on │ │ │ -000672e0: 5f70 6565 725f 6e61 6d65 5f6c 6f6f 6b75 _peer_name_looku │ │ │ -000672f0: 702c 2073 6861 7265 645f 6672 6f6d 5f74 p, shared_from_t │ │ │ -00067300: 6869 7328 292c 205f 312c 205f 322c 2069 his(), _1, _2, i │ │ │ -00067310: 2e70 6f72 742c 2076 2929 3b0a 0909 0909 .port, v));..... │ │ │ -00067320: 7d0a 0909 097d 0a09 097d 0a0a 3c2f 7072 }....}...}..rel │ │ │ -00067360: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/to │ │ │ -000673a0: 7272 656e 742e 6370 703a 3432 3537 3c2f rrent.cpp:4257store │ │ │ -000673c0: 2069 3270 2061 6464 7265 7373 6573 2061 i2p addresses a │ │ │ -000673d0: 7320 6120 3332 2062 7974 6520 7368 6132 s a 32 byte sha2 │ │ │ -000673e0: 3536 2068 6173 6820 696e 2074 6865 2069 56 hash in the i │ │ │ -000673f0: 3270 5f70 6565 7220 6f62 6a65 6374 2c20 2p_peer object, │ │ │ -00067400: 7261 7468 6572 2074 6861 6e20 7265 736f rather than reso │ │ │ -00067410: 6c76 696e 6720 6974 2069 6e74 6f20 7468 lving it into th │ │ │ -00067420: 6520 6675 6c6c 2076 6173 6536 3420 6465 e full vase64 de │ │ │ -00067430: 7374 696e 6174 696f 6e2e 2057 6520 7368 stination. We sh │ │ │ -00067440: 6f75 6c64 206b 6565 7020 7468 6520 6675 ould keep the fu │ │ │ -00067450: 6c6c 2064 6573 7469 6e61 7469 6f6e 2061 ll destination a │ │ │ -00067460: 7320 6120 6361 6368 6520 696e 2074 6865 s a cache in the │ │ │ -00067470: 2069 3270 5f70 6565 7220 6f62 6a65 6374 i2p_peer object │ │ │ -00067480: 2073 7469 6c6c 2e3c 2f74 643e 3c2f 7472 still.

    store i2p a │ │ │ -000674e0: 6464 7265 7373 6573 2061 7320 6120 3332 ddresses as a 32 │ │ │ -000674f0: 2062 7974 6520 7368 6132 3536 2068 6173 byte sha256 has │ │ │ -00067500: 6820 696e 2074 6865 0a69 3270 5f70 6565 h in the.i2p_pee │ │ │ -00067510: 7220 6f62 6a65 6374 2c20 7261 7468 6572 r object, rather │ │ │ -00067520: 2074 6861 6e20 7265 736f 6c76 696e 6720 than resolving │ │ │ -00067530: 6974 2069 6e74 6f20 7468 6520 6675 6c6c it into the full │ │ │ -00067540: 2076 6173 6536 340a 6465 7374 696e 6174 vase64.destinat │ │ │ -00067550: 696f 6e2e 2057 6520 7368 6f75 6c64 206b ion. We should k │ │ │ -00067560: 6565 7020 7468 6520 6675 6c6c 2064 6573 eep the full des │ │ │ -00067570: 7469 6e61 7469 6f6e 2061 7320 6120 6361 tination as a ca │ │ │ -00067580: 6368 6520 696e 2074 6865 0a69 3270 5f70 che in the.i2p_p │ │ │ -00067590: 6565 7220 6f62 6a65 6374 2073 7469 6c6c eer object still │ │ │ -000675a0: 2e3c 2f68 323e 3c68 343e 2e2e 2f73 7263 .

    ../src │ │ │ -000675b0: 2f74 6f72 7265 6e74 2e63 7070 3a34 3235 /torrent.cpp:425 │ │ │ -000675c0: 373c 2f68 343e 3c70 7265 2073 7479 6c65 7

    │ │ │ -00067600: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ -00067610: 4449 5341 424c 455f 4c4f 4747 494e 470a  DISABLE_LOGGING.
    │ │ │ -00067620: 0909 656c 7365 0a09 097b 0a09 0909 6465  ..else...{....de
    │ │ │ -00067630: 6275 675f 6c6f 6728 222a 2a2a 2066 6f75  bug_log("*** fou
    │ │ │ -00067640: 6e64 206e 6f20 7472 6163 6b65 7220 656e  nd no tracker en
    │ │ │ -00067650: 6470 6f69 6e74 7320 746f 2061 6e6e 6f75  dpoints to annou
    │ │ │ -00067660: 6e63 6522 293b 0a09 097d 0a23 656e 6469  nce");...}.#endi
    │ │ │ -00067670: 660a 097d 0a0a 2369 6620 544f 5252 454e  f..}..#if TORREN
    │ │ │ -00067680: 545f 4142 495f 5645 5253 494f 4e20 3d3d  T_ABI_VERSION ==
    │ │ │ -00067690: 2031 0a09 766f 6964 2074 6f72 7265 6e74   1..void torrent
    │ │ │ -000676a0: 3a3a 7365 745f 7472 6163 6b65 725f 6c6f  ::set_tracker_lo
    │ │ │ -000676b0: 6769 6e28 7374 643a 3a73 7472 696e 6720  gin(std::string 
    │ │ │ -000676c0: 636f 6e73 7426 616d 703b 206e 616d 650a  const& name.
    │ │ │ -000676d0: 0909 2c20 7374 643a 3a73 7472 696e 6720  .., std::string 
    │ │ │ -000676e0: 636f 6e73 7426 616d 703b 2070 7729 0a09  const& pw)..
    │ │ │ -000676f0: 7b0a 0909 6d5f 7573 6572 6e61 6d65 203d  {...m_username =
    │ │ │ -00067700: 206e 616d 653b 0a09 096d 5f70 6173 7377   name;...m_passw
    │ │ │ -00067710: 6f72 6420 3d20 7077 3b0a 097d 0a23 656e  ord = pw;..}.#en
    │ │ │ -00067720: 6469 660a 0a23 6966 2054 4f52 5245 4e54  dif..#if TORRENT
    │ │ │ -00067730: 5f55 5345 5f49 3250 0a09 766f 6964 2074  _USE_I2P..void t
    │ │ │ -00067740: 6f72 7265 6e74 3a3a 6164 645f 6932 705f  orrent::add_i2p_
    │ │ │ -00067750: 7065 6572 2873 6861 3235 365f 6861 7368  peer(sha256_hash
    │ │ │ -00067760: 2063 6f6e 7374 2661 6d70 3b20 6465 7374   const& dest
    │ │ │ -00067770: 2c20 7065 6572 5f73 6f75 7263 655f 666c  , peer_source_fl
    │ │ │ -00067780: 6167 735f 7420 636f 6e73 7420 736f 7572  ags_t const sour
    │ │ │ -00067790: 6365 290a 097b 0a3c 6469 7620 7374 796c  ce)..{.
    ..i2p_conne │ │ │ -000677d0: 6374 696f 6e26 616d 703b 2069 3270 636f ction& i2pco │ │ │ -000677e0: 6e6e 203d 2073 6573 7369 6f6e 2829 2e69 nn = session().i │ │ │ -000677f0: 3270 5f63 6f6e 6e28 293b 0a3c 2f64 6976 2p_conn();.
    ..if (!i2pconn. │ │ │ -00067810: 6973 5f6f 7065 6e28 2929 2072 6574 7572 is_open()) retur │ │ │ -00067820: 6e3b 0a0a 0909 7374 643a 3a73 7472 696e n;....std::strin │ │ │ -00067830: 6720 6465 7374 696e 6174 696f 6e20 3d20 g destination = │ │ │ -00067840: 6261 7365 3332 656e 636f 6465 5f69 3270 base32encode_i2p │ │ │ -00067850: 2864 6573 7429 3b0a 0909 6465 7374 696e (dest);...destin │ │ │ -00067860: 6174 696f 6e20 2b3d 2022 2e62 3332 2e69 ation += ".b32.i │ │ │ -00067870: 3270 223b 0a0a 0909 4144 445f 4f55 5453 2p";....ADD_OUTS │ │ │ -00067880: 5441 4e44 494e 475f 4153 594e 4328 2274 TANDING_ASYNC("t │ │ │ -00067890: 6f72 7265 6e74 3a3a 6f6e 5f69 3270 5f72 orrent::on_i2p_r │ │ │ -000678a0: 6573 6f6c 7665 2229 3b0a 0909 6932 7063 esolve");...i2pc │ │ │ -000678b0: 6f6e 6e2e 6173 796e 635f 6e61 6d65 5f6c onn.async_name_l │ │ │ -000678c0: 6f6f 6b75 7028 6465 7374 696e 6174 696f ookup(destinatio │ │ │ -000678d0: 6e2e 635f 7374 7228 290a 0909 092c 205b n.c_str()...., [ │ │ │ -000678e0: 7365 6c66 203d 2073 6861 7265 645f 6672 self = shared_fr │ │ │ -000678f0: 6f6d 5f74 6869 7328 292c 2073 6f75 7263 om_this(), sourc │ │ │ -00067900: 655d 2028 6572 726f 725f 636f 6465 2063 e] (error_code c │ │ │ -00067910: 6f6e 7374 2661 6d70 3b20 6563 2c20 6368 onst& ec, ch │ │ │ -00067920: 6172 2063 6f6e 7374 2a20 6429 0a09 0909 ar const* d).... │ │ │ -00067930: 7b20 7365 6c66 2d26 6774 3b74 6f72 7265 { self->torre │ │ │ -00067940: 6e74 3a3a 6f6e 5f69 3270 5f72 6573 6f6c nt::on_i2p_resol │ │ │ -00067950: 7665 2865 632c 2064 2c20 736f 7572 6365 ve(ec, d, source │ │ │ -00067960: 293b 207d 293b 0a09 7d0a 0a09 766f 6964 ); });..}...void │ │ │ -00067970: 2074 6f72 7265 6e74 3a3a 6f6e 5f69 3270 torrent::on_i2p │ │ │ -00067980: 5f72 6573 6f6c 7665 2865 7272 6f72 5f63 _resolve(error_c │ │ │ -00067990: 6f64 6520 636f 6e73 7426 616d 703b 2065 ode const& e │ │ │ -000679a0: 632c 2063 6861 7220 636f 6e73 742a 2064 c, char const* d │ │ │ -000679b0: 6573 742c 2070 6565 725f 736f 7572 6365 est, peer_source │ │ │ -000679c0: 5f66 6c61 6773 5f74 2063 6f6e 7374 2073 _flags_t const s │ │ │ -000679d0: 6f75 7263 6529 2074 7279 0a09 7b0a 0909 ource) try..{... │ │ │ -000679e0: 544f 5252 454e 545f 4153 5345 5254 2869 TORRENT_ASSERT(i │ │ │ -000679f0: 735f 7369 6e67 6c65 5f74 6872 6561 6428 s_single_thread( │ │ │ -00067a00: 2929 3b0a 0a09 0949 4e56 4152 4941 4e54 ));....INVARIANT │ │ │ -00067a10: 5f43 4845 434b 3b0a 0a09 0943 4f4d 504c _CHECK;....COMPL │ │ │ -00067a20: 4554 455f 4153 594e 4328 2274 6f72 7265 ETE_ASYNC("torre │ │ │ -00067a30: 6e74 3a3a 6f6e 5f69 3270 5f72 6573 6f6c nt::on_i2p_resol │ │ │ -00067a40: 7665 2229 3b0a 2369 666e 6465 6620 544f ve");.#ifndef TO │ │ │ -00067a50: 5252 454e 545f 4449 5341 424c 455f 4c4f RRENT_DISABLE_LO │ │ │ -00067a60: 4747 494e 470a 0909 6966 2028 6563 2026 GGING...if (ec & │ │ │ -00067a70: 616d 703b 2661 6d70 3b20 7368 6f75 6c64 amp;& should │ │ │ -00067a80: 5f6c 6f67 2829 290a 0909 0964 6562 7567 _log())....debug │ │ │ -00067a90: 5f6c 6f67 2822 6932 705f 7265 736f 6c76 _log("i2p_resolv │ │ │ -00067aa0: 6520 6572 726f 723a 2025 7322 2c20 6563 e error: %s", ec │ │ │ -00067ab0: 2e6d 6573 7361 6765 2829 2e63 5f73 7472 .message().c_str │ │ │ -00067ac0: 2829 293b 0a23 656e 6469 660a 0909 6966 ());.#endif...if │ │ │ -00067ad0: 2028 6563 207c 7c20 6d5f 6162 6f72 7420 (ec || m_abort │ │ │ -00067ae0: 7c7c 206d 5f73 6573 2e69 735f 6162 6f72 || m_ses.is_abor │ │ │ -00067af0: 7465 6428 2929 2072 6574 7572 6e3b 0a0a ted()) return;.. │ │ │ -00067b00: 0909 6e65 6564 5f70 6565 725f 6c69 7374 ..need_peer_list │ │ │ -00067b10: 2829 3b0a 0909 746f 7272 656e 745f 7374 ();...torrent_st │ │ │ -00067b20: 6174 6520 7374 203d 2067 6574 5f70 6565 ate st = get_pee │ │ │ -00067b30: 725f 6c69 7374 5f73 7461 7465 2829 3b0a r_list_state();. │ │ │ -00067b40: 0909 6966 2028 6d5f 7065 6572 5f6c 6973 ..if (m_peer_lis │ │ │ -00067b50: 742d 2667 743b 6164 645f 6932 705f 7065 t->add_i2p_pe │ │ │ -00067b60: 6572 2864 6573 742c 2073 6f75 7263 652c er(dest, source, │ │ │ -00067b70: 207b 7d2c 2026 616d 703b 7374 2929 0a09 {}, &st)).. │ │ │ -00067b80: 0909 7374 6174 655f 7570 6461 7465 6428 ..state_updated( │ │ │ -00067b90: 293b 0a09 0970 6565 7273 5f65 7261 7365 );...peers_erase │ │ │ -00067ba0: 6428 7374 2e65 7261 7365 6429 3b0a 0a3c d(st.erased);..< │ │ │ -00067bb0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00067bc0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00067bd0: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -00067be0: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -00067bf0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566
    ../src │ │ │ -00067c20: 2f74 6f72 7265 6e74 2e63 7070 3a34 3331 /torrent.cpp:431 │ │ │ -00067c30: 343c 2f61 3e3c 2f74 643e 3c74 643e 6164 4ad │ │ │ -00067c40: 6420 6f6e 6520 7065 6572 2070 6572 2049 d one peer per I │ │ │ -00067c50: 5020 7468 6520 686f 7374 6e61 6d65 2072 P the hostname r │ │ │ -00067c60: 6573 6f6c 7665 7320 746f 3c2f 7464 3e3c esolves to< │ │ │ -00067c70: 2f74 723e 3c74 7220 6964 3d22 3233 3622 /tr>

    add one │ │ │ -00067cc0: 7065 6572 2070 6572 2049 5020 7468 6520 peer per IP the │ │ │ -00067cd0: 686f 7374 6e61 6d65 2072 6573 6f6c 7665 hostname resolve │ │ │ -00067ce0: 7320 746f 3c2f 6832 3e3c 6834 3e2e 2e2f s to

    ../ │ │ │ -00067cf0: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ -00067d00: 3433 3134 3c2f 6834 3e3c 7072 6520 7374 4314

    .catch (...) 
    │ │ │ -00067d50: 7b20 6861 6e64 6c65 5f65 7863 6570 7469  { handle_excepti
    │ │ │ -00067d60: 6f6e 2829 3b20 7d0a 2365 6e64 6966 0a0a  on(); }.#endif..
    │ │ │ -00067d70: 0976 6f69 6420 746f 7272 656e 743a 3a6f  .void torrent::o
    │ │ │ -00067d80: 6e5f 7065 6572 5f6e 616d 655f 6c6f 6f6b  n_peer_name_look
    │ │ │ -00067d90: 7570 2865 7272 6f72 5f63 6f64 6520 636f  up(error_code co
    │ │ │ -00067da0: 6e73 7426 616d 703b 2065 0a09 092c 2073  nst& e..., s
    │ │ │ -00067db0: 7464 3a3a 7665 6374 6f72 266c 743b 6164  td::vector<ad
    │ │ │ -00067dc0: 6472 6573 7326 6774 3b20 636f 6e73 7426  dress> const&
    │ │ │ -00067dd0: 616d 703b 2068 6f73 745f 6c69 7374 2c20  amp; host_list, 
    │ │ │ -00067de0: 696e 7420 636f 6e73 7420 706f 7274 0a09  int const port..
    │ │ │ -00067df0: 092c 2070 726f 746f 636f 6c5f 7665 7273  ., protocol_vers
    │ │ │ -00067e00: 696f 6e20 636f 6e73 7420 7629 2074 7279  ion const v) try
    │ │ │ -00067e10: 0a09 7b0a 0909 544f 5252 454e 545f 4153  ..{...TORRENT_AS
    │ │ │ -00067e20: 5345 5254 2869 735f 7369 6e67 6c65 5f74  SERT(is_single_t
    │ │ │ -00067e30: 6872 6561 6428 2929 3b0a 0a09 0949 4e56  hread());....INV
    │ │ │ -00067e40: 4152 4941 4e54 5f43 4845 434b 3b0a 0a09  ARIANT_CHECK;...
    │ │ │ -00067e50: 0943 4f4d 504c 4554 455f 4153 594e 4328  .COMPLETE_ASYNC(
    │ │ │ -00067e60: 2274 6f72 7265 6e74 3a3a 6f6e 5f70 6565  "torrent::on_pee
    │ │ │ -00067e70: 725f 6e61 6d65 5f6c 6f6f 6b75 7022 293b  r_name_lookup");
    │ │ │ -00067e80: 0a0a 2369 666e 6465 6620 544f 5252 454e  ..#ifndef TORREN
    │ │ │ -00067e90: 545f 4449 5341 424c 455f 4c4f 4747 494e  T_DISABLE_LOGGIN
    │ │ │ -00067ea0: 470a 0909 6966 2028 6520 2661 6d70 3b26  G...if (e &&
    │ │ │ -00067eb0: 616d 703b 2073 686f 756c 645f 6c6f 6728  amp; should_log(
    │ │ │ -00067ec0: 2929 0a09 0909 6465 6275 675f 6c6f 6728  ))....debug_log(
    │ │ │ -00067ed0: 2270 6565 7220 6e61 6d65 206c 6f6f 6b75  "peer name looku
    │ │ │ -00067ee0: 7020 6572 726f 723a 2025 7322 2c20 652e  p error: %s", e.
    │ │ │ -00067ef0: 6d65 7373 6167 6528 292e 635f 7374 7228  message().c_str(
    │ │ │ -00067f00: 2929 3b0a 2365 6e64 6966 0a0a 0909 6966  ));.#endif....if
    │ │ │ -00067f10: 2028 6520 7c7c 206d 5f61 626f 7274 207c   (e || m_abort |
    │ │ │ -00067f20: 7c20 686f 7374 5f6c 6973 742e 656d 7074  | host_list.empt
    │ │ │ -00067f30: 7928 2920 7c7c 206d 5f73 6573 2e69 735f  y() || m_ses.is_
    │ │ │ -00067f40: 6162 6f72 7465 6428 2929 2072 6574 7572  aborted()) retur
    │ │ │ -00067f50: 6e3b 0a0a 3c64 6976 2073 7479 6c65 3d22  n;..
    ..tcp::endpoin │ │ │ -00067f90: 7420 686f 7374 2868 6f73 745f 6c69 7374 t host(host_list │ │ │ -00067fa0: 2e66 726f 6e74 2829 2c20 7374 643a 3a75 .front(), std::u │ │ │ -00067fb0: 696e 7431 365f 7428 706f 7274 2929 3b0a int16_t(port));. │ │ │ -00067fc0: 3c2f 6469 763e 0a09 0969 6620 286d 5f69
    ...if (m_i │ │ │ -00067fd0: 705f 6669 6c74 6572 2026 616d 703b 2661 p_filter &&a │ │ │ -00067fe0: 6d70 3b20 6d5f 6970 5f66 696c 7465 722d mp; m_ip_filter- │ │ │ -00067ff0: 2667 743b 6163 6365 7373 2868 6f73 742e >access(host. │ │ │ -00068000: 6164 6472 6573 7328 2929 2026 616d 703b address()) & │ │ │ -00068010: 2069 705f 6669 6c74 6572 3a3a 626c 6f63 ip_filter::bloc │ │ │ -00068020: 6b65 6429 0a09 097b 0a23 6966 6e64 6566 ked)...{.#ifndef │ │ │ -00068030: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ -00068040: 5f4c 4f47 4749 4e47 0a09 0909 6966 2028 _LOGGING....if ( │ │ │ -00068050: 7368 6f75 6c64 5f6c 6f67 2829 290a 0909 should_log())... │ │ │ -00068060: 097b 0a09 0909 0964 6562 7567 5f6c 6f67 .{.....debug_log │ │ │ -00068070: 2822 626c 6f63 6b65 6420 6970 2066 726f ("blocked ip fro │ │ │ -00068080: 6d20 7472 6163 6b65 723a 2025 7322 2c20 m tracker: %s", │ │ │ -00068090: 686f 7374 2e61 6464 7265 7373 2829 2e74 host.address().t │ │ │ -000680a0: 6f5f 7374 7269 6e67 2829 2e63 5f73 7472 o_string().c_str │ │ │ -000680b0: 2829 293b 0a09 0909 7d0a 2365 6e64 6966 ());....}.#endif │ │ │ -000680c0: 0a09 0909 6966 2028 6d5f 7365 732e 616c ....if (m_ses.al │ │ │ -000680d0: 6572 7473 2829 2e73 686f 756c 645f 706f erts().should_po │ │ │ -000680e0: 7374 266c 743b 7065 6572 5f62 6c6f 636b st<peer_block │ │ │ -000680f0: 6564 5f61 6c65 7274 2667 743b 2829 290a ed_alert>()). │ │ │ -00068100: 0909 0909 6d5f 7365 732e 616c 6572 7473 ....m_ses.alerts │ │ │ -00068110: 2829 2e65 6d70 6c61 6365 5f61 6c65 7274 ().emplace_alert │ │ │ -00068120: 266c 743b 7065 6572 5f62 6c6f 636b 6564 <peer_blocked │ │ │ -00068130: 5f61 6c65 7274 2667 743b 2867 6574 5f68 _alert>(get_h │ │ │ -00068140: 616e 646c 6528 290a 0909 0909 092c 2068 andle()......, h │ │ │ -00068150: 6f73 742c 2070 6565 725f 626c 6f63 6b65 ost, peer_blocke │ │ │ -00068160: 645f 616c 6572 743a 3a69 705f 6669 6c74 d_alert::ip_filt │ │ │ -00068170: 6572 293b 0a09 0909 7265 7475 726e 3b0a er);....return;. │ │ │ -00068180: 0909 7d0a 0a09 0969 6620 2861 6464 5f70 ..}....if (add_p │ │ │ -00068190: 6565 7228 686f 7374 2c20 7065 6572 5f69 eer(host, peer_i │ │ │ -000681a0: 6e66 6f3a 3a74 7261 636b 6572 2c20 7620 nfo::tracker, v │ │ │ -000681b0: 3d3d 2070 726f 746f 636f 6c5f 7665 7273 == protocol_vers │ │ │ -000681c0: 696f 6e3a 3a56 3220 3f20 7065 785f 6c74 ion::V2 ? pex_lt │ │ │ -000681d0: 5f76 3220 3a20 7065 785f 666c 6167 735f _v2 : pex_flags_ │ │ │ -000681e0: 7428 3029 2929 0a09 097b 0a09 0909 7374 t(0)))...{....st │ │ │ -000681f0: 6174 655f 7570 6461 7465 6428 293b 0a0a ate_updated();.. │ │ │ -00068200: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ -00068210: 4449 5341 424c 455f 4c4f 4747 494e 470a DISABLE_LOGGING. │ │ │ -00068220: 0909 0969 6620 2873 686f 756c 645f 6c6f ...if (should_lo │ │ │ -00068230: 6728 2929 0a09 0909 7b0a 0909 0909 6465 g())....{.....de │ │ │ -00068240: 6275 675f 6c6f 6728 226e 616d 652d 6c6f bug_log("name-lo │ │ │ -00068250: 6f6b 7570 2061 6464 5f70 6565 7228 2920 okup add_peer() │ │ │ -00068260: 5b20 2573 205d 2063 6f6e 6e65 6374 2d63 [ %s ] connect-c │ │ │ -00068270: 616e 6469 6461 7465 733a 2025 6422 0a09 andidates: %d".. │ │ │ -00068280: 0909 0909 2c20 686f 7374 2e61 6464 7265 ...., host.addre │ │ │ -00068290: 7373 2829 2e74 6f5f 7374 7269 6e67 2829 ss().to_string() │ │ │ -000682a0: 2e63 5f73 7472 2829 0a09 0909 0909 2c20 .c_str()......, │ │ │ -000682b0: 6d5f 7065 6572 5f6c 6973 7420 3f20 6d5f m_peer_list ? m_ │ │ │ -000682c0: 7065 6572 5f6c 6973 742d 2667 743b 6e75 peer_list->nu │ │ │ -000682d0: 6d5f 636f 6e6e 6563 745f 6361 6e64 6964 m_connect_candid │ │ │ -000682e0: 6174 6573 2829 203a 202d 3129 3b0a 0909 ates() : -1);... │ │ │ -000682f0: 097d 0a23 656e 6469 660a 0909 7d0a 0909 .}.#endif...}... │ │ │ -00068300: 7570 6461 7465 5f77 616e 745f 7065 6572 update_want_peer │ │ │ -00068310: 7328 293b 0a09 7d0a 3c2f 7072 653e 3c2f s();..}.
    relevan │ │ │ -00068350: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/torren │ │ │ -00068390: 742e 6370 703a 3530 3531 3c2f 613e 3c2f t.cpp:5051only do t │ │ │ -000683b0: 6869 7320 6966 2074 6865 2070 6965 6365 his if the piece │ │ │ -000683c0: 2073 697a 6520 3e20 3120 626c 6f63 6b73 size > 1 blocks │ │ │ -000683d0: 2054 6869 7320 6973 2061 2076 3220 746f This is a v2 to │ │ │ -000683e0: 7272 656e 7420 736f 2077 6520 6361 6e20 rrent so we can │ │ │ -000683f0: 7265 7175 6573 7420 6765 7420 626c 6f63 request get bloc │ │ │ -00068400: 6b20 6c65 7665 6c20 6861 7368 6573 2e3c k level hashes.< │ │ │ -00068410: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    onl │ │ │ -00068460: 7920 646f 2074 6869 7320 6966 2074 6865 y do this if the │ │ │ -00068470: 2070 6965 6365 2073 697a 6520 3e20 3120 piece size > 1 │ │ │ -00068480: 626c 6f63 6b73 0a54 6869 7320 6973 2061 blocks.This is a │ │ │ -00068490: 2076 3220 746f 7272 656e 7420 736f 2077 v2 torrent so w │ │ │ -000684a0: 6520 6361 6e20 7265 7175 6573 7420 6765 e can request ge │ │ │ -000684b0: 7420 626c 6f63 6b0a 6c65 7665 6c20 6861 t block.level ha │ │ │ -000684c0: 7368 6573 2e3c 2f68 323e 3c68 343e 2e2e shes.

    .. │ │ │ -000684d0: 2f73 7263 2f74 6f72 7265 6e74 2e63 7070 /src/torrent.cpp │ │ │ -000684e0: 3a35 3035 313c 2f68 343e 3c70 7265 2073 :5051

    ...if (!bloc
    │ │ │ -00068530: 6b73 2e65 6d70 7479 2829 290a 0909 097b  ks.empty())....{
    │ │ │ -00068540: 0a09 0909 0966 6f72 2028 6175 746f 2063  .....for (auto c
    │ │ │ -00068550: 6f6e 7374 2062 203a 2062 6c6f 636b 7329  onst b : blocks)
    │ │ │ -00068560: 2072 6574 2e69 6e73 6572 7428 646f 776e   ret.insert(down
    │ │ │ -00068570: 6c6f 6164 6572 735b 7374 643a 3a73 697a  loaders[std::siz
    │ │ │ -00068580: 655f 7428 6229 5d29 3b0a 0909 097d 0a09  e_t(b)]);....}..
    │ │ │ -00068590: 0909 656c 7365 0a09 0909 7b0a 0909 0909  ..else....{.....
    │ │ │ -000685a0: 7374 643a 3a63 6f70 7928 646f 776e 6c6f  std::copy(downlo
    │ │ │ -000685b0: 6164 6572 732e 6265 6769 6e28 292c 0a09  aders.begin(),..
    │ │ │ -000685c0: 0909 0909 646f 776e 6c6f 6164 6572 732e  ....downloaders.
    │ │ │ -000685d0: 6265 6769 6e28 2920 2b20 7061 796c 6f61  begin() + payloa
    │ │ │ -000685e0: 645f 626c 6f63 6b73 2c0a 0909 0909 0973  d_blocks,......s
    │ │ │ -000685f0: 7464 3a3a 696e 7365 7274 6572 2872 6574  td::inserter(ret
    │ │ │ -00068600: 2c20 7265 742e 6265 6769 6e28 2929 293b  , ret.begin()));
    │ │ │ -00068610: 0a09 0909 7d0a 0909 0972 6574 7572 6e20  ....}....return 
    │ │ │ -00068620: 7265 743b 0a09 097d 2829 3b0a 0a09 092f  ret;...}();..../
    │ │ │ -00068630: 2f20 6966 2074 6869 7320 7069 6563 6520  / if this piece 
    │ │ │ -00068640: 7761 736e 2774 2064 6f77 6e6c 6f61 6465  wasn't downloade
    │ │ │ -00068650: 6420 6672 6f6d 2070 6565 7273 2c20 7765  d from peers, we
    │ │ │ -00068660: 206a 7573 7420 666f 756e 6420 6974 206f   just found it o
    │ │ │ -00068670: 6e20 6469 736b 2e0a 0909 2f2f 2049 6e20  n disk....// In 
    │ │ │ -00068680: 7468 6174 2063 6173 652c 2077 6520 7368  that case, we sh
    │ │ │ -00068690: 6f75 6c64 206a 7573 7420 636f 6e73 6964  ould just consid
    │ │ │ -000686a0: 6572 2069 7420 6173 2022 6e6f 742d 6861  er it as "not-ha
    │ │ │ -000686b0: 7665 2220 616e 6420 7468 6572 6527 7320  ve" and there's 
    │ │ │ -000686c0: 6e6f 0a09 092f 2f20 6e65 6564 2074 6f20  no...// need to 
    │ │ │ -000686d0: 7472 7920 746f 2067 6574 2068 6967 6865  try to get highe
    │ │ │ -000686e0: 7220 6669 6465 6c69 7479 2068 6173 6865  r fidelity hashe
    │ │ │ -000686f0: 7320 2879 6574 290a 0909 626f 6f6c 2063  s (yet)...bool c
    │ │ │ -00068700: 6f6e 7374 2066 6f75 6e64 5f6f 6e5f 6469  onst found_on_di
    │ │ │ -00068710: 736b 203d 2070 6565 7273 2e73 697a 6528  sk = peers.size(
    │ │ │ -00068720: 2920 3d3d 2031 2026 616d 703b 2661 6d70  ) == 1 &&
    │ │ │ -00068730: 3b20 7065 6572 732e 636f 756e 7428 6e75  ; peers.count(nu
    │ │ │ -00068740: 6c6c 7074 7229 3b0a 0a09 0969 6620 2874  llptr);....if (t
    │ │ │ -00068750: 6f72 7265 6e74 5f66 696c 6528 292e 696e  orrent_file().in
    │ │ │ -00068760: 666f 5f68 6173 6865 7328 292e 6861 735f  fo_hashes().has_
    │ │ │ -00068770: 7632 2829 2026 616d 703b 2661 6d70 3b20  v2() && 
    │ │ │ -00068780: 626c 6f63 6b73 2e65 6d70 7479 2829 2026  blocks.empty() &
    │ │ │ -00068790: 616d 703b 2661 6d70 3b20 2166 6f75 6e64  amp;& !found
    │ │ │ -000687a0: 5f6f 6e5f 6469 736b 290a 0909 7b0a 3c64  _on_disk)...{....v
    │ │ │ -000687e0: 6572 6966 795f 626c 6f63 6b5f 6861 7368  erify_block_hash
    │ │ │ -000687f0: 6573 2869 6e64 6578 293b 0a3c 2f64 6976  es(index);...}....// the b
    │ │ │ -00068810: 656c 6f77 2063 6f64 6520 6973 2070 656e  elow code is pen
    │ │ │ -00068820: 616c 697a 696e 6720 7065 6572 7320 7468  alizing peers th
    │ │ │ -00068830: 6174 2073 656e 7420 7573 6520 6261 6420  at sent use bad 
    │ │ │ -00068840: 6461 7461 2e0a 0909 2f2f 2069 6e63 7265  data....// incre
    │ │ │ -00068850: 6173 6520 7468 6520 746f 7461 6c20 616d  ase the total am
    │ │ │ -00068860: 6f75 6e74 206f 6620 6661 696c 6564 2062  ount of failed b
    │ │ │ -00068870: 7974 6573 0a09 0969 6620 2821 666f 756e  ytes...if (!foun
    │ │ │ -00068880: 645f 6f6e 5f64 6973 6b29 0a09 097b 0a09  d_on_disk)...{..
    │ │ │ -00068890: 0909 6966 2028 626c 6f63 6b73 2e65 6d70  ..if (blocks.emp
    │ │ │ -000688a0: 7479 2829 290a 0909 0909 6164 645f 6661  ty()).....add_fa
    │ │ │ -000688b0: 696c 6564 5f62 7974 6573 286d 5f74 6f72  iled_bytes(m_tor
    │ │ │ -000688c0: 7265 6e74 5f66 696c 652d 2667 743b 7069  rent_file->pi
    │ │ │ -000688d0: 6563 655f 7369 7a65 2869 6e64 6578 2929  ece_size(index))
    │ │ │ -000688e0: 3b0a 0909 0965 6c73 650a 0909 0909 6164  ;....else.....ad
    │ │ │ -000688f0: 645f 6661 696c 6564 5f62 7974 6573 2873  d_failed_bytes(s
    │ │ │ -00068900: 7461 7469 635f 6361 7374 266c 743b 696e  tatic_cast<in
    │ │ │ -00068910: 7426 6774 3b28 626c 6f63 6b73 2e73 697a  t>(blocks.siz
    │ │ │ -00068920: 6528 2929 202a 2064 6566 6175 6c74 5f62  e()) * default_b
    │ │ │ -00068930: 6c6f 636b 5f73 697a 6529 3b0a 0a23 6966  lock_size);..#if
    │ │ │ -00068940: 6e64 6566 2054 4f52 5245 4e54 5f44 4953  ndef TORRENT_DIS
    │ │ │ -00068950: 4142 4c45 5f45 5854 454e 5349 4f4e 530a  ABLE_EXTENSIONS.
    │ │ │ -00068960: 0909 0966 6f72 2028 6175 746f 2661 6d70  ...for (auto&
    │ │ │ -00068970: 3b20 6578 7420 3a20 6d5f 6578 7465 6e73  ; ext : m_extens
    │ │ │ -00068980: 696f 6e73 290a 0909 097b 0a09 0909 0965  ions)....{.....e
    │ │ │ -00068990: 7874 2d26 6774 3b6f 6e5f 7069 6563 655f  xt->on_piece_
    │ │ │ -000689a0: 6661 696c 6564 2869 6e64 6578 293b 0a09  failed(index);..
    │ │ │ -000689b0: 0909 7d0a 2365 6e64 6966 0a0a 0909 092f  ..}.#endif...../
    │ │ │ -000689c0: 2f20 6469 6420 7765 2072 6563 6569 7665  / did we receive
    │ │ │ -000689d0: 2074 6869 7320 7069 6563 6520 6672 6f6d   this piece from
    │ │ │ -000689e0: 2061 2073 696e 676c 6520 7065 6572 3f0a   a single peer?.
    │ │ │ -000689f0: 0909 092f 2f20 6966 2077 6520 6b6e 6f77  ...// if we know
    │ │ │ -00068a00: 2065 7861 6374 6c79 2077 6869 6368 2062   exactly which b
    │ │ │ -00068a10: 6c6f 636b 7320 6661 696c 6564 2074 6865  locks failed the
    │ │ │ -00068a20: 2068 6173 682c 2077 6520 6361 6e20 616c   hash, we can al
    │ │ │ -00068a30: 736f 2062 6520 6365 7274 6169 6e0a 0909  so be certain...
    │ │ │ -00068a40: 092f 2f20 7468 6174 2061 6c6c 2070 6565  .// that all pee
    │ │ │ -00068a50: 7273 2069 6e20 7468 6520 6c69 7374 2073  rs in the list s
    │ │ │ -00068a60: 656e 7420 7573 2062 6164 2064 6174 610a  ent us bad data.
    │ │ │ -00068a70: 0909 0962 6f6f 6c20 636f 6e73 7420 6b6e  ...bool const kn
    │ │ │ -00068a80: 6f77 6e5f 6261 645f 7065 6572 203d 2070  own_bad_peer = p
    │ │ │ -00068a90: 6565 7273 2e73 697a 6528 2920 3d3d 2031  eers.size() == 1
    │ │ │ -00068aa0: 207c 7c20 2162 6c6f 636b 732e 656d 7074   || !blocks.empt
    │ │ │ -00068ab0: 7928 293b 0a0a 0909 0970 656e 616c 697a  y();.....penaliz
    │ │ │ -00068ac0: 655f 7065 6572 7328 7065 6572 732c 2069  e_peers(peers, i
    │ │ │ -00068ad0: 6e64 6578 2c20 6b6e 6f77 6e5f 6261 645f  ndex, known_bad_
    │ │ │ -00068ae0: 7065 6572 293b 0a09 097d 0a0a 0909 2f2f  peer);...}....//
    │ │ │ -00068af0: 2049 6620 6d5f 7374 6f72 6167 6520 6973   If m_storage is
    │ │ │ -00068b00: 6e27 7420 7365 7420 6865 7265 2c20 6974  n't set here, it
    │ │ │ -00068b10: 206d 6561 6e73 2077 6527 7265 2073 6875   means we're shu
    │ │ │ -00068b20: 7474 696e 6720 646f 776e 0a09 0969 6620  tting down...if 
    │ │ │ -00068b30: 286d 5f73 746f 7261 6765 290a 0909 7b0a  (m_storage)...{.
    │ │ │ -00068b40: 0909 092f 2f20 6974 2064 6f65 736e 2774  ...// it doesn't
    │ │ │ -00068b50: 206d 616b 6520 6d75 6368 2073 656e 7365   make much sense
    │ │ │ -00068b60: 2074 6f20 6661 696c 2074 6f20 6861 7368   to fail to hash
    │ │ │ -00068b70: 2061 2070 6965 6365 0a3c 2f70 7265 3e3c   a piece.
    < │ │ │ -00068b80: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00068bb0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00068bc0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/torre │ │ │ -00068bf0: 6e74 2e63 7070 3a38 3036 383c 2f61 3e3c nt.cpp:8068< │ │ │ -00068c00: 2f74 643e 3c74 643e 636f 6d65 2075 7020 /td>come up │ │ │ -00068c10: 7769 7468 2061 2062 6574 7465 7220 7761 with a better wa │ │ │ -00068c20: 7920 6f66 2064 6f69 6e67 2074 6869 732c y of doing this, │ │ │ -00068c30: 2069 6e73 7465 6164 206f 6620 616e 2069 instead of an i │ │ │ -00068c40: 6d6d 6564 6961 7465 6c79 2069 6e76 6f6b mmediately invok │ │ │ -00068c50: 6564 206c 616d 6264 6120 6578 7072 6573 ed lambda expres │ │ │ -00068c60: 7369 6f6e 2e3c 2f74 643e 3c2f 7472 3e3c sion.< │ │ │ -00068c70: 7472 2069 643d 2232 3338 2220 7374 796c tr id="238" styl │ │ │ -00068c80: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00068c90: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00068ca0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00068cb0: 6832 3e63 6f6d 6520 7570 2077 6974 6820 h2>come up with │ │ │ -00068cc0: 6120 6265 7474 6572 2077 6179 206f 6620 a better way of │ │ │ -00068cd0: 646f 696e 6720 7468 6973 2c20 696e 7374 doing this, inst │ │ │ -00068ce0: 6561 6420 6f66 2061 6e0a 696d 6d65 6469 ead of an.immedi │ │ │ -00068cf0: 6174 656c 7920 696e 766f 6b65 6420 6c61 ately invoked la │ │ │ -00068d00: 6d62 6461 2065 7870 7265 7373 696f 6e2e mbda expression. │ │ │ -00068d10: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -00068d20: 746f 7272 656e 742e 6370 703a 3830 3638 torrent.cpp:8068 │ │ │ -00068d30: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00068d70: 0909 0909 7c7c 2070 6565 7269 6e66 6f2d  ....|| peerinfo-
    │ │ │ -00068d80: 2667 743b 636f 6e66 6972 6d65 645f 7375  >confirmed_su
    │ │ │ -00068d90: 7070 6f72 7473 5f75 7470 2929 0a09 0909  pports_utp))....
    │ │ │ -00068da0: 7b0a 0909 0909 736d 203d 206d 5f73 6573  {.....sm = m_ses
    │ │ │ -00068db0: 2e75 7470 5f73 6f63 6b65 745f 6d61 6e61  .utp_socket_mana
    │ │ │ -00068dc0: 6765 7228 293b 0a09 0909 7d0a 0a09 0909  ger();....}.....
    │ │ │ -00068dd0: 2f2f 2064 6f6e 2774 206d 616b 6520 6120  // don't make a 
    │ │ │ -00068de0: 5443 5020 636f 6e6e 6563 7469 6f6e 2069  TCP connection i
    │ │ │ -00068df0: 6620 6974 2773 2064 6973 6162 6c65 640a  f it's disabled.
    │ │ │ -00068e00: 0909 0969 6620 2873 6d20 3d3d 206e 756c  ...if (sm == nul
    │ │ │ -00068e10: 6c70 7472 2026 616d 703b 2661 6d70 3b20  lptr && 
    │ │ │ -00068e20: 2173 6574 7469 6e67 7328 292e 6765 745f  !settings().get_
    │ │ │ -00068e30: 626f 6f6c 2873 6574 7469 6e67 735f 7061  bool(settings_pa
    │ │ │ -00068e40: 636b 3a3a 656e 6162 6c65 5f6f 7574 676f  ck::enable_outgo
    │ │ │ -00068e50: 696e 675f 7463 7029 290a 0909 097b 0a23  ing_tcp))....{.#
    │ │ │ -00068e60: 6966 6e64 6566 2054 4f52 5245 4e54 5f44  ifndef TORRENT_D
    │ │ │ -00068e70: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09  ISABLE_LOGGING..
    │ │ │ -00068e80: 0909 0969 6620 2873 686f 756c 645f 6c6f  ...if (should_lo
    │ │ │ -00068e90: 6728 2929 0a09 0909 097b 0a09 0909 0909  g()).....{......
    │ │ │ -00068ea0: 6465 6275 675f 6c6f 6728 2264 6973 6361  debug_log("disca
    │ │ │ -00068eb0: 7264 696e 6720 7065 6572 205c 2225 735c  rding peer \"%s\
    │ │ │ -00068ec0: 223a 2054 4350 2063 6f6e 6e65 6374 696f  ": TCP connectio
    │ │ │ -00068ed0: 6e73 2064 6973 6162 6c65 6420 220a 0909  ns disabled "...
    │ │ │ -00068ee0: 0909 0909 225b 2073 7570 706f 7274 732d  ...."[ supports-
    │ │ │ -00068ef0: 7574 703a 2025 6420 5d22 2c20 7065 6572  utp: %d ]", peer
    │ │ │ -00068f00: 696e 666f 2d26 6774 3b74 6f5f 7374 7269  info->to_stri
    │ │ │ -00068f10: 6e67 2829 2e63 5f73 7472 2829 0a09 0909  ng().c_str()....
    │ │ │ -00068f20: 0909 092c 2070 6565 7269 6e66 6f2d 2667  ..., peerinfo-&g
    │ │ │ -00068f30: 743b 7375 7070 6f72 7473 5f75 7470 293b  t;supports_utp);
    │ │ │ -00068f40: 0a09 0909 097d 0a23 656e 6469 660a 0909  .....}.#endif...
    │ │ │ -00068f50: 0909 7265 7475 726e 2066 616c 7365 3b0a  ..return false;.
    │ │ │ -00068f60: 0909 097d 0a09 097d 0a0a 3c64 6976 2073  ...}...}..
    ..aux::s │ │ │ -00068fa0: 6f63 6b65 745f 7479 7065 2073 203d 205b ocket_type s = [ │ │ │ -00068fb0: 2661 6d70 3b5d 207b 0a3c 2f64 6976 3e0a &] {.
    . │ │ │ -00068fc0: 2369 6620 544f 5252 454e 545f 5553 455f #if TORRENT_USE_ │ │ │ -00068fd0: 4932 500a 0909 6966 2028 7065 6572 696e I2P...if (peerin │ │ │ -00068fe0: 666f 2d26 6774 3b69 735f 6932 705f 6164 fo->is_i2p_ad │ │ │ -00068ff0: 6472 290a 0909 7b0a 0909 092f 2f20 4974 dr)...{....// It │ │ │ -00069000: 2773 206e 6f74 2065 6e74 6972 656c 7920 's not entirely │ │ │ -00069010: 6f62 7669 6f75 7320 7768 7920 7468 6973 obvious why this │ │ │ -00069020: 2070 6565 7220 636f 6e6e 6563 7469 6f6e peer connection │ │ │ -00069030: 2069 7320 6e6f 7420 6d61 726b 6564 2061 is not marked a │ │ │ -00069040: 730a 0909 092f 2f20 6f6e 652e 2054 6865 s....// one. The │ │ │ -00069050: 206d 6169 6e20 6665 6174 7572 6520 6f66 main feature of │ │ │ -00069060: 2061 2070 6565 7220 636f 6e6e 6563 7469 a peer connecti │ │ │ -00069070: 6f6e 2069 7320 7468 6174 2077 6865 7468 on is that wheth │ │ │ -00069080: 6572 206f 7220 6e6f 7420 7765 0a09 0909 er or not we.... │ │ │ -00069090: 2f2f 2070 726f 7879 2069 7420 6973 2063 // proxy it is c │ │ │ -000690a0: 6f6e 6669 6775 7261 626c 652e 2057 6865 onfigurable. Whe │ │ │ -000690b0: 6e20 7765 2075 7365 2069 3270 2c20 7765 n we use i2p, we │ │ │ -000690c0: 2077 616e 7420 746f 2061 6c77 6179 7320 want to always │ │ │ -000690d0: 7072 6f78 0a09 0909 2f2f 2065 7665 7279 prox....// every │ │ │ -000690e0: 7468 696e 6720 7669 6120 6932 702e 0a0a thing via i2p... │ │ │ -000690f0: 0909 0961 7578 3a3a 7072 6f78 795f 7365 ...aux::proxy_se │ │ │ -00069100: 7474 696e 6773 2070 726f 7879 3b0a 0909 ttings proxy;... │ │ │ -00069110: 0970 726f 7879 2e68 6f73 746e 616d 6520 .proxy.hostname │ │ │ -00069120: 3d20 7365 7474 696e 6773 2829 2e67 6574 = settings().get │ │ │ -00069130: 5f73 7472 2873 6574 7469 6e67 735f 7061 _str(settings_pa │ │ │ -00069140: 636b 3a3a 6932 705f 686f 7374 6e61 6d65 ck::i2p_hostname │ │ │ -00069150: 293b 0a09 0909 7072 6f78 792e 706f 7274 );....proxy.port │ │ │ -00069160: 203d 2073 7464 3a3a 7569 6e74 3136 5f74 = std::uint16_t │ │ │ -00069170: 2873 6574 7469 6e67 7328 292e 6765 745f (settings().get_ │ │ │ -00069180: 696e 7428 7365 7474 696e 6773 5f70 6163 int(settings_pac │ │ │ -00069190: 6b3a 3a69 3270 5f70 6f72 7429 293b 0a09 k::i2p_port));.. │ │ │ -000691a0: 0909 7072 6f78 792e 7479 7065 203d 2073 ..proxy.type = s │ │ │ -000691b0: 6574 7469 6e67 735f 7061 636b 3a3a 6932 ettings_pack::i2 │ │ │ -000691c0: 705f 7072 6f78 793b 0a0a 0909 0961 7578 p_proxy;.....aux │ │ │ -000691d0: 3a3a 736f 636b 6574 5f74 7970 6520 7265 ::socket_type re │ │ │ -000691e0: 7420 3d20 696e 7374 616e 7469 6174 655f t = instantiate_ │ │ │ -000691f0: 636f 6e6e 6563 7469 6f6e 286d 5f73 6573 connection(m_ses │ │ │ -00069200: 2e67 6574 5f63 6f6e 7465 7874 2829 0a09 .get_context().. │ │ │ -00069210: 0909 092c 2070 726f 7879 2c20 6e75 6c6c ..., proxy, null │ │ │ -00069220: 7074 722c 206e 756c 6c70 7472 2c20 6661 ptr, nullptr, fa │ │ │ -00069230: 6c73 652c 2066 616c 7365 293b 0a09 0909 lse, false);.... │ │ │ -00069240: 6175 746f 2661 6d70 3b20 7374 7220 3d20 auto& str = │ │ │ -00069250: 7374 643a 3a67 6574 266c 743b 6932 705f std::get<i2p_ │ │ │ -00069260: 7374 7265 616d 2667 743b 2872 6574 293b stream>(ret); │ │ │ -00069270: 0a09 0909 7374 722e 7365 745f 6c6f 6361 ....str.set_loca │ │ │ -00069280: 6c5f 6932 705f 656e 6470 6f69 6e74 286d l_i2p_endpoint(m │ │ │ -00069290: 5f73 6573 2e6c 6f63 616c 5f69 3270 5f65 _ses.local_i2p_e │ │ │ -000692a0: 6e64 706f 696e 7428 2929 3b0a 0909 0973 ndpoint());....s │ │ │ -000692b0: 7472 2e73 6574 5f64 6573 7469 6e61 7469 tr.set_destinati │ │ │ -000692c0: 6f6e 2873 7461 7469 635f 6361 7374 266c on(static_cast&l │ │ │ -000692d0: 743b 6932 705f 7065 6572 2a26 6774 3b28 t;i2p_peer*>( │ │ │ -000692e0: 7065 6572 696e 666f 292d 2667 743b 6465 peerinfo)->de │ │ │ -000692f0: 7374 2829 293b 0a09 0909 7374 722e 7365 st());....str.se │ │ │ -00069300: 745f 636f 6d6d 616e 6428 6932 705f 7374 t_command(i2p_st │ │ │ -00069310: 7265 616d 3a3a 636d 645f 636f 6e6e 6563 ream::cmd_connec │ │ │ -00069320: 7429 3b0a 0909 0973 7472 2e73 6574 5f73 t);....str.set_s │ │ │ -00069330: 6573 7369 6f6e 5f69 6428 6d5f 7365 732e ession_id(m_ses. │ │ │ -00069340: 6932 705f 7365 7373 696f 6e28 2929 3b0a i2p_session());. │ │ │ -00069350: 0909 0972 6574 7572 6e20 7265 743b 0a09 ...return ret;.. │ │ │ -00069360: 097d 0a09 0965 6c73 650a 2365 6e64 6966 .}...else.#endif │ │ │ -00069370: 0a09 097b 0a09 0909 766f 6964 2a20 7573 ...{....void* us │ │ │ -00069380: 6572 6461 7461 203d 206e 756c 6c70 7472 erdata = nullptr │ │ │ -00069390: 3b0a 2369 6664 6566 2054 4f52 5245 4e54 ;.#ifdef TORRENT │ │ │ -000693a0: 5f53 534c 5f50 4545 5253 0a09 0909 6966 _SSL_PEERS....if │ │ │ -000693b0: 2028 6973 5f73 736c 5f74 6f72 7265 6e74 (is_ssl_torrent │ │ │ -000693c0: 2829 290a 0909 097b 0a3c 2f70 7265 3e3c ())....{.
    < │ │ │ -000693d0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -00069400: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -00069410: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/torre │ │ │ -00069440: 6e74 2e63 7070 3a39 3735 373c 2f61 3e3c nt.cpp:9757< │ │ │ -00069450: 2f74 643e 3c74 643e 7065 7268 6170 7320 /td>perhaps │ │ │ -00069460: 3020 7368 6f75 6c64 2061 6374 7561 6c6c 0 should actuall │ │ │ -00069470: 7920 6d65 616e 2030 3c2f 7464 3e3c 2f74 y mean 0

    perhaps 0 │ │ │ -000694d0: 7368 6f75 6c64 2061 6374 7561 6c6c 7920 should actually │ │ │ -000694e0: 6d65 616e 2030 3c2f 6832 3e3c 6834 3e2e mean 0

    . │ │ │ -000694f0: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ -00069500: 703a 3937 3537 3c2f 6834 3e3c 7072 6520 p:9757

    ..// finish
    │ │ │ -00069550: 6564 2074 6f72 7265 6e74 7320 6d61 7920  ed torrents may 
    │ │ │ -00069560: 6e6f 7420 6368 616e 6765 2074 6865 6972  not change their
    │ │ │ -00069570: 2071 7565 7565 2070 6f73 6974 696f 6e73   queue positions
    │ │ │ -00069580: 2c20 6173 2069 7427 7320 7365 7420 746f  , as it's set to
    │ │ │ -00069590: 0a09 092f 2f20 2d31 0a09 0969 6620 2828  ...// -1...if ((
    │ │ │ -000695a0: 6d5f 6162 6f72 7420 7c7c 2069 735f 6669  m_abort || is_fi
    │ │ │ -000695b0: 6e69 7368 6564 2829 2920 2661 6d70 3b26  nished()) &&
    │ │ │ -000695c0: 616d 703b 2070 2021 3d20 6e6f 5f70 6f73  amp; p != no_pos
    │ │ │ -000695d0: 2920 7265 7475 726e 3b0a 0a09 0954 4f52  ) return;....TOR
    │ │ │ -000695e0: 5245 4e54 5f41 5353 4552 5428 2870 203d  RENT_ASSERT((p =
    │ │ │ -000695f0: 3d20 6e6f 5f70 6f73 2920 3d3d 2069 735f  = no_pos) == is_
    │ │ │ -00069600: 6669 6e69 7368 6564 2829 0a09 0909 7c7c  finished()....||
    │ │ │ -00069610: 2028 216d 5f61 7574 6f5f 6d61 6e61 6765   (!m_auto_manage
    │ │ │ -00069620: 6420 2661 6d70 3b26 616d 703b 2070 203d  d && p =
    │ │ │ -00069630: 3d20 6e6f 5f70 6f73 290a 0909 097c 7c20  = no_pos)....|| 
    │ │ │ -00069640: 286d 5f61 626f 7274 2026 616d 703b 2661  (m_abort &&a
    │ │ │ -00069650: 6d70 3b20 7020 3d3d 206e 6f5f 706f 7329  mp; p == no_pos)
    │ │ │ -00069660: 0a09 0909 7c7c 2028 216d 5f61 6464 6564  ....|| (!m_added
    │ │ │ -00069670: 2026 616d 703b 2661 6d70 3b20 7020 3d3d   && p ==
    │ │ │ -00069680: 206e 6f5f 706f 7329 293b 0a09 0969 6620   no_pos));...if 
    │ │ │ -00069690: 2870 203d 3d20 6d5f 7365 7175 656e 6365  (p == m_sequence
    │ │ │ -000696a0: 5f6e 756d 6265 7229 2072 6574 7572 6e3b  _number) return;
    │ │ │ -000696b0: 0a0a 0909 544f 5252 454e 545f 4153 5345  ....TORRENT_ASSE
    │ │ │ -000696c0: 5254 2870 2026 6774 3b3d 206e 6f5f 706f  RT(p >= no_po
    │ │ │ -000696d0: 7329 3b0a 0a09 0973 7461 7465 5f75 7064  s);....state_upd
    │ │ │ -000696e0: 6174 6564 2829 3b0a 0a09 096d 5f73 6573  ated();....m_ses
    │ │ │ -000696f0: 2e73 6574 5f71 7565 7565 5f70 6f73 6974  .set_queue_posit
    │ │ │ -00069700: 696f 6e28 7468 6973 2c20 7029 3b0a 097d  ion(this, p);..}
    │ │ │ -00069710: 0a0a 0976 6f69 6420 746f 7272 656e 743a  ...void torrent:
    │ │ │ -00069720: 3a73 6574 5f6d 6178 5f75 706c 6f61 6473  :set_max_uploads
    │ │ │ -00069730: 2869 6e74 206c 696d 6974 2c20 626f 6f6c  (int limit, bool
    │ │ │ -00069740: 2063 6f6e 7374 2073 7461 7465 5f75 7064   const state_upd
    │ │ │ -00069750: 6174 6529 0a09 7b0a 0909 544f 5252 454e  ate)..{...TORREN
    │ │ │ -00069760: 545f 4153 5345 5254 2869 735f 7369 6e67  T_ASSERT(is_sing
    │ │ │ -00069770: 6c65 5f74 6872 6561 6428 2929 3b0a 3c64  le_thread());...if
    │ │ │ -000697b0: 2028 6c69 6d69 7420 266c 743b 3d20 3029   (limit <= 0)
    │ │ │ -000697c0: 206c 696d 6974 203d 2028 3120 266c 743b   limit = (1 <
    │ │ │ -000697d0: 266c 743b 2032 3429 202d 2031 3b0a 3c2f  < 24) - 1;...if (int(m_
    │ │ │ -000697f0: 6d61 785f 7570 6c6f 6164 7329 203d 3d20  max_uploads) == 
    │ │ │ -00069800: 6c69 6d69 7429 2072 6574 7572 6e3b 0a09  limit) return;..
    │ │ │ -00069810: 0969 6620 2873 7461 7465 5f75 7064 6174  .if (state_updat
    │ │ │ -00069820: 6529 2073 7461 7465 5f75 7064 6174 6564  e) state_updated
    │ │ │ -00069830: 2829 3b0a 0909 6d5f 6d61 785f 7570 6c6f  ();...m_max_uplo
    │ │ │ -00069840: 6164 7320 3d20 6175 783a 3a6e 756d 6572  ads = aux::numer
    │ │ │ -00069850: 6963 5f63 6173 7426 6c74 3b73 7464 3a3a  ic_cast<std::
    │ │ │ -00069860: 7569 6e74 3332 5f74 2667 743b 286c 696d  uint32_t>(lim
    │ │ │ -00069870: 6974 293b 0a23 6966 6e64 6566 2054 4f52  it);.#ifndef TOR
    │ │ │ -00069880: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47  RENT_DISABLE_LOG
    │ │ │ -00069890: 4749 4e47 0a09 0969 6620 2873 686f 756c  GING...if (shoul
    │ │ │ -000698a0: 645f 6c6f 6728 2920 2661 6d70 3b26 616d  d_log() &&am
    │ │ │ -000698b0: 703b 2073 7461 7465 5f75 7064 6174 6529  p; state_update)
    │ │ │ -000698c0: 0a09 0909 6465 6275 675f 6c6f 6728 222a  ....debug_log("*
    │ │ │ -000698d0: 2a2a 2073 6574 2d6d 6178 2d75 706c 6f61  ** set-max-uploa
    │ │ │ -000698e0: 6473 3a20 2564 222c 206d 5f6d 6178 5f75  ds: %d", m_max_u
    │ │ │ -000698f0: 706c 6f61 6473 293b 0a23 656e 6469 660a  ploads);.#endif.
    │ │ │ -00069900: 0a09 0969 6620 2873 7461 7465 5f75 7064  ...if (state_upd
    │ │ │ -00069910: 6174 6529 0a09 0909 7365 745f 6e65 6564  ate)....set_need
    │ │ │ -00069920: 5f73 6176 655f 7265 7375 6d65 2874 6f72  _save_resume(tor
    │ │ │ -00069930: 7265 6e74 5f68 616e 646c 653a 3a69 665f  rent_handle::if_
    │ │ │ -00069940: 636f 6e66 6967 5f63 6861 6e67 6564 293b  config_changed);
    │ │ │ -00069950: 0a09 7d0a 0a09 766f 6964 2074 6f72 7265  ..}...void torre
    │ │ │ -00069960: 6e74 3a3a 7365 745f 6d61 785f 636f 6e6e  nt::set_max_conn
    │ │ │ -00069970: 6563 7469 6f6e 7328 696e 7420 6c69 6d69  ections(int limi
    │ │ │ -00069980: 742c 2062 6f6f 6c20 636f 6e73 7420 7374  t, bool const st
    │ │ │ -00069990: 6174 655f 7570 6461 7465 290a 097b 0a09  ate_update)..{..
    │ │ │ -000699a0: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ -000699b0: 6973 5f73 696e 676c 655f 7468 7265 6164  is_single_thread
    │ │ │ -000699c0: 2829 293b 0a3c 2f70 7265 3e3c 2f74 643e  ());.
    │ │ │ -000699d0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00069a00: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00069a10: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00069a20: 7074 3a65 7870 616e 6428 3234 3029 223e pt:expand(240)"> │ │ │ -00069a30: 2e2e 2f73 7263 2f74 6f72 7265 6e74 2e63 ../src/torrent.c │ │ │ -00069a40: 7070 3a39 3737 343c 2f61 3e3c 2f74 643e pp:9774 │ │ │ -00069a50: 3c74 643e 7065 7268 6170 7320 3020 7368 perhaps 0 sh │ │ │ -00069a60: 6f75 6c64 2061 6374 7561 6c6c 7920 6d65 ould actually me │ │ │ -00069a70: 616e 2030 3c2f 7464 3e3c 2f74 723e 3c74 an 0perhaps 0 shou │ │ │ -00069ad0: 6c64 2061 6374 7561 6c6c 7920 6d65 616e ld actually mean │ │ │ -00069ae0: 2030 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 0

    ../sr │ │ │ -00069af0: 632f 746f 7272 656e 742e 6370 703a 3937 c/torrent.cpp:97 │ │ │ -00069b00: 3734 3c2f 6834 3e3c 7072 6520 7374 796c 74

    ..void torrent:
    │ │ │ -00069b50: 3a73 6574 5f6d 6178 5f75 706c 6f61 6473  :set_max_uploads
    │ │ │ -00069b60: 2869 6e74 206c 696d 6974 2c20 626f 6f6c  (int limit, bool
    │ │ │ -00069b70: 2063 6f6e 7374 2073 7461 7465 5f75 7064   const state_upd
    │ │ │ -00069b80: 6174 6529 0a09 7b0a 0909 544f 5252 454e  ate)..{...TORREN
    │ │ │ -00069b90: 545f 4153 5345 5254 2869 735f 7369 6e67  T_ASSERT(is_sing
    │ │ │ -00069ba0: 6c65 5f74 6872 6561 6428 2929 3b0a 0909  le_thread());...
    │ │ │ -00069bb0: 6966 2028 6c69 6d69 7420 266c 743b 3d20  if (limit <= 
    │ │ │ -00069bc0: 3029 206c 696d 6974 203d 2028 3120 266c  0) limit = (1 &l
    │ │ │ -00069bd0: 743b 266c 743b 2032 3429 202d 2031 3b0a  t;< 24) - 1;.
    │ │ │ -00069be0: 0909 6966 2028 696e 7428 6d5f 6d61 785f  ..if (int(m_max_
    │ │ │ -00069bf0: 7570 6c6f 6164 7329 203d 3d20 6c69 6d69  uploads) == limi
    │ │ │ -00069c00: 7429 2072 6574 7572 6e3b 0a09 0969 6620  t) return;...if 
    │ │ │ -00069c10: 2873 7461 7465 5f75 7064 6174 6529 2073  (state_update) s
    │ │ │ -00069c20: 7461 7465 5f75 7064 6174 6564 2829 3b0a  tate_updated();.
    │ │ │ -00069c30: 0909 6d5f 6d61 785f 7570 6c6f 6164 7320  ..m_max_uploads 
    │ │ │ -00069c40: 3d20 6175 783a 3a6e 756d 6572 6963 5f63  = aux::numeric_c
    │ │ │ -00069c50: 6173 7426 6c74 3b73 7464 3a3a 7569 6e74  ast<std::uint
    │ │ │ -00069c60: 3332 5f74 2667 743b 286c 696d 6974 293b  32_t>(limit);
    │ │ │ -00069c70: 0a23 6966 6e64 6566 2054 4f52 5245 4e54  .#ifndef TORRENT
    │ │ │ -00069c80: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47  _DISABLE_LOGGING
    │ │ │ -00069c90: 0a09 0969 6620 2873 686f 756c 645f 6c6f  ...if (should_lo
    │ │ │ -00069ca0: 6728 2920 2661 6d70 3b26 616d 703b 2073  g() && s
    │ │ │ -00069cb0: 7461 7465 5f75 7064 6174 6529 0a09 0909  tate_update)....
    │ │ │ -00069cc0: 6465 6275 675f 6c6f 6728 222a 2a2a 2073  debug_log("*** s
    │ │ │ -00069cd0: 6574 2d6d 6178 2d75 706c 6f61 6473 3a20  et-max-uploads: 
    │ │ │ -00069ce0: 2564 222c 206d 5f6d 6178 5f75 706c 6f61  %d", m_max_uploa
    │ │ │ -00069cf0: 6473 293b 0a23 656e 6469 660a 0a09 0969  ds);.#endif....i
    │ │ │ -00069d00: 6620 2873 7461 7465 5f75 7064 6174 6529  f (state_update)
    │ │ │ -00069d10: 0a09 0909 7365 745f 6e65 6564 5f73 6176  ....set_need_sav
    │ │ │ -00069d20: 655f 7265 7375 6d65 2874 6f72 7265 6e74  e_resume(torrent
    │ │ │ -00069d30: 5f68 616e 646c 653a 3a69 665f 636f 6e66  _handle::if_conf
    │ │ │ -00069d40: 6967 5f63 6861 6e67 6564 293b 0a09 7d0a  ig_changed);..}.
    │ │ │ -00069d50: 0a09 766f 6964 2074 6f72 7265 6e74 3a3a  ..void torrent::
    │ │ │ -00069d60: 7365 745f 6d61 785f 636f 6e6e 6563 7469  set_max_connecti
    │ │ │ -00069d70: 6f6e 7328 696e 7420 6c69 6d69 742c 2062  ons(int limit, b
    │ │ │ -00069d80: 6f6f 6c20 636f 6e73 7420 7374 6174 655f  ool const state_
    │ │ │ -00069d90: 7570 6461 7465 290a 097b 0a09 0954 4f52  update)..{...TOR
    │ │ │ -00069da0: 5245 4e54 5f41 5353 4552 5428 6973 5f73  RENT_ASSERT(is_s
    │ │ │ -00069db0: 696e 676c 655f 7468 7265 6164 2829 293b  ingle_thread());
    │ │ │ -00069dc0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -00069df0: 0969 6620 286c 696d 6974 2026 6c74 3b3d .if (limit <= │ │ │ -00069e00: 2030 2920 6c69 6d69 7420 3d20 2831 2026 0) limit = (1 & │ │ │ -00069e10: 6c74 3b26 6c74 3b20 3234 2920 2d20 313b lt;< 24) - 1; │ │ │ -00069e20: 0a3c 2f64 6976 3e09 0969 6620 2869 6e74 .
    ..if (int │ │ │ -00069e30: 286d 5f6d 6178 5f63 6f6e 6e65 6374 696f (m_max_connectio │ │ │ -00069e40: 6e73 2920 3d3d 206c 696d 6974 2920 7265 ns) == limit) re │ │ │ -00069e50: 7475 726e 3b0a 0909 6966 2028 7374 6174 turn;...if (stat │ │ │ -00069e60: 655f 7570 6461 7465 2920 7374 6174 655f e_update) state_ │ │ │ -00069e70: 7570 6461 7465 6428 293b 0a09 096d 5f6d updated();...m_m │ │ │ -00069e80: 6178 5f63 6f6e 6e65 6374 696f 6e73 203d ax_connections = │ │ │ -00069e90: 2061 7578 3a3a 6e75 6d65 7269 635f 6361 aux::numeric_ca │ │ │ -00069ea0: 7374 266c 743b 7374 643a 3a75 696e 7433 st<std::uint3 │ │ │ -00069eb0: 325f 7426 6774 3b28 6c69 6d69 7429 3b0a 2_t>(limit);. │ │ │ -00069ec0: 0909 7570 6461 7465 5f77 616e 745f 7065 ..update_want_pe │ │ │ -00069ed0: 6572 7328 293b 0a0a 2369 666e 6465 6620 ers();..#ifndef │ │ │ -00069ee0: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -00069ef0: 4c4f 4747 494e 470a 0909 6966 2028 7368 LOGGING...if (sh │ │ │ -00069f00: 6f75 6c64 5f6c 6f67 2829 2026 616d 703b ould_log() & │ │ │ -00069f10: 2661 6d70 3b20 7374 6174 655f 7570 6461 & state_upda │ │ │ -00069f20: 7465 290a 0909 0964 6562 7567 5f6c 6f67 te)....debug_log │ │ │ -00069f30: 2822 2a2a 2a20 7365 742d 6d61 782d 636f ("*** set-max-co │ │ │ -00069f40: 6e6e 6563 7469 6f6e 733a 2025 6422 2c20 nnections: %d", │ │ │ -00069f50: 6d5f 6d61 785f 636f 6e6e 6563 7469 6f6e m_max_connection │ │ │ -00069f60: 7329 3b0a 2365 6e64 6966 0a0a 0909 6966 s);.#endif....if │ │ │ -00069f70: 2028 6e75 6d5f 7065 6572 7328 2920 2667 (num_peers() &g │ │ │ -00069f80: 743b 2069 6e74 286d 5f6d 6178 5f63 6f6e t; int(m_max_con │ │ │ -00069f90: 6e65 6374 696f 6e73 2929 0a09 097b 0a09 nections))...{.. │ │ │ -00069fa0: 0909 6469 7363 6f6e 6e65 6374 5f70 6565 ..disconnect_pee │ │ │ -00069fb0: 7273 286e 756d 5f70 6565 7273 2829 202d rs(num_peers() - │ │ │ -00069fc0: 206d 5f6d 6178 5f63 6f6e 6e65 6374 696f m_max_connectio │ │ │ -00069fd0: 6e73 0a09 0909 092c 2065 7272 6f72 733a ns....., errors: │ │ │ -00069fe0: 3a74 6f6f 5f6d 616e 795f 636f 6e6e 6563 :too_many_connec │ │ │ -00069ff0: 7469 6f6e 7329 3b0a 0909 7d0a 0a09 0969 tions);...}....i │ │ │ -0006a000: 6620 2873 7461 7465 5f75 7064 6174 6529 f (state_update) │ │ │ -0006a010: 0a09 0909 7365 745f 6e65 6564 5f73 6176 ....set_need_sav │ │ │ -0006a020: 655f 7265 7375 6d65 2874 6f72 7265 6e74 e_resume(torrent │ │ │ -0006a030: 5f68 616e 646c 653a 3a69 665f 636f 6e66 _handle::if_conf │ │ │ -0006a040: 6967 5f63 6861 6e67 6564 293b 0a09 7d0a ig_changed);..}. │ │ │ -0006a050: 0a09 766f 6964 2074 6f72 7265 6e74 3a3a ..void torrent:: │ │ │ -0006a060: 7365 745f 7570 6c6f 6164 5f6c 696d 6974 set_upload_limit │ │ │ -0006a070: 2869 6e74 2063 6f6e 7374 206c 696d 6974 (int const limit │ │ │ -0006a080: 290a 097b 0a09 0973 6574 5f6c 696d 6974 )..{...set_limit │ │ │ -0006a090: 5f69 6d70 6c28 6c69 6d69 742c 2070 6565 _impl(limit, pee │ │ │ -0006a0a0: 725f 636f 6e6e 6563 7469 6f6e 3a3a 7570 r_connection::up │ │ │ -0006a0b0: 6c6f 6164 5f63 6861 6e6e 656c 293b 0a23 load_channel);.# │ │ │ -0006a0c0: 6966 6e64 6566 2054 4f52 5245 4e54 5f44 ifndef TORRENT_D │ │ │ -0006a0d0: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09 ISABLE_LOGGING.. │ │ │ -0006a0e0: 0964 6562 7567 5f6c 6f67 2822 2a2a 2a20 .debug_log("*** │ │ │ -0006a0f0: 7365 742d 7570 6c6f 6164 2d6c 696d 6974 set-upload-limit │ │ │ -0006a100: 3a20 2564 222c 206c 696d 6974 293b 0a23 : %d", limit);.# │ │ │ -0006a110: 656e 6469 660a 097d 0a0a 0976 6f69 6420 endif..}...void │ │ │ -0006a120: 746f 7272 656e 743a 3a73 6574 5f64 6f77 torrent::set_dow │ │ │ -0006a130: 6e6c 6f61 645f 6c69 6d69 7428 696e 7420 nload_limit(int │ │ │ -0006a140: 636f 6e73 7420 6c69 6d69 7429 0a09 7b0a const limit)..{. │ │ │ -0006a150: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -0006a160: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0006a190: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ -0006a1c0: 632f 746f 7272 656e 742e 6370 703a 3131 c/torrent.cpp:11 │ │ │ -0006a1d0: 3638 373c 2f61 3e3c 2f74 643e 3c74 643e 687 │ │ │ -0006a1e0: 696e 7374 6561 6420 6f66 2072 6573 6f72 instead of resor │ │ │ -0006a1f0: 7469 6e67 2074 6865 2077 686f 6c65 206c ting the whole l │ │ │ -0006a200: 6973 742c 2069 6e73 6572 7420 7468 6520 ist, insert the │ │ │ -0006a210: 7065 6572 7320 6469 7265 6374 6c79 2069 peers directly i │ │ │ -0006a220: 6e74 6f20 7468 6520 7269 6768 7420 706c nto the right pl │ │ │ -0006a230: 6163 653c 2f74 643e 3c2f 7472 3e3c 7472 ace

    instead of reso │ │ │ -0006a290: 7274 696e 6720 7468 6520 7768 6f6c 6520 rting the whole │ │ │ -0006a2a0: 6c69 7374 2c20 696e 7365 7274 2074 6865 list, insert the │ │ │ -0006a2b0: 2070 6565 7273 0a64 6972 6563 746c 7920 peers.directly │ │ │ -0006a2c0: 696e 746f 2074 6865 2072 6967 6874 2070 into the right p │ │ │ -0006a2d0: 6c61 6365 3c2f 6832 3e3c 6834 3e2e 2e2f lace

    ../ │ │ │ -0006a2e0: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ -0006a2f0: 3131 3638 373c 2f68 343e 3c70 7265 2073 11687

    ....std::pri
    │ │ │ -0006a340: 6e74 6628 2274 696d 6564 206f 7574 205b  ntf("timed out [
    │ │ │ -0006a350: 6176 6572 6167 652d 7069 6563 652d 7469  average-piece-ti
    │ │ │ -0006a360: 6d65 3a20 2564 206d 7320 5d5c 6e22 0a09  me: %d ms ]\n"..
    │ │ │ -0006a370: 0909 0909 2c20 6d5f 6176 6572 6167 655f  ...., m_average_
    │ │ │ -0006a380: 7069 6563 655f 7469 6d65 293b 0a23 656e  piece_time);.#en
    │ │ │ -0006a390: 6469 660a 0909 097d 0a0a 0909 092f 2f20  dif....}.....// 
    │ │ │ -0006a3a0: 7069 636b 2061 6c6c 2062 6c6f 636b 7320  pick all blocks 
    │ │ │ -0006a3b0: 666f 7220 7468 6973 2070 6965 6365 2e20  for this piece. 
    │ │ │ -0006a3c0: 7468 6520 7065 6572 7320 6c69 7374 2069  the peers list i
    │ │ │ -0006a3d0: 7320 6b65 7074 2075 7020 746f 2064 6174  s kept up to dat
    │ │ │ -0006a3e0: 650a 0909 092f 2f20 616e 6420 736f 7274  e....// and sort
    │ │ │ -0006a3f0: 6564 2e20 7768 656e 2077 6520 6973 7375  ed. when we issu
    │ │ │ -0006a400: 6520 6120 7265 7175 6573 7420 746f 2061  e a request to a
    │ │ │ -0006a410: 2070 6565 722c 2069 7473 2064 6f77 6e6c   peer, its downl
    │ │ │ -0006a420: 6f61 6420 7175 6575 650a 0909 092f 2f20  oad queue....// 
    │ │ │ -0006a430: 7469 6d65 2077 696c 6c20 696e 6372 6561  time will increa
    │ │ │ -0006a440: 7365 2061 6e64 2069 7420 6d61 7920 6e65  se and it may ne
    │ │ │ -0006a450: 6564 2074 6f20 6265 2062 756d 7065 6420  ed to be bumped 
    │ │ │ -0006a460: 696e 2074 6865 2070 6565 7273 206c 6973  in the peers lis
    │ │ │ -0006a470: 742c 0a09 0909 2f2f 2073 696e 6365 2069  t,....// since i
    │ │ │ -0006a480: 7427 7320 6f72 6465 7265 6420 6279 2064  t's ordered by d
    │ │ │ -0006a490: 6f77 6e6c 6f61 6420 7175 6575 6520 7469  ownload queue ti
    │ │ │ -0006a4a0: 6d65 0a09 0909 7069 636b 5f74 696d 655f  me....pick_time_
    │ │ │ -0006a4b0: 6372 6974 6963 616c 5f62 6c6f 636b 2870  critical_block(p
    │ │ │ -0006a4c0: 6565 7273 2c20 6967 6e6f 7265 5f70 6565  eers, ignore_pee
    │ │ │ -0006a4d0: 7273 0a09 0909 092c 2070 6565 7273 5f77  rs....., peers_w
    │ │ │ -0006a4e0: 6974 685f 7265 7175 6573 7473 0a09 0909  ith_requests....
    │ │ │ -0006a4f0: 092c 2070 692c 2026 616d 703b 692c 206d  ., pi, &i, m
    │ │ │ -0006a500: 5f70 6963 6b65 722e 6765 7428 290a 0909  _picker.get()...
    │ │ │ -0006a510: 0909 2c20 626c 6f63 6b73 5f69 6e5f 7069  .., blocks_in_pi
    │ │ │ -0006a520: 6563 652c 2074 696d 6564 5f6f 7574 293b  ece, timed_out);
    │ │ │ -0006a530: 0a0a 0909 092f 2f20 7075 7420 6261 636b  .....// put back
    │ │ │ -0006a540: 2074 6865 2070 6565 7273 2077 6520 6967   the peers we ig
    │ │ │ -0006a550: 6e6f 7265 6420 696e 746f 2074 6865 2070  nored into the p
    │ │ │ -0006a560: 6565 7220 6c69 7374 2066 6f72 2074 6865  eer list for the
    │ │ │ -0006a570: 206e 6578 7420 7069 6563 650a 0909 0969   next piece....i
    │ │ │ -0006a580: 6620 2821 6967 6e6f 7265 5f70 6565 7273  f (!ignore_peers
    │ │ │ -0006a590: 2e65 6d70 7479 2829 290a 0909 097b 0a09  .empty())....{..
    │ │ │ -0006a5a0: 0909 0970 6565 7273 2e69 6e73 6572 7428  ...peers.insert(
    │ │ │ -0006a5b0: 7065 6572 732e 6265 6769 6e28 292c 2069  peers.begin(), i
    │ │ │ -0006a5c0: 676e 6f72 655f 7065 6572 732e 6265 6769  gnore_peers.begi
    │ │ │ -0006a5d0: 6e28 292c 2069 676e 6f72 655f 7065 6572  n(), ignore_peer
    │ │ │ -0006a5e0: 732e 656e 6428 2929 3b0a 0909 0909 6967  s.end());.....ig
    │ │ │ -0006a5f0: 6e6f 7265 5f70 6565 7273 2e63 6c65 6172  nore_peers.clear
    │ │ │ -0006a600: 2829 3b0a 0a3c 6469 7620 7374 796c 653d  ();..
    ....std::sort │ │ │ -0006a640: 2870 6565 7273 2e62 6567 696e 2829 2c20 (peers.begin(), │ │ │ -0006a650: 7065 6572 732e 656e 6428 290a 3c2f 6469 peers.end()......, [] (pee │ │ │ -0006a670: 725f 636f 6e6e 6563 7469 6f6e 2063 6f6e r_connection con │ │ │ -0006a680: 7374 2a20 6c68 732c 2070 6565 725f 636f st* lhs, peer_co │ │ │ -0006a690: 6e6e 6563 7469 6f6e 2063 6f6e 7374 2a20 nnection const* │ │ │ -0006a6a0: 7268 7329 0a09 0909 0909 7b20 7265 7475 rhs)......{ retu │ │ │ -0006a6b0: 726e 206c 6873 2d26 6774 3b64 6f77 6e6c rn lhs->downl │ │ │ -0006a6c0: 6f61 645f 7175 6575 655f 7469 6d65 2831 oad_queue_time(1 │ │ │ -0006a6d0: 362a 3130 3234 2920 266c 743b 2072 6873 6*1024) < rhs │ │ │ -0006a6e0: 2d26 6774 3b64 6f77 6e6c 6f61 645f 7175 ->download_qu │ │ │ -0006a6f0: 6575 655f 7469 6d65 2831 362a 3130 3234 eue_time(16*1024 │ │ │ -0006a700: 293b 207d 293b 0a09 0909 7d0a 0a09 0909 ); });....}..... │ │ │ -0006a710: 2f2f 2069 6620 7468 6973 2070 6565 7227 // if this peer' │ │ │ -0006a720: 7320 646f 776e 6c6f 6164 2074 696d 6520 s download time │ │ │ -0006a730: 6578 6365 6564 7320 3220 7365 636f 6e64 exceeds 2 second │ │ │ -0006a740: 732c 2077 6527 7265 2064 6f6e 652e 0a09 s, we're done... │ │ │ -0006a750: 0909 2f2f 2057 6520 646f 6e27 7420 7761 ..// We don't wa │ │ │ -0006a760: 6e74 2074 6f20 6275 696c 6420 756e 7265 nt to build unre │ │ │ -0006a770: 6173 6f6e 6162 6c79 206c 6f6e 6720 7265 asonably long re │ │ │ -0006a780: 7175 6573 7420 7175 6575 6573 0a09 0909 quest queues.... │ │ │ -0006a790: 6966 2028 2170 6565 7273 2e65 6d70 7479 if (!peers.empty │ │ │ -0006a7a0: 2829 2026 616d 703b 2661 6d70 3b20 7065 () && pe │ │ │ -0006a7b0: 6572 735b 305d 2d26 6774 3b64 6f77 6e6c ers[0]->downl │ │ │ -0006a7c0: 6f61 645f 7175 6575 655f 7469 6d65 2829 oad_queue_time() │ │ │ -0006a7d0: 2026 6774 3b20 6d69 6c6c 6973 6563 6f6e > millisecon │ │ │ -0006a7e0: 6473 2832 3030 3029 290a 0909 0909 6272 ds(2000)).....br │ │ │ -0006a7f0: 6561 6b3b 0a09 097d 0a0a 0909 2f2f 2063 eak;...}....// c │ │ │ -0006a800: 6f6d 6d69 7420 616c 6c20 7468 6520 7469 ommit all the ti │ │ │ -0006a810: 6d65 2063 7269 7469 6361 6c20 7265 7175 me critical requ │ │ │ -0006a820: 6573 7473 0a09 0966 6f72 2028 6175 746f ests...for (auto │ │ │ -0006a830: 2a20 7020 3a20 7065 6572 735f 7769 7468 * p : peers_with │ │ │ -0006a840: 5f72 6571 7565 7374 7329 0a09 097b 0a09 _requests)...{.. │ │ │ -0006a850: 0909 702d 2667 743b 7365 6e64 5f62 6c6f ..p->send_blo │ │ │ -0006a860: 636b 5f72 6571 7565 7374 7328 293b 0a09 ck_requests();.. │ │ │ -0006a870: 097d 0a09 7d0a 2365 6e64 6966 202f 2f20 .}..}.#endif // │ │ │ -0006a880: 544f 5252 454e 545f 4449 5341 424c 455f TORRENT_DISABLE_ │ │ │ -0006a890: 5354 5245 414d 494e 470a 0a09 7374 643a STREAMING...std: │ │ │ -0006a8a0: 3a73 6574 266c 743b 7374 643a 3a73 7472 :set<std::str │ │ │ -0006a8b0: 696e 6726 6774 3b20 746f 7272 656e 743a ing> torrent: │ │ │ -0006a8c0: 3a77 6562 5f73 6565 6473 2829 2063 6f6e :web_seeds() con │ │ │ -0006a8d0: 7374 0a09 7b0a 0909 544f 5252 454e 545f st..{...TORRENT_ │ │ │ -0006a8e0: 4153 5345 5254 2869 735f 7369 6e67 6c65 ASSERT(is_single │ │ │ -0006a8f0: 5f74 6872 6561 6428 2929 3b0a 0909 7374 _thread());...st │ │ │ -0006a900: 643a 3a73 6574 266c 743b 7374 643a 3a73 d::set<std::s │ │ │ -0006a910: 7472 696e 6726 6774 3b20 7265 743b 0a09 tring> ret;.. │ │ │ -0006a920: 0966 6f72 2028 6175 746f 2063 6f6e 7374 .for (auto const │ │ │ -0006a930: 2661 6d70 3b20 7320 3a20 6d5f 7765 625f & s : m_web_ │ │ │ -0006a940: 7365 6564 7329 0a09 097b 0a09 0909 6966 seeds)...{....if │ │ │ -0006a950: 2028 732e 7065 6572 5f69 6e66 6f2e 6261 (s.peer_info.ba │ │ │ -0006a960: 6e6e 6564 2920 636f 6e74 696e 7565 3b0a nned) continue;. │ │ │ -0006a970: 0909 0969 6620 2873 2e72 656d 6f76 6564 ...if (s.removed │ │ │ -0006a980: 2920 636f 6e74 696e 7565 3b0a 0909 0972 ) continue;....r │ │ │ -0006a990: 6574 2e69 6e73 6572 7428 732e 7572 6c29 et.insert(s.url) │ │ │ -0006a9a0: 3b0a 0909 7d0a 0909 7265 7475 726e 2072 ;...}...return r │ │ │ -0006a9b0: 6574 3b0a 097d 0a3c 2f70 7265 3e3c 2f74 et;..}.
    relevanc │ │ │ -0006a9f0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/enum_ne │ │ │ -0006aa30: 742e 6370 703a 3237 373c 2f61 3e3c 2f74 t.cpp:277
    if we get │ │ │ -0006aa50: 6865 7265 2c20 7468 6520 6361 6c6c 6572 here, the caller │ │ │ -0006aa60: 2073 7469 6c6c 2061 7373 756d 6573 2074 still assumes t │ │ │ -0006aa70: 6865 2065 7272 6f72 2063 6f64 6520 6973 he error code is │ │ │ -0006aa80: 2072 6570 6f72 7465 6420 7669 6120 6572 reported via er │ │ │ -0006aa90: 726e 6f3c 2f74 643e 3c2f 7472 3e3c 7472 rno

    if we get here, │ │ │ -0006aaf0: 2074 6865 2063 616c 6c65 7220 7374 696c the caller stil │ │ │ -0006ab00: 6c20 6173 7375 6d65 7320 7468 6520 6572 l assumes the er │ │ │ -0006ab10: 726f 7220 636f 6465 0a69 7320 7265 706f ror code.is repo │ │ │ -0006ab20: 7274 6564 2076 6961 2065 7272 6e6f 3c2f rted via errno

    ../src/en │ │ │ -0006ab40: 756d 5f6e 6574 2e63 7070 3a32 3737 3c2f um_net.cpp:277
    ...
    │ │ │ -0006ab90: 7d0a 0909 0962 7566 2e72 6573 697a 6528  }....buf.resize(
    │ │ │ -0006aba0: 7374 6174 6963 5f63 6173 7426 6c74 3b73  static_cast<s
    │ │ │ -0006abb0: 7464 3a3a 7369 7a65 5f74 2667 743b 2870  td::size_t>(p
    │ │ │ -0006abc0: 6163 6b65 745f 7369 7a65 2929 3b0a 0909  acket_size));...
    │ │ │ -0006abd0: 0969 6e74 2072 6561 645f 6c65 6e3b 0a09  .int read_len;..
    │ │ │ -0006abe0: 0909 646f 0a09 0909 7b0a 0909 0909 7265  ..do....{.....re
    │ │ │ -0006abf0: 6164 5f6c 656e 203d 2069 6e74 2872 6563  ad_len = int(rec
    │ │ │ -0006ac00: 7628 736f 636b 2c20 6275 662e 6461 7461  v(sock, buf.data
    │ │ │ -0006ac10: 2829 2c20 6275 662e 7369 7a65 2829 2c20  (), buf.size(), 
    │ │ │ -0006ac20: 4d53 475f 5452 554e 4329 293b 0a09 0909  MSG_TRUNC));....
    │ │ │ -0006ac30: 7d0a 0909 0977 6869 6c65 2028 7265 6164  }....while (read
    │ │ │ -0006ac40: 5f6c 656e 2026 6c74 3b20 3020 2661 6d70  _len < 0 &
    │ │ │ -0006ac50: 3b26 616d 703b 2065 7272 6e6f 203d 3d20  ;& errno == 
    │ │ │ -0006ac60: 4549 4e54 5229 3b0a 0909 0969 6620 2872  EINTR);....if (r
    │ │ │ -0006ac70: 6561 645f 6c65 6e20 266c 743b 2030 2920  ead_len < 0) 
    │ │ │ -0006ac80: 7265 7475 726e 202d 313b 0a09 0909 6966  return -1;....if
    │ │ │ -0006ac90: 2028 7265 6164 5f6c 656e 2021 3d20 7061   (read_len != pa
    │ │ │ -0006aca0: 636b 6574 5f73 697a 6529 0a09 0909 7b0a  cket_size)....{.
    │ │ │ -0006acb0: 0909 0909 6572 726e 6f20 3d20 454d 5347  ....errno = EMSG
    │ │ │ -0006acc0: 5349 5a45 3b0a 0909 0909 7265 7475 726e  SIZE;.....return
    │ │ │ -0006acd0: 202d 313b 0a09 0909 7d0a 0a09 0909 6175   -1;....}.....au
    │ │ │ -0006ace0: 746f 2063 6f6e 7374 2a20 6e6c 5f68 6472  to const* nl_hdr
    │ │ │ -0006acf0: 203d 2072 6569 6e74 6572 7072 6574 5f63   = reinterpret_c
    │ │ │ -0006ad00: 6173 7426 6c74 3b6e 6c6d 7367 6864 7220  ast<nlmsghdr 
    │ │ │ -0006ad10: 636f 6e73 742a 2667 743b 2862 7566 2e64  const*>(buf.d
    │ │ │ -0006ad20: 6174 6128 2929 3b0a 0909 0969 6e74 206c  ata());....int l
    │ │ │ -0006ad30: 656e 203d 2072 6561 645f 6c65 6e3b 0a0a  en = read_len;..
    │ │ │ -0006ad40: 0909 0966 6f72 2028 3b20 6c65 6e20 2667  ...for (; len &g
    │ │ │ -0006ad50: 743b 2030 2026 616d 703b 2661 6d70 3b20  t; 0 && 
    │ │ │ -0006ad60: 6175 783a 3a6e 6c6d 7367 5f6f 6b28 6e6c  aux::nlmsg_ok(nl
    │ │ │ -0006ad70: 5f68 6472 2c20 6c65 6e29 3b20 6e6c 5f68  _hdr, len); nl_h
    │ │ │ -0006ad80: 6472 203d 2061 7578 3a3a 6e6c 6d73 675f  dr = aux::nlmsg_
    │ │ │ -0006ad90: 6e65 7874 286e 6c5f 6864 722c 206c 656e  next(nl_hdr, len
    │ │ │ -0006ada0: 2929 0a09 0909 7b0a 3c64 6976 2073 7479  ))....{.
    ....if ((a │ │ │ -0006ade0: 7578 3a3a 6e6c 6d73 675f 6f6b 286e 6c5f ux::nlmsg_ok(nl_ │ │ │ -0006adf0: 6864 722c 2072 6561 645f 6c65 6e29 203d hdr, read_len) = │ │ │ -0006ae00: 3d20 3029 207c 7c20 286e 6c5f 6864 722d = 0) || (nl_hdr- │ │ │ -0006ae10: 2667 743b 6e6c 6d73 675f 7479 7065 203d >nlmsg_type = │ │ │ -0006ae20: 3d20 4e4c 4d53 475f 4552 524f 5229 290a = NLMSG_ERROR)). │ │ │ -0006ae30: 3c2f 6469 763e 0909 0909 0972 6574 7572
    .....retur │ │ │ -0006ae40: 6e20 2d31 3b0a 0909 0909 2f2f 2074 6869 n -1;.....// thi │ │ │ -0006ae50: 7320 6675 6e63 7469 6f6e 2064 6f65 736e s function doesn │ │ │ -0006ae60: 2774 2068 616e 646c 6520 6d75 6c74 6970 't handle multip │ │ │ -0006ae70: 6c65 2072 6571 7565 7374 7320 6174 2074 le requests at t │ │ │ -0006ae80: 6865 2073 616d 6520 7469 6d65 0a09 0909 he same time.... │ │ │ -0006ae90: 092f 2f20 736f 2072 6570 6f72 7420 616e .// so report an │ │ │ -0006aea0: 2065 7272 6f72 2069 6620 7468 6520 6d65 error if the me │ │ │ -0006aeb0: 7373 6167 6520 646f 6573 206e 6f74 2068 ssage does not h │ │ │ -0006aec0: 6176 6520 7468 6520 6578 7065 6374 6564 ave the expected │ │ │ -0006aed0: 2073 6571 2061 6e64 2070 6964 0a3c 2f70 seq and pid.

    re │ │ │ -0006af10: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/e │ │ │ -0006af50: 6e75 6d5f 6e65 742e 6370 703a 3238 333c num_net.cpp:283< │ │ │ -0006af60: 2f61 3e3c 2f74 643e 3c74 643e 6966 2077 /a>if w │ │ │ -0006af70: 6520 6765 7420 6865 7265 2c20 7468 6520 e get here, the │ │ │ -0006af80: 6361 6c6c 6572 2073 7469 6c6c 2061 7373 caller still ass │ │ │ -0006af90: 756d 6573 2074 6865 2065 7272 6f72 2063 umes the error c │ │ │ -0006afa0: 6f64 6520 6973 2072 6570 6f72 7465 6420 ode is reported │ │ │ -0006afb0: 7669 6120 6572 726e 6f3c 2f74 643e 3c2f via errno

    if we get │ │ │ -0006b010: 2068 6572 652c 2074 6865 2063 616c 6c65 here, the calle │ │ │ -0006b020: 7220 7374 696c 6c20 6173 7375 6d65 7320 r still assumes │ │ │ -0006b030: 7468 6520 6572 726f 7220 636f 6465 0a69 the error code.i │ │ │ -0006b040: 7320 7265 706f 7274 6564 2076 6961 2065 s reported via e │ │ │ -0006b050: 7272 6e6f 3c2f 6832 3e3c 6834 3e2e 2e2f rrno

    ../ │ │ │ -0006b060: 7372 632f 656e 756d 5f6e 6574 2e63 7070 src/enum_net.cpp │ │ │ -0006b070: 3a32 3833 3c2f 6834 3e3c 7072 6520 7374 :283

    ...{.....read
    │ │ │ -0006b0c0: 5f6c 656e 203d 2069 6e74 2872 6563 7628  _len = int(recv(
    │ │ │ -0006b0d0: 736f 636b 2c20 6275 662e 6461 7461 2829  sock, buf.data()
    │ │ │ -0006b0e0: 2c20 6275 662e 7369 7a65 2829 2c20 4d53  , buf.size(), MS
    │ │ │ -0006b0f0: 475f 5452 554e 4329 293b 0a09 0909 7d0a  G_TRUNC));....}.
    │ │ │ -0006b100: 0909 0977 6869 6c65 2028 7265 6164 5f6c  ...while (read_l
    │ │ │ -0006b110: 656e 2026 6c74 3b20 3020 2661 6d70 3b26  en < 0 &&
    │ │ │ -0006b120: 616d 703b 2065 7272 6e6f 203d 3d20 4549  amp; errno == EI
    │ │ │ -0006b130: 4e54 5229 3b0a 0909 0969 6620 2872 6561  NTR);....if (rea
    │ │ │ -0006b140: 645f 6c65 6e20 266c 743b 2030 2920 7265  d_len < 0) re
    │ │ │ -0006b150: 7475 726e 202d 313b 0a09 0909 6966 2028  turn -1;....if (
    │ │ │ -0006b160: 7265 6164 5f6c 656e 2021 3d20 7061 636b  read_len != pack
    │ │ │ -0006b170: 6574 5f73 697a 6529 0a09 0909 7b0a 0909  et_size)....{...
    │ │ │ -0006b180: 0909 6572 726e 6f20 3d20 454d 5347 5349  ..errno = EMSGSI
    │ │ │ -0006b190: 5a45 3b0a 0909 0909 7265 7475 726e 202d  ZE;.....return -
    │ │ │ -0006b1a0: 313b 0a09 0909 7d0a 0a09 0909 6175 746f  1;....}.....auto
    │ │ │ -0006b1b0: 2063 6f6e 7374 2a20 6e6c 5f68 6472 203d   const* nl_hdr =
    │ │ │ -0006b1c0: 2072 6569 6e74 6572 7072 6574 5f63 6173   reinterpret_cas
    │ │ │ -0006b1d0: 7426 6c74 3b6e 6c6d 7367 6864 7220 636f  t<nlmsghdr co
    │ │ │ -0006b1e0: 6e73 742a 2667 743b 2862 7566 2e64 6174  nst*>(buf.dat
    │ │ │ -0006b1f0: 6128 2929 3b0a 0909 0969 6e74 206c 656e  a());....int len
    │ │ │ -0006b200: 203d 2072 6561 645f 6c65 6e3b 0a0a 0909   = read_len;....
    │ │ │ -0006b210: 0966 6f72 2028 3b20 6c65 6e20 2667 743b  .for (; len >
    │ │ │ -0006b220: 2030 2026 616d 703b 2661 6d70 3b20 6175   0 && au
    │ │ │ -0006b230: 783a 3a6e 6c6d 7367 5f6f 6b28 6e6c 5f68  x::nlmsg_ok(nl_h
    │ │ │ -0006b240: 6472 2c20 6c65 6e29 3b20 6e6c 5f68 6472  dr, len); nl_hdr
    │ │ │ -0006b250: 203d 2061 7578 3a3a 6e6c 6d73 675f 6e65   = aux::nlmsg_ne
    │ │ │ -0006b260: 7874 286e 6c5f 6864 722c 206c 656e 2929  xt(nl_hdr, len))
    │ │ │ -0006b270: 0a09 0909 7b0a 0909 0909 6966 2028 2861  ....{.....if ((a
    │ │ │ -0006b280: 7578 3a3a 6e6c 6d73 675f 6f6b 286e 6c5f  ux::nlmsg_ok(nl_
    │ │ │ -0006b290: 6864 722c 2072 6561 645f 6c65 6e29 203d  hdr, read_len) =
    │ │ │ -0006b2a0: 3d20 3029 207c 7c20 286e 6c5f 6864 722d  = 0) || (nl_hdr-
    │ │ │ -0006b2b0: 2667 743b 6e6c 6d73 675f 7479 7065 203d  >nlmsg_type =
    │ │ │ -0006b2c0: 3d20 4e4c 4d53 475f 4552 524f 5229 290a  = NLMSG_ERROR)).
    │ │ │ -0006b2d0: 0909 0909 0972 6574 7572 6e20 2d31 3b0a  .....return -1;.
    │ │ │ -0006b2e0: 0909 0909 2f2f 2074 6869 7320 6675 6e63  ....// this func
    │ │ │ -0006b2f0: 7469 6f6e 2064 6f65 736e 2774 2068 616e  tion doesn't han
    │ │ │ -0006b300: 646c 6520 6d75 6c74 6970 6c65 2072 6571  dle multiple req
    │ │ │ -0006b310: 7565 7374 7320 6174 2074 6865 2073 616d  uests at the sam
    │ │ │ -0006b320: 6520 7469 6d65 0a09 0909 092f 2f20 736f  e time.....// so
    │ │ │ -0006b330: 2072 6570 6f72 7420 616e 2065 7272 6f72   report an error
    │ │ │ -0006b340: 2069 6620 7468 6520 6d65 7373 6167 6520   if the message 
    │ │ │ -0006b350: 646f 6573 206e 6f74 2068 6176 6520 7468  does not have th
    │ │ │ -0006b360: 6520 6578 7065 6374 6564 2073 6571 2061  e expected seq a
    │ │ │ -0006b370: 6e64 2070 6964 0a3c 6469 7620 7374 796c  nd pid.
    ....if (nl_ │ │ │ -0006b3b0: 6864 722d 2667 743b 6e6c 6d73 675f 7365 hdr->nlmsg_se │ │ │ -0006b3c0: 7120 213d 2073 6571 207c 7c20 6e6c 5f68 q != seq || nl_h │ │ │ -0006b3d0: 6472 2d26 6774 3b6e 6c6d 7367 5f70 6964 dr->nlmsg_pid │ │ │ -0006b3e0: 2021 3d20 7069 6429 0a3c 2f64 6976 3e09 != pid).
    . │ │ │ -0006b3f0: 0909 0909 7265 7475 726e 202d 313b 0a0a ....return -1;.. │ │ │ -0006b400: 0909 0909 6966 2028 6e6c 5f68 6472 2d26 ....if (nl_hdr-& │ │ │ -0006b410: 6774 3b6e 6c6d 7367 5f74 7970 6520 3d3d gt;nlmsg_type == │ │ │ -0006b420: 204e 4c4d 5347 5f44 4f4e 4529 2072 6574 NLMSG_DONE) ret │ │ │ -0006b430: 7572 6e20 303b 0a0a 0909 0909 6f6e 5f6d urn 0;......on_m │ │ │ -0006b440: 7367 286e 6c5f 6864 7229 3b0a 0a09 0909 sg(nl_hdr);..... │ │ │ -0006b450: 0969 6620 2828 6e6c 5f68 6472 2d26 6774 .if ((nl_hdr-> │ │ │ -0006b460: 3b6e 6c6d 7367 5f66 6c61 6773 2026 616d ;nlmsg_flags &am │ │ │ -0006b470: 703b 204e 4c4d 5f46 5f4d 554c 5449 2920 p; NLM_F_MULTI) │ │ │ -0006b480: 3d3d 2030 2920 7265 7475 726e 2030 3b0a == 0) return 0;. │ │ │ -0006b490: 0909 097d 0a09 097d 0a2f 2f09 0972 6574 ...}...}.//..ret │ │ │ -0006b4a0: 7572 6e20 303b 0a09 7d0a 0a09 696e 7420 urn 0;..}...int │ │ │ -0006b4b0: 6e6c 5f64 756d 705f 7265 7175 6573 7428 nl_dump_request( │ │ │ -0006b4c0: 696e 7420 636f 6e73 7420 736f 636b 2c20 int const sock, │ │ │ -0006b4d0: 7374 643a 3a75 696e 7433 325f 7420 636f std::uint32_t co │ │ │ -0006b4e0: 6e73 7420 7365 710a 0909 2c20 6e6c 6d73 nst seq..., nlms │ │ │ -0006b4f0: 6768 6472 2a20 636f 6e73 7420 7265 7175 ghdr* const requ │ │ │ -0006b500: 6573 745f 6d73 672c 2073 7464 3a3a 6675 est_msg, std::fu │ │ │ -0006b510: 6e63 7469 6f6e 266c 743b 766f 6964 286e nction<void(n │ │ │ -0006b520: 6c6d 7367 6864 7220 636f 6e73 742a 2926 lmsghdr const*)& │ │ │ -0006b530: 6774 3b20 6f6e 5f6d 7367 290a 097b 0a09 gt; on_msg)..{.. │ │ │ -0006b540: 0972 6571 7565 7374 5f6d 7367 2d26 6774 .request_msg-> │ │ │ -0006b550: 3b6e 6c6d 7367 5f66 6c61 6773 203d 204e ;nlmsg_flags = N │ │ │ -0006b560: 4c4d 5f46 5f44 554d 5020 7c20 4e4c 4d5f LM_F_DUMP | NLM_ │ │ │ -0006b570: 465f 5245 5155 4553 543b 0a09 0972 6571 F_REQUEST;...req │ │ │ -0006b580: 7565 7374 5f6d 7367 2d26 6774 3b6e 6c6d uest_msg->nlm │ │ │ -0006b590: 7367 5f73 6571 203d 2073 6571 3b0a 0909 sg_seq = seq;... │ │ │ -0006b5a0: 2f2f 2069 6e20 7468 656f 7279 206e 6c6d // in theory nlm │ │ │ -0006b5b0: 7367 5f70 6964 2073 686f 756c 6420 6265 sg_pid should be │ │ │ -0006b5c0: 2073 6574 2074 6f20 7468 6520 6e65 746c set to the netl │ │ │ -0006b5d0: 696e 6b20 706f 7274 2049 4420 284e 4f54 ink port ID (NOT │ │ │ -0006b5e0: 2074 6865 2070 726f 6365 7373 2049 4429 the process ID) │ │ │ -0006b5f0: 0a09 092f 2f20 6f66 2074 6865 2073 656e ...// of the sen │ │ │ -0006b600: 6465 722c 2062 7574 2074 6865 206b 6572 der, but the ker │ │ │ -0006b610: 6e65 6c20 6967 6e6f 7265 7320 7468 6973 nel ignores this │ │ │ -0006b620: 2066 6965 6c64 2073 6f20 6974 2069 7320 field so it is │ │ │ -0006b630: 7479 7069 6361 6c6c 7920 7365 7420 746f typically set to │ │ │ -0006b640: 0a09 092f 2f20 7a65 726f 0a09 0972 6571 ...// zero...req │ │ │ -0006b650: 7565 7374 5f6d 7367 2d26 6774 3b6e 6c6d uest_msg->nlm │ │ │ -0006b660: 7367 5f70 6964 203d 2030 3b0a 0a09 0969 sg_pid = 0;....i │ │ │ -0006b670: 6620 283a 3a73 656e 6428 736f 636b 2c20 f (::send(sock, │ │ │ -0006b680: 7265 7175 6573 745f 6d73 672c 2072 6571 request_msg, req │ │ │ -0006b690: 7565 7374 5f6d 7367 2d26 6774 3b6e 6c6d uest_msg->nlm │ │ │ -0006b6a0: 7367 5f6c 656e 2c20 3029 2026 6c74 3b20 sg_len, 0) < │ │ │ -0006b6b0: 3029 0a09 0909 7265 7475 726e 202d 313b 0)....return -1; │ │ │ -0006b6c0: 0a0a 0909 2f2f 2067 6574 2074 6865 2073 ....// get the s │ │ │ -0006b6d0: 6f63 6b65 7427 7320 706f 7274 2049 4420 ocket's port ID │ │ │ -0006b6e0: 736f 2074 6861 7420 7765 2063 616e 2076 so that we can v │ │ │ -0006b6f0: 6572 6966 7920 6974 2069 6e20 7468 6520 erify it in the │ │ │ -0006b700: 7265 7370 6f6e 7365 0a09 0973 6f63 6b61 response...socka │ │ │ -0006b710: 6464 725f 6e6c 2073 6f63 6b5f 6164 6472 ddr_nl sock_addr │ │ │ -0006b720: 3b0a 0909 736f 636b 6c65 6e5f 7420 736f ;...socklen_t so │ │ │ -0006b730: 636b 5f61 6464 725f 6c65 6e20 3d20 7369 ck_addr_len = si │ │ │ -0006b740: 7a65 6f66 2873 6f63 6b5f 6164 6472 293b zeof(sock_addr); │ │ │ -0006b750: 0a09 0969 6620 283a 3a67 6574 736f 636b ...if (::getsock │ │ │ -0006b760: 6e61 6d65 2873 6f63 6b2c 2072 6569 6e74 name(sock, reint │ │ │ -0006b770: 6572 7072 6574 5f63 6173 7426 6c74 3b73 erpret_cast<s │ │ │ -0006b780: 6f63 6b61 6464 722a 2667 743b 2826 616d ockaddr*>(&am │ │ │ -0006b790: 703b 736f 636b 5f61 6464 7229 2c20 2661 p;sock_addr), &a │ │ │ -0006b7a0: 6d70 3b73 6f63 6b5f 6164 6472 5f6c 656e mp;sock_addr_len │ │ │ -0006b7b0: 2920 266c 743b 2030 290a 0909 0972 6574 ) < 0)....ret │ │ │ -0006b7c0: 7572 6e20 2d31 3b0a 3c2f 7072 653e 3c2f urn -1;.
    relevan │ │ │ -0006b800: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0
    ../src/finger │ │ │ -0006b840: 7072 696e 742e 6370 703a 3535 3c2f 613e print.cpp:55 │ │ │ -0006b850: 3c2f 7464 3e3c 7464 3e74 6865 2066 696e the fin │ │ │ -0006b860: 6765 7270 7269 6e74 2063 6f6e 7374 7275 gerprint constru │ │ │ -0006b870: 6374 6f72 2073 686f 756c 6420 7461 6b65 ctor should take │ │ │ -0006b880: 2061 2073 7472 696e 675f 7669 6577 3c2f a string_view

    the │ │ │ -0006b8e0: 6669 6e67 6572 7072 696e 7420 636f 6e73 fingerprint cons │ │ │ -0006b8f0: 7472 7563 746f 7220 7368 6f75 6c64 2074 tructor should t │ │ │ -0006b900: 616b 6520 6120 7374 7269 6e67 5f76 6965 ake a string_vie │ │ │ -0006b910: 773c 2f68 323e 3c68 343e 2e2e 2f73 7263 w

    ../src │ │ │ -0006b920: 2f66 696e 6765 7270 7269 6e74 2e63 7070 /fingerprint.cpp │ │ │ -0006b930: 3a35 353c 2f68 343e 3c70 7265 2073 7479 :55

    ..TORRENT_ASSE
    │ │ │ -0006b980: 5254 5f50 5245 434f 4e44 286d 696e 6f72  RT_PRECOND(minor
    │ │ │ -0006b990: 2026 6774 3b3d 2030 293b 0a09 0954 4f52   >= 0);...TOR
    │ │ │ -0006b9a0: 5245 4e54 5f41 5353 4552 545f 5052 4543  RENT_ASSERT_PREC
    │ │ │ -0006b9b0: 4f4e 4428 7265 7669 7369 6f6e 2026 6774  OND(revision >
    │ │ │ -0006b9c0: 3b3d 2030 293b 0a09 0954 4f52 5245 4e54  ;= 0);...TORRENT
    │ │ │ -0006b9d0: 5f41 5353 4552 545f 5052 4543 4f4e 4428  _ASSERT_PRECOND(
    │ │ │ -0006b9e0: 7461 6720 2667 743b 3d20 3029 3b0a 0909  tag >= 0);...
    │ │ │ -0006b9f0: 544f 5252 454e 545f 4153 5345 5254 5f50  TORRENT_ASSERT_P
    │ │ │ -0006ba00: 5245 434f 4e44 286e 616d 652e 7369 7a65  RECOND(name.size
    │ │ │ -0006ba10: 2829 203d 3d20 3229 3b0a 0909 6966 2028  () == 2);...if (
    │ │ │ -0006ba20: 6e61 6d65 2e73 697a 6528 2920 266c 743b  name.size() <
    │ │ │ -0006ba30: 2032 2920 6e61 6d65 203d 2022 2d2d 223b   2) name = "--";
    │ │ │ -0006ba40: 0a0a 0909 7374 643a 3a73 7472 696e 6720  ....std::string 
    │ │ │ -0006ba50: 7265 743b 0a09 0972 6574 2e72 6573 697a  ret;...ret.resiz
    │ │ │ -0006ba60: 6528 3829 3b0a 0909 7265 745b 305d 203d  e(8);...ret[0] =
    │ │ │ -0006ba70: 2027 2d27 3b0a 0909 7265 745b 315d 203d   '-';...ret[1] =
    │ │ │ -0006ba80: 206e 616d 655b 305d 3b0a 0909 7265 745b   name[0];...ret[
    │ │ │ -0006ba90: 325d 203d 206e 616d 655b 315d 3b0a 0909  2] = name[1];...
    │ │ │ -0006baa0: 7265 745b 335d 203d 2076 6572 7369 6f6e  ret[3] = version
    │ │ │ -0006bab0: 5f74 6f5f 6368 6172 286d 616a 6f72 293b  _to_char(major);
    │ │ │ -0006bac0: 0a09 0972 6574 5b34 5d20 3d20 7665 7273  ...ret[4] = vers
    │ │ │ -0006bad0: 696f 6e5f 746f 5f63 6861 7228 6d69 6e6f  ion_to_char(mino
    │ │ │ -0006bae0: 7229 3b0a 0909 7265 745b 355d 203d 2076  r);...ret[5] = v
    │ │ │ -0006baf0: 6572 7369 6f6e 5f74 6f5f 6368 6172 2872  ersion_to_char(r
    │ │ │ -0006bb00: 6576 6973 696f 6e29 3b0a 0909 7265 745b  evision);...ret[
    │ │ │ -0006bb10: 365d 203d 2076 6572 7369 6f6e 5f74 6f5f  6] = version_to_
    │ │ │ -0006bb20: 6368 6172 2874 6167 293b 0a09 0972 6574  char(tag);...ret
    │ │ │ -0006bb30: 5b37 5d20 3d20 272d 273b 0a09 0972 6574  [7] = '-';...ret
    │ │ │ -0006bb40: 7572 6e20 7265 743b 0a09 7d0a 0a23 6966  urn ret;..}..#if
    │ │ │ -0006bb50: 6465 6620 5f5f 636c 616e 675f 5f0a 3c64  def __clang__.#pra
    │ │ │ -0006bb90: 676d 6120 636c 616e 6720 6469 6167 6e6f  gma clang diagno
    │ │ │ -0006bba0: 7374 6963 2070 7573 680a 3c2f 6469 763e  stic push.
    │ │ │ -0006bbb0: 2370 7261 676d 6120 636c 616e 6720 6469  #pragma clang di
    │ │ │ -0006bbc0: 6167 6e6f 7374 6963 2069 676e 6f72 6564  agnostic ignored
    │ │ │ -0006bbd0: 2022 2d57 756e 6b6e 6f77 6e2d 7761 726e   "-Wunknown-warn
    │ │ │ -0006bbe0: 696e 672d 6f70 7469 6f6e 220a 2370 7261  ing-option".#pra
    │ │ │ -0006bbf0: 676d 6120 636c 616e 6720 6469 6167 6e6f  gma clang diagno
    │ │ │ -0006bc00: 7374 6963 2069 676e 6f72 6564 2022 2d57  stic ignored "-W
    │ │ │ -0006bc10: 756e 7361 6665 2d62 7566 6665 722d 7573  unsafe-buffer-us
    │ │ │ -0006bc20: 6167 6522 0a23 656e 6469 660a 0a09 6669  age".#endif...fi
    │ │ │ -0006bc30: 6e67 6572 7072 696e 743a 3a66 696e 6765  ngerprint::finge
    │ │ │ -0006bc40: 7270 7269 6e74 2863 6f6e 7374 2063 6861  rprint(const cha
    │ │ │ -0006bc50: 722a 2069 645f 7374 7269 6e67 2c20 696e  r* id_string, in
    │ │ │ -0006bc60: 7420 6d61 6a6f 722c 2069 6e74 206d 696e  t major, int min
    │ │ │ -0006bc70: 6f72 0a09 092c 2069 6e74 2072 6576 6973  or..., int revis
    │ │ │ -0006bc80: 696f 6e2c 2069 6e74 2074 6167 290a 0909  ion, int tag)...
    │ │ │ -0006bc90: 3a20 6d61 6a6f 725f 7665 7273 696f 6e28  : major_version(
    │ │ │ -0006bca0: 6d61 6a6f 7229 0a09 092c 206d 696e 6f72  major)..., minor
    │ │ │ -0006bcb0: 5f76 6572 7369 6f6e 286d 696e 6f72 290a  _version(minor).
    │ │ │ -0006bcc0: 0909 2c20 7265 7669 7369 6f6e 5f76 6572  .., revision_ver
    │ │ │ -0006bcd0: 7369 6f6e 2872 6576 6973 696f 6e29 0a09  sion(revision)..
    │ │ │ -0006bce0: 092c 2074 6167 5f76 6572 7369 6f6e 2874  ., tag_version(t
    │ │ │ -0006bcf0: 6167 290a 097b 0a09 0954 4f52 5245 4e54  ag)..{...TORRENT
    │ │ │ -0006bd00: 5f41 5353 4552 5428 6964 5f73 7472 696e  _ASSERT(id_strin
    │ │ │ -0006bd10: 6729 3b0a 0909 544f 5252 454e 545f 4153  g);...TORRENT_AS
    │ │ │ -0006bd20: 5345 5254 286d 616a 6f72 2026 6774 3b3d  SERT(major >=
    │ │ │ -0006bd30: 2030 293b 0a09 0954 4f52 5245 4e54 5f41   0);...TORRENT_A
    │ │ │ -0006bd40: 5353 4552 5428 6d69 6e6f 7220 2667 743b  SSERT(minor >
    │ │ │ -0006bd50: 3d20 3029 3b0a 0909 544f 5252 454e 545f  = 0);...TORRENT_
    │ │ │ -0006bd60: 4153 5345 5254 2872 6576 6973 696f 6e20  ASSERT(revision 
    │ │ │ -0006bd70: 2667 743b 3d20 3029 3b0a 0909 544f 5252  >= 0);...TORR
    │ │ │ -0006bd80: 454e 545f 4153 5345 5254 2874 6167 2026  ENT_ASSERT(tag &
    │ │ │ -0006bd90: 6774 3b3d 2030 293b 0a09 0954 4f52 5245  gt;= 0);...TORRE
    │ │ │ -0006bda0: 4e54 5f41 5353 4552 5428 7374 643a 3a73  NT_ASSERT(std::s
    │ │ │ -0006bdb0: 7472 6c65 6e28 6964 5f73 7472 696e 6729  trlen(id_string)
    │ │ │ -0006bdc0: 203d 3d20 3229 3b0a 0909 6e61 6d65 5b30   == 2);...name[0
    │ │ │ -0006bdd0: 5d20 3d20 6964 5f73 7472 696e 675b 305d  ] = id_string[0]
    │ │ │ -0006bde0: 3b0a 0909 6e61 6d65 5b31 5d20 3d20 6964  ;...name[1] = id
    │ │ │ -0006bdf0: 5f73 7472 696e 675b 315d 3b0a 097d 0a0a  _string[1];..}..
    │ │ │ -0006be00: 2369 6664 6566 205f 5f63 6c61 6e67 5f5f  #ifdef __clang__
    │ │ │ -0006be10: 0a23 7072 6167 6d61 2063 6c61 6e67 2064  .#pragma clang d
    │ │ │ -0006be20: 6961 676e 6f73 7469 6320 706f 700a 2365  iagnostic pop.#e
    │ │ │ -0006be30: 6e64 6966 0a0a 2369 6620 544f 5252 454e  ndif..#if TORREN
    │ │ │ -0006be40: 545f 4142 495f 5645 5253 494f 4e20 3d3d  T_ABI_VERSION ==
    │ │ │ -0006be50: 2031 0a09 7374 643a 3a73 7472 696e 6720   1..std::string 
    │ │ │ -0006be60: 6669 6e67 6572 7072 696e 743a 3a74 6f5f  fingerprint::to_
    │ │ │ -0006be70: 7374 7269 6e67 2829 2063 6f6e 7374 0a09  string() const..
    │ │ │ -0006be80: 7b0a 0909 7265 7475 726e 2067 656e 6572  {...return gener
    │ │ │ -0006be90: 6174 655f 6669 6e67 6572 7072 696e 7428  ate_fingerprint(
    │ │ │ -0006bea0: 7374 643a 3a73 7472 696e 6728 6e61 6d65  std::string(name
    │ │ │ -0006beb0: 2c20 3229 2c20 6d61 6a6f 725f 7665 7273  , 2), major_vers
    │ │ │ -0006bec0: 696f 6e2c 206d 696e 6f72 5f76 6572 7369  ion, minor_versi
    │ │ │ -0006bed0: 6f6e 0a09 0909 2c20 7265 7669 7369 6f6e  on...., revision
    │ │ │ -0006bee0: 5f76 6572 7369 6f6e 2c20 7461 675f 7665  _version, tag_ve
    │ │ │ -0006bef0: 7273 696f 6e29 3b0a 3c2f 7072 653e 3c2f  rsion);.
    relevan │ │ │ -0006bf30: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/perfor │ │ │ -0006bf70: 6d61 6e63 655f 636f 756e 7465 7273 2e63 mance_counters.c │ │ │ -0006bf80: 7070 3a31 373c 2f61 3e3c 2f74 643e 3c74 pp:17move stats_cou │ │ │ -0006bfa0: 6e74 6572 5f74 206f 7574 206f 6620 636f nter_t out of co │ │ │ -0006bfb0: 756e 7465 7273 3c2f 7464 3e3c 2f74 723e unters │ │ │ -0006bfc0: 3c74 7220 6964 3d22 3234 3522 2073 7479 │ │ │ -0006bff0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ -0006c000: 3c68 323e 6d6f 7665 2073 7461 7473 5f63

    move stats_c │ │ │ -0006c010: 6f75 6e74 6572 5f74 206f 7574 206f 6620 ounter_t out of │ │ │ -0006c020: 636f 756e 7465 7273 3c2f 6832 3e3c 6834 counters

    ../src/performa │ │ │ -0006c040: 6e63 655f 636f 756e 7465 7273 2e63 7070 nce_counters.cpp │ │ │ -0006c050: 3a31 373c 2f68 343e 3c70 7265 2073 7479 :17

    < │ │ │ -0006c0c0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0006c0d0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0006c100: 7372 632f 7065 7266 6f72 6d61 6e63 655f src/performance_ │ │ │ -0006c110: 636f 756e 7465 7273 2e63 7070 3a31 383c counters.cpp:18< │ │ │ -0006c120: 2f61 3e3c 2f74 643e 3c74 643e 7368 6f75 /a>shou │ │ │ -0006c130: 6c64 2062 6974 746f 7272 656e 7420 6b65 ld bittorrent ke │ │ │ -0006c140: 6570 2d61 6c69 7665 206d 6573 7361 6765 ep-alive message │ │ │ -0006c150: 7320 6861 7665 2061 2063 6f75 6e74 6572 s have a counter │ │ │ -0006c160: 2074 6f6f 3f3c 2f74 643e 3c2f 7472 3e3c too?< │ │ │ -0006c170: 7472 2069 643d 2232 3436 2220 7374 796c tr id="246" styl │ │ │ -0006c180: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -0006c190: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -0006c1a0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -0006c1b0: 6832 3e73 686f 756c 6420 6269 7474 6f72 h2>should bittor │ │ │ -0006c1c0: 7265 6e74 206b 6565 702d 616c 6976 6520 rent keep-alive │ │ │ -0006c1d0: 6d65 7373 6167 6573 2068 6176 6520 6120 messages have a │ │ │ -0006c1e0: 636f 756e 7465 7220 746f 6f3f 3c2f 6832 counter too?

    ../src/perf │ │ │ -0006c200: 6f72 6d61 6e63 655f 636f 756e 7465 7273 ormance_counters │ │ │ -0006c210: 2e63 7070 3a31 383c 2f68 343e 3c70 7265 .cpp:18

    relevance
    │ │ │ -0006c290: 266e 6273 703b 303c 2f74 643e 3c74 643e   0
    │ │ │ -0006c2a0: 3c61 2068 7265 663d 226a 6176 6173 6372  ../src/performa
    │ │ │ -0006c2d0: 6e63 655f 636f 756e 7465 7273 2e63 7070  nce_counters.cpp
    │ │ │ -0006c2e0: 3a31 393c 2f61 3e3c 2f74 643e 3c74 643e  :19
    │ │ │ -0006c2f0: 4974 2077 6f75 6c64 2062 6520 6e69 6365  It would be nice
    │ │ │ -0006c300: 2069 6620 7468 6973 2063 6f75 6c64 2062   if this could b
    │ │ │ -0006c310: 6520 616e 2069 6e74 6572 6e61 6c20 7479  e an internal ty
    │ │ │ -0006c320: 7065 2e20 6465 6661 756c 745f 6469 736b  pe. default_disk
    │ │ │ -0006c330: 5f63 6f6e 7374 7275 6374 6f72 2064 6570  _constructor dep
    │ │ │ -0006c340: 656e 6473 206f 6e20 6974 206e 6f77 3c2f  ends on it now

    It w │ │ │ -0006c3a0: 6f75 6c64 2062 6520 6e69 6365 2069 6620 ould be nice if │ │ │ -0006c3b0: 7468 6973 2063 6f75 6c64 2062 6520 616e this could be an │ │ │ -0006c3c0: 2069 6e74 6572 6e61 6c20 7479 7065 2e20 internal type. │ │ │ -0006c3d0: 6465 6661 756c 745f 6469 736b 5f63 6f6e default_disk_con │ │ │ -0006c3e0: 7374 7275 6374 6f72 2064 6570 656e 6473 structor depends │ │ │ -0006c3f0: 206f 6e20 6974 206e 6f77 3c2f 6832 3e3c on it now

    < │ │ │ -0006c400: 6834 3e2e 2e2f 7372 632f 7065 7266 6f72 h4>../src/perfor │ │ │ -0006c410: 6d61 6e63 655f 636f 756e 7465 7273 2e63 mance_counters.c │ │ │ -0006c420: 7070 3a31 393c 2f68 343e 3c70 7265 2073 pp:19
    #endif // TO
    │ │ │ -0006c470: 5252 454e 545f 4142 495f 5645 5253 494f  RRENT_ABI_VERSIO
    │ │ │ -0006c480: 4e0a 0a7d 0a0a 2f2a 0a0a 436f 7079 7269  N..}../*..Copyri
    │ │ │ -0006c490: 6768 7420 2863 2920 3230 3130 2c20 3230  ght (c) 2010, 20
    │ │ │ -0006c4a0: 3133 2d32 3032 302c 2041 7276 6964 204e  13-2020, Arvid N
    │ │ │ -0006c4b0: 6f72 6265 7267 0a43 6f70 7972 6967 6874  orberg.Copyright
    │ │ │ -0006c4c0: 2028 6329 2032 3031 362d 3230 3137 2c20   (c) 2016-2017, 
    │ │ │ -0006c4d0: 416c 6465 6e20 546f 7272 6573 0a41 6c6c  Alden Torres.All
    │ │ │ -0006c4e0: 2072 6967 6874 7320 7265 7365 7276 6564   rights reserved
    │ │ │ -0006c4f0: 2e0a 0a59 6f75 206d 6179 2075 7365 2c20  ...You may use, 
    │ │ │ -0006c500: 6469 7374 7269 6275 7465 2061 6e64 206d  distribute and m
    │ │ │ -0006c510: 6f64 6966 7920 7468 6973 2063 6f64 6520  odify this code 
    │ │ │ -0006c520: 756e 6465 7220 7468 6520 7465 726d 7320  under the terms 
    │ │ │ -0006c530: 6f66 2074 6865 2042 5344 206c 6963 656e  of the BSD licen
    │ │ │ -0006c540: 7365 2c0a 7365 6520 4c49 4345 4e53 4520  se,.see LICENSE 
    │ │ │ -0006c550: 6669 6c65 2e0a 2a2f 0a0a 2369 6e63 6c75  file..*/..#inclu
    │ │ │ -0006c560: 6465 2022 6c69 6274 6f72 7265 6e74 2f70  de "libtorrent/p
    │ │ │ -0006c570: 6572 666f 726d 616e 6365 5f63 6f75 6e74  erformance_count
    │ │ │ -0006c580: 6572 732e 6870 7022 0a23 696e 636c 7564  ers.hpp".#includ
    │ │ │ -0006c590: 6520 226c 6962 746f 7272 656e 742f 6173  e "libtorrent/as
    │ │ │ -0006c5a0: 7365 7274 2e68 7070 220a 2369 6e63 6c75  sert.hpp".#inclu
    │ │ │ -0006c5b0: 6465 2026 6c74 3b63 7374 7269 6e67 2667  de <cstring&g
    │ │ │ -0006c5c0: 743b 202f 2f20 666f 7220 6d65 6d73 6574  t; // for memset
    │ │ │ -0006c5d0: 0a0a 6e61 6d65 7370 6163 6520 6c69 6274  ..namespace libt
    │ │ │ -0006c5e0: 6f72 7265 6e74 207b 0a0a 3c64 6976 2073  orrent {..
    .counter │ │ │ -0006c620: 733a 3a63 6f75 6e74 6572 7328 2920 544f s::counters() TO │ │ │ -0006c630: 5252 454e 545f 434f 554e 5445 525f 4e4f RRENT_COUNTER_NO │ │ │ -0006c640: 4558 4345 5054 0a3c 2f64 6976 3e09 7b0a EXCEPT.
    .{. │ │ │ -0006c650: 2369 6664 6566 2041 544f 4d49 435f 4c4c #ifdef ATOMIC_LL │ │ │ -0006c660: 4f4e 475f 4c4f 434b 5f46 5245 450a 0909 ONG_LOCK_FREE... │ │ │ -0006c670: 666f 7220 2861 7574 6f26 616d 703b 2063 for (auto& c │ │ │ -0006c680: 6f75 6e74 6572 203a 206d 5f73 7461 7473 ounter : m_stats │ │ │ -0006c690: 5f63 6f75 6e74 6572 290a 0909 0963 6f75 _counter)....cou │ │ │ -0006c6a0: 6e74 6572 2e73 746f 7265 2830 2c20 7374 nter.store(0, st │ │ │ -0006c6b0: 643a 3a6d 656d 6f72 795f 6f72 6465 725f d::memory_order_ │ │ │ -0006c6c0: 7265 6c61 7865 6429 3b0a 2365 6c73 650a relaxed);.#else. │ │ │ -0006c6d0: 0909 6d5f 7374 6174 735f 636f 756e 7465 ..m_stats_counte │ │ │ -0006c6e0: 722e 6669 6c6c 2830 293b 0a23 656e 6469 r.fill(0);.#endi │ │ │ -0006c6f0: 660a 097d 0a0a 0963 6f75 6e74 6572 733a f..}...counters: │ │ │ -0006c700: 3a63 6f75 6e74 6572 7328 636f 756e 7465 :counters(counte │ │ │ -0006c710: 7273 2063 6f6e 7374 2661 6d70 3b20 6329 rs const& c) │ │ │ -0006c720: 2054 4f52 5245 4e54 5f43 4f55 4e54 4552 TORRENT_COUNTER │ │ │ -0006c730: 5f4e 4f45 5843 4550 540a 097b 0a23 6966 _NOEXCEPT..{.#if │ │ │ -0006c740: 6465 6620 4154 4f4d 4943 5f4c 4c4f 4e47 def ATOMIC_LLONG │ │ │ -0006c750: 5f4c 4f43 4b5f 4652 4545 0a09 0966 6f72 _LOCK_FREE...for │ │ │ -0006c760: 2028 696e 7420 6920 3d20 303b 2069 2026 (int i = 0; i & │ │ │ -0006c770: 6c74 3b20 6d5f 7374 6174 735f 636f 756e lt; m_stats_coun │ │ │ -0006c780: 7465 722e 656e 645f 696e 6465 7828 293b ter.end_index(); │ │ │ -0006c790: 202b 2b69 290a 0909 096d 5f73 7461 7473 ++i)....m_stats │ │ │ -0006c7a0: 5f63 6f75 6e74 6572 5b69 5d2e 7374 6f72 _counter[i].stor │ │ │ -0006c7b0: 6528 0a09 0909 0963 2e6d 5f73 7461 7473 e(.....c.m_stats │ │ │ -0006c7c0: 5f63 6f75 6e74 6572 5b69 5d2e 6c6f 6164 _counter[i].load │ │ │ -0006c7d0: 2873 7464 3a3a 6d65 6d6f 7279 5f6f 7264 (std::memory_ord │ │ │ -0006c7e0: 6572 5f72 656c 6178 6564 290a 0909 0909 er_relaxed)..... │ │ │ -0006c7f0: 092c 2073 7464 3a3a 6d65 6d6f 7279 5f6f ., std::memory_o │ │ │ -0006c800: 7264 6572 5f72 656c 6178 6564 293b 0a23 rder_relaxed);.# │ │ │ -0006c810: 656c 7365 0a09 0973 7464 3a3a 6c6f 636b else...std::lock │ │ │ -0006c820: 5f67 7561 7264 266c 743b 7374 643a 3a6d _guard<std::m │ │ │ -0006c830: 7574 6578 2667 743b 206c 2863 2e6d 5f6d utex> l(c.m_m │ │ │ -0006c840: 7574 6578 293b 0a09 096d 5f73 7461 7473 utex);...m_stats │ │ │ -0006c850: 5f63 6f75 6e74 6572 203d 2063 2e6d 5f73 _counter = c.m_s │ │ │ -0006c860: 7461 7473 5f63 6f75 6e74 6572 3b0a 2365 tats_counter;.#e │ │ │ -0006c870: 6e64 6966 0a09 7d0a 0a09 636f 756e 7465 ndif..}...counte │ │ │ -0006c880: 7273 2661 6d70 3b20 636f 756e 7465 7273 rs& counters │ │ │ -0006c890: 3a3a 6f70 6572 6174 6f72 3d28 636f 756e ::operator=(coun │ │ │ -0006c8a0: 7465 7273 2063 6f6e 7374 2661 6d70 3b20 ters const& │ │ │ -0006c8b0: 6329 2026 616d 703b 2054 4f52 5245 4e54 c) & TORRENT │ │ │ -0006c8c0: 5f43 4f55 4e54 4552 5f4e 4f45 5843 4550 _COUNTER_NOEXCEP │ │ │ -0006c8d0: 540a 097b 0a09 0969 6620 2826 616d 703b T..{...if (& │ │ │ -0006c8e0: 6320 3d3d 2074 6869 7329 2072 6574 7572 c == this) retur │ │ │ -0006c8f0: 6e20 2a74 6869 733b 0a23 6966 6465 6620 n *this;.#ifdef │ │ │ -0006c900: 4154 4f4d 4943 5f4c 4c4f 4e47 5f4c 4f43 ATOMIC_LLONG_LOC │ │ │ -0006c910: 4b5f 4652 4545 0a09 0966 6f72 2028 696e K_FREE...for (in │ │ │ -0006c920: 7420 6920 3d20 303b 2069 2026 6c74 3b20 t i = 0; i < │ │ │ -0006c930: 6d5f 7374 6174 735f 636f 756e 7465 722e m_stats_counter. │ │ │ -0006c940: 656e 645f 696e 6465 7828 293b 202b 2b69 end_index(); ++i │ │ │ -0006c950: 290a 0909 096d 5f73 7461 7473 5f63 6f75 )....m_stats_cou │ │ │ -0006c960: 6e74 6572 5b69 5d2e 7374 6f72 6528 0a09 nter[i].store(.. │ │ │ -0006c970: 0909 0963 2e6d 5f73 7461 7473 5f63 6f75 ...c.m_stats_cou │ │ │ -0006c980: 6e74 6572 5b69 5d2e 6c6f 6164 2873 7464 nter[i].load(std │ │ │ -0006c990: 3a3a 6d65 6d6f 7279 5f6f 7264 6572 5f72 ::memory_order_r │ │ │ -0006c9a0: 656c 6178 6564 290a 0909 0909 092c 2073 elaxed)......, s │ │ │ -0006c9b0: 7464 3a3a 6d65 6d6f 7279 5f6f 7264 6572 td::memory_order │ │ │ -0006c9c0: 5f72 656c 6178 6564 293b 0a3c 2f70 7265 _relaxed);.
    rele │ │ │ -0006ca00: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/kad │ │ │ -0006ca40: 656d 6c69 612f 6974 656d 2e63 7070 3a31 emlia/item.cpp:1 │ │ │ -0006ca50: 3333 3c2f 613e 3c2f 7464 3e3c 7464 3e69 33i │ │ │ -0006ca60: 6d70 6c65 6d65 6e74 2063 746f 7220 666f mplement ctor fo │ │ │ -0006ca70: 7220 656e 7472 7920 6672 6f6d 2062 6465 r entry from bde │ │ │ -0006ca80: 636f 6465 5f6e 6f64 653f 3c2f 7464 3e3c code_node?< │ │ │ -0006ca90: 2f74 723e 3c74 7220 6964 3d22 3234 3822 /tr>

    implemen │ │ │ -0006cae0: 7420 6374 6f72 2066 6f72 2065 6e74 7279 t ctor for entry │ │ │ -0006caf0: 2066 726f 6d20 6264 6563 6f64 655f 6e6f from bdecode_no │ │ │ -0006cb00: 6465 3f3c 2f68 323e 3c68 343e 2e2e 2f73 de?

    ../s │ │ │ -0006cb10: 7263 2f6b 6164 656d 6c69 612f 6974 656d rc/kademlia/item │ │ │ -0006cb20: 2e63 7070 3a31 3333 3c2f 6834 3e3c 7072 .cpp:133

    ., secret │ │ │ -0006cb70: 5f6b 6579 2063 6f6e 7374 2661 6d70 3b20 _key const& │ │ │ -0006cb80: 736b 290a 7b0a 0963 6861 7220 7374 725b sk).{..char str[ │ │ │ -0006cb90: 3132 3030 5d3b 0a09 696e 7420 636f 6e73 1200];..int cons │ │ │ -0006cba0: 7420 6c65 6e20 3d20 6361 6e6f 6e69 6361 t len = canonica │ │ │ -0006cbb0: 6c5f 7374 7269 6e67 2876 2c20 7365 712c l_string(v, seq, │ │ │ -0006cbc0: 2073 616c 742c 2073 7472 293b 0a0a 0972 salt, str);...r │ │ │ -0006cbd0: 6574 7572 6e20 6564 3235 3531 395f 7369 eturn ed25519_si │ │ │ -0006cbe0: 676e 287b 7374 722c 206c 656e 7d2c 2070 gn({str, len}, p │ │ │ -0006cbf0: 6b2c 2073 6b29 3b0a 7d0a 0a69 7465 6d3a k, sk);.}..item: │ │ │ -0006cc00: 3a69 7465 6d28 7075 626c 6963 5f6b 6579 :item(public_key │ │ │ -0006cc10: 2063 6f6e 7374 2661 6d70 3b20 706b 2c20 const& pk, │ │ │ -0006cc20: 7370 616e 266c 743b 6368 6172 2063 6f6e span<char con │ │ │ -0006cc30: 7374 2667 743b 2073 616c 7429 0a09 3a20 st> salt)..: │ │ │ -0006cc40: 6d5f 7361 6c74 2873 616c 742e 6461 7461 m_salt(salt.data │ │ │ -0006cc50: 2829 2c20 7374 6174 6963 5f63 6173 7426 (), static_cast& │ │ │ -0006cc60: 6c74 3b73 7464 3a3a 7369 7a65 5f74 2667 lt;std::size_t&g │ │ │ -0006cc70: 743b 2873 616c 742e 7369 7a65 2829 2929 t;(salt.size())) │ │ │ -0006cc80: 0a09 2c20 6d5f 706b 2870 6b29 0a09 2c20 .., m_pk(pk).., │ │ │ -0006cc90: 6d5f 6d75 7461 626c 6528 7472 7565 290a m_mutable(true). │ │ │ -0006cca0: 7b7d 0a0a 6974 656d 3a3a 6974 656d 2865 {}..item::item(e │ │ │ -0006ccb0: 6e74 7279 2076 290a 093a 206d 5f76 616c ntry v)..: m_val │ │ │ -0006ccc0: 7565 2873 7464 3a3a 6d6f 7665 2876 2929 ue(std::move(v)) │ │ │ -0006ccd0: 0a7b 7d0a 0a69 7465 6d3a 3a69 7465 6d28 .{}..item::item( │ │ │ -0006cce0: 6264 6563 6f64 655f 6e6f 6465 2063 6f6e bdecode_node con │ │ │ -0006ccf0: 7374 2661 6d70 3b20 7629 0a7b 0a3c 6469 st& v).{..m_va │ │ │ -0006cd30: 6c75 6520 3d20 763b 0a3c 2f64 6976 3e7d lue = v;.} │ │ │ -0006cd40: 0a0a 6974 656d 3a3a 6974 656d 2865 6e74 ..item::item(ent │ │ │ -0006cd50: 7279 2076 2c20 7370 616e 266c 743b 6368 ry v, span<ch │ │ │ -0006cd60: 6172 2063 6f6e 7374 2667 743b 2073 616c ar const> sal │ │ │ -0006cd70: 740a 092c 2073 6571 7565 6e63 655f 6e75 t.., sequence_nu │ │ │ -0006cd80: 6d62 6572 2063 6f6e 7374 2073 6571 2c20 mber const seq, │ │ │ -0006cd90: 7075 626c 6963 5f6b 6579 2063 6f6e 7374 public_key const │ │ │ -0006cda0: 2661 6d70 3b20 706b 2c20 7365 6372 6574 & pk, secret │ │ │ -0006cdb0: 5f6b 6579 2063 6f6e 7374 2661 6d70 3b20 _key const& │ │ │ -0006cdc0: 736b 290a 7b0a 0961 7373 6967 6e28 7374 sk).{..assign(st │ │ │ -0006cdd0: 643a 3a6d 6f76 6528 7629 2c20 7361 6c74 d::move(v), salt │ │ │ -0006cde0: 2c20 7365 712c 2070 6b2c 2073 6b29 3b0a , seq, pk, sk);. │ │ │ -0006cdf0: 7d0a 0a76 6f69 6420 6974 656d 3a3a 6173 }..void item::as │ │ │ -0006ce00: 7369 676e 2865 6e74 7279 2076 290a 7b0a sign(entry v).{. │ │ │ -0006ce10: 096d 5f6d 7574 6162 6c65 203d 2066 616c .m_mutable = fal │ │ │ -0006ce20: 7365 3b0a 096d 5f76 616c 7565 203d 2073 se;..m_value = s │ │ │ -0006ce30: 7464 3a3a 6d6f 7665 2876 293b 0a7d 0a0a td::move(v);.}.. │ │ │ -0006ce40: 766f 6964 2069 7465 6d3a 3a61 7373 6967 void item::assig │ │ │ -0006ce50: 6e28 656e 7472 7920 762c 2073 7061 6e26 n(entry v, span& │ │ │ -0006ce60: 6c74 3b63 6861 7220 636f 6e73 7426 6774 lt;char const> │ │ │ -0006ce70: 3b20 7361 6c74 0a09 2c20 7365 7175 656e ; salt.., sequen │ │ │ -0006ce80: 6365 5f6e 756d 6265 7220 636f 6e73 7420 ce_number const │ │ │ -0006ce90: 7365 712c 2070 7562 6c69 635f 6b65 7920 seq, public_key │ │ │ -0006cea0: 636f 6e73 7426 616d 703b 2070 6b2c 2073 const& pk, s │ │ │ -0006ceb0: 6563 7265 745f 6b65 7920 636f 6e73 7426 ecret_key const& │ │ │ -0006cec0: 616d 703b 2073 6b29 0a7b 0a09 7374 643a amp; sk).{..std: │ │ │ -0006ced0: 3a61 7272 6179 266c 743b 6368 6172 2c20 :array<char, │ │ │ -0006cee0: 3130 3030 2667 743b 2062 7566 6665 723b 1000> buffer; │ │ │ -0006cef0: 0a09 696e 7420 636f 6e73 7420 6273 697a ..int const bsiz │ │ │ -0006cf00: 6520 3d20 6265 6e63 6f64 6528 6275 6666 e = bencode(buff │ │ │ -0006cf10: 6572 2e62 6567 696e 2829 2c20 7629 3b0a er.begin(), v);. │ │ │ -0006cf20: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -0006cf30: 6273 697a 6520 266c 743b 3d20 3130 3030 bsize <= 1000 │ │ │ -0006cf40: 293b 0a09 6d5f 7369 6720 3d20 7369 676e );..m_sig = sign │ │ │ -0006cf50: 5f6d 7574 6162 6c65 5f69 7465 6d28 7370 _mutable_item(sp │ │ │ -0006cf60: 616e 266c 743b 6368 6172 2063 6f6e 7374 an<char const │ │ │ -0006cf70: 2667 743b 2862 7566 6665 7229 2e66 6972 >(buffer).fir │ │ │ -0006cf80: 7374 2862 7369 7a65 290a 0909 2c20 7361 st(bsize)..., sa │ │ │ -0006cf90: 6c74 2c20 7365 712c 2070 6b2c 2073 6b29 lt, seq, pk, sk) │ │ │ -0006cfa0: 3b0a 096d 5f73 616c 742e 6173 7369 676e ;..m_salt.assign │ │ │ -0006cfb0: 2873 616c 742e 6461 7461 2829 2c20 7374 (salt.data(), st │ │ │ -0006cfc0: 6174 6963 5f63 6173 7426 6c74 3b73 7464 atic_cast<std │ │ │ -0006cfd0: 3a3a 7369 7a65 5f74 2667 743b 2873 616c ::size_t>(sal │ │ │ -0006cfe0: 742e 7369 7a65 2829 2929 3b0a 096d 5f70 t.size()));..m_p │ │ │ -0006cff0: 6b20 3d20 706b 3b0a 096d 5f73 6571 203d k = pk;..m_seq = │ │ │ -0006d000: 2073 6571 3b0a 096d 5f6d 7574 6162 6c65 seq;..m_mutable │ │ │ -0006d010: 203d 2074 7275 653b 0a09 6d5f 7661 6c75 = true;..m_valu │ │ │ -0006d020: 6520 3d20 7374 643a 3a6d 6f76 6528 7629 e = std::move(v) │ │ │ -0006d030: 3b0a 7d0a 0a76 6f69 6420 6974 656d 3a3a ;.}..void item:: │ │ │ -0006d040: 6173 7369 676e 2862 6465 636f 6465 5f6e assign(bdecode_n │ │ │ -0006d050: 6f64 6520 636f 6e73 7426 616d 703b 2076 ode const& v │ │ │ -0006d060: 290a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ).
    < │ │ │ -0006d090: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0006d0a0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0006d0d0: 7372 632f 6b61 6465 6d6c 6961 2f6e 6f64 src/kademlia/nod │ │ │ -0006d0e0: 655f 6964 2e63 7070 3a34 333c 2f61 3e3c e_id.cpp:43< │ │ │ -0006d0f0: 2f74 643e 3c74 643e 6974 2773 2061 206c /td>it's a l │ │ │ -0006d100: 6974 746c 6520 6269 7420 7765 6972 6420 ittle bit weird │ │ │ -0006d110: 746f 2072 6574 7572 6e20 3135 3920 2d20 to return 159 - │ │ │ -0006d120: 6c65 6164 696e 6720 7a65 726f 6573 2e20 leading zeroes. │ │ │ -0006d130: 4974 2073 686f 756c 6420 7072 6f62 6162 It should probab │ │ │ -0006d140: 6c79 2062 6520 3136 3020 2d20 6c65 6164 ly be 160 - lead │ │ │ -0006d150: 696e 6720 7a65 726f 6573 2c20 6275 7420 ing zeroes, but │ │ │ -0006d160: 616c 6c20 6f74 6865 7220 636f 6465 2069 all other code i │ │ │ -0006d170: 6e20 6865 7265 2069 7320 7475 6e65 6420 n here is tuned │ │ │ -0006d180: 746f 2074 6869 7320 6578 7065 6374 6174 to this expectat │ │ │ -0006d190: 696f 6e20 6e6f 772c 2061 6e64 2069 7420 ion now, and it │ │ │ -0006d1a0: 646f 6573 6e27 7420 7265 616c 6c79 206d doesn't really m │ │ │ -0006d1b0: 6174 7465 7220 286f 7468 6572 2074 6861 atter (other tha │ │ │ -0006d1c0: 6e20 636f 6d70 6c65 7869 7479 293c 2f74 n complexity)

    it's │ │ │ -0006d220: 6120 6c69 7474 6c65 2062 6974 2077 6569 a little bit wei │ │ │ -0006d230: 7264 2074 6f20 7265 7475 726e 2031 3539 rd to return 159 │ │ │ -0006d240: 202d 206c 6561 6469 6e67 207a 6572 6f65 - leading zeroe │ │ │ -0006d250: 732e 2049 7420 7368 6f75 6c64 0a70 726f s. It should.pro │ │ │ -0006d260: 6261 626c 7920 6265 2031 3630 202d 206c bably be 160 - l │ │ │ -0006d270: 6561 6469 6e67 207a 6572 6f65 732c 2062 eading zeroes, b │ │ │ -0006d280: 7574 2061 6c6c 206f 7468 6572 2063 6f64 ut all other cod │ │ │ -0006d290: 6520 696e 2068 6572 6520 6973 2074 756e e in here is tun │ │ │ -0006d2a0: 6564 2074 6f0a 7468 6973 2065 7870 6563 ed to.this expec │ │ │ -0006d2b0: 7461 7469 6f6e 206e 6f77 2c20 616e 6420 tation now, and │ │ │ -0006d2c0: 6974 2064 6f65 736e 2774 2072 6561 6c6c it doesn't reall │ │ │ -0006d2d0: 7920 6d61 7474 6572 2028 6f74 6865 7220 y matter (other │ │ │ -0006d2e0: 7468 616e 2063 6f6d 706c 6578 6974 7929 than complexity) │ │ │ -0006d2f0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -0006d300: 6b61 6465 6d6c 6961 2f6e 6f64 655f 6964 kademlia/node_id │ │ │ -0006d310: 2e63 7070 3a34 333c 2f68 343e 3c70 7265 .cpp:43

    .// return
    │ │ │ -0006d360: 7320 7468 6520 6469 7374 616e 6365 2062  s the distance b
    │ │ │ -0006d370: 6574 7765 656e 2074 6865 2074 776f 206e  etween the two n
    │ │ │ -0006d380: 6f64 6573 0a2f 2f20 7573 696e 6720 7468  odes.// using th
    │ │ │ -0006d390: 6520 6b61 6465 6d6c 6961 2058 4f52 2d6d  e kademlia XOR-m
    │ │ │ -0006d3a0: 6574 7269 630a 6e6f 6465 5f69 6420 6469  etric.node_id di
    │ │ │ -0006d3b0: 7374 616e 6365 286e 6f64 655f 6964 2063  stance(node_id c
    │ │ │ -0006d3c0: 6f6e 7374 2661 6d70 3b20 6e31 2c20 6e6f  onst& n1, no
    │ │ │ -0006d3d0: 6465 5f69 6420 636f 6e73 7426 616d 703b  de_id const&
    │ │ │ -0006d3e0: 206e 3229 0a7b 0a09 7265 7475 726e 206e   n2).{..return n
    │ │ │ -0006d3f0: 3120 5e20 6e32 3b0a 7d0a 0a2f 2f20 7265  1 ^ n2;.}..// re
    │ │ │ -0006d400: 7475 726e 7320 7472 7565 2069 663a 2064  turns true if: d
    │ │ │ -0006d410: 6973 7461 6e63 6528 6e31 2c20 7265 6629  istance(n1, ref)
    │ │ │ -0006d420: 2026 6c74 3b20 6469 7374 616e 6365 286e   < distance(n
    │ │ │ -0006d430: 322c 2072 6566 290a 626f 6f6c 2063 6f6d  2, ref).bool com
    │ │ │ -0006d440: 7061 7265 5f72 6566 286e 6f64 655f 6964  pare_ref(node_id
    │ │ │ -0006d450: 2063 6f6e 7374 2661 6d70 3b20 6e31 2c20   const& n1, 
    │ │ │ -0006d460: 6e6f 6465 5f69 6420 636f 6e73 7426 616d  node_id const&am
    │ │ │ -0006d470: 703b 206e 322c 206e 6f64 655f 6964 2063  p; n2, node_id c
    │ │ │ -0006d480: 6f6e 7374 2661 6d70 3b20 7265 6629 0a7b  onst& ref).{
    │ │ │ -0006d490: 0a09 6e6f 6465 5f69 6420 636f 6e73 7420  ..node_id const 
    │ │ │ -0006d4a0: 6c68 7320 3d20 6e31 205e 2072 6566 3b0a  lhs = n1 ^ ref;.
    │ │ │ -0006d4b0: 096e 6f64 655f 6964 2063 6f6e 7374 2072  .node_id const r
    │ │ │ -0006d4c0: 6873 203d 206e 3220 5e20 7265 663b 0a09  hs = n2 ^ ref;..
    │ │ │ -0006d4d0: 7265 7475 726e 206c 6873 2026 6c74 3b20  return lhs < 
    │ │ │ -0006d4e0: 7268 733b 0a7d 0a0a 2f2f 2072 6574 7572  rhs;.}..// retur
    │ │ │ -0006d4f0: 6e73 206e 2069 6e3a 2032 5e6e 2026 6c74  ns n in: 2^n <
    │ │ │ -0006d500: 3b3d 2064 6973 7461 6e63 6528 6e31 2c20  ;= distance(n1, 
    │ │ │ -0006d510: 6e32 2920 266c 743b 2032 5e28 6e2b 3129  n2) < 2^(n+1)
    │ │ │ -0006d520: 0a2f 2f20 7573 6566 756c 2066 6f72 2066  .// useful for f
    │ │ │ -0006d530: 696e 6469 6e67 206f 7574 2077 6869 6368  inding out which
    │ │ │ -0006d540: 2062 7563 6b65 7420 6120 6e6f 6465 2062   bucket a node b
    │ │ │ -0006d550: 656c 6f6e 6773 2074 6f0a 696e 7420 6469  elongs to.int di
    │ │ │ -0006d560: 7374 616e 6365 5f65 7870 286e 6f64 655f  stance_exp(node_
    │ │ │ -0006d570: 6964 2063 6f6e 7374 2661 6d70 3b20 6e31  id const& n1
    │ │ │ -0006d580: 2c20 6e6f 6465 5f69 6420 636f 6e73 7426  , node_id const&
    │ │ │ -0006d590: 616d 703b 206e 3229 0a7b 0a3c 6469 7620  amp; n2).{.
    .return │ │ │ -0006d5d0: 2073 7464 3a3a 6d61 7828 3135 3920 2d20 std::max(159 - │ │ │ -0006d5e0: 6469 7374 616e 6365 286e 312c 206e 3229 distance(n1, n2) │ │ │ -0006d5f0: 2e63 6f75 6e74 5f6c 6561 6469 6e67 5f7a .count_leading_z │ │ │ -0006d600: 6572 6f65 7328 292c 2030 293b 0a3c 2f64 eroes(), 0);.}..int min_di │ │ │ -0006d620: 7374 616e 6365 5f65 7870 286e 6f64 655f stance_exp(node_ │ │ │ -0006d630: 6964 2063 6f6e 7374 2661 6d70 3b20 6e31 id const& n1 │ │ │ -0006d640: 2c20 7374 643a 3a76 6563 746f 7226 6c74 , std::vector< │ │ │ -0006d650: 3b6e 6f64 655f 6964 2667 743b 2063 6f6e ;node_id> con │ │ │ -0006d660: 7374 2661 6d70 3b20 6964 7329 0a7b 0a09 st& ids).{.. │ │ │ -0006d670: 544f 5252 454e 545f 4153 5345 5254 2869 TORRENT_ASSERT(i │ │ │ -0006d680: 6473 2e73 697a 6528 2920 2667 743b 2030 ds.size() > 0 │ │ │ -0006d690: 293b 0a0a 0969 6e74 206d 696e 203d 2031 );...int min = 1 │ │ │ -0006d6a0: 3630 3b20 2f2f 2073 6565 2064 6973 7461 60; // see dista │ │ │ -0006d6b0: 6e63 655f 6578 7020 666f 7220 7468 6520 nce_exp for the │ │ │ -0006d6c0: 7768 7920 6f66 2074 6869 7320 636f 6e73 why of this cons │ │ │ -0006d6d0: 7461 6e74 0a09 666f 7220 2861 7574 6f20 tant..for (auto │ │ │ -0006d6e0: 636f 6e73 7426 616d 703b 206e 6f64 655f const& node_ │ │ │ -0006d6f0: 6964 203a 2069 6473 290a 097b 0a09 096d id : ids)..{...m │ │ │ -0006d700: 696e 203d 2073 7464 3a3a 6d69 6e28 6d69 in = std::min(mi │ │ │ -0006d710: 6e2c 2064 6973 7461 6e63 655f 6578 7028 n, distance_exp( │ │ │ -0006d720: 6e31 2c20 6e6f 6465 5f69 6429 293b 0a09 n1, node_id));.. │ │ │ -0006d730: 7d0a 0a09 7265 7475 726e 206d 696e 3b0a }...return min;. │ │ │ -0006d740: 7d0a 0a6e 6f64 655f 6964 2067 656e 6572 }..node_id gener │ │ │ -0006d750: 6174 655f 6964 5f69 6d70 6c28 6164 6472 ate_id_impl(addr │ │ │ -0006d760: 6573 7320 636f 6e73 7426 616d 703b 2069 ess const& i │ │ │ -0006d770: 705f 2c20 7374 643a 3a75 696e 7433 325f p_, std::uint32_ │ │ │ -0006d780: 7420 7229 0a7b 0a09 7374 643a 3a75 696e t r).{..std::uin │ │ │ -0006d790: 7438 5f74 2a20 6970 203d 206e 756c 6c70 t8_t* ip = nullp │ │ │ -0006d7a0: 7472 3b0a 0a09 7374 6174 6963 2073 7464 tr;...static std │ │ │ -0006d7b0: 3a3a 7569 6e74 385f 7420 636f 6e73 7420 ::uint8_t const │ │ │ -0006d7c0: 7634 6d61 736b 5b5d 203d 207b 2030 7830 v4mask[] = { 0x0 │ │ │ -0006d7d0: 332c 2030 7830 662c 2030 7833 662c 2030 3, 0x0f, 0x3f, 0 │ │ │ -0006d7e0: 7866 6620 7d3b 0a09 7374 6174 6963 2073 xff };..static s │ │ │ -0006d7f0: 7464 3a3a 7569 6e74 385f 7420 636f 6e73 td::uint8_t cons │ │ │ -0006d800: 7420 7636 6d61 736b 5b5d 203d 207b 2030 t v6mask[] = { 0 │ │ │ -0006d810: 7830 312c 2030 7830 332c 2030 7830 372c x01, 0x03, 0x07, │ │ │ -0006d820: 2030 7830 662c 2030 7831 662c 2030 7833 0x0f, 0x1f, 0x3 │ │ │ -0006d830: 662c 2030 7837 662c 2030 7866 6620 7d3b f, 0x7f, 0xff }; │ │ │ -0006d840: 0a09 7374 643a 3a75 696e 7438 5f74 2063 ..std::uint8_t c │ │ │ -0006d850: 6f6e 7374 2a20 6d61 736b 203d 206e 756c onst* mask = nul │ │ │ -0006d860: 6c70 7472 3b0a 0969 6e74 206e 756d 5f6f lptr;..int num_o │ │ │ -0006d870: 6374 6574 7320 3d20 303b 0a0a 0961 6464 ctets = 0;...add │ │ │ -0006d880: 7265 7373 5f76 343a 3a62 7974 6573 5f74 ress_v4::bytes_t │ │ │ -0006d890: 7970 6520 6234 7b7d 3b0a 0961 6464 7265 ype b4{};..addre │ │ │ -0006d8a0: 7373 5f76 363a 3a62 7974 6573 5f74 7970 ss_v6::bytes_typ │ │ │ -0006d8b0: 6520 6236 7b7d 3b0a 0969 6620 2869 705f e b6{};..if (ip_ │ │ │ -0006d8c0: 2e69 735f 7636 2829 290a 097b 0a09 0962 .is_v6())..{...b │ │ │ -0006d8d0: 3620 3d20 6970 5f2e 746f 5f76 3628 292e 6 = ip_.to_v6(). │ │ │ -0006d8e0: 746f 5f62 7974 6573 2829 3b0a 0909 6970 to_bytes();...ip │ │ │ -0006d8f0: 203d 2062 362e 6461 7461 2829 3b0a 3c2f = b6.data();.r │ │ │ -0006d930: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -0006d940: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ -0006d970: 6b61 6465 6d6c 6961 2f70 7574 5f64 6174 kademlia/put_dat │ │ │ -0006d980: 612e 6370 703a 3639 3c2f 613e 3c2f 7464 a.cpp:69what if o i │ │ │ -0006d9a0: 7320 6e6f 7420 616e 2069 6e73 7461 6e63 s not an instanc │ │ │ -0006d9b0: 6520 6f66 2070 7574 5f64 6174 615f 6f62 e of put_data_ob │ │ │ -0006d9c0: 7365 7276 6572 3f20 5468 6973 206e 6565 server? This nee │ │ │ -0006d9d0: 6420 746f 2062 6520 7265 6465 7369 676e d to be redesign │ │ │ -0006d9e0: 6564 2066 6f72 2062 6574 7465 7220 7479 ed for better ty │ │ │ -0006d9f0: 7065 2073 6166 6574 792e 3c2f 7464 3e3c pe safety.< │ │ │ -0006da00: 2f74 723e 3c74 7220 6964 3d22 3235 3022 /tr>

    what if │ │ │ -0006da50: 6f20 6973 206e 6f74 2061 6e20 696e 7374 o is not an inst │ │ │ -0006da60: 616e 6365 206f 6620 7075 745f 6461 7461 ance of put_data │ │ │ -0006da70: 5f6f 6273 6572 7665 723f 2054 6869 7320 _observer? This │ │ │ -0006da80: 6e65 6564 2074 6f20 6265 0a72 6564 6573 need to be.redes │ │ │ -0006da90: 6967 6e65 6420 666f 7220 6265 7474 6572 igned for better │ │ │ -0006daa0: 2074 7970 6520 7361 6665 7479 2e3c 2f68 type safety.

    ../src/kad │ │ │ -0006dac0: 656d 6c69 612f 7075 745f 6461 7461 2e63 emlia/put_data.c │ │ │ -0006dad0: 7070 3a36 393c 2f68 343e 3c70 7265 2073 pp:69

    .}.}..void p
    │ │ │ -0006db20: 7574 5f64 6174 613a 3a64 6f6e 6528 290a  ut_data::done().
    │ │ │ -0006db30: 7b0a 096d 5f64 6f6e 6520 3d20 7472 7565  {..m_done = true
    │ │ │ -0006db40: 3b0a 0a23 6966 6e64 6566 2054 4f52 5245  ;..#ifndef TORRE
    │ │ │ -0006db50: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749  NT_DISABLE_LOGGI
    │ │ │ -0006db60: 4e47 0a09 6765 745f 6e6f 6465 2829 2e6f  NG..get_node().o
    │ │ │ -0006db70: 6273 6572 7665 7228 292d 2667 743b 6c6f  bserver()->lo
    │ │ │ -0006db80: 6728 6468 745f 6c6f 6767 6572 3a3a 7472  g(dht_logger::tr
    │ │ │ -0006db90: 6176 6572 7361 6c2c 2022 5b25 755d 2025  aversal, "[%u] %
    │ │ │ -0006dba0: 7320 444f 4e45 2c20 7265 7370 6f6e 7365  s DONE, response
    │ │ │ -0006dbb0: 2025 642c 2074 696d 656f 7574 2025 6422   %d, timeout %d"
    │ │ │ -0006dbc0: 0a09 092c 2069 6428 292c 206e 616d 6528  ..., id(), name(
    │ │ │ -0006dbd0: 292c 206e 756d 5f72 6573 706f 6e73 6573  ), num_responses
    │ │ │ -0006dbe0: 2829 2c20 6e75 6d5f 7469 6d65 6f75 7473  (), num_timeouts
    │ │ │ -0006dbf0: 2829 293b 0a23 656e 6469 660a 0a09 6d5f  ());.#endif...m_
    │ │ │ -0006dc00: 7075 745f 6361 6c6c 6261 636b 286d 5f64  put_callback(m_d
    │ │ │ -0006dc10: 6174 612c 206e 756d 5f72 6573 706f 6e73  ata, num_respons
    │ │ │ -0006dc20: 6573 2829 293b 0a09 7472 6176 6572 7361  es());..traversa
    │ │ │ -0006dc30: 6c5f 616c 676f 7269 7468 6d3a 3a64 6f6e  l_algorithm::don
    │ │ │ -0006dc40: 6528 293b 0a7d 0a0a 626f 6f6c 2070 7574  e();.}..bool put
    │ │ │ -0006dc50: 5f64 6174 613a 3a69 6e76 6f6b 6528 6f62  _data::invoke(ob
    │ │ │ -0006dc60: 7365 7276 6572 5f70 7472 206f 290a 7b0a  server_ptr o).{.
    │ │ │ -0006dc70: 0969 6620 286d 5f64 6f6e 6529 2072 6574  .if (m_done) ret
    │ │ │ -0006dc80: 7572 6e20 6661 6c73 653b 0a0a 3c64 6976  urn false;..
    .auto* │ │ │ -0006dcc0: 2070 6f20 3d20 7374 6174 6963 5f63 6173 po = static_cas │ │ │ -0006dcd0: 7426 6c74 3b70 7574 5f64 6174 615f 6f62 t<put_data_ob │ │ │ -0006dce0: 7365 7276 6572 2a26 6774 3b28 6f2e 6765 server*>(o.ge │ │ │ -0006dcf0: 7428 2929 3b0a 3c2f 6469 763e 0a09 656e t());.
    ..en │ │ │ -0006dd00: 7472 7920 653b 0a09 655b 2279 225d 203d try e;..e["y"] = │ │ │ -0006dd10: 2022 7122 3b0a 0965 5b22 7122 5d20 3d20 "q";..e["q"] = │ │ │ -0006dd20: 2270 7574 223b 0a09 656e 7472 7926 616d "put";..entry&am │ │ │ -0006dd30: 703b 2061 203d 2065 5b22 6122 5d3b 0a09 p; a = e["a"];.. │ │ │ -0006dd40: 615b 2276 225d 203d 206d 5f64 6174 612e a["v"] = m_data. │ │ │ -0006dd50: 7661 6c75 6528 293b 0a09 615b 2274 6f6b value();..a["tok │ │ │ -0006dd60: 656e 225d 203d 2070 6f2d 2667 743b 6d5f en"] = po->m_ │ │ │ -0006dd70: 746f 6b65 6e3b 0a09 6966 2028 6d5f 6461 token;..if (m_da │ │ │ -0006dd80: 7461 2e69 735f 6d75 7461 626c 6528 2929 ta.is_mutable()) │ │ │ -0006dd90: 0a09 7b0a 0909 615b 226b 225d 203d 206d ..{...a["k"] = m │ │ │ -0006dda0: 5f64 6174 612e 706b 2829 2e62 7974 6573 _data.pk().bytes │ │ │ -0006ddb0: 3b0a 0909 615b 2273 6571 225d 203d 206d ;...a["seq"] = m │ │ │ -0006ddc0: 5f64 6174 612e 7365 7128 292e 7661 6c75 _data.seq().valu │ │ │ -0006ddd0: 653b 0a09 0961 5b22 7369 6722 5d20 3d20 e;...a["sig"] = │ │ │ -0006dde0: 6d5f 6461 7461 2e73 6967 2829 2e62 7974 m_data.sig().byt │ │ │ -0006ddf0: 6573 3b0a 0909 6966 2028 216d 5f64 6174 es;...if (!m_dat │ │ │ -0006de00: 612e 7361 6c74 2829 2e65 6d70 7479 2829 a.salt().empty() │ │ │ -0006de10: 290a 0909 7b0a 0909 0961 5b22 7361 6c74 )...{....a["salt │ │ │ -0006de20: 225d 203d 206d 5f64 6174 612e 7361 6c74 "] = m_data.salt │ │ │ -0006de30: 2829 3b0a 0909 7d0a 097d 0a0a 096d 5f6e ();...}..}...m_n │ │ │ -0006de40: 6f64 652e 7374 6174 735f 636f 756e 7465 ode.stats_counte │ │ │ -0006de50: 7273 2829 2e69 6e63 5f73 7461 7473 5f63 rs().inc_stats_c │ │ │ -0006de60: 6f75 6e74 6572 2863 6f75 6e74 6572 733a ounter(counters: │ │ │ -0006de70: 3a64 6874 5f70 7574 5f6f 7574 293b 0a0a :dht_put_out);.. │ │ │ -0006de80: 0972 6574 7572 6e20 6d5f 6e6f 6465 2e6d .return m_node.m │ │ │ -0006de90: 5f72 7063 2e69 6e76 6f6b 6528 652c 206f _rpc.invoke(e, o │ │ │ -0006dea0: 2d26 6774 3b74 6172 6765 745f 6570 2829 ->target_ep() │ │ │ -0006deb0: 2c20 6f29 3b0a 7d0a 0a7d 207d 202f 2f20 , o);.}..} } // │ │ │ -0006dec0: 6e61 6d65 7370 6163 6520 6c69 6274 6f72 namespace libtor │ │ │ -0006ded0: 7265 6e74 3a3a 6468 740a 3c2f 7072 653e rent::dht.
    │ │ │ -0006dee0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0006df10: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0006df20: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/kade │ │ │ -0006df50: 6d6c 6961 2f72 6f75 7469 6e67 5f74 6162 mlia/routing_tab │ │ │ -0006df60: 6c65 2e63 7070 3a32 3634 3c2f 613e 3c2f le.cpp:264This is t │ │ │ -0006df80: 656d 706f 7261 7279 2e20 466f 7220 6e6f emporary. For no │ │ │ -0006df90: 772c 206f 6e6c 7920 7265 706f 7274 2074 w, only report t │ │ │ -0006dfa0: 6865 206c 6172 6765 7374 2072 6f75 7469 he largest routi │ │ │ -0006dfb0: 6e67 2074 6162 6c65 2028 6f66 2070 6f74 ng table (of pot │ │ │ -0006dfc0: 656e 7469 616c 6c79 206d 756c 7469 706c entially multipl │ │ │ -0006dfd0: 6520 6f6e 6573 2c20 666f 7220 6d75 6c74 e ones, for mult │ │ │ -0006dfe0: 692d 686f 6d65 6420 7379 7374 656d 7329 i-homed systems) │ │ │ -0006dff0: 2069 6e20 6e65 7874 206d 616a 6f72 2076 in next major v │ │ │ -0006e000: 6572 7369 6f6e 2c20 6272 6561 6b20 7468 ersion, break th │ │ │ -0006e010: 6520 4142 4920 616e 6420 7375 7070 6f72 e ABI and suppor │ │ │ -0006e020: 7420 7265 706f 7274 696e 6720 616c 6c20 t reporting all │ │ │ -0006e030: 6f66 2074 6865 6d20 696e 2074 6865 2064 of them in the d │ │ │ -0006e040: 6874 5f73 7461 7473 5f61 6c65 7274 3c2f ht_stats_alert

    This │ │ │ -0006e0a0: 2069 7320 7465 6d70 6f72 6172 792e 2046 is temporary. F │ │ │ -0006e0b0: 6f72 206e 6f77 2c20 6f6e 6c79 2072 6570 or now, only rep │ │ │ -0006e0c0: 6f72 7420 7468 6520 6c61 7267 6573 7420 ort the largest │ │ │ -0006e0d0: 726f 7574 696e 6720 7461 626c 650a 286f routing table.(o │ │ │ -0006e0e0: 6620 706f 7465 6e74 6961 6c6c 7920 6d75 f potentially mu │ │ │ -0006e0f0: 6c74 6970 6c65 206f 6e65 732c 2066 6f72 ltiple ones, for │ │ │ -0006e100: 206d 756c 7469 2d68 6f6d 6564 2073 7973 multi-homed sys │ │ │ -0006e110: 7465 6d73 290a 696e 206e 6578 7420 6d61 tems).in next ma │ │ │ -0006e120: 6a6f 7220 7665 7273 696f 6e2c 2062 7265 jor version, bre │ │ │ -0006e130: 616b 2074 6865 2041 4249 2061 6e64 2073 ak the ABI and s │ │ │ -0006e140: 7570 706f 7274 2072 6570 6f72 7469 6e67 upport reporting │ │ │ -0006e150: 2061 6c6c 206f 6620 7468 656d 2069 6e0a all of them in. │ │ │ -0006e160: 7468 6520 6468 745f 7374 6174 735f 616c the dht_stats_al │ │ │ -0006e170: 6572 743c 2f68 323e 3c68 343e 2e2e 2f73 ert

    ../s │ │ │ -0006e180: 7263 2f6b 6164 656d 6c69 612f 726f 7574 rc/kademlia/rout │ │ │ -0006e190: 696e 675f 7461 626c 652e 6370 703a 3236 ing_table.cpp:26 │ │ │ -0006e1a0: 343c 2f68 343e 3c70 7265 2073 7479 6c65 4

    │ │ │ -0006e1e0: 092c 206d 5f62 7563 6b65 745f 7369 7a65  ., m_bucket_size
    │ │ │ -0006e1f0: 2862 7563 6b65 745f 7369 7a65 290a 7b0a  (bucket_size).{.
    │ │ │ -0006e200: 092f 2f20 6275 636b 6574 2073 697a 6573  .// bucket sizes
    │ │ │ -0006e210: 206d 7573 7420 6265 2061 2070 6f77 6572   must be a power
    │ │ │ -0006e220: 206f 6620 320a 0954 4f52 5245 4e54 5f41   of 2..TORRENT_A
    │ │ │ -0006e230: 5353 4552 545f 5641 4c28 2828 6275 636b  SSERT_VAL(((buck
    │ │ │ -0006e240: 6574 5f73 697a 6520 2d20 3129 2026 616d  et_size - 1) &am
    │ │ │ -0006e250: 703b 2062 7563 6b65 745f 7369 7a65 2920  p; bucket_size) 
    │ │ │ -0006e260: 3d3d 2030 2c20 6275 636b 6574 5f73 697a  == 0, bucket_siz
    │ │ │ -0006e270: 6529 3b0a 0954 4f52 5245 4e54 5f55 4e55  e);..TORRENT_UNU
    │ │ │ -0006e280: 5345 4428 6c6f 6729 3b0a 096d 5f62 7563  SED(log);..m_buc
    │ │ │ -0006e290: 6b65 7473 2e72 6573 6572 7665 2833 3029  kets.reserve(30)
    │ │ │ -0006e2a0: 3b0a 7d0a 0a69 6e74 2072 6f75 7469 6e67  ;.}..int routing
    │ │ │ -0006e2b0: 5f74 6162 6c65 3a3a 6275 636b 6574 5f6c  _table::bucket_l
    │ │ │ -0006e2c0: 696d 6974 2869 6e74 2062 7563 6b65 7429  imit(int bucket)
    │ │ │ -0006e2d0: 2063 6f6e 7374 0a7b 0a09 6966 2028 216d   const.{..if (!m
    │ │ │ -0006e2e0: 5f73 6574 7469 6e67 732e 6765 745f 626f  _settings.get_bo
    │ │ │ -0006e2f0: 6f6c 2873 6574 7469 6e67 735f 7061 636b  ol(settings_pack
    │ │ │ -0006e300: 3a3a 6468 745f 6578 7465 6e64 6564 5f72  ::dht_extended_r
    │ │ │ -0006e310: 6f75 7469 6e67 5f74 6162 6c65 2929 2072  outing_table)) r
    │ │ │ -0006e320: 6574 7572 6e20 6d5f 6275 636b 6574 5f73  eturn m_bucket_s
    │ │ │ -0006e330: 697a 653b 0a0a 0973 7461 7469 6320 636f  ize;...static co
    │ │ │ -0006e340: 6e73 7420 6175 783a 3a61 7272 6179 266c  nst aux::array&l
    │ │ │ -0006e350: 743b 696e 742c 2034 2667 743b 2073 697a  t;int, 4> siz
    │ │ │ -0006e360: 655f 6578 6365 7074 696f 6e73 7b7b 7b31  e_exceptions{{{1
    │ │ │ -0006e370: 362c 2038 2c20 342c 2032 7d7d 7d3b 0a09  6, 8, 4, 2}}};..
    │ │ │ -0006e380: 6966 2028 6275 636b 6574 2026 6c74 3b20  if (bucket < 
    │ │ │ -0006e390: 7369 7a65 5f65 7863 6570 7469 6f6e 732e  size_exceptions.
    │ │ │ -0006e3a0: 656e 645f 696e 6465 7828 2929 0a09 0972  end_index())...r
    │ │ │ -0006e3b0: 6574 7572 6e20 6d5f 6275 636b 6574 5f73  eturn m_bucket_s
    │ │ │ -0006e3c0: 697a 6520 2a20 7369 7a65 5f65 7863 6570  ize * size_excep
    │ │ │ -0006e3d0: 7469 6f6e 735b 6275 636b 6574 5d3b 0a09  tions[bucket];..
    │ │ │ -0006e3e0: 7265 7475 726e 206d 5f62 7563 6b65 745f  return m_bucket_
    │ │ │ -0006e3f0: 7369 7a65 3b0a 7d0a 0a76 6f69 6420 726f  size;.}..void ro
    │ │ │ -0006e400: 7574 696e 675f 7461 626c 653a 3a73 7461  uting_table::sta
    │ │ │ -0006e410: 7475 7328 7374 643a 3a76 6563 746f 7226  tus(std::vector&
    │ │ │ -0006e420: 6c74 3b64 6874 5f72 6f75 7469 6e67 5f62  lt;dht_routing_b
    │ │ │ -0006e430: 7563 6b65 7426 6774 3b26 616d 703b 2073  ucket>& s
    │ │ │ -0006e440: 2920 636f 6e73 740a 7b0a 3c64 6976 2073  ) const.{.
    .if (s.s │ │ │ -0006e480: 697a 6528 2920 2667 743b 206d 5f62 7563 ize() > m_buc │ │ │ -0006e490: 6b65 7473 2e73 697a 6528 2929 2072 6574 kets.size()) ret │ │ │ -0006e4a0: 7572 6e3b 0a3c 2f64 6976 3e09 732e 636c urn;.
    .s.cl │ │ │ -0006e4b0: 6561 7228 293b 0a09 666f 7220 2861 7574 ear();..for (aut │ │ │ -0006e4c0: 6f20 636f 6e73 7426 616d 703b 2069 203a o const& i : │ │ │ -0006e4d0: 206d 5f62 7563 6b65 7473 290a 097b 0a09 m_buckets)..{.. │ │ │ -0006e4e0: 0964 6874 5f72 6f75 7469 6e67 5f62 7563 .dht_routing_buc │ │ │ -0006e4f0: 6b65 7420 623b 0a09 0962 2e6e 756d 5f6e ket b;...b.num_n │ │ │ -0006e500: 6f64 6573 203d 2069 6e74 2869 2e6c 6976 odes = int(i.liv │ │ │ -0006e510: 655f 6e6f 6465 732e 7369 7a65 2829 293b e_nodes.size()); │ │ │ -0006e520: 0a09 0962 2e6e 756d 5f72 6570 6c61 6365 ...b.num_replace │ │ │ -0006e530: 6d65 6e74 7320 3d20 696e 7428 692e 7265 ments = int(i.re │ │ │ -0006e540: 706c 6163 656d 656e 7473 2e73 697a 6528 placements.size( │ │ │ -0006e550: 2929 3b0a 0909 732e 7075 7368 5f62 6163 ));...s.push_bac │ │ │ -0006e560: 6b28 6229 3b0a 097d 0a7d 0a0a 2369 6620 k(b);..}.}..#if │ │ │ -0006e570: 544f 5252 454e 545f 4142 495f 5645 5253 TORRENT_ABI_VERS │ │ │ -0006e580: 494f 4e20 3d3d 2031 0a3c 2f70 7265 3e3c ION == 1.
    < │ │ │ -0006e590: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -0006e5c0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -0006e5d0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/kadem │ │ │ -0006e600: 6c69 612f 726f 7574 696e 675f 7461 626c lia/routing_tabl │ │ │ -0006e610: 652e 6370 703a 3238 363c 2f61 3e3c 2f74 e.cpp:286
    arvidn not │ │ │ -0006e630: 6520 7768 656e 2069 7427 7320 6163 726f e when it's acro │ │ │ -0006e640: 7373 2049 5076 3420 616e 6420 4950 7636 ss IPv4 and IPv6 │ │ │ -0006e650: 2c20 6164 6469 6e67 2028 6468 745f 676c , adding (dht_gl │ │ │ -0006e660: 6f62 616c 5f6e 6f64 6573 2920 776f 756c obal_nodes) woul │ │ │ -0006e670: 6420 6d61 6b65 2073 656e 7365 2e20 696e d make sense. in │ │ │ -0006e680: 2074 6865 2066 7574 7572 6520 7468 6f75 the future thou │ │ │ -0006e690: 6768 2c20 7768 6572 6520 7765 206d 6179 gh, where we may │ │ │ -0006e6a0: 2068 6176 6520 6f6e 6520 4448 5420 6e6f have one DHT no │ │ │ -0006e6b0: 6465 2070 6572 2065 7874 6572 6e61 6c20 de per external │ │ │ -0006e6c0: 696e 7465 7266 6163 6520 2877 6869 6368 interface (which │ │ │ -0006e6d0: 206d 6179 2062 6520 6d75 6c74 6970 6c65 may be multiple │ │ │ -0006e6e0: 206f 6620 7468 6520 7361 6d65 2061 6464 of the same add │ │ │ -0006e6f0: 7265 7373 2066 616d 696c 7929 2c20 7468 ress family), th │ │ │ -0006e700: 656e 2069 7420 6265 636f 6d65 7320 6120 en it becomes a │ │ │ -0006e710: 6269 7420 7472 6963 6b69 6572 3c2f 7464 bit trickier

    arvidn │ │ │ -0006e770: 206e 6f74 650a 7768 656e 2069 7427 7320 note.when it's │ │ │ -0006e780: 6163 726f 7373 2049 5076 3420 616e 6420 across IPv4 and │ │ │ -0006e790: 4950 7636 2c20 6164 6469 6e67 2028 6468 IPv6, adding (dh │ │ │ -0006e7a0: 745f 676c 6f62 616c 5f6e 6f64 6573 2920 t_global_nodes) │ │ │ -0006e7b0: 776f 756c 640a 6d61 6b65 2073 656e 7365 would.make sense │ │ │ -0006e7c0: 2e20 696e 2074 6865 2066 7574 7572 6520 . in the future │ │ │ -0006e7d0: 7468 6f75 6768 2c20 7768 6572 6520 7765 though, where we │ │ │ -0006e7e0: 206d 6179 2068 6176 6520 6f6e 6520 4448 may have one DH │ │ │ -0006e7f0: 5420 6e6f 6465 0a70 6572 2065 7874 6572 T node.per exter │ │ │ -0006e800: 6e61 6c20 696e 7465 7266 6163 6520 2877 nal interface (w │ │ │ -0006e810: 6869 6368 206d 6179 2062 6520 6d75 6c74 hich may be mult │ │ │ -0006e820: 6970 6c65 206f 6620 7468 6520 7361 6d65 iple of the same │ │ │ -0006e830: 2061 6464 7265 7373 0a66 616d 696c 7929 address.family) │ │ │ -0006e840: 2c20 7468 656e 2069 7420 6265 636f 6d65 , then it become │ │ │ -0006e850: 7320 6120 6269 7420 7472 6963 6b69 6572 s a bit trickier │ │ │ -0006e860: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ -0006e870: 6b61 6465 6d6c 6961 2f72 6f75 7469 6e67 kademlia/routing │ │ │ -0006e880: 5f74 6162 6c65 2e63 7070 3a32 3836 3c2f _table.cpp:286
    .vo
    │ │ │ -0006e8d0: 6964 2072 6f75 7469 6e67 5f74 6162 6c65  id routing_table
    │ │ │ -0006e8e0: 3a3a 7374 6174 7573 2873 7464 3a3a 7665  ::status(std::ve
    │ │ │ -0006e8f0: 6374 6f72 266c 743b 6468 745f 726f 7574  ctor<dht_rout
    │ │ │ -0006e900: 696e 675f 6275 636b 6574 2667 743b 2661  ing_bucket>&a
    │ │ │ -0006e910: 6d70 3b20 7329 2063 6f6e 7374 0a7b 0a09  mp; s) const.{..
    │ │ │ -0006e920: 6966 2028 732e 7369 7a65 2829 2026 6774  if (s.size() >
    │ │ │ -0006e930: 3b20 6d5f 6275 636b 6574 732e 7369 7a65  ; m_buckets.size
    │ │ │ -0006e940: 2829 2920 7265 7475 726e 3b0a 0973 2e63  ()) return;..s.c
    │ │ │ -0006e950: 6c65 6172 2829 3b0a 0966 6f72 2028 6175  lear();..for (au
    │ │ │ -0006e960: 746f 2063 6f6e 7374 2661 6d70 3b20 6920  to const& i 
    │ │ │ -0006e970: 3a20 6d5f 6275 636b 6574 7329 0a09 7b0a  : m_buckets)..{.
    │ │ │ -0006e980: 0909 6468 745f 726f 7574 696e 675f 6275  ..dht_routing_bu
    │ │ │ -0006e990: 636b 6574 2062 3b0a 0909 622e 6e75 6d5f  cket b;...b.num_
    │ │ │ -0006e9a0: 6e6f 6465 7320 3d20 696e 7428 692e 6c69  nodes = int(i.li
    │ │ │ -0006e9b0: 7665 5f6e 6f64 6573 2e73 697a 6528 2929  ve_nodes.size())
    │ │ │ -0006e9c0: 3b0a 0909 622e 6e75 6d5f 7265 706c 6163  ;...b.num_replac
    │ │ │ -0006e9d0: 656d 656e 7473 203d 2069 6e74 2869 2e72  ements = int(i.r
    │ │ │ -0006e9e0: 6570 6c61 6365 6d65 6e74 732e 7369 7a65  eplacements.size
    │ │ │ -0006e9f0: 2829 293b 0a09 0973 2e70 7573 685f 6261  ());...s.push_ba
    │ │ │ -0006ea00: 636b 2862 293b 0a09 7d0a 7d0a 0a23 6966  ck(b);..}.}..#if
    │ │ │ -0006ea10: 2054 4f52 5245 4e54 5f41 4249 5f56 4552   TORRENT_ABI_VER
    │ │ │ -0006ea20: 5349 4f4e 203d 3d20 310a 766f 6964 2072  SION == 1.void r
    │ │ │ -0006ea30: 6f75 7469 6e67 5f74 6162 6c65 3a3a 7374  outing_table::st
    │ │ │ -0006ea40: 6174 7573 2873 6573 7369 6f6e 5f73 7461  atus(session_sta
    │ │ │ -0006ea50: 7475 7326 616d 703b 2073 2920 636f 6e73  tus& s) cons
    │ │ │ -0006ea60: 740a 7b0a 0961 7574 6f20 636f 6e73 7420  t.{..auto const 
    │ │ │ -0006ea70: 5b64 6874 5f6e 6f64 6573 2c20 6468 745f  [dht_nodes, dht_
    │ │ │ -0006ea80: 6e6f 6465 5f63 6163 6865 2c20 6967 6e6f  node_cache, igno
    │ │ │ -0006ea90: 7265 5d20 3d20 7369 7a65 2829 3b0a 0973  re] = size();..s
    │ │ │ -0006eaa0: 2e64 6874 5f6e 6f64 6573 202b 3d20 6468  .dht_nodes += dh
    │ │ │ -0006eab0: 745f 6e6f 6465 733b 0a09 732e 6468 745f  t_nodes;..s.dht_
    │ │ │ -0006eac0: 6e6f 6465 5f63 6163 6865 202b 3d20 6468  node_cache += dh
    │ │ │ -0006ead0: 745f 6e6f 6465 5f63 6163 6865 3b0a 3c64  t_node_cache;..s.d
    │ │ │ -0006eb10: 6874 5f67 6c6f 6261 6c5f 6e6f 6465 7320  ht_global_nodes 
    │ │ │ -0006eb20: 2b3d 206e 756d 5f67 6c6f 6261 6c5f 6e6f  += num_global_no
    │ │ │ -0006eb30: 6465 7328 293b 0a3c 2f64 6976 3e0a 0966  des();.

    ..f │ │ │ -0006eb40: 6f72 2028 6175 746f 2063 6f6e 7374 2661 or (auto const&a │ │ │ -0006eb50: 6d70 3b20 6920 3a20 6d5f 6275 636b 6574 mp; i : m_bucket │ │ │ -0006eb60: 7329 0a09 7b0a 0909 6468 745f 726f 7574 s)..{...dht_rout │ │ │ -0006eb70: 696e 675f 6275 636b 6574 2062 3b0a 0909 ing_bucket b;... │ │ │ -0006eb80: 622e 6e75 6d5f 6e6f 6465 7320 3d20 696e b.num_nodes = in │ │ │ -0006eb90: 7428 692e 6c69 7665 5f6e 6f64 6573 2e73 t(i.live_nodes.s │ │ │ -0006eba0: 697a 6528 2929 3b0a 0909 622e 6e75 6d5f ize());...b.num_ │ │ │ -0006ebb0: 7265 706c 6163 656d 656e 7473 203d 2069 replacements = i │ │ │ -0006ebc0: 6e74 2869 2e72 6570 6c61 6365 6d65 6e74 nt(i.replacement │ │ │ -0006ebd0: 732e 7369 7a65 2829 293b 0a09 0962 2e6c s.size());...b.l │ │ │ -0006ebe0: 6173 745f 6163 7469 7665 203d 2030 3b0a ast_active = 0;. │ │ │ -0006ebf0: 0909 732e 6468 745f 726f 7574 696e 675f ..s.dht_routing_ │ │ │ -0006ec00: 7461 626c 652e 7075 7368 5f62 6163 6b28 table.push_back( │ │ │ -0006ec10: 6229 3b0a 097d 0a7d 0a23 656e 6469 660a b);..}.}.#endif. │ │ │ -0006ec20: 0a73 7464 3a3a 7475 706c 6526 6c74 3b69 .std::tuple<i │ │ │ -0006ec30: 6e74 2c20 696e 742c 2069 6e74 2667 743b nt, int, int> │ │ │ -0006ec40: 2072 6f75 7469 6e67 5f74 6162 6c65 3a3a routing_table:: │ │ │ -0006ec50: 7369 7a65 2829 2063 6f6e 7374 0a7b 0a09 size() const.{.. │ │ │ -0006ec60: 696e 7420 6e6f 6465 7320 3d20 303b 0a09 int nodes = 0;.. │ │ │ -0006ec70: 696e 7420 7265 706c 6163 656d 656e 7473 int replacements │ │ │ -0006ec80: 203d 2030 3b0a 0969 6e74 2063 6f6e 6669 = 0;..int confi │ │ │ -0006ec90: 726d 6564 203d 2030 3b0a 0966 6f72 2028 rmed = 0;..for ( │ │ │ -0006eca0: 6175 746f 2063 6f6e 7374 2661 6d70 3b20 auto const& │ │ │ -0006ecb0: 6920 3a20 6d5f 6275 636b 6574 7329 0a09 i : m_buckets).. │ │ │ -0006ecc0: 7b0a 0909 6e6f 6465 7320 2b3d 2069 6e74 {...nodes += int │ │ │ -0006ecd0: 2869 2e6c 6976 655f 6e6f 6465 732e 7369 (i.live_nodes.si │ │ │ -0006ece0: 7a65 2829 293b 0a09 0963 6f6e 6669 726d ze());...confirm │ │ │ -0006ecf0: 6564 202b 3d20 7374 6174 6963 5f63 6173 ed += static_cas │ │ │ -0006ed00: 7426 6c74 3b69 6e74 2667 743b 2873 7464 t<int>(std │ │ │ -0006ed10: 3a3a 636f 756e 745f 6966 2869 2e6c 6976 ::count_if(i.liv │ │ │ -0006ed20: 655f 6e6f 6465 732e 6265 6769 6e28 292c e_nodes.begin(), │ │ │ -0006ed30: 2069 2e6c 6976 655f 6e6f 6465 732e 656e i.live_nodes.en │ │ │ -0006ed40: 6428 290a 0909 092c 205b 5d28 6e6f 6465 d()...., [](node │ │ │ -0006ed50: 5f65 6e74 7279 2063 6f6e 7374 2661 6d70 _entry const& │ │ │ -0006ed60: 3b20 6b29 207b 2072 6574 7572 6e20 6b2e ; k) { return k. │ │ │ -0006ed70: 636f 6e66 6972 6d65 6428 293b 207d 2029 confirmed(); } ) │ │ │ -0006ed80: 293b 0a0a 0909 7265 706c 6163 656d 656e );....replacemen │ │ │ -0006ed90: 7473 202b 3d20 696e 7428 692e 7265 706c ts += int(i.repl │ │ │ -0006eda0: 6163 656d 656e 7473 2e73 697a 6528 2929 acements.size()) │ │ │ -0006edb0: 3b0a 097d 0a09 7265 7475 726e 2073 7464 ;..}..return std │ │ │ -0006edc0: 3a3a 6d61 6b65 5f74 7570 6c65 286e 6f64 ::make_tuple(nod │ │ │ -0006edd0: 6573 2c20 7265 706c 6163 656d 656e 7473 es, replacements │ │ │ -0006ede0: 2c20 636f 6e66 6972 6d65 6429 3b0a 7d0a , confirmed);.}. │ │ │ -0006edf0: 0a73 7464 3a3a 696e 7436 345f 7420 726f .std::int64_t ro │ │ │ -0006ee00: 7574 696e 675f 7461 626c 653a 3a6e 756d uting_table::num │ │ │ -0006ee10: 5f67 6c6f 6261 6c5f 6e6f 6465 7328 2920 _global_nodes() │ │ │ -0006ee20: 636f 6e73 740a 7b0a 3c2f 7072 653e 3c2f const.{.
    relevan │ │ │ -0006ee60: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/kademl │ │ │ -0006eea0: 6961 2f72 6f75 7469 6e67 5f74 6162 6c65 ia/routing_table │ │ │ -0006eeb0: 2e63 7070 3a34 3838 3c2f 613e 3c2f 7464 .cpp:488this need t │ │ │ -0006eed0: 6f20 7461 6b65 2062 7563 6b65 7420 2270 o take bucket "p │ │ │ -0006eee0: 7265 6669 7822 2069 6e74 6f20 6163 636f refix" into acco │ │ │ -0006eef0: 756e 742e 2049 7420 7368 6f75 6c64 2062 unt. It should b │ │ │ -0006ef00: 6520 756e 6966 6965 6420 7769 7468 2061 e unified with a │ │ │ -0006ef10: 6464 5f6e 6f64 655f 696d 706c 2829 3c2f dd_node_impl()

    this │ │ │ -0006ef70: 206e 6565 6420 746f 2074 616b 6520 6275 need to take bu │ │ │ -0006ef80: 636b 6574 2022 7072 6566 6978 2220 696e cket "prefix" in │ │ │ -0006ef90: 746f 2061 6363 6f75 6e74 2e20 4974 2073 to account. It s │ │ │ -0006efa0: 686f 756c 6420 6265 2075 6e69 6669 6564 hould be unified │ │ │ -0006efb0: 0a77 6974 6820 6164 645f 6e6f 6465 5f69 .with add_node_i │ │ │ -0006efc0: 6d70 6c28 293c 2f68 323e 3c68 343e 2e2e mpl()

    .. │ │ │ -0006efd0: 2f73 7263 2f6b 6164 656d 6c69 612f 726f /src/kademlia/ro │ │ │ -0006efe0: 7574 696e 675f 7461 626c 652e 6370 703a uting_table.cpp: │ │ │ -0006eff0: 3438 383c 2f68 343e 3c70 7265 2073 7479 488

    {..for (auto i
    │ │ │ -0006f040: 203d 206d 5f62 7563 6b65 7473 2e62 6567   = m_buckets.beg
    │ │ │ -0006f050: 696e 2829 202c 2065 6e64 286d 5f62 7563  in() , end(m_buc
    │ │ │ -0006f060: 6b65 7473 2e65 6e64 2829 293b 2069 2021  kets.end()); i !
    │ │ │ -0006f070: 3d20 656e 643b 202b 2b69 290a 097b 0a09  = end; ++i)..{..
    │ │ │ -0006f080: 0966 6f72 2028 6175 746f 206a 203d 2069  .for (auto j = i
    │ │ │ -0006f090: 2d26 6774 3b72 6570 6c61 6365 6d65 6e74  ->replacement
    │ │ │ -0006f0a0: 732e 6265 6769 6e28 293b 206a 2021 3d20  s.begin(); j != 
    │ │ │ -0006f0b0: 692d 2667 743b 7265 706c 6163 656d 656e  i->replacemen
    │ │ │ -0006f0c0: 7473 2e65 6e64 2829 3b20 2b2b 6a29 0a09  ts.end(); ++j)..
    │ │ │ -0006f0d0: 097b 0a09 0909 6966 2028 6a2d 2667 743b  .{....if (j->
    │ │ │ -0006f0e0: 6164 6472 2829 2021 3d20 6570 2e61 6464  addr() != ep.add
    │ │ │ -0006f0f0: 7265 7373 2829 2920 636f 6e74 696e 7565  ress()) continue
    │ │ │ -0006f100: 3b0a 0909 0969 6620 286a 2d26 6774 3b70  ;....if (j->p
    │ │ │ -0006f110: 6f72 7428 2920 213d 2065 702e 706f 7274  ort() != ep.port
    │ │ │ -0006f120: 2829 2920 636f 6e74 696e 7565 3b0a 0909  ()) continue;...
    │ │ │ -0006f130: 0972 6574 7572 6e20 7374 643a 3a6d 616b  .return std::mak
    │ │ │ -0006f140: 655f 7475 706c 6528 2661 6d70 3b2a 6a2c  e_tuple(&*j,
    │ │ │ -0006f150: 2069 2c20 2661 6d70 3b69 2d26 6774 3b72   i, &i->r
    │ │ │ -0006f160: 6570 6c61 6365 6d65 6e74 7329 3b0a 0909  eplacements);...
    │ │ │ -0006f170: 7d0a 0909 666f 7220 2861 7574 6f20 6a20  }...for (auto j 
    │ │ │ -0006f180: 3d20 692d 2667 743b 6c69 7665 5f6e 6f64  = i->live_nod
    │ │ │ -0006f190: 6573 2e62 6567 696e 2829 3b20 6a20 213d  es.begin(); j !=
    │ │ │ -0006f1a0: 2069 2d26 6774 3b6c 6976 655f 6e6f 6465   i->live_node
    │ │ │ -0006f1b0: 732e 656e 6428 293b 202b 2b6a 290a 0909  s.end(); ++j)...
    │ │ │ -0006f1c0: 7b0a 0909 0969 6620 286a 2d26 6774 3b61  {....if (j->a
    │ │ │ -0006f1d0: 6464 7228 2920 213d 2065 702e 6164 6472  ddr() != ep.addr
    │ │ │ -0006f1e0: 6573 7328 2929 2063 6f6e 7469 6e75 653b  ess()) continue;
    │ │ │ -0006f1f0: 0a09 0909 6966 2028 6a2d 2667 743b 706f  ....if (j->po
    │ │ │ -0006f200: 7274 2829 2021 3d20 6570 2e70 6f72 7428  rt() != ep.port(
    │ │ │ -0006f210: 2929 2063 6f6e 7469 6e75 653b 0a09 0909  )) continue;....
    │ │ │ -0006f220: 7265 7475 726e 2073 7464 3a3a 6d61 6b65  return std::make
    │ │ │ -0006f230: 5f74 7570 6c65 2826 616d 703b 2a6a 2c20  _tuple(&*j, 
    │ │ │ -0006f240: 692c 2026 616d 703b 692d 2667 743b 6c69  i, &i->li
    │ │ │ -0006f250: 7665 5f6e 6f64 6573 293b 0a09 097d 0a09  ve_nodes);...}..
    │ │ │ -0006f260: 7d0a 0972 6574 7572 6e20 7374 643a 3a74  }..return std::t
    │ │ │ -0006f270: 7570 6c65 266c 743b 6e6f 6465 5f65 6e74  uple<node_ent
    │ │ │ -0006f280: 7279 2a2c 2072 6f75 7469 6e67 5f74 6162  ry*, routing_tab
    │ │ │ -0006f290: 6c65 3a3a 7461 626c 655f 743a 3a69 7465  le::table_t::ite
    │ │ │ -0006f2a0: 7261 746f 722c 2062 7563 6b65 745f 742a  rator, bucket_t*
    │ │ │ -0006f2b0: 2667 743b 0a09 7b6e 756c 6c70 7472 2c20  >..{nullptr, 
    │ │ │ -0006f2c0: 6d5f 6275 636b 6574 732e 656e 6428 292c  m_buckets.end(),
    │ │ │ -0006f2d0: 206e 756c 6c70 7472 7d3b 0a7d 0a0a 3c64   nullptr};.}..void
    │ │ │ -0006f310: 2072 6f75 7469 6e67 5f74 6162 6c65 3a3a   routing_table::
    │ │ │ -0006f320: 6669 6c6c 5f66 726f 6d5f 7265 706c 6163  fill_from_replac
    │ │ │ -0006f330: 656d 656e 7473 2874 6162 6c65 5f74 3a3a  ements(table_t::
    │ │ │ -0006f340: 6974 6572 6174 6f72 2062 7563 6b65 7429  iterator bucket)
    │ │ │ -0006f350: 0a3c 2f64 6976 3e7b 0a09 6275 636b 6574  .{..bucket
    │ │ │ -0006f360: 5f74 2661 6d70 3b20 6220 3d20 6275 636b  _t& b = buck
    │ │ │ -0006f370: 6574 2d26 6774 3b6c 6976 655f 6e6f 6465  et->live_node
    │ │ │ -0006f380: 733b 0a09 6275 636b 6574 5f74 2661 6d70  s;..bucket_t&
    │ │ │ -0006f390: 3b20 7262 203d 2062 7563 6b65 742d 2667  ; rb = bucket-&g
    │ │ │ -0006f3a0: 743b 7265 706c 6163 656d 656e 7473 3b0a  t;replacements;.
    │ │ │ -0006f3b0: 0969 6e74 2063 6f6e 7374 2062 7563 6b65  .int const bucke
    │ │ │ -0006f3c0: 745f 7369 7a65 203d 2062 7563 6b65 745f  t_size = bucket_
    │ │ │ -0006f3d0: 6c69 6d69 7428 696e 7428 7374 643a 3a64  limit(int(std::d
    │ │ │ -0006f3e0: 6973 7461 6e63 6528 6d5f 6275 636b 6574  istance(m_bucket
    │ │ │ -0006f3f0: 732e 6265 6769 6e28 292c 2062 7563 6b65  s.begin(), bucke
    │ │ │ -0006f400: 7429 2929 3b0a 0a09 6966 2028 696e 7428  t)));...if (int(
    │ │ │ -0006f410: 622e 7369 7a65 2829 2920 2667 743b 3d20  b.size()) >= 
    │ │ │ -0006f420: 6275 636b 6574 5f73 697a 6529 2072 6574  bucket_size) ret
    │ │ │ -0006f430: 7572 6e3b 0a0a 092f 2f20 736f 7274 2062  urn;...// sort b
    │ │ │ -0006f440: 7920 5254 5420 6669 7273 742c 2074 6f20  y RTT first, to 
    │ │ │ -0006f450: 6669 6e64 2074 6865 206e 6f64 6520 7769  find the node wi
    │ │ │ -0006f460: 7468 2074 6865 206c 6f77 6573 740a 092f  th the lowest../
    │ │ │ -0006f470: 2f20 5254 5420 7468 6174 2069 7320 7069  / RTT that is pi
    │ │ │ -0006f480: 6e67 6564 0a09 7374 643a 3a73 6f72 7428  nged..std::sort(
    │ │ │ -0006f490: 7262 2e62 6567 696e 2829 2c20 7262 2e65  rb.begin(), rb.e
    │ │ │ -0006f4a0: 6e64 2829 293b 0a0a 0977 6869 6c65 2028  nd());...while (
    │ │ │ -0006f4b0: 696e 7428 622e 7369 7a65 2829 2920 266c  int(b.size()) &l
    │ │ │ -0006f4c0: 743b 2062 7563 6b65 745f 7369 7a65 2026  t; bucket_size &
    │ │ │ -0006f4d0: 616d 703b 2661 6d70 3b20 2172 622e 656d  amp;& !rb.em
    │ │ │ -0006f4e0: 7074 7928 2929 0a09 7b0a 0909 6175 746f  pty())..{...auto
    │ │ │ -0006f4f0: 206a 203d 2073 7464 3a3a 6669 6e64 5f69   j = std::find_i
    │ │ │ -0006f500: 6628 7262 2e62 6567 696e 2829 2c20 7262  f(rb.begin(), rb
    │ │ │ -0006f510: 2e65 6e64 2829 2c20 7374 643a 3a62 696e  .end(), std::bin
    │ │ │ -0006f520: 6428 2661 6d70 3b6e 6f64 655f 656e 7472  d(&node_entr
    │ │ │ -0006f530: 793a 3a70 696e 6765 642c 205f 3129 293b  y::pinged, _1));
    │ │ │ -0006f540: 0a09 0969 6620 286a 203d 3d20 7262 2e65  ...if (j == rb.e
    │ │ │ -0006f550: 6e64 2829 2920 6272 6561 6b3b 0a09 0962  nd()) break;...b
    │ │ │ -0006f560: 2e70 7573 685f 6261 636b 282a 6a29 3b0a  .push_back(*j);.
    │ │ │ -0006f570: 0909 7262 2e65 7261 7365 286a 293b 0a09  ..rb.erase(j);..
    │ │ │ -0006f580: 7d0a 7d0a 0a76 6f69 6420 726f 7574 696e  }.}..void routin
    │ │ │ -0006f590: 675f 7461 626c 653a 3a70 7275 6e65 5f65  g_table::prune_e
    │ │ │ -0006f5a0: 6d70 7479 5f62 7563 6b65 7428 290a 7b0a  mpty_bucket().{.
    │ │ │ -0006f5b0: 0969 6620 286d 5f62 7563 6b65 7473 2e62  .if (m_buckets.b
    │ │ │ -0006f5c0: 6163 6b28 292e 6c69 7665 5f6e 6f64 6573  ack().live_nodes
    │ │ │ -0006f5d0: 2e65 6d70 7479 2829 0a09 0926 616d 703b  .empty()...&
    │ │ │ -0006f5e0: 2661 6d70 3b20 6d5f 6275 636b 6574 732e  & m_buckets.
    │ │ │ -0006f5f0: 6261 636b 2829 2e72 6570 6c61 6365 6d65  back().replaceme
    │ │ │ -0006f600: 6e74 732e 656d 7074 7928 2929 0a09 7b0a  nts.empty())..{.
    │ │ │ -0006f610: 0909 6d5f 6275 636b 6574 732e 6572 6173  ..m_buckets.eras
    │ │ │ -0006f620: 6528 6d5f 6275 636b 6574 732e 656e 6428  e(m_buckets.end(
    │ │ │ -0006f630: 2920 2d20 3129 3b0a 097d 0a7d 0a0a 766f  ) - 1);..}.}..vo
    │ │ │ -0006f640: 6964 2072 6f75 7469 6e67 5f74 6162 6c65  id routing_table
    │ │ │ -0006f650: 3a3a 7265 6d6f 7665 5f6e 6f64 6528 6e6f  ::remove_node(no
    │ │ │ -0006f660: 6465 5f65 6e74 7279 2a20 6e2c 2062 7563  de_entry* n, buc
    │ │ │ -0006f670: 6b65 745f 742a 2062 290a 3c2f 7072 653e  ket_t* b).
    │ │ │ -0006f680: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0006f6b0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0006f6c0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/kade │ │ │ -0006f6f0: 6d6c 6961 2f64 6874 5f74 7261 636b 6572 mlia/dht_tracker │ │ │ -0006f700: 2e63 7070 3a32 3934 3c2f 613e 3c2f 7464 .cpp:294pick the cl │ │ │ -0006f720: 6f73 6573 7420 6e6f 6465 2072 6174 6865 osest node rathe │ │ │ -0006f730: 7220 7468 616e 2074 6865 2066 6972 7374 r than the first │ │ │ -0006f740: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    pi │ │ │ -0006f790: 636b 2074 6865 2063 6c6f 7365 7374 206e ck the closest n │ │ │ -0006f7a0: 6f64 6520 7261 7468 6572 2074 6861 6e20 ode rather than │ │ │ -0006f7b0: 7468 6520 6669 7273 743c 2f68 323e 3c68 the first

    ../src/kademli │ │ │ -0006f7d0: 612f 6468 745f 7472 6163 6b65 722e 6370 a/dht_tracker.cp │ │ │ -0006f7e0: 703a 3239 343c 2f68 343e 3c70 7265 2073 p:294
    .#ifndef TOR
    │ │ │ -0006f830: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47  RENT_DISABLE_LOG
    │ │ │ -0006f840: 4749 4e47 0a09 096d 5f6c 6f67 2d26 6774  GING...m_log->
    │ │ │ -0006f850: 3b6c 6f67 2864 6874 5f6c 6f67 6765 723a  ;log(dht_logger:
    │ │ │ -0006f860: 3a74 7261 636b 6572 2c20 222a 2a2a 206e  :tracker, "*** n
    │ │ │ -0006f870: 6577 2077 7269 7465 206b 6579 2a2a 2a20  ew write key*** 
    │ │ │ -0006f880: 2564 206e 6f64 6573 220a 0909 092c 2069  %d nodes"...., i
    │ │ │ -0006f890: 6e74 286d 5f6e 6f64 6573 2e73 697a 6528  nt(m_nodes.size(
    │ │ │ -0006f8a0: 2929 293b 0a23 656e 6469 660a 097d 0a0a  )));.#endif..}..
    │ │ │ -0006f8b0: 0976 6f69 6420 6468 745f 7472 6163 6b65  .void dht_tracke
    │ │ │ -0006f8c0: 723a 3a75 7064 6174 655f 7374 6f72 6167  r::update_storag
    │ │ │ -0006f8d0: 655f 6e6f 6465 5f69 6473 2829 0a09 7b0a  e_node_ids()..{.
    │ │ │ -0006f8e0: 0909 7374 643a 3a76 6563 746f 7226 6c74  ..std::vector<
    │ │ │ -0006f8f0: 3b73 6861 315f 6861 7368 2667 743b 2069  ;sha1_hash> i
    │ │ │ -0006f900: 6473 3b0a 0909 666f 7220 2861 7574 6f26  ds;...for (auto&
    │ │ │ -0006f910: 616d 703b 206e 203a 206d 5f6e 6f64 6573  amp; n : m_nodes
    │ │ │ -0006f920: 290a 0909 0969 6473 2e70 7573 685f 6261  )....ids.push_ba
    │ │ │ -0006f930: 636b 286e 2e73 6563 6f6e 642e 6468 742e  ck(n.second.dht.
    │ │ │ -0006f940: 6e69 6428 2929 3b0a 0909 6d5f 7374 6f72  nid());...m_stor
    │ │ │ -0006f950: 6167 652e 7570 6461 7465 5f6e 6f64 655f  age.update_node_
    │ │ │ -0006f960: 6964 7328 6964 7329 3b0a 097d 0a0a 096e  ids(ids);..}...n
    │ │ │ -0006f970: 6f64 652a 2064 6874 5f74 7261 636b 6572  ode* dht_tracker
    │ │ │ -0006f980: 3a3a 6765 745f 6e6f 6465 286e 6f64 655f  ::get_node(node_
    │ │ │ -0006f990: 6964 2063 6f6e 7374 2661 6d70 3b20 6964  id const& id
    │ │ │ -0006f9a0: 2c20 7374 7269 6e67 5f76 6965 7720 2066  , string_view  f
    │ │ │ -0006f9b0: 616d 696c 795f 6e61 6d65 290a 097b 0a09  amily_name)..{..
    │ │ │ -0006f9c0: 0954 4f52 5245 4e54 5f55 4e55 5345 4428  .TORRENT_UNUSED(
    │ │ │ -0006f9d0: 6964 293b 0a09 0966 6f72 2028 6175 746f  id);...for (auto
    │ │ │ -0006f9e0: 2661 6d70 3b20 6e20 3a20 6d5f 6e6f 6465  & n : m_node
    │ │ │ -0006f9f0: 7329 0a09 097b 0a3c 6469 7620 7374 796c  s)...{.
    ...if (n.se │ │ │ -0006fa30: 636f 6e64 2e64 6874 2e70 726f 746f 636f cond.dht.protoco │ │ │ -0006fa40: 6c5f 6661 6d69 6c79 5f6e 616d 6528 2920 l_family_name() │ │ │ -0006fa50: 3d3d 2066 616d 696c 795f 6e61 6d65 290a == family_name). │ │ │ -0006fa60: 3c2f 6469 763e 0909 0909 7265 7475 726e
    ....return │ │ │ -0006fa70: 2026 616d 703b 6e2e 7365 636f 6e64 2e64 &n.second.d │ │ │ -0006fa80: 6874 3b0a 0909 7d0a 0a09 0972 6574 7572 ht;...}....retur │ │ │ -0006fa90: 6e20 6e75 6c6c 7074 723b 0a09 7d0a 0a09 n nullptr;..}... │ │ │ -0006faa0: 766f 6964 2064 6874 5f74 7261 636b 6572 void dht_tracker │ │ │ -0006fab0: 3a3a 6765 745f 7065 6572 7328 7368 6131 ::get_peers(sha1 │ │ │ -0006fac0: 5f68 6173 6820 636f 6e73 7426 616d 703b _hash const& │ │ │ -0006fad0: 2069 680a 0909 2c20 7374 643a 3a66 756e ih..., std::fun │ │ │ -0006fae0: 6374 696f 6e26 6c74 3b76 6f69 6428 7374 ction<void(st │ │ │ -0006faf0: 643a 3a76 6563 746f 7226 6c74 3b74 6370 d::vector<tcp │ │ │ -0006fb00: 3a3a 656e 6470 6f69 6e74 2667 743b 2063 ::endpoint> c │ │ │ -0006fb10: 6f6e 7374 2661 6d70 3b29 2667 743b 2066 onst&)> f │ │ │ -0006fb20: 290a 097b 0a09 0966 6f72 2028 6175 746f )..{...for (auto │ │ │ -0006fb30: 2661 6d70 3b20 6e20 3a20 6d5f 6e6f 6465 & n : m_node │ │ │ -0006fb40: 7329 0a09 0909 6e2e 7365 636f 6e64 2e64 s)....n.second.d │ │ │ -0006fb50: 6874 2e67 6574 5f70 6565 7273 2869 682c ht.get_peers(ih, │ │ │ -0006fb60: 2066 2c20 7b7d 2c20 7b7d 293b 0a09 7d0a f, {}, {});..}. │ │ │ -0006fb70: 0a09 766f 6964 2064 6874 5f74 7261 636b ..void dht_track │ │ │ -0006fb80: 6572 3a3a 616e 6e6f 756e 6365 2873 6861 er::announce(sha │ │ │ -0006fb90: 315f 6861 7368 2063 6f6e 7374 2661 6d70 1_hash const& │ │ │ -0006fba0: 3b20 6968 2c20 696e 7420 6c69 7374 656e ; ih, int listen │ │ │ -0006fbb0: 5f70 6f72 740a 0909 2c20 616e 6e6f 756e _port..., announ │ │ │ -0006fbc0: 6365 5f66 6c61 6773 5f74 2063 6f6e 7374 ce_flags_t const │ │ │ -0006fbd0: 2066 6c61 6773 0a09 092c 2073 7464 3a3a flags..., std:: │ │ │ -0006fbe0: 6675 6e63 7469 6f6e 266c 743b 766f 6964 function<void │ │ │ -0006fbf0: 2873 7464 3a3a 7665 6374 6f72 266c 743b (std::vector< │ │ │ -0006fc00: 7463 703a 3a65 6e64 706f 696e 7426 6774 tcp::endpoint> │ │ │ -0006fc10: 3b20 636f 6e73 7426 616d 703b 2926 6774 ; const&)> │ │ │ -0006fc20: 3b20 6629 0a09 7b0a 0909 666f 7220 2861 ; f)..{...for (a │ │ │ -0006fc30: 7574 6f26 616d 703b 206e 203a 206d 5f6e uto& n : m_n │ │ │ -0006fc40: 6f64 6573 290a 0909 096e 2e73 6563 6f6e odes)....n.secon │ │ │ -0006fc50: 642e 6468 742e 616e 6e6f 756e 6365 2869 d.dht.announce(i │ │ │ -0006fc60: 682c 206c 6973 7465 6e5f 706f 7274 2c20 h, listen_port, │ │ │ -0006fc70: 666c 6167 732c 2066 293b 0a09 7d0a 0a09 flags, f);..}... │ │ │ -0006fc80: 766f 6964 2064 6874 5f74 7261 636b 6572 void dht_tracker │ │ │ -0006fc90: 3a3a 7361 6d70 6c65 5f69 6e66 6f68 6173 ::sample_infohas │ │ │ -0006fca0: 6865 7328 7564 703a 3a65 6e64 706f 696e hes(udp::endpoin │ │ │ -0006fcb0: 7420 636f 6e73 7426 616d 703b 2065 702c t const& ep, │ │ │ -0006fcc0: 2073 6861 315f 6861 7368 2063 6f6e 7374 sha1_hash const │ │ │ -0006fcd0: 2661 6d70 3b20 7461 7267 6574 0a09 092c & target..., │ │ │ -0006fce0: 2073 7464 3a3a 6675 6e63 7469 6f6e 266c std::function&l │ │ │ -0006fcf0: 743b 766f 6964 286e 6f64 655f 6964 0a09 t;void(node_id.. │ │ │ -0006fd00: 0909 2c20 7469 6d65 5f64 7572 6174 696f .., time_duratio │ │ │ -0006fd10: 6e0a 0909 092c 2069 6e74 2c20 7374 643a n...., int, std: │ │ │ -0006fd20: 3a76 6563 746f 7226 6c74 3b73 6861 315f :vector<sha1_ │ │ │ -0006fd30: 6861 7368 2667 743b 0a09 0909 2c20 7374 hash>...., st │ │ │ -0006fd40: 643a 3a76 6563 746f 7226 6c74 3b73 7464 d::vector<std │ │ │ -0006fd50: 3a3a 7061 6972 266c 743b 7368 6131 5f68 ::pair<sha1_h │ │ │ -0006fd60: 6173 682c 2075 6470 3a3a 656e 6470 6f69 ash, udp::endpoi │ │ │ -0006fd70: 6e74 2667 743b 2667 743b 2926 6774 3b20 nt>>)> │ │ │ -0006fd80: 6629 0a09 7b0a 0909 666f 7220 2861 7574 f)..{...for (aut │ │ │ -0006fd90: 6f26 616d 703b 206e 203a 206d 5f6e 6f64 o& n : m_nod │ │ │ -0006fda0: 6573 290a 0909 7b0a 0909 0969 6620 2865 es)...{....if (e │ │ │ -0006fdb0: 702e 7072 6f74 6f63 6f6c 2829 2021 3d20 p.protocol() != │ │ │ -0006fdc0: 286e 2e66 6972 7374 2e67 6574 5f65 7874 (n.first.get_ext │ │ │ -0006fdd0: 6572 6e61 6c5f 6164 6472 6573 7328 292e ernal_address(). │ │ │ -0006fde0: 6973 5f76 3428 2920 3f20 7564 703a 3a76 is_v4() ? udp::v │ │ │ -0006fdf0: 3428 2920 3a20 7564 703a 3a76 3628 2929 4() : udp::v6()) │ │ │ -0006fe00: 290a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ).
    < │ │ │ -0006fe30: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0006fe40: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0006fe70: 7372 632f 6b61 6465 6d6c 6961 2f6e 6f64 src/kademlia/nod │ │ │ -0006fe80: 652e 6370 703a 3131 3638 3c2f 613e 3c2f e.cpp:1168keep the │ │ │ -0006fea0: 7265 7475 726e 6564 2076 616c 7565 2074 returned value t │ │ │ -0006feb0: 6f20 7061 7373 2061 7320 6120 6c69 6d69 o pass as a limi │ │ │ -0006fec0: 7420 746f 2077 7269 7465 5f6e 6f64 6573 t to write_nodes │ │ │ -0006fed0: 5f65 6e74 7269 6573 2077 6865 6e20 696d _entries when im │ │ │ -0006fee0: 706c 656d 656e 7465 643c 2f74 643e 3c2f plemented

    keep the │ │ │ -0006ff40: 7265 7475 726e 6564 2076 616c 7565 2074 returned value t │ │ │ -0006ff50: 6f20 7061 7373 2061 7320 6120 6c69 6d69 o pass as a limi │ │ │ -0006ff60: 740a 746f 2077 7269 7465 5f6e 6f64 6573 t.to write_nodes │ │ │ -0006ff70: 5f65 6e74 7269 6573 2077 6865 6e20 696d _entries when im │ │ │ -0006ff80: 706c 656d 656e 7465 643c 2f68 323e 3c68 plemented

    ../src/kademli │ │ │ -0006ffa0: 612f 6e6f 6465 2e63 7070 3a31 3136 383c a/node.cpp:1168< │ │ │ -0006ffb0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -0006fff0: 7d0a 097d 0a09 656c 7365 2069 6620 2871  }..}..else if (q
    │ │ │ -00070000: 7565 7279 203d 3d20 2273 616d 706c 655f  uery == "sample_
    │ │ │ -00070010: 696e 666f 6861 7368 6573 2229 0a09 7b0a  infohashes")..{.
    │ │ │ -00070020: 0909 7374 6174 6963 206b 6579 5f64 6573  ..static key_des
    │ │ │ -00070030: 635f 7420 636f 6e73 7420 6d73 675f 6465  c_t const msg_de
    │ │ │ -00070040: 7363 5b5d 203d 207b 0a09 0909 7b22 7461  sc[] = {....{"ta
    │ │ │ -00070050: 7267 6574 222c 2062 6465 636f 6465 5f6e  rget", bdecode_n
    │ │ │ -00070060: 6f64 653a 3a73 7472 696e 675f 742c 2032  ode::string_t, 2
    │ │ │ -00070070: 302c 2030 7d2c 0a09 0909 7b22 7761 6e74  0, 0},....{"want
    │ │ │ -00070080: 222c 2062 6465 636f 6465 5f6e 6f64 653a  ", bdecode_node:
    │ │ │ -00070090: 3a6c 6973 745f 742c 2030 2c20 6b65 795f  :list_t, 0, key_
    │ │ │ -000700a0: 6465 7363 5f74 3a3a 6f70 7469 6f6e 616c  desc_t::optional
    │ │ │ -000700b0: 7d2c 0a09 097d 3b0a 0a09 0962 6465 636f  },...};....bdeco
    │ │ │ -000700c0: 6465 5f6e 6f64 6520 6d73 675f 6b65 7973  de_node msg_keys
    │ │ │ -000700d0: 5b32 5d3b 0a09 0969 6620 2821 7665 7269  [2];...if (!veri
    │ │ │ -000700e0: 6679 5f6d 6573 7361 6765 2861 7267 5f65  fy_message(arg_e
    │ │ │ -000700f0: 6e74 2c20 6d73 675f 6465 7363 2c20 6d73  nt, msg_desc, ms
    │ │ │ -00070100: 675f 6b65 7973 2c20 6572 726f 725f 7374  g_keys, error_st
    │ │ │ -00070110: 7269 6e67 2929 0a09 097b 0a09 0909 6d5f  ring))...{....m_
    │ │ │ -00070120: 636f 756e 7465 7273 2e69 6e63 5f73 7461  counters.inc_sta
    │ │ │ -00070130: 7473 5f63 6f75 6e74 6572 2863 6f75 6e74  ts_counter(count
    │ │ │ -00070140: 6572 733a 3a64 6874 5f69 6e76 616c 6964  ers::dht_invalid
    │ │ │ -00070150: 5f73 616d 706c 655f 696e 666f 6861 7368  _sample_infohash
    │ │ │ -00070160: 6573 293b 0a09 0909 696e 636f 6d69 6e67  es);....incoming
    │ │ │ -00070170: 5f65 7272 6f72 2865 2c20 6572 726f 725f  _error(e, error_
    │ │ │ -00070180: 7374 7269 6e67 293b 0a09 0909 7265 7475  string);....retu
    │ │ │ -00070190: 726e 3b0a 0909 7d0a 0a09 096d 5f63 6f75  rn;...}....m_cou
    │ │ │ -000701a0: 6e74 6572 732e 696e 635f 7374 6174 735f  nters.inc_stats_
    │ │ │ -000701b0: 636f 756e 7465 7228 636f 756e 7465 7273  counter(counters
    │ │ │ -000701c0: 3a3a 6468 745f 7361 6d70 6c65 5f69 6e66  ::dht_sample_inf
    │ │ │ -000701d0: 6f68 6173 6865 735f 696e 293b 0a09 0973  ohashes_in);...s
    │ │ │ -000701e0: 6861 315f 6861 7368 2063 6f6e 7374 2074  ha1_hash const t
    │ │ │ -000701f0: 6172 6765 7428 6d73 675f 6b65 7973 5b30  arget(msg_keys[0
    │ │ │ -00070200: 5d2e 7374 7269 6e67 5f70 7472 2829 293b  ].string_ptr());
    │ │ │ -00070210: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -00070240: 0909 6d5f 7374 6f72 6167 652e 6765 745f ..m_storage.get_ │ │ │ -00070250: 696e 666f 6861 7368 6573 5f73 616d 706c infohashes_sampl │ │ │ -00070260: 6528 7265 706c 7929 3b0a 3c2f 6469 763e e(reply);.
    │ │ │ -00070270: 0a09 0977 7269 7465 5f6e 6f64 6573 5f65 ...write_nodes_e │ │ │ -00070280: 6e74 7269 6573 2874 6172 6765 742c 206d ntries(target, m │ │ │ -00070290: 7367 5f6b 6579 735b 315d 2c20 7265 706c sg_keys[1], repl │ │ │ -000702a0: 7929 3b0a 097d 0a09 656c 7365 0a09 7b0a y);..}..else..{. │ │ │ -000702b0: 0909 2f2f 2069 6620 7765 2064 6f6e 2774 ..// if we don't │ │ │ -000702c0: 2072 6563 6f67 6e69 7a65 2074 6865 206d recognize the m │ │ │ -000702d0: 6573 7361 6765 2062 7574 2074 6865 7265 essage but there │ │ │ -000702e0: 2773 2061 0a09 092f 2f20 2774 6172 6765 's a...// 'targe │ │ │ -000702f0: 7427 206f 7220 2769 6e66 6f5f 6861 7368 t' or 'info_hash │ │ │ -00070300: 2720 696e 2074 6865 2061 7267 756d 656e ' in the argumen │ │ │ -00070310: 7473 2c20 7472 6561 7420 6974 0a09 092f ts, treat it.../ │ │ │ -00070320: 2f20 6173 2066 696e 645f 6e6f 6465 2074 / as find_node t │ │ │ -00070330: 6f20 6265 2066 7574 7572 6520 636f 6d70 o be future comp │ │ │ -00070340: 6174 6962 6c65 0a09 0962 6465 636f 6465 atible...bdecode │ │ │ -00070350: 5f6e 6f64 6520 7461 7267 6574 5f65 6e74 _node target_ent │ │ │ -00070360: 203d 2061 7267 5f65 6e74 2e64 6963 745f = arg_ent.dict_ │ │ │ -00070370: 6669 6e64 5f73 7472 696e 6728 2274 6172 find_string("tar │ │ │ -00070380: 6765 7422 293b 0a09 0969 6620 2821 7461 get");...if (!ta │ │ │ -00070390: 7267 6574 5f65 6e74 207c 7c20 7461 7267 rget_ent || targ │ │ │ -000703a0: 6574 5f65 6e74 2e73 7472 696e 675f 6c65 et_ent.string_le │ │ │ -000703b0: 6e67 7468 2829 2021 3d20 3230 290a 0909 ngth() != 20)... │ │ │ -000703c0: 7b0a 0909 0974 6172 6765 745f 656e 7420 {....target_ent │ │ │ -000703d0: 3d20 6172 675f 656e 742e 6469 6374 5f66 = arg_ent.dict_f │ │ │ -000703e0: 696e 645f 7374 7269 6e67 2822 696e 666f ind_string("info │ │ │ -000703f0: 5f68 6173 6822 293b 0a09 0909 6966 2028 _hash");....if ( │ │ │ -00070400: 2174 6172 6765 745f 656e 7420 7c7c 2074 !target_ent || t │ │ │ -00070410: 6172 6765 745f 656e 742e 7374 7269 6e67 arget_ent.string │ │ │ -00070420: 5f6c 656e 6774 6828 2920 213d 2032 3029 _length() != 20) │ │ │ -00070430: 0a09 0909 7b0a 0909 0909 696e 636f 6d69 ....{.....incomi │ │ │ -00070440: 6e67 5f65 7272 6f72 2865 2c20 2275 6e6b ng_error(e, "unk │ │ │ -00070450: 6e6f 776e 206d 6573 7361 6765 2229 3b0a nown message");. │ │ │ -00070460: 0909 0909 7265 7475 726e 3b0a 0909 097d ....return;....} │ │ │ -00070470: 0a09 097d 0a0a 0909 7368 6131 5f68 6173 ...}....sha1_has │ │ │ -00070480: 6820 636f 6e73 7420 7461 7267 6574 2874 h const target(t │ │ │ -00070490: 6172 6765 745f 656e 742e 7374 7269 6e67 arget_ent.string │ │ │ -000704a0: 5f70 7472 2829 293b 0a09 092f 2f20 616c _ptr());...// al │ │ │ -000704b0: 7761 7973 2072 6574 7572 6e20 6e6f 6465 ways return node │ │ │ -000704c0: 7320 6173 2077 656c 6c20 6173 2070 6565 s as well as pee │ │ │ -000704d0: 7273 0a09 0977 7269 7465 5f6e 6f64 6573 rs...write_nodes │ │ │ -000704e0: 5f65 6e74 7269 6573 2874 6172 6765 742c _entries(target, │ │ │ -000704f0: 2061 7267 5f65 6e74 2e64 6963 745f 6669 arg_ent.dict_fi │ │ │ -00070500: 6e64 5f6c 6973 7428 2277 616e 7422 292c nd_list("want"), │ │ │ -00070510: 2072 6570 6c79 293b 0a09 7d0a 7d0a 0a3c reply);..}.}..< │ │ │ -00070520: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ -00070530: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ -00070540: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ -00070550: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ -00070560: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ -00070590: 2f6b 6164 656d 6c69 612f 6e6f 6465 2e63 /kademlia/node.c │ │ │ -000705a0: 7070 3a31 3139 363c 2f61 3e3c 2f74 643e pp:1196 │ │ │ -000705b0: 3c74 643e 6c69 6d69 7420 6e75 6d62 6572 limit number │ │ │ -000705c0: 206f 6620 656e 7472 6965 7320 696e 2074 of entries in t │ │ │ -000705d0: 6865 2072 6573 756c 743c 2f74 643e 3c2f he result

    limit num │ │ │ -00070630: 6265 7220 6f66 2065 6e74 7269 6573 2069 ber of entries i │ │ │ -00070640: 6e20 7468 6520 7265 7375 6c74 3c2f 6832 n the result

    ../src/kade │ │ │ -00070660: 6d6c 6961 2f6e 6f64 652e 6370 703a 3131 mlia/node.cpp:11 │ │ │ -00070670: 3936 3c2f 6834 3e3c 7072 6520 7374 796c 96

    ..// if we don'
    │ │ │ -000706c0: 7420 7265 636f 676e 697a 6520 7468 6520  t recognize the 
    │ │ │ -000706d0: 6d65 7373 6167 6520 6275 7420 7468 6572  message but ther
    │ │ │ -000706e0: 6527 7320 610a 0909 2f2f 2027 7461 7267  e's a...// 'targ
    │ │ │ -000706f0: 6574 2720 6f72 2027 696e 666f 5f68 6173  et' or 'info_has
    │ │ │ -00070700: 6827 2069 6e20 7468 6520 6172 6775 6d65  h' in the argume
    │ │ │ -00070710: 6e74 732c 2074 7265 6174 2069 740a 0909  nts, treat it...
    │ │ │ -00070720: 2f2f 2061 7320 6669 6e64 5f6e 6f64 6520  // as find_node 
    │ │ │ -00070730: 746f 2062 6520 6675 7475 7265 2063 6f6d  to be future com
    │ │ │ -00070740: 7061 7469 626c 650a 0909 6264 6563 6f64  patible...bdecod
    │ │ │ -00070750: 655f 6e6f 6465 2074 6172 6765 745f 656e  e_node target_en
    │ │ │ -00070760: 7420 3d20 6172 675f 656e 742e 6469 6374  t = arg_ent.dict
    │ │ │ -00070770: 5f66 696e 645f 7374 7269 6e67 2822 7461  _find_string("ta
    │ │ │ -00070780: 7267 6574 2229 3b0a 0909 6966 2028 2174  rget");...if (!t
    │ │ │ -00070790: 6172 6765 745f 656e 7420 7c7c 2074 6172  arget_ent || tar
    │ │ │ -000707a0: 6765 745f 656e 742e 7374 7269 6e67 5f6c  get_ent.string_l
    │ │ │ -000707b0: 656e 6774 6828 2920 213d 2032 3029 0a09  ength() != 20)..
    │ │ │ -000707c0: 097b 0a09 0909 7461 7267 6574 5f65 6e74  .{....target_ent
    │ │ │ -000707d0: 203d 2061 7267 5f65 6e74 2e64 6963 745f   = arg_ent.dict_
    │ │ │ -000707e0: 6669 6e64 5f73 7472 696e 6728 2269 6e66  find_string("inf
    │ │ │ -000707f0: 6f5f 6861 7368 2229 3b0a 0909 0969 6620  o_hash");....if 
    │ │ │ -00070800: 2821 7461 7267 6574 5f65 6e74 207c 7c20  (!target_ent || 
    │ │ │ -00070810: 7461 7267 6574 5f65 6e74 2e73 7472 696e  target_ent.strin
    │ │ │ -00070820: 675f 6c65 6e67 7468 2829 2021 3d20 3230  g_length() != 20
    │ │ │ -00070830: 290a 0909 097b 0a09 0909 0969 6e63 6f6d  )....{.....incom
    │ │ │ -00070840: 696e 675f 6572 726f 7228 652c 2022 756e  ing_error(e, "un
    │ │ │ -00070850: 6b6e 6f77 6e20 6d65 7373 6167 6522 293b  known message");
    │ │ │ -00070860: 0a09 0909 0972 6574 7572 6e3b 0a09 0909  .....return;....
    │ │ │ -00070870: 7d0a 0909 7d0a 0a09 0973 6861 315f 6861  }...}....sha1_ha
    │ │ │ -00070880: 7368 2063 6f6e 7374 2074 6172 6765 7428  sh const target(
    │ │ │ -00070890: 7461 7267 6574 5f65 6e74 2e73 7472 696e  target_ent.strin
    │ │ │ -000708a0: 675f 7074 7228 2929 3b0a 0909 2f2f 2061  g_ptr());...// a
    │ │ │ -000708b0: 6c77 6179 7320 7265 7475 726e 206e 6f64  lways return nod
    │ │ │ -000708c0: 6573 2061 7320 7765 6c6c 2061 7320 7065  es as well as pe
    │ │ │ -000708d0: 6572 730a 0909 7772 6974 655f 6e6f 6465  ers...write_node
    │ │ │ -000708e0: 735f 656e 7472 6965 7328 7461 7267 6574  s_entries(target
    │ │ │ -000708f0: 2c20 6172 675f 656e 742e 6469 6374 5f66  , arg_ent.dict_f
    │ │ │ -00070900: 696e 645f 6c69 7374 2822 7761 6e74 2229  ind_list("want")
    │ │ │ -00070910: 2c20 7265 706c 7929 3b0a 097d 0a7d 0a0a  , reply);..}.}..
    │ │ │ -00070920: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    vo │ │ │ -00070950: 6964 206e 6f64 653a 3a77 7269 7465 5f6e id node::write_n │ │ │ -00070960: 6f64 6573 5f65 6e74 7269 6573 2873 6861 odes_entries(sha │ │ │ -00070970: 315f 6861 7368 2063 6f6e 7374 2661 6d70 1_hash const& │ │ │ -00070980: 3b20 696e 666f 5f68 6173 680a 3c2f 6469 ; info_hash.., bdecode_nod │ │ │ -000709a0: 6520 636f 6e73 7426 616d 703b 2077 616e e const& wan │ │ │ -000709b0: 742c 2065 6e74 7279 2661 6d70 3b20 7229 t, entry& r) │ │ │ -000709c0: 0a7b 0a09 2f2f 2069 6620 6e6f 2077 616e .{..// if no wan │ │ │ -000709d0: 7473 2065 6e74 7279 2077 6173 2073 7065 ts entry was spe │ │ │ -000709e0: 6369 6669 6564 2c20 696e 636c 7564 6520 cified, include │ │ │ -000709f0: 6120 6e6f 6465 730a 092f 2f20 656e 7472 a nodes..// entr │ │ │ -00070a00: 7920 6261 7365 6420 6f6e 2074 6865 2070 y based on the p │ │ │ -00070a10: 726f 746f 636f 6c20 7468 6520 7265 7175 rotocol the requ │ │ │ -00070a20: 6573 7420 6361 6d65 2069 6e20 7769 7468 est came in with │ │ │ -00070a30: 0a09 6966 2028 7761 6e74 2e74 7970 6528 ..if (want.type( │ │ │ -00070a40: 2920 213d 2062 6465 636f 6465 5f6e 6f64 ) != bdecode_nod │ │ │ -00070a50: 653a 3a6c 6973 745f 7429 0a09 7b0a 0909 e::list_t)..{... │ │ │ -00070a60: 7374 643a 3a76 6563 746f 7226 6c74 3b6e std::vector<n │ │ │ -00070a70: 6f64 655f 656e 7472 7926 6774 3b20 636f ode_entry> co │ │ │ -00070a80: 6e73 7420 6e20 3d20 6d5f 7461 626c 652e nst n = m_table. │ │ │ -00070a90: 6669 6e64 5f6e 6f64 6528 696e 666f 5f68 find_node(info_h │ │ │ -00070aa0: 6173 682c 207b 7d29 3b0a 0909 725b 7072 ash, {});...r[pr │ │ │ -00070ab0: 6f74 6f63 6f6c 5f6e 6f64 6573 5f6b 6579 otocol_nodes_key │ │ │ -00070ac0: 2829 5d20 3d20 7772 6974 655f 6e6f 6465 ()] = write_node │ │ │ -00070ad0: 735f 656e 7472 7928 6e29 3b0a 0909 7265 s_entry(n);...re │ │ │ -00070ae0: 7475 726e 3b0a 097d 0a0a 092f 2f20 6966 turn;..}...// if │ │ │ -00070af0: 2074 6865 7265 2069 7320 6120 7761 6e74 there is a want │ │ │ -00070b00: 7320 656e 7472 7920 7468 656e 2077 6520 s entry then we │ │ │ -00070b10: 6d61 7920 6e65 6564 2074 6f20 7265 6163 may need to reac │ │ │ -00070b20: 6820 696e 746f 0a09 2f2f 2061 6e6f 7468 h into..// anoth │ │ │ -00070b30: 6572 206e 6f64 6527 7320 726f 7574 696e er node's routin │ │ │ -00070b40: 6720 7461 626c 6520 746f 2067 6574 206e g table to get n │ │ │ -00070b50: 6f64 6573 206f 6620 7468 6520 7265 7175 odes of the requ │ │ │ -00070b60: 6573 7465 6420 7479 7065 0a09 2f2f 2077 ested type..// w │ │ │ -00070b70: 6520 7573 6520 6120 6d61 7020 6d61 696e e use a map main │ │ │ -00070b80: 7461 696e 6564 2062 7920 7468 6520 6f77 tained by the ow │ │ │ -00070b90: 6e69 6e67 2064 6874 5f74 7261 636b 6572 ning dht_tracker │ │ │ -00070ba0: 2074 6f20 6669 6e64 2074 6865 0a09 2f2f to find the..// │ │ │ -00070bb0: 206e 6f64 6520 6173 736f 6369 6174 6564 node associated │ │ │ -00070bc0: 2077 6974 6820 6561 6368 2073 7472 696e with each strin │ │ │ -00070bd0: 6720 696e 2074 6865 2077 616e 7420 6c69 g in the want li │ │ │ -00070be0: 7374 2c20 7768 6963 6820 6d61 790a 092f st, which may../ │ │ │ -00070bf0: 2f20 696e 636c 7564 6520 7468 6973 206e / include this n │ │ │ -00070c00: 6f64 650a 0966 6f72 2028 696e 7420 6920 ode..for (int i │ │ │ -00070c10: 3d20 303b 2069 2026 6c74 3b20 7761 6e74 = 0; i < want │ │ │ -00070c20: 2e6c 6973 745f 7369 7a65 2829 3b20 2b2b .list_size(); ++ │ │ │ -00070c30: 6929 0a09 7b0a 0909 6264 6563 6f64 655f i)..{...bdecode_ │ │ │ -00070c40: 6e6f 6465 2077 616e 7465 6420 3d20 7761 node wanted = wa │ │ │ -00070c50: 6e74 2e6c 6973 745f 6174 2869 293b 0a09 nt.list_at(i);.. │ │ │ -00070c60: 0969 6620 2877 616e 7465 642e 7479 7065 .if (wanted.type │ │ │ -00070c70: 2829 2021 3d20 6264 6563 6f64 655f 6e6f () != bdecode_no │ │ │ -00070c80: 6465 3a3a 7374 7269 6e67 5f74 290a 0909 de::string_t)... │ │ │ -00070c90: 0963 6f6e 7469 6e75 653b 0a09 096e 6f64 .continue;...nod │ │ │ -00070ca0: 652a 2077 616e 7465 645f 6e6f 6465 203d e* wanted_node = │ │ │ -00070cb0: 206d 5f67 6574 5f66 6f72 6569 676e 5f6e m_get_foreign_n │ │ │ -00070cc0: 6f64 6528 696e 666f 5f68 6173 682c 2077 ode(info_hash, w │ │ │ -00070cd0: 616e 7465 642e 7374 7269 6e67 5f76 616c anted.string_val │ │ │ -00070ce0: 7565 2829 293b 0a09 0969 6620 2821 7761 ue());...if (!wa │ │ │ -00070cf0: 6e74 6564 5f6e 6f64 6529 2063 6f6e 7469 nted_node) conti │ │ │ -00070d00: 6e75 653b 0a09 0973 7464 3a3a 7665 6374 nue;...std::vect │ │ │ -00070d10: 6f72 266c 743b 6e6f 6465 5f65 6e74 7279 or<node_entry │ │ │ -00070d20: 2667 743b 2063 6f6e 7374 206e 203d 2077 > const n = w │ │ │ -00070d30: 616e 7465 645f 6e6f 6465 2d26 6774 3b6d anted_node->m │ │ │ -00070d40: 5f74 6162 6c65 2e66 696e 645f 6e6f 6465 _table.find_node │ │ │ -00070d50: 2869 6e66 6f5f 6861 7368 2c20 7b7d 293b (info_hash, {}); │ │ │ -00070d60: 0a09 0972 5b77 616e 7465 645f 6e6f 6465 ...r[wanted_node │ │ │ -00070d70: 2d26 6774 3b70 726f 746f 636f 6c5f 6e6f ->protocol_no │ │ │ -00070d80: 6465 735f 6b65 7928 295d 203d 2077 7269 des_key()] = wri │ │ │ -00070d90: 7465 5f6e 6f64 6573 5f65 6e74 7279 286e te_nodes_entry(n │ │ │ -00070da0: 293b 0a09 7d0a 7d0a 0a6e 6f64 653a 3a70 );..}.}..node::p │ │ │ -00070db0: 726f 746f 636f 6c5f 6465 7363 7269 7074 rotocol_descript │ │ │ -00070dc0: 6f72 2063 6f6e 7374 2661 6d70 3b20 6e6f or const& no │ │ │ -00070dd0: 6465 3a3a 6d61 705f 7072 6f74 6f63 6f6c de::map_protocol │ │ │ -00070de0: 5f74 6f5f 6465 7363 7269 7074 6f72 2875 _to_descriptor(u │ │ │ -00070df0: 6470 2063 6f6e 7374 2070 726f 746f 636f dp const protoco │ │ │ -00070e00: 6c29 0a7b 0a3c 2f70 7265 3e3c 2f74 643e l).{.
    │ │ │ -00070e10: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00070e40: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00070e50: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00070e60: 7074 3a65 7870 616e 6428 3235 3729 223e pt:expand(257)"> │ │ │ -00070e70: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -00070e80: 7272 656e 742f 6669 6c65 5f73 746f 7261 rrent/file_stora │ │ │ -00070e90: 6765 2e68 7070 3a37 3132 3c2f 613e 3c2f ge.hpp:712can we re │ │ │ -00070eb0: 6d6f 7665 2073 6574 5f6e 616d 653f 3c2f move set_name?

    can │ │ │ -00070f10: 7765 2072 656d 6f76 6520 7365 745f 6e61 we remove set_na │ │ │ -00070f20: 6d65 3f3c 2f68 323e 3c68 343e 2e2e 2f69 me?

    ../i │ │ │ -00070f30: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -00070f40: 742f 6669 6c65 5f73 746f 7261 6765 2e68 t/file_storage.h │ │ │ -00070f50: 7070 3a37 3132 3c2f 6834 3e3c 7072 6520 pp:712

    #endif....,
    │ │ │ -00070fa0: 2073 7464 3a3a 696e 7436 345f 7420 636f   std::int64_t co
    │ │ │ -00070fb0: 6e73 7420 6d74 696d 652c 2073 7472 696e  nst mtime, strin
    │ │ │ -00070fc0: 675f 7669 6577 2063 6f6e 7374 2073 796d  g_view const sym
    │ │ │ -00070fd0: 6c69 6e6b 5f70 6174 680a 0909 092c 2063  link_path...., c
    │ │ │ -00070fe0: 6861 7220 636f 6e73 742a 2072 6f6f 745f  har const* root_
    │ │ │ -00070ff0: 6861 7368 293b 0a0a 0909 7374 643a 3a73  hash);....std::s
    │ │ │ -00071000: 7472 696e 6720 696e 7465 726e 616c 5f66  tring internal_f
    │ │ │ -00071010: 696c 655f 7061 7468 2866 696c 655f 696e  ile_path(file_in
    │ │ │ -00071020: 6465 785f 7420 696e 6465 7829 2063 6f6e  dex_t index) con
    │ │ │ -00071030: 7374 3b0a 0909 6669 6c65 5f69 6e64 6578  st;...file_index
    │ │ │ -00071040: 5f74 206c 6173 745f 6669 6c65 2829 2063  _t last_file() c
    │ │ │ -00071050: 6f6e 7374 206e 6f65 7863 6570 743b 0a0a  onst noexcept;..
    │ │ │ -00071060: 0909 6175 783a 3a70 6174 685f 696e 6465  ..aux::path_inde
    │ │ │ -00071070: 785f 7420 6765 745f 6f72 5f61 6464 5f70  x_t get_or_add_p
    │ │ │ -00071080: 6174 6828 7374 7269 6e67 5f76 6965 7720  ath(string_view 
    │ │ │ -00071090: 7061 7468 293b 0a0a 0909 2f2f 2074 6865  path);....// the
    │ │ │ -000710a0: 206e 756d 6265 7220 6f66 2062 7974 6573   number of bytes
    │ │ │ -000710b0: 2069 6e20 6120 7265 6775 6c61 7220 7069   in a regular pi
    │ │ │ -000710c0: 6563 650a 0909 2f2f 2028 692e 652e 206e  ece...// (i.e. n
    │ │ │ -000710d0: 6f74 2074 6865 2070 6f74 656e 7469 616c  ot the potential
    │ │ │ -000710e0: 6c79 2074 7275 6e63 6174 6564 206c 6173  ly truncated las
    │ │ │ -000710f0: 7420 7069 6563 6529 0a09 0969 6e74 206d  t piece)...int m
    │ │ │ -00071100: 5f70 6965 6365 5f6c 656e 6774 6820 3d20  _piece_length = 
    │ │ │ -00071110: 303b 0a0a 0909 2f2f 2074 6865 206e 756d  0;....// the num
    │ │ │ -00071120: 6265 7220 6f66 2070 6965 6365 7320 696e  ber of pieces in
    │ │ │ -00071130: 2074 6865 2074 6f72 7265 6e74 0a09 0969   the torrent...i
    │ │ │ -00071140: 6e74 206d 5f6e 756d 5f70 6965 6365 7320  nt m_num_pieces 
    │ │ │ -00071150: 3d20 303b 0a0a 0909 2f2f 2077 6865 7468  = 0;....// wheth
    │ │ │ -00071160: 6572 2074 6869 7320 6973 2061 2076 3220  er this is a v2 
    │ │ │ -00071170: 746f 7272 656e 7420 6f72 206e 6f74 2e20  torrent or not. 
    │ │ │ -00071180: 4164 6469 7469 6f6e 616c 2072 6571 7569  Additional requi
    │ │ │ -00071190: 7265 6d65 6e74 7320 6170 706c 7920 746f  rements apply to
    │ │ │ -000711a0: 0a09 092f 2f20 7632 2074 6f72 7265 6e74  ...// v2 torrent
    │ │ │ -000711b0: 730a 0909 626f 6f6c 206d 5f76 3220 3d20  s...bool m_v2 = 
    │ │ │ -000711c0: 6661 6c73 653b 0a0a 3c64 6976 2073 7479  false;..
    ..void upd │ │ │ -00071200: 6174 655f 7061 7468 5f69 6e64 6578 2861 ate_path_index(a │ │ │ -00071210: 7578 3a3a 6669 6c65 5f65 6e74 7279 2661 ux::file_entry&a │ │ │ -00071220: 6d70 3b20 652c 2073 7464 3a3a 7374 7269 mp; e, std::stri │ │ │ -00071230: 6e67 2063 6f6e 7374 2661 6d70 3b20 7061 ng const& pa │ │ │ -00071240: 7468 0a3c 2f64 6976 3e09 0909 2c20 626f th.
    ..., bo │ │ │ -00071250: 6f6c 2073 6574 5f6e 616d 6520 3d20 7472 ol set_name = tr │ │ │ -00071260: 7565 293b 0a0a 0909 2f2f 2074 6865 206c ue);....// the l │ │ │ -00071270: 6973 7420 6f66 2066 696c 6573 2074 6861 ist of files tha │ │ │ -00071280: 7420 7468 6973 2074 6f72 7265 6e74 2063 t this torrent c │ │ │ -00071290: 6f6e 7369 7374 7320 6f66 0a09 0961 7578 onsists of...aux │ │ │ -000712a0: 3a3a 7665 6374 6f72 266c 743b 6175 783a ::vector<aux: │ │ │ -000712b0: 3a66 696c 655f 656e 7472 792c 2066 696c :file_entry, fil │ │ │ -000712c0: 655f 696e 6465 785f 7426 6774 3b20 6d5f e_index_t> m_ │ │ │ -000712d0: 6669 6c65 733b 0a0a 2369 6620 544f 5252 files;..#if TORR │ │ │ -000712e0: 454e 545f 4142 495f 5645 5253 494f 4e20 ENT_ABI_VERSION │ │ │ -000712f0: 266c 743b 2034 0a09 092f 2f20 6966 2074 < 4...// if t │ │ │ -00071300: 6865 7265 2061 7265 2073 6861 3120 6861 here are sha1 ha │ │ │ -00071310: 7368 6573 2066 6f72 2065 6163 6820 696e shes for each in │ │ │ -00071320: 6469 7669 6475 616c 2066 696c 6520 7468 dividual file th │ │ │ -00071330: 6572 6520 6172 6520 6173 206d 616e 790a ere are as many. │ │ │ -00071340: 0909 2f2f 2065 6e74 7269 6573 2069 6e20 ..// entries in │ │ │ -00071350: 7468 6973 2061 7272 6179 2061 7320 7468 this array as th │ │ │ -00071360: 6520 6d5f 6669 6c65 7320 6172 7261 792e e m_files array. │ │ │ -00071370: 2045 6163 6820 656e 7472 7920 696e 206d Each entry in m │ │ │ -00071380: 5f66 696c 6573 2068 6173 0a09 092f 2f20 _files has...// │ │ │ -00071390: 6120 636f 7272 6573 706f 6e64 696e 6720 a corresponding │ │ │ -000713a0: 6861 7368 2070 6f69 6e74 6572 2069 6e20 hash pointer in │ │ │ -000713b0: 7468 6973 2061 7272 6179 2e20 5468 6520 this array. The │ │ │ -000713c0: 7265 6173 6f6e 2074 6f20 7370 6c69 7420 reason to split │ │ │ -000713d0: 6974 2075 700a 0909 2f2f 2069 6e20 7365 it up...// in se │ │ │ -000713e0: 7061 7261 7465 2061 7272 6179 7320 6973 parate arrays is │ │ │ -000713f0: 2074 6f20 7361 7665 206d 656d 6f72 7920 to save memory │ │ │ -00071400: 696e 2063 6173 6520 7468 6520 746f 7272 in case the torr │ │ │ -00071410: 656e 7420 646f 6573 6e27 7420 6861 7665 ent doesn't have │ │ │ -00071420: 0a09 092f 2f20 6669 6c65 2068 6173 6865 ...// file hashe │ │ │ -00071430: 730a 0909 2f2f 2074 6865 2070 6f69 6e74 s...// the point │ │ │ -00071440: 6572 7320 696e 2074 6869 7320 7665 6374 ers in this vect │ │ │ -00071450: 6f72 2061 7265 2070 6f69 6e74 696e 6720 or are pointing │ │ │ -00071460: 696e 746f 2074 6865 202e 746f 7272 656e into the .torren │ │ │ -00071470: 7420 6669 6c65 2069 6e0a 0909 2f2f 206d t file in...// m │ │ │ -00071480: 656d 6f72 7920 7768 6963 6820 6973 205f emory which is _ │ │ │ -00071490: 6e6f 745f 206f 776e 6564 2062 7920 7468 not_ owned by th │ │ │ -000714a0: 6973 2066 696c 655f 7374 6f72 6167 6520 is file_storage │ │ │ -000714b0: 6f62 6a65 6374 2e20 4974 2773 2073 696d object. It's sim │ │ │ -000714c0: 706c 790a 0909 2f2f 2061 206e 6f6e 2d6f ply...// a non-o │ │ │ -000714d0: 776e 696e 6720 706f 696e 7465 722e 2049 wning pointer. I │ │ │ -000714e0: 7420 6973 2074 6865 2075 7365 7227 7320 t is the user's │ │ │ -000714f0: 7265 7370 6f6e 7369 6269 6c69 7479 2074 responsibility t │ │ │ -00071500: 6861 7420 7468 6520 6861 7368 0a09 092f hat the hash.../ │ │ │ -00071510: 2f20 7374 6179 7320 7661 6c69 6420 7468 / stays valid th │ │ │ -00071520: 726f 7567 686f 7574 2074 6865 206c 6966 roughout the lif │ │ │ -00071530: 6574 696d 6520 6f66 2074 6869 7320 6669 etime of this fi │ │ │ -00071540: 6c65 5f73 746f 7261 6765 206f 626a 6563 le_storage objec │ │ │ -00071550: 742e 0a09 0961 7578 3a3a 7665 6374 6f72 t....aux::vector │ │ │ -00071560: 266c 743b 6368 6172 2063 6f6e 7374 2a2c <char const*, │ │ │ -00071570: 2066 696c 655f 696e 6465 785f 7426 6774 file_index_t> │ │ │ -00071580: 3b20 6d5f 6669 6c65 5f68 6173 6865 733b ; m_file_hashes; │ │ │ -00071590: 0a23 656e 6469 660a 0a09 092f 2f20 666f .#endif....// fo │ │ │ -000715a0: 7220 6669 6c65 7320 7468 6174 2061 7265 r files that are │ │ │ -000715b0: 2073 796d 6c69 6e6b 732c 2074 6865 2073 symlinks, the s │ │ │ -000715c0: 796d 6c69 6e6b 0a09 092f 2f20 7061 7468 ymlink...// path │ │ │ -000715d0: 5f69 6e64 6578 2069 6e20 7468 6520 6175 _index in the au │ │ │ -000715e0: 783a 3a66 696c 655f 656e 7472 7920 696e x::file_entry in │ │ │ -000715f0: 6465 7865 730a 0909 2f2f 2074 6869 7320 dexes...// this │ │ │ -00071600: 7665 6374 6f72 206f 6620 7374 7269 6e67 vector of string │ │ │ -00071610: 730a 0909 7374 643a 3a76 6563 746f 7226 s...std::vector& │ │ │ -00071620: 6c74 3b73 7464 3a3a 7374 7269 6e67 2667 lt;std::string&g │ │ │ -00071630: 743b 206d 5f73 796d 6c69 6e6b 733b 0a0a t; m_symlinks;.. │ │ │ -00071640: 0909 2f2f 2074 6865 206d 6f64 6966 6963 ..// the modific │ │ │ -00071650: 6174 696f 6e20 7469 6d65 7320 6f66 2065 ation times of e │ │ │ -00071660: 6163 6820 6669 6c65 2e20 5468 6973 2076 ach file. This v │ │ │ -00071670: 6563 746f 720a 0909 2f2f 2069 7320 656d ector...// is em │ │ │ -00071680: 7074 7920 6966 206e 6f20 6669 6c65 2068 pty if no file h │ │ │ -00071690: 6176 6520 6120 6d6f 6469 6669 6361 7469 ave a modificati │ │ │ -000716a0: 6f6e 2074 696d 652e 0a09 092f 2f20 6561 on time....// ea │ │ │ -000716b0: 6368 2065 6c65 6d65 6e74 2063 6f72 7265 ch element corre │ │ │ -000716c0: 7370 6f6e 6473 2074 6f20 7468 6520 6669 sponds to the fi │ │ │ -000716d0: 6c65 2077 6974 6820 7468 6520 7361 6d65 le with the same │ │ │ -000716e0: 0a09 092f 2f20 696e 6465 7820 696e 206d ...// index in m │ │ │ -000716f0: 5f66 696c 6573 0a09 0961 7578 3a3a 7665 _files...aux::ve │ │ │ -00071700: 6374 6f72 266c 743b 7374 643a 3a74 696d ctor<std::tim │ │ │ -00071710: 655f 742c 2066 696c 655f 696e 6465 785f e_t, file_index_ │ │ │ -00071720: 7426 6774 3b20 6d5f 6d74 696d 653b 0a0a t> m_mtime;.. │ │ │ -00071730: 0909 2f2f 2061 6c6c 2075 6e69 7175 6520 ..// all unique │ │ │ -00071740: 7061 7468 7320 6669 6c65 7320 6861 7665 paths files have │ │ │ -00071750: 2e20 5468 6520 6175 783a 3a66 696c 655f . The aux::file_ │ │ │ -00071760: 656e 7472 793a 3a70 6174 685f 696e 6465 entry::path_inde │ │ │ -00071770: 780a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 x.
    < │ │ │ -000717a0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -000717b0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -000717e0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -000717f0: 6e74 2f73 6f63 6b65 745f 7479 7065 2e68 nt/socket_type.h │ │ │ -00071800: 7070 3a33 393c 2f61 3e3c 2f74 643e 3c74 pp:39move to aux

    move │ │ │ -00071870: 746f 2061 7578 3c2f 6832 3e3c 6834 3e2e to aux

    . │ │ │ -00071880: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -00071890: 7265 6e74 2f73 6f63 6b65 745f 7479 7065 rent/socket_type │ │ │ -000718a0: 2e68 7070 3a33 393c 2f68 343e 3c70 7265 .hpp:39

    .// A type
    │ │ │ -000718f0: 2064 6573 6372 6962 696e 6720 6b69 6e64   describing kind
    │ │ │ -00071900: 7320 6f66 2073 6f63 6b65 7473 2069 6e76  s of sockets inv
    │ │ │ -00071910: 6f6c 7665 6420 696e 2076 6172 696f 7573  olved in various
    │ │ │ -00071920: 206f 7065 7261 7469 6f6e 7320 6f72 2065   operations or e
    │ │ │ -00071930: 7665 6e74 732e 0a65 6e75 6d20 636c 6173  vents..enum clas
    │ │ │ -00071940: 7320 736f 636b 6574 5f74 7970 655f 7420  s socket_type_t 
    │ │ │ -00071950: 3a20 7374 643a 3a75 696e 7438 5f74 207b  : std::uint8_t {
    │ │ │ -00071960: 0a09 7463 702c 0a09 736f 636b 7335 2c0a  ..tcp,..socks5,.
    │ │ │ -00071970: 0968 7474 702c 0a09 7574 702c 0a09 6932  .http,..utp,..i2
    │ │ │ -00071980: 702c 0a09 7274 632c 0a09 7463 705f 7373  p,..rtc,..tcp_ss
    │ │ │ -00071990: 6c2c 0a09 736f 636b 7335 5f73 736c 2c0a  l,..socks5_ssl,.
    │ │ │ -000719a0: 0968 7474 705f 7373 6c2c 0a09 7574 705f  .http_ssl,..utp_
    │ │ │ -000719b0: 7373 6c2c 0a0a 2369 6620 544f 5252 454e  ssl,..#if TORREN
    │ │ │ -000719c0: 545f 4142 495f 5645 5253 494f 4e20 266c  T_ABI_VERSION &l
    │ │ │ -000719d0: 743b 3d20 320a 0975 6470 2054 4f52 5245  t;= 2..udp TORRE
    │ │ │ -000719e0: 4e54 5f44 4550 5245 4341 5445 445f 454e  NT_DEPRECATED_EN
    │ │ │ -000719f0: 554d 203d 2075 7470 2c0a 2365 6e64 6966  UM = utp,.#endif
    │ │ │ -00071a00: 0a7d 3b0a 0a2f 2f20 7265 7475 726e 2061  .};..// return a
    │ │ │ -00071a10: 2073 686f 7274 2068 756d 616e 2072 6561   short human rea
    │ │ │ -00071a20: 6461 626c 6520 6e61 6d65 2066 6f72 2074  dable name for t
    │ │ │ -00071a30: 7970 6573 206f 6620 736f 636b 6574 0a3c  ypes of socket.<
    │ │ │ -00071a40: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -00071a50: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -00071a60: 7769 6474 683d 2231 3030 2522 3e63 6861  width="100%">cha
    │ │ │ -00071a70: 7220 636f 6e73 742a 2073 6f63 6b65 745f  r const* socket_
    │ │ │ -00071a80: 7479 7065 5f6e 616d 6528 736f 636b 6574  type_name(socket
    │ │ │ -00071a90: 5f74 7970 655f 7429 3b0a 3c2f 6469 763e  _type_t);.
    │ │ │ -00071aa0: 0a7d 0a0a 2365 6e64 6966 0a3c 2f70 7265  .}..#endif.
    rele │ │ │ -00071ae0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../include │ │ │ -00071b20: 2f6c 6962 746f 7272 656e 742f 7065 7266 /libtorrent/perf │ │ │ -00071b30: 6f72 6d61 6e63 655f 636f 756e 7465 7273 ormance_counters │ │ │ -00071b40: 2e68 7070 3a35 3230 3c2f 613e 3c2f 7464 .hpp:520some space │ │ │ -00071b60: 636f 756c 6420 6265 2073 6176 6564 2068 could be saved h │ │ │ -00071b70: 6572 6520 6279 206d 616b 696e 6720 6761 ere by making ga │ │ │ -00071b80: 7567 6573 2033 3220 6269 7473 3c2f 7464 uges 32 bits

    some s │ │ │ -00071be0: 7061 6365 2063 6f75 6c64 2062 6520 7361 pace could be sa │ │ │ -00071bf0: 7665 6420 6865 7265 2062 7920 6d61 6b69 ved here by maki │ │ │ -00071c00: 6e67 2067 6175 6765 7320 3332 2062 6974 ng gauges 32 bit │ │ │ -00071c10: 733c 2f68 323e 3c68 343e 2e2e 2f69 6e63 s

    ../inc │ │ │ -00071c20: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -00071c30: 7065 7266 6f72 6d61 6e63 655f 636f 756e performance_coun │ │ │ -00071c40: 7465 7273 2e68 7070 3a35 3230 3c2f 6834 ters.hpp:520

    rele
    │ │ │ -00071cc0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464  vance 0../include
    │ │ │ -00071d00: 2f6c 6962 746f 7272 656e 742f 7065 7266  /libtorrent/perf
    │ │ │ -00071d10: 6f72 6d61 6e63 655f 636f 756e 7465 7273  ormance_counters
    │ │ │ -00071d20: 2e68 7070 3a35 3231 3c2f 613e 3c2f 7464  .hpp:521restore the
    │ │ │ -00071d40: 7365 2074 6f20 7265 6775 6c61 7220 696e  se to regular in
    │ │ │ -00071d50: 7465 6765 7273 2e20 496e 7374 6561 6420  tegers. Instead 
    │ │ │ -00071d60: 6861 7665 206f 6e65 2063 6f70 7920 6f66  have one copy of
    │ │ │ -00071d70: 2074 6865 2063 6f75 6e74 6572 7320 7065   the counters pe
    │ │ │ -00071d80: 7220 7468 7265 6164 2061 6e64 2063 6f6c  r thread and col
    │ │ │ -00071d90: 6c65 6374 2074 6865 6d20 6174 2063 6f6e  lect them at con
    │ │ │ -00071da0: 7665 6e69 656e 7420 7379 6e63 6872 6f6e  venient synchron
    │ │ │ -00071db0: 697a 6174 696f 6e20 706f 696e 7473 3c2f  ization points

    rest │ │ │ -00071e10: 6f72 6520 7468 6573 6520 746f 2072 6567 ore these to reg │ │ │ -00071e20: 756c 6172 2069 6e74 6567 6572 732e 2049 ular integers. I │ │ │ -00071e30: 6e73 7465 6164 2068 6176 6520 6f6e 6520 nstead have one │ │ │ -00071e40: 636f 7079 0a6f 6620 7468 6520 636f 756e copy.of the coun │ │ │ -00071e50: 7465 7273 2070 6572 2074 6872 6561 6420 ters per thread │ │ │ -00071e60: 616e 6420 636f 6c6c 6563 7420 7468 656d and collect them │ │ │ -00071e70: 2061 7420 636f 6e76 656e 6965 6e74 0a73 at convenient.s │ │ │ -00071e80: 796e 6368 726f 6e69 7a61 7469 6f6e 2070 ynchronization p │ │ │ -00071e90: 6f69 6e74 733c 2f68 323e 3c68 343e 2e2e oints

    .. │ │ │ -00071ea0: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -00071eb0: 656e 742f 7065 7266 6f72 6d61 6e63 655f ent/performance_ │ │ │ -00071ec0: 636f 756e 7465 7273 2e68 7070 3a35 3231 counters.hpp:521 │ │ │ -00071ed0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -00071f10: 0963 6f75 6e74 6572 7328 636f 756e 7465  .counters(counte
    │ │ │ -00071f20: 7273 2063 6f6e 7374 2661 6d70 3b29 2054  rs const&) T
    │ │ │ -00071f30: 4f52 5245 4e54 5f43 4f55 4e54 4552 5f4e  ORRENT_COUNTER_N
    │ │ │ -00071f40: 4f45 5843 4550 543b 0a09 0963 6f75 6e74  OEXCEPT;...count
    │ │ │ -00071f50: 6572 7326 616d 703b 206f 7065 7261 746f  ers& operato
    │ │ │ -00071f60: 723d 2863 6f75 6e74 6572 7320 636f 6e73  r=(counters cons
    │ │ │ -00071f70: 7426 616d 703b 2920 2661 6d70 3b20 544f  t&) & TO
    │ │ │ -00071f80: 5252 454e 545f 434f 554e 5445 525f 4e4f  RRENT_COUNTER_NO
    │ │ │ -00071f90: 4558 4345 5054 3b0a 0a09 092f 2f20 696e  EXCEPT;....// in
    │ │ │ -00071fa0: 6372 656d 656e 7473 2074 6865 2063 6f75  crements the cou
    │ │ │ -00071fb0: 6e74 6572 206f 7220 6761 7567 6520 6060  nter or gauge ``
    │ │ │ -00071fc0: 6360 6020 2861 6e20 696e 6465 7820 696e  c`` (an index in
    │ │ │ -00071fd0: 746f 2074 6865 2063 6f75 6e74 6572 0a09  to the counter..
    │ │ │ -00071fe0: 092f 2f20 6172 7261 7929 2062 7920 6060  .// array) by ``
    │ │ │ -00071ff0: 7661 6c75 6560 6020 616e 6420 7265 7475  value`` and retu
    │ │ │ -00072000: 726e 7320 7468 6520 6e65 7720 7661 6c75  rns the new valu
    │ │ │ -00072010: 652e 0a09 0973 7464 3a3a 696e 7436 345f  e....std::int64_
    │ │ │ -00072020: 7420 696e 635f 7374 6174 735f 636f 756e  t inc_stats_coun
    │ │ │ -00072030: 7465 7228 696e 7420 632c 2073 7464 3a3a  ter(int c, std::
    │ │ │ -00072040: 696e 7436 345f 7420 7661 6c75 6520 3d20  int64_t value = 
    │ │ │ -00072050: 3129 2054 4f52 5245 4e54 5f43 4f55 4e54  1) TORRENT_COUNT
    │ │ │ -00072060: 4552 5f4e 4f45 5843 4550 543b 0a0a 0909  ER_NOEXCEPT;....
    │ │ │ -00072070: 2f2f 2072 6574 7572 6e73 2074 6865 2063  // returns the c
    │ │ │ -00072080: 7572 7265 6e74 2076 616c 7565 206f 6620  urrent value of 
    │ │ │ -00072090: 636f 756e 7465 7220 6f72 2067 6175 6765  counter or gauge
    │ │ │ -000720a0: 2060 6069 6060 2028 616e 2069 6e64 6578   ``i`` (an index
    │ │ │ -000720b0: 2069 6e74 6f0a 0909 2f2f 2074 6865 2063   into...// the c
    │ │ │ -000720c0: 6f75 6e74 6572 2061 7272 6179 292e 0a09  ounter array)...
    │ │ │ -000720d0: 0973 7464 3a3a 696e 7436 345f 7420 6f70  .std::int64_t op
    │ │ │ -000720e0: 6572 6174 6f72 5b5d 2869 6e74 2069 2920  erator[](int i) 
    │ │ │ -000720f0: 636f 6e73 7420 544f 5252 454e 545f 434f  const TORRENT_CO
    │ │ │ -00072100: 554e 5445 525f 4e4f 4558 4345 5054 3b0a  UNTER_NOEXCEPT;.
    │ │ │ -00072110: 0a09 092f 2f20 6f76 6572 7772 6974 6573  ...// overwrites
    │ │ │ -00072120: 2074 6865 2076 616c 7565 206f 6620 636f   the value of co
    │ │ │ -00072130: 756e 7465 7220 6f72 2067 6175 6765 2060  unter or gauge `
    │ │ │ -00072140: 6063 6060 2028 616e 2069 6e64 6578 2069  `c`` (an index i
    │ │ │ -00072150: 6e74 6f0a 0909 2f2f 2074 6865 2063 6f75  nto...// the cou
    │ │ │ -00072160: 6e74 6572 2061 7272 6179 292e 2060 6062  nter array). ``b
    │ │ │ -00072170: 6c65 6e64 5f73 7461 7473 5f63 6f75 6e74  lend_stats_count
    │ │ │ -00072180: 6572 2829 6060 2061 646a 7573 7473 2074  er()`` adjusts t
    │ │ │ -00072190: 6865 2073 7461 7420 7661 6c75 650a 0909  he stat value...
    │ │ │ -000721a0: 2f2f 2074 6f77 6172 6420 7468 6520 7370  // toward the sp
    │ │ │ -000721b0: 6563 6966 6965 6420 6060 7661 6c75 6560  ecified ``value`
    │ │ │ -000721c0: 602c 2060 6072 6174 696f 6060 2073 7065  `, ``ratio`` spe
    │ │ │ -000721d0: 6369 6669 6573 2074 6865 2070 6572 6365  cifies the perce
    │ │ │ -000721e0: 6e74 206f 660a 0909 2f2f 2074 6865 206e  nt of...// the n
    │ │ │ -000721f0: 6577 2076 616c 7565 2073 686f 756c 6420  ew value should 
    │ │ │ -00072200: 6265 2069 6e66 6c75 656e 6365 6420 6279  be influenced by
    │ │ │ -00072210: 2060 6076 616c 7565 6060 2e0a 0909 766f   ``value``....vo
    │ │ │ -00072220: 6964 2073 6574 5f76 616c 7565 2869 6e74  id set_value(int
    │ │ │ -00072230: 2063 2c20 7374 643a 3a69 6e74 3634 5f74   c, std::int64_t
    │ │ │ -00072240: 2076 616c 7565 2920 544f 5252 454e 545f   value) TORRENT_
    │ │ │ -00072250: 434f 554e 5445 525f 4e4f 4558 4345 5054  COUNTER_NOEXCEPT
    │ │ │ -00072260: 3b0a 0909 766f 6964 2062 6c65 6e64 5f73  ;...void blend_s
    │ │ │ -00072270: 7461 7473 5f63 6f75 6e74 6572 2869 6e74  tats_counter(int
    │ │ │ -00072280: 2063 2c20 7374 643a 3a69 6e74 3634 5f74   c, std::int64_t
    │ │ │ -00072290: 2076 616c 7565 2c20 696e 7420 7261 7469   value, int rati
    │ │ │ -000722a0: 6f29 2054 4f52 5245 4e54 5f43 4f55 4e54  o) TORRENT_COUNT
    │ │ │ -000722b0: 4552 5f4e 4f45 5843 4550 543b 0a0a 0970  ER_NOEXCEPT;...p
    │ │ │ -000722c0: 7269 7661 7465 3a0a 0a3c 6469 7620 7374  rivate:..
    #ifdef AT │ │ │ -00072300: 4f4d 4943 5f4c 4c4f 4e47 5f4c 4f43 4b5f OMIC_LLONG_LOCK_ │ │ │ -00072310: 4652 4545 0a3c 2f64 6976 3e09 0961 7578 FREE.
    ..aux │ │ │ -00072320: 3a3a 6172 7261 7926 6c74 3b73 7464 3a3a ::array<std:: │ │ │ -00072330: 6174 6f6d 6963 266c 743b 7374 643a 3a69 atomic<std::i │ │ │ -00072340: 6e74 3634 5f74 2667 743b 2c20 6e75 6d5f nt64_t>, num_ │ │ │ -00072350: 636f 756e 7465 7273 2667 743b 206d 5f73 counters> m_s │ │ │ -00072360: 7461 7473 5f63 6f75 6e74 6572 3b0a 2365 tats_counter;.#e │ │ │ -00072370: 6c73 650a 0909 2f2f 2069 6620 7468 6520 lse...// if the │ │ │ -00072380: 6174 6f6d 6963 2074 7970 6520 6973 6e27 atomic type isn' │ │ │ -00072390: 7420 6c6f 636b 2d66 7265 652c 2075 7365 t lock-free, use │ │ │ -000723a0: 2061 2073 696e 676c 6520 6c6f 636b 2069 a single lock i │ │ │ -000723b0: 6e73 7465 6164 2c20 666f 720a 0909 2f2f nstead, for...// │ │ │ -000723c0: 2074 6865 2077 686f 6c65 2061 7272 6179 the whole array │ │ │ -000723d0: 0a09 096d 7574 6162 6c65 2073 7464 3a3a ...mutable std:: │ │ │ -000723e0: 6d75 7465 7820 6d5f 6d75 7465 783b 0a09 mutex m_mutex;.. │ │ │ -000723f0: 0961 7578 3a3a 6172 7261 7926 6c74 3b73 .aux::array<s │ │ │ -00072400: 7464 3a3a 696e 7436 345f 742c 206e 756d td::int64_t, num │ │ │ -00072410: 5f63 6f75 6e74 6572 7326 6774 3b20 6d5f _counters> m_ │ │ │ -00072420: 7374 6174 735f 636f 756e 7465 723b 0a23 stats_counter;.# │ │ │ -00072430: 656e 6469 660a 097d 3b0a 7d0a 0a23 656e endif..};.}..#en │ │ │ -00072440: 6469 660a 3c2f 7072 653e 3c2f 7464 3e3c dif.
    < │ │ │ -00072450: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00072480: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -000724b0: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -000724c0: 7265 6e74 2f75 706e 702e 6870 703a 3134 rent/upnp.hpp:14 │ │ │ -000724d0: 323c 2f61 3e3c 2f74 643e 3c74 643e 7375 2su │ │ │ -000724e0: 7070 6f72 7420 7573 696e 6720 7468 6520 pport using the │ │ │ -000724f0: 7769 6e64 6f77 7320 4150 4920 666f 7220 windows API for │ │ │ -00072500: 5550 6e50 206f 7065 7261 7469 6f6e 7320 UPnP operations │ │ │ -00072510: 6173 2077 656c 6c3c 2f74 643e 3c2f 7472 as well

    support usi │ │ │ -00072570: 6e67 2074 6865 2077 696e 646f 7773 2041 ng the windows A │ │ │ -00072580: 5049 2066 6f72 2055 506e 5020 6f70 6572 PI for UPnP oper │ │ │ -00072590: 6174 696f 6e73 2061 7320 7765 6c6c 3c2f ations as well

    ../includ │ │ │ -000725b0: 652f 6c69 6274 6f72 7265 6e74 2f75 706e e/libtorrent/upn │ │ │ -000725c0: 702e 6870 703a 3134 323c 2f68 343e 3c70 p.hpp:142

    {..bool │ │ │ -00072610: 696e 5f65 7272 6f72 5f63 6f64 6520 3d20 in_error_code = │ │ │ -00072620: 6661 6c73 653b 0a09 626f 6f6c 2065 7869 false;..bool exi │ │ │ -00072630: 7420 3d20 6661 6c73 653b 0a09 696e 7420 t = false;..int │ │ │ -00072640: 6572 726f 725f 636f 6465 203d 202d 313b error_code = -1; │ │ │ -00072650: 0a7d 3b0a 0a73 7472 7563 7420 6970 5f61 .};..struct ip_a │ │ │ -00072660: 6464 7265 7373 5f70 6172 7365 5f73 7461 ddress_parse_sta │ │ │ -00072670: 7465 3a20 6572 726f 725f 636f 6465 5f70 te: error_code_p │ │ │ -00072680: 6172 7365 5f73 7461 7465 0a7b 0a09 626f arse_state.{..bo │ │ │ -00072690: 6f6c 2069 6e5f 6970 5f61 6464 7265 7373 ol in_ip_address │ │ │ -000726a0: 203d 2066 616c 7365 3b0a 0973 7464 3a3a = false;..std:: │ │ │ -000726b0: 7374 7269 6e67 2069 705f 6164 6472 6573 string ip_addres │ │ │ -000726c0: 733b 0a7d 3b0a 0a54 4f52 5245 4e54 5f45 s;.};..TORRENT_E │ │ │ -000726d0: 5854 5241 5f45 5850 4f52 5420 766f 6964 XTRA_EXPORT void │ │ │ -000726e0: 2066 696e 645f 636f 6e74 726f 6c5f 7572 find_control_ur │ │ │ -000726f0: 6c28 696e 7420 7479 7065 2c20 7374 7269 l(int type, stri │ │ │ -00072700: 6e67 5f76 6965 772c 2070 6172 7365 5f73 ng_view, parse_s │ │ │ -00072710: 7461 7465 2661 6d70 3b20 7374 6174 6529 tate& state) │ │ │ -00072720: 3b0a 0a54 4f52 5245 4e54 5f45 5854 5241 ;..TORRENT_EXTRA │ │ │ -00072730: 5f45 5850 4f52 5420 766f 6964 2066 696e _EXPORT void fin │ │ │ -00072740: 645f 6572 726f 725f 636f 6465 2869 6e74 d_error_code(int │ │ │ -00072750: 2074 7970 652c 2073 7472 696e 675f 7669 type, string_vi │ │ │ -00072760: 6577 2073 7472 696e 670a 092c 2065 7272 ew string.., err │ │ │ -00072770: 6f72 5f63 6f64 655f 7061 7273 655f 7374 or_code_parse_st │ │ │ -00072780: 6174 6526 616d 703b 2073 7461 7465 293b ate& state); │ │ │ -00072790: 0a0a 544f 5252 454e 545f 4558 5452 415f ..TORRENT_EXTRA_ │ │ │ -000727a0: 4558 504f 5254 2076 6f69 6420 6669 6e64 EXPORT void find │ │ │ -000727b0: 5f69 705f 6164 6472 6573 7328 696e 7420 _ip_address(int │ │ │ -000727c0: 7479 7065 2c20 7374 7269 6e67 5f76 6965 type, string_vie │ │ │ -000727d0: 7720 7374 7269 6e67 0a09 2c20 6970 5f61 w string.., ip_a │ │ │ -000727e0: 6464 7265 7373 5f70 6172 7365 5f73 7461 ddress_parse_sta │ │ │ -000727f0: 7465 2661 6d70 3b20 7374 6174 6529 3b0a te& state);. │ │ │ -00072800: 0a3c 6469 7620 7374 796c 653d 2262 6163 .

    s │ │ │ -00072830: 7472 7563 7420 544f 5252 454e 545f 4558 truct TORRENT_EX │ │ │ -00072840: 5452 415f 4558 504f 5254 2075 706e 7020 TRA_EXPORT upnp │ │ │ -00072850: 6669 6e61 6c0a 3c2f 6469 763e 093a 2073 final.
    .: s │ │ │ -00072860: 7464 3a3a 656e 6162 6c65 5f73 6861 7265 td::enable_share │ │ │ -00072870: 645f 6672 6f6d 5f74 6869 7326 6c74 3b75 d_from_this<u │ │ │ -00072880: 706e 7026 6774 3b0a 092c 2061 7578 3a3a pnp>.., aux:: │ │ │ -00072890: 7369 6e67 6c65 5f74 6872 6561 6465 640a single_threaded. │ │ │ -000728a0: 7b0a 0975 706e 7028 696f 5f63 6f6e 7465 {..upnp(io_conte │ │ │ -000728b0: 7874 2661 6d70 3b20 696f 730a 0909 2c20 xt& ios..., │ │ │ -000728c0: 6175 783a 3a73 6573 7369 6f6e 5f73 6574 aux::session_set │ │ │ -000728d0: 7469 6e67 7320 636f 6e73 7426 616d 703b tings const& │ │ │ -000728e0: 2073 6574 7469 6e67 730a 0909 2c20 6175 settings..., au │ │ │ -000728f0: 783a 3a70 6f72 746d 6170 5f63 616c 6c62 x::portmap_callb │ │ │ -00072900: 6163 6b26 616d 703b 2063 620a 0909 2c20 ack& cb..., │ │ │ -00072910: 6164 6472 6573 735f 7634 206c 6973 7465 address_v4 liste │ │ │ -00072920: 6e5f 6164 6472 6573 730a 0909 2c20 6164 n_address..., ad │ │ │ -00072930: 6472 6573 735f 7634 206e 6574 6d61 736b dress_v4 netmask │ │ │ -00072940: 0a09 092c 2073 7464 3a3a 7374 7269 6e67 ..., std::string │ │ │ -00072950: 206c 6973 7465 6e5f 6465 7669 6365 0a09 listen_device.. │ │ │ -00072960: 092c 2061 7578 3a3a 6c69 7374 656e 5f73 ., aux::listen_s │ │ │ -00072970: 6f63 6b65 745f 6861 6e64 6c65 206c 7329 ocket_handle ls) │ │ │ -00072980: 3b0a 097e 7570 6e70 2829 3b0a 0a09 766f ;..~upnp();...vo │ │ │ -00072990: 6964 2073 7461 7274 2829 3b0a 0a09 2f2f id start();...// │ │ │ -000729a0: 2041 7474 656d 7074 7320 746f 2061 6464 Attempts to add │ │ │ -000729b0: 2061 2070 6f72 7420 6d61 7070 696e 6720 a port mapping │ │ │ -000729c0: 666f 7220 7468 6520 7370 6563 6966 6965 for the specifie │ │ │ -000729d0: 6420 7072 6f74 6f63 6f6c 2e20 5661 6c69 d protocol. Vali │ │ │ -000729e0: 6420 7072 6f74 6f63 6f6c 7320 6172 650a d protocols are. │ │ │ -000729f0: 092f 2f20 6060 7570 6e70 3a3a 7463 7060 .// ``upnp::tcp` │ │ │ -00072a00: 6020 616e 6420 6060 7570 6e70 3a3a 7564 ` and ``upnp::ud │ │ │ -00072a10: 7060 6020 666f 7220 7468 6520 5550 6e50 p`` for the UPnP │ │ │ -00072a20: 2063 6c61 7373 2061 6e64 2060 606e 6174 class and ``nat │ │ │ -00072a30: 706d 703a 3a74 6370 6060 2061 6e64 0a09 pmp::tcp`` and.. │ │ │ -00072a40: 2f2f 2060 606e 6174 706d 703a 3a75 6470 // ``natpmp::udp │ │ │ -00072a50: 6060 2066 6f72 2074 6865 204e 4154 2d50 `` for the NAT-P │ │ │ -00072a60: 4d50 2063 6c61 7373 2e0a 092f 2f0a 092f MP class...//../ │ │ │ -00072a70: 2f20 6060 6578 7465 726e 616c 5f70 6f72 / ``external_por │ │ │ -00072a80: 7460 6020 6973 2074 6865 2070 6f72 7420 t`` is the port │ │ │ -00072a90: 6f6e 2074 6865 2065 7874 6572 6e61 6c20 on the external │ │ │ -00072aa0: 6164 6472 6573 7320 7468 6174 2077 696c address that wil │ │ │ -00072ab0: 6c20 6265 206d 6170 7065 642e 2054 6869 l be mapped. Thi │ │ │ -00072ac0: 730a 092f 2f20 6973 2061 2068 696e 742c s..// is a hint, │ │ │ -00072ad0: 2079 6f75 2061 7265 206e 6f74 2067 7561 you are not gua │ │ │ -00072ae0: 7261 6e74 6565 6420 7468 6174 2074 6869 ranteed that thi │ │ │ -00072af0: 7320 706f 7274 2077 696c 6c20 6265 2061 s port will be a │ │ │ -00072b00: 7661 696c 6162 6c65 2c20 616e 6420 6974 vailable, and it │ │ │ -00072b10: 206d 6179 0a09 2f2f 2065 6e64 2075 7020 may..// end up │ │ │ -00072b20: 6265 696e 6720 736f 6d65 7468 696e 6720 being something │ │ │ -00072b30: 656c 7365 2e20 496e 2074 6865 2070 6f72 else. In the por │ │ │ -00072b40: 746d 6170 5f61 6c65 7274 5f20 6e6f 7469 tmap_alert_ noti │ │ │ -00072b50: 6669 6361 7469 6f6e 2c20 7468 6520 6163 fication, the ac │ │ │ -00072b60: 7475 616c 0a09 2f2f 2065 7874 6572 6e61 tual..// externa │ │ │ -00072b70: 6c20 706f 7274 2069 7320 7265 706f 7274 l port is report │ │ │ -00072b80: 6564 2e0a 092f 2f0a 092f 2f20 6060 6c6f ed...//..// ``lo │ │ │ -00072b90: 6361 6c5f 706f 7274 6060 2069 7320 7468 cal_port`` is th │ │ │ -00072ba0: 6520 706f 7274 2069 6e20 7468 6520 6c6f e port in the lo │ │ │ -00072bb0: 6361 6c20 6d61 6368 696e 6520 7468 6174 cal machine that │ │ │ -00072bc0: 2074 6865 206d 6170 7069 6e67 2073 686f the mapping sho │ │ │ -00072bd0: 756c 6420 666f 7277 6172 640a 092f 2f20 uld forward..// │ │ │ -00072be0: 746f 2e0a 092f 2f0a 092f 2f20 5468 6520 to...//..// The │ │ │ -00072bf0: 7265 7475 726e 2076 616c 7565 2069 7320 return value is │ │ │ -00072c00: 616e 2069 6e64 6578 2074 6861 7420 6964 an index that id │ │ │ -00072c10: 656e 7469 6669 6573 2074 6869 7320 706f entifies this po │ │ │ -00072c20: 7274 206d 6170 7069 6e67 2e20 5468 6973 rt mapping. This │ │ │ -00072c30: 2069 7320 7573 6564 0a09 2f2f 2074 6f20 is used..// to │ │ │ -00072c40: 7265 6665 7220 746f 206d 6170 7069 6e67 refer to mapping │ │ │ -00072c50: 7320 7468 6174 2066 6169 6c73 206f 7220 s that fails or │ │ │ -00072c60: 7375 6363 6565 6473 2069 6e20 7468 6520 succeeds in the │ │ │ -00072c70: 706f 7274 6d61 705f 6572 726f 725f 616c portmap_error_al │ │ │ -00072c80: 6572 745f 2061 6e64 0a09 2f2f 2070 6f72 ert_ and..// por │ │ │ -00072c90: 746d 6170 5f61 6c65 7274 5f20 7265 7370 tmap_alert_ resp │ │ │ -00072ca0: 6563 7469 7665 6c79 2e20 4966 2054 6865 ectively. If The │ │ │ -00072cb0: 206d 6170 7069 6e67 2066 6169 6c73 2069 mapping fails i │ │ │ -00072cc0: 6d6d 6564 6961 7465 6c79 2c20 7468 6520 mmediately, the │ │ │ -00072cd0: 7265 7475 726e 2076 616c 7565 0a09 2f2f return value..// │ │ │ -00072ce0: 2069 7320 2d31 2c20 7768 6963 6820 6d65 is -1, which me │ │ │ -00072cf0: 616e 7320 6661 696c 7572 652e 2054 6865 ans failure. The │ │ │ -00072d00: 7265 2077 696c 6c20 6e6f 7420 6265 2061 re will not be a │ │ │ -00072d10: 6e79 2065 7272 6f72 2061 6c65 7274 206e ny error alert n │ │ │ -00072d20: 6f74 6966 6963 6174 696f 6e20 666f 720a otification for. │ │ │ -00072d30: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ -00072d40: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -00072d70: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../in │ │ │ -00072da0: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -00072db0: 2f69 6465 6e74 6966 795f 636c 6965 6e74 /identify_client │ │ │ -00072dc0: 2e68 7070 3a32 333c 2f61 3e3c 2f74 643e .hpp:23 │ │ │ -00072dd0: 3c74 643e 6869 6465 2074 6869 7320 6465 hide this de │ │ │ -00072de0: 636c 6172 6174 696f 6e20 7768 656e 2064 claration when d │ │ │ -00072df0: 6570 7265 6361 7465 6420 6675 6e63 7469 eprecated functi │ │ │ -00072e00: 6f6e 7320 6172 6520 6469 7361 626c 6564 ons are disabled │ │ │ -00072e10: 2c20 616e 6420 7265 6d6f 7665 2069 7473 , and remove its │ │ │ -00072e20: 2069 6e74 6572 6e61 6c20 7573 653c 2f74 internal use

    hide │ │ │ -00072e80: 7468 6973 2064 6563 6c61 7261 7469 6f6e this declaration │ │ │ -00072e90: 2077 6865 6e20 6465 7072 6563 6174 6564 when deprecated │ │ │ -00072ea0: 2066 756e 6374 696f 6e73 2061 7265 2064 functions are d │ │ │ -00072eb0: 6973 6162 6c65 642c 2061 6e64 0a72 656d isabled, and.rem │ │ │ -00072ec0: 6f76 6520 6974 7320 696e 7465 726e 616c ove its internal │ │ │ -00072ed0: 2075 7365 3c2f 6832 3e3c 6834 3e2e 2e2f use

    ../ │ │ │ -00072ee0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -00072ef0: 6e74 2f69 6465 6e74 6966 795f 636c 6965 nt/identify_clie │ │ │ -00072f00: 6e74 2e68 7070 3a32 333c 2f68 343e 3c70 nt.hpp:23

    Copyrigh │ │ │ -00072f50: 7420 2863 2920 3230 3033 2c20 3230 3036 t (c) 2003, 2006 │ │ │ -00072f60: 2c20 3230 3133 2d32 3032 312c 2041 7276 , 2013-2021, Arv │ │ │ -00072f70: 6964 204e 6f72 6265 7267 0a43 6f70 7972 id Norberg.Copyr │ │ │ -00072f80: 6967 6874 2028 6329 2032 3032 302c 2041 ight (c) 2020, A │ │ │ -00072f90: 6c64 656e 2054 6f72 7265 730a 416c 6c20 lden Torres.All │ │ │ -00072fa0: 7269 6768 7473 2072 6573 6572 7665 642e rights reserved. │ │ │ -00072fb0: 0a0a 596f 7520 6d61 7920 7573 652c 2064 ..You may use, d │ │ │ -00072fc0: 6973 7472 6962 7574 6520 616e 6420 6d6f istribute and mo │ │ │ -00072fd0: 6469 6679 2074 6869 7320 636f 6465 2075 dify this code u │ │ │ -00072fe0: 6e64 6572 2074 6865 2074 6572 6d73 206f nder the terms o │ │ │ -00072ff0: 6620 7468 6520 4253 4420 6c69 6365 6e73 f the BSD licens │ │ │ -00073000: 652c 0a73 6565 204c 4943 454e 5345 2066 e,.see LICENSE f │ │ │ -00073010: 696c 652e 0a2a 2f0a 0a23 6966 6e64 6566 ile..*/..#ifndef │ │ │ -00073020: 2054 4f52 5245 4e54 5f49 4445 4e54 4946 TORRENT_IDENTIF │ │ │ -00073030: 595f 434c 4945 4e54 5f48 5050 5f49 4e43 Y_CLIENT_HPP_INC │ │ │ -00073040: 4c55 4445 440a 2364 6566 696e 6520 544f LUDED.#define TO │ │ │ -00073050: 5252 454e 545f 4944 454e 5449 4659 5f43 RRENT_IDENTIFY_C │ │ │ -00073060: 4c49 454e 545f 4850 505f 494e 434c 5544 LIENT_HPP_INCLUD │ │ │ -00073070: 4544 0a0a 2369 6e63 6c75 6465 2022 6c69 ED..#include "li │ │ │ -00073080: 6274 6f72 7265 6e74 2f63 6f6e 6669 672e btorrent/config. │ │ │ -00073090: 6870 7022 0a0a 2369 6620 544f 5252 454e hpp"..#if TORREN │ │ │ -000730a0: 545f 4142 495f 5645 5253 494f 4e20 3d3d T_ABI_VERSION == │ │ │ -000730b0: 2031 0a23 696e 636c 7564 6520 266c 743b 1.#include < │ │ │ -000730c0: 6f70 7469 6f6e 616c 2667 743b 0a23 656e optional>.#en │ │ │ -000730d0: 6469 660a 0a23 696e 636c 7564 6520 226c dif..#include "l │ │ │ -000730e0: 6962 746f 7272 656e 742f 7065 6572 5f69 ibtorrent/peer_i │ │ │ -000730f0: 642e 6870 7022 0a23 696e 636c 7564 6520 d.hpp".#include │ │ │ -00073100: 226c 6962 746f 7272 656e 742f 6669 6e67 "libtorrent/fing │ │ │ -00073110: 6572 7072 696e 742e 6870 7022 0a0a 3c64 erprint.hpp"..name │ │ │ -00073150: 7370 6163 6520 6c69 6274 6f72 7265 6e74 space libtorrent │ │ │ -00073160: 207b 0a3c 2f64 6976 3e0a 6e61 6d65 7370 {..namesp │ │ │ -00073170: 6163 6520 6175 7820 7b0a 0a09 544f 5252 ace aux {...TORR │ │ │ -00073180: 454e 545f 4558 5452 415f 4558 504f 5254 ENT_EXTRA_EXPORT │ │ │ -00073190: 0a09 7374 643a 3a73 7472 696e 6720 6964 ..std::string id │ │ │ -000731a0: 656e 7469 6679 5f63 6c69 656e 745f 696d entify_client_im │ │ │ -000731b0: 706c 2863 6f6e 7374 2070 6565 725f 6964 pl(const peer_id │ │ │ -000731c0: 2661 6d70 3b20 7029 3b0a 0a7d 0a0a 092f & p);..}.../ │ │ │ -000731d0: 2f20 7468 6573 6520 6675 6e63 7469 6f6e / these function │ │ │ -000731e0: 7320 646f 6e27 7420 7265 616c 6c79 206e s don't really n │ │ │ -000731f0: 6565 6420 746f 2062 6520 7075 626c 6963 eed to be public │ │ │ -00073200: 2e20 5468 6973 206d 6563 6861 6e69 736d . This mechanism │ │ │ -00073210: 206f 660a 092f 2f20 6164 7665 7274 6973 of..// advertis │ │ │ -00073220: 696e 6720 636c 6965 6e74 2073 6f66 7477 ing client softw │ │ │ -00073230: 6172 6520 616e 6420 7665 7273 696f 6e20 are and version │ │ │ -00073240: 6973 2061 6c73 6f20 6f75 742d 6461 7465 is also out-date │ │ │ -00073250: 642e 0a0a 092f 2f20 5468 6973 2066 756e d....// This fun │ │ │ -00073260: 6374 696f 6e20 6361 6e20 6361 6e20 6265 ction can can be │ │ │ -00073270: 2075 7365 6420 746f 2065 7874 7261 6374 used to extract │ │ │ -00073280: 2061 2073 7472 696e 6720 6465 7363 7269 a string descri │ │ │ -00073290: 6269 6e67 2061 2063 6c69 656e 740a 092f bing a client../ │ │ │ -000732a0: 2f20 7665 7273 696f 6e20 6672 6f6d 2069 / version from i │ │ │ -000732b0: 7473 2070 6565 722d 6964 2e20 4974 2077 ts peer-id. It w │ │ │ -000732c0: 696c 6c20 7265 636f 676e 697a 6520 6d6f ill recognize mo │ │ │ -000732d0: 7374 2063 6c69 656e 7473 2074 6861 7420 st clients that │ │ │ -000732e0: 6861 7665 2074 6869 730a 092f 2f20 6b69 have this..// ki │ │ │ -000732f0: 6e64 206f 6620 6964 656e 7469 6669 6361 nd of identifica │ │ │ -00073300: 7469 6f6e 2069 6e20 7468 6520 7065 6572 tion in the peer │ │ │ -00073310: 2d69 642e 0a09 544f 5252 454e 545f 4445 -id...TORRENT_DE │ │ │ -00073320: 5052 4543 4154 4544 5f45 5850 4f52 540a PRECATED_EXPORT. │ │ │ -00073330: 0973 7464 3a3a 7374 7269 6e67 2069 6465 .std::string ide │ │ │ -00073340: 6e74 6966 795f 636c 6965 6e74 2863 6f6e ntify_client(con │ │ │ -00073350: 7374 2070 6565 725f 6964 2661 6d70 3b20 st peer_id& │ │ │ -00073360: 7029 3b0a 0a23 6966 2054 4f52 5245 4e54 p);..#if TORRENT │ │ │ -00073370: 5f41 4249 5f56 4552 5349 4f4e 203d 3d20 _ABI_VERSION == │ │ │ -00073380: 310a 0a23 696e 636c 7564 6520 226c 6962 1..#include "lib │ │ │ -00073390: 746f 7272 656e 742f 6175 785f 2f64 6973 torrent/aux_/dis │ │ │ -000733a0: 6162 6c65 5f64 6570 7265 6361 7469 6f6e able_deprecation │ │ │ -000733b0: 5f77 6172 6e69 6e67 735f 7075 7368 2e68 _warnings_push.h │ │ │ -000733c0: 7070 220a 0a09 2f2f 2052 6574 7572 6e73 pp"...// Returns │ │ │ -000733d0: 2061 6e20 6f70 7469 6f6e 616c 2066 696e an optional fin │ │ │ -000733e0: 6765 7270 7269 6e74 2069 6620 616e 7920 gerprint if any │ │ │ -000733f0: 6361 6e20 6265 2069 6465 6e74 6966 6965 can be identifie │ │ │ -00073400: 6420 6672 6f6d 2074 6865 2070 6565 720a d from the peer. │ │ │ -00073410: 092f 2f20 6964 2e20 5468 6973 2063 616e .// id. This can │ │ │ -00073420: 2062 6520 7573 6564 2074 6f20 6175 746f be used to auto │ │ │ -00073430: 6d61 7465 2074 6865 2069 6465 6e74 6966 mate the identif │ │ │ -00073440: 6963 6174 696f 6e20 6f66 2063 6c69 656e ication of clien │ │ │ -00073450: 7473 2e20 4974 2077 696c 6c0a 092f 2f20 ts. It will..// │ │ │ -00073460: 6e6f 7420 6265 2061 626c 6520 746f 2069 not be able to i │ │ │ -00073470: 6465 6e74 6966 7920 7065 6572 7320 7769 dentify peers wi │ │ │ -00073480: 7468 206e 6f6e 2d20 7374 616e 6461 7264 th non- standard │ │ │ -00073490: 2065 6e63 6f64 696e 6773 2e20 4f6e 6c79 encodings. Only │ │ │ -000734a0: 2041 7a75 7265 7573 0a09 2f2f 2073 7479 Azureus..// sty │ │ │ -000734b0: 6c65 2c20 5368 6164 6f77 2773 2073 7479 le, Shadow's sty │ │ │ -000734c0: 6c65 2061 6e64 204d 6169 6e6c 696e 6520 le and Mainline │ │ │ -000734d0: 7374 796c 652e 0a09 544f 5252 454e 545f style...TORRENT_ │ │ │ -000734e0: 4445 5052 4543 4154 4544 5f45 5850 4f52 DEPRECATED_EXPOR │ │ │ -000734f0: 540a 0973 7464 3a3a 6f70 7469 6f6e 616c T..std::optional │ │ │ -00073500: 266c 743b 6669 6e67 6572 7072 696e 7426 <fingerprint& │ │ │ -00073510: 6774 3b0a 0909 636c 6965 6e74 5f66 696e gt;...client_fin │ │ │ -00073520: 6765 7270 7269 6e74 2870 6565 725f 6964 gerprint(peer_id │ │ │ -00073530: 2063 6f6e 7374 2661 6d70 3b20 7029 3b0a const& p);. │ │ │ -00073540: 0a23 696e 636c 7564 6520 226c 6962 746f .#include "libto │ │ │ -00073550: 7272 656e 742f 6175 785f 2f64 6973 6162 rrent/aux_/disab │ │ │ -00073560: 6c65 5f77 6172 6e69 6e67 735f 706f 702e le_warnings_pop. │ │ │ -00073570: 6870 7022 0a3c 2f70 7265 3e3c 2f74 643e hpp".

    │ │ │ -00073580: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -000735b0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -000735c0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -000735d0: 7074 3a65 7870 616e 6428 3236 3329 223e pt:expand(263)"> │ │ │ -000735e0: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -000735f0: 7272 656e 742f 6932 705f 7374 7265 616d rrent/i2p_stream │ │ │ -00073600: 2e68 7070 3a35 3631 3c2f 613e 3c2f 7464 .hpp:561make this a │ │ │ -00073620: 2073 7472 696e 675f 7669 6577 3c2f 7464 string_view

    make t │ │ │ -00073680: 6869 7320 6120 7374 7269 6e67 5f76 6965 his a string_vie │ │ │ -00073690: 773c 2f68 323e 3c68 343e 2e2e 2f69 6e63 w

    ../inc │ │ │ -000736a0: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -000736b0: 6932 705f 7374 7265 616d 2e68 7070 3a35 i2p_stream.hpp:5 │ │ │ -000736c0: 3631 3c2f 6834 3e3c 7072 6520 7374 796c 61

    ...char tmp[20]
    │ │ │ -00073710: 3b0a 0909 6175 783a 3a72 616e 646f 6d5f  ;...aux::random_
    │ │ │ -00073720: 6279 7465 7328 746d 7029 3b0a 0909 6d5f  bytes(tmp);...m_
    │ │ │ -00073730: 7365 7373 696f 6e5f 6964 2e72 6573 697a  session_id.resiz
    │ │ │ -00073740: 6528 7369 7a65 6f66 2874 6d70 292a 3229  e(sizeof(tmp)*2)
    │ │ │ -00073750: 3b0a 0909 6175 783a 3a74 6f5f 6865 7828  ;...aux::to_hex(
    │ │ │ -00073760: 746d 702c 2026 616d 703b 6d5f 7365 7373  tmp, &m_sess
    │ │ │ -00073770: 696f 6e5f 6964 5b30 5d29 3b0a 0a09 096d  ion_id[0]);....m
    │ │ │ -00073780: 5f73 616d 5f73 6f63 6b65 7420 3d20 7374  _sam_socket = st
    │ │ │ -00073790: 643a 3a6d 616b 655f 7368 6172 6564 266c  d::make_shared&l
    │ │ │ -000737a0: 743b 6932 705f 7374 7265 616d 2667 743b  t;i2p_stream>
    │ │ │ -000737b0: 286d 5f69 6f5f 7365 7276 6963 6529 3b0a  (m_io_service);.
    │ │ │ -000737c0: 0909 6d5f 7361 6d5f 736f 636b 6574 2d26  ..m_sam_socket-&
    │ │ │ -000737d0: 6774 3b73 6574 5f70 726f 7879 286d 5f68  gt;set_proxy(m_h
    │ │ │ -000737e0: 6f73 746e 616d 652c 206d 5f70 6f72 7429  ostname, m_port)
    │ │ │ -000737f0: 3b0a 0909 6d5f 7361 6d5f 736f 636b 6574  ;...m_sam_socket
    │ │ │ -00073800: 2d26 6774 3b73 6574 5f63 6f6d 6d61 6e64  ->set_command
    │ │ │ -00073810: 2869 3270 5f73 7472 6561 6d3a 3a63 6d64  (i2p_stream::cmd
    │ │ │ -00073820: 5f63 7265 6174 655f 7365 7373 696f 6e29  _create_session)
    │ │ │ -00073830: 3b0a 0909 6d5f 7361 6d5f 736f 636b 6574  ;...m_sam_socket
    │ │ │ -00073840: 2d26 6774 3b73 6574 5f73 6573 7369 6f6e  ->set_session
    │ │ │ -00073850: 5f69 6428 6d5f 7365 7373 696f 6e5f 6964  _id(m_session_id
    │ │ │ -00073860: 2e63 5f73 7472 2829 293b 0a09 096d 5f73  .c_str());...m_s
    │ │ │ -00073870: 616d 5f73 6f63 6b65 742d 2667 743b 7365  am_socket->se
    │ │ │ -00073880: 745f 7365 7373 696f 6e5f 6f70 7469 6f6e  t_session_option
    │ │ │ -00073890: 7328 7365 7373 696f 6e5f 6f70 7469 6f6e  s(session_option
    │ │ │ -000738a0: 7329 3b0a 0a09 0941 4444 5f4f 5554 5354  s);....ADD_OUTST
    │ │ │ -000738b0: 414e 4449 4e47 5f41 5359 4e43 2822 6932  ANDING_ASYNC("i2
    │ │ │ -000738c0: 705f 7374 7265 616d 3a3a 6f6e 5f73 616d  p_stream::on_sam
    │ │ │ -000738d0: 5f63 6f6e 6e65 6374 2229 3b0a 0909 6d5f  _connect");...m_
    │ │ │ -000738e0: 7361 6d5f 736f 636b 6574 2d26 6774 3b61  sam_socket->a
    │ │ │ -000738f0: 7379 6e63 5f63 6f6e 6e65 6374 2874 6370  sync_connect(tcp
    │ │ │ -00073900: 3a3a 656e 6470 6f69 6e74 2829 2c20 6175  ::endpoint(), au
    │ │ │ -00073910: 783a 3a77 7261 705f 616c 6c6f 6361 746f  x::wrap_allocato
    │ │ │ -00073920: 7228 0a09 0909 5b74 6869 732c 733d 6d5f  r(....[this,s=m_
    │ │ │ -00073930: 7361 6d5f 736f 636b 6574 5d28 6572 726f  sam_socket](erro
    │ │ │ -00073940: 725f 636f 6465 2063 6f6e 7374 2661 6d70  r_code const&
    │ │ │ -00073950: 3b20 6563 2c20 4861 6e64 6c65 7220 686e  ; ec, Handler hn
    │ │ │ -00073960: 2920 7b0a 0909 0909 6f6e 5f73 616d 5f63  ) {.....on_sam_c
    │ │ │ -00073970: 6f6e 6e65 6374 2865 632c 2073 2c20 7374  onnect(ec, s, st
    │ │ │ -00073980: 643a 3a6d 6f76 6528 686e 2929 3b0a 0909  d::move(hn));...
    │ │ │ -00073990: 097d 2c20 7374 643a 3a6d 6f76 6528 6861  .}, std::move(ha
    │ │ │ -000739a0: 6e64 6c65 7229 2929 3b0a 097d 0a09 766f  ndler)));..}..vo
    │ │ │ -000739b0: 6964 2063 6c6f 7365 2865 7272 6f72 5f63  id close(error_c
    │ │ │ -000739c0: 6f64 6526 616d 703b 293b 0a0a 3c64 6976  ode&);..
    .char │ │ │ -00073a00: 636f 6e73 742a 2073 6573 7369 6f6e 5f69 const* session_i │ │ │ -00073a10: 6428 2920 636f 6e73 7420 7b20 7265 7475 d() const { retu │ │ │ -00073a20: 726e 206d 5f73 6573 7369 6f6e 5f69 642e rn m_session_id. │ │ │ -00073a30: 635f 7374 7228 293b 207d 0a3c 2f64 6976 c_str(); }.
    .std::string co │ │ │ -00073a50: 6e73 7426 616d 703b 206c 6f63 616c 5f65 nst& local_e │ │ │ -00073a60: 6e64 706f 696e 7428 2920 636f 6e73 7420 ndpoint() const │ │ │ -00073a70: 7b20 7265 7475 726e 206d 5f69 3270 5f6c { return m_i2p_l │ │ │ -00073a80: 6f63 616c 5f65 6e64 706f 696e 743b 207d ocal_endpoint; } │ │ │ -00073a90: 0a0a 0974 656d 706c 6174 6520 266c 743b ...template < │ │ │ -00073aa0: 7479 7065 6e61 6d65 2048 616e 646c 6572 typename Handler │ │ │ -00073ab0: 2667 743b 0a09 766f 6964 2061 7379 6e63 >..void async │ │ │ -00073ac0: 5f6e 616d 655f 6c6f 6f6b 7570 2863 6861 _name_lookup(cha │ │ │ -00073ad0: 7220 636f 6e73 742a 206e 616d 652c 2048 r const* name, H │ │ │ -00073ae0: 616e 646c 6572 2068 616e 646c 6572 290a andler handler). │ │ │ -00073af0: 097b 0a09 0969 6620 286d 5f73 7461 7465 .{...if (m_state │ │ │ -00073b00: 203d 3d20 7361 6d5f 6964 6c65 2026 616d == sam_idle &am │ │ │ -00073b10: 703b 2661 6d70 3b20 6d5f 6e61 6d65 5f6c p;& m_name_l │ │ │ -00073b20: 6f6f 6b75 702e 656d 7074 7928 2920 2661 ookup.empty() &a │ │ │ -00073b30: 6d70 3b26 616d 703b 2069 735f 6f70 656e mp;& is_open │ │ │ -00073b40: 2829 290a 0909 0964 6f5f 6e61 6d65 5f6c ())....do_name_l │ │ │ -00073b50: 6f6f 6b75 7028 6e61 6d65 2c20 7374 643a ookup(name, std: │ │ │ -00073b60: 3a6d 6f76 6528 6861 6e64 6c65 7229 293b :move(handler)); │ │ │ -00073b70: 0a09 0965 6c73 650a 0909 096d 5f6e 616d ...else....m_nam │ │ │ -00073b80: 655f 6c6f 6f6b 7570 2e65 6d70 6c61 6365 e_lookup.emplace │ │ │ -00073b90: 5f62 6163 6b28 7374 643a 3a73 7472 696e _back(std::strin │ │ │ -00073ba0: 6728 6e61 6d65 290a 0909 0909 2c20 7374 g(name)....., st │ │ │ -00073bb0: 643a 3a6d 6f76 6528 6861 6e64 6c65 7229 d::move(handler) │ │ │ -00073bc0: 293b 0a09 7d0a 0a70 7269 7661 7465 3a0a );..}..private:. │ │ │ -00073bd0: 0a09 7465 6d70 6c61 7465 2026 6c74 3b74 ..template <t │ │ │ -00073be0: 7970 656e 616d 6520 4861 6e64 6c65 7226 ypename Handler& │ │ │ -00073bf0: 6774 3b0a 0976 6f69 6420 6f6e 5f73 616d gt;..void on_sam │ │ │ -00073c00: 5f63 6f6e 6e65 6374 2865 7272 6f72 5f63 _connect(error_c │ │ │ -00073c10: 6f64 6520 636f 6e73 7426 616d 703b 2065 ode const& e │ │ │ -00073c20: 632c 2073 7464 3a3a 7368 6172 6564 5f70 c, std::shared_p │ │ │ -00073c30: 7472 266c 743b 6932 705f 7374 7265 616d tr<i2p_stream │ │ │ -00073c40: 2667 743b 2c20 4861 6e64 6c65 7220 6829 >, Handler h) │ │ │ -00073c50: 0a09 7b0a 0909 434f 4d50 4c45 5445 5f41 ..{...COMPLETE_A │ │ │ -00073c60: 5359 4e43 2822 6932 705f 7374 7265 616d SYNC("i2p_stream │ │ │ -00073c70: 3a3a 6f6e 5f73 616d 5f63 6f6e 6e65 6374 ::on_sam_connect │ │ │ -00073c80: 2229 3b0a 0909 6d5f 7374 6174 6520 3d20 ");...m_state = │ │ │ -00073c90: 7361 6d5f 6964 6c65 3b0a 0a09 0969 6620 sam_idle;....if │ │ │ -00073ca0: 2865 6329 0a09 097b 0a09 0909 6828 6563 (ec)...{....h(ec │ │ │ -00073cb0: 293b 0a09 0909 7265 7475 726e 3b0a 0909 );....return;... │ │ │ -00073cc0: 7d0a 0a09 0964 6f5f 6e61 6d65 5f6c 6f6f }....do_name_loo │ │ │ -00073cd0: 6b75 7028 224d 4522 2c20 6175 783a 3a77 kup("ME", aux::w │ │ │ -00073ce0: 7261 705f 616c 6c6f 6361 746f 7228 0a09 rap_allocator(.. │ │ │ -00073cf0: 0909 5b74 6869 735d 2865 7272 6f72 5f63 ..[this](error_c │ │ │ -00073d00: 6f64 6520 636f 6e73 7426 616d 703b 2065 ode const& e │ │ │ -00073d10: 2c20 6368 6172 2063 6f6e 7374 2a20 6473 , char const* ds │ │ │ -00073d20: 742c 2048 616e 646c 6572 2068 6e29 207b t, Handler hn) { │ │ │ -00073d30: 0a09 0909 0973 6574 5f6c 6f63 616c 5f65 .....set_local_e │ │ │ -00073d40: 6e64 706f 696e 7428 652c 2064 7374 2c20 ndpoint(e, dst, │ │ │ -00073d50: 7374 643a 3a6d 6f76 6528 686e 2929 3b0a std::move(hn));. │ │ │ -00073d60: 0909 097d 2c20 7374 643a 3a6d 6f76 6528 ...}, std::move( │ │ │ -00073d70: 6829 2929 3b0a 3c2f 7072 653e 3c2f 7464 h)));.
    relevance │ │ │ -00073db0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -00073dc0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../include/libt │ │ │ -00073df0: 6f72 7265 6e74 2f70 6565 725f 636f 6e6e orrent/peer_conn │ │ │ -00073e00: 6563 7469 6f6e 5f69 6e74 6572 6661 6365 ection_interface │ │ │ -00073e10: 2e68 7070 3a34 313c 2f61 3e3c 2f74 643e .hpp:41 │ │ │ -00073e20: 3c74 643e 6d61 6b65 2074 6869 7320 696e make this in │ │ │ -00073e30: 7465 7266 6163 6520 736d 616c 6c65 7221 terface smaller! │ │ │ -00073e40: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    ma │ │ │ -00073e90: 6b65 2074 6869 7320 696e 7465 7266 6163 ke this interfac │ │ │ -00073ea0: 6520 736d 616c 6c65 7221 3c2f 6832 3e3c e smaller!

    < │ │ │ -00073eb0: 6834 3e2e 2e2f 696e 636c 7564 652f 6c69 h4>../include/li │ │ │ -00073ec0: 6274 6f72 7265 6e74 2f70 6565 725f 636f btorrent/peer_co │ │ │ -00073ed0: 6e6e 6563 7469 6f6e 5f69 6e74 6572 6661 nnection_interfa │ │ │ -00073ee0: 6365 2e68 7070 3a34 313c 2f68 343e 3c70 ce.hpp:41

    namespac │ │ │ -00073f30: 6520 6c69 6274 6f72 7265 6e74 207b 0a0a e libtorrent {.. │ │ │ -00073f40: 096e 616d 6573 7061 6365 2061 7578 207b .namespace aux { │ │ │ -00073f50: 0a09 0973 7472 7563 7420 746f 7272 656e ...struct torren │ │ │ -00073f60: 745f 7065 6572 3b0a 0909 636c 6173 7320 t_peer;...class │ │ │ -00073f70: 7374 6174 3b0a 097d 0a0a 092f 2f20 636c stat;..}...// cl │ │ │ -00073f80: 6173 7369 6669 6573 2061 2070 6565 7220 assifies a peer │ │ │ -00073f90: 636f 6e6e 6563 7469 6f6e 2062 7920 7468 connection by th │ │ │ -00073fa0: 6520 7072 6f74 6f63 6f6c 2069 7420 7370 e protocol it sp │ │ │ -00073fb0: 6561 6b73 2e0a 0965 6e75 6d20 636c 6173 eaks...enum clas │ │ │ -00073fc0: 7320 636f 6e6e 6563 7469 6f6e 5f74 7970 s connection_typ │ │ │ -00073fd0: 6520 3a20 7374 643a 3a75 696e 7438 5f74 e : std::uint8_t │ │ │ -00073fe0: 0a09 7b0a 0909 2f2f 2074 6869 7320 6973 ..{...// this is │ │ │ -00073ff0: 2061 2072 6567 756c 6172 2062 6974 746f a regular bitto │ │ │ -00074000: 7272 656e 7420 7065 6572 2063 6f6e 6e65 rrent peer conne │ │ │ -00074010: 6374 696f 6e0a 0909 6269 7474 6f72 7265 ction...bittorre │ │ │ -00074020: 6e74 2c0a 0909 2f2f 2042 4550 2031 3920 nt,...// BEP 19 │ │ │ -00074030: 7765 6220 7365 6564 0a09 0975 726c 5f73 web seed...url_s │ │ │ -00074040: 6565 642c 0a09 092f 2f20 4245 5020 3137 eed,...// BEP 17 │ │ │ -00074050: 2077 6562 2073 6565 6420 286e 6f20 6c6f web seed (no lo │ │ │ -00074060: 6e67 6572 2073 7570 706f 7274 6564 290a nger supported). │ │ │ -00074070: 0909 6874 7470 5f73 6565 640a 097d 3b0a ..http_seed..};. │ │ │ -00074080: 0a09 7573 696e 6720 6469 7363 6f6e 6e65 ..using disconne │ │ │ -00074090: 6374 5f73 6576 6572 6974 795f 7420 3d20 ct_severity_t = │ │ │ -000740a0: 6175 783a 3a73 7472 6f6e 675f 7479 7065 aux::strong_type │ │ │ -000740b0: 6465 6626 6c74 3b73 7464 3a3a 7569 6e74 def<std::uint │ │ │ -000740c0: 385f 742c 2073 7472 7563 7420 6469 7363 8_t, struct disc │ │ │ -000740d0: 6f6e 6e65 6374 5f73 6576 6572 6974 795f onnect_severity_ │ │ │ -000740e0: 7461 6726 6774 3b3b 0a0a 3c64 6976 2073 tag>;..

    .struct │ │ │ -00074120: 544f 5252 454e 545f 4558 5452 415f 4558 TORRENT_EXTRA_EX │ │ │ -00074130: 504f 5254 2070 6565 725f 636f 6e6e 6563 PORT peer_connec │ │ │ -00074140: 7469 6f6e 5f69 6e74 6572 6661 6365 0a3c tion_interface.< │ │ │ -00074150: 2f64 6976 3e09 7b0a 0909 7374 6174 6963 /div>.{...static │ │ │ -00074160: 2069 6e6c 696e 6520 636f 6e73 7465 7870 inline constexp │ │ │ -00074170: 7220 6469 7363 6f6e 6e65 6374 5f73 6576 r disconnect_sev │ │ │ -00074180: 6572 6974 795f 7420 6e6f 726d 616c 7b30 erity_t normal{0 │ │ │ -00074190: 7d3b 0a09 0973 7461 7469 6320 696e 6c69 };...static inli │ │ │ -000741a0: 6e65 2063 6f6e 7374 6578 7072 2064 6973 ne constexpr dis │ │ │ -000741b0: 636f 6e6e 6563 745f 7365 7665 7269 7479 connect_severity │ │ │ -000741c0: 5f74 2066 6169 6c75 7265 7b31 7d3b 0a09 _t failure{1};.. │ │ │ -000741d0: 0973 7461 7469 6320 696e 6c69 6e65 2063 .static inline c │ │ │ -000741e0: 6f6e 7374 6578 7072 2064 6973 636f 6e6e onstexpr disconn │ │ │ -000741f0: 6563 745f 7365 7665 7269 7479 5f74 2070 ect_severity_t p │ │ │ -00074200: 6565 725f 6572 726f 727b 327d 3b0a 0a23 eer_error{2};..# │ │ │ -00074210: 6966 2054 4f52 5245 4e54 5f55 5345 5f49 if TORRENT_USE_I │ │ │ -00074220: 3250 0a09 0976 6972 7475 616c 2073 7464 2P...virtual std │ │ │ -00074230: 3a3a 7374 7269 6e67 2063 6f6e 7374 2661 ::string const&a │ │ │ -00074240: 6d70 3b20 6465 7374 696e 6174 696f 6e28 mp; destination( │ │ │ -00074250: 2920 636f 6e73 7420 3d20 303b 0a09 0976 ) const = 0;...v │ │ │ -00074260: 6972 7475 616c 2073 7464 3a3a 7374 7269 irtual std::stri │ │ │ -00074270: 6e67 2063 6f6e 7374 2661 6d70 3b20 6c6f ng const& lo │ │ │ -00074280: 6361 6c5f 6932 705f 656e 6470 6f69 6e74 cal_i2p_endpoint │ │ │ -00074290: 2829 2063 6f6e 7374 203d 2030 3b0a 2365 () const = 0;.#e │ │ │ -000742a0: 6e64 6966 0a09 0976 6972 7475 616c 2074 ndif...virtual t │ │ │ -000742b0: 6370 3a3a 656e 6470 6f69 6e74 2063 6f6e cp::endpoint con │ │ │ -000742c0: 7374 2661 6d70 3b20 7265 6d6f 7465 2829 st& remote() │ │ │ -000742d0: 2063 6f6e 7374 203d 2030 3b0a 0909 7669 const = 0;...vi │ │ │ -000742e0: 7274 7561 6c20 7463 703a 3a65 6e64 706f rtual tcp::endpo │ │ │ -000742f0: 696e 7420 6c6f 6361 6c5f 656e 6470 6f69 int local_endpoi │ │ │ -00074300: 6e74 2829 2063 6f6e 7374 203d 2030 3b0a nt() const = 0;. │ │ │ -00074310: 0909 7669 7274 7561 6c20 766f 6964 2064 ..virtual void d │ │ │ -00074320: 6973 636f 6e6e 6563 7428 6572 726f 725f isconnect(error_ │ │ │ -00074330: 636f 6465 2063 6f6e 7374 2661 6d70 3b20 code const& │ │ │ -00074340: 6563 0a09 0909 2c20 6f70 6572 6174 696f ec...., operatio │ │ │ -00074350: 6e5f 7420 6f70 2c20 6469 7363 6f6e 6e65 n_t op, disconne │ │ │ -00074360: 6374 5f73 6576 6572 6974 795f 7420 3d20 ct_severity_t = │ │ │ -00074370: 7065 6572 5f63 6f6e 6e65 6374 696f 6e5f peer_connection_ │ │ │ -00074380: 696e 7465 7266 6163 653a 3a6e 6f72 6d61 interface::norma │ │ │ -00074390: 6c29 203d 2030 3b0a 0909 7669 7274 7561 l) = 0;...virtua │ │ │ -000743a0: 6c20 7065 6572 5f69 6420 636f 6e73 7426 l peer_id const& │ │ │ -000743b0: 616d 703b 2070 6964 2829 2063 6f6e 7374 amp; pid() const │ │ │ -000743c0: 203d 2030 3b0a 0909 7669 7274 7561 6c20 = 0;...virtual │ │ │ -000743d0: 7065 6572 5f69 6420 6f75 725f 7069 6428 peer_id our_pid( │ │ │ -000743e0: 2920 636f 6e73 7420 3d20 303b 0a09 0976 ) const = 0;...v │ │ │ -000743f0: 6972 7475 616c 2076 6f69 6420 7365 745f irtual void set_ │ │ │ -00074400: 686f 6c65 7075 6e63 685f 6d6f 6465 2829 holepunch_mode() │ │ │ -00074410: 203d 2030 3b0a 0909 7669 7274 7561 6c20 = 0;...virtual │ │ │ -00074420: 6175 783a 3a74 6f72 7265 6e74 5f70 6565 aux::torrent_pee │ │ │ -00074430: 722a 2070 6565 725f 696e 666f 5f73 7472 r* peer_info_str │ │ │ -00074440: 7563 7428 2920 636f 6e73 7420 3d20 303b uct() const = 0; │ │ │ -00074450: 0a09 0976 6972 7475 616c 2076 6f69 6420 ...virtual void │ │ │ -00074460: 7365 745f 7065 6572 5f69 6e66 6f28 6175 set_peer_info(au │ │ │ -00074470: 783a 3a74 6f72 7265 6e74 5f70 6565 722a x::torrent_peer* │ │ │ -00074480: 2070 6929 203d 2030 3b0a 0909 7669 7274 pi) = 0;...virt │ │ │ -00074490: 7561 6c20 626f 6f6c 2069 735f 6f75 7467 ual bool is_outg │ │ │ -000744a0: 6f69 6e67 2829 2063 6f6e 7374 203d 2030 oing() const = 0 │ │ │ -000744b0: 3b0a 0909 7669 7274 7561 6c20 766f 6964 ;...virtual void │ │ │ -000744c0: 2061 6464 5f73 7461 7428 7374 643a 3a69 add_stat(std::i │ │ │ -000744d0: 6e74 3634 5f74 2064 6f77 6e6c 6f61 6465 nt64_t downloade │ │ │ -000744e0: 642c 2073 7464 3a3a 696e 7436 345f 7420 d, std::int64_t │ │ │ -000744f0: 7570 6c6f 6164 6564 2920 3d20 303b 0a09 uploaded) = 0;.. │ │ │ -00074500: 0976 6972 7475 616c 2062 6f6f 6c20 6661 .virtual bool fa │ │ │ -00074510: 7374 5f72 6563 6f6e 6e65 6374 2829 2063 st_reconnect() c │ │ │ -00074520: 6f6e 7374 203d 2030 3b0a 0909 7669 7274 onst = 0;...virt │ │ │ -00074530: 7561 6c20 626f 6f6c 2069 735f 6368 6f6b ual bool is_chok │ │ │ -00074540: 6564 2829 2063 6f6e 7374 203d 2030 3b0a ed() const = 0;. │ │ │ -00074550: 0909 7669 7274 7561 6c20 626f 6f6c 2066 ..virtual bool f │ │ │ -00074560: 6169 6c65 6428 2920 636f 6e73 7420 3d20 ailed() const = │ │ │ -00074570: 303b 0a09 0976 6972 7475 616c 2061 7578 0;...virtual aux │ │ │ -00074580: 3a3a 7374 6174 2063 6f6e 7374 2661 6d70 ::stat const& │ │ │ -00074590: 3b20 7374 6174 6973 7469 6373 2829 2063 ; statistics() c │ │ │ -000745a0: 6f6e 7374 203d 2030 3b0a 0909 7669 7274 onst = 0;...virt │ │ │ -000745b0: 7561 6c20 766f 6964 2067 6574 5f70 6565 ual void get_pee │ │ │ -000745c0: 725f 696e 666f 2870 6565 725f 696e 666f r_info(peer_info │ │ │ -000745d0: 2661 6d70 3b20 7029 2063 6f6e 7374 203d & p) const = │ │ │ -000745e0: 2030 3b0a 2369 666e 6465 6620 544f 5252 0;.#ifndef TORR │ │ │ -000745f0: 454e 545f 4449 5341 424c 455f 4c4f 4747 ENT_DISABLE_LOGG │ │ │ -00074600: 494e 470a 0909 7669 7274 7561 6c20 626f ING...virtual bo │ │ │ -00074610: 6f6c 2073 686f 756c 645f 6c6f 6728 7065 ol should_log(pe │ │ │ -00074620: 6572 5f6c 6f67 5f61 6c65 7274 3a3a 6469 er_log_alert::di │ │ │ -00074630: 7265 6374 696f 6e5f 7420 6469 7265 6374 rection_t direct │ │ │ -00074640: 696f 6e29 2063 6f6e 7374 203d 2030 3b0a ion) const = 0;. │ │ │ -00074650: 0909 7669 7274 7561 6c20 766f 6964 2070 ..virtual void p │ │ │ -00074660: 6565 725f 6c6f 6728 7065 6572 5f6c 6f67 eer_log(peer_log │ │ │ -00074670: 5f61 6c65 7274 3a3a 6469 7265 6374 696f _alert::directio │ │ │ -00074680: 6e5f 7420 6469 7265 6374 696f 6e0a 0909 n_t direction... │ │ │ -00074690: 092c 2070 6565 725f 6c6f 675f 616c 6572 ., peer_log_aler │ │ │ -000746a0: 743a 3a65 7665 6e74 5f74 2065 7665 6e74 t::event_t event │ │ │ -000746b0: 2c20 6368 6172 2063 6f6e 7374 2a20 666d , char const* fm │ │ │ -000746c0: 7420 3d20 2222 2c20 2e2e 2e29 2063 6f6e t = "", ...) con │ │ │ -000746d0: 7374 206e 6f65 7863 6570 7420 544f 5252 st noexcept TORR │ │ │ -000746e0: 454e 545f 464f 524d 4154 2834 2c35 2920 ENT_FORMAT(4,5) │ │ │ -000746f0: 3d20 303b 0a23 656e 6469 660a 3c2f 7072 = 0;.#endif.rel │ │ │ -00074730: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../includ │ │ │ -00074770: 652f 6c69 6274 6f72 7265 6e74 2f73 6f63 e/libtorrent/soc │ │ │ -00074780: 6b73 355f 7374 7265 616d 2e68 7070 3a31 ks5_stream.hpp:1 │ │ │ -00074790: 3736 3c2f 613e 3c2f 7464 3e3c 7464 3e77 76w │ │ │ -000747a0: 6520 636f 756c 6420 6269 6e64 2074 6865 e could bind the │ │ │ -000747b0: 2073 6f63 6b65 7420 6865 7265 2c20 7369 socket here, si │ │ │ -000747c0: 6e63 6520 7765 206b 6e6f 7720 7768 6174 nce we know what │ │ │ -000747d0: 2074 6865 2074 6172 6765 7420 656e 6470 the target endp │ │ │ -000747e0: 6f69 6e74 2069 7320 6f66 2074 6865 2070 oint is of the p │ │ │ -000747f0: 726f 7879 3c2f 7464 3e3c 2f74 723e 3c74 roxywe could bind │ │ │ -00074850: 7468 6520 736f 636b 6574 2068 6572 652c the socket here, │ │ │ -00074860: 2073 696e 6365 2077 6520 6b6e 6f77 2077 since we know w │ │ │ -00074870: 6861 7420 7468 650a 7461 7267 6574 2065 hat the.target e │ │ │ -00074880: 6e64 706f 696e 7420 6973 206f 6620 7468 ndpoint is of th │ │ │ -00074890: 6520 7072 6f78 793c 2f68 323e 3c68 343e e proxy

    │ │ │ -000748a0: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -000748b0: 7272 656e 742f 736f 636b 7335 5f73 7472 rrent/socks5_str │ │ │ -000748c0: 6561 6d2e 6870 703a 3137 363c 2f68 343e eam.hpp:176

    │ │ │ -000748d0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ...}, 
    │ │ │ -00074910: 7374 643a 3a6d 6f76 6528 6861 6e64 6c65  std::move(handle
    │ │ │ -00074920: 7229 2929 3b0a 097d 0a0a 7072 6976 6174  r)));..}..privat
    │ │ │ -00074930: 653a 0a0a 0974 656d 706c 6174 6520 266c  e:...template &l
    │ │ │ -00074940: 743b 7479 7065 6e61 6d65 2048 616e 646c  t;typename Handl
    │ │ │ -00074950: 6572 2667 743b 0a09 766f 6964 206e 616d  er>..void nam
    │ │ │ -00074960: 655f 6c6f 6f6b 7570 2865 7272 6f72 5f63  e_lookup(error_c
    │ │ │ -00074970: 6f64 6520 636f 6e73 7426 616d 703b 2065  ode const& e
    │ │ │ -00074980: 2c20 7463 703a 3a72 6573 6f6c 7665 723a  , tcp::resolver:
    │ │ │ -00074990: 3a72 6573 756c 7473 5f74 7970 6520 6970  :results_type ip
    │ │ │ -000749a0: 730a 0909 2c20 4861 6e64 6c65 7220 6829  s..., Handler h)
    │ │ │ -000749b0: 0a09 7b0a 0909 434f 4d50 4c45 5445 5f41  ..{...COMPLETE_A
    │ │ │ -000749c0: 5359 4e43 2822 736f 636b 7335 5f73 7472  SYNC("socks5_str
    │ │ │ -000749d0: 6561 6d3a 3a6e 616d 655f 6c6f 6f6b 7570  eam::name_lookup
    │ │ │ -000749e0: 2229 3b0a 0909 6966 2028 6861 6e64 6c65  ");...if (handle
    │ │ │ -000749f0: 5f65 7272 6f72 2865 2c20 7374 643a 3a6d  _error(e, std::m
    │ │ │ -00074a00: 6f76 6528 6829 2929 2072 6574 7572 6e3b  ove(h))) return;
    │ │ │ -00074a10: 0a0a 0909 6175 746f 2069 203d 2069 7073  ....auto i = ips
    │ │ │ -00074a20: 2e62 6567 696e 2829 3b0a 0909 6966 2028  .begin();...if (
    │ │ │ -00074a30: 216d 5f73 6f63 6b2e 6973 5f6f 7065 6e28  !m_sock.is_open(
    │ │ │ -00074a40: 2929 0a09 097b 0a09 0909 6572 726f 725f  ))...{....error_
    │ │ │ -00074a50: 636f 6465 2065 633b 0a09 0909 6d5f 736f  code ec;....m_so
    │ │ │ -00074a60: 636b 2e6f 7065 6e28 692d 2667 743b 656e  ck.open(i->en
    │ │ │ -00074a70: 6470 6f69 6e74 2829 2e70 726f 746f 636f  dpoint().protoco
    │ │ │ -00074a80: 6c28 292c 2065 6329 3b0a 0909 0969 6620  l(), ec);....if 
    │ │ │ -00074a90: 2868 616e 646c 655f 6572 726f 7228 6563  (handle_error(ec
    │ │ │ -00074aa0: 2c20 7374 643a 3a6d 6f76 6528 6829 2929  , std::move(h)))
    │ │ │ -00074ab0: 2072 6574 7572 6e3b 0a09 097d 0a0a 3c64   return;...}....AD
    │ │ │ -00074af0: 445f 4f55 5453 5441 4e44 494e 475f 4153  D_OUTSTANDING_AS
    │ │ │ -00074b00: 594e 4328 2273 6f63 6b73 355f 7374 7265  YNC("socks5_stre
    │ │ │ -00074b10: 616d 3a3a 636f 6e6e 6563 7465 6422 293b  am::connected");
    │ │ │ -00074b20: 0a3c 2f64 6976 3e09 096d 5f73 6f63 6b2e  .
    ..m_sock. │ │ │ -00074b30: 6173 796e 635f 636f 6e6e 6563 7428 692d async_connect(i- │ │ │ -00074b40: 2667 743b 656e 6470 6f69 6e74 2829 2c20 >endpoint(), │ │ │ -00074b50: 6175 783a 3a77 7261 705f 616c 6c6f 6361 aux::wrap_alloca │ │ │ -00074b60: 746f 7228 0a09 0909 5b74 6869 735d 2865 tor(....[this](e │ │ │ -00074b70: 7272 6f72 5f63 6f64 6520 636f 6e73 7426 rror_code const& │ │ │ -00074b80: 616d 703b 2065 632c 2048 616e 646c 6572 amp; ec, Handler │ │ │ -00074b90: 2068 6e29 0a09 0909 7b20 636f 6e6e 6563 hn)....{ connec │ │ │ -00074ba0: 7465 6428 6563 2c20 7374 643a 3a6d 6f76 ted(ec, std::mov │ │ │ -00074bb0: 6528 686e 2929 3b20 7d2c 2073 7464 3a3a e(hn)); }, std:: │ │ │ -00074bc0: 6d6f 7665 2868 2929 293b 0a09 7d0a 0a09 move(h)));..}... │ │ │ -00074bd0: 7465 6d70 6c61 7465 2026 6c74 3b74 7970 template <typ │ │ │ -00074be0: 656e 616d 6520 4861 6e64 6c65 7226 6774 ename Handler> │ │ │ -00074bf0: 3b0a 0976 6f69 6420 636f 6e6e 6563 7465 ;..void connecte │ │ │ -00074c00: 6428 6572 726f 725f 636f 6465 2063 6f6e d(error_code con │ │ │ -00074c10: 7374 2661 6d70 3b20 652c 2048 616e 646c st& e, Handl │ │ │ -00074c20: 6572 2068 290a 097b 0a09 0943 4f4d 504c er h)..{...COMPL │ │ │ -00074c30: 4554 455f 4153 594e 4328 2273 6f63 6b73 ETE_ASYNC("socks │ │ │ -00074c40: 355f 7374 7265 616d 3a3a 636f 6e6e 6563 5_stream::connec │ │ │ -00074c50: 7465 6422 293b 0a09 0969 6620 2868 616e ted");...if (han │ │ │ -00074c60: 646c 655f 6572 726f 7228 652c 2073 7464 dle_error(e, std │ │ │ -00074c70: 3a3a 6d6f 7665 2868 2929 2920 7265 7475 ::move(h))) retu │ │ │ -00074c80: 726e 3b0a 0a09 0975 7369 6e67 206e 616d rn;....using nam │ │ │ -00074c90: 6573 7061 6365 206c 6962 746f 7272 656e espace libtorren │ │ │ -00074ca0: 743a 3a61 7578 3b0a 0909 6966 2028 6d5f t::aux;...if (m_ │ │ │ -00074cb0: 7665 7273 696f 6e20 3d3d 2035 290a 0909 version == 5)... │ │ │ -00074cc0: 7b0a 0909 092f 2f20 7365 6e64 2053 4f43 {....// send SOC │ │ │ -00074cd0: 4b53 3520 6175 7468 656e 7469 6361 7469 KS5 authenticati │ │ │ -00074ce0: 6f6e 206d 6574 686f 6473 0a09 0909 6d5f on methods....m_ │ │ │ -00074cf0: 6275 6666 6572 2e72 6573 697a 6528 6d5f buffer.resize(m_ │ │ │ -00074d00: 7573 6572 2e65 6d70 7479 2829 3f33 3a34 user.empty()?3:4 │ │ │ -00074d10: 293b 0a09 0909 6368 6172 2a20 7020 3d20 );....char* p = │ │ │ -00074d20: 2661 6d70 3b6d 5f62 7566 6665 725b 305d &m_buffer[0] │ │ │ -00074d30: 3b0a 0909 0977 7269 7465 5f75 696e 7438 ;....write_uint8 │ │ │ -00074d40: 2835 2c20 7029 3b20 2f2f 2053 4f43 4b53 (5, p); // SOCKS │ │ │ -00074d50: 2056 4552 5349 4f4e 2035 0a09 0909 6966 VERSION 5....if │ │ │ -00074d60: 2028 6d5f 7573 6572 2e65 6d70 7479 2829 (m_user.empty() │ │ │ -00074d70: 290a 0909 097b 0a09 0909 0977 7269 7465 )....{.....write │ │ │ -00074d80: 5f75 696e 7438 2831 2c20 7029 3b20 2f2f _uint8(1, p); // │ │ │ -00074d90: 2031 2061 7574 6865 6e74 6963 6174 696f 1 authenticatio │ │ │ -00074da0: 6e20 6d65 7468 6f64 2028 6e6f 2061 7574 n method (no aut │ │ │ -00074db0: 6829 0a09 0909 0977 7269 7465 5f75 696e h).....write_uin │ │ │ -00074dc0: 7438 2830 2c20 7029 3b20 2f2f 206e 6f20 t8(0, p); // no │ │ │ -00074dd0: 6175 7468 656e 7469 6361 7469 6f6e 0a09 authentication.. │ │ │ -00074de0: 0909 7d0a 0909 0965 6c73 650a 0909 097b ..}....else....{ │ │ │ -00074df0: 0a09 0909 0977 7269 7465 5f75 696e 7438 .....write_uint8 │ │ │ -00074e00: 2832 2c20 7029 3b20 2f2f 2032 2061 7574 (2, p); // 2 aut │ │ │ -00074e10: 6865 6e74 6963 6174 696f 6e20 6d65 7468 hentication meth │ │ │ -00074e20: 6f64 730a 0909 0909 7772 6974 655f 7569 ods.....write_ui │ │ │ -00074e30: 6e74 3828 302c 2070 293b 202f 2f20 6e6f nt8(0, p); // no │ │ │ -00074e40: 2061 7574 6865 6e74 6963 6174 696f 6e0a authentication. │ │ │ -00074e50: 0909 0909 7772 6974 655f 7569 6e74 3828 ....write_uint8( │ │ │ -00074e60: 322c 2070 293b 202f 2f20 7573 6572 6e61 2, p); // userna │ │ │ -00074e70: 6d65 2f70 6173 7377 6f72 640a 0909 097d me/password....} │ │ │ -00074e80: 0a09 0909 4144 445f 4f55 5453 5441 4e44 ....ADD_OUTSTAND │ │ │ -00074e90: 494e 475f 4153 594e 4328 2273 6f63 6b73 ING_ASYNC("socks │ │ │ -00074ea0: 355f 7374 7265 616d 3a3a 6861 6e64 7368 5_stream::handsh │ │ │ -00074eb0: 616b 6531 2229 3b0a 3c2f 7072 653e 3c2f ake1");.relevan │ │ │ -00074ef0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../include/li │ │ │ -00074f30: 6274 6f72 7265 6e74 2f61 6e6e 6f75 6e63 btorrent/announc │ │ │ -00074f40: 655f 656e 7472 792e 6870 703a 3539 3c2f e_entry.hpp:59inclu │ │ │ -00074f60: 6465 2074 6865 206e 756d 6265 7220 6f66 de the number of │ │ │ -00074f70: 2070 6565 7273 2072 6563 6569 7665 6420 peers received │ │ │ -00074f80: 6672 6f6d 2074 6869 7320 7472 6163 6b65 from this tracke │ │ │ -00074f90: 722c 2061 7420 6c61 7374 2061 6e6e 6f75 r, at last annou │ │ │ -00074fa0: 6e63 653c 2f74 643e 3c2f 7472 3e3c 7472 nce

    include the num │ │ │ -00075000: 6265 7220 6f66 2070 6565 7273 2072 6563 ber of peers rec │ │ │ -00075010: 6569 7665 6420 6672 6f6d 2074 6869 7320 eived from this │ │ │ -00075020: 7472 6163 6b65 722c 2061 7420 6c61 7374 tracker, at last │ │ │ -00075030: 0a61 6e6e 6f75 6e63 653c 2f68 323e 3c68 .announce

    ../include/lib │ │ │ -00075050: 746f 7272 656e 742f 616e 6e6f 756e 6365 torrent/announce │ │ │ -00075060: 5f65 6e74 7279 2e68 7070 3a35 393c 2f68 _entry.hpp:59
    // f
    │ │ │ -000750b0: 6f72 2065 6163 6820 7072 6f74 6f63 6f6c  or each protocol
    │ │ │ -000750c0: 2076 6572 7369 6f6e 2e0a 7374 7275 6374   version..struct
    │ │ │ -000750d0: 2054 4f52 5245 4e54 5f45 5850 4f52 5420   TORRENT_EXPORT 
    │ │ │ -000750e0: 616e 6e6f 756e 6365 5f69 6e66 6f68 6173  announce_infohas
    │ │ │ -000750f0: 680a 7b0a 092f 2f20 696e 7465 726e 616c  h.{..// internal
    │ │ │ -00075100: 0a09 544f 5252 454e 545f 554e 4558 504f  ..TORRENT_UNEXPO
    │ │ │ -00075110: 5254 2061 6e6e 6f75 6e63 655f 696e 666f  RT announce_info
    │ │ │ -00075120: 6861 7368 2829 3b0a 0a09 2f2f 2069 6620  hash();...// if 
    │ │ │ -00075130: 7468 6973 2074 7261 636b 6572 2068 6173  this tracker has
    │ │ │ -00075140: 2072 6574 7572 6e65 6420 616e 2065 7272   returned an err
    │ │ │ -00075150: 6f72 206f 7220 7761 726e 696e 6720 6d65  or or warning me
    │ │ │ -00075160: 7373 6167 650a 092f 2f20 7468 6174 206d  ssage..// that m
    │ │ │ -00075170: 6573 7361 6765 2069 7320 7374 6f72 6564  essage is stored
    │ │ │ -00075180: 2068 6572 650a 0973 7464 3a3a 7374 7269   here..std::stri
    │ │ │ -00075190: 6e67 206d 6573 7361 6765 3b0a 0a09 2f2f  ng message;...//
    │ │ │ -000751a0: 2069 6620 7468 6973 2074 7261 636b 6572   if this tracker
    │ │ │ -000751b0: 2066 6169 6c65 6420 7468 6520 6c61 7374   failed the last
    │ │ │ -000751c0: 2074 696d 6520 6974 2077 6173 2063 6f6e   time it was con
    │ │ │ -000751d0: 7461 6374 6564 0a09 2f2f 2074 6869 7320  tacted..// this 
    │ │ │ -000751e0: 6572 726f 7220 636f 6465 2073 7065 6369  error code speci
    │ │ │ -000751f0: 6669 6573 2077 6861 7420 6572 726f 7220  fies what error 
    │ │ │ -00075200: 6f63 6375 7272 6564 0a09 6572 726f 725f  occurred..error_
    │ │ │ -00075210: 636f 6465 206c 6173 745f 6572 726f 723b  code last_error;
    │ │ │ -00075220: 0a0a 092f 2f20 7468 6520 7469 6d65 206f  ...// the time o
    │ │ │ -00075230: 6620 6e65 7874 2074 7261 636b 6572 2061  f next tracker a
    │ │ │ -00075240: 6e6e 6f75 6e63 650a 0974 696d 655f 706f  nnounce..time_po
    │ │ │ -00075250: 696e 7433 3220 6e65 7874 5f61 6e6e 6f75  int32 next_annou
    │ │ │ -00075260: 6e63 6520 3d20 2874 696d 655f 706f 696e  nce = (time_poin
    │ │ │ -00075270: 7433 323a 3a6d 696e 2928 293b 0a0a 092f  t32::min)();.../
    │ │ │ -00075280: 2f20 6e6f 2061 6e6e 6f75 6e63 6573 2062  / no announces b
    │ │ │ -00075290: 6566 6f72 6520 7468 6973 2074 696d 650a  efore this time.
    │ │ │ -000752a0: 0974 696d 655f 706f 696e 7433 3220 6d69  .time_point32 mi
    │ │ │ -000752b0: 6e5f 616e 6e6f 756e 6365 203d 2028 7469  n_announce = (ti
    │ │ │ -000752c0: 6d65 5f70 6f69 6e74 3332 3a3a 6d69 6e29  me_point32::min)
    │ │ │ -000752d0: 2829 3b0a 0a3c 6469 7620 7374 796c 653d  ();..
    .
    .// th │ │ │ -00075310: 6573 6520 6172 6520 6569 7468 6572 202d ese are either - │ │ │ -00075320: 3120 6f72 2074 6865 2073 6372 6170 6520 1 or the scrape │ │ │ -00075330: 696e 666f 726d 6174 696f 6e20 7468 6973 information this │ │ │ -00075340: 2074 7261 636b 6572 206c 6173 740a 092f tracker last../ │ │ │ -00075350: 2f20 7265 7370 6f6e 6465 6420 7769 7468 / responded with │ │ │ -00075360: 2e20 2a69 6e63 6f6d 706c 6574 652a 2069 . *incomplete* i │ │ │ -00075370: 7320 7468 6520 6375 7272 656e 7420 6e75 s the current nu │ │ │ -00075380: 6d62 6572 206f 6620 646f 776e 6c6f 6164 mber of download │ │ │ -00075390: 6572 7320 696e 0a09 2f2f 2074 6865 2073 ers in..// the s │ │ │ -000753a0: 7761 726d 2c20 2a63 6f6d 706c 6574 652a warm, *complete* │ │ │ -000753b0: 2069 7320 7468 6520 6375 7272 656e 7420 is the current │ │ │ -000753c0: 6e75 6d62 6572 206f 6620 7365 6564 7320 number of seeds │ │ │ -000753d0: 696e 2074 6865 2073 7761 726d 2061 6e64 in the swarm and │ │ │ -000753e0: 0a09 2f2f 202a 646f 776e 6c6f 6164 6564 ..// *downloaded │ │ │ -000753f0: 2a20 6973 2074 6865 2063 756d 756c 6174 * is the cumulat │ │ │ -00075400: 6976 6520 6e75 6d62 6572 206f 6620 636f ive number of co │ │ │ -00075410: 6d70 6c65 7465 6420 646f 776e 6c6f 6164 mpleted download │ │ │ -00075420: 7320 6f66 2074 6869 730a 092f 2f20 746f s of this..// to │ │ │ -00075430: 7272 656e 742c 2073 696e 6365 2074 6865 rrent, since the │ │ │ -00075440: 2062 6567 696e 6e69 6e67 206f 6620 7469 beginning of ti │ │ │ -00075450: 6d65 2028 6672 6f6d 2074 6869 7320 7472 me (from this tr │ │ │ -00075460: 6163 6b65 7227 7320 706f 696e 7420 6f66 acker's point of │ │ │ -00075470: 0a09 2f2f 2076 6965 7729 2e0a 0a09 2f2f ..// view)....// │ │ │ -00075480: 2069 6620 7468 6973 2074 7261 636b 6572 if this tracker │ │ │ -00075490: 2068 6173 2072 6574 7572 6e65 6420 7363 has returned sc │ │ │ -000754a0: 7261 7065 2064 6174 612c 2074 6865 7365 rape data, these │ │ │ -000754b0: 2066 6965 6c64 7320 6172 6520 6669 6c6c fields are fill │ │ │ -000754c0: 6564 2069 6e0a 092f 2f20 7769 7468 2076 ed in..// with v │ │ │ -000754d0: 616c 6964 206e 756d 6265 7273 2e20 4f74 alid numbers. Ot │ │ │ -000754e0: 6865 7277 6973 6520 7468 6579 2061 7265 herwise they are │ │ │ -000754f0: 2073 6574 2074 6f20 2d31 2e20 6060 696e set to -1. ``in │ │ │ -00075500: 636f 6d70 6c65 7465 6060 2063 6f75 6e74 complete`` count │ │ │ -00075510: 730a 092f 2f20 7468 6520 6e75 6d62 6572 s..// the number │ │ │ -00075520: 206f 6620 6375 7272 656e 7420 646f 776e of current down │ │ │ -00075530: 6c6f 6164 6572 732e 2060 6063 6f6d 706c loaders. ``compl │ │ │ -00075540: 6574 6560 6020 636f 756e 7473 2074 6865 ete`` counts the │ │ │ -00075550: 206e 756d 6265 7220 6f66 0a09 2f2f 2063 number of..// c │ │ │ -00075560: 7572 7265 6e74 2070 6565 7273 2063 6f6d urrent peers com │ │ │ -00075570: 706c 6574 6564 2074 6865 2064 6f77 6e6c pleted the downl │ │ │ -00075580: 6f61 642c 206f 7220 2273 6565 6473 222e oad, or "seeds". │ │ │ -00075590: 2060 6064 6f77 6e6c 6f61 6465 6460 6020 ``downloaded`` │ │ │ -000755a0: 6973 2074 6865 0a09 2f2f 2063 756d 756c is the..// cumul │ │ │ -000755b0: 6174 6976 6520 6e75 6d62 6572 206f 6620 ative number of │ │ │ -000755c0: 636f 6d70 6c65 7465 6420 646f 776e 6c6f completed downlo │ │ │ -000755d0: 6164 732e 0a09 696e 7420 7363 7261 7065 ads...int scrape │ │ │ -000755e0: 5f69 6e63 6f6d 706c 6574 6520 3d20 2d31 _incomplete = -1 │ │ │ -000755f0: 3b0a 0969 6e74 2073 6372 6170 655f 636f ;..int scrape_co │ │ │ -00075600: 6d70 6c65 7465 203d 202d 313b 0a09 696e mplete = -1;..in │ │ │ -00075610: 7420 7363 7261 7065 5f64 6f77 6e6c 6f61 t scrape_downloa │ │ │ -00075620: 6465 6420 3d20 2d31 3b0a 0a09 2f2f 2074 ded = -1;...// t │ │ │ -00075630: 6865 206e 756d 6265 7220 6f66 2074 696d he number of tim │ │ │ -00075640: 6573 2069 6e20 6120 726f 7720 7765 2068 es in a row we h │ │ │ -00075650: 6176 6520 6661 696c 6564 2074 6f20 616e ave failed to an │ │ │ -00075660: 6e6f 756e 6365 2074 6f20 7468 6973 0a09 nounce to this.. │ │ │ -00075670: 2f2f 2074 7261 636b 6572 2e0a 0973 7464 // tracker...std │ │ │ -00075680: 3a3a 7569 6e74 385f 7420 6661 696c 7320 ::uint8_t fails │ │ │ -00075690: 3a20 373b 0a0a 092f 2f20 7472 7565 2077 : 7;...// true w │ │ │ -000756a0: 6869 6c65 2077 6527 7265 2077 6169 7469 hile we're waiti │ │ │ -000756b0: 6e67 2066 6f72 2061 2072 6573 706f 6e73 ng for a respons │ │ │ -000756c0: 6520 6672 6f6d 2074 6865 2074 7261 636b e from the track │ │ │ -000756d0: 6572 2e0a 0962 6f6f 6c20 7570 6461 7469 er...bool updati │ │ │ -000756e0: 6e67 203a 2031 3b0a 0a09 2f2f 2073 6574 ng : 1;...// set │ │ │ -000756f0: 2074 6f20 7472 7565 2077 6865 6e20 7765 to true when we │ │ │ -00075700: 2067 6574 2061 2076 616c 6964 2072 6573 get a valid res │ │ │ -00075710: 706f 6e73 6520 6672 6f6d 2061 6e20 616e ponse from an an │ │ │ -00075720: 6e6f 756e 6365 0a09 2f2f 2077 6974 6820 nounce..// with │ │ │ -00075730: 6576 656e 743d 7374 6172 7465 642e 2049 event=started. I │ │ │ -00075740: 6620 6974 2069 7320 7365 742c 2077 6520 f it is set, we │ │ │ -00075750: 776f 6e27 7420 7365 6e64 2073 7461 7274 won't send start │ │ │ -00075760: 2069 6e20 7468 6520 7375 6273 6571 7565 in the subseque │ │ │ -00075770: 6e74 0a09 2f2f 2061 6e6e 6f75 6e63 6573 nt..// announces │ │ │ -00075780: 2e0a 0962 6f6f 6c20 7374 6172 745f 7365 ...bool start_se │ │ │ -00075790: 6e74 203a 2031 3b0a 0a09 2f2f 2073 6574 nt : 1;...// set │ │ │ -000757a0: 2074 6f20 7472 7565 2077 6865 6e20 7765 to true when we │ │ │ -000757b0: 2073 656e 6420 6120 6576 656e 743d 636f send a event=co │ │ │ -000757c0: 6d70 6c65 7465 642e 0a09 626f 6f6c 2063 mpleted...bool c │ │ │ -000757d0: 6f6d 706c 6574 655f 7365 6e74 203a 2031 omplete_sent : 1 │ │ │ -000757e0: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ -00075810: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00075820: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00075850: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -00075860: 6e74 2f6b 6164 656d 6c69 612f 6d73 672e nt/kademlia/msg. │ │ │ -00075870: 6870 703a 3634 3c2f 613e 3c2f 7464 3e3c hpp:64< │ │ │ -00075880: 7464 3e6d 6f76 6520 7468 6973 2074 6f20 td>move this to │ │ │ -00075890: 6974 7320 6f77 6e20 2e68 7070 2f2e 6370 its own .hpp/.cp │ │ │ -000758a0: 7020 7061 6972 3f3c 2f74 643e 3c2f 7472 p pair?

    move this t │ │ │ -00075900: 6f20 6974 7320 6f77 6e20 2e68 7070 2f2e o its own .hpp/. │ │ │ -00075910: 6370 7020 7061 6972 3f3c 2f68 323e 3c68 cpp pair?

    ../include/lib │ │ │ -00075930: 746f 7272 656e 742f 6b61 6465 6d6c 6961 torrent/kademlia │ │ │ -00075940: 2f6d 7367 2e68 7070 3a36 343c 2f68 343e /msg.hpp:64 │ │ │ -00075950: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    .int f
    │ │ │ -00075990: 6c61 6773 3b0a 0a09 656e 756d 207b 0a09  lags;...enum {..
    │ │ │ -000759a0: 092f 2f20 7468 6973 2061 7267 756d 656e  .// this argumen
    │ │ │ -000759b0: 7420 6973 206f 7074 696f 6e61 6c2c 2070  t is optional, p
    │ │ │ -000759c0: 6172 7369 6e67 2077 696c 6c20 6e6f 740a  arsing will not.
    │ │ │ -000759d0: 0909 2f2f 2066 6169 6c20 6966 2069 7427  ..// fail if it'
    │ │ │ -000759e0: 7320 6e6f 7420 7072 6573 656e 740a 0909  s not present...
    │ │ │ -000759f0: 6f70 7469 6f6e 616c 203d 2031 2c0a 0909  optional = 1,...
    │ │ │ -00075a00: 2f2f 2066 6f72 2064 6963 7469 6f6e 6172  // for dictionar
    │ │ │ -00075a10: 6965 732c 2074 6865 2066 6f6c 6c6f 7769  ies, the followi
    │ │ │ -00075a20: 6e67 2065 6e74 7269 6573 2072 6566 6572  ng entries refer
    │ │ │ -00075a30: 0a09 092f 2f20 746f 2063 6869 6c64 206e  ...// to child n
    │ │ │ -00075a40: 6f64 6573 2074 6f20 7468 6973 206e 6f64  odes to this nod
    │ │ │ -00075a50: 652c 2075 7020 756e 7469 6c20 616e 6420  e, up until and 
    │ │ │ -00075a60: 696e 636c 7564 696e 670a 0909 2f2f 2074  including...// t
    │ │ │ -00075a70: 6865 206e 6578 7420 6974 656d 2074 6861  he next item tha
    │ │ │ -00075a80: 7420 6861 7320 7468 6520 6c61 7374 5f63  t has the last_c
    │ │ │ -00075a90: 6869 6c64 2066 6c61 6720 7365 742e 0a09  hild flag set...
    │ │ │ -00075aa0: 092f 2f20 7468 6573 6520 666c 6167 7320  .// these flags 
    │ │ │ -00075ab0: 6172 6520 6e65 7374 6162 6c65 0a09 0970  are nestable...p
    │ │ │ -00075ac0: 6172 7365 5f63 6869 6c64 7265 6e20 3d20  arse_children = 
    │ │ │ -00075ad0: 322c 0a09 092f 2f20 7468 6973 2069 7320  2,...// this is 
    │ │ │ -00075ae0: 7468 6520 6c61 7374 2069 7465 6d20 696e  the last item in
    │ │ │ -00075af0: 2061 2063 6869 6c64 2064 6963 7469 6f6e   a child diction
    │ │ │ -00075b00: 6172 790a 0909 6c61 7374 5f63 6869 6c64  ary...last_child
    │ │ │ -00075b10: 203d 2034 2c0a 0909 2f2f 2074 6865 2073   = 4,...// the s
    │ │ │ -00075b20: 697a 6520 6172 6775 6d65 6e74 2072 6566  ize argument ref
    │ │ │ -00075b30: 6572 7320 746f 2074 6861 7420 7468 6520  ers to that the 
    │ │ │ -00075b40: 7369 7a65 0a09 092f 2f20 6861 7320 746f  size...// has to
    │ │ │ -00075b50: 2062 6520 6469 7669 7369 626c 6520 6279   be divisible by
    │ │ │ -00075b60: 2074 6865 206e 756d 6265 722c 2069 6e73   the number, ins
    │ │ │ -00075b70: 7465 6164 0a09 092f 2f20 6f66 2068 6176  tead...// of hav
    │ │ │ -00075b80: 696e 6720 7468 6174 2065 7861 6374 2073  ing that exact s
    │ │ │ -00075b90: 697a 650a 0909 7369 7a65 5f64 6976 6973  ize...size_divis
    │ │ │ -00075ba0: 6962 6c65 203d 2038 0a09 7d3b 0a7d 3b0a  ible = 8..};.};.
    │ │ │ -00075bb0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    T │ │ │ -00075be0: 4f52 5245 4e54 5f45 5854 5241 5f45 5850 ORRENT_EXTRA_EXP │ │ │ -00075bf0: 4f52 5420 626f 6f6c 2076 6572 6966 795f ORT bool verify_ │ │ │ -00075c00: 6d65 7373 6167 655f 696d 706c 2862 6465 message_impl(bde │ │ │ -00075c10: 636f 6465 5f6e 6f64 6520 636f 6e73 7426 code_node const& │ │ │ -00075c20: 616d 703b 206d 6573 7361 6765 2c20 7370 amp; message, sp │ │ │ -00075c30: 616e 266c 743b 6b65 795f 6465 7363 5f74 an<key_desc_t │ │ │ -00075c40: 2063 6f6e 7374 2667 743b 2064 6573 630a const> desc. │ │ │ -00075c50: 3c2f 6469 763e 092c 2073 7061 6e26 6c74
    ., span< │ │ │ -00075c60: 3b62 6465 636f 6465 5f6e 6f64 6526 6774 ;bdecode_node> │ │ │ -00075c70: 3b20 7265 742c 2073 7061 6e26 6c74 3b63 ; ret, span<c │ │ │ -00075c80: 6861 7226 6774 3b20 6572 726f 7229 3b0a har> error);. │ │ │ -00075c90: 0a2f 2f20 7665 7269 6669 6573 2074 6861 .// verifies tha │ │ │ -00075ca0: 7420 6120 6d65 7373 6167 6520 6861 7320 t a message has │ │ │ -00075cb0: 616c 6c20 7468 6520 7265 7175 6972 6564 all the required │ │ │ -00075cc0: 0a2f 2f20 656e 7472 6965 7320 616e 6420 .// entries and │ │ │ -00075cd0: 7265 7475 726e 7320 7468 656d 2069 6e20 returns them in │ │ │ -00075ce0: 7265 740a 7465 6d70 6c61 7465 2026 6c74 ret.template < │ │ │ -00075cf0: 3b69 6e74 2053 697a 6526 6774 3b0a 626f ;int Size>.bo │ │ │ -00075d00: 6f6c 2076 6572 6966 795f 6d65 7373 6167 ol verify_messag │ │ │ -00075d10: 6528 6264 6563 6f64 655f 6e6f 6465 2063 e(bdecode_node c │ │ │ -00075d20: 6f6e 7374 2661 6d70 3b20 6d73 672c 206b onst& msg, k │ │ │ -00075d30: 6579 5f64 6573 635f 7420 636f 6e73 7420 ey_desc_t const │ │ │ -00075d40: 2826 616d 703b 6465 7363 295b 5369 7a65 (&desc)[Size │ │ │ -00075d50: 5d0a 092c 2062 6465 636f 6465 5f6e 6f64 ].., bdecode_nod │ │ │ -00075d60: 6520 2826 616d 703b 7265 7429 5b53 697a e (&ret)[Siz │ │ │ -00075d70: 655d 2c20 7370 616e 266c 743b 6368 6172 e], span<char │ │ │ -00075d80: 2667 743b 2065 7272 6f72 290a 7b0a 0972 > error).{..r │ │ │ -00075d90: 6574 7572 6e20 7665 7269 6679 5f6d 6573 eturn verify_mes │ │ │ -00075da0: 7361 6765 5f69 6d70 6c28 6d73 672c 2064 sage_impl(msg, d │ │ │ -00075db0: 6573 632c 2072 6574 2c20 6572 726f 7229 esc, ret, error) │ │ │ -00075dc0: 3b0a 7d0a 0a7d 0a7d 0a0a 2365 6e64 6966 ;.}..}.}..#endif │ │ │ -00075dd0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -00075e10: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../i │ │ │ -00075e40: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -00075e50: 742f 6b61 6465 6d6c 6961 2f69 7465 6d2e t/kademlia/item. │ │ │ -00075e60: 6870 703a 3338 3c2f 613e 3c2f 7464 3e3c hpp:38< │ │ │ -00075e70: 7464 3e73 696e 6365 2074 6869 7320 6973 td>since this is │ │ │ -00075e80: 2061 2070 7562 6c69 6320 6675 6e63 7469 a public functi │ │ │ -00075e90: 6f6e 2c20 6974 2073 686f 756c 6420 7072 on, it should pr │ │ │ -00075ea0: 6f62 6162 6c79 2062 6520 6d6f 7665 6420 obably be moved │ │ │ -00075eb0: 6f75 7420 6f66 2074 6869 7320 6865 6164 out of this head │ │ │ -00075ec0: 6572 2061 6e64 2069 6e74 6f20 6f6e 6520 er and into one │ │ │ -00075ed0: 7769 7468 206f 7468 6572 2070 7562 6c69 with other publi │ │ │ -00075ee0: 6320 6675 6e63 7469 6f6e 732e 3c2f 7464 c functions.

    since │ │ │ -00075f40: 7468 6973 2069 7320 6120 7075 626c 6963 this is a public │ │ │ -00075f50: 2066 756e 6374 696f 6e2c 2069 7420 7368 function, it sh │ │ │ -00075f60: 6f75 6c64 2070 726f 6261 626c 7920 6265 ould probably be │ │ │ -00075f70: 206d 6f76 6564 0a6f 7574 206f 6620 7468 moved.out of th │ │ │ -00075f80: 6973 2068 6561 6465 7220 616e 6420 696e is header and in │ │ │ -00075f90: 746f 206f 6e65 2077 6974 6820 6f74 6865 to one with othe │ │ │ -00075fa0: 7220 7075 626c 6963 2066 756e 6374 696f r public functio │ │ │ -00075fb0: 6e73 2e3c 2f68 323e 3c68 343e 2e2e 2f69 ns.

    ../i │ │ │ -00075fc0: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -00075fd0: 742f 6b61 6465 6d6c 6961 2f69 7465 6d2e t/kademlia/item. │ │ │ -00075fe0: 6870 703a 3338 3c2f 6834 3e3c 7072 6520 hpp:38

    #include &l
    │ │ │ -00076030: 743b 6c69 6274 6f72 7265 6e74 2f73 7061  t;libtorrent/spa
    │ │ │ -00076040: 6e2e 6870 7026 6774 3b0a 2369 6e63 6c75  n.hpp>.#inclu
    │ │ │ -00076050: 6465 2026 6c74 3b6c 6962 746f 7272 656e  de <libtorren
    │ │ │ -00076060: 742f 6b61 6465 6d6c 6961 2f74 7970 6573  t/kademlia/types
    │ │ │ -00076070: 2e68 7070 2667 743b 0a0a 6e61 6d65 7370  .hpp>..namesp
    │ │ │ -00076080: 6163 6520 6c69 6274 6f72 7265 6e74 207b  ace libtorrent {
    │ │ │ -00076090: 0a6e 616d 6573 7061 6365 2064 6874 207b  .namespace dht {
    │ │ │ -000760a0: 0a0a 2f2f 2063 616c 6375 6c61 7465 2074  ..// calculate t
    │ │ │ -000760b0: 6865 2074 6172 6765 7420 6861 7368 2066  he target hash f
    │ │ │ -000760c0: 6f72 2061 6e20 696d 6d75 7461 626c 6520  or an immutable 
    │ │ │ -000760d0: 6974 656d 2e0a 544f 5252 454e 545f 4558  item..TORRENT_EX
    │ │ │ -000760e0: 5452 415f 4558 504f 5254 2073 6861 315f  TRA_EXPORT sha1_
    │ │ │ -000760f0: 6861 7368 2069 7465 6d5f 7461 7267 6574  hash item_target
    │ │ │ -00076100: 5f69 6428 7370 616e 266c 743b 6368 6172  _id(span<char
    │ │ │ -00076110: 2063 6f6e 7374 2667 743b 2076 293b 0a0a   const> v);..
    │ │ │ -00076120: 2f2f 2063 616c 6375 6c61 7465 2074 6865  // calculate the
    │ │ │ -00076130: 2074 6172 6765 7420 6861 7368 2066 6f72   target hash for
    │ │ │ -00076140: 2061 206d 7574 6162 6c65 2069 7465 6d2e   a mutable item.
    │ │ │ -00076150: 0a54 4f52 5245 4e54 5f45 5854 5241 5f45  .TORRENT_EXTRA_E
    │ │ │ -00076160: 5850 4f52 5420 7368 6131 5f68 6173 6820  XPORT sha1_hash 
    │ │ │ -00076170: 6974 656d 5f74 6172 6765 745f 6964 2873  item_target_id(s
    │ │ │ -00076180: 7061 6e26 6c74 3b63 6861 7220 636f 6e73  pan<char cons
    │ │ │ -00076190: 7426 6774 3b20 7361 6c74 0a09 2c20 7075  t> salt.., pu
    │ │ │ -000761a0: 626c 6963 5f6b 6579 2063 6f6e 7374 2661  blic_key const&a
    │ │ │ -000761b0: 6d70 3b20 706b 293b 0a0a 544f 5252 454e  mp; pk);..TORREN
    │ │ │ -000761c0: 545f 4558 5452 415f 4558 504f 5254 2062  T_EXTRA_EXPORT b
    │ │ │ -000761d0: 6f6f 6c20 7665 7269 6679 5f6d 7574 6162  ool verify_mutab
    │ │ │ -000761e0: 6c65 5f69 7465 6d28 0a09 7370 616e 266c  le_item(..span&l
    │ │ │ -000761f0: 743b 6368 6172 2063 6f6e 7374 2667 743b  t;char const>
    │ │ │ -00076200: 2076 0a09 2c20 7370 616e 266c 743b 6368   v.., span<ch
    │ │ │ -00076210: 6172 2063 6f6e 7374 2667 743b 2073 616c  ar const> sal
    │ │ │ -00076220: 740a 092c 2073 6571 7565 6e63 655f 6e75  t.., sequence_nu
    │ │ │ -00076230: 6d62 6572 2073 6571 0a09 2c20 7075 626c  mber seq.., publ
    │ │ │ -00076240: 6963 5f6b 6579 2063 6f6e 7374 2661 6d70  ic_key const&
    │ │ │ -00076250: 3b20 706b 0a09 2c20 7369 676e 6174 7572  ; pk.., signatur
    │ │ │ -00076260: 6520 636f 6e73 7426 616d 703b 2073 6967  e const& sig
    │ │ │ -00076270: 293b 0a0a 3c64 6976 2073 7479 6c65 3d22  );..
    .
    // give │ │ │ -000762b0: 6e20 6120 6279 7465 2072 616e 6765 2060 n a byte range ` │ │ │ -000762c0: 6076 6060 2061 6e64 2061 6e20 6f70 7469 `v`` and an opti │ │ │ -000762d0: 6f6e 616c 2062 7974 6520 7261 6e67 6520 onal byte range │ │ │ -000762e0: 6060 7361 6c74 6060 2c20 610a 2f2f 2073 ``salt``, a.// s │ │ │ -000762f0: 6571 7565 6e63 6520 6e75 6d62 6572 2c20 equence number, │ │ │ -00076300: 7075 626c 6963 206b 6579 2060 6070 6b60 public key ``pk` │ │ │ -00076310: 6020 286d 7573 7420 6265 2033 3220 6279 ` (must be 32 by │ │ │ -00076320: 7465 7329 2061 6e64 2061 2073 6563 7265 tes) and a secre │ │ │ -00076330: 7420 6b65 790a 2f2f 2060 6073 6b60 6020 t key.// ``sk`` │ │ │ -00076340: 286d 7573 7420 6265 2036 3420 6279 7465 (must be 64 byte │ │ │ -00076350: 7329 2c20 7468 6973 2066 756e 6374 696f s), this functio │ │ │ -00076360: 6e20 7072 6f64 7563 6573 2061 2073 6967 n produces a sig │ │ │ -00076370: 6e61 7475 7265 2077 6869 6368 0a2f 2f20 nature which.// │ │ │ -00076380: 6973 2077 7269 7474 656e 2069 6e74 6f20 is written into │ │ │ -00076390: 6120 3634 2062 7974 6520 6275 6666 6572 a 64 byte buffer │ │ │ -000763a0: 2070 6f69 6e74 6564 2074 6f20 6279 2060 pointed to by ` │ │ │ -000763b0: 6073 6967 6060 2e20 5468 6520 6361 6c6c `sig``. The call │ │ │ -000763c0: 6572 0a2f 2f20 6973 2072 6573 706f 6e73 er.// is respons │ │ │ -000763d0: 6962 6c65 2066 6f72 2061 6c6c 6f63 6174 ible for allocat │ │ │ -000763e0: 696e 6720 7468 6520 6465 7374 696e 6174 ing the destinat │ │ │ -000763f0: 696f 6e20 6275 6666 6572 2074 6861 7427 ion buffer that' │ │ │ -00076400: 7320 7061 7373 6564 2069 6e0a 2f2f 2061 s passed in.// a │ │ │ -00076410: 7320 7468 6520 6060 7369 6760 6020 6172 s the ``sig`` ar │ │ │ -00076420: 6775 6d65 6e74 2e20 5479 7069 6361 6c6c gument. Typicall │ │ │ -00076430: 7920 6974 2077 6f75 6c64 2062 6520 616c y it would be al │ │ │ -00076440: 6c6f 6361 7465 6420 6f6e 2074 6865 2073 located on the s │ │ │ -00076450: 7461 636b 2e0a 544f 5252 454e 545f 4558 tack..TORRENT_EX │ │ │ -00076460: 504f 5254 2073 6967 6e61 7475 7265 2073 PORT signature s │ │ │ -00076470: 6967 6e5f 6d75 7461 626c 655f 6974 656d ign_mutable_item │ │ │ -00076480: 280a 0973 7061 6e26 6c74 3b63 6861 7220 (..span<char │ │ │ -00076490: 636f 6e73 7426 6774 3b20 760a 092c 2073 const> v.., s │ │ │ -000764a0: 7061 6e26 6c74 3b63 6861 7220 636f 6e73 pan<char cons │ │ │ -000764b0: 7426 6774 3b20 7361 6c74 0a09 2c20 7365 t> salt.., se │ │ │ -000764c0: 7175 656e 6365 5f6e 756d 6265 7220 7365 quence_number se │ │ │ -000764d0: 710a 092c 2070 7562 6c69 635f 6b65 7920 q.., public_key │ │ │ -000764e0: 636f 6e73 7426 616d 703b 2070 6b0a 092c const& pk.., │ │ │ -000764f0: 2073 6563 7265 745f 6b65 7920 636f 6e73 secret_key cons │ │ │ -00076500: 7426 616d 703b 2073 6b29 3b0a 0a63 6c61 t& sk);..cla │ │ │ -00076510: 7373 2054 4f52 5245 4e54 5f45 5854 5241 ss TORRENT_EXTRA │ │ │ -00076520: 5f45 5850 4f52 5420 6974 656d 0a7b 0a70 _EXPORT item.{.p │ │ │ -00076530: 7562 6c69 633a 0a09 6974 656d 2829 207b ublic:..item() { │ │ │ -00076540: 7d0a 0969 7465 6d28 7075 626c 6963 5f6b }..item(public_k │ │ │ -00076550: 6579 2063 6f6e 7374 2661 6d70 3b20 706b ey const& pk │ │ │ -00076560: 2c20 7370 616e 266c 743b 6368 6172 2063 , span<char c │ │ │ -00076570: 6f6e 7374 2667 743b 2073 616c 7429 3b0a onst> salt);. │ │ │ -00076580: 0965 7870 6c69 6369 7420 6974 656d 2865 .explicit item(e │ │ │ -00076590: 6e74 7279 2076 293b 0a09 6974 656d 2865 ntry v);..item(e │ │ │ -000765a0: 6e74 7279 2076 0a09 092c 2073 7061 6e26 ntry v..., span& │ │ │ -000765b0: 6c74 3b63 6861 7220 636f 6e73 7426 6774 lt;char const> │ │ │ -000765c0: 3b20 7361 6c74 0a09 092c 2073 6571 7565 ; salt..., seque │ │ │ -000765d0: 6e63 655f 6e75 6d62 6572 2073 6571 0a09 nce_number seq.. │ │ │ -000765e0: 092c 2070 7562 6c69 635f 6b65 7920 636f ., public_key co │ │ │ -000765f0: 6e73 7426 616d 703b 2070 6b0a 0909 2c20 nst& pk..., │ │ │ -00076600: 7365 6372 6574 5f6b 6579 2063 6f6e 7374 secret_key const │ │ │ -00076610: 2661 6d70 3b20 736b 293b 0a09 6578 706c & sk);..expl │ │ │ -00076620: 6963 6974 2069 7465 6d28 6264 6563 6f64 icit item(bdecod │ │ │ -00076630: 655f 6e6f 6465 2063 6f6e 7374 2661 6d70 e_node const& │ │ │ -00076640: 3b20 7629 3b0a 0a09 766f 6964 2061 7373 ; v);...void ass │ │ │ -00076650: 6967 6e28 656e 7472 7920 7629 3b0a 0976 ign(entry v);..v │ │ │ -00076660: 6f69 6420 6173 7369 676e 2865 6e74 7279 oid assign(entry │ │ │ -00076670: 2076 2c20 7370 616e 266c 743b 6368 6172 v, span<char │ │ │ -00076680: 2063 6f6e 7374 2667 743b 2073 616c 740a const> salt. │ │ │ -00076690: 0909 2c20 7365 7175 656e 6365 5f6e 756d .., sequence_num │ │ │ -000766a0: 6265 7220 7365 710a 0909 2c20 7075 626c ber seq..., publ │ │ │ -000766b0: 6963 5f6b 6579 2063 6f6e 7374 2661 6d70 ic_key const& │ │ │ -000766c0: 3b20 706b 0a3c 2f70 7265 3e3c 2f74 643e ; pk.
    │ │ │ -000766d0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00076700: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00076710: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00076720: 7074 3a65 7870 616e 6428 3236 3929 223e pt:expand(269)"> │ │ │ -00076730: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -00076740: 7272 656e 742f 6175 785f 2f68 6173 685f rrent/aux_/hash_ │ │ │ -00076750: 7069 636b 6572 2e68 7070 3a31 3333 3c2f picker.hpp:133suppo │ │ │ -00076770: 7274 2062 6174 6368 6564 2061 6464 696e rt batched addin │ │ │ -00076780: 6720 6f66 2062 6c6f 636b 2068 6173 6865 g of block hashe │ │ │ -00076790: 7320 666f 7220 7265 6475 6365 6420 6f76 s for reduced ov │ │ │ -000767a0: 6572 6865 6164 3f3c 2f74 643e 3c2f 7472 erhead?

    support bat │ │ │ -00076800: 6368 6564 2061 6464 696e 6720 6f66 2062 ched adding of b │ │ │ -00076810: 6c6f 636b 2068 6173 6865 7320 666f 7220 lock hashes for │ │ │ -00076820: 7265 6475 6365 6420 6f76 6572 6865 6164 reduced overhead │ │ │ -00076830: 3f3c 2f68 323e 3c68 343e 2e2e 2f69 6e63 ?

    ../inc │ │ │ -00076840: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -00076850: 6175 785f 2f68 6173 685f 7069 636b 6572 aux_/hash_picker │ │ │ -00076860: 2e68 7070 3a31 3333 3c2f 6834 3e3c 7072 .hpp:133

    ..// the │ │ │ -000768b0: 6e75 6d62 6572 206f 6620 6861 7368 6573 number of hashes │ │ │ -000768c0: 2069 6e20 7468 6520 7261 6e67 650a 0909 in the range... │ │ │ -000768d0: 696e 7420 636f 756e 7420 3d20 303b 0a09 int count = 0;.. │ │ │ -000768e0: 0969 6e74 2070 726f 6f66 5f6c 6179 6572 .int proof_layer │ │ │ -000768f0: 7320 3d20 303b 0a09 7d3b 0a0a 092f 2f20 s = 0;..};...// │ │ │ -00076900: 7661 6c69 6461 7465 7320 7468 6520 6861 validates the ha │ │ │ -00076910: 7368 5f72 6571 7565 7374 2c20 746f 2065 sh_request, to e │ │ │ -00076920: 6e73 7572 6520 6974 7320 696e 7661 7269 nsure its invari │ │ │ -00076930: 616e 7420 6173 2077 656c 6c20 6173 206d ant as well as m │ │ │ -00076940: 6174 6368 696e 670a 092f 2f20 7468 6520 atching..// the │ │ │ -00076950: 746f 7272 656e 7427 7320 6669 6c65 5f73 torrent's file_s │ │ │ -00076960: 746f 7261 6765 2061 6e64 2074 6865 206e torage and the n │ │ │ -00076970: 756d 6265 7220 6f66 2068 6173 6865 7320 umber of hashes │ │ │ -00076980: 6163 636f 6d70 616e 7969 6e67 2074 6865 accompanying the │ │ │ -00076990: 0a09 2f2f 2072 6571 7565 7374 0a09 544f ..// request..TO │ │ │ -000769a0: 5252 454e 545f 4558 5452 415f 4558 504f RRENT_EXTRA_EXPO │ │ │ -000769b0: 5254 0a09 626f 6f6c 2076 616c 6964 6174 RT..bool validat │ │ │ -000769c0: 655f 6861 7368 5f72 6571 7565 7374 2868 e_hash_request(h │ │ │ -000769d0: 6173 685f 7265 7175 6573 7420 636f 6e73 ash_request cons │ │ │ -000769e0: 7426 616d 703b 2068 722c 2066 696c 655f t& hr, file_ │ │ │ -000769f0: 7374 6f72 6167 6520 636f 6e73 7426 616d storage const&am │ │ │ -00076a00: 703b 2066 7329 3b0a 0a09 636c 6173 7320 p; fs);...class │ │ │ -00076a10: 544f 5252 454e 545f 4558 5452 415f 4558 TORRENT_EXTRA_EX │ │ │ -00076a20: 504f 5254 2068 6173 685f 7069 636b 6572 PORT hash_picker │ │ │ -00076a30: 0a09 7b0a 0970 7562 6c69 633a 0a09 0968 ..{..public:...h │ │ │ -00076a40: 6173 685f 7069 636b 6572 2866 696c 655f ash_picker(file_ │ │ │ -00076a50: 7374 6f72 6167 6520 636f 6e73 7426 616d storage const&am │ │ │ -00076a60: 703b 2066 696c 6573 0a09 0909 2c20 6175 p; files...., au │ │ │ -00076a70: 783a 3a76 6563 746f 7226 6c74 3b61 7578 x::vector<aux │ │ │ -00076a80: 3a3a 6d65 726b 6c65 5f74 7265 652c 2066 ::merkle_tree, f │ │ │ -00076a90: 696c 655f 696e 6465 785f 7426 6774 3b26 ile_index_t>& │ │ │ -00076aa0: 616d 703b 2074 7265 6573 293b 0a0a 0909 amp; trees);.... │ │ │ -00076ab0: 6861 7368 5f72 6571 7565 7374 2070 6963 hash_request pic │ │ │ -00076ac0: 6b5f 6861 7368 6573 2874 7970 6564 5f62 k_hashes(typed_b │ │ │ -00076ad0: 6974 6669 656c 6426 6c74 3b70 6965 6365 itfield<piece │ │ │ -00076ae0: 5f69 6e64 6578 5f74 2667 743b 2063 6f6e _index_t> con │ │ │ -00076af0: 7374 2661 6d70 3b20 7069 6563 6573 293b st& pieces); │ │ │ -00076b00: 0a0a 0909 6164 645f 6861 7368 6573 5f72 ....add_hashes_r │ │ │ -00076b10: 6573 756c 7420 6164 645f 6861 7368 6573 esult add_hashes │ │ │ -00076b20: 2868 6173 685f 7265 7175 6573 7420 636f (hash_request co │ │ │ -00076b30: 6e73 7426 616d 703b 2072 6571 2c20 7370 nst& req, sp │ │ │ -00076b40: 616e 266c 743b 7368 6132 3536 5f68 6173 an<sha256_has │ │ │ -00076b50: 6820 636f 6e73 7426 6774 3b20 6861 7368 h const> hash │ │ │ -00076b60: 6573 293b 0a3c 6469 7620 7374 796c 653d es);.
    ..set_block_h │ │ │ -00076ba0: 6173 685f 7265 7375 6c74 2073 6574 5f62 ash_result set_b │ │ │ -00076bb0: 6c6f 636b 5f68 6173 6828 7069 6563 655f lock_hash(piece_ │ │ │ -00076bc0: 696e 6465 785f 7420 7069 6563 652c 2069 index_t piece, i │ │ │ -00076bd0: 6e74 206f 6666 7365 742c 2073 6861 3235 nt offset, sha25 │ │ │ -00076be0: 365f 6861 7368 2063 6f6e 7374 2661 6d70 6_hash const& │ │ │ -00076bf0: 3b20 6829 3b0a 3c2f 6469 763e 0909 766f ; h);.
    ..vo │ │ │ -00076c00: 6964 2068 6173 6865 735f 7265 6a65 6374 id hashes_reject │ │ │ -00076c10: 6564 2868 6173 685f 7265 7175 6573 7420 ed(hash_request │ │ │ -00076c20: 636f 6e73 7426 616d 703b 2072 6571 293b const& req); │ │ │ -00076c30: 0a09 0976 6f69 6420 7665 7269 6679 5f62 ...void verify_b │ │ │ -00076c40: 6c6f 636b 5f68 6173 6865 7328 7069 6563 lock_hashes(piec │ │ │ -00076c50: 655f 696e 6465 785f 7420 696e 6465 7829 e_index_t index) │ │ │ -00076c60: 3b0a 0a09 092f 2f20 646f 2077 6520 6b6e ;....// do we kn │ │ │ -00076c70: 6f77 2074 6865 2070 6965 6365 206c 6179 ow the piece lay │ │ │ -00076c80: 6572 2068 6173 6820 666f 7220 6120 7069 er hash for a pi │ │ │ -00076c90: 6563 650a 0909 626f 6f6c 2068 6176 655f ece...bool have_ │ │ │ -00076ca0: 6861 7368 2870 6965 6365 5f69 6e64 6578 hash(piece_index │ │ │ -00076cb0: 5f74 2069 6e64 6578 2920 636f 6e73 743b _t index) const; │ │ │ -00076cc0: 0a09 092f 2f20 646f 2077 6520 6b6e 6f77 ...// do we know │ │ │ -00076cd0: 2061 6c6c 2074 6865 2062 6c6f 636b 2068 all the block h │ │ │ -00076ce0: 6173 6865 7320 666f 7220 6120 6669 6c65 ashes for a file │ │ │ -00076cf0: 3f0a 0909 626f 6f6c 2068 6176 655f 616c ?...bool have_al │ │ │ -00076d00: 6c28 6669 6c65 5f69 6e64 6578 5f74 2066 l(file_index_t f │ │ │ -00076d10: 696c 6529 2063 6f6e 7374 3b0a 0909 626f ile) const;...bo │ │ │ -00076d20: 6f6c 2068 6176 655f 616c 6c28 2920 636f ol have_all() co │ │ │ -00076d30: 6e73 743b 0a09 0962 6f6f 6c20 7069 6563 nst;...bool piec │ │ │ -00076d40: 655f 7665 7269 6669 6564 2870 6965 6365 e_verified(piece │ │ │ -00076d50: 5f69 6e64 6578 5f74 2070 6965 6365 2920 _index_t piece) │ │ │ -00076d60: 636f 6e73 743b 0a0a 0909 696e 7420 7069 const;....int pi │ │ │ -00076d70: 6563 655f 6c61 7965 7228 2920 636f 6e73 ece_layer() cons │ │ │ -00076d80: 7420 7b20 7265 7475 726e 206d 5f70 6965 t { return m_pie │ │ │ -00076d90: 6365 5f6c 6179 6572 3b20 7d0a 0a09 7072 ce_layer; }...pr │ │ │ -00076da0: 6976 6174 653a 0a09 092f 2f20 7265 7475 ivate:...// retu │ │ │ -00076db0: 726e 7320 7468 6520 6e75 6d62 6572 206f rns the number o │ │ │ -00076dc0: 6620 7072 6f6f 6620 6c61 7965 7273 206e f proof layers n │ │ │ -00076dd0: 6565 6465 6420 746f 2076 6572 6966 7920 eeded to verify │ │ │ -00076de0: 7468 6520 6e6f 6465 2773 2068 6173 680a the node's hash. │ │ │ -00076df0: 0909 696e 7420 6c61 7965 7273 5f74 6f5f ..int layers_to_ │ │ │ -00076e00: 7665 7269 6679 286e 6f64 655f 696e 6465 verify(node_inde │ │ │ -00076e10: 7820 6964 7829 2063 6f6e 7374 3b0a 0909 x idx) const;... │ │ │ -00076e20: 696e 7420 6669 6c65 5f6e 756d 5f6c 6179 int file_num_lay │ │ │ -00076e30: 6572 7328 6669 6c65 5f69 6e64 6578 5f74 ers(file_index_t │ │ │ -00076e40: 2069 6478 2920 636f 6e73 743b 0a0a 0909 idx) const;.... │ │ │ -00076e50: 2f2f 2061 2072 6571 7565 7374 206d 7573 // a request mus │ │ │ -00076e60: 7420 6d61 7463 6820 6f6e 6520 6f66 2068 t match one of h │ │ │ -00076e70: 6173 685f 7069 636b 6572 2773 2074 776f ash_picker's two │ │ │ -00076e80: 206b 6e6f 776e 2073 6861 7065 733a 2061 known shapes: a │ │ │ -00076e90: 0a09 092f 2f20 3531 322d 7069 6563 6520 ...// 512-piece │ │ │ -00076ea0: 6368 756e 6b20 616c 6967 6e65 6420 746f chunk aligned to │ │ │ -00076eb0: 2074 6865 2070 6965 6365 206c 6179 6572 the piece layer │ │ │ -00076ec0: 2c20 6f72 206f 6e65 2077 686f 6c65 2070 , or one whole p │ │ │ -00076ed0: 6965 6365 2773 0a09 092f 2f20 626c 6f63 iece's...// bloc │ │ │ -00076ee0: 6b20 6861 7368 6573 2e20 5768 656e 2062 k hashes. When b │ │ │ -00076ef0: 6c6f 636b 735f 7065 725f 7069 6563 6520 locks_per_piece │ │ │ -00076f00: 3d3d 2031 2c20 6d5f 7069 6563 655f 6c61 == 1, m_piece_la │ │ │ -00076f10: 7965 7220 3d3d 2030 2c20 736f 0a09 092f yer == 0, so.../ │ │ │ -00076f20: 2f20 626f 7468 2073 6861 7065 7320 6861 / both shapes ha │ │ │ -00076f30: 7665 2072 6571 2e62 6173 6520 3d3d 2030 ve req.base == 0 │ │ │ -00076f40: 2061 6e64 2061 2073 696e 676c 6520 7265 and a single re │ │ │ -00076f50: 7175 6573 7420 6361 6e20 7361 7469 7366 quest can satisf │ │ │ -00076f60: 790a 0909 2f2f 2062 6f74 6820 6174 206f y...// both at o │ │ │ -00076f70: 6e63 653b 2074 6865 2074 776f 2061 7265 nce; the two are │ │ │ -00076f80: 2074 6865 7265 666f 7265 2063 6865 636b therefore check │ │ │ -00076f90: 6564 2069 6e64 6570 656e 6465 6e74 6c79 ed independently │ │ │ -00076fa0: 2072 6174 6865 720a 0909 2f2f 2074 6861 rather...// tha │ │ │ -00076fb0: 6e20 6f6e 6520 6265 696e 6720 6465 7269 n one being deri │ │ │ -00076fc0: 7665 6420 6672 6f6d 2072 6571 2e62 6173 ved from req.bas │ │ │ -00076fd0: 652e 0a09 0962 6f6f 6c20 6d61 7463 6865 e....bool matche │ │ │ -00076fe0: 735f 7069 6563 655f 6c61 7965 725f 7265 s_piece_layer_re │ │ │ -00076ff0: 7175 6573 7428 6861 7368 5f72 6571 7565 quest(hash_reque │ │ │ -00077000: 7374 2063 6f6e 7374 2661 6d70 3b20 7265 st const& re │ │ │ -00077010: 7129 2063 6f6e 7374 3b0a 0909 626f 6f6c q) const;...bool │ │ │ -00077020: 206d 6174 6368 6573 5f62 6c6f 636b 5f72 matches_block_r │ │ │ -00077030: 6571 7565 7374 2868 6173 685f 7265 7175 equest(hash_requ │ │ │ -00077040: 6573 7420 636f 6e73 7426 616d 703b 2072 est const& r │ │ │ -00077050: 6571 2920 636f 6e73 743b 0a0a 0909 7374 eq) const;....st │ │ │ -00077060: 7275 6374 2070 6965 6365 5f68 6173 685f ruct piece_hash_ │ │ │ -00077070: 7265 7175 6573 740a 0909 7b0a 0909 0974 request...{....t │ │ │ -00077080: 696d 655f 706f 696e 7420 6c61 7374 5f72 ime_point last_r │ │ │ -00077090: 6571 7565 7374 203d 206d 696e 5f74 696d equest = min_tim │ │ │ -000770a0: 6528 293b 0a09 0909 696e 7420 6e75 6d5f e();....int num_ │ │ │ -000770b0: 7265 7175 6573 7473 203d 2030 3b0a 3c2f requests = 0;.r │ │ │ -000770f0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -00077100: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../incl │ │ │ -00077130: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -00077140: 7578 5f2f 7065 6572 2e68 7070 3a34 373c ux_/peer.hpp:47< │ │ │ -00077150: 2f61 3e3c 2f74 643e 3c74 643e 6974 2073 /a>it s │ │ │ -00077160: 6565 6d73 2075 6e6e 6563 6573 7361 7279 eems unnecessary │ │ │ -00077170: 2074 6f20 7772 6170 2074 6869 7320 6932 to wrap this i2 │ │ │ -00077180: 7020 6164 6472 6573 7320 696e 2061 2073 p address in a s │ │ │ -00077190: 7472 7563 743c 2f74 643e 3c2f 7472 3e3c truct< │ │ │ -000771a0: 7472 2069 643d 2232 3730 2220 7374 796c tr id="270" styl │ │ │ -000771b0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -000771c0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -000771d0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -000771e0: 6832 3e69 7420 7365 656d 7320 756e 6e65 h2>it seems unne │ │ │ -000771f0: 6365 7373 6172 7920 746f 2077 7261 7020 cessary to wrap │ │ │ -00077200: 7468 6973 2069 3270 2061 6464 7265 7373 this i2p address │ │ │ -00077210: 2069 6e20 6120 7374 7275 6374 3c2f 6832 in a struct

    ../include/ │ │ │ -00077230: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -00077240: 7065 6572 2e68 7070 3a34 373c 2f68 343e peer.hpp:47

    │ │ │ -00077250: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..bool
    │ │ │ -00077290: 206f 7065 7261 746f 723d 3d28 636f 6e73   operator==(cons
    │ │ │ -000772a0: 7420 7065 6572 5f65 6e74 7279 2661 6d70  t peer_entry&
    │ │ │ -000772b0: 3b20 7029 2063 6f6e 7374 0a09 097b 2072  ; p) const...{ r
    │ │ │ -000772c0: 6574 7572 6e20 7069 6420 3d3d 2070 2e70  eturn pid == p.p
    │ │ │ -000772d0: 6964 3b20 7d0a 0a09 0962 6f6f 6c20 6f70  id; }....bool op
    │ │ │ -000772e0: 6572 6174 6f72 266c 743b 2863 6f6e 7374  erator<(const
    │ │ │ -000772f0: 2070 6565 725f 656e 7472 7926 616d 703b   peer_entry&
    │ │ │ -00077300: 2070 2920 636f 6e73 740a 0909 7b20 7265   p) const...{ re
    │ │ │ -00077310: 7475 726e 2070 6964 2026 6c74 3b20 702e  turn pid < p.
    │ │ │ -00077320: 7069 643b 207d 0a09 7d3b 0a0a 0973 7472  pid; }..};...str
    │ │ │ -00077330: 7563 7420 6970 7634 5f70 6565 725f 656e  uct ipv4_peer_en
    │ │ │ -00077340: 7472 790a 097b 0a09 0961 6464 7265 7373  try..{...address
    │ │ │ -00077350: 5f76 343a 3a62 7974 6573 5f74 7970 6520  _v4::bytes_type 
    │ │ │ -00077360: 6970 3b0a 0909 7374 643a 3a75 696e 7431  ip;...std::uint1
    │ │ │ -00077370: 365f 7420 706f 7274 3b0a 097d 3b0a 0a09  6_t port;..};...
    │ │ │ -00077380: 7374 7275 6374 2069 7076 365f 7065 6572  struct ipv6_peer
    │ │ │ -00077390: 5f65 6e74 7279 0a09 7b0a 0909 6164 6472  _entry..{...addr
    │ │ │ -000773a0: 6573 735f 7636 3a3a 6279 7465 735f 7479  ess_v6::bytes_ty
    │ │ │ -000773b0: 7065 2069 703b 0a09 0973 7464 3a3a 7569  pe ip;...std::ui
    │ │ │ -000773c0: 6e74 3136 5f74 2070 6f72 743b 0a09 7d3b  nt16_t port;..};
    │ │ │ -000773d0: 0a0a 2369 6620 544f 5252 454e 545f 5553  ..#if TORRENT_US
    │ │ │ -000773e0: 455f 4932 500a 3c64 6976 2073 7479 6c65  E_I2P.
    .struct i2p_ │ │ │ -00077420: 7065 6572 5f65 6e74 7279 0a3c 2f64 6976 peer_entry.
    .{...sha256_has │ │ │ -00077440: 6820 6465 7374 696e 6174 696f 6e3b 0a09 h destination;.. │ │ │ -00077450: 7d3b 0a23 656e 6469 660a 7d0a 0a23 656e };.#endif.}..#en │ │ │ -00077460: 6469 6620 2f2f 2054 4f52 5245 4e54 5f50 dif // TORRENT_P │ │ │ -00077470: 4545 525f 4850 505f 494e 434c 5544 4544 EER_HPP_INCLUDED │ │ │ -00077480: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ -000774c0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0
    ../i │ │ │ -000774f0: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -00077500: 742f 6175 785f 2f73 6573 7369 6f6e 5f69 t/aux_/session_i │ │ │ -00077510: 6d70 6c2e 6870 703a 3234 333c 2f61 3e3c mpl.hpp:243< │ │ │ -00077520: 2f74 643e 3c74 643e 6d61 6b65 2074 6865 /td>make the │ │ │ -00077530: 7365 2064 6972 6563 7420 6d65 6d62 6572 se direct member │ │ │ -00077540: 7320 616e 6420 6765 6e65 7261 7465 2073 s and generate s │ │ │ -00077550: 6861 7265 645f 7074 7273 2074 6f20 7468 hared_ptrs to th │ │ │ -00077560: 656d 2077 6869 6368 2061 6c69 6173 2074 em which alias t │ │ │ -00077570: 6865 206c 6973 7465 6e5f 736f 636b 6574 he listen_socket │ │ │ -00077580: 5f74 2073 6861 7265 645f 7074 723c 2f74 _t shared_ptr

    make │ │ │ -000775e0: 7468 6573 6520 6469 7265 6374 206d 656d these direct mem │ │ │ -000775f0: 6265 7273 2061 6e64 2067 656e 6572 6174 bers and generat │ │ │ -00077600: 6520 7368 6172 6564 5f70 7472 7320 746f e shared_ptrs to │ │ │ -00077610: 2074 6865 6d0a 7768 6963 6820 616c 6961 them.which alia │ │ │ -00077620: 7320 7468 6520 6c69 7374 656e 5f73 6f63 s the listen_soc │ │ │ -00077630: 6b65 745f 7420 7368 6172 6564 5f70 7472 ket_t shared_ptr │ │ │ -00077640: 3c2f 6832 3e3c 6834 3e2e 2e2f 696e 636c

    ../incl │ │ │ -00077650: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -00077660: 7578 5f2f 7365 7373 696f 6e5f 696d 706c ux_/session_impl │ │ │ -00077670: 2e68 7070 3a32 3433 3c2f 6834 3e3c 7072 .hpp:243

    ...if (ud │ │ │ -000776c0: 705f 736f 636b 2920 7265 7475 726e 2075 p_sock) return u │ │ │ -000776d0: 6470 5f73 6f63 6b2d 2667 743b 736f 636b dp_sock->sock │ │ │ -000776e0: 2e6c 6f63 616c 5f70 6f72 7428 293b 0a09 .local_port();.. │ │ │ -000776f0: 0909 7265 7475 726e 2030 3b0a 0909 7d0a ..return 0;...}. │ │ │ -00077700: 0a09 092f 2f20 3020 6973 206e 6174 706d ...// 0 is natpm │ │ │ -00077710: 7020 3120 6973 2075 706e 700a 0909 2f2f p 1 is upnp...// │ │ │ -00077720: 2074 6865 206f 7264 6572 206f 6620 7468 the order of th │ │ │ -00077730: 6573 6520 6172 7261 7973 2064 6574 6572 ese arrays deter │ │ │ -00077740: 6d69 6e65 7320 7468 6520 7072 696f 7269 mines the priori │ │ │ -00077750: 7479 2069 6e0a 0909 2f2f 2077 6869 6368 ty in...// which │ │ │ -00077760: 2074 6865 6972 2070 6f72 7473 2077 696c their ports wil │ │ │ -00077770: 6c20 6265 2061 6e6e 6f75 6e63 6564 2074 l be announced t │ │ │ -00077780: 6f20 7065 6572 730a 0909 6175 783a 3a61 o peers...aux::a │ │ │ -00077790: 7272 6179 266c 743b 6c69 7374 656e 5f70 rray<listen_p │ │ │ -000777a0: 6f72 745f 6d61 7070 696e 672c 2032 2c20 ort_mapping, 2, │ │ │ -000777b0: 706f 7274 6d61 705f 7472 616e 7370 6f72 portmap_transpor │ │ │ -000777c0: 7426 6774 3b20 7463 705f 706f 7274 5f6d t> tcp_port_m │ │ │ -000777d0: 6170 7069 6e67 3b0a 0909 6175 783a 3a61 apping;...aux::a │ │ │ -000777e0: 7272 6179 266c 743b 6c69 7374 656e 5f70 rray<listen_p │ │ │ -000777f0: 6f72 745f 6d61 7070 696e 672c 2032 2c20 ort_mapping, 2, │ │ │ -00077800: 706f 7274 6d61 705f 7472 616e 7370 6f72 portmap_transpor │ │ │ -00077810: 7426 6774 3b20 7564 705f 706f 7274 5f6d t> udp_port_m │ │ │ -00077820: 6170 7069 6e67 3b0a 0a09 092f 2f20 696e apping;....// in │ │ │ -00077830: 6469 6361 7465 7320 7768 6574 6865 7220 dicates whether │ │ │ -00077840: 7468 6973 2069 7320 616e 2053 534c 206c this is an SSL l │ │ │ -00077850: 6973 7465 6e20 736f 636b 6574 206f 7220 isten socket or │ │ │ -00077860: 6e6f 740a 0909 7472 616e 7370 6f72 7420 not...transport │ │ │ -00077870: 7373 6c20 3d20 7472 616e 7370 6f72 743a ssl = transport: │ │ │ -00077880: 3a70 6c61 696e 7465 7874 3b0a 0a09 096c :plaintext;....l │ │ │ -00077890: 6973 7465 6e5f 736f 636b 6574 5f66 6c61 isten_socket_fla │ │ │ -000778a0: 6773 5f74 2066 6c61 6773 203d 2061 6363 gs_t flags = acc │ │ │ -000778b0: 6570 745f 696e 636f 6d69 6e67 3b0a 0a09 ept_incoming;... │ │ │ -000778c0: 092f 2f20 7468 6520 6163 7475 616c 2073 .// the actual s │ │ │ -000778d0: 6f63 6b65 7473 2028 5443 5020 6c69 7374 ockets (TCP list │ │ │ -000778e0: 656e 2073 6f63 6b65 7420 616e 6420 5544 en socket and UD │ │ │ -000778f0: 5020 736f 636b 6574 290a 0909 2f2f 2041 P socket)...// A │ │ │ -00077900: 6e20 656e 7472 7920 646f 6573 206e 6f74 n entry does not │ │ │ -00077910: 206e 6563 6573 7361 7269 6c79 2068 6176 necessarily hav │ │ │ -00077920: 6520 6120 5544 5020 6f72 2054 4350 2073 e a UDP or TCP s │ │ │ -00077930: 6f63 6b65 742e 204f 6e65 206f 6620 7468 ocket. One of th │ │ │ -00077940: 6573 650a 0909 2f2f 2070 6f69 6e74 6572 ese...// pointer │ │ │ -00077950: 7320 6d61 7920 6265 206e 756c 6c70 7472 s may be nullptr │ │ │ -00077960: 210a 0909 2f2f 2054 6865 7365 206d 7573 !...// These mus │ │ │ -00077970: 7420 6265 2073 6861 7265 645f 7074 7220 t be shared_ptr │ │ │ -00077980: 746f 2061 766f 6964 2061 2064 616e 676c to avoid a dangl │ │ │ -00077990: 696e 6720 7265 6665 7265 6e63 6520 6966 ing reference if │ │ │ -000779a0: 2061 6e0a 0909 2f2f 2069 6e63 6f6d 696e an...// incomin │ │ │ -000779b0: 6720 7061 636b 6574 2069 7320 696e 2074 g packet is in t │ │ │ -000779c0: 6865 2065 7665 6e74 2071 7565 7565 2077 he event queue w │ │ │ -000779d0: 6865 6e20 7468 6520 736f 636b 6574 2069 hen the socket i │ │ │ -000779e0: 7320 6572 6173 6564 0a3c 6469 7620 7374 s erased.
    ..std::sh │ │ │ -00077a20: 6172 6564 5f70 7472 266c 743b 7463 703a ared_ptr<tcp: │ │ │ -00077a30: 3a61 6363 6570 746f 7226 6774 3b20 736f :acceptor> so │ │ │ -00077a40: 636b 3b0a 3c2f 6469 763e 0909 7374 643a ck;.
    ..std: │ │ │ -00077a50: 3a73 6861 7265 645f 7074 7226 6c74 3b61 :shared_ptr<a │ │ │ -00077a60: 7578 3a3a 7365 7373 696f 6e5f 7564 705f ux::session_udp_ │ │ │ -00077a70: 736f 636b 6574 2667 743b 2075 6470 5f73 socket> udp_s │ │ │ -00077a80: 6f63 6b3b 0a0a 0909 2f2f 2073 696e 6365 ock;....// since │ │ │ -00077a90: 2075 6470 2070 6163 6b65 7473 2061 7265 udp packets are │ │ │ -00077aa0: 2065 7870 6563 7465 6420 746f 2062 6520 expected to be │ │ │ -00077ab0: 6469 7370 6174 6368 6564 2066 7265 7175 dispatched frequ │ │ │ -00077ac0: 656e 746c 792c 2074 6869 7320 7361 7665 ently, this save │ │ │ -00077ad0: 730a 0909 2f2f 2074 696d 6520 6f6e 2068 s...// time on h │ │ │ -00077ae0: 616e 646c 6572 2061 6c6c 6f63 6174 696f andler allocatio │ │ │ -00077af0: 6e20 6576 6572 7920 7469 6d65 2077 6520 n every time we │ │ │ -00077b00: 7265 6164 2061 6761 696e 2e0a 0909 6175 read again....au │ │ │ -00077b10: 783a 3a68 616e 646c 6572 5f73 746f 7261 x::handler_stora │ │ │ -00077b20: 6765 266c 743b 6175 783a 3a75 6470 5f68 ge<aux::udp_h │ │ │ -00077b30: 616e 646c 6572 5f6d 6178 5f73 697a 652c andler_max_size, │ │ │ -00077b40: 2061 7578 3a3a 7564 705f 6861 6e64 6c65 aux::udp_handle │ │ │ -00077b50: 7226 6774 3b20 7564 705f 6861 6e64 6c65 r> udp_handle │ │ │ -00077b60: 725f 7374 6f72 6167 653b 0a0a 0909 7374 r_storage;....st │ │ │ -00077b70: 643a 3a73 6861 7265 645f 7074 7226 6c74 d::shared_ptr< │ │ │ -00077b80: 3b6e 6174 706d 7026 6774 3b20 6e61 7470 ;natpmp> natp │ │ │ -00077b90: 6d70 5f6d 6170 7065 723b 0a09 0973 7464 mp_mapper;...std │ │ │ -00077ba0: 3a3a 7368 6172 6564 5f70 7472 266c 743b ::shared_ptr< │ │ │ -00077bb0: 7570 6e70 2667 743b 2075 706e 705f 6d61 upnp> upnp_ma │ │ │ -00077bc0: 7070 6572 3b0a 0a09 0973 7464 3a3a 7368 pper;....std::sh │ │ │ -00077bd0: 6172 6564 5f70 7472 266c 743b 7374 7275 ared_ptr<stru │ │ │ -00077be0: 6374 206c 7364 2667 743b 206c 7364 3b0a ct lsd> lsd;. │ │ │ -00077bf0: 0a09 092f 2f20 7365 7420 746f 2074 7275 ...// set to tru │ │ │ -00077c00: 6520 7768 656e 2077 6520 7265 6365 6976 e when we receiv │ │ │ -00077c10: 6520 616e 2069 6e63 6f6d 696e 6720 636f e an incoming co │ │ │ -00077c20: 6e6e 6563 7469 6f6e 2066 726f 6d20 7468 nnection from th │ │ │ -00077c30: 6973 206c 6973 7465 6e0a 0909 2f2f 2073 is listen...// s │ │ │ -00077c40: 6f63 6b65 740a 0909 626f 6f6c 2069 6e63 ocket...bool inc │ │ │ -00077c50: 6f6d 696e 675f 636f 6e6e 6563 7469 6f6e oming_connection │ │ │ -00077c60: 203d 2066 616c 7365 3b0a 0a09 7072 6976 = false;...priv │ │ │ -00077c70: 6174 653a 0a09 092f 2f20 6e6f 6e2d 6174 ate:...// non-at │ │ │ -00077c80: 6f6d 6963 2069 7320 6669 6e65 3a20 6c69 omic is fine: li │ │ │ -00077c90: 7374 656e 5f73 6f63 6b65 745f 7420 6973 sten_socket_t is │ │ │ -00077ca0: 206f 6e6c 7920 6576 6572 2063 6f6e 7374 only ever const │ │ │ -00077cb0: 7275 6374 6564 206f 6e0a 0909 2f2f 2074 ructed on...// t │ │ │ -00077cc0: 6865 206e 6574 776f 726b 2074 6872 6561 he network threa │ │ │ -00077cd0: 642e 0a09 0973 7461 7469 6320 7374 643a d....static std: │ │ │ -00077ce0: 3a75 696e 7433 325f 7420 6e65 7874 5f69 :uint32_t next_i │ │ │ -00077cf0: 6428 290a 0909 7b0a 0909 0973 7461 7469 d()...{....stati │ │ │ -00077d00: 6320 7374 643a 3a75 696e 7433 325f 7420 c std::uint32_t │ │ │ -00077d10: 6e65 7874 203d 2030 3b0a 0909 0972 6574 next = 0;....ret │ │ │ -00077d20: 7572 6e20 2b2b 6e65 7874 3b0a 0909 7d0a urn ++next;...}. │ │ │ -00077d30: 097d 3b0a 0a09 0973 7472 7563 7420 544f .};....struct TO │ │ │ -00077d40: 5252 454e 545f 4558 5452 415f 4558 504f RRENT_EXTRA_EXPO │ │ │ -00077d50: 5254 206c 6973 7465 6e5f 656e 6470 6f69 RT listen_endpoi │ │ │ -00077d60: 6e74 5f74 0a09 097b 0a09 0909 6c69 7374 nt_t...{....list │ │ │ -00077d70: 656e 5f65 6e64 706f 696e 745f 7428 6164 en_endpoint_t(ad │ │ │ -00077d80: 6472 6573 7320 636f 6e73 7426 616d 703b dress const& │ │ │ -00077d90: 2061 6472 2c20 696e 7420 702c 2073 7464 adr, int p, std │ │ │ -00077da0: 3a3a 7374 7269 6e67 2064 6576 2c20 7472 ::string dev, tr │ │ │ -00077db0: 616e 7370 6f72 7420 730a 0909 0909 2c20 ansport s....., │ │ │ -00077dc0: 6c69 7374 656e 5f73 6f63 6b65 745f 666c listen_socket_fl │ │ │ -00077dd0: 6167 735f 7420 662c 2061 6464 7265 7373 ags_t f, address │ │ │ -00077de0: 2063 6f6e 7374 2661 6d70 3b20 6e6d 6173 const& nmas │ │ │ -00077df0: 6b20 3d20 6164 6472 6573 737b 7d29 0a09 k = address{}).. │ │ │ -00077e00: 0909 093a 2061 6464 7228 6164 7229 2c20 ...: addr(adr), │ │ │ -00077e10: 6e65 746d 6173 6b28 6e6d 6173 6b29 2c20 netmask(nmask), │ │ │ -00077e20: 706f 7274 2870 292c 2064 6576 6963 6528 port(p), device( │ │ │ -00077e30: 7374 643a 3a6d 6f76 6528 6465 7629 292c std::move(dev)), │ │ │ -00077e40: 2073 736c 2873 292c 2066 6c61 6773 2866 ssl(s), flags(f │ │ │ -00077e50: 2920 7b7d 0a3c 2f70 7265 3e3c 2f74 643e ) {}. │ │ │ -00077e60: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00077e90: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00077ea0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00077eb0: 7074 3a65 7870 616e 6428 3237 3229 223e pt:expand(272)"> │ │ │ -00077ec0: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -00077ed0: 7272 656e 742f 6175 785f 2f73 6573 7369 rrent/aux_/sessi │ │ │ -00077ee0: 6f6e 5f69 6d70 6c2e 6870 703a 3131 3032 on_impl.hpp:1102 │ │ │ -00077ef0: 3c2f 613e 3c2f 7464 3e3c 7464 3e72 6570 rep │ │ │ -00077f00: 6c61 6365 2074 6869 7320 6279 2061 2070 lace this by a p │ │ │ -00077f10: 726f 7065 7220 6173 696f 2074 696d 6572 roper asio timer │ │ │ -00077f20: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    re │ │ │ -00077f70: 706c 6163 6520 7468 6973 2062 7920 6120 place this by a │ │ │ -00077f80: 7072 6f70 6572 2061 7369 6f20 7469 6d65 proper asio time │ │ │ -00077f90: 723c 2f68 323e 3c68 343e 2e2e 2f69 6e63 r

    ../inc │ │ │ -00077fa0: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -00077fb0: 6175 785f 2f73 6573 7369 6f6e 5f69 6d70 aux_/session_imp │ │ │ -00077fc0: 6c2e 6870 703a 3131 3032 3c2f 6834 3e3c l.hpp:1102

    < │ │ │ -00077fd0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -00077fe0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -00077ff0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -00078000: 7820 2364 6464 3b22 3e23 6966 6465 6620 x #ddd;">#ifdef │ │ │ -00078010: 544f 5252 454e 545f 5353 4c5f 5045 4552 TORRENT_SSL_PEER │ │ │ -00078020: 530a 0909 0976 6f69 6420 6f6e 5f69 6e63 S....void on_inc │ │ │ -00078030: 6f6d 696e 675f 7574 705f 7373 6c28 736f oming_utp_ssl(so │ │ │ -00078040: 636b 6574 5f74 7970 6520 7329 3b0a 0909 cket_type s);... │ │ │ -00078050: 0976 6f69 6420 7373 6c5f 6861 6e64 7368 .void ssl_handsh │ │ │ -00078060: 616b 6528 6572 726f 725f 636f 6465 2063 ake(error_code c │ │ │ -00078070: 6f6e 7374 2661 6d70 3b20 6563 2c20 736f onst& ec, so │ │ │ -00078080: 636b 6574 5f74 7970 652a 2073 293b 0a23 cket_type* s);.# │ │ │ -00078090: 656e 6469 660a 0a09 0909 2f2f 2072 6f75 endif.....// rou │ │ │ -000780a0: 6e64 2d72 6f62 696e 2069 6e64 6578 2069 nd-robin index i │ │ │ -000780b0: 6e74 6f20 6d5f 6f75 7467 6f69 6e67 5f69 nto m_outgoing_i │ │ │ -000780c0: 6e74 6572 6661 6365 730a 0909 096d 7574 nterfaces....mut │ │ │ -000780d0: 6162 6c65 2073 7464 3a3a 7569 6e74 385f able std::uint8_ │ │ │ -000780e0: 7420 6d5f 696e 7465 7266 6163 655f 696e t m_interface_in │ │ │ -000780f0: 6465 7820 3d20 303b 0a0a 0909 0973 7464 dex = 0;.....std │ │ │ -00078100: 3a3a 7368 6172 6564 5f70 7472 266c 743b ::shared_ptr< │ │ │ -00078110: 6c69 7374 656e 5f73 6f63 6b65 745f 7426 listen_socket_t& │ │ │ -00078120: 6774 3b20 7365 7475 705f 6c69 7374 656e gt; setup_listen │ │ │ -00078130: 6572 280a 0909 0909 6c69 7374 656e 5f65 er(.....listen_e │ │ │ -00078140: 6e64 706f 696e 745f 7420 636f 6e73 7426 ndpoint_t const& │ │ │ -00078150: 616d 703b 206c 6570 2c20 6572 726f 725f amp; lep, error_ │ │ │ -00078160: 636f 6465 2661 6d70 3b20 6563 293b 0a0a code& ec);.. │ │ │ -00078170: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ -00078180: 4449 5341 424c 455f 4448 540a 0909 0964 DISABLE_DHT....d │ │ │ -00078190: 6874 3a3a 6468 745f 7374 6174 6520 6d5f ht::dht_state m_ │ │ │ -000781a0: 6468 745f 7374 6174 653b 0a23 656e 6469 dht_state;.#endi │ │ │ -000781b0: 660a 0a09 0909 2f2f 2074 6869 7320 6973 f.....// this is │ │ │ -000781c0: 2069 6e69 7469 616c 697a 6564 2074 6f20 initialized to │ │ │ -000781d0: 7468 6520 756e 6368 6f6b 655f 696e 7465 the unchoke_inte │ │ │ -000781e0: 7276 616c 0a09 0909 2f2f 2073 6573 7369 rval....// sessi │ │ │ -000781f0: 6f6e 5f73 6574 7469 6e67 2061 6e64 2064 on_setting and d │ │ │ -00078200: 6563 7265 6173 6564 2065 7665 7279 2073 ecreased every s │ │ │ -00078210: 6563 6f6e 642e 0a09 0909 2f2f 2077 6865 econd.....// whe │ │ │ -00078220: 6e20 6974 2072 6561 6368 6573 207a 6572 n it reaches zer │ │ │ -00078230: 6f2c 2069 7420 6973 2072 6573 6574 2074 o, it is reset t │ │ │ -00078240: 6f20 7468 650a 0909 092f 2f20 756e 6368 o the....// unch │ │ │ -00078250: 6f6b 655f 696e 7465 7276 616c 2061 6e64 oke_interval and │ │ │ -00078260: 2074 6865 2075 6e63 686f 6b65 2073 6574 the unchoke set │ │ │ -00078270: 2069 730a 0909 092f 2f20 7265 636f 6d70 is....// recomp │ │ │ -00078280: 7574 6564 2e0a 3c64 6976 2073 7479 6c65 uted..
    ...int m_unc │ │ │ -000782c0: 686f 6b65 5f74 696d 655f 7363 616c 6572 hoke_time_scaler │ │ │ -000782d0: 203d 2030 3b0a 3c2f 6469 763e 0a09 0909 = 0;.
    .... │ │ │ -000782e0: 2f2f 2074 6869 7320 6973 2075 7365 6420 // this is used │ │ │ -000782f0: 746f 2064 6563 6964 6520 7768 656e 2074 to decide when t │ │ │ -00078300: 6f20 7265 6361 6c63 756c 6174 6520 7768 o recalculate wh │ │ │ -00078310: 6963 680a 0909 092f 2f20 746f 7272 656e ich....// torren │ │ │ -00078320: 7473 2074 6f20 6b65 6570 2071 7565 7565 ts to keep queue │ │ │ -00078330: 6420 616e 6420 7768 6963 6820 746f 2061 d and which to a │ │ │ -00078340: 6374 6976 6174 650a 3c2f 7072 653e 3c2f ctivate.relevan │ │ │ -00078380: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../include/li │ │ │ -000783c0: 6274 6f72 7265 6e74 2f61 7578 5f2f 7365 btorrent/aux_/se │ │ │ -000783d0: 7373 696f 6e5f 696d 706c 2e68 7070 3a31 ssion_impl.hpp:1 │ │ │ -000783e0: 3130 373c 2f61 3e3c 2f74 643e 3c74 643e 107 │ │ │ -000783f0: 7265 706c 6163 6520 7468 6973 2062 7920 replace this by │ │ │ -00078400: 6120 7072 6f70 6572 2061 7369 6f20 7469 a proper asio ti │ │ │ -00078410: 6d65 723c 2f74 643e 3c2f 7472 3e3c 7472 mer

    replace this by │ │ │ -00078470: 2061 2070 726f 7065 7220 6173 696f 2074 a proper asio t │ │ │ -00078480: 696d 6572 3c2f 6832 3e3c 6834 3e2e 2e2f imer

    ../ │ │ │ -00078490: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -000784a0: 6e74 2f61 7578 5f2f 7365 7373 696f 6e5f nt/aux_/session_ │ │ │ -000784b0: 696d 706c 2e68 7070 3a31 3130 373c 2f68 impl.hpp:1107
    ....
    │ │ │ -00078500: 2f2f 2072 6f75 6e64 2d72 6f62 696e 2069  // round-robin i
    │ │ │ -00078510: 6e64 6578 2069 6e74 6f20 6d5f 6f75 7467  ndex into m_outg
    │ │ │ -00078520: 6f69 6e67 5f69 6e74 6572 6661 6365 730a  oing_interfaces.
    │ │ │ -00078530: 0909 096d 7574 6162 6c65 2073 7464 3a3a  ...mutable std::
    │ │ │ -00078540: 7569 6e74 385f 7420 6d5f 696e 7465 7266  uint8_t m_interf
    │ │ │ -00078550: 6163 655f 696e 6465 7820 3d20 303b 0a0a  ace_index = 0;..
    │ │ │ -00078560: 0909 0973 7464 3a3a 7368 6172 6564 5f70  ...std::shared_p
    │ │ │ -00078570: 7472 266c 743b 6c69 7374 656e 5f73 6f63  tr<listen_soc
    │ │ │ -00078580: 6b65 745f 7426 6774 3b20 7365 7475 705f  ket_t> setup_
    │ │ │ -00078590: 6c69 7374 656e 6572 280a 0909 0909 6c69  listener(.....li
    │ │ │ -000785a0: 7374 656e 5f65 6e64 706f 696e 745f 7420  sten_endpoint_t 
    │ │ │ -000785b0: 636f 6e73 7426 616d 703b 206c 6570 2c20  const& lep, 
    │ │ │ -000785c0: 6572 726f 725f 636f 6465 2661 6d70 3b20  error_code& 
    │ │ │ -000785d0: 6563 293b 0a0a 2369 666e 6465 6620 544f  ec);..#ifndef TO
    │ │ │ -000785e0: 5252 454e 545f 4449 5341 424c 455f 4448  RRENT_DISABLE_DH
    │ │ │ -000785f0: 540a 0909 0964 6874 3a3a 6468 745f 7374  T....dht::dht_st
    │ │ │ -00078600: 6174 6520 6d5f 6468 745f 7374 6174 653b  ate m_dht_state;
    │ │ │ -00078610: 0a23 656e 6469 660a 0a09 0909 2f2f 2074  .#endif.....// t
    │ │ │ -00078620: 6869 7320 6973 2069 6e69 7469 616c 697a  his is initializ
    │ │ │ -00078630: 6564 2074 6f20 7468 6520 756e 6368 6f6b  ed to the unchok
    │ │ │ -00078640: 655f 696e 7465 7276 616c 0a09 0909 2f2f  e_interval....//
    │ │ │ -00078650: 2073 6573 7369 6f6e 5f73 6574 7469 6e67   session_setting
    │ │ │ -00078660: 2061 6e64 2064 6563 7265 6173 6564 2065   and decreased e
    │ │ │ -00078670: 7665 7279 2073 6563 6f6e 642e 0a09 0909  very second.....
    │ │ │ -00078680: 2f2f 2077 6865 6e20 6974 2072 6561 6368  // when it reach
    │ │ │ -00078690: 6573 207a 6572 6f2c 2069 7420 6973 2072  es zero, it is r
    │ │ │ -000786a0: 6573 6574 2074 6f20 7468 650a 0909 092f  eset to the..../
    │ │ │ -000786b0: 2f20 756e 6368 6f6b 655f 696e 7465 7276  / unchoke_interv
    │ │ │ -000786c0: 616c 2061 6e64 2074 6865 2075 6e63 686f  al and the uncho
    │ │ │ -000786d0: 6b65 2073 6574 2069 730a 0909 092f 2f20  ke set is....// 
    │ │ │ -000786e0: 7265 636f 6d70 7574 6564 2e0a 0909 0969  recomputed.....i
    │ │ │ -000786f0: 6e74 206d 5f75 6e63 686f 6b65 5f74 696d  nt m_unchoke_tim
    │ │ │ -00078700: 655f 7363 616c 6572 203d 2030 3b0a 0a09  e_scaler = 0;...
    │ │ │ -00078710: 0909 2f2f 2074 6869 7320 6973 2075 7365  ..// this is use
    │ │ │ -00078720: 6420 746f 2064 6563 6964 6520 7768 656e  d to decide when
    │ │ │ -00078730: 2074 6f20 7265 6361 6c63 756c 6174 6520   to recalculate 
    │ │ │ -00078740: 7768 6963 680a 0909 092f 2f20 746f 7272  which....// torr
    │ │ │ -00078750: 656e 7473 2074 6f20 6b65 6570 2071 7565  ents to keep que
    │ │ │ -00078760: 7565 6420 616e 6420 7768 6963 6820 746f  ued and which to
    │ │ │ -00078770: 2061 6374 6976 6174 650a 3c64 6976 2073   activate.
    ...int m │ │ │ -000787b0: 5f61 7574 6f5f 6d61 6e61 6765 5f74 696d _auto_manage_tim │ │ │ -000787c0: 655f 7363 616c 6572 203d 2030 3b0a 3c2f e_scaler = 0;.....// works │ │ │ -000787e0: 206c 696b 6520 756e 6368 6f6b 655f 7469 like unchoke_ti │ │ │ -000787f0: 6d65 5f73 6361 6c65 7220 6275 7420 6974 me_scaler but it │ │ │ -00078800: 0a09 0909 2f2f 2069 7320 6f6e 6c79 2064 ....// is only d │ │ │ -00078810: 6563 7265 6173 6564 2077 6865 6e20 7468 ecreased when th │ │ │ -00078820: 6520 756e 6368 6f6b 6520 7365 740a 0909 e unchoke set... │ │ │ -00078830: 092f 2f20 6973 2072 6563 6f6d 7075 7465 .// is recompute │ │ │ -00078840: 642c 2061 6e64 2077 6865 6e20 6974 2072 d, and when it r │ │ │ -00078850: 6561 6368 6573 207a 6572 6f2c 0a09 0909 eaches zero,.... │ │ │ -00078860: 2f2f 2074 6865 206f 7074 696d 6973 7469 // the optimisti │ │ │ -00078870: 6320 756e 6368 6f6b 6520 6973 206d 6f76 c unchoke is mov │ │ │ -00078880: 6564 2074 6f20 616e 6f74 6865 7220 7065 ed to another pe │ │ │ -00078890: 6572 2e0a 3c2f 7072 653e 3c2f 7464 3e3c er..
    < │ │ │ -000788a0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -000788d0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -00078900: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -00078910: 7265 6e74 2f61 7578 5f2f 7365 7373 696f rent/aux_/sessio │ │ │ -00078920: 6e5f 696d 706c 2e68 7070 3a31 3131 343c n_impl.hpp:1114< │ │ │ -00078930: 2f61 3e3c 2f74 643e 3c74 643e 7265 706c /a>repl │ │ │ -00078940: 6163 6520 7468 6973 2062 7920 6120 7072 ace this by a pr │ │ │ -00078950: 6f70 6572 2061 7369 6f20 7469 6d65 723c oper asio timer< │ │ │ -00078960: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    rep │ │ │ -000789b0: 6c61 6365 2074 6869 7320 6279 2061 2070 lace this by a p │ │ │ -000789c0: 726f 7065 7220 6173 696f 2074 696d 6572 roper asio timer │ │ │ -000789d0: 3c2f 6832 3e3c 6834 3e2e 2e2f 696e 636c

    ../incl │ │ │ -000789e0: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -000789f0: 7578 5f2f 7365 7373 696f 6e5f 696d 706c ux_/session_impl │ │ │ -00078a00: 2e68 7070 3a31 3131 343c 2f68 343e 3c70 .hpp:1114

    .#ifndef │ │ │ -00078a50: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ -00078a60: 5f44 4854 0a09 0909 6468 743a 3a64 6874 _DHT....dht::dht │ │ │ -00078a70: 5f73 7461 7465 206d 5f64 6874 5f73 7461 _state m_dht_sta │ │ │ -00078a80: 7465 3b0a 2365 6e64 6966 0a0a 0909 092f te;.#endif...../ │ │ │ -00078a90: 2f20 7468 6973 2069 7320 696e 6974 6961 / this is initia │ │ │ -00078aa0: 6c69 7a65 6420 746f 2074 6865 2075 6e63 lized to the unc │ │ │ -00078ab0: 686f 6b65 5f69 6e74 6572 7661 6c0a 0909 hoke_interval... │ │ │ -00078ac0: 092f 2f20 7365 7373 696f 6e5f 7365 7474 .// session_sett │ │ │ -00078ad0: 696e 6720 616e 6420 6465 6372 6561 7365 ing and decrease │ │ │ -00078ae0: 6420 6576 6572 7920 7365 636f 6e64 2e0a d every second.. │ │ │ -00078af0: 0909 092f 2f20 7768 656e 2069 7420 7265 ...// when it re │ │ │ -00078b00: 6163 6865 7320 7a65 726f 2c20 6974 2069 aches zero, it i │ │ │ -00078b10: 7320 7265 7365 7420 746f 2074 6865 0a09 s reset to the.. │ │ │ -00078b20: 0909 2f2f 2075 6e63 686f 6b65 5f69 6e74 ..// unchoke_int │ │ │ -00078b30: 6572 7661 6c20 616e 6420 7468 6520 756e erval and the un │ │ │ -00078b40: 6368 6f6b 6520 7365 7420 6973 0a09 0909 choke set is.... │ │ │ -00078b50: 2f2f 2072 6563 6f6d 7075 7465 642e 0a09 // recomputed... │ │ │ -00078b60: 0909 696e 7420 6d5f 756e 6368 6f6b 655f ..int m_unchoke_ │ │ │ -00078b70: 7469 6d65 5f73 6361 6c65 7220 3d20 303b time_scaler = 0; │ │ │ -00078b80: 0a0a 0909 092f 2f20 7468 6973 2069 7320 .....// this is │ │ │ -00078b90: 7573 6564 2074 6f20 6465 6369 6465 2077 used to decide w │ │ │ -00078ba0: 6865 6e20 746f 2072 6563 616c 6375 6c61 hen to recalcula │ │ │ -00078bb0: 7465 2077 6869 6368 0a09 0909 2f2f 2074 te which....// t │ │ │ -00078bc0: 6f72 7265 6e74 7320 746f 206b 6565 7020 orrents to keep │ │ │ -00078bd0: 7175 6575 6564 2061 6e64 2077 6869 6368 queued and which │ │ │ -00078be0: 2074 6f20 6163 7469 7661 7465 0a09 0909 to activate.... │ │ │ -00078bf0: 696e 7420 6d5f 6175 746f 5f6d 616e 6167 int m_auto_manag │ │ │ -00078c00: 655f 7469 6d65 5f73 6361 6c65 7220 3d20 e_time_scaler = │ │ │ -00078c10: 303b 0a0a 0909 092f 2f20 776f 726b 7320 0;.....// works │ │ │ -00078c20: 6c69 6b65 2075 6e63 686f 6b65 5f74 696d like unchoke_tim │ │ │ -00078c30: 655f 7363 616c 6572 2062 7574 2069 740a e_scaler but it. │ │ │ -00078c40: 0909 092f 2f20 6973 206f 6e6c 7920 6465 ...// is only de │ │ │ -00078c50: 6372 6561 7365 6420 7768 656e 2074 6865 creased when the │ │ │ -00078c60: 2075 6e63 686f 6b65 2073 6574 0a09 0909 unchoke set.... │ │ │ -00078c70: 2f2f 2069 7320 7265 636f 6d70 7574 6564 // is recomputed │ │ │ -00078c80: 2c20 616e 6420 7768 656e 2069 7420 7265 , and when it re │ │ │ -00078c90: 6163 6865 7320 7a65 726f 2c0a 0909 092f aches zero,..../ │ │ │ -00078ca0: 2f20 7468 6520 6f70 7469 6d69 7374 6963 / the optimistic │ │ │ -00078cb0: 2075 6e63 686f 6b65 2069 7320 6d6f 7665 unchoke is move │ │ │ -00078cc0: 6420 746f 2061 6e6f 7468 6572 2070 6565 d to another pee │ │ │ -00078cd0: 722e 0a3c 6469 7620 7374 796c 653d 2262 r..

    ...int m_optimi │ │ │ -00078d10: 7374 6963 5f75 6e63 686f 6b65 5f74 696d stic_unchoke_tim │ │ │ -00078d20: 655f 7363 616c 6572 203d 2030 3b0a 3c2f e_scaler = 0;.....// works │ │ │ -00078d40: 206c 696b 6520 756e 6368 6f6b 655f 7469 like unchoke_ti │ │ │ -00078d50: 6d65 5f73 6361 6c65 722e 2045 6163 6820 me_scaler. Each │ │ │ -00078d60: 7469 6d65 0a09 0909 2f2f 2069 7420 7265 time....// it re │ │ │ -00078d70: 6163 6865 7320 302c 2061 6e64 2061 6c6c aches 0, and all │ │ │ -00078d80: 2074 6865 2063 6f6e 6e65 6374 696f 6e73 the connections │ │ │ -00078d90: 2061 7265 0a09 0909 2f2f 2075 7365 642c are....// used, │ │ │ -00078da0: 2074 6865 2077 6f72 7374 2063 6f6e 6e65 the worst conne │ │ │ -00078db0: 6374 696f 6e20 7769 6c6c 2062 6520 6469 ction will be di │ │ │ -00078dc0: 7363 6f6e 6e65 6374 6564 0a09 0909 2f2f sconnected....// │ │ │ -00078dd0: 2066 726f 6d20 7468 6520 746f 7272 656e from the torren │ │ │ -00078de0: 7420 7769 7468 2074 6865 206d 6f73 7420 t with the most │ │ │ -00078df0: 7065 6572 730a 0909 0969 6e74 206d 5f64 peers....int m_d │ │ │ -00078e00: 6973 636f 6e6e 6563 745f 7469 6d65 5f73 isconnect_time_s │ │ │ -00078e10: 6361 6c65 7220 3d20 3930 3b0a 0a09 0909 caler = 90;..... │ │ │ -00078e20: 2f2f 2077 6865 6e20 7468 6973 2073 6361 // when this sca │ │ │ -00078e30: 6c65 7220 7265 6163 6865 7320 7a65 726f ler reaches zero │ │ │ -00078e40: 2c20 6974 2077 696c 6c0a 0909 092f 2f20 , it will....// │ │ │ -00078e50: 7363 7261 7065 206f 6e65 206f 6620 7468 scrape one of th │ │ │ -00078e60: 6520 6175 746f 206d 616e 6167 6564 2c20 e auto managed, │ │ │ -00078e70: 7061 7573 6564 2c0a 0909 092f 2f20 746f paused,....// to │ │ │ -00078e80: 7272 656e 7473 2e0a 0909 0969 6e74 206d rrents.....int m │ │ │ -00078e90: 5f61 7574 6f5f 7363 7261 7065 5f74 696d _auto_scrape_tim │ │ │ -00078ea0: 655f 7363 616c 6572 203d 2031 3830 3b0a e_scaler = 180;. │ │ │ -00078eb0: 0a09 0909 2f2f 2073 7461 7469 7374 6963 ....// statistic │ │ │ -00078ec0: 7320 6761 7468 6572 6564 2066 726f 6d20 s gathered from │ │ │ -00078ed0: 616c 6c20 746f 7272 656e 7473 2e0a 0909 all torrents.... │ │ │ -00078ee0: 0973 7461 7420 6d5f 7374 6174 3b0a 0a09 .stat m_stat;... │ │ │ -00078ef0: 0909 2f2f 2069 6d70 6c65 6d65 6e74 7320 ..// implements │ │ │ -00078f00: 7365 7373 696f 6e5f 696e 7465 7266 6163 session_interfac │ │ │ -00078f10: 650a 0909 0976 6f69 6420 7365 6e74 5f62 e....void sent_b │ │ │ -00078f20: 7974 6573 2869 6e74 2062 7974 6573 5f70 ytes(int bytes_p │ │ │ -00078f30: 6179 6c6f 6164 2c20 696e 7420 6279 7465 ayload, int byte │ │ │ -00078f40: 735f 7072 6f74 6f63 6f6c 2920 6f76 6572 s_protocol) over │ │ │ -00078f50: 7269 6465 3b0a 0909 0976 6f69 6420 7265 ride;....void re │ │ │ -00078f60: 6365 6976 6564 5f62 7974 6573 2869 6e74 ceived_bytes(int │ │ │ -00078f70: 2062 7974 6573 5f70 6179 6c6f 6164 2c20 bytes_payload, │ │ │ -00078f80: 696e 7420 6279 7465 735f 7072 6f74 6f63 int bytes_protoc │ │ │ -00078f90: 6f6c 2920 6f76 6572 7269 6465 3b0a 0909 ol) override;... │ │ │ -00078fa0: 0976 6f69 6420 7472 616e 6369 6576 655f .void trancieve_ │ │ │ -00078fb0: 6970 5f70 6163 6b65 7428 696e 7420 6279 ip_packet(int by │ │ │ -00078fc0: 7465 732c 2062 6f6f 6c20 6970 7636 2920 tes, bool ipv6) │ │ │ -00078fd0: 6f76 6572 7269 6465 3b0a 0909 0976 6f69 override;....voi │ │ │ -00078fe0: 6420 7365 6e74 5f73 796e 2862 6f6f 6c20 d sent_syn(bool │ │ │ -00078ff0: 6970 7636 2920 6f76 6572 7269 6465 3b0a ipv6) override;. │ │ │ -00079000: 0909 0976 6f69 6420 7265 6365 6976 6564 ...void received │ │ │ -00079010: 5f73 796e 6163 6b28 626f 6f6c 2069 7076 _synack(bool ipv │ │ │ -00079020: 3629 206f 7665 7272 6964 653b 0a0a 2369 6) override;..#i │ │ │ -00079030: 6620 544f 5252 454e 545f 4142 495f 5645 f TORRENT_ABI_VE │ │ │ -00079040: 5253 494f 4e20 3d3d 2031 0a09 0909 696e RSION == 1....in │ │ │ -00079050: 7420 6d5f 7065 616b 5f75 705f 7261 7465 t m_peak_up_rate │ │ │ -00079060: 203d 2030 3b0a 2365 6e64 6966 0a0a 0909 = 0;.#endif.... │ │ │ -00079070: 0976 6f69 6420 6f6e 5f74 6963 6b28 6572 .void on_tick(er │ │ │ -00079080: 726f 725f 636f 6465 2063 6f6e 7374 2661 ror_code const&a │ │ │ -00079090: 6d70 3b20 6529 3b0a 0a09 0909 766f 6964 mp; e);.....void │ │ │ -000790a0: 2074 7279 5f63 6f6e 6e65 6374 5f6d 6f72 try_connect_mor │ │ │ -000790b0: 655f 7065 6572 7328 293b 0a09 0909 766f e_peers();....vo │ │ │ -000790c0: 6964 2061 7574 6f5f 6d61 6e61 6765 5f63 id auto_manage_c │ │ │ -000790d0: 6865 636b 696e 675f 746f 7272 656e 7473 hecking_torrents │ │ │ -000790e0: 2873 7464 3a3a 7665 6374 6f72 266c 743b (std::vector< │ │ │ -000790f0: 746f 7272 656e 742a 2667 743b 2661 6d70 torrent*>& │ │ │ -00079100: 3b20 6c69 7374 0a3c 2f70 7265 3e3c 2f74 ; list.relevanc │ │ │ -00079140: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../include/lib │ │ │ -00079180: 746f 7272 656e 742f 6175 785f 2f6d 6572 torrent/aux_/mer │ │ │ -00079190: 6b6c 655f 7472 6565 2e68 7070 3a36 323c kle_tree.hpp:62< │ │ │ -000791a0: 2f61 3e3c 2f74 643e 3c74 643e 7265 6d6f /a>remo │ │ │ -000791b0: 7665 2074 6869 7320 636f 6e73 7472 7563 ve this construc │ │ │ -000791c0: 746f 722e 2044 6f6e 2774 2073 7570 706f tor. Don't suppo │ │ │ -000791d0: 7274 2022 756e 696e 6974 6961 6c69 7a65 rt "uninitialize │ │ │ -000791e0: 6422 2074 7265 6573 2e20 5468 6973 2061 d" trees. This a │ │ │ -000791f0: 6c73 6f20 7265 7175 6972 6573 206e 6f74 lso requires not │ │ │ -00079200: 2063 6f6e 7374 7275 6374 696e 6720 7468 constructing th │ │ │ -00079210: 6573 6520 666f 7220 7061 642d 6669 6c65 ese for pad-file │ │ │ -00079220: 7320 616e 6420 736d 616c 6c20 6669 6c65 s and small file │ │ │ -00079230: 7320 6173 2077 656c 6c2e 2053 6f2c 2061 s as well. So, a │ │ │ -00079240: 2073 7061 7273 6520 6861 7368 206c 6973 sparse hash lis │ │ │ -00079250: 7420 696e 2074 6f72 7265 6e74 5f69 6e66 t in torrent_inf │ │ │ -00079260: 6f3c 2f74 643e 3c2f 7472 3e3c 7472 2069 o

    r │ │ │ -000792b0: 656d 6f76 6520 7468 6973 2063 6f6e 7374 emove this const │ │ │ -000792c0: 7275 6374 6f72 2e20 446f 6e27 7420 7375 ructor. Don't su │ │ │ -000792d0: 7070 6f72 7420 2275 6e69 6e69 7469 616c pport "uninitial │ │ │ -000792e0: 697a 6564 2220 7472 6565 732e 2054 6869 ized" trees. Thi │ │ │ -000792f0: 730a 616c 736f 2072 6571 7569 7265 7320 s.also requires │ │ │ -00079300: 6e6f 7420 636f 6e73 7472 7563 7469 6e67 not constructing │ │ │ -00079310: 2074 6865 7365 2066 6f72 2070 6164 2d66 these for pad-f │ │ │ -00079320: 696c 6573 2061 6e64 2073 6d61 6c6c 2066 iles and small f │ │ │ -00079330: 696c 6573 2061 730a 7765 6c6c 2e20 536f iles as.well. So │ │ │ -00079340: 2c20 6120 7370 6172 7365 2068 6173 6820 , a sparse hash │ │ │ -00079350: 6c69 7374 2069 6e20 746f 7272 656e 745f list in torrent_ │ │ │ -00079360: 696e 666f 3c2f 6832 3e3c 6834 3e2e 2e2f info

    ../ │ │ │ -00079370: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -00079380: 6e74 2f61 7578 5f2f 6d65 726b 6c65 5f74 nt/aux_/merkle_t │ │ │ -00079390: 7265 652e 6870 703a 3632 3c2f 6834 3e3c ree.hpp:62

    < │ │ │ -000793a0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ -000793b0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ -000793c0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ -000793d0: 7820 2364 6464 3b22 3e2f 2f20 5468 6520 x #ddd;">// The │ │ │ -000793e0: 696e 7661 7269 616e 7420 6f66 2074 6865 invariant of the │ │ │ -000793f0: 2074 7265 6520 6973 2074 6861 7420 616c tree is that al │ │ │ -00079400: 6c20 696e 7465 7269 6f72 206e 6f64 6573 l interior nodes │ │ │ -00079410: 2028 692e 652e 2061 6c6c 2062 7574 2074 (i.e. all but t │ │ │ -00079420: 6865 2076 6572 790a 2f2f 2062 6f74 746f he very.// botto │ │ │ -00079430: 6d20 6c65 6166 206e 6f64 6573 2c20 7265 m leaf nodes, re │ │ │ -00079440: 7072 6573 656e 7469 6e67 2062 6c6f 636b presenting block │ │ │ -00079450: 2068 6173 6865 7329 2061 7265 2065 6974 hashes) are eit │ │ │ -00079460: 6865 7220 7365 7420 616e 6420 7661 6c69 her set and vali │ │ │ -00079470: 642c 206f 720a 2f2f 2063 6c65 6172 2e20 d, or.// clear. │ │ │ -00079480: 4e6f 2069 6e76 616c 6964 2068 6173 6865 No invalid hashe │ │ │ -00079490: 7320 6172 6520 616c 6c6f 7765 642c 2061 s are allowed, a │ │ │ -000794a0: 6e64 2074 6865 7920 6361 6e20 6f6e 6c79 nd they can only │ │ │ -000794b0: 2062 6520 6164 6465 6420 6279 2061 6c73 be added by als │ │ │ -000794c0: 6f0a 2f2f 2070 726f 7669 6469 6e67 2070 o.// providing p │ │ │ -000794d0: 726f 6f66 206f 6620 6265 696e 6720 7661 roof of being va │ │ │ -000794e0: 6c69 642e 0a0a 2f2f 2054 6865 206c 6561 lid...// The lea │ │ │ -000794f0: 6620 626c 6f63 6b73 206f 6e20 7468 6520 f blocks on the │ │ │ -00079500: 6f74 6865 7220 6861 6e64 2c20 4d41 5920 other hand, MAY │ │ │ -00079510: 6265 2069 6e76 616c 6964 2e20 466f 7220 be invalid. For │ │ │ -00079520: 696e 7374 616e 6365 2c20 7768 656e 2061 instance, when a │ │ │ -00079530: 6464 696e 670a 2f2f 2061 206d 6167 6e65 dding.// a magne │ │ │ -00079540: 7420 6c69 6e6b 2066 6f72 2061 2074 6f72 t link for a tor │ │ │ -00079550: 7265 6e74 2074 6861 7420 7765 2061 6c72 rent that we alr │ │ │ -00079560: 6561 6479 2068 6176 6520 6669 6c65 7320 eady have files │ │ │ -00079570: 666f 722e 204f 6e63 6520 7765 2068 6176 for. Once we hav │ │ │ -00079580: 6520 7468 650a 2f2f 206d 6574 6164 6174 e the.// metadat │ │ │ -00079590: 612c 2077 6520 6861 7665 2066 696c 6573 a, we have files │ │ │ -000795a0: 206f 6e20 6469 736b 2062 7574 206e 6f20 on disk but no │ │ │ -000795b0: 6861 7368 6573 2e20 5765 2077 6f6e 2774 hashes. We won't │ │ │ -000795c0: 206b 6e6f 7720 7768 6574 6865 7220 7468 know whether th │ │ │ -000795d0: 6520 6461 7461 0a2f 2f20 6f6e 2064 6973 e data.// on dis │ │ │ -000795e0: 6b20 6973 2076 616c 6964 206f 7220 6e6f k is valid or no │ │ │ -000795f0: 742c 2075 6e74 696c 2077 6527 7665 2064 t, until we've d │ │ │ -00079600: 6f77 6e6c 6f61 6465 6420 7468 6520 6861 ownloaded the ha │ │ │ -00079610: 7368 6573 2074 6f20 7661 6c69 6461 7465 shes to validate │ │ │ -00079620: 2074 6865 6d2e 0a0a 2f2f 2049 6465 6120 them...// Idea │ │ │ -00079630: 666f 7220 6675 7475 7265 2073 7061 6365 for future space │ │ │ -00079640: 206f 7074 696d 697a 6174 696f 6e3a 0a2f optimization:./ │ │ │ -00079650: 2f20 7768 696c 6520 646f 776e 6c6f 6164 / while download │ │ │ -00079660: 696e 672c 2077 6520 6e65 6564 2074 6f20 ing, we need to │ │ │ -00079670: 7374 6f72 6520 696e 7465 7269 6f72 206e store interior n │ │ │ -00079680: 6f64 6573 206f 6620 7468 6973 2074 7265 odes of this tre │ │ │ -00079690: 652e 2048 6f77 6576 6572 2c20 7765 0a2f e. However, we./ │ │ │ -000796a0: 2f20 646f 6e27 7420 6e65 6564 2074 6f20 / don't need to │ │ │ -000796b0: 7374 6f72 6520 7468 6520 7061 6464 696e store the paddin │ │ │ -000796c0: 672e 2061 2053 4841 2d32 3536 2069 7320 g. a SHA-256 is │ │ │ -000796d0: 3332 2062 7974 6573 2e20 496e 7374 6561 32 bytes. Instea │ │ │ -000796e0: 6420 6f66 2073 746f 7269 6e67 0a2f 2f20 d of storing.// │ │ │ -000796f0: 7468 6520 6675 6c6c 2028 7061 6464 6564 the full (padded │ │ │ -00079700: 2920 7472 6565 206f 6620 5348 412d 3235 ) tree of SHA-25 │ │ │ -00079710: 3620 6861 7368 6573 2c20 7374 6f72 6520 6 hashes, store │ │ │ -00079720: 7468 6520 6675 6c6c 2074 7265 6520 6f66 the full tree of │ │ │ -00079730: 2033 3220 6269 740a 2f2f 2073 6967 6e65 32 bit.// signe │ │ │ -00079740: 6420 696e 7465 6765 7273 2c20 6265 696e d integers, bein │ │ │ -00079750: 6720 696e 6469 6365 7320 696e 746f 2074 g indices into t │ │ │ -00079760: 6865 2061 6374 7561 6c20 7374 6f72 6167 he actual storag │ │ │ -00079770: 6520 666f 7220 7468 6520 7472 6565 2e20 e for the tree. │ │ │ -00079780: 5765 2063 6f75 6c64 0a2f 2f20 6576 656e We could.// even │ │ │ -00079790: 2067 726f 7720 7468 6520 7374 6f72 6167 grow the storag │ │ │ -000797a0: 6520 6c61 7a69 6c79 2e20 496e 7374 6561 e lazily. Instea │ │ │ -000797b0: 6420 6f66 2073 746f 7269 6e67 2074 6865 d of storing the │ │ │ -000797c0: 2070 6164 6469 6e67 2068 6173 6865 732c padding hashes, │ │ │ -000797d0: 2075 7365 0a2f 2f20 6e65 6761 7469 7665 use.// negative │ │ │ -000797e0: 2069 6e64 6963 6573 2074 6f20 7265 6665 indices to refe │ │ │ -000797f0: 7220 746f 2066 6978 6564 2053 4841 2d32 r to fixed SHA-2 │ │ │ -00079800: 3536 2830 292c 2061 6e64 2053 4841 2d32 56(0), and SHA-2 │ │ │ -00079810: 3536 2853 4841 2d32 3536 2830 2929 2061 56(SHA-256(0)) a │ │ │ -00079820: 6e64 2073 6f0a 2f2f 206f 6e0a 7374 7275 nd so.// on.stru │ │ │ -00079830: 6374 2054 4f52 5245 4e54 5f45 5854 5241 ct TORRENT_EXTRA │ │ │ -00079840: 5f45 5850 4f52 5420 6d65 726b 6c65 5f74 _EXPORT merkle_t │ │ │ -00079850: 7265 650a 7b0a 3c64 6976 2073 7479 6c65 ree.{.
    .merkle_tree │ │ │ -00079890: 2829 203d 2064 6566 6175 6c74 3b0a 3c2f () = default;..merkle_tree │ │ │ -000798b0: 2869 6e74 206e 756d 5f62 6c6f 636b 732c (int num_blocks, │ │ │ -000798c0: 2069 6e74 2062 6c6f 636b 735f 7065 725f int blocks_per_ │ │ │ -000798d0: 7069 6563 652c 2063 6861 7220 636f 6e73 piece, char cons │ │ │ -000798e0: 742a 2072 293b 0a0a 0973 6861 3235 365f t* r);...sha256_ │ │ │ -000798f0: 6861 7368 2072 6f6f 7428 2920 636f 6e73 hash root() cons │ │ │ -00079900: 743b 0a0a 0976 6f69 6420 6c6f 6164 5f74 t;...void load_t │ │ │ -00079910: 7265 6528 7370 616e 266c 743b 7368 6132 ree(span<sha2 │ │ │ -00079920: 3536 5f68 6173 6820 636f 6e73 7426 6774 56_hash const> │ │ │ -00079930: 3b20 742c 2062 6974 6669 656c 6420 636f ; t, bitfield co │ │ │ -00079940: 6e73 7426 616d 703b 2076 6572 6966 6965 nst& verifie │ │ │ -00079950: 6429 3b0a 0976 6f69 6420 6c6f 6164 5f73 d);..void load_s │ │ │ -00079960: 7061 7273 655f 7472 6565 2873 7061 6e26 parse_tree(span& │ │ │ -00079970: 6c74 3b73 6861 3235 365f 6861 7368 2063 lt;sha256_hash c │ │ │ -00079980: 6f6e 7374 2667 743b 2074 2c20 6269 7466 onst> t, bitf │ │ │ -00079990: 6965 6c64 2063 6f6e 7374 2661 6d70 3b20 ield const& │ │ │ -000799a0: 6d61 736b 0a09 092c 2062 6974 6669 656c mask..., bitfiel │ │ │ -000799b0: 6420 636f 6e73 7426 616d 703b 2076 6572 d const& ver │ │ │ -000799c0: 6966 6965 6429 3b0a 0976 6f69 6420 6c6f ified);..void lo │ │ │ -000799d0: 6164 5f76 6572 6966 6965 645f 6269 7473 ad_verified_bits │ │ │ -000799e0: 2862 6974 6669 656c 6420 636f 6e73 7426 (bitfield const& │ │ │ -000799f0: 616d 703b 2076 6572 6966 6965 6429 3b0a amp; verified);. │ │ │ -00079a00: 0a09 7374 643a 3a73 697a 655f 7420 7369 ..std::size_t si │ │ │ -00079a10: 7a65 2829 2063 6f6e 7374 3b0a 0969 6e74 ze() const;..int │ │ │ -00079a20: 2065 6e64 5f69 6e64 6578 2829 2063 6f6e end_index() con │ │ │ -00079a30: 7374 207b 2072 6574 7572 6e20 696e 7428 st { return int( │ │ │ -00079a40: 7369 7a65 2829 293b 207d 0a0a 0962 6f6f size()); }...boo │ │ │ -00079a50: 6c20 6861 735f 6e6f 6465 2869 6e74 2069 l has_node(int i │ │ │ -00079a60: 6478 2920 636f 6e73 743b 0a0a 0962 6f6f dx) const;...boo │ │ │ -00079a70: 6c20 636f 6d70 6172 655f 6e6f 6465 2869 l compare_node(i │ │ │ -00079a80: 6e74 2069 6478 2c20 7368 6132 3536 5f68 nt idx, sha256_h │ │ │ -00079a90: 6173 6820 636f 6e73 7426 616d 703b 2068 ash const& h │ │ │ -00079aa0: 2920 636f 6e73 743b 0a0a 0973 6861 3235 ) const;...sha25 │ │ │ -00079ab0: 365f 6861 7368 206f 7065 7261 746f 725b 6_hash operator[ │ │ │ -00079ac0: 5d28 696e 7420 6964 7829 2063 6f6e 7374 ](int idx) const │ │ │ -00079ad0: 3b0a 0a09 7374 643a 3a76 6563 746f 7226 ;...std::vector& │ │ │ -00079ae0: 6c74 3b73 6861 3235 365f 6861 7368 2667 lt;sha256_hash&g │ │ │ -00079af0: 743b 2062 7569 6c64 5f76 6563 746f 7228 t; build_vector( │ │ │ -00079b00: 2920 636f 6e73 743b 0a09 7374 643a 3a70 ) const;..std::p │ │ │ -00079b10: 6169 7226 6c74 3b73 7464 3a3a 7665 6374 air<std::vect │ │ │ -00079b20: 6f72 266c 743b 7368 6132 3536 5f68 6173 or<sha256_has │ │ │ -00079b30: 6826 6774 3b2c 2062 6974 6669 656c 6426 h>, bitfield& │ │ │ -00079b40: 6774 3b20 6275 696c 645f 7370 6172 7365 gt; build_sparse │ │ │ -00079b50: 5f76 6563 746f 7228 2920 636f 6e73 743b _vector() const; │ │ │ -00079b60: 0a0a 092f 2f20 6765 7420 6269 7473 2069 ...// get bits i │ │ │ -00079b70: 6e64 6963 6174 696e 6720 6966 2065 6163 ndicating if eac │ │ │ -00079b80: 6820 6c65 6166 2068 6173 6820 6973 2076 h leaf hash is v │ │ │ -00079b90: 6572 6966 6965 640a 0962 6974 6669 656c erified..bitfiel │ │ │ -00079ba0: 6420 7665 7269 6669 6564 5f6c 6561 6673 d verified_leafs │ │ │ -00079bb0: 2829 2063 6f6e 7374 3b0a 0a09 2f2f 2072 () const;...// r │ │ │ -00079bc0: 6574 7572 6e73 2074 7275 6520 6966 2074 eturns true if t │ │ │ -00079bd0: 6865 2065 6e74 6972 6520 7472 6565 2069 he entire tree i │ │ │ -00079be0: 7320 6b6e 6f77 6e20 616e 6420 7665 7269 s known and veri │ │ │ -00079bf0: 6669 6564 0a09 626f 6f6c 2069 735f 636f fied..bool is_co │ │ │ -00079c00: 6d70 6c65 7465 2829 2063 6f6e 7374 3b0a mplete() const;. │ │ │ -00079c10: 0a09 2f2f 2072 6574 7572 6e73 2074 7275 ..// returns tru │ │ │ -00079c20: 6520 6966 2061 6c6c 2062 6c6f 636b 2068 e if all block h │ │ │ -00079c30: 6173 6865 7320 696e 2074 6865 2073 7065 ashes in the spe │ │ │ -00079c40: 6369 6669 6564 2072 616e 6765 2068 6176 cified range hav │ │ │ -00079c50: 6520 6265 656e 2076 6572 6966 6965 640a e been verified. │ │ │ -00079c60: 0962 6f6f 6c20 626c 6f63 6b73 5f76 6572 .bool blocks_ver │ │ │ -00079c70: 6966 6965 6428 696e 7420 626c 6f63 6b5f ified(int block_ │ │ │ -00079c80: 6964 782c 2069 6e74 206e 756d 5f62 6c6f idx, int num_blo │ │ │ -00079c90: 636b 7329 2063 6f6e 7374 3b0a 0a3c 2f70 cks) const;..

    re │ │ │ -00079cd0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0
    ../inclu │ │ │ -00079d10: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ -00079d20: 785f 2f6d 6572 6b6c 655f 7472 6565 2e68 x_/merkle_tree.h │ │ │ -00079d30: 7070 3a31 3532 3c2f 613e 3c2f 7464 3e3c pp:152< │ │ │ -00079d40: 7464 3e6d 616b 6520 7468 6973 2061 2073 td>make this a s │ │ │ -00079d50: 7464 3a3a 756e 6971 7565 5f70 7472 3c73 td::unique_ptr

    make │ │ │ -00079dc0: 7468 6973 2061 2073 7464 3a3a 756e 6971 this a std::uniq │ │ │ -00079dd0: 7565 5f70 7472 3c73 6861 3235 365f 6861 ue_ptr

    .. │ │ │ -00079df0: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -00079e00: 656e 742f 6175 785f 2f6d 6572 6b6c 655f ent/aux_/merkle_ │ │ │ -00079e10: 7472 6565 2e68 7070 3a31 3532 3c2f 6834 tree.hpp:152

    ..int
    │ │ │ -00079e60: 2062 6c6f 636b 735f 7065 725f 7069 6563   blocks_per_piec
    │ │ │ -00079e70: 6528 2920 636f 6e73 7420 7b20 7265 7475  e() const { retu
    │ │ │ -00079e80: 726e 2031 2026 6c74 3b26 6c74 3b20 6d5f  rn 1 << m_
    │ │ │ -00079e90: 626c 6f63 6b73 5f70 6572 5f70 6965 6365  blocks_per_piece
    │ │ │ -00079ea0: 5f6c 6f67 3b20 7d0a 092f 2f20 7468 6520  _log; }..// the 
    │ │ │ -00079eb0: 6e75 6d62 6572 2074 7265 6520 6c65 7665  number tree leve
    │ │ │ -00079ec0: 6c73 2070 6572 2070 6965 6365 2e20 5468  ls per piece. Th
    │ │ │ -00079ed0: 6973 2069 7320 3020 6966 2074 6865 2062  is is 0 if the b
    │ │ │ -00079ee0: 6c6f 636b 206c 6179 6572 2069 7320 616c  lock layer is al
    │ │ │ -00079ef0: 736f 0a09 2f2f 2074 6865 2070 6965 6365  so..// the piece
    │ │ │ -00079f00: 206c 6179 6572 2e0a 0969 6e74 2070 6965   layer...int pie
    │ │ │ -00079f10: 6365 5f6c 6576 656c 7328 2920 636f 6e73  ce_levels() cons
    │ │ │ -00079f20: 7420 7b20 7265 7475 726e 206d 5f62 6c6f  t { return m_blo
    │ │ │ -00079f30: 636b 735f 7065 725f 7069 6563 655f 6c6f  cks_per_piece_lo
    │ │ │ -00079f40: 673b 207d 0a0a 0969 6e74 2062 6c6f 636b  g; }...int block
    │ │ │ -00079f50: 5f6c 6179 6572 5f73 7461 7274 2829 2063  _layer_start() c
    │ │ │ -00079f60: 6f6e 7374 3b0a 0969 6e74 2070 6965 6365  onst;..int piece
    │ │ │ -00079f70: 5f6c 6179 6572 5f73 7461 7274 2829 2063  _layer_start() c
    │ │ │ -00079f80: 6f6e 7374 3b0a 0969 6e74 206e 756d 5f70  onst;..int num_p
    │ │ │ -00079f90: 6965 6365 7328 2920 636f 6e73 743b 0a09  ieces() const;..
    │ │ │ -00079fa0: 696e 7420 6e75 6d5f 6c65 6166 7328 2920  int num_leafs() 
    │ │ │ -00079fb0: 636f 6e73 743b 0a0a 0976 6f69 6420 6f70  const;...void op
    │ │ │ -00079fc0: 7469 6d69 7a65 5f73 746f 7261 6765 2829  timize_storage()
    │ │ │ -00079fd0: 3b0a 0976 6f69 6420 6f70 7469 6d69 7a65  ;..void optimize
    │ │ │ -00079fe0: 5f73 746f 7261 6765 5f70 6965 6365 5f6c  _storage_piece_l
    │ │ │ -00079ff0: 6179 6572 2829 3b0a 0976 6f69 6420 616c  ayer();..void al
    │ │ │ -0007a000: 6c6f 6361 7465 5f66 756c 6c28 293b 0a0a  locate_full();..
    │ │ │ -0007a010: 092f 2f20 6120 706f 696e 7465 7220 746f  .// a pointer to
    │ │ │ -0007a020: 2074 6865 2072 6f6f 7420 6861 7368 2066   the root hash f
    │ │ │ -0007a030: 6f72 2074 6869 7320 6669 6c65 2e0a 0963  or this file...c
    │ │ │ -0007a040: 6861 7220 636f 6e73 742a 206d 5f72 6f6f  har const* m_roo
    │ │ │ -0007a050: 7420 3d20 6e75 6c6c 7074 723b 0a0a 092f  t = nullptr;.../
    │ │ │ -0007a060: 2f20 7468 6973 2069 7320 6569 7468 6572  / this is either
    │ │ │ -0007a070: 2074 6865 2066 756c 6c20 7472 6565 2c20   the full tree, 
    │ │ │ -0007a080: 6f72 2073 6f6d 6520 7370 6172 7365 2072  or some sparse r
    │ │ │ -0007a090: 6570 7265 7365 6e74 6174 696f 6e20 6f66  epresentation of
    │ │ │ -0007a0a0: 2069 742c 0a09 2f2f 2064 6570 656e 6469   it,..// dependi
    │ │ │ -0007a0b0: 6e67 206f 6e20 6d5f 6d6f 6465 0a3c 6469  ng on m_mode..aux:
    │ │ │ -0007a0f0: 3a76 6563 746f 7226 6c74 3b73 6861 3235  :vector<sha25
    │ │ │ -0007a100: 365f 6861 7368 2667 743b 206d 5f74 7265  6_hash> m_tre
    │ │ │ -0007a110: 653b 0a3c 2f64 6976 3e0a 092f 2f20 7768  e;.
    ..// wh │ │ │ -0007a120: 656e 2074 6865 2066 756c 6c20 7472 6565 en the full tree │ │ │ -0007a130: 2069 7320 616c 6c6f 6361 7465 642c 2074 is allocated, t │ │ │ -0007a140: 6869 7320 6861 7320 6f6e 6520 6269 7420 his has one bit │ │ │ -0007a150: 666f 7220 6561 6368 2062 6c6f 636b 2068 for each block h │ │ │ -0007a160: 6173 682e 2061 0a09 2f2f 2031 206d 6561 ash. a..// 1 mea │ │ │ -0007a170: 6e73 2077 6520 6861 7665 2076 6572 6966 ns we have verif │ │ │ -0007a180: 6965 6420 7468 6520 626c 6f63 6b20 6861 ied the block ha │ │ │ -0007a190: 7368 2074 6f20 6265 2063 6f72 7265 6374 sh to be correct │ │ │ -0007a1a0: 2c20 6f74 6865 7277 6973 6520 7468 6520 , otherwise the │ │ │ -0007a1b0: 626c 6f63 6b0a 092f 2f20 6861 7368 206d block..// hash m │ │ │ -0007a1c0: 6179 2072 6570 7265 7365 6e74 2077 6861 ay represent wha │ │ │ -0007a1d0: 7427 7320 6f6e 2064 6973 6b2c 2062 7574 t's on disk, but │ │ │ -0007a1e0: 2077 6520 6861 7665 6e27 7420 6265 656e we haven't been │ │ │ -0007a1f0: 2061 626c 6520 746f 2076 6572 6966 7920 able to verify │ │ │ -0007a200: 6974 0a09 2f2f 2079 6574 0a09 6269 7466 it..// yet..bitf │ │ │ -0007a210: 6965 6c64 206d 5f62 6c6f 636b 5f76 6572 ield m_block_ver │ │ │ -0007a220: 6966 6965 643b 0a0a 092f 2f20 6e75 6d62 ified;...// numb │ │ │ -0007a230: 6572 206f 6620 626c 6f63 6b73 2069 6e20 er of blocks in │ │ │ -0007a240: 7468 6520 6669 6c65 2074 6869 7320 7472 the file this tr │ │ │ -0007a250: 6565 2072 6570 7265 7365 6e74 732e 2054 ee represents. T │ │ │ -0007a260: 6865 206e 756d 6265 7220 6f66 206c 6561 he number of lea │ │ │ -0007a270: 6673 2069 6e0a 092f 2f20 7468 6520 7472 fs in..// the tr │ │ │ -0007a280: 6565 2069 7320 726f 756e 6465 6420 7570 ee is rounded up │ │ │ -0007a290: 2074 6f20 616e 2065 7665 6e20 706f 7765 to an even powe │ │ │ -0007a2a0: 7220 6f66 2032 2e0a 0969 6e74 206d 5f6e r of 2...int m_n │ │ │ -0007a2b0: 756d 5f62 6c6f 636b 7320 3d20 303b 0a0a um_blocks = 0;.. │ │ │ -0007a2c0: 092f 2f20 7468 6520 6e75 6d62 6572 206f .// the number o │ │ │ -0007a2d0: 6620 626c 6f63 6b73 2070 6572 2070 6965 f blocks per pie │ │ │ -0007a2e0: 6365 2c20 7370 6563 6966 6965 6420 6173 ce, specified as │ │ │ -0007a2f0: 2068 6f77 206d 616e 7920 7374 6570 7320 how many steps │ │ │ -0007a300: 746f 2073 6869 6674 0a09 2f2f 2072 6967 to shift..// rig │ │ │ -0007a310: 6874 2031 2074 6f20 6765 7420 7468 6520 ht 1 to get the │ │ │ -0007a320: 6e75 6d62 6572 206f 6620 626c 6f63 6b73 number of blocks │ │ │ -0007a330: 2069 6e20 6f6e 6520 7069 6563 652e 2054 in one piece. T │ │ │ -0007a340: 6869 7320 6973 2061 2063 6f6d 7061 6374 his is a compact │ │ │ -0007a350: 0a09 2f2f 2072 6570 7265 7365 6e74 6174 ..// representat │ │ │ -0007a360: 696f 6e20 7468 6174 2773 2076 616c 6964 ion that's valid │ │ │ -0007a370: 2062 6563 6175 7365 2070 6965 6365 7320 because pieces │ │ │ -0007a380: 6172 6520 616c 7761 7973 2070 6f77 6572 are always power │ │ │ -0007a390: 7320 6f66 2032 2e0a 092f 2f20 7468 6973 s of 2...// this │ │ │ -0007a3a0: 2069 7320 6e65 6365 7373 6172 7920 746f is necessary to │ │ │ -0007a3b0: 206b 6e6f 7720 7768 6963 6820 6c61 7965 know which laye │ │ │ -0007a3c0: 7220 696e 2074 6865 2074 7265 6520 7468 r in the tree th │ │ │ -0007a3d0: 6520 7069 6563 6520 6c61 7965 7220 6973 e piece layer is │ │ │ -0007a3e0: 2e0a 0973 7464 3a3a 7569 6e74 385f 7420 ...std::uint8_t │ │ │ -0007a3f0: 6d5f 626c 6f63 6b73 5f70 6572 5f70 6965 m_blocks_per_pie │ │ │ -0007a400: 6365 5f6c 6f67 203d 2030 3b0a 0a09 656e ce_log = 0;...en │ │ │ -0007a410: 756d 2063 6c61 7373 206d 6f64 655f 7420 um class mode_t │ │ │ -0007a420: 3a20 7374 643a 3a75 696e 7438 5f74 0a09 : std::uint8_t.. │ │ │ -0007a430: 7b0a 0909 2f2f 2061 2064 6566 6175 6c74 {...// a default │ │ │ -0007a440: 2063 6f6e 7374 7275 6374 6564 2074 7265 constructed tre │ │ │ -0007a450: 6520 6973 2074 7275 6c79 2065 6d70 7479 e is truly empty │ │ │ -0007a460: 2e20 4974 2064 6f65 7320 6e6f 7420 6576 . It does not ev │ │ │ -0007a470: 656e 2068 6176 6520 610a 0909 2f2f 2072 en have a...// r │ │ │ -0007a480: 6f6f 7420 6861 7368 0a09 0975 6e69 6e69 oot hash...unini │ │ │ -0007a490: 7469 616c 697a 6564 5f74 7265 652c 0a0a tialized_tree,.. │ │ │ -0007a4a0: 0909 2f2f 2077 6520 646f 6e27 7420 6861 ..// we don't ha │ │ │ -0007a4b0: 7665 2061 6e79 2068 6173 6865 7320 696e ve any hashes in │ │ │ -0007a4c0: 2074 6869 7320 7472 6565 2e20 6d5f 7472 this tree. m_tr │ │ │ -0007a4d0: 6565 2073 686f 756c 6420 6265 2065 6d70 ee should be emp │ │ │ -0007a4e0: 7479 0a09 092f 2f20 616e 2065 6d70 7479 ty...// an empty │ │ │ -0007a4f0: 2074 7265 6520 7374 696c 6c20 616c 7761 tree still alwa │ │ │ -0007a500: 7973 2068 6176 6520 7468 6520 726f 6f74 ys have the root │ │ │ -0007a510: 2068 6173 6820 2861 7661 696c 6162 6c65 hash (available │ │ │ -0007a520: 2061 7320 726f 6f74 2829 290a 0909 656d as root())...em │ │ │ -0007a530: 7074 795f 7472 6565 2c0a 0a09 092f 2f20 pty_tree,....// │ │ │ -0007a540: 696e 2074 6869 7320 6d6f 6465 2c20 6d5f in this mode, m_ │ │ │ -0007a550: 7472 6565 2072 6570 7265 7365 6e74 7320 tree represents │ │ │ -0007a560: 7468 6520 6675 6c6c 2074 7265 652c 2069 the full tree, i │ │ │ -0007a570: 6e63 6c75 6469 6e67 2070 6164 6469 6e67 ncluding padding │ │ │ -0007a580: 2e0a 0909 6675 6c6c 5f74 7265 652c 0a0a ....full_tree,.. │ │ │ -0007a590: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e │ │ │ -0007a5a0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ -0007a5d0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../in │ │ │ -0007a600: 636c 7564 652f 6c69 6274 6f72 7265 6e74 clude/libtorrent │ │ │ -0007a610: 2f61 7578 5f2f 7265 6164 7772 6974 652e /aux_/readwrite. │ │ │ -0007a620: 6870 703a 3235 353c 2f61 3e3c 2f74 643e hpp:255 │ │ │ -0007a630: 3c74 643e 6973 2069 7420 7265 616c 6c79 is it really │ │ │ -0007a640: 206e 6563 6573 7361 7279 2074 6f20 6d61 necessary to ma │ │ │ -0007a650: 6b65 2074 776f 2063 6f70 6965 7320 6f66 ke two copies of │ │ │ -0007a660: 2074 6865 2069 6f76 6563 733f 2054 6865 the iovecs? The │ │ │ -0007a670: 206c 6f77 2d6c 6576 656c 2073 7973 7465 low-level syste │ │ │ -0007a680: 6d20 6361 6c6c 2077 696c 6c20 6e65 6564 m call will need │ │ │ -0007a690: 2074 6f20 6d61 6b65 2069 7473 206f 776e to make its own │ │ │ -0007a6a0: 2063 6f70 7920 6173 2077 656c 6c3c 2f74 copy as well

    is it │ │ │ -0007a700: 2072 6561 6c6c 7920 6e65 6365 7373 6172 really necessar │ │ │ -0007a710: 7920 746f 206d 616b 6520 7477 6f20 636f y to make two co │ │ │ -0007a720: 7069 6573 206f 6620 7468 6520 696f 7665 pies of the iove │ │ │ -0007a730: 6373 3f20 5468 6520 6c6f 772d 6c65 7665 cs? The low-leve │ │ │ -0007a740: 6c0a 7379 7374 656d 2063 616c 6c20 7769 l.system call wi │ │ │ -0007a750: 6c6c 206e 6565 6420 746f 206d 616b 6520 ll need to make │ │ │ -0007a760: 6974 7320 6f77 6e20 636f 7079 2061 7320 its own copy as │ │ │ -0007a770: 7765 6c6c 3c2f 6832 3e3c 6834 3e2e 2e2f well

    ../ │ │ │ -0007a780: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -0007a790: 6e74 2f61 7578 5f2f 7265 6164 7772 6974 nt/aux_/readwrit │ │ │ -0007a7a0: 652e 6870 703a 3235 353c 2f68 343e 3c70 e.hpp:255

    .TORRENT │ │ │ -0007a7f0: 5f41 5353 4552 5428 7374 6174 6963 5f63 _ASSERT(static_c │ │ │ -0007a800: 6173 7426 6c74 3b69 6e74 2667 743b 2870 ast<int>(p │ │ │ -0007a810: 6965 6365 2920 2a20 7374 6174 6963 5f63 iece) * static_c │ │ │ -0007a820: 6173 7426 6c74 3b73 7464 3a3a 696e 7436 ast<std::int6 │ │ │ -0007a830: 345f 7426 6774 3b28 6669 6c65 732e 7069 4_t>(files.pi │ │ │ -0007a840: 6563 655f 6c65 6e67 7468 2829 290a 0909 ece_length())... │ │ │ -0007a850: 2b20 6f66 6673 6574 202b 2073 697a 6520 + offset + size │ │ │ -0007a860: 266c 743b 3d20 6669 6c65 732e 746f 7461 <= files.tota │ │ │ -0007a870: 6c5f 7369 7a65 2829 293b 0a0a 092f 2f20 l_size());...// │ │ │ -0007a880: 6669 6e64 2074 6865 2066 696c 6520 6974 find the file it │ │ │ -0007a890: 6572 6174 6f72 2061 6e64 2066 696c 6520 erator and file │ │ │ -0007a8a0: 6f66 6673 6574 0a09 7374 643a 3a69 6e74 offset..std::int │ │ │ -0007a8b0: 3634 5f74 2063 6f6e 7374 2074 6f72 7265 64_t const torre │ │ │ -0007a8c0: 6e74 5f6f 6666 7365 7420 3d20 7374 6174 nt_offset = stat │ │ │ -0007a8d0: 6963 5f63 6173 7426 6c74 3b69 6e74 2667 ic_cast<int&g │ │ │ -0007a8e0: 743b 2870 6965 6365 2920 2a20 7374 643a t;(piece) * std: │ │ │ -0007a8f0: 3a69 6e74 3634 5f74 2866 696c 6573 2e70 :int64_t(files.p │ │ │ -0007a900: 6965 6365 5f6c 656e 6774 6828 2929 202b iece_length()) + │ │ │ -0007a910: 206f 6666 7365 743b 0a09 6669 6c65 5f69 offset;..file_i │ │ │ -0007a920: 6e64 6578 5f74 2066 696c 655f 696e 6465 ndex_t file_inde │ │ │ -0007a930: 7820 3d20 6669 6c65 732e 6669 6c65 5f69 x = files.file_i │ │ │ -0007a940: 6e64 6578 5f61 745f 6f66 6673 6574 2874 ndex_at_offset(t │ │ │ -0007a950: 6f72 7265 6e74 5f6f 6666 7365 7429 3b0a orrent_offset);. │ │ │ -0007a960: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ -0007a970: 746f 7272 656e 745f 6f66 6673 6574 2026 torrent_offset & │ │ │ -0007a980: 6774 3b3d 2066 696c 6573 2e66 696c 655f gt;= files.file_ │ │ │ -0007a990: 6f66 6673 6574 2866 696c 655f 696e 6465 offset(file_inde │ │ │ -0007a9a0: 7829 293b 0a09 544f 5252 454e 545f 4153 x));..TORRENT_AS │ │ │ -0007a9b0: 5345 5254 2874 6f72 7265 6e74 5f6f 6666 SERT(torrent_off │ │ │ -0007a9c0: 7365 7420 266c 743b 2066 696c 6573 2e66 set < files.f │ │ │ -0007a9d0: 696c 655f 6f66 6673 6574 2866 696c 655f ile_offset(file_ │ │ │ -0007a9e0: 696e 6465 7829 202b 2066 696c 6573 2e66 index) + files.f │ │ │ -0007a9f0: 696c 655f 7369 7a65 2866 696c 655f 696e ile_size(file_in │ │ │ -0007aa00: 6465 7829 293b 0a09 7374 643a 3a69 6e74 dex));..std::int │ │ │ -0007aa10: 3634 5f74 2066 696c 655f 6f66 6673 6574 64_t file_offset │ │ │ -0007aa20: 203d 2074 6f72 7265 6e74 5f6f 6666 7365 = torrent_offse │ │ │ -0007aa30: 7420 2d20 6669 6c65 732e 6669 6c65 5f6f t - files.file_o │ │ │ -0007aa40: 6666 7365 7428 6669 6c65 5f69 6e64 6578 ffset(file_index │ │ │ -0007aa50: 293b 0a0a 092f 2f20 7468 6520 6e75 6d62 );...// the numb │ │ │ -0007aa60: 6572 206f 6620 6279 7465 7320 6c65 6674 er of bytes left │ │ │ -0007aa70: 2062 6566 6f72 6520 7468 6973 2072 6561 before this rea │ │ │ -0007aa80: 6420 6f72 2077 7269 7465 206f 7065 7261 d or write opera │ │ │ -0007aa90: 7469 6f6e 2069 730a 092f 2f20 636f 6d70 tion is..// comp │ │ │ -0007aaa0: 6c65 7465 6c79 2073 6174 6973 6669 6564 letely satisfied │ │ │ -0007aab0: 2e0a 0969 6e74 2062 7974 6573 5f6c 6566 ...int bytes_lef │ │ │ -0007aac0: 7420 3d20 7369 7a65 3b0a 0a09 544f 5252 t = size;...TORR │ │ │ -0007aad0: 454e 545f 4153 5345 5254 2862 7974 6573 ENT_ASSERT(bytes │ │ │ -0007aae0: 5f6c 6566 7420 2667 743b 3d20 3029 3b0a _left >= 0);. │ │ │ -0007aaf0: 0a09 2f2f 2063 6f70 7920 7468 6520 696f ..// copy the io │ │ │ -0007ab00: 7665 6320 6172 7261 7920 736f 2077 6520 vec array so we │ │ │ -0007ab10: 6361 6e20 7573 6520 6974 2074 6f20 6b65 can use it to ke │ │ │ -0007ab20: 6570 2074 7261 636b 206f 6620 6f75 7220 ep track of our │ │ │ -0007ab30: 6375 7272 656e 740a 092f 2f20 6c6f 6361 current..// loca │ │ │ -0007ab40: 7469 6f6e 2062 7920 7570 6461 7469 6e67 tion by updating │ │ │ -0007ab50: 2074 6865 2068 6561 6420 6261 7365 2070 the head base p │ │ │ -0007ab60: 6f69 6e74 6572 2061 6e64 2073 697a 652e ointer and size. │ │ │ -0007ab70: 2028 7365 650a 092f 2f20 6164 7661 6e63 (see..// advanc │ │ │ -0007ab80: 655f 6275 6673 2829 290a 0a3c 6469 7620 e_bufs())..

    .TORREN │ │ │ -0007abc0: 545f 414c 4c4f 4341 2863 7572 7265 6e74 T_ALLOCA(current │ │ │ -0007abd0: 5f62 7566 2c20 7370 616e 266c 743b 4368 _buf, span<Ch │ │ │ -0007abe0: 6172 2667 743b 2c20 6275 6673 2e73 697a ar>, bufs.siz │ │ │ -0007abf0: 6528 2929 3b0a 3c2f 6469 763e 0963 6f70 e());.
    .cop │ │ │ -0007ac00: 795f 6275 6673 2862 7566 732c 2073 697a y_bufs(bufs, siz │ │ │ -0007ac10: 652c 2063 7572 7265 6e74 5f62 7566 293b e, current_buf); │ │ │ -0007ac20: 0a09 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ -0007ac30: 2863 6f75 6e74 5f62 7566 7328 6375 7272 (count_bufs(curr │ │ │ -0007ac40: 656e 745f 6275 662c 2073 697a 6529 203d ent_buf, size) = │ │ │ -0007ac50: 3d20 696e 7428 6275 6673 2e73 697a 6528 = int(bufs.size( │ │ │ -0007ac60: 2929 293b 0a0a 0954 4f52 5245 4e54 5f41 )));...TORRENT_A │ │ │ -0007ac70: 4c4c 4f43 4128 746d 705f 6275 662c 2073 LLOCA(tmp_buf, s │ │ │ -0007ac80: 7061 6e26 6c74 3b43 6861 7226 6774 3b2c pan<Char>, │ │ │ -0007ac90: 2062 7566 732e 7369 7a65 2829 293b 0a09 bufs.size());.. │ │ │ -0007aca0: 7768 696c 6520 2862 7974 6573 5f6c 6566 while (bytes_lef │ │ │ -0007acb0: 7420 2667 743b 2030 290a 097b 0a09 092f t > 0)..{.../ │ │ │ -0007acc0: 2f20 7468 6520 6e75 6d62 6572 206f 6620 / the number of │ │ │ -0007acd0: 6279 7465 7320 6c65 6674 2074 6f20 7265 bytes left to re │ │ │ -0007ace0: 6164 2069 6e20 7468 6520 6375 7272 656e ad in the curren │ │ │ -0007acf0: 7420 6669 6c65 2028 7370 6563 6966 6965 t file (specifie │ │ │ -0007ad00: 6420 6279 0a09 092f 2f20 6669 6c65 5f69 d by...// file_i │ │ │ -0007ad10: 6e64 6578 292e 2054 6869 7320 6973 2074 ndex). This is t │ │ │ -0007ad20: 6865 206d 696e 696d 756d 206f 6620 2866 he minimum of (f │ │ │ -0007ad30: 696c 655f 7369 7a65 202d 2066 696c 655f ile_size - file_ │ │ │ -0007ad40: 6f66 6673 6574 2920 616e 640a 0909 2f2f offset) and...// │ │ │ -0007ad50: 2062 7974 6573 5f6c 6566 742e 0a09 0969 bytes_left....i │ │ │ -0007ad60: 6e74 2066 696c 655f 6279 7465 735f 6c65 nt file_bytes_le │ │ │ -0007ad70: 6674 203d 2062 7974 6573 5f6c 6566 743b ft = bytes_left; │ │ │ -0007ad80: 0a09 0969 6620 2866 696c 655f 6f66 6673 ...if (file_offs │ │ │ -0007ad90: 6574 202b 2066 696c 655f 6279 7465 735f et + file_bytes_ │ │ │ -0007ada0: 6c65 6674 2026 6774 3b20 6669 6c65 732e left > files. │ │ │ -0007adb0: 6669 6c65 5f73 697a 6528 6669 6c65 5f69 file_size(file_i │ │ │ -0007adc0: 6e64 6578 2929 0a09 0909 6669 6c65 5f62 ndex))....file_b │ │ │ -0007add0: 7974 6573 5f6c 6566 7420 3d20 7374 643a ytes_left = std: │ │ │ -0007ade0: 3a6d 6178 2873 7461 7469 635f 6361 7374 :max(static_cast │ │ │ -0007adf0: 266c 743b 696e 7426 6774 3b28 6669 6c65 <int>(file │ │ │ -0007ae00: 732e 6669 6c65 5f73 697a 6528 6669 6c65 s.file_size(file │ │ │ -0007ae10: 5f69 6e64 6578 2920 2d20 6669 6c65 5f6f _index) - file_o │ │ │ -0007ae20: 6666 7365 7429 2c20 3029 3b0a 0a09 092f ffset), 0);..../ │ │ │ -0007ae30: 2f20 7468 6572 6520 6172 6520 6e6f 2062 / there are no b │ │ │ -0007ae40: 7974 6573 206c 6566 7420 696e 2074 6869 ytes left in thi │ │ │ -0007ae50: 7320 6669 6c65 2c20 6d6f 7665 2074 6f20 s file, move to │ │ │ -0007ae60: 7468 6520 6e65 7874 206f 6e65 0a09 092f the next one.../ │ │ │ -0007ae70: 2f20 7468 6973 206c 6f6f 7020 736b 6970 / this loop skip │ │ │ -0007ae80: 7320 6f76 6572 2065 6d70 7479 2066 696c s over empty fil │ │ │ -0007ae90: 6573 0a09 0977 6869 6c65 2028 6669 6c65 es...while (file │ │ │ -0007aea0: 5f62 7974 6573 5f6c 6566 7420 3d3d 2030 _bytes_left == 0 │ │ │ -0007aeb0: 290a 0909 7b0a 0909 092b 2b66 696c 655f )...{....++file_ │ │ │ -0007aec0: 696e 6465 783b 0a09 0909 6669 6c65 5f6f index;....file_o │ │ │ -0007aed0: 6666 7365 7420 3d20 303b 0a09 0909 544f ffset = 0;....TO │ │ │ -0007aee0: 5252 454e 545f 4153 5345 5254 2866 696c RRENT_ASSERT(fil │ │ │ -0007aef0: 655f 696e 6465 7820 266c 743b 2066 696c e_index < fil │ │ │ -0007af00: 6573 2e65 6e64 5f66 696c 6528 2929 3b0a es.end_file());. │ │ │ -0007af10: 0a09 0909 2f2f 2074 6869 7320 7368 6f75 ....// this shou │ │ │ -0007af20: 6c64 206e 6f74 2068 6170 7065 6e2e 2062 ld not happen. b │ │ │ -0007af30: 7974 6573 5f6c 6566 7420 7368 6f75 6c64 ytes_left should │ │ │ -0007af40: 2062 6520 636c 616d 7065 6420 6279 2074 be clamped by t │ │ │ -0007af50: 6865 2074 6f74 616c 0a09 0909 2f2f 2073 he total....// s │ │ │ -0007af60: 697a 6520 6f66 2074 6865 2074 6f72 7265 ize of the torre │ │ │ -0007af70: 6e74 2c20 736f 2077 6520 7368 6f75 6c64 nt, so we should │ │ │ -0007af80: 206e 6576 6572 2072 756e 206f 6666 2074 never run off t │ │ │ -0007af90: 6865 2065 6e64 206f 6620 6974 0a09 0909 he end of it.... │ │ │ -0007afa0: 6966 2028 6669 6c65 5f69 6e64 6578 2026 if (file_index & │ │ │ -0007afb0: 6774 3b3d 2066 696c 6573 2e65 6e64 5f66 gt;= files.end_f │ │ │ -0007afc0: 696c 6528 2929 2072 6574 7572 6e20 7369 ile()) return si │ │ │ -0007afd0: 7a65 3b0a 0a09 0909 6669 6c65 5f62 7974 ze;.....file_byt │ │ │ -0007afe0: 6573 5f6c 6566 7420 3d20 6279 7465 735f es_left = bytes_ │ │ │ -0007aff0: 6c65 6674 3b0a 0a09 0909 6966 2028 6669 left;.....if (fi │ │ │ -0007b000: 6c65 5f6f 6666 7365 7420 2b20 6669 6c65 le_offset + file │ │ │ -0007b010: 5f62 7974 6573 5f6c 6566 7420 2667 743b _bytes_left > │ │ │ -0007b020: 2066 696c 6573 2e66 696c 655f 7369 7a65 files.file_size │ │ │ -0007b030: 2866 696c 655f 696e 6465 7829 290a 0909 (file_index))... │ │ │ -0007b040: 0909 6669 6c65 5f62 7974 6573 5f6c 6566 ..file_bytes_lef │ │ │ -0007b050: 7420 3d20 7374 643a 3a6d 6178 2873 7461 t = std::max(sta │ │ │ -0007b060: 7469 635f 6361 7374 266c 743b 696e 7426 tic_cast<int& │ │ │ -0007b070: 6774 3b28 6669 6c65 732e 6669 6c65 5f73 gt;(files.file_s │ │ │ -0007b080: 697a 6528 6669 6c65 5f69 6e64 6578 2920 ize(file_index) │ │ │ -0007b090: 2d20 6669 6c65 5f6f 6666 7365 7429 2c20 - file_offset), │ │ │ -0007b0a0: 3029 3b0a 0909 7d0a 3c2f 7072 653e 3c2f 0);...}.relevan │ │ │ -0007b0e0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../include/li │ │ │ -0007b120: 6274 6f72 7265 6e74 2f61 7578 5f2f 6469 btorrent/aux_/di │ │ │ -0007b130: 736b 5f69 6f5f 7468 7265 6164 5f70 6f6f sk_io_thread_poo │ │ │ -0007b140: 6c2e 6870 703a 3330 3c2f 613e 3c2f 7464 l.hpp:30move into a │ │ │ -0007b160: 7578 206e 616d 6573 7061 6365 3c2f 7464 ux namespace

    move i │ │ │ -0007b1c0: 6e74 6f20 6175 7820 6e61 6d65 7370 6163 nto aux namespac │ │ │ -0007b1d0: 653c 2f68 323e 3c68 343e 2e2e 2f69 6e63 e

    ../inc │ │ │ -0007b1e0: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -0007b1f0: 6175 785f 2f64 6973 6b5f 696f 5f74 6872 aux_/disk_io_thr │ │ │ -0007b200: 6561 645f 706f 6f6c 2e68 7070 3a33 303c ead_pool.hpp:30< │ │ │ -0007b210: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    */
    │ │ │ -0007b250: 0a0a 2369 666e 6465 6620 544f 5252 454e  ..#ifndef TORREN
    │ │ │ -0007b260: 545f 4449 534b 5f49 4f5f 5448 5245 4144  T_DISK_IO_THREAD
    │ │ │ -0007b270: 5f50 4f4f 4c0a 2364 6566 696e 6520 544f  _POOL.#define TO
    │ │ │ -0007b280: 5252 454e 545f 4449 534b 5f49 4f5f 5448  RRENT_DISK_IO_TH
    │ │ │ -0007b290: 5245 4144 5f50 4f4f 4c0a 0a23 696e 636c  READ_POOL..#incl
    │ │ │ -0007b2a0: 7564 6520 226c 6962 746f 7272 656e 742f  ude "libtorrent/
    │ │ │ -0007b2b0: 636f 6e66 6967 2e68 7070 220a 2369 6e63  config.hpp".#inc
    │ │ │ -0007b2c0: 6c75 6465 2022 6c69 6274 6f72 7265 6e74  lude "libtorrent
    │ │ │ -0007b2d0: 2f61 7578 5f2f 6578 706f 7274 2e68 7070  /aux_/export.hpp
    │ │ │ -0007b2e0: 220a 2369 6e63 6c75 6465 2022 6c69 6274  ".#include "libt
    │ │ │ -0007b2f0: 6f72 7265 6e74 2f61 7578 5f2f 6465 6164  orrent/aux_/dead
    │ │ │ -0007b300: 6c69 6e65 5f74 696d 6572 2e68 7070 220a  line_timer.hpp".
    │ │ │ -0007b310: 0a23 696e 636c 7564 6520 226c 6962 746f  .#include "libto
    │ │ │ -0007b320: 7272 656e 742f 6175 785f 2f64 6973 6b5f  rrent/aux_/disk_
    │ │ │ -0007b330: 6a6f 622e 6870 7022 0a23 696e 636c 7564  job.hpp".#includ
    │ │ │ -0007b340: 6520 226c 6962 746f 7272 656e 742f 6175  e "libtorrent/au
    │ │ │ -0007b350: 785f 2f64 6562 7567 2e68 7070 220a 2369  x_/debug.hpp".#i
    │ │ │ -0007b360: 6e63 6c75 6465 2022 6c69 6274 6f72 7265  nclude "libtorre
    │ │ │ -0007b370: 6e74 2f69 6f5f 636f 6e74 6578 742e 6870  nt/io_context.hp
    │ │ │ -0007b380: 7022 0a23 696e 636c 7564 6520 226c 6962  p".#include "lib
    │ │ │ -0007b390: 746f 7272 656e 742f 6572 726f 725f 636f  torrent/error_co
    │ │ │ -0007b3a0: 6465 2e68 7070 220a 0a23 696e 636c 7564  de.hpp"..#includ
    │ │ │ -0007b3b0: 6520 266c 743b 7468 7265 6164 2667 743b  e <thread>
    │ │ │ -0007b3c0: 0a23 696e 636c 7564 6520 266c 743b 6d75  .#include <mu
    │ │ │ -0007b3d0: 7465 7826 6774 3b0a 2369 6e63 6c75 6465  tex>.#include
    │ │ │ -0007b3e0: 2026 6c74 3b61 746f 6d69 6326 6774 3b0a   <atomic>.
    │ │ │ -0007b3f0: 2369 6e63 6c75 6465 2026 6c74 3b63 6f6e  #include <con
    │ │ │ -0007b400: 6469 7469 6f6e 5f76 6172 6961 626c 6526  dition_variable&
    │ │ │ -0007b410: 6774 3b0a 0a6e 616d 6573 7061 6365 206c  gt;..namespace l
    │ │ │ -0007b420: 6962 746f 7272 656e 7420 7b0a 3c64 6976  ibtorrent {.
    .using │ │ │ -0007b460: 206a 6f62 7175 6575 655f 7420 3d20 6175 jobqueue_t = au │ │ │ -0007b470: 783a 3a74 6169 6c71 7565 7565 266c 743b x::tailqueue< │ │ │ -0007b480: 6175 783a 3a64 6973 6b5f 6a6f 6226 6774 aux::disk_job> │ │ │ -0007b490: 3b3b 0a3c 2f64 6976 3e7d 0a0a 6e61 6d65 ;;.
    }..name │ │ │ -0007b4a0: 7370 6163 6520 6c69 6274 6f72 7265 6e74 space libtorrent │ │ │ -0007b4b0: 3a3a 6175 7820 7b0a 0a09 7374 7275 6374 ::aux {...struct │ │ │ -0007b4c0: 2064 6973 6b5f 696f 5f74 6872 6561 645f disk_io_thread_ │ │ │ -0007b4d0: 706f 6f6c 3b0a 0a09 7573 696e 6720 6469 pool;...using di │ │ │ -0007b4e0: 736b 5f74 6872 6561 645f 6675 6e20 3d20 sk_thread_fun = │ │ │ -0007b4f0: 7374 643a 3a66 756e 6374 696f 6e26 6c74 std::function< │ │ │ -0007b500: 3b76 6f69 6428 0a09 0961 7578 3a3a 6469 ;void(...aux::di │ │ │ -0007b510: 736b 5f69 6f5f 7468 7265 6164 5f70 6f6f sk_io_thread_poo │ │ │ -0007b520: 6c26 616d 703b 2c20 6578 6563 7574 6f72 l&, executor │ │ │ -0007b530: 5f77 6f72 6b5f 6775 6172 6426 6c74 3b69 _work_guard<i │ │ │ -0007b540: 6f5f 636f 6e74 6578 743a 3a65 7865 6375 o_context::execu │ │ │ -0007b550: 746f 725f 7479 7065 2667 743b 2077 6f72 tor_type> wor │ │ │ -0007b560: 6b29 2667 743b 3b0a 0a09 656e 756d 2063 k)>;...enum c │ │ │ -0007b570: 6c61 7373 2077 6169 745f 7265 7375 6c74 lass wait_result │ │ │ -0007b580: 3a20 7374 643a 3a75 696e 7438 5f74 0a09 : std::uint8_t.. │ │ │ -0007b590: 7b0a 0909 6e65 775f 6a6f 622c 0a09 0965 {...new_job,...e │ │ │ -0007b5a0: 7869 745f 7468 7265 6164 2c0a 0909 696e xit_thread,...in │ │ │ -0007b5b0: 7465 7272 7570 742c 0a09 7d3b 0a0a 092f terrupt,..};.../ │ │ │ -0007b5c0: 2f20 7468 6973 2063 6c61 7373 2069 6d70 / this class imp │ │ │ -0007b5d0: 6c65 6d65 6e74 7320 7468 6520 706f 6c69 lements the poli │ │ │ -0007b5e0: 6379 2066 6f72 2063 7265 6174 696e 6720 cy for creating │ │ │ -0007b5f0: 616e 6420 6465 7374 726f 7969 6e67 2049 and destroying I │ │ │ -0007b600: 2f4f 2074 6872 6561 6473 0a09 2f2f 2074 /O threads..// t │ │ │ -0007b610: 6872 6561 6473 2061 7265 2063 7265 6174 hreads are creat │ │ │ -0007b620: 6564 2077 6865 6e20 6a6f 625f 7175 6575 ed when job_queu │ │ │ -0007b630: 6564 2069 7320 6361 6c6c 6564 2074 6f20 ed is called to │ │ │ -0007b640: 7369 676e 616c 2074 6865 2061 7272 6976 signal the arriv │ │ │ -0007b650: 616c 206f 660a 092f 2f20 6e65 7720 6a6f al of..// new jo │ │ │ -0007b660: 6273 0a09 2f2f 206f 6e63 6520 6120 6d69 bs..// once a mi │ │ │ -0007b670: 6e75 7465 2074 6872 6561 6473 2061 7265 nute threads are │ │ │ -0007b680: 2064 6573 7472 6f79 6564 2069 6620 6174 destroyed if at │ │ │ -0007b690: 206c 6561 7374 206f 6e65 2074 6872 6561 least one threa │ │ │ -0007b6a0: 6420 6861 7320 6265 656e 0a09 2f2f 2069 d has been..// i │ │ │ -0007b6b0: 646c 6520 666f 7220 7468 6520 656e 7469 dle for the enti │ │ │ -0007b6c0: 7265 206d 696e 7574 650a 092f 2f20 7468 re minute..// th │ │ │ -0007b6d0: 6520 706f 6f6c 5f74 6872 6561 645f 696e e pool_thread_in │ │ │ -0007b6e0: 7465 7266 6163 6520 6973 2075 7365 6420 terface is used │ │ │ -0007b6f0: 746f 2073 7061 776e 2061 6e64 206e 6f74 to spawn and not │ │ │ -0007b700: 6966 7920 7468 6520 776f 726b 6572 2074 ify the worker t │ │ │ -0007b710: 6872 6561 6473 0a09 7374 7275 6374 2054 hreads..struct T │ │ │ -0007b720: 4f52 5245 4e54 5f45 5854 5241 5f45 5850 ORRENT_EXTRA_EXP │ │ │ -0007b730: 4f52 5420 6469 736b 5f69 6f5f 7468 7265 ORT disk_io_thre │ │ │ -0007b740: 6164 5f70 6f6f 6c0a 097b 0a09 0964 6973 ad_pool..{...dis │ │ │ -0007b750: 6b5f 696f 5f74 6872 6561 645f 706f 6f6c k_io_thread_pool │ │ │ -0007b760: 2864 6973 6b5f 7468 7265 6164 5f66 756e (disk_thread_fun │ │ │ -0007b770: 2074 6872 6561 645f 6675 6e2c 2069 6f5f thread_fun, io_ │ │ │ -0007b780: 636f 6e74 6578 7426 616d 703b 2069 6f73 context& ios │ │ │ -0007b790: 293b 0a09 097e 6469 736b 5f69 6f5f 7468 );...~disk_io_th │ │ │ -0007b7a0: 7265 6164 5f70 6f6f 6c28 293b 0a0a 0909 read_pool();.... │ │ │ -0007b7b0: 2f2f 2073 6574 2074 6865 206d 6178 696d // set the maxim │ │ │ -0007b7c0: 756d 206e 756d 6265 7220 6f66 2049 2f4f um number of I/O │ │ │ -0007b7d0: 2074 6872 6561 6473 2077 6869 6368 206d threads which m │ │ │ -0007b7e0: 6179 2062 6520 7275 6e6e 696e 670a 0909 ay be running... │ │ │ -0007b7f0: 2f2f 2074 6865 2061 6374 7561 6c20 6e75 // the actual nu │ │ │ -0007b800: 6d62 6572 206f 6620 7468 7265 6164 7320 mber of threads │ │ │ -0007b810: 7769 6c6c 2062 6520 266c 743b 3d20 7468 will be <= th │ │ │ -0007b820: 6973 206e 756d 6265 720a 0909 766f 6964 is number...void │ │ │ -0007b830: 2073 6574 5f6d 6178 5f74 6872 6561 6473 set_max_threads │ │ │ -0007b840: 2869 6e74 2069 293b 0a3c 2f70 7265 3e3c (int i);.
    < │ │ │ -0007b850: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ -0007b880: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ -0007b890: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../include/l │ │ │ -0007b8c0: 6962 746f 7272 656e 742f 6175 785f 2f64 ibtorrent/aux_/d │ │ │ -0007b8d0: 6973 6b5f 696f 5f74 6872 6561 645f 706f isk_io_thread_po │ │ │ -0007b8e0: 6f6c 2e68 7070 3a31 3036 3c2f 613e 3c2f ol.hpp:106the job m │ │ │ -0007b900: 7574 6578 206d 7573 7420 6265 2068 656c utex must be hel │ │ │ -0007b910: 6420 7768 656e 2074 6869 7320 6973 2063 d when this is c │ │ │ -0007b920: 616c 6c65 643c 2f74 643e 3c2f 7472 3e3c alled< │ │ │ -0007b930: 7472 2069 643d 2232 3739 2220 7374 796c tr id="279" styl │ │ │ -0007b940: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -0007b950: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -0007b960: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -0007b970: 6832 3e74 6865 206a 6f62 206d 7574 6578 h2>the job mutex │ │ │ -0007b980: 206d 7573 7420 6265 2068 656c 6420 7768 must be held wh │ │ │ -0007b990: 656e 2074 6869 7320 6973 2063 616c 6c65 en this is calle │ │ │ -0007b9a0: 643c 2f68 323e 3c68 343e 2e2e 2f69 6e63 d

    ../inc │ │ │ -0007b9b0: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -0007b9c0: 6175 785f 2f64 6973 6b5f 696f 5f74 6872 aux_/disk_io_thr │ │ │ -0007b9d0: 6561 645f 706f 6f6c 2e68 7070 3a31 3036 ead_pool.hpp:106 │ │ │ -0007b9e0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ -0007ba20: 092f 2f20 7468 6973 2069 7320 6120 7765  .// this is a we
    │ │ │ -0007ba30: 616b 2063 6865 636b 2c20 6966 2069 7420  ak check, if it 
    │ │ │ -0007ba40: 7265 7475 726e 7320 7472 7565 2074 7279  returns true try
    │ │ │ -0007ba50: 5f74 6872 6561 645f 6578 6974 206d 6179  _thread_exit may
    │ │ │ -0007ba60: 2073 7469 6c6c 0a09 092f 2f20 7265 7475   still...// retu
    │ │ │ -0007ba70: 726e 2066 616c 7365 0a09 0962 6f6f 6c20  rn false...bool 
    │ │ │ -0007ba80: 7368 6f75 6c64 5f65 7869 7428 2920 7b20  should_exit() { 
    │ │ │ -0007ba90: 7265 7475 726e 206d 5f74 6872 6561 6473  return m_threads
    │ │ │ -0007baa0: 5f74 6f5f 6578 6974 2026 6774 3b20 303b  _to_exit > 0;
    │ │ │ -0007bab0: 207d 0a09 092f 2f20 7468 6973 2073 686f   }...// this sho
    │ │ │ -0007bac0: 756c 6420 6265 2074 6865 206c 6173 7420  uld be the last 
    │ │ │ -0007bad0: 6675 6e63 7469 6f6e 2061 6e20 492f 4f20  function an I/O 
    │ │ │ -0007bae0: 7468 7265 6164 2063 616c 6c73 2062 6566  thread calls bef
    │ │ │ -0007baf0: 6f72 6520 6272 6561 6b69 6e67 0a09 092f  ore breaking.../
    │ │ │ -0007bb00: 2f20 6f75 7420 6f66 2069 7473 2073 6572  / out of its ser
    │ │ │ -0007bb10: 7669 6365 206c 6f6f 700a 0909 2f2f 2069  vice loop...// i
    │ │ │ -0007bb20: 6620 6974 2072 6574 7572 6e73 2074 7275  f it returns tru
    │ │ │ -0007bb30: 6520 7468 656e 2074 6865 2074 6872 6561  e then the threa
    │ │ │ -0007bb40: 6420 4d55 5354 2065 7869 740a 0909 2f2f  d MUST exit...//
    │ │ │ -0007bb50: 2069 6620 6974 2072 6574 7572 6e73 2066   if it returns f
    │ │ │ -0007bb60: 616c 7365 2074 6865 2074 6872 6561 6420  alse the thread 
    │ │ │ -0007bb70: 7368 6f75 6c64 206e 6f74 2065 7869 740a  should not exit.
    │ │ │ -0007bb80: 0909 626f 6f6c 2074 7279 5f74 6872 6561  ..bool try_threa
    │ │ │ -0007bb90: 645f 6578 6974 2873 7464 3a3a 7468 7265  d_exit(std::thre
    │ │ │ -0007bba0: 6164 3a3a 6964 2069 6429 3b0a 0a09 092f  ad::id id);..../
    │ │ │ -0007bbb0: 2f20 6765 7420 7468 6520 7468 7265 6164  / get the thread
    │ │ │ -0007bbc0: 2069 6420 6f66 2074 6865 2066 6972 7374   id of the first
    │ │ │ -0007bbd0: 2074 6872 6561 6420 696e 2074 6865 2069   thread in the i
    │ │ │ -0007bbe0: 6e74 6572 6e61 6c20 7665 6374 6f72 0a09  nternal vector..
    │ │ │ -0007bbf0: 092f 2f20 7369 6e63 6520 7468 6973 2069  .// since this i
    │ │ │ -0007bc00: 7320 7468 6520 6669 7273 7420 7468 7265  s the first thre
    │ │ │ -0007bc10: 6164 2069 7420 7769 6c6c 2072 656d 6169  ad it will remai
    │ │ │ -0007bc20: 6e20 7468 6520 7361 6d65 2075 6e74 696c  n the same until
    │ │ │ -0007bc30: 2074 6865 2066 6972 7374 0a09 092f 2f20   the first...// 
    │ │ │ -0007bc40: 7468 7265 6164 2065 7869 7473 0a09 092f  thread exits.../
    │ │ │ -0007bc50: 2f20 6974 2063 616e 2062 6520 7573 6564  / it can be used
    │ │ │ -0007bc60: 2074 6f20 7472 6967 6765 7220 6d61 696e   to trigger main
    │ │ │ -0007bc70: 7465 6e61 6e63 6520 6a6f 6273 2077 6869  tenance jobs whi
    │ │ │ -0007bc80: 6368 2073 686f 756c 6420 6f6e 6c79 2072  ch should only r
    │ │ │ -0007bc90: 756e 206f 6e20 6f6e 6520 7468 7265 6164  un on one thread
    │ │ │ -0007bca0: 0a09 0973 7464 3a3a 7468 7265 6164 3a3a  ...std::thread::
    │ │ │ -0007bcb0: 6964 2066 6972 7374 5f74 6872 6561 645f  id first_thread_
    │ │ │ -0007bcc0: 6964 2829 3b0a 0909 696e 7420 6e75 6d5f  id();...int num_
    │ │ │ -0007bcd0: 7468 7265 6164 7328 290a 0909 7b0a 0909  threads()...{...
    │ │ │ -0007bce0: 0973 7464 3a3a 6c6f 636b 5f67 7561 7264  .std::lock_guard
    │ │ │ -0007bcf0: 266c 743b 7374 643a 3a6d 7574 6578 2667  <std::mutex&g
    │ │ │ -0007bd00: 743b 206c 286d 5f6d 7574 6578 293b 0a09  t; l(m_mutex);..
    │ │ │ -0007bd10: 0909 7265 7475 726e 2069 6e74 286d 5f74  ..return int(m_t
    │ │ │ -0007bd20: 6872 6561 6473 2e73 697a 6528 2929 3b0a  hreads.size());.
    │ │ │ -0007bd30: 0909 7d0a 0a3c 6469 7620 7374 796c 653d  ..}..
    ..void append │ │ │ -0007bd70: 286a 6f62 7175 6575 655f 7420 6a6f 6273 (jobqueue_t jobs │ │ │ -0007bd80: 290a 3c2f 6469 763e 0909 7b0a 0909 096d ).
    ..{....m │ │ │ -0007bd90: 5f71 7565 7565 645f 6a6f 6273 2e61 7070 _queued_jobs.app │ │ │ -0007bda0: 656e 6428 7374 643a 3a6d 6f76 6528 6a6f end(std::move(jo │ │ │ -0007bdb0: 6273 2929 3b0a 0909 7d0a 0a3c 2f70 7265 bs));...}..
    rele │ │ │ -0007bdf0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../include │ │ │ -0007be30: 2f6c 6962 746f 7272 656e 742f 6175 785f /libtorrent/aux_ │ │ │ -0007be40: 2f64 6973 6b5f 696f 5f74 6872 6561 645f /disk_io_thread_ │ │ │ -0007be50: 706f 6f6c 2e68 7070 3a31 3132 3c2f 613e pool.hpp:112 │ │ │ -0007be60: 3c2f 7464 3e3c 7464 3e74 6865 206a 6f62 the job │ │ │ -0007be70: 206d 7574 6578 206d 7573 7420 6265 2068 mutex must be h │ │ │ -0007be80: 656c 6420 7768 656e 2074 6869 7320 6973 eld when this is │ │ │ -0007be90: 2063 616c 6c65 643c 2f74 643e 3c2f 7472 called

    the job mut │ │ │ -0007bef0: 6578 206d 7573 7420 6265 2068 656c 6420 ex must be held │ │ │ -0007bf00: 7768 656e 2074 6869 7320 6973 2063 616c when this is cal │ │ │ -0007bf10: 6c65 643c 2f68 323e 3c68 343e 2e2e 2f69 led

    ../i │ │ │ -0007bf20: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -0007bf30: 742f 6175 785f 2f64 6973 6b5f 696f 5f74 t/aux_/disk_io_t │ │ │ -0007bf40: 6872 6561 645f 706f 6f6c 2e68 7070 3a31 hread_pool.hpp:1 │ │ │ -0007bf50: 3132 3c2f 6834 3e3c 7072 6520 7374 796c 12

    ..// if it retu
    │ │ │ -0007bfa0: 726e 7320 7472 7565 2074 6865 6e20 7468  rns true then th
    │ │ │ -0007bfb0: 6520 7468 7265 6164 204d 5553 5420 6578  e thread MUST ex
    │ │ │ -0007bfc0: 6974 0a09 092f 2f20 6966 2069 7420 7265  it...// if it re
    │ │ │ -0007bfd0: 7475 726e 7320 6661 6c73 6520 7468 6520  turns false the 
    │ │ │ -0007bfe0: 7468 7265 6164 2073 686f 756c 6420 6e6f  thread should no
    │ │ │ -0007bff0: 7420 6578 6974 0a09 0962 6f6f 6c20 7472  t exit...bool tr
    │ │ │ -0007c000: 795f 7468 7265 6164 5f65 7869 7428 7374  y_thread_exit(st
    │ │ │ -0007c010: 643a 3a74 6872 6561 643a 3a69 6420 6964  d::thread::id id
    │ │ │ -0007c020: 293b 0a0a 0909 2f2f 2067 6574 2074 6865  );....// get the
    │ │ │ -0007c030: 2074 6872 6561 6420 6964 206f 6620 7468   thread id of th
    │ │ │ -0007c040: 6520 6669 7273 7420 7468 7265 6164 2069  e first thread i
    │ │ │ -0007c050: 6e20 7468 6520 696e 7465 726e 616c 2076  n the internal v
    │ │ │ -0007c060: 6563 746f 720a 0909 2f2f 2073 696e 6365  ector...// since
    │ │ │ -0007c070: 2074 6869 7320 6973 2074 6865 2066 6972   this is the fir
    │ │ │ -0007c080: 7374 2074 6872 6561 6420 6974 2077 696c  st thread it wil
    │ │ │ -0007c090: 6c20 7265 6d61 696e 2074 6865 2073 616d  l remain the sam
    │ │ │ -0007c0a0: 6520 756e 7469 6c20 7468 6520 6669 7273  e until the firs
    │ │ │ -0007c0b0: 740a 0909 2f2f 2074 6872 6561 6420 6578  t...// thread ex
    │ │ │ -0007c0c0: 6974 730a 0909 2f2f 2069 7420 6361 6e20  its...// it can 
    │ │ │ -0007c0d0: 6265 2075 7365 6420 746f 2074 7269 6767  be used to trigg
    │ │ │ -0007c0e0: 6572 206d 6169 6e74 656e 616e 6365 206a  er maintenance j
    │ │ │ -0007c0f0: 6f62 7320 7768 6963 6820 7368 6f75 6c64  obs which should
    │ │ │ -0007c100: 206f 6e6c 7920 7275 6e20 6f6e 206f 6e65   only run on one
    │ │ │ -0007c110: 2074 6872 6561 640a 0909 7374 643a 3a74   thread...std::t
    │ │ │ -0007c120: 6872 6561 643a 3a69 6420 6669 7273 745f  hread::id first_
    │ │ │ -0007c130: 7468 7265 6164 5f69 6428 293b 0a09 0969  thread_id();...i
    │ │ │ -0007c140: 6e74 206e 756d 5f74 6872 6561 6473 2829  nt num_threads()
    │ │ │ -0007c150: 0a09 097b 0a09 0909 7374 643a 3a6c 6f63  ...{....std::loc
    │ │ │ -0007c160: 6b5f 6775 6172 6426 6c74 3b73 7464 3a3a  k_guard<std::
    │ │ │ -0007c170: 6d75 7465 7826 6774 3b20 6c28 6d5f 6d75  mutex> l(m_mu
    │ │ │ -0007c180: 7465 7829 3b0a 0909 0972 6574 7572 6e20  tex);....return 
    │ │ │ -0007c190: 696e 7428 6d5f 7468 7265 6164 732e 7369  int(m_threads.si
    │ │ │ -0007c1a0: 7a65 2829 293b 0a09 097d 0a0a 0909 766f  ze());...}....vo
    │ │ │ -0007c1b0: 6964 2061 7070 656e 6428 6a6f 6271 7565  id append(jobque
    │ │ │ -0007c1c0: 7565 5f74 206a 6f62 7329 0a09 097b 0a09  ue_t jobs)...{..
    │ │ │ -0007c1d0: 0909 6d5f 7175 6575 6564 5f6a 6f62 732e  ..m_queued_jobs.
    │ │ │ -0007c1e0: 6170 7065 6e64 2873 7464 3a3a 6d6f 7665  append(std::move
    │ │ │ -0007c1f0: 286a 6f62 7329 293b 0a09 097d 0a0a 3c64  (jobs));...}....vo
    │ │ │ -0007c230: 6964 2070 7573 685f 6261 636b 2861 7578  id push_back(aux
    │ │ │ -0007c240: 3a3a 6469 736b 5f6a 6f62 2a20 6a29 0a3c  ::disk_job* j).<
    │ │ │ -0007c250: 2f64 6976 3e09 097b 0a09 0909 6d5f 7175  /div>..{....m_qu
    │ │ │ -0007c260: 6575 6564 5f6a 6f62 732e 7075 7368 5f62  eued_jobs.push_b
    │ │ │ -0007c270: 6163 6b28 6a29 3b0a 0909 7d0a 0a3c 2f70  ack(j);...}..

    re │ │ │ -0007c2b0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../inclu │ │ │ -0007c2f0: 6465 2f6c 6962 746f 7272 656e 742f 6175 de/libtorrent/au │ │ │ -0007c300: 785f 2f64 6973 6b5f 696f 5f74 6872 6561 x_/disk_io_threa │ │ │ -0007c310: 645f 706f 6f6c 2e68 7070 3a31 3138 3c2f d_pool.hpp:118the j │ │ │ -0007c330: 6f62 206d 7574 6578 206d 7573 7420 6265 ob mutex must be │ │ │ -0007c340: 2068 656c 6420 7768 656e 2074 6869 7320 held when this │ │ │ -0007c350: 6973 2063 616c 6c65 643c 2f74 643e 3c2f is called

    the job m │ │ │ -0007c3b0: 7574 6578 206d 7573 7420 6265 2068 656c utex must be hel │ │ │ -0007c3c0: 6420 7768 656e 2074 6869 7320 6973 2063 d when this is c │ │ │ -0007c3d0: 616c 6c65 643c 2f68 323e 3c68 343e 2e2e alled

    .. │ │ │ -0007c3e0: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -0007c3f0: 656e 742f 6175 785f 2f64 6973 6b5f 696f ent/aux_/disk_io │ │ │ -0007c400: 5f74 6872 6561 645f 706f 6f6c 2e68 7070 _thread_pool.hpp │ │ │ -0007c410: 3a31 3138 3c2f 6834 3e3c 7072 6520 7374 :118

    ..// since th
    │ │ │ -0007c460: 6973 2069 7320 7468 6520 6669 7273 7420  is is the first 
    │ │ │ -0007c470: 7468 7265 6164 2069 7420 7769 6c6c 2072  thread it will r
    │ │ │ -0007c480: 656d 6169 6e20 7468 6520 7361 6d65 2075  emain the same u
    │ │ │ -0007c490: 6e74 696c 2074 6865 2066 6972 7374 0a09  ntil the first..
    │ │ │ -0007c4a0: 092f 2f20 7468 7265 6164 2065 7869 7473  .// thread exits
    │ │ │ -0007c4b0: 0a09 092f 2f20 6974 2063 616e 2062 6520  ...// it can be 
    │ │ │ -0007c4c0: 7573 6564 2074 6f20 7472 6967 6765 7220  used to trigger 
    │ │ │ -0007c4d0: 6d61 696e 7465 6e61 6e63 6520 6a6f 6273  maintenance jobs
    │ │ │ -0007c4e0: 2077 6869 6368 2073 686f 756c 6420 6f6e   which should on
    │ │ │ -0007c4f0: 6c79 2072 756e 206f 6e20 6f6e 6520 7468  ly run on one th
    │ │ │ -0007c500: 7265 6164 0a09 0973 7464 3a3a 7468 7265  read...std::thre
    │ │ │ -0007c510: 6164 3a3a 6964 2066 6972 7374 5f74 6872  ad::id first_thr
    │ │ │ -0007c520: 6561 645f 6964 2829 3b0a 0909 696e 7420  ead_id();...int 
    │ │ │ -0007c530: 6e75 6d5f 7468 7265 6164 7328 290a 0909  num_threads()...
    │ │ │ -0007c540: 7b0a 0909 0973 7464 3a3a 6c6f 636b 5f67  {....std::lock_g
    │ │ │ -0007c550: 7561 7264 266c 743b 7374 643a 3a6d 7574  uard<std::mut
    │ │ │ -0007c560: 6578 2667 743b 206c 286d 5f6d 7574 6578  ex> l(m_mutex
    │ │ │ -0007c570: 293b 0a09 0909 7265 7475 726e 2069 6e74  );....return int
    │ │ │ -0007c580: 286d 5f74 6872 6561 6473 2e73 697a 6528  (m_threads.size(
    │ │ │ -0007c590: 2929 3b0a 0909 7d0a 0a09 0976 6f69 6420  ));...}....void 
    │ │ │ -0007c5a0: 6170 7065 6e64 286a 6f62 7175 6575 655f  append(jobqueue_
    │ │ │ -0007c5b0: 7420 6a6f 6273 290a 0909 7b0a 0909 096d  t jobs)...{....m
    │ │ │ -0007c5c0: 5f71 7565 7565 645f 6a6f 6273 2e61 7070  _queued_jobs.app
    │ │ │ -0007c5d0: 656e 6428 7374 643a 3a6d 6f76 6528 6a6f  end(std::move(jo
    │ │ │ -0007c5e0: 6273 2929 3b0a 0909 7d0a 0a09 0976 6f69  bs));...}....voi
    │ │ │ -0007c5f0: 6420 7075 7368 5f62 6163 6b28 6175 783a  d push_back(aux:
    │ │ │ -0007c600: 3a64 6973 6b5f 6a6f 622a 206a 290a 0909  :disk_job* j)...
    │ │ │ -0007c610: 7b0a 0909 096d 5f71 7565 7565 645f 6a6f  {....m_queued_jo
    │ │ │ -0007c620: 6273 2e70 7573 685f 6261 636b 286a 293b  bs.push_back(j);
    │ │ │ -0007c630: 0a09 097d 0a0a 3c64 6976 2073 7479 6c65  ...}..
    ..aux::disk_ │ │ │ -0007c670: 6a6f 622a 2070 6f70 5f66 726f 6e74 2829 job* pop_front() │ │ │ -0007c680: 0a3c 2f64 6976 3e09 097b 0a09 0909 7265 .
    ..{....re │ │ │ -0007c690: 7475 726e 206d 5f71 7565 7565 645f 6a6f turn m_queued_jo │ │ │ -0007c6a0: 6273 2e70 6f70 5f66 726f 6e74 2829 3b0a bs.pop_front();. │ │ │ -0007c6b0: 0909 7d0a 0a3c 2f70 7265 3e3c 2f74 643e ..}..
    │ │ │ -0007c6c0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -0007c6f0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -0007c700: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -0007c710: 7074 3a65 7870 616e 6428 3238 3229 223e pt:expand(282)"> │ │ │ -0007c720: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -0007c730: 7272 656e 742f 6175 785f 2f64 6973 6b5f rrent/aux_/disk_ │ │ │ -0007c740: 696f 5f74 6872 6561 645f 706f 6f6c 2e68 io_thread_pool.h │ │ │ -0007c750: 7070 3a31 3234 3c2f 613e 3c2f 7464 3e3c pp:124
    < │ │ │ -0007c760: 7464 3e74 6865 206a 6f62 206d 7574 6578 td>the job mutex │ │ │ -0007c770: 206d 7573 7420 6265 2068 656c 6420 7768 must be held wh │ │ │ -0007c780: 656e 2074 6869 7320 6973 2063 616c 6c65 en this is calle │ │ │ -0007c790: 643c 2f74 643e 3c2f 7472 3e3c 7472 2069 d

    t │ │ │ -0007c7e0: 6865 206a 6f62 206d 7574 6578 206d 7573 he job mutex mus │ │ │ -0007c7f0: 7420 6265 2068 656c 6420 7768 656e 2074 t be held when t │ │ │ -0007c800: 6869 7320 6973 2063 616c 6c65 643c 2f68 his is called

    ../include │ │ │ -0007c820: 2f6c 6962 746f 7272 656e 742f 6175 785f /libtorrent/aux_ │ │ │ -0007c830: 2f64 6973 6b5f 696f 5f74 6872 6561 645f /disk_io_thread_ │ │ │ -0007c840: 706f 6f6c 2e68 7070 3a31 3234 3c2f 6834 pool.hpp:124

    ..{..
    │ │ │ -0007c890: 0909 7374 643a 3a6c 6f63 6b5f 6775 6172  ..std::lock_guar
    │ │ │ -0007c8a0: 6426 6c74 3b73 7464 3a3a 6d75 7465 7826  d<std::mutex&
    │ │ │ -0007c8b0: 6774 3b20 6c28 6d5f 6d75 7465 7829 3b0a  gt; l(m_mutex);.
    │ │ │ -0007c8c0: 0909 0972 6574 7572 6e20 696e 7428 6d5f  ...return int(m_
    │ │ │ -0007c8d0: 7468 7265 6164 732e 7369 7a65 2829 293b  threads.size());
    │ │ │ -0007c8e0: 0a09 097d 0a0a 0909 766f 6964 2061 7070  ...}....void app
    │ │ │ -0007c8f0: 656e 6428 6a6f 6271 7565 7565 5f74 206a  end(jobqueue_t j
    │ │ │ -0007c900: 6f62 7329 0a09 097b 0a09 0909 6d5f 7175  obs)...{....m_qu
    │ │ │ -0007c910: 6575 6564 5f6a 6f62 732e 6170 7065 6e64  eued_jobs.append
    │ │ │ -0007c920: 2873 7464 3a3a 6d6f 7665 286a 6f62 7329  (std::move(jobs)
    │ │ │ -0007c930: 293b 0a09 097d 0a0a 0909 766f 6964 2070  );...}....void p
    │ │ │ -0007c940: 7573 685f 6261 636b 2861 7578 3a3a 6469  ush_back(aux::di
    │ │ │ -0007c950: 736b 5f6a 6f62 2a20 6a29 0a09 097b 0a09  sk_job* j)...{..
    │ │ │ -0007c960: 0909 6d5f 7175 6575 6564 5f6a 6f62 732e  ..m_queued_jobs.
    │ │ │ -0007c970: 7075 7368 5f62 6163 6b28 6a29 3b0a 0909  push_back(j);...
    │ │ │ -0007c980: 7d0a 0a09 0961 7578 3a3a 6469 736b 5f6a  }....aux::disk_j
    │ │ │ -0007c990: 6f62 2a20 706f 705f 6672 6f6e 7428 290a  ob* pop_front().
    │ │ │ -0007c9a0: 0909 7b0a 0909 0972 6574 7572 6e20 6d5f  ..{....return m_
    │ │ │ -0007c9b0: 7175 6575 6564 5f6a 6f62 732e 706f 705f  queued_jobs.pop_
    │ │ │ -0007c9c0: 6672 6f6e 7428 293b 0a09 097d 0a0a 3c64  front();...}....bo
    │ │ │ -0007ca00: 6f6c 2065 6d70 7479 2829 2063 6f6e 7374  ol empty() const
    │ │ │ -0007ca10: 0a3c 2f64 6976 3e09 097b 0a09 0909 7265  .
    ..{....re │ │ │ -0007ca20: 7475 726e 206d 5f71 7565 7565 645f 6a6f turn m_queued_jo │ │ │ -0007ca30: 6273 2e65 6d70 7479 2829 3b0a 0909 7d0a bs.empty();...}. │ │ │ -0007ca40: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .relevance  │ │ │ -0007ca80: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../i │ │ │ -0007cab0: 6e63 6c75 6465 2f6c 6962 746f 7272 656e nclude/libtorren │ │ │ -0007cac0: 742f 6175 785f 2f64 6973 6b5f 696f 5f74 t/aux_/disk_io_t │ │ │ -0007cad0: 6872 6561 645f 706f 6f6c 2e68 7070 3a31 hread_pool.hpp:1 │ │ │ -0007cae0: 3330 3c2f 613e 3c2f 7464 3e3c 7464 3e74 30t │ │ │ -0007caf0: 6865 206a 6f62 206d 7574 6578 206d 7573 he job mutex mus │ │ │ -0007cb00: 7420 6265 2068 656c 6420 7768 656e 2074 t be held when t │ │ │ -0007cb10: 6869 7320 6973 2063 616c 6c65 643c 2f74 his is called

    the j │ │ │ -0007cb70: 6f62 206d 7574 6578 206d 7573 7420 6265 ob mutex must be │ │ │ -0007cb80: 2068 656c 6420 7768 656e 2074 6869 7320 held when this │ │ │ -0007cb90: 6973 2063 616c 6c65 643c 2f68 323e 3c68 is called

    ../include/lib │ │ │ -0007cbb0: 746f 7272 656e 742f 6175 785f 2f64 6973 torrent/aux_/dis │ │ │ -0007cbc0: 6b5f 696f 5f74 6872 6561 645f 706f 6f6c k_io_thread_pool │ │ │ -0007cbd0: 2e68 7070 3a31 3330 3c2f 6834 3e3c 7072 .hpp:130

    ..void ap │ │ │ -0007cc20: 7065 6e64 286a 6f62 7175 6575 655f 7420 pend(jobqueue_t │ │ │ -0007cc30: 6a6f 6273 290a 0909 7b0a 0909 096d 5f71 jobs)...{....m_q │ │ │ -0007cc40: 7565 7565 645f 6a6f 6273 2e61 7070 656e ueued_jobs.appen │ │ │ -0007cc50: 6428 7374 643a 3a6d 6f76 6528 6a6f 6273 d(std::move(jobs │ │ │ -0007cc60: 2929 3b0a 0909 7d0a 0a09 0976 6f69 6420 ));...}....void │ │ │ -0007cc70: 7075 7368 5f62 6163 6b28 6175 783a 3a64 push_back(aux::d │ │ │ -0007cc80: 6973 6b5f 6a6f 622a 206a 290a 0909 7b0a isk_job* j)...{. │ │ │ -0007cc90: 0909 096d 5f71 7565 7565 645f 6a6f 6273 ...m_queued_jobs │ │ │ -0007cca0: 2e70 7573 685f 6261 636b 286a 293b 0a09 .push_back(j);.. │ │ │ -0007ccb0: 097d 0a0a 0909 6175 783a 3a64 6973 6b5f .}....aux::disk_ │ │ │ -0007ccc0: 6a6f 622a 2070 6f70 5f66 726f 6e74 2829 job* pop_front() │ │ │ -0007ccd0: 0a09 097b 0a09 0909 7265 7475 726e 206d ...{....return m │ │ │ -0007cce0: 5f71 7565 7565 645f 6a6f 6273 2e70 6f70 _queued_jobs.pop │ │ │ -0007ccf0: 5f66 726f 6e74 2829 3b0a 0909 7d0a 0a09 _front();...}... │ │ │ -0007cd00: 0962 6f6f 6c20 656d 7074 7928 2920 636f .bool empty() co │ │ │ -0007cd10: 6e73 740a 0909 7b0a 0909 0972 6574 7572 nst...{....retur │ │ │ -0007cd20: 6e20 6d5f 7175 6575 6564 5f6a 6f62 732e n m_queued_jobs. │ │ │ -0007cd30: 656d 7074 7928 293b 0a09 097d 0a0a 3c64 empty();...}....in │ │ │ -0007cd70: 7420 7175 6575 655f 7369 7a65 2829 2063 t queue_size() c │ │ │ -0007cd80: 6f6e 7374 0a3c 2f64 6976 3e09 097b 0a09 onst...{.. │ │ │ -0007cd90: 0909 7265 7475 726e 206d 5f71 7565 7565 ..return m_queue │ │ │ -0007cda0: 645f 6a6f 6273 2e73 697a 6528 293b 0a09 d_jobs.size();.. │ │ │ -0007cdb0: 097d 0a0a 3c2f 7072 653e 3c2f 7464 3e3c .}..< │ │ │ -0007cdc0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -0007cdf0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -0007ce20: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -0007ce30: 7265 6e74 2f61 7578 5f2f 6469 736b 5f69 rent/aux_/disk_i │ │ │ -0007ce40: 6f5f 7468 7265 6164 5f70 6f6f 6c2e 6870 o_thread_pool.hp │ │ │ -0007ce50: 703a 3133 363c 2f61 3e3c 2f74 643e 3c74 p:136the job mutex │ │ │ -0007ce70: 6d75 7374 2062 6520 6865 6c64 2077 6865 must be held whe │ │ │ -0007ce80: 6e20 7468 6973 2069 7320 6361 6c6c 6564 n this is called │ │ │ -0007ce90: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    th │ │ │ -0007cee0: 6520 6a6f 6220 6d75 7465 7820 6d75 7374 e job mutex must │ │ │ -0007cef0: 2062 6520 6865 6c64 2077 6865 6e20 7468 be held when th │ │ │ -0007cf00: 6973 2069 7320 6361 6c6c 6564 3c2f 6832 is is called

    ../include/ │ │ │ -0007cf20: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -0007cf30: 6469 736b 5f69 6f5f 7468 7265 6164 5f70 disk_io_thread_p │ │ │ -0007cf40: 6f6f 6c2e 6870 703a 3133 363c 2f68 343e ool.hpp:136

    │ │ │ -0007cf50: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..void
    │ │ │ -0007cf90: 2070 7573 685f 6261 636b 2861 7578 3a3a   push_back(aux::
    │ │ │ -0007cfa0: 6469 736b 5f6a 6f62 2a20 6a29 0a09 097b  disk_job* j)...{
    │ │ │ -0007cfb0: 0a09 0909 6d5f 7175 6575 6564 5f6a 6f62  ....m_queued_job
    │ │ │ -0007cfc0: 732e 7075 7368 5f62 6163 6b28 6a29 3b0a  s.push_back(j);.
    │ │ │ -0007cfd0: 0909 7d0a 0a09 0961 7578 3a3a 6469 736b  ..}....aux::disk
    │ │ │ -0007cfe0: 5f6a 6f62 2a20 706f 705f 6672 6f6e 7428  _job* pop_front(
    │ │ │ -0007cff0: 290a 0909 7b0a 0909 0972 6574 7572 6e20  )...{....return 
    │ │ │ -0007d000: 6d5f 7175 6575 6564 5f6a 6f62 732e 706f  m_queued_jobs.po
    │ │ │ -0007d010: 705f 6672 6f6e 7428 293b 0a09 097d 0a0a  p_front();...}..
    │ │ │ -0007d020: 0909 626f 6f6c 2065 6d70 7479 2829 2063  ..bool empty() c
    │ │ │ -0007d030: 6f6e 7374 0a09 097b 0a09 0909 7265 7475  onst...{....retu
    │ │ │ -0007d040: 726e 206d 5f71 7565 7565 645f 6a6f 6273  rn m_queued_jobs
    │ │ │ -0007d050: 2e65 6d70 7479 2829 3b0a 0909 7d0a 0a09  .empty();...}...
    │ │ │ -0007d060: 0969 6e74 2071 7565 7565 5f73 697a 6528  .int queue_size(
    │ │ │ -0007d070: 2920 636f 6e73 740a 0909 7b0a 0909 0972  ) const...{....r
    │ │ │ -0007d080: 6574 7572 6e20 6d5f 7175 6575 6564 5f6a  eturn m_queued_j
    │ │ │ -0007d090: 6f62 732e 7369 7a65 2829 3b0a 0909 7d0a  obs.size();...}.
    │ │ │ -0007d0a0: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ -0007d0d0: 0976 6f69 6420 7375 626d 6974 5f6a 6f62 .void submit_job │ │ │ -0007d0e0: 7328 290a 3c2f 6469 763e 0909 7b0a 0909 s().
    ..{... │ │ │ -0007d0f0: 0969 6620 286d 5f71 7565 7565 645f 6a6f .if (m_queued_jo │ │ │ -0007d100: 6273 2e65 6d70 7479 2829 2920 7265 7475 bs.empty()) retu │ │ │ -0007d110: 726e 3b0a 0909 096e 6f74 6966 795f 616c rn;....notify_al │ │ │ -0007d120: 6c28 293b 0a09 0909 6a6f 625f 7175 6575 l();....job_queu │ │ │ -0007d130: 6564 286d 5f71 7565 7565 645f 6a6f 6273 ed(m_queued_jobs │ │ │ -0007d140: 2e73 697a 6528 2929 3b0a 0909 7d0a 0a09 .size());...}... │ │ │ -0007d150: 0976 6f69 6420 696e 7465 7272 7570 7428 .void interrupt( │ │ │ -0007d160: 290a 0909 7b0a 0909 096d 5f69 6e74 6572 )...{....m_inter │ │ │ -0007d170: 7275 7074 203d 2074 7275 653b 0a09 0909 rupt = true;.... │ │ │ -0007d180: 6d5f 6a6f 625f 636f 6e64 2e6e 6f74 6966 m_job_cond.notif │ │ │ -0007d190: 795f 6f6e 6528 293b 0a09 097d 0a0a 0909 y_one();...}.... │ │ │ -0007d1a0: 7465 6d70 6c61 7465 266c 743b 7479 7065 template<type │ │ │ -0007d1b0: 6e61 6d65 2046 756e 2667 743b 0a09 0976 name Fun>...v │ │ │ -0007d1c0: 6f69 6420 7669 7369 745f 6a6f 6273 2846 oid visit_jobs(F │ │ │ -0007d1d0: 756e 2066 290a 0909 7b0a 0909 0966 6f72 un f)...{....for │ │ │ -0007d1e0: 2028 6175 746f 2069 203d 206d 5f71 7565 (auto i = m_que │ │ │ -0007d1f0: 7565 645f 6a6f 6273 2e69 7465 7261 7465 ued_jobs.iterate │ │ │ -0007d200: 2829 3b20 692e 6765 7428 293b 2069 2e6e (); i.get(); i.n │ │ │ -0007d210: 6578 7428 2929 0a09 0909 0966 2869 2e67 ext()).....f(i.g │ │ │ -0007d220: 6574 2829 293b 0a09 097d 0a0a 0970 7269 et());...}...pri │ │ │ -0007d230: 7661 7465 3a0a 0a09 092f 2f20 7468 6973 vate:....// this │ │ │ -0007d240: 2073 686f 756c 6420 6265 2063 616c 6c65 should be calle │ │ │ -0007d250: 6420 7768 656e 6576 6572 206e 6577 206a d whenever new j │ │ │ -0007d260: 6f62 7320 6172 6520 7175 6575 6564 0a09 obs are queued.. │ │ │ -0007d270: 092f 2f20 7175 6575 655f 7369 7a65 2069 .// queue_size i │ │ │ -0007d280: 7320 7468 6520 6375 7272 656e 7420 7369 s the current si │ │ │ -0007d290: 7a65 206f 6620 7468 6520 6a6f 6220 7175 ze of the job qu │ │ │ -0007d2a0: 6575 650a 0909 2f2f 206e 6f74 2074 6872 eue...// not thr │ │ │ -0007d2b0: 6561 6420 7361 6665 0a09 0976 6f69 6420 ead safe...void │ │ │ -0007d2c0: 6a6f 625f 7175 6575 6564 2869 6e74 2071 job_queued(int q │ │ │ -0007d2d0: 7565 7565 5f73 697a 6529 3b0a 0a09 0976 ueue_size);....v │ │ │ -0007d2e0: 6f69 6420 7265 6170 5f69 646c 655f 7468 oid reap_idle_th │ │ │ -0007d2f0: 7265 6164 7328 6572 726f 725f 636f 6465 reads(error_code │ │ │ -0007d300: 2063 6f6e 7374 2661 6d70 3b20 6563 293b const& ec); │ │ │ -0007d310: 0a0a 0909 2f2f 2074 6865 2063 616c 6c65 ....// the calle │ │ │ -0007d320: 7220 6d75 7374 2068 6f6c 6420 6d5f 6d75 r must hold m_mu │ │ │ -0007d330: 7465 780a 0909 766f 6964 2073 746f 705f tex...void stop_ │ │ │ -0007d340: 7468 7265 6164 7328 696e 7420 6e75 6d5f threads(int num_ │ │ │ -0007d350: 746f 5f73 746f 7029 3b0a 3c2f 7072 653e to_stop);.
    │ │ │ -0007d360: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ -0007d390: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ -0007d3a0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../include/ │ │ │ -0007d3d0: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -0007d3e0: 7072 6f78 795f 6261 7365 2e68 7070 3a32 proxy_base.hpp:2 │ │ │ -0007d3f0: 3034 3c2f 613e 3c2f 7464 3e3c 7464 3e69 04i │ │ │ -0007d400: 7420 776f 756c 6420 6265 206e 6963 6520 t would be nice │ │ │ -0007d410: 746f 2072 656d 656d 6265 7220 7468 6520 to remember the │ │ │ -0007d420: 6269 6e64 2070 6f72 7420 616e 6420 6269 bind port and bi │ │ │ -0007d430: 6e64 206f 6e63 6520 7765 206b 6e6f 7720 nd once we know │ │ │ -0007d440: 7768 6572 6520 7468 6520 7072 6f78 7920 where the proxy │ │ │ -0007d450: 6973 206d 5f73 6f63 6b2e 6269 6e64 2865 is m_sock.bind(e │ │ │ -0007d460: 6e64 706f 696e 742c 2065 6329 3b3c 2f74 ndpoint, ec);

    it wo │ │ │ -0007d4c0: 756c 6420 6265 206e 6963 6520 746f 2072 uld be nice to r │ │ │ -0007d4d0: 656d 656d 6265 7220 7468 6520 6269 6e64 emember the bind │ │ │ -0007d4e0: 2070 6f72 7420 616e 6420 6269 6e64 206f port and bind o │ │ │ -0007d4f0: 6e63 6520 7765 206b 6e6f 7720 7768 6572 nce we know wher │ │ │ -0007d500: 6520 7468 6520 7072 6f78 7920 6973 0a6d e the proxy is.m │ │ │ -0007d510: 5f73 6f63 6b2e 6269 6e64 2865 6e64 706f _sock.bind(endpo │ │ │ -0007d520: 696e 742c 2065 6329 3b3c 2f68 323e 3c68 int, ec);

    ../include/lib │ │ │ -0007d540: 746f 7272 656e 742f 6175 785f 2f70 726f torrent/aux_/pro │ │ │ -0007d550: 7879 5f62 6173 652e 6870 703a 3230 343c xy_base.hpp:204< │ │ │ -0007d560: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -0007d5a0: 544f 5252 454e 545f 4153 5345 5254 286d  TORRENT_ASSERT(m
    │ │ │ -0007d5b0: 5f6d 6167 6963 203d 3d20 3078 3133 3337  _magic == 0x1337
    │ │ │ -0007d5c0: 293b 0a09 096d 5f73 6f63 6b2e 6361 6e63  );...m_sock.canc
    │ │ │ -0007d5d0: 656c 2829 3b0a 097d 0a0a 0976 6f69 6420  el();..}...void 
    │ │ │ -0007d5e0: 6361 6e63 656c 2865 7272 6f72 5f63 6f64  cancel(error_cod
    │ │ │ -0007d5f0: 6526 616d 703b 2065 6329 0a09 7b0a 0909  e& ec)..{...
    │ │ │ -0007d600: 544f 5252 454e 545f 4153 5345 5254 286d  TORRENT_ASSERT(m
    │ │ │ -0007d610: 5f6d 6167 6963 203d 3d20 3078 3133 3337  _magic == 0x1337
    │ │ │ -0007d620: 293b 0a09 096d 5f73 6f63 6b2e 6361 6e63  );...m_sock.canc
    │ │ │ -0007d630: 656c 2865 6329 3b0a 097d 0a0a 0976 6f69  el(ec);..}...voi
    │ │ │ -0007d640: 6420 6269 6e64 2865 6e64 706f 696e 745f  d bind(endpoint_
    │ │ │ -0007d650: 7479 7065 2063 6f6e 7374 2661 6d70 3b20  type const& 
    │ │ │ -0007d660: 2f2a 2065 6e64 706f 696e 7420 2a2f 2c20  /* endpoint */, 
    │ │ │ -0007d670: 6572 726f 725f 636f 6465 2661 6d70 3b20  error_code& 
    │ │ │ -0007d680: 2f2a 2065 6320 2a2f 290a 097b 0a09 0954  /* ec */)..{...T
    │ │ │ -0007d690: 4f52 5245 4e54 5f41 5353 4552 5428 6d5f  ORRENT_ASSERT(m_
    │ │ │ -0007d6a0: 6d61 6769 6320 3d3d 2030 7831 3333 3729  magic == 0x1337)
    │ │ │ -0007d6b0: 3b0a 0909 2f2f 2074 6865 2072 6561 736f  ;...// the reaso
    │ │ │ -0007d6c0: 6e20 7768 7920 7765 2069 676e 6f72 6520  n why we ignore 
    │ │ │ -0007d6d0: 6269 6e64 7320 6865 7265 2069 7320 6265  binds here is be
    │ │ │ -0007d6e0: 6361 7573 6520 7765 2064 6f6e 2774 0a09  cause we don't..
    │ │ │ -0007d6f0: 092f 2f20 286e 6563 6573 7361 7269 6c79  .// (necessarily
    │ │ │ -0007d700: 2920 7965 7420 6b6e 6f77 2077 6861 7420  ) yet know what 
    │ │ │ -0007d710: 6164 6472 6573 7320 6661 6d69 6c79 2074  address family t
    │ │ │ -0007d720: 6865 2070 726f 7879 0a09 092f 2f20 7769  he proxy...// wi
    │ │ │ -0007d730: 6c6c 2072 6573 6f6c 7665 2074 6f2c 2061  ll resolve to, a
    │ │ │ -0007d740: 6e64 2062 696e 6469 6e67 2074 6f20 7468  nd binding to th
    │ │ │ -0007d750: 6520 7772 6f6e 6720 6f6e 6520 776f 756c  e wrong one woul
    │ │ │ -0007d760: 640a 0909 2f2f 2062 7265 616b 206f 7572  d...// break our
    │ │ │ -0007d770: 2063 6f6e 6e65 6374 696f 6e20 6174 7465   connection atte
    │ │ │ -0007d780: 6d70 7420 6c61 7465 722e 2054 6865 2063  mpt later. The c
    │ │ │ -0007d790: 616c 6c65 7220 6865 7265 0a09 092f 2f20  aller here...// 
    │ │ │ -0007d7a0: 646f 6573 6e27 7420 6e65 6365 7373 6172  doesn't necessar
    │ │ │ -0007d7b0: 696c 7920 6b6e 6f77 2074 6861 7420 7765  ily know that we
    │ │ │ -0007d7c0: 2772 6520 7072 6f78 7969 6e67 2c20 736f  're proxying, so
    │ │ │ -0007d7d0: 2074 6869 730a 0909 2f2f 2062 696e 6420   this...// bind 
    │ │ │ -0007d7e0: 6164 6472 6573 7320 6973 2062 6173 6564  address is based
    │ │ │ -0007d7f0: 206f 6e20 7468 6520 6669 6e61 6c20 656e   on the final en
    │ │ │ -0007d800: 6470 6f69 6e74 2c20 6e6f 7420 7468 650a  dpoint, not the.
    │ │ │ -0007d810: 0909 2f2f 2070 726f 7879 2e0a 3c64 6976  ..// proxy..
    .}..#ifndef BOOS │ │ │ -0007d860: 545f 4e4f 5f45 5843 4550 5449 4f4e 530a T_NO_EXCEPTIONS. │ │ │ -0007d870: 0976 6f69 6420 6f70 656e 2870 726f 746f .void open(proto │ │ │ -0007d880: 636f 6c5f 7479 7065 2063 6f6e 7374 2661 col_type const&a │ │ │ -0007d890: 6d70 3b29 0a09 7b0a 0909 544f 5252 454e mp;)..{...TORREN │ │ │ -0007d8a0: 545f 4153 5345 5254 286d 5f6d 6167 6963 T_ASSERT(m_magic │ │ │ -0007d8b0: 203d 3d20 3078 3133 3337 293b 0a2f 2f09 == 0x1337);.//. │ │ │ -0007d8c0: 096d 5f73 6f63 6b2e 6f70 656e 2870 293b .m_sock.open(p); │ │ │ -0007d8d0: 0a09 7d0a 2365 6e64 6966 0a0a 0976 6f69 ..}.#endif...voi │ │ │ -0007d8e0: 6420 6f70 656e 2870 726f 746f 636f 6c5f d open(protocol_ │ │ │ -0007d8f0: 7479 7065 2063 6f6e 7374 2661 6d70 3b2c type const&, │ │ │ -0007d900: 2065 7272 6f72 5f63 6f64 6526 616d 703b error_code& │ │ │ -0007d910: 290a 097b 0a09 0954 4f52 5245 4e54 5f41 )..{...TORRENT_A │ │ │ -0007d920: 5353 4552 5428 6d5f 6d61 6769 6320 3d3d SSERT(m_magic == │ │ │ -0007d930: 2030 7831 3333 3729 3b0a 0909 2f2f 2077 0x1337);...// w │ │ │ -0007d940: 6520 6e65 6564 2074 6f20 6967 6e6f 7265 e need to ignore │ │ │ -0007d950: 2074 6869 7320 666f 7220 7468 6520 7361 this for the sa │ │ │ -0007d960: 6d65 2072 6561 736f 6e20 6173 2073 7461 me reason as sta │ │ │ -0007d970: 7465 640a 0909 2f2f 2066 6f72 2069 676e ted...// for ign │ │ │ -0007d980: 6f72 696e 6720 6269 6e64 2829 0a2f 2f09 oring bind().//. │ │ │ -0007d990: 096d 5f73 6f63 6b2e 6f70 656e 2870 2c20 .m_sock.open(p, │ │ │ -0007d9a0: 6563 293b 0a09 7d0a 0a23 6966 6e64 6566 ec);..}..#ifndef │ │ │ -0007d9b0: 2042 4f4f 5354 5f4e 4f5f 4558 4345 5054 BOOST_NO_EXCEPT │ │ │ -0007d9c0: 494f 4e53 0a09 766f 6964 2063 6c6f 7365 IONS..void close │ │ │ -0007d9d0: 2829 0a09 7b0a 0909 544f 5252 454e 545f ()..{...TORRENT_ │ │ │ -0007d9e0: 4153 5345 5254 286d 5f6d 6167 6963 203d ASSERT(m_magic = │ │ │ -0007d9f0: 3d20 3078 3133 3337 293b 0a09 096d 5f72 = 0x1337);...m_r │ │ │ -0007da00: 656d 6f74 655f 656e 6470 6f69 6e74 203d emote_endpoint = │ │ │ -0007da10: 2065 6e64 706f 696e 745f 7479 7065 2829 endpoint_type() │ │ │ -0007da20: 3b0a 0909 6d5f 736f 636b 2e63 6c6f 7365 ;...m_sock.close │ │ │ -0007da30: 2829 3b0a 0909 6d5f 7265 736f 6c76 6572 ();...m_resolver │ │ │ -0007da40: 2e63 616e 6365 6c28 293b 0a09 7d0a 2365 .cancel();..}.#e │ │ │ -0007da50: 6e64 6966 0a0a 0976 6f69 6420 636c 6f73 ndif...void clos │ │ │ -0007da60: 6528 6572 726f 725f 636f 6465 2661 6d70 e(error_code& │ │ │ -0007da70: 3b20 6563 290a 097b 0a09 0954 4f52 5245 ; ec)..{...TORRE │ │ │ -0007da80: 4e54 5f41 5353 4552 5428 6d5f 6d61 6769 NT_ASSERT(m_magi │ │ │ -0007da90: 6320 3d3d 2030 7831 3333 3729 3b0a 3c2f c == 0x1337);.r │ │ │ -0007dad0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ -0007dae0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../incl │ │ │ -0007db10: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -0007db20: 7578 5f2f 7365 7373 696f 6e5f 696e 7465 ux_/session_inte │ │ │ -0007db30: 7266 6163 652e 6870 703a 3138 383c 2f61 rface.hpp:188it wou │ │ │ -0007db50: 6c64 2062 6520 6e69 6365 2074 6f20 6e6f ld be nice to no │ │ │ -0007db60: 7420 6861 7665 2074 6869 7320 6265 2070 t have this be p │ │ │ -0007db70: 6172 7420 6f66 2073 6573 7369 6f6e 5f69 art of session_i │ │ │ -0007db80: 6e74 6572 6661 6365 3c2f 7464 3e3c 2f74 nterface

    it would b │ │ │ -0007dbe0: 6520 6e69 6365 2074 6f20 6e6f 7420 6861 e nice to not ha │ │ │ -0007dbf0: 7665 2074 6869 7320 6265 2070 6172 7420 ve this be part │ │ │ -0007dc00: 6f66 2073 6573 7369 6f6e 5f69 6e74 6572 of session_inter │ │ │ -0007dc10: 6661 6365 3c2f 6832 3e3c 6834 3e2e 2e2f face

    ../ │ │ │ -0007dc20: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -0007dc30: 6e74 2f61 7578 5f2f 7365 7373 696f 6e5f nt/aux_/session_ │ │ │ -0007dc40: 696e 7465 7266 6163 652e 6870 703a 3138 interface.hpp:18 │ │ │ -0007dc50: 383c 2f68 343e 3c70 7265 2073 7479 6c65 8

    │ │ │ -0007dc90: 0909 7669 7274 7561 6c20 766f 6964 2064  ..virtual void d
    │ │ │ -0007dca0: 6566 6572 7265 645f 7375 626d 6974 5f6a  eferred_submit_j
    │ │ │ -0007dcb0: 6f62 7328 2920 3d20 303b 0a0a 0909 7669  obs() = 0;....vi
    │ │ │ -0007dcc0: 7274 7561 6c20 7374 643a 3a75 696e 7431  rtual std::uint1
    │ │ │ -0007dcd0: 365f 7420 6c69 7374 656e 5f70 6f72 7428  6_t listen_port(
    │ │ │ -0007dce0: 2920 636f 6e73 7420 3d20 303b 0a09 0976  ) const = 0;...v
    │ │ │ -0007dcf0: 6972 7475 616c 2073 7464 3a3a 7569 6e74  irtual std::uint
    │ │ │ -0007dd00: 3136 5f74 2073 736c 5f6c 6973 7465 6e5f  16_t ssl_listen_
    │ │ │ -0007dd10: 706f 7274 2829 2063 6f6e 7374 203d 2030  port() const = 0
    │ │ │ -0007dd20: 3b0a 0a09 0976 6972 7475 616c 2069 6e74  ;....virtual int
    │ │ │ -0007dd30: 206c 6973 7465 6e5f 706f 7274 2861 7578   listen_port(aux
    │ │ │ -0007dd40: 3a3a 7472 616e 7370 6f72 7420 7373 6c2c  ::transport ssl,
    │ │ │ -0007dd50: 2061 6464 7265 7373 2063 6f6e 7374 2661   address const&a
    │ │ │ -0007dd60: 6d70 3b20 6c6f 6361 6c5f 6164 6472 2920  mp; local_addr) 
    │ │ │ -0007dd70: 636f 6e73 7420 3d20 303b 0a0a 0909 7669  const = 0;....vi
    │ │ │ -0007dd80: 7274 7561 6c20 7374 643a 3a75 696e 7433  rtual std::uint3
    │ │ │ -0007dd90: 325f 7420 6c69 7374 656e 5f73 6f63 6b65  2_t listen_socke
    │ │ │ -0007dda0: 745f 7665 7273 696f 6e28 2920 636f 6e73  t_version() cons
    │ │ │ -0007ddb0: 7420 3d20 303b 0a09 0976 6972 7475 616c  t = 0;...virtual
    │ │ │ -0007ddc0: 2076 6f69 6420 666f 725f 6561 6368 5f6c   void for_each_l
    │ │ │ -0007ddd0: 6973 7465 6e5f 736f 636b 6574 2873 7464  isten_socket(std
    │ │ │ -0007dde0: 3a3a 6675 6e63 7469 6f6e 266c 743b 766f  ::function<vo
    │ │ │ -0007ddf0: 6964 2861 7578 3a3a 6c69 7374 656e 5f73  id(aux::listen_s
    │ │ │ -0007de00: 6f63 6b65 745f 6861 6e64 6c65 2063 6f6e  ocket_handle con
    │ │ │ -0007de10: 7374 2661 6d70 3b29 2667 743b 2066 2920  st&)> f) 
    │ │ │ -0007de20: 636f 6e73 7420 3d20 303b 0a0a 0909 2f2f  const = 0;....//
    │ │ │ -0007de30: 2061 736b 2066 6f72 2077 6869 6368 2069   ask for which i
    │ │ │ -0007de40: 6e74 6572 6661 6365 2061 6e64 2070 6f72  nterface and por
    │ │ │ -0007de50: 7420 746f 2062 696e 6420 6f75 7467 6f69  t to bind outgoi
    │ │ │ -0007de60: 6e67 2070 6565 7220 636f 6e6e 6563 7469  ng peer connecti
    │ │ │ -0007de70: 6f6e 7320 6f6e 0a09 0976 6972 7475 616c  ons on...virtual
    │ │ │ -0007de80: 2074 6370 3a3a 656e 6470 6f69 6e74 2062   tcp::endpoint b
    │ │ │ -0007de90: 696e 645f 6f75 7467 6f69 6e67 5f73 6f63  ind_outgoing_soc
    │ │ │ -0007dea0: 6b65 7428 736f 636b 6574 5f74 7970 6526  ket(socket_type&
    │ │ │ -0007deb0: 616d 703b 2073 2c20 6164 6472 6573 7320  amp; s, address 
    │ │ │ -0007dec0: 636f 6e73 7426 616d 703b 0a09 0909 7265  const&....re
    │ │ │ -0007ded0: 6d6f 7465 5f61 6464 7265 7373 2c20 6572  mote_address, er
    │ │ │ -0007dee0: 726f 725f 636f 6465 2661 6d70 3b20 6563  ror_code& ec
    │ │ │ -0007def0: 2920 636f 6e73 7420 3d20 303b 0a09 0976  ) const = 0;...v
    │ │ │ -0007df00: 6972 7475 616c 2062 6f6f 6c20 7665 7269  irtual bool veri
    │ │ │ -0007df10: 6679 5f62 6f75 6e64 5f61 6464 7265 7373  fy_bound_address
    │ │ │ -0007df20: 2861 6464 7265 7373 2063 6f6e 7374 2661  (address const&a
    │ │ │ -0007df30: 6d70 3b20 6164 6472 2c20 626f 6f6c 2075  mp; addr, bool u
    │ │ │ -0007df40: 7470 2920 3d20 303b 0a0a 2369 666e 6465  tp) = 0;..#ifnde
    │ │ │ -0007df50: 6620 544f 5252 454e 545f 4449 5341 424c  f TORRENT_DISABL
    │ │ │ -0007df60: 455f 4d55 5441 424c 455f 544f 5252 454e  E_MUTABLE_TORREN
    │ │ │ -0007df70: 5453 0a09 0976 6972 7475 616c 2073 7464  TS...virtual std
    │ │ │ -0007df80: 3a3a 7665 6374 6f72 266c 743b 7374 643a  ::vector<std:
    │ │ │ -0007df90: 3a73 6861 7265 645f 7074 7226 6c74 3b74  :shared_ptr<t
    │ │ │ -0007dfa0: 6f72 7265 6e74 2667 743b 2667 743b 2066  orrent>> f
    │ │ │ -0007dfb0: 696e 645f 636f 6c6c 6563 7469 6f6e 280a  ind_collection(.
    │ │ │ -0007dfc0: 0909 0973 7464 3a3a 7374 7269 6e67 2063  ...std::string c
    │ │ │ -0007dfd0: 6f6e 7374 2661 6d70 3b20 636f 6c6c 6563  onst& collec
    │ │ │ -0007dfe0: 7469 6f6e 2920 636f 6e73 7420 3d20 303b  tion) const = 0;
    │ │ │ -0007dff0: 0a23 656e 6469 660a 0a3c 6469 7620 7374  .#endif..
    ..virtual │ │ │ -0007e030: 2070 726f 7879 5f73 6574 7469 6e67 7320 proxy_settings │ │ │ -0007e040: 7072 6f78 7928 2920 636f 6e73 7420 3d20 proxy() const = │ │ │ -0007e050: 303b 0a3c 2f64 6976 3e0a 2369 6620 544f 0;.
    .#if TO │ │ │ -0007e060: 5252 454e 545f 5553 455f 4932 500a 0909 RRENT_USE_I2P... │ │ │ -0007e070: 7669 7274 7561 6c20 6932 705f 636f 6e6e virtual i2p_conn │ │ │ -0007e080: 6563 7469 6f6e 2661 6d70 3b20 6932 705f ection& i2p_ │ │ │ -0007e090: 636f 6e6e 2829 203d 2030 3b0a 0909 7669 conn() = 0;...vi │ │ │ -0007e0a0: 7274 7561 6c20 6368 6172 2063 6f6e 7374 rtual char const │ │ │ -0007e0b0: 2a20 6932 705f 7365 7373 696f 6e28 2920 * i2p_session() │ │ │ -0007e0c0: 636f 6e73 7420 3d20 303b 0a09 0976 6972 const = 0;...vir │ │ │ -0007e0d0: 7475 616c 2073 7464 3a3a 7374 7269 6e67 tual std::string │ │ │ -0007e0e0: 2063 6f6e 7374 2661 6d70 3b20 6c6f 6361 const& loca │ │ │ -0007e0f0: 6c5f 6932 705f 656e 6470 6f69 6e74 2829 l_i2p_endpoint() │ │ │ -0007e100: 2063 6f6e 7374 203d 2030 3b0a 2365 6e64 const = 0;.#end │ │ │ -0007e110: 6966 0a0a 0909 7669 7274 7561 6c20 766f if....virtual vo │ │ │ -0007e120: 6964 2070 7269 6f72 6974 697a 655f 636f id prioritize_co │ │ │ -0007e130: 6e6e 6563 7469 6f6e 7328 7374 643a 3a77 nnections(std::w │ │ │ -0007e140: 6561 6b5f 7074 7226 6c74 3b74 6f72 7265 eak_ptr<torre │ │ │ -0007e150: 6e74 2667 743b 2074 2920 3d20 303b 0a0a nt> t) = 0;.. │ │ │ -0007e160: 0909 7669 7274 7561 6c20 766f 6964 2074 ..virtual void t │ │ │ -0007e170: 7269 6767 6572 5f61 7574 6f5f 6d61 6e61 rigger_auto_mana │ │ │ -0007e180: 6765 2829 203d 2030 3b0a 0a09 0976 6972 ge() = 0;....vir │ │ │ -0007e190: 7475 616c 2076 6f69 6420 6170 706c 795f tual void apply_ │ │ │ -0007e1a0: 7365 7474 696e 6773 5f70 6163 6b28 7374 settings_pack(st │ │ │ -0007e1b0: 643a 3a73 6861 7265 645f 7074 7226 6c74 d::shared_ptr< │ │ │ -0007e1c0: 3b73 6574 7469 6e67 735f 7061 636b 2667 ;settings_pack&g │ │ │ -0007e1d0: 743b 2070 6163 6b29 203d 2030 3b0a 0909 t; pack) = 0;... │ │ │ -0007e1e0: 7669 7274 7561 6c20 7365 7373 696f 6e5f virtual session_ │ │ │ -0007e1f0: 7365 7474 696e 6773 2063 6f6e 7374 2661 settings const&a │ │ │ -0007e200: 6d70 3b20 7365 7474 696e 6773 2829 2063 mp; settings() c │ │ │ -0007e210: 6f6e 7374 203d 2030 3b0a 0a09 0976 6972 onst = 0;....vir │ │ │ -0007e220: 7475 616c 2076 6f69 6420 7175 6575 655f tual void queue_ │ │ │ -0007e230: 7472 6163 6b65 725f 7265 7175 6573 7428 tracker_request( │ │ │ -0007e240: 6175 783a 3a74 7261 636b 6572 5f72 6571 aux::tracker_req │ │ │ -0007e250: 7565 7374 2072 6571 0a09 0909 2c20 7374 uest req...., st │ │ │ -0007e260: 643a 3a77 6561 6b5f 7074 7226 6c74 3b61 d::weak_ptr<a │ │ │ -0007e270: 7578 3a3a 7265 7175 6573 745f 6361 6c6c ux::request_call │ │ │ -0007e280: 6261 636b 2667 743b 2063 2920 3d20 303b back> c) = 0; │ │ │ -0007e290: 0a0a 0909 2f2f 2070 6565 722d 636c 6173 ....// peer-clas │ │ │ -0007e2a0: 7365 730a 0909 7669 7274 7561 6c20 766f ses...virtual vo │ │ │ -0007e2b0: 6964 2073 6574 5f70 6565 725f 636c 6173 id set_peer_clas │ │ │ -0007e2c0: 7365 7328 7065 6572 5f63 6c61 7373 5f73 ses(peer_class_s │ │ │ -0007e2d0: 6574 2a20 732c 2061 6464 7265 7373 2063 et* s, address c │ │ │ -0007e2e0: 6f6e 7374 2661 6d70 3b20 612c 2073 6f63 onst& a, soc │ │ │ -0007e2f0: 6b65 745f 7479 7065 5f74 2073 7429 203d ket_type_t st) = │ │ │ -0007e300: 2030 3b0a 0909 7669 7274 7561 6c20 7065 0;...virtual pe │ │ │ -0007e310: 6572 5f63 6c61 7373 5f70 6f6f 6c20 636f er_class_pool co │ │ │ -0007e320: 6e73 7426 616d 703b 2070 6565 725f 636c nst& peer_cl │ │ │ -0007e330: 6173 7365 7328 2920 636f 6e73 7420 3d20 asses() const = │ │ │ -0007e340: 303b 0a09 0976 6972 7475 616c 2070 6565 0;...virtual pee │ │ │ -0007e350: 725f 636c 6173 735f 706f 6f6c 2661 6d70 r_class_pool& │ │ │ -0007e360: 3b20 7065 6572 5f63 6c61 7373 6573 2829 ; peer_classes() │ │ │ -0007e370: 203d 2030 3b0a 0909 7669 7274 7561 6c20 = 0;...virtual │ │ │ -0007e380: 626f 6f6c 2069 676e 6f72 655f 756e 6368 bool ignore_unch │ │ │ -0007e390: 6f6b 655f 736c 6f74 735f 7365 7428 7065 oke_slots_set(pe │ │ │ -0007e3a0: 6572 5f63 6c61 7373 5f73 6574 2063 6f6e er_class_set con │ │ │ -0007e3b0: 7374 2661 6d70 3b20 7365 7429 2063 6f6e st& set) con │ │ │ -0007e3c0: 7374 203d 2030 3b0a 0909 7669 7274 7561 st = 0;...virtua │ │ │ -0007e3d0: 6c20 696e 7420 636f 7079 5f70 6572 7469 l int copy_perti │ │ │ -0007e3e0: 6e65 6e74 5f63 6861 6e6e 656c 7328 7065 nent_channels(pe │ │ │ -0007e3f0: 6572 5f63 6c61 7373 5f73 6574 2063 6f6e er_class_set con │ │ │ -0007e400: 7374 2661 6d70 3b20 7365 740a 0909 092c st& set...., │ │ │ -0007e410: 2069 6e74 2063 6861 6e6e 656c 2c20 6261 int channel, ba │ │ │ -0007e420: 6e64 7769 6474 685f 6368 616e 6e65 6c2a ndwidth_channel* │ │ │ -0007e430: 2a20 6473 742c 2069 6e74 206d 2920 3d20 * dst, int m) = │ │ │ -0007e440: 303b 0a09 0976 6972 7475 616c 2073 7464 0;...virtual std │ │ │ -0007e450: 3a3a 7569 6e74 385f 7420 7573 655f 7175 ::uint8_t use_qu │ │ │ -0007e460: 6f74 615f 6f76 6572 6865 6164 2870 6565 ota_overhead(pee │ │ │ -0007e470: 725f 636c 6173 735f 7365 7426 616d 703b r_class_set& │ │ │ -0007e480: 2073 6574 2c20 696e 7420 616d 6f75 6e74 set, int amount │ │ │ -0007e490: 5f64 6f77 6e2c 2069 6e74 2061 6d6f 756e _down, int amoun │ │ │ -0007e4a0: 745f 7570 2920 3d20 303b 0a0a 0909 7669 t_up) = 0;....vi │ │ │ -0007e4b0: 7274 7561 6c20 6261 6e64 7769 6474 685f rtual bandwidth_ │ │ │ -0007e4c0: 6d61 6e61 6765 722a 2067 6574 5f62 616e manager* get_ban │ │ │ -0007e4d0: 6477 6964 7468 5f6d 616e 6167 6572 2869 dwidth_manager(i │ │ │ -0007e4e0: 6e74 2063 6861 6e6e 656c 2920 3d20 303b nt channel) = 0; │ │ │ -0007e4f0: 0a0a 0909 7669 7274 7561 6c20 766f 6964 ....virtual void │ │ │ -0007e500: 2073 656e 745f 6279 7465 7328 696e 7420 sent_bytes(int │ │ │ -0007e510: 6279 7465 735f 7061 796c 6f61 642c 2069 bytes_payload, i │ │ │ -0007e520: 6e74 2062 7974 6573 5f70 726f 746f 636f nt bytes_protoco │ │ │ -0007e530: 6c29 203d 2030 3b0a 0909 7669 7274 7561 l) = 0;...virtua │ │ │ -0007e540: 6c20 766f 6964 2072 6563 6569 7665 645f l void received_ │ │ │ -0007e550: 6279 7465 7328 696e 7420 6279 7465 735f bytes(int bytes_ │ │ │ -0007e560: 7061 796c 6f61 642c 2069 6e74 2062 7974 payload, int byt │ │ │ -0007e570: 6573 5f70 726f 746f 636f 6c29 203d 2030 es_protocol) = 0 │ │ │ -0007e580: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ -0007e5b0: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -0007e5c0: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -0007e5f0: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -0007e600: 6e74 2f61 7578 5f2f 6465 7072 6563 6174 nt/aux_/deprecat │ │ │ -0007e610: 6564 2e68 7070 3a32 343c 2f61 3e3c 2f74 ed.hpp:24figure out │ │ │ -0007e630: 2077 6869 6368 2076 6572 7369 6f6e 206f which version o │ │ │ -0007e640: 6620 636c 616e 6720 7468 6973 2069 7320 f clang this is │ │ │ -0007e650: 7375 7070 6f72 7465 6420 696e 3c2f 7464 supported in

    figure │ │ │ -0007e6b0: 206f 7574 2077 6869 6368 2076 6572 7369 out which versi │ │ │ -0007e6c0: 6f6e 206f 6620 636c 616e 6720 7468 6973 on of clang this │ │ │ -0007e6d0: 2069 7320 7375 7070 6f72 7465 6420 696e is supported in │ │ │ -0007e6e0: 3c2f 6832 3e3c 6834 3e2e 2e2f 696e 636c

    ../incl │ │ │ -0007e6f0: 7564 652f 6c69 6274 6f72 7265 6e74 2f61 ude/libtorrent/a │ │ │ -0007e700: 7578 5f2f 6465 7072 6563 6174 6564 2e68 ux_/deprecated.h │ │ │ -0007e710: 7070 3a32 343c 2f68 343e 3c70 7265 2073 pp:24

    All rights r
    │ │ │ -0007e760: 6573 6572 7665 642e 0a0a 596f 7520 6d61  eserved...You ma
    │ │ │ -0007e770: 7920 7573 652c 2064 6973 7472 6962 7574  y use, distribut
    │ │ │ -0007e780: 6520 616e 6420 6d6f 6469 6679 2074 6869  e and modify thi
    │ │ │ -0007e790: 7320 636f 6465 2075 6e64 6572 2074 6865  s code under the
    │ │ │ -0007e7a0: 2074 6572 6d73 206f 6620 7468 6520 4253   terms of the BS
    │ │ │ -0007e7b0: 4420 6c69 6365 6e73 652c 0a73 6565 204c  D license,.see L
    │ │ │ -0007e7c0: 4943 454e 5345 2066 696c 652e 0a2a 2f0a  ICENSE file..*/.
    │ │ │ -0007e7d0: 0a23 6966 6e64 6566 2054 4f52 5245 4e54  .#ifndef TORRENT
    │ │ │ -0007e7e0: 5f44 4550 5245 4341 5445 445f 4850 505f  _DEPRECATED_HPP_
    │ │ │ -0007e7f0: 494e 434c 5544 4544 0a23 6465 6669 6e65  INCLUDED.#define
    │ │ │ -0007e800: 2054 4f52 5245 4e54 5f44 4550 5245 4341   TORRENT_DEPRECA
    │ │ │ -0007e810: 5445 445f 4850 505f 494e 434c 5544 4544  TED_HPP_INCLUDED
    │ │ │ -0007e820: 0a0a 2369 6620 2164 6566 696e 6564 2054  ..#if !defined T
    │ │ │ -0007e830: 4f52 5245 4e54 5f42 5549 4c44 494e 475f  ORRENT_BUILDING_
    │ │ │ -0007e840: 4c49 4252 4152 590a 2320 6465 6669 6e65  LIBRARY.# define
    │ │ │ -0007e850: 2054 4f52 5245 4e54 5f44 4550 5245 4341   TORRENT_DEPRECA
    │ │ │ -0007e860: 5445 4420 5b5b 6465 7072 6563 6174 6564  TED [[deprecated
    │ │ │ -0007e870: 5d5d 0a23 656c 7365 0a23 2064 6566 696e  ]].#else.# defin
    │ │ │ -0007e880: 6520 544f 5252 454e 545f 4445 5052 4543  e TORRENT_DEPREC
    │ │ │ -0007e890: 4154 4544 0a23 656e 6469 660a 0a23 6966  ATED.#endif..#if
    │ │ │ -0007e8a0: 2064 6566 696e 6564 205f 5f63 6c61 6e67   defined __clang
    │ │ │ -0007e8b0: 5f5f 0a0a 2f2f 203d 3d3d 3d3d 3d20 434c  __..// ====== CL
    │ │ │ -0007e8c0: 414e 4720 3d3d 3d3d 3d3d 3d3d 0a0a 2320  ANG ========..# 
    │ │ │ -0007e8d0: 6966 2021 6465 6669 6e65 6420 544f 5252  if !defined TORR
    │ │ │ -0007e8e0: 454e 545f 4255 494c 4449 4e47 5f4c 4942  ENT_BUILDING_LIB
    │ │ │ -0007e8f0: 5241 5259 0a3c 6469 7620 7374 796c 653d  RARY.
    # define TOR │ │ │ -0007e930: 5245 4e54 5f44 4550 5245 4341 5445 445f RENT_DEPRECATED_ │ │ │ -0007e940: 454e 554d 205f 5f61 7474 7269 6275 7465 ENUM __attribute │ │ │ -0007e950: 5f5f 2028 2864 6570 7265 6361 7465 6429 __ ((deprecated) │ │ │ -0007e960: 290a 3c2f 6469 763e 2320 656e 6469 660a ).
    # endif. │ │ │ -0007e970: 0a23 656c 6966 2064 6566 696e 6564 205f .#elif defined _ │ │ │ -0007e980: 5f47 4e55 435f 5f0a 0a2f 2f20 3d3d 3d3d _GNUC__..// ==== │ │ │ -0007e990: 3d3d 3d3d 2047 4343 203d 3d3d 3d3d 3d3d ==== GCC ======= │ │ │ -0007e9a0: 3d0a 0a2f 2f20 6465 7072 6563 6174 696f =..// deprecatio │ │ │ -0007e9b0: 6e20 6d61 726b 7570 2069 7320 6f6e 6c79 n markup is only │ │ │ -0007e9c0: 2065 6e61 626c 6564 2077 6865 6e20 6c69 enabled when li │ │ │ -0007e9d0: 6274 6f72 7265 6e74 0a2f 2f20 6865 6164 btorrent.// head │ │ │ -0007e9e0: 6572 7320 6172 6520 696e 636c 7564 6564 ers are included │ │ │ -0007e9f0: 2062 7920 636c 6965 6e74 732c 206e 6f74 by clients, not │ │ │ -0007ea00: 2077 6869 6c65 2062 7569 6c64 696e 670a while building. │ │ │ -0007ea10: 2f2f 206c 6962 746f 7272 656e 7420 6974 // libtorrent it │ │ │ -0007ea20: 7365 6c66 0a23 2069 6620 5f5f 474e 5543 self.# if __GNUC │ │ │ -0007ea30: 5f5f 2026 6774 3b3d 2036 2026 616d 703b __ >= 6 & │ │ │ -0007ea40: 2661 6d70 3b20 2164 6566 696e 6564 2054 & !defined T │ │ │ -0007ea50: 4f52 5245 4e54 5f42 5549 4c44 494e 475f ORRENT_BUILDING_ │ │ │ -0007ea60: 4c49 4252 4152 590a 2320 2064 6566 696e LIBRARY.# defin │ │ │ -0007ea70: 6520 544f 5252 454e 545f 4445 5052 4543 e TORRENT_DEPREC │ │ │ -0007ea80: 4154 4544 5f45 4e55 4d20 5f5f 6174 7472 ATED_ENUM __attr │ │ │ -0007ea90: 6962 7574 655f 5f20 2828 6465 7072 6563 ibute__ ((deprec │ │ │ -0007eaa0: 6174 6564 2929 0a23 2065 6e64 6966 0a0a ated)).# endif.. │ │ │ -0007eab0: 2365 6e64 6966 0a0a 2369 666e 6465 6620 #endif..#ifndef │ │ │ -0007eac0: 544f 5252 454e 545f 4445 5052 4543 4154 TORRENT_DEPRECAT │ │ │ -0007ead0: 4544 5f45 4e55 4d0a 2364 6566 696e 6520 ED_ENUM.#define │ │ │ -0007eae0: 544f 5252 454e 545f 4445 5052 4543 4154 TORRENT_DEPRECAT │ │ │ -0007eaf0: 4544 5f45 4e55 4d0a 2365 6e64 6966 0a0a ED_ENUM.#endif.. │ │ │ -0007eb00: 2365 6e64 6966 0a3c 2f70 7265 3e3c 2f74 #endif.
    relevanc │ │ │ -0007eb40: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../include/lib │ │ │ -0007eb80: 746f 7272 656e 742f 6175 785f 2f74 6f72 torrent/aux_/tor │ │ │ -0007eb90: 7265 6e74 5f70 6565 722e 6870 703a 3232 rent_peer.hpp:22 │ │ │ -0007eba0: 383c 2f61 3e3c 2f74 643e 3c74 643e 5468 8Th │ │ │ -0007ebb0: 6973 2064 6573 7469 6e61 7469 6f6e 2073 is destination s │ │ │ -0007ebc0: 686f 756c 6420 7072 6f62 6162 6c79 2062 hould probably b │ │ │ -0007ebd0: 6520 6b65 7074 2069 6e20 6269 6e61 7279 e kept in binary │ │ │ -0007ebe0: 2066 6f72 6d20 2872 6174 6865 7220 7468 form (rather th │ │ │ -0007ebf0: 616e 2062 6173 6536 3429 2e20 5468 6520 an base64). The │ │ │ -0007ec00: 7065 6572 7320 7368 6f75 6c64 2070 7269 peers should pri │ │ │ -0007ec10: 6d61 7269 6c79 2062 6520 6861 6e64 6c65 marily be handle │ │ │ -0007ec20: 6420 6279 2074 6865 6972 2073 6861 3235 d by their sha25 │ │ │ -0007ec30: 3620 6861 7368 206f 6620 7468 6520 6465 6 hash of the de │ │ │ -0007ec40: 7374 696e 6174 696f 6e2c 2074 6861 7420 stination, that │ │ │ -0007ec50: 7368 6f75 6c64 2062 6520 6b65 7074 2069 should be kept i │ │ │ -0007ec60: 6e20 6865 7265 2061 7320 7765 6c6c 2e3c n here as well.< │ │ │ -0007ec70: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    Thi │ │ │ -0007ecc0: 7320 6465 7374 696e 6174 696f 6e20 7368 s destination sh │ │ │ -0007ecd0: 6f75 6c64 2070 726f 6261 626c 7920 6265 ould probably be │ │ │ -0007ece0: 206b 6570 7420 696e 2062 696e 6172 7920 kept in binary │ │ │ -0007ecf0: 666f 726d 2028 7261 7468 6572 2074 6861 form (rather tha │ │ │ -0007ed00: 6e0a 6261 7365 3634 292e 2054 6865 2070 n.base64). The p │ │ │ -0007ed10: 6565 7273 2073 686f 756c 6420 7072 696d eers should prim │ │ │ -0007ed20: 6172 696c 7920 6265 2068 616e 646c 6564 arily be handled │ │ │ -0007ed30: 2062 7920 7468 6569 7220 7368 6132 3536 by their sha256 │ │ │ -0007ed40: 2068 6173 680a 6f66 2074 6865 2064 6573 hash.of the des │ │ │ -0007ed50: 7469 6e61 7469 6f6e 2c20 7468 6174 2073 tination, that s │ │ │ -0007ed60: 686f 756c 6420 6265 206b 6570 7420 696e hould be kept in │ │ │ -0007ed70: 2068 6572 6520 6173 2077 656c 6c2e 3c2f here as well.

    ../includ │ │ │ -0007ed90: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ -0007eda0: 5f2f 746f 7272 656e 745f 7065 6572 2e68 _/torrent_peer.h │ │ │ -0007edb0: 7070 3a32 3238 3c2f 6834 3e3c 7072 6520 pp:228

    .};...struc
    │ │ │ -0007ee00: 7420 544f 5252 454e 545f 4558 5452 415f  t TORRENT_EXTRA_
    │ │ │ -0007ee10: 4558 504f 5254 2069 7076 345f 7065 6572  EXPORT ipv4_peer
    │ │ │ -0007ee20: 203a 2074 6f72 7265 6e74 5f70 6565 720a   : torrent_peer.
    │ │ │ -0007ee30: 097b 0a09 0969 7076 345f 7065 6572 2874  .{...ipv4_peer(t
    │ │ │ -0007ee40: 6370 3a3a 656e 6470 6f69 6e74 2063 6f6e  cp::endpoint con
    │ │ │ -0007ee50: 7374 2661 6d70 3b20 6570 2c20 626f 6f6c  st& ep, bool
    │ │ │ -0007ee60: 2063 6f6e 6e65 6374 6162 6c65 2c20 7065   connectable, pe
    │ │ │ -0007ee70: 6572 5f73 6f75 7263 655f 666c 6167 735f  er_source_flags_
    │ │ │ -0007ee80: 7420 7372 6329 3b0a 0909 6970 7634 5f70  t src);...ipv4_p
    │ │ │ -0007ee90: 6565 7228 6970 7634 5f70 6565 7220 636f  eer(ipv4_peer co
    │ │ │ -0007eea0: 6e73 7426 616d 703b 2070 293b 0a09 0969  nst& p);...i
    │ │ │ -0007eeb0: 7076 345f 7065 6572 2661 6d70 3b20 6f70  pv4_peer& op
    │ │ │ -0007eec0: 6572 6174 6f72 3d28 6970 7634 5f70 6565  erator=(ipv4_pee
    │ │ │ -0007eed0: 7220 636f 6e73 7426 616d 703b 2070 2920  r const& p) 
    │ │ │ -0007eee0: 2661 6d70 3b3b 0a0a 0909 6164 6472 6573  &;....addres
    │ │ │ -0007eef0: 735f 7634 2061 6464 723b 0a09 7d3b 0a0a  s_v4 addr;..};..
    │ │ │ -0007ef00: 2369 6620 544f 5252 454e 545f 5553 455f  #if TORRENT_USE_
    │ │ │ -0007ef10: 4932 500a 0973 7472 7563 7420 544f 5252  I2P..struct TORR
    │ │ │ -0007ef20: 454e 545f 4558 5452 415f 4558 504f 5254  ENT_EXTRA_EXPORT
    │ │ │ -0007ef30: 2069 3270 5f70 6565 7220 3a20 746f 7272   i2p_peer : torr
    │ │ │ -0007ef40: 656e 745f 7065 6572 0a09 7b0a 0909 6932  ent_peer..{...i2
    │ │ │ -0007ef50: 705f 7065 6572 2873 7472 696e 675f 7669  p_peer(string_vi
    │ │ │ -0007ef60: 6577 2064 6573 742c 2062 6f6f 6c20 636f  ew dest, bool co
    │ │ │ -0007ef70: 6e6e 6563 7461 626c 652c 2070 6565 725f  nnectable, peer_
    │ │ │ -0007ef80: 736f 7572 6365 5f66 6c61 6773 5f74 2073  source_flags_t s
    │ │ │ -0007ef90: 7263 293b 0a09 0969 3270 5f70 6565 7228  rc);...i2p_peer(
    │ │ │ -0007efa0: 6932 705f 7065 6572 2063 6f6e 7374 2661  i2p_peer const&a
    │ │ │ -0007efb0: 6d70 3b29 203d 2064 656c 6574 653b 0a09  mp;) = delete;..
    │ │ │ -0007efc0: 0969 3270 5f70 6565 7226 616d 703b 206f  .i2p_peer& o
    │ │ │ -0007efd0: 7065 7261 746f 723d 2869 3270 5f70 6565  perator=(i2p_pee
    │ │ │ -0007efe0: 7220 636f 6e73 7426 616d 703b 2920 3d20  r const&) = 
    │ │ │ -0007eff0: 6465 6c65 7465 3b0a 0909 6932 705f 7065  delete;...i2p_pe
    │ │ │ -0007f000: 6572 2869 3270 5f70 6565 7226 616d 703b  er(i2p_peer&
    │ │ │ -0007f010: 2661 6d70 3b29 203d 2064 6566 6175 6c74  &) = default
    │ │ │ -0007f020: 3b0a 0909 6932 705f 7065 6572 2661 6d70  ;...i2p_peer&
    │ │ │ -0007f030: 3b20 6f70 6572 6174 6f72 3d28 6932 705f  ; operator=(i2p_
    │ │ │ -0007f040: 7065 6572 2661 6d70 3b26 616d 703b 2920  peer&&) 
    │ │ │ -0007f050: 2661 6d70 3b20 3d20 6465 6661 756c 743b  & = default;
    │ │ │ -0007f060: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ -0007f090: 0909 6175 783a 3a73 7472 696e 675f 7074 ..aux::string_pt │ │ │ -0007f0a0: 7220 6465 7374 696e 6174 696f 6e3b 0a3c r destination;.< │ │ │ -0007f0b0: 2f64 6976 3e09 7d3b 0a23 656e 6469 660a /div>.};.#endif. │ │ │ -0007f0c0: 0a23 6966 2054 4f52 5245 4e54 5f55 5345 .#if TORRENT_USE │ │ │ -0007f0d0: 5f52 5443 0a09 7374 7275 6374 2054 4f52 _RTC..struct TOR │ │ │ -0007f0e0: 5245 4e54 5f45 5854 5241 5f45 5850 4f52 RENT_EXTRA_EXPOR │ │ │ -0007f0f0: 5420 7274 635f 7065 6572 203a 2074 6f72 T rtc_peer : tor │ │ │ -0007f100: 7265 6e74 5f70 6565 720a 097b 0a09 0972 rent_peer..{...r │ │ │ -0007f110: 7463 5f70 6565 7228 7463 703a 3a65 6e64 tc_peer(tcp::end │ │ │ -0007f120: 706f 696e 7420 6570 2c20 7065 6572 5f73 point ep, peer_s │ │ │ -0007f130: 6f75 7263 655f 666c 6167 735f 7420 7372 ource_flags_t sr │ │ │ -0007f140: 6329 3b0a 0909 7274 635f 7065 6572 2872 c);...rtc_peer(r │ │ │ -0007f150: 7463 5f70 6565 7220 636f 6e73 7426 616d tc_peer const&am │ │ │ -0007f160: 703b 2920 3d20 6465 6c65 7465 3b0a 0909 p;) = delete;... │ │ │ -0007f170: 7274 635f 7065 6572 2661 6d70 3b20 6f70 rtc_peer& op │ │ │ -0007f180: 6572 6174 6f72 3d28 7274 635f 7065 6572 erator=(rtc_peer │ │ │ -0007f190: 2063 6f6e 7374 2661 6d70 3b29 203d 2064 const&) = d │ │ │ -0007f1a0: 656c 6574 653b 0a09 0972 7463 5f70 6565 elete;...rtc_pee │ │ │ -0007f1b0: 7228 7274 635f 7065 6572 2661 6d70 3b26 r(rtc_peer&& │ │ │ -0007f1c0: 616d 703b 2920 3d20 6465 6661 756c 743b amp;) = default; │ │ │ -0007f1d0: 0a09 0972 7463 5f70 6565 7226 616d 703b ...rtc_peer& │ │ │ -0007f1e0: 206f 7065 7261 746f 723d 2872 7463 5f70 operator=(rtc_p │ │ │ -0007f1f0: 6565 7226 616d 703b 2661 6d70 3b29 2026 eer&&) & │ │ │ -0007f200: 616d 703b 203d 2064 6566 6175 6c74 3b0a amp; = default;. │ │ │ -0007f210: 0a09 0974 6370 3a3a 656e 6470 6f69 6e74 ...tcp::endpoint │ │ │ -0007f220: 2065 6e64 706f 696e 743b 0a09 7d3b 0a23 endpoint;..};.# │ │ │ -0007f230: 656e 6469 660a 0a09 7374 7275 6374 2054 endif...struct T │ │ │ -0007f240: 4f52 5245 4e54 5f45 5854 5241 5f45 5850 ORRENT_EXTRA_EXP │ │ │ -0007f250: 4f52 5420 6970 7636 5f70 6565 7220 3a20 ORT ipv6_peer : │ │ │ -0007f260: 746f 7272 656e 745f 7065 6572 0a09 7b0a torrent_peer..{. │ │ │ -0007f270: 0909 6970 7636 5f70 6565 7228 7463 703a ..ipv6_peer(tcp: │ │ │ -0007f280: 3a65 6e64 706f 696e 7420 636f 6e73 7426 :endpoint const& │ │ │ -0007f290: 616d 703b 2065 702c 2062 6f6f 6c20 636f amp; ep, bool co │ │ │ -0007f2a0: 6e6e 6563 7461 626c 652c 2070 6565 725f nnectable, peer_ │ │ │ -0007f2b0: 736f 7572 6365 5f66 6c61 6773 5f74 2073 source_flags_t s │ │ │ -0007f2c0: 7263 293b 0a09 0969 7076 365f 7065 6572 rc);...ipv6_peer │ │ │ -0007f2d0: 2869 7076 365f 7065 6572 2063 6f6e 7374 (ipv6_peer const │ │ │ -0007f2e0: 2661 6d70 3b20 7029 3b0a 0a09 0963 6f6e & p);....con │ │ │ -0007f2f0: 7374 2061 6464 7265 7373 5f76 363a 3a62 st address_v6::b │ │ │ -0007f300: 7974 6573 5f74 7970 6520 6164 6472 3b0a ytes_type addr;. │ │ │ -0007f310: 097d 3b0a 0a09 2f2f 2069 6620 7765 2068 .};...// if we h │ │ │ -0007f320: 6176 6520 6932 7020 7065 6572 2061 6464 ave i2p peer add │ │ │ -0007f330: 7265 7373 6573 2c20 736f 7274 2074 6865 resses, sort the │ │ │ -0007f340: 6d20 2a61 6674 6572 2a20 616c 6c20 4950 m *after* all IP │ │ │ -0007f350: 2061 6464 7265 7373 6573 0a09 7374 7275 addresses..stru │ │ │ -0007f360: 6374 2070 6565 725f 6164 6472 6573 735f ct peer_address_ │ │ │ -0007f370: 636f 6d70 6172 650a 097b 0a09 0962 6f6f compare..{...boo │ │ │ -0007f380: 6c20 6f70 6572 6174 6f72 2829 2874 6f72 l operator()(tor │ │ │ -0007f390: 7265 6e74 5f70 6565 7220 636f 6e73 742a rent_peer const* │ │ │ -0007f3a0: 206c 6873 2c20 6164 6472 6573 7320 636f lhs, address co │ │ │ -0007f3b0: 6e73 7426 616d 703b 2072 6873 2920 636f nst& rhs) co │ │ │ -0007f3c0: 6e73 740a 0909 7b0a 2369 6620 544f 5252 nst...{.#if TORR │ │ │ -0007f3d0: 454e 545f 5553 455f 4932 500a 3c2f 7072 ENT_USE_I2P.rel │ │ │ -0007f410: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../includ │ │ │ -0007f450: 652f 6c69 6274 6f72 7265 6e74 2f61 7578 e/libtorrent/aux │ │ │ -0007f460: 5f2f 6469 736b 5f63 6163 6865 2e68 7070 _/disk_cache.hpp │ │ │ -0007f470: 3a33 3530 3c2f 613e 3c2f 7464 3e3c 7464 :350it would be nic │ │ │ -0007f490: 6520 6966 2074 6869 7320 636f 756c 6420 e if this could │ │ │ -0007f4a0: 6265 2063 616c 6c65 6420 7769 7468 6f75 be called withou │ │ │ -0007f4b0: 7420 686f 6c64 696e 6720 7468 6520 6d75 t holding the mu │ │ │ -0007f4c0: 7465 782e 2049 7420 776f 756c 6420 7265 tex. It would re │ │ │ -0007f4d0: 7175 6972 6520 6265 696e 6720 6162 6c65 quire being able │ │ │ -0007f4e0: 2074 6f20 6c6f 636b 2074 6865 2070 6965 to lock the pie │ │ │ -0007f4f0: 6365 3c2f 7464 3e3c 2f74 723e 3c74 7220 ce

    │ │ │ -0007f540: 6974 2077 6f75 6c64 2062 6520 6e69 6365 it would be nice │ │ │ -0007f550: 2069 6620 7468 6973 2063 6f75 6c64 2062 if this could b │ │ │ -0007f560: 6520 6361 6c6c 6564 2077 6974 686f 7574 e called without │ │ │ -0007f570: 2068 6f6c 6469 6e67 0a74 6865 206d 7574 holding.the mut │ │ │ -0007f580: 6578 2e20 4974 2077 6f75 6c64 2072 6571 ex. It would req │ │ │ -0007f590: 7569 7265 2062 6569 6e67 2061 626c 6520 uire being able │ │ │ -0007f5a0: 746f 206c 6f63 6b20 7468 6520 7069 6563 to lock the piec │ │ │ -0007f5b0: 653c 2f68 323e 3c68 343e 2e2e 2f69 6e63 e

    ../inc │ │ │ -0007f5c0: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -0007f5d0: 6175 785f 2f64 6973 6b5f 6361 6368 652e aux_/disk_cache. │ │ │ -0007f5e0: 6870 703a 3335 303c 2f68 343e 3c70 7265 hpp:350

    ..mi::hash
    │ │ │ -0007f630: 6564 5f75 6e69 7175 6526 6c74 3b6d 693a  ed_unique<mi:
    │ │ │ -0007f640: 3a6d 656d 6265 7226 6c74 3b63 6163 6865  :member<cache
    │ │ │ -0007f650: 645f 7069 6563 655f 656e 7472 792c 2070  d_piece_entry, p
    │ │ │ -0007f660: 6965 6365 5f6c 6f63 6174 696f 6e2c 2026  iece_location, &
    │ │ │ -0007f670: 616d 703b 6361 6368 6564 5f70 6965 6365  amp;cached_piece
    │ │ │ -0007f680: 5f65 6e74 7279 3a3a 7069 6563 6526 6774  _entry::piece>
    │ │ │ -0007f690: 3b26 6774 3b2c 0a09 092f 2f20 6f72 6465  ;>,...// orde
    │ │ │ -0007f6a0: 7265 6420 6279 2077 6865 7468 6572 2074  red by whether t
    │ │ │ -0007f6b0: 6865 2070 6965 6365 206e 6565 6473 2069  he piece needs i
    │ │ │ -0007f6c0: 7473 2068 6173 6865 7220 6b69 636b 6564  ts hasher kicked
    │ │ │ -0007f6d0: 2e0a 0909 2f2f 2074 7275 6520 6973 206f  ....// true is o
    │ │ │ -0007f6e0: 7264 6572 6564 2062 6566 6f72 6520 6661  rdered before fa
    │ │ │ -0007f6f0: 6c73 652c 2073 6f20 7069 6563 6573 206e  lse, so pieces n
    │ │ │ -0007f700: 6565 6469 6e67 2061 206b 6963 6b20 636f  eeding a kick co
    │ │ │ -0007f710: 6d65 2066 6972 7374 2e0a 0909 6d69 3a3a  me first....mi::
    │ │ │ -0007f720: 6f72 6465 7265 645f 6e6f 6e5f 756e 6971  ordered_non_uniq
    │ │ │ -0007f730: 7565 266c 743b 6d69 3a3a 636f 6e73 745f  ue<mi::const_
    │ │ │ -0007f740: 6d65 6d5f 6675 6e26 6c74 3b63 6163 6865  mem_fun<cache
    │ │ │ -0007f750: 645f 7069 6563 655f 656e 7472 792c 2062  d_piece_entry, b
    │ │ │ -0007f760: 6f6f 6c2c 2026 616d 703b 6361 6368 6564  ool, &cached
    │ │ │ -0007f770: 5f70 6965 6365 5f65 6e74 7279 3a3a 6e65  _piece_entry::ne
    │ │ │ -0007f780: 6564 735f 6861 7368 6572 5f6b 6963 6b26  eds_hasher_kick&
    │ │ │ -0007f790: 6774 3b2c 2073 7464 3a3a 6772 6561 7465  gt;, std::greate
    │ │ │ -0007f7a0: 7226 6c74 3b76 6f69 6426 6774 3b26 6774  r<void>>
    │ │ │ -0007f7b0: 3b0a 0909 2667 743b 0a09 2667 743b 3b0a  ;...>..>;.
    │ │ │ -0007f7c0: 0a09 7465 6d70 6c61 7465 2026 6c74 3b74  ..template <t
    │ │ │ -0007f7d0: 7970 656e 616d 6520 4675 6e26 6774 3b0a  ypename Fun>.
    │ │ │ -0007f7e0: 0962 6f6f 6c20 6765 7428 7069 6563 655f  .bool get(piece_
    │ │ │ -0007f7f0: 6c6f 6361 7469 6f6e 2063 6f6e 7374 206c  location const l
    │ │ │ -0007f800: 6f63 2c20 696e 7420 636f 6e73 7420 626c  oc, int const bl
    │ │ │ -0007f810: 6f63 6b5f 6964 782c 2046 756e 2066 2920  ock_idx, Fun f) 
    │ │ │ -0007f820: 636f 6e73 740a 097b 0a09 0973 7464 3a3a  const..{...std::
    │ │ │ -0007f830: 756e 6971 7565 5f6c 6f63 6b26 6c74 3b73  unique_lock<s
    │ │ │ -0007f840: 7464 3a3a 6d75 7465 7826 6774 3b20 6c28  td::mutex> l(
    │ │ │ -0007f850: 6d5f 6d75 7465 7829 3b0a 0a09 0949 4e56  m_mutex);....INV
    │ │ │ -0007f860: 4152 4941 4e54 5f43 4845 434b 3b0a 0a09  ARIANT_CHECK;...
    │ │ │ -0007f870: 0961 7574 6f26 616d 703b 2076 6965 7720  .auto& view 
    │ │ │ -0007f880: 3d20 6d5f 7069 6563 6573 2e74 656d 706c  = m_pieces.templ
    │ │ │ -0007f890: 6174 6520 6765 7426 6c74 3b30 2667 743b  ate get<0>
    │ │ │ -0007f8a0: 2829 3b0a 0909 6175 746f 2069 203d 2076  ();...auto i = v
    │ │ │ -0007f8b0: 6965 772e 6669 6e64 286c 6f63 293b 0a09  iew.find(loc);..
    │ │ │ -0007f8c0: 0969 6620 2869 203d 3d20 7669 6577 2e65  .if (i == view.e
    │ │ │ -0007f8d0: 6e64 2829 2920 7265 7475 726e 2066 616c  nd()) return fal
    │ │ │ -0007f8e0: 7365 3b0a 0a09 0969 6620 2869 2d26 6774  se;....if (i->
    │ │ │ -0007f8f0: 3b62 6c6f 636b 735b 626c 6f63 6b5f 6964  ;blocks[block_id
    │ │ │ -0007f900: 785d 2e64 6174 6128 2929 0a09 097b 0a3c  x].data())...{.<
    │ │ │ -0007f910: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ -0007f920: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ -0007f930: 7769 6474 683d 2231 3030 2522 3e09 0909  width="100%">...
    │ │ │ -0007f940: 696e 7420 636f 6e73 7420 626c 6b5f 7369  int const blk_si
    │ │ │ -0007f950: 7a65 203d 2073 7464 3a3a 6d69 6e28 6465  ze = std::min(de
    │ │ │ -0007f960: 6661 756c 745f 626c 6f63 6b5f 7369 7a65  fault_block_size
    │ │ │ -0007f970: 0a3c 2f64 6976 3e09 0909 092c 2069 2d26  .
    ...., i-& │ │ │ -0007f980: 6774 3b70 6965 6365 5f73 697a 6520 2d20 gt;piece_size - │ │ │ -0007f990: 626c 6f63 6b5f 6964 7820 2a20 6465 6661 block_idx * defa │ │ │ -0007f9a0: 756c 745f 626c 6f63 6b5f 7369 7a65 293b ult_block_size); │ │ │ -0007f9b0: 0a09 0909 6628 692d 2667 743b 626c 6f63 ....f(i->bloc │ │ │ -0007f9c0: 6b73 5b62 6c6f 636b 5f69 6478 5d2e 6275 ks[block_idx].bu │ │ │ -0007f9d0: 6628 626c 6b5f 7369 7a65 2929 3b0a 0909 f(blk_size));... │ │ │ -0007f9e0: 0972 6574 7572 6e20 7472 7565 3b0a 0909 .return true;... │ │ │ -0007f9f0: 7d0a 0909 7265 7475 726e 2066 616c 7365 }...return false │ │ │ -0007fa00: 3b0a 097d 0a0a 0974 656d 706c 6174 6520 ;..}...template │ │ │ -0007fa10: 266c 743b 7479 7065 6e61 6d65 2046 756e <typename Fun │ │ │ -0007fa20: 2667 743b 0a09 7368 6132 3536 5f68 6173 >..sha256_has │ │ │ -0007fa30: 6820 6861 7368 3228 7069 6563 655f 6c6f h hash2(piece_lo │ │ │ -0007fa40: 6361 7469 6f6e 2063 6f6e 7374 206c 6f63 cation const loc │ │ │ -0007fa50: 2c20 696e 7420 636f 6e73 7420 626c 6f63 , int const bloc │ │ │ -0007fa60: 6b5f 6964 782c 2046 756e 2066 2920 636f k_idx, Fun f) co │ │ │ -0007fa70: 6e73 740a 097b 0a09 0973 7464 3a3a 756e nst..{...std::un │ │ │ -0007fa80: 6971 7565 5f6c 6f63 6b26 6c74 3b73 7464 ique_lock<std │ │ │ -0007fa90: 3a3a 6d75 7465 7826 6774 3b20 6c28 6d5f ::mutex> l(m_ │ │ │ -0007faa0: 6d75 7465 7829 3b0a 0a09 0949 4e56 4152 mutex);....INVAR │ │ │ -0007fab0: 4941 4e54 5f43 4845 434b 3b0a 0a09 0961 IANT_CHECK;....a │ │ │ -0007fac0: 7574 6f26 616d 703b 2076 6965 7720 3d20 uto& view = │ │ │ -0007fad0: 6d5f 7069 6563 6573 2e74 656d 706c 6174 m_pieces.templat │ │ │ -0007fae0: 6520 6765 7426 6c74 3b30 2667 743b 2829 e get<0>() │ │ │ -0007faf0: 3b0a 0909 6175 746f 2069 203d 2076 6965 ;...auto i = vie │ │ │ -0007fb00: 772e 6669 6e64 286c 6f63 293b 0a09 0969 w.find(loc);...i │ │ │ -0007fb10: 6620 2869 203d 3d20 7669 6577 2e65 6e64 f (i == view.end │ │ │ -0007fb20: 2829 290a 0909 7b0a 0909 096c 2e75 6e6c ())...{....l.unl │ │ │ -0007fb30: 6f63 6b28 293b 0a09 0909 7265 7475 726e ock();....return │ │ │ -0007fb40: 2066 2829 3b0a 0909 7d0a 0a09 092f 2f20 f();...}....// │ │ │ -0007fb50: 416e 6f74 6865 7220 7468 7265 6164 206d Another thread m │ │ │ -0007fb60: 6179 2062 6520 6861 7368 696e 6720 7468 ay be hashing th │ │ │ -0007fb70: 6973 2070 6965 6365 2072 6967 6874 206e is piece right n │ │ │ -0007fb80: 6f77 2e20 496e 2074 6869 7320 6361 7365 ow. In this case │ │ │ -0007fb90: 2077 650a 0909 2f2f 206e 6565 6420 746f we...// need to │ │ │ -0007fba0: 2077 6169 740a 3c2f 7072 653e 3c2f 7464 wait.
    relevance │ │ │ -0007fbe0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ -0007fbf0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../include/libt │ │ │ -0007fc20: 6f72 7265 6e74 2f61 7578 5f2f 6469 736b orrent/aux_/disk │ │ │ -0007fc30: 5f63 6163 6865 2e68 7070 3a33 3737 3c2f _cache.hpp:377there │ │ │ -0007fc50: 206d 6179 2062 6520 6120 6265 7474 6572 may be a better │ │ │ -0007fc60: 2077 6179 2074 6f20 736f 6c76 6520 7468 way to solve th │ │ │ -0007fc70: 6973 2c20 6d61 7962 6520 6861 6e67 2074 is, maybe hang t │ │ │ -0007fc80: 6865 206a 6f62 206f 6e20 7468 6520 7069 he job on the pi │ │ │ -0007fc90: 6563 6520 616e 6420 7472 7920 6c61 7465 ece and try late │ │ │ -0007fca0: 722e 2042 7574 2069 7427 7320 6120 6269 r. But it's a bi │ │ │ -0007fcb0: 6720 6368 616e 6765 2074 6f20 646f 2073 g change to do s │ │ │ -0007fcc0: 6f3c 2f74 643e 3c2f 7472 3e3c 7472 2069 o

    t │ │ │ -0007fd10: 6865 7265 206d 6179 2062 6520 6120 6265 here may be a be │ │ │ -0007fd20: 7474 6572 2077 6179 2074 6f20 736f 6c76 tter way to solv │ │ │ -0007fd30: 6520 7468 6973 2c20 6d61 7962 6520 6861 e this, maybe ha │ │ │ -0007fd40: 6e67 2074 6865 206a 6f62 206f 6e0a 7468 ng the job on.th │ │ │ -0007fd50: 6520 7069 6563 6520 616e 6420 7472 7920 e piece and try │ │ │ -0007fd60: 6c61 7465 722e 2042 7574 2069 7427 7320 later. But it's │ │ │ -0007fd70: 6120 6269 6720 6368 616e 6765 2074 6f20 a big change to │ │ │ -0007fd80: 646f 2073 6f3c 2f68 323e 3c68 343e 2e2e do so

    .. │ │ │ -0007fd90: 2f69 6e63 6c75 6465 2f6c 6962 746f 7272 /include/libtorr │ │ │ -0007fda0: 656e 742f 6175 785f 2f64 6973 6b5f 6361 ent/aux_/disk_ca │ │ │ -0007fdb0: 6368 652e 6870 703a 3337 373c 2f68 343e che.hpp:377

    │ │ │ -0007fdc0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..retu
    │ │ │ -0007fe00: 726e 2066 616c 7365 3b0a 097d 0a0a 0974  rn false;..}...t
    │ │ │ -0007fe10: 656d 706c 6174 6520 266c 743b 7479 7065  emplate <type
    │ │ │ -0007fe20: 6e61 6d65 2046 756e 2667 743b 0a09 7368  name Fun>..sh
    │ │ │ -0007fe30: 6132 3536 5f68 6173 6820 6861 7368 3228  a256_hash hash2(
    │ │ │ -0007fe40: 7069 6563 655f 6c6f 6361 7469 6f6e 2063  piece_location c
    │ │ │ -0007fe50: 6f6e 7374 206c 6f63 2c20 696e 7420 636f  onst loc, int co
    │ │ │ -0007fe60: 6e73 7420 626c 6f63 6b5f 6964 782c 2046  nst block_idx, F
    │ │ │ -0007fe70: 756e 2066 2920 636f 6e73 740a 097b 0a09  un f) const..{..
    │ │ │ -0007fe80: 0973 7464 3a3a 756e 6971 7565 5f6c 6f63  .std::unique_loc
    │ │ │ -0007fe90: 6b26 6c74 3b73 7464 3a3a 6d75 7465 7826  k<std::mutex&
    │ │ │ -0007fea0: 6774 3b20 6c28 6d5f 6d75 7465 7829 3b0a  gt; l(m_mutex);.
    │ │ │ -0007feb0: 0a09 0949 4e56 4152 4941 4e54 5f43 4845  ...INVARIANT_CHE
    │ │ │ -0007fec0: 434b 3b0a 0a09 0961 7574 6f26 616d 703b  CK;....auto&
    │ │ │ -0007fed0: 2076 6965 7720 3d20 6d5f 7069 6563 6573   view = m_pieces
    │ │ │ -0007fee0: 2e74 656d 706c 6174 6520 6765 7426 6c74  .template get<
    │ │ │ -0007fef0: 3b30 2667 743b 2829 3b0a 0909 6175 746f  ;0>();...auto
    │ │ │ -0007ff00: 2069 203d 2076 6965 772e 6669 6e64 286c   i = view.find(l
    │ │ │ -0007ff10: 6f63 293b 0a09 0969 6620 2869 203d 3d20  oc);...if (i == 
    │ │ │ -0007ff20: 7669 6577 2e65 6e64 2829 290a 0909 7b0a  view.end())...{.
    │ │ │ -0007ff30: 0909 096c 2e75 6e6c 6f63 6b28 293b 0a09  ...l.unlock();..
    │ │ │ -0007ff40: 0909 7265 7475 726e 2066 2829 3b0a 0909  ..return f();...
    │ │ │ -0007ff50: 7d0a 0a09 092f 2f20 416e 6f74 6865 7220  }....// Another 
    │ │ │ -0007ff60: 7468 7265 6164 206d 6179 2062 6520 6861  thread may be ha
    │ │ │ -0007ff70: 7368 696e 6720 7468 6973 2070 6965 6365  shing this piece
    │ │ │ -0007ff80: 2072 6967 6874 206e 6f77 2e20 496e 2074   right now. In t
    │ │ │ -0007ff90: 6869 7320 6361 7365 2077 650a 0909 2f2f  his case we...//
    │ │ │ -0007ffa0: 206e 6565 6420 746f 2077 6169 740a 3c64   need to wait...wh
    │ │ │ -0007ffe0: 696c 6520 2869 2d26 6774 3b66 6c61 6773  ile (i->flags
    │ │ │ -0007fff0: 2026 616d 703b 2063 6163 6865 645f 7069   & cached_pi
    │ │ │ -00080000: 6563 655f 656e 7472 793a 3a68 6173 6869  ece_entry::hashi
    │ │ │ -00080010: 6e67 5f66 6c61 6729 0a3c 2f64 6976 3e09  ng_flag).
    . │ │ │ -00080020: 097b 0a09 0909 6c2e 756e 6c6f 636b 2829 .{....l.unlock() │ │ │ -00080030: 3b0a 0909 0973 7464 3a3a 7468 6973 5f74 ;....std::this_t │ │ │ -00080040: 6872 6561 643a 3a79 6965 6c64 2829 3b0a hread::yield();. │ │ │ -00080050: 0909 096c 2e6c 6f63 6b28 293b 0a0a 0909 ...l.lock();.... │ │ │ -00080060: 0969 203d 2076 6965 772e 6669 6e64 286c .i = view.find(l │ │ │ -00080070: 6f63 293b 0a09 0909 6966 2028 6920 3d3d oc);....if (i == │ │ │ -00080080: 2076 6965 772e 656e 6428 2929 0a09 0909 view.end()).... │ │ │ -00080090: 7b0a 0909 0909 6c2e 756e 6c6f 636b 2829 {.....l.unlock() │ │ │ -000800a0: 3b0a 0909 0909 7265 7475 726e 2066 2829 ;.....return f() │ │ │ -000800b0: 3b0a 0909 097d 0a09 097d 0a09 0961 7574 ;....}...}...aut │ │ │ -000800c0: 6f20 636f 6e73 7426 616d 703b 2063 6265 o const& cbe │ │ │ -000800d0: 203d 2069 2d26 6774 3b62 6c6f 636b 735b = i->blocks[ │ │ │ -000800e0: 626c 6f63 6b5f 6964 785d 3b0a 0909 2f2f block_idx];...// │ │ │ -000800f0: 2069 6e64 6570 656e 6465 6e74 206f 6620 independent of │ │ │ -00080100: 6861 7368 6572 5f63 7572 736f 723a 2061 hasher_cursor: a │ │ │ -00080110: 6e79 2076 3220 626c 6f63 6b20 6d61 7920 ny v2 block may │ │ │ -00080120: 6265 2068 6173 6865 6420 696e 2061 6e79 be hashed in any │ │ │ -00080130: 0a09 092f 2f20 6f72 6465 722e 2050 7265 ...// order. Pre │ │ │ -00080140: 636f 6d70 7574 6564 2076 3220 6861 7368 computed v2 hash │ │ │ -00080150: 6573 206c 6976 6520 6f6e 2070 7265 6164 es live on pread │ │ │ -00080160: 5f73 746f 7261 6765 2061 6e64 2061 7265 _storage and are │ │ │ -00080170: 0a09 092f 2f20 636f 6e73 756c 7465 6420 ...// consulted │ │ │ -00080180: 6279 2074 6865 2063 616c 6c65 7220 6265 by the caller be │ │ │ -00080190: 666f 7265 2072 6561 6368 696e 6720 6865 fore reaching he │ │ │ -000801a0: 7265 2e0a 0909 6966 2028 6362 652e 6461 re....if (cbe.da │ │ │ -000801b0: 7461 2829 290a 0909 7b0a 0909 0969 6e74 ta())...{....int │ │ │ -000801c0: 2063 6f6e 7374 2062 6c6b 5f73 697a 6520 const blk_size │ │ │ -000801d0: 3d20 7374 643a 3a6d 696e 2864 6566 6175 = std::min(defau │ │ │ -000801e0: 6c74 5f62 6c6f 636b 5f73 697a 650a 0909 lt_block_size... │ │ │ -000801f0: 0909 2c20 692d 2667 743b 7069 6563 655f .., i->piece_ │ │ │ -00080200: 7369 7a65 3220 2d20 626c 6f63 6b5f 6964 size2 - block_id │ │ │ -00080210: 7820 2a20 6465 6661 756c 745f 626c 6f63 x * default_bloc │ │ │ -00080220: 6b5f 7369 7a65 293b 0a09 0909 6861 7368 k_size);....hash │ │ │ -00080230: 6572 3235 3620 683b 0a09 0909 682e 7570 er256 h;....h.up │ │ │ -00080240: 6461 7465 2863 6265 2e62 7566 2862 6c6b date(cbe.buf(blk │ │ │ -00080250: 5f73 697a 6529 293b 0a09 0909 7265 7475 _size));....retu │ │ │ -00080260: 726e 2068 2e66 696e 616c 2829 3b0a 0909 rn h.final();... │ │ │ -00080270: 7d0a 0909 6c2e 756e 6c6f 636b 2829 3b0a }...l.unlock();. │ │ │ -00080280: 0909 7265 7475 726e 2066 2829 3b0a 097d ..return f();..} │ │ │ -00080290: 0a0a 0965 6e75 6d20 636c 6173 7320 6861 ...enum class ha │ │ │ -000802a0: 7368 5f70 6965 6365 5f72 6573 756c 7420 sh_piece_result │ │ │ -000802b0: 7b20 6e6f 745f 696e 5f63 6163 6865 2c20 { not_in_cache, │ │ │ -000802c0: 636f 6d70 6c65 7465 642c 2064 6566 6572 completed, defer │ │ │ -000802d0: 7265 6420 7d3b 0a0a 3c2f 7072 653e 3c2f red };..
    relevan │ │ │ -00080310: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../include/li │ │ │ -00080350: 6274 6f72 7265 6e74 2f61 7578 5f2f 706f btorrent/aux_/po │ │ │ -00080360: 6f6c 2e68 7070 3a32 373c 2f61 3e3c 2f74 ol.hpp:27
    ensure the │ │ │ -00080380: 2061 6c69 676e 6d65 6e74 2069 7320 676f alignment is go │ │ │ -00080390: 6f64 2068 6572 653c 2f74 643e 3c2f 7472 od here

    ensure the │ │ │ -000803f0: 616c 6967 6e6d 656e 7420 6973 2067 6f6f alignment is goo │ │ │ -00080400: 6420 6865 7265 3c2f 6832 3e3c 6834 3e2e d here

    . │ │ │ -00080410: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -00080420: 7265 6e74 2f61 7578 5f2f 706f 6f6c 2e68 rent/aux_/pool.h │ │ │ -00080430: 7070 3a32 373c 2f68 343e 3c70 7265 2073 pp:27

    see LICENSE 
    │ │ │ -00080480: 6669 6c65 2e0a 2a2f 0a0a 2369 666e 6465  file..*/..#ifnde
    │ │ │ -00080490: 6620 544f 5252 454e 545f 504f 4f4c 5f48  f TORRENT_POOL_H
    │ │ │ -000804a0: 5050 0a23 6465 6669 6e65 2054 4f52 5245  PP.#define TORRE
    │ │ │ -000804b0: 4e54 5f50 4f4f 4c5f 4850 500a 0a23 696e  NT_POOL_HPP..#in
    │ │ │ -000804c0: 636c 7564 6520 226c 6962 746f 7272 656e  clude "libtorren
    │ │ │ -000804d0: 742f 6175 785f 2f64 6973 6162 6c65 5f77  t/aux_/disable_w
    │ │ │ -000804e0: 6172 6e69 6e67 735f 7075 7368 2e68 7070  arnings_push.hpp
    │ │ │ -000804f0: 220a 2369 6e63 6c75 6465 2026 6c74 3b62  ".#include <b
    │ │ │ -00080500: 6f6f 7374 2f70 6f6f 6c2f 706f 6f6c 2e68  oost/pool/pool.h
    │ │ │ -00080510: 7070 2667 743b 0a23 696e 636c 7564 6520  pp>.#include 
    │ │ │ -00080520: 226c 6962 746f 7272 656e 742f 6175 785f  "libtorrent/aux_
    │ │ │ -00080530: 2f64 6973 6162 6c65 5f77 6172 6e69 6e67  /disable_warning
    │ │ │ -00080540: 735f 706f 702e 6870 7022 0a0a 2369 6e63  s_pop.hpp"..#inc
    │ │ │ -00080550: 6c75 6465 2026 6c74 3b63 7374 6464 6566  lude <cstddef
    │ │ │ -00080560: 2667 743b 0a0a 6e61 6d65 7370 6163 6520  >..namespace 
    │ │ │ -00080570: 6c69 6274 6f72 7265 6e74 207b 0a6e 616d  libtorrent {.nam
    │ │ │ -00080580: 6573 7061 6365 2061 7578 207b 0a0a 7374  espace aux {..st
    │ │ │ -00080590: 7275 6374 2061 6c6c 6f63 6174 6f72 5f6e  ruct allocator_n
    │ │ │ -000805a0: 6577 5f64 656c 6574 650a 7b0a 0975 7369  ew_delete.{..usi
    │ │ │ -000805b0: 6e67 2073 697a 655f 7479 7065 203d 2073  ng size_type = s
    │ │ │ -000805c0: 7464 3a3a 7369 7a65 5f74 3b0a 0975 7369  td::size_t;..usi
    │ │ │ -000805d0: 6e67 2064 6966 6665 7265 6e63 655f 7479  ng difference_ty
    │ │ │ -000805e0: 7065 203d 2073 7464 3a3a 7074 7264 6966  pe = std::ptrdif
    │ │ │ -000805f0: 665f 743b 0a0a 3c64 6976 2073 7479 6c65  f_t;..
    .static char │ │ │ -00080630: 2a20 6d61 6c6c 6f63 2873 697a 655f 7479 * malloc(size_ty │ │ │ -00080640: 7065 2063 6f6e 7374 2062 7974 6573 290a pe const bytes). │ │ │ -00080650: 3c2f 6469 763e 097b 2072 6574 7572 6e20
    .{ return │ │ │ -00080660: 6e65 7720 6368 6172 5b62 7974 6573 5d3b new char[bytes]; │ │ │ -00080670: 207d 0a09 7374 6174 6963 2076 6f69 6420 }..static void │ │ │ -00080680: 6672 6565 2863 6861 722a 2063 6f6e 7374 free(char* const │ │ │ -00080690: 2062 6c6f 636b 290a 097b 2064 656c 6574 block)..{ delet │ │ │ -000806a0: 6520 5b5d 2062 6c6f 636b 3b20 7d0a 7d3b e [] block; }.}; │ │ │ -000806b0: 0a0a 7573 696e 6720 706f 6f6c 203d 2062 ..using pool = b │ │ │ -000806c0: 6f6f 7374 3a3a 706f 6f6c 266c 743b 616c oost::pool<al │ │ │ -000806d0: 6c6f 6361 746f 725f 6e65 775f 6465 6c65 locator_new_dele │ │ │ -000806e0: 7465 2667 743b 3b0a 7d0a 7d0a 0a23 656e te>;.}.}..#en │ │ │ -000806f0: 6469 660a 3c2f 7072 653e 3c2f 7464 3e3c dif.
    < │ │ │ -00080700: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ -00080730: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ -00080760: 2e2f 696e 636c 7564 652f 6c69 6274 6f72 ./include/libtor │ │ │ -00080770: 7265 6e74 2f61 7578 5f2f 7574 705f 7374 rent/aux_/utp_st │ │ │ -00080780: 7265 616d 2e68 7070 3a36 3637 3c2f 613e ream.hpp:667 │ │ │ -00080790: 3c2f 7464 3e3c 7464 3e69 7420 776f 756c it woul │ │ │ -000807a0: 6420 6265 206e 6963 6520 746f 206d 616b d be nice to mak │ │ │ -000807b0: 6520 7468 6973 2070 7269 7661 7465 3c2f e this private

    it w │ │ │ -00080810: 6f75 6c64 2062 6520 6e69 6365 2074 6f20 ould be nice to │ │ │ -00080820: 6d61 6b65 2074 6869 7320 7072 6976 6174 make this privat │ │ │ -00080830: 653c 2f68 323e 3c68 343e 2e2e 2f69 6e63 e

    ../inc │ │ │ -00080840: 6c75 6465 2f6c 6962 746f 7272 656e 742f lude/libtorrent/ │ │ │ -00080850: 6175 785f 2f75 7470 5f73 7472 6561 6d2e aux_/utp_stream. │ │ │ -00080860: 6870 703a 3636 373c 2f68 343e 3c70 7265 hpp:667

    .bool cons
    │ │ │ -000808b0: 756d 655f 696e 636f 6d69 6e67 5f64 6174  ume_incoming_dat
    │ │ │ -000808c0: 6128 0a09 0975 7470 5f68 6561 6465 7220  a(...utp_header 
    │ │ │ -000808d0: 636f 6e73 742a 2070 682c 2073 7464 3a3a  const* ph, std::
    │ │ │ -000808e0: 7569 6e74 385f 7420 636f 6e73 742a 2070  uint8_t const* p
    │ │ │ -000808f0: 7472 2c20 696e 7420 7061 796c 6f61 645f  tr, int payload_
    │ │ │ -00080900: 7369 7a65 2c20 7469 6d65 5f70 6f69 6e74  size, time_point
    │ │ │ -00080910: 206e 6f77 293b 0a09 766f 6964 2075 7064   now);..void upd
    │ │ │ -00080920: 6174 655f 6d74 755f 6c69 6d69 7473 2829  ate_mtu_limits()
    │ │ │ -00080930: 3b0a 0976 6f69 6420 6578 7065 7269 656e  ;..void experien
    │ │ │ -00080940: 6365 645f 6c6f 7373 2873 7464 3a3a 7569  ced_loss(std::ui
    │ │ │ -00080950: 6e74 3332 5f74 2073 6571 5f6e 722c 2074  nt32_t seq_nr, t
    │ │ │ -00080960: 696d 655f 706f 696e 7420 6e6f 7729 3b0a  ime_point now);.
    │ │ │ -00080970: 0a09 766f 6964 2073 656e 645f 6465 6665  ..void send_defe
    │ │ │ -00080980: 7272 6564 5f61 636b 2829 3b0a 0976 6f69  rred_ack();..voi
    │ │ │ -00080990: 6420 736f 636b 6574 5f64 7261 696e 6564  d socket_drained
    │ │ │ -000809a0: 2829 3b0a 0a09 766f 6964 2073 6574 5f75  ();...void set_u
    │ │ │ -000809b0: 7365 7264 6174 6128 7574 705f 7374 7265  serdata(utp_stre
    │ │ │ -000809c0: 616d 2a20 7329 207b 206d 5f75 7365 7264  am* s) { m_userd
    │ │ │ -000809d0: 6174 6120 3d20 733b 207d 0a09 766f 6964  ata = s; }..void
    │ │ │ -000809e0: 2061 626f 7274 2829 3b0a 0975 6470 3a3a   abort();..udp::
    │ │ │ -000809f0: 656e 6470 6f69 6e74 2072 656d 6f74 655f  endpoint remote_
    │ │ │ -00080a00: 656e 6470 6f69 6e74 2829 2063 6f6e 7374  endpoint() const
    │ │ │ -00080a10: 3b0a 0a09 7374 643a 3a75 696e 7431 365f  ;...std::uint16_
    │ │ │ -00080a20: 7420 7265 6365 6976 655f 6964 2829 2063  t receive_id() c
    │ │ │ -00080a30: 6f6e 7374 207b 2072 6574 7572 6e20 6d5f  onst { return m_
    │ │ │ -00080a40: 7265 6376 5f69 643b 207d 0a09 626f 6f6c  recv_id; }..bool
    │ │ │ -00080a50: 206d 6174 6368 2875 6470 3a3a 656e 6470   match(udp::endp
    │ │ │ -00080a60: 6f69 6e74 2063 6f6e 7374 2661 6d70 3b20  oint const& 
    │ │ │ -00080a70: 6570 2c20 7374 643a 3a75 696e 7431 365f  ep, std::uint16_
    │ │ │ -00080a80: 7420 6964 2920 636f 6e73 743b 0a0a 092f  t id) const;.../
    │ │ │ -00080a90: 2f20 6e6f 6e2d 636f 7079 6162 6c65 0a09  / non-copyable..
    │ │ │ -00080aa0: 7574 705f 736f 636b 6574 5f69 6d70 6c28  utp_socket_impl(
    │ │ │ -00080ab0: 7574 705f 736f 636b 6574 5f69 6d70 6c20  utp_socket_impl 
    │ │ │ -00080ac0: 636f 6e73 7426 616d 703b 2920 3d20 6465  const&) = de
    │ │ │ -00080ad0: 6c65 7465 3b0a 0975 7470 5f73 6f63 6b65  lete;..utp_socke
    │ │ │ -00080ae0: 745f 696d 706c 2063 6f6e 7374 2661 6d70  t_impl const&
    │ │ │ -00080af0: 3b20 6f70 6572 6174 6f72 3d28 7574 705f  ; operator=(utp_
    │ │ │ -00080b00: 736f 636b 6574 5f69 6d70 6c20 636f 6e73  socket_impl cons
    │ │ │ -00080b10: 7426 616d 703b 2920 3d20 6465 6c65 7465  t&) = delete
    │ │ │ -00080b20: 3b0a 0a09 2f2f 2054 6865 2075 6e64 6572  ;...// The under
    │ │ │ -00080b30: 6c79 696e 6720 5544 5020 736f 636b 6574  lying UDP socket
    │ │ │ -00080b40: 2074 6869 7320 7554 5020 736f 636b 6574   this uTP socket
    │ │ │ -00080b50: 2069 7320 626f 756e 6420 746f 0a3c 6469   is bound to..std:
    │ │ │ -00080b90: 3a77 6561 6b5f 7074 7226 6c74 3b75 7470  :weak_ptr<utp
    │ │ │ -00080ba0: 5f73 6f63 6b65 745f 696e 7465 7266 6163  _socket_interfac
    │ │ │ -00080bb0: 6526 6774 3b20 6d5f 736f 636b 3b0a 3c2f  e> m_sock;...void add_w
    │ │ │ -00080bd0: 7269 7465 5f62 7566 6665 7228 766f 6964  rite_buffer(void
    │ │ │ -00080be0: 2063 6f6e 7374 2a20 6275 662c 2069 6e74   const* buf, int
    │ │ │ -00080bf0: 206c 656e 293b 0a09 766f 6964 2061 6464   len);..void add
    │ │ │ -00080c00: 5f72 6561 645f 6275 6666 6572 2876 6f69  _read_buffer(voi
    │ │ │ -00080c10: 642a 2062 7566 2c20 696e 7420 6c65 6e29  d* buf, int len)
    │ │ │ -00080c20: 3b0a 0a09 696e 7420 7365 6e64 5f64 656c  ;...int send_del
    │ │ │ -00080c30: 6179 2829 2063 6f6e 7374 207b 2072 6574  ay() const { ret
    │ │ │ -00080c40: 7572 6e20 6d5f 7365 6e64 5f64 656c 6179  urn m_send_delay
    │ │ │ -00080c50: 3b20 7d0a 0969 6e74 2072 6563 765f 6465  ; }..int recv_de
    │ │ │ -00080c60: 6c61 7928 2920 636f 6e73 7420 7b20 7265  lay() const { re
    │ │ │ -00080c70: 7475 726e 206d 5f72 6563 765f 6465 6c61  turn m_recv_dela
    │ │ │ -00080c80: 793b 207d 0a0a 0976 6f69 6420 6973 7375  y; }...void issu
    │ │ │ -00080c90: 655f 7265 6164 2829 3b0a 0976 6f69 6420  e_read();..void 
    │ │ │ -00080ca0: 6973 7375 655f 7772 6974 6528 293b 0a09  issue_write();..
    │ │ │ -00080cb0: 766f 6964 2073 7562 7363 7269 6265 5f77  void subscribe_w
    │ │ │ -00080cc0: 7269 7465 6162 6c65 2829 3b0a 0a09 626f  riteable();...bo
    │ │ │ -00080cd0: 6f6c 2063 6865 636b 5f66 696e 5f73 656e  ol check_fin_sen
    │ │ │ -00080ce0: 7428 2920 636f 6e73 743b 0a0a 0976 6f69  t() const;...voi
    │ │ │ -00080cf0: 6420 646f 5f63 6f6e 6e65 6374 2874 6370  d do_connect(tcp
    │ │ │ -00080d00: 3a3a 656e 6470 6f69 6e74 2063 6f6e 7374  ::endpoint const
    │ │ │ -00080d10: 2661 6d70 3b20 6570 293b 0a0a 0973 7464  & ep);...std
    │ │ │ -00080d20: 3a3a 7369 7a65 5f74 2072 6561 645f 736f  ::size_t read_so
    │ │ │ -00080d30: 6d65 2862 6f6f 6c20 636f 6e73 7420 636c  me(bool const cl
    │ │ │ -00080d40: 6561 725f 6275 6666 6572 732c 2065 7272  ear_buffers, err
    │ │ │ -00080d50: 6f72 5f63 6f64 6526 616d 703b 2065 6329  or_code& ec)
    │ │ │ -00080d60: 3b0a 0973 7464 3a3a 7369 7a65 5f74 2077  ;..std::size_t w
    │ │ │ -00080d70: 7269 7465 5f73 6f6d 6528 626f 6f6c 2063  rite_some(bool c
    │ │ │ -00080d80: 6f6e 7374 2063 6c65 6172 5f62 7566 6665  onst clear_buffe
    │ │ │ -00080d90: 7273 293b 202f 2f20 5761 726e 696e 673a  rs); // Warning:
    │ │ │ -00080da0: 206e 6f6e 2d62 6c6f 636b 696e 670a 0969   non-blocking..i
    │ │ │ -00080db0: 6e74 2072 6563 6569 7665 5f62 7566 6665  nt receive_buffe
    │ │ │ -00080dc0: 725f 7369 7a65 2829 2063 6f6e 7374 207b  r_size() const {
    │ │ │ -00080dd0: 2072 6574 7572 6e20 6d5f 7265 6365 6976   return m_receiv
    │ │ │ -00080de0: 655f 6275 6666 6572 5f73 697a 653b 207d  e_buffer_size; }
    │ │ │ -00080df0: 0a0a 0962 6f6f 6c20 6e75 6c6c 5f62 7566  ...bool null_buf
    │ │ │ -00080e00: 6665 7273 2829 2063 6f6e 7374 207b 2072  fers() const { r
    │ │ │ -00080e10: 6574 7572 6e20 6d5f 6e75 6c6c 5f62 7566  eturn m_null_buf
    │ │ │ -00080e20: 6665 7273 3b20 7d0a 0a70 7269 7661 7465  fers; }..private
    │ │ │ -00080e30: 3a0a 0a09 2f2f 2069 7427 7320 696d 706f  :...// it's impo
    │ │ │ -00080e40: 7274 616e 7420 7468 6174 2074 6865 7365  rtant that these
    │ │ │ -00080e50: 206d 6174 6368 2074 6865 2065 6e75 6d73   match the enums
    │ │ │ -00080e60: 2069 6e20 7065 7266 6f72 6d61 6e63 655f   in performance_
    │ │ │ -00080e70: 636f 756e 7465 7273 2066 6f72 0a09 2f2f  counters for..//
    │ │ │ -00080e80: 206e 756d 5f75 7470 5f69 646c 6520 6574   num_utp_idle et
    │ │ │ -00080e90: 632e 0a09 656e 756d 2063 6c61 7373 2073  c...enum class s
    │ │ │ -00080ea0: 7461 7465 5f74 207b 0a09 092f 2f20 6e6f  tate_t {...// no
    │ │ │ -00080eb0: 7420 7965 7420 636f 6e6e 6563 7465 640a  t yet connected.
    │ │ │ -00080ec0: 0909 6e6f 6e65 2c0a 0909 2f2f 2073 656e  ..none,...// sen
    │ │ │ -00080ed0: 7420 6120 7379 6e20 7061 636b 6574 2c20  t a syn packet, 
    │ │ │ -00080ee0: 6e6f 7420 7265 6365 6976 6564 2061 6e79  not received any
    │ │ │ -00080ef0: 2061 636b 730a 0909 7379 6e5f 7365 6e74   acks...syn_sent
    │ │ │ -00080f00: 2c0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74  ,.
    < │ │ │ -00080f30: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ -00080f40: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ -00080f70: 696e 636c 7564 652f 6c69 6274 6f72 7265 include/libtorre │ │ │ -00080f80: 6e74 2f61 7578 5f2f 7069 6563 655f 7069 nt/aux_/piece_pi │ │ │ -00080f90: 636b 6572 2e68 7070 3a38 3136 3c2f 613e cker.hpp:816 │ │ │ -00080fa0: 3c2f 7464 3e3c 7464 3e73 686f 756c 6420 should │ │ │ -00080fb0: 7468 6973 2062 6520 616c 6c6f 6361 7465 this be allocate │ │ │ -00080fc0: 6420 6c61 7a69 6c79 3f3c 2f74 643e 3c2f d lazily?

    should th │ │ │ -00081020: 6973 2062 6520 616c 6c6f 6361 7465 6420 is be allocated │ │ │ -00081030: 6c61 7a69 6c79 3f3c 2f68 323e 3c68 343e lazily?

    │ │ │ -00081040: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -00081050: 7272 656e 742f 6175 785f 2f70 6965 6365 rrent/aux_/piece │ │ │ -00081060: 5f70 6963 6b65 722e 6870 703a 3831 363c _picker.hpp:816< │ │ │ -00081070: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ -000810b0: 2f2f 2064 6f77 6e6c 6f61 6420 6c69 7374  // download list
    │ │ │ -000810c0: 2069 7420 6d61 7920 6c69 7665 2069 6e20   it may live in 
    │ │ │ -000810d0: 6e6f 770a 0909 7374 643a 3a76 6563 746f  now...std::vecto
    │ │ │ -000810e0: 7226 6c74 3b64 6f77 6e6c 6f61 6469 6e67  r<downloading
    │ │ │ -000810f0: 5f70 6965 6365 2667 743b 3a3a 6974 6572  _piece>::iter
    │ │ │ -00081100: 6174 6f72 2075 7064 6174 655f 7069 6563  ator update_piec
    │ │ │ -00081110: 655f 7374 6174 6528 0a09 0909 7374 643a  e_state(....std:
    │ │ │ -00081120: 3a76 6563 746f 7226 6c74 3b64 6f77 6e6c  :vector<downl
    │ │ │ -00081130: 6f61 6469 6e67 5f70 6965 6365 2667 743b  oading_piece>
    │ │ │ -00081140: 3a3a 6974 6572 6174 6f72 2064 7029 3b0a  ::iterator dp);.
    │ │ │ -00081150: 0a09 7072 6976 6174 653a 0a0a 2369 6620  ..private:..#if 
    │ │ │ -00081160: 544f 5252 454e 545f 5553 455f 4153 5345  TORRENT_USE_ASSE
    │ │ │ -00081170: 5254 5320 7c7c 2054 4f52 5245 4e54 5f55  RTS || TORRENT_U
    │ │ │ -00081180: 5345 5f49 4e56 4152 4941 4e54 5f43 4845  SE_INVARIANT_CHE
    │ │ │ -00081190: 434b 530a 0909 696e 6465 785f 7261 6e67  CKS...index_rang
    │ │ │ -000811a0: 6526 6c74 3b64 6f77 6e6c 6f61 645f 7175  e<download_qu
    │ │ │ -000811b0: 6575 655f 7426 6774 3b20 6361 7465 676f  eue_t> catego
    │ │ │ -000811c0: 7269 6573 2829 2063 6f6e 7374 0a09 097b  ries() const...{
    │ │ │ -000811d0: 2072 6574 7572 6e20 7b7b 7d2c 2070 6965   return {{}, pie
    │ │ │ -000811e0: 6365 5f70 6963 6b65 723a 3a70 6965 6365  ce_picker::piece
    │ │ │ -000811f0: 5f70 6f73 3a3a 6e75 6d5f 646f 776e 6c6f  _pos::num_downlo
    │ │ │ -00081200: 6164 5f63 6174 6567 6f72 6965 737d 3b20  ad_categories}; 
    │ │ │ -00081210: 7d0a 2365 6e64 6966 0a0a 0909 2f2f 2074  }.#endif....// t
    │ │ │ -00081220: 6865 2066 6f6c 6c6f 7769 6e67 2076 6563  he following vec
    │ │ │ -00081230: 746f 7273 2061 7265 206d 7574 6162 6c65  tors are mutable
    │ │ │ -00081240: 2062 6563 6175 7365 2074 6865 7920 736f   because they so
    │ │ │ -00081250: 6d65 7469 6d65 7320 6d61 790a 0909 2f2f  metimes may...//
    │ │ │ -00081260: 2062 6520 7570 6461 7465 6420 6c61 7a69   be updated lazi
    │ │ │ -00081270: 6c79 2c20 7472 6967 6765 7265 6420 6279  ly, triggered by
    │ │ │ -00081280: 2063 6f6e 7374 2066 756e 6374 696f 6e73   const functions
    │ │ │ -00081290: 0a0a 0909 2f2f 2074 6869 7320 6d61 7073  ....// this maps
    │ │ │ -000812a0: 2069 6e64 6963 6573 2074 6f20 6e75 6d62   indices to numb
    │ │ │ -000812b0: 6572 206f 6620 7065 6572 7320 7468 6174  er of peers that
    │ │ │ -000812c0: 2068 6173 2074 6869 7320 7069 6563 6520   has this piece 
    │ │ │ -000812d0: 616e 640a 0909 2f2f 2069 6e64 6578 2069  and...// index i
    │ │ │ -000812e0: 6e74 6f20 7468 6520 6d5f 7069 6563 655f  nto the m_piece_
    │ │ │ -000812f0: 696e 666f 2076 6563 746f 7273 2e0a 0909  info vectors....
    │ │ │ -00081300: 2f2f 2070 6965 6365 5f70 6f73 3a3a 666c  // piece_pos::fl
    │ │ │ -00081310: 7573 6865 645f 696e 6465 7820 6d65 616e  ushed_index mean
    │ │ │ -00081320: 7320 7468 6520 7069 636b 6572 2068 6173  s the picker has
    │ │ │ -00081330: 2066 696e 616c 697a 6564 2074 6865 0a09   finalized the..
    │ │ │ -00081340: 092f 2f20 7069 6563 652c 2073 6f20 6974  .// piece, so it
    │ │ │ -00081350: 2064 6f65 736e 2774 2065 7869 7374 2069   doesn't exist i
    │ │ │ -00081360: 6e20 7468 6520 7069 6563 655f 696e 666f  n the piece_info
    │ │ │ -00081370: 2062 7563 6b65 7473 0a09 092f 2f20 7069   buckets...// pi
    │ │ │ -00081380: 6563 6573 2077 6974 6820 7468 6520 6669  eces with the fi
    │ │ │ -00081390: 6c74 6572 6564 2066 6c61 6720 7365 7420  ltered flag set 
    │ │ │ -000813a0: 646f 6573 6e27 7420 6861 7665 2065 6e74  doesn't have ent
    │ │ │ -000813b0: 7269 6573 2069 6e0a 0909 2f2f 2074 6865  ries in...// the
    │ │ │ -000813c0: 206d 5f70 6965 6365 5f69 6e66 6f20 6275   m_piece_info bu
    │ │ │ -000813d0: 636b 6574 7320 6569 7468 6572 0a3c 6469  ckets either...mut
    │ │ │ -00081410: 6162 6c65 2061 7578 3a3a 7665 6374 6f72  able aux::vector
    │ │ │ -00081420: 266c 743b 7069 6563 655f 706f 732c 2070  <piece_pos, p
    │ │ │ -00081430: 6965 6365 5f69 6e64 6578 5f74 2667 743b  iece_index_t>
    │ │ │ -00081440: 206d 5f70 6965 6365 5f6d 6170 3b0a 3c2f   m_piece_map;....// tracks
    │ │ │ -00081460: 2074 6865 206e 756d 6265 7220 6f66 2062   the number of b
    │ │ │ -00081470: 7974 6573 2069 6e20 6120 7370 6563 6966  ytes in a specif
    │ │ │ -00081480: 6963 2070 6965 6365 2074 6861 7420 6172  ic piece that ar
    │ │ │ -00081490: 6520 7061 7274 206f 6620 6120 7061 640a  e part of a pad.
    │ │ │ -000814a0: 0909 2f2f 2066 696c 652e 2054 6865 2070  ..// file. The p
    │ │ │ -000814b0: 6164 6469 6e67 2069 7320 6173 7375 6d65  adding is assume
    │ │ │ -000814c0: 6420 746f 2062 6520 6174 2074 6865 2065  d to be at the e
    │ │ │ -000814d0: 6e64 206f 6620 7468 6520 7069 6563 652c  nd of the piece,
    │ │ │ -000814e0: 2061 6e64 2074 6865 0a09 092f 2f20 626c   and the...// bl
    │ │ │ -000814f0: 6f63 6b73 2063 6f76 6572 6564 2062 7920  ocks covered by 
    │ │ │ -00081500: 7468 6520 7061 6420 6279 7465 7320 6172  the pad bytes ar
    │ │ │ -00081510: 6520 6e6f 7420 7069 636b 6564 2062 7920  e not picked by 
    │ │ │ -00081520: 7468 6520 7069 6563 6520 7069 636b 6572  the piece picker
    │ │ │ -00081530: 0a09 0973 7464 3a3a 756e 6f72 6465 7265  ...std::unordere
    │ │ │ -00081540: 645f 6d61 7026 6c74 3b70 6965 6365 5f69  d_map<piece_i
    │ │ │ -00081550: 6e64 6578 5f74 2c20 696e 7426 6774 3b20  ndex_t, int> 
    │ │ │ -00081560: 6d5f 7061 6473 5f69 6e5f 7069 6563 653b  m_pads_in_piece;
    │ │ │ -00081570: 0a0a 0909 2f2f 2077 6865 6e20 7468 6520  ....// when the 
    │ │ │ -00081580: 6164 6a61 6365 6e74 5f70 6965 6365 2061  adjacent_piece a
    │ │ │ -00081590: 6666 696e 6974 7920 6973 2065 6e61 626c  ffinity is enabl
    │ │ │ -000815a0: 6564 2c20 7468 6973 2063 6f6e 7461 696e  ed, this contain
    │ │ │ -000815b0: 7320 7468 6520 6d6f 7374 0a09 092f 2f20  s the most...// 
    │ │ │ -000815c0: 7265 6365 6e74 2022 6578 7465 6e74 7322  recent "extents"
    │ │ │ -000815d0: 206f 6620 6164 6a61 6365 6e74 2070 6965   of adjacent pie
    │ │ │ -000815e0: 6365 7320 7468 6174 2068 6176 6520 6265  ces that have be
    │ │ │ -000815f0: 656e 2072 6571 7565 7374 6564 2066 726f  en requested fro
    │ │ │ -00081600: 6d0a 0909 2f2f 2074 6869 7320 6973 206d  m...// this is m
    │ │ │ -00081610: 7574 6162 6c65 2062 6563 6175 7365 2069  utable because i
    │ │ │ -00081620: 7427 7320 7570 6461 7465 6420 6279 2066  t's updated by f
    │ │ │ -00081630: 756e 6374 696f 6e73 2074 6f20 7069 636b  unctions to pick
    │ │ │ -00081640: 2070 6965 6365 732c 2077 6869 6368 0a09   pieces, which..
    │ │ │ -00081650: 092f 2f20 6172 6520 636f 6e73 742e 2054  .// are const. T
    │ │ │ -00081660: 6861 7427 7320 616e 2065 6666 6963 6965  hat's an efficie
    │ │ │ -00081670: 6e74 2070 6c61 6365 2074 6f20 7570 6461  nt place to upda
    │ │ │ -00081680: 7465 2069 742c 2073 696e 6365 2069 7427  te it, since it'
    │ │ │ -00081690: 7320 6265 696e 670a 0909 2f2f 2074 7261  s being...// tra
    │ │ │ -000816a0: 7665 7273 6564 2061 6c72 6561 6479 2e0a  versed already..
    │ │ │ -000816b0: 0909 6d75 7461 626c 6520 7374 643a 3a76  ..mutable std::v
    │ │ │ -000816c0: 6563 746f 7226 6c74 3b70 6965 6365 5f65  ector<piece_e
    │ │ │ -000816d0: 7874 656e 745f 7426 6774 3b20 6d5f 7265  xtent_t> m_re
    │ │ │ -000816e0: 6365 6e74 5f65 7874 656e 7473 3b0a 0a09  cent_extents;...
    │ │ │ -000816f0: 092f 2f20 7468 6520 6e75 6d62 6572 206f  .// the number o
    │ │ │ -00081700: 6620 6279 7465 7320 6f66 2070 6164 2066  f bytes of pad f
    │ │ │ -00081710: 696c 6520 7365 7420 696e 2074 6869 7320  ile set in this 
    │ │ │ -00081720: 7069 6563 6520 7069 636b 6572 0a09 0973  piece picker...s
    │ │ │ -00081730: 7464 3a3a 696e 7436 345f 7420 6d5f 6e75  td::int64_t m_nu
    │ │ │ -00081740: 6d5f 7061 645f 6279 7465 7320 3d20 303b  m_pad_bytes = 0;
    │ │ │ -00081750: 0a0a 0909 2f2f 2074 6865 206e 756d 6265  ....// the numbe
    │ │ │ -00081760: 7220 6f66 2070 6164 2062 6c6f 636b 7320  r of pad blocks 
    │ │ │ -00081770: 7468 6174 2077 6520 616c 7265 6164 7920  that we already 
    │ │ │ -00081780: 6861 7665 0a09 0973 7464 3a3a 696e 7436  have...std::int6
    │ │ │ -00081790: 345f 7420 6d5f 6861 7665 5f70 6164 5f62  4_t m_have_pad_b
    │ │ │ -000817a0: 7974 6573 203d 2030 3b0a 0a09 092f 2f20  ytes = 0;....// 
    │ │ │ -000817b0: 7468 6520 6e75 6d62 6572 206f 6620 7061  the number of pa
    │ │ │ -000817c0: 6420 626c 6f63 6b73 2070 6172 7420 6f66  d blocks part of
    │ │ │ -000817d0: 2066 696c 7465 7265 6420 7069 6563 6573   filtered pieces
    │ │ │ -000817e0: 2077 6520 646f 6e27 7420 6861 7665 0a09   we don't have..
    │ │ │ -000817f0: 0973 7464 3a3a 696e 7436 345f 7420 6d5f  .std::int64_t m_
    │ │ │ -00081800: 6669 6c74 6572 6564 5f70 6164 5f62 7974  filtered_pad_byt
    │ │ │ -00081810: 6573 203d 2030 3b0a 0a09 092f 2f20 7468  es = 0;....// th
    │ │ │ -00081820: 6520 6e75 6d62 6572 206f 6620 7061 6420  e number of pad 
    │ │ │ -00081830: 626c 6f63 6b73 2077 6520 6861 7665 2074  blocks we have t
    │ │ │ -00081840: 6861 7420 6172 6520 616c 736f 2066 696c  hat are also fil
    │ │ │ -00081850: 7465 7265 640a 0909 7374 643a 3a69 6e74  tered...std::int
    │ │ │ -00081860: 3634 5f74 206d 5f68 6176 655f 6669 6c74  64_t m_have_filt
    │ │ │ -00081870: 6572 6564 5f70 6164 5f62 7974 6573 203d  ered_pad_bytes =
    │ │ │ -00081880: 2030 3b0a 0a09 092f 2f20 7468 6520 6e75   0;....// the nu
    │ │ │ -00081890: 6d62 6572 206f 6620 7365 6564 732e 2054  mber of seeds. T
    │ │ │ -000818a0: 6865 7365 2061 7265 206e 6f74 2061 6464  hese are not add
    │ │ │ -000818b0: 6564 2074 6f0a 0909 2f2f 2074 6865 2061  ed to...// the a
    │ │ │ -000818c0: 7661 696c 6162 696c 6974 7920 636f 756e  vailability coun
    │ │ │ -000818d0: 7465 7273 206f 6620 7468 6520 7069 6563  ters of the piec
    │ │ │ -000818e0: 6573 0a09 0969 6e74 206d 5f73 6565 6473  es...int m_seeds
    │ │ │ -000818f0: 203d 2030 3b0a 0a09 092f 2f20 7468 6973   = 0;....// this
    │ │ │ -00081900: 2076 6563 746f 7220 636f 6e74 6169 6e73   vector contains
    │ │ │ -00081910: 2061 6c6c 2070 6965 6365 2069 6e64 6963   all piece indic
    │ │ │ -00081920: 6573 2074 6861 7420 6172 6520 7069 636b  es that are pick
    │ │ │ -00081930: 6162 6c65 0a3c 2f70 7265 3e3c 2f74 643e  able.
    │ │ │ -00081940: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ -00081970: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ -00081980: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ -00081990: 7074 3a65 7870 616e 6428 3239 3429 223e pt:expand(294)"> │ │ │ -000819a0: 2e2e 2f69 6e63 6c75 6465 2f6c 6962 746f ../include/libto │ │ │ -000819b0: 7272 656e 742f 6175 785f 2f70 6965 6365 rrent/aux_/piece │ │ │ -000819c0: 5f70 6963 6b65 722e 6870 703a 3838 383c _picker.hpp:888< │ │ │ -000819d0: 2f61 3e3c 2f74 643e 3c74 643e 6974 2077 /a>it w │ │ │ -000819e0: 6f75 6c64 2062 6520 6d6f 7265 2069 6e74 ould be more int │ │ │ -000819f0: 7569 7469 7665 2074 6f20 6163 636f 756e uitive to accoun │ │ │ -00081a00: 7420 2277 616e 7465 6422 2070 6965 6365 t "wanted" piece │ │ │ -00081a10: 7320 696e 7374 6561 6420 6f66 2066 696c s instead of fil │ │ │ -00081a20: 7465 7265 643c 2f74 643e 3c2f 7472 3e3c tered< │ │ │ -00081a30: 7472 2069 643d 2232 3934 2220 7374 796c tr id="294" styl │ │ │ -00081a40: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ -00081a50: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ -00081a60: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ -00081a70: 6832 3e69 7420 776f 756c 6420 6265 206d h2>it would be m │ │ │ -00081a80: 6f72 6520 696e 7475 6974 6976 6520 746f ore intuitive to │ │ │ -00081a90: 2061 6363 6f75 6e74 2022 7761 6e74 6564 account "wanted │ │ │ -00081aa0: 2220 7069 6563 6573 0a69 6e73 7465 6164 " pieces.instead │ │ │ -00081ab0: 206f 6620 6669 6c74 6572 6564 3c2f 6832 of filtered

    ../include/ │ │ │ -00081ad0: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ -00081ae0: 7069 6563 655f 7069 636b 6572 2e68 7070 piece_picker.hpp │ │ │ -00081af0: 3a38 3838 3c2f 6834 3e3c 7072 6520 7374 :888

    ...// this ho
    │ │ │ -00081b40: 6c64 7320 7468 6520 696e 666f 726d 6174  lds the informat
    │ │ │ -00081b50: 696f 6e20 6f66 2074 6865 2062 6c6f 636b  ion of the block
    │ │ │ -00081b60: 7320 696e 2070 6172 7469 616c 6c79 2064  s in partially d
    │ │ │ -00081b70: 6f77 6e6c 6f61 6465 640a 0909 2f2f 2070  ownloaded...// p
    │ │ │ -00081b80: 6965 6365 732e 2074 6865 2064 6f77 6e6c  ieces. the downl
    │ │ │ -00081b90: 6f61 6469 6e67 5f70 6965 6365 3a3a 696e  oading_piece::in
    │ │ │ -00081ba0: 666f 2069 6e64 6578 2070 6f69 6e74 2069  fo index point i
    │ │ │ -00081bb0: 6e74 6f20 7468 6973 2076 6563 746f 7220  nto this vector 
    │ │ │ -00081bc0: 666f 720a 0909 2f2f 2069 7473 2073 746f  for...// its sto
    │ │ │ -00081bd0: 7261 6765 0a09 0961 7578 3a3a 7665 6374  rage...aux::vect
    │ │ │ -00081be0: 6f72 266c 743b 626c 6f63 6b5f 696e 666f  or<block_info
    │ │ │ -00081bf0: 2667 743b 206d 5f62 6c6f 636b 5f69 6e66  > m_block_inf
    │ │ │ -00081c00: 6f3b 0a0a 0909 2f2f 2074 6865 7365 2061  o;....// these a
    │ │ │ -00081c10: 7265 2062 6c6f 636b 2072 616e 6765 7320  re block ranges 
    │ │ │ -00081c20: 696e 206d 5f62 6c6f 636b 5f69 6e66 6f20  in m_block_info 
    │ │ │ -00081c30: 7468 6174 2061 7265 2066 7265 652e 2054  that are free. T
    │ │ │ -00081c40: 6865 206e 756d 6265 7273 0a09 092f 2f20  he numbers...// 
    │ │ │ -00081c50: 696e 2068 6572 652c 2077 6865 6e20 6d75  in here, when mu
    │ │ │ -00081c60: 6c74 6970 6c69 6564 2062 7920 626c 6f63  ltiplied by bloc
    │ │ │ -00081c70: 6b73 5f70 6572 5f70 6965 6365 2069 7320  ks_per_piece is 
    │ │ │ -00081c80: 7468 6520 696e 6465 7820 746f 2074 6865  the index to the
    │ │ │ -00081c90: 0a09 092f 2f20 6669 7273 7420 626c 6f63  ...// first bloc
    │ │ │ -00081ca0: 6b20 696e 2074 6865 2072 616e 6765 2074  k in the range t
    │ │ │ -00081cb0: 6861 7427 7320 6672 6565 2074 6f20 7573  hat's free to us
    │ │ │ -00081cc0: 6520 6279 2061 206e 6577 2064 6f77 6e6c  e by a new downl
    │ │ │ -00081cd0: 6f61 6469 6e67 5f70 6965 6365 2e0a 0909  oading_piece....
    │ │ │ -00081ce0: 2f2f 2074 6869 7320 6973 2061 2066 7265  // this is a fre
    │ │ │ -00081cf0: 652d 6c69 7374 2e0a 0909 7374 643a 3a76  e-list....std::v
    │ │ │ -00081d00: 6563 746f 7226 6c74 3b73 7464 3a3a 7569  ector<std::ui
    │ │ │ -00081d10: 6e74 3136 5f74 2667 743b 206d 5f66 7265  nt16_t> m_fre
    │ │ │ -00081d20: 655f 626c 6f63 6b5f 696e 666f 733b 0a0a  e_block_infos;..
    │ │ │ -00081d30: 0909 7374 643a 3a75 696e 7431 365f 7420  ..std::uint16_t 
    │ │ │ -00081d40: 6d5f 626c 6f63 6b73 5f69 6e5f 6c61 7374  m_blocks_in_last
    │ │ │ -00081d50: 5f70 6965 6365 203d 2030 3b0a 0909 696e  _piece = 0;...in
    │ │ │ -00081d60: 7420 6d5f 7069 6563 655f 7369 7a65 203d  t m_piece_size =
    │ │ │ -00081d70: 2030 3b0a 0909 7374 643a 3a69 6e74 3634   0;...std::int64
    │ │ │ -00081d80: 5f74 206d 5f74 6f74 616c 5f73 697a 6520  _t m_total_size 
    │ │ │ -00081d90: 3d20 303b 0a0a 0909 2f2f 2074 6865 206e  = 0;....// the n
    │ │ │ -00081da0: 756d 6265 7220 6f66 2066 696c 7465 7265  umber of filtere
    │ │ │ -00081db0: 6420 7069 6563 6573 2074 6861 7420 7765  d pieces that we
    │ │ │ -00081dc0: 2064 6f6e 2774 2061 6c72 6561 6479 0a09   don't already..
    │ │ │ -00081dd0: 092f 2f20 6861 7665 2e20 746f 7461 6c5f  .// have. total_
    │ │ │ -00081de0: 6e75 6d62 6572 5f6f 665f 7069 6563 6573  number_of_pieces
    │ │ │ -00081df0: 202d 206e 756d 6265 725f 6f66 5f70 6965   - number_of_pie
    │ │ │ -00081e00: 6365 735f 7765 5f68 6176 650a 0909 2f2f  ces_we_have...//
    │ │ │ -00081e10: 202d 206e 756d 5f66 696c 7465 7265 6420   - num_filtered 
    │ │ │ -00081e20: 6973 2073 7570 706f 7365 6420 746f 2074  is supposed to t
    │ │ │ -00081e30: 6865 206e 756d 6265 7220 6f66 2070 6965  he number of pie
    │ │ │ -00081e40: 6365 730a 0909 2f2f 2077 6520 7374 696c  ces...// we stil
    │ │ │ -00081e50: 6c20 7761 6e74 2074 6f20 646f 776e 6c6f  l want to downlo
    │ │ │ -00081e60: 6164 0a3c 6469 7620 7374 796c 653d 2262  ad.
    ..int m_num_fil │ │ │ -00081ea0: 7465 7265 6420 3d20 303b 0a3c 2f64 6976 tered = 0;.
    ...// the numbe │ │ │ -00081ec0: 7220 6f66 2070 6965 6365 7320 7765 2068 r of pieces we h │ │ │ -00081ed0: 6176 6520 7468 6174 2061 6c73 6f20 6172 ave that also ar │ │ │ -00081ee0: 6520 6669 6c74 6572 6564 0a09 0969 6e74 e filtered...int │ │ │ -00081ef0: 206d 5f6e 756d 5f68 6176 655f 6669 6c74 m_num_have_filt │ │ │ -00081f00: 6572 6564 203d 2030 3b0a 0a09 092f 2f20 ered = 0;....// │ │ │ -00081f10: 7765 2068 6176 6520 616c 6c20 7069 6563 we have all piec │ │ │ -00081f20: 6573 2069 6e20 7468 6520 7261 6e67 6520 es in the range │ │ │ -00081f30: 5b73 7461 7274 5f72 616e 6765 2c20 6d5f [start_range, m_ │ │ │ -00081f40: 6375 7273 6f72 290a 0909 2f2f 206d 5f63 cursor)...// m_c │ │ │ -00081f50: 7572 736f 7220 6973 2074 6865 2066 6972 ursor is the fir │ │ │ -00081f60: 7374 2070 6965 6365 2077 6520 646f 6e27 st piece we don' │ │ │ -00081f70: 7420 6861 7665 2e0a 0909 2f2f 0a09 092f t have....//.../ │ │ │ -00081f80: 2f20 2268 6176 6522 2068 6572 6520 6973 / "have" here is │ │ │ -00081f90: 2074 6865 2073 7472 6963 7420 6e6f 7469 the strict noti │ │ │ -00081fa0: 6f6e 3a20 7069 6563 655f 706f 733a 3a66 on: piece_pos::f │ │ │ -00081fb0: 6c75 7368 6564 2829 2e20 5468 650a 0909 lushed(). The... │ │ │ -00081fc0: 2f2f 2063 7572 736f 7220 6973 206f 6e6c // cursor is onl │ │ │ -00081fd0: 7920 6164 7661 6e63 6564 2070 6173 7420 y advanced past │ │ │ -00081fe0: 6120 7069 6563 6520 6279 2070 6965 6365 a piece by piece │ │ │ -00081ff0: 5f66 6c75 7368 6564 2829 2028 616e 640a _flushed() (and. │ │ │ -00082000: 0909 2f2f 2074 6865 2063 7572 736f 7220 ..// the cursor │ │ │ -00082010: 7761 6c6b 7320 696e 2073 6574 5f70 6965 walks in set_pie │ │ │ -00082020: 6365 5f70 7269 6f72 6974 7928 2920 7768 ce_priority() wh │ │ │ -00082030: 656e 2066 696c 7465 7269 6e67 2c20 7369 en filtering, si │ │ │ -00082040: 6e63 650a 0909 2f2f 2066 696c 7465 7265 nce...// filtere │ │ │ -00082050: 6420 7069 6563 6573 2061 7265 2061 6c73 d pieces are als │ │ │ -00082060: 6f20 6f75 7420 6f66 2074 6865 2070 6963 o out of the pic │ │ │ -00082070: 6b65 7227 7320 776f 726b 696e 6720 7365 ker's working se │ │ │ -00082080: 7429 2e20 410a 0909 2f2f 2070 6965 6365 t). A...// piece │ │ │ -00082090: 2074 6861 7420 6861 7320 6f6e 6c79 2070 that has only p │ │ │ -000820a0: 6173 7365 645f 6861 7368 5f63 6865 636b assed_hash_check │ │ │ -000820b0: 2062 7574 2069 7320 6e6f 7420 7965 7420 but is not yet │ │ │ -000820c0: 666c 7573 6865 640a 0909 2f2f 2077 696c flushed...// wil │ │ │ -000820d0: 6c20 6e6f 7420 6d6f 7665 2074 6865 2063 l not move the c │ │ │ -000820e0: 7572 736f 723b 2074 6865 2063 7572 736f ursor; the curso │ │ │ -000820f0: 7220 6c61 6773 2075 6e74 696c 2070 6965 r lags until pie │ │ │ -00082100: 6365 5f66 6c75 7368 6564 2829 0a09 092f ce_flushed().../ │ │ │ -00082110: 2f20 7275 6e73 2028 7479 7069 6361 6c6c / runs (typicall │ │ │ -00082120: 7920 6672 6f6d 206d 6172 6b5f 6173 5f66 y from mark_as_f │ │ │ -00082130: 696e 6973 6865 6428 2920 6f6e 6365 2074 inished() once t │ │ │ -00082140: 6865 206c 6173 7420 626c 6f63 6b0a 0909 he last block... │ │ │ -00082150: 2f2f 2063 6f6d 706c 6574 6573 292e 2054 // completes). T │ │ │ -00082160: 6869 7320 6176 6f69 6473 206e 6565 6469 his avoids needi │ │ │ -00082170: 6e67 2074 6f20 7761 6c6b 2074 6865 2063 ng to walk the c │ │ │ -00082180: 7572 736f 7220 6261 636b 7761 7264 730a ursor backwards. │ │ │ -00082190: 0909 2f2f 2069 6620 7772 6974 655f 6661 ..// if write_fa │ │ │ -000821a0: 696c 6564 2829 206c 6174 6572 2063 6c65 iled() later cle │ │ │ -000821b0: 6172 7320 7061 7373 6564 5f68 6173 685f ars passed_hash_ │ │ │ -000821c0: 6368 6563 6b2e 0a09 0970 6965 6365 5f69 check....piece_i │ │ │ -000821d0: 6e64 6578 5f74 206d 5f63 7572 736f 727b ndex_t m_cursor{ │ │ │ -000821e0: 307d 3b0a 0a09 092f 2f20 7765 2068 6176 0};....// we hav │ │ │ -000821f0: 6520 616c 6c20 7069 6563 6573 2069 6e20 e all pieces in │ │ │ -00082200: 7468 6520 7261 6e67 6520 5b6d 5f72 6576 the range [m_rev │ │ │ -00082210: 6572 7365 5f63 7572 736f 722c 2065 6e64 erse_cursor, end │ │ │ -00082220: 5f72 616e 6765 290a 0909 2f2f 206d 5f72 _range)...// m_r │ │ │ -00082230: 6576 6572 7365 5f63 7572 736f 7220 6973 everse_cursor is │ │ │ -00082240: 2074 6865 2066 6972 7374 2070 6965 6365 the first piece │ │ │ -00082250: 2077 6865 7265 2077 6520 616c 736f 2068 where we also h │ │ │ -00082260: 6176 650a 0909 2f2f 2061 6c6c 2074 6865 ave...// all the │ │ │ -00082270: 2073 7562 7365 7175 656e 7420 7069 6563 subsequent piec │ │ │ -00082280: 6573 2e0a 0909 2f2f 2053 616d 6520 7374 es....// Same st │ │ │ -00082290: 7269 6374 2d66 6c75 7368 6564 2073 656d rict-flushed sem │ │ │ -000822a0: 616e 7469 6373 2061 7320 6d5f 6375 7273 antics as m_curs │ │ │ -000822b0: 6f72 2061 626f 7665 2e0a 0909 7069 6563 or above....piec │ │ │ -000822c0: 655f 696e 6465 785f 7420 6d5f 7265 7665 e_index_t m_reve │ │ │ -000822d0: 7273 655f 6375 7273 6f72 7b30 7d3b 0a0a rse_cursor{0};.. │ │ │ -000822e0: 0909 2f2f 2074 6865 206e 756d 6265 7220 ..// the number │ │ │ -000822f0: 6f66 2070 6965 6365 7320 7765 2068 6176 of pieces we hav │ │ │ -00082300: 6520 2869 2e65 2e20 7061 7373 6564 2068 e (i.e. passed h │ │ │ -00082310: 6173 6820 6368 6563 6b29 2e0a 0909 2f2f ash check)....// │ │ │ -00082320: 2054 6869 7320 696e 636c 7564 6573 2070 This includes p │ │ │ -00082330: 6965 6365 7320 7468 6174 2077 6520 6861 ieces that we ha │ │ │ -00082340: 7665 2066 696c 7465 7265 6420 6275 7420 ve filtered but │ │ │ -00082350: 7374 696c 6c20 6861 7665 0a09 0969 6e74 still have...int │ │ │ -00082360: 206d 5f6e 756d 5f68 6176 6520 3d20 303b m_num_have = 0; │ │ │ -00082370: 0a0a 0909 2f2f 2069 6620 7468 6973 2069 ....// if this i │ │ │ -00082380: 7320 7365 7420 746f 2074 7275 652c 2069 s set to true, i │ │ │ -00082390: 7420 6d65 616e 7320 7570 6461 7465 5f70 t means update_p │ │ │ -000823a0: 6965 6365 7328 290a 0909 2f2f 2068 6173 ieces()...// has │ │ │ -000823b0: 2074 6f20 6265 2063 616c 6c65 6420 6265 to be called be │ │ │ -000823c0: 666f 7265 2061 6363 6573 7369 6e67 206d fore accessing m │ │ │ -000823d0: 5f70 6965 6365 732e 0a3c 2f70 7265 3e3c _pieces..
    < │ │ │ +0003bf00: 7263 2f73 6574 7469 6e67 735f 7061 636b rc/settings_pack │ │ │ +0003bf10: 2e63 7070 3a32 3837 3c2f 613e 3c2f 7464 .cpp:287deprecate t │ │ │ +0003bf30: 6869 733c 2f74 643e 3c2f 7472 3e3c 7472 his

    deprecate this< │ │ │ +0003bf90: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f73 /h2>

    ../src/s │ │ │ +0003bfa0: 6574 7469 6e67 735f 7061 636b 2e63 7070 ettings_pack.cpp │ │ │ +0003bfb0: 3a32 3837 3c2f 6834 3e3c 7072 6520 7374 :287

    ..SET(outgoin
    │ │ │ +0003c000: 675f 706f 7274 2c20 302c 206e 756c 6c70  g_port, 0, nullp
    │ │ │ +0003c010: 7472 292c 0a09 0953 4554 286e 756d 5f6f  tr),...SET(num_o
    │ │ │ +0003c020: 7574 676f 696e 675f 706f 7274 732c 2030  utgoing_ports, 0
    │ │ │ +0003c030: 2c20 6e75 6c6c 7074 7229 2c0a 0909 5345  , nullptr),...SE
    │ │ │ +0003c040: 5428 7065 6572 5f64 7363 702c 2030 7830  T(peer_dscp, 0x0
    │ │ │ +0003c050: 312c 2026 616d 703b 7365 7373 696f 6e5f  1, &session_
    │ │ │ +0003c060: 696d 706c 3a3a 7570 6461 7465 5f70 6565  impl::update_pee
    │ │ │ +0003c070: 725f 6473 6370 292c 0a09 0953 4554 2861  r_dscp),...SET(a
    │ │ │ +0003c080: 6374 6976 655f 646f 776e 6c6f 6164 732c  ctive_downloads,
    │ │ │ +0003c090: 2033 2c20 2661 6d70 3b73 6573 7369 6f6e   3, &session
    │ │ │ +0003c0a0: 5f69 6d70 6c3a 3a74 7269 6767 6572 5f61  _impl::trigger_a
    │ │ │ +0003c0b0: 7574 6f5f 6d61 6e61 6765 292c 0a09 0953  uto_manage),...S
    │ │ │ +0003c0c0: 4554 2861 6374 6976 655f 7365 6564 732c  ET(active_seeds,
    │ │ │ +0003c0d0: 2035 2c20 2661 6d70 3b73 6573 7369 6f6e   5, &session
    │ │ │ +0003c0e0: 5f69 6d70 6c3a 3a74 7269 6767 6572 5f61  _impl::trigger_a
    │ │ │ +0003c0f0: 7574 6f5f 6d61 6e61 6765 292c 0a09 0953  uto_manage),...S
    │ │ │ +0003c100: 4554 2861 6374 6976 655f 6368 6563 6b69  ET(active_checki
    │ │ │ +0003c110: 6e67 2c20 312c 2026 616d 703b 7365 7373  ng, 1, &sess
    │ │ │ +0003c120: 696f 6e5f 696d 706c 3a3a 7472 6967 6765  ion_impl::trigge
    │ │ │ +0003c130: 725f 6175 746f 5f6d 616e 6167 6529 2c0a  r_auto_manage),.
    │ │ │ +0003c140: 0909 5345 5428 6163 7469 7665 5f64 6874  ..SET(active_dht
    │ │ │ +0003c150: 5f6c 696d 6974 2c20 3838 2c20 6e75 6c6c  _limit, 88, null
    │ │ │ +0003c160: 7074 7229 2c0a 0909 5345 5428 6163 7469  ptr),...SET(acti
    │ │ │ +0003c170: 7665 5f74 7261 636b 6572 5f6c 696d 6974  ve_tracker_limit
    │ │ │ +0003c180: 2c20 3136 3030 2c20 6e75 6c6c 7074 7229  , 1600, nullptr)
    │ │ │ +0003c190: 2c0a 0909 5345 5428 6163 7469 7665 5f6c  ,...SET(active_l
    │ │ │ +0003c1a0: 7364 5f6c 696d 6974 2c20 3630 2c20 6e75  sd_limit, 60, nu
    │ │ │ +0003c1b0: 6c6c 7074 7229 2c0a 0909 5345 5428 6163  llptr),...SET(ac
    │ │ │ +0003c1c0: 7469 7665 5f6c 696d 6974 2c20 3530 302c  tive_limit, 500,
    │ │ │ +0003c1d0: 2026 616d 703b 7365 7373 696f 6e5f 696d   &session_im
    │ │ │ +0003c1e0: 706c 3a3a 7472 6967 6765 725f 6175 746f  pl::trigger_auto
    │ │ │ +0003c1f0: 5f6d 616e 6167 6529 2c0a 0909 4445 5052  _manage),...DEPR
    │ │ │ +0003c200: 4543 4154 4544 5f53 4554 2861 6374 6976  ECATED_SET(activ
    │ │ │ +0003c210: 655f 6c6f 6164 6564 5f6c 696d 6974 2c20  e_loaded_limit, 
    │ │ │ +0003c220: 302c 2026 616d 703b 7365 7373 696f 6e5f  0, &session_
    │ │ │ +0003c230: 696d 706c 3a3a 7472 6967 6765 725f 6175  impl::trigger_au
    │ │ │ +0003c240: 746f 5f6d 616e 6167 6529 2c0a 0909 5345  to_manage),...SE
    │ │ │ +0003c250: 5428 6175 746f 5f6d 616e 6167 655f 696e  T(auto_manage_in
    │ │ │ +0003c260: 7465 7276 616c 2c20 3330 2c20 6e75 6c6c  terval, 30, null
    │ │ │ +0003c270: 7074 7229 2c0a 0909 5345 5428 7365 6564  ptr),...SET(seed
    │ │ │ +0003c280: 5f74 696d 655f 6c69 6d69 742c 2032 3420  _time_limit, 24 
    │ │ │ +0003c290: 2a20 3630 202a 2036 302c 206e 756c 6c70  * 60 * 60, nullp
    │ │ │ +0003c2a0: 7472 292c 0a09 0953 4554 2861 7574 6f5f  tr),...SET(auto_
    │ │ │ +0003c2b0: 7363 7261 7065 5f69 6e74 6572 7661 6c2c  scrape_interval,
    │ │ │ +0003c2c0: 2031 3830 302c 206e 756c 6c70 7472 292c   1800, nullptr),
    │ │ │ +0003c2d0: 0a09 0953 4554 2861 7574 6f5f 7363 7261  ...SET(auto_scra
    │ │ │ +0003c2e0: 7065 5f6d 696e 5f69 6e74 6572 7661 6c2c  pe_min_interval,
    │ │ │ +0003c2f0: 2033 3030 2c20 6e75 6c6c 7074 7229 2c0a   300, nullptr),.
    │ │ │ +0003c300: 0909 5345 5428 6d61 785f 7065 6572 6c69  ..SET(max_peerli
    │ │ │ +0003c310: 7374 5f73 697a 652c 2033 3030 302c 206e  st_size, 3000, n
    │ │ │ +0003c320: 756c 6c70 7472 292c 0a09 0953 4554 286d  ullptr),...SET(m
    │ │ │ +0003c330: 6178 5f70 6175 7365 645f 7065 6572 6c69  ax_paused_peerli
    │ │ │ +0003c340: 7374 5f73 697a 652c 2031 3030 302c 206e  st_size, 1000, n
    │ │ │ +0003c350: 756c 6c70 7472 292c 0a09 0953 4554 286d  ullptr),...SET(m
    │ │ │ +0003c360: 696e 5f61 6e6e 6f75 6e63 655f 696e 7465  in_announce_inte
    │ │ │ +0003c370: 7276 616c 2c20 3520 2a20 3630 2c20 6e75  rval, 5 * 60, nu
    │ │ │ +0003c380: 6c6c 7074 7229 2c0a 0909 5345 5428 6175  llptr),...SET(au
    │ │ │ +0003c390: 746f 5f6d 616e 6167 655f 7374 6172 7475  to_manage_startu
    │ │ │ +0003c3a0: 702c 2036 302c 206e 756c 6c70 7472 292c  p, 60, nullptr),
    │ │ │ +0003c3b0: 0a09 0953 4554 2873 6565 6469 6e67 5f70  ...SET(seeding_p
    │ │ │ +0003c3c0: 6965 6365 5f71 756f 7461 2c20 3230 2c20  iece_quota, 20, 
    │ │ │ +0003c3d0: 6e75 6c6c 7074 7229 2c0a 3c64 6976 2073  nullptr),.
    ..SET(ma │ │ │ +0003c410: 785f 7265 6a65 6374 732c 2035 302c 206e x_rejects, 50, n │ │ │ +0003c420: 756c 6c70 7472 292c 0a3c 2f64 6976 3e09 ullptr),.
    . │ │ │ +0003c430: 0953 4554 2872 6563 765f 736f 636b 6574 .SET(recv_socket │ │ │ +0003c440: 5f62 7566 6665 725f 7369 7a65 2c20 302c _buffer_size, 0, │ │ │ +0003c450: 2026 616d 703b 7365 7373 696f 6e5f 696d &session_im │ │ │ +0003c460: 706c 3a3a 7570 6461 7465 5f73 6f63 6b65 pl::update_socke │ │ │ +0003c470: 745f 6275 6666 6572 5f73 697a 6529 2c0a t_buffer_size),. │ │ │ +0003c480: 0909 5345 5428 7365 6e64 5f73 6f63 6b65 ..SET(send_socke │ │ │ +0003c490: 745f 6275 6666 6572 5f73 697a 652c 2030 t_buffer_size, 0 │ │ │ +0003c4a0: 2c20 2661 6d70 3b73 6573 7369 6f6e 5f69 , &session_i │ │ │ +0003c4b0: 6d70 6c3a 3a75 7064 6174 655f 736f 636b mpl::update_sock │ │ │ +0003c4c0: 6574 5f62 7566 6665 725f 7369 7a65 292c et_buffer_size), │ │ │ +0003c4d0: 0a09 0953 4554 286d 6178 5f70 6565 725f ...SET(max_peer_ │ │ │ +0003c4e0: 7265 6376 5f62 7566 6665 725f 7369 7a65 recv_buffer_size │ │ │ +0003c4f0: 2c20 3220 2a20 3130 3234 202a 2031 3032 , 2 * 1024 * 102 │ │ │ +0003c500: 342c 206e 756c 6c70 7472 292c 0a09 0944 4, nullptr),...D │ │ │ +0003c510: 4550 5245 4341 5445 445f 5345 5428 6669 EPRECATED_SET(fi │ │ │ +0003c520: 6c65 5f63 6865 636b 735f 6465 6c61 795f le_checks_delay_ │ │ │ +0003c530: 7065 725f 626c 6f63 6b2c 2030 2c20 6e75 per_block, 0, nu │ │ │ +0003c540: 6c6c 7074 7229 2c0a 0909 4445 5052 4543 llptr),...DEPREC │ │ │ +0003c550: 4154 4544 325f 5345 5428 7265 6164 5f63 ATED2_SET(read_c │ │ │ +0003c560: 6163 6865 5f6c 696e 655f 7369 7a65 2c20 ache_line_size, │ │ │ +0003c570: 3332 2c20 6e75 6c6c 7074 7229 2c0a 0909 32, nullptr),... │ │ │ +0003c580: 4445 5052 4543 4154 4544 325f 5345 5428 DEPRECATED2_SET( │ │ │ +0003c590: 7772 6974 655f 6361 6368 655f 6c69 6e65 write_cache_line │ │ │ +0003c5a0: 5f73 697a 652c 2031 362c 206e 756c 6c70 _size, 16, nullp │ │ │ +0003c5b0: 7472 292c 0a09 0953 4554 286f 7074 696d tr),...SET(optim │ │ │ +0003c5c0: 6973 7469 635f 6469 736b 5f72 6574 7279 istic_disk_retry │ │ │ +0003c5d0: 2c20 3130 202a 2036 302c 206e 756c 6c70 , 10 * 60, nullp │ │ │ +0003c5e0: 7472 292c 0a09 0953 4554 286d 6178 5f73 tr),...SET(max_s │ │ │ +0003c5f0: 7567 6765 7374 5f70 6965 6365 732c 2031 uggest_pieces, 1 │ │ │ +0003c600: 362c 206e 756c 6c70 7472 292c 0a09 0953 6, nullptr),...S │ │ │ +0003c610: 4554 286c 6f63 616c 5f73 6572 7669 6365 ET(local_service │ │ │ +0003c620: 5f61 6e6e 6f75 6e63 655f 696e 7465 7276 _announce_interv │ │ │ +0003c630: 616c 2c20 3520 2a20 3630 2c20 6e75 6c6c al, 5 * 60, null │ │ │ +0003c640: 7074 7229 2c0a 0909 5345 5428 6468 745f ptr),...SET(dht_ │ │ │ +0003c650: 616e 6e6f 756e 6365 5f69 6e74 6572 7661 announce_interva │ │ │ +0003c660: 6c2c 2031 3520 2a20 3630 2c20 2661 6d70 l, 15 * 60, & │ │ │ +0003c670: 3b73 6573 7369 6f6e 5f69 6d70 6c3a 3a75 ;session_impl::u │ │ │ +0003c680: 7064 6174 655f 6468 745f 616e 6e6f 756e pdate_dht_announ │ │ │ +0003c690: 6365 5f69 6e74 6572 7661 6c29 2c0a 0909 ce_interval),... │ │ │ +0003c6a0: 5345 5428 7564 705f 7472 6163 6b65 725f SET(udp_tracker_ │ │ │ +0003c6b0: 746f 6b65 6e5f 6578 7069 7279 2c20 3630 token_expiry, 60 │ │ │ +0003c6c0: 2c20 6e75 6c6c 7074 7229 2c0a 0909 4445 , nullptr),...DE │ │ │ +0003c6d0: 5052 4543 4154 4544 5f53 4554 2864 6566 PRECATED_SET(def │ │ │ +0003c6e0: 6175 6c74 5f63 6163 6865 5f6d 696e 5f61 ault_cache_min_a │ │ │ +0003c6f0: 6765 2c20 312c 206e 756c 6c70 7472 292c ge, 1, nullptr), │ │ │ +0003c700: 0a09 0953 4554 286e 756d 5f6f 7074 696d ...SET(num_optim │ │ │ +0003c710: 6973 7469 635f 756e 6368 6f6b 655f 736c istic_unchoke_sl │ │ │ +0003c720: 6f74 732c 2030 2c20 6e75 6c6c 7074 7229 ots, 0, nullptr) │ │ │ +0003c730: 2c0a 0909 4445 5052 4543 4154 4544 5f53 ,...DEPRECATED_S │ │ │ +0003c740: 4554 2864 6566 6175 6c74 5f65 7374 5f72 ET(default_est_r │ │ │ +0003c750: 6563 6970 726f 6361 7469 6f6e 5f72 6174 eciprocation_rat │ │ │ +0003c760: 652c 2031 3630 3030 2c20 6e75 6c6c 7074 e, 16000, nullpt │ │ │ +0003c770: 7229 2c0a 0909 4445 5052 4543 4154 4544 r),...DEPRECATED │ │ │ +0003c780: 5f53 4554 2869 6e63 7265 6173 655f 6573 _SET(increase_es │ │ │ +0003c790: 745f 7265 6369 7072 6f63 6174 696f 6e5f t_reciprocation_ │ │ │ +0003c7a0: 7261 7465 2c20 3230 2c20 6e75 6c6c 7074 rate, 20, nullpt │ │ │ +0003c7b0: 7229 2c0a 0909 4445 5052 4543 4154 4544 r),...DEPRECATED │ │ │ +0003c7c0: 5f53 4554 2864 6563 7265 6173 655f 6573 _SET(decrease_es │ │ │ +0003c7d0: 745f 7265 6369 7072 6f63 6174 696f 6e5f t_reciprocation_ │ │ │ +0003c7e0: 7261 7465 2c20 332c 206e 756c 6c70 7472 rate, 3, nullptr │ │ │ +0003c7f0: 292c 0a09 0953 4554 286d 6178 5f70 6578 ),...SET(max_pex │ │ │ +0003c800: 5f70 6565 7273 2c20 3530 2c20 6e75 6c6c _peers, 50, null │ │ │ +0003c810: 7074 7229 2c0a 0909 5345 5428 7469 636b ptr),...SET(tick │ │ │ +0003c820: 5f69 6e74 6572 7661 6c2c 2035 3030 2c20 _interval, 500, │ │ │ +0003c830: 6e75 6c6c 7074 7229 2c0a 0909 5345 5428 nullptr),...SET( │ │ │ +0003c840: 7368 6172 655f 6d6f 6465 5f74 6172 6765 share_mode_targe │ │ │ +0003c850: 742c 2033 2c20 6e75 6c6c 7074 7229 2c0a t, 3, nullptr),. │ │ │ +0003c860: 0909 5345 5428 7570 6c6f 6164 5f72 6174 ..SET(upload_rat │ │ │ +0003c870: 655f 6c69 6d69 742c 2030 2c20 2661 6d70 e_limit, 0, & │ │ │ +0003c880: 3b73 6573 7369 6f6e 5f69 6d70 6c3a 3a75 ;session_impl::u │ │ │ +0003c890: 7064 6174 655f 7570 6c6f 6164 5f72 6174 pdate_upload_rat │ │ │ +0003c8a0: 6529 2c0a 0909 5345 5428 646f 776e 6c6f e),...SET(downlo │ │ │ +0003c8b0: 6164 5f72 6174 655f 6c69 6d69 742c 2030 ad_rate_limit, 0 │ │ │ +0003c8c0: 2c20 2661 6d70 3b73 6573 7369 6f6e 5f69 , &session_i │ │ │ +0003c8d0: 6d70 6c3a 3a75 7064 6174 655f 646f 776e mpl::update_down │ │ │ +0003c8e0: 6c6f 6164 5f72 6174 6529 2c0a 0909 4445 load_rate),...DE │ │ │ +0003c8f0: 5052 4543 4154 4544 5f53 4554 286c 6f63 PRECATED_SET(loc │ │ │ +0003c900: 616c 5f75 706c 6f61 645f 7261 7465 5f6c al_upload_rate_l │ │ │ +0003c910: 696d 6974 2c20 302c 2026 616d 703b 7365 imit, 0, &se │ │ │ +0003c920: 7373 696f 6e5f 696d 706c 3a3a 7570 6461 ssion_impl::upda │ │ │ +0003c930: 7465 5f6c 6f63 616c 5f75 706c 6f61 645f te_local_upload_ │ │ │ +0003c940: 7261 7465 292c 0a09 0944 4550 5245 4341 rate),...DEPRECA │ │ │ +0003c950: 5445 445f 5345 5428 6c6f 6361 6c5f 646f TED_SET(local_do │ │ │ +0003c960: 776e 6c6f 6164 5f72 6174 655f 6c69 6d69 wnload_rate_limi │ │ │ +0003c970: 742c 2030 2c20 2661 6d70 3b73 6573 7369 t, 0, &sessi │ │ │ +0003c980: 6f6e 5f69 6d70 6c3a 3a75 7064 6174 655f on_impl::update_ │ │ │ +0003c990: 6c6f 6361 6c5f 646f 776e 6c6f 6164 5f72 local_download_r │ │ │ +0003c9a0: 6174 6529 2c0a 0909 5345 5428 6468 745f ate),...SET(dht_ │ │ │ +0003c9b0: 7570 6c6f 6164 5f72 6174 655f 6c69 6d69 upload_rate_limi │ │ │ +0003c9c0: 742c 2038 3030 302c 2026 616d 703b 7365 t, 8000, &se │ │ │ +0003c9d0: 7373 696f 6e5f 696d 706c 3a3a 7570 6461 ssion_impl::upda │ │ │ +0003c9e0: 7465 5f64 6874 5f75 706c 6f61 645f 7261 te_dht_upload_ra │ │ │ +0003c9f0: 7465 5f6c 696d 6974 292c 0a09 0953 4554 te_limit),...SET │ │ │ +0003ca00: 2875 6e63 686f 6b65 5f73 6c6f 7473 5f6c (unchoke_slots_l │ │ │ +0003ca10: 696d 6974 2c20 382c 2026 616d 703b 7365 imit, 8, &se │ │ │ +0003ca20: 7373 696f 6e5f 696d 706c 3a3a 7570 6461 ssion_impl::upda │ │ │ +0003ca30: 7465 5f75 6e63 686f 6b65 5f6c 696d 6974 te_unchoke_limit │ │ │ +0003ca40: 292c 0a09 0944 4550 5245 4341 5445 445f ),...DEPRECATED_ │ │ │ +0003ca50: 5345 5428 6861 6c66 5f6f 7065 6e5f 6c69 SET(half_open_li │ │ │ +0003ca60: 6d69 742c 2030 2c20 6e75 6c6c 7074 7229 mit, 0, nullptr) │ │ │ +0003ca70: 2c0a 0909 5345 5428 636f 6e6e 6563 7469 ,...SET(connecti │ │ │ +0003ca80: 6f6e 735f 6c69 6d69 742c 2032 3030 2c20 ons_limit, 200, │ │ │ +0003ca90: 2661 6d70 3b73 6573 7369 6f6e 5f69 6d70 &session_imp │ │ │ +0003caa0: 6c3a 3a75 7064 6174 655f 636f 6e6e 6563 l::update_connec │ │ │ +0003cab0: 7469 6f6e 735f 6c69 6d69 7429 2c0a 0909 tions_limit),... │ │ │ +0003cac0: 5345 5428 636f 6e6e 6563 7469 6f6e 735f SET(connections_ │ │ │ +0003cad0: 736c 6163 6b2c 2031 302c 206e 756c 6c70 slack, 10, nullp │ │ │ +0003cae0: 7472 292c 0a09 0953 4554 2875 7470 5f74 tr),...SET(utp_t │ │ │ +0003caf0: 6172 6765 745f 6465 6c61 792c 2031 3030 arget_delay, 100 │ │ │ +0003cb00: 2c20 6e75 6c6c 7074 7229 2c0a 0909 5345 , nullptr),...SE │ │ │ +0003cb10: 5428 7574 705f 6761 696e 5f66 6163 746f T(utp_gain_facto │ │ │ +0003cb20: 722c 2033 3030 302c 206e 756c 6c70 7472 r, 3000, nullptr │ │ │ +0003cb30: 292c 0a3c 2f70 7265 3e3c 2f74 643e 3c2f ),.
    │ │ │ +0003cb60: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +0003cb70: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +0003cba0: 2f73 7263 2f73 6574 7469 6e67 735f 7061 /src/settings_pa │ │ │ +0003cbb0: 636b 2e63 7070 3a35 3737 3c2f 613e 3c2f ck.cpp:577it would │ │ │ +0003cbd0: 6265 206e 6963 6520 746f 2072 6573 6572 be nice to reser │ │ │ +0003cbe0: 7665 2829 2074 6865 7365 2076 6563 746f ve() these vecto │ │ │ +0003cbf0: 7273 2075 7020 6672 6f6e 743c 2f74 643e rs up front │ │ │ +0003cc00: 3c2f 7472 3e3c 7472 2069 643d 2231 3532

    it woul │ │ │ +0003cc50: 6420 6265 206e 6963 6520 746f 2072 6573 d be nice to res │ │ │ +0003cc60: 6572 7665 2829 2074 6865 7365 2076 6563 erve() these vec │ │ │ +0003cc70: 746f 7273 2075 7020 6672 6f6e 743c 2f68 tors up front

    ../src/set │ │ │ +0003cc90: 7469 6e67 735f 7061 636b 2e63 7070 3a35 tings_pack.cpp:5 │ │ │ +0003cca0: 3737 3c2f 6834 3e3c 7072 6520 7374 796c 77

    ...s.set_str(se
    │ │ │ +0003ccf0: 7474 696e 6773 5f70 6163 6b3a 3a73 7472  ttings_pack::str
    │ │ │ +0003cd00: 696e 675f 7479 7065 5f62 6173 6520 7c20  ing_type_base | 
    │ │ │ +0003cd10: 692c 2073 7472 5f73 6574 7469 6e67 735b  i, str_settings[
    │ │ │ +0003cd20: 695d 2e64 6566 6175 6c74 5f76 616c 7565  i].default_value
    │ │ │ +0003cd30: 293b 0a09 0909 544f 5252 454e 545f 4153  );....TORRENT_AS
    │ │ │ +0003cd40: 5345 5254 2873 2e67 6574 5f73 7472 2873  SERT(s.get_str(s
    │ │ │ +0003cd50: 6574 7469 6e67 735f 7061 636b 3a3a 7374  ettings_pack::st
    │ │ │ +0003cd60: 7269 6e67 5f74 7970 655f 6261 7365 202b  ring_type_base +
    │ │ │ +0003cd70: 2069 2920 3d3d 2073 7472 5f73 6574 7469   i) == str_setti
    │ │ │ +0003cd80: 6e67 735b 695d 2e64 6566 6175 6c74 5f76  ngs[i].default_v
    │ │ │ +0003cd90: 616c 7565 293b 0a09 097d 0a0a 0909 666f  alue);...}....fo
    │ │ │ +0003cda0: 7220 2869 6e74 2069 203d 2030 3b20 6920  r (int i = 0; i 
    │ │ │ +0003cdb0: 266c 743b 2073 6574 7469 6e67 735f 7061  < settings_pa
    │ │ │ +0003cdc0: 636b 3a3a 6e75 6d5f 696e 745f 7365 7474  ck::num_int_sett
    │ │ │ +0003cdd0: 696e 6773 3b20 2b2b 6929 0a09 097b 0a09  ings; ++i)...{..
    │ │ │ +0003cde0: 0909 732e 7365 745f 696e 7428 7365 7474  ..s.set_int(sett
    │ │ │ +0003cdf0: 696e 6773 5f70 6163 6b3a 3a69 6e74 5f74  ings_pack::int_t
    │ │ │ +0003ce00: 7970 655f 6261 7365 207c 2069 2c20 696e  ype_base | i, in
    │ │ │ +0003ce10: 745f 7365 7474 696e 6773 5b69 5d2e 6465  t_settings[i].de
    │ │ │ +0003ce20: 6661 756c 745f 7661 6c75 6529 3b0a 0909  fault_value);...
    │ │ │ +0003ce30: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ +0003ce40: 732e 6765 745f 696e 7428 7365 7474 696e  s.get_int(settin
    │ │ │ +0003ce50: 6773 5f70 6163 6b3a 3a69 6e74 5f74 7970  gs_pack::int_typ
    │ │ │ +0003ce60: 655f 6261 7365 202b 2069 2920 3d3d 2069  e_base + i) == i
    │ │ │ +0003ce70: 6e74 5f73 6574 7469 6e67 735b 695d 2e64  nt_settings[i].d
    │ │ │ +0003ce80: 6566 6175 6c74 5f76 616c 7565 293b 0a09  efault_value);..
    │ │ │ +0003ce90: 097d 0a0a 0909 666f 7220 2869 6e74 2069  .}....for (int i
    │ │ │ +0003cea0: 203d 2030 3b20 6920 266c 743b 2073 6574   = 0; i < set
    │ │ │ +0003ceb0: 7469 6e67 735f 7061 636b 3a3a 6e75 6d5f  tings_pack::num_
    │ │ │ +0003cec0: 626f 6f6c 5f73 6574 7469 6e67 733b 202b  bool_settings; +
    │ │ │ +0003ced0: 2b69 290a 0909 7b0a 0909 0973 2e73 6574  +i)...{....s.set
    │ │ │ +0003cee0: 5f62 6f6f 6c28 7365 7474 696e 6773 5f70  _bool(settings_p
    │ │ │ +0003cef0: 6163 6b3a 3a62 6f6f 6c5f 7479 7065 5f62  ack::bool_type_b
    │ │ │ +0003cf00: 6173 6520 7c20 692c 2062 6f6f 6c5f 7365  ase | i, bool_se
    │ │ │ +0003cf10: 7474 696e 6773 5b69 5d2e 6465 6661 756c  ttings[i].defaul
    │ │ │ +0003cf20: 745f 7661 6c75 6529 3b0a 0909 0954 4f52  t_value);....TOR
    │ │ │ +0003cf30: 5245 4e54 5f41 5353 4552 5428 732e 6765  RENT_ASSERT(s.ge
    │ │ │ +0003cf40: 745f 626f 6f6c 2873 6574 7469 6e67 735f  t_bool(settings_
    │ │ │ +0003cf50: 7061 636b 3a3a 626f 6f6c 5f74 7970 655f  pack::bool_type_
    │ │ │ +0003cf60: 6261 7365 202b 2069 2920 3d3d 2062 6f6f  base + i) == boo
    │ │ │ +0003cf70: 6c5f 7365 7474 696e 6773 5b69 5d2e 6465  l_settings[i].de
    │ │ │ +0003cf80: 6661 756c 745f 7661 6c75 6529 3b0a 0909  fault_value);...
    │ │ │ +0003cf90: 7d0a 097d 0a0a 0973 6574 7469 6e67 735f  }..}...settings_
    │ │ │ +0003cfa0: 7061 636b 2064 6566 6175 6c74 5f73 6574  pack default_set
    │ │ │ +0003cfb0: 7469 6e67 7328 290a 097b 0a09 0973 6574  tings()..{...set
    │ │ │ +0003cfc0: 7469 6e67 735f 7061 636b 2072 6574 3b0a  tings_pack ret;.
    │ │ │ +0003cfd0: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ +0003d000: 666f 7220 2869 6e74 2069 203d 2030 3b20 for (int i = 0; │ │ │ +0003d010: 6920 266c 743b 2073 6574 7469 6e67 735f i < settings_ │ │ │ +0003d020: 7061 636b 3a3a 6e75 6d5f 7374 7269 6e67 pack::num_string │ │ │ +0003d030: 5f73 6574 7469 6e67 733b 202b 2b69 290a _settings; ++i). │ │ │ +0003d040: 3c2f 6469 763e 0909 7b0a 0909 0969 6620
    ..{....if │ │ │ +0003d050: 2873 7472 5f73 6574 7469 6e67 735b 695d (str_settings[i] │ │ │ +0003d060: 2e64 6566 6175 6c74 5f76 616c 7565 2e65 .default_value.e │ │ │ +0003d070: 6d70 7479 2829 2920 636f 6e74 696e 7565 mpty()) continue │ │ │ +0003d080: 3b0a 0909 0972 6574 2e73 6574 5f73 7472 ;....ret.set_str │ │ │ +0003d090: 2873 6574 7469 6e67 735f 7061 636b 3a3a (settings_pack:: │ │ │ +0003d0a0: 7374 7269 6e67 5f74 7970 655f 6261 7365 string_type_base │ │ │ +0003d0b0: 202b 2069 2c20 7374 725f 7365 7474 696e + i, str_settin │ │ │ +0003d0c0: 6773 5b69 5d2e 6465 6661 756c 745f 7661 gs[i].default_va │ │ │ +0003d0d0: 6c75 6529 3b0a 0909 7d0a 0a09 0966 6f72 lue);...}....for │ │ │ +0003d0e0: 2028 696e 7420 6920 3d20 303b 2069 2026 (int i = 0; i & │ │ │ +0003d0f0: 6c74 3b20 7365 7474 696e 6773 5f70 6163 lt; settings_pac │ │ │ +0003d100: 6b3a 3a6e 756d 5f69 6e74 5f73 6574 7469 k::num_int_setti │ │ │ +0003d110: 6e67 733b 202b 2b69 290a 0909 7b0a 0909 ngs; ++i)...{... │ │ │ +0003d120: 0972 6574 2e73 6574 5f69 6e74 2873 6574 .ret.set_int(set │ │ │ +0003d130: 7469 6e67 735f 7061 636b 3a3a 696e 745f tings_pack::int_ │ │ │ +0003d140: 7479 7065 5f62 6173 6520 2b20 692c 2069 type_base + i, i │ │ │ +0003d150: 6e74 5f73 6574 7469 6e67 735b 695d 2e64 nt_settings[i].d │ │ │ +0003d160: 6566 6175 6c74 5f76 616c 7565 293b 0a09 efault_value);.. │ │ │ +0003d170: 097d 0a0a 0909 666f 7220 2869 6e74 2069 .}....for (int i │ │ │ +0003d180: 203d 2030 3b20 6920 266c 743b 2073 6574 = 0; i < set │ │ │ +0003d190: 7469 6e67 735f 7061 636b 3a3a 6e75 6d5f tings_pack::num_ │ │ │ +0003d1a0: 626f 6f6c 5f73 6574 7469 6e67 733b 202b bool_settings; + │ │ │ +0003d1b0: 2b69 290a 0909 7b0a 0909 0972 6574 2e73 +i)...{....ret.s │ │ │ +0003d1c0: 6574 5f62 6f6f 6c28 7365 7474 696e 6773 et_bool(settings │ │ │ +0003d1d0: 5f70 6163 6b3a 3a62 6f6f 6c5f 7479 7065 _pack::bool_type │ │ │ +0003d1e0: 5f62 6173 6520 2b20 692c 2062 6f6f 6c5f _base + i, bool_ │ │ │ +0003d1f0: 7365 7474 696e 6773 5b69 5d2e 6465 6661 settings[i].defa │ │ │ +0003d200: 756c 745f 7661 6c75 6529 3b0a 0909 7d0a ult_value);...}. │ │ │ +0003d210: 0909 7265 7475 726e 2072 6574 3b0a 097d ..return ret;..} │ │ │ +0003d220: 0a0a 0976 6f69 6420 6170 706c 795f 7061 ...void apply_pa │ │ │ +0003d230: 636b 2873 6574 7469 6e67 735f 7061 636b ck(settings_pack │ │ │ +0003d240: 2063 6f6e 7374 2a20 7061 636b 2c20 6175 const* pack, au │ │ │ +0003d250: 783a 3a73 6573 7369 6f6e 5f73 6574 7469 x::session_setti │ │ │ +0003d260: 6e67 7326 616d 703b 2073 6574 740a 0909 ngs& sett... │ │ │ +0003d270: 2c20 6175 783a 3a73 6573 7369 6f6e 5f69 , aux::session_i │ │ │ +0003d280: 6d70 6c2a 2073 6573 290a 097b 0a09 0975 mpl* ses)..{...u │ │ │ +0003d290: 7369 6e67 2066 756e 5f74 203d 2076 6f69 sing fun_t = voi │ │ │ +0003d2a0: 6420 2861 7578 3a3a 7365 7373 696f 6e5f d (aux::session_ │ │ │ +0003d2b0: 696d 706c 3a3a 2a29 2829 3b0a 0909 7374 impl::*)();...st │ │ │ +0003d2c0: 643a 3a76 6563 746f 7226 6c74 3b66 756e d::vector<fun │ │ │ +0003d2d0: 5f74 2667 743b 2063 616c 6c62 6163 6b73 _t> callbacks │ │ │ +0003d2e0: 3b0a 0a09 0973 6574 742e 6275 6c6b 5f73 ;....sett.bulk_s │ │ │ +0003d2f0: 6574 285b 2661 6d70 3b5d 2861 7578 3a3a et([&](aux:: │ │ │ +0003d300: 7365 7373 696f 6e5f 7365 7474 696e 6773 session_settings │ │ │ +0003d310: 5f73 696e 676c 655f 7468 7265 6164 2661 _single_thread&a │ │ │ +0003d320: 6d70 3b20 7329 0a09 097b 0a09 0909 6170 mp; s)...{....ap │ │ │ +0003d330: 706c 795f 7061 636b 5f69 6d70 6c28 7061 ply_pack_impl(pa │ │ │ +0003d340: 636b 2c20 732c 2073 6573 203f 2026 616d ck, s, ses ? &am │ │ │ +0003d350: 703b 6361 6c6c 6261 636b 7320 3a20 6e75 p;callbacks : nu │ │ │ +0003d360: 6c6c 7074 7229 3b0a 0909 7d29 3b0a 0a09 llptr);...});... │ │ │ +0003d370: 092f 2f20 6361 6c6c 2074 6865 2063 616c .// call the cal │ │ │ +0003d380: 6c62 6163 6b73 206f 6e63 6520 616c 6c20 lbacks once all │ │ │ +0003d390: 7468 6520 7365 7474 696e 6773 2068 6176 the settings hav │ │ │ +0003d3a0: 6520 6265 656e 2061 7070 6c69 6564 2c20 e been applied, │ │ │ +0003d3b0: 616e 640a 0909 2f2f 206f 6e6c 7920 6f6e and...// only on │ │ │ +0003d3c0: 6365 2070 6572 2063 616c 6c62 6163 6b0a ce per callback. │ │ │ +0003d3d0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +0003d3e0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +0003d410: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +0003d440: 632f 7365 7373 696f 6e5f 696d 706c 2e63 c/session_impl.c │ │ │ +0003d450: 7070 3a35 3837 3c2f 613e 3c2f 7464 3e3c pp:587< │ │ │ +0003d460: 7464 3e63 6f6d 6520 7570 2077 6974 6820 td>come up with │ │ │ +0003d470: 736f 6d65 2061 6273 7472 6163 7469 6f6e some abstraction │ │ │ +0003d480: 2074 6f20 646f 2074 6869 7320 666f 7220 to do this for │ │ │ +0003d490: 676e 7574 6c73 2061 7320 7765 6c6c 206c gnutls as well l │ │ │ +0003d4a0: 6f61 6420 6365 7274 6966 6963 6174 6573 oad certificates │ │ │ +0003d4b0: 2066 726f 6d20 7468 6520 7769 6e64 6f77 from the window │ │ │ +0003d4c0: 7320 7379 7374 656d 2063 6572 7469 6669 s system certifi │ │ │ +0003d4d0: 6361 7465 2073 746f 7265 3c2f 7464 3e3c cate store< │ │ │ +0003d4e0: 2f74 723e 3c74 7220 6964 3d22 3135 3322 /tr>

    come up │ │ │ +0003d530: 7769 7468 2073 6f6d 6520 6162 7374 7261 with some abstra │ │ │ +0003d540: 6374 696f 6e20 746f 2064 6f20 7468 6973 ction to do this │ │ │ +0003d550: 2066 6f72 2067 6e75 746c 7320 6173 2077 for gnutls as w │ │ │ +0003d560: 656c 6c0a 6c6f 6164 2063 6572 7469 6669 ell.load certifi │ │ │ +0003d570: 6361 7465 7320 6672 6f6d 2074 6865 2077 cates from the w │ │ │ +0003d580: 696e 646f 7773 2073 7973 7465 6d20 6365 indows system ce │ │ │ +0003d590: 7274 6966 6963 6174 6520 7374 6f72 653c rtificate store< │ │ │ +0003d5a0: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f73 /h2>

    ../src/s │ │ │ +0003d5b0: 6573 7369 6f6e 5f69 6d70 6c2e 6370 703a ession_impl.cpp: │ │ │ +0003d5c0: 3538 373c 2f68 343e 3c70 7265 2073 7479 587

    .void session_
    │ │ │ +0003d610: 696d 706c 3a3a 7374 6172 745f 7365 7373  impl::start_sess
    │ │ │ +0003d620: 696f 6e28 290a 097b 0a23 6966 6e64 6566  ion()..{.#ifndef
    │ │ │ +0003d630: 2054 4f52 5245 4e54 5f44 4953 4142 4c45   TORRENT_DISABLE
    │ │ │ +0003d640: 5f4c 4f47 4749 4e47 0a09 0973 6573 7369  _LOGGING...sessi
    │ │ │ +0003d650: 6f6e 5f6c 6f67 2822 7374 6172 7420 7365  on_log("start se
    │ │ │ +0003d660: 7373 696f 6e22 293b 0a23 656e 6469 660a  ssion");.#endif.
    │ │ │ +0003d670: 0a23 6966 2054 4f52 5245 4e54 5f55 5345  .#if TORRENT_USE
    │ │ │ +0003d680: 5f53 534c 0a09 0965 7272 6f72 5f63 6f64  _SSL...error_cod
    │ │ │ +0003d690: 6520 6563 3b0a 0909 6d5f 7373 6c5f 6374  e ec;...m_ssl_ct
    │ │ │ +0003d6a0: 782e 7365 745f 6f70 7469 6f6e 7328 7373  x.set_options(ss
    │ │ │ +0003d6b0: 6c3a 3a6e 6f5f 6c65 6761 6379 5f74 6c73  l::no_legacy_tls
    │ │ │ +0003d6c0: 5f76 6572 7369 6f6e 732c 2065 6329 3b0a  _versions, ec);.
    │ │ │ +0003d6d0: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ +0003d6e0: 4449 5341 424c 455f 4c4f 4747 494e 470a  DISABLE_LOGGING.
    │ │ │ +0003d6f0: 0909 6966 2028 6563 290a 0909 0973 6573  ..if (ec)....ses
    │ │ │ +0003d700: 7369 6f6e 5f6c 6f67 2822 5353 4c20 7365  sion_log("SSL se
    │ │ │ +0003d710: 745f 6f70 7469 6f6e 7320 6661 696c 6564  t_options failed
    │ │ │ +0003d720: 3a20 2573 222c 2065 632e 6d65 7373 6167  : %s", ec.messag
    │ │ │ +0003d730: 6528 292e 635f 7374 7228 2929 3b0a 0909  e().c_str());...
    │ │ │ +0003d740: 6563 2e63 6c65 6172 2829 3b0a 2365 6e64  ec.clear();.#end
    │ │ │ +0003d750: 6966 0a09 096d 5f73 736c 5f63 7478 2e73  if...m_ssl_ctx.s
    │ │ │ +0003d760: 6574 5f64 6566 6175 6c74 5f76 6572 6966  et_default_verif
    │ │ │ +0003d770: 795f 7061 7468 7328 6563 293b 0a23 6966  y_paths(ec);.#if
    │ │ │ +0003d780: 6e64 6566 2054 4f52 5245 4e54 5f44 4953  ndef TORRENT_DIS
    │ │ │ +0003d790: 4142 4c45 5f4c 4f47 4749 4e47 0a09 0969  ABLE_LOGGING...i
    │ │ │ +0003d7a0: 6620 2865 6329 2073 6573 7369 6f6e 5f6c  f (ec) session_l
    │ │ │ +0003d7b0: 6f67 2822 5353 4c20 7365 745f 6465 6661  og("SSL set_defa
    │ │ │ +0003d7c0: 756c 7420 7665 7269 6679 5f70 6174 6873  ult verify_paths
    │ │ │ +0003d7d0: 2066 6169 6c65 643a 2025 7322 2c20 6563   failed: %s", ec
    │ │ │ +0003d7e0: 2e6d 6573 7361 6765 2829 2e63 5f73 7472  .message().c_str
    │ │ │ +0003d7f0: 2829 293b 0a09 0965 632e 636c 6561 7228  ());...ec.clear(
    │ │ │ +0003d800: 293b 0a23 656e 6469 660a 2369 6620 6465  );.#endif.#if de
    │ │ │ +0003d810: 6669 6e65 6420 544f 5252 454e 545f 5749  fined TORRENT_WI
    │ │ │ +0003d820: 4e44 4f57 5320 2661 6d70 3b26 616d 703b  NDOWS &&
    │ │ │ +0003d830: 2064 6566 696e 6564 2054 4f52 5245 4e54   defined TORRENT
    │ │ │ +0003d840: 5f55 5345 5f4f 5045 4e53 534c 2026 616d  _USE_OPENSSL &am
    │ │ │ +0003d850: 703b 2661 6d70 3b20 2164 6566 696e 6564  p;& !defined
    │ │ │ +0003d860: 2054 4f52 5245 4e54 5f57 494e 5254 0a3c   TORRENT_WINRT.<
    │ │ │ +0003d870: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +0003d880: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +0003d890: 7769 6474 683d 2231 3030 2522 3e09 0958  width="100%">..X
    │ │ │ +0003d8a0: 3530 395f 5354 4f52 452a 2073 746f 7265  509_STORE* store
    │ │ │ +0003d8b0: 203d 2058 3530 395f 5354 4f52 455f 6e65   = X509_STORE_ne
    │ │ │ +0003d8c0: 7728 293b 0a3c 2f64 6976 3e09 0969 6620  w();...if 
    │ │ │ +0003d8d0: 2873 746f 7265 290a 0909 7b0a 0909 0948  (store)...{....H
    │ │ │ +0003d8e0: 4345 5254 5354 4f52 4520 7379 7374 656d  CERTSTORE system
    │ │ │ +0003d8f0: 5f73 746f 7265 203d 2043 6572 744f 7065  _store = CertOpe
    │ │ │ +0003d900: 6e53 7973 7465 6d53 746f 7265 4128 302c  nSystemStoreA(0,
    │ │ │ +0003d910: 2022 524f 4f54 2229 3b0a 0909 092f 2f20   "ROOT");....// 
    │ │ │ +0003d920: 7468 6973 2069 7320 6265 7374 2065 6666  this is best eff
    │ │ │ +0003d930: 6f72 740a 0909 0969 6620 2873 7973 7465  ort....if (syste
    │ │ │ +0003d940: 6d5f 7374 6f72 6529 0a09 0909 7b0a 0909  m_store)....{...
    │ │ │ +0003d950: 0909 4345 5254 5f43 4f4e 5445 5854 2063  ..CERT_CONTEXT c
    │ │ │ +0003d960: 6f6e 7374 2a20 6374 7820 3d20 6e75 6c6c  onst* ctx = null
    │ │ │ +0003d970: 7074 723b 0a09 0909 0977 6869 6c65 2028  ptr;.....while (
    │ │ │ +0003d980: 2863 7478 203d 2043 6572 7445 6e75 6d43  (ctx = CertEnumC
    │ │ │ +0003d990: 6572 7469 6669 6361 7465 7349 6e53 746f  ertificatesInSto
    │ │ │ +0003d9a0: 7265 2873 7973 7465 6d5f 7374 6f72 652c  re(system_store,
    │ │ │ +0003d9b0: 2063 7478 2929 2021 3d20 6e75 6c6c 7074   ctx)) != nullpt
    │ │ │ +0003d9c0: 7229 0a09 0909 097b 0a09 0909 0909 756e  r).....{......un
    │ │ │ +0003d9d0: 7369 676e 6564 2063 6861 7220 636f 6e73  signed char cons
    │ │ │ +0003d9e0: 742a 2063 6572 745f 7074 7220 3d20 7265  t* cert_ptr = re
    │ │ │ +0003d9f0: 696e 7465 7270 7265 745f 6361 7374 266c  interpret_cast&l
    │ │ │ +0003da00: 743b 756e 7369 676e 6564 2063 6861 7220  t;unsigned char 
    │ │ │ +0003da10: 636f 6e73 742a 2667 743b 2863 7478 2d26  const*>(ctx-&
    │ │ │ +0003da20: 6774 3b70 6243 6572 7445 6e63 6f64 6564  gt;pbCertEncoded
    │ │ │ +0003da30: 293b 0a09 0909 0909 5835 3039 2a20 7835  );......X509* x5
    │ │ │ +0003da40: 3039 203d 2064 3269 5f58 3530 3928 6e75  09 = d2i_X509(nu
    │ │ │ +0003da50: 6c6c 7074 722c 2026 616d 703b 6365 7274  llptr, &cert
    │ │ │ +0003da60: 5f70 7472 2c20 6374 782d 2667 743b 6362  _ptr, ctx->cb
    │ │ │ +0003da70: 4365 7274 456e 636f 6465 6429 3b0a 0909  CertEncoded);...
    │ │ │ +0003da80: 0909 092f 2f20 7468 6973 2069 7320 6265  ...// this is be
    │ │ │ +0003da90: 7374 2065 6666 6f72 740a 0909 0909 0969  st effort......i
    │ │ │ +0003daa0: 6620 2821 7835 3039 2920 636f 6e74 696e  f (!x509) contin
    │ │ │ +0003dab0: 7565 3b0a 0909 0909 0958 3530 395f 5354  ue;......X509_ST
    │ │ │ +0003dac0: 4f52 455f 6164 645f 6365 7274 2873 746f  ORE_add_cert(sto
    │ │ │ +0003dad0: 7265 2c20 7835 3039 293b 0a09 0909 0909  re, x509);......
    │ │ │ +0003dae0: 5835 3039 5f66 7265 6528 7835 3039 293b  X509_free(x509);
    │ │ │ +0003daf0: 0a09 0909 097d 0a09 0909 0943 6572 7446  .....}.....CertF
    │ │ │ +0003db00: 7265 6543 6572 7469 6669 6361 7465 436f  reeCertificateCo
    │ │ │ +0003db10: 6e74 6578 7428 6374 7829 3b0a 0909 0909  ntext(ctx);.....
    │ │ │ +0003db20: 4365 7274 436c 6f73 6553 746f 7265 2873  CertCloseStore(s
    │ │ │ +0003db30: 7973 7465 6d5f 7374 6f72 652c 2030 293b  ystem_store, 0);
    │ │ │ +0003db40: 0a09 0909 7d0a 0909 7d0a 0a09 0953 534c  ....}...}....SSL
    │ │ │ +0003db50: 5f43 5458 2a20 7373 6c5f 6374 7820 3d20  _CTX* ssl_ctx = 
    │ │ │ +0003db60: 6d5f 7373 6c5f 6374 782e 6e61 7469 7665  m_ssl_ctx.native
    │ │ │ +0003db70: 5f68 616e 646c 6528 293b 0a09 0953 534c  _handle();...SSL
    │ │ │ +0003db80: 5f43 5458 5f73 6574 5f63 6572 745f 7374  _CTX_set_cert_st
    │ │ │ +0003db90: 6f72 6528 7373 6c5f 6374 782c 2073 746f  ore(ssl_ctx, sto
    │ │ │ +0003dba0: 7265 293b 0a23 656e 6469 660a 2369 6664  re);.#endif.#ifd
    │ │ │ +0003dbb0: 6566 205f 5f41 5050 4c45 5f5f 0a09 096d  ef __APPLE__...m
    │ │ │ +0003dbc0: 5f73 736c 5f63 7478 2e6c 6f61 645f 7665  _ssl_ctx.load_ve
    │ │ │ +0003dbd0: 7269 6679 5f66 696c 6528 222f 6574 632f  rify_file("/etc/
    │ │ │ +0003dbe0: 7373 6c2f 6365 7274 2e70 656d 222c 2065  ssl/cert.pem", e
    │ │ │ +0003dbf0: 6329 3b0a 2369 666e 6465 6620 544f 5252  c);.#ifndef TORR
    │ │ │ +0003dc00: 454e 545f 4449 5341 424c 455f 4c4f 4747  ENT_DISABLE_LOGG
    │ │ │ +0003dc10: 494e 470a 0909 6966 2028 6563 2920 7365  ING...if (ec) se
    │ │ │ +0003dc20: 7373 696f 6e5f 6c6f 6728 2253 534c 206c  ssion_log("SSL l
    │ │ │ +0003dc30: 6f61 645f 7665 7269 6679 5f66 696c 6520  oad_verify_file 
    │ │ │ +0003dc40: 6661 696c 6564 3a20 2573 222c 2065 632e  failed: %s", ec.
    │ │ │ +0003dc50: 6d65 7373 6167 6528 292e 635f 7374 7228  message().c_str(
    │ │ │ +0003dc60: 2929 3b0a 2365 6e64 6966 0a09 0965 632e  ));.#endif...ec.
    │ │ │ +0003dc70: 636c 6561 7228 293b 0a3c 2f70 7265 3e3c  clear();.
    < │ │ │ +0003dc80: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +0003dcb0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +0003dcc0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/sessi │ │ │ +0003dcf0: 6f6e 5f69 6d70 6c2e 6370 703a 3134 3634 on_impl.cpp:1464 │ │ │ +0003dd00: 3c2f 613e 3c2f 7464 3e3c 7464 3e69 7420 it │ │ │ +0003dd10: 776f 756c 6420 6265 206e 6963 6520 746f would be nice to │ │ │ +0003dd20: 2072 6573 6572 7665 2829 2074 6865 7365 reserve() these │ │ │ +0003dd30: 2076 6563 746f 7273 2075 7020 6672 6f6e vectors up fron │ │ │ +0003dd40: 743c 2f74 643e 3c2f 7472 3e3c 7472 2069 t

    i │ │ │ +0003dd90: 7420 776f 756c 6420 6265 206e 6963 6520 t would be nice │ │ │ +0003dda0: 746f 2072 6573 6572 7665 2829 2074 6865 to reserve() the │ │ │ +0003ddb0: 7365 2076 6563 746f 7273 2075 7020 6672 se vectors up fr │ │ │ +0003ddc0: 6f6e 743c 2f68 323e 3c68 343e 2e2e 2f73 ont

    ../s │ │ │ +0003ddd0: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ +0003dde0: 6370 703a 3134 3634 3c2f 6834 3e3c 7072 cpp:1464

    ...bandwi │ │ │ +0003de30: 6474 685f 6368 616e 6e65 6c2a 2063 6820 dth_channel* ch │ │ │ +0003de40: 3d20 2661 6d70 3b70 2d26 6774 3b63 6861 = &p->cha │ │ │ +0003de50: 6e6e 656c 5b70 6565 725f 636f 6e6e 6563 nnel[peer_connec │ │ │ +0003de60: 7469 6f6e 3a3a 646f 776e 6c6f 6164 5f63 tion::download_c │ │ │ +0003de70: 6861 6e6e 656c 5d3b 0a09 0909 6966 2028 hannel];....if ( │ │ │ +0003de80: 7573 655f 7175 6f74 615f 6f76 6572 6865 use_quota_overhe │ │ │ +0003de90: 6164 2863 682c 2061 6d6f 756e 745f 646f ad(ch, amount_do │ │ │ +0003dea0: 776e 2929 0a09 0909 0972 6574 207c 3d20 wn)).....ret |= │ │ │ +0003deb0: 3175 2026 6c74 3b26 6c74 3b20 7065 6572 1u << peer │ │ │ +0003dec0: 5f63 6f6e 6e65 6374 696f 6e3a 3a64 6f77 _connection::dow │ │ │ +0003ded0: 6e6c 6f61 645f 6368 616e 6e65 6c3b 0a09 nload_channel;.. │ │ │ +0003dee0: 0909 6368 203d 2026 616d 703b 702d 2667 ..ch = &p-&g │ │ │ +0003def0: 743b 6368 616e 6e65 6c5b 7065 6572 5f63 t;channel[peer_c │ │ │ +0003df00: 6f6e 6e65 6374 696f 6e3a 3a75 706c 6f61 onnection::uploa │ │ │ +0003df10: 645f 6368 616e 6e65 6c5d 3b0a 0909 0969 d_channel];....i │ │ │ +0003df20: 6620 2875 7365 5f71 756f 7461 5f6f 7665 f (use_quota_ove │ │ │ +0003df30: 7268 6561 6428 6368 2c20 616d 6f75 6e74 rhead(ch, amount │ │ │ +0003df40: 5f75 7029 290a 0909 0909 7265 7420 7c3d _up)).....ret |= │ │ │ +0003df50: 2031 7520 266c 743b 266c 743b 2070 6565 1u << pee │ │ │ +0003df60: 725f 636f 6e6e 6563 7469 6f6e 3a3a 7570 r_connection::up │ │ │ +0003df70: 6c6f 6164 5f63 6861 6e6e 656c 3b0a 0909 load_channel;... │ │ │ +0003df80: 7d0a 0909 7265 7475 726e 2072 6574 3b0a }...return ret;. │ │ │ +0003df90: 097d 0a0a 092f 2f20 7365 7373 696f 6e5f .}...// session_ │ │ │ +0003dfa0: 696d 706c 2069 7320 7265 7370 6f6e 7369 impl is responsi │ │ │ +0003dfb0: 626c 6520 666f 7220 6465 6c65 7469 6e67 ble for deleting │ │ │ +0003dfc0: 2027 7061 636b 270a 0976 6f69 6420 7365 'pack'..void se │ │ │ +0003dfd0: 7373 696f 6e5f 696d 706c 3a3a 6170 706c ssion_impl::appl │ │ │ +0003dfe0: 795f 7365 7474 696e 6773 5f70 6163 6b28 y_settings_pack( │ │ │ +0003dff0: 7374 643a 3a73 6861 7265 645f 7074 7226 std::shared_ptr& │ │ │ +0003e000: 6c74 3b73 6574 7469 6e67 735f 7061 636b lt;settings_pack │ │ │ +0003e010: 2667 743b 2070 6163 6b29 0a09 7b0a 0909 > pack)..{... │ │ │ +0003e020: 494e 5641 5249 414e 545f 4348 4543 4b3b INVARIANT_CHECK; │ │ │ +0003e030: 0a09 0961 7070 6c79 5f73 6574 7469 6e67 ...apply_setting │ │ │ +0003e040: 735f 7061 636b 5f69 6d70 6c28 2a70 6163 s_pack_impl(*pac │ │ │ +0003e050: 6b29 3b0a 097d 0a0a 0973 6574 7469 6e67 k);..}...setting │ │ │ +0003e060: 735f 7061 636b 2073 6573 7369 6f6e 5f69 s_pack session_i │ │ │ +0003e070: 6d70 6c3a 3a67 6574 5f73 6574 7469 6e67 mpl::get_setting │ │ │ +0003e080: 7328 2920 636f 6e73 740a 097b 0a09 0973 s() const..{...s │ │ │ +0003e090: 6574 7469 6e67 735f 7061 636b 2072 6574 ettings_pack ret │ │ │ +0003e0a0: 3b0a 3c64 6976 2073 7479 6c65 3d22 6261 ;.
    │ │ │ +0003e0d0: 0909 666f 7220 2869 6e74 2069 203d 2073 ..for (int i = s │ │ │ +0003e0e0: 6574 7469 6e67 735f 7061 636b 3a3a 7374 ettings_pack::st │ │ │ +0003e0f0: 7269 6e67 5f74 7970 655f 6261 7365 3b0a ring_type_base;. │ │ │ +0003e100: 3c2f 6469 763e 0909 0969 2026 6c74 3b20
    ...i < │ │ │ +0003e110: 7365 7474 696e 6773 5f70 6163 6b3a 3a6d settings_pack::m │ │ │ +0003e120: 6178 5f73 7472 696e 675f 7365 7474 696e ax_string_settin │ │ │ +0003e130: 675f 696e 7465 726e 616c 3b20 2b2b 6929 g_internal; ++i) │ │ │ +0003e140: 0a09 097b 0a09 0909 7265 742e 7365 745f ...{....ret.set_ │ │ │ +0003e150: 7374 7228 692c 206d 5f73 6574 7469 6e67 str(i, m_setting │ │ │ +0003e160: 732e 6765 745f 7374 7228 6929 293b 0a09 s.get_str(i));.. │ │ │ +0003e170: 097d 0a09 0966 6f72 2028 696e 7420 6920 .}...for (int i │ │ │ +0003e180: 3d20 7365 7474 696e 6773 5f70 6163 6b3a = settings_pack: │ │ │ +0003e190: 3a69 6e74 5f74 7970 655f 6261 7365 3b0a :int_type_base;. │ │ │ +0003e1a0: 0909 0969 2026 6c74 3b20 7365 7474 696e ...i < settin │ │ │ +0003e1b0: 6773 5f70 6163 6b3a 3a6d 6178 5f69 6e74 gs_pack::max_int │ │ │ +0003e1c0: 5f73 6574 7469 6e67 5f69 6e74 6572 6e61 _setting_interna │ │ │ +0003e1d0: 6c3b 202b 2b69 290a 0909 7b0a 0909 0972 l; ++i)...{....r │ │ │ +0003e1e0: 6574 2e73 6574 5f69 6e74 2869 2c20 6d5f et.set_int(i, m_ │ │ │ +0003e1f0: 7365 7474 696e 6773 2e67 6574 5f69 6e74 settings.get_int │ │ │ +0003e200: 2869 2929 3b0a 0909 7d0a 0909 666f 7220 (i));...}...for │ │ │ +0003e210: 2869 6e74 2069 203d 2073 6574 7469 6e67 (int i = setting │ │ │ +0003e220: 735f 7061 636b 3a3a 626f 6f6c 5f74 7970 s_pack::bool_typ │ │ │ +0003e230: 655f 6261 7365 3b0a 0909 0969 2026 6c74 e_base;....i < │ │ │ +0003e240: 3b20 7365 7474 696e 6773 5f70 6163 6b3a ; settings_pack: │ │ │ +0003e250: 3a6d 6178 5f62 6f6f 6c5f 7365 7474 696e :max_bool_settin │ │ │ +0003e260: 675f 696e 7465 726e 616c 3b20 2b2b 6929 g_internal; ++i) │ │ │ +0003e270: 0a09 097b 0a09 0909 7265 742e 7365 745f ...{....ret.set_ │ │ │ +0003e280: 626f 6f6c 2869 2c20 6d5f 7365 7474 696e bool(i, m_settin │ │ │ +0003e290: 6773 2e67 6574 5f62 6f6f 6c28 6929 293b gs.get_bool(i)); │ │ │ +0003e2a0: 0a09 097d 0a09 0972 6574 7572 6e20 7265 ...}...return re │ │ │ +0003e2b0: 743b 0a09 7d0a 0a6e 616d 6573 7061 6365 t;..}..namespace │ │ │ +0003e2c0: 207b 0a09 7465 6d70 6c61 7465 2026 6c74 {..template < │ │ │ +0003e2d0: 3b74 7970 656e 616d 6520 5061 636b 2667 ;typename Pack&g │ │ │ +0003e2e0: 743b 0a09 696e 7420 6765 745f 7365 7474 t;..int get_sett │ │ │ +0003e2f0: 696e 675f 696d 706c 2850 6163 6b20 636f ing_impl(Pack co │ │ │ +0003e300: 6e73 7426 616d 703b 2070 2c20 696e 7420 nst& p, int │ │ │ +0003e310: 6e61 6d65 2c20 696e 742a 290a 097b 2072 name, int*)..{ r │ │ │ +0003e320: 6574 7572 6e20 702e 6765 745f 696e 7428 eturn p.get_int( │ │ │ +0003e330: 6e61 6d65 293b 207d 0a0a 0974 656d 706c name); }...templ │ │ │ +0003e340: 6174 6520 266c 743b 7479 7065 6e61 6d65 ate <typename │ │ │ +0003e350: 2050 6163 6b26 6774 3b0a 0962 6f6f 6c20 Pack>..bool │ │ │ +0003e360: 6765 745f 7365 7474 696e 675f 696d 706c get_setting_impl │ │ │ +0003e370: 2850 6163 6b20 636f 6e73 7426 616d 703b (Pack const& │ │ │ +0003e380: 2070 2c20 696e 7420 6e61 6d65 2c20 626f p, int name, bo │ │ │ +0003e390: 6f6c 2a29 0a09 7b20 7265 7475 726e 2070 ol*)..{ return p │ │ │ +0003e3a0: 2e67 6574 5f62 6f6f 6c28 6e61 6d65 293b .get_bool(name); │ │ │ +0003e3b0: 207d 0a0a 0974 656d 706c 6174 6520 266c }...template &l │ │ │ +0003e3c0: 743b 7479 7065 6e61 6d65 2050 6163 6b26 t;typename Pack& │ │ │ +0003e3d0: 6774 3b0a 0973 7464 3a3a 7374 7269 6e67 gt;..std::string │ │ │ +0003e3e0: 2067 6574 5f73 6574 7469 6e67 5f69 6d70 get_setting_imp │ │ │ +0003e3f0: 6c28 5061 636b 2063 6f6e 7374 2661 6d70 l(Pack const& │ │ │ +0003e400: 3b20 702c 2069 6e74 206e 616d 652c 2073 ; p, int name, s │ │ │ +0003e410: 7464 3a3a 7374 7269 6e67 2a29 0a09 7b20 td::string*)..{ │ │ │ +0003e420: 7265 7475 726e 2070 2e67 6574 5f73 7472 return p.get_str │ │ │ +0003e430: 286e 616d 6529 3b20 7d0a 0a3c 2f70 7265 (name); }..rele │ │ │ +0003e470: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/ses │ │ │ +0003e4b0: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3230 sion_impl.cpp:20 │ │ │ +0003e4c0: 3239 3c2f 613e 3c2f 7464 3e3c 7464 3e63 29c │ │ │ +0003e4d0: 6f75 6c64 2074 6869 7320 6675 6e63 7469 ould this functi │ │ │ +0003e4e0: 6f6e 2062 6520 6d65 7267 6564 2077 6974 on be merged wit │ │ │ +0003e4f0: 6820 6578 7061 6e64 5f75 6e73 7065 6369 h expand_unspeci │ │ │ +0003e500: 6669 6564 5f61 6464 7265 7373 6573 3f20 fied_addresses? │ │ │ +0003e510: 7269 6768 7420 6e6f 7720 626f 7468 206c right now both l │ │ │ +0003e520: 6973 7465 6e5f 656e 6470 6f69 6e74 5f74 isten_endpoint_t │ │ │ +0003e530: 2061 6e64 206c 6973 7465 6e5f 696e 7465 and listen_inte │ │ │ +0003e540: 7266 6163 655f 7420 6172 6520 616c 6d6f rface_t are almo │ │ │ +0003e550: 7374 2069 6465 6e74 6963 616c 2c20 6d61 st identical, ma │ │ │ +0003e560: 7962 6520 7468 6520 6c61 7474 6572 2063 ybe the latter c │ │ │ +0003e570: 6f75 6c64 2062 6520 7265 6d6f 7665 6420 ould be removed │ │ │ +0003e580: 746f 6f3c 2f74 643e 3c2f 7472 3e3c 7472 too

    could this func │ │ │ +0003e5e0: 7469 6f6e 2062 6520 6d65 7267 6564 2077 tion be merged w │ │ │ +0003e5f0: 6974 6820 6578 7061 6e64 5f75 6e73 7065 ith expand_unspe │ │ │ +0003e600: 6369 6669 6564 5f61 6464 7265 7373 6573 cified_addresses │ │ │ +0003e610: 3f0a 7269 6768 7420 6e6f 7720 626f 7468 ?.right now both │ │ │ +0003e620: 206c 6973 7465 6e5f 656e 6470 6f69 6e74 listen_endpoint │ │ │ +0003e630: 5f74 2061 6e64 206c 6973 7465 6e5f 696e _t and listen_in │ │ │ +0003e640: 7465 7266 6163 655f 7420 6172 6520 616c terface_t are al │ │ │ +0003e650: 6d6f 7374 0a69 6465 6e74 6963 616c 2c20 most.identical, │ │ │ +0003e660: 6d61 7962 6520 7468 6520 6c61 7474 6572 maybe the latter │ │ │ +0003e670: 2063 6f75 6c64 2062 6520 7265 6d6f 7665 could be remove │ │ │ +0003e680: 6420 746f 6f3c 2f68 323e 3c68 343e 2e2e d too

    .. │ │ │ +0003e690: 2f73 7263 2f73 6573 7369 6f6e 5f69 6d70 /src/session_imp │ │ │ +0003e6a0: 6c2e 6370 703a 3230 3239 3c2f 6834 3e3c l.cpp:2029

    < │ │ │ +0003e6b0: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +0003e6c0: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +0003e6d0: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +0003e6e0: 7820 2364 6464 3b22 3e09 0973 6573 7369 x #ddd;">..sessi │ │ │ +0003e6f0: 6f6e 5f6c 6f67 2822 4641 5441 4c20 5345 on_log("FATAL SE │ │ │ +0003e700: 5353 494f 4e20 4552 524f 5220 2825 7320 SSION ERROR (%s │ │ │ +0003e710: 3a20 2564 2920 5b25 735d 220a 0909 092c : %d) [%s]"...., │ │ │ +0003e720: 2065 632e 6361 7465 676f 7279 2829 2e6e ec.category().n │ │ │ +0003e730: 616d 6528 292c 2065 632e 7661 6c75 6528 ame(), ec.value( │ │ │ +0003e740: 292c 2065 632e 6d65 7373 6167 6528 292e ), ec.message(). │ │ │ +0003e750: 635f 7374 7228 2929 3b0a 2365 6e64 6966 c_str());.#endif │ │ │ +0003e760: 0a09 0974 6869 732d 2667 743b 6162 6f72 ...this->abor │ │ │ +0003e770: 7428 293b 0a09 7d0a 0a09 766f 6964 2073 t();..}...void s │ │ │ +0003e780: 6573 7369 6f6e 5f69 6d70 6c3a 3a6f 6e5f ession_impl::on_ │ │ │ +0003e790: 6970 5f63 6861 6e67 6528 6572 726f 725f ip_change(error_ │ │ │ +0003e7a0: 636f 6465 2063 6f6e 7374 2661 6d70 3b20 code const& │ │ │ +0003e7b0: 6563 290a 097b 0a23 6966 6e64 6566 2054 ec)..{.#ifndef T │ │ │ +0003e7c0: 4f52 5245 4e54 5f44 4953 4142 4c45 5f4c ORRENT_DISABLE_L │ │ │ +0003e7d0: 4f47 4749 4e47 0a09 0969 6620 2821 6563 OGGING...if (!ec │ │ │ +0003e7e0: 290a 0909 0973 6573 7369 6f6e 5f6c 6f67 )....session_log │ │ │ +0003e7f0: 2822 7265 6365 6976 6564 2069 7020 6368 ("received ip ch │ │ │ +0003e800: 616e 6765 2066 726f 6d20 696e 7465 726e ange from intern │ │ │ +0003e810: 616c 2069 705f 6e6f 7469 6669 6572 2229 al ip_notifier") │ │ │ +0003e820: 3b0a 0909 656c 7365 0a09 0909 7365 7373 ;...else....sess │ │ │ +0003e830: 696f 6e5f 6c6f 6728 2272 6563 6569 7665 ion_log("receive │ │ │ +0003e840: 6420 6572 726f 7220 6f6e 5f69 705f 6368 d error on_ip_ch │ │ │ +0003e850: 616e 6765 3a20 2564 2c20 2573 222c 2065 ange: %d, %s", e │ │ │ +0003e860: 632e 7661 6c75 6528 292c 2065 632e 6d65 c.value(), ec.me │ │ │ +0003e870: 7373 6167 6528 292e 635f 7374 7228 2929 ssage().c_str()) │ │ │ +0003e880: 3b0a 2365 6e64 6966 0a09 0969 6620 2865 ;.#endif...if (e │ │ │ +0003e890: 6320 7c7c 206d 5f61 626f 7274 207c 7c20 c || m_abort || │ │ │ +0003e8a0: 216d 5f69 705f 6e6f 7469 6669 6572 2920 !m_ip_notifier) │ │ │ +0003e8b0: 7265 7475 726e 3b0a 0909 6d5f 6970 5f6e return;...m_ip_n │ │ │ +0003e8c0: 6f74 6966 6965 722d 2667 743b 6173 796e otifier->asyn │ │ │ +0003e8d0: 635f 7761 6974 285b 7468 6973 5d20 2865 c_wait([this] (e │ │ │ +0003e8e0: 7272 6f72 5f63 6f64 6520 636f 6e73 7426 rror_code const& │ │ │ +0003e8f0: 616d 703b 2065 290a 0909 097b 2077 7261 amp; e)....{ wra │ │ │ +0003e900: 7028 2661 6d70 3b73 6573 7369 6f6e 5f69 p(&session_i │ │ │ +0003e910: 6d70 6c3a 3a6f 6e5f 6970 5f63 6861 6e67 mpl::on_ip_chang │ │ │ +0003e920: 652c 2065 293b 207d 293b 0a09 0972 656f e, e); });...reo │ │ │ +0003e930: 7065 6e5f 6e65 7477 6f72 6b5f 736f 636b pen_network_sock │ │ │ +0003e940: 6574 7328 7b7d 293b 0a09 7d0a 0a3c 6469 ets({});..}...void │ │ │ +0003e980: 2069 6e74 6572 6661 6365 5f74 6f5f 656e interface_to_en │ │ │ +0003e990: 6470 6f69 6e74 7328 6c69 7374 656e 5f69 dpoints(listen_i │ │ │ +0003e9a0: 6e74 6572 6661 6365 5f74 2063 6f6e 7374 nterface_t const │ │ │ +0003e9b0: 2661 6d70 3b20 6966 6163 650a 3c2f 6469 & iface..., listen_soc │ │ │ +0003e9d0: 6b65 745f 666c 6167 735f 7420 666c 6167 ket_flags_t flag │ │ │ +0003e9e0: 730a 0909 2c20 7370 616e 266c 743b 6970 s..., span<ip │ │ │ +0003e9f0: 5f69 6e74 6572 6661 6365 2063 6f6e 7374 _interface const │ │ │ +0003ea00: 2667 743b 2063 6f6e 7374 2069 6673 0a09 > const ifs.. │ │ │ +0003ea10: 092c 2073 7464 3a3a 7665 6374 6f72 266c ., std::vector&l │ │ │ +0003ea20: 743b 6c69 7374 656e 5f65 6e64 706f 696e t;listen_endpoin │ │ │ +0003ea30: 745f 7426 6774 3b26 616d 703b 2065 7073 t_t>& eps │ │ │ +0003ea40: 290a 097b 0a09 0966 6c61 6773 207c 3d20 )..{...flags |= │ │ │ +0003ea50: 6966 6163 652e 6c6f 6361 6c20 3f20 6c69 iface.local ? li │ │ │ +0003ea60: 7374 656e 5f73 6f63 6b65 745f 743a 3a6c sten_socket_t::l │ │ │ +0003ea70: 6f63 616c 5f6e 6574 776f 726b 203a 206c ocal_network : l │ │ │ +0003ea80: 6973 7465 6e5f 736f 636b 6574 5f66 6c61 isten_socket_fla │ │ │ +0003ea90: 6773 5f74 7b7d 3b0a 0909 7472 616e 7370 gs_t{};...transp │ │ │ +0003eaa0: 6f72 7420 636f 6e73 7420 7373 6c20 3d20 ort const ssl = │ │ │ +0003eab0: 6966 6163 652e 7373 6c20 3f20 7472 616e iface.ssl ? tran │ │ │ +0003eac0: 7370 6f72 743a 3a73 736c 203a 2074 7261 sport::ssl : tra │ │ │ +0003ead0: 6e73 706f 7274 3a3a 706c 6169 6e74 6578 nsport::plaintex │ │ │ +0003eae0: 743b 0a0a 0909 2f2f 2046 6972 7374 2c20 t;....// First, │ │ │ +0003eaf0: 6368 6563 6b20 746f 2073 6565 2069 6620 check to see if │ │ │ +0003eb00: 6974 2773 2061 6e20 4950 2061 6464 7265 it's an IP addre │ │ │ +0003eb10: 7373 0a09 0965 7272 6f72 5f63 6f64 6520 ss...error_code │ │ │ +0003eb20: 6572 723b 0a09 0961 6464 7265 7373 2063 err;...address c │ │ │ +0003eb30: 6f6e 7374 2061 6472 203d 206d 616b 655f onst adr = make_ │ │ │ +0003eb40: 6164 6472 6573 7328 6966 6163 652e 6465 address(iface.de │ │ │ +0003eb50: 7669 6365 2e63 5f73 7472 2829 2c20 6572 vice.c_str(), er │ │ │ +0003eb60: 7229 3b0a 0909 6966 2028 2165 7272 290a r);...if (!err). │ │ │ +0003eb70: 0909 7b0a 0909 0965 7073 2e65 6d70 6c61 ..{....eps.empla │ │ │ +0003eb80: 6365 5f62 6163 6b28 6164 722c 2069 6661 ce_back(adr, ifa │ │ │ +0003eb90: 6365 2e70 6f72 742c 2073 7464 3a3a 7374 ce.port, std::st │ │ │ +0003eba0: 7269 6e67 7b7d 2c20 7373 6c2c 2066 6c61 ring{}, ssl, fla │ │ │ +0003ebb0: 6773 293b 0a09 097d 0a09 0965 6c73 650a gs);...}...else. │ │ │ +0003ebc0: 0909 7b0a 0909 0966 6c61 6773 207c 3d20 ..{....flags |= │ │ │ +0003ebd0: 6c69 7374 656e 5f73 6f63 6b65 745f 743a listen_socket_t: │ │ │ +0003ebe0: 3a77 6173 5f65 7870 616e 6465 643b 0a0a :was_expanded;.. │ │ │ +0003ebf0: 0909 092f 2f20 7468 6973 2069 7320 7468 ...// this is th │ │ │ +0003ec00: 6520 6361 7365 2077 6865 7265 2064 6576 e case where dev │ │ │ +0003ec10: 6963 6520 6e61 6d65 7320 6120 6e65 7477 ice names a netw │ │ │ +0003ec20: 6f72 6b20 6465 7669 6365 2e20 5765 206e ork device. We n │ │ │ +0003ec30: 6565 6420 746f 0a09 0909 2f2f 2065 6e75 eed to....// enu │ │ │ +0003ec40: 6d65 7261 7465 2061 6c6c 2049 5073 2061 merate all IPs a │ │ │ +0003ec50: 7373 6f63 6961 7465 6420 7769 7468 2074 ssociated with t │ │ │ +0003ec60: 6869 7320 6465 7669 6365 0a09 0909 666f his device....fo │ │ │ +0003ec70: 7220 2861 7574 6f20 636f 6e73 7426 616d r (auto const&am │ │ │ +0003ec80: 703b 2069 7066 6163 6520 3a20 6966 7329 p; ipface : ifs) │ │ │ +0003ec90: 0a09 0909 7b0a 0909 0909 2f2f 2077 6527 ....{.....// we' │ │ │ +0003eca0: 7265 206c 6f6f 6b69 6e67 2066 6f72 2061 re looking for a │ │ │ +0003ecb0: 2073 7065 6369 6669 6320 696e 7465 7266 specific interf │ │ │ +0003ecc0: 6163 652c 2061 6e64 2069 7473 2061 6464 ace, and its add │ │ │ +0003ecd0: 7265 7373 0a09 0909 092f 2f20 2877 6869 ress.....// (whi │ │ │ +0003ece0: 6368 206d 7573 7420 6265 206f 6620 7468 ch must be of th │ │ │ +0003ecf0: 6520 7361 6d65 2066 616d 696c 7920 6173 e same family as │ │ │ +0003ed00: 2074 6865 2061 6464 7265 7373 2077 6527 the address we' │ │ │ +0003ed10: 7265 0a09 0909 092f 2f20 636f 6e6e 6563 re.....// connec │ │ │ +0003ed20: 7469 6e67 2074 6f29 0a09 0909 0969 6620 ting to).....if │ │ │ +0003ed30: 2869 6661 6365 2e64 6576 6963 6520 213d (iface.device != │ │ │ +0003ed40: 2069 7066 6163 652e 6e61 6d65 2920 636f ipface.name) co │ │ │ +0003ed50: 6e74 696e 7565 3b0a 0a09 0909 0962 6f6f ntinue;......boo │ │ │ +0003ed60: 6c20 636f 6e73 7420 6c6f 6361 6c20 3d20 l const local = │ │ │ +0003ed70: 6966 6163 652e 6c6f 6361 6c0a 0909 0909 iface.local..... │ │ │ +0003ed80: 097c 7c20 6970 6661 6365 2e69 6e74 6572 .|| ipface.inter │ │ │ +0003ed90: 6661 6365 5f61 6464 7265 7373 2e69 735f face_address.is_ │ │ │ +0003eda0: 6c6f 6f70 6261 636b 2829 0a09 0909 0909 loopback()...... │ │ │ +0003edb0: 7c7c 2069 735f 6c69 6e6b 5f6c 6f63 616c || is_link_local │ │ │ +0003edc0: 2869 7066 6163 652e 696e 7465 7266 6163 (ipface.interfac │ │ │ +0003edd0: 655f 6164 6472 6573 7329 3b0a 3c2f 7072 e_address);.
    rel │ │ │ +0003ee10: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0
    ../src/se │ │ │ +0003ee50: 7373 696f 6e5f 696d 706c 2e63 7070 3a32 ssion_impl.cpp:2 │ │ │ +0003ee60: 3335 373c 2f61 3e3c 2f74 643e 3c74 643e 357 │ │ │ +0003ee70: 6974 2077 6f75 6c64 2070 726f 6261 626c it would probabl │ │ │ +0003ee80: 7920 6265 2062 6574 7465 7220 746f 2064 y be better to d │ │ │ +0003ee90: 6f20 7468 6973 2062 7920 6861 7669 6e67 o this by having │ │ │ +0003eea0: 2061 206c 6973 7465 6e2d 736f 636b 6574 a listen-socket │ │ │ +0003eeb0: 2022 7665 7273 696f 6e22 206e 756d 6265 "version" numbe │ │ │ +0003eec0: 7220 7468 6174 2067 6574 7320 6275 6d70 r that gets bump │ │ │ +0003eed0: 6564 2e20 416e 6420 696e 7374 6561 6420 ed. And instead │ │ │ +0003eee0: 6f66 2073 6574 7469 6e67 2061 2062 6f6f of setting a boo │ │ │ +0003eef0: 6c20 746f 2064 6973 6162 6c65 2061 2074 l to disable a t │ │ │ +0003ef00: 7261 636b 6572 2c20 7765 2073 6574 2074 racker, we set t │ │ │ +0003ef10: 6865 2076 6572 7369 6f6e 206e 756d 6265 he version numbe │ │ │ +0003ef20: 7220 7468 6174 2069 7420 7761 7320 6469 r that it was di │ │ │ +0003ef30: 7361 626c 6564 2061 742e 2054 6869 7320 sabled at. This │ │ │ +0003ef40: 6368 616e 6765 2077 6f75 6c64 2061 6666 change would aff │ │ │ +0003ef50: 6563 7420 7468 6520 4142 4920 696e 2031 ect the ABI in 1 │ │ │ +0003ef60: 2e32 2c20 736f 2073 686f 756c 6420 6265 .2, so should be │ │ │ +0003ef70: 2064 6f6e 6520 696e 2032 2e30 206f 7220 done in 2.0 or │ │ │ +0003ef80: 6c61 7465 723c 2f74 643e 3c2f 7472 3e3c later< │ │ │ +0003ef90: 7472 2069 643d 2231 3536 2220 7374 796c tr id="156" styl │ │ │ +0003efa0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +0003efb0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +0003efc0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +0003efd0: 6832 3e69 7420 776f 756c 6420 7072 6f62 h2>it would prob │ │ │ +0003efe0: 6162 6c79 2062 6520 6265 7474 6572 2074 ably be better t │ │ │ +0003eff0: 6f20 646f 2074 6869 7320 6279 2068 6176 o do this by hav │ │ │ +0003f000: 696e 6720 610a 6c69 7374 656e 2d73 6f63 ing a.listen-soc │ │ │ +0003f010: 6b65 7420 2276 6572 7369 6f6e 2220 6e75 ket "version" nu │ │ │ +0003f020: 6d62 6572 2074 6861 7420 6765 7473 2062 mber that gets b │ │ │ +0003f030: 756d 7065 642e 2041 6e64 2069 6e73 7465 umped. And inste │ │ │ +0003f040: 6164 206f 660a 7365 7474 696e 6720 6120 ad of.setting a │ │ │ +0003f050: 626f 6f6c 2074 6f20 6469 7361 626c 6520 bool to disable │ │ │ +0003f060: 6120 7472 6163 6b65 722c 2077 6520 7365 a tracker, we se │ │ │ +0003f070: 7420 7468 6520 7665 7273 696f 6e20 6e75 t the version nu │ │ │ +0003f080: 6d62 6572 2074 6861 740a 6974 2077 6173 mber that.it was │ │ │ +0003f090: 2064 6973 6162 6c65 6420 6174 2e20 5468 disabled at. Th │ │ │ +0003f0a0: 6973 2063 6861 6e67 6520 776f 756c 6420 is change would │ │ │ +0003f0b0: 6166 6665 6374 2074 6865 2041 4249 2069 affect the ABI i │ │ │ +0003f0c0: 6e20 312e 322c 2073 6f0a 7368 6f75 6c64 n 1.2, so.should │ │ │ +0003f0d0: 2062 6520 646f 6e65 2069 6e20 322e 3020 be done in 2.0 │ │ │ +0003f0e0: 6f72 206c 6174 6572 3c2f 6832 3e3c 6834 or later

    ../src/session_ │ │ │ +0003f100: 696d 706c 2e63 7070 3a32 3335 373c 2f68 impl.cpp:2357
    ..{.
    │ │ │ +0003f150: 0909 0966 6f72 2028 6175 746f 2063 6f6e  ...for (auto con
    │ │ │ +0003f160: 7374 2661 6d70 3b20 7320 3a20 6d5f 6c69  st& s : m_li
    │ │ │ +0003f170: 7374 656e 5f73 6f63 6b65 7473 290a 0909  sten_sockets)...
    │ │ │ +0003f180: 0909 7265 6d61 705f 706f 7274 7328 7265  ..remap_ports(re
    │ │ │ +0003f190: 6d61 705f 6e61 7470 6d70 5f61 6e64 5f75  map_natpmp_and_u
    │ │ │ +0003f1a0: 706e 702c 202a 7329 3b0a 0909 7d0a 0909  pnp, *s);...}...
    │ │ │ +0003f1b0: 656c 7365 0a09 097b 0a09 0909 2f2f 206e  else...{....// n
    │ │ │ +0003f1c0: 6577 2073 6f63 6b65 7473 206e 6565 6420  ew sockets need 
    │ │ │ +0003f1d0: 746f 206d 6170 2070 6f72 7473 2065 7665  to map ports eve
    │ │ │ +0003f1e0: 6e20 6966 2074 6865 2063 616c 6c65 7220  n if the caller 
    │ │ │ +0003f1f0: 6469 6420 6e6f 7420 7265 7175 6573 740a  did not request.
    │ │ │ +0003f200: 0909 092f 2f20 7265 2d6d 6170 7069 6e67  ...// re-mapping
    │ │ │ +0003f210: 0a09 0909 666f 7220 2861 7574 6f20 636f  ....for (auto co
    │ │ │ +0003f220: 6e73 7426 616d 703b 2073 203a 206e 6577  nst& s : new
    │ │ │ +0003f230: 5f73 6f63 6b65 7473 290a 0909 0909 7265  _sockets).....re
    │ │ │ +0003f240: 6d61 705f 706f 7274 7328 7265 6d61 705f  map_ports(remap_
    │ │ │ +0003f250: 6e61 7470 6d70 5f61 6e64 5f75 706e 702c  natpmp_and_upnp,
    │ │ │ +0003f260: 202a 7329 3b0a 0909 7d0a 0a09 0975 7064   *s);...}....upd
    │ │ │ +0003f270: 6174 655f 6c73 6428 293b 0a0a 2369 6620  ate_lsd();..#if 
    │ │ │ +0003f280: 544f 5252 454e 545f 5553 455f 4932 500a  TORRENT_USE_I2P.
    │ │ │ +0003f290: 0909 6f70 656e 5f6e 6577 5f69 6e63 6f6d  ..open_new_incom
    │ │ │ +0003f2a0: 696e 675f 6932 705f 636f 6e6e 6563 7469  ing_i2p_connecti
    │ │ │ +0003f2b0: 6f6e 2829 3b0a 2365 6e64 6966 0a0a 0909  on();.#endif....
    │ │ │ +0003f2c0: 2f2f 2074 7261 636b 6572 7320 7468 6174  // trackers that
    │ │ │ +0003f2d0: 2077 6572 6520 6e6f 7420 7265 6163 6861   were not reacha
    │ │ │ +0003f2e0: 626c 652c 206d 6179 2068 6176 6520 6265  ble, may have be
    │ │ │ +0003f2f0: 636f 6d65 2072 6561 6368 6162 6c65 206e  come reachable n
    │ │ │ +0003f300: 6f77 2e0a 0909 2f2f 2073 6f20 636c 6561  ow....// so clea
    │ │ │ +0003f310: 7220 7468 6520 2264 6973 6162 6c65 6422  r the "disabled"
    │ │ │ +0003f320: 2066 6c61 6773 2074 6f20 6c65 7420 7468   flags to let th
    │ │ │ +0003f330: 656d 2062 6520 7472 6965 6420 6f6e 6520  em be tried one 
    │ │ │ +0003f340: 6d6f 7265 2074 696d 650a 3c64 6976 2073  more time.
    ..for (a │ │ │ +0003f380: 7574 6f26 616d 703b 2074 203a 206d 5f74 uto& t : m_t │ │ │ +0003f390: 6f72 7265 6e74 7329 0a3c 2f64 6976 3e09 orrents).
    . │ │ │ +0003f3a0: 0909 742d 2667 743b 656e 6162 6c65 5f61 ..t->enable_a │ │ │ +0003f3b0: 6c6c 5f74 7261 636b 6572 7328 293b 0a09 ll_trackers();.. │ │ │ +0003f3c0: 7d0a 0a09 766f 6964 2073 6573 7369 6f6e }...void session │ │ │ +0003f3d0: 5f69 6d70 6c3a 3a72 656f 7065 6e5f 6e65 _impl::reopen_ne │ │ │ +0003f3e0: 7477 6f72 6b5f 736f 636b 6574 7328 7265 twork_sockets(re │ │ │ +0003f3f0: 6f70 656e 5f6e 6574 776f 726b 5f66 6c61 open_network_fla │ │ │ +0003f400: 6773 5f74 2063 6f6e 7374 206f 7074 696f gs_t const optio │ │ │ +0003f410: 6e73 290a 097b 0a09 0972 656f 7065 6e5f ns)..{...reopen_ │ │ │ +0003f420: 6c69 7374 656e 5f73 6f63 6b65 7473 2862 listen_sockets(b │ │ │ +0003f430: 6f6f 6c28 6f70 7469 6f6e 7320 2661 6d70 ool(options & │ │ │ +0003f440: 3b20 7365 7373 696f 6e5f 6861 6e64 6c65 ; session_handle │ │ │ +0003f450: 3a3a 7265 6f70 656e 5f6d 6170 5f70 6f72 ::reopen_map_por │ │ │ +0003f460: 7473 2929 3b0a 097d 0a0a 096e 616d 6573 ts));..}...names │ │ │ +0003f470: 7061 6365 207b 0a09 0974 656d 706c 6174 pace {...templat │ │ │ +0003f480: 6520 266c 743b 7479 7065 6e61 6d65 204d e <typename M │ │ │ +0003f490: 6170 5072 6f74 6f63 6f6c 2c20 7479 7065 apProtocol, type │ │ │ +0003f4a0: 6e61 6d65 2050 726f 746f 5479 7065 2c20 name ProtoType, │ │ │ +0003f4b0: 7479 7065 6e61 6d65 2045 6e64 706f 696e typename Endpoin │ │ │ +0003f4c0: 7454 7970 6526 6774 3b0a 0909 766f 6964 tType>...void │ │ │ +0003f4d0: 206d 6170 5f70 6f72 7428 4d61 7050 726f map_port(MapPro │ │ │ +0003f4e0: 746f 636f 6c26 616d 703b 206d 2c20 5072 tocol& m, Pr │ │ │ +0003f4f0: 6f74 6f54 7970 6520 7072 6f74 6f63 6f6c otoType protocol │ │ │ +0003f500: 2c20 456e 6470 6f69 6e74 5479 7065 2063 , EndpointType c │ │ │ +0003f510: 6f6e 7374 2661 6d70 3b20 6570 0a09 0909 onst& ep.... │ │ │ +0003f520: 2c20 706f 7274 5f6d 6170 7069 6e67 5f74 , port_mapping_t │ │ │ +0003f530: 2661 6d70 3b20 6d61 705f 6861 6e64 6c65 & map_handle │ │ │ +0003f540: 2c20 7374 643a 3a73 7472 696e 6720 636f , std::string co │ │ │ +0003f550: 6e73 7426 616d 703b 2064 6576 6963 6529 nst& device) │ │ │ +0003f560: 0a09 097b 0a09 0909 6966 2028 6d61 705f ...{....if (map_ │ │ │ +0003f570: 6861 6e64 6c65 2021 3d20 706f 7274 5f6d handle != port_m │ │ │ +0003f580: 6170 7069 6e67 5f74 7b2d 317d 2920 6d2e apping_t{-1}) m. │ │ │ +0003f590: 6465 6c65 7465 5f6d 6170 7069 6e67 286d delete_mapping(m │ │ │ +0003f5a0: 6170 5f68 616e 646c 6529 3b0a 0909 096d ap_handle);....m │ │ │ +0003f5b0: 6170 5f68 616e 646c 6520 3d20 706f 7274 ap_handle = port │ │ │ +0003f5c0: 5f6d 6170 7069 6e67 5f74 7b2d 317d 3b0a _mapping_t{-1};. │ │ │ +0003f5d0: 0a09 0909 6164 6472 6573 7320 636f 6e73 ....address cons │ │ │ +0003f5e0: 7420 6164 6472 203d 2065 702e 6164 6472 t addr = ep.addr │ │ │ +0003f5f0: 6573 7328 293b 0a09 0909 2f2f 2077 6974 ess();....// wit │ │ │ +0003f600: 6820 4950 7634 2074 6865 2069 6e74 6572 h IPv4 the inter │ │ │ +0003f610: 6661 6365 206d 6967 6874 2062 6520 6265 face might be be │ │ │ +0003f620: 6869 6e64 204e 4154 2073 6f20 7765 2063 hind NAT so we c │ │ │ +0003f630: 616e 2774 2073 6b69 7020 7468 656d 0a09 an't skip them.. │ │ │ +0003f640: 0909 2f2f 2062 6173 6564 206f 6e20 7468 ..// based on th │ │ │ +0003f650: 6520 7363 6f70 6520 6f66 2074 6865 206c e scope of the l │ │ │ +0003f660: 6f63 616c 2061 6464 7265 7373 0a09 0909 ocal address.... │ │ │ +0003f670: 6966 2028 6164 6472 2e69 735f 7636 2829 if (addr.is_v6() │ │ │ +0003f680: 2026 616d 703b 2661 6d70 3b20 6973 5f6c && is_l │ │ │ +0003f690: 6f63 616c 2861 6464 7229 290a 0909 0909 ocal(addr))..... │ │ │ +0003f6a0: 7265 7475 726e 3b0a 0a09 0909 2f2f 206f return;.....// o │ │ │ +0003f6b0: 6e6c 7920 7570 6461 7465 2074 6869 7320 nly update this │ │ │ +0003f6c0: 6d61 7070 696e 6720 6966 2077 6520 6163 mapping if we ac │ │ │ +0003f6d0: 7475 616c 6c79 2068 6176 6520 6120 736f tually have a so │ │ │ +0003f6e0: 636b 6574 206c 6973 7465 6e69 6e67 0a09 cket listening.. │ │ │ +0003f6f0: 0909 6966 2028 6570 2021 3d20 456e 6470 ..if (ep != Endp │ │ │ +0003f700: 6f69 6e74 5479 7065 2829 290a 0909 0909 ointType())..... │ │ │ +0003f710: 6d61 705f 6861 6e64 6c65 203d 206d 2e61 map_handle = m.a │ │ │ +0003f720: 6464 5f6d 6170 7069 6e67 2870 726f 746f dd_mapping(proto │ │ │ +0003f730: 636f 6c2c 2065 702e 706f 7274 2829 2c20 col, ep.port(), │ │ │ +0003f740: 6570 2c20 6465 7669 6365 293b 0a09 097d ep, device);...} │ │ │ +0003f750: 0a09 7d0a 0a09 766f 6964 2073 6573 7369 ..}...void sessi │ │ │ +0003f760: 6f6e 5f69 6d70 6c3a 3a72 656d 6170 5f70 on_impl::remap_p │ │ │ +0003f770: 6f72 7473 2872 656d 6170 5f70 6f72 745f orts(remap_port_ │ │ │ +0003f780: 6d61 736b 5f74 2063 6f6e 7374 206d 6173 mask_t const mas │ │ │ +0003f790: 6b0a 0909 2c20 6c69 7374 656e 5f73 6f63 k..., listen_soc │ │ │ +0003f7a0: 6b65 745f 7426 616d 703b 2073 290a 3c2f ket_t& s).r │ │ │ +0003f7e0: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +0003f7f0: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +0003f820: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ +0003f830: 3a32 3939 363c 2f61 3e3c 2f74 643e 3c74 :2996this size need │ │ │ +0003f850: 2074 6f20 6265 2063 6170 7065 643c 2f74 to be capped

    this │ │ │ +0003f8b0: 7369 7a65 206e 6565 6420 746f 2062 6520 size need to be │ │ │ +0003f8c0: 6361 7070 6564 3c2f 6832 3e3c 6834 3e2e capped

    . │ │ │ +0003f8d0: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ +0003f8e0: 706c 2e63 7070 3a32 3939 363c 2f68 343e pl.cpp:2996

    │ │ │ +0003f8f0: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ....//
    │ │ │ +0003f930: 2068 616e 6473 6861 6b69 6e67 0a09 0909   handshaking....
    │ │ │ +0003f940: 0972 6574 7572 6e20 736f 636b 6574 5f74  .return socket_t
    │ │ │ +0003f950: 7970 6528 7373 6c5f 7374 7265 616d 266c  ype(ssl_stream&l
    │ │ │ +0003f960: 743b 7463 703a 3a73 6f63 6b65 7426 6774  t;tcp::socket>
    │ │ │ +0003f970: 3b28 7463 703a 3a73 6f63 6b65 7428 7374  ;(tcp::socket(st
    │ │ │ +0003f980: 643a 3a6d 6f76 6528 7329 292c 206d 5f70  d::move(s)), m_p
    │ │ │ +0003f990: 6565 725f 7373 6c5f 6374 7829 293b 0a09  eer_ssl_ctx));..
    │ │ │ +0003f9a0: 0909 7d0a 0909 0965 6c73 650a 2365 6e64  ..}....else.#end
    │ │ │ +0003f9b0: 6966 0a09 0909 7b0a 0909 0909 7265 7475  if....{.....retu
    │ │ │ +0003f9c0: 726e 2073 6f63 6b65 745f 7479 7065 2874  rn socket_type(t
    │ │ │ +0003f9d0: 6370 3a3a 736f 636b 6574 2873 7464 3a3a  cp::socket(std::
    │ │ │ +0003f9e0: 6d6f 7665 2873 2929 293b 0a09 0909 7d0a  move(s)));....}.
    │ │ │ +0003f9f0: 0909 7d28 293b 0a0a 2369 6664 6566 2054  ..}();..#ifdef T
    │ │ │ +0003fa00: 4f52 5245 4e54 5f53 534c 5f50 4545 5253  ORRENT_SSL_PEERS
    │ │ │ +0003fa10: 0a09 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ +0003fa20: 5428 2873 736c 203d 3d20 7472 616e 7370  T((ssl == transp
    │ │ │ +0003fa30: 6f72 743a 3a73 736c 2920 3d3d 2069 735f  ort::ssl) == is_
    │ │ │ +0003fa40: 7373 6c28 6329 293b 0a23 656e 6469 660a  ssl(c));.#endif.
    │ │ │ +0003fa50: 0a23 6966 6465 6620 544f 5252 454e 545f  .#ifdef TORRENT_
    │ │ │ +0003fa60: 5353 4c5f 5045 4552 530a 0909 6966 2028  SSL_PEERS...if (
    │ │ │ +0003fa70: 7373 6c20 3d3d 2074 7261 6e73 706f 7274  ssl == transport
    │ │ │ +0003fa80: 3a3a 7373 6c29 0a09 097b 0a09 0909 544f  ::ssl)...{....TO
    │ │ │ +0003fa90: 5252 454e 545f 4153 5345 5254 2869 735f  RRENT_ASSERT(is_
    │ │ │ +0003faa0: 7373 6c28 6329 293b 0a0a 0909 092f 2f20  ssl(c));.....// 
    │ │ │ +0003fab0: 7361 7665 2074 6865 2073 6f63 6b65 7420  save the socket 
    │ │ │ +0003fac0: 736f 2077 6520 6361 6e20 6361 6e63 656c  so we can cancel
    │ │ │ +0003fad0: 2074 6865 2068 616e 6473 6861 6b65 0a3c   the handshake.<
    │ │ │ +0003fae0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +0003faf0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +0003fb00: 7769 6474 683d 2231 3030 2522 3e09 0909  width="100%">...
    │ │ │ +0003fb10: 6175 746f 2069 7465 7220 3d20 6d5f 696e  auto iter = m_in
    │ │ │ +0003fb20: 636f 6d69 6e67 5f73 6f63 6b65 7473 2e65  coming_sockets.e
    │ │ │ +0003fb30: 6d70 6c61 6365 2873 7464 3a3a 6d61 6b65  mplace(std::make
    │ │ │ +0003fb40: 5f75 6e69 7175 6526 6c74 3b73 6f63 6b65  _unique<socke
    │ │ │ +0003fb50: 745f 7479 7065 2667 743b 2873 7464 3a3a  t_type>(std::
    │ │ │ +0003fb60: 6d6f 7665 2863 2929 292e 6669 7273 743b  move(c))).first;
    │ │ │ +0003fb70: 0a3c 2f64 6976 3e0a 0909 0961 7574 6f20  .....auto 
    │ │ │ +0003fb80: 736f 636b 203d 2069 7465 722d 2667 743b  sock = iter->
    │ │ │ +0003fb90: 6765 7428 293b 0a09 0909 2f2f 2066 6f72  get();....// for
    │ │ │ +0003fba0: 2053 534c 2063 6f6e 6e65 6374 696f 6e73   SSL connections
    │ │ │ +0003fbb0: 2c20 696e 636f 6d69 6e67 5f63 6f6e 6e65  , incoming_conne
    │ │ │ +0003fbc0: 6374 696f 6e28 2920 6973 2063 616c 6c65  ction() is calle
    │ │ │ +0003fbd0: 640a 0909 092f 2f20 6166 7465 7220 7468  d....// after th
    │ │ │ +0003fbe0: 6520 6861 6e64 7368 616b 6520 6973 2064  e handshake is d
    │ │ │ +0003fbf0: 6f6e 650a 0909 0941 4444 5f4f 5554 5354  one....ADD_OUTST
    │ │ │ +0003fc00: 414e 4449 4e47 5f41 5359 4e43 2822 7365  ANDING_ASYNC("se
    │ │ │ +0003fc10: 7373 696f 6e5f 696d 706c 3a3a 7373 6c5f  ssion_impl::ssl_
    │ │ │ +0003fc20: 6861 6e64 7368 616b 6522 293b 0a09 0909  handshake");....
    │ │ │ +0003fc30: 7374 643a 3a67 6574 266c 743b 7373 6c5f  std::get<ssl_
    │ │ │ +0003fc40: 7374 7265 616d 266c 743b 7463 703a 3a73  stream<tcp::s
    │ │ │ +0003fc50: 6f63 6b65 7426 6774 3b26 6774 3b28 2a2a  ocket>>(**
    │ │ │ +0003fc60: 6974 6572 292e 6173 796e 635f 6163 6365  iter).async_acce
    │ │ │ +0003fc70: 7074 5f68 616e 6473 6861 6b65 280a 0909  pt_handshake(...
    │ │ │ +0003fc80: 0909 5b74 6869 732c 2073 6f63 6b5d 2028  ..[this, sock] (
    │ │ │ +0003fc90: 6572 726f 725f 636f 6465 2063 6f6e 7374  error_code const
    │ │ │ +0003fca0: 2661 6d70 3b20 6572 7229 207b 2073 736c  & err) { ssl
    │ │ │ +0003fcb0: 5f68 616e 6473 6861 6b65 2865 7272 2c20  _handshake(err, 
    │ │ │ +0003fcc0: 736f 636b 293b 207d 293b 0a09 097d 0a09  sock); });...}..
    │ │ │ +0003fcd0: 0965 6c73 650a 2365 6e64 6966 0a09 097b  .else.#endif...{
    │ │ │ +0003fce0: 0a09 0909 696e 636f 6d69 6e67 5f63 6f6e  ....incoming_con
    │ │ │ +0003fcf0: 6e65 6374 696f 6e28 7374 643a 3a6d 6f76  nection(std::mov
    │ │ │ +0003fd00: 6528 6329 293b 0a09 097d 0a09 7d0a 0a23  e(c));...}..}..#
    │ │ │ +0003fd10: 6966 6465 6620 544f 5252 454e 545f 5353  ifdef TORRENT_SS
    │ │ │ +0003fd20: 4c5f 5045 4552 530a 0a09 766f 6964 2073  L_PEERS...void s
    │ │ │ +0003fd30: 6573 7369 6f6e 5f69 6d70 6c3a 3a6f 6e5f  ession_impl::on_
    │ │ │ +0003fd40: 696e 636f 6d69 6e67 5f75 7470 5f73 736c  incoming_utp_ssl
    │ │ │ +0003fd50: 2873 6f63 6b65 745f 7479 7065 2073 290a  (socket_type s).
    │ │ │ +0003fd60: 097b 0a09 0954 4f52 5245 4e54 5f41 5353  .{...TORRENT_ASS
    │ │ │ +0003fd70: 4552 5428 6973 5f73 736c 2873 2929 3b0a  ERT(is_ssl(s));.
    │ │ │ +0003fd80: 0a09 092f 2f20 7361 7665 2074 6865 2073  ...// save the s
    │ │ │ +0003fd90: 6f63 6b65 7420 736f 2077 6520 6361 6e20  ocket so we can 
    │ │ │ +0003fda0: 6361 6e63 656c 2074 6865 2068 616e 6473  cancel the hands
    │ │ │ +0003fdb0: 6861 6b65 0a0a 3c2f 7072 653e 3c2f 7464  hake..
    relevance │ │ │ +0003fdf0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +0003fe00: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/session_ │ │ │ +0003fe30: 696d 706c 2e63 7070 3a33 3032 313c 2f61 impl.cpp:3021this s │ │ │ +0003fe50: 697a 6520 6e65 6564 2074 6f20 6265 2063 ize need to be c │ │ │ +0003fe60: 6170 7065 643c 2f74 643e 3c2f 7472 3e3c apped< │ │ │ +0003fe70: 7472 2069 643d 2231 3538 2220 7374 796c tr id="158" styl │ │ │ +0003fe80: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +0003fe90: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +0003fea0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +0003feb0: 6832 3e74 6869 7320 7369 7a65 206e 6565 h2>this size nee │ │ │ +0003fec0: 6420 746f 2062 6520 6361 7070 6564 3c2f d to be capped

    ../src/se │ │ │ +0003fee0: 7373 696f 6e5f 696d 706c 2e63 7070 3a33 ssion_impl.cpp:3 │ │ │ +0003fef0: 3032 313c 2f68 343e 3c70 7265 2073 7479 021

    ...// after th
    │ │ │ +0003ff40: 6520 6861 6e64 7368 616b 6520 6973 2064  e handshake is d
    │ │ │ +0003ff50: 6f6e 650a 0909 0941 4444 5f4f 5554 5354  one....ADD_OUTST
    │ │ │ +0003ff60: 414e 4449 4e47 5f41 5359 4e43 2822 7365  ANDING_ASYNC("se
    │ │ │ +0003ff70: 7373 696f 6e5f 696d 706c 3a3a 7373 6c5f  ssion_impl::ssl_
    │ │ │ +0003ff80: 6861 6e64 7368 616b 6522 293b 0a09 0909  handshake");....
    │ │ │ +0003ff90: 7374 643a 3a67 6574 266c 743b 7373 6c5f  std::get<ssl_
    │ │ │ +0003ffa0: 7374 7265 616d 266c 743b 7463 703a 3a73  stream<tcp::s
    │ │ │ +0003ffb0: 6f63 6b65 7426 6774 3b26 6774 3b28 2a2a  ocket>>(**
    │ │ │ +0003ffc0: 6974 6572 292e 6173 796e 635f 6163 6365  iter).async_acce
    │ │ │ +0003ffd0: 7074 5f68 616e 6473 6861 6b65 280a 0909  pt_handshake(...
    │ │ │ +0003ffe0: 0909 5b74 6869 732c 2073 6f63 6b5d 2028  ..[this, sock] (
    │ │ │ +0003fff0: 6572 726f 725f 636f 6465 2063 6f6e 7374  error_code const
    │ │ │ +00040000: 2661 6d70 3b20 6572 7229 207b 2073 736c  & err) { ssl
    │ │ │ +00040010: 5f68 616e 6473 6861 6b65 2865 7272 2c20  _handshake(err, 
    │ │ │ +00040020: 736f 636b 293b 207d 293b 0a09 097d 0a09  sock); });...}..
    │ │ │ +00040030: 0965 6c73 650a 2365 6e64 6966 0a09 097b  .else.#endif...{
    │ │ │ +00040040: 0a09 0909 696e 636f 6d69 6e67 5f63 6f6e  ....incoming_con
    │ │ │ +00040050: 6e65 6374 696f 6e28 7374 643a 3a6d 6f76  nection(std::mov
    │ │ │ +00040060: 6528 6329 293b 0a09 097d 0a09 7d0a 0a23  e(c));...}..}..#
    │ │ │ +00040070: 6966 6465 6620 544f 5252 454e 545f 5353  ifdef TORRENT_SS
    │ │ │ +00040080: 4c5f 5045 4552 530a 0a09 766f 6964 2073  L_PEERS...void s
    │ │ │ +00040090: 6573 7369 6f6e 5f69 6d70 6c3a 3a6f 6e5f  ession_impl::on_
    │ │ │ +000400a0: 696e 636f 6d69 6e67 5f75 7470 5f73 736c  incoming_utp_ssl
    │ │ │ +000400b0: 2873 6f63 6b65 745f 7479 7065 2073 290a  (socket_type s).
    │ │ │ +000400c0: 097b 0a09 0954 4f52 5245 4e54 5f41 5353  .{...TORRENT_ASS
    │ │ │ +000400d0: 4552 5428 6973 5f73 736c 2873 2929 3b0a  ERT(is_ssl(s));.
    │ │ │ +000400e0: 0a09 092f 2f20 7361 7665 2074 6865 2073  ...// save the s
    │ │ │ +000400f0: 6f63 6b65 7420 736f 2077 6520 6361 6e20  ocket so we can 
    │ │ │ +00040100: 6361 6e63 656c 2074 6865 2068 616e 6473  cancel the hands
    │ │ │ +00040110: 6861 6b65 0a0a 3c64 6976 2073 7479 6c65  hake..
    ..auto iter │ │ │ +00040150: 3d20 6d5f 696e 636f 6d69 6e67 5f73 6f63 = m_incoming_soc │ │ │ +00040160: 6b65 7473 2e65 6d70 6c61 6365 2873 7464 kets.emplace(std │ │ │ +00040170: 3a3a 6d61 6b65 5f75 6e69 7175 6526 6c74 ::make_unique< │ │ │ +00040180: 3b73 6f63 6b65 745f 7479 7065 2667 743b ;socket_type> │ │ │ +00040190: 2873 7464 3a3a 6d6f 7665 2873 2929 292e (std::move(s))). │ │ │ +000401a0: 6669 7273 743b 0a3c 2f64 6976 3e09 0961 first;.
    ..a │ │ │ +000401b0: 7574 6f20 736f 636b 203d 2069 7465 722d uto sock = iter- │ │ │ +000401c0: 2667 743b 6765 7428 293b 0a0a 0909 2f2f >get();....// │ │ │ +000401d0: 2066 6f72 2053 534c 2063 6f6e 6e65 6374 for SSL connect │ │ │ +000401e0: 696f 6e73 2c20 696e 636f 6d69 6e67 5f63 ions, incoming_c │ │ │ +000401f0: 6f6e 6e65 6374 696f 6e28 2920 6973 2063 onnection() is c │ │ │ +00040200: 616c 6c65 640a 0909 2f2f 2061 6674 6572 alled...// after │ │ │ +00040210: 2074 6865 2068 616e 6473 6861 6b65 2069 the handshake i │ │ │ +00040220: 7320 646f 6e65 0a09 0941 4444 5f4f 5554 s done...ADD_OUT │ │ │ +00040230: 5354 414e 4449 4e47 5f41 5359 4e43 2822 STANDING_ASYNC(" │ │ │ +00040240: 7365 7373 696f 6e5f 696d 706c 3a3a 7373 session_impl::ss │ │ │ +00040250: 6c5f 6861 6e64 7368 616b 6522 293b 0a09 l_handshake");.. │ │ │ +00040260: 0973 7464 3a3a 6765 7426 6c74 3b73 736c .std::get<ssl │ │ │ +00040270: 5f73 7472 6561 6d26 6c74 3b75 7470 5f73 _stream<utp_s │ │ │ +00040280: 7472 6561 6d26 6774 3b26 6774 3b28 2a2a tream>>(** │ │ │ +00040290: 6974 6572 292e 6173 796e 635f 6163 6365 iter).async_acce │ │ │ +000402a0: 7074 5f68 616e 6473 6861 6b65 280a 0909 pt_handshake(... │ │ │ +000402b0: 095b 7468 6973 2c20 736f 636b 5d20 2865 .[this, sock] (e │ │ │ +000402c0: 7272 6f72 5f63 6f64 6520 636f 6e73 7426 rror_code const& │ │ │ +000402d0: 616d 703b 2065 7272 2920 7b20 7373 6c5f amp; err) { ssl_ │ │ │ +000402e0: 6861 6e64 7368 616b 6528 6572 722c 2073 handshake(err, s │ │ │ +000402f0: 6f63 6b29 3b20 7d29 3b0a 097d 0a0a 092f ock); });..}.../ │ │ │ +00040300: 2f20 746f 2074 6573 7420 5353 4c20 636f / to test SSL co │ │ │ +00040310: 6e6e 6563 7469 6f6e 732c 206f 6e65 2063 nnections, one c │ │ │ +00040320: 616e 2075 7365 2074 6869 7320 6f70 656e an use this open │ │ │ +00040330: 7373 6c20 636f 6d6d 616e 6420 7465 6d70 ssl command temp │ │ │ +00040340: 6c61 7465 3a0a 092f 2f0a 092f 2f20 6f70 late:..//..// op │ │ │ +00040350: 656e 7373 6c20 735f 636c 6965 6e74 202d enssl s_client - │ │ │ +00040360: 6365 7274 2026 6c74 3b63 6c69 656e 742d cert <client- │ │ │ +00040370: 6365 7274 2667 743b 2e70 656d 202d 6b65 cert>.pem -ke │ │ │ +00040380: 7920 266c 743b 636c 6965 6e74 2d70 7269 y <client-pri │ │ │ +00040390: 7661 7465 2d6b 6579 2667 743b 2e70 656d vate-key>.pem │ │ │ +000403a0: 0a09 2f2f 2020 202d 4341 6669 6c65 2026 ..// -CAfile & │ │ │ +000403b0: 6c74 3b74 6f72 7265 6e74 2d63 6572 7426 lt;torrent-cert& │ │ │ +000403c0: 6774 3b2e 7065 6d20 202d 6465 6275 6720 gt;.pem -debug │ │ │ +000403d0: 2d63 6f6e 6e65 6374 2031 3237 2e30 2e30 -connect 127.0.0 │ │ │ +000403e0: 2e31 3a34 3433 3320 2d74 6c73 310a 092f .1:4433 -tls1../ │ │ │ +000403f0: 2f20 2020 2d73 6572 7665 726e 616d 6520 / -servername │ │ │ +00040400: 266c 743b 6865 782d 656e 636f 6465 642d <hex-encoded- │ │ │ +00040410: 696e 666f 2d68 6173 6826 6774 3b0a 0a09 info-hash>... │ │ │ +00040420: 766f 6964 2073 6573 7369 6f6e 5f69 6d70 void session_imp │ │ │ +00040430: 6c3a 3a73 736c 5f68 616e 6473 6861 6b65 l::ssl_handshake │ │ │ +00040440: 2865 7272 6f72 5f63 6f64 6520 636f 6e73 (error_code cons │ │ │ +00040450: 7426 616d 703b 2065 632c 2073 6f63 6b65 t& ec, socke │ │ │ +00040460: 745f 7479 7065 2a20 736f 636b 290a 097b t_type* sock)..{ │ │ │ +00040470: 0a09 0943 4f4d 504c 4554 455f 4153 594e ...COMPLETE_ASYN │ │ │ +00040480: 4328 2273 6573 7369 6f6e 5f69 6d70 6c3a C("session_impl: │ │ │ +00040490: 3a73 736c 5f68 616e 6473 6861 6b65 2229 :ssl_handshake") │ │ │ +000404a0: 3b0a 0a09 0961 7574 6f20 6974 6572 203d ;....auto iter = │ │ │ +000404b0: 206d 5f69 6e63 6f6d 696e 675f 736f 636b m_incoming_sock │ │ │ +000404c0: 6574 732e 6669 6e64 2873 6f63 6b29 3b0a ets.find(sock);. │ │ │ +000404d0: 0a09 092f 2f20 7468 6973 2068 6170 7065 ...// this happe │ │ │ +000404e0: 6e73 2069 6620 7468 6520 5353 4c20 636f ns if the SSL co │ │ │ +000404f0: 6e6e 6563 7469 6f6e 2069 7320 6162 6f72 nnection is abor │ │ │ +00040500: 7465 6420 6265 6361 7573 6520 7765 2772 ted because we'r │ │ │ +00040510: 6520 7368 7574 7469 6e67 0a09 092f 2f20 e shutting...// │ │ │ +00040520: 646f 776e 0a09 0969 6620 2869 7465 7220 down...if (iter │ │ │ +00040530: 3d3d 206d 5f69 6e63 6f6d 696e 675f 736f == m_incoming_so │ │ │ +00040540: 636b 6574 732e 656e 6428 2929 2072 6574 ckets.end()) ret │ │ │ +00040550: 7572 6e3b 0a0a 0909 736f 636b 6574 5f74 urn;....socket_t │ │ │ +00040560: 7970 6520 7328 7374 643a 3a6d 6f76 6528 ype s(std::move( │ │ │ +00040570: 2a2a 6974 6572 2929 3b0a 0909 544f 5252 **iter));...TORR │ │ │ +00040580: 454e 545f 4153 5345 5254 2869 735f 7373 ENT_ASSERT(is_ss │ │ │ +00040590: 6c28 7329 293b 0a09 096d 5f69 6e63 6f6d l(s));...m_incom │ │ │ +000405a0: 696e 675f 736f 636b 6574 732e 6572 6173 ing_sockets.eras │ │ │ +000405b0: 6528 6974 6572 293b 0a0a 0909 6572 726f e(iter);....erro │ │ │ +000405c0: 725f 636f 6465 2065 3b0a 3c2f 7072 653e r_code e;.
    │ │ │ +000405d0: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +00040600: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +00040610: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/sess │ │ │ +00040640: 696f 6e5f 696d 706c 2e63 7070 3a33 3733 ion_impl.cpp:373 │ │ │ +00040650: 333c 2f61 3e3c 2f74 643e 3c74 643e 6861 3ha │ │ │ +00040660: 7665 2061 2073 6570 6172 6174 6520 6c69 ve a separate li │ │ │ +00040670: 7374 2066 6f72 2074 6865 7365 2063 6f6e st for these con │ │ │ +00040680: 6e65 6374 696f 6e73 2c20 696e 7374 6561 nections, instea │ │ │ +00040690: 6420 6f66 2068 6176 696e 6720 746f 206c d of having to l │ │ │ +000406a0: 6f6f 7020 7468 726f 7567 6820 616c 6c20 oop through all │ │ │ +000406b0: 6f66 2074 6865 6d3c 2f74 643e 3c2f 7472 of them

    have a sepa │ │ │ +00040710: 7261 7465 206c 6973 7420 666f 7220 7468 rate list for th │ │ │ +00040720: 6573 6520 636f 6e6e 6563 7469 6f6e 732c ese connections, │ │ │ +00040730: 2069 6e73 7465 6164 206f 6620 6861 7669 instead of havi │ │ │ +00040740: 6e67 2074 6f20 6c6f 6f70 2074 6872 6f75 ng to loop throu │ │ │ +00040750: 6768 2061 6c6c 206f 6620 7468 656d 3c2f gh all of them

    ../src/se │ │ │ +00040770: 7373 696f 6e5f 696d 706c 2e63 7070 3a33 ssion_impl.cpp:3 │ │ │ +00040780: 3733 333c 2f68 343e 3c70 7265 2073 7479 733

    ..// ---------
    │ │ │ +000407d0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +000407e0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +000407f0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00040800: 2d2d 2d2d 2d0a 0909 6966 2028 216d 5f70  -----...if (!m_p
    │ │ │ +00040810: 6175 7365 6429 206d 5f61 7574 6f5f 6d61  aused) m_auto_ma
    │ │ │ +00040820: 6e61 6765 5f74 696d 655f 7363 616c 6572  nage_time_scaler
    │ │ │ +00040830: 2d2d 3b0a 0909 6966 2028 6d5f 6175 746f  --;...if (m_auto
    │ │ │ +00040840: 5f6d 616e 6167 655f 7469 6d65 5f73 6361  _manage_time_sca
    │ │ │ +00040850: 6c65 7220 266c 743b 2030 290a 0909 7b0a  ler < 0)...{.
    │ │ │ +00040860: 0909 096d 5f61 7574 6f5f 6d61 6e61 6765  ...m_auto_manage
    │ │ │ +00040870: 5f74 696d 655f 7363 616c 6572 203d 2073  _time_scaler = s
    │ │ │ +00040880: 6574 7469 6e67 7328 292e 6765 745f 696e  ettings().get_in
    │ │ │ +00040890: 7428 7365 7474 696e 6773 5f70 6163 6b3a  t(settings_pack:
    │ │ │ +000408a0: 3a61 7574 6f5f 6d61 6e61 6765 5f69 6e74  :auto_manage_int
    │ │ │ +000408b0: 6572 7661 6c29 3b0a 0909 0972 6563 616c  erval);....recal
    │ │ │ +000408c0: 6375 6c61 7465 5f61 7574 6f5f 6d61 6e61  culate_auto_mana
    │ │ │ +000408d0: 6765 645f 746f 7272 656e 7473 2829 3b0a  ged_torrents();.
    │ │ │ +000408e0: 0909 7d0a 0a09 092f 2f20 2d2d 2d2d 2d2d  ..}....// ------
    │ │ │ +000408f0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00040900: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00040910: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00040920: 2d2d 2d2d 2d2d 2d2d 0a09 092f 2f20 6368  --------...// ch
    │ │ │ +00040930: 6563 6b20 666f 7220 696e 636f 6d69 6e67  eck for incoming
    │ │ │ +00040940: 2063 6f6e 6e65 6374 696f 6e73 2074 6861   connections tha
    │ │ │ +00040950: 7420 6d69 6768 7420 6861 7665 2074 696d  t might have tim
    │ │ │ +00040960: 6564 206f 7574 0a09 092f 2f20 2d2d 2d2d  ed out...// ----
    │ │ │ +00040970: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00040980: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +00040990: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  ----------------
    │ │ │ +000409a0: 2d2d 2d2d 2d2d 2d2d 2d2d 0a0a 0909 666f  ----------....fo
    │ │ │ +000409b0: 7220 2861 7574 6f20 6920 3d20 6d5f 636f  r (auto i = m_co
    │ │ │ +000409c0: 6e6e 6563 7469 6f6e 732e 6265 6769 6e28  nnections.begin(
    │ │ │ +000409d0: 293b 2069 2021 3d20 6d5f 636f 6e6e 6563  ); i != m_connec
    │ │ │ +000409e0: 7469 6f6e 732e 656e 6428 293b 290a 0909  tions.end();)...
    │ │ │ +000409f0: 7b0a 0909 0970 6565 725f 636f 6e6e 6563  {....peer_connec
    │ │ │ +00040a00: 7469 6f6e 2a20 7020 3d20 282a 6929 2e67  tion* p = (*i).g
    │ │ │ +00040a10: 6574 2829 3b0a 0909 092b 2b69 3b0a 0909  et();....++i;...
    │ │ │ +00040a20: 092f 2f20 6967 6e6f 7265 2063 6f6e 6e65  .// ignore conne
    │ │ │ +00040a30: 6374 696f 6e73 2074 6861 7420 616c 7265  ctions that alre
    │ │ │ +00040a40: 6164 7920 6861 7665 2061 2074 6f72 7265  ady have a torre
    │ │ │ +00040a50: 6e74 2c20 7369 6e63 6520 7468 6579 0a09  nt, since they..
    │ │ │ +00040a60: 0909 2f2f 2061 7265 2074 6963 6b65 6420  ..// are ticked 
    │ │ │ +00040a70: 7468 726f 7567 6820 7468 6520 746f 7272  through the torr
    │ │ │ +00040a80: 656e 7473 2720 7365 636f 6e64 5f74 6963  ents' second_tic
    │ │ │ +00040a90: 6b0a 0909 0969 6620 2821 702d 2667 743b  k....if (!p->
    │ │ │ +00040aa0: 6173 736f 6369 6174 6564 5f74 6f72 7265  associated_torre
    │ │ │ +00040ab0: 6e74 2829 2e65 7870 6972 6564 2829 2920  nt().expired()) 
    │ │ │ +00040ac0: 636f 6e74 696e 7565 3b0a 0a3c 6469 7620  continue;..
    ...int │ │ │ +00040b00: 7469 6d65 6f75 7420 3d20 6d5f 7365 7474 timeout = m_sett │ │ │ +00040b10: 696e 6773 2e67 6574 5f69 6e74 2873 6574 ings.get_int(set │ │ │ +00040b20: 7469 6e67 735f 7061 636b 3a3a 6861 6e64 tings_pack::hand │ │ │ +00040b30: 7368 616b 655f 7469 6d65 6f75 7429 3b0a shake_timeout);. │ │ │ +00040b40: 3c2f 6469 763e 2369 6620 544f 5252 454e
    #if TORREN │ │ │ +00040b50: 545f 5553 455f 4932 500a 0909 0974 696d T_USE_I2P....tim │ │ │ +00040b60: 656f 7574 202a 3d20 6973 5f69 3270 2870 eout *= is_i2p(p │ │ │ +00040b70: 2d26 6774 3b67 6574 5f73 6f63 6b65 7428 ->get_socket( │ │ │ +00040b80: 2929 203f 2034 203a 2031 3b0a 2365 6e64 )) ? 4 : 1;.#end │ │ │ +00040b90: 6966 0a09 0909 6966 2028 6d5f 6c61 7374 if....if (m_last │ │ │ +00040ba0: 5f74 6963 6b20 2d20 702d 2667 743b 636f _tick - p->co │ │ │ +00040bb0: 6e6e 6563 7465 645f 7469 6d65 2028 2920 nnected_time () │ │ │ +00040bc0: 2667 743b 2073 6563 6f6e 6473 2874 696d > seconds(tim │ │ │ +00040bd0: 656f 7574 2929 0a09 0909 0970 2d26 6774 eout)).....p-> │ │ │ +00040be0: 3b64 6973 636f 6e6e 6563 7428 6572 726f ;disconnect(erro │ │ │ +00040bf0: 7273 3a3a 7469 6d65 645f 6f75 742c 206f rs::timed_out, o │ │ │ +00040c00: 7065 7261 7469 6f6e 5f74 3a3a 6269 7474 peration_t::bitt │ │ │ +00040c10: 6f72 7265 6e74 293b 0a09 097d 0a0a 0909 orrent);...}.... │ │ │ +00040c20: 2f2f 202d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d // ------------- │ │ │ +00040c30: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040c40: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040c50: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040c60: 2d0a 0909 2f2f 2073 6563 6f6e 645f 7469 -...// second_ti │ │ │ +00040c70: 636b 2065 7665 7279 2074 6f72 7265 6e74 ck every torrent │ │ │ +00040c80: 2028 7468 6174 2077 616e 7473 2069 7429 (that wants it) │ │ │ +00040c90: 0a09 092f 2f20 2d2d 2d2d 2d2d 2d2d 2d2d ...// ---------- │ │ │ +00040ca0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040cb0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040cc0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00040cd0: 2d2d 2d2d 0a0a 2369 6620 544f 5252 454e ----..#if TORREN │ │ │ +00040ce0: 545f 4445 4255 475f 5354 5245 414d 494e T_DEBUG_STREAMIN │ │ │ +00040cf0: 4720 2667 743b 2030 0a09 0973 7464 3a3a G > 0...std:: │ │ │ +00040d00: 7072 696e 7466 2822 5c30 3333 5b32 4a5c printf("\033[2J\ │ │ │ +00040d10: 3033 335b 303b 3048 2229 3b0a 2365 6e64 033[0;0H");.#end │ │ │ +00040d20: 6966 0a0a 0909 6175 783a 3a76 6563 746f if....aux::vecto │ │ │ +00040d30: 7226 6c74 3b74 6f72 7265 6e74 2a26 6774 r<torrent*> │ │ │ +00040d40: 3b26 616d 703b 2077 616e 745f 7469 636b ;& want_tick │ │ │ +00040d50: 203d 206d 5f74 6f72 7265 6e74 5f6c 6973 = m_torrent_lis │ │ │ +00040d60: 7473 5b74 6f72 7265 6e74 5f77 616e 745f ts[torrent_want_ │ │ │ +00040d70: 7469 636b 5d3b 0a09 0966 6f72 2028 696e tick];...for (in │ │ │ +00040d80: 7420 6920 3d20 303b 2069 2026 6c74 3b20 t i = 0; i < │ │ │ +00040d90: 696e 7428 7761 6e74 5f74 6963 6b2e 7369 int(want_tick.si │ │ │ +00040da0: 7a65 2829 293b 202b 2b69 290a 0909 7b0a ze()); ++i)...{. │ │ │ +00040db0: 0909 0974 6f72 7265 6e74 2661 6d70 3b20 ...torrent& │ │ │ +00040dc0: 7420 3d20 2a77 616e 745f 7469 636b 5b69 t = *want_tick[i │ │ │ +00040dd0: 5d3b 0a09 0909 544f 5252 454e 545f 4153 ];....TORRENT_AS │ │ │ +00040de0: 5345 5254 2874 2e77 616e 745f 7469 636b SERT(t.want_tick │ │ │ +00040df0: 2829 293b 0a09 0909 544f 5252 454e 545f ());....TORRENT_ │ │ │ +00040e00: 4153 5345 5254 2821 742e 6973 5f61 626f ASSERT(!t.is_abo │ │ │ +00040e10: 7274 6564 2829 293b 0a0a 0909 0974 2e73 rted());.....t.s │ │ │ +00040e20: 6563 6f6e 645f 7469 636b 2874 6963 6b5f econd_tick(tick_ │ │ │ +00040e30: 696e 7465 7276 616c 5f6d 7329 3b0a 0a09 interval_ms);... │ │ │ +00040e40: 0909 2f2f 2069 6620 7468 6520 6361 6c6c ..// if the call │ │ │ +00040e50: 2074 6f20 7365 636f 6e64 5f74 6963 6b20 to second_tick │ │ │ +00040e60: 6361 7573 6564 2074 6865 2074 6f72 7265 caused the torre │ │ │ +00040e70: 6e74 0a09 0909 2f2f 2074 6f20 6e6f 206c nt....// to no l │ │ │ +00040e80: 6f6e 6765 7220 7761 6e74 2074 6f20 6265 onger want to be │ │ │ +00040e90: 2074 6963 6b65 6420 2869 2e65 2e20 6974 ticked (i.e. it │ │ │ +00040ea0: 2077 6173 0a09 0909 2f2f 2072 656d 6f76 was....// remov │ │ │ +00040eb0: 6564 2066 726f 6d20 7468 6520 6c69 7374 ed from the list │ │ │ +00040ec0: 2920 7765 206e 6565 6420 746f 2062 6163 ) we need to bac │ │ │ +00040ed0: 6b20 7570 2074 6865 2063 6f75 6e74 6572 k up the counter │ │ │ +00040ee0: 0a09 0909 2f2f 2074 6f20 6e6f 7420 6d69 ....// to not mi │ │ │ +00040ef0: 7373 2074 6865 2074 6f72 7265 6e74 2061 ss the torrent a │ │ │ +00040f00: 6674 6572 2069 740a 0909 0969 6620 2821 fter it....if (! │ │ │ +00040f10: 742e 7761 6e74 5f74 6963 6b28 2929 202d t.want_tick()) - │ │ │ +00040f20: 2d69 3b0a 0909 7d0a 3c2f 7072 653e 3c2f -i;...}.
    relevan │ │ │ +00040f60: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/sessio │ │ │ +00040fa0: 6e5f 696d 706c 2e63 7070 3a33 3736 363c n_impl.cpp:3766< │ │ │ +00040fb0: 2f61 3e3c 2f74 643e 3c74 643e 7468 6973 /a>this │ │ │ +00040fc0: 2073 686f 756c 6420 6170 706c 7920 746f should apply to │ │ │ +00040fd0: 2061 6c6c 2062 616e 6477 6964 7468 2063 all bandwidth c │ │ │ +00040fe0: 6861 6e6e 656c 733c 2f74 643e 3c2f 7472 hannels

    this should │ │ │ +00041040: 2061 7070 6c79 2074 6f20 616c 6c20 6261 apply to all ba │ │ │ +00041050: 6e64 7769 6474 6820 6368 616e 6e65 6c73 ndwidth channels │ │ │ +00041060: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +00041070: 7365 7373 696f 6e5f 696d 706c 2e63 7070 session_impl.cpp │ │ │ +00041080: 3a33 3736 363c 2f68 343e 3c70 7265 2073 :3766

    #if TORRENT_
    │ │ │ +000410d0: 4445 4255 475f 5354 5245 414d 494e 4720  DEBUG_STREAMING 
    │ │ │ +000410e0: 2667 743b 2030 0a09 0973 7464 3a3a 7072  > 0...std::pr
    │ │ │ +000410f0: 696e 7466 2822 5c30 3333 5b32 4a5c 3033  intf("\033[2J\03
    │ │ │ +00041100: 335b 303b 3048 2229 3b0a 2365 6e64 6966  3[0;0H");.#endif
    │ │ │ +00041110: 0a0a 0909 6175 783a 3a76 6563 746f 7226  ....aux::vector&
    │ │ │ +00041120: 6c74 3b74 6f72 7265 6e74 2a26 6774 3b26  lt;torrent*>&
    │ │ │ +00041130: 616d 703b 2077 616e 745f 7469 636b 203d  amp; want_tick =
    │ │ │ +00041140: 206d 5f74 6f72 7265 6e74 5f6c 6973 7473   m_torrent_lists
    │ │ │ +00041150: 5b74 6f72 7265 6e74 5f77 616e 745f 7469  [torrent_want_ti
    │ │ │ +00041160: 636b 5d3b 0a09 0966 6f72 2028 696e 7420  ck];...for (int 
    │ │ │ +00041170: 6920 3d20 303b 2069 2026 6c74 3b20 696e  i = 0; i < in
    │ │ │ +00041180: 7428 7761 6e74 5f74 6963 6b2e 7369 7a65  t(want_tick.size
    │ │ │ +00041190: 2829 293b 202b 2b69 290a 0909 7b0a 0909  ()); ++i)...{...
    │ │ │ +000411a0: 0974 6f72 7265 6e74 2661 6d70 3b20 7420  .torrent& t 
    │ │ │ +000411b0: 3d20 2a77 616e 745f 7469 636b 5b69 5d3b  = *want_tick[i];
    │ │ │ +000411c0: 0a09 0909 544f 5252 454e 545f 4153 5345  ....TORRENT_ASSE
    │ │ │ +000411d0: 5254 2874 2e77 616e 745f 7469 636b 2829  RT(t.want_tick()
    │ │ │ +000411e0: 293b 0a09 0909 544f 5252 454e 545f 4153  );....TORRENT_AS
    │ │ │ +000411f0: 5345 5254 2821 742e 6973 5f61 626f 7274  SERT(!t.is_abort
    │ │ │ +00041200: 6564 2829 293b 0a0a 0909 0974 2e73 6563  ed());.....t.sec
    │ │ │ +00041210: 6f6e 645f 7469 636b 2874 6963 6b5f 696e  ond_tick(tick_in
    │ │ │ +00041220: 7465 7276 616c 5f6d 7329 3b0a 0a09 0909  terval_ms);.....
    │ │ │ +00041230: 2f2f 2069 6620 7468 6520 6361 6c6c 2074  // if the call t
    │ │ │ +00041240: 6f20 7365 636f 6e64 5f74 6963 6b20 6361  o second_tick ca
    │ │ │ +00041250: 7573 6564 2074 6865 2074 6f72 7265 6e74  used the torrent
    │ │ │ +00041260: 0a09 0909 2f2f 2074 6f20 6e6f 206c 6f6e  ....// to no lon
    │ │ │ +00041270: 6765 7220 7761 6e74 2074 6f20 6265 2074  ger want to be t
    │ │ │ +00041280: 6963 6b65 6420 2869 2e65 2e20 6974 2077  icked (i.e. it w
    │ │ │ +00041290: 6173 0a09 0909 2f2f 2072 656d 6f76 6564  as....// removed
    │ │ │ +000412a0: 2066 726f 6d20 7468 6520 6c69 7374 2920   from the list) 
    │ │ │ +000412b0: 7765 206e 6565 6420 746f 2062 6163 6b20  we need to back 
    │ │ │ +000412c0: 7570 2074 6865 2063 6f75 6e74 6572 0a09  up the counter..
    │ │ │ +000412d0: 0909 2f2f 2074 6f20 6e6f 7420 6d69 7373  ..// to not miss
    │ │ │ +000412e0: 2074 6865 2074 6f72 7265 6e74 2061 6674   the torrent aft
    │ │ │ +000412f0: 6572 2069 740a 0909 0969 6620 2821 742e  er it....if (!t.
    │ │ │ +00041300: 7761 6e74 5f74 6963 6b28 2929 202d 2d69  want_tick()) --i
    │ │ │ +00041310: 3b0a 0909 7d0a 0a3c 6469 7620 7374 796c  ;...}..
    ..if (m_set │ │ │ +00041350: 7469 6e67 732e 6765 745f 626f 6f6c 2873 tings.get_bool(s │ │ │ +00041360: 6574 7469 6e67 735f 7061 636b 3a3a 7261 ettings_pack::ra │ │ │ +00041370: 7465 5f6c 696d 6974 5f69 705f 6f76 6572 te_limit_ip_over │ │ │ +00041380: 6865 6164 2929 0a3c 2f64 6976 3e09 097b head)).
    ..{ │ │ │ +00041390: 0a09 0909 696e 7420 636f 6e73 7420 7570 ....int const up │ │ │ +000413a0: 5f6c 696d 6974 203d 2075 706c 6f61 645f _limit = upload_ │ │ │ +000413b0: 7261 7465 5f6c 696d 6974 286d 5f67 6c6f rate_limit(m_glo │ │ │ +000413c0: 6261 6c5f 636c 6173 7329 3b0a 0909 0969 bal_class);....i │ │ │ +000413d0: 6e74 2063 6f6e 7374 2064 6f77 6e5f 6c69 nt const down_li │ │ │ +000413e0: 6d69 7420 3d20 646f 776e 6c6f 6164 5f72 mit = download_r │ │ │ +000413f0: 6174 655f 6c69 6d69 7428 6d5f 676c 6f62 ate_limit(m_glob │ │ │ +00041400: 616c 5f63 6c61 7373 293b 0a0a 0909 0969 al_class);.....i │ │ │ +00041410: 6620 2864 6f77 6e5f 6c69 6d69 7420 2667 f (down_limit &g │ │ │ +00041420: 743b 2030 0a09 0909 0926 616d 703b 2661 t; 0.....&&a │ │ │ +00041430: 6d70 3b20 6d5f 7374 6174 2e64 6f77 6e6c mp; m_stat.downl │ │ │ +00041440: 6f61 645f 6970 5f6f 7665 7268 6561 6428 oad_ip_overhead( │ │ │ +00041450: 2920 2667 743b 3d20 646f 776e 5f6c 696d ) >= down_lim │ │ │ +00041460: 6974 0a09 0909 0926 616d 703b 2661 6d70 it.....&& │ │ │ +00041470: 3b20 6d5f 616c 6572 7473 2e73 686f 756c ; m_alerts.shoul │ │ │ +00041480: 645f 706f 7374 266c 743b 7065 7266 6f72 d_post<perfor │ │ │ +00041490: 6d61 6e63 655f 616c 6572 7426 6774 3b28 mance_alert>( │ │ │ +000414a0: 2929 0a09 0909 7b0a 0909 0909 6d5f 616c ))....{.....m_al │ │ │ +000414b0: 6572 7473 2e65 6d70 6c61 6365 5f61 6c65 erts.emplace_ale │ │ │ +000414c0: 7274 266c 743b 7065 7266 6f72 6d61 6e63 rt<performanc │ │ │ +000414d0: 655f 616c 6572 7426 6774 3b28 746f 7272 e_alert>(torr │ │ │ +000414e0: 656e 745f 6861 6e64 6c65 2829 0a09 0909 ent_handle().... │ │ │ +000414f0: 0909 2c20 7065 7266 6f72 6d61 6e63 655f .., performance_ │ │ │ +00041500: 616c 6572 743a 3a64 6f77 6e6c 6f61 645f alert::download_ │ │ │ +00041510: 6c69 6d69 745f 746f 6f5f 6c6f 7729 3b0a limit_too_low);. │ │ │ +00041520: 0909 097d 0a0a 0909 0969 6620 2875 705f ...}.....if (up_ │ │ │ +00041530: 6c69 6d69 7420 2667 743b 2030 0a09 0909 limit > 0.... │ │ │ +00041540: 0926 616d 703b 2661 6d70 3b20 6d5f 7374 .&& m_st │ │ │ +00041550: 6174 2e75 706c 6f61 645f 6970 5f6f 7665 at.upload_ip_ove │ │ │ +00041560: 7268 6561 6428 2920 2667 743b 3d20 7570 rhead() >= up │ │ │ +00041570: 5f6c 696d 6974 0a09 0909 0926 616d 703b _limit.....& │ │ │ +00041580: 2661 6d70 3b20 6d5f 616c 6572 7473 2e73 & m_alerts.s │ │ │ +00041590: 686f 756c 645f 706f 7374 266c 743b 7065 hould_post<pe │ │ │ +000415a0: 7266 6f72 6d61 6e63 655f 616c 6572 7426 rformance_alert& │ │ │ +000415b0: 6774 3b28 2929 0a09 0909 7b0a 0909 0909 gt;())....{..... │ │ │ +000415c0: 6d5f 616c 6572 7473 2e65 6d70 6c61 6365 m_alerts.emplace │ │ │ +000415d0: 5f61 6c65 7274 266c 743b 7065 7266 6f72 _alert<perfor │ │ │ +000415e0: 6d61 6e63 655f 616c 6572 7426 6774 3b28 mance_alert>( │ │ │ +000415f0: 746f 7272 656e 745f 6861 6e64 6c65 2829 torrent_handle() │ │ │ +00041600: 0a09 0909 0909 2c20 7065 7266 6f72 6d61 ......, performa │ │ │ +00041610: 6e63 655f 616c 6572 743a 3a75 706c 6f61 nce_alert::uploa │ │ │ +00041620: 645f 6c69 6d69 745f 746f 6f5f 6c6f 7729 d_limit_too_low) │ │ │ +00041630: 3b0a 0909 097d 0a09 097d 0a0a 2369 6620 ;....}...}..#if │ │ │ +00041640: 544f 5252 454e 545f 4142 495f 5645 5253 TORRENT_ABI_VERS │ │ │ +00041650: 494f 4e20 3d3d 2031 0a09 096d 5f70 6561 ION == 1...m_pea │ │ │ +00041660: 6b5f 7570 5f72 6174 6520 3d20 7374 643a k_up_rate = std: │ │ │ +00041670: 3a6d 6178 286d 5f73 7461 742e 7570 6c6f :max(m_stat.uplo │ │ │ +00041680: 6164 5f72 6174 6528 292c 206d 5f70 6561 ad_rate(), m_pea │ │ │ +00041690: 6b5f 7570 5f72 6174 6529 3b0a 2365 6e64 k_up_rate);.#end │ │ │ +000416a0: 6966 0a0a 0909 6d5f 7374 6174 2e73 6563 if....m_stat.sec │ │ │ +000416b0: 6f6e 645f 7469 636b 2874 6963 6b5f 696e ond_tick(tick_in │ │ │ +000416c0: 7465 7276 616c 5f6d 7329 3b0a 0a09 092f terval_ms);..../ │ │ │ +000416d0: 2f20 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d / -------------- │ │ │ +000416e0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +000416f0: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00041700: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d ---------------- │ │ │ +00041710: 0a09 092f 2f20 7363 7261 7065 2070 6175 ...// scrape pau │ │ │ +00041720: 7365 6420 746f 7272 656e 7473 2074 6861 sed torrents tha │ │ │ +00041730: 7420 6172 6520 6175 746f 206d 616e 6167 t are auto manag │ │ │ +00041740: 6564 0a09 092f 2f20 2875 6e6c 6573 7320 ed...// (unless │ │ │ +00041750: 7468 6520 7365 7373 696f 6e20 6973 2070 the session is p │ │ │ +00041760: 6175 7365 6429 0a3c 2f70 7265 3e3c 2f74 aused).
    relevanc │ │ │ +000417a0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/session │ │ │ +000417e0: 5f69 6d70 6c2e 6370 703a 3435 3231 3c2f _impl.cpp:4521use a │ │ │ +00041800: 206c 6f77 6572 206c 696d 6974 2074 6861 lower limit tha │ │ │ +00041810: 6e20 6d5f 7365 7474 696e 6773 2e63 6f6e n m_settings.con │ │ │ +00041820: 6e65 6374 696f 6e73 5f6c 696d 6974 2074 nections_limit t │ │ │ +00041830: 6f20 616c 6c6f 6361 7465 2074 6865 2074 o allocate the t │ │ │ +00041840: 6f20 3130 2520 6f72 2073 6f20 6f66 2063 o 10% or so of c │ │ │ +00041850: 6f6e 6e65 6374 696f 6e20 736c 6f74 7320 onnection slots │ │ │ +00041860: 666f 7220 696e 636f 6d69 6e67 2063 6f6e for incoming con │ │ │ +00041870: 6e65 6374 696f 6e73 2063 6170 2074 6869 nections cap thi │ │ │ +00041880: 7320 6174 206d 6178 202d 2031 2c20 7369 s at max - 1, si │ │ │ +00041890: 6e63 6520 7765 206d 6179 2061 6464 206f nce we may add o │ │ │ +000418a0: 6e65 2062 656c 6f77 3c2f 7464 3e3c 2f74 ne below

    use a lowe │ │ │ +00041900: 7220 6c69 6d69 7420 7468 616e 206d 5f73 r limit than m_s │ │ │ +00041910: 6574 7469 6e67 732e 636f 6e6e 6563 7469 ettings.connecti │ │ │ +00041920: 6f6e 735f 6c69 6d69 740a 746f 2061 6c6c ons_limit.to all │ │ │ +00041930: 6f63 6174 6520 7468 6520 746f 2031 3025 ocate the to 10% │ │ │ +00041940: 206f 7220 736f 206f 6620 636f 6e6e 6563 or so of connec │ │ │ +00041950: 7469 6f6e 2073 6c6f 7473 2066 6f72 2069 tion slots for i │ │ │ +00041960: 6e63 6f6d 696e 670a 636f 6e6e 6563 7469 ncoming.connecti │ │ │ +00041970: 6f6e 730a 6361 7020 7468 6973 2061 7420 ons.cap this at │ │ │ +00041980: 6d61 7820 2d20 312c 2073 696e 6365 2077 max - 1, since w │ │ │ +00041990: 6520 6d61 7920 6164 6420 6f6e 6520 6265 e may add one be │ │ │ +000419a0: 6c6f 773c 2f68 323e 3c68 343e 2e2e 2f73 low

    ../s │ │ │ +000419b0: 7263 2f73 6573 7369 6f6e 5f69 6d70 6c2e rc/session_impl. │ │ │ +000419c0: 6370 703a 3435 3231 3c2f 6834 3e3c 7072 cpp:4521

    ..// boos │ │ │ +00041a10: 742c 2077 6869 6368 2061 7265 2064 6f6e t, which are don │ │ │ +00041a20: 6520 696d 6d65 6469 6174 656c 7920 6f6e e immediately on │ │ │ +00041a30: 2061 2074 7261 636b 6572 2072 6573 706f a tracker respo │ │ │ +00041a40: 6e73 652e 2054 6865 7365 0a09 092f 2f20 nse. These...// │ │ │ +00041a50: 636f 6e6e 6563 7469 6f6e 7320 6e65 6564 connections need │ │ │ +00041a60: 7320 746f 2062 6520 6465 6475 6374 6564 s to be deducted │ │ │ +00041a70: 2066 726f 6d20 7468 6520 7265 6775 6c61 from the regula │ │ │ +00041a80: 7220 636f 6e6e 6563 7469 6f6e 2061 7474 r connection att │ │ │ +00041a90: 656d 7074 0a09 092f 2f20 7175 6f74 6120 empt...// quota │ │ │ +00041aa0: 666f 7220 7468 6973 2074 6963 6b0a 0909 for this tick... │ │ │ +00041ab0: 6966 2028 6d5f 626f 6f73 745f 636f 6e6e if (m_boost_conn │ │ │ +00041ac0: 6563 7469 6f6e 7320 2667 743b 2030 290a ections > 0). │ │ │ +00041ad0: 0909 7b0a 0909 0969 6620 286d 5f62 6f6f ..{....if (m_boo │ │ │ +00041ae0: 7374 5f63 6f6e 6e65 6374 696f 6e73 2026 st_connections & │ │ │ +00041af0: 6774 3b20 6d61 785f 636f 6e6e 6563 7469 gt; max_connecti │ │ │ +00041b00: 6f6e 7329 0a09 0909 7b0a 0909 0909 6d5f ons)....{.....m_ │ │ │ +00041b10: 626f 6f73 745f 636f 6e6e 6563 7469 6f6e boost_connection │ │ │ +00041b20: 7320 2d3d 206d 6178 5f63 6f6e 6e65 6374 s -= max_connect │ │ │ +00041b30: 696f 6e73 3b0a 0909 0909 6d61 785f 636f ions;.....max_co │ │ │ +00041b40: 6e6e 6563 7469 6f6e 7320 3d20 303b 0a09 nnections = 0;.. │ │ │ +00041b50: 0909 7d0a 0909 0965 6c73 650a 0909 097b ..}....else....{ │ │ │ +00041b60: 0a09 0909 096d 6178 5f63 6f6e 6e65 6374 .....max_connect │ │ │ +00041b70: 696f 6e73 202d 3d20 6d5f 626f 6f73 745f ions -= m_boost_ │ │ │ +00041b80: 636f 6e6e 6563 7469 6f6e 733b 0a09 0909 connections;.... │ │ │ +00041b90: 096d 5f62 6f6f 7374 5f63 6f6e 6e65 6374 .m_boost_connect │ │ │ +00041ba0: 696f 6e73 203d 2030 3b0a 0909 097d 0a09 ions = 0;....}.. │ │ │ +00041bb0: 097d 0a0a 0909 2f2f 207a 6572 6f20 636f .}....// zero co │ │ │ +00041bc0: 6e6e 6563 7469 6f6e 7320 7370 6565 6473 nnections speeds │ │ │ +00041bd0: 2061 7265 2061 6c6c 6f77 6564 2c20 7765 are allowed, we │ │ │ +00041be0: 206a 7573 7420 776f 6e27 7420 6d61 6b65 just won't make │ │ │ +00041bf0: 2061 6e79 2063 6f6e 6e65 6374 696f 6e73 any connections │ │ │ +00041c00: 0a09 0969 6620 286d 6178 5f63 6f6e 6e65 ...if (max_conne │ │ │ +00041c10: 6374 696f 6e73 2026 6c74 3b3d 2030 2920 ctions <= 0) │ │ │ +00041c20: 7265 7475 726e 3b0a 0a3c 6469 7620 7374 return;..
    ..int con │ │ │ +00041c60: 7374 206c 696d 6974 203d 2073 7464 3a3a st limit = std:: │ │ │ +00041c70: 6d69 6e28 6d5f 7365 7474 696e 6773 2e67 min(m_settings.g │ │ │ +00041c80: 6574 5f69 6e74 2873 6574 7469 6e67 735f et_int(settings_ │ │ │ +00041c90: 7061 636b 3a3a 636f 6e6e 6563 7469 6f6e pack::connection │ │ │ +00041ca0: 735f 6c69 6d69 7429 0a3c 2f64 6976 3e09 s_limit).
    . │ │ │ +00041cb0: 0909 2d20 6e75 6d5f 636f 6e6e 6563 7469 ..- num_connecti │ │ │ +00041cc0: 6f6e 7328 292c 2073 7464 3a3a 6e75 6d65 ons(), std::nume │ │ │ +00041cd0: 7269 635f 6c69 6d69 7473 266c 743b 696e ric_limits<in │ │ │ +00041ce0: 7426 6774 3b3a 3a6d 6178 2829 202d 2031 t>::max() - 1 │ │ │ +00041cf0: 293b 0a0a 0909 2f2f 2074 6869 7320 6c6f );....// this lo │ │ │ +00041d00: 6769 6320 6973 2068 6572 6520 746f 2073 gic is here to s │ │ │ +00041d10: 6d6f 6f74 6820 6f75 7420 7468 6520 6e75 mooth out the nu │ │ │ +00041d20: 6d62 6572 206f 6620 6e65 7720 636f 6e6e mber of new conn │ │ │ +00041d30: 6563 7469 6f6e 0a09 092f 2f20 6174 7465 ection...// atte │ │ │ +00041d40: 6d70 7473 206f 7665 7220 7469 6d65 2c20 mpts over time, │ │ │ +00041d50: 746f 2070 7265 7665 6e74 2063 6f6e 6e65 to prevent conne │ │ │ +00041d60: 6374 696e 6720 6120 6c61 7267 6520 6e75 cting a large nu │ │ │ +00041d70: 6d62 6572 206f 660a 0909 2f2f 2073 6f63 mber of...// soc │ │ │ +00041d80: 6b65 7473 2c20 7761 6974 2031 3020 7365 kets, wait 10 se │ │ │ +00041d90: 636f 6e64 732c 2061 6e64 2074 6865 6e20 conds, and then │ │ │ +00041da0: 7472 7920 6167 6169 6e0a 0909 6966 2028 try again...if ( │ │ │ +00041db0: 6d5f 7365 7474 696e 6773 2e67 6574 5f62 m_settings.get_b │ │ │ +00041dc0: 6f6f 6c28 7365 7474 696e 6773 5f70 6163 ool(settings_pac │ │ │ +00041dd0: 6b3a 3a73 6d6f 6f74 685f 636f 6e6e 6563 k::smooth_connec │ │ │ +00041de0: 7473 2920 2661 6d70 3b26 616d 703b 206d ts) && m │ │ │ +00041df0: 6178 5f63 6f6e 6e65 6374 696f 6e73 2026 ax_connections & │ │ │ +00041e00: 6774 3b20 286c 696d 6974 2b31 2920 2f20 gt; (limit+1) / │ │ │ +00041e10: 3229 0a09 0909 6d61 785f 636f 6e6e 6563 2)....max_connec │ │ │ +00041e20: 7469 6f6e 7320 3d20 286c 696d 6974 202b tions = (limit + │ │ │ +00041e30: 2031 2920 2f20 323b 0a0a 0909 6175 783a 1) / 2;....aux: │ │ │ +00041e40: 3a76 6563 746f 7226 6c74 3b74 6f72 7265 :vector<torre │ │ │ +00041e50: 6e74 2a26 6774 3b26 616d 703b 2077 616e nt*>& wan │ │ │ +00041e60: 745f 7065 6572 735f 646f 776e 6c6f 6164 t_peers_download │ │ │ +00041e70: 203d 206d 5f74 6f72 7265 6e74 5f6c 6973 = m_torrent_lis │ │ │ +00041e80: 7473 5b74 6f72 7265 6e74 5f77 616e 745f ts[torrent_want_ │ │ │ +00041e90: 7065 6572 735f 646f 776e 6c6f 6164 5d3b peers_download]; │ │ │ +00041ea0: 0a09 0961 7578 3a3a 7665 6374 6f72 266c ...aux::vector&l │ │ │ +00041eb0: 743b 746f 7272 656e 742a 2667 743b 2661 t;torrent*>&a │ │ │ +00041ec0: 6d70 3b20 7761 6e74 5f70 6565 7273 5f66 mp; want_peers_f │ │ │ +00041ed0: 696e 6973 6865 6420 3d20 6d5f 746f 7272 inished = m_torr │ │ │ +00041ee0: 656e 745f 6c69 7374 735b 746f 7272 656e ent_lists[torren │ │ │ +00041ef0: 745f 7761 6e74 5f70 6565 7273 5f66 696e t_want_peers_fin │ │ │ +00041f00: 6973 6865 645d 3b0a 0a09 092f 2f20 6966 ished];....// if │ │ │ +00041f10: 206e 6f20 746f 7272 656e 7420 7761 6e74 no torrent want │ │ │ +00041f20: 2061 6e79 2070 6565 7273 2c20 6a75 7374 any peers, just │ │ │ +00041f30: 2072 6574 7572 6e0a 0909 6966 2028 7761 return...if (wa │ │ │ +00041f40: 6e74 5f70 6565 7273 5f64 6f77 6e6c 6f61 nt_peers_downloa │ │ │ +00041f50: 642e 656d 7074 7928 2920 2661 6d70 3b26 d.empty() && │ │ │ +00041f60: 616d 703b 2077 616e 745f 7065 6572 735f amp; want_peers_ │ │ │ +00041f70: 6669 6e69 7368 6564 2e65 6d70 7479 2829 finished.empty() │ │ │ +00041f80: 2920 7265 7475 726e 3b0a 0a09 092f 2f20 ) return;....// │ │ │ +00041f90: 6966 2077 6520 646f 6e27 7420 6861 7665 if we don't have │ │ │ +00041fa0: 2061 6e79 2063 6f6e 6e65 6374 696f 6e20 any connection │ │ │ +00041fb0: 6174 7465 6d70 7420 7175 6f74 612c 2072 attempt quota, r │ │ │ +00041fc0: 6574 7572 6e0a 0909 6966 2028 6d61 785f eturn...if (max_ │ │ │ +00041fd0: 636f 6e6e 6563 7469 6f6e 7320 266c 743b connections < │ │ │ +00041fe0: 3d20 3029 2072 6574 7572 6e3b 0a0a 0909 = 0) return;.... │ │ │ +00041ff0: 696e 7420 7374 6570 735f 7369 6e63 655f int steps_since_ │ │ │ +00042000: 6c61 7374 5f63 6f6e 6e65 6374 203d 2030 last_connect = 0 │ │ │ +00042010: 3b0a 0909 696e 7420 636f 6e73 7420 6e75 ;...int const nu │ │ │ +00042020: 6d5f 746f 7272 656e 7473 203d 2069 6e74 m_torrents = int │ │ │ +00042030: 2877 616e 745f 7065 6572 735f 6669 6e69 (want_peers_fini │ │ │ +00042040: 7368 6564 2e73 697a 6528 2920 2b20 7761 shed.size() + wa │ │ │ +00042050: 6e74 5f70 6565 7273 5f64 6f77 6e6c 6f61 nt_peers_downloa │ │ │ +00042060: 642e 7369 7a65 2829 293b 0a09 0966 6f72 d.size());...for │ │ │ +00042070: 2028 3b3b 290a 0909 7b0a 0909 0969 6620 (;;)...{....if │ │ │ +00042080: 286d 5f6e 6578 745f 646f 776e 6c6f 6164 (m_next_download │ │ │ +00042090: 696e 675f 636f 6e6e 6563 745f 746f 7272 ing_connect_torr │ │ │ +000420a0: 656e 7420 2667 743b 3d20 696e 7428 7761 ent >= int(wa │ │ │ +000420b0: 6e74 5f70 6565 7273 5f64 6f77 6e6c 6f61 nt_peers_downloa │ │ │ +000420c0: 642e 7369 7a65 2829 2929 0a09 0909 096d d.size())).....m │ │ │ +000420d0: 5f6e 6578 745f 646f 776e 6c6f 6164 696e _next_downloadin │ │ │ +000420e0: 675f 636f 6e6e 6563 745f 746f 7272 656e g_connect_torren │ │ │ +000420f0: 7420 3d20 303b 0a0a 0909 0969 6620 286d t = 0;.....if (m │ │ │ +00042100: 5f6e 6578 745f 6669 6e69 7368 6564 5f63 _next_finished_c │ │ │ +00042110: 6f6e 6e65 6374 5f74 6f72 7265 6e74 2026 onnect_torrent & │ │ │ +00042120: 6774 3b3d 2069 6e74 2877 616e 745f 7065 gt;= int(want_pe │ │ │ +00042130: 6572 735f 6669 6e69 7368 6564 2e73 697a ers_finished.siz │ │ │ +00042140: 6528 2929 290a 0909 0909 6d5f 6e65 7874 e())).....m_next │ │ │ +00042150: 5f66 696e 6973 6865 645f 636f 6e6e 6563 _finished_connec │ │ │ +00042160: 745f 746f 7272 656e 7420 3d20 303b 0a0a t_torrent = 0;.. │ │ │ +00042170: 0909 0974 6f72 7265 6e74 2a20 7420 3d20 ...torrent* t = │ │ │ +00042180: 6e75 6c6c 7074 723b 0a09 0909 2f2f 2074 nullptr;....// t │ │ │ +00042190: 6865 7265 2061 7265 2070 7269 6f72 6974 here are priorit │ │ │ +000421a0: 697a 6564 2074 6f72 7265 6e74 732e 2050 ized torrents. P │ │ │ +000421b0: 6963 6b20 6f6e 6520 6f66 2074 686f 7365 ick one of those │ │ │ +000421c0: 0a09 0909 7768 696c 6520 2821 6d5f 7072 ....while (!m_pr │ │ │ +000421d0: 696f 5f74 6f72 7265 6e74 732e 656d 7074 io_torrents.empt │ │ │ +000421e0: 7928 2929 0a3c 2f70 7265 3e3c 2f74 643e y()).
    │ │ │ +000421f0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +00042220: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +00042230: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +00042240: 7074 3a65 7870 616e 6428 3136 3229 223e pt:expand(162)"> │ │ │ +00042250: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ +00042260: 6d70 6c2e 6370 703a 3436 3636 3c2f 613e mpl.cpp:4666 │ │ │ +00042270: 3c2f 7464 3e3c 7464 3e70 6f73 7420 6120 post a │ │ │ +00042280: 6d65 7373 6167 6520 746f 2068 6176 6520 message to have │ │ │ +00042290: 7468 6973 2068 6170 7065 6e20 696d 6d65 this happen imme │ │ │ +000422a0: 6469 6174 656c 7920 696e 7374 6561 6420 diately instead │ │ │ +000422b0: 6f66 2077 6169 7469 6e67 2066 6f72 2074 of waiting for t │ │ │ +000422c0: 6865 206e 6578 7420 7469 636b 3c2f 7464 he next tick

    post a │ │ │ +00042320: 206d 6573 7361 6765 2074 6f20 6861 7665 message to have │ │ │ +00042330: 2074 6869 7320 6861 7070 656e 0a69 6d6d this happen.imm │ │ │ +00042340: 6564 6961 7465 6c79 2069 6e73 7465 6164 ediately instead │ │ │ +00042350: 206f 6620 7761 6974 696e 6720 666f 7220 of waiting for │ │ │ +00042360: 7468 6520 6e65 7874 2074 6963 6b3c 2f68 the next tick

    ../src/ses │ │ │ +00042380: 7369 6f6e 5f69 6d70 6c2e 6370 703a 3436 sion_impl.cpp:46 │ │ │ +00042390: 3636 3c2f 6834 3e3c 7072 6520 7374 796c 66

    ....continue;..
    │ │ │ +000423e0: 0909 7d0a 0a09 0909 6966 2028 2170 2d26  ..}.....if (!p-&
    │ │ │ +000423f0: 6774 3b69 735f 7065 6572 5f69 6e74 6572  gt;is_peer_inter
    │ │ │ +00042400: 6573 7465 6428 290a 0909 0909 7c7c 2070  ested().....|| p
    │ │ │ +00042410: 2d26 6774 3b69 735f 6469 7363 6f6e 6e65  ->is_disconne
    │ │ │ +00042420: 6374 696e 6728 290a 0909 0909 7c7c 2070  cting().....|| p
    │ │ │ +00042430: 2d26 6774 3b69 735f 636f 6e6e 6563 7469  ->is_connecti
    │ │ │ +00042440: 6e67 2829 290a 0909 097b 0a09 0909 092f  ng())....{...../
    │ │ │ +00042450: 2f20 7468 6973 2070 6565 7220 6973 206e  / this peer is n
    │ │ │ +00042460: 6f74 2075 6e63 686f 6b61 626c 652e 2053  ot unchokable. S
    │ │ │ +00042470: 6f2c 2069 6620 6974 2773 2075 6e63 686f  o, if it's uncho
    │ │ │ +00042480: 6b65 640a 0909 0909 2f2f 2061 6c72 6561  ked.....// alrea
    │ │ │ +00042490: 6479 2c20 6d61 6b65 2073 7572 6520 746f  dy, make sure to
    │ │ │ +000424a0: 2063 686f 6b65 2069 742e 0a09 0909 0969   choke it......i
    │ │ │ +000424b0: 6620 2870 2d26 6774 3b69 735f 6368 6f6b  f (p->is_chok
    │ │ │ +000424c0: 6564 2829 290a 0909 0909 7b0a 0909 0909  ed()).....{.....
    │ │ │ +000424d0: 0970 2d26 6774 3b72 6573 6574 5f63 686f  .p->reset_cho
    │ │ │ +000424e0: 6b65 5f63 6f75 6e74 6572 7328 293b 0a09  ke_counters();..
    │ │ │ +000424f0: 0909 0909 636f 6e74 696e 7565 3b0a 0909  ....continue;...
    │ │ │ +00042500: 0909 7d0a 0909 0909 6966 2028 7069 2026  ..}.....if (pi &
    │ │ │ +00042510: 616d 703b 2661 6d70 3b20 7069 2d26 6774  amp;& pi->
    │ │ │ +00042520: 3b6f 7074 696d 6973 7469 6361 6c6c 795f  ;optimistically_
    │ │ │ +00042530: 756e 6368 6f6b 6564 290a 0909 0909 7b0a  unchoked).....{.
    │ │ │ +00042540: 0909 0909 096d 5f73 7461 7473 5f63 6f75  .....m_stats_cou
    │ │ │ +00042550: 6e74 6572 732e 696e 635f 7374 6174 735f  nters.inc_stats_
    │ │ │ +00042560: 636f 756e 7465 7228 636f 756e 7465 7273  counter(counters
    │ │ │ +00042570: 3a3a 6e75 6d5f 7065 6572 735f 7570 5f75  ::num_peers_up_u
    │ │ │ +00042580: 6e63 686f 6b65 645f 6f70 7469 6d69 7374  nchoked_optimist
    │ │ │ +00042590: 6963 2c20 2d31 293b 0a09 0909 0909 7069  ic, -1);......pi
    │ │ │ +000425a0: 2d26 6774 3b6f 7074 696d 6973 7469 6361  ->optimistica
    │ │ │ +000425b0: 6c6c 795f 756e 6368 6f6b 6564 203d 2066  lly_unchoked = f
    │ │ │ +000425c0: 616c 7365 3b0a 0909 0909 092f 2f20 666f  alse;......// fo
    │ │ │ +000425d0: 7263 6520 6120 6e65 7720 6f70 7469 6d69  rce a new optimi
    │ │ │ +000425e0: 7374 6963 2075 6e63 686f 6b65 0a09 0909  stic unchoke....
    │ │ │ +000425f0: 0909 6d5f 6f70 7469 6d69 7374 6963 5f75  ..m_optimistic_u
    │ │ │ +00042600: 6e63 686f 6b65 5f74 696d 655f 7363 616c  nchoke_time_scal
    │ │ │ +00042610: 6572 203d 2030 3b0a 3c64 6976 2073 7479  er = 0;.
    ....}.....t->chok │ │ │ +00042660: 655f 7065 6572 282a 7029 3b0a 0909 0909 e_peer(*p);..... │ │ │ +00042670: 702d 2667 743b 7265 7365 745f 6368 6f6b p->reset_chok │ │ │ +00042680: 655f 636f 756e 7465 7273 2829 3b0a 0909 e_counters();... │ │ │ +00042690: 0909 636f 6e74 696e 7565 3b0a 0909 097d ..continue;....} │ │ │ +000426a0: 0a0a 0909 0970 6565 7273 2e70 7573 685f .....peers.push_ │ │ │ +000426b0: 6261 636b 2870 2e67 6574 2829 293b 0a09 back(p.get());.. │ │ │ +000426c0: 097d 0a0a 0909 696e 7420 636f 6e73 7420 .}....int const │ │ │ +000426d0: 616c 6c6f 7765 645f 7570 6c6f 6164 5f73 allowed_upload_s │ │ │ +000426e0: 6c6f 7473 203d 2075 6e63 686f 6b65 5f73 lots = unchoke_s │ │ │ +000426f0: 6f72 7428 7065 6572 730a 0909 092c 2075 ort(peers...., u │ │ │ +00042700: 6e63 686f 6b65 5f69 6e74 6572 7661 6c2c nchoke_interval, │ │ │ +00042710: 206d 5f73 6574 7469 6e67 7329 3b0a 0a09 m_settings);... │ │ │ +00042720: 0969 6620 286d 5f73 6574 7469 6e67 732e .if (m_settings. │ │ │ +00042730: 6765 745f 696e 7428 7365 7474 696e 6773 get_int(settings │ │ │ +00042740: 5f70 6163 6b3a 3a63 686f 6b69 6e67 5f61 _pack::choking_a │ │ │ +00042750: 6c67 6f72 6974 686d 2920 3d3d 2073 6574 lgorithm) == set │ │ │ +00042760: 7469 6e67 735f 7061 636b 3a3a 6669 7865 tings_pack::fixe │ │ │ +00042770: 645f 736c 6f74 735f 6368 6f6b 6572 290a d_slots_choker). │ │ │ +00042780: 0909 7b0a 0909 0969 6e74 2063 6f6e 7374 ..{....int const │ │ │ +00042790: 2075 706c 6f61 645f 736c 6f74 7320 3d20 upload_slots = │ │ │ +000427a0: 6765 745f 696e 745f 7365 7474 696e 6728 get_int_setting( │ │ │ +000427b0: 7365 7474 696e 6773 5f70 6163 6b3a 3a75 settings_pack::u │ │ │ +000427c0: 6e63 686f 6b65 5f73 6c6f 7473 5f6c 696d nchoke_slots_lim │ │ │ +000427d0: 6974 293b 0a09 0909 6d5f 7374 6174 735f it);....m_stats_ │ │ │ +000427e0: 636f 756e 7465 7273 2e73 6574 5f76 616c counters.set_val │ │ │ +000427f0: 7565 2863 6f75 6e74 6572 733a 3a6e 756d ue(counters::num │ │ │ +00042800: 5f75 6e63 686f 6b65 5f73 6c6f 7473 2c20 _unchoke_slots, │ │ │ +00042810: 7570 6c6f 6164 5f73 6c6f 7473 293b 0a09 upload_slots);.. │ │ │ +00042820: 097d 0a09 0965 6c73 650a 0909 7b0a 0909 .}...else...{... │ │ │ +00042830: 096d 5f73 7461 7473 5f63 6f75 6e74 6572 .m_stats_counter │ │ │ +00042840: 732e 7365 745f 7661 6c75 6528 636f 756e s.set_value(coun │ │ │ +00042850: 7465 7273 3a3a 6e75 6d5f 756e 6368 6f6b ters::num_unchok │ │ │ +00042860: 655f 736c 6f74 730a 0909 0909 2c20 616c e_slots....., al │ │ │ +00042870: 6c6f 7765 645f 7570 6c6f 6164 5f73 6c6f lowed_upload_slo │ │ │ +00042880: 7473 293b 0a09 097d 0a0a 2369 666e 6465 ts);...}..#ifnde │ │ │ +00042890: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ +000428a0: 455f 4c4f 4747 494e 470a 0909 6966 2028 E_LOGGING...if ( │ │ │ +000428b0: 7368 6f75 6c64 5f6c 6f67 2829 290a 0909 should_log())... │ │ │ +000428c0: 7b0a 0909 0973 6573 7369 6f6e 5f6c 6f67 {....session_log │ │ │ +000428d0: 2822 5245 4341 4c43 554c 4154 4520 554e ("RECALCULATE UN │ │ │ +000428e0: 4348 4f4b 4520 534c 4f54 533a 205b 2070 CHOKE SLOTS: [ p │ │ │ +000428f0: 6565 7273 3a20 2564 2022 0a09 0909 0922 eers: %d "....." │ │ │ +00042900: 656c 6967 6962 6c65 2d70 6565 7273 3a20 eligible-peers: │ │ │ +00042910: 2564 220a 0909 0909 2220 616c 6c6f 7765 %d"....." allowe │ │ │ +00042920: 642d 736c 6f74 733a 2025 6420 5d22 0a09 d-slots: %d ]".. │ │ │ +00042930: 0909 092c 2069 6e74 286d 5f63 6f6e 6e65 ..., int(m_conne │ │ │ +00042940: 6374 696f 6e73 2e73 697a 6528 2929 0a09 ctions.size()).. │ │ │ +00042950: 0909 092c 2069 6e74 2870 6565 7273 2e73 ..., int(peers.s │ │ │ +00042960: 697a 6528 2929 0a3c 2f70 7265 3e3c 2f74 ize()).
    relevanc │ │ │ +000429a0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/session │ │ │ +000429e0: 5f69 6d70 6c2e 6370 703a 3439 3933 3c2f _impl.cpp:4993it mi │ │ │ +00042a00: 6768 7420 6265 2061 206e 6963 6520 6665 ght be a nice fe │ │ │ +00042a10: 6174 7572 6520 6865 7265 2074 6f20 6c69 ature here to li │ │ │ +00042a20: 6d69 7420 7468 6520 6e75 6d62 6572 206f mit the number o │ │ │ +00042a30: 6620 746f 7272 656e 7473 2074 6f20 7365 f torrents to se │ │ │ +00042a40: 6e64 2069 6e20 6120 7369 6e67 6c65 2075 nd in a single u │ │ │ +00042a50: 7064 6174 652e 2042 7920 6a75 7374 2070 pdate. By just p │ │ │ +00042a60: 6f73 7469 6e67 2074 6865 2066 6972 7374 osting the first │ │ │ +00042a70: 206e 2074 6f72 7265 6e74 732c 2074 6865 n torrents, the │ │ │ +00042a80: 7920 776f 756c 6420 6e69 6365 6c79 2062 y would nicely b │ │ │ +00042a90: 6520 726f 756e 642d 726f 6269 6e65 6420 e round-robined │ │ │ +00042aa0: 6265 6361 7573 6520 7468 6520 746f 7272 because the torr │ │ │ +00042ab0: 656e 7420 6c69 7374 7320 6172 6520 616c ent lists are al │ │ │ +00042ac0: 7761 7973 2070 7573 6865 6420 6261 636b ways pushed back │ │ │ +00042ad0: 2e20 5065 7268 6170 7320 7468 6520 7374 . Perhaps the st │ │ │ +00042ae0: 6174 7573 5f75 7064 6174 655f 616c 6572 atus_update_aler │ │ │ +00042af0: 7420 636f 756c 6420 6576 656e 2068 6176 t could even hav │ │ │ +00042b00: 6520 6120 6669 7865 6420 6172 7261 7920 e a fixed array │ │ │ +00042b10: 6f66 206e 2065 6e74 7269 6573 2072 6174 of n entries rat │ │ │ +00042b20: 6865 7220 7468 616e 2061 2076 6563 746f her than a vecto │ │ │ +00042b30: 722c 2074 6f20 6675 7274 6865 7220 696d r, to further im │ │ │ +00042b40: 7072 6f76 6520 6d65 6d6f 7279 206c 6f63 prove memory loc │ │ │ +00042b50: 616c 6974 792e 3c2f 7464 3e3c 2f74 723e ality. │ │ │ +00042b60: 3c74 7220 6964 3d22 3136 3322 2073 7479 │ │ │ +00042b90: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00042ba0: 3c68 323e 6974 206d 6967 6874 2062 6520

    it might be │ │ │ +00042bb0: 6120 6e69 6365 2066 6561 7475 7265 2068 a nice feature h │ │ │ +00042bc0: 6572 6520 746f 206c 696d 6974 2074 6865 ere to limit the │ │ │ +00042bd0: 206e 756d 6265 7220 6f66 2074 6f72 7265 number of torre │ │ │ +00042be0: 6e74 730a 746f 2073 656e 6420 696e 2061 nts.to send in a │ │ │ +00042bf0: 2073 696e 676c 6520 7570 6461 7465 2e20 single update. │ │ │ +00042c00: 4279 206a 7573 7420 706f 7374 696e 6720 By just posting │ │ │ +00042c10: 7468 6520 6669 7273 7420 6e20 746f 7272 the first n torr │ │ │ +00042c20: 656e 7473 2c20 7468 6579 0a77 6f75 6c64 ents, they.would │ │ │ +00042c30: 206e 6963 656c 7920 6265 2072 6f75 6e64 nicely be round │ │ │ +00042c40: 2d72 6f62 696e 6564 2062 6563 6175 7365 -robined because │ │ │ +00042c50: 2074 6865 2074 6f72 7265 6e74 206c 6973 the torrent lis │ │ │ +00042c60: 7473 2061 7265 2061 6c77 6179 730a 7075 ts are always.pu │ │ │ +00042c70: 7368 6564 2062 6163 6b2e 2050 6572 6861 shed back. Perha │ │ │ +00042c80: 7073 2074 6865 2073 7461 7475 735f 7570 ps the status_up │ │ │ +00042c90: 6461 7465 5f61 6c65 7274 2063 6f75 6c64 date_alert could │ │ │ +00042ca0: 2065 7665 6e20 6861 7665 2061 2066 6978 even have a fix │ │ │ +00042cb0: 6564 0a61 7272 6179 206f 6620 6e20 656e ed.array of n en │ │ │ +00042cc0: 7472 6965 7320 7261 7468 6572 2074 6861 tries rather tha │ │ │ +00042cd0: 6e20 6120 7665 6374 6f72 2c20 746f 2066 n a vector, to f │ │ │ +00042ce0: 7572 7468 6572 2069 6d70 726f 7665 206d urther improve m │ │ │ +00042cf0: 656d 6f72 790a 6c6f 6361 6c69 7479 2e3c emory.locality.< │ │ │ +00042d00: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f73 /h2>

    ../src/s │ │ │ +00042d10: 6573 7369 6f6e 5f69 6d70 6c2e 6370 703a ession_impl.cpp: │ │ │ +00042d20: 3439 3933 3c2f 6834 3e3c 7072 6520 7374 4993

    ...t->stat
    │ │ │ +00042d70: 7573 2826 616d 703b 7374 2c20 666c 6167  us(&st, flag
    │ │ │ +00042d80: 7329 3b0a 0909 7d0a 097d 0a0a 0976 6f69  s);...}..}...voi
    │ │ │ +00042d90: 6420 7365 7373 696f 6e5f 696d 706c 3a3a  d session_impl::
    │ │ │ +00042da0: 706f 7374 5f74 6f72 7265 6e74 5f75 7064  post_torrent_upd
    │ │ │ +00042db0: 6174 6573 2873 7461 7475 735f 666c 6167  ates(status_flag
    │ │ │ +00042dc0: 735f 7420 636f 6e73 7420 666c 6167 7329  s_t const flags)
    │ │ │ +00042dd0: 0a09 7b0a 0909 494e 5641 5249 414e 545f  ..{...INVARIANT_
    │ │ │ +00042de0: 4348 4543 4b3b 0a0a 0909 544f 5252 454e  CHECK;....TORREN
    │ │ │ +00042df0: 545f 4153 5345 5254 2869 735f 7369 6e67  T_ASSERT(is_sing
    │ │ │ +00042e00: 6c65 5f74 6872 6561 6428 2929 3b0a 0a09  le_thread());...
    │ │ │ +00042e10: 0973 7464 3a3a 7665 6374 6f72 266c 743b  .std::vector<
    │ │ │ +00042e20: 746f 7272 656e 742a 2667 743b 2661 6d70  torrent*>&
    │ │ │ +00042e30: 3b20 7374 6174 655f 7570 6461 7465 730a  ; state_updates.
    │ │ │ +00042e40: 0909 093d 206d 5f74 6f72 7265 6e74 5f6c  ...= m_torrent_l
    │ │ │ +00042e50: 6973 7473 5b61 7578 3a3a 7365 7373 696f  ists[aux::sessio
    │ │ │ +00042e60: 6e5f 696d 706c 3a3a 746f 7272 656e 745f  n_impl::torrent_
    │ │ │ +00042e70: 7374 6174 655f 7570 6461 7465 735d 3b0a  state_updates];.
    │ │ │ +00042e80: 0a23 6966 2054 4f52 5245 4e54 5f55 5345  .#if TORRENT_USE
    │ │ │ +00042e90: 5f41 5353 4552 5453 0a09 096d 5f70 6f73  _ASSERTS...m_pos
    │ │ │ +00042ea0: 7469 6e67 5f74 6f72 7265 6e74 5f75 7064  ting_torrent_upd
    │ │ │ +00042eb0: 6174 6573 203d 2074 7275 653b 0a23 656e  ates = true;.#en
    │ │ │ +00042ec0: 6469 660a 0a09 0973 7464 3a3a 7665 6374  dif....std::vect
    │ │ │ +00042ed0: 6f72 266c 743b 746f 7272 656e 745f 7374  or<torrent_st
    │ │ │ +00042ee0: 6174 7573 2667 743b 2073 7461 7475 733b  atus> status;
    │ │ │ +00042ef0: 0a09 0973 7461 7475 732e 7265 7365 7276  ...status.reserv
    │ │ │ +00042f00: 6528 7374 6174 655f 7570 6461 7465 732e  e(state_updates.
    │ │ │ +00042f10: 7369 7a65 2829 293b 0a0a 3c64 6976 2073  size());..
    ..for (a │ │ │ +00042f50: 7574 6f26 616d 703b 2074 203a 2073 7461 uto& t : sta │ │ │ +00042f60: 7465 5f75 7064 6174 6573 290a 3c2f 6469 te_updates)...{....TORRENT │ │ │ +00042f80: 5f41 5353 4552 5428 742d 2667 743b 6d5f _ASSERT(t->m_ │ │ │ +00042f90: 6c69 6e6b 735b 6175 783a 3a73 6573 7369 links[aux::sessi │ │ │ +00042fa0: 6f6e 5f69 6d70 6c3a 3a74 6f72 7265 6e74 on_impl::torrent │ │ │ +00042fb0: 5f73 7461 7465 5f75 7064 6174 6573 5d2e _state_updates]. │ │ │ +00042fc0: 696e 5f6c 6973 7428 2929 3b0a 0909 0973 in_list());....s │ │ │ +00042fd0: 7461 7475 732e 656d 706c 6163 655f 6261 tatus.emplace_ba │ │ │ +00042fe0: 636b 2829 3b0a 0909 092f 2f20 7175 6572 ck();....// quer │ │ │ +00042ff0: 7969 6e67 2061 6363 7572 6174 6520 646f ying accurate do │ │ │ +00043000: 776e 6c6f 6164 2063 6f75 6e74 6572 7320 wnload counters │ │ │ +00043010: 6d61 7920 7265 7175 6972 650a 0909 092f may require..../ │ │ │ +00043020: 2f20 7468 6520 746f 7272 656e 7420 746f / the torrent to │ │ │ +00043030: 2062 6520 6c6f 6164 6564 2e20 4c6f 6164 be loaded. Load │ │ │ +00043040: 696e 6720 6120 746f 7272 656e 742c 2061 ing a torrent, a │ │ │ +00043050: 6e64 2065 7669 6374 696e 6720 616e 6f74 nd evicting anot │ │ │ +00043060: 6865 720a 0909 092f 2f20 6f6e 6520 7769 her....// one wi │ │ │ +00043070: 6c6c 206c 6561 6420 746f 2063 616c 6c69 ll lead to calli │ │ │ +00043080: 6e67 2073 7461 7465 5f75 7064 6174 6564 ng state_updated │ │ │ +00043090: 2829 2c20 7768 6963 6820 7363 7265 7773 (), which screws │ │ │ +000430a0: 2077 6974 680a 0909 092f 2f20 7468 6973 with....// this │ │ │ +000430b0: 206c 6973 7420 7768 696c 6520 7765 2772 list while we'r │ │ │ +000430c0: 6520 776f 726b 696e 6720 6f6e 2069 742c e working on it, │ │ │ +000430d0: 2061 6e64 2062 7265 616b 2074 6869 6e67 and break thing │ │ │ +000430e0: 730a 0909 0974 2d26 6774 3b73 7461 7475 s....t->statu │ │ │ +000430f0: 7328 2661 6d70 3b73 7461 7475 732e 6261 s(&status.ba │ │ │ +00043100: 636b 2829 2c20 666c 6167 7329 3b0a 0909 ck(), flags);... │ │ │ +00043110: 0974 2d26 6774 3b63 6c65 6172 5f69 6e5f .t->clear_in_ │ │ │ +00043120: 7374 6174 655f 7570 6461 7465 2829 3b0a state_update();. │ │ │ +00043130: 0909 7d0a 0909 7374 6174 655f 7570 6461 ..}...state_upda │ │ │ +00043140: 7465 732e 636c 6561 7228 293b 0a0a 2369 tes.clear();..#i │ │ │ +00043150: 6620 544f 5252 454e 545f 5553 455f 4153 f TORRENT_USE_AS │ │ │ +00043160: 5345 5254 530a 0909 6d5f 706f 7374 696e SERTS...m_postin │ │ │ +00043170: 675f 746f 7272 656e 745f 7570 6461 7465 g_torrent_update │ │ │ +00043180: 7320 3d20 6661 6c73 653b 0a23 656e 6469 s = false;.#endi │ │ │ +00043190: 660a 0a09 096d 5f61 6c65 7274 732e 656d f....m_alerts.em │ │ │ +000431a0: 706c 6163 655f 616c 6572 7426 6c74 3b73 place_alert<s │ │ │ +000431b0: 7461 7465 5f75 7064 6174 655f 616c 6572 tate_update_aler │ │ │ +000431c0: 7426 6774 3b28 7374 643a 3a6d 6f76 6528 t>(std::move( │ │ │ +000431d0: 7374 6174 7573 2929 3b0a 097d 0a0a 0976 status));..}...v │ │ │ +000431e0: 6f69 6420 7365 7373 696f 6e5f 696d 706c oid session_impl │ │ │ +000431f0: 3a3a 706f 7374 5f73 6573 7369 6f6e 5f73 ::post_session_s │ │ │ +00043200: 7461 7473 2829 0a09 7b0a 0909 6966 2028 tats()..{...if ( │ │ │ +00043210: 216d 5f70 6f73 7465 645f 7374 6174 735f !m_posted_stats_ │ │ │ +00043220: 6865 6164 6572 290a 0909 7b0a 0909 096d header)...{....m │ │ │ +00043230: 5f70 6f73 7465 645f 7374 6174 735f 6865 _posted_stats_he │ │ │ +00043240: 6164 6572 203d 2074 7275 653b 0a09 0909 ader = true;.... │ │ │ +00043250: 6d5f 616c 6572 7473 2e65 6d70 6c61 6365 m_alerts.emplace │ │ │ +00043260: 5f61 6c65 7274 266c 743b 7365 7373 696f _alert<sessio │ │ │ +00043270: 6e5f 7374 6174 735f 6865 6164 6572 5f61 n_stats_header_a │ │ │ +00043280: 6c65 7274 2667 743b 2829 3b0a 0909 7d0a lert>();...}. │ │ │ +00043290: 0909 6d5f 6469 736b 5f74 6872 6561 642d ..m_disk_thread- │ │ │ +000432a0: 2667 743b 7570 6461 7465 5f73 7461 7473 >update_stats │ │ │ +000432b0: 5f63 6f75 6e74 6572 7328 6d5f 7374 6174 _counters(m_stat │ │ │ +000432c0: 735f 636f 756e 7465 7273 293b 0a0a 2369 s_counters);..#i │ │ │ +000432d0: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ +000432e0: 5341 424c 455f 4448 540a 0909 6966 2028 SABLE_DHT...if ( │ │ │ +000432f0: 6d5f 6468 7429 0a3c 2f70 7265 3e3c 2f74 m_dht).
    relevanc │ │ │ +00043330: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0
    ../src/session │ │ │ +00043370: 5f69 6d70 6c2e 6370 703a 3533 3837 3c2f _impl.cpp:5387facto │ │ │ +00043390: 7220 6f75 7420 7468 6973 206c 6f67 6963 r out this logic │ │ │ +000433a0: 2069 6e74 6f20 6120 7365 7061 7261 7465 into a separate │ │ │ +000433b0: 2066 756e 6374 696f 6e20 666f 7220 756e function for un │ │ │ +000433c0: 6974 2074 6573 7469 6e67 3c2f 7464 3e3c it testing< │ │ │ +000433d0: 2f74 723e 3c74 7220 6964 3d22 3136 3422 /tr>

    factor o │ │ │ +00043420: 7574 2074 6869 7320 6c6f 6769 6320 696e ut this logic in │ │ │ +00043430: 746f 2061 2073 6570 6172 6174 6520 6675 to a separate fu │ │ │ +00043440: 6e63 7469 6f6e 2066 6f72 2075 6e69 740a nction for unit. │ │ │ +00043450: 7465 7374 696e 673c 2f68 323e 3c68 343e testing

    │ │ │ +00043460: 2e2e 2f73 7263 2f73 6573 7369 6f6e 5f69 ../src/session_i │ │ │ +00043470: 6d70 6c2e 6370 703a 3533 3837 3c2f 6834 mpl.cpp:5387

    ..if 
    │ │ │ +000434c0: 286d 5f73 6574 7469 6e67 732e 6765 745f  (m_settings.get_
    │ │ │ +000434d0: 696e 7428 7365 7474 696e 6773 5f70 6163  int(settings_pac
    │ │ │ +000434e0: 6b3a 3a6f 7574 676f 696e 675f 706f 7274  k::outgoing_port
    │ │ │ +000434f0: 2920 2667 743b 2030 290a 0909 7b0a 2369  ) > 0)...{.#i
    │ │ │ +00043500: 6664 6566 2054 4f52 5245 4e54 5f57 494e  fdef TORRENT_WIN
    │ │ │ +00043510: 444f 5753 0a09 0909 732e 7365 745f 6f70  DOWS....s.set_op
    │ │ │ +00043520: 7469 6f6e 2865 7863 6c75 7369 7665 5f61  tion(exclusive_a
    │ │ │ +00043530: 6464 7265 7373 5f75 7365 2874 7275 6529  ddress_use(true)
    │ │ │ +00043540: 2c20 6563 293b 0a23 656c 7365 0a09 0909  , ec);.#else....
    │ │ │ +00043550: 732e 7365 745f 6f70 7469 6f6e 2874 6370  s.set_option(tcp
    │ │ │ +00043560: 3a3a 6163 6365 7074 6f72 3a3a 7265 7573  ::acceptor::reus
    │ │ │ +00043570: 655f 6164 6472 6573 7328 7472 7565 292c  e_address(true),
    │ │ │ +00043580: 2065 6329 3b0a 2365 6e64 6966 0a09 0909   ec);.#endif....
    │ │ │ +00043590: 2f2f 2069 676e 6f72 6520 6572 726f 7273  // ignore errors
    │ │ │ +000435a0: 2062 6563 6175 7365 2074 6865 2075 6e64   because the und
    │ │ │ +000435b0: 6572 6c79 696e 6720 736f 636b 6574 206d  erlying socket m
    │ │ │ +000435c0: 6179 206e 6f74 0a09 0909 2f2f 2062 6520  ay not....// be 
    │ │ │ +000435d0: 6f70 656e 6564 2079 6574 2e20 5468 6973  opened yet. This
    │ │ │ +000435e0: 2068 6170 7065 6e73 2077 6865 6e20 7765   happens when we
    │ │ │ +000435f0: 2772 6520 726f 7574 696e 6720 7468 726f  're routing thro
    │ │ │ +00043600: 7567 680a 0909 092f 2f20 6120 7072 6f78  ugh....// a prox
    │ │ │ +00043610: 792e 2049 6e20 7468 6174 2063 6173 652c  y. In that case,
    │ │ │ +00043620: 2077 6520 646f 6e27 7420 7965 7420 6b6e   we don't yet kn
    │ │ │ +00043630: 6f77 2074 6865 2061 6464 7265 7373 206f  ow the address o
    │ │ │ +00043640: 660a 0909 092f 2f20 7468 6520 7072 6f78  f....// the prox
    │ │ │ +00043650: 7920 7365 7276 6572 2c20 616e 6420 6d6f  y server, and mo
    │ │ │ +00043660: 7265 2069 6d70 6f72 7461 6e74 6c79 2c20  re importantly, 
    │ │ │ +00043670: 7765 2064 6f6e 2774 206b 6e6f 770a 0909  we don't know...
    │ │ │ +00043680: 092f 2f20 7468 6520 6164 6472 6573 7320  .// the address 
    │ │ │ +00043690: 6661 6d69 6c79 206f 6620 6974 7320 6164  family of its ad
    │ │ │ +000436a0: 6472 6573 732e 2054 6869 7320 6d65 616e  dress. This mean
    │ │ │ +000436b0: 7320 7765 2063 616e 2774 0a09 0909 2f2f  s we can't....//
    │ │ │ +000436c0: 206f 7065 6e20 7468 6520 736f 636b 6574   open the socket
    │ │ │ +000436d0: 2079 6574 2e20 5468 6520 736f 636b 7320   yet. The socks 
    │ │ │ +000436e0: 6162 7374 7261 6374 696f 6e20 6c61 7965  abstraction laye
    │ │ │ +000436f0: 7220 6465 6665 7273 0a09 0909 2f2f 206f  r defers....// o
    │ │ │ +00043700: 7065 6e69 6e67 2069 742e 0a09 0909 6563  pening it.....ec
    │ │ │ +00043710: 2e63 6c65 6172 2829 3b0a 0909 0962 696e  .clear();....bin
    │ │ │ +00043720: 645f 6570 2e70 6f72 7428 7374 643a 3a75  d_ep.port(std::u
    │ │ │ +00043730: 696e 7431 365f 7428 6e65 7874 5f70 6f72  int16_t(next_por
    │ │ │ +00043740: 7428 2929 293b 0a09 097d 0a0a 0909 6966  t()));...}....if
    │ │ │ +00043750: 2028 6973 5f75 7470 2873 2929 0a09 097b   (is_utp(s))...{
    │ │ │ +00043760: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +00043790: 3c2f 6469 763e 0909 0975 7470 5f73 6f63
    ...utp_soc │ │ │ +000437a0: 6b65 745f 696d 706c 2a20 696d 706c 203d ket_impl* impl = │ │ │ +000437b0: 206e 756c 6c70 7472 3b0a 0909 0974 7261 nullptr;....tra │ │ │ +000437c0: 6e73 706f 7274 2073 736c 203d 2074 7261 nsport ssl = tra │ │ │ +000437d0: 6e73 706f 7274 3a3a 706c 6169 6e74 6578 nsport::plaintex │ │ │ +000437e0: 743b 0a23 6966 2054 4f52 5245 4e54 5f55 t;.#if TORRENT_U │ │ │ +000437f0: 5345 5f53 534c 0a09 0909 6966 2028 7374 SE_SSL....if (st │ │ │ +00043800: 643a 3a67 6574 5f69 6626 6c74 3b73 736c d::get_if<ssl │ │ │ +00043810: 5f73 7472 6561 6d26 6c74 3b75 7470 5f73 _stream<utp_s │ │ │ +00043820: 7472 6561 6d26 6774 3b26 6774 3b28 2661 tream>>(&a │ │ │ +00043830: 6d70 3b73 2e76 6172 2829 2920 213d 206e mp;s.var()) != n │ │ │ +00043840: 756c 6c70 7472 290a 0909 097b 0a09 0909 ullptr)....{.... │ │ │ +00043850: 0969 6d70 6c20 3d20 7374 643a 3a67 6574 .impl = std::get │ │ │ +00043860: 266c 743b 7373 6c5f 7374 7265 616d 266c <ssl_stream&l │ │ │ +00043870: 743b 7574 705f 7374 7265 616d 2667 743b t;utp_stream> │ │ │ +00043880: 2667 743b 2873 292e 6e65 7874 5f6c 6179 >(s).next_lay │ │ │ +00043890: 6572 2829 2e67 6574 5f69 6d70 6c28 293b er().get_impl(); │ │ │ +000438a0: 0a09 0909 0973 736c 203d 2074 7261 6e73 .....ssl = trans │ │ │ +000438b0: 706f 7274 3a3a 7373 6c3b 0a09 0909 7d0a port::ssl;....}. │ │ │ +000438c0: 0909 0965 6c73 650a 2365 6e64 6966 0a09 ...else.#endif.. │ │ │ +000438d0: 0909 0969 6d70 6c20 3d20 7374 643a 3a67 ...impl = std::g │ │ │ +000438e0: 6574 266c 743b 7574 705f 7374 7265 616d et<utp_stream │ │ │ +000438f0: 2667 743b 2873 292e 6765 745f 696d 706c >(s).get_impl │ │ │ +00043900: 2829 3b0a 0a09 0909 7374 643a 3a76 6563 ();.....std::vec │ │ │ +00043910: 746f 7226 6c74 3b73 7464 3a3a 7368 6172 tor<std::shar │ │ │ +00043920: 6564 5f70 7472 266c 743b 6c69 7374 656e ed_ptr<listen │ │ │ +00043930: 5f73 6f63 6b65 745f 7426 6774 3b26 6774 _socket_t>> │ │ │ +00043940: 3b20 7769 7468 5f67 6174 6577 6179 733b ; with_gateways; │ │ │ +00043950: 0a09 0909 7374 643a 3a73 6861 7265 645f ....std::shared_ │ │ │ +00043960: 7074 7226 6c74 3b6c 6973 7465 6e5f 736f ptr<listen_so │ │ │ +00043970: 636b 6574 5f74 2667 743b 206d 6174 6368 cket_t> match │ │ │ +00043980: 3b0a 0909 0966 6f72 2028 6175 746f 2063 ;....for (auto c │ │ │ +00043990: 6f6e 7374 2661 6d70 3b20 6c73 203a 206d onst& ls : m │ │ │ +000439a0: 5f6c 6973 7465 6e5f 736f 636b 6574 7329 _listen_sockets) │ │ │ +000439b0: 0a09 0909 7b0a 0909 0909 2f2f 2074 6869 ....{.....// thi │ │ │ +000439c0: 7320 6973 2061 6c6d 6f73 742c 2062 7574 s is almost, but │ │ │ +000439d0: 206e 6f74 2071 7569 7465 2c20 6c69 6b65 not quite, like │ │ │ +000439e0: 2063 616e 5f72 6f75 7465 2829 0a09 0909 can_route().... │ │ │ +000439f0: 0969 6620 2821 286c 732d 2667 743b 666c .if (!(ls->fl │ │ │ +00043a00: 6167 7320 2661 6d70 3b20 6c69 7374 656e ags & listen │ │ │ +00043a10: 5f73 6f63 6b65 745f 743a 3a70 726f 7879 _socket_t::proxy │ │ │ +00043a20: 290a 0909 0909 0926 616d 703b 2661 6d70 )......&& │ │ │ +00043a30: 3b20 6973 5f76 3428 6c73 2d26 6774 3b6c ; is_v4(ls->l │ │ │ +00043a40: 6f63 616c 5f65 6e64 706f 696e 7429 2021 ocal_endpoint) ! │ │ │ +00043a50: 3d20 7265 6d6f 7465 5f61 6464 7265 7373 = remote_address │ │ │ +00043a60: 2e69 735f 7634 2829 290a 0909 0909 0963 .is_v4())......c │ │ │ +00043a70: 6f6e 7469 6e75 653b 0a09 0909 0969 6620 ontinue;.....if │ │ │ +00043a80: 286c 732d 2667 743b 7373 6c20 213d 2073 (ls->ssl != s │ │ │ +00043a90: 736c 2920 636f 6e74 696e 7565 3b0a 0909 sl) continue;... │ │ │ +00043aa0: 0909 6966 2028 2128 6c73 2d26 6774 3b66 ..if (!(ls->f │ │ │ +00043ab0: 6c61 6773 2026 616d 703b 206c 6973 7465 lags & liste │ │ │ +00043ac0: 6e5f 736f 636b 6574 5f74 3a3a 6c6f 6361 n_socket_t::loca │ │ │ +00043ad0: 6c5f 6e65 7477 6f72 6b29 290a 0909 0909 l_network))..... │ │ │ +00043ae0: 0977 6974 685f 6761 7465 7761 7973 2e70 .with_gateways.p │ │ │ +00043af0: 7573 685f 6261 636b 286c 7329 3b0a 0a09 ush_back(ls);... │ │ │ +00043b00: 0909 0969 6620 286c 732d 2667 743b 666c ...if (ls->fl │ │ │ +00043b10: 6167 7320 2661 6d70 3b20 6c69 7374 656e ags & listen │ │ │ +00043b20: 5f73 6f63 6b65 745f 743a 3a70 726f 7879 _socket_t::proxy │ │ │ +00043b30: 0a09 0909 0909 7c7c 206d 6174 6368 5f61 ......|| match_a │ │ │ +00043b40: 6464 725f 6d61 736b 286c 732d 2667 743b ddr_mask(ls-> │ │ │ +00043b50: 6c6f 6361 6c5f 656e 6470 6f69 6e74 2e61 local_endpoint.a │ │ │ +00043b60: 6464 7265 7373 2829 2c20 7265 6d6f 7465 ddress(), remote │ │ │ +00043b70: 5f61 6464 7265 7373 2c20 6c73 2d26 6774 _address, ls-> │ │ │ +00043b80: 3b6e 6574 6d61 736b 2929 0a09 0909 097b ;netmask)).....{ │ │ │ +00043b90: 0a09 0909 0909 2f2f 2069 7320 7468 6973 ......// is this │ │ │ +00043ba0: 2062 6574 7465 7220 7468 616e 2074 6865 better than the │ │ │ +00043bb0: 2070 7265 7669 6f75 7320 6d61 7463 683f previous match? │ │ │ +00043bc0: 0a09 0909 0909 6d61 7463 6820 3d20 6c73 ......match = ls │ │ │ +00043bd0: 3b0a 0909 0909 7d0a 3c2f 7072 653e 3c2f ;.....}.
    relevan │ │ │ +00043c10: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0
    ../src/sessio │ │ │ +00043c50: 6e5f 696d 706c 2e63 7070 3a36 3131 393c n_impl.cpp:6119< │ │ │ +00043c60: 2f61 3e3c 2f74 643e 3c74 643e 7265 6661 /a>refa │ │ │ +00043c70: 6374 6f72 2c20 6d6f 7665 2074 6865 2073 ctor, move the s │ │ │ +00043c80: 746f 7261 6765 2074 6f20 6468 745f 7472 torage to dht_tr │ │ │ +00043c90: 6163 6b65 723c 2f74 643e 3c2f 7472 3e3c acker< │ │ │ +00043ca0: 7472 2069 643d 2231 3635 2220 7374 796c tr id="165" styl │ │ │ +00043cb0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00043cc0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00043cd0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00043ce0: 6832 3e72 6566 6163 746f 722c 206d 6f76 h2>refactor, mov │ │ │ +00043cf0: 6520 7468 6520 7374 6f72 6167 6520 746f e the storage to │ │ │ +00043d00: 2064 6874 5f74 7261 636b 6572 3c2f 6832 dht_tracker

    ../src/sess │ │ │ +00043d20: 696f 6e5f 696d 706c 2e63 7070 3a36 3131 ion_impl.cpp:611 │ │ │ +00043d30: 393c 2f68 343e 3c70 7265 2073 7479 6c65 9

    │ │ │ +00043d70: 2369 666e 6465 6620 544f 5252 454e 545f  #ifndef TORRENT_
    │ │ │ +00043d80: 4449 5341 424c 455f 4c4f 4747 494e 470a  DISABLE_LOGGING.
    │ │ │ +00043d90: 0909 0973 6573 7369 6f6e 5f6c 6f67 2822  ...session_log("
    │ │ │ +00043da0: 6e6f 7420 7374 6172 7469 6e67 2044 4854  not starting DHT
    │ │ │ +00043db0: 2c20 6f75 7473 7461 6e64 696e 6720 726f  , outstanding ro
    │ │ │ +00043dc0: 7574 6572 206c 6f6f 6b75 7073 3a20 2564  uter lookups: %d
    │ │ │ +00043dd0: 220a 0909 0909 2c20 6d5f 6f75 7473 7461  "....., m_outsta
    │ │ │ +00043de0: 6e64 696e 675f 726f 7574 6572 5f6c 6f6f  nding_router_loo
    │ │ │ +00043df0: 6b75 7073 293b 0a23 656e 6469 660a 0909  kups);.#endif...
    │ │ │ +00043e00: 0972 6574 7572 6e3b 0a09 097d 0a0a 0909  .return;...}....
    │ │ │ +00043e10: 6966 2028 6d5f 6162 6f72 7429 0a09 097b  if (m_abort)...{
    │ │ │ +00043e20: 0a23 6966 6e64 6566 2054 4f52 5245 4e54  .#ifndef TORRENT
    │ │ │ +00043e30: 5f44 4953 4142 4c45 5f4c 4f47 4749 4e47  _DISABLE_LOGGING
    │ │ │ +00043e40: 0a09 0909 7365 7373 696f 6e5f 6c6f 6728  ....session_log(
    │ │ │ +00043e50: 226e 6f74 2073 7461 7274 696e 6720 4448  "not starting DH
    │ │ │ +00043e60: 542c 2061 626f 7274 696e 6722 293b 0a23  T, aborting");.#
    │ │ │ +00043e70: 656e 6469 660a 0909 0972 6574 7572 6e3b  endif....return;
    │ │ │ +00043e80: 0a09 097d 0a0a 2369 666e 6465 6620 544f  ...}..#ifndef TO
    │ │ │ +00043e90: 5252 454e 545f 4449 5341 424c 455f 4c4f  RRENT_DISABLE_LO
    │ │ │ +00043ea0: 4747 494e 470a 0909 7365 7373 696f 6e5f  GGING...session_
    │ │ │ +00043eb0: 6c6f 6728 2273 7461 7274 696e 6720 4448  log("starting DH
    │ │ │ +00043ec0: 542c 2072 756e 6e69 6e67 3a20 2573 2c20  T, running: %s, 
    │ │ │ +00043ed0: 726f 7574 6572 206c 6f6f 6b75 7073 3a20  router lookups: 
    │ │ │ +00043ee0: 2564 220a 0909 092c 206d 5f64 6874 203f  %d"...., m_dht ?
    │ │ │ +00043ef0: 2022 7472 7565 2220 3a20 2266 616c 7365   "true" : "false
    │ │ │ +00043f00: 222c 206d 5f6f 7574 7374 616e 6469 6e67  ", m_outstanding
    │ │ │ +00043f10: 5f72 6f75 7465 725f 6c6f 6f6b 7570 7329  _router_lookups)
    │ │ │ +00043f20: 3b0a 2365 6e64 6966 0a0a 3c64 6976 2073  ;.#endif..
    ..m_dht_ │ │ │ +00043f60: 7374 6f72 6167 6520 3d20 6d5f 6468 745f storage = m_dht_ │ │ │ +00043f70: 7374 6f72 6167 655f 636f 6e73 7472 7563 storage_construc │ │ │ +00043f80: 746f 7228 6d5f 7365 7474 696e 6773 293b tor(m_settings); │ │ │ +00043f90: 0a3c 2f64 6976 3e09 096d 5f64 6874 203d .
    ..m_dht = │ │ │ +00043fa0: 2073 7464 3a3a 6d61 6b65 5f73 6861 7265 std::make_share │ │ │ +00043fb0: 6426 6c74 3b64 6874 3a3a 6468 745f 7472 d<dht::dht_tr │ │ │ +00043fc0: 6163 6b65 7226 6774 3b28 0a09 0909 7374 acker>(....st │ │ │ +00043fd0: 6174 6963 5f63 6173 7426 6c74 3b64 6874 atic_cast<dht │ │ │ +00043fe0: 3a3a 6468 745f 6f62 7365 7276 6572 2a26 ::dht_observer*& │ │ │ +00043ff0: 6774 3b28 7468 6973 290a 0909 092c 206d gt;(this)...., m │ │ │ +00044000: 5f69 6f5f 636f 6e74 6578 740a 0909 092c _io_context...., │ │ │ +00044010: 205b 7468 6973 5d28 6175 783a 3a6c 6973 [this](aux::lis │ │ │ +00044020: 7465 6e5f 736f 636b 6574 5f68 616e 646c ten_socket_handl │ │ │ +00044030: 6520 636f 6e73 7426 616d 703b 2073 6f63 e const& soc │ │ │ +00044040: 6b0a 0909 0909 2c20 7564 703a 3a65 6e64 k....., udp::end │ │ │ +00044050: 706f 696e 7420 636f 6e73 7426 616d 703b point const& │ │ │ +00044060: 2065 700a 0909 0909 2c20 7370 616e 266c ep....., span&l │ │ │ +00044070: 743b 6368 6172 2063 6f6e 7374 2667 743b t;char const> │ │ │ +00044080: 2070 0a09 0909 092c 2065 7272 6f72 5f63 p....., error_c │ │ │ +00044090: 6f64 6526 616d 703b 2065 630a 0909 0909 ode& ec..... │ │ │ +000440a0: 2c20 7564 705f 7365 6e64 5f66 6c61 6773 , udp_send_flags │ │ │ +000440b0: 5f74 2063 6f6e 7374 2066 6c61 6773 290a _t const flags). │ │ │ +000440c0: 0909 0909 7b20 7365 6e64 5f75 6470 5f70 ....{ send_udp_p │ │ │ +000440d0: 6163 6b65 745f 6c69 7374 656e 2873 6f63 acket_listen(soc │ │ │ +000440e0: 6b2c 2065 702c 2070 2c20 6563 2c20 666c k, ep, p, ec, fl │ │ │ +000440f0: 6167 7329 3b20 7d0a 0909 092c 206d 5f73 ags); }...., m_s │ │ │ +00044100: 6574 7469 6e67 730a 0909 092c 206d 5f73 ettings...., m_s │ │ │ +00044110: 7461 7473 5f63 6f75 6e74 6572 730a 0909 tats_counters... │ │ │ +00044120: 092c 202a 6d5f 6468 745f 7374 6f72 6167 ., *m_dht_storag │ │ │ +00044130: 650a 0909 092c 2073 7464 3a3a 6d6f 7665 e...., std::move │ │ │ +00044140: 286d 5f64 6874 5f73 7461 7465 2929 3b0a (m_dht_state));. │ │ │ +00044150: 0a09 0966 6f72 2028 6175 746f 2661 6d70 ...for (auto& │ │ │ +00044160: 3b20 7320 3a20 6d5f 6c69 7374 656e 5f73 ; s : m_listen_s │ │ │ +00044170: 6f63 6b65 7473 290a 0909 7b0a 0909 0969 ockets)...{....i │ │ │ +00044180: 6620 2873 2d26 6774 3b73 736c 2021 3d20 f (s->ssl != │ │ │ +00044190: 7472 616e 7370 6f72 743a 3a73 736c 0a09 transport::ssl.. │ │ │ +000441a0: 0909 0926 616d 703b 2661 6d70 3b20 2128 ...&& !( │ │ │ +000441b0: 732d 2667 743b 666c 6167 7320 2661 6d70 s->flags & │ │ │ +000441c0: 3b20 6c69 7374 656e 5f73 6f63 6b65 745f ; listen_socket_ │ │ │ +000441d0: 743a 3a6c 6f63 616c 5f6e 6574 776f 726b t::local_network │ │ │ +000441e0: 2929 0a09 0909 7b0a 0909 0909 6d5f 6468 ))....{.....m_dh │ │ │ +000441f0: 742d 2667 743b 6e65 775f 736f 636b 6574 t->new_socket │ │ │ +00044200: 2873 293b 0a09 0909 7d0a 0909 7d0a 0a09 (s);....}...}... │ │ │ +00044210: 0966 6f72 2028 6175 746f 2063 6f6e 7374 .for (auto const │ │ │ +00044220: 2661 6d70 3b20 6e20 3a20 6d5f 6468 745f & n : m_dht_ │ │ │ +00044230: 726f 7574 6572 5f6e 6f64 6573 290a 0909 router_nodes)... │ │ │ +00044240: 7b0a 0909 096d 5f64 6874 2d26 6774 3b61 {....m_dht->a │ │ │ +00044250: 6464 5f72 6f75 7465 725f 6e6f 6465 286e dd_router_node(n │ │ │ +00044260: 293b 0a09 097d 0a0a 0909 666f 7220 2861 );...}....for (a │ │ │ +00044270: 7574 6f20 636f 6e73 7426 616d 703b 206e uto const& n │ │ │ +00044280: 203a 206d 5f64 6874 5f6e 6f64 6573 290a : m_dht_nodes). │ │ │ +00044290: 0909 7b0a 3c2f 7072 653e 3c2f 7464 3e3c ..{.
    < │ │ │ +000442a0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +000442d0: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0
    . │ │ │ +00044300: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ +00044310: 706c 2e63 7070 3a36 3530 323c 2f61 3e3c pl.cpp:6502< │ │ │ +00044320: 2f74 643e 3c74 643e 6173 7365 7274 7320 /td>asserts │ │ │ +00044330: 7468 6174 206e 6f20 6f75 7473 7461 6e64 that no outstand │ │ │ +00044340: 696e 6720 6173 796e 6320 6f70 6572 6174 ing async operat │ │ │ +00044350: 696f 6e73 2061 7265 2073 7469 6c6c 2069 ions are still i │ │ │ +00044360: 6e20 666c 6967 6874 3c2f 7464 3e3c 2f74 n flight

    asserts th │ │ │ +000443c0: 6174 206e 6f20 6f75 7473 7461 6e64 696e at no outstandin │ │ │ +000443d0: 6720 6173 796e 6320 6f70 6572 6174 696f g async operatio │ │ │ +000443e0: 6e73 2061 7265 2073 7469 6c6c 2069 6e20 ns are still in │ │ │ +000443f0: 666c 6967 6874 3c2f 6832 3e3c 6834 3e2e flight

    . │ │ │ +00044400: 2e2f 7372 632f 7365 7373 696f 6e5f 696d ./src/session_im │ │ │ +00044410: 706c 2e63 7070 3a36 3530 323c 2f68 343e pl.cpp:6502

    │ │ │ +00044420: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ..if (
    │ │ │ +00044460: 216d 5f64 6874 2920 7265 7475 726e 3b0a  !m_dht) return;.
    │ │ │ +00044470: 0909 6d5f 6468 742d 2667 743b 6469 7265  ..m_dht->dire
    │ │ │ +00044480: 6374 5f72 6571 7565 7374 2865 702c 2065  ct_request(ep, e
    │ │ │ +00044490: 2c20 7374 643a 3a62 696e 6428 2661 6d70  , std::bind(&
    │ │ │ +000444a0: 3b6f 6e5f 6469 7265 6374 5f72 6573 706f  ;on_direct_respo
    │ │ │ +000444b0: 6e73 652c 2073 7464 3a3a 7265 6628 6d5f  nse, std::ref(m_
    │ │ │ +000444c0: 616c 6572 7473 292c 2075 7365 7264 6174  alerts), userdat
    │ │ │ +000444d0: 612c 205f 3129 293b 0a09 7d0a 0a23 656e  a, _1));..}..#en
    │ │ │ +000444e0: 6469 660a 0a09 626f 6f6c 2073 6573 7369  dif...bool sessi
    │ │ │ +000444f0: 6f6e 5f69 6d70 6c3a 3a69 735f 6c69 7374  on_impl::is_list
    │ │ │ +00044500: 656e 696e 6728 2920 636f 6e73 740a 097b  ening() const..{
    │ │ │ +00044510: 0a09 0972 6574 7572 6e20 216d 5f6c 6973  ...return !m_lis
    │ │ │ +00044520: 7465 6e5f 736f 636b 6574 732e 656d 7074  ten_sockets.empt
    │ │ │ +00044530: 7928 293b 0a09 7d0a 0a09 7365 7373 696f  y();..}...sessio
    │ │ │ +00044540: 6e5f 696d 706c 3a3a 7e73 6573 7369 6f6e  n_impl::~session
    │ │ │ +00044550: 5f69 6d70 6c28 290a 097b 0a09 092f 2f20  _impl()..{...// 
    │ │ │ +00044560: 7369 6e63 6520 7765 2772 6520 6465 7374  since we're dest
    │ │ │ +00044570: 7275 6374 696e 6720 7468 6520 7365 7373  ructing the sess
    │ │ │ +00044580: 696f 6e2c 206e 6f20 6d6f 7265 2061 6c65  ion, no more ale
    │ │ │ +00044590: 7274 7320 7769 6c6c 206d 616b 6520 6974  rts will make it
    │ │ │ +000445a0: 206f 7574 2074 6f0a 0909 2f2f 2074 6865   out to...// the
    │ │ │ +000445b0: 2075 7365 722e 2053 6f20 7374 6f70 2070   user. So stop p
    │ │ │ +000445c0: 6f73 7469 6e67 2074 6865 6d20 6e6f 770a  osting them now.
    │ │ │ +000445d0: 0909 6d5f 616c 6572 7473 2e73 6574 5f61  ..m_alerts.set_a
    │ │ │ +000445e0: 6c65 7274 5f6d 6173 6b28 7b7d 293b 0a09  lert_mask({});..
    │ │ │ +000445f0: 096d 5f61 6c65 7274 732e 7365 745f 6e6f  .m_alerts.set_no
    │ │ │ +00044600: 7469 6679 5f66 756e 6374 696f 6e28 7b7d  tify_function({}
    │ │ │ +00044610: 293b 0a0a 0909 2f2f 2074 6869 7320 6973  );....// this is
    │ │ │ +00044620: 206e 6f74 2061 6c6c 6f77 6564 2074 6f20   not allowed to 
    │ │ │ +00044630: 6265 2074 6865 206e 6574 776f 726b 2074  be the network t
    │ │ │ +00044640: 6872 6561 6421 0a2f 2f09 0954 4f52 5245  hread!.//..TORRE
    │ │ │ +00044650: 4e54 5f41 5353 4552 5428 6973 5f6e 6f74  NT_ASSERT(is_not
    │ │ │ +00044660: 5f74 6872 6561 6428 2929 3b0a 3c64 6976  _thread());.
    .
    ..// this can h │ │ │ +000446b0: 6170 7065 6e20 6966 2077 6520 656e 6420 appen if we end │ │ │ +000446c0: 7468 6520 696f 5f63 6f6e 7465 7874 2072 the io_context r │ │ │ +000446d0: 756e 206c 6f6f 7020 7769 7468 2061 6e20 un loop with an │ │ │ +000446e0: 6578 6365 7074 696f 6e0a 0909 6d5f 636f exception...m_co │ │ │ +000446f0: 6e6e 6563 7469 6f6e 732e 636c 6561 7228 nnections.clear( │ │ │ +00044700: 293b 0a09 0966 6f72 2028 6175 746f 2661 );...for (auto&a │ │ │ +00044710: 6d70 3b20 7420 3a20 6d5f 746f 7272 656e mp; t : m_torren │ │ │ +00044720: 7473 290a 0909 7b0a 0909 0974 2d26 6774 ts)...{....t-> │ │ │ +00044730: 3b70 616e 6963 2829 3b0a 0909 0974 2d26 ;panic();....t-& │ │ │ +00044740: 6774 3b61 626f 7274 2829 3b0a 0909 7d0a gt;abort();...}. │ │ │ +00044750: 0909 6d5f 746f 7272 656e 7473 2e63 6c65 ..m_torrents.cle │ │ │ +00044760: 6172 2829 3b0a 0a09 092f 2f20 7468 6973 ar();....// this │ │ │ +00044770: 2068 6173 2070 726f 6261 626c 7920 6265 has probably be │ │ │ +00044780: 656e 2063 616c 6c65 6420 616c 7265 6164 en called alread │ │ │ +00044790: 792c 2062 7574 2069 6e20 6361 7365 206f y, but in case o │ │ │ +000447a0: 6620 7375 6464 656e 0a09 092f 2f20 7465 f sudden...// te │ │ │ +000447b0: 726d 696e 6174 696f 6e20 7468 726f 7567 rmination throug │ │ │ +000447c0: 6820 616e 2065 7863 6570 7469 6f6e 2c20 h an exception, │ │ │ +000447d0: 6974 206d 6179 206e 6f74 2068 6176 6520 it may not have │ │ │ +000447e0: 6265 656e 2064 6f6e 650a 0909 6162 6f72 been done...abor │ │ │ +000447f0: 745f 7374 6167 6532 2829 3b0a 0a23 6966 t_stage2();..#if │ │ │ +00044800: 2064 6566 696e 6564 2054 4f52 5245 4e54 defined TORRENT │ │ │ +00044810: 5f41 5349 4f5f 4445 4255 4747 494e 470a _ASIO_DEBUGGING. │ │ │ +00044820: 0909 4649 4c45 2a20 6620 3d20 666f 7065 ..FILE* f = fope │ │ │ +00044830: 6e28 2277 616b 6575 7073 2e6c 6f67 222c n("wakeups.log", │ │ │ +00044840: 2022 772b 2229 3b0a 0909 6966 2028 6620 "w+");...if (f │ │ │ +00044850: 213d 206e 756c 6c70 7472 290a 0909 7b0a != nullptr)...{. │ │ │ +00044860: 0909 0974 696d 655f 706f 696e 7420 6d20 ...time_point m │ │ │ +00044870: 3d20 6d69 6e5f 7469 6d65 2829 3b0a 0909 = min_time();... │ │ │ +00044880: 0969 6620 2821 5f77 616b 6575 7073 2e65 .if (!_wakeups.e │ │ │ +00044890: 6d70 7479 2829 2920 6d20 3d20 5f77 616b mpty()) m = _wak │ │ │ +000448a0: 6575 7073 5b30 5d2e 7469 6d65 7374 616d eups[0].timestam │ │ │ +000448b0: 703b 0a09 0909 7469 6d65 5f70 6f69 6e74 p;....time_point │ │ │ +000448c0: 2070 7265 7620 3d20 6d3b 0a09 0909 7374 prev = m;....st │ │ │ +000448d0: 643a 3a75 696e 7436 345f 7420 7072 6576 d::uint64_t prev │ │ │ +000448e0: 5f63 7377 203d 2030 3b0a 0909 0969 6620 _csw = 0;....if │ │ │ +000448f0: 2821 5f77 616b 6575 7073 2e65 6d70 7479 (!_wakeups.empty │ │ │ +00044900: 2829 2920 7072 6576 5f63 7377 203d 205f ()) prev_csw = _ │ │ │ +00044910: 7761 6b65 7570 735b 305d 2e63 6f6e 7465 wakeups[0].conte │ │ │ +00044920: 7874 5f73 7769 7463 6865 733b 0a09 0909 xt_switches;.... │ │ │ +00044930: 7374 643a 3a66 7072 696e 7466 2866 2c20 std::fprintf(f, │ │ │ +00044940: 2261 6273 2e20 7469 6d65 5c74 7265 6c2e "abs. time\trel. │ │ │ +00044950: 2074 696d 655c 7463 7478 2073 7769 7463 time\tctx switc │ │ │ +00044960: 685c 7469 646c 652d 7761 6b65 7570 5c74 h\tidle-wakeup\t │ │ │ +00044970: 6f70 6572 6174 696f 6e5c 6e22 293b 0a09 operation\n");.. │ │ │ +00044980: 0909 666f 7220 2877 616b 6575 705f 7420 ..for (wakeup_t │ │ │ +00044990: 636f 6e73 7426 616d 703b 2077 203a 205f const& w : _ │ │ │ +000449a0: 7761 6b65 7570 7329 0a09 0909 7b0a 0909 wakeups)....{... │ │ │ +000449b0: 0909 626f 6f6c 2063 6f6e 7374 2069 646c ..bool const idl │ │ │ +000449c0: 655f 7761 6b65 7570 203d 2077 2e63 6f6e e_wakeup = w.con │ │ │ +000449d0: 7465 7874 5f73 7769 7463 6865 7320 2667 text_switches &g │ │ │ +000449e0: 743b 2070 7265 765f 6373 773b 0a09 0909 t; prev_csw;.... │ │ │ +000449f0: 0973 7464 3a3a 6670 7269 6e74 6628 662c .std::fprintf(f, │ │ │ +00044a00: 2022 2522 2050 5249 6436 3420 225c 7425 "%" PRId64 "\t% │ │ │ +00044a10: 2220 5052 4964 3634 2022 5c74 2522 2050 " PRId64 "\t%" P │ │ │ +00044a20: 5249 6436 3420 225c 7425 635c 7425 735c RId64 "\t%c\t%s\ │ │ │ +00044a30: 6e22 0a09 0909 0909 2c20 746f 7461 6c5f n"......, total_ │ │ │ +00044a40: 6d69 6372 6f73 6563 6f6e 6473 2877 2e74 microseconds(w.t │ │ │ +00044a50: 696d 6573 7461 6d70 202d 206d 290a 0909 imestamp - m)... │ │ │ +00044a60: 0909 092c 2074 6f74 616c 5f6d 6963 726f ..., total_micro │ │ │ +00044a70: 7365 636f 6e64 7328 772e 7469 6d65 7374 seconds(w.timest │ │ │ +00044a80: 616d 7020 2d20 7072 6576 290a 0909 0909 amp - prev)..... │ │ │ +00044a90: 092c 2077 2e63 6f6e 7465 7874 5f73 7769 ., w.context_swi │ │ │ +00044aa0: 7463 6865 730a 3c2f 7072 653e 3c2f 7464 tches.
    relevance │ │ │ +00044ae0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +00044af0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/udp_sock │ │ │ +00044b20: 6574 2e63 7070 3a36 3433 3c2f 613e 3c2f et.cpp:643perhaps a │ │ │ +00044b40: 6e20 6174 7465 6d70 7420 7368 6f75 6c64 n attempt should │ │ │ +00044b50: 2062 6520 6d61 6465 2074 6f20 6269 6e64 be made to bind │ │ │ +00044b60: 206d 5f73 6f63 6b73 355f 736f 636b 2074 m_socks5_sock t │ │ │ +00044b70: 6f20 7468 6520 6465 7669 6365 206f 6620 o the device of │ │ │ +00044b80: 6d5f 6c69 7374 656e 5f73 6f63 6b65 743c m_listen_socket< │ │ │ +00044b90: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    per │ │ │ +00044be0: 6861 7073 2061 6e20 6174 7465 6d70 7420 haps an attempt │ │ │ +00044bf0: 7368 6f75 6c64 2062 6520 6d61 6465 2074 should be made t │ │ │ +00044c00: 6f20 6269 6e64 206d 5f73 6f63 6b73 355f o bind m_socks5_ │ │ │ +00044c10: 736f 636b 2074 6f20 7468 650a 6465 7669 sock to the.devi │ │ │ +00044c20: 6365 206f 6620 6d5f 6c69 7374 656e 5f73 ce of m_listen_s │ │ │ +00044c30: 6f63 6b65 743c 2f68 323e 3c68 343e 2e2e ocket

    .. │ │ │ +00044c40: 2f73 7263 2f75 6470 5f73 6f63 6b65 742e /src/udp_socket. │ │ │ +00044c50: 6370 703a 3634 333c 2f68 343e 3c70 7265 cpp:643

    .if (ec)..
    │ │ │ +00044ca0: 7b0a 0909 6966 2028 6d5f 616c 6572 7473  {...if (m_alerts
    │ │ │ +00044cb0: 2e73 686f 756c 645f 706f 7374 266c 743b  .should_post<
    │ │ │ +00044cc0: 736f 636b 7335 5f61 6c65 7274 2667 743b  socks5_alert>
    │ │ │ +00044cd0: 2829 290a 0909 096d 5f61 6c65 7274 732e  ())....m_alerts.
    │ │ │ +00044ce0: 656d 706c 6163 655f 616c 6572 7426 6c74  emplace_alert<
    │ │ │ +00044cf0: 3b73 6f63 6b73 355f 616c 6572 7426 6774  ;socks5_alert>
    │ │ │ +00044d00: 3b28 6d5f 7072 6f78 795f 6164 6472 2c20  ;(m_proxy_addr, 
    │ │ │ +00044d10: 6f70 6572 6174 696f 6e5f 743a 3a73 6f63  operation_t::soc
    │ │ │ +00044d20: 6b5f 6f70 7469 6f6e 2c20 6563 293b 0a09  k_option, ec);..
    │ │ │ +00044d30: 0965 632e 636c 6561 7228 293b 0a09 7d0a  .ec.clear();..}.
    │ │ │ +00044d40: 2365 6e64 6966 0a23 656e 6469 660a 0a09  #endif.#endif...
    │ │ │ +00044d50: 7463 703a 3a65 6e64 706f 696e 7420 636f  tcp::endpoint co
    │ │ │ +00044d60: 6e73 7420 6269 6e64 5f65 7028 6d5f 6c69  nst bind_ep(m_li
    │ │ │ +00044d70: 7374 656e 5f73 6f63 6b65 742e 6765 745f  sten_socket.get_
    │ │ │ +00044d80: 6c6f 6361 6c5f 656e 6470 6f69 6e74 2829  local_endpoint()
    │ │ │ +00044d90: 2e61 6464 7265 7373 2829 2c20 3029 3b0a  .address(), 0);.
    │ │ │ +00044da0: 096d 5f73 6f63 6b73 355f 736f 636b 2e62  .m_socks5_sock.b
    │ │ │ +00044db0: 696e 6428 6269 6e64 5f65 702c 2065 6329  ind(bind_ep, ec)
    │ │ │ +00044dc0: 3b0a 0969 6620 2865 6329 0a09 7b0a 0909  ;..if (ec)..{...
    │ │ │ +00044dd0: 6966 2028 6d5f 616c 6572 7473 2e73 686f  if (m_alerts.sho
    │ │ │ +00044de0: 756c 645f 706f 7374 266c 743b 736f 636b  uld_post<sock
    │ │ │ +00044df0: 7335 5f61 6c65 7274 2667 743b 2829 290a  s5_alert>()).
    │ │ │ +00044e00: 0909 096d 5f61 6c65 7274 732e 656d 706c  ...m_alerts.empl
    │ │ │ +00044e10: 6163 655f 616c 6572 7426 6c74 3b73 6f63  ace_alert<soc
    │ │ │ +00044e20: 6b73 355f 616c 6572 7426 6774 3b28 6d5f  ks5_alert>(m_
    │ │ │ +00044e30: 7072 6f78 795f 6164 6472 2c20 6f70 6572  proxy_addr, oper
    │ │ │ +00044e40: 6174 696f 6e5f 743a 3a73 6f63 6b5f 6269  ation_t::sock_bi
    │ │ │ +00044e50: 6e64 2c20 6563 293b 0a09 092b 2b6d 5f66  nd, ec);...++m_f
    │ │ │ +00044e60: 6169 6c75 7265 733b 0a09 0972 6574 7279  ailures;...retry
    │ │ │ +00044e70: 5f63 6f6e 6e65 6374 696f 6e28 293b 0a09  _connection();..
    │ │ │ +00044e80: 0972 6574 7572 6e3b 0a09 7d0a 0a3c 6469  .return;..}....ADD_OUTSTANDI
    │ │ │ +00044ed0: 4e47 5f41 5359 4e43 2822 736f 636b 7335  NG_ASYNC("socks5
    │ │ │ +00044ee0: 3a3a 6f6e 5f63 6f6e 6e65 6374 6564 2229  ::on_connected")
    │ │ │ +00044ef0: 3b0a 096d 5f73 6f63 6b73 355f 736f 636b  ;..m_socks5_sock
    │ │ │ +00044f00: 2e61 7379 6e63 5f63 6f6e 6e65 6374 286d  .async_connect(m
    │ │ │ +00044f10: 5f70 726f 7879 5f61 6464 720a 0909 2c20  _proxy_addr..., 
    │ │ │ +00044f20: 7374 643a 3a62 696e 6428 2661 6d70 3b73  std::bind(&s
    │ │ │ +00044f30: 6f63 6b73 353a 3a6f 6e5f 636f 6e6e 6563  ocks5::on_connec
    │ │ │ +00044f40: 7465 642c 2073 656c 6628 292c 205f 3129  ted, self(), _1)
    │ │ │ +00044f50: 293b 0a0a 0941 4444 5f4f 5554 5354 414e  );...ADD_OUTSTAN
    │ │ │ +00044f60: 4449 4e47 5f41 5359 4e43 2822 736f 636b  DING_ASYNC("sock
    │ │ │ +00044f70: 7335 3a3a 6f6e 5f63 6f6e 6e65 6374 5f74  s5::on_connect_t
    │ │ │ +00044f80: 696d 656f 7574 2229 3b0a 096d 5f74 696d  imeout");..m_tim
    │ │ │ +00044f90: 6572 2e65 7870 6972 6573 5f61 6674 6572  er.expires_after
    │ │ │ +00044fa0: 2873 6563 6f6e 6473 2831 3029 293b 0a09  (seconds(10));..
    │ │ │ +00044fb0: 6d5f 7469 6d65 722e 6173 796e 635f 7761  m_timer.async_wa
    │ │ │ +00044fc0: 6974 2873 7464 3a3a 6269 6e64 2826 616d  it(std::bind(&am
    │ │ │ +00044fd0: 703b 736f 636b 7335 3a3a 6f6e 5f63 6f6e  p;socks5::on_con
    │ │ │ +00044fe0: 6e65 6374 5f74 696d 656f 7574 0a09 092c  nect_timeout...,
    │ │ │ +00044ff0: 2073 656c 6628 292c 205f 3129 293b 0a7d   self(), _1));.}
    │ │ │ +00045000: 0a0a 766f 6964 2073 6f63 6b73 353a 3a6f  ..void socks5::o
    │ │ │ +00045010: 6e5f 636f 6e6e 6563 745f 7469 6d65 6f75  n_connect_timeou
    │ │ │ +00045020: 7428 6572 726f 725f 636f 6465 2063 6f6e  t(error_code con
    │ │ │ +00045030: 7374 2661 6d70 3b20 6529 0a7b 0a09 434f  st& e).{..CO
    │ │ │ +00045040: 4d50 4c45 5445 5f41 5359 4e43 2822 736f  MPLETE_ASYNC("so
    │ │ │ +00045050: 636b 7335 3a3a 6f6e 5f63 6f6e 6e65 6374  cks5::on_connect
    │ │ │ +00045060: 5f74 696d 656f 7574 2229 3b0a 0a09 6966  _timeout");...if
    │ │ │ +00045070: 2028 6520 3d3d 2062 6f6f 7374 3a3a 6173   (e == boost::as
    │ │ │ +00045080: 696f 3a3a 6572 726f 723a 3a6f 7065 7261  io::error::opera
    │ │ │ +00045090: 7469 6f6e 5f61 626f 7274 6564 2920 7265  tion_aborted) re
    │ │ │ +000450a0: 7475 726e 3b0a 0a09 6966 2028 6d5f 6162  turn;...if (m_ab
    │ │ │ +000450b0: 6f72 7429 2072 6574 7572 6e3b 0a0a 0969  ort) return;...i
    │ │ │ +000450c0: 6620 286d 5f61 6c65 7274 732e 7368 6f75  f (m_alerts.shou
    │ │ │ +000450d0: 6c64 5f70 6f73 7426 6c74 3b73 6f63 6b73  ld_post<socks
    │ │ │ +000450e0: 355f 616c 6572 7426 6774 3b28 2929 0a09  5_alert>())..
    │ │ │ +000450f0: 096d 5f61 6c65 7274 732e 656d 706c 6163  .m_alerts.emplac
    │ │ │ +00045100: 655f 616c 6572 7426 6c74 3b73 6f63 6b73  e_alert<socks
    │ │ │ +00045110: 355f 616c 6572 7426 6774 3b28 6d5f 7072  5_alert>(m_pr
    │ │ │ +00045120: 6f78 795f 6164 6472 2c20 6f70 6572 6174  oxy_addr, operat
    │ │ │ +00045130: 696f 6e5f 743a 3a63 6f6e 6e65 6374 2c20  ion_t::connect, 
    │ │ │ +00045140: 6572 726f 7273 3a3a 7469 6d65 645f 6f75  errors::timed_ou
    │ │ │ +00045150: 7429 3b0a 0a09 6572 726f 725f 636f 6465  t);...error_code
    │ │ │ +00045160: 2069 676e 6f72 653b 0a09 6d5f 736f 636b   ignore;..m_sock
    │ │ │ +00045170: 7335 5f73 6f63 6b2e 636c 6f73 6528 6967  s5_sock.close(ig
    │ │ │ +00045180: 6e6f 7265 293b 0a0a 092b 2b6d 5f66 6169  nore);...++m_fai
    │ │ │ +00045190: 6c75 7265 733b 0a09 7265 7472 795f 636f  lures;..retry_co
    │ │ │ +000451a0: 6e6e 6563 7469 6f6e 2829 3b0a 7d0a 0a76  nnection();.}..v
    │ │ │ +000451b0: 6f69 6420 736f 636b 7335 3a3a 6f6e 5f63  oid socks5::on_c
    │ │ │ +000451c0: 6f6e 6e65 6374 6564 2865 7272 6f72 5f63  onnected(error_c
    │ │ │ +000451d0: 6f64 6520 636f 6e73 7426 616d 703b 2065  ode const& e
    │ │ │ +000451e0: 290a 7b0a 3c2f 7072 653e 3c2f 7464 3e3c  ).{.
    < │ │ │ +000451f0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +00045220: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +00045250: 2e2f 7372 632f 7065 6572 5f63 6f6e 6e65 ./src/peer_conne │ │ │ +00045260: 6374 696f 6e2e 6370 703a 3130 3838 3c2f ction.cpp:1088this │ │ │ +00045280: 7368 6f75 6c64 2062 6520 7468 6520 676c should be the gl │ │ │ +00045290: 6f62 616c 2064 6f77 6e6c 6f61 6420 7261 obal download ra │ │ │ +000452a0: 7465 3c2f 7464 3e3c 2f74 723e 3c74 7220 te

    │ │ │ +000452f0: 7468 6973 2073 686f 756c 6420 6265 2074 this should be t │ │ │ +00045300: 6865 2067 6c6f 6261 6c20 646f 776e 6c6f he global downlo │ │ │ +00045310: 6164 2072 6174 653c 2f68 323e 3c68 343e ad rate

    │ │ │ +00045320: 2e2e 2f73 7263 2f70 6565 725f 636f 6e6e ../src/peer_conn │ │ │ +00045330: 6563 7469 6f6e 2e63 7070 3a31 3038 383c ection.cpp:1088< │ │ │ +00045340: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +00045380: 0969 6e74 2072 6174 6520 3d20 303b 0a0a  .int rate = 0;..
    │ │ │ +00045390: 0909 2f2f 2069 6620 7765 2068 6176 656e  ..// if we haven
    │ │ │ +000453a0: 2774 2072 6563 6569 7665 6420 616e 7920  't received any 
    │ │ │ +000453b0: 6461 7461 2072 6563 656e 746c 792c 2074  data recently, t
    │ │ │ +000453c0: 6865 2063 7572 7265 6e74 2064 6f77 6e6c  he current downl
    │ │ │ +000453d0: 6f61 6420 7261 7465 0a09 092f 2f20 6973  oad rate...// is
    │ │ │ +000453e0: 206e 6f74 2072 6570 7265 7365 6e74 6174   not representat
    │ │ │ +000453f0: 6976 650a 0909 6966 2028 6175 783a 3a74  ive...if (aux::t
    │ │ │ +00045400: 696d 655f 6e6f 7728 2920 2d20 6d5f 6c61  ime_now() - m_la
    │ │ │ +00045410: 7374 5f70 6965 6365 2e67 6574 286d 5f63  st_piece.get(m_c
    │ │ │ +00045420: 6f6e 6e65 6374 2920 2667 743b 2073 6563  onnect) > sec
    │ │ │ +00045430: 6f6e 6473 2833 3029 2026 616d 703b 2661  onds(30) &&a
    │ │ │ +00045440: 6d70 3b20 6d5f 646f 776e 6c6f 6164 5f72  mp; m_download_r
    │ │ │ +00045450: 6174 655f 7065 616b 2026 6774 3b20 3029  ate_peak > 0)
    │ │ │ +00045460: 0a09 097b 0a09 0909 7261 7465 203d 206d  ...{....rate = m
    │ │ │ +00045470: 5f64 6f77 6e6c 6f61 645f 7261 7465 5f70  _download_rate_p
    │ │ │ +00045480: 6561 6b3b 0a09 097d 0a09 0965 6c73 6520  eak;...}...else 
    │ │ │ +00045490: 6966 2028 6175 783a 3a74 696d 655f 6e6f  if (aux::time_no
    │ │ │ +000454a0: 7728 2920 2d20 6d5f 6c61 7374 5f75 6e63  w() - m_last_unc
    │ │ │ +000454b0: 686f 6b65 642e 6765 7428 6d5f 636f 6e6e  hoked.get(m_conn
    │ │ │ +000454c0: 6563 7429 2026 6c74 3b20 7365 636f 6e64  ect) < second
    │ │ │ +000454d0: 7328 3529 0a09 0909 2661 6d70 3b26 616d  s(5)....&&am
    │ │ │ +000454e0: 703b 206d 5f73 7461 7469 7374 6963 732e  p; m_statistics.
    │ │ │ +000454f0: 746f 7461 6c5f 7061 796c 6f61 645f 7570  total_payload_up
    │ │ │ +00045500: 6c6f 6164 2829 2026 6c74 3b20 3220 2a20  load() < 2 * 
    │ │ │ +00045510: 3078 3430 3030 290a 0909 7b0a 0909 092f  0x4000)...{..../
    │ │ │ +00045520: 2f20 6966 2077 6527 7265 2068 6176 6520  / if we're have 
    │ │ │ +00045530: 6f6e 6c79 2062 6565 6e20 756e 6368 6f6b  only been unchok
    │ │ │ +00045540: 6564 2066 6f72 2061 2073 686f 7274 2070  ed for a short p
    │ │ │ +00045550: 6572 696f 6420 6f66 2074 696d 652c 0a09  eriod of time,..
    │ │ │ +00045560: 0909 2f2f 2077 6520 646f 6e27 7420 6b6e  ..// we don't kn
    │ │ │ +00045570: 6f77 2077 6861 7420 7261 7465 2077 6520  ow what rate we 
    │ │ │ +00045580: 6361 6e20 6765 7420 6672 6f6d 2074 6869  can get from thi
    │ │ │ +00045590: 7320 7065 6572 2e20 496e 7374 6561 6420  s peer. Instead 
    │ │ │ +000455a0: 6f66 2061 7373 756d 696e 670a 0909 092f  of assuming..../
    │ │ │ +000455b0: 2f20 7468 6520 6c6f 7765 7374 2070 6f73  / the lowest pos
    │ │ │ +000455c0: 7369 626c 6520 7261 7465 2c20 6173 7375  sible rate, assu
    │ │ │ +000455d0: 6d65 2074 6865 2061 7665 7261 6765 2e0a  me the average..
    │ │ │ +000455e0: 0a09 0909 696e 7420 7065 6572 735f 7769  ....int peers_wi
    │ │ │ +000455f0: 7468 5f72 6571 7565 7374 7320 3d20 696e  th_requests = in
    │ │ │ +00045600: 7428 7374 6174 735f 636f 756e 7465 7273  t(stats_counters
    │ │ │ +00045610: 2829 5b63 6f75 6e74 6572 733a 3a6e 756d  ()[counters::num
    │ │ │ +00045620: 5f70 6565 7273 5f64 6f77 6e5f 7265 7175  _peers_down_requ
    │ │ │ +00045630: 6573 7473 5d29 3b0a 0909 092f 2f20 6176  ests]);....// av
    │ │ │ +00045640: 6f69 6420 6469 7669 7369 6f6e 2062 7920  oid division by 
    │ │ │ +00045650: 300a 0909 0969 6620 2870 6565 7273 5f77  0....if (peers_w
    │ │ │ +00045660: 6974 685f 7265 7175 6573 7473 203d 3d20  ith_requests == 
    │ │ │ +00045670: 3029 2070 6565 7273 5f77 6974 685f 7265  0) peers_with_re
    │ │ │ +00045680: 7175 6573 7473 203d 2031 3b0a 0a3c 6469  quests = 1;.....ra
    │ │ │ +000456c0: 7465 203d 2074 2d26 6774 3b73 7461 7469  te = t->stati
    │ │ │ +000456d0: 7374 6963 7328 292e 7472 616e 7366 6572  stics().transfer
    │ │ │ +000456e0: 5f72 6174 6528 6175 783a 3a73 7461 743a  _rate(aux::stat:
    │ │ │ +000456f0: 3a64 6f77 6e6c 6f61 645f 7061 796c 6f61  :download_payloa
    │ │ │ +00045700: 6429 202f 2070 6565 7273 5f77 6974 685f  d) / peers_with_
    │ │ │ +00045710: 7265 7175 6573 7473 3b0a 3c2f 6469 763e  requests;.
    │ │ │ +00045720: 0909 7d0a 0909 656c 7365 0a09 097b 0a09  ..}...else...{..
    │ │ │ +00045730: 0909 2f2f 2063 7572 7265 6e74 2064 6f77  ..// current dow
    │ │ │ +00045740: 6e6c 6f61 6420 7261 7465 2069 6e20 6279  nload rate in by
    │ │ │ +00045750: 7465 7320 7065 7220 7365 636f 6e64 730a  tes per seconds.
    │ │ │ +00045760: 0909 0972 6174 6520 3d20 6d5f 7374 6174  ...rate = m_stat
    │ │ │ +00045770: 6973 7469 6373 2e74 7261 6e73 6665 725f  istics.transfer_
    │ │ │ +00045780: 7261 7465 2861 7578 3a3a 7374 6174 3a3a  rate(aux::stat::
    │ │ │ +00045790: 646f 776e 6c6f 6164 5f70 6179 6c6f 6164  download_payload
    │ │ │ +000457a0: 293b 0a09 097d 0a0a 0909 2f2f 2061 766f  );...}....// avo
    │ │ │ +000457b0: 6964 2064 6976 6973 696f 6e20 6279 207a  id division by z
    │ │ │ +000457c0: 6572 6f0a 0909 6966 2028 7261 7465 2026  ero...if (rate &
    │ │ │ +000457d0: 6c74 3b20 3530 2920 7261 7465 203d 2035  lt; 50) rate = 5
    │ │ │ +000457e0: 303b 0a0a 0909 2f2f 2061 7665 7261 6765  0;....// average
    │ │ │ +000457f0: 206f 6620 6375 7272 656e 7420 7261 7465   of current rate
    │ │ │ +00045800: 2061 6e64 2070 6561 6b0a 2f2f 0909 7261   and peak.//..ra
    │ │ │ +00045810: 7465 203d 2028 7261 7465 202b 206d 5f64  te = (rate + m_d
    │ │ │ +00045820: 6f77 6e6c 6f61 645f 7261 7465 5f70 6561  ownload_rate_pea
    │ │ │ +00045830: 6b29 202f 2032 3b0a 0a09 0972 6574 7572  k) / 2;....retur
    │ │ │ +00045840: 6e20 6d69 6c6c 6973 6563 6f6e 6473 2828  n milliseconds((
    │ │ │ +00045850: 7374 643a 3a69 6e74 3634 5f74 286d 5f6f  std::int64_t(m_o
    │ │ │ +00045860: 7574 7374 616e 6469 6e67 5f62 7974 6573  utstanding_bytes
    │ │ │ +00045870: 2920 2b20 6578 7472 615f 6279 7465 730a  ) + extra_bytes.
    │ │ │ +00045880: 0909 0909 0909 0909 2b20 7374 643a 3a69  ........+ std::i
    │ │ │ +00045890: 6e74 3634 5f74 286d 5f71 7565 7565 645f  nt64_t(m_queued_
    │ │ │ +000458a0: 7469 6d65 5f63 7269 7469 6361 6c29 202a  time_critical) *
    │ │ │ +000458b0: 2074 2d26 6774 3b62 6c6f 636b 5f73 697a   t->block_siz
    │ │ │ +000458c0: 6528 2920 2a20 3130 3030 290a 0909 092f  e() * 1000)..../
    │ │ │ +000458d0: 2072 6174 6529 3b0a 097d 0a0a 0976 6f69   rate);..}...voi
    │ │ │ +000458e0: 6420 7065 6572 5f63 6f6e 6e65 6374 696f  d peer_connectio
    │ │ │ +000458f0: 6e3a 3a61 6464 5f73 7461 7428 7374 643a  n::add_stat(std:
    │ │ │ +00045900: 3a69 6e74 3634 5f74 2063 6f6e 7374 2064  :int64_t const d
    │ │ │ +00045910: 6f77 6e6c 6f61 6465 642c 2073 7464 3a3a  ownloaded, std::
    │ │ │ +00045920: 696e 7436 345f 7420 636f 6e73 7420 7570  int64_t const up
    │ │ │ +00045930: 6c6f 6164 6564 290a 097b 0a09 0954 4f52  loaded)..{...TOR
    │ │ │ +00045940: 5245 4e54 5f41 5353 4552 5428 6973 5f73  RENT_ASSERT(is_s
    │ │ │ +00045950: 696e 676c 655f 7468 7265 6164 2829 293b  ingle_thread());
    │ │ │ +00045960: 0a09 096d 5f73 7461 7469 7374 6963 732e  ...m_statistics.
    │ │ │ +00045970: 6164 645f 7374 6174 2864 6f77 6e6c 6f61  add_stat(downloa
    │ │ │ +00045980: 6465 642c 2075 706c 6f61 6465 6429 3b0a  ded, uploaded);.
    │ │ │ +00045990: 097d 0a0a 0973 6861 315f 6861 7368 2070  .}...sha1_hash p
    │ │ │ +000459a0: 6565 725f 636f 6e6e 6563 7469 6f6e 3a3a  eer_connection::
    │ │ │ +000459b0: 6173 736f 6369 6174 6564 5f69 6e66 6f5f  associated_info_
    │ │ │ +000459c0: 6861 7368 2829 2063 6f6e 7374 0a09 7b0a  hash() const..{.
    │ │ │ +000459d0: 0909 6175 746f 2074 203d 2061 7373 6f63  ..auto t = assoc
    │ │ │ +000459e0: 6961 7465 645f 746f 7272 656e 7428 292e  iated_torrent().
    │ │ │ +000459f0: 6c6f 636b 2829 3b0a 0909 544f 5252 454e  lock();...TORREN
    │ │ │ +00045a00: 545f 4153 5345 5254 2874 293b 0a09 0961  T_ASSERT(t);...a
    │ │ │ +00045a10: 7574 6f20 636f 6e73 7426 616d 703b 2069  uto const& i
    │ │ │ +00045a20: 6820 3d20 742d 2667 743b 696e 666f 5f68  h = t->info_h
    │ │ │ +00045a30: 6173 6828 293b 0a09 092f 2f20 6120 7065  ash();...// a pe
    │ │ │ +00045a40: 6572 2773 2070 726f 746f 636f 6c5f 7632  er's protocol_v2
    │ │ │ +00045a50: 2066 6c61 6720 6d61 7920 6265 2073 6574   flag may be set
    │ │ │ +00045a60: 2073 7065 6375 6c61 7469 7665 6c79 2077   speculatively w
    │ │ │ +00045a70: 6869 6c65 206d 6574 6164 6174 610a 3c2f  hile metadata.r
    │ │ │ +00045ab0: 656c 6576 616e 6365 266e 6273 703b 303c  elevance 0<
    │ │ │ +00045ac0: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../src/
    │ │ │ +00045af0: 7065 6572 5f63 6f6e 6e65 6374 696f 6e2e  peer_connection.
    │ │ │ +00045b00: 6370 703a 3131 3933 3c2f 613e 3c2f 7464  cpp:1193store the s
    │ │ │ +00045b20: 6168 3235 3620 6861 7368 206f 6620 7468  ah256 hash of th
    │ │ │ +00045b30: 6520 6465 7374 696e 6174 696f 6e20 696e  e destination in
    │ │ │ +00045b40: 2074 6865 2069 3270 5f70 6565 7220 7374   the i2p_peer st
    │ │ │ +00045b50: 7275 6374 2c20 736f 2077 6520 646f 6e27  ruct, so we don'
    │ │ │ +00045b60: 7420 6861 7665 2074 6f20 7265 636f 6d70  t have to recomp
    │ │ │ +00045b70: 7574 6520 6974 2065 7665 7279 2074 696d  ute it every tim
    │ │ │ +00045b80: 653c 2f74 643e 3c2f 7472 3e3c 7472 2069  e

    s │ │ │ +00045bd0: 746f 7265 2074 6865 2073 6168 3235 3620 tore the sah256 │ │ │ +00045be0: 6861 7368 206f 6620 7468 6520 6465 7374 hash of the dest │ │ │ +00045bf0: 696e 6174 696f 6e20 696e 2074 6865 0a69 ination in the.i │ │ │ +00045c00: 3270 5f70 6565 7220 7374 7275 6374 2c20 2p_peer struct, │ │ │ +00045c10: 736f 2077 6520 646f 6e27 7420 6861 7665 so we don't have │ │ │ +00045c20: 2074 6f20 7265 636f 6d70 7574 6520 6974 to recompute it │ │ │ +00045c30: 2065 7665 7279 2074 696d 653c 2f68 323e every time

    │ │ │ +00045c40: 3c68 343e 2e2e 2f73 7263 2f70 6565 725f

    ../src/peer_ │ │ │ +00045c50: 636f 6e6e 6563 7469 6f6e 2e63 7070 3a31 connection.cpp:1 │ │ │ +00045c60: 3139 333c 2f68 343e 3c70 7265 2073 7479 193

    ..auto t = m_t
    │ │ │ +00045cb0: 6f72 7265 6e74 2e6c 6f63 6b28 293b 0a09  orrent.lock();..
    │ │ │ +00045cc0: 0969 6620 2821 7429 2072 6574 7572 6e3b  .if (!t) return;
    │ │ │ +00045cd0: 0a09 0974 2d26 6774 3b73 656e 745f 7379  ...t->sent_sy
    │ │ │ +00045ce0: 6e28 6970 7636 293b 0a09 7d0a 0a09 766f  n(ipv6);..}...vo
    │ │ │ +00045cf0: 6964 2070 6565 725f 636f 6e6e 6563 7469  id peer_connecti
    │ │ │ +00045d00: 6f6e 3a3a 7265 6365 6976 6564 5f73 796e  on::received_syn
    │ │ │ +00045d10: 6163 6b28 626f 6f6c 2063 6f6e 7374 2069  ack(bool const i
    │ │ │ +00045d20: 7076 3629 0a09 7b0a 0909 544f 5252 454e  pv6)..{...TORREN
    │ │ │ +00045d30: 545f 4153 5345 5254 2869 735f 7369 6e67  T_ASSERT(is_sing
    │ │ │ +00045d40: 6c65 5f74 6872 6561 6428 2929 3b0a 0909  le_thread());...
    │ │ │ +00045d50: 6d5f 7374 6174 6973 7469 6373 2e72 6563  m_statistics.rec
    │ │ │ +00045d60: 6569 7665 645f 7379 6e61 636b 2869 7076  eived_synack(ipv
    │ │ │ +00045d70: 3629 3b0a 0909 6966 2028 6d5f 6967 6e6f  6);...if (m_igno
    │ │ │ +00045d80: 7265 5f73 7461 7473 2920 7265 7475 726e  re_stats) return
    │ │ │ +00045d90: 3b0a 0909 6175 746f 2074 203d 206d 5f74  ;...auto t = m_t
    │ │ │ +00045da0: 6f72 7265 6e74 2e6c 6f63 6b28 293b 0a09  orrent.lock();..
    │ │ │ +00045db0: 0969 6620 2821 7429 2072 6574 7572 6e3b  .if (!t) return;
    │ │ │ +00045dc0: 0a09 0974 2d26 6774 3b72 6563 6569 7665  ...t->receive
    │ │ │ +00045dd0: 645f 7379 6e61 636b 2869 7076 3629 3b0a  d_synack(ipv6);.
    │ │ │ +00045de0: 097d 0a0a 0970 6565 725f 656e 6470 6f69  .}...peer_endpoi
    │ │ │ +00045df0: 6e74 5f74 2070 6565 725f 636f 6e6e 6563  nt_t peer_connec
    │ │ │ +00045e00: 7469 6f6e 3a3a 7265 6d6f 7465 5f65 6e64  tion::remote_end
    │ │ │ +00045e10: 706f 696e 7428 2920 636f 6e73 740a 097b  point() const..{
    │ │ │ +00045e20: 0a23 6966 2054 4f52 5245 4e54 5f55 5345  .#if TORRENT_USE
    │ │ │ +00045e30: 5f49 3250 0a09 0969 6620 2861 7574 6f20  _I2P...if (auto 
    │ │ │ +00045e40: 7320 3d20 7374 643a 3a67 6574 5f69 6626  s = std::get_if&
    │ │ │ +00045e50: 6c74 3b69 3270 5f73 7472 6561 6d26 6774  lt;i2p_stream>
    │ │ │ +00045e60: 3b28 2661 6d70 3b6d 5f73 6f63 6b65 7429  ;(&m_socket)
    │ │ │ +00045e70: 290a 0909 7b0a 3c64 6976 2073 7479 6c65  )...{.
    ...return ha │ │ │ +00045eb0: 7368 6572 3235 3628 6261 7365 3634 6465 sher256(base64de │ │ │ +00045ec0: 636f 6465 5f69 3270 2873 2d26 6774 3b64 code_i2p(s->d │ │ │ +00045ed0: 6573 7469 6e61 7469 6f6e 2829 2929 2e66 estination())).f │ │ │ +00045ee0: 696e 616c 2829 3b0a 3c2f 6469 763e 0909 inal();.
    .. │ │ │ +00045ef0: 7d0a 2365 6e64 6966 0a09 0972 6574 7572 }.#endif...retur │ │ │ +00045f00: 6e20 6d5f 7265 6d6f 7465 3b0a 097d 0a0a n m_remote;..}.. │ │ │ +00045f10: 2369 6620 544f 5252 454e 545f 5553 455f #if TORRENT_USE_ │ │ │ +00045f20: 4932 500a 0973 7464 3a3a 7374 7269 6e67 I2P..std::string │ │ │ +00045f30: 2063 6f6e 7374 2661 6d70 3b20 7065 6572 const& peer │ │ │ +00045f40: 5f63 6f6e 6e65 6374 696f 6e3a 3a64 6573 _connection::des │ │ │ +00045f50: 7469 6e61 7469 6f6e 2829 2063 6f6e 7374 tination() const │ │ │ +00045f60: 0a09 7b0a 0909 7374 6174 6963 2073 7464 ..{...static std │ │ │ +00045f70: 3a3a 7374 7269 6e67 2063 6f6e 7374 2065 ::string const e │ │ │ +00045f80: 6d70 7479 3b0a 0909 6175 746f 2073 203d mpty;...auto s = │ │ │ +00045f90: 2073 7464 3a3a 6765 745f 6966 266c 743b std::get_if< │ │ │ +00045fa0: 6932 705f 7374 7265 616d 2667 743b 2826 i2p_stream>(& │ │ │ +00045fb0: 616d 703b 6d5f 736f 636b 6574 293b 0a09 amp;m_socket);.. │ │ │ +00045fc0: 0972 6574 7572 6e20 7320 3f20 732d 2667 .return s ? s-&g │ │ │ +00045fd0: 743b 6465 7374 696e 6174 696f 6e28 2920 t;destination() │ │ │ +00045fe0: 3a20 656d 7074 793b 0a09 7d0a 0a09 7374 : empty;..}...st │ │ │ +00045ff0: 643a 3a73 7472 696e 6720 636f 6e73 7426 d::string const& │ │ │ +00046000: 616d 703b 2070 6565 725f 636f 6e6e 6563 amp; peer_connec │ │ │ +00046010: 7469 6f6e 3a3a 6c6f 6361 6c5f 6932 705f tion::local_i2p_ │ │ │ +00046020: 656e 6470 6f69 6e74 2829 2063 6f6e 7374 endpoint() const │ │ │ +00046030: 0a09 7b0a 0909 7374 6174 6963 2073 7464 ..{...static std │ │ │ +00046040: 3a3a 7374 7269 6e67 2063 6f6e 7374 2065 ::string const e │ │ │ +00046050: 6d70 7479 3b0a 0909 6175 746f 2073 203d mpty;...auto s = │ │ │ +00046060: 2073 7464 3a3a 6765 745f 6966 266c 743b std::get_if< │ │ │ +00046070: 6932 705f 7374 7265 616d 2667 743b 2826 i2p_stream>(& │ │ │ +00046080: 616d 703b 6d5f 736f 636b 6574 293b 0a09 amp;m_socket);.. │ │ │ +00046090: 0972 6574 7572 6e20 7320 3f20 732d 2667 .return s ? s-&g │ │ │ +000460a0: 743b 6c6f 6361 6c5f 6932 705f 656e 6470 t;local_i2p_endp │ │ │ +000460b0: 6f69 6e74 2829 203a 2065 6d70 7479 3b0a oint() : empty;. │ │ │ +000460c0: 097d 0a23 656e 6469 660a 0a09 7479 7065 .}.#endif...type │ │ │ +000460d0: 645f 6269 7466 6965 6c64 266c 743b 7069 d_bitfield<pi │ │ │ +000460e0: 6563 655f 696e 6465 785f 7426 6774 3b20 ece_index_t> │ │ │ +000460f0: 636f 6e73 7426 616d 703b 2070 6565 725f const& peer_ │ │ │ +00046100: 636f 6e6e 6563 7469 6f6e 3a3a 6765 745f connection::get_ │ │ │ +00046110: 6269 7466 6965 6c64 2829 2063 6f6e 7374 bitfield() const │ │ │ +00046120: 0a09 7b0a 0909 544f 5252 454e 545f 4153 ..{...TORRENT_AS │ │ │ +00046130: 5345 5254 2869 735f 7369 6e67 6c65 5f74 SERT(is_single_t │ │ │ +00046140: 6872 6561 6428 2929 3b0a 0909 7265 7475 hread());...retu │ │ │ +00046150: 726e 206d 5f68 6176 655f 7069 6563 653b rn m_have_piece; │ │ │ +00046160: 0a09 7d0a 0a09 766f 6964 2070 6565 725f ..}...void peer_ │ │ │ +00046170: 636f 6e6e 6563 7469 6f6e 3a3a 7265 6365 connection::rece │ │ │ +00046180: 6976 6564 5f76 616c 6964 5f64 6174 6128 ived_valid_data( │ │ │ +00046190: 7069 6563 655f 696e 6465 785f 7420 636f piece_index_t co │ │ │ +000461a0: 6e73 7420 696e 6465 7829 0a09 7b0a 0909 nst index)..{... │ │ │ +000461b0: 544f 5252 454e 545f 4153 5345 5254 2869 TORRENT_ASSERT(i │ │ │ +000461c0: 735f 7369 6e67 6c65 5f74 6872 6561 6428 s_single_thread( │ │ │ +000461d0: 2929 3b0a 3c2f 7072 653e 3c2f 7464 3e3c ));.
    < │ │ │ +000461e0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +00046210: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +00046240: 2e2f 7372 632f 7065 6572 5f63 6f6e 6e65 ./src/peer_conne │ │ │ +00046250: 6374 696f 6e2e 6370 703a 3335 3637 3c2f ction.cpp:3567sort │ │ │ +00046270: 7468 6520 616c 6c6f 7765 6420 6661 7374 the allowed fast │ │ │ +00046280: 2073 6574 2069 6e20 7072 696f 7269 7479 set in priority │ │ │ +00046290: 206f 7264 6572 3c2f 7464 3e3c 2f74 723e order │ │ │ +000462a0: 3c74 7220 6964 3d22 3137 3022 2073 7479 │ │ │ +000462d0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +000462e0: 3c68 323e 736f 7274 2074 6865 2061 6c6c

    sort the all │ │ │ +000462f0: 6f77 6564 2066 6173 7420 7365 7420 696e owed fast set in │ │ │ +00046300: 2070 7269 6f72 6974 7920 6f72 6465 723c priority order< │ │ │ +00046310: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f70 /h2>

    ../src/p │ │ │ +00046320: 6565 725f 636f 6e6e 6563 7469 6f6e 2e63 eer_connection.c │ │ │ +00046330: 7070 3a33 3536 373c 2f68 343e 3c70 7265 pp:3567

    ...// if t
    │ │ │ +00046380: 6865 2070 6565 7220 6861 7320 7468 6520  he peer has the 
    │ │ │ +00046390: 7069 6563 6520 616e 6420 7765 2077 616e  piece and we wan
    │ │ │ +000463a0: 740a 0909 2f2f 2074 6f20 646f 776e 6c6f  t...// to downlo
    │ │ │ +000463b0: 6164 2069 742c 2072 6571 7565 7374 2069  ad it, request i
    │ │ │ +000463c0: 740a 0909 6966 2028 696e 6465 7820 266c  t...if (index &l
    │ │ │ +000463d0: 743b 206d 5f68 6176 655f 7069 6563 652e  t; m_have_piece.
    │ │ │ +000463e0: 656e 645f 696e 6465 7828 290a 0909 0926  end_index()....&
    │ │ │ +000463f0: 616d 703b 2661 6d70 3b20 6d5f 6861 7665  amp;& m_have
    │ │ │ +00046400: 5f70 6965 6365 5b69 6e64 6578 5d0a 0909  _piece[index]...
    │ │ │ +00046410: 0926 616d 703b 2661 6d70 3b20 2174 2d26  .&& !t-&
    │ │ │ +00046420: 6774 3b68 6176 655f 7069 6563 6528 696e  gt;have_piece(in
    │ │ │ +00046430: 6465 7829 0a09 0909 2661 6d70 3b26 616d  dex)....&&am
    │ │ │ +00046440: 703b 2074 2d26 6774 3b76 616c 6964 5f6d  p; t->valid_m
    │ │ │ +00046450: 6574 6164 6174 6128 290a 0909 0926 616d  etadata()....&am
    │ │ │ +00046460: 703b 2661 6d70 3b20 742d 2667 743b 6861  p;& t->ha
    │ │ │ +00046470: 735f 7069 636b 6572 2829 0a09 0909 2661  s_picker()....&a
    │ │ │ +00046480: 6d70 3b26 616d 703b 2074 2d26 6774 3b70  mp;& t->p
    │ │ │ +00046490: 6963 6b65 7228 292e 7069 6563 655f 7072  icker().piece_pr
    │ │ │ +000464a0: 696f 7269 7479 2869 6e64 6578 2920 2667  iority(index) &g
    │ │ │ +000464b0: 743b 2064 6f6e 745f 646f 776e 6c6f 6164  t; dont_download
    │ │ │ +000464c0: 290a 0909 7b0a 0909 0974 2d26 6774 3b70  )...{....t->p
    │ │ │ +000464d0: 6565 725f 6973 5f69 6e74 6572 6573 7469  eer_is_interesti
    │ │ │ +000464e0: 6e67 282a 7468 6973 293b 0a09 097d 0a09  ng(*this);...}..
    │ │ │ +000464f0: 7d0a 0a09 7374 643a 3a76 6563 746f 7226  }...std::vector&
    │ │ │ +00046500: 6c74 3b70 6965 6365 5f69 6e64 6578 5f74  lt;piece_index_t
    │ │ │ +00046510: 2667 743b 2063 6f6e 7374 2661 6d70 3b20  > const& 
    │ │ │ +00046520: 7065 6572 5f63 6f6e 6e65 6374 696f 6e3a  peer_connection:
    │ │ │ +00046530: 3a61 6c6c 6f77 6564 5f66 6173 7428 290a  :allowed_fast().
    │ │ │ +00046540: 097b 0a09 0954 4f52 5245 4e54 5f41 5353  .{...TORRENT_ASS
    │ │ │ +00046550: 4552 5428 6973 5f73 696e 676c 655f 7468  ERT(is_single_th
    │ │ │ +00046560: 7265 6164 2829 293b 0a09 0961 7574 6f20  read());...auto 
    │ │ │ +00046570: 7420 3d20 6d5f 746f 7272 656e 742e 6c6f  t = m_torrent.lo
    │ │ │ +00046580: 636b 2829 3b0a 0909 544f 5252 454e 545f  ck();...TORRENT_
    │ │ │ +00046590: 4153 5345 5254 2874 293b 0a0a 3c64 6976  ASSERT(t);..
    ..retu │ │ │ +000465d0: 726e 206d 5f61 6c6c 6f77 6564 5f66 6173 rn m_allowed_fas │ │ │ +000465e0: 743b 0a3c 2f64 6976 3e09 7d0a 0a09 626f t;.
    .}...bo │ │ │ +000465f0: 6f6c 2070 6565 725f 636f 6e6e 6563 7469 ol peer_connecti │ │ │ +00046600: 6f6e 3a3a 6361 6e5f 7265 7175 6573 745f on::can_request_ │ │ │ +00046610: 7469 6d65 5f63 7269 7469 6361 6c28 2920 time_critical() │ │ │ +00046620: 636f 6e73 740a 097b 0a09 0954 4f52 5245 const..{...TORRE │ │ │ +00046630: 4e54 5f41 5353 4552 5428 6973 5f73 696e NT_ASSERT(is_sin │ │ │ +00046640: 676c 655f 7468 7265 6164 2829 293b 0a09 gle_thread());.. │ │ │ +00046650: 0969 6620 2868 6173 5f70 6565 725f 6368 .if (has_peer_ch │ │ │ +00046660: 6f6b 6564 2829 207c 7c20 2169 735f 696e oked() || !is_in │ │ │ +00046670: 7465 7265 7374 696e 6728 2929 2072 6574 teresting()) ret │ │ │ +00046680: 7572 6e20 6661 6c73 653b 0a09 0969 6620 urn false;...if │ │ │ +00046690: 2869 6e74 286d 5f64 6f77 6e6c 6f61 645f (int(m_download_ │ │ │ +000466a0: 7175 6575 652e 7369 7a65 2829 2920 2b20 queue.size()) + │ │ │ +000466b0: 696e 7428 6d5f 7265 7175 6573 745f 7175 int(m_request_qu │ │ │ +000466c0: 6575 652e 7369 7a65 2829 290a 0909 0926 eue.size())....& │ │ │ +000466d0: 6774 3b20 6d5f 6465 7369 7265 645f 7175 gt; m_desired_qu │ │ │ +000466e0: 6575 655f 7369 7a65 202a 2032 2920 7265 eue_size * 2) re │ │ │ +000466f0: 7475 726e 2066 616c 7365 3b0a 0909 6966 turn false;...if │ │ │ +00046700: 2028 6f6e 5f70 6172 6f6c 6528 2929 2072 (on_parole()) r │ │ │ +00046710: 6574 7572 6e20 6661 6c73 653b 0a09 0969 eturn false;...i │ │ │ +00046720: 6620 286d 5f64 6973 636f 6e6e 6563 7469 f (m_disconnecti │ │ │ +00046730: 6e67 2920 7265 7475 726e 2066 616c 7365 ng) return false │ │ │ +00046740: 3b0a 0909 6175 746f 2074 203d 206d 5f74 ;...auto t = m_t │ │ │ +00046750: 6f72 7265 6e74 2e6c 6f63 6b28 293b 0a09 orrent.lock();.. │ │ │ +00046760: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ +00046770: 7429 3b0a 0909 6966 2028 742d 2667 743b t);...if (t-> │ │ │ +00046780: 7570 6c6f 6164 5f6d 6f64 6528 2929 2072 upload_mode()) r │ │ │ +00046790: 6574 7572 6e20 6661 6c73 653b 0a0a 0909 eturn false;.... │ │ │ +000467a0: 2f2f 2069 676e 6f72 6520 736e 7562 6265 // ignore snubbe │ │ │ +000467b0: 6420 7065 6572 732c 2073 696e 6365 2074 d peers, since t │ │ │ +000467c0: 6865 7927 7265 206e 6f74 206c 696b 656c hey're not likel │ │ │ +000467d0: 7920 746f 2072 6574 7572 6e20 7069 6563 y to return piec │ │ │ +000467e0: 6573 2069 6e20 610a 0909 2f2f 2074 696d es in a...// tim │ │ │ +000467f0: 656c 7920 6d61 6e6e 6572 2061 6e79 7761 ely manner anywa │ │ │ +00046800: 790a 0909 6966 2028 6d5f 736e 7562 6265 y...if (m_snubbe │ │ │ +00046810: 6429 2072 6574 7572 6e20 6661 6c73 653b d) return false; │ │ │ +00046820: 0a09 0972 6574 7572 6e20 7472 7565 3b0a ...return true;. │ │ │ +00046830: 097d 0a0a 0962 6f6f 6c20 7065 6572 5f63 .}...bool peer_c │ │ │ +00046840: 6f6e 6e65 6374 696f 6e3a 3a6d 616b 655f onnection::make_ │ │ │ +00046850: 7469 6d65 5f63 7269 7469 6361 6c28 7069 time_critical(pi │ │ │ +00046860: 6563 655f 626c 6f63 6b20 636f 6e73 7426 ece_block const& │ │ │ +00046870: 616d 703b 2062 6c6f 636b 290a 097b 0a09 amp; block)..{.. │ │ │ +00046880: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ +00046890: 6973 5f73 696e 676c 655f 7468 7265 6164 is_single_thread │ │ │ +000468a0: 2829 293b 0a09 0961 7574 6f20 636f 6e73 ());...auto cons │ │ │ +000468b0: 7420 7269 7420 3d20 7374 643a 3a66 696e t rit = std::fin │ │ │ +000468c0: 645f 6966 286d 5f72 6571 7565 7374 5f71 d_if(m_request_q │ │ │ +000468d0: 7565 7565 2e62 6567 696e 2829 0a09 0909 ueue.begin().... │ │ │ +000468e0: 2c20 6d5f 7265 7175 6573 745f 7175 6575 , m_request_queu │ │ │ +000468f0: 652e 656e 6428 292c 2061 7578 3a3a 6861 e.end(), aux::ha │ │ │ +00046900: 735f 626c 6f63 6b28 626c 6f63 6b29 293b s_block(block)); │ │ │ +00046910: 0a09 0969 6620 2872 6974 203d 3d20 6d5f ...if (rit == m_ │ │ │ +00046920: 7265 7175 6573 745f 7175 6575 652e 656e request_queue.en │ │ │ +00046930: 6428 2929 2072 6574 7572 6e20 6661 6c73 d()) return fals │ │ │ +00046940: 653b 0a23 6966 2054 4f52 5245 4e54 5f55 e;.#if TORRENT_U │ │ │ +00046950: 5345 5f41 5353 4552 5453 0a09 0961 7574 SE_ASSERTS...aut │ │ │ +00046960: 6f20 7420 3d20 6d5f 746f 7272 656e 742e o t = m_torrent. │ │ │ +00046970: 6c6f 636b 2829 3b0a 0909 544f 5252 454e lock();...TORREN │ │ │ +00046980: 545f 4153 5345 5254 2874 293b 0a09 0954 T_ASSERT(t);...T │ │ │ +00046990: 4f52 5245 4e54 5f41 5353 4552 5428 742d ORRENT_ASSERT(t- │ │ │ +000469a0: 2667 743b 6861 735f 7069 636b 6572 2829 >has_picker() │ │ │ +000469b0: 293b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f );.
    │ │ │ +000469e0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +000469f0: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0
    .. │ │ │ +00046a20: 2f73 7263 2f74 6f72 7265 6e74 2e63 7070 /src/torrent.cpp │ │ │ +00046a30: 3a32 3132 323c 2f61 3e3c 2f74 643e 3c74 :2122this could be │ │ │ +00046a50: 6f70 7469 6d69 7a65 6420 6279 206c 6f6f optimized by loo │ │ │ +00046a60: 6b69 6e67 2075 7020 7768 6963 6820 6669 king up which fi │ │ │ +00046a70: 6c65 7320 6172 6520 636f 6d70 6c65 7465 les are complete │ │ │ +00046a80: 2061 6e64 206a 7573 7420 6c6f 6f6b 2061 and just look a │ │ │ +00046a90: 7420 7468 6f73 653c 2f74 643e 3c2f 7472 t those

    this could │ │ │ +00046af0: 6265 206f 7074 696d 697a 6564 2062 7920 be optimized by │ │ │ +00046b00: 6c6f 6f6b 696e 6720 7570 2077 6869 6368 looking up which │ │ │ +00046b10: 2066 696c 6573 2061 7265 0a63 6f6d 706c files are.compl │ │ │ +00046b20: 6574 6520 616e 6420 6a75 7374 206c 6f6f ete and just loo │ │ │ +00046b30: 6b20 6174 2074 686f 7365 3c2f 6832 3e3c k at those

    < │ │ │ +00046b40: 6834 3e2e 2e2f 7372 632f 746f 7272 656e h4>../src/torren │ │ │ +00046b50: 742e 6370 703a 3231 3232 3c2f 6834 3e3c t.cpp:2122

    < │ │ │ +00046b60: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00046b70: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00046b80: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00046b90: 7820 2364 6464 3b22 3e2f 2f09 0909 0954 x #ddd;">//....T │ │ │ +00046ba0: 4f52 5245 4e54 5f41 5353 4552 5428 7069 ORRENT_ASSERT(pi │ │ │ +00046bb0: 636b 6572 2829 2e68 6176 655f 7069 6563 cker().have_piec │ │ │ +00046bc0: 6528 6929 293b 0a09 0909 0977 655f 6861 e(i));.....we_ha │ │ │ +00046bd0: 7665 2869 293b 0a09 0909 7d0a 0909 7d0a ve(i);....}...}. │ │ │ +00046be0: 0a09 0973 6574 5f73 7461 7465 2874 6f72 ...set_state(tor │ │ │ +00046bf0: 7265 6e74 5f73 7461 7475 733a 3a63 6865 rent_status::che │ │ │ +00046c00: 636b 696e 675f 7265 7375 6d65 5f64 6174 cking_resume_dat │ │ │ +00046c10: 6129 3b0a 0a09 0961 7578 3a3a 7665 6374 a);....aux::vect │ │ │ +00046c20: 6f72 266c 743b 7374 643a 3a73 7472 696e or<std::strin │ │ │ +00046c30: 672c 2066 696c 655f 696e 6465 785f 7426 g, file_index_t& │ │ │ +00046c40: 6774 3b20 6c69 6e6b 733b 0a23 6966 6e64 gt; links;.#ifnd │ │ │ +00046c50: 6566 2054 4f52 5245 4e54 5f44 4953 4142 ef TORRENT_DISAB │ │ │ +00046c60: 4c45 5f4d 5554 4142 4c45 5f54 4f52 5245 LE_MUTABLE_TORRE │ │ │ +00046c70: 4e54 530a 0909 6966 2028 216d 5f74 6f72 NTS...if (!m_tor │ │ │ +00046c80: 7265 6e74 5f66 696c 652d 2667 743b 7369 rent_file->si │ │ │ +00046c90: 6d69 6c61 725f 746f 7272 656e 7473 2829 milar_torrents() │ │ │ +00046ca0: 2e65 6d70 7479 2829 0a09 0909 7c7c 2021 .empty()....|| ! │ │ │ +00046cb0: 6d5f 746f 7272 656e 745f 6669 6c65 2d26 m_torrent_file-& │ │ │ +00046cc0: 6774 3b63 6f6c 6c65 6374 696f 6e73 2829 gt;collections() │ │ │ +00046cd0: 2e65 6d70 7479 2829 290a 0909 7b0a 0909 .empty())...{... │ │ │ +00046ce0: 0972 6573 6f6c 7665 5f6c 696e 6b73 2072 .resolve_links r │ │ │ +00046cf0: 6573 286d 5f74 6f72 7265 6e74 5f66 696c es(m_torrent_fil │ │ │ +00046d00: 6529 3b0a 0a09 0909 666f 7220 2861 7574 e);.....for (aut │ │ │ +00046d10: 6f20 636f 6e73 7426 616d 703b 2069 6820 o const& ih │ │ │ +00046d20: 3a20 6d5f 746f 7272 656e 745f 6669 6c65 : m_torrent_file │ │ │ +00046d30: 2d26 6774 3b73 696d 696c 6172 5f74 6f72 ->similar_tor │ │ │ +00046d40: 7265 6e74 7328 2929 0a09 0909 7b0a 0909 rents())....{... │ │ │ +00046d50: 0909 7374 643a 3a73 6861 7265 645f 7074 ..std::shared_pt │ │ │ +00046d60: 7226 6c74 3b74 6f72 7265 6e74 2667 743b r<torrent> │ │ │ +00046d70: 2074 203d 206d 5f73 6573 2e66 696e 645f t = m_ses.find_ │ │ │ +00046d80: 746f 7272 656e 7428 696e 666f 5f68 6173 torrent(info_has │ │ │ +00046d90: 685f 7428 6968 2929 2e6c 6f63 6b28 293b h_t(ih)).lock(); │ │ │ +00046da0: 0a09 0909 0969 6620 2821 7429 2063 6f6e .....if (!t) con │ │ │ +00046db0: 7469 6e75 653b 0a0a 0909 0909 2f2f 204f tinue;......// O │ │ │ +00046dc0: 6e6c 7920 6174 7465 6d70 7420 746f 2072 nly attempt to r │ │ │ +00046dd0: 6575 7365 2066 696c 6573 2066 726f 6d20 euse files from │ │ │ +00046de0: 746f 7272 656e 7473 2074 6861 7420 6172 torrents that ar │ │ │ +00046df0: 6520 7365 6564 696e 672e 0a3c 6469 7620 e seeding..
    ....if │ │ │ +00046e30: 2821 742d 2667 743b 6973 5f73 6565 6428 (!t->is_seed( │ │ │ +00046e40: 2929 2063 6f6e 7469 6e75 653b 0a3c 2f64 )) continue;......auto ti │ │ │ +00046e60: 3d20 742d 2667 743b 6765 745f 746f 7272 = t->get_torr │ │ │ +00046e70: 656e 745f 6669 6c65 2829 3b0a 0909 0909 ent_file();..... │ │ │ +00046e80: 7265 732e 6d61 7463 6828 2a74 692c 2066 res.match(*ti, f │ │ │ +00046e90: 696c 656e 616d 6573 2874 692d 2667 743b ilenames(ti-> │ │ │ +00046ea0: 6c61 796f 7574 2829 2c20 742d 2667 743b layout(), t-> │ │ │ +00046eb0: 6d5f 7265 6e61 6d65 645f 6669 6c65 7329 m_renamed_files) │ │ │ +00046ec0: 2c20 742d 2667 743b 7361 7665 5f70 6174 , t->save_pat │ │ │ +00046ed0: 6828 2929 3b0a 0909 097d 0a09 0909 666f h());....}....fo │ │ │ +00046ee0: 7220 2861 7574 6f20 636f 6e73 7426 616d r (auto const&am │ │ │ +00046ef0: 703b 2063 203a 206d 5f74 6f72 7265 6e74 p; c : m_torrent │ │ │ +00046f00: 5f66 696c 652d 2667 743b 636f 6c6c 6563 _file->collec │ │ │ +00046f10: 7469 6f6e 7328 2929 0a09 0909 7b0a 0909 tions())....{... │ │ │ +00046f20: 0909 7374 643a 3a76 6563 746f 7226 6c74 ..std::vector< │ │ │ +00046f30: 3b73 7464 3a3a 7368 6172 6564 5f70 7472 ;std::shared_ptr │ │ │ +00046f40: 266c 743b 746f 7272 656e 7426 6774 3b26 <torrent>& │ │ │ +00046f50: 6774 3b20 7473 203d 206d 5f73 6573 2e66 gt; ts = m_ses.f │ │ │ +00046f60: 696e 645f 636f 6c6c 6563 7469 6f6e 2863 ind_collection(c │ │ │ +00046f70: 293b 0a0a 0909 0909 666f 7220 2861 7574 );......for (aut │ │ │ +00046f80: 6f20 636f 6e73 7426 616d 703b 2074 203a o const& t : │ │ │ +00046f90: 2074 7329 0a09 0909 097b 0a09 0909 0909 ts).....{...... │ │ │ +00046fa0: 2f2f 204f 6e6c 7920 6174 7465 6d70 7420 // Only attempt │ │ │ +00046fb0: 746f 2072 6575 7365 2066 696c 6573 2066 to reuse files f │ │ │ +00046fc0: 726f 6d20 746f 7272 656e 7473 2074 6861 rom torrents tha │ │ │ +00046fd0: 7420 6172 6520 7365 6564 696e 672e 0a3c t are seeding..< │ │ │ +00046fe0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00046ff0: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +00047000: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +00047010: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +00047020: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ +00047050: 2f74 6f72 7265 6e74 2e63 7070 3a32 3133 /torrent.cpp:213 │ │ │ +00047060: 363c 2f61 3e3c 2f74 643e 3c74 643e 7468 6th │ │ │ +00047070: 6973 2063 6f75 6c64 2062 6520 6f70 7469 is could be opti │ │ │ +00047080: 6d69 7a65 6420 6279 206c 6f6f 6b69 6e67 mized by looking │ │ │ +00047090: 2075 7020 7768 6963 6820 6669 6c65 7320 up which files │ │ │ +000470a0: 6172 6520 636f 6d70 6c65 7465 2061 6e64 are complete and │ │ │ +000470b0: 206a 7573 7420 6c6f 6f6b 2061 7420 7468 just look at th │ │ │ +000470c0: 6f73 653c 2f74 643e 3c2f 7472 3e3c 7472 ose

    this could be o │ │ │ +00047120: 7074 696d 697a 6564 2062 7920 6c6f 6f6b ptimized by look │ │ │ +00047130: 696e 6720 7570 2077 6869 6368 2066 696c ing up which fil │ │ │ +00047140: 6573 2061 7265 0a63 6f6d 706c 6574 6520 es are.complete │ │ │ +00047150: 616e 6420 6a75 7374 206c 6f6f 6b20 6174 and just look at │ │ │ +00047160: 2074 686f 7365 3c2f 6832 3e3c 6834 3e2e those

    . │ │ │ +00047170: 2e2f 7372 632f 746f 7272 656e 742e 6370 ./src/torrent.cp │ │ │ +00047180: 703a 3231 3336 3c2f 6834 3e3c 7072 6520 p:2136

    ...resolve_
    │ │ │ +000471d0: 6c69 6e6b 7320 7265 7328 6d5f 746f 7272  links res(m_torr
    │ │ │ +000471e0: 656e 745f 6669 6c65 293b 0a0a 0909 0966  ent_file);.....f
    │ │ │ +000471f0: 6f72 2028 6175 746f 2063 6f6e 7374 2661  or (auto const&a
    │ │ │ +00047200: 6d70 3b20 6968 203a 206d 5f74 6f72 7265  mp; ih : m_torre
    │ │ │ +00047210: 6e74 5f66 696c 652d 2667 743b 7369 6d69  nt_file->simi
    │ │ │ +00047220: 6c61 725f 746f 7272 656e 7473 2829 290a  lar_torrents()).
    │ │ │ +00047230: 0909 097b 0a09 0909 0973 7464 3a3a 7368  ...{.....std::sh
    │ │ │ +00047240: 6172 6564 5f70 7472 266c 743b 746f 7272  ared_ptr<torr
    │ │ │ +00047250: 656e 7426 6774 3b20 7420 3d20 6d5f 7365  ent> t = m_se
    │ │ │ +00047260: 732e 6669 6e64 5f74 6f72 7265 6e74 2869  s.find_torrent(i
    │ │ │ +00047270: 6e66 6f5f 6861 7368 5f74 2869 6829 292e  nfo_hash_t(ih)).
    │ │ │ +00047280: 6c6f 636b 2829 3b0a 0909 0909 6966 2028  lock();.....if (
    │ │ │ +00047290: 2174 2920 636f 6e74 696e 7565 3b0a 0a09  !t) continue;...
    │ │ │ +000472a0: 0909 092f 2f20 4f6e 6c79 2061 7474 656d  ...// Only attem
    │ │ │ +000472b0: 7074 2074 6f20 7265 7573 6520 6669 6c65  pt to reuse file
    │ │ │ +000472c0: 7320 6672 6f6d 2074 6f72 7265 6e74 7320  s from torrents 
    │ │ │ +000472d0: 7468 6174 2061 7265 2073 6565 6469 6e67  that are seeding
    │ │ │ +000472e0: 2e0a 0909 0909 6966 2028 2174 2d26 6774  ......if (!t->
    │ │ │ +000472f0: 3b69 735f 7365 6564 2829 2920 636f 6e74  ;is_seed()) cont
    │ │ │ +00047300: 696e 7565 3b0a 0a09 0909 0961 7574 6f20  inue;......auto 
    │ │ │ +00047310: 7469 203d 2074 2d26 6774 3b67 6574 5f74  ti = t->get_t
    │ │ │ +00047320: 6f72 7265 6e74 5f66 696c 6528 293b 0a09  orrent_file();..
    │ │ │ +00047330: 0909 0972 6573 2e6d 6174 6368 282a 7469  ...res.match(*ti
    │ │ │ +00047340: 2c20 6669 6c65 6e61 6d65 7328 7469 2d26  , filenames(ti-&
    │ │ │ +00047350: 6774 3b6c 6179 6f75 7428 292c 2074 2d26  gt;layout(), t-&
    │ │ │ +00047360: 6774 3b6d 5f72 656e 616d 6564 5f66 696c  gt;m_renamed_fil
    │ │ │ +00047370: 6573 292c 2074 2d26 6774 3b73 6176 655f  es), t->save_
    │ │ │ +00047380: 7061 7468 2829 293b 0a09 0909 7d0a 0909  path());....}...
    │ │ │ +00047390: 0966 6f72 2028 6175 746f 2063 6f6e 7374  .for (auto const
    │ │ │ +000473a0: 2661 6d70 3b20 6320 3a20 6d5f 746f 7272  & c : m_torr
    │ │ │ +000473b0: 656e 745f 6669 6c65 2d26 6774 3b63 6f6c  ent_file->col
    │ │ │ +000473c0: 6c65 6374 696f 6e73 2829 290a 0909 097b  lections())....{
    │ │ │ +000473d0: 0a09 0909 0973 7464 3a3a 7665 6374 6f72  .....std::vector
    │ │ │ +000473e0: 266c 743b 7374 643a 3a73 6861 7265 645f  <std::shared_
    │ │ │ +000473f0: 7074 7226 6c74 3b74 6f72 7265 6e74 2667  ptr<torrent&g
    │ │ │ +00047400: 743b 2667 743b 2074 7320 3d20 6d5f 7365  t;> ts = m_se
    │ │ │ +00047410: 732e 6669 6e64 5f63 6f6c 6c65 6374 696f  s.find_collectio
    │ │ │ +00047420: 6e28 6329 3b0a 0a09 0909 0966 6f72 2028  n(c);......for (
    │ │ │ +00047430: 6175 746f 2063 6f6e 7374 2661 6d70 3b20  auto const& 
    │ │ │ +00047440: 7420 3a20 7473 290a 0909 0909 7b0a 0909  t : ts).....{...
    │ │ │ +00047450: 0909 092f 2f20 4f6e 6c79 2061 7474 656d  ...// Only attem
    │ │ │ +00047460: 7074 2074 6f20 7265 7573 6520 6669 6c65  pt to reuse file
    │ │ │ +00047470: 7320 6672 6f6d 2074 6f72 7265 6e74 7320  s from torrents 
    │ │ │ +00047480: 7468 6174 2061 7265 2073 6565 6469 6e67  that are seeding
    │ │ │ +00047490: 2e0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +000474c0: 0909 0909 0969 6620 2821 742d 2667 743b .....if (!t-> │ │ │ +000474d0: 6973 5f73 6565 6428 2929 2063 6f6e 7469 is_seed()) conti │ │ │ +000474e0: 6e75 653b 0a3c 2f64 6976 3e0a 0909 0909 nue;.
    ..... │ │ │ +000474f0: 0961 7574 6f20 7469 203d 2074 2d26 6774 .auto ti = t-> │ │ │ +00047500: 3b67 6574 5f74 6f72 7265 6e74 5f66 696c ;get_torrent_fil │ │ │ +00047510: 6528 293b 0a09 0909 0909 7265 732e 6d61 e();......res.ma │ │ │ +00047520: 7463 6828 2a74 692c 2066 696c 656e 616d tch(*ti, filenam │ │ │ +00047530: 6573 2874 692d 2667 743b 6c61 796f 7574 es(ti->layout │ │ │ +00047540: 2829 2c20 742d 2667 743b 6d5f 7265 6e61 (), t->m_rena │ │ │ +00047550: 6d65 645f 6669 6c65 7329 2c20 742d 2667 med_files), t-&g │ │ │ +00047560: 743b 7361 7665 5f70 6174 6828 2929 3b0a t;save_path());. │ │ │ +00047570: 0909 0909 7d0a 0909 097d 0a0a 0909 096c ....}....}.....l │ │ │ +00047580: 696e 6b73 203d 2073 7464 3a3a 6d6f 7665 inks = std::move │ │ │ +00047590: 2872 6573 292e 6765 745f 6c69 6e6b 7328 (res).get_links( │ │ │ +000475a0: 293b 0a09 097d 0a23 656e 6469 6620 2f2f );...}.#endif // │ │ │ +000475b0: 2054 4f52 5245 4e54 5f44 4953 4142 4c45 TORRENT_DISABLE │ │ │ +000475c0: 5f4d 5554 4142 4c45 5f54 4f52 5245 4e54 _MUTABLE_TORRENT │ │ │ +000475d0: 530a 0a23 6966 2054 4f52 5245 4e54 5f55 S..#if TORRENT_U │ │ │ +000475e0: 5345 5f41 5353 4552 5453 0a09 0954 4f52 SE_ASSERTS...TOR │ │ │ +000475f0: 5245 4e54 5f41 5353 4552 5428 6d5f 6f75 RENT_ASSERT(m_ou │ │ │ +00047600: 7473 7461 6e64 696e 675f 6368 6563 6b5f tstanding_check_ │ │ │ +00047610: 6669 6c65 7320 3d3d 2066 616c 7365 293b files == false); │ │ │ +00047620: 0a09 096d 5f6f 7574 7374 616e 6469 6e67 ...m_outstanding │ │ │ +00047630: 5f63 6865 636b 5f66 696c 6573 203d 2074 _check_files = t │ │ │ +00047640: 7275 653b 0a23 656e 6469 660a 0a09 0969 rue;.#endif....i │ │ │ +00047650: 6620 2821 6d5f 6164 645f 746f 7272 656e f (!m_add_torren │ │ │ +00047660: 745f 7061 7261 6d73 207c 7c20 2128 6d5f t_params || !(m_ │ │ │ +00047670: 6164 645f 746f 7272 656e 745f 7061 7261 add_torrent_para │ │ │ +00047680: 6d73 2d26 6774 3b66 6c61 6773 2026 616d ms->flags &am │ │ │ +00047690: 703b 2074 6f72 7265 6e74 5f66 6c61 6773 p; torrent_flags │ │ │ +000476a0: 3a3a 6e6f 5f76 6572 6966 795f 6669 6c65 ::no_verify_file │ │ │ +000476b0: 7329 290a 0909 7b0a 0909 096d 5f73 6573 s))...{....m_ses │ │ │ +000476c0: 2e64 6973 6b5f 7468 7265 6164 2829 2e61 .disk_thread().a │ │ │ +000476d0: 7379 6e63 5f63 6865 636b 5f66 696c 6573 sync_check_files │ │ │ +000476e0: 280a 0909 0909 6d5f 7374 6f72 6167 652c (.....m_storage, │ │ │ +000476f0: 206d 5f61 6464 5f74 6f72 7265 6e74 5f70 m_add_torrent_p │ │ │ +00047700: 6172 616d 7320 3f20 6d5f 6164 645f 746f arams ? m_add_to │ │ │ +00047710: 7272 656e 745f 7061 7261 6d73 2e67 6574 rrent_params.get │ │ │ +00047720: 2829 203a 206e 756c 6c70 7472 0a09 0909 () : nullptr.... │ │ │ +00047730: 092c 2073 7464 3a3a 6d6f 7665 286c 696e ., std::move(lin │ │ │ +00047740: 6b73 292c 205b 7365 6c66 203d 2073 6861 ks), [self = sha │ │ │ +00047750: 7265 645f 6672 6f6d 5f74 6869 7328 295d red_from_this()] │ │ │ +00047760: 2873 7461 7475 735f 7420 7374 2c20 7374 (status_t st, st │ │ │ +00047770: 6f72 6167 655f 6572 726f 7220 636f 6e73 orage_error cons │ │ │ +00047780: 7426 616d 703b 2065 7272 6f72 290a 0909 t& error)... │ │ │ +00047790: 0909 7b20 7365 6c66 2d26 6774 3b6f 6e5f ..{ self->on_ │ │ │ +000477a0: 7265 7375 6d65 5f64 6174 615f 6368 6563 resume_data_chec │ │ │ +000477b0: 6b65 6428 7374 2c20 6572 726f 7229 3b20 ked(st, error); │ │ │ +000477c0: 7d29 3b0a 2369 666e 6465 6620 544f 5252 });.#ifndef TORR │ │ │ +000477d0: 454e 545f 4449 5341 424c 455f 4c4f 4747 ENT_DISABLE_LOGG │ │ │ +000477e0: 494e 470a 0909 0964 6562 7567 5f6c 6f67 ING....debug_log │ │ │ +000477f0: 2822 696e 6974 2c20 6173 796e 635f 6368 ("init, async_ch │ │ │ +00047800: 6563 6b5f 6669 6c65 7322 293b 0a23 656e eck_files");.#en │ │ │ +00047810: 6469 660a 0909 096d 5f73 6573 2e64 6566 dif....m_ses.def │ │ │ +00047820: 6572 7265 645f 7375 626d 6974 5f6a 6f62 erred_submit_job │ │ │ +00047830: 7328 293b 0a09 097d 0a09 0965 6c73 650a s();...}...else. │ │ │ +00047840: 0909 7b0a 0909 096f 6e5f 7265 7375 6d65 ..{....on_resume │ │ │ +00047850: 5f64 6174 615f 6368 6563 6b65 6428 7b7d _data_checked({} │ │ │ +00047860: 2c20 7374 6f72 6167 655f 6572 726f 727b , storage_error{ │ │ │ +00047870: 7d29 3b0a 0909 7d0a 3c2f 7072 653e 3c2f });...}.
    relevan │ │ │ +000478b0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/torren │ │ │ +000478f0: 742e 6370 703a 3239 3435 3c2f 613e 3c2f t.cpp:2945this patt │ │ │ +00047910: 6572 6e20 6973 2072 6570 6561 7465 6420 ern is repeated │ │ │ +00047920: 696e 2061 2066 6577 2070 6c61 6365 732e in a few places. │ │ │ +00047930: 2046 6163 746f 7220 7468 6973 2069 6e74 Factor this int │ │ │ +00047940: 6f20 6120 6675 6e63 7469 6f6e 2061 6e64 o a function and │ │ │ +00047950: 2067 656e 6572 616c 697a 6520 7468 6520 generalize the │ │ │ +00047960: 636f 6e63 6570 7420 6f66 2061 2074 6f72 concept of a tor │ │ │ +00047970: 7265 6e74 2068 6176 696e 6720 6120 6465 rent having a de │ │ │ +00047980: 6469 6361 7465 6420 6c69 7374 656e 2070 dicated listen p │ │ │ +00047990: 6f72 743c 2f74 643e 3c2f 7472 3e3c 7472 ort

    this pattern is │ │ │ +000479f0: 2072 6570 6561 7465 6420 696e 2061 2066 repeated in a f │ │ │ +00047a00: 6577 2070 6c61 6365 732e 2046 6163 746f ew places. Facto │ │ │ +00047a10: 7220 7468 6973 2069 6e74 6f0a 6120 6675 r this into.a fu │ │ │ +00047a20: 6e63 7469 6f6e 2061 6e64 2067 656e 6572 nction and gener │ │ │ +00047a30: 616c 697a 6520 7468 6520 636f 6e63 6570 alize the concep │ │ │ +00047a40: 7420 6f66 2061 2074 6f72 7265 6e74 2068 t of a torrent h │ │ │ +00047a50: 6176 696e 6720 610a 6465 6469 6361 7465 aving a.dedicate │ │ │ +00047a60: 6420 6c69 7374 656e 2070 6f72 743c 2f68 d listen port

    ../src/tor │ │ │ +00047a80: 7265 6e74 2e63 7070 3a32 3934 353c 2f68 rent.cpp:2945
    ..//
    │ │ │ +00047ad0: 206e 6f74 2072 6561 6479 2066 6f72 2070   not ready for p
    │ │ │ +00047ae0: 6565 7273 2e20 4578 6365 7074 2c20 6966  eers. Except, if
    │ │ │ +00047af0: 2077 6520 646f 6e27 7420 6861 7665 206d   we don't have m
    │ │ │ +00047b00: 6574 6164 6174 612c 0a09 092f 2f20 7765  etadata,...// we
    │ │ │ +00047b10: 206e 6565 6420 7065 6572 7320 746f 2064   need peers to d
    │ │ │ +00047b20: 6f77 6e6c 6f61 6420 6672 6f6d 0a09 0969  ownload from...i
    │ │ │ +00047b30: 6620 2821 6d5f 6669 6c65 735f 6368 6563  f (!m_files_chec
    │ │ │ +00047b40: 6b65 6420 2661 6d70 3b26 616d 703b 2076  ked && v
    │ │ │ +00047b50: 616c 6964 5f6d 6574 6164 6174 6128 2929  alid_metadata())
    │ │ │ +00047b60: 2072 6574 7572 6e3b 0a0a 0909 6966 2028   return;....if (
    │ │ │ +00047b70: 216d 5f61 6e6e 6f75 6e63 655f 746f 5f6c  !m_announce_to_l
    │ │ │ +00047b80: 7364 2920 7265 7475 726e 3b0a 0a09 092f  sd) return;..../
    │ │ │ +00047b90: 2f20 7072 6976 6174 6520 746f 7272 656e  / private torren
    │ │ │ +00047ba0: 7473 2061 7265 206e 6576 6572 2061 6e6e  ts are never ann
    │ │ │ +00047bb0: 6f75 6e63 6564 206f 6e20 4c53 440a 0909  ounced on LSD...
    │ │ │ +00047bc0: 6966 2028 6d5f 746f 7272 656e 745f 6669  if (m_torrent_fi
    │ │ │ +00047bd0: 6c65 2d26 6774 3b69 735f 7661 6c69 6428  le->is_valid(
    │ │ │ +00047be0: 2920 2661 6d70 3b26 616d 703b 206d 5f74  ) && m_t
    │ │ │ +00047bf0: 6f72 7265 6e74 5f66 696c 652d 2667 743b  orrent_file->
    │ │ │ +00047c00: 7072 6976 2829 2920 7265 7475 726e 3b0a  priv()) return;.
    │ │ │ +00047c10: 0a23 6966 2054 4f52 5245 4e54 5f55 5345  .#if TORRENT_USE
    │ │ │ +00047c20: 5f49 3250 0a09 092f 2f20 6932 7020 746f  _I2P...// i2p to
    │ │ │ +00047c30: 7272 656e 7473 2061 7265 2061 6c73 6f20  rrents are also 
    │ │ │ +00047c40: 6e65 7665 7220 616e 6e6f 756e 6365 6420  never announced 
    │ │ │ +00047c50: 6f6e 204c 5344 0a09 092f 2f20 756e 6c65  on LSD...// unle
    │ │ │ +00047c60: 7373 2077 6520 616c 6c6f 7720 6d69 7865  ss we allow mixe
    │ │ │ +00047c70: 6420 7377 6172 6d73 0a09 0969 6620 2869  d swarms...if (i
    │ │ │ +00047c80: 735f 6932 7028 2920 2661 6d70 3b26 616d  s_i2p() &&am
    │ │ │ +00047c90: 703b 2021 7365 7474 696e 6773 2829 2e67  p; !settings().g
    │ │ │ +00047ca0: 6574 5f62 6f6f 6c28 7365 7474 696e 6773  et_bool(settings
    │ │ │ +00047cb0: 5f70 6163 6b3a 3a61 6c6c 6f77 5f69 3270  _pack::allow_i2p
    │ │ │ +00047cc0: 5f6d 6978 6564 2929 0a09 0909 7265 7475  _mixed))....retu
    │ │ │ +00047cd0: 726e 3b0a 2365 6e64 6966 0a0a 0909 6966  rn;.#endif....if
    │ │ │ +00047ce0: 2028 6973 5f70 6175 7365 6428 2929 2072   (is_paused()) r
    │ │ │ +00047cf0: 6574 7572 6e3b 0a0a 0909 6966 2028 216d  eturn;....if (!m
    │ │ │ +00047d00: 5f73 6573 2e68 6173 5f6c 7364 2829 2920  _ses.has_lsd()) 
    │ │ │ +00047d10: 7265 7475 726e 3b0a 0a3c 6469 7620 7374  return;..
    #ifdef TO │ │ │ +00047d50: 5252 454e 545f 5353 4c5f 5045 4552 530a RRENT_SSL_PEERS. │ │ │ +00047d60: 3c2f 6469 763e 0909 696e 7420 706f 7274
    ..int port │ │ │ +00047d70: 203d 2069 735f 7373 6c5f 746f 7272 656e = is_ssl_torren │ │ │ +00047d80: 7428 2920 3f20 6d5f 7365 732e 7373 6c5f t() ? m_ses.ssl_ │ │ │ +00047d90: 6c69 7374 656e 5f70 6f72 7428 2920 3a20 listen_port() : │ │ │ +00047da0: 6d5f 7365 732e 6c69 7374 656e 5f70 6f72 m_ses.listen_por │ │ │ +00047db0: 7428 293b 0a23 656c 7365 0a09 0969 6e74 t();.#else...int │ │ │ +00047dc0: 2070 6f72 7420 3d20 6d5f 7365 732e 6c69 port = m_ses.li │ │ │ +00047dd0: 7374 656e 5f70 6f72 7428 293b 0a23 656e sten_port();.#en │ │ │ +00047de0: 6469 660a 0a09 092f 2f20 616e 6e6f 756e dif....// announ │ │ │ +00047df0: 6365 2077 6974 6820 7468 6520 6c6f 6361 ce with the loca │ │ │ +00047e00: 6c20 6469 7363 6f76 6572 7920 7365 7276 l discovery serv │ │ │ +00047e10: 6963 650a 0909 6d5f 746f 7272 656e 745f ice...m_torrent_ │ │ │ +00047e20: 6669 6c65 2d26 6774 3b69 6e66 6f5f 6861 file->info_ha │ │ │ +00047e30: 7368 6573 2829 2e66 6f72 5f65 6163 6828 shes().for_each( │ │ │ +00047e40: 5b26 616d 703b 5d28 7368 6131 5f68 6173 [&](sha1_has │ │ │ +00047e50: 6820 636f 6e73 7426 616d 703b 2069 682c h const& ih, │ │ │ +00047e60: 2070 726f 746f 636f 6c5f 7665 7273 696f protocol_versio │ │ │ +00047e70: 6e29 0a09 097b 0a09 0909 6d5f 7365 732e n)...{....m_ses. │ │ │ +00047e80: 616e 6e6f 756e 6365 5f6c 7364 2869 682c announce_lsd(ih, │ │ │ +00047e90: 2070 6f72 7429 3b0a 0909 7d29 3b0a 097d port);...});..} │ │ │ +00047ea0: 0a0a 2369 666e 6465 6620 544f 5252 454e ..#ifndef TORREN │ │ │ +00047eb0: 545f 4449 5341 424c 455f 4448 540a 0a09 T_DISABLE_DHT... │ │ │ +00047ec0: 766f 6964 2074 6f72 7265 6e74 3a3a 6468 void torrent::dh │ │ │ +00047ed0: 745f 616e 6e6f 756e 6365 2829 0a09 7b0a t_announce()..{. │ │ │ +00047ee0: 0909 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +00047ef0: 2869 735f 7369 6e67 6c65 5f74 6872 6561 (is_single_threa │ │ │ +00047f00: 6428 2929 3b0a 0909 6966 2028 216d 5f73 d());...if (!m_s │ │ │ +00047f10: 6573 2e64 6874 2829 290a 0909 7b0a 2369 es.dht())...{.#i │ │ │ +00047f20: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ +00047f30: 5341 424c 455f 4c4f 4747 494e 470a 0909 SABLE_LOGGING... │ │ │ +00047f40: 0964 6562 7567 5f6c 6f67 2822 4448 543a .debug_log("DHT: │ │ │ +00047f50: 206e 6f20 6468 7420 696e 6974 6961 6c69 no dht initiali │ │ │ +00047f60: 7a65 6422 293b 0a23 656e 6469 660a 0909 zed");.#endif... │ │ │ +00047f70: 0972 6574 7572 6e3b 0a09 097d 0a09 0969 .return;...}...i │ │ │ +00047f80: 6620 2821 7368 6f75 6c64 5f61 6e6e 6f75 f (!should_annou │ │ │ +00047f90: 6e63 655f 6468 7428 2929 0a09 097b 0a23 nce_dht())...{.# │ │ │ +00047fa0: 6966 6e64 6566 2054 4f52 5245 4e54 5f44 ifndef TORRENT_D │ │ │ +00047fb0: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09 ISABLE_LOGGING.. │ │ │ +00047fc0: 0909 6966 2028 7368 6f75 6c64 5f6c 6f67 ..if (should_log │ │ │ +00047fd0: 2829 290a 0909 097b 0a23 6966 2054 4f52 ())....{.#if TOR │ │ │ +00047fe0: 5245 4e54 5f55 5345 5f49 3250 0a3c 2f70 RENT_USE_I2P.

    re │ │ │ +00048020: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/t │ │ │ +00048060: 6f72 7265 6e74 2e63 7070 3a33 3239 303c orrent.cpp:3290< │ │ │ +00048070: 2f61 3e3c 2f74 643e 3c74 643e 6974 2077 /a>it w │ │ │ +00048080: 6f75 6c64 2062 6520 6e69 6365 2074 6f20 ould be nice to │ │ │ +00048090: 7261 6973 6520 7468 6520 6162 7374 7261 raise the abstra │ │ │ +000480a0: 6374 696f 6e20 6c65 7665 6c20 6f66 2074 ction level of t │ │ │ +000480b0: 6865 2074 7261 636b 6572 5f6c 6973 7420 he tracker_list │ │ │ +000480c0: 6f72 2074 7261 636b 6572 7320 6120 6269 or trackers a bi │ │ │ +000480d0: 7420 6865 7265 3c2f 7464 3e3c 2f74 723e t here │ │ │ +000480e0: 3c74 7220 6964 3d22 3137 3422 2073 7479 │ │ │ +00048110: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00048120: 3c68 323e 6974 2077 6f75 6c64 2062 6520

    it would be │ │ │ +00048130: 6e69 6365 2074 6f20 7261 6973 6520 7468 nice to raise th │ │ │ +00048140: 6520 6162 7374 7261 6374 696f 6e20 6c65 e abstraction le │ │ │ +00048150: 7665 6c20 6f66 2074 6865 0a74 7261 636b vel of the.track │ │ │ +00048160: 6572 5f6c 6973 7420 6f72 2074 7261 636b er_list or track │ │ │ +00048170: 6572 7320 6120 6269 7420 6865 7265 3c2f ers a bit here

    ../src/to │ │ │ +00048190: 7272 656e 742e 6370 703a 3332 3930 3c2f rrent.cpp:3290
    ..t
    │ │ │ +000481e0: 696d 655f 706f 696e 7433 3220 636f 6e73  ime_point32 cons
    │ │ │ +000481f0: 7420 6e6f 7720 3d20 6175 783a 3a74 696d  t now = aux::tim
    │ │ │ +00048200: 655f 6e6f 7733 3228 293b 0a0a 0909 2f2f  e_now32();....//
    │ │ │ +00048210: 2065 6163 6820 6c69 7374 656e 2073 6f63   each listen soc
    │ │ │ +00048220: 6b65 7420 6765 7473 2069 7473 206f 776e  ket gets its own
    │ │ │ +00048230: 2061 6e6e 6f75 6e63 6520 7374 6174 650a   announce state.
    │ │ │ +00048240: 0909 2f2f 2073 6f20 7468 6174 2065 6163  ..// so that eac
    │ │ │ +00048250: 6820 6f6e 6520 7368 6f75 6c64 2067 6574  h one should get
    │ │ │ +00048260: 2061 7420 6c65 6173 7420 6f6e 6520 616e   at least one an
    │ │ │ +00048270: 6e6f 756e 6365 0a09 0973 7464 3a3a 7665  nounce...std::ve
    │ │ │ +00048280: 6374 6f72 266c 743b 616e 6e6f 756e 6365  ctor<announce
    │ │ │ +00048290: 5f73 7461 7465 2667 743b 206c 6973 7465  _state> liste
    │ │ │ +000482a0: 6e5f 736f 636b 6574 5f73 7461 7465 733b  n_socket_states;
    │ │ │ +000482b0: 0a0a 0909 626f 6f6c 2063 6f6e 7374 2061  ....bool const a
    │ │ │ +000482c0: 6e6e 6f75 6e63 655f 746f 5f61 6c6c 5f74  nnounce_to_all_t
    │ │ │ +000482d0: 6965 7273 203d 2073 6574 7469 6e67 7328  iers = settings(
    │ │ │ +000482e0: 292e 6765 745f 626f 6f6c 2873 6574 7469  ).get_bool(setti
    │ │ │ +000482f0: 6e67 735f 7061 636b 3a3a 616e 6e6f 756e  ngs_pack::announ
    │ │ │ +00048300: 6365 5f74 6f5f 616c 6c5f 7469 6572 7329  ce_to_all_tiers)
    │ │ │ +00048310: 3b0a 0909 626f 6f6c 2063 6f6e 7374 2061  ;...bool const a
    │ │ │ +00048320: 6e6e 6f75 6e63 655f 746f 5f61 6c6c 5f74  nnounce_to_all_t
    │ │ │ +00048330: 7261 636b 6572 7320 3d20 7365 7474 696e  rackers = settin
    │ │ │ +00048340: 6773 2829 2e67 6574 5f62 6f6f 6c28 7365  gs().get_bool(se
    │ │ │ +00048350: 7474 696e 6773 5f70 6163 6b3a 3a61 6e6e  ttings_pack::ann
    │ │ │ +00048360: 6f75 6e63 655f 746f 5f61 6c6c 5f74 7261  ounce_to_all_tra
    │ │ │ +00048370: 636b 6572 7329 3b0a 2369 666e 6465 6620  ckers);.#ifndef 
    │ │ │ +00048380: 544f 5252 454e 545f 4449 5341 424c 455f  TORRENT_DISABLE_
    │ │ │ +00048390: 4c4f 4747 494e 470a 0909 696e 7420 6964  LOGGING...int id
    │ │ │ +000483a0: 7820 3d20 2d31 3b0a 0909 6966 2028 7368  x = -1;...if (sh
    │ │ │ +000483b0: 6f75 6c64 5f6c 6f67 2829 290a 0909 7b0a  ould_log())...{.
    │ │ │ +000483c0: 0909 0964 6562 7567 5f6c 6f67 2822 2a2a  ...debug_log("**
    │ │ │ +000483d0: 2a20 616e 6e6f 756e 6365 3a20 220a 0909  * announce: "...
    │ │ │ +000483e0: 0909 225b 2061 6e6e 6f75 6e63 655f 746f  .."[ announce_to
    │ │ │ +000483f0: 5f61 6c6c 5f74 6965 7273 3a20 2564 2061  _all_tiers: %d a
    │ │ │ +00048400: 6e6e 6f75 6e63 655f 746f 5f61 6c6c 5f74  nnounce_to_all_t
    │ │ │ +00048410: 7261 636b 6572 733a 2025 6420 6e75 6d5f  rackers: %d num_
    │ │ │ +00048420: 7472 6163 6b65 7273 3a20 2564 205d 220a  trackers: %d ]".
    │ │ │ +00048430: 0909 0909 2c20 616e 6e6f 756e 6365 5f74  ...., announce_t
    │ │ │ +00048440: 6f5f 616c 6c5f 7469 6572 730a 0909 0909  o_all_tiers.....
    │ │ │ +00048450: 2c20 616e 6e6f 756e 6365 5f74 6f5f 616c  , announce_to_al
    │ │ │ +00048460: 6c5f 7472 6163 6b65 7273 0a09 0909 092c  l_trackers.....,
    │ │ │ +00048470: 2069 6e74 286d 5f74 7261 636b 6572 732e   int(m_trackers.
    │ │ │ +00048480: 7369 7a65 2829 2929 3b0a 0909 7d0a 2365  size()));...}.#e
    │ │ │ +00048490: 6e64 6966 0a0a 3c64 6976 2073 7479 6c65  ndif..
    ..for (auto& │ │ │ +000484d0: 616d 703b 2061 6520 3a20 6d5f 7472 6163 amp; ae : m_trac │ │ │ +000484e0: 6b65 7273 290a 3c2f 6469 763e 0909 7b0a kers).
    ..{. │ │ │ +000484f0: 2369 666e 6465 6620 544f 5252 454e 545f #ifndef TORRENT_ │ │ │ +00048500: 4449 5341 424c 455f 4c4f 4747 494e 470a DISABLE_LOGGING. │ │ │ +00048510: 0909 092b 2b69 6478 3b0a 2365 6e64 6966 ...++idx;.#endif │ │ │ +00048520: 0a09 0909 7265 6672 6573 685f 656e 6470 ....refresh_endp │ │ │ +00048530: 6f69 6e74 5f6c 6973 7428 6d5f 7365 732c oint_list(m_ses, │ │ │ +00048540: 2069 735f 7373 6c5f 746f 7272 656e 7428 is_ssl_torrent( │ │ │ +00048550: 292c 2062 6f6f 6c28 6d5f 636f 6d70 6c65 ), bool(m_comple │ │ │ +00048560: 7465 5f73 656e 7429 2c20 6165 293b 0a0a te_sent), ae);.. │ │ │ +00048570: 0909 092f 2f20 6966 2074 7261 636b 6572 ...// if tracker │ │ │ +00048580: 6964 2069 7320 6e6f 7420 7370 6563 6966 id is not specif │ │ │ +00048590: 6965 6420 666f 7220 7472 6163 6b65 7220 ied for tracker │ │ │ +000485a0: 7573 6520 6465 6661 756c 7420 6f6e 652c use default one, │ │ │ +000485b0: 2070 726f 6261 626c 7920 7365 7420 6578 probably set ex │ │ │ +000485c0: 706c 6963 6974 6c79 0a09 0909 7265 712e plicitly....req. │ │ │ +000485d0: 7472 6163 6b65 7269 6420 3d20 6165 2e74 trackerid = ae.t │ │ │ +000485e0: 7261 636b 6572 6964 2e65 6d70 7479 2829 rackerid.empty() │ │ │ +000485f0: 203f 206d 5f74 7261 636b 6572 6964 203a ? m_trackerid : │ │ │ +00048600: 2061 652e 7472 6163 6b65 7269 643b 0a09 ae.trackerid;.. │ │ │ +00048610: 0909 7265 712e 7572 6c20 3d20 6165 2e75 ..req.url = ae.u │ │ │ +00048620: 726c 3b0a 0a23 6966 2054 4f52 5245 4e54 rl;..#if TORRENT │ │ │ +00048630: 5f55 5345 5f49 3250 0a09 0909 2f2f 2069 _USE_I2P....// i │ │ │ +00048640: 6620 7765 2064 6f6e 2774 2061 6c6c 6f77 f we don't allow │ │ │ +00048650: 206d 6978 696e 6720 6e6f 726d 616c 2070 mixing normal p │ │ │ +00048660: 6565 7273 2069 6e74 6f20 7468 6973 2069 eers into this i │ │ │ +00048670: 3270 2074 6f72 7265 6e74 2c0a 0909 092f 2p torrent,..../ │ │ │ +00048680: 2f20 736b 6970 206e 6f6e 2d69 3270 2074 / skip non-i2p t │ │ │ +00048690: 7261 636b 6572 732e 2075 7064 6174 655f rackers. update_ │ │ │ +000486a0: 7472 6163 6b65 725f 7469 6d65 7228 2920 tracker_timer() │ │ │ +000486b0: 6170 706c 6965 7320 7468 650a 0909 092f applies the..../ │ │ │ +000486c0: 2f20 7361 6d65 2073 6b69 7020 736f 2074 / same skip so t │ │ │ +000486d0: 6865 2074 696d 6572 2064 6f65 736e 2774 he timer doesn't │ │ │ +000486e0: 206b 6565 7020 6669 7269 6e67 2066 6f72 keep firing for │ │ │ +000486f0: 2074 7261 636b 6572 7320 7765 276c 6c0a trackers we'll. │ │ │ +00048700: 0909 092f 2f20 6e65 7665 7220 636f 6e74 ...// never cont │ │ │ +00048710: 6163 742e 0a09 0909 6966 2028 2169 3270 act.....if (!i2p │ │ │ +00048720: 5f63 6f6d 7061 7469 626c 655f 7472 6163 _compatible_trac │ │ │ +00048730: 6b65 7228 6165 2929 2063 6f6e 7469 6e75 ker(ae)) continu │ │ │ +00048740: 653b 0a09 0909 2f2f 2072 6571 2069 7320 e;....// req is │ │ │ +00048750: 7265 7573 6564 2061 6372 6f73 7320 6974 reused across it │ │ │ +00048760: 6572 6174 696f 6e73 2c20 736f 2073 6574 erations, so set │ │ │ +00048770: 2074 6865 2069 3270 2062 6974 2074 6f20 the i2p bit to │ │ │ +00048780: 6d61 7463 680a 0909 092f 2f20 7468 6973 match....// this │ │ │ +00048790: 2074 7261 636b 6572 2072 6174 6865 7220 tracker rather │ │ │ +000487a0: 7468 616e 206f 6e6c 7920 6576 6572 204f than only ever O │ │ │ +000487b0: 522d 696e 6720 6974 2069 6e2e 0a09 0909 R-ing it in..... │ │ │ +000487c0: 6966 2028 6165 2e69 3270 290a 0909 0909 if (ae.i2p)..... │ │ │ +000487d0: 7265 712e 6b69 6e64 207c 3d20 7472 6163 req.kind |= trac │ │ │ +000487e0: 6b65 725f 7265 7175 6573 743a 3a69 3270 ker_request::i2p │ │ │ +000487f0: 3b0a 0909 0965 6c73 650a 0909 0909 7265 ;....else.....re │ │ │ +00048800: 712e 6b69 6e64 2026 616d 703b 3d20 7e74 q.kind &= ~t │ │ │ +00048810: 7261 636b 6572 5f72 6571 7565 7374 3a3a racker_request:: │ │ │ +00048820: 6932 703b 0a23 656e 6469 660a 0a09 0909 i2p;.#endif..... │ │ │ +00048830: 666f 7220 2861 7574 6f26 616d 703b 2061 for (auto& a │ │ │ +00048840: 6570 203a 2061 652e 656e 6470 6f69 6e74 ep : ae.endpoint │ │ │ +00048850: 7329 0a09 0909 7b0a 0909 0909 2f2f 2064 s)....{.....// d │ │ │ +00048860: 6f20 6e6f 7420 6164 6420 636f 6465 2077 o not add code w │ │ │ +00048870: 6869 6368 2063 6f6e 7469 6e75 6573 2074 hich continues t │ │ │ +00048880: 6f20 7468 6520 6e65 7874 2065 6e64 706f o the next endpo │ │ │ +00048890: 696e 7420 6865 7265 210a 0909 0909 2f2f int here!.....// │ │ │ +000488a0: 206c 6973 7465 6e5f 736f 636b 6574 5f73 listen_socket_s │ │ │ +000488b0: 7461 7465 7320 6e65 6564 7320 746f 2062 tates needs to b │ │ │ +000488c0: 6520 706f 7075 6c61 7465 6420 6576 656e e populated even │ │ │ +000488d0: 2069 6620 6e6f 6e65 206f 6620 7468 6520 if none of the │ │ │ +000488e0: 656e 6470 6f69 6e74 730a 0909 0909 2f2f endpoints.....// │ │ │ +000488f0: 2077 696c 6c20 6265 2061 6e6e 6f75 6e63 will be announc │ │ │ +00048900: 696e 6720 666f 7220 7468 6973 2074 7261 ing for this tra │ │ │ +00048910: 636b 6572 0a09 0909 092f 2f20 6f74 6865 cker.....// othe │ │ │ +00048920: 7277 6973 6520 7468 6520 6561 726c 7920 rwise the early │ │ │ +00048930: 6261 696c 206f 7574 2077 6865 6e20 6e65 bail out when ne │ │ │ +00048940: 6974 6865 7220 616e 6e6f 756e 6365 5f74 ither announce_t │ │ │ +00048950: 6f5f 616c 6c5f 7472 6163 6b65 7273 0a3c o_all_trackers.< │ │ │ +00048960: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00048970: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +00048980: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +00048990: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +000489a0: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566
    ../src │ │ │ +000489d0: 2f74 6f72 7265 6e74 2e63 7070 3a33 3832 /torrent.cpp:382 │ │ │ +000489e0: 343c 2f61 3e3c 2f74 643e 3c74 643e 6d6f 4mo │ │ │ +000489f0: 7665 2074 6869 7320 696e 746f 2061 2066 ve this into a f │ │ │ +00048a00: 756e 6374 696f 6e20 6f6e 2074 7261 636b unction on track │ │ │ +00048a10: 6572 5f6c 6973 743c 2f74 643e 3c2f 7472 er_list

    move this i │ │ │ +00048a70: 6e74 6f20 6120 6675 6e63 7469 6f6e 206f nto a function o │ │ │ +00048a80: 6e20 7472 6163 6b65 725f 6c69 7374 3c2f n tracker_list

    ../src/to │ │ │ +00048aa0: 7272 656e 742e 6370 703a 3338 3234 3c2f rrent.cpp:3824
    ..,
    │ │ │ +00048af0: 2073 7472 7563 7420 7472 6163 6b65 725f   struct tracker_
    │ │ │ +00048b00: 7265 7370 6f6e 7365 2063 6f6e 7374 2661  response const&a
    │ │ │ +00048b10: 6d70 3b20 7265 7370 290a 097b 0a09 0954  mp; resp)..{...T
    │ │ │ +00048b20: 4f52 5245 4e54 5f41 5353 4552 5428 6973  ORRENT_ASSERT(is
    │ │ │ +00048b30: 5f73 696e 676c 655f 7468 7265 6164 2829  _single_thread()
    │ │ │ +00048b40: 293b 0a0a 0909 494e 5641 5249 414e 545f  );....INVARIANT_
    │ │ │ +00048b50: 4348 4543 4b3b 0a09 0954 4f52 5245 4e54  CHECK;...TORRENT
    │ │ │ +00048b60: 5f41 5353 4552 5428 2128 722e 6b69 6e64  _ASSERT(!(r.kind
    │ │ │ +00048b70: 2026 616d 703b 2074 7261 636b 6572 5f72   & tracker_r
    │ │ │ +00048b80: 6571 7565 7374 3a3a 7363 7261 7065 5f72  equest::scrape_r
    │ │ │ +00048b90: 6571 7565 7374 2929 3b0a 0a09 092f 2f20  equest));....// 
    │ │ │ +00048ba0: 6966 2074 6865 2074 7261 636b 6572 2074  if the tracker t
    │ │ │ +00048bb0: 6f6c 6420 7573 2077 6861 7420 6f75 7220  old us what our 
    │ │ │ +00048bc0: 6578 7465 726e 616c 2049 5020 6164 6472  external IP addr
    │ │ │ +00048bd0: 6573 7320 6973 2c20 7265 636f 7264 2069  ess is, record i
    │ │ │ +00048be0: 7420 7769 7468 0a09 092f 2f20 6f75 7420  t with...// out 
    │ │ │ +00048bf0: 6578 7465 726e 616c 2049 5020 636f 756e  external IP coun
    │ │ │ +00048c00: 7465 7220 2861 6e64 2070 6173 7320 616c  ter (and pass al
    │ │ │ +00048c10: 6f6e 6720 7468 6520 4950 206f 6620 7468  ong the IP of th
    │ │ │ +00048c20: 6520 7472 6163 6b65 7220 746f 206b 6e6f  e tracker to kno
    │ │ │ +00048c30: 770a 0909 2f2f 2077 686f 2074 6f20 6174  w...// who to at
    │ │ │ +00048c40: 7472 6962 7574 6520 7468 6973 2076 6f74  tribute this vot
    │ │ │ +00048c50: 6520 746f 290a 0909 6966 2028 7265 7370  e to)...if (resp
    │ │ │ +00048c60: 2e65 7874 6572 6e61 6c5f 6970 2021 3d20  .external_ip != 
    │ │ │ +00048c70: 6164 6472 6573 7328 2920 2661 6d70 3b26  address() &&
    │ │ │ +00048c80: 616d 703b 2021 7472 6163 6b65 725f 6970  amp; !tracker_ip
    │ │ │ +00048c90: 2e69 735f 756e 7370 6563 6966 6965 6428  .is_unspecified(
    │ │ │ +00048ca0: 2920 2661 6d70 3b26 616d 703b 2072 2e6f  ) && r.o
    │ │ │ +00048cb0: 7574 676f 696e 675f 736f 636b 6574 290a  utgoing_socket).
    │ │ │ +00048cc0: 0909 096d 5f73 6573 2e73 6574 5f65 7874  ...m_ses.set_ext
    │ │ │ +00048cd0: 6572 6e61 6c5f 6164 6472 6573 7328 722e  ernal_address(r.
    │ │ │ +00048ce0: 6f75 7467 6f69 6e67 5f73 6f63 6b65 742e  outgoing_socket.
    │ │ │ +00048cf0: 6765 745f 6c6f 6361 6c5f 656e 6470 6f69  get_local_endpoi
    │ │ │ +00048d00: 6e74 2829 0a09 0909 092c 2072 6573 702e  nt()....., resp.
    │ │ │ +00048d10: 6578 7465 726e 616c 5f69 700a 0909 0909  external_ip.....
    │ │ │ +00048d20: 2c20 6175 783a 3a73 6573 7369 6f6e 5f69  , aux::session_i
    │ │ │ +00048d30: 6e74 6572 6661 6365 3a3a 736f 7572 6365  nterface::source
    │ │ │ +00048d40: 5f74 7261 636b 6572 2c20 7472 6163 6b65  _tracker, tracke
    │ │ │ +00048d50: 725f 6970 293b 0a0a 0909 7469 6d65 5f70  r_ip);....time_p
    │ │ │ +00048d60: 6f69 6e74 3332 2063 6f6e 7374 206e 6f77  oint32 const now
    │ │ │ +00048d70: 203d 2061 7578 3a3a 7469 6d65 5f6e 6f77   = aux::time_now
    │ │ │ +00048d80: 3332 2829 3b0a 0a09 0970 726f 746f 636f  32();....protoco
    │ │ │ +00048d90: 6c5f 7665 7273 696f 6e20 636f 6e73 7420  l_version const 
    │ │ │ +00048da0: 7620 3d20 722e 696e 666f 5f68 6173 6820  v = r.info_hash 
    │ │ │ +00048db0: 3d3d 2074 6f72 7265 6e74 5f66 696c 6528  == torrent_file(
    │ │ │ +00048dc0: 292e 696e 666f 5f68 6173 6865 7328 292e  ).info_hashes().
    │ │ │ +00048dd0: 7631 0a09 0909 3f20 7072 6f74 6f63 6f6c  v1....? protocol
    │ │ │ +00048de0: 5f76 6572 7369 6f6e 3a3a 5631 203a 2070  _version::V1 : p
    │ │ │ +00048df0: 726f 746f 636f 6c5f 7665 7273 696f 6e3a  rotocol_version:
    │ │ │ +00048e00: 3a56 323b 0a0a 3c64 6976 2073 7479 6c65  :V2;..
    ..aux::annou │ │ │ +00048e40: 6e63 655f 656e 7472 792a 2061 6520 3d20 nce_entry* ae = │ │ │ +00048e50: 6d5f 7472 6163 6b65 7273 2e66 696e 645f m_trackers.find_ │ │ │ +00048e60: 7472 6163 6b65 7228 722e 7572 6c29 3b0a tracker(r.url);. │ │ │ +00048e70: 3c2f 6469 763e 0a09 0974 6370 3a3a 656e
    ...tcp::en │ │ │ +00048e80: 6470 6f69 6e74 206c 6f63 616c 5f65 6e64 dpoint local_end │ │ │ +00048e90: 706f 696e 743b 0a09 0969 6620 2861 6529 point;...if (ae) │ │ │ +00048ea0: 0a09 097b 0a09 0909 6175 746f 2a20 6165 ...{....auto* ae │ │ │ +00048eb0: 7020 3d20 6165 2d26 6774 3b66 696e 645f p = ae->find_ │ │ │ +00048ec0: 656e 6470 6f69 6e74 2872 2e6f 7574 676f endpoint(r.outgo │ │ │ +00048ed0: 696e 675f 736f 636b 6574 293b 0a09 0909 ing_socket);.... │ │ │ +00048ee0: 6966 2028 6165 7029 0a09 0909 7b0a 0909 if (aep)....{... │ │ │ +00048ef0: 0909 6175 746f 2661 6d70 3b20 6120 3d20 ..auto& a = │ │ │ +00048f00: 6165 702d 2667 743b 696e 666f 5f68 6173 aep->info_has │ │ │ +00048f10: 6865 735b 765d 3b0a 0a09 0909 096c 6f63 hes[v];......loc │ │ │ +00048f20: 616c 5f65 6e64 706f 696e 7420 3d20 6165 al_endpoint = ae │ │ │ +00048f30: 702d 2667 743b 6c6f 6361 6c5f 656e 6470 p->local_endp │ │ │ +00048f40: 6f69 6e74 3b0a 0909 0909 6966 2028 7265 oint;.....if (re │ │ │ +00048f50: 7370 2e69 6e63 6f6d 706c 6574 6520 2667 sp.incomplete &g │ │ │ +00048f60: 743b 3d20 3029 2061 2e73 6372 6170 655f t;= 0) a.scrape_ │ │ │ +00048f70: 696e 636f 6d70 6c65 7465 203d 2072 6573 incomplete = res │ │ │ +00048f80: 702e 696e 636f 6d70 6c65 7465 3b0a 0909 p.incomplete;... │ │ │ +00048f90: 0909 6966 2028 7265 7370 2e63 6f6d 706c ..if (resp.compl │ │ │ +00048fa0: 6574 6520 2667 743b 3d20 3029 2061 2e73 ete >= 0) a.s │ │ │ +00048fb0: 6372 6170 655f 636f 6d70 6c65 7465 203d crape_complete = │ │ │ +00048fc0: 2072 6573 702e 636f 6d70 6c65 7465 3b0a resp.complete;. │ │ │ +00048fd0: 0909 0909 6966 2028 7265 7370 2e64 6f77 ....if (resp.dow │ │ │ +00048fe0: 6e6c 6f61 6465 6420 2667 743b 3d20 3029 nloaded >= 0) │ │ │ +00048ff0: 2061 2e73 6372 6170 655f 646f 776e 6c6f a.scrape_downlo │ │ │ +00049000: 6164 6564 203d 2072 6573 702e 646f 776e aded = resp.down │ │ │ +00049010: 6c6f 6164 6564 3b0a 0909 0909 6966 2028 loaded;.....if ( │ │ │ +00049020: 2161 2e73 7461 7274 5f73 656e 7420 2661 !a.start_sent &a │ │ │ +00049030: 6d70 3b26 616d 703b 2072 2e65 7665 6e74 mp;& r.event │ │ │ +00049040: 203d 3d20 6576 656e 745f 743a 3a73 7461 == event_t::sta │ │ │ +00049050: 7274 6564 290a 0909 0909 0961 2e73 7461 rted)......a.sta │ │ │ +00049060: 7274 5f73 656e 7420 3d20 7472 7565 3b0a rt_sent = true;. │ │ │ +00049070: 0909 0909 6966 2028 2161 2e63 6f6d 706c ....if (!a.compl │ │ │ +00049080: 6574 655f 7365 6e74 2026 616d 703b 2661 ete_sent &&a │ │ │ +00049090: 6d70 3b20 722e 6576 656e 7420 3d3d 2065 mp; r.event == e │ │ │ +000490a0: 7665 6e74 5f74 3a3a 636f 6d70 6c65 7465 vent_t::complete │ │ │ +000490b0: 6429 0a09 0909 097b 0a09 0909 0909 612e d).....{......a. │ │ │ +000490c0: 636f 6d70 6c65 7465 5f73 656e 7420 3d20 complete_sent = │ │ │ +000490d0: 7472 7565 3b0a 0909 0909 092f 2f20 7765 true;......// we │ │ │ +000490e0: 2073 7563 6365 7373 6675 6c6c 7920 7265 successfully re │ │ │ +000490f0: 706f 7274 6564 2065 7665 6e74 3d63 6f6d ported event=com │ │ │ +00049100: 706c 6574 6564 2074 6f20 6f6e 6520 7472 pleted to one tr │ │ │ +00049110: 6163 6b65 722e 2044 6f6e 2774 0a09 0909 acker. Don't.... │ │ │ +00049120: 0909 2f2f 2073 656e 6420 6974 2074 6f20 ..// send it to │ │ │ +00049130: 616e 7920 6f74 6865 7220 6f6e 6573 2066 any other ones f │ │ │ +00049140: 726f 6d20 6e6f 7720 6f6e 2028 7468 6572 rom now on (ther │ │ │ +00049150: 6520 6d61 7920 6265 206f 7468 6572 0a09 e may be other.. │ │ │ +00049160: 0909 0909 2f2f 2061 6e6e 6f75 6e63 6573 ....// announces │ │ │ +00049170: 206f 7574 7374 616e 6469 6e67 2072 6967 outstanding rig │ │ │ +00049180: 6874 206e 6f77 2074 686f 7567 6829 0a09 ht now though).. │ │ │ +00049190: 0909 0909 6d5f 636f 6d70 6c65 7465 5f73 ....m_complete_s │ │ │ +000491a0: 656e 7420 3d20 7472 7565 3b0a 0909 0909 ent = true;..... │ │ │ +000491b0: 7d0a 0909 0909 6165 2d26 6774 3b76 6572 }.....ae->ver │ │ │ +000491c0: 6966 6965 6420 3d20 7472 7565 3b0a 0909 ified = true;... │ │ │ +000491d0: 0909 612e 6e65 7874 5f61 6e6e 6f75 6e63 ..a.next_announc │ │ │ +000491e0: 6520 3d20 6e6f 7720 2b20 7265 7370 2e69 e = now + resp.i │ │ │ +000491f0: 6e74 6572 7661 6c3b 0a09 0909 0961 2e6d nterval;.....a.m │ │ │ +00049200: 696e 5f61 6e6e 6f75 6e63 6520 3d20 6e6f in_announce = no │ │ │ +00049210: 7720 2b20 7265 7370 2e6d 696e 5f69 6e74 w + resp.min_int │ │ │ +00049220: 6572 7661 6c3b 0a09 0909 0961 2e75 7064 erval;.....a.upd │ │ │ +00049230: 6174 696e 6720 3d20 6661 6c73 653b 0a09 ating = false;.. │ │ │ +00049240: 0909 0961 2e66 6169 6c73 203d 2030 3b0a ...a.fails = 0;. │ │ │ +00049250: 0909 0909 612e 6c61 7374 5f65 7272 6f72 ....a.last_error │ │ │ +00049260: 2e63 6c65 6172 2829 3b0a 0909 0909 612e .clear();.....a. │ │ │ +00049270: 6d65 7373 6167 6520 3d20 2172 6573 702e message = !resp. │ │ │ +00049280: 7761 726e 696e 675f 6d65 7373 6167 652e warning_message. │ │ │ +00049290: 656d 7074 7928 2920 3f20 7265 7370 2e77 empty() ? resp.w │ │ │ +000492a0: 6172 6e69 6e67 5f6d 6573 7361 6765 203a arning_message : │ │ │ +000492b0: 2073 7464 3a3a 7374 7269 6e67 2829 3b0a std::string();. │ │ │ +000492c0: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +000492d0: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00049300: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +00049330: 632f 746f 7272 656e 742e 6370 703a 3339 c/torrent.cpp:39 │ │ │ +00049340: 3138 3c2f 613e 3c2f 7464 3e3c 7464 3e74 18t │ │ │ +00049350: 6865 2064 6573 7469 6e61 7469 6f6e 2073 he destination s │ │ │ +00049360: 7472 696e 6720 7368 6f75 6c64 2062 6520 tring should be │ │ │ +00049370: 6261 7365 3634 2064 6563 6f64 6564 2061 base64 decoded a │ │ │ +00049380: 6e64 2073 6861 3235 3620 6861 7368 6564 nd sha256 hashed │ │ │ +00049390: 2074 6f20 666f 726d 2074 6865 2064 6573 to form the des │ │ │ +000493a0: 7469 6e61 7469 6f6e 2061 6464 7265 7373 tination address │ │ │ +000493b0: 2061 6e64 2073 746f 7265 2074 6861 7420 and store that │ │ │ +000493c0: 696e 2074 6865 2069 3270 5f70 6565 7220 in the i2p_peer │ │ │ +000493d0: 6f62 6a65 6374 2064 6972 6563 746c 793c object directly< │ │ │ +000493e0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    the │ │ │ +00049430: 2064 6573 7469 6e61 7469 6f6e 2073 7472 destination str │ │ │ +00049440: 696e 6720 7368 6f75 6c64 2062 6520 6261 ing should be ba │ │ │ +00049450: 7365 3634 2064 6563 6f64 6564 2061 6e64 se64 decoded and │ │ │ +00049460: 0a73 6861 3235 3620 6861 7368 6564 2074 .sha256 hashed t │ │ │ +00049470: 6f20 666f 726d 2074 6865 2064 6573 7469 o form the desti │ │ │ +00049480: 6e61 7469 6f6e 2061 6464 7265 7373 2061 nation address a │ │ │ +00049490: 6e64 2073 746f 7265 0a74 6861 7420 696e nd store.that in │ │ │ +000494a0: 2074 6865 2069 3270 5f70 6565 7220 6f62 the i2p_peer ob │ │ │ +000494b0: 6a65 6374 2064 6972 6563 746c 793c 2f68 ject directly

    ../src/tor │ │ │ +000494d0: 7265 6e74 2e63 7070 3a33 3931 383c 2f68 rent.cpp:3918
    ..fo
    │ │ │ +00049520: 7220 2861 7574 6f20 636f 6e73 7426 616d  r (auto const&am
    │ │ │ +00049530: 703b 2069 203a 2072 6573 702e 7065 6572  p; i : resp.peer
    │ │ │ +00049540: 7329 0a09 097b 0a09 0909 2f2f 2064 6f6e  s)...{....// don
    │ │ │ +00049550: 2774 206d 616b 6520 636f 6e6e 6563 7469  't make connecti
    │ │ │ +00049560: 6f6e 7320 746f 206f 7572 7365 6c66 0a09  ons to ourself..
    │ │ │ +00049570: 0909 6966 2028 692e 7069 6420 3d3d 206d  ..if (i.pid == m
    │ │ │ +00049580: 5f70 6565 725f 6964 290a 0909 0909 636f  _peer_id).....co
    │ │ │ +00049590: 6e74 696e 7565 3b0a 0a23 6966 2054 4f52  ntinue;..#if TOR
    │ │ │ +000495a0: 5245 4e54 5f55 5345 5f49 3250 0a09 0909  RENT_USE_I2P....
    │ │ │ +000495b0: 6966 2028 722e 6932 7063 6f6e 6e29 0a09  if (r.i2pconn)..
    │ │ │ +000495c0: 0909 7b0a 0909 0909 2f2f 2074 6869 7320  ..{.....// this 
    │ │ │ +000495d0: 6973 2061 6e20 6932 7020 6e61 6d65 2c20  is an i2p name, 
    │ │ │ +000495e0: 7765 206e 6565 6420 746f 2075 7365 2074  we need to use t
    │ │ │ +000495f0: 6865 2053 414d 2063 6f6e 6e65 6374 696f  he SAM connectio
    │ │ │ +00049600: 6e0a 0909 0909 2f2f 2074 6f20 646f 2074  n.....// to do t
    │ │ │ +00049610: 6865 206e 616d 6520 6c6f 6f6b 7570 0a09  he name lookup..
    │ │ │ +00049620: 0909 0969 6620 2873 7472 696e 675f 656e  ...if (string_en
    │ │ │ +00049630: 6473 5f77 6974 6828 692e 686f 7374 6e61  ds_with(i.hostna
    │ │ │ +00049640: 6d65 2c20 222e 6932 7022 2929 0a09 0909  me, ".i2p"))....
    │ │ │ +00049650: 097b 0a09 0909 0909 4144 445f 4f55 5453  .{......ADD_OUTS
    │ │ │ +00049660: 5441 4e44 494e 475f 4153 594e 4328 2274  TANDING_ASYNC("t
    │ │ │ +00049670: 6f72 7265 6e74 3a3a 6f6e 5f69 3270 5f72  orrent::on_i2p_r
    │ │ │ +00049680: 6573 6f6c 7665 2229 3b0a 0909 0909 0972  esolve");......r
    │ │ │ +00049690: 2e69 3270 636f 6e6e 2d26 6774 3b61 7379  .i2pconn->asy
    │ │ │ +000496a0: 6e63 5f6e 616d 655f 6c6f 6f6b 7570 2869  nc_name_lookup(i
    │ │ │ +000496b0: 2e68 6f73 746e 616d 652e 635f 7374 7228  .hostname.c_str(
    │ │ │ +000496c0: 290a 0909 0909 0909 2c20 5b73 656c 6620  )......., [self 
    │ │ │ +000496d0: 3d20 7368 6172 6564 5f66 726f 6d5f 7468  = shared_from_th
    │ │ │ +000496e0: 6973 2829 5d20 2865 7272 6f72 5f63 6f64  is()] (error_cod
    │ │ │ +000496f0: 6520 636f 6e73 7426 616d 703b 2065 632c  e const& ec,
    │ │ │ +00049700: 2063 6861 7220 636f 6e73 742a 2064 6573   char const* des
    │ │ │ +00049710: 7429 0a09 0909 0909 097b 2073 656c 662d  t).......{ self-
    │ │ │ +00049720: 2667 743b 746f 7272 656e 743a 3a6f 6e5f  >torrent::on_
    │ │ │ +00049730: 6932 705f 7265 736f 6c76 6528 6563 2c20  i2p_resolve(ec, 
    │ │ │ +00049740: 6465 7374 2c20 7065 6572 5f69 6e66 6f3a  dest, peer_info:
    │ │ │ +00049750: 3a74 7261 636b 6572 293b 207d 293b 0a09  :tracker); });..
    │ │ │ +00049760: 0909 097d 0a09 0909 0965 6c73 650a 0909  ...}.....else...
    │ │ │ +00049770: 0909 7b0a 3c64 6976 2073 7479 6c65 3d22  ..{.
    .....torrent_s │ │ │ +000497b0: 7461 7465 2073 7420 3d20 6765 745f 7065 tate st = get_pe │ │ │ +000497c0: 6572 5f6c 6973 745f 7374 6174 6528 293b er_list_state(); │ │ │ +000497d0: 0a3c 2f64 6976 3e09 0909 0909 6e65 6564 .
    .....need │ │ │ +000497e0: 5f70 6565 725f 6c69 7374 2829 3b0a 0909 _peer_list();... │ │ │ +000497f0: 0909 0969 6620 286d 5f70 6565 725f 6c69 ...if (m_peer_li │ │ │ +00049800: 7374 2d26 6774 3b61 6464 5f69 3270 5f70 st->add_i2p_p │ │ │ +00049810: 6565 7228 692e 686f 7374 6e61 6d65 2c20 eer(i.hostname, │ │ │ +00049820: 7065 6572 5f69 6e66 6f3a 3a74 7261 636b peer_info::track │ │ │ +00049830: 6572 2c20 7b7d 2c20 2661 6d70 3b73 7429 er, {}, &st) │ │ │ +00049840: 290a 0909 0909 0909 7374 6174 655f 7570 ).......state_up │ │ │ +00049850: 6461 7465 6428 293b 0a09 0909 0909 7065 dated();......pe │ │ │ +00049860: 6572 735f 6572 6173 6564 2873 742e 6572 ers_erased(st.er │ │ │ +00049870: 6173 6564 293b 0a09 0909 097d 0a09 0909 ased);.....}.... │ │ │ +00049880: 7d0a 0909 0965 6c73 650a 2365 6e64 6966 }....else.#endif │ │ │ +00049890: 0a09 0909 7b0a 0909 0909 2f2f 2074 6865 ....{.....// the │ │ │ +000498a0: 7265 2773 206e 6f20 6d65 6368 616e 6973 re's no mechanis │ │ │ +000498b0: 6d20 746f 2063 6f6e 6e65 6374 2074 6f20 m to connect to │ │ │ +000498c0: 6120 7065 6572 2062 7920 686f 7374 6e61 a peer by hostna │ │ │ +000498d0: 6d65 2074 6872 6f75 6768 0a09 0909 092f me through...../ │ │ │ +000498e0: 2f20 6120 7072 6f78 792c 2073 6f20 7769 / a proxy, so wi │ │ │ +000498f0: 7468 2070 726f 7879 5f68 6f73 746e 616d th proxy_hostnam │ │ │ +00049900: 6573 2073 6574 2c20 6472 6f70 2068 6f73 es set, drop hos │ │ │ +00049910: 746e 616d 6564 2070 6565 7273 0a09 0909 tnamed peers.... │ │ │ +00049920: 092f 2f20 696e 7374 6561 6420 6f66 206c .// instead of l │ │ │ +00049930: 6561 6b69 6e67 2074 6865 6d20 746f 2074 eaking them to t │ │ │ +00049940: 6865 2072 6567 756c 6172 2072 6573 6f6c he regular resol │ │ │ +00049950: 7665 722e 2061 206c 6974 6572 616c 2049 ver. a literal I │ │ │ +00049960: 500a 0909 0909 2f2f 2061 6464 7265 7373 P.....// address │ │ │ +00049970: 2069 6e20 692e 686f 7374 6e61 6d65 2069 in i.hostname i │ │ │ +00049980: 736e 2774 2061 206c 6561 6b2c 2073 696e sn't a leak, sin │ │ │ +00049990: 6365 206e 6f20 7265 616c 2072 6573 6f6c ce no real resol │ │ │ +000499a0: 7574 696f 6e0a 0909 0909 2f2f 2068 6170 ution.....// hap │ │ │ +000499b0: 7065 6e73 2e20 7468 6973 206f 6e6c 7920 pens. this only │ │ │ +000499c0: 6d61 7474 6572 7320 7768 656e 2070 6565 matters when pee │ │ │ +000499d0: 7220 636f 6e6e 6563 7469 6f6e 7320 6172 r connections ar │ │ │ +000499e0: 6520 6163 7475 616c 6c79 0a09 0909 092f e actually...../ │ │ │ +000499f0: 2f20 7072 6f78 6965 642c 2073 6f20 7769 / proxied, so wi │ │ │ +00049a00: 7468 206e 6f20 7072 6f78 7920 636f 6e66 th no proxy conf │ │ │ +00049a10: 6967 7572 6564 2028 6f72 206f 6e65 2074 igured (or one t │ │ │ +00049a20: 6861 7420 646f 6573 6e27 740a 0909 0909 hat doesn't..... │ │ │ +00049a30: 2f2f 2070 726f 7879 2070 6565 7220 636f // proxy peer co │ │ │ +00049a40: 6e6e 6563 7469 6f6e 7329 2072 6573 6f6c nnections) resol │ │ │ +00049a50: 7665 206e 6f72 6d61 6c6c 790a 0909 0909 ve normally..... │ │ │ +00049a60: 6175 783a 3a70 726f 7879 5f73 6574 7469 aux::proxy_setti │ │ │ +00049a70: 6e67 7320 636f 6e73 7426 616d 703b 2070 ngs const& p │ │ │ +00049a80: 7320 3d20 6d5f 7365 732e 7072 6f78 7928 s = m_ses.proxy( │ │ │ +00049a90: 293b 0a09 0909 0969 6620 2821 7365 7474 );.....if (!sett │ │ │ +00049aa0: 696e 6773 2829 2e67 6574 5f62 6f6f 6c28 ings().get_bool( │ │ │ +00049ab0: 7365 7474 696e 6773 5f70 6163 6b3a 3a70 settings_pack::p │ │ │ +00049ac0: 726f 7879 5f68 6f73 746e 616d 6573 290a roxy_hostnames). │ │ │ +00049ad0: 0909 0909 097c 7c20 6175 783a 3a69 735f .....|| aux::is_ │ │ │ +00049ae0: 6970 5f61 6464 7265 7373 2869 2e68 6f73 ip_address(i.hos │ │ │ +00049af0: 746e 616d 6529 207c 7c20 7073 2e74 7970 tname) || ps.typ │ │ │ +00049b00: 6520 3d3d 2073 6574 7469 6e67 735f 7061 e == settings_pa │ │ │ +00049b10: 636b 3a3a 6e6f 6e65 0a09 0909 0909 7c7c ck::none......|| │ │ │ +00049b20: 2021 7073 2e70 726f 7879 5f70 6565 725f !ps.proxy_peer_ │ │ │ +00049b30: 636f 6e6e 6563 7469 6f6e 7329 0a09 0909 connections).... │ │ │ +00049b40: 097b 0a09 0909 0909 4144 445f 4f55 5453 .{......ADD_OUTS │ │ │ +00049b50: 5441 4e44 494e 475f 4153 594e 4328 2274 TANDING_ASYNC("t │ │ │ +00049b60: 6f72 7265 6e74 3a3a 6f6e 5f70 6565 725f orrent::on_peer_ │ │ │ +00049b70: 6e61 6d65 5f6c 6f6f 6b75 7022 293b 0a09 name_lookup");.. │ │ │ +00049b80: 0909 0909 6d5f 7365 732e 6765 745f 7265 ....m_ses.get_re │ │ │ +00049b90: 736f 6c76 6572 2829 2e61 7379 6e63 5f72 solver().async_r │ │ │ +00049ba0: 6573 6f6c 7665 2869 2e68 6f73 746e 616d esolve(i.hostnam │ │ │ +00049bb0: 652c 0a09 0909 0909 0961 7578 3a3a 7265 e,.......aux::re │ │ │ +00049bc0: 736f 6c76 6572 5f69 6e74 6572 6661 6365 solver_interface │ │ │ +00049bd0: 3a3a 6162 6f72 745f 6f6e 5f73 6875 7464 ::abort_on_shutd │ │ │ +00049be0: 6f77 6e2c 0a09 0909 0909 0973 7464 3a3a own,.......std:: │ │ │ +00049bf0: 6269 6e64 280a 0909 0909 0909 0926 616d bind(........&am │ │ │ +00049c00: 703b 746f 7272 656e 743a 3a6f 6e5f 7065 p;torrent::on_pe │ │ │ +00049c10: 6572 5f6e 616d 655f 6c6f 6f6b 7570 2c20 er_name_lookup, │ │ │ +00049c20: 7368 6172 6564 5f66 726f 6d5f 7468 6973 shared_from_this │ │ │ +00049c30: 2829 2c20 5f31 2c20 5f32 2c20 692e 706f (), _1, _2, i.po │ │ │ +00049c40: 7274 2c20 7629 293b 0a09 0909 097d 0a09 rt, v));.....}.. │ │ │ +00049c50: 0909 7d0a 0909 7d0a 0a3c 2f70 7265 3e3c ..}...}..
    < │ │ │ +00049c60: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00049c90: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +00049ca0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/torre │ │ │ +00049cd0: 6e74 2e63 7070 3a34 3235 373c 2f61 3e3c nt.cpp:4257< │ │ │ +00049ce0: 2f74 643e 3c74 643e 7374 6f72 6520 6932 /td>store i2 │ │ │ +00049cf0: 7020 6164 6472 6573 7365 7320 6173 2061 p addresses as a │ │ │ +00049d00: 2033 3220 6279 7465 2073 6861 3235 3620 32 byte sha256 │ │ │ +00049d10: 6861 7368 2069 6e20 7468 6520 6932 705f hash in the i2p_ │ │ │ +00049d20: 7065 6572 206f 626a 6563 742c 2072 6174 peer object, rat │ │ │ +00049d30: 6865 7220 7468 616e 2072 6573 6f6c 7669 her than resolvi │ │ │ +00049d40: 6e67 2069 7420 696e 746f 2074 6865 2066 ng it into the f │ │ │ +00049d50: 756c 6c20 7661 7365 3634 2064 6573 7469 ull vase64 desti │ │ │ +00049d60: 6e61 7469 6f6e 2e20 5765 2073 686f 756c nation. We shoul │ │ │ +00049d70: 6420 6b65 6570 2074 6865 2066 756c 6c20 d keep the full │ │ │ +00049d80: 6465 7374 696e 6174 696f 6e20 6173 2061 destination as a │ │ │ +00049d90: 2063 6163 6865 2069 6e20 7468 6520 6932 cache in the i2 │ │ │ +00049da0: 705f 7065 6572 206f 626a 6563 7420 7374 p_peer object st │ │ │ +00049db0: 696c 6c2e 3c2f 7464 3e3c 2f74 723e 3c74 ill.store i2p addr │ │ │ +00049e10: 6573 7365 7320 6173 2061 2033 3220 6279 esses as a 32 by │ │ │ +00049e20: 7465 2073 6861 3235 3620 6861 7368 2069 te sha256 hash i │ │ │ +00049e30: 6e20 7468 650a 6932 705f 7065 6572 206f n the.i2p_peer o │ │ │ +00049e40: 626a 6563 742c 2072 6174 6865 7220 7468 bject, rather th │ │ │ +00049e50: 616e 2072 6573 6f6c 7669 6e67 2069 7420 an resolving it │ │ │ +00049e60: 696e 746f 2074 6865 2066 756c 6c20 7661 into the full va │ │ │ +00049e70: 7365 3634 0a64 6573 7469 6e61 7469 6f6e se64.destination │ │ │ +00049e80: 2e20 5765 2073 686f 756c 6420 6b65 6570 . We should keep │ │ │ +00049e90: 2074 6865 2066 756c 6c20 6465 7374 696e the full destin │ │ │ +00049ea0: 6174 696f 6e20 6173 2061 2063 6163 6865 ation as a cache │ │ │ +00049eb0: 2069 6e20 7468 650a 6932 705f 7065 6572 in the.i2p_peer │ │ │ +00049ec0: 206f 626a 6563 7420 7374 696c 6c2e 3c2f object still.

    ../src/to │ │ │ +00049ee0: 7272 656e 742e 6370 703a 3432 3537 3c2f rrent.cpp:4257
    #if
    │ │ │ +00049f30: 6e64 6566 2054 4f52 5245 4e54 5f44 4953  ndef TORRENT_DIS
    │ │ │ +00049f40: 4142 4c45 5f4c 4f47 4749 4e47 0a09 0965  ABLE_LOGGING...e
    │ │ │ +00049f50: 6c73 650a 0909 7b0a 0909 0964 6562 7567  lse...{....debug
    │ │ │ +00049f60: 5f6c 6f67 2822 2a2a 2a20 666f 756e 6420  _log("*** found 
    │ │ │ +00049f70: 6e6f 2074 7261 636b 6572 2065 6e64 706f  no tracker endpo
    │ │ │ +00049f80: 696e 7473 2074 6f20 616e 6e6f 756e 6365  ints to announce
    │ │ │ +00049f90: 2229 3b0a 0909 7d0a 2365 6e64 6966 0a09  ");...}.#endif..
    │ │ │ +00049fa0: 7d0a 0a23 6966 2054 4f52 5245 4e54 5f41  }..#if TORRENT_A
    │ │ │ +00049fb0: 4249 5f56 4552 5349 4f4e 203d 3d20 310a  BI_VERSION == 1.
    │ │ │ +00049fc0: 0976 6f69 6420 746f 7272 656e 743a 3a73  .void torrent::s
    │ │ │ +00049fd0: 6574 5f74 7261 636b 6572 5f6c 6f67 696e  et_tracker_login
    │ │ │ +00049fe0: 2873 7464 3a3a 7374 7269 6e67 2063 6f6e  (std::string con
    │ │ │ +00049ff0: 7374 2661 6d70 3b20 6e61 6d65 0a09 092c  st& name...,
    │ │ │ +0004a000: 2073 7464 3a3a 7374 7269 6e67 2063 6f6e   std::string con
    │ │ │ +0004a010: 7374 2661 6d70 3b20 7077 290a 097b 0a09  st& pw)..{..
    │ │ │ +0004a020: 096d 5f75 7365 726e 616d 6520 3d20 6e61  .m_username = na
    │ │ │ +0004a030: 6d65 3b0a 0909 6d5f 7061 7373 776f 7264  me;...m_password
    │ │ │ +0004a040: 203d 2070 773b 0a09 7d0a 2365 6e64 6966   = pw;..}.#endif
    │ │ │ +0004a050: 0a0a 2369 6620 544f 5252 454e 545f 5553  ..#if TORRENT_US
    │ │ │ +0004a060: 455f 4932 500a 0976 6f69 6420 746f 7272  E_I2P..void torr
    │ │ │ +0004a070: 656e 743a 3a61 6464 5f69 3270 5f70 6565  ent::add_i2p_pee
    │ │ │ +0004a080: 7228 7368 6132 3536 5f68 6173 6820 636f  r(sha256_hash co
    │ │ │ +0004a090: 6e73 7426 616d 703b 2064 6573 742c 2070  nst& dest, p
    │ │ │ +0004a0a0: 6565 725f 736f 7572 6365 5f66 6c61 6773  eer_source_flags
    │ │ │ +0004a0b0: 5f74 2063 6f6e 7374 2073 6f75 7263 6529  _t const source)
    │ │ │ +0004a0c0: 0a09 7b0a 3c64 6976 2073 7479 6c65 3d22  ..{.
    ..i2p_connecti │ │ │ +0004a100: 6f6e 2661 6d70 3b20 6932 7063 6f6e 6e20 on& i2pconn │ │ │ +0004a110: 3d20 7365 7373 696f 6e28 292e 6932 705f = session().i2p_ │ │ │ +0004a120: 636f 6e6e 2829 3b0a 3c2f 6469 763e 0909 conn();.
    .. │ │ │ +0004a130: 6966 2028 2169 3270 636f 6e6e 2e69 735f if (!i2pconn.is_ │ │ │ +0004a140: 6f70 656e 2829 2920 7265 7475 726e 3b0a open()) return;. │ │ │ +0004a150: 0a09 0973 7464 3a3a 7374 7269 6e67 2064 ...std::string d │ │ │ +0004a160: 6573 7469 6e61 7469 6f6e 203d 2062 6173 estination = bas │ │ │ +0004a170: 6533 3265 6e63 6f64 655f 6932 7028 6465 e32encode_i2p(de │ │ │ +0004a180: 7374 293b 0a09 0964 6573 7469 6e61 7469 st);...destinati │ │ │ +0004a190: 6f6e 202b 3d20 222e 6233 322e 6932 7022 on += ".b32.i2p" │ │ │ +0004a1a0: 3b0a 0a09 0941 4444 5f4f 5554 5354 414e ;....ADD_OUTSTAN │ │ │ +0004a1b0: 4449 4e47 5f41 5359 4e43 2822 746f 7272 DING_ASYNC("torr │ │ │ +0004a1c0: 656e 743a 3a6f 6e5f 6932 705f 7265 736f ent::on_i2p_reso │ │ │ +0004a1d0: 6c76 6522 293b 0a09 0969 3270 636f 6e6e lve");...i2pconn │ │ │ +0004a1e0: 2e61 7379 6e63 5f6e 616d 655f 6c6f 6f6b .async_name_look │ │ │ +0004a1f0: 7570 2864 6573 7469 6e61 7469 6f6e 2e63 up(destination.c │ │ │ +0004a200: 5f73 7472 2829 0a09 0909 2c20 5b73 656c _str()...., [sel │ │ │ +0004a210: 6620 3d20 7368 6172 6564 5f66 726f 6d5f f = shared_from_ │ │ │ +0004a220: 7468 6973 2829 2c20 736f 7572 6365 5d20 this(), source] │ │ │ +0004a230: 2865 7272 6f72 5f63 6f64 6520 636f 6e73 (error_code cons │ │ │ +0004a240: 7426 616d 703b 2065 632c 2063 6861 7220 t& ec, char │ │ │ +0004a250: 636f 6e73 742a 2064 290a 0909 097b 2073 const* d)....{ s │ │ │ +0004a260: 656c 662d 2667 743b 746f 7272 656e 743a elf->torrent: │ │ │ +0004a270: 3a6f 6e5f 6932 705f 7265 736f 6c76 6528 :on_i2p_resolve( │ │ │ +0004a280: 6563 2c20 642c 2073 6f75 7263 6529 3b20 ec, d, source); │ │ │ +0004a290: 7d29 3b0a 097d 0a0a 0976 6f69 6420 746f });..}...void to │ │ │ +0004a2a0: 7272 656e 743a 3a6f 6e5f 6932 705f 7265 rrent::on_i2p_re │ │ │ +0004a2b0: 736f 6c76 6528 6572 726f 725f 636f 6465 solve(error_code │ │ │ +0004a2c0: 2063 6f6e 7374 2661 6d70 3b20 6563 2c20 const& ec, │ │ │ +0004a2d0: 6368 6172 2063 6f6e 7374 2a20 6465 7374 char const* dest │ │ │ +0004a2e0: 2c20 7065 6572 5f73 6f75 7263 655f 666c , peer_source_fl │ │ │ +0004a2f0: 6167 735f 7420 636f 6e73 7420 736f 7572 ags_t const sour │ │ │ +0004a300: 6365 2920 7472 790a 097b 0a09 0954 4f52 ce) try..{...TOR │ │ │ +0004a310: 5245 4e54 5f41 5353 4552 5428 6973 5f73 RENT_ASSERT(is_s │ │ │ +0004a320: 696e 676c 655f 7468 7265 6164 2829 293b ingle_thread()); │ │ │ +0004a330: 0a0a 0909 494e 5641 5249 414e 545f 4348 ....INVARIANT_CH │ │ │ +0004a340: 4543 4b3b 0a0a 0909 434f 4d50 4c45 5445 ECK;....COMPLETE │ │ │ +0004a350: 5f41 5359 4e43 2822 746f 7272 656e 743a _ASYNC("torrent: │ │ │ +0004a360: 3a6f 6e5f 6932 705f 7265 736f 6c76 6522 :on_i2p_resolve" │ │ │ +0004a370: 293b 0a23 6966 6e64 6566 2054 4f52 5245 );.#ifndef TORRE │ │ │ +0004a380: 4e54 5f44 4953 4142 4c45 5f4c 4f47 4749 NT_DISABLE_LOGGI │ │ │ +0004a390: 4e47 0a09 0969 6620 2865 6320 2661 6d70 NG...if (ec & │ │ │ +0004a3a0: 3b26 616d 703b 2073 686f 756c 645f 6c6f ;& should_lo │ │ │ +0004a3b0: 6728 2929 0a09 0909 6465 6275 675f 6c6f g())....debug_lo │ │ │ +0004a3c0: 6728 2269 3270 5f72 6573 6f6c 7665 2065 g("i2p_resolve e │ │ │ +0004a3d0: 7272 6f72 3a20 2573 222c 2065 632e 6d65 rror: %s", ec.me │ │ │ +0004a3e0: 7373 6167 6528 292e 635f 7374 7228 2929 ssage().c_str()) │ │ │ +0004a3f0: 3b0a 2365 6e64 6966 0a09 0969 6620 2865 ;.#endif...if (e │ │ │ +0004a400: 6320 7c7c 206d 5f61 626f 7274 207c 7c20 c || m_abort || │ │ │ +0004a410: 6d5f 7365 732e 6973 5f61 626f 7274 6564 m_ses.is_aborted │ │ │ +0004a420: 2829 2920 7265 7475 726e 3b0a 0a09 096e ()) return;....n │ │ │ +0004a430: 6565 645f 7065 6572 5f6c 6973 7428 293b eed_peer_list(); │ │ │ +0004a440: 0a09 0974 6f72 7265 6e74 5f73 7461 7465 ...torrent_state │ │ │ +0004a450: 2073 7420 3d20 6765 745f 7065 6572 5f6c st = get_peer_l │ │ │ +0004a460: 6973 745f 7374 6174 6528 293b 0a09 0969 ist_state();...i │ │ │ +0004a470: 6620 286d 5f70 6565 725f 6c69 7374 2d26 f (m_peer_list-& │ │ │ +0004a480: 6774 3b61 6464 5f69 3270 5f70 6565 7228 gt;add_i2p_peer( │ │ │ +0004a490: 6465 7374 2c20 736f 7572 6365 2c20 7b7d dest, source, {} │ │ │ +0004a4a0: 2c20 2661 6d70 3b73 7429 290a 0909 0973 , &st))....s │ │ │ +0004a4b0: 7461 7465 5f75 7064 6174 6564 2829 3b0a tate_updated();. │ │ │ +0004a4c0: 0909 7065 6572 735f 6572 6173 6564 2873 ..peers_erased(s │ │ │ +0004a4d0: 742e 6572 6173 6564 293b 0a0a 3c2f 7072 t.erased);..rel │ │ │ +0004a510: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/to │ │ │ +0004a550: 7272 656e 742e 6370 703a 3433 3134 3c2f rrent.cpp:4314add o │ │ │ +0004a570: 6e65 2070 6565 7220 7065 7220 4950 2074 ne peer per IP t │ │ │ +0004a580: 6865 2068 6f73 746e 616d 6520 7265 736f he hostname reso │ │ │ +0004a590: 6c76 6573 2074 6f3c 2f74 643e 3c2f 7472 lves to

    add one pee │ │ │ +0004a5f0: 7220 7065 7220 4950 2074 6865 2068 6f73 r per IP the hos │ │ │ +0004a600: 746e 616d 6520 7265 736f 6c76 6573 2074 tname resolves t │ │ │ +0004a610: 6f3c 2f68 323e 3c68 343e 2e2e 2f73 7263 o

    ../src │ │ │ +0004a620: 2f74 6f72 7265 6e74 2e63 7070 3a34 3331 /torrent.cpp:431 │ │ │ +0004a630: 343c 2f68 343e 3c70 7265 2073 7479 6c65 4

    │ │ │ +0004a670: 0963 6174 6368 2028 2e2e 2e29 207b 2068  .catch (...) { h
    │ │ │ +0004a680: 616e 646c 655f 6578 6365 7074 696f 6e28  andle_exception(
    │ │ │ +0004a690: 293b 207d 0a23 656e 6469 660a 0a09 766f  ); }.#endif...vo
    │ │ │ +0004a6a0: 6964 2074 6f72 7265 6e74 3a3a 6f6e 5f70  id torrent::on_p
    │ │ │ +0004a6b0: 6565 725f 6e61 6d65 5f6c 6f6f 6b75 7028  eer_name_lookup(
    │ │ │ +0004a6c0: 6572 726f 725f 636f 6465 2063 6f6e 7374  error_code const
    │ │ │ +0004a6d0: 2661 6d70 3b20 650a 0909 2c20 7374 643a  & e..., std:
    │ │ │ +0004a6e0: 3a76 6563 746f 7226 6c74 3b61 6464 7265  :vector<addre
    │ │ │ +0004a6f0: 7373 2667 743b 2063 6f6e 7374 2661 6d70  ss> const&
    │ │ │ +0004a700: 3b20 686f 7374 5f6c 6973 742c 2069 6e74  ; host_list, int
    │ │ │ +0004a710: 2063 6f6e 7374 2070 6f72 740a 0909 2c20   const port..., 
    │ │ │ +0004a720: 7072 6f74 6f63 6f6c 5f76 6572 7369 6f6e  protocol_version
    │ │ │ +0004a730: 2063 6f6e 7374 2076 2920 7472 790a 097b   const v) try..{
    │ │ │ +0004a740: 0a09 0954 4f52 5245 4e54 5f41 5353 4552  ...TORRENT_ASSER
    │ │ │ +0004a750: 5428 6973 5f73 696e 676c 655f 7468 7265  T(is_single_thre
    │ │ │ +0004a760: 6164 2829 293b 0a0a 0909 494e 5641 5249  ad());....INVARI
    │ │ │ +0004a770: 414e 545f 4348 4543 4b3b 0a0a 0909 434f  ANT_CHECK;....CO
    │ │ │ +0004a780: 4d50 4c45 5445 5f41 5359 4e43 2822 746f  MPLETE_ASYNC("to
    │ │ │ +0004a790: 7272 656e 743a 3a6f 6e5f 7065 6572 5f6e  rrent::on_peer_n
    │ │ │ +0004a7a0: 616d 655f 6c6f 6f6b 7570 2229 3b0a 0a23  ame_lookup");..#
    │ │ │ +0004a7b0: 6966 6e64 6566 2054 4f52 5245 4e54 5f44  ifndef TORRENT_D
    │ │ │ +0004a7c0: 4953 4142 4c45 5f4c 4f47 4749 4e47 0a09  ISABLE_LOGGING..
    │ │ │ +0004a7d0: 0969 6620 2865 2026 616d 703b 2661 6d70  .if (e &&
    │ │ │ +0004a7e0: 3b20 7368 6f75 6c64 5f6c 6f67 2829 290a  ; should_log()).
    │ │ │ +0004a7f0: 0909 0964 6562 7567 5f6c 6f67 2822 7065  ...debug_log("pe
    │ │ │ +0004a800: 6572 206e 616d 6520 6c6f 6f6b 7570 2065  er name lookup e
    │ │ │ +0004a810: 7272 6f72 3a20 2573 222c 2065 2e6d 6573  rror: %s", e.mes
    │ │ │ +0004a820: 7361 6765 2829 2e63 5f73 7472 2829 293b  sage().c_str());
    │ │ │ +0004a830: 0a23 656e 6469 660a 0a09 0969 6620 2865  .#endif....if (e
    │ │ │ +0004a840: 207c 7c20 6d5f 6162 6f72 7420 7c7c 2068   || m_abort || h
    │ │ │ +0004a850: 6f73 745f 6c69 7374 2e65 6d70 7479 2829  ost_list.empty()
    │ │ │ +0004a860: 207c 7c20 6d5f 7365 732e 6973 5f61 626f   || m_ses.is_abo
    │ │ │ +0004a870: 7274 6564 2829 2920 7265 7475 726e 3b0a  rted()) return;.
    │ │ │ +0004a880: 0a3c 6469 7620 7374 796c 653d 2262 6163  .
    . │ │ │ +0004a8b0: 0974 6370 3a3a 656e 6470 6f69 6e74 2068 .tcp::endpoint h │ │ │ +0004a8c0: 6f73 7428 686f 7374 5f6c 6973 742e 6672 ost(host_list.fr │ │ │ +0004a8d0: 6f6e 7428 292c 2073 7464 3a3a 7569 6e74 ont(), std::uint │ │ │ +0004a8e0: 3136 5f74 2870 6f72 7429 293b 0a3c 2f64 16_t(port));....if (m_ip_f │ │ │ +0004a900: 696c 7465 7220 2661 6d70 3b26 616d 703b ilter && │ │ │ +0004a910: 206d 5f69 705f 6669 6c74 6572 2d26 6774 m_ip_filter-> │ │ │ +0004a920: 3b61 6363 6573 7328 686f 7374 2e61 6464 ;access(host.add │ │ │ +0004a930: 7265 7373 2829 2920 2661 6d70 3b20 6970 ress()) & ip │ │ │ +0004a940: 5f66 696c 7465 723a 3a62 6c6f 636b 6564 _filter::blocked │ │ │ +0004a950: 290a 0909 7b0a 2369 666e 6465 6620 544f )...{.#ifndef TO │ │ │ +0004a960: 5252 454e 545f 4449 5341 424c 455f 4c4f RRENT_DISABLE_LO │ │ │ +0004a970: 4747 494e 470a 0909 0969 6620 2873 686f GGING....if (sho │ │ │ +0004a980: 756c 645f 6c6f 6728 2929 0a09 0909 7b0a uld_log())....{. │ │ │ +0004a990: 0909 0909 6465 6275 675f 6c6f 6728 2262 ....debug_log("b │ │ │ +0004a9a0: 6c6f 636b 6564 2069 7020 6672 6f6d 2074 locked ip from t │ │ │ +0004a9b0: 7261 636b 6572 3a20 2573 222c 2068 6f73 racker: %s", hos │ │ │ +0004a9c0: 742e 6164 6472 6573 7328 292e 746f 5f73 t.address().to_s │ │ │ +0004a9d0: 7472 696e 6728 292e 635f 7374 7228 2929 tring().c_str()) │ │ │ +0004a9e0: 3b0a 0909 097d 0a23 656e 6469 660a 0909 ;....}.#endif... │ │ │ +0004a9f0: 0969 6620 286d 5f73 6573 2e61 6c65 7274 .if (m_ses.alert │ │ │ +0004aa00: 7328 292e 7368 6f75 6c64 5f70 6f73 7426 s().should_post& │ │ │ +0004aa10: 6c74 3b70 6565 725f 626c 6f63 6b65 645f lt;peer_blocked_ │ │ │ +0004aa20: 616c 6572 7426 6774 3b28 2929 0a09 0909 alert>()).... │ │ │ +0004aa30: 096d 5f73 6573 2e61 6c65 7274 7328 292e .m_ses.alerts(). │ │ │ +0004aa40: 656d 706c 6163 655f 616c 6572 7426 6c74 emplace_alert< │ │ │ +0004aa50: 3b70 6565 725f 626c 6f63 6b65 645f 616c ;peer_blocked_al │ │ │ +0004aa60: 6572 7426 6774 3b28 6765 745f 6861 6e64 ert>(get_hand │ │ │ +0004aa70: 6c65 2829 0a09 0909 0909 2c20 686f 7374 le()......, host │ │ │ +0004aa80: 2c20 7065 6572 5f62 6c6f 636b 6564 5f61 , peer_blocked_a │ │ │ +0004aa90: 6c65 7274 3a3a 6970 5f66 696c 7465 7229 lert::ip_filter) │ │ │ +0004aaa0: 3b0a 0909 0972 6574 7572 6e3b 0a09 097d ;....return;...} │ │ │ +0004aab0: 0a0a 0909 6966 2028 6164 645f 7065 6572 ....if (add_peer │ │ │ +0004aac0: 2868 6f73 742c 2070 6565 725f 696e 666f (host, peer_info │ │ │ +0004aad0: 3a3a 7472 6163 6b65 722c 2076 203d 3d20 ::tracker, v == │ │ │ +0004aae0: 7072 6f74 6f63 6f6c 5f76 6572 7369 6f6e protocol_version │ │ │ +0004aaf0: 3a3a 5632 203f 2070 6578 5f6c 745f 7632 ::V2 ? pex_lt_v2 │ │ │ +0004ab00: 203a 2070 6578 5f66 6c61 6773 5f74 2830 : pex_flags_t(0 │ │ │ +0004ab10: 2929 290a 0909 7b0a 0909 0973 7461 7465 )))...{....state │ │ │ +0004ab20: 5f75 7064 6174 6564 2829 3b0a 0a23 6966 _updated();..#if │ │ │ +0004ab30: 6e64 6566 2054 4f52 5245 4e54 5f44 4953 ndef TORRENT_DIS │ │ │ +0004ab40: 4142 4c45 5f4c 4f47 4749 4e47 0a09 0909 ABLE_LOGGING.... │ │ │ +0004ab50: 6966 2028 7368 6f75 6c64 5f6c 6f67 2829 if (should_log() │ │ │ +0004ab60: 290a 0909 097b 0a09 0909 0964 6562 7567 )....{.....debug │ │ │ +0004ab70: 5f6c 6f67 2822 6e61 6d65 2d6c 6f6f 6b75 _log("name-looku │ │ │ +0004ab80: 7020 6164 645f 7065 6572 2829 205b 2025 p add_peer() [ % │ │ │ +0004ab90: 7320 5d20 636f 6e6e 6563 742d 6361 6e64 s ] connect-cand │ │ │ +0004aba0: 6964 6174 6573 3a20 2564 220a 0909 0909 idates: %d"..... │ │ │ +0004abb0: 092c 2068 6f73 742e 6164 6472 6573 7328 ., host.address( │ │ │ +0004abc0: 292e 746f 5f73 7472 696e 6728 292e 635f ).to_string().c_ │ │ │ +0004abd0: 7374 7228 290a 0909 0909 092c 206d 5f70 str()......, m_p │ │ │ +0004abe0: 6565 725f 6c69 7374 203f 206d 5f70 6565 eer_list ? m_pee │ │ │ +0004abf0: 725f 6c69 7374 2d26 6774 3b6e 756d 5f63 r_list->num_c │ │ │ +0004ac00: 6f6e 6e65 6374 5f63 616e 6469 6461 7465 onnect_candidate │ │ │ +0004ac10: 7328 2920 3a20 2d31 293b 0a09 0909 7d0a s() : -1);....}. │ │ │ +0004ac20: 2365 6e64 6966 0a09 097d 0a09 0975 7064 #endif...}...upd │ │ │ +0004ac30: 6174 655f 7761 6e74 5f70 6565 7273 2829 ate_want_peers() │ │ │ +0004ac40: 3b0a 097d 0a3c 2f70 7265 3e3c 2f74 643e ;..}.
    │ │ │ +0004ac50: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +0004ac80: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +0004ac90: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +0004aca0: 7074 3a65 7870 616e 6428 3137 3929 223e pt:expand(179)"> │ │ │ +0004acb0: 2e2e 2f73 7263 2f74 6f72 7265 6e74 2e63 ../src/torrent.c │ │ │ +0004acc0: 7070 3a35 3035 313c 2f61 3e3c 2f74 643e pp:5051
    │ │ │ +0004acd0: 3c74 643e 6f6e 6c79 2064 6f20 7468 6973 only do this │ │ │ +0004ace0: 2069 6620 7468 6520 7069 6563 6520 7369 if the piece si │ │ │ +0004acf0: 7a65 203e 2031 2062 6c6f 636b 7320 5468 ze > 1 blocks Th │ │ │ +0004ad00: 6973 2069 7320 6120 7632 2074 6f72 7265 is is a v2 torre │ │ │ +0004ad10: 6e74 2073 6f20 7765 2063 616e 2072 6571 nt so we can req │ │ │ +0004ad20: 7565 7374 2067 6574 2062 6c6f 636b 206c uest get block l │ │ │ +0004ad30: 6576 656c 2068 6173 6865 732e 3c2f 7464 evel hashes.

    only d │ │ │ +0004ad90: 6f20 7468 6973 2069 6620 7468 6520 7069 o this if the pi │ │ │ +0004ada0: 6563 6520 7369 7a65 203e 2031 2062 6c6f ece size > 1 blo │ │ │ +0004adb0: 636b 730a 5468 6973 2069 7320 6120 7632 cks.This is a v2 │ │ │ +0004adc0: 2074 6f72 7265 6e74 2073 6f20 7765 2063 torrent so we c │ │ │ +0004add0: 616e 2072 6571 7565 7374 2067 6574 2062 an request get b │ │ │ +0004ade0: 6c6f 636b 0a6c 6576 656c 2068 6173 6865 lock.level hashe │ │ │ +0004adf0: 732e 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 s.

    ../sr │ │ │ +0004ae00: 632f 746f 7272 656e 742e 6370 703a 3530 c/torrent.cpp:50 │ │ │ +0004ae10: 3531 3c2f 6834 3e3c 7072 6520 7374 796c 51

    ...if (!blocks.
    │ │ │ +0004ae60: 656d 7074 7928 2929 0a09 0909 7b0a 0909  empty())....{...
    │ │ │ +0004ae70: 0909 666f 7220 2861 7574 6f20 636f 6e73  ..for (auto cons
    │ │ │ +0004ae80: 7420 6220 3a20 626c 6f63 6b73 2920 7265  t b : blocks) re
    │ │ │ +0004ae90: 742e 696e 7365 7274 2864 6f77 6e6c 6f61  t.insert(downloa
    │ │ │ +0004aea0: 6465 7273 5b73 7464 3a3a 7369 7a65 5f74  ders[std::size_t
    │ │ │ +0004aeb0: 2862 295d 293b 0a09 0909 7d0a 0909 0965  (b)]);....}....e
    │ │ │ +0004aec0: 6c73 650a 0909 097b 0a09 0909 0973 7464  lse....{.....std
    │ │ │ +0004aed0: 3a3a 636f 7079 2864 6f77 6e6c 6f61 6465  ::copy(downloade
    │ │ │ +0004aee0: 7273 2e62 6567 696e 2829 2c0a 0909 0909  rs.begin(),.....
    │ │ │ +0004aef0: 0964 6f77 6e6c 6f61 6465 7273 2e62 6567  .downloaders.beg
    │ │ │ +0004af00: 696e 2829 202b 2070 6179 6c6f 6164 5f62  in() + payload_b
    │ │ │ +0004af10: 6c6f 636b 732c 0a09 0909 0909 7374 643a  locks,......std:
    │ │ │ +0004af20: 3a69 6e73 6572 7465 7228 7265 742c 2072  :inserter(ret, r
    │ │ │ +0004af30: 6574 2e62 6567 696e 2829 2929 3b0a 0909  et.begin()));...
    │ │ │ +0004af40: 097d 0a09 0909 7265 7475 726e 2072 6574  .}....return ret
    │ │ │ +0004af50: 3b0a 0909 7d28 293b 0a0a 0909 2f2f 2069  ;...}();....// i
    │ │ │ +0004af60: 6620 7468 6973 2070 6965 6365 2077 6173  f this piece was
    │ │ │ +0004af70: 6e27 7420 646f 776e 6c6f 6164 6564 2066  n't downloaded f
    │ │ │ +0004af80: 726f 6d20 7065 6572 732c 2077 6520 6a75  rom peers, we ju
    │ │ │ +0004af90: 7374 2066 6f75 6e64 2069 7420 6f6e 2064  st found it on d
    │ │ │ +0004afa0: 6973 6b2e 0a09 092f 2f20 496e 2074 6861  isk....// In tha
    │ │ │ +0004afb0: 7420 6361 7365 2c20 7765 2073 686f 756c  t case, we shoul
    │ │ │ +0004afc0: 6420 6a75 7374 2063 6f6e 7369 6465 7220  d just consider 
    │ │ │ +0004afd0: 6974 2061 7320 226e 6f74 2d68 6176 6522  it as "not-have"
    │ │ │ +0004afe0: 2061 6e64 2074 6865 7265 2773 206e 6f0a   and there's no.
    │ │ │ +0004aff0: 0909 2f2f 206e 6565 6420 746f 2074 7279  ..// need to try
    │ │ │ +0004b000: 2074 6f20 6765 7420 6869 6768 6572 2066   to get higher f
    │ │ │ +0004b010: 6964 656c 6974 7920 6861 7368 6573 2028  idelity hashes (
    │ │ │ +0004b020: 7965 7429 0a09 0962 6f6f 6c20 636f 6e73  yet)...bool cons
    │ │ │ +0004b030: 7420 666f 756e 645f 6f6e 5f64 6973 6b20  t found_on_disk 
    │ │ │ +0004b040: 3d20 7065 6572 732e 7369 7a65 2829 203d  = peers.size() =
    │ │ │ +0004b050: 3d20 3120 2661 6d70 3b26 616d 703b 2070  = 1 && p
    │ │ │ +0004b060: 6565 7273 2e63 6f75 6e74 286e 756c 6c70  eers.count(nullp
    │ │ │ +0004b070: 7472 293b 0a0a 0909 6966 2028 746f 7272  tr);....if (torr
    │ │ │ +0004b080: 656e 745f 6669 6c65 2829 2e69 6e66 6f5f  ent_file().info_
    │ │ │ +0004b090: 6861 7368 6573 2829 2e68 6173 5f76 3228  hashes().has_v2(
    │ │ │ +0004b0a0: 2920 2661 6d70 3b26 616d 703b 2062 6c6f  ) && blo
    │ │ │ +0004b0b0: 636b 732e 656d 7074 7928 2920 2661 6d70  cks.empty() &
    │ │ │ +0004b0c0: 3b26 616d 703b 2021 666f 756e 645f 6f6e  ;& !found_on
    │ │ │ +0004b0d0: 5f64 6973 6b29 0a09 097b 0a3c 6469 7620  _disk)...{.
    ...veri │ │ │ +0004b110: 6679 5f62 6c6f 636b 5f68 6173 6865 7328 fy_block_hashes( │ │ │ +0004b120: 696e 6465 7829 3b0a 3c2f 6469 763e 0909 index);.
    .. │ │ │ +0004b130: 7d0a 0a09 092f 2f20 7468 6520 6265 6c6f }....// the belo │ │ │ +0004b140: 7720 636f 6465 2069 7320 7065 6e61 6c69 w code is penali │ │ │ +0004b150: 7a69 6e67 2070 6565 7273 2074 6861 7420 zing peers that │ │ │ +0004b160: 7365 6e74 2075 7365 2062 6164 2064 6174 sent use bad dat │ │ │ +0004b170: 612e 0a09 092f 2f20 696e 6372 6561 7365 a....// increase │ │ │ +0004b180: 2074 6865 2074 6f74 616c 2061 6d6f 756e the total amoun │ │ │ +0004b190: 7420 6f66 2066 6169 6c65 6420 6279 7465 t of failed byte │ │ │ +0004b1a0: 730a 0909 6966 2028 2166 6f75 6e64 5f6f s...if (!found_o │ │ │ +0004b1b0: 6e5f 6469 736b 290a 0909 7b0a 0909 0969 n_disk)...{....i │ │ │ +0004b1c0: 6620 2862 6c6f 636b 732e 656d 7074 7928 f (blocks.empty( │ │ │ +0004b1d0: 2929 0a09 0909 0961 6464 5f66 6169 6c65 )).....add_faile │ │ │ +0004b1e0: 645f 6279 7465 7328 6d5f 746f 7272 656e d_bytes(m_torren │ │ │ +0004b1f0: 745f 6669 6c65 2d26 6774 3b70 6965 6365 t_file->piece │ │ │ +0004b200: 5f73 697a 6528 696e 6465 7829 293b 0a09 _size(index));.. │ │ │ +0004b210: 0909 656c 7365 0a09 0909 0961 6464 5f66 ..else.....add_f │ │ │ +0004b220: 6169 6c65 645f 6279 7465 7328 7374 6174 ailed_bytes(stat │ │ │ +0004b230: 6963 5f63 6173 7426 6c74 3b69 6e74 2667 ic_cast<int&g │ │ │ +0004b240: 743b 2862 6c6f 636b 732e 7369 7a65 2829 t;(blocks.size() │ │ │ +0004b250: 2920 2a20 6465 6661 756c 745f 626c 6f63 ) * default_bloc │ │ │ +0004b260: 6b5f 7369 7a65 293b 0a0a 2369 666e 6465 k_size);..#ifnde │ │ │ +0004b270: 6620 544f 5252 454e 545f 4449 5341 424c f TORRENT_DISABL │ │ │ +0004b280: 455f 4558 5445 4e53 494f 4e53 0a09 0909 E_EXTENSIONS.... │ │ │ +0004b290: 666f 7220 2861 7574 6f26 616d 703b 2065 for (auto& e │ │ │ +0004b2a0: 7874 203a 206d 5f65 7874 656e 7369 6f6e xt : m_extension │ │ │ +0004b2b0: 7329 0a09 0909 7b0a 0909 0909 6578 742d s)....{.....ext- │ │ │ +0004b2c0: 2667 743b 6f6e 5f70 6965 6365 5f66 6169 >on_piece_fai │ │ │ +0004b2d0: 6c65 6428 696e 6465 7829 3b0a 0909 097d led(index);....} │ │ │ +0004b2e0: 0a23 656e 6469 660a 0a09 0909 2f2f 2064 .#endif.....// d │ │ │ +0004b2f0: 6964 2077 6520 7265 6365 6976 6520 7468 id we receive th │ │ │ +0004b300: 6973 2070 6965 6365 2066 726f 6d20 6120 is piece from a │ │ │ +0004b310: 7369 6e67 6c65 2070 6565 723f 0a09 0909 single peer?.... │ │ │ +0004b320: 2f2f 2069 6620 7765 206b 6e6f 7720 6578 // if we know ex │ │ │ +0004b330: 6163 746c 7920 7768 6963 6820 626c 6f63 actly which bloc │ │ │ +0004b340: 6b73 2066 6169 6c65 6420 7468 6520 6861 ks failed the ha │ │ │ +0004b350: 7368 2c20 7765 2063 616e 2061 6c73 6f20 sh, we can also │ │ │ +0004b360: 6265 2063 6572 7461 696e 0a09 0909 2f2f be certain....// │ │ │ +0004b370: 2074 6861 7420 616c 6c20 7065 6572 7320 that all peers │ │ │ +0004b380: 696e 2074 6865 206c 6973 7420 7365 6e74 in the list sent │ │ │ +0004b390: 2075 7320 6261 6420 6461 7461 0a09 0909 us bad data.... │ │ │ +0004b3a0: 626f 6f6c 2063 6f6e 7374 206b 6e6f 776e bool const known │ │ │ +0004b3b0: 5f62 6164 5f70 6565 7220 3d20 7065 6572 _bad_peer = peer │ │ │ +0004b3c0: 732e 7369 7a65 2829 203d 3d20 3120 7c7c s.size() == 1 || │ │ │ +0004b3d0: 2021 626c 6f63 6b73 2e65 6d70 7479 2829 !blocks.empty() │ │ │ +0004b3e0: 3b0a 0a09 0909 7065 6e61 6c69 7a65 5f70 ;.....penalize_p │ │ │ +0004b3f0: 6565 7273 2870 6565 7273 2c20 696e 6465 eers(peers, inde │ │ │ +0004b400: 782c 206b 6e6f 776e 5f62 6164 5f70 6565 x, known_bad_pee │ │ │ +0004b410: 7229 3b0a 0909 7d0a 0a09 092f 2f20 4966 r);...}....// If │ │ │ +0004b420: 206d 5f73 746f 7261 6765 2069 736e 2774 m_storage isn't │ │ │ +0004b430: 2073 6574 2068 6572 652c 2069 7420 6d65 set here, it me │ │ │ +0004b440: 616e 7320 7765 2772 6520 7368 7574 7469 ans we're shutti │ │ │ +0004b450: 6e67 2064 6f77 6e0a 0909 6966 2028 6d5f ng down...if (m_ │ │ │ +0004b460: 7374 6f72 6167 6529 0a09 097b 0a09 0909 storage)...{.... │ │ │ +0004b470: 2f2f 2069 7420 646f 6573 6e27 7420 6d61 // it doesn't ma │ │ │ +0004b480: 6b65 206d 7563 6820 7365 6e73 6520 746f ke much sense to │ │ │ +0004b490: 2066 6169 6c20 746f 2068 6173 6820 6120 fail to hash a │ │ │ +0004b4a0: 7069 6563 650a 3c2f 7072 653e 3c2f 7464 piece.
    relevance │ │ │ +0004b4e0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +0004b4f0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/torrent. │ │ │ +0004b520: 6370 703a 3830 3638 3c2f 613e 3c2f 7464 cpp:8068come up wit │ │ │ +0004b540: 6820 6120 6265 7474 6572 2077 6179 206f h a better way o │ │ │ +0004b550: 6620 646f 696e 6720 7468 6973 2c20 696e f doing this, in │ │ │ +0004b560: 7374 6561 6420 6f66 2061 6e20 696d 6d65 stead of an imme │ │ │ +0004b570: 6469 6174 656c 7920 696e 766f 6b65 6420 diately invoked │ │ │ +0004b580: 6c61 6d62 6461 2065 7870 7265 7373 696f lambda expressio │ │ │ +0004b590: 6e2e 3c2f 7464 3e3c 2f74 723e 3c74 7220 n.

    │ │ │ +0004b5e0: 636f 6d65 2075 7020 7769 7468 2061 2062 come up with a b │ │ │ +0004b5f0: 6574 7465 7220 7761 7920 6f66 2064 6f69 etter way of doi │ │ │ +0004b600: 6e67 2074 6869 732c 2069 6e73 7465 6164 ng this, instead │ │ │ +0004b610: 206f 6620 616e 0a69 6d6d 6564 6961 7465 of an.immediate │ │ │ +0004b620: 6c79 2069 6e76 6f6b 6564 206c 616d 6264 ly invoked lambd │ │ │ +0004b630: 6120 6578 7072 6573 7369 6f6e 2e3c 2f68 a expression.

    ../src/tor │ │ │ +0004b650: 7265 6e74 2e63 7070 3a38 3036 383c 2f68 rent.cpp:8068
    ....
    │ │ │ +0004b6a0: 097c 7c20 7065 6572 696e 666f 2d26 6774  .|| peerinfo->
    │ │ │ +0004b6b0: 3b63 6f6e 6669 726d 6564 5f73 7570 706f  ;confirmed_suppo
    │ │ │ +0004b6c0: 7274 735f 7574 7029 290a 0909 097b 0a09  rts_utp))....{..
    │ │ │ +0004b6d0: 0909 0973 6d20 3d20 6d5f 7365 732e 7574  ...sm = m_ses.ut
    │ │ │ +0004b6e0: 705f 736f 636b 6574 5f6d 616e 6167 6572  p_socket_manager
    │ │ │ +0004b6f0: 2829 3b0a 0909 097d 0a0a 0909 092f 2f20  ();....}.....// 
    │ │ │ +0004b700: 646f 6e27 7420 6d61 6b65 2061 2054 4350  don't make a TCP
    │ │ │ +0004b710: 2063 6f6e 6e65 6374 696f 6e20 6966 2069   connection if i
    │ │ │ +0004b720: 7427 7320 6469 7361 626c 6564 0a09 0909  t's disabled....
    │ │ │ +0004b730: 6966 2028 736d 203d 3d20 6e75 6c6c 7074  if (sm == nullpt
    │ │ │ +0004b740: 7220 2661 6d70 3b26 616d 703b 2021 7365  r && !se
    │ │ │ +0004b750: 7474 696e 6773 2829 2e67 6574 5f62 6f6f  ttings().get_boo
    │ │ │ +0004b760: 6c28 7365 7474 696e 6773 5f70 6163 6b3a  l(settings_pack:
    │ │ │ +0004b770: 3a65 6e61 626c 655f 6f75 7467 6f69 6e67  :enable_outgoing
    │ │ │ +0004b780: 5f74 6370 2929 0a09 0909 7b0a 2369 666e  _tcp))....{.#ifn
    │ │ │ +0004b790: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ +0004b7a0: 424c 455f 4c4f 4747 494e 470a 0909 0909  BLE_LOGGING.....
    │ │ │ +0004b7b0: 6966 2028 7368 6f75 6c64 5f6c 6f67 2829  if (should_log()
    │ │ │ +0004b7c0: 290a 0909 0909 7b0a 0909 0909 0964 6562  ).....{......deb
    │ │ │ +0004b7d0: 7567 5f6c 6f67 2822 6469 7363 6172 6469  ug_log("discardi
    │ │ │ +0004b7e0: 6e67 2070 6565 7220 5c22 2573 5c22 3a20  ng peer \"%s\": 
    │ │ │ +0004b7f0: 5443 5020 636f 6e6e 6563 7469 6f6e 7320  TCP connections 
    │ │ │ +0004b800: 6469 7361 626c 6564 2022 0a09 0909 0909  disabled "......
    │ │ │ +0004b810: 0922 5b20 7375 7070 6f72 7473 2d75 7470  ."[ supports-utp
    │ │ │ +0004b820: 3a20 2564 205d 222c 2070 6565 7269 6e66  : %d ]", peerinf
    │ │ │ +0004b830: 6f2d 2667 743b 746f 5f73 7472 696e 6728  o->to_string(
    │ │ │ +0004b840: 292e 635f 7374 7228 290a 0909 0909 0909  ).c_str().......
    │ │ │ +0004b850: 2c20 7065 6572 696e 666f 2d26 6774 3b73  , peerinfo->s
    │ │ │ +0004b860: 7570 706f 7274 735f 7574 7029 3b0a 0909  upports_utp);...
    │ │ │ +0004b870: 0909 7d0a 2365 6e64 6966 0a09 0909 0972  ..}.#endif.....r
    │ │ │ +0004b880: 6574 7572 6e20 6661 6c73 653b 0a09 0909  eturn false;....
    │ │ │ +0004b890: 7d0a 0909 7d0a 0a3c 6469 7620 7374 796c  }...}..
    ..aux::sock │ │ │ +0004b8d0: 6574 5f74 7970 6520 7320 3d20 5b26 616d et_type s = [&am │ │ │ +0004b8e0: 703b 5d20 7b0a 3c2f 6469 763e 0a23 6966 p;] {.
    .#if │ │ │ +0004b8f0: 2054 4f52 5245 4e54 5f55 5345 5f49 3250 TORRENT_USE_I2P │ │ │ +0004b900: 0a09 0969 6620 2870 6565 7269 6e66 6f2d ...if (peerinfo- │ │ │ +0004b910: 2667 743b 6973 5f69 3270 5f61 6464 7229 >is_i2p_addr) │ │ │ +0004b920: 0a09 097b 0a09 0909 2f2f 2049 7427 7320 ...{....// It's │ │ │ +0004b930: 6e6f 7420 656e 7469 7265 6c79 206f 6276 not entirely obv │ │ │ +0004b940: 696f 7573 2077 6879 2074 6869 7320 7065 ious why this pe │ │ │ +0004b950: 6572 2063 6f6e 6e65 6374 696f 6e20 6973 er connection is │ │ │ +0004b960: 206e 6f74 206d 6172 6b65 6420 6173 0a09 not marked as.. │ │ │ +0004b970: 0909 2f2f 206f 6e65 2e20 5468 6520 6d61 ..// one. The ma │ │ │ +0004b980: 696e 2066 6561 7475 7265 206f 6620 6120 in feature of a │ │ │ +0004b990: 7065 6572 2063 6f6e 6e65 6374 696f 6e20 peer connection │ │ │ +0004b9a0: 6973 2074 6861 7420 7768 6574 6865 7220 is that whether │ │ │ +0004b9b0: 6f72 206e 6f74 2077 650a 0909 092f 2f20 or not we....// │ │ │ +0004b9c0: 7072 6f78 7920 6974 2069 7320 636f 6e66 proxy it is conf │ │ │ +0004b9d0: 6967 7572 6162 6c65 2e20 5768 656e 2077 igurable. When w │ │ │ +0004b9e0: 6520 7573 6520 6932 702c 2077 6520 7761 e use i2p, we wa │ │ │ +0004b9f0: 6e74 2074 6f20 616c 7761 7973 2070 726f nt to always pro │ │ │ +0004ba00: 780a 0909 092f 2f20 6576 6572 7974 6869 x....// everythi │ │ │ +0004ba10: 6e67 2076 6961 2069 3270 2e0a 0a09 0909 ng via i2p...... │ │ │ +0004ba20: 6175 783a 3a70 726f 7879 5f73 6574 7469 aux::proxy_setti │ │ │ +0004ba30: 6e67 7320 7072 6f78 793b 0a09 0909 7072 ngs proxy;....pr │ │ │ +0004ba40: 6f78 792e 686f 7374 6e61 6d65 203d 2073 oxy.hostname = s │ │ │ +0004ba50: 6574 7469 6e67 7328 292e 6765 745f 7374 ettings().get_st │ │ │ +0004ba60: 7228 7365 7474 696e 6773 5f70 6163 6b3a r(settings_pack: │ │ │ +0004ba70: 3a69 3270 5f68 6f73 746e 616d 6529 3b0a :i2p_hostname);. │ │ │ +0004ba80: 0909 0970 726f 7879 2e70 6f72 7420 3d20 ...proxy.port = │ │ │ +0004ba90: 7374 643a 3a75 696e 7431 365f 7428 7365 std::uint16_t(se │ │ │ +0004baa0: 7474 696e 6773 2829 2e67 6574 5f69 6e74 ttings().get_int │ │ │ +0004bab0: 2873 6574 7469 6e67 735f 7061 636b 3a3a (settings_pack:: │ │ │ +0004bac0: 6932 705f 706f 7274 2929 3b0a 0909 0970 i2p_port));....p │ │ │ +0004bad0: 726f 7879 2e74 7970 6520 3d20 7365 7474 roxy.type = sett │ │ │ +0004bae0: 696e 6773 5f70 6163 6b3a 3a69 3270 5f70 ings_pack::i2p_p │ │ │ +0004baf0: 726f 7879 3b0a 0a09 0909 6175 783a 3a73 roxy;.....aux::s │ │ │ +0004bb00: 6f63 6b65 745f 7479 7065 2072 6574 203d ocket_type ret = │ │ │ +0004bb10: 2069 6e73 7461 6e74 6961 7465 5f63 6f6e instantiate_con │ │ │ +0004bb20: 6e65 6374 696f 6e28 6d5f 7365 732e 6765 nection(m_ses.ge │ │ │ +0004bb30: 745f 636f 6e74 6578 7428 290a 0909 0909 t_context()..... │ │ │ +0004bb40: 2c20 7072 6f78 792c 206e 756c 6c70 7472 , proxy, nullptr │ │ │ +0004bb50: 2c20 6e75 6c6c 7074 722c 2066 616c 7365 , nullptr, false │ │ │ +0004bb60: 2c20 6661 6c73 6529 3b0a 0909 0961 7574 , false);....aut │ │ │ +0004bb70: 6f26 616d 703b 2073 7472 203d 2073 7464 o& str = std │ │ │ +0004bb80: 3a3a 6765 7426 6c74 3b69 3270 5f73 7472 ::get<i2p_str │ │ │ +0004bb90: 6561 6d26 6774 3b28 7265 7429 3b0a 0909 eam>(ret);... │ │ │ +0004bba0: 0973 7472 2e73 6574 5f6c 6f63 616c 5f69 .str.set_local_i │ │ │ +0004bbb0: 3270 5f65 6e64 706f 696e 7428 6d5f 7365 2p_endpoint(m_se │ │ │ +0004bbc0: 732e 6c6f 6361 6c5f 6932 705f 656e 6470 s.local_i2p_endp │ │ │ +0004bbd0: 6f69 6e74 2829 293b 0a09 0909 7374 722e oint());....str. │ │ │ +0004bbe0: 7365 745f 6465 7374 696e 6174 696f 6e28 set_destination( │ │ │ +0004bbf0: 7374 6174 6963 5f63 6173 7426 6c74 3b69 static_cast<i │ │ │ +0004bc00: 3270 5f70 6565 722a 2667 743b 2870 6565 2p_peer*>(pee │ │ │ +0004bc10: 7269 6e66 6f29 2d26 6774 3b64 6573 7428 rinfo)->dest( │ │ │ +0004bc20: 2929 3b0a 0909 0973 7472 2e73 6574 5f63 ));....str.set_c │ │ │ +0004bc30: 6f6d 6d61 6e64 2869 3270 5f73 7472 6561 ommand(i2p_strea │ │ │ +0004bc40: 6d3a 3a63 6d64 5f63 6f6e 6e65 6374 293b m::cmd_connect); │ │ │ +0004bc50: 0a09 0909 7374 722e 7365 745f 7365 7373 ....str.set_sess │ │ │ +0004bc60: 696f 6e5f 6964 286d 5f73 6573 2e69 3270 ion_id(m_ses.i2p │ │ │ +0004bc70: 5f73 6573 7369 6f6e 2829 293b 0a09 0909 _session());.... │ │ │ +0004bc80: 7265 7475 726e 2072 6574 3b0a 0909 7d0a return ret;...}. │ │ │ +0004bc90: 0909 656c 7365 0a23 656e 6469 660a 0909 ..else.#endif... │ │ │ +0004bca0: 7b0a 0909 0976 6f69 642a 2075 7365 7264 {....void* userd │ │ │ +0004bcb0: 6174 6120 3d20 6e75 6c6c 7074 723b 0a23 ata = nullptr;.# │ │ │ +0004bcc0: 6966 6465 6620 544f 5252 454e 545f 5353 ifdef TORRENT_SS │ │ │ +0004bcd0: 4c5f 5045 4552 530a 0909 0969 6620 2869 L_PEERS....if (i │ │ │ +0004bce0: 735f 7373 6c5f 746f 7272 656e 7428 2929 s_ssl_torrent()) │ │ │ +0004bcf0: 0a09 0909 7b0a 3c2f 7072 653e 3c2f 7464 ....{.
    relevance │ │ │ +0004bd30: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +0004bd40: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/torrent. │ │ │ +0004bd70: 6370 703a 3937 3537 3c2f 613e 3c2f 7464 cpp:9757perhaps 0 s │ │ │ +0004bd90: 686f 756c 6420 6163 7475 616c 6c79 206d hould actually m │ │ │ +0004bda0: 6561 6e20 303c 2f74 643e 3c2f 7472 3e3c ean 0< │ │ │ +0004bdb0: 7472 2069 643d 2231 3831 2220 7374 796c tr id="181" styl │ │ │ +0004bdc0: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +0004bdd0: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +0004bde0: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +0004bdf0: 6832 3e70 6572 6861 7073 2030 2073 686f h2>perhaps 0 sho │ │ │ +0004be00: 756c 6420 6163 7475 616c 6c79 206d 6561 uld actually mea │ │ │ +0004be10: 6e20 303c 2f68 323e 3c68 343e 2e2e 2f73 n 0

    ../s │ │ │ +0004be20: 7263 2f74 6f72 7265 6e74 2e63 7070 3a39 rc/torrent.cpp:9 │ │ │ +0004be30: 3735 373c 2f68 343e 3c70 7265 2073 7479 757

    ..// finished 
    │ │ │ +0004be80: 746f 7272 656e 7473 206d 6179 206e 6f74  torrents may not
    │ │ │ +0004be90: 2063 6861 6e67 6520 7468 6569 7220 7175   change their qu
    │ │ │ +0004bea0: 6575 6520 706f 7369 7469 6f6e 732c 2061  eue positions, a
    │ │ │ +0004beb0: 7320 6974 2773 2073 6574 2074 6f0a 0909  s it's set to...
    │ │ │ +0004bec0: 2f2f 202d 310a 0909 6966 2028 286d 5f61  // -1...if ((m_a
    │ │ │ +0004bed0: 626f 7274 207c 7c20 6973 5f66 696e 6973  bort || is_finis
    │ │ │ +0004bee0: 6865 6428 2929 2026 616d 703b 2661 6d70  hed()) &&
    │ │ │ +0004bef0: 3b20 7020 213d 206e 6f5f 706f 7329 2072  ; p != no_pos) r
    │ │ │ +0004bf00: 6574 7572 6e3b 0a0a 0909 544f 5252 454e  eturn;....TORREN
    │ │ │ +0004bf10: 545f 4153 5345 5254 2828 7020 3d3d 206e  T_ASSERT((p == n
    │ │ │ +0004bf20: 6f5f 706f 7329 203d 3d20 6973 5f66 696e  o_pos) == is_fin
    │ │ │ +0004bf30: 6973 6865 6428 290a 0909 097c 7c20 2821  ished()....|| (!
    │ │ │ +0004bf40: 6d5f 6175 746f 5f6d 616e 6167 6564 2026  m_auto_managed &
    │ │ │ +0004bf50: 616d 703b 2661 6d70 3b20 7020 3d3d 206e  amp;& p == n
    │ │ │ +0004bf60: 6f5f 706f 7329 0a09 0909 7c7c 2028 6d5f  o_pos)....|| (m_
    │ │ │ +0004bf70: 6162 6f72 7420 2661 6d70 3b26 616d 703b  abort &&
    │ │ │ +0004bf80: 2070 203d 3d20 6e6f 5f70 6f73 290a 0909   p == no_pos)...
    │ │ │ +0004bf90: 097c 7c20 2821 6d5f 6164 6465 6420 2661  .|| (!m_added &a
    │ │ │ +0004bfa0: 6d70 3b26 616d 703b 2070 203d 3d20 6e6f  mp;& p == no
    │ │ │ +0004bfb0: 5f70 6f73 2929 3b0a 0909 6966 2028 7020  _pos));...if (p 
    │ │ │ +0004bfc0: 3d3d 206d 5f73 6571 7565 6e63 655f 6e75  == m_sequence_nu
    │ │ │ +0004bfd0: 6d62 6572 2920 7265 7475 726e 3b0a 0a09  mber) return;...
    │ │ │ +0004bfe0: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ +0004bff0: 7020 2667 743b 3d20 6e6f 5f70 6f73 293b  p >= no_pos);
    │ │ │ +0004c000: 0a0a 0909 7374 6174 655f 7570 6461 7465  ....state_update
    │ │ │ +0004c010: 6428 293b 0a0a 0909 6d5f 7365 732e 7365  d();....m_ses.se
    │ │ │ +0004c020: 745f 7175 6575 655f 706f 7369 7469 6f6e  t_queue_position
    │ │ │ +0004c030: 2874 6869 732c 2070 293b 0a09 7d0a 0a09  (this, p);..}...
    │ │ │ +0004c040: 766f 6964 2074 6f72 7265 6e74 3a3a 7365  void torrent::se
    │ │ │ +0004c050: 745f 6d61 785f 7570 6c6f 6164 7328 696e  t_max_uploads(in
    │ │ │ +0004c060: 7420 6c69 6d69 742c 2062 6f6f 6c20 636f  t limit, bool co
    │ │ │ +0004c070: 6e73 7420 7374 6174 655f 7570 6461 7465  nst state_update
    │ │ │ +0004c080: 290a 097b 0a09 0954 4f52 5245 4e54 5f41  )..{...TORRENT_A
    │ │ │ +0004c090: 5353 4552 5428 6973 5f73 696e 676c 655f  SSERT(is_single_
    │ │ │ +0004c0a0: 7468 7265 6164 2829 293b 0a3c 6469 7620  thread());.
    ..if (l │ │ │ +0004c0e0: 696d 6974 2026 6c74 3b3d 2030 2920 6c69 imit <= 0) li │ │ │ +0004c0f0: 6d69 7420 3d20 2831 2026 6c74 3b26 6c74 mit = (1 << │ │ │ +0004c100: 3b20 3234 2920 2d20 313b 0a3c 2f64 6976 ; 24) - 1;.
    ..if (int(m_max │ │ │ +0004c120: 5f75 706c 6f61 6473 2920 3d3d 206c 696d _uploads) == lim │ │ │ +0004c130: 6974 2920 7265 7475 726e 3b0a 0909 6966 it) return;...if │ │ │ +0004c140: 2028 7374 6174 655f 7570 6461 7465 2920 (state_update) │ │ │ +0004c150: 7374 6174 655f 7570 6461 7465 6428 293b state_updated(); │ │ │ +0004c160: 0a09 096d 5f6d 6178 5f75 706c 6f61 6473 ...m_max_uploads │ │ │ +0004c170: 203d 2061 7578 3a3a 6e75 6d65 7269 635f = aux::numeric_ │ │ │ +0004c180: 6361 7374 266c 743b 7374 643a 3a75 696e cast<std::uin │ │ │ +0004c190: 7433 325f 7426 6774 3b28 6c69 6d69 7429 t32_t>(limit) │ │ │ +0004c1a0: 3b0a 2369 666e 6465 6620 544f 5252 454e ;.#ifndef TORREN │ │ │ +0004c1b0: 545f 4449 5341 424c 455f 4c4f 4747 494e T_DISABLE_LOGGIN │ │ │ +0004c1c0: 470a 0909 6966 2028 7368 6f75 6c64 5f6c G...if (should_l │ │ │ +0004c1d0: 6f67 2829 2026 616d 703b 2661 6d70 3b20 og() && │ │ │ +0004c1e0: 7374 6174 655f 7570 6461 7465 290a 0909 state_update)... │ │ │ +0004c1f0: 0964 6562 7567 5f6c 6f67 2822 2a2a 2a20 .debug_log("*** │ │ │ +0004c200: 7365 742d 6d61 782d 7570 6c6f 6164 733a set-max-uploads: │ │ │ +0004c210: 2025 6422 2c20 6d5f 6d61 785f 7570 6c6f %d", m_max_uplo │ │ │ +0004c220: 6164 7329 3b0a 2365 6e64 6966 0a0a 0909 ads);.#endif.... │ │ │ +0004c230: 6966 2028 7374 6174 655f 7570 6461 7465 if (state_update │ │ │ +0004c240: 290a 0909 0973 6574 5f6e 6565 645f 7361 )....set_need_sa │ │ │ +0004c250: 7665 5f72 6573 756d 6528 746f 7272 656e ve_resume(torren │ │ │ +0004c260: 745f 6861 6e64 6c65 3a3a 6966 5f63 6f6e t_handle::if_con │ │ │ +0004c270: 6669 675f 6368 616e 6765 6429 3b0a 097d fig_changed);..} │ │ │ +0004c280: 0a0a 0976 6f69 6420 746f 7272 656e 743a ...void torrent: │ │ │ +0004c290: 3a73 6574 5f6d 6178 5f63 6f6e 6e65 6374 :set_max_connect │ │ │ +0004c2a0: 696f 6e73 2869 6e74 206c 696d 6974 2c20 ions(int limit, │ │ │ +0004c2b0: 626f 6f6c 2063 6f6e 7374 2073 7461 7465 bool const state │ │ │ +0004c2c0: 5f75 7064 6174 6529 0a09 7b0a 0909 544f _update)..{...TO │ │ │ +0004c2d0: 5252 454e 545f 4153 5345 5254 2869 735f RRENT_ASSERT(is_ │ │ │ +0004c2e0: 7369 6e67 6c65 5f74 6872 6561 6428 2929 single_thread()) │ │ │ +0004c2f0: 3b0a 3c2f 7072 653e 3c2f 7464 3e3c 2f74 ;.
    < │ │ │ +0004c320: 7464 3e72 656c 6576 616e 6365 266e 6273 td>relevance&nbs │ │ │ +0004c330: 703b 303c 2f74 643e 3c74 643e 3c61 2068 p;0../ │ │ │ +0004c360: 7372 632f 746f 7272 656e 742e 6370 703a src/torrent.cpp: │ │ │ +0004c370: 3937 3734 3c2f 613e 3c2f 7464 3e3c 7464 9774perhaps 0 shoul │ │ │ +0004c390: 6420 6163 7475 616c 6c79 206d 6561 6e20 d actually mean │ │ │ +0004c3a0: 303c 2f74 643e 3c2f 7472 3e3c 7472 2069 0

    p │ │ │ +0004c3f0: 6572 6861 7073 2030 2073 686f 756c 6420 erhaps 0 should │ │ │ +0004c400: 6163 7475 616c 6c79 206d 6561 6e20 303c actually mean 0< │ │ │ +0004c410: 2f68 323e 3c68 343e 2e2e 2f73 7263 2f74 /h2>

    ../src/t │ │ │ +0004c420: 6f72 7265 6e74 2e63 7070 3a39 3737 343c orrent.cpp:9774< │ │ │ +0004c430: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +0004c470: 766f 6964 2074 6f72 7265 6e74 3a3a 7365  void torrent::se
    │ │ │ +0004c480: 745f 6d61 785f 7570 6c6f 6164 7328 696e  t_max_uploads(in
    │ │ │ +0004c490: 7420 6c69 6d69 742c 2062 6f6f 6c20 636f  t limit, bool co
    │ │ │ +0004c4a0: 6e73 7420 7374 6174 655f 7570 6461 7465  nst state_update
    │ │ │ +0004c4b0: 290a 097b 0a09 0954 4f52 5245 4e54 5f41  )..{...TORRENT_A
    │ │ │ +0004c4c0: 5353 4552 5428 6973 5f73 696e 676c 655f  SSERT(is_single_
    │ │ │ +0004c4d0: 7468 7265 6164 2829 293b 0a09 0969 6620  thread());...if 
    │ │ │ +0004c4e0: 286c 696d 6974 2026 6c74 3b3d 2030 2920  (limit <= 0) 
    │ │ │ +0004c4f0: 6c69 6d69 7420 3d20 2831 2026 6c74 3b26  limit = (1 <&
    │ │ │ +0004c500: 6c74 3b20 3234 2920 2d20 313b 0a09 0969  lt; 24) - 1;...i
    │ │ │ +0004c510: 6620 2869 6e74 286d 5f6d 6178 5f75 706c  f (int(m_max_upl
    │ │ │ +0004c520: 6f61 6473 2920 3d3d 206c 696d 6974 2920  oads) == limit) 
    │ │ │ +0004c530: 7265 7475 726e 3b0a 0909 6966 2028 7374  return;...if (st
    │ │ │ +0004c540: 6174 655f 7570 6461 7465 2920 7374 6174  ate_update) stat
    │ │ │ +0004c550: 655f 7570 6461 7465 6428 293b 0a09 096d  e_updated();...m
    │ │ │ +0004c560: 5f6d 6178 5f75 706c 6f61 6473 203d 2061  _max_uploads = a
    │ │ │ +0004c570: 7578 3a3a 6e75 6d65 7269 635f 6361 7374  ux::numeric_cast
    │ │ │ +0004c580: 266c 743b 7374 643a 3a75 696e 7433 325f  <std::uint32_
    │ │ │ +0004c590: 7426 6774 3b28 6c69 6d69 7429 3b0a 2369  t>(limit);.#i
    │ │ │ +0004c5a0: 666e 6465 6620 544f 5252 454e 545f 4449  fndef TORRENT_DI
    │ │ │ +0004c5b0: 5341 424c 455f 4c4f 4747 494e 470a 0909  SABLE_LOGGING...
    │ │ │ +0004c5c0: 6966 2028 7368 6f75 6c64 5f6c 6f67 2829  if (should_log()
    │ │ │ +0004c5d0: 2026 616d 703b 2661 6d70 3b20 7374 6174   && stat
    │ │ │ +0004c5e0: 655f 7570 6461 7465 290a 0909 0964 6562  e_update)....deb
    │ │ │ +0004c5f0: 7567 5f6c 6f67 2822 2a2a 2a20 7365 742d  ug_log("*** set-
    │ │ │ +0004c600: 6d61 782d 7570 6c6f 6164 733a 2025 6422  max-uploads: %d"
    │ │ │ +0004c610: 2c20 6d5f 6d61 785f 7570 6c6f 6164 7329  , m_max_uploads)
    │ │ │ +0004c620: 3b0a 2365 6e64 6966 0a0a 0909 6966 2028  ;.#endif....if (
    │ │ │ +0004c630: 7374 6174 655f 7570 6461 7465 290a 0909  state_update)...
    │ │ │ +0004c640: 0973 6574 5f6e 6565 645f 7361 7665 5f72  .set_need_save_r
    │ │ │ +0004c650: 6573 756d 6528 746f 7272 656e 745f 6861  esume(torrent_ha
    │ │ │ +0004c660: 6e64 6c65 3a3a 6966 5f63 6f6e 6669 675f  ndle::if_config_
    │ │ │ +0004c670: 6368 616e 6765 6429 3b0a 097d 0a0a 0976  changed);..}...v
    │ │ │ +0004c680: 6f69 6420 746f 7272 656e 743a 3a73 6574  oid torrent::set
    │ │ │ +0004c690: 5f6d 6178 5f63 6f6e 6e65 6374 696f 6e73  _max_connections
    │ │ │ +0004c6a0: 2869 6e74 206c 696d 6974 2c20 626f 6f6c  (int limit, bool
    │ │ │ +0004c6b0: 2063 6f6e 7374 2073 7461 7465 5f75 7064   const state_upd
    │ │ │ +0004c6c0: 6174 6529 0a09 7b0a 0909 544f 5252 454e  ate)..{...TORREN
    │ │ │ +0004c6d0: 545f 4153 5345 5254 2869 735f 7369 6e67  T_ASSERT(is_sing
    │ │ │ +0004c6e0: 6c65 5f74 6872 6561 6428 2929 3b0a 3c64  le_thread());...if
    │ │ │ +0004c720: 2028 6c69 6d69 7420 266c 743b 3d20 3029   (limit <= 0)
    │ │ │ +0004c730: 206c 696d 6974 203d 2028 3120 266c 743b   limit = (1 <
    │ │ │ +0004c740: 266c 743b 2032 3429 202d 2031 3b0a 3c2f  < 24) - 1;...if (int(m_
    │ │ │ +0004c760: 6d61 785f 636f 6e6e 6563 7469 6f6e 7329  max_connections)
    │ │ │ +0004c770: 203d 3d20 6c69 6d69 7429 2072 6574 7572   == limit) retur
    │ │ │ +0004c780: 6e3b 0a09 0969 6620 2873 7461 7465 5f75  n;...if (state_u
    │ │ │ +0004c790: 7064 6174 6529 2073 7461 7465 5f75 7064  pdate) state_upd
    │ │ │ +0004c7a0: 6174 6564 2829 3b0a 0909 6d5f 6d61 785f  ated();...m_max_
    │ │ │ +0004c7b0: 636f 6e6e 6563 7469 6f6e 7320 3d20 6175  connections = au
    │ │ │ +0004c7c0: 783a 3a6e 756d 6572 6963 5f63 6173 7426  x::numeric_cast&
    │ │ │ +0004c7d0: 6c74 3b73 7464 3a3a 7569 6e74 3332 5f74  lt;std::uint32_t
    │ │ │ +0004c7e0: 2667 743b 286c 696d 6974 293b 0a09 0975  >(limit);...u
    │ │ │ +0004c7f0: 7064 6174 655f 7761 6e74 5f70 6565 7273  pdate_want_peers
    │ │ │ +0004c800: 2829 3b0a 0a23 6966 6e64 6566 2054 4f52  ();..#ifndef TOR
    │ │ │ +0004c810: 5245 4e54 5f44 4953 4142 4c45 5f4c 4f47  RENT_DISABLE_LOG
    │ │ │ +0004c820: 4749 4e47 0a09 0969 6620 2873 686f 756c  GING...if (shoul
    │ │ │ +0004c830: 645f 6c6f 6728 2920 2661 6d70 3b26 616d  d_log() &&am
    │ │ │ +0004c840: 703b 2073 7461 7465 5f75 7064 6174 6529  p; state_update)
    │ │ │ +0004c850: 0a09 0909 6465 6275 675f 6c6f 6728 222a  ....debug_log("*
    │ │ │ +0004c860: 2a2a 2073 6574 2d6d 6178 2d63 6f6e 6e65  ** set-max-conne
    │ │ │ +0004c870: 6374 696f 6e73 3a20 2564 222c 206d 5f6d  ctions: %d", m_m
    │ │ │ +0004c880: 6178 5f63 6f6e 6e65 6374 696f 6e73 293b  ax_connections);
    │ │ │ +0004c890: 0a23 656e 6469 660a 0a09 0969 6620 286e  .#endif....if (n
    │ │ │ +0004c8a0: 756d 5f70 6565 7273 2829 2026 6774 3b20  um_peers() > 
    │ │ │ +0004c8b0: 696e 7428 6d5f 6d61 785f 636f 6e6e 6563  int(m_max_connec
    │ │ │ +0004c8c0: 7469 6f6e 7329 290a 0909 7b0a 0909 0964  tions))...{....d
    │ │ │ +0004c8d0: 6973 636f 6e6e 6563 745f 7065 6572 7328  isconnect_peers(
    │ │ │ +0004c8e0: 6e75 6d5f 7065 6572 7328 2920 2d20 6d5f  num_peers() - m_
    │ │ │ +0004c8f0: 6d61 785f 636f 6e6e 6563 7469 6f6e 730a  max_connections.
    │ │ │ +0004c900: 0909 0909 2c20 6572 726f 7273 3a3a 746f  ...., errors::to
    │ │ │ +0004c910: 6f5f 6d61 6e79 5f63 6f6e 6e65 6374 696f  o_many_connectio
    │ │ │ +0004c920: 6e73 293b 0a09 097d 0a0a 0909 6966 2028  ns);...}....if (
    │ │ │ +0004c930: 7374 6174 655f 7570 6461 7465 290a 0909  state_update)...
    │ │ │ +0004c940: 0973 6574 5f6e 6565 645f 7361 7665 5f72  .set_need_save_r
    │ │ │ +0004c950: 6573 756d 6528 746f 7272 656e 745f 6861  esume(torrent_ha
    │ │ │ +0004c960: 6e64 6c65 3a3a 6966 5f63 6f6e 6669 675f  ndle::if_config_
    │ │ │ +0004c970: 6368 616e 6765 6429 3b0a 097d 0a0a 0976  changed);..}...v
    │ │ │ +0004c980: 6f69 6420 746f 7272 656e 743a 3a73 6574  oid torrent::set
    │ │ │ +0004c990: 5f75 706c 6f61 645f 6c69 6d69 7428 696e  _upload_limit(in
    │ │ │ +0004c9a0: 7420 636f 6e73 7420 6c69 6d69 7429 0a09  t const limit)..
    │ │ │ +0004c9b0: 7b0a 0909 7365 745f 6c69 6d69 745f 696d  {...set_limit_im
    │ │ │ +0004c9c0: 706c 286c 696d 6974 2c20 7065 6572 5f63  pl(limit, peer_c
    │ │ │ +0004c9d0: 6f6e 6e65 6374 696f 6e3a 3a75 706c 6f61  onnection::uploa
    │ │ │ +0004c9e0: 645f 6368 616e 6e65 6c29 3b0a 2369 666e  d_channel);.#ifn
    │ │ │ +0004c9f0: 6465 6620 544f 5252 454e 545f 4449 5341  def TORRENT_DISA
    │ │ │ +0004ca00: 424c 455f 4c4f 4747 494e 470a 0909 6465  BLE_LOGGING...de
    │ │ │ +0004ca10: 6275 675f 6c6f 6728 222a 2a2a 2073 6574  bug_log("*** set
    │ │ │ +0004ca20: 2d75 706c 6f61 642d 6c69 6d69 743a 2025  -upload-limit: %
    │ │ │ +0004ca30: 6422 2c20 6c69 6d69 7429 3b0a 2365 6e64  d", limit);.#end
    │ │ │ +0004ca40: 6966 0a09 7d0a 0a09 766f 6964 2074 6f72  if..}...void tor
    │ │ │ +0004ca50: 7265 6e74 3a3a 7365 745f 646f 776e 6c6f  rent::set_downlo
    │ │ │ +0004ca60: 6164 5f6c 696d 6974 2869 6e74 2063 6f6e  ad_limit(int con
    │ │ │ +0004ca70: 7374 206c 696d 6974 290a 097b 0a3c 2f70  st limit)..{.

    re │ │ │ +0004cab0: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/t │ │ │ +0004caf0: 6f72 7265 6e74 2e63 7070 3a31 3136 3837 orrent.cpp:11687 │ │ │ +0004cb00: 3c2f 613e 3c2f 7464 3e3c 7464 3e69 6e73 ins │ │ │ +0004cb10: 7465 6164 206f 6620 7265 736f 7274 696e tead of resortin │ │ │ +0004cb20: 6720 7468 6520 7768 6f6c 6520 6c69 7374 g the whole list │ │ │ +0004cb30: 2c20 696e 7365 7274 2074 6865 2070 6565 , insert the pee │ │ │ +0004cb40: 7273 2064 6972 6563 746c 7920 696e 746f rs directly into │ │ │ +0004cb50: 2074 6865 2072 6967 6874 2070 6c61 6365 the right place │ │ │ +0004cb60: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    in │ │ │ +0004cbb0: 7374 6561 6420 6f66 2072 6573 6f72 7469 stead of resorti │ │ │ +0004cbc0: 6e67 2074 6865 2077 686f 6c65 206c 6973 ng the whole lis │ │ │ +0004cbd0: 742c 2069 6e73 6572 7420 7468 6520 7065 t, insert the pe │ │ │ +0004cbe0: 6572 730a 6469 7265 6374 6c79 2069 6e74 ers.directly int │ │ │ +0004cbf0: 6f20 7468 6520 7269 6768 7420 706c 6163 o the right plac │ │ │ +0004cc00: 653c 2f68 323e 3c68 343e 2e2e 2f73 7263 e

    ../src │ │ │ +0004cc10: 2f74 6f72 7265 6e74 2e63 7070 3a31 3136 /torrent.cpp:116 │ │ │ +0004cc20: 3837 3c2f 6834 3e3c 7072 6520 7374 796c 87

    ....std::printf
    │ │ │ +0004cc70: 2822 7469 6d65 6420 6f75 7420 5b61 7665  ("timed out [ave
    │ │ │ +0004cc80: 7261 6765 2d70 6965 6365 2d74 696d 653a  rage-piece-time:
    │ │ │ +0004cc90: 2025 6420 6d73 205d 5c6e 220a 0909 0909   %d ms ]\n".....
    │ │ │ +0004cca0: 092c 206d 5f61 7665 7261 6765 5f70 6965  ., m_average_pie
    │ │ │ +0004ccb0: 6365 5f74 696d 6529 3b0a 2365 6e64 6966  ce_time);.#endif
    │ │ │ +0004ccc0: 0a09 0909 7d0a 0a09 0909 2f2f 2070 6963  ....}.....// pic
    │ │ │ +0004ccd0: 6b20 616c 6c20 626c 6f63 6b73 2066 6f72  k all blocks for
    │ │ │ +0004cce0: 2074 6869 7320 7069 6563 652e 2074 6865   this piece. the
    │ │ │ +0004ccf0: 2070 6565 7273 206c 6973 7420 6973 206b   peers list is k
    │ │ │ +0004cd00: 6570 7420 7570 2074 6f20 6461 7465 0a09  ept up to date..
    │ │ │ +0004cd10: 0909 2f2f 2061 6e64 2073 6f72 7465 642e  ..// and sorted.
    │ │ │ +0004cd20: 2077 6865 6e20 7765 2069 7373 7565 2061   when we issue a
    │ │ │ +0004cd30: 2072 6571 7565 7374 2074 6f20 6120 7065   request to a pe
    │ │ │ +0004cd40: 6572 2c20 6974 7320 646f 776e 6c6f 6164  er, its download
    │ │ │ +0004cd50: 2071 7565 7565 0a09 0909 2f2f 2074 696d   queue....// tim
    │ │ │ +0004cd60: 6520 7769 6c6c 2069 6e63 7265 6173 6520  e will increase 
    │ │ │ +0004cd70: 616e 6420 6974 206d 6179 206e 6565 6420  and it may need 
    │ │ │ +0004cd80: 746f 2062 6520 6275 6d70 6564 2069 6e20  to be bumped in 
    │ │ │ +0004cd90: 7468 6520 7065 6572 7320 6c69 7374 2c0a  the peers list,.
    │ │ │ +0004cda0: 0909 092f 2f20 7369 6e63 6520 6974 2773  ...// since it's
    │ │ │ +0004cdb0: 206f 7264 6572 6564 2062 7920 646f 776e   ordered by down
    │ │ │ +0004cdc0: 6c6f 6164 2071 7565 7565 2074 696d 650a  load queue time.
    │ │ │ +0004cdd0: 0909 0970 6963 6b5f 7469 6d65 5f63 7269  ...pick_time_cri
    │ │ │ +0004cde0: 7469 6361 6c5f 626c 6f63 6b28 7065 6572  tical_block(peer
    │ │ │ +0004cdf0: 732c 2069 676e 6f72 655f 7065 6572 730a  s, ignore_peers.
    │ │ │ +0004ce00: 0909 0909 2c20 7065 6572 735f 7769 7468  ...., peers_with
    │ │ │ +0004ce10: 5f72 6571 7565 7374 730a 0909 0909 2c20  _requests....., 
    │ │ │ +0004ce20: 7069 2c20 2661 6d70 3b69 2c20 6d5f 7069  pi, &i, m_pi
    │ │ │ +0004ce30: 636b 6572 2e67 6574 2829 0a09 0909 092c  cker.get().....,
    │ │ │ +0004ce40: 2062 6c6f 636b 735f 696e 5f70 6965 6365   blocks_in_piece
    │ │ │ +0004ce50: 2c20 7469 6d65 645f 6f75 7429 3b0a 0a09  , timed_out);...
    │ │ │ +0004ce60: 0909 2f2f 2070 7574 2062 6163 6b20 7468  ..// put back th
    │ │ │ +0004ce70: 6520 7065 6572 7320 7765 2069 676e 6f72  e peers we ignor
    │ │ │ +0004ce80: 6564 2069 6e74 6f20 7468 6520 7065 6572  ed into the peer
    │ │ │ +0004ce90: 206c 6973 7420 666f 7220 7468 6520 6e65   list for the ne
    │ │ │ +0004cea0: 7874 2070 6965 6365 0a09 0909 6966 2028  xt piece....if (
    │ │ │ +0004ceb0: 2169 676e 6f72 655f 7065 6572 732e 656d  !ignore_peers.em
    │ │ │ +0004cec0: 7074 7928 2929 0a09 0909 7b0a 0909 0909  pty())....{.....
    │ │ │ +0004ced0: 7065 6572 732e 696e 7365 7274 2870 6565  peers.insert(pee
    │ │ │ +0004cee0: 7273 2e62 6567 696e 2829 2c20 6967 6e6f  rs.begin(), igno
    │ │ │ +0004cef0: 7265 5f70 6565 7273 2e62 6567 696e 2829  re_peers.begin()
    │ │ │ +0004cf00: 2c20 6967 6e6f 7265 5f70 6565 7273 2e65  , ignore_peers.e
    │ │ │ +0004cf10: 6e64 2829 293b 0a09 0909 0969 676e 6f72  nd());.....ignor
    │ │ │ +0004cf20: 655f 7065 6572 732e 636c 6561 7228 293b  e_peers.clear();
    │ │ │ +0004cf30: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +0004cf60: 0909 0909 7374 643a 3a73 6f72 7428 7065 ....std::sort(pe │ │ │ +0004cf70: 6572 732e 6265 6769 6e28 292c 2070 6565 ers.begin(), pee │ │ │ +0004cf80: 7273 2e65 6e64 2829 0a3c 2f64 6976 3e09 rs.end().
    . │ │ │ +0004cf90: 0909 0909 2c20 5b5d 2028 7065 6572 5f63 ...., [] (peer_c │ │ │ +0004cfa0: 6f6e 6e65 6374 696f 6e20 636f 6e73 742a onnection const* │ │ │ +0004cfb0: 206c 6873 2c20 7065 6572 5f63 6f6e 6e65 lhs, peer_conne │ │ │ +0004cfc0: 6374 696f 6e20 636f 6e73 742a 2072 6873 ction const* rhs │ │ │ +0004cfd0: 290a 0909 0909 097b 2072 6574 7572 6e20 )......{ return │ │ │ +0004cfe0: 6c68 732d 2667 743b 646f 776e 6c6f 6164 lhs->download │ │ │ +0004cff0: 5f71 7565 7565 5f74 696d 6528 3136 2a31 _queue_time(16*1 │ │ │ +0004d000: 3032 3429 2026 6c74 3b20 7268 732d 2667 024) < rhs-&g │ │ │ +0004d010: 743b 646f 776e 6c6f 6164 5f71 7565 7565 t;download_queue │ │ │ +0004d020: 5f74 696d 6528 3136 2a31 3032 3429 3b20 _time(16*1024); │ │ │ +0004d030: 7d29 3b0a 0909 097d 0a0a 0909 092f 2f20 });....}.....// │ │ │ +0004d040: 6966 2074 6869 7320 7065 6572 2773 2064 if this peer's d │ │ │ +0004d050: 6f77 6e6c 6f61 6420 7469 6d65 2065 7863 ownload time exc │ │ │ +0004d060: 6565 6473 2032 2073 6563 6f6e 6473 2c20 eeds 2 seconds, │ │ │ +0004d070: 7765 2772 6520 646f 6e65 2e0a 0909 092f we're done...../ │ │ │ +0004d080: 2f20 5765 2064 6f6e 2774 2077 616e 7420 / We don't want │ │ │ +0004d090: 746f 2062 7569 6c64 2075 6e72 6561 736f to build unreaso │ │ │ +0004d0a0: 6e61 626c 7920 6c6f 6e67 2072 6571 7565 nably long reque │ │ │ +0004d0b0: 7374 2071 7565 7565 730a 0909 0969 6620 st queues....if │ │ │ +0004d0c0: 2821 7065 6572 732e 656d 7074 7928 2920 (!peers.empty() │ │ │ +0004d0d0: 2661 6d70 3b26 616d 703b 2070 6565 7273 && peers │ │ │ +0004d0e0: 5b30 5d2d 2667 743b 646f 776e 6c6f 6164 [0]->download │ │ │ +0004d0f0: 5f71 7565 7565 5f74 696d 6528 2920 2667 _queue_time() &g │ │ │ +0004d100: 743b 206d 696c 6c69 7365 636f 6e64 7328 t; milliseconds( │ │ │ +0004d110: 3230 3030 2929 0a09 0909 0962 7265 616b 2000)).....break │ │ │ +0004d120: 3b0a 0909 7d0a 0a09 092f 2f20 636f 6d6d ;...}....// comm │ │ │ +0004d130: 6974 2061 6c6c 2074 6865 2074 696d 6520 it all the time │ │ │ +0004d140: 6372 6974 6963 616c 2072 6571 7565 7374 critical request │ │ │ +0004d150: 730a 0909 666f 7220 2861 7574 6f2a 2070 s...for (auto* p │ │ │ +0004d160: 203a 2070 6565 7273 5f77 6974 685f 7265 : peers_with_re │ │ │ +0004d170: 7175 6573 7473 290a 0909 7b0a 0909 0970 quests)...{....p │ │ │ +0004d180: 2d26 6774 3b73 656e 645f 626c 6f63 6b5f ->send_block_ │ │ │ +0004d190: 7265 7175 6573 7473 2829 3b0a 0909 7d0a requests();...}. │ │ │ +0004d1a0: 097d 0a23 656e 6469 6620 2f2f 2054 4f52 .}.#endif // TOR │ │ │ +0004d1b0: 5245 4e54 5f44 4953 4142 4c45 5f53 5452 RENT_DISABLE_STR │ │ │ +0004d1c0: 4541 4d49 4e47 0a0a 0973 7464 3a3a 7365 EAMING...std::se │ │ │ +0004d1d0: 7426 6c74 3b73 7464 3a3a 7374 7269 6e67 t<std::string │ │ │ +0004d1e0: 2667 743b 2074 6f72 7265 6e74 3a3a 7765 > torrent::we │ │ │ +0004d1f0: 625f 7365 6564 7328 2920 636f 6e73 740a b_seeds() const. │ │ │ +0004d200: 097b 0a09 0954 4f52 5245 4e54 5f41 5353 .{...TORRENT_ASS │ │ │ +0004d210: 4552 5428 6973 5f73 696e 676c 655f 7468 ERT(is_single_th │ │ │ +0004d220: 7265 6164 2829 293b 0a09 0973 7464 3a3a read());...std:: │ │ │ +0004d230: 7365 7426 6c74 3b73 7464 3a3a 7374 7269 set<std::stri │ │ │ +0004d240: 6e67 2667 743b 2072 6574 3b0a 0909 666f ng> ret;...fo │ │ │ +0004d250: 7220 2861 7574 6f20 636f 6e73 7426 616d r (auto const&am │ │ │ +0004d260: 703b 2073 203a 206d 5f77 6562 5f73 6565 p; s : m_web_see │ │ │ +0004d270: 6473 290a 0909 7b0a 0909 0969 6620 2873 ds)...{....if (s │ │ │ +0004d280: 2e70 6565 725f 696e 666f 2e62 616e 6e65 .peer_info.banne │ │ │ +0004d290: 6429 2063 6f6e 7469 6e75 653b 0a09 0909 d) continue;.... │ │ │ +0004d2a0: 6966 2028 732e 7265 6d6f 7665 6429 2063 if (s.removed) c │ │ │ +0004d2b0: 6f6e 7469 6e75 653b 0a09 0909 7265 742e ontinue;....ret. │ │ │ +0004d2c0: 696e 7365 7274 2873 2e75 726c 293b 0a09 insert(s.url);.. │ │ │ +0004d2d0: 097d 0a09 0972 6574 7572 6e20 7265 743b .}...return ret; │ │ │ +0004d2e0: 0a09 7d0a 3c2f 7072 653e 3c2f 7464 3e3c ..}.
    < │ │ │ +0004d2f0: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +0004d320: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +0004d350: 2e2f 7372 632f 7765 625f 636f 6e6e 6563 ./src/web_connec │ │ │ +0004d360: 7469 6f6e 5f62 6173 652e 6370 703a 3530 tion_base.cpp:50 │ │ │ +0004d370: 3c2f 613e 3c2f 7464 3e3c 7464 3e69 6e74 int │ │ │ +0004d380: 726f 6475 6365 2061 2077 6562 2d73 6565 roduce a web-see │ │ │ +0004d390: 6420 6465 6661 756c 7420 636c 6173 7320 d default class │ │ │ +0004d3a0: 7768 6963 6820 6861 7320 6120 6c6f 7720 which has a low │ │ │ +0004d3b0: 646f 776e 6c6f 6164 2070 7269 6f72 6974 download priorit │ │ │ +0004d3c0: 793c 2f74 643e 3c2f 7472 3e3c 7472 2069 y

    i │ │ │ +0004d410: 6e74 726f 6475 6365 2061 2077 6562 2d73 ntroduce a web-s │ │ │ +0004d420: 6565 6420 6465 6661 756c 7420 636c 6173 eed default clas │ │ │ +0004d430: 7320 7768 6963 6820 6861 7320 6120 6c6f s which has a lo │ │ │ +0004d440: 7720 646f 776e 6c6f 6164 2070 7269 6f72 w download prior │ │ │ +0004d450: 6974 793c 2f68 323e 3c68 343e 2e2e 2f73 ity

    ../s │ │ │ +0004d460: 7263 2f77 6562 5f63 6f6e 6e65 6374 696f rc/web_connectio │ │ │ +0004d470: 6e5f 6261 7365 2e63 7070 3a35 303c 2f68 n_base.cpp:50
    ..: 
    │ │ │ +0004d4c0: 7065 6572 5f63 6f6e 6e65 6374 696f 6e28  peer_connection(
    │ │ │ +0004d4d0: 7061 636b 290a 0909 2c20 6d5f 6669 7273  pack)..., m_firs
    │ │ │ +0004d4e0: 745f 7265 7175 6573 7428 7472 7565 290a  t_request(true).
    │ │ │ +0004d4f0: 0909 2c20 6d5f 7373 6c28 6661 6c73 6529  .., m_ssl(false)
    │ │ │ +0004d500: 0a09 092c 206d 5f65 7874 6572 6e61 6c5f  ..., m_external_
    │ │ │ +0004d510: 6175 7468 2877 6562 2e61 7574 6829 0a09  auth(web.auth)..
    │ │ │ +0004d520: 092c 206d 5f65 7874 7261 5f68 6561 6465  ., m_extra_heade
    │ │ │ +0004d530: 7273 2877 6562 2e65 7874 7261 5f68 6561  rs(web.extra_hea
    │ │ │ +0004d540: 6465 7273 290a 0909 2c20 6d5f 7061 7273  ders)..., m_pars
    │ │ │ +0004d550: 6572 2861 7578 3a3a 6874 7470 5f70 6172  er(aux::http_par
    │ │ │ +0004d560: 7365 723a 3a64 6f6e 745f 7061 7273 655f  ser::dont_parse_
    │ │ │ +0004d570: 6368 756e 6b73 290a 0909 2c20 6d5f 626f  chunks)..., m_bo
    │ │ │ +0004d580: 6479 5f73 7461 7274 2830 290a 097b 0a09  dy_start(0)..{..
    │ │ │ +0004d590: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ +0004d5a0: 2661 6d70 3b77 6562 2e70 6565 725f 696e  &web.peer_in
    │ │ │ +0004d5b0: 666f 203d 3d20 7061 636b 2e70 6565 7269  fo == pack.peeri
    │ │ │ +0004d5c0: 6e66 6f29 3b0a 0909 2f2f 2077 6865 6e20  nfo);...// when 
    │ │ │ +0004d5d0: 676f 696e 6720 7468 726f 7567 6820 6120  going through a 
    │ │ │ +0004d5e0: 7072 6f78 792c 2077 6520 646f 6e27 7420  proxy, we don't 
    │ │ │ +0004d5f0: 6e65 6365 7373 6172 696c 7920 6861 7665  necessarily have
    │ │ │ +0004d600: 2061 6e20 656e 6470 6f69 6e74 2068 6572   an endpoint her
    │ │ │ +0004d610: 652c 0a09 092f 2f20 7369 6e63 6520 7468  e,...// since th
    │ │ │ +0004d620: 6520 7072 6f78 7920 6d69 6768 7420 6265  e proxy might be
    │ │ │ +0004d630: 2072 6573 6f6c 7669 6e67 2074 6865 2068   resolving the h
    │ │ │ +0004d640: 6f73 746e 616d 652c 206e 6f74 2075 730a  ostname, not us.
    │ │ │ +0004d650: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ +0004d660: 2877 6562 2e65 6e64 706f 696e 7473 2e65  (web.endpoints.e
    │ │ │ +0004d670: 6d70 7479 2829 207c 7c20 7765 622e 656e  mpty() || web.en
    │ │ │ +0004d680: 6470 6f69 6e74 732e 6672 6f6e 7428 2920  dpoints.front() 
    │ │ │ +0004d690: 3d3d 2070 6163 6b2e 656e 6470 293b 0a0a  == pack.endp);..
    │ │ │ +0004d6a0: 0909 494e 5641 5249 414e 545f 4348 4543  ..INVARIANT_CHEC
    │ │ │ +0004d6b0: 4b3b 0a0a 0909 544f 5252 454e 545f 4153  K;....TORRENT_AS
    │ │ │ +0004d6c0: 5345 5254 2869 735f 6f75 7467 6f69 6e67  SERT(is_outgoing
    │ │ │ +0004d6d0: 2829 293b 0a0a 0909 544f 5252 454e 545f  ());....TORRENT_
    │ │ │ +0004d6e0: 4153 5345 5254 2821 6d5f 746f 7272 656e  ASSERT(!m_torren
    │ │ │ +0004d6f0: 742e 6c6f 636b 2829 2d26 6774 3b69 735f  t.lock()->is_
    │ │ │ +0004d700: 7570 6c6f 6164 5f6f 6e6c 7928 2929 3b0a  upload_only());.
    │ │ │ +0004d710: 0a09 092f 2f20 7765 206f 6e6c 7920 7761  ...// we only wa
    │ │ │ +0004d720: 6e74 206c 6566 742d 6f76 6572 2062 616e  nt left-over ban
    │ │ │ +0004d730: 6477 6964 7468 0a3c 6469 7620 7374 796c  dwidth.
    .
    ..st │ │ │ +0004d770: 643a 3a73 7472 696e 6720 7072 6f74 6f63 d::string protoc │ │ │ +0004d780: 6f6c 3b0a 0909 6572 726f 725f 636f 6465 ol;...error_code │ │ │ +0004d790: 2065 633b 0a09 0973 7464 3a3a 7469 6528 ec;...std::tie( │ │ │ +0004d7a0: 7072 6f74 6f63 6f6c 2c20 6d5f 6261 7369 protocol, m_basi │ │ │ +0004d7b0: 635f 6175 7468 2c20 6d5f 686f 7374 2c20 c_auth, m_host, │ │ │ +0004d7c0: 6d5f 706f 7274 2c20 6d5f 7061 7468 290a m_port, m_path). │ │ │ +0004d7d0: 0909 093d 2070 6172 7365 5f75 726c 5f63 ...= parse_url_c │ │ │ +0004d7e0: 6f6d 706f 6e65 6e74 7328 7765 622e 7572 omponents(web.ur │ │ │ +0004d7f0: 6c2c 2065 6329 3b0a 0909 544f 5252 454e l, ec);...TORREN │ │ │ +0004d800: 545f 4153 5345 5254 2821 6563 293b 0a0a T_ASSERT(!ec);.. │ │ │ +0004d810: 0909 6966 2028 6d5f 706f 7274 203d 3d20 ..if (m_port == │ │ │ +0004d820: 2d31 2026 616d 703b 2661 6d70 3b20 7072 -1 && pr │ │ │ +0004d830: 6f74 6f63 6f6c 203d 3d20 2268 7474 7022 otocol == "http" │ │ │ +0004d840: 290a 0909 096d 5f70 6f72 7420 3d20 3830 )....m_port = 80 │ │ │ +0004d850: 3b0a 0a23 6966 2054 4f52 5245 4e54 5f55 ;..#if TORRENT_U │ │ │ +0004d860: 5345 5f53 534c 0a09 0969 6620 2870 726f SE_SSL...if (pro │ │ │ +0004d870: 746f 636f 6c20 3d3d 2022 6874 7470 7322 tocol == "https" │ │ │ +0004d880: 290a 0909 7b0a 0909 096d 5f73 736c 203d )...{....m_ssl = │ │ │ +0004d890: 2074 7275 653b 0a09 0909 6966 2028 6d5f true;....if (m_ │ │ │ +0004d8a0: 706f 7274 203d 3d20 2d31 2920 6d5f 706f port == -1) m_po │ │ │ +0004d8b0: 7274 203d 2034 3433 3b0a 0909 7d0a 2365 rt = 443;...}.#e │ │ │ +0004d8c0: 6e64 6966 0a0a 0909 6966 2028 216d 5f62 ndif....if (!m_b │ │ │ +0004d8d0: 6173 6963 5f61 7574 682e 656d 7074 7928 asic_auth.empty( │ │ │ +0004d8e0: 2929 0a09 0909 6d5f 6261 7369 635f 6175 ))....m_basic_au │ │ │ +0004d8f0: 7468 203d 2062 6173 6536 3465 6e63 6f64 th = base64encod │ │ │ +0004d900: 6528 6d5f 6261 7369 635f 6175 7468 293b e(m_basic_auth); │ │ │ +0004d910: 0a0a 0909 6d5f 7365 7276 6572 5f73 7472 ....m_server_str │ │ │ +0004d920: 696e 6720 3d20 6d5f 686f 7374 3b0a 0909 ing = m_host;... │ │ │ +0004d930: 6175 783a 3a76 6572 6966 795f 656e 636f aux::verify_enco │ │ │ +0004d940: 6469 6e67 286d 5f73 6572 7665 725f 7374 ding(m_server_st │ │ │ +0004d950: 7269 6e67 293b 0a09 7d0a 0a09 696e 7420 ring);..}...int │ │ │ +0004d960: 7765 625f 636f 6e6e 6563 7469 6f6e 5f62 web_connection_b │ │ │ +0004d970: 6173 653a 3a74 696d 656f 7574 2829 2063 ase::timeout() c │ │ │ +0004d980: 6f6e 7374 0a09 7b0a 0909 2f2f 2073 696e onst..{...// sin │ │ │ +0004d990: 6365 2074 6869 7320 6973 2061 2077 6562 ce this is a web │ │ │ +0004d9a0: 2073 6565 642c 2063 6861 6e67 6520 7468 seed, change th │ │ │ +0004d9b0: 6520 7469 6d65 6f75 740a 0909 2f2f 2061 e timeout...// a │ │ │ +0004d9c0: 6363 6f72 6469 6e67 2074 6f20 7468 6520 ccording to the │ │ │ +0004d9d0: 7365 7474 696e 6773 2e0a 0909 7265 7475 settings....retu │ │ │ +0004d9e0: 726e 206d 5f73 6574 7469 6e67 732e 6765 rn m_settings.ge │ │ │ +0004d9f0: 745f 696e 7428 7365 7474 696e 6773 5f70 t_int(settings_p │ │ │ +0004da00: 6163 6b3a 3a75 726c 7365 6564 5f74 696d ack::urlseed_tim │ │ │ +0004da10: 656f 7574 293b 0a09 7d0a 3c2f 7072 653e eout);..}.
    │ │ │ +0004da20: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +0004da50: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +0004da60: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/stor │ │ │ +0004da90: 6167 655f 7574 696c 732e 6370 703a 3132 age_utils.cpp:12 │ │ │ +0004daa0: 353c 2f61 3e3c 2f74 643e 3c74 643e 6964 5id │ │ │ +0004dab0: 6561 6c6c 792c 2069 6620 7765 2065 6e64 eally, if we end │ │ │ +0004dac0: 2075 7020 636f 7079 696e 6720 6669 6c65 up copying file │ │ │ +0004dad0: 7320 6265 6361 7573 6520 6f66 2061 206d s because of a m │ │ │ +0004dae0: 6f76 6520 6163 726f 7373 2076 6f6c 756d ove across volum │ │ │ +0004daf0: 6573 2c20 7468 6520 736f 7572 6365 2073 es, the source s │ │ │ +0004db00: 686f 756c 6420 6e6f 7420 6265 2064 656c hould not be del │ │ │ +0004db10: 6574 6564 2075 6e74 696c 2074 6865 7927 eted until they' │ │ │ +0004db20: 7665 2061 6c6c 2062 6565 6e20 636f 7069 ve all been copi │ │ │ +0004db30: 6564 2e20 5468 6174 2077 6f75 6c64 206c ed. That would l │ │ │ +0004db40: 6574 2075 7320 726f 6c6c 6261 636b 2077 et us rollback w │ │ │ +0004db50: 6974 6820 6869 6768 6572 2063 6f6e 6669 ith higher confi │ │ │ +0004db60: 6465 6e63 652e 3c2f 7464 3e3c 2f74 723e dence. │ │ │ +0004db70: 3c74 7220 6964 3d22 3138 3522 2073 7479 │ │ │ +0004dba0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +0004dbb0: 3c68 323e 6964 6561 6c6c 792c 2069 6620

    ideally, if │ │ │ +0004dbc0: 7765 2065 6e64 2075 7020 636f 7079 696e we end up copyin │ │ │ +0004dbd0: 6720 6669 6c65 7320 6265 6361 7573 6520 g files because │ │ │ +0004dbe0: 6f66 2061 206d 6f76 6520 6163 726f 7373 of a move across │ │ │ +0004dbf0: 0a76 6f6c 756d 6573 2c20 7468 6520 736f .volumes, the so │ │ │ +0004dc00: 7572 6365 2073 686f 756c 6420 6e6f 7420 urce should not │ │ │ +0004dc10: 6265 2064 656c 6574 6564 2075 6e74 696c be deleted until │ │ │ +0004dc20: 2074 6865 7927 7665 2061 6c6c 2062 6565 they've all bee │ │ │ +0004dc30: 6e0a 636f 7069 6564 2e20 5468 6174 2077 n.copied. That w │ │ │ +0004dc40: 6f75 6c64 206c 6574 2075 7320 726f 6c6c ould let us roll │ │ │ +0004dc50: 6261 636b 2077 6974 6820 6869 6768 6572 back with higher │ │ │ +0004dc60: 2063 6f6e 6669 6465 6e63 652e 3c2f 6832 confidence.

    ../src/stor │ │ │ +0004dc80: 6167 655f 7574 696c 732e 6370 703a 3132 age_utils.cpp:12 │ │ │ +0004dc90: 353c 2f68 343e 3c70 7265 2073 7479 6c65 5

    │ │ │ +0004dcd0: 0909 6175 783a 3a76 6563 746f 7226 6c74  ..aux::vector<
    │ │ │ +0004dce0: 3b62 6f6f 6c2c 2066 696c 655f 696e 6465  ;bool, file_inde
    │ │ │ +0004dcf0: 785f 7426 6774 3b20 636f 7069 6564 5f66  x_t> copied_f
    │ │ │ +0004dd00: 696c 6573 2873 7464 3a3a 7369 7a65 5f74  iles(std::size_t
    │ │ │ +0004dd10: 2866 2e6e 756d 5f66 696c 6573 2829 292c  (f.num_files()),
    │ │ │ +0004dd20: 2066 616c 7365 293b 0a0a 0909 2f2f 2074   false);....// t
    │ │ │ +0004dd30: 7261 636b 2068 6f77 2066 6172 2077 6520  rack how far we 
    │ │ │ +0004dd40: 676f 7420 696e 2063 6173 6520 6f66 2061  got in case of a
    │ │ │ +0004dd50: 6e20 6572 726f 720a 0909 6669 6c65 5f69  n error...file_i
    │ │ │ +0004dd60: 6e64 6578 5f74 2066 696c 655f 696e 6465  ndex_t file_inde
    │ │ │ +0004dd70: 787b 7d3b 0a09 0966 6f72 2028 6175 746f  x{};...for (auto
    │ │ │ +0004dd80: 2063 6f6e 7374 2069 203a 2066 2e66 696c   const i : f.fil
    │ │ │ +0004dd90: 655f 7261 6e67 6528 2929 0a09 097b 0a09  e_range())...{..
    │ │ │ +0004dda0: 0909 2f2f 2066 696c 6573 206d 6f76 6564  ..// files moved
    │ │ │ +0004ddb0: 206f 7574 2074 6f20 6162 736f 6c75 7465   out to absolute
    │ │ │ +0004ddc0: 2070 6174 6873 2061 7265 206e 6f74 206d   paths are not m
    │ │ │ +0004ddd0: 6f76 6564 0a09 0909 6966 2028 662e 6669  oved....if (f.fi
    │ │ │ +0004dde0: 6c65 5f61 6273 6f6c 7574 655f 7061 7468  le_absolute_path
    │ │ │ +0004ddf0: 2869 2929 2063 6f6e 7469 6e75 653b 0a0a  (i)) continue;..
    │ │ │ +0004de00: 0909 0973 7464 3a3a 7374 7269 6e67 2063  ...std::string c
    │ │ │ +0004de10: 6f6e 7374 206f 6c64 5f70 6174 6820 3d20  onst old_path = 
    │ │ │ +0004de20: 636f 6d62 696e 655f 7061 7468 2873 6176  combine_path(sav
    │ │ │ +0004de30: 655f 7061 7468 2c20 662e 6669 6c65 5f70  e_path, f.file_p
    │ │ │ +0004de40: 6174 6828 6929 293b 0a09 0909 7374 643a  ath(i));....std:
    │ │ │ +0004de50: 3a73 7472 696e 6720 636f 6e73 7420 6e65  :string const ne
    │ │ │ +0004de60: 775f 7061 7468 203d 2063 6f6d 6269 6e65  w_path = combine
    │ │ │ +0004de70: 5f70 6174 6828 6e65 775f 7361 7665 5f70  _path(new_save_p
    │ │ │ +0004de80: 6174 682c 2066 2e66 696c 655f 7061 7468  ath, f.file_path
    │ │ │ +0004de90: 2869 2929 3b0a 0a09 0909 6572 726f 725f  (i));.....error_
    │ │ │ +0004dea0: 636f 6465 2069 676e 6f72 653b 0a09 0909  code ignore;....
    │ │ │ +0004deb0: 2f2f 2061 2064 616e 676c 696e 6720 7379  // a dangling sy
    │ │ │ +0004dec0: 6d6c 696e 6b20 7374 696c 6c20 636f 756e  mlink still coun
    │ │ │ +0004ded0: 7473 2061 7320 6578 6973 7469 6e67 0a09  ts as existing..
    │ │ │ +0004dee0: 0909 6966 2028 666c 6167 7320 3d3d 206d  ..if (flags == m
    │ │ │ +0004def0: 6f76 655f 666c 6167 735f 743a 3a64 6f6e  ove_flags_t::don
    │ │ │ +0004df00: 745f 7265 706c 6163 6520 2661 6d70 3b26  t_replace &&
    │ │ │ +0004df10: 616d 703b 2065 7869 7374 7328 6e65 775f  amp; exists(new_
    │ │ │ +0004df20: 7061 7468 2c20 6967 6e6f 7265 2c20 646f  path, ignore, do
    │ │ │ +0004df30: 6e74 5f66 6f6c 6c6f 775f 6c69 6e6b 7329  nt_follow_links)
    │ │ │ +0004df40: 290a 0909 097b 0a09 0909 0972 6574 207c  )....{.....ret |
    │ │ │ +0004df50: 3d20 6469 736b 5f73 7461 7475 733a 3a6e  = disk_status::n
    │ │ │ +0004df60: 6565 645f 6675 6c6c 5f63 6865 636b 3b0a  eed_full_check;.
    │ │ │ +0004df70: 0909 0909 636f 6e74 696e 7565 3b0a 0909  ....continue;...
    │ │ │ +0004df80: 097d 0a0a 3c64 6976 2073 7479 6c65 3d22  .}..
    ...move_file(o │ │ │ +0004dfc0: 6c64 5f70 6174 682c 206e 6577 5f70 6174 ld_path, new_pat │ │ │ +0004dfd0: 682c 2065 6329 3b0a 3c2f 6469 763e 0a09 h, ec);.
    .. │ │ │ +0004dfe0: 0909 2f2f 2069 6620 7468 6520 736f 7572 ..// if the sour │ │ │ +0004dff0: 6365 2066 696c 6520 646f 6573 6e27 7420 ce file doesn't │ │ │ +0004e000: 6578 6973 742e 2054 6861 7427 7320 6e6f exist. That's no │ │ │ +0004e010: 7420 6120 7072 6f62 6c65 6d0a 0909 092f t a problem..../ │ │ │ +0004e020: 2f20 7765 206a 7573 7420 6967 6e6f 7265 / we just ignore │ │ │ +0004e030: 2074 6861 7420 6669 6c65 0a09 0909 6966 that file....if │ │ │ +0004e040: 2028 6563 2e65 6320 3d3d 2062 6f6f 7374 (ec.ec == boost │ │ │ +0004e050: 3a3a 7379 7374 656d 3a3a 6572 7263 3a3a ::system::errc:: │ │ │ +0004e060: 6e6f 5f73 7563 685f 6669 6c65 5f6f 725f no_such_file_or_ │ │ │ +0004e070: 6469 7265 6374 6f72 7929 0a09 0909 0965 directory).....e │ │ │ +0004e080: 632e 6563 2e63 6c65 6172 2829 3b0a 0909 c.ec.clear();... │ │ │ +0004e090: 0965 6c73 6520 6966 2028 6563 0a09 0909 .else if (ec.... │ │ │ +0004e0a0: 0926 616d 703b 2661 6d70 3b20 6563 2e65 .&& ec.e │ │ │ +0004e0b0: 6320 213d 2062 6f6f 7374 3a3a 7379 7374 c != boost::syst │ │ │ +0004e0c0: 656d 3a3a 6572 7263 3a3a 696e 7661 6c69 em::errc::invali │ │ │ +0004e0d0: 645f 6172 6775 6d65 6e74 0a09 0909 0926 d_argument.....& │ │ │ +0004e0e0: 616d 703b 2661 6d70 3b20 6563 2e65 6320 amp;& ec.ec │ │ │ +0004e0f0: 213d 2062 6f6f 7374 3a3a 7379 7374 656d != boost::system │ │ │ +0004e100: 3a3a 6572 7263 3a3a 7065 726d 6973 7369 ::errc::permissi │ │ │ +0004e110: 6f6e 5f64 656e 6965 6429 0a09 0909 7b0a on_denied)....{. │ │ │ +0004e120: 0909 0909 2f2f 206d 6f76 696e 6720 7468 ....// moving th │ │ │ +0004e130: 6520 6669 6c65 2066 6169 6c65 640a 0909 e file failed... │ │ │ +0004e140: 0909 2f2f 206f 6e20 4f53 582c 2074 6865 ..// on OSX, the │ │ │ +0004e150: 2065 7272 6f72 2077 6865 6e20 7472 7969 error when tryi │ │ │ +0004e160: 6e67 2074 6f20 7265 6e61 6d65 2061 2066 ng to rename a f │ │ │ +0004e170: 696c 6520 6163 726f 7373 2064 6966 6665 ile across diffe │ │ │ +0004e180: 7265 6e74 0a09 0909 092f 2f20 766f 6c75 rent.....// volu │ │ │ +0004e190: 6d65 7320 6973 2045 5844 4556 2c20 7768 mes is EXDEV, wh │ │ │ +0004e1a0: 6963 6820 7769 6c6c 206d 616b 6520 6974 ich will make it │ │ │ +0004e1b0: 2066 616c 6c20 6261 636b 2074 6f20 636f fall back to co │ │ │ +0004e1c0: 7079 696e 672e 0a09 0909 0965 632e 6563 pying......ec.ec │ │ │ +0004e1d0: 2e63 6c65 6172 2829 3b0a 2369 6620 544f .clear();.#if TO │ │ │ +0004e1e0: 5252 454e 545f 4841 535f 5359 4d4c 494e RRENT_HAS_SYMLIN │ │ │ +0004e1f0: 4b0a 0909 0909 626f 6f6c 2063 6f6e 7374 K.....bool const │ │ │ +0004e200: 2064 6563 6c61 7265 645f 7379 6d6c 696e declared_symlin │ │ │ +0004e210: 6b20 3d20 626f 6f6c 2866 2e66 696c 655f k = bool(f.file_ │ │ │ +0004e220: 666c 6167 7328 6929 2026 616d 703b 2066 flags(i) & f │ │ │ +0004e230: 696c 655f 7374 6f72 6167 653a 3a66 6c61 ile_storage::fla │ │ │ +0004e240: 675f 7379 6d6c 696e 6b29 3b0a 0909 0909 g_symlink);..... │ │ │ +0004e250: 6669 6c65 5f73 7461 7475 7320 6f6c 645f file_status old_ │ │ │ +0004e260: 7374 6174 3b0a 0909 0909 6572 726f 725f stat;.....error_ │ │ │ +0004e270: 636f 6465 2073 7461 745f 6563 3b0a 0909 code stat_ec;... │ │ │ +0004e280: 0909 7374 6174 5f66 696c 6528 6f6c 645f ..stat_file(old_ │ │ │ +0004e290: 7061 7468 2c20 2661 6d70 3b6f 6c64 5f73 path, &old_s │ │ │ +0004e2a0: 7461 742c 2073 7461 745f 6563 2c20 646f tat, stat_ec, do │ │ │ +0004e2b0: 6e74 5f66 6f6c 6c6f 775f 6c69 6e6b 7329 nt_follow_links) │ │ │ +0004e2c0: 3b0a 0909 0909 626f 6f6c 2063 6f6e 7374 ;.....bool const │ │ │ +0004e2d0: 2061 6374 7561 6c5f 7379 6d6c 696e 6b20 actual_symlink │ │ │ +0004e2e0: 3d20 2173 7461 745f 6563 2026 616d 703b = !stat_ec & │ │ │ +0004e2f0: 2661 6d70 3b20 626f 6f6c 286f 6c64 5f73 & bool(old_s │ │ │ +0004e300: 7461 742e 6d6f 6465 2026 616d 703b 2066 tat.mode & f │ │ │ +0004e310: 696c 655f 7374 6174 7573 3a3a 7379 6d6c ile_status::syml │ │ │ +0004e320: 696e 6b29 3b0a 0909 0909 6966 2028 6465 ink);.....if (de │ │ │ +0004e330: 636c 6172 6564 5f73 796d 6c69 6e6b 2021 clared_symlink ! │ │ │ +0004e340: 3d20 6163 7475 616c 5f73 796d 6c69 6e6b = actual_symlink │ │ │ +0004e350: 290a 0909 0909 7b0a 0909 0909 092f 2f20 ).....{......// │ │ │ +0004e360: 7768 6174 2773 206f 6e20 6469 736b 2064 what's on disk d │ │ │ +0004e370: 6f65 7320 6e6f 7420 6d61 7463 6820 7768 oes not match wh │ │ │ +0004e380: 6174 2074 6865 2074 6f72 7265 6e74 2065 at the torrent e │ │ │ +0004e390: 7870 6563 7473 3b0a 0909 0909 092f 2f20 xpects;......// │ │ │ +0004e3a0: 6974 2773 206e 6f74 2073 6166 6520 746f it's not safe to │ │ │ +0004e3b0: 2061 7373 756d 6520 6f77 6e65 7273 6869 assume ownershi │ │ │ +0004e3c0: 7020 6f66 2074 6869 7320 6669 6c65 0a09 p of this file.. │ │ │ +0004e3d0: 0909 0909 6563 2e65 6320 3d20 6572 726f ....ec.ec = erro │ │ │ +0004e3e0: 7273 3a3a 6d69 736d 6174 6368 696e 675f rs::mismatching_ │ │ │ +0004e3f0: 6669 6c65 5f74 7970 653b 0a09 0909 0909 file_type;...... │ │ │ +0004e400: 6563 2e6f 7065 7261 7469 6f6e 203d 206f ec.operation = o │ │ │ +0004e410: 7065 7261 7469 6f6e 5f74 3a3a 6669 6c65 peration_t::file │ │ │ +0004e420: 5f73 7461 743b 0a09 0909 097d 0a09 0909 _stat;.....}.... │ │ │ +0004e430: 0965 6c73 6520 6966 2028 6465 636c 6172 .else if (declar │ │ │ +0004e440: 6564 5f73 796d 6c69 6e6b 290a 0909 0909 ed_symlink)..... │ │ │ +0004e450: 7b0a 0909 0909 092f 2f20 636f 7079 5f66 {......// copy_f │ │ │ +0004e460: 696c 6528 2920 776f 756c 6420 666f 6c6c ile() would foll │ │ │ +0004e470: 6f77 2074 6865 2073 796d 6c69 6e6b 2061 ow the symlink a │ │ │ +0004e480: 6e64 2063 6f70 7920 7768 6174 6576 6572 nd copy whatever │ │ │ +0004e490: 0a09 0909 0909 2f2f 2069 7420 706f 696e ......// it poin │ │ │ +0004e4a0: 7473 2074 6f2c 2069 6e73 7465 6164 206f ts to, instead o │ │ │ +0004e4b0: 6620 6d6f 7669 6e67 2074 6865 206c 696e f moving the lin │ │ │ +0004e4c0: 6b20 6974 7365 6c66 0a3c 2f70 7265 3e3c k itself.
    < │ │ │ +0004e4d0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +0004e500: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +0004e510: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/stora │ │ │ +0004e540: 6765 5f75 7469 6c73 2e63 7070 3a35 3832 ge_utils.cpp:582 │ │ │ +0004e550: 3c2f 613e 3c2f 7464 3e3c 7464 3e69 7420 it │ │ │ +0004e560: 776f 756c 6420 7365 656d 2072 6561 736f would seem reaso │ │ │ +0004e570: 6e61 626c 6520 746f 2c20 696e 7374 6561 nable to, instea │ │ │ +0004e580: 642c 2073 6574 2074 6865 2068 6176 655f d, set the have_ │ │ │ +0004e590: 7069 6563 6573 2062 6974 7320 666f 7220 pieces bits for │ │ │ +0004e5a0: 7468 6520 7069 6563 6573 2072 6570 7265 the pieces repre │ │ │ +0004e5b0: 7365 6e74 696e 6720 7468 6573 6520 6669 senting these fi │ │ │ +0004e5c0: 6c65 732c 2061 6e64 2072 6573 756d 6520 les, and resume │ │ │ +0004e5d0: 7769 7468 2074 6865 206e 6f72 6d61 6c20 with the normal │ │ │ +0004e5e0: 6c6f 6769 633c 2f74 643e 3c2f 7472 3e3c logic< │ │ │ +0004e5f0: 7472 2069 643d 2231 3836 2220 7374 796c tr id="186" styl │ │ │ +0004e600: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +0004e610: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +0004e620: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +0004e630: 6832 3e69 7420 776f 756c 6420 7365 656d h2>it would seem │ │ │ +0004e640: 2072 6561 736f 6e61 626c 6520 746f 2c20 reasonable to, │ │ │ +0004e650: 696e 7374 6561 642c 2073 6574 2074 6865 instead, set the │ │ │ +0004e660: 2068 6176 655f 7069 6563 6573 2062 6974 have_pieces bit │ │ │ +0004e670: 730a 666f 7220 7468 6520 7069 6563 6573 s.for the pieces │ │ │ +0004e680: 2072 6570 7265 7365 6e74 696e 6720 7468 representing th │ │ │ +0004e690: 6573 6520 6669 6c65 732c 2061 6e64 2072 ese files, and r │ │ │ +0004e6a0: 6573 756d 6520 7769 7468 2074 6865 206e esume with the n │ │ │ +0004e6b0: 6f72 6d61 6c0a 6c6f 6769 633c 2f68 323e ormal.logic

    │ │ │ +0004e6c0: 3c68 343e 2e2e 2f73 7263 2f73 746f 7261

    ../src/stora │ │ │ +0004e6d0: 6765 5f75 7469 6c73 2e63 7070 3a35 3832 ge_utils.cpp:582 │ │ │ +0004e6e0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +0004e720: 0909 0909 636f 6e74 696e 7565 3b0a 0a09  ....continue;...
    │ │ │ +0004e730: 0909 0973 7464 3a3a 696e 7436 345f 7420  ...std::int64_t 
    │ │ │ +0004e740: 636f 6e73 7420 7369 7a65 203d 2067 6574  const size = get
    │ │ │ +0004e750: 5f66 696c 6573 697a 6528 7374 6174 2c20  _filesize(stat, 
    │ │ │ +0004e760: 6669 6c65 5f69 6e64 6578 2c20 6673 0a09  file_index, fs..
    │ │ │ +0004e770: 0909 0909 2c20 7361 7665 5f70 6174 682c  ...., save_path,
    │ │ │ +0004e780: 2065 6329 3b0a 0909 0909 6966 2028 7369   ec);.....if (si
    │ │ │ +0004e790: 7a65 2026 6c74 3b20 3029 2072 6574 7572  ze < 0) retur
    │ │ │ +0004e7a0: 6e20 6661 6c73 653b 0a0a 0909 0909 6966  n false;......if
    │ │ │ +0004e7b0: 2028 7369 7a65 2026 6c74 3b20 6673 2e66   (size < fs.f
    │ │ │ +0004e7c0: 696c 655f 7369 7a65 2866 696c 655f 696e  ile_size(file_in
    │ │ │ +0004e7d0: 6465 7829 290a 0909 0909 7b0a 0909 0909  dex)).....{.....
    │ │ │ +0004e7e0: 0965 632e 6563 203d 2065 7272 6f72 733a  .ec.ec = errors:
    │ │ │ +0004e7f0: 3a6d 6973 6d61 7463 6869 6e67 5f66 696c  :mismatching_fil
    │ │ │ +0004e800: 655f 7369 7a65 3b0a 0909 0909 0965 632e  e_size;......ec.
    │ │ │ +0004e810: 6669 6c65 2866 696c 655f 696e 6465 7829  file(file_index)
    │ │ │ +0004e820: 3b0a 0909 0909 0965 632e 6f70 6572 6174  ;......ec.operat
    │ │ │ +0004e830: 696f 6e20 3d20 6f70 6572 6174 696f 6e5f  ion = operation_
    │ │ │ +0004e840: 743a 3a63 6865 636b 5f72 6573 756d 653b  t::check_resume;
    │ │ │ +0004e850: 0a09 0909 0909 7265 7475 726e 2066 616c  ......return fal
    │ │ │ +0004e860: 7365 3b0a 0909 0909 7d0a 0909 097d 0a09  se;.....}....}..
    │ │ │ +0004e870: 0909 7265 7475 726e 2074 7275 653b 0a09  ..return true;..
    │ │ │ +0004e880: 097d 0a0a 2369 666e 6465 6620 544f 5252  .}..#ifndef TORR
    │ │ │ +0004e890: 454e 545f 4449 5341 424c 455f 4d55 5441  ENT_DISABLE_MUTA
    │ │ │ +0004e8a0: 424c 455f 544f 5252 454e 5453 0a09 092f  BLE_TORRENTS.../
    │ │ │ +0004e8b0: 2f20 616c 7761 7973 2074 7269 6767 6572  / always trigger
    │ │ │ +0004e8c0: 2061 2066 756c 6c20 7265 6368 6563 6b20   a full recheck 
    │ │ │ +0004e8d0: 7768 656e 2077 6520 7075 6c6c 2069 6e20  when we pull in 
    │ │ │ +0004e8e0: 6669 6c65 7320 6672 6f6d 206f 7468 6572  files from other
    │ │ │ +0004e8f0: 0a09 092f 2f20 746f 7272 656e 7473 2c20  ...// torrents, 
    │ │ │ +0004e900: 7669 6120 6861 7264 206c 696e 6b73 0a3c  via hard links.<
    │ │ │ +0004e910: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +0004e920: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +0004e930: 7769 6474 683d 2231 3030 2522 3e09 0969  width="100%">..i
    │ │ │ +0004e940: 6620 2861 6464 6564 5f66 696c 6573 2920  f (added_files) 
    │ │ │ +0004e950: 7265 7475 726e 2066 616c 7365 3b0a 3c2f  return false;.#endif....//
    │ │ │ +0004e970: 2070 6172 7365 2068 6176 6520 6269 746d   parse have bitm
    │ │ │ +0004e980: 6173 6b2e 2056 6572 6966 7920 7468 6174  ask. Verify that
    │ │ │ +0004e990: 2066 696c 6573 2074 6f75 6368 6564 2062   files touched b
    │ │ │ +0004e9a0: 7920 636f 6d70 6c65 7465 6420 7069 6563  y completed piec
    │ │ │ +0004e9b0: 6573 0a09 092f 2f20 6163 7475 616c 6c79  es...// actually
    │ │ │ +0004e9c0: 2065 7869 7374 2e20 4120 636f 6d70 6c65   exist. A comple
    │ │ │ +0004e9d0: 7465 6420 7069 6563 6520 6d61 7920 7370  ted piece may sp
    │ │ │ +0004e9e0: 616e 206d 756c 7469 706c 6520 6669 6c65  an multiple file
    │ │ │ +0004e9f0: 732e 0a09 0966 6f72 2028 6669 6c65 5f69  s....for (file_i
    │ │ │ +0004ea00: 6e64 6578 5f74 2063 6f6e 7374 2066 696c  ndex_t const fil
    │ │ │ +0004ea10: 655f 696e 6465 7820 3a20 6673 2e66 696c  e_index : fs.fil
    │ │ │ +0004ea20: 655f 7261 6e67 6528 2929 0a09 097b 0a09  e_range())...{..
    │ │ │ +0004ea30: 0909 2f2f 2066 696c 6573 2077 6974 6820  ..// files with 
    │ │ │ +0004ea40: 7072 696f 7269 7479 207a 6572 6f20 6d61  priority zero ma
    │ │ │ +0004ea50: 7920 6e6f 7420 6861 7665 2062 6565 6e20  y not have been 
    │ │ │ +0004ea60: 7361 7665 6420 746f 2064 6973 6b20 6174  saved to disk at
    │ │ │ +0004ea70: 2074 6865 6972 0a09 0909 2f2f 2065 7870   their....// exp
    │ │ │ +0004ea80: 6563 7465 6420 6c6f 6361 7469 6f6e 2c20  ected location, 
    │ │ │ +0004ea90: 6275 7420 6973 206c 696b 656c 7920 746f  but is likely to
    │ │ │ +0004eaa0: 2062 6520 696e 2061 2070 6172 7466 696c   be in a partfil
    │ │ │ +0004eab0: 652e 204a 7573 7420 6578 656d 7074 2069  e. Just exempt i
    │ │ │ +0004eac0: 740a 0909 092f 2f20 6672 6f6d 2063 6865  t....// from che
    │ │ │ +0004ead0: 636b 696e 670a 0909 0969 6620 2866 696c  cking....if (fil
    │ │ │ +0004eae0: 655f 696e 6465 7820 266c 743b 2066 696c  e_index < fil
    │ │ │ +0004eaf0: 655f 7072 696f 7269 7479 2e65 6e64 5f69  e_priority.end_i
    │ │ │ +0004eb00: 6e64 6578 2829 0a09 0909 0926 616d 703b  ndex().....&
    │ │ │ +0004eb10: 2661 6d70 3b20 6669 6c65 5f70 7269 6f72  & file_prior
    │ │ │ +0004eb20: 6974 795b 6669 6c65 5f69 6e64 6578 5d20  ity[file_index] 
    │ │ │ +0004eb30: 3d3d 2064 6f6e 745f 646f 776e 6c6f 6164  == dont_download
    │ │ │ +0004eb40: 290a 0909 0909 636f 6e74 696e 7565 3b0a  ).....continue;.
    │ │ │ +0004eb50: 0a09 0909 6966 2028 6673 2e70 6164 5f66  ....if (fs.pad_f
    │ │ │ +0004eb60: 696c 655f 6174 2866 696c 655f 696e 6465  ile_at(file_inde
    │ │ │ +0004eb70: 7829 2920 636f 6e74 696e 7565 3b0a 0909  x)) continue;...
    │ │ │ +0004eb80: 0969 6620 2866 732e 6669 6c65 5f73 697a  .if (fs.file_siz
    │ │ │ +0004eb90: 6528 6669 6c65 5f69 6e64 6578 2920 3d3d  e(file_index) ==
    │ │ │ +0004eba0: 2030 2920 636f 6e74 696e 7565 3b0a 0a09   0) continue;...
    │ │ │ +0004ebb0: 0909 6175 746f 2063 6f6e 7374 2070 6965  ..auto const pie
    │ │ │ +0004ebc0: 6365 5f72 616e 6765 203d 2061 7578 3a3a  ce_range = aux::
    │ │ │ +0004ebd0: 6669 6c65 5f70 6965 6365 5f72 616e 6765  file_piece_range
    │ │ │ +0004ebe0: 5f69 6e63 6c75 7369 7665 2866 732c 2066  _inclusive(fs, f
    │ │ │ +0004ebf0: 696c 655f 696e 6465 7829 3b0a 0909 0970  ile_index);....p
    │ │ │ +0004ec00: 6965 6365 5f69 6e64 6578 5f74 2063 6f6e  iece_index_t con
    │ │ │ +0004ec10: 7374 2073 7461 7274 5f70 6965 6365 203d  st start_piece =
    │ │ │ +0004ec20: 2070 6965 6365 5f72 616e 6765 2e5f 6265   piece_range._be
    │ │ │ +0004ec30: 6769 6e3b 0a0a 0909 0970 6965 6365 5f69  gin;.....piece_i
    │ │ │ +0004ec40: 6e64 6578 5f74 2063 6f6e 7374 2065 6e64  ndex_t const end
    │ │ │ +0004ec50: 5f70 6965 6365 203d 2073 7464 3a3a 6d69  _piece = std::mi
    │ │ │ +0004ec60: 6e28 7069 6563 655f 7261 6e67 652e 5f65  n(piece_range._e
    │ │ │ +0004ec70: 6e64 2c20 7264 2e68 6176 655f 7069 6563  nd, rd.have_piec
    │ │ │ +0004ec80: 6573 2e65 6e64 5f69 6e64 6578 2829 293b  es.end_index());
    │ │ │ +0004ec90: 0a0a 0909 0962 6f6f 6c20 6861 735f 636f  .....bool has_co
    │ │ │ +0004eca0: 6d70 6c65 7465 645f 7265 7375 6d65 5f70  mpleted_resume_p
    │ │ │ +0004ecb0: 6965 6365 203d 2066 616c 7365 3b0a 0909  iece = false;...
    │ │ │ +0004ecc0: 0966 6f72 2028 7069 6563 655f 696e 6465  .for (piece_inde
    │ │ │ +0004ecd0: 785f 7420 7069 6563 6520 3d20 7374 6172  x_t piece = star
    │ │ │ +0004ece0: 745f 7069 6563 653b 2070 6965 6365 2026  t_piece; piece &
    │ │ │ +0004ecf0: 6c74 3b20 656e 645f 7069 6563 653b 202b  lt; end_piece; +
    │ │ │ +0004ed00: 2b70 6965 6365 290a 0909 097b 0a09 0909  +piece)....{....
    │ │ │ +0004ed10: 0969 6620 2821 7264 2e68 6176 655f 7069  .if (!rd.have_pi
    │ │ │ +0004ed20: 6563 6573 2e67 6574 5f62 6974 2870 6965  eces.get_bit(pie
    │ │ │ +0004ed30: 6365 2929 2063 6f6e 7469 6e75 653b 0a09  ce)) continue;..
    │ │ │ +0004ed40: 0909 0968 6173 5f63 6f6d 706c 6574 6564  ...has_completed
    │ │ │ +0004ed50: 5f72 6573 756d 655f 7069 6563 6520 3d20  _resume_piece = 
    │ │ │ +0004ed60: 7472 7565 3b0a 0909 0909 6272 6561 6b3b  true;.....break;
    │ │ │ +0004ed70: 0a09 0909 7d0a 0a09 0909 6966 2028 2168  ....}.....if (!h
    │ │ │ +0004ed80: 6173 5f63 6f6d 706c 6574 6564 5f72 6573  as_completed_res
    │ │ │ +0004ed90: 756d 655f 7069 6563 6529 2063 6f6e 7469  ume_piece) conti
    │ │ │ +0004eda0: 6e75 653b 0a3c 2f70 7265 3e3c 2f74 643e  nue;.
    │ │ │ +0004edb0: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +0004ede0: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +0004edf0: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +0004ee00: 7074 3a65 7870 616e 6428 3138 3729 223e pt:expand(187)"> │ │ │ +0004ee10: 2e2e 2f73 7263 2f65 6e75 6d5f 6e65 742e ../src/enum_net. │ │ │ +0004ee20: 6370 703a 3237 373c 2f61 3e3c 2f74 643e cpp:277 │ │ │ +0004ee30: 3c74 643e 6966 2077 6520 6765 7420 6865 if we get he │ │ │ +0004ee40: 7265 2c20 7468 6520 6361 6c6c 6572 2073 re, the caller s │ │ │ +0004ee50: 7469 6c6c 2061 7373 756d 6573 2074 6865 till assumes the │ │ │ +0004ee60: 2065 7272 6f72 2063 6f64 6520 6973 2072 error code is r │ │ │ +0004ee70: 6570 6f72 7465 6420 7669 6120 6572 726e eported via errn │ │ │ +0004ee80: 6f3c 2f74 643e 3c2f 7472 3e3c 7472 2069 o

    i │ │ │ +0004eed0: 6620 7765 2067 6574 2068 6572 652c 2074 f we get here, t │ │ │ +0004eee0: 6865 2063 616c 6c65 7220 7374 696c 6c20 he caller still │ │ │ +0004eef0: 6173 7375 6d65 7320 7468 6520 6572 726f assumes the erro │ │ │ +0004ef00: 7220 636f 6465 0a69 7320 7265 706f 7274 r code.is report │ │ │ +0004ef10: 6564 2076 6961 2065 7272 6e6f 3c2f 6832 ed via errno

    ../src/enum │ │ │ +0004ef30: 5f6e 6574 2e63 7070 3a32 3737 3c2f 6834 _net.cpp:277

    ...}.
    │ │ │ +0004ef80: 0909 0962 7566 2e72 6573 697a 6528 7374  ...buf.resize(st
    │ │ │ +0004ef90: 6174 6963 5f63 6173 7426 6c74 3b73 7464  atic_cast<std
    │ │ │ +0004efa0: 3a3a 7369 7a65 5f74 2667 743b 2870 6163  ::size_t>(pac
    │ │ │ +0004efb0: 6b65 745f 7369 7a65 2929 3b0a 0909 0969  ket_size));....i
    │ │ │ +0004efc0: 6e74 2072 6561 645f 6c65 6e3b 0a09 0909  nt read_len;....
    │ │ │ +0004efd0: 646f 0a09 0909 7b0a 0909 0909 7265 6164  do....{.....read
    │ │ │ +0004efe0: 5f6c 656e 203d 2069 6e74 2872 6563 7628  _len = int(recv(
    │ │ │ +0004eff0: 736f 636b 2c20 6275 662e 6461 7461 2829  sock, buf.data()
    │ │ │ +0004f000: 2c20 6275 662e 7369 7a65 2829 2c20 4d53  , buf.size(), MS
    │ │ │ +0004f010: 475f 5452 554e 4329 293b 0a09 0909 7d0a  G_TRUNC));....}.
    │ │ │ +0004f020: 0909 0977 6869 6c65 2028 7265 6164 5f6c  ...while (read_l
    │ │ │ +0004f030: 656e 2026 6c74 3b20 3020 2661 6d70 3b26  en < 0 &&
    │ │ │ +0004f040: 616d 703b 2065 7272 6e6f 203d 3d20 4549  amp; errno == EI
    │ │ │ +0004f050: 4e54 5229 3b0a 0909 0969 6620 2872 6561  NTR);....if (rea
    │ │ │ +0004f060: 645f 6c65 6e20 266c 743b 2030 2920 7265  d_len < 0) re
    │ │ │ +0004f070: 7475 726e 202d 313b 0a09 0909 6966 2028  turn -1;....if (
    │ │ │ +0004f080: 7265 6164 5f6c 656e 2021 3d20 7061 636b  read_len != pack
    │ │ │ +0004f090: 6574 5f73 697a 6529 0a09 0909 7b0a 0909  et_size)....{...
    │ │ │ +0004f0a0: 0909 6572 726e 6f20 3d20 454d 5347 5349  ..errno = EMSGSI
    │ │ │ +0004f0b0: 5a45 3b0a 0909 0909 7265 7475 726e 202d  ZE;.....return -
    │ │ │ +0004f0c0: 313b 0a09 0909 7d0a 0a09 0909 6175 746f  1;....}.....auto
    │ │ │ +0004f0d0: 2063 6f6e 7374 2a20 6e6c 5f68 6472 203d   const* nl_hdr =
    │ │ │ +0004f0e0: 2072 6569 6e74 6572 7072 6574 5f63 6173   reinterpret_cas
    │ │ │ +0004f0f0: 7426 6c74 3b6e 6c6d 7367 6864 7220 636f  t<nlmsghdr co
    │ │ │ +0004f100: 6e73 742a 2667 743b 2862 7566 2e64 6174  nst*>(buf.dat
    │ │ │ +0004f110: 6128 2929 3b0a 0909 0969 6e74 206c 656e  a());....int len
    │ │ │ +0004f120: 203d 2072 6561 645f 6c65 6e3b 0a0a 0909   = read_len;....
    │ │ │ +0004f130: 0966 6f72 2028 3b20 6c65 6e20 2667 743b  .for (; len >
    │ │ │ +0004f140: 2030 2026 616d 703b 2661 6d70 3b20 6175   0 && au
    │ │ │ +0004f150: 783a 3a6e 6c6d 7367 5f6f 6b28 6e6c 5f68  x::nlmsg_ok(nl_h
    │ │ │ +0004f160: 6472 2c20 6c65 6e29 3b20 6e6c 5f68 6472  dr, len); nl_hdr
    │ │ │ +0004f170: 203d 2061 7578 3a3a 6e6c 6d73 675f 6e65   = aux::nlmsg_ne
    │ │ │ +0004f180: 7874 286e 6c5f 6864 722c 206c 656e 2929  xt(nl_hdr, len))
    │ │ │ +0004f190: 0a09 0909 7b0a 3c64 6976 2073 7479 6c65  ....{.
    ....if ((aux │ │ │ +0004f1d0: 3a3a 6e6c 6d73 675f 6f6b 286e 6c5f 6864 ::nlmsg_ok(nl_hd │ │ │ +0004f1e0: 722c 2072 6561 645f 6c65 6e29 203d 3d20 r, read_len) == │ │ │ +0004f1f0: 3029 207c 7c20 286e 6c5f 6864 722d 2667 0) || (nl_hdr-&g │ │ │ +0004f200: 743b 6e6c 6d73 675f 7479 7065 203d 3d20 t;nlmsg_type == │ │ │ +0004f210: 4e4c 4d53 475f 4552 524f 5229 290a 3c2f NLMSG_ERROR))......return │ │ │ +0004f230: 2d31 3b0a 0909 0909 2f2f 2074 6869 7320 -1;.....// this │ │ │ +0004f240: 6675 6e63 7469 6f6e 2064 6f65 736e 2774 function doesn't │ │ │ +0004f250: 2068 616e 646c 6520 6d75 6c74 6970 6c65 handle multiple │ │ │ +0004f260: 2072 6571 7565 7374 7320 6174 2074 6865 requests at the │ │ │ +0004f270: 2073 616d 6520 7469 6d65 0a09 0909 092f same time...../ │ │ │ +0004f280: 2f20 736f 2072 6570 6f72 7420 616e 2065 / so report an e │ │ │ +0004f290: 7272 6f72 2069 6620 7468 6520 6d65 7373 rror if the mess │ │ │ +0004f2a0: 6167 6520 646f 6573 206e 6f74 2068 6176 age does not hav │ │ │ +0004f2b0: 6520 7468 6520 6578 7065 6374 6564 2073 e the expected s │ │ │ +0004f2c0: 6571 2061 6e64 2070 6964 0a3c 2f70 7265 eq and pid.
    rele │ │ │ +0004f300: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/enu │ │ │ +0004f340: 6d5f 6e65 742e 6370 703a 3238 333c 2f61 m_net.cpp:283if we │ │ │ +0004f360: 6765 7420 6865 7265 2c20 7468 6520 6361 get here, the ca │ │ │ +0004f370: 6c6c 6572 2073 7469 6c6c 2061 7373 756d ller still assum │ │ │ +0004f380: 6573 2074 6865 2065 7272 6f72 2063 6f64 es the error cod │ │ │ +0004f390: 6520 6973 2072 6570 6f72 7465 6420 7669 e is reported vi │ │ │ +0004f3a0: 6120 6572 726e 6f3c 2f74 643e 3c2f 7472 a errno

    if we get h │ │ │ +0004f400: 6572 652c 2074 6865 2063 616c 6c65 7220 ere, the caller │ │ │ +0004f410: 7374 696c 6c20 6173 7375 6d65 7320 7468 still assumes th │ │ │ +0004f420: 6520 6572 726f 7220 636f 6465 0a69 7320 e error code.is │ │ │ +0004f430: 7265 706f 7274 6564 2076 6961 2065 7272 reported via err │ │ │ +0004f440: 6e6f 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 no

    ../sr │ │ │ +0004f450: 632f 656e 756d 5f6e 6574 2e63 7070 3a32 c/enum_net.cpp:2 │ │ │ +0004f460: 3833 3c2f 6834 3e3c 7072 6520 7374 796c 83

    ...{.....read_l
    │ │ │ +0004f4b0: 656e 203d 2069 6e74 2872 6563 7628 736f  en = int(recv(so
    │ │ │ +0004f4c0: 636b 2c20 6275 662e 6461 7461 2829 2c20  ck, buf.data(), 
    │ │ │ +0004f4d0: 6275 662e 7369 7a65 2829 2c20 4d53 475f  buf.size(), MSG_
    │ │ │ +0004f4e0: 5452 554e 4329 293b 0a09 0909 7d0a 0909  TRUNC));....}...
    │ │ │ +0004f4f0: 0977 6869 6c65 2028 7265 6164 5f6c 656e  .while (read_len
    │ │ │ +0004f500: 2026 6c74 3b20 3020 2661 6d70 3b26 616d   < 0 &&am
    │ │ │ +0004f510: 703b 2065 7272 6e6f 203d 3d20 4549 4e54  p; errno == EINT
    │ │ │ +0004f520: 5229 3b0a 0909 0969 6620 2872 6561 645f  R);....if (read_
    │ │ │ +0004f530: 6c65 6e20 266c 743b 2030 2920 7265 7475  len < 0) retu
    │ │ │ +0004f540: 726e 202d 313b 0a09 0909 6966 2028 7265  rn -1;....if (re
    │ │ │ +0004f550: 6164 5f6c 656e 2021 3d20 7061 636b 6574  ad_len != packet
    │ │ │ +0004f560: 5f73 697a 6529 0a09 0909 7b0a 0909 0909  _size)....{.....
    │ │ │ +0004f570: 6572 726e 6f20 3d20 454d 5347 5349 5a45  errno = EMSGSIZE
    │ │ │ +0004f580: 3b0a 0909 0909 7265 7475 726e 202d 313b  ;.....return -1;
    │ │ │ +0004f590: 0a09 0909 7d0a 0a09 0909 6175 746f 2063  ....}.....auto c
    │ │ │ +0004f5a0: 6f6e 7374 2a20 6e6c 5f68 6472 203d 2072  onst* nl_hdr = r
    │ │ │ +0004f5b0: 6569 6e74 6572 7072 6574 5f63 6173 7426  einterpret_cast&
    │ │ │ +0004f5c0: 6c74 3b6e 6c6d 7367 6864 7220 636f 6e73  lt;nlmsghdr cons
    │ │ │ +0004f5d0: 742a 2667 743b 2862 7566 2e64 6174 6128  t*>(buf.data(
    │ │ │ +0004f5e0: 2929 3b0a 0909 0969 6e74 206c 656e 203d  ));....int len =
    │ │ │ +0004f5f0: 2072 6561 645f 6c65 6e3b 0a0a 0909 0966   read_len;.....f
    │ │ │ +0004f600: 6f72 2028 3b20 6c65 6e20 2667 743b 2030  or (; len > 0
    │ │ │ +0004f610: 2026 616d 703b 2661 6d70 3b20 6175 783a   && aux:
    │ │ │ +0004f620: 3a6e 6c6d 7367 5f6f 6b28 6e6c 5f68 6472  :nlmsg_ok(nl_hdr
    │ │ │ +0004f630: 2c20 6c65 6e29 3b20 6e6c 5f68 6472 203d  , len); nl_hdr =
    │ │ │ +0004f640: 2061 7578 3a3a 6e6c 6d73 675f 6e65 7874   aux::nlmsg_next
    │ │ │ +0004f650: 286e 6c5f 6864 722c 206c 656e 2929 0a09  (nl_hdr, len))..
    │ │ │ +0004f660: 0909 7b0a 0909 0909 6966 2028 2861 7578  ..{.....if ((aux
    │ │ │ +0004f670: 3a3a 6e6c 6d73 675f 6f6b 286e 6c5f 6864  ::nlmsg_ok(nl_hd
    │ │ │ +0004f680: 722c 2072 6561 645f 6c65 6e29 203d 3d20  r, read_len) == 
    │ │ │ +0004f690: 3029 207c 7c20 286e 6c5f 6864 722d 2667  0) || (nl_hdr-&g
    │ │ │ +0004f6a0: 743b 6e6c 6d73 675f 7479 7065 203d 3d20  t;nlmsg_type == 
    │ │ │ +0004f6b0: 4e4c 4d53 475f 4552 524f 5229 290a 0909  NLMSG_ERROR))...
    │ │ │ +0004f6c0: 0909 0972 6574 7572 6e20 2d31 3b0a 0909  ...return -1;...
    │ │ │ +0004f6d0: 0909 2f2f 2074 6869 7320 6675 6e63 7469  ..// this functi
    │ │ │ +0004f6e0: 6f6e 2064 6f65 736e 2774 2068 616e 646c  on doesn't handl
    │ │ │ +0004f6f0: 6520 6d75 6c74 6970 6c65 2072 6571 7565  e multiple reque
    │ │ │ +0004f700: 7374 7320 6174 2074 6865 2073 616d 6520  sts at the same 
    │ │ │ +0004f710: 7469 6d65 0a09 0909 092f 2f20 736f 2072  time.....// so r
    │ │ │ +0004f720: 6570 6f72 7420 616e 2065 7272 6f72 2069  eport an error i
    │ │ │ +0004f730: 6620 7468 6520 6d65 7373 6167 6520 646f  f the message do
    │ │ │ +0004f740: 6573 206e 6f74 2068 6176 6520 7468 6520  es not have the 
    │ │ │ +0004f750: 6578 7065 6374 6564 2073 6571 2061 6e64  expected seq and
    │ │ │ +0004f760: 2070 6964 0a3c 6469 7620 7374 796c 653d   pid.
    ....if (nl_hd │ │ │ +0004f7a0: 722d 2667 743b 6e6c 6d73 675f 7365 7120 r->nlmsg_seq │ │ │ +0004f7b0: 213d 2073 6571 207c 7c20 6e6c 5f68 6472 != seq || nl_hdr │ │ │ +0004f7c0: 2d26 6774 3b6e 6c6d 7367 5f70 6964 2021 ->nlmsg_pid ! │ │ │ +0004f7d0: 3d20 7069 6429 0a3c 2f64 6976 3e09 0909 = pid).
    ... │ │ │ +0004f7e0: 0909 7265 7475 726e 202d 313b 0a0a 0909 ..return -1;.... │ │ │ +0004f7f0: 0909 6966 2028 6e6c 5f68 6472 2d26 6774 ..if (nl_hdr-> │ │ │ +0004f800: 3b6e 6c6d 7367 5f74 7970 6520 3d3d 204e ;nlmsg_type == N │ │ │ +0004f810: 4c4d 5347 5f44 4f4e 4529 2072 6574 7572 LMSG_DONE) retur │ │ │ +0004f820: 6e20 303b 0a0a 0909 0909 6f6e 5f6d 7367 n 0;......on_msg │ │ │ +0004f830: 286e 6c5f 6864 7229 3b0a 0a09 0909 0969 (nl_hdr);......i │ │ │ +0004f840: 6620 2828 6e6c 5f68 6472 2d26 6774 3b6e f ((nl_hdr->n │ │ │ +0004f850: 6c6d 7367 5f66 6c61 6773 2026 616d 703b lmsg_flags & │ │ │ +0004f860: 204e 4c4d 5f46 5f4d 554c 5449 2920 3d3d NLM_F_MULTI) == │ │ │ +0004f870: 2030 2920 7265 7475 726e 2030 3b0a 0909 0) return 0;... │ │ │ +0004f880: 097d 0a09 097d 0a2f 2f09 0972 6574 7572 .}...}.//..retur │ │ │ +0004f890: 6e20 303b 0a09 7d0a 0a09 696e 7420 6e6c n 0;..}...int nl │ │ │ +0004f8a0: 5f64 756d 705f 7265 7175 6573 7428 696e _dump_request(in │ │ │ +0004f8b0: 7420 636f 6e73 7420 736f 636b 2c20 7374 t const sock, st │ │ │ +0004f8c0: 643a 3a75 696e 7433 325f 7420 636f 6e73 d::uint32_t cons │ │ │ +0004f8d0: 7420 7365 710a 0909 2c20 6e6c 6d73 6768 t seq..., nlmsgh │ │ │ +0004f8e0: 6472 2a20 636f 6e73 7420 7265 7175 6573 dr* const reques │ │ │ +0004f8f0: 745f 6d73 672c 2073 7464 3a3a 6675 6e63 t_msg, std::func │ │ │ +0004f900: 7469 6f6e 266c 743b 766f 6964 286e 6c6d tion<void(nlm │ │ │ +0004f910: 7367 6864 7220 636f 6e73 742a 2926 6774 sghdr const*)> │ │ │ +0004f920: 3b20 6f6e 5f6d 7367 290a 097b 0a09 0972 ; on_msg)..{...r │ │ │ +0004f930: 6571 7565 7374 5f6d 7367 2d26 6774 3b6e equest_msg->n │ │ │ +0004f940: 6c6d 7367 5f66 6c61 6773 203d 204e 4c4d lmsg_flags = NLM │ │ │ +0004f950: 5f46 5f44 554d 5020 7c20 4e4c 4d5f 465f _F_DUMP | NLM_F_ │ │ │ +0004f960: 5245 5155 4553 543b 0a09 0972 6571 7565 REQUEST;...reque │ │ │ +0004f970: 7374 5f6d 7367 2d26 6774 3b6e 6c6d 7367 st_msg->nlmsg │ │ │ +0004f980: 5f73 6571 203d 2073 6571 3b0a 0909 2f2f _seq = seq;...// │ │ │ +0004f990: 2069 6e20 7468 656f 7279 206e 6c6d 7367 in theory nlmsg │ │ │ +0004f9a0: 5f70 6964 2073 686f 756c 6420 6265 2073 _pid should be s │ │ │ +0004f9b0: 6574 2074 6f20 7468 6520 6e65 746c 696e et to the netlin │ │ │ +0004f9c0: 6b20 706f 7274 2049 4420 284e 4f54 2074 k port ID (NOT t │ │ │ +0004f9d0: 6865 2070 726f 6365 7373 2049 4429 0a09 he process ID).. │ │ │ +0004f9e0: 092f 2f20 6f66 2074 6865 2073 656e 6465 .// of the sende │ │ │ +0004f9f0: 722c 2062 7574 2074 6865 206b 6572 6e65 r, but the kerne │ │ │ +0004fa00: 6c20 6967 6e6f 7265 7320 7468 6973 2066 l ignores this f │ │ │ +0004fa10: 6965 6c64 2073 6f20 6974 2069 7320 7479 ield so it is ty │ │ │ +0004fa20: 7069 6361 6c6c 7920 7365 7420 746f 0a09 pically set to.. │ │ │ +0004fa30: 092f 2f20 7a65 726f 0a09 0972 6571 7565 .// zero...reque │ │ │ +0004fa40: 7374 5f6d 7367 2d26 6774 3b6e 6c6d 7367 st_msg->nlmsg │ │ │ +0004fa50: 5f70 6964 203d 2030 3b0a 0a09 0969 6620 _pid = 0;....if │ │ │ +0004fa60: 283a 3a73 656e 6428 736f 636b 2c20 7265 (::send(sock, re │ │ │ +0004fa70: 7175 6573 745f 6d73 672c 2072 6571 7565 quest_msg, reque │ │ │ +0004fa80: 7374 5f6d 7367 2d26 6774 3b6e 6c6d 7367 st_msg->nlmsg │ │ │ +0004fa90: 5f6c 656e 2c20 3029 2026 6c74 3b20 3029 _len, 0) < 0) │ │ │ +0004faa0: 0a09 0909 7265 7475 726e 202d 313b 0a0a ....return -1;.. │ │ │ +0004fab0: 0909 2f2f 2067 6574 2074 6865 2073 6f63 ..// get the soc │ │ │ +0004fac0: 6b65 7427 7320 706f 7274 2049 4420 736f ket's port ID so │ │ │ +0004fad0: 2074 6861 7420 7765 2063 616e 2076 6572 that we can ver │ │ │ +0004fae0: 6966 7920 6974 2069 6e20 7468 6520 7265 ify it in the re │ │ │ +0004faf0: 7370 6f6e 7365 0a09 0973 6f63 6b61 6464 sponse...sockadd │ │ │ +0004fb00: 725f 6e6c 2073 6f63 6b5f 6164 6472 3b0a r_nl sock_addr;. │ │ │ +0004fb10: 0909 736f 636b 6c65 6e5f 7420 736f 636b ..socklen_t sock │ │ │ +0004fb20: 5f61 6464 725f 6c65 6e20 3d20 7369 7a65 _addr_len = size │ │ │ +0004fb30: 6f66 2873 6f63 6b5f 6164 6472 293b 0a09 of(sock_addr);.. │ │ │ +0004fb40: 0969 6620 283a 3a67 6574 736f 636b 6e61 .if (::getsockna │ │ │ +0004fb50: 6d65 2873 6f63 6b2c 2072 6569 6e74 6572 me(sock, reinter │ │ │ +0004fb60: 7072 6574 5f63 6173 7426 6c74 3b73 6f63 pret_cast<soc │ │ │ +0004fb70: 6b61 6464 722a 2667 743b 2826 616d 703b kaddr*>(& │ │ │ +0004fb80: 736f 636b 5f61 6464 7229 2c20 2661 6d70 sock_addr), & │ │ │ +0004fb90: 3b73 6f63 6b5f 6164 6472 5f6c 656e 2920 ;sock_addr_len) │ │ │ +0004fba0: 266c 743b 2030 290a 0909 0972 6574 7572 < 0)....retur │ │ │ +0004fbb0: 6e20 2d31 3b0a 3c2f 7072 653e 3c2f 7464 n -1;.
    relevance │ │ │ +0004fbf0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +0004fc00: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/pread_di │ │ │ +0004fc30: 736b 5f69 6f2e 6370 703a 3735 323c 2f61 sk_io.cpp:752back-p │ │ │ +0004fc50: 7265 7373 7572 6520 2874 6865 2064 6973 ressure (the dis │ │ │ +0004fc60: 6b5f 6f62 7365 7276 6572 206f 2920 6973 k_observer o) is │ │ │ +0004fc70: 2064 726f 7070 6564 206f 6e20 7468 6520 dropped on the │ │ │ +0004fc80: 626c 6f63 6b65 6420 7061 7468 2e20 6173 blocked path. as │ │ │ +0004fc90: 796e 635f 7772 6974 6520 7265 7475 726e ync_write return │ │ │ +0004fca0: 7320 6661 6c73 6520 286b 6565 7020 7772 s false (keep wr │ │ │ +0004fcb0: 6974 696e 6729 2062 7574 2074 6865 2063 iting) but the c │ │ │ +0004fcc0: 6163 6865 2773 2062 6163 6b2d 7072 6573 ache's back-pres │ │ │ +0004fcd0: 7375 7265 2028 6472 6976 656e 206f 6666 sure (driven off │ │ │ +0004fce0: 206d 5f62 6c6f 636b 7329 2063 616e 2774 m_blocks) can't │ │ │ +0004fcf0: 2073 6565 2074 6865 2070 6172 6b65 6420 see the parked │ │ │ +0004fd00: 7772 6974 6573 2c20 736f 2061 206c 6f6e writes, so a lon │ │ │ +0004fd10: 672d 6c69 7665 6420 6665 6e63 6520 2865 g-lived fence (e │ │ │ +0004fd20: 2e67 2e20 6d6f 7665 5f73 746f 7261 6765 .g. move_storage │ │ │ +0004fd30: 2920 6f6e 2061 2062 7573 7920 746f 7272 ) on a busy torr │ │ │ +0004fd40: 656e 7420 6361 6e20 6772 6f77 206d 5f62 ent can grow m_b │ │ │ +0004fd50: 6c6f 636b 6564 5f6a 6f62 7320 756e 626f locked_jobs unbo │ │ │ +0004fd60: 756e 6465 642e 2043 6172 7279 2074 6865 unded. Carry the │ │ │ +0004fd70: 206f 6273 6572 7665 7220 7468 726f 7567 observer throug │ │ │ +0004fd80: 6820 746f 2074 6872 6f74 746c 6520 7468 h to throttle th │ │ │ +0004fd90: 6520 7065 6572 2077 6869 6c65 2069 7473 e peer while its │ │ │ +0004fda0: 2077 7269 7465 7320 6172 6520 7061 726b writes are park │ │ │ +0004fdb0: 6564 2e3c 2f74 643e 3c2f 7472 3e3c 7472 ed.

    back-pressure ( │ │ │ +0004fe10: 7468 6520 6469 736b 5f6f 6273 6572 7665 the disk_observe │ │ │ +0004fe20: 7220 6f29 2069 7320 6472 6f70 7065 6420 r o) is dropped │ │ │ +0004fe30: 6f6e 2074 6865 2062 6c6f 636b 6564 2070 on the blocked p │ │ │ +0004fe40: 6174 682e 0a61 7379 6e63 5f77 7269 7465 ath..async_write │ │ │ +0004fe50: 2072 6574 7572 6e73 2066 616c 7365 2028 returns false ( │ │ │ +0004fe60: 6b65 6570 2077 7269 7469 6e67 2920 6275 keep writing) bu │ │ │ +0004fe70: 7420 7468 6520 6361 6368 6527 7320 6261 t the cache's ba │ │ │ +0004fe80: 636b 2d70 7265 7373 7572 650a 2864 7269 ck-pressure.(dri │ │ │ +0004fe90: 7665 6e20 6f66 6620 6d5f 626c 6f63 6b73 ven off m_blocks │ │ │ +0004fea0: 2920 6361 6e27 7420 7365 6520 7468 6520 ) can't see the │ │ │ +0004feb0: 7061 726b 6564 2077 7269 7465 732c 2073 parked writes, s │ │ │ +0004fec0: 6f20 6120 6c6f 6e67 2d6c 6976 6564 2066 o a long-lived f │ │ │ +0004fed0: 656e 6365 0a28 652e 672e 206d 6f76 655f ence.(e.g. move_ │ │ │ +0004fee0: 7374 6f72 6167 6529 206f 6e20 6120 6275 storage) on a bu │ │ │ +0004fef0: 7379 2074 6f72 7265 6e74 2063 616e 2067 sy torrent can g │ │ │ +0004ff00: 726f 7720 6d5f 626c 6f63 6b65 645f 6a6f row m_blocked_jo │ │ │ +0004ff10: 6273 2075 6e62 6f75 6e64 6564 2e0a 4361 bs unbounded..Ca │ │ │ +0004ff20: 7272 7920 7468 6520 6f62 7365 7276 6572 rry the observer │ │ │ +0004ff30: 2074 6872 6f75 6768 2074 6f20 7468 726f through to thro │ │ │ +0004ff40: 7474 6c65 2074 6865 2070 6565 7220 7768 ttle the peer wh │ │ │ +0004ff50: 696c 6520 6974 7320 7772 6974 6573 2061 ile its writes a │ │ │ +0004ff60: 7265 2070 6172 6b65 642e 3c2f 6832 3e3c re parked.

    < │ │ │ +0004ff70: 6834 3e2e 2e2f 7372 632f 7072 6561 645f h4>../src/pread_ │ │ │ +0004ff80: 6469 736b 5f69 6f2e 6370 703a 3735 323c disk_io.cpp:752< │ │ │ +0004ff90: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ./
    │ │ │ +0004ffd0: 2f20 7374 6f72 6167 6527 7320 6f75 7473  / storage's outs
    │ │ │ +0004ffe0: 7461 6e64 696e 672d 6a6f 6220 636f 756e  tanding-job coun
    │ │ │ +0004fff0: 742e 2069 735f 626c 6f63 6b65 6428 2920  t. is_blocked() 
    │ │ │ +00050000: 6861 7320 6e6f 7420 7275 6e2c 2073 6f20  has not run, so 
    │ │ │ +00050010: 6a20 6973 206e 6f74 0a09 2f2f 2069 6e5f  j is not..// in_
    │ │ │ +00050020: 7072 6f67 7265 7373 2061 6e64 206d 7573  progress and mus
    │ │ │ +00050030: 7420 6e6f 7420 6265 206a 6f62 5f63 6f6d  t not be job_com
    │ │ │ +00050040: 706c 6574 6528 2964 202d 2d20 6162 6f72  plete()d -- abor
    │ │ │ +00050050: 7420 6974 2064 6972 6563 746c 792e 0a09  t it directly...
    │ │ │ +00050060: 6966 2028 6d5f 6162 6f72 7429 0a09 7b0a  if (m_abort)..{.
    │ │ │ +00050070: 0909 6d5f 636f 6d70 6c65 7465 645f 6a6f  ..m_completed_jo
    │ │ │ +00050080: 6273 2e61 626f 7274 5f6a 6f62 286d 5f69  bs.abort_job(m_i
    │ │ │ +00050090: 6f73 2c20 6a29 3b0a 0909 7265 7475 726e  os, j);...return
    │ │ │ +000500a0: 2066 616c 7365 3b0a 097d 0a0a 092f 2f20   false;..}...// 
    │ │ │ +000500b0: 6120 7772 6974 6520 636f 756e 7473 2061  a write counts a
    │ │ │ +000500c0: 7320 616e 206f 7574 7374 616e 6469 6e67  s an outstanding
    │ │ │ +000500d0: 206a 6f62 206f 6e20 7468 6520 7374 6f72   job on the stor
    │ │ │ +000500e0: 6167 6520 286c 696b 6520 6120 7265 6164  age (like a read
    │ │ │ +000500f0: 206f 7220 6861 7368 292c 0a09 2f2f 2073   or hash),..// s
    │ │ │ +00050100: 6f20 6120 6665 6e63 6520 7761 6974 7320  o a fence waits 
    │ │ │ +00050110: 666f 7220 6275 6666 6572 6564 2077 7269  for buffered wri
    │ │ │ +00050120: 7465 7320 616e 6420 7468 6569 7220 696e  tes and their in
    │ │ │ +00050130: 2d66 6c69 6768 7420 666c 7573 6820 6265  -flight flush be
    │ │ │ +00050140: 666f 7265 2069 740a 092f 2f20 7275 6e73  fore it..// runs
    │ │ │ +00050150: 2c20 7261 7468 6572 2074 6861 6e20 7465  , rather than te
    │ │ │ +00050160: 6172 696e 6720 7468 6520 7374 6f72 6167  aring the storag
    │ │ │ +00050170: 6520 646f 776e 2075 6e64 6572 2061 2066  e down under a f
    │ │ │ +00050180: 6c75 7368 2e20 5468 6973 2064 6f65 7320  lush. This does 
    │ │ │ +00050190: 6e6f 740a 092f 2f20 6465 6164 6c6f 636b  not..// deadlock
    │ │ │ +000501a0: 2074 6865 2066 656e 6365 3a20 6164 645f   the fence: add_
    │ │ │ +000501b0: 6665 6e63 655f 6a6f 6228 2920 6861 6e64  fence_job() hand
    │ │ │ +000501c0: 7320 6120 7374 6f72 6167 6520 7769 7468  s a storage with
    │ │ │ +000501d0: 206f 7574 7374 616e 6469 6e67 2077 7269   outstanding wri
    │ │ │ +000501e0: 7465 730a 092f 2f20 746f 2061 2067 656e  tes..// to a gen
    │ │ │ +000501f0: 6572 6963 2074 6872 6561 6420 746f 2066  eric thread to f
    │ │ │ +00050200: 6c75 7368 2c20 6472 6169 6e69 6e67 2074  lush, draining t
    │ │ │ +00050210: 6865 2077 7269 7465 7320 7468 6520 6665  he writes the fe
    │ │ │ +00050220: 6e63 6520 7761 6974 7320 6f6e 2e0a 092f  nce waits on.../
    │ │ │ +00050230: 2f0a 092f 2f20 7768 656e 2061 2066 656e  /..// when a fen
    │ │ │ +00050240: 6365 2069 7320 7570 2c20 6973 5f62 6c6f  ce is up, is_blo
    │ │ │ +00050250: 636b 6564 2829 2070 6172 6b73 2074 6865  cked() parks the
    │ │ │ +00050260: 206a 6f62 2069 6e20 7468 6520 6665 6e63   job in the fenc
    │ │ │ +00050270: 6527 7320 626c 6f63 6b65 6420 7175 6575  e's blocked queu
    │ │ │ +00050280: 650a 092f 2f20 746f 2062 6520 7265 706f  e..// to be repo
    │ │ │ +00050290: 7374 6564 2069 6e74 6f20 7468 6520 6361  sted into the ca
    │ │ │ +000502a0: 6368 6520 6f6e 6365 2074 6865 2066 656e  che once the fen
    │ │ │ +000502b0: 6365 206c 6f77 6572 7320 2861 6464 5f63  ce lowers (add_c
    │ │ │ +000502c0: 6f6d 706c 6574 6564 5f6a 6f62 735f 696d  ompleted_jobs_im
    │ │ │ +000502d0: 706c 292e 0a09 2f2f 2049 6e73 6572 7469  pl)...// Inserti
    │ │ │ +000502e0: 6e67 206e 6f77 2077 6f75 6c64 2072 6163  ng now would rac
    │ │ │ +000502f0: 6520 7465 6172 646f 776e 3a20 666f 7220  e teardown: for 
    │ │ │ +00050300: 636c 6561 725f 7069 6563 6520 7468 6520  clear_piece the 
    │ │ │ +00050310: 6370 6520 6973 2061 626f 7574 2074 6f20  cpe is about to 
    │ │ │ +00050320: 6265 0a09 2f2f 2072 6573 6574 2c20 666f  be..// reset, fo
    │ │ │ +00050330: 7220 7374 6f72 6167 652d 7769 6465 2066  r storage-wide f
    │ │ │ +00050340: 656e 6365 7320 7468 6520 7374 6f72 6167  ences the storag
    │ │ │ +00050350: 6520 6973 2061 626f 7574 2074 6f20 676f  e is about to go
    │ │ │ +00050360: 2061 7761 792e 2050 6172 6b69 6e67 0a09   away. Parking..
    │ │ │ +00050370: 2f2f 206b 6565 7073 2074 6865 2062 6c6f  // keeps the blo
    │ │ │ +00050380: 636b 2022 7772 6974 696e 6722 2069 6e20  ck "writing" in 
    │ │ │ +00050390: 7468 6520 7069 636b 6572 2773 2076 6965  the picker's vie
    │ │ │ +000503a0: 772c 2073 6f20 7468 6520 7069 6563 6520  w, so the piece 
    │ │ │ +000503b0: 6973 6e27 7420 7265 706f 7274 6564 0a09  isn't reported..
    │ │ │ +000503c0: 2f2f 2066 696e 6973 6865 6420 616e 6420  // finished and 
    │ │ │ +000503d0: 6974 7320 6861 7368 2069 736e 2774 2072  its hash isn't r
    │ │ │ +000503e0: 6571 7565 7374 6564 2062 6566 6f72 6520  equested before 
    │ │ │ +000503f0: 7468 6520 626c 6f63 6b20 6861 7320 6265  the block has be
    │ │ │ +00050400: 656e 2069 6e73 6572 7465 642e 0a3c 6469  en inserted...if (
    │ │ │ +00050440: 6a2d 2667 743b 7374 6f72 6167 652d 2667  j->storage-&g
    │ │ │ +00050450: 743b 6973 5f62 6c6f 636b 6564 286a 2c20  t;is_blocked(j, 
    │ │ │ +00050460: 6d5f 7374 6174 735f 636f 756e 7465 7273  m_stats_counters
    │ │ │ +00050470: 2929 0a3c 2f64 6976 3e09 7b0a 0909 7265  )).

    .{...re │ │ │ +00050480: 7475 726e 2066 616c 7365 3b0a 097d 0a0a turn false;..}.. │ │ │ +00050490: 092f 2f20 6973 5f62 6c6f 636b 6564 2829 .// is_blocked() │ │ │ +000504a0: 206d 6172 6b65 6420 6a20 696e 5f70 726f marked j in_pro │ │ │ +000504b0: 6772 6573 7320 616e 6420 636f 756e 7465 gress and counte │ │ │ +000504c0: 6420 6974 2061 7320 6f75 7473 7461 6e64 d it as outstand │ │ │ +000504d0: 696e 672e 0a09 626f 6f6c 2063 6f6e 7374 ing...bool const │ │ │ +000504e0: 2065 7863 6565 6465 6420 3d20 6164 645f exceeded = add_ │ │ │ +000504f0: 7772 6974 655f 746f 5f63 6163 6865 286a write_to_cache(j │ │ │ +00050500: 2c20 7374 643a 3a6d 6f76 6528 6f29 293b , std::move(o)); │ │ │ +00050510: 0a09 7363 6865 6475 6c65 5f66 6c75 7368 ..schedule_flush │ │ │ +00050520: 2829 3b0a 0972 6574 7572 6e20 6578 6365 ();..return exce │ │ │ +00050530: 6564 6564 3b0a 7d0a 0a61 7578 3a3a 696e eded;.}..aux::in │ │ │ +00050540: 7365 7274 5f72 6573 756c 745f 666c 6167 sert_result_flag │ │ │ +00050550: 7320 7072 6561 645f 6469 736b 5f69 6f3a s pread_disk_io: │ │ │ +00050560: 3a69 6e73 6572 745f 7772 6974 6528 0a09 :insert_write(.. │ │ │ +00050570: 6175 783a 3a70 7265 6164 5f64 6973 6b5f aux::pread_disk_ │ │ │ +00050580: 6a6f 622a 206a 2c20 7374 643a 3a73 6861 job* j, std::sha │ │ │ +00050590: 7265 645f 7074 7226 6c74 3b64 6973 6b5f red_ptr<disk_ │ │ │ +000505a0: 6f62 7365 7276 6572 2667 743b 206f 290a observer> o). │ │ │ +000505b0: 7b0a 0961 7574 6f20 636f 6e73 7426 616d {..auto const&am │ │ │ +000505c0: 703b 2061 203d 2073 7464 3a3a 6765 7426 p; a = std::get& │ │ │ +000505d0: 6c74 3b61 7578 3a3a 6a6f 623a 3a77 7269 lt;aux::job::wri │ │ │ +000505e0: 7465 2667 743b 286a 2d26 6774 3b61 6374 te>(j->act │ │ │ +000505f0: 696f 6e29 3b0a 0970 6965 6365 5f69 6e64 ion);..piece_ind │ │ │ +00050600: 6578 5f74 2063 6f6e 7374 2070 6965 6365 ex_t const piece │ │ │ +00050610: 203d 2061 2e70 6965 6365 3b0a 0969 6e74 = a.piece;..int │ │ │ +00050620: 2063 6f6e 7374 206f 6666 7365 7420 3d20 const offset = │ │ │ +00050630: 612e 6f66 6673 6574 3b0a 0a09 444c 4f47 a.offset;...DLOG │ │ │ +00050640: 2822 6173 796e 635f 7772 6974 653a 2070 ("async_write: p │ │ │ +00050650: 6965 6365 3a20 2564 206f 6666 7365 743a iece: %d offset: │ │ │ +00050660: 2025 6420 666c 6167 733a 2025 785c 6e22 %d flags: %x\n" │ │ │ +00050670: 2c0a 0909 696e 7428 7069 6563 6529 2c0a ,...int(piece),. │ │ │ +00050680: 0909 696e 7428 6f66 6673 6574 292c 0a09 ..int(offset),.. │ │ │ +00050690: 0973 7461 7469 635f 6361 7374 266c 743b .static_cast< │ │ │ +000506a0: 7374 643a 3a75 696e 7438 5f74 2667 743b std::uint8_t> │ │ │ +000506b0: 286a 2d26 6774 3b66 6c61 6773 2929 3b0a (j->flags));. │ │ │ +000506c0: 0962 6f6f 6c20 636f 6e73 7420 666f 7263 .bool const forc │ │ │ +000506d0: 655f 666c 7573 6820 3d20 626f 6f6c 286a e_flush = bool(j │ │ │ +000506e0: 2d26 6774 3b66 6c61 6773 2026 616d 703b ->flags & │ │ │ +000506f0: 2066 6c75 7368 5f70 6965 6365 293b 0a09 flush_piece);.. │ │ │ +00050700: 6669 6c65 5f73 746f 7261 6765 2063 6f6e file_storage con │ │ │ +00050710: 7374 2661 6d70 3b20 6673 203d 206a 2d26 st& fs = j-& │ │ │ +00050720: 6774 3b73 746f 7261 6765 2d26 6774 3b66 gt;storage->f │ │ │ +00050730: 696c 6573 2829 3b0a 092f 2f20 696e 206f iles();..// in o │ │ │ +00050740: 7264 6572 2074 6f20 636f 6d70 7574 6520 rder to compute │ │ │ +00050750: 7631 2068 6173 6865 732c 2077 6520 6e65 v1 hashes, we ne │ │ │ +00050760: 6564 2074 6865 2066 756c 6c20 7069 6563 ed the full piec │ │ │ +00050770: 652c 2069 6e63 6c75 6469 6e67 2070 6164 e, including pad │ │ │ +00050780: 0a09 2f2f 2066 696c 6573 2e20 4576 656e ..// files. Even │ │ │ +00050790: 2074 686f 7567 6820 7632 2074 6f72 7265 though v2 torre │ │ │ +000507a0: 6e74 7320 6775 6172 616e 7465 6520 7468 nts guarantee th │ │ │ +000507b0: 6174 2074 6865 7920 6172 6520 7a65 726f at they are zero │ │ │ +000507c0: 2e0a 0969 6e74 2063 6f6e 7374 2070 6965 ...int const pie │ │ │ +000507d0: 6365 5f73 697a 6520 3d20 6a2d 2667 743b ce_size = j-> │ │ │ +000507e0: 7374 6f72 6167 652d 2667 743b 7631 2829 storage->v1() │ │ │ +000507f0: 203f 2066 732e 7069 6563 655f 7369 7a65 ? fs.piece_size │ │ │ +00050800: 2870 6965 6365 2920 3a20 6673 2e70 6965 (piece) : fs.pie │ │ │ +00050810: 6365 5f73 697a 6532 2870 6965 6365 293b ce_size2(piece); │ │ │ +00050820: 0a09 544f 5252 454e 545f 4153 5345 5254 ..TORRENT_ASSERT │ │ │ +00050830: 2861 2e62 7566 6665 725f 7369 7a65 203d (a.buffer_size = │ │ │ +00050840: 3d20 7374 643a 3a6d 696e 2870 6965 6365 = std::min(piece │ │ │ +00050850: 5f73 697a 6520 2d20 6f66 6673 6574 2c20 _size - offset, │ │ │ +00050860: 6465 6661 756c 745f 626c 6f63 6b5f 7369 default_block_si │ │ │ +00050870: 7a65 2929 3b0a 0961 7578 3a3a 6469 736b ze));..aux::disk │ │ │ +00050880: 5f63 6163 6865 3a3a 7069 6563 655f 656e _cache::piece_en │ │ │ +00050890: 7472 795f 7061 7261 6d73 2063 6f6e 7374 try_params const │ │ │ +000508a0: 2070 6965 6365 5f70 6172 616d 737b 0a09 piece_params{.. │ │ │ +000508b0: 0966 732e 7069 6563 655f 7369 7a65 3228 .fs.piece_size2( │ │ │ +000508c0: 7069 6563 6529 2c20 7069 6563 655f 7369 piece), piece_si │ │ │ +000508d0: 7a65 2c20 6a2d 2667 743b 7374 6f72 6167 ze, j->storag │ │ │ +000508e0: 652d 2667 743b 7631 2829 2c20 6a2d 2667 e->v1(), j-&g │ │ │ +000508f0: 743b 7374 6f72 6167 652d 2667 743b 7632 t;storage->v2 │ │ │ +00050900: 2829 2c20 6a2d 2667 743b 7374 6f72 6167 (), j->storag │ │ │ +00050910: 657d 3b0a 0972 6574 7572 6e20 6d5f 6361 e};..return m_ca │ │ │ +00050920: 6368 652e 696e 7365 7274 287b 6a2d 2667 che.insert({j-&g │ │ │ +00050930: 743b 7374 6f72 6167 652d 2667 743b 7374 t;storage->st │ │ │ +00050940: 6f72 6167 655f 696e 6465 7828 292c 2070 orage_index(), p │ │ │ +00050950: 6965 6365 7d2c 0a3c 2f70 7265 3e3c 2f74 iece},.relevanc │ │ │ +00050990: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/pread_d │ │ │ +000509d0: 6973 6b5f 696f 2e63 7070 3a39 3336 3c2f isk_io.cpp:936we ma │ │ │ +000509f0: 7920 6e6f 7420 6e65 6564 2074 6f20 646f y not need to do │ │ │ +00050a00: 2074 6869 732c 2074 6865 2063 6163 6865 this, the cache │ │ │ +00050a10: 2063 6f75 6c64 2074 656c 6c20 7573 2074 could tell us t │ │ │ +00050a20: 6869 7320 7069 6563 6520 7368 6f75 6c64 his piece should │ │ │ +00050a30: 2062 6520 666c 7573 6865 6420 746f 2064 be flushed to d │ │ │ +00050a40: 6973 6b20 6e6f 772e 3c2f 7464 3e3c 2f74 isk now.

    we may not │ │ │ +00050aa0: 206e 6565 6420 746f 2064 6f20 7468 6973 need to do this │ │ │ +00050ab0: 2c20 7468 6520 6361 6368 6520 636f 756c , the cache coul │ │ │ +00050ac0: 6420 7465 6c6c 2075 730a 7468 6973 2070 d tell us.this p │ │ │ +00050ad0: 6965 6365 2073 686f 756c 6420 6265 2066 iece should be f │ │ │ +00050ae0: 6c75 7368 6564 2074 6f20 6469 736b 206e lushed to disk n │ │ │ +00050af0: 6f77 2e3c 2f68 323e 3c68 343e 2e2e 2f73 ow.

    ../s │ │ │ +00050b00: 7263 2f70 7265 6164 5f64 6973 6b5f 696f rc/pread_disk_io │ │ │ +00050b10: 2e63 7070 3a39 3336 3c2f 6834 3e3c 7072 .cpp:936

    ...fill_p │ │ │ +00050b60: 7265 636f 6d70 7574 6564 5f76 3228 0a09 recomputed_v2(.. │ │ │ +00050b70: 0909 0961 2e62 6c6f 636b 5f68 6173 6865 ...a.block_hashe │ │ │ +00050b80: 732c 206a 2d26 6774 3b73 746f 7261 6765 s, j->storage │ │ │ +00050b90: 2d26 6774 3b74 616b 655f 7072 6563 6f6d ->take_precom │ │ │ +00050ba0: 7075 7465 645f 7632 2870 6965 6365 292c puted_v2(piece), │ │ │ +00050bb0: 2062 6c6f 636b 735f 696e 5f70 6965 6365 blocks_in_piece │ │ │ +00050bc0: 3229 3b0a 0a09 0909 666f 7220 2869 6e74 2);.....for (int │ │ │ +00050bd0: 2069 203d 2030 3b20 6920 266c 743b 2062 i = 0; i < b │ │ │ +00050be0: 6c6f 636b 735f 696e 5f70 6965 6365 323b locks_in_piece2; │ │ │ +00050bf0: 202b 2b69 290a 0909 097b 0a09 0909 0969 ++i)....{.....i │ │ │ +00050c00: 6620 2869 2026 6774 3b3d 2069 6e74 2861 f (i >= int(a │ │ │ +00050c10: 2e62 6c6f 636b 5f68 6173 6865 732e 7369 .block_hashes.si │ │ │ +00050c20: 7a65 2829 2920 7c7c 2061 2e62 6c6f 636b ze()) || a.block │ │ │ +00050c30: 5f68 6173 6865 735b 695d 2e69 735f 616c _hashes[i].is_al │ │ │ +00050c40: 6c5f 7a65 726f 7328 2929 0a09 0909 097b l_zeros()).....{ │ │ │ +00050c50: 0a09 0909 0909 6e65 6564 5f64 6973 6b5f ......need_disk_ │ │ │ +00050c60: 6661 6c6c 6261 636b 203d 2074 7275 653b fallback = true; │ │ │ +00050c70: 0a09 0909 0909 6272 6561 6b3b 0a09 0909 ......break;.... │ │ │ +00050c80: 097d 0a09 0909 7d0a 0909 7d0a 0a09 0969 .}....}...}....i │ │ │ +00050c90: 6620 286e 6565 645f 6469 736b 5f66 616c f (need_disk_fal │ │ │ +00050ca0: 6c62 6163 6b29 0a09 097b 0a09 0909 444c lback)...{....DL │ │ │ +00050cb0: 4f47 2822 6173 796e 635f 6861 7368 3a20 OG("async_hash: │ │ │ +00050cc0: 7632 2068 6173 6865 7320 696e 636f 6d70 v2 hashes incomp │ │ │ +00050cd0: 6c65 7465 2c20 6661 6c6c 696e 6720 6261 lete, falling ba │ │ │ +00050ce0: 636b 2074 6f20 646f 5f6a 6f62 2868 6173 ck to do_job(has │ │ │ +00050cf0: 6829 5c6e 2229 3b0a 0909 0961 6464 5f6a h)\n");....add_j │ │ │ +00050d00: 6f62 286a 293b 0a09 0909 7265 7475 726e ob(j);....return │ │ │ +00050d10: 3b0a 0909 7d0a 0a3c 6469 7620 7374 796c ;...}..
    ..m_generic │ │ │ +00050d50: 5f74 6872 6561 6473 2e69 6e74 6572 7275 _threads.interru │ │ │ +00050d60: 7074 2829 3b0a 3c2f 6469 763e 0a09 096a pt();.
    ...j │ │ │ +00050d70: 6f62 7175 6575 655f 7420 6a6f 6273 3b0a obqueue_t jobs;. │ │ │ +00050d80: 0909 6a6f 6273 2e70 7573 685f 6261 636b ..jobs.push_back │ │ │ +00050d90: 286a 293b 0a09 0961 6464 5f63 6f6d 706c (j);...add_compl │ │ │ +00050da0: 6574 6564 5f6a 6f62 7328 7374 643a 3a6d eted_jobs(std::m │ │ │ +00050db0: 6f76 6528 6a6f 6273 2929 3b0a 0909 7265 ove(jobs));...re │ │ │ +00050dc0: 7475 726e 3b0a 097d 0a0a 092f 2f20 496e turn;..}...// In │ │ │ +00050dd0: 2074 6869 7320 6361 7365 2074 6865 206a this case the j │ │ │ +00050de0: 6f62 2068 6173 2062 6565 6e20 7175 6575 ob has been queu │ │ │ +00050df0: 6564 206f 6e20 7468 6520 7069 6563 652c ed on the piece, │ │ │ +00050e00: 2061 6e64 2077 696c 6c20 6265 2070 6f73 and will be pos │ │ │ +00050e10: 7465 640a 092f 2f20 6f6e 6365 2074 6865 ted..// once the │ │ │ +00050e20: 2068 6173 6869 6e67 2063 6f6d 706c 6574 hashing complet │ │ │ +00050e30: 6573 0a09 6966 2028 7265 7420 3d3d 2061 es..if (ret == a │ │ │ +00050e40: 7578 3a3a 6469 736b 5f63 6163 6865 3a3a ux::disk_cache:: │ │ │ +00050e50: 6a6f 625f 7175 6575 6564 290a 0909 7265 job_queued)...re │ │ │ +00050e60: 7475 726e 3b0a 0a09 6164 645f 6a6f 6228 turn;...add_job( │ │ │ +00050e70: 6a29 3b0a 7d0a 0a76 6f69 6420 7072 6561 j);.}..void prea │ │ │ +00050e80: 645f 6469 736b 5f69 6f3a 3a61 7379 6e63 d_disk_io::async │ │ │ +00050e90: 5f68 6173 6832 2873 746f 7261 6765 5f69 _hash2(storage_i │ │ │ +00050ea0: 6e64 6578 5f74 2063 6f6e 7374 2073 746f ndex_t const sto │ │ │ +00050eb0: 7261 6765 0a09 2c20 7069 6563 655f 696e rage.., piece_in │ │ │ +00050ec0: 6465 785f 7420 636f 6e73 7420 7069 6563 dex_t const piec │ │ │ +00050ed0: 652c 2069 6e74 2063 6f6e 7374 206f 6666 e, int const off │ │ │ +00050ee0: 7365 742c 2064 6973 6b5f 6a6f 625f 666c set, disk_job_fl │ │ │ +00050ef0: 6167 735f 7420 636f 6e73 7420 666c 6167 ags_t const flag │ │ │ +00050f00: 730a 092c 2073 7464 3a3a 6675 6e63 7469 s.., std::functi │ │ │ +00050f10: 6f6e 266c 743b 766f 6964 2870 6965 6365 on<void(piece │ │ │ +00050f20: 5f69 6e64 6578 5f74 2c20 7368 6132 3536 _index_t, sha256 │ │ │ +00050f30: 5f68 6173 6820 636f 6e73 7426 616d 703b _hash const& │ │ │ +00050f40: 2c20 7374 6f72 6167 655f 6572 726f 7220 , storage_error │ │ │ +00050f50: 636f 6e73 7426 616d 703b 2926 6774 3b20 const&)> │ │ │ +00050f60: 6861 6e64 6c65 7229 0a7b 0a09 544f 5252 handler).{..TORR │ │ │ +00050f70: 454e 545f 4153 5345 5254 2876 616c 6964 ENT_ASSERT(valid │ │ │ +00050f80: 5f66 6c61 6773 2866 6c61 6773 2929 3b0a _flags(flags));. │ │ │ +00050f90: 0961 7578 3a3a 7072 6561 645f 6469 736b .aux::pread_disk │ │ │ +00050fa0: 5f6a 6f62 2a20 6a20 3d20 6d5f 6a6f 625f _job* j = m_job_ │ │ │ +00050fb0: 706f 6f6c 2e61 6c6c 6f63 6174 655f 6a6f pool.allocate_jo │ │ │ +00050fc0: 6226 6c74 3b61 7578 3a3a 6a6f 623a 3a68 b<aux::job::h │ │ │ +00050fd0: 6173 6832 2667 743b 280a 0909 666c 6167 ash2>(...flag │ │ │ +00050fe0: 732c 0a09 096d 5f74 6f72 7265 6e74 735b s,...m_torrents[ │ │ │ +00050ff0: 7374 6f72 6167 655d 2d26 6774 3b73 6861 storage]->sha │ │ │ +00051000: 7265 645f 6672 6f6d 5f74 6869 7328 292c red_from_this(), │ │ │ +00051010: 0a09 0973 7464 3a3a 6d6f 7665 2868 616e ...std::move(han │ │ │ +00051020: 646c 6572 292c 0a09 0970 6965 6365 2c0a dler),...piece,. │ │ │ +00051030: 0909 6f66 6673 6574 2c0a 0909 7368 6132 ..offset,...sha2 │ │ │ +00051040: 3536 5f68 6173 687b 7d0a 0929 3b0a 0a09 56_hash{}..);... │ │ │ +00051050: 2f2f 2049 6e20 7468 656f 7279 2c20 7765 // In theory, we │ │ │ +00051060: 2063 6f75 6c64 2063 6865 636b 2074 6865 could check the │ │ │ +00051070: 2063 6163 6865 2066 6f72 2074 6869 7320 cache for this │ │ │ +00051080: 626c 6f63 6b20 6861 7368 2c20 6275 7420 block hash, but │ │ │ +00051090: 7765 0a3c 2f70 7265 3e3c 2f74 643e 3c2f we. │ │ │ +000510c0: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +000510d0: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0
    .. │ │ │ +00051100: 2f73 7263 2f70 7265 6164 5f64 6973 6b5f /src/pread_disk_ │ │ │ +00051110: 696f 2e63 7070 3a31 3432 303c 2f61 3e3c io.cpp:1420< │ │ │ +00051120: 2f74 643e 3c74 643e 6d61 7962 6520 7765 /td>maybe we │ │ │ +00051130: 2064 6f6e 2774 206e 6565 6420 746f 2077 don't need to w │ │ │ +00051140: 7269 7465 2074 6f20 6669 6c65 7320 7765 rite to files we │ │ │ +00051150: 2772 6520 6162 6f75 7420 746f 2064 656c 're about to del │ │ │ +00051160: 6574 653c 2f74 643e 3c2f 7472 3e3c 7472 ete

    maybe we don't │ │ │ +000511c0: 6e65 6564 2074 6f20 7772 6974 6520 746f need to write to │ │ │ +000511d0: 2066 696c 6573 2077 6527 7265 2061 626f files we're abo │ │ │ +000511e0: 7574 2074 6f20 6465 6c65 7465 3c2f 6832 ut to delete

    ../src/prea │ │ │ +00051200: 645f 6469 736b 5f69 6f2e 6370 703a 3134 d_disk_io.cpp:14 │ │ │ +00051210: 3230 3c2f 6834 3e3c 7072 6520 7374 796c 20

    .a.path = std::
    │ │ │ +00051260: 6d6f 7665 2870 293b 0a09 7265 7475 726e  move(p);..return
    │ │ │ +00051270: 2072 6574 3b0a 7d0a 0a73 7461 7475 735f   ret;.}..status_
    │ │ │ +00051280: 7420 7072 6561 645f 6469 736b 5f69 6f3a  t pread_disk_io:
    │ │ │ +00051290: 3a64 6f5f 6a6f 6228 6175 783a 3a6a 6f62  :do_job(aux::job
    │ │ │ +000512a0: 3a3a 7265 6c65 6173 655f 6669 6c65 7326  ::release_files&
    │ │ │ +000512b0: 616d 703b 2c20 6175 783a 3a70 7265 6164  amp;, aux::pread
    │ │ │ +000512c0: 5f64 6973 6b5f 6a6f 622a 206a 290a 7b0a  _disk_job* j).{.
    │ │ │ +000512d0: 092f 2f20 6966 2074 6869 7320 6173 7365  .// if this asse
    │ │ │ +000512e0: 7274 2066 6169 6c73 2c20 736f 6d65 7468  rt fails, someth
    │ │ │ +000512f0: 696e 6727 7320 7772 6f6e 6720 7769 7468  ing's wrong with
    │ │ │ +00051300: 2074 6865 2066 656e 6365 206c 6f67 6963   the fence logic
    │ │ │ +00051310: 0a09 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ +00051320: 286a 2d26 6774 3b73 746f 7261 6765 2d26  (j->storage-&
    │ │ │ +00051330: 6774 3b6e 756d 5f6f 7574 7374 616e 6469  gt;num_outstandi
    │ │ │ +00051340: 6e67 5f6a 6f62 7328 2920 3d3d 2031 293b  ng_jobs() == 1);
    │ │ │ +00051350: 0a09 666c 7573 685f 7374 6f72 6167 6528  ..flush_storage(
    │ │ │ +00051360: 6a2d 2667 743b 7374 6f72 6167 6529 3b0a  j->storage);.
    │ │ │ +00051370: 096a 2d26 6774 3b73 746f 7261 6765 2d26  .j->storage-&
    │ │ │ +00051380: 6774 3b72 656c 6561 7365 5f66 696c 6573  gt;release_files
    │ │ │ +00051390: 286a 2d26 6774 3b65 7272 6f72 293b 0a09  (j->error);..
    │ │ │ +000513a0: 7265 7475 726e 206a 2d26 6774 3b65 7272  return j->err
    │ │ │ +000513b0: 6f72 203f 2064 6973 6b5f 7374 6174 7573  or ? disk_status
    │ │ │ +000513c0: 3a3a 6661 7461 6c5f 6469 736b 5f65 7272  ::fatal_disk_err
    │ │ │ +000513d0: 6f72 203a 2073 7461 7475 735f 747b 7d3b  or : status_t{};
    │ │ │ +000513e0: 0a7d 0a0a 7374 6174 7573 5f74 2070 7265  .}..status_t pre
    │ │ │ +000513f0: 6164 5f64 6973 6b5f 696f 3a3a 646f 5f6a  ad_disk_io::do_j
    │ │ │ +00051400: 6f62 2861 7578 3a3a 6a6f 623a 3a64 656c  ob(aux::job::del
    │ │ │ +00051410: 6574 655f 6669 6c65 7326 616d 703b 2061  ete_files& a
    │ │ │ +00051420: 2c20 6175 783a 3a70 7265 6164 5f64 6973  , aux::pread_dis
    │ │ │ +00051430: 6b5f 6a6f 622a 206a 290a 7b0a 0954 4f52  k_job* j).{..TOR
    │ │ │ +00051440: 5245 4e54 5f41 5353 4552 5428 612e 666c  RENT_ASSERT(a.fl
    │ │ │ +00051450: 6167 7329 3b0a 0a09 2f2f 2069 6620 7468  ags);...// if th
    │ │ │ +00051460: 6973 2061 7373 6572 7420 6661 696c 732c  is assert fails,
    │ │ │ +00051470: 2073 6f6d 6574 6869 6e67 2773 2077 726f   something's wro
    │ │ │ +00051480: 6e67 2077 6974 6820 7468 6520 6665 6e63  ng with the fenc
    │ │ │ +00051490: 6520 6c6f 6769 630a 0954 4f52 5245 4e54  e logic..TORRENT
    │ │ │ +000514a0: 5f41 5353 4552 5428 6a2d 2667 743b 7374  _ASSERT(j->st
    │ │ │ +000514b0: 6f72 6167 652d 2667 743b 6e75 6d5f 6f75  orage->num_ou
    │ │ │ +000514c0: 7473 7461 6e64 696e 675f 6a6f 6273 2829  tstanding_jobs()
    │ │ │ +000514d0: 203d 3d20 3129 3b0a 0a3c 6469 7620 7374   == 1);..
    .flush_st │ │ │ +00051510: 6f72 6167 6528 6a2d 2667 743b 7374 6f72 orage(j->stor │ │ │ +00051520: 6167 6529 3b0a 3c2f 6469 763e 0a09 6a2d age);.
    ..j- │ │ │ +00051530: 2667 743b 7374 6f72 6167 652d 2667 743b >storage-> │ │ │ +00051540: 6465 6c65 7465 5f66 696c 6573 2861 2e66 delete_files(a.f │ │ │ +00051550: 6c61 6773 2c20 6a2d 2667 743b 6572 726f lags, j->erro │ │ │ +00051560: 7229 3b0a 0972 6574 7572 6e20 6a2d 2667 r);..return j-&g │ │ │ +00051570: 743b 6572 726f 7220 3f20 6469 736b 5f73 t;error ? disk_s │ │ │ +00051580: 7461 7475 733a 3a66 6174 616c 5f64 6973 tatus::fatal_dis │ │ │ +00051590: 6b5f 6572 726f 7220 3a20 7374 6174 7573 k_error : status │ │ │ +000515a0: 5f74 7b7d 3b0a 7d0a 0a73 7461 7475 735f _t{};.}..status_ │ │ │ +000515b0: 7420 7072 6561 645f 6469 736b 5f69 6f3a t pread_disk_io: │ │ │ +000515c0: 3a64 6f5f 6a6f 6228 6175 783a 3a6a 6f62 :do_job(aux::job │ │ │ +000515d0: 3a3a 6368 6563 6b5f 6661 7374 7265 7375 ::check_fastresu │ │ │ +000515e0: 6d65 2661 6d70 3b20 612c 2061 7578 3a3a me& a, aux:: │ │ │ +000515f0: 7072 6561 645f 6469 736b 5f6a 6f62 2a20 pread_disk_job* │ │ │ +00051600: 6a29 0a7b 0a09 2f2f 2069 6620 7468 6973 j).{..// if this │ │ │ +00051610: 2061 7373 6572 7420 6661 696c 732c 2073 assert fails, s │ │ │ +00051620: 6f6d 6574 6869 6e67 2773 2077 726f 6e67 omething's wrong │ │ │ +00051630: 2077 6974 6820 7468 6520 6665 6e63 6520 with the fence │ │ │ +00051640: 6c6f 6769 630a 0954 4f52 5245 4e54 5f41 logic..TORRENT_A │ │ │ +00051650: 5353 4552 5428 6a2d 2667 743b 7374 6f72 SSERT(j->stor │ │ │ +00051660: 6167 652d 2667 743b 6e75 6d5f 6f75 7473 age->num_outs │ │ │ +00051670: 7461 6e64 696e 675f 6a6f 6273 2829 203d tanding_jobs() = │ │ │ +00051680: 3d20 3129 3b0a 0966 6c75 7368 5f73 746f = 1);..flush_sto │ │ │ +00051690: 7261 6765 286a 2d26 6774 3b73 746f 7261 rage(j->stora │ │ │ +000516a0: 6765 293b 0a09 6164 645f 746f 7272 656e ge);..add_torren │ │ │ +000516b0: 745f 7061 7261 6d73 2063 6f6e 7374 2a20 t_params const* │ │ │ +000516c0: 7264 203d 2061 2e72 6573 756d 655f 6461 rd = a.resume_da │ │ │ +000516d0: 7461 3b0a 0961 6464 5f74 6f72 7265 6e74 ta;..add_torrent │ │ │ +000516e0: 5f70 6172 616d 7320 746d 703b 0a09 6966 _params tmp;..if │ │ │ +000516f0: 2028 7264 203d 3d20 6e75 6c6c 7074 7229 (rd == nullptr) │ │ │ +00051700: 2072 6420 3d20 2661 6d70 3b74 6d70 3b0a rd = &tmp;. │ │ │ +00051710: 0a09 7374 643a 3a75 6e69 7175 655f 7074 ..std::unique_pt │ │ │ +00051720: 7226 6c74 3b61 7578 3a3a 7665 6374 6f72 r<aux::vector │ │ │ +00051730: 266c 743b 7374 643a 3a73 7472 696e 672c <std::string, │ │ │ +00051740: 2066 696c 655f 696e 6465 785f 7426 6774 file_index_t> │ │ │ +00051750: 3b26 6774 3b20 6c69 6e6b 7328 612e 6c69 ;> links(a.li │ │ │ +00051760: 6e6b 7329 3b0a 092f 2f20 6368 6563 6b20 nks);..// check │ │ │ +00051770: 6966 2074 6865 2066 6173 7472 6573 756d if the fastresum │ │ │ +00051780: 6520 6461 7461 2069 7320 7570 2074 6f20 e data is up to │ │ │ +00051790: 6461 7465 0a09 2f2f 2069 6620 6974 2069 date..// if it i │ │ │ +000517a0: 732c 2075 7365 2069 7420 616e 6420 7265 s, use it and re │ │ │ +000517b0: 7475 726e 2074 7275 652e 2049 6620 6974 turn true. If it │ │ │ +000517c0: 0a09 2f2f 2069 736e 2774 2072 6574 7572 ..// isn't retur │ │ │ +000517d0: 6e20 6661 6c73 6520 616e 6420 7468 6520 n false and the │ │ │ +000517e0: 6675 6c6c 2063 6865 636b 0a09 2f2f 2077 full check..// w │ │ │ +000517f0: 696c 6c20 6265 2072 756e 2e20 4966 2074 ill be run. If t │ │ │ +00051800: 6865 206c 696e 6b73 2070 6f69 6e74 6572 he links pointer │ │ │ +00051810: 2069 7320 6e6f 6e2d 656d 7074 792c 2069 is non-empty, i │ │ │ +00051820: 7420 6861 7320 7468 6520 7361 6d65 206e t has the same n │ │ │ +00051830: 756d 6265 720a 092f 2f20 6f66 2065 6c65 umber..// of ele │ │ │ +00051840: 6d65 6e74 7320 6173 2074 6865 7265 2061 ments as there a │ │ │ +00051850: 7265 2066 696c 6573 2e20 4561 6368 2065 re files. Each e │ │ │ +00051860: 6c65 6d65 6e74 2069 7320 6569 7468 6572 lement is either │ │ │ +00051870: 2065 6d70 7479 206f 7220 636f 6e74 6169 empty or contai │ │ │ +00051880: 6e73 0a09 2f2f 2074 6865 2061 6273 6f6c ns..// the absol │ │ │ +00051890: 7574 6520 7061 7468 2074 6f20 6120 6669 ute path to a fi │ │ │ +000518a0: 6c65 2069 6465 6e74 6963 616c 2074 6f20 le identical to │ │ │ +000518b0: 7468 6520 636f 7272 6573 706f 6e64 696e the correspondin │ │ │ +000518c0: 6720 6669 6c65 2069 6e20 7468 6973 0a09 g file in this.. │ │ │ +000518d0: 2f2f 2074 6f72 7265 6e74 2e20 5468 6520 // torrent. The │ │ │ +000518e0: 7374 6f72 6167 6520 6d75 7374 2063 7265 storage must cre │ │ │ +000518f0: 6174 6520 6861 7264 206c 696e 6b73 2028 ate hard links ( │ │ │ +00051900: 6f72 2063 6f70 7929 2074 686f 7365 2066 or copy) those f │ │ │ +00051910: 696c 6573 2e20 4966 0a09 2f2f 2061 6e79 iles. If..// any │ │ │ +00051920: 2066 696c 6520 646f 6573 206e 6f74 2065 file does not e │ │ │ +00051930: 7869 7374 206f 7220 6973 2069 6e61 6363 xist or is inacc │ │ │ +00051940: 6573 7369 626c 652c 2074 6865 2064 6973 essible, the dis │ │ │ +00051950: 6b20 6a6f 6220 6d75 7374 2066 6169 6c2e k job must fail. │ │ │ +00051960: 0a0a 0954 4f52 5245 4e54 5f41 5353 4552 ...TORRENT_ASSER │ │ │ +00051970: 5428 6a2d 2667 743b 7374 6f72 6167 652d T(j->storage- │ │ │ +00051980: 2667 743b 6669 6c65 7328 292e 7069 6563 >files().piec │ │ │ +00051990: 655f 6c65 6e67 7468 2829 2026 6774 3b20 e_length() > │ │ │ +000519a0: 3029 3b0a 0a09 2f2f 2061 6c77 6179 7320 0);...// always │ │ │ +000519b0: 696e 6974 6961 6c69 7a65 2074 6865 2073 initialize the s │ │ │ +000519c0: 746f 7261 6765 0a09 6175 746f 2063 6f6e torage..auto con │ │ │ +000519d0: 7374 2072 6574 5f66 6c61 6720 3d20 6a2d st ret_flag = j- │ │ │ +000519e0: 2667 743b 7374 6f72 6167 652d 2667 743b >storage-> │ │ │ +000519f0: 696e 6974 6961 6c69 7a65 286d 5f73 6574 initialize(m_set │ │ │ +00051a00: 7469 6e67 732c 206a 2d26 6774 3b65 7272 tings, j->err │ │ │ +00051a10: 6f72 293b 0a09 6966 2028 6a2d 2667 743b or);..if (j-> │ │ │ +00051a20: 6572 726f 7229 2072 6574 7572 6e20 6469 error) return di │ │ │ +00051a30: 736b 5f73 7461 7475 733a 3a66 6174 616c sk_status::fatal │ │ │ +00051a40: 5f64 6973 6b5f 6572 726f 7220 7c20 7265 _disk_error | re │ │ │ +00051a50: 745f 666c 6167 3b0a 0a3c 2f70 7265 3e3c t_flag;..
    < │ │ │ +00051a60: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00051a90: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +00051aa0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/posix │ │ │ +00051ad0: 5f70 6172 745f 6669 6c65 2e63 7070 3a33 _part_file.cpp:3 │ │ │ +00051ae0: 3136 3c2f 613e 3c2f 7464 3e3c 7464 3e77 16w │ │ │ +00051af0: 6861 7420 646f 2077 6520 646f 2069 6620 hat do we do if │ │ │ +00051b00: 736f 6d65 6f6e 6520 6973 2063 7572 7265 someone is curre │ │ │ +00051b10: 6e74 6c79 2072 6561 6469 6e67 2066 726f ntly reading fro │ │ │ +00051b20: 6d20 7468 6520 6469 736b 2066 726f 6d20 m the disk from │ │ │ +00051b30: 7468 6973 2070 6965 6365 3f20 646f 6573 this piece? does │ │ │ +00051b40: 2069 7420 6d61 7474 6572 3f20 5369 6e63 it matter? Sinc │ │ │ +00051b50: 6520 7765 2077 6f6e 2774 2061 6374 6976 e we won't activ │ │ │ +00051b60: 656c 7920 6572 6173 6520 7468 6520 6461 ely erase the da │ │ │ +00051b70: 7461 2066 726f 6d20 6469 736b 2c20 6275 ta from disk, bu │ │ │ +00051b80: 7420 6974 206d 6179 2062 6520 6f76 6572 t it may be over │ │ │ +00051b90: 7772 6974 7465 6e20 736f 6f6e 2c20 6974 written soon, it │ │ │ +00051ba0: 2773 2070 726f 6261 626c 7920 6e6f 7420 's probably not │ │ │ +00051bb0: 7468 6174 2062 6967 206f 6620 6120 6465 that big of a de │ │ │ +00051bc0: 616c 3c2f 7464 3e3c 2f74 723e 3c74 7220 al

    │ │ │ +00051c10: 7768 6174 2064 6f20 7765 2064 6f20 6966 what do we do if │ │ │ +00051c20: 2073 6f6d 656f 6e65 2069 7320 6375 7272 someone is curr │ │ │ +00051c30: 656e 746c 7920 7265 6164 696e 6720 6672 ently reading fr │ │ │ +00051c40: 6f6d 2074 6865 2064 6973 6b0a 6672 6f6d om the disk.from │ │ │ +00051c50: 2074 6869 7320 7069 6563 653f 2064 6f65 this piece? doe │ │ │ +00051c60: 7320 6974 206d 6174 7465 723f 2053 696e s it matter? Sin │ │ │ +00051c70: 6365 2077 6520 776f 6e27 7420 6163 7469 ce we won't acti │ │ │ +00051c80: 7665 6c79 2065 7261 7365 2074 6865 0a64 vely erase the.d │ │ │ +00051c90: 6174 6120 6672 6f6d 2064 6973 6b2c 2062 ata from disk, b │ │ │ +00051ca0: 7574 2069 7420 6d61 7920 6265 206f 7665 ut it may be ove │ │ │ +00051cb0: 7277 7269 7474 656e 2073 6f6f 6e2c 2069 rwritten soon, i │ │ │ +00051cc0: 7427 7320 7072 6f62 6162 6c79 206e 6f74 t's probably not │ │ │ +00051cd0: 2074 6861 740a 6269 6720 6f66 2061 2064 that.big of a d │ │ │ +00051ce0: 6561 6c3c 2f68 323e 3c68 343e 2e2e 2f73 eal

    ../s │ │ │ +00051cf0: 7263 2f70 6f73 6978 5f70 6172 745f 6669 rc/posix_part_fi │ │ │ +00051d00: 6c65 2e63 7070 3a33 3136 3c2f 6834 3e3c le.cpp:316

    < │ │ │ +00051d10: 7072 6520 7374 796c 653d 2262 6163 6b67 pre style="backg │ │ │ +00051d20: 726f 756e 643a 2023 6636 6636 6636 3b20 round: #f6f6f6; │ │ │ +00051d30: 626f 7264 6572 3a20 736f 6c69 6420 3170 border: solid 1p │ │ │ +00051d40: 7820 2364 6464 3b22 3e0a 0909 0969 6620 x #ddd;">....if │ │ │ +00051d50: 2865 6329 2072 6574 7572 6e20 7b7d 3b0a (ec) return {};. │ │ │ +00051d60: 0a23 6966 6465 6620 544f 5252 454e 545f .#ifdef TORRENT_ │ │ │ +00051d70: 5749 4e44 4f57 530a 0909 0972 6574 203d WINDOWS....ret = │ │ │ +00051d80: 2066 696c 655f 706f 696e 7465 7228 3a3a file_pointer(:: │ │ │ +00051d90: 5f77 666f 7065 6e28 636f 6e76 6572 745f _wfopen(convert_ │ │ │ +00051da0: 746f 5f6e 6174 6976 655f 7061 7468 5f73 to_native_path_s │ │ │ +00051db0: 7472 696e 6728 666e 292e 635f 7374 7228 tring(fn).c_str( │ │ │ +00051dc0: 292c 204c 2277 622b 2229 293b 0a23 656c ), L"wb+"));.#el │ │ │ +00051dd0: 7365 0a09 0909 7265 7420 3d20 6669 6c65 se....ret = file │ │ │ +00051de0: 5f70 6f69 6e74 6572 283a 3a66 6f70 656e _pointer(::fopen │ │ │ +00051df0: 2866 6e2e 635f 7374 7228 292c 2022 7762 (fn.c_str(), "wb │ │ │ +00051e00: 2b22 2929 3b0a 2365 6e64 6966 0a09 0909 +"));.#endif.... │ │ │ +00051e10: 6966 2028 7265 742e 6669 6c65 2829 203d if (ret.file() = │ │ │ +00051e20: 3d20 6e75 6c6c 7074 7229 0a09 0909 0965 = nullptr).....e │ │ │ +00051e30: 632e 6173 7369 676e 2865 7272 6e6f 2c20 c.assign(errno, │ │ │ +00051e40: 6765 6e65 7269 635f 6361 7465 676f 7279 generic_category │ │ │ +00051e50: 2829 293b 0a09 097d 0a09 0969 6620 2865 ());...}...if (e │ │ │ +00051e60: 6329 2072 6574 7572 6e20 7b7d 3b0a 0909 c) return {};... │ │ │ +00051e70: 7265 7475 726e 2072 6574 3b0a 097d 0a0a return ret;..}.. │ │ │ +00051e80: 0976 6f69 6420 706f 7369 785f 7061 7274 .void posix_part │ │ │ +00051e90: 5f66 696c 653a 3a66 7265 655f 7069 6563 _file::free_piec │ │ │ +00051ea0: 6528 7069 6563 655f 696e 6465 785f 7420 e(piece_index_t │ │ │ +00051eb0: 636f 6e73 7420 7069 6563 6529 0a09 7b0a const piece)..{. │ │ │ +00051ec0: 0909 6175 746f 2063 6f6e 7374 2069 203d ..auto const i = │ │ │ +00051ed0: 206d 5f70 6965 6365 5f6d 6170 2e66 696e m_piece_map.fin │ │ │ +00051ee0: 6428 7069 6563 6529 3b0a 0909 6966 2028 d(piece);...if ( │ │ │ +00051ef0: 6920 3d3d 206d 5f70 6965 6365 5f6d 6170 i == m_piece_map │ │ │ +00051f00: 2e65 6e64 2829 2920 7265 7475 726e 3b0a .end()) return;. │ │ │ +00051f10: 0a3c 6469 7620 7374 796c 653d 2262 6163 .
    . │ │ │ +00051f40: 3c2f 6469 763e 0909 6d5f 6672 6565 5f73
    ..m_free_s │ │ │ +00051f50: 6c6f 7473 2e70 7573 685f 6261 636b 2869 lots.push_back(i │ │ │ +00051f60: 2d26 6774 3b73 6563 6f6e 6429 3b0a 0909 ->second);... │ │ │ +00051f70: 6d5f 7069 6563 655f 6d61 702e 6572 6173 m_piece_map.eras │ │ │ +00051f80: 6528 6929 3b0a 0909 6d5f 6469 7274 795f e(i);...m_dirty_ │ │ │ +00051f90: 6d65 7461 6461 7461 203d 2074 7275 653b metadata = true; │ │ │ +00051fa0: 0a09 7d0a 0a09 766f 6964 2070 6f73 6978 ..}...void posix │ │ │ +00051fb0: 5f70 6172 745f 6669 6c65 3a3a 6d6f 7665 _part_file::move │ │ │ +00051fc0: 5f70 6172 7466 696c 6528 7374 643a 3a73 _partfile(std::s │ │ │ +00051fd0: 7472 696e 6720 636f 6e73 7426 616d 703b tring const& │ │ │ +00051fe0: 2070 6174 682c 2065 7272 6f72 5f63 6f64 path, error_cod │ │ │ +00051ff0: 6526 616d 703b 2065 6329 0a09 7b0a 0909 e& ec)..{... │ │ │ +00052000: 666c 7573 685f 6d65 7461 6461 7461 5f69 flush_metadata_i │ │ │ +00052010: 6d70 6c28 6563 293b 0a09 0969 6620 2865 mpl(ec);...if (e │ │ │ +00052020: 6329 2072 6574 7572 6e3b 0a0a 0909 6966 c) return;....if │ │ │ +00052030: 2028 216d 5f70 6965 6365 5f6d 6170 2e65 (!m_piece_map.e │ │ │ +00052040: 6d70 7479 2829 290a 0909 7b0a 0909 0973 mpty())...{....s │ │ │ +00052050: 7464 3a3a 7374 7269 6e67 206f 6c64 5f70 td::string old_p │ │ │ +00052060: 6174 6820 3d20 636f 6d62 696e 655f 7061 ath = combine_pa │ │ │ +00052070: 7468 286d 5f70 6174 682c 206d 5f6e 616d th(m_path, m_nam │ │ │ +00052080: 6529 3b0a 0909 0973 7464 3a3a 7374 7269 e);....std::stri │ │ │ +00052090: 6e67 206e 6577 5f70 6174 6820 3d20 636f ng new_path = co │ │ │ +000520a0: 6d62 696e 655f 7061 7468 2870 6174 682c mbine_path(path, │ │ │ +000520b0: 206d 5f6e 616d 6529 3b0a 0a09 0909 7265 m_name);.....re │ │ │ +000520c0: 6e61 6d65 286f 6c64 5f70 6174 682c 206e name(old_path, n │ │ │ +000520d0: 6577 5f70 6174 682c 2065 6329 3b0a 0909 ew_path, ec);... │ │ │ +000520e0: 0969 6620 2865 6320 3d3d 2062 6f6f 7374 .if (ec == boost │ │ │ +000520f0: 3a3a 7379 7374 656d 3a3a 6572 7263 3a3a ::system::errc:: │ │ │ +00052100: 6e6f 5f73 7563 685f 6669 6c65 5f6f 725f no_such_file_or_ │ │ │ +00052110: 6469 7265 6374 6f72 7929 0a09 0909 0965 directory).....e │ │ │ +00052120: 632e 636c 6561 7228 293b 0a0a 0909 0969 c.clear();.....i │ │ │ +00052130: 6620 2865 6329 0a09 0909 7b0a 0909 0909 f (ec)....{..... │ │ │ +00052140: 7374 6f72 6167 655f 6572 726f 7220 7365 storage_error se │ │ │ +00052150: 3b0a 0909 0909 6175 783a 3a63 6f70 795f ;.....aux::copy_ │ │ │ +00052160: 6669 6c65 286f 6c64 5f70 6174 682c 206e file(old_path, n │ │ │ +00052170: 6577 5f70 6174 682c 2073 6529 3b0a 0909 ew_path, se);... │ │ │ +00052180: 0909 6563 203d 2073 652e 6563 3b0a 0909 ..ec = se.ec;... │ │ │ +00052190: 0909 6966 2028 6563 2920 7265 7475 726e ..if (ec) return │ │ │ +000521a0: 3b0a 0909 0909 7265 6d6f 7665 286f 6c64 ;.....remove(old │ │ │ +000521b0: 5f70 6174 682c 2065 6329 3b0a 0909 097d _path, ec);....} │ │ │ +000521c0: 0a09 097d 0a09 096d 5f70 6174 6820 3d20 ...}...m_path = │ │ │ +000521d0: 7061 7468 3b0a 097d 0a3c 2f70 7265 3e3c path;..}.< │ │ │ +000521e0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00052210: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +00052220: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/posix │ │ │ +00052250: 5f70 6172 745f 6669 6c65 2e63 7070 3a34 _part_file.cpp:4 │ │ │ +00052260: 3038 3c2f 613e 3c2f 7464 3e3c 7464 3e69 08i │ │ │ +00052270: 6e73 7465 6164 206f 6620 7265 6275 696c nstead of rebuil │ │ │ +00052280: 6469 6e67 2074 6865 2077 686f 6c65 2066 ding the whole f │ │ │ +00052290: 696c 6520 6865 6164 6572 2061 6e64 2066 ile header and f │ │ │ +000522a0: 6c75 7368 696e 6720 6974 2c20 7570 6461 lushing it, upda │ │ │ +000522b0: 7465 2074 6865 2073 6c6f 7420 656e 7472 te the slot entr │ │ │ +000522c0: 6965 7320 6173 2077 6520 676f 3c2f 7464 ies as we go

    instea │ │ │ +00052320: 6420 6f66 2072 6562 7569 6c64 696e 6720 d of rebuilding │ │ │ +00052330: 7468 6520 7768 6f6c 6520 6669 6c65 2068 the whole file h │ │ │ +00052340: 6561 6465 720a 616e 6420 666c 7573 6869 eader.and flushi │ │ │ +00052350: 6e67 2069 742c 2075 7064 6174 6520 7468 ng it, update th │ │ │ +00052360: 6520 736c 6f74 2065 6e74 7269 6573 2061 e slot entries a │ │ │ +00052370: 7320 7765 2067 6f3c 2f68 323e 3c68 343e s we go

    │ │ │ +00052380: 2e2e 2f73 7263 2f70 6f73 6978 5f70 6172 ../src/posix_par │ │ │ +00052390: 745f 6669 6c65 2e63 7070 3a34 3038 3c2f t_file.cpp:408
    ...
    │ │ │ +000523e0: 0909 0965 632e 6173 7369 676e 2865 7272  ...ec.assign(err
    │ │ │ +000523f0: 6e6f 2c20 6765 6e65 7269 635f 6361 7465  no, generic_cate
    │ │ │ +00052400: 676f 7279 2829 293b 0a09 0909 0909 656c  gory());......el
    │ │ │ +00052410: 7365 0a09 0909 0909 0965 632e 6173 7369  se.......ec.assi
    │ │ │ +00052420: 676e 2865 7272 6f72 733a 3a66 696c 655f  gn(errors::file_
    │ │ │ +00052430: 746f 6f5f 7368 6f72 742c 206c 6962 746f  too_short, libto
    │ │ │ +00052440: 7272 656e 745f 6361 7465 676f 7279 2829  rrent_category()
    │ │ │ +00052450: 293b 0a09 0909 097d 0a0a 0909 0909 6966  );.....}......if
    │ │ │ +00052460: 2028 6563 2920 7265 7475 726e 3b0a 0a09   (ec) return;...
    │ │ │ +00052470: 0909 0966 2866 696c 655f 6f66 6673 6574  ...f(file_offset
    │ │ │ +00052480: 2c20 7b62 7566 2e67 6574 2829 2c20 626c  , {buf.get(), bl
    │ │ │ +00052490: 6f63 6b5f 746f 5f63 6f70 797d 293b 0a09  ock_to_copy});..
    │ │ │ +000524a0: 0909 7d0a 0909 0966 696c 655f 6f66 6673  ..}....file_offs
    │ │ │ +000524b0: 6574 202b 3d20 626c 6f63 6b5f 746f 5f63  et += block_to_c
    │ │ │ +000524c0: 6f70 793b 0a09 0909 7069 6563 655f 6f66  opy;....piece_of
    │ │ │ +000524d0: 6673 6574 203d 2030 3b0a 0909 0973 697a  fset = 0;....siz
    │ │ │ +000524e0: 6520 2d3d 2062 6c6f 636b 5f74 6f5f 636f  e -= block_to_co
    │ │ │ +000524f0: 7079 3b0a 0909 7d0a 097d 0a0a 0976 6f69  py;...}..}...voi
    │ │ │ +00052500: 6420 706f 7369 785f 7061 7274 5f66 696c  d posix_part_fil
    │ │ │ +00052510: 653a 3a66 6c75 7368 5f6d 6574 6164 6174  e::flush_metadat
    │ │ │ +00052520: 6128 6572 726f 725f 636f 6465 2661 6d70  a(error_code&
    │ │ │ +00052530: 3b20 6563 290a 097b 0a09 0966 6c75 7368  ; ec)..{...flush
    │ │ │ +00052540: 5f6d 6574 6164 6174 615f 696d 706c 2865  _metadata_impl(e
    │ │ │ +00052550: 6329 3b0a 097d 0a0a 3c64 6976 2073 7479  c);..}..
    .void posi │ │ │ +00052590: 785f 7061 7274 5f66 696c 653a 3a66 6c75 x_part_file::flu │ │ │ +000525a0: 7368 5f6d 6574 6164 6174 615f 696d 706c sh_metadata_impl │ │ │ +000525b0: 2865 7272 6f72 5f63 6f64 6526 616d 703b (error_code& │ │ │ +000525c0: 2065 6329 0a3c 2f64 6976 3e09 7b0a 0909 ec).
    .{... │ │ │ +000525d0: 2f2f 2064 6f20 7765 206e 6565 6420 746f // do we need to │ │ │ +000525e0: 2066 6c75 7368 2074 6865 206d 6574 6164 flush the metad │ │ │ +000525f0: 6174 613f 0a09 0969 6620 286d 5f64 6972 ata?...if (m_dir │ │ │ +00052600: 7479 5f6d 6574 6164 6174 6120 3d3d 2066 ty_metadata == f │ │ │ +00052610: 616c 7365 2920 7265 7475 726e 3b0a 0a09 alse) return;... │ │ │ +00052620: 0969 6620 286d 5f70 6965 6365 5f6d 6170 .if (m_piece_map │ │ │ +00052630: 2e65 6d70 7479 2829 290a 0909 7b0a 0909 .empty())...{... │ │ │ +00052640: 092f 2f20 6966 2077 6520 646f 6e27 7420 .// if we don't │ │ │ +00052650: 6861 7665 2061 6e79 2070 6965 6365 7320 have any pieces │ │ │ +00052660: 6c65 6674 2069 6e20 7468 650a 0909 092f left in the..../ │ │ │ +00052670: 2f20 7061 7274 2066 696c 652c 2072 656d / part file, rem │ │ │ +00052680: 6f76 6520 6974 0a09 0909 7374 643a 3a73 ove it....std::s │ │ │ +00052690: 7472 696e 6720 636f 6e73 7420 7020 3d20 tring const p = │ │ │ +000526a0: 636f 6d62 696e 655f 7061 7468 286d 5f70 combine_path(m_p │ │ │ +000526b0: 6174 682c 206d 5f6e 616d 6529 3b0a 0909 ath, m_name);... │ │ │ +000526c0: 0972 656d 6f76 6528 702c 2065 6329 3b0a .remove(p, ec);. │ │ │ +000526d0: 0a09 0909 6966 2028 6563 203d 3d20 626f ....if (ec == bo │ │ │ +000526e0: 6f73 743a 3a73 7973 7465 6d3a 3a65 7272 ost::system::err │ │ │ +000526f0: 633a 3a6e 6f5f 7375 6368 5f66 696c 655f c::no_such_file_ │ │ │ +00052700: 6f72 5f64 6972 6563 746f 7279 290a 0909 or_directory)... │ │ │ +00052710: 0909 6563 2e63 6c65 6172 2829 3b0a 0909 ..ec.clear();... │ │ │ +00052720: 0972 6574 7572 6e3b 0a09 097d 0a0a 0909 .return;...}.... │ │ │ +00052730: 6175 746f 2066 203d 206f 7065 6e5f 6669 auto f = open_fi │ │ │ +00052740: 6c65 286f 7065 6e5f 6d6f 6465 3a3a 7265 le(open_mode::re │ │ │ +00052750: 6164 5f77 7269 7465 2c20 6563 293b 0a09 ad_write, ec);.. │ │ │ +00052760: 0969 6620 2865 6329 2072 6574 7572 6e3b .if (ec) return; │ │ │ +00052770: 0a0a 0909 7374 643a 3a76 6563 746f 7226 ....std::vector& │ │ │ +00052780: 6c74 3b63 6861 7226 6774 3b20 6865 6164 lt;char> head │ │ │ +00052790: 6572 2873 7461 7469 635f 6361 7374 266c er(static_cast&l │ │ │ +000527a0: 743b 7374 643a 3a73 697a 655f 7426 6774 t;std::size_t> │ │ │ +000527b0: 3b28 6d5f 6865 6164 6572 5f73 697a 6529 ;(m_header_size) │ │ │ +000527c0: 293b 0a0a 0909 7573 696e 6720 6e61 6d65 );....using name │ │ │ +000527d0: 7370 6163 6520 6c69 6274 6f72 7265 6e74 space libtorrent │ │ │ +000527e0: 3a3a 6175 783b 0a0a 0909 6368 6172 2a20 ::aux;....char* │ │ │ +000527f0: 7074 7220 3d20 6865 6164 6572 2e64 6174 ptr = header.dat │ │ │ +00052800: 6128 293b 0a09 0977 7269 7465 5f75 696e a();...write_uin │ │ │ +00052810: 7433 3228 6d5f 6d61 785f 7069 6563 6573 t32(m_max_pieces │ │ │ +00052820: 2c20 7074 7229 3b0a 0909 7772 6974 655f , ptr);...write_ │ │ │ +00052830: 7569 6e74 3332 286d 5f70 6965 6365 5f73 uint32(m_piece_s │ │ │ +00052840: 697a 652c 2070 7472 293b 0a0a 0909 666f ize, ptr);....fo │ │ │ +00052850: 7220 2870 6965 6365 5f69 6e64 6578 5f74 r (piece_index_t │ │ │ +00052860: 2070 6965 6365 2830 293b 2070 6965 6365 piece(0); piece │ │ │ +00052870: 2026 6c74 3b20 7069 6563 655f 696e 6465 < piece_inde │ │ │ +00052880: 785f 7428 6d5f 6d61 785f 7069 6563 6573 x_t(m_max_pieces │ │ │ +00052890: 293b 202b 2b70 6965 6365 290a 0909 7b0a ); ++piece)...{. │ │ │ +000528a0: 0909 0961 7574 6f20 636f 6e73 7420 6920 ...auto const i │ │ │ +000528b0: 3d20 6d5f 7069 6563 655f 6d61 702e 6669 = m_piece_map.fi │ │ │ +000528c0: 6e64 2870 6965 6365 293b 0a3c 2f70 7265 nd(piece);.
    rele │ │ │ +00052900: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/tor │ │ │ +00052940: 7265 6e74 5f70 6565 722e 6370 703a 3136 rent_peer.cpp:16 │ │ │ +00052950: 373c 2f61 3e3c 2f74 643e 3c74 643e 686f 7ho │ │ │ +00052960: 7720 646f 2077 6520 6465 616c 2077 6974 w do we deal wit │ │ │ +00052970: 6820 6f75 7220 6578 7465 726e 616c 2061 h our external a │ │ │ +00052980: 6464 7265 7373 2063 6861 6e67 696e 673f ddress changing? │ │ │ +00052990: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    ho │ │ │ +000529e0: 7720 646f 2077 6520 6465 616c 2077 6974 w do we deal wit │ │ │ +000529f0: 6820 6f75 7220 6578 7465 726e 616c 2061 h our external a │ │ │ +00052a00: 6464 7265 7373 2063 6861 6e67 696e 673f ddress changing? │ │ │ +00052a10: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +00052a20: 746f 7272 656e 745f 7065 6572 2e63 7070 torrent_peer.cpp │ │ │ +00052a30: 3a31 3637 3c2f 6834 3e3c 7072 6520 7374 :167

    #endif..., is
    │ │ │ +00052a80: 5f76 365f 6164 6472 2866 616c 7365 290a  _v6_addr(false).
    │ │ │ +00052a90: 2369 6620 544f 5252 454e 545f 5553 455f  #if TORRENT_USE_
    │ │ │ +00052aa0: 4932 500a 0909 2c20 6973 5f69 3270 5f61  I2P..., is_i2p_a
    │ │ │ +00052ab0: 6464 7228 6661 6c73 6529 0a23 656e 6469  ddr(false).#endi
    │ │ │ +00052ac0: 660a 2369 6620 544f 5252 454e 545f 5553  f.#if TORRENT_US
    │ │ │ +00052ad0: 455f 5254 430a 0909 2c20 6973 5f72 7463  E_RTC..., is_rtc
    │ │ │ +00052ae0: 5f61 6464 7228 6661 6c73 6529 0a23 656e  _addr(false).#en
    │ │ │ +00052af0: 6469 660a 0909 2c20 6f6e 5f70 6172 6f6c  dif..., on_parol
    │ │ │ +00052b00: 6528 6661 6c73 6529 0a09 092c 2062 616e  e(false)..., ban
    │ │ │ +00052b10: 6e65 6428 6661 6c73 6529 0a09 092c 2073  ned(false)..., s
    │ │ │ +00052b20: 7570 706f 7274 735f 7574 7028 7472 7565  upports_utp(true
    │ │ │ +00052b30: 2920 2f2f 2061 7373 756d 6520 7065 6572  ) // assume peer
    │ │ │ +00052b40: 7320 7375 7070 6f72 7420 7574 700a 0909  s support utp...
    │ │ │ +00052b50: 2c20 636f 6e66 6972 6d65 645f 7375 7070  , confirmed_supp
    │ │ │ +00052b60: 6f72 7473 5f75 7470 2866 616c 7365 290a  orts_utp(false).
    │ │ │ +00052b70: 0909 2c20 7375 7070 6f72 7473 5f68 6f6c  .., supports_hol
    │ │ │ +00052b80: 6570 756e 6368 2866 616c 7365 290a 0909  epunch(false)...
    │ │ │ +00052b90: 2c20 7765 625f 7365 6564 2866 616c 7365  , web_seed(false
    │ │ │ +00052ba0: 290a 0909 2c20 7072 6f74 6f63 6f6c 5f76  )..., protocol_v
    │ │ │ +00052bb0: 3228 6661 6c73 6529 0a09 7b7d 0a0a 0973  2(false)..{}...s
    │ │ │ +00052bc0: 7464 3a3a 7569 6e74 3332 5f74 2074 6f72  td::uint32_t tor
    │ │ │ +00052bd0: 7265 6e74 5f70 6565 723a 3a72 616e 6b28  rent_peer::rank(
    │ │ │ +00052be0: 6175 783a 3a65 7874 6572 6e61 6c5f 6970  aux::external_ip
    │ │ │ +00052bf0: 2063 6f6e 7374 2661 6d70 3b20 6578 7465   const& exte
    │ │ │ +00052c00: 726e 616c 2c20 696e 7420 6578 7465 726e  rnal, int extern
    │ │ │ +00052c10: 616c 5f70 6f72 7429 2063 6f6e 7374 0a09  al_port) const..
    │ │ │ +00052c20: 7b0a 0909 544f 5252 454e 545f 4153 5345  {...TORRENT_ASSE
    │ │ │ +00052c30: 5254 2869 6e5f 7573 6529 3b0a 3c64 6976  RT(in_use);.
    ..if ( │ │ │ +00052c70: 7065 6572 5f72 616e 6b20 3d3d 2030 290a peer_rank == 0). │ │ │ +00052c80: 3c2f 6469 763e 0909 0970 6565 725f 7261
    ...peer_ra │ │ │ +00052c90: 6e6b 203d 2070 6565 725f 7072 696f 7269 nk = peer_priori │ │ │ +00052ca0: 7479 280a 0909 0909 7463 703a 3a65 6e64 ty(.....tcp::end │ │ │ +00052cb0: 706f 696e 7428 6578 7465 726e 616c 2e65 point(external.e │ │ │ +00052cc0: 7874 6572 6e61 6c5f 6164 6472 6573 7328 xternal_address( │ │ │ +00052cd0: 7468 6973 2d26 6774 3b61 6464 7265 7373 this->address │ │ │ +00052ce0: 2829 292c 2073 7464 3a3a 7569 6e74 3136 ()), std::uint16 │ │ │ +00052cf0: 5f74 2865 7874 6572 6e61 6c5f 706f 7274 _t(external_port │ │ │ +00052d00: 2929 0a09 0909 092c 2074 6370 3a3a 656e ))....., tcp::en │ │ │ +00052d10: 6470 6f69 6e74 2874 6869 732d 2667 743b dpoint(this-> │ │ │ +00052d20: 6164 6472 6573 7328 292c 2074 6869 732d address(), this- │ │ │ +00052d30: 2667 743b 706f 7274 2929 3b0a 0909 7265 >port));...re │ │ │ +00052d40: 7475 726e 2070 6565 725f 7261 6e6b 3b0a turn peer_rank;. │ │ │ +00052d50: 097d 0a0a 2369 666e 6465 6620 544f 5252 .}..#ifndef TORR │ │ │ +00052d60: 454e 545f 4449 5341 424c 455f 4c4f 4747 ENT_DISABLE_LOGG │ │ │ +00052d70: 494e 470a 0973 7464 3a3a 7374 7269 6e67 ING..std::string │ │ │ +00052d80: 2074 6f72 7265 6e74 5f70 6565 723a 3a74 torrent_peer::t │ │ │ +00052d90: 6f5f 7374 7269 6e67 2829 2063 6f6e 7374 o_string() const │ │ │ +00052da0: 0a09 7b0a 0909 544f 5252 454e 545f 4153 ..{...TORRENT_AS │ │ │ +00052db0: 5345 5254 2869 6e5f 7573 6529 3b0a 2369 SERT(in_use);.#i │ │ │ +00052dc0: 6620 544f 5252 454e 545f 5553 455f 4932 f TORRENT_USE_I2 │ │ │ +00052dd0: 500a 0909 6966 2028 6973 5f69 3270 5f61 P...if (is_i2p_a │ │ │ +00052de0: 6464 7229 2072 6574 7572 6e20 7374 643a ddr) return std: │ │ │ +00052df0: 3a73 7472 696e 6728 6465 7374 2829 293b :string(dest()); │ │ │ +00052e00: 0a23 656e 6469 660a 0909 7265 7475 726e .#endif...return │ │ │ +00052e10: 2061 6464 7265 7373 2829 2e74 6f5f 7374 address().to_st │ │ │ +00052e20: 7269 6e67 2829 3b0a 097d 0a23 656e 6469 ring();..}.#endi │ │ │ +00052e30: 660a 0a09 7374 643a 3a69 6e74 3634 5f74 f...std::int64_t │ │ │ +00052e40: 2074 6f72 7265 6e74 5f70 6565 723a 3a74 torrent_peer::t │ │ │ +00052e50: 6f74 616c 5f64 6f77 6e6c 6f61 6428 2920 otal_download() │ │ │ +00052e60: 636f 6e73 740a 097b 0a09 0954 4f52 5245 const..{...TORRE │ │ │ +00052e70: 4e54 5f41 5353 4552 5428 696e 5f75 7365 NT_ASSERT(in_use │ │ │ +00052e80: 293b 0a09 0969 6620 2863 6f6e 6e65 6374 );...if (connect │ │ │ +00052e90: 696f 6e20 213d 206e 756c 6c70 7472 290a ion != nullptr). │ │ │ +00052ea0: 0909 7b0a 0909 0954 4f52 5245 4e54 5f41 ..{....TORRENT_A │ │ │ +00052eb0: 5353 4552 5428 7072 6576 5f61 6d6f 756e SSERT(prev_amoun │ │ │ +00052ec0: 745f 646f 776e 6c6f 6164 203d 3d20 3029 t_download == 0) │ │ │ +00052ed0: 3b0a 0909 0972 6574 7572 6e20 636f 6e6e ;....return conn │ │ │ +00052ee0: 6563 7469 6f6e 2d26 6774 3b73 7461 7469 ection->stati │ │ │ +00052ef0: 7374 6963 7328 292e 746f 7461 6c5f 7061 stics().total_pa │ │ │ +00052f00: 796c 6f61 645f 646f 776e 6c6f 6164 2829 yload_download() │ │ │ +00052f10: 3b0a 0909 7d0a 0909 656c 7365 0a09 097b ;...}...else...{ │ │ │ +00052f20: 0a09 0909 7265 7475 726e 2073 7464 3a3a ....return std:: │ │ │ +00052f30: 696e 7436 345f 7428 7072 6576 5f61 6d6f int64_t(prev_amo │ │ │ +00052f40: 756e 745f 646f 776e 6c6f 6164 2920 2a20 unt_download) * │ │ │ +00052f50: 3130 3234 3b0a 0909 7d0a 097d 0a3c 2f70 1024;...}..}.

    re │ │ │ +00052f90: 6c65 7661 6e63 6526 6e62 7370 3b30 3c2f levance 0../src/m │ │ │ +00052fd0: 6167 6e65 745f 7572 692e 6370 703a 3432 agnet_uri.cpp:42 │ │ │ +00052fe0: 353c 2f61 3e3c 2f74 643e 3c74 643e 7768 5wh │ │ │ +00052ff0: 6174 2773 2074 6865 2072 6967 6874 206e at's the right n │ │ │ +00053000: 756d 6265 7220 6865 7265 3f3c 2f74 643e umber here? │ │ │ +00053010: 3c2f 7472 3e3c 7472 2069 643d 2231 3935

    what's │ │ │ +00053060: 7468 6520 7269 6768 7420 6e75 6d62 6572 the right number │ │ │ +00053070: 2068 6572 653f 3c2f 6832 3e3c 6834 3e2e here?

    . │ │ │ +00053080: 2e2f 7372 632f 6d61 676e 6574 5f75 7269 ./src/magnet_uri │ │ │ +00053090: 2e63 7070 3a34 3235 3c2f 6834 3e3c 7072 .cpp:425

    ...}....e │ │ │ +000530e0: 6c73 6520 6966 2028 6175 783a 3a73 7472 lse if (aux::str │ │ │ +000530f0: 696e 675f 6571 7561 6c5f 6e6f 5f63 6173 ing_equal_no_cas │ │ │ +00053100: 6528 6e61 6d65 2c20 2273 6f22 5f73 7629 e(name, "so"_sv) │ │ │ +00053110: 2920 2f2f 2073 656c 6563 742d 6f6e 6c79 ) // select-only │ │ │ +00053120: 2028 6669 6c65 7329 0a09 0909 7b0a 0909 (files)....{... │ │ │ +00053130: 0909 2f2f 2061 6363 6570 7420 6f6e 6c79 ..// accept only │ │ │ +00053140: 2064 6967 6974 732c 2027 2d27 2061 6e64 digits, '-' and │ │ │ +00053150: 2027 2c27 0a09 0909 0969 6620 2873 7464 ','.....if (std │ │ │ +00053160: 3a3a 616e 795f 6f66 2876 616c 7565 2e62 ::any_of(value.b │ │ │ +00053170: 6567 696e 2829 2c20 7661 6c75 652e 656e egin(), value.en │ │ │ +00053180: 6428 292c 205b 5d28 6368 6172 2063 290a d(), [](char c). │ │ │ +00053190: 0909 0909 097b 2072 6574 7572 6e20 2161 .....{ return !a │ │ │ +000531a0: 7578 3a3a 6973 5f64 6967 6974 2863 2920 ux::is_digit(c) │ │ │ +000531b0: 2661 6d70 3b26 616d 703b 2063 2021 3d20 && c != │ │ │ +000531c0: 272d 2720 2661 6d70 3b26 616d 703b 2063 '-' && c │ │ │ +000531d0: 2021 3d20 272c 273b 207d 2929 0a09 0909 != ','; })).... │ │ │ +000531e0: 0909 636f 6e74 696e 7565 3b0a 0a09 0909 ..continue;..... │ │ │ +000531f0: 092f 2f20 6d61 6b65 2073 7572 6520 616c .// make sure al │ │ │ +00053200: 6c20 6669 6c65 2070 7269 6f72 6974 6965 l file prioritie │ │ │ +00053210: 7320 6172 6520 7365 7420 746f 2030 2c20 s are set to 0, │ │ │ +00053220: 6578 6365 7074 2074 6865 206f 6e65 730a except the ones. │ │ │ +00053230: 0909 0909 2f2f 2077 6520 7370 6563 6966 ....// we specif │ │ │ +00053240: 7920 696e 2074 6865 2066 696c 655f 7072 y in the file_pr │ │ │ +00053250: 696f 7269 7469 6573 0a09 0909 0970 2e66 iorities.....p.f │ │ │ +00053260: 6c61 6773 207c 3d20 746f 7272 656e 745f lags |= torrent_ │ │ │ +00053270: 666c 6167 733a 3a64 6566 6175 6c74 5f64 flags::default_d │ │ │ +00053280: 6f6e 745f 646f 776e 6c6f 6164 3b0a 0a09 ont_download;... │ │ │ +00053290: 0909 0964 6f0a 0909 0909 7b0a 0909 0909 ...do.....{..... │ │ │ +000532a0: 0973 7472 696e 675f 7669 6577 2074 6f6b .string_view tok │ │ │ +000532b0: 656e 3b0a 0909 0909 0973 7464 3a3a 7469 en;......std::ti │ │ │ +000532c0: 6528 746f 6b65 6e2c 2076 616c 7565 2920 e(token, value) │ │ │ +000532d0: 3d20 6175 783a 3a73 706c 6974 5f73 7472 = aux::split_str │ │ │ +000532e0: 696e 6728 7661 6c75 652c 2027 2c27 293b ing(value, ','); │ │ │ +000532f0: 0a0a 0909 0909 0969 6620 2874 6f6b 656e .......if (token │ │ │ +00053300: 2e65 6d70 7479 2829 2920 636f 6e74 696e .empty()) contin │ │ │ +00053310: 7565 3b0a 0a09 0909 0909 696e 7420 6964 ue;.......int id │ │ │ +00053320: 7831 2c20 6964 7832 3b0a 3c64 6976 2073 x1, idx2;.
    .....con │ │ │ +00053360: 7374 6578 7072 2069 6e74 206d 6178 5f69 stexpr int max_i │ │ │ +00053370: 6e64 6578 203d 2031 3030 3030 3b20 2f2f ndex = 10000; // │ │ │ +00053380: 2063 616e 2774 2072 6973 6b20 6f75 7420 can't risk out │ │ │ +00053390: 6f66 206d 656d 6f72 790a 3c2f 6469 763e of memory.
    │ │ │ +000533a0: 0a09 0909 0909 6175 746f 2063 6f6e 7374 ......auto const │ │ │ +000533b0: 2064 6976 6964 6572 203d 2074 6f6b 656e divider = token │ │ │ +000533c0: 2e66 696e 645f 6669 7273 745f 6f66 2827 .find_first_of(' │ │ │ +000533d0: 2d27 293b 0a09 0909 0909 6966 2028 6469 -');......if (di │ │ │ +000533e0: 7669 6465 7220 213d 2073 7464 3a3a 7374 vider != std::st │ │ │ +000533f0: 7269 6e67 3a3a 6e70 6f73 2920 2f2f 2069 ring::npos) // i │ │ │ +00053400: 7427 7320 6120 7261 6e67 650a 0909 0909 t's a range..... │ │ │ +00053410: 097b 0a09 0909 0909 0969 6620 2864 6976 .{.......if (div │ │ │ +00053420: 6964 6572 203d 3d20 3029 202f 2f20 6e6f ider == 0) // no │ │ │ +00053430: 2073 7461 7274 2069 6e64 6578 0a09 0909 start index.... │ │ │ +00053440: 0909 0909 636f 6e74 696e 7565 3b0a 0909 ....continue;... │ │ │ +00053450: 0909 0909 6966 2028 6469 7669 6465 7220 ....if (divider │ │ │ +00053460: 3d3d 2074 6f6b 656e 2e73 697a 6528 2920 == token.size() │ │ │ +00053470: 2d20 3129 202f 2f20 6e6f 2065 6e64 2069 - 1) // no end i │ │ │ +00053480: 6e64 6578 0a09 0909 0909 0909 636f 6e74 ndex........cont │ │ │ +00053490: 696e 7565 3b0a 0a09 0909 0909 0961 7574 inue;........aut │ │ │ +000534a0: 6f20 636f 6e73 7420 6669 7273 7420 3d20 o const first = │ │ │ +000534b0: 6175 783a 3a70 6172 7365 5f64 6563 696d aux::parse_decim │ │ │ +000534c0: 616c 2874 6f6b 656e 2e73 7562 7374 7228 al(token.substr( │ │ │ +000534d0: 302c 2064 6976 6964 6572 2929 3b0a 0909 0, divider));... │ │ │ +000534e0: 0909 0909 6966 2028 2166 6972 7374 207c ....if (!first | │ │ │ +000534f0: 7c20 2a66 6972 7374 2026 6c74 3b20 3020 | *first < 0 │ │ │ +00053500: 7c7c 202a 6669 7273 7420 2667 743b 206d || *first > m │ │ │ +00053510: 6178 5f69 6e64 6578 2920 2f2f 2069 6e76 ax_index) // inv │ │ │ +00053520: 616c 6964 2069 6e64 6578 0a09 0909 0909 alid index...... │ │ │ +00053530: 0909 636f 6e74 696e 7565 3b0a 0909 0909 ..continue;..... │ │ │ +00053540: 0909 6175 746f 2063 6f6e 7374 206c 6173 ..auto const las │ │ │ +00053550: 7420 3d20 6175 783a 3a70 6172 7365 5f64 t = aux::parse_d │ │ │ +00053560: 6563 696d 616c 2874 6f6b 656e 2e73 7562 ecimal(token.sub │ │ │ +00053570: 7374 7228 6469 7669 6465 7220 2b20 3129 str(divider + 1) │ │ │ +00053580: 293b 0a09 0909 0909 0969 6620 2821 6c61 );.......if (!la │ │ │ +00053590: 7374 207c 7c20 2a6c 6173 7420 266c 743b st || *last < │ │ │ +000535a0: 2030 207c 7c20 2a6c 6173 7420 2667 743b 0 || *last > │ │ │ +000535b0: 206d 6178 5f69 6e64 6578 2920 2f2f 2069 max_index) // i │ │ │ +000535c0: 6e76 616c 6964 2069 6e64 6578 0a09 0909 nvalid index.... │ │ │ +000535d0: 0909 0909 636f 6e74 696e 7565 3b0a 0909 ....continue;... │ │ │ +000535e0: 0909 0909 6964 7831 203d 202a 6669 7273 ....idx1 = *firs │ │ │ +000535f0: 743b 0a09 0909 0909 0969 6478 3220 3d20 t;.......idx2 = │ │ │ +00053600: 2a6c 6173 743b 0a0a 0909 0909 0909 6966 *last;........if │ │ │ +00053610: 2028 6964 7831 2026 6774 3b20 6964 7832 (idx1 > idx2 │ │ │ +00053620: 2920 2f2f 2077 726f 6e67 2072 616e 6765 ) // wrong range │ │ │ +00053630: 206c 696d 6974 730a 0909 0909 0909 0963 limits........c │ │ │ +00053640: 6f6e 7469 6e75 653b 0a09 0909 0909 7d0a ontinue;......}. │ │ │ +00053650: 0909 0909 0965 6c73 6520 2f2f 2069 7427 .....else // it' │ │ │ +00053660: 7320 616e 2069 6e64 6578 0a09 0909 0909 s an index...... │ │ │ +00053670: 7b0a 0909 0909 0909 6175 746f 2063 6f6e {.......auto con │ │ │ +00053680: 7374 2069 6478 203d 2061 7578 3a3a 7061 st idx = aux::pa │ │ │ +00053690: 7273 655f 6465 6369 6d61 6c28 746f 6b65 rse_decimal(toke │ │ │ +000536a0: 6e29 3b0a 0909 0909 0909 6966 2028 2169 n);.......if (!i │ │ │ +000536b0: 6478 207c 7c20 2a69 6478 2026 6c74 3b20 dx || *idx < │ │ │ +000536c0: 3020 7c7c 202a 6964 7820 2667 743b 206d 0 || *idx > m │ │ │ +000536d0: 6178 5f69 6e64 6578 2920 2f2f 2069 6e76 ax_index) // inv │ │ │ +000536e0: 616c 6964 2069 6e64 6578 0a09 0909 0909 alid index...... │ │ │ +000536f0: 0909 636f 6e74 696e 7565 3b0a 0909 0909 ..continue;..... │ │ │ +00053700: 0909 6964 7831 203d 202a 6964 783b 0a09 ..idx1 = *idx;.. │ │ │ +00053710: 0909 0909 0969 6478 3220 3d20 6964 7831 .....idx2 = idx1 │ │ │ +00053720: 3b0a 0909 0909 097d 0a0a 3c2f 7072 653e ;......}..
    │ │ │ +00053730: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +00053760: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +00053770: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/reso │ │ │ +000537a0: 6c76 655f 6475 706c 6963 6174 655f 6669 lve_duplicate_fi │ │ │ +000537b0: 6c65 6e61 6d65 732e 6370 703a 3137 393c lenames.cpp:179< │ │ │ +000537c0: 2f61 3e3c 2f74 643e 3c74 643e 7468 6973 /a>this │ │ │ +000537d0: 2063 616e 2062 6520 6d6f 7265 2065 6666 can be more eff │ │ │ +000537e0: 6963 6965 6e74 2066 6f72 2076 3220 746f icient for v2 to │ │ │ +000537f0: 7272 656e 7473 3c2f 7464 3e3c 2f74 723e rrents │ │ │ +00053800: 3c74 7220 6964 3d22 3139 3622 2073 7479 │ │ │ +00053830: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00053840: 3c68 323e 7468 6973 2063 616e 2062 6520

    this can be │ │ │ +00053850: 6d6f 7265 2065 6666 6963 6965 6e74 2066 more efficient f │ │ │ +00053860: 6f72 2076 3220 746f 7272 656e 7473 3c2f or v2 torrents

    ../src/re │ │ │ +00053880: 736f 6c76 655f 6475 706c 6963 6174 655f solve_duplicate_ │ │ │ +00053890: 6669 6c65 6e61 6d65 732e 6370 703a 3137 filenames.cpp:17 │ │ │ +000538a0: 393c 2f68 343e 3c70 7265 2073 7479 6c65 9

    │ │ │ +000538e0: 0909 0909 7d0a 0909 0909 2b2b 6e75 6d5f  ....}.....++num_
    │ │ │ +000538f0: 636f 6c6c 6973 696f 6e73 3b0a 0909 0909  collisions;.....
    │ │ │ +00053900: 6966 2028 6e75 6d5f 636f 6c6c 6973 696f  if (num_collisio
    │ │ │ +00053910: 6e73 2026 6774 3b20 6d61 785f 6475 706c  ns > max_dupl
    │ │ │ +00053920: 6963 6174 655f 6669 6c65 6e61 6d65 7329  icate_filenames)
    │ │ │ +00053930: 0a09 0909 097b 0a09 0909 0909 6563 203d  .....{......ec =
    │ │ │ +00053940: 2065 7272 6f72 733a 3a74 6f6f 5f6d 616e   errors::too_man
    │ │ │ +00053950: 795f 6475 706c 6963 6174 655f 6669 6c65  y_duplicate_file
    │ │ │ +00053960: 6e61 6d65 733b 0a09 0909 0909 7265 7475  names;......retu
    │ │ │ +00053970: 726e 207b 7d3b 0a09 0909 097d 0a09 0909  rn {};.....}....
    │ │ │ +00053980: 7d0a 0909 0972 6574 2e69 6e73 6572 7428  }....ret.insert(
    │ │ │ +00053990: 7b69 2c20 6669 6c65 6e61 6d65 7d29 3b0a  {i, filename});.
    │ │ │ +000539a0: 0909 7d0a 0909 7265 7475 726e 2072 6574  ..}...return ret
    │ │ │ +000539b0: 3b0a 097d 0a0a 7d0a 0a09 7374 643a 3a6d  ;..}..}...std::m
    │ │ │ +000539c0: 6170 266c 743b 6669 6c65 5f69 6e64 6578  ap<file_index
    │ │ │ +000539d0: 5f74 2c20 7374 643a 3a73 7472 696e 6726  _t, std::string&
    │ │ │ +000539e0: 6774 3b20 7265 736f 6c76 655f 6475 706c  gt; resolve_dupl
    │ │ │ +000539f0: 6963 6174 655f 6669 6c65 6e61 6d65 7328  icate_filenames(
    │ │ │ +00053a00: 0a09 0966 696c 655f 7374 6f72 6167 6520  ...file_storage 
    │ │ │ +00053a10: 636f 6e73 7426 616d 703b 2066 730a 0909  const& fs...
    │ │ │ +00053a20: 2c20 696e 7420 636f 6e73 7420 6d61 785f  , int const max_
    │ │ │ +00053a30: 6475 706c 6963 6174 655f 6669 6c65 6e61  duplicate_filena
    │ │ │ +00053a40: 6d65 730a 0909 2c20 6572 726f 725f 636f  mes..., error_co
    │ │ │ +00053a50: 6465 2661 6d70 3b20 6563 290a 097b 0a3c  de& ec)..{.<
    │ │ │ +00053a60: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +00053a70: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +00053a80: 7769 6474 683d 2231 3030 2522 3e09 0973  width="100%">..s
    │ │ │ +00053a90: 7464 3a3a 756e 6f72 6465 7265 645f 7365  td::unordered_se
    │ │ │ +00053aa0: 7426 6c74 3b73 7464 3a3a 7569 6e74 3332  t<std::uint32
    │ │ │ +00053ab0: 5f74 2667 743b 2066 696c 6573 3b0a 3c2f  _t> files;....std::stri
    │ │ │ +00053ad0: 6e67 2063 6f6e 7374 2065 6d70 7479 5f73  ng const empty_s
    │ │ │ +00053ae0: 7472 3b0a 0a09 092f 2f20 696e 7365 7274  tr;....// insert
    │ │ │ +00053af0: 2061 6c6c 2064 6972 6563 746f 7269 6573   all directories
    │ │ │ +00053b00: 2066 6972 7374 2c20 746f 206d 616b 6520   first, to make 
    │ │ │ +00053b10: 7375 7265 206e 6f20 6669 6c65 730a 0909  sure no files...
    │ │ │ +00053b20: 2f2f 2061 7265 2061 6c6c 6f77 6564 2074  // are allowed t
    │ │ │ +00053b30: 6f20 636f 6c6c 6965 6420 7769 7468 2074  o collied with t
    │ │ │ +00053b40: 6865 6d0a 0909 6673 2e61 6c6c 5f70 6174  hem...fs.all_pat
    │ │ │ +00053b50: 685f 6861 7368 6573 2866 696c 6573 293b  h_hashes(files);
    │ │ │ +00053b60: 0a09 0966 6f72 2028 6175 746f 2063 6f6e  ...for (auto con
    │ │ │ +00053b70: 7374 2069 203a 2066 732e 6669 6c65 5f72  st i : fs.file_r
    │ │ │ +00053b80: 616e 6765 2829 290a 0909 7b0a 0909 092f  ange())...{..../
    │ │ │ +00053b90: 2f20 6173 206c 6f6e 6720 6173 2074 6869  / as long as thi
    │ │ │ +00053ba0: 7320 6669 6c65 2061 6c72 6561 6479 2065  s file already e
    │ │ │ +00053bb0: 7869 7374 730a 0909 092f 2f20 696e 6372  xists....// incr
    │ │ │ +00053bc0: 6561 7365 2074 6865 2063 6f75 6e74 6572  ease the counter
    │ │ │ +00053bd0: 0a09 0909 7374 643a 3a75 696e 7433 325f  ....std::uint32_
    │ │ │ +00053be0: 7420 636f 6e73 7420 6820 3d20 6673 2e66  t const h = fs.f
    │ │ │ +00053bf0: 696c 655f 7061 7468 5f68 6173 6828 692c  ile_path_hash(i,
    │ │ │ +00053c00: 2065 6d70 7479 5f73 7472 293b 0a09 0909   empty_str);....
    │ │ │ +00053c10: 6966 2028 2166 696c 6573 2e69 6e73 6572  if (!files.inser
    │ │ │ +00053c20: 7428 6829 2e73 6563 6f6e 6429 0a09 0909  t(h).second)....
    │ │ │ +00053c30: 7b0a 0909 0909 2f2f 2054 6869 7320 6669  {.....// This fi
    │ │ │ +00053c40: 6c65 6e61 6d65 2061 7070 6561 7273 2074  lename appears t
    │ │ │ +00053c50: 6f20 616c 7265 6164 7920 6578 6973 7421  o already exist!
    │ │ │ +00053c60: 0a09 0909 092f 2f20 4966 2074 6869 7320  .....// If this 
    │ │ │ +00053c70: 6861 7070 656e 732c 206a 7573 7420 7374  happens, just st
    │ │ │ +00053c80: 6172 7420 6f76 6572 2061 6e64 2064 6f20  art over and do 
    │ │ │ +00053c90: 6974 2074 6865 2073 6c6f 7720 7761 792c  it the slow way,
    │ │ │ +00053ca0: 0a09 0909 092f 2f20 636f 6d70 6172 696e  .....// comparin
    │ │ │ +00053cb0: 6720 6675 6c6c 2066 696c 6520 6e61 6d65  g full file name
    │ │ │ +00053cc0: 7320 616e 6420 636f 6d65 2075 7020 7769  s and come up wi
    │ │ │ +00053cd0: 7468 206e 6577 206e 616d 6573 0a09 0909  th new names....
    │ │ │ +00053ce0: 0972 6574 7572 6e20 7265 736f 6c76 655f  .return resolve_
    │ │ │ +00053cf0: 6475 706c 6963 6174 655f 6669 6c65 6e61  duplicate_filena
    │ │ │ +00053d00: 6d65 735f 736c 6f77 2866 732c 206d 6178  mes_slow(fs, max
    │ │ │ +00053d10: 5f64 7570 6c69 6361 7465 5f66 696c 656e  _duplicate_filen
    │ │ │ +00053d20: 616d 6573 2c20 6563 293b 0a09 0909 7d0a  ames, ec);....}.
    │ │ │ +00053d30: 0909 7d0a 0909 7265 7475 726e 207b 7d3b  ..}...return {};
    │ │ │ +00053d40: 0a09 7d0a 0a7d 0a3c 2f70 7265 3e3c 2f74  ..}..}.
    relevanc │ │ │ +00053d80: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0
    ../src/fingerp │ │ │ +00053dc0: 7269 6e74 2e63 7070 3a35 353c 2f61 3e3c rint.cpp:55< │ │ │ +00053dd0: 2f74 643e 3c74 643e 7468 6520 6669 6e67 /td>the fing │ │ │ +00053de0: 6572 7072 696e 7420 636f 6e73 7472 7563 erprint construc │ │ │ +00053df0: 746f 7220 7368 6f75 6c64 2074 616b 6520 tor should take │ │ │ +00053e00: 6120 7374 7269 6e67 5f76 6965 773c 2f74 a string_view

    the f │ │ │ +00053e60: 696e 6765 7270 7269 6e74 2063 6f6e 7374 ingerprint const │ │ │ +00053e70: 7275 6374 6f72 2073 686f 756c 6420 7461 ructor should ta │ │ │ +00053e80: 6b65 2061 2073 7472 696e 675f 7669 6577 ke a string_view │ │ │ +00053e90: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +00053ea0: 6669 6e67 6572 7072 696e 742e 6370 703a fingerprint.cpp: │ │ │ +00053eb0: 3535 3c2f 6834 3e3c 7072 6520 7374 796c 55

    ..TORRENT_ASSER
    │ │ │ +00053f00: 545f 5052 4543 4f4e 4428 6d69 6e6f 7220  T_PRECOND(minor 
    │ │ │ +00053f10: 2667 743b 3d20 3029 3b0a 0909 544f 5252  >= 0);...TORR
    │ │ │ +00053f20: 454e 545f 4153 5345 5254 5f50 5245 434f  ENT_ASSERT_PRECO
    │ │ │ +00053f30: 4e44 2872 6576 6973 696f 6e20 2667 743b  ND(revision >
    │ │ │ +00053f40: 3d20 3029 3b0a 0909 544f 5252 454e 545f  = 0);...TORRENT_
    │ │ │ +00053f50: 4153 5345 5254 5f50 5245 434f 4e44 2874  ASSERT_PRECOND(t
    │ │ │ +00053f60: 6167 2026 6774 3b3d 2030 293b 0a09 0954  ag >= 0);...T
    │ │ │ +00053f70: 4f52 5245 4e54 5f41 5353 4552 545f 5052  ORRENT_ASSERT_PR
    │ │ │ +00053f80: 4543 4f4e 4428 6e61 6d65 2e73 697a 6528  ECOND(name.size(
    │ │ │ +00053f90: 2920 3d3d 2032 293b 0a09 0969 6620 286e  ) == 2);...if (n
    │ │ │ +00053fa0: 616d 652e 7369 7a65 2829 2026 6c74 3b20  ame.size() < 
    │ │ │ +00053fb0: 3229 206e 616d 6520 3d20 222d 2d22 3b0a  2) name = "--";.
    │ │ │ +00053fc0: 0a09 0973 7464 3a3a 7374 7269 6e67 2072  ...std::string r
    │ │ │ +00053fd0: 6574 3b0a 0909 7265 742e 7265 7369 7a65  et;...ret.resize
    │ │ │ +00053fe0: 2838 293b 0a09 0972 6574 5b30 5d20 3d20  (8);...ret[0] = 
    │ │ │ +00053ff0: 272d 273b 0a09 0972 6574 5b31 5d20 3d20  '-';...ret[1] = 
    │ │ │ +00054000: 6e61 6d65 5b30 5d3b 0a09 0972 6574 5b32  name[0];...ret[2
    │ │ │ +00054010: 5d20 3d20 6e61 6d65 5b31 5d3b 0a09 0972  ] = name[1];...r
    │ │ │ +00054020: 6574 5b33 5d20 3d20 7665 7273 696f 6e5f  et[3] = version_
    │ │ │ +00054030: 746f 5f63 6861 7228 6d61 6a6f 7229 3b0a  to_char(major);.
    │ │ │ +00054040: 0909 7265 745b 345d 203d 2076 6572 7369  ..ret[4] = versi
    │ │ │ +00054050: 6f6e 5f74 6f5f 6368 6172 286d 696e 6f72  on_to_char(minor
    │ │ │ +00054060: 293b 0a09 0972 6574 5b35 5d20 3d20 7665  );...ret[5] = ve
    │ │ │ +00054070: 7273 696f 6e5f 746f 5f63 6861 7228 7265  rsion_to_char(re
    │ │ │ +00054080: 7669 7369 6f6e 293b 0a09 0972 6574 5b36  vision);...ret[6
    │ │ │ +00054090: 5d20 3d20 7665 7273 696f 6e5f 746f 5f63  ] = version_to_c
    │ │ │ +000540a0: 6861 7228 7461 6729 3b0a 0909 7265 745b  har(tag);...ret[
    │ │ │ +000540b0: 375d 203d 2027 2d27 3b0a 0909 7265 7475  7] = '-';...retu
    │ │ │ +000540c0: 726e 2072 6574 3b0a 097d 0a0a 2369 6664  rn ret;..}..#ifd
    │ │ │ +000540d0: 6566 205f 5f63 6c61 6e67 5f5f 0a3c 6469  ef __clang__.#prag
    │ │ │ +00054110: 6d61 2063 6c61 6e67 2064 6961 676e 6f73  ma clang diagnos
    │ │ │ +00054120: 7469 6320 7075 7368 0a3c 2f64 6976 3e23  tic push.#
    │ │ │ +00054130: 7072 6167 6d61 2063 6c61 6e67 2064 6961  pragma clang dia
    │ │ │ +00054140: 676e 6f73 7469 6320 6967 6e6f 7265 6420  gnostic ignored 
    │ │ │ +00054150: 222d 5775 6e6b 6e6f 776e 2d77 6172 6e69  "-Wunknown-warni
    │ │ │ +00054160: 6e67 2d6f 7074 696f 6e22 0a23 7072 6167  ng-option".#prag
    │ │ │ +00054170: 6d61 2063 6c61 6e67 2064 6961 676e 6f73  ma clang diagnos
    │ │ │ +00054180: 7469 6320 6967 6e6f 7265 6420 222d 5775  tic ignored "-Wu
    │ │ │ +00054190: 6e73 6166 652d 6275 6666 6572 2d75 7361  nsafe-buffer-usa
    │ │ │ +000541a0: 6765 220a 2365 6e64 6966 0a0a 0966 696e  ge".#endif...fin
    │ │ │ +000541b0: 6765 7270 7269 6e74 3a3a 6669 6e67 6572  gerprint::finger
    │ │ │ +000541c0: 7072 696e 7428 636f 6e73 7420 6368 6172  print(const char
    │ │ │ +000541d0: 2a20 6964 5f73 7472 696e 672c 2069 6e74  * id_string, int
    │ │ │ +000541e0: 206d 616a 6f72 2c20 696e 7420 6d69 6e6f   major, int mino
    │ │ │ +000541f0: 720a 0909 2c20 696e 7420 7265 7669 7369  r..., int revisi
    │ │ │ +00054200: 6f6e 2c20 696e 7420 7461 6729 0a09 093a  on, int tag)...:
    │ │ │ +00054210: 206d 616a 6f72 5f76 6572 7369 6f6e 286d   major_version(m
    │ │ │ +00054220: 616a 6f72 290a 0909 2c20 6d69 6e6f 725f  ajor)..., minor_
    │ │ │ +00054230: 7665 7273 696f 6e28 6d69 6e6f 7229 0a09  version(minor)..
    │ │ │ +00054240: 092c 2072 6576 6973 696f 6e5f 7665 7273  ., revision_vers
    │ │ │ +00054250: 696f 6e28 7265 7669 7369 6f6e 290a 0909  ion(revision)...
    │ │ │ +00054260: 2c20 7461 675f 7665 7273 696f 6e28 7461  , tag_version(ta
    │ │ │ +00054270: 6729 0a09 7b0a 0909 544f 5252 454e 545f  g)..{...TORRENT_
    │ │ │ +00054280: 4153 5345 5254 2869 645f 7374 7269 6e67  ASSERT(id_string
    │ │ │ +00054290: 293b 0a09 0954 4f52 5245 4e54 5f41 5353  );...TORRENT_ASS
    │ │ │ +000542a0: 4552 5428 6d61 6a6f 7220 2667 743b 3d20  ERT(major >= 
    │ │ │ +000542b0: 3029 3b0a 0909 544f 5252 454e 545f 4153  0);...TORRENT_AS
    │ │ │ +000542c0: 5345 5254 286d 696e 6f72 2026 6774 3b3d  SERT(minor >=
    │ │ │ +000542d0: 2030 293b 0a09 0954 4f52 5245 4e54 5f41   0);...TORRENT_A
    │ │ │ +000542e0: 5353 4552 5428 7265 7669 7369 6f6e 2026  SSERT(revision &
    │ │ │ +000542f0: 6774 3b3d 2030 293b 0a09 0954 4f52 5245  gt;= 0);...TORRE
    │ │ │ +00054300: 4e54 5f41 5353 4552 5428 7461 6720 2667  NT_ASSERT(tag &g
    │ │ │ +00054310: 743b 3d20 3029 3b0a 0909 544f 5252 454e  t;= 0);...TORREN
    │ │ │ +00054320: 545f 4153 5345 5254 2873 7464 3a3a 7374  T_ASSERT(std::st
    │ │ │ +00054330: 726c 656e 2869 645f 7374 7269 6e67 2920  rlen(id_string) 
    │ │ │ +00054340: 3d3d 2032 293b 0a09 096e 616d 655b 305d  == 2);...name[0]
    │ │ │ +00054350: 203d 2069 645f 7374 7269 6e67 5b30 5d3b   = id_string[0];
    │ │ │ +00054360: 0a09 096e 616d 655b 315d 203d 2069 645f  ...name[1] = id_
    │ │ │ +00054370: 7374 7269 6e67 5b31 5d3b 0a09 7d0a 0a23  string[1];..}..#
    │ │ │ +00054380: 6966 6465 6620 5f5f 636c 616e 675f 5f0a  ifdef __clang__.
    │ │ │ +00054390: 2370 7261 676d 6120 636c 616e 6720 6469  #pragma clang di
    │ │ │ +000543a0: 6167 6e6f 7374 6963 2070 6f70 0a23 656e  agnostic pop.#en
    │ │ │ +000543b0: 6469 660a 0a23 6966 2054 4f52 5245 4e54  dif..#if TORRENT
    │ │ │ +000543c0: 5f41 4249 5f56 4552 5349 4f4e 203d 3d20  _ABI_VERSION == 
    │ │ │ +000543d0: 310a 0973 7464 3a3a 7374 7269 6e67 2066  1..std::string f
    │ │ │ +000543e0: 696e 6765 7270 7269 6e74 3a3a 746f 5f73  ingerprint::to_s
    │ │ │ +000543f0: 7472 696e 6728 2920 636f 6e73 740a 097b  tring() const..{
    │ │ │ +00054400: 0a09 0972 6574 7572 6e20 6765 6e65 7261  ...return genera
    │ │ │ +00054410: 7465 5f66 696e 6765 7270 7269 6e74 2873  te_fingerprint(s
    │ │ │ +00054420: 7464 3a3a 7374 7269 6e67 286e 616d 652c  td::string(name,
    │ │ │ +00054430: 2032 292c 206d 616a 6f72 5f76 6572 7369   2), major_versi
    │ │ │ +00054440: 6f6e 2c20 6d69 6e6f 725f 7665 7273 696f  on, minor_versio
    │ │ │ +00054450: 6e0a 0909 092c 2072 6576 6973 696f 6e5f  n...., revision_
    │ │ │ +00054460: 7665 7273 696f 6e2c 2074 6167 5f76 6572  version, tag_ver
    │ │ │ +00054470: 7369 6f6e 293b 0a3c 2f70 7265 3e3c 2f74  sion);.
    relevanc │ │ │ +000544b0: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/random. │ │ │ +000544f0: 6370 703a 3131 373c 2f61 3e3c 2f74 643e cpp:117 │ │ │ +00054500: 3c74 643e 696d 7072 6f76 6520 6361 6c6c improve call │ │ │ +00054510: 696e 6720 5241 4e44 5f62 7974 6573 206d ing RAND_bytes m │ │ │ +00054520: 756c 7469 706c 6520 7469 6d65 732c 2075 ultiple times, u │ │ │ +00054530: 7369 6e67 2066 616c 6c62 6163 6b20 666f sing fallback fo │ │ │ +00054540: 7220 6e6f 773c 2f74 643e 3c2f 7472 3e3c r now< │ │ │ +00054550: 7472 2069 643d 2231 3938 2220 7374 796c tr id="198" styl │ │ │ +00054560: 653d 2264 6973 706c 6179 3a20 6e6f 6e65 e="display: none │ │ │ +00054570: 3b22 2063 6f6c 7370 616e 3d22 3322 3e3c ;" colspan="3">< │ │ │ +00054580: 7464 2063 6f6c 7370 616e 3d22 3322 3e3c td colspan="3">< │ │ │ +00054590: 6832 3e69 6d70 726f 7665 2063 616c 6c69 h2>improve calli │ │ │ +000545a0: 6e67 2052 414e 445f 6279 7465 7320 6d75 ng RAND_bytes mu │ │ │ +000545b0: 6c74 6970 6c65 2074 696d 6573 2c20 7573 ltiple times, us │ │ │ +000545c0: 696e 6720 6661 6c6c 6261 636b 2066 6f72 ing fallback for │ │ │ +000545d0: 206e 6f77 3c2f 6832 3e3c 6834 3e2e 2e2f now

    ../ │ │ │ +000545e0: 7372 632f 7261 6e64 6f6d 2e63 7070 3a31 src/random.cpp:1 │ │ │ +000545f0: 3137 3c2f 6834 3e3c 7072 6520 7374 796c 17

    #else....std::g
    │ │ │ +00054640: 656e 6572 6174 6528 6275 6666 6572 2e62  enerate(buffer.b
    │ │ │ +00054650: 6567 696e 2829 2c20 6275 6666 6572 2e65  egin(), buffer.e
    │ │ │ +00054660: 6e64 2829 2c20 5b5d 207b 2072 6574 7572  nd(), [] { retur
    │ │ │ +00054670: 6e20 6368 6172 2872 616e 646f 6d28 3078  n char(random(0x
    │ │ │ +00054680: 6666 2929 3b20 7d29 3b0a 2365 6e64 6966  ff)); });.#endif
    │ │ │ +00054690: 0a09 097d 0a0a 0909 766f 6964 2063 7279  ...}....void cry
    │ │ │ +000546a0: 7074 6f5f 7261 6e64 6f6d 5f62 7974 6573  pto_random_bytes
    │ │ │ +000546b0: 2873 7061 6e26 6c74 3b63 6861 7226 6774  (span<char>
    │ │ │ +000546c0: 3b20 6275 6666 6572 290a 0909 7b0a 2369  ; buffer)...{.#i
    │ │ │ +000546d0: 6664 6566 2054 4f52 5245 4e54 5f42 5549  fdef TORRENT_BUI
    │ │ │ +000546e0: 4c44 5f53 494d 554c 4154 4f52 0a09 0909  LD_SIMULATOR....
    │ │ │ +000546f0: 2f2f 2049 6e20 7468 6520 7369 6d75 6c61  // In the simula
    │ │ │ +00054700: 746f 7220 7765 2077 616e 7420 6465 7465  tor we want dete
    │ │ │ +00054710: 726d 696e 6973 7469 6320 7261 6e64 6f6d  rministic random
    │ │ │ +00054720: 206e 756d 6265 7273 0a09 0909 7374 643a   numbers....std:
    │ │ │ +00054730: 3a67 656e 6572 6174 6528 6275 6666 6572  :generate(buffer
    │ │ │ +00054740: 2e62 6567 696e 2829 2c20 6275 6666 6572  .begin(), buffer
    │ │ │ +00054750: 2e65 6e64 2829 2c20 5b5d 207b 2072 6574  .end(), [] { ret
    │ │ │ +00054760: 7572 6e20 6368 6172 2872 616e 646f 6d28  urn char(random(
    │ │ │ +00054770: 3078 6666 2929 3b20 7d29 3b0a 2365 6c69  0xff)); });.#eli
    │ │ │ +00054780: 6620 544f 5252 454e 545f 5553 455f 434e  f TORRENT_USE_CN
    │ │ │ +00054790: 470a 0909 0961 7578 3a3a 636e 675f 6765  G....aux::cng_ge
    │ │ │ +000547a0: 6e5f 7261 6e64 6f6d 2862 7566 6665 7229  n_random(buffer)
    │ │ │ +000547b0: 3b0a 2365 6c69 6620 544f 5252 454e 545f  ;.#elif TORRENT_
    │ │ │ +000547c0: 5553 455f 4352 5950 544f 4150 490a 0909  USE_CRYPTOAPI...
    │ │ │ +000547d0: 092f 2f20 7769 6e64 6f77 730a 0909 0961  .// windows....a
    │ │ │ +000547e0: 7578 3a3a 6372 7970 745f 6765 6e5f 7261  ux::crypt_gen_ra
    │ │ │ +000547f0: 6e64 6f6d 2862 7566 6665 7229 3b0a 2365  ndom(buffer);.#e
    │ │ │ +00054800: 6c69 6620 6465 6669 6e65 6420 544f 5252  lif defined TORR
    │ │ │ +00054810: 454e 545f 5553 455f 4c49 4243 5259 5054  ENT_USE_LIBCRYPT
    │ │ │ +00054820: 4f20 2661 6d70 3b26 616d 703b 2021 6465  O && !de
    │ │ │ +00054830: 6669 6e65 6420 544f 5252 454e 545f 5553  fined TORRENT_US
    │ │ │ +00054840: 455f 574f 4c46 5353 4c0a 2f2f 2077 6f6c  E_WOLFSSL.// wol
    │ │ │ +00054850: 6653 534c 2075 7365 7320 7763 5f52 4e47  fSSL uses wc_RNG
    │ │ │ +00054860: 5f47 656e 6572 6174 6542 6c6f 636b 2061  _GenerateBlock a
    │ │ │ +00054870: 7320 7468 6520 696e 7465 726e 616c 2066  s the internal f
    │ │ │ +00054880: 756e 6374 696f 6e20 666f 7220 7468 650a  unction for the.
    │ │ │ +00054890: 2f2f 206f 7065 6e73 736c 2063 6f6d 7061  // openssl compa
    │ │ │ +000548a0: 7469 6269 6c69 7479 206c 6179 6572 2e20  tibility layer. 
    │ │ │ +000548b0: 5468 6973 2066 756e 6374 696f 6e20 4150  This function AP
    │ │ │ +000548c0: 4920 646f 6573 206e 6f74 2073 7570 706f  I does not suppo
    │ │ │ +000548d0: 7274 0a2f 2f20 616e 2061 7262 6974 7261  rt.// an arbitra
    │ │ │ +000548e0: 7279 2062 7566 6665 7220 7369 7a65 2028  ry buffer size (
    │ │ │ +000548f0: 6f70 656e 7373 6c20 646f 6573 292c 2069  openssl does), i
    │ │ │ +00054900: 7420 6973 206c 696d 6974 6564 2062 7920  t is limited by 
    │ │ │ +00054910: 7468 650a 2f2f 2063 6f6e 7374 616e 7420  the.// constant 
    │ │ │ +00054920: 524e 475f 4d41 585f 424c 4f43 4b5f 4c45  RNG_MAX_BLOCK_LE
    │ │ │ +00054930: 4e2e 0a3c 6469 7620 7374 796c 653d 2262  N..
    .
    ...// op │ │ │ +00054970: 656e 7373 6c0a 0909 0969 6e74 2072 203d enssl....int r = │ │ │ +00054980: 2052 414e 445f 6279 7465 7328 7265 696e RAND_bytes(rein │ │ │ +00054990: 7465 7270 7265 745f 6361 7374 266c 743b terpret_cast< │ │ │ +000549a0: 756e 7369 676e 6564 2063 6861 722a 2667 unsigned char*&g │ │ │ +000549b0: 743b 2862 7566 6665 722e 6461 7461 2829 t;(buffer.data() │ │ │ +000549c0: 290a 0909 0909 2c20 696e 7428 6275 6666 )....., int(buff │ │ │ +000549d0: 6572 2e73 697a 6528 2929 293b 0a09 0909 er.size()));.... │ │ │ +000549e0: 6966 2028 7220 213d 2031 2920 6175 783a if (r != 1) aux: │ │ │ +000549f0: 3a74 6872 6f77 5f65 7826 6c74 3b73 7973 :throw_ex<sys │ │ │ +00054a00: 7465 6d5f 6572 726f 7226 6774 3b28 6572 tem_error>(er │ │ │ +00054a10: 726f 7273 3a3a 6e6f 5f65 6e74 726f 7079 rors::no_entropy │ │ │ +00054a20: 293b 0a23 656c 6966 2054 4f52 5245 4e54 );.#elif TORRENT │ │ │ +00054a30: 5f55 5345 5f47 4554 5241 4e44 4f4d 0a09 _USE_GETRANDOM.. │ │ │ +00054a40: 0909 7373 697a 655f 7420 636f 6e73 7420 ..ssize_t const │ │ │ +00054a50: 7220 3d20 3a3a 6765 7472 616e 646f 6d28 r = ::getrandom( │ │ │ +00054a60: 6275 6666 6572 2e64 6174 6128 292c 2073 buffer.data(), s │ │ │ +00054a70: 7461 7469 635f 6361 7374 266c 743b 7374 tatic_cast<st │ │ │ +00054a80: 643a 3a73 697a 655f 7426 6774 3b28 6275 d::size_t>(bu │ │ │ +00054a90: 6666 6572 2e73 697a 6528 2929 2c20 3029 ffer.size()), 0) │ │ │ +00054aa0: 3b0a 0909 0969 6620 2872 203d 3d20 7373 ;....if (r == ss │ │ │ +00054ab0: 697a 655f 7428 6275 6666 6572 2e73 697a ize_t(buffer.siz │ │ │ +00054ac0: 6528 2929 2920 7265 7475 726e 3b0a 0909 e())) return;... │ │ │ +00054ad0: 0969 6620 2872 203d 3d20 2d31 2026 616d .if (r == -1 &am │ │ │ +00054ae0: 703b 2661 6d70 3b20 6572 726e 6f20 213d p;& errno != │ │ │ +00054af0: 2045 4e4f 5359 5329 2061 7578 3a3a 7468 ENOSYS) aux::th │ │ │ +00054b00: 726f 775f 6578 266c 743b 7379 7374 656d row_ex<system │ │ │ +00054b10: 5f65 7272 6f72 2667 743b 2865 7272 6f72 _error>(error │ │ │ +00054b20: 5f63 6f64 6528 6572 726e 6f2c 2067 656e _code(errno, gen │ │ │ +00054b30: 6572 6963 5f63 6174 6567 6f72 7928 2929 eric_category()) │ │ │ +00054b40: 293b 0a09 0909 7374 6174 6963 2064 6576 );....static dev │ │ │ +00054b50: 5f72 616e 646f 6d20 6465 763b 0a09 0909 _random dev;.... │ │ │ +00054b60: 6465 762e 7265 6164 2862 7566 6665 7229 dev.read(buffer) │ │ │ +00054b70: 3b0a 2365 6c69 6620 544f 5252 454e 545f ;.#elif TORRENT_ │ │ │ +00054b80: 5553 455f 4445 565f 5241 4e44 4f4d 0a09 USE_DEV_RANDOM.. │ │ │ +00054b90: 0909 7374 6174 6963 2064 6576 5f72 616e ..static dev_ran │ │ │ +00054ba0: 646f 6d20 6465 763b 0a09 0909 6465 762e dom dev;....dev. │ │ │ +00054bb0: 7265 6164 2862 7566 6665 7229 3b0a 2365 read(buffer);.#e │ │ │ +00054bc0: 6c73 650a 0a23 6966 2054 4f52 5245 4e54 lse..#if TORRENT │ │ │ +00054bd0: 5f42 524f 4b45 4e5f 5241 4e44 4f4d 5f44 _BROKEN_RANDOM_D │ │ │ +00054be0: 4556 4943 450a 0909 092f 2f20 6576 656e EVICE....// even │ │ │ +00054bf0: 2070 7365 7564 6f20 7261 6e64 6f6d 206e pseudo random n │ │ │ +00054c00: 756d 6265 7273 2072 656c 7920 6f6e 2062 umbers rely on b │ │ │ +00054c10: 6569 6e67 2061 626c 6520 746f 2073 6565 eing able to see │ │ │ +00054c20: 6420 7468 6520 7261 6e64 6f6d 0a09 0909 d the random.... │ │ │ +00054c30: 2f2f 2067 656e 6572 6174 6f72 0a23 6572 // generator.#er │ │ │ +00054c40: 726f 7220 226e 6f20 656e 7472 6f70 7920 ror "no entropy │ │ │ +00054c50: 736f 7572 6365 2061 7661 696c 6162 6c65 source available │ │ │ +00054c60: 220a 2365 6c73 650a 2369 6664 6566 2054 ".#else.#ifdef T │ │ │ +00054c70: 4f52 5245 4e54 5f49 5f57 414e 545f 494e ORRENT_I_WANT_IN │ │ │ +00054c80: 5345 4355 5245 5f52 414e 444f 4d5f 4e55 SECURE_RANDOM_NU │ │ │ +00054c90: 4d42 4552 530a 0909 0973 7464 3a3a 6765 MBERS....std::ge │ │ │ +00054ca0: 6e65 7261 7465 2862 7566 6665 722e 6265 nerate(buffer.be │ │ │ +00054cb0: 6769 6e28 292c 2062 7566 6665 722e 656e gin(), buffer.en │ │ │ +00054cc0: 6428 292c 205b 5d20 7b20 7265 7475 726e d(), [] { return │ │ │ +00054cd0: 2063 6861 7228 7261 6e64 6f6d 2830 7866 char(random(0xf │ │ │ +00054ce0: 6629 293b 207d 293b 0a23 656c 7365 0a23 f)); });.#else.# │ │ │ +00054cf0: 6572 726f 7220 226e 6f20 7365 6375 7265 error "no secure │ │ │ +00054d00: 2065 6e74 726f 7079 2073 6f75 7263 6520 entropy source │ │ │ +00054d10: 6176 6169 6c61 626c 652e 2049 6620 796f available. If yo │ │ │ +00054d20: 7520 7265 616c 6c79 2077 616e 7420 696e u really want in │ │ │ +00054d30: 7365 6375 7265 2072 616e 646f 6d20 6e75 secure random nu │ │ │ +00054d40: 6d62 6572 732c 2064 6566 696e 6520 544f mbers, define TO │ │ │ +00054d50: 5252 454e 545f 495f 5741 4e54 5f49 4e53 RRENT_I_WANT_INS │ │ │ +00054d60: 4543 5552 455f 5241 4e44 4f4d 5f4e 554d ECURE_RANDOM_NUM │ │ │ +00054d70: 4245 5253 220a 2365 6e64 6966 0a23 656e BERS".#endif.#en │ │ │ +00054d80: 6469 660a 0a23 656e 6469 660a 0909 7d0a dif..#endif...}. │ │ │ +00054d90: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472 .
    relevance  │ │ │ +00054dd0: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +00054e00: 7263 2f74 6f72 7265 6e74 5f68 616e 646c rc/torrent_handl │ │ │ +00054e10: 652e 6370 703a 3535 383c 2f61 3e3c 2f74 e.cpp:558support mo │ │ │ +00054e30: 7669 6e67 2066 696c 6573 2069 6e74 6f20 ving files into │ │ │ +00054e40: 7468 6973 2063 616c 6c3c 2f74 643e 3c2f this call

    support m │ │ │ +00054ea0: 6f76 696e 6720 6669 6c65 7320 696e 746f oving files into │ │ │ +00054eb0: 2074 6869 7320 6361 6c6c 3c2f 6832 3e3c this call

    < │ │ │ +00054ec0: 6834 3e2e 2e2f 7372 632f 746f 7272 656e h4>../src/torren │ │ │ +00054ed0: 745f 6861 6e64 6c65 2e63 7070 3a35 3538 t_handle.cpp:558 │ │ │ +00054ee0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d
    .
    │ │ │ +00054f20: 0961 7574 6f2a 2063 6f6e 7374 2072 6574  .auto* const ret
    │ │ │ +00054f30: 7020 3d20 2661 6d70 3b70 7269 6f3b 0a09  p = &prio;..
    │ │ │ +00054f40: 0973 796e 635f 6361 6c6c 2826 616d 703b  .sync_call(&
    │ │ │ +00054f50: 6175 783a 3a74 6f72 7265 6e74 3a3a 7069  aux::torrent::pi
    │ │ │ +00054f60: 6563 655f 7072 696f 7269 7469 6573 2c20  ece_priorities, 
    │ │ │ +00054f70: 7265 7470 293b 0a09 0973 7464 3a3a 7665  retp);...std::ve
    │ │ │ +00054f80: 6374 6f72 266c 743b 696e 7426 6774 3b20  ctor<int> 
    │ │ │ +00054f90: 7265 743b 0a09 0972 6574 2e72 6573 6572  ret;...ret.reser
    │ │ │ +00054fa0: 7665 2870 7269 6f2e 7369 7a65 2829 293b  ve(prio.size());
    │ │ │ +00054fb0: 0a09 0966 6f72 2028 6175 746f 2070 203a  ...for (auto p :
    │ │ │ +00054fc0: 2070 7269 6f29 0a09 0909 7265 742e 7075   prio)....ret.pu
    │ │ │ +00054fd0: 7368 5f62 6163 6b28 696e 7428 7374 6174  sh_back(int(stat
    │ │ │ +00054fe0: 6963 5f63 6173 7426 6c74 3b73 7464 3a3a  ic_cast<std::
    │ │ │ +00054ff0: 7569 6e74 385f 7426 6774 3b28 7029 2929  uint8_t>(p)))
    │ │ │ +00055000: 3b0a 0909 7265 7475 726e 2072 6574 3b0a  ;...return ret;.
    │ │ │ +00055010: 097d 0a23 656e 6469 660a 0a09 766f 6964  .}.#endif...void
    │ │ │ +00055020: 2074 6f72 7265 6e74 5f68 616e 646c 653a   torrent_handle:
    │ │ │ +00055030: 3a66 696c 655f 7072 696f 7269 7479 2866  :file_priority(f
    │ │ │ +00055040: 696c 655f 696e 6465 785f 7420 696e 6465  ile_index_t inde
    │ │ │ +00055050: 782c 2064 6f77 6e6c 6f61 645f 7072 696f  x, download_prio
    │ │ │ +00055060: 7269 7479 5f74 2070 7269 6f72 6974 7929  rity_t priority)
    │ │ │ +00055070: 2063 6f6e 7374 0a09 7b0a 0909 6173 796e   const..{...asyn
    │ │ │ +00055080: 635f 6361 6c6c 2826 616d 703b 6175 783a  c_call(&aux:
    │ │ │ +00055090: 3a74 6f72 7265 6e74 3a3a 7365 745f 6669  :torrent::set_fi
    │ │ │ +000550a0: 6c65 5f70 7269 6f72 6974 792c 2069 6e64  le_priority, ind
    │ │ │ +000550b0: 6578 2c20 7072 696f 7269 7479 293b 0a09  ex, priority);..
    │ │ │ +000550c0: 7d0a 0a09 646f 776e 6c6f 6164 5f70 7269  }...download_pri
    │ │ │ +000550d0: 6f72 6974 795f 7420 746f 7272 656e 745f  ority_t torrent_
    │ │ │ +000550e0: 6861 6e64 6c65 3a3a 6669 6c65 5f70 7269  handle::file_pri
    │ │ │ +000550f0: 6f72 6974 7928 6669 6c65 5f69 6e64 6578  ority(file_index
    │ │ │ +00055100: 5f74 2069 6e64 6578 2920 636f 6e73 740a  _t index) const.
    │ │ │ +00055110: 097b 0a09 0972 6574 7572 6e20 7379 6e63  .{...return sync
    │ │ │ +00055120: 5f63 616c 6c5f 7265 7426 6c74 3b64 6f77  _call_ret<dow
    │ │ │ +00055130: 6e6c 6f61 645f 7072 696f 7269 7479 5f74  nload_priority_t
    │ │ │ +00055140: 2667 743b 2864 6f6e 745f 646f 776e 6c6f  >(dont_downlo
    │ │ │ +00055150: 6164 2c20 2661 6d70 3b61 7578 3a3a 746f  ad, &aux::to
    │ │ │ +00055160: 7272 656e 743a 3a66 696c 655f 7072 696f  rrent::file_prio
    │ │ │ +00055170: 7269 7479 2c20 696e 6465 7829 3b0a 097d  rity, index);..}
    │ │ │ +00055180: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +000551b0: 0976 6f69 6420 746f 7272 656e 745f 6861 .void torrent_ha │ │ │ +000551c0: 6e64 6c65 3a3a 7072 696f 7269 7469 7a65 ndle::prioritize │ │ │ +000551d0: 5f66 696c 6573 2873 7464 3a3a 7665 6374 _files(std::vect │ │ │ +000551e0: 6f72 266c 743b 646f 776e 6c6f 6164 5f70 or<download_p │ │ │ +000551f0: 7269 6f72 6974 795f 7426 6774 3b20 636f riority_t> co │ │ │ +00055200: 6e73 7426 616d 703b 2066 696c 6573 2920 nst& files) │ │ │ +00055210: 636f 6e73 740a 3c2f 6469 763e 097b 0a09 const.
    .{.. │ │ │ +00055220: 0961 7379 6e63 5f63 616c 6c28 2661 6d70 .async_call(& │ │ │ +00055230: 3b61 7578 3a3a 746f 7272 656e 743a 3a70 ;aux::torrent::p │ │ │ +00055240: 7269 6f72 6974 697a 655f 6669 6c65 730a rioritize_files. │ │ │ +00055250: 0909 092c 2073 7461 7469 635f 6361 7374 ..., static_cast │ │ │ +00055260: 266c 743b 6175 783a 3a76 6563 746f 7226 <aux::vector& │ │ │ +00055270: 6c74 3b64 6f77 6e6c 6f61 645f 7072 696f lt;download_prio │ │ │ +00055280: 7269 7479 5f74 2c20 6669 6c65 5f69 6e64 rity_t, file_ind │ │ │ +00055290: 6578 5f74 2667 743b 2063 6f6e 7374 2661 ex_t> const&a │ │ │ +000552a0: 6d70 3b26 6774 3b28 6669 6c65 7329 293b mp;>(files)); │ │ │ +000552b0: 0a09 7d0a 0a09 766f 6964 2074 6f72 7265 ..}...void torre │ │ │ +000552c0: 6e74 5f68 616e 646c 653a 3a70 6f73 745f nt_handle::post_ │ │ │ +000552d0: 6669 6c65 5f70 7269 6f72 6974 6965 7328 file_priorities( │ │ │ +000552e0: 2920 636f 6e73 740a 097b 0a09 0961 7379 ) const..{...asy │ │ │ +000552f0: 6e63 5f63 616c 6c28 2661 6d70 3b61 7578 nc_call(&aux │ │ │ +00055300: 3a3a 746f 7272 656e 743a 3a70 6f73 745f ::torrent::post_ │ │ │ +00055310: 6669 6c65 5f70 7269 6f72 6974 6965 7329 file_priorities) │ │ │ +00055320: 3b0a 097d 0a0a 0973 7464 3a3a 7665 6374 ;..}...std::vect │ │ │ +00055330: 6f72 266c 743b 646f 776e 6c6f 6164 5f70 or<download_p │ │ │ +00055340: 7269 6f72 6974 795f 7426 6774 3b20 746f riority_t> to │ │ │ +00055350: 7272 656e 745f 6861 6e64 6c65 3a3a 6765 rrent_handle::ge │ │ │ +00055360: 745f 6669 6c65 5f70 7269 6f72 6974 6965 t_file_prioritie │ │ │ +00055370: 7328 2920 636f 6e73 740a 097b 0a09 0961 s() const..{...a │ │ │ +00055380: 7578 3a3a 7665 6374 6f72 266c 743b 646f ux::vector<do │ │ │ +00055390: 776e 6c6f 6164 5f70 7269 6f72 6974 795f wnload_priority_ │ │ │ +000553a0: 742c 2066 696c 655f 696e 6465 785f 7426 t, file_index_t& │ │ │ +000553b0: 6774 3b20 7265 743b 0a09 0961 7574 6f2a gt; ret;...auto* │ │ │ +000553c0: 2063 6f6e 7374 2072 6574 7020 3d20 2661 const retp = &a │ │ │ +000553d0: 6d70 3b72 6574 3b0a 0909 7379 6e63 5f63 mp;ret;...sync_c │ │ │ +000553e0: 616c 6c28 2661 6d70 3b61 7578 3a3a 746f all(&aux::to │ │ │ +000553f0: 7272 656e 743a 3a66 696c 655f 7072 696f rrent::file_prio │ │ │ +00055400: 7269 7469 6573 2c20 7265 7470 293b 0a09 rities, retp);.. │ │ │ +00055410: 0972 6574 7572 6e20 544f 5252 454e 545f .return TORRENT_ │ │ │ +00055420: 5256 4f28 7265 7429 3b0a 097d 0a0a 2369 RVO(ret);..}..#i │ │ │ +00055430: 6620 544f 5252 454e 545f 4142 495f 5645 f TORRENT_ABI_VE │ │ │ +00055440: 5253 494f 4e20 3d3d 2031 0a0a 2f2f 203d RSION == 1..// = │ │ │ +00055450: 3d3d 3d3d 3d3d 3d3d 3d3d 3d20 7374 6172 =========== star │ │ │ +00055460: 7420 6465 7072 6563 6174 696f 6e20 3d3d t deprecation == │ │ │ +00055470: 3d3d 3d3d 3d3d 3d3d 3d3d 3d3d 3d0a 0a09 =============... │ │ │ +00055480: 766f 6964 2074 6f72 7265 6e74 5f68 616e void torrent_han │ │ │ +00055490: 646c 653a 3a70 7269 6f72 6974 697a 655f dle::prioritize_ │ │ │ +000554a0: 6669 6c65 7328 7374 643a 3a76 6563 746f files(std::vecto │ │ │ +000554b0: 7226 6c74 3b69 6e74 2667 743b 2063 6f6e r<int> con │ │ │ +000554c0: 7374 2661 6d70 3b20 6669 6c65 7329 2063 st& files) c │ │ │ +000554d0: 6f6e 7374 0a09 7b0a 0909 6175 783a 3a76 onst..{...aux::v │ │ │ +000554e0: 6563 746f 7226 6c74 3b64 6f77 6e6c 6f61 ector<downloa │ │ │ +000554f0: 645f 7072 696f 7269 7479 5f74 2c20 6669 d_priority_t, fi │ │ │ +00055500: 6c65 5f69 6e64 6578 5f74 2667 743b 2066 le_index_t> f │ │ │ +00055510: 696c 655f 7072 696f 3b0a 0909 6669 6c65 ile_prio;...file │ │ │ +00055520: 5f70 7269 6f2e 7265 7365 7276 6528 6669 _prio.reserve(fi │ │ │ +00055530: 6c65 732e 7369 7a65 2829 293b 0a09 0966 les.size());...f │ │ │ +00055540: 6f72 2028 6175 746f 2063 6f6e 7374 2070 or (auto const p │ │ │ +00055550: 203a 2066 696c 6573 2920 7b0a 0909 0966 : files) {....f │ │ │ +00055560: 696c 655f 7072 696f 2e70 7573 685f 6261 ile_prio.push_ba │ │ │ +00055570: 636b 2864 6f77 6e6c 6f61 645f 7072 696f ck(download_prio │ │ │ +00055580: 7269 7479 5f74 2873 7461 7469 635f 6361 rity_t(static_ca │ │ │ +00055590: 7374 266c 743b 7374 643a 3a75 696e 7438 st<std::uint8 │ │ │ +000555a0: 5f74 2667 743b 2870 2929 293b 0a09 097d _t>(p)));...} │ │ │ +000555b0: 0a09 0961 7379 6e63 5f63 616c 6c28 2661 ...async_call(&a │ │ │ +000555c0: 6d70 3b61 7578 3a3a 746f 7272 656e 743a mp;aux::torrent: │ │ │ +000555d0: 3a70 7269 6f72 6974 697a 655f 6669 6c65 :prioritize_file │ │ │ +000555e0: 732c 2066 696c 655f 7072 696f 293b 0a3c s, file_prio);.< │ │ │ +000555f0: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +00055600: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +00055610: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +00055620: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +00055630: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ +00055660: 2f74 6f72 7265 6e74 5f68 616e 646c 652e /torrent_handle. │ │ │ +00055670: 6370 703a 3834 333c 2f61 3e3c 2f74 643e cpp:843 │ │ │ +00055680: 3c74 643e 6465 7072 6563 6174 6520 7468 deprecate th │ │ │ +00055690: 6520 6f76 6572 6c6f 6164 2074 6861 7420 e overload that │ │ │ +000556a0: 7461 6b65 7320 616e 2069 6e64 6578 3c2f takes an index

    depr │ │ │ +00055700: 6563 6174 6520 7468 6520 6f76 6572 6c6f ecate the overlo │ │ │ +00055710: 6164 2074 6861 7420 7461 6b65 7320 616e ad that takes an │ │ │ +00055720: 2069 6e64 6578 3c2f 6832 3e3c 6834 3e2e index

    . │ │ │ +00055730: 2e2f 7372 632f 746f 7272 656e 745f 6861 ./src/torrent_ha │ │ │ +00055740: 6e64 6c65 2e63 7070 3a38 3433 3c2f 6834 ndle.cpp:843

    ...au
    │ │ │ +00055790: 746f 2074 203d 206d 5f74 6f72 7265 6e74  to t = m_torrent
    │ │ │ +000557a0: 2e6c 6f63 6b28 293b 0a09 0969 6620 2821  .lock();...if (!
    │ │ │ +000557b0: 7420 7c7c 2021 742d 2667 743b 6861 735f  t || !t->has_
    │ │ │ +000557c0: 7374 6f72 6167 6528 2929 2072 6574 7572  storage()) retur
    │ │ │ +000557d0: 6e3b 0a09 0961 7574 6f26 616d 703b 2073  n;...auto& s
    │ │ │ +000557e0: 6573 203d 2073 7461 7469 635f 6361 7374  es = static_cast
    │ │ │ +000557f0: 266c 743b 7365 7373 696f 6e5f 696d 706c  <session_impl
    │ │ │ +00055800: 2661 6d70 3b26 6774 3b28 742d 2667 743b  &>(t->
    │ │ │ +00055810: 7365 7373 696f 6e28 2929 3b0a 0909 7374  session());...st
    │ │ │ +00055820: 6174 7573 203d 2073 6573 2e64 6973 6b5f  atus = ses.disk_
    │ │ │ +00055830: 7468 7265 6164 2829 2e67 6574 5f73 7461  thread().get_sta
    │ │ │ +00055840: 7475 7328 742d 2667 743b 7374 6f72 6167  tus(t->storag
    │ │ │ +00055850: 6528 2929 3b0a 097d 0a23 656e 6469 660a  e());..}.#endif.
    │ │ │ +00055860: 0a09 766f 6964 2074 6f72 7265 6e74 5f68  ..void torrent_h
    │ │ │ +00055870: 616e 646c 653a 3a66 6f72 6365 5f64 6874  andle::force_dht
    │ │ │ +00055880: 5f61 6e6e 6f75 6e63 6528 2920 636f 6e73  _announce() cons
    │ │ │ +00055890: 740a 097b 0a23 6966 6e64 6566 2054 4f52  t..{.#ifndef TOR
    │ │ │ +000558a0: 5245 4e54 5f44 4953 4142 4c45 5f44 4854  RENT_DISABLE_DHT
    │ │ │ +000558b0: 0a09 0961 7379 6e63 5f63 616c 6c28 2661  ...async_call(&a
    │ │ │ +000558c0: 6d70 3b61 7578 3a3a 746f 7272 656e 743a  mp;aux::torrent:
    │ │ │ +000558d0: 3a64 6874 5f61 6e6e 6f75 6e63 6529 3b0a  :dht_announce);.
    │ │ │ +000558e0: 2365 6e64 6966 0a09 7d0a 0a09 766f 6964  #endif..}...void
    │ │ │ +000558f0: 2074 6f72 7265 6e74 5f68 616e 646c 653a   torrent_handle:
    │ │ │ +00055900: 3a66 6f72 6365 5f6c 7364 5f61 6e6e 6f75  :force_lsd_annou
    │ │ │ +00055910: 6e63 6528 2920 636f 6e73 740a 097b 0a09  nce() const..{..
    │ │ │ +00055920: 0961 7379 6e63 5f63 616c 6c28 2661 6d70  .async_call(&
    │ │ │ +00055930: 3b61 7578 3a3a 746f 7272 656e 743a 3a6c  ;aux::torrent::l
    │ │ │ +00055940: 7364 5f61 6e6e 6f75 6e63 6529 3b0a 097d  sd_announce);..}
    │ │ │ +00055950: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +00055980: 0976 6f69 6420 746f 7272 656e 745f 6861 .void torrent_ha │ │ │ +00055990: 6e64 6c65 3a3a 666f 7263 655f 7265 616e ndle::force_rean │ │ │ +000559a0: 6e6f 756e 6365 2869 6e74 2063 6f6e 7374 nounce(int const │ │ │ +000559b0: 2073 2c20 696e 7420 636f 6e73 7420 6964 s, int const id │ │ │ +000559c0: 782c 2072 6561 6e6e 6f75 6e63 655f 666c x, reannounce_fl │ │ │ +000559d0: 6167 735f 7420 636f 6e73 7420 666c 6167 ags_t const flag │ │ │ +000559e0: 7329 2063 6f6e 7374 0a3c 2f64 6976 3e09 s) const.
    . │ │ │ +000559f0: 7b0a 0909 6173 796e 635f 6361 6c6c 2826 {...async_call(& │ │ │ +00055a00: 616d 703b 6175 783a 3a74 6f72 7265 6e74 amp;aux::torrent │ │ │ +00055a10: 3a3a 666f 7263 655f 7472 6163 6b65 725f ::force_tracker_ │ │ │ +00055a20: 7265 7175 6573 742c 2061 7578 3a3a 7469 request, aux::ti │ │ │ +00055a30: 6d65 5f6e 6f77 2829 202b 2073 6563 6f6e me_now() + secon │ │ │ +00055a40: 6473 2873 292c 2069 6478 2c20 666c 6167 ds(s), idx, flag │ │ │ +00055a50: 7329 3b0a 097d 0a0a 0976 6f69 6420 746f s);..}...void to │ │ │ +00055a60: 7272 656e 745f 6861 6e64 6c65 3a3a 666f rrent_handle::fo │ │ │ +00055a70: 7263 655f 7265 616e 6e6f 756e 6365 2869 rce_reannounce(i │ │ │ +00055a80: 6e74 2063 6f6e 7374 2073 2c20 7374 643a nt const s, std: │ │ │ +00055a90: 3a73 7472 696e 6720 636f 6e73 7426 616d :string const&am │ │ │ +00055aa0: 703b 2075 726c 2c20 7265 616e 6e6f 756e p; url, reannoun │ │ │ +00055ab0: 6365 5f66 6c61 6773 5f74 2063 6f6e 7374 ce_flags_t const │ │ │ +00055ac0: 2066 6c61 6773 2920 636f 6e73 740a 097b flags) const..{ │ │ │ +00055ad0: 0a09 0961 7379 6e63 5f63 616c 6c28 2661 ...async_call(&a │ │ │ +00055ae0: 6d70 3b61 7578 3a3a 746f 7272 656e 743a mp;aux::torrent: │ │ │ +00055af0: 3a66 6f72 6365 5f74 7261 636b 6572 5f72 :force_tracker_r │ │ │ +00055b00: 6571 7565 7374 5f75 726c 2c20 6175 783a equest_url, aux: │ │ │ +00055b10: 3a74 696d 655f 6e6f 7728 2920 2b20 7365 :time_now() + se │ │ │ +00055b20: 636f 6e64 7328 7329 2c20 7572 6c2c 2066 conds(s), url, f │ │ │ +00055b30: 6c61 6773 293b 0a09 7d0a 0a09 766f 6964 lags);..}...void │ │ │ +00055b40: 2074 6f72 7265 6e74 5f68 616e 646c 653a torrent_handle: │ │ │ +00055b50: 3a66 6f72 6365 5f72 6561 6e6e 6f75 6e63 :force_reannounc │ │ │ +00055b60: 6528 696e 7420 636f 6e73 7420 732c 2072 e(int const s, r │ │ │ +00055b70: 6561 6e6e 6f75 6e63 655f 666c 6167 735f eannounce_flags_ │ │ │ +00055b80: 7420 636f 6e73 7420 666c 6167 7329 2063 t const flags) c │ │ │ +00055b90: 6f6e 7374 0a09 7b0a 0909 6173 796e 635f onst..{...async_ │ │ │ +00055ba0: 6361 6c6c 2826 616d 703b 6175 783a 3a74 call(&aux::t │ │ │ +00055bb0: 6f72 7265 6e74 3a3a 666f 7263 655f 7472 orrent::force_tr │ │ │ +00055bc0: 6163 6b65 725f 7265 7175 6573 742c 2061 acker_request, a │ │ │ +00055bd0: 7578 3a3a 7469 6d65 5f6e 6f77 2829 202b ux::time_now() + │ │ │ +00055be0: 2073 6563 6f6e 6473 2873 292c 202d 312c seconds(s), -1, │ │ │ +00055bf0: 2066 6c61 6773 293b 0a09 7d0a 0a09 7374 flags);..}...st │ │ │ +00055c00: 643a 3a76 6563 746f 7226 6c74 3b6f 7065 d::vector<ope │ │ │ +00055c10: 6e5f 6669 6c65 5f73 7461 7465 2667 743b n_file_state> │ │ │ +00055c20: 2074 6f72 7265 6e74 5f68 616e 646c 653a torrent_handle: │ │ │ +00055c30: 3a66 696c 655f 7374 6174 7573 2829 2063 :file_status() c │ │ │ +00055c40: 6f6e 7374 0a09 7b0a 0909 6175 746f 2074 onst..{...auto t │ │ │ +00055c50: 203d 206d 5f74 6f72 7265 6e74 2e6c 6f63 = m_torrent.loc │ │ │ +00055c60: 6b28 293b 0a09 0969 6620 2821 7420 7c7c k();...if (!t || │ │ │ +00055c70: 2021 742d 2667 743b 6861 735f 7374 6f72 !t->has_stor │ │ │ +00055c80: 6167 6528 2929 2072 6574 7572 6e20 7b7d age()) return {} │ │ │ +00055c90: 3b0a 0909 6175 746f 2661 6d70 3b20 7365 ;...auto& se │ │ │ +00055ca0: 7320 3d20 7374 6174 6963 5f63 6173 7426 s = static_cast& │ │ │ +00055cb0: 6c74 3b73 6573 7369 6f6e 5f69 6d70 6c26 lt;session_impl& │ │ │ +00055cc0: 616d 703b 2667 743b 2874 2d26 6774 3b73 amp;>(t->s │ │ │ +00055cd0: 6573 7369 6f6e 2829 293b 0a09 0972 6574 ession());...ret │ │ │ +00055ce0: 7572 6e20 7365 732e 6469 736b 5f74 6872 urn ses.disk_thr │ │ │ +00055cf0: 6561 6428 292e 6765 745f 7374 6174 7573 ead().get_status │ │ │ +00055d00: 2874 2d26 6774 3b73 746f 7261 6765 2829 (t->storage() │ │ │ +00055d10: 293b 0a09 7d0a 0a09 766f 6964 2074 6f72 );..}...void tor │ │ │ +00055d20: 7265 6e74 5f68 616e 646c 653a 3a70 6f73 rent_handle::pos │ │ │ +00055d30: 745f 6669 6c65 5f73 7461 7475 7328 2920 t_file_status() │ │ │ +00055d40: 636f 6e73 740a 097b 0a09 0961 7379 6e63 const..{...async │ │ │ +00055d50: 5f63 616c 6c28 2661 6d70 3b61 7578 3a3a _call(&aux:: │ │ │ +00055d60: 746f 7272 656e 743a 3a70 6f73 745f 6669 torrent::post_fi │ │ │ +00055d70: 6c65 5f73 7461 7475 7329 3b0a 097d 0a0a le_status);..}.. │ │ │ +00055d80: 0976 6f69 6420 746f 7272 656e 745f 6861 .void torrent_ha │ │ │ +00055d90: 6e64 6c65 3a3a 7363 7261 7065 5f74 7261 ndle::scrape_tra │ │ │ +00055da0: 636b 6572 2869 6e74 2069 6478 2920 636f cker(int idx) co │ │ │ +00055db0: 6e73 740a 097b 0a09 0961 7379 6e63 5f63 nst..{...async_c │ │ │ +00055dc0: 616c 6c28 2661 6d70 3b61 7578 3a3a 746f all(&aux::to │ │ │ +00055dd0: 7272 656e 743a 3a73 6372 6170 655f 7472 rrent::scrape_tr │ │ │ +00055de0: 6163 6b65 722c 2069 6478 2c20 7472 7565 acker, idx, true │ │ │ +00055df0: 293b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f );.
    │ │ │ +00055e20: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00055e30: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +00055e60: 2f73 7263 2f70 6172 745f 6669 6c65 2e63 /src/part_file.c │ │ │ +00055e70: 7070 3a32 3934 3c2f 613e 3c2f 7464 3e3c pp:294< │ │ │ +00055e80: 7464 3e77 6861 7420 646f 2077 6520 646f td>what do we do │ │ │ +00055e90: 2069 6620 736f 6d65 6f6e 6520 6973 2063 if someone is c │ │ │ +00055ea0: 7572 7265 6e74 6c79 2072 6561 6469 6e67 urrently reading │ │ │ +00055eb0: 2066 726f 6d20 7468 6520 6469 736b 2066 from the disk f │ │ │ +00055ec0: 726f 6d20 7468 6973 2070 6965 6365 3f20 rom this piece? │ │ │ +00055ed0: 646f 6573 2069 7420 6d61 7474 6572 3f20 does it matter? │ │ │ +00055ee0: 5369 6e63 6520 7765 2077 6f6e 2774 2061 Since we won't a │ │ │ +00055ef0: 6374 6976 656c 7920 6572 6173 6520 7468 ctively erase th │ │ │ +00055f00: 6520 6461 7461 2066 726f 6d20 6469 736b e data from disk │ │ │ +00055f10: 2c20 6275 7420 6974 206d 6179 2062 6520 , but it may be │ │ │ +00055f20: 6f76 6572 7772 6974 7465 6e20 736f 6f6e overwritten soon │ │ │ +00055f30: 2c20 6974 2773 2070 726f 6261 626c 7920 , it's probably │ │ │ +00055f40: 6e6f 7420 7468 6174 2062 6967 206f 6620 not that big of │ │ │ +00055f50: 6120 6465 616c 3c2f 7464 3e3c 2f74 723e a deal │ │ │ +00055f60: 3c74 7220 6964 3d22 3230 3122 2073 7479 │ │ │ +00055f90: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +00055fa0: 3c68 323e 7768 6174 2064 6f20 7765 2064

    what do we d │ │ │ +00055fb0: 6f20 6966 2073 6f6d 656f 6e65 2069 7320 o if someone is │ │ │ +00055fc0: 6375 7272 656e 746c 7920 7265 6164 696e currently readin │ │ │ +00055fd0: 6720 6672 6f6d 2074 6865 2064 6973 6b0a g from the disk. │ │ │ +00055fe0: 6672 6f6d 2074 6869 7320 7069 6563 653f from this piece? │ │ │ +00055ff0: 2064 6f65 7320 6974 206d 6174 7465 723f does it matter? │ │ │ +00056000: 2053 696e 6365 2077 6520 776f 6e27 7420 Since we won't │ │ │ +00056010: 6163 7469 7665 6c79 2065 7261 7365 2074 actively erase t │ │ │ +00056020: 6865 0a64 6174 6120 6672 6f6d 2064 6973 he.data from dis │ │ │ +00056030: 6b2c 2062 7574 2069 7420 6d61 7920 6265 k, but it may be │ │ │ +00056040: 206f 7665 7277 7269 7474 656e 2073 6f6f overwritten soo │ │ │ +00056050: 6e2c 2069 7427 7320 7072 6f62 6162 6c79 n, it's probably │ │ │ +00056060: 206e 6f74 2074 6861 740a 6269 6720 6f66 not that.big of │ │ │ +00056070: 2061 2064 6561 6c3c 2f68 323e 3c68 343e a deal

    │ │ │ +00056080: 2e2e 2f73 7263 2f70 6172 745f 6669 6c65 ../src/part_file │ │ │ +00056090: 2e63 7070 3a32 3934 3c2f 6834 3e3c 7072 .cpp:294

    ....creat │ │ │ +000560e0: 655f 6469 7265 6374 6f72 6965 7328 6d5f e_directories(m_ │ │ │ +000560f0: 7061 7468 2c20 6563 293b 0a09 0909 0969 path, ec);.....i │ │ │ +00056100: 6620 2865 6329 2072 6574 7572 6e20 7b7d f (ec) return {} │ │ │ +00056110: 3b0a 0909 0909 7265 7475 726e 207b 666e ;.....return {fn │ │ │ +00056120: 2c20 302c 206d 6f64 657d 3b0a 0909 097d , 0, mode};....} │ │ │ +00056130: 0a09 0909 7265 7475 726e 207b 7d3b 0a09 ....return {};.. │ │ │ +00056140: 097d 0a09 7d0a 0963 6174 6368 2028 7374 .}..}..catch (st │ │ │ +00056150: 6f72 6167 655f 6572 726f 7220 636f 6e73 orage_error cons │ │ │ +00056160: 7426 616d 703b 2065 290a 097b 0a09 0965 t& e)..{...e │ │ │ +00056170: 6320 3d20 652e 6563 3b0a 0909 7265 7475 c = e.ec;...retu │ │ │ +00056180: 726e 207b 7d3b 0a09 7d0a 0a09 766f 6964 rn {};..}...void │ │ │ +00056190: 2070 6172 745f 6669 6c65 3a3a 6672 6565 part_file::free │ │ │ +000561a0: 5f70 6965 6365 2870 6965 6365 5f69 6e64 _piece(piece_ind │ │ │ +000561b0: 6578 5f74 2063 6f6e 7374 2070 6965 6365 ex_t const piece │ │ │ +000561c0: 290a 097b 0a09 0973 7464 3a3a 6c6f 636b )..{...std::lock │ │ │ +000561d0: 5f67 7561 7264 266c 743b 7374 643a 3a6d _guard<std::m │ │ │ +000561e0: 7574 6578 2667 743b 206c 286d 5f6d 7574 utex> l(m_mut │ │ │ +000561f0: 6578 293b 0a0a 0909 6175 746f 2063 6f6e ex);....auto con │ │ │ +00056200: 7374 2069 203d 206d 5f70 6965 6365 5f6d st i = m_piece_m │ │ │ +00056210: 6170 2e66 696e 6428 7069 6563 6529 3b0a ap.find(piece);. │ │ │ +00056220: 0909 6966 2028 6920 3d3d 206d 5f70 6965 ..if (i == m_pie │ │ │ +00056230: 6365 5f6d 6170 2e65 6e64 2829 2920 7265 ce_map.end()) re │ │ │ +00056240: 7475 726e 3b0a 0a3c 6469 7620 7374 796c turn;..
    .
    ..m_ │ │ │ +00056280: 6672 6565 5f73 6c6f 7473 2e70 7573 685f free_slots.push_ │ │ │ +00056290: 6261 636b 2869 2d26 6774 3b73 6563 6f6e back(i->secon │ │ │ +000562a0: 6429 3b0a 0909 6d5f 7069 6563 655f 6d61 d);...m_piece_ma │ │ │ +000562b0: 702e 6572 6173 6528 6929 3b0a 0909 6d5f p.erase(i);...m_ │ │ │ +000562c0: 6469 7274 795f 6d65 7461 6461 7461 203d dirty_metadata = │ │ │ +000562d0: 2074 7275 653b 0a09 7d0a 0a09 766f 6964 true;..}...void │ │ │ +000562e0: 2070 6172 745f 6669 6c65 3a3a 6d6f 7665 part_file::move │ │ │ +000562f0: 5f70 6172 7466 696c 6528 7374 643a 3a73 _partfile(std::s │ │ │ +00056300: 7472 696e 6720 636f 6e73 7426 616d 703b tring const& │ │ │ +00056310: 2070 6174 682c 2065 7272 6f72 5f63 6f64 path, error_cod │ │ │ +00056320: 6526 616d 703b 2065 6329 0a09 7b0a 0909 e& ec)..{... │ │ │ +00056330: 7374 643a 3a6c 6f63 6b5f 6775 6172 6426 std::lock_guard& │ │ │ +00056340: 6c74 3b73 7464 3a3a 6d75 7465 7826 6774 lt;std::mutex> │ │ │ +00056350: 3b20 6c28 6d5f 6d75 7465 7829 3b0a 0a09 ; l(m_mutex);... │ │ │ +00056360: 0966 6c75 7368 5f6d 6574 6164 6174 615f .flush_metadata_ │ │ │ +00056370: 696d 706c 2865 6329 3b0a 0909 6966 2028 impl(ec);...if ( │ │ │ +00056380: 6563 2920 7265 7475 726e 3b0a 0a09 0969 ec) return;....i │ │ │ +00056390: 6620 2821 6d5f 7069 6563 655f 6d61 702e f (!m_piece_map. │ │ │ +000563a0: 656d 7074 7928 2929 0a09 097b 0a09 0909 empty())...{.... │ │ │ +000563b0: 7374 643a 3a73 7472 696e 6720 6f6c 645f std::string old_ │ │ │ +000563c0: 7061 7468 203d 2063 6f6d 6269 6e65 5f70 path = combine_p │ │ │ +000563d0: 6174 6828 6d5f 7061 7468 2c20 6d5f 6e61 ath(m_path, m_na │ │ │ +000563e0: 6d65 293b 0a09 0909 7374 643a 3a73 7472 me);....std::str │ │ │ +000563f0: 696e 6720 6e65 775f 7061 7468 203d 2063 ing new_path = c │ │ │ +00056400: 6f6d 6269 6e65 5f70 6174 6828 7061 7468 ombine_path(path │ │ │ +00056410: 2c20 6d5f 6e61 6d65 293b 0a0a 0909 0972 , m_name);.....r │ │ │ +00056420: 656e 616d 6528 6f6c 645f 7061 7468 2c20 ename(old_path, │ │ │ +00056430: 6e65 775f 7061 7468 2c20 6563 293b 0a09 new_path, ec);.. │ │ │ +00056440: 0909 6966 2028 6563 203d 3d20 626f 6f73 ..if (ec == boos │ │ │ +00056450: 743a 3a73 7973 7465 6d3a 3a65 7272 633a t::system::errc: │ │ │ +00056460: 3a6e 6f5f 7375 6368 5f66 696c 655f 6f72 :no_such_file_or │ │ │ +00056470: 5f64 6972 6563 746f 7279 290a 0909 0909 _directory)..... │ │ │ +00056480: 6563 2e63 6c65 6172 2829 3b0a 0a09 0909 ec.clear();..... │ │ │ +00056490: 6966 2028 6563 290a 0909 097b 0a09 0909 if (ec)....{.... │ │ │ +000564a0: 0973 746f 7261 6765 5f65 7272 6f72 2073 .storage_error s │ │ │ +000564b0: 653b 0a09 0909 0961 7578 3a3a 636f 7079 e;.....aux::copy │ │ │ +000564c0: 5f66 696c 6528 6f6c 645f 7061 7468 2c20 _file(old_path, │ │ │ +000564d0: 6e65 775f 7061 7468 2c20 7365 293b 0a09 new_path, se);.. │ │ │ +000564e0: 0909 0965 6320 3d20 7365 2e65 633b 0a09 ...ec = se.ec;.. │ │ │ +000564f0: 0909 0969 6620 2865 6329 2072 6574 7572 ...if (ec) retur │ │ │ +00056500: 6e3b 0a09 0909 0972 656d 6f76 6528 6f6c n;.....remove(ol │ │ │ +00056510: 645f 7061 7468 2c20 6563 293b 0a09 0909 d_path, ec);.... │ │ │ +00056520: 7d0a 0909 7d0a 3c2f 7072 653e 3c2f 7464 }...}.
    relevance │ │ │ +00056560: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +00056570: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/part_fil │ │ │ +000565a0: 652e 6370 703a 3430 353c 2f61 3e3c 2f74 e.cpp:405instead of │ │ │ +000565c0: 2072 6562 7569 6c64 696e 6720 7468 6520 rebuilding the │ │ │ +000565d0: 7768 6f6c 6520 6669 6c65 2068 6561 6465 whole file heade │ │ │ +000565e0: 7220 616e 6420 666c 7573 6869 6e67 2069 r and flushing i │ │ │ +000565f0: 742c 2075 7064 6174 6520 7468 6520 736c t, update the sl │ │ │ +00056600: 6f74 2065 6e74 7269 6573 2061 7320 7765 ot entries as we │ │ │ +00056610: 2067 6f3c 2f74 643e 3c2f 7472 3e3c 7472 go

    instead of rebu │ │ │ +00056670: 696c 6469 6e67 2074 6865 2077 686f 6c65 ilding the whole │ │ │ +00056680: 2066 696c 6520 6865 6164 6572 0a61 6e64 file header.and │ │ │ +00056690: 2066 6c75 7368 696e 6720 6974 2c20 7570 flushing it, up │ │ │ +000566a0: 6461 7465 2074 6865 2073 6c6f 7420 656e date the slot en │ │ │ +000566b0: 7472 6965 7320 6173 2077 6520 676f 3c2f tries as we go

    ../src/pa │ │ │ +000566d0: 7274 5f66 696c 652e 6370 703a 3430 353c rt_file.cpp:405< │ │ │ +000566e0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +00056720: 0909 0909 544f 5252 454e 545f 4153 5345  ....TORRENT_ASSE
    │ │ │ +00056730: 5254 286a 2d26 6774 3b73 6563 6f6e 6420  RT(j->second 
    │ │ │ +00056740: 3d3d 2073 6c6f 7429 3b0a 0909 0909 0909  == slot);.......
    │ │ │ +00056750: 6d5f 6672 6565 5f73 6c6f 7473 2e70 7573  m_free_slots.pus
    │ │ │ +00056760: 685f 6261 636b 286a 2d26 6774 3b73 6563  h_back(j->sec
    │ │ │ +00056770: 6f6e 6429 3b0a 0909 0909 0909 6d5f 7069  ond);.......m_pi
    │ │ │ +00056780: 6563 655f 6d61 702e 6572 6173 6528 6a29  ece_map.erase(j)
    │ │ │ +00056790: 3b0a 0909 0909 0909 6d5f 6469 7274 795f  ;.......m_dirty_
    │ │ │ +000567a0: 6d65 7461 6461 7461 203d 2074 7275 653b  metadata = true;
    │ │ │ +000567b0: 0a09 0909 0909 7d0a 0909 0909 7d0a 0909  ......}.....}...
    │ │ │ +000567c0: 097d 0a09 0909 6669 6c65 5f6f 6666 7365  .}....file_offse
    │ │ │ +000567d0: 7420 2b3d 2062 6c6f 636b 5f74 6f5f 636f  t += block_to_co
    │ │ │ +000567e0: 7079 3b0a 0909 0970 6965 6365 5f6f 6666  py;....piece_off
    │ │ │ +000567f0: 7365 7420 3d20 303b 0a09 0909 7369 7a65  set = 0;....size
    │ │ │ +00056800: 202d 3d20 626c 6f63 6b5f 746f 5f63 6f70   -= block_to_cop
    │ │ │ +00056810: 793b 0a09 097d 0a09 7d0a 0a09 766f 6964  y;...}..}...void
    │ │ │ +00056820: 2070 6172 745f 6669 6c65 3a3a 666c 7573   part_file::flus
    │ │ │ +00056830: 685f 6d65 7461 6461 7461 2865 7272 6f72  h_metadata(error
    │ │ │ +00056840: 5f63 6f64 6526 616d 703b 2065 6329 0a09  _code& ec)..
    │ │ │ +00056850: 7b0a 0909 7374 643a 3a6c 6f63 6b5f 6775  {...std::lock_gu
    │ │ │ +00056860: 6172 6426 6c74 3b73 7464 3a3a 6d75 7465  ard<std::mute
    │ │ │ +00056870: 7826 6774 3b20 6c28 6d5f 6d75 7465 7829  x> l(m_mutex)
    │ │ │ +00056880: 3b0a 0a09 0966 6c75 7368 5f6d 6574 6164  ;....flush_metad
    │ │ │ +00056890: 6174 615f 696d 706c 2865 6329 3b0a 097d  ata_impl(ec);..}
    │ │ │ +000568a0: 0a0a 3c64 6976 2073 7479 6c65 3d22 6261  ..
    │ │ │ +000568d0: 0976 6f69 6420 7061 7274 5f66 696c 653a .void part_file: │ │ │ +000568e0: 3a66 6c75 7368 5f6d 6574 6164 6174 615f :flush_metadata_ │ │ │ +000568f0: 696d 706c 2865 7272 6f72 5f63 6f64 6526 impl(error_code& │ │ │ +00056900: 616d 703b 2065 6329 0a3c 2f64 6976 3e09 amp; ec).
    . │ │ │ +00056910: 7b0a 0909 2f2f 2064 6f20 7765 206e 6565 {...// do we nee │ │ │ +00056920: 6420 746f 2066 6c75 7368 2074 6865 206d d to flush the m │ │ │ +00056930: 6574 6164 6174 613f 0a09 0969 6620 286d etadata?...if (m │ │ │ +00056940: 5f64 6972 7479 5f6d 6574 6164 6174 6120 _dirty_metadata │ │ │ +00056950: 3d3d 2066 616c 7365 2920 7265 7475 726e == false) return │ │ │ +00056960: 3b0a 0a09 0969 6620 286d 5f70 6965 6365 ;....if (m_piece │ │ │ +00056970: 5f6d 6170 2e65 6d70 7479 2829 290a 0909 _map.empty())... │ │ │ +00056980: 7b0a 0909 092f 2f20 6966 2077 6520 646f {....// if we do │ │ │ +00056990: 6e27 7420 6861 7665 2061 6e79 2070 6965 n't have any pie │ │ │ +000569a0: 6365 7320 6c65 6674 2069 6e20 7468 650a ces left in the. │ │ │ +000569b0: 0909 092f 2f20 7061 7274 2066 696c 652c ...// part file, │ │ │ +000569c0: 2072 656d 6f76 6520 6974 0a09 0909 7374 remove it....st │ │ │ +000569d0: 643a 3a73 7472 696e 6720 636f 6e73 7420 d::string const │ │ │ +000569e0: 7020 3d20 636f 6d62 696e 655f 7061 7468 p = combine_path │ │ │ +000569f0: 286d 5f70 6174 682c 206d 5f6e 616d 6529 (m_path, m_name) │ │ │ +00056a00: 3b0a 0909 0972 656d 6f76 6528 702c 2065 ;....remove(p, e │ │ │ +00056a10: 6329 3b0a 0a09 0909 6966 2028 6563 203d c);.....if (ec = │ │ │ +00056a20: 3d20 626f 6f73 743a 3a73 7973 7465 6d3a = boost::system: │ │ │ +00056a30: 3a65 7272 633a 3a6e 6f5f 7375 6368 5f66 :errc::no_such_f │ │ │ +00056a40: 696c 655f 6f72 5f64 6972 6563 746f 7279 ile_or_directory │ │ │ +00056a50: 290a 0909 0909 6563 2e63 6c65 6172 2829 ).....ec.clear() │ │ │ +00056a60: 3b0a 0909 0972 6574 7572 6e3b 0a09 097d ;....return;...} │ │ │ +00056a70: 0a0a 0909 6175 746f 2066 203d 206f 7065 ....auto f = ope │ │ │ +00056a80: 6e5f 6669 6c65 2861 7578 3a3a 6f70 656e n_file(aux::open │ │ │ +00056a90: 5f6d 6f64 653a 3a77 7269 7465 207c 2061 _mode::write | a │ │ │ +00056aa0: 7578 3a3a 6f70 656e 5f6d 6f64 653a 3a68 ux::open_mode::h │ │ │ +00056ab0: 6964 6465 6e2c 2065 6329 3b0a 0909 6966 idden, ec);...if │ │ │ +00056ac0: 2028 6563 2920 7265 7475 726e 3b0a 0a09 (ec) return;... │ │ │ +00056ad0: 0973 7464 3a3a 7665 6374 6f72 266c 743b .std::vector< │ │ │ +00056ae0: 6368 6172 2667 743b 2068 6561 6465 7228 char> header( │ │ │ +00056af0: 7374 6174 6963 5f63 6173 7426 6c74 3b73 static_cast<s │ │ │ +00056b00: 7464 3a3a 7369 7a65 5f74 2667 743b 286d td::size_t>(m │ │ │ +00056b10: 5f68 6561 6465 725f 7369 7a65 2929 3b0a _header_size));. │ │ │ +00056b20: 0a09 0975 7369 6e67 206e 616d 6573 7061 ...using namespa │ │ │ +00056b30: 6365 206c 6962 746f 7272 656e 743a 3a61 ce libtorrent::a │ │ │ +00056b40: 7578 3b0a 0a09 0963 6861 722a 2070 7472 ux;....char* ptr │ │ │ +00056b50: 203d 2068 6561 6465 722e 6461 7461 2829 = header.data() │ │ │ +00056b60: 3b0a 0909 7772 6974 655f 7569 6e74 3332 ;...write_uint32 │ │ │ +00056b70: 286d 5f6d 6178 5f70 6965 6365 732c 2070 (m_max_pieces, p │ │ │ +00056b80: 7472 293b 0a09 0977 7269 7465 5f75 696e tr);...write_uin │ │ │ +00056b90: 7433 3228 6d5f 7069 6563 655f 7369 7a65 t32(m_piece_size │ │ │ +00056ba0: 2c20 7074 7229 3b0a 0a09 0966 6f72 2028 , ptr);....for ( │ │ │ +00056bb0: 7069 6563 655f 696e 6465 785f 7420 7069 piece_index_t pi │ │ │ +00056bc0: 6563 6528 3029 3b20 7069 6563 6520 266c ece(0); piece &l │ │ │ +00056bd0: 743b 2070 6965 6365 5f69 6e64 6578 5f74 t; piece_index_t │ │ │ +00056be0: 286d 5f6d 6178 5f70 6965 6365 7329 3b20 (m_max_pieces); │ │ │ +00056bf0: 2b2b 7069 6563 6529 0a09 097b 0a09 0909 ++piece)...{.... │ │ │ +00056c00: 6175 746f 2063 6f6e 7374 2069 203d 206d auto const i = m │ │ │ +00056c10: 5f70 6965 6365 5f6d 6170 2e66 696e 6428 _piece_map.find( │ │ │ +00056c20: 7069 6563 6529 3b0a 3c2f 7072 653e 3c2f piece);.
    relevan │ │ │ +00056c60: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/add_to │ │ │ +00056ca0: 7272 656e 745f 7061 7261 6d73 2e63 7070 rrent_params.cpp │ │ │ +00056cb0: 3a33 313c 2f61 3e3c 2f74 643e 3c74 643e :31 │ │ │ +00056cc0: 6974 2077 6f75 6c64 2062 6520 6e69 6365 it would be nice │ │ │ +00056cd0: 2069 6620 7468 6973 2077 6173 206e 6f74 if this was not │ │ │ +00056ce0: 6872 6f77 2064 6566 6175 6c74 2063 6f6e hrow default con │ │ │ +00056cf0: 7374 7275 6374 6962 6c65 2073 7461 7469 structible stati │ │ │ +00056d00: 635f 6173 7365 7274 2873 7464 3a3a 6973 c_assert(std::is │ │ │ +00056d10: 5f6e 6f74 6872 6f77 5f64 6566 6175 6c74 _nothrow_default │ │ │ +00056d20: 5f63 6f6e 7374 7275 6374 6962 6c65 3c61 _constructible::value , "sho │ │ │ +00056d50: 756c 6420 6265 206e 6f74 6872 6f77 2064 uld be nothrow d │ │ │ +00056d60: 6566 6175 6c74 2063 6f6e 7374 7275 6374 efault construct │ │ │ +00056d70: 6962 6c65 2229 3b3c 2f74 643e 3c2f 7472 ible");

    it would be │ │ │ +00056dd0: 206e 6963 6520 6966 2074 6869 7320 7761 nice if this wa │ │ │ +00056de0: 7320 6e6f 7468 726f 7720 6465 6661 756c s nothrow defaul │ │ │ +00056df0: 7420 636f 6e73 7472 7563 7469 626c 650a t constructible. │ │ │ +00056e00: 7374 6174 6963 5f61 7373 6572 7428 7374 static_assert(st │ │ │ +00056e10: 643a 3a69 735f 6e6f 7468 726f 775f 6465 d::is_nothrow_de │ │ │ +00056e20: 6661 756c 745f 636f 6e73 7472 7563 7469 fault_constructi │ │ │ +00056e30: 626c 653c 6164 645f 746f 7272 656e 745f ble::value., │ │ │ +00056e50: 2022 7368 6f75 6c64 2062 6520 6e6f 7468 "should be noth │ │ │ +00056e60: 726f 7720 6465 6661 756c 7420 636f 6e73 row default cons │ │ │ +00056e70: 7472 7563 7469 626c 6522 293b 3c2f 6832 tructible");

    ../src/add_ │ │ │ +00056e90: 746f 7272 656e 745f 7061 7261 6d73 2e63 torrent_params.c │ │ │ +00056ea0: 7070 3a33 313c 2f68 343e 3c70 7265 2073 pp:31

    #include "li
    │ │ │ +00056ef0: 6274 6f72 7265 6e74 2f61 6464 5f74 6f72  btorrent/add_tor
    │ │ │ +00056f00: 7265 6e74 5f70 6172 616d 732e 6870 7022  rent_params.hpp"
    │ │ │ +00056f10: 0a0a 6e61 6d65 7370 6163 6520 6c69 6274  ..namespace libt
    │ │ │ +00056f20: 6f72 7265 6e74 207b 0a0a 0961 6464 5f74  orrent {...add_t
    │ │ │ +00056f30: 6f72 7265 6e74 5f70 6172 616d 733a 3a61  orrent_params::a
    │ │ │ +00056f40: 6464 5f74 6f72 7265 6e74 5f70 6172 616d  dd_torrent_param
    │ │ │ +00056f50: 7328 2920 3d20 6465 6661 756c 743b 0a09  s() = default;..
    │ │ │ +00056f60: 6164 645f 746f 7272 656e 745f 7061 7261  add_torrent_para
    │ │ │ +00056f70: 6d73 3a3a 7e61 6464 5f74 6f72 7265 6e74  ms::~add_torrent
    │ │ │ +00056f80: 5f70 6172 616d 7328 2920 3d20 6465 6661  _params() = defa
    │ │ │ +00056f90: 756c 743b 0a09 6164 645f 746f 7272 656e  ult;..add_torren
    │ │ │ +00056fa0: 745f 7061 7261 6d73 3a3a 6164 645f 746f  t_params::add_to
    │ │ │ +00056fb0: 7272 656e 745f 7061 7261 6d73 2861 6464  rrent_params(add
    │ │ │ +00056fc0: 5f74 6f72 7265 6e74 5f70 6172 616d 7326  _torrent_params&
    │ │ │ +00056fd0: 616d 703b 2661 6d70 3b29 206e 6f65 7863  amp;&) noexc
    │ │ │ +00056fe0: 6570 7420 3d20 6465 6661 756c 743b 0a09  ept = default;..
    │ │ │ +00056ff0: 6164 645f 746f 7272 656e 745f 7061 7261  add_torrent_para
    │ │ │ +00057000: 6d73 2661 6d70 3b20 6164 645f 746f 7272  ms& add_torr
    │ │ │ +00057010: 656e 745f 7061 7261 6d73 3a3a 6f70 6572  ent_params::oper
    │ │ │ +00057020: 6174 6f72 3d28 6164 645f 746f 7272 656e  ator=(add_torren
    │ │ │ +00057030: 745f 7061 7261 6d73 2661 6d70 3b26 616d  t_params&&am
    │ │ │ +00057040: 703b 2920 2661 6d70 3b20 6e6f 6578 6365  p;) & noexce
    │ │ │ +00057050: 7074 203d 2064 6566 6175 6c74 3b0a 0961  pt = default;..a
    │ │ │ +00057060: 6464 5f74 6f72 7265 6e74 5f70 6172 616d  dd_torrent_param
    │ │ │ +00057070: 733a 3a61 6464 5f74 6f72 7265 6e74 5f70  s::add_torrent_p
    │ │ │ +00057080: 6172 616d 7328 6164 645f 746f 7272 656e  arams(add_torren
    │ │ │ +00057090: 745f 7061 7261 6d73 2063 6f6e 7374 2661  t_params const&a
    │ │ │ +000570a0: 6d70 3b29 203d 2064 6566 6175 6c74 3b0a  mp;) = default;.
    │ │ │ +000570b0: 0961 6464 5f74 6f72 7265 6e74 5f70 6172  .add_torrent_par
    │ │ │ +000570c0: 616d 7326 616d 703b 2061 6464 5f74 6f72  ams& add_tor
    │ │ │ +000570d0: 7265 6e74 5f70 6172 616d 733a 3a6f 7065  rent_params::ope
    │ │ │ +000570e0: 7261 746f 723d 2861 6464 5f74 6f72 7265  rator=(add_torre
    │ │ │ +000570f0: 6e74 5f70 6172 616d 7320 636f 6e73 7426  nt_params const&
    │ │ │ +00057100: 616d 703b 2920 2661 6d70 3b20 3d20 6465  amp;) & = de
    │ │ │ +00057110: 6661 756c 743b 0a0a 0973 7461 7469 635f  fault;...static_
    │ │ │ +00057120: 6173 7365 7274 2873 7464 3a3a 6973 5f6e  assert(std::is_n
    │ │ │ +00057130: 6f74 6872 6f77 5f6d 6f76 655f 636f 6e73  othrow_move_cons
    │ │ │ +00057140: 7472 7563 7469 626c 6526 6c74 3b61 6464  tructible<add
    │ │ │ +00057150: 5f74 6f72 7265 6e74 5f70 6172 616d 7326  _torrent_params&
    │ │ │ +00057160: 6774 3b3a 3a76 616c 7565 0a09 092c 2022  gt;::value..., "
    │ │ │ +00057170: 7368 6f75 6c64 2062 6520 6e6f 7468 726f  should be nothro
    │ │ │ +00057180: 7720 6d6f 7665 2063 6f6e 7374 7275 6374  w move construct
    │ │ │ +00057190: 6962 6c65 2229 3b0a 0a09 7374 6174 6963  ible");...static
    │ │ │ +000571a0: 5f61 7373 6572 7428 7374 643a 3a69 735f  _assert(std::is_
    │ │ │ +000571b0: 6e6f 7468 726f 775f 6d6f 7665 5f63 6f6e  nothrow_move_con
    │ │ │ +000571c0: 7374 7275 6374 6962 6c65 266c 743b 7374  structible<st
    │ │ │ +000571d0: 643a 3a73 7472 696e 6726 6774 3b3a 3a76  d::string>::v
    │ │ │ +000571e0: 616c 7565 0a09 092c 2022 7368 6f75 6c64  alue..., "should
    │ │ │ +000571f0: 2062 6520 6e6f 7468 726f 7720 6d6f 7665   be nothrow move
    │ │ │ +00057200: 2063 6f6e 7374 7275 6374 6962 6c65 2229   constructible")
    │ │ │ +00057210: 3b0a 0a09 7374 6174 6963 5f61 7373 6572  ;...static_asser
    │ │ │ +00057220: 7428 7374 643a 3a69 735f 6e6f 7468 726f  t(std::is_nothro
    │ │ │ +00057230: 775f 6d6f 7665 5f61 7373 6967 6e61 626c  w_move_assignabl
    │ │ │ +00057240: 6526 6c74 3b61 6464 5f74 6f72 7265 6e74  e<add_torrent
    │ │ │ +00057250: 5f70 6172 616d 7326 6774 3b3a 3a76 616c  _params>::val
    │ │ │ +00057260: 7565 0a09 092c 2022 7368 6f75 6c64 2062  ue..., "should b
    │ │ │ +00057270: 6520 6e6f 7468 726f 7720 6d6f 7665 2061  e nothrow move a
    │ │ │ +00057280: 7373 6967 6e61 626c 6522 293b 0a0a 3c64  ssignable");...namespace aux
    │ │ │ +000572d0: 207b 0a0a 092f 2f20 7265 7475 726e 7320   {...// returns 
    │ │ │ +000572e0: 7768 6574 6865 7220 7468 6973 2061 6464  whether this add
    │ │ │ +000572f0: 5f74 6f72 7265 6e74 5f70 6172 616d 7320  _torrent_params 
    │ │ │ +00057300: 6f62 6a65 6374 2068 6173 2022 7265 7375  object has "resu
    │ │ │ +00057310: 6d65 2d64 6174 6122 2c20 692e 652e 0a09  me-data", i.e...
    │ │ │ +00057320: 2f2f 2069 6e66 6f72 6d61 7469 6f6e 2061  // information a
    │ │ │ +00057330: 626f 7574 2077 6869 6368 2070 6965 6365  bout which piece
    │ │ │ +00057340: 7320 7765 2068 6176 652e 0a09 626f 6f6c  s we have...bool
    │ │ │ +00057350: 2063 6f6e 7461 696e 735f 7265 7375 6d65   contains_resume
    │ │ │ +00057360: 5f64 6174 6128 6164 645f 746f 7272 656e  _data(add_torren
    │ │ │ +00057370: 745f 7061 7261 6d73 2063 6f6e 7374 2661  t_params const&a
    │ │ │ +00057380: 6d70 3b20 6174 7029 0a09 7b0a 0909 7265  mp; atp)..{...re
    │ │ │ +00057390: 7475 726e 2021 6174 702e 6861 7665 5f70  turn !atp.have_p
    │ │ │ +000573a0: 6965 6365 732e 656d 7074 7928 290a 0909  ieces.empty()...
    │ │ │ +000573b0: 097c 7c20 2861 7470 2e66 6c61 6773 2026  .|| (atp.flags &
    │ │ │ +000573c0: 616d 703b 2074 6f72 7265 6e74 5f66 6c61  amp; torrent_fla
    │ │ │ +000573d0: 6773 3a3a 7365 6564 5f6d 6f64 6529 3b0a  gs::seed_mode);.
    │ │ │ +000573e0: 097d 0a7d 0a0a 7d0a 3c2f 7072 653e 3c2f  .}.}..}.
    relevan │ │ │ +00057420: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0
    ../src/choker │ │ │ +00057460: 2e63 7070 3a32 3335 3c2f 613e 3c2f 7464 .cpp:235make config │ │ │ +00057480: 7572 6162 6c65 3c2f 7464 3e3c 2f74 723e urable │ │ │ +00057490: 3c74 7220 6964 3d22 3230 3422 2073 7479 │ │ │ +000574c0: 3c74 6420 636f 6c73 7061 6e3d 2233 223e │ │ │ +000574d0: 3c68 323e 6d61 6b65 2063 6f6e 6669 6775

    make configu │ │ │ +000574e0: 7261 626c 653c 2f68 323e 3c68 343e 2e2e rable

    .. │ │ │ +000574f0: 2f73 7263 2f63 686f 6b65 722e 6370 703a /src/choker.cpp: │ │ │ +00057500: 3233 353c 2f68 343e 3c70 7265 2073 7479 235

    ...// first re
    │ │ │ +00057550: 7365 7420 7468 6520 6e75 6d62 6572 206f  set the number o
    │ │ │ +00057560: 6620 756e 6368 6f6b 6520 736c 6f74 732c  f unchoke slots,
    │ │ │ +00057570: 2062 6563 6175 7365 2077 6527 6c6c 2063   because we'll c
    │ │ │ +00057580: 616c 6375 6c61 7465 0a09 0909 2f2f 2069  alculate....// i
    │ │ │ +00057590: 7420 7075 7265 6c79 2062 6173 6564 206f  t purely based o
    │ │ │ +000575a0: 6e20 7468 6520 6375 7272 656e 7420 7374  n the current st
    │ │ │ +000575b0: 6174 6520 6f66 206f 7572 2070 6565 7273  ate of our peers
    │ │ │ +000575c0: 2e0a 0909 0975 706c 6f61 645f 736c 6f74  .....upload_slot
    │ │ │ +000575d0: 7320 3d20 303b 0a0a 0909 0969 6e74 2072  s = 0;.....int r
    │ │ │ +000575e0: 6174 655f 7468 7265 7368 6f6c 6420 3d20  ate_threshold = 
    │ │ │ +000575f0: 7365 7474 2e67 6574 5f69 6e74 2873 6574  sett.get_int(set
    │ │ │ +00057600: 7469 6e67 735f 7061 636b 3a3a 7261 7465  tings_pack::rate
    │ │ │ +00057610: 5f63 686f 6b65 725f 696e 6974 6961 6c5f  _choker_initial_
    │ │ │ +00057620: 7468 7265 7368 6f6c 6429 3b0a 0a09 0909  threshold);.....
    │ │ │ +00057630: 7374 643a 3a73 6f72 7428 7065 6572 732e  std::sort(peers.
    │ │ │ +00057640: 6265 6769 6e28 292c 2070 6565 7273 2e65  begin(), peers.e
    │ │ │ +00057650: 6e64 2829 0a09 0909 092c 205b 5d28 7065  nd()....., [](pe
    │ │ │ +00057660: 6572 5f63 6f6e 6e65 6374 696f 6e20 636f  er_connection co
    │ │ │ +00057670: 6e73 742a 206c 6873 2c20 7065 6572 5f63  nst* lhs, peer_c
    │ │ │ +00057680: 6f6e 6e65 6374 696f 6e20 636f 6e73 742a  onnection const*
    │ │ │ +00057690: 2072 6873 290a 0909 0909 7b20 7265 7475   rhs).....{ retu
    │ │ │ +000576a0: 726e 2075 706c 6f61 645f 7261 7465 5f63  rn upload_rate_c
    │ │ │ +000576b0: 6f6d 7061 7265 286c 6873 2c20 7268 7329  ompare(lhs, rhs)
    │ │ │ +000576c0: 3b20 7d29 3b0a 0a09 0909 666f 7220 2861  ; });.....for (a
    │ │ │ +000576d0: 7574 6f20 636f 6e73 742a 2070 203a 2070  uto const* p : p
    │ │ │ +000576e0: 6565 7273 290a 0909 097b 0a09 0909 0969  eers)....{.....i
    │ │ │ +000576f0: 6e74 2063 6f6e 7374 2072 6174 6520 3d20  nt const rate = 
    │ │ │ +00057700: 696e 7428 702d 2667 743b 7570 6c6f 6164  int(p->upload
    │ │ │ +00057710: 6564 5f69 6e5f 6c61 7374 5f72 6f75 6e64  ed_in_last_round
    │ │ │ +00057720: 2829 0a09 0909 0909 2a20 3130 3030 202f  ()......* 1000 /
    │ │ │ +00057730: 2074 6f74 616c 5f6d 696c 6c69 7365 636f   total_milliseco
    │ │ │ +00057740: 6e64 7328 756e 6368 6f6b 655f 696e 7465  nds(unchoke_inte
    │ │ │ +00057750: 7276 616c 2929 3b0a 0a09 0909 092f 2f20  rval));......// 
    │ │ │ +00057760: 616c 7761 7973 2068 6176 6520 6174 206c  always have at l
    │ │ │ +00057770: 6561 7374 2031 2075 6e63 686f 6b65 2073  east 1 unchoke s
    │ │ │ +00057780: 6c6f 740a 0909 0909 6966 2028 7261 7465  lot.....if (rate
    │ │ │ +00057790: 2026 6c74 3b20 7261 7465 5f74 6872 6573   < rate_thres
    │ │ │ +000577a0: 686f 6c64 2920 6272 6561 6b3b 0a0a 0909  hold) break;....
    │ │ │ +000577b0: 0909 2b2b 7570 6c6f 6164 5f73 6c6f 7473  ..++upload_slots
    │ │ │ +000577c0: 3b0a 0a3c 6469 7620 7374 796c 653d 2262  ;..
    ....rate_thresh │ │ │ +00057800: 6f6c 6420 2b3d 2032 3034 383b 0a3c 2f64 old += 2048;....}....++upl │ │ │ +00057820: 6f61 645f 736c 6f74 733b 0a09 097d 0a0a oad_slots;...}.. │ │ │ +00057830: 0909 2f2f 2073 6f72 7473 2074 6865 2070 ..// sorts the p │ │ │ +00057840: 6565 7273 2074 6861 7420 6172 6520 656c eers that are el │ │ │ +00057850: 6967 6962 6c65 2066 6f72 2075 6e63 686f igible for uncho │ │ │ +00057860: 6b65 2062 7920 646f 776e 6c6f 6164 2072 ke by download r │ │ │ +00057870: 6174 6520 616e 640a 0909 2f2f 2073 6563 ate and...// sec │ │ │ +00057880: 6f6e 6461 7279 2062 7920 746f 7461 6c20 ondary by total │ │ │ +00057890: 7570 6c6f 6164 2e20 5468 6520 7265 6173 upload. The reas │ │ │ +000578a0: 6f6e 2066 6f72 2074 6869 7320 6973 2c20 on for this is, │ │ │ +000578b0: 6966 2061 6c6c 2074 6f72 7265 6e74 7320 if all torrents │ │ │ +000578c0: 6172 650a 0909 2f2f 2062 6569 6e67 2073 are...// being s │ │ │ +000578d0: 6565 6465 642c 2074 6865 2064 6f77 6e6c eeded, the downl │ │ │ +000578e0: 6f61 6420 7261 7465 2077 696c 6c20 6265 oad rate will be │ │ │ +000578f0: 2030 2c20 616e 6420 7468 6520 7065 6572 0, and the peer │ │ │ +00057900: 7320 7765 2068 6176 6520 7365 6e74 0a09 s we have sent.. │ │ │ +00057910: 092f 2f20 7468 6520 6c65 6173 7420 746f .// the least to │ │ │ +00057920: 2073 686f 756c 6420 6265 2075 6e63 686f should be uncho │ │ │ +00057930: 6b65 640a 0a09 092f 2f20 7765 2075 7365 ked....// we use │ │ │ +00057940: 2070 6172 7469 616c 2073 6f72 7420 6865 partial sort he │ │ │ +00057950: 7265 2c20 6265 6361 7573 6520 7765 206f re, because we o │ │ │ +00057960: 6e6c 7920 6361 7265 2061 626f 7574 2074 nly care about t │ │ │ +00057970: 6865 2074 6f70 0a09 092f 2f20 7570 6c6f he top...// uplo │ │ │ +00057980: 6164 5f73 6c6f 7473 2070 6565 7273 2e0a ad_slots peers.. │ │ │ +00057990: 0a09 0969 6e74 2063 6f6e 7374 2073 6c6f ...int const slo │ │ │ +000579a0: 7473 203d 2073 7464 3a3a 6d69 6e28 7570 ts = std::min(up │ │ │ +000579b0: 6c6f 6164 5f73 6c6f 7473 2c20 696e 7428 load_slots, int( │ │ │ +000579c0: 7065 6572 732e 7369 7a65 2829 2929 3b0a peers.size()));. │ │ │ +000579d0: 0909 696e 7420 636f 6e73 7420 7365 6564 ..int const seed │ │ │ +000579e0: 5f63 686f 6b65 203d 2073 6574 742e 6765 _choke = sett.ge │ │ │ +000579f0: 745f 696e 7428 7365 7474 696e 6773 5f70 t_int(settings_p │ │ │ +00057a00: 6163 6b3a 3a73 6565 645f 6368 6f6b 696e ack::seed_chokin │ │ │ +00057a10: 675f 616c 676f 7269 7468 6d29 3b0a 0a09 g_algorithm);... │ │ │ +00057a20: 0969 6620 2873 6565 645f 6368 6f6b 6520 .if (seed_choke │ │ │ +00057a30: 3d3d 2073 6574 7469 6e67 735f 7061 636b == settings_pack │ │ │ +00057a40: 3a3a 6661 7374 6573 745f 7570 6c6f 6164 ::fastest_upload │ │ │ +00057a50: 290a 0909 7b0a 0909 0973 7464 3a3a 6e74 )...{....std::nt │ │ │ +00057a60: 685f 656c 656d 656e 7428 7065 6572 732e h_element(peers. │ │ │ +00057a70: 6265 6769 6e28 292c 2070 6565 7273 2e62 begin(), peers.b │ │ │ +00057a80: 6567 696e 2829 0a09 0909 092b 2073 6c6f egin().....+ slo │ │ │ +00057a90: 7473 2c20 7065 6572 732e 656e 6428 290a ts, peers.end(). │ │ │ +00057aa0: 0909 0909 2c20 5b5d 2870 6565 725f 636f ...., [](peer_co │ │ │ +00057ab0: 6e6e 6563 7469 6f6e 2063 6f6e 7374 2a20 nnection const* │ │ │ +00057ac0: 6c68 732c 2070 6565 725f 636f 6e6e 6563 lhs, peer_connec │ │ │ +00057ad0: 7469 6f6e 2063 6f6e 7374 2a20 7268 7329 tion const* rhs) │ │ │ +00057ae0: 0a09 0909 097b 2072 6574 7572 6e20 756e .....{ return un │ │ │ +00057af0: 6368 6f6b 655f 636f 6d70 6172 655f 6661 choke_compare_fa │ │ │ +00057b00: 7374 6573 745f 7570 6c6f 6164 286c 6873 stest_upload(lhs │ │ │ +00057b10: 2c20 7268 7329 3b20 7d29 3b0a 0909 7d0a , rhs); });...}. │ │ │ +00057b20: 0909 656c 7365 2069 6620 2873 6565 645f ..else if (seed_ │ │ │ +00057b30: 6368 6f6b 6520 3d3d 2073 6574 7469 6e67 choke == setting │ │ │ +00057b40: 735f 7061 636b 3a3a 616e 7469 5f6c 6565 s_pack::anti_lee │ │ │ +00057b50: 6368 290a 0909 7b0a 0909 0973 7464 3a3a ch)...{....std:: │ │ │ +00057b60: 6e74 685f 656c 656d 656e 7428 7065 6572 nth_element(peer │ │ │ +00057b70: 732e 6265 6769 6e28 292c 2070 6565 7273 s.begin(), peers │ │ │ +00057b80: 2e62 6567 696e 2829 0a09 0909 092b 2073 .begin().....+ s │ │ │ +00057b90: 6c6f 7473 2c20 7065 6572 732e 656e 6428 lots, peers.end( │ │ │ +00057ba0: 290a 0909 0909 2c20 5b5d 2870 6565 725f )....., [](peer_ │ │ │ +00057bb0: 636f 6e6e 6563 7469 6f6e 2063 6f6e 7374 connection const │ │ │ +00057bc0: 2a20 6c68 732c 2070 6565 725f 636f 6e6e * lhs, peer_conn │ │ │ +00057bd0: 6563 7469 6f6e 2063 6f6e 7374 2a20 7268 ection const* rh │ │ │ +00057be0: 7329 0a09 0909 097b 2072 6574 7572 6e20 s).....{ return │ │ │ +00057bf0: 756e 6368 6f6b 655f 636f 6d70 6172 655f unchoke_compare_ │ │ │ +00057c00: 616e 7469 5f6c 6565 6368 286c 6873 2c20 anti_leech(lhs, │ │ │ +00057c10: 7268 7329 3b20 7d29 3b0a 0909 7d0a 0909 rhs); });...}... │ │ │ +00057c20: 656c 7365 0a3c 2f70 7265 3e3c 2f74 643e else.
    │ │ │ +00057c30: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +00057c60: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +00057c70: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +00057c80: 7074 3a65 7870 616e 6428 3230 3529 223e pt:expand(205)"> │ │ │ +00057c90: 2e2e 2f73 7263 2f6d 6572 6b6c 655f 7472 ../src/merkle_tr │ │ │ +00057ca0: 6565 2e63 7070 3a38 383c 2f61 3e3c 2f74 ee.cpp:88
    in C++20, │ │ │ +00057cc0: 7573 6520 7374 643a 3a69 6465 6e74 6974 use std::identit │ │ │ +00057cd0: 793c 2f74 643e 3c2f 7472 3e3c 7472 2069 y

    i │ │ │ +00057d20: 6e20 432b 2b32 302c 2075 7365 2073 7464 n C++20, use std │ │ │ +00057d30: 3a3a 6964 656e 7469 7479 3c2f 6832 3e3c ::identity

    < │ │ │ +00057d40: 6834 3e2e 2e2f 7372 632f 6d65 726b 6c65 h4>../src/merkle │ │ │ +00057d50: 5f74 7265 652e 6370 703a 3838 3c2f 6834 _tree.cpp:88
    ..all
    │ │ │ +00057da0: 6f63 6174 655f 6675 6c6c 2829 3b0a 0a09  ocate_full();...
    │ │ │ +00057db0: 096d 6572 6b6c 655f 7661 6c69 6461 7465  .merkle_validate
    │ │ │ +00057dc0: 5f63 6f70 7928 742c 206d 5f74 7265 652c  _copy(t, m_tree,
    │ │ │ +00057dd0: 2072 6f6f 7428 292c 206d 5f62 6c6f 636b   root(), m_block
    │ │ │ +00057de0: 5f76 6572 6966 6965 6429 3b0a 0a09 096c  _verified);....l
    │ │ │ +00057df0: 6f61 645f 7665 7269 6669 6564 5f62 6974  oad_verified_bit
    │ │ │ +00057e00: 7328 7665 7269 6669 6564 293b 0a0a 0909  s(verified);....
    │ │ │ +00057e10: 6f70 7469 6d69 7a65 5f73 746f 7261 6765  optimize_storage
    │ │ │ +00057e20: 2829 3b0a 0909 6f70 7469 6d69 7a65 5f73  ();...optimize_s
    │ │ │ +00057e30: 746f 7261 6765 5f70 6965 6365 5f6c 6179  torage_piece_lay
    │ │ │ +00057e40: 6572 2829 3b0a 097d 0a0a 0976 6f69 6420  er();..}...void 
    │ │ │ +00057e50: 6d65 726b 6c65 5f74 7265 653a 3a63 6c65  merkle_tree::cle
    │ │ │ +00057e60: 6172 2829 0a09 7b0a 0909 6d5f 7472 6565  ar()..{...m_tree
    │ │ │ +00057e70: 2e63 6c65 6172 2829 3b0a 0909 6d5f 7472  .clear();...m_tr
    │ │ │ +00057e80: 6565 2e73 6872 696e 6b5f 746f 5f66 6974  ee.shrink_to_fit
    │ │ │ +00057e90: 2829 3b0a 0909 6d5f 626c 6f63 6b5f 7665  ();...m_block_ve
    │ │ │ +00057ea0: 7269 6669 6564 2e63 6c65 6172 2829 3b0a  rified.clear();.
    │ │ │ +00057eb0: 0909 6d5f 6d6f 6465 203d 206d 6f64 655f  ..m_mode = mode_
    │ │ │ +00057ec0: 743a 3a65 6d70 7479 5f74 7265 653b 0a09  t::empty_tree;..
    │ │ │ +00057ed0: 7d0a 0a6e 616d 6573 7061 6365 207b 0a0a  }..namespace {..
    │ │ │ +00057ee0: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .s │ │ │ +00057f10: 7472 7563 7420 6964 656e 7469 7479 0a3c truct identity.< │ │ │ +00057f20: 2f64 6976 3e09 7b0a 0909 626f 6f6c 206f /div>.{...bool o │ │ │ +00057f30: 7065 7261 746f 7228 2928 626f 6f6c 2062 perator()(bool b │ │ │ +00057f40: 2920 636f 6e73 7420 7b20 7265 7475 726e ) const { return │ │ │ +00057f50: 2062 3b20 7d0a 097d 3b0a 7d0a 0a09 766f b; }..};.}...vo │ │ │ +00057f60: 6964 206d 6572 6b6c 655f 7472 6565 3a3a id merkle_tree:: │ │ │ +00057f70: 6c6f 6164 5f73 7061 7273 655f 7472 6565 load_sparse_tree │ │ │ +00057f80: 2873 7061 6e26 6c74 3b73 6861 3235 365f (span<sha256_ │ │ │ +00057f90: 6861 7368 2063 6f6e 7374 2667 743b 2074 hash const> t │ │ │ +00057fa0: 0a09 092c 2062 6974 6669 656c 6420 636f ..., bitfield co │ │ │ +00057fb0: 6e73 7426 616d 703b 206d 6173 6b0a 0909 nst& mask... │ │ │ +00057fc0: 2c20 6269 7466 6965 6c64 2063 6f6e 7374 , bitfield const │ │ │ +00057fd0: 2661 6d70 3b20 7665 7269 6669 6564 290a & verified). │ │ │ +00057fe0: 097b 0a09 0949 4e56 4152 4941 4e54 5f43 .{...INVARIANT_C │ │ │ +00057ff0: 4845 434b 3b0a 0a09 092f 2f20 5468 6520 HECK;....// The │ │ │ +00058000: 7369 7a65 206f 6620 7468 6520 6d61 736b size of the mask │ │ │ +00058010: 2073 686f 756c 6420 6e6f 7420 6578 6365 should not exce │ │ │ +00058020: 6564 2074 6865 2073 697a 6520 6f66 2074 ed the size of t │ │ │ +00058030: 6865 2074 7265 652c 2062 7574 2061 206d he tree, but a m │ │ │ +00058040: 6173 6b20 6c61 7267 6572 2074 6861 6e0a ask larger than. │ │ │ +00058050: 0909 2f2f 2074 6865 2074 7265 6520 6361 ..// the tree ca │ │ │ +00058060: 6e20 6265 2065 6e63 6f75 6e74 6572 6564 n be encountered │ │ │ +00058070: 2069 6e20 7468 6520 2272 6573 756d 6520 in the "resume │ │ │ +00058080: 6461 7461 2220 666f 7220 736f 6d65 2072 data" for some r │ │ │ +00058090: 6561 736f 6e2c 2070 6572 6861 7073 2074 eason, perhaps t │ │ │ +000580a0: 6865 7265 2069 730a 0909 2f2f 2061 2062 here is...// a b │ │ │ +000580b0: 7567 2069 6e20 7468 6520 2272 6573 756d ug in the "resum │ │ │ +000580c0: 6520 6461 7461 2220 6765 6e65 7261 7469 e data" generati │ │ │ +000580d0: 6f6e 2061 6c67 6f72 6974 686d 2e0a 0909 on algorithm.... │ │ │ +000580e0: 2f2f 2053 6f20 7765 206a 7573 7420 7072 // So we just pr │ │ │ +000580f0: 6f63 6573 7320 6d61 736b 2069 7465 6d73 ocess mask items │ │ │ +00058100: 2063 6f75 6e74 2075 7020 746f 2074 7265 count up to tre │ │ │ +00058110: 6520 7369 7a65 2e0a 0909 696e 7420 636f e size....int co │ │ │ +00058120: 6e73 7420 6d61 736b 5f73 697a 6520 3d20 nst mask_size = │ │ │ +00058130: 7374 643a 3a6d 696e 286d 6173 6b2e 7369 std::min(mask.si │ │ │ +00058140: 7a65 2829 2c20 696e 7428 7369 7a65 2829 ze(), int(size() │ │ │ +00058150: 2929 3b0a 0a09 0969 6e74 2063 6f6e 7374 ));....int const │ │ │ +00058160: 2066 6972 7374 5f62 6c6f 636b 203d 2062 first_block = b │ │ │ +00058170: 6c6f 636b 5f6c 6179 6572 5f73 7461 7274 lock_layer_start │ │ │ +00058180: 2829 3b0a 0909 696e 7420 636f 6e73 7420 ();...int const │ │ │ +00058190: 656e 645f 626c 6f63 6b20 3d20 6669 7273 end_block = firs │ │ │ +000581a0: 745f 626c 6f63 6b20 2b20 6d5f 6e75 6d5f t_block + m_num_ │ │ │ +000581b0: 626c 6f63 6b73 3b0a 0a09 0954 4f52 5245 blocks;....TORRE │ │ │ +000581c0: 4e54 5f41 5353 4552 5428 6669 7273 745f NT_ASSERT(first_ │ │ │ +000581d0: 626c 6f63 6b20 266c 743b 2069 6e74 2873 block < int(s │ │ │ +000581e0: 697a 6528 2929 293b 0a09 0954 4f52 5245 ize()));...TORRE │ │ │ +000581f0: 4e54 5f41 5353 4552 5428 656e 645f 626c NT_ASSERT(end_bl │ │ │ +00058200: 6f63 6b20 266c 743b 3d20 696e 7428 7369 ock <= int(si │ │ │ +00058210: 7a65 2829 2929 3b0a 0a09 092f 2f20 6966 ze()));....// if │ │ │ +00058220: 2074 6865 206d 6173 6b20 636f 7665 7273 the mask covers │ │ │ +00058230: 2061 6c6c 2062 6c6f 636b 732c 2067 6f20 all blocks, go │ │ │ +00058240: 7374 7261 6967 6874 2074 6f20 626c 6f63 straight to bloc │ │ │ +00058250: 6b5f 6c61 7965 720a 0909 2f2f 206d 6f64 k_layer...// mod │ │ │ +00058260: 652c 2061 6e64 2076 616c 6964 6174 650a e, and validate. │ │ │ +00058270: 0909 6966 2028 2866 6972 7374 5f62 6c6f ..if ((first_blo │ │ │ +00058280: 636b 2026 6c74 3b20 6d61 736b 5f73 697a ck < mask_siz │ │ │ +00058290: 6529 2026 616d 703b 2661 6d70 3b20 2865 e) && (e │ │ │ +000582a0: 6e64 5f62 6c6f 636b 2026 6c74 3b3d 206d nd_block <= m │ │ │ +000582b0: 6173 6b5f 7369 7a65 290a 0909 0926 616d ask_size)....&am │ │ │ +000582c0: 703b 2661 6d70 3b20 7374 643a 3a61 6c6c p;& std::all │ │ │ +000582d0: 5f6f 6628 6d61 736b 2e62 6567 696e 2829 _of(mask.begin() │ │ │ +000582e0: 202b 2066 6972 7374 5f62 6c6f 636b 2c20 + first_block, │ │ │ +000582f0: 6d61 736b 2e62 6567 696e 2829 202b 2065 mask.begin() + e │ │ │ +00058300: 6e64 5f62 6c6f 636b 2c20 6964 656e 7469 nd_block, identi │ │ │ +00058310: 7479 2829 2929 0a09 097b 0a09 0909 2f2f ty()))...{....// │ │ │ +00058320: 2074 6865 2069 6e64 6578 2069 6e20 7420 the index in t │ │ │ +00058330: 7468 6174 2070 6f69 6e74 7320 746f 2066 that points to f │ │ │ +00058340: 6972 7374 5f62 6c6f 636b 0a09 0909 6175 irst_block....au │ │ │ +00058350: 746f 2063 6f6e 7374 2062 6c6f 636b 5f69 to const block_i │ │ │ +00058360: 6e64 6578 203d 2073 7464 3a3a 636f 756e ndex = std::coun │ │ │ +00058370: 745f 6966 286d 6173 6b2e 6265 6769 6e28 t_if(mask.begin( │ │ │ +00058380: 292c 206d 6173 6b2e 6265 6769 6e28 2920 ), mask.begin() │ │ │ +00058390: 2b20 6669 7273 745f 626c 6f63 6b2c 2069 + first_block, i │ │ │ +000583a0: 6465 6e74 6974 7928 2929 3b0a 3c2f 7072 dentity());.rel │ │ │ +000583e0: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/me │ │ │ +00058420: 726b 6c65 5f74 7265 652e 6370 703a 3330 rkle_tree.cpp:30 │ │ │ +00058430: 383c 2f61 3e3c 2f74 643e 3c74 643e 7468 8th │ │ │ +00058440: 6973 2063 616e 2062 6520 6f70 7469 6d69 is can be optimi │ │ │ +00058450: 7a65 6420 6279 2075 7369 6e67 206d 5f74 zed by using m_t │ │ │ +00058460: 7265 6520 6173 2073 746f 7261 6765 2074 ree as storage t │ │ │ +00058470: 6f20 6669 6c6c 2074 6869 7320 7472 6565 o fill this tree │ │ │ +00058480: 2069 6e74 6f2c 2061 6e64 2074 6865 6e20 into, and then │ │ │ +00058490: 636c 6561 7220 6974 2069 6620 7468 6520 clear it if the │ │ │ +000584a0: 6861 7368 6573 2066 6169 6c3c 2f74 643e hashes fail │ │ │ +000584b0: 3c2f 7472 3e3c 7472 2069 643d 2232 3036

    this ca │ │ │ +00058500: 6e20 6265 206f 7074 696d 697a 6564 2062 n be optimized b │ │ │ +00058510: 7920 7573 696e 6720 6d5f 7472 6565 2061 y using m_tree a │ │ │ +00058520: 7320 7374 6f72 6167 6520 746f 2066 696c s storage to fil │ │ │ +00058530: 6c20 7468 6973 0a74 7265 6520 696e 746f l this.tree into │ │ │ +00058540: 2c20 616e 6420 7468 656e 2063 6c65 6172 , and then clear │ │ │ +00058550: 2069 7420 6966 2074 6865 2068 6173 6865 it if the hashe │ │ │ +00058560: 7320 6661 696c 3c2f 6832 3e3c 6834 3e2e s fail

    . │ │ │ +00058570: 2e2f 7372 632f 6d65 726b 6c65 5f74 7265 ./src/merkle_tre │ │ │ +00058580: 652e 6370 703a 3330 383c 2f68 343e 3c70 e.cpp:308

    .{...INV │ │ │ +000585d0: 4152 4941 4e54 5f43 4845 434b 3b0a 0a09 ARIANT_CHECK;... │ │ │ +000585e0: 092f 2f20 6173 2077 6520 7365 7420 7468 .// as we set th │ │ │ +000585f0: 6520 6861 7368 6573 206f 6620 696e 7465 e hashes of inte │ │ │ +00058600: 7269 6f72 206e 6f64 6573 2c20 7765 206d rior nodes, we m │ │ │ +00058610: 6179 2062 6520 6162 6c65 2074 6f20 7661 ay be able to va │ │ │ +00058620: 6c69 6461 7465 0a09 092f 2f20 626c 6f63 lidate...// bloc │ │ │ +00058630: 6b20 6861 7368 6573 2074 6861 7420 7765 k hashes that we │ │ │ +00058640: 2068 6164 2073 696e 6365 2065 6172 6c69 had since earli │ │ │ +00058650: 6572 2e20 416e 7920 626c 6f63 6b73 2074 er. Any blocks t │ │ │ +00058660: 6861 7420 6361 6e20 6265 0a09 092f 2f20 hat can be...// │ │ │ +00058670: 7661 6c69 6461 7465 642c 2061 6e64 2066 validated, and f │ │ │ +00058680: 6169 6c65 642c 2061 7265 2061 6464 6564 ailed, are added │ │ │ +00058690: 2074 6f20 7468 6973 206c 6973 740a 0909 to this list... │ │ │ +000586a0: 6164 645f 6861 7368 6573 5f72 6573 756c add_hashes_resul │ │ │ +000586b0: 745f 7420 7265 743b 0a0a 0909 2f2f 2077 t_t ret;....// w │ │ │ +000586c0: 6520 616c 7265 6164 7920 6861 7665 2061 e already have a │ │ │ +000586d0: 6c6c 2068 6173 6865 730a 0909 6966 2028 ll hashes...if ( │ │ │ +000586e0: 6d5f 6d6f 6465 203d 3d20 6d6f 6465 5f74 m_mode == mode_t │ │ │ +000586f0: 3a3a 626c 6f63 6b5f 6c61 7965 7229 0a09 ::block_layer).. │ │ │ +00058700: 097b 0a09 0909 2f2f 2073 696e 6365 2077 .{....// since w │ │ │ +00058710: 6527 7265 2061 6c72 6561 6479 206f 6e20 e're already on │ │ │ +00058720: 7468 6520 626c 6f63 6b20 6c61 7965 7220 the block layer │ │ │ +00058730: 6d6f 6465 2c20 7765 2068 6176 6520 7468 mode, we have th │ │ │ +00058740: 6520 7768 6f6c 650a 0909 092f 2f20 7472 e whole....// tr │ │ │ +00058750: 6565 2c20 616e 6420 7765 2776 6520 616c ee, and we've al │ │ │ +00058760: 7265 6164 7920 7265 706f 7274 6564 2061 ready reported a │ │ │ +00058770: 6e79 2070 6965 6365 7320 6173 2070 6173 ny pieces as pas │ │ │ +00058780: 7369 6e67 2074 6861 7420 6d61 790a 0909 sing that may... │ │ │ +00058790: 092f 2f20 6861 7665 2065 7869 7374 6564 .// have existed │ │ │ +000587a0: 2069 6e20 7468 6520 7472 6565 2077 6865 in the tree whe │ │ │ +000587b0: 6e20 7765 2063 6f6d 706c 6574 6564 2069 n we completed i │ │ │ +000587c0: 742e 2041 7420 7468 6973 2070 6f69 6e74 t. At this point │ │ │ +000587d0: 206e 6f0a 0909 092f 2f20 6d6f 7265 2070 no....// more p │ │ │ +000587e0: 6965 6365 7320 7368 6f75 6c64 2062 6520 ieces should be │ │ │ +000587f0: 7265 706f 7274 6564 2061 7320 7061 7373 reported as pass │ │ │ +00058800: 6564 0a09 0909 7265 7475 726e 2072 6574 ed....return ret │ │ │ +00058810: 3b0a 0909 7d0a 0a09 0961 6c6c 6f63 6174 ;...}....allocat │ │ │ +00058820: 655f 6675 6c6c 2829 3b0a 0a3c 6469 7620 e_full();..

    ..int c │ │ │ +00058860: 6f6e 7374 206c 6561 665f 636f 756e 7420 onst leaf_count │ │ │ +00058870: 3d20 6d65 726b 6c65 5f6e 756d 5f6c 6561 = merkle_num_lea │ │ │ +00058880: 6673 2869 6e74 2868 6173 6865 732e 7369 fs(int(hashes.si │ │ │ +00058890: 7a65 2829 2929 3b0a 3c2f 6469 763e 0a09 ze()));.
    .. │ │ │ +000588a0: 092f 2f20 6861 7368 6573 2e73 697a 6528 .// hashes.size( │ │ │ +000588b0: 2920 2861 6e64 2073 6f20 6c65 6166 5f63 ) (and so leaf_c │ │ │ +000588c0: 6f75 6e74 2c20 6f6e 6365 2072 6f75 6e64 ount, once round │ │ │ +000588d0: 6564 2075 7020 746f 2061 2070 6f77 6572 ed up to a power │ │ │ +000588e0: 206f 6620 3229 0a09 092f 2f20 6973 206e of 2)...// is n │ │ │ +000588f0: 6f74 2062 6f75 6e64 732d 6368 6563 6b65 ot bounds-checke │ │ │ +00058900: 6420 6167 6169 6e73 7420 7468 6520 6465 d against the de │ │ │ +00058910: 7374 696e 6174 696f 6e20 6c61 7965 7220 stination layer │ │ │ +00058920: 6279 2074 6865 2063 616c 6c65 722c 0a09 by the caller,.. │ │ │ +00058930: 092f 2f20 6f6e 6c79 2074 6865 2075 6e2d .// only the un- │ │ │ +00058940: 726f 756e 6465 6420 636f 756e 7420 6973 rounded count is │ │ │ +00058950: 2e20 5265 6a65 6374 2061 6e79 2072 6571 . Reject any req │ │ │ +00058960: 7565 7374 2077 686f 7365 2070 6164 6465 uest whose padde │ │ │ +00058970: 6420 7370 616e 0a09 092f 2f20 776f 756c d span...// woul │ │ │ +00058980: 6420 7275 6e20 7061 7374 2074 6865 2065 d run past the e │ │ │ +00058990: 6e64 206f 6620 7468 6520 6c61 7965 7220 nd of the layer │ │ │ +000589a0: 6974 2773 2069 6e73 6572 7465 6420 696e it's inserted in │ │ │ +000589b0: 746f 2e0a 0909 696e 7420 636f 6e73 7420 to....int const │ │ │ +000589c0: 6465 7374 5f6c 6179 6572 5f73 697a 6520 dest_layer_size │ │ │ +000589d0: 3d20 3120 266c 743b 266c 743b 206d 6572 = 1 << mer │ │ │ +000589e0: 6b6c 655f 6765 745f 6c61 7965 7228 6465 kle_get_layer(de │ │ │ +000589f0: 7374 5f73 7461 7274 5f69 6478 293b 0a09 st_start_idx);.. │ │ │ +00058a00: 0969 6e74 2063 6f6e 7374 2064 6573 745f .int const dest_ │ │ │ +00058a10: 6c61 7965 725f 6f66 6673 6574 203d 206d layer_offset = m │ │ │ +00058a20: 6572 6b6c 655f 6765 745f 6c61 7965 725f erkle_get_layer_ │ │ │ +00058a30: 6f66 6673 6574 2864 6573 745f 7374 6172 offset(dest_star │ │ │ +00058a40: 745f 6964 7829 3b0a 0909 6966 2028 6465 t_idx);...if (de │ │ │ +00058a50: 7374 5f6c 6179 6572 5f6f 6666 7365 7420 st_layer_offset │ │ │ +00058a60: 2b20 6c65 6166 5f63 6f75 6e74 2026 6774 + leaf_count > │ │ │ +00058a70: 3b20 6465 7374 5f6c 6179 6572 5f73 697a ; dest_layer_siz │ │ │ +00058a80: 6529 0a09 0909 7265 7475 726e 207b 7d3b e)....return {}; │ │ │ +00058a90: 0a0a 0909 6175 783a 3a76 6563 746f 7226 ....aux::vector& │ │ │ +00058aa0: 6c74 3b73 6861 3235 365f 6861 7368 2667 lt;sha256_hash&g │ │ │ +00058ab0: 743b 2074 7265 6528 6d65 726b 6c65 5f6e t; tree(merkle_n │ │ │ +00058ac0: 756d 5f6e 6f64 6573 286c 6561 665f 636f um_nodes(leaf_co │ │ │ +00058ad0: 756e 7429 293b 0a09 0973 7464 3a3a 636f unt));...std::co │ │ │ +00058ae0: 7079 2868 6173 6865 732e 6265 6769 6e28 py(hashes.begin( │ │ │ +00058af0: 292c 2068 6173 6865 732e 656e 6428 292c ), hashes.end(), │ │ │ +00058b00: 2074 7265 652e 656e 6428 2920 2d20 6c65 tree.end() - le │ │ │ +00058b10: 6166 5f63 6f75 6e74 293b 0a0a 0909 2f2f af_count);....// │ │ │ +00058b20: 2074 6865 2065 6e64 206f 6620 6120 6669 the end of a fi │ │ │ +00058b30: 6c65 2069 7320 6120 7370 6563 6961 6c20 le is a special │ │ │ +00058b40: 6361 7365 2c20 7765 206d 6179 206e 6565 case, we may nee │ │ │ +00058b50: 6420 746f 2070 6164 2074 6865 206c 6561 d to pad the lea │ │ │ +00058b60: 6620 6c61 7965 720a 0909 6966 2028 6c65 f layer...if (le │ │ │ +00058b70: 6166 5f63 6f75 6e74 2026 6774 3b20 6861 af_count > ha │ │ │ +00058b80: 7368 6573 2e73 697a 6528 2929 0a09 097b shes.size())...{ │ │ │ +00058b90: 0a09 0909 696e 7420 636f 6e73 7420 6c65 ....int const le │ │ │ +00058ba0: 6166 5f6c 6179 6572 5f73 697a 6520 3d20 af_layer_size = │ │ │ +00058bb0: 6e75 6d5f 6c65 6166 7328 293b 0a09 0909 num_leafs();.... │ │ │ +00058bc0: 2f2f 2061 7373 756d 696e 6720 756e 636c // assuming uncl │ │ │ +00058bd0: 655f 6861 7368 6573 206c 6561 6420 616c e_hashes lead al │ │ │ +00058be0: 6c20 7468 6520 7761 7920 746f 2074 6865 l the way to the │ │ │ +00058bf0: 2072 6f6f 742c 2074 6865 7920 7465 6c6c root, they tell │ │ │ +00058c00: 2075 730a 0909 092f 2f20 686f 7720 6d61 us....// how ma │ │ │ +00058c10: 6e79 206c 6179 6572 7320 646f 776e 2077 ny layers down w │ │ │ +00058c20: 6520 6172 650a 0909 092f 2f20 756e 636c e are....// uncl │ │ │ +00058c30: 655f 6861 7368 6573 2e73 697a 6528 2920 e_hashes.size() │ │ │ +00058c40: 6973 2063 616c 6c65 722d 636f 6e74 726f is caller-contro │ │ │ +00058c50: 6c6c 6564 3b20 626f 756e 6420 6974 2062 lled; bound it b │ │ │ +00058c60: 6566 6f72 6520 7573 696e 6720 6974 0a09 efore using it.. │ │ │ +00058c70: 0909 2f2f 2061 7320 6120 7368 6966 7420 ..// as a shift │ │ │ +00058c80: 6578 706f 6e65 6e74 2062 656c 6f77 2c20 exponent below, │ │ │ +00058c90: 6974 2773 206f 7468 6572 7769 7365 2075 it's otherwise u │ │ │ +00058ca0: 6e72 656c 6174 6564 2074 6f20 6c65 6166 nrelated to leaf │ │ │ +00058cb0: 5f63 6f75 6e74 0a09 0909 696e 7420 636f _count....int co │ │ │ +00058cc0: 6e73 7420 6d61 785f 7072 6f6f 665f 6c61 nst max_proof_la │ │ │ +00058cd0: 7965 7273 203d 0a09 0909 096d 6572 6b6c yers =.....merkl │ │ │ +00058ce0: 655f 6e75 6d5f 6c61 7965 7273 286c 6561 e_num_layers(lea │ │ │ +00058cf0: 665f 6c61 7965 725f 7369 7a65 2920 2d20 f_layer_size) - │ │ │ +00058d00: 6d65 726b 6c65 5f6e 756d 5f6c 6179 6572 merkle_num_layer │ │ │ +00058d10: 7328 6c65 6166 5f63 6f75 6e74 293b 0a09 s(leaf_count);.. │ │ │ +00058d20: 0909 6966 2028 756e 636c 655f 6861 7368 ..if (uncle_hash │ │ │ +00058d30: 6573 2e73 697a 6528 2920 2667 743b 206d es.size() > m │ │ │ +00058d40: 6178 5f70 726f 6f66 5f6c 6179 6572 7329 ax_proof_layers) │ │ │ +00058d50: 0a09 0909 0972 6574 7572 6e20 7b7d 3b0a .....return {};. │ │ │ +00058d60: 0909 0969 6e74 2063 6f6e 7374 2069 6e73 ...int const ins │ │ │ +00058d70: 6572 745f 6c61 7965 725f 7369 7a65 203d ert_layer_size = │ │ │ +00058d80: 206c 6561 665f 636f 756e 7420 266c 743b leaf_count < │ │ │ +00058d90: 266c 743b 2075 6e63 6c65 5f68 6173 6865 < uncle_hashe │ │ │ +00058da0: 732e 7369 7a65 2829 3b0a 0909 0969 6620 s.size();....if │ │ │ +00058db0: 286c 6561 665f 6c61 7965 725f 7369 7a65 (leaf_layer_size │ │ │ +00058dc0: 2021 3d20 696e 7365 7274 5f6c 6179 6572 != insert_layer │ │ │ +00058dd0: 5f73 697a 6529 0a09 0909 7b0a 0909 0909 _size)....{..... │ │ │ +00058de0: 7368 6132 3536 5f68 6173 6820 636f 6e73 sha256_hash cons │ │ │ +00058df0: 7420 7061 645f 6861 7368 203d 206d 6572 t pad_hash = mer │ │ │ +00058e00: 6b6c 655f 7061 6428 6c65 6166 5f6c 6179 kle_pad(leaf_lay │ │ │ +00058e10: 6572 5f73 697a 652c 2069 6e73 6572 745f er_size, insert_ │ │ │ +00058e20: 6c61 7965 725f 7369 7a65 293b 0a09 0909 layer_size);.... │ │ │ +00058e30: 0966 6f72 2028 696e 7420 6920 3d20 696e .for (int i = in │ │ │ +00058e40: 7428 6861 7368 6573 2e73 697a 6528 2929 t(hashes.size()) │ │ │ +00058e50: 3b20 6920 266c 743b 206c 6561 665f 636f ; i < leaf_co │ │ │ +00058e60: 756e 743b 202b 2b69 290a 3c2f 7072 653e unt; ++i).
    │ │ │ +00058e70: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +00058ea0: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +00058eb0: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/merk │ │ │ +00058ee0: 6c65 5f74 7265 652e 6370 703a 3434 353c le_tree.cpp:445< │ │ │ +00058ef0: 2f61 3e3c 2f74 643e 3c74 643e 6120 7069 /a>a pi │ │ │ +00058f00: 6563 6520 6f75 7473 6964 6520 6f66 2074 ece outside of t │ │ │ +00058f10: 6869 7320 7261 6e67 6520 6d61 7920 616c his range may al │ │ │ +00058f20: 736f 2066 6169 6c2c 2069 6620 6f6e 6520 so fail, if one │ │ │ +00058f30: 6f66 2074 6865 2075 6e63 6c65 2068 6173 of the uncle has │ │ │ +00058f40: 6865 7320 6973 2061 7420 7468 6520 6c61 hes is at the la │ │ │ +00058f50: 7965 7220 7269 6768 7420 6162 6f76 6520 yer right above │ │ │ +00058f60: 7468 6520 626c 6f63 6b20 6861 7368 6573 the block hashes │ │ │ +00058f70: 3c2f 7464 3e3c 2f74 723e 3c74 7220 6964

    a │ │ │ +00058fc0: 7069 6563 6520 6f75 7473 6964 6520 6f66 piece outside of │ │ │ +00058fd0: 2074 6869 7320 7261 6e67 6520 6d61 7920 this range may │ │ │ +00058fe0: 616c 736f 2066 6169 6c2c 2069 6620 6f6e also fail, if on │ │ │ +00058ff0: 6520 6f66 2074 6865 2075 6e63 6c65 0a68 e of the uncle.h │ │ │ +00059000: 6173 6865 7320 6973 2061 7420 7468 6520 ashes is at the │ │ │ +00059010: 6c61 7965 7220 7269 6768 7420 6162 6f76 layer right abov │ │ │ +00059020: 6520 7468 6520 626c 6f63 6b20 6861 7368 e the block hash │ │ │ +00059030: 6573 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 es

    ../sr │ │ │ +00059040: 632f 6d65 726b 6c65 5f74 7265 652e 6370 c/merkle_tree.cp │ │ │ +00059050: 703a 3434 353c 2f68 343e 3c70 7265 2073 p:445

    ..// middle 
    │ │ │ +000590a0: 6f66 2061 2070 6965 6365 2e20 5468 6973  of a piece. This
    │ │ │ +000590b0: 2069 7320 7768 6174 206d 616b 6573 2074   is what makes t
    │ │ │ +000590c0: 6865 2072 756e 6e69 6e67 0a09 092f 2f20  he running...// 
    │ │ │ +000590d0: 6375 7272 656e 745f 7069 6563 655f 6d61  current_piece_ma
    │ │ │ +000590e0: 7463 6865 6420 636f 756e 7420 6265 6c6f  tched count belo
    │ │ │ +000590f0: 7720 736f 756e 643a 2061 2070 6965 6365  w sound: a piece
    │ │ │ +00059100: 2773 2062 6c6f 636b 7320 616c 7761 7973  's blocks always
    │ │ │ +00059110: 0a09 092f 2f20 6172 7269 7665 2074 6f67  ...// arrive tog
    │ │ │ +00059120: 6574 6865 7220 696e 2074 6865 2073 616d  ether in the sam
    │ │ │ +00059130: 6520 6361 6c6c 2e0a 2369 6620 544f 5252  e call..#if TORR
    │ │ │ +00059140: 454e 545f 5553 455f 4153 5345 5254 530a  ENT_USE_ASSERTS.
    │ │ │ +00059150: 0909 6966 2028 6465 7374 5f73 7461 7274  ..if (dest_start
    │ │ │ +00059160: 5f69 6478 2026 6774 3b3d 2066 6972 7374  _idx >= first
    │ │ │ +00059170: 5f6c 6561 6629 0a09 097b 0a09 0909 696e  _leaf)...{....in
    │ │ │ +00059180: 7420 636f 6e73 7420 626c 6f63 6b73 5f70  t const blocks_p
    │ │ │ +00059190: 6572 5f70 6965 6365 203d 2031 2026 6c74  er_piece = 1 <
    │ │ │ +000591a0: 3b26 6c74 3b20 6261 7365 3b0a 0909 0969  ;< base;....i
    │ │ │ +000591b0: 6e74 2063 6f6e 7374 2070 6f73 203d 2064  nt const pos = d
    │ │ │ +000591c0: 6573 745f 7374 6172 745f 6964 7820 2d20  est_start_idx - 
    │ │ │ +000591d0: 6669 7273 745f 6c65 6166 3b0a 0909 0954  first_leaf;....T
    │ │ │ +000591e0: 4f52 5245 4e54 5f41 5353 4552 5428 706f  ORRENT_ASSERT(po
    │ │ │ +000591f0: 7320 2520 626c 6f63 6b73 5f70 6572 5f70  s % blocks_per_p
    │ │ │ +00059200: 6965 6365 203d 3d20 3029 3b0a 0909 0954  iece == 0);....T
    │ │ │ +00059210: 4f52 5245 4e54 5f41 5353 4552 5428 6c65  ORRENT_ASSERT(le
    │ │ │ +00059220: 6166 5f63 6f75 6e74 2025 2062 6c6f 636b  af_count % block
    │ │ │ +00059230: 735f 7065 725f 7069 6563 6520 3d3d 2030  s_per_piece == 0
    │ │ │ +00059240: 207c 7c20 706f 7320 2b20 6c65 6166 5f63   || pos + leaf_c
    │ │ │ +00059250: 6f75 6e74 203d 3d20 6d5f 6e75 6d5f 626c  ount == m_num_bl
    │ │ │ +00059260: 6f63 6b73 293b 0a09 097d 0a23 656e 6469  ocks);...}.#endi
    │ │ │ +00059270: 660a 0a09 092f 2f20 636f 756e 7420 6f66  f....// count of
    │ │ │ +00059280: 2074 6865 2063 7572 7265 6e74 2070 6965   the current pie
    │ │ │ +00059290: 6365 2773 206d 6174 6368 6564 2062 6c6f  ce's matched blo
    │ │ │ +000592a0: 636b 2068 6173 6865 732c 206e 6565 6465  ck hashes, neede
    │ │ │ +000592b0: 6420 6265 6361 7573 6520 610a 0909 2f2f  d because a...//
    │ │ │ +000592c0: 2073 696e 676c 6520 6d61 7463 6869 6e67   single matching
    │ │ │ +000592d0: 206c 6561 6620 646f 6573 206e 6f74 2070   leaf does not p
    │ │ │ +000592e0: 726f 7665 2061 206d 756c 7469 2d62 6c6f  rove a multi-blo
    │ │ │ +000592f0: 636b 2070 6965 6365 2069 7320 7661 6c69  ck piece is vali
    │ │ │ +00059300: 642e 0a09 092f 2f20 5468 6520 6c65 6166  d....// The leaf
    │ │ │ +00059310: 206c 6179 6572 2062 656c 6f77 2069 7320   layer below is 
    │ │ │ +00059320: 7363 616e 6e65 6420 6f6e 6365 2069 6e20  scanned once in 
    │ │ │ +00059330: 696e 6372 6561 7369 6e67 206f 7264 6572  increasing order
    │ │ │ +00059340: 2c20 736f 2070 6965 6365 730a 0909 2f2f  , so pieces...//
    │ │ │ +00059350: 2061 7265 206e 6576 6572 2072 6576 6973   are never revis
    │ │ │ +00059360: 6974 6564 2061 6e64 2061 2072 756e 6e69  ited and a runni
    │ │ │ +00059370: 6e67 2063 6f75 6e74 2072 6573 6574 2070  ng count reset p
    │ │ │ +00059380: 6572 2070 6965 6365 2073 7566 6669 6365  er piece suffice
    │ │ │ +00059390: 732e 0a09 0961 7574 6f20 6375 7272 656e  s....auto curren
    │ │ │ +000593a0: 745f 7069 6563 6520 3d20 7069 6563 655f  t_piece = piece_
    │ │ │ +000593b0: 696e 6465 785f 7428 2d31 293b 0a09 0969  index_t(-1);...i
    │ │ │ +000593c0: 6e74 2063 7572 7265 6e74 5f70 6965 6365  nt current_piece
    │ │ │ +000593d0: 5f6d 6174 6368 6564 203d 2030 3b0a 0a3c  _matched = 0;..<
    │ │ │ +000593e0: 6469 7620 7374 796c 653d 2262 6163 6b67  div style="backg
    │ │ │ +000593f0: 726f 756e 643a 2023 6666 6666 3030 2220  round: #ffff00" 
    │ │ │ +00059400: 7769 6474 683d 2231 3030 2522 3e09 0966  width="100%">..f
    │ │ │ +00059410: 6f72 2028 696e 7420 6c61 7965 725f 7369  or (int layer_si
    │ │ │ +00059420: 7a65 203d 206c 6561 665f 636f 756e 743b  ze = leaf_count;
    │ │ │ +00059430: 206c 6179 6572 5f73 697a 6520 213d 2030   layer_size != 0
    │ │ │ +00059440: 3b20 6c61 7965 725f 7369 7a65 202f 3d20  ; layer_size /= 
    │ │ │ +00059450: 3229 0a3c 2f64 6976 3e09 097b 0a09 0909  2)...{....
    │ │ │ +00059460: 666f 7220 2869 6e74 2069 203d 2030 3b20  for (int i = 0; 
    │ │ │ +00059470: 6920 266c 743b 206c 6179 6572 5f73 697a  i < layer_siz
    │ │ │ +00059480: 653b 202b 2b69 290a 0909 097b 0a09 0909  e; ++i)....{....
    │ │ │ +00059490: 0969 6e74 2063 6f6e 7374 2064 7374 5f69  .int const dst_i
    │ │ │ +000594a0: 6478 203d 2064 6573 745f 6375 7273 6f72  dx = dest_cursor
    │ │ │ +000594b0: 202b 2069 3b0a 0909 0909 696e 7420 636f   + i;.....int co
    │ │ │ +000594c0: 6e73 7420 7372 635f 6964 7820 3d20 736f  nst src_idx = so
    │ │ │ +000594d0: 7572 6365 5f63 7572 736f 7220 2b20 693b  urce_cursor + i;
    │ │ │ +000594e0: 0a09 0909 092f 2f20 6473 745f 6964 7820  .....// dst_idx 
    │ │ │ +000594f0: 3d3d 2069 6e73 6572 745f 726f 6f74 5f69  == insert_root_i
    │ │ │ +00059500: 6478 2077 6173 2061 6c72 6561 6479 2077  dx was already w
    │ │ │ +00059510: 7269 7474 656e 2061 626f 7665 2062 790a  ritten above by.
    │ │ │ +00059520: 0909 0909 2f2f 206d 6572 6b6c 655f 7661  ....// merkle_va
    │ │ │ +00059530: 6c69 6461 7465 5f61 6e64 5f69 6e73 6572  lidate_and_inser
    │ │ │ +00059540: 745f 7072 6f6f 6673 2829 0a09 0909 0969  t_proofs().....i
    │ │ │ +00059550: 6620 2864 7374 5f69 6478 203d 3d20 696e  f (dst_idx == in
    │ │ │ +00059560: 7365 7274 5f72 6f6f 745f 6964 7820 3f20  sert_root_idx ? 
    │ │ │ +00059570: 696e 7365 7274 5f72 6f6f 745f 616c 7265  insert_root_alre
    │ │ │ +00059580: 6164 795f 6b6e 6f77 6e20 3a20 6861 735f  ady_known : has_
    │ │ │ +00059590: 6e6f 6465 2864 7374 5f69 6478 2929 0a09  node(dst_idx))..
    │ │ │ +000595a0: 0909 097b 0a09 0909 0909 6966 2028 6d5f  ...{......if (m_
    │ │ │ +000595b0: 7472 6565 5b64 7374 5f69 6478 5d20 213d  tree[dst_idx] !=
    │ │ │ +000595c0: 2074 7265 655b 7372 635f 6964 785d 290a   tree[src_idx]).
    │ │ │ +000595d0: 0909 0909 097b 0a09 0909 0909 092f 2f20  .....{.......// 
    │ │ │ +000595e0: 7468 6973 206d 7573 7420 6265 2061 2062  this must be a b
    │ │ │ +000595f0: 6c6f 636b 2068 6173 6820 6265 6361 7573  lock hash becaus
    │ │ │ +00059600: 6520 696e 6e65 7220 6e6f 6465 7320 6172  e inner nodes ar
    │ │ │ +00059610: 6520 6e6f 7420 6669 6c6c 6564 2069 6e20  e not filled in 
    │ │ │ +00059620: 756e 7469 6c0a 0909 0909 0909 2f2f 2074  until.......// t
    │ │ │ +00059630: 6865 7920 6361 6e20 6265 2076 6572 6966  hey can be verif
    │ │ │ +00059640: 6965 642e 2054 6869 7320 6173 7365 7274  ied. This assert
    │ │ │ +00059650: 2065 6e73 7572 6573 2077 6527 7265 2061   ensures we're a
    │ │ │ +00059660: 7420 7468 650a 0909 0909 0909 2f2f 206c  t the.......// l
    │ │ │ +00059670: 6561 6620 6c61 7965 7220 6f66 2074 6865  eaf layer of the
    │ │ │ +00059680: 2066 696c 6520 7472 6565 0a09 0909 0909   file tree......
    │ │ │ +00059690: 0954 4f52 5245 4e54 5f41 5353 4552 5428  .TORRENT_ASSERT(
    │ │ │ +000596a0: 6473 745f 6964 7820 2667 743b 3d20 6669  dst_idx >= fi
    │ │ │ +000596b0: 7273 745f 6c65 6166 293b 0a09 0909 0909  rst_leaf);......
    │ │ │ +000596c0: 0969 6e74 2063 6f6e 7374 2070 6f73 203d  .int const pos =
    │ │ │ +000596d0: 2064 7374 5f69 6478 202d 2066 6972 7374   dst_idx - first
    │ │ │ +000596e0: 5f6c 6561 663b 0a09 0909 0909 0969 6e74  _leaf;.......int
    │ │ │ +000596f0: 2063 6f6e 7374 2062 6c6f 636b 203d 2070   const block = p
    │ │ │ +00059700: 6f73 2026 616d 703b 2028 2831 2026 6c74  os & ((1 <
    │ │ │ +00059710: 3b26 6c74 3b20 6d5f 626c 6f63 6b73 5f70  ;< m_blocks_p
    │ │ │ +00059720: 6572 5f70 6965 6365 5f6c 6f67 2920 2d20  er_piece_log) - 
    │ │ │ +00059730: 3129 3b0a 0909 0909 0909 6175 746f 2063  1);.......auto c
    │ │ │ +00059740: 6f6e 7374 2070 6965 6365 203d 0a09 0909  onst piece =....
    │ │ │ +00059750: 0909 0909 7069 6563 655f 696e 6465 785f  ....piece_index_
    │ │ │ +00059760: 747b 706f 7320 2667 743b 2667 743b 206d  t{pos >> m
    │ │ │ +00059770: 5f62 6c6f 636b 735f 7065 725f 7069 6563  _blocks_per_piec
    │ │ │ +00059780: 655f 6c6f 677d 202b 2066 696c 655f 7069  e_log} + file_pi
    │ │ │ +00059790: 6563 655f 6f66 6673 6574 3b0a 0909 0909  ece_offset;.....
    │ │ │ +000597a0: 0909 544f 5252 454e 545f 4153 5345 5254  ..TORRENT_ASSERT
    │ │ │ +000597b0: 2870 6f73 2026 6c74 3b20 6d5f 6e75 6d5f  (pos < m_num_
    │ │ │ +000597c0: 626c 6f63 6b73 293b 0a0a 0909 0909 0909  blocks);........
    │ │ │ +000597d0: 6966 2028 2172 6574 2e66 6169 6c65 642e  if (!ret.failed.
    │ │ │ +000597e0: 656d 7074 7928 2920 2661 6d70 3b26 616d  empty() &&am
    │ │ │ +000597f0: 703b 2072 6574 2e66 6169 6c65 642e 6261  p; ret.failed.ba
    │ │ │ +00059800: 636b 2829 2e66 6972 7374 203d 3d20 7069  ck().first == pi
    │ │ │ +00059810: 6563 6529 0a09 0909 0909 0909 7265 742e  ece)........ret.
    │ │ │ +00059820: 6661 696c 6564 2e62 6163 6b28 292e 7365  failed.back().se
    │ │ │ +00059830: 636f 6e64 2e70 7573 685f 6261 636b 2862  cond.push_back(b
    │ │ │ +00059840: 6c6f 636b 293b 0a09 0909 0909 0965 6c73  lock);.......els
    │ │ │ +00059850: 650a 0909 0909 0909 0972 6574 2e66 6169  e........ret.fai
    │ │ │ +00059860: 6c65 642e 656d 706c 6163 655f 6261 636b  led.emplace_back
    │ │ │ +00059870: 2870 6965 6365 2c20 7374 643a 3a76 6563  (piece, std::vec
    │ │ │ +00059880: 746f 7226 6c74 3b69 6e74 2667 743b 7b62  tor<int>{b
    │ │ │ +00059890: 6c6f 636b 7d29 3b0a 0a09 0909 0909 092f  lock});......../
    │ │ │ +000598a0: 2f20 6e6f 7720 7468 6174 2074 6869 7320  / now that this 
    │ │ │ +000598b0: 6861 7368 2068 6173 2062 6565 6e20 7265  hash has been re
    │ │ │ +000598c0: 706f 7274 6564 2061 7320 6661 696c 696e  ported as failin
    │ │ │ +000598d0: 672c 2077 650a 0909 0909 0909 2f2f 2063  g, we.......// c
    │ │ │ +000598e0: 616e 2063 6c65 6172 2069 742e 2054 6869  an clear it. Thi
    │ │ │ +000598f0: 7320 7769 6c6c 2070 7265 7665 6e74 2069  s will prevent i
    │ │ │ +00059900: 7420 6672 6f6d 2062 6569 6e67 0a09 0909  t from being....
    │ │ │ +00059910: 0909 092f 2f20 7265 706f 7274 6564 2061  ...// reported a
    │ │ │ +00059920: 7320 6661 696c 696e 6720 6167 6169 6e2e  s failing again.
    │ │ │ +00059930: 0a09 0909 0909 096d 5f74 7265 655b 6473  .......m_tree[ds
    │ │ │ +00059940: 745f 6964 785d 2e63 6c65 6172 2829 3b0a  t_idx].clear();.
    │ │ │ +00059950: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e  
    │ │ │ +00059960: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +00059990: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0
    ../sr │ │ │ +000599c0: 632f 6d65 726b 6c65 5f74 7265 652e 6370 c/merkle_tree.cp │ │ │ +000599d0: 703a 3534 373c 2f61 3e3c 2f74 643e 3c74 p:547instead of ove │ │ │ +000599f0: 7277 7269 7469 6e67 2074 6865 2072 6f6f rwriting the roo │ │ │ +00059a00: 7420 616e 6420 636f 6d70 6172 696e 6720 t and comparing │ │ │ +00059a10: 6974 2061 6761 696e 7374 2068 6173 6865 it against hashe │ │ │ +00059a20: 735b 5d2c 2077 7269 7465 2061 2066 756e s[], write a fun │ │ │ +00059a30: 6374 696f 6e73 2074 6861 7420 2a76 616c ctions that *val │ │ │ +00059a40: 6964 6174 6573 2a20 6120 7472 6565 2062 idates* a tree b │ │ │ +00059a50: 7920 6a75 7374 2066 696c 6c69 6e67 2069 y just filling i │ │ │ +00059a60: 7420 7570 2074 6f20 7468 6520 6c65 7665 t up to the leve │ │ │ +00059a70: 6c20 6265 6c6f 7720 7468 6520 726f 6f74 l below the root │ │ │ +00059a80: 2061 6e64 2074 6865 6e20 7661 6c69 6461 and then valida │ │ │ +00059a90: 7465 7320 6974 2e3c 2f74 643e 3c2f 7472 tes it.

    instead of │ │ │ +00059af0: 6f76 6572 7772 6974 696e 6720 7468 6520 overwriting the │ │ │ +00059b00: 726f 6f74 2061 6e64 2063 6f6d 7061 7269 root and compari │ │ │ +00059b10: 6e67 2069 740a 6167 6169 6e73 7420 6861 ng it.against ha │ │ │ +00059b20: 7368 6573 5b5d 2c20 7772 6974 6520 6120 shes[], write a │ │ │ +00059b30: 6675 6e63 7469 6f6e 7320 7468 6174 202a functions that * │ │ │ +00059b40: 7661 6c69 6461 7465 732a 2061 2074 7265 validates* a tre │ │ │ +00059b50: 650a 6279 206a 7573 7420 6669 6c6c 696e e.by just fillin │ │ │ +00059b60: 6720 6974 2075 7020 746f 2074 6865 206c g it up to the l │ │ │ +00059b70: 6576 656c 2062 656c 6f77 2074 6865 2072 evel below the r │ │ │ +00059b80: 6f6f 7420 616e 6420 7468 656e 0a76 616c oot and then.val │ │ │ +00059b90: 6964 6174 6573 2069 742e 3c2f 6832 3e3c idates it.

    < │ │ │ +00059ba0: 6834 3e2e 2e2f 7372 632f 6d65 726b 6c65 h4>../src/merkle │ │ │ +00059bb0: 5f74 7265 652e 6370 703a 3534 373c 2f68 _tree.cpp:547
    ...&
    │ │ │ +00059c00: 616d 703b 2661 6d70 3b20 6465 7374 5f73  amp;& dest_s
    │ │ │ +00059c10: 7461 7274 5f69 6478 2026 6c74 3b20 6669  tart_idx < fi
    │ │ │ +00059c20: 7273 745f 7069 6563 655f 6964 7820 2b20  rst_piece_idx + 
    │ │ │ +00059c30: 6e75 6d5f 7069 6563 6573 2829 290a 0909  num_pieces())...
    │ │ │ +00059c40: 7b0a 0909 0969 6e74 2063 6f6e 7374 2062  {....int const b
    │ │ │ +00059c50: 6c6f 636b 735f 696e 5f70 6965 6365 203d  locks_in_piece =
    │ │ │ +00059c60: 2031 2026 6c74 3b26 6c74 3b20 6261 7365   1 << base
    │ │ │ +00059c70: 3b0a 0a09 0909 2f2f 2069 7420 6d61 7920  ;.....// it may 
    │ │ │ +00059c80: 6e6f 7720 6265 2070 6f73 7369 626c 6520  now be possible 
    │ │ │ +00059c90: 746f 2076 6572 6966 7920 7468 6520 6861  to verify the ha
    │ │ │ +00059ca0: 7368 6573 206f 6620 7072 6576 696f 7573  shes of previous
    │ │ │ +00059cb0: 6c79 2072 6563 6569 7665 6420 626c 6f63  ly received bloc
    │ │ │ +00059cc0: 6b73 0a09 0909 2f2f 2074 7279 2074 6f20  ks....// try to 
    │ │ │ +00059cd0: 7665 7269 6679 2061 7320 6d61 6e79 2063  verify as many c
    │ │ │ +00059ce0: 6869 6c64 206e 6f64 6573 206f 6620 7468  hild nodes of th
    │ │ │ +00059cf0: 6520 7265 6365 6976 6564 2068 6173 6865  e received hashe
    │ │ │ +00059d00: 7320 6173 2070 6f73 7369 626c 650a 0909  s as possible...
    │ │ │ +00059d10: 0966 6f72 2028 696e 7420 6920 3d20 303b  .for (int i = 0;
    │ │ │ +00059d20: 2069 2026 6c74 3b20 696e 7428 6861 7368   i < int(hash
    │ │ │ +00059d30: 6573 2e73 697a 6528 2929 3b20 2b2b 6929  es.size()); ++i)
    │ │ │ +00059d40: 0a09 0909 7b0a 0909 0909 696e 7420 636f  ....{.....int co
    │ │ │ +00059d50: 6e73 7420 7069 6563 6520 3d20 6465 7374  nst piece = dest
    │ │ │ +00059d60: 5f73 7461 7274 5f69 6478 202b 2069 3b0a  _start_idx + i;.
    │ │ │ +00059d70: 0909 0909 6966 2028 7069 6563 6520 2d20  ....if (piece - 
    │ │ │ +00059d80: 6669 7273 745f 7069 6563 655f 6964 7820  first_piece_idx 
    │ │ │ +00059d90: 2667 743b 3d20 6e75 6d5f 7069 6563 6573  >= num_pieces
    │ │ │ +00059da0: 2829 290a 0909 0909 0962 7265 616b 3b0a  ())......break;.
    │ │ │ +00059db0: 0909 0909 2f2f 2074 6865 2066 6972 7374  ....// the first
    │ │ │ +00059dc0: 2062 6c6f 636b 2069 6e20 7468 6973 2070   block in this p
    │ │ │ +00059dd0: 6965 6365 0a09 0909 0969 6e74 2063 6f6e  iece.....int con
    │ │ │ +00059de0: 7374 2062 6c6f 636b 5f69 6478 203d 206d  st block_idx = m
    │ │ │ +00059df0: 6572 6b6c 655f 6765 745f 6669 7273 745f  erkle_get_first_
    │ │ │ +00059e00: 6368 696c 6428 7069 6563 652c 2062 6173  child(piece, bas
    │ │ │ +00059e10: 6529 3b0a 0a09 0909 0969 6e74 2063 6f6e  e);......int con
    │ │ │ +00059e20: 7374 2062 6c6f 636b 5f65 6e64 5f69 6478  st block_end_idx
    │ │ │ +00059e30: 203d 2073 7464 3a3a 6d69 6e28 626c 6f63   = std::min(bloc
    │ │ │ +00059e40: 6b5f 6964 7820 2b20 626c 6f63 6b73 5f69  k_idx + blocks_i
    │ │ │ +00059e50: 6e5f 7069 6563 652c 2066 6972 7374 5f6c  n_piece, first_l
    │ │ │ +00059e60: 6561 6620 2b20 6d5f 6e75 6d5f 626c 6f63  eaf + m_num_bloc
    │ │ │ +00059e70: 6b73 293b 0a09 0909 0969 6620 2873 7464  ks);.....if (std
    │ │ │ +00059e80: 3a3a 616e 795f 6f66 286d 5f74 7265 652e  ::any_of(m_tree.
    │ │ │ +00059e90: 6265 6769 6e28 2920 2b20 626c 6f63 6b5f  begin() + block_
    │ │ │ +00059ea0: 6964 780a 0909 0909 092c 206d 5f74 7265  idx......, m_tre
    │ │ │ +00059eb0: 652e 6265 6769 6e28 2920 2b20 626c 6f63  e.begin() + bloc
    │ │ │ +00059ec0: 6b5f 656e 645f 6964 780a 0909 0909 092c  k_end_idx......,
    │ │ │ +00059ed0: 205b 5d28 7368 6132 3536 5f68 6173 6820   [](sha256_hash 
    │ │ │ +00059ee0: 636f 6e73 7426 616d 703b 2068 2920 7b20  const& h) { 
    │ │ │ +00059ef0: 7265 7475 726e 2068 2e69 735f 616c 6c5f  return h.is_all_
    │ │ │ +00059f00: 7a65 726f 7328 293b 207d 2929 0a09 0909  zeros(); }))....
    │ │ │ +00059f10: 0909 636f 6e74 696e 7565 3b0a 0a3c 6469  ..continue;......m
    │ │ │ +00059f50: 6572 6b6c 655f 6669 6c6c 5f74 7265 6528  erkle_fill_tree(
    │ │ │ +00059f60: 6d5f 7472 6565 2c20 626c 6f63 6b73 5f69  m_tree, blocks_i
    │ │ │ +00059f70: 6e5f 7069 6563 652c 2062 6c6f 636b 5f69  n_piece, block_i
    │ │ │ +00059f80: 6478 293b 0a3c 2f64 6976 3e09 0909 0969  dx);.....i
    │ │ │ +00059f90: 6620 286d 5f74 7265 655b 7069 6563 655d  f (m_tree[piece]
    │ │ │ +00059fa0: 2021 3d20 6861 7368 6573 5b69 5d29 0a09   != hashes[i])..
    │ │ │ +00059fb0: 0909 097b 0a09 0909 0909 6d65 726b 6c65  ...{......merkle
    │ │ │ +00059fc0: 5f63 6c65 6172 5f74 7265 6528 6d5f 7472  _clear_tree(m_tr
    │ │ │ +00059fd0: 6565 2c20 626c 6f63 6b73 5f69 6e5f 7069  ee, blocks_in_pi
    │ │ │ +00059fe0: 6563 652c 2062 6c6f 636b 5f69 6478 293b  ece, block_idx);
    │ │ │ +00059ff0: 0a09 0909 0909 2f2f 2077 7269 7465 2062  ......// write b
    │ │ │ +0005a000: 6163 6b20 7468 6520 636f 7272 6563 7420  ack the correct 
    │ │ │ +0005a010: 6861 7368 0a09 0909 0909 6d5f 7472 6565  hash......m_tree
    │ │ │ +0005a020: 5b70 6965 6365 5d20 3d20 6861 7368 6573  [piece] = hashes
    │ │ │ +0005a030: 5b69 5d3b 0a09 0909 0909 544f 5252 454e  [i];......TORREN
    │ │ │ +0005a040: 545f 4153 5345 5254 2862 6c6f 636b 735f  T_ASSERT(blocks_
    │ │ │ +0005a050: 696e 5f70 6965 6365 203d 3d20 626c 6f63  in_piece == bloc
    │ │ │ +0005a060: 6b73 5f70 6572 5f70 6965 6365 2829 293b  ks_per_piece());
    │ │ │ +0005a070: 0a0a 0909 0909 092f 2f20 616e 2065 6d70  .......// an emp
    │ │ │ +0005a080: 7479 2062 6c6f 636b 7320 7665 6374 6f72  ty blocks vector
    │ │ │ +0005a090: 2069 6e64 6963 6174 6573 2074 6861 7420   indicates that 
    │ │ │ +0005a0a0: 7765 2064 6f6e 2774 2068 6176 6520 7468  we don't have th
    │ │ │ +0005a0b0: 650a 0909 0909 092f 2f20 626c 6f63 6b20  e......// block 
    │ │ │ +0005a0c0: 6861 7368 6573 2c20 616e 6420 7765 2063  hashes, and we c
    │ │ │ +0005a0d0: 616e 2774 206b 6e6f 7720 7768 6963 6820  an't know which 
    │ │ │ +0005a0e0: 626c 6f63 6b20 6661 696c 6564 0a09 0909  block failed....
    │ │ │ +0005a0f0: 0909 2f2f 2074 6869 7320 7769 6c6c 2063  ..// this will c
    │ │ │ +0005a100: 6175 7365 2074 6865 2062 6c6f 636b 2068  ause the block h
    │ │ │ +0005a110: 6173 6865 7320 746f 2062 6520 7265 7175  ashes to be requ
    │ │ │ +0005a120: 6573 7465 640a 0909 0909 0972 6574 2e66  ested......ret.f
    │ │ │ +0005a130: 6169 6c65 642e 656d 706c 6163 655f 6261  ailed.emplace_ba
    │ │ │ +0005a140: 636b 2870 6965 6365 5f69 6e64 6578 5f74  ck(piece_index_t
    │ │ │ +0005a150: 7b70 6965 6365 202d 2066 6972 7374 5f70  {piece - first_p
    │ │ │ +0005a160: 6965 6365 5f69 6478 7d20 2b20 6669 6c65  iece_idx} + file
    │ │ │ +0005a170: 5f70 6965 6365 5f6f 6666 7365 740a 0909  _piece_offset...
    │ │ │ +0005a180: 0909 0909 2c20 7374 643a 3a76 6563 746f  ...., std::vecto
    │ │ │ +0005a190: 7226 6c74 3b69 6e74 2667 743b 2829 293b  r<int>());
    │ │ │ +0005a1a0: 0a09 0909 097d 0a09 0909 0965 6c73 650a  .....}.....else.
    │ │ │ +0005a1b0: 0909 0909 7b0a 0909 0909 0972 6574 2e70  ....{......ret.p
    │ │ │ +0005a1c0: 6173 7365 642e 7075 7368 5f62 6163 6b28  assed.push_back(
    │ │ │ +0005a1d0: 7069 6563 655f 696e 6465 785f 747b 7069  piece_index_t{pi
    │ │ │ +0005a1e0: 6563 6520 2d20 6669 7273 745f 7069 6563  ece - first_piec
    │ │ │ +0005a1f0: 655f 6964 787d 202b 2066 696c 655f 7069  e_idx} + file_pi
    │ │ │ +0005a200: 6563 655f 6f66 6673 6574 293b 0a09 0909  ece_offset);....
    │ │ │ +0005a210: 0909 2f2f 2072 6563 6f72 6420 7468 6174  ..// record that
    │ │ │ +0005a220: 2074 6865 7365 2062 6c6f 636b 2068 6173   these block has
    │ │ │ +0005a230: 6865 7320 6172 6520 636f 7272 6563 7421  hes are correct!
    │ │ │ +0005a240: 0a09 0909 0909 696e 7420 636f 6e73 7420  ......int const 
    │ │ │ +0005a250: 6c65 6166 735f 7374 6172 7420 3d20 626c  leafs_start = bl
    │ │ │ +0005a260: 6f63 6b5f 6964 7820 2d20 626c 6f63 6b5f  ock_idx - block_
    │ │ │ +0005a270: 6c61 7965 725f 7374 6172 7428 293b 0a09  layer_start();..
    │ │ │ +0005a280: 0909 0909 696e 7420 636f 6e73 7420 6c65  ....int const le
    │ │ │ +0005a290: 6166 735f 656e 6420 3d20 7374 643a 3a6d  afs_end = std::m
    │ │ │ +0005a2a0: 696e 286d 5f6e 756d 5f62 6c6f 636b 732c  in(m_num_blocks,
    │ │ │ +0005a2b0: 206c 6561 6673 5f73 7461 7274 202b 2062   leafs_start + b
    │ │ │ +0005a2c0: 6c6f 636b 735f 696e 5f70 6965 6365 293b  locks_in_piece);
    │ │ │ +0005a2d0: 0a3c 2f70 7265 3e3c 2f74 643e 3c2f 7472  .
    relevance  │ │ │ +0005a310: 3b30 3c2f 7464 3e3c 7464 3e3c 6120 6872 ;0../s │ │ │ +0005a340: 7263 2f6d 6572 6b6c 655f 7472 6565 2e63 rc/merkle_tree.c │ │ │ +0005a350: 7070 3a35 3731 3c2f 613e 3c2f 7464 3e3c pp:571< │ │ │ +0005a360: 7464 3e74 6869 7320 636f 756c 6420 6265 td>this could be │ │ │ +0005a370: 2064 6f6e 6520 6d6f 7265 2065 6666 6963 done more effic │ │ │ +0005a380: 6965 6e74 6c79 2069 6620 6269 7466 6965 iently if bitfie │ │ │ +0005a390: 6c64 2068 6164 2061 2066 756e 6374 696f ld had a functio │ │ │ +0005a3a0: 6e20 746f 2073 6574 2061 2072 616e 6765 n to set a range │ │ │ +0005a3b0: 206f 6620 6269 7473 3c2f 7464 3e3c 2f74 of bits

    this could │ │ │ +0005a410: 2062 6520 646f 6e65 206d 6f72 6520 6566 be done more ef │ │ │ +0005a420: 6669 6369 656e 746c 7920 6966 2062 6974 ficiently if bit │ │ │ +0005a430: 6669 656c 6420 6861 6420 6120 6675 6e63 field had a func │ │ │ +0005a440: 7469 6f6e 0a74 6f20 7365 7420 6120 7261 tion.to set a ra │ │ │ +0005a450: 6e67 6520 6f66 2062 6974 733c 2f68 323e nge of bits

    │ │ │ +0005a460: 3c68 343e 2e2e 2f73 7263 2f6d 6572 6b6c

    ../src/merkl │ │ │ +0005a470: 655f 7472 6565 2e63 7070 3a35 3731 3c2f e_tree.cpp:571
    ...
    │ │ │ +0005a4c0: 096d 6572 6b6c 655f 6669 6c6c 5f74 7265  .merkle_fill_tre
    │ │ │ +0005a4d0: 6528 6d5f 7472 6565 2c20 626c 6f63 6b73  e(m_tree, blocks
    │ │ │ +0005a4e0: 5f69 6e5f 7069 6563 652c 2062 6c6f 636b  _in_piece, block
    │ │ │ +0005a4f0: 5f69 6478 293b 0a09 0909 0969 6620 286d  _idx);.....if (m
    │ │ │ +0005a500: 5f74 7265 655b 7069 6563 655d 2021 3d20  _tree[piece] != 
    │ │ │ +0005a510: 6861 7368 6573 5b69 5d29 0a09 0909 097b  hashes[i]).....{
    │ │ │ +0005a520: 0a09 0909 0909 6d65 726b 6c65 5f63 6c65  ......merkle_cle
    │ │ │ +0005a530: 6172 5f74 7265 6528 6d5f 7472 6565 2c20  ar_tree(m_tree, 
    │ │ │ +0005a540: 626c 6f63 6b73 5f69 6e5f 7069 6563 652c  blocks_in_piece,
    │ │ │ +0005a550: 2062 6c6f 636b 5f69 6478 293b 0a09 0909   block_idx);....
    │ │ │ +0005a560: 0909 2f2f 2077 7269 7465 2062 6163 6b20  ..// write back 
    │ │ │ +0005a570: 7468 6520 636f 7272 6563 7420 6861 7368  the correct hash
    │ │ │ +0005a580: 0a09 0909 0909 6d5f 7472 6565 5b70 6965  ......m_tree[pie
    │ │ │ +0005a590: 6365 5d20 3d20 6861 7368 6573 5b69 5d3b  ce] = hashes[i];
    │ │ │ +0005a5a0: 0a09 0909 0909 544f 5252 454e 545f 4153  ......TORRENT_AS
    │ │ │ +0005a5b0: 5345 5254 2862 6c6f 636b 735f 696e 5f70  SERT(blocks_in_p
    │ │ │ +0005a5c0: 6965 6365 203d 3d20 626c 6f63 6b73 5f70  iece == blocks_p
    │ │ │ +0005a5d0: 6572 5f70 6965 6365 2829 293b 0a0a 0909  er_piece());....
    │ │ │ +0005a5e0: 0909 092f 2f20 616e 2065 6d70 7479 2062  ...// an empty b
    │ │ │ +0005a5f0: 6c6f 636b 7320 7665 6374 6f72 2069 6e64  locks vector ind
    │ │ │ +0005a600: 6963 6174 6573 2074 6861 7420 7765 2064  icates that we d
    │ │ │ +0005a610: 6f6e 2774 2068 6176 6520 7468 650a 0909  on't have the...
    │ │ │ +0005a620: 0909 092f 2f20 626c 6f63 6b20 6861 7368  ...// block hash
    │ │ │ +0005a630: 6573 2c20 616e 6420 7765 2063 616e 2774  es, and we can't
    │ │ │ +0005a640: 206b 6e6f 7720 7768 6963 6820 626c 6f63   know which bloc
    │ │ │ +0005a650: 6b20 6661 696c 6564 0a09 0909 0909 2f2f  k failed......//
    │ │ │ +0005a660: 2074 6869 7320 7769 6c6c 2063 6175 7365   this will cause
    │ │ │ +0005a670: 2074 6865 2062 6c6f 636b 2068 6173 6865   the block hashe
    │ │ │ +0005a680: 7320 746f 2062 6520 7265 7175 6573 7465  s to be requeste
    │ │ │ +0005a690: 640a 0909 0909 0972 6574 2e66 6169 6c65  d......ret.faile
    │ │ │ +0005a6a0: 642e 656d 706c 6163 655f 6261 636b 2870  d.emplace_back(p
    │ │ │ +0005a6b0: 6965 6365 5f69 6e64 6578 5f74 7b70 6965  iece_index_t{pie
    │ │ │ +0005a6c0: 6365 202d 2066 6972 7374 5f70 6965 6365  ce - first_piece
    │ │ │ +0005a6d0: 5f69 6478 7d20 2b20 6669 6c65 5f70 6965  _idx} + file_pie
    │ │ │ +0005a6e0: 6365 5f6f 6666 7365 740a 0909 0909 0909  ce_offset.......
    │ │ │ +0005a6f0: 2c20 7374 643a 3a76 6563 746f 7226 6c74  , std::vector<
    │ │ │ +0005a700: 3b69 6e74 2667 743b 2829 293b 0a09 0909  ;int>());....
    │ │ │ +0005a710: 097d 0a09 0909 0965 6c73 650a 0909 0909  .}.....else.....
    │ │ │ +0005a720: 7b0a 0909 0909 0972 6574 2e70 6173 7365  {......ret.passe
    │ │ │ +0005a730: 642e 7075 7368 5f62 6163 6b28 7069 6563  d.push_back(piec
    │ │ │ +0005a740: 655f 696e 6465 785f 747b 7069 6563 6520  e_index_t{piece 
    │ │ │ +0005a750: 2d20 6669 7273 745f 7069 6563 655f 6964  - first_piece_id
    │ │ │ +0005a760: 787d 202b 2066 696c 655f 7069 6563 655f  x} + file_piece_
    │ │ │ +0005a770: 6f66 6673 6574 293b 0a09 0909 0909 2f2f  offset);......//
    │ │ │ +0005a780: 2072 6563 6f72 6420 7468 6174 2074 6865   record that the
    │ │ │ +0005a790: 7365 2062 6c6f 636b 2068 6173 6865 7320  se block hashes 
    │ │ │ +0005a7a0: 6172 6520 636f 7272 6563 7421 0a09 0909  are correct!....
    │ │ │ +0005a7b0: 0909 696e 7420 636f 6e73 7420 6c65 6166  ..int const leaf
    │ │ │ +0005a7c0: 735f 7374 6172 7420 3d20 626c 6f63 6b5f  s_start = block_
    │ │ │ +0005a7d0: 6964 7820 2d20 626c 6f63 6b5f 6c61 7965  idx - block_laye
    │ │ │ +0005a7e0: 725f 7374 6172 7428 293b 0a09 0909 0909  r_start();......
    │ │ │ +0005a7f0: 696e 7420 636f 6e73 7420 6c65 6166 735f  int const leafs_
    │ │ │ +0005a800: 656e 6420 3d20 7374 643a 3a6d 696e 286d  end = std::min(m
    │ │ │ +0005a810: 5f6e 756d 5f62 6c6f 636b 732c 206c 6561  _num_blocks, lea
    │ │ │ +0005a820: 6673 5f73 7461 7274 202b 2062 6c6f 636b  fs_start + block
    │ │ │ +0005a830: 735f 696e 5f70 6965 6365 293b 0a3c 6469  s_in_piece);......
    │ │ │ +0005a870: 666f 7220 2869 6e74 206b 203d 206c 6561  for (int k = lea
    │ │ │ +0005a880: 6673 5f73 7461 7274 3b20 6b20 266c 743b  fs_start; k <
    │ │ │ +0005a890: 206c 6561 6673 5f65 6e64 3b20 2b2b 6b29   leafs_end; ++k)
    │ │ │ +0005a8a0: 0a3c 2f64 6976 3e09 0909 0909 096d 5f62  .......m_b
    │ │ │ +0005a8b0: 6c6f 636b 5f76 6572 6966 6965 642e 7365  lock_verified.se
    │ │ │ +0005a8c0: 745f 6269 7428 6b29 3b0a 0909 0909 7d0a  t_bit(k);.....}.
    │ │ │ +0005a8d0: 0909 0909 544f 5252 454e 545f 4153 5345  ....TORRENT_ASSE
    │ │ │ +0005a8e0: 5254 2828 7069 6563 6520 2d20 6669 7273  RT((piece - firs
    │ │ │ +0005a8f0: 745f 7069 6563 655f 6964 7829 2026 6774  t_piece_idx) >
    │ │ │ +0005a900: 3b3d 2030 293b 0a09 0909 7d0a 0909 7d0a  ;= 0);....}...}.
    │ │ │ +0005a910: 0a09 096f 7074 696d 697a 655f 7374 6f72  ...optimize_stor
    │ │ │ +0005a920: 6167 6528 293b 0a0a 0909 7265 7475 726e  age();....return
    │ │ │ +0005a930: 2072 6574 3b0a 097d 0a0a 0973 7464 3a3a   ret;..}...std::
    │ │ │ +0005a940: 7475 706c 6526 6c74 3b6d 6572 6b6c 655f  tuple<merkle_
    │ │ │ +0005a950: 7472 6565 3a3a 7365 745f 626c 6f63 6b5f  tree::set_block_
    │ │ │ +0005a960: 7265 7375 6c74 2c20 696e 742c 2069 6e74  result, int, int
    │ │ │ +0005a970: 2667 743b 206d 6572 6b6c 655f 7472 6565  > merkle_tree
    │ │ │ +0005a980: 3a3a 7365 745f 626c 6f63 6b28 696e 7420  ::set_block(int 
    │ │ │ +0005a990: 636f 6e73 7420 626c 6f63 6b5f 696e 6465  const block_inde
    │ │ │ +0005a9a0: 780a 0909 2c20 7368 6132 3536 5f68 6173  x..., sha256_has
    │ │ │ +0005a9b0: 6820 636f 6e73 7426 616d 703b 2068 290a  h const& h).
    │ │ │ +0005a9c0: 097b 0a23 6966 6465 6620 544f 5252 454e  .{.#ifdef TORREN
    │ │ │ +0005a9d0: 545f 4558 5045 4e53 4956 455f 494e 5641  T_EXPENSIVE_INVA
    │ │ │ +0005a9e0: 5249 414e 545f 4348 4543 4b53 0a09 0949  RIANT_CHECKS...I
    │ │ │ +0005a9f0: 4e56 4152 4941 4e54 5f43 4845 434b 3b0a  NVARIANT_CHECK;.
    │ │ │ +0005aa00: 2365 6e64 6966 0a09 0954 4f52 5245 4e54  #endif...TORRENT
    │ │ │ +0005aa10: 5f41 5353 4552 5428 626c 6f63 6b5f 696e  _ASSERT(block_in
    │ │ │ +0005aa20: 6465 7820 266c 743b 206d 5f6e 756d 5f62  dex < m_num_b
    │ │ │ +0005aa30: 6c6f 636b 7329 3b0a 0a09 0961 7574 6f20  locks);....auto 
    │ │ │ +0005aa40: 636f 6e73 7420 6e75 6d5f 6c65 6166 7320  const num_leafs 
    │ │ │ +0005aa50: 3d20 6d65 726b 6c65 5f6e 756d 5f6c 6561  = merkle_num_lea
    │ │ │ +0005aa60: 6673 286d 5f6e 756d 5f62 6c6f 636b 7329  fs(m_num_blocks)
    │ │ │ +0005aa70: 3b0a 0909 6175 746f 2063 6f6e 7374 2066  ;...auto const f
    │ │ │ +0005aa80: 6972 7374 5f6c 6561 6620 3d20 6d65 726b  irst_leaf = merk
    │ │ │ +0005aa90: 6c65 5f66 6972 7374 5f6c 6561 6628 6e75  le_first_leaf(nu
    │ │ │ +0005aaa0: 6d5f 6c65 6166 7329 3b0a 0909 6175 746f  m_leafs);...auto
    │ │ │ +0005aab0: 2063 6f6e 7374 2062 6c6f 636b 5f74 7265   const block_tre
    │ │ │ +0005aac0: 655f 696e 6465 7820 3d20 6669 7273 745f  e_index = first_
    │ │ │ +0005aad0: 6c65 6166 202b 2062 6c6f 636b 5f69 6e64  leaf + block_ind
    │ │ │ +0005aae0: 6578 3b0a 0a09 0969 6620 2862 6c6f 636b  ex;....if (block
    │ │ │ +0005aaf0: 735f 7665 7269 6669 6564 2862 6c6f 636b  s_verified(block
    │ │ │ +0005ab00: 5f69 6e64 6578 2c20 3129 290a 0909 7b0a  _index, 1))...{.
    │ │ │ +0005ab10: 0909 092f 2f20 6966 2074 6869 7320 626c  ...// if this bl
    │ │ │ +0005ab20: 6f63 6b73 2773 2068 6173 6820 6973 2061  ocks's hash is a
    │ │ │ +0005ab30: 6c72 6561 6479 206b 6e6f 776e 2c20 6368  lready known, ch
    │ │ │ +0005ab40: 6563 6b20 7468 6520 7061 7373 6564 2d69  eck the passed-i
    │ │ │ +0005ab50: 6e20 6861 7368 2061 6761 696e 7374 2069  n hash against i
    │ │ │ +0005ab60: 740a 0909 0969 6620 2863 6f6d 7061 7265  t....if (compare
    │ │ │ +0005ab70: 5f6e 6f64 6528 626c 6f63 6b5f 7472 6565  _node(block_tree
    │ │ │ +0005ab80: 5f69 6e64 6578 2c20 6829 290a 0909 0909  _index, h)).....
    │ │ │ +0005ab90: 7265 7475 726e 2073 7464 3a3a 6d61 6b65  return std::make
    │ │ │ +0005aba0: 5f74 7570 6c65 2873 6574 5f62 6c6f 636b  _tuple(set_block
    │ │ │ +0005abb0: 5f72 6573 756c 743a 3a6f 6b2c 2062 6c6f  _result::ok, blo
    │ │ │ +0005abc0: 636b 5f69 6e64 6578 2c20 3129 3b0a 0909  ck_index, 1);...
    │ │ │ +0005abd0: 0965 6c73 650a 0909 0909 7265 7475 726e  .else.....return
    │ │ │ +0005abe0: 2073 7464 3a3a 6d61 6b65 5f74 7570 6c65   std::make_tuple
    │ │ │ +0005abf0: 2873 6574 5f62 6c6f 636b 5f72 6573 756c  (set_block_resul
    │ │ │ +0005ac00: 743a 3a62 6c6f 636b 5f68 6173 685f 6661  t::block_hash_fa
    │ │ │ +0005ac10: 696c 6564 2c20 626c 6f63 6b5f 696e 6465  iled, block_inde
    │ │ │ +0005ac20: 782c 2031 293b 0a3c 2f70 7265 3e3c 2f74  x, 1);.
    relevanc │ │ │ +0005ac60: 6526 6e62 7370 3b30 3c2f 7464 3e3c 7464 e 0../src/merkle_ │ │ │ +0005aca0: 7472 6565 2e63 7070 3a36 3339 3c2f 613e tree.cpp:639 │ │ │ +0005acb0: 3c2f 7464 3e3c 7464 3e74 6869 7320 636f this co │ │ │ +0005acc0: 756c 6420 6265 2064 6f6e 6520 6d6f 7265 uld be done more │ │ │ +0005acd0: 2065 6666 6963 6965 6e74 6c79 2069 6620 efficiently if │ │ │ +0005ace0: 6269 7466 6965 6c64 2068 6164 2061 2066 bitfield had a f │ │ │ +0005acf0: 756e 6374 696f 6e20 746f 2073 6574 2061 unction to set a │ │ │ +0005ad00: 2072 616e 6765 206f 6620 6269 7473 3c2f range of bits

    this │ │ │ +0005ad60: 2063 6f75 6c64 2062 6520 646f 6e65 206d could be done m │ │ │ +0005ad70: 6f72 6520 6566 6669 6369 656e 746c 7920 ore efficiently │ │ │ +0005ad80: 6966 2062 6974 6669 656c 6420 6861 6420 if bitfield had │ │ │ +0005ad90: 6120 6675 6e63 7469 6f6e 0a74 6f20 7365 a function.to se │ │ │ +0005ada0: 7420 6120 7261 6e67 6520 6f66 2062 6974 t a range of bit │ │ │ +0005adb0: 733c 2f68 323e 3c68 343e 2e2e 2f73 7263 s

    ../src │ │ │ +0005adc0: 2f6d 6572 6b6c 655f 7472 6565 2e63 7070 /merkle_tree.cpp │ │ │ +0005add0: 3a36 3339 3c2f 6834 3e3c 7072 6520 7374 :639

    ...return std
    │ │ │ +0005ae20: 3a3a 6d61 6b65 5f74 7570 6c65 2873 6574  ::make_tuple(set
    │ │ │ +0005ae30: 5f62 6c6f 636b 5f72 6573 756c 743a 3a75  _block_result::u
    │ │ │ +0005ae40: 6e6b 6e6f 776e 2c20 6c65 6166 735f 7374  nknown, leafs_st
    │ │ │ +0005ae50: 6172 742c 206c 6561 6673 5f73 697a 6529  art, leafs_size)
    │ │ │ +0005ae60: 3b0a 0a09 092f 2f20 7361 7665 2074 6865  ;....// save the
    │ │ │ +0005ae70: 2072 6f6f 7420 6861 7368 2062 6563 6175   root hash becau
    │ │ │ +0005ae80: 7365 206d 6572 6b6c 655f 6669 6c6c 5f74  se merkle_fill_t
    │ │ │ +0005ae90: 7265 6520 7769 6c6c 206f 7665 7277 7269  ree will overwri
    │ │ │ +0005aea0: 7465 2069 740a 0909 7368 6132 3536 5f68  te it...sha256_h
    │ │ │ +0005aeb0: 6173 6820 636f 6e73 7420 726f 6f74 203d  ash const root =
    │ │ │ +0005aec0: 206d 5f74 7265 655b 726f 6f74 5f69 6e64   m_tree[root_ind
    │ │ │ +0005aed0: 6578 5d3b 0a09 096d 6572 6b6c 655f 6669  ex];...merkle_fi
    │ │ │ +0005aee0: 6c6c 5f74 7265 6528 6d5f 7472 6565 2c20  ll_tree(m_tree, 
    │ │ │ +0005aef0: 6c65 6166 735f 7369 7a65 2c20 6669 7273  leafs_size, firs
    │ │ │ +0005af00: 745f 6c65 6166 202b 206c 6561 6673 5f73  t_leaf + leafs_s
    │ │ │ +0005af10: 7461 7274 293b 0a0a 0909 6966 2028 726f  tart);....if (ro
    │ │ │ +0005af20: 6f74 2021 3d20 6d5f 7472 6565 5b72 6f6f  ot != m_tree[roo
    │ │ │ +0005af30: 745f 696e 6465 785d 290a 0909 7b0a 0909  t_index])...{...
    │ │ │ +0005af40: 092f 2f20 6861 7368 2066 6169 6c75 7265  .// hash failure
    │ │ │ +0005af50: 2c20 636c 6561 7220 616c 6c20 7468 6520  , clear all the 
    │ │ │ +0005af60: 696e 7465 726e 616c 206e 6f64 6573 0a09  internal nodes..
    │ │ │ +0005af70: 0909 2f2f 2074 6865 2077 686f 6c65 2070  ..// the whole p
    │ │ │ +0005af80: 6965 6365 2066 6169 6c65 6420 7468 6520  iece failed the 
    │ │ │ +0005af90: 6861 7368 2063 6865 636b 2e20 436c 6561  hash check. Clea
    │ │ │ +0005afa0: 7220 616c 6c20 626c 6f63 6b20 6861 7368  r all block hash
    │ │ │ +0005afb0: 6573 0a09 0909 2f2f 2069 6e20 7468 6973  es....// in this
    │ │ │ +0005afc0: 2070 6965 6365 2061 6e64 2072 6570 6f72   piece and repor
    │ │ │ +0005afd0: 7420 6120 6861 7368 2066 6169 6c75 7265  t a hash failure
    │ │ │ +0005afe0: 0a09 0909 2f2f 0a09 0909 2f2f 2077 6520  ....//....// we 
    │ │ │ +0005aff0: 6361 6e27 7420 7465 6c6c 2077 6869 6368  can't tell which
    │ │ │ +0005b000: 2062 6c6f 636b 2069 6e20 7468 6520 7375   block in the su
    │ │ │ +0005b010: 6274 7265 6520 6973 2077 726f 6e67 2c20  btree is wrong, 
    │ │ │ +0005b020: 6f6e 6c79 2074 6861 740a 0909 092f 2f20  only that....// 
    │ │ │ +0005b030: 7468 6569 7220 636f 6d62 696e 6564 2068  their combined h
    │ │ │ +0005b040: 6173 6820 6e6f 206c 6f6e 6765 7220 6d61  ash no longer ma
    │ │ │ +0005b050: 7463 6865 732c 2073 6f20 6e6f 6e65 206f  tches, so none o
    │ │ │ +0005b060: 6620 7468 656d 2063 616e 0a09 0909 2f2f  f them can....//
    │ │ │ +0005b070: 2073 7469 6c6c 2062 6520 766f 7563 6865   still be vouche
    │ │ │ +0005b080: 6420 666f 7220 696e 6469 7669 6475 616c  d for individual
    │ │ │ +0005b090: 6c79 0a09 0909 6d65 726b 6c65 5f63 6c65  ly....merkle_cle
    │ │ │ +0005b0a0: 6172 5f74 7265 6528 6d5f 7472 6565 2c20  ar_tree(m_tree, 
    │ │ │ +0005b0b0: 6c65 6166 735f 7369 7a65 2c20 6669 7273  leafs_size, firs
    │ │ │ +0005b0c0: 745f 6c65 6166 202b 206c 6561 6673 5f73  t_leaf + leafs_s
    │ │ │ +0005b0d0: 7461 7274 293b 0a09 0909 6d5f 7472 6565  tart);....m_tree
    │ │ │ +0005b0e0: 5b72 6f6f 745f 696e 6465 785d 203d 2072  [root_index] = r
    │ │ │ +0005b0f0: 6f6f 743b 0a09 0909 7265 7475 726e 2073  oot;....return s
    │ │ │ +0005b100: 7464 3a3a 6d61 6b65 5f74 7570 6c65 2873  td::make_tuple(s
    │ │ │ +0005b110: 6574 5f62 6c6f 636b 5f72 6573 756c 743a  et_block_result:
    │ │ │ +0005b120: 3a68 6173 685f 6661 696c 6564 2c20 6c65  :hash_failed, le
    │ │ │ +0005b130: 6166 735f 7374 6172 742c 206c 6561 6673  afs_start, leafs
    │ │ │ +0005b140: 5f73 697a 6529 3b0a 0909 7d0a 0a3c 6469  _size);...}....int
    │ │ │ +0005b180: 2063 6f6e 7374 206c 6561 6673 5f65 6e64   const leafs_end
    │ │ │ +0005b190: 203d 2073 7464 3a3a 6d69 6e28 6d5f 6e75   = std::min(m_nu
    │ │ │ +0005b1a0: 6d5f 626c 6f63 6b73 2c20 6c65 6166 735f  m_blocks, leafs_
    │ │ │ +0005b1b0: 7374 6172 7420 2b20 6c65 6166 735f 7369  start + leafs_si
    │ │ │ +0005b1c0: 7a65 293b 0a3c 2f64 6976 3e09 0966 6f72  ze);...for
    │ │ │ +0005b1d0: 2028 696e 7420 6920 3d20 6c65 6166 735f   (int i = leafs_
    │ │ │ +0005b1e0: 7374 6172 743b 2069 2026 6c74 3b20 6c65  start; i < le
    │ │ │ +0005b1f0: 6166 735f 656e 643b 202b 2b69 290a 0909  afs_end; ++i)...
    │ │ │ +0005b200: 096d 5f62 6c6f 636b 5f76 6572 6966 6965  .m_block_verifie
    │ │ │ +0005b210: 642e 7365 745f 6269 7428 6929 3b0a 0a09  d.set_bit(i);...
    │ │ │ +0005b220: 092f 2f20 6174 7465 6d70 7469 6e67 2074  .// attempting t
    │ │ │ +0005b230: 6f20 6f70 7469 6d69 7a65 2073 746f 7261  o optimize stora
    │ │ │ +0005b240: 6765 2069 7320 7175 6974 6520 636f 7374  ge is quite cost
    │ │ │ +0005b250: 6c79 2c20 6f6e 6c79 2064 6f20 6974 2069  ly, only do it i
    │ │ │ +0005b260: 6620 7765 2068 6176 650a 0909 2f2f 2061  f we have...// a
    │ │ │ +0005b270: 2072 6561 736f 6e20 746f 2062 656c 6965   reason to belie
    │ │ │ +0005b280: 7665 2069 7420 6d69 6768 7420 6861 7665  ve it might have
    │ │ │ +0005b290: 2061 6e20 6566 6665 6374 0a09 0969 6620   an effect...if 
    │ │ │ +0005b2a0: 2862 6c6f 636b 5f69 6e64 6578 203d 3d20  (block_index == 
    │ │ │ +0005b2b0: 6d5f 6e75 6d5f 626c 6f63 6b73 202d 2031  m_num_blocks - 1
    │ │ │ +0005b2c0: 207c 7c20 216d 5f74 7265 655b 626c 6f63   || !m_tree[bloc
    │ │ │ +0005b2d0: 6b5f 7472 6565 5f69 6e64 6578 202b 2031  k_tree_index + 1
    │ │ │ +0005b2e0: 5d2e 6973 5f61 6c6c 5f7a 6572 6f73 2829  ].is_all_zeros()
    │ │ │ +0005b2f0: 290a 0909 096f 7074 696d 697a 655f 7374  )....optimize_st
    │ │ │ +0005b300: 6f72 6167 6528 293b 0a0a 0909 7265 7475  orage();....retu
    │ │ │ +0005b310: 726e 2073 7464 3a3a 6d61 6b65 5f74 7570  rn std::make_tup
    │ │ │ +0005b320: 6c65 2873 6574 5f62 6c6f 636b 5f72 6573  le(set_block_res
    │ │ │ +0005b330: 756c 743a 3a6f 6b2c 206c 6561 6673 5f73  ult::ok, leafs_s
    │ │ │ +0005b340: 7461 7274 2c20 6c65 6166 735f 7369 7a65  tart, leafs_size
    │ │ │ +0005b350: 293b 0a09 7d0a 0a09 7374 643a 3a73 697a  );..}...std::siz
    │ │ │ +0005b360: 655f 7420 6d65 726b 6c65 5f74 7265 653a  e_t merkle_tree:
    │ │ │ +0005b370: 3a73 697a 6528 2920 636f 6e73 740a 097b  :size() const..{
    │ │ │ +0005b380: 0a09 0972 6574 7572 6e20 7374 6174 6963  ...return static
    │ │ │ +0005b390: 5f63 6173 7426 6c74 3b73 7464 3a3a 7369  _cast<std::si
    │ │ │ +0005b3a0: 7a65 5f74 2667 743b 286d 6572 6b6c 655f  ze_t>(merkle_
    │ │ │ +0005b3b0: 6e75 6d5f 6e6f 6465 7328 6d65 726b 6c65  num_nodes(merkle
    │ │ │ +0005b3c0: 5f6e 756d 5f6c 6561 6673 286d 5f6e 756d  _num_leafs(m_num
    │ │ │ +0005b3d0: 5f62 6c6f 636b 7329 2929 3b0a 097d 0a0a  _blocks)));..}..
    │ │ │ +0005b3e0: 0969 6e74 206d 6572 6b6c 655f 7472 6565  .int merkle_tree
    │ │ │ +0005b3f0: 3a3a 6e75 6d5f 7069 6563 6573 2829 2063  ::num_pieces() c
    │ │ │ +0005b400: 6f6e 7374 0a09 7b0a 0909 696e 7420 636f  onst..{...int co
    │ │ │ +0005b410: 6e73 7420 7073 203d 2062 6c6f 636b 735f  nst ps = blocks_
    │ │ │ +0005b420: 7065 725f 7069 6563 6528 293b 0a09 0954  per_piece();...T
    │ │ │ +0005b430: 4f52 5245 4e54 5f41 5353 4552 5428 7073  ORRENT_ASSERT(ps
    │ │ │ +0005b440: 2026 6774 3b20 3029 3b0a 0909 7265 7475   > 0);...retu
    │ │ │ +0005b450: 726e 2028 6d5f 6e75 6d5f 626c 6f63 6b73  rn (m_num_blocks
    │ │ │ +0005b460: 202b 2070 7320 2d20 3129 2026 6774 3b26   + ps - 1) >&
    │ │ │ +0005b470: 6774 3b20 6d5f 626c 6f63 6b73 5f70 6572  gt; m_blocks_per
    │ │ │ +0005b480: 5f70 6965 6365 5f6c 6f67 3b0a 097d 0a0a  _piece_log;..}..
    │ │ │ +0005b490: 0969 6e74 206d 6572 6b6c 655f 7472 6565  .int merkle_tree
    │ │ │ +0005b4a0: 3a3a 626c 6f63 6b5f 6c61 7965 725f 7374  ::block_layer_st
    │ │ │ +0005b4b0: 6172 7428 2920 636f 6e73 740a 097b 0a09  art() const..{..
    │ │ │ +0005b4c0: 0969 6e74 2063 6f6e 7374 206e 756d 5f6c  .int const num_l
    │ │ │ +0005b4d0: 6561 6673 203d 206d 6572 6b6c 655f 6e75  eafs = merkle_nu
    │ │ │ +0005b4e0: 6d5f 6c65 6166 7328 6d5f 6e75 6d5f 626c  m_leafs(m_num_bl
    │ │ │ +0005b4f0: 6f63 6b73 293b 0a09 0954 4f52 5245 4e54  ocks);...TORRENT
    │ │ │ +0005b500: 5f41 5353 4552 5428 6e75 6d5f 6c65 6166  _ASSERT(num_leaf
    │ │ │ +0005b510: 7320 2667 743b 2030 293b 0a09 0972 6574  s > 0);...ret
    │ │ │ +0005b520: 7572 6e20 6d65 726b 6c65 5f66 6972 7374  urn merkle_first
    │ │ │ +0005b530: 5f6c 6561 6628 6e75 6d5f 6c65 6166 7329  _leaf(num_leafs)
    │ │ │ +0005b540: 3b0a 097d 0a0a 3c2f 7072 653e 3c2f 7464  ;..}..
    relevance │ │ │ +0005b580: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +0005b590: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/torrent_ │ │ │ +0005b5c0: 696e 666f 2e63 7070 3a31 3234 373c 2f61 info.cpp:1247this s │ │ │ +0005b5e0: 686f 756c 6420 7573 696e 6720 7468 6520 hould using the │ │ │ +0005b5f0: 7632 2068 6173 6820 666f 7220 7632 2074 v2 hash for v2 t │ │ │ +0005b600: 6f72 7265 6e74 732c 2062 7574 2063 6861 orrents, but cha │ │ │ +0005b610: 6e67 696e 6720 6974 2069 7320 6e6f 7420 nging it is not │ │ │ +0005b620: 6261 636b 7761 7264 7320 636f 6d70 6174 backwards compat │ │ │ +0005b630: 6962 6c65 2e20 5665 7273 696f 6e20 7468 ible. Version th │ │ │ +0005b640: 6520 7361 6e69 7469 7a65 722c 206c 6574 e sanitizer, let │ │ │ +0005b650: 7469 6e67 2074 6865 2063 616c 6c65 7220 ting the caller │ │ │ +0005b660: 7069 636b 2077 6869 6368 2073 616e 6974 pick which sanit │ │ │ +0005b670: 697a 6572 2076 6572 7369 6f6e 2074 6f20 izer version to │ │ │ +0005b680: 7573 652e 2054 6865 6e20 7468 6973 2063 use. Then this c │ │ │ +0005b690: 616e 2062 6520 6669 7865 6420 696e 2061 an be fixed in a │ │ │ +0005b6a0: 6e20 7570 6461 7465 6420 7665 7273 696f n updated versio │ │ │ +0005b6b0: 6e2e 3c2f 7464 3e3c 2f74 723e 3c74 7220 n.

    │ │ │ +0005b700: 7468 6973 2073 686f 756c 6420 7573 696e this should usin │ │ │ +0005b710: 6720 7468 6520 7632 2068 6173 6820 666f g the v2 hash fo │ │ │ +0005b720: 7220 7632 2074 6f72 7265 6e74 732c 2062 r v2 torrents, b │ │ │ +0005b730: 7574 0a63 6861 6e67 696e 6720 6974 2069 ut.changing it i │ │ │ +0005b740: 7320 6e6f 7420 6261 636b 7761 7264 7320 s not backwards │ │ │ +0005b750: 636f 6d70 6174 6962 6c65 2e20 5665 7273 compatible. Vers │ │ │ +0005b760: 696f 6e20 7468 6520 7361 6e69 7469 7a65 ion the sanitize │ │ │ +0005b770: 722c 0a6c 6574 7469 6e67 2074 6865 2063 r,.letting the c │ │ │ +0005b780: 616c 6c65 7220 7069 636b 2077 6869 6368 aller pick which │ │ │ +0005b790: 2073 616e 6974 697a 6572 2076 6572 7369 sanitizer versi │ │ │ +0005b7a0: 6f6e 2074 6f20 7573 652e 2054 6865 6e0a on to use. Then. │ │ │ +0005b7b0: 7468 6973 2063 616e 2062 6520 6669 7865 this can be fixe │ │ │ +0005b7c0: 6420 696e 2061 6e20 7570 6461 7465 6420 d in an updated │ │ │ +0005b7d0: 7665 7273 696f 6e2e 3c2f 6832 3e3c 6834 version.

    ../src/torrent_ │ │ │ +0005b7f0: 696e 666f 2e63 7070 3a31 3234 373c 2f68 info.cpp:1247
    .../
    │ │ │ +0005b840: 2f20 6578 7472 6163 7420 6669 6c65 206e  / extract file n
    │ │ │ +0005b850: 616d 6520 286f 7220 7468 6520 6469 7265  ame (or the dire
    │ │ │ +0005b860: 6374 6f72 7920 6e61 6d65 2069 6620 6974  ctory name if it
    │ │ │ +0005b870: 2773 2061 206d 756c 7469 2066 696c 6520  's a multi file 
    │ │ │ +0005b880: 6c69 6274 6f72 7265 6e74 290a 0909 6264  libtorrent)...bd
    │ │ │ +0005b890: 6563 6f64 655f 6e6f 6465 206e 616d 655f  ecode_node name_
    │ │ │ +0005b8a0: 656e 7420 3d20 696e 666f 2e64 6963 745f  ent = info.dict_
    │ │ │ +0005b8b0: 6669 6e64 5f73 7472 696e 6728 226e 616d  find_string("nam
    │ │ │ +0005b8c0: 652e 7574 662d 3822 293b 0a09 0969 6620  e.utf-8");...if 
    │ │ │ +0005b8d0: 2821 6e61 6d65 5f65 6e74 2920 6e61 6d65  (!name_ent) name
    │ │ │ +0005b8e0: 5f65 6e74 203d 2069 6e66 6f2e 6469 6374  _ent = info.dict
    │ │ │ +0005b8f0: 5f66 696e 645f 7374 7269 6e67 2822 6e61  _find_string("na
    │ │ │ +0005b900: 6d65 2229 3b0a 0909 6966 2028 216e 616d  me");...if (!nam
    │ │ │ +0005b910: 655f 656e 7429 0a09 097b 0a09 0909 6563  e_ent)...{....ec
    │ │ │ +0005b920: 203d 2065 7272 6f72 733a 3a74 6f72 7265   = errors::torre
    │ │ │ +0005b930: 6e74 5f6d 6973 7369 6e67 5f6e 616d 653b  nt_missing_name;
    │ │ │ +0005b940: 0a09 0909 2f2f 206d 6172 6b20 7468 6520  ....// mark the 
    │ │ │ +0005b950: 746f 7272 656e 7420 6173 2069 6e76 616c  torrent as inval
    │ │ │ +0005b960: 6964 0a09 0909 6d5f 6669 6c65 732e 7365  id....m_files.se
    │ │ │ +0005b970: 745f 7069 6563 655f 6c65 6e67 7468 2830  t_piece_length(0
    │ │ │ +0005b980: 293b 0a09 0909 7265 7475 726e 3b0a 0909  );....return;...
    │ │ │ +0005b990: 7d0a 0a09 0973 7464 3a3a 7374 7269 6e67  }....std::string
    │ │ │ +0005b9a0: 206e 616d 653b 0a09 0961 7578 3a3a 7361   name;...aux::sa
    │ │ │ +0005b9b0: 6e69 7469 7a65 5f61 7070 656e 645f 7061  nitize_append_pa
    │ │ │ +0005b9c0: 7468 5f65 6c65 6d65 6e74 286e 616d 652c  th_element(name,
    │ │ │ +0005b9d0: 206e 616d 655f 656e 742e 7374 7269 6e67   name_ent.string
    │ │ │ +0005b9e0: 5f76 616c 7565 2829 293b 0a09 0969 6620  _value());...if 
    │ │ │ +0005b9f0: 286e 616d 652e 656d 7074 7928 2929 0a09  (name.empty())..
    │ │ │ +0005ba00: 097b 0a09 0909 2f2f 2074 6865 2066 616c  .{....// the fal
    │ │ │ +0005ba10: 6c62 6163 6b20 6e61 6d65 2069 7320 616c  lback name is al
    │ │ │ +0005ba20: 7761 7973 2062 6173 6564 206f 6e20 7468  ways based on th
    │ │ │ +0005ba30: 6520 7631 2028 5348 412d 3129 2069 6e66  e v1 (SHA-1) inf
    │ │ │ +0005ba40: 6f2d 6861 7368 2c0a 0909 092f 2f20 6576  o-hash,....// ev
    │ │ │ +0005ba50: 656e 2066 6f72 2076 322d 6f6e 6c79 2074  en for v2-only t
    │ │ │ +0005ba60: 6f72 7265 6e74 7320 7768 6572 6520 6974  orrents where it
    │ │ │ +0005ba70: 2773 206f 7468 6572 7769 7365 206e 6f74  's otherwise not
    │ │ │ +0005ba80: 206e 6565 6465 642e 2043 6f6d 7075 7465   needed. Compute
    │ │ │ +0005ba90: 0a09 0909 2f2f 2069 7420 6c61 7a69 6c79  ....// it lazily
    │ │ │ +0005baa0: 2068 6572 6520 7261 7468 6572 2074 6861   here rather tha
    │ │ │ +0005bab0: 6e20 756e 636f 6e64 6974 696f 6e61 6c6c  n unconditionall
    │ │ │ +0005bac0: 7920 7570 2d66 726f 6e74 2c20 746f 2061  y up-front, to a
    │ │ │ +0005bad0: 766f 6964 2074 6865 0a09 0909 2f2f 2065  void the....// e
    │ │ │ +0005bae0: 7874 7261 2068 6173 6820 696e 2074 6865  xtra hash in the
    │ │ │ +0005baf0: 2063 6f6d 6d6f 6e20 6361 7365 2077 6865   common case whe
    │ │ │ +0005bb00: 7265 2074 6865 206e 616d 6520 6669 656c  re the name fiel
    │ │ │ +0005bb10: 6420 6973 2076 616c 6964 2e0a 3c64 6976  d is valid..
    ...nam │ │ │ +0005bb50: 6520 3d20 6175 783a 3a74 6f5f 6865 7828 e = aux::to_hex( │ │ │ +0005bb60: 6d5f 696e 666f 5f68 6173 682e 6861 735f m_info_hash.has_ │ │ │ +0005bb70: 7631 2829 203f 206d 5f69 6e66 6f5f 6861 v1() ? m_info_ha │ │ │ +0005bb80: 7368 2e76 3120 3a20 6861 7368 6572 2873 sh.v1 : hasher(s │ │ │ +0005bb90: 6563 7469 6f6e 292e 6669 6e61 6c28 2929 ection).final()) │ │ │ +0005bba0: 3b0a 3c2f 6469 763e 0909 7d0a 0a09 092f ;.
    ..}..../ │ │ │ +0005bbb0: 2f20 6578 7472 6163 7420 6669 6c65 206c / extract file l │ │ │ +0005bbc0: 6973 740a 0a09 092f 2f20 7361 7665 2061 ist....// save a │ │ │ +0005bbd0: 2063 6f70 7920 736f 2074 6861 7420 7765 copy so that we │ │ │ +0005bbe0: 2063 616e 2065 7874 7261 6374 2062 6f74 can extract bot │ │ │ +0005bbf0: 6820 7631 2061 6e64 2076 3220 6669 6c65 h v1 and v2 file │ │ │ +0005bc00: 7320 7468 656e 2063 6f6d 7061 7265 2074 s then compare t │ │ │ +0005bc10: 6865 2072 6573 756c 7473 0a09 0966 696c he results...fil │ │ │ +0005bc20: 655f 7374 6f72 6167 6520 7631 5f66 696c e_storage v1_fil │ │ │ +0005bc30: 6573 3b0a 0909 6966 2028 7665 7273 696f es;...if (versio │ │ │ +0005bc40: 6e20 2667 743b 3d20 3229 0a09 0909 7631 n >= 2)....v1 │ │ │ +0005bc50: 5f66 696c 6573 203d 2066 696c 6573 3b0a _files = files;. │ │ │ +0005bc60: 0a09 0962 6465 636f 6465 5f6e 6f64 6520 ...bdecode_node │ │ │ +0005bc70: 636f 6e73 7420 6669 6c65 5f74 7265 655f const file_tree_ │ │ │ +0005bc80: 6e6f 6465 203d 2069 6e66 6f2e 6469 6374 node = info.dict │ │ │ +0005bc90: 5f66 696e 645f 6469 6374 2822 6669 6c65 _find_dict("file │ │ │ +0005bca0: 2074 7265 6522 293b 0a09 0969 6620 2876 tree");...if (v │ │ │ +0005bcb0: 6572 7369 6f6e 2026 6774 3b3d 2032 2026 ersion >= 2 & │ │ │ +0005bcc0: 616d 703b 2661 6d70 3b20 6669 6c65 5f74 amp;& file_t │ │ │ +0005bcd0: 7265 655f 6e6f 6465 290a 0909 7b0a 0909 ree_node)...{... │ │ │ +0005bce0: 0969 6620 2821 6578 7472 6163 745f 6669 .if (!extract_fi │ │ │ +0005bcf0: 6c65 7332 2866 696c 655f 7472 6565 5f6e les2(file_tree_n │ │ │ +0005bd00: 6f64 652c 0a09 0909 0909 6669 6c65 732c ode,......files, │ │ │ +0005bd10: 0a09 0909 0909 6e61 6d65 2c0a 0909 0909 ......name,..... │ │ │ +0005bd20: 0969 6e66 6f5f 6f66 6673 6574 2c0a 0909 .info_offset,... │ │ │ +0005bd30: 0909 096d 5f69 6e66 6f5f 7365 6374 696f ...m_info_sectio │ │ │ +0005bd40: 6e2e 6765 7428 292c 0a09 0909 0909 626f n.get(),......bo │ │ │ +0005bd50: 6f6c 2866 696c 6573 5f6e 6f64 6529 2c0a ol(files_node),. │ │ │ +0005bd60: 0909 0909 096d 6178 5f64 6972 6563 746f .....max_directo │ │ │ +0005bd70: 7279 5f64 6570 7468 2c0a 0909 0909 0965 ry_depth,......e │ │ │ +0005bd80: 6329 290a 0909 097b 0a09 0909 092f 2f20 c))....{.....// │ │ │ +0005bd90: 6d61 726b 2074 6865 2074 6f72 7265 6e74 mark the torrent │ │ │ +0005bda0: 2061 7320 696e 7661 6c69 640a 0909 0909 as invalid..... │ │ │ +0005bdb0: 6d5f 6669 6c65 732e 7365 745f 7069 6563 m_files.set_piec │ │ │ +0005bdc0: 655f 6c65 6e67 7468 2830 293b 0a09 0909 e_length(0);.... │ │ │ +0005bdd0: 0972 6574 7572 6e3b 0a09 0909 7d0a 0a09 .return;....}... │ │ │ +0005bde0: 0909 6669 6c65 732e 7361 6e69 7469 7a65 ..files.sanitize │ │ │ +0005bdf0: 5f73 796d 6c69 6e6b 7328 293b 0a09 0909 _symlinks();.... │ │ │ +0005be00: 6966 2028 6669 6c65 732e 6e75 6d5f 6669 if (files.num_fi │ │ │ +0005be10: 6c65 7328 2920 2667 743b 2031 290a 0909 les() > 1)... │ │ │ +0005be20: 0909 6d5f 666c 6167 7320 7c3d 206d 756c ..m_flags |= mul │ │ │ +0005be30: 7469 6669 6c65 3b0a 0909 0965 6c73 650a tifile;....else. │ │ │ +0005be40: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e
    │ │ │ +0005be50: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +0005be80: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +0005beb0: 632f 746f 7272 656e 745f 696e 666f 2e63 c/torrent_info.c │ │ │ +0005bec0: 7070 3a31 3635 343c 2f61 3e3c 2f74 643e pp:1654 │ │ │ +0005bed0: 3c74 643e 636f 6c6c 6563 7469 6f6e 733c collections< │ │ │ +0005bee0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    col │ │ │ +0005bf30: 6c65 6374 696f 6e73 3c2f 6832 3e3c 6834 lections

    ../src/torrent_ │ │ │ +0005bf50: 696e 666f 2e63 7070 3a31 3635 343c 2f68 info.cpp:1654
    rel
    │ │ │ +0005bfd0: 6576 616e 6365 266e 6273 703b 303c 2f74  evance 0../src/to
    │ │ │ +0005c010: 7272 656e 745f 696e 666f 2e63 7070 3a31  rrent_info.cpp:1
    │ │ │ +0005c020: 3635 353c 2f61 3e3c 2f74 643e 3c74 643e  655
    │ │ │ +0005c030: 7369 6d69 6c61 723c 2f74 643e 3c2f 7472  similar

    similar

    ../src/torr │ │ │ +0005c0a0: 656e 745f 696e 666f 2e63 7070 3a31 3635 ent_info.cpp:165 │ │ │ +0005c0b0: 353c 2f68 343e 3c70 7265 2073 7479 6c65 5

    │ │ │ +0005c0f0: 0a09 0966 6f72 2028 6175 746f 2063 6f6e  ...for (auto con
    │ │ │ +0005c100: 7374 2661 6d70 3b20 7572 6c20 3a20 6174  st& url : at
    │ │ │ +0005c110: 702e 7572 6c5f 7365 6564 7329 0a09 097b  p.url_seeds)...{
    │ │ │ +0005c120: 0a09 0909 7765 625f 7365 6564 5f65 6e74  ....web_seed_ent
    │ │ │ +0005c130: 7279 2065 6e74 2875 726c 293b 0a09 0909  ry ent(url);....
    │ │ │ +0005c140: 656e 742e 7479 7065 203d 2077 6562 5f73  ent.type = web_s
    │ │ │ +0005c150: 6565 645f 656e 7472 793a 3a75 726c 5f73  eed_entry::url_s
    │ │ │ +0005c160: 6565 643b 0a09 0909 6d5f 7765 625f 7365  eed;....m_web_se
    │ │ │ +0005c170: 6564 732e 7075 7368 5f62 6163 6b28 7374  eds.push_back(st
    │ │ │ +0005c180: 643a 3a6d 6f76 6528 656e 7429 293b 0a09  d::move(ent));..
    │ │ │ +0005c190: 097d 0a0a 0909 666f 7220 2861 7574 6f20  .}....for (auto 
    │ │ │ +0005c1a0: 636f 6e73 7426 616d 703b 2075 726c 203a  const& url :
    │ │ │ +0005c1b0: 2061 7470 2e68 7474 705f 7365 6564 7329   atp.http_seeds)
    │ │ │ +0005c1c0: 0a09 097b 0a09 0909 7765 625f 7365 6564  ...{....web_seed
    │ │ │ +0005c1d0: 5f65 6e74 7279 2065 6e74 2875 726c 293b  _entry ent(url);
    │ │ │ +0005c1e0: 0a09 0909 656e 742e 7479 7065 203d 2077  ....ent.type = w
    │ │ │ +0005c1f0: 6562 5f73 6565 645f 656e 7472 793a 3a68  eb_seed_entry::h
    │ │ │ +0005c200: 7474 705f 7365 6564 3b0a 0909 096d 5f77  ttp_seed;....m_w
    │ │ │ +0005c210: 6562 5f73 6565 6473 2e70 7573 685f 6261  eb_seeds.push_ba
    │ │ │ +0005c220: 636b 2873 7464 3a3a 6d6f 7665 2865 6e74  ck(std::move(ent
    │ │ │ +0005c230: 2929 3b0a 0909 7d0a 0a09 0966 6f72 2028  ));...}....for (
    │ │ │ +0005c240: 6175 746f 2063 6f6e 7374 2661 6d70 3b20  auto const& 
    │ │ │ +0005c250: 6e20 3a20 6174 702e 6468 745f 6e6f 6465  n : atp.dht_node
    │ │ │ +0005c260: 7329 0a09 097b 0a09 0909 6d5f 6e6f 6465  s)...{....m_node
    │ │ │ +0005c270: 732e 656d 706c 6163 655f 6261 636b 286e  s.emplace_back(n
    │ │ │ +0005c280: 293b 0a09 097d 0a0a 3c64 6976 2073 7479  );...}..
    ..return t │ │ │ +0005c2c0: 7275 653b 0a3c 2f64 6976 3e09 7d0a 0a09 rue;.
    .}... │ │ │ +0005c2d0: 766f 6964 2074 6f72 7265 6e74 5f69 6e66 void torrent_inf │ │ │ +0005c2e0: 6f3a 3a61 6464 5f74 7261 636b 6572 2873 o::add_tracker(s │ │ │ +0005c2f0: 7464 3a3a 7374 7269 6e67 2063 6f6e 7374 td::string const │ │ │ +0005c300: 2661 6d70 3b20 7572 6c2c 2069 6e74 2063 & url, int c │ │ │ +0005c310: 6f6e 7374 2074 6965 7229 0a09 7b0a 0909 onst tier)..{... │ │ │ +0005c320: 6164 645f 7472 6163 6b65 7228 7572 6c2c add_tracker(url, │ │ │ +0005c330: 2074 6965 722c 2061 6e6e 6f75 6e63 655f tier, announce_ │ │ │ +0005c340: 656e 7472 793a 3a73 6f75 7263 655f 636c entry::source_cl │ │ │ +0005c350: 6965 6e74 293b 0a09 7d0a 0a09 766f 6964 ient);..}...void │ │ │ +0005c360: 2074 6f72 7265 6e74 5f69 6e66 6f3a 3a61 torrent_info::a │ │ │ +0005c370: 6464 5f74 7261 636b 6572 2873 7464 3a3a dd_tracker(std:: │ │ │ +0005c380: 7374 7269 6e67 2063 6f6e 7374 2661 6d70 string const& │ │ │ +0005c390: 3b20 7572 6c2c 2069 6e74 2063 6f6e 7374 ; url, int const │ │ │ +0005c3a0: 2074 6965 720a 0909 2c20 616e 6e6f 756e tier..., announ │ │ │ +0005c3b0: 6365 5f65 6e74 7279 3a3a 7472 6163 6b65 ce_entry::tracke │ │ │ +0005c3c0: 725f 736f 7572 6365 2063 6f6e 7374 2073 r_source const s │ │ │ +0005c3d0: 6f75 7263 6529 0a09 7b0a 0909 544f 5252 ource)..{...TORR │ │ │ +0005c3e0: 454e 545f 4153 5345 5254 5f50 5245 434f ENT_ASSERT_PRECO │ │ │ +0005c3f0: 4e44 2821 7572 6c2e 656d 7074 7928 2929 ND(!url.empty()) │ │ │ +0005c400: 3b0a 0909 6175 746f 2063 6f6e 7374 2069 ;...auto const i │ │ │ +0005c410: 203d 2073 7464 3a3a 6669 6e64 5f69 6628 = std::find_if( │ │ │ +0005c420: 6d5f 7572 6c73 2e62 6567 696e 2829 2c20 m_urls.begin(), │ │ │ +0005c430: 6d5f 7572 6c73 2e65 6e64 2829 0a09 0909 m_urls.end().... │ │ │ +0005c440: 2c20 5b26 616d 703b 7572 6c5d 2861 6e6e , [&url](ann │ │ │ +0005c450: 6f75 6e63 655f 656e 7472 7920 636f 6e73 ounce_entry cons │ │ │ +0005c460: 7426 616d 703b 2061 6529 207b 2072 6574 t& ae) { ret │ │ │ +0005c470: 7572 6e20 6165 2e75 726c 203d 3d20 7572 urn ae.url == ur │ │ │ +0005c480: 6c3b 207d 293b 0a09 0969 6620 2869 2021 l; });...if (i ! │ │ │ +0005c490: 3d20 6d5f 7572 6c73 2e65 6e64 2829 2920 = m_urls.end()) │ │ │ +0005c4a0: 7265 7475 726e 3b0a 0909 6966 2028 216c return;...if (!l │ │ │ +0005c4b0: 743a 3a61 7578 3a3a 6973 5f76 616c 6964 t::aux::is_valid │ │ │ +0005c4c0: 5f74 7261 636b 6572 5f75 726c 2875 726c _tracker_url(url │ │ │ +0005c4d0: 2929 2072 6574 7572 6e3b 0a0a 0909 616e )) return;....an │ │ │ +0005c4e0: 6e6f 756e 6365 5f65 6e74 7279 2065 2875 nounce_entry e(u │ │ │ +0005c4f0: 726c 293b 0a09 0965 2e74 6965 7220 3d20 rl);...e.tier = │ │ │ +0005c500: 7374 643a 3a75 696e 7438 5f74 2874 6965 std::uint8_t(tie │ │ │ +0005c510: 7229 3b0a 0909 652e 736f 7572 6365 203d r);...e.source = │ │ │ +0005c520: 2073 6f75 7263 653b 0a09 096d 5f75 726c source;...m_url │ │ │ +0005c530: 732e 7075 7368 5f62 6163 6b28 6529 3b0a s.push_back(e);. │ │ │ +0005c540: 0a09 0973 7464 3a3a 736f 7274 286d 5f75 ...std::sort(m_u │ │ │ +0005c550: 726c 732e 6265 6769 6e28 292c 206d 5f75 rls.begin(), m_u │ │ │ +0005c560: 726c 732e 656e 6428 290a 0909 092c 205b rls.end()...., [ │ │ │ +0005c570: 5d20 2861 6e6e 6f75 6e63 655f 656e 7472 ] (announce_entr │ │ │ +0005c580: 7920 636f 6e73 7426 616d 703b 206c 6873 y const& lhs │ │ │ +0005c590: 2c20 616e 6e6f 756e 6365 5f65 6e74 7279 , announce_entry │ │ │ +0005c5a0: 2063 6f6e 7374 2661 6d70 3b20 7268 7329 const& rhs) │ │ │ +0005c5b0: 0a09 0909 7b20 7265 7475 726e 206c 6873 ....{ return lhs │ │ │ +0005c5c0: 2e74 6965 7220 266c 743b 2072 6873 2e74 .tier < rhs.t │ │ │ +0005c5d0: 6965 723b 207d 293b 0a09 7d0a 0a09 766f ier; });..}...vo │ │ │ +0005c5e0: 6964 2074 6f72 7265 6e74 5f69 6e66 6f3a id torrent_info: │ │ │ +0005c5f0: 3a63 6c65 6172 5f74 7261 636b 6572 7328 :clear_trackers( │ │ │ +0005c600: 290a 097b 0a09 096d 5f75 726c 732e 636c )..{...m_urls.cl │ │ │ +0005c610: 6561 7228 293b 0a09 7d0a 3c2f 7072 653e ear();..}.
    │ │ │ +0005c620: 3c2f 7464 3e3c 2f74 723e 3c74 7220 7374 relev │ │ │ +0005c650: 616e 6365 266e 6273 703b 303c 2f74 643e ance 0 │ │ │ +0005c660: 3c74 643e 3c61 2068 7265 663d 226a 6176 ../src/cpui │ │ │ +0005c690: 642e 6370 703a 3131 343c 2f61 3e3c 2f74 d.cpp:114enable whe │ │ │ +0005c6b0: 6e20 6161 7263 6836 3420 6973 2072 6561 n aarch64 is rea │ │ │ +0005c6c0: 6c6c 7920 7465 7374 6564 3c2f 7464 3e3c lly tested< │ │ │ +0005c6d0: 2f74 723e 3c74 7220 6964 3d22 3231 3422 /tr>

    enable w │ │ │ +0005c720: 6865 6e20 6161 7263 6836 3420 6973 2072 hen aarch64 is r │ │ │ +0005c730: 6561 6c6c 7920 7465 7374 6564 3c2f 6832 eally tested

    ../src/cpui │ │ │ +0005c750: 642e 6370 703a 3131 343c 2f68 343e 3c70 d.cpp:114

    .bool su │ │ │ +0005c7a0: 7070 6f72 7473 5f6d 6d78 2829 206e 6f65 pports_mmx() noe │ │ │ +0005c7b0: 7863 6570 740a 097b 0a23 6966 2054 4f52 xcept..{.#if TOR │ │ │ +0005c7c0: 5245 4e54 5f48 4153 5f53 5345 0a09 0973 RENT_HAS_SSE...s │ │ │ +0005c7d0: 7464 3a3a 7569 6e74 3332 5f74 2063 7075 td::uint32_t cpu │ │ │ +0005c7e0: 695b 345d 203d 207b 307d 3b0a 0909 6370 i[4] = {0};...cp │ │ │ +0005c7f0: 7569 6428 6370 7569 2c20 3129 3b0a 0909 uid(cpui, 1);... │ │ │ +0005c800: 7265 7475 726e 2028 6370 7569 5b32 5d20 return (cpui[2] │ │ │ +0005c810: 2661 6d70 3b20 2831 2026 6c74 3b26 6c74 & (1 << │ │ │ +0005c820: 3b20 3233 2929 2021 3d20 303b 0a23 656c ; 23)) != 0;.#el │ │ │ +0005c830: 7365 0a09 0972 6574 7572 6e20 6661 6c73 se...return fals │ │ │ +0005c840: 653b 0a23 656e 6469 660a 097d 0a0a 0962 e;.#endif..}...b │ │ │ +0005c850: 6f6f 6c20 7375 7070 6f72 7473 5f61 726d ool supports_arm │ │ │ +0005c860: 5f6e 656f 6e28 2920 6e6f 6578 6365 7074 _neon() noexcept │ │ │ +0005c870: 0a09 7b0a 2369 6620 544f 5252 454e 545f ..{.#if TORRENT_ │ │ │ +0005c880: 4841 535f 4152 4d5f 4e45 4f4e 2026 616d HAS_ARM_NEON &am │ │ │ +0005c890: 703b 2661 6d70 3b20 544f 5252 454e 545f p;& TORRENT_ │ │ │ +0005c8a0: 4841 535f 4155 5856 0a23 6966 2064 6566 HAS_AUXV.#if def │ │ │ +0005c8b0: 696e 6564 205f 5f61 726d 5f5f 0a09 092f ined __arm__.../ │ │ │ +0005c8c0: 2f72 6574 7572 6e20 2867 6574 6175 7876 /return (getauxv │ │ │ +0005c8d0: 616c 2841 545f 4857 4341 5029 2026 616d al(AT_HWCAP) &am │ │ │ +0005c8e0: 703b 2048 5743 4150 5f4e 454f 4e29 3b0a p; HWCAP_NEON);. │ │ │ +0005c8f0: 0909 7265 7475 726e 2028 6865 6c70 6572 ..return (helper │ │ │ +0005c900: 5f67 6574 6175 7876 616c 2831 3629 2026 _getauxval(16) & │ │ │ +0005c910: 616d 703b 2028 3120 266c 743b 266c 743b amp; (1 << │ │ │ +0005c920: 2031 3229 293b 0a23 656c 6966 2064 6566 12));.#elif def │ │ │ +0005c930: 696e 6564 205f 5f61 6172 6368 3634 5f5f ined __aarch64__ │ │ │ +0005c940: 0a09 092f 2f72 6574 7572 6e20 2867 6574 ...//return (get │ │ │ +0005c950: 6175 7876 616c 2841 545f 4857 4341 5029 auxval(AT_HWCAP) │ │ │ +0005c960: 2026 616d 703b 2048 5743 4150 5f41 5349 & HWCAP_ASI │ │ │ +0005c970: 4d44 293b 0a09 092f 2f72 6574 7572 6e20 MD);...//return │ │ │ +0005c980: 2867 6574 6175 7876 616c 2831 3629 2026 (getauxval(16) & │ │ │ +0005c990: 616d 703b 2028 3120 266c 743b 266c 743b amp; (1 << │ │ │ +0005c9a0: 2031 2929 3b0a 3c64 6976 2073 7479 6c65 1));.

    ..return fal │ │ │ +0005c9e0: 7365 3b0a 3c2f 6469 763e 2365 6e64 6966 se;.
    #endif │ │ │ +0005c9f0: 0a23 656c 7365 0a09 0972 6574 7572 6e20 .#else...return │ │ │ +0005ca00: 6661 6c73 653b 0a23 656e 6469 660a 097d false;.#endif..} │ │ │ +0005ca10: 0a0a 0962 6f6f 6c20 7375 7070 6f72 7473 ...bool supports │ │ │ +0005ca20: 5f61 726d 5f63 7263 3332 6328 2920 6e6f _arm_crc32c() no │ │ │ +0005ca30: 6578 6365 7074 0a09 7b0a 2369 6620 544f except..{.#if TO │ │ │ +0005ca40: 5252 454e 545f 4841 535f 4152 4d5f 4352 RRENT_HAS_ARM_CR │ │ │ +0005ca50: 4333 3220 2661 6d70 3b26 616d 703b 2054 C32 && T │ │ │ +0005ca60: 4f52 5245 4e54 5f48 4153 5f41 5558 560a ORRENT_HAS_AUXV. │ │ │ +0005ca70: 2369 6620 6465 6669 6e65 6420 544f 5252 #if defined TORR │ │ │ +0005ca80: 454e 545f 464f 5243 455f 4152 4d5f 4352 ENT_FORCE_ARM_CR │ │ │ +0005ca90: 4333 320a 0909 7265 7475 726e 2074 7275 C32...return tru │ │ │ +0005caa0: 653b 0a23 656c 6966 2064 6566 696e 6564 e;.#elif defined │ │ │ +0005cab0: 205f 5f61 726d 5f5f 0a09 092f 2f72 6574 __arm__...//ret │ │ │ +0005cac0: 7572 6e20 2867 6574 6175 7876 616c 2841 urn (getauxval(A │ │ │ +0005cad0: 545f 4857 4341 5032 2920 2661 6d70 3b20 T_HWCAP2) & │ │ │ +0005cae0: 4857 4341 5032 5f43 5243 3332 293b 0a09 HWCAP2_CRC32);.. │ │ │ +0005caf0: 0972 6574 7572 6e20 2868 656c 7065 725f .return (helper_ │ │ │ +0005cb00: 6765 7461 7578 7661 6c28 3236 2920 2661 getauxval(26) &a │ │ │ +0005cb10: 6d70 3b20 2831 2026 6c74 3b26 6c74 3b20 mp; (1 << │ │ │ +0005cb20: 3429 293b 0a23 656c 6966 2064 6566 696e 4));.#elif defin │ │ │ +0005cb30: 6564 205f 5f61 6172 6368 3634 5f5f 0a09 ed __aarch64__.. │ │ │ +0005cb40: 092f 2f72 6574 7572 6e20 2867 6574 6175 .//return (getau │ │ │ +0005cb50: 7876 616c 2841 545f 4857 4341 5029 2026 xval(AT_HWCAP) & │ │ │ +0005cb60: 616d 703b 2048 5743 4150 5f43 5243 3332 amp; HWCAP_CRC32 │ │ │ +0005cb70: 293b 0a09 0972 6574 7572 6e20 2868 656c );...return (hel │ │ │ +0005cb80: 7065 725f 6765 7461 7578 7661 6c28 3136 per_getauxval(16 │ │ │ +0005cb90: 2920 2661 6d70 3b20 2831 2026 6c74 3b26 ) & (1 <& │ │ │ +0005cba0: 6c74 3b20 3729 293b 0a23 656e 6469 660a lt; 7));.#endif. │ │ │ +0005cbb0: 2365 6c73 650a 0909 7265 7475 726e 2066 #else...return f │ │ │ +0005cbc0: 616c 7365 3b0a 2365 6e64 6966 0a09 7d0a alse;.#endif..}. │ │ │ +0005cbd0: 0a23 6966 6465 6620 5f5f 636c 616e 675f .#ifdef __clang_ │ │ │ +0005cbe0: 5f0a 2370 7261 676d 6120 636c 616e 6720 _.#pragma clang │ │ │ +0005cbf0: 6469 6167 6e6f 7374 6963 2070 6f70 0a23 diagnostic pop.# │ │ │ +0005cc00: 656e 6469 660a 0a7d 202f 2f20 616e 6f6e endif..} // anon │ │ │ +0005cc10: 796d 6f75 7320 6e61 6d65 7370 6163 650a ymous namespace. │ │ │ +0005cc20: 0a09 626f 6f6c 2063 6f6e 7374 2073 7365 ..bool const sse │ │ │ +0005cc30: 3432 5f73 7570 706f 7274 203d 2073 7570 42_support = sup │ │ │ +0005cc40: 706f 7274 735f 7373 6534 3228 293b 0a3c ports_sse42();.< │ │ │ +0005cc50: 2f70 7265 3e3c 2f74 643e 3c2f 7472 3e3c /pre>< │ │ │ +0005cc60: 7472 2073 7479 6c65 3d22 6261 636b 6772 tr style="backgr │ │ │ +0005cc70: 6f75 6e64 3a20 2363 6363 223e 3c74 643e ound: #ccc"> │ │ │ +0005cc80: 7265 6c65 7661 6e63 6526 6e62 7370 3b30 relevance 0 │ │ │ +0005cc90: 3c2f 7464 3e3c 7464 3e3c 6120 6872 6566 ../src │ │ │ +0005ccc0: 2f73 6573 7369 6f6e 2e63 7070 3a32 3631 /session.cpp:261 │ │ │ +0005ccd0: 3c2f 613e 3c2f 7464 3e3c 7464 3e73 7461 sta │ │ │ +0005cce0: 7274 2829 2073 686f 756c 6420 6a75 7374 rt() should just │ │ │ +0005ccf0: 2075 7365 2066 6c61 6773 206f 7574 206f use flags out o │ │ │ +0005cd00: 6620 7468 6520 7365 7373 696f 6e5f 7061 f the session_pa │ │ │ +0005cd10: 7261 6d73 206f 626a 6563 742c 3c2f 7464 rams object,

    start( │ │ │ +0005cd70: 2920 7368 6f75 6c64 206a 7573 7420 7573 ) should just us │ │ │ +0005cd80: 6520 666c 6167 7320 6f75 7420 6f66 2074 e flags out of t │ │ │ +0005cd90: 6865 2073 6573 7369 6f6e 5f70 6172 616d he session_param │ │ │ +0005cda0: 7320 6f62 6a65 6374 2c3c 2f68 323e 3c68 s object,

    ../src/session │ │ │ +0005cdc0: 2e63 7070 3a32 3631 3c2f 6834 3e3c 7072 .cpp:261

    ..SET_BOO │ │ │ +0005ce10: 4c28 7265 7374 7269 6374 5f72 6f75 7469 L(restrict_routi │ │ │ +0005ce20: 6e67 5f69 7073 293b 0a09 0953 4554 5f42 ng_ips);...SET_B │ │ │ +0005ce30: 4f4f 4c28 7265 7374 7269 6374 5f73 6561 OOL(restrict_sea │ │ │ +0005ce40: 7263 685f 6970 7329 3b0a 0909 5345 545f rch_ips);...SET_ │ │ │ +0005ce50: 424f 4f4c 2865 7874 656e 6465 645f 726f BOOL(extended_ro │ │ │ +0005ce60: 7574 696e 675f 7461 626c 6529 3b0a 0909 uting_table);... │ │ │ +0005ce70: 5345 545f 424f 4f4c 2861 6767 7265 7373 SET_BOOL(aggress │ │ │ +0005ce80: 6976 655f 6c6f 6f6b 7570 7329 3b0a 0909 ive_lookups);... │ │ │ +0005ce90: 5345 545f 424f 4f4c 2870 7269 7661 6379 SET_BOOL(privacy │ │ │ +0005cea0: 5f6c 6f6f 6b75 7073 293b 0a09 0953 4554 _lookups);...SET │ │ │ +0005ceb0: 5f42 4f4f 4c28 656e 666f 7263 655f 6e6f _BOOL(enforce_no │ │ │ +0005cec0: 6465 5f69 6429 3b0a 0909 5345 545f 424f de_id);...SET_BO │ │ │ +0005ced0: 4f4c 2869 676e 6f72 655f 6461 726b 5f69 OL(ignore_dark_i │ │ │ +0005cee0: 6e74 6572 6e65 7429 3b0a 0909 5345 545f nternet);...SET_ │ │ │ +0005cef0: 494e 5428 626c 6f63 6b5f 7469 6d65 6f75 INT(block_timeou │ │ │ +0005cf00: 7429 3b0a 0909 5345 545f 494e 5428 626c t);...SET_INT(bl │ │ │ +0005cf10: 6f63 6b5f 7261 7465 6c69 6d69 7429 3b0a ock_ratelimit);. │ │ │ +0005cf20: 0909 5345 545f 424f 4f4c 2872 6561 645f ..SET_BOOL(read_ │ │ │ +0005cf30: 6f6e 6c79 293b 0a09 0953 4554 5f49 4e54 only);...SET_INT │ │ │ +0005cf40: 2869 7465 6d5f 6c69 6665 7469 6d65 293b (item_lifetime); │ │ │ +0005cf50: 0a09 0953 4554 5f49 4e54 2875 706c 6f61 ...SET_INT(uploa │ │ │ +0005cf60: 645f 7261 7465 5f6c 696d 6974 293b 0a09 d_rate_limit);.. │ │ │ +0005cf70: 0953 4554 5f49 4e54 2873 616d 706c 655f .SET_INT(sample_ │ │ │ +0005cf80: 696e 666f 6861 7368 6573 5f69 6e74 6572 infohashes_inter │ │ │ +0005cf90: 7661 6c29 3b0a 0909 5345 545f 494e 5428 val);...SET_INT( │ │ │ +0005cfa0: 6d61 785f 696e 666f 6861 7368 6573 5f73 max_infohashes_s │ │ │ +0005cfb0: 616d 706c 655f 636f 756e 7429 3b0a 2375 ample_count);.#u │ │ │ +0005cfc0: 6e64 6566 2053 4554 5f42 4f4f 4c0a 2375 ndef SET_BOOL.#u │ │ │ +0005cfd0: 6e64 6566 2053 4554 5f49 4e54 0a09 097d ndef SET_INT...} │ │ │ +0005cfe0: 0a23 656e 6469 660a 2365 6e64 6966 0a0a .#endif.#endif.. │ │ │ +0005cff0: 3c64 6976 2073 7479 6c65 3d22 6261 636b
    .. │ │ │ +0005d020: 6d5f 696d 706c 203d 2073 7464 3a3a 6d61 m_impl = std::ma │ │ │ +0005d030: 6b65 5f73 6861 7265 6426 6c74 3b61 7578 ke_shared<aux │ │ │ +0005d040: 3a3a 7365 7373 696f 6e5f 696d 706c 2667 ::session_impl&g │ │ │ +0005d050: 743b 2873 7464 3a3a 7265 6628 2a69 6f73 t;(std::ref(*ios │ │ │ +0005d060: 290a 3c2f 6469 763e 0909 092c 2073 7464 ).
    ..., std │ │ │ +0005d070: 3a3a 6d6f 7665 2870 6172 616d 732e 7365 ::move(params.se │ │ │ +0005d080: 7474 696e 6773 290a 0909 092c 2073 7464 ttings)...., std │ │ │ +0005d090: 3a3a 6d6f 7665 2870 6172 616d 732e 6469 ::move(params.di │ │ │ +0005d0a0: 736b 5f69 6f5f 636f 6e73 7472 7563 746f sk_io_constructo │ │ │ +0005d0b0: 7229 0a09 0909 2c20 666c 6167 7329 3b0a r)...., flags);. │ │ │ +0005d0c0: 0909 2a73 7461 7469 635f 6361 7374 266c ..*static_cast&l │ │ │ +0005d0d0: 743b 7365 7373 696f 6e5f 6861 6e64 6c65 t;session_handle │ │ │ +0005d0e0: 2a26 6774 3b28 7468 6973 2920 3d20 7365 *>(this) = se │ │ │ +0005d0f0: 7373 696f 6e5f 6861 6e64 6c65 286d 5f69 ssion_handle(m_i │ │ │ +0005d100: 6d70 6c29 3b0a 0a23 6966 6e64 6566 2054 mpl);..#ifndef T │ │ │ +0005d110: 4f52 5245 4e54 5f44 4953 4142 4c45 5f45 ORRENT_DISABLE_E │ │ │ +0005d120: 5854 454e 5349 4f4e 530a 0909 666f 7220 XTENSIONS...for │ │ │ +0005d130: 2861 7574 6f26 616d 703b 2065 7874 203a (auto& ext : │ │ │ +0005d140: 2070 6172 616d 732e 6578 7465 6e73 696f params.extensio │ │ │ +0005d150: 6e73 290a 0909 7b0a 0909 0965 7874 2d26 ns)...{....ext-& │ │ │ +0005d160: 6774 3b6c 6f61 645f 7374 6174 6528 7061 gt;load_state(pa │ │ │ +0005d170: 7261 6d73 2e65 7874 5f73 7461 7465 293b rams.ext_state); │ │ │ +0005d180: 0a09 0909 6d5f 696d 706c 2d26 6774 3b61 ....m_impl->a │ │ │ +0005d190: 6464 5f73 6573 5f65 7874 656e 7369 6f6e dd_ses_extension │ │ │ +0005d1a0: 2873 7464 3a3a 6d6f 7665 2865 7874 2929 (std::move(ext)) │ │ │ +0005d1b0: 3b0a 0909 7d0a 2365 6e64 6966 0a0a 2369 ;...}.#endif..#i │ │ │ +0005d1c0: 666e 6465 6620 544f 5252 454e 545f 4449 fndef TORRENT_DI │ │ │ +0005d1d0: 5341 424c 455f 4448 540a 0909 6d5f 696d SABLE_DHT...m_im │ │ │ +0005d1e0: 706c 2d26 6774 3b73 6574 5f64 6874 5f73 pl->set_dht_s │ │ │ +0005d1f0: 7461 7465 2873 7464 3a3a 6d6f 7665 2870 tate(std::move(p │ │ │ +0005d200: 6172 616d 732e 6468 745f 7374 6174 6529 arams.dht_state) │ │ │ +0005d210: 293b 0a0a 0909 544f 5252 454e 545f 4153 );....TORRENT_AS │ │ │ +0005d220: 5345 5254 2870 6172 616d 732e 6468 745f SERT(params.dht_ │ │ │ +0005d230: 7374 6f72 6167 655f 636f 6e73 7472 7563 storage_construc │ │ │ +0005d240: 746f 7229 3b0a 0909 6d5f 696d 706c 2d26 tor);...m_impl-& │ │ │ +0005d250: 6774 3b73 6574 5f64 6874 5f73 746f 7261 gt;set_dht_stora │ │ │ +0005d260: 6765 2873 7464 3a3a 6d6f 7665 2870 6172 ge(std::move(par │ │ │ +0005d270: 616d 732e 6468 745f 7374 6f72 6167 655f ams.dht_storage_ │ │ │ +0005d280: 636f 6e73 7472 7563 746f 7229 293b 0a23 constructor));.# │ │ │ +0005d290: 656e 6469 660a 0a09 0969 6620 2821 7061 endif....if (!pa │ │ │ +0005d2a0: 7261 6d73 2e69 705f 6669 6c74 6572 2e65 rams.ip_filter.e │ │ │ +0005d2b0: 6d70 7479 2829 290a 0909 7b0a 0909 0973 mpty())...{....s │ │ │ +0005d2c0: 7464 3a3a 7368 6172 6564 5f70 7472 266c td::shared_ptr&l │ │ │ +0005d2d0: 743b 6970 5f66 696c 7465 7226 6774 3b20 t;ip_filter> │ │ │ +0005d2e0: 636f 7079 203d 2073 7464 3a3a 6d61 6b65 copy = std::make │ │ │ +0005d2f0: 5f73 6861 7265 6426 6c74 3b69 705f 6669 _shared<ip_fi │ │ │ +0005d300: 6c74 6572 2667 743b 2873 7464 3a3a 6d6f lter>(std::mo │ │ │ +0005d310: 7665 2870 6172 616d 732e 6970 5f66 696c ve(params.ip_fil │ │ │ +0005d320: 7465 7229 293b 0a09 0909 6d5f 696d 706c ter));....m_impl │ │ │ +0005d330: 2d26 6774 3b73 6574 5f69 705f 6669 6c74 ->set_ip_filt │ │ │ +0005d340: 6572 2873 7464 3a3a 6d6f 7665 2863 6f70 er(std::move(cop │ │ │ +0005d350: 7929 293b 0a09 097d 0a0a 0909 6d5f 696d y));...}....m_im │ │ │ +0005d360: 706c 2d26 6774 3b73 7461 7274 5f73 6573 pl->start_ses │ │ │ +0005d370: 7369 6f6e 2829 3b0a 0a09 0969 6620 2869 sion();....if (i │ │ │ +0005d380: 6e74 6572 6e61 6c5f 6578 6563 7574 6f72 nternal_executor │ │ │ +0005d390: 290a 0909 7b0a 3c2f 7072 653e 3c2f 7464 )...{.relevance │ │ │ +0005d3d0: 266e 6273 703b 303c 2f74 643e 3c74 643e  0 │ │ │ +0005d3e0: 3c61 2068 7265 663d 226a 6176 6173 6372 ../src/utp_sock │ │ │ +0005d410: 6574 5f6d 616e 6167 6572 2e63 7070 3a31 et_manager.cpp:1 │ │ │ +0005d420: 3830 3c2f 613e 3c2f 7464 3e3c 7464 3e74 80t │ │ │ +0005d430: 6869 7320 7368 6f75 6c64 206e 6f74 2062 his should not b │ │ │ +0005d440: 6520 6865 6170 2061 6c6c 6f63 6174 6564 e heap allocated │ │ │ +0005d450: 2c20 736f 636b 6574 7320 7368 6f75 6c64 , sockets should │ │ │ +0005d460: 2062 6520 6d6f 7661 626c 653c 2f74 643e be movable │ │ │ +0005d470: 3c2f 7472 3e3c 7472 2069 643d 2232 3136

    this sh │ │ │ +0005d4c0: 6f75 6c64 206e 6f74 2062 6520 6865 6170 ould not be heap │ │ │ +0005d4d0: 2061 6c6c 6f63 6174 6564 2c20 736f 636b allocated, sock │ │ │ +0005d4e0: 6574 7320 7368 6f75 6c64 2062 6520 6d6f ets should be mo │ │ │ +0005d4f0: 7661 626c 653c 2f68 323e 3c68 343e 2e2e vable

    .. │ │ │ +0005d500: 2f73 7263 2f75 7470 5f73 6f63 6b65 745f /src/utp_socket_ │ │ │ +0005d510: 6d61 6e61 6765 722e 6370 703a 3138 303c manager.cpp:180< │ │ │ +0005d520: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ./
    │ │ │ +0005d560: 2f09 0955 5450 5f4c 4f47 5628 2269 6e63  /..UTP_LOGV("inc
    │ │ │ +0005d570: 6f6d 696e 6720 7061 636b 6574 2069 643a  oming packet id:
    │ │ │ +0005d580: 2564 2073 6f75 7263 653a 2573 5c6e 222c  %d source:%s\n",
    │ │ │ +0005d590: 2069 642c 2070 7269 6e74 5f65 6e64 706f   id, print_endpo
    │ │ │ +0005d5a0: 696e 7428 6570 292e 635f 7374 7228 2929  int(ep).c_str())
    │ │ │ +0005d5b0: 3b0a 0a09 0969 6620 2821 6d5f 7365 7474  ;....if (!m_sett
    │ │ │ +0005d5c0: 2e67 6574 5f62 6f6f 6c28 7365 7474 696e  .get_bool(settin
    │ │ │ +0005d5d0: 6773 5f70 6163 6b3a 3a65 6e61 626c 655f  gs_pack::enable_
    │ │ │ +0005d5e0: 696e 636f 6d69 6e67 5f75 7470 2929 0a09  incoming_utp))..
    │ │ │ +0005d5f0: 0909 7265 7475 726e 2066 616c 7365 3b0a  ..return false;.
    │ │ │ +0005d600: 0a09 092f 2f20 6966 206e 6f74 2066 6f75  ...// if not fou
    │ │ │ +0005d610: 6e64 2c20 7365 6520 6966 2069 7427 7320  nd, see if it's 
    │ │ │ +0005d620: 6120 5359 4e20 7061 636b 6574 2c20 6966  a SYN packet, if
    │ │ │ +0005d630: 2069 7420 6973 2c0a 0909 2f2f 2063 7265   it is,...// cre
    │ │ │ +0005d640: 6174 6520 6120 6e65 7720 7574 705f 7374  ate a new utp_st
    │ │ │ +0005d650: 7265 616d 0a09 0969 6620 2870 682d 2667  ream...if (ph-&g
    │ │ │ +0005d660: 743b 6765 745f 7479 7065 2829 203d 3d20  t;get_type() == 
    │ │ │ +0005d670: 5354 5f53 594e 290a 0909 7b0a 0909 092f  ST_SYN)...{..../
    │ │ │ +0005d680: 2f20 706f 7373 6962 6c65 2053 594e 2066  / possible SYN f
    │ │ │ +0005d690: 6c6f 6f64 2e20 4a75 7374 2069 676e 6f72  lood. Just ignor
    │ │ │ +0005d6a0: 650a 0909 0969 6620 2869 6e74 286d 5f75  e....if (int(m_u
    │ │ │ +0005d6b0: 7470 5f73 6f63 6b65 7473 2e73 697a 6528  tp_sockets.size(
    │ │ │ +0005d6c0: 2929 2026 6774 3b20 6d5f 7365 7474 2e67  )) > m_sett.g
    │ │ │ +0005d6d0: 6574 5f69 6e74 2873 6574 7469 6e67 735f  et_int(settings_
    │ │ │ +0005d6e0: 7061 636b 3a3a 636f 6e6e 6563 7469 6f6e  pack::connection
    │ │ │ +0005d6f0: 735f 6c69 6d69 7429 202a 2032 290a 0909  s_limit) * 2)...
    │ │ │ +0005d700: 0909 7265 7475 726e 2066 616c 7365 3b0a  ..return false;.
    │ │ │ +0005d710: 0a09 0909 544f 5252 454e 545f 4153 5345  ....TORRENT_ASSE
    │ │ │ +0005d720: 5254 286d 5f6e 6577 5f63 6f6e 6e65 6374  RT(m_new_connect
    │ │ │ +0005d730: 696f 6e20 3d3d 202d 3129 3b0a 0909 092f  ion == -1);..../
    │ │ │ +0005d740: 2f20 6372 6561 7465 2074 6865 206e 6577  / create the new
    │ │ │ +0005d750: 2073 6f63 6b65 7420 7769 7468 2074 6869   socket with thi
    │ │ │ +0005d760: 7320 4944 0a09 0909 6d5f 6e65 775f 636f  s ID....m_new_co
    │ │ │ +0005d770: 6e6e 6563 7469 6f6e 203d 2069 643b 0a0a  nnection = id;..
    │ │ │ +0005d780: 2f2f 0909 0955 5450 5f4c 4f47 5628 226e  //...UTP_LOGV("n
    │ │ │ +0005d790: 6f74 2066 6f75 6e64 2c20 6e65 7720 636f  ot found, new co
    │ │ │ +0005d7a0: 6e6e 6563 7469 6f6e 2069 643a 2564 5c6e  nnection id:%d\n
    │ │ │ +0005d7b0: 222c 206d 5f6e 6577 5f63 6f6e 6e65 6374  ", m_new_connect
    │ │ │ +0005d7c0: 696f 6e29 3b0a 0a3c 6469 7620 7374 796c  ion);..
    ...aux::soc │ │ │ +0005d800: 6b65 745f 7479 7065 2063 2861 7578 3a3a ket_type c(aux:: │ │ │ +0005d810: 696e 7374 616e 7469 6174 655f 636f 6e6e instantiate_conn │ │ │ +0005d820: 6563 7469 6f6e 286d 5f69 6f73 2c20 6175 ection(m_ios, au │ │ │ +0005d830: 783a 3a70 726f 7879 5f73 6574 7469 6e67 x::proxy_setting │ │ │ +0005d840: 7328 292c 206d 5f73 736c 5f63 6f6e 7465 s(), m_ssl_conte │ │ │ +0005d850: 7874 2c20 7468 6973 2c20 7472 7565 2c20 xt, this, true, │ │ │ +0005d860: 6661 6c73 6529 293b 0a3c 2f64 6976 3e0a false));.
    . │ │ │ +0005d870: 0909 0975 7470 5f73 7472 6561 6d2a 2073 ...utp_stream* s │ │ │ +0005d880: 7472 203d 206e 756c 6c70 7472 3b0a 2369 tr = nullptr;.#i │ │ │ +0005d890: 6664 6566 2054 4f52 5245 4e54 5f53 534c fdef TORRENT_SSL │ │ │ +0005d8a0: 5f50 4545 5253 0a09 0909 6966 2028 6973 _PEERS....if (is │ │ │ +0005d8b0: 5f73 736c 2863 2929 0a09 0909 0973 7472 _ssl(c)).....str │ │ │ +0005d8c0: 203d 2026 616d 703b 7374 643a 3a67 6574 = &std::get │ │ │ +0005d8d0: 266c 743b 7373 6c5f 7374 7265 616d 266c <ssl_stream&l │ │ │ +0005d8e0: 743b 7574 705f 7374 7265 616d 2667 743b t;utp_stream> │ │ │ +0005d8f0: 2667 743b 2863 292e 6e65 7874 5f6c 6179 >(c).next_lay │ │ │ +0005d900: 6572 2829 3b0a 0909 0965 6c73 650a 2365 er();....else.#e │ │ │ +0005d910: 6e64 6966 0a09 0909 0973 7472 203d 2073 ndif.....str = s │ │ │ +0005d920: 7464 3a3a 6765 745f 6966 266c 743b 7574 td::get_if<ut │ │ │ +0005d930: 705f 7374 7265 616d 2667 743b 2826 616d p_stream>(&am │ │ │ +0005d940: 703b 6329 3b0a 0a09 0909 544f 5252 454e p;c);.....TORREN │ │ │ +0005d950: 545f 4153 5345 5254 2873 7472 293b 0a09 T_ASSERT(str);.. │ │ │ +0005d960: 0909 696e 7420 636f 6e73 7420 6d74 7520 ..int const mtu │ │ │ +0005d970: 3d20 6d74 755f 666f 725f 6465 7374 2865 = mtu_for_dest(e │ │ │ +0005d980: 702e 6164 6472 6573 7328 2929 3b0a 0909 p.address());... │ │ │ +0005d990: 0973 7472 2d26 6774 3b67 6574 5f69 6d70 .str->get_imp │ │ │ +0005d9a0: 6c28 292d 2667 743b 696e 6974 5f6d 7475 l()->init_mtu │ │ │ +0005d9b0: 286d 7475 293b 0a09 0909 7374 722d 2667 (mtu);....str-&g │ │ │ +0005d9c0: 743b 6765 745f 696d 706c 2829 2d26 6774 t;get_impl()-> │ │ │ +0005d9d0: 3b6d 5f73 6f63 6b20 3d20 7374 643a 3a6d ;m_sock = std::m │ │ │ +0005d9e0: 6f76 6528 736f 636b 6574 293b 0a09 0909 ove(socket);.... │ │ │ +0005d9f0: 626f 6f6c 2063 6f6e 7374 2072 6574 203d bool const ret = │ │ │ +0005da00: 2073 7472 2d26 6774 3b67 6574 5f69 6d70 str->get_imp │ │ │ +0005da10: 6c28 292d 2667 743b 696e 636f 6d69 6e67 l()->incoming │ │ │ +0005da20: 5f70 6163 6b65 7428 702c 2065 702c 2072 _packet(p, ep, r │ │ │ +0005da30: 6563 6569 7665 5f74 696d 6529 3b0a 0909 eceive_time);... │ │ │ +0005da40: 0969 6620 2821 7265 7429 2072 6574 7572 .if (!ret) retur │ │ │ +0005da50: 6e20 6661 6c73 653b 0a09 0909 6d5f 6c61 n false;....m_la │ │ │ +0005da60: 7374 5f73 6f63 6b65 7420 3d20 7374 722d st_socket = str- │ │ │ +0005da70: 2667 743b 6765 745f 696d 706c 2829 3b0a >get_impl();. │ │ │ +0005da80: 0909 096d 5f63 6228 7374 643a 3a6d 6f76 ...m_cb(std::mov │ │ │ +0005da90: 6528 6329 293b 0a09 0909 2f2f 2074 6865 e(c));....// the │ │ │ +0005daa0: 2063 6f6e 6e65 6374 696f 6e20 6d6f 7374 connection most │ │ │ +0005dab0: 206c 696b 656c 7920 6368 616e 6765 6420 likely changed │ │ │ +0005dac0: 6974 7320 636f 6e6e 6563 7469 6f6e 2049 its connection I │ │ │ +0005dad0: 4420 6865 7265 0a09 0909 2f2f 2077 6520 D here....// we │ │ │ +0005dae0: 6e65 6564 2074 6f20 6d6f 7665 2069 7420 need to move it │ │ │ +0005daf0: 746f 2074 6865 2063 6f72 7265 6374 2049 to the correct I │ │ │ +0005db00: 440a 0909 0972 6574 7572 6e20 7472 7565 D....return true │ │ │ +0005db10: 3b0a 0909 7d0a 0a09 0969 6620 2870 682d ;...}....if (ph- │ │ │ +0005db20: 2667 743b 6765 745f 7479 7065 2829 203d >get_type() = │ │ │ +0005db30: 3d20 5354 5f52 4553 4554 2920 7265 7475 = ST_RESET) retu │ │ │ +0005db40: 726e 2066 616c 7365 3b0a 0a09 092f 2f20 rn false;....// │ │ │ +0005db50: 2365 7272 6f72 2073 656e 6420 7265 7365 #error send rese │ │ │ +0005db60: 740a 0a09 0972 6574 7572 6e20 6661 6c73 t....return fals │ │ │ +0005db70: 653b 0a09 7d0a 0a09 766f 6964 2075 7470 e;..}...void utp │ │ │ +0005db80: 5f73 6f63 6b65 745f 6d61 6e61 6765 723a _socket_manager: │ │ │ +0005db90: 3a73 7562 7363 7269 6265 5f77 7269 7461 :subscribe_writa │ │ │ +0005dba0: 626c 6528 7574 705f 736f 636b 6574 5f69 ble(utp_socket_i │ │ │ +0005dbb0: 6d70 6c2a 2073 290a 3c2f 7072 653e 3c2f mpl* s).
    relevan │ │ │ +0005dbf0: 6365 266e 6273 703b 303c 2f74 643e 3c74 ce 0../src/smart_ │ │ │ +0005dc30: 6261 6e2e 6370 703a 3135 383c 2f61 3e3c ban.cpp:158< │ │ │ +0005dc40: 2f74 643e 3c74 643e 7265 706c 6163 6520 /td>replace │ │ │ +0005dc50: 7769 7468 2073 7464 3a3a 6572 6173 655f with std::erase_ │ │ │ +0005dc60: 6966 2829 206f 6e63 6520 7765 2072 6571 if() once we req │ │ │ +0005dc70: 7569 7265 2043 2b2b 3230 3c2f 7464 3e3c uire C++20< │ │ │ +0005dc80: 2f74 723e 3c74 7220 6964 3d22 3231 3722 /tr>

    replace │ │ │ +0005dcd0: 7769 7468 2073 7464 3a3a 6572 6173 655f with std::erase_ │ │ │ +0005dce0: 6966 2829 206f 6e63 6520 7765 2072 6571 if() once we req │ │ │ +0005dcf0: 7569 7265 2043 2b2b 3230 3c2f 6832 3e3c uire C++20

    < │ │ │ +0005dd00: 6834 3e2e 2e2f 7372 632f 736d 6172 745f h4>../src/smart_ │ │ │ +0005dd10: 6261 6e2e 6370 703a 3135 383c 2f68 343e ban.cpp:158

    │ │ │ +0005dd20: 3c70 7265 2073 7479 6c65 3d22 6261 636b
    ......
    │ │ │ +0005dd60: 2c20 6469 736b 5f69 6e74 6572 6661 6365  , disk_interface
    │ │ │ +0005dd70: 3a3a 666f 7263 655f 636f 7079 293b 0a09  ::force_copy);..
    │ │ │ +0005dd80: 0909 097d 0a0a 0909 0909 722e 7374 6172  ...}......r.star
    │ │ │ +0005dd90: 7420 2b3d 2031 362a 3130 3234 3b0a 0909  t += 16*1024;...
    │ │ │ +0005dda0: 0909 7369 7a65 202d 3d20 3136 2a31 3032  ..size -= 16*102
    │ │ │ +0005ddb0: 343b 0a09 0909 0972 2e6c 656e 6774 6820  4;.....r.length 
    │ │ │ +0005ddc0: 3d20 7374 643a 3a6d 696e 2831 362a 3130  = std::min(16*10
    │ │ │ +0005ddd0: 3234 2c20 7369 7a65 293b 0a09 0909 092b  24, size);.....+
    │ │ │ +0005dde0: 2b70 622e 626c 6f63 6b5f 696e 6465 783b  +pb.block_index;
    │ │ │ +0005ddf0: 0a09 0909 7d0a 0909 0954 4f52 5245 4e54  ....}....TORRENT
    │ │ │ +0005de00: 5f41 5353 4552 5428 7369 7a65 2026 6c74  _ASSERT(size <
    │ │ │ +0005de10: 3b3d 2030 293b 0a09 097d 0a0a 0909 2f2f  ;= 0);...}....//
    │ │ │ +0005de20: 206e 6f74 2064 6563 6c61 7265 6420 6f6e   not declared on
    │ │ │ +0005de30: 2074 6f72 7265 6e74 5f70 6c75 6769 6e20   torrent_plugin 
    │ │ │ +0005de40: 2877 6f75 6c64 2072 6571 7569 7265 2061  (would require a
    │ │ │ +0005de50: 6e20 4142 492d 6272 6561 6b69 6e67 206e  n ABI-breaking n
    │ │ │ +0005de60: 6577 0a09 092f 2f20 7669 7274 7561 6c29  ew...// virtual)
    │ │ │ +0005de70: 2e20 4361 6c6c 6564 2076 6961 2061 2064  . Called via a d
    │ │ │ +0005de80: 6f77 6e63 6173 7420 696e 2074 6f72 7265  owncast in torre
    │ │ │ +0005de90: 6e74 3a3a 7065 6572 735f 6572 6173 6564  nt::peers_erased
    │ │ │ +0005dea0: 2829 20e2 8094 2073 6565 0a09 092f 2f20  () ... see...// 
    │ │ │ +0005deb0: 736d 6172 745f 6261 6e5f 6e6f 7469 6679  smart_ban_notify
    │ │ │ +0005dec0: 5f65 7261 7365 5f70 6565 7273 2829 2062  _erase_peers() b
    │ │ │ +0005ded0: 656c 6f77 0a09 0976 6f69 6420 6f6e 5f65  elow...void on_e
    │ │ │ +0005dee0: 7261 7365 5f70 6565 7273 2873 7061 6e26  rase_peers(span&
    │ │ │ +0005def0: 6c74 3b61 7578 3a3a 746f 7272 656e 745f  lt;aux::torrent_
    │ │ │ +0005df00: 7065 6572 2a20 636f 6e73 7426 6774 3b20  peer* const> 
    │ │ │ +0005df10: 7065 6572 7329 0a09 097b 0a09 0909 6966  peers)...{....if
    │ │ │ +0005df20: 2028 6d5f 626c 6f63 6b5f 6861 7368 6573   (m_block_hashes
    │ │ │ +0005df30: 2e65 6d70 7479 2829 207c 7c20 7065 6572  .empty() || peer
    │ │ │ +0005df40: 732e 656d 7074 7928 2929 2072 6574 7572  s.empty()) retur
    │ │ │ +0005df50: 6e3b 0a0a 0909 0973 7464 3a3a 7665 6374  n;.....std::vect
    │ │ │ +0005df60: 6f72 266c 743b 6175 783a 3a74 6f72 7265  or<aux::torre
    │ │ │ +0005df70: 6e74 5f70 6565 722a 2667 743b 2065 7261  nt_peer*> era
    │ │ │ +0005df80: 7365 6428 7065 6572 732e 6265 6769 6e28  sed(peers.begin(
    │ │ │ +0005df90: 292c 2070 6565 7273 2e65 6e64 2829 293b  ), peers.end());
    │ │ │ +0005dfa0: 0a09 0909 7374 643a 3a73 6f72 7428 6572  ....std::sort(er
    │ │ │ +0005dfb0: 6173 6564 2e62 6567 696e 2829 2c20 6572  ased.begin(), er
    │ │ │ +0005dfc0: 6173 6564 2e65 6e64 2829 293b 0a3c 6469  ased.end());....fo
    │ │ │ +0005e000: 7220 2861 7574 6f20 6920 3d20 6d5f 626c  r (auto i = m_bl
    │ │ │ +0005e010: 6f63 6b5f 6861 7368 6573 2e62 6567 696e  ock_hashes.begin
    │ │ │ +0005e020: 2829 3b20 6920 213d 206d 5f62 6c6f 636b  (); i != m_block
    │ │ │ +0005e030: 5f68 6173 6865 732e 656e 6428 293b 290a  _hashes.end();).
    │ │ │ +0005e040: 3c2f 6469 763e 0909 097b 0a09 0909 0969  ...{.....i
    │ │ │ +0005e050: 6620 2873 7464 3a3a 6269 6e61 7279 5f73  f (std::binary_s
    │ │ │ +0005e060: 6561 7263 6828 6572 6173 6564 2e62 6567  earch(erased.beg
    │ │ │ +0005e070: 696e 2829 2c20 6572 6173 6564 2e65 6e64  in(), erased.end
    │ │ │ +0005e080: 2829 2c20 692d 2667 743b 7365 636f 6e64  (), i->second
    │ │ │ +0005e090: 2e70 6565 7229 290a 0909 0909 0969 203d  .peer))......i =
    │ │ │ +0005e0a0: 206d 5f62 6c6f 636b 5f68 6173 6865 732e   m_block_hashes.
    │ │ │ +0005e0b0: 6572 6173 6528 6929 3b0a 0909 0909 656c  erase(i);.....el
    │ │ │ +0005e0c0: 7365 0a09 0909 0909 2b2b 693b 0a09 0909  se......++i;....
    │ │ │ +0005e0d0: 7d0a 0909 7d0a 0a09 092f 2f20 7361 6d65  }...}....// same
    │ │ │ +0005e0e0: 2061 7320 6f6e 5f65 7261 7365 5f70 6565   as on_erase_pee
    │ │ │ +0005e0f0: 7273 2829 2c20 6275 7420 666f 7220 7768  rs(), but for wh
    │ │ │ +0005e100: 656e 2074 6865 2065 6e74 6972 6520 7065  en the entire pe
    │ │ │ +0005e110: 6572 206c 6973 7420 7761 730a 0909 2f2f  er list was...//
    │ │ │ +0005e120: 2074 6f72 6e20 646f 776e 2061 7420 6f6e   torn down at on
    │ │ │ +0005e130: 6365 3b20 6576 6572 7920 7374 6f72 6564  ce; every stored
    │ │ │ +0005e140: 2074 6f72 7265 6e74 5f70 6565 7220 6973   torrent_peer is
    │ │ │ +0005e150: 2069 6e76 616c 6964 2c20 736f 2074 6865   invalid, so the
    │ │ │ +0005e160: 7265 0a09 092f 2f20 6973 206e 6f20 6e65  re...// is no ne
    │ │ │ +0005e170: 6564 2074 6f20 6d61 7463 6820 696e 6469  ed to match indi
    │ │ │ +0005e180: 7669 6475 616c 2070 6f69 6e74 6572 730a  vidual pointers.
    │ │ │ +0005e190: 0909 766f 6964 206f 6e5f 636c 6561 725f  ..void on_clear_
    │ │ │ +0005e1a0: 7065 6572 7328 2920 7b20 6d5f 626c 6f63  peers() { m_bloc
    │ │ │ +0005e1b0: 6b5f 6861 7368 6573 2e63 6c65 6172 2829  k_hashes.clear()
    │ │ │ +0005e1c0: 3b20 7d0a 0a09 7072 6976 6174 653a 0a0a  ; }...private:..
    │ │ │ +0005e1d0: 0909 2f2f 2074 6869 7320 656e 7472 7920  ..// this entry 
    │ │ │ +0005e1e0: 7469 6573 2061 2073 7065 6369 6669 6320  ties a specific 
    │ │ │ +0005e1f0: 626c 6f63 6b20 4352 4320 746f 0a09 092f  block CRC to.../
    │ │ │ +0005e200: 2f20 6120 7065 6572 2e0a 0909 7374 7275  / a peer....stru
    │ │ │ +0005e210: 6374 2062 6c6f 636b 5f65 6e74 7279 0a09  ct block_entry..
    │ │ │ +0005e220: 097b 0a09 0909 6175 783a 3a74 6f72 7265  .{....aux::torre
    │ │ │ +0005e230: 6e74 5f70 6565 722a 2070 6565 723b 0a09  nt_peer* peer;..
    │ │ │ +0005e240: 0909 7368 6131 5f68 6173 6820 6469 6765  ..sha1_hash dige
    │ │ │ +0005e250: 7374 3b0a 0909 7d3b 0a0a 0909 766f 6964  st;...};....void
    │ │ │ +0005e260: 206f 6e5f 7265 6164 5f66 6169 6c65 645f   on_read_failed_
    │ │ │ +0005e270: 626c 6f63 6b28 7069 6563 655f 626c 6f63  block(piece_bloc
    │ │ │ +0005e280: 6b20 636f 6e73 7420 622c 2061 6464 7265  k const b, addre
    │ │ │ +0005e290: 7373 2063 6f6e 7374 2061 0a09 0909 2c20  ss const a...., 
    │ │ │ +0005e2a0: 6469 736b 5f62 7566 6665 725f 686f 6c64  disk_buffer_hold
    │ │ │ +0005e2b0: 6572 2062 7566 6665 722c 2069 6e74 2063  er buffer, int c
    │ │ │ +0005e2c0: 6f6e 7374 2062 6c6f 636b 5f73 697a 650a  onst block_size.
    │ │ │ +0005e2d0: 0909 092c 2073 746f 7261 6765 5f65 7272  ..., storage_err
    │ │ │ +0005e2e0: 6f72 2063 6f6e 7374 2661 6d70 3b20 6572  or const& er
    │ │ │ +0005e2f0: 726f 7229 0a09 097b 0a09 0909 544f 5252  ror)...{....TORR
    │ │ │ +0005e300: 454e 545f 4153 5345 5254 286d 5f74 6f72  ENT_ASSERT(m_tor
    │ │ │ +0005e310: 7265 6e74 2e73 6573 7369 6f6e 2829 2e69  rent.session().i
    │ │ │ +0005e320: 735f 7369 6e67 6c65 5f74 6872 6561 6428  s_single_thread(
    │ │ │ +0005e330: 2929 3b0a 0a09 0909 2f2f 2069 676e 6f72  ));.....// ignor
    │ │ │ +0005e340: 6520 7265 6164 2065 7272 6f72 730a 3c2f  e read errors.r
    │ │ │ +0005e380: 656c 6576 616e 6365 266e 6273 703b 303c  elevance 0<
    │ │ │ +0005e390: 2f74 643e 3c74 643e 3c61 2068 7265 663d  /td>../src/
    │ │ │ +0005e3c0: 7574 5f6d 6574 6164 6174 612e 6370 703a  ut_metadata.cpp:
    │ │ │ +0005e3d0: 3235 363c 2f61 3e3c 2f74 643e 3c74 643e  256
    │ │ │ +0005e3e0: 7765 2072 6561 6c6c 7920 6e65 6564 2074  we really need t
    │ │ │ +0005e3f0: 6f20 696e 6372 656d 656e 7420 7468 6520  o increment the 
    │ │ │ +0005e400: 7265 6663 6f75 6e74 6572 206f 6e20 7468  refcounter on th
    │ │ │ +0005e410: 6520 746f 7272 656e 7420 7768 696c 6520  e torrent while 
    │ │ │ +0005e420: 7468 6973 2062 7566 6665 7220 6973 2073  this buffer is s
    │ │ │ +0005e430: 7469 6c6c 2069 6e20 7468 6520 7065 6572  till in the peer
    │ │ │ +0005e440: 2773 2073 656e 6420 6275 6666 6572 3c2f  's send buffer

    we r │ │ │ +0005e4a0: 6561 6c6c 7920 6e65 6564 2074 6f20 696e eally need to in │ │ │ +0005e4b0: 6372 656d 656e 7420 7468 6520 7265 6663 crement the refc │ │ │ +0005e4c0: 6f75 6e74 6572 206f 6e20 7468 6520 746f ounter on the to │ │ │ +0005e4d0: 7272 656e 740a 7768 696c 6520 7468 6973 rrent.while this │ │ │ +0005e4e0: 2062 7566 6665 7220 6973 2073 7469 6c6c buffer is still │ │ │ +0005e4f0: 2069 6e20 7468 6520 7065 6572 2773 2073 in the peer's s │ │ │ +0005e500: 656e 6420 6275 6666 6572 3c2f 6832 3e3c end buffer

    < │ │ │ +0005e510: 6834 3e2e 2e2f 7372 632f 7574 5f6d 6574 h4>../src/ut_met │ │ │ +0005e520: 6164 6174 612e 6370 703a 3235 363c 2f68 adata.cpp:256
    ....
    │ │ │ +0005e570: 696e 7420 636f 6e73 7420 6f66 6673 6574  int const offset
    │ │ │ +0005e580: 203d 2070 6965 6365 202a 2031 3620 2a20   = piece * 16 * 
    │ │ │ +0005e590: 3130 3234 3b0a 0909 0909 6d65 7461 6461  1024;.....metada
    │ │ │ +0005e5a0: 7461 203d 206d 5f74 702e 6d65 7461 6461  ta = m_tp.metada
    │ │ │ +0005e5b0: 7461 2829 2e64 6174 6128 2920 2b20 6f66  ta().data() + of
    │ │ │ +0005e5c0: 6673 6574 3b0a 0909 0909 6d65 7461 6461  fset;.....metada
    │ │ │ +0005e5d0: 7461 5f70 6965 6365 5f73 697a 6520 3d20  ta_piece_size = 
    │ │ │ +0005e5e0: 7374 643a 3a6d 696e 280a 0909 0909 0969  std::min(......i
    │ │ │ +0005e5f0: 6e74 286d 5f74 702e 6d65 7461 6461 7461  nt(m_tp.metadata
    │ │ │ +0005e600: 2829 2e73 697a 6528 2929 202d 206f 6666  ().size()) - off
    │ │ │ +0005e610: 7365 742c 2031 3620 2a20 3130 3234 293b  set, 16 * 1024);
    │ │ │ +0005e620: 0a09 0909 0954 4f52 5245 4e54 5f41 5353  .....TORRENT_ASS
    │ │ │ +0005e630: 4552 5428 6d65 7461 6461 7461 5f70 6965  ERT(metadata_pie
    │ │ │ +0005e640: 6365 5f73 697a 6520 2667 743b 2030 293b  ce_size > 0);
    │ │ │ +0005e650: 0a09 0909 0954 4f52 5245 4e54 5f41 5353  .....TORRENT_ASS
    │ │ │ +0005e660: 4552 5428 6f66 6673 6574 2026 6774 3b3d  ERT(offset >=
    │ │ │ +0005e670: 2030 293b 0a09 0909 0954 4f52 5245 4e54   0);.....TORRENT
    │ │ │ +0005e680: 5f41 5353 4552 5428 6f66 6673 6574 202b  _ASSERT(offset +
    │ │ │ +0005e690: 206d 6574 6164 6174 615f 7069 6563 655f   metadata_piece_
    │ │ │ +0005e6a0: 7369 7a65 2026 6c74 3b3d 206d 5f74 702e  size <= m_tp.
    │ │ │ +0005e6b0: 6d65 7461 6461 7461 2829 2e73 697a 6528  metadata().size(
    │ │ │ +0005e6c0: 2929 3b0a 0909 097d 0a0a 0909 0963 6861  ));....}.....cha
    │ │ │ +0005e6d0: 7220 6d73 675b 3230 305d 3b0a 0909 0963  r msg[200];....c
    │ │ │ +0005e6e0: 6861 722a 2068 6561 6465 7220 3d20 6d73  har* header = ms
    │ │ │ +0005e6f0: 673b 0a09 0909 6368 6172 2a20 7020 3d20  g;....char* p = 
    │ │ │ +0005e700: 2661 6d70 3b6d 7367 5b36 5d3b 0a09 0909  &msg[6];....
    │ │ │ +0005e710: 696e 7420 636f 6e73 7420 6c65 6e20 3d20  int const len = 
    │ │ │ +0005e720: 6265 6e63 6f64 6528 702c 2065 293b 0a09  bencode(p, e);..
    │ │ │ +0005e730: 0909 696e 7420 636f 6e73 7420 746f 7461  ..int const tota
    │ │ │ +0005e740: 6c5f 7369 7a65 203d 2032 202b 206c 656e  l_size = 2 + len
    │ │ │ +0005e750: 202b 206d 6574 6164 6174 615f 7069 6563   + metadata_piec
    │ │ │ +0005e760: 655f 7369 7a65 3b0a 0909 096e 616d 6573  e_size;....names
    │ │ │ +0005e770: 7061 6365 2069 6f20 3d20 6175 783b 0a09  pace io = aux;..
    │ │ │ +0005e780: 0909 696f 3a3a 7772 6974 655f 7569 6e74  ..io::write_uint
    │ │ │ +0005e790: 3332 2874 6f74 616c 5f73 697a 652c 2068  32(total_size, h
    │ │ │ +0005e7a0: 6561 6465 7229 3b0a 0909 0969 6f3a 3a77  eader);....io::w
    │ │ │ +0005e7b0: 7269 7465 5f75 696e 7438 2861 7578 3a3a  rite_uint8(aux::
    │ │ │ +0005e7c0: 6274 5f70 6565 725f 636f 6e6e 6563 7469  bt_peer_connecti
    │ │ │ +0005e7d0: 6f6e 3a3a 6d73 675f 6578 7465 6e64 6564  on::msg_extended
    │ │ │ +0005e7e0: 2c20 6865 6164 6572 293b 0a09 0909 696f  , header);....io
    │ │ │ +0005e7f0: 3a3a 7772 6974 655f 7569 6e74 3828 6d5f  ::write_uint8(m_
    │ │ │ +0005e800: 6d65 7373 6167 655f 696e 6465 782c 2068  message_index, h
    │ │ │ +0005e810: 6561 6465 7229 3b0a 0a09 0909 6d5f 7063  eader);.....m_pc
    │ │ │ +0005e820: 2e73 656e 645f 6275 6666 6572 287b 6d73  .send_buffer({ms
    │ │ │ +0005e830: 672c 206c 656e 202b 2036 7d29 3b0a 3c64  g, len + 6});....i
    │ │ │ +0005e870: 6620 286d 6574 6164 6174 615f 7069 6563  f (metadata_piec
    │ │ │ +0005e880: 655f 7369 7a65 290a 3c2f 6469 763e 0909  e_size)...
    │ │ │ +0005e890: 097b 0a09 0909 096d 5f70 632e 6170 7065  .{.....m_pc.appe
    │ │ │ +0005e8a0: 6e64 5f63 6f6e 7374 5f73 656e 645f 6275  nd_const_send_bu
    │ │ │ +0005e8b0: 6666 6572 280a 0909 0909 0973 7061 6e26  ffer(......span&
    │ │ │ +0005e8c0: 6c74 3b63 6861 7226 6774 3b28 636f 6e73  lt;char>(cons
    │ │ │ +0005e8d0: 745f 6361 7374 266c 743b 6368 6172 2a26  t_cast<char*&
    │ │ │ +0005e8e0: 6774 3b28 6d65 7461 6461 7461 292c 206d  gt;(metadata), m
    │ │ │ +0005e8f0: 6574 6164 6174 615f 7069 6563 655f 7369  etadata_piece_si
    │ │ │ +0005e900: 7a65 292c 206d 6574 6164 6174 615f 7069  ze), metadata_pi
    │ │ │ +0005e910: 6563 655f 7369 7a65 293b 0a09 0909 7d0a  ece_size);....}.
    │ │ │ +0005e920: 0a09 0909 6d5f 7063 2e73 7461 7473 5f63  ....m_pc.stats_c
    │ │ │ +0005e930: 6f75 6e74 6572 7328 292e 696e 635f 7374  ounters().inc_st
    │ │ │ +0005e940: 6174 735f 636f 756e 7465 7228 636f 756e  ats_counter(coun
    │ │ │ +0005e950: 7465 7273 3a3a 6e75 6d5f 6f75 7467 6f69  ters::num_outgoi
    │ │ │ +0005e960: 6e67 5f65 7874 656e 6465 6429 3b0a 0909  ng_extended);...
    │ │ │ +0005e970: 096d 5f70 632e 7374 6174 735f 636f 756e  .m_pc.stats_coun
    │ │ │ +0005e980: 7465 7273 2829 2e69 6e63 5f73 7461 7473  ters().inc_stats
    │ │ │ +0005e990: 5f63 6f75 6e74 6572 2863 6f75 6e74 6572  _counter(counter
    │ │ │ +0005e9a0: 733a 3a6e 756d 5f6f 7574 676f 696e 675f  s::num_outgoing_
    │ │ │ +0005e9b0: 6d65 7461 6461 7461 293b 0a09 097d 0a0a  metadata);...}..
    │ │ │ +0005e9c0: 0909 626f 6f6c 206f 6e5f 6578 7465 6e64  ..bool on_extend
    │ │ │ +0005e9d0: 6564 2869 6e74 2063 6f6e 7374 206c 656e  ed(int const len
    │ │ │ +0005e9e0: 6774 680a 0909 092c 2069 6e74 2063 6f6e  gth...., int con
    │ │ │ +0005e9f0: 7374 2065 7874 656e 6465 645f 6d73 672c  st extended_msg,
    │ │ │ +0005ea00: 2073 7061 6e26 6c74 3b63 6861 7220 636f   span<char co
    │ │ │ +0005ea10: 6e73 7426 6774 3b20 626f 6479 2920 6f76  nst> body) ov
    │ │ │ +0005ea20: 6572 7269 6465 0a09 097b 0a09 0909 6966  erride...{....if
    │ │ │ +0005ea30: 2028 6578 7465 6e64 6564 5f6d 7367 2021   (extended_msg !
    │ │ │ +0005ea40: 3d20 3229 2072 6574 7572 6e20 6661 6c73  = 2) return fals
    │ │ │ +0005ea50: 653b 0a09 0909 6966 2028 6d5f 6d65 7373  e;....if (m_mess
    │ │ │ +0005ea60: 6167 655f 696e 6465 7820 3d3d 2030 2920  age_index == 0) 
    │ │ │ +0005ea70: 7265 7475 726e 2066 616c 7365 3b0a 0a09  return false;...
    │ │ │ +0005ea80: 0909 6966 2028 6c65 6e67 7468 2026 6774  ..if (length >
    │ │ │ +0005ea90: 3b20 3137 202a 2031 3032 3429 0a09 0909  ; 17 * 1024)....
    │ │ │ +0005eaa0: 7b0a 2369 666e 6465 6620 544f 5252 454e  {.#ifndef TORREN
    │ │ │ +0005eab0: 545f 4449 5341 424c 455f 4c4f 4747 494e  T_DISABLE_LOGGIN
    │ │ │ +0005eac0: 470a 0909 0909 6d5f 7063 2e70 6565 725f  G.....m_pc.peer_
    │ │ │ +0005ead0: 6c6f 6728 7065 6572 5f6c 6f67 5f61 6c65  log(peer_log_ale
    │ │ │ +0005eae0: 7274 3a3a 696e 636f 6d69 6e67 5f6d 6573  rt::incoming_mes
    │ │ │ +0005eaf0: 7361 6765 2c20 7065 6572 5f6c 6f67 5f61  sage, peer_log_a
    │ │ │ +0005eb00: 6c65 7274 3a3a 7574 5f6d 6574 6164 6174  lert::ut_metadat
    │ │ │ +0005eb10: 610a 0909 0909 092c 2022 7061 636b 6574  a......, "packet
    │ │ │ +0005eb20: 2074 6f6f 2062 6967 2025 6422 2c20 6c65   too big %d", le
    │ │ │ +0005eb30: 6e67 7468 293b 0a23 656e 6469 660a 0909  ngth);.#endif...
    │ │ │ +0005eb40: 0909 6d5f 7063 2e64 6973 636f 6e6e 6563  ..m_pc.disconnec
    │ │ │ +0005eb50: 7428 6572 726f 7273 3a3a 696e 7661 6c69  t(errors::invali
    │ │ │ +0005eb60: 645f 6d65 7461 6461 7461 5f6d 6573 7361  d_metadata_messa
    │ │ │ +0005eb70: 6765 2c20 6f70 6572 6174 696f 6e5f 743a  ge, operation_t:
    │ │ │ +0005eb80: 3a62 6974 746f 7272 656e 742c 2070 6565  :bittorrent, pee
    │ │ │ +0005eb90: 725f 636f 6e6e 6563 7469 6f6e 5f69 6e74  r_connection_int
    │ │ │ +0005eba0: 6572 6661 6365 3a3a 7065 6572 5f65 7272  erface::peer_err
    │ │ │ +0005ebb0: 6f72 293b 0a09 0909 0972 6574 7572 6e20  or);.....return 
    │ │ │ +0005ebc0: 7472 7565 3b0a 0909 097d 0a0a 0909 0969  true;....}.....i
    │ │ │ +0005ebd0: 6620 2821 6d5f 7063 2e70 6163 6b65 745f  f (!m_pc.packet_
    │ │ │ +0005ebe0: 6669 6e69 7368 6564 2829 2920 7265 7475  finished()) retu
    │ │ │ +0005ebf0: 726e 2074 7275 653b 0a0a 0909 0965 7272  rn true;.....err
    │ │ │ +0005ec00: 6f72 5f63 6f64 6520 6563 3b0a 0909 0962  or_code ec;....b
    │ │ │ +0005ec10: 6465 636f 6465 5f6e 6f64 6520 6d73 6720  decode_node msg 
    │ │ │ +0005ec20: 3d20 6264 6563 6f64 6528 626f 6479 2c20  = bdecode(body, 
    │ │ │ +0005ec30: 6563 293b 0a09 0909 6966 2028 6d73 672e  ec);....if (msg.
    │ │ │ +0005ec40: 7479 7065 2829 2021 3d20 6264 6563 6f64  type() != bdecod
    │ │ │ +0005ec50: 655f 6e6f 6465 3a3a 6469 6374 5f74 290a  e_node::dict_t).
    │ │ │ +0005ec60: 3c2f 7072 653e 3c2f 7464 3e3c 2f74 723e  
    │ │ │ +0005ec70: 3c74 7220 7374 796c 653d 2262 6163 6b67 relevance  │ │ │ +0005eca0: 303c 2f74 643e 3c74 643e 3c61 2068 7265 0../sr │ │ │ +0005ecd0: 632f 6469 7361 626c 6564 5f64 6973 6b5f c/disabled_disk_ │ │ │ +0005ece0: 696f 2e63 7070 3a38 333c 2f61 3e3c 2f74 io.cpp:83
    it would b │ │ │ +0005ed00: 6520 6e69 6365 2074 6f20 7265 7475 726e e nice to return │ │ │ +0005ed10: 2061 2076 616c 6964 2068 6173 6820 6f66 a valid hash of │ │ │ +0005ed20: 207a 6572 6f65 7320 6865 7265 3c2f 7464 zeroes here

    it wou │ │ │ +0005ed80: 6c64 2062 6520 6e69 6365 2074 6f20 7265 ld be nice to re │ │ │ +0005ed90: 7475 726e 2061 2076 616c 6964 2068 6173 turn a valid has │ │ │ +0005eda0: 6820 6f66 207a 6572 6f65 7320 6865 7265 h of zeroes here │ │ │ +0005edb0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +0005edc0: 6469 7361 626c 6564 5f64 6973 6b5f 696f disabled_disk_io │ │ │ +0005edd0: 2e63 7070 3a38 333c 2f68 343e 3c70 7265 .cpp:83

    ..});..}..
    │ │ │ +0005ee20: 0962 6f6f 6c20 6173 796e 635f 7772 6974  .bool async_writ
    │ │ │ +0005ee30: 6528 7374 6f72 6167 655f 696e 6465 785f  e(storage_index_
    │ │ │ +0005ee40: 740a 0909 2c20 7065 6572 5f72 6571 7565  t..., peer_reque
    │ │ │ +0005ee50: 7374 2063 6f6e 7374 2661 6d70 3b20 720a  st const& r.
    │ │ │ +0005ee60: 0909 2c20 6368 6172 2063 6f6e 7374 2a2c  .., char const*,
    │ │ │ +0005ee70: 2073 7464 3a3a 7368 6172 6564 5f70 7472   std::shared_ptr
    │ │ │ +0005ee80: 266c 743b 6469 736b 5f6f 6273 6572 7665  <disk_observe
    │ │ │ +0005ee90: 7226 6774 3b0a 0909 2c20 7374 643a 3a66  r>..., std::f
    │ │ │ +0005eea0: 756e 6374 696f 6e26 6c74 3b76 6f69 6428  unction<void(
    │ │ │ +0005eeb0: 7374 6f72 6167 655f 6572 726f 7220 636f  storage_error co
    │ │ │ +0005eec0: 6e73 7426 616d 703b 2926 6774 3b20 6861  nst&)> ha
    │ │ │ +0005eed0: 6e64 6c65 720a 0909 2c20 6469 736b 5f6a  ndler..., disk_j
    │ │ │ +0005eee0: 6f62 5f66 6c61 6773 5f74 2920 6f76 6572  ob_flags_t) over
    │ │ │ +0005eef0: 7269 6465 0a09 7b0a 0909 544f 5252 454e  ride..{...TORREN
    │ │ │ +0005ef00: 545f 4153 5345 5254 2872 2e6c 656e 6774  T_ASSERT(r.lengt
    │ │ │ +0005ef10: 6820 266c 743b 3d20 6465 6661 756c 745f  h <= default_
    │ │ │ +0005ef20: 626c 6f63 6b5f 7369 7a65 293b 0a09 0954  block_size);...T
    │ │ │ +0005ef30: 4f52 5245 4e54 5f55 4e55 5345 4428 7229  ORRENT_UNUSED(r)
    │ │ │ +0005ef40: 3b0a 0a09 0970 6f73 7428 6d5f 696f 732c  ;....post(m_ios,
    │ │ │ +0005ef50: 205b 6820 3d20 7374 643a 3a6d 6f76 6528   [h = std::move(
    │ │ │ +0005ef60: 6861 6e64 6c65 7229 5d20 7b20 6828 7374  handler)] { h(st
    │ │ │ +0005ef70: 6f72 6167 655f 6572 726f 727b 7d29 3b20  orage_error{}); 
    │ │ │ +0005ef80: 7d29 3b0a 0909 7265 7475 726e 2066 616c  });...return fal
    │ │ │ +0005ef90: 7365 3b0a 097d 0a0a 0976 6f69 6420 6173  se;..}...void as
    │ │ │ +0005efa0: 796e 635f 6861 7368 2873 746f 7261 6765  ync_hash(storage
    │ │ │ +0005efb0: 5f69 6e64 6578 5f74 0a09 092c 2070 6965  _index_t..., pie
    │ │ │ +0005efc0: 6365 5f69 6e64 6578 5f74 2070 6965 6365  ce_index_t piece
    │ │ │ +0005efd0: 2c20 7370 616e 266c 743b 7368 6132 3536  , span<sha256
    │ │ │ +0005efe0: 5f68 6173 6826 6774 3b2c 2064 6973 6b5f  _hash>, disk_
    │ │ │ +0005eff0: 6a6f 625f 666c 6167 735f 740a 0909 2c20  job_flags_t..., 
    │ │ │ +0005f000: 7374 643a 3a66 756e 6374 696f 6e26 6c74  std::function<
    │ │ │ +0005f010: 3b76 6f69 6428 7069 6563 655f 696e 6465  ;void(piece_inde
    │ │ │ +0005f020: 785f 742c 2073 6861 315f 6861 7368 2063  x_t, sha1_hash c
    │ │ │ +0005f030: 6f6e 7374 2661 6d70 3b2c 2073 746f 7261  onst&, stora
    │ │ │ +0005f040: 6765 5f65 7272 6f72 2063 6f6e 7374 2661  ge_error const&a
    │ │ │ +0005f050: 6d70 3b29 2667 743b 2068 616e 646c 6572  mp;)> handler
    │ │ │ +0005f060: 2920 6f76 6572 7269 6465 0a09 7b0a 3c64  ) override..{...po
    │ │ │ +0005f0a0: 7374 286d 5f69 6f73 2c20 5b68 203d 2073  st(m_ios, [h = s
    │ │ │ +0005f0b0: 7464 3a3a 6d6f 7665 2868 616e 646c 6572  td::move(handler
    │ │ │ +0005f0c0: 292c 2070 6965 6365 5d20 7b20 6828 7069  ), piece] { h(pi
    │ │ │ +0005f0d0: 6563 652c 2073 6861 315f 6861 7368 7b7d  ece, sha1_hash{}
    │ │ │ +0005f0e0: 2c20 7374 6f72 6167 655f 6572 726f 727b  , storage_error{
    │ │ │ +0005f0f0: 7d29 3b20 7d29 3b0a 3c2f 6469 763e 097d  }); });..}
    │ │ │ +0005f100: 0a0a 0976 6f69 6420 6173 796e 635f 6861  ...void async_ha
    │ │ │ +0005f110: 7368 3228 7374 6f72 6167 655f 696e 6465  sh2(storage_inde
    │ │ │ +0005f120: 785f 742c 2070 6965 6365 5f69 6e64 6578  x_t, piece_index
    │ │ │ +0005f130: 5f74 2070 6965 6365 2c20 696e 740a 0909  _t piece, int...
    │ │ │ +0005f140: 2c20 6469 736b 5f6a 6f62 5f66 6c61 6773  , disk_job_flags
    │ │ │ +0005f150: 5f74 0a09 092c 2073 7464 3a3a 6675 6e63  _t..., std::func
    │ │ │ +0005f160: 7469 6f6e 266c 743b 766f 6964 2870 6965  tion<void(pie
    │ │ │ +0005f170: 6365 5f69 6e64 6578 5f74 2c20 7368 6132  ce_index_t, sha2
    │ │ │ +0005f180: 3536 5f68 6173 6820 636f 6e73 7426 616d  56_hash const&am
    │ │ │ +0005f190: 703b 2c20 7374 6f72 6167 655f 6572 726f  p;, storage_erro
    │ │ │ +0005f1a0: 7220 636f 6e73 7426 616d 703b 2926 6774  r const&)>
    │ │ │ +0005f1b0: 3b20 6861 6e64 6c65 7229 206f 7665 7272  ; handler) overr
    │ │ │ +0005f1c0: 6964 650a 097b 0a09 0970 6f73 7428 6d5f  ide..{...post(m_
    │ │ │ +0005f1d0: 696f 732c 205b 6820 3d20 7374 643a 3a6d  ios, [h = std::m
    │ │ │ +0005f1e0: 6f76 6528 6861 6e64 6c65 7229 2c20 7069  ove(handler), pi
    │ │ │ +0005f1f0: 6563 655d 2829 207b 2068 2870 6965 6365  ece]() { h(piece
    │ │ │ +0005f200: 2c20 7368 6132 3536 5f68 6173 687b 7d2c  , sha256_hash{},
    │ │ │ +0005f210: 2073 746f 7261 6765 5f65 7272 6f72 7b7d   storage_error{}
    │ │ │ +0005f220: 293b 207d 293b 0a09 7d0a 0a09 766f 6964  ); });..}...void
    │ │ │ +0005f230: 2061 7379 6e63 5f6d 6f76 655f 7374 6f72   async_move_stor
    │ │ │ +0005f240: 6167 6528 7374 6f72 6167 655f 696e 6465  age(storage_inde
    │ │ │ +0005f250: 785f 740a 0909 2c20 7374 643a 3a73 7472  x_t..., std::str
    │ │ │ +0005f260: 696e 6720 702c 206d 6f76 655f 666c 6167  ing p, move_flag
    │ │ │ +0005f270: 735f 740a 0909 2c20 7374 643a 3a66 756e  s_t..., std::fun
    │ │ │ +0005f280: 6374 696f 6e26 6c74 3b76 6f69 6428 7374  ction<void(st
    │ │ │ +0005f290: 6174 7573 5f74 2c20 7374 643a 3a73 7472  atus_t, std::str
    │ │ │ +0005f2a0: 696e 6720 636f 6e73 7426 616d 703b 2c20  ing const&, 
    │ │ │ +0005f2b0: 7374 6f72 6167 655f 6572 726f 7220 636f  storage_error co
    │ │ │ +0005f2c0: 6e73 7426 616d 703b 2926 6774 3b20 6861  nst&)> ha
    │ │ │ +0005f2d0: 6e64 6c65 7229 206f 7665 7272 6964 650a  ndler) override.
    │ │ │ +0005f2e0: 097b 0a09 0970 6f73 7428 6d5f 696f 732c  .{...post(m_ios,
    │ │ │ +0005f2f0: 205b 6820 3d20 7374 643a 3a6d 6f76 6528   [h = std::move(
    │ │ │ +0005f300: 6861 6e64 6c65 7229 2c20 7061 7468 203d  handler), path =
    │ │ │ +0005f310: 2073 7464 3a3a 6d6f 7665 2870 295d 2028   std::move(p)] (
    │ │ │ +0005f320: 2920 6d75 7461 626c 650a 0909 097b 2068  ) mutable....{ h
    │ │ │ +0005f330: 2873 7461 7475 735f 747b 7d2c 2073 7464  (status_t{}, std
    │ │ │ +0005f340: 3a3a 6d6f 7665 2870 6174 6829 2c20 7374  ::move(path), st
    │ │ │ +0005f350: 6f72 6167 655f 6572 726f 727b 7d29 3b20  orage_error{}); 
    │ │ │ +0005f360: 7d29 3b0a 097d 0a0a 0976 6f69 6420 6173  });..}...void as
    │ │ │ +0005f370: 796e 635f 7265 6c65 6173 655f 6669 6c65  ync_release_file
    │ │ │ +0005f380: 7328 7374 6f72 6167 655f 696e 6465 785f  s(storage_index_
    │ │ │ +0005f390: 742c 2073 7464 3a3a 6675 6e63 7469 6f6e  t, std::function
    │ │ │ +0005f3a0: 266c 743b 766f 6964 2829 2667 743b 2068  <void()> h
    │ │ │ +0005f3b0: 616e 646c 6572 2920 6f76 6572 7269 6465  andler) override
    │ │ │ +0005f3c0: 0a09 7b0a 0909 706f 7374 286d 5f69 6f73  ..{...post(m_ios
    │ │ │ +0005f3d0: 2c20 5b68 203d 2073 7464 3a3a 6d6f 7665  , [h = std::move
    │ │ │ +0005f3e0: 2868 616e 646c 6572 295d 207b 2068 2829  (handler)] { h()
    │ │ │ +0005f3f0: 3b20 7d29 3b0a 097d 0a0a 0976 6f69 6420  ; });..}...void 
    │ │ │ +0005f400: 6173 796e 635f 6465 6c65 7465 5f66 696c  async_delete_fil
    │ │ │ +0005f410: 6573 2873 746f 7261 6765 5f69 6e64 6578  es(storage_index
    │ │ │ +0005f420: 5f74 0a09 092c 2072 656d 6f76 655f 666c  _t..., remove_fl
    │ │ │ +0005f430: 6167 735f 742c 2073 7464 3a3a 6675 6e63  ags_t, std::func
    │ │ │ +0005f440: 7469 6f6e 266c 743b 766f 6964 2873 746f  tion<void(sto
    │ │ │ +0005f450: 7261 6765 5f65 7272 6f72 2063 6f6e 7374  rage_error const
    │ │ │ +0005f460: 2661 6d70 3b29 2667 743b 2068 616e 646c  &)> handl
    │ │ │ +0005f470: 6572 2920 6f76 6572 7269 6465 0a09 7b0a  er) override..{.
    │ │ │ +0005f480: 0909 706f 7374 286d 5f69 6f73 2c20 5b68  ..post(m_ios, [h
    │ │ │ +0005f490: 203d 2073 7464 3a3a 6d6f 7665 2868 616e   = std::move(han
    │ │ │ +0005f4a0: 646c 6572 295d 207b 2068 2873 746f 7261  dler)] { h(stora
    │ │ │ +0005f4b0: 6765 5f65 7272 6f72 7b7d 293b 207d 293b  ge_error{}); });
    │ │ │ +0005f4c0: 0a09 7d0a 0a09 766f 6964 2061 7379 6e63  ..}...void async
    │ │ │ +0005f4d0: 5f63 6865 636b 5f66 696c 6573 2873 746f  _check_files(sto
    │ │ │ +0005f4e0: 7261 6765 5f69 6e64 6578 5f74 0a09 092c  rage_index_t...,
    │ │ │ +0005f4f0: 2061 6464 5f74 6f72 7265 6e74 5f70 6172   add_torrent_par
    │ │ │ +0005f500: 616d 7320 636f 6e73 742a 0a3c 2f70 7265  ams const*.
    rele │ │ │ +0005f540: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/dis │ │ │ +0005f580: 6b5f 6361 6368 652e 6370 703a 3732 303c k_cache.cpp:720< │ │ │ +0005f590: 2f61 3e3c 2f74 643e 3c74 643e 7061 7373 /a>pass │ │ │ +0005f5a0: 2074 6865 2062 6c6f 636b 206f 6666 7365 the block offse │ │ │ +0005f5b0: 7420 6173 2061 2070 6172 616d 6574 6572 t as a parameter │ │ │ +0005f5c0: 2069 6e73 7465 6164 206f 6620 636f 6d70 instead of comp │ │ │ +0005f5d0: 7574 696e 6720 6974 206c 696b 6520 7468 uting it like th │ │ │ +0005f5e0: 6973 3c2f 7464 3e3c 2f74 723e 3c74 7220 is

    │ │ │ +0005f630: 7061 7373 2074 6865 2062 6c6f 636b 206f pass the block o │ │ │ +0005f640: 6666 7365 7420 6173 2061 2070 6172 616d ffset as a param │ │ │ +0005f650: 6574 6572 2069 6e73 7465 6164 206f 6620 eter instead of │ │ │ +0005f660: 636f 6d70 7574 696e 6720 6974 206c 696b computing it lik │ │ │ +0005f670: 6520 7468 6973 3c2f 6832 3e3c 6834 3e2e e this

    . │ │ │ +0005f680: 2e2f 7372 632f 6469 736b 5f63 6163 6865 ./src/disk_cache │ │ │ +0005f690: 2e63 7070 3a37 3230 3c2f 6834 3e3c 7072 .cpp:720

    template │ │ │ +0005f6e0: 266c 743b 7479 7065 6e61 6d65 2049 7465 <typename Ite │ │ │ +0005f6f0: 722c 2074 7970 656e 616d 6520 5669 6577 r, typename View │ │ │ +0005f700: 2667 743b 0a49 7465 7220 6469 736b 5f63 >.Iter disk_c │ │ │ +0005f710: 6163 6865 3a3a 666c 7573 685f 7069 6563 ache::flush_piec │ │ │ +0005f720: 655f 696d 706c 2856 6965 7726 616d 703b e_impl(View& │ │ │ +0005f730: 2076 6965 772c 0a09 4974 6572 2070 6965 view,..Iter pie │ │ │ +0005f740: 6365 5f69 7465 722c 0a09 7374 643a 3a66 ce_iter,..std::f │ │ │ +0005f750: 756e 6374 696f 6e26 6c74 3b69 6e74 2862 unction<int(b │ │ │ +0005f760: 6974 6669 656c 6426 616d 703b 2c20 7370 itfield&, sp │ │ │ +0005f770: 616e 266c 743b 6469 736b 5f6a 6f62 2a20 an<disk_job* │ │ │ +0005f780: 636f 6e73 7426 6774 3b29 2667 743b 2063 const>)> c │ │ │ +0005f790: 6f6e 7374 2661 6d70 3b20 662c 0a09 7374 onst& f,..st │ │ │ +0005f7a0: 643a 3a75 6e69 7175 655f 6c6f 636b 266c d::unique_lock&l │ │ │ +0005f7b0: 743b 7374 643a 3a6d 7574 6578 2667 743b t;std::mutex> │ │ │ +0005f7c0: 2661 6d70 3b20 6c2c 0a09 7370 616e 266c & l,..span&l │ │ │ +0005f7d0: 743b 6361 6368 6564 5f62 6c6f 636b 5f65 t;cached_block_e │ │ │ +0005f7e0: 6e74 7279 2667 743b 2063 6f6e 7374 2062 ntry> const b │ │ │ +0005f7f0: 6c6f 636b 732c 0a09 7374 643a 3a66 756e locks,..std::fun │ │ │ +0005f800: 6374 696f 6e26 6c74 3b76 6f69 6428 6a6f ction<void(jo │ │ │ +0005f810: 6271 7565 7565 5f74 2c20 6469 736b 5f6a bqueue_t, disk_j │ │ │ +0005f820: 6f62 2a29 2667 743b 2063 6c65 6172 5f70 ob*)> clear_p │ │ │ +0005f830: 6965 6365 5f66 756e 290a 7b0a 0954 4f52 iece_fun).{..TOR │ │ │ +0005f840: 5245 4e54 5f41 5353 4552 5428 6c2e 6f77 RENT_ASSERT(l.ow │ │ │ +0005f850: 6e73 5f6c 6f63 6b28 2929 3b0a 092f 2f20 ns_lock());..// │ │ │ +0005f860: 7768 656e 2022 626c 6f63 6b73 2220 636f when "blocks" co │ │ │ +0005f870: 7665 7273 2074 6865 2077 686f 6c65 2070 vers the whole p │ │ │ +0005f880: 6965 6365 2077 6520 6361 6e20 7573 6520 iece we can use │ │ │ +0005f890: 7468 6520 6d61 696e 7461 696e 6564 2070 the maintained p │ │ │ +0005f8a0: 6572 2d70 6965 6365 0a09 2f2f 2063 6f75 er-piece..// cou │ │ │ +0005f8b0: 6e74 6572 2069 6e73 7465 6164 206f 6620 nter instead of │ │ │ +0005f8c0: 7363 616e 6e69 6e67 2e20 4120 7375 6273 scanning. A subs │ │ │ +0005f8d0: 7061 6e20 2874 6865 2063 6865 6170 2d66 pan (the cheap-f │ │ │ +0005f8e0: 6c75 7368 2070 6173 7329 2073 7469 6c6c lush pass) still │ │ │ +0005f8f0: 206e 6565 6473 0a09 2f2f 2074 6f20 636f needs..// to co │ │ │ +0005f900: 756e 7420 7468 6520 7772 6974 6520 6a6f unt the write jo │ │ │ +0005f910: 6273 2077 6974 6869 6e20 7468 6174 2072 bs within that r │ │ │ +0005f920: 616e 6765 2e0a 0969 6e74 2063 6f6e 7374 ange...int const │ │ │ +0005f930: 206e 756d 5f62 6c6f 636b 7320 3d20 2862 num_blocks = (b │ │ │ +0005f940: 6c6f 636b 732e 7369 7a65 2829 203d 3d20 locks.size() == │ │ │ +0005f950: 7069 6563 655f 6974 6572 2d26 6774 3b62 piece_iter->b │ │ │ +0005f960: 6c6f 636b 735f 696e 5f70 6965 6365 2829 locks_in_piece() │ │ │ +0005f970: 290a 0909 3f20 696e 7428 7069 6563 655f )...? int(piece_ │ │ │ +0005f980: 6974 6572 2d26 6774 3b6e 756d 5f6a 6f62 iter->num_job │ │ │ +0005f990: 7329 0a09 093a 2063 6f75 6e74 5f6a 6f62 s)...: count_job │ │ │ +0005f9a0: 7328 626c 6f63 6b73 293b 0a09 544f 5252 s(blocks);..TORR │ │ │ +0005f9b0: 454e 545f 4153 5345 5254 286e 756d 5f62 ENT_ASSERT(num_b │ │ │ +0005f9c0: 6c6f 636b 7320 3d3d 2063 6f75 6e74 5f6a locks == count_j │ │ │ +0005f9d0: 6f62 7328 626c 6f63 6b73 2929 3b0a 0969 obs(blocks));..i │ │ │ +0005f9e0: 6620 286e 756d 5f62 6c6f 636b 7320 266c f (num_blocks &l │ │ │ +0005f9f0: 743b 3d20 3029 0a09 0972 6574 7572 6e20 t;= 0)...return │ │ │ +0005fa00: 7374 643a 3a6e 6578 7428 7069 6563 655f std::next(piece_ │ │ │ +0005fa10: 6974 6572 293b 0a0a 092f 2f20 626c 6f63 iter);...// bloc │ │ │ +0005fa20: 6b73 206d 6179 2062 6520 6120 7375 6273 ks may be a subs │ │ │ +0005fa30: 7061 6e20 6f66 2061 6c6c 2074 6865 2062 pan of all the b │ │ │ +0005fa40: 6c6f 636b 7320 696e 2074 6865 2070 6965 locks in the pie │ │ │ +0005fa50: 6365 2c20 736f 2077 6865 6e20 636f 6d70 ce, so when comp │ │ │ +0005fa60: 6172 696e 6720 666c 7573 6865 645f 6375 aring flushed_cu │ │ │ +0005fa70: 7273 6f72 2061 6e64 2068 6173 6865 725f rsor and hasher_ │ │ │ +0005fa80: 6375 7273 6f72 2c20 7765 206e 6565 6420 cursor, we need │ │ │ +0005fa90: 746f 2061 6464 2074 6865 206f 6666 7365 to add the offse │ │ │ +0005faa0: 742e 0a3c 6469 7620 7374 796c 653d 2262 t..
    .int const bloc │ │ │ +0005fae0: 6b5f 6f66 6673 6574 203d 2073 7461 7469 k_offset = stati │ │ │ +0005faf0: 635f 6361 7374 266c 743b 696e 7426 6774 c_cast<int> │ │ │ +0005fb00: 3b28 626c 6f63 6b73 2e64 6174 6128 2920 ;(blocks.data() │ │ │ +0005fb10: 2d20 7069 6563 655f 6974 6572 2d26 6774 - piece_iter-> │ │ │ +0005fb20: 3b67 6574 5f62 6c6f 636b 7328 292e 6461 ;get_blocks().da │ │ │ +0005fb30: 7461 2829 293b 0a3c 2f64 6976 3e0a 0976 ta());.
    ..v │ │ │ +0005fb40: 6965 772e 6d6f 6469 6679 2870 6965 6365 iew.modify(piece │ │ │ +0005fb50: 5f69 7465 722c 205b 5d28 6361 6368 6564 _iter, [](cached │ │ │ +0005fb60: 5f70 6965 6365 5f65 6e74 7279 2661 6d70 _piece_entry& │ │ │ +0005fb70: 3b20 6529 207b 0a09 0954 4f52 5245 4e54 ; e) {...TORRENT │ │ │ +0005fb80: 5f41 5353 4552 5428 2128 652e 666c 6167 _ASSERT(!(e.flag │ │ │ +0005fb90: 7320 2661 6d70 3b20 6361 6368 6564 5f70 s & cached_p │ │ │ +0005fba0: 6965 6365 5f65 6e74 7279 3a3a 666c 7573 iece_entry::flus │ │ │ +0005fbb0: 6869 6e67 5f66 6c61 6729 293b 0a09 0965 hing_flag));...e │ │ │ +0005fbc0: 2e66 6c61 6773 207c 3d20 6361 6368 6564 .flags |= cached │ │ │ +0005fbd0: 5f70 6965 6365 5f65 6e74 7279 3a3a 666c _piece_entry::fl │ │ │ +0005fbe0: 7573 6869 6e67 5f66 6c61 673b 0a09 7d29 ushing_flag;..}) │ │ │ +0005fbf0: 3b0a 0a09 2f2f 2053 6e61 7073 686f 7420 ;...// Snapshot │ │ │ +0005fc00: 7468 6520 7065 6e64 696e 6720 7772 6974 the pending writ │ │ │ +0005fc10: 655f 6a6f 6220 706f 696e 7465 7220 666f e_job pointer fo │ │ │ +0005fc20: 7220 6561 6368 2062 6c6f 636b 2077 6869 r each block whi │ │ │ +0005fc30: 6c65 2077 6520 7374 696c 6c0a 092f 2f20 le we still..// │ │ │ +0005fc40: 686f 6c64 2074 6865 206d 7574 6578 2e20 hold the mutex. │ │ │ +0005fc50: 666c 7573 6869 6e67 5f66 6c61 6720 7072 flushing_flag pr │ │ │ +0005fc60: 6576 656e 7473 206f 7468 6572 2074 6872 events other thr │ │ │ +0005fc70: 6561 6473 2066 726f 6d20 666c 7573 6869 eads from flushi │ │ │ +0005fc80: 6e67 0a09 2f2f 2074 6869 7320 7069 6563 ng..// this piec │ │ │ +0005fc90: 652c 2062 7574 2064 6973 6b5f 6361 6368 e, but disk_cach │ │ │ +0005fca0: 653a 3a69 6e73 6572 7428 2920 6d61 7920 e::insert() may │ │ │ +0005fcb0: 7374 696c 6c20 706f 7075 6c61 7465 2070 still populate p │ │ │ +0005fcc0: 7265 7669 6f75 736c 790a 092f 2f20 656d reviously..// em │ │ │ +0005fcd0: 7074 7920 7472 6169 6c69 6e67 2073 6c6f pty trailing slo │ │ │ +0005fce0: 7473 2028 696e 7365 7274 206f 6e6c 7920 ts (insert only │ │ │ +0005fcf0: 7265 7175 6972 6573 2062 6c6f 636b 5f69 requires block_i │ │ │ +0005fd00: 6478 2026 6774 3b3d 2068 6173 6865 725f dx >= hasher_ │ │ │ +0005fd10: 6375 7273 6f72 292e 0a09 2f2f 2052 6561 cursor)...// Rea │ │ │ +0005fd20: 6469 6e67 2063 6163 6865 645f 626c 6f63 ding cached_bloc │ │ │ +0005fd30: 6b5f 656e 7472 793a 3a77 7269 7465 5f73 k_entry::write_s │ │ │ +0005fd40: 7461 7465 2066 726f 6d20 6f75 7473 6964 tate from outsid │ │ │ +0005fd50: 6520 7468 6520 6c6f 636b 2077 6f75 6c64 e the lock would │ │ │ +0005fd60: 0a09 2f2f 2072 6163 6520 7769 7468 2074 ..// race with t │ │ │ +0005fd70: 6861 742e 204f 6e63 6520 6120 736c 6f74 hat. Once a slot │ │ │ +0005fd80: 2068 6f6c 6473 2061 2064 6973 6b5f 6a6f holds a disk_jo │ │ │ +0005fd90: 6220 7468 6520 6e65 7477 6f72 6b20 7468 b the network th │ │ │ +0005fda0: 7265 6164 2077 6f6e 2774 0a09 2f2f 2074 read won't..// t │ │ │ +0005fdb0: 6f75 6368 2069 7420 286e 6f72 2074 6865 ouch it (nor the │ │ │ +0005fdc0: 206a 6f62 2773 2063 6f6e 7465 6e74 7329 job's contents) │ │ │ +0005fdd0: 2075 6e74 696c 2074 6865 2064 6973 6b20 until the disk │ │ │ +0005fde0: 7468 7265 6164 2074 616b 6573 2069 740a thread takes it. │ │ │ +0005fdf0: 092f 2f20 6261 636b 2c20 736f 2074 6865 .// back, so the │ │ │ +0005fe00: 2073 6e61 7073 686f 7474 6564 2070 6f69 snapshotted poi │ │ │ +0005fe10: 6e74 6572 7320 616e 6420 7468 6520 6275 nters and the bu │ │ │ +0005fe20: 6666 6572 7320 7468 6579 2072 6566 6572 ffers they refer │ │ │ +0005fe30: 656e 6365 2073 7461 790a 092f 2f20 7661 ence stay..// va │ │ │ +0005fe40: 6c69 6420 666f 7220 7468 6520 656e 7469 lid for the enti │ │ │ +0005fe50: 7265 2075 6e6c 6f63 6b65 6420 7265 6769 re unlocked regi │ │ │ +0005fe60: 6f6e 2062 656c 6f77 2e0a 0954 4f52 5245 on below...TORRE │ │ │ +0005fe70: 4e54 5f41 4c4c 4f43 4128 736e 6170 7368 NT_ALLOCA(snapsh │ │ │ +0005fe80: 6f74 2c20 6469 736b 5f6a 6f62 2a2c 2062 ot, disk_job*, b │ │ │ +0005fe90: 6c6f 636b 732e 7369 7a65 2829 293b 0a09 locks.size());.. │ │ │ +0005fea0: 666f 7220 2869 6e74 2069 203d 2030 3b20 for (int i = 0; │ │ │ +0005feb0: 6920 266c 743b 2062 6c6f 636b 732e 7369 i < blocks.si │ │ │ +0005fec0: 7a65 2829 3b20 2b2b 6929 0a09 0973 6e61 ze(); ++i)...sna │ │ │ +0005fed0: 7073 686f 745b 695d 203d 2062 6c6f 636b pshot[i] = block │ │ │ +0005fee0: 735b 695d 2e67 6574 5f77 7269 7465 5f6a s[i].get_write_j │ │ │ +0005fef0: 6f62 2829 3b0a 0a09 2f2f 2077 6520 6861 ob();...// we ha │ │ │ +0005ff00: 7665 2074 6f20 7265 6c65 6173 6520 7468 ve to release th │ │ │ +0005ff10: 6520 6c6f 636b 2077 6869 6c65 2066 6c75 e lock while flu │ │ │ +0005ff20: 7368 696e 672c 2062 7574 2073 696e 6365 shing, but since │ │ │ +0005ff30: 2077 6520 7365 7420 7468 650a 092f 2f20 we set the..// │ │ │ +0005ff40: 2266 6c75 7368 696e 6722 206d 656d 6265 "flushing" membe │ │ │ +0005ff50: 7220 746f 2074 7275 652c 2074 6869 7320 r to true, this │ │ │ +0005ff60: 7069 6563 6520 6973 2070 696e 6e65 6420 piece is pinned │ │ │ +0005ff70: 746f 2074 6865 2063 6163 6865 0a09 6c2e to the cache..l. │ │ │ +0005ff80: 756e 6c6f 636b 2829 3b0a 0a09 696e 7420 unlock();...int │ │ │ +0005ff90: 636f 756e 7420 3d20 303b 0a09 6269 7466 count = 0;..bitf │ │ │ +0005ffa0: 6965 6c64 2066 6c75 7368 6564 5f62 6c6f ield flushed_blo │ │ │ +0005ffb0: 636b 733b 0a09 7b0a 0909 6175 746f 2073 cks;..{...auto s │ │ │ +0005ffc0: 6520 3d20 7363 6f70 655f 656e 6428 5b26 e = scope_end([& │ │ │ +0005ffd0: 616d 703b 5d20 7b0a 0909 096c 2e6c 6f63 amp;] {....l.loc │ │ │ +0005ffe0: 6b28 293b 0a09 0909 626f 6f6c 206e 6f74 k();....bool not │ │ │ +0005fff0: 6966 7920 3d20 6661 6c73 653b 0a09 0909 ify = false;.... │ │ │ +00060000: 7669 6577 2e6d 6f64 6966 7928 7069 6563 view.modify(piec │ │ │ +00060010: 655f 6974 6572 2c20 5b26 616d 703b 6e6f e_iter, [&no │ │ │ +00060020: 7469 6679 5d28 6361 6368 6564 5f70 6965 tify](cached_pie │ │ │ +00060030: 6365 5f65 6e74 7279 2661 6d70 3b20 6529 ce_entry& e) │ │ │ +00060040: 207b 0a3c 2f70 7265 3e3c 2f74 643e 3c2f {.
    │ │ │ +00060070: 3c74 643e 7265 6c65 7661 6e63 6526 6e62 relevance&nb │ │ │ +00060080: 7370 3b30 3c2f 7464 3e3c 7464 3e3c 6120 sp;0.. │ │ │ +000600b0: 2f73 7263 2f70 6965 6365 5f70 6963 6b65 /src/piece_picke │ │ │ +000600c0: 722e 6370 703a 3130 303c 2f61 3e3c 2f74 r.cpp:100find a bet │ │ │ +000600e0: 7465 7220 706c 6163 6520 666f 7220 7468 ter place for th │ │ │ +000600f0: 6973 3c2f 7464 3e3c 2f74 723e 3c74 7220 is

    │ │ │ +00060140: 6669 6e64 2061 2062 6574 7465 7220 706c find a better pl │ │ │ +00060150: 6163 6520 666f 7220 7468 6973 3c2f 6832 ace for this

    ../src/piec │ │ │ +00060170: 655f 7069 636b 6572 2e63 7070 3a31 3030 e_picker.cpp:100 │ │ │ +00060180: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +000601c0: 0909 7b0a 0909 0909 7374 643a 3a63 6572  ..{.....std::cer
    │ │ │ +000601d0: 7220 266c 743b 266c 743b 2022 202e 2e2e  r << " ...
    │ │ │ +000601e0: 223b 0a09 0909 0962 7265 616b 3b0a 0909  ";.....break;...
    │ │ │ +000601f0: 097d 0a09 0909 6966 2028 2a69 203d 3d20  .}....if (*i == 
    │ │ │ +00060200: 2d31 2920 6272 6561 6b3b 0a09 0909 7768  -1) break;....wh
    │ │ │ +00060210: 696c 6520 286a 2021 3d20 702e 6d5f 7072  ile (j != p.m_pr
    │ │ │ +00060220: 696f 7269 7479 5f62 6f75 6e64 6172 6965  iority_boundarie
    │ │ │ +00060230: 732e 656e 6428 2920 2661 6d70 3b26 616d  s.end() &&am
    │ │ │ +00060240: 703b 202a 6a20 266c 743b 3d20 696e 6465  p; *j <= inde
    │ │ │ +00060250: 7829 0a09 0909 7b0a 0909 0909 7374 643a  x)....{.....std:
    │ │ │ +00060260: 3a63 6572 7220 266c 743b 266c 743b 2022  :cerr << "
    │ │ │ +00060270: 7c20 223b 0a09 0909 092b 2b6a 3b0a 0909  | ";.....++j;...
    │ │ │ +00060280: 097d 0a09 0909 7374 643a 3a63 6572 7220  .}....std::cerr 
    │ │ │ +00060290: 266c 743b 266c 743b 202a 6920 266c 743b  << *i <
    │ │ │ +000602a0: 266c 743b 2022 2822 2026 6c74 3b26 6c74  < "(" <<
    │ │ │ +000602b0: 3b20 702e 6d5f 7069 6563 655f 6d61 705b  ; p.m_piece_map[
    │ │ │ +000602c0: 2a69 5d2e 696e 6465 7820 266c 743b 266c  *i].index <&l
    │ │ │ +000602d0: 743b 2022 2920 223b 0a09 0909 2d2d 6c69  t; ") ";....--li
    │ │ │ +000602e0: 6d69 743b 0a09 097d 0a09 0973 7464 3a3a  mit;...}...std::
    │ │ │ +000602f0: 6365 7272 2026 6c74 3b26 6c74 3b20 7374  cerr << st
    │ │ │ +00060300: 643a 3a65 6e64 6c3b 0a09 7d0a 7d0a 2365  d::endl;..}.}.#e
    │ │ │ +00060310: 6e64 6966 202f 2f20 544f 5252 454e 545f  ndif // TORRENT_
    │ │ │ +00060320: 5049 434b 4552 5f4c 4f47 0a0a 6e61 6d65  PICKER_LOG..name
    │ │ │ +00060330: 7370 6163 6520 6c69 6274 6f72 7265 6e74  space libtorrent
    │ │ │ +00060340: 207b 0a0a 3c64 6976 2073 7479 6c65 3d22   {..
    .const piece_b │ │ │ +00060380: 6c6f 636b 2070 6965 6365 5f62 6c6f 636b lock piece_block │ │ │ +00060390: 3a3a 696e 7661 6c69 6428 0a3c 2f64 6976 ::invalid(.
    ..std::numeric_ │ │ │ +000603b0: 6c69 6d69 7473 266c 743b 7069 6563 655f limits<piece_ │ │ │ +000603c0: 696e 6465 785f 7426 6774 3b3a 3a6d 6178 index_t>::max │ │ │ +000603d0: 2829 0a09 092c 2073 7464 3a3a 6e75 6d65 ()..., std::nume │ │ │ +000603e0: 7269 635f 6c69 6d69 7473 266c 743b 696e ric_limits<in │ │ │ +000603f0: 7426 6774 3b3a 3a6d 6178 2829 293b 0a7d t>::max());.} │ │ │ +00060400: 0a0a 6e61 6d65 7370 6163 6520 6c69 6274 ..namespace libt │ │ │ +00060410: 6f72 7265 6e74 3a3a 6175 7820 7b0a 0a09 orrent::aux {... │ │ │ +00060420: 2f2f 2074 6865 206d 6178 206e 756d 6265 // the max numbe │ │ │ +00060430: 7220 6f66 2062 6c6f 636b 7320 746f 2063 r of blocks to c │ │ │ +00060440: 7265 6174 6520 616e 2061 6666 696e 6974 reate an affinit │ │ │ +00060450: 7920 666f 720a 0963 6f6e 7374 6578 7072 y for..constexpr │ │ │ +00060460: 2069 6e74 206d 6178 5f70 6965 6365 5f61 int max_piece_a │ │ │ +00060470: 6666 696e 6974 795f 6578 7465 6e74 203d ffinity_extent = │ │ │ +00060480: 2034 202a 2031 3032 3420 2a20 3130 3234 4 * 1024 * 1024 │ │ │ +00060490: 202f 2064 6566 6175 6c74 5f62 6c6f 636b / default_block │ │ │ +000604a0: 5f73 697a 653b 0a0a 0970 6965 6365 5f70 _size;...piece_p │ │ │ +000604b0: 6963 6b65 723a 3a70 6965 6365 5f70 6963 icker::piece_pic │ │ │ +000604c0: 6b65 7228 7374 643a 3a69 6e74 3634 5f74 ker(std::int64_t │ │ │ +000604d0: 2063 6f6e 7374 2074 6f74 616c 5f73 697a const total_siz │ │ │ +000604e0: 652c 2069 6e74 2063 6f6e 7374 2070 6965 e, int const pie │ │ │ +000604f0: 6365 5f73 697a 6529 0a09 093a 206d 5f70 ce_size)...: m_p │ │ │ +00060500: 7269 6f72 6974 795f 626f 756e 6461 7269 riority_boundari │ │ │ +00060510: 6573 2831 2c20 6d5f 7069 6563 6573 2e65 es(1, m_pieces.e │ │ │ +00060520: 6e64 5f69 6e64 6578 2829 290a 097b 0a09 nd_index())..{.. │ │ │ +00060530: 0954 4f52 5245 4e54 5f41 5353 4552 5428 .TORRENT_ASSERT( │ │ │ +00060540: 746f 7461 6c5f 7369 7a65 2026 6774 3b20 total_size > │ │ │ +00060550: 3029 3b0a 0909 544f 5252 454e 545f 4153 0);...TORRENT_AS │ │ │ +00060560: 5345 5254 2870 6965 6365 5f73 697a 6520 SERT(piece_size │ │ │ +00060570: 2667 743b 2030 293b 0a23 6966 6465 6620 > 0);.#ifdef │ │ │ +00060580: 544f 5252 454e 545f 5049 434b 4552 5f4c TORRENT_PICKER_L │ │ │ +00060590: 4f47 0a09 0973 7464 3a3a 6365 7272 2026 OG...std::cerr & │ │ │ +000605a0: 6c74 3b26 6c74 3b20 225b 2220 266c 743b lt;< "[" < │ │ │ +000605b0: 266c 743b 2074 6869 7320 266c 743b 266c < this <&l │ │ │ +000605c0: 743b 2022 5d20 2220 266c 743b 266c 743b t; "] " << │ │ │ +000605d0: 2022 6e65 7720 7069 6563 655f 7069 636b "new piece_pick │ │ │ +000605e0: 6572 2220 266c 743b 266c 743b 2073 7464 er" << std │ │ │ +000605f0: 3a3a 656e 646c 3b0a 2365 6e64 6966 0a23 ::endl;.#endif.# │ │ │ +00060600: 6966 2054 4f52 5245 4e54 5f55 5345 5f49 if TORRENT_USE_I │ │ │ +00060610: 4e56 4152 4941 4e54 5f43 4845 434b 530a NVARIANT_CHECKS. │ │ │ +00060620: 0909 6368 6563 6b5f 696e 7661 7269 616e ..check_invarian │ │ │ +00060630: 7428 293b 0a23 656e 6469 660a 0a09 0972 t();.#endif....r │ │ │ +00060640: 6573 697a 6528 746f 7461 6c5f 7369 7a65 esize(total_size │ │ │ +00060650: 2c20 7069 6563 655f 7369 7a65 293b 0a09 , piece_size);.. │ │ │ +00060660: 7d0a 0a09 766f 6964 2070 6965 6365 5f70 }...void piece_p │ │ │ +00060670: 6963 6b65 723a 3a72 6573 697a 6528 7374 icker::resize(st │ │ │ +00060680: 643a 3a69 6e74 3634 5f74 2063 6f6e 7374 d::int64_t const │ │ │ +00060690: 2074 6f74 616c 5f73 697a 652c 2069 6e74 total_size, int │ │ │ +000606a0: 2063 6f6e 7374 2070 6965 6365 5f73 697a const piece_siz │ │ │ +000606b0: 6529 0a09 7b0a 0909 544f 5252 454e 545f e)..{...TORRENT_ │ │ │ +000606c0: 4153 5345 5254 2874 6f74 616c 5f73 697a ASSERT(total_siz │ │ │ +000606d0: 6520 2667 743b 2030 293b 0a09 0954 4f52 e > 0);...TOR │ │ │ +000606e0: 5245 4e54 5f41 5353 4552 5428 7069 6563 RENT_ASSERT(piec │ │ │ +000606f0: 655f 7369 7a65 2026 6774 3b20 3029 3b0a e_size > 0);. │ │ │ +00060700: 0a09 096d 5f74 6f74 616c 5f73 697a 6520 ...m_total_size │ │ │ +00060710: 3d20 746f 7461 6c5f 7369 7a65 3b0a 3c2f = total_size;.r │ │ │ +00060750: 656c 6576 616e 6365 266e 6273 703b 303c elevance 0< │ │ │ +00060760: 2f74 643e 3c74 643e 3c61 2068 7265 663d /td>../src/ │ │ │ +00060790: 7069 6563 655f 7069 636b 6572 2e63 7070 piece_picker.cpp │ │ │ +000607a0: 3a32 3035 333c 2f61 3e3c 2f74 643e 3c74 :2053this could pro │ │ │ +000607c0: 6261 626c 7920 6265 206f 7074 696d 697a bably be optimiz │ │ │ +000607d0: 6564 2062 7920 696e 6372 656d 656e 7461 ed by incrementa │ │ │ +000607e0: 6c6c 7920 6361 6c6c 696e 6720 7061 7274 lly calling part │ │ │ +000607f0: 6961 6c5f 736f 7274 2074 6f20 736f 7274 ial_sort to sort │ │ │ +00060800: 206f 6e65 206d 6f72 6520 656c 656d 656e one more elemen │ │ │ +00060810: 7420 696e 2074 6865 206c 6973 742e 2042 t in the list. B │ │ │ +00060820: 6563 6175 7365 2063 6861 6e63 6573 2061 ecause chances a │ │ │ +00060830: 7265 2074 6861 7420 7765 276c 6c20 6a75 re that we'll ju │ │ │ +00060840: 7374 206e 6565 6420 6120 7369 6e67 6c65 st need a single │ │ │ +00060850: 2070 6965 6365 2c20 616e 6420 6f6e 6365 piece, and once │ │ │ +00060860: 2077 6527 7665 2070 6963 6b65 6420 6672 we've picked fr │ │ │ +00060870: 6f6d 2069 7420 7765 2772 6520 646f 6e65 om it we're done │ │ │ +00060880: 2e20 536f 7274 696e 6720 7468 6520 7265 . Sorting the re │ │ │ +00060890: 7374 206f 6620 7468 6520 6c69 7374 2069 st of the list i │ │ │ +000608a0: 6e20 7468 6174 2063 6173 6520 6973 2061 n that case is a │ │ │ +000608b0: 2077 6173 7465 206f 6620 7469 6d65 2e3c waste of time.< │ │ │ +000608c0: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    thi │ │ │ +00060910: 7320 636f 756c 6420 7072 6f62 6162 6c79 s could probably │ │ │ +00060920: 2062 6520 6f70 7469 6d69 7a65 6420 6279 be optimized by │ │ │ +00060930: 2069 6e63 7265 6d65 6e74 616c 6c79 0a63 incrementally.c │ │ │ +00060940: 616c 6c69 6e67 2070 6172 7469 616c 5f73 alling partial_s │ │ │ +00060950: 6f72 7420 746f 2073 6f72 7420 6f6e 6520 ort to sort one │ │ │ +00060960: 6d6f 7265 2065 6c65 6d65 6e74 2069 6e20 more element in │ │ │ +00060970: 7468 6520 6c69 7374 2e20 4265 6361 7573 the list. Becaus │ │ │ +00060980: 650a 6368 616e 6365 7320 6172 6520 7468 e.chances are th │ │ │ +00060990: 6174 2077 6527 6c6c 206a 7573 7420 6e65 at we'll just ne │ │ │ +000609a0: 6564 2061 2073 696e 676c 6520 7069 6563 ed a single piec │ │ │ +000609b0: 652c 2061 6e64 206f 6e63 6520 7765 2776 e, and once we'v │ │ │ +000609c0: 650a 7069 636b 6564 2066 726f 6d20 6974 e.picked from it │ │ │ +000609d0: 2077 6527 7265 2064 6f6e 652e 2053 6f72 we're done. Sor │ │ │ +000609e0: 7469 6e67 2074 6865 2072 6573 7420 6f66 ting the rest of │ │ │ +000609f0: 2074 6865 206c 6973 7420 696e 2074 6861 the list in tha │ │ │ +00060a00: 740a 6361 7365 2069 7320 6120 7761 7374 t.case is a wast │ │ │ +00060a10: 6520 6f66 2074 696d 652e 3c2f 6832 3e3c e of time.

    < │ │ │ +00060a20: 6834 3e2e 2e2f 7372 632f 7069 6563 655f h4>../src/piece_ │ │ │ +00060a30: 7069 636b 6572 2e63 7070 3a32 3035 333c picker.cpp:2053< │ │ │ +00060a40: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +00060a80: 092f 2f20 6e6f 772c 2063 6f70 7920 6f76  .// now, copy ov
    │ │ │ +00060a90: 6572 2074 6865 2070 6f69 6e74 6572 732e  er the pointers.
    │ │ │ +00060aa0: 2057 6520 616c 736f 2061 7070 6c79 2061   We also apply a
    │ │ │ +00060ab0: 2066 696c 7465 7220 6865 7265 2074 6f20   filter here to 
    │ │ │ +00060ac0: 6e6f 740a 0909 092f 2f20 696e 636c 7564  not....// includ
    │ │ │ +00060ad0: 6520 696e 656c 6967 6962 6c65 2070 6965  e ineligible pie
    │ │ │ +00060ae0: 6365 7320 696e 2063 6572 7461 696e 206d  ces in certain m
    │ │ │ +00060af0: 6f64 6573 2e20 466f 7220 696e 7374 616e  odes. For instan
    │ │ │ +00060b00: 6365 2c20 6120 7069 6563 650a 0909 092f  ce, a piece..../
    │ │ │ +00060b10: 2f20 7468 6174 2074 6865 2063 7572 7265  / that the curre
    │ │ │ +00060b20: 6e74 2070 6565 7220 646f 6573 6e27 7420  nt peer doesn't 
    │ │ │ +00060b30: 6861 7665 2069 7320 6e6f 7420 696e 636c  have is not incl
    │ │ │ +00060b40: 7564 6564 2e0a 0909 0966 6f72 2028 6175  uded.....for (au
    │ │ │ +00060b50: 746f 2063 6f6e 7374 2661 6d70 3b20 6470  to const& dp
    │ │ │ +00060b60: 203a 206d 5f64 6f77 6e6c 6f61 6473 5b70   : m_downloads[p
    │ │ │ +00060b70: 6965 6365 5f70 6f73 3a3a 7069 6563 655f  iece_pos::piece_
    │ │ │ +00060b80: 646f 776e 6c6f 6164 696e 675d 290a 0909  downloading])...
    │ │ │ +00060b90: 097b 0a09 0909 0970 632e 696e 635f 7374  .{.....pc.inc_st
    │ │ │ +00060ba0: 6174 735f 636f 756e 7465 7228 636f 756e  ats_counter(coun
    │ │ │ +00060bb0: 7465 7273 3a3a 7069 6563 655f 7069 636b  ters::piece_pick
    │ │ │ +00060bc0: 6572 5f70 6172 7469 616c 5f6c 6f6f 7073  er_partial_loops
    │ │ │ +00060bd0: 293b 0a0a 0909 0909 6966 2028 2169 735f  );......if (!is_
    │ │ │ +00060be0: 7069 6563 655f 6672 6565 2864 702e 696e  piece_free(dp.in
    │ │ │ +00060bf0: 6465 782c 2070 6965 6365 7329 2920 636f  dex, pieces)) co
    │ │ │ +00060c00: 6e74 696e 7565 3b0a 0a09 0909 0954 4f52  ntinue;......TOR
    │ │ │ +00060c10: 5245 4e54 5f41 5353 4552 5428 6d5f 7069  RENT_ASSERT(m_pi
    │ │ │ +00060c20: 6563 655f 6d61 705b 6470 2e69 6e64 6578  ece_map[dp.index
    │ │ │ +00060c30: 5d2e 646f 776e 6c6f 6164 5f71 7565 7565  ].download_queue
    │ │ │ +00060c40: 2829 0a09 0909 0909 3d3d 2070 6965 6365  ()......== piece
    │ │ │ +00060c50: 5f70 6f73 3a3a 7069 6563 655f 646f 776e  _pos::piece_down
    │ │ │ +00060c60: 6c6f 6164 696e 6729 3b0a 0a09 0909 096f  loading);......o
    │ │ │ +00060c70: 7264 6572 6564 5f70 6172 7469 616c 735b  rdered_partials[
    │ │ │ +00060c80: 6e75 6d5f 6f72 6465 7265 645f 7061 7274  num_ordered_part
    │ │ │ +00060c90: 6961 6c73 2b2b 5d20 3d20 2661 6d70 3b64  ials++] = &d
    │ │ │ +00060ca0: 703b 0a09 0909 7d0a 0a09 0909 2f2f 206e  p;....}.....// n
    │ │ │ +00060cb0: 6f77 2c20 736f 7274 2074 6865 206c 6973  ow, sort the lis
    │ │ │ +00060cc0: 742e 0a09 0909 6966 2028 6f70 7469 6f6e  t.....if (option
    │ │ │ +00060cd0: 7320 2661 6d70 3b20 7261 7265 7374 5f66  s & rarest_f
    │ │ │ +00060ce0: 6972 7374 290a 0909 097b 0a09 0909 0972  irst)....{.....r
    │ │ │ +00060cf0: 6574 207c 3d20 7069 636b 6572 5f6c 6f67  et |= picker_log
    │ │ │ +00060d00: 5f61 6c65 7274 3a3a 7261 7265 7374 5f66  _alert::rarest_f
    │ │ │ +00060d10: 6972 7374 5f70 6172 7469 616c 733b 0a0a  irst_partials;..
    │ │ │ +00060d20: 3c64 6976 2073 7479 6c65 3d22 6261 636b  
    .. │ │ │ +00060d50: 0909 7374 643a 3a73 6f72 7428 6f72 6465 ..std::sort(orde │ │ │ +00060d60: 7265 645f 7061 7274 6961 6c73 2e62 6567 red_partials.beg │ │ │ +00060d70: 696e 2829 2c20 6f72 6465 7265 645f 7061 in(), ordered_pa │ │ │ +00060d80: 7274 6961 6c73 2e62 6567 696e 2829 202b rtials.begin() + │ │ │ +00060d90: 206e 756d 5f6f 7264 6572 6564 5f70 6172 num_ordered_par │ │ │ +00060da0: 7469 616c 730a 3c2f 6469 763e 0909 0909 tials.
    .... │ │ │ +00060db0: 092c 2073 7464 3a3a 6269 6e64 2826 616d ., std::bind(&am │ │ │ +00060dc0: 703b 7069 6563 655f 7069 636b 6572 3a3a p;piece_picker:: │ │ │ +00060dd0: 7061 7274 6961 6c5f 636f 6d70 6172 655f partial_compare_ │ │ │ +00060de0: 7261 7265 7374 5f66 6972 7374 2c20 7468 rarest_first, th │ │ │ +00060df0: 6973 0a09 0909 0909 092c 205f 312c 205f is......., _1, _ │ │ │ +00060e00: 3229 293b 0a09 0909 7d0a 0a09 0909 666f 2));....}.....fo │ │ │ +00060e10: 7220 2869 6e74 2069 203d 2030 3b20 6920 r (int i = 0; i │ │ │ +00060e20: 266c 743b 206e 756d 5f6f 7264 6572 6564 < num_ordered │ │ │ +00060e30: 5f70 6172 7469 616c 733b 202b 2b69 290a _partials; ++i). │ │ │ +00060e40: 0909 097b 0a09 0909 0972 6574 207c 3d20 ...{.....ret |= │ │ │ +00060e50: 7069 636b 6572 5f6c 6f67 5f61 6c65 7274 picker_log_alert │ │ │ +00060e60: 3a3a 7072 696f 7269 7469 7a65 5f70 6172 ::prioritize_par │ │ │ +00060e70: 7469 616c 733b 0a0a 0909 0909 6e75 6d5f tials;......num_ │ │ │ +00060e80: 626c 6f63 6b73 203d 2061 6464 5f62 6c6f blocks = add_blo │ │ │ +00060e90: 636b 735f 646f 776e 6c6f 6164 696e 6728 cks_downloading( │ │ │ +00060ea0: 2a6f 7264 6572 6564 5f70 6172 7469 616c *ordered_partial │ │ │ +00060eb0: 735b 695d 2c20 7069 6563 6573 0a09 0909 s[i], pieces.... │ │ │ +00060ec0: 0909 2c20 696e 7465 7265 7374 696e 675f .., interesting_ │ │ │ +00060ed0: 626c 6f63 6b73 2c20 6261 636b 7570 5f62 blocks, backup_b │ │ │ +00060ee0: 6c6f 636b 730a 0909 0909 092c 206e 756d locks......, num │ │ │ +00060ef0: 5f62 6c6f 636b 732c 2070 7265 6665 725f _blocks, prefer_ │ │ │ +00060f00: 636f 6e74 6967 756f 7573 5f62 6c6f 636b contiguous_block │ │ │ +00060f10: 732c 2070 6565 722c 206f 7074 696f 6e73 s, peer, options │ │ │ +00060f20: 293b 0a09 0909 0969 6620 286e 756d 5f62 );.....if (num_b │ │ │ +00060f30: 6c6f 636b 7320 266c 743b 3d20 3029 2072 locks <= 0) r │ │ │ +00060f40: 6574 7572 6e20 7265 743b 0a09 0909 0969 eturn ret;.....i │ │ │ +00060f50: 6620 2869 6e74 2862 6163 6b75 705f 626c f (int(backup_bl │ │ │ +00060f60: 6f63 6b73 2e73 697a 6528 2929 2026 6774 ocks.size()) > │ │ │ +00060f70: 3b3d 206e 756d 5f62 6c6f 636b 7329 0a09 ;= num_blocks).. │ │ │ +00060f80: 0909 0909 6272 6561 6b3b 0a09 0909 7d0a ....break;....}. │ │ │ +00060f90: 0a09 0909 6e75 6d5f 626c 6f63 6b73 203d ....num_blocks = │ │ │ +00060fa0: 2061 7070 656e 645f 626c 6f63 6b73 2869 append_blocks(i │ │ │ +00060fb0: 6e74 6572 6573 7469 6e67 5f62 6c6f 636b nteresting_block │ │ │ +00060fc0: 732c 2062 6163 6b75 705f 626c 6f63 6b73 s, backup_blocks │ │ │ +00060fd0: 0a09 0909 092c 206e 756d 5f62 6c6f 636b ....., num_block │ │ │ +00060fe0: 7329 3b0a 0909 0969 6620 286e 756d 5f62 s);....if (num_b │ │ │ +00060ff0: 6c6f 636b 7320 266c 743b 3d20 3029 2072 locks <= 0) r │ │ │ +00061000: 6574 7572 6e20 7265 743b 0a09 097d 0a0a eturn ret;...}.. │ │ │ +00061010: 0909 6966 2028 2173 7567 6765 7374 6564 ..if (!suggested │ │ │ +00061020: 5f70 6965 6365 732e 656d 7074 7928 2929 _pieces.empty()) │ │ │ +00061030: 0a09 097b 0a09 0909 666f 7220 2870 6965 ...{....for (pie │ │ │ +00061040: 6365 5f69 6e64 6578 5f74 2069 203a 2073 ce_index_t i : s │ │ │ +00061050: 7567 6765 7374 6564 5f70 6965 6365 7329 uggested_pieces) │ │ │ +00061060: 0a09 0909 7b0a 0909 0909 7063 2e69 6e63 ....{.....pc.inc │ │ │ +00061070: 5f73 7461 7473 5f63 6f75 6e74 6572 2863 _stats_counter(c │ │ │ +00061080: 6f75 6e74 6572 733a 3a70 6965 6365 5f70 ounters::piece_p │ │ │ +00061090: 6963 6b65 725f 7375 6767 6573 745f 6c6f icker_suggest_lo │ │ │ +000610a0: 6f70 7329 3b0a 0909 0909 6966 2028 2169 ops);.....if (!i │ │ │ +000610b0: 735f 7069 6563 655f 6672 6565 2869 2c20 s_piece_free(i, │ │ │ +000610c0: 7069 6563 6573 2929 2063 6f6e 7469 6e75 pieces)) continu │ │ │ +000610d0: 653b 0a0a 0909 0909 7265 7420 7c3d 2070 e;......ret |= p │ │ │ +000610e0: 6963 6b65 725f 6c6f 675f 616c 6572 743a icker_log_alert: │ │ │ +000610f0: 3a73 7567 6765 7374 6564 5f70 6965 6365 :suggested_piece │ │ │ +00061100: 733b 0a0a 3c2f 7072 653e 3c2f 7464 3e3c s;..
    < │ │ │ +00061110: 2f74 723e 3c74 7220 7374 796c 653d 2262 /tr>relevance&n │ │ │ +00061140: 6273 703b 303c 2f74 643e 3c74 643e 3c61 bsp;0. │ │ │ +00061170: 2e2f 7372 632f 7069 6563 655f 7069 636b ./src/piece_pick │ │ │ +00061180: 6572 2e63 7070 3a32 3139 353c 2f61 3e3c er.cpp:2195< │ │ │ +00061190: 2f74 643e 3c74 643e 4973 2069 7420 6120 /td>Is it a │ │ │ +000611a0: 676f 6f64 2069 6465 6120 7468 6174 2074 good idea that t │ │ │ +000611b0: 6869 7320 6166 6669 6e69 7479 2074 616b his affinity tak │ │ │ +000611c0: 6573 2070 7265 6365 6465 6e63 6520 6f76 es precedence ov │ │ │ +000611d0: 6572 2070 6965 6365 2070 7269 6f72 6974 er piece priorit │ │ │ +000611e0: 793f 3c2f 7464 3e3c 2f74 723e 3c74 7220 y?

    │ │ │ +00061230: 4973 2069 7420 6120 676f 6f64 2069 6465 Is it a good ide │ │ │ +00061240: 6120 7468 6174 2074 6869 7320 6166 6669 a that this affi │ │ │ +00061250: 6e69 7479 2074 616b 6573 2070 7265 6365 nity takes prece │ │ │ +00061260: 6465 6e63 6520 6f76 6572 0a70 6965 6365 dence over.piece │ │ │ +00061270: 2070 7269 6f72 6974 793f 3c2f 6832 3e3c priority?

    < │ │ │ +00061280: 6834 3e2e 2e2f 7372 632f 7069 6563 655f h4>../src/piece_ │ │ │ +00061290: 7069 636b 6572 2e63 7070 3a32 3139 353c picker.cpp:2195< │ │ │ +000612a0: 2f68 343e 3c70 7265 2073 7479 6c65 3d22 /h4>
    ..
    │ │ │ +000612e0: 0909 0909 7063 2e69 6e63 5f73 7461 7473  ....pc.inc_stats
    │ │ │ +000612f0: 5f63 6f75 6e74 6572 2863 6f75 6e74 6572  _counter(counter
    │ │ │ +00061300: 733a 3a70 6965 6365 5f70 6963 6b65 725f  s::piece_picker_
    │ │ │ +00061310: 7265 7665 7273 655f 7261 7265 5f6c 6f6f  reverse_rare_loo
    │ │ │ +00061320: 7073 293b 0a0a 0909 0909 0909 6966 2028  ps);........if (
    │ │ │ +00061330: 2169 735f 7069 6563 655f 6672 6565 286d  !is_piece_free(m
    │ │ │ +00061340: 5f70 6965 6365 735b 705d 2c20 7069 6563  _pieces[p], piec
    │ │ │ +00061350: 6573 2929 2063 6f6e 7469 6e75 653b 0a09  es)) continue;..
    │ │ │ +00061360: 0909 0909 092f 2f20 6375 7273 6f72 7320  .....// cursors 
    │ │ │ +00061370: 6172 6520 6e6f 7420 6d75 7461 7465 6420  are not mutated 
    │ │ │ +00061380: 6475 7269 6e67 2070 6963 6b69 6e67 3b20  during picking; 
    │ │ │ +00061390: 6d61 6b65 2073 7572 6520 7765 2064 6f6e  make sure we don
    │ │ │ +000613a0: 2774 2070 6963 6b20 7069 6563 6573 2077  't pick pieces w
    │ │ │ +000613b0: 6974 6869 6e20 7468 650a 0909 0909 0909  ithin the.......
    │ │ │ +000613c0: 2f2f 2073 6571 7565 6e74 6961 6c20 7261  // sequential ra
    │ │ │ +000613d0: 6e67 6520 6966 2069 6e20 7365 7175 656e  nge if in sequen
    │ │ │ +000613e0: 7469 616c 2064 6f77 6e6c 6f61 6420 6d6f  tial download mo
    │ │ │ +000613f0: 6465 2073 6f20 7468 6174 2077 6520 646f  de so that we do
    │ │ │ +00061400: 6e27 7420 7069 636b 2064 7570 6c69 6361  n't pick duplica
    │ │ │ +00061410: 7465 2070 6965 6365 730a 0909 0909 0909  te pieces.......
    │ │ │ +00061420: 6966 2028 286f 7074 696f 6e73 2026 616d  if ((options &am
    │ │ │ +00061430: 703b 2073 6571 7565 6e74 6961 6c29 2026  p; sequential) &
    │ │ │ +00061440: 616d 703b 2661 6d70 3b20 6d5f 7069 6563  amp;& m_piec
    │ │ │ +00061450: 6573 5b70 5d20 2667 743b 3d20 6d5f 6375  es[p] >= m_cu
    │ │ │ +00061460: 7273 6f72 2026 616d 703b 2661 6d70 3b20  rsor && 
    │ │ │ +00061470: 6d5f 7069 6563 6573 5b70 5d20 266c 743b  m_pieces[p] <
    │ │ │ +00061480: 206d 5f72 6576 6572 7365 5f63 7572 736f   m_reverse_curso
    │ │ │ +00061490: 7229 2063 6f6e 7469 6e75 653b 0a0a 0909  r) continue;....
    │ │ │ +000614a0: 0909 0909 7265 7420 7c3d 2070 6963 6b65  ....ret |= picke
    │ │ │ +000614b0: 725f 6c6f 675f 616c 6572 743a 3a72 6576  r_log_alert::rev
    │ │ │ +000614c0: 6572 7365 5f72 6172 6573 745f 6669 7273  erse_rarest_firs
    │ │ │ +000614d0: 743b 0a0a 0909 0909 0909 6e75 6d5f 626c  t;........num_bl
    │ │ │ +000614e0: 6f63 6b73 203d 2061 6464 5f62 6c6f 636b  ocks = add_block
    │ │ │ +000614f0: 7328 6d5f 7069 6563 6573 5b70 5d2c 2070  s(m_pieces[p], p
    │ │ │ +00061500: 6965 6365 730a 0909 0909 0909 092c 2069  ieces........, i
    │ │ │ +00061510: 6e74 6572 6573 7469 6e67 5f62 6c6f 636b  nteresting_block
    │ │ │ +00061520: 730a 0909 0909 0909 092c 2062 6163 6b75  s........, backu
    │ │ │ +00061530: 705f 626c 6f63 6b73 2c20 6e75 6d5f 626c  p_blocks, num_bl
    │ │ │ +00061540: 6f63 6b73 0a09 0909 0909 0909 2c20 7072  ocks........, pr
    │ │ │ +00061550: 6566 6572 5f63 6f6e 7469 6775 6f75 735f  efer_contiguous_
    │ │ │ +00061560: 626c 6f63 6b73 2c20 7065 6572 2c20 6967  blocks, peer, ig
    │ │ │ +00061570: 6e6f 7265 645f 7069 6563 6573 0a09 0909  nored_pieces....
    │ │ │ +00061580: 0909 0909 2c20 6f70 7469 6f6e 7329 3b0a  ...., options);.
    │ │ │ +00061590: 0909 0909 0909 6966 2028 6e75 6d5f 626c  ......if (num_bl
    │ │ │ +000615a0: 6f63 6b73 2026 6c74 3b3d 2030 2920 7265  ocks <= 0) re
    │ │ │ +000615b0: 7475 726e 2072 6574 3b0a 0909 0909 097d  turn ret;......}
    │ │ │ +000615c0: 0a09 0909 097d 0a09 0909 7d0a 0909 0965  .....}....}....e
    │ │ │ +000615d0: 6c73 650a 0909 097b 0a3c 6469 7620 7374  lse....{.
    ....if (o │ │ │ +00061610: 7074 696f 6e73 2026 616d 703b 2070 6965 ptions & pie │ │ │ +00061620: 6365 5f65 7874 656e 745f 6166 6669 6e69 ce_extent_affini │ │ │ +00061630: 7479 290a 3c2f 6469 763e 0909 0909 7b0a ty).
    ....{. │ │ │ +00061640: 0909 0909 0969 6e74 2074 6f5f 6572 6173 .....int to_eras │ │ │ +00061650: 6520 3d20 2d31 3b0a 0909 0909 0969 6e74 e = -1;......int │ │ │ +00061660: 2069 6478 203d 202d 313b 0a09 0909 0909 idx = -1;...... │ │ │ +00061670: 666f 7220 2870 6965 6365 5f65 7874 656e for (piece_exten │ │ │ +00061680: 745f 7420 636f 6e73 7420 6520 3a20 6d5f t_t const e : m_ │ │ │ +00061690: 7265 6365 6e74 5f65 7874 656e 7473 290a recent_extents). │ │ │ +000616a0: 0909 0909 097b 0a09 0909 0909 092b 2b69 .....{.......++i │ │ │ +000616b0: 6478 3b0a 0909 0909 0909 626f 6f6c 2068 dx;.......bool h │ │ │ +000616c0: 6176 655f 616c 6c20 3d20 7472 7565 3b0a ave_all = true;. │ │ │ +000616d0: 0909 0909 0909 666f 7220 2870 6965 6365 ......for (piece │ │ │ +000616e0: 5f69 6e64 6578 5f74 2063 6f6e 7374 2070 _index_t const p │ │ │ +000616f0: 203a 2065 7874 656e 745f 666f 7228 6529 : extent_for(e) │ │ │ +00061700: 290a 0909 0909 0909 7b0a 0909 0909 0909 ).......{....... │ │ │ +00061710: 0969 6620 2821 6d5f 7069 6563 655f 6d61 .if (!m_piece_ma │ │ │ +00061720: 705b 705d 2e66 6c75 7368 6564 2829 2920 p[p].flushed()) │ │ │ +00061730: 6861 7665 5f61 6c6c 203d 2066 616c 7365 have_all = false │ │ │ +00061740: 3b0a 0909 0909 0909 0969 6620 2821 6973 ;........if (!is │ │ │ +00061750: 5f70 6965 6365 5f66 7265 6528 702c 2070 _piece_free(p, p │ │ │ +00061760: 6965 6365 7329 2920 636f 6e74 696e 7565 ieces)) continue │ │ │ +00061770: 3b0a 0909 0909 0909 0969 6620 2828 6f70 ;........if ((op │ │ │ +00061780: 7469 6f6e 7320 2661 6d70 3b20 7365 7175 tions & sequ │ │ │ +00061790: 656e 7469 616c 2920 2661 6d70 3b26 616d ential) &&am │ │ │ +000617a0: 703b 2070 2026 6774 3b3d 206d 5f63 7572 p; p >= m_cur │ │ │ +000617b0: 736f 7220 2661 6d70 3b26 616d 703b 2070 sor && p │ │ │ +000617c0: 2026 6c74 3b20 6d5f 7265 7665 7273 655f < m_reverse_ │ │ │ +000617d0: 6375 7273 6f72 2920 636f 6e74 696e 7565 cursor) continue │ │ │ +000617e0: 3b0a 0a09 0909 0909 0909 7265 7420 7c3d ;.........ret |= │ │ │ +000617f0: 2070 6963 6b65 725f 6c6f 675f 616c 6572 picker_log_aler │ │ │ +00061800: 743a 3a65 7874 656e 745f 6166 6669 6e69 t::extent_affini │ │ │ +00061810: 7479 3b0a 0a09 0909 0909 0909 6e75 6d5f ty;.........num_ │ │ │ +00061820: 626c 6f63 6b73 203d 2061 6464 5f62 6c6f blocks = add_blo │ │ │ +00061830: 636b 7328 702c 2070 6965 6365 730a 0909 cks(p, pieces... │ │ │ +00061840: 0909 0909 0909 2c20 696e 7465 7265 7374 ......, interest │ │ │ +00061850: 696e 675f 626c 6f63 6b73 0a09 0909 0909 ing_blocks...... │ │ │ +00061860: 0909 092c 2062 6163 6b75 705f 626c 6f63 ..., backup_bloc │ │ │ +00061870: 6b73 2c20 6e75 6d5f 626c 6f63 6b73 0a09 ks, num_blocks.. │ │ │ +00061880: 0909 0909 0909 092c 2070 7265 6665 725f ......., prefer_ │ │ │ +00061890: 636f 6e74 6967 756f 7573 5f62 6c6f 636b contiguous_block │ │ │ +000618a0: 732c 2070 6565 722c 2069 676e 6f72 6564 s, peer, ignored │ │ │ +000618b0: 5f70 6965 6365 730a 0909 0909 0909 0909 _pieces......... │ │ │ +000618c0: 2c20 6f70 7469 6f6e 7329 3b0a 0909 0909 , options);..... │ │ │ +000618d0: 0909 0969 6620 286e 756d 5f62 6c6f 636b ...if (num_block │ │ │ +000618e0: 7320 266c 743b 3d20 3029 0a09 0909 0909 s <= 0)...... │ │ │ +000618f0: 0909 7b0a 0909 0909 0909 0909 2f2f 2069 ..{.........// i │ │ │ +00061900: 6620 7765 2068 6176 6520 616c 6c20 7069 f we have all pi │ │ │ +00061910: 6563 6573 2062 656c 6f6e 6769 6e67 2074 eces belonging t │ │ │ +00061920: 6f20 7468 6973 2065 7874 656e 742c 2072 o this extent, r │ │ │ +00061930: 656d 6f76 6520 6974 0a09 0909 0909 0909 emove it........ │ │ │ +00061940: 0969 6620 2874 6f5f 6572 6173 6520 213d .if (to_erase != │ │ │ +00061950: 202d 3129 206d 5f72 6563 656e 745f 6578 -1) m_recent_ex │ │ │ +00061960: 7465 6e74 732e 6572 6173 6528 6d5f 7265 tents.erase(m_re │ │ │ +00061970: 6365 6e74 5f65 7874 656e 7473 2e62 6567 cent_extents.beg │ │ │ +00061980: 696e 2829 202b 2074 6f5f 6572 6173 6529 in() + to_erase) │ │ │ +00061990: 3b0a 0909 0909 0909 0909 7265 7475 726e ;.........return │ │ │ +000619a0: 2072 6574 3b0a 0909 0909 0909 097d 0a09 ret;........}.. │ │ │ +000619b0: 0909 0909 097d 0a09 0909 0909 092f 2f20 .....}.......// │ │ │ +000619c0: 6966 2077 6520 6861 7665 2061 6c6c 2070 if we have all p │ │ │ +000619d0: 6965 6365 7320 6265 6c6f 6e67 696e 6720 ieces belonging │ │ │ +000619e0: 746f 2074 6869 7320 6578 7465 6e74 2c20 to this extent, │ │ │ +000619f0: 7265 6d6f 7665 2069 740a 0909 0909 0909 remove it....... │ │ │ +00061a00: 6966 2028 6861 7665 5f61 6c6c 2920 746f if (have_all) to │ │ │ +00061a10: 5f65 7261 7365 203d 2069 6478 3b0a 0909 _erase = idx;... │ │ │ +00061a20: 0909 097d 0a3c 2f70 7265 3e3c 2f74 643e ...}.
    │ │ │ +00061a30: 3c2f 7472 3e3c 7472 2073 7479 6c65 3d22 relevance& │ │ │ +00061a60: 6e62 7370 3b30 3c2f 7464 3e3c 7464 3e3c nbsp;0< │ │ │ +00061a70: 6120 6872 6566 3d22 6a61 7661 7363 7269 a href="javascri │ │ │ +00061a80: 7074 3a65 7870 616e 6428 3232 3429 223e pt:expand(224)"> │ │ │ +00061a90: 2e2e 2f73 7263 2f70 6965 6365 5f70 6963 ../src/piece_pic │ │ │ +00061aa0: 6b65 722e 6370 703a 3235 3532 3c2f 613e ker.cpp:2552 │ │ │ +00061ab0: 3c2f 7464 3e3c 7464 3e77 6865 6e20 6578 when ex │ │ │ +00061ac0: 7061 6e64 696e 6720 7069 6563 6573 2066 panding pieces f │ │ │ +00061ad0: 6f72 2063 6163 6865 2073 7472 6970 6520 or cache stripe │ │ │ +00061ae0: 7265 6173 6f6e 732c 2074 6865 2021 646f reasons, the !do │ │ │ +00061af0: 776e 6c6f 6164 696e 6720 636f 6e64 6974 wnloading condit │ │ │ +00061b00: 696f 6e20 646f 6573 6e27 7420 6d61 6b65 ion doesn't make │ │ │ +00061b10: 206d 7563 6820 7365 6e73 653c 2f74 643e much sense │ │ │ +00061b20: 3c2f 7472 3e3c 7472 2069 643d 2232 3234

    when ex │ │ │ +00061b70: 7061 6e64 696e 6720 7069 6563 6573 2066 panding pieces f │ │ │ +00061b80: 6f72 2063 6163 6865 2073 7472 6970 6520 or cache stripe │ │ │ +00061b90: 7265 6173 6f6e 732c 0a74 6865 2021 646f reasons,.the !do │ │ │ +00061ba0: 776e 6c6f 6164 696e 6720 636f 6e64 6974 wnloading condit │ │ │ +00061bb0: 696f 6e20 646f 6573 6e27 7420 6d61 6b65 ion doesn't make │ │ │ +00061bc0: 206d 7563 6820 7365 6e73 653c 2f68 323e much sense

    │ │ │ +00061bd0: 3c68 343e 2e2e 2f73 7263 2f70 6965 6365

    ../src/piece │ │ │ +00061be0: 5f70 6963 6b65 722e 6370 703a 3235 3532 _picker.cpp:2552 │ │ │ +00061bf0: 3c2f 6834 3e3c 7072 6520 7374 796c 653d

    .
    │ │ │ +00061c30: 7d0a 0a09 696e 7420 7069 6563 655f 7069  }...int piece_pi
    │ │ │ +00061c40: 636b 6572 3a3a 7061 796c 6f61 645f 626c  cker::payload_bl
    │ │ │ +00061c50: 6f63 6b73 5f69 6e5f 7069 6563 6528 7069  ocks_in_piece(pi
    │ │ │ +00061c60: 6563 655f 696e 6465 785f 7420 636f 6e73  ece_index_t cons
    │ │ │ +00061c70: 7420 696e 6465 7829 2063 6f6e 7374 0a09  t index) const..
    │ │ │ +00061c80: 7b0a 0909 7265 7475 726e 2062 6c6f 636b  {...return block
    │ │ │ +00061c90: 735f 696e 5f70 6965 6365 2869 6e64 6578  s_in_piece(index
    │ │ │ +00061ca0: 2920 2d20 7061 645f 6279 7465 735f 696e  ) - pad_bytes_in
    │ │ │ +00061cb0: 5f70 6965 6365 2869 6e64 6578 2920 2f20  _piece(index) / 
    │ │ │ +00061cc0: 626c 6f63 6b5f 7369 7a65 2829 3b0a 097d  block_size();..}
    │ │ │ +00061cd0: 0a0a 0962 6f6f 6c20 7069 6563 655f 7069  ...bool piece_pi
    │ │ │ +00061ce0: 636b 6572 3a3a 6973 5f70 6965 6365 5f66  cker::is_piece_f
    │ │ │ +00061cf0: 7265 6528 7069 6563 655f 696e 6465 785f  ree(piece_index_
    │ │ │ +00061d00: 7420 636f 6e73 7420 7069 6563 650a 0909  t const piece...
    │ │ │ +00061d10: 2c20 7479 7065 645f 6269 7466 6965 6c64  , typed_bitfield
    │ │ │ +00061d20: 266c 743b 7069 6563 655f 696e 6465 785f  <piece_index_
    │ │ │ +00061d30: 7426 6774 3b20 636f 6e73 7426 616d 703b  t> const&
    │ │ │ +00061d40: 2062 6974 6d61 736b 2920 636f 6e73 740a   bitmask) const.
    │ │ │ +00061d50: 097b 0a09 0972 6574 7572 6e20 6269 746d  .{...return bitm
    │ │ │ +00061d60: 6173 6b5b 7069 6563 655d 0a09 0909 2661  ask[piece]....&a
    │ │ │ +00061d70: 6d70 3b26 616d 703b 2021 6d5f 7069 6563  mp;& !m_piec
    │ │ │ +00061d80: 655f 6d61 705b 7069 6563 655d 2e66 6c75  e_map[piece].flu
    │ │ │ +00061d90: 7368 6564 2829 0a09 0909 2661 6d70 3b26  shed()....&&
    │ │ │ +00061da0: 616d 703b 2021 6d5f 7069 6563 655f 6d61  amp; !m_piece_ma
    │ │ │ +00061db0: 705b 7069 6563 655d 2e66 696c 7465 7265  p[piece].filtere
    │ │ │ +00061dc0: 6428 293b 0a09 7d0a 0a09 626f 6f6c 2070  d();..}...bool p
    │ │ │ +00061dd0: 6965 6365 5f70 6963 6b65 723a 3a63 616e  iece_picker::can
    │ │ │ +00061de0: 5f70 6963 6b28 7069 6563 655f 696e 6465  _pick(piece_inde
    │ │ │ +00061df0: 785f 7420 636f 6e73 7420 7069 6563 650a  x_t const piece.
    │ │ │ +00061e00: 0909 2c20 7479 7065 645f 6269 7466 6965  .., typed_bitfie
    │ │ │ +00061e10: 6c64 266c 743b 7069 6563 655f 696e 6465  ld<piece_inde
    │ │ │ +00061e20: 785f 7426 6774 3b20 636f 6e73 7426 616d  x_t> const&am
    │ │ │ +00061e30: 703b 2062 6974 6d61 736b 2920 636f 6e73  p; bitmask) cons
    │ │ │ +00061e40: 740a 097b 0a09 0972 6574 7572 6e20 6269  t..{...return bi
    │ │ │ +00061e50: 746d 6173 6b5b 7069 6563 655d 0a09 0909  tmask[piece]....
    │ │ │ +00061e60: 2661 6d70 3b26 616d 703b 2021 6d5f 7069  && !m_pi
    │ │ │ +00061e70: 6563 655f 6d61 705b 7069 6563 655d 2e66  ece_map[piece].f
    │ │ │ +00061e80: 6c75 7368 6564 2829 0a3c 6469 7620 7374  lushed().
    ...&& │ │ │ +00061ec0: 616d 703b 2021 6d5f 7069 6563 655f 6d61 amp; !m_piece_ma │ │ │ +00061ed0: 705b 7069 6563 655d 2e64 6f77 6e6c 6f61 p[piece].downloa │ │ │ +00061ee0: 6469 6e67 2829 0a3c 2f64 6976 3e09 0909 ding().
    ... │ │ │ +00061ef0: 2661 6d70 3b26 616d 703b 2021 6d5f 7069 && !m_pi │ │ │ +00061f00: 6563 655f 6d61 705b 7069 6563 655d 2e66 ece_map[piece].f │ │ │ +00061f10: 696c 7465 7265 6428 293b 0a09 7d0a 0a23 iltered();..}..# │ │ │ +00061f20: 6966 2054 4f52 5245 4e54 5f55 5345 5f49 if TORRENT_USE_I │ │ │ +00061f30: 4e56 4152 4941 4e54 5f43 4845 434b 530a NVARIANT_CHECKS. │ │ │ +00061f40: 0976 6f69 6420 7069 6563 655f 7069 636b .void piece_pick │ │ │ +00061f50: 6572 3a3a 6368 6563 6b5f 7065 6572 7328 er::check_peers( │ │ │ +00061f60: 290a 097b 0a09 0966 6f72 2028 6175 746f )..{...for (auto │ │ │ +00061f70: 2063 6f6e 7374 2661 6d70 3b20 6220 3a20 const& b : │ │ │ +00061f80: 6d5f 626c 6f63 6b5f 696e 666f 290a 0909 m_block_info)... │ │ │ +00061f90: 7b0a 0909 0954 4f52 5245 4e54 5f41 5353 {....TORRENT_ASS │ │ │ +00061fa0: 4552 5428 622e 7065 6572 203d 3d20 6e75 ERT(b.peer == nu │ │ │ +00061fb0: 6c6c 7074 7220 7c7c 2073 7461 7469 635f llptr || static_ │ │ │ +00061fc0: 6361 7374 266c 743b 6175 783a 3a74 6f72 cast<aux::tor │ │ │ +00061fd0: 7265 6e74 5f70 6565 722a 2667 743b 2862 rent_peer*>(b │ │ │ +00061fe0: 2e70 6565 7229 2d26 6774 3b69 6e5f 7573 .peer)->in_us │ │ │ +00061ff0: 6529 3b0a 0909 7d0a 097d 0a23 656e 6469 e);...}..}.#endi │ │ │ +00062000: 660a 0a09 766f 6964 2070 6965 6365 5f70 f...void piece_p │ │ │ +00062010: 6963 6b65 723a 3a63 6c65 6172 5f70 6565 icker::clear_pee │ │ │ +00062020: 7228 6175 783a 3a74 6f72 7265 6e74 5f70 r(aux::torrent_p │ │ │ +00062030: 6565 722a 2070 6565 7229 0a09 7b0a 0909 eer* peer)..{... │ │ │ +00062040: 666f 7220 2861 7574 6f26 616d 703b 2062 for (auto& b │ │ │ +00062050: 203a 206d 5f62 6c6f 636b 5f69 6e66 6f29 : m_block_info) │ │ │ +00062060: 0a09 097b 0a09 0909 6966 2028 622e 7065 ...{....if (b.pe │ │ │ +00062070: 6572 203d 3d20 7065 6572 2920 622e 7065 er == peer) b.pe │ │ │ +00062080: 6572 203d 206e 756c 6c70 7472 3b0a 0909 er = nullptr;... │ │ │ +00062090: 7d0a 097d 0a0a 0976 6f69 6420 7069 6563 }..}...void piec │ │ │ +000620a0: 655f 7069 636b 6572 3a3a 636c 6561 725f e_picker::clear_ │ │ │ +000620b0: 616c 6c5f 7065 6572 7328 290a 097b 0a09 all_peers()..{.. │ │ │ +000620c0: 0966 6f72 2028 6175 746f 2661 6d70 3b20 .for (auto& │ │ │ +000620d0: 6220 3a20 6d5f 626c 6f63 6b5f 696e 666f b : m_block_info │ │ │ +000620e0: 290a 0909 0962 2e70 6565 7220 3d20 6e75 )....b.peer = nu │ │ │ +000620f0: 6c6c 7074 723b 0a09 7d0a 0a09 2f2f 2074 llptr;..}...// t │ │ │ +00062100: 6865 2066 6972 7374 2062 6f6f 6c20 6973 he first bool is │ │ │ +00062110: 2074 7275 6520 6966 2074 6869 7320 6973 true if this is │ │ │ +00062120: 2074 6865 206f 6e6c 7920 7065 6572 2074 the only peer t │ │ │ +00062130: 6861 7420 6861 7320 7265 7175 6573 7465 hat has requeste │ │ │ +00062140: 6420 616e 6420 646f 776e 6c6f 6164 6564 d and downloaded │ │ │ +00062150: 0a09 2f2f 2062 6c6f 636b 7320 6672 6f6d ..// blocks from │ │ │ +00062160: 2074 6869 7320 7069 6563 652e 0a09 2f2f this piece...// │ │ │ +00062170: 2074 6865 2073 6563 6f6e 6420 626f 6f6c the second bool │ │ │ +00062180: 2069 7320 7472 7565 2069 6620 7468 6973 is true if this │ │ │ +00062190: 2069 7320 7468 6520 6f6e 6c79 2061 6374 is the only act │ │ │ +000621a0: 6976 6520 7065 6572 2074 6861 7420 6973 ive peer that is │ │ │ +000621b0: 2072 6571 7565 7374 696e 670a 3c2f 7072 requesting.rel │ │ │ +000621f0: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/pi │ │ │ +00062230: 6563 655f 7069 636b 6572 2e63 7070 3a33 ece_picker.cpp:3 │ │ │ +00062240: 3133 303c 2f61 3e3c 2f74 643e 3c74 643e 130 │ │ │ +00062250: 7368 6f75 6c64 2035 2062 6520 636f 6e66 should 5 be conf │ │ │ +00062260: 6967 7572 6162 6c65 3f3c 2f74 643e 3c2f igurable?

    should 5 │ │ │ +000622c0: 6265 2063 6f6e 6669 6775 7261 626c 653f be configurable? │ │ │ +000622d0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +000622e0: 7069 6563 655f 7069 636b 6572 2e63 7070 piece_picker.cpp │ │ │ +000622f0: 3a33 3133 303c 2f68 343e 3c70 7265 2073 :3130

    ..bool have_
    │ │ │ +00062340: 616c 6c20 3d20 7472 7565 3b0a 0a09 0966  all = true;....f
    │ │ │ +00062350: 6f72 2028 6175 746f 2063 6f6e 7374 2070  or (auto const p
    │ │ │ +00062360: 6965 6365 203a 2065 7874 656e 745f 666f  iece : extent_fo
    │ │ │ +00062370: 7228 7468 6973 5f65 7874 656e 7429 290a  r(this_extent)).
    │ │ │ +00062380: 0909 7b0a 0909 0969 6620 2870 6965 6365  ..{....if (piece
    │ │ │ +00062390: 203d 3d20 7029 2063 6f6e 7469 6e75 653b   == p) continue;
    │ │ │ +000623a0: 0a0a 0909 0969 6620 2821 6d5f 7069 6563  .....if (!m_piec
    │ │ │ +000623b0: 655f 6d61 705b 7069 6563 655d 2e66 6c75  e_map[piece].flu
    │ │ │ +000623c0: 7368 6564 2829 2920 6861 7665 5f61 6c6c  shed()) have_all
    │ │ │ +000623d0: 203d 2066 616c 7365 3b0a 0a09 0909 2f2f   = false;.....//
    │ │ │ +000623e0: 2069 6620 6174 206c 6561 7374 206f 6e65   if at least one
    │ │ │ +000623f0: 2070 6965 6365 2069 6e20 7468 6973 2065   piece in this e
    │ │ │ +00062400: 7874 656e 7420 6861 7320 6120 6469 6666  xtent has a diff
    │ │ │ +00062410: 6572 656e 7420 7072 696f 7269 7479 2074  erent priority t
    │ │ │ +00062420: 6861 6e0a 0909 092f 2f20 7468 6520 6f6e  han....// the on
    │ │ │ +00062430: 6520 7765 206a 7573 7420 7374 6172 7465  e we just starte
    │ │ │ +00062440: 6420 646f 776e 6c6f 6164 696e 672c 2064  d downloading, d
    │ │ │ +00062450: 6f6e 2774 2063 7265 6174 6520 616e 2061  on't create an a
    │ │ │ +00062460: 6666 696e 6974 7920 666f 720a 0909 092f  ffinity for..../
    │ │ │ +00062470: 2f20 6164 6a61 6365 6e74 2070 6965 6365  / adjacent piece
    │ │ │ +00062480: 732e 2054 6869 7320 7072 6f62 6162 6c79  s. This probably
    │ │ │ +00062490: 206d 6561 6e73 2074 6865 2070 6965 6365   means the piece
    │ │ │ +000624a0: 7320 6265 6c6f 6e67 2074 6f20 6469 6666  s belong to diff
    │ │ │ +000624b0: 6572 656e 740a 0909 092f 2f20 6669 6c65  erent....// file
    │ │ │ +000624c0: 732c 206f 7220 7468 6174 2073 6f6d 6520  s, or that some 
    │ │ │ +000624d0: 6f74 6865 7220 6d65 6368 616e 6973 6d20  other mechanism 
    │ │ │ +000624e0: 6465 7465 726d 696e 696e 6720 7468 6520  determining the 
    │ │ │ +000624f0: 7072 696f 7269 7479 2073 686f 756c 640a  priority should.
    │ │ │ +00062500: 0909 092f 2f20 7461 6b65 2070 7265 6365  ...// take prece
    │ │ │ +00062510: 6465 6e63 652e 0a09 0909 6966 2028 7069  dence.....if (pi
    │ │ │ +00062520: 6563 655f 7072 696f 7269 7479 2870 6965  ece_priority(pie
    │ │ │ +00062530: 6365 2920 213d 2074 6869 735f 7072 696f  ce) != this_prio
    │ │ │ +00062540: 2920 7265 7475 726e 3b0a 0909 7d0a 0a09  ) return;...}...
    │ │ │ +00062550: 092f 2f20 6966 2077 6520 616c 7265 6164  .// if we alread
    │ │ │ +00062560: 7920 6861 7665 2061 6c6c 2074 6865 202a  y have all the *
    │ │ │ +00062570: 6f74 6865 722a 2070 6965 6365 7320 696e  other* pieces in
    │ │ │ +00062580: 2074 6869 7320 6578 7465 6e74 2c20 7468   this extent, th
    │ │ │ +00062590: 6572 6527 7320 6e6f 0a09 092f 2f20 6e65  ere's no...// ne
    │ │ │ +000625a0: 6564 2074 6f20 696e 666c 6174 6520 7468  ed to inflate th
    │ │ │ +000625b0: 6569 7220 7072 696f 7269 7469 6573 0a09  eir priorities..
    │ │ │ +000625c0: 0969 6620 2868 6176 655f 616c 6c29 2072  .if (have_all) r
    │ │ │ +000625d0: 6574 7572 6e3b 0a0a 3c64 6976 2073 7479  eturn;..
    ..if (m_re │ │ │ +00062610: 6365 6e74 5f65 7874 656e 7473 2e73 697a cent_extents.siz │ │ │ +00062620: 6528 2920 266c 743b 2035 290a 3c2f 6469 e() < 5)....m_recent_ex │ │ │ +00062640: 7465 6e74 732e 7075 7368 5f62 6163 6b28 tents.push_back( │ │ │ +00062650: 7468 6973 5f65 7874 656e 7429 3b0a 0a09 this_extent);... │ │ │ +00062660: 092f 2f20 6c69 6d69 7420 7468 6520 6e75 .// limit the nu │ │ │ +00062670: 6d62 6572 206f 6620 6578 7465 6e74 2061 mber of extent a │ │ │ +00062680: 6666 696e 6974 6965 7320 6163 7469 7665 ffinities active │ │ │ +00062690: 2061 7420 616e 7920 6769 7665 6e20 7469 at any given ti │ │ │ +000626a0: 6d65 2074 6f20 6c69 6d69 740a 0909 2f2f me to limit...// │ │ │ +000626b0: 2074 6865 2063 6f73 7420 6f66 2063 6865 the cost of che │ │ │ +000626c0: 636b 696e 6720 7468 656d 2e20 416c 736f cking them. Also │ │ │ +000626d0: 2c20 646f 6e27 7420 7265 706c 6163 6520 , don't replace │ │ │ +000626e0: 7468 656d 2c20 636f 6d6d 6974 2074 6f0a them, commit to. │ │ │ +000626f0: 0909 2f2f 2066 696e 6973 6869 6e67 2074 ..// finishing t │ │ │ +00062700: 6865 6d20 6265 666f 7265 2073 7461 7274 hem before start │ │ │ +00062710: 696e 6720 616e 6f74 6865 7220 6578 7465 ing another exte │ │ │ +00062720: 6e74 2e20 5468 6973 2069 7320 616e 616c nt. This is anal │ │ │ +00062730: 6f67 6f75 7320 746f 0a09 092f 2f20 6c69 ogous to...// li │ │ │ +00062740: 6d69 7469 6e67 2074 6865 206e 756d 6265 miting the numbe │ │ │ +00062750: 7220 6f66 2070 6172 7469 616c 2070 6965 r of partial pie │ │ │ +00062760: 6365 732e 0a09 7d0a 0a09 2f2f 206f 7074 ces...}...// opt │ │ │ +00062770: 696f 6e73 206d 6179 2062 6520 3020 6f72 ions may be 0 or │ │ │ +00062780: 2070 6965 6365 5f70 6963 6b65 723a 3a72 piece_picker::r │ │ │ +00062790: 6576 6572 7365 0a09 2f2f 2072 6574 7572 everse..// retur │ │ │ +000627a0: 6e73 2066 616c 7365 2069 6620 7468 6520 ns false if the │ │ │ +000627b0: 626c 6f63 6b20 636f 756c 6420 6e6f 7420 block could not │ │ │ +000627c0: 6265 206d 6172 6b65 6420 6173 2064 6f77 be marked as dow │ │ │ +000627d0: 6e6c 6f61 6469 6e67 0a09 626f 6f6c 2070 nloading..bool p │ │ │ +000627e0: 6965 6365 5f70 6963 6b65 723a 3a6d 6172 iece_picker::mar │ │ │ +000627f0: 6b5f 6173 5f64 6f77 6e6c 6f61 6469 6e67 k_as_downloading │ │ │ +00062800: 2870 6965 6365 5f62 6c6f 636b 2063 6f6e (piece_block con │ │ │ +00062810: 7374 2062 6c6f 636b 0a09 092c 2061 7578 st block..., aux │ │ │ +00062820: 3a3a 746f 7272 656e 745f 7065 6572 2a20 ::torrent_peer* │ │ │ +00062830: 7065 6572 2c20 7069 636b 6572 5f6f 7074 peer, picker_opt │ │ │ +00062840: 696f 6e73 5f74 2063 6f6e 7374 206f 7074 ions_t const opt │ │ │ +00062850: 696f 6e73 290a 097b 0a23 6966 6465 6620 ions)..{.#ifdef │ │ │ +00062860: 544f 5252 454e 545f 5049 434b 4552 5f4c TORRENT_PICKER_L │ │ │ +00062870: 4f47 0a09 0973 7464 3a3a 6365 7272 2026 OG...std::cerr & │ │ │ +00062880: 6c74 3b26 6c74 3b20 225b 2220 266c 743b lt;< "[" < │ │ │ +00062890: 266c 743b 2074 6869 7320 266c 743b 266c < this <&l │ │ │ +000628a0: 743b 2022 5d20 2220 266c 743b 266c 743b t; "] " << │ │ │ +000628b0: 2022 6d61 726b 5f61 735f 646f 776e 6c6f "mark_as_downlo │ │ │ +000628c0: 6164 696e 6728 207b 220a 0909 0926 6c74 ading( {"....< │ │ │ +000628d0: 3b26 6c74 3b20 626c 6f63 6b2e 7069 6563 ;< block.piec │ │ │ +000628e0: 655f 696e 6465 7820 266c 743b 266c 743b e_index << │ │ │ +000628f0: 2022 2c20 2220 266c 743b 266c 743b 2062 ", " << b │ │ │ +00062900: 6c6f 636b 2e62 6c6f 636b 5f69 6e64 6578 lock.block_index │ │ │ +00062910: 2026 6c74 3b26 6c74 3b20 227d 2029 2220 << "} )" │ │ │ +00062920: 266c 743b 266c 743b 2073 7464 3a3a 656e << std::en │ │ │ +00062930: 646c 3b0a 2365 6e64 6966 0a0a 0909 544f dl;.#endif....TO │ │ │ +00062940: 5252 454e 545f 4153 5345 5254 2870 6565 RRENT_ASSERT(pee │ │ │ +00062950: 7220 3d3d 206e 756c 6c70 7472 207c 7c20 r == nullptr || │ │ │ +00062960: 7065 6572 2d26 6774 3b69 6e5f 7573 6529 peer->in_use) │ │ │ +00062970: 3b0a 0909 544f 5252 454e 545f 4153 5345 ;...TORRENT_ASSE │ │ │ +00062980: 5254 2862 6c6f 636b 2e62 6c6f 636b 5f69 RT(block.block_i │ │ │ +00062990: 6e64 6578 2021 3d20 7069 6563 655f 626c ndex != piece_bl │ │ │ +000629a0: 6f63 6b3a 3a69 6e76 616c 6964 2e62 6c6f ock::invalid.blo │ │ │ +000629b0: 636b 5f69 6e64 6578 293b 0a09 0954 4f52 ck_index);...TOR │ │ │ +000629c0: 5245 4e54 5f41 5353 4552 5428 626c 6f63 RENT_ASSERT(bloc │ │ │ +000629d0: 6b2e 7069 6563 655f 696e 6465 7820 213d k.piece_index != │ │ │ +000629e0: 2070 6965 6365 5f62 6c6f 636b 3a3a 696e piece_block::in │ │ │ +000629f0: 7661 6c69 642e 7069 6563 655f 696e 6465 valid.piece_inde │ │ │ +00062a00: 7829 3b0a 0909 544f 5252 454e 545f 4153 x);...TORRENT_AS │ │ │ +00062a10: 5345 5254 2862 6c6f 636b 2e70 6965 6365 SERT(block.piece │ │ │ +00062a20: 5f69 6e64 6578 2026 6c74 3b20 6d5f 7069 _index < m_pi │ │ │ +00062a30: 6563 655f 6d61 702e 656e 645f 696e 6465 ece_map.end_inde │ │ │ +00062a40: 7828 2929 3b0a 0909 544f 5252 454e 545f x());...TORRENT_ │ │ │ +00062a50: 4153 5345 5254 2862 6c6f 636b 2e62 6c6f ASSERT(block.blo │ │ │ +00062a60: 636b 5f69 6e64 6578 2026 6c74 3b20 626c ck_index < bl │ │ │ +00062a70: 6f63 6b73 5f69 6e5f 7069 6563 6528 626c ocks_in_piece(bl │ │ │ +00062a80: 6f63 6b2e 7069 6563 655f 696e 6465 7829 ock.piece_index) │ │ │ +00062a90: 293b 0a09 0954 4f52 5245 4e54 5f41 5353 );...TORRENT_ASS │ │ │ +00062aa0: 4552 5428 216d 5f70 6965 6365 5f6d 6170 ERT(!m_piece_map │ │ │ +00062ab0: 5b62 6c6f 636b 2e70 6965 6365 5f69 6e64 [block.piece_ind │ │ │ +00062ac0: 6578 5d2e 666c 7573 6865 6428 2929 3b0a ex].flushed());. │ │ │ +00062ad0: 0a09 0970 6965 6365 5f70 6f73 2661 6d70 ...piece_pos& │ │ │ +00062ae0: 3b20 7020 3d20 6d5f 7069 6563 655f 6d61 ; p = m_piece_ma │ │ │ +00062af0: 705b 626c 6f63 6b2e 7069 6563 655f 696e p[block.piece_in │ │ │ +00062b00: 6465 785d 3b0a 0909 6966 2028 702e 646f dex];...if (p.do │ │ │ +00062b10: 776e 6c6f 6164 5f71 7565 7565 2829 203d wnload_queue() = │ │ │ +00062b20: 3d20 7069 6563 655f 706f 733a 3a70 6965 = piece_pos::pie │ │ │ +00062b30: 6365 5f6f 7065 6e29 0a09 097b 0a23 6966 ce_open)...{.#if │ │ │ +00062b40: 6465 6620 544f 5252 454e 545f 4558 5045 def TORRENT_EXPE │ │ │ +00062b50: 4e53 4956 455f 494e 5641 5249 414e 545f NSIVE_INVARIANT_ │ │ │ +00062b60: 4348 4543 4b53 0a09 0909 494e 5641 5249 CHECKS....INVARI │ │ │ +00062b70: 414e 545f 4348 4543 4b3b 0a3c 2f70 7265 ANT_CHECK;.
    rele │ │ │ +00062bb0: 7661 6e63 6526 6e62 7370 3b30 3c2f 7464 vance 0../src/ip_ │ │ │ +00062bf0: 6e6f 7469 6669 6572 2e63 7070 3a31 383c notifier.cpp:18< │ │ │ +00062c00: 2f61 3e3c 2f74 643e 3c74 643e 7369 6d75 /a>simu │ │ │ +00062c10: 6c61 746f 7220 7375 7070 6f72 743c 2f74 lator support

    simul │ │ │ +00062c70: 6174 6f72 2073 7570 706f 7274 3c2f 6832 ator support

    ../src/ip_n │ │ │ +00062c90: 6f74 6966 6965 722e 6370 703a 3138 3c2f otifier.cpp:18
    ..m
    │ │ │ +00062ce0: 5f68 6176 655f 7061 645f 6279 7465 7320  _have_pad_bytes 
    │ │ │ +00062cf0: 2d3d 2070 6164 5f62 7974 6573 3b0a 097d  -= pad_bytes;..}
    │ │ │ +00062d00: 0a7d 0a2f 2a0a 0a43 6f70 7972 6967 6874  .}./*..Copyright
    │ │ │ +00062d10: 2028 6329 2032 3031 362d 3230 3137 2c20   (c) 2016-2017, 
    │ │ │ +00062d20: 3230 3231 2c20 416c 6465 6e20 546f 7272  2021, Alden Torr
    │ │ │ +00062d30: 6573 0a43 6f70 7972 6967 6874 2028 6329  es.Copyright (c)
    │ │ │ +00062d40: 2032 3031 362c 2032 3032 302c 2053 7465   2016, 2020, Ste
    │ │ │ +00062d50: 7665 6e20 5369 6c6f 7469 0a43 6f70 7972  ven Siloti.Copyr
    │ │ │ +00062d60: 6967 6874 2028 6329 2032 3031 372d 3230  ight (c) 2017-20
    │ │ │ +00062d70: 3232 2c20 4172 7669 6420 4e6f 7262 6572  22, Arvid Norber
    │ │ │ +00062d80: 670a 436f 7079 7269 6768 7420 2863 2920  g.Copyright (c) 
    │ │ │ +00062d90: 3230 3137 2c20 5469 6d20 4e69 6564 6572  2017, Tim Nieder
    │ │ │ +00062da0: 6861 7573 656e 0a43 6f70 7972 6967 6874  hausen.Copyright
    │ │ │ +00062db0: 2028 6329 2032 3032 302c 2054 6967 6572   (c) 2020, Tiger
    │ │ │ +00062dc0: 2057 616e 670a 416c 6c20 7269 6768 7473   Wang.All rights
    │ │ │ +00062dd0: 2072 6573 6572 7665 642e 0a0a 596f 7520   reserved...You 
    │ │ │ +00062de0: 6d61 7920 7573 652c 2064 6973 7472 6962  may use, distrib
    │ │ │ +00062df0: 7574 6520 616e 6420 6d6f 6469 6679 2074  ute and modify t
    │ │ │ +00062e00: 6869 7320 636f 6465 2075 6e64 6572 2074  his code under t
    │ │ │ +00062e10: 6865 2074 6572 6d73 206f 6620 7468 6520  he terms of the 
    │ │ │ +00062e20: 4253 4420 6c69 6365 6e73 652c 0a73 6565  BSD license,.see
    │ │ │ +00062e30: 204c 4943 454e 5345 2066 696c 652e 0a2a   LICENSE file..*
    │ │ │ +00062e40: 2f0a 0a23 696e 636c 7564 6520 226c 6962  /..#include "lib
    │ │ │ +00062e50: 746f 7272 656e 742f 6175 785f 2f69 705f  torrent/aux_/ip_
    │ │ │ +00062e60: 6e6f 7469 6669 6572 2e68 7070 220a 2369  notifier.hpp".#i
    │ │ │ +00062e70: 6e63 6c75 6465 2022 6c69 6274 6f72 7265  nclude "libtorre
    │ │ │ +00062e80: 6e74 2f61 7373 6572 742e 6870 7022 0a0a  nt/assert.hpp"..
    │ │ │ +00062e90: 2369 6620 6465 6669 6e65 6420 544f 5252  #if defined TORR
    │ │ │ +00062ea0: 454e 545f 4255 494c 445f 5349 4d55 4c41  ENT_BUILD_SIMULA
    │ │ │ +00062eb0: 544f 520a 3c64 6976 2073 7479 6c65 3d22  TOR.
    #elif TORRENT_ │ │ │ +00062ef0: 5553 455f 4e45 544c 494e 4b0a 3c2f 6469 USE_NETLINK.#include "libt │ │ │ +00062f10: 6f72 7265 6e74 2f61 7578 5f2f 6e65 746c orrent/aux_/netl │ │ │ +00062f20: 696e 6b2e 6870 7022 0a23 696e 636c 7564 ink.hpp".#includ │ │ │ +00062f30: 6520 226c 6962 746f 7272 656e 742f 736f e "libtorrent/so │ │ │ +00062f40: 636b 6574 2e68 7070 220a 2369 6e63 6c75 cket.hpp".#inclu │ │ │ +00062f50: 6465 2026 6c74 3b61 7272 6179 2667 743b de <array> │ │ │ +00062f60: 0a23 696e 636c 7564 6520 266c 743b 756e .#include <un │ │ │ +00062f70: 6f72 6465 7265 645f 6d61 7026 6774 3b0a ordered_map>. │ │ │ +00062f80: 2365 6c69 6620 544f 5252 454e 545f 5553 #elif TORRENT_US │ │ │ +00062f90: 455f 5359 5354 454d 434f 4e46 4947 5552 E_SYSTEMCONFIGUR │ │ │ +00062fa0: 4154 494f 4e20 7c7c 2054 4f52 5245 4e54 ATION || TORRENT │ │ │ +00062fb0: 5f55 5345 5f53 435f 4e45 5457 4f52 4b5f _USE_SC_NETWORK_ │ │ │ +00062fc0: 5245 4143 4841 4249 4c49 5459 0a23 696e REACHABILITY.#in │ │ │ +00062fd0: 636c 7564 6520 266c 743b 5379 7374 656d clude <System │ │ │ +00062fe0: 436f 6e66 6967 7572 6174 696f 6e2f 5379 Configuration/Sy │ │ │ +00062ff0: 7374 656d 436f 6e66 6967 7572 6174 696f stemConfiguratio │ │ │ +00063000: 6e2e 6826 6774 3b0a 2365 6c69 6620 6465 n.h>.#elif de │ │ │ +00063010: 6669 6e65 6420 544f 5252 454e 545f 5749 fined TORRENT_WI │ │ │ +00063020: 4e44 4f57 530a 2369 6e63 6c75 6465 2022 NDOWS.#include " │ │ │ +00063030: 6c69 6274 6f72 7265 6e74 2f61 7578 5f2f libtorrent/aux_/ │ │ │ +00063040: 7468 726f 772e 6870 7022 0a23 696e 636c throw.hpp".#incl │ │ │ +00063050: 7564 6520 226c 6962 746f 7272 656e 742f ude "libtorrent/ │ │ │ +00063060: 6175 785f 2f64 6973 6162 6c65 5f77 6172 aux_/disable_war │ │ │ +00063070: 6e69 6e67 735f 7075 7368 2e68 7070 220a nings_push.hpp". │ │ │ +00063080: 2369 6e63 6c75 6465 2026 6c74 3b69 7068 #include <iph │ │ │ +00063090: 6c70 6170 692e 6826 6774 3b0a 2369 6664 lpapi.h>.#ifd │ │ │ +000630a0: 6566 2054 4f52 5245 4e54 5f57 494e 5254 ef TORRENT_WINRT │ │ │ +000630b0: 0a23 696e 636c 7564 6520 266c 743b 6e65 .#include <ne │ │ │ +000630c0: 7469 6f61 7069 2e68 2667 743b 0a23 656e tioapi.h>.#en │ │ │ +000630d0: 6469 660a 2369 6e63 6c75 6465 2026 6c74 dif.#include < │ │ │ +000630e0: 3b6d 7574 6578 2667 743b 0a23 696e 636c ;mutex>.#incl │ │ │ +000630f0: 7564 6520 226c 6962 746f 7272 656e 742f ude "libtorrent/ │ │ │ +00063100: 6175 785f 2f64 6973 6162 6c65 5f77 6172 aux_/disable_war │ │ │ +00063110: 6e69 6e67 735f 706f 702e 6870 7022 0a23 nings_pop.hpp".# │ │ │ +00063120: 656e 6469 660a 0a23 696e 636c 7564 6520 endif..#include │ │ │ +00063130: 226c 6962 746f 7272 656e 742f 6175 785f "libtorrent/aux_ │ │ │ +00063140: 2f6e 6574 6c69 6e6b 5f75 7469 6c73 2e68 /netlink_utils.h │ │ │ +00063150: 7070 220a 0a6e 616d 6573 7061 6365 206c pp"..namespace l │ │ │ +00063160: 6962 746f 7272 656e 743a 3a61 7578 207b ibtorrent::aux { │ │ │ +00063170: 0a0a 6e61 6d65 7370 6163 6520 7b0a 0a23 ..namespace {..# │ │ │ +00063180: 6966 2028 544f 5252 454e 545f 5553 455f if (TORRENT_USE_ │ │ │ +00063190: 5359 5354 454d 434f 4e46 4947 5552 4154 SYSTEMCONFIGURAT │ │ │ +000631a0: 494f 4e20 7c7c 2054 4f52 5245 4e54 5f55 ION || TORRENT_U │ │ │ +000631b0: 5345 5f53 435f 4e45 5457 4f52 4b5f 5245 SE_SC_NETWORK_RE │ │ │ +000631c0: 4143 4841 4249 4c49 5459 2920 2661 6d70 ACHABILITY) & │ │ │ +000631d0: 3b26 616d 703b 205c 0a09 2164 6566 696e ;& \..!defin │ │ │ +000631e0: 6564 2054 4f52 5245 4e54 5f42 5549 4c44 ed TORRENT_BUILD │ │ │ +000631f0: 5f53 494d 554c 4154 4f52 0a0a 2f2f 2063 _SIMULATOR..// c │ │ │ +00063200: 6f6d 6d6f 6e20 7574 696c 6974 6965 7320 ommon utilities │ │ │ +00063210: 666f 7220 4d61 6320 616e 6420 694f 530a for Mac and iOS. │ │ │ +00063220: 7465 6d70 6c61 7465 2026 6c74 3b74 7970 template <typ │ │ │ +00063230: 656e 616d 6520 5426 6774 3b20 766f 6964 ename T> void │ │ │ +00063240: 2043 4652 6566 5265 7461 696e 2854 2068 CFRefRetain(T h │ │ │ +00063250: 2920 7b20 4346 5265 7461 696e 2868 293b ) { CFRetain(h); │ │ │ +00063260: 207d 0a74 656d 706c 6174 6520 266c 743b }.template < │ │ │ +00063270: 7479 7065 6e61 6d65 2054 2667 743b 2076 typename T> v │ │ │ +00063280: 6f69 6420 4346 5265 6652 656c 6561 7365 oid CFRefRelease │ │ │ +00063290: 2854 2068 2920 7b20 4346 5265 6c65 6173 (T h) { CFReleas │ │ │ +000632a0: 6528 6829 3b20 7d0a 0a3c 2f70 7265 3e3c e(h); }..
    < │ │ │ +000632b0: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +000632e0: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +000632f0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>
    ../src/pe_cr │ │ │ +00063320: 7970 746f 2e63 7070 3a31 3332 3c2f 613e ypto.cpp:132 │ │ │ +00063330: 3c2f 7464 3e3c 7464 3e69 7420 776f 756c it woul │ │ │ +00063340: 6420 6265 206e 6963 6520 746f 2062 6520 d be nice to be │ │ │ +00063350: 6162 6c65 2074 6f20 6578 706f 7274 2074 able to export t │ │ │ +00063360: 6f20 6120 6669 7865 6420 7769 6474 6820 o a fixed width │ │ │ +00063370: 6669 656c 642c 2073 6f20 7765 2077 6f75 field, so we wou │ │ │ +00063380: 6c64 6e27 7420 6861 7665 2074 6f20 7368 ldn't have to sh │ │ │ +00063390: 6966 7420 6974 206c 6174 6572 3c2f 7464 ift it later

    it wou │ │ │ +000633f0: 6c64 2062 6520 6e69 6365 2074 6f20 6265 ld be nice to be │ │ │ +00063400: 2061 626c 6520 746f 2065 7870 6f72 7420 able to export │ │ │ +00063410: 746f 2061 2066 6978 6564 2077 6964 7468 to a fixed width │ │ │ +00063420: 2066 6965 6c64 2c20 736f 0a77 6520 776f field, so.we wo │ │ │ +00063430: 756c 646e 2774 2068 6176 6520 746f 2073 uldn't have to s │ │ │ +00063440: 6869 6674 2069 7420 6c61 7465 723c 2f68 hift it later

    ../src/pe_ │ │ │ +00063460: 6372 7970 746f 2e63 7070 3a31 3332 3c2f crypto.cpp:132
    ...
    │ │ │ +000634b0: 0942 4e5f 4d4f 4e54 5f43 5458 5f6e 6577  .BN_MONT_CTX_new
    │ │ │ +000634c0: 2829 2c20 2661 6d70 3b42 4e5f 4d4f 4e54  (), &BN_MONT
    │ │ │ +000634d0: 5f43 5458 5f66 7265 6529 3b0a 0909 0969  _CTX_free);....i
    │ │ │ +000634e0: 6620 2821 7265 7420 7c7c 2021 424e 5f4d  f (!ret || !BN_M
    │ │ │ +000634f0: 4f4e 545f 4354 585f 7365 7428 7265 742e  ONT_CTX_set(ret.
    │ │ │ +00063500: 6765 7428 292c 2064 685f 7072 696d 6528  get(), dh_prime(
    │ │ │ +00063510: 292e 6765 7428 292c 2063 7478 2829 2929  ).get(), ctx()))
    │ │ │ +00063520: 0a09 0909 0961 7578 3a3a 7468 726f 775f  .....aux::throw_
    │ │ │ +00063530: 6578 266c 743b 7379 7374 656d 5f65 7272  ex<system_err
    │ │ │ +00063540: 6f72 2667 743b 2865 7272 6f72 733a 3a6e  or>(errors::n
    │ │ │ +00063550: 6f5f 6d65 6d6f 7279 293b 0a09 0909 7265  o_memory);....re
    │ │ │ +00063560: 7475 726e 2072 6574 3b0a 0909 7d3b 0a23  turn ret;...};.#
    │ │ │ +00063570: 6966 6465 6620 424f 4f53 545f 4e4f 5f43  ifdef BOOST_NO_C
    │ │ │ +00063580: 5858 3131 5f54 4852 4541 445f 4c4f 4341  XX11_THREAD_LOCA
    │ │ │ +00063590: 4c0a 0909 7374 6174 6963 2073 7464 3a3a  L...static std::
    │ │ │ +000635a0: 756e 6971 7565 5f70 7472 266c 743b 3a3a  unique_ptr<::
    │ │ │ +000635b0: 424e 5f4d 4f4e 545f 4354 582c 2076 6f69  BN_MONT_CTX, voi
    │ │ │ +000635c0: 6420 282a 2928 3a3a 424e 5f4d 4f4e 545f  d (*)(::BN_MONT_
    │ │ │ +000635d0: 4354 582a 2926 6774 3b20 7368 6172 6564  CTX*)> shared
    │ │ │ +000635e0: 5f6d 6f6e 7420 3d20 6d61 6b65 5f6d 6f6e  _mont = make_mon
    │ │ │ +000635f0: 7428 293b 0a23 656c 7365 0a09 0974 6872  t();.#else...thr
    │ │ │ +00063600: 6561 645f 6c6f 6361 6c20 7374 6174 6963  ead_local static
    │ │ │ +00063610: 2073 7464 3a3a 756e 6971 7565 5f70 7472   std::unique_ptr
    │ │ │ +00063620: 266c 743b 3a3a 424e 5f4d 4f4e 545f 4354  <::BN_MONT_CT
    │ │ │ +00063630: 582c 2076 6f69 6420 282a 2928 3a3a 424e  X, void (*)(::BN
    │ │ │ +00063640: 5f4d 4f4e 545f 4354 582a 2926 6774 3b20  _MONT_CTX*)> 
    │ │ │ +00063650: 7368 6172 6564 5f6d 6f6e 7420 3d0a 0909  shared_mont =...
    │ │ │ +00063660: 096d 616b 655f 6d6f 6e74 2829 3b0a 2365  .make_mont();.#e
    │ │ │ +00063670: 6e64 6966 0a09 0972 6574 7572 6e20 7368  ndif...return sh
    │ │ │ +00063680: 6172 6564 5f6d 6f6e 742e 6765 7428 293b  ared_mont.get();
    │ │ │ +00063690: 0a09 7d0a 0a09 7374 643a 3a61 7272 6179  ..}...std::array
    │ │ │ +000636a0: 266c 743b 6368 6172 2c20 3936 2667 743b  <char, 96>
    │ │ │ +000636b0: 2064 685f 6b65 795f 6578 6368 616e 6765   dh_key_exchange
    │ │ │ +000636c0: 3a3a 6578 706f 7274 5f6b 6579 286b 6579  ::export_key(key
    │ │ │ +000636d0: 5f74 2063 6f6e 7374 2661 6d70 3b20 6b29  _t const& k)
    │ │ │ +000636e0: 0a09 7b0a 0909 7374 643a 3a61 7272 6179  ..{...std::array
    │ │ │ +000636f0: 266c 743b 6368 6172 2c20 3936 2667 743b  <char, 96>
    │ │ │ +00063700: 2072 6574 3b0a 0909 6175 746f 2a20 6265   ret;...auto* be
    │ │ │ +00063710: 6769 6e20 3d20 7265 696e 7465 7270 7265  gin = reinterpre
    │ │ │ +00063720: 745f 6361 7374 266c 743b 756e 7369 676e  t_cast<unsign
    │ │ │ +00063730: 6564 2063 6861 722a 2667 743b 2872 6574  ed char*>(ret
    │ │ │ +00063740: 2e64 6174 6128 2929 3b0a 0909 696e 7420  .data());...int 
    │ │ │ +00063750: 636f 6e73 7420 6c65 6e20 3d20 424e 5f62  const len = BN_b
    │ │ │ +00063760: 6e32 6269 6e28 6b2e 6765 7428 292c 2062  n2bin(k.get(), b
    │ │ │ +00063770: 6567 696e 293b 0a0a 3c64 6976 2073 7479  egin);..
    ..if (len │ │ │ +000637b0: 266c 743b 2039 3629 0a3c 2f64 6976 3e09 < 96).
    . │ │ │ +000637c0: 097b 0a09 0909 7374 643a 3a6d 656d 6d6f .{....std::memmo │ │ │ +000637d0: 7665 2862 6567 696e 202b 2039 3620 2d20 ve(begin + 96 - │ │ │ +000637e0: 6c65 6e2c 2062 6567 696e 2c20 6175 783a len, begin, aux: │ │ │ +000637f0: 3a6e 756d 6572 6963 5f63 6173 7426 6c74 :numeric_cast< │ │ │ +00063800: 3b73 7464 3a3a 7369 7a65 5f74 2667 743b ;std::size_t> │ │ │ +00063810: 286c 656e 2929 3b0a 0909 0973 7464 3a3a (len));....std:: │ │ │ +00063820: 6d65 6d73 6574 2862 6567 696e 2c20 302c memset(begin, 0, │ │ │ +00063830: 2061 7578 3a3a 6e75 6d65 7269 635f 6361 aux::numeric_ca │ │ │ +00063840: 7374 266c 743b 7374 643a 3a73 697a 655f st<std::size_ │ │ │ +00063850: 7426 6774 3b28 3936 202d 206c 656e 2929 t>(96 - len)) │ │ │ +00063860: 3b0a 0909 7d0a 0909 7265 7475 726e 2072 ;...}...return r │ │ │ +00063870: 6574 3b0a 097d 0a0a 092f 2f20 5365 7420 et;..}...// Set │ │ │ +00063880: 7468 6520 7072 696d 6520 5020 616e 6420 the prime P and │ │ │ +00063890: 7468 6520 6765 6e65 7261 746f 722c 2067 the generator, g │ │ │ +000638a0: 656e 6572 6174 6520 6c6f 6361 6c20 7075 enerate local pu │ │ │ +000638b0: 626c 6963 206b 6579 0a09 6468 5f6b 6579 blic key..dh_key │ │ │ +000638c0: 5f65 7863 6861 6e67 653a 3a64 685f 6b65 _exchange::dh_ke │ │ │ +000638d0: 795f 6578 6368 616e 6765 2829 0a09 7b0a y_exchange()..{. │ │ │ +000638e0: 0909 6175 783a 3a61 7272 6179 266c 743b ..aux::array< │ │ │ +000638f0: 7374 643a 3a75 696e 7438 5f74 2c20 3230 std::uint8_t, 20 │ │ │ +00063900: 2667 743b 2072 616e 646f 6d5f 6b65 793b > random_key; │ │ │ +00063910: 0a09 0961 7578 3a3a 7261 6e64 6f6d 5f62 ...aux::random_b │ │ │ +00063920: 7974 6573 287b 7265 696e 7465 7270 7265 ytes({reinterpre │ │ │ +00063930: 745f 6361 7374 266c 743b 6368 6172 2a26 t_cast<char*& │ │ │ +00063940: 6774 3b28 7261 6e64 6f6d 5f6b 6579 2e64 gt;(random_key.d │ │ │ +00063950: 6174 6128 2929 2c0a 0909 0973 7461 7469 ata()),....stati │ │ │ +00063960: 635f 6361 7374 266c 743b 7374 643a 3a70 c_cast<std::p │ │ │ +00063970: 7472 6469 6666 5f74 2667 743b 2872 616e trdiff_t>(ran │ │ │ +00063980: 646f 6d5f 6b65 792e 7369 7a65 2829 297d dom_key.size())} │ │ │ +00063990: 293b 0a0a 0909 2f2f 2063 7265 6174 6520 );....// create │ │ │ +000639a0: 6c6f 6361 6c20 6b65 7920 2872 616e 646f local key (rando │ │ │ +000639b0: 6d29 0a09 0969 6620 2821 424e 5f62 696e m)...if (!BN_bin │ │ │ +000639c0: 3262 6e28 7261 6e64 6f6d 5f6b 6579 2e64 2bn(random_key.d │ │ │ +000639d0: 6174 6128 292c 2069 6e74 2872 616e 646f ata(), int(rando │ │ │ +000639e0: 6d5f 6b65 792e 7369 7a65 2829 292c 206d m_key.size()), m │ │ │ +000639f0: 5f64 685f 6c6f 6361 6c5f 7365 6372 6574 _dh_local_secret │ │ │ +00063a00: 2e67 6574 2829 2929 0a09 0909 6175 783a .get()))....aux: │ │ │ +00063a10: 3a74 6872 6f77 5f65 7826 6c74 3b73 7973 :throw_ex<sys │ │ │ +00063a20: 7465 6d5f 6572 726f 7226 6774 3b28 6572 tem_error>(er │ │ │ +00063a30: 726f 7273 3a3a 6e6f 5f6d 656d 6f72 7929 rors::no_memory) │ │ │ +00063a40: 3b0a 0a09 092f 2f20 6b65 7920 3d20 2832 ;....// key = (2 │ │ │ +00063a50: 205e 2073 6563 7265 7429 2025 2070 7269 ^ secret) % pri │ │ │ +00063a60: 6d65 0a09 096b 6579 5f74 206c 6f63 616c me...key_t local │ │ │ +00063a70: 5f6b 6579 3b0a 0a09 097b 0a23 6966 6465 _key;....{.#ifde │ │ │ +00063a80: 6620 424f 4f53 545f 4e4f 5f43 5858 3131 f BOOST_NO_CXX11 │ │ │ +00063a90: 5f54 4852 4541 445f 4c4f 4341 4c0a 0909 _THREAD_LOCAL... │ │ │ +00063aa0: 0973 7464 3a3a 6c6f 636b 5f67 7561 7264 .std::lock_guard │ │ │ +00063ab0: 266c 743b 7374 643a 3a6d 7574 6578 2667 <std::mutex&g │ │ │ +00063ac0: 743b 206c 2867 5f62 6e5f 6374 785f 6d75 t; l(g_bn_ctx_mu │ │ │ +00063ad0: 7465 7829 3b0a 2365 6e64 6966 0a09 0909 tex);.#endif.... │ │ │ +00063ae0: 6966 2028 2142 4e5f 6d6f 645f 6578 705f if (!BN_mod_exp_ │ │ │ +00063af0: 6d6f 6e74 286c 6f63 616c 5f6b 6579 2e67 mont(local_key.g │ │ │ +00063b00: 6574 2829 2c0a 0909 0909 0974 776f 2829 et(),......two() │ │ │ +00063b10: 2e67 6574 2829 2c0a 0909 0909 096d 5f64 .get(),......m_d │ │ │ +00063b20: 685f 6c6f 6361 6c5f 7365 6372 6574 2e67 h_local_secret.g │ │ │ +00063b30: 6574 2829 2c0a 0909 0909 0964 685f 7072 et(),......dh_pr │ │ │ +00063b40: 696d 6528 292e 6765 7428 292c 0a09 0909 ime().get(),.... │ │ │ +00063b50: 0909 6374 7828 292c 0a3c 2f70 7265 3e3c ..ctx(),.
    < │ │ │ +00063b60: 2f74 643e 3c2f 7472 3e3c 7472 2073 7479 /td>releva │ │ │ +00063b90: 6e63 6526 6e62 7370 3b30 3c2f 7464 3e3c nce 0< │ │ │ +00063ba0: 7464 3e3c 6120 6872 6566 3d22 6a61 7661 td>../src/pe_cr │ │ │ +00063bd0: 7970 746f 2e63 7070 3a32 3132 3c2f 613e ypto.cpp:212 │ │ │ +00063be0: 3c2f 7464 3e3c 7464 3e69 7420 776f 756c it woul │ │ │ +00063bf0: 6420 6265 206e 6963 6520 746f 2067 6574 d be nice to get │ │ │ +00063c00: 2074 6865 206c 6974 6572 616c 2077 6f72 the literal wor │ │ │ +00063c10: 6b69 6e67 3c2f 7464 3e3c 2f74 723e 3c74 kingit would be ni │ │ │ +00063c70: 6365 2074 6f20 6765 7420 7468 6520 6c69 ce to get the li │ │ │ +00063c80: 7465 7261 6c20 776f 726b 696e 673c 2f68 teral working

    ../src/pe_ │ │ │ +00063ca0: 6372 7970 746f 2e63 7070 3a32 3132 3c2f crypto.cpp:212
    ...
    │ │ │ +00063cf0: 6966 2028 2142 4e5f 6d6f 645f 6578 705f  if (!BN_mod_exp_
    │ │ │ +00063d00: 6d6f 6e74 2873 6563 7265 742e 6765 7428  mont(secret.get(
    │ │ │ +00063d10: 292c 0a09 0909 0909 6b65 792e 6765 7428  ),......key.get(
    │ │ │ +00063d20: 292c 0a09 0909 0909 6d5f 6468 5f6c 6f63  ),......m_dh_loc
    │ │ │ +00063d30: 616c 5f73 6563 7265 742e 6765 7428 292c  al_secret.get(),
    │ │ │ +00063d40: 0a09 0909 0909 6468 5f70 7269 6d65 2829  ......dh_prime()
    │ │ │ +00063d50: 2e67 6574 2829 2c0a 0909 0909 0963 7478  .get(),......ctx
    │ │ │ +00063d60: 2829 2c0a 0909 0909 096d 6f6e 7428 2929  (),......mont())
    │ │ │ +00063d70: 290a 0909 0909 6175 783a 3a74 6872 6f77  ).....aux::throw
    │ │ │ +00063d80: 5f65 7826 6c74 3b73 7973 7465 6d5f 6572  _ex<system_er
    │ │ │ +00063d90: 726f 7226 6774 3b28 6572 726f 7273 3a3a  ror>(errors::
    │ │ │ +00063da0: 6e6f 5f6d 656d 6f72 7929 3b0a 0909 7d0a  no_memory);...}.
    │ │ │ +00063db0: 0909 6d5f 6468 5f73 6861 7265 645f 7365  ..m_dh_shared_se
    │ │ │ +00063dc0: 6372 6574 203d 2065 7870 6f72 745f 6b65  cret = export_ke
    │ │ │ +00063dd0: 7928 7365 6372 6574 293b 0a0a 0909 7374  y(secret);....st
    │ │ │ +00063de0: 6174 6963 2063 6861 7220 636f 6e73 7420  atic char const 
    │ │ │ +00063df0: 7265 7133 5b34 5d20 3d20 7b27 7227 2c20  req3[4] = {'r', 
    │ │ │ +00063e00: 2765 272c 2027 7127 2c20 2733 277d 3b0a  'e', 'q', '3'};.
    │ │ │ +00063e10: 0909 2f2f 2063 616c 6375 6c61 7465 2074  ..// calculate t
    │ │ │ +00063e20: 6865 2078 6f72 206d 6173 6b20 666f 7220  he xor mask for 
    │ │ │ +00063e30: 7468 6520 6f62 6675 7363 6174 6564 2068  the obfuscated h
    │ │ │ +00063e40: 6173 680a 0909 6d5f 786f 725f 6d61 736b  ash...m_xor_mask
    │ │ │ +00063e50: 203d 2068 6173 6865 7228 7265 7133 292e   = hasher(req3).
    │ │ │ +00063e60: 7570 6461 7465 286d 5f64 685f 7368 6172  update(m_dh_shar
    │ │ │ +00063e70: 6564 5f73 6563 7265 7429 2e66 696e 616c  ed_secret).final
    │ │ │ +00063e80: 2829 3b0a 0909 7265 7475 726e 2074 7275  ();...return tru
    │ │ │ +00063e90: 653b 0a09 7d0a 0a23 656c 7365 202f 2f20  e;..}..#else // 
    │ │ │ +00063ea0: 544f 5252 454e 545f 5553 455f 4c49 4243  TORRENT_USE_LIBC
    │ │ │ +00063eb0: 5259 5054 4f0a 0a09 6468 5f6b 6579 5f65  RYPTO...dh_key_e
    │ │ │ +00063ec0: 7863 6861 6e67 653a 3a6b 6579 5f74 2063  xchange::key_t c
    │ │ │ +00063ed0: 6f6e 7374 2661 6d70 3b20 6468 5f6b 6579  onst& dh_key
    │ │ │ +00063ee0: 5f65 7863 6861 6e67 653a 3a64 685f 7072  _exchange::dh_pr
    │ │ │ +00063ef0: 696d 6528 290a 097b 0a3c 6469 7620 7374  ime()..{.
    ..static │ │ │ +00063f30: 6b65 795f 7420 636f 6e73 7420 7072 696d key_t const prim │ │ │ +00063f40: 6528 0a3c 2f64 6976 3e09 0909 2230 7846 e(.
    ..."0xF │ │ │ +00063f50: 4646 4646 4646 4646 4646 4646 4646 4643 FFFFFFFFFFFFFFFC │ │ │ +00063f60: 3930 4644 4141 3232 3136 3843 3233 3443 90FDAA22168C234C │ │ │ +00063f70: 3443 3636 3238 4238 3044 4331 4344 3132 4C6628B80DC1CD12 │ │ │ +00063f80: 3930 3234 4530 3838 4136 3743 4337 3430 9024E088A67CC740 │ │ │ +00063f90: 3230 4242 4541 3633 4231 3339 4232 3235 20BBEA63B139B225 │ │ │ +00063fa0: 3134 4122 0a09 0909 2230 3837 3938 4533 14A"...."08798E3 │ │ │ +00063fb0: 3430 3444 4445 4639 3531 3942 3343 4433 404DDEF9519B3CD3 │ │ │ +00063fc0: 4134 3331 4233 3032 4230 4136 4446 3235 A431B302B0A6DF25 │ │ │ +00063fd0: 4631 3433 3734 4645 3133 3536 4436 4435 F14374FE1356D6D5 │ │ │ +00063fe0: 3143 3234 3545 3438 3542 3537 3636 3235 1C245E485B576625 │ │ │ +00063ff0: 4537 4543 3646 3434 4334 3245 3941 3622 E7EC6F44C42E9A6" │ │ │ +00064000: 0a09 0909 2233 4133 3632 3130 3030 3030 ...."3A362100000 │ │ │ +00064010: 3030 3030 3030 3930 3536 3322 293b 0a09 00000090563");.. │ │ │ +00064020: 0972 6574 7572 6e20 7072 696d 653b 0a09 .return prime;.. │ │ │ +00064030: 7d0a 0a09 7374 643a 3a61 7272 6179 266c }...std::array&l │ │ │ +00064040: 743b 6368 6172 2c20 3936 2667 743b 2064 t;char, 96> d │ │ │ +00064050: 685f 6b65 795f 6578 6368 616e 6765 3a3a h_key_exchange:: │ │ │ +00064060: 6578 706f 7274 5f6b 6579 286b 6579 5f74 export_key(key_t │ │ │ +00064070: 2063 6f6e 7374 2661 6d70 3b20 6b29 0a09 const& k).. │ │ │ +00064080: 7b0a 0909 7374 643a 3a61 7272 6179 266c {...std::array&l │ │ │ +00064090: 743b 6368 6172 2c20 3936 2667 743b 2072 t;char, 96> r │ │ │ +000640a0: 6574 3b0a 0909 6175 746f 2a20 6265 6769 et;...auto* begi │ │ │ +000640b0: 6e20 3d20 7265 696e 7465 7270 7265 745f n = reinterpret_ │ │ │ +000640c0: 6361 7374 266c 743b 7374 643a 3a75 696e cast<std::uin │ │ │ +000640d0: 7438 5f74 2a26 6774 3b28 7265 742e 6461 t8_t*>(ret.da │ │ │ +000640e0: 7461 2829 293b 0a09 0973 7464 3a3a 7569 ta());...std::ui │ │ │ +000640f0: 6e74 385f 742a 2065 6e64 203d 206d 703a nt8_t* end = mp: │ │ │ +00064100: 3a65 7870 6f72 745f 6269 7473 286b 2c20 :export_bits(k, │ │ │ +00064110: 6265 6769 6e2c 2038 293b 0a0a 3c2f 7072 begin, 8);..rel │ │ │ +00064150: 6576 616e 6365 266e 6273 703b 303c 2f74 evance 0../src/pe │ │ │ +00064190: 5f63 7279 7074 6f2e 6370 703a 3232 363c _crypto.cpp:226< │ │ │ +000641a0: 2f61 3e3c 2f74 643e 3c74 643e 6974 2077 /a>it w │ │ │ +000641b0: 6f75 6c64 2062 6520 6e69 6365 2074 6f20 ould be nice to │ │ │ +000641c0: 6265 2061 626c 6520 746f 2065 7870 6f72 be able to expor │ │ │ +000641d0: 7420 746f 2061 2066 6978 6564 2077 6964 t to a fixed wid │ │ │ +000641e0: 7468 2066 6965 6c64 2c20 736f 2077 6520 th field, so we │ │ │ +000641f0: 776f 756c 646e 2774 2068 6176 6520 746f wouldn't have to │ │ │ +00064200: 2073 6869 6674 2069 7420 6c61 7465 723c shift it later< │ │ │ +00064210: 2f74 643e 3c2f 7472 3e3c 7472 2069 643d /td>

    it │ │ │ +00064260: 776f 756c 6420 6265 206e 6963 6520 746f would be nice to │ │ │ +00064270: 2062 6520 6162 6c65 2074 6f20 6578 706f be able to expo │ │ │ +00064280: 7274 2074 6f20 6120 6669 7865 6420 7769 rt to a fixed wi │ │ │ +00064290: 6474 6820 6669 656c 642c 2073 6f0a 7765 dth field, so.we │ │ │ +000642a0: 2077 6f75 6c64 6e27 7420 6861 7665 2074 wouldn't have t │ │ │ +000642b0: 6f20 7368 6966 7420 6974 206c 6174 6572 o shift it later │ │ │ +000642c0: 3c2f 6832 3e3c 6834 3e2e 2e2f 7372 632f

    ../src/ │ │ │ +000642d0: 7065 5f63 7279 7074 6f2e 6370 703a 3232 pe_crypto.cpp:22 │ │ │ +000642e0: 363c 2f68 343e 3c70 7265 2073 7479 6c65 6

    │ │ │ +00064320: 0909 7265 7475 726e 2074 7275 653b 0a09  ..return true;..
    │ │ │ +00064330: 7d0a 0a23 656c 7365 202f 2f20 544f 5252  }..#else // TORR
    │ │ │ +00064340: 454e 545f 5553 455f 4c49 4243 5259 5054  ENT_USE_LIBCRYPT
    │ │ │ +00064350: 4f0a 0a09 6468 5f6b 6579 5f65 7863 6861  O...dh_key_excha
    │ │ │ +00064360: 6e67 653a 3a6b 6579 5f74 2063 6f6e 7374  nge::key_t const
    │ │ │ +00064370: 2661 6d70 3b20 6468 5f6b 6579 5f65 7863  & dh_key_exc
    │ │ │ +00064380: 6861 6e67 653a 3a64 685f 7072 696d 6528  hange::dh_prime(
    │ │ │ +00064390: 290a 097b 0a09 0973 7461 7469 6320 6b65  )..{...static ke
    │ │ │ +000643a0: 795f 7420 636f 6e73 7420 7072 696d 6528  y_t const prime(
    │ │ │ +000643b0: 0a09 0909 2230 7846 4646 4646 4646 4646  ...."0xFFFFFFFFF
    │ │ │ +000643c0: 4646 4646 4646 4643 3930 4644 4141 3232  FFFFFFFC90FDAA22
    │ │ │ +000643d0: 3136 3843 3233 3443 3443 3636 3238 4238  168C234C4C6628B8
    │ │ │ +000643e0: 3044 4331 4344 3132 3930 3234 4530 3838  0DC1CD129024E088
    │ │ │ +000643f0: 4136 3743 4337 3430 3230 4242 4541 3633  A67CC74020BBEA63
    │ │ │ +00064400: 4231 3339 4232 3235 3134 4122 0a09 0909  B139B22514A"....
    │ │ │ +00064410: 2230 3837 3938 4533 3430 3444 4445 4639  "08798E3404DDEF9
    │ │ │ +00064420: 3531 3942 3343 4433 4134 3331 4233 3032  519B3CD3A431B302
    │ │ │ +00064430: 4230 4136 4446 3235 4631 3433 3734 4645  B0A6DF25F14374FE
    │ │ │ +00064440: 3133 3536 4436 4435 3143 3234 3545 3438  1356D6D51C245E48
    │ │ │ +00064450: 3542 3537 3636 3235 4537 4543 3646 3434  5B576625E7EC6F44
    │ │ │ +00064460: 4334 3245 3941 3622 0a09 0909 2233 4133  C42E9A6"...."3A3
    │ │ │ +00064470: 3632 3130 3030 3030 3030 3030 3030 3930  6210000000000090
    │ │ │ +00064480: 3536 3322 293b 0a09 0972 6574 7572 6e20  563");...return 
    │ │ │ +00064490: 7072 696d 653b 0a09 7d0a 0a09 7374 643a  prime;..}...std:
    │ │ │ +000644a0: 3a61 7272 6179 266c 743b 6368 6172 2c20  :array<char, 
    │ │ │ +000644b0: 3936 2667 743b 2064 685f 6b65 795f 6578  96> dh_key_ex
    │ │ │ +000644c0: 6368 616e 6765 3a3a 6578 706f 7274 5f6b  change::export_k
    │ │ │ +000644d0: 6579 286b 6579 5f74 2063 6f6e 7374 2661  ey(key_t const&a
    │ │ │ +000644e0: 6d70 3b20 6b29 0a09 7b0a 0909 7374 643a  mp; k)..{...std:
    │ │ │ +000644f0: 3a61 7272 6179 266c 743b 6368 6172 2c20  :array<char, 
    │ │ │ +00064500: 3936 2667 743b 2072 6574 3b0a 0909 6175  96> ret;...au
    │ │ │ +00064510: 746f 2a20 6265 6769 6e20 3d20 7265 696e  to* begin = rein
    │ │ │ +00064520: 7465 7270 7265 745f 6361 7374 266c 743b  terpret_cast<
    │ │ │ +00064530: 7374 643a 3a75 696e 7438 5f74 2a26 6774  std::uint8_t*>
    │ │ │ +00064540: 3b28 7265 742e 6461 7461 2829 293b 0a09  ;(ret.data());..
    │ │ │ +00064550: 0973 7464 3a3a 7569 6e74 385f 742a 2065  .std::uint8_t* e
    │ │ │ +00064560: 6e64 203d 206d 703a 3a65 7870 6f72 745f  nd = mp::export_
    │ │ │ +00064570: 6269 7473 286b 2c20 6265 6769 6e2c 2038  bits(k, begin, 8
    │ │ │ +00064580: 293b 0a0a 3c64 6976 2073 7479 6c65 3d22  );..
    ..if (end < │ │ │ +000645c0: 2062 6567 696e 202b 2039 3629 0a3c 2f64 begin + 96)...{....int co │ │ │ +000645e0: 6e73 7420 6c65 6e20 3d20 696e 7428 656e nst len = int(en │ │ │ +000645f0: 6420 2d20 6265 6769 6e29 3b0a 2369 6620 d - begin);.#if │ │ │ +00064600: 6465 6669 6e65 6420 5f5f 474e 5543 5f5f defined __GNUC__ │ │ │ +00064610: 2026 616d 703b 2661 6d70 3b20 5f5f 474e && __GN │ │ │ +00064620: 5543 5f5f 203d 3d20 3132 0a23 7072 6167 UC__ == 12.#prag │ │ │ +00064630: 6d61 2047 4343 2064 6961 676e 6f73 7469 ma GCC diagnosti │ │ │ +00064640: 6320 7075 7368 0a23 7072 6167 6d61 2047 c push.#pragma G │ │ │ +00064650: 4343 2064 6961 676e 6f73 7469 6320 6967 CC diagnostic ig │ │ │ +00064660: 6e6f 7265 6420 222d 5773 7472 696e 676f nored "-Wstringo │ │ │ +00064670: 702d 6f76 6572 666c 6f77 220a 2365 6e64 p-overflow".#end │ │ │ +00064680: 6966 0a09 0909 7374 643a 3a6d 656d 6d6f if....std::memmo │ │ │ +00064690: 7665 2862 6567 696e 202b 2039 3620 2d20 ve(begin + 96 - │ │ │ +000646a0: 6c65 6e2c 2062 6567 696e 2c20 6175 783a len, begin, aux: │ │ │ +000646b0: 3a6e 756d 6572 6963 5f63 6173 7426 6c74 :numeric_cast< │ │ │ +000646c0: 3b73 7464 3a3a 7369 7a65 5f74 2667 743b ;std::size_t> │ │ │ +000646d0: 286c 656e 2929 3b0a 2369 6620 6465 6669 (len));.#if defi │ │ │ +000646e0: 6e65 6420 5f5f 474e 5543 5f5f 2026 616d ned __GNUC__ &am │ │ │ +000646f0: 703b 2661 6d70 3b20 5f5f 474e 5543 5f5f p;& __GNUC__ │ │ │ +00064700: 203d 3d20 3132 0a23 7072 6167 6d61 2047 == 12.#pragma G │ │ │ +00064710: 4343 2064 6961 676e 6f73 7469 6320 706f CC diagnostic po │ │ │ +00064720: 700a 2365 6e64 6966 0a09 0909 7374 643a p.#endif....std: │ │ │ +00064730: 3a6d 656d 7365 7428 6265 6769 6e2c 2030 :memset(begin, 0 │ │ │ +00064740: 2c20 6175 783a 3a6e 756d 6572 6963 5f63 , aux::numeric_c │ │ │ +00064750: 6173 7426 6c74 3b73 7464 3a3a 7369 7a65 ast<std::size │ │ │ +00064760: 5f74 2667 743b 2839 3620 2d20 6c65 6e29 _t>(96 - len) │ │ │ +00064770: 293b 0a09 097d 0a09 0972 6574 7572 6e20 );...}...return │ │ │ +00064780: 7265 743b 0a09 7d0a 0a09 2f2f 2053 6574 ret;..}...// Set │ │ │ +00064790: 2074 6865 2070 7269 6d65 2050 2061 6e64 the prime P and │ │ │ +000647a0: 2074 6865 2067 656e 6572 6174 6f72 2c20 the generator, │ │ │ +000647b0: 6765 6e65 7261 7465 206c 6f63 616c 2070 generate local p │ │ │ +000647c0: 7562 6c69 6320 6b65 790a 0964 685f 6b65 ublic key..dh_ke │ │ │ +000647d0: 795f 6578 6368 616e 6765 3a3a 6468 5f6b y_exchange::dh_k │ │ │ +000647e0: 6579 5f65 7863 6861 6e67 6528 290a 097b ey_exchange()..{ │ │ │ +000647f0: 0a09 0961 7578 3a3a 6172 7261 7926 6c74 ...aux::array< │ │ │ +00064800: 3b73 7464 3a3a 7569 6e74 385f 742c 2032 ;std::uint8_t, 2 │ │ │ +00064810: 3026 6774 3b20 7261 6e64 6f6d 5f6b 6579 0> random_key │ │ │ +00064820: 3b0a 0909 6175 783a 3a72 616e 646f 6d5f ;...aux::random_ │ │ │ +00064830: 6279 7465 7328 7b72 6569 6e74 6572 7072 bytes({reinterpr │ │ │ +00064840: 6574 5f63 6173 7426 6c74 3b63 6861 722a et_cast<char* │ │ │ +00064850: 2667 743b 2872 616e 646f 6d5f 6b65 792e >(random_key. │ │ │ +00064860: 6461 7461 2829 TRUNCATED DUE TO SIZE LIMIT: 10485760 bytes